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 ncurses2.util; use ncurses2.util;
43 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
44 with Ada.Strings.Fixed;
46 procedure ncurses2.color_test is
49 procedure show_color_name (y, x : Integer; color : Integer);
51 color_names : constant array (0 .. 15) of String (1 .. 7) :=
72 procedure show_color_name (y, x : Integer; color : Integer) is
73 tmp5 : String (1 .. 5);
75 if Number_Of_Colors > 8 then
78 Add (Line => Line_Position (y), Column => Column_Position (x),
81 Add (Line => Line_Position (y), Column => Column_Position (x),
82 Str => color_names (color));
88 hello : String (1 .. 5);
89 -- tmp3 : String (1 .. 3);
90 -- tmp2 : String (1 .. 2);
94 Add (Str => "There are ");
95 -- Put(tmp3, Number_Of_Colors*Number_Of_Colors);
96 Add (Str => Ada.Strings.Fixed.Trim (Integer'Image (Number_Of_Colors *
99 Add (Str => " color pairs");
102 if Number_Of_Colors > 8 then
108 if Number_Of_Colors > 8 then
114 for Bright in Boolean loop
115 if Number_Of_Colors > 8 then
118 top := Boolean'Pos (Bright) * (Number_Of_Colors + 3);
120 Clear_To_End_Of_Screen;
121 Move_Cursor (Line => Line_Position (top) + 1, Column => 0);
122 -- Put(tmp2, Number_Of_Colors);
123 Add (Str => Ada.Strings.Fixed.Trim (Integer'Image (Number_Of_Colors),
126 Add (Str => Ada.Strings.Fixed.Trim (Integer'Image (Number_Of_Colors),
128 Add (Str => " matrix of foreground/background colors, bright *");
136 for i in 0 .. Number_Of_Colors - 1 loop
137 show_color_name (top + 2, (i + 1) * width, i);
139 for i in 0 .. Number_Of_Colors - 1 loop
140 show_color_name (top + 3 + i, 0, i);
142 for i in 1 .. Number_Of_Color_Pairs - 1 loop
143 Init_Pair (Color_Pair (i), Color_Number (i mod Number_Of_Colors),
144 Color_Number (i / Number_Of_Colors));
145 -- attron((attr_t) COLOR_PAIR(i)) -- Huh?
146 Set_Color (Pair => Color_Pair (i));
148 Switch_Character_Attribute (Attr => (Bold_Character => True,
151 Add (Line => Line_Position (top + 3 + (i / Number_Of_Colors)),
152 Column => Column_Position ((i mod Number_Of_Colors + 1) *
155 Set_Character_Attributes;
157 if Number_Of_Colors > 8 or Bright then
164 end ncurses2.color_test;