Google
 

Trailing-Edge - PDP-10 Archives - CFS_TSU04_19910205_1of1 - update/t20src/chmspllin.bli
There are 11 other files named chmspllin.bli in the archive. Click here to see a list.
 %TITLE 'CHMSPLLIN - split line'
MODULE CHMSPLLIN (				! Split line
		IDENT = '3-001'			! File: CHMSPLLIN.BLI Edit: GB3001
		) =
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 splits a line of text at the current cursor position.
!
! 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 routines EDT$$SPLT_LN  and SPLIT_LINE from
!	module CHANGE.BLI.
! 1-002	- Regularize headers.  JBS 03-Mar-1981
! 1-003	- Change SPLIT_LINE to EDT$$SPLT_LNINS .  JBS 27-Mar-1981
! 1-004	- Use the ASSERT macro.  JBS 01-Jun-1981
! 1-005	- EDT$$SEL_RNGPOS  has 3 values.  JBS 02-Jun-1981
! 1-006	- New screen update logic.  JBS 13-Sep-1982
! 1-007	- Remove EDT$$G_LN_NO for new screen update logic.  JBS 29-Sep-1982
! 1-008 - Make code dependent on length of inserted line.  SMB 16-Nov-1982
! 1-009 - Reorganize to fix bugs in line numbering.  SMB 17-Nov-1982
! 1-010	- Save the end of the old line in heap storage rather than
!	   on the stack.  Saving it on the stack uses too much
!	   stack on the PDP-11.  JBS 18-Nov-1982
! 1-011	- Change the call to EDT$$MRK_LNCHG.  JBS 27-Dec-1982
! 1-012	- Do things the stupid way if there is a select active, so tha.
!	   the select range will be updated properly.  JBS 22-Feb-1983
! 3-001 - Add updates from V3 sources.  GB 27-Apr-1983
!--
%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$SPLT_LN : NOVALUE,			! Split a line of text at the current cursor position
    EDT$$SPLT_LNINS : NOVALUE;			! Split a line of text at the current cursor position

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routines
%SBTTL 'EDT$$SPLT_LN  - split line'

GLOBAL ROUTINE EDT$$SPLT_LN 			! Split line
    : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Split a line of text at the current cursor position.
!
!	The characters in front of the cursor become a new line, inserted
!	in front of the current one.  The cursor is left on the original
!	line.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	LN_BUF
!	LN_END
!	LN_PTR
!
! IMPLICIT OUTPUTS:
!
!	LN_PTR
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$MRK_LNCHG : NOVALUE,		! Track line update bounds
	EDT$$UPD_LNLEN : NOVALUE,		! Update the length of the current line
	EDT$$INS_LN;				! Insert a line into buffer
    EXTERNAL
	LN_BUF,				! Current line buffer
	LN_END,				! End of current line pointer
	LN_PTR;				! Current character pointer

    LOCAL
	LEN;

!+
! Get length of the new line.
!-
    LEN = CH$DIFF (.LN_PTR, CH$PTR (LN_BUF, 0, BYTE_SIZE));

!+
! Insert the new line.
!-
    EDT$$INS_LN (CH$PTR (LN_BUF, 0, BYTE_SIZE), .LEN);

    IF (.LEN NEQ 0)
    THEN
	BEGIN
	EDT$$CPY_STR (CH$DIFF (.LN_END, .LN_PTR), .LN_PTR, CH$PTR (LN_BUF, 0, BYTE_SIZE));
	EDT$$MRK_LNCHG (SCR_EDIT_MODIFY, 0);
	EDT$$UPD_LNLEN (-.LEN);
	END;

    LN_PTR = CH$PTR (LN_BUF, 0, BYTE_SIZE);
    END;
%SBTTL 'EDT$$SPLT_LNINS  - split a line'

GLOBAL ROUTINE EDT$$SPLT_LNINS (		! Split a line
    LENGTH_OPT					! 1 = use length optimizer
    ) : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Split a line of text at the current cursor position.
!
! FORMAL PARAMETERS:
!
!	LENGTH_OPT		! 1 = length is greater than zero so insert
!				! after current line
!
!
! IMPLICIT INPUTS:
!
!	LN_LEN
!	LN_BUF
!	LN_END
!	LN_PTR
!	WK_LN
!	EOB_LN
!
! IMPLICIT OUTPUTS:
!
!	LN_LEN
!	LN_BUF
!	LN_END
!	LN_PTR
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	Calls EDT$$SPLT_LN
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$MRK_LNCHG : NOVALUE,		! Track line updates
	EDT$$UPD_LNLEN : NOVALUE,		! Update the length of the current line
	EDT$$INS_LN : NOVALUE,			! Insert a line into buffer
	EDT$$RPL_CHGDLN : NOVALUE,		! Replace a changed workfile line
	EDT$$RD_NXTLN,				! Read next work file record
	EDT$$RD_PRVLN,				! Read previous record
	EDT$$START_INS : NOVALUE,		! Start an insert sequence
	EDT$$END_INS : NOVALUE,			! End an insert sequence
	EDT$$ALO_HEAP,				! Allocate heap storage
	EDT$$DEA_HEAP : NOVALUE;		! Deallocate heap storage

    EXTERNAL
	LN_LEN,				! Length of the current line
	LN_BUF,				! Current line buffer
	LN_END,				! End of current line pointer
	LN_PTR,				! Current character pointer
	WK_LN,				! Current work line
	EOB_LN,				! EOB line
	SEL_BUF : REF TBCB_BLOCK;	! Select buffer, 0 = none

    LOCAL
	LEN,					! New length of old line
	ENDLEN,					! Ending line length
	INSERT_AFTER,				! Insert after current record
	INSERT_DONE;				! 1 = the insert has been done

    INSERT_DONE = 0;
!+
! Don't do the length optinization if we are at [EOB] or if there is an active select.
!-

    IF ((.WK_LN EQLA EOB_LN) OR (.SEL_BUF NEQA 0))
    THEN
	INSERT_AFTER = 0
    ELSE
	INSERT_AFTER = .LENGTH_OPT;

    IF (.INSERT_AFTER NEQ 0)
    THEN
	BEGIN
	LEN = CH$DIFF (.LN_PTR, CH$PTR (LN_BUF, 0, BYTE_SIZE));
	ENDLEN = CH$DIFF (.LN_END, .LN_PTR);
!+
! Use the length optimizer, which says insert below the current line
! if we're positioned anywhere except at the beginning of a line.
!-

	IF (.LEN EQL 0)
	THEN
	    BEGIN
!+
! We are at the beginning of the line.  Just insert a 0-length line before this one.
!-
	    EDT$$START_INS ();			! Perform initialization for text insertion
	    EDT$$INS_LN (CH$PTR (LN_BUF, 0, BYTE_SIZE), 0);
	    EDT$$END_INS ();			! End the insertion sequence
	    LN_PTR = CH$PTR (LN_BUF, 0, BYTE_SIZE);
	    INSERT_DONE = 1;
	    END
	ELSE
	    BEGIN
!+
! Adjust the old line and mark for repaint.
!-

	    LOCAL
		SAV_LN_BUF,			! Place to save the end of the old line
		GOT_HEAP;			! 1 = we got (or don't need) heap storage

!+
! Copy the end of the old line into heap storage, so we can insert it later.
!-

	    IF (.ENDLEN NEQ 0) THEN GOT_HEAP = EDT$$ALO_HEAP (ENDLEN, SAV_LN_BUF) ELSE GOT_HEAP = 1;

	    IF .GOT_HEAP
	    THEN
		BEGIN

		IF (.ENDLEN NEQ 0)
		THEN
		    BEGIN
		    EDT$$CPY_STR (.ENDLEN, .LN_PTR, CH$PTR (.SAV_LN_BUF, 0, BYTE_SIZE));
!+
! Shorten the current line
!-
		    EDT$$UPD_LNLEN (-.ENDLEN);
		    EDT$$MRK_LNCHG (SCR_EDIT_MODIFY, .LEN);
		    END;

		EDT$$RPL_CHGDLN ();
!+
! Insert the tail as the new line.
!-

		IF (.ENDLEN NEQ 0)
		THEN
		    BEGIN
		    EDT$$CPY_STR (.ENDLEN, CH$PTR (.SAV_LN_BUF, 0, BYTE_SIZE),
			 CH$PTR (LN_BUF, 0, BYTE_SIZE));
		    EDT$$DEA_HEAP (ENDLEN, SAV_LN_BUF);
		    END;

		EDT$$RD_NXTLN ();
		EDT$$START_INS ();		! Perform initialization for text insertion
!+
! Adjust the line pointer to the new line.
!-
		EDT$$INS_LN (CH$PTR (LN_BUF, 0, BYTE_SIZE), .ENDLEN);
		LN_LEN = .ENDLEN + .LEN;
		EDT$$UPD_LNLEN (-.LEN);
		EDT$$END_INS ();		! End the insertion sequence
		EDT$$RD_PRVLN ();
		LN_PTR = CH$PTR (LN_BUF, 0, BYTE_SIZE);
		INSERT_DONE = 1;
		END;

	    END;

	END;

!+
! If we haven't done the insert, perhaps because we have run out of heap storage,
! do it the stupid way.
!-

    IF ( NOT .INSERT_DONE)
    THEN
	BEGIN
	EDT$$START_INS ();			! Perform initialization for text insertion
	EDT$$SPLT_LN ();			! Split the line
	EDT$$END_INS ();			! End the insertion sequence
	END;

    END;					! of routine EDT$$SPLT_LNINS

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

ELUDOM