1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding Samples --
5 -- Sample.Text_IO_Demo --
11 -- The ncurses Ada95 binding is copyrighted 1996 by --
12 -- Juergen Pfeifer, Email: Juergen.Pfeifer@T-Online.de --
14 -- Permission is hereby granted to reproduce and distribute this --
15 -- binding by any means and for any fee, whether alone or as part --
16 -- of a larger distribution, in source or in binary form, PROVIDED --
17 -- this notice is included with any such distribution, and is not --
18 -- removed from any of its header files. Mention of ncurses and the --
19 -- author of this binding in any applications linked with it is --
20 -- highly appreciated. --
22 -- This binding comes AS IS with no warranty, implied or expressed. --
23 ------------------------------------------------------------------------------
26 ------------------------------------------------------------------------------
27 with Ada.Numerics.Generic_Elementary_Functions;
28 with Ada.Numerics.Complex_Types;
29 use Ada.Numerics.Complex_Types;
31 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
32 with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
33 with Terminal_Interface.Curses.Text_IO;
34 use Terminal_Interface.Curses.Text_IO;
35 with Terminal_Interface.Curses.Text_IO.Integer_IO;
36 with Terminal_Interface.Curses.Text_IO.Float_IO;
37 with Terminal_Interface.Curses.Text_IO.Enumeration_IO;
38 with Terminal_Interface.Curses.Text_IO.Complex_IO;
39 with Terminal_Interface.Curses.Text_IO.Fixed_IO;
40 with Terminal_Interface.Curses.Text_IO.Decimal_IO;
41 with Terminal_Interface.Curses.Text_IO.Modular_IO;
43 with Sample.Manifest; use Sample.Manifest;
44 with Sample.Helpers; use Sample.Helpers;
45 with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
46 with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
47 with Sample.Explanation; use Sample.Explanation;
49 package body Sample.Text_IO_Demo is
51 type Weekday is (Sunday,
59 type Fix is delta 0.1 range 0.0 .. 4.0;
60 type Dec is delta 0.01 digits 5 range 0.0 .. 4.0;
64 Ada.Numerics.Generic_Elementary_Functions (Float);
67 Terminal_Interface.Curses.Text_IO.Integer_IO (Integer);
70 package Real_IO is new
71 Terminal_Interface.Curses.Text_IO.Float_IO (Float);
74 package Enum_IO is new
75 Terminal_Interface.Curses.Text_IO.Enumeration_IO (Weekday);
79 Terminal_Interface.Curses.Text_IO.Complex_IO (Ada.Numerics.Complex_Types);
83 Terminal_Interface.Curses.Text_IO.Fixed_IO (Fix);
87 Terminal_Interface.Curses.Text_IO.Decimal_IO (Dec);
91 Terminal_Interface.Curses.Text_IO.Modular_IO (Md);
97 P : Panel := Create (Standard_Window);
99 Im : Complex := (0.0, 1.0);
105 Push_Environment ("TEXTIO");
107 Notepad ("TEXTIO-PAD00");
109 Set_Echo_Mode (FALSE);
113 W := Sub_Window (Standard_Window, Lines - 2, Columns - 2, 1, 1);
115 Refresh_Without_Update;
118 Immediate_Update_Mode (W, True);
122 for I in 1 .. 10 loop
123 Put ("Square root of ");
124 Put (Item => I, Width => 5);
126 Put (Item => Math.Sqrt (Float (I)), Exp => 0, Aft => 7);
130 for W in Weekday loop
131 Put (Item => W); Put (' ');
137 for J in Md'Range loop
150 if K in Special_Key_Code'Range then
152 when QUIT_CODE => exit;
153 when HELP_CODE => Explain_Context;
154 when EXPLAIN_CODE => Explain ("TEXTIOKEYS");
160 Set_Window (Null_Window);
161 Erase; Refresh_Without_Update;
168 end Sample.Text_IO_Demo;