ncurses 5.4
[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:  Juergen Pfeifer, 1996</EM></FONT>
41 <FONT COLOR=green><EM>--  Version Control:</EM></FONT>
42 <FONT COLOR=green><EM>--  @Revision: 1.5 @</EM></FONT>
43 <FONT COLOR=green><EM>--  Binding Version 01.00</EM></FONT>
44 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
45
46 <b>with</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#50_35">Aux</A>; <b>use</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#50_35">Aux</A>;
47 <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;
48 <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;
49
50 <b>package</b> <b>body</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-termcap__ads.htm#42_35">Termcap</A> <b>is</b>
51
52    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#59_13">Get_Entry</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#59_24">Name</A> : String) <b>return</b> Boolean
53    <b>is</b>
54       <b>function</b> <FONT COLOR=red><A NAME="50_16">tgetent</A></FONT> (<FONT COLOR=red><A NAME="50_25">name</A></FONT> : char_array; <FONT COLOR=red><A NAME="50_44">val</A></FONT> : char_array)
55                         <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A>;
56       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#50_16">tgetent</A>, "tgetent");
57       <FONT COLOR=red><A NAME="53_7">NameTxt</A></FONT> : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#59_24">Name</A>'Length);
58       <FONT COLOR=red><A NAME="54_7">Length</A></FONT>  : size_t;
59       <FONT COLOR=red><A NAME="55_7">ignored</A></FONT> : char_array (0 .. 0) := (0 =&gt; nul);
60       <FONT COLOR=red><A NAME="56_7">result</A></FONT>  : <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A>;
61    <b>begin</b>
62       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#59_24">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#53_7">NameTxt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#54_7">Length</A>);
63       <A HREF="terminal_interface-curses-termcap__adb.htm#56_7">result</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#50_16">tgetent</A> (char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#55_7">ignored</A>), <A HREF="terminal_interface-curses-termcap__adb.htm#53_7">NameTxt</A>);
64       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#56_7">result</A> = -1 <b>then</b>
65          <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#382_4">Curses_Exception</A>;
66       <b>else</b>
67          <b>return</b> Boolean'Val (<A HREF="terminal_interface-curses-termcap__adb.htm#56_7">result</A>);
68       <b>end</b> <b>if</b>;
69    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#59_13">Get_Entry</A><A HREF="terminal_interface-curses-termcap__ads.htm#59_13">;</A>
70
71 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
72    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#63_13">Get_Flag</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#63_23">Name</A> : String) <b>return</b> Boolean
73    <b>is</b>
74       <b>function</b> <FONT COLOR=red><A NAME="70_16">tgetflag</A></FONT> (<FONT COLOR=red><A NAME="70_26">id</A></FONT> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A>;
75       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#70_16">tgetflag</A>, "tgetflag");
76       <FONT COLOR=red><A NAME="72_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#63_23">Name</A>'Length);
77       <FONT COLOR=red><A NAME="73_7">Length</A></FONT> : size_t;
78    <b>begin</b>
79       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#63_23">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#72_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#73_7">Length</A>);
80       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#70_16">tgetflag</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#72_7">Txt</A>) = 0 <b>then</b>
81          <b>return</b> False;
82       <b>else</b>
83          <b>return</b> True;
84       <b>end</b> <b>if</b>;
85    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#63_13">Get_Flag</A><A HREF="terminal_interface-curses-termcap__ads.htm#63_13">;</A>
86
87 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
88    <b>procedure</b> <A HREF="terminal_interface-curses-termcap__ads.htm#67_14">Get_Number</A><FONT COLOR=red><A NAME="84_14"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#67_26">Name</A>   : <b>in</b>  String;
89                          <A HREF="terminal_interface-curses-termcap__ads.htm#68_26">Value</A>  : <b>out</b> Integer;
90                          <A HREF="terminal_interface-curses-termcap__ads.htm#69_26">Result</A> : <b>out</b> Boolean)
91    <b>is</b>
92       <b>function</b> <FONT COLOR=red><A NAME="88_16">tgetnum</A></FONT> (<FONT COLOR=red><A NAME="88_25">id</A></FONT> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A>;
93       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#88_16">tgetnum</A>, "tgetnum");
94       <FONT COLOR=red><A NAME="90_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#67_26">Name</A>'Length);
95       <FONT COLOR=red><A NAME="91_7">Length</A></FONT> : size_t;
96    <b>begin</b>
97       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#67_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#90_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#91_7">Length</A>);
98       <A HREF="terminal_interface-curses-termcap__ads.htm#68_26">Value</A> := Integer (<A HREF="terminal_interface-curses-termcap__adb.htm#88_16">tgetnum</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#90_7">Txt</A>));
99       <b>if</b> <A HREF="terminal_interface-curses-termcap__ads.htm#68_26">Value</A> = -1 <b>then</b>
100          <A HREF="terminal_interface-curses-termcap__ads.htm#69_26">Result</A> := False;
101       <b>else</b>
102          <A HREF="terminal_interface-curses-termcap__ads.htm#69_26">Result</A> :=  True;
103       <b>end</b> <b>if</b>;
104    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#67_14">Get_Number</A><A HREF="terminal_interface-curses-termcap__ads.htm#67_14">;</A>
105
106 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
107    <b>procedure</b> <A HREF="terminal_interface-curses-termcap__ads.htm#73_14">Get_String</A><FONT COLOR=red><A NAME="103_14"></A></FONT> (<A HREF="terminal_interface-curses-termcap__ads.htm#73_26">Name</A>   : String;
108                          <A HREF="terminal_interface-curses-termcap__ads.htm#74_26">Value</A>  : <b>out</b> String;
109                          <A HREF="terminal_interface-curses-termcap__ads.htm#75_26">Result</A> : <b>out</b> Boolean)
110    <b>is</b>
111       <b>function</b> <FONT COLOR=red><A NAME="107_16">tgetstr</A></FONT> (<FONT COLOR=red><A NAME="107_25">id</A></FONT>  : char_array;
112                         <FONT COLOR=red><A NAME="108_25">buf</A></FONT> : char_array) <b>return</b> chars_ptr;
113       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#107_16">tgetstr</A>, "tgetstr");
114       <FONT COLOR=red><A NAME="110_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#73_26">Name</A>'Length);
115       <FONT COLOR=red><A NAME="111_7">Length</A></FONT> : size_t;
116       <FONT COLOR=red><A NAME="112_7">Txt2</A></FONT>   : chars_ptr;
117       <b>type</b> t <b>is</b> <b>new</b> char_array (0 .. 1024); <FONT COLOR=green><EM>--  does it need to be 1024?</EM></FONT>
118       <FONT COLOR=red><A NAME="114_7">Return_Buffer</A></FONT> : t := (0 =&gt; nul);
119    <b>begin</b>
120       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#73_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#110_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#111_7">Length</A>);
121       <A HREF="terminal_interface-curses-termcap__adb.htm#112_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#107_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#110_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#114_7">Return_Buffer</A>));
122       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#112_7">Txt2</A> = Null_Ptr <b>then</b>
123          <A HREF="terminal_interface-curses-termcap__ads.htm#75_26">Result</A> := False;
124       <b>else</b>
125          <A HREF="terminal_interface-curses-termcap__ads.htm#74_26">Value</A> := <A HREF="terminal_interface-curses-aux__ads.htm#121_13">Fill_String</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#112_7">Txt2</A>);
126          <A HREF="terminal_interface-curses-termcap__ads.htm#75_26">Result</A> := True;
127       <b>end</b> <b>if</b>;
128    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#73_14">Get_String</A><A HREF="terminal_interface-curses-termcap__ads.htm#73_14">;</A>
129
130    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#76_13">Get_String</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#76_25">Name</A> : String) <b>return</b> Boolean
131    <b>is</b>
132       <b>function</b> <FONT COLOR=red><A NAME="128_16">tgetstr</A></FONT> (<FONT COLOR=red><A NAME="128_25">Id</A></FONT>  : char_array;
133                         <FONT COLOR=red><A NAME="129_25">buf</A></FONT> : char_array) <b>return</b> chars_ptr;
134       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#128_16">tgetstr</A>, "tgetstr");
135       <FONT COLOR=red><A NAME="131_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#76_25">Name</A>'Length);
136       <FONT COLOR=red><A NAME="132_7">Length</A></FONT> : size_t;
137       <FONT COLOR=red><A NAME="133_7">Txt2</A></FONT>   : chars_ptr;
138       <b>type</b> t <b>is</b> <b>new</b> char_array (0 .. 1024); <FONT COLOR=green><EM>--  does it need to be 1024?</EM></FONT>
139       <FONT COLOR=red><A NAME="135_7">Phony_Txt</A></FONT> : t := (0 =&gt; nul);
140    <b>begin</b>
141       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#76_25">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#131_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#132_7">Length</A>);
142       <A HREF="terminal_interface-curses-termcap__adb.htm#133_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#128_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#131_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#135_7">Phony_Txt</A>));
143       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#133_7">Txt2</A> = Null_Ptr <b>then</b>
144          <b>return</b> False;
145       <b>else</b>
146          <b>return</b> True;
147       <b>end</b> <b>if</b>;
148    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#76_13">Get_String</A><A HREF="terminal_interface-curses-termcap__ads.htm#76_13">;</A>
149
150 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
151    <b>function</b> <A HREF="terminal_interface-curses-termcap__ads.htm#53_13">TGoto</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#53_20">Cap</A> : String;
152                    <A HREF="terminal_interface-curses-termcap__ads.htm#54_20">Col</A> : <A HREF="terminal_interface-curses__ads.htm#60_9">Column_Position</A>;
153                    <A HREF="terminal_interface-curses-termcap__ads.htm#55_20">Row</A> : <A HREF="terminal_interface-curses__ads.htm#59_9">Line_Position</A>) <b>return</b> <A HREF="terminal_interface-curses-termcap__ads.htm#50_9">Termcap_String</A> <b>is</b>
154       <b>function</b> <FONT COLOR=red><A NAME="150_16">tgoto</A></FONT> (<FONT COLOR=red><A NAME="150_23">cap</A></FONT> : char_array;
155                       <FONT COLOR=red><A NAME="151_23">col</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A>;
156                       <FONT COLOR=red><A NAME="152_23">row</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A>) <b>return</b> chars_ptr;
157       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-termcap__adb.htm#150_16">tgoto</A>);
158       <FONT COLOR=red><A NAME="154_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#53_20">Cap</A>'Length);
159       <FONT COLOR=red><A NAME="155_7">Length</A></FONT> : size_t;
160    <b>begin</b>
161       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#53_20">Cap</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#154_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#155_7">Length</A>);
162       <b>return</b> <A HREF="terminal_interface-curses-termcap__ads.htm#50_9">Termcap_String</A> (<A HREF="terminal_interface-curses-aux__ads.htm#121_13">Fill_String</A>
163                              (<A HREF="terminal_interface-curses-termcap__adb.htm#150_16">tgoto</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#154_7">Txt</A>, <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#54_20">Col</A>), <A HREF="terminal_interface-curses-aux__ads.htm#55_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#55_20">Row</A>))));
164    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#53_13">TGoto</A><A HREF="terminal_interface-curses-termcap__ads.htm#53_13">;</A>
165
166
167 <b>end</b> <A HREF="terminal_interface__ads.htm#41_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#48_28">Curses</A>.<A HREF="terminal_interface-curses-termcap__ads.htm#42_35">Termcap</A><A HREF="terminal_interface-curses-termcap__ads.htm#42_35">;</A>
168 </PRE></BODY></HTML>