ncurses 5.3
[ncurses.git] / doc / html / ada / terminal_interface-curses-termcap__adb.htm
1 <HTML><HEAD><TITLE>terminal_interface-curses-termcap.adb</TITLE></HEAD>
2 <BODY>
3 <HR><DIV ALIGN="center"><H1> File : terminal_interface-curses-termcap.adb </H1></DIV><HR>
4 <PRE>
5 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
6 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
7 <FONT COLOR=green><EM>--                           <A HREF="http://www.gnat.com">GNAT</A> ncurses Binding                           --</EM></FONT>
8 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
9 <FONT COLOR=green><EM>--                    Terminal_Interface.Curses.Termcap                     --</EM></FONT>
10 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
11 <FONT COLOR=green><EM>--                                 B O D Y                                  --</EM></FONT>
12 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
13 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
14 <FONT COLOR=green><EM>-- Copyright (c) 2000 Free Software Foundation, Inc.                        --</EM></FONT>
15 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
16 <FONT COLOR=green><EM>-- Permission is hereby granted, free of charge, to any person obtaining a  --</EM></FONT>
17 <FONT COLOR=green><EM>-- copy of this software and associated documentation files (the            --</EM></FONT>
18 <FONT COLOR=green><EM>-- "Software"), to deal in the Software without restriction, including      --</EM></FONT>
19 <FONT COLOR=green><EM>-- without limitation the rights to use, copy, modify, merge, publish,      --</EM></FONT>
20 <FONT COLOR=green><EM>-- distribute, distribute with modifications, sublicense, and/or sell       --</EM></FONT>
21 <FONT COLOR=green><EM>-- copies of the Software, and to permit persons to whom the Software is    --</EM></FONT>
22 <FONT COLOR=green><EM>-- furnished to do so, subject to the following conditions:                 --</EM></FONT>
23 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
24 <FONT COLOR=green><EM>-- The above copyright notice and this permission notice shall be included  --</EM></FONT>
25 <FONT COLOR=green><EM>-- in all copies or substantial portions of the Software.                   --</EM></FONT>
26 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
27 <FONT COLOR=green><EM>-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --</EM></FONT>
28 <FONT COLOR=green><EM>-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --</EM></FONT>
29 <FONT COLOR=green><EM>-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --</EM></FONT>
30 <FONT COLOR=green><EM>-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --</EM></FONT>
31 <FONT COLOR=green><EM>-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --</EM></FONT>
32 <FONT COLOR=green><EM>-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --</EM></FONT>
33 <FONT COLOR=green><EM>-- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --</EM></FONT>
34 <FONT COLOR=green><EM>--                                                                          --</EM></FONT>
35 <FONT COLOR=green><EM>-- Except as contained in this notice, the name(s) of the above copyright   --</EM></FONT>
36 <FONT COLOR=green><EM>-- holders shall not be used in advertising or otherwise to promote the     --</EM></FONT>
37 <FONT COLOR=green><EM>-- sale, use or other dealings in this Software without prior written       --</EM></FONT>
38 <FONT COLOR=green><EM>-- authorization.                                                           --</EM></FONT>
39 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
40 <FONT COLOR=green><EM>--  Author:  <A HREF="http://www.familiepfeifer.de/juergen">J&uuml;rgen Pfeifer</A>, 1996</EM></FONT>
41 <FONT COLOR=green><EM>--  Contact: <A HREF="http://www.familiepfeifer.de/Contact.aspx?Lang=en">www.familiepfeifer.de/Contact.aspx?Lang=en</A></EM></FONT>
42 <FONT COLOR=green><EM>--  Version Control:</EM></FONT>
43 <FONT COLOR=green><EM>--  @Revision: 1.4 @</EM></FONT>
44 <FONT COLOR=green><EM>--  Binding Version 01.00</EM></FONT>
45 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
46
47 <b>with</b> <A HREF="terminal_interface__ads.htm#42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#49_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#51_35">Aux</A>; <b>use</b> <A HREF="terminal_interface__ads.htm#42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#49_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#51_35">Aux</A>;
48 <b>with</b> <A HREF="interfac__ads.htm#23_9">Interfaces</A>.C; <b>use</b> <A HREF="interfac__ads.htm#23_9">Interfaces</A>.C;
49 <b>with</b> <A HREF="interfac__ads.htm#23_9">Interfaces</A>.C.Strings; <b>use</b> <A HREF="interfac__ads.htm#23_9">Interfaces</A>.C.Strings;
50
51 <b>package</b> <b>body</b> <A HREF="terminal_interface__ads.htm#42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#49_28">Curses</A>.<A HREF="terminal_interface-curses-termcap__ads.htm#43_35">Termcap</A><FONT COLOR=red><A NAME="47_40"></A></FONT> <b>is</b>
52
53    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#60_13">Get_Entry</A><FONT COLOR=red><A NAME="49_13"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#60_24">Name</A> : String) <b>return</b> Boolean
54    <b>is</b>
55       <b>function</b> <FONT COLOR=red><A NAME="51_16">tgetent</A></FONT> (<FONT COLOR=red><A NAME="51_25">name</A></FONT> : char_array; <FONT COLOR=red><A NAME="51_44">val</A></FONT> : char_array)
56                         <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
57       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#51_16">tgetent</A>, "tgetent");
58       <FONT COLOR=red><A NAME="54_7">NameTxt</A></FONT> : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#60_24">Name</A>'Length);
59       <FONT COLOR=red><A NAME="55_7">Length</A></FONT>  : size_t;
60       <FONT COLOR=red><A NAME="56_7">ignored</A></FONT> : char_array (0 .. 0) := (0 =&gt; nul);
61       <FONT COLOR=red><A NAME="57_7">result</A></FONT>  : <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
62    <b>begin</b>
63       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#60_24">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#54_7">NameTxt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#55_7">Length</A>);
64       <A HREF="terminal_interface-curses-termcap__adb.htm#57_7">result</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#51_16">tgetent</A> (char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#56_7">ignored</A>), <A HREF="terminal_interface-curses-termcap__adb.htm#54_7">NameTxt</A>);
65       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#57_7">result</A> = -1 <b>then</b>
66          <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#383_4">Curses_Exception</A>;
67       <b>else</b>
68          <b>return</b> Boolean'Val (<A HREF="terminal_interface-curses-termcap__adb.htm#57_7">result</A>);
69       <b>end</b> <b>if</b>;
70    <b>end</b> Get_Entry;
71
72 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
73    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#64_13">Get_Flag</A><FONT COLOR=red><A NAME="69_13"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#64_23">Name</A> : String) <b>return</b> Boolean
74    <b>is</b>
75       <b>function</b> <FONT COLOR=red><A NAME="71_16">tgetflag</A></FONT> (<FONT COLOR=red><A NAME="71_26">id</A></FONT> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
76       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#71_16">tgetflag</A>, "tgetflag");
77       <FONT COLOR=red><A NAME="73_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#64_23">Name</A>'Length);
78       <FONT COLOR=red><A NAME="74_7">Length</A></FONT> : size_t;
79    <b>begin</b>
80       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#64_23">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#73_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#74_7">Length</A>);
81       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#71_16">tgetflag</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#73_7">Txt</A>) = 0 <b>then</b>
82          <b>return</b> False;
83       <b>else</b>
84          <b>return</b> True;
85       <b>end</b> <b>if</b>;
86    <b>end</b> Get_Flag;
87
88 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
89    <b>procedure</b> <A HREF="terminal_interface-curses-termcap__ads.htm#68_14">Get_Number</A><FONT COLOR=red><A NAME="85_14"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#68_26">Name</A>   : <b>in</b>  String;
90                          <A HREF="terminal_interface-curses-termcap__ads.htm#69_26">Value</A>  : <b>out</b> Integer;
91                          <A HREF="terminal_interface-curses-termcap__ads.htm#70_26">Result</A> : <b>out</b> Boolean)
92    <b>is</b>
93       <b>function</b> <FONT COLOR=red><A NAME="89_16">tgetnum</A></FONT> (<FONT COLOR=red><A NAME="89_25">id</A></FONT> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
94       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#89_16">tgetnum</A>, "tgetnum");
95       <FONT COLOR=red><A NAME="91_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#68_26">Name</A>'Length);
96       <FONT COLOR=red><A NAME="92_7">Length</A></FONT> : size_t;
97    <b>begin</b>
98       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#68_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#91_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#92_7">Length</A>);
99       <A HREF="terminal_interface-curses-termcap__ads.htm#69_26">Value</A> := Integer (<A HREF="terminal_interface-curses-termcap__adb.htm#89_16">tgetnum</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#91_7">Txt</A>));
100       <b>if</b> <A HREF="terminal_interface-curses-termcap__ads.htm#69_26">Value</A> = -1 <b>then</b>
101          <A HREF="terminal_interface-curses-termcap__ads.htm#70_26">Result</A> := False;
102       <b>else</b>
103          <A HREF="terminal_interface-curses-termcap__ads.htm#70_26">Result</A> :=  True;
104       <b>end</b> <b>if</b>;
105    <b>end</b> Get_Number;
106
107 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
108    <b>procedure</b> <A HREF="terminal_interface-curses-termcap__ads.htm#74_14">Get_String</A><FONT COLOR=red><A NAME="104_14"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#74_26">Name</A>   : String;
109                          <A HREF="terminal_interface-curses-termcap__ads.htm#75_26">Value</A>  : <b>out</b> String;
110                          <A HREF="terminal_interface-curses-termcap__ads.htm#76_26">Result</A> : <b>out</b> Boolean)
111    <b>is</b>
112       <b>function</b> <FONT COLOR=red><A NAME="108_16">tgetstr</A></FONT> (<FONT COLOR=red><A NAME="108_25">id</A></FONT>  : char_array;
113                         <FONT COLOR=red><A NAME="109_25">buf</A></FONT> : char_array) <b>return</b> chars_ptr;
114       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#108_16">tgetstr</A>, "tgetstr");
115       <FONT COLOR=red><A NAME="111_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#74_26">Name</A>'Length);
116       <FONT COLOR=red><A NAME="112_7">Length</A></FONT> : size_t;
117       <FONT COLOR=red><A NAME="113_7">Txt2</A></FONT>   : chars_ptr;
118       <b>type</b> <FONT COLOR=red><A NAME="114_12">t</A></FONT> <b>is</b> <b>new</b> char_array (0 .. 1024); <FONT COLOR=green><EM>--  does it need to be 1024?</EM></FONT>
119       <FONT COLOR=red><A NAME="115_7">Return_Buffer</A></FONT> : <A HREF="terminal_interface-curses-termcap__adb.htm#114_12">t</A> := (0 =&gt; nul);
120    <b>begin</b>
121       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#74_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#111_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#112_7">Length</A>);
122       <A HREF="terminal_interface-curses-termcap__adb.htm#113_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#108_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#111_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#115_7">Return_Buffer</A>));
123       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#113_7">Txt2</A> = Null_Ptr <b>then</b>
124          <A HREF="terminal_interface-curses-termcap__ads.htm#76_26">Result</A> := False;
125       <b>else</b>
126          <A HREF="terminal_interface-curses-termcap__ads.htm#75_26">Value</A> := <A HREF="terminal_interface-curses-aux__ads.htm#122_13">Fill_String</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#113_7">Txt2</A>);
127          <A HREF="terminal_interface-curses-termcap__ads.htm#76_26">Result</A> := True;
128       <b>end</b> <b>if</b>;
129    <b>end</b> Get_String;
130
131    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#77_13">Get_String</A><FONT COLOR=red><A NAME="127_13"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#77_25">Name</A> : String) <b>return</b> Boolean
132    <b>is</b>
133       <b>function</b> <FONT COLOR=red><A NAME="129_16">tgetstr</A></FONT> (<FONT COLOR=red><A NAME="129_25">Id</A></FONT>  : char_array;
134                         <FONT COLOR=red><A NAME="130_25">buf</A></FONT> : char_array) <b>return</b> chars_ptr;
135       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#129_16">tgetstr</A>, "tgetstr");
136       <FONT COLOR=red><A NAME="132_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#77_25">Name</A>'Length);
137       <FONT COLOR=red><A NAME="133_7">Length</A></FONT> : size_t;
138       <FONT COLOR=red><A NAME="134_7">Txt2</A></FONT>   : chars_ptr;
139       <b>type</b> <FONT COLOR=red><A NAME="135_12">t</A></FONT> <b>is</b> <b>new</b> char_array (0 .. 1024); <FONT COLOR=green><EM>--  does it need to be 1024?</EM></FONT>
140       <FONT COLOR=red><A NAME="136_7">Phony_Txt</A></FONT> : <A HREF="terminal_interface-curses-termcap__adb.htm#135_12">t</A> := (0 =&gt; nul);
141    <b>begin</b>
142       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#77_25">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#132_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#133_7">Length</A>);
143       <A HREF="terminal_interface-curses-termcap__adb.htm#134_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#129_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#132_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#136_7">Phony_Txt</A>));
144       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#134_7">Txt2</A> = Null_Ptr <b>then</b>
145          <b>return</b> False;
146       <b>else</b>
147          <b>return</b> True;
148       <b>end</b> <b>if</b>;
149    <b>end</b> Get_String;
150
151 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
152    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#54_13">TGoto</A><FONT COLOR=red><A NAME="148_13"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#54_20">Cap</A> : String;
153                    <A HREF="terminal_interface-curses-termcap__ads.htm#55_20">Col</A> : <A HREF="terminal_interface-curses__ads.htm#61_9">Column_Position</A>;
154                    <A HREF="terminal_interface-curses-termcap__ads.htm#56_20">Row</A> : <A HREF="terminal_interface-curses__ads.htm#60_9">Line_Position</A>) <b>return</b> <A HREF="terminal_interface-curses-termcap__ads.htm#51_9">Termcap_String</A> <b>is</b>
155       <b>function</b> <FONT COLOR=red><A NAME="151_16">tgoto</A></FONT> (<FONT COLOR=red><A NAME="151_23">cap</A></FONT> : char_array;
156                       <FONT COLOR=red><A NAME="152_23">col</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
157                       <FONT COLOR=red><A NAME="153_23">row</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>) <b>return</b> chars_ptr;
158       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#151_16">tgoto</A>);
159       <FONT COLOR=red><A NAME="155_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#54_20">Cap</A>'Length);
160       <FONT COLOR=red><A NAME="156_7">Length</A></FONT> : size_t;
161    <b>begin</b>
162       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#54_20">Cap</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#155_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#156_7">Length</A>);
163       <b>return</b> <A HREF="terminal_interface-curses-termcap__ads.htm#51_9">Termcap_String</A> (<A HREF="terminal_interface-curses-aux__ads.htm#122_13">Fill_String</A>
164                              (<A HREF="terminal_interface-curses-termcap__adb.htm#151_16">tgoto</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#155_7">Txt</A>, <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#55_20">Col</A>), <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#56_20">Row</A>))));
165    <b>end</b> TGoto;
166
167
168 <b>end</b> Terminal_Interface.Curses.Termcap;
169 </PRE></BODY></HTML>