1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding --
5 -- Terminal_Interface.Curses.Aux --
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 ------------------------------------------------------------------------------
29 with Interfaces.C.Strings; use Interfaces.C.Strings;
30 with Unchecked_Conversion;
32 package Terminal_Interface.Curses.Aux is
34 use type Interfaces.C.Int;
36 subtype C_Int is Interfaces.C.Int;
37 subtype C_Short is Interfaces.C.Short;
38 subtype C_Long_Int is Interfaces.C.Long;
39 subtype C_Size_T is Interfaces.C.Size_T;
40 subtype C_Char_Ptr is Interfaces.C.Strings.Chars_Ptr;
41 type C_Void_Ptr is new System.Address;
43 -- This is how those constants are defined in ncurses. I see them also
44 -- exactly like this in all ETI implementations I ever tested. So it
45 -- could be that this is quite general, but please check with your curses.
46 -- This is critical, because curses sometime mixes boolean returns with
47 -- returning an error status.
48 Curses_Ok : constant C_Int := 0;
49 Curses_Err : constant C_Int := -1;
51 Curses_True : constant C_Int := 1;
52 Curses_False : constant C_Int := 0;
54 subtype Eti_Error is C_Int range -14 .. 0;
55 -- Type for error codes returned by the menu and forms subsystem
57 E_Ok : constant Eti_Error := 0;
58 E_System_Error : constant Eti_Error := -1;
59 E_Bad_Argument : constant Eti_Error := -2;
60 E_Posted : constant Eti_Error := -3;
61 E_Connected : constant Eti_Error := -4;
62 E_Bad_State : constant Eti_Error := -5;
63 E_No_Room : constant Eti_Error := -6;
64 E_Not_Posted : constant Eti_Error := -7;
65 E_Unknown_Command : constant Eti_Error := -8;
66 E_No_Match : constant Eti_Error := -9;
67 E_Not_Selectable : constant Eti_Error := -10;
68 E_Not_Connected : constant Eti_Error := -11;
69 E_Request_Denied : constant Eti_Error := -12;
70 E_Invalid_Field : constant Eti_Error := -13;
71 E_Current : constant Eti_Error := -14;
73 procedure Eti_Exception (Code : Eti_Error);
74 -- Dispatch the error code and raise the appropriate exception
78 function CInt_To_Chtype is new
79 Unchecked_Conversion (Source => C_Int,
80 Target => Attributed_Character);
81 function Chtype_To_CInt is new
82 Unchecked_Conversion (Source => Attributed_Character,
85 procedure Fill_String (Cp : in chars_ptr;
87 -- Fill the Str parameter with the string denoted by the chars_ptr
90 end Terminal_Interface.Curses.Aux;