Copyright 1997,1998 by Thomas E. Dickey

Contents


What is XTERM?

From the manual page:
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.

Who wrote XTERM?

A lot of people, cited at the bottom of the manual page wrote the original xterm program, maintained by the X Consortium (now part of the Open Group). There is no changelog, and it is not clear who did what. Email from Jim Gettys provides some background:
Cast of thousands...

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.

Email from Doug Mink provides more background:
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 3.3, which is based on the X11R6.3 xterm, with the addition of ANSI color and VT220 controls.

What platforms does it run on?

Xterm runs in all of the implementations of X Windows. 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.

What is the latest version?

The most recent (and well supported) version of xterm is the XFree86 version. I have a copy at

Ftp: ftp://dickey.his.com/xterm/xterm.tar.gz

What versions are available?

There are several other versions of xterm, as well as similar programs. These include (I am aware of a few others, such as xcterm and mterm, but have not seen a working version of these).

There are actually two versions of XFree86 xterm. Starting with my patch 88, there are the stable (beta) and unstable (alpha) versions, which currently are XFree86 3.3.6 and XFree86 4.0, respectively. I have been making only critical changes to the stable version since patch 88; ongoing development (including all non-critical fixes) is focused on the "unstable".

XFree86 4.0 should have incorporated my patch 131, but it was overlooked at the last moment. 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 is some resistance at this time (2000/4/5) by that organization to incorporating the fix because it might be confused with the 4.0 release version.

How do I ...

Not really problems, but frequently asked questions (the point of this, after all):

How do I change the font size?

This is in the manpage, in MENUS.

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.

How do I print the screen?

That depends on why you want to print it.

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:

Well, what about logging? Some versions of xterm support logging to a file. In fact XFree86 xterm does. Logging was dropped from X Consortium xterm during X11R5 due to security concerns. Those were addressed, but logging was not reinstated (in fact there is a related bug in xterm). Some people prefer this, because it is convenient: you can start and stop logging a popup menu entry. However Both script and logging are useful for recording, but they require interpretation to make sense of the trace. You probably would not send that trace to a printer (not twice, anyway).

If you want to print the contents of the screen, XFree86 xterm implements, as part of the VT100 emulation, an "attached" printer.

There are limitations and tradeoffs using the "attached" printer, because it is an emulation: If you use the popup menu to print the screen, this will close the printer pipe unless it was already opened by the application running in xterm.

How do I set up function keys?

With XFree86 xterm, this is relatively simple. So I'll answer that first.

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 &

How do I set the title?

The control sequences are documented in ctlseqs.ms; a copy is contained in the xterm.tar.gz file.

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

Frequent problems

My terminal doesn't show box characters

Xterm displays the 7-bit ASCII and VT100 graphic characters (including box corners) using specially arranged fixed-pitch fonts. The first 32 glyph positions (which would correspond to nonprinting control characters) are used to hold the VT100 graphic characters. Some fonts that otherwise look fine (such as courier) do not have glyphs defined for these positions. So they display as blanks. Use xfd to display the font.

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.

My terminal doesn't recognize color

First, ensure that you have set up xterm to render color. The XFree86 xterm renders color only if you have set resources to do this; the default behavior is monochrome to maintain compatibility with older applications. The manual page describes these resources. I set them in my .Xdefaults file.

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.

Why is my screen size not set?

Well, it may be set, but not correctly. You may notice these symptoms: Xterm knows how big the screen is (of course), and tries to tell your applications (e.g., by invoking ioctl's and sending SIGWINCH). But sometimes it cannot: Most full-screen applications such as vi are designed to use the ioctl calls that return the screen size. When they fail, the applications use the size defined in the terminal's terminfo or termcap description.

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.

Why can't I use the pageup/pagedown keys?

Some vendors, e.g,. Sun, have added key translations which make the pageup and pagedown keys talk to the xterm's scrollbar instead of your application. 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. For example,

	XTerm.VT100.Translations:       #override \
		~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(100,page) \n\
		Shift<Key>Next:   scroll-forw(100,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.

Why can't I cut/paste in xterm

When an application sets xterm to any of its mouse tracking modes, it reserves the unshifted mouse button clicks for the application's use. Unless you have modified the treatment of the shifted mouse button events (e.g., with your window manager), you can always do cut/paste by pressing the shift key while clicking with the mouse.

I need libncurses.so.3.0

During initialization, xterm checks to see if the value of $TERM is legal, i.e., is defined via the termcap interface. Some people have linked xterm against ncurses, which provides a similar interface, since they do not want to package termcap on their system.

The libncurses.so.3.0 corresponds to ncurses 1.9.8a; while there have been interface changes to ncurses past this point (the current version of ncurses), the termcap interface should still be compatible. So (for xterm) it doesn't matter much which version of ncurses you have installed. However, other applications may not work properly. Some people have advised just linking libncurses.so.2.0 to libncurses.so.3.0, but that won't work well at all (one person simply linked libncurses.so.3.0 to the libtermcap.so, which may work...). A better solution would be to install the later version of ncurses, with a link (if you must) from the newer version to the older library.

Since there is little agreement on the set of shared libraries that are assumed to be present on the user's system, XFree86 distributes xterm statically linked against termcap because that is simplest, and because you lose functionality (the $TERMCAP variable) when linked against terminfo libraries such as ncurses.

I need /etc/termcap

If you have a termcap version of xterm on a system with no termcap libraries, you may also be missing /etc/termcap.

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.

Xterm does not run (no available pty's)

For older systems (most computers in fact) you must either make xterm run setuid to root, or make the pty's world-writable.

Perhaps your system does not have enough pty's, or (a recent problem reported with newer Linux kernels, especially RedHat 6.0) the major device numbers of the pty's may have changed during a kernel upgrade.

Reverse video is not reset

When running less or other programs that do highlighting, you see the highlighting not turned off properly.

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.

What $TERM should I use?

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. Use the xterm-xfree86 entry which is distributed with XFree86 xterm (or the similar 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. 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.

FVWM does weird things when I try to resize xterm

I have an old (3.1.2G) bug report for xterm which may be related to the second (3.9s) problem: I have not observed the first, but have reproduced the second.

Why doesn't the screen clear when running vi?

Under SunOS 4.x, the termcap description for xterm embeds in the 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: enter_ca_mode and exit_ca_mode, 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

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 which addresses 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.

Why is the cursor misplaced after running vi?

Vi and other full-screen applications use the termcap 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, 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).

Why doesn't my delete key work?

This seems to be a problem with the older XFree86 release (3.1.2). I have picked up pieces of the story (xterm and the keyboard work as designed under XFree86 3.2 and up).

You are probably talking about the backarrow key (on my keyboard, at the upper right of the QWERTY block), or the key labeled delete. 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 (from VT320) that changes this key between the two styles (backspace or delete).

With XFree86 xterm patch number 95, 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.

Why did my delete key stop working?

Well, something changed. You have to determine what did.

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 (^?).

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.

Unset $TERMCAP in xterms in which you expect to run screen. That works.

Why doesn't my keypad work?

A few people have commented that the keypad does not work properly. Aside from bugs (I have fixed a few), the most common problem seems to be misconception.

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 X Windows, 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.

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.

Why can't I input 8-bit characters

You must have the eightBitInput resource set to do this.

My .Xdefaults for XTERM


	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

Why are the menus tiny

Everything seems to work, except that the xterm menus (VT options, fonts, etc.) do not display properly; the menus pop up, but only with a tiny display area in which none of the options are visible (and only part of the menu title is visible).

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

What is this warning message?

xterm: Error 11, errno 22: permission denied
Actually, any message like this denotes a failure which requires studying the xterm source to determine the exact problem.

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.

input method doesn't support my preedit type
Ignore this if you do not know what input method is. Input methods are used to enter composite characters (e.g., umlauts, other types of punctuated characters, East Asian characters, etc). Your computer's libraries support this, but are missing configuration tables, and xterm is warning you.

Known Bugs in XTERM

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.

X11R6.3 XTERM

The X Consortium version of xterm (and versions based on it) has additional bugs not in XFree86 xterm: (These bugs are also present in the X11R5 version).

COLOR_XTERM download

This is based on the X Consortium X11R5 source, with the same bugs. Not exactly a bug, but it does not build on Linux with X11R6.3

ANSI_XTERM download

This is based on the X Consortium source, with the same bugs.

DTTERM

This is distributed with CDE. It implements more of the DEC VT220 than the X Consortium xterm, and also adds controls to manipulate the window and icon.

EMU 1.3 download

This is not based on the X Consortium source. The authors state that it implements VT220 emulation. It is in need of maintenance, since it builds with some problems to produce an executable that (on Linux and SunOS) does not handle the carriage return and newline translations properly. So I am unable to run vttest on this emulator.

KTERM download

This is based on the X Consortium source, with the same bugs (though the list of original authors has been removed; the modifications that comprise kterm is relatively small).

NXTERM

Distributed with Redhat Linux 5.2, it is a repackaging of xterm-sb_right-ansi, to use the Xaw3d widget set. This is based on the X Consortium X11R6 source, with the same bugs. Starting with Redhat 6.0, nxterm is the XFree86 3.3.6 xterm. Unfortunately Redhat neglected to update their termcap for nxterm to match the program.

RXVT link

This applies to versions of rxvt through 2.21: A new version (upgraded to an beta as of 2.6.PRE3, however, since it no longer dumps core in vttest) is reported to fix the 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.

XITERM link

This appears to be rxvt 2.20, lightly reformatted, with a few ifdef's changed.

How do I build XTERM?

Building a copy of xterm is simple, provided that you have a development configuration for X Windows: If you have a working xmkmf script (or correctly configured imake utility), all you need to do is type

	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 plan to restructure xterm to eliminate the 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 --help
to get a list of options.

Though I plan to replace the hardcoded ifdef's with autoconfigured values, it will still continue to build properly with the imake environment, since that is how large distributions incorporate xterm.

How do I report bugs?

You should report bugs to report@XFree86.org; however I am continuing development as I find time; your input is valuable: mail. See also Analyzing problems with configure scripts

Ongoing/future work