blob: b90b8dd61d504d4eb37f7c33a6427a1f4a21fdae [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301-- -*- ada -*-
2define(`HTMLNAME',`terminal_interface-curses-aux__ads.htm')dnl
3include(M4MACRO)dnl
4------------------------------------------------------------------------------
5-- --
6-- GNAT ncurses Binding --
7-- --
8-- Terminal_Interface.Curses.Aux --
9-- --
10-- S P E C --
11-- --
12------------------------------------------------------------------------------
Steve Kondikae271bc2015-11-15 02:50:53 +010013-- Copyright (c) 1998-2011,2014 Free Software Foundation, Inc. --
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053014-- --
15-- Permission is hereby granted, free of charge, to any person obtaining a --
16-- copy of this software and associated documentation files (the --
17-- "Software"), to deal in the Software without restriction, including --
18-- without limitation the rights to use, copy, modify, merge, publish, --
19-- distribute, distribute with modifications, sublicense, and/or sell --
20-- copies of the Software, and to permit persons to whom the Software is --
21-- furnished to do so, subject to the following conditions: --
22-- --
23-- The above copyright notice and this permission notice shall be included --
24-- in all copies or substantial portions of the Software. --
25-- --
26-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
27-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
28-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
29-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
30-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
31-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
32-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
33-- --
34-- Except as contained in this notice, the name(s) of the above copyright --
35-- holders shall not be used in advertising or otherwise to promote the --
36-- sale, use or other dealings in this Software without prior written --
37-- authorization. --
38------------------------------------------------------------------------------
39-- Author: Juergen Pfeifer, 1996
40-- Version Control:
Steve Kondikae271bc2015-11-15 02:50:53 +010041-- $Revision: 1.23 $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053042-- Binding Version 01.00
43------------------------------------------------------------------------------
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053044with System;
45with Interfaces.C;
46with Interfaces.C.Strings; use Interfaces.C.Strings;
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047
48package Terminal_Interface.Curses.Aux is
49 pragma Preelaborate (Terminal_Interface.Curses.Aux);
50
51 use type Interfaces.C.int;
52
53 subtype C_Int is Interfaces.C.int;
54 subtype C_Short is Interfaces.C.short;
55 subtype C_Long_Int is Interfaces.C.long;
56 subtype C_Size_T is Interfaces.C.size_t;
57 subtype C_UInt is Interfaces.C.unsigned;
58 subtype C_ULong is Interfaces.C.unsigned_long;
59 subtype C_Char_Ptr is Interfaces.C.Strings.chars_ptr;
60 type C_Void_Ptr is new System.Address;
Steve Kondikae271bc2015-11-15 02:50:53 +010061
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053062 -- This is how those constants are defined in ncurses. I see them also
63 -- exactly like this in all ETI implementations I ever tested. So it
64 -- could be that this is quite general, but please check with your curses.
Steve Kondikae271bc2015-11-15 02:50:53 +010065 -- This is critical, because curses sometime mixes Boolean returns with
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053066 -- returning an error status.
Steve Kondikae271bc2015-11-15 02:50:53 +010067 Curses_Ok : constant C_Int := Curses_Constants.OK;
68 Curses_Err : constant C_Int := Curses_Constants.ERR;
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053069
Steve Kondikae271bc2015-11-15 02:50:53 +010070 Curses_True : constant C_Int := Curses_Constants.TRUE;
71 Curses_False : constant C_Int := Curses_Constants.FALSE;
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053072
73 -- Eti_Error: type for error codes returned by the menu and form subsystem
Steve Kondikae271bc2015-11-15 02:50:53 +010074 type Eti_Error is
75 (E_Current,
76 E_Invalid_Field,
77 E_Request_Denied,
78 E_Not_Connected,
79 E_Not_Selectable,
80 E_No_Match,
81 E_Unknown_Command,
82 E_Not_Posted,
83 E_No_Room,
84 E_Bad_State,
85 E_Connected,
86 E_Posted,
87 E_Bad_Argument,
88 E_System_Error,
89 E_Ok);
90
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053091 procedure Eti_Exception (Code : Eti_Error);
Steve Kondikae271bc2015-11-15 02:50:53 +010092 -- Do nothing if Code = E_Ok.
93 -- Else dispatch the error code and raise the appropriate exception.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053094
Steve Kondikae271bc2015-11-15 02:50:53 +010095 procedure Fill_String (Cp : chars_ptr;
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053096 Str : out String);
97 -- Fill the Str parameter with the string denoted by the chars_ptr
98 -- C-Style string.
99
100 function Fill_String (Cp : chars_ptr) return String;
101 -- Same but as function.
102
Steve Kondikae271bc2015-11-15 02:50:53 +0100103private
104 for Eti_Error'Size use C_Int'Size;
105 pragma Convention (C, Eti_Error);
106 for Eti_Error use
107 (E_Current => Curses_Constants.E_CURRENT,
108 E_Invalid_Field => Curses_Constants.E_INVALID_FIELD,
109 E_Request_Denied => Curses_Constants.E_REQUEST_DENIED,
110 E_Not_Connected => Curses_Constants.E_NOT_CONNECTED,
111 E_Not_Selectable => Curses_Constants.E_NOT_SELECTABLE,
112 E_No_Match => Curses_Constants.E_NO_MATCH,
113 E_Unknown_Command => Curses_Constants.E_UNKNOWN_COMMAND,
114 E_Not_Posted => Curses_Constants.E_NOT_POSTED,
115 E_No_Room => Curses_Constants.E_NO_ROOM,
116 E_Bad_State => Curses_Constants.E_BAD_STATE,
117 E_Connected => Curses_Constants.E_CONNECTED,
118 E_Posted => Curses_Constants.E_POSTED,
119 E_Bad_Argument => Curses_Constants.E_BAD_ARGUMENT,
120 E_System_Error => Curses_Constants.E_SYSTEM_ERROR,
121 E_Ok => Curses_Constants.E_OK);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530122end Terminal_Interface.Curses.Aux;