Google
 

Trailing-Edge - PDP-10 Archives - walsh_goodStuff_1600 - cho/vt100.pcl
There are no other files named vt100.pcl in the archive.
COMMAND VT100; BEGIN
    EXTERNAL PROCEDURE VT100_CHANGE;
    EXTERNAL STRING PROCEDURE VT100_LINE;
    INTEGER IDX,TOP,BOTTOM,NUM2DO;
    STRING FCN,KEYWD,MESS,FIL;
    PARSE NOISE "function";
    PARSE KEYWORD(WORDS(
	ANSI:0,
	ARROW_MODE:0,
	AUTOREPEAT:0,
	BLACK:0,
	C132:0,
	C80:0,
	CHARACTER_ATTRIBUTE:0,
	KEYPAD_MODE:0,
	NO_AUTOREPEAT:0,
	REGION:0,
	SCROLL_MODE:0,
	SELECT_CHARACTERS:0,
	VT52:0,
	WHITE:0));
  LET FCN = $ATOM;
  SELECT FCN OF BEGIN
    ["BLACK"]: BEGIN
	PARSE NOISE "background";
	PARSE EOL;
	CALL VT100_CHANGE ("[?5l");EXIT;
	END;

    ["SELECT-CHARACTERS"]: BEGIN
	PARSE NOISE "set";
	PARSE KEYWORD (WORDS(
	    ASCII:66,
	    GRAPHICS:48,
	    ROM1:49,
	    ROM2:50,
	    UNITED_KINGDOM:65));
	LET IDX = $VALUE;
	PARSE EOL;
	CALL VT100_CHANGE ("(" + $CVITC(IDX) + ")" + $CVITC(IDX));
	    !Make both CTRL/N and CTRL/O sets be the specified one for now!
	EXIT;
	END;

    ["CHARACTER-ATTRIBUTE"]: BEGIN
	PARSE NOISE "is";
	PARSE KEYWORD (WORDS(
	    BLINK:5,
	    BOLD:1,
	    NONE:0,
	    REVERSE_VIDEO:7,
	    UNDERSCORE:4));
	LET IDX = $VALUE;	!Get correct selective parameter
	PARSE NOISE "for subsequent typeout";
	PARSE EOL;
	CALL VT100_CHANGE ("[" + $STRING(IDX) + "m");
	EXIT;
	END;
    ["WHITE"]: BEGIN
	PARSE NOISE "background";
	PARSE EOL;
	CALL VT100_CHANGE ("[?5h");EXIT;
	END;

    ["NO-AUTOREPEAT"]: BEGIN
	PARSE NOISE "when keys held down";
	PARSE EOL;
	CALL VT100_CHANGE ("[?8l");EXIT;
	END;

    ["AUTOREPEAT"]: BEGIN
	PARSE NOISE "when keys held down";
	PARSE EOL;
	CALL VT100_CHANGE ("[?8h");EXIT;
	END;

    ["C132"]: BEGIN
	PARSE EOL;
	DOCOMMAND "TER WID 132";
	CALL VT100_CHANGE ("[?3h");
	END;

    ["C80"]: BEGIN
	PARSE EOL;
	DOCOMMAND "TER WID 80";
	CALL VT100_CHANGE ("[?3l");
	END;

    ["KEYPAD-MODE"]: BEGIN
	PARSE KEYWORD (WORDS (
	    APPLICATION:0,
	    NUMERIC:1));
	LET KEYWD = $ATOM;
	PARSE EOL;
	SELECT KEYWD OF BEGIN
	    ["APLICATION"]:CALL VT100_CHANGE ("=");
	    ["NUMERIC"]:CALL VT100_CHANGE (">");
	    END;
	EXIT;
	END;

    ["ARROW-MODE"]: BEGIN
	PARSE KEYWORD (WORDS (
	    APPLICATION:0,
	    CURSOR:1));
	LET KEYWD = $ATOM;
	PARSE EOL;
	SELECT KEYWD OF BEGIN
	    ["APPLICATION"]:CALL VT100_CHANGE ("[?1h");
	    ["CURSOR"]:CALL VT100_CHANGE ("[?1l");
	    END;
	EXIT;
	END;

    ["SCROLL-MODE"]: BEGIN
	PARSE NOISE "style";
	PARSE KEYWORD (WORDS (
	    JUMP:0,
	    SMOOTH:1));
	LET KEYWD = $ATOM;
	PARSE EOL;
	SELECT KEYWD OF BEGIN
	    ["JUMP"]:CALL VT100_CHANGE ("[?4l");
	    ["SMOOTH"]:CALL VT100_CHANGE ("[?4h");
	    END;
	EXIT;
	END;

    ["REGION"]: BEGIN
	GUIDE "from line";
	PARSE NUMBER (HELP "Line number of top of region",DEFAULT "1");
	LET TOP = $VALUE;
	GUIDE "through line";
	PARSE NUMBER (HELP "Line number of bottom of region",DEFAULT "24");
	LET BOTTOM = $VALUE;
	PARSE EOL;
	DOCOMMAND "TER LEN " + $STRING (BOTTOM-TOP+1);
	LET IDX = TOP;
	WHILE IDX LEQ BOTTOM DO BEGIN	!Clear new region
	    CALL VT100_CHANGE ("[" + $STRING(IDX) + ";0H");
	    LET IDX = IDX + 1;
	    END;
	CALL VT100_CHANGE ("[" + $STRING(TOP) + ";" + $STRING(BOTTOM) + "r");
	CALL VT100_CHANGE ("[" + $STRING(TOP) + ";0H");
	EXIT;
	END;

    ["ANSI"]: BEGIN
	GUIDE "mode";
	PARSE EOL;
	IF $TTYPE = 15 THEN BEGIN
	    DISPLAY BINARY "<";
	    DOCOMMAND "TERMINAL VT100";
	    END;
	EXIT;
	END;

    ["VT52"]: BEGIN
	GUIDE "mode";
	PARSE EOL;
	IF $TTYPE = 16 THEN BEGIN
	    DISPLAY BINARY "[?2l";
	    DOCOMMAND "TERMINAL VT52";
	    END;
	EXIT;
	END;
    END;
END;

PROCEDURE VT100_CHANGE (STRING STR); BEGIN
EXTERNAL STRING PROCEDURE VT100_ANSIIZE;
!	DISPLAY STR;
    DISPLAY BINARY VT100_ANSIIZE(STR);
END;

!VT100_LINE(N) returns the string necessary to put the VT100 cursor at line N.
STRING PROCEDURE VT100_LINE(INTEGER N);
BEGIN
STRING X;
EXTERNAL STRING PROCEDURE VT100_ANSIIZE;
LET X =  VT100_ANSIIZE("[" + $STRING(N) + ";0H");
RETURN X;
END;

!VT100_ANSIIZE puts appropriate escape codes on strings so that they work
!regardless of whether VT100 is in ANSI or VT52 mode.
STRING PROCEDURE VT100_ANSIIZE(STRING STR);
BEGIN STRING RESULT;IF $TTYPE = 15 THEN LET RESULT = "<";
LET RESULT = RESULT + STR;IF $TTYPE = 15 THEN LET RESULT = RESULT + "[?2l";
RETURN RESULT;
END;