1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding Samples --
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.Characters.Latin_1; use Ada.Characters.Latin_1;
28 with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
30 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
31 with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
32 with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
33 with Terminal_Interface.Curses.Forms.Field_User_Data;
34 with Terminal_Interface.Curses.Forms.Form_User_Data;
36 with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
37 with Sample.My_Field_Type; use Sample.My_Field_Type;
38 with Sample.Manifest; use Sample.Manifest;
39 with Sample.Explanation; use Sample.Explanation;
40 with Sample.Form_Demo.Aux; use Sample.Form_Demo.Aux;
41 with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
42 with Sample.Form_Demo.Handler;
44 package body Sample.Form_Demo is
50 type User_Access is access User_Data;
53 Terminal_Interface.Curses.Forms.Field_User_Data (User_Data,
57 Terminal_Interface.Curses.Forms.Form_User_Data (User_Data,
60 Enums : constant Enum_Array := (new String'("alpha"),
62 new String'("gamma"));
64 Enum_Info : constant Enumeration_Info := (Enums'Length, Enums,
67 Enum_Field : constant Enumeration_Field := Create (Enum_Info, True);
72 Mft : My_Data := (Ch => 'X');
74 FA : Field_Array (1 .. 9) := (Make (0, 14, "Sample Entry Form"),
75 Make (2, 0, "An Enumeration"),
76 Make (2, 20, "Numeric 1-10"),
77 Make (2, 34, "Only 'X'"),
79 "Multiple Lines offscreen (Scroll)"),
81 Make (Width => 18, Top => 3, Left => 0),
82 Make (Width => 12, Top => 3, Left => 20),
83 Make (Width => 12, Top => 3, Left => 34),
84 Make (Width => 46, Top => 6, Left => 0,
85 Height => 4, Off_Screen => 2)
88 Frm : Terminal_Interface.Curses.Forms.Form := Create (FA);
90 I_F : constant Integer_Field := (Precision => 0,
96 package Fh is new Sample.Form_Demo.Handler (Default_Driver);
99 Push_Environment ("FORM00");
100 Notepad ("FORM-PAD00");
103 Set_Type (FA (6), Enum_Field);
104 Set_Type (FA (7), I_F);
105 Set_Type (FA (8), Mft);
107 F1 := new User_Data'(Data => 4711);
108 Fld_U.Set_User_Data (FA (1), F1);
112 Fld_U.Get_User_Data (FA (1), F2);
113 pragma Assert (F1 = F2);
114 pragma Assert (F1.Data = F2.Data);
119 for I in FA'Range loop
124 end Sample.Form_Demo;