with Window_Io;
with Unbounded_String;
package Form is

    -- This package provides an abstraction define, display, and
    -- parse a form returning the user's responses in an iterator.


    subtype Window_Type is Window_Io.File_Type;

    type Form_Definition is private;

    function Make return Form_Definition;

    function Copy (Form : Form_Definition) return Form_Definition;
    -- returns an unaliasing copy of a form definition

    subtype Item_Name is String;

    function Default_Prompt_Font return Window_Io.Font;

    function Default_Prompt_Kind return Window_Io.Designation;

    procedure Add (Item : Item_Name;
                   Prompt : String;
                   Prompt_Font : Window_Io.Font := Default_Prompt_Font;
                   Prompt_Kind : Window_Io.Designation := Default_Prompt_Kind;
                   To_Form : in out Form_Definition);

    procedure Modify_Prompt
                 (For_Item : Item_Name;
                  New_Prompt : String := "";
                  Prompt_Font : Window_Io.Font := Default_Prompt_Font;
                  Prompt_Kind : Window_Io.Designation := Default_Prompt_Kind;
                  In_Form : in out Form_Definition);

    -- If the New_Prompt is defaulted to "" the old prompt is unchanged

    type Modification_Iterator is private;

    procedure Create (Form_Output : Window_Io.File_Type;
                      Form_Input : Window_Io.File_Type;
                      Definition : Form_Definition;
                      The_Form : out Modification_Iterator);

    -- Creates the window, displays the form, and returns an iterator of
    -- user responses.

    function Convert (Mods_Iter : Modification_Iterator) return Form_Definition;

    type Modification_Information is private;

    procedure Next (Iter : in out Modification_Iterator);
    function Is_Done (Iter : Modification_Iterator) return Boolean;
    function Value (Iter : Modification_Iterator)
                   return Modification_Information;

    function Item_Image (Mod_Info : Modification_Information) return String;
    function Response (Mod_Info : Modification_Information) return String;

    Unable_To_Parse_Response : exception;

    Item_Not_Found : exception;
private
    Item_Size : constant := 80;

    package Unbounded is new Unbounded_String (Item_Size);

    subtype Item_String is Unbounded.Variable_String;

    type Form_Item;

    type Form_Definition is access Form_Item;

    type Form_Item is
        record
            Name : Item_String;
            Prompt : Item_String;
            Prompt_Font : Window_Io.Font;
            Prompt_Kind : Window_Io.Designation;
            Next_Item : Form_Definition;
        end record;

    type Modification_Information is new Form_Item;

    type Modification_Iterator is new Form_Definition;
end Form;



