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