home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 December / simtel1292_SIMTEL_1292_Walnut_Creek.iso / msdos / pibterm / pibt41s2.arc / PIBGOSSI.MOD < prev    next >
Text File  |  1988-03-23  |  12KB  |  316 lines

  1. (*--------------------------------------------------------------------------*)
  2. (*        Emulate_Gossip --- Gossip Mode from PibTerm to PibTerm            *)
  3. (*--------------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Emulate_Gossip;
  6.  
  7. (*--------------------------------------------------------------------------*)
  8. (*                                                                          *)
  9. (*     Procedure:  Emulate_Gossip                                           *)
  10. (*                                                                          *)
  11. (*     Purpose:    Provides split-screen gossip mode, dumb terminal         *)
  12. (*                 emulation.                                               *)
  13. (*                                                                          *)
  14. (*     Calling sequence:                                                    *)
  15. (*                                                                          *)
  16. (*        Emulate_Gossip;                                                   *)
  17. (*                                                                          *)
  18. (*     Calls:                                                               *)
  19. (*                                                                          *)
  20. (*        Async_Receive                                                     *)
  21. (*        Process_Command                                                   *)
  22. (*        PibTerm_KeyPressed                                                *)
  23. (*        Async_Send                                                        *)
  24. (*        Display_Character                                                 *)
  25. (*                                                                          *)
  26. (*     Called by:                                                           *)
  27. (*                                                                          *)
  28. (*        PibTerm (Main)                                                    *)
  29. (*                                                                          *)
  30. (*--------------------------------------------------------------------------*)
  31.  
  32. VAR
  33.    MyX                  : INTEGER;
  34.    MyY                  : INTEGER;
  35.    YourX                : INTEGER;
  36.    YourY                : INTEGER;
  37.    Save_AutoWrap        : BOOLEAN;
  38.    I                    : INTEGER;
  39.    Comm_Ch              : CHAR;
  40.    Done                 : BOOLEAN;
  41.    My_Last_Column_Hit   : BOOLEAN;
  42.    Your_Last_Column_Hit : BOOLEAN;
  43.    G_Window_Size        : INTEGER;
  44.    Divider_Line         : INTEGER;
  45.    Top_Of_Bottom        : INTEGER;
  46.    Input_Line           : AnyStr;
  47.    Save_Ansi_Last_Line  : INTEGER;
  48.    Reset_Requested      : BOOLEAN;
  49.    ClrScr_Req           : BOOLEAN;
  50.    TT                   : Transfer_Type;
  51.  
  52. (*--------------------------------------------------------------------------*)
  53. (*       Display_Status_Message --- Display message for line mode           *)
  54. (*--------------------------------------------------------------------------*)
  55.  
  56. PROCEDURE Display_Status_Message( Status_Text : AnyStr );
  57.  
  58. VAR
  59.    Save_My_X: INTEGER;
  60.    Save_My_Y: INTEGER;
  61.  
  62. BEGIN (* Display_Status_Message *)
  63.  
  64.    Save_My_X := MyX;
  65.    Save_My_Y := MyY;
  66.  
  67.    WriteSXY( Status_Text, 55, Divider_Line, Global_Text_Attribute );
  68.  
  69.    MyX := Save_My_X;
  70.    MyY := Save_My_Y;
  71.  
  72. END   (* Display_Status_Message *);
  73.  
  74. (*--------------------------------------------------------------------------*)
  75. (*  Do_Gossip_Line_Mode --- Process keyboard input for gossip line mode     *)
  76. (*--------------------------------------------------------------------------*)
  77.  
  78. PROCEDURE Do_Gossip_Line_Mode;
  79.  
  80. VAR
  81.    Ch                    : CHAR;
  82.    Save_Gossip_Line_Mode : BOOLEAN;
  83.  
  84. BEGIN (* Do_Gossip_Line_Mode *)
  85.                                    (* Read in entire line *)
  86.    IF PibTerm_KeyPressed THEN
  87.       BEGIN
  88.  
  89.          PibTerm_Window( 1, Top_Of_Bottom, Max_Screen_Col, Ansi_Last_Line );
  90.          GoToXY( MyX, MyY );
  91.                                    (* Get first character *)
  92.          Read_Kbd( Comm_Ch );
  93.  
  94.          IF ( Comm_Ch = CHR( CR ) ) THEN
  95.             BEGIN
  96.                Display_Status_Message(' Sending line ====');
  97.                Async_Send_String( Input_Line );
  98.                Input_Line := '';
  99.                Display_Status_Message(' Line sent =======');
  100.             END
  101.          ELSE IF ( Comm_Ch = CHR( ESC ) ) THEN
  102.             BEGIN
  103.                Save_Gossip_Line_Mode := Gossip_Line_Mode;
  104.                Process_Command( Comm_Ch, FALSE, PibTerm_Command );
  105.                IF PibTerm_Command <> Null_Command THEN
  106.                   Execute_Command( PibTerm_Command, Done, FALSE );
  107.                IF ( Gossip_Line_Mode <> Save_Gossip_Line_Mode ) THEN
  108.                   IF Gossip_Line_Mode THEN
  109.                      Display_Status_Message(' Awaiting input ==' )
  110.                   ELSE
  111.                      Display_Status_Message('==================' );
  112.             END
  113.          ELSE
  114.             BEGIN
  115.                Display_Status_Message(' Reading keyboard ');
  116.                Input_Line := Comm_Ch;
  117.                Ch := Edit_String( Input_Line, 255, 1, 2, WhereY,
  118.                                   Max_Screen_Col, FALSE, 0 );
  119.                IF ( Ch <> CHR( ESC ) ) THEN
  120.                   BEGIN
  121.                      WRITELN;
  122.                      Input_Line := Input_Line + CHR( CR );
  123.                      Display_Status_Message(' Waiting to send =');
  124.                   END
  125.                ELSE
  126.                   BEGIN
  127.                      Input_Line := '';
  128.                      Display_Status_Message(' Input cancelled ==');
  129.                   END;
  130.             END;
  131.                                    (* Remember position! *)
  132.             MyX := WhereX;
  133.             MyY := WhereY;
  134.  
  135.          END;
  136.  
  137. END   (* Do_Gossip_Line_Mode *);
  138.  
  139. (*--------------------------------------------------------------------------*)
  140. (*  Do_Gossip_Character_Mode --- Process kbd input for gossip char. mode    *)
  141. (*--------------------------------------------------------------------------*)
  142.  
  143. PROCEDURE Do_Gossip_Character_Mode;
  144.  
  145. BEGIN (* Do_Gossip_Character_Mode *)
  146.  
  147.                                    (* Process local user's input      *)
  148.    IF PibTerm_KeyPressed THEN
  149.       BEGIN
  150.                                    (* Move to local input window *)
  151.  
  152.          PibTerm_Window( 1, Top_Of_Bottom, Max_Screen_Col, Ansi_Last_Line );
  153.          GoToXY( MyX, MyY );
  154.                                    (* Handle input character *)
  155.  
  156.          Handle_Keyboard_Input( Done , Reset_Requested , ClrScr_Req );
  157.  
  158.          IF ( Reset_Requested OR ClrScr_Req ) THEN
  159.             Clear_Window;
  160.  
  161.                                    (* Remember position! *)
  162.          MyX := WhereX;
  163.          MyY := WhereY;
  164.  
  165.       END (* PibTerm_KeyPressed *);
  166.  
  167. END   (* Do_Gossip_Character_Mode *);
  168.  
  169. (*--------------------------------------------------------------------------*)
  170.  
  171. BEGIN (* Emulate_Gossip *)
  172.                                    (* Ensure we're in text mode *)
  173.  
  174.    Init_Text_Terminal;
  175.                                    (* Set status line *)
  176.  
  177.    Set_Status_Line_Name(Short_Terminal_Name);
  178.  
  179.                                    (* Status line to last line *)
  180.  
  181.    Do_Status_Line      := Show_Status_Line;
  182.    Do_Status_Time      := Do_Status_Line AND Show_Status_Time;
  183.    Current_Status_Time := -1;
  184.  
  185.    IF Do_Status_Line THEN
  186.       BEGIN
  187.          Ansi_Last_Line := PRED( Max_Screen_Line );
  188.          Write_To_Status_Line( Status_Line_Name, 1 );
  189.          Update_Status_Line;
  190.       END
  191.    ELSE
  192.       Ansi_Last_Line := Max_Screen_Line;
  193.  
  194.                                    (* Set initial positions for each  *)
  195.                                    (* user's message area.            *)
  196.    MyX            := 1;
  197.    MyY            := 1;
  198.    YourX          := 1;
  199.    YourY          := 1;
  200.    Done           := FALSE;
  201.    Input_Line     := '';
  202.    G_Window_Size  := Gossip_Window_Size;
  203.  
  204.                                    (* Ensure proper wrapping *)
  205.    My_Last_Column_Hit   := FALSE;
  206.    Your_Last_Column_Hit := FALSE;
  207.    Save_AutoWrap        := Auto_Wrap_Mode;
  208.    Auto_Wrap_Mode       := TRUE;
  209.  
  210.                                    (* Split screen into two parts:    *)
  211.                                    (* Upper for local user, lower for *)
  212.                                    (* remote user.                    *)
  213.  
  214.    PibTerm_Window( 1, 1, Max_Screen_Col, Ansi_Last_Line );
  215.    Clear_Window;
  216.                                    (* Print divider                   *)
  217.  
  218.    Divider_Line  := SUCC( G_Window_Size );
  219.    Top_Of_Bottom := SUCC( Divider_Line  );
  220.  
  221.    GoToXY( 1 , Divider_Line );
  222.  
  223.    FOR I := 1 TO 34 DO WRITE('=');
  224.    WRITE('Gossip Mode');
  225.    FOR I := 1 TO 35 DO WRITE('=');
  226.  
  227.    IF Gossip_Line_Mode THEN
  228.       Display_Status_Message(' Awaiting input ==' );
  229.  
  230.    Do_Script_Tests := Waitstring_Mode OR When_Mode OR
  231.                       WaitCount_Mode  OR WaitQuiet_Mode OR
  232.                       Script_Learn_Mode;
  233.  
  234.    REPEAT
  235.                                    (* Process local user's input      *)
  236.       IF Gossip_Line_Mode THEN
  237.          Do_Gossip_Line_Mode
  238.       ELSE
  239.          Do_Gossip_Character_Mode;
  240.                                    (* Process script file entry *)
  241.  
  242.       IF ( Script_File_Mode AND ( NOT ( Done OR Really_Wait_String ) ) ) THEN
  243.          BEGIN
  244.             Get_Script_Command( PibTerm_Command );
  245.             Execute_Command   ( PibTerm_Command , Done , TRUE );
  246.          END;
  247.                                    (* Hold everything while scroll lock on *)
  248.       IF Scroll_Lock_On THEN
  249.          Handle_Scroll_Lock;
  250.                                    (* Process remote user's input *)
  251.  
  252.       IF Async_Receive( Comm_Ch ) THEN
  253.  
  254.          BEGIN  (* Comm_Ch found *)
  255.  
  256.             Save_Ansi_Last_Line := Ansi_Last_Line;
  257.             Ansi_Last_Line      := G_Window_Size;
  258.  
  259.             PibTerm_Window( 1, 1, Max_Screen_Col, G_Window_Size );
  260.             GoToXY( YourX, YourY );
  261.  
  262.             Last_Column_Hit := Your_Last_Column_Hit;
  263.             Comm_Ch         := TrTab[ Comm_Ch ];
  264.  
  265.             CASE ORD( Comm_Ch ) OF
  266.  
  267.                SOH : IF ( NOT Handle_Kermit_Autodownload ) THEN
  268.                         Display_Character( Comm_Ch );
  269.  
  270.                CAN : IF ( NOT Handle_Zmodem_Autodownload ) THEN
  271.                         Display_Character( Comm_Ch );
  272.  
  273.                ELSE  Display_Character( Comm_Ch );
  274.  
  275.             END (* CASE *);
  276.  
  277.             IF Do_Script_Tests THEN
  278.                Do_Script_Checks( Comm_Ch );
  279.  
  280.             Your_Last_Column_Hit := Last_Column_Hit;
  281.             Ansi_Last_Line       := Save_Ansi_Last_Line;
  282.  
  283.             YourX := WhereX;
  284.             YourY := WhereY;
  285.  
  286.          END (* Comm_Ch found *)
  287.                                    (* Check if waitstring time exhausted *)
  288.       ELSE
  289.          BEGIN
  290.             Async_Line_Status := Async_Line_Status AND $FD;
  291.             IF Really_Wait_String THEN
  292.                Check_Wait_String_Time;
  293.             IF ( NOT PibTerm_KeyPressed ) THEN
  294.                GiveAwayTime( 1 );
  295.          END;
  296.                                     (* Send saved line if at left margin *)
  297.       IF ( YourX = 1 ) THEN
  298.          IF ( LENGTH( Input_Line ) > 0 ) THEN
  299.             BEGIN
  300.                Display_Status_Message(' Sending line ====');
  301.                Async_Send_String( Input_Line );
  302.                Input_Line := '';
  303.                Display_Status_Message(' Line sent =======' );
  304.             END;
  305.  
  306.    UNTIL ( NOT Gossip_Mode_On ) OR Done;
  307.  
  308.                                   (* Restore single screen mode *)
  309.  
  310.    Auto_Wrap_Mode      := Save_AutoWrap;
  311.  
  312.    PibTerm_Window( 1, 1, Max_Screen_Col, Ansi_Last_Line );
  313.    Clear_Window;
  314.  
  315. END    (* Emulate_Gossip *);
  316.