]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/samples/ncurses2-test_sgr_attributes.adb
9948dc59c320fbd18c77012682b46e77863502c0
[ncurses.git] / Ada95 / samples / ncurses2-test_sgr_attributes.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                       GNAT ncurses Binding Samples                       --
4 --                                                                          --
5 --                                 ncurses                                  --
6 --                                                                          --
7 --                                 B O D Y                                  --
8 --                                                                          --
9 ------------------------------------------------------------------------------
10 -- Copyright (c) 2000 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.1 $
39 --  Binding Version 01.00
40 ------------------------------------------------------------------------------
41 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
42 with ncurses2.util; use ncurses2.util;
43
44
45 --  Graphic-rendition test (adapted from vttest)
46
47 procedure ncurses2.test_sgr_attributes is
48
49    procedure xAdd (l : Line_Position; c : Column_Position; s : String);
50
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;
55
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;
65
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:");
74
75       xAdd (4, 1, "vanilla");
76
77
78       current := normal;
79       current.Attr.Bold_Character := not current.Attr.Bold_Character;
80       Set_Background (Ch => current);
81       xAdd (4, 40, "bold");
82
83       current := normal;
84       current.Attr.Under_Line := not current.Attr.Under_Line;
85       Set_Background (Ch => current);
86       xAdd (6, 6, "underline");
87
88       current := normal;
89       current.Attr.Bold_Character  := not current.Attr.Bold_Character;
90       current.Attr.Under_Line := not current.Attr.Under_Line;
91       Set_Background (Ch => current);
92       xAdd (6, 45, "bold underline");
93
94       current := normal;
95       current.Attr.Blink := not current.Attr.Blink;
96       Set_Background (Ch => current);
97       xAdd (8, 1, "blink");
98
99       current := normal;
100       current.Attr.Blink  := not current.Attr.Blink;
101       current.Attr.Bold_Character := not current.Attr.Bold_Character;
102       Set_Background (Ch => current);
103       xAdd (8, 40, "bold blink");
104
105       current := normal;
106       current.Attr.Under_Line  := not current.Attr.Under_Line;
107       current.Attr.Blink := not current.Attr.Blink;
108       Set_Background (Ch => current);
109       xAdd (10, 6, "underline blink");
110
111       current := normal;
112       current.Attr.Bold_Character  := not current.Attr.Bold_Character;
113       current.Attr.Under_Line  := not current.Attr.Under_Line;
114       current.Attr.Blink := not current.Attr.Blink;
115       Set_Background (Ch => current);
116       xAdd (10, 45, "bold underline blink");
117
118       current := normal;
119       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
120       Set_Background (Ch => current);
121       xAdd (12, 1, "negative");
122
123       current := normal;
124       current.Attr.Bold_Character  := not current.Attr.Bold_Character;
125       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
126       Set_Background (Ch => current);
127       xAdd (12, 40, "bold negative");
128
129       current := normal;
130       current.Attr.Under_Line  := not current.Attr.Under_Line;
131       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
132       Set_Background (Ch => current);
133       xAdd (14, 6, "underline negative");
134
135       current := normal;
136       current.Attr.Bold_Character  := not current.Attr.Bold_Character;
137       current.Attr.Under_Line  := not current.Attr.Under_Line;
138       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
139       Set_Background (Ch => current);
140       xAdd (14, 45, "bold underline negative");
141
142       current := normal;
143       current.Attr.Blink  := not current.Attr.Blink;
144       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
145       Set_Background (Ch => current);
146       xAdd (16, 1, "blink negative");
147
148       current := normal;
149       current.Attr.Bold_Character  := not current.Attr.Bold_Character;
150       current.Attr.Blink  := not current.Attr.Blink;
151       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
152       Set_Background (Ch => current);
153       xAdd (16, 40, "bold blink negative");
154
155       current := normal;
156       current.Attr.Under_Line  := not current.Attr.Under_Line;
157       current.Attr.Blink  := not current.Attr.Blink;
158       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
159       Set_Background (Ch => current);
160       xAdd (18, 6, "underline blink negative");
161
162       current := normal;
163       current.Attr.Bold_Character  := not current.Attr.Bold_Character;
164       current.Attr.Under_Line  := not current.Attr.Under_Line;
165       current.Attr.Blink  := not current.Attr.Blink;
166       current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
167       Set_Background (Ch => current);
168       xAdd (18, 45, "bold underline blink negative");
169
170       Set_Background (Ch => normal);
171       Move_Cursor (Line => Lines - 2, Column => 1);
172       if pass then
173          Add (Str => "Dark");
174       else
175          Add (Str => "Light");
176       end if;
177       Add (Str => " background. ");
178       Clear_To_End_Of_Line;
179       Pause;
180    end loop;
181
182    Set_Background (Ch => Blank2);
183    Erase;
184    End_Windows;
185
186 end ncurses2.test_sgr_attributes;