Google
 

Trailing-Edge - PDP-10 Archives - CFS_TSU04_19910205_1of1 - update/t20src/chmchange.bli
There are 11 other files named chmchange.bli in the archive. Click here to see a list.
%TITLE 'CHMCHANGE - change mode execution'
MODULE CHMCHANGE (				! Change mode execution
		IDENT = '3-006'			! File: CHMCHANGE.BLI Edit: CJG3006
		) =
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 contains the main routine for change mode execution.
!
! 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 EDT$$CHM_EXE  from module CHANGE.BLI.
! 1-002	- Regularize headers and remove control C.  JBS 27-Feb-1981
! 1-003	- Fix module name.  JBS 02-Mar-1981
! 1-004	- Revise journaling.  JBS 22-Jun-1981
! 1-005	- Fix a journaling bug.  JBS 08-Jul-1981
! 1-006	- Use EDT$_ for message codes.  JBS 04-Aug-1981
! 1-007	- Fix a comment which stated that EDT$$GZ_COMMAND_RAB is an implicit input;
!	   actually, it is not used.  JBS 16-Aug-1981
! 1-008	- Return if the journal file terminates, and tell the caller.  JBS 01-Oct-1981
! 1-009 - Change EOB to user defined string. STS 06-Oct-1981
! 1-010	- Change literal prompt to use global string.  JBS 20-Oct-1981
! 1-011	- Remove length of prompt string.  JBS 23-Oct-1981
! 1-012	- Add control C handling.  JBS 21-Dec-1981
! 1-013	- Debug control C handling.  JBS 24-Dec-1981
! 1-014	- Add JOU_VALID.  JBS 09-Apr-1982
! 1-015	- Simplify the call to EDT$$SC_RESET.  JBS 22-Apr-1982
! 1-016	- Add alternative control C message.  JBS 25-May-1982
! 1-017	- Clear EXI before exiting.  JBS 02-Jun-1982
! 1-018	- Clear error indicator after an error in hardcopy
! 1-019 - Remove reference to SET_FMTWRRUT and other message changes.
!	  SMB 29-Jun-1982
! 1-020 - Make FIRST_TIME_ENTERED a global.  SMB 1-Jul-1982
! 1-021	- Remove CHM_FRST_ENTRY, use instead LASTMSG.  JBS 05-Jul-1982
! 1-022 - Remove EDT$$G_LN_NO.  SMB 24-Sep-1982
! 1-023	- Change the call to screen update and add a LOAD entry point, so this module
!	   can be displaced by the screen update modules on the PDP-11.  JBS 25-Sep-1982
! 1-024	- Change the screen update call again, to improve overlay size.  JBS 27-Sep-1982
! 1-025 - Remove the call to SC_INIT, set a flag instead.  SMB 06-Oct-1982
! 1-026 - Convert to new journalling scheme. STS 06-Oct-1982
! 1-027	- Change the name of the cursor positioning routine, to obsolete a
!	   redundent module.  JBS 07-Oct-1982
! 1-028	- Correct a comment.  JBS 09-Oct-1982
! 1-029	- Set EDT$$G_SCR_REBUILD on exit, so line mode will be more efficient.  JBS 21-Oct-1982
! 1-030 - First time through - ignore typeahead. STS 10-Nov-1982
! 1-031 - First time through - don't update screen if typeahead. STS 01-Dec-1982
! 1-032 - Clear screen first time through. STS 02-Dec-1982
! 1-033 - Fix problem with hardcopy recoveries. STS 13-Dec-1982
! 1-034	- Only initialize the screen once.  JBS 20-Dec-1982
! 1-035	- Be more careful about printing the owed message.  JBS 18-Jan-1983
! 1-036	- Don't call EDT$$ERA_MSGLN unnecessarily.  JBS 20-Jan-1983
! 1-037	- Don't call EDT$$RD_ECHO unnecessarily.  JBS 21-Jan-1983
! 1-038	- Only update the screen for every 10 characters when doing
!	   a recovery.  JBS 21-Jan-1983
! 1-039	- Add new value for EDT$$G_SCR_CHGD.  JBS 02-Mar-1983
!	  Start of modifications for TOPS10/20.
! 3-001 - Fix EDT$$FMT_STR. CJG 22-Mar-1983
! 3-002 - Add updates from V3 source kit.  GB 26-Apr-1983
! 3-003 - Modify to use EDT$$TI_BUFSTR for journalling. CJG 15-Jun-1983
! 3-004 - Fix problem in handling of nokeypad commands with CHANGE command.
!	  CJG 13-Dec-1983
! 3-005 - Fix a problem with journalling multicommand lines, especially CHANGE\...
!	  CJG 10-Jan-1984
! 3-006 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
EDT$$CHM_EXE;				! Driver for change mode processing

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine

%SBTTL 'EDT$$CHM_EXE  - change mode execution'

GLOBAL ROUTINE EDT$$CHM_EXE 			! Change mode execution
=

!++
! FUNCTIONAL DESCRIPTION:
!
!	This is the main routine for change mode execution.  First we initialize
!	for change mode, then execute any change mode commands on the current
!	command line.  After we have finished with them, we check to see if an
!	exit was done and if so get out.  Otherwise we enter into the change mode
!	command loop, getting commands and executing them until an exit is done,
!	or until the journal file ends.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	CMD_BUF
!	CUR_COL
!	CS_LNO
!	EXI
!	CMD_LEN
!	CMD_PTR
!	INP_SRC
!	RCOV_MOD
!	TI_TYP
!	LN_BUF
!	LN_PTR
!	LN_END
!	PMT_HCCHG
!	CC_DONE
!	LASTMSG
!	TIN_ECHOFLG
!	RECSCRUPD
!
! IMPLICIT OUTPUTS:
!
!	EXI
!	CMD_END
!	CMD_PTR
!	CUR_BUF
!	EDIT_MOD
!	JOU_VALID
!	SCR_CHGD
!	SCR_REBUILD
!	RECSCRUPD
!
! ROUTINE VALUE:
!
!	1 = reached the end of the journal file
!	0 = executed an exit command
!
! SIDE EFFECTS:
!
!	MANY
!
!--

BEGIN

EXTERNAL ROUTINE
	EDT$$MSG_BELL : NOVALUE,	! Output a message to the terminal with a warning bell
	EDT$$SC_POSCSIF,		! Absolute cursor positioning
	EDT$$RD_ECHO,			! Try to optimize terminal input
	EDT$$INIT_CHM : NOVALUE,	! Initialization on entering change mode
	EDT$$FMT_CH,			! Format a charcter
	EDT$$OUT_FMTBUF,		! Dump the format buffer
	EDT$$FMT_STR,			! Format a string
	EDT$$RD_CMDLN,			! Get a command line
	EDT$$TI_BUFCH : NOVALUE,	! Put a character in the journal file buffer
	EDT$$TI_BUFSTR : NOVALUE,	! Put string in journal file
	EDT$$TI_FLUSHJOUFI : NOVALUE,	! Empty the journal file's buffer
	EDT$$RD_JOUTXT,			! Read a text record from the journal file
	EDT$$TI_WRLN,			! Write to terminal
	EDT$$TI_WRSTR,			! Write to terminal unformatted
	EDT$$GET_KPADCMD,		! Get a keypad command
	EDT$$FMT_TEXT : NOVALUE,	! output eob string
	EDT$$RPL_CHGDLN,		! Declare current line as changed
	EDT$$CHM_PAREXE,		! Parse and execute a change mode command string
	EDT$$SC_INIT,			! Initialize for screen mode
	EDT$$SC_ERAALL,			! Erase the screen
	EDT$$SC_RESET,			! Reset screen parameters
	EDT$$SC_UPD,			! Update the screen
	EDT$$START_WKINGMSG,		! Set up working AST
	EDT$$STOP_WKINGMSG,		! Terminate working AST
	EDT$$FMT_MSG,			! Print message text
	EDT$$ERA_MSGLN,			! Start command echoing
	EDT$$TI_TSTTYAHED,		! Check for type ahead
	EDT$$TST_EOB,			! Check for end of buffer
	EDT$$CHK_CC,			! Check for control C
	EDT$$CLR_CC : NOVALUE;		! Clear control C flag

EXTERNAL
	EDIT_DFLTMOD,			! Editing default mode
	PUT_JOU,			!
	MESSAGE_LINE,			! Error message line is 1 more
	MSGFLG,				! 1 = there is a message on the last line
	LASTMSG,			! The last message printed
	FMT_WRRUT,			! Holds address of write routine
	CMD_BUF,			! Command string buffer
	PA_MORE,			! Non-zero = more command in buffer
	PA_CURTOK,			! Pointer to remainder of command
	PA_CURTOKLEN,			! Length of remainder
	CUR_COL,			! current column
	CS_LNO,				! cursor line.
	EXI,				! Change mode has been exited.
	CMD_END,			! End of command pointer
	CMD_LEN,			! Length of command buffer
	CMD_PTR,			! Command string pointer
	INP_SRC,			! Source of command input.
	RCOV_MOD,			! In recovery mode?
	CUR_BUF : REF TBCB_BLOCK,	! The current buffer tbcb
	TI_TYP,				! Terminal type.
	LN_BUF,				! Current line buffer
	LN_PTR,				! Current character pointer
	LN_END,				! End of current line pointer
	EDIT_MOD,			! Editing mode: line or change
	PMT_HCCHG : VECTOR,		! Counted ASCII prompt string for hardcopy change mode
	CC_DONE,			! 1 = Control C actually aborted something
	JOU_VALID,			! 1 = Journal record is valid
	WK_LN : REF LIN_BLOCK,
	EOB_LN,
	SCR_CHGD,			! The screen must be repainted
	SCR_REBUILD,			! The screen must be rebuilt from the work file
	TIN_ECHOFLG,
	RECSCRUPD;			! Counter for screen updates in recovery mode

LOCAL
	FIRST_TIME,			! 1 = first time at least initialise the screen
	STATUS,				! 0 = error, 1 = ok, 2 = journal file ended
	CC_MSG,				! 0 = no message, 1 = aborted msg, 2 = ignored msg
	OWED_MESSAGE;			! 1 = we should print the last message again

!+
! Specify messages used in this routine.
!-

    MESSAGES ((CHGMODTER, ABOBYCC, CTRC__IGN));

!+
! Since we entered this routine, we must be in change mode.
!-

    ASSERT (2, .EDIT_MOD EQL CHANGE_MODE);

!+
! Perform initialization.
!-

    EDT$$INIT_CHM ();
    FIRST_TIME = 1;
    CC_MSG = 0;

!+
! Execute remainder of command line if there is a backslash.
!-

    IF (.PA_MORE)
    THEN
	BEGIN
	PA_MORE = 0;
	CMD_PTR = .PA_CURTOK;
	CMD_END = CH$PLUS (.PA_CURTOK, .PA_CURTOKLEN - 2);
	EDT$$TI_BUFSTR (CH$PTR (CMD_BUF ,,BYTE_SIZE), .CMD_LEN + .PA_CURTOKLEN - 2);
	JOU_VALID = 1;
	STATUS = EDT$$CHM_PAREXE (1);
	END
    ELSE
	STATUS = 1;

!+
! Make sure any previous commands have been written out to the journal file
!-

    IF ( NOT .RCOV_MOD) THEN EDT$$TI_FLUSHJOUFI (%C'T');

!+
! If an exit command was seen, get out now.
!-

    IF .EXI
    THEN
	BEGIN
	EDIT_MOD = LINE_MODE;
	EDT$$RPL_CHGDLN ();
	EXI = 0;
	RETURN (0);
	END;

!+
! Before entering the command loop, make sure the input is either coming
! from the terminal or from a recovery file.  We do not allow the startup
! file or macros to enter change mode.
!-

    IF (((.INP_SRC NEQ INP_TERM) AND ( NOT .RCOV_MOD)) OR 	!
	(.TI_TYP EQL TERM_UNKNOWN))
    THEN
	BEGIN
	EDIT_MOD = LINE_MODE;
	EDT$$FMT_MSG (EDT$_CHGMODTER);
	RETURN (0);
	END;

!+
! Set up for change mode editing.
!-
    OWED_MESSAGE = 1;

    IF ((.TI_TYP EQL TERM_VT52) OR (.TI_TYP EQL TERM_VT100))
    THEN
	BEGIN
	FMT_WRRUT = EDT$$TI_WRSTR;
!+
! Since we are about to refresh the screen, remember if there is a message,
! so we can display it.  This lets us display, for example, "Input file does not
! have standard text format" even if the first thing we do is enter change mode.
!-

	OWED_MESSAGE = .LASTMSG;
	SCR_CHGD = 2;

	END;

!+
! Now loop through, getting commands until an exit is seen or the journal file ends.
!-

    WHILE ((.EXI EQL 0) AND (.STATUS NEQ 2)) DO
	BEGIN
	IF .PUT_JOU
	THEN
	    BEGIN
	    IF ( NOT .RCOV_MOD) THEN EDT$$TI_FLUSHJOUFI (%C'T');
	    EDT$$CLR_CC ();
	    PUT_JOU = 0;
	    END;
!+
! Check for a hardcopy terminal.
!-

	IF (.TI_TYP EQL TERM_HCPY)
	THEN
	    BEGIN
!+
! Hard copy change mode.  Output a control C message if we owe one.
!-

	    CASE .CC_MSG FROM 0 TO 2 OF
		SET

		[0] : 				! We don't owe a message
		    BEGIN
		    0
		    END;

		[1] : 				! The previous operation was aborted by a control C
		    BEGIN
		    EDT$$MSG_BELL (EDT$_ABOBYCC);
		    CC_MSG = 0;
		    END;
	
		[2] : 				! The previous control C was ignored
		    BEGIN
		    EDT$$MSG_BELL (EDT$_CTRC__IGN);
		    CC_MSG = 0;
		    END;
		TES;
!+
! Type the current line with the cursor bracketed.
!-

	    IF (.WK_LN EQLA EOB_LN)
	    THEN
		EDT$$FMT_TEXT (0)
	    ELSE
		BEGIN
		EDT$$FMT_STR (CH$PTR (LN_BUF,, BYTE_SIZE),
			      CH$DIFF (.LN_PTR, CH$PTR (LN_BUF,, BYTE_SIZE)));
		EDT$$FMT_CH (%C'[');
		EDT$$FMT_CH (CH$RCHAR (.LN_PTR));
		EDT$$FMT_CH (%C']');

		IF CH$PTR_NEQ (.LN_PTR, .LN_END)
		THEN
		    EDT$$FMT_STR (CH$PLUS (.LN_PTR, 1), CH$DIFF (.LN_END, .LN_PTR) - 1);

		END;

	    EDT$$OUT_FMTBUF ();
!+
! Now get the next command string.
!-
	    STATUS = 1;

	    IF .RCOV_MOD
	    THEN
		BEGIN

		IF ( NOT EDT$$RD_JOUTXT (CMD_BUF, CMD_LEN))
		THEN
		    STATUS = 2			! Journal file ended
		ELSE
		    BEGIN

		    IF (.CMD_LEN EQL 2)
		    THEN

			IF (CH$RCHAR (CH$PTR (CMD_BUF,, BYTE_SIZE)) EQL %C'^')
			THEN

			    IF ((CH$RCHAR (CH$PTR (CMD_BUF, 1, BYTE_SIZE)) EQL %C'Z') OR 	!
				(CH$RCHAR (CH$PTR (CMD_BUF, 1, BYTE_SIZE)) EQL %C'z'))
			    THEN
				EXI = 1;
		    CMD_END = CH$PTR (CMD_BUF, .CMD_LEN, BYTE_SIZE);
		    END

		END
	    ELSE
		BEGIN
!+
! We are not recovering.
!-
!+
! Since we are about to read from the terminal, make sure the last
! line has been written to the journal file.
!-
		EXI = EDT$$RD_CMDLN (PMT_HCCHG [1], .PMT_HCCHG [0], CMD_BUF,
		    CMD_LEN, 255);
		CMD_END = CH$PTR (CMD_BUF, .CMD_LEN, BYTE_SIZE);
!+
! Put the new line in the journal file buffer.
!-

		IF .EXI
		THEN
		    BEGIN
		    EDT$$TI_BUFCH (%C'^');
		    EDT$$TI_BUFCH (%C'Z');
		    END
		ELSE
		    EDT$$TI_BUFSTR (CH$PTR (CMD_BUF,, BYTE_SIZE), .CMD_LEN);

		JOU_VALID = 1;
		END;

	    END
	ELSE
	    BEGIN
!+
! This is not a hard copy terminal.
! Erase the message line, unless it is scheduled to be erased by the next keystroke.
!-

	    IF (( NOT .MSGFLG) AND .TIN_ECHOFLG) THEN EDT$$ERA_MSGLN ();

!+
! Check for characters in type ahead.  Do not update if there
! are more characters to handle.
!-

	    IF ( NOT EDT$$TI_TSTTYAHED ())
	    THEN
		BEGIN
		FIRST_TIME = 0;
!+
! Update the screen.
! In recovery mode we update the screen only 1/10 as often, to make
! recovery go faster.
!-

		IF .RCOV_MOD
		THEN
		    BEGIN
		    RECSCRUPD = .RECSCRUPD - 1;

		    IF (.RECSCRUPD LEQ 0)
		    THEN
			BEGIN
			RECSCRUPD = 10;
			EDT$$SC_UPD ();
			END

		    END
		ELSE
		    EDT$$SC_UPD ();
!+
! Re-display the last message we saw before entering change mode.
!-

		IF (.OWED_MESSAGE NEQ 1)	! If there is a message
		THEN
		    BEGIN
		    EDT$$SC_POSCSIF (.MESSAGE_LINE + 1, 0);
		    EDT$$MSG_BELL (.OWED_MESSAGE);
		    MSGFLG = 1;			! Erase it on next keystroke
		    OWED_MESSAGE = 1;		! We no longer owe the message
		    END
		ELSE
		    BEGIN
!+
! Output a control C message if we owe one.
!-

		    CASE .CC_MSG FROM 0 TO 2 OF
			SET

			[0] : 			! We don't owe a message
			    BEGIN
			    0
			    END;

			[1] : 			! The previous operation was aborted by a control C
			    BEGIN
			    EDT$$MSG_BELL (EDT$_ABOBYCC);
			    CC_MSG = 0;
			    END;

			[2] : 			! The previous control C was ignored
			    BEGIN
			    EDT$$MSG_BELL (EDT$_CTRC__IGN);
			    CC_MSG = 0;
			    END;
			TES;

		    END;

!+
! Check for the optimized input applying.
!-

		IF ( NOT .RCOV_MOD)
		THEN
		    IF ( NOT EDT$$RD_ECHO ()) THEN EDT$$SC_POSCSIF (.CS_LNO, .CUR_COL);
		END
	    ELSE
		IF .FIRST_TIME
		THEN
		    BEGIN
		    FIRST_TIME = 0;
		    EDT$$SC_INIT ();
		    EDT$$SC_ERAALL ();
		    END;

!+
! Get the next command string.
!-
	    CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
	    CMD_END = CH$PTR (CMD_BUF, 256, BYTE_SIZE);

	    IF EDT$$CHK_CC () THEN STATUS = 1 ELSE STATUS = EDT$$GET_KPADCMD ();

	    END;

	IF ((.STATUS EQL 1) AND ( NOT EDT$$CHK_CC ()))
	THEN
	    BEGIN
!+
! Start up the 'working' AST.
!-

	    IF (.TI_TYP NEQ TERM_HCPY) THEN EDT$$START_WKINGMSG ();

!+
! Execute the command string in CMD_BUF .
!-
	    CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
	    STATUS = EDT$$CHM_PAREXE (1);
!+
! Turn off the 'working' AST.
!-

	    IF (.TI_TYP NEQ TERM_HCPY) THEN EDT$$STOP_WKINGMSG ();

	    END;

!+
! If the control C flag is set, the command was probably aborted by a control C.
! Invalidate the screen (since control C can sometimes cause a scroll) and arrange
! to show an appropriate message.
!-

	IF EDT$$CHK_CC ()
	THEN
	    BEGIN

	    IF (.TI_TYP NEQ TERM_HCPY) THEN SCR_CHGD = 1;

	    IF .CC_DONE THEN CC_MSG = 1 ELSE CC_MSG = 2;

	    END
	ELSE
	    CC_MSG = 0;

	END;

    EDT$$RPL_CHGDLN ();

!+
! Clean up after ourselves.  If we will be back here because this is
! just the journal file ending we will put everything back for change
! mode again.
!
! Reset the terminal as required.
!-

    EDT$$SC_RESET ();

!+
! Flag that the screen must be rebuilt from the work file.  This makes line
! mode more efficient, since it does not need to maintain the screen data base.
!-

    SCR_REBUILD = 1;

!+
! Reset the formatted write routine for line mode.
!-

    FMT_WRRUT = EDT$$TI_WRLN;
    CUR_BUF [TBCB_CHAR_POS] = CH$DIFF (.LN_PTR, CH$PTR (LN_BUF,, BYTE_SIZE));
    CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
    CH$WCHAR (%C'!', .CMD_PTR);

    IF (.EXI NEQ 0)
    THEN
	BEGIN
	EDIT_MOD = LINE_MODE;
	EXI = 0;
	END;

    IF (.STATUS EQL 2) THEN RETURN (1) ELSE RETURN (0);

    END;					! of routine EDT$$CHM_EXE

END
ELUDOM