home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / msdos / pibterm / pibt41s1.arc / DODISPLA.MOD < prev    next >
Encoding:
Text File  |  1988-03-18  |  12.1 KB  |  347 lines

  1. (*----------------------------------------------------------------------*)
  2. (*     Do_Display_Action  ---  interpret display escape sequence        *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Do_Display_Action( Ch : CHAR; VAR Done : BOOLEAN ) : BOOLEAN;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*   Function: Do_Display_Action                                        *)
  10. (*                                                                      *)
  11. (*   Purpose:  Interprets and executes display escape sequence          *)
  12. (*                                                                      *)
  13. (*   Calling sequence:                                                  *)
  14. (*                                                                      *)
  15. (*      B := Do_Display_Action( Ch : CHAR ) : BOOLEAN;                  *)
  16. (*                                                                      *)
  17. (*         Ch   --- Character to act upon                               *)
  18. (*         B    --- TRUE if display action completed                    *)
  19. (*                                                                      *)
  20. (*   Calls:  Scroll                                                     *)
  21. (*           Get_Async_Integer                                          *)
  22. (*                                                                      *)
  23. (*----------------------------------------------------------------------*)
  24.  
  25. VAR
  26.    X    : INTEGER;
  27.    Y    : INTEGER;
  28.    B    : BOOLEAN;
  29.    I    : INTEGER;
  30.    C    : INTEGER;
  31.    D_Ch : CHAR;
  32.    TT   : Transfer_Type;
  33.  
  34. BEGIN (* Do_Display_Action *)
  35.  
  36.    X := WhereX;
  37.    Y := WhereY;
  38.    B := TRUE;
  39.  
  40.    IF ( Ch = CHR( 0 ) ) THEN
  41.  
  42.    ELSE IF ( Ch = ^[ ) THEN
  43.       BEGIN
  44.          Escape_Mode := TRUE;
  45.          B           := FALSE;
  46.       END
  47.  
  48.    ELSE IF ( ( ORD( Ch ) < 32 ) OR Escape_Mode ) THEN
  49.       BEGIN
  50.  
  51.          CASE Display_Action_Ptr[Display_Action_State]^[ Ch ] OF
  52.  
  53.                                    (* Display character as is *)
  54.  
  55.           DisplayChar:   BEGIN
  56.                             D_Ch := Character_Set_Ptr^[Ch];
  57.                             IF Use_Dos_Con_Output THEN
  58.                                Display_Character_Through_DOS( D_Ch )
  59.                             ELSE
  60.                                Display_Character( D_Ch );
  61.                          END;
  62.                                    (* Move cursor up one line *)
  63.  
  64.           CursorUp:      IF ( Y > 1 ) THEN
  65.                             GoToXY( X , PRED( Y ) );
  66.  
  67.                                    (* Move cursor down one line *)
  68.  
  69.           CursorDown:    IF ( Y < Ansi_Last_Line ) THEN
  70.                             GoToXY( X , SUCC( Y ) );
  71.  
  72.                                    (* Move cursor left one column *)
  73.  
  74.           CursorLeft:    IF ( X > 1 ) THEN
  75.                             GoToXY( PRED( X ) , Y );
  76.  
  77.                                    (* Move cursor right one column *)
  78.  
  79.           CursorRight:   IF ( X < Max_Screen_Col ) THEN
  80.                             GoToXY( SUCC( X ) , Y );
  81.  
  82.                                    (* Clear screen *)
  83.           ClearScr:     BEGIN
  84.                            Scroll( 1, Ansi_Last_Line, 1, Max_Screen_Col, 0,
  85.                                    ForeGround_Color, BackGround_Color );
  86.                            FillChar( Line_Attributes, 100, 0 );
  87.                            GoToXY( X , Y );
  88.                         END;
  89.  
  90.                                    (* VT52 tabs *)
  91.  
  92.           VT52HT:       Handle_Tab( Tab_Stops , Number_Tab_Stops );
  93.  
  94.                                    (* VT52 line feeds *)
  95.  
  96.           VT52LF:       Do_VT52_LineFeeds( Ch );
  97.  
  98.           DoCISBESCI:   CISB_Term_ESC_I;
  99.  
  100.           DoCISBDLE:    CISB_DLE_Seen;
  101.  
  102.           DoCISBENQ:    CISB_Term_ENQ;
  103.  
  104.           DoKermitReceive : IF ( NOT Handle_Kermit_Autodownload ) THEN
  105.                                BEGIN
  106.                                   D_Ch := Character_Set_Ptr^[Ch];
  107.                                   IF Use_Dos_Con_Output THEN
  108.                                      Display_Character_Through_DOS( D_Ch )
  109.                                   ELSE
  110.                                      Display_Character( D_Ch );
  111.                                END;
  112.  
  113.           DoZmodemReceive : IF ( NOT Handle_Zmodem_Autodownload ) THEN
  114.                                BEGIN
  115.                                   D_Ch := Character_Set_Ptr^[Ch];
  116.                                   IF Use_Dos_Con_Output THEN
  117.                                      Display_Character_Through_DOS( D_Ch )
  118.                                   ELSE
  119.                                      Display_Character( D_Ch );
  120.                                END;
  121.  
  122.           EnterState1:  Display_Action_State := 1;
  123.  
  124.           EnterState2:  Display_Action_State := 2;
  125.  
  126.           EnterState3:  Display_Action_State := 3;
  127.  
  128.           EnterState4:  Display_Action_State := 4;
  129.  
  130.           EnterState5:  Display_Action_State := 5;
  131.  
  132.                                    (* Clear screen and home cursor *)
  133.           ClearScrH:     BEGIN
  134.                             Scroll( 1, Ansi_Last_Line, 1, Max_Screen_Col, 0,
  135.                                     ForeGround_Color, BackGround_Color );
  136.                             FillChar( Line_Attributes, 100, 0 );
  137.                             GoToXY( 1 , 1 );
  138.                          END;
  139.  
  140.                                    (* Clear cursor to end of screen *)
  141.           ClearEOS:      BEGIN
  142.  
  143.                             ClrEol;
  144.  
  145.                             FOR I := SUCC( Y ) TO Ansi_Last_Line DO
  146.                                BEGIN
  147.                                   GoToXY( 1 , I );
  148.                                   ClrEol;
  149.                                   Line_Attributes[I] := 0;
  150.                                END;
  151.  
  152.                             GoToXY( X , Y );
  153.  
  154.                          END;
  155.  
  156.                                    (* Clear start of screen to current *)
  157.                                    (* cursor position                  *)
  158.           ClearSCur:     BEGIN
  159.  
  160.                             IF ( Y > 1 ) THEN
  161.                                Scroll( 1, PRED( Y ), 1, Max_Screen_Col, 0,
  162.                                        ForeGround_Color, BackGround_Color );
  163.  
  164.                             GoToXY( 1 , Y );
  165.  
  166.                             FOR I := 1 TO X DO
  167.                                WRITE(' ');
  168.  
  169.                             FOR I := 1 TO Y DO
  170.                                Line_Attributes[I] := 0;
  171.  
  172.                          END;
  173.  
  174.                                    (* Clear entire line *)
  175.           ClearLine:     BEGIN
  176.                             GoToXY( 1 , Y );
  177.                             ClrEol;
  178.                             GoToXY( X , Y );
  179.                             Line_Attributes[Y] := 0;
  180.                          END;
  181.  
  182.                                    (* Clear cursor to end of line *)
  183.           ClearEOL:      ClrEol;
  184.  
  185.                                    (* Clear start of line to cursor *)
  186.           ClearLCur:     BEGIN
  187.                             GoToXY( 1 , Y );
  188.                             FOR I := 1 TO X DO
  189.                                WRITE(' ');
  190.                          END;
  191.  
  192.                                    (* Move cursor to top left hand corner *)
  193.  
  194.           CursorHome:    GoToXY( 1 , 1 );
  195.  
  196.                                    (* Reverse index *)
  197.           ReverseIndex:  BEGIN
  198.                             IF ( Y > 1 ) THEN
  199.                                GoToXY( X , PRED( Y ) )
  200.                             ELSE
  201.                                Scroll( 1, PRED( Max_Screen_Line ), 1,
  202.                                        Max_Screen_Col,
  203.                                        -1,
  204.                                        ForeGround_Color, BackGround_Color );
  205.                          END;
  206.  
  207.                                    (* Index *)
  208.  
  209.           Index:         Display_Character( ^J );
  210.  
  211.           TV950Video:    BEGIN
  212.                             Async_Receive_With_TimeOut( 5 , C );
  213.                             IF ( C <> TimeOut ) THEN
  214.                                CASE CHR( C ) OF
  215.                                   '0': ;
  216.                                   '2': ;
  217.                                   '4': ;
  218.                                   '8': ;
  219.                                END (* CASE *);
  220.                          END;
  221.  
  222.           StartGraphicsMode : BEGIN
  223.                                  Graphics_Mode     := TRUE;
  224.                                  Character_Set_Ptr := Display_Char_Set_Ptr[2];
  225.                               END;
  226.  
  227.           EndGraphicsMode   : BEGIN
  228.                                  Graphics_Mode     := FALSE;
  229.                                  Character_Set_Ptr := Display_Char_Set_Ptr[1];
  230.                               END;
  231.  
  232.           IdentifyVT52   : Async_Send_String( ^[ + '/Z' );
  233.  
  234.  
  235.           PrintPage:       Print_Screen;
  236.  
  237.                                    (* Toggle reverse video *)
  238.           ReverseVideo:    BEGIN
  239.                               I                := ForeGround_Color;
  240.                               ForeGround_Color := BackGround_Color;
  241.                               BackGround_Color := I;
  242.                               Global_Text_Attribute := 16 * ( BackGround_Color AND 7 ) + ForeGround_Color;
  243.                               TextColor( ForeGround_Color );
  244.                               TextBackGround( BackGround_Color );
  245.                            END;
  246.  
  247.           StartDim     :   LowVideo;
  248.  
  249.           EndDim       :   HighVideo;
  250.  
  251.                                    (* Move to screen position in VT52 format *)
  252.           CursorPosVT52:   BEGIN
  253.  
  254.                               OldX   := NewX;
  255.                               OldY   := NewY;
  256.  
  257.                               Get_Async_Integer( NewY );
  258.                               Get_Async_Integer( NewX );
  259.  
  260.                               NewY := MAX( 1 , MIN( NewY , PRED( Max_Screen_Line ) ) );
  261.                               NewX := MAX( 1 , MIN( NewX , Max_Screen_Col ) );
  262.  
  263.                               GoToXY( NewX, NewY );
  264.  
  265.                            END;
  266.  
  267.           StartAltKey:     Alt_Keypad_Mode := ON;
  268.  
  269.           EndAltKey  :     Alt_Keypad_Mode := OFF;
  270.  
  271.           StartAutoPrint:  Auto_Print_Mode := ON;
  272.  
  273.           EndAutoPrint:    Auto_Print_Mode := OFF;
  274.  
  275.  
  276.           StartPrintControl: Printer_Ctrl_Mode := ON;
  277.  
  278.           EndPrintControl  : Printer_Ctrl_Mode := OFF;
  279.  
  280.           StartVT52HoldScreen: Hold_Screen_Mode := ON;
  281.  
  282.           EndVT52HoldScreen  : Hold_Screen_Mode := OFF;
  283.  
  284.           EnterVT100:      BEGIN                (* Enter VT100 mode  *)
  285.  
  286.                               Terminal_To_Emulate := VT100;
  287.                               Done                := TRUE;
  288.  
  289.                            END;
  290.  
  291.                                         (* Indicate AutoDownload possible *)
  292.  
  293.           SendMahoneyOn : IF Mahoney_On THEN Async_Send_String( 'EXECPC2' );
  294.  
  295.           ExecPCCommands: IF Mahoney_On THEN Exec_PC_Commands;
  296. {
  297.           InsertCharA:
  298.           InsertCharB:
  299.           InsertLineA:
  300.           InsertLineB:
  301.           DeleteChar:
  302.           DeleteLine:
  303.           StartInsert:
  304.           EndInsert:
  305.           NormalVideo:
  306.           StartBlink:
  307.           EndBlink:
  308.           StartUnderline:
  309.           EndUnderline:
  310.           StartBold:
  311.           EndBold:
  312.           PrintLine:
  313.           SetTab:
  314.           ClearTab:
  315.           Swallow:
  316.           CursorPosH:
  317.           CursorPosV:
  318.           EnterVT52:
  319.           NotDone       : B := FALSE;
  320.  
  321.           EndCase       : ;
  322. }
  323.           ELSE            B := FALSE;
  324.  
  325.          END (* CASE *)
  326.  
  327.       END
  328.    ELSE
  329.       BEGIN
  330.          D_Ch := Character_Set_Ptr^[Ch];
  331.          IF Use_Dos_Con_Output THEN
  332.             Display_Character_Through_DOS( D_Ch )
  333.          ELSE
  334.             Display_Character( D_Ch );
  335.       END;
  336.  
  337.    IF B THEN
  338.       BEGIN
  339.          Do_Display_Action := TRUE;
  340.          Escape_Mode       := FALSE;
  341.       END
  342.    ELSE
  343.       Do_Display_Action := FALSE;
  344.  
  345. END   (* Do_Display_Action *);
  346.  
  347.