| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT ncurses Binding Samples -- |
| 4 |
-- -- |
| 5 |
-- ncurses -- |
| 6 |
-- -- |
| 7 |
-- B O D Y -- |
| 8 |
-- -- |
| 9 |
------------------------------------------------------------------------------ |
| 10 |
-- Copyright 2020 Thomas E. Dickey -- |
| 11 |
-- Copyright 2000,2006 Free Software Foundation, Inc. -- |
| 12 |
-- -- |
| 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: -- |
| 20 |
-- -- |
| 21 |
-- The above copyright notice and this permission notice shall be included -- |
| 22 |
-- in all copies or substantial portions of the Software. -- |
| 23 |
-- -- |
| 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. -- |
| 31 |
-- -- |
| 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 -- |
| 35 |
-- authorization. -- |
| 36 |
------------------------------------------------------------------------------ |
| 37 |
-- Author: Eugene V. Melaragno <[email protected]> 2000 |
| 38 |
-- Version Control |
| 39 |
-- $Revision: 1.3 $ |
| 40 |
-- $Date: 2020/02/02 23:34:34 $ |
| 41 |
-- Binding Version 01.00 |
| 42 |
------------------------------------------------------------------------------ |
| 43 |
with Terminal_Interface.Curses; use Terminal_Interface.Curses; |
| 44 |
with ncurses2.util; use ncurses2.util; |
| 45 |
|
| 46 |
-- Graphic-rendition test (adapted from vttest) |
| 47 |
|
| 48 |
procedure ncurses2.test_sgr_attributes is |
| 49 |
|
| 50 |
procedure xAdd (l : Line_Position; c : Column_Position; s : String); |
| 51 |
|
| 52 |
procedure xAdd (l : Line_Position; c : Column_Position; s : String) is |
| 53 |
begin |
| 54 |
Add (Line => l, Column => c, Str => s); |
| 55 |
end xAdd; |
| 56 |
|
| 57 |
normal, current : Attributed_Character; |
| 58 |
begin |
| 59 |
for pass in reverse Boolean loop |
| 60 |
if pass then |
| 61 |
normal := (Ch => ' ', Attr => Normal_Video, Color => 0); |
| 62 |
else |
| 63 |
normal := (Ch => ' ', Attr => |
| 64 |
(Reverse_Video => True, others => False), Color => 0); |
| 65 |
end if; |
| 66 |
|
| 67 |
-- Use non-default colors if possible to exercise bce a little |
| 68 |
if Has_Colors then |
| 69 |
Init_Pair (1, White, Blue); |
| 70 |
normal.Color := 1; |
| 71 |
end if; |
| 72 |
Set_Background (Ch => normal); |
| 73 |
Erase; |
| 74 |
xAdd (1, 20, "Graphic rendition test pattern:"); |
| 75 |
|
| 76 |
xAdd (4, 1, "vanilla"); |
| 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; |