aboutsummaryrefslogtreecommitdiff
path: root/Ada95/samples/sample-curses_demo-attributes.adb
blob: b0f60d4a3465691d332d3063f444c262747a25e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
------------------------------------------------------------------------------
--                                                                          --
--                       GNAT ncurses Binding Samples                       --
--                                                                          --
--                       Sample.Curses_Demo.Attributes                      --
--                                                                          --
--                                 B O D Y                                  --
--                                                                          --
------------------------------------------------------------------------------
-- Copyright (c) 1998,2003 Free Software Foundation, Inc.                   --
--                                                                          --
-- Permission is hereby granted, free of charge, to any person obtaining a  --
-- copy of this software and associated documentation files (the            --
-- "Software"), to deal in the Software without restriction, including      --
-- without limitation the rights to use, copy, modify, merge, publish,      --
-- distribute, distribute with modifications, sublicense, and/or sell       --
-- copies of the Software, and to permit persons to whom the Software is    --
-- furnished to do so, subject to the following conditions:                 --
--                                                                          --
-- The above copyright notice and this permission notice shall be included  --
-- in all copies or substantial portions of the Software.                   --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --
--                                                                          --
-- Except as contained in this notice, the name(s) of the above copyright   --
-- holders shall not be used in advertising or otherwise to promote the     --
-- sale, use or other dealings in this Software without prior written       --
-- authorization.                                                           --
------------------------------------------------------------------------------
--  Author:  Juergen Pfeifer, 1996
--  Version Control
--  $Revision: 1.13 $
--  Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Panels;  use Terminal_Interface.Curses.Panels;

with Sample.Manifest; use Sample.Manifest;
with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
with Sample.Explanation; use Sample.Explanation;

package body Sample.Curses_Demo.Attributes is

   procedure Demo
   is
      P : Panel := Create (Standard_Window);
      K : Real_Key_Code;
   begin
      Set_Meta_Mode;
      Set_KeyPad_Mode;

      Top (P);

      Push_Environment ("ATTRIBDEMO");
      Default_Labels;
      Notepad ("ATTRIB-PAD00");

      Set_Character_Attributes (Attr => (others => False));
      Add (Line => 1, Column => Columns / 2 - 10,
           Str => "This is NORMAL");

      Set_Character_Attributes (Attr => (Stand_Out => True,
                                          others => False));
      Add (Line => 2, Column => Columns / 2 - 10,
           Str => "This is Stand_Out");

      Set_Character_Attributes (Attr => (Under_Line => True,
                                          others => False));
      Add (Line => 3, Column => Columns / 2 - 10,
           Str => "This is Under_Line");

      Set_Character_Attributes (Attr => (Reverse_Video => True,
                                          others => False));
      Add (Line => 4, Column => Columns / 2 - 10,
           Str => "This is Reverse_Video");

      Set_Character_Attributes (Attr => (Blink => True,
                                          others => False));
      Add (Line => 5, Column => Columns / 2 - 10,
           Str => "This is Blink");

      Set_Character_Attributes (Attr => (Dim_Character => True,
                                          others => False));
      Add (Line => 6, Column => Columns / 2 - 10,
           Str => "This is Dim_Character");

      Set_Character_Attributes (Attr => (Bold_Character => True,
                                          others => False));
      Add (Line => 7, Column => Columns / 2 - 10,
           Str => "This is Bold_Character");

      Refresh_Without_Update;
      Update_Panels; Update_Screen;

      loop
         K := Get_Key;
         if K in Special_Key_Code'Range then
            case K is
               when QUIT_CODE     => exit;
               when HELP_CODE     => Explain_Context;
               when EXPLAIN_CODE  => Explain ("ATTRIBKEYS");
               when others        => null;
            end case;
         end if;
      end loop;

      Pop_Environment;
      Clear;
      Refresh_Without_Update;
      Delete (P);
      Update_Panels; Update_Screen;

   end Demo;

end Sample.Curses_Demo.Attributes;