The xterm program is a terminal emulator for the X Window System. It provides DEC VT102 and Tektronix 4014 compatible terminals for programs that can't use the window system directly. If the underlying operating system supports terminal resizing capabilities (for example, the SIGWINCH signal in systems derived from 4.3bsd), xterm will use the facilities to notify programs running in the window whenever it is resized.
But the program is much older than that.
A lot of people, cited at the bottom of the manual page wrote the original xterm program, maintained by the X Consortium (later part of the Open Group - I'm well aware of the distinction, but am citing when the work was done, not who the current owner may be). There is no changelog, and it is not clear who did what. Email from Jim Gettys provides some background:
Cast of thousands...Email from Doug Mink provides more background:To give a bit of history, xterm predates X!
It was originally written as a stand-alone terminal emulator for the VS100 by Mark Vandevoorde, as my coop student the summer that X started.
Part way through the summer, it became clear that X was more useful than trying to do a stand alone program, so I had him retarget it to X. Part of why xterm's internals are so horrifying is that it was originally intended that a single process be able to drive multiple VS100 displays. Don't hold this against Mark; it isn't his fault.
I then did a lot of hacking on it, and merged several improved versions from others back in.
Notable improvements include the proper ANSI parser, that Bob McNamara did.
The Tek 4010 support came from a guy at Smithsonian Astrophysical Observatory whose name slips my mind at the moment.
Ported to X11 by Loretta Guarino.
Then hacked on at the X Consortium by uncounted people.
I was checking out the newly revised AltaVista search engine to see what was on the net about xterm, and I found your pages. I can add to the FAQ in that I was the "guy at the Smithsonian Astrophysical Observatory" Jim Gettys refers to. I am listed at the end of the man page under authors. What happened was that I was hired by SAO (after leaving the research staff at MIT) in October 1985 to write analysis software for the Spacelab 2 Infrared Telescope which was to fly on the Space Shuttle in 1985 less than six months after I was hired. I came with a tar tape full of software I had written for Unix and Tektronix terminals, but I was presented with a VS100 terminal which had an early version (X6 or so) of xterm, with no graphics capabilities. SAO is at Harvard, across Cambridge from MIT, where Jim Gettys was detailed from DEC to the X project, and Jim had connections with SAO, having worked here after college (MIT, where we had both worked at the observatory at various times); he was still sharing an apartment with an SAO colleague of mine, too. Anyway, everyone decided that since I knew Tektronix commands pretty well, and our group desparately needed the graphics capabilities, it would be a good use of my time to implement a Tektronix terminal emulator under X. So I set to work learning more C--I had only written a couple of wrappers to C I/O routines so I could use them with my Fortran software--and wrote a Tektronix emulator. The only X documentation at the time was the code itself. While I was at it, I wrote an improved Tektronix emulator for our Imagen laser printer which used the full resolution of that 300 dpi printer instead of the effective 100 dpi (i.e. jaggy) emultator distributed with the printer. The original xterm Tek emulator shared a window with the VT100 emulator, much like on the VT240 terminals which I had been using at MIT before I came to Harvard. With a VAX 750 running several VS100's, window creation was sloowww, so sharing a window was the quickest way to do things, and all of my software was written for that mode of operation, anyway. While I wrote the emulator so that my software would work on it, it was tested by the X group against a BBN graphics package, the name of which slips my mind right now.Anyway, 15 years later, I am still using xterm and some of the same mapping software I wrote the emulator for. And I am still at the Smithsonian Astrophysical Observatory.
This FAQ is oriented toward the version of xterm distributed with XFree86, which is based on the X11R6.3 xterm, with the addition of ANSI color and VT220 controls.
Xterm
runs in all of the implementations of X11.
I've built and run these since I started working on xterm:
Most of these configurations have X11R5 libraries. Only minor changes are needed to make xterm work on those systems. However, with X11R6 you can obtain better locale support, as well as new features such as the active icon.
Ftp: ftp://invisible-island.net/xterm/xterm.tar.gz
There were for some time two versions of XFree86 xterm. Starting with my patch 88, there were the stable (beta) and unstable (alpha) versions, which currently are XFree86 3.3.6 and XFree86 4.x, respectively. I made only critical changes to the stable version since patch 88; ongoing development (including all non-critical fixes) was focused on the "unstable".
XFree86 4.0 should have incorporated my patch 131, but it was overlooked at the last moment (though it was listed in the ChangeLog, the patch itself was not applied). Unfortunately, the patch 130 version which was released renders colors incorrectly on most platforms, in particular FreeBSD. Ironically, the change in patch 129 which introduced this bug was designed to work around a bug which I have seen only running with FreeBSD. To compound the irony, there was some resistance at the time (2000/4/5) by that organization to incorporating the fix because it might be confused with the 4.0 release version.
X Consortium xterm provides popup menus, by pressing the control key together with the mouse button. Control right mouse button pops up the VT FONTS menu, from which you can select fonts that are specified in xterm's resources. Usually these are in increasing order of size.
XFree86 xterm provides the menu, plus a feature adapted from rxvt: pressing the shifted keypad plus or minus keys steps through the font menu selections, in order of their size.
If you want a trace of an interactive session, you should use the
script program. It records every character sent to the
screen, recording them in a file typescript
.
There are two drawbacks to this approach:
typescript
file.
If you want to print the contents of the screen, XFree86 xterm implements, as part of the VT100 emulation, an "attached" printer.
printAttributes
to get
more easily printed output.
printerAutoClose
resource to change
xterm's behavior to close the printer pipe whenever the terminal
is told to switch the printer offline.
With X Consortium xterm, you have partial support for DEC VTxxx function keys. Function keys F1 to F12 correspond to DEC's F1 to F12 (sort of). Actually, DEC's VT220 terminals do not have codes for F1 through F5. They are reserved for local functions. And the VT220 (and up) terminals have 20 function keys. So you cannot do anything with the F13 through F20 (i.e., DO, HELP and SELECT). Finally, though xterm is reputed to be VT100-compatible, it has no support for the VT100 keypad (PF1 to PF4, and the "," key).
XFree86 xterm changes the X Consortium codes for F1 to F4 to match the
VT100 PF1 to PF4, except when the emulation level is VT220 and up.
In this case, it generates the same F1 to F4 codes as X Consortium xterm.
Moreover, it adds a new resource sunKeyboard
, which
tells the program whether it has only 12 function keys (i.e., a Sun or PC
keyboard).
If so (this is selectable from the popup menu), you can use the control key
with F1 to F12 to get F13 to F24, and use the "+" key on the keypad as an
alias for "," (comma).
The emulation level for XFree86 xterm is set via the resource
decTerminalID
, e.g., to 220 for a VT220.
Once set, applications can set the emulation level up or down within that
limit. DEC's terminals are configured in much the same way by a setup
option.
That is the simple way, using a couple of new resources. The traditional way to get function keys involves translations. I have seen a few postings on the newsgroups that do this. Here is one from Bruce Momjian <root@candle.pha.pa.us> for a VT220:
xterm $XTERMFLAGS +rw +sb +ls $@ -tm 'erase ^? intr ^c' \
-name vt220 -title vt220 -tn xterm-220 "$@" &
with the corresponding resources:
XTerm*VT100.translations: #override \n\
<Key>Home: string(0x1b) string("[3~") \n \
<Key>End: string(0x1b) string("[4~") \n
vt220*VT100.translations: #override \n\
~Shift <Key>F1: string(0x1b) string("OP") \n \
~Shift <Key>F2: string(0x1b) string("OQ") \n \
~Shift <Key>F3: string(0x1b) string("OR") \n \
~Shift <Key>F4: string(0x1b) string("OS") \n \
~Shift <Key>F5: string(0x1b) string("[16~") \n \
~Shift <Key>F6: string(0x1b) string("[17~") \n \
~Shift <Key>F7: string(0x1b) string("[18~") \n \
~Shift <Key>F8: string(0x1b) string("[19~") \n \
~Shift <Key>F9: string(0x1b) string("[20~") \n \
~Shift <Key>F10: string(0x1b) string("[21~") \n \
~Shift <Key>F11: string(0x1b) string("[28~") \n \
~Shift <Key>F12: string(0x1b) string("[29~") \n \
Shift <Key>F1: string(0x1b) string("[23~") \n \
Shift <Key>F2: string(0x1b) string("[24~") \n \
Shift <Key>F3: string(0x1b) string("[25~") \n \
Shift <Key>F4: string(0x1b) string("[26~") \n \
Shift <Key>F5: string(0x1b) string("[K~") \n \
Shift <Key>F6: string(0x1b) string("[31~") \n \
Shift <Key>F7: string(0x1b) string("[31~") \n \
Shift <Key>F8: string(0x1b) string("[32~") \n \
Shift <Key>F9: string(0x1b) string("[33~") \n \
Shift <Key>F10: string(0x1b) string("[34~") \n \
Shift <Key>F11: string(0x1b) string("[28~") \n \
Shift <Key>F12: string(0x1b) string("[29~") \n \
<Key>Print: string(0x1b) string("[32~") \n\
<Key>Cancel: string(0x1b) string("[33~") \n\
<Key>Pause: string(0x1b) string("[34~") \n\
<Key>Insert: string(0x1b) string("[2~") \n\
<Key>Delete: string(0x1b) string("[3~") \n\
<Key>Home: string(0x1b) string("[1~") \n\
<Key>End: string(0x1b) string("[4~") \n\
<Key>Prior: string(0x1b) string("[5~") \n\
<Key>Next: string(0x1b) string("[6~") \n\
<Key>BackSpace: string(0x7f) \n\
<Key>Num_Lock: string(0x1b) string("OP") \n\
<Key>KP_Divide: string(0x1b) string("Ol") \n\
<Key>KP_Multiply: string(0x1b) string("Om") \n\
<Key>KP_Subtract: string(0x1b) string("OS") \n\
<Key>KP_Add: string(0x1b) string("OM") \n\
<Key>KP_Enter: string(0x1b) string("OM") \n\
<Key>KP_Decimal: string(0x1b) string("On") \n\
<Key>KP_0: string(0x1b) string("Op") \n\
<Key>KP_1: string(0x1b) string("Oq") \n\
<Key>KP_2: string(0x1b) string("Or") \n\
<Key>KP_3: string(0x1b) string("Os") \n\
<Key>KP_4: string(0x1b) string("Ot") \n\
<Key>KP_5: string(0x1b) string("Ou") \n\
<Key>KP_6: string(0x1b) string("Ov") \n\
<Key>KP_7: string(0x1b) string("Ow") \n\
<Key>KP_8: string(0x1b) string("Ox") \n\
<Key>KP_9: string(0x1b) string("Oy") \n
! <Key>Up: string(0x1b) string("[A") \n\
! <Key>Down: string(0x1b) string("[B") \n\
! <Key>Right: string(0x1b) string("[C") \n\
! <Key>Left: string(0x1b) string("[D") \n\
*visualBell: true
*saveLines: 1000
*cursesemul: true
*scrollKey: true
*scrollBar: true
Note that real VT220 terminals use shifted function keys to mean something
different: the user-programmable keys (i.e., DECUDK). XFree86 xterm
supports this, but the translations do not (they're using shift to select
F13 to F20).
Here's another one, from Robert Ess <ress@spd.dsccc.com>:
#!/bin/sh
# vax
# 09-17-96 Bob Ess - initial creation
# 09-26-96 Shig Katada - Additional keybindings
#
# Script file to incorporate keybindings and command line
# options for connecting to a VAX node
# Usage statement
Usage(){
echo
echo " Usage : vax -options"
echo
echo " Options: -80 for 80 column terminal"
echo " -132 for 132 column terminal"
echo " -fg colorname"
echo " -bg colorname"
echo " -fn fontname"
echo " -fb bold fontname"
echo " -host [altair] [devel] [leonis] [castor]"
echo ""
echo " Example: \"vax -80 -fg white -bg black -fn 9x15 -fb 9x15b -host castor\""
echo " Starts a VAX session with an 80 column terminal"
echo " with a black background, white foreground, a normal"
echo " font of 9x15 and a bold font of 9x15b, and connects"
echo " to the node 'castor'"
echo
echo " If you need additional help, please call Workstation"
echo " Services at x92396."
echo
exit 1
}
# Default to a black foreground with a white background.
# Use the 9x15 and 9x15bold fonts. Connect to castor by default.
#
FG=black
BG=white
HOST=castor
FONT=9x15
BFONT=9x15bold
COLS=80
# Parse the command line arguments
#
while [ $# != 0 ];
do
case $1 in
-80) COLS=80
FONT=spc12x24c
BFONT=spc12x24b
shift
;;
-132) COLS=132
FONT=9x15
BFONT=9x15b
shift
;;
-fg) shift
FG=$1
shift;;
-bg) shift
BG=$1
shift;;
-fn) shift
FONT=$1
shift;;
-fb) shift
BFONT=$1
shift;;
-host) shift
HOST=$1
shift;;
-help) Usage;;
*) Usage;;
esac
done
xterm -title "VAX" -sb -sl 1200 -geo ${COLS}x24 -fg ${FG} -bg ${BG} \
-cr red -fn ${FONT} -fb ${BFONT} -xrm \
'XTerm*VT100.translations: #override \n\
<Key>Insert: string(\001) \n\
Shift <Key>Up: scroll-back(1,lines) \n\
Shift <Key>Down: scroll-forw(1,lines) \n\
Shift <Key>Right: string(0x1b) string("f") \n\
Shift <Key>Left: string(0x1b) string("b") \n\
Shift <Key>Delete: string(0x1b) string(0x08) \n\
Shift <Key>Tab: string(0x1b) string("*") \n\
<Key>0x1000FF0D: scroll-back(1,page) \n\
<Key>0x1000FF0E: scroll-forw(1,page) \n\
<Key>0x1000FF09: string(\010) \n\
<Key>0x1000FF0A: string(\005) \n\
<Key>BackSpace: string(0xff) \n\
<Key>Select: select-start() \n\
<Key>0x1000FF02: select-end(PRIMARY,CUT_BUFFER0) \n\
Meta <Key>0x1000FF02: select-end(CLIPBOARD) \n\
<Key>0x1000FF04: insert-selection(PRIMARY,CUT_BUFFER0) \n\
Meta <Key>0x1000FF04: insert-selection(CLIPBOARD) \n\
<Key>F1: string(0x1b) string("OP") \n\
<Key>F2: string(0x1b) string("OQ") \n\
<Key>F3: string(0x1b) string("OR") \n\
<Key>F4: string(0x1b) string("OS") \n\
<Key>F5: string(0x1b) string("OA") \n\
<Key>F11: string(0x1b) string("[23~") \n\
<Key>F12: string(0x1b) string("[24~") \n\
<Key>KP_0: string(0x1b) string("Op") \n\
<Key>KP_1: string(0x1b) string("Oq") \n\
<Key>KP_2: string(0x1b) string("Or") \n\
<Key>KP_3: string(0x1b) string("Os") \n\
<Key>KP_4: string(0x1b) string("Ot") \n\
<Key>KP_5: string(0x1b) string("Ou") \n\
<Key>KP_Divide: string(0x1b) string("OP") \n\
<Key>KP_Multiply: string(0x1b) string("[29~") \n\
<Key>KP_Enter: string(0x1b) string("OM") \n\
<Key>KP_Subtract: string(0x1b) string("Om") \n\
<Key>KP_Add: string(0x1b) string("Ol") \n\
<Key>KP_Decimal: string(0x1b) string("On") \n\
<Btn1Down>: select-start() \n\
<Btn1Motion>: select-extend() \n\
<Btn1Up>: select-end(PRIMARY,CUT_BUFFER0) \n\
Button1<Btn2Down>: select-end(CLIPBOARD) \n\
Button1<Btn2Up>: ignore()' \
-e telnet $HOST &
Finally (for the moment) is a further modification of Robert Ess's script
by Erik Ahlefeldt,
<oahlefel@metz.une.edu.au>.
From his readme file, for vmsterm:
This script is for people who wish to connect from a Linux or Unix computer to a VMS computer using telnet and get a good VT100 or VT220 emulation. The key mappings have been specifically designed to emulate the VT terminal auxiliary numeric keypad, so that you can use VMS EDT and TPU editors, as well as the many VMS applications use keys PF1 to PF4. The script should work with any recent version of Xterm using a standard extended IBM PC keyboard or a Sun keyboard.a summary of the keyboard mapping:About the keymappings. First the auxiliary numeric keypad. My prime objective with these mappings was to produce a setup that I could use with the EDT and TPU editors which make extensive use of the numeric keypad. The top row of keys PC numeric keypad (Num Lock, Divide, Multiply, Subtract) are where you find PF1, PF2, PF3, PF4 on a VT keyboard, so I have mapped them to PF1 thru PF4. The PC numeric keypad Add key (+) takes up the space of two keys which are Minus and Comma on the VT keyboard - I have mapped it to Comma (Delete Character in the EDT editor). I have then used the PC Pause key to map to VT key Minus (Delete Word in the EDT editor). The remaining keys on the auxiliary numeric keypad are the same for PC and VT.
The six keys between the main and numeric keypads on the PC (Insert, Home, Page Up, Delete End, Page Down) are usually mapped to the VT keys by either position or by (approximate) function. As I rarely use these keys I have mapped them by function as follows: PC key Insert to VT Insert Here, PC Home to VT Find, PC Page Up to VT Prev, PC Delete to VT Remove, PC End to VT Select, PC Page Down to VT Next.
- Function keys.
- There are 12 function keys on the PC keyboard and 20 on the VT keyboard, so I map PC F1 thru F12 to VT F1 thru F12 (except for F1 thru F5 as noted below) and PC Shift F1 thru Shift F10 to VT F11 thru F20.
The VT keys F1 thru F5 are local hardware function keys so there is nothing to emulate, however some PC to VT emulations in the past have mapped PF1 thru PF4 here, so I have done that too, even though they are already mapped on the auxiliary numeric keypad.
- Xterm functionality.
- You lose some xterm functions when you remap the keyboard, however this script implements a scroll back buffer of 1000 lines which you scroll through using Shift and Up (a.k.a. Up Arrow or Cursor Up key) or Shift and Down.
PC Key maps to VT Key. ------ ------ F1 PF1 F2 PF2 F3 PF3 F4 PF4 F5 unused F6 F6 F7 F7 F8 F8 F9 F9 F10 F10 F11 F11 F12 F12 Shift F1 F11 Shift F2 F12 Shift F3 F13 Shift F4 F14 Shift F5 F15 (Help) Shift F6 F16 (Do) Shift F7 F17 Shift F8 F18 Shift F9 F19 Shift F10 F20 Shift F11 F11 Shift F12 F12 Print Help (F15) Cancel Do (F16) Pause Keypad Minus Insert Insert Here Delete Remove Home Find End Select Prior Prev Next Next BackSpace BackSpace (sends DEL - ascii 127) Num_Lock PF1 KP_Divide PF2 KP_Multiply PF3 KP_Subtract PF4 KP_Add Keypad Comma KP_Enter Enter KP_Decimal Period KP_0 Keypad 0 KP_1 Keypad 1 KP_2 Keypad 2 KP_3 Keypad 3 KP_4 Keypad 4 KP_5 Keypad 5 KP_6 Keypad 6 KP_7 Keypad 7 KP_8 Keypad 8 KP_9 Keypad 9 Up Up Shift Up Scroll Back Down Down Shift Down Scroll Forward Right Right Left Leftand the script:
#!/bin/sh
# vmsterm
# from an original script by Bob Ess
# key translations by Erik Ahlefeldt
#
# Script file using Xterm and telnet to connect to a VMS host
# and give a decent vt220 emulation.
#
# Usage statement
Usage(){
echo
echo " Usage : vmsterm -options"
echo
echo " Options: -80 for 80 column terminal"
echo " -132 for 132 column terminal"
echo " -bg colorname"
echo " -fg colorname"
echo " -fn fontname"
echo " -fb bold fontname"
echo " -host [crusher.saltmine.com] [earth] [192.168.7.7]"
echo ""
echo " Example: \"vmsterm -80 -fg white -bg black -fn 9x15 -fb 9x15b -host earth\""
echo " Starts a VMS session with an 80 column terminal"
echo " with a black background, white foreground, a normal"
echo " font of 9x15 and a bold font of 9x15b, and connects"
echo " to the node 'earth'"
echo ""
echo " Example: \"vmsterm -host earth\""
echo " Starts a VMS session with default terminal settings "
echo ""
echo " Example: \"vmsterm -help\""
echo " Displays vmsterm options "
echo
exit 1
}
# Default to a black foreground with a white background.
# Use the 9x15 and 9x15bold fonts. Connect to 192.168.3.3 by default.
#
FG=black
BG=white
HOST=192.168.3.3
FONT=9x15
BFONT=9x15bold
COLS=80
# Parse the command line arguments
#
while [ $# != 0 ];
do
case $1 in
-80) COLS=80
FONT=spc12x24c
BFONT=spc12x24b
shift
;;
-132) COLS=132
FONT=9x15
BFONT=9x15b
shift
;;
-fg) shift
FG=$1
shift;;
-bg) shift
BG=$1
shift;;
-fn) shift
FONT=$1
shift;;
-fb) shift
BFONT=$1
shift;;
-host) shift
HOST=$1
shift;;
-help) Usage;;
*) Usage;;
esac
done
xterm -title "VMSTERM" -sb -sl 1000 -geo ${COLS}x24 -fg ${FG} -bg ${BG} \
-cr blue -fn ${FONT} -fb ${BFONT} -xrm \
'XTerm*VT100.translations: #override \n \
~Shift <Key>F1: string(0x1b) string("OP") \n \
~Shift <Key>F2: string(0x1b) string("OQ") \n \
~Shift <Key>F3: string(0x1b) string("OR") \n \
~Shift <Key>F4: string(0x1b) string("OS") \n \
~Shift <Key>F5: string("Break") \n \
~Shift <Key>F6: string(0x1b) string("[17~") \n \
~Shift <Key>F7: string(0x1b) string("[18~") \n \
~Shift <Key>F8: string(0x1b) string("[19~") \n \
~Shift <Key>F9: string(0x1b) string("[20~") \n \
~Shift <Key>F10: string(0x1b) string("[21~") \n \
~Shift <Key>F11: string(0x1b) string("[23~") \n \
~Shift <Key>F12: string(0x1b) string("[24~") \n \
Shift <Key>F1: string(0x1b) string("[23~") \n \
Shift <Key>F2: string(0x1b) string("[24~") \n \
Shift <Key>F3: string(0x1b) string("[25~") \n \
Shift <Key>F4: string(0x1b) string("[26~") \n \
Shift <Key>F5: string(0x1b) string("[28~") \n \
Shift <Key>F6: string(0x1b) string("[29~") \n \
Shift <Key>F7: string(0x1b) string("[31~") \n \
Shift <Key>F8: string(0x1b) string("[32~") \n \
Shift <Key>F9: string(0x1b) string("[33~") \n \
Shift <Key>F10: string(0x1b) string("[34~") \n \
Shift <Key>F11: string(0x1b) string("[28~") \n \
Shift <Key>F12: string(0x1b) string("[29~") \n \
<Key>Print: string(0x1b) string("[28~") \n \
<Key>Cancel: string(0x1b) string("[29~") \n \
<Key>Pause: string(0x1b) string("Om") \n \
<Key>Insert: string(0x1b) string("[2~") \n \
<Key>Delete: string(0x1b) string("[3~") \n \
<Key>Home: string(0x1b) string("[1~") \n \
<Key>End: string(0x1b) string("[4~") \n \
<Key>Prior: string(0x1b) string("[5~") \n \
<Key>Next: string(0x1b) string("[6~") \n \
<Key>BackSpace: string(0x7f) \n \
<Key>Num_Lock: string(0x1b) string("OP") \n \
<Key>KP_Divide: string(0x1b) string("OQ") \n \
<Key>KP_Multiply: string(0x1b) string("OR") \n \
<Key>KP_Subtract: string(0x1b) string("OS") \n \
<Key>KP_Add: string(0x1b) string("Ol") \n \
<Key>KP_Enter: string(0x1b) string("OM") \n \
<Key>KP_Decimal: string(0x1b) string("On") \n \
<Key>KP_0: string(0x1b) string("Op") \n \
<Key>KP_1: string(0x1b) string("Oq") \n \
<Key>KP_2: string(0x1b) string("Or") \n \
<Key>KP_3: string(0x1b) string("Os") \n \
<Key>KP_4: string(0x1b) string("Ot") \n \
<Key>KP_5: string(0x1b) string("Ou") \n \
<Key>KP_6: string(0x1b) string("Ov") \n \
<Key>KP_7: string(0x1b) string("Ow") \n \
<Key>KP_8: string(0x1b) string("Ox") \n \
<Key>KP_9: string(0x1b) string("Oy") \n \
~Shift <Key>Up: string(0x1b) string("[A") \n \
Shift <Key>Up: scroll-back(1,lines) \n \
~Shift <Key>Down: string(0x1b) string("[B") \n \
Shift <Key>Down: scroll-forw(1,lines) \n \
<Key>Right: string(0x1b) string("[C") \n \
<Key>Left: string(0x1b) string("[D")' \
-e telnet $HOST
The usual context for this question is setting the title according to the current working directory. People post answers to this periodically on the newsgroups. Here is one that I have seen, from Roy Wright <nobody@roystoy.dseg.ti.com>. In your /etc/profile after:
if [ "$SHELL" = "/bin/pdksh" -o "$SHELL" = "/bin/ksh" ]; then
PS1="! $ "
elif [ "$SHELL" = "/bin/zsh" ]; then
PS1="%m:%~%# "
elif [ "$SHELL" = "/bin/ash" ]; then
PS1="$ "
else
PS1='\u@\h:\w\$ '
fi
add:
if [ "$TERM" = "xterm" ]; then
PS1="\033]2;\u@\h:\w\007bash$ "
fi
The terminator "\007" is a problem area. Xterm historically uses this character, though it is non-ANSI. The "correct" character should be a "\233" string terminator, or "\033\\", which is the 7-bit equivalent. XFree86 xterm recognizes either (the "\007" or string terminator); waiting for the first of these.
You may have resource or environment problems that prevent you from setting the title at all. Newer xterms (starting somewhere in X11R5) use the $LANG variable. If your locale is incorrectly installed, you will be unable to set the xterm's title. As noted by Mikhail Teterin <mi@rtfm.ziplink.net>: Make sure that the locale (LANG and/or LOCALE environment variable) is known to X Window System. Check ${X11ROOT}/lib/X11/locale.* for it. If it is not listed in either one of the files, find the nearest match and add an alias to it. Restart X if you have made changes.
On a related note, some people want to know how to read the title from an xterm. This works for XFree86 xterm and dtterm, but not for other variations:
#!/bin/ksh
# Echo the current X term title bar to standard output.
# Written by Icarus Sparry <icarus@bath.ac.uk> 11 Apr 1997
#
exec </dev/tty
old=$(stty -g)
stty raw -echo min 0 time ${1-10}
print "\033[21t\c" > /dev/tty
IFS='' read -r a
stty $old
b=${a#???}
print -R "${b%??}"
But it is possible to avoid escape sequences altogether (from
Hemant Shah <shah@typhoon.xnet.com>):
$ xprop -id $WINDOWID | grep WM_NAME
WM_NAME(STRING) = "this is my title"
current_title=$(xprop -id $WINDOWID | grep WM_NAME | cut -d= -f2)
Here's another source of information:
Xterm-Title HowTo
XFree86 xterm can form its own line-drawing characters (see patch 90, for example). It does not draw all of the graphic characters, only those that may be done with straight lines. But those are the most used, making most of the fixed-pitch fonts useful for xterm.
You may also have a problem with the terminfo description. As distributed, the X11R6 terminfo for xterm does not have the acsc string defined, so most implementations of curses do not try to use the alternate character set.
Finally, some people confuse the VT100 graphic characters with the VT220 support for DEC technical character set. These are distinct (7-bit) character sets. Xterm currently does not support this.
FontPath "/usr/lib/X11/fonts/100dpi/:unscaled"
FontPath "/usr/lib/X11/fonts/75dpi/:unscaled"
FontPath "/usr/lib/X11/fonts/misc/:unscaled"
Standard xterm has a "normal" font for which a bold font can be chosen, and several alternative fonts, useful for changing the font size. The alternative fonts do not have corresponding bold fonts. Xterm simulates bold fonts in this case by overstriking the character one pixel offset. That can make an bold character extend into the area that another character occupies. When erasing a bold character from the screen, xterm does not erase the extra pixel. This is corrected in XFree86 xterm, subject to the available fonts (from late 1998, patch 85). For each font, it asks the font server for a corresponding bold font. Your font server may not have the bold font (or it may incorrectly report that it does). But it usually works.
-k8
)
and corresponding resource settings to allow them to customize their
environment.
Here is a
sample script and
resource file which
I use for testing this configuration.
Even if you set the resources properly, there may be another application running which prevents xterm from allocating the colors you have specified. But you should see a warning message for this.
Check the terminal description, to see if it is installed properly, e.g., for ncurses, which uses terminfo.
Finally, some applications (that do not interface properly with terminfo or termcap) may need the environment variable $COLORTERM to be set.
stty -a
shows the rows and/or columns values as 0, or some other value (such as 65)
which has nothing to do with the actual window size.
You may be able to use the resize program to issue the ioctl's that will notify your application of the actual screen size. This does not always work for the reasons just mentioned. Newer versions of stty let you specify the screen size, though it will not be updated if you resize the xterm window:
stty rows 24 columns 80
Most full-screen applications also
check if the $LINES and $COLUMNS variables are set, using those values to
override the terminal description:
setenv LINES 24
setenv COLUMNS 80
Why 65 lines? The standard xterm terminfo description specifies 65 lines,
perhaps because someone liked it that way. Real VT100's are 24 lines.
I once used (and wrote applications for) a Bitgraph terminal, which
emulated VT100, but displayed 65 lines.
You can override this by specifying your own translations in your resource file. Use the translations in
/usr/lib/X11/app-defaults/XTerm
as a guide.
The relevant section of the app-default file looks like
*VT100.translations: #override \
@Num_Lock<Key>KP_0: string(0)\n\
@Num_Lock<Key>KP_1: string(1)\n\
@Num_Lock<Key>KP_2: string(2)\n\
@Num_Lock<Key>KP_3: string(3)\n\
@Num_Lock<Key>KP_4: string(4)\n\
@Num_Lock<Key>KP_5: string(5)\n\
@Num_Lock<Key>KP_6: string(6)\n\
@Num_Lock<Key>KP_7: string(7)\n\
@Num_Lock<Key>KP_8: string(8)\n\
@Num_Lock<Key>KP_9: string(9)\n\
@Num_Lock<Key>KP_Add: string(+)\n\
@Num_Lock<Key>KP_Decimal: string(.)\n\
@Num_Lock<Key>KP_Divide: string(/)\n\
@Num_Lock<Key>KP_Enter: string(\015)\n\
@Num_Lock<Key>KP_Equal: string(=)\n\
@Num_Lock<Key>KP_Multiply: string(*)\n\
@Num_Lock<Key>KP_Subtract: string(-)\n\
<Key>Prior:scroll-back(1,page)\n\
<Key>Next:scroll-forw(1,page)\n\
<Key>F16: start-extend() select-end(PRIMARY, CUT_BUFFER0, CLIPBOARD) \n\
<Key>F18: insert-selection(PRIMARY, CLIPBOARD) \n\
<Key>F27: scroll-back(100,page) \n\
<Key>R13: scroll-forw(100,page) \n\
<Key>Home: scroll-back(100,page) \n\
<Key>End: scroll-forw(100,page) \n
For example, a more-specific pattern for the resource name lets you override:
XTerm*VT100.translations: #override \n\
~Shift<Key>Home: string(\033[1~)\n\
~Shift<Key>End: string(\033[4~)\n\
~Shift<Key>Prior: string(\033[5~)\n\
~Shift<Key>Next: string(\033[6~)\n\
Shift<Key>Prior: scroll-back(1,page) \n\
Shift<Key>Next: scroll-forw(1,page) \n\
Shift<Key>Home: scroll-back(100,page) \n\
Shift<Key>End: scroll-forw(100,page) \n
makes the home/end and pageup/pagedown keys usable by your editor,
while leaving their shifted equivalents available for the scrollbar.
At the beginning, when the home/end keys were fixed for XFree86 xterm (in early 1996), there was some discussion regarding what the escape sequences should be for those keys (for the 6-key editing keypad). Those were chosen as "PC-style" codes (like SCO "ansi"), i.e.,
ESC [ H ESC [ Ffor normal mode, and
ESC O H ESC O Ffor cursor application mode.
That style of coding fit easily into the existing logic of xterm. It was not my change, and (because xterm should be based upon standards), I did question this, and asked the opinion of the person who was at that time developing rxvt. He had chosen a layout based on DEC's VT220 terminals, though the key labels on the typical PC keyboard did not match. At that point, neither of us knew enough to make a good case for this.
Somewhat later I could see that xterm had a number of undocumented extensions to support the VT220-style (pre-ISO 2022) character sets. I decided to complete the functionality by making xterm a VT220 emulator. This would require that it provide the same escape sequences for the editing and numeric keypads. I could not simply change the escape sequences from "PC-style" to "VT220-style", since a number of users "knew" that the keypad "ought to" send home, end, cursor keys, etc., because they had labels indicating that use. To retain compatibility (but allow easy reconfiguration to make a VT220 emulator), I added popup-menu items to switch between the modes. With minor refinements, this was the approach for about two years, culminating with the "stable" patch #88, which is essentially the version distributed with XFree86 3.3.x.
*sunKeyboard: true
Downstream packagers (when they noticed this)
accommodated the bug by modifying the VT100 translations
resource which is not a good technical solution since it interferes with
the users' ability to modify that resource.
See this for more discussion.
xkb
with X11R6 interfered with
xterm's use of the NumLock key for the numeric keypad.
sunKeyboard
resource.
Partway through that, I was asked to do similar cleanup and redesign of
the backspace and delete key handling, e.g.,
the ptyInitialErase resource.
Because it is a redesign, I chose to not make the keyboard differences
between the old and new xterms completely compatible.
If you were to run both on the same system, one or the other would have
some problems with the editing keypad or the backspace/delete keys
which would be addressed by the popup-menu selections.
For example, at this time (2001/9/4):
kbs
from ^H
to ^?
.
As noted, the terminfo I wrote for XFree86 3.3.x has an error.
Setting
*sunKeyboard: true
in the app-defaults file fixes the problem with xterm-88, which was that I
documented in the terminfo the behavior with that resource set.
Similarly, setting
*backarrowKey: false
is one way to address Debian's change to kbs
.
VTxxx terminals are usually set up so that full-screen applications will use the cursor application mode strings. This is good for full-screen applications, including legacy applications which may have hard-coded behavior, but bad for interactive shells (e.g., ksh, tcsh, bash) which use arrow keys to scroll through a history of command strings.
To see the difference between normal/application modes, consider this example:
Depending on the terminal type,
the keypad(s) on the keyboard may switch modes along with the
cursor keys, or have their own independent modes.
The control sequences for these are independent of the ones used for
cursor-addressing, but are grouped together, e.g., as the
terminfo smkx
and rmkx
capabilities.
Terminfo entries are written assuming that the application has initialized
the terminal using the smkx
string before it is able to
match the codes given for the cursor or keypad keys.
$PATH
and $LD_LIBRARY_PATH
, since
they affect the choice of which programs are run if not specified via a
full pathname.
This means, for example, that if you attempt to run
xterm -e foo
where foo
is a program that uses shared libraries in
/usr/local/lib
, then the command will fail, because
/usr/local/lib
is not considered part of root
's
environment.
Modern Unix systems (such as recent Solaris and HPUX versions) do not require you to run xterm setuid. Some will result in odd malfunctions if you do this.
.login
file, for instance.
-e
, and if that fails for
whatever reason will fall through to the -ls
option.
It cannot (in general) combine the two, since some shells permit this
(e.g., bash), and others do not (e.g., tcsh).
A workaround is to copy /usr/X11R6/lib/X11/etc/xterm.termcap to /etc/termcap.
This is fixed another way starting with XFree86 3.3.1. If xterm cannot find the terminal description, it will accept that, though it will print a warning. If xterm does not find the termcap entry, it will not set the $TERMCAP variable.
# ls -l /dev/ptmx
crw-rw---- 1 root tty 5, 2 Aug 21 20:19 /dev/ptmx
Perhaps your system does not have enough pty's, or (problems
reported with newer Linux kernels supporting Unix98 pty's,
beginning with RedHat 6.0) the major device
numbers of the pty's may have changed during a kernel upgrade.
(This is described in /usr/src/linux/Documentation
).
See also the MAKEDEV script, which usually exists under /dev.
This may be due to incompatible terminal descriptions for xterm. With XFree86 3.2, I modified the terminal description for XFree86 xterm to use the VT220 (aka ISO 6429) controls that allow an application to turn off highlighting (or bold, underline) without modifying the other attributes. The X Consortium xterm does not recognize these controls.
If, for example, you are running an older xterm and rlogin to a system
where the newer xterm has been installed, you will have this problem,
because both programs default to $TERM set to xterm.
The solution for mixed systems is to install the newer terminal description as
as a different name (e.g., xterm-color
)
and set the termName
resource accordingly in the app-defaults file for the system which has the
newer xterm.
However - see below.
vim
users may notice their colors change after
updating to patch 238.
Before, some text would display in a dark color using a bold font.
Now, it displays in a bright color and normal font.
This is not a bug, but the result of a feature tcap-query which was added for vim in 2000. Several vim users requested that it be enabled by default in the configure script. It allows vim to ask what characters the different function keys actually send, eliminating the chance that the termcap does not match.
Vim also asks how many colors the terminal supports. Since patch 148, xterm has responded with the number of distinct colors that it can display. By default, that is 16 (8 ANSI colors with bright counterparts for displaying PC-style "bold" text).
The interpretation of this depends on the application: termcaps do not tell how to display more than 8 colors. But vim understands how to tell xterm to display using 16 colors. It makes a difference when displaying bright colors. Vim has a table of 16 color names ("dos-colors"), which one can use to define parts of the color scheme. If the terminal supports only 8 colors (colors 0-7), vim uses the bold attribute to simulate colors 8-15.
Changing the color scheme to use bold where it is wanted will make the colors work as before – and work consistently with other terminals.
The xterm-color
value for $TERM
is a bad choice for XFree86 xterm because it is
commonly used for a terminfo entry which happens to not support bce
.
Complicating matters, FreeBSD (after dithering for a few years on the matter)
introduced a bastardized version which implies the opposite sense of bce
,
(because it uses SGR 39 and 49), but does not set it.
The most recent version
provides the xterm-xfree86
entry which is distributed with
XFree86 xterm (which corresponds to the one distributed with ncurses).
The term "bce
" stands for "back color erase".
Terminals such as XFree86 xterm
and rxvt implement back color erase, others such as dtterm do not.
(Roughly half of the emulators that I know about implement bce).
When an application clears the screen, a terminal that implements back
color erase will retain the last-set background color. A terminal
that does not implement back color erase will reset the background color
to the default or initial colors. Applications that paint most of the
screen in a single color are more efficient on terminals that support
back color erase.
Curses libraries that support color know about bce
and do the
right thing - provided that you tell them what the terminal does.
That is the whole point of setting $TERM.
The "xterm-color" description distributed with ncurses does not list
bce
, because it was applied originally to a terminal type
which does
not implement back color erase.
It will "work" for XFree86 xterm,
though less efficient. Some other applications such as the slang library
have hardcoded support for terminals that implement back color erase.
Given the "xterm-color" description, those will be efficient - and
fortuitously work. However, slang (through version 1.4.0) does not
work properly for the terminals that xterm-color was designed for.
See this page for an example
of (n)curses and slang running on dtterm.
That bug in slang is reported to be fixed for succeeding versions, though
your application may require changes to use this fix.
(The demo which comes with slang to illustrate the use of bce
does not work properly, for instance).
The xterm-color
value for $TERM
is also (for the same reason) a bad choice for rxvt, but
"works" due to the large number of hard-coded applications that override
this.
Some people recommend using xtermc
.
That is installed on Solaris.
However, it does not match any xterm in current use.
(Apparently it was written for an obsolete version on Unixware).
The colors work, true, but the mouse will not, nor will the function keys.
When I change font size often I will get the double-refresh, and when that happens the text program gets 2 resize events.. Running a quick test, I got this: Going to a bigger font, it got a 53x20 resize, then a 80x24 resize. Going to a smaller font, it got a 120x27 resize, then a 80x24 resize.
Earlier I made a mention of changing font size in rxvt (And xterm does it to) causing 2 resize events. Well I just happened to do it in fvwm (Instead of fvwm 95) and found it seems to be a 'feature' of fvwm95, not XFree86 as I'd initially assumed.
Using the XFree86 xterm-53 with the active icon feature on, I get some problems resizing where the xterm window shrinks as small as possible and won't stay at whatever size you set it thereafter.
Comment out the PixmapPath and IconPath from your .fvwmrc file to disable the fvwm icons and restart the WM. Start an xterm. Iconify xterm and maximize it again. Use resize button or corners to resize the xterm.
The xterm now shrinks to a tiny size and attempts to resize it result in it shrinking again.
I've tried this with fvwm 1.23 and fvwm 2.0.46 with the same results. Olvm, olvwm and twm all behave correctly so it may be a fvwm problem.
ti
and te
capabilities a command to switch to
xterm's alternate screen (e.g., while running vi
), and return
to the normal screen on exit.
This has the effect of clearing the screen.
Under Solaris 2.x, the terminfo description does not use the alternate
screen (it is a matter of preference after all), so that the text from
vi remains on the screen after exit.
There are corresponding terminfo symbols for
ti
and te
:
smcup
and rmcup
, respectively.
This is configurable.
For example (from Bjorn Helgaas <helgaas@dhc.net>) this procedure adds these capabilities to the "xterm" terminfo definition on HP-UX 10.20:
cp /usr/lib/terminfo/x/xterm /usr/lib/terminfo/x/xterm.orig
untic xterm > /tmp/xterm.src
echo " smcup=\E7\E[?47h, rmcup=\E[2J\E[?47l\E8," >> /tmp/xterm.src
tic /tmp/xterm.src
In this example, the terminfo strings are a series of operations:
smcup
\E7
saves the cursor's position
\E[?47h
switches to the alternate screen
rmcup
\E[2J
clears the screen (assumed to be the alternate screen)
\E[?47l
switches back to the normal screen
\E8
restores the cursor's position.
However, xterms that are linked with termcap are more flexible in this area
than those linked with terminfo libraries.
The xterm program supports a resource titeInhibit
which
manipulates the $TERMCAP variable to accomplish this. It sets the $TERMCAP
variable for the client with the ti
and te
capabilities
suppressed.
Systems that use terminfo cannot do this. If you are running terminfo
with the alternate screen controls in the terminal description, then
you can suppress the switching to the alternate screen by the
titeInhibit
, but not the associated cursor save/restore
and clear-screen operations.
XFree86 3.9s xterm implements a different set of controls
(private setmodes 1047, 1048 and 1049) which address
this (in addition to the older set of controls, for compatibility).
The new set of controls implements the entire ti
sequence
(save cursor, switch to alternate screen, clear screen)
and te
(switch to normal screen, restore cursor)
as two control sequences that can be disabled by titeInhibit
.
The 1049 code is a refinement of 1047 and 1048, clearing the alternate
screen before switching to it rather than after switching back to the
normal screen.
This allows you (with a popup menu entry designed to exploit this behavior) to
switch the display back to the alternate screen to select text from it,
to paste into the normal screen.
You can also set or clear the titeInhibit
resource using another
popup menu entry (Enable Alternate Screen Switching
).
ti/te
(terminfo
smcup/rmcup
) strings to initiate and end cursor addressing mode.
As mentioned in the discussion of titeInhibit,
full-screen applications can expect the initialization string to save
the cursor's position, and the end-string to restore it.
A few applications (reportedly IRIX 5.x and 6.x vi
incorrectly move the cursor before initializing cursor-addressing.
This will cause the end-string to restore the cursor to its position
when it was saved by the initialization string (typically at the
upper left corner of the screen).
The usual reason is due to the cursor save/restore controls in
the ti/te
strings. If your application runs a subprocess
which in turn runs another full-screen application (or when reinitializing
the screen after the shell process), it will save the
cursor position again, so the position which is restored when finally
exiting your program is the last one saved, not the first.
XFree86 xterm
(from late 1998, patch 90)
changes the behavior of the cursor save/restore
operations so they apply only to the current screen.
That makes it less likely to misplace your cursor.
For instance
configure --disable-imake --disable-narrowproto
The underlying problem is that we've accumulated three things that are being equated as "Delete":
ASCII backspace (code 8) ASCII delete (code 127) VT220 "remove" aka "delete" (ESC [ 3 ~)
You are probably talking about the backarrow key
(on my keyboard, at the upper right of the QWERTY block),
or the key labeled delete which is on the 6-key "editing keypad".
Since xterm is emulating a VT100/VT220,
the backarrow key should generate a 127 (often displayed as ^?
).
You would use a control/H to obtain a backspace on a real VT220.
Tastes differ on Unix, people expect the backarrow key to generate a backspace (or not). As I understand it, at one point, XFree86 picked up the sense of the erase character during initialization, so that xterm would in effect use the same erase character as the console. The current scheme (X11R6) uses keyboard mapping tables that are independent of the environment.
XFree86 xterm provides a resource toggle backarrowKey (and an escape sequence from VT320) that changes this key between the two styles (backspace or delete).
With XFree86 xterm patch 95 (also in the stable version as "88c"), you may have an xterm which can automatically initialize the backarrow key to backspace or delete depending on the pseudo terminal's sense, or based on the termcap setting of kbs (backspace key). This feature is controlled by the resource setting ptyInitialErase.
This may be because an upgrade introduced different X resource settings, or because you are using the newer xterm with the ptyInitialErase resource (or perhaps both). Use
appres XTerm
to see the X resources that you are using, in particular the
translation
(or
Translation
)
resource for the vt100 widget.
One unexpected scenario came out of hiding when I was implementing the
ptyInitialErase resource. When xterm is (by default) built
to support this, it sets the pty's erase character to match the
termcap entry. Xterm also sets the $TERMCAP environment variable to match.
So everything is consistent, and everything defined.
The stty erase
character is either backspace (^H) or delete (^?).
The problem arises because there are two things called "delete", which were not well-defined: ASCII delete (127) and the PC-style adaptation of VT220 remove assigned to the key Delete.
However, the screen program prefers to make the termcap
delete (kD
) an <escape>[3~, which corresponds to the VT220
remove key.
If $TERMCAP is set when starting screen, it will translate stty's
erase character into the <escape>[3~, making most curses and
termcap applications work.
But stty still has the original erase character.
So low-level applications which check stty will not work.
I found that unsetting $TERMCAP before running would work, but this
was not a good solution.
Someone pointed out
(see patch 129),
that the problem really was because termcap kD
should delete
the character at the current position. So it cannot be the same
as stty erase
.
As a matter of fact, stty erase
has to be a single character,
so <escape>[3~ would not work anyway.
keysym BackSpace = Delete
or
keycode 22 = 0xff08
Either way is a bad technical solution - it works for some people
but not others (on my keyboard at work, keycode 22 is the numeric
keypad '9').
Alternatively, you can set resources. This works reasonably well for environments where you have different versions of xterm, e.g.,
XTerm*VT100.translations: #override \n\
<Key>Delete: string(0x7f)
I do not do that either, because it is not flexible.
Not all programs use the same sense of
stty erase
;
some use termcap or terminfo,
and some are hardcoded.
So I prefer to be able to switch the xterm's keyboard at runtime.
You cannot do that with resources.
(Or not really - xterm has a keymap()
action which could
support this if you provided a rather complex resource settings, but
the X library support for that is broken in X11R6).
Instead, I have added to XFree86 a set of resources (and popup menu entries)
to allow simple switching between the different styles of keyboard,
in particular for the backspace/delete issues.
See the manual page for
backarrowKey
backarrowKeyIsErase
and
deleteIsDEL
as well as
sunKeyboard
.
Here's a picture of the VT100 numeric keypad:
+-----+-----+-----+-----+ | PF1 | PF2 | PF3 | PF4 | +-----+-----+-----+-----+ | 7 | 8 | 9 | - | +-----+-----+-----+-----+ | 4 | 5 | 6 | , | +-----+-----+-----+-----+ | 1 | 2 | 3 | | +-----+-----+-----+ ENT + | 0 | . | | +-----+-----+-----+-----+and the similar Sun and PC keypads:
+-----+-----+-----+-----+ | NUM | / | * | - | +-----+-----+-----+-----+ | 7 | 8 | 9 | | +-----+-----+-----+ + + | 4 | 5 | 6 | | +-----+-----+-----+-----+ | 1 | 2 | 3 | | +-----+-----+-----+ ENT + | 0 | . | | +-----+-----+-----+-----+Working in X11, the NUM (NumLock) key has better uses than an alias for PF1 (and is sometimes reserved). I use the F1 through F4 on the keyboard to implement PF1 through PF4, alias the keypad "+" to "," and use the existing "-" key.
VT220 emulation uses the VT100 numeric keypad as well as a 6-key editing keypad. Here's a picture of the VT220 numeric keypad:
+--------+--------+--------+ | Find | Insert | Remove | +--------+--------+--------+ | Select | Prev | Next | +--------+--------+--------+and the similar Sun and PC keypads:
+--------+--------+--------+ | Insert | Home | PageUp | +--------+--------+--------+ | Delete | End | PageDn | +--------+--------+--------+
I chose to use keys that are mnemonic rather than in the "same" positions, though some emulators (e.g., Tera Term) use the same positions:
+--------+--------+--------+ | Insert | Find | Prev | +--------+--------+--------+ | Remove | Select | Next | +--------+--------+--------+
I test the keyboard (for VT52/VT100/VT220) using vttest. If you find (or think that you have found) a problem with the keyboard handling of xterm, please test it with vttest first.
Other arrangements of the keyboard are possible of course. If you prefer to use the top row of the numeric keypad as PF1 through PF4, you should do this using xterm's X resources.
eightBitInput
resource set to do this.
XTerm*internalBorder: 10
XTerm*highlightSelection: true
XTerm*VT100.colorBDMode: on
XTerm*VT100.colorBD: blue
XTerm*VT100.colorULMode: on
XTerm*VT100.colorUL: magenta
XTerm*VT100.eightBitInput: true
XTerm*VT100.eightBitOutput: true
XTerm*scrollBar: true
XTerm*VT100.titeInhibit: true
XTerm*VT100.colorMode: on
XTerm*VT100.dynamicColors: on
! Uncomment this to use color for underline attribute
XTerm*VT100.colorULMode: on
XTerm*VT100.underLine: off
! Uncomment this to use color for the bold attribute
XTerm*VT100.colorBDMode: on
XTerm*VT100.color0: black
XTerm*VT100.color1: red3
XTerm*VT100.color2: green3
XTerm*VT100.color3: yellow3
XTerm*VT100.color4: blue3
XTerm*VT100.color5: magenta3
XTerm*VT100.color6: cyan3
XTerm*VT100.color7: gray90
XTerm*VT100.color8: gray30
XTerm*VT100.color9: red
XTerm*VT100.color10: green
XTerm*VT100.color11: yellow
XTerm*VT100.color12: blue
XTerm*VT100.color13: magenta
XTerm*VT100.color14: cyan
XTerm*VT100.color15: white
XTerm*VT100.colorUL: yellow
XTerm*VT100.colorBD: white
XTerm*VT100.cursorColor: lime green
XFree86 xterm comes with two copies of the resource file,
one with color only (XTerm-col.ad
,
which is installed as XTerm-color
),
and the regular one (XTerm.ad
,
installed as XTerm
).
To use the XTerm-color
file in conjunction
with a separate XTerm
app-defaults
file which does not contain color,
add the following line to your .Xdefaults
file:
*customization: -color
You have specified the geometry for xterm too high in the hierarchy, and that 24x80 (or whatever the -geometry parameter happens to be) is applying to the menus in pixels. This resource makes the geometry apply to the menus as well as the VT100 widget:
XTerm*geometry: 80x24
while this applies only to the VT100 widget
(which is probably what you intended):
XTerm.VT100.geometry: 80x24
or better yet (to allow for the toolbar option, which uses a level of
widget hierarchy):
XTerm*VT100.geometry: 80x24
You have either found a bug in xterm, or there is something wrong with your computer's configuration, e.g., not enough pty's, incorrect permissions, etc.
The first number is an internal code (defined in error.h in xterm's source), and the second is the system error number (defined in /usr/include/sys/errno.h). The system error number is easier to lookup, but the internal error code tells you where to look in the source.
If the message bothers you (e.g., if you aren't starting xterm from a window manager menu), you can suppress it by setting a resource:
XTerm*openIm:false
XTerm*translations: #override\n\
<Leave>, ~Ctrl ~Meta <Btn2Up>: ignore()\n\
~Shift <Key>KP_8: scroll-back(1,line)\n\
~Shift <Key>KP_2: scroll-forw(1,line)\n\
Shift <Key>KP_8: scroll-back(1,halfpage)\n\
Shift <Key>KP_2: scroll-forw(1,halfpage)
will produce warnings such as
Warning: Actions not found: ignore, scroll-back, scroll-forw
Warning: Actions not found: ignore, scroll-back, scroll-forw
Warning: Actions not found: ignore, scroll-back, scroll-forw
This is a correct form, assigning the actions to the "VT100" widget.
XTerm*VT100.translations: #override\n\
<Leave>, ~Ctrl ~Meta <Btn2Up>: ignore()\n\
~Shift <Key>KP_8: scroll-back(1,line)\n\
~Shift <Key>KP_2: scroll-forw(1,line)\n\
Shift <Key>KP_8: scroll-back(1,halfpage)\n\
Shift <Key>KP_2: scroll-forw(1,halfpage)
During resource initialization, xterm attempts to allocate an entry from the color map for each color which it might use. If there are not enough free slots in the color map, you will see a "Cannot allocate" message for each color that xterm failed to allocate. Those colors will be rendered in the foreground color, making full-screen color applications such as dialog unreadable.
This problem is alleviated with patch 129, which modified xterm to delay the most color allocation until the colors are first needed. If a color is never needed (xterm allocates 20 colors in this manner), that reduces the number of slots in the color map that are needed. Even with this improvement, xterm must still allocate 4 colors during initialization to determine how to display the cursor. If none of those colors can be allocated, XFree86 xterm reverts to monochrome.
These are the known bugs (or limitations) in the XFree86 xterm. They are also present in the other versions based on the X Consortium sources (color_xterm, ansi_xterm, kterm).
Note that of the emulators that support color, most do not support
bce
(back color erase).
The bce capability is also called the
"new color model", though it has been implemented in the IBM PC for
quite a while.
Technically, not implementing bce
(or allowing the choice between it and its complement) is not a bug,
since few hardware terminals (with good reason) implemented this feature.
Update 2004/04/08:
Complicating this discussion is the recently-released "X.Org" xterm.
That is the XFree86 xterm from XFree86 CVS
with all visible "xfree86" strings changed to "X.Org" or "xorg",
depending on the use.
For example the "xterm-xfree86" terminfo entry becomes "xterm-xorg".
The change history for the related CVS for X.Org shows this.
Similarly, the release notes for X11R6.7 include my notes for XFree86 4.4.
It is of course too soon to see the overall impact of this,
so I'll update this FAQ as I find it necessary.
\E[>c
expecting a response such as
\E[>0;138;0c
for vt100.
The bug report indicates that the "c" sent by vim is echoed rather than
interpreted by the emulator.
But it suffices for vi.
A more recent GNOME Terminal (version 1.4.0.4, late 2001) did not implement a complete vt102: it was missing several features which can be demonstrated in vttest). Most of the bugs in the Device Attributes responses remain, but it works a little better with vim. However, there are problems with the alternate screen that show up with vim. Again, these can be demonstrated with vttest (menu 11.6.3 in the 20011130 snapshot).
The documentation for GNOME terminal asserts:
GNOME Terminal emulates the xterm application developed by the X Consortium. In turn, the xterm application emulates the DEC VT102 terminal and also supports the DEC VT220 escape sequences. An escape sequence is a series of characters that starts with the Esc character. GNOME Terminal accepts all of the escape sequences that the VT102 and VT220 terminals use for functions such as to position the cursor and to clear the screen.
That sounds fine, except that it is both inaccurate and misleading:
It emulates a subset of VT100, lacks support for most of the VT220 control sequences (including some used for positioning the cursor) that are not recognized by a VT100.
Perhaps that was unintentional - GNOME developers do not appear to document what their program does outside of that remark. However, an inspection of the changelog for libvte does show that most of the borrowing from xterm is cited in an oblique manner - not once mentioning XFree86 for example, leaving the impression (as indicated by "X Consortium") that all of the work on xterm was done before development of GNOME Terminal commenced.
Like GNOME Terminal, konsole's documentation is incomplete and inaccurate. This gem from its handbook illustrates the problem:
After a decade, Konsole is the first rewrite from the ground up. While xterm has definitely been hacked to death (its README begins with the words Abandon All Hope, Ye Who Enter Here), Konsole offers a fresh start using contemporary technologies and understanding of X.The problem:
(mouse@Lightning.McRCIM.McGill.EDU) Available: larry.mcrcim.mcgill.edu (132.206.1.1) in /X/mterm.src/mterm.ball-o-wax.I saw only an incomplete version of this while it was advertised in the mid-90's. It is available by email from <mouse@Rodents.Montreal.QC.CA>. or via ftp. This is not a patched version of xterm, though it was apparently written, like rxvt, to emulate vt100's. While it does have some interesting features (such as blinking characters), overall it does not do as well with vttest) as the more widely known emulators.
The original patch changes only the scrollbars to Motif, leaving the popup menus in Athena widgets. That was not what I wanted. My motivation for using Motif is not for performance or esthetics, of course, but to make it simpler to build on hosts that have no Athena widgets installed.
I set those changes aside, having found (the hard way) that the Motif library has hardcoded behavior regarding the control right-mouse button. According to the O'Reilly book on Motif programming (volume 6), it does a server grab when processing menus. Making the menus behave just as in the Athena widgets can cause the X server to hang. (I was able to do this with both Lesstif and Motif libraries). Given that, I decided to restructure the menus entirely, making a toolbar which could support at compile-time either widget set.
rxvt, version 2.6.2, is a colour vt102 terminal emulator intended as an xterm(1) replacement for users who do not require features such as Tektronix 4014 emulation and toolkit-style configurability. As a result, rxvt uses much less swap space -- a significant advantage on a machine serving many X sessions.How much is much less? Perhaps not as much as one would think from reading that. The Tektronix emulation in xterm (which has been optional since late 1997) accounts for about 25kb of the code. The toolkit-style configurability glibly referenced is the ability to redefine keys on the keyboard without recompiling the program, i.e., the translations resource. The toolkit-style configurability accounts for about 300kb, which does add up if you happen to be running 50 xterm processes (i.e., about 10Mb). Compared with something like GNOME Terminal, which takes 2-3 times, or KDE konsole, which takes 15-20 times as much memory to run, xterm and rxvt memory requirements are indistinguishable to the normal user.
These comments apply to versions of rxvt through 2.21:
ech
(erase characters) does not
follow DEC VT220 (also ISO 6429), causing applications using this function to
misbehave.
ech
bug.
However, it is less VT100-compatible than the earlier versions such as 2.21b
because it does not render reverse video (DECSCNM
) properly.
All versions do not update the screen frequently enough, making animation
ineffective.
See vttest, tests 1 and 2.
That is from reading the source code. However testing under Debian Linux, something is wrong with the resource processing (neither popup menus nor colors work).
That is, it was.
The name was later appropriated by a different
program,
which also uses the name iterm
.
Like gnome-terminal,
iterm aims to be an xterm-emulator
rather than a VT102- or VT220-emulator.
An earlier attempt by the same author (the "CSI-xterm") incorporates some of the changes I made for XFree86 xterm via cut and paste (but does not mention this in its README). It is said to be the basis for Solaris 10 xterm.
Both have similar problems running vttest.
Xaw
library for popup menus.
xmkmf
make
I have written a simple configure script for xterm which uses imake
(or xmkmf) to generate a Makefile from the Makefile.in.
I have restructured xterm to eliminate most hardcoded
#ifdef
's, replacing them with definitions that can be derived
with the configuration script.
The configure script is more flexible than xmkmf, since it
allows you to enable or disable a variety of features.
Type
configure --helpto get a list of options.
Though I have replaced most hardcoded ifdef's with autoconfigured values, it will still continue to build properly with the imake environment.
The command-line options, X resources and similar configurable options of xterm are documented in the manual page.
Here are copies of the file in various forms: html, pdf and text.
ctlseqs.ms
file which I bundle with the
program source.
(It used to be in the same directory in the X distribution, but was moved
to a different part of the tree long ago).
Note that you must format
this file with different options than a manpage, e.g.,
tbl ctlseqs.ms | nroff -ms >ctlseqs.txt
tbl ctlseqs.ms | groff -ms >ctlseqs.ps
As a PostScript or PDF file,
the individual letters of the control sequences are
all boxed, for emphasis, but I find the text file equally readable.
Here are copies of the file in various forms: html, pdf and text.
Done, except for the corresponding support in the VT52 emulation. It would be nice to have a dialog to control this.
My configure script currently provides tests for the variations of Athena widgets (Xaw3D, neXtaw). I intend to make additional changes to support Motif scrollbars and menus. Motif requires a different style of interface for the menus: binding a popup menu to control right mouse may cause the server to hang. As an intermediate step, I implemented a toolbar for the Athena widgets. In turn, that works well enough except with XFree86 4.x: the Xaw library geometry management is broken. (Other implementations of the Athena widgets work well enough).