home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / DISPLAYC.MOD < prev    next >
Text File  |  1988-01-11  |  12KB  |  300 lines

  1. (*----------------------------------------------------------------------*)
  2. (*           Display_Character --- show character received from port    *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Display_Character( Ch: CHAR );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Display_Character                                    *)
  10. (*                                                                      *)
  11. (*     Purpose:    Displays character received from comm. port on       *)
  12. (*                 screen/printer/capture file.                         *)
  13. (*                                                                      *)
  14. (*     Calling Sequence:                                                *)
  15. (*                                                                      *)
  16. (*        Display_Character( Ch : CHAR );                               *)
  17. (*                                                                      *)
  18. (*           Ch         --- Character received from Comm. port.         *)
  19. (*                                                                      *)
  20. (*      Calls:   Async_Receive                                          *)
  21. (*               Min                                                    *)
  22. (*               Update_Review_Pointers                                 *)
  23. (*               TimeOfDay                                              *)
  24. (*               TimeDiff                                               *)
  25. (*                                                                      *)
  26. (*      Remarks:                                                        *)
  27. (*                                                                      *)
  28. (*         This routine strips out certain characters which             *)
  29. (*         should not be displayed, performs output line wrapping,      *)
  30. (*         and saves the output line characters in the review buffer.   *)
  31. (*                                                                      *)
  32. (*----------------------------------------------------------------------*)
  33.  
  34. (* STRUCTURED *) CONST
  35.    CR_Ch    : CHAR = ^M;
  36.    LF_Ch    : CHAR = ^J;
  37.    BL_Ch    : CHAR = ' ';
  38.                                    (* Terminal types so effect of FF *)
  39.                                    (* can be distinguished           *)
  40.    Ansi_Set : SET OF Terminal_Type
  41.               = [Ansi, VT52, VT100];
  42.  
  43. VAR
  44.    I    : INTEGER;
  45.    J    : INTEGER;
  46.    L    : INTEGER;
  47.    Xpos : INTEGER;
  48.    Ypos : INTEGER;
  49.    KeyC : CHAR;
  50.    Disp : BOOLEAN;
  51.  
  52. (*----------------------------------------------------------------------*)
  53. (*       MoveXY --- Move to (X,Y) on screen using BIOS call             *)
  54. (*----------------------------------------------------------------------*)
  55.  
  56. PROCEDURE MoveXY( X: INTEGER; Y: INTEGER );
  57.  
  58. (*----------------------------------------------------------------------*)
  59. (*                                                                      *)
  60. (*     Procedure:  MoveXY                                               *)
  61. (*                                                                      *)
  62. (*     Purpose:    Moves to specified (X,Y) position on screen          *)
  63. (*                                                                      *)
  64. (*     Calling Sequence:                                                *)
  65. (*                                                                      *)
  66. (*        MoveXY( X: INTEGER; Y: INTEGER );                             *)
  67. (*                                                                      *)
  68. (*           (X,Y)  --- Where to move to                                *)
  69. (*                                                                      *)
  70. (*----------------------------------------------------------------------*)
  71.  
  72. BEGIN (* MoveXY *)
  73.  
  74. INLINE(
  75.   $55/                   {  PUSH    BP}
  76.   $B4/$02/               {  MOV     Ah,2                    ;BIOS position cursor function}
  77.   $B7/$00/               {  MOV     Bh,0                    ;Page 0}
  78.   $8A/$B6/>Y/            {  MOV     Dh,[BP+>Y]              ;Y coordinate}
  79.   $FE/$CE/               {  DEC     Dh                      ;Drop by 1}
  80.   $8A/$96/>X/            {  MOV     Dl,[BP+>X]              ;X coordinate}
  81.   $FE/$CA/               {  DEC     Dl                      ;Drop by 1}
  82.   $CD/$10/               {  INT     $10                     ;BIOS video interrupt}
  83.   $5D);                  {  POP     BP}
  84.  
  85. END   (* MoveXY *);
  86.  
  87. (*----------------------------------------------------------------------*)
  88.  
  89. PROCEDURE Move_Chars_To_Right;
  90.  
  91. VAR
  92.    I          : INTEGER;
  93.    L          : INTEGER;
  94.    C          : CHAR;
  95.    CAttr      : BYTE;
  96.    Hold_Chars : ARRAY[1..300] OF BYTE;
  97.  
  98. BEGIN (* Move_Chars_To_Right *)
  99.  
  100.    IF ( NOT Write_Screen_Memory ) THEN
  101.       FOR I := ( Wrap_Screen_Col - 1 ) DOWNTO XPos DO
  102.          BEGIN
  103.             ReadCXY ( C, I, YPos, CAttr );
  104.             WriteCXY( C, SUCC( I ), YPos, CAttr );
  105.          END
  106.    ELSE
  107.       BEGIN
  108.                                    (* Freeze screen for DoubleDos *)
  109.  
  110.          IF ( MultiTasker = DoubleDos ) THEN
  111.             BEGIN
  112.                TurnOffTimeSharing;
  113.                Get_Screen_Address( DesqView_Screen );
  114.             END;
  115.  
  116.          L := Wrap_Screen_Col - XPos;
  117.          I := PRED( ( PRED( YPos ) * Max_Screen_Col + XPos ) SHL 1 );
  118.  
  119.          IF Wait_For_Retrace THEN
  120.             BEGIN
  121.                MoveFromScreen( DesqView_Screen^.Screen_Image[ I ],
  122.                                Hold_Chars[1], L );
  123.                MoveToScreen  ( Hold_Chars[1],
  124.                                DesqView_Screen^.Screen_Image[ I + 2 ],
  125.                                L );
  126.             END
  127.          ELSE
  128.             MOVE( DesqView_Screen^.Screen_Image[ I ],
  129.                   DesqView_Screen^.Screen_Image[ I + 2 ],
  130.                   L SHL 1 );
  131.                                    (* Unfreeze screen in DoubleDos *)
  132.  
  133.          IF ( MultiTasker = DoubleDos ) THEN
  134.             TurnOnTimeSharing
  135.                                    (* Synchronize screen for TopView *)
  136.  
  137.          ELSE IF ( MultiTasker = TopView ) THEN
  138.             Sync_Screen( I , SUCC( L ) );
  139.  
  140.       END;
  141.  
  142. END   (* Move_Chars_To_Right *);
  143.  
  144. (*----------------------------------------------------------------------*)
  145.  
  146. BEGIN (* Display_Character *)
  147.                                    (* Select display depending on *)
  148.                                    (* character.                  *)
  149.    Disp := FALSE;
  150.  
  151.    IF ( ( ORD( Ch ) < 32 ) AND ( NOT Graphics_Mode ) ) THEN
  152.       CASE ORD( Ch ) OF
  153.  
  154.          CR   :    IF Add_LF THEN
  155.                       BEGIN
  156.                          IF Capture_On THEN
  157.                             Capture_Char( LF_Ch );
  158.                          IF Printer_On THEN
  159.                             BEGIN
  160.                                Write_Prt( CR_Ch );
  161.                                Write_Prt( LF_Ch );
  162.                             END;
  163.                          WRITE( CR_Ch, LF_Ch );
  164.                          Last_Column_Hit := FALSE;
  165.                          IF Review_On THEN
  166.                             Update_Review_Pointers;
  167.                       END
  168.                    ELSE
  169.                       BEGIN
  170.                          WRITE( CR_Ch );
  171.                          Last_Column_Hit := FALSE;
  172.                          IF Printer_On THEN
  173.                             Write_Prt( CR_Ch );
  174.                       END;
  175.  
  176.          LF   :    IF NOT Add_LF THEN
  177.                       BEGIN
  178.                          IF Capture_On THEN
  179.                             Capture_Char( LF_Ch );
  180.                          WRITE( LF_Ch );
  181.                          IF Printer_On THEN
  182.                             Write_Prt( LF_Ch );
  183.                          IF Review_On THEN
  184.                             Update_Review_Pointers;
  185.                       END;
  186.  
  187.          BS   :    BEGIN
  188.                       WRITE( Ch );
  189.                       IF Capture_On THEN
  190.                          Capture_Char( Ch );
  191.                       IF Printer_On THEN
  192.                          Write_Prt( Ch );
  193.                       IF Review_On THEN
  194.                          IF ( LENGTH( Review_Line ) > 0 ) THEN
  195.                             DELETE( Review_Line, LENGTH( Review_Line ), 1 );
  196.                    END;
  197.  
  198.          NUL  :    ;               (* Strip Nulls              *)
  199.  
  200.                                    (* Strip unattached XONs    *)
  201.          XON  :    Disp := NOT Do_Xon_Xoff_Checks;
  202.  
  203.          BELL :    IF ( Not Silent_Mode ) THEN
  204.                       Sound_Bell;
  205.  
  206.          HT   :    BEGIN
  207.  
  208.                       L := 9 - WhereX MOD 8;
  209.  
  210.                       FOR I := 1 TO L DO
  211.                          BEGIN
  212.                             WRITE( BL_Ch );
  213.                             IF Review_On THEN
  214.                                IF ( LENGTH( Review_Line ) < Max_Review_Line_Length ) THEN
  215.                                   Review_Line := Review_Line + ' ';
  216.                          END;
  217.  
  218.                       IF ( Capture_On AND Exact_Capture ) THEN
  219.                          Capture_Char( Ch );
  220.  
  221.                       IF Printer_On THEN
  222.                          FOR I := 1 TO L DO
  223.                             Write_Prt( BL_Ch );
  224.  
  225.                    END;
  226.  
  227.          VT, FF:   BEGIN
  228.                       IF Capture_On THEN
  229.                          Capture_Char( Ch );
  230.                       IF Printer_On THEN
  231.                          Write_Prt( Ch );
  232.                       IF ( NOT ( Terminal_To_Emulate IN Ansi_Set ) ) THEN
  233.                          Clear_Window
  234.                       ELSE
  235.                          BEGIN
  236.                             WRITE( LF_Ch );
  237.                             IF Review_On THEN
  238.                                Update_Review_Pointers;
  239.                          END;
  240.                    END;
  241.  
  242.          ELSE
  243.                    Disp := TRUE;
  244.  
  245.       END (* CASE *)
  246.    ELSE
  247.       Disp := TRUE;
  248.  
  249.    IF Disp AND ( ORD( Ch ) <> DEL ) THEN
  250.       BEGIN
  251.  
  252.          XPos := WhereX + PRED( Upper_Left_Column );
  253.          YPos := WhereY + PRED( Upper_Left_Row    );
  254.  
  255.          IF ( XPos < Wrap_Screen_Col ) THEN
  256.             BEGIN
  257.                IF Insertion_Mode THEN
  258.                   Move_Chars_To_Right;
  259.                WriteCXY( Ch, XPos, YPos, Global_Text_Attribute );
  260.                MoveXY( SUCC( XPos ) , YPos );
  261.                Last_Column_Hit := FALSE;
  262.             END
  263.          ELSE
  264.             BEGIN
  265.                IF Auto_Wrap_Mode THEN
  266.                   BEGIN
  267.                      IF Last_Column_Hit THEN
  268.                         BEGIN
  269.                            IF ( Capture_On AND ( NOT Exact_Capture ) ) THEN
  270.                               Capture_Char( CHR( LF ) );
  271.                            WRITELN;
  272.                            XPos            := WhereX + PRED( Upper_Left_Column );
  273.                            YPos            := WhereY + PRED( Upper_Left_Row    );
  274.                         END;
  275.                      Last_Column_Hit := NOT Last_Column_Hit;
  276.                      WriteCXY( Ch, XPos, YPos, Global_Text_Attribute );
  277.                      IF ( NOT Last_Column_Hit ) THEN
  278.                         MoveXY( SUCC( XPos ) , YPos );
  279.                   END
  280.                ELSE
  281.                   BEGIN
  282.                      WriteCXY( Ch, Wrap_Screen_Col, YPos, Global_Text_Attribute );
  283.                      Last_Column_Hit := TRUE;
  284.                   END;
  285.             END;
  286.  
  287.          IF Review_On THEN
  288.             IF ( LENGTH( Review_Line ) < Max_Review_Line_Length ) THEN
  289.                Review_Line := Review_Line + Ch;
  290.  
  291.          IF Capture_On THEN
  292.             Capture_Char( Ch );
  293.  
  294.          IF Printer_On THEN
  295.             Write_Prt( Ch );
  296.  
  297.       END;
  298.  
  299. END   (* Display_Character *);
  300.