Google
 

Trailing-Edge - PDP-10 Archives - tops20-v7-ft-dist1-clock - 7-sources/scrfind.bli
There are 10 other files named scrfind.bli in the archive. Click here to see a list.
 %TITLE 'SCRFIND - find a record in the screen structure'
MODULE SCRFIND (				! Find a screen record
		IDENT = '3-001'			! File: SCRFIND.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 searches for a record in the screen
!	data structure.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: John Sauter CREATION DATE: 13-Sep-1982
!
! MODIFIED BY:
!
! 1-001 - Original.  This module was created by extracting the search code from
!	  EDT$CHMMRKCHG.  SMB 22-Sep-1982
! 1-002 - Add some parameters and extra code to original extracted version.
!	  SMB  22-Sep-1982
! 1-003 - Change the parameters passed.  SMB 28-Sep-1982
! 1-004 - Modify to use new 48 bit macros. STS 01-Oct-1982
! 1-005 - Search for EOB differently.  SMB 05-Oct-1982
! 1-006 - Modify to return value of screen pointer found.  SMB 08-Oct-1982
! 1-007 - Increment and decrement displacement on lines equal.  SMB 12-Oct-1982
! 1-008 - Modify to use new compare macro. STS 20-Oct-1982
! 1-009	- Deleted lines have the record number of the next line.  JBS 25-Oct-1982
! 1-010 - Modify search for bottom line of a record.  SMB 28-Oct-1982
! 1-011 - Fix a bug in notruncate mode.  SMB 24-Nov-1982
! 1-012	- Worry about deleted lines when scanning backwards.  JBS 25-Nov-1982
! 1-013	- Remove the edit buffer.  JBS 27-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$$SC_FNDREC;				! Fins a screen record

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$SC_FNDREC - find a record in the screen data structure'

GLOBAL ROUTINE EDT$$SC_FNDREC (			! Find a screen record
    POSITION, 					! Position on the line
    DISPLACEMENT				! Displacement from cursor screen line
    ) : =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Given the current record number, determine if it has a corresponding
!	screen block in the screen data structure.  If so, return
!	the address.
!
! FORMAL PARAMETERS:
!
!  POSITION		The position on the line at which the operation takes place
!
!  DISPLACEMENT		The displacement of the current line info block from the cursor line info block
!
! IMPLICIT INPUTS:
!
!	LST_SCRPTR
!	EOB_SCRPTR
!	LWK_LN
!	EOB_LN
!	CSR_SCRPTR
!	CUR_BUF
!	CUR_SCRLN
!	SCR_BUF
!
! IMPLICIT OUTPUTS:
!
!	NONE
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL
	LNO0,
	LST_SCRPTR : REF SCREEN_LINE,		! Last screen info pointer
	EOB_LN,					! Address of EOB line
	WK_LN,					! Current workfile line
	EOB_SCRPTR : REF SCREEN_LINE,		! EOB screen pointer
	CSR_SCRPTR : REF SCREEN_LINE,		! Pointer to cursor line screen info
	CUR_BUF : REF TBCB_BLOCK,		! Current text buffer control block
	CUR_SCRLN : LN_BLOCK,			! Record number of current screen linM
	SCR_BUF : REF TBCB_BLOCK;		! Current screen buffer

    EXTERNAL ROUTINE
	EDT$$CMP_LNO;				! Compare line numbers

    LOCAL
	DISP,					! Displacement temporary
	SCRPTR : REF SCREEN_LINE,		! Pointer to our screen line
	RECORD_NO : LN_BLOCK,			! Record number of our screen line
	FOUND_LINE;

!+
! If the screen buffer is different from the current buffer then bail out.
! None of the lines in the current buffer can be on the screen.
!-
    DISP = 0;
    FOUND_LINE = 0;

    IF (.CUR_BUF EQLA .SCR_BUF)
    THEN
	BEGIN
!+
! Find our screen line block.
!-
	SCRPTR = .CSR_SCRPTR;
!+
! First check to see if we are searching for EOB on the screen.
!-

	IF (.WK_LN EQLA EOB_LN)
	THEN
	    BEGIN

	    IF (.LST_SCRPTR NEQA .EOB_SCRPTR)
	    THEN
		FOUND_LINE = 0
	    ELSE
		BEGIN
		FOUND_LINE = 1;

		WHILE (.SCRPTR NEQA .EOB_SCRPTR) DO
		    BEGIN
		    SCRPTR = .SCRPTR [SCR_NXT_LINE];
		    DISP = .DISP + 1;
		    END;

		END;

	    END
	ELSE
	    BEGIN
	    MOVELINE (CUR_SCRLN, RECORD_NO);

	    WHILE (( NOT .FOUND_LINE) AND (.SCRPTR NEQA 0)) DO

		CASE EDT$$CMP_LNO (RECORD_NO, CUR_BUF [TBCB_CUR_LIN]) FROM -1 TO 1 OF
		    SET

		    [-1] : 			! Cursor line is before current line
			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
				ADDLINE (LNO0, RECORD_NO, RECORD_NO);

			    END;

			DISP = .DISP + 1;
			SCRPTR = .SCRPTR [SCR_NXT_LINE];
			END;

		    [0] : 			! Cursor line is the current line
			BEGIN

			IF ((.SCRPTR [SCR_CHR_FROM] LEQ .POSITION)	!
			    AND (.SCRPTR [SCR_CHR_TO] GEQ .POSITION)	!
			    AND ((.SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) EQL 0))
			THEN
			    FOUND_LINE = 1
			ELSE
			    BEGIN

			    IF ((.SCRPTR [SCR_EDIT_FLAGS] AND SCR_EDIT_DELLN) NEQ 0)
			    THEN
				BEGIN
!+
! This is a deleted record; the record we want is the first non-deleted record after it.
!-
				SCRPTR = .SCRPTR [SCR_NXT_LINE];
				END
			    ELSE
				IF (.POSITION GTR .SCRPTR [SCR_CHR_TO])
				THEN
				    BEGIN
!+
! This line is continued, the line we want is further down the screen.
!-
				    SCRPTR = .SCRPTR [SCR_NXT_LINE];	! Move forward
				    DISP = .DISP + 1;
				    END
				ELSE
				    BEGIN
!+
! This is a continuation line, the line we want is further up the screen.
!-
				    ASSERT (7, .POSITION LSS .SCRPTR [SCR_CHR_FROM]);
				    SCRPTR = .SCRPTR [SCR_PRV_LINE];	! Move backward
				    DISP = .DISP - 1;
				    END;

			    END;

			END;

		    [1] :		! Cursor line is after the current line
			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
				    SUBLINE (LNO0, RECORD_NO, RECORD_NO);
				END;

			    END;

			DISP = .DISP - 1;
			SCRPTR = .SCRPTR [SCR_PRV_LINE];
			END;

		    [OUTRANGE] :
			ASSERT (7, 0);

		    TES;

	    END;

	END;

!+
! If FOUND_LINE is not set, the record does not appear on the screen.
! In that case return zero.
!-

    .DISPLACEMENT = .DISP;

    IF .FOUND_LINE THEN RETURN (.SCRPTR) ELSE RETURN (0);

    END;				! Of routine EDT$$SC_FNDREC

END

ELUDOM