1 ------------------------------------------------------------------------------
3 -- GNAT ncurses Binding --
5 -- Terminal_Interface.Curses.Forms --
9 ------------------------------------------------------------------------------
10 -- Copyright (c) 1998 Free Software Foundation, Inc. --
12 -- Permission is hereby granted, free of charge, to any person obtaining a --
13 -- copy of this software and associated documentation files (the --
14 -- "Software"), to deal in the Software without restriction, including --
15 -- without limitation the rights to use, copy, modify, merge, publish, --
16 -- distribute, distribute with modifications, sublicense, and/or sell --
17 -- copies of the Software, and to permit persons to whom the Software is --
18 -- furnished to do so, subject to the following conditions: --
20 -- The above copyright notice and this permission notice shall be included --
21 -- in all copies or substantial portions of the Software. --
23 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
24 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
25 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
26 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
27 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
28 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
29 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
31 -- Except as contained in this notice, the name(s) of the above copyright --
32 -- holders shall not be used in advertising or otherwise to promote the --
33 -- sale, use or other dealings in this Software without prior written --
35 ------------------------------------------------------------------------------
36 -- Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1996
39 -- Binding Version 00.93
40 ------------------------------------------------------------------------------
41 with Ada.Unchecked_Deallocation;
42 with Unchecked_Conversion;
44 with Interfaces.C; use Interfaces.C;
45 with Interfaces.C.Strings; use Interfaces.C.Strings;
47 with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
49 package body Terminal_Interface.Curses.Forms is
51 ------------------------------------------------------------------------------
55 -- subtype chars_ptr is Interfaces.C.Strings.chars_ptr;
57 function FOS_2_CInt is new
58 Unchecked_Conversion (Field_Option_Set,
61 function CInt_2_FOS is new
62 Unchecked_Conversion (C_Int,
65 function FrmOS_2_CInt is new
66 Unchecked_Conversion (Form_Option_Set,
69 function CInt_2_FrmOS is new
70 Unchecked_Conversion (C_Int,
73 procedure Request_Name (Key : in Form_Request_Code;
76 function Form_Request_Name (Key : C_Int) return chars_ptr;
77 pragma Import (C, Form_Request_Name, "form_request_name");
79 Fill_String (Form_Request_Name (C_Int (Key)), Name);
82 function Request_Name (Key : Form_Request_Code) return String
84 function Form_Request_Name (Key : C_Int) return chars_ptr;
85 pragma Import (C, Form_Request_Name, "form_request_name");
87 return Fill_String (Form_Request_Name (C_Int (Key)));
89 ------------------------------------------------------------------------------
94 -- |=====================================================================
95 -- | man page form_field_new.3x
96 -- |=====================================================================
100 function Create (Height : Line_Count;
101 Width : Column_Count;
103 Left : Column_Position;
104 Off_Screen : Natural := 0;
105 More_Buffers : Buffer_Number := Buffer_Number'First)
108 function Newfield (H, W, T, L, O, M : C_Int) return Field;
109 pragma Import (C, Newfield, "new_field");
110 Fld : constant Field := Newfield (C_Int (Height), C_Int (Width),
111 C_Int (Top), C_Int (Left),
113 C_Int (More_Buffers));
115 if Fld = Null_Field then
116 raise Form_Exception;
123 procedure Delete (Fld : in out Field)
125 function Free_Field (Fld : Field) return C_Int;
126 pragma Import (C, Free_Field, "free_field");
130 Res := Free_Field (Fld);
139 function Duplicate (Fld : Field;
141 Left : Column_Position) return Field
143 function Dup_Field (Fld : Field;
145 Left : C_Int) return Field;
146 pragma Import (C, Dup_Field, "dup_field");
148 F : constant Field := Dup_Field (Fld,
152 if F = Null_Field then
153 raise Form_Exception;
160 function Link (Fld : Field;
162 Left : Column_Position) return Field
164 function Lnk_Field (Fld : Field;
166 Left : C_Int) return Field;
167 pragma Import (C, Lnk_Field, "link_field");
169 F : constant Field := Lnk_Field (Fld,
173 if F = Null_Field then
174 raise Form_Exception;
179 -- |=====================================================================
180 -- | man page form_field_just.3x
181 -- |=====================================================================
185 procedure Set_Justification (Fld : in Field;
186 Just : in Field_Justification := None)
188 function Set_Field_Just (Fld : Field;
189 Just : C_Int) return C_Int;
190 pragma Import (C, Set_Field_Just, "set_field_just");
192 Res : constant Eti_Error :=
194 C_Int (Field_Justification'Pos (Just)));
199 end Set_Justification;
203 function Get_Justification (Fld : Field) return Field_Justification
205 function Field_Just (Fld : Field) return C_Int;
206 pragma Import (C, Field_Just, "field_just");
208 return Field_Justification'Val (Field_Just (Fld));
209 end Get_Justification;
211 -- |=====================================================================
212 -- | man page form_field_buffer.3x
213 -- |=====================================================================
219 Buffer : in Buffer_Number := Buffer_Number'First;
222 type Char_Ptr is access all Interfaces.C.Char;
223 function Set_Fld_Buffer (Fld : Field;
227 pragma Import (C, Set_Fld_Buffer, "set_field_buffer");
229 Txt : char_array (0 .. Str'Length);
233 To_C (Str, Txt, Len);
234 Res := Set_Fld_Buffer (Fld, C_Int (Buffer), Txt (Txt'First)'Access);
244 Buffer : in Buffer_Number := Buffer_Number'First;
247 function Field_Buffer (Fld : Field;
248 B : C_Int) return chars_ptr;
249 pragma Import (C, Field_Buffer, "field_buffer");
251 Fill_String (Field_Buffer (Fld, C_Int (Buffer)), Str);
256 Buffer : in Buffer_Number := Buffer_Number'First) return String
258 function Field_Buffer (Fld : Field;
259 B : C_Int) return chars_ptr;
260 pragma Import (C, Field_Buffer, "field_buffer");
262 return Fill_String (Field_Buffer (Fld, C_Int (Buffer)));
267 procedure Set_Status (Fld : in Field;
268 Status : in Boolean := True)
270 function Set_Fld_Status (Fld : Field;
271 St : C_Int) return C_Int;
272 pragma Import (C, Set_Fld_Status, "set_field_status");
274 Res : constant Eti_Error := Set_Fld_Status (Fld, Boolean'Pos (Status));
277 raise Form_Exception;
283 function Changed (Fld : Field) return Boolean
285 function Field_Status (Fld : Field) return C_Int;
286 pragma Import (C, Field_Status, "field_status");
288 Res : constant C_Int := Field_Status (Fld);
290 if Res = Curses_False then
299 procedure Set_Maximum_Size (Fld : in Field;
300 Max : in Natural := 0)
302 function Set_Field_Max (Fld : Field;
303 M : C_Int) return C_Int;
304 pragma Import (C, Set_Field_Max, "set_max_field");
306 Res : constant Eti_Error := Set_Field_Max (Fld, C_Int (Max));
311 end Set_Maximum_Size;
313 -- |=====================================================================
314 -- | man page form_field_opts.3x
315 -- |=====================================================================
319 procedure Normalize_Field_Options (Options : in out C_Int);
320 pragma Import (C, Normalize_Field_Options, "_nc_ada_normalize_field_opts");
322 procedure Set_Options (Fld : in Field;
323 Options : in Field_Option_Set)
325 function Set_Field_Opts (Fld : Field;
326 Opt : C_Int) return C_Int;
327 pragma Import (C, Set_Field_Opts, "set_field_opts");
329 Opt : C_Int := FOS_2_CInt (Options);
332 Normalize_Field_Options (Opt);
333 Res := Set_Field_Opts (Fld, Opt);
341 procedure Switch_Options (Fld : in Field;
342 Options : in Field_Option_Set;
343 On : Boolean := True)
345 function Field_Opts_On (Fld : Field;
346 Opt : C_Int) return C_Int;
347 pragma Import (C, Field_Opts_On, "field_opts_on");
348 function Field_Opts_Off (Fld : Field;
349 Opt : C_Int) return C_Int;
350 pragma Import (C, Field_Opts_Off, "field_opts_off");
353 Opt : C_Int := FOS_2_CInt (Options);
355 Normalize_Field_Options (Opt);
357 Err := Field_Opts_On (Fld, Opt);
359 Err := Field_Opts_Off (Fld, Opt);
368 procedure Get_Options (Fld : in Field;
369 Options : out Field_Option_Set)
371 function Field_Opts (Fld : Field) return C_Int;
372 pragma Import (C, Field_Opts, "field_opts");
374 Res : C_Int := Field_Opts (Fld);
376 Normalize_Field_Options (Res);
377 Options := CInt_2_FOS (Res);
382 function Get_Options (Fld : Field := Null_Field)
383 return Field_Option_Set
385 Fos : Field_Option_Set;
387 Get_Options (Fld, Fos);
391 -- |=====================================================================
392 -- | man page form_field_attributes.3x
393 -- |=====================================================================
397 procedure Set_Foreground
399 Fore : in Character_Attribute_Set := Normal_Video;
400 Color : in Color_Pair := Color_Pair'First)
402 function Set_Field_Fore (Fld : Field;
403 Attr : C_Int) return C_Int;
404 pragma Import (C, Set_Field_Fore, "set_field_fore");
406 Ch : constant Attributed_Character := (Ch => Character'First,
409 Res : constant Eti_Error := Set_Field_Fore (Fld, Chtype_To_CInt (Ch));
418 procedure Foreground (Fld : in Field;
419 Fore : out Character_Attribute_Set)
421 function Field_Fore (Fld : Field) return C_Int;
422 pragma Import (C, Field_Fore, "field_fore");
424 Fore := CInt_To_Chtype (Field_Fore (Fld)).Attr;
427 procedure Foreground (Fld : in Field;
428 Fore : out Character_Attribute_Set;
429 Color : out Color_Pair)
431 function Field_Fore (Fld : Field) return C_Int;
432 pragma Import (C, Field_Fore, "field_fore");
434 Fore := CInt_To_Chtype (Field_Fore (Fld)).Attr;
435 Color := CInt_To_Chtype (Field_Fore (Fld)).Color;
440 procedure Set_Background
442 Back : in Character_Attribute_Set := Normal_Video;
443 Color : in Color_Pair := Color_Pair'First)
445 function Set_Field_Back (Fld : Field;
446 Attr : C_Int) return C_Int;
447 pragma Import (C, Set_Field_Back, "set_field_back");
449 Ch : constant Attributed_Character := (Ch => Character'First,
452 Res : constant Eti_Error := Set_Field_Back (Fld, Chtype_To_CInt (Ch));
461 procedure Background (Fld : in Field;
462 Back : out Character_Attribute_Set)
464 function Field_Back (Fld : Field) return C_Int;
465 pragma Import (C, Field_Back, "field_back");
467 Back := CInt_To_Chtype (Field_Back (Fld)).Attr;
470 procedure Background (Fld : in Field;
471 Back : out Character_Attribute_Set;
472 Color : out Color_Pair)
474 function Field_Back (Fld : Field) return C_Int;
475 pragma Import (C, Field_Back, "field_back");
477 Back := CInt_To_Chtype (Field_Back (Fld)).Attr;
478 Color := CInt_To_Chtype (Field_Back (Fld)).Color;
483 procedure Set_Pad_Character (Fld : in Field;
484 Pad : in Character := Space)
486 function Set_Field_Pad (Fld : Field;
487 Ch : C_Int) return C_Int;
488 pragma Import (C, Set_Field_Pad, "set_field_pad");
490 Res : constant Eti_Error := Set_Field_Pad (Fld,
491 C_Int (Character'Pos (Pad)));
496 end Set_Pad_Character;
500 procedure Pad_Character (Fld : in Field;
503 function Field_Pad (Fld : Field) return C_Int;
504 pragma Import (C, Field_Pad, "field_pad");
506 Pad := Character'Val (Field_Pad (Fld));
509 -- |=====================================================================
510 -- | man page form_field_info.3x
511 -- |=====================================================================
515 procedure Info (Fld : in Field;
516 Lines : out Line_Count;
517 Columns : out Column_Count;
518 First_Row : out Line_Position;
519 First_Column : out Column_Position;
520 Off_Screen : out Natural;
521 Additional_Buffers : out Buffer_Number)
523 type C_Int_Access is access all C_Int;
524 function Fld_Info (Fld : Field;
525 L, C, Fr, Fc, Os, Ab : C_Int_Access)
527 pragma Import (C, Fld_Info, "field_info");
529 L, C, Fr, Fc, Os, Ab : aliased C_Int;
530 Res : constant Eti_Error := Fld_Info (Fld,
532 Fr'Access, Fc'Access,
533 Os'Access, Ab'Access);
538 Lines := Line_Count (L);
539 Columns := Column_Count (C);
540 First_Row := Line_Position (Fr);
541 First_Column := Column_Position (Fc);
542 Off_Screen := Natural (Os);
543 Additional_Buffers := Buffer_Number (Ab);
549 procedure Dynamic_Info (Fld : in Field;
550 Lines : out Line_Count;
551 Columns : out Column_Count;
554 type C_Int_Access is access all C_Int;
555 function Dyn_Info (Fld : Field; L, C, M : C_Int_Access) return C_Int;
556 pragma Import (C, Dyn_Info, "dynamic_field_info");
558 L, C, M : aliased C_Int;
559 Res : constant Eti_Error := Dyn_Info (Fld,
566 Lines := Line_Count (L);
567 Columns := Column_Count (C);
572 -- |=====================================================================
573 -- | man page form_win.3x
574 -- |=====================================================================
578 procedure Set_Window (Frm : in Form;
581 function Set_Form_Win (Frm : Form;
582 Win : Window) return C_Int;
583 pragma Import (C, Set_Form_Win, "set_form_win");
585 Res : constant Eti_Error := Set_Form_Win (Frm, Win);
594 function Get_Window (Frm : Form) return Window
596 function Form_Win (Frm : Form) return Window;
597 pragma Import (C, Form_Win, "form_win");
599 W : constant Window := Form_Win (Frm);
606 procedure Set_Sub_Window (Frm : in Form;
609 function Set_Form_Sub (Frm : Form;
610 Win : Window) return C_Int;
611 pragma Import (C, Set_Form_Sub, "set_form_sub");
613 Res : constant Eti_Error := Set_Form_Sub (Frm, Win);
622 function Get_Sub_Window (Frm : Form) return Window
624 function Form_Sub (Frm : Form) return Window;
625 pragma Import (C, Form_Sub, "form_sub");
627 W : constant Window := Form_Sub (Frm);
634 procedure Scale (Frm : in Form;
635 Lines : out Line_Count;
636 Columns : out Column_Count)
638 type C_Int_Access is access all C_Int;
639 function M_Scale (Frm : Form; Yp, Xp : C_Int_Access) return C_Int;
640 pragma Import (C, M_Scale, "scale_form");
642 X, Y : aliased C_Int;
643 Res : constant Eti_Error := M_Scale (Frm, Y'Access, X'Access);
648 Lines := Line_Count (Y);
649 Columns := Column_Count (X);
652 -- |=====================================================================
653 -- | man page menu_hook.3x
654 -- |=====================================================================
658 procedure Set_Field_Init_Hook (Frm : in Form;
659 Proc : in Form_Hook_Function)
661 function Set_Field_Init (Frm : Form;
662 Proc : Form_Hook_Function) return C_Int;
663 pragma Import (C, Set_Field_Init, "set_field_init");
665 Res : constant Eti_Error := Set_Field_Init (Frm, Proc);
670 end Set_Field_Init_Hook;
674 procedure Set_Field_Term_Hook (Frm : in Form;
675 Proc : in Form_Hook_Function)
677 function Set_Field_Term (Frm : Form;
678 Proc : Form_Hook_Function) return C_Int;
679 pragma Import (C, Set_Field_Term, "set_field_term");
681 Res : constant Eti_Error := Set_Field_Term (Frm, Proc);
686 end Set_Field_Term_Hook;
690 procedure Set_Form_Init_Hook (Frm : in Form;
691 Proc : in Form_Hook_Function)
693 function Set_Form_Init (Frm : Form;
694 Proc : Form_Hook_Function) return C_Int;
695 pragma Import (C, Set_Form_Init, "set_form_init");
697 Res : constant Eti_Error := Set_Form_Init (Frm, Proc);
702 end Set_Form_Init_Hook;
706 procedure Set_Form_Term_Hook (Frm : in Form;
707 Proc : in Form_Hook_Function)
709 function Set_Form_Term (Frm : Form;
710 Proc : Form_Hook_Function) return C_Int;
711 pragma Import (C, Set_Form_Term, "set_form_term");
713 Res : constant Eti_Error := Set_Form_Term (Frm, Proc);
718 end Set_Form_Term_Hook;
720 -- |=====================================================================
721 -- | man page form_fields.3x
722 -- |=====================================================================
726 procedure Redefine (Frm : in Form;
727 Flds : in Field_Array_Access)
729 function Set_Frm_Fields (Frm : Form;
730 Items : System.Address) return C_Int;
731 pragma Import (C, Set_Frm_Fields, "set_form_fields");
735 pragma Assert (Flds (Flds'Last) = Null_Field);
736 if Flds (Flds'Last) /= Null_Field then
737 raise Form_Exception;
739 Res := Set_Frm_Fields (Frm, Flds (Flds'First)'Address);
748 function Fields (Frm : Form;
749 Index : Positive) return Field
751 function F_Fields (Frm : Form;
752 Idx : C_Int) return Field;
753 pragma Import (C, F_Fields, "_nc_get_field");
755 if Frm = Null_Form or else Index not in 1 .. Field_Count (Frm) then
756 raise Form_Exception;
758 return F_Fields (Frm, C_Int (Index) - 1);
764 function Field_Count (Frm : Form) return Natural
766 function Count (Frm : Form) return C_Int;
767 pragma Import (C, Count, "field_count");
769 return Natural (Count (Frm));
774 procedure Move (Fld : in Field;
775 Line : in Line_Position;
776 Column : in Column_Position)
778 function Move (Fld : Field; L, C : C_Int) return C_Int;
779 pragma Import (C, Move, "move_field");
781 Res : constant Eti_Error := Move (Fld, C_Int (Line), C_Int (Column));
788 -- |=====================================================================
789 -- | man page form_new.3x
790 -- |=====================================================================
794 function Create (Fields : Field_Array_Access) return Form
796 function NewForm (Fields : System.Address) return Form;
797 pragma Import (C, NewForm, "new_form");
801 pragma Assert (Fields (Fields'Last) = Null_Field);
802 if Fields (Fields'Last) /= Null_Field then
803 raise Form_Exception;
805 M := NewForm (Fields (Fields'First)'Address);
806 if M = Null_Form then
807 raise Form_Exception;
815 procedure Delete (Frm : in out Form)
817 function Free (Frm : Form) return C_Int;
818 pragma Import (C, Free, "free_form");
820 Res : constant Eti_Error := Free (Frm);
828 -- |=====================================================================
829 -- | man page form_opts.3x
830 -- |=====================================================================
834 procedure Normalize_Form_Options (Options : in out C_Int);
835 pragma Import (C, Normalize_Form_Options, "_nc_ada_normalize_form_opts");
837 procedure Set_Options (Frm : in Form;
838 Options : in Form_Option_Set)
840 function Set_Form_Opts (Frm : Form;
841 Opt : C_Int) return C_Int;
842 pragma Import (C, Set_Form_Opts, "set_form_opts");
844 Opt : C_Int := FrmOS_2_CInt (Options);
847 Normalize_Form_Options (Opt);
848 Res := Set_Form_Opts (Frm, Opt);
856 procedure Switch_Options (Frm : in Form;
857 Options : in Form_Option_Set;
858 On : Boolean := True)
860 function Form_Opts_On (Frm : Form;
861 Opt : C_Int) return C_Int;
862 pragma Import (C, Form_Opts_On, "form_opts_on");
863 function Form_Opts_Off (Frm : Form;
864 Opt : C_Int) return C_Int;
865 pragma Import (C, Form_Opts_Off, "form_opts_off");
868 Opt : C_Int := FrmOS_2_CInt (Options);
870 Normalize_Form_Options (Opt);
872 Err := Form_Opts_On (Frm, Opt);
874 Err := Form_Opts_Off (Frm, Opt);
883 procedure Get_Options (Frm : in Form;
884 Options : out Form_Option_Set)
886 function Form_Opts (Frm : Form) return C_Int;
887 pragma Import (C, Form_Opts, "form_opts");
889 Res : C_Int := Form_Opts (Frm);
891 Normalize_Form_Options (Res);
892 Options := CInt_2_FrmOS (Res);
897 function Get_Options (Frm : Form := Null_Form) return Form_Option_Set
899 Fos : Form_Option_Set;
901 Get_Options (Frm, Fos);
905 -- |=====================================================================
906 -- | man page form_post.3x
907 -- |=====================================================================
911 procedure Post (Frm : in Form;
912 Post : in Boolean := True)
914 function M_Post (Frm : Form) return C_Int;
915 pragma Import (C, M_Post, "post_form");
916 function M_Unpost (Frm : Form) return C_Int;
917 pragma Import (C, M_Unpost, "unpost_form");
924 Res := M_Unpost (Frm);
931 -- |=====================================================================
932 -- | man page form_cursor.3x
933 -- |=====================================================================
937 procedure Position_Cursor (Frm : Form)
939 function Pos_Form_Cursor (Frm : Form) return C_Int;
940 pragma Import (C, Pos_Form_Cursor, "pos_form_cursor");
942 Res : constant Eti_Error := Pos_Form_Cursor (Frm);
949 -- |=====================================================================
950 -- | man page form_data.3x
951 -- |=====================================================================
955 function Data_Ahead (Frm : Form) return Boolean
957 function Ahead (Frm : Form) return C_Int;
958 pragma Import (C, Ahead, "data_ahead");
960 Res : constant C_Int := Ahead (Frm);
962 if Res = Curses_False then
971 function Data_Behind (Frm : Form) return Boolean
973 function Behind (Frm : Form) return C_Int;
974 pragma Import (C, Behind, "data_behind");
976 Res : constant C_Int := Behind (Frm);
978 if Res = Curses_False then
985 -- |=====================================================================
986 -- | man page form_driver.3x
987 -- |=====================================================================
991 function Driver (Frm : Form;
992 Key : Key_Code) return Driver_Result
994 function Frm_Driver (Frm : Form; Key : C_Int) return C_Int;
995 pragma Import (C, Frm_Driver, "form_driver");
997 R : Eti_Error := Frm_Driver (Frm, C_Int (Key));
1000 if R = E_Unknown_Command then
1001 return Unknown_Request;
1002 elsif R = E_Invalid_Field then
1003 return Invalid_Field;
1004 elsif R = E_Request_Denied then
1005 return Request_Denied;
1015 -- |=====================================================================
1016 -- | man page form_page.3x
1017 -- |=====================================================================
1021 procedure Set_Current (Frm : in Form;
1024 function Set_Current_Fld (Frm : Form; Fld : Field) return C_Int;
1025 pragma Import (C, Set_Current_Fld, "set_current_field");
1027 Res : constant Eti_Error := Set_Current_Fld (Frm, Fld);
1030 Eti_Exception (Res);
1036 function Current (Frm : in Form) return Field
1038 function Current_Fld (Frm : Form) return Field;
1039 pragma Import (C, Current_Fld, "current_field");
1041 Fld : constant Field := Current_Fld (Frm);
1043 if Fld = Null_Field then
1044 raise Form_Exception;
1051 procedure Set_Page (Frm : in Form;
1052 Page : in Page_Number := Page_Number'First)
1054 function Set_Frm_Page (Frm : Form; Pg : C_Int) return C_Int;
1055 pragma Import (C, Set_Frm_Page, "set_form_page");
1057 Res : constant Eti_Error := Set_Frm_Page (Frm, C_Int (Page));
1060 Eti_Exception (Res);
1066 function Page (Frm : Form) return Page_Number
1068 function Get_Page (Frm : Form) return C_Int;
1069 pragma Import (C, Get_Page, "form_page");
1071 P : constant C_Int := Get_Page (Frm);
1074 raise Form_Exception;
1076 return Page_Number (P);
1080 function Get_Index (Fld : Field) return Positive
1082 function Get_Fieldindex (Fld : Field) return C_Int;
1083 pragma Import (C, Get_Fieldindex, "field_index");
1085 Res : constant C_Int := Get_Fieldindex (Fld);
1087 if Res = Curses_Err then
1088 raise Form_Exception;
1090 return Positive (Natural (Res) + Positive'First);
1094 -- |=====================================================================
1095 -- | man page form_new_page.3x
1096 -- |=====================================================================
1100 procedure Set_New_Page (Fld : in Field;
1101 New_Page : in Boolean := True)
1103 function Set_Page (Fld : Field; Flg : C_Int) return C_Int;
1104 pragma Import (C, Set_Page, "set_new_page");
1106 Res : constant Eti_Error := Set_Page (Fld, Boolean'Pos (New_Page));
1109 Eti_Exception (Res);
1115 function Is_New_Page (Fld : Field) return Boolean
1117 function Is_New (Fld : Field) return C_Int;
1118 pragma Import (C, Is_New, "new_page");
1120 Res : constant C_Int := Is_New (Fld);
1122 if Res = Curses_False then
1129 procedure Free (FA : in out Field_Array_Access;
1130 Free_Fields : in Boolean := False)
1132 procedure Release is new Ada.Unchecked_Deallocation
1133 (Field_Array, Field_Array_Access);
1135 if FA /= null and then Free_Fields then
1136 for I in FA'First .. (FA'Last - 1) loop
1137 if (FA (I) /= Null_Field) then
1145 -- |=====================================================================
1147 function Default_Field_Options return Field_Option_Set
1150 return Get_Options (Null_Field);
1151 end Default_Field_Options;
1153 function Default_Form_Options return Form_Option_Set
1156 return Get_Options (Null_Form);
1157 end Default_Form_Options;
1159 end Terminal_Interface.Curses.Forms;