1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding Samples --
5 -- Sample.Text_IO_Demo --
9 ------------------------------------------------------------------------------
10 -- Copyright 2018,2020 Thomas E. Dickey --
11 -- Copyright 1998-2006,2011 Free Software Foundation, Inc. --
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: --
21 -- The above copyright notice and this permission notice shall be included --
22 -- in all copies or substantial portions of the Software. --
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. --
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 --
36 ------------------------------------------------------------------------------
37 -- Author: Juergen Pfeifer, 1996
40 -- $Date: 2020/02/02 23:34:34 $
41 -- Binding Version 01.00
42 ------------------------------------------------------------------------------
43 with Ada.Numerics.Generic_Elementary_Functions;
45 with Ada.Numerics.Complex_Types;
46 use Ada.Numerics.Complex_Types;
48 with Terminal_Interface.Curses;
49 use Terminal_Interface.Curses;
51 with Terminal_Interface.Curses.Panels;
52 use Terminal_Interface.Curses.Panels;
54 with Terminal_Interface.Curses.Text_IO;
55 use Terminal_Interface.Curses.Text_IO;
57 with Terminal_Interface.Curses.Text_IO.Integer_IO;
58 with Terminal_Interface.Curses.Text_IO.Float_IO;
59 with Terminal_Interface.Curses.Text_IO.Enumeration_IO;
60 with Terminal_Interface.Curses.Text_IO.Complex_IO;
61 with Terminal_Interface.Curses.Text_IO.Decimal_IO;
62 with Terminal_Interface.Curses.Text_IO.Modular_IO;
64 with Sample.Manifest; use Sample.Manifest;
65 with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
66 with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
67 with Sample.Explanation; use Sample.Explanation;
69 pragma Elaborate_All (Terminal_Interface.Curses.Text_Io.Complex_IO);
70 pragma Elaborate_All (Terminal_Interface.Curses.Text_Io.Decimal_IO);
71 pragma Elaborate_All (Terminal_Interface.Curses.Text_Io.Enumeration_IO);
72 pragma Elaborate_All (Terminal_Interface.Curses.Text_Io.Float_IO);
73 pragma Elaborate_All (Terminal_Interface.Curses.Text_Io.Integer_IO);
74 pragma Elaborate_All (Terminal_Interface.Curses.Text_Io.Modular_IO);
76 package body Sample.Text_IO_Demo is
78 type Weekday is (Sunday,
86 type Dec is delta 0.01 digits 5 range 0.0 .. 4.0;
90 Ada.Numerics.Generic_Elementary_Functions (Float);
93 Terminal_Interface.Curses.Text_IO.Integer_IO (Integer);
96 package Real_IO is new
97 Terminal_Interface.Curses.Text_IO.Float_IO (Float);
100 package Enum_IO is new
101 Terminal_Interface.Curses.Text_IO.Enumeration_IO (Weekday);
105 Terminal_Interface.Curses.Text_IO.Complex_IO (Ada.Numerics.Complex_Types);
109 Terminal_Interface.Curses.Text_IO.Decimal_IO (Dec);
113 Terminal_Interface.Curses.Text_IO.Modular_IO (Md);
119 P : Panel := Create (Standard_Window);
121 Im : constant Complex := (0.0, 1.0);
122 Fx : constant Dec := 3.14;
123 Dc : constant Dec := 2.72;
127 Push_Environment ("TEXTIO");
129 Notepad ("TEXTIO-PAD00");
131 Set_Echo_Mode (False);
134 W := Sub_Window (Standard_Window, Lines - 2, Columns - 2, 1, 1);
136 Refresh_Without_Update;
139 Immediate_Update_Mode (W, True);
143 for I in 1 .. 10 loop
144 Put ("Square root of ");
145 Put (Item => I, Width => 5);
147 Put (Item => Math.Sqrt (Float (I)), Exp => 0, Aft => 7);
151 for W in Weekday loop
152 Put (Item => W); Put (' ');
158 for J in Md'Range loop
171 if K in Special_Key_Code'Range then
173 when QUIT_CODE => exit;
174 when HELP_CODE => Explain_Context;
175 when EXPLAIN_CODE => Explain ("TEXTIOKEYS");
181 Set_Window (Null_Window);
182 Erase; Refresh_Without_Update;
189 end Sample.Text_IO_Demo;