missing ncurses sources
[tomato.git] / release / src / router / libncurses / Ada95 / samples / ncurses2-test_sgr_attributes.adb
blob97449a40cafcff23cef234faf415ce8df40ecab9
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT ncurses Binding Samples --
4 -- --
5 -- ncurses --
6 -- --
7 -- B O D Y --
8 -- --
9 ------------------------------------------------------------------------------
10 -- Copyright (c) 2000,2006 Free Software Foundation, Inc. --
11 -- --
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: --
19 -- --
20 -- The above copyright notice and this permission notice shall be included --
21 -- in all copies or substantial portions of the Software. --
22 -- --
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. --
30 -- --
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 --
34 -- authorization. --
35 ------------------------------------------------------------------------------
36 -- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
37 -- Version Control
38 -- $Revision: 1.2 $
39 -- $Date: 2006/06/25 14:24:40 $
40 -- Binding Version 01.00
41 ------------------------------------------------------------------------------
42 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
43 with ncurses2.util; use ncurses2.util;
45 -- Graphic-rendition test (adapted from vttest)
47 procedure ncurses2.test_sgr_attributes is
49 procedure xAdd (l : Line_Position; c : Column_Position; s : String);
51 procedure xAdd (l : Line_Position; c : Column_Position; s : String) is
52 begin
53 Add (Line => l, Column => c, Str => s);
54 end xAdd;
56 normal, current : Attributed_Character;
57 begin
58 for pass in reverse Boolean loop
59 if pass then
60 normal := (Ch => ' ', Attr => Normal_Video, Color => 0);
61 else
62 normal := (Ch => ' ', Attr =>
63 (Reverse_Video => True, others => False), Color => 0);
64 end if;
66 -- Use non-default colors if possible to exercise bce a little
67 if Has_Colors then
68 Init_Pair (1, White, Blue);
69 normal.Color := 1;
70 end if;
71 Set_Background (Ch => normal);
72 Erase;
73 xAdd (1, 20, "Graphic rendition test pattern:");
75 xAdd (4, 1, "vanilla");
77 current := normal;
78 current.Attr.Bold_Character := not current.Attr.Bold_Character;
79 Set_Background (Ch => current);
80 xAdd (4, 40, "bold");
82 current := normal;
83 current.Attr.Under_Line := not current.Attr.Under_Line;
84 Set_Background (Ch => current);
85 xAdd (6, 6, "underline");
87 current := normal;
88 current.Attr.Bold_Character := not current.Attr.Bold_Character;
89 current.Attr.Under_Line := not current.Attr.Under_Line;
90 Set_Background (Ch => current);
91 xAdd (6, 45, "bold underline");
93 current := normal;
94 current.Attr.Blink := not current.Attr.Blink;
95 Set_Background (Ch => current);
96 xAdd (8, 1, "blink");
98 current := normal;
99 current.Attr.Blink := not current.Attr.Blink;
100 current.Attr.Bold_Character := not current.Attr.Bold_Character;
101 Set_Background (Ch => current);
102 xAdd (8, 40, "bold blink");
104 current := normal;
105 current.Attr.Under_Line := not current.Attr.Under_Line;
106 current.Attr.Blink := not current.Attr.Blink;
107 Set_Background (Ch => current);
108 xAdd (10, 6, "underline blink");
110 current := normal;
111 current.Attr.Bold_Character := not current.Attr.Bold_Character;
112 current.Attr.Under_Line := not current.Attr.Under_Line;
113 current.Attr.Blink := not current.Attr.Blink;
114 Set_Background (Ch => current);
115 xAdd (10, 45, "bold underline blink");
117 current := normal;
118 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
119 Set_Background (Ch => current);
120 xAdd (12, 1, "negative");
122 current := normal;
123 current.Attr.Bold_Character := not current.Attr.Bold_Character;
124 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
125 Set_Background (Ch => current);
126 xAdd (12, 40, "bold negative");
128 current := normal;
129 current.Attr.Under_Line := not current.Attr.Under_Line;
130 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
131 Set_Background (Ch => current);
132 xAdd (14, 6, "underline negative");
134 current := normal;
135 current.Attr.Bold_Character := not current.Attr.Bold_Character;
136 current.Attr.Under_Line := not current.Attr.Under_Line;
137 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
138 Set_Background (Ch => current);
139 xAdd (14, 45, "bold underline negative");
141 current := normal;
142 current.Attr.Blink := not current.Attr.Blink;
143 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
144 Set_Background (Ch => current);
145 xAdd (16, 1, "blink negative");
147 current := normal;
148 current.Attr.Bold_Character := not current.Attr.Bold_Character;
149 current.Attr.Blink := not current.Attr.Blink;
150 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
151 Set_Background (Ch => current);
152 xAdd (16, 40, "bold blink negative");
154 current := normal;
155 current.Attr.Under_Line := not current.Attr.Under_Line;
156 current.Attr.Blink := not current.Attr.Blink;
157 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
158 Set_Background (Ch => current);
159 xAdd (18, 6, "underline blink negative");
161 current := normal;
162 current.Attr.Bold_Character := not current.Attr.Bold_Character;
163 current.Attr.Under_Line := not current.Attr.Under_Line;
164 current.Attr.Blink := not current.Attr.Blink;
165 current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
166 Set_Background (Ch => current);
167 xAdd (18, 45, "bold underline blink negative");
169 Set_Background (Ch => normal);
170 Move_Cursor (Line => Lines - 2, Column => 1);
171 if pass then
172 Add (Str => "Dark");
173 else
174 Add (Str => "Light");
175 end if;
176 Add (Str => " background. ");
177 Clear_To_End_Of_Line;
178 Pause;
179 end loop;
181 Set_Background (Ch => Blank2);
182 Erase;
183 End_Windows;
185 end ncurses2.test_sgr_attributes;