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 - download
Index: ┃ B T

⟦04a54ddd2⟧ TextFile

    Length: 22569 (0x5829)
    Types: TextFile
    Names: »B«

Derivation

└─⟦bfaa708f6⟧ Bits:30000531 8mm tape, Rational 1000, INSIGHT 1_3_0
    └─ ⟦c51948655⟧ »DATA« 
        └─⟦266b31e86⟧ 
            └─⟦this⟧ 

TextFile

with Parameter_Parser;
with Window_Io;
with String_Utilities;
with Unbounded_String;
package body Screen is

    package Wio renames Window_Io;

    package U_String is new Unbounded_String (80);

    type Screen_Position is
        record
            Line : Wio.Line_Number;
            Column : Wio.Column_Number;  
        end record;


    Item_Labels : constant array (Display_Item_With_Label) of Screen_Position :=
       (Weather => (12, 5),
        Flight_Info => (12, 21),
        Reservations => (12, 41),
        Stock_Market => (12, 62),
        Call => (4, 60),
        Redial => (6, 60),
        Modem => (8, 60),
        Light_On => (3, 5),
        Light_Off => (5, 5),
        Service_Call => (7, 5),
        Audio_Channel => (14, 5),
        Game => (16, 5),
        Movie => (18, 5));

    type Display_Item_Value_Record is
        record
            Value : U_String.Variable_String;
            Position : Screen_Position;
        end record;

    Item_Values : constant array (Display_Item_With_Value) of
                              Display_Item_Value_Record :=
       (Light_On => (Value => U_String.Value ("----ON----"),
                     Position => (4, 19)),
        Light_Off => (Value => U_String.Value ("---OFF----"),
                      Position => (4, 19)),
        Service_Call => (Value => U_String.Value (": ----------"),
                         Position => (7, 17)),
        Audio_Channel => (Value => U_String.Value ("1"), Position => (14, 20)),
        Game => (Value => U_String.Value ("Pong"), Position => (16, 20)),
        Movie => (Value => U_String.Value ("Airport"), Position => (18, 20)),
        Smoking_Permitted => (Value => U_String.Value ("NO SMOKING"),
                              Position => (14, 63)),
        Seat_Belt_Required => (Value => U_String.Value ("FASTEN SEAT BELT"),
                               Position => (16, 60)),
        Seat_Number => (Value => U_String.Value ("SEAT 23A"),
                        Position => (18, 64)));

    Light_Field_Values : array (State) of String (1 .. 10) :=
       (On => "----ON----", Off => "---OFF----");

    Service_Call_Field_Values : array (State) of String (1 .. 12) :=
       (On => ": ---CALL---", Off => ": ----------");

    subtype Phone_Keyboard_Text_String is String (1 .. 13);
    Phone_Keyboard_Upper_Left : constant Screen_Position :=
       (Line => 2, Column => 40);
    Phone_Keyboard_Text :
       constant array (1 .. 9) of Phone_Keyboard_Text_String :=
       (1 => "looowooowoook",
        2 => "x 1 x 2 x 3 x",
        3 => "tooonooonooou",
        4 => "x 4 x 5 x 6 x",
        5 => "tooonooonooou",
        6 => "x 7 x 8 x 9 x",
        7 => "tooonooonooou",
        8 => "x * x 0 x # x",
        9 => "mooovooovoooj"); -- When Window IO graphics characters are used,
                               -- This produces a telephone keyboard display.

    Bold : constant Wio.Font := (Wio.Plain, (Bold => True, others => False));

    package Pp is new Parameter_Parser (Option_Id => Boolean);

    function Is_Up_Arrow (The_Key : Key) return Boolean is
    begin
        return The_Key = 206  -- PC arrow keys
                   or The_Key = 201  -- PC numeric keypad
                   or The_Key = 229;  -- Rational terminal
    end Is_Up_Arrow;

    function Is_Down_Arrow (The_Key : Key) return Boolean is
    begin
        return The_Key = 207  -- PC arrow keys
                   or The_Key = 195  -- PC numeric keypad
                   or The_Key = 230;  -- Rational terminal
    end Is_Down_Arrow;

    function Is_Left_Arrow (The_Key : Key) return Boolean is
    begin
        return The_Key = 209  -- PC arrow keys
                   or The_Key = 197  -- PC numeric keypad
                   or The_Key = 232;  -- Rational terminal
    end Is_Left_Arrow;

    function Is_Right_Arrow (The_Key : Key) return Boolean is
    begin
        return The_Key = 208  -- PC arrow keys
                   or The_Key = 199  -- PC numeric keypad
                   or The_Key = 231;  -- Rational terminal
    end Is_Right_Arrow;

    function Is_Enter_Key (The_Key : Key) return Boolean is
    begin
        return The_Key = 130  -- both PC enter keys
                   or The_Key = 131  -- Rational terminal Return key
                   or The_Key = 228;  -- Rational terminal Enter key
    end Is_Enter_Key;


    function To_String (From : Display_Item) return String is  
        Location_Of_Underscore : Natural;
        Not_Found : constant := 0;
        S : constant String := Display_Item'Image (From);
        New_S : String (1 .. S'Length) := S;
    begin  
        Location_Of_Underscore := String_Utilities.Locate ('_', New_S);

        while Location_Of_Underscore > Not_Found loop
            New_S (Location_Of_Underscore) := ' ';
            Location_Of_Underscore := String_Utilities.Locate ('_', New_S);
        end loop;

        return String_Utilities.Upper_Case (New_S);
    end To_String;

    procedure Create (The_Panel : in out Panel) is
    begin
        The_Panel.Manager.Start;
    end Create;


    function Get_Selection (The_Panel : Panel) return Display_Item_With_Label is
        Current_Selection : Display_Item_With_Label;
        User_Input : Key;
    begin  
        The_Panel.Manager.Get_Current_Highlighted (Current_Selection);
        loop  
            The_Panel.Manager.Highlight (Current_Selection);
            The_Panel.Manager.Get (User_Input);
            exit when Is_Enter_Key (User_Input);

            if Is_Left_Arrow (User_Input) then
                case Current_Selection is
                    when Weather | Light_On | Light_Off |
                         Service_Call | Audio_Channel | Game | Movie =>
                        null;  -- Can't go left from here.
                    when Flight_Info | Reservations | Stock_Market =>
                        Current_Selection :=
                           Display_Item'Pred (Current_Selection);
                    when Call =>
                        Current_Selection := Light_On;
                    when Redial =>
                        Current_Selection := Light_Off;
                    when Modem =>
                        Current_Selection := Service_Call;
                end case;
            elsif Is_Right_Arrow (User_Input) then
                case Current_Selection is
                    when Stock_Market | Call | Redial | Modem |
                         Audio_Channel | Game | Movie =>
                        null;  -- Can't go right from here.
                    when Weather | Flight_Info | Reservations =>
                        Current_Selection :=
                           Display_Item'Succ (Current_Selection);
                    when Light_On =>
                        Current_Selection := Call;
                    when Light_Off =>
                        Current_Selection := Redial;
                    when Service_Call =>
                        Current_Selection := Modem;
                end case;
            elsif Is_Up_Arrow (User_Input) then
                case Current_Selection is
                    when Audio_Channel =>
                        Current_Selection := Weather;
                    when Weather | Flight_Info =>
                        Current_Selection := Service_Call;
                    when Reservations | Stock_Market =>
                        Current_Selection := Modem;
                    when Redial | Modem | Game | Movie |
                         Service_Call | Light_Off =>
                        Current_Selection :=
                           Display_Item'Pred (Current_Selection);
                    when Light_On | Call =>
                        null;  -- Can't go up from here.
                end case;
            elsif Is_Down_Arrow (User_Input) then
                case Current_Selection is
                    when Service_Call =>
                        Current_Selection := Weather;
                    when Weather | Flight_Info =>
                        Current_Selection := Audio_Channel;
                    when Redial | Call | Audio_Channel |
                         Game | Light_Off | Light_On =>
                        Current_Selection :=
                           Display_Item'Succ (Current_Selection);
                    when Modem =>
                        Current_Selection := Stock_Market;
                    when Reservations | Stock_Market | Movie =>
                        null;  -- Can't go down from here.
                end case;
            else
                null; -- ignore for now.
            end if;
        end loop;

        return Current_Selection;

    end Get_Selection;


    procedure Close (The_Panel : in out Panel) is
    begin
        The_Panel.Manager.Kill;
    end Close;

    procedure Set_Light (To_State : State; On_The_Panel : Panel) is

    begin
        On_The_Panel.Manager.Set_Light (To_State);
    end Set_Light;

    procedure Set_Service_Call (To_State : State; On_The_Panel : Panel) is
    begin
        On_The_Panel.Manager.Set_Service_Call (To_State);
    end Set_Service_Call;

    task body Panel_Manager is
        Window : Window_Io.File_Type;

        Current_Highlighted_Item : Display_Item_With_Label := Light_On;
        Last_Chosen : array (Display_Item_With_Passenger_Choices) of Positive :=
           (others => 1);

        function Input_From_User return Key is
            Input : Wio.Raw.Key;
            Stream : Wio.Raw.Stream_Type;
        begin
            Wio.Raw.Open (Stream);
            Wio.Raw.Get (Stream, Input);
            Wio.Raw.Close (Stream);
            return Key (Input);
        end Input_From_User;

        procedure Set_Choice (For_Item : Display_Item_With_Passenger_Choices;
                              From_List : Passenger_Choice_List) is
            Iter : Pp.Iterator := Pp.Parse (From_List);
            User_Input : Key;
            First_Choice : constant := 1;
            Last_Choice : Positive := First_Choice;

            function Remove_Underscores (From : String) return String is
                New_String : String (1 .. From'Length) := From;
                Underscore : constant Character := '_';
                Blank : constant Character := ' ';
            begin
                for I in New_String'First .. New_String'Last loop
                    if New_String (I) = Underscore then
                        New_String (I) := Blank;
                    end if;
                end loop;
                return New_String;
            end Remove_Underscores;

            procedure Display_Choices
                         (For_Item : Display_Item_With_Passenger_Choices;
                          From_List : in out Pp.Iterator;
                          Highlight : Positive) is  
            begin
                Wio.Position_Cursor (File => Window,
                                     Line => Item_Labels (For_Item).Line,
                                     Column => Item_Labels (For_Item).Column,
                                     Offset => 0);
                Wio.Overwrite (File => Window,
                               Item => To_String (For_Item),
                               Image => Wio.Normal,
                               Kind => Wio.Protected);
                Wio.Position_Cursor
                   (File => Window,
                    Line => Item_Values (For_Item).Position.Line,
                    Column => Item_Values (For_Item).Position.Column,
                    Offset => 0);
                Pp.Reset (From_List);
                for I in First_Choice .. Last_Choice loop
                    if I = Highlight then
                        Wio.Overwrite (File => Window,
                                       Item => Remove_Underscores
                                                  (From => Pp.Name (From_List)),
                                       Image => Bold,
                                       Kind => Wio.Protected);
                    else
                        Wio.Overwrite (File => Window,
                                       Item => Remove_Underscores
                                                  (From => Pp.Name (From_List)),
                                       Image => Wio.Normal,
                                       Kind => Wio.Protected);
                    end if;

                    if I /= Last_Choice then
                        -- Add some spaces between the choices:
                        Wio.Overwrite (File => Window,
                                       Item => "  ",
                                       Image => Wio.Normal,
                                       Kind => Wio.Protected);
                    end if;

                    Pp.Next (From_List);
                end loop;
            end Display_Choices;

            procedure Display_Choice (For_Item :
                                         Display_Item_With_Passenger_Choices;
                                      From_List : in out Pp.Iterator) is
                String_O_Blanks : constant String (1 .. 36) := (others => ' ');

                function Choice_String_Length
                            (Choice_String : String) return Natural is
                begin
                    return Choice_String'Length;
                end Choice_String_Length;

            begin
                Wio.Position_Cursor
                   (File => Window,
                    Line => Item_Values (For_Item).Position.Line,
                    Column => Item_Values (For_Item).Position.Column,
                    Offset => 0);
                Pp.Reset (From_List);
                for I in First_Choice .. Last_Chosen (For_Item) - 1 loop
                    Pp.Next (From_List);
                end loop;
                Wio.Overwrite (File => Window,
                               Item => Remove_Underscores
                                          (From => Pp.Name (From_List)),
                               Image => Wio.Normal,
                               Kind => Wio.Protected);

                -- Overwrite old choice list with blanks:
                Wio.Overwrite (File => Window,
                               Item => String_O_Blanks
                                          (Choice_String_Length
                                              (Pp.Name (From_List)) ..
                                              String_O_Blanks'Last),
                               Image => Wio.Normal,
                               Kind => Wio.Protected);

                Wio.Position_Cursor (File => Window,
                                     Line => Item_Labels (For_Item).Line,
                                     Column => Item_Labels (For_Item).Column,
                                     Offset => 0);
                Wio.Overwrite (File => Window,
                               Item => To_String (For_Item),
                               Image => Bold,
                               Kind => Wio.Protected);
            end Display_Choice;

        begin  
            while not Pp.Done (Iter) loop
                Last_Choice := Last_Choice + 1;
                Pp.Next (Iter);
            end loop;  
            Pp.Reset (Iter);
            loop
                exit when Is_Enter_Key (User_Input);
                Display_Choices (For_Item => For_Item,
                                 From_List => Iter,
                                 Highlight => Last_Chosen (For_Item));
                User_Input := Input_From_User;  
                if Is_Left_Arrow (User_Input) then  
                    if Last_Chosen (For_Item) /= First_Choice then
                        Last_Chosen (For_Item) := Last_Chosen (For_Item) - 1;
                    end if;
                elsif Is_Right_Arrow (User_Input) then
                    if Last_Chosen (For_Item) /= Last_Choice then
                        Last_Chosen (For_Item) := Last_Chosen (For_Item) + 1;
                    end if;
                else
                    null;  -- ignore unexpected input.
                end if;
            end loop;
            Display_Choice (For_Item, Iter);
        end Set_Choice;
    begin
        accept Start;
        Wio.Create (File => Window,
                    Mode => Wio.Out_File,
                    Name => "Passenger Control Panel",
                    Form => "");
        for Item in Display_Item_With_Label loop
            Wio.Position_Cursor (File => Window,
                                 Line => Item_Labels (Item).Line,
                                 Column => Item_Labels (Item).Column,
                                 Offset => 0);
            Wio.Overwrite (File => Window,
                           Item => To_String (Item),
                           Image => Wio.Normal,
                           Kind => Wio.Protected);
        end loop;

        for Item in Display_Item_With_Value loop
            Wio.Position_Cursor (File => Window,
                                 Line => Item_Values (Item).Position.Line,
                                 Column => Item_Values (Item).Position.Column,
                                 Offset => 0);
            Wio.Overwrite (File => Window,
                           Item => U_String.Image (Item_Values (Item).Value),
                           Image => Wio.Normal,
                           Kind => Wio.Protected);
        end loop;

        for Line in Phone_Keyboard_Text'Range loop
            Wio.Position_Cursor
               (File => Window,
                Line => Phone_Keyboard_Upper_Left.Line + Line - 1,
                Column => Phone_Keyboard_Upper_Left.Column,
                Offset => 0);
            Wio.Overwrite (File => Window,
                           Item => Phone_Keyboard_Text (Line),
                           Image => (Wio.Graphics, Wio.Vanilla),
                           Kind => Wio.Protected);
        end loop;

        loop
            select
                accept Get (User_Input : out Key) do
                    User_Input := Input_From_User;
                end Get;
            or
                accept Get_Current_Highlighted
                          (Item : out Display_Item_With_Label) do
                    Item := Current_Highlighted_Item;
                end Get_Current_Highlighted;
            or
                accept Highlight (Item : Display_Item_With_Label) do
                    -- Get rid of bold type on current item:
                    Wio.Position_Cursor
                       (File => Window,
                        Line => Item_Labels (Current_Highlighted_Item).Line,
                        Column => Item_Labels (Current_Highlighted_Item).Column,
                        Offset => 0);
                    Wio.Overwrite (File => Window,
                                   Item => To_String (Current_Highlighted_Item),
                                   Image => Wio.Normal,
                                   Kind => Wio.Protected);

                    -- Highlight the new item:
                    Wio.Position_Cursor  
                       (File => Window,
                        Line => Item_Labels (Item).Line,
                        Column => Item_Labels (Item).Column,
                        Offset => 0);
                    Wio.Overwrite (File => Window,
                                   Item => To_String (Item),
                                   Image => Bold,
                                   Kind => Wio.Protected);
                    Current_Highlighted_Item := Item;
                end Highlight;
            or
                accept Set_Light (To_State : State) do

                    Wio.Position_Cursor
                       (File => Window,
                        Line => Item_Values (Light_On).Position.Line,
                        Column => Item_Values (Light_On).Position.Column,

                        Offset => 0);
                    Wio.Overwrite (File => Window,
                                   Item => Light_Field_Values (To_State),
                                   Image => Wio.Normal,
                                   Kind => Wio.Protected);

                    -- Return the cursor to it's old position:
                    Wio.Position_Cursor
                       (File => Window,
                        Line => Item_Labels (Current_Highlighted_Item).Line,
                        Column => Item_Labels (Current_Highlighted_Item).Column,
                        Offset => 0);
                end Set_Light;
            or
                accept Set_Service_Call (To_State : State) do
                    Wio.Position_Cursor
                       (File => Window,
                        Line => Item_Values (Service_Call).Position.Line,
                        Column => Item_Values (Service_Call).Position.Column,
                        Offset => 0);
                    Wio.Overwrite (File => Window,
                                   Item => Service_Call_Field_Values (To_State),
                                   Image => Wio.Normal,
                                   Kind => Wio.Protected);

                    -- Return the cursor to it's old position:
                    Wio.Position_Cursor
                       (File => Window,
                        Line => Item_Labels (Current_Highlighted_Item).Line,
                        Column => Item_Labels (Current_Highlighted_Item).Column,
                        Offset => 0);
                end Set_Service_Call;
            or
                accept Get_Choice (For_Item :
                                      Display_Item_With_Passenger_Choices;
                                   From_List : Passenger_Choice_List;
                                   Choice_Number : out Positive) do
                    Set_Choice (For_Item, From_List);
                    Choice_Number := Last_Chosen (For_Item);
                end Get_Choice;
            or
                accept Kill;  
                Wio.Close (File => Window);
                exit;
            end select;
        end loop;
    end Panel_Manager;

    function Get_Choice (For_Item : Display_Item_With_Passenger_Choices;
                         From_List : Passenger_Choice_List;
                         On_The_Panel : Panel) return Passenger_Choice is
        Choice_Number : Positive;
        Iter : Pp.Iterator := Pp.Parse (From_List);
    begin  
        On_The_Panel.Manager.Get_Choice (For_Item, From_List, Choice_Number);
        for I in 1 .. Choice_Number - 1 loop
            Pp.Next (Iter);
        end loop;
        return Pp.Name (Iter);
    end Get_Choice;

end Screen;