DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦51a736851⟧ TextFile

    Length: 9447 (0x24e7)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with Window_Io;
with Fonts, Window_Utilities;
package body Form is

    Blank_Line : Unbounded.Variable_String := Unbounded.Value ("");


    function "=" (D1, D2 : Window_Io.Designation) return Boolean
        renames Window_Io."=";

    function Tail (F : Form_Definition) return Form_Definition is
        Temp : Form_Definition := F;
    begin
        if F = null then
            return F;
        end if;

        while Temp.Next_Item /= null loop
            Temp := Temp.Next_Item;
        end loop;

        return Temp;
    end Tail;

    function Find_Definition (For_Item : String; In_Def : Form_Definition)
                             return Form_Definition is

        Temp : Form_Definition := In_Def;
    begin
        if In_Def = null then
            raise Item_Not_Found;
        end if;

        while Temp /= null loop
            if Unbounded.Image (Temp.Name) = For_Item then
                return Temp;
            end if;

            Temp := Temp.Next_Item;
        end loop;

        raise Item_Not_Found;

    end Find_Definition;

    function Make return Form_Definition is
    begin
        return null;
    end Make;

    function Copy (Form : Form_Definition) return Form_Definition is

        Form_Copy : Form_Definition :=
           new Form_Item'(Blank_Line, Blank_Line, Window_Io.Normal,
                          Window_Io.Prompt, null);
        Temp_Copy : Form_Definition := Form_Copy;

        Temp : Form_Definition := Form;
    begin
        while Temp /= null loop
            declare
                Name_String : Item_String;
                Prompt_String : Item_String;
            begin
                Unbounded.Copy (Name_String, Temp.Name);
                Unbounded.Copy (Prompt_String, Temp.Prompt);
                Temp_Copy.Next_Item :=
                   new Form_Item'(Name_String, Prompt_String,
                                  Temp.Prompt_Font, Temp.Prompt_Kind, null);
            end;

            Temp_Copy := Temp_Copy.Next_Item;
            Temp := Temp.Next_Item;
        end loop;

        return Form_Copy.Next_Item;
    end Copy;

    function Default_Prompt_Font return Window_Io.Font is
    begin
        return Fonts.Inverse_Bold;
    end Default_Prompt_Font;

    function Default_Prompt_Kind return Window_Io.Designation is
    begin
        return Window_Io.Prompt;
    end Default_Prompt_Kind;

    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) is

        Name_String : Item_String;
        Prompt_String : Item_String;

        Last : Form_Definition := Tail (To_Form);
    begin
        Unbounded.Copy (Name_String, Item);
        Unbounded.Copy (Prompt_String, Prompt);

        if To_Form = null then
            To_Form := new Form_Item'(Name_String, Prompt_String,
                                      Prompt_Font, Prompt_Kind, null);
        else
            Last.Next_Item := new Form_Item'(Name_String, Prompt_String,
                                             Prompt_Font, Prompt_Kind, null);
        end if;

    end Add;

    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) is

        The_Item : Form_Definition := Find_Definition (For_Item, In_Form);
    begin
        if New_Prompt /= "" then
            Unbounded.Copy (The_Item.Prompt, New_Prompt);
        end if;

        The_Item.Prompt_Font := Prompt_Font;
        The_Item.Prompt_Kind := Prompt_Kind;
    end Modify_Prompt;

    procedure Display_Form (Output_Window : Window_Io.File_Type;
                            Form          : Form_Definition) is
        Temp_Form : Form_Definition := Form;

        First_Prompt_Column : Positive;
        First_Prompt_Line   : Positive;

        A_Char : Character;
    begin
        Window_Io.Position_Cursor (Output_Window);

        while Temp_Form /= null loop
            Window_Io.Insert (Output_Window,
                              Unbounded.Image (Temp_Form.Name) & " : ",
                              Kind => Window_Io.Protected);

            if Temp_Form.Prompt_Kind = Window_Io.Prompt then
                Window_Io.Report_Cursor (File   => Output_Window,
                                         Line   => First_Prompt_Line,
                                         Column => First_Prompt_Column);
            end if;

            for I in 1 .. Unbounded.Length (Temp_Form.Prompt) loop
                A_Char := Unbounded.Char_At (Temp_Form.Prompt, I);

                if A_Char = Ascii.Lf then
                    Window_Io.New_Line (Output_Window, 1);
                else
                    Window_Io.Insert (Output_Window, A_Char,
                                      Image => Temp_Form.Prompt_Font,
                                      Kind  => Temp_Form.Prompt_Kind);
                end if;
            end loop;

            Window_Io.New_Line (Output_Window, 1);
            Temp_Form := Temp_Form.Next_Item;
        end loop;

        Window_Io.Position_Cursor (File   => Output_Window,
                                   Line   => First_Prompt_Line,
                                   Column => First_Prompt_Column);
    end Display_Form;

    function Begins_With (S : String; In_String : String) return Boolean is
    begin
        return
           In_String (In_String'First .. In_String'First + S'Length - 1) = S;
    exception
        when Constraint_Error =>
            return False;
    end Begins_With;

    function Strip (S : String; From_String : String) return String is
    begin
        return From_String (From_String'First + S'Length .. From_String'Last);
    end Strip;

    function Parse_Form (Input_Window : Window_Io.File_Type;
                         Form : Form_Definition) return Modification_Iterator is

        Replies_Form : Form_Definition := Copy (Form);

        Temp_Replies_Form : Form_Definition := Replies_Form;
    begin
        Window_Io.Position_Cursor (Input_Window);

        if Begins_With (Unbounded.Image (Temp_Replies_Form.Name) & " : ",
                        Window_Io.Line_Image (Input_Window)) then

            Unbounded.Copy
               (Temp_Replies_Form.Prompt,
                Strip (Unbounded.Image (Temp_Replies_Form.Name) & " : ",
                       Window_Io.Line_Image (Input_Window)));
        else
            raise Unable_To_Parse_Response;
        end if;

        for L in 2 .. Window_Io.Last_Line (Input_Window) loop
            Window_Utilities.Next_Line (Input_Window);

            if Temp_Replies_Form.Next_Item /= null and then
               Begins_With
                  (Unbounded.Image (Temp_Replies_Form.Next_Item.Name) & " : ",
                   Window_Io.Line_Image (Input_Window)) then

                Temp_Replies_Form := Temp_Replies_Form.Next_Item;

                Unbounded.Copy (Temp_Replies_Form.Prompt,
                                Strip (Unbounded.Image
                                          (Temp_Replies_Form.Name) & " : ",
                                       Window_Io.Line_Image (Input_Window)));
            else
                Unbounded.Append (Temp_Replies_Form.Prompt, Ascii.Lf);
                Unbounded.Append (Temp_Replies_Form.Prompt,
                                  Window_Io.Line_Image (Input_Window));
            end if;
        end loop;

        if Temp_Replies_Form.Next_Item /= null then
            raise Unable_To_Parse_Response;
        end if;

        return Modification_Iterator (Replies_Form);
    end Parse_Form;

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

        Out_Char : Character;
    begin
        Window_Utilities.Erase (Form_Output);
        Display_Form (Form_Output, Definition);

        Window_Io.Get (Form_Input, "", Out_Char);

        The_Form := Parse_Form (Form_Input, Definition);

    exception



        when Unable_To_Parse_Response =>
            raise;
    end Create;

    function Convert (Mods_Iter : Modification_Iterator)
                     return Form_Definition is
    begin
        return Copy (Form_Definition (Mods_Iter));
    end Convert;

    procedure Next (Iter : in out Modification_Iterator) is
    begin
        if Iter /= null then
            Iter := Modification_Iterator (Iter.Next_Item);
        end if;

    end Next;

    function Is_Done (Iter : Modification_Iterator) return Boolean is
    begin
        return Iter = null;
    end Is_Done;

    function Value (Iter : Modification_Iterator)
                   return Modification_Information is
    begin
        return Modification_Information (Iter.all);
    end Value;

    function Item_Image (Mod_Info : Modification_Information) return String is
    begin
        return Unbounded.Image (Mod_Info.Name);
    end Item_Image;

    function Response (Mod_Info : Modification_Information) return String is
    begin
        return Unbounded.Image (Mod_Info.Prompt);
    end Response;
end Form;