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