Google
 

Trailing-Edge - PDP-10 Archives - BB-H138F-BM_1988 - 7-sources/fixnotrun.bli
There are 10 other files named fixnotrun.bli in the archive. Click here to see a list.
 %TITLE 'FIXNOTRUN - Fix screen data base in NOTRUNCATE mode'
MODULE FIXNOTRUN (				! Fix screen data base in NOTRUNCATE mode
		IDENT = '3-001'			! File: FIXNOTRUN.BLI Edit: CJG3001
		) =
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 fixes up the screen data base if we are in NOTRUNCATE mode.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: John Sauter, CREATION DATE: November 1, 1983
!
! MODIFIED BY:
!
! 1-001	- Original.  This is a stub which always forces the data base to be rebuilt.
!	   JBS 01-Nov-1982
! 1-002	- Enable this routine.  JBS 02-Nov-1982
! 1-003	- Fix a problem in counting records.  JBS 09-Nov-1982
! 1-004 - Fix backwards search bug.  SMB 23-Nov-1982
! 1-005	- Worry about deleted lines when scanning backwards.  JBS 25-Nov-1982
! 1-006	- Revise handling of EDT$$G_SHF.  JBS 14-Dec-1982
! 1-007	- Fix tabbing at the end of a line.  JBS 15-Dec-1982
! 1-008	- Remove the edit buffer.  JBS 27-Dec-1982
! 1-009	- Fix a bug in finding the current screen pointer which caused excessive rebuilding.  JBS 30-Dec-1982
! 3-001 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$FIX_NOTRUNC : NOVALUE;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$FIX_NOTRUNC - fix screen data base in NOTRUNCATE mode'

GLOBAL ROUTINE EDT$$FIX_NOTRUNC 		! Fix screen data base in NOTRUNCATE mode
    : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Fix the screen data base if we are in NOTRUNCATE mode.  If a character is
!	inserted on a line, or deleted from a line, or even replaced (since characters
!	have different widths), the limits of this line must be recomputed.  If this line's
!	limits change the limits of the next line may also change.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	LN_PTR
!	LN_BUF
!	CUR_SCRPTR
!	FST_SCRPTR
!	FST_AVLN
!	CUR_SCRLN
!	SCR_BUF
!	CUR_BUF
!	CS_LN
!	CUR_SCRLN
!	CSR_SCRPTR
!	WK_LN
!	MEM_CNT
!	SHF
!	TI_WID
!
! IMPLICIT OUTPUTS:
!
!	SCR_REBUILD
!	FST_AVLN
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	MANY
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$CMP_LNO,			! compare line numbers
	EDT$$SC_MOVTOLN,		! Move to a record in the work file relative to the current record
	EDT$$FMT_CHWID,				! Compute the width of a character
	EDT$$SC_FNDREC;				! Find the screen pointer for the current record

    EXTERNAL
	LN_PTR,				! Current line character position
	LN_BUF,				! Current line buffer
	SCR_REBUILD,			! Rebuild the screen data base
	FST_SCRPTR : REF SCREEN_LINE,	! First screen line info address
	FST_AVLN : REF SCREEN_LINE,	! List of available lines
	LNO_EMPTY : REF LN_BLOCK,
	CUR_SCRLN : REF LN_BLOCK,
	SCR_BUF : REF TBCB_BLOCK,
	CUR_BUF : REF TBCB_BLOCK,
	CS_LN : REF LN_BLOCK,
	CSR_SCRPTR : REF SCREEN_LINE,
	WK_LN : REF LIN_BLOCK,
	MEM_CNT,
	SHF,				! Number of columns shifted
	TI_WID;

    LOCAL
	SCRPTR : REF SCREEN_LINE,		! Address of a current screen line buffer
	NXT_SCRPTR : REF SCREEN_LINE,		! Address of next screen line buffer
	REC_NO,					! Current relative reocrd number
	FST_RECNO,			! Relative record number of first line in the screen data base
	UPDATE_DONE,
	ANOTHER_PASS,
	WIDTH,
	DISP,
	COL,
	LEFT,
	RIGHT,
	DIR,
	TXT,
	CHAR,
	LEN;

!+
! If we are already going to rebuild the screen data base, just return.
!-

    IF .SCR_REBUILD THEN RETURN;

!+
! Compute the direction of motion.
!-

    IF (EDT$$CMP_LNO (LNO_EMPTY, CUR_SCRLN) EQL 0) OR (.SCR_BUF NEQA .CUR_BUF)
    THEN
	DIR = 1
    ELSE
	DIR = EDT$$CMP_LNO (CS_LN, CUR_SCRLN);

!+
! Find the relative record number of the old cursor line.
! We must be careful of deleted lines.  The convention is that a deleted line
! has the record number of the next lower line.  This prevents deleted
! lines before record zero from having negative absolute record numbers.
!-
    SCRPTR = EDT$$SC_FNDREC (CH$DIFF (.LN_PTR, CH$PTR (LN_BUF,, BYTE_SIZE)), DISP);

    IF (.SCRPTR EQLA 0)
    THEN
	BEGIN
	SCR_REBUILD = 1;
	RETURN;
	END;

    REC_NO = 0;

    CASE .DIR FROM -1 TO 1 OF
	SET

	[1] :
	    BEGIN
!+
! The new line is after the old.  We must move back in the work file.
!-

	    DO
		BEGIN

		IF ((.SCRPTR [SCR_LINE_IDX] EQL 0) OR ((.SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) NEQ 0))
		THEN
		    BEGIN

		    LOCAL
			PREV_SCRPTR : REF SCREEN_LINE;

		    PREV_SCRPTR = .SCRPTR [SCR_PRV_LINE];

		    IF (.PREV_SCRPTR NEQA 0)
		    THEN
			BEGIN

			IF ((.PREV_SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) EQL 0)
			THEN
			    REC_NO = .REC_NO - 1;

			END;

		    END;

		SCRPTR = .SCRPTR [SCR_PRV_LINE];
		END
	    UNTIL ((.SCRPTR EQLA .CSR_SCRPTR) OR (.SCRPTR EQLA 0));

	    END;

	[0] :
	    BEGIN
!+
! We are positioned correctly in the work file.
!-
	    SCRPTR = .CSR_SCRPTR;
	    END;

	[-1] :
	    BEGIN
!+
! The new line is before the old.  We must move forward in the work file.
!-

	    DO
		BEGIN

		LOCAL
		    NEXT_SCRPTR : REF SCREEN_LINE;

		NEXT_SCRPTR = .SCRPTR [SCR_NXT_LINE];

		IF (.NEXT_SCRPTR NEQA 0)
		THEN
		    BEGIN

		    IF (((.SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) EQL 0) AND 	!
			((.NEXT_SCRPTR [SCR_LINE_IDX] EQL 0) OR 	!
			((.NEXT_SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) NEQ 0)))
		    THEN
			REC_NO = .REC_NO + 1;

		    END;

		SCRPTR = .SCRPTR [SCR_NXT_LINE];
		END
	    UNTIL ((.SCRPTR EQLA .CSR_SCRPTR) OR (.SCRPTR EQLA 0));

	    END;

	[OUTRANGE] :
	    ASSERT (11, 0);
	TES;

!+
! If we couldn't find it, rebuild the screen data base.
!-

    IF (.SCRPTR NEQA .CSR_SCRPTR)
    THEN
	BEGIN
	SCR_REBUILD = 1;
	RETURN;
	END;

!+
! Now work backwards to the first line.
!-

    WHILE ((.SCRPTR NEQA .FST_SCRPTR) AND (.SCRPTR NEQA 0)) DO
	BEGIN

	IF ((.SCRPTR [SCR_LINE_IDX] EQL 0) OR ((.SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) NEQ 0))
	THEN
	    BEGIN

	    LOCAL
		PREV_SCRPTR : REF SCREEN_LINE;

	    PREV_SCRPTR = .SCRPTR [SCR_PRV_LINE];

	    IF (.PREV_SCRPTR NEQA 0)
	    THEN
		BEGIN

		IF ((.PREV_SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) EQL 0) THEN REC_NO = .REC_NO - 1;

		END;

	    END;

	SCRPTR = .SCRPTR [SCR_PRV_LINE];
	END;

    FST_RECNO = .REC_NO;
!+
! If we didn't find it, rebuild the screen data base.
!-

    IF (.SCRPTR NEQA .FST_SCRPTR)
    THEN
	BEGIN
	SCR_REBUILD = 1;
	RETURN;
	END;

!+
! Recompute the end points of any lines which have changed.
!-

    DO
	BEGIN
	ANOTHER_PASS = 0;
	REC_NO = .FST_RECNO;
	SCRPTR = .FST_SCRPTR;

	DO
	    BEGIN
	    UPDATE_DONE = 0;

	    IF ((.SCRPTR [SCR_EDIT_FLAGS] AND (SCR_EDIT_MODIFY OR SCR_EDIT_INSLN)) NEQ 0)
	    THEN
		BEGIN
!+
! Compute the width of the current line.
!-
		LEFT = .SCRPTR [SCR_CHR_FROM];

		IF (.LEFT EQL 0)
		THEN
		    BEGIN
		    WIDTH = .TI_WID + .SHF;
		    COL = 0;
		    END
		ELSE
		    BEGIN
		    WIDTH = .TI_WID + .SHF;
		    COL = .SHF + 2;
		    END;

!+
! We must compute the width of each character to see how many will fit.
!-
		ASSERT (12, EDT$$SC_MOVTOLN (.REC_NO));
		LEN = .WK_LN [LIN_LENGTH] - .LEFT;
		TXT = CH$PTR (WK_LN [LIN_TEXT], .LEFT, BYTE_SIZE);
		RIGHT = .LEFT - 1;
		CHAR = CH$RCHAR_A (TXT);

		WHILE ((.LEN GTR 0) AND ((.COL + EDT$$FMT_CHWID (.CHAR, .COL)) LEQ .WIDTH)) DO
		    BEGIN
		    LEN = .LEN - 1;
		    RIGHT = .RIGHT + 1;
		    COL = .COL + EDT$$FMT_CHWID (.CHAR, .COL);
		    CHAR = CH$RCHAR_A (TXT);
		    END;

		IF (.LEN EQL 0) THEN RIGHT = 255;

		IF (.SCRPTR [SCR_CHR_TO] NEQ .RIGHT)
		THEN
		    BEGIN
!+
! This line's width has changed.  Store the new width and
! arrange to recompute the width of the next line.
!-
		    SCRPTR [SCR_CHR_TO] = .RIGHT;
		    NXT_SCRPTR = .SCRPTR [SCR_NXT_LINE];
!+
! If there is no next line in the screen data base and we need one, do it the hard way.
!-

		    IF (.RIGHT NEQ 255)
		    THEN
			BEGIN

			IF (.NXT_SCRPTR EQLA 0)
			THEN
			    BEGIN
			    EDT$$SC_MOVTOLN (0);
			    SCR_REBUILD = 1;
			    RETURN;
			    END;

!+
! If there isn't another line already for this record, and we need one,
! do it the hard way.
! Perhaps someday we'll allocate another screen line block here.
!-

			IF (.NXT_SCRPTR [SCR_CHR_FROM] EQL 0)
			THEN
			    BEGIN
			    EDT$$SC_MOVTOLN (0);
			    SCR_REBUILD = 1;
			    RETURN;
			    END;

			NXT_SCRPTR [SCR_CHR_FROM] = .RIGHT + 1;
			NXT_SCRPTR [SCR_EDIT_MINPOS] = 0;
			NXT_SCRPTR [SCR_EDIT_MAXPOS] = 255;
			NXT_SCRPTR [SCR_EDIT_FLAGS] = .NXT_SCRPTR [SCR_EDIT_FLAGS] OR SCR_EDIT_MODIFY;
			END
		    ELSE
			BEGIN
!+
! We have reached the end of the record, make sure there isn't
! another line allocated for it.
!-
			NXT_SCRPTR = .SCRPTR [SCR_NXT_LINE];

			IF (.NXT_SCRPTR NEQA 0)
			THEN
			    BEGIN

			    IF (.NXT_SCRPTR [SCR_CHR_FROM] NEQ 0)
			    THEN
				BEGIN
				EDT$$SC_MOVTOLN (0);
				SCR_REBUILD = 1;
				RETURN;
				END;

			    END;

			END;

		    END;

		END;

	    IF ( NOT .UPDATE_DONE)
	    THEN
		BEGIN

		IF (.SCRPTR [SCR_NXT_LINE] EQLA 0)
		THEN
		    UPDATE_DONE = 1
		ELSE
		    BEGIN

		    LOCAL
			NEXT_SCRPTR : REF SCREEN_LINE;

		    NEXT_SCRPTR = .SCRPTR [SCR_NXT_LINE];

		    IF (.NEXT_SCRPTR NEQA 0)
		    THEN
			BEGIN

			IF (((.SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) EQL 0) AND 	!
			    ((.NEXT_SCRPTR [SCR_LINE_IDX] EQL 0) OR 	!
			    ((.NEXT_SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) NEQ 0)))
			THEN
			    REC_NO = .REC_NO + 1;

			END;

		    SCRPTR = .SCRPTR [SCR_NXT_LINE];
		    END;

		END;

	    END
	UNTIL .UPDATE_DONE;

	END
    UNTIL ( NOT .ANOTHER_PASS);

    EDT$$SC_MOVTOLN (0);
    END;					! of routine EDT$$SC_UPD

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

ELUDOM