Trailing-Edge
-
PDP-10 Archives
-
bb-r775d-bm_tops20_ks_upd_4
-
sources/chminsstr.bli
There are 11 other files named chminsstr.bli in the archive. Click here to see a list.
%TITLE 'CHMINSSTR - insert characters'
MODULE CHMINSSTR ( ! Insert characters
IDENT = '3-001' ! File: CHMINSSTR.BLI Edit: GB3001
) =
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:
!
! This module does a (change mode) insertion of a string of
! characters which may include carriage returns.
!
! ENVIRONMENT: Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: Unknown
!
! MODIFIED BY:
!
! 1-001 - Original. DJS 04-Feb-1981. This module was created by
! extracting the routine INSERT_STRING from the module CHANGE.BLI.
! 1-002 - Regularize headers. JBS 03-Mar-1981
! 1-003 - Change SPLIT_LINE to EDT$$SPLT_LNINS . JBS 30-Mar-1981
! 1-004 - New screen update logic. JBS 13-Sep-1982
! 1-005 - Add parameter to split line routine. SMB 16-Nov-1982
! 1-006 - Do special handling for trailing carriage returns. JBS 28-Dec-1982
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!
REQUIRE 'EDTSRC:TRAROUNAM';
FORWARD ROUTINE
EDT$$INS_CHS; ! Insert a string of characters which may include carriage returns
!
! INCLUDE FILES:
!
REQUIRE 'EDTSRC:EDTREQ';
!
! MACROS:
!
! NONE
!
! EQUATED SYMBOLS:
!
! NONE
!
! OWN STORAGE:
!
! NONE
!
! EXTERNAL REFERENCES:
!
! In the routine
%SBTTL 'EDT$$INS_CHS - insert characters'
GLOBAL ROUTINE EDT$$INS_CHS ( ! Insert characters
S, ! address of string to insert
L ! length of that string
) =
!++
! FUNCTIONAL DESCRIPTION:
!
! Insert a string of characters which may include carriage returns.
! Carriage returns are treated as line terminators, having the effect of
! breaking the current line of text into two.
!
! FORMAL PARAMETERS:
!
! S a pointer to the character string to insert.
!
! L the length of the string.
!
! IMPLICIT INPUTS:
!
! NONE
!
! IMPLICIT OUTPUTS:
!
! NONE
!
! ROUTINE VALUE:
!
! A value of 0 is returned if a line exceeded 255 characters during the
! insert (further insertions were lost).
!
! SIDE EFFECTS:
!
! NONE
!
!--
BEGIN
EXTERNAL ROUTINE
EDT$$INS_STR, ! Insert a string of characters at the current position
EDT$$SPLT_LNINS : NOVALUE, ! Split a line of text at the current cursor position
EDT$$CS_RIGHT, ! Move right a characteI
EDT$$CS_LEFT; ! Move left a character
LOCAL
END_STRING,
POINT,
MY_S,
MY_L;
MY_L = .L;
!+
! Initialize a pointer to the current character and one to the end of the
! string.
!-
POINT = .S;
END_STRING = CH$PLUS (.S, .MY_L);
!+
! If we have trailing carriage returns do the line splitting before the insertion
! to improve screen repainting.
!-
IF ((.MY_L GTR 1) AND (CH$RCHAR (CH$PLUS (.POINT, .MY_L - 1)) EQL ASC_K_CR))
THEN
BEGIN
LOCAL
LINES_INSERTED,
STATUS;
!+
! Insert enough empty lines to account for the carriage returns.
! Keep backing up so our position doesn't change.
!-
LINES_INSERTED = 0;
WHILE ((.MY_L GTR 1) AND (CH$RCHAR (CH$PLUS (.POINT, .MY_L - 1)) EQL ASC_K_CR)) DO
BEGIN
EDT$$SPLT_LNINS (1);
EDT$$CS_LEFT ();
MY_L = .MY_L - 1;
LINES_INSERTED = .LINES_INSERTED + 1;
END;
!+
! Insert the text without the trailing carriage returns.
!-
STATUS = EDT$$INS_CHS (.POINT, .MY_L);
!+
! Now move forward over those blank lines.
!-
DECR I FROM .LINES_INSERTED - 1 TO 0 DO
EDT$$CS_RIGHT ();
!+
! We are done with the insert.
!-
RETURN (.STATUS);
END;
!+
! Either this is a string of length one or there is no
! trailing carriage returns. Loop until no more characters remain.
!-
WHILE CH$PTR_NEQ (.END_STRING, .POINT) DO
BEGIN
IF (CH$RCHAR (.POINT) EQL ASC_K_CR)
THEN
!+
! The character is a carriage return. Split the line, scrolling
! the screen if possible to make room for the new line.
!-
BEGIN
EDT$$SPLT_LNINS (1);
POINT = CH$PLUS (.POINT, 1);
END
ELSE
BEGIN
!+
! The character is not a carriage return. Insert the string of
! characters up to the end or to the next carriage return.
!-
MY_S = .POINT;
WHILE (CH$PTR_NEQ (.END_STRING, .POINT) AND (CH$RCHAR (.POINT) NEQ ASC_K_CR)) DO
POINT = CH$PLUS (.POINT, 1);
IF (EDT$$INS_STR (.MY_S, CH$DIFF (.POINT, .MY_S)) EQL 0) THEN RETURN (0);
END;
END;
RETURN (1);
END;
END
ELUDOM