1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding --
5 -- Terminal_Interface.Curses.Termcap --
9 ------------------------------------------------------------------------------
10 -- Copyright (c) 2000,2004 Free Software Foundation, Inc. --
12 -- Permission is hereby granted, free of charge, to any person obtaining a --
13 -- copy of this software and associated documentation files (the --
14 -- "Software"), to deal in the Software without restriction, including --
15 -- without limitation the rights to use, copy, modify, merge, publish, --
16 -- distribute, distribute with modifications, sublicense, and/or sell --
17 -- copies of the Software, and to permit persons to whom the Software is --
18 -- furnished to do so, subject to the following conditions: --
20 -- The above copyright notice and this permission notice shall be included --
21 -- in all copies or substantial portions of the Software. --
23 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
24 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
25 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
26 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
27 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
28 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
29 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
31 -- Except as contained in this notice, the name(s) of the above copyright --
32 -- holders shall not be used in advertising or otherwise to promote the --
33 -- sale, use or other dealings in this Software without prior written --
35 ------------------------------------------------------------------------------
36 -- Author: Juergen Pfeifer, 1996
39 -- Binding Version 01.00
40 ------------------------------------------------------------------------------
42 with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
43 with Interfaces.C; use Interfaces.C;
44 with Interfaces.C.Strings; use Interfaces.C.Strings;
46 package body Terminal_Interface.Curses.Termcap is
48 function Get_Entry (Name : String) return Boolean
50 function tgetent (name : char_array; val : char_array)
52 pragma Import (C, tgetent, "tgetent");
53 NameTxt : char_array (0 .. Name'Length);
55 ignored : char_array (0 .. 0) := (0 => nul);
58 To_C (Name, NameTxt, Length);
59 result := tgetent (char_array (ignored), NameTxt);
61 raise Curses_Exception;
63 return Boolean'Val (result);
67 ------------------------------------------------------------------------------
68 function Get_Flag (Name : String) return Boolean
70 function tgetflag (id : char_array) return C_Int;
71 pragma Import (C, tgetflag, "tgetflag");
72 Txt : char_array (0 .. Name'Length);
75 To_C (Name, Txt, Length);
76 if tgetflag (Txt) = 0 then
83 ------------------------------------------------------------------------------
84 procedure Get_Number (Name : in String;
88 function tgetnum (id : char_array) return C_Int;
89 pragma Import (C, tgetnum, "tgetnum");
90 Txt : char_array (0 .. Name'Length);
93 To_C (Name, Txt, Length);
94 Value := Integer (tgetnum (Txt));
102 ------------------------------------------------------------------------------
103 procedure Get_String (Name : String;
105 Result : out Boolean)
107 function tgetstr (id : char_array;
108 buf : char_array) return chars_ptr;
109 pragma Import (C, tgetstr, "tgetstr");
110 Txt : char_array (0 .. Name'Length);
113 type t is new char_array (0 .. 1024); -- does it need to be 1024?
114 Return_Buffer : t := (others => nul);
116 To_C (Name, Txt, Length);
117 Txt2 := tgetstr (Txt, char_array (Return_Buffer));
118 if Txt2 = Null_Ptr then
121 Value := Fill_String (Txt2);
126 function Get_String (Name : String) return Boolean
128 function tgetstr (Id : char_array;
129 buf : char_array) return chars_ptr;
130 pragma Import (C, tgetstr, "tgetstr");
131 Txt : char_array (0 .. Name'Length);
134 type t is new char_array (0 .. 1024); -- does it need to be 1024?
135 Phony_Txt : t := (others => nul);
137 To_C (Name, Txt, Length);
138 Txt2 := tgetstr (Txt, char_array (Phony_Txt));
139 if Txt2 = Null_Ptr then
146 ------------------------------------------------------------------------------
147 function TGoto (Cap : String;
148 Col : Column_Position;
149 Row : Line_Position) return Termcap_String is
150 function tgoto (cap : char_array;
152 row : C_Int) return chars_ptr;
153 pragma Import (C, tgoto);
154 Txt : char_array (0 .. Cap'Length);
157 To_C (Cap, Txt, Length);
158 return Termcap_String (Fill_String
159 (tgoto (Txt, C_Int (Col), C_Int (Row))));
163 end Terminal_Interface.Curses.Termcap;