blob: 8602f32be99d07e12473bccd78b51f0c1230ddbb [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301------------------------------------------------------------------------------
2-- --
3-- GNAT ncurses Binding --
4-- --
5-- Terminal_Interface.Curses.Panels --
6-- --
7-- B O D Y --
8-- --
9------------------------------------------------------------------------------
micky3879b9f5e72025-07-08 18:04:53 -040010-- Copyright 2020 Thomas E. Dickey --
11-- Copyright 1999-2004,2009 Free Software Foundation, Inc. --
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053012-- --
13-- Permission is hereby granted, free of charge, to any person obtaining a --
14-- copy of this software and associated documentation files (the --
15-- "Software"), to deal in the Software without restriction, including --
16-- without limitation the rights to use, copy, modify, merge, publish, --
17-- distribute, distribute with modifications, sublicense, and/or sell --
18-- copies of the Software, and to permit persons to whom the Software is --
19-- furnished to do so, subject to the following conditions: --
20-- --
21-- The above copyright notice and this permission notice shall be included --
22-- in all copies or substantial portions of the Software. --
23-- --
24-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
25-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
26-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
27-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
28-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
29-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
30-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
31-- --
32-- Except as contained in this notice, the name(s) of the above copyright --
33-- holders shall not be used in advertising or otherwise to promote the --
34-- sale, use or other dealings in this Software without prior written --
35-- authorization. --
36------------------------------------------------------------------------------
37-- Author: Juergen Pfeifer, 1996
38-- Version Control:
micky3879b9f5e72025-07-08 18:04:53 -040039-- $Revision: 1.15 $
40-- $Date: 2020/02/02 23:34:34 $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053041-- Binding Version 01.00
42------------------------------------------------------------------------------
43with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
44with Interfaces.C;
45
46package body Terminal_Interface.Curses.Panels is
47
48 use type Interfaces.C.int;
49
50 function Create (Win : Window) return Panel
51 is
52 function Newpanel (Win : Window) return Panel;
53 pragma Import (C, Newpanel, "new_panel");
54
55 Pan : Panel;
56 begin
57 Pan := Newpanel (Win);
58 if Pan = Null_Panel then
59 raise Panel_Exception;
60 end if;
61 return Pan;
62 end Create;
63
Steve Kondikae271bc2015-11-15 02:50:53 +010064 procedure Bottom (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053065 is
66 function Bottompanel (Pan : Panel) return C_Int;
67 pragma Import (C, Bottompanel, "bottom_panel");
68 begin
69 if Bottompanel (Pan) = Curses_Err then
70 raise Panel_Exception;
71 end if;
72 end Bottom;
73
Steve Kondikae271bc2015-11-15 02:50:53 +010074 procedure Top (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053075 is
76 function Toppanel (Pan : Panel) return C_Int;
77 pragma Import (C, Toppanel, "top_panel");
78 begin
79 if Toppanel (Pan) = Curses_Err then
80 raise Panel_Exception;
81 end if;
82 end Top;
83
Steve Kondikae271bc2015-11-15 02:50:53 +010084 procedure Show (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053085 is
86 function Showpanel (Pan : Panel) return C_Int;
87 pragma Import (C, Showpanel, "show_panel");
88 begin
89 if Showpanel (Pan) = Curses_Err then
90 raise Panel_Exception;
91 end if;
92 end Show;
93
Steve Kondikae271bc2015-11-15 02:50:53 +010094 procedure Hide (Pan : Panel)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053095 is
96 function Hidepanel (Pan : Panel) return C_Int;
97 pragma Import (C, Hidepanel, "hide_panel");
98 begin
99 if Hidepanel (Pan) = Curses_Err then
100 raise Panel_Exception;
101 end if;
102 end Hide;
103
104 function Get_Window (Pan : Panel) return Window
105 is
106 function Panel_Win (Pan : Panel) return Window;
107 pragma Import (C, Panel_Win, "panel_window");
108
109 Win : constant Window := Panel_Win (Pan);
110 begin
111 if Win = Null_Window then
112 raise Panel_Exception;
113 end if;
114 return Win;
115 end Get_Window;
116
Steve Kondikae271bc2015-11-15 02:50:53 +0100117 procedure Replace (Pan : Panel;
118 Win : Window)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530119 is
120 function Replace_Pan (Pan : Panel;
121 Win : Window) return C_Int;
122 pragma Import (C, Replace_Pan, "replace_panel");
123 begin
124 if Replace_Pan (Pan, Win) = Curses_Err then
125 raise Panel_Exception;
126 end if;
127 end Replace;
128
Steve Kondikae271bc2015-11-15 02:50:53 +0100129 procedure Move (Pan : Panel;
130 Line : Line_Position;
131 Column : Column_Position)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530132 is
133 function Move (Pan : Panel;
134 Line : C_Int;
135 Column : C_Int) return C_Int;
136 pragma Import (C, Move, "move_panel");
137 begin
138 if Move (Pan, C_Int (Line), C_Int (Column)) = Curses_Err then
139 raise Panel_Exception;
140 end if;
141 end Move;
142
143 function Is_Hidden (Pan : Panel) return Boolean
144 is
145 function Panel_Hidden (Pan : Panel) return C_Int;
146 pragma Import (C, Panel_Hidden, "panel_hidden");
147 begin
148 if Panel_Hidden (Pan) = Curses_False then
149 return False;
150 else
151 return True;
152 end if;
153 end Is_Hidden;
154
155 procedure Delete (Pan : in out Panel)
156 is
157 function Del_Panel (Pan : Panel) return C_Int;
158 pragma Import (C, Del_Panel, "del_panel");
159 begin
160 if Del_Panel (Pan) = Curses_Err then
161 raise Panel_Exception;
162 end if;
163 Pan := Null_Panel;
164 end Delete;
165
166end Terminal_Interface.Curses.Panels;