1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding Samples --
9 ------------------------------------------------------------------------------
10 -- Copyright 2020,2021 Thomas E. Dickey --
11 -- Copyright 2000-2014,2015 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 -- $Date: 2021/09/04 10:52:55 $
41 -- Binding Version 01.00
42 ------------------------------------------------------------------------------
43 with ncurses2.util; use ncurses2.util;
44 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
46 -- test effects of overlapping windows
48 procedure ncurses2.overlap_test is
50 procedure fillwin (win : Window; ch : Character);
51 procedure crosswin (win : Window; ch : Character);
53 procedure fillwin (win : Window; ch : Character) is
57 Get_Size (win, y1, x1);
58 for y in 0 .. y1 - 1 loop
59 Move_Cursor (win, y, 0);
60 for x in 0 .. x1 - 1 loop
65 when Curses_Exception => null;
66 -- write to lower right corner
69 procedure crosswin (win : Window; ch : Character) is
73 Get_Size (win, y1, x1);
74 for y in 0 .. y1 - 1 loop
75 for x in 0 .. x1 - 1 loop
76 if ((x > (x1 - 1) / 3) and (x <= (2 * (x1 - 1)) / 3)) or
77 (((y > (y1 - 1) / 3) and (y <= (2 * (y1 - 1)) / 3)))
79 Move_Cursor (win, y, x);
86 -- In a 24x80 screen like some xterms are, the instructions will
89 win1 : Window := New_Window (9, 20, 3, 3);
90 win2 : Window := New_Window (9, 20, 9, 16);
92 Set_Raw_Mode (SwitchOn => True);
94 Move_Cursor (Line => 0, Column => 0);
95 Add (Str => "This test shows the behavior of wnoutrefresh() with " &
98 Add (Str => "the shared region of two overlapping windows A and B. " &
101 Add (Str => "pattern in each window does not overlap the other.");
104 Move_Cursor (Line => 18, Column => 0);
105 Add (Str => "a = refresh A, then B, then doupdate. b = refresh B, " &
106 "then A, then doupdate");
108 Add (Str => "c = fill window A with letter A. d = fill window B " &
111 Add (Str => "e = cross pattern in window A. f = cross pattern " &
114 Add (Str => "g = clear window A. h = clear window B.");
116 Add (Str => "i = overwrite A onto B. j = overwrite " &
119 Add (Str => "^Q/ESC = terminate test.");
122 ch := Code_To_Char (Getchar);
123 exit when ch = CTRL ('Q') or ch = CTRL ('['); -- QUIT or ESCAPE
125 when 'a' => -- refresh window A first, then B
126 Refresh_Without_Update (win1);
127 Refresh_Without_Update (win2);
129 when 'b' => -- refresh window B first, then A
130 Refresh_Without_Update (win2);
131 Refresh_Without_Update (win1);
133 when 'c' => -- fill window A so it is visible
135 when 'd' => -- fill window B so it is visible
137 when 'e' => -- cross test pattern in window A
138 crosswin (win1, 'A');
139 when 'f' => -- cross test pattern in window B
140 crosswin (win2, 'B');
141 when 'g' => -- clear window A
143 Move_Cursor (win1, 0, 0);
144 when 'h' => -- clear window B
146 Move_Cursor (win2, 0, 0);
147 when 'i' => -- overwrite A onto B
148 Overwrite (win1, win2);
149 when 'j' => -- overwrite B onto A
150 Overwrite (win2, win1);
159 end ncurses2.overlap_test;