]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/ada/terminal_interface-curses-termcap__adb.htm
ncurses 6.3 - patch 20220924
[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>--                           <strong>GNAT</strong> 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">name</a></span> : char_array; <span class="symbol"><a name="ref_52_44">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">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">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">id</a></span>  : char_array;
127                         <span class="symbol"><a name="ref_110_25">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">Id</a></span>  : char_array;
148                         <span class="symbol"><a name="ref_131_25">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">cap</a></span> : char_array;
170                       <span class="symbol"><a name="ref_153_23">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">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>