1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding Samples --
9 ------------------------------------------------------------------------------
10 -- Copyright 2020 Thomas E. Dickey --
11 -- Copyright 2000 Free Software Foundation, Inc. --
13 -- Permission is hereby granted, free of charge, to any person obtaining a --
14 -- copy of this software and associated documentation files (the --
15 -- "Software"), to deal in the Software without restriction, including --
16 -- without limitation the rights to use, copy, modify, merge, publish, --
17 -- distribute, distribute with modifications, sublicense, and/or sell --
18 -- copies of the Software, and to permit persons to whom the Software is --
19 -- furnished to do so, subject to the following conditions: --
21 -- The above copyright notice and this permission notice shall be included --
22 -- in all copies or substantial portions of the Software. --
24 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
25 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
26 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
27 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
28 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
29 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
30 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
32 -- Except as contained in this notice, the name(s) of the above copyright --
33 -- holders shall not be used in advertising or otherwise to promote the --
34 -- sale, use or other dealings in this Software without prior written --
36 ------------------------------------------------------------------------------
37 -- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
40 -- Binding Version 01.00
41 ------------------------------------------------------------------------------
42 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
43 with ncurses2.util; use ncurses2.util;
45 procedure ncurses2.flushinp_test (win : Window) is
47 procedure Continue (win : Window);
49 procedure Continue (win : Window) is
51 Set_Echo_Mode (False);
52 Move_Cursor (win, 10, 1);
53 Add (win, 10, 1, " Press any key to continue");
58 h, by, sh : Line_Position;
59 w, bx, sw : Column_Position;
66 Get_Window_Position (win, by, bx);
69 subWin := Sub_Window (win, sh, sw, by + h - sh - 2, bx + w - sw - 2);
72 Init_Pair (2, Cyan, Blue);
73 Change_Background (subWin,
74 Attributed_Character'(Ch => ' ', Color => 2,
75 Attr => Normal_Video));
78 Set_Character_Attributes (subWin,
79 (Bold_Character => True, others => False));
81 Add (subWin, 2, 1, "This is a subwindow");
84 Set_Cbreak_Mode (True);
85 Add (win, 0, 1, "This is a test of the flushinp() call.");
87 Add (win, 2, 1, "Type random keys for 5 seconds.");
89 "These should be discarded (not echoed) after the subwindow " &
94 Move_Cursor (subWin, 1, 1);
95 Add (subWin, Str => "Time = ");
96 Add (subWin, Str => Integer'Image (i));
98 Nap_Milli_Seconds (1000);
106 Nap_Milli_Seconds (1000);
109 Str => "If you were still typing when the window timer expired,");
111 "or else you typed nothing at all while it was running,");
113 "test was invalid. You'll see garbage or nothing at all. ");
114 Add (win, 6, 1, "Press a key");
115 Move_Cursor (win, 9, 10);
117 Set_Echo_Mode (True);
121 "If you see any key other than what you typed, flushinp() is broken.");
124 Move_Cursor (win, 9, 10);
125 Delete_Character (win);
127 Move_Cursor (win, 12, 0);
128 Clear_To_End_Of_Line;
130 "What you typed should now have been deleted; if not, wdelch() " &
134 Set_Cbreak_Mode (True);
136 end ncurses2.flushinp_test;