Google
 

Trailing-Edge - PDP-10 Archives - BB-H138F-BM_1988 - 7-sources/wfdellin.bli
There are 10 other files named wfdellin.bli in the archive. Click here to see a list.
 %TITLE 'WFDELLIN - delete the current line'
MODULE WFDELLIN (				! Delete the current line
		IDENT = '3-002'			! File: WFDELLIN.BLI Edit: CJG3002
		) =
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:
!
!	Delete the current line.  If that empties the current bucket,
!	delete the bucket also.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: October 16, 1978
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 23-Feb-1981.  This module was created by
!	extracting routine EDT$$DEL_CURLN  from module EDTWF.
! 1-002	- Regularize headers.  JBS 16-Mar-1981
! 1-003 - Change index for line numbers from 10 to 15.  SMB 18-Jan-1982
! 1-004	- Correct IDENT format.  JBS 15-Mar-1982
! 1-005	- New screen update logic.  JBS 13-Sep-1982
! 1-006	- Remove EDT$$SET_WKLN.  JBS 14-Sep-1982
! 1-007 - Change the name of the delete line routine.  SMB 21-Sep-1982
! 1-008 - Modify to use new 48bit macro. STS 01-Oct-1982
! 1-009	- Count the number of deleted lines since the last screen update.  JBS 21-Oct-1982
! 1-010	- Change the handling of EDT$$G_RECS_INSERTED.  JBS 27-Oct-1982
! 1-011 - Up the number of recs inserted before setting SCR_REBUILD.  SMB 16-Feb-1983
! 3-001 - Use different buffer structure for Tops 10/20.  GB 21-Feb-1983
! 3-002 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--

%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$DEL_CURLN : NOVALUE;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$DEL_CURLN  - delete the current line'

GLOBAL ROUTINE EDT$$DEL_CURLN 			! Delete the current line
    : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine deletes the current line from the buffer.  Close up the
!	gap in the block by moving any text following the deleted line.  If the
!	line is the only one in a bucket, then also delete the bucket.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	LN_BUF
!	SEL_LN
!	CUR_BUF
!	WK_BUK
!	WK_LN
!	LNO0
!	SEL_POS
!	RECS_INSERTED
!	SCR_REBUILD
!
! IMPLICIT OUTPUTS:
!
!	WK_MODFD
!	CUR_BUF
!	WK_BUK
!	WK_LN
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$WF_DELBUK : NOVALUE,
	EDT$$RD_NXTLN,
	EDT$$SEL_RNGPOS,
	EDT$$SC_DELLN : NOVALUE;

    EXTERNAL
	CUR_BUF : REF TBCB_BLOCK,	! Current text buffer control block
	WK_BUK : 			! Pointer to current bucket
	    REF BLOCK [WF_BUKT_SIZE] FIELD (WFB_FIELDS),
	WK_LN : REF LIN_BLOCK,		! Pointer to current line
	WK_MODFD,			! Flag indicating bucket was modified
	LNO0 : LNOVECTOR [14],
	SEL_POS,			! Position on the select line
	SEL_LN,				! Record number of the select line
	LN_BUF,				! Current line buffer
	SCR_REBUILD,			! 1 = rebuild the screen data structure from the work file
	SCR_LNS,			! Number of lines in the text area of the screen
	RECS_INSERTED;			! Number of records inserted and deleted since the last screen update

    LOCAL
	SIZE,
	SOURCE,
	REMAINING;

!+
! Test for end of buffer. (do not try to delete if at end of block)
!-

    IF (.CUR_BUF [TBCB_LINE_ADDR] EQL .WK_BUK [WFB_END]) THEN RETURN;

!+
! If we are not going to rebuild the screen data structure from the work file,
! tell the screen package that the current line has been deleted.
!-

    IF ( NOT .SCR_REBUILD)
    THEN
	BEGIN
	RECS_INSERTED = .RECS_INSERTED + 1;

	IF (.RECS_INSERTED GTR (.SCR_LNS * 2)) THEN SCR_REBUILD = 1 ELSE EDT$$SC_DELLN ();

	END;

!+
! Update the line and character count fields
!-
    SUBLINE (LNO0, CUR_BUF [TBCB_LINE_COUNT], CUR_BUF [TBCB_LINE_COUNT]);
    CUR_BUF [TBCB_CHAR_COUNT] = .CUR_BUF [TBCB_CHAR_COUNT] - .WK_LN [LIN_LENGTH];
!+
! Mark bucket as modified.
!-
    WK_MODFD = 1;
!+
! Calculate the length of text to be deleted.
!-
    SIZE = .WK_LN [LIN_NEXT];
!+
! Source is a pointer to the following information.
!-
    SOURCE = .WK_LN + .SIZE;
!+
! Calculate the number of used words left in the block.
!-
    REMAINING = .WK_BUK [WFB_END] - .CUR_BUF [TBCB_LINE_ADDR] - .SIZE;
!+
! Update the end of bucket information.
!-
    WK_BUK [WFB_END] = .WK_BUK [WFB_END] - .SIZE;
!+
! And close up the hole we created.
!-

    IF (.REMAINING NEQ 0)
    THEN
	BEGIN
	EDT$$CPY_MEM (.REMAINING, .SOURCE, .WK_LN);
	WK_LN = .WK_BUK + .CUR_BUF [TBCB_LINE_ADDR];
	END
    ELSE
!+
! No text after the line, check to see if bucket is now empty.
!-

	IF (.CUR_BUF [TBCB_LINE_ADDR] EQL WFB_FIXED_SIZE)	!
	THEN
	    EDT$$WF_DELBUK ()
	ELSE
	    EDT$$RD_NXTLN ();			! position to first line in next bucket

!+
! Update the select point, if it is after the line being deleted.
!-

    SELECTONE EDT$$SEL_RNGPOS () OF
	SET

	[0] : 					! Select line is current line
	    SEL_POS = CH$PTR (LN_BUF, 0, BYTE_SIZE);

	[1] : 					! Select line is after current line
	    SUBLINE (LNO0, SEL_LN, SEL_LN);

	[-1] : 					! Select line is before current line, or no select
	    BEGIN
	    0
	    END;

	[OTHERWISE] :
	    ASSERT (8, 0);
	TES;

    END;					! of routine EDT$$DEL_CURLN

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

ELUDOM