ncurses 6.2 - patch 20200212
[ncurses.git] / doc / html / ada / terminal_interface-curses-termcap__adb.htm
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>terminal_interface-curses-termcap.adb</TITLE>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <style type="text/css">
7 *.comment {
8         color: green;
9 }
10 *.symbol {
11         color: red;
12 }
13 </style>
14 </HEAD>
15 <BODY>
16 <HR><DIV style="text-align:center"><H1> File : terminal_interface-curses-termcap.adb </H1></DIV><HR>
17 <PRE>
18 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
19 <span class="comment"><EM>--                                                                          --</EM></span>
20 <span class="comment"><EM>--                           <A HREF="http://www.gnat.com">GNAT</A> ncurses Binding                           --</EM></span>
21 <span class="comment"><EM>--                                                                          --</EM></span>
22 <span class="comment"><EM>--                    Terminal_Interface.Curses.Termcap                     --</EM></span>
23 <span class="comment"><EM>--                                                                          --</EM></span>
24 <span class="comment"><EM>--                                 B O D Y                                  --</EM></span>
25 <span class="comment"><EM>--                                                                          --</EM></span>
26 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
27 <span class="comment"><EM>-- Copyright 2020 Thomas E. Dickey                                          --</EM></span>
28 <span class="comment"><EM>-- Copyright 2000-2006,2009 Free Software Foundation, Inc.                  --</EM></span>
29 <span class="comment"><EM>--                                                                          --</EM></span>
30 <span class="comment"><EM>-- Permission is hereby granted, free of charge, to any person obtaining a  --</EM></span>
31 <span class="comment"><EM>-- copy of this software and associated documentation files (the            --</EM></span>
32 <span class="comment"><EM>-- "Software"), to deal in the Software without restriction, including      --</EM></span>
33 <span class="comment"><EM>-- without limitation the rights to use, copy, modify, merge, publish,      --</EM></span>
34 <span class="comment"><EM>-- distribute, distribute with modifications, sublicense, and/or sell       --</EM></span>
35 <span class="comment"><EM>-- copies of the Software, and to permit persons to whom the Software is    --</EM></span>
36 <span class="comment"><EM>-- furnished to do so, subject to the following conditions:                 --</EM></span>
37 <span class="comment"><EM>--                                                                          --</EM></span>
38 <span class="comment"><EM>-- The above copyright notice and this permission notice shall be included  --</EM></span>
39 <span class="comment"><EM>-- in all copies or substantial portions of the Software.                   --</EM></span>
40 <span class="comment"><EM>--                                                                          --</EM></span>
41 <span class="comment"><EM>-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --</EM></span>
42 <span class="comment"><EM>-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --</EM></span>
43 <span class="comment"><EM>-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --</EM></span>
44 <span class="comment"><EM>-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --</EM></span>
45 <span class="comment"><EM>-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --</EM></span>
46 <span class="comment"><EM>-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --</EM></span>
47 <span class="comment"><EM>-- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --</EM></span>
48 <span class="comment"><EM>--                                                                          --</EM></span>
49 <span class="comment"><EM>-- Except as contained in this notice, the name(s) of the above copyright   --</EM></span>
50 <span class="comment"><EM>-- holders shall not be used in advertising or otherwise to promote the     --</EM></span>
51 <span class="comment"><EM>-- sale, use or other dealings in this Software without prior written       --</EM></span>
52 <span class="comment"><EM>-- authorization.                                                           --</EM></span>
53 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
54 <span class="comment"><EM>--  Author:  Juergen Pfeifer, 1996</EM></span>
55 <span class="comment"><EM>--  Version Control:</EM></span>
56 <span class="comment"><EM>--  @Revision: 1.13 @</EM></span>
57 <span class="comment"><EM>--  @Date: 2020/02/02 23:34:34 @</EM></span>
58 <span class="comment"><EM>--  Binding Version 01.00</EM></span>
59 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
60
61 <b>with</b> <A HREF="terminal_interface__ads.htm#ref_43_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_48_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#ref_46_35">Aux</A>; <b>use</b> <A HREF="terminal_interface__ads.htm#ref_43_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_48_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#ref_46_35">Aux</A>;
62 <b>with</b> <A HREF="interfac__ads.htm#ref_38_9">Interfaces</A>.C; <b>use</b> <A HREF="interfac__ads.htm#ref_38_9">Interfaces</A>.C;
63 <b>with</b> <A HREF="interfac__ads.htm#ref_38_9">Interfaces</A>.C.Strings; <b>use</b> <A HREF="interfac__ads.htm#ref_38_9">Interfaces</A>.C.Strings;
64
65 <b>package</b> <b>body</b> <A HREF="terminal_interface__ads.htm#ref_43_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_48_28">Curses</A>.<span class="symbol"><A NAME="ref_48_40" HREF="terminal_interface-curses-termcap__ads.htm#ref_43_35">Termcap</A></span> <b>is</b>
66
67    <b>function</b> <span class="symbol"><A NAME="ref_50_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_60_13">Get_Entry</A></span> (<span class="symbol"><A NAME="ref_50_24" HREF="terminal_interface-curses-termcap__ads.htm#ref_60_24">Name</A></span> : String) <b>return</b> Boolean
68    <b>is</b>
69       <b>function</b> <span class="symbol"><A NAME="ref_52_16">tgetent</A></span> (<span class="symbol"><A NAME="ref_52_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_52_16">name</A></span> : char_array; <span class="symbol"><A NAME="ref_52_44" HREF="terminal_interface-curses-termcap__adb.htm#ref_52_16">val</A></span> : char_array)
70                         <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A>;
71       <b>pragma</b> Import (C, tgetent, "tgetent");
72       <span class="symbol"><A NAME="ref_55_7">NameTxt</A></span> : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_60_24">Name</A>'Length);
73       <span class="symbol"><A NAME="ref_56_7">Length</A></span>  : size_t;
74       <span class="symbol"><A NAME="ref_57_7">ignored</A></span> : <b>constant</b> char_array (0 .. 0) := (0 =&gt; nul);
75       <span class="symbol"><A NAME="ref_58_7">result</A></span>  : <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A>;
76    <b>begin</b>
77       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_60_24">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_55_7">NameTxt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_56_7">Length</A>);
78       <A HREF="terminal_interface-curses-termcap__adb.htm#ref_58_7">result</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#ref_52_16">tgetent</A> (char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_57_7">ignored</A>), <A HREF="terminal_interface-curses-termcap__adb.htm#ref_55_7">NameTxt</A>);
79       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_58_7">result</A> = -1 <b>then</b>
80          <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#ref_522_4">Curses_Exception</A>;
81       <b>else</b>
82          <b>return</b> Boolean'Val (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_58_7">result</A>);
83       <b>end</b> <b>if</b>;
84    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_60_13">Get_Entry</A>;
85
86 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
87    <b>function</b> <span class="symbol"><A NAME="ref_70_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_64_13">Get_Flag</A></span> (<span class="symbol"><A NAME="ref_70_23" HREF="terminal_interface-curses-termcap__ads.htm#ref_64_23">Name</A></span> : String) <b>return</b> Boolean
88    <b>is</b>
89       <b>function</b> <span class="symbol"><A NAME="ref_72_16">tgetflag</A></span> (<span class="symbol"><A NAME="ref_72_26" HREF="terminal_interface-curses-termcap__adb.htm#ref_72_16">id</A></span> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A>;
90       <b>pragma</b> Import (C, tgetflag, "tgetflag");
91       <span class="symbol"><A NAME="ref_74_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_64_23">Name</A>'Length);
92       <span class="symbol"><A NAME="ref_75_7">Length</A></span> : size_t;
93    <b>begin</b>
94       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_64_23">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_74_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_75_7">Length</A>);
95       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_72_16">tgetflag</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_74_7">Txt</A>) = 0 <b>then</b>
96          <b>return</b> False;
97       <b>else</b>
98          <b>return</b> True;
99       <b>end</b> <b>if</b>;
100    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_64_13">Get_Flag</A>;
101
102 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
103    <b>procedure</b> <span class="symbol"><A NAME="ref_86_14" HREF="terminal_interface-curses-termcap__ads.htm#ref_68_14">Get_Number</A></span> (<span class="symbol"><A NAME="ref_86_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_68_26">Name</A></span>   : String;
104                          <span class="symbol"><A NAME="ref_87_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_69_26">Value</A></span>  : <b>out</b> Integer;
105                          <span class="symbol"><A NAME="ref_88_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_70_26">Result</A></span> : <b>out</b> Boolean)
106    <b>is</b>
107       <b>function</b> <span class="symbol"><A NAME="ref_90_16">tgetnum</A></span> (<span class="symbol"><A NAME="ref_90_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_90_16">id</A></span> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A>;
108       <b>pragma</b> Import (C, tgetnum, "tgetnum");
109       <span class="symbol"><A NAME="ref_92_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_68_26">Name</A>'Length);
110       <span class="symbol"><A NAME="ref_93_7">Length</A></span> : size_t;
111    <b>begin</b>
112       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_68_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_92_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_93_7">Length</A>);
113       <A HREF="terminal_interface-curses-termcap__ads.htm#ref_69_26">Value</A> := Integer (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_90_16">tgetnum</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_92_7">Txt</A>));
114       <b>if</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_69_26">Value</A> = -1 <b>then</b>
115          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_70_26">Result</A> := False;
116       <b>else</b>
117          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_70_26">Result</A> :=  True;
118       <b>end</b> <b>if</b>;
119    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_68_14">Get_Number</A>;
120
121 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
122    <b>procedure</b> <span class="symbol"><A NAME="ref_105_14" HREF="terminal_interface-curses-termcap__ads.htm#ref_74_14">Get_String</A></span> (<span class="symbol"><A NAME="ref_105_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_74_26">Name</A></span>   : String;
123                          <span class="symbol"><A NAME="ref_106_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_75_26">Value</A></span>  : <b>out</b> String;
124                          <span class="symbol"><A NAME="ref_107_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_76_26">Result</A></span> : <b>out</b> Boolean)
125    <b>is</b>
126       <b>function</b> <span class="symbol"><A NAME="ref_109_16">tgetstr</A></span> (<span class="symbol"><A NAME="ref_109_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_109_16">id</A></span>  : char_array;
127                         <span class="symbol"><A NAME="ref_110_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_109_16">buf</A></span> : char_array) <b>return</b> chars_ptr;
128       <b>pragma</b> Import (C, tgetstr, "tgetstr");
129       <span class="symbol"><A NAME="ref_112_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_74_26">Name</A>'Length);
130       <span class="symbol"><A NAME="ref_113_7">Length</A></span> : size_t;
131       <span class="symbol"><A NAME="ref_114_7">Txt2</A></span>   : chars_ptr;
132       <b>type</b> t <b>is</b> <b>new</b> char_array (0 .. 1024); <span class="comment"><EM>--  does it need to be 1024?</EM></span>
133       <span class="symbol"><A NAME="ref_116_7">Return_Buffer</A></span> : <b>constant</b> t := (<b>others</b> =&gt; nul);
134    <b>begin</b>
135       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_74_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_112_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_113_7">Length</A>);
136       <A HREF="terminal_interface-curses-termcap__adb.htm#ref_114_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#ref_109_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_112_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_116_7">Return_Buffer</A>));
137       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_114_7">Txt2</A> = Null_Ptr <b>then</b>
138          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_76_26">Result</A> := False;
139       <b>else</b>
140          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_75_26">Value</A> := <A HREF="terminal_interface-curses-aux__ads.htm#ref_96_13">Fill_String</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_114_7">Txt2</A>);
141          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_76_26">Result</A> := True;
142       <b>end</b> <b>if</b>;
143    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_74_14">Get_String</A>;
144
145    <b>function</b> <span class="symbol"><A NAME="ref_128_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_77_13">Get_String</A></span> (<span class="symbol"><A NAME="ref_128_25" HREF="terminal_interface-curses-termcap__ads.htm#ref_77_25">Name</A></span> : String) <b>return</b> Boolean
146    <b>is</b>
147       <b>function</b> <span class="symbol"><A NAME="ref_130_16">tgetstr</A></span> (<span class="symbol"><A NAME="ref_130_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_130_16">Id</A></span>  : char_array;
148                         <span class="symbol"><A NAME="ref_131_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_130_16">buf</A></span> : char_array) <b>return</b> chars_ptr;
149       <b>pragma</b> Import (C, tgetstr, "tgetstr");
150       <span class="symbol"><A NAME="ref_133_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_77_25">Name</A>'Length);
151       <span class="symbol"><A NAME="ref_134_7">Length</A></span> : size_t;
152       <span class="symbol"><A NAME="ref_135_7">Txt2</A></span>   : chars_ptr;
153       <b>type</b> t <b>is</b> <b>new</b> char_array (0 .. 1024); <span class="comment"><EM>--  does it need to be 1024?</EM></span>
154       <span class="symbol"><A NAME="ref_137_7">Phony_Txt</A></span> : <b>constant</b> t := (<b>others</b> =&gt; nul);
155    <b>begin</b>
156       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_77_25">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_133_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_134_7">Length</A>);
157       <A HREF="terminal_interface-curses-termcap__adb.htm#ref_135_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#ref_130_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_133_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_137_7">Phony_Txt</A>));
158       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_135_7">Txt2</A> = Null_Ptr <b>then</b>
159          <b>return</b> False;
160       <b>else</b>
161          <b>return</b> True;
162       <b>end</b> <b>if</b>;
163    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_77_13">Get_String</A>;
164
165 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
166    <b>function</b> <span class="symbol"><A NAME="ref_149_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_54_13">TGoto</A></span> (<span class="symbol"><A NAME="ref_149_20" HREF="terminal_interface-curses-termcap__ads.htm#ref_54_20">Cap</A></span> : String;
167                    <span class="symbol"><A NAME="ref_150_20" HREF="terminal_interface-curses-termcap__ads.htm#ref_55_20">Col</A></span> : <A HREF="terminal_interface-curses__ads.htm#ref_60_9">Column_Position</A>;
168                    <span class="symbol"><A NAME="ref_151_20" HREF="terminal_interface-curses-termcap__ads.htm#ref_56_20">Row</A></span> : <A HREF="terminal_interface-curses__ads.htm#ref_59_9">Line_Position</A>) <b>return</b> Termcap_String <b>is</b>
169       <b>function</b> <span class="symbol"><A NAME="ref_152_16">tgoto</A></span> (<span class="symbol"><A NAME="ref_152_23" HREF="terminal_interface-curses-termcap__adb.htm#ref_152_16">cap</A></span> : char_array;
170                       <span class="symbol"><A NAME="ref_153_23" HREF="terminal_interface-curses-termcap__adb.htm#ref_152_16">col</A></span> : <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A>;
171                       <span class="symbol"><A NAME="ref_154_23" HREF="terminal_interface-curses-termcap__adb.htm#ref_152_16">row</A></span> : <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A>) <b>return</b> chars_ptr;
172       <b>pragma</b> Import (C, tgoto);
173       <span class="symbol"><A NAME="ref_156_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_54_20">Cap</A>'Length);
174       <span class="symbol"><A NAME="ref_157_7">Length</A></span> : size_t;
175    <b>begin</b>
176       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_54_20">Cap</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_156_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_157_7">Length</A>);
177       <b>return</b> Termcap_String (<A HREF="terminal_interface-curses-aux__ads.htm#ref_96_13">Fill_String</A>
178                              (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_152_16">tgoto</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_156_7">Txt</A>, <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_55_20">Col</A>), <A HREF="terminal_interface-curses-aux__ads.htm#ref_49_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_56_20">Row</A>))));
179    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_54_13">TGoto</A>;
180
181 <b>end</b> <A HREF="terminal_interface__ads.htm#ref_43_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_48_28">Curses</A>.<A HREF="terminal_interface-curses-termcap__ads.htm#ref_43_35">Termcap</A>;
182 </PRE></BODY></HTML>