Google
 

Trailing-Edge - PDP-10 Archives - tops20-v7-ft-dist1-clock - 7-sources/scrcurs.bli
There are 10 other files named scrcurs.bli in the archive. Click here to see a list.
 %TITLE 'SCRCURS - conditionally position the cursor'
MODULE SCRCURS (				! Conditionally position the cursor
		IDENT = '3-004'			! File: SCRCURS.BLI Edit: CJG3004
		) =
BEGIN
!COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1981, 1988.  ALL RIGHTS RESERVED.
!
!THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ONLY
!IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION OF 
!THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY OTHER COPIES THEREOF MAY 
!NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON.  NO TITLE
!TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
!
!THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND 
!SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
!
!DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS 
!SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL.
!
!
!++
! FACILITY:	EDT -- The DEC Standard Editor
!
! ABSTRACT:
!
!	This module puts out a cursor position sequence to a specified
!	line and column, unless the cursor is already there.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: September 8, 1979
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 12-Feb-1981.  This module was created by
!	extracting the routine EDT$$SC_POSCSIF  from module SCREEN.
! 1-002	- Regularize headers and don't store into the parameter list.  This
!	   change saved two words on the PDP-11.  JBS 13-Mar-1981
! 1-003	- Always position to the last column, to avoid autowrap problems.
!	   JBS 15-Apr-1982
! 1-004	- Remove edit 1-003, since it doesn't help a VT100, and add some
!	   cursor positioning optimizations.  For now, turn off the cursor
!	   positioning optimizations, until EDT passes the QA system.  JBS 05-Oct-1982
! 1-005	- Turn the cursor positioning optimizations on, to see if EDT still
!	   passes the QA system.  JBS 15-Oct-1982
! 1-006	- When positioning below the scrolling region don't use the
!	   relative cursor motion commands.  JBS 15-Oct-1982
! 1-007	- Fix a bug involving BS.  JBS 17-Oct-1982
! 1-008	- For dumb terminal drivers, always use absolute cursor positioning.
!	   JBS 17-Oct-1982
! 1-009	- Preserve EDT$$G_FMT_LNPOS.  JBS 28-Oct-1982
! 1-010	- Changed test for being outside scrolling region.  JBS for SB 17-Jan-1983
! 1-011	- Add more error checking.  JBS 17-Jan-1983
! 3-002 - Fix a problem when the cursor is expected to be at the right
!	  margin but is actually one place beyond. This happens when SET
!	  TRUNCATE and SET SCREEN N<80 are in effect. If the screen width
!	  is set to 80 or 132 then all is OK. CJG 6-Jan-1984
! 3-003 - Add a bit more to 3-002. CJG 12-Jan-1984
! 3-004 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$SC_POSCSIF : NOVALUE;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$SC_POSCSIF  - conditionally position the cursor'

GLOBAL ROUTINE EDT$$SC_POSCSIF (		! Conditionally position the cursor
    LINE, 					! Desired line
    POS						! Desired column
    ) : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine positions the cursor to [LINE, POS].  No output is
!	produced if the cursor is already positioned correctly.
!
! FORMAL PARAMETERS:
!
!  LINE			Desired line
!
!  POS			Desired column
!
! IMPLICIT INPUTS:
!
!	PRV_LN
!	PRV_COL
!	BOT_SCREG
!	TI_DUMB
!
! IMPLICIT OUTPUTS:
!
!	NONE
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	May position the cursor.
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$SC_POSABS : NOVALUE,	! Force a cursor position sequence to the output buffer
	EDT$$STORE_FMTCH : NOVALUE,	! Store a character in the format buffer
	EDT$$FMT_DCML : NOVALUE;	! Place a decimal number in the format buffer

    EXTERNAL
	BOT_SCREG,			! Bottom of current scrolling region
	PRV_LN,				! Previous line number
	PRV_COL,			! Previous column number
	TI_TYP,				! Terminal type, either VT52 or VT100
	TI_DUMB,			! 1 = this is a dumb terminal driver
	TI_WID,				! Terminal defined width
	FMT_LNPOS;			! Cursor position, for formatting purposes.

    LOCAL
	SAVE_FMTLNPOS;

    ASSERT (21, .LINE GEQ 0);

!+
! Preserve FMT_LNPOS, since the calls to EDT$$FMT_DCML will increment it,
! but those characters do not in fact move the cursor, since they are in a control sequence.
!-

    SAVE_FMTLNPOS = .FMT_LNPOS;

!+
! If this is a dumb terminal driver, always use absolute cursor positioning
!-

    IF .TI_DUMB
    THEN

	IF ((.LINE NEQ .PRV_LN) OR (.POS NEQ .PRV_COL))	!
	THEN
	    EDT$$SC_POSABS (.LINE, .POS);

!+
! If the desired column is zero, but the current column is non-zero, issue a
! carriage return.
!-

    IF ((.POS EQL 0) AND (.POS NEQ .PRV_COL))
    THEN
	BEGIN
	EDT$$STORE_FMTCH (ASC_K_CR);
	PRV_COL = 0;
	END;

!+
! If we are positioning below the scrolling region, issue an absolute cursor position.
!-

    IF ((.LINE + 1) GEQ .BOT_SCREG) THEN EDT$$SC_POSABS (.LINE, .POS);

!+
! If the column is correct but the row is incorrect, issue an appropriate
! sequence.
!-

    IF ((.POS EQL .PRV_COL) AND (.LINE NEQ .PRV_LN))
    THEN
	BEGIN
!+
! If we are moving down one, issue a line feed.
!-

	IF (.LINE EQL (.PRV_LN + 1))
	THEN
	    BEGIN
	    EDT$$STORE_FMTCH (ASC_K_LF);
	    PRV_LN = .PRV_LN + 1;
	    END
	ELSE
!+
! Otherwise issue an appropriate relative cursor motion command.  Note that the VT52
! can only move by one.
!-

	    IF ((.TI_TYP EQL TERM_VT100) OR (ABS (.LINE - .PRV_LN) EQL 1))
	    THEN
		BEGIN
		EDT$$STORE_FMTCH (ASC_K_ESC);

		IF (.TI_TYP EQL TERM_VT100) THEN EDT$$STORE_FMTCH (%C'[');

		IF (.LINE LSS .PRV_LN)
		THEN
		    BEGIN

		    IF ((.PRV_LN - .LINE) NEQ 1) THEN EDT$$FMT_DCML (.PRV_LN - .LINE);

		    EDT$$STORE_FMTCH (%C'A');
		    PRV_LN = .LINE;
		    PRV_COL = .POS;
		    END
		ELSE
		    BEGIN
		    EDT$$FMT_DCML (.LINE - .PRV_LN);
		    EDT$$STORE_FMTCH (%C'B');
		    PRV_LN = .LINE;
		    PRV_COL = .POS;
		    END;

		END;

	END;

!+
! Now check for moving left or right.  Note again that the VT52 can only
! move by one.
!-

    IF ((.POS NEQ .PRV_COL) AND (.LINE EQL .PRV_LN))
    THEN
	BEGIN
!+
! If we are just going back one, use BS.
!-

	IF (.POS EQL (.PRV_COL - 1))
	THEN
	    BEGIN
	    IF ((.PRV_COL NEQ 80) AND (.PRV_COL NEQ 132))
	    THEN
		EDT$$STORE_FMTCH (ASC_K_BS);
	    PRV_COL = .PRV_COL - 1;
	    END
	ELSE

	    IF ((.TI_TYP EQL TERM_VT100) OR (ABS (.POS - .PRV_COL) EQL 1))
	    THEN
		BEGIN
!+
! Otherwise, use a relative cursor motion command.
!-
		EDT$$STORE_FMTCH (ASC_K_ESC);

		IF (.TI_TYP EQL TERM_VT100) THEN EDT$$STORE_FMTCH (%C'[');

		IF (.POS LSS .PRV_COL)
		THEN
		    BEGIN
		    LOCAL
			DISP;

!+
! If we are sitting just past the last logical column and the width is not
! 80 or 132 then correct the displacement.
!-

		    DISP = .PRV_COL - .POS;
		    IF ((.PRV_COL EQL .TI_WID) AND ((.TI_WID EQL 80) OR (.TI_WID EQL 132)))
		    THEN 
			DISP = .DISP - 1;
		    EDT$$FMT_DCML (.DISP);
		    EDT$$STORE_FMTCH (%C'D');
		    PRV_COL = .POS;
		    END
		ELSE
		    BEGIN

		    IF ((.POS - .PRV_COL) NEQ 1) THEN EDT$$FMT_DCML (.POS - .PRV_COL);

		    EDT$$STORE_FMTCH (%C'C');
		    PRV_COL = .POS;
		    END;

		END;

	END;

!+
! If both the column and line need to be changed, and if the desired
! column is not zero, issue an absolute cursor positioning command.
!-

    IF ((.LINE NEQ .PRV_LN) OR (.POS NEQ .PRV_COL))	!
    THEN
	EDT$$SC_POSABS (.LINE, .POS);

!+
! Restore the format line position.
!-
    FMT_LNPOS = .SAVE_FMTLNPOS;
    END;					! of routine EDT$$SC_POSCSIF

!<BLF/PAGE>
END						! of module EDT$SCRCURS

ELUDOM