[comp.windows.x] XTerm Escape Sequences

ravi@mcnc.org (Ravi Subrahmanyan) (08/08/89)

	The "xterm" man pages refer to a document called "Xterm Escape
Sequences", which I cannot find anywhere.  I am looking for the
sequences which can be sent by a host  select the VT100 or the Tek
mode.  Would someone who knows the sequences please mail me either the
specific ones I'm looking for, or the list of Xterm escape sequences?
Thanks in advance,

-ravi

ps: I basicaly want the host to send the escape sequence to
switch to Tek mode, draw something on the Tek screen, and then send
the sequence to switch back to VT100 mode.

montnaro@sprite.crd.ge.com (Skip Montanaro) (09/13/89)

I rummaged around through the xterm code and came up with the following
stuff. No guarantees. I'm headed out of town for a couple days and thought
it better to get it out than let it get stale. Comments, bugs, and other
notes are welcome. Somebody else can convert it to troff. I prefer LaTeX.
:-) I will try and get to the Tek mode stuff when I return, although I doubt
it's changed much from X10 XTerm.

I gleaned the basic stuff out of the charproc.c code, by hacking VTparse()
so it spit out leaves of the parse tree. I was mildly surprised to see
things like "ESC # BEL" turn up.

For most folks, the most interesting stuff will probably be "ESC ] Ps ND
string NP" down near the bottom. That's what you use to change the icon and
window labels, and the log file name. Most other things appear the same as
the X10 documentation, although a few DEC-ish mode parameters (42, 43, 48, &
49) seem to have disappeared.

------------------------------------------------------------------------------
BEL		Bell (Ctrl-G)
BS		Backspace (Ctrl-H)
HT		Horizontal Tab (Ctrl-I)
NL		Line Feed or New Line (Ctrl-J)
VT		Vertical Tab (Ctrl-K)
NP		Form Feed or New Page (Ctrl-L)
CR		Carriage Return (Ctrl-M)
SO		Shift Out (Ctrl-N) -> Switch to Alternate Character Set
SI		Shift In (Ctrl-O) -> Switch to Standard Character Set
ESC BEL		(Same as non-escaped BEL)
ESC BS		(Same as non-escaped BS)
ESC HT		(Same as non-escaped HT)
ESC NL		(Same as non-escaped NL)
ESC VT		(Same as non-escaped VT)
ESC NP		(Same as non-escaped NP)
ESC CR		(Same as non-escaped CR)
ESC SO		(Same as non-escaped SO)
ESC SI		(Same as non-escaped SI)
ESC # BEL	(Same as non-escaped BEL)
ESC # BS	(Same as non-escaped BS)
ESC # HT	(Same as non-escaped HT)
ESC # NL	(Same as non-escaped NL)
ESC # VT	(Same as non-escaped VT)
ESC # NP	(Same as non-escaped NP)
ESC # CR	(Same as non-escaped CR)
ESC # SO	(Same as non-escaped SO)
ESC # SI	(Same as non-escaped SI)
ESC # 8		DEC Screen Alignment Test (DECALN)
ESC ( BEL	(Same as non-escaped BEL)
ESC ( BS	(Same as non-escaped BS)
ESC ( HT	(Same as non-escaped HT)
ESC ( NL	(Same as non-escaped NL)
ESC ( VT	(Same as non-escaped VT)
ESC ( NP	(Same as non-escaped NP)
ESC ( CR	(Same as non-escaped CR)
ESC ( SO	(Same as non-escaped SO)
ESC ( SI	(Same as non-escaped SI)
ESC ( C		Select G0 Character Set (SCS)
		C = 0 -> Special Character and Line Drawing Set
		C = 1 -> Alternate Character ROM Standard Set
		C = 2 -> Alternate Character ROM Special Set
		C = A -> United Kingdom (UK)
		C = B -> United States (USASCII)
ESC ) C		Select G1 Character Set (SCS)
		C takes same values as above
ESC * C		Select G2 Character Set (SCS)
		C takes same values as above
ESC + C		Select G3 Character Set (SCS)
		C takes same values as above
ESC 7		Save Cursor (DECSC)
ESC 8		Restore Cursor (DECRC)
ESC =		Application Keypad (DECPAM)
ESC >		Normal Keypad (DECNM)
ESC D		Index (IND)
ESC E		Next Line (NEL)
ESC H		Tab Set (HTS)
ESC M		Reverse Index (RI)
ESC N		Single Shift Select of G2 Character Set (SS2)
ESC O		Single Shift Select of G3 Character Set (SS3)
ESC [ BEL	(Same as non-escaped BEL)
ESC [ BS	(Same as non-escaped BS)
ESC [ HT	(Same as non-escaped HT)
ESC [ NL	(Same as non-escaped NL)
ESC [ VT	(Same as non-escaped VT)
ESC [ NP	(Same as non-escaped NP)
ESC [ CR	(Same as non-escaped CR)
ESC [ SO	(Same as non-escaped SO)
ESC [ SI	(Same as non-escaped SI)
ESC [ ? BEL	(Same as non-escaped BEL)
ESC [ ? BS	(Same as non-escaped BS)
ESC [ ? HT	(Same as non-escaped HT)
ESC [ ? NL	(Same as non-escaped NL)
ESC [ ? VT	(Same as non-escaped VT)
ESC [ ? NP	(Same as non-escaped NP)
ESC [ ? CR	(Same as non-escaped CR)
ESC [ ? SO	(Same as non-escaped SO)
ESC [ ? SI	(Same as non-escaped SI)
ESC [ ? Ps h	DEC Private Mode Set (DECSET)
		Ps = 1 -> Application Cursor Keys (DECCKM)
		Ps = 2 -> Set VT52 Mode
		Ps = 3 -> 132 Column Mode (DECCOLM)
		Ps = 4 -> Smooth (Slow) Scroll (DECSCLM)
		Ps = 5 -> Reverse Video (DECSCNM)
		Ps = 6 -> Origin Mode (DECOM)
		Ps = 7 -> Wraparound Mode (DECAWM)
		Ps = 8 -> Auto-Repeat Keys (DECARM)
		Ps = 9 -> Send MIT Mouse Row & Column on Button
			  Press
		Ps = 38 -> Enter Tektronix Mode (DECTEK)
		Ps = 40 -> Allow 80 <-> 132 Mode
		Ps = 41 -> curses(5) fix
		Ps = 44 -> Turn on Margin Bell
		Ps = 45 -> Reverse-wraparound Mode
		Ps = 46 -> Start Logging
		Ps = 47 -> Use Alternate Screen Buffer
		Ps = 1000 -> xtem bogus sequence (???)
		Ps = 1001 -> xtem sequence w/hilite tracking (???)
ESC [ ? Ps l	DEC Private Mode Reset (DECRST)
		Ps = 1 -> Normal Cursor Keys (DECCKM)
		Ps = 3 -> 80 Column Mode (DECCOLM)
		Ps = 4 -> Jump (Fast) Scroll (DECSCLM)
		Ps = 5 -> Normal Video (DECSCNM)
		Ps = 6 -> Normal Cursor Mode (DECOM)
		Ps = 7 -> No Wraparound Mode (DECAWM)
		Ps = 8 -> No Auto-Repeat Keys (DECARM)
		Ps = 9 -> Don't Send MIT Mouse Row & Column on
			  Button Press
		Ps = 40 -> Don't Allow 80 <-> 132 Mode
		Ps = 41 -> No curses(5) fix
		Ps = 44 -> Turn Off Margin Bell
		Ps = 45 -> No Reverse-wraparound Mode
		Ps = 46 -> Stop Logging
		Ps = 47 -> Use Normal Screen Buffer
		Ps = 1000 -> xtem bogus sequence (???)
		Ps = 1001 -> xtem sequence w/hilite tracking (???)
ESC [ ? Ps r	Restore DEC Private Mode
		Ps = 1 -> Normal/Application Cursor Keys (DECCKM)
		Ps = 3 -> 80/132 Column Mode (DECCOLM)
		Ps = 4 -> Jump (Fast)/Smooth (Slow) Scroll (DECSCLM)
		Ps = 5 -> Normal/Reverse Video (DECSCNM)
		Ps = 6 -> Normal/Origin  Cursor Mode (DECOM)
		Ps = 7 -> No Wraparound/Wraparound Mode (DECAWM)
		Ps = 8 -> Auto-repeat/No Auto-repeat Keys (DECARM)
		Ps = 9 -> Don't Send/Send MIT Mouse Row & Column on
			  Button Press
		Ps = 40 -> Disallow/Allow 80 <-> 132 Mode
		Ps = 41 -> Off/On curses(5) fix
		Ps = 44 -> Turn Off/On Margin Bell
		Ps = 45 -> No Reverse-wraparound/Reverse-wraparound
			   Mode 
		Ps = 46 -> Stop/Start Logging
		Ps = 47 -> Use Normal/Alternate Screen Buffer
		Ps = 1000 -> mouse bogus sequence (???)
		Ps = 1001 -> mouse bogus sequence (???)
ESC [ ? Ps s	Save DEC Private Mode
			Same P's as Restore DEC Private Mode
ESC [ Ps @	Insert Ps (Blank) Character(s) (default = 1) (ICH)
ESC [ Ps A	Cursor Up Ps Times (default = 1) (CUU)
ESC [ Ps B	Cursor Down Ps Times (default = 1) (CUD)
ESC [ Ps C	Cursor Forward Ps Times (default = 1) (CUF)
ESC [ Ps D	Cursor Backward Ps Times (default = 1) (CUB)
ESC [ Ps ; Ps H	Cursor Position [row;column] (default = [1,1]) (CUP)
ESC [ Ps J	Erase in Display
		Ps = 0 -> Clear Below (default)
		Ps = 1 -> Clear Above
		Ps = 2 -> Clear All
ESC [ Ps K	Erase in Line
		Ps = 0 -> Clear to Right (default)
		Ps = 1 -> Clear to Left
		Ps = 2 -> Clear All
ESC [ Ps L	Insert Ps lines (default = 1) (IL)
ESC [ Ps M	Delete Ps lines (default = 1) (DL)
ESC [ Ps P	Delete Ps Characters (default = 1) (DCH)
ESC [ T		Track Mouse (???)
ESC [ Ps c	Device Attributes (DA1)
ESC [ Ps ; Ps f	Cursor Position [row;column] (default = [1,1]) (HVP)
ESC [ Ps g	Tab Clear
		Ps = 0 -> Clear Current Column (default)
		Ps = 3 -> Clear All
ESC [ Ps h	Mode Set (SET)
		Ps = 4 -> Insert Mode (IRM)
		Ps = 20 -> Automatic Linefeed (LNM)
ESC [ Ps l	Mode Reset (RST)
		Ps = 4 -> Insert Mode (IRM)
		Ps = 20 -> Automatic Linefeed (LNM)
ESC [ Pm m	Character Attributes (SGR)
		Ps = 0 -> Normal (default)
		Ps = 1 -> Blink (appears as Bold)
		Ps = 4 -> Underscore
		Ps = 5 -> Bold
		Ps = 7 -> Inverse
ESC [ Ps n	Device Status Report (DSR)
		Ps = 5 -> Status Report ESC [ 0 n -> OK
		Ps = 6 -> Report Cursor Position (CPR) [row;column]
			  as ESC [ r ; c R
ESC [ Ps ; Ps r	Set Scrolling Region [top;bottom] (default = full size
		of window) (DECSTBM)
ESC [ Ps x	Request Terminal Parameters (DECREQTPARM)
ESC ] Ps ND string NP		OSC Mode
		ND can be any non-digit Character (it's discarded)
		NP can be any non-printing Character (it's discarded)
		string can be any ASCII printable string
			(max 511 characters)
		Ps = 0 -> use string as a new icon name and title
		Ps = 1 -> use string is a new icon name only
		Ps = 2 -> use string is a new title only
		Ps = 46 -> use string as a new log file name
		
ESC c		Full Reset
ESC n		Switch to Alternate Character Set LS2
ESC o		Switch to Alternate Character Set LS3
ESC |		Switch to Alternate Graphics(?) Set LS3R
ESC }		Switch to Alternate Graphics(?) Set LS2R
ESC ~		Switch to Alternate Graphics(?) Set LS1R
--
Skip Montanaro (montanaro@crdgw1.ge.com)

martin@citi.umich.edu (Martin Friedmann) (09/19/89)

In article <MONTNARO.89Sep12134443@sprite.crd.ge.com> montnaro@sprite.crd.ge.com (Skip Montanaro) writes:

>   I rummaged around through the xterm code and came up with the following
>   stuff. No guarantees.

Well so did I...  I hacked in the following escape sequences for those
who like to have secure keyboards when they type in their passwords...

set secure keyboard
	ESC ] 3 NP     (NP is a non printing character)
unset secure keyboard
	ESC ] 4 NP

*** misc.c.link Wed Jan 11 20:24:12 1989
--- misc.c      Mon Sep 18 12:52:18 1989
***************
*** 724,729 ****
--- 724,738 ----
                Changetitle(buf);
                break;

+        case 3:        /* set xterm secure mode */
+               if (!screen->grabbedKbd)
+                   xdomenufunc(0, CurrentTime);  /* XXX  constant zero! */
+               break;
+
+        case 4:
+               if (screen->grabbedKbd)
+                   xdomenufunc(0, CurrentTime);  /* XXX  constant zero! */
+               break;

         case 46:       /* new log file */
                if((cp = malloc((unsigned)strlen(buf) + 1)) == NULL)


I haven't yet completed my rlogin and telnet aliases, but they may look like
this...

alias secure 'if ($term == xterm) echo -n "^[]3^G"'
alias unsecure 'if ($term == xterm) echo -n "^[]4^G"'
alias rlogin 'secure;\rlogin'
alias telnet 'secure;\telnet'
alias ftp 'secure;\ftp'

Then...  in your .login or .cshrc on the various hosts to which you login
unsecure

This way you need not fuss with the ctrl Button1 menu each time you type your
password.  Also system administrators and modify system, or network wide
/bin/login programs and log scripts (klog) to provide these escape sequences
for users in the default case.

NOTE to the X Consortium: I didn't think too hard about *where* to put the new
escape sequences.  And wouldn't want these to stick, because they are surely
not mapped in the *correct* spot in the escape code space, and because from
looking at my modified code it isn't too cool having a 0 instead of the real
#defined XMENU_GRABKBD. But I (and ?others?)  would like to see this
functionality in the R4 xterm, because it makes the (normal persons, not the
consortiums) secure X environment much easier to use.
--

Marty.