Google
 

Trailing-Edge - PDP-10 Archives - bb-h138e-bm_tops20_v6_1_distr - 6-1-sources/exec.bli
There are 10 other files named exec.bli in the archive. Click here to see a list.
 %TITLE 'EXEC - enter and exit line and change mode'
MODULE EXEC (				! Enter and Exit Line and Change Mode
		IDENT = '3-007'			! File: EXEC.BLI Edit: CJG3007
		) =
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 provides the initialization and termination
!	processing for entering and exiting line and change mode.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: 6-AUG-1979
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 18-FEB-1981.  This module was created by
!	extracting routine EDT$$EXE_CMD  from module EDTCTRL.
! 1-002	- Regularized the headers.  JBS 24-Feb-1981
! 1-003	- Fix the file name and module name, and remove control C handling.
!	   JBS 04-Mar-1981
! 1-004	- Use the ASSERT macro.  JBS 01-Jun-1981
! 1-005	- Don't change the current mode to line just because the change mode
!	   processor exits, since it now exits at the end of the journal file.
!	   Rearrange the looping logic to take the new recovery procedure into
!	   account; this means this module no longer has RCOV_MOD as an
!	   implicit input.  Also, remove L_LINE and L_CHANGE.  JBS 02-Oct-1981
! 1-006	- Don't fail to enter change mode if the terminal is unknown or hard copy.
!	   JBS 20-Oct-1981
! 1-007	- Take the prompt from the global rather than from a constant.  JBS 21-Oct-1981
! 1-008	- Remove length of prompt string.  JBS 23-Oct-1981
! 1-009	- Correct an error in a comment.  JBS 17-Nov-1981
! 1-010 - Put L_LINE and L_CHANGE back TMV 7-Dec-81
! 1-011	- Add control C handling for line mode.  JBS 21-Dec-1981
! 1-012	- Debug control C handling.  JBS 24-Dec-1981
! 1-013	- Before returning load MACCAL into memory, in case we are returning
!	   to it on the PDP-11.  JBS 10-Mar-1982
! 1-014	- Revise the nooverlay logic to avoid undefined symbols at build time.
!	   JBS 15-Mar-1982
! 1-015	- Remove the reference to EDT$$LOAD_MACCAL.  JBS 18-Mar-1982
! 1-016	- Add alternative control C message.  JBS 24-May-1982
! 1-017	- Remove L_LINE and L_CHANGE.  JBS 03-Jun-1982
! 1-018 - Reset command buffer if ^c seen from terminal. STS 15-Jul-1982
! 1-019	- Don't clear the control C counters unless we are reading from
!	   a terminal.  Also, treat the startup file like a macro for
!	   control C processing.  JBS 28-Jul-1982
! 1-020	- Improve the control Z ignoring logic: don't journal ignored
!	   control Z's, since three in a row will be mistaken for the
!	   end of the journal file on a /RECOVER.  JBS 29-Jul-1982
! 1-021	- Simplify the call to initialize the keypad.  JBS 13-Jul-1982
! 1-022 - Clear control C if we don't have a macro. STS 06-Oct-1982
! 3-001 - Use string pointers not addresses.  GB 09-Feb-1983
! 3-002 - Modify for the TOPS-20 parser. CJG Ides of March, 1983
! 3-003 - Don't need overlay code. CJG 17-Apr-1983
! 3-004 - Add updates from V3 source kit.  GB 27-Apr-1983
! 3-005 - Modify to use EDT$$TI_BUFSTR for journalling. CJG 15-Jun-1983
! 3-006 - Fix incorrect journalling of multicommand lines. Only journal at the
!	  end of the line. CJG 10-Jan-1984
! 3-007 - Modify ASSERT macro to include error code. CJG 30-Jan-1984
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$EXE_CMD : NOVALUE;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$EXE_CMD  - execute commands'

GLOBAL ROUTINE EDT$$EXE_CMD (			! Execute commands
    SOURCE					! New input source
    ) : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Enter and exit line and change mode.
!
! FORMAL PARAMETERS:
!
!  SOURCE		new input source
!
! IMPLICIT INPUTS:
!
!	TRN_TBLINIT
!	CMD_BUF
!	CMD_LEN
!	EXITD
!	EDIT_MOD
!	TI_TYP
!	TXT_ONSCR
!	PA_STK
!	PA_MORE
!	VT52_KTBL
!	VT100_KTBL
!	PMT_LINE
!	CC_DONE
!
! IMPLICIT OUTPUTS:
!
!	INP_SRC
!	CMD_PTR
!	TXT_ONSCR
!
! ROUTINE VALUE:
!
!	0 - We have seen an EXIT command; EXITD will be set
!	1 - We have reached end of file.
!	2 - We saw a control C
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$TI_BUFSTR : NOVALUE,	! Write a line to journal buffer
	EDT$$DEF_DFLTK,			! Define default keys
	EDT$$CHM_EXE,			! Execute change mode commands
	EDT$$GET_LN,			! Read a line of input
	EDT$$PA_CMD,			! Parse a command
	EDT$$LNM_CMD,			! Execute a line mode command
	EDT$$CHK_CC,			! Check for control C
	EDT$$MSG_TOSTR : NOVALUE,	! Convert a message code to a string
	EDT$$OUT_FMTBUF : NOVALUE,	! Print the format buffer
	EDT$$CLR_CC : NOVALUE,		! Clear control C flag
	EDT$$FMT_CRLF : NOVALUE;	! End of output line

    EXTERNAL
	TRN_TBLINIT,			! Translate table init flag
	CMD_END,			! Pointer to end of command
	CMD_BUF,			! Command line buffer
	CMD_PTR,			! Pointer into command line buffer
	CMD_LEN,			! Length of current command
	EXITD,				! Did we exit with the last command?
	INP_SRC,			! Source of input commands
	EDIT_MOD,			! Current editing mode
	TXT_ONSCR,			! Text was written to screen
	PA_STK,				! Parser semantic stack
	PA_MORE,			! More input on current line
	PMT_LINE : VECTOR,		! Counted ASCII string of line-mode prompt
	CC_DONE,			! Set if control C actually aborted anything
	TIN_OBUFPOS,			! Current length of journal record
	JOU_VALID;			! Set to 1 if there is a record in the journal buffer

!+
! Specify the messages used in this routine.
!-
    MESSAGES ((ABOBYCC, CTRC__IGN));

    LOCAL
	STATUS,
	SAVE_SOURCE,
	EOF_FLAG;				! 1 = reached end of file, 2 = control C

!+
! If we are not coming from the terminal but a control C has been typed, get out now.
!-

    IF ((.INP_SRC NEQ INP_TERM) AND (.INP_SRC NEQ INP_JOURNAL))
    THEN

	IF EDT$$CHK_CC ()
	THEN
	    BEGIN
	    CC_DONE = 1;
	    RETURN (2);
	    END;

    SAVE_SOURCE = .INP_SRC;
    INP_SRC = .SOURCE;
    CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);

    PA_MORE = 0;
    EOF_FLAG = 0;

    WHILE ((.EOF_FLAG EQL 0) AND ( NOT .EXITD)) DO

	IF (.EDIT_MOD EQL CHANGE_MODE)
	THEN
!+
! We are in change mode, go into the change mode processor.
!-
	    BEGIN

!+
! Init the keypad translation table if necessary.
! If the initialization fails, drop into line mode.
!-
	    STATUS = 1;

	    IF ( NOT .TRN_TBLINIT) THEN STATUS = EDT$$DEF_DFLTK ();

	    IF (.STATUS EQL 1)
	    THEN
		EOF_FLAG = EDT$$CHM_EXE ()
	    ELSE
		BEGIN
		EDT$$MSG_TOSTR (.STATUS);
		EDT$$FMT_CRLF ();
		EDIT_MOD = LINE_MODE;
		END;

!+
! EDT$$CHM_EXE returns after a series of commands.  It returns on the EXIT
! command (which sets EDIT_MOD to LINE_MODE) and at the end of the
! journal file.  In the latter case it returns a 1; if it returns because
! of exiting it returns a 0.
!-
	    END
	ELSE
	    BEGIN
	    IF (.INP_SRC NEQ INP_MACRO) THEN EDT$$CLR_CC ();

	    ASSERT (2, .EDIT_MOD EQL LINE_MODE);	! We are in line mode
!+
! See if we must read a line.
!-
	    IF (.PA_MORE EQL 0) THEN
		BEGIN

		WHILE ((EDT$$GET_LN (1, PMT_LINE [1], .PMT_LINE [0]) NEQ 0) AND ( NOT .EOF_FLAG))
		DO
		    BEGIN

		    IF (.INP_SRC NEQ INP_TERM)
		    THEN
			EOF_FLAG = 1
		    ELSE
			BEGIN
!+
! This is an EOF from the terminal, invalidate the journal buffer.
! If we journal this it may be confused with the end of the journal file.
!-
			TIN_OBUFPOS = 0;
			JOU_VALID = 0;
			END;

		    END;

		END;


!+
! Parse and execute the command. (Unless it is a comment or we have reached EOF.)
!-

	    IF ( NOT .EOF_FLAG)
	    THEN
		BEGIN

		STATUS = EDT$$PA_CMD (CH$PTR (PMT_LINE [1],, BYTE_SIZE),
		    (IF (.INP_SRC EQL INP_TERM)
			THEN .PMT_LINE [0]
			ELSE 0));
!+
! Write the command to the journal file
!-

		IF ((.INP_SRC EQL INP_TERM) AND (.PA_MORE EQL 0)) THEN
		    BEGIN
		    EDT$$TI_BUFSTR (CH$PTR (CMD_BUF,, BYTE_SIZE), .CMD_LEN - 2);
		    JOU_VALID = 1;
		    END;

		IF .STATUS THEN
		    EDT$$LNM_CMD (PA_STK)
		ELSE
		    TXT_ONSCR = .TXT_ONSCR + 1;

!+
! If the control C flag is set, it is likely that the command was aborted
! by a control C.
!-

		IF EDT$$CHK_CC ()
		THEN
		    BEGIN
		    IF ((.INP_SRC EQL INP_TERM) OR (.INP_SRC EQL INP_JOURNAL))
		    THEN
			BEGIN

			IF CH$PTR_NEQ (.CMD_PTR, CH$PTR (CMD_BUF,, BYTE_SIZE))
			THEN
			    CC_DONE = 1;

			IF (.CC_DONE)
			THEN
			    EDT$$MSG_TOSTR (EDT$_ABOBYCC)
			ELSE
			    EDT$$MSG_TOSTR (EDT$_CTRC__IGN);

			EDT$$OUT_FMTBUF ();
!+
! We've seen a control C from the terminal, so clear out the command buffer.
!-
			CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
			CMD_END = .CMD_PTR;
!			CH$WCHAR (%C'!', .CMD_END);
			END
		    ELSE
!+
! We have seen a control C but we are not reading from the terminal.  Return to our caller, who
! will arrange to print an appropriate message.
!-
			BEGIN
			CC_DONE = 1;
			EOF_FLAG = 2;
			END;

		    END;

		END;

	    END;

!+
! When the loop falls through we have either reached an end of file or
! seen an EXIT command.  Tell the caller which.
!-
    INP_SRC = .SAVE_SOURCE;
    RETURN (.EOF_FLAG);
    END;


END
ELUDOM