home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / pibsoft / terminal / source / dodispla.mod < prev    next >
Encoding:
Text File  |  1988-02-21  |  12.1 KB  |  348 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 : BEGIN
  105.                                Doing_Kermit_Autodown := TRUE;
  106.                                PibDownLoad( Kermit );
  107.                             END;
  108.  
  109.           DoZmodemReceive : BEGIN
  110.                                TT := Get_Zmodem_Type;
  111.                                IF ( TT <> None ) THEN
  112.                                   PibDownLoad( TT )
  113.                                ELSE
  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.                             END;
  122.  
  123.           EnterState1:  Display_Action_State := 1;
  124.  
  125.           EnterState2:  Display_Action_State := 2;
  126.  
  127.           EnterState3:  Display_Action_State := 3;
  128.  
  129.           EnterState4:  Display_Action_State := 4;
  130.  
  131.           EnterState5:  Display_Action_State := 5;
  132.  
  133.                                    (* Clear screen and home cursor *)
  134.           ClearScrH:     BEGIN
  135.                             Scroll( 1, Ansi_Last_Line, 1, Max_Screen_Col, 0,
  136.                                     ForeGround_Color, BackGround_Color );
  137.                             FillChar( Line_Attributes, 100, 0 );
  138.                             GoToXY( 1 , 1 );
  139.                          END;
  140.  
  141.                                    (* Clear cursor to end of screen *)
  142.           ClearEOS:      BEGIN
  143.  
  144.                             ClrEol;
  145.  
  146.                             FOR I := SUCC( Y ) TO Ansi_Last_Line DO
  147.                                BEGIN
  148.                                   GoToXY( 1 , I );
  149.                                   ClrEol;
  150.                                   Line_Attributes[I] := 0;
  151.                                END;
  152.  
  153.                             GoToXY( X , Y );
  154.  
  155.                          END;
  156.  
  157.                                    (* Clear start of screen to current *)
  158.                                    (* cursor position                  *)
  159.           ClearSCur:     BEGIN
  160.  
  161.                             IF ( Y > 1 ) THEN
  162.                                Scroll( 1, PRED( Y ), 1, Max_Screen_Col, 0,
  163.                                        ForeGround_Color, BackGround_Color );
  164.  
  165.                             GoToXY( 1 , Y );
  166.  
  167.                             FOR I := 1 TO X DO
  168.                                WRITE(' ');
  169.  
  170.                             FOR I := 1 TO Y DO
  171.                                Line_Attributes[I] := 0;
  172.  
  173.                          END;
  174.  
  175.                                    (* Clear entire line *)
  176.           ClearLine:     BEGIN
  177.                             GoToXY( 1 , Y );
  178.                             ClrEol;
  179.                             GoToXY( X , Y );
  180.                             Line_Attributes[Y] := 0;
  181.                          END;
  182.  
  183.                                    (* Clear cursor to end of line *)
  184.           ClearEOL:      ClrEol;
  185.  
  186.                                    (* Clear start of line to cursor *)
  187.           ClearLCur:     BEGIN
  188.                             GoToXY( 1 , Y );
  189.                             FOR I := 1 TO X DO
  190.                                WRITE(' ');
  191.                          END;
  192.  
  193.                                    (* Move cursor to top left hand corner *)
  194.  
  195.           CursorHome:    GoToXY( 1 , 1 );
  196.  
  197.                                    (* Reverse index *)
  198.           ReverseIndex:  BEGIN
  199.                             IF ( Y > 1 ) THEN
  200.                                GoToXY( X , PRED( Y ) )
  201.                             ELSE
  202.                                Scroll( 1, PRED( Max_Screen_Line ), 1,
  203.                                        Max_Screen_Col,
  204.                                        -1,
  205.                                        ForeGround_Color, BackGround_Color );
  206.                          END;
  207.  
  208.                                    (* Index *)
  209.  
  210.           Index:         Display_Character( ^J );
  211.  
  212.           TV950Video:    BEGIN
  213.                             Async_Receive_With_TimeOut( 5 , C );
  214.                             IF ( C <> TimeOut ) THEN
  215.                                CASE CHR( C ) OF
  216.                                   '0': ;
  217.                                   '2': ;
  218.                                   '4': ;
  219.                                   '8': ;
  220.                                END (* CASE *);
  221.                          END;
  222.  
  223.           StartGraphicsMode : BEGIN
  224.                                  Graphics_Mode     := TRUE;
  225.                                  Character_Set_Ptr := Display_Char_Set_Ptr[2];
  226.                               END;
  227.  
  228.           EndGraphicsMode   : BEGIN
  229.                                  Graphics_Mode     := FALSE;
  230.                                  Character_Set_Ptr := Display_Char_Set_Ptr[1];
  231.                               END;
  232.  
  233.           IdentifyVT52   : Async_Send_String( ^[ + '/Z' );
  234.  
  235.  
  236.           PrintPage:       Print_Screen;
  237.  
  238.                                    (* Toggle reverse video *)
  239.           ReverseVideo:    BEGIN
  240.                               I                := ForeGround_Color;
  241.                               ForeGround_Color := BackGround_Color;
  242.                               BackGround_Color := I;
  243.                               Global_Text_Attribute := 16 * ( BackGround_Color AND 7 ) + ForeGround_Color;
  244.                               TextColor( ForeGround_Color );
  245.                               TextBackGround( BackGround_Color );
  246.                            END;
  247.  
  248.           StartDim     :   LowVideo;
  249.  
  250.           EndDim       :   HighVideo;
  251.  
  252.                                    (* Move to screen position in VT52 format *)
  253.           CursorPosVT52:   BEGIN
  254.  
  255.                               OldX   := NewX;
  256.                               OldY   := NewY;
  257.  
  258.                               Get_Async_Integer( NewY );
  259.                               Get_Async_Integer( NewX );
  260.  
  261.                               NewY := MAX( 1 , MIN( NewY , PRED( Max_Screen_Line ) ) );
  262.                               NewX := MAX( 1 , MIN( NewX , Max_Screen_Col ) );
  263.  
  264.                               GoToXY( NewX, NewY );
  265.  
  266.                            END;
  267.  
  268.           StartAltKey:     Alt_Keypad_Mode := ON;
  269.  
  270.           EndAltKey  :     Alt_Keypad_Mode := OFF;
  271.  
  272.           StartAutoPrint:  Auto_Print_Mode := ON;
  273.  
  274.           EndAutoPrint:    Auto_Print_Mode := OFF;
  275.  
  276.  
  277.           StartPrintControl: Printer_Ctrl_Mode := ON;
  278.  
  279.           EndPrintControl  : Printer_Ctrl_Mode := OFF;
  280.  
  281.           StartVT52HoldScreen: Hold_Screen_Mode := ON;
  282.  
  283.           EndVT52HoldScreen  : Hold_Screen_Mode := OFF;
  284.  
  285.           EnterVT100:      BEGIN                (* Enter VT100 mode  *)
  286.  
  287.                               Terminal_To_Emulate := VT100;
  288.                               Done                := TRUE;
  289.  
  290.                            END;
  291.  
  292.                                         (* Indicate AutoDownload possible *)
  293.  
  294.           SendMahoneyOn : IF Mahoney_On THEN Async_Send_String( 'EXECPC2' );
  295.  
  296.           ExecPCCommands: IF Mahoney_On THEN Exec_PC_Commands;
  297. {
  298.           InsertCharA:
  299.           InsertCharB:
  300.           InsertLineA:
  301.           InsertLineB:
  302.           DeleteChar:
  303.           DeleteLine:
  304.           StartInsert:
  305.           EndInsert:
  306.           NormalVideo:
  307.           StartBlink:
  308.           EndBlink:
  309.           StartUnderline:
  310.           EndUnderline:
  311.           StartBold:
  312.           EndBold:
  313.           PrintLine:
  314.           SetTab:
  315.           ClearTab:
  316.           Swallow:
  317.           CursorPosH:
  318.           CursorPosV:
  319.           EnterVT52:
  320.           NotDone       : B := FALSE;
  321.  
  322.           EndCase       : ;
  323. }
  324.           ELSE            B := FALSE;
  325.  
  326.          END (* CASE *)
  327.  
  328.       END
  329.    ELSE
  330.       BEGIN
  331.          D_Ch := Character_Set_Ptr^[Ch];
  332.          IF Use_Dos_Con_Output THEN
  333.             Display_Character_Through_DOS( D_Ch )
  334.          ELSE
  335.             Display_Character( D_Ch );
  336.       END;
  337.  
  338.    IF B THEN
  339.       BEGIN
  340.          Do_Display_Action := TRUE;
  341.          Escape_Mode       := FALSE;
  342.       END
  343.    ELSE
  344.       Do_Display_Action := FALSE;
  345.  
  346. END   (* Do_Display_Action *);
  347.  
  348.