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