Google
 

Trailing-Edge - PDP-10 Archives - tops20-v7-ft-dist1-clock - 7-sources/scrcomcur.bli
There are 10 other files named scrcomcur.bli in the archive. Click here to see a list.
 %TITLE 'SCRCOMCUR - compute cursor position'
MODULE SCRCOMCUR (				! Compute cursor position
		IDENT = '3-001'			! File: SCRCOMCUR.BLI Edit: GB3001
		) =
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 computes the current cursor position.
!
! 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_CPUCSPOS  from module SCREEN.
! 1-002	- Regularize headers.  JBS 13-Mar-1981
! 1-003	- Rewrite for new screen logic.  JBS 12-Oct-1982
! 1-004	- Fix a couple of minor bugs.  JBS 13-Oct-1982
! 1-005	- Fix call to EDT$$FMT_CHWID.  JBS 13-Oct-1982
! 1-006	- Fix problem with SHL.  JBS 27-Oct-1982
! 1-007	- Fix the cursor position in NOTRUNCATE mode.  JBS 09-Nov-1982
! 1-008	- Fix the cursor positioning again.  JBS 10-Nov-1982
! 1-009	- Change the handling of SHF.  JBS 14-Dec-1982
! 1-010	- Correct tab at front of continued line.  JBS 15-Dec-1982
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$SC_CPUCSPOS : NOVALUE;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

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

GLOBAL ROUTINE EDT$$SC_CPUCSPOS (		! Compute cursor position
    LINE, 					! Where to return line number
    COLUMN					! Where to return column number
    ) : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine computes the current cursor position returning the line
!	and column numbers in the ref parameters LINE and COLUMN.
!
! FORMAL PARAMETERS:
!
!  LINE			Cursor's relative line number
!
!  COLUMN			Cursor's column number
!
! IMPLICIT INPUTS:
!
!	SHF
!	TI_WID
!	TRUN
!	LN_BUF
!	LN_PTR
!	LN_END
!
! IMPLICIT OUTPUTS:
!
!	NONE
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$FMT_CHWID;				! Compute the width of a character

    EXTERNAL
	SHF,				! The number of columns shifted.
	TI_WID,				! Width of terminal line.
	TRUN,				! Truncate or wrap long lines.
	LN_BUF,				! Current line buffer.
	LN_PTR,				! Current character pointer.
	LN_END;				! End of line

    LOCAL
	CP,					! Character pointer into the current record
	LIN,					! Relative line number (first line = 0)
	COL,					! Column number (first column = 0), unshifted
	CHAR,					! Current character
	CHAR_WID,				! Width of the current character
	LINE_DONE;				! 1 = we are done with this line

    LIN = 0;
    COL = 0;
    CP = CH$PTR (LN_BUF, 0, BYTE_SIZE);
    LINE_DONE = 0;

    DECR I FROM CH$DIFF (.LN_PTR, .CP) - 1 TO 0 DO
	BEGIN

	IF ( NOT .LINE_DONE)
	THEN
	    BEGIN
	    CHAR = CH$RCHAR_A (CP);
	    CHAR_WID = EDT$$FMT_CHWID (.CHAR, .COL);

	    IF ((.COL + .CHAR_WID) LEQ (.TI_WID + .SHF))
	    THEN
!+
! The character fits on this line, count it and go on to the next.
!-
		COL = .COL + .CHAR_WID
	    ELSE
!+
! The character does not fit on this line.
!-

		IF .TRUN
	 	THEN
		    BEGIN
!+
! In TRUNCATE mode, just position to the last column and terminate.
!-
		    COL = .TI_WID + .SHF - 1;
		    LINE_DONE = 1;
		    END
		ELSE
		    BEGIN
!+
! In NOTRUNCATE mode, try fitting it on the next line.  Don't produce too many lines.
!-
		    LIN = .LIN + 1;
		    COL = .SHF + 2;
!+
! We can't use .CHAR_WID in the next statement because the width of a tab may be
! different on the new line since it is in a new position.
!-

		    IF (.LIN GEQ 255) THEN LINE_DONE = 1 ELSE COL = .COL + EDT$$FMT_CHWID (.CHAR, .COL);

		    END;
	    END

        ELSE
	    EXITLOOP;

	END;

!+
! In NOTRUNCATE mode, make sure the current character will fit on this line.  If it will not,
! move the cursor to the beginning of the next line.
!-

    IF (( NOT .TRUN) AND ( NOT .LINE_DONE) AND (CH$PTR_NEQ (.LN_PTR, .LN_END)))
    THEN
	BEGIN
	CHAR = CH$RCHAR_A (CP);
	CHAR_WID = EDT$$FMT_CHWID (.CHAR, .COL);

	IF ((.COL + .CHAR_WID) GTR (.TI_WID + .SHF))
	THEN
	    BEGIN
	    LIN = .LIN + 1;
	    COL = .SHF + 2;
	    END;

	END;

    .LINE = .LIN;
    .COLUMN = MAX (0, MIN (.COL - .SHF, .TI_WID - 1));
    END;					! of routine EDT$$SC_CPUCSPOS

!<BLF/PAGE>
END						! of module SCRCOMCUR

ELUDOM