ncurses 5.3
[ncurses.git] / doc / html / ada / terminal_interface-curses-terminfo__adb.htm
1 <HTML><HEAD><TITLE>terminal_interface-curses-terminfo.adb</TITLE></HEAD>
2 <BODY>
3 <HR><DIV ALIGN="center"><H1> File : terminal_interface-curses-terminfo.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.Terminfo                    --</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.2 @</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 <b>with</b> Ada.Unchecked_Conversion;
51
52 <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-terminfo__ads.htm#45_35">Terminfo</A><FONT COLOR=red><A NAME="48_40"></A></FONT> <b>is</b>
53
54
55    <b>function</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#53_13">Is_MinusOne_Pointer</A><FONT COLOR=red><A NAME="51_13"></A></FONT> (<FONT COLOR=red><A NAME="51_34">P</A></FONT> : <b>in</b> chars_ptr) <b>return</b> Boolean;
56
57    <b>function</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#51_13">Is_MinusOne_Pointer</A><FONT COLOR=red><A NAME="53_13"></A></FONT> (<A HREF="terminal_interface-curses-terminfo__adb.htm#51_34">P</A> : <b>in</b> chars_ptr) <b>return</b> Boolean <b>is</b>
58       <b>type</b> <FONT COLOR=red><A NAME="54_12">Weird_Address</A></FONT> <b>is</b> <b>new</b> System.Storage_Elements.Integer_Address;
59       <FONT COLOR=red><A NAME="55_7">Invalid_Pointer</A></FONT> : <b>constant</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#54_12">Weird_Address</A> := -1;
60       <b>function</b> <FONT COLOR=red><A NAME="56_16">To_Weird</A></FONT> <b>is</b> <b>new</b> Ada.Unchecked_Conversion
61         (Source =&gt; chars_ptr, Target =&gt; <A HREF="terminal_interface-curses-terminfo__adb.htm#54_12">Weird_Address</A>);
62    <b>begin</b>
63       <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#56_16">To_Weird</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#51_34">P</A>) = <A HREF="terminal_interface-curses-terminfo__adb.htm#55_7">Invalid_Pointer</A> <b>then</b>
64          <b>return</b> True;
65       <b>else</b>
66          <b>return</b> False;
67       <b>end</b> <b>if</b>;
68    <b>end</b> Is_MinusOne_Pointer;
69    <b>pragma</b> Inline (<A HREF="terminal_interface-curses-terminfo__adb.htm#51_13">Is_MinusOne_Pointer</A>);
70
71 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
72    <b>function</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#65_13">Get_Flag</A><FONT COLOR=red><A NAME="68_13"></A></FONT> (<A HREF="terminal_interface-curses-terminfo__ads.htm#65_23">Name</A> : String) <b>return</b> Boolean
73    <b>is</b>
74       <b>function</b> <FONT COLOR=red><A NAME="70_16">tigetflag</A></FONT> (<FONT COLOR=red><A NAME="70_27">id</A></FONT> : char_array) <b>return</b> <A HREF="terminal_interface-curses__ads.htm#1931_9">Curses_Bool</A>;
75       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-terminfo__adb.htm#70_16">tigetflag</A>);
76       <FONT COLOR=red><A NAME="72_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#65_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-terminfo__ads.htm#65_23">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#72_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#73_7">Length</A>);
80       <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#70_16">tigetflag</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#72_7">Txt</A>) = <A HREF="terminal_interface-curses__ads.htm#1931_9">Curses_Bool</A> (<A HREF="terminal_interface-curses-aux__ads.htm#75_4">Curses_True</A>) <b>then</b>
81          <b>return</b> True;
82       <b>else</b>
83          <b>return</b> False;
84       <b>end</b> <b>if</b>;
85    <b>end</b> Get_Flag;
86
87 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
88    <b>procedure</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#58_14">Get_String</A><FONT COLOR=red><A NAME="84_14"></A></FONT> (<A HREF="terminal_interface-curses-terminfo__ads.htm#58_26">Name</A>   : String;
89                          <A HREF="terminal_interface-curses-terminfo__ads.htm#59_26">Value</A>  : <b>out</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#55_9">Terminfo_String</A>;
90                          <A HREF="terminal_interface-curses-terminfo__ads.htm#60_26">Result</A> : <b>out</b> Boolean)
91    <b>is</b>
92       <b>function</b> <FONT COLOR=red><A NAME="88_16">tigetstr</A></FONT> (<FONT COLOR=red><A NAME="88_26">id</A></FONT> : char_array) <b>return</b> chars_ptr;
93       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-terminfo__adb.htm#88_16">tigetstr</A>, "tigetstr");
94       <FONT COLOR=red><A NAME="90_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#58_26">Name</A>'Length);
95       <FONT COLOR=red><A NAME="91_7">Length</A></FONT> : size_t;
96       <FONT COLOR=red><A NAME="92_7">Txt2</A></FONT> : chars_ptr;
97    <b>begin</b>
98       To_C (<A HREF="terminal_interface-curses-terminfo__ads.htm#58_26">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#90_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#91_7">Length</A>);
99       <A HREF="terminal_interface-curses-terminfo__adb.htm#92_7">Txt2</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#88_16">tigetstr</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#90_7">Txt</A>);
100       <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#92_7">Txt2</A> = Null_Ptr <b>then</b>
101          <A HREF="terminal_interface-curses-terminfo__ads.htm#60_26">Result</A> := False;
102       <b>elsif</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#51_13">Is_MinusOne_Pointer</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#92_7">Txt2</A>) <b>then</b>
103          <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#383_4">Curses_Exception</A>;
104       <b>else</b>
105          <A HREF="terminal_interface-curses-terminfo__ads.htm#59_26">Value</A>  := <A HREF="terminal_interface-curses-terminfo__ads.htm#55_9">Terminfo_String</A> (<A HREF="terminal_interface-curses-aux__ads.htm#122_13">Fill_String</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#92_7">Txt2</A>));
106          <A HREF="terminal_interface-curses-terminfo__ads.htm#60_26">Result</A> := True;
107       <b>end</b> <b>if</b>;
108    <b>end</b> Get_String;
109
110 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
111    <b>function</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#61_13">Has_String</A><FONT COLOR=red><A NAME="107_13"></A></FONT> (<A HREF="terminal_interface-curses-terminfo__ads.htm#61_25">Name</A> : String) <b>return</b> Boolean
112    <b>is</b>
113       <b>function</b> <FONT COLOR=red><A NAME="109_16">tigetstr</A></FONT> (<FONT COLOR=red><A NAME="109_26">id</A></FONT> : char_array) <b>return</b> chars_ptr;
114       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-terminfo__adb.htm#109_16">tigetstr</A>, "tigetstr");
115       <FONT COLOR=red><A NAME="111_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#61_25">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>begin</b>
119       To_C (<A HREF="terminal_interface-curses-terminfo__ads.htm#61_25">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#111_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#112_7">Length</A>);
120       <A HREF="terminal_interface-curses-terminfo__adb.htm#113_7">Txt2</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#109_16">tigetstr</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#111_7">Txt</A>);
121       <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#113_7">Txt2</A> = Null_Ptr <b>then</b>
122          <b>return</b> False;
123       <b>elsif</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#51_13">Is_MinusOne_Pointer</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#113_7">Txt2</A>) <b>then</b>
124          <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#383_4">Curses_Exception</A>;
125       <b>else</b>
126          <b>return</b> True;
127       <b>end</b> <b>if</b>;
128    <b>end</b> Has_String;
129
130 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
131    <b>function</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#69_13">Get_Number</A><FONT COLOR=red><A NAME="127_13"></A></FONT> (<A HREF="terminal_interface-curses-terminfo__ads.htm#69_25">Name</A> : String) <b>return</b> Integer <b>is</b>
132       <b>function</b> <FONT COLOR=red><A NAME="128_16">tigetstr</A></FONT> (<FONT COLOR=red><A NAME="128_26">s</A></FONT> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
133       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-terminfo__adb.htm#128_16">tigetstr</A>);
134       <FONT COLOR=red><A NAME="130_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#69_25">Name</A>'Length);
135       <FONT COLOR=red><A NAME="131_7">Length</A></FONT> : size_t;
136    <b>begin</b>
137       To_C (<A HREF="terminal_interface-curses-terminfo__ads.htm#69_25">Name</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#130_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#131_7">Length</A>);
138       <b>return</b> Integer (<A HREF="terminal_interface-curses-terminfo__adb.htm#128_16">tigetstr</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#130_7">Txt</A>));
139    <b>end</b> Get_Number;
140
141 <FONT COLOR=green><EM>------------------------------------------------------------------------------</EM></FONT>
142    <b>procedure</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#77_14">Put_String</A><FONT COLOR=red><A NAME="138_14"></A></FONT> (<A HREF="terminal_interface-curses-terminfo__ads.htm#77_26">Str</A>    : <A HREF="terminal_interface-curses-terminfo__ads.htm#55_9">Terminfo_String</A>;
143                          <A HREF="terminal_interface-curses-terminfo__ads.htm#78_26">affcnt</A> : Natural := 1;
144                          <A HREF="terminal_interface-curses-terminfo__ads.htm#79_26">putc</A>   : <A HREF="terminal_interface-curses-terminfo__ads.htm#72_9">putctype</A> := <b>null</b>) <b>is</b>
145       <b>function</b> <FONT COLOR=red><A NAME="141_16">tputs</A></FONT> (<FONT COLOR=red><A NAME="141_23">str</A></FONT>    : char_array;
146                       <FONT COLOR=red><A NAME="142_23">affcnt</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
147                       <FONT COLOR=red><A NAME="143_23">putc</A></FONT>   : <A HREF="terminal_interface-curses-terminfo__ads.htm#72_9">putctype</A>) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
148       <b>function</b> <FONT COLOR=red><A NAME="144_16">putp</A></FONT> (<FONT COLOR=red><A NAME="144_22">str</A></FONT> : char_array) <b>return</b> <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
149       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-terminfo__adb.htm#141_16">tputs</A>);
150       <b>pragma</b> Import (C, <A HREF="terminal_interface-curses-terminfo__adb.htm#144_16">putp</A>);
151       <FONT COLOR=red><A NAME="147_7">Txt</A></FONT>    : char_array (0 .. <A HREF="terminal_interface-curses-terminfo__ads.htm#77_26">Str</A>'Length);
152       <FONT COLOR=red><A NAME="148_7">Length</A></FONT> : size_t;
153       <FONT COLOR=red><A NAME="149_7">Err</A></FONT> : <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A>;
154    <b>begin</b>
155       To_C (String (<A HREF="terminal_interface-curses-terminfo__ads.htm#77_26">Str</A>), <A HREF="terminal_interface-curses-terminfo__adb.htm#147_7">Txt</A>, <A HREF="terminal_interface-curses-terminfo__adb.htm#148_7">Length</A>);
156       <b>if</b> <A HREF="terminal_interface-curses-terminfo__ads.htm#79_26">putc</A> = <b>null</b> <b>then</b>
157          <A HREF="terminal_interface-curses-terminfo__adb.htm#149_7">Err</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#144_16">putp</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#147_7">Txt</A>);
158       <b>else</b>
159          <A HREF="terminal_interface-curses-terminfo__adb.htm#149_7">Err</A> := <A HREF="terminal_interface-curses-terminfo__adb.htm#141_16">tputs</A> (<A HREF="terminal_interface-curses-terminfo__adb.htm#147_7">Txt</A>, <A HREF="terminal_interface-curses-aux__ads.htm#56_12">C_Int</A> (<A HREF="terminal_interface-curses-terminfo__ads.htm#78_26">affcnt</A>), <A HREF="terminal_interface-curses-terminfo__ads.htm#79_26">putc</A>);
160       <b>end</b> <b>if</b>;
161       <b>if</b> <A HREF="terminal_interface-curses-terminfo__adb.htm#149_7">Err</A> = <A HREF="terminal_interface-curses-aux__ads.htm#73_4">Curses_Err</A> <b>then</b>
162          <b>raise</b> <A HREF="terminal_interface-curses__ads.htm#383_4">Curses_Exception</A>;
163       <b>end</b> <b>if</b>;
164    <b>end</b> Put_String;
165
166 <b>end</b> Terminal_Interface.Curses.Terminfo;
167 </PRE></BODY></HTML>