ncurses 5.9 - patch 20140524
[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 (c) 2000-2006,2009 Free Software Foundation, Inc.              --</EM></span>
28 <span class="comment"><EM>--                                                                          --</EM></span>
29 <span class="comment"><EM>-- Permission is hereby granted, free of charge, to any person obtaining a  --</EM></span>
30 <span class="comment"><EM>-- copy of this software and associated documentation files (the            --</EM></span>
31 <span class="comment"><EM>-- "Software"), to deal in the Software without restriction, including      --</EM></span>
32 <span class="comment"><EM>-- without limitation the rights to use, copy, modify, merge, publish,      --</EM></span>
33 <span class="comment"><EM>-- distribute, distribute with modifications, sublicense, and/or sell       --</EM></span>
34 <span class="comment"><EM>-- copies of the Software, and to permit persons to whom the Software is    --</EM></span>
35 <span class="comment"><EM>-- furnished to do so, subject to the following conditions:                 --</EM></span>
36 <span class="comment"><EM>--                                                                          --</EM></span>
37 <span class="comment"><EM>-- The above copyright notice and this permission notice shall be included  --</EM></span>
38 <span class="comment"><EM>-- in all copies or substantial portions of the Software.                   --</EM></span>
39 <span class="comment"><EM>--                                                                          --</EM></span>
40 <span class="comment"><EM>-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --</EM></span>
41 <span class="comment"><EM>-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --</EM></span>
42 <span class="comment"><EM>-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --</EM></span>
43 <span class="comment"><EM>-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --</EM></span>
44 <span class="comment"><EM>-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --</EM></span>
45 <span class="comment"><EM>-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --</EM></span>
46 <span class="comment"><EM>-- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --</EM></span>
47 <span class="comment"><EM>--                                                                          --</EM></span>
48 <span class="comment"><EM>-- Except as contained in this notice, the name(s) of the above copyright   --</EM></span>
49 <span class="comment"><EM>-- holders shall not be used in advertising or otherwise to promote the     --</EM></span>
50 <span class="comment"><EM>-- sale, use or other dealings in this Software without prior written       --</EM></span>
51 <span class="comment"><EM>-- authorization.                                                           --</EM></span>
52 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
53 <span class="comment"><EM>--  Author:  Juergen Pfeifer, 1996</EM></span>
54 <span class="comment"><EM>--  Version Control:</EM></span>
55 <span class="comment"><EM>--  @Revision: 1.12 @</EM></span>
56 <span class="comment"><EM>--  @Date: 2009/12/26 17:38:58 @</EM></span>
57 <span class="comment"><EM>--  Binding Version 01.00</EM></span>
58 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
59
60 <b>with</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#ref_45_35">Aux</A>; <b>use</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<A HREF="terminal_interface-curses-aux__ads.htm#ref_45_35">Aux</A>;
61 <b>with</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C; <b>use</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C;
62 <b>with</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C.Strings; <b>use</b> <A HREF="interfac__ads.htm#ref_36_9">Interfaces</A>.C.Strings;
63
64 <b>package</b> <b>body</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<span class="symbol"><A NAME="ref_47_40" HREF="terminal_interface-curses-termcap__ads.htm#ref_42_35">Termcap</A></span> <b>is</b>
65
66    <b>function</b> <span class="symbol"><A NAME="ref_49_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_59_13">Get_Entry</A></span> (<span class="symbol"><A NAME="ref_49_24" HREF="terminal_interface-curses-termcap__ads.htm#ref_59_24">Name</A></span> : String) <b>return</b> Boolean
67    <b>is</b>
68       <b>function</b> <span class="symbol"><A NAME="ref_51_16">tgetent</A></span> (<span class="symbol"><A NAME="ref_51_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_51_16">name</A></span> : char_array; <span class="symbol"><A NAME="ref_51_44" HREF="terminal_interface-curses-termcap__adb.htm#ref_51_16">val</A></span> : char_array)
69                         <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
70       <b>pragma</b> Import (C, tgetent, "tgetent");
71       <span class="symbol"><A NAME="ref_54_7">NameTxt</A></span> : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_59_24">Name</A>'Length);
72       <span class="symbol"><A NAME="ref_55_7">Length</A></span>  : size_t;
73       <span class="symbol"><A NAME="ref_56_7">ignored</A></span> : <b>constant</b> char_array (0 .. 0) := (0 =&gt; nul);
74       <span class="symbol"><A NAME="ref_57_7">result</A></span>  : <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
75    <b>begin</b>
76       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_59_24">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_54_7">NameTxt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_55_7">Length</A>);
77       <A HREF="terminal_interface-curses-termcap__adb.htm#ref_57_7">result</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#ref_51_16">tgetent</A> (char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_56_7">ignored</A>), <A HREF="terminal_interface-curses-termcap__adb.htm#ref_54_7">NameTxt</A>);
78       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_57_7">result</A> = -1 <b>then</b>
79          <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#ref_521_4">Curses_Exception</A>;
80       <b>else</b>
81          <b>return</b> Boolean'Val (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_57_7">result</A>);
82       <b>end</b> <b>if</b>;
83    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_59_13">Get_Entry</A>;
84
85 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
86    <b>function</b> <span class="symbol"><A NAME="ref_69_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_63_13">Get_Flag</A></span> (<span class="symbol"><A NAME="ref_69_23" HREF="terminal_interface-curses-termcap__ads.htm#ref_63_23">Name</A></span> : String) <b>return</b> Boolean
87    <b>is</b>
88       <b>function</b> <span class="symbol"><A NAME="ref_71_16">tgetflag</A></span> (<span class="symbol"><A NAME="ref_71_26" HREF="terminal_interface-curses-termcap__adb.htm#ref_71_16">id</A></span> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
89       <b>pragma</b> Import (C, tgetflag, "tgetflag");
90       <span class="symbol"><A NAME="ref_73_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_63_23">Name</A>'Length);
91       <span class="symbol"><A NAME="ref_74_7">Length</A></span> : size_t;
92    <b>begin</b>
93       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_63_23">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_73_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_74_7">Length</A>);
94       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_71_16">tgetflag</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_73_7">Txt</A>) = 0 <b>then</b>
95          <b>return</b> False;
96       <b>else</b>
97          <b>return</b> True;
98       <b>end</b> <b>if</b>;
99    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_63_13">Get_Flag</A>;
100
101 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
102    <b>procedure</b> <span class="symbol"><A NAME="ref_85_14" HREF="terminal_interface-curses-termcap__ads.htm#ref_67_14">Get_Number</A></span> (<span class="symbol"><A NAME="ref_85_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_67_26">Name</A></span>   : String;
103                          <span class="symbol"><A NAME="ref_86_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_68_26">Value</A></span>  : <b>out</b> Integer;
104                          <span class="symbol"><A NAME="ref_87_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_69_26">Result</A></span> : <b>out</b> Boolean)
105    <b>is</b>
106       <b>function</b> <span class="symbol"><A NAME="ref_89_16">tgetnum</A></span> (<span class="symbol"><A NAME="ref_89_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_89_16">id</A></span> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
107       <b>pragma</b> Import (C, tgetnum, "tgetnum");
108       <span class="symbol"><A NAME="ref_91_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_67_26">Name</A>'Length);
109       <span class="symbol"><A NAME="ref_92_7">Length</A></span> : size_t;
110    <b>begin</b>
111       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_67_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_91_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_92_7">Length</A>);
112       <A HREF="terminal_interface-curses-termcap__ads.htm#ref_68_26">Value</A> := Integer (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_89_16">tgetnum</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_91_7">Txt</A>));
113       <b>if</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_68_26">Value</A> = -1 <b>then</b>
114          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_69_26">Result</A> := False;
115       <b>else</b>
116          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_69_26">Result</A> :=  True;
117       <b>end</b> <b>if</b>;
118    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_67_14">Get_Number</A>;
119
120 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
121    <b>procedure</b> <span class="symbol"><A NAME="ref_104_14" HREF="terminal_interface-curses-termcap__ads.htm#ref_73_14">Get_String</A></span> (<span class="symbol"><A NAME="ref_104_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_73_26">Name</A></span>   : String;
122                          <span class="symbol"><A NAME="ref_105_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_74_26">Value</A></span>  : <b>out</b> String;
123                          <span class="symbol"><A NAME="ref_106_26" HREF="terminal_interface-curses-termcap__ads.htm#ref_75_26">Result</A></span> : <b>out</b> Boolean)
124    <b>is</b>
125       <b>function</b> <span class="symbol"><A NAME="ref_108_16">tgetstr</A></span> (<span class="symbol"><A NAME="ref_108_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_108_16">id</A></span>  : char_array;
126                         <span class="symbol"><A NAME="ref_109_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_108_16">buf</A></span> : char_array) <b>return</b> chars_ptr;
127       <b>pragma</b> Import (C, tgetstr, "tgetstr");
128       <span class="symbol"><A NAME="ref_111_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_73_26">Name</A>'Length);
129       <span class="symbol"><A NAME="ref_112_7">Length</A></span> : size_t;
130       <span class="symbol"><A NAME="ref_113_7">Txt2</A></span>   : chars_ptr;
131       <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>
132       <span class="symbol"><A NAME="ref_115_7">Return_Buffer</A></span> : <b>constant</b> t := (<b>others</b> =&gt; nul);
133    <b>begin</b>
134       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_73_26">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_111_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_112_7">Length</A>);
135       <A HREF="terminal_interface-curses-termcap__adb.htm#ref_113_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#ref_108_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_111_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_115_7">Return_Buffer</A>));
136       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_113_7">Txt2</A> = Null_Ptr <b>then</b>
137          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_75_26">Result</A> := False;
138       <b>else</b>
139          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_74_26">Value</A> := <A HREF="terminal_interface-curses-aux__ads.htm#ref_97_13">Fill_String</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_113_7">Txt2</A>);
140          <A HREF="terminal_interface-curses-termcap__ads.htm#ref_75_26">Result</A> := True;
141       <b>end</b> <b>if</b>;
142    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_73_14">Get_String</A>;
143
144    <b>function</b> <span class="symbol"><A NAME="ref_127_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_76_13">Get_String</A></span> (<span class="symbol"><A NAME="ref_127_25" HREF="terminal_interface-curses-termcap__ads.htm#ref_76_25">Name</A></span> : String) <b>return</b> Boolean
145    <b>is</b>
146       <b>function</b> <span class="symbol"><A NAME="ref_129_16">tgetstr</A></span> (<span class="symbol"><A NAME="ref_129_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_129_16">Id</A></span>  : char_array;
147                         <span class="symbol"><A NAME="ref_130_25" HREF="terminal_interface-curses-termcap__adb.htm#ref_129_16">buf</A></span> : char_array) <b>return</b> chars_ptr;
148       <b>pragma</b> Import (C, tgetstr, "tgetstr");
149       <span class="symbol"><A NAME="ref_132_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_76_25">Name</A>'Length);
150       <span class="symbol"><A NAME="ref_133_7">Length</A></span> : size_t;
151       <span class="symbol"><A NAME="ref_134_7">Txt2</A></span>   : chars_ptr;
152       <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>
153       <span class="symbol"><A NAME="ref_136_7">Phony_Txt</A></span> : <b>constant</b> t := (<b>others</b> =&gt; nul);
154    <b>begin</b>
155       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_76_25">Name</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_132_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_133_7">Length</A>);
156       <A HREF="terminal_interface-curses-termcap__adb.htm#ref_134_7">Txt2</A> := <A HREF="terminal_interface-curses-termcap__adb.htm#ref_129_16">tgetstr</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_132_7">Txt</A>, char_array (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_136_7">Phony_Txt</A>));
157       <b>if</b> <A HREF="terminal_interface-curses-termcap__adb.htm#ref_134_7">Txt2</A> = Null_Ptr <b>then</b>
158          <b>return</b> False;
159       <b>else</b>
160          <b>return</b> True;
161       <b>end</b> <b>if</b>;
162    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_76_13">Get_String</A>;
163
164 <span class="comment"><EM>------------------------------------------------------------------------------</EM></span>
165    <b>function</b> <span class="symbol"><A NAME="ref_148_13" HREF="terminal_interface-curses-termcap__ads.htm#ref_53_13">TGoto</A></span> (<span class="symbol"><A NAME="ref_148_20" HREF="terminal_interface-curses-termcap__ads.htm#ref_53_20">Cap</A></span> : String;
166                    <span class="symbol"><A NAME="ref_149_20" HREF="terminal_interface-curses-termcap__ads.htm#ref_54_20">Col</A></span> : <A HREF="terminal_interface-curses__ads.htm#ref_59_9">Column_Position</A>;
167                    <span class="symbol"><A NAME="ref_150_20" HREF="terminal_interface-curses-termcap__ads.htm#ref_55_20">Row</A></span> : <A HREF="terminal_interface-curses__ads.htm#ref_58_9">Line_Position</A>) <b>return</b> Termcap_String <b>is</b>
168       <b>function</b> <span class="symbol"><A NAME="ref_151_16">tgoto</A></span> (<span class="symbol"><A NAME="ref_151_23" HREF="terminal_interface-curses-termcap__adb.htm#ref_151_16">cap</A></span> : char_array;
169                       <span class="symbol"><A NAME="ref_152_23" HREF="terminal_interface-curses-termcap__adb.htm#ref_151_16">col</A></span> : <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>;
170                       <span class="symbol"><A NAME="ref_153_23" HREF="terminal_interface-curses-termcap__adb.htm#ref_151_16">row</A></span> : <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A>) <b>return</b> chars_ptr;
171       <b>pragma</b> Import (C, tgoto);
172       <span class="symbol"><A NAME="ref_155_7">Txt</A></span>    : char_array (0 .. <A HREF="terminal_interface-curses-termcap__ads.htm#ref_53_20">Cap</A>'Length);
173       <span class="symbol"><A NAME="ref_156_7">Length</A></span> : size_t;
174    <b>begin</b>
175       To_C (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_53_20">Cap</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_155_7">Txt</A>, <A HREF="terminal_interface-curses-termcap__adb.htm#ref_156_7">Length</A>);
176       <b>return</b> Termcap_String (<A HREF="terminal_interface-curses-aux__ads.htm#ref_97_13">Fill_String</A>
177                              (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_151_16">tgoto</A> (<A HREF="terminal_interface-curses-termcap__adb.htm#ref_155_7">Txt</A>, <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_54_20">Col</A>), <A HREF="terminal_interface-curses-aux__ads.htm#ref_50_12">C_Int</A> (<A HREF="terminal_interface-curses-termcap__ads.htm#ref_55_20">Row</A>))));
178    <b>end</b> <A HREF="terminal_interface-curses-termcap__ads.htm#ref_53_13">TGoto</A>;
179
180 <b>end</b> <A HREF="terminal_interface__ads.htm#ref_42_9">Terminal_Interface</A>.<A HREF="terminal_interface-curses__ads.htm#ref_47_28">Curses</A>.<A HREF="terminal_interface-curses-termcap__ads.htm#ref_42_35">Termcap</A>;
181 </PRE></BODY></HTML>