Google
 

Trailing-Edge - PDP-10 Archives - BB-R775C-BM - sources/lmove.bli
There are 10 other files named lmove.bli in the archive. Click here to see a list.
 %TITLE 'LMOVE - MOVE and COPY line-mode commands'
MODULE LMOVE (				! MOVE and COPY line-mode commands
		IDENT = '3-003'			! File: LMOVE.BLI Edit: GB3003
		) =
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 executes the line mode MOVE and COPY commands.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: February 3, 1978
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 30-JAN-81.  This module was created by
!	extracting the routine from the module EXEC.BLI.
! 1-002	- Regularize headers.  JBS 20-Mar-1981
! 1-003	- Use new message codes.  JBS 04-Aug-1981
! 1-004	- Abort on control C.  JBS 04-Jan-1982
! 1-005 - Change size of move/copy counters.  SMB 05-Feb-1982
! 1-006 - Change DUP count to 48-bits.  SMB 07-Feb-1982
! 1-007 - Limit DUP count to 65535 or less.  SMB 08-Feb-1982
! 1-008 - Fix bug in return address for DUP range check.  SMB 09-Feb-1982
! 1-009	- Set a flag if control C actually aborts something.  JBS 25-May-1982
! 1-010	- Correct a message error introduced by edit 1-009.  JBS 26-May-1982
! 1-011	- Check the status returned by EDT$$CPY_LN.  JBS 09-Jun-1982
! 1-012 - Stop working message before messages.  SMB 30-Jun-1982
! 1-013 - Stop processing on bad select range.  SMB 01-Jul-1982
! 1-014	- Use EDT$$FMT_CRLF instead of EDT$$OUT_FMTBUF.  JBS 05-Jul-1982
! 1-015	- Make sure the screen is repainted if any lines are changed.  For
!	   compatibility with EDT version 2, don't go through "Press return
!	   to continue".  JBS 06-Jul-1982
! 1-016 - Move edt$$tst_eob in line. STS 22-Sep-1982
! 1-017 - Modify to use new 48 bit macro. STS 01-Oct-1982
! 1-018	- Remove EDT$$G_SCR_CHGD, new screen update logic doesn't need it.  JBS 09-Oct-1982
! 1-019 - Put code for edt$$rng_posfrst in line. STS 11-Oct-1982
! 1-020 - Modify to use new compare macro. STS 20-Oct-1982
! 1-021 - Modify control c checking. STS 01-Dec-1982
! 3-001 - Fix EDT$$FMT_STR and EDT$$FMT_STRCNT. CJG 22-Mar-1983
! 3-002 - Use EDT$$CPY_MEM instead of EDT$$SAV_POS and EDT$$SET_POS. 
!	   CJG 17-Apr-1983
! 3-003 - Add updates from V3 sources.  GB 29-Apr-1983
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$MOVCPY_CMD : NOVALUE;			! Process the MOVE and COPY commands

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$MOVCPY_CMD  - MOVE and COPY line-mode commands'

GLOBAL ROUTINE EDT$$MOVCPY_CMD (		! MOVE and COPY line-mode commands
    DELETE					! 1 = delete lines as moved (0 = copy)
    ) : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Command processing for MOVE and COPY.   First, find the destination
!	range to make sure we can position there.  Next process the source
!	range, copying all the lines to an intermediate buffer.  Then position
!	to the destination range again, and copy the temporary buffer the
!	indicated number of times.  If the command is MOVE then the  DELETE parameter
!	will be true, causing us to delete the source lines as they are processed.
!
! FORMAL PARAMETERS:
!
!  DELETE		 1 = delete lines (MOVE command) 0 = don't (COPY command)
!
! IMPLICIT INPUTS:
!
!	CUR_BUF
!	WK_LN
!	EXE_CURCMD
!	EXE_QRYQUIT
!	EXE_SBITS
!	EXE_SBLK
!
! IMPLICIT OUTPUTS:
!
!	CC_DONE
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$STOP_WKINGMSG,
	EDT$$CMP_LNO,
	EDT$$FMT_STRCNT : NOVALUE,
	EDT$$FMT_CRLF,				! Terminate an output line
	EDT$$FMT_MSG,
	EDT$$FMT_STR,
	EDT$$PROC_QRYQAL,
	EDT$$NXT_LNRNG,
	EDT$$RNG_REPOS,
	EDT$$CPY_LN,
	EDT$$END_CPY,
	EDT$$LOC_LN,
	EDT$$NEW_BUF,
	EDT$$RD_CURLN,
	EDT$$RD_NXTLN,
	EDT$$START_CPY,
	EDT$$TOP_BUF,
	EDT$$CHK_CC;				! Check for a control C having been typed

    EXTERNAL
	EXT_MOD,				! Are we in EXT mode
	LNO0 : LN_BLOCK,
	LNO_ZERO : LN_BLOCK,
	CUR_BUF : REF POS_BLOCK,
	WK_LN : REF LIN_BLOCK,
	EXE_CURCMD : REF NODE_BLOCK,	! Pointer to the current command.
	EXE_QRYQUIT,			! Quit flag for /QUERY operations.
    	RNG_FRSTLN,
    	RNG_ORIGPOS: POS_BLOCK,
	EXE_SBITS,			! The options switches.
	EXE_SBLK : REF NODE_BLOCK,	! The option switch value block.
	CC_DONE,				! Set to 1 if control C actually aborts something
	EOB_LN;

    MESSAGES ((DSTMOVCOP, BADRANGE, INSMEM));

    LOCAL
	NLINES : LN_BLOCK,			! Number of lines copied.
	DEST_LINE : LN_BLOCK,			! Line number of the destination.
	S_TBCB,					! Address of TBCB for the source.
	D_TBCB,					! Address of TBCB for the destination.
	NUM_COPIES : LN_BLOCK,			! Number of times to copy it.
	START_POS : POS_BLOCK,			! The start position.
	TEMP : TBCB_BLOCK,			! Temporary buffer TBCB.
	COPY_COUNTER : LN_BLOCK,		! Number of copies made
	CONTROL_C;				! 1 = a control C was typed.

!+
! Save the current position for future restoration.
!-
    EDT$$CPY_MEM (POS_SIZE, .CUR_BUF, START_POS);
!+
! Save the current TBCB address so we can detect a buffer change
!-
    S_TBCB = .CUR_BUF;
!+
! First check to make sure we can locate the destination line.
!-

    RNG_FRSTLN = 1;
    EDT$$CPY_MEM(POS_SIZE, .CUR_BUF, RNG_ORIGPOS);
    IF ( NOT EDT$$RNG_REPOS (.EXE_CURCMD [RANGE1]))
    THEN
	BEGIN
	EDT$$FMT_MSG (EDT$_DSTMOVCOP);
	RETURN;
	END;

    CONTROL_C = EDT$$CHK_CC();
    IF .CONTROL_C THEN RETURN;
!+
! Save the line number of the destination line so we are able to reposition
! there when we are ready to move it.
!-
    DEST_LINE [LN_LO] = .WK_LN [LIN_NUM];
    DEST_LINE [LN_MD] = .WK_LN [LIN_NUMM];
    DEST_LINE [LN_HI] = .WK_LN [LIN_NUMH];
    D_TBCB = .CUR_BUF;
!+
! Create a temporary buffer to copy the lines.
!-
    CUR_BUF = TEMP;
!+
! Zero the temporary TBCB - Is there a better way?  GB
!-
    CH$FILL (0, TBCB_SIZE * 4, CH$PTR(TEMP, 0, 9));
    EDT$$NEW_BUF ();
    CUR_BUF = .S_TBCB;
    EDT$$CPY_MEM (POS_SIZE, START_POS, .CUR_BUF);
    EDT$$RD_CURLN ();
!+
! Now position to the front of the source range.
!-

    RNG_FRSTLN = 1;
    EDT$$CPY_MEM(POS_SIZE,.CUR_BUF, RNG_ORIGPOS);
    IF ( NOT EDT$$RNG_REPOS (.EXE_CURCMD [RANGE2])) THEN RETURN;

!+
! Copy the source lines to a temporary buffer.
!-
    EDT$$START_CPY (TEMP);
    NLINES [LN_LO] = .LNO_ZERO [LN_LO];
    NLINES [LN_MD] = .LNO_ZERO [LN_MD];
    NLINES [LN_HI] = .LNO_ZERO [LN_HI];

    IF (.DELETE EQL 0) THEN CONTROL_C = EDT$$CHK_CC();

    WHILE (EDT$$NXT_LNRNG (.DELETE) AND (.WK_LN NEQA EOB_LN) AND (.EXE_QRYQUIT EQL 0)) DO
        BEGIN
	IF EDT$$PROC_QRYQAL (0, 0)
	THEN
	    BEGIN
	    ADDLINE (LNO0, NLINES, NLINES);

    	    IF .DELETE THEN CUR_BUF [POS_CHAR_POS] = 0;
	    IF ( NOT EDT$$CPY_LN (.DELETE))
	    THEN
		BEGIN
		EDT$$END_CPY (0);
		EDT$$FMT_MSG (EDT$_INSMEM);
		RETURN;
		END;

	    END
	ELSE

	    IF .DELETE THEN EDT$$RD_NXTLN ();

    IF (.DELETE EQL 0) THEN CONTROL_C = EDT$$CHK_CC();
    END;
    EDT$$END_CPY (0);
!+
! Now, re-position to the destination range.
!-
    CUR_BUF = .D_TBCB;
    EDT$$RD_CURLN ();
    EDT$$LOC_LN (DEST_LINE);
!+
! Switch to the temp buffer we just created.
!-
    CUR_BUF = TEMP;
    EDT$$RD_CURLN ();
!+
! Get the number of times to copy.
!-

    IF .EXE_SBITS<OPB_DUPL>
    THEN
	MOVELINE (EXE_SBLK [SW_VAL1], NUM_COPIES)
    ELSE
	BEGIN
	MOVELINE (LNO0, NUM_COPIES);
	END;

!+
! Check that DUP is less than 65536
!-

    IF ((.NUM_COPIES [LN_HI] NEQ 0) OR (.NUM_COPIES [LN_MD] NEQ 0))
    THEN
	BEGIN
	EDT$$FMT_MSG (EDT$_BADRANGE);
	MOVELINE (LNO_ZERO, NUM_COPIES);
	MOVELINE (LNO_ZERO, NLINES);
	END;

!+
! And finally, do the copy.
!-
    EDT$$START_CPY (.D_TBCB);
    MOVELINE (LNO_ZERO, COPY_COUNTER);
    IF (.DELETE EQL 0) THEN CONTROL_C = EDT$$CHK_CC ();

    WHILE ((EDT$$CMP_LNO (COPY_COUNTER, NUM_COPIES) LSS 0) AND ( NOT .CONTROL_C)) DO
	BEGIN
	EDT$$TOP_BUF ();

	WHILE (.WK_LN NEQA EOB_LN) DO

	    BEGIN

	    IF ( NOT EDT$$CPY_LN (0))
	    THEN
		BEGIN
		EDT$$END_CPY (1);
		EDT$$FMT_MSG (EDT$_INSMEM);
		RETURN;
		END;

	    EDT$$RD_NXTLN ();
	    END;

	ADDLINE (LNO0, COPY_COUNTER, COPY_COUNTER);
	IF (.DELETE EQL 0) THEN CONTROL_C = EDT$$CHK_CC ();
	END;

    EDT$$END_CPY (1);

    IF (.EXT_MOD) THEN EDT$$STOP_WKINGMSG ();

!+
! Report the number of lines moved or copied.
!-
    EDT$$FMT_STRCNT (NLINES, CH$PTR (UPLIT (%STRING (' line'))), 5);

    IF (.DELETE NEQ 0)
    THEN
	EDT$$FMT_STR (CH$PTR (UPLIT (%STRING (' moved'))), 6)
    ELSE
	EDT$$FMT_STR (CH$PTR (UPLIT (%STRING (' copied'))), 7);

    IF (EDT$$CMP_LNO (COPY_COUNTER, LNO0) NEQ 0)	!
    THEN
	BEGIN
	EDT$$FMT_STR (CH$PTR (UPLIT (%STRING (' '))), 1);
	EDT$$FMT_STRCNT (COPY_COUNTER, CH$PTR (UPLIT (%STRING (' time'))), 5);
	END;

    EDT$$FMT_CRLF ();

    IF ((EDT$$CMP_LNO (COPY_COUNTER, NUM_COPIES) NEQ 0) AND (.CONTROL_C)) THEN CC_DONE = 1;

    END;					! of routine EDT$$MOVCPY_CMD

END
ELUDOM