X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=Ada95%2Fhtml%2Fterminal_interface-curses-forms-field_types_s.html;h=89f8a85c6908d31d5c5ecc2f428dadb258287c5d;hp=28c6fa6b18a114eb946aeb60c33503a80c1418a7;hb=661078ddbde3ce0f3b06e95642fbb9b5fef7dca1;hpb=3a9b6a3bf0269231bef7de74757a910dedd04e0c diff --git a/Ada95/html/terminal_interface-curses-forms-field_types_s.html b/Ada95/html/terminal_interface-curses-forms-field_types_s.html index 28c6fa6b..89f8a85c 100644 --- a/Ada95/html/terminal_interface-curses-forms-field_types_s.html +++ b/Ada95/html/terminal_interface-curses-forms-field_types_s.html @@ -4,6 +4,7 @@
+ ------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- @@ -12,48 +13,229 @@ -- -- -- S P E C -- -- -- --- Version 00.92 -- +------------------------------------------------------------------------------ +-- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- --- The ncurses Ada95 binding is copyrighted 1996 by -- --- Jürgen Pfeifer, Email: Juergen.Pfeifer@T-Online.de -- +-- Permission is hereby granted, free of charge, to any person obtaining a -- +-- copy of this software and associated documentation files (the -- +-- "Software"), to deal in the Software without restriction, including -- +-- without limitation the rights to use, copy, modify, merge, publish, -- +-- distribute, distribute with modifications, sublicense, and/or sell -- +-- copies of the Software, and to permit persons to whom the Software is -- +-- furnished to do so, subject to the following conditions: -- -- -- --- Permission is hereby granted to reproduce and distribute this -- --- binding by any means and for any fee, whether alone or as part -- --- of a larger distribution, in source or in binary form, PROVIDED -- --- this notice is included with any such distribution, and is not -- --- removed from any of its header files. Mention of ncurses and the -- --- author of this binding in any applications linked with it is -- --- highly appreciated. -- +-- The above copyright notice and this permission notice shall be included -- +-- in all copies or substantial portions of the Software. -- -- -- --- This binding comes AS IS with no warranty, implied or expressed. -- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- +-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- +-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- +-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- +-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- +-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- +-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- +-- -- +-- Except as contained in this notice, the name(s) of the above copyright -- +-- holders shall not be used in advertising or otherwise to promote the -- +-- sale, use or other dealings in this Software without prior written -- +-- authorization. -- ------------------------------------------------------------------------------ +-- Jürgen Pfeifer, Email: Juergen.Pfeifer@T-Online.de -- -- Version Control: --- @Revision: 1.3 @ +-- @Revision: 1.1 @ ------------------------------------------------------------------------------ -with Ada.Finalization; use Ada.Finalization; - --- You must instantiate this package for any user defined field type --- to make it visible to the runtime. --- -generic - type User is new Ada_Defined_Field_Type with private; - type User_Access is access User; - with function Field_Check (Fld : Field; - Info : User_Access) return Boolean; - with function Character_Check (Ch : Character; - Info : User_Access) return Boolean; +with Terminal_Interface.Curses.Aux; + package Terminal_Interface.Curses.Forms.Field_Types is --- --- Nothing public. All happens magically. --- + + -- |===================================================================== + -- | Man page form_fieldtype.3x + -- |===================================================================== + + type Field_Type is abstract tagged null record; + -- Abstract base type for all field types. A concrete field type + -- is an extension that adds some data elements describing formats or + -- boundary values for the type and validation routines. + -- For the builtin low-level fieldtypes, the validation routines are + -- already defined by the low-level C library. + -- The builtin types like Alpha or AlphaNumeric etc. are defined in + -- child packages of this package. You may use one of them as example + -- how to create you own child packages for low-level field types that + -- you may have already written in C. + + type Field_Type_Access is access all Field_Type'Class; + + -- | + procedure Set_Field_Type (Fld : in Field; + Fld_Type : in Field_Type) is abstract; + -- AKA: set_field_type() + -- But: we hide the vararg mechanism of the C interface. You always + -- have to pass a single Field_Type parameter. + + -- --------------------------------------------------------------------- + + -- |===================================================================== + -- | Man page form_field_validation.3x + -- |===================================================================== + + -- | + function Get_Type (Fld : in Field) return Field_Type_Access; + -- AKA: field_type() + -- AKA: field_arg() + -- In Ada95 we can combine these. If you try to retrieve the field type + -- that is not defined as extension of the abstract tagged type above, + -- you will raise a Form_Exception. + + -- +---------------------------------------------------------------------- + -- | Private Part. + -- | Most of this is used by the implementations of the child packages. + -- | private - type Tracker is new Limited_Controlled with null record; + use Terminal_Interface.Curses.Aux; - procedure Initialize (Obj : in out Tracker); - procedure Finalize (Obj : in out Tracker); + type Makearg_Function is access + function (Args : System.Address) return System.Address; + pragma Convention (C, Makearg_Function); -end Terminal_Interface.Curses.Forms.Field_Types; + type Copyarg_Function is access + function (Usr : System.Address) return System.Address; + pragma Convention (C, Copyarg_Function); + + type Freearg_Function is access + procedure (Usr : System.Address); + pragma Convention (C, Freearg_Function); + + type Field_Check_Function is access + function (Fld : Field; Usr : System.Address) return C_Int; + pragma Convention (C, Field_Check_Function); + + type Char_Check_Function is access + function (Ch : C_Int; Usr : System.Address) return C_Int; + pragma Convention (C, Char_Check_Function); + type Choice_Function is access + function (Fld : Field; Usr : System.Address) return C_Int; + pragma Convention (C, Choice_Function); + + -- +---------------------------------------------------------------------- + -- | This must be in sync with the FIELDTYPE structure in form.h + -- | + type Low_Level_Field_Type is + record + Status : C_Short; + Ref_Count : C_Long_Int; + Left, Right : System.Address; + Makearg : Makearg_Function; + Copyarg : Copyarg_Function; + Freearg : Freearg_Function; + Fcheck : Field_Check_Function; + Ccheck : Char_Check_Function; + Next, Prev : Choice_Function; + end record; + pragma Convention (C, Low_Level_Field_Type); + type C_Field_Type is access all Low_Level_Field_Type; + + Null_Field_Type : constant C_Field_Type := null; + + -- +---------------------------------------------------------------------- + -- | This four low-level fieldtypes are the ones associated with + -- | fieldtypes handled by this binding. Any other low-level fieldtype + -- | will result in a Form_Exception is function Get_Type. + -- | + C_Generic_Type : C_Field_Type := Null_Field_Type; + C_Generic_Choice : C_Field_Type := Null_Field_Type; + C_Builtin_Router : C_Field_Type := Null_Field_Type; + C_Choice_Router : C_Field_Type := Null_Field_Type; + + procedure Wrap_Builtin (Fld : Field; + Typ : Field_Type'Class; + Cft : C_Field_Type := C_Builtin_Router); + -- This procedure has to be called by the Set_Field_Type implementation + -- for builtin low-level fieldtypes to replace it by an Ada95 + -- conformant Field_Type object. + -- The parameter Cft must be C_Builtin_Router for regular low-level + -- fieldtypes (like TYP_ALPHA or TYP_ALNUM) and C_Choice_Router for + -- low-level fieldtypes witch choice functions (like TYP_ENUM). + -- Any other value will raise a Form_Exception. + + function Make_Arg (Args : System.Address) return System.Address; + pragma Convention (C, Make_Arg); + -- This is the Makearg_Function for the internal low-level types + -- introduced by this binding. + + function Copy_Arg (Usr : System.Address) return System.Address; + pragma Convention (C, Copy_Arg); + -- This is the Copyarg_Function for the internal low-level types + -- introduced by this binding. + + procedure Free_Arg (Usr : System.Address); + pragma Convention (C, Free_Arg); + -- This is the Freearg_Function for the internal low-level types + -- introduced by this binding. + + function Field_Check_Router (Fld : Field; + Usr : System.Address) return C_Int; + pragma Convention (C, Field_Check_Router); + -- This is the Field_Check_Function for the internal low-level types + -- introduced to wrap the low-level types by a Field_Type derived + -- type. It routes the call to the corresponding low-level validation + -- function. + + function Char_Check_Router (Ch : C_Int; + Usr : System.Address) return C_Int; + pragma Convention (C, Char_Check_Router); + -- This is the Char_Check_Function for the internal low-level types + -- introduced to wrap the low-level types by a Field_Type derived + -- type. It routes the call to the corresponding low-level validation + -- function. + + function Next_Router (Fld : Field; + Usr : System.Address) return C_Int; + pragma Convention (C, Next_Router); + -- This is the Choice_Function for the internal low-level types + -- introduced to wrap the low-level types by a Field_Type derived + -- type. It routes the call to the corresponding low-level next_choice + -- function. + + function Prev_Router (Fld : Field; + Usr : System.Address) return C_Int; + pragma Convention (C, Prev_Router); + -- This is the Choice_Function for the internal low-level types + -- introduced to wrap the low-level types by a Field_Type derived + -- type. It routes the call to the corresponding low-level prev_choice + -- function. + + -- This is the Argument structure maintained by all low-level field types + -- introduced by this binding. + type Argument is record + Typ : Field_Type_Access; -- the Field_Type creating this record + Usr : System.Address; -- original arg for builtin low-level types + Cft : C_Field_Type; -- the original low-level type + end record; + type Argument_Access is access all Argument; + + -- +---------------------------------------------------------------------- + -- | + -- | Some Imports of libform routines to deal with low-level fieldtypes. + -- | + function New_Fieldtype (Fcheck : Field_Check_Function; + Ccheck : Char_Check_Function) + return C_Field_Type; + pragma Import (C, New_Fieldtype, "new_fieldtype"); + + function Set_Fieldtype_Arg (Cft : C_Field_Type; + Mak : Makearg_Function := Make_Arg'Access; + Cop : Copyarg_Function := Copy_Arg'Access; + Fre : Freearg_Function := Free_Arg'Access) + return C_Int; + pragma Import (C, Set_Fieldtype_Arg, "set_fieldtype_arg"); + + function Set_Fieldtype_Choice (Cft : C_Field_Type; + Next, Prev : Choice_Function) + return C_Int; + pragma Import (C, Set_Fieldtype_Choice, "set_fieldtype_choice"); + +end Terminal_Interface.Curses.Forms.Field_Types;