Google
 

Trailing-Edge - PDP-10 Archives - bb-r775d-bm_tops20_ks_upd_4 - sources/keydefkey.bli
There are 10 other files named keydefkey.bli in the archive. Click here to see a list.
 %TITLE 'KEYDEFKEY - interactive define key'
MODULE KEYDEFKEY (				! Interactive define key
		IDENT = '3-002'			! File: KEYDEFKEY.BLI Edit: GB3002
		) =
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:
!
!	Interactive define key
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: April 7, 1979
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 24-Feb-1981.  This module was created by
!	extracting routine EDT$$LN_DEFK  from module KEYTRAN.
! 1-002	- Regularize headers.  JBS 09-Mar-1981
! 1-003	- Use new message codes.  JBS 04-Aug-1981
! 1-004	- Add return values.  JBS 02-Oct-1981
! 1-005	- Revise call to enable autorepeat.  JBS 30-Jan-1982
! 1-006 - Make CR a valid part of the key definition.  SMB 17-Feb-1982
! 1-007 - Make DEFK illegal in NOKEYPAD mode - used only for defining
!         keys in KEYPAD mode.  SMB 1-Mar-1982
! 1-008	- Fix routine header.  JBS 22-Apr-1982
! 1-009 - EDT$$DEFK returns a status.  JBS 18-May-1982
! 1-010	- Set a flag if control C actually aborts something.  JBS 24-May-1982
! 1-011 - Return true success from EDT$$NXT_CMDCH. STS 16-Jun-1982
! 1-012 - Pass flag to EDT$$NXT_CMDCH to indicate whether or not we wish
!	    to accept repeat counts. STS 16-Jun-1982
! 1-013 - Modify message processing.  SMB 22-Jun-1982
! 1-014	- New implementation of defined keys.  JBS 13-Aug-1982
! 1-015	- Change cursor positioning call to obsolete a module.  JBS 05-Oct-1982
! 1-016	- Worry about having no cursor position to return to.  This can happen
!	   if this command is typed ahead initially.  JBS 22-Feb-198I
! 3-001 - Fix string pointers.  GB 25-Apr-1983
! 3-002 - Add updates from V3 sources.  GB 29-Apr-1983
!--

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$LN_DEFK;				! Interactive "define key"

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

LIBRARY 'EDTSRC:KEYPADDEF';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!
!	NONE
!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$LN_DEFK  - interactive define key'

GLOBAL ROUTINE EDT$$LN_DEFK 			! Interactive define key
    =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine is called when the change mode command DEFK is processed
!	to process the interactive define key command.  The user is prompted
!	for the key to be defined and the defining string.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	CMD_BUF
!	CS_LNO
!	CUR_COL
!	KPAD
!
! IMPLICIT OUTPUTS:
!
!	CMD_PTR
!	CMD_END
!	CC_DONE
!
! ROUTINE VALUE:
!
!	1 = ok, 2 = end of journal file, 0 = fail or control C
!
! SIDE EFFECTS:
!
!	May define a key, or undefine a key.
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$STOP_WKINGMSG,
	EDT$$CHK_CC,
	EDT$$SC_POSCSIF : NOVALUE,
	EDT$$ERA_MSGLN,
	EDT$$MSG_BELL,
	EDT$$OUT_MSG,
	EDT$$TST_BADK,
	EDT$$DEFK,
	EDT$$CAN_KDEF,
	EDT$$NXT_CMDCH,				! Get the next command character
	EDT$$TRN_KSTR,				! Build the command buffer
	EDT$$PUT_CMDCH : NOVALUE,		! Put a character in the command buffer
	EDT$$SC_NONREVID,
	EDT$$TI_ENBLAUTREP,			! Enable or disable autorepeat
	EDT$$TI_DELK;

    EXTERNAL
	MSGFLG,				! Message flag
	MESSAGE_LINE,			! Line on which to print prompts
	KPAD,				! Are we in KEY or NOKEY mode
	CMD_BUF,				! Command buffer
	CMD_PTR,				! Pointer to next char in command buffer
	CMD_END,				! Pointer to end of info in command buffer
	CS_LNO,				! Line on which the cursor is positioned
	CUR_COL,				! Column on which the cursor is positioned.
	CC_DONE;				! Set to 1 if control C actualls aborts something

    MESSAGES ((PRSKEYDEF, KEYNOTDEF, NOWENTDEF, BADDEFK));

    LOCAL
	KEY_ADDR,
	KEY : INITIAL (K_KEY_MAX + 1),		! Initialize to an illegal value
	CON_U,
	C,
	SUCCEED,
	STATUS;
!+
! Since this command uses the bottom two lines for prompting and echoing,
! we don't want the Working message to continue printing.
!-
    EDT$$STOP_WKINGMSG ();

!+
! The interactive define key facility only works in keypad mode.
!-
    IF ( NOT .KPAD)
    THEN
	BEGIN
	EDT$$MSG_BELL (EDT$_BADDEFK);
	CMD_END = CH$PTR (CMD_BUF,, BYTE_SIZE);
	RETURN (0)
	END;

    SUCCEED = 1;
!+
! Set up the buffer for the definition to go into
!-
    CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
    CMD_END = CH$PTR (CMD_BUF, 256, BYTE_SIZE);
!+
! Prompt for the key.
!-
    EDT$$OUT_MSG (.MESSAGE_LINE, EDT$_PRSKEYDEF, 0, 0);
    SUCCEED = EDT$$NXT_CMDCH (KEY, 0);		! zero means no repeat counts allowed

    IF (.SUCCEED NEQ 1) THEN RETURN (.SUCCEED);

!+
! Check for the validity of the key.
!-


    IF EDT$$TST_BADK (.KEY)
    THEN
	BEGIN
!+
! Bad key.  Put out a message and return.
!-
	EDT$$MSG_BELL (EDT$_KEYNOTDEF);
	CMD_END = CH$PTR (CMD_BUF,, BYTE_SIZE);
	RETURN (0);
	END;

!+
! Now prompt for the definition.
!-
    EDT$$OUT_MSG (.MESSAGE_LINE, EDT$_NOWENTDEF, 0, 0);
!+
! Loop, reading characters until we see the enter key.  Keypad keys
! and gold/letter are translated, delete and CTRL/U have the usual
! meanings and all other characters are inserted directly.
!-
    CON_U = 0;					! Note whether CONTROL U entered

    WHILE 1 DO
	BEGIN
	SUCCEED = EDT$$NXT_CMDCH (C, 1);

	IF (.SUCCEED NEQ 1) THEN RETURN (2);

	IF EDT$$CHK_CC ()
	THEN
	    BEGIN
	    CMD_END = CH$PTR (CMD_BUF,, BYTE_SIZE);
	    CC_DONE = 1;
	    RETURN (0);
	    END;

	SELECTONE .C OF
	    SET

	    [K_ENTER] :
		EXITLOOP;

	    [K_KPAD_BASE to K_KEY_MAX] :
		BEGIN
!+
! Keypad or gold key, place the translation in the buffer.
!-
		SUCCEED = EDT$$TRN_KSTR (.C, 0, 1);

		IF (.SUCCEED EQL 2) THEN RETURN (2);

		CMD_END = CH$PTR (CMD_BUF, 256, BYTE_SIZE);
		END;

	    [ASC_K_DEL] :
		BEGIN
!+
! Delete key.  Delete the previous character unless we are at
! the beginning.
!-

		IF CH$PTR_GTR (.CMD_PTR, CH$PTR (CMD_BUF,, BYTE_SIZE))
		THEN
		    BEGIN
		    CMD_PTR = CH$PLUS (.CMD_PTR, -1);
		    EDT$$TI_DELK (CH$RCHAR (.CMD_PTR));
		    END;

		END;

	    [ASC_K_CTRL_U] :
		BEGIN
!+
! CTRL/U: abort the define key command.
!-
		CON_U = 1;
		CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
		EXITLOOP;
		END;

	    [OTHERWISE] :
!+
! None of the above: must be a character (other than DEL or CTRL/U) from
! the main keyboard.  Insert it in the definition.
!-
		EDT$$PUT_CMDCH (.C, 1);
	    TES;

!+
! Turn on autorepeat, since seeing a keypad key will have turned
! it off.
!-
	EDT$$TI_ENBLAUTREP (1);
	END;

!+
! Now define the key.
!-

    IF CH$PTR_NEQ (.CMD_PTR, CH$PTR (CMD_BUF,, BYTE_SIZE))
    THEN
	BEGIN
	STATUS = EDT$$DEFK (.KEY, CH$PTR (CMD_BUF,, BYTE_SIZE),
		  CH$DIFF (.CMD_PTR, CH$PTR (CMD_BUF,, BYTE_SIZE)));

	IF ( NOT .STATUS) THEN SUCCEED = 0;

	END
    ELSE
	BEGIN
!+
! Clear the definition of a key defined as the null string,
! except do nothing if the definition was terminated by a CTRL/U.
!-

	IF (.CON_U EQL 0)
	THEN
	    BEGIN
	    STATUS = EDT$$CAN_KDEF (.KEY);

	    IF ( NOT .STATUS) THEN SUCCEED = 0;

	    END;

	END;

!+
! Reset the buffer pointer, erase the command line and reposition the cursor
! before continuing.
!-
    CMD_PTR = CH$PTR (CMD_BUF,, BYTE_SIZE);
    CMD_END = CH$PTR (CMD_BUF,, BYTE_SIZE);
    MSGFLG = 1;
    EDT$$ERA_MSGLN ();
    IF (.CS_LNO GEQ 0) THEN EDT$$SC_POSCSIF (.CS_LNO, .CUR_COL);
    EDT$$SC_NONREVID ();
!+
! If we had an error print an appropriate message.
!-

    IF (.SUCCEED EQL 0) THEN EDT$$MSG_BELL (.STATUS);

    RETURN (.SUCCEED);
    END;					! of routine EDT$$LN_DEFKEY


END
ELUDOM