Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

init

  • Loading branch information...
commit 9d743c4305d742737d476d45d3710e4166305a39 0 parents
@JessThrysoee authored
21 .gitignore
@@ -0,0 +1,21 @@
+aclocal.m4
+config.h
+config.h.in
+config.log
+config.status
+config.h.in~
+configure
+missing
+install-sh
+stamp-h1
+Makefile
+Makefile.in
+src/Makefile
+src/Makefile.in
+doc/Makefile
+doc/Makefile.in
+tests/Makefile
+tests/Makefile.in
+a.out.dSYM/
+autom4te.cache/
+
144 ChangeLog
@@ -0,0 +1,144 @@
+2009-10-16 Jess Thrysoee
+
+ * Version 2.10
+
+ * doc/xtermcontrol.roff: Update troubleshooting section. Add list
+ of which xtermcontrol options are effected by which of the three
+ xterm resources allowWindowOps, allowTitleOps, and allowFontOps.
+ All of these resorces can be changed in the xterm ctrl+rightclick
+ menu, or persistently in ~/.Xdefaults, to avoid xtermcontrol hangs.
+
+ * all: remove compile warnings.
+
+2007-09-03 Jess Thrysoee
+
+ * Version 2.9
+
+ * doc/xtermcontrol.roff: Add note that xterm resource allowWindowOps
+ should be set true, to allow xtermcontrol to use extended window
+ control sequences, and avoid that it hangs.
+
+2006-02-04 Jess Thrysoee
+
+ * Version 2.8
+
+ * src/configuration.c: Fix regexp, so the '#rrggbb' way to specify a
+ color works in configuration file. Reported by Olle Mulmo.
+
+ * doc/xtermcontrol.roff: add BUGS section describing how install needs
+ to setuid root on some broken systems.
+
+2004-12-22 Jess Thrysoee
+
+ * Version 2.7
+
+ * configure.ac, src/Makefile.am: remove all dependencies on Xlib.
+ Reported by Rich Paul.
+
+2004-10-11 Jess Thrysoee
+
+ * Version 2.6
+
+ * src/xtermcontrol.c: rewrite of --get-* methods. On Cygwin chars are simply
+ read (VMIN=)1 at a time.
+
+ *config.guess, config.sub: removed. No need for specific Cygwin test.
+
+ * all: remove --get-raw option.
+
+2004-10-03 Jess Thrysoee
+
+ * Version 2.5
+
+ * configure.ac: update autotool scripts.
+
+ * all: remove --timeout option. Use VMIN=1 && VTIME=1, this blocks until at
+ least one char is available and makes --get-* much faster.
+
+ Cygwin does not seem to get this right, as it reads only one char before
+ blocking again, i.e. it uses VMIN as the maximum of chars to read in raw
+ mode. The workaround is to set VMIN=0 and read nonblocking after a fixed
+ timeout. Patch by Mark Paulus.
+
+2004-04-21 Jess Thrysoee
+
+ * Version 2.4
+
+ * doc/xtermcontrol.roff, src/xtermcontrol.h, doc/xtermcontrol.roff: Added
+ new option: --timeout
+
+ * doc/ctlseqs.ms, doc/ctlseqs.txt: updated from xterm-186
+
+2004-01-07 Jess Thrysoee
+
+ * Version 2.3
+
+ * src/xtermcontrol.h: don't include X11/Xlib.h, it not needed.
+
+ * doc/xtermcontrol.roff, src/xtermcontrol.c, src/configuration.c,
+ src/xtermcontrol.h, src/configuration.h: Update Copyright year.
+
+ * doc/xtermcontrol.roff: update documentation of the --font option with the
+ syntax of how to access the fontmenu.
+
+ NOTE: The implementation of the negative relative size fontmenu navigation
+ at xterm patch level #184 has a typo preventing it from working correctly.
+ This has been reported to the xterm maintainer.
+
+2003-09-07 Jess Thrysoee
+
+ * Version 2.2
+
+ * src/configuration.c, src/xtermcontrol.c: compile without errors and
+ warnings with g++
+
+2003-08-17 Jess Thrysoee
+
+ * Version 2.1 (only one minor version number is needed)
+
+ * geometry.c: Source file removed. As of xterm patch #168 the window
+ position bug has been fixed, so the Xlib workaround is no longer needed.
+
+ * all: Added new options: --[get-]colorN
+ --[get-]highlight
+ --force
+ --reset
+ --get-raw
+
+ NOTE: Setting highlight does not work at xterm patch level #179. A patch
+ for this has been accepted by the xterm maintainer, so presumably, it
+ should be fixed in the next release, i.e. #180.
+
+2002-10-26 Jess Thrysoee
+
+ * Version 2.0.2
+
+ * src/configuration.c: Problem: configuration files take no effect.
+ Solution: remove newline from fgets input when reading key/value pairs
+ from configuration file.
+
+ * src/xtermcontrol.c: remove trailing whitespace from configuration file
+
+
+2002-10-20 Jess Thrysoee
+
+ * Version 2.0.1
+
+ * src/configuration.c: included OpenPKG.org patch.
+
+ * configure.in: exit configure when X libs/includes not located
+
+ * doc/xtermcontrol.spec: added rpm spec file.
+
+2002-09-19 Jess Thrysoee
+
+ * Version 2.0.0
+
+ * all: Complete rewrite. Rename project from xtermcolors
+ to xtermcontrol.
+
+2002-05-18 Jess Thrysoee
+
+ * Version 1.0.0
+
+ * all: Initial version.
8 Makefile.am
@@ -0,0 +1,8 @@
+
+AUTOMAKE_OPTIONS = foreign
+
+SUBDIRS = src doc tests
+
+.PHONY: test
+test:
+ cd "$(top_builddir)/tests" && $(MAKE) $@;
0  README
No changes.
7 acinclude.m4
@@ -0,0 +1,7 @@
+dnl XTC_PACKAGE_DATE
+dnl make PACKAGE_DATE shell variable available with bootstrap date, e.g. "July 25, 2002"
+AC_DEFUN([XTC_PACKAGE_DATE],
+[
+ PACKAGE_DATE="esyscmd([date +'%B %d[,] %Y"'])
+ AC_SUBST(PACKAGE_DATE)
+])
26 bootstrap.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+rm -f \
+aclocal.m4 \
+config.h \
+config.h.in \
+config.log \
+config.status \
+config.h.in~ \
+configure \
+missing \
+install-sh \
+stamp-h1 \
+Makefile \
+Makefile.in \
+src/Makefile \
+src/Makefile.in \
+doc/Makefile \
+doc/Makefile.in \
+tests/Makefile \
+tests/Makefile.in
+
+rm -rf a.out.dSYM
+rm -rf autom4te.cache
+
+#autoreconf -fi
44 configure.ac
@@ -0,0 +1,44 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+#
+# Compile pedantic and with debug symbols:
+# CFLAGS="-ggdb -Wall -Wextra -pedantic -ansi -O0" ./configure
+#
+# Verbose output can be enabled with
+# "./configure --disable-silent-rules" or "make V=1"
+#
+
+AC_INIT(xtermcontrol, 2.10, )
+AC_CONFIG_SRCDIR([src/xtermcontrol.c])
+AC_CONFIG_HEADER([config.h])
+
+AM_INIT_AUTOMAKE
+
+XTC_PACKAGE_DATE
+
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+
+# Checks for programs.
+AC_PROG_CC
+
+# features of Posix that are extensions to C (define _GNU_SOURCE)
+AC_USE_SYSTEM_EXTENSIONS
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([fcntl.h libintl.h stdlib.h string.h strings.h termios.h unistd.h wchar.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_CHECK_FUNCS([memset regcomp strchr strrchr strstr])
+AC_CHECK_FUNC([snprintf], [], AC_MSG_ERROR([required function missing]))
+
+AC_CONFIG_FILES([Makefile
+ doc/Makefile
+ src/Makefile
+ tests/Makefile])
+AC_OUTPUT
22 doc/Makefile.am
@@ -0,0 +1,22 @@
+
+CLEANFILES = $(PACKAGE).1 changelog.txt
+
+ROOTNAME = xtermcontrol
+## Date used in manpage header
+PACKAGE_DATE = @PACKAGE_DATE@
+
+man_MANS = $(PACKAGE).1
+EXTRA_DIST = $(ROOTNAME).roff ctlseqs.txt
+
+all: $(PACKAGE).1
+
+$(PACKAGE).1: $(ROOTNAME).roff
+ @PACKAGE_CAPS=`echo $(PACKAGE) | tr [a-z] [A-Z]`;\
+ echo '.\" troff' > $@;\
+ echo ".ds x $(PACKAGE)" >> $@;\
+ echo ".TH $$PACKAGE_CAPS 1 \"$(PACKAGE_DATE)\" \"$(PACKAGE) $(VERSION)\" \"User Commands\"" >> $@;\
+ cat $(srcdir)/$(ROOTNAME).roff >> $@;
+
+changelog.txt: ../ChangeLog
+ @sed 's/@/ (at)/g;s/&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g' $(srcdir)/$< > $@;
+
1,324 doc/ctlseqs.txt
@@ -0,0 +1,1324 @@
+
+
+
+
+
+
+
+
+
+ Xterm Control Sequences
+
+ Edward Moy
+ University of California, Berkeley
+
+ Revised by
+
+ Stephen Gildea
+ X Consortium (1994)
+
+ Thomas Dickey
+ XFree86 Project (1996-2006)
+ invisible-island.net (2006-2008)
+
+
+
+Definitions
+
+c The literal character c.
+
+C A single (required) character.
+
+Ps A single (usually optional) numeric parameter, composed of one of
+ more digits.
+
+Pm A multiple numeric parameter composed of any number of single
+ numeric parameters, separated by ; character(s). Individual val-
+ ues for the parameters are listed with Ps .
+
+Pt A text parameter composed of printable characters.
+
+C1 (8-Bit) Control Characters
+
+The xterm program recognizes both 8-bit and 7-bit control characters.
+It generates 7-bit controls (by default) or 8-bit if S8C1T is enabled.
+The following pairs of 7-bit and 8-bit control characters are equiva-
+lent:
+
+ESC D
+ Index (IND is 0x84)
+ESC E
+ Next Line (NEL is 0x85)
+ESC H
+ Tab Set (HTS is 0x88)
+ESC M
+ Reverse Index (RI is 0x8d)
+ESC N
+ Single Shift Select of G2 Character Set (SS2 is 0x8e): affects
+ next character only
+ESC O
+ Single Shift Select of G3 Character Set (SS3 is 0x8f): affects
+ next character only
+ESC P
+ Device Control String (DCS is 0x90)
+ESC V
+ Start of Guarded Area (SPA is 0x96)
+ESC W
+ End of Guarded Area (EPA is 0x97)
+ESC X
+ Start of String (SOS is 0x98)
+ESC Z
+ Return Terminal ID (DECID is 0x9a). Obsolete form of CSI c (DA).
+ESC [
+ Control Sequence Introducer (CSI is 0x9b)
+ESC \
+ String Terminator (ST is 0x9c)
+ESC ]
+ Operating System Command (OSC is 0x9d)
+ESC ^
+ Privacy Message (PM is 0x9e)
+ESC _
+ Application Program Command (APC is 0x9f)
+
+These control characters are used in the vtXXX emulation.
+
+VT100 Mode
+Most of these control sequences are standard VT102 control sequences,
+but there is support for later DEC VT terminals (i.e., VT220, VT320,
+VT420), as well as ISO 6429 and aixterm color controls. The only VT102
+features not supported is auto-repeat, since the only way X provides for
+this will affect all windows. There are additional control sequences to
+provide xterm-dependent functions, such as the scrollbar or window size.
+Where the function is specified by DEC or ISO 6429, the code assigned to
+it is given in parentheses. The escape codes to designate and invoke
+character sets are specified by ISO 2022; see that document for a dis-
+cussion of character sets.
+
+Single-character functions
+BEL Bell (Ctrl-G)
+BS Backspace (Ctrl-H)
+CR Carriage Return (Ctrl-M)
+ENQ Return Terminal Status (Ctrl-E). Default response is an empty
+ string, but may be overridden by a resource answerbackString.
+FF Form Feed or New Page (NP) (Ctrl-L) same as LF
+LF Line Feed or New Line (NL) (Ctrl-J)
+SO Shift Out (Ctrl-N) -> Switch to Alternate Character Set:
+ invokes the G1 character set.
+SP Space.
+TAB Horizontal Tab (HT) (Ctrl-I)
+VT Vertical Tab (Ctrl-K) same as LF
+SI Shift In (Ctrl-O) -> Switch to Standard Character Set: invokes
+ the G0 character set (the default).
+
+Controls beginning with ESC (other than those where ESC is part of a
+7-bit equivalent to 8-bit C1 controls), ordered by the final charac-
+ter(s).
+ESC SP F 7-bit controls (S7C1T).
+ESC SP G 8-bit controls (S8C1T).
+ESC SP L Set ANSI conformance level 1 (dpANS X3.134.1).
+ESC SP M Set ANSI conformance level 2 (dpANS X3.134.1).
+ESC SP N Set ANSI conformance level 3 (dpANS X3.134.1).
+ESC # 3 DEC double-height line, top half (DECDHL)
+ESC # 4 DEC double-height line, bottom half (DECDHL)
+ESC # 5 DEC single-width line (DECSWL)
+ESC # 6 DEC double-width line (DECDWL)
+ESC # 8 DEC Screen Alignment Test (DECALN)
+ESC % @ Select default character set, ISO 8859-1 (ISO 2022)
+ESC % G Select UTF-8 character set (ISO 2022)
+ESC ( C Designate G0 Character Set (ISO 2022)
+ESC ) C Designate G1 Character Set (ISO 2022)
+ESC * C Designate G2 Character Set (ISO 2022)
+ESC + C Designate G3 Character Set (ISO 2022)
+ Final character C for designating 94-character sets (0 , A
+ and B apply to VT100 and up, the remainder to VT220 and up):
+ C = 0 -> DEC Special Character and Line Drawing Set
+ C = A -> United Kingdom (UK)
+ C = B -> United States (USASCII)
+ C = 4 -> Dutch
+ C = C or 5 -> Finnish
+ C = R -> French
+ C = Q -> French Canadian
+ C = K -> German
+ C = Y -> Italian
+ C = E or 6 -> Norwegian/Danish
+ C = Z -> Spanish
+ C = H or 7 -> Swedish
+ C = = -> Swiss
+ESC - C Designate G1 Character Set (VT300)
+ESC . C Designate G2 Character Set (VT300)
+ESC / C Designate G3 Character Set (VT300)
+ These work for 96-character sets only.
+ C = A -> ISO Latin-1 Supplemental
+ESC 7 Save Cursor (DECSC)
+ESC 8 Restore Cursor (DECRC)
+ESC = Application Keypad (DECPAM)
+ESC > Normal Keypad (DECPNM)
+ESC F Cursor to lower left corner of screen (if enabled by the
+ hpLowerleftBugCompat resource).
+ESC c Full Reset (RIS)
+ESC l Memory Lock (per HP terminals). Locks memory above the cur-
+ sor.
+ESC m Memory Unlock (per HP terminals)
+ESC n Invoke the G2 Character Set as GL (LS2).
+ESC o Invoke the G3 Character Set as GL (LS3).
+ESC | Invoke the G3 Character Set as GR (LS3R).
+ESC } Invoke the G2 Character Set as GR (LS2R).
+ESC ~ Invoke the G1 Character Set as GR (LS1R).
+
+Application Program-Control functions
+APC Pt ST xterm implements no APC functions; Pt is ignored. Pt need
+ not be printable characters.
+
+Device-Control functions
+DCS Ps; Ps| Pt ST
+ User-Defined Keys (DECUDK). The first parameter:
+ Ps = 0 -> Clear all UDK definitions before starting
+ (default)
+ Ps = 1 -> Erase Below (default)
+ The second parameter:
+ Ps = 0 -> Lock the keys (default)
+ Ps = 1 -> Do not lock.
+ The third parameter is a ';'-separated list of strings denot-
+ ing the key-code separated by a '/' from the hex-encoded key
+ value. The key codes correspond to the DEC function-key codes
+ (e.g., F6=17).
+DCS $ q Pt ST
+ Request Status String (DECRQSS). The string following the "q"
+ is one of the following:
+ " q -> DECSCA
+ " p -> DECSCL
+ r -> DECSTBM
+ m -> SGR
+ xterm responds with DCS 1 $ r Pt ST for valid requests,
+ replacing the Pt with the corresponding CSI string, or DCS 0 $
+ r Pt ST for invalid requests.
+DCS + q Pt ST
+ Request Termcap/Terminfo String (xterm, experimental). The
+ string following the "q" is a list of names encoded in hex-
+ adecimal (2 digits per character) separated by ; which corre-
+ spond to termcap or terminfo key names.
+ xterm responds with DCS 1 + r Pt ST for valid requests, adding
+ to Pt an = , and the value of the corresponding string that
+ xterm would send, or DCS 0 + r Pt ST for invalid requests.
+ The strings are encoded in hexadecimal (2 digits per charac-
+ ter).
+
+Functions using CSI , ordered by the final character(s)
+CSI Ps @ Insert Ps (Blank) Character(s) (default = 1) (ICH)
+CSI Ps A Cursor Up Ps Times (default = 1) (CUU)
+CSI Ps B Cursor Down Ps Times (default = 1) (CUD)
+CSI Ps C Cursor Forward Ps Times (default = 1) (CUF)
+CSI Ps D Cursor Backward Ps Times (default = 1) (CUB)
+CSI Ps E Cursor Next Line Ps Times (default = 1) (CNL)
+CSI Ps F Cursor Preceding Line Ps Times (default = 1) (CPL)
+CSI Ps G Cursor Character Absolute [column] (default = [row,1]) (CHA)
+CSI Ps ; Ps H
+ Cursor Position [row;column] (default = [1,1]) (CUP)
+CSI Ps I Cursor Forward Tabulation Ps tab stops (default = 1) (CHT)
+CSI Ps J Erase in Display (ED)
+ Ps = 0 -> Erase Below (default)
+ Ps = 1 -> Erase Above
+ Ps = 2 -> Erase All
+ Ps = 3 -> Erase Saved Lines (xterm)
+CSI ? Ps J
+ Erase in Display (DECSED)
+ Ps = 0 -> Selective Erase Below (default)
+ Ps = 1 -> Selective Erase Above
+ Ps = 2 -> Selective Erase All
+CSI Ps K Erase in Line (EL)
+ Ps = 0 -> Erase to Right (default)
+ Ps = 1 -> Erase to Left
+ Ps = 2 -> Erase All
+CSI ? Ps K
+ Erase in Line (DECSEL)
+ Ps = 0 -> Selective Erase to Right (default)
+ Ps = 1 -> Selective Erase to Left
+ Ps = 2 -> Selective Erase All
+CSI Ps L Insert Ps Line(s) (default = 1) (IL)
+CSI Ps M Delete Ps Line(s) (default = 1) (DL)
+CSI Ps P Delete Ps Character(s) (default = 1) (DCH)
+CSI Ps S Scroll up Ps lines (default = 1) (SU)
+CSI Ps T Scroll down Ps lines (default = 1) (SD)
+CSI Ps ; Ps ; Ps ; Ps ; Ps T
+ Initiate highlight mouse tracking. Parameters are
+ [func;startx;starty;firstrow;lastrow]. See the section Mouse
+ Tracking.
+CSI Ps X Erase Ps Character(s) (default = 1) (ECH)
+CSI Ps Z Cursor Backward Tabulation Ps tab stops (default = 1) (CBT)
+CSI Pm ` Character Position Absolute [column] (default = [row,1])
+ (HPA)
+CSI Ps b Repeat the preceding graphic character Ps times (REP)
+CSI Ps c Send Device Attributes (Primary DA)
+ Ps = 0 or omitted -> request attributes from terminal. The
+ response depends on the decTerminalID resource setting.
+ -> CSI ? 1 ; 2 c (``VT100 with Advanced Video Option'')
+ -> CSI ? 1 ; 0 c (``VT101 with No Options'')
+ -> CSI ? 6 c (``VT102'')
+ -> CSI ? 6 0 ; 1 ; 2 ; 6 ; 8 ; 9 ; 1 5 ; c (``VT220'')
+ The VT100-style response parameters do not mean anything by
+ themselves. VT220 parameters do, telling the host what fea-
+ tures the terminal supports:
+ -> 1 132-columns
+ -> 2 Printer
+ -> 6 Selective erase
+ -> 8 User-defined keys
+ -> 9 National replacement character sets
+ -> 1 5 Technical characters
+ -> 2 2 ANSI color, e.g., VT525
+ -> 2 9 ANSI text locator (i.e., DEC Locator mode)
+CSI > Ps c
+ Send Device Attributes (Secondary DA)
+ Ps = 0 or omitted -> request the terminal's identification
+ code. The response depends on the decTerminalID resource set-
+ ting. It should apply only to VT220 and up, but xterm extends
+ this to VT100.
+ -> CSI > Pp ; Pv ; Pc c
+ where Pp denotes the terminal type
+ -> 0 (``VT100'')
+ -> 1 (``VT220'')
+ and Pv is the firmware version (for xterm, this was originally
+ the XFree86 patch number, starting with 95). In a DEC termi-
+ nal, Pc indicates the ROM cartridge registration number and is
+ always zero.
+CSI Pm d Line Position Absolute [row] (default = [1,column]) (VPA)
+CSI Ps ; Ps f
+ Horizontal and Vertical Position [row;column] (default =
+ [1,1]) (HVP)
+CSI Ps g Tab Clear (TBC)
+ Ps = 0 -> Clear Current Column (default)
+ Ps = 3 -> Clear All
+CSI Pm h Set Mode (SM)
+ Ps = 2 -> Keyboard Action Mode (AM)
+ Ps = 4 -> Insert Mode (IRM)
+ Ps = 1 2 -> Send/receive (SRM)
+ Ps = 2 0 -> Automatic Newline (LNM)
+CSI ? Pm h
+ DEC Private Mode Set (DECSET)
+ Ps = 1 -> Application Cursor Keys (DECCKM)
+ Ps = 2 -> Designate USASCII for character sets G0-G3
+ (DECANM), and set VT100 mode.
+ Ps = 3 -> 132 Column Mode (DECCOLM)
+ Ps = 4 -> Smooth (Slow) Scroll (DECSCLM)
+ Ps = 5 -> Reverse Video (DECSCNM)
+ Ps = 6 -> Origin Mode (DECOM)
+ Ps = 7 -> Wraparound Mode (DECAWM)
+ Ps = 8 -> Auto-repeat Keys (DECARM)
+ Ps = 9 -> Send Mouse X & Y on button press. See the sec-
+ tion Mouse Tracking.
+ Ps = 1 0 -> Show toolbar (rxvt)
+ Ps = 1 2 -> Start Blinking Cursor (att610)
+ Ps = 1 8 -> Print form feed (DECPFF)
+ Ps = 1 9 -> Set print extent to full screen (DECPEX)
+ Ps = 2 5 -> Show Cursor (DECTCEM)
+ Ps = 3 0 -> Show scrollbar (rxvt).
+ Ps = 3 5 -> Enable font-shifting functions (rxvt).
+ Ps = 3 8 -> Enter Tektronix Mode (DECTEK)
+ Ps = 4 0 -> Allow 80 -> 132 Mode
+ Ps = 4 1 -> more(1) fix (see curses resource)
+ Ps = 4 2 -> Enable Nation Replacement Character sets (DECN-
+ RCM)
+ Ps = 4 4 -> Turn On Margin Bell
+ Ps = 4 5 -> Reverse-wraparound Mode
+ Ps = 4 6 -> Start Logging (normally disabled by a compile-
+ time option)
+ Ps = 4 7 -> Use Alternate Screen Buffer (unless disabled by
+ the titeInhibit resource)
+ Ps = 6 6 -> Application keypad (DECNKM)
+ Ps = 6 7 -> Backarrow key sends backspace (DECBKM)
+ Ps = 1 0 0 0 -> Send Mouse X & Y on button press and
+ release. See the section Mouse Tracking.
+ Ps = 1 0 0 1 -> Use Hilite Mouse Tracking.
+ Ps = 1 0 0 2 -> Use Cell Motion Mouse Tracking.
+ Ps = 1 0 0 3 -> Use All Motion Mouse Tracking.
+ Ps = 1 0 0 4 -> Send FocusIn/FocusOut events.
+ Ps = 1 0 1 0 -> Scroll to bottom on tty output (rxvt).
+ Ps = 1 0 1 1 -> Scroll to bottom on key press (rxvt).
+ Ps = 1 0 3 4 -> Interpret "meta" key, sets eighth bit.
+ (enables the eightBitInput resource).
+ Ps = 1 0 3 5 -> Enable special modifiers for Alt and Num-
+ Lock keys (enables the numLock resource).
+ Ps = 1 0 3 6 -> Send ESC when Meta modifies a key (enables
+ the metaSendsEscape resource).
+ Ps = 1 0 3 7 -> Send DEL from the editing-keypad Delete key
+ Ps = 1 0 3 9 -> Send ESC when Alt modifies a key (enables
+ the altSendsEscape resource).
+ Ps = 1 0 4 0 -> Keep selection even if not highlighted
+ (enables the keepSelection resource).
+ Ps = 1 0 4 1 -> Use the CLIPBOARD selection (enables the
+ selectToClipboard resource).
+ Ps = 1 0 4 2 -> Enable Urgency window manager hint when
+ Control-G is received (enables the bellIsUrgent resource).
+ Ps = 1 0 4 3 -> Enable raising of the window when Control-G
+ is received (enables the popOnBell resource).
+ Ps = 1 0 4 7 -> Use Alternate Screen Buffer (unless dis-
+ abled by the titeInhibit resource)
+ Ps = 1 0 4 8 -> Save cursor as in DECSC (unless disabled by
+ the titeInhibit resource)
+ Ps = 1 0 4 9 -> Save cursor as in DECSC and use Alternate
+ Screen Buffer, clearing it first (unless disabled by the
+ titeInhibit resource). This combines the effects of the 1 0 4
+ 7 and 1 0 4 8 modes. Use this with terminfo-based applica-
+ tions rather than the 4 7 mode.
+ Ps = 1 0 5 0 -> Set terminfo/termcap function-key mode.
+ Ps = 1 0 5 1 -> Set Sun function-key mode.
+ Ps = 1 0 5 2 -> Set HP function-key mode.
+ Ps = 1 0 5 3 -> Set SCO function-key mode.
+ Ps = 1 0 6 0 -> Set legacy keyboard emulation (X11R6).
+ Ps = 1 0 6 1 -> Set VT220 keyboard emulation.
+ Ps = 2 0 0 4 -> Set bracketed paste mode.
+CSI Pm i Media Copy (MC)
+ Ps = 0 -> Print screen (default)
+ Ps = 4 -> Turn off printer controller mode
+ Ps = 5 -> Turn on printer controller mode
+CSI ? Pm i
+ Media Copy (MC, DEC-specific)
+ Ps = 1 -> Print line containing cursor
+ Ps = 4 -> Turn off autoprint mode
+ Ps = 5 -> Turn on autoprint mode
+ Ps = 1 0 -> Print composed display, ignores DECPEX
+ Ps = 1 1 -> Print all pages
+CSI Pm l Reset Mode (RM)
+ Ps = 2 -> Keyboard Action Mode (AM)
+ Ps = 4 -> Replace Mode (IRM)
+ Ps = 1 2 -> Send/receive (SRM)
+ Ps = 2 0 -> Normal Linefeed (LNM)
+CSI ? Pm l
+ DEC Private Mode Reset (DECRST)
+ Ps = 1 -> Normal Cursor Keys (DECCKM)
+ Ps = 2 -> Designate VT52 mode (DECANM).
+ Ps = 3 -> 80 Column Mode (DECCOLM)
+ Ps = 4 -> Jump (Fast) Scroll (DECSCLM)
+ Ps = 5 -> Normal Video (DECSCNM)
+ Ps = 6 -> Normal Cursor Mode (DECOM)
+ Ps = 7 -> No Wraparound Mode (DECAWM)
+ Ps = 8 -> No Auto-repeat Keys (DECARM)
+ Ps = 9 -> Don't send Mouse X & Y on button press
+ Ps = 1 0 -> Hide toolbar (rxvt)
+ Ps = 1 2 -> Stop Blinking Cursor (att610)
+ Ps = 1 8 -> Don't print form feed (DECPFF)
+ Ps = 1 9 -> Limit print to scrolling region (DECPEX)
+ Ps = 2 5 -> Hide Cursor (DECTCEM)
+ Ps = 3 0 -> Don't show scrollbar (rxvt).
+ Ps = 3 5 -> Disable font-shifting functions (rxvt).
+ Ps = 4 0 -> Disallow 80 -> 132 Mode
+ Ps = 4 1 -> No more(1) fix (see curses resource)
+ Ps = 4 2 -> Disable Nation Replacement Character sets (DEC-
+ NRCM)
+ Ps = 4 4 -> Turn Off Margin Bell
+ Ps = 4 5 -> No Reverse-wraparound Mode
+ Ps = 4 6 -> Stop Logging (normally disabled by a compile-
+ time option)
+ Ps = 4 7 -> Use Normal Screen Buffer
+ Ps = 6 6 -> Numeric keypad (DECNKM)
+ Ps = 6 7 -> Backarrow key sends delete (DECBKM)
+ Ps = 1 0 0 0 -> Don't send Mouse X & Y on button press and
+ release. See the section Mouse Tracking.
+ Ps = 1 0 0 1 -> Don't use Hilite Mouse Tracking.
+ Ps = 1 0 0 2 -> Don't use Cell Motion Mouse Tracking.
+ Ps = 1 0 0 3 -> Don't use All Motion Mouse Tracking.
+ Ps = 1 0 0 4 -> Don't send FocusIn/FocusOut events.
+ Ps = 1 0 1 0 -> Don't scroll to bottom on tty output
+ (rxvt).
+ Ps = 1 0 1 1 -> Don't scroll to bottom on key press (rxvt).
+ Ps = 1 0 3 4 -> Don't interpret "meta" key (disables the
+ eightBitInput resource).
+ Ps = 1 0 3 5 -> Disable special modifiers for Alt and Num-
+ Lock keys (disables the numLock resource).
+ Ps = 1 0 3 6 -> Don't send ESC when Meta modifies a key
+ (disables the metaSendsEscape resource).
+ Ps = 1 0 3 7 -> Send VT220 Remove from the editing-keypad
+ Delete key
+ Ps = 1 0 3 9 -> Don't send ESC when Alt modifies a key
+ (disables the altSendsEscape resource).
+ Ps = 1 0 4 0 -> Do not keep selection when not highlighted
+ (disables the keepSelection resource).
+ Ps = 1 0 4 1 -> Use the PRIMARY selection. (disables the
+ selectToClipboard resource).
+ Ps = 1 0 4 2 -> Disable Urgency window manager hint when
+ Control-G is received (disables the bellIsUrgent resource).
+ Ps = 1 0 4 3 -> Disable raising of the window when Control-
+ G is received (disables the popOnBell resource).
+ Ps = 1 0 4 7 -> Use Normal Screen Buffer, clearing screen
+ first if in the Alternate Screen (unless disabled by the
+ titeInhibit resource)
+ Ps = 1 0 4 8 -> Restore cursor as in DECRC (unless disabled
+ by the titeInhibit resource)
+ Ps = 1 0 4 9 -> Use Normal Screen Buffer and restore cursor
+ as in DECRC (unless disabled by the titeInhibit resource).
+ This combines the effects of the 1 0 4 7 and 1 0 4 8 modes.
+ Use this with terminfo-based applications rather than the 4 7
+ mode.
+ Ps = 1 0 5 0 -> Reset terminfo/termcap function-key mode.
+ Ps = 1 0 5 1 -> Reset Sun function-key mode.
+ Ps = 1 0 5 2 -> Reset HP function-key mode.
+ Ps = 1 0 5 3 -> Reset SCO function-key mode.
+ Ps = 1 0 6 0 -> Reset legacy keyboard emulation (X11R6).
+ Ps = 1 0 6 1 -> Reset keyboard emulation to Sun/PC style.
+ Ps = 2 0 0 4 -> Reset bracketed paste mode.
+CSI Pm m Character Attributes (SGR)
+ Ps = 0 -> Normal (default)
+ Ps = 1 -> Bold
+ Ps = 4 -> Underlined
+ Ps = 5 -> Blink (appears as Bold)
+ Ps = 7 -> Inverse
+ Ps = 8 -> Invisible, i.e., hidden (VT300)
+ Ps = 2 2 -> Normal (neither bold nor faint)
+ Ps = 2 4 -> Not underlined
+ Ps = 2 5 -> Steady (not blinking)
+ Ps = 2 7 -> Positive (not inverse)
+ Ps = 2 8 -> Visible, i.e., not hidden (VT300)
+ Ps = 3 0 -> Set foreground color to Black
+ Ps = 3 1 -> Set foreground color to Red
+ Ps = 3 2 -> Set foreground color to Green
+ Ps = 3 3 -> Set foreground color to Yellow
+ Ps = 3 4 -> Set foreground color to Blue
+ Ps = 3 5 -> Set foreground color to Magenta
+ Ps = 3 6 -> Set foreground color to Cyan
+ Ps = 3 7 -> Set foreground color to White
+ Ps = 3 9 -> Set foreground color to default (original)
+ Ps = 4 0 -> Set background color to Black
+ Ps = 4 1 -> Set background color to Red
+ Ps = 4 2 -> Set background color to Green
+ Ps = 4 3 -> Set background color to Yellow
+ Ps = 4 4 -> Set background color to Blue
+ Ps = 4 5 -> Set background color to Magenta
+ Ps = 4 6 -> Set background color to Cyan
+ Ps = 4 7 -> Set background color to White
+ Ps = 4 9 -> Set background color to default (original).
+
+ If 16-color support is compiled, the following apply. Assume
+ that xterm's resources are set so that the ISO color codes are
+ the first 8 of a set of 16. Then the aixterm colors are the
+ bright versions of the ISO colors:
+ Ps = 9 0 -> Set foreground color to Black
+ Ps = 9 1 -> Set foreground color to Red
+ Ps = 9 2 -> Set foreground color to Green
+ Ps = 9 3 -> Set foreground color to Yellow
+ Ps = 9 4 -> Set foreground color to Blue
+ Ps = 9 5 -> Set foreground color to Magenta
+ Ps = 9 6 -> Set foreground color to Cyan
+ Ps = 9 7 -> Set foreground color to White
+ Ps = 1 0 0 -> Set background color to Black
+ Ps = 1 0 1 -> Set background color to Red
+ Ps = 1 0 2 -> Set background color to Green
+ Ps = 1 0 3 -> Set background color to Yellow
+ Ps = 1 0 4 -> Set background color to Blue
+ Ps = 1 0 5 -> Set background color to Magenta
+ Ps = 1 0 6 -> Set background color to Cyan
+ Ps = 1 0 7 -> Set background color to White
+
+ If xterm is compiled with the 16-color support disabled, it
+ supports the following, from rxvt:
+ Ps = 1 0 0 -> Set foreground and background color to
+ default
+
+ If 88- or 256-color support is compiled, the following apply.
+ Ps = 3 8 ; 5 ; Ps -> Set foreground color to the second Ps
+ Ps = 4 8 ; 5 ; Ps -> Set background color to the second Ps
+
+CSI > Ps; Ps m
+ Set or reset resource-values used by xterm to decide whether
+ to construct escape sequences holding information about the
+ modifiers pressed with a given key. The first parameter iden-
+ tifies the resource to set/reset. The second parameter is the
+ value to assign to the resource. If the second parameter is
+ omitted, the resource is reset to its initial value.
+ -> 1 modifyCursorKeys
+ -> 2 modifyFunctionKeys
+ -> 4 modifyOtherKeys
+ If no parameters are given, all resources are reset to their
+ initial values.
+CSI Ps n Device Status Report (DSR)
+ Ps = 5 -> Status Report CSI 0 n (``OK'')
+ Ps = 6 -> Report Cursor Position (CPR) [row;column] as
+ CSI r ; c R
+CSI > Ps n
+ Disable modifiers which may be enabled via the CSI > Ps; Ps m
+ sequence. This corresponds to a resource value of "-1", which
+ cannot be set with the other sequence. The parameter identi-
+ fies the resource to be disabled:
+ -> 1 modifyCursorKeys
+ -> 2 modifyFunctionKeys
+ -> 4 modifyOtherKeys If the parameter is omitted, modify-
+ FunctionKeys is disabled. When modifyFunctionKeys is dis-
+ abled, xterm uses the modifier keys to make an extended
+ sequence of functions rather than adding a parameter to each
+ function key to denote the modifiers.
+CSI ? Ps n
+ Device Status Report (DSR, DEC-specific)
+ Ps = 6 -> Report Cursor Position (CPR) [row;column] as CSI
+ ? r ; c R (assumes page is zero).
+ Ps = 1 5 -> Report Printer status as CSI ? 1 0 n (ready)
+ or CSI ? 1 1 n (not ready)
+ Ps = 2 5 -> Report UDK status as CSI ? 2 0 n (unlocked)
+ or CSI ? 2 1 n (locked)
+ Ps = 2 6 -> Report Keyboard status as
+ CSI ? 2 7 ; 1 ; 0 ; 0 n (North American)
+ The last two parameters apply to VT400 & up, and denote key-
+ board ready and LK01 respectively.
+ Ps = 5 3 -> Report Locator status as
+ CSI ? 5 3 n Locator available, if compiled-in, or
+ CSI ? 5 0 n No Locator, if not.
+CSI > Ps p
+ Set resource value pointerMode, used by xterm to decide
+ whether to hide the pointer cursor as the user types. Valid
+ values for the parameter:
+ Ps = 0 -> never hide the pointer
+ Ps = 1 -> hide if the mouse tracking mode is not enabled
+ Ps = 2 -> always hide the pointer If no parameter is given,
+ xterm uses the default, which is 1 .
+CSI ! p Soft terminal reset (DECSTR)
+CSI Ps ; Ps " p
+ Set conformance level (DECSCL) Valid values for the first
+ parameter:
+ Ps = 6 1 -> VT100
+ Ps = 6 2 -> VT200
+ Ps = 6 3 -> VT300
+ Valid values for the second parameter:
+ Ps = 0 -> 8-bit controls
+ Ps = 1 -> 7-bit controls (always set for VT100)
+ Ps = 2 -> 8-bit controls
+CSI Ps " q
+ Select character protection attribute (DECSCA). Valid values
+ for the parameter:
+ Ps = 0 -> DECSED and DECSEL can erase (default)
+ Ps = 1 -> DECSED and DECSEL cannot erase
+ Ps = 2 -> DECSED and DECSEL can erase
+CSI Ps ; Ps r
+ Set Scrolling Region [top;bottom] (default = full size of win-
+ dow) (DECSTBM)
+CSI ? Pm r
+ Restore DEC Private Mode Values. The value of Ps previously
+ saved is restored. Ps values are the same as for DECSET.
+CSI Pt; Pl; Pb; Pr; Ps$ r
+ Change Attributes in Rectangular Area (DECCARA).
+ Pt; Pl; Pb; Pr denotes the rectangle.
+ Ps denotes the SGR attributes to change: 0, 1, 4, 5, 7
+CSI s Save cursor (ANSI.SYS)
+CSI ? Pm s
+ Save DEC Private Mode Values. Ps values are the same as for
+ DECSET.
+CSI Ps ; Ps ; Ps t
+ Window manipulation (from dtterm, as well as extensions).
+ These controls may be disabled using the allowWindowOps
+ resource. Valid values for the first (and any additional
+ parameters) are:
+ Ps = 1 -> De-iconify window.
+ Ps = 2 -> Iconify window.
+ Ps = 3 ; x ; y -> Move window to [x, y].
+ Ps = 4 ; height ; width -> Resize the xterm window to
+ height and width in pixels.
+ Ps = 5 -> Raise the xterm window to the front of the stack-
+ ing order.
+ Ps = 6 -> Lower the xterm window to the bottom of the
+ stacking order.
+ Ps = 7 -> Refresh the xterm window.
+ Ps = 8 ; height ; width -> Resize the text area to
+ [height;width] in characters.
+ Ps = 9 ; 0 -> Restore maximized window.
+ Ps = 9 ; 1 -> Maximize window (i.e., resize to screen
+ size).
+ Ps = 1 1 -> Report xterm window state. If the xterm window
+ is open (non-iconified), it returns CSI 1 t . If the xterm
+ window is iconified, it returns CSI 2 t .
+ Ps = 1 3 -> Report xterm window position as CSI 3 ; x; yt
+ Ps = 1 4 -> Report xterm window in pixels as CSI 4 ;
+ height ; width t
+ Ps = 1 8 -> Report the size of the text area in characters
+ as CSI 8 ; height ; width t
+ Ps = 1 9 -> Report the size of the screen in characters as
+ CSI 9 ; height ; width t
+ Ps = 2 0 -> Report xterm window's icon label as OSC L
+ label ST
+ Ps = 2 1 -> Report xterm window's title as OSC l title ST
+ Ps >= 2 4 -> Resize to Ps lines (DECSLPP)
+CSI Pt; Pl; Pb; Pr; Ps$ t
+ Reverse Attributes in Rectangular Area (DECRARA).
+ Pt; Pl; Pb; Pr denotes the rectangle.
+ Ps denotes the attributes to reverse. 1, 4, 5, 7
+CSI u Restore cursor (ANSI.SYS)
+CSI Pt; Pl; Pb; Pr; Pp; Pt; Pl; Pp$ v
+ Copy Rectangular Area (DECCRA)
+ Pt; Pl; Pb; Pr denotes the rectangle.
+ Pp denotes the source page.
+ Pt; Pl denotes the target location.
+ Pp denotes the target page.
+CSI Pt ; Pl ; Pb ; Pr ' w
+ Enable Filter Rectangle (DECEFR)
+ Parameters are [top;left;bottom;right].
+ Defines the coordinates of a filter rectangle and activates
+ it. Anytime the locator is detected outside of the filter
+ rectangle, an outside rectangle event is generated and the
+ rectangle is disabled. Filter rectangles are always treated
+ as "one-shot" events. Any parameters that are omitted default
+ to the current locator position. If all parameters are omit-
+ ted, any locator motion will be reported. DECELR always can-
+ cels any prevous rectangle definition.
+CSI Ps x Request Terminal Parameters (DECREQTPARM)
+ if Ps is a "0" (default) or "1", and xterm is emulating VT100,
+ the control sequence elicits a response of the same form whose
+ parameters describe the terminal:
+ Ps -> the given Ps incremented by 2.
+ 1 -> no parity
+ 1 -> eight bits
+ 1 2 8 -> transmit 38.4k baud
+ 1 2 8 -> receive 38.4k baud
+ 1 -> clock multiplier
+ 0 -> STP flags
+CSI Ps x Select Attribute Change Extent (DECSACE).
+ Ps = 0 -> from start to end position, wrapped
+ Ps = 1 -> from start to end position, wrapped
+ Ps = 2 -> rectangle (exact).
+CSI Pc; Pt; Pl; Pb; Pr$ x
+ Fill Rectangular Area (DECFRA).
+ Pc is the character to use.
+ Pt; Pl; Pb; Pr denotes the rectangle.
+CSI Ps ; Pu ' z
+ Enable Locator Reporting (DECELR)
+ Valid values for the first parameter:
+ Ps = 0 -> Locator disabled (default)
+ Ps = 1 -> Locator enabled
+ Ps = 2 -> Locator enabled for one report, then disabled
+ The second parameter specifies the coordinate unit for locator
+ reports.
+ Valid values for the second parameter:
+ Pu = 0 or omitted -> default to character cells
+ Pu = 1 -> device physical pixels
+ Pu = 2 -> character cells
+CSI Pt; Pl; Pb; Pr$ z
+ Erase Rectangular Area (DECERA).
+ Pt; Pl; Pb; Pr denotes the rectangle.
+CSI Pm ' {
+ Select Locator Events (DECSLE)
+ Valid values for the first (and any additional parameters)
+ are:
+ Ps = 0 -> only respond to explicit host requests (DECRQLP)
+ (default) also cancels any filter rectangle
+ Ps = 1 -> report button down transitions
+ Ps = 2 -> do not report button down transitions
+ Ps = 3 -> report button up transitions
+ Ps = 4 -> do not report button up transitions
+CSI Pt; Pl; Pb; Pr$ {
+ Selective Erase Rectangular Area (DECSERA).
+ Pt; Pl; Pb; Pr denotes the rectangle.
+CSI Ps ' |
+ Request Locator Position (DECRQLP)
+ Valid values for the parameter are:
+ Ps = 0 , 1 or omitted -> transmit a single DECLRP locator
+ report
+
+ If Locator Reporting has been enabled by a DECELR, xterm will
+ respond with a DECLRP Locator Report. This report is also
+ generated on button up and down events if they have been
+ enabled with a DECSLE, or when the locator is detected outside
+ of a filter rectangle, if filter rectangles have been enabled
+ with a DECEFR.
+
+ -> CSI Pe ; Pb ; Pr ; Pc ; Pp & w
+
+ Parameters are [event;button;row;column;page].
+ Valid values for the event:
+ Pe = 0 -> locator unavailable - no other parameters sent
+ Pe = 1 -> request - xterm received a DECRQLP
+ Pe = 2 -> left button down
+ Pe = 3 -> left button up
+ Pe = 4 -> middle button down
+ Pe = 5 -> middle button up
+ Pe = 6 -> right button down
+ Pe = 7 -> right button up
+ Pe = 8 -> M4 button down
+ Pe = 9 -> M4 button up
+ Pe = 1 0 -> locator outside filter rectangle
+ ``button'' parameter is a bitmask indicating which buttons are
+ pressed:
+ Pb = 0 -> no buttons down
+ Pb & 1 -> right button down
+ Pb & 2 -> middle button down
+ Pb & 4 -> left button down
+ Pb & 8 -> M4 button down
+ ``row'' and ``column'' parameters are the coordinates of the
+ locator position in the xterm window, encoded as ASCII deci-
+ mal.
+ The ``page'' parameter is not used by xterm, and will be omit-
+ ted.
+
+Operating System Controls
+OSC Ps ; Pt ST
+OSC Ps ; Pt BEL
+ Set Text Parameters. For colors and font, if Pt is a "?", the
+ control sequence elicits a response which consists of the con-
+ trol sequence which would set the corresponding value. The
+ dtterm control sequences allow you to determine the icon name
+ and window title.
+ Ps = 0 -> Change Icon Name and Window Title to Pt
+ Ps = 1 -> Change Icon Name to Pt
+ Ps = 2 -> Change Window Title to Pt
+ Ps = 3 -> Set X property on top-level window. Pt should be
+ in the form "prop=value", or just "prop" to delete the prop-
+ erty
+ Ps = 4 ; c ; spec -> Change Color Number c to the color
+ specified by spec, i.e., a name or RGB specification as per
+ XParseColor. Any number of c name pairs may be given. The
+ color numbers correspond to the ANSI colors 0-7, their bright
+ versions 8-15, and if supported, the remainder of the 88-color
+ or 256-color table.
+
+ If a "?" is given rather than a name or RGB specification,
+ xterm replies with a control sequence of the same form which
+ can be used to set the corresponding color. Because more than
+ one pair of color number and specification can be given in one
+ control sequence, xterm can make more than one reply.
+
+ The 8 colors which may be set using 1 0 through 1 7 are
+ denoted dynamic colors, since the corresponding control
+ sequences were the first means for setting xterm's colors
+ dynamically, i.e., after it was started. They are not the
+ same as the ANSI colors. One or more parameters is expected
+ for Pt. Each successive parameter changes the next color in
+ the list. The value of Ps tells the starting point in the
+ list. The colors are specified by name or RGB specification
+ as per XParseColor.
+
+ If a "?" is given rather than a name or RGB specification,
+ xterm replies with a control sequence of the same form which
+ can be used to set the corresponding dynamic color. Because
+ more than one pair of color number and specification can be
+ given in one control sequence, xterm can make more than one
+ reply.
+
+ Ps = 1 0 -> Change VT100 text foreground color to Pt
+ Ps = 1 1 -> Change VT100 text background color to Pt
+ Ps = 1 2 -> Change text cursor color to Pt
+ Ps = 1 3 -> Change mouse foreground color to Pt
+ Ps = 1 4 -> Change mouse background color to Pt
+ Ps = 1 5 -> Change Tektronix foreground color to Pt
+ Ps = 1 6 -> Change Tektronix background color to Pt
+ Ps = 1 7 -> Change highlight color to Pt
+ Ps = 1 8 -> Change Tektronix cursor color to Pt
+
+ Ps = 4 6 -> Change Log File to Pt (normally disabled by a
+ compile-time option)
+
+ Ps = 5 0 -> Set Font to Pt If Pt begins with a "#", index
+ in the font menu, relative (if the next character is a plus or
+ minus sign) or absolute. A number is expected but not
+ required after the sign (the default is the current entry for
+ relative, zero for absolute indexing).
+
+ Ps = 5 1 (reserved for Emacs shell)
+
+ Ps = 5 2 -> Manipulate Selection Data. These controls may
+ be disabled using the allowWindowOps resource. The parameter
+ Pt is parsed as
+ Pc; Pd
+ The first, Pc, may contain any character from the set c p s
+ 0 1 2 3 4 5 6 7 . It is used to construct a list of
+ selection parameters for clipboard, primary, select, or cut
+ buffers 0 through 8 respectively, in the order given. If the
+ parameter is empty, xterm uses s 0 , to specify the config-
+ urable primary/clipboard selection and cut buffer 0.
+ The second parameter, Pd, gives the selection data. Normally
+ this is a string encoded in base64. The data becomes the new
+ selection, which is then available for pasting by other appli-
+ cations.
+ If the second parameter is a ? , xterm replies to the host
+ with the selection data encoded using the same protocol.
+
+Privacy Message
+PM Pt ST xterm implements no PM functions; Pt is ignored. Pt need not
+ be printable characters.
+
+Alt and Meta Keys
+Many keyboards have keys labeled "Alt". Few have keys labeled "Meta".
+However, xterm's default translations use the Meta modifier. Common
+keyboard configurations assign the Meta modifier to an "Alt" key. By
+using xmodmap one may have the modifier assigned to a different key, and
+have "real" alt and meta keys. Here is an example:
+
+ ! put meta on mod3 to distinguish it from alt
+ keycode 64 = Alt_L
+ clear mod1
+ add mod1 = Alt_L
+ keycode 115 = Meta_L
+ clear mod3
+ add mod3 = Meta_L
+
+The metaSendsEscape resource (and altSendsEscape if altIsNotMeta is set)
+can be used to control the way the Meta modifier applies to ordinary
+keys unless the modifyOtherKeys resource is set:
+ - prefix a key with the ESC character.
+ - shift the key from codes 0-127 to 128-255 by adding 128.
+The table shows the result for a given character "x" with modifiers
+according to the default translations with the resources set on or off.
+This assumes altIsNotMeta is set:
+
+ -----------------------------------------------------------
+ key altSendsEscape metaSendsEscape result
+ -----------------------------------------------------------
+ x off off x
+ Meta-x off off shift
+ Alt-x off off shift
+ Alt+Meta-x off off shift
+ x ON off x
+ Meta-x ON off shift
+ Alt-x ON off ESC x
+ Alt+Meta-x ON off ESC shift
+ x off ON x
+ Meta-x off ON ESC x
+ Alt-x off ON shift
+ Alt+Meta-x off ON ESC shift
+ x ON ON x
+ Meta-x ON ON ESC x
+ Alt-x ON ON ESC x
+ Alt+Meta-x ON ON ESC x
+ -----------------------------------------------------------
+
+
+PC-Style Function Keys
+If xterm does minimal translation of the function keys, it usually does
+this with a PC-style keyboard, so PC-style function keys result. Sun
+keyboards are similar to PC keyboards. Both have cursor and scrolling
+operations printed on the keypad, which duplicate the smaller cursor and
+scrolling keypads.
+X does not predefine NumLock (used for VT220 keyboards) or Alt (used as
+an extension for the Sun/PC keyboards) as modifiers. These keys are
+recognized as modifiers when enabled by the numLock resource, or by the
+DECSET 1 0 3 5 control sequence.
+The cursor keys transmit the following escape sequences depending on the
+mode specified via the DECCKM escape sequence.
+
+ Key Normal Application
+ --------------------------------------
+ Cursor Up CSI A SS3 A
+ Cursor Down CSI B SS3 B
+ Cursor Right CSI C SS3 C
+ Cursor Left CSI D SS3 D
+ --------------------------------------
+
+The home- and end-keys (unlike PageUp and other keys also on the 6-key
+editing keypad) are considered "cursor keys" by xterm. Their mode is
+also controlled by the DECCKM escape sequence:
+
+ Key Normal Application
+ ----------------------------------
+ Home CSI H SS3 H
+ End CSI F SS3 F
+ ----------------------------------
+
+The application keypad transmits the following escape sequences depend-
+ing on the mode specified via the DECPNM and DECPAM escape sequences.
+Use the NumLock key to override the application mode.
+Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are
+supported by the program.
+
+ Key Numeric Application Terminfo Termcap
+ --------------------------------------------------------------
+ Space SP SS3 SP - -
+ Tab TAB SS3 I - -
+ Enter CR SS3 M kent @8
+ PF1 SS3 P SS3 P kf1 k1
+ PF2 SS3 Q SS3 Q kf2 k2
+ PF3 SS3 R SS3 R kf3 k3
+ PF4 SS3 S SS3 S kf4 k4
+ * (multiply) * SS3 j - -
+ + (add) + SS3 k - -
+ , (comma) , SS3 l - -
+ - (minus) - SS3 m - -
+ . (Delete) . CSI 3 ~ - -
+ / (divide) / SS3 o - -
+ 0 (Insert) 0 CSI 2 ~ - -
+ 1 (End) 1 SS3 F kc1 K4
+ 2 (DownArrow) 2 CSI B - -
+ 3 (PageDown) 3 CSI 6 ~ kc3 K5
+ 4 (LeftArrow) 4 CSI D - -
+ 5 (Begin) 5 CSI E kb2 K2
+ 6 (RightArrow) 6 CSI C - -
+ 7 (Home) 7 SS3 H ka1 K1
+ 8 (UpArrow) 8 CSI A - -
+ 9 (PageUp) 9 CSI 5 ~ ka3 K3
+ = (equal) = SS3 X - -
+ --------------------------------------------------------------
+
+They also provide 12 function keys, as well as a few other special-pur-
+pose keys.
+
+ Key Escape Sequence
+ ---------------------------
+ F1 SS3 P
+ F2 SS3 Q
+ F3 SS3 R
+ F4 SS3 S
+ F5 CSI 1 5 ~
+ F6 CSI 1 7 ~
+ F7 CSI 1 8 ~
+ F8 CSI 1 9 ~
+ F9 CSI 2 0 ~
+ F10 CSI 2 1 ~
+ F11 CSI 2 3 ~
+ F12 CSI 2 4 ~
+ ---------------------------
+
+Older versions of xterm implement different escape sequences for F1
+through F4. These can be activated by setting the oldXtermFKeys
+resource. However, since they do not correspond to any hardware termi-
+nal, they have been deprecated. (The DEC VT220 reserves F1 through F5
+for local functions such as Setup).
+
+ Key Escape Sequence
+ ---------------------------
+ F1 CSI 1 1 ~
+ F2 CSI 1 2 ~
+ F3 CSI 1 3 ~
+ F4 CSI 1 4 ~
+ ---------------------------
+
+In normal mode, i.e., a Sun/PC keyboard when the sunKeyboard resource is
+false, xterm recognizes function key modifiers which are parameters
+appended before the final character of the control sequence.
+
+ Code Modifiers
+ ---------------------------------
+ 2 Shift
+ 3 Alt
+ 4 Shift + Alt
+ 5 Control
+ 6 Shift + Control
+ 7 Alt + Control
+ 8 Shift + Alt + Control
+ ---------------------------------
+
+For example, shift-F5 would be sent as CSI 1 5 ; 2 ~
+If the alwaysUseMods resource is set, the Meta modifier also is recog-
+nized, making parameters 9 through 16.
+
+VT220-Style Function Keys
+However, xterm is most useful as a DEC VT102 or VT220 emulator. Set the
+sunKeyboard resource to true to force a Sun/PC keyboard to act like a
+VT220 keyboard.
+
+The VT102/VT220 application keypad transmits unique escape sequences in
+application mode, which are distinct from the cursor and scrolling key-
+pad:
+
+ Key Numeric Application
+ --------------------------------------
+ Space SP SS3 SP
+ Tab TAB SS3 I
+ Enter CR SS3 M
+ PF1 SS3 P SS3 P
+ PF2 SS3 Q SS3 Q
+ PF3 SS3 R SS3 R
+ PF4 SS3 S SS3 S
+ * (multiply) * SS3 j
+ + (add) + SS3 k
+ , (comma) , SS3 l
+ - (minus) - SS3 m
+ . (period) . SS3 n
+ / (divide) / SS3 o
+ 0 0 SS3 p
+ 1 1 SS3 q
+ 2 2 SS3 r
+ 3 3 SS3 s
+ 4 4 SS3 t
+ 5 5 SS3 u
+ 6 6 SS3 v
+ 7 7 SS3 w
+ 8 8 SS3 x
+ 9 9 SS3 y
+ = (equal) = SS3 X
+ --------------------------------------
+
+The VT220 provides a 6-key editing keypad, which is analogous to that on
+the PC keyboard. It is not affected by DECCKM or DECPNM/DECPAM:
+
+ Key Normal Application
+ ----------------------------------
+ Insert CSI 2 ~ CSI 2 ~
+ Delete CSI 3 ~ CSI 3 ~
+ Home CSI 1 ~ CSI 1 ~
+ End CSI 4 ~ CSI 4 ~
+ PageUp CSI 5 ~ CSI 5 ~
+ PageDown CSI 6 ~ CSI 6 ~
+ ----------------------------------
+
+The VT220 provides 8 additional function keys. With a Sun/PC keyboard,
+access these keys by Control/F1 for F13, etc.
+
+ Key Escape Sequence
+ ---------------------------
+ F13 CSI 2 5 ~
+ F14 CSI 2 6 ~
+ F15 CSI 2 8 ~
+ F16 CSI 2 9 ~
+ F17 CSI 3 1 ~
+ F18 CSI 3 2 ~
+ F19 CSI 3 3 ~
+ F20 CSI 3 4 ~
+ ---------------------------
+
+
+VT52-Style Function Keys
+A VT52 does not have function keys, but it does have a numeric keypad
+and cursor keys. They differ from the other emulations by the prefix.
+Also, the cursor keys do not change:
+
+ Key Normal/Application
+ ----------------------------------
+ Cursor Up ESC A
+ Cursor Down ESC B
+ Cursor Right ESC C
+ Cursor Left ESC D
+ ----------------------------------
+
+The keypad is similar:
+
+ Key Numeric Application
+ --------------------------------------
+ Space SP ESC ? SP
+ Tab TAB ESC ? I
+ Enter CR ESC ? M
+ PF1 ESC P ESC P
+ PF2 ESC Q ESC Q
+ PF3 ESC R ESC R
+ PF4 ESC S ESC S
+ * (multiply) * ESC ? j
+ + (add) + ESC ? k
+ , (comma) , ESC ? l
+ - (minus) - ESC ? m
+ . (period) . ESC ? n
+ / (divide) / ESC ? o
+ 0 0 ESC ? p
+ 1 1 ESC ? q
+ 2 2 ESC ? r
+ 3 3 ESC ? s
+ 4 4 ESC ? t
+ 5 5 ESC ? u
+ 6 6 ESC ? v
+ 7 7 ESC ? w
+ 8 8 ESC ? x
+ 9 9 ESC ? y
+ = (equal) = ESC ? X
+ --------------------------------------
+
+
+Sun-Style Function Keys
+The xterm program provides support for Sun keyboards more directly, by a
+menu toggle that causes it to send Sun-style function key codes rather
+than VT220. Note, however, that the sun and VT100 emulations are not
+really compatible. For example, their wrap-margin behavior differs.
+Only function keys are altered; keypad and cursor keys are the same.
+The emulation responds identically. See the xterm-sun terminfo entry
+for details.
+
+HP-Style Function Keys
+Similarly, xterm can be compiled to support HP keyboards. See the
+xterm-hp terminfo entry for details.
+
+The Alternate Screen Buffer
+Xterm maintains two screen buffers. The normal screen buffer allows you
+to scroll back to view saved lines of output up to the maximum set by
+the saveLines resource. The alternate screen buffer is exactly as large
+as the display, contains no additional saved lines. When the alternate
+screen buffer is active, you cannot scroll back to view saved lines.
+Xterm provides control sequences and menu entries for switching between
+the two.
+
+Most full-screen applications use terminfo or termcap to obtain strings
+used to start/stop full-screen mode, i.e., smcup and rmcup for terminfo,
+or the corresponding ti and te for termcap. The titeInhibit resource
+removes the ti and te strings from the TERMCAP string which is set in
+the environment for some platforms. That is not done when xterm is
+built with terminfo libraries because terminfo does not provide the
+whole text of the termcap data in one piece. It would not work for ter-
+minfo anyway, since terminfo data is not passed in environment vari-
+ables; setting an environment variable in this manner would have no
+effect on the application's ability to switch between normal and alter-
+nate screen buffers. Instead, the newer private mode controls (such as
+1 0 4 9 ) for switching between normal and alternate screen buffers sim-
+ply disable the switching. They add other features such as clearing the
+display for the same reason: to make the details of switching indepen-
+dent of the application that requests the switch.
+
+Bracketed Paste Mode
+When bracketed paste mode is set, pasted text is bracketed with control
+sequences so that the program can differentiate pasted text from typed-
+in text. When bracketed paste mode is set, the program will receive:
+ESC [ 200 ~, followed by the pasted text, followed by ESC [ 201 ~.
+
+Mouse Tracking
+The VT widget can be set to send the mouse position and other informa-
+tion on button presses. These modes are typically used by editors and
+other full-screen applications that want to make use of the mouse.
+
+There are six mutually exclusive modes. One is DEC Locator mode,
+enabled by the DECELR CSI Ps ; Ps ' z control sequence, and is not
+described here (control sequences are summarized above). The remaining
+five modes are each enabled (or disabled) by a different parameter in
+DECSET CSI ? Pm h or DECRST CSI ? Pm l control sequence.
+
+Manifest constants for the parameter values are defined in xcharmouse.h
+as follows:
+
+ #define SET_X10_MOUSE 9
+ #define SET_VT200_MOUSE 1000
+ #define SET_VT200_HIGHLIGHT_MOUSE 1001
+ #define SET_BTN_EVENT_MOUSE 1002
+ #define SET_ANY_EVENT_MOUSE 1003
+
+ #define SET_FOCUS_EVENT_MOUSE 1004
+
+The motion reporting modes are strictly xterm extensions, and are not
+part of any standard, though they are analogous to the DEC VT200 DECELR
+locator reports.
+
+Parameters (such as pointer position and button number) for all mouse
+tracking escape sequences generated by xterm encode numeric parameters
+in a single character as value+32. For example, ! specifies the value
+1. The upper left character position on the terminal is denoted as 1,1.
+
+X10 compatibility mode sends an escape sequence only on button press,
+encoding the location and the mouse button pressed. It is enabled by
+specifying parameter 9 to DECSET. On button press, xterm sends CSI M
+CbCxCy (6 characters). Cb is button-1. Cx and Cy are the x and y coor-
+dinates of the mouse when the button was pressed.
+
+Normal tracking mode sends an escape sequence on both button press and
+release. Modifier key (shift, ctrl, meta) information is also sent. It
+is enabled by specifying parameter 1000 to DECSET. On button press or
+release, xterm sends CSI M CbCxCy. The low two bits of Cb encode button
+information: 0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release.
+The next three bits encode the modifiers which were down when the button
+was pressed and are added together: 4=Shift, 8=Meta, 16=Control. Note
+however that the shift and control bits are normally unavailable because
+xterm uses the control modifier with mouse for popup menus, and the
+shift modifier is used in the default translations for button events.
+The Meta modifier recognized by xterm is the mod1 mask, and is not nec-
+essarily the "Meta" key (see xmodmap). Cx and Cy are the x and y coor-
+dinates of the mouse event, encoded as in X10 mode.
+
+Wheel mice may return buttons 4 and 5. Those buttons are represented by
+the same event codes as buttons 1 and 2 respectively, except that 64 is
+added to the event code. Release events for the wheel buttons are not
+reported.
+
+Mouse highlight tracking notifies a program of a button press, receives
+a range of lines from the program, highlights the region covered by the
+mouse within that range until button release, and then sends the program
+the release coordinates. It is enabled by specifying parameter 1001 to
+DECSET. Highlighting is performed only for button 1, though other but-
+ton events can be received. Warning: use of this mode requires a coop-
+erating program or it will hang xterm. On button press, the same infor-
+mation as for normal tracking is generated; xterm then waits for the
+program to send mouse tracking information. All X events are ignored
+until the proper escape sequence is received from the pty: CSI Ps ; Ps ;
+Ps ; Ps ; Ps T . The parameters are func, startx, starty, firstrow, and
+lastrow. func is non-zero to initiate highlight tracking and zero to
+abort. startx and starty give the starting x and y location for the
+highlighted region. The ending location tracks the mouse, but will
+never be above row firstrow and will always be above row lastrow. (The
+top of the screen is row 1.) When the button is released, xterm reports
+the ending position one of two ways: if the start and end coordinates
+are valid text locations: CSI t CxCy. If either coordinate is past the
+end of the line: CSI T CxCyCxCyCxCy. The parameters are startx, starty,
+endx, endy, mousex, and mousey. startx, starty, endx, and endy give the
+starting and ending character positions of the region. mousex and
+mousey give the location of the mouse at button up, which may not be
+over a character.
+
+Button-event tracking is essentially the same as normal tracking, but
+xterm also reports button-motion events. Motion events are reported
+only if the mouse pointer has moved to a different character cell. It
+is enabled by specifying parameter 1002 to DECSET. On button press or
+release, xterm sends the same codes used by normal tracking mode. On
+button-motion events, xterm adds 32 to the event code (the third charac-
+ter, Cb). The other bits of the event code specify button and modifier
+keys as in normal mode. For example, motion into cell x,y with button 1
+down is reported as CSI M @ CxCy. ( @ = 32 + 0 (button 1) + 32 (motion
+indicator) ). Similarly, motion with button 3 down is reported as CSI M
+B CxCy. ( B = 32 + 2 (button 3) + 32 (motion indicator) ).
+
+Any-event mode is the same as button-event mode, except that all motion
+events are reported, even if no mouse button is down. It is enabled by
+specifying 1003 to DECSET.
+
+FocusIn/FocusOut can be combined with any of the mouse events since it
+uses a different protocol. When set, it causes xterm to send CSI I
+when the terminal gains focus, and CSI O when it loses focus.
+
+Tektronix 4014 Mode
+Most of these sequences are standard Tektronix 4014 control sequences.
+Graph mode supports the 12-bit addressing of the Tektronix 4014. The
+major features missing are the write-through and defocused modes. This
+document does not describe the commands used in the various Tektronix
+plotting modes but does describe the commands to switch modes.
+
+BEL Bell (Ctrl-G)
+BS Backspace (Ctrl-H)
+TAB Horizontal Tab (Ctrl-I)
+LF Line Feed or New Line (Ctrl-J)
+VT Cursor up (Ctrl-K)
+FF Form Feed or New Page (Ctrl-L)
+CR Carriage Return (Ctrl-M)
+ESC ETX Switch to VT100 Mode (ESC Ctrl-C)
+ESC ENQ Return Terminal Status (ESC Ctrl-E)
+ESC FF PAGE (Clear Screen) (ESC Ctrl-L)
+ESC SO Begin 4015 APL mode (ignored by xterm) (ESC Ctrl-N)
+ESC SI End 4015 APL mode (ignored by xterm) (ESC Ctrl-O)
+ESC ETB COPY (Save Tektronix Codes to file COPYyyyy-mm-dd.hh:mm:ss)
+ (ESC Ctrl-W)
+ESC CAN Bypass Condition (ESC Ctrl-X)
+ESC SUB GIN mode (ESC Ctrl-Z)
+ESC FS Special Point Plot Mode (ESC Ctrl-\)
+ESC 8 Select Large Character Set
+ESC 9 Select #2 Character Set
+ESC : Select #3 Character Set
+ESC ; Select Small Character Set
+OSC Ps ; Pt BEL
+ Set Text Parameters of VT window
+ Ps = 0 -> Change Icon Name and Window Title to Pt
+ Ps = 1 -> Change Icon Name to Pt
+ Ps = 2 -> Change Window Title to Pt
+ Ps = 4 6 -> Change Log File to Pt (normally disabled by a
+ compile-time option)
+ESC ` Normal Z Axis and Normal (solid) Vectors
+ESC a Normal Z Axis and Dotted Line Vectors
+ESC b Normal Z Axis and Dot-Dashed Vectors
+ESC c Normal Z Axis and Short-Dashed Vectors
+ESC d Normal Z Axis and Long-Dashed Vectors
+ESC h Defocused Z Axis and Normal (solid) Vectors
+ESC i Defocused Z Axis and Dotted Line Vectors
+ESC j Defocused Z Axis and Dot-Dashed Vectors
+ESC k Defocused Z Axis and Short-Dashed Vectors
+ESC l Defocused Z Axis and Long-Dashed Vectors
+ESC p Write-Thru Mode and Normal (solid) Vectors
+ESC q Write-Thru Mode and Dotted Line Vectors
+ESC r Write-Thru Mode and Dot-Dashed Vectors
+ESC s Write-Thru Mode and Short-Dashed Vectors
+ESC t Write-Thru Mode and Long-Dashed Vectors
+FS Point Plot Mode (Ctrl-\)
+GS Graph Mode (Ctrl-])
+RS Incremental Plot Mode (Ctrl-^)
+US Alpha Mode (Ctrl-_)
+
+VT52 Mode
+Parameters for cursor movement are at the end of the ESC Y escape
+sequence. Each ordinate is encoded in a single character as value+32.
+For example, ! is 1. The screen coordinate system is 0-based.
+
+ESC A Cursor up.
+ESC B Cursor down.
+ESC C Cursor right.
+ESC D Cursor left.
+ESC F Enter graphics mode.
+ESC G Exit graphics mode.
+ESC H Move the cursor to the home position.
+ESC I Reverse line feed.
+ESC J Erase from the cursor to the end of the screen.
+ESC K Erase from the cursor to the end of the line.
+ESC Y Ps Ps
+ Move the cursor to given row and column.
+ESC Z Identify
+ -> ESC / Z (``I am a VT52.'')
+ESC = Enter alternate keypad mode.
+ESC > Exit alternate keypad mode.
+ESC < Exit VT52 mode (Enter VT100 mode).
235 doc/xtermcontrol.roff
@@ -0,0 +1,235 @@
+.SH NAME
+.\" the x macro is the package name
+\*x \- dynamic control of XFree86 xterm properties.
+.\"
+.\" "SYNOPSIS"
+.\"
+.SH SYNOPSIS
+.B \*x
+.RI [OPTIONS] ...
+.\"
+.\" "DESCRIPTION"
+.\"
+.SH DESCRIPTION
+.B \*x
+makes it easy to change colors, title, font and geometry of a running XFree86
+\fBxterm(1)\fR, as well as to report the current settings of the aforementioned
+properties.
+
+Window manipulations de\-/iconify, raise/lower, maximize/restore and reset
+are also supported.
+
+To complete the feature set; \*x lets advanced users issue any xterm control
+sequence of their choosing.
+.br
+.\"
+.\" "OPTIONS"
+.\"
+.SH OPTIONS
+.IP "\fB\-\-fg\fR=\fICOLOR\fR"
+Set foreground color (see also \fBCOLOR NAMES\fR).
+.IP "\fB\-\-bg\fR=\fICOLOR\fR"
+Set background color.
+.IP "\fB\-\-color\fIN\fR=\fICOLOR\fR"
+Set N'th [0-15] color.
+.IP "\fB\-\-highlight\fR=\fICOLOR\fR"
+Set highlight color.
+.IP "\fB\-\-cursor\fR=\fICOLOR\fR"
+Set cursor color.
+.IP "\fB\-\-mouse\-fg\fR=\fICOLOR\fR"
+Set mouse pointer foreground color.
+.IP "\fB\-\-mouse\-bg\fR=\fICOLOR\fR"
+Set mouse pointer background color.
+.IP "\fB\-\-font\fR=\fIFONT\fR"
+Set font name (see also \fBFONT NAMES\fR). Alternatively it is possible to specify
+a fontmenu index as \'#[0-6]\' or navigate the fontmenu by
+relative sizes as \'#+N\' or \'#-N\', where N is an optional integer.
+.IP "\fB\-\-title\fR=\fISTRING\fR"
+Set window title. Note that mechanisms like the \fBbash(1)\fR
+PROMPT_COMMAND may overwrite the title.
+.IP "\fB\-\-geometry\fR=\fIWIDTHxHEIGHT+XOFF+YOFF\fR"
+Set size and/or position. Through its control sequences the xterm only
+recognize positive \fIXOFF\fR and \fIYOFF\fR offsets, which are pixels relative to the
+upper left hand corner of the display. \*x is therefore unable to
+handle negative offsets as described in the \fBX(7x)\fR GEOMETRY SPECIFICATIONS
+and therefore truncates negative values to zero.
+.IP "\fB\-\-get\-fg\fR"
+Report foreground color.
+.IP "\fB\-\-get\-bg\fR"
+Report background color.
+.IP "\fB\-\-get\-color\fIN\fR"
+Report N'th [0-15] color.
+.IP "\fB\-\-get\-highlight\fR"
+Report highlight color.
+.IP "\fB\-\-get\-cursor\fR"
+Report cursor color.
+.IP "\fB\-\-get\-mouse\-fg\fR"
+Report mouse pointer foreground color.
+.IP "\fB\-\-get\-mouse\-bg\fR"
+Report mouse pointer background color.
+.IP "\fB\-\-get\-font\fR"
+Report font.
+.IP "\fB\-\-get\-title\fR"
+Report window title.
+.IP "\fB\-\-get\-geometry\fR"
+Report size and position. The size of the text area is reported in characters and
+the position is reported in pixels relative to the upper left hand corner of the display.
+.IP "\fB\-\-maximize\fR"
+Maximize window.
+.IP "\fB\-\-restore\fR"
+Restore maximized window.
+.IP "\fB\-\-iconify\fR"
+Iconify window.
+.IP "\fB\-\-de\-iconify\fR"
+De\-iconify window.
+.IP "\fB\-\-raise\fR"
+Raise window.
+.IP "\fB\-\-lower\fR"
+Lower window.
+.IP "\fB\-\-reset\fR"
+Full reset.
+.IP "\fB\-\-raw\fR=\fICTLSEQS\fR"
+Issue raw control sequence (see also \fBXTERM CONTROL SEQUENCES\fR).
+.IP "\fB\-\-file\fR=\fIFILE\fR"
+Force \*x to read configurations (see also \fBCONFIGURATION\fR) from \fIFILE\fR
+instead of the standard personal initialization file ~/.\*x.
+.IP "\fB\-\-force\fR, \fB\-f\fR"
+Skip TERM environment variable check.
+.IP "\fB\-\-verbose\fR, \fB\-v\fR"
+Print verbose reports.
+.IP "\fB\-\-help\fR, \fB\-h\fR"
+Print help message and exit.
+.IP "\fB\-\-version\fR"
+Print the version number and exit.
+.\"
+.\" "CONFIGURATION"
+.\"
+.SH CONFIGURATION
+\*x reads a default, ~/.\*x, or a user specified
+configuration file on startup.
+Each line in the file is either a comment or contains an attribute.
+Attributes consist of a keyword and an associated value:
+.nf
+.sp
+ keyword = value # comment
+.sp
+.fi
+The valid keyword/value combinations are:
+.nf
+.sp
+ foreground="COLOR"
+ background="COLOR"
+ highlight="COLOR"
+ cursor="COLOR"
+ mouse\-foreground="COLOR"
+ mouse\-background="COLOR"
+ geometry="WIDTHxHEIGHT+XOFF+YOFF"
+ font="FONT"
+ color0="COLOR"
+ color1="COLOR"
+ color2="COLOR"
+ color3="COLOR"
+ color4="COLOR"
+ color5="COLOR"
+ color6="COLOR"
+ color7="COLOR"
+ color8="COLOR"
+ color9="COLOR"
+ color10="COLOR"
+ color11="COLOR"
+ color12="COLOR"
+ color13="COLOR"
+ color14="COLOR"
+ color15="COLOR"
+.sp
+.fi
+Whitespace is ignored in attributes unless within a quoted value. The
+character \'#\' is taken to begin a comment. Each \'#\'
+and all remaining characters on that line is ignored.
+.\"
+.\" "FONT NAMES"
+.\"
+.SH FONT NAMES
+\*x accepts any \fBX(7x)\fR FONT NAMES.
+Font names like \'-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1\' are
+very cumbersome to write, so it is convenient to make use of aliases, e.g.
+\'fixed\' or \'8x13\', if present in fonts.alias files of the font directories.
+.\"
+.\" "COLOR NAMES"
+.\"
+.SH COLOR NAMES
+\*x accepts any \fBX(7x)\fR COLOR NAMES.
+Basically this means that colors are specified by name or rgb value, e.g. \'blue\',
+\'rgb:0000/0000/FFFF\' or \'#00F\'. Colors are typically reported by the
+xterm in a device-dependent numerical form, e.g. \'rgb:0000/0000/FFFF\'.
+Note that old syntax rgb values should always be quoted to avoid \'#\' being
+interpreted as the beginning of a comment by the shell (see also \fBFILES\fR).
+.\"
+.\" "XTERM CONTROL SEQUENCES"
+.\"
+.SH XTERM CONTROL SEQUENCES
+The secret behind \*x is xterm control sequences. All the possible
+(there are a plethora of them) control sequences are documented in ctlseqs.txt,
+found in the \fBxterm(1)\fR distribution (see also \fBFILES\fR).
+.\"
+.\" "BUGS"
+.\"
+.SH TROUBLESHOOTING
+If read/write permissions on the tty's are changed so
+that special group membership is required to be able to write to the pseudo terminal,
+the easiest workaround is to install \*x setuid root.
+
+\fBXterm(1)\fR has three resources, allowWindowOps, allowTitleOps, and
+allowFontOps, that enables or disables special operations which \*x relies on.
+If any of these resources are set (or defaults) to 'false' \*x may hang.
+The resources corresponds to \*x options as:
+.nf
+.sp
+ allowWindowOps:
+ --raise
+ --lower
+ --restore
+ --maximize
+ --iconify
+ --de-iconify
+ --get-title
+ --geometry
+ --get-geometry
+
+ allowTitleOps:
+ --title
+
+ allowFontOps:
+ --font
+ --get-font
+.sp
+.fi
+All three resources can usually be enabled for the current xterm session via a menu; ctrl+rightclick and look for menu item names like 'Allow Window Ops'. To set these resource values persistently you can add the following to either your local ~/.Xdefaults file, or to a system-wide resource file like /etc/X11/app-defaults/XTerm:
+.nf
+.sp
+ *VT100.allowWindowOps: true
+ *VT100.allowTitleOps: true
+ *VT100.allowFontOps: true
+.sp
+.fi
+.\"
+.\" "FILES"
+.\"
+.SH FILES
+.IP <XRoot>/X11/rgb.txt
+Default rgb color name file location.
+.IP ctlseqs.txt
+Xterm control sequences documentation. Distributed with xterm from
+http://dickey.his.com/xterm/
+.\"
+.\" "SEE ALSO"
+.\"
+.SH "SEE ALSO"
+.BR xterm(1),
+.B X(7x)
+.\"
+.\" "EOF"
+.\"
+.SH COPYRIGHT
+Copyright \(co 2002-2009 Jess Thrysoee <jess@thrysoee.dk>
+
8 src/Makefile.am
@@ -0,0 +1,8 @@
+
+#AM_CFLAGS = -ggdb -pedantic -Wall
+
+bin_PROGRAMS = xtermcontrol
+
+xtermcontrol_SOURCES = xtermcontrol.c configuration.c getopt1.c getopt.c
+
+noinst_HEADERS = xtermcontrol.h configuration.h getopt.h
227 src/configuration.c
@@ -0,0 +1,227 @@
+/****************************************************************************
+** $Id: configuration.c,v 1.17 2002/10/26 17:20:36 jet Exp $
+**
+** Copyright (C) 2002-2007 Jess Thrysoee <jess@thrysoee.dk>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+****************************************************************************/
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <regex.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "configuration.h"
+
+static void configuration_add(configuration* list, const char* keyword, const char* value);
+static void do_regerror(int errcode, const regex_t *preg);
+
+void
+configuration_init(configuration* list)
+{
+ list->n_elements = 0;
+ list->first = NULL;
+}
+
+int
+configuration_read(configuration* list, const char* filepath)
+{
+ int errcode;
+ char temp[BUFSIZ];
+ size_t matchlen;
+
+ FILE* stream;
+ char* value, *p;
+ char* keyword;
+
+ regex_t preg;
+ regmatch_t* pmatch;
+ const char* regex;
+
+ stream = fopen(filepath, "r");
+ if (stream == NULL) {
+ return -1;
+ }
+
+ /*
+ * match: 'keyword=value'
+ * and : 'keyword = value'
+ * and : '"key word" = value'
+ * and : 'keyword = value # comment'
+ * and : 'keyword = value1 value2 # comment'
+ * and : 'keyword = #ffffff'
+ * not : '#keyword = value'
+ */
+ regex = "^[ \t\"']*([^#]*[^ \t\"'#])[ \t\"']*=[ \t\"']*(#?[^\"'#]*)";
+ errcode = regcomp(&preg, regex, REG_EXTENDED | REG_NEWLINE);
+ if (errcode) {
+ do_regerror(errcode, &preg);
+ return -1;
+ }
+ pmatch = (regmatch_t*) malloc(sizeof(regmatch_t) * (preg.re_nsub+1));
+ if (!pmatch) {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
+
+ while (fgets(temp, sizeof(temp), stream) != NULL) {
+ /* fgets keeps the newline - delete it */
+ if((p = strchr(temp, '\n')) != NULL)
+ *p = '\0';
+ errcode = regexec(&preg, temp, (preg.re_nsub+1), pmatch, 0);
+ if (errcode) {
+ /* line did not match */
+ continue;
+ }
+ /* ignore pmatch[0] which is the entire match */
+
+ /* keyword */
+ if (pmatch[1].rm_so != -1) {
+ matchlen = pmatch[1].rm_eo - pmatch[1].rm_so;
+ keyword = (char*) malloc(matchlen+1);
+ if (!keyword) {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
+ strncpy(keyword, temp+pmatch[1].rm_so, matchlen);
+ keyword[matchlen] = '\0';
+ } else {
+ fprintf(stderr, "missing keyword: %s\n", temp);
+ continue;
+ }
+ /* value */
+ if (pmatch[2].rm_so != -1) {
+ matchlen = pmatch[2].rm_eo - pmatch[2].rm_so;
+ value = (char*) malloc(matchlen+1);
+ if (!value) {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
+ strncpy(value, temp+pmatch[2].rm_so, matchlen);
+ value[matchlen] = '\0';
+ } else {
+ fprintf(stderr, "missing value: %s\n", temp);
+ free(keyword);
+ keyword = NULL;
+ continue;
+ }
+ configuration_add(list, keyword, value);
+
+ free(keyword);
+ keyword = NULL;
+ free(value);
+ value = NULL;
+ }
+
+ free(pmatch);
+ regfree(&preg);
+ fclose(stream);
+
+ return 0;
+}
+
+static void
+configuration_add(configuration* list, const char* keyword, const char* value)
+{
+ configuration_element* new_element;
+
+ /* check if keyword already exists */
+ new_element = (configuration_element*) configuration_find(list, keyword);
+ if (new_element) {
+ if (new_element->value) {
+ free(new_element->value);
+ new_element->value = NULL;
+ }
+ } else {
+ /* allocate mem for the struct */
+ new_element = (configuration_element*) malloc(sizeof(configuration_element));
+ if (!new_element) {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
+
+ /* allocate mem for the keyword */
+ new_element->keyword = (char*) malloc(strlen(keyword)+1);
+ if (new_element->keyword)
+ strcpy(new_element->keyword, keyword);
+ else {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
+
+ /* link */
+ new_element->next = list->first;
+ list->first = new_element;
+ list->n_elements++;
+ }
+
+ /* allocate mem for the value */
+ new_element->value = (char*) malloc(strlen(value)+1);
+ if (new_element->value)
+ strcpy(new_element->value, value);
+ else {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
+}
+
+void
+configuration_free(configuration* list)
+{
+ configuration_element *lp, *lp_next;
+
+ for (lp_next = list->first; lp_next != NULL; ) {
+ lp = lp_next;
+ lp_next = lp_next->next;
+ if (lp->keyword) {
+ free(lp->keyword);
+ lp->keyword = NULL;
+ }
+ if (lp->value) {
+ free(lp->value);
+ lp->value = NULL;
+ }
+ free(lp);
+ }
+ list->first = NULL;
+ list->n_elements = 0;
+}
+
+const configuration_element*
+configuration_find(configuration* list, const char* keyword)
+{
+ configuration_element *lp = NULL;
+
+ if (!keyword)
+ return NULL;
+
+ for (lp = list->first; lp != NULL; lp = lp->next)
+ if (strcmp(lp->keyword, keyword) == 0)
+ break;
+
+ return lp;
+}
+
+static void
+do_regerror(int errcode, const regex_t *preg)
+{
+ char* errbuf;
+ size_t errbuf_size;
+
+ errbuf_size = regerror(errcode, preg, NULL, 0);
+ errbuf = (char*) malloc(errbuf_size);
+ if (!errbuf) {
+ fprintf(stderr, "out of memory\n");
+ exit(8);
+ }
+ regerror(errcode, preg, errbuf, errbuf_size);
+ fprintf(stderr, "%s\n", errbuf);
+
+ free(errbuf);
+}
72 src/configuration.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+** $Id: configuration.h,v 1.5 2002/08/01 21:54:17 jet Exp $
+**
+** Copyright (C) 2002-2007 Jess Thrysoee <jess@thrysoee.dk>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+****************************************************************************/
+
+/* Configuration files must be plain ascii test file. Each line in the file is
+ * either a comment or contains an attribute. Attributes consist of a keyword
+ * and an associated value:
+ *
+ * keyword = value # comment
+ *
+ * Whitespace is ignored in attributes unless within a quoted value. The
+ * character '#' is taken to begin a comment. Each '#' and all remaining
+ * characters on that line is ignored.
+ *
+ *
+ * EXAMPLE:
+ *
+ * char path[BUFSIZ];
+ * configuration list;
+ * const configuration_element *lp;
+ *
+ * configuration_init(&list)
+ * configuration_read(&list, "/etc/application.conf");
+ * snprintf(path, sizeof(path), "%s/.%s", getenv("HOME"), "application");
+ * configuration_read(&list, path);
+ *
+ * for (lp = list.first; lp != NULL; lp = lp->next) {
+ * printf("key:%s value:%s\n", lp->keyword, lp->value);
+ * }
+ *
+ * if (lp = configuration_find(&list, "example_keyword"))
+ * printf("found %s with value %s\n", lp->keyword, lp->value);
+ *
+ * configuration_free(&list);
+ */
+
+#ifndef CONFIGURATION_H
+#define CONFIGURATION_H
+
+typedef struct configuration_element {
+ struct configuration_element* next;
+ char* keyword;
+ char* value;
+} configuration_element;
+
+typedef struct configuration {
+ struct configuration_element* first;
+ int n_elements;
+} configuration;
+
+/* configuration.c */
+extern void configuration_init(configuration* list);
+extern int configuration_read(configuration* list, const char* filepath);
+extern void configuration_free(configuration* list);
+extern const configuration_element* configuration_find(configuration* list, const char* keyword);
+
+/* something like the following function should be created to write the
+ * configuration to a file, but it will always be very implementation specific,
+ * so it is left to be done per project and not in this library.
+
+extern int configuration_write(const char* filepath);
+*/
+
+#endif /* CONFIGURATION_H */
1,252 src/getopt.c
@@ -0,0 +1,1252 @@
+/* Getopt for GNU.
+ NOTE: getopt is now part of the C library, so if you don't know what
+ "Keep this file name-space clean" means, talk to drepper@gnu.org
+ before changing it!
+ Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
+ Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
+ Ditto for AIX 3.2 and <stdlib.h>. */
+#ifndef _NO_PROTO
+# define _NO_PROTO
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if !defined __STDC__ || !__STDC__
+/* This is a separate conditional since some stdc systems
+ reject `defined (const)'. */
+# ifndef const
+# define const
+# endif
+#endif
+
+#include <stdio.h>
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#define GETOPT_INTERFACE_VERSION 2
+#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
+# include <gnu-versions.h>
+# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
+# define ELIDE_CODE
+# endif
+#endif
+
+#ifndef ELIDE_CODE
+
+
+/* This needs to come after some library #include
+ to get __GNU_LIBRARY__ defined. */
+#ifdef __GNU_LIBRARY__
+/* Don't include stdlib.h for non-GNU C libraries because some of them
+ contain conflicting prototypes for getopt. */
+# include <stdlib.h>
+# include <unistd.h>
+#endif /* GNU C library. */
+
+#ifdef VMS
+# include <unixlib.h>
+# if HAVE_STRING_H - 0
+# include <string.h>
+# endif
+#endif
+
+#ifndef _
+/* This is for other GNU distributions with internationalized messages. */
+# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
+# include <libintl.h>
+# ifndef _
+# define _(msgid) gettext (msgid)
+# endif
+# else
+# define _(msgid) (msgid)
+# endif
+# if defined _LIBC && defined USE_IN_LIBIO
+# include <wchar.h>
+# endif
+#endif
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+ but it behaves differently for the user, since it allows the user
+ to intersperse the options with the other arguments.
+
+ As `getopt' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+
+ Setting the environment variable POSIXLY_CORRECT disables permutation.
+ Then the behavior is completely standard.
+
+ GNU application programs can use a third alternative mode in which
+ they can distinguish the relative order of options and other arguments. */
+
+#include "getopt.h"
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns -1, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+/* 1003.2 says this must be 1 before any call. */
+int optind = 1;
+
+/* Formerly, initialization of getopt depended on optind==0, which
+ causes problems with re-calling getopt as programs generally don't
+ know that. */
+
+int __getopt_initialized;
+
+/* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+
+static char *nextchar;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Set to an option character which was unrecognized.
+ This must be initialized on some systems to avoid linking in the
+ system's own getopt implementation. */
+
+int optopt = '?';
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we scan,
+ so that eventually all the non-options are at the end. This allows options
+ to be given in any order, even with programs that were not written to
+ expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were written
+ to expect options and other ARGV-elements in any order and that care about
+ the ordering of the two. We describe each non-option ARGV-element
+ as if it were the argument of an option with character code 1.
+ Using `-' as the first character of the list of option characters
+ selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return -1 with `optind' != ARGC. */
+
+static enum
+{
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+} ordering;
+
+/* Value of POSIXLY_CORRECT environment variable. */
+static char *posixly_correct;
+
+#ifdef __GNU_LIBRARY__
+/* We want to avoid inclusion of string.h with non-GNU libraries
+ because there are many ways it can cause trouble.
+ On some systems, it contains special magic macros that don't work
+ in GCC. */
+# include <string.h>
+# define my_index strchr
+#else
+
+# if HAVE_STRING_H
+# include <string.h>
+# else
+# include <strings.h>
+# endif
+
+/* Avoid depending on library functions or files
+ whose names are inconsistent. */
+
+#ifndef getenv
+extern char *getenv ();
+#endif
+
+static char *
+my_index (str, chr)
+ const char *str;
+ int chr;
+{
+ while (*str)
+ {
+ if (*str == chr)
+ return (char *) str;
+ str++;
+ }
+ return 0;
+}
+
+/* If using GCC, we can safely declare strlen this way.
+ If not using GCC, it is ok not to declare it. */
+#ifdef __GNUC__
+/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
+ That was relevant to code that was here before. */
+# if (!defined __STDC__ || !__STDC__) && !defined strlen
+/* gcc with -traditional declares the built-in strlen to return int,
+ and has done so at least since version 2.4.5. -- rms. */
+extern int strlen (const char *);
+# endif /* not __STDC__ */
+#endif /* __GNUC__ */
+
+#endif /* not __GNU_LIBRARY__ */
+
+/* Handle permutation of arguments. */
+
+/* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
+ `last_nonopt' is the index after the last of them. */
+
+static int first_nonopt;
+static int last_nonopt;
+
+#ifdef _LIBC
+/* Stored original parameters.
+ XXX This is no good solution. We should rather copy the args so
+ that we can compare them later. But we must not use malloc(3). */
+extern int __libc_argc;
+extern char **__libc_argv;
+
+/* Bash 2.0 gives us an environment variable containing flags
+ indicating ARGV elements that should not be considered arguments. */
+
+# ifdef USE_NONOPTION_FLAGS
+/* Defined in getopt_init.c */
+extern char *__getopt_nonoption_flags;
+
+static int nonoption_flags_max_len;
+static int nonoption_flags_len;
+# endif
+
+# ifdef USE_NONOPTION_FLAGS
+# define SWAP_FLAGS(ch1, ch2) \
+ if (nonoption_flags_len > 0) \
+ { \
+ char __tmp = __getopt_nonoption_flags[ch1]; \
+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
+ __getopt_nonoption_flags[ch2] = __tmp; \
+ }
+# else
+# define SWAP_FLAGS(ch1, ch2)
+# endif
+#else /* !_LIBC */
+# define SWAP_FLAGS(ch1, ch2)
+#endif /* _LIBC */
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+#if defined __STDC__ && __STDC__
+static void exchange (char **);
+#endif
+
+static void
+exchange (argv)
+ char **argv;
+{
+ int bottom = first_nonopt;
+ int middle = last_nonopt;
+ int top = optind;
+ char *tem;
+
+ /* Exchange the shorter segment with the far end of the longer segment.
+ That puts the shorter segment into the right place.
+ It leaves the longer segment in the right place overall,
+ but it consists of two parts that need to be swapped next. */
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ /* First make sure the handling of the `__getopt_nonoption_flags'
+ string can work normally. Our top argument must be in the range
+ of the string. */
+ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
+ {
+ /* We must extend the array. The user plays games with us and
+ presents new arguments. */
+ char *new_str = malloc (top + 1);
+ if (new_str == NULL)
+ nonoption_flags_len = nonoption_flags_max_len = 0;
+ else
+ {
+ memset (__mempcpy (new_str, __getopt_nonoption_flags,
+ nonoption_flags_max_len),
+ '\0', top + 1 - nonoption_flags_max_len);
+ nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
+ }
+ }
+#endif
+
+ while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
+ {
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS (bottom + i, middle + i);
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
+ }
+ }
+
+ /* Update records for the slots the non-options now occupy. */
+
+ first_nonopt += (optind - last_nonopt);
+ last_nonopt = optind;
+}
+
+/* Initialize the internal data when the first call is made. */
+
+#if defined __STDC__ && __STDC__
+static const char *_getopt_initialize (int, char *const *, const char *);
+#endif
+static const char *
+_getopt_initialize (argc, argv, optstring)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+{
+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+
+ first_nonopt = last_nonopt = optind;
+
+ nextchar = NULL;
+
+ posixly_correct = getenv ("POSIXLY_CORRECT");
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+
+ if (optstring[0] == '-')
+ {
+ ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (posixly_correct != NULL)
+ ordering = REQUIRE_ORDER;
+ else
+ ordering = PERMUTE;
+
+#if defined _LIBC && defined USE_NONOPTION_FLAGS
+ if (posixly_correct == NULL
+ && argc == __libc_argc && argv == __libc_argv)
+ {
+ if (nonoption_flags_max_len == 0)
+ {
+ if (__getopt_nonoption_flags == NULL
+ || __getopt_nonoption_flags[0] == '\0')
+ nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str = __getopt_nonoption_flags;
+ int len = nonoption_flags_max_len = strlen (orig_str);
+ if (nonoption_flags_max_len < argc)
+ nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags =
+ (char *) malloc (nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ nonoption_flags_max_len = -1;
+ else
+ memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
+ '\0', nonoption_flags_max_len - len);
+ }
+ }
+ nonoption_flags_len = nonoption_flags_max_len;
+ }
+ else
+ nonoption_flags_len = 0;
+#endif
+
+ return optstring;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If `getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If `getopt' finds another option character, it returns that character,
+ updating `optind' and `nextchar' so that the next call to `getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, `getopt' returns -1.
+ Then `optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return '?' after printing an error message. If you set `opterr' to
+ zero, the error message is suppressed but we still return '?'.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following