Trailing-Edge
-
PDP-10 Archives
-
BB-R775E-BM
-
sources/edt/wfreplin.bli
There are 10 other files named wfreplin.bli in the archive. Click here to see a list.
%TITLE 'WFREPLIN - replace the current line'
MODULE WFREPLIN ( ! Replace the current line
IDENT = '3-002' ! File: WFREPLIN.BLI Edit: GB3002
) =
BEGIN
!
! COPYRIGHT (c) 1981, 1985 BY
! DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
! 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 WHICH IS NOT SUPPLIED BY DIGITAL.
!
!++
! FACILITY: EDT -- The DEC Standard Editor
!
! ABSTRACT:
!
! Replace the current line with a specified line.
!
! 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$$RPL_LN from module EDTWF.
! 1-002 - Regularize headers. JBS 19-Mar-1981
! 1-003 - Change index for line numbers from 10 to 15. SMB 18-Jan-1982
! 1-004 - Remove original line numbers. SMB 28-Jan-1982
! 1-005 - Do most replaces without doing delete/insert, to improve
! performance, especially when updating the screen. JBS 04-Oct-1982
! 1-006 - Preserve EDT$$A_SEL_POS if we must delete and then insert. JBS 09-Nov-1982
! 1-007 - Don't disturb the screen data base if we must delete and then insert. JBS 01-Dec-1982
! 3-001 - Change EDT$$CPY_MEM to EDT$$CPY_STR and make changes for word addressing. GB 09-May-1983
! 3-002 - Fix calculation of buffer end and line size. CJG 8-Jun-1983
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!
REQUIRE 'EDTSRC:TRAROUNAM';
FORWARD ROUTINE
EDT$$RPL_LN : NOVALUE;
!
! INCLUDE FILES:
!
REQUIRE 'EDTSRC:EDTREQ';
!
! MACROS:
!
! NONE
!
! EQUATED SYMBOLS:
!
! NONE
!
! OWN STORAGE:
!
! NONE
!
! EXTERNAL REFERENCES:
!
! In the routine
%SBTTL 'EDT$$RPL_LN - replace the current line'
GLOBAL ROUTINE EDT$$RPL_LN ( ! Replace the current line
NEWLINE, ! Address of the new line
LEN ! Length of the new line (in bytes)
) : NOVALUE =
!++
! FUNCTIONAL DESCRIPTION:
!
! Replace the current line. If the replacement line is the same size as
! the current line, just copy the new one in its place, otherwise, delete
! the current line and insert the new one.
!
! FORMAL PARAMETERS:
!
! NEWLINE a pointer to the new line
!
! LEN its length
!
! IMPLICIT INPUTS:
!
! WK_INSCNT
! WK_LN
! WK_MODFD
! LNO0
! CUR_BUF
! WK_BUK
!
!IMPLICIT OUTPUTS:
!
! WK_INSCNT
! WK_LN
! CUR_BUF
! WK_BUK
!
! ROUTINE VALUE:
!
! NONE
!
! SIDE EFFECTS:
!
! NONE
!
!--
BEGIN
EXTERNAL ROUTINE
EDT$$DEL_CURLN : NOVALUE,
EDT$$INS_LN : NOVALUE,
EDT$$RD_PRVLN;
EXTERNAL
WK_INSCNT : LN_BLOCK, ! The count of inserted lines
WK_LN : REF LIN_BLOCK, ! Pointer to current line
WK_MODFD, ! Flag indicating bucket was modified
LNO0 : LNOVECTOR [14], ! 48-bit line numbers
CUR_BUF : REF TBCB_BLOCK, ! Current text buffer control block
WK_BUK : REF BLOCK [WF_BUKT_SIZE] FIELD (WFB_FIELDS),
SEL_POS, ! Select position
SCR_REBUILD; ! 1 = don't touch the screen data base
LOCAL
SAVE_LIN : LN_BLOCK,
SAVE_SELPOS,
OLD_LEN, ! Length of the old line (in bytes)
REP_LEN, ! Length of new line (in words)
CUR_LEN, ! Length of old line (in words)
SOURCE,
REMAINING,
SAVE_REBUILD;
!+
! Check for a replacement which does not change the length of the
! line, and leave the work-file block structure unaltered. This
! is not done only for speed; EDT will break if it is removed.
!-
OLD_LEN = .WK_LN [LIN_LENGTH];
IF (.OLD_LEN EQL .LEN)
THEN
BEGIN
EDT$$CPY_STR (.LEN, .NEWLINE, CH$PTR (WK_LN [LIN_TEXT], 0, BYTE_SIZE));
WK_MODFD = 1;
RETURN;
END;
!+
! Check for a replacement which neither empties the block nor causes it
! to overflow. Do such a replacement directly in the block, without
! calling the more general routines which delete and insert lines.
!-
REP_LEN = (.LEN + BYTES_PER_WORD - 1) / BYTES_PER_WORD + LIN_FIXED_SIZE + 1;
CUR_LEN = .WK_LN [LIN_NEXT];
IF (((.WK_BUK [WFB_END] - .CUR_LEN + .REP_LEN) LSS WF_BUKT_SIZE) AND
(.CUR_BUF [TBCB_LINE_ADDR] NEQ .WK_BUK [WFB_END]) AND !
(.CUR_BUF [TBCB_LINE_ADDR] NEQ WFB_FIXED_SIZE))
THEN
BEGIN
!+
! Update the character count for this buffer.
!-
CUR_BUF [TBCB_CHAR_COUNT] = .CUR_BUF [TBCB_CHAR_COUNT] - .OLD_LEN + .LEN;
!+
! Make room in the block for the line. This may require either increasing or decreasing
! the amount of space now available.
!-
SOURCE = .WK_LN + .CUR_LEN;
REMAINING = .WK_BUK [WFB_END] - .CUR_BUF [TBCB_LINE_ADDR] - .CUR_LEN;
WK_BUK [WFB_END] = .WK_BUK [WFB_END] - .CUR_LEN + .REP_LEN;
IF (.REMAINING NEQ 0) !
THEN
EDT$$CPY_MEM (ABS (.REMAINING), .SOURCE, .WK_LN + .REP_LEN);
!+
! Insert the text into the buffer and update the line lengths
!-
WK_LN [LIN_LENGTH] = .LEN;
WK_LN [LIN_NEXT] = .REP_LEN;
CH$FILL (0, .REP_LEN - (LIN_FIXED_SIZE + 1), CH$PTR (WK_LN [LIN_TEXT], 0, 36));
CH$MOVE (.LEN, .NEWLINE, CH$PTR (WK_LN [LIN_TEXT], 0, BYTE_SIZE));
.WK_LN + .REP_LEN - 1 = .REP_LEN;
WK_MODFD = 1;
RETURN;
END;
!+
! This is a complex case. Delete the old line and insert the new one.
!-
MOVELINE (WK_LN [LIN_NUM], SAVE_LIN);
SAVE_SELPOS = .SEL_POS;
SAVE_REBUILD = .SCR_REBUILD;
SCR_REBUILD = 1;
EDT$$DEL_CURLN ();
EDT$$INS_LN (.NEWLINE, .LEN);
EDT$$RD_PRVLN ();
SCR_REBUILD = .SAVE_REBUILD;
SEL_POS = .SAVE_SELPOS;
MOVELINE (SAVE_LIN, WK_LN [LIN_NUM]);
SUBLINE (LNO0, WK_INSCNT, WK_INSCNT);
RETURN;
END; ! of routine EDT$$RPL_LN
!<BLF/PAGE>
END ! of module EDT$WFREPLIN
ELUDOM