Initial commit for Tizen Extras 2.0alpha accepted/2.0alpha/20130201.184657 submit/2.0alpha/20130201.191058
authorGraydon, Tracy <tracy.graydon@intel.com>
Fri, 1 Feb 2013 19:10:31 +0000 (11:10 -0800)
committerGraydon, Tracy <tracy.graydon@intel.com>
Fri, 1 Feb 2013 19:10:31 +0000 (11:10 -0800)
171 files changed:
256colres.h [new file with mode: 0644]
256colres.pl [new file with mode: 0755]
88colres.h [new file with mode: 0644]
88colres.pl [new file with mode: 0755]
AAA_README_VMS.txt [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Imakefile [new file with mode: 0644]
KOI8RXTerm.ad [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
README [new file with mode: 0644]
README.i18n [new file with mode: 0644]
README.os390 [new file with mode: 0644]
THANKS [new file with mode: 0644]
TekPrsTbl.c [new file with mode: 0644]
Tekparse.def [new file with mode: 0644]
Tekparse.h [new file with mode: 0644]
Tekproc.c [new file with mode: 0644]
Tests [new file with mode: 0644]
UXTerm.ad [new file with mode: 0644]
VTPrsTbl.c [new file with mode: 0644]
VTparse.def [new file with mode: 0644]
VTparse.h [new file with mode: 0644]
XTerm-col.ad [new file with mode: 0644]
XTerm.ad [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
button.c [new file with mode: 0644]
cachedGCs.c [new file with mode: 0644]
charclass.c [new file with mode: 0644]
charclass.h [new file with mode: 0644]
charproc.c [new file with mode: 0644]
charsets.c [new file with mode: 0644]
config.guess [new file with mode: 0755]
config.sub [new file with mode: 0755]
configure [new file with mode: 0755]
configure.in [new file with mode: 0644]
ctlseqs.ms [new file with mode: 0644]
ctlseqs.txt [new file with mode: 0644]
cursor.c [new file with mode: 0644]
data.c [new file with mode: 0644]
data.h [new file with mode: 0644]
doublechr.c [new file with mode: 0644]
error.h [new file with mode: 0644]
fontutils.c [new file with mode: 0644]
fontutils.h [new file with mode: 0644]
gen-pc-fkeys.pl [new file with mode: 0755]
icons/xterm-color_32x32.xcf [new file with mode: 0644]
icons/xterm-color_32x32.xpm [new file with mode: 0644]
icons/xterm-color_48x48.xcf [new file with mode: 0644]
icons/xterm-color_48x48.xpm [new file with mode: 0644]
icons/xterm_32x32.xcf [new file with mode: 0644]
icons/xterm_32x32.xpm [new file with mode: 0644]
icons/xterm_48x48.xcf [new file with mode: 0644]
icons/xterm_48x48.xpm [new file with mode: 0644]
input.c [new file with mode: 0644]
install-sh [new file with mode: 0755]
keysym2ucs.c [new file with mode: 0644]
keysym2ucs.h [new file with mode: 0644]
koi8rxterm [new file with mode: 0755]
koi8rxterm.man [new file with mode: 0644]
linedata.c [new file with mode: 0644]
link_axp.com [new file with mode: 0644]
main.c [new file with mode: 0644]
main.h [new file with mode: 0644]
make.com [new file with mode: 0644]
menu.c [new file with mode: 0644]
menu.h [new file with mode: 0644]
minstall.sh [new file with mode: 0755]
misc.c [new file with mode: 0644]
os2main.c [new file with mode: 0644]
package/debian/changelog [new file with mode: 0644]
package/debian/color.sed [new file with mode: 0644]
package/debian/compat [new file with mode: 0644]
package/debian/control [new file with mode: 0644]
package/debian/copyright [new file with mode: 0644]
package/debian/rules [new file with mode: 0755]
package/debian/source/format [new file with mode: 0644]
package/debian/watch [new file with mode: 0644]
package/debian/xterm-dev.docs [new file with mode: 0644]
package/debian/xterm-xres.sed [new file with mode: 0644]
package/xterm.spec [new file with mode: 0644]
packaging/16colors.txt [new file with mode: 0644]
packaging/buildfix.patch [new file with mode: 0644]
packaging/failsafe.desktop [new file with mode: 0644]
packaging/xterm-256-man-page_paths.patch [new file with mode: 0644]
packaging/xterm-261-resources.patch [new file with mode: 0644]
packaging/xterm.changes [new file with mode: 0644]
packaging/xterm.desktop [new file with mode: 0644]
packaging/xterm.spec [new file with mode: 0644]
plink.sh [new file with mode: 0755]
precompose.c [new file with mode: 0644]
precompose.h [new file with mode: 0644]
print.c [new file with mode: 0644]
proto.h [new file with mode: 0644]
ptydata.c [new file with mode: 0644]
ptyx.h [new file with mode: 0644]
resize.c [new file with mode: 0644]
resize.man [new file with mode: 0644]
run-tic.sh [new file with mode: 0755]
screen.c [new file with mode: 0644]
scrollback.c [new file with mode: 0644]
scrollbar.c [new file with mode: 0644]
sinstall.sh [new file with mode: 0755]
tabs.c [new file with mode: 0644]
tektests/aitest.tek [new file with mode: 0644]
tektests/dmerc.tek [new file with mode: 0644]
tektests/fotest.tek [new file with mode: 0644]
tektests/imtest.tek [new file with mode: 0644]
tektests/imtesth.tek [new file with mode: 0644]
tektests/ocpred.tek [new file with mode: 0644]
tektests/usmap.tek [new file with mode: 0644]
termcap [new file with mode: 0644]
terminfo [new file with mode: 0644]
testxmc.c [new file with mode: 0644]
trace.c [new file with mode: 0644]
trace.h [new file with mode: 0644]
unicode/README [new file with mode: 0644]
unicode/convmap.pl [new file with mode: 0755]
unicode/keysym.map [new file with mode: 0644]
unicode/make-precompose.sh [new file with mode: 0755]
unicode/precompose.c.head [new file with mode: 0644]
unicode/precompose.c.tail [new file with mode: 0644]
util.c [new file with mode: 0644]
uxterm [new file with mode: 0755]
uxterm.desktop [new file with mode: 0644]
uxterm.man [new file with mode: 0644]
version.h [new file with mode: 0644]
vms.c [new file with mode: 0644]
vms.h [new file with mode: 0644]
vttests/16colors.sh [new file with mode: 0755]
vttests/256colors.pl [new file with mode: 0755]
vttests/256colors2.pl [new file with mode: 0755]
vttests/88colors.pl [new file with mode: 0755]
vttests/88colors2.pl [new file with mode: 0755]
vttests/8colors.sh [new file with mode: 0755]
vttests/acolors.sh [new file with mode: 0755]
vttests/doublechars.sh [new file with mode: 0755]
vttests/dynamic.sh [new file with mode: 0755]
vttests/dynamic2.sh [new file with mode: 0755]
vttests/fonts.sh [new file with mode: 0755]
vttests/paste64.pl [new file with mode: 0755]
vttests/query-fonts.pl [new file with mode: 0755]
vttests/resize.pl [new file with mode: 0755]
vttests/resize.sh [new file with mode: 0755]
vttests/tcapquery.pl [new file with mode: 0755]
vttests/title.sh [new file with mode: 0755]
wcwidth.c [new file with mode: 0644]
wcwidth.h [new file with mode: 0644]
xcharmouse.h [new file with mode: 0644]
xstrings.c [new file with mode: 0644]
xstrings.h [new file with mode: 0644]
xterm-268/packaging/16colors.txt [new file with mode: 0644]
xterm-268/packaging/buildfix.patch [new file with mode: 0644]
xterm-268/packaging/failsafe.desktop [new file with mode: 0644]
xterm-268/packaging/xterm-256-man-page_paths.patch [new file with mode: 0644]
xterm-268/packaging/xterm-261-resources.patch [new file with mode: 0644]
xterm-268/packaging/xterm.changes [new file with mode: 0644]
xterm-268/packaging/xterm.desktop [new file with mode: 0644]
xterm-268/packaging/xterm.spec [new file with mode: 0644]
xterm.dat [new file with mode: 0644]
xterm.desktop [new file with mode: 0644]
xterm.h [new file with mode: 0644]
xterm.log.html [new file with mode: 0644]
xterm.man [new file with mode: 0644]
xterm_axp.opt [new file with mode: 0644]
xterm_io.h [new file with mode: 0644]
xtermcap.c [new file with mode: 0644]
xtermcap.h [new file with mode: 0644]
xtermcfg.hin [new file with mode: 0644]
xutf8.c [new file with mode: 0644]
xutf8.h [new file with mode: 0644]

diff --git a/256colres.h b/256colres.h
new file mode 100644 (file)
index 0000000..4b98391
--- /dev/null
@@ -0,0 +1,250 @@
+/*
+ * This header file was generated by ./256colres.pl
+ */
+/* $XTermId: 256colres.h,v 1.11 2007/06/12 00:44:23 tom Exp $ */
+
+#ifndef included_256colres_h
+#define included_256colres_h
+
+COLOR_RES("16",        screen.Acolors[16],     DFT_COLOR("rgb:00/00/00")),
+COLOR_RES("17",        screen.Acolors[17],     DFT_COLOR("rgb:00/00/5f")),
+COLOR_RES("18",        screen.Acolors[18],     DFT_COLOR("rgb:00/00/87")),
+COLOR_RES("19",        screen.Acolors[19],     DFT_COLOR("rgb:00/00/af")),
+COLOR_RES("20",        screen.Acolors[20],     DFT_COLOR("rgb:00/00/d7")),
+COLOR_RES("21",        screen.Acolors[21],     DFT_COLOR("rgb:00/00/ff")),
+COLOR_RES("22",        screen.Acolors[22],     DFT_COLOR("rgb:00/5f/00")),
+COLOR_RES("23",        screen.Acolors[23],     DFT_COLOR("rgb:00/5f/5f")),
+COLOR_RES("24",        screen.Acolors[24],     DFT_COLOR("rgb:00/5f/87")),
+COLOR_RES("25",        screen.Acolors[25],     DFT_COLOR("rgb:00/5f/af")),
+COLOR_RES("26",        screen.Acolors[26],     DFT_COLOR("rgb:00/5f/d7")),
+COLOR_RES("27",        screen.Acolors[27],     DFT_COLOR("rgb:00/5f/ff")),
+COLOR_RES("28",        screen.Acolors[28],     DFT_COLOR("rgb:00/87/00")),
+COLOR_RES("29",        screen.Acolors[29],     DFT_COLOR("rgb:00/87/5f")),
+COLOR_RES("30",        screen.Acolors[30],     DFT_COLOR("rgb:00/87/87")),
+COLOR_RES("31",        screen.Acolors[31],     DFT_COLOR("rgb:00/87/af")),
+COLOR_RES("32",        screen.Acolors[32],     DFT_COLOR("rgb:00/87/d7")),
+COLOR_RES("33",        screen.Acolors[33],     DFT_COLOR("rgb:00/87/ff")),
+COLOR_RES("34",        screen.Acolors[34],     DFT_COLOR("rgb:00/af/00")),
+COLOR_RES("35",        screen.Acolors[35],     DFT_COLOR("rgb:00/af/5f")),
+COLOR_RES("36",        screen.Acolors[36],     DFT_COLOR("rgb:00/af/87")),
+COLOR_RES("37",        screen.Acolors[37],     DFT_COLOR("rgb:00/af/af")),
+COLOR_RES("38",        screen.Acolors[38],     DFT_COLOR("rgb:00/af/d7")),
+COLOR_RES("39",        screen.Acolors[39],     DFT_COLOR("rgb:00/af/ff")),
+COLOR_RES("40",        screen.Acolors[40],     DFT_COLOR("rgb:00/d7/00")),
+COLOR_RES("41",        screen.Acolors[41],     DFT_COLOR("rgb:00/d7/5f")),
+COLOR_RES("42",        screen.Acolors[42],     DFT_COLOR("rgb:00/d7/87")),
+COLOR_RES("43",        screen.Acolors[43],     DFT_COLOR("rgb:00/d7/af")),
+COLOR_RES("44",        screen.Acolors[44],     DFT_COLOR("rgb:00/d7/d7")),
+COLOR_RES("45",        screen.Acolors[45],     DFT_COLOR("rgb:00/d7/ff")),
+COLOR_RES("46",        screen.Acolors[46],     DFT_COLOR("rgb:00/ff/00")),
+COLOR_RES("47",        screen.Acolors[47],     DFT_COLOR("rgb:00/ff/5f")),
+COLOR_RES("48",        screen.Acolors[48],     DFT_COLOR("rgb:00/ff/87")),
+COLOR_RES("49",        screen.Acolors[49],     DFT_COLOR("rgb:00/ff/af")),
+COLOR_RES("50",        screen.Acolors[50],     DFT_COLOR("rgb:00/ff/d7")),
+COLOR_RES("51",        screen.Acolors[51],     DFT_COLOR("rgb:00/ff/ff")),
+COLOR_RES("52",        screen.Acolors[52],     DFT_COLOR("rgb:5f/00/00")),
+COLOR_RES("53",        screen.Acolors[53],     DFT_COLOR("rgb:5f/00/5f")),
+COLOR_RES("54",        screen.Acolors[54],     DFT_COLOR("rgb:5f/00/87")),
+COLOR_RES("55",        screen.Acolors[55],     DFT_COLOR("rgb:5f/00/af")),
+COLOR_RES("56",        screen.Acolors[56],     DFT_COLOR("rgb:5f/00/d7")),
+COLOR_RES("57",        screen.Acolors[57],     DFT_COLOR("rgb:5f/00/ff")),
+COLOR_RES("58",        screen.Acolors[58],     DFT_COLOR("rgb:5f/5f/00")),
+COLOR_RES("59",        screen.Acolors[59],     DFT_COLOR("rgb:5f/5f/5f")),
+COLOR_RES("60",        screen.Acolors[60],     DFT_COLOR("rgb:5f/5f/87")),
+COLOR_RES("61",        screen.Acolors[61],     DFT_COLOR("rgb:5f/5f/af")),
+COLOR_RES("62",        screen.Acolors[62],     DFT_COLOR("rgb:5f/5f/d7")),
+COLOR_RES("63",        screen.Acolors[63],     DFT_COLOR("rgb:5f/5f/ff")),
+COLOR_RES("64",        screen.Acolors[64],     DFT_COLOR("rgb:5f/87/00")),
+COLOR_RES("65",        screen.Acolors[65],     DFT_COLOR("rgb:5f/87/5f")),
+COLOR_RES("66",        screen.Acolors[66],     DFT_COLOR("rgb:5f/87/87")),
+COLOR_RES("67",        screen.Acolors[67],     DFT_COLOR("rgb:5f/87/af")),
+COLOR_RES("68",        screen.Acolors[68],     DFT_COLOR("rgb:5f/87/d7")),
+COLOR_RES("69",        screen.Acolors[69],     DFT_COLOR("rgb:5f/87/ff")),
+COLOR_RES("70",        screen.Acolors[70],     DFT_COLOR("rgb:5f/af/00")),
+COLOR_RES("71",        screen.Acolors[71],     DFT_COLOR("rgb:5f/af/5f")),
+COLOR_RES("72",        screen.Acolors[72],     DFT_COLOR("rgb:5f/af/87")),
+COLOR_RES("73",        screen.Acolors[73],     DFT_COLOR("rgb:5f/af/af")),
+COLOR_RES("74",        screen.Acolors[74],     DFT_COLOR("rgb:5f/af/d7")),
+COLOR_RES("75",        screen.Acolors[75],     DFT_COLOR("rgb:5f/af/ff")),
+COLOR_RES("76",        screen.Acolors[76],     DFT_COLOR("rgb:5f/d7/00")),
+COLOR_RES("77",        screen.Acolors[77],     DFT_COLOR("rgb:5f/d7/5f")),
+COLOR_RES("78",        screen.Acolors[78],     DFT_COLOR("rgb:5f/d7/87")),
+COLOR_RES("79",        screen.Acolors[79],     DFT_COLOR("rgb:5f/d7/af")),
+COLOR_RES("80",        screen.Acolors[80],     DFT_COLOR("rgb:5f/d7/d7")),
+COLOR_RES("81",        screen.Acolors[81],     DFT_COLOR("rgb:5f/d7/ff")),
+COLOR_RES("82",        screen.Acolors[82],     DFT_COLOR("rgb:5f/ff/00")),
+COLOR_RES("83",        screen.Acolors[83],     DFT_COLOR("rgb:5f/ff/5f")),
+COLOR_RES("84",        screen.Acolors[84],     DFT_COLOR("rgb:5f/ff/87")),
+COLOR_RES("85",        screen.Acolors[85],     DFT_COLOR("rgb:5f/ff/af")),
+COLOR_RES("86",        screen.Acolors[86],     DFT_COLOR("rgb:5f/ff/d7")),
+COLOR_RES("87",        screen.Acolors[87],     DFT_COLOR("rgb:5f/ff/ff")),
+COLOR_RES("88",        screen.Acolors[88],     DFT_COLOR("rgb:87/00/00")),
+COLOR_RES("89",        screen.Acolors[89],     DFT_COLOR("rgb:87/00/5f")),
+COLOR_RES("90",        screen.Acolors[90],     DFT_COLOR("rgb:87/00/87")),
+COLOR_RES("91",        screen.Acolors[91],     DFT_COLOR("rgb:87/00/af")),
+COLOR_RES("92",        screen.Acolors[92],     DFT_COLOR("rgb:87/00/d7")),
+COLOR_RES("93",        screen.Acolors[93],     DFT_COLOR("rgb:87/00/ff")),
+COLOR_RES("94",        screen.Acolors[94],     DFT_COLOR("rgb:87/5f/00")),
+COLOR_RES("95",        screen.Acolors[95],     DFT_COLOR("rgb:87/5f/5f")),
+COLOR_RES("96",        screen.Acolors[96],     DFT_COLOR("rgb:87/5f/87")),
+COLOR_RES("97",        screen.Acolors[97],     DFT_COLOR("rgb:87/5f/af")),
+COLOR_RES("98",        screen.Acolors[98],     DFT_COLOR("rgb:87/5f/d7")),
+COLOR_RES("99",        screen.Acolors[99],     DFT_COLOR("rgb:87/5f/ff")),
+COLOR_RES("100",       screen.Acolors[100],    DFT_COLOR("rgb:87/87/00")),
+COLOR_RES("101",       screen.Acolors[101],    DFT_COLOR("rgb:87/87/5f")),
+COLOR_RES("102",       screen.Acolors[102],    DFT_COLOR("rgb:87/87/87")),
+COLOR_RES("103",       screen.Acolors[103],    DFT_COLOR("rgb:87/87/af")),
+COLOR_RES("104",       screen.Acolors[104],    DFT_COLOR("rgb:87/87/d7")),
+COLOR_RES("105",       screen.Acolors[105],    DFT_COLOR("rgb:87/87/ff")),
+COLOR_RES("106",       screen.Acolors[106],    DFT_COLOR("rgb:87/af/00")),
+COLOR_RES("107",       screen.Acolors[107],    DFT_COLOR("rgb:87/af/5f")),
+COLOR_RES("108",       screen.Acolors[108],    DFT_COLOR("rgb:87/af/87")),
+COLOR_RES("109",       screen.Acolors[109],    DFT_COLOR("rgb:87/af/af")),
+COLOR_RES("110",       screen.Acolors[110],    DFT_COLOR("rgb:87/af/d7")),
+COLOR_RES("111",       screen.Acolors[111],    DFT_COLOR("rgb:87/af/ff")),
+COLOR_RES("112",       screen.Acolors[112],    DFT_COLOR("rgb:87/d7/00")),
+COLOR_RES("113",       screen.Acolors[113],    DFT_COLOR("rgb:87/d7/5f")),
+COLOR_RES("114",       screen.Acolors[114],    DFT_COLOR("rgb:87/d7/87")),
+COLOR_RES("115",       screen.Acolors[115],    DFT_COLOR("rgb:87/d7/af")),
+COLOR_RES("116",       screen.Acolors[116],    DFT_COLOR("rgb:87/d7/d7")),
+COLOR_RES("117",       screen.Acolors[117],    DFT_COLOR("rgb:87/d7/ff")),
+COLOR_RES("118",       screen.Acolors[118],    DFT_COLOR("rgb:87/ff/00")),
+COLOR_RES("119",       screen.Acolors[119],    DFT_COLOR("rgb:87/ff/5f")),
+COLOR_RES("120",       screen.Acolors[120],    DFT_COLOR("rgb:87/ff/87")),
+COLOR_RES("121",       screen.Acolors[121],    DFT_COLOR("rgb:87/ff/af")),
+COLOR_RES("122",       screen.Acolors[122],    DFT_COLOR("rgb:87/ff/d7")),
+COLOR_RES("123",       screen.Acolors[123],    DFT_COLOR("rgb:87/ff/ff")),
+COLOR_RES("124",       screen.Acolors[124],    DFT_COLOR("rgb:af/00/00")),
+COLOR_RES("125",       screen.Acolors[125],    DFT_COLOR("rgb:af/00/5f")),
+COLOR_RES("126",       screen.Acolors[126],    DFT_COLOR("rgb:af/00/87")),
+COLOR_RES("127",       screen.Acolors[127],    DFT_COLOR("rgb:af/00/af")),
+COLOR_RES("128",       screen.Acolors[128],    DFT_COLOR("rgb:af/00/d7")),
+COLOR_RES("129",       screen.Acolors[129],    DFT_COLOR("rgb:af/00/ff")),
+COLOR_RES("130",       screen.Acolors[130],    DFT_COLOR("rgb:af/5f/00")),
+COLOR_RES("131",       screen.Acolors[131],    DFT_COLOR("rgb:af/5f/5f")),
+COLOR_RES("132",       screen.Acolors[132],    DFT_COLOR("rgb:af/5f/87")),
+COLOR_RES("133",       screen.Acolors[133],    DFT_COLOR("rgb:af/5f/af")),
+COLOR_RES("134",       screen.Acolors[134],    DFT_COLOR("rgb:af/5f/d7")),
+COLOR_RES("135",       screen.Acolors[135],    DFT_COLOR("rgb:af/5f/ff")),
+COLOR_RES("136",       screen.Acolors[136],    DFT_COLOR("rgb:af/87/00")),
+COLOR_RES("137",       screen.Acolors[137],    DFT_COLOR("rgb:af/87/5f")),
+COLOR_RES("138",       screen.Acolors[138],    DFT_COLOR("rgb:af/87/87")),
+COLOR_RES("139",       screen.Acolors[139],    DFT_COLOR("rgb:af/87/af")),
+COLOR_RES("140",       screen.Acolors[140],    DFT_COLOR("rgb:af/87/d7")),
+COLOR_RES("141",       screen.Acolors[141],    DFT_COLOR("rgb:af/87/ff")),
+COLOR_RES("142",       screen.Acolors[142],    DFT_COLOR("rgb:af/af/00")),
+COLOR_RES("143",       screen.Acolors[143],    DFT_COLOR("rgb:af/af/5f")),
+COLOR_RES("144",       screen.Acolors[144],    DFT_COLOR("rgb:af/af/87")),
+COLOR_RES("145",       screen.Acolors[145],    DFT_COLOR("rgb:af/af/af")),
+COLOR_RES("146",       screen.Acolors[146],    DFT_COLOR("rgb:af/af/d7")),
+COLOR_RES("147",       screen.Acolors[147],    DFT_COLOR("rgb:af/af/ff")),
+COLOR_RES("148",       screen.Acolors[148],    DFT_COLOR("rgb:af/d7/00")),
+COLOR_RES("149",       screen.Acolors[149],    DFT_COLOR("rgb:af/d7/5f")),
+COLOR_RES("150",       screen.Acolors[150],    DFT_COLOR("rgb:af/d7/87")),
+COLOR_RES("151",       screen.Acolors[151],    DFT_COLOR("rgb:af/d7/af")),
+COLOR_RES("152",       screen.Acolors[152],    DFT_COLOR("rgb:af/d7/d7")),
+COLOR_RES("153",       screen.Acolors[153],    DFT_COLOR("rgb:af/d7/ff")),
+COLOR_RES("154",       screen.Acolors[154],    DFT_COLOR("rgb:af/ff/00")),
+COLOR_RES("155",       screen.Acolors[155],    DFT_COLOR("rgb:af/ff/5f")),
+COLOR_RES("156",       screen.Acolors[156],    DFT_COLOR("rgb:af/ff/87")),
+COLOR_RES("157",       screen.Acolors[157],    DFT_COLOR("rgb:af/ff/af")),
+COLOR_RES("158",       screen.Acolors[158],    DFT_COLOR("rgb:af/ff/d7")),
+COLOR_RES("159",       screen.Acolors[159],    DFT_COLOR("rgb:af/ff/ff")),
+COLOR_RES("160",       screen.Acolors[160],    DFT_COLOR("rgb:d7/00/00")),
+COLOR_RES("161",       screen.Acolors[161],    DFT_COLOR("rgb:d7/00/5f")),
+COLOR_RES("162",       screen.Acolors[162],    DFT_COLOR("rgb:d7/00/87")),
+COLOR_RES("163",       screen.Acolors[163],    DFT_COLOR("rgb:d7/00/af")),
+COLOR_RES("164",       screen.Acolors[164],    DFT_COLOR("rgb:d7/00/d7")),
+COLOR_RES("165",       screen.Acolors[165],    DFT_COLOR("rgb:d7/00/ff")),
+COLOR_RES("166",       screen.Acolors[166],    DFT_COLOR("rgb:d7/5f/00")),
+COLOR_RES("167",       screen.Acolors[167],    DFT_COLOR("rgb:d7/5f/5f")),
+COLOR_RES("168",       screen.Acolors[168],    DFT_COLOR("rgb:d7/5f/87")),
+COLOR_RES("169",       screen.Acolors[169],    DFT_COLOR("rgb:d7/5f/af")),
+COLOR_RES("170",       screen.Acolors[170],    DFT_COLOR("rgb:d7/5f/d7")),
+COLOR_RES("171",       screen.Acolors[171],    DFT_COLOR("rgb:d7/5f/ff")),
+COLOR_RES("172",       screen.Acolors[172],    DFT_COLOR("rgb:d7/87/00")),
+COLOR_RES("173",       screen.Acolors[173],    DFT_COLOR("rgb:d7/87/5f")),
+COLOR_RES("174",       screen.Acolors[174],    DFT_COLOR("rgb:d7/87/87")),
+COLOR_RES("175",       screen.Acolors[175],    DFT_COLOR("rgb:d7/87/af")),
+COLOR_RES("176",       screen.Acolors[176],    DFT_COLOR("rgb:d7/87/d7")),
+COLOR_RES("177",       screen.Acolors[177],    DFT_COLOR("rgb:d7/87/ff")),
+COLOR_RES("178",       screen.Acolors[178],    DFT_COLOR("rgb:d7/af/00")),
+COLOR_RES("179",       screen.Acolors[179],    DFT_COLOR("rgb:d7/af/5f")),
+COLOR_RES("180",       screen.Acolors[180],    DFT_COLOR("rgb:d7/af/87")),
+COLOR_RES("181",       screen.Acolors[181],    DFT_COLOR("rgb:d7/af/af")),
+COLOR_RES("182",       screen.Acolors[182],    DFT_COLOR("rgb:d7/af/d7")),
+COLOR_RES("183",       screen.Acolors[183],    DFT_COLOR("rgb:d7/af/ff")),
+COLOR_RES("184",       screen.Acolors[184],    DFT_COLOR("rgb:d7/d7/00")),
+COLOR_RES("185",       screen.Acolors[185],    DFT_COLOR("rgb:d7/d7/5f")),
+COLOR_RES("186",       screen.Acolors[186],    DFT_COLOR("rgb:d7/d7/87")),
+COLOR_RES("187",       screen.Acolors[187],    DFT_COLOR("rgb:d7/d7/af")),
+COLOR_RES("188",       screen.Acolors[188],    DFT_COLOR("rgb:d7/d7/d7")),
+COLOR_RES("189",       screen.Acolors[189],    DFT_COLOR("rgb:d7/d7/ff")),
+COLOR_RES("190",       screen.Acolors[190],    DFT_COLOR("rgb:d7/ff/00")),
+COLOR_RES("191",       screen.Acolors[191],    DFT_COLOR("rgb:d7/ff/5f")),
+COLOR_RES("192",       screen.Acolors[192],    DFT_COLOR("rgb:d7/ff/87")),
+COLOR_RES("193",       screen.Acolors[193],    DFT_COLOR("rgb:d7/ff/af")),
+COLOR_RES("194",       screen.Acolors[194],    DFT_COLOR("rgb:d7/ff/d7")),
+COLOR_RES("195",       screen.Acolors[195],    DFT_COLOR("rgb:d7/ff/ff")),
+COLOR_RES("196",       screen.Acolors[196],    DFT_COLOR("rgb:ff/00/00")),
+COLOR_RES("197",       screen.Acolors[197],    DFT_COLOR("rgb:ff/00/5f")),
+COLOR_RES("198",       screen.Acolors[198],    DFT_COLOR("rgb:ff/00/87")),
+COLOR_RES("199",       screen.Acolors[199],    DFT_COLOR("rgb:ff/00/af")),
+COLOR_RES("200",       screen.Acolors[200],    DFT_COLOR("rgb:ff/00/d7")),
+COLOR_RES("201",       screen.Acolors[201],    DFT_COLOR("rgb:ff/00/ff")),
+COLOR_RES("202",       screen.Acolors[202],    DFT_COLOR("rgb:ff/5f/00")),
+COLOR_RES("203",       screen.Acolors[203],    DFT_COLOR("rgb:ff/5f/5f")),
+COLOR_RES("204",       screen.Acolors[204],    DFT_COLOR("rgb:ff/5f/87")),
+COLOR_RES("205",       screen.Acolors[205],    DFT_COLOR("rgb:ff/5f/af")),
+COLOR_RES("206",       screen.Acolors[206],    DFT_COLOR("rgb:ff/5f/d7")),
+COLOR_RES("207",       screen.Acolors[207],    DFT_COLOR("rgb:ff/5f/ff")),
+COLOR_RES("208",       screen.Acolors[208],    DFT_COLOR("rgb:ff/87/00")),
+COLOR_RES("209",       screen.Acolors[209],    DFT_COLOR("rgb:ff/87/5f")),
+COLOR_RES("210",       screen.Acolors[210],    DFT_COLOR("rgb:ff/87/87")),
+COLOR_RES("211",       screen.Acolors[211],    DFT_COLOR("rgb:ff/87/af")),
+COLOR_RES("212",       screen.Acolors[212],    DFT_COLOR("rgb:ff/87/d7")),
+COLOR_RES("213",       screen.Acolors[213],    DFT_COLOR("rgb:ff/87/ff")),
+COLOR_RES("214",       screen.Acolors[214],    DFT_COLOR("rgb:ff/af/00")),
+COLOR_RES("215",       screen.Acolors[215],    DFT_COLOR("rgb:ff/af/5f")),
+COLOR_RES("216",       screen.Acolors[216],    DFT_COLOR("rgb:ff/af/87")),
+COLOR_RES("217",       screen.Acolors[217],    DFT_COLOR("rgb:ff/af/af")),
+COLOR_RES("218",       screen.Acolors[218],    DFT_COLOR("rgb:ff/af/d7")),
+COLOR_RES("219",       screen.Acolors[219],    DFT_COLOR("rgb:ff/af/ff")),
+COLOR_RES("220",       screen.Acolors[220],    DFT_COLOR("rgb:ff/d7/00")),
+COLOR_RES("221",       screen.Acolors[221],    DFT_COLOR("rgb:ff/d7/5f")),
+COLOR_RES("222",       screen.Acolors[222],    DFT_COLOR("rgb:ff/d7/87")),
+COLOR_RES("223",       screen.Acolors[223],    DFT_COLOR("rgb:ff/d7/af")),
+COLOR_RES("224",       screen.Acolors[224],    DFT_COLOR("rgb:ff/d7/d7")),
+COLOR_RES("225",       screen.Acolors[225],    DFT_COLOR("rgb:ff/d7/ff")),
+COLOR_RES("226",       screen.Acolors[226],    DFT_COLOR("rgb:ff/ff/00")),
+COLOR_RES("227",       screen.Acolors[227],    DFT_COLOR("rgb:ff/ff/5f")),
+COLOR_RES("228",       screen.Acolors[228],    DFT_COLOR("rgb:ff/ff/87")),
+COLOR_RES("229",       screen.Acolors[229],    DFT_COLOR("rgb:ff/ff/af")),
+COLOR_RES("230",       screen.Acolors[230],    DFT_COLOR("rgb:ff/ff/d7")),
+COLOR_RES("231",       screen.Acolors[231],    DFT_COLOR("rgb:ff/ff/ff")),
+COLOR_RES("232",       screen.Acolors[232],    DFT_COLOR("rgb:08/08/08")),
+COLOR_RES("233",       screen.Acolors[233],    DFT_COLOR("rgb:12/12/12")),
+COLOR_RES("234",       screen.Acolors[234],    DFT_COLOR("rgb:1c/1c/1c")),
+COLOR_RES("235",       screen.Acolors[235],    DFT_COLOR("rgb:26/26/26")),
+COLOR_RES("236",       screen.Acolors[236],    DFT_COLOR("rgb:30/30/30")),
+COLOR_RES("237",       screen.Acolors[237],    DFT_COLOR("rgb:3a/3a/3a")),
+COLOR_RES("238",       screen.Acolors[238],    DFT_COLOR("rgb:44/44/44")),
+COLOR_RES("239",       screen.Acolors[239],    DFT_COLOR("rgb:4e/4e/4e")),
+COLOR_RES("240",       screen.Acolors[240],    DFT_COLOR("rgb:58/58/58")),
+COLOR_RES("241",       screen.Acolors[241],    DFT_COLOR("rgb:62/62/62")),
+COLOR_RES("242",       screen.Acolors[242],    DFT_COLOR("rgb:6c/6c/6c")),
+COLOR_RES("243",       screen.Acolors[243],    DFT_COLOR("rgb:76/76/76")),
+COLOR_RES("244",       screen.Acolors[244],    DFT_COLOR("rgb:80/80/80")),
+COLOR_RES("245",       screen.Acolors[245],    DFT_COLOR("rgb:8a/8a/8a")),
+COLOR_RES("246",       screen.Acolors[246],    DFT_COLOR("rgb:94/94/94")),
+COLOR_RES("247",       screen.Acolors[247],    DFT_COLOR("rgb:9e/9e/9e")),
+COLOR_RES("248",       screen.Acolors[248],    DFT_COLOR("rgb:a8/a8/a8")),
+COLOR_RES("249",       screen.Acolors[249],    DFT_COLOR("rgb:b2/b2/b2")),
+COLOR_RES("250",       screen.Acolors[250],    DFT_COLOR("rgb:bc/bc/bc")),
+COLOR_RES("251",       screen.Acolors[251],    DFT_COLOR("rgb:c6/c6/c6")),
+COLOR_RES("252",       screen.Acolors[252],    DFT_COLOR("rgb:d0/d0/d0")),
+COLOR_RES("253",       screen.Acolors[253],    DFT_COLOR("rgb:da/da/da")),
+COLOR_RES("254",       screen.Acolors[254],    DFT_COLOR("rgb:e4/e4/e4")),
+COLOR_RES("255",       screen.Acolors[255],    DFT_COLOR("rgb:ee/ee/ee")),
+
+#endif /* included_256colres_h */
diff --git a/256colres.pl b/256colres.pl
new file mode 100755 (executable)
index 0000000..cf9673c
--- /dev/null
@@ -0,0 +1,93 @@
+#! /usr/bin/perl
+# $XTermId: 256colres.pl,v 1.16 2007/06/08 23:58:37 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2007 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+
+# Construct a header file defining default resources for the 256-color model
+# of xterm.  This is modeled after the 256colors2.pl script.
+
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+use strict;
+
+our ( $line1, $line2, $line3 );
+our ( $red, $green, $blue, $gray );
+our ( $level, $code, @steps );
+
+print <<EOF;
+/*
+ * This header file was generated by $0
+ */
+/* \$XTermId\$ */
+
+#ifndef included_256colres_h
+#define included_256colres_h
+
+EOF
+
+$line1="COLOR_RES(\"%d\",";
+$line2="\tscreen.Acolors[%d],";
+$line3="\tDFT_COLOR(\"rgb:%2.2x/%2.2x/%2.2x\")),\n";
+
+# colors 16-231 are a 6x6x6 color cube
+for ($red = 0; $red < 6; $red++) {
+    for ($green = 0; $green < 6; $green++) {
+       for ($blue = 0; $blue < 6; $blue++) {
+           $code = 16 + ($red * 36) + ($green * 6) + $blue;
+           printf($line1, $code);
+           printf($line2, $code);
+           printf($line3,
+                  ($red ? ($red * 40 + 55) : 0),
+                  ($green ? ($green * 40 + 55) : 0),
+                  ($blue ? ($blue * 40 + 55) : 0));
+       }
+    }
+}
+
+# colors 232-255 are a grayscale ramp, intentionally leaving out
+# black and white
+$code=232;
+for ($gray = 0; $gray < 24; $gray++) {
+    $level = ($gray * 10) + 8;
+    $code = 232 + $gray;
+    printf($line1, $code);
+    printf($line2, $code);
+    printf($line3,
+          $level, $level, $level);
+}
+
+print <<EOF;
+
+#endif /* included_256colres_h */
+EOF
diff --git a/88colres.h b/88colres.h
new file mode 100644 (file)
index 0000000..fcad714
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * This header file was generated by ./88colres.pl
+ */
+/* $XTermId: 88colres.h,v 1.11 2007/06/12 00:44:21 tom Exp $ */
+
+#ifndef included_88colres_h
+#define included_88colres_h
+
+COLOR_RES("16",        screen.Acolors[16],     DFT_COLOR("rgb:00/00/00")),
+COLOR_RES("17",        screen.Acolors[17],     DFT_COLOR("rgb:00/00/8b")),
+COLOR_RES("18",        screen.Acolors[18],     DFT_COLOR("rgb:00/00/cd")),
+COLOR_RES("19",        screen.Acolors[19],     DFT_COLOR("rgb:00/00/ff")),
+COLOR_RES("20",        screen.Acolors[20],     DFT_COLOR("rgb:00/8b/00")),
+COLOR_RES("21",        screen.Acolors[21],     DFT_COLOR("rgb:00/8b/8b")),
+COLOR_RES("22",        screen.Acolors[22],     DFT_COLOR("rgb:00/8b/cd")),
+COLOR_RES("23",        screen.Acolors[23],     DFT_COLOR("rgb:00/8b/ff")),
+COLOR_RES("24",        screen.Acolors[24],     DFT_COLOR("rgb:00/cd/00")),
+COLOR_RES("25",        screen.Acolors[25],     DFT_COLOR("rgb:00/cd/8b")),
+COLOR_RES("26",        screen.Acolors[26],     DFT_COLOR("rgb:00/cd/cd")),
+COLOR_RES("27",        screen.Acolors[27],     DFT_COLOR("rgb:00/cd/ff")),
+COLOR_RES("28",        screen.Acolors[28],     DFT_COLOR("rgb:00/ff/00")),
+COLOR_RES("29",        screen.Acolors[29],     DFT_COLOR("rgb:00/ff/8b")),
+COLOR_RES("30",        screen.Acolors[30],     DFT_COLOR("rgb:00/ff/cd")),
+COLOR_RES("31",        screen.Acolors[31],     DFT_COLOR("rgb:00/ff/ff")),
+COLOR_RES("32",        screen.Acolors[32],     DFT_COLOR("rgb:8b/00/00")),
+COLOR_RES("33",        screen.Acolors[33],     DFT_COLOR("rgb:8b/00/8b")),
+COLOR_RES("34",        screen.Acolors[34],     DFT_COLOR("rgb:8b/00/cd")),
+COLOR_RES("35",        screen.Acolors[35],     DFT_COLOR("rgb:8b/00/ff")),
+COLOR_RES("36",        screen.Acolors[36],     DFT_COLOR("rgb:8b/8b/00")),
+COLOR_RES("37",        screen.Acolors[37],     DFT_COLOR("rgb:8b/8b/8b")),
+COLOR_RES("38",        screen.Acolors[38],     DFT_COLOR("rgb:8b/8b/cd")),
+COLOR_RES("39",        screen.Acolors[39],     DFT_COLOR("rgb:8b/8b/ff")),
+COLOR_RES("40",        screen.Acolors[40],     DFT_COLOR("rgb:8b/cd/00")),
+COLOR_RES("41",        screen.Acolors[41],     DFT_COLOR("rgb:8b/cd/8b")),
+COLOR_RES("42",        screen.Acolors[42],     DFT_COLOR("rgb:8b/cd/cd")),
+COLOR_RES("43",        screen.Acolors[43],     DFT_COLOR("rgb:8b/cd/ff")),
+COLOR_RES("44",        screen.Acolors[44],     DFT_COLOR("rgb:8b/ff/00")),
+COLOR_RES("45",        screen.Acolors[45],     DFT_COLOR("rgb:8b/ff/8b")),
+COLOR_RES("46",        screen.Acolors[46],     DFT_COLOR("rgb:8b/ff/cd")),
+COLOR_RES("47",        screen.Acolors[47],     DFT_COLOR("rgb:8b/ff/ff")),
+COLOR_RES("48",        screen.Acolors[48],     DFT_COLOR("rgb:cd/00/00")),
+COLOR_RES("49",        screen.Acolors[49],     DFT_COLOR("rgb:cd/00/8b")),
+COLOR_RES("50",        screen.Acolors[50],     DFT_COLOR("rgb:cd/00/cd")),
+COLOR_RES("51",        screen.Acolors[51],     DFT_COLOR("rgb:cd/00/ff")),
+COLOR_RES("52",        screen.Acolors[52],     DFT_COLOR("rgb:cd/8b/00")),
+COLOR_RES("53",        screen.Acolors[53],     DFT_COLOR("rgb:cd/8b/8b")),
+COLOR_RES("54",        screen.Acolors[54],     DFT_COLOR("rgb:cd/8b/cd")),
+COLOR_RES("55",        screen.Acolors[55],     DFT_COLOR("rgb:cd/8b/ff")),
+COLOR_RES("56",        screen.Acolors[56],     DFT_COLOR("rgb:cd/cd/00")),
+COLOR_RES("57",        screen.Acolors[57],     DFT_COLOR("rgb:cd/cd/8b")),
+COLOR_RES("58",        screen.Acolors[58],     DFT_COLOR("rgb:cd/cd/cd")),
+COLOR_RES("59",        screen.Acolors[59],     DFT_COLOR("rgb:cd/cd/ff")),
+COLOR_RES("60",        screen.Acolors[60],     DFT_COLOR("rgb:cd/ff/00")),
+COLOR_RES("61",        screen.Acolors[61],     DFT_COLOR("rgb:cd/ff/8b")),
+COLOR_RES("62",        screen.Acolors[62],     DFT_COLOR("rgb:cd/ff/cd")),
+COLOR_RES("63",        screen.Acolors[63],     DFT_COLOR("rgb:cd/ff/ff")),
+COLOR_RES("64",        screen.Acolors[64],     DFT_COLOR("rgb:ff/00/00")),
+COLOR_RES("65",        screen.Acolors[65],     DFT_COLOR("rgb:ff/00/8b")),
+COLOR_RES("66",        screen.Acolors[66],     DFT_COLOR("rgb:ff/00/cd")),
+COLOR_RES("67",        screen.Acolors[67],     DFT_COLOR("rgb:ff/00/ff")),
+COLOR_RES("68",        screen.Acolors[68],     DFT_COLOR("rgb:ff/8b/00")),
+COLOR_RES("69",        screen.Acolors[69],     DFT_COLOR("rgb:ff/8b/8b")),
+COLOR_RES("70",        screen.Acolors[70],     DFT_COLOR("rgb:ff/8b/cd")),
+COLOR_RES("71",        screen.Acolors[71],     DFT_COLOR("rgb:ff/8b/ff")),
+COLOR_RES("72",        screen.Acolors[72],     DFT_COLOR("rgb:ff/cd/00")),
+COLOR_RES("73",        screen.Acolors[73],     DFT_COLOR("rgb:ff/cd/8b")),
+COLOR_RES("74",        screen.Acolors[74],     DFT_COLOR("rgb:ff/cd/cd")),
+COLOR_RES("75",        screen.Acolors[75],     DFT_COLOR("rgb:ff/cd/ff")),
+COLOR_RES("76",        screen.Acolors[76],     DFT_COLOR("rgb:ff/ff/00")),
+COLOR_RES("77",        screen.Acolors[77],     DFT_COLOR("rgb:ff/ff/8b")),
+COLOR_RES("78",        screen.Acolors[78],     DFT_COLOR("rgb:ff/ff/cd")),
+COLOR_RES("79",        screen.Acolors[79],     DFT_COLOR("rgb:ff/ff/ff")),
+COLOR_RES("80",        screen.Acolors[80],     DFT_COLOR("rgb:2e/2e/2e")),
+COLOR_RES("81",        screen.Acolors[81],     DFT_COLOR("rgb:5c/5c/5c")),
+COLOR_RES("82",        screen.Acolors[82],     DFT_COLOR("rgb:73/73/73")),
+COLOR_RES("83",        screen.Acolors[83],     DFT_COLOR("rgb:8b/8b/8b")),
+COLOR_RES("84",        screen.Acolors[84],     DFT_COLOR("rgb:a2/a2/a2")),
+COLOR_RES("85",        screen.Acolors[85],     DFT_COLOR("rgb:b9/b9/b9")),
+COLOR_RES("86",        screen.Acolors[86],     DFT_COLOR("rgb:d0/d0/d0")),
+COLOR_RES("87",        screen.Acolors[87],     DFT_COLOR("rgb:e7/e7/e7")),
+
+#endif /* included_88colres_h */
diff --git a/88colres.pl b/88colres.pl
new file mode 100755 (executable)
index 0000000..59ba412
--- /dev/null
@@ -0,0 +1,96 @@
+#!/usr/bin/perl
+# $XTermId: 88colres.pl,v 1.17 2007/06/08 23:57:23 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2005,2007 by Thomas E. Dickey
+# Copyright 1999-2000 by Steve Wall
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Made from 256colres.pl
+
+# Construct a header file defining default resources for the
+# 88-color model of xterm.
+
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+use strict;
+
+our ( $line1, $line2, $line3 );
+our ( $red, $green, $blue, $gray );
+our ( $level, $code, @steps );
+
+print <<EOF;
+/*
+ * This header file was generated by $0
+ */
+/* \$XTermId\$ */
+
+#ifndef included_88colres_h
+#define included_88colres_h
+
+EOF
+
+$line1="COLOR_RES(\"%d\",";
+$line2="\tscreen.Acolors[%d],";
+$line3="\tDFT_COLOR(\"rgb:%2.2x/%2.2x/%2.2x\")),\n";
+@steps=(0,139,205,255);
+
+# colors 16-79 are a 4x4x4 color cube
+for ($red = 0; $red < 4; $red++) {
+    for ($green = 0; $green < 4; $green++) {
+       for ($blue = 0; $blue < 4; $blue++) {
+           $code = 16 + ($red * 16) + ($green * 4) + $blue;
+           printf($line1, $code);
+           printf($line2, $code);
+           printf($line3,
+                  int (@steps[$red]),
+                  int (@steps[$green]),
+                  int (@steps[$blue]));
+       }
+    }
+}
+
+# colors 80-87 are a grayscale ramp, intentionally leaving out
+# black and white
+for ($gray = 0; $gray < 8; $gray++) {
+    $level = ($gray * 23.18181818) + 46.36363636;
+    if( $gray > 0 ) { $level += 23.18181818; }
+    $code = 80 + $gray;
+    printf($line1, $code);
+    printf($line2, $code);
+    printf($line3,
+          int($level), int($level), int($level));
+}
+
+print <<EOF;
+
+#endif /* included_88colres_h */
+EOF
diff --git a/AAA_README_VMS.txt b/AAA_README_VMS.txt
new file mode 100644 (file)
index 0000000..edf8ef1
--- /dev/null
@@ -0,0 +1,48 @@
+http://dickey.his.com/xterm/xterm.html
+
+Downloaded 1.22 variant (current Linux version) on 18-JAN-2000.
+
+Port stalled for a few days because OpenVMS X11 lacks XtGravity.
+
+X11KIT shared libraries almost work, but missing _XA_ symbols
+for some reason.  
+
+Copied X11KIT [.xaw3d] and [.xmu] into [.lib], put together simplified
+build procedures.  Made a few mods.  Merged in some changes from
+Patrick Young.  Now these build mostly ok except for tons of bcopy
+related warnings and problems with LAYOUT.C. 
+
+Merged changes from Xterm021 into here.
+
+Made changes here and there to get it all to work.
+
+25-JAN-2000, more or less done.  Logging doesn't work but PRINT
+does, as does regular VT emulation, TEK emulation, 80 and 132 wide
+modes.  The resource file needs work.  Cleaned up a really nasty problem 
+with infinite loops on copy/paste in button.c (see tt_pasting).
+
+To build this, if you have DECC, DW 1.2-5 and VMS 7.2-1 (the latter
+probably doesn't matter) do:
+
+$ @make
+
+in the top directory.  Expect a bunch of I and W warnings, but nothing 
+worse.  Then define a foreign symbol for xterm for the resulting .exe.
+
+26-JAN-2000.  Enabled logging.  When this is turned on from the menu
+it creates a new file SYS$SCRATCH:XTERM_LOG.TXT and writes everything that
+goes to the screen into it.  This may slow down output a bit as each block
+of data read must be copied to disk.  The log file has RMS format stream-lf
+and typically has a <CR> at the end of each line. 
+
+27-JAN-2000.  Discovered a bug when doing an X11 paste into an EDT session,
+had to add a tt_start_read() in button.c after the paste to reenable the
+read AST.  Rearranged code in VMS.C to make the compiler happy and 
+eliminate warnings.
+
+David Mathog
+mathog@seqaxp.bio.caltech.edu
+Manager, sequence analysis facility, biology division, Caltech 
+
+
+$XFree86: xc/programs/xterm/AAA_README_VMS.txt,v 1.2 2000/06/13 02:28:37 dawes Exp $
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..4f1cd8c
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,666 @@
+-- $XTermId: INSTALL,v 1.123 2010/06/14 08:57:22 tom Exp $
+-------------------------------------------------------------------------------
+-- Copyright 1997-2009,2010 by Thomas E. Dickey
+--
+--                         All Rights Reserved
+--
+-- Permission is hereby granted, free of charge, to any person obtaining a
+-- copy of this software and associated documentation files (the
+-- "Software"), to deal in the Software without restriction, including
+-- without limitation the rights to use, copy, modify, merge, publish,
+-- distribute, sublicense, and/or sell copies of the Software, and to
+-- permit persons to whom the Software is furnished to do so, subject to
+-- the following conditions:
+--
+-- The above copyright notice and this permission notice shall be included
+-- in all copies or substantial portions of the Software.
+--
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+-- IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+--
+-- Except as contained in this notice, the name(s) of the above copyright
+-- holders shall not be used in advertising or otherwise to promote the
+-- sale, use or other dealings in this Software without prior written
+-- authorization.
+-------------------------------------------------------------------------------
+
+Xterm is normally built as part of the X Window System source tree, using
+imake to generate a Makefile from Imakefile.  You can also use the
+configure script to generate a Makefile from Makefile.in:
+
+       + If you have imake (or xmkmf), then you can use those directly,
+         or use the configure script, which normally uses those tools
+         to obtain the special definitions needed to build xterm.
+
+         Ultimately, imake will not be necessary, since it is possible
+         to add configure tests that derive the information that imake
+         would supply.
+
+       + You need the Athena widgets (or a clone, such as Xaw3d or
+         neXtaw), to provide the popup menus.
+
+Even if you have imake, the configure script is still convenient because
+it allows you to build different configurations more easily than with
+imake, simply by specifying options to the configure script.
+
+Options:
+-------
+
+Autoconf configure scripts recognize two types of application-defined
+options, enable/disable and with/without.  The latter, by convention, are
+used for denoting inclusion of external packages, while the former denote
+enabling/disabling of internal features.  The configure --help option lists
+the available options.  This script uses "enable" and "disable" to indicate
+the sense of the default behavior.
+
+The options (in alphabetic order):
+
+  --disable-16-color      disable 16-color support
+
+       Do not compile-in code to recognize aixterm-style control sequences
+       that support color values 8-15.
+
+       Most color applications know only about 8 ANSI colors, but some
+       (e.g., ones built with ncurses) do.
+
+  --disable-active-icon   disable X11R6.3 active-icon feature
+
+       Do not compile-in code to support the active-icon feature.  This is
+       not configured on systems (e.g., X11R5) which lack the library
+       support needed.
+
+       Xterms with an active icon continue to respond to input and update
+       their display when iconified.  Not all window managers support
+       active icons.  Those that do include fvwm, olvwm and mwm.
+
+  --disable-ansi-color    disable ANSI color
+
+       Do not compile-in code for ANSI colors.
+
+  --disable-blink-cursor  disable support for blinking cursor
+
+       Do not compile-in code that implements a blinking cursor.  The blinking
+       cursor is enabled either by resource setting or by popup menu entry.
+
+  --disable-bold-color    disable PC-style mapping of bold colors
+
+       Do not compile-in code that maps colors 8-15 to bold versions of
+       colors 0-7.
+
+       Some applications have hardcoded logic that assumes this.  It does
+       not interfere with the 16-color support.
+
+  --disable-boxchars      disable fallback-support for box chars
+
+       Do not compile-in code to generate approximations for box/graphic
+       characters.
+
+       Most fonts do not contain the vt100-style graphic characters in
+       positions 0-31.  Many applications use the line-drawing characters,
+       e.g., to make boxes.  When xterm loads a font, it checks if those
+       characters are present, and draws its own if they are missing.
+
+  --disable-broken-st     disallow broken string-terminators],
+
+       Do not compile-in code that works around a bug in some ISDN routers
+       (and possibly other applications written by the same people):  they
+       send an unterminated control string in their banner text, making xterm
+       freeze.
+
+       The workaround tells xterm to stop processing the control string when
+       it receives one of the whitespace control characters such as newline.
+       That was the behavior before patch #171.
+
+       See also --enable-broken-osc
+
+  --disable-c1-print      disallow -k8 option for printable 128-159],
+
+       Use this option to suppress support for nonstandard use of codes
+       128-159, which normally are considered control characters.  Some users
+       have fonts which use those positions.  The default value for the
+       allowC1Printable resource is false, so this feature does not impact
+       normal users.
+
+  --disable-color-class   disable color class resources
+
+       Use this option to change most of the color resources to use Foreground
+       as the color class.  This is the older (before patch #157) behavior
+       which has the drawback that setting the Foreground resource on most
+       platforms prevents use of color since the class is evaluated before
+       the instance.
+
+  --disable-color-mode    disable default colorMode resource
+
+       Do not compile-in code that sets the default value of the colorMode
+       resource to ``true''.
+
+  --disable-desktop       disable install of xterm desktop files
+
+       Do not install the xterm desktop files, used in menus.
+       These use the icons installed in the --with-icondir option.
+       Use the environment variable $DESKTOP_FLAGS to supply options
+       required by desktop-file-install.
+
+       Note: If desktop-utils is not found they will not be installed anyway.
+
+  --disable-doublechars   disable support for double-size chars
+
+       Do not compile-in code that supports font-manipulation needed to
+       implement vt100-style double-sized characters.
+
+  --disable-echo          test: display "compiling" commands
+
+       Modify the generated Makefile so that most compiler options are
+       not shown.  This makes it simpler to read a build log and see the
+       actual warning messages.
+
+  --disable-fifo-lines    enable FIFO-storage for saved-lines
+
+       With patch #244, xterm by default stores saved-lines in a FIFO
+       (circular buffer), which improves performance when the number of saved
+       lines is large.  Disable this option to revert to the pre-244 layout.
+
+  --disable-freetype      disable freetype library-support
+
+       Do not use freetype libraries if they are found.  Normally they will
+       be used automatically.
+
+  --disable-full-tgetent  disable check for termcap library
+
+       Do not look for the tgetent() function specifically in the termcap
+       library, accept the first library (from termlib, ncurses and curses)
+       which contains this function rather than continuing to search for
+       a termcap implementation rather than terminfo.  The former would
+       supply the complete $TERMCAP data needed for some legacy programs.
+
+  --disable-highlighting  disable support for color highlighting
+
+       Do not compile-in code that allows the selected region to be a
+       different color than the reverse of foreground/background colors.
+
+       See the discussion of highlightColor in the manual.
+
+  --disable-i18n          disable internationalization
+
+       Do not compile-in code to handle multi-byte characters.  This is
+       related to, but not identical with the input method logic.
+
+  --disable-imake         disable use of imake for definitions
+
+       Do not attempt to use imake to determine compiler options.
+
+       The main.c file has many ifdef's which rely on obscure combinations
+       known only to imake.  The configure script implements only a
+       portion of the tests needed to supplant imake.
+
+  --disable-initial-erase disable setup for stty erase
+
+       Do not compile-in code which aligns the stty erase and the backarrow
+       key.  When compiled-in, xterm will optionally use the pty's sense
+       of stty erase and apply that to the backarrow mode (sending 8 or 127),
+       or go the other way, setting stty erase to match xterm's configuration.
+
+  --disable-input-method  disable input-method
+
+       Do not compile-in code for "input method".  This is an X11R6
+       feature which deals with translation of composite characters.
+
+       Some users report problems with their configuration, e.g., messages
+       stating that there is no input method defined for the given preedit
+       type.  If you do not need input method (and are troubled by the
+       warning messages), it is safe to disable this option.
+
+  --disable-leaks         test: set to test memory leaks
+
+       Compile-in code which frees memory which might confuse a leak-testing
+       tool.  Normally these chunks of memory are retained as long as xterm
+       is running.
+
+  --disable-maximize      disable actions for iconify/deiconify/maximize/restore
+
+       Do not compile-in code that implements runtime 'actions' for
+       iconifying, maximizing, etc.
+
+       Most users will find that the window manager is more suitable for
+       this sort of manipulation than putting the capabilities into xterm.
+
+  --disable-num-lock      disable NumLock keypad support
+
+       Do not compile-in code that looks for the actual NumLock key to
+       support vt100/vt220 keypad translation.
+
+       This is used in xterm to simplify logic, and to workaround some
+       quirks of the keyboard tables.  Use the ``numLock'' resource to
+       disable this feature if you must customize xterm in some other way.
+
+       (The same ifdef controls the metaSendsEscape support).
+
+  --disable-paste64       disable support for bracketed paste mode
+
+       Do not compile-in code to support experimental bracketed paste mode,
+       i.e., provide functions for setting/getting the selection data.
+
+       (see ctlseqs.ms description of OSC 52).
+
+  --disable-pty-handshake disable support for pty handshakes
+
+       This feature is used to ensure that the child process's terminal modes
+       match the parent's.  In particular, it addresses a problem where the
+       terminal size is not defined in the stty settings.
+
+  --disable-rectangles    disable VT420 rectangle support
+
+       Do not compile-in code to support VT420 rectangle control-sequences.
+
+  --disable-regex         disable regular-expression selections
+
+       Do not compile-in code to support the "regex" option for multiple
+       mouse clicks.
+
+  --disable-rightbar      disable right-scrollbar support
+
+       Do not compile-in code that supports a scrollbar on the right.
+
+       Left/right scrollbars are a matter of taste.  Some older libraries
+       (e.g., X11R5) do not perform the geometry computation correctly,
+       leaving the right scrollbar incorrectly positioned after changing
+       the font size.
+
+  --disable-rpath-hack    don't add rpath options for additional libraries
+
+       By default, the configure script looks for libraries in unusual places
+       and adds an rpath linker option to help.
+
+  --disable-samename      disable check for redundant name-change
+
+       Do not compile-in code that suppresses redundant updates to the
+       titlebar when the text has not changed.
+
+  --disable-session-mgt   enable support for session management
+
+       Do not compile-in code which adds simple session management hooks
+       which are used when closing an xterm.  Normally the code is
+       compiled-in, except for systems which do not support it.
+
+  --disable-setgid        disable setgid
+
+       Do not install xterm using setuid/setgid permissions.  Drop setgid
+       permissions on startup.
+
+  --disable-setuid        disable setuid
+
+       Do not install xterm using setuid/setgid permissions.  Drop setuid
+       permissions on startup.
+
+  --disable-sun-fkeys
+
+       Do not compile-in code to support Sun-style function keys.
+
+  --disable-tcap-fkeys    disable termcap function-keys
+
+       Do not compile-in code to support feature which allows xterm to use the
+       function-key definitions from the termcap/terminfo entry which it used
+       to set the $TERM variable on startup.
+
+  --disable-tcap-query    disable termcap query/report
+
+       Do not compile-in code to support DCS '+' control sequence, which
+       allows an application to ask xterm what control sequences it would
+       transmit for specified function keys, given the termcap or terminfo
+       names.
+
+  --disable-tek4014       disable tek4014 emulation
+
+       Do not compile-in code to support Tektronix 4014 emulation.
+
+       This reduces the executable size by 17% (checked 1999/3/13).
+
+       Some people use the Tektronix emulation (which has been in xterm
+       for many years) as an example of code bloat, though this is not an
+       accurate impression.
+
+  --disable-vt52          disable VT52 emulation
+
+       Do not compile-in code to support vt52 emulation.
+
+       A genuine vt100 emulates a vt52.
+
+  --disable-ziconbeep     disable -ziconbeep option
+
+       Do not compile-in code that modifies the icon's title and sounds a
+       beep when they receive output.
+
+  --enable-16bit-chars    enable 16-bit characters support
+
+       Enable wide-character support, but store only 16-bits for each wide
+       character.  Unicode values can be larger than 16-bits, up to 21-bits.
+       This uses less memory, but is less complete.  However, most languages
+       are covered by the 16-bit encoding.
+
+  --enable-256-color      enable 256-color support
+
+       Compile-in code that interprets SGR 38 and 48 for 256-colors.
+
+  --enable-88-color       enable 88-color support
+
+       Compile-in code that interprets SGR 38 and 48 for 88-colors.
+
+  --enable-broken-osc     allow broken Linux OSC-strings],
+
+       Compile-in code to accommodate scripts that write Linux's malformed
+       palette control strings without checking.  The result makes xterm
+       appear to freeze.  This workaround makes xterm ignore the strings,
+       and is compiled-in by default for Linux.
+
+  --enable-dabbrev        enable dynamic-abbreviation support
+
+       Compile-in support for "dabbrev-expand()" action and related key
+       translation.
+
+  --enable-dec-locator    enable DECterm Locator support
+       Add support for DEC Locator control sequences for xterm:
+
+               DECEFR - Enable Filter Rectangle
+               DECELR - Enable Locator Reports
+               DECSLE - Select Locator Events
+               DECRQLP - Request Locator Position
+
+       This allows the xterm mouse to be used with applications that use the
+       DEC Locator sequences, such as VAX Tpu, or SMG$ based applications.
+
+  --enable-exec-xterm     enable "spawn-new-terminal" action
+
+       If your platform supports the process filesystem "cwd" link,
+       compile-in support for the "spawn-new-terminal" action, which
+       allows you to define a key translation that runs a new xterm
+       using the same working directory as the current process within
+       xterm.
+
+  --enable-hp-fkeys       enable support for HP-style function keys
+
+       Compile-in code to support HP-style function keys.
+
+  --enable-load-vt-fonts  enable load-vt-fonts() action
+
+       Compile-in code that allows user to define load different VT-font
+       definitions at runtime.
+
+  --enable-logfile-exec   enable exec'd logfile filter
+
+       Compile-in code that allows logging piped via an external filter.
+
+  --enable-logging        enable logging
+
+       Compile-in code that allows logging.
+
+       Logging was disabled in X11R5 xterm because of security problems.
+       They were addressed in X11R6, but the feature was not reinstated.
+
+  --enable-luit           enable support for luit filter (Unicode translation)
+
+       Luit is a filter that can be run between an arbitrary application and a
+       UTF-8 terminal emulator.  It will convert application output from the
+       locale's encoding into UTF-8, and convert terminal input from UTF-8
+       into the locale's encoding.
+
+       This sets "--enable-wide-chars" as a side-effect.
+
+  --enable-mini-luit      enable support for poor man's luit filter (Latin-9)
+
+       Provide built-in support for Latin-9, relying on having specified
+       Unicode (ISO10646) fonts and setting the locale resource to "checkfont".
+
+       This sets "--enable-luit" as a side-effect.
+
+  --enable-narrowproto    enable narrow prototypes for X libraries
+
+       Originally xterm was built using imake rather than a configure script. 
+       One feature of imake that is not possible to guess within the
+       configure script is the wide-prototype compile-time definition
+       NARROWPROTO.  When this is not set properly, the Athena widget
+       scrollbars do not work properly.  xterm's configure script has a
+       fallback case which allows disabling imake.  However, this is moot
+       with the X.org "modular" build, whose compiler options are unrelated to
+       imake or older versions of any libraries that it may distribute.  In
+       this case, the configure script needs some help.  Use this option to
+       enable or disable NARROW proto (and disable imake with the
+       --disable-imake option) to match the whims of X.org hackers.
+
+       For instance
+
+               configure --disable-imake --disable-narrowproto
+
+  --enable-readline-mouse enable support for mouse in readline applications
+
+       Compile-in code to support experimental bracketed paste mode, i.e.,
+       provide functions for setting/getting the selection data.  Essentially
+       this puts xterm into a mode that sends special function-key strings to
+       bracket the data.
+
+       (See --enable-paste64, which fits xterm's protocol better).
+
+  --enable-sco-fkeys      enable support for SCO-style function keys
+
+       Compile-in code to support SCO-style function keys.
+
+  --enable-sun-fkeys      enable support for Sun-style function keys
+
+       Compile-in code to support Sun-style function keys.
+
+  --enable-toolbar        enable pulldown menus on toolbar
+
+       Compile-in code that builds a toolbar with pulldown menus.  The
+       normal popup menus are still available.
+
+       This is an experimental option.  As of patch #206, it is known to
+       work well with fvwm, but not as well with some other window managers,
+       e.g., KDE's Kwin and IceWM.
+
+       In addition to isolated layout problems, it is reported that some
+       flavors of the Athena widget library perform badly with ISO-10646
+       fonts.  You can work around those by setting the menu fonts to
+       an ISO-8859 variant in your X resources.
+
+  --enable-trace          test: set to enable debugging traces
+
+       Compile-in code to trace xterm's internal states.
+
+       This is a debugging feature.  It causes xterm to produce two files
+       (Trace-parent.out and Trace-child.out).
+
+  --enable-warnings       test: turn on GCC compiler warnings
+
+       Modify the generate Makefile to turn on gcc compiler warnings.
+
+       I use this option regularly, and correct all but a few (difficult)
+       problems.
+
+  --enable-wide-chars     enable wide-character support
+
+       Compile-in code that supports 16-bit characters.  Includes support
+       for UTF-8.
+
+  --enable-xmc-glitch     test: enable xmc magic-cookie emulation
+
+       Compile-in code that simulates the terminfo "magic cookie" glitch.
+
+       This is for testing ncurses.
+
+  --with-Xaw3d            link with Xaw 3d library
+
+       Look for, compile and link with the Xaw 3d widget library.
+
+  --with-XawPlus          link with Athena-Plus library
+
+       Look for, compile and link with the Xaw Plus widget library.
+
+  --with-app-defaults=DIR directory in which to install resource files (default: EPREFIX/lib/X11/app-defaults)
+
+       autoconf scripts assume that all of the files should be installed
+       under the same top-level directory.  But X applications defaults
+       must be installed into a special directory, e.g.,
+
+               /usr/X11/lib/app-defaults
+
+       However, there is no standard for this pathname.  The manual page
+       for X notes that the environment variable $XUSERFILESEARCHPATH can
+       specify a list of places where X searches for applications defaults.
+       Also, it may look in $XAPPLRESDIR, but that usually is not related
+       to where xterm might be installed.  To keep it simple, the configure
+       script uses
+
+               EPREFIX/lib/X11/app-defaults
+
+       as the default (EPREFIX is --prefix).  That makes it work normally
+       for most systems if --prefix is /usr.  For other installs, e.g., to
+       /usr/local, you should use this option to customize the location to
+       match your system configuration.
+
+       Use --without-app-defaults or --with-app-defaults=no to disable the
+       feature.
+
+  --with-freetype-cflags  -D/-I options for compiling with FreeType library
+
+       Override options provided by xft-config or freetype-config.
+
+  --with-freetype-libs    -L/-l options for linking with FreeType library
+
+       Override options provided by xft-config or freetype-config.
+
+  --with-icondir=DIR directory in which to install icon files (default: EPREFIX/share/pixmaps)
+
+       The X libraries may automatically search these locations:
+
+       $HOME/.icons
+       $XDG_DATA_DIRS/icons
+       /usr/share/pixmaps
+
+       See also
+       http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
+
+       Use --without-icondir or --with-icondir=no to disable the feature.
+
+  --with-neXtaw           link with neXT Athena library
+
+       Look for, compile and link with the neXT Athena widget library.
+
+  --with-own-terminfo=P   set default $TERMINFO (default: from environment)
+
+       Modify the generated Makefile to set the target for the 'install-ti'
+       rule to point to the given directory.
+
+       If you have the $TERMINFO variable defined in your environment, the
+       configure script will use that value.  If no option and no variable
+       are are given, the configure script uses /usr/lib/terminfo, if it
+       exists.
+
+       You do not have to run "make install-ti", if there is already a
+       workable terminfo description.  Be advised, however, that the
+       common variety of "xterm-color" is not suited for xterm, but is
+       directed to other variations (such as nxterm) which do not
+       support the background-color erase capability.
+
+  --with-pcre             use PCRE for regular-expressions
+
+       If regular expressions are not disable (--disable-regex), use PCRE
+       rather than the POSIX regular expressions.
+
+  --with-pkg-config{=path} enable/disable use of pkg-config
+
+       The configure script looks for certain libraries which have well
+       established pkg-config scripts, and will use those settings if
+       available.  Not all pkg-config scripts work; this option suppresses
+       the check and relies on normal library search paths.
+
+  --with-reference=XXX    program to use as permissions-reference
+
+       To install xterm with setuid permissions, the scripts usually compare
+       it with a previous install.  That works well for individual
+       maintainers, but can be a problem for packagers who may be
+       cross-compiling, etc.  This option lets the package builder specify
+       the file used for permissions reference.
+
+  --with-setuid=XXX       use the given setuid user
+
+       Install xterm setuid'd to the given user.  If no parameter value
+       is given, assume it is root.
+
+       See also --with-utmp-setgid and --with-utempter, which manipulate
+       the setgid group.
+
+  --with-tty-group=XXX    use XXX for the tty-group
+
+       If xterm is installed setuid'd to root, change the group of the tty
+       device to the given value on startup.  Three cases are possible:
+       
+       a) If this option is not given, the configure script will attempt to
+          find a suitable value (usually "tty"), and verify that it exists in
+          the group database.
+
+       b) If the option value is given, it will use the value even if it does
+          not exist in the group database (allowing packagers to work about
+          deficient environments).
+
+       c) If the option is disabled, e.g., --without-tty-group, the
+          permissions change will use the group-id of the process.
+
+       If xterm is not installed setuid'd to root, this option is not needed,
+       since it cannot change the tty device's ownership.
+
+  --with-xterm-symlink=XXX  make symbolic link to installed xterm
+
+       If any of the configure options to modify the program name i.e.,
+       --program-prefix, --program-suffix or --program-transform-name
+       are given, this option allows the makefile to create a symbolic link,
+       e.g., to "xterm" on install.  The option value gives the name for
+       the link, which defaults to "xterm".
+
+       Use --without-xterm-symlink to disable a link to "xterm" if none
+       is wanted.
+
+  --with-terminal-id[=V]  set default decTerminalID (default: vt100)
+
+       Set the default emulation level.
+
+       DEC terminals vt52/vt100/vt220/etc form a series where succeeding
+       models emulate features of the older terminals.  While most
+       features of these terminals are recognized by xterm at all levels,
+       a few behave differently according to the emulation level.
+
+       You can always override this with the command-line option "-ti".
+
+  --with-terminal-type=T  set default $TERM (default: xterm)
+
+       Set the default value for $TERM.  Xterm supports legacy termcap
+       applications by constructing a modified version of the $TERMCAP
+       variable at initialization, which supplies the resulting screen
+       size.  It also sets $TERM, if not already set, for use by programs
+       running within xterm.
+
+       The default value "xterm", can be overridden to avoid conflict
+       with older versions of xterm, e.g., those that do not implement
+       vt220 emulation.
+
+       You can always override this with the command-line option "-tn".
+
+  --with-utempter         use utempter library for access to utmp
+
+       The utempter library is a set-uid wrapper for the utmp facility.
+       On systems with Unix98 pty's, xterm can use this library when
+       available so it need not be installed set-uid.
+
+  --with-utmp-setgid=XXX  use setgid for access to utmp
+
+       The option value specifies a group to use when installing.
+       xterm will be installed with setgid privilege to this group.
+       At runtime, xterm will drop the setuid privilege immediately
+       after opening the pseudo-terminal, and will have only the
+       group privilege needed to access the utmp file.  This relies
+       on having POSIX setuid behavior.
+
+-- vile:txtmode
diff --git a/Imakefile b/Imakefile
new file mode 100644 (file)
index 0000000..57a7fd0
--- /dev/null
+++ b/Imakefile
@@ -0,0 +1,305 @@
+XCOMM $XTermId: Imakefile,v 1.102 2009/04/27 19:26:34 tom Exp $
+XCOMM
+XCOMM                         Attention xterm porters
+XCOMM
+XCOMM
+XCOMM Xterm assumes that bcopy can handle overlapping arguments.  If your
+XCOMM bcopy (or memcpy) cannot, write a routine called bcopy and link it in
+XCOMM or add -Dbcopy=mybcopy to the DEFINES list below.
+XCOMM
+XCOMM $XFree86: xc/programs/xterm/Imakefile,v 3.73 2006/04/10 00:34:36 dickey Exp $
+XCOMM
+
+/* Uncomment SCROLLBAR_RIGHT if you want the scroll bar to be on the right */
+SCROLLBAR_RIGHT = -DSCROLLBAR_RIGHT
+
+/* Define UTF8support to compile-in support for UTF-8 */
+#define UTF8support
+
+/*
+ * setgid mode works for systems that do not require setuid to open pty.
+ *
+ * This feature could also be applied to FreeBSD, but requires the installer
+ * to define a "utmp" group as well as chgrp the utmp file to match.
+ *
+ * Note: InstallXtermSetUID is always defined; InstallXtermSetGID is defined
+ * in newer imake configurations.
+ */
+#if !defined(InstallXtermSetGID) && !InstallXtermSetUID
+#if defined(OpenBSDArchitecture) || \
+    (defined(LinuxArchitecture) && \
+     (LinuxCLibMajorVersion == 6))
+#define InstallXtermSetGID YES
+#endif
+#endif
+
+/*
+ * Override the set uid/gid flags to use the utempter library.
+ */
+#if defined(UseUtempter)
+#undef InstallXtermSetUID /* imake sets this */
+#undef InstallXtermSetGID /* we set this */
+#define InstallXtermSetUID NO
+#define InstallXtermSetGID NO
+        UTMPLIB = -lutempter
+#endif
+
+/*
+ * Fixes to allow compile with X11R5, etc.
+ */
+#ifndef InstGidFlags
+#define InstGidFlags -m 2755 -g utmp
+#endif
+
+#ifndef InstUidFlags
+#define InstUidFlags -m 4711
+#endif
+
+#ifndef XkbClientDefines
+#define XkbClientDefines /**/
+#endif
+
+#ifndef InstallXtermSetUID
+#define InstallXtermSetUID NO
+#endif
+
+#ifndef InstallXtermSetGID
+#define InstallXtermSetGID NO
+#endif
+
+#ifndef XkbClientDepLibs
+#define XkbClientDepLibs /**/
+#endif
+
+#ifndef XkbClientLibs
+#define XkbClientLibs /**/
+#endif
+
+/* This must come before setting DEFINES */
+#if InstallXtermSetGID
+CSGIDFLAGS = -DUSE_UTMP_SETGID
+INSTSETIDFLAGS = InstGidFlags
+#elif InstallXtermSetUID
+INSTSETIDFLAGS = InstUidFlags
+#else
+INSTSETIDFLAGS = NullParameter
+#endif
+
+/*
+ * Compensate for broken imake configuration.
+ */
+#ifdef LinuxGnuSourceDefines
+# ifdef UseInstalled
+   IMAKEDEFINES = -D_GNU_SOURCE
+# endif
+#endif
+
+#ifndef SpecialCObjectRule
+#define SpecialCObjectRule(module,ignore,defines) \
+module.o: ; $(CC) -c defines $(CFLAGS) module.c
+#endif
+
+#ifndef ProgramTargetName
+#define ProgramTargetName(program) program
+#endif
+
+/*
+ * add -DWTMP and -DLASTLOG if you want them; make sure that bcopy can
+ * handle overlapping copies before using it.
+ */
+#if SetTtyGroup                        /* turn on in config/machine.cf */
+    TTYGROUPDEF = -DUSE_TTY_GROUP
+#endif
+#ifdef UsePUCCPtyd             /* turn on in config/site.def */
+    PUCCPTYDDEF = -DPUCC_PTYD  /* does not need to be setuid */
+         PTYLIB = -lpucc
+#endif
+
+#if defined(NetBSDArchitecture) || \
+    defined(OpenBSDArchitecture) || \
+    defined(FreeBSDArchitecture) || \
+    (defined(LinuxArchitecture) && \
+     (LinuxCLibMajorVersion == 6) && (LinuxCLibMinorVersion < 1))
+         PTYLIB = -lutil
+#endif
+
+#ifdef DarwinArchitecture
+/* dyld can deadlock if a signal comes in when it is looking up a symbol */
+  LOCAL_LDFLAGS = -Wl,-bind_at_load
+#endif
+
+#ifdef OS2Architecture
+/*
+ * Only used in os2main.c, see ptyx.h for OPT_I18N_SUPPORT
+ * <werner@suse.de>
+ */
+#if XtermWithI18N
+        I18NDEF = -DI18N
+      FEATURE_DEFINES = -DDEBUG -DALLOWLOGGING $(I18NDEF)
+#else
+      FEATURE_DEFINES = -DDEBUG -DALLOWLOGGING
+#endif
+#endif
+
+ OSMAJORVERSION = OSMajorVersion
+ OSMINORVERSION = OSMinorVersion
+
+#if !defined(OS2Architecture) && !defined(__GNU__)
+#if defined(UseUtempter)
+        UTMPDEF = -DUSE_UTEMPTER
+#else
+        UTMPDEF = -DUTMP
+#endif
+#endif
+
+#ifdef UTF8support
+    UTF8_OPTION = -DOPT_WIDE_CHARS -DOPT_LUIT_PROG
+        UTF8SRC = charclass.c precompose.c wcwidth.c xutf8.c
+        UTF8OBJ = charclass.o precompose.o wcwidth.o xutf8.o
+#endif
+#if BuildXftLibrary
+#define XRenderSupport
+#endif
+#ifdef XRenderSupport
+         XRFDEF = -DXRENDERFONT -DXFREE86_FT2
+        XRFLIBS = XftClientLibs
+     XRFDEPLIBS = XftClientDepLibs
+    XRFINCLUDES = $(XFTINCLUDES)
+#endif
+#if !HasPutenv
+      PUTENVDEF = -DNOPUTENV
+#endif
+#ifdef TraceXTerm
+       TRACEDEF = -DOPT_TRACE=1
+#endif
+   MAIN_DEFINES = $(UTMPDEF) $(TTYGROUPDEF) $(PUCCPTYDDEF) $(CSGIDFLAGS) \
+                 -DOSMAJORVERSION=$(OSMAJORVERSION) \
+                 -DOSMINORVERSION=$(OSMINORVERSION)
+   MISC_DEFINES = /* -DALLOWLOGGING -DALLOWLOGFILEEXEC */
+    XKB_DEFINES = XkbClientDefines
+   PATH_DEFINES = -DPROJECTROOT=$(PROJECTROOT)
+        DEFINES = $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) $(PATH_DEFINES) $(PUTENVDEF) $(IMAKEDEFINES) $(TRACEDEF)
+       INCLUDES = -I. $(XRFINCLUDES)
+
+#ifdef OS2Architecture
+        MAINSRC = os2main.c
+        MAINOBJ = os2main.o
+#else
+        MAINSRC = main.c
+        MAINOBJ = main.o
+#endif
+#ifdef TraceXTerm
+       TRACESRC = trace.c
+       TRACEOBJ = trace.o
+#endif
+          SRCS1 = button.c cachedGCs.c charproc.c charsets.c cursor.c \
+                 data.c doublechr.c fontutils.c input.c \
+                 linedata.c menu.c misc.c print.c ptydata.c scrollback.c \
+                 screen.c scrollbar.c tabs.c util.c xstrings.c xtermcap.c \
+                 TekPrsTbl.c Tekproc.c VTPrsTbl.c \
+                 $(MAINSRC) $(EXTRASRC) $(UTF8SRC) $(TRACESRC)
+          OBJS1 = button.o cachedGCs.o charproc.o charsets.o cursor.o \
+                 data.o doublechr.o fontutils.o input.o \
+                 linedata.o menu.o misc.o print.o ptydata.o scrollback.o \
+                 screen.o scrollbar.o tabs.o util.o xstrings.o xtermcap.o \
+                 TekPrsTbl.o Tekproc.o VTPrsTbl.o \
+                 $(MAINOBJ) $(EXTRAOBJ) $(UTF8OBJ) $(TRACEOBJ)
+          SRCS2 = resize.c xstrings.c
+          OBJS2 = resize.o xstrings.o
+           SRCS = $(SRCS1) $(SRCS2)
+           OBJS = $(OBJS1) $(OBJS2)
+       PROGRAMS = ProgramTargetName(resize) ProgramTargetName(xterm)
+       DEPLIBS1 = XkbClientDepLibs XawClientDepLibs $(XRFDEPLIBS)
+       DEPLIBS2 =
+
+#ifndef TermcapLibrary
+#if SystemV && !defined(MacIIArchitecture)
+#if    defined(CrayArchitecture) || \
+       (defined(HPArchitecture) && (OSMajorVersion < 10)) || \
+       defined(RsArchitecture) || \
+       defined(SCOArchitecture) || \
+       defined(USLArchitecture)
+#define TermcapLibrary -lcurses                /* special cases of System V */
+#else
+#define TermcapLibrary -ltermlib       /* usually in here */
+#endif
+#else
+#define TermcapLibrary -ltermcap       /* bsd puts it here */
+#endif
+#endif
+
+     TERMCAPLIB = TermcapLibrary
+
+AllTarget($(PROGRAMS))
+
+SpecialCObjectRule(main,$(_NOOP_),$(MAIN_DEFINES))
+SpecialCObjectRule(menu,$(_NOOP_),$(MISC_DEFINES))
+SpecialCObjectRule(misc,$(_NOOP_),$(MISC_DEFINES))
+SpecialCObjectRule(charproc,$(_NOOP_),$(MISC_DEFINES))
+SpecialCObjectRule(data,$(_NOOP_),$(MISC_DEFINES))
+
+#if InstallXtermSetUID
+SetUIDProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(PTYLIB))
+#else
+NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(UTMPLIB) $(PTYLIB))
+#endif
+
+#if InstallXtermSetUID && defined(SunArchitecture) && HasSharedLibraries && (OSMajorVersion < 5)
+#if AlternateUsrLibDir
+#if ((OSMajorVersion == 4) && (OSMinorVersion >= 1))
+LDOVERRIDE = -L$(DESTDIR)$(USRLIBDIR)
+#else
+#if HasGcc
+LDOVERRIDE = -static -L$(DESTDIR)$(USRLIBDIR)
+#else
+LDOVERRIDE = -Bstatic -L$(DESTDIR)$(USRLIBDIR)
+LDRESUME = -Bdynamic
+#endif
+#endif
+#endif
+install::
+       MakeDir($(DESTDIR)$(BINDIR))
+       RemoveFile(ProgramTargetName(xterm.inst))
+       LinkRule(ProgramTargetName(xterm.inst),$(CDEBUGFLAGS) $(CCOPTIONS)
+       $(EXTRA_LDOPTIONS) $(LOCAL_LDFLAGS),$(OBJS1),$(LDOVERRIDE)
+       $(XRFLIBS) XawClientLibs $(LDRESUME) $(LDLIBS) $(TERMCAPLIB)
+       $(PTYLIB))
+       $(INSTALL) -c $(INSTPGMFLAGS) $(INSTSETIDFLAGS) ProgramTargetName(xterm.inst) $(DESTDIR)$(BINDIR)/ProgramTargetName(xterm)
+       RemoveFile(ProgramTargetName(xterm.inst))
+#else
+InstallProgramWithFlags(xterm,$(BINDIR),$(INSTSETIDFLAGS))
+#endif
+
+InstallNamedProg(uxterm,uxterm,$(BINDIR))
+
+/*
+ * Link with the termcap library if USE_TERMCAP is defined in resize.c
+ */
+#if    defined(NTOArchitecture)        || \
+       defined(LinuxArchitecture)      || \
+       defined(OpenBSDArchitecture)    || \
+       defined(SGIArchitecture)        || \
+       defined(SunArchitecture)
+NormalProgramTarget(resize,$(OBJS2),$(DEPLIBS2),NullParameter,NullParameter)
+#else
+NormalProgramTarget(resize,$(OBJS2),$(DEPLIBS2),NullParameter,$(TERMCAPLIB))
+#endif
+
+InstallProgramWithFlags(resize,$(BINDIR),NullParameter)
+
+/*
+ * termcap is a special name that does not install correctly with
+ * InstallNamedNonExec()
+ */
+install::
+       MakeDir($(DESTDIR)$(LIBDIR)/etc)
+       $(INSTALL) $(INSTALLFLAGS) $(INSTDATFLAGS) termcap \
+               $(DESTDIR)$(LIBDIR)/etc/xterm.termcap
+InstallNamedNonExec(terminfo,xterm.terminfo,$(LIBDIR)/etc)
+
+InstallAppDefaults(XTerm)
+InstallAppDefaults(UXTerm)
+InstallAppDefaultsLong(XTerm-col,XTerm-color)
+InstallManPage(xterm,$(MANDIR))
+InstallManPage(resize,$(MANDIR))
+DependTarget()
diff --git a/KOI8RXTerm.ad b/KOI8RXTerm.ad
new file mode 100644 (file)
index 0000000..acc82d2
--- /dev/null
@@ -0,0 +1,50 @@
+! $XTermId: KOI8RXTerm.ad,v 1.4 2010/03/04 01:17:49 tom Exp $
+! -----------------------------------------------------------------------------
+! this file is part of xterm
+!
+! Copyright 2007,2010 by Thomas E. Dickey
+! 
+!                         All Rights Reserved
+! 
+! Permission is hereby granted, free of charge, to any person obtaining a
+! copy of this software and associated documentation files (the
+! "Software"), to deal in the Software without restriction, including
+! without limitation the rights to use, copy, modify, merge, publish,
+! distribute, sublicense, and/or sell copies of the Software, and to
+! permit persons to whom the Software is furnished to do so, subject to
+! the following conditions:
+! 
+! The above copyright notice and this permission notice shall be included
+! in all copies or substantial portions of the Software.
+! 
+! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+! IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+! CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+! TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+! SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+! 
+! Except as contained in this notice, the name(s) of the above copyright
+! holders shall not be used in advertising or otherwise to promote the
+! sale, use or other dealings in this Software without prior written
+! authorization.
+! -----------------------------------------------------------------------------
+! This is based on the UXTerm app-defaults file.
+! -----------------------------------------------------------------------------
+! Use
+!      xterm -class KOI8RXTerm
+! to set resources for KOI8-R mode with corresponding fonts.
+
+#include "XTerm"
+
+*fontMenu.Label:  KOI8-R Fonts
+*VT100*allowC1Printable:       true
+
+! Use Cyrillic instead of Latin fonts.
+*VT100.font:   -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-koi8-r
+*VT100.font2:  -misc-fixed-medium-r-normal--8-80-75-75-c-50-koi8-r
+*VT100.font3:  -misc-fixed-medium-r-normal--14-130-75-75-c-70-koi8-r
+*VT100.font4:  -misc-fixed-medium-r-normal--13-120-75-75-c-80-koi8-r
+*VT100.font5:  -misc-fixed-medium-r-normal--18-120-100-100-c-90-koi8-r
+*VT100.font6:  -misc-fixed-medium-r-normal--20-200-75-75-c-100-koi8-r
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..3b01936
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,165 @@
+MANIFEST for xterm-268, version xterm-268
+--------------------------------------------------------------------------------
+MANIFEST                        this file
+256colres.h                     resource-definitions for 256-color mode
+256colres.pl                    script to generate 256colres.h
+88colres.h                      resource definitions for 88-color mode
+88colres.pl                     script to generate 88colres.h
+AAA_README_VMS.txt              note for VMS port of 'xterm'
+INSTALL                         configure script: options and related install instructions
+Imakefile                       imake template for Makefile
+KOI8RXTerm.ad                   resources for koi8rxterm
+Makefile.in                     configure script template for Makefile
+README                          overview & caveats for 'xterm'
+README.i18n                     i18n readme:
+README.os390                    overview for os390 (EBCDIC) port of 'xterm'
+THANKS                          list of direct contributors
+TekPrsTbl.c                     Tek4014 parser state tables
+Tekparse.def                    template for generating Tekparse.h
+Tekparse.h                      Tek4014 parser-state definitions
+Tekproc.c                       Tek4014 parser-state functions
+Tests                           Useful tests for xterm-developers
+UXTerm.ad                       alternate resources for UTF-8
+VTPrsTbl.c                      VT100 parser state tables
+VTparse.def                     template for generating VTparse.h
+VTparse.h                       VT100 parser-state definitions
+XTerm-col.ad                    color resource definitions for XTerm class
+XTerm.ad                        resource definitions for XTerm class
+aclocal.m4                      configure script: custom macros
+button.c                        mouse button and selection processing
+cachedGCs.c                     maintain cache of GC's
+charclass.c                     compact character-class module
+charclass.h                     interface of charclass.c
+charproc.c                      VT100 parser functions
+charsets.c                      module to translate character-sets
+config.guess                    configure script: guess the system type
+config.sub                      configure script: validate system type
+configure                       generated
+configure.in                    template for generating configure script
+ctlseqs.ms                      documentation: Xterm Control Sequences
+ctlseqs.txt                     generated rendition of ctlseqs.ms
+cursor.c                        VT100 low-level cursor movement
+data.c                          global data declarations
+data.h                          global data external-definitions
+doublechr.c                     VT100 double-size character support
+error.h                         error-code definitions for 'xterm'
+fontutils.c                     xterm functions for (re)loading fonts
+fontutils.h                     interface of fontutils.c
+gen-pc-fkeys.pl                 script to generate extended function-key terminfo
+input.c                         VT100 key-symbol and function-key translation
+install-sh                      install-script (needed by configure)
+keysym2ucs.c                    lookup-table for UTF-8 to keysyms
+keysym2ucs.h                    interface of keysym2ucs.c
+koi8rxterm                      KOI-8 wrapper from Debian (originally me)
+koi8rxterm.man                  manpage for koi8rxterm
+linedata.c                      manage all line-data for VT100 widget
+link_axp.com                    build-script for VMS port of xterm
+main.c                          main program of 'xterm'
+main.h                          default definitions for 'xterm'
+make.com                        build-script for VMS port of 'xterm'
+menu.c                          popup/pulldown menus for 'xterm'
+menu.h                          interface of menu.c
+minstall.sh                     script for installing manpages
+misc.c                          miscellaneous utility functions for 'xterm'
+os2main.c                       main program for OS/2 EMX port of 'xterm'
+plink.sh                        script to prune unneeded libraries from link
+precompose.c                    table of precompose sequences
+precompose.h                    interface of precompose.c
+print.c                         VT100+ print support functions
+proto.h                         macros to simplify function prototypes
+ptydata.c                       functions to manipulate data read from pty
+ptyx.h                          structure-definitions for 'xterm'
+resize.c                        program to compute/modify xterm's window size
+resize.man                      manual page for 'resize'
+run-tic.sh                      run tic, filtering out harmless messages
+screen.c                        VT100 screen update functions
+scrollback.c                    manage scrollback (a big FIFO)
+scrollbar.c                     VT100 scrollbar support functions
+sinstall.sh                     install setuid if existing program was
+tabs.c                          VT100 tabstop support-functions
+termcap                         termcap entries for 'xterm'
+terminfo                        terminfo entries for 'xterm'
+testxmc.c                       testing: xmc/magic-cookies
+trace.c                         debugging trace functions for 'xterm'
+trace.h                         interface of trace.c
+util.c                          miscellaneous utility functions for 'xterm'
+uxterm                          wrapper script to make unicode-xterm
+uxterm.desktop                  sample desktop file for uxterm
+uxterm.man                      manpage for uxterm, from Debian
+version.h                       version of xterm
+vms.c                           VMS version of xterm's spawn(), etc.
+vms.h                           system headers and definitions for vms.c
+wcwidth.c                       wide-character utility functions
+wcwidth.h                       interface of wcwidth.c
+xcharmouse.h                    Jason Bacon's mouse-defs, cleaned up a little
+xstrings.c                      a few common string functions
+xstrings.h                      interface of xstrings.c
+xterm.dat                       application defaults for VMS port of 'xterm'
+xterm.desktop                   sample desktop file for xterm.
+xterm.h                         common includes, definitions and prototypes for 'xterm'
+xterm.log.html                  changelog for xterm
+xterm.man                       manual page for 'xterm'
+xterm_axp.opt                   linker options file for VMS port of 'xterm'
+xterm_io.h                      split-out definitions of termio/termios/sgtty and winsize from main.c, os2main.c, screen.c and resize.c
+xtermcap.c                      termcap-related functions.
+xtermcap.h                      interface of xtermcap.c
+xtermcfg.hin                    configure script: template for xtermcfg.h
+xutf8.c                         JC's cleanup of UTF8
+xutf8.h                         JC's cleanup of UTF8
+icons                           subdirectory
+icons/xterm-color_32x32.xcf     gimp file for editing 32x32 icon
+icons/xterm-color_32x32.xpm     32x32 color icon
+icons/xterm-color_48x48.xcf     gimp file for editing 48x48 icon
+icons/xterm-color_48x48.xpm     48x48 color icon
+icons/xterm_32x32.xcf           gimp file, for editing 32x32 icon
+icons/xterm_32x32.xpm           32x32 monochrome icon
+icons/xterm_48x48.xcf           gimp file, for editing 48x48 icon
+icons/xterm_48x48.xpm           48x48 monochrome icon
+package/debian                  subdirectory
+package/debian/changelog        build-script
+package/debian/color.sed        build-script
+package/debian/compat           build-script
+package/debian/control          build-script
+package/debian/copyright        build-script
+package/debian/rules            build-script
+package/debian/source           subdirectory
+package/debian/source/format    build-script
+package/debian                  subdirectory
+package/debian/watch            build-script
+package/debian/xterm-dev.docs   build-script
+package/debian/xterm-xres.sed   build-script
+package                         subdirectory
+package/xterm.spec              build-script
+tektests                        subdirectory
+tektests/aitest.tek             tek4014 demo: draw a globe
+tektests/dmerc.tek              tek4014 demo: draws a Mercator projection with orbit
+tektests/fotest.tek             tek4014 demo: draw a scatterplot on log scale
+tektests/imtest.tek             tek4014 demo: draw a test pattern
+tektests/imtesth.tek            tek4014 demo: draw a test pattern
+tektests/ocpred.tek             tek4014 demo: an occultation prediction
+tektests/usmap.tek              tek4014 demo: a US map
+unicode                         subdirectory
+unicode/README                  description of files in ./unicode
+unicode/convmap.pl              perl script for generating the lookup table for UTF-8 to keysym
+unicode/keysym.map              keysym mapping from UTF-8
+unicode/make-precompose.sh      make precompose.c
+unicode/precompose.c.head       header of precompose.c
+unicode/precompose.c.tail       tail of precompose.c
+vttests                         subdirectory
+vttests/16colors.sh             test-script to show 16-colors
+vttests/256colors.pl            script to illustrate 256-colors
+vttests/256colors2.pl           fancy test-script for 256-colors
+vttests/88colors.pl             sample script showing 88-colors
+vttests/88colors2.pl            sample script showing 88-colors
+vttests/8colors.sh              test-script to illustrate 8-colors
+vttests/acolors.sh              demonstrate changing the ANSI colors
+vttests/doublechars.sh          test script to demonstrate doublesize chars
+vttests/dynamic.sh              script to illustrate the dynamic colors control sequence
+vttests/dynamic2.sh             complete example of dynamic colors
+vttests/fonts.sh                script to demonstrate font-switching sequences
+vttests/paste64.pl              script to test base64-selection option
+vttests/query-fonts.pl          script to demo/test font-querying
+vttests/resize.pl               translated resize.sh to perl since it is easy to test, and I needed
+vttests/resize.sh               script to demonstrate resizing
+vttests/tcapquery.pl            script to test tcap-query option
+vttests/title.sh                test-script to show title of xterm in action
diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..2a6a265
--- /dev/null
@@ -0,0 +1,431 @@
+## $XTermId: Makefile.in,v 1.174 2010/11/24 11:21:01 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1997-2009,2010 by Thomas E. Dickey
+#
+#                         All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+
+SHELL          = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir         = @srcdir@
+VPATH                  = @srcdir@
+
+x              = @EXEEXT@
+o              = .@OBJEXT@
+
+CC             = @CC@
+CPP            = @CPP@
+AWK            = @AWK@
+LINK           = $(CC) $(CFLAGS)
+
+CTAGS          = @CTAGS@
+ETAGS          = @ETAGS@
+
+LN_S           = @LN_S@
+RM              = rm -f
+LINT           = @LINT@
+
+INSTALL                = @INSTALL@
+INSTALL_PROGRAM        = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_DATA   = @INSTALL_DATA@
+transform      = @program_transform_name@
+
+EXTRA_CFLAGS   = @EXTRA_CFLAGS@
+EXTRA_CPPFLAGS = @EXTRA_CPPFLAGS@
+EXTRA_LOADFLAGS        = @IMAKE_LOADFLAGS@
+
+CPPFLAGS       = -I. -I$(srcdir) -DHAVE_CONFIG_H @CPPFLAGS@ $(EXTRA_CPPFLAGS)
+CFLAGS         = @CFLAGS@ $(EXTRA_CFLAGS)
+LDFLAGS                = @LDFLAGS@
+LIBS           = @LIBS@
+
+prefix         = @prefix@
+exec_prefix    = @exec_prefix@
+
+manext         = 1
+bindir         = @bindir@
+libdir         = @libdir@
+mandir         = @mandir@/man$(manext)
+appsdir                = @appsdir@
+icondir                = @icondir@
+
+#### End of system configuration section. ####
+
+DESTDIR                =
+BINDIR         = $(DESTDIR)$(bindir)
+LIBDIR         = $(DESTDIR)$(libdir)
+MANDIR         = $(DESTDIR)$(mandir)
+APPSDIR                = $(DESTDIR)$(appsdir)
+ICONDIR                = $(DESTDIR)$(icondir)
+
+INSTALL_DIRS    = $(BINDIR) $(APPSDIR) $(ICONDIR) $(MANDIR)
+
+CLASS          = XTerm
+EXTRAHDR       = @EXTRAHDRS@
+EXTRASRC       = @EXTRASRCS@
+EXTRAOBJ       = @EXTRAOBJS@
+
+          SRCS1 = button.c cachedGCs.c charproc.c charsets.c cursor.c \
+                 data.c doublechr.c fontutils.c input.c \
+                 linedata.c main.c menu.c misc.c \
+                 print.c ptydata.c scrollback.c \
+                 screen.c scrollbar.c tabs.c util.c xstrings.c xtermcap.c \
+                 VTPrsTbl.c $(EXTRASRC)
+          OBJS1 = button$o cachedGCs$o charproc$o charsets$o cursor$o \
+                 data$o doublechr$o fontutils$o input$o \
+                 linedata$o main$o menu$o misc$o \
+                 print$o ptydata$o scrollback$o \
+                 screen$o scrollbar$o tabs$o util$o xstrings$o xtermcap$o \
+                 VTPrsTbl$o $(EXTRAOBJ)
+          SRCS2 = resize.c xstrings.c
+          OBJS2 = resize$o xstrings$o
+           SRCS = $(SRCS1) $(SRCS2)
+           OBJS = $(OBJS1) $(OBJS2)
+           HDRS = VTparse.h data.h error.h main.h menu.h proto.h \
+                  ptyx.h version.h xstrings.h xterm.h xtermcap.h $(EXTRAHDR)
+       PROGRAMS = xterm$x resize$x
+
+all :  $(PROGRAMS)
+################################################################################
+.SUFFIXES : .i .def .hin .html .$(manext) .ms .man .ps .pdf .txt
+
+.c$o :
+       @RULE_CC@
+       @ECHO_CC@$(CC) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/$*.c
+
+.c.i :
+       @RULE_CC@
+       @ECHO_CC@$(CPP) -C $(CPPFLAGS) $*.c >$@
+
+.def.hin :
+       grep '^CASE_' $< | $(AWK) '{printf "#define %s %d\n", $$1, n++}' >$@
+
+.man.$(manext) :
+       $(SHELL) $(srcdir)/minstall.sh "$(INSTALL_DATA)" $< $@ $(appsdir)
+
+.$(manext).html :
+       GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | groff -Thtml -man" >$@
+
+.$(manext).ps :
+       $(SHELL) -c "tbl $*.$(manext) | groff -man" >$@
+
+.$(manext).txt :
+       GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | nroff -Tascii -man | col -bx" >$@
+
+.ms.html :
+       GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.ms | groff -Thtml -ms" >$@
+
+.ms.ps :
+       $(SHELL) -c "tbl $*.ms | groff -ms" >$@
+
+.ms.txt :
+       GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.ms | nroff -Tascii -ms | col -bx" >$@
+
+.ps.pdf :
+       ps2pdf $*.ps
+################################################################################
+main$o : main.h
+misc$o : version.h
+
+$(OBJS1) : xterm.h ptyx.h xtermcfg.h
+main$o resize$o screen$o : xterm_io.h
+
+xterm$x : $(OBJS1)
+       @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(LIBS) $(EXTRA_LOADFLAGS)
+
+resize$x : $(OBJS2)
+       @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(LIBS)
+
+256colres.h :
+       -rm -f $@
+       perl $(srcdir)/256colres.pl > $@
+
+88colres.h :
+       -rm -f $@
+       perl $(srcdir)/88colres.pl > $@
+
+charproc$o : main.h @CHARPROC_DEPS@
+################################################################################
+actual_xterm  = `echo xterm|        sed '$(transform)'`
+actual_resize = `echo resize|       sed '$(transform)'`
+actual_uxterm = `echo uxterm|       sed '$(transform)'`
+actual_k8term = `echo koi8rxterm|   sed '$(transform)'`
+
+binary_xterm  = $(actual_xterm)$x
+binary_resize = $(actual_resize)$x
+binary_uxterm = $(actual_uxterm)
+binary_k8term = $(actual_k8term)
+
+install \
+install-bin \
+install-full :: xterm$x resize$x $(BINDIR)
+@MAY_SETUID@   $(SHELL) $(srcdir)/sinstall.sh @SINSTALL_OPTS@ "$(INSTALL_PROGRAM)" xterm$x  @XTERM_PATH@ $(BINDIR)/$(binary_xterm)
+@NOT_SETUID@   $(INSTALL_PROGRAM) xterm$x $(BINDIR)/$(binary_xterm)
+       $(INSTALL_PROGRAM) -m  755 resize$x $(BINDIR)/$(binary_resize)
+
+install \
+install-bin \
+install-scripts \
+install-full ::
+       @$(SHELL) -c "name=\"$(binary_xterm)\"; \
+               dest=\"$(binary_uxterm)\"; \
+               echo \"... installing $(BINDIR)/\$$dest\"; \
+               if test \"\$$name\" != \"xterm\"; then \
+                       sed -e \"s,=xterm,=\$$name,\" $(srcdir)/uxterm >uxterm.tmp; \
+                       $(INSTALL_SCRIPT) -m  755 uxterm.tmp $(BINDIR)/\$$dest; \
+                       rm -f uxterm.tmp; \
+               else \
+                       $(INSTALL_SCRIPT) -m  755 $(srcdir)/uxterm $(BINDIR)/\$$dest; \
+               fi"
+       @$(SHELL) -c "name=\"$(binary_xterm)\"; \
+               dest=\"$(binary_k8term)\"; \
+               echo \"... installing $(BINDIR)/\$$dest\"; \
+               if test \"\$$name\" != \"xterm\"; then \
+                       sed -e \"s,=xterm,=\$$name,\" $(srcdir)/koi8rxterm >k8term.tmp; \
+                       $(INSTALL_SCRIPT) -m  755 k8term.tmp $(BINDIR)/\$$dest; \
+                       rm -f k8term.tmp; \
+               else \
+                       $(INSTALL_SCRIPT) -m  755 $(srcdir)/koi8rxterm $(BINDIR)/\$$dest; \
+               fi"
+       @-$(SHELL) -c "name=\"$(binary_xterm)\"; \
+               if test @XTERM_SYMLINK@ != NONE ; then \
+               cd $(BINDIR) && ( \
+                       rm -f @XTERM_SYMLINK@ ; \
+                       $(LN_S) \$$name @XTERM_SYMLINK@ ; \
+                       echo \"... created symbolic link:\" ; \
+                       ls -l \$$name @XTERM_SYMLINK@ ) ; \
+               fi"
+
+install \
+install-man \
+install-full :: $(MANDIR)
+       $(SHELL) $(srcdir)/minstall.sh "$(INSTALL_DATA)" $(srcdir)/xterm.man    $(MANDIR)/$(actual_xterm).$(manext)  $(appsdir)
+       $(SHELL) $(srcdir)/minstall.sh "$(INSTALL_DATA)" $(srcdir)/resize.man   $(MANDIR)/$(actual_resize).$(manext) $(appsdir)
+       $(SHELL) $(srcdir)/minstall.sh "$(INSTALL_DATA)" $(srcdir)/uxterm.man   $(MANDIR)/$(actual_uxterm).$(manext) $(appsdir)
+       $(SHELL) $(srcdir)/minstall.sh "$(INSTALL_DATA)" $(srcdir)/koi8rxterm.man   $(MANDIR)/$(actual_k8term).$(manext) $(appsdir)
+       @-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && rm -f @XTERM_SYMLINK@.$(manext) ; fi"
+       @-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && $(LN_S) $(actual_xterm).$(manext) @XTERM_SYMLINK@.$(manext) ; fi"
+       @-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && echo '... created symbolic link:' && ls -l $(actual_xterm).$(manext) @XTERM_SYMLINK@.$(manext) ; fi"
+
+APP_NAMES = XTerm UXTerm KOI8RXTerm
+
+@no_appsdir@install \
+@no_appsdir@install-app \
+@no_appsdir@install-full :: $(APPSDIR)
+@no_appsdir@   @-$(SHELL) -c 'for s in $(APP_NAMES); \
+@no_appsdir@   do \
+@no_appsdir@           echo "** $$s"; \
+@no_appsdir@           d=`echo $$s | sed -e s/XTerm/$(CLASS)/`; \
+@no_appsdir@           echo installing $(APPSDIR)/$$d; \
+@no_appsdir@           sed -e s/XTerm/$(CLASS)/ $(srcdir)/$$s.ad >XTerm.tmp; \
+@no_appsdir@           $(INSTALL_DATA) XTerm.tmp $(APPSDIR)/$$d; \
+@no_appsdir@           echo installing $(APPSDIR)/$$d-color; \
+@no_appsdir@           sed -e s/XTerm/$$d/ $(srcdir)/XTerm-col.ad >XTerm.tmp; \
+@no_appsdir@           $(INSTALL_DATA) XTerm.tmp $(APPSDIR)/$$d-color; \
+@no_appsdir@   done'
+@no_appsdir@   @rm -f XTerm.tmp
+@no_icondir@   @echo "... installed app-defaults"
+
+@no_icondir@install \
+@no_icondir@install-icon \
+@no_icondir@install-full :: $(ICONDIR)
+@no_icondir@   @$(INSTALL_DATA) $(srcdir)/icons/xterm-color_32x32.xpm $(ICONDIR)
+@no_icondir@   @$(INSTALL_DATA) $(srcdir)/icons/xterm-color_48x48.xpm $(ICONDIR)
+@no_icondir@   @$(INSTALL_DATA) $(srcdir)/icons/xterm_32x32.xpm $(ICONDIR)
+@no_icondir@   @$(INSTALL_DATA) $(srcdir)/icons/xterm_48x48.xpm $(ICONDIR)
+@no_icondir@   @echo "... installed icons"
+
+install ::
+       @echo 'Completed installation of executables and documentation.'
+       @echo 'Use "make install-ti" to install terminfo description.'
+
+TERMINFO_DIR = @TERMINFO_DIR@
+SET_TERMINFO = @SET_TERMINFO@
+
+@no_ticprog@install-full \
+@no_ticprog@install-ti :: $(TERMINFO_DIR)
+@no_ticprog@   @$(SHELL) -c "$(SET_TERMINFO) $(srcdir)/run-tic.sh $(srcdir)/terminfo"
+@no_ticprog@   @echo 'Completed installation of terminfo description.'
+
+install-full \
+install-tc ::
+       @-$(SHELL) -c "test -f /etc/termcap && echo 'You must install the termcap entry manually by editing /etc/termcap'"
+
+installdirs : $(INSTALL_DIRS)
+################################################################################
+uninstall \
+uninstall-bin \
+uninstall-full ::
+       -$(RM) $(BINDIR)/$(binary_xterm)
+       -$(RM) $(BINDIR)/$(binary_resize)
+       @-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(BINDIR) && rm -f @XTERM_SYMLINK@; fi"
+
+uninstall \
+uninstall-bin \
+uninstall-scripts \
+uninstall-full ::
+       -$(RM) $(BINDIR)/$(binary_uxterm)
+       -$(RM) $(BINDIR)/$(binary_k8term)
+
+uninstall \
+uninstall-man \
+uninstall-full ::
+       -$(RM) $(MANDIR)/$(actual_xterm).$(manext)
+       -$(RM) $(MANDIR)/$(actual_resize).$(manext)
+       -$(RM) $(MANDIR)/$(actual_uxterm).$(manext)
+       -$(RM) $(MANDIR)/$(actual_k8term).$(manext)
+       @-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && rm -f @XTERM_SYMLINK@.$(manext); fi"
+
+@no_appsdir@uninstall \
+@no_appsdir@uninstall-app \
+@no_appsdir@uninstall-full ::
+@no_appsdir@   @-$(SHELL) -c 'for s in $(APP_NAMES); \
+@no_appsdir@   do \
+@no_appsdir@           echo "** $$s"; \
+@no_appsdir@           d=`echo $$s | sed -e s/XTerm/$(CLASS)/`; \
+@no_appsdir@           echo uninstalling $(APPSDIR)/$$d; \
+@no_appsdir@           $(RM) $(APPSDIR)/$$d; \
+@no_appsdir@           echo uninstalling $(APPSDIR)/$$d-color; \
+@no_appsdir@           $(RM) $(APPSDIR)/$$d-color; \
+@no_appsdir@   done'
+
+@no_icondir@uninstall \
+@no_icondir@uninstall-icon \
+@no_icondir@uninstall-full ::
+@no_icondir@   -$(RM) $(ICONDIR)/xterm-color_32x32.xpm
+@no_icondir@   -$(RM) $(ICONDIR)/xterm_32x32.xpm
+@no_icondir@   -$(RM) $(ICONDIR)/xterm-color_48x48.xpm
+@no_icondir@   -$(RM) $(ICONDIR)/xterm_48x48.xpm
+################################################################################
+# Desktop-utils does not provide an uninstall, and is not uniformly available.
+@desktop_utils@DESKTOP_FLAGS = @DESKTOP_FLAGS@
+@desktop_utils@install-desktop \
+@desktop_utils@install-full ::
+@desktop_utils@        desktop-file-install $(DESKTOP_FLAGS) xterm.desktop
+@desktop_utils@        desktop-file-install $(DESKTOP_FLAGS) uxterm.desktop
+################################################################################
+mostlyclean :
+       -$(RM) *$o *.[is] XtermLog.* .pure core *~ *.bak *.BAK *.out *.tmp
+
+clean : mostlyclean
+       -$(RM) $(PROGRAMS)
+
+distclean :: clean
+       -$(RM) Makefile config.status config.cache config.log xtermcfg.h
+
+distclean \
+docs-clean ::
+       -$(RM) *.ps *.pdf *.png
+       -$(SHELL) -c 'for p in xterm resize uxterm koi8rxterm; \
+       do \
+               $(RM) $$p.html $$p.$(manext) $$p.txt; \
+       done'
+       -$(RM) ctlseqs.html ctlseqs.$(manext)
+
+realclean : distclean
+       -$(RM) tags TAGS
+
+maintainer-clean : realclean
+       -$(RM) 256colres.h 88colres.h
+################################################################################
+terminfo.out : terminfo                ; tic -a -I -1 terminfo >$@
+termcap.out : termcap          ; tic -a -C -U termcap >$@
+################################################################################
+docs-ctlseqs \
+docs :: ctlseqs.html \
+       ctlseqs.pdf \
+       ctlseqs.ps \
+       ctlseqs.txt
+ctlseqs.html : ctlseqs.ms
+ctlseqs.pdf : ctlseqs.ps
+ctlseqs.ps : ctlseqs.ms
+ctlseqs.txt : ctlseqs.ms
+################################################################################
+docs-resize \
+docs :: resize.html \
+       resize.pdf \
+       resize.ps \
+       resize.txt
+resize.html : resize.$(manext)
+resize.pdf : resize.ps
+resize.ps : resize.$(manext)
+resize.txt : resize.$(manext)
+################################################################################
+docs-xterm \
+docs :: xterm.html \
+       xterm.pdf \
+       xterm.ps \
+       xterm.txt
+xterm.html : xterm.$(manext)
+xterm.pdf : xterm.ps
+xterm.ps : xterm.$(manext)
+xterm.txt : xterm.$(manext)
+################################################################################
+docs-uxterm \
+docs :: uxterm.html \
+       uxterm.pdf \
+       uxterm.ps \
+       uxterm.txt
+uxterm.html : uxterm.$(manext)
+uxterm.pdf : uxterm.ps
+uxterm.ps : uxterm.$(manext)
+uxterm.txt : uxterm.$(manext)
+################################################################################
+docs-koi8rxterm \
+docs :: koi8rxterm.html \
+       koi8rxterm.pdf \
+       koi8rxterm.ps \
+       koi8rxterm.txt
+koi8rxterm.html : koi8rxterm.$(manext)
+koi8rxterm.pdf : koi8rxterm.ps
+koi8rxterm.ps : koi8rxterm.$(manext)
+koi8rxterm.txt : koi8rxterm.$(manext)
+################################################################################
+lint :
+       $(LINT) $(CPPFLAGS) $(SRCS1)
+       $(LINT) $(CPPFLAGS) $(SRCS2)
+
+tags :
+       $(CTAGS) $(SRCS) $(HDRS)
+
+TAGS :
+       $(ETAGS) $(SRCS) $(HDRS)
+
+$(TERMINFO_DIR) $(INSTALL_DIRS) :
+       mkdir -p $@
+
+ALWAYS :
+
+depend : $(TABLES)
+       makedepend -- $(CPPFLAGS) -- $(SRCS)
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..76328f4
--- /dev/null
+++ b/README
@@ -0,0 +1,19 @@
+-- $XTermId: README,v 1.3 2007/05/24 19:49:19 tom Exp $
+-- Below is the original README for xterm from 1991, for your amusement.
+-- For a better overview, see http://invisible-island.net/xterm/ 
+-------------------------------------------------------------------------------
+                       Abandon All Hope, Ye Who Enter Here
+
+
+This is undoubtedly the most ugly program in the distribution.  It was one of
+the first "serious" programs ported, and still has a lot of historical baggage.
+Ideally, there would be a general tty widget and then vt102 and tek4014 
+subwidgets so that they could be used in other programs.  We are trying to 
+clean things up as we go, but there is still a lot of work to do.
+
+If you are porting this to a machine that has problems with overlapping
+bcopy's, watch out!
+
+There are two documents on xterm: the man page, xterm.man, which describes
+how to use it, and ctlseqs.ms, which describes the control sequences it
+understands.
diff --git a/README.i18n b/README.i18n
new file mode 100644 (file)
index 0000000..511ee60
--- /dev/null
@@ -0,0 +1,199 @@
+-- $XFree86: xc/programs/xterm/README.i18n,v 1.1 2003/11/13 01:16:37 dickey Exp $
+
+Using xterm in your language
+============================
+
+Since XFree86 version 4.0, the internationalization (i18n) feature of
+xterm is gradually improved.  Xterm is being improved even now.  You
+need only set the standard locale environment variables such as
+LC_CTYPE, LC_ALL, LC_CTYPE, or LANG.  Once the locale is set up you can
+use xterm in your favorite character encoding.
+
+This document explains how the i18n feature is realized and how to
+configure xterm for your character encoding.
+
+Refer to locale(7) for details of the locale mechanism.
+
+
+Basic i18n-related settings and resources
+=========================================
+
+These settings apply to XFree86 xterm patch #181, and the program luit
+which is distributed with XFree86 4.4
+
+1.  Usage of "locale mode"
+
+    On startup, xterm must be in "locale mode" to make it follow the
+    current locale.  You can invoke xterm in locale mode in these ways:
+
+    a.  Set "vt100.locale" resource "true".  This resource was
+        introduced since XFree86 4.3.  The default value of the "locale"
+        resource is "medium", which means xterm follows the locale only
+        in Chinese, Japanese, Korean, or Thai locales.  For example,
+
+          XTerm*locale: true
+
+        in your ~/.Xresources file.
+
+    or
+
+    b.  Invoke xterm with the "-lc" option.
+
+2.  Converter program "luit"
+
+    The "luit" must be available in the standard XFree86 binary
+    directory.  It is usually available because it is part of the
+    XFree86 distribution.  The standard binary directory may differ from
+    system to system.  /usr/X11R6/bin/luit is an example.
+
+    "luit" is used to convert between Unicode and the character encoding
+    for your locale.  When built for XFree86, xterm includes logic for
+    invoking luit.
+
+3.  Locale setting
+
+    Finally, you will need to configure your locale.  We expect that you
+    have already configured your locale for other software.  For example,
+
+      LANG=de_DE@euro
+      export LANG
+
+    in your ~/.xsession file.  There are many ways to configure locale. 
+    For example, your display manager may have a mechanism to invoke a
+    window manager in your favorite locale, or you may have system-wide
+    locale setting in /etc/environment.  You may also have set the
+    LC_ALL variable instead of the LANG variable.
+
+
+How to use xterm in different locale temporarily
+================================================
+
+You may sometimes need to invoke xterm in a different character encoding
+than your current locale.  For example, use xterm to login remote systems
+in different locale.
+
+Do this by invoking xterm in the target locale.  For example,
+
+  $ LANG=ru_RU.KOI8-R xterm &
+
+Previously, font setting has been used in such cases.
+
+  $ xterm -fn -misc-fixed-medium-r-normal--10-*-*-*-*-*-koi8-r &
+
+This does not work well in conjunction with the "locale" resource,
+because luit and xterm combined rely upon Unicode fonts.
+
+
+How to set fonts for UTF-8/locale modes
+=======================================
+
+Since xterm patch #181, xterm can automatically use Unicode fonts in
+UTF-8 mode and locale mode.  Few of you will need to modify the default
+setting to display your language.  In particular, Unicode fonts in
+combination with locale mode will satisfy the needs of not only
+ISO-8859-1 users but also East Asian and other non-ISO-8859-1 users.
+
+If you want to set your favorite Unicode font for UTF-8 and locale
+modes, you should add a line such as the following in your ~/.Xresources
+file:
+
+    XTerm*VT100.utf8Fonts.font: \
+         -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1
+
+The leading "XTerm*" pattern is more specific than the system's
+app-defaults file, therefore it overrides the corresponding line
+beginning with
+
+    *VT100.utf8Fonts.font:
+
+Here is an additional note.  If you want to display East Asian
+doublewidth characters (CJK Ideogram, Hiragana, Katakana, Hangul,
+and so on), we recommend using
+
+    -misc-fixed-medium-r-semicondensed--13-*-*-*-*-*-iso10646-1
+
+or
+
+    -misc-fixed-medium-r-normal--18-*-*-*-*-*-iso10646-1
+
+because these two fonts have corresponding doublewidth fonts.  These
+fonts are used as default font and default "Large" font, respectively.
+
+
+The internals of xterm i18n
+===========================
+
+You do not need to read this section if you only want to configure your
+xterm.  Here we describe how xterm is implemented to support i18n.
+
+The original version of xterm does not support locale or character
+encoding.  Its I/O stream is interpreted as a mere 8-bit index for a
+font.
+
+Beginning with XFree86 4.0, xterm supported UTF-8.  It was implemented
+as a separate UTF-8 mode from the conventional 8-bit mode.  Character
+encodings had no effect on the 8-bit mode.  The UTF-8 mode has been
+extended to support doublewidth characters (for East Asian characters)
+and combining characters (such as accents for Latin alphabets and Thai
+vowels/tone marks).
+
+Doublewidth characters are characters that occupy two continuing
+columns on the terminal.  Xterm uses separate fonts for normal
+(singlewidth) characters and doublewidth characters.  Though xterm has
+configuration items for specifying doublewidth fonts, it will
+automatically search for a font with exactly twice as wide and the same
+name as the specified normal font.
+
+The default behavior of xterm was modified to use this UTF-8 mode in
+UTF-8 locales.  A command line option of "-u8" and a resource of "utf8"
+were introduced to choose UTF-8 mode.
+
+"luit" was introduced to XFree86 at version 4.2.  It converts between
+UTF-8 and other encodings.  When luit is invoked in a UTF-8 terminal,
+the terminal acts as if it is really running in the other encoding.
+
+Since XFree86 version 4.3, xterm provides a new mode to invoke luit
+automatically to support various encodings.  The mode where xterm
+invokes luit is called "locale mode".  It is the third mode following
+conventional 8-bit mode and UTF-8 mode.  In the locale mode, xterm is
+aware of the current locale and character encoding.  Since locale mode
+uses luit, it is based on the UTF-8 mode.  That is, xterm works in UTF-8
+mode and luit works as a converter between UTF-8 and the character
+encoding for your locale.  This is why the locale mode always needs
+Unicode fonts.  The default behavior of xterm is modified so that the
+"locale mode" will be adopted in Chinese (Big5 and GB2312), Japanese
+(EUC-JP), Korean (EUC-KR), and Thai (ISO-8859-11, as known as TIS-620)
+locales.  Locale mode is chosen for these character encodings because
+these encodings are not supported by conventional 8-bit mode even by
+changing fonts (ISO-8859-11 needs combining characters and others need
+doublewidth characters).
+
+To control the locale mode, command line options of "-lc" and "-en" and
+a resource of "locale" were introduced.  The command line option of
+"-u8" and a resource of "utf8" were made obsolete by them, though
+retained for compatibility.
+
+Since XFree86 version 4.4, xterm can have two sets of default fonts,
+one for conventional 8-bit mode and another for UTF-8 and locale modes,
+by introducing the "utf8Fonts" subresource.
+
+
+Future TODO Items
+=================
+
+We anticipate that xterm's locale mode will be used increasingly in the
+future.  Since the UTF-8 and locale modes use more resources than
+conventional 8-bit mode (because it needs larger fonts and another
+process "luit"), faster hardware may be needed to gain complete
+acceptance by users.  However, the locale mechanism allows users
+to manipulate data in a standard form.  Its usefulness compensates
+in part for reduced performance.
+
+Xterm supports antialiased fonts ("-fa" and "-fs" command line options). 
+Currently UTF-8 nor locale modes do not work with antialiased fonts.
+
+Xterm does not support bi-directional or RTL languages such as Hebrew
+and Arab.  A simple standard how terminal should behave for these
+languages is needed.
+
+Xterm does not support Unicode characters above U+10000.
diff --git a/README.os390 b/README.os390
new file mode 100644 (file)
index 0000000..2fe50b6
--- /dev/null
@@ -0,0 +1,74 @@
+-- $XFree86: xc/programs/xterm/README.os390,v 1.3 2000/09/22 10:42:05 alanh Exp $
+
+Below are install instructions for os/390 2.5 & below and
+for os/390 2.6 & above.  The basic reasons for exporting
+the LIBS and CFLAGS variables is to get the configure
+script to run properly under os/390.  configure, when
+checking for X, attempts to compile a program something like
+
+   int main() {
+   XtMalloc()
+   ; return 0; }
+
+using 'cc -o conftest conftest.c -lXt'.  However this results
+in a number of linkedit messages such as:
+
+   IEW2456E 9207 SYMBOL xcatd UNRESOLVED.  MEMBER COULD NOT BE INCLUDED FROM THE
+            DESIGNATED CALL LIBRARY. NAME SPACE = 3
+   IEW2456E 9207 SYMBOL XrmQGetResource UNRESOLVED.  MEMBER COULD NOT BE INCLUDED
+            FROM THE DESIGNATED CALL LIBRARY.
+   IEW2456E 9207 SYMBOL XrmGetDatabase UNRESOLVED.  MEMBER COULD NOT BE INCLUDED
+            FROM THE DESIGNATED CALL LIBRARY.
+
+The only way I can get this program to compile and link is to
+use 'cc -o conftest conftest.c -lXt -lX11 -lSM -lICE'.
+With os/390 2.6 and above, IBM has provided X functions in dlls;
+this is the reason for the separate install steps.  In fact,
+trying to use the X archive files (eg -lX11) when linking xterm
+results in an abend0C1 in low storage when X tries to call the
+initialize function (at least on my system).  This has something
+to do with the calling X routine thinking it has a function pointer
+descriptor (c++) when it actually has just a function pointer (c).
+Unfortunately, I have been unable to recreate the problem in a
+simple testcase, so I haven't reported it to IBM.  Anyway, for os/390
+2.6 and above, configure will build a Makefile with the following line:
+
+   LIBS  = -lXaw -lXext -lXmu -lXt  -lSM -lICE -lX11 /usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x -lcurses
+
+The '-lXaw -lXext -lXmu -lXt  -lSM -lICE -lX11' should be manually removed;
+this isn't strictly necessary, but will reduce the size of the executable
+by about 4M.
+
+The '-Wl,EDIT=NO' causes the Binder to produce a non-editable executable,
+dramatically reducing the size of the executable file.
+
+Good Luck!!
+Greg Smith
+rys@trex.rtpnc.epa.gov
+
+
+
+Install instructions for os/390 2.5 and *below*:
+------------------------------------------------
+   gunzip xterm.tar.gz
+   pax -o from=ISO8859-1,to=IBM-1047 -rf xterm.tar
+   cd xterm
+   export LIBS='-lXt  -lX11 -lSM -lICE'
+   export CFLAGS='-D_ALL_SOURCE -Wl,EDIT=NO'
+   ./configure
+   make
+   export DISPLAY=my.xserver.name:0
+   ./xterm
+
+
+Install instructions for os/390 2.6 and *above*:
+------------------------------------------------
+   gunzip xterm.tar.gz
+   pax -o from=ISO8859-1,to=IBM-1047 -rf xterm.tar
+   cd xterm
+   ./configure   # LIBS, CFLAGS, and CC are defined by configure for os/390 2.6.
+   [optional: edit the Makefile and remove '-lXaw -lXext -lXmu -lXt  -lSM -lICE -lX11'
+              from the LIBS assignment]
+   make
+   export DISPLAY=my.xserver.name:0
+   ./xterm
diff --git a/THANKS b/THANKS
new file mode 100644 (file)
index 0000000..02cc710
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,166 @@
+-- $XTermId: THANKS,v 1.3 2011/01/22 13:22:37 tom Exp $
+-- vile:txtmode fk=8bit
+There's no AUTHORS file in this distribution; it would be redundant since
+I (Thomas E. Dickey) have done more than 80% of the work on xterm since 1996.
+
+There's no reliable history before that point.
+For some insight, see
+
+       http://invisible-island.net/xterm/xterm.faq.html#who_did_it
+
+Here's a list from xterm.log.html of people who have contributed changes.
+
+Adam M Costello
+Adam Sulmicki
+Alan Coopersmith
+Alex Hornung
+Alexander Pohoyda
+Alexander V Lukyanov
+Andrea Odetti
+Andreas Jaeger
+Andreas Schwab
+Andrew Sumner
+Andrew Tipton
+Anton Kovalenko
+Ben Yoshino
+Bernhard R Link
+Bernhard Rosenkraenzer
+Bill Nottingham
+Bob Maynard
+Bradd W Szonye
+Bram Moolenaar
+Branden Robinson
+Bruno Haible
+Caetano Jimenez Carezzato
+Chris Adams
+Chris Clayton
+Christian Biere
+Christian Weisgerber
+Chuck Blake
+D Roland Walker
+Daniel Colascione
+Daniel Jacobowitz
+Dave Simmons
+David Dawes
+David Krause
+David Madore
+David Martínez Moreno
+David Mathog
+David Wood
+David Yeo
+Denis Zaitsev
+Dennis Preiser
+Dennis Schneider
+Dr Werner Fink
+Ed Schouten
+Eddy De Greef
+Edward S Arthur
+Egbert Eich
+Emanuele Giaquinta
+Eugene Konev
+Fabrice Bellard
+Frank Giessler
+Frank Guangxin Liu
+Frank Liu
+Gael Roualland
+George Peter Staplin
+Greg Badros
+Greg Klanderman
+Greg Smith
+H Merijn Brand
+Hasso Tepper
+Holger Veit
+Ilya Zakharevich
+James Armstrong
+Jason Bacon
+Jason Vas Dias
+Jeff Chua
+Jeff Uphoff
+Jens Schweikhardt
+Jeremy Buhler
+Jeremy Huddleston
+Jeroen Ruigrok
+Jess Thrysoee
+Jim Paris
+Jochen Voss
+Joe Allen
+Joe Peterson
+Johnny Billquist
+Julien Cristau
+Juliusz Chroboczek
+Jungshik Shin
+Jürgen Keil
+Kean Johnston
+Keith Packard
+Ken Martin
+Kevin Buhr
+Kevin Schoedel
+Kiyokazu Suto
+Larry Riedel
+Lee Olsen
+Marc Bevand
+Marc La France
+Marius Tolzmann
+Mark Waggoner
+Markus Kuhn
+Martin Pirker
+Matthias Baake
+Matthias Scheler
+Matthieu Herrb
+Matthieu Lagouge
+Max Mikhanosha
+Michael Riepe
+Michael Rohleder
+Michael Schroeder
+Mike Castle
+Mike Fabian
+Mike Hopkirk
+Min Sik Kim
+Miroslav Lichvar
+Nam SungHyun
+Nelson Beebe
+Németh Márton
+Ovidiu Gheorghioiu
+Paul Gilmartin
+Paul Giordano
+Paul Lampert
+Paul Vojta
+Paul Williams
+Pavel Roskin
+Per Hedeland
+Peter Berg Larsen
+Pierre Lombard
+Richard Braakman
+Richard Griswold
+Rob Braun
+Robert Brady
+Robert Earl
+Robin Cutshaw
+Ross Paterson
+Ryan Johnson
+Scott Sewall
+Semen A Ustimenko
+Sergei Laskavy
+Sergey Vlasov
+Slava Semushin
+Stefan Dirsch
+Steve Wall
+Stuart Lissaman
+Sven Verdoolaege
+Taneli Huuskonen
+Ted Phelps
+Thomas Wolff
+Tim Adye
+Tim Pope
+Tobias Stoeckmann
+Todd Larason
+Todd Miller
+Tomas Vanhala
+Tomasz Cholewo
+Tomohiro Kubota
+Tor Lillqvist
+Torrey Lyons
+Victor Stinner
+Werner Lemberg
+Will Day
+Zdenek Sekera
diff --git a/TekPrsTbl.c b/TekPrsTbl.c
new file mode 100644 (file)
index 0000000..b244353
--- /dev/null
@@ -0,0 +1,2619 @@
+/* $XTermId: TekPrsTbl.c,v 1.8 2006/02/13 01:14:57 tom Exp $ */
+
+/*
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+/* $XFree86: xc/programs/xterm/TekPrsTbl.c,v 3.5 2006/02/13 01:14:57 dickey Exp $ */
+
+#include <Tekparse.h>
+
+Const int Talptable[] =                /* US (^_) normal alpha mode */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_LF,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_ESC_STATE,
+/*     FS              GS              RS              US      */
+CASE_PT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_SP,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     $               %               &               '       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     (               )               *               +       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     ,               -               .               /       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     0               1               2               3       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     4               5               6               7       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     8               9               :               ;       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     <               =               >               ?       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     @               A               B               C       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     D               E               F               G       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     H               I               J               K       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     L               M               N               O       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     P               Q               R               S       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     T               U               V               W       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     X               Y               Z               [       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     \               ]               ^               _       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     `               a               b               c       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     d               e               f               g       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     h               i               j               k       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     l               m               n               o       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     p               q               r               s       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     t               u               v               w       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     x               y               z               {       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     |               }               ~               DEL     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      currency        yen             brokenbar       section         */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      notsign         hyphen          registered      macron          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      eth             ntilde          ograve          oacute          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+};
+
+Const int Tbestable[] =                /* ESC while in bypass state */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_VT_MODE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_BYP_STATE,
+CASE_REPORT,
+CASE_BYP_STATE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_IGNORE,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_PAGE,
+CASE_IGNORE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_COPY,
+/*     CAN             EM              SUB             ESC     */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_GIN,
+CASE_IGNORE,
+/*     FS              GS              RS              US      */
+CASE_SPT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     $               %               &               '       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     (               )               *               +       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     ,               -               .               /       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     0               1               2               3       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     4               5               6               7       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     8               9               :               ;       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     <               =               >               ?       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     @               A               B               C       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     D               E               F               G       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     H               I               J               K       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     L               M               N               O       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     P               Q               R               S       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     T               U               V               W       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     X               Y               Z               [       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     \               ]               ^               _       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     `               a               b               c       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     d               e               f               g       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     h               i               j               k       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     l               m               n               o       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     p               q               r               s       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     t               u               v               w       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     x               y               z               {       */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*     |               }               ~               DEL     */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_IGNORE,
+CASE_BYP_STATE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      currency        yen             brokenbar       section         */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      notsign         hyphen          registered      macron          */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+CASE_BYP_STATE,
+};
+
+Const int Tbyptable[] =                /* ESC CAN (^X) bypass state */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_LF,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BES_STATE,
+/*     FS              GS              RS              US      */
+CASE_PT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     $               %               &               '       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     (               )               *               +       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     ,               -               .               /       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     0               1               2               3       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     4               5               6               7       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     8               9               :               ;       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     <               =               >               ?       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     @               A               B               C       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     D               E               F               G       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     H               I               J               K       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     L               M               N               O       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     P               Q               R               S       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     T               U               V               W       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     X               Y               Z               [       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     \               ]               ^               _       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     `               a               b               c       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     d               e               f               g       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     h               i               j               k       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     l               m               n               o       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     p               q               r               s       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     t               u               v               w       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     x               y               z               {       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     |               }               ~               DEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const int Tesctable[] =                /* ESC */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_VT_MODE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_CURSTATE,
+CASE_REPORT,
+CASE_CURSTATE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_IGNORE,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_PAGE,
+CASE_IGNORE,
+CASE_APL,
+CASE_ASCII,
+/*     DLE             DC1             DC2             DC3     */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_COPY,
+/*     CAN             EM              SUB             ESC     */
+CASE_BYP_STATE,
+CASE_CURSTATE,
+CASE_GIN,
+CASE_IGNORE,
+/*     FS              GS              RS              US      */
+CASE_SPT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     $               %               &               '       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     (               )               *               +       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     ,               -               .               /       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     0               1               2               3       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     4               5               6               7       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     8               9               :               ;       */
+CASE_CHAR_SIZE,
+CASE_CHAR_SIZE,
+CASE_CHAR_SIZE,
+CASE_CHAR_SIZE,
+/*     <               =               >               ?       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     @               A               B               C       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     D               E               F               G       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     H               I               J               K       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     L               M               N               O       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     P               Q               R               S       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     T               U               V               W       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     X               Y               Z               [       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     \               ]               ^               _       */
+CASE_CURSTATE,
+CASE_OSC,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     `               a               b               c       */
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+/*     d               e               f               g       */
+CASE_BEAM_VEC,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_BEAM_VEC,
+/*     h               i               j               k       */
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+/*     l               m               n               o       */
+CASE_BEAM_VEC,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_BEAM_VEC,
+/*     p               q               r               s       */
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+CASE_BEAM_VEC,
+/*     t               u               v               w       */
+CASE_BEAM_VEC,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_BEAM_VEC,
+/*     x               y               z               {       */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_CURSTATE,
+/*     |               }               ~               DEL     */
+CASE_CURSTATE,
+CASE_CURSTATE,
+CASE_IGNORE,
+CASE_CURSTATE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const int Tipltable[] =                /* RS (^^) incremental plot */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_LF,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_ESC_STATE,
+/*     FS              GS              RS              US      */
+CASE_PT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_PENUP,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     $               %               &               '       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     (               )               *               +       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     ,               -               .               /       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     0               1               2               3       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     4               5               6               7       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     8               9               :               ;       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     <               =               >               ?       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     @               A               B               C       */
+CASE_IGNORE,
+CASE_IPL_POINT,
+CASE_IPL_POINT,
+CASE_IGNORE,
+/*     D               E               F               G       */
+CASE_IPL_POINT,
+CASE_IPL_POINT,
+CASE_IPL_POINT,
+CASE_IGNORE,
+/*     H               I               J               K       */
+CASE_IPL_POINT,
+CASE_IPL_POINT,
+CASE_IPL_POINT,
+CASE_IGNORE,
+/*     L               M               N               O       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     P               Q               R               S       */
+CASE_PENDOWN,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     T               U               V               W       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     X               Y               Z               [       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     \               ]               ^               _       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     `               a               b               c       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     d               e               f               g       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     h               i               j               k       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     l               m               n               o       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     p               q               r               s       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     t               u               v               w       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     x               y               z               {       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     |               }               ~               DEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const int Tplttable[] =                /* GS (^]) graph (plot) mode */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_LF,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_ESC_STATE,
+/*     FS              GS              RS              US      */
+CASE_PT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     $               %               &               '       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     (               )               *               +       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     ,               -               .               /       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     0               1               2               3       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     4               5               6               7       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     8               9               :               ;       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     <               =               >               ?       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     @               A               B               C       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     D               E               F               G       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     H               I               J               K       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     L               M               N               O       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     P               Q               R               S       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     T               U               V               W       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     X               Y               Z               [       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     \               ]               ^               _       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     `               a               b               c       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     d               e               f               g       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     h               i               j               k       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     l               m               n               o       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     p               q               r               s       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     t               u               v               w       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     x               y               z               {       */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*     |               }               ~               DEL     */
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+CASE_PLT_VEC,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const int Tpttable[] =         /* FS (^\) point plot mode */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_LF,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_ESC_STATE,
+/*     FS              GS              RS              US      */
+CASE_PT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     $               %               &               '       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     (               )               *               +       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     ,               -               .               /       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     0               1               2               3       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     4               5               6               7       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     8               9               :               ;       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     <               =               >               ?       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     @               A               B               C       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     D               E               F               G       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     H               I               J               K       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     L               M               N               O       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     P               Q               R               S       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     T               U               V               W       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     X               Y               Z               [       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     \               ]               ^               _       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     `               a               b               c       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     d               e               f               g       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     h               i               j               k       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     l               m               n               o       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     p               q               r               s       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     t               u               v               w       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     x               y               z               {       */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*     |               }               ~               DEL     */
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+CASE_PT_POINT,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const int Tspttable[] =                /* ESC FS (^\) special point plot */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BEL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_LF,
+CASE_UP,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_ESC_STATE,
+/*     FS              GS              RS              US      */
+CASE_PT_STATE,
+CASE_PLT_STATE,
+CASE_IPL_STATE,
+CASE_ALP_STATE,
+/*     SP              !               "               #       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     $               %               &               '       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     (               )               *               +       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     ,               -               .               /       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     0               1               2               3       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     4               5               6               7       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     8               9               :               ;       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     <               =               >               ?       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     @               A               B               C       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     D               E               F               G       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     H               I               J               K       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     L               M               N               O       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     P               Q               R               S       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     T               U               V               W       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     X               Y               Z               [       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     \               ]               ^               _       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     `               a               b               c       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     d               e               f               g       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     h               i               j               k       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     l               m               n               o       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     p               q               r               s       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     t               u               v               w       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     x               y               z               {       */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*     |               }               ~               DEL     */
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+CASE_SPT_POINT,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x99            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
diff --git a/Tekparse.def b/Tekparse.def
new file mode 100644 (file)
index 0000000..d4a0b8e
--- /dev/null
@@ -0,0 +1,74 @@
+# $XTermId: Tekparse.def,v 1.4 2006/02/12 22:43:56 tom Exp $
+#
+# vile:confmode rs=lf
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2002,2006 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# List of symbols that need to be defined for Tekparse.h.  If you need to 
+# change any of the CASE_ macros, make the change here and rerun the command
+# shown in Tekparse.h.
+#
+
+CASE_REPORT
+CASE_VT_MODE
+CASE_SPT_STATE
+CASE_GIN
+CASE_BEL
+CASE_BS
+CASE_PT_STATE
+CASE_PLT_STATE
+CASE_TAB
+CASE_IPL_STATE
+CASE_ALP_STATE
+CASE_UP
+CASE_COPY
+CASE_PAGE
+CASE_BES_STATE
+CASE_BYP_STATE
+CASE_IGNORE
+CASE_ASCII
+CASE_APL
+CASE_CHAR_SIZE
+CASE_BEAM_VEC
+CASE_CURSTATE
+CASE_PENUP
+CASE_PENDOWN
+CASE_IPL_POINT
+CASE_PLT_VEC
+CASE_PT_POINT
+CASE_SPT_POINT
+CASE_CR
+CASE_ESC_STATE
+CASE_LF
+CASE_SP
+CASE_PRINT
+CASE_OSC
diff --git a/Tekparse.h b/Tekparse.h
new file mode 100644 (file)
index 0000000..9c706ce
--- /dev/null
@@ -0,0 +1,97 @@
+/* $XTermId: Tekparse.h,v 1.7 2006/02/13 01:14:57 tom Exp $ */
+
+/*
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+/* $XFree86: xc/programs/xterm/Tekparse.h,v 1.6 2006/02/13 01:14:57 dickey Exp $ */
+
+
+/* @(#)Tekparse.h      X10/6.6 11/7/86 */
+
+#ifndef included_Tekparse_h
+#define included_Tekparse_h 1
+
+#ifndef Const
+# if defined(__STDC__) && !defined(__cplusplus)
+#  define Const const
+# else
+#  define Const /**/
+# endif
+#endif
+
+extern Const int Talptable[];
+extern Const int Tbestable[];
+extern Const int Tbyptable[];
+extern Const int Tesctable[];
+extern Const int Tipltable[];
+extern Const int Tplttable[];
+extern Const int Tpttable[];
+extern Const int Tspttable[];
+
+/*
+ * The following list of definitions is generated from Tekparse.def using the
+ * following command line:
+ *
+ *     egrep -v '^CASE_' Tekparse.def | \
+ *     awk 'BEGIN {n = 0;} {printf "#define %s %d\n", $1, n; n++}' 
+ *
+ * You you need to change something, change Tekparse.def and regenerate the
+ * definitions.  This would have been automatic, but since this doesn't change
+ * very often, it isn't worth the makefile hassle.
+ */
+
+#define CASE_REPORT 0
+#define CASE_VT_MODE 1
+#define CASE_SPT_STATE 2
+#define CASE_GIN 3
+#define CASE_BEL 4
+#define CASE_BS 5
+#define CASE_PT_STATE 6
+#define CASE_PLT_STATE 7
+#define CASE_TAB 8
+#define CASE_IPL_STATE 9
+#define CASE_ALP_STATE 10
+#define CASE_UP 11
+#define CASE_COPY 12
+#define CASE_PAGE 13
+#define CASE_BES_STATE 14
+#define CASE_BYP_STATE 15
+#define CASE_IGNORE 16
+#define CASE_ASCII 17
+#define CASE_APL 18
+#define CASE_CHAR_SIZE 19
+#define CASE_BEAM_VEC 20
+#define CASE_CURSTATE 21
+#define CASE_PENUP 22
+#define CASE_PENDOWN 23
+#define CASE_IPL_POINT 24
+#define CASE_PLT_VEC 25
+#define CASE_PT_POINT 26
+#define CASE_SPT_POINT 27
+#define CASE_CR 28
+#define CASE_ESC_STATE 29
+#define CASE_LF 30
+#define CASE_SP 31
+#define CASE_PRINT 32
+#define CASE_OSC 33
+
+#endif /* included_Tekparse_h */
diff --git a/Tekproc.c b/Tekproc.c
new file mode 100644 (file)
index 0000000..d124394
--- /dev/null
+++ b/Tekproc.c
@@ -0,0 +1,1986 @@
+/* $XTermId: Tekproc.c,v 1.185 2011/01/20 10:50:19 tom Exp $ */
+
+/*
+ *
+ * Copyright 2001-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ * Copyright 1988  The Open Group
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of The Open Group shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from The Open Group.
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* Tekproc.c */
+
+#define RES_OFFSET(field)      XtOffsetOf(TekWidgetRec, field)
+
+#include <xterm.h>
+
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
+#include <X11/Xmu/CharSet.h>
+
+#if OPT_TOOLBAR
+
+#if defined(HAVE_LIB_XAW)
+#include <X11/Xaw/Form.h>
+#elif defined(HAVE_LIB_XAW3D)
+#include <X11/Xaw3d/Form.h>
+#elif defined(HAVE_LIB_NEXTAW)
+#include <X11/neXtaw/Form.h>
+#elif defined(HAVE_LIB_XAWPLUS)
+#include <X11/XawPlus/Form.h>
+#endif
+
+#endif /* OPT_TOOLBAR */
+
+#include <assert.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+
+#include <Tekparse.h>
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <xstrings.h>
+
+#define DefaultGCID XGContextFromGC(DefaultGC(XtDisplay(tw), DefaultScreen(XtDisplay(tw))))
+
+/* Tek defines */
+
+#define        DOTDASHEDLINE   2
+#define        DOTTEDLINE      1
+#define        EAST            01
+#define        LINEMASK        07
+#define        LONGDASHEDLINE  4
+#define        MARGIN1         0
+#define        MARGIN2         1
+#define MAX_PTS                150
+#define MAX_VTX                300
+#define        NORTH           04
+#define        PENDOWN         1
+#define        PENUP           0
+#define        SHORTDASHEDLINE 3
+#define        SOLIDLINE       0
+#define        SOUTH           010
+#define        TEKBOTTOMPAD    23
+#define        TEKDEFHEIGHT    565
+#define        TEKDEFWIDTH     750
+#define        TEKHEIGHT       3072
+#define        TEKHOME         ( (TekChar[tekscr->page.fontsize].nlines - 1) \
+                        * TekChar[tekscr->page.fontsize].vsize)
+#define        TEKMINHEIGHT    452
+#define        TEKMINWIDTH     600
+#define        TEKTOPPAD       34
+#define        TEKWIDTH        4096
+#define        WEST            02
+
+#define        TekMove(tw,x,y) tekscr->cur_X = x; tekscr->cur_Y = y
+#define        input()         Tinput(tw)
+#define        unput(c)        *Tpushback++ = (Char) c
+/* *INDENT-OFF* */
+static struct Tek_Char {
+    int hsize;                 /* in Tek units */
+    int vsize;                 /* in Tek units */
+    int charsperline;
+    int nlines;
+} TekChar[TEKNUMFONTS] = {
+    {56, 88, 74, 35},          /* large */
+    {51, 82, 81, 38},          /* #2 */
+    {34, 53, 121, 58},         /* #3 */
+    {31, 48, 133, 64},         /* small */
+};
+/* *INDENT-ON* */
+
+static Cursor GINcursor;
+static XSegment *line_pt;
+static int nplot;
+static TekLink Tek0;
+static jmp_buf Tekjump;
+static TekLink *TekRecord;
+static XSegment *Tline;
+
+static Const int *curstate = Talptable;
+static Const int *Tparsestate = Talptable;
+
+static char defaultTranslations[] = "\
+                ~Meta<KeyPress>: insert-seven-bit() \n\
+                 Meta<KeyPress>: insert-eight-bit() \n\
+               !Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
+          !Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \n\
+!Lock Ctrl @Num_Lock <Btn1Down>: popup-menu(mainMenu) \n\
+     !Ctrl @Num_Lock <Btn1Down>: popup-menu(mainMenu) \n\
+               !Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
+          !Lock Ctrl <Btn2Down>: popup-menu(tekMenu) \n\
+!Lock Ctrl @Num_Lock <Btn2Down>: popup-menu(tekMenu) \n\
+     !Ctrl @Num_Lock <Btn2Down>: popup-menu(tekMenu) \n\
+          Shift ~Meta<Btn1Down>: gin-press(L) \n\
+                ~Meta<Btn1Down>: gin-press(l) \n\
+          Shift ~Meta<Btn2Down>: gin-press(M) \n\
+                ~Meta<Btn2Down>: gin-press(m) \n\
+          Shift ~Meta<Btn3Down>: gin-press(R) \n\
+                ~Meta<Btn3Down>: gin-press(r)";
+/* *INDENT-OFF* */
+static XtActionsRec actionsList[] = {
+    { "string",        HandleStringEvent },
+    { "insert",        HandleKeyPressed },     /* alias for insert-seven-bit */
+    { "insert-seven-bit",      HandleKeyPressed },
+    { "insert-eight-bit",      HandleEightBitKeyPressed },
+    { "gin-press",             HandleGINInput },
+    { "secure",                        HandleSecure },
+    { "create-menu",           HandleCreateMenu },
+    { "popup-menu",            HandlePopupMenu },
+    /* menu actions */
+    { "allow-send-events",     HandleAllowSends },
+    { "set-visual-bell",       HandleSetVisualBell },
+#ifdef ALLOWLOGGING
+    { "set-logging",           HandleLogging },
+#endif
+    { "redraw",                        HandleRedraw },
+    { "send-signal",           HandleSendSignal },
+    { "quit",                  HandleQuit },
+    { "set-scrollbar",         HandleScrollbar },
+    { "set-jumpscroll",                HandleJumpscroll },
+    { "set-reverse-video",     HandleReverseVideo },
+    { "set-autowrap",          HandleAutoWrap },
+    { "set-reversewrap",       HandleReverseWrap },
+    { "set-autolinefeed",      HandleAutoLineFeed },
+    { "set-appcursor",         HandleAppCursor },
+    { "set-appkeypad",         HandleAppKeypad },
+    { "set-scroll-on-key",     HandleScrollKey },
+    { "set-scroll-on-tty-output", HandleScrollTtyOutput },
+    { "set-allow132",          HandleAllow132 },
+    { "set-cursesemul",                HandleCursesEmul },
+    { "set-marginbell",                HandleMarginBell },
+    { "set-altscreen",         HandleAltScreen },
+    { "soft-reset",            HandleSoftReset },
+    { "hard-reset",            HandleHardReset },
+    { "set-terminal-type",     HandleSetTerminalType },
+    { "set-visibility",                HandleVisibility },
+    { "set-tek-text",          HandleSetTekText },
+    { "tek-page",              HandleTekPage },
+    { "tek-reset",             HandleTekReset },
+    { "tek-copy",              HandleTekCopy },
+#if OPT_TOOLBAR
+    { "set-toolbar",           HandleToolbar },
+#endif
+};
+/* *INDENT-ON* */
+
+static Dimension defOne = 1;
+
+#define GIN_TERM_NONE_STR      "none"
+#define GIN_TERM_CR_STR                "CRonly"
+#define GIN_TERM_EOT_STR       "CR&EOT"
+
+#define GIN_TERM_NONE  0
+#define GIN_TERM_CR    1
+#define GIN_TERM_EOT   2
+
+#ifdef VMS
+#define DFT_FONT_SMALL "FIXED"
+#else
+#define DFT_FONT_SMALL "6x10"
+#endif
+
+static XtResource resources[] =
+{
+    {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
+     XtOffsetOf(CoreRec, core.width), XtRDimension, (caddr_t) & defOne},
+    {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
+     XtOffsetOf(CoreRec, core.height), XtRDimension, (caddr_t) & defOne},
+    Fres("fontLarge", XtCFont, tek.Tfont[TEK_FONT_LARGE], "9x15"),
+    Fres("font2", XtCFont, tek.Tfont[TEK_FONT_2], "6x13"),
+    Fres("font3", XtCFont, tek.Tfont[TEK_FONT_3], "8x13"),
+    Fres("fontSmall", XtCFont, tek.Tfont[TEK_FONT_SMALL], DFT_FONT_SMALL),
+    Sres(XtNinitialFont, XtCInitialFont, tek.initial_font, "large"),
+    Sres("ginTerminator", "GinTerminator", tek.gin_terminator_str, GIN_TERM_NONE_STR),
+#if OPT_TOOLBAR
+    Wres(XtNmenuBar, XtCMenuBar, tek.tb_info.menu_bar, 0),
+    Ires(XtNmenuHeight, XtCMenuHeight, tek.tb_info.menu_height, 25),
+#endif
+};
+
+static IChar Tinput(TekWidget /* tw */ );
+static int getpoint(TekWidget /* tw */ );
+static void TCursorBack(TekWidget /* tw */ );
+static void TCursorDown(TekWidget /* tw */ );
+static void TCursorForward(TekWidget /* tw */ );
+static void TCursorUp(TekWidget /* tw */ );
+static void TekBackground(TekWidget /* tw */ ,
+                         TScreen * /* screen */ );
+static void TekConfigure(Widget /* w */ );
+static void TekDraw(TekWidget /* tw */ ,
+                   int /* x */ ,
+                   int /* y */ );
+static void TekEnq(TekWidget /* tw */ ,
+                  unsigned /* status */ ,
+                  int /* x */ ,
+                  int /* y */ );
+static void TekFlush(TekWidget /* tw */ );
+static void TekInitialize(Widget /* request */ ,
+                         Widget /* wnew */ ,
+                         ArgList /* args */ ,
+                         Cardinal * /* num_args */ );
+static void TekPage(TekWidget /* tw */ );
+static void TekRealize(Widget /* gw */ ,
+                      XtValueMask * /* valuemaskp */ ,
+                      XSetWindowAttributes * /* values */ );
+
+static WidgetClassRec tekClassRec =
+{
+    {
+/* core_class fields */
+       (WidgetClass) & widgetClassRec,         /* superclass     */
+       "Tek4014",              /* class_name                   */
+       sizeof(TekWidgetRec),   /* widget_size                  */
+       NULL,                   /* class_initialize             */
+       NULL,                   /* class_part_initialize        */
+       False,                  /* class_inited                 */
+       TekInitialize,          /* initialize                   */
+       NULL,                   /* initialize_hook              */
+       TekRealize,             /* realize                      */
+       actionsList,            /* actions                      */
+       XtNumber(actionsList),  /* num_actions                  */
+       resources,              /* resources                    */
+       XtNumber(resources),    /* num_resources                */
+       NULLQUARK,              /* xrm_class                    */
+       True,                   /* compress_motion              */
+       True,                   /* compress_exposure            */
+       True,                   /* compress_enterleave          */
+       False,                  /* visible_interest             */
+       NULL,                   /* destroy                      */
+       TekConfigure,           /* resize                       */
+       TekExpose,              /* expose                       */
+       NULL,                   /* set_values                   */
+       NULL,                   /* set_values_hook              */
+       XtInheritSetValuesAlmost,       /* set_values_almost    */
+       NULL,                   /* get_values_hook              */
+       NULL,                   /* accept_focus                 */
+       XtVersion,              /* version                      */
+       NULL,                   /* callback_offsets             */
+       defaultTranslations,    /* tm_table                     */
+       XtInheritQueryGeometry, /* query_geometry               */
+       XtInheritDisplayAccelerator,    /* display_accelerator  */
+       NULL                    /* extension                    */
+    }
+};
+WidgetClass tekWidgetClass = (WidgetClass) & tekClassRec;
+
+static Bool Tfailed = False;
+
+int
+TekInit(void)
+{
+    Widget form_top, menu_top;
+    Dimension menu_high;
+
+    if (!Tfailed
+       && tekWidget == 0) {
+       Cardinal nargs = 0;
+       Arg myArgs[3];
+       Boolean iconic = 0;
+
+       TRACE(("TekInit\n"));
+       XtSetArg(myArgs[nargs], XtNiconic, &iconic);
+       ++nargs;
+       XtGetValues(toplevel, myArgs, nargs);
+
+       nargs = 0;
+       XtSetArg(myArgs[nargs], XtNiconic, iconic);
+       ++nargs;
+       XtSetArg(myArgs[nargs], XtNallowShellResize, True);
+       ++nargs;
+       XtSetArg(myArgs[nargs], XtNinput, True);
+       ++nargs;
+
+       /* this causes the Initialize method to be called */
+       tekshellwidget =
+           XtCreatePopupShell("tektronix", topLevelShellWidgetClass,
+                              toplevel, myArgs, nargs);
+
+       SetupMenus(tekshellwidget, &form_top, &menu_top, &menu_high);
+
+       /* this causes the Realize method to be called */
+       tekWidget = (TekWidget)
+           XtVaCreateManagedWidget("tek4014",
+                                   tekWidgetClass, form_top,
+#if OPT_TOOLBAR
+                                   XtNmenuBar, menu_top,
+                                   XtNresizable, True,
+                                   XtNfromVert, menu_top,
+                                   XtNtop, XawChainTop,
+                                   XtNleft, XawChainLeft,
+                                   XtNright, XawChainRight,
+                                   XtNbottom, XawChainBottom,
+                                   XtNmenuHeight, menu_high,
+#endif
+                                   (XtPointer) 0);
+#if OPT_TOOLBAR
+       ShowToolbar(resource.toolBar);
+#endif
+    }
+    return (!Tfailed);
+}
+
+/*
+ * If we haven't allocated the PtyData struct, do so.
+ */
+int
+TekPtyData(void)
+{
+    if (Tpushb == 0) {
+       if ((Tpushb = TypeMallocN(Char, 10)) == NULL
+           || (Tline = TypeMallocN(XSegment, MAX_VTX)) == NULL) {
+           fprintf(stderr, "%s: Not enough core for Tek mode\n", xterm_name);
+           if (Tpushb)
+               free(Tpushb);
+           Tfailed = True;
+           return 0;
+       }
+    }
+    return 1;
+}
+
+static void
+Tekparse(TekWidget tw)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    TekScreen *tekscr = TekScreenOf(tw);
+    int x, y;
+    IChar c = 0;
+    IChar ch;
+    int nextstate;
+
+    for (;;) {
+       c = input();
+       /*
+        * The parsing tables all have 256 entries.  If we're supporting
+        * wide characters, we handle them by treating them the same as
+        * printing characters.
+        */
+#if OPT_WIDE_CHARS
+       if (c > 255) {
+           nextstate = (Tparsestate == Talptable)
+               ? CASE_PRINT
+               : CASE_IGNORE;
+       } else
+#endif
+           nextstate = Tparsestate[c];
+       TRACE(("Tekparse %04X -> %d\n", c, nextstate));
+
+       switch (nextstate) {
+       case CASE_REPORT:
+           TRACE(("case: report address\n"));
+           if (tekscr->TekGIN) {
+               TekGINoff(tw);
+               TekEnqMouse(tw, 0);
+           } else {
+               c = 064;        /* has hard copy unit */
+               if (tekscr->margin == MARGIN2)
+                   c |= 02;
+               TekEnq(tw, c, tekscr->cur_X, tekscr->cur_Y);
+           }
+           TekRecord->ptr[-1] = ANSI_NAK;      /* remove from recording */
+           Tparsestate = curstate;
+           break;
+
+       case CASE_VT_MODE:
+           TRACE(("case: special return to vt102 mode\n"));
+           Tparsestate = curstate;
+           TekRecord->ptr[-1] = ANSI_NAK;      /* remove from recording */
+           FlushLog(xw);
+           return;
+
+       case CASE_SPT_STATE:
+           TRACE(("case: Enter Special Point Plot mode\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           Tparsestate = curstate = Tspttable;
+           break;
+
+       case CASE_GIN:
+           TRACE(("case: Do Tek GIN mode\n"));
+           tekscr->TekGIN = &TekRecord->ptr[-1];
+           /* Set cross-hair cursor raster array */
+           if ((GINcursor =
+                make_colored_cursor(XC_tcross,
+                                    T_COLOR(screen, MOUSE_FG),
+                                    T_COLOR(screen, MOUSE_BG))) != 0) {
+               XDefineCursor(XtDisplay(tw), TWindow(tekscr),
+                             GINcursor);
+           }
+           Tparsestate = Tbyptable;    /* Bypass mode */
+           break;
+
+       case CASE_BEL:
+           TRACE(("case: BEL\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           if (!tekRefreshList)
+               Bell(xw, XkbBI_TerminalBell, 0);
+           Tparsestate = curstate;     /* clear bypass condition */
+           break;
+
+       case CASE_BS:
+           TRACE(("case: BS\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           Tparsestate = curstate;     /* clear bypass condition */
+           TCursorBack(tw);
+           break;
+
+       case CASE_PT_STATE:
+           TRACE(("case: Enter Tek Point Plot mode\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           Tparsestate = curstate = Tpttable;
+           break;
+
+       case CASE_PLT_STATE:
+           TRACE(("case: Enter Tek Plot mode\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           Tparsestate = curstate = Tplttable;
+           if ((c = input()) == ANSI_BEL)
+               tekscr->pen = PENDOWN;
+           else {
+               unput(c);
+               tekscr->pen = PENUP;
+           }
+           break;
+
+       case CASE_TAB:
+           TRACE(("case: HT\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           Tparsestate = curstate;     /* clear bypass condition */
+           TCursorForward(tw);
+           break;
+
+       case CASE_IPL_STATE:
+           TRACE(("case: Enter Tek Incremental Plot mode\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           Tparsestate = curstate = Tipltable;
+           break;
+
+       case CASE_ALP_STATE:
+           TRACE(("case: Enter Tek Alpha mode from any other mode\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           /* if in one of graphics states, move alpha cursor */
+           if (nplot > 0)      /* flush line VTbuffer */
+               TekFlush(tw);
+           Tparsestate = curstate = Talptable;
+           break;
+
+       case CASE_UP:
+           TRACE(("case: cursor up\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           Tparsestate = curstate;     /* clear bypass condition */
+           TCursorUp(tw);
+           break;
+
+       case CASE_COPY:
+           TRACE(("case: make copy\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           TekCopy(tw);
+           TekRecord->ptr[-1] = ANSI_NAK;      /* remove from recording */
+           Tparsestate = curstate;     /* clear bypass condition */
+           break;
+
+       case CASE_PAGE:
+           TRACE(("case: Page Function\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           TekPage(tw);        /* clear bypass condition */
+           break;
+
+       case CASE_BES_STATE:
+           TRACE(("case: Byp: an escape char\n"));
+           Tparsestate = Tbestable;
+           break;
+
+       case CASE_BYP_STATE:
+           TRACE(("case: set bypass condition\n"));
+           Tparsestate = Tbyptable;
+           break;
+
+       case CASE_IGNORE:
+           TRACE(("case: Esc: totally ignore CR, ESC, LF, ~\n"));
+           break;
+
+       case CASE_ASCII:
+           TRACE(("case: Select ASCII char set\n"));
+           /* ignore for now */
+           Tparsestate = curstate;
+           break;
+
+       case CASE_APL:
+           TRACE(("case: Select APL char set\n"));
+           /* ignore for now */
+           Tparsestate = curstate;
+           break;
+
+       case CASE_CHAR_SIZE:
+           TRACE(("case: character size selector\n"));
+           TekSetFontSize(tw, False, (int) (c & 03));
+           Tparsestate = curstate;
+           break;
+
+       case CASE_BEAM_VEC:
+           TRACE(("case: beam and vector selector\n"));
+           /* only line types */
+           if ((c &= LINEMASK) != tekscr->cur.linetype) {
+               if (nplot > 0)
+                   TekFlush(tw);
+               if (c <= TEKNUMLINES)
+                   tekscr->cur.linetype = c;
+           }
+           Tparsestate = curstate;
+           break;
+
+       case CASE_CURSTATE:
+           Tparsestate = curstate;
+           break;
+
+       case CASE_PENUP:
+           TRACE(("case: Ipl: penup\n"));
+           tekscr->pen = PENUP;
+           break;
+
+       case CASE_PENDOWN:
+           TRACE(("case: Ipl: pendown\n"));
+           tekscr->pen = PENDOWN;
+           break;
+
+       case CASE_IPL_POINT:
+           TRACE(("case: Ipl: point\n"));
+           x = tekscr->cur_X;
+           y = tekscr->cur_Y;
+           if (c & NORTH)
+               y++;
+           else if (c & SOUTH)
+               y--;
+           if (c & EAST)
+               x++;
+           else if (c & WEST)
+               x--;
+           if (tekscr->pen == PENDOWN)
+               TekDraw(tw, x, y);
+           else
+               TekMove(tw, x, y);
+           break;
+
+       case CASE_PLT_VEC:
+           TRACE(("case: Plt: vector\n"));
+           unput(c);
+           if (getpoint(tw)) {
+               if (tekscr->pen == PENDOWN) {
+                   TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
+               } else {
+                   TekMove(tw, tekscr->cur.x, tekscr->cur.y);
+               }
+               tekscr->pen = PENDOWN;
+           }
+           break;
+
+       case CASE_PT_POINT:
+           TRACE(("case: Pt: point\n"));
+           unput(c);
+           if (getpoint(tw)) {
+               TekMove(tw, tekscr->cur.x, tekscr->cur.y);
+               TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
+           }
+           break;
+
+       case CASE_SPT_POINT:
+           TRACE(("case: Spt: point\n"));
+           /* ignore intensity character in c */
+           if (getpoint(tw)) {
+               TekMove(tw, tekscr->cur.x, tekscr->cur.y);
+               TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
+           }
+           break;
+
+       case CASE_CR:
+           TRACE(("case: CR\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           if (nplot > 0)      /* flush line VTbuffer */
+               TekFlush(tw);
+           tekscr->cur_X = tekscr->margin == MARGIN1 ? 0 :
+               TEKWIDTH / 2;
+           Tparsestate = curstate = Talptable;
+           break;
+
+       case CASE_ESC_STATE:
+           TRACE(("case: ESC\n"));
+           Tparsestate = Tesctable;
+           break;
+
+       case CASE_LF:
+           TRACE(("case: LF\n"));
+           if (tekscr->TekGIN)
+               TekGINoff(tw);
+           TCursorDown(tw);
+           if (!tekRefreshList)
+               do_xevents();
+           break;
+
+       case CASE_SP:
+           TRACE(("case: SP\n"));
+           TCursorForward(tw);
+           break;
+
+       case CASE_PRINT:
+           TRACE(("case: printable character\n"));
+           ch = c;
+           x = (int) (tekscr->cur_X * TekScale(tekscr))
+               + screen->border;
+           y = (int) ((TEKHEIGHT + TEKTOPPAD - tekscr->cur_Y) * TekScale(tekscr))
+               + screen->border;
+
+#if OPT_WIDE_CHARS
+           if (screen->wide_chars
+               && (ch > 255)) {
+               XChar2b sbuf;
+               sbuf.byte2 = LO_BYTE(ch);
+               sbuf.byte1 = HI_BYTE(ch);
+               XDrawImageString16(XtDisplay(tw),
+                                  TWindow(tekscr),
+                                  tekscr->TnormalGC,
+                                  x,
+                                  y,
+                                  &sbuf,
+                                  1);
+           } else
+#endif
+           {
+               char ch2 = (char) ch;
+               XDrawString(XtDisplay(tw),
+                           TWindow(tekscr),
+                           tekscr->TnormalGC,
+                           x,
+                           y,
+                           &ch2,
+                           1);
+           }
+           TCursorForward(tw);
+           break;
+       case CASE_OSC:
+           /* FIXME:  someone should disentangle the input queues
+            * of this code so that it can be state-driven.
+            */
+           TRACE(("case: do osc escape\n"));
+           {
+               /*
+                * do_osc() can call TekExpose(), which calls TekRefresh(),
+                * and sends us recurring here - don't do that...
+                */
+               static int nested;
+
+               Char buf2[512];
+               IChar c2;
+               size_t len = 0;
+               while ((c2 = input()) != ANSI_BEL) {
+                   if (!isprint((int) (c2 & 0x7f))
+                       || len + 2 >= (int) sizeof(buf2))
+                       break;
+                   buf2[len++] = (Char) c2;
+               }
+               buf2[len] = 0;
+               if (!nested++) {
+                   if (c2 == ANSI_BEL)
+                       do_osc(xw, buf2, len, ANSI_BEL);
+               }
+               --nested;
+           }
+           Tparsestate = curstate;
+           break;
+       }
+    }
+}
+
+static int rcnt;
+static char *rptr;
+static PtySelect Tselect_mask;
+
+static IChar
+Tinput(TekWidget tw)
+{
+    XtermWidget xw = term;
+    TekScreen *tekscr = TekScreenOf(tw);
+    TScreen *screen = TScreenOf(xw);
+    TekLink *tek;
+
+    if (Tpushback > Tpushb)
+       return (*--Tpushback);
+    if (tekRefreshList) {
+       if (rcnt-- > 0)
+           return (IChar) (*rptr++);
+       if ((tek = tekRefreshList->next) != 0) {
+           tekRefreshList = tek;
+           rptr = tek->data;
+           rcnt = tek->count - 1;
+           TekSetFontSize(tw, False, tek->fontsize);
+           return (IChar) (*rptr++);
+       }
+       tekRefreshList = (TekLink *) 0;
+       longjmp(Tekjump, 1);
+    }
+  again:
+    if (VTbuffer->next >= VTbuffer->last) {
+       int update = VTbuffer->update;
+
+       if (nplot > 0)          /* flush line */
+           TekFlush(tw);
+#ifdef VMS
+       Tselect_mask = pty_mask;        /* force a read */
+#else /* VMS */
+       XFD_COPYSET(&pty_mask, &Tselect_mask);
+#endif /* VMS */
+       for (;;) {
+#ifdef CRAY
+           struct timeval crocktimeout;
+           crocktimeout.tv_sec = 0;
+           crocktimeout.tv_usec = 0;
+           (void) Select(max_plus1,
+                         &Tselect_mask, NULL, NULL,
+                         &crocktimeout);
+#endif
+           if (readPtyData(xw, &Tselect_mask, VTbuffer)) {
+               break;
+           }
+           if (Ttoggled && curstate == Talptable) {
+               TCursorToggle(tw, TOGGLE);
+               Ttoggled = False;
+           }
+           if (XtAppPending(app_con) & XtIMXEvent) {
+#ifdef VMS
+               Tselect_mask = X_mask;
+#else /* VMS */
+               XFD_COPYSET(&X_mask, &Tselect_mask);
+#endif /* VMS */
+           } else {
+               XFlush(XtDisplay(tw));
+#ifdef VMS
+               Tselect_mask = Select_mask;
+
+#else /* VMS */
+               XFD_COPYSET(&Select_mask, &Tselect_mask);
+               if (Select(max_plus1, &Tselect_mask, NULL, NULL, NULL) < 0) {
+                   if (errno != EINTR)
+                       SysError(ERROR_TSELECT);
+                   continue;
+               }
+#endif /* VMS */
+           }
+#ifdef VMS
+           if (Tselect_mask & X_mask) {
+               xevents();
+               if (VTbuffer->update != update)
+                   goto again;
+           }
+#else /* VMS */
+           if (FD_ISSET(ConnectionNumber(XtDisplay(tw)), &Tselect_mask)) {
+               xevents();
+               if (VTbuffer->update != update)
+                   goto again;
+           }
+#endif /* VMS */
+       }
+       if (!Ttoggled && curstate == Talptable) {
+           TCursorToggle(tw, TOGGLE);
+           Ttoggled = True;
+       }
+    }
+    tek = TekRecord;
+    if (tek->count >= TEK_LINK_BLOCK_SIZE
+       || tek->fontsize != tekscr->cur.fontsize) {
+       if ((TekRecord = tek->next = CastMalloc(TekLink)) == 0) {
+           Panic("Tinput: malloc error (%d)\n", errno);
+       } else {
+           tek = tek->next;
+           tek->next = (TekLink *) 0;
+           tek->fontsize = (unsigned short) tekscr->cur.fontsize;
+           tek->count = 0;
+           tek->ptr = tek->data;
+       }
+    }
+    tek->count++;
+
+    (void) morePtyData(screen, VTbuffer);
+    return (IChar) (*tek->ptr++ = (char) nextPtyData(screen, VTbuffer));
+}
+
+static void
+TekClear(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+
+    if (TWindow(tekscr))
+       XClearWindow(XtDisplay(tw), TWindow(tekscr));
+}
+
+/* this should become the Tek Widget's Resize proc */
+static void
+TekConfigure(Widget w)
+{
+    TekWidget tw = getTekWidget(w);
+    if (tw != 0) {
+       XtermWidget xw = term;
+       TekScreen *tekscr = TekScreenOf(tw);
+       TScreen *screen = TScreenOf(xw);
+       int border = 2 * screen->border;
+       double d;
+
+       TekClear(tw);
+       TWidth(tekscr) = w->core.width - border;
+       THeight(tekscr) = w->core.height - border;
+       TekScale(tekscr) = (double) TWidth(tekscr) / TEKWIDTH;
+       if ((d = (double) THeight(tekscr) / (TEKHEIGHT + TEKTOPPAD + TEKBOTTOMPAD))
+           < TekScale(tekscr))
+           TekScale(tekscr) = d;
+       TFullWidth(tekscr) = w->core.width;
+       TFullHeight(tekscr) = w->core.height;
+    }
+}
+
+/*ARGSUSED*/
+void
+TekExpose(Widget w,
+         XEvent * event GCC_UNUSED,
+         Region region GCC_UNUSED)
+{
+    TekWidget tw = getTekWidget(w);
+    if (tw != 0) {
+       TekScreen *tekscr = TekScreenOf(tw);
+
+       TRACE(("TekExpose {{\n"));
+
+#ifdef lint
+       region = region;
+#endif
+       if (!Ttoggled)
+           TCursorToggle(tw, CLEAR);
+       Ttoggled = True;
+       Tpushback = Tpushb;
+       tekscr->cur_X = 0;
+       tekscr->cur_Y = TEKHOME;
+       tekscr->cur = tekscr->page;
+       TekSetFontSize(tw, False, tekscr->cur.fontsize);
+       tekscr->margin = MARGIN1;
+       if (tekscr->TekGIN) {
+           tekscr->TekGIN = NULL;
+           TekGINoff(tw);
+       }
+       tekRefreshList = &Tek0;
+       rptr = tekRefreshList->data;
+       rcnt = tekRefreshList->count;
+       Tparsestate = curstate = Talptable;
+       TRACE(("TekExpose resets data to replay %d bytes\n", rcnt));
+       first_map_occurred();
+       if (!tekscr->waitrefresh)
+           TekRefresh(tw);
+       TRACE(("}} TekExpose\n"));
+    }
+}
+
+void
+TekRefresh(TekWidget tw)
+{
+    if (tw != 0) {
+       XtermWidget xw = term;
+       TScreen *screen = TScreenOf(xw);
+       TekScreen *tekscr = TekScreenOf(tw);
+       static Cursor wait_cursor = None;
+
+       if (wait_cursor == None)
+           wait_cursor = make_colored_cursor(XC_watch,
+                                             T_COLOR(screen, MOUSE_FG),
+                                             T_COLOR(screen, MOUSE_BG));
+       XDefineCursor(XtDisplay(tw), TWindow(tekscr), wait_cursor);
+       XFlush(XtDisplay(tw));
+       if (!setjmp(Tekjump))
+           Tekparse(tw);
+       XDefineCursor(XtDisplay(tw), TWindow(tekscr),
+                     (tekscr->TekGIN && GINcursor) ? GINcursor : tekscr->arrow);
+    }
+}
+
+void
+TekRepaint(TekWidget tw)
+{
+    TRACE(("TekRepaint\n"));
+    TekClear(tw);
+    TekExpose((Widget) tw, (XEvent *) NULL, (Region) NULL);
+}
+
+static void
+TekPage(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+    TekLink *tek;
+
+    TekClear(tw);
+    tekscr->cur_X = 0;
+    tekscr->cur_Y = TEKHOME;
+    tekscr->margin = MARGIN1;
+    tekscr->page = tekscr->cur;
+    if (tekscr->TekGIN)
+       TekGINoff(tw);
+    tek = TekRecord = &Tek0;
+    tek->fontsize = (unsigned short) tekscr->cur.fontsize;
+    tek->count = 0;
+    tek->ptr = tek->data;
+    tek = tek->next;
+    if (tek)
+       do {
+           TekLink *tek2 = tek->next;
+
+           free(tek);
+           tek = tek2;
+       } while (tek);
+    TekRecord->next = (TekLink *) 0;
+    tekRefreshList = (TekLink *) 0;
+    Ttoggled = True;
+    Tparsestate = curstate = Talptable;                /* Tek Alpha mode */
+}
+
+#define        EXTRABITS       017
+#define        FIVEBITS        037
+#define        HIBITS          (FIVEBITS << SHIFTHI)
+#define        LOBITS          (FIVEBITS << SHIFTLO)
+#define        SHIFTHI         7
+#define        SHIFTLO         2
+#define        TWOBITS         03
+
+static int
+getpoint(TekWidget tw)
+{
+    int c, x, y, e, lo_y = 0;
+    TekScreen *tekscr = TekScreenOf(tw);
+
+    x = tekscr->cur.x;
+    y = tekscr->cur.y;
+    for (;;) {
+       if ((c = (int) input()) < ' ') {        /* control character */
+           unput(c);
+           return (0);
+       }
+       if (c < '@') {          /* Hi X or Hi Y */
+           if (lo_y) {         /* seen a Lo Y, so this must be Hi X */
+               x &= ~HIBITS;
+               x |= (c & FIVEBITS) << SHIFTHI;
+               continue;
+           }
+           /* else Hi Y */
+           y &= ~HIBITS;
+           y |= (c & FIVEBITS) << SHIFTHI;
+           continue;
+       }
+       if (c < '`') {          /* Lo X */
+           x &= ~LOBITS;
+           x |= (c & FIVEBITS) << SHIFTLO;
+           tekscr->cur.x = x;
+           tekscr->cur.y = y;
+           return (1);         /* OK */
+       }
+       /* else Lo Y */
+       if (lo_y) {             /* seen a Lo Y, so other must be extra bits */
+           e = (y >> SHIFTLO) & EXTRABITS;
+           x &= ~TWOBITS;
+           x |= e & TWOBITS;
+           y &= ~TWOBITS;
+           y |= (e >> SHIFTLO) & TWOBITS;
+       }
+       y &= ~LOBITS;
+       y |= (c & FIVEBITS) << SHIFTLO;
+       lo_y++;
+    }
+}
+
+static void
+TCursorBack(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+    struct Tek_Char *t;
+    int x, l;
+
+    x = (tekscr->cur_X -=
+        (t = &TekChar[tekscr->cur.fontsize])->hsize
+       );
+
+    if (((tekscr->margin == MARGIN1) && (x < 0))
+       || ((tekscr->margin == MARGIN2) && (x < TEKWIDTH / 2))) {
+       if ((l = (tekscr->cur_Y + (t->vsize - 1)) / t->vsize + 1) >=
+           t->nlines) {
+           tekscr->margin = !tekscr->margin;
+           l = 0;
+       }
+       tekscr->cur_Y = l * t->vsize;
+       tekscr->cur_X = (t->charsperline - 1) * t->hsize;
+    }
+}
+
+static void
+TCursorForward(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+    struct Tek_Char *t;
+    int l;
+
+    if ((tekscr->cur_X +=
+        (t = &TekChar[tekscr->cur.fontsize])->hsize
+       ) > TEKWIDTH
+       ) {
+       if ((l = tekscr->cur_Y / t->vsize - 1) < 0) {
+           tekscr->margin = !tekscr->margin;
+           l = t->nlines - 1;
+       }
+       tekscr->cur_Y = l * t->vsize;
+       tekscr->cur_X = tekscr->margin == MARGIN1 ? 0 : TEKWIDTH / 2;
+    }
+}
+
+static void
+TCursorUp(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+    struct Tek_Char *t;
+    int l;
+
+    t = &TekChar[tekscr->cur.fontsize];
+
+    if ((l = (tekscr->cur_Y + (t->vsize - 1)) / t->vsize + 1) >= t->nlines) {
+       l = 0;
+       if ((tekscr->margin = !tekscr->margin) != MARGIN1) {
+           if (tekscr->cur_X < TEKWIDTH / 2)
+               tekscr->cur_X += TEKWIDTH / 2;
+       } else if (tekscr->cur_X >= TEKWIDTH / 2)
+           tekscr->cur_X -= TEKWIDTH / 2;
+    }
+    tekscr->cur_Y = l * t->vsize;
+}
+
+static void
+TCursorDown(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+    struct Tek_Char *t;
+    int l;
+
+    t = &TekChar[tekscr->cur.fontsize];
+
+    if ((l = tekscr->cur_Y / t->vsize - 1) < 0) {
+       l = t->nlines - 1;
+       if ((tekscr->margin = !tekscr->margin) != MARGIN1) {
+           if (tekscr->cur_X < TEKWIDTH / 2)
+               tekscr->cur_X += TEKWIDTH / 2;
+       } else if (tekscr->cur_X >= TEKWIDTH / 2)
+           tekscr->cur_X -= TEKWIDTH / 2;
+    }
+    tekscr->cur_Y = l * t->vsize;
+}
+
+static void
+AddToDraw(TekWidget tw, int x1, int y1, int x2, int y2)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    TekScreen *tekscr = TekScreenOf(tw);
+    XSegment *lp;
+
+    TRACE(("AddToDraw (%d,%d) (%d,%d)\n", x1, y1, x2, y2));
+    if (nplot >= MAX_PTS) {
+       TekFlush(tw);
+    }
+    lp = line_pt++;
+    lp->x1 = (short) (x1 * TekScale(tekscr) + screen->border);
+    lp->y1 = (short) ((TEKHEIGHT + TEKTOPPAD - y1) * TekScale(tekscr) +
+                     screen->border);
+    lp->x2 = (short) (x2 * TekScale(tekscr) + screen->border);
+    lp->y2 = (short) ((TEKHEIGHT + TEKTOPPAD - y2) * TekScale(tekscr) +
+                     screen->border);
+    nplot++;
+    TRACE(("...AddToDraw %d points\n", nplot));
+}
+
+static void
+TekDraw(TekWidget tw, int x, int y)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+
+    if (nplot == 0 || T_lastx != tekscr->cur_X || T_lasty != tekscr->cur_Y) {
+       /*
+        * We flush on each unconnected line segment if the line
+        * type is not solid.  This solves a bug in X when drawing
+        * points while the line type is not solid.
+        */
+       if (nplot > 0 && tekscr->cur.linetype != SOLIDLINE)
+           TekFlush(tw);
+    }
+    AddToDraw(tw, tekscr->cur_X, tekscr->cur_Y, x, y);
+    T_lastx = tekscr->cur_X = x;
+    T_lasty = tekscr->cur_Y = y;
+}
+
+static void
+TekFlush(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+
+    TRACE(("TekFlush\n"));
+    XDrawSegments(XtDisplay(tw), TWindow(tekscr),
+                 ((tekscr->cur.linetype == SOLIDLINE)
+                  ? tekscr->TnormalGC
+                  : tekscr->linepat[tekscr->cur.linetype - 1]),
+                 Tline, nplot);
+    nplot = 0;
+    line_pt = Tline;
+}
+
+void
+TekGINoff(TekWidget tw)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+
+    TRACE(("TekGINoff\n"));
+    XDefineCursor(XtDisplay(tw), TWindow(tekscr), tekscr->arrow);
+    if (GINcursor)
+       XFreeCursor(XtDisplay(tw), GINcursor);
+    if (tekscr->TekGIN) {
+       *tekscr->TekGIN = ANSI_CAN;     /* modify recording */
+       tekscr->TekGIN = NULL;
+    }
+}
+
+void
+TekEnqMouse(TekWidget tw, int c)       /* character pressed */
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    TekScreen *tekscr = TekScreenOf(tw);
+    int mousex, mousey, rootx, rooty;
+    unsigned int mask;         /* XQueryPointer */
+    Window root, subw;
+
+    TRACE(("TekEnqMouse\n"));
+    XQueryPointer(
+                    XtDisplay(tw), TWindow(tekscr),
+                    &root, &subw,
+                    &rootx, &rooty,
+                    &mousex, &mousey,
+                    &mask);
+    if ((mousex = (int) ((mousex - screen->border) / TekScale(tekscr))) < 0)
+       mousex = 0;
+    else if (mousex >= TEKWIDTH)
+       mousex = TEKWIDTH - 1;
+    if ((mousey = (int) (TEKHEIGHT + TEKTOPPAD - (mousey - screen->border) /
+                        TekScale(tekscr))) < 0)
+       mousey = 0;
+    else if (mousey >= TEKHEIGHT)
+       mousey = TEKHEIGHT - 1;
+    TekEnq(tw, (unsigned) c, mousex, mousey);
+}
+
+static void
+TekEnq(TekWidget tw,
+       unsigned status,
+       int x,
+       int y)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    TekScreen *tekscr = TekScreenOf(tw);
+    Char cplot[7];
+    int len = 5;
+    int adj = (status != 0) ? 0 : 1;
+
+    TRACE(("TekEnq\n"));
+    cplot[0] = (Char) status;
+    /* Translate x and y to Tektronix code */
+    cplot[1] = (Char) (040 | ((x >> SHIFTHI) & FIVEBITS));
+    cplot[2] = (Char) (040 | ((x >> SHIFTLO) & FIVEBITS));
+    cplot[3] = (Char) (040 | ((y >> SHIFTHI) & FIVEBITS));
+    cplot[4] = (Char) (040 | ((y >> SHIFTLO) & FIVEBITS));
+
+    if (tekscr->gin_terminator != GIN_TERM_NONE)
+       cplot[len++] = '\r';
+    if (tekscr->gin_terminator == GIN_TERM_EOT)
+       cplot[len++] = '\004';
+#ifdef VMS
+    tt_write(cplot + adj, len - adj);
+#else /* VMS */
+    v_write(screen->respond, cplot + adj, (unsigned) (len - adj));
+#endif /* VMS */
+}
+
+void
+TekRun(void)
+{
+    XtermWidget xw = term;
+
+    assert(xw != 0);
+    if (tekWidget == 0) {
+       TekInit();
+    }
+    if (tekWidget != 0) {
+       TRACE(("TekRun ...\n"));
+
+       if (!TEK4014_SHOWN(xw)) {
+           set_tek_visibility(True);
+       }
+       update_vttekmode();
+       update_vtshow();
+       update_tekshow();
+       set_tekhide_sensitivity();
+
+       Tpushback = Tpushb;
+       Ttoggled = True;
+       if (!setjmp(Tekend))
+           Tekparse(tekWidget);
+       if (!Ttoggled) {
+           TCursorToggle(tekWidget, TOGGLE);
+           Ttoggled = True;
+       }
+       TEK4014_ACTIVE(xw) = False;
+    } else {
+       TEK4014_ACTIVE(xw) = False;
+       if (VWindow(TScreenOf(xw)) == 0) {
+           Exit(ERROR_TINIT);
+       }
+    }
+}
+
+#define DOTTED_LENGTH 2
+#define DOT_DASHED_LENGTH 4
+#define SHORT_DASHED_LENGTH 2
+#define LONG_DASHED_LENGTH 2
+
+static int dash_length[TEKNUMLINES] =
+{
+    DOTTED_LENGTH,
+    DOT_DASHED_LENGTH,
+    SHORT_DASHED_LENGTH,
+    LONG_DASHED_LENGTH,
+};
+
+static unsigned char dotted[DOTTED_LENGTH] =
+{3, 1};
+static unsigned char dot_dashed[DOT_DASHED_LENGTH] =
+{3, 4, 3, 1};
+static unsigned char short_dashed[SHORT_DASHED_LENGTH] =
+{4, 4};
+static unsigned char long_dashed[LONG_DASHED_LENGTH] =
+{4, 7};
+
+static unsigned char *dashes[TEKNUMLINES] =
+{
+    dotted,
+    dot_dashed,
+    short_dashed,
+    long_dashed,
+};
+
+/*
+ * The following is called to create the tekWidget
+ */
+
+static void
+TekInitialize(Widget wrequest,
+             Widget new_arg,
+             ArgList args GCC_UNUSED,
+             Cardinal *num_args GCC_UNUSED)
+{
+    TekWidget request = (TekWidget) wrequest;
+    TekWidget wnew = (TekWidget) new_arg;
+    Widget tekparent = SHELL_OF(wnew);
+#ifndef NO_ACTIVE_ICON
+    TekScreen *screen = TekScreenOf((TekWidget) wnew);
+#endif
+    int n;
+
+    TRACE(("TekInitialize\n"));
+
+    /* look for focus related events on the shell, because we need
+     * to care about the shell's border being part of our focus.
+     */
+    XtAddEventHandler(tekparent, EnterWindowMask, False,
+                     HandleEnterWindow, (Opaque) 0);
+    XtAddEventHandler(tekparent, LeaveWindowMask, False,
+                     HandleLeaveWindow, (Opaque) 0);
+    XtAddEventHandler(tekparent, FocusChangeMask, False,
+                     HandleFocusChange, (Opaque) 0);
+    XtAddEventHandler(new_arg, PropertyChangeMask, False,
+                     HandleBellPropertyChange, (Opaque) 0);
+
+#ifndef NO_ACTIVE_ICON
+    screen->whichTwin = &(screen->fullTwin);
+#endif /* NO_ACTIVE_ICON */
+
+    for (n = 0; n < TEKNUMFONTS; ++n) {
+       wnew->tek.Tfont[n] = request->tek.Tfont[n];
+    }
+
+    init_Sres(tek.initial_font);
+    init_Sres(tek.gin_terminator_str);
+#if OPT_TOOLBAR
+    init_Ires(tek.tb_info.menu_height);
+    wnew->tek.tb_info.menu_bar = request->tek.tb_info.menu_bar;
+#endif
+}
+
+static void
+TekRealize(Widget gw,
+          XtValueMask * valuemaskp,
+          XSetWindowAttributes * values)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    TekWidget tw = (TekWidget) gw;
+    TekScreen *tekscr = TekScreenOf(tw);
+    int i;
+    TekLink *tek;
+    double d;
+    int border = 2 * screen->border;
+    int pr;
+    XGCValues gcv;
+    int winX, winY;
+    unsigned width, height;
+    char Tdefault[32];
+    unsigned long TEKgcFontMask;
+
+    TRACE(("TekRealize\n"));
+    memset(tekscr, 0, sizeof(*tekscr));
+
+#ifndef NO_ACTIVE_ICON
+    tekscr->whichTwin = &tekscr->fullTwin;
+#endif /* NO_ACTIVE_ICON */
+
+    BorderPixel(tw) = BorderPixel(xw);
+
+    tekscr->arrow = make_colored_cursor(XC_left_ptr,
+                                       T_COLOR(screen, MOUSE_FG),
+                                       T_COLOR(screen, MOUSE_BG));
+
+    for (i = 0; i < TEKNUMFONTS; i++) {
+       if (!tw->tek.Tfont[i]) {
+           tw->tek.Tfont[i] = XQueryFont(XtDisplay(tw), DefaultGCID);
+       }
+       TRACE(("Tfont[%d] %dx%d\n",
+              i,
+              tw->tek.Tfont[i]->ascent +
+              tw->tek.Tfont[i]->descent,
+              tw->tek.Tfont[i]->max_bounds.width));
+       tw->tek.tobaseline[i] = tw->tek.Tfont[i]->ascent;
+    }
+
+    if (!TekPtyData())
+       return;
+
+    if (xw->misc.T_geometry == NULL) {
+       int defwidth, defheight;
+
+       if (xw->misc.tekSmall) {
+           defwidth = TEKMINWIDTH;
+           defheight = TEKMINHEIGHT;
+       } else {
+           defwidth = TEKDEFWIDTH;
+           defheight = TEKDEFHEIGHT;
+       }
+       sprintf(Tdefault, "=%dx%d", defwidth + border, defheight + border);
+       xw->misc.T_geometry = Tdefault;
+    }
+
+    winX = 1;
+    winY = 1;
+    width = (unsigned) (TEKDEFWIDTH + border);
+    height = (unsigned) (TEKDEFHEIGHT + border);
+
+    TRACE(("parsing T_geometry %s\n", NonNull(xw->misc.T_geometry)));
+    pr = XParseGeometry(xw->misc.T_geometry,
+                       &winX,
+                       &winY,
+                       &width,
+                       &height);
+    TRACE(("... position %d,%d size %dx%d\n", winY, winX, height, width));
+    if ((pr & XValue) && (pr & XNegative))
+       winX += DisplayWidth(XtDisplay(tw), DefaultScreen(XtDisplay(tw)))
+           - (int) width - (BorderWidth(SHELL_OF(xw)) * 2);
+    if ((pr & YValue) && (pr & YNegative))
+       winY += DisplayHeight(XtDisplay(tw), DefaultScreen(XtDisplay(tw)))
+           - (int) height - (BorderWidth(SHELL_OF(xw)) * 2);
+
+    /* set up size hints */
+    tw->hints.min_width = TEKMINWIDTH + border;
+    tw->hints.min_height = TEKMINHEIGHT + border;
+    tw->hints.width_inc = 1;
+    tw->hints.height_inc = 1;
+    tw->hints.flags = PMinSize | PResizeInc;
+    tw->hints.x = winX;
+    tw->hints.y = winY;
+    if ((XValue & pr) || (YValue & pr)) {
+       tw->hints.flags |= USSize | USPosition;
+       tw->hints.flags |= PWinGravity;
+       switch (pr & (XNegative | YNegative)) {
+       case 0:
+           tw->hints.win_gravity = NorthWestGravity;
+           break;
+       case XNegative:
+           tw->hints.win_gravity = NorthEastGravity;
+           break;
+       case YNegative:
+           tw->hints.win_gravity = SouthWestGravity;
+           break;
+       default:
+           tw->hints.win_gravity = SouthEastGravity;
+           break;
+       }
+    } else {
+       /* set a default size, but do *not* set position */
+       tw->hints.flags |= PSize;
+    }
+    tw->hints.width = (int) width;
+    tw->hints.height = (int) height;
+    if ((WidthValue & pr) || (HeightValue & pr))
+       tw->hints.flags |= USSize;
+    else
+       tw->hints.flags |= PSize;
+
+    (void) REQ_RESIZE((Widget) tw,
+                     (Dimension) width, (Dimension) height,
+                     &tw->core.width, &tw->core.height);
+
+    /* XXX This is bogus.  We are parsing geometries too late.  This
+     * is information that the shell widget ought to have before we get
+     * realized, so that it can do the right thing.
+     */
+    if (tw->hints.flags & USPosition)
+       XMoveWindow(XtDisplay(tw), TShellWindow, tw->hints.x, tw->hints.y);
+
+    XSetWMNormalHints(XtDisplay(tw), TShellWindow, &tw->hints);
+    XFlush(XtDisplay(tw));     /* get it out to window manager */
+
+    values->win_gravity = NorthWestGravity;
+    values->background_pixel = T_COLOR(screen, TEK_BG);
+
+    XtWindow(tw) = TWindow(tekscr) =
+       XCreateWindow(XtDisplay(tw),
+                     VShellWindow(tw),
+                     tw->core.x, tw->core.y,
+                     tw->core.width, tw->core.height,
+                     BorderWidth(tw),
+                     (int) tw->core.depth,
+                     InputOutput, CopyFromParent,
+                     ((*valuemaskp) | CWBackPixel | CWWinGravity),
+                     values);
+
+    TFullWidth(tekscr) = (Dimension) width;
+    TFullHeight(tekscr) = (Dimension) height;
+    TWidth(tekscr) = (int) width - border;
+    THeight(tekscr) = (int) height - border;
+    TekScale(tekscr) = (double) TWidth(tekscr) / TEKWIDTH;
+    if ((d = (double) THeight(tekscr) / (TEKHEIGHT + TEKTOPPAD +
+                                        TEKBOTTOMPAD)) < TekScale(tekscr))
+       TekScale(tekscr) = d;
+
+    tekscr->cur.fontsize = TEK_FONT_LARGE;
+    if (tw->tek.initial_font) {
+       int result = TekGetFontSize(tw->tek.initial_font);
+       if (result >= 0)
+           tekscr->cur.fontsize = result;
+    }
+#define TestGIN(s) XmuCompareISOLatin1(tw->tek.gin_terminator_str, s)
+
+    if (TestGIN(GIN_TERM_NONE_STR) == 0)
+       tekscr->gin_terminator = GIN_TERM_NONE;
+    else if (TestGIN(GIN_TERM_CR_STR) == 0)
+       tekscr->gin_terminator = GIN_TERM_CR;
+    else if (TestGIN(GIN_TERM_EOT_STR) == 0)
+       tekscr->gin_terminator = GIN_TERM_EOT;
+    else
+       fprintf(stderr, "%s: illegal GIN terminator setting \"%s\"\n",
+               xterm_name, tw->tek.gin_terminator_str);
+
+    gcv.graphics_exposures = True;     /* default */
+    gcv.font = tw->tek.Tfont[tekscr->cur.fontsize]->fid;
+    gcv.foreground = T_COLOR(screen, TEK_FG);
+    gcv.background = T_COLOR(screen, TEK_BG);
+
+    /* if font wasn't successfully opened, then gcv.font will contain
+       the Default GC's ID, meaning that we must use the server default font.
+     */
+    TEKgcFontMask = (unsigned long) ((gcv.font == DefaultGCID) ? 0 : GCFont);
+    tekscr->TnormalGC = XCreateGC(XtDisplay(tw), TWindow(tekscr),
+                                 (TEKgcFontMask | GCGraphicsExposures |
+                                  GCForeground | GCBackground),
+                                 &gcv);
+
+    gcv.function = GXinvert;
+    gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
+                     T_COLOR(screen, TEK_CURSOR));
+    gcv.join_style = JoinMiter;        /* default */
+    gcv.line_width = 1;
+    tekscr->TcursorGC = XCreateGC(XtDisplay(tw), TWindow(tekscr),
+                                 (GCFunction | GCPlaneMask), &gcv);
+
+    gcv.foreground = T_COLOR(screen, TEK_FG);
+    gcv.line_style = LineOnOffDash;
+    gcv.line_width = 0;
+    for (i = 0; i < TEKNUMLINES; i++) {
+       tekscr->linepat[i] = XCreateGC(XtDisplay(tw), TWindow(tekscr),
+                                      (GCForeground | GCLineStyle), &gcv);
+       XSetDashes(XtDisplay(tw), tekscr->linepat[i], 0,
+                  (char *) dashes[i], dash_length[i]);
+    }
+
+    TekBackground(tw, screen);
+
+    tekscr->margin = MARGIN1;  /* Margin 1             */
+    tekscr->TekGIN = False;    /* GIN off              */
+
+    XDefineCursor(XtDisplay(tw), TWindow(tekscr), tekscr->arrow);
+
+    {                          /* there's gotta be a better way... */
+       static Arg args[] =
+       {
+           {XtNtitle, (XtArgVal) NULL},
+           {XtNiconName, (XtArgVal) NULL},
+       };
+       char *icon_name, *title, *tek_icon_name, *tek_title;
+
+       args[0].value = (XtArgVal) & icon_name;
+       args[1].value = (XtArgVal) & title;
+       XtGetValues(SHELL_OF(tw), args, 2);
+       tek_icon_name = XtMalloc((Cardinal) strlen(icon_name) + 7);
+       strcpy(tek_icon_name, icon_name);
+       strcat(tek_icon_name, "(Tek)");
+       tek_title = XtMalloc((Cardinal) strlen(title) + 7);
+       strcpy(tek_title, title);
+       strcat(tek_title, "(Tek)");
+       args[0].value = (XtArgVal) tek_icon_name;
+       args[1].value = (XtArgVal) tek_title;
+       XtSetValues(SHELL_OF(tw), args, 2);
+       XtFree(tek_icon_name);
+       XtFree(tek_title);
+    }
+
+    tek = TekRecord = &Tek0;
+    tek->next = (TekLink *) 0;
+    tek->fontsize = (unsigned short) tekscr->cur.fontsize;
+    tek->count = 0;
+    tek->ptr = tek->data;
+    Tpushback = Tpushb;
+    tekscr->cur_X = 0;
+    tekscr->cur_Y = TEKHOME;
+    line_pt = Tline;
+    Ttoggled = True;
+    tekscr->page = tekscr->cur;
+    return;
+}
+
+int
+TekGetFontSize(const char *param)
+{
+    int result;
+
+    if (XmuCompareISOLatin1(param, "l") == 0 ||
+       XmuCompareISOLatin1(param, "large") == 0)
+       result = TEK_FONT_LARGE;
+    else if (XmuCompareISOLatin1(param, "2") == 0 ||
+            XmuCompareISOLatin1(param, "two") == 0)
+       result = TEK_FONT_2;
+    else if (XmuCompareISOLatin1(param, "3") == 0 ||
+            XmuCompareISOLatin1(param, "three") == 0)
+       result = TEK_FONT_3;
+    else if (XmuCompareISOLatin1(param, "s") == 0 ||
+            XmuCompareISOLatin1(param, "small") == 0)
+       result = TEK_FONT_SMALL;
+    else
+       result = -1;
+
+    return result;
+}
+
+void
+TekSetFontSize(TekWidget tw, Bool fromMenu, int newitem)
+{
+    if (tw != 0) {
+       XtermWidget xw = term;
+       TekScreen *tekscr = TekScreenOf(tw);
+       int oldsize = tekscr->cur.fontsize;
+       int newsize = MI2FS(newitem);
+       Font fid;
+
+       TRACE(("TekSetFontSize(%d) size %d ->%d\n", newitem, oldsize, newsize));
+       if (newsize < 0 || newsize >= TEKNUMFONTS) {
+           Bell(xw, XkbBI_MinorError, 0);
+       } else if (oldsize != newsize) {
+           if (!Ttoggled)
+               TCursorToggle(tw, TOGGLE);
+           set_tekfont_menu_item(oldsize, False);
+
+           tekscr->cur.fontsize = newsize;
+           if (fromMenu)
+               tekscr->page.fontsize = newsize;
+
+           fid = tw->tek.Tfont[newsize]->fid;
+           if (fid == DefaultGCID) {
+               /* we didn't succeed in opening a real font
+                  for this size.  Instead, use server default. */
+               XCopyGC(XtDisplay(tw),
+                       DefaultGC(XtDisplay(tw), DefaultScreen(XtDisplay(tw))),
+                       GCFont, tekscr->TnormalGC);
+           } else {
+               XSetFont(XtDisplay(tw), tekscr->TnormalGC, fid);
+           }
+
+           set_tekfont_menu_item(newsize, True);
+           if (!Ttoggled)
+               TCursorToggle(tw, TOGGLE);
+
+           if (fromMenu) {
+               /* we'll get an exposure event after changing fontsize, so we
+                * have to clear the screen to avoid painting over the previous
+                * text.
+                */
+               TekClear(tw);
+           }
+       }
+    }
+}
+
+void
+ChangeTekColors(TekWidget tw, TScreen * screen, ScrnColors * pNew)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+    int i;
+    XGCValues gcv;
+
+    if (COLOR_DEFINED(pNew, TEK_FG)) {
+       T_COLOR(screen, TEK_FG) = COLOR_VALUE(pNew, TEK_FG);
+       TRACE(("... TEK_FG: %#lx\n", T_COLOR(screen, TEK_FG)));
+    }
+    if (COLOR_DEFINED(pNew, TEK_BG)) {
+       T_COLOR(screen, TEK_BG) = COLOR_VALUE(pNew, TEK_BG);
+       TRACE(("... TEK_BG: %#lx\n", T_COLOR(screen, TEK_BG)));
+    }
+    if (COLOR_DEFINED(pNew, TEK_CURSOR)) {
+       T_COLOR(screen, TEK_CURSOR) = COLOR_VALUE(pNew, TEK_CURSOR);
+       TRACE(("... TEK_CURSOR: %#lx\n", T_COLOR(screen, TEK_CURSOR)));
+    } else {
+       T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG);
+       TRACE(("... TEK_CURSOR: %#lx\n", T_COLOR(screen, TEK_CURSOR)));
+    }
+
+    if (tw) {
+       XSetForeground(XtDisplay(tw), tekscr->TnormalGC,
+                      T_COLOR(screen, TEK_FG));
+       XSetBackground(XtDisplay(tw), tekscr->TnormalGC,
+                      T_COLOR(screen, TEK_BG));
+       if (BorderPixel(tw) == T_COLOR(screen, TEK_BG)) {
+           BorderPixel(tw) = T_COLOR(screen, TEK_FG);
+           BorderPixel(XtParent(tw)) = T_COLOR(screen, TEK_FG);
+           if (XtWindow(XtParent(tw)))
+               XSetWindowBorder(XtDisplay(tw),
+                                XtWindow(XtParent(tw)),
+                                BorderPixel(tw));
+       }
+
+       for (i = 0; i < TEKNUMLINES; i++) {
+           XSetForeground(XtDisplay(tw), tekscr->linepat[i],
+                          T_COLOR(screen, TEK_FG));
+       }
+
+       gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
+                         T_COLOR(screen, TEK_CURSOR));
+       XChangeGC(XtDisplay(tw), tekscr->TcursorGC, GCPlaneMask, &gcv);
+       TekBackground(tw, screen);
+    }
+    return;
+}
+
+void
+TekReverseVideo(TekWidget tw)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    TekScreen *tekscr = TekScreenOf(tw);
+    int i;
+    Pixel tmp;
+    XGCValues gcv;
+
+    EXCHANGE(T_COLOR(screen, TEK_FG), T_COLOR(screen, TEK_BG), tmp);
+
+    T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG);
+
+    if (tw) {
+       XSetForeground(XtDisplay(tw), tekscr->TnormalGC, T_COLOR(screen, TEK_FG));
+       XSetBackground(XtDisplay(tw), tekscr->TnormalGC, T_COLOR(screen, TEK_BG));
+
+       if (BorderPixel(tw) == T_COLOR(screen, TEK_BG)) {
+           BorderPixel(tw) = T_COLOR(screen, TEK_FG);
+           BorderPixel(XtParent(tw)) = T_COLOR(screen, TEK_FG);
+           if (XtWindow(XtParent(tw)))
+               XSetWindowBorder(XtDisplay(tw),
+                                XtWindow(XtParent(tw)),
+                                BorderPixel(tw));
+       }
+
+       for (i = 0; i < TEKNUMLINES; i++) {
+           XSetForeground(XtDisplay(tw), tekscr->linepat[i],
+                          T_COLOR(screen, TEK_FG));
+       }
+
+       gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
+                         T_COLOR(screen, TEK_CURSOR));
+       XChangeGC(XtDisplay(tw), tekscr->TcursorGC, GCPlaneMask, &gcv);
+       TekBackground(tw, screen);
+    }
+}
+
+static void
+TekBackground(TekWidget tw, TScreen * screen)
+{
+    TekScreen *tekscr = TekScreenOf(tw);
+
+    if (TWindow(tekscr))
+       XSetWindowBackground(XtDisplay(tw), TWindow(tekscr),
+                            T_COLOR(screen, TEK_BG));
+}
+
+/*
+ * Toggles cursor on or off at cursor position in screen.
+ */
+void
+TCursorToggle(TekWidget tw, int toggle)                /* TOGGLE or CLEAR */
+{
+    XtermWidget xw = term;
+    TekScreen *tekscr = TekScreenOf(tw);
+    TScreen *screen = TScreenOf(xw);
+    int c, x, y;
+    unsigned int cellwidth, cellheight;
+
+    if (!TEK4014_SHOWN(xw))
+       return;
+
+    TRACE(("TCursorToggle %s\n", (toggle == TOGGLE) ? "toggle" : "clear"));
+    c = tekscr->cur.fontsize;
+    cellwidth = (unsigned) tw->tek.Tfont[c]->max_bounds.width;
+    cellheight = (unsigned) (tw->tek.Tfont[c]->ascent +
+                            tw->tek.Tfont[c]->descent);
+
+    x = (int) ((tekscr->cur_X * TekScale(tekscr)) + screen->border);
+    y = (int) (((TEKHEIGHT + TEKTOPPAD - tekscr->cur_Y) * TekScale(tekscr))
+              + screen->border - tw->tek.tobaseline[c]);
+
+    if (toggle == TOGGLE) {
+       if (screen->select || screen->always_highlight)
+           XFillRectangle(XtDisplay(tw), TWindow(tekscr),
+                          tekscr->TcursorGC, x, y,
+                          cellwidth, cellheight);
+       else {                  /* fix to use different GC! */
+           XDrawRectangle(XtDisplay(tw), TWindow(tekscr),
+                          tekscr->TcursorGC, x, y,
+                          cellwidth - 1, cellheight - 1);
+       }
+    } else {
+       /* Clear the entire rectangle, even though we may only
+        * have drawn an outline.  This fits with our refresh
+        * scheme of redrawing the entire window on any expose
+        * event and is easier than trying to figure out exactly
+        * which part of the cursor needs to be erased.
+        */
+       XClearArea(XtDisplay(tw), TWindow(tekscr), x, y,
+                  cellwidth, cellheight, False);
+    }
+}
+
+void
+TekSimulatePageButton(TekWidget tw, Bool reset)
+{
+    if (tw != 0) {
+       TekScreen *tekscr = TekScreenOf(tw);
+
+       if (reset) {
+           memset(&tekscr->cur, 0, sizeof tekscr->cur);
+       }
+       tekRefreshList = (TekLink *) 0;
+       TekPage(tw);
+       tekscr->cur_X = 0;
+       tekscr->cur_Y = TEKHOME;
+    }
+}
+
+/* write copy of screen to a file */
+
+void
+TekCopy(TekWidget tw)
+{
+    if (tw != 0) {
+       XtermWidget xw = term;
+       TekScreen *tekscr = TekScreenOf(tw);
+       TScreen *screen = TScreenOf(xw);
+
+       TekLink *Tp;
+       char buf[32];
+       char initbuf[5];
+       int tekcopyfd;
+
+       timestamp_filename(buf, "COPY");
+       if (access(buf, F_OK) >= 0
+           && access(buf, W_OK) < 0) {
+           Bell(xw, XkbBI_MinorError, 0);
+           return;
+       }
+#ifndef VMS
+       if (access(".", W_OK) < 0) {    /* can't write in directory */
+           Bell(xw, XkbBI_MinorError, 0);
+           return;
+       }
+#endif
+
+       tekcopyfd = open_userfile(screen->uid, screen->gid, buf, False);
+       if (tekcopyfd >= 0) {
+           sprintf(initbuf, "%c%c%c%c",
+                   ANSI_ESC, (char) (tekscr->page.fontsize + '8'),
+                   ANSI_ESC, (char) (tekscr->page.linetype + '`'));
+           IGNORE_RC(write(tekcopyfd, initbuf, (size_t) 4));
+           Tp = &Tek0;
+           do {
+               IGNORE_RC(write(tekcopyfd, Tp->data, (size_t) Tp->count));
+               Tp = Tp->next;
+           } while (Tp);
+           close(tekcopyfd);
+       }
+    }
+}
+
+/*ARGSUSED*/
+void
+HandleGINInput(Widget w,
+              XEvent * event GCC_UNUSED,
+              String * param_list,
+              Cardinal *nparamsp)
+{
+    XtermWidget xw = term;
+    TekWidget tw = getTekWidget(w);
+
+    if (tw != 0) {
+       TekScreen *tekscr = TekScreenOf(tw);
+
+       if (tekscr->TekGIN && *nparamsp == 1) {
+           int c = param_list[0][0];
+           switch (c) {
+           case 'l':
+           case 'm':
+           case 'r':
+           case 'L':
+           case 'M':
+           case 'R':
+               break;
+           default:
+               Bell(xw, XkbBI_MinorError, 0);  /* let them know they goofed */
+               c = 'l';        /* provide a default */
+           }
+           TekEnqMouse(tw, c | 0x80);
+           TekGINoff(tw);
+       } else {
+           Bell(xw, XkbBI_MinorError, 0);
+       }
+    }
+}
+
+/*
+ * Check if the current widget, or any parent, is the VT100 "xterm" widget.
+ */
+TekWidget
+getTekWidget(Widget w)
+{
+    TekWidget xw;
+
+    if (w == 0) {
+       xw = (TekWidget) CURRENT_EMU();
+       if (!IsTekWidget(xw)) {
+           xw = 0;
+       }
+    } else if (IsTekWidget(w)) {
+       xw = (TekWidget) w;
+    } else {
+       xw = getTekWidget(XtParent(w));
+    }
+    TRACE2(("getTekWidget %p -> %p\n", w, xw));
+    return xw;
+}
diff --git a/Tests b/Tests
new file mode 100644 (file)
index 0000000..0c6c889
--- /dev/null
+++ b/Tests
@@ -0,0 +1,42 @@
+Tests for xterm:
+
+If system supports window size (i.e., some combination of SIGWINCH,
+TIOCSSIZE, TIOCSWINSZ), start a full-screen program (e.g., Emacs,
+Jove, vi) and resize the xterm window.  The program must immediately
+update its screen image for the new size.
+
+If compiled with -DUTMP, starting a new xterm should create a new utmp
+entry.  ("who" will show this info.)  Exiting xterm should remove the
+entry.  Killing the xterm window (or other unnatural exit) should also
+remove the entry.  When should entries be made in the wtmp file?
+
+Process group stuff should be correct.
+
+Should work without access to /dev/tty, say started from an xdm
+started from a boot-time script.
+
+If "xterm -help" offers the -C option, it should work.
+
+echo "test" > /dev/tty
+
+vi with lines that wrap.
+
+Exec'ing things other than shells.
+
+Another thing that has caused problems in the past is process groups,
+especially w.r.t. signal propagation to the child.
+
+Popup menu signals: running only a shell, click on "Send INT Signal."
+Do you get a new prompt from the shell?  (Same as typing ^C at it.)
+
+Should scroll *fast* with jumpScroll enabled.
+
+While a mouse button is down tracing out a selection, output to the
+screen should be suspended.
+
+Selections more than one screen long.
+
+start xterm running only Tek widget: "xterm -t"
+
+
+Please add to this list if you find xterm failing in some way.
diff --git a/UXTerm.ad b/UXTerm.ad
new file mode 100644 (file)
index 0000000..a2cca85
--- /dev/null
+++ b/UXTerm.ad
@@ -0,0 +1,76 @@
+! $XTermId: UXTerm.ad,v 1.13 2010/03/04 01:17:07 tom Exp $
+! -----------------------------------------------------------------------------
+! this file is part of xterm
+!
+! Copyright 2000-2006,2010 by Thomas E. Dickey
+! 
+!                         All Rights Reserved
+! 
+! Permission is hereby granted, free of charge, to any person obtaining a
+! copy of this software and associated documentation files (the
+! "Software"), to deal in the Software without restriction, including
+! without limitation the rights to use, copy, modify, merge, publish,
+! distribute, sublicense, and/or sell copies of the Software, and to
+! permit persons to whom the Software is furnished to do so, subject to
+! the following conditions:
+! 
+! The above copyright notice and this permission notice shall be included
+! in all copies or substantial portions of the Software.
+! 
+! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+! IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+! CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+! TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+! SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+! 
+! Except as contained in this notice, the name(s) of the above copyright
+! holders shall not be used in advertising or otherwise to promote the
+! sale, use or other dealings in this Software without prior written
+! authorization.
+! -----------------------------------------------------------------------------
+! Use
+!      xterm -class UXTerm
+! to set resources for UTF-8 mode with corresponding fonts.
+! See the uxterm script for an example.
+
+#include "XTerm"
+
+*fontMenu.Label:  Unicode Fonts
+*VT100.utf8:   1
+
+! This includes "XTerm-color" which includes "XTerm", which defines fonts.
+! Why set them here?
+!
+! Here is a simple description.  A technically precise one would be very long.
+! When xterm starts up, it uses the
+!
+!      *VT100.font
+!
+! resource, and if it is told to switch to wide-character (UTF-8) mode, it
+! checks if the given font is "wide", and if not looks for the
+!
+!      *VT100.utf8Fonts.font
+!
+! to obtain a wide font.  A "wide" font has more than 256 glyphs.  Typical
+! wide fonts have 10,000 glyphs.  If the original "*VT100.font" is not wide,
+! and xterm can load the *VT100.utf8Fonts.font, it will use that.
+!
+! Making the wide fonts associated with *VT100.font in this file allows uxterm
+! to skip that step.  It will use the fonts that the XTerm file gives for the
+! *VT100.uft8Fonts.font pattern.
+*VT100.font2:  -misc-fixed-medium-r-normal--8-80-75-75-c-50-iso10646-1
+*VT100.font:   -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1
+*VT100.font3:  -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1
+*VT100.font4:  -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1
+*VT100.font5:  -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1
+*VT100.font6:  -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1
+
+! Here is an alternate set of fonts with better support for bold:
+!*VT100.font2: -efont-biwidth-medium-r-normal--10-100-75-75-p-50-iso10646-1
+!*VT100.font:  -efont-biwidth-medium-r-normal--10-100-75-75-p-50-iso10646-1
+!*VT100.font3: -efont-biwidth-medium-r-normal--12-120-75-75-p-60-iso10646-1
+!*VT100.font4: -efont-biwidth-medium-r-normal--14-140-75-75-p-70-iso10646-1
+!*VT100.font5: -efont-biwidth-medium-r-normal--16-160-75-75-p-80-iso10646-1
+!*VT100.font6: -efont-biwidth-medium-r-normal--24-240-75-75-p-120-iso10646-1
diff --git a/VTPrsTbl.c b/VTPrsTbl.c
new file mode 100644 (file)
index 0000000..ea7f812
--- /dev/null
@@ -0,0 +1,8199 @@
+/* $XTermId: VTPrsTbl.c,v 1.59 2010/08/24 21:26:42 tom Exp $ */
+
+/*
+ *
+ * Copyright 1999-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <VTparse.h>
+
+#if !OPT_BLINK_CURS
+#undef  CASE_CSI_SPACE_STATE
+#define CASE_CSI_SPACE_STATE CASE_CSI_IGNORE
+#endif
+
+#if !OPT_DEC_LOCATOR
+#undef  CASE_CSI_TICK_STATE
+#define CASE_CSI_TICK_STATE CASE_CSI_IGNORE
+#endif
+
+#if !OPT_WIDE_CHARS
+#undef  CASE_ESC_PERCENT
+#define CASE_ESC_PERCENT CASE_ESC_IGNORE
+#endif
+
+#if !OPT_MOD_FKEYS
+#undef  CASE_SET_MOD_FKEYS
+#define CASE_SET_MOD_FKEYS CASE_GROUND_STATE
+#undef  CASE_SET_MOD_FKEYS0
+#define CASE_SET_MOD_FKEYS0 CASE_GROUND_STATE
+#endif
+
+/*
+ * Stupid Apollo C preprocessor can't handle long lines.  So... To keep
+ * it happy, we put each onto a separate line....  Sigh...
+ */
+
+Const PARSE_T ansi_table[] =
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     $               %               &               '       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     (               )               *               +       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     ,               -               .               /       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     0               1               2               3       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     4               5               6               7       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     8               9               :               ;       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     <               =               >               ?       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     @               A               B               C       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     D               E               F               G       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     H               I               J               K       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     L               M               N               O       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     P               Q               R               S       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     T               U               V               W       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     X               Y               Z               [       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     \               ]               ^               _       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     `               a               b               c       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     d               e               f               g       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     h               i               j               k       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     l               m               n               o       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     p               q               r               s       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     t               u               v               w       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     x               y               z               {       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     |               }               ~               DEL     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      currency        yen             brokenbar       section         */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      notsign         hyphen          registered      macron          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      eth             ntilde          ograve          oacute          */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+};
+
+Const PARSE_T csi_table[] =            /* CSI */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_SPACE_STATE,
+CASE_CSI_EX_STATE,
+CASE_CSI_QUOTE_STATE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_TICK_STATE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     4               5               6               7       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     8               9               :               ;       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_DEC3_STATE,
+CASE_DEC2_STATE,
+CASE_DEC_STATE,
+/*     @               A               B               C       */
+CASE_ICH,
+CASE_CUU,
+CASE_CUD,
+CASE_CUF,
+/*     D               E               F               G       */
+CASE_CUB,
+CASE_CNL,
+CASE_CPL,
+CASE_HPA,
+/*     H               I               J               K       */
+CASE_CUP,
+CASE_CHT,
+CASE_ED,
+CASE_EL,
+/*     L               M               N               O       */
+CASE_IL,
+CASE_DL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_DCH,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SU,
+/*     T               U               V               W       */
+CASE_TRACK_MOUSE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_ECH,
+CASE_GROUND_STATE,
+CASE_CBT,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_HPA,
+CASE_GROUND_STATE,
+CASE_REP,
+CASE_DA1,
+/*     d               e               f               g       */
+CASE_VPA,
+CASE_GROUND_STATE,
+CASE_CUP,
+CASE_TBC,
+/*     h               i               j               k       */
+CASE_SET,
+CASE_MC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_RST,
+CASE_SGR,
+CASE_CPR,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_DECLL,
+CASE_DECSTBM,
+CASE_DECSC,
+/*     t               u               v               w       */
+CASE_XTERM_WINOPS,
+CASE_DECRC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_DECREQTPARM,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_SPACE_STATE,
+CASE_CSI_EX_STATE,
+CASE_CSI_QUOTE_STATE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_TICK_STATE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_DEC3_STATE,
+CASE_DEC2_STATE,
+CASE_DEC_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_ICH,
+CASE_CUU,
+CASE_CUD,
+CASE_CUF,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_CUB,
+CASE_CNL,
+CASE_CPL,
+CASE_HPA,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_CUP,
+CASE_CHT,
+CASE_ED,
+CASE_EL,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IL,
+CASE_DL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_DCH,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SU,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_TRACK_MOUSE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_ECH,
+CASE_GROUND_STATE,
+CASE_CBT,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_HPA,
+CASE_GROUND_STATE,
+CASE_REP,
+CASE_DA1,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_VPA,
+CASE_GROUND_STATE,
+CASE_CUP,
+CASE_TBC,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_SET,
+CASE_MC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_RST,
+CASE_SGR,
+CASE_CPR,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_DECLL,
+CASE_DECSTBM,
+CASE_DECSC,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_XTERM_WINOPS,
+CASE_DECRC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_DECREQTPARM,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T csi2_table[] =           /* CSI */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_SPACE_STATE,
+CASE_CSI_EX_STATE,
+CASE_CSI_QUOTE_STATE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_DOLLAR_STATE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_TICK_STATE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_STAR_STATE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     4               5               6               7       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     8               9               :               ;       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_ICH,
+CASE_CUU,
+CASE_CUD,
+CASE_CUF,
+/*     D               E               F               G       */
+CASE_CUB,
+CASE_CNL,
+CASE_CPL,
+CASE_HPA,
+/*     H               I               J               K       */
+CASE_CUP,
+CASE_CHT,
+CASE_ED,
+CASE_EL,
+/*     L               M               N               O       */
+CASE_IL,
+CASE_DL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_DCH,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SU,
+/*     T               U               V               W       */
+CASE_TRACK_MOUSE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_ECH,
+CASE_GROUND_STATE,
+CASE_CBT,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_HPA,
+CASE_GROUND_STATE,
+CASE_REP,
+CASE_DA1,
+/*     d               e               f               g       */
+CASE_VPA,
+CASE_GROUND_STATE,
+CASE_CUP,
+CASE_TBC,
+/*     h               i               j               k       */
+CASE_SET,
+CASE_MC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_RST,
+CASE_SGR,
+CASE_CPR,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_DECLL,
+CASE_DECSTBM,
+CASE_DECSC,
+/*     t               u               v               w       */
+CASE_XTERM_WINOPS,
+CASE_DECRC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_DECREQTPARM,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_SPACE_STATE,
+CASE_CSI_EX_STATE,
+CASE_CSI_QUOTE_STATE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_DOLLAR_STATE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_TICK_STATE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_STAR_STATE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_ICH,
+CASE_CUU,
+CASE_CUD,
+CASE_CUF,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_CUB,
+CASE_CNL,
+CASE_CPL,
+CASE_HPA,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_CUP,
+CASE_CHT,
+CASE_ED,
+CASE_EL,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IL,
+CASE_DL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_DCH,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SU,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_TRACK_MOUSE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_ECH,
+CASE_GROUND_STATE,
+CASE_CBT,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_HPA,
+CASE_GROUND_STATE,
+CASE_REP,
+CASE_DA1,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_VPA,
+CASE_GROUND_STATE,
+CASE_CUP,
+CASE_TBC,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_SET,
+CASE_MC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_RST,
+CASE_SGR,
+CASE_CPR,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_DECLL,
+CASE_DECSTBM,
+CASE_DECSC,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_XTERM_WINOPS,
+CASE_DECRC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_DECREQTPARM,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T csi_ex_table[] =         /* CSI ! */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     4               5               6               7       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     8               9               :               ;       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_DECSTR,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_DECSTR,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T csi_quo_table[] =                /* CSI ... " */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     4               5               6               7       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     8               9               :               ;       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_DECSCL,
+CASE_DECSCA,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_DECSCL,
+CASE_DECSCA,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+#if OPT_BLINK_CURS
+Const PARSE_T csi_sp_table[] =         /* CSI ... SP */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     4               5               6               7       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     8               9               :               ;       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_DECSCUSR,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_DECSWBV,
+CASE_DECSMBV,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_DECSCUSR,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_DECSWBV,
+CASE_DECSMBV,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+#endif
+
+#if OPT_DEC_LOCATOR
+Const PARSE_T csi_tick_table[] =       /* CSI ... ' */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     4               5               6               7       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     8               9               :               ;       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECEFR,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECELR,
+CASE_DECSLE,
+/*     |               }               ~               DEL     */
+CASE_DECRQLP,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*     nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     degree          plusminus       twosuperior     threesuperior   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     acute           mu              paragraph       periodcentered  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     cedilla         onesuperior     masculine       guillemotright  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECEFR,
+/*     oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECELR,
+CASE_DECSLE,
+/*     udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_DECRQLP,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+#endif /* OPT_DEC_LOCATOR */
+
+#if OPT_DEC_RECTOPS
+Const PARSE_T csi_dollar_table[] =     /* CSI ... $ */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     4               5               6               7       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     8               9               :               ;       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_RQM,
+CASE_GROUND_STATE,
+CASE_DECCARA,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_DECRARA,
+CASE_GROUND_STATE,
+CASE_DECCRA,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_DECFRA,
+CASE_GROUND_STATE,
+CASE_DECERA,
+CASE_DECSERA,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*     nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     degree          plusminus       twosuperior     threesuperior   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     acute           mu              paragraph       periodcentered  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     cedilla         onesuperior     masculine       guillemotright  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     eth             ntilde          ograve          oacute          */
+CASE_RQM,
+CASE_GROUND_STATE,
+CASE_DECCARA,
+CASE_GROUND_STATE,
+/*     ocircumflex     otilde          odiaeresis      division        */
+CASE_DECRARA,
+CASE_GROUND_STATE,
+CASE_DECCRA,
+CASE_GROUND_STATE,
+/*     oslash          ugrave          uacute          ucircumflex     */
+CASE_DECFRA,
+CASE_GROUND_STATE,
+CASE_DECERA,
+CASE_DECSERA,
+/*     udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+};
+
+Const PARSE_T csi_star_table[] =       /* CSI ... * */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     4               5               6               7       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     8               9               :               ;       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_DECSACE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*     nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     degree          plusminus       twosuperior     threesuperior   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     acute           mu              paragraph       periodcentered  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     cedilla         onesuperior     masculine       guillemotright  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     oslash          ugrave          uacute          ucircumflex     */
+CASE_DECSACE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+};
+#endif /* OPT_DEC_RECTOPS */
+
+Const PARSE_T dec_table[] =            /* CSI ? */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_DEC_DOLLAR_STATE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     4               5               6               7       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     8               9               :               ;       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECSED,
+CASE_DECSEL,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_DECSET,
+CASE_DEC_MC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_DECRST,
+CASE_GROUND_STATE,
+CASE_DSR,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_XTERM_RESTORE,
+CASE_XTERM_SAVE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_DEC_DOLLAR_STATE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECSED,
+CASE_DECSEL,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_DECSET,
+CASE_DEC_MC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_DECRST,
+CASE_GROUND_STATE,
+CASE_DSR,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_XTERM_RESTORE,
+CASE_XTERM_SAVE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+#if OPT_DEC_RECTOPS
+Const PARSE_T csi_dec_dollar_table[] = /* CSI ?... $ */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     4               5               6               7       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     8               9               :               ;       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_DECRQM,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*     nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     degree          plusminus       twosuperior     threesuperior   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     acute           mu              paragraph       periodcentered  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     cedilla         onesuperior     masculine       guillemotright  */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     eth             ntilde          ograve          oacute          */
+CASE_DECRQM,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+};
+#endif /* OPT_DEC_RECTOPS */
+
+Const PARSE_T dec2_table[] =           /* CSI > */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     4               5               6               7       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     8               9               :               ;       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_RM_TITLE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DA2,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_SET_MOD_FKEYS,
+CASE_SET_MOD_FKEYS0,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_HIDE_POINTER,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_SM_TITLE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_RM_TITLE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DA2,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_SET_MOD_FKEYS,
+CASE_SET_MOD_FKEYS0,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_HIDE_POINTER,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_SM_TITLE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T dec3_table[] =           /* CSI = */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     $               %               &               '       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     (               )               *               +       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     ,               -               .               /       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     0               1               2               3       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     4               5               6               7       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*     8               9               :               ;       */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*     <               =               >               ?       */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECRPTUI,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_ESC_DIGIT,
+CASE_ESC_DIGIT,
+CASE_CSI_IGNORE,
+CASE_ESC_SEMI,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+CASE_CSI_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECRPTUI,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T cigtable[] =             /* CASE_CSI_IGNORE */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     $               %               &               '       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     (               )               *               +       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     ,               -               .               /       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     0               1               2               3       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     4               5               6               7       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     8               9               :               ;       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     <               =               >               ?       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T eigtable[] =             /* CASE_ESC_IGNORE */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     $               %               &               '       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     (               )               *               +       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     ,               -               .               /       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     8               9               :               ;       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T esc_table[] =            /* ESC */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_ESC_SP_STATE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_SCR_STATE,
+/*     $               %               &               '       */
+CASE_ESC_IGNORE,
+CASE_ESC_PERCENT,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     (               )               *               +       */
+CASE_SCS0_STATE,
+CASE_SCS1_STATE,
+CASE_SCS2_STATE,
+CASE_SCS3_STATE,
+/*     ,               -               .               /       */
+CASE_ESC_IGNORE,
+CASE_SCS1A_STATE,
+CASE_SCS2A_STATE,
+CASE_SCS3A_STATE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECSC,
+/*     8               9               :               ;       */
+CASE_DECRC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_DECKPAM,
+CASE_DECKPNM,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_IND,
+CASE_NEL,
+CASE_HP_BUGGY_LL,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*     P               Q               R               S       */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_XTERM_TITLE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*     X               Y               Z               [       */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*     \               ]               ^               _       */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_RIS,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_HP_MEM_LOCK,
+CASE_HP_MEM_UNLOCK,
+CASE_LS2,
+CASE_LS3,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_LS3R,
+CASE_LS2R,
+CASE_LS1R,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_ESC_SP_STATE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_SCR_STATE,
+/*      currency        yen             brokenbar       section         */
+CASE_ESC_IGNORE,
+CASE_ESC_PERCENT,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_SCS0_STATE,
+CASE_SCS1_STATE,
+CASE_SCS2_STATE,
+CASE_SCS3_STATE,
+/*      notsign         hyphen          registered      macron          */
+CASE_ESC_IGNORE,
+CASE_SCS1A_STATE,
+CASE_SCS2A_STATE,
+CASE_SCS3A_STATE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECSC,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_DECRC,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_GROUND_STATE,
+CASE_DECKPAM,
+CASE_DECKPNM,
+CASE_GROUND_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IND,
+CASE_NEL,
+CASE_HP_BUGGY_LL,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_XTERM_TITLE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_RIS,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_HP_MEM_LOCK,
+CASE_HP_MEM_UNLOCK,
+CASE_LS2,
+CASE_LS3,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_LS3R,
+CASE_LS2R,
+CASE_LS1R,
+CASE_IGNORE,
+};
+
+Const PARSE_T esc_sp_table[] =         /* ESC SP */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     $               %               &               '       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     (               )               *               +       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     ,               -               .               /       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     8               9               :               ;       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_S7C1T,
+CASE_S8C1T,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_ANSI_LEVEL_1,
+CASE_ANSI_LEVEL_2,
+CASE_ANSI_LEVEL_3,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_S7C1T,
+CASE_S8C1T,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_ANSI_LEVEL_1,
+CASE_ANSI_LEVEL_2,
+CASE_ANSI_LEVEL_3,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T scrtable[] =             /* ESC # */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     $               %               &               '       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     (               )               *               +       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     ,               -               .               /       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECDHL,
+/*     4               5               6               7       */
+CASE_DECDHL,
+CASE_DECSWL,
+CASE_DECDWL,
+CASE_GROUND_STATE,
+/*     8               9               :               ;       */
+CASE_DECALN,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECDHL,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_DECDHL,
+CASE_DECSWL,
+CASE_DECDWL,
+CASE_GROUND_STATE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_DECALN,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T scstable[] =             /* ESC ( etc. */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     $               %               &               '       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     (               )               *               +       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     ,               -               .               /       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     0               1               2               3       */
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+/*     8               9               :               ;       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GSETS,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GROUND_STATE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GSETS,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GSETS,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GSETS,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+Const PARSE_T scs96table[] =           /* ESC - etc. */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     $               %               &               '       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     (               )               *               +       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     ,               -               .               /       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     8               9               :               ;       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+
+/*
+ * This table is treated specially.  The CASE_IGNORE entries correspond to the
+ * characters that can be accumulated for the string function (e.g., OSC).
+ */
+Const PARSE_T sos_table[] =            /* OSC, DCS, etc. */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     NP              CR              SO              SI      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     $               %               &               '       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     (               )               *               +       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     ,               -               .               /       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     0               1               2               3       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     4               5               6               7       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     8               9               :               ;       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     <               =               >               ?       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     @               A               B               C       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     D               E               F               G       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     H               I               J               K       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     L               M               N               O       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     P               Q               R               S       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     T               U               V               W       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     X               Y               Z               [       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     \               ]               ^               _       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     `               a               b               c       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     d               e               f               g       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     h               i               j               k       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     l               m               n               o       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     p               q               r               s       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     t               u               v               w       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     x               y               z               {       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     |               }               ~               DEL     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+#if OPT_WIDE_CHARS
+Const PARSE_T esc_pct_table[] =                /* ESC % */
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_SO,
+CASE_SI,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     $               %               &               '       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     (               )               *               +       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     ,               -               .               /       */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     8               9               :               ;       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_UTF8,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_UTF8,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IND,
+CASE_NEL,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_HTS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_GROUND_STATE,
+CASE_RI,
+CASE_SS2,
+CASE_SS3,
+/*      0x90            0x91            0x92            0x93    */
+CASE_DCS,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_SPA,
+CASE_EPA,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_SOS,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_ST,
+CASE_OSC,
+CASE_PM,
+CASE_APC,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_UTF8,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_UTF8,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+};
+#endif /* OPT_WIDE_CHARS */
+
+#if OPT_VT52_MODE
+Const PARSE_T vt52_table[] =
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     $               %               &               '       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     (               )               *               +       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     ,               -               .               /       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     0               1               2               3       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     4               5               6               7       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     8               9               :               ;       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     <               =               >               ?       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     @               A               B               C       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     D               E               F               G       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     H               I               J               K       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     L               M               N               O       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     P               Q               R               S       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     T               U               V               W       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     X               Y               Z               [       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     \               ]               ^               _       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     `               a               b               c       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     d               e               f               g       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     h               i               j               k       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     l               m               n               o       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     p               q               r               s       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     t               u               v               w       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     x               y               z               {       */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+/*     |               }               ~               DEL     */
+CASE_PRINT,
+CASE_PRINT,
+CASE_PRINT,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const PARSE_T vt52_esc_table[] =
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+/*     $               %               &               '       */
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+/*     (               )               *               +       */
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+/*     ,               -               .               /       */
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+CASE_VT52_IGNORE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     8               9               :               ;       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_VT52_FINISH,
+CASE_DECKPAM,
+CASE_DECKPNM,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_CUU,
+CASE_CUD,
+CASE_CUF,
+/*     D               E               F               G       */
+CASE_CUB,
+CASE_GROUND_STATE,
+CASE_SO,
+CASE_SI,
+/*     H               I               J               K       */
+CASE_CUP,
+CASE_RI,
+CASE_ED,
+CASE_EL,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_VT52_CUP,
+CASE_DECID,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+
+Const PARSE_T vt52_ignore_table[] =
+{
+/*     NUL             SOH             STX             ETX     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     EOT             ENQ             ACK             BEL     */
+CASE_IGNORE,
+CASE_ENQ,
+CASE_IGNORE,
+CASE_BELL,
+/*     BS              HT              NL              VT      */
+CASE_BS,
+CASE_TAB,
+CASE_VMOT,
+CASE_VMOT,
+/*     NP              CR              SO              SI      */
+CASE_VMOT,
+CASE_CR,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DLE             DC1             DC2             DC3     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     DC4             NAK             SYN             ETB     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     CAN             EM              SUB             ESC     */
+CASE_GROUND_STATE,
+CASE_IGNORE,
+CASE_GROUND_STATE,
+CASE_ESC,
+/*     FS              GS              RS              US      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     SP              !               "               #       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     $               %               &               '       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     (               )               *               +       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     ,               -               .               /       */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*     0               1               2               3       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     4               5               6               7       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     8               9               :               ;       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     <               =               >               ?       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     @               A               B               C       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     D               E               F               G       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     H               I               J               K       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     L               M               N               O       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     P               Q               R               S       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     T               U               V               W       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     X               Y               Z               [       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     \               ]               ^               _       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     `               a               b               c       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     d               e               f               g       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     h               i               j               k       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     l               m               n               o       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     p               q               r               s       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     t               u               v               w       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     x               y               z               {       */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/*     |               }               ~               DEL     */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_IGNORE,
+/*      0x80            0x81            0x82            0x83    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x84            0x85            0x86            0x87    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x88            0x89            0x8a            0x8b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x8c            0x8d            0x8e            0x8f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x90            0x91            0x92            0x93    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x94            0x95            0x96            0x97    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x98            0x99            0x9a            0x9b    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      0x9c            0x9d            0x9e            0x9f    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      nobreakspace    exclamdown      cent            sterling        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      currency        yen             brokenbar       section         */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      diaeresis       copyright       ordfeminine     guillemotleft   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      notsign         hyphen          registered      macron          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      degree          plusminus       twosuperior     threesuperior   */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      acute           mu              paragraph       periodcentered  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      cedilla         onesuperior     masculine       guillemotright  */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      onequarter      onehalf         threequarters   questiondown    */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Agrave          Aacute          Acircumflex     Atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Adiaeresis      Aring           AE              Ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Egrave          Eacute          Ecircumflex     Ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Igrave          Iacute          Icircumflex     Idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Eth             Ntilde          Ograve          Oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ocircumflex     Otilde          Odiaeresis      multiply        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Ooblique        Ugrave          Uacute          Ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      Udiaeresis      Yacute          Thorn           ssharp          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      agrave          aacute          acircumflex     atilde          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      adiaeresis      aring           ae              ccedilla        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      egrave          eacute          ecircumflex     ediaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      igrave          iacute          icircumflex     idiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      eth             ntilde          ograve          oacute          */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      ocircumflex     otilde          odiaeresis      division        */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      oslash          ugrave          uacute          ucircumflex     */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/*      udiaeresis      yacute          thorn           ydiaeresis      */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+};
+#endif /* OPT_VT52_MODE */
diff --git a/VTparse.def b/VTparse.def
new file mode 100644 (file)
index 0000000..da9b5c7
--- /dev/null
@@ -0,0 +1,187 @@
+# $XTermId: VTparse.def,v 1.40 2010/08/24 21:26:42 tom Exp $
+#
+# vile:confmode rs=lf
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1996-2009,2010 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# List of symbols that need to be defined for VTparse.h.  If you need to
+# change any of the CASE_ macros, make the change here and rerun the command
+# shown in VTparse.h.
+#
+
+CASE_GROUND_STATE
+CASE_IGNORE
+CASE_BELL
+CASE_BS
+CASE_CR
+CASE_ESC
+CASE_VMOT
+CASE_TAB
+CASE_SI
+CASE_SO
+CASE_SCR_STATE
+CASE_SCS0_STATE
+CASE_SCS1_STATE
+CASE_SCS2_STATE
+CASE_SCS3_STATE
+CASE_ESC_IGNORE
+CASE_ESC_DIGIT
+CASE_ESC_SEMI
+CASE_DEC_STATE
+CASE_ICH
+CASE_CUU
+CASE_CUD
+CASE_CUF
+CASE_CUB
+CASE_CUP
+CASE_ED
+CASE_EL
+CASE_IL
+CASE_DL
+CASE_DCH
+CASE_DA1
+CASE_TRACK_MOUSE
+CASE_TBC
+CASE_SET
+CASE_RST
+CASE_SGR
+CASE_CPR
+CASE_DECSTBM
+CASE_DECREQTPARM
+CASE_DECSET
+CASE_DECRST
+CASE_DECALN
+CASE_GSETS
+CASE_DECSC
+CASE_DECRC
+CASE_DECKPAM
+CASE_DECKPNM
+CASE_IND
+CASE_NEL
+CASE_HTS
+CASE_RI
+CASE_SS2
+CASE_SS3
+CASE_CSI_STATE
+CASE_OSC
+CASE_RIS
+CASE_LS2
+CASE_LS3
+CASE_LS3R
+CASE_LS2R
+CASE_LS1R
+CASE_PRINT
+CASE_XTERM_SAVE
+CASE_XTERM_RESTORE
+CASE_XTERM_TITLE
+CASE_DECID
+CASE_HP_MEM_LOCK
+CASE_HP_MEM_UNLOCK
+CASE_HP_BUGGY_LL
+CASE_HPA
+CASE_VPA
+CASE_XTERM_WINOPS
+CASE_ECH
+CASE_CHT
+CASE_CPL
+CASE_CNL
+CASE_CBT
+CASE_SU
+CASE_SD
+CASE_S7C1T
+CASE_S8C1T
+CASE_ESC_SP_STATE
+CASE_ENQ
+CASE_DECSCL
+CASE_DECSCA
+CASE_DECSED
+CASE_DECSEL
+CASE_DCS
+CASE_PM
+CASE_SOS
+CASE_ST
+CASE_APC
+CASE_EPA
+CASE_SPA
+CASE_CSI_QUOTE_STATE
+CASE_DSR
+CASE_ANSI_LEVEL_1
+CASE_ANSI_LEVEL_2
+CASE_ANSI_LEVEL_3
+CASE_MC
+CASE_DEC2_STATE
+CASE_DA2
+CASE_DEC3_STATE
+CASE_DECRPTUI
+CASE_VT52_CUP
+CASE_REP
+CASE_CSI_EX_STATE
+CASE_DECSTR
+CASE_DECDHL
+CASE_DECSWL
+CASE_DECDWL
+CASE_DEC_MC
+CASE_ESC_PERCENT
+CASE_UTF8
+CASE_CSI_TICK_STATE
+CASE_DECELR
+CASE_DECRQLP
+CASE_DECEFR
+CASE_DECSLE
+CASE_CSI_IGNORE
+CASE_VT52_IGNORE
+CASE_VT52_FINISH
+CASE_CSI_DOLLAR_STATE
+CASE_DECCRA
+CASE_DECERA
+CASE_DECFRA
+CASE_DECSERA
+CASE_DECSACE
+CASE_DECCARA
+CASE_DECRARA
+CASE_CSI_STAR_STATE
+CASE_SET_MOD_FKEYS
+CASE_SET_MOD_FKEYS0
+CASE_HIDE_POINTER
+CASE_SCS1A_STATE
+CASE_SCS2A_STATE
+CASE_SCS3A_STATE
+CASE_CSI_SPACE_STATE
+CASE_DECSCUSR
+CASE_SM_TITLE
+CASE_RM_TITLE
+CASE_DECSMBV
+CASE_DECSWBV
+CASE_DECLL
+CASE_DECRQM
+CASE_RQM
+CASE_CSI_DEC_DOLLAR_STATE
diff --git a/VTparse.h b/VTparse.h
new file mode 100644 (file)
index 0000000..cafbbe3
--- /dev/null
+++ b/VTparse.h
@@ -0,0 +1,270 @@
+/* $XTermId: VTparse.h,v 1.53 2010/08/24 21:27:13 tom Exp $ */
+
+/*
+ * Copyright 2002-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef included_VTparse_h
+#define included_VTparse_h 1
+
+#include <xterm.h>
+
+#ifndef Const
+# if defined(__STDC__) && !defined(__cplusplus)
+#  define Const const
+# else
+#  define Const /**/
+# endif
+#endif
+
+/*
+ * PARSE_T has to be large enough to handle the number of cases enumerated here.
+ */
+typedef unsigned char PARSE_T;
+
+extern Const PARSE_T ansi_table[];
+extern Const PARSE_T cigtable[];
+extern Const PARSE_T csi2_table[];
+extern Const PARSE_T csi_ex_table[];
+extern Const PARSE_T csi_quo_table[];
+extern Const PARSE_T csi_sp_table[];
+extern Const PARSE_T csi_table[];
+extern Const PARSE_T dec2_table[];
+extern Const PARSE_T dec3_table[];
+extern Const PARSE_T dec_table[];
+extern Const PARSE_T eigtable[];
+extern Const PARSE_T esc_sp_table[];
+extern Const PARSE_T esc_table[];
+extern Const PARSE_T scrtable[];
+extern Const PARSE_T scs96table[];
+extern Const PARSE_T scstable[];
+extern Const PARSE_T sos_table[];
+extern Const PARSE_T csi_dec_dollar_table[];
+
+#if OPT_DEC_LOCATOR
+extern Const PARSE_T csi_tick_table[];
+#endif /* OPT_DEC_LOCATOR */
+
+#if OPT_DEC_RECTOPS
+extern Const PARSE_T csi_dollar_table[];
+extern Const PARSE_T csi_star_table[];
+#endif /* OPT_DEC_LOCATOR */
+
+#if OPT_VT52_MODE
+extern Const PARSE_T vt52_table[];
+extern Const PARSE_T vt52_esc_table[];
+extern Const PARSE_T vt52_ignore_table[];
+#endif
+
+#if OPT_WIDE_CHARS
+extern Const PARSE_T esc_pct_table[];
+#endif
+
+/*
+ * The following list of definitions is generated from VTparse.def using the
+ * following command line:
+ *
+ *     grep '^CASE_' VTparse.def | awk '{printf "#define %s %d\n", $1, n++}'
+ *
+ * If you need to change something, change VTparse.def and regenerate the
+ * definitions.  This would have been automatic, but since this doesn't change
+ * very often, it isn't worth the makefile hassle.
+ */
+
+#define CASE_GROUND_STATE 0
+#define CASE_IGNORE 1
+#define CASE_BELL 2
+#define CASE_BS 3
+#define CASE_CR 4
+#define CASE_ESC 5
+#define CASE_VMOT 6
+#define CASE_TAB 7
+#define CASE_SI 8
+#define CASE_SO 9
+#define CASE_SCR_STATE 10
+#define CASE_SCS0_STATE 11
+#define CASE_SCS1_STATE 12
+#define CASE_SCS2_STATE 13
+#define CASE_SCS3_STATE 14
+#define CASE_ESC_IGNORE 15
+#define CASE_ESC_DIGIT 16
+#define CASE_ESC_SEMI 17
+#define CASE_DEC_STATE 18
+#define CASE_ICH 19
+#define CASE_CUU 20
+#define CASE_CUD 21
+#define CASE_CUF 22
+#define CASE_CUB 23
+#define CASE_CUP 24
+#define CASE_ED 25
+#define CASE_EL 26
+#define CASE_IL 27
+#define CASE_DL 28
+#define CASE_DCH 29
+#define CASE_DA1 30
+#define CASE_TRACK_MOUSE 31
+#define CASE_TBC 32
+#define CASE_SET 33
+#define CASE_RST 34
+#define CASE_SGR 35
+#define CASE_CPR 36
+#define CASE_DECSTBM 37
+#define CASE_DECREQTPARM 38
+#define CASE_DECSET 39
+#define CASE_DECRST 40
+#define CASE_DECALN 41
+#define CASE_GSETS 42
+#define CASE_DECSC 43
+#define CASE_DECRC 44
+#define CASE_DECKPAM 45
+#define CASE_DECKPNM 46
+#define CASE_IND 47
+#define CASE_NEL 48
+#define CASE_HTS 49
+#define CASE_RI 50
+#define CASE_SS2 51
+#define CASE_SS3 52
+#define CASE_CSI_STATE 53
+#define CASE_OSC 54
+#define CASE_RIS 55
+#define CASE_LS2 56
+#define CASE_LS3 57
+#define CASE_LS3R 58
+#define CASE_LS2R 59
+#define CASE_LS1R 60
+#define CASE_PRINT 61
+#define CASE_XTERM_SAVE 62
+#define CASE_XTERM_RESTORE 63
+#define CASE_XTERM_TITLE 64
+#define CASE_DECID 65
+#define CASE_HP_MEM_LOCK 66
+#define CASE_HP_MEM_UNLOCK 67
+#define CASE_HP_BUGGY_LL 68
+#define CASE_HPA 69
+#define CASE_VPA 70
+#define CASE_XTERM_WINOPS 71
+#define CASE_ECH 72
+#define CASE_CHT 73
+#define CASE_CPL 74
+#define CASE_CNL 75
+#define CASE_CBT 76
+#define CASE_SU 77
+#define CASE_SD 78
+#define CASE_S7C1T 79
+#define CASE_S8C1T 80
+#define CASE_ESC_SP_STATE 81
+#define CASE_ENQ 82
+#define CASE_DECSCL 83
+#define CASE_DECSCA 84
+#define CASE_DECSED 85
+#define CASE_DECSEL 86
+#define CASE_DCS 87
+#define CASE_PM 88
+#define CASE_SOS 89
+#define CASE_ST 90
+#define CASE_APC 91
+#define CASE_EPA 92
+#define CASE_SPA 93
+#define CASE_CSI_QUOTE_STATE 94
+#define CASE_DSR 95
+#define CASE_ANSI_LEVEL_1 96
+#define CASE_ANSI_LEVEL_2 97
+#define CASE_ANSI_LEVEL_3 98
+#define CASE_MC 99
+#define CASE_DEC2_STATE 100
+#define CASE_DA2 101
+#define CASE_DEC3_STATE 102
+#define CASE_DECRPTUI 103
+#define CASE_VT52_CUP 104
+#define CASE_REP 105
+#define CASE_CSI_EX_STATE 106
+#define CASE_DECSTR 107
+#define CASE_DECDHL 108
+#define CASE_DECSWL 109
+#define CASE_DECDWL 110
+#define CASE_DEC_MC 111
+#define CASE_ESC_PERCENT 112
+#define CASE_UTF8 113
+#define CASE_CSI_TICK_STATE 114
+#define CASE_DECELR 115
+#define CASE_DECRQLP 116
+#define CASE_DECEFR 117
+#define CASE_DECSLE 118
+#define CASE_CSI_IGNORE 119
+#define CASE_VT52_IGNORE 120
+#define CASE_VT52_FINISH 121
+#define CASE_CSI_DOLLAR_STATE 122
+#define CASE_DECCRA 123
+#define CASE_DECERA 124
+#define CASE_DECFRA 125
+#define CASE_DECSERA 126
+#define CASE_DECSACE 127
+#define CASE_DECCARA 128
+#define CASE_DECRARA 129
+#define CASE_CSI_STAR_STATE 130
+#define CASE_SET_MOD_FKEYS 131
+#define CASE_SET_MOD_FKEYS0 132
+#define CASE_HIDE_POINTER 133
+#define CASE_SCS1A_STATE 134
+#define CASE_SCS2A_STATE 135
+#define CASE_SCS3A_STATE 136
+#define CASE_CSI_SPACE_STATE 137
+#define CASE_DECSCUSR 138
+#define CASE_SM_TITLE 139
+#define CASE_RM_TITLE 140
+#define CASE_DECSMBV 141
+#define CASE_DECSWBV 142
+#define CASE_DECLL 143
+#define CASE_DECRQM 144
+#define CASE_RQM 145
+#define CASE_CSI_DEC_DOLLAR_STATE 146
+
+#endif /* included_VTparse_h */
diff --git a/XTerm-col.ad b/XTerm-col.ad
new file mode 100644 (file)
index 0000000..c157e9f
--- /dev/null
@@ -0,0 +1,163 @@
+! $XTermId: XTerm-col.ad,v 1.22 2009/08/15 15:56:29 tom Exp $
+! -----------------------------------------------------------------------------
+! this file is part of xterm
+!
+! Copyright 2002-2006,2009 by Thomas E. Dickey
+! 
+!                         All Rights Reserved
+! 
+! Permission is hereby granted, free of charge, to any person obtaining a
+! copy of this software and associated documentation files (the
+! "Software"), to deal in the Software without restriction, including
+! without limitation the rights to use, copy, modify, merge, publish,
+! distribute, sublicense, and/or sell copies of the Software, and to
+! permit persons to whom the Software is furnished to do so, subject to
+! the following conditions:
+! 
+! The above copyright notice and this permission notice shall be included
+! in all copies or substantial portions of the Software.
+! 
+! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+! IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+! CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+! TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+! SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+! 
+! Except as contained in this notice, the name(s) of the above copyright
+! holders shall not be used in advertising or otherwise to promote the
+! sale, use or other dealings in this Software without prior written
+! authorization.
+! -----------------------------------------------------------------------------
+
+#include "XTerm"
+
+*VT100*colorMode: on
+*VT100*boldColors: on
+*VT100*dynamicColors: on
+
+! Uncomment this for "white" text on a dark background.
+!*VT100*foreground: gray90
+!*VT100*background: black
+
+! - OR -
+! Uncomment this for black text on a "white" background.
+!*VT100*foreground: black
+!*VT100*background: gray90
+
+! - OR -
+! leave the foreground/background colors alone (at the mercy of your desktop
+! designer).
+
+! Color the popup/pulldown menu border to match the text widget foreground.
+!*SimpleMenu*borderColor: gray15
+
+! Uncomment this to use color for underline attribute
+!*VT100*colorULMode: on
+*VT100*colorUL: yellow
+
+!*VT100*italicULMode: on
+
+! Uncomment this to disable underlining, e.g., if colorULMode is set.
+!*VT100*underLine: off
+
+! Uncomment this to use color for the bold attribute
+!*VT100*colorBDMode: on
+*VT100*colorBD: white
+
+! Uncomment this to use the bold/underline colors in preference to other colors
+!*VT100*colorAttrMode: on
+
+! These are the 8 ANSI colors and their bright equivalents.  Depending on
+! other resource settings, xterm may use the bright colors when displaying
+! bold text (see the boldColors resource).
+*VT100*color0: black
+*VT100*color1: red3
+*VT100*color2: green3
+*VT100*color3: yellow3
+*VT100*color4: blue2
+*VT100*color5: magenta3
+*VT100*color6: cyan3
+*VT100*color7: gray90
+*VT100*color8: gray50
+*VT100*color9: red
+*VT100*color10: green
+*VT100*color11: yellow
+*VT100*color12: rgb:5c/5c/ff
+*VT100*color13: magenta
+*VT100*color14: cyan
+*VT100*color15: white
+
+! Disclaimer: there are no standard colors used in terminal emulation.
+!
+! The choice for color4 and color12 is a tradeoff between contrast, depending
+! on whether they are used for text or backgrounds.  Note that either color4 or
+! color12 would be used for text, while only color4 would be used for a
+! background.  These are treated specially, since the luminosity of blue is
+! only about half that of red/green, and is typically not accounted for in the
+! RGB scheme.
+!
+! Blue text on a black background should be readable.
+! Blue backgrounds should not be "too" bright.
+!
+! Originally color4/color12 were set to the names blue3/blue
+!*VT100*color4: blue3
+!*VT100*color12: blue
+!
+! They are from rgb.txt respectively:
+!  0   0 205           blue3
+!  0   0 255           blue
+! However, blue3 is not readable on a black background.
+!
+! Another choice was from the Debian settings:
+!*VT100*color4: DodgerBlue1
+!*VT100*color12: SteelBlue1
+!
+! From rgb.txt:
+! 30 144 255           DodgerBlue1
+! 99 184 255           SteelBlue1
+!
+! Some users object to this choice because the background (color4) is brighter
+! than they are accustomed.  Others point out that the different weights for
+! the red/green components make it appear to be not really blue.  Finally, it
+! provides poor contrast against color13 and color14.
+!
+! The current choice uses equal weights for red/green (effectively adding a
+! gray to the result).  It is brighter than the original choice, and provides
+! more contrast between color12 and color13, color14 than SteelBlue1 did.
+! Contrast of color4 against black is slightly improved over the original.
+!
+! Some refinement is certainly possible (you are welcome to try) -TD
+
+
+#if PLANES > 8
+! Color the popup menus and the menubar to match:
+*SimpleMenu*background: AntiqueWhite
+*SimpleMenu*foreground: gray15
+
+! Color the menubar to match:
+*Form.menubar.background: AntiqueWhite
+*Form.menubar*background: AntiqueWhite
+*Form.menubar.foreground: gray15
+*Form.menubar*foreground: gray15
+*Form.background: AntiqueWhite
+*form.background: AntiqueWhite
+
+! The following two sections take advantage of new features in version 7
+! of the Athena widget library.  Comment them out if you have a shallow
+! color depth.
+!*SimpleMenu*backgroundPixmap:   gradient:vertical?dimension=350&start=gray90&end=gray60
+!*SimpleMenu*foreground:         gray15
+
+!*VT100.scrollbar.thumb:         vlines2
+!*VT100.scrollbar.width:         14
+!*VT100.scrollbar.background:    gray60
+!*VT100.scrollbar.foreground:    rgb:a/5/5
+!*VT100.scrollbar.borderWidth:   0
+!*VT100.scrollbar.displayList:\
+!foreground      gray90;\
+!lines           1,-1,-1,-1,-1,1;\
+!foreground      gray60;\
+!lines           -1,0,0,0,0,-1
+#endif
diff --git a/XTerm.ad b/XTerm.ad
new file mode 100644 (file)
index 0000000..dd99d9f
--- /dev/null
+++ b/XTerm.ad
@@ -0,0 +1,252 @@
+! $XTermId: XTerm.ad,v 1.94 2011/01/19 22:05:58 tom Exp $
+! -----------------------------------------------------------------------------
+! this file is part of xterm
+!
+! Copyright 1996-2010,2011 by Thomas E. Dickey
+! 
+!                         All Rights Reserved
+! 
+! Permission is hereby granted, free of charge, to any person obtaining a
+! copy of this software and associated documentation files (the
+! "Software"), to deal in the Software without restriction, including
+! without limitation the rights to use, copy, modify, merge, publish,
+! distribute, sublicense, and/or sell copies of the Software, and to
+! permit persons to whom the Software is furnished to do so, subject to
+! the following conditions:
+! 
+! The above copyright notice and this permission notice shall be included
+! in all copies or substantial portions of the Software.
+! 
+! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+! IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+! CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+! TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+! SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+! 
+! Except as contained in this notice, the name(s) of the above copyright
+! holders shall not be used in advertising or otherwise to promote the
+! sale, use or other dealings in this Software without prior written
+! authorization.
+! -----------------------------------------------------------------------------
+
+*saveLines: 1024
+
+*SimpleMenu*BackingStore: NotUseful
+*SimpleMenu*menuLabel.font: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-*
+*SimpleMenu*menuLabel.vertSpace:       100
+*SimpleMenu*HorizontalMargins: 16
+*SimpleMenu*Sme.height:        16
+
+*SimpleMenu*Cursor: left_ptr
+
+*mainMenu.Label:  Main Options
+*mainMenu*toolbar*Label:  Toolbar
+*mainMenu*fullscreen*Label: Full Screen
+*mainMenu*securekbd*Label:  Secure Keyboard
+*mainMenu*allowsends*Label:  Allow SendEvents
+*mainMenu*redraw*Label:  Redraw Window
+*mainMenu*logging*Label:  Log to File
+*mainMenu*print*Label:  Print Window
+*mainMenu*print-redir*Label:  Redirect to Printer
+*mainMenu*8-bit control*Label: 8-Bit Controls
+*mainMenu*backarrow key*Label: Backarrow Key (BS/DEL)
+*mainMenu*num-lock*Label: Alt/NumLock Modifiers
+*mainMenu*alt-esc*Label: Alt Sends Escape
+*mainMenu*meta-esc*Label: Meta Sends Escape
+*mainMenu*delete-is-del*Label: Delete is DEL
+*mainMenu*oldFunctionKeys*Label: Old Function-Keys
+*mainMenu*sunFunctionKeys*Label: Sun Function-Keys
+*mainMenu*sunKeyboard*Label: VT220 Keyboard
+*mainMenu*hpFunctionKeys*Label: HP Function-Keys
+*mainMenu*scoFunctionKeys*Label: SCO Function-Keys
+*mainMenu*tcapFunctionKeys*Label: Termcap Function-Keys
+*mainMenu*suspend*Label:  Send STOP Signal
+*mainMenu*continue*Label:  Send CONT Signal
+*mainMenu*interrupt*Label:  Send INT Signal
+*mainMenu*hangup*Label:  Send HUP Signal
+*mainMenu*terminate*Label:  Send TERM Signal
+*mainMenu*kill*Label:  Send KILL Signal
+*mainMenu*quit*Label:  Quit
+
+*vtMenu.Label:  VT Options
+*vtMenu*scrollbar*Label:  Enable Scrollbar
+*vtMenu*jumpscroll*Label:  Enable Jump Scroll
+*vtMenu*reversevideo*Label:  Enable Reverse Video
+*vtMenu*autowrap*Label:  Enable Auto Wraparound
+*vtMenu*reversewrap*Label:  Enable Reverse Wraparound
+*vtMenu*autolinefeed*Label:  Enable Auto Linefeed
+*vtMenu*appcursor*Label:  Enable Application Cursor Keys
+*vtMenu*appkeypad*Label:  Enable Application Keypad
+*vtMenu*scrollkey*Label:  Scroll to Bottom on Key Press
+*vtMenu*scrollttyoutput*Label:  Scroll to Bottom on Tty Output
+*vtMenu*allow132*Label: Allow 80/132 Column Switching
+*vtMenu*keepSelection*Label: Keep Selection
+*vtMenu*selectToClipboard*Label: Select to Clipboard
+*vtMenu*cursesemul*Label:  Enable Curses Emulation
+*vtMenu*visualbell*Label:  Enable Visual Bell
+*vtMenu*bellIsUrgent*Label:  Enable Bell Urgency
+*vtMenu*poponbell*Label:  Enable Pop on Bell
+*vtMenu*cursorblink*Label: Enable Blinking Cursor
+*vtMenu*titeInhibit*Label:  Enable Alternate Screen Switching
+*vtMenu*activeicon*Label: Enable Active Icon
+*vtMenu*softreset*Label:  Do Soft Reset
+*vtMenu*hardreset*Label:  Do Full Reset
+*vtMenu*clearsavedlines*Label:  Reset and Clear Saved Lines
+*vtMenu*tekshow*Label:  Show Tek Window
+*vtMenu*tekmode*Label:  Switch to Tek Mode
+*vtMenu*vthide*Label:  Hide VT Window
+*vtMenu*altscreen*Label:  Show Alternate Screen
+
+*fontMenu.Label:  VT Fonts
+*fontMenu*fontdefault*Label:   Default
+*fontMenu*font1*Label: Unreadable
+*VT100.font1:          nil2
+*IconFont:             nil2
+*fontMenu*font2*Label: Tiny
+*VT100.font2:          5x7
+*fontMenu*font3*Label: Small
+*VT100.font3:          6x10
+*fontMenu*font4*Label: Medium
+*VT100.font4:          7x13
+*fontMenu*font5*Label: Large
+*VT100.font5:          9x15
+*fontMenu*font6*Label: Huge
+*VT100.font6:          10x20
+*fontMenu*fontescape*Label:    Escape Sequence
+*fontMenu*fontsel*Label:       Selection
+!fontescape and fontsel overridden by application
+*fontMenu*font-linedrawing*Label: Line-Drawing Characters
+*fontMenu*font-doublesize*Label: Doublesized Characters
+*fontMenu*font-loadable*Label: VT220 Soft Fonts
+*fontMenu*font-packed*Label:   Packed Font
+*fontMenu*render-font*Label:   TrueType Fonts
+*fontMenu*utf8-mode*Label:     UTF-8
+*fontMenu*utf8-title*Label:    UTF-8 Titles
+
+*fontMenu*allow-color-ops*Label:       Allow Color Ops
+*fontMenu*allow-font-ops*Label:        Allow Font Ops
+*fontMenu*allow-tcap-ops*Label:        Allow Termcap Ops
+*fontMenu*allow-title-ops*Label:       Allow Title Ops
+*fontMenu*allow-window-ops*Label:      Allow Window Ops
+
+*VT100.utf8Fonts.font2:        -misc-fixed-medium-r-normal--8-80-75-75-c-50-iso10646-1
+*VT100.utf8Fonts.font: -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1
+*VT100.utf8Fonts.font3:        -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1
+*VT100.utf8Fonts.font4:        -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1
+*VT100.utf8Fonts.font5:        -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1
+*VT100.utf8Fonts.font6:        -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1
+
+*tekMenu.Label:  Tek Options
+*tekMenu*tektextlarge*Label:  Large Characters
+*tekMenu*tektext2*Label:  #2 Size Characters
+*tekMenu*tektext3*Label:  #3 Size Characters
+*tekMenu*tektextsmall*Label:  Small Characters
+*tekMenu*tekpage*Label:  PAGE
+*tekMenu*tekreset*Label:  RESET
+*tekMenu*tekcopy*Label:  COPY
+*tekMenu*vtshow*Label:  Show VT Window
+*tekMenu*vtmode*Label:  Switch to VT Mode
+*tekMenu*tekhide*Label:  Hide Tek Window
+
+*tek4014*fontLarge: 9x15
+*tek4014*font2: 8x13
+*tek4014*font3: 6x13
+*tek4014*fontSmall: 6x10
+
+! If xterm is built with a toolbar, the widget hierarchy looks like this,
+! showing widget name / class names.  The complete menu hierarchy is built
+! at startup because it is needed to make the layout work for the menubar:
+!
+!      xterm/XTerm
+!              form/Form
+!                      menubar/Box
+!                              mainMenuButton/MenuButton
+!                                      mainMenu/SimpleMenu
+!                                              menuLabel/SmeBSB
+!                                              toolbar/SmeBSB
+!                                              ...
+!                                      vtMenu/SimpleMenu
+!                                              menuLabel/SmeBSB
+!                                              scrollbar/SmeBSB
+!                                              ...
+!                                      fontMenu/SimpleMenu
+!                                              menuLabel/SmeBSB
+!                                              fontdefault/SmeBSB
+!                                              ...
+!                                      tekMenu/SimpleMenu
+!                                              menuLabel/SmeBSB
+!                                              fontdefault/SmeBSB
+!                                              ...
+!                      vt100/VT100
+!                      tektronix/TopLevelShell
+!                              shellext/VendorShellExt
+!                                      tek4014/Tek4014
+!
+! If built without a toolbar, the widget hierarchy is simpler, because there
+! is no form, and the popup menu widgets are created only when they are first
+! used.
+!
+!      xterm/XTerm
+!              shellext/VendorShellExt
+!                      mainMenu/SimpleMenu
+!                              menuLabel/SmeBSB
+!                              ...
+!                      ...
+!              vt100/VT100
+!              tektronix/TopLevelShell
+!                      shellext/VendorShellExt
+!                              tek4014/Tek4014
+!
+! A more complete list of the widget/class names can be obtained using editres
+! to dump a file.  Some widget names are not available until the corresponding
+! menu has been created.
+
+! These resources reduce space around the menubar, by eliminating padding in
+! the enclosing form (Thickness) and the border of the Box which represents
+! the menubar widget.
+*form.Thickness: 0
+*menubar.borderWidth: 0
+
+! If we wanted to eliminate the border of the popup menus, we could do this
+! instead, since they are children of the menubar:
+!*menubar*borderWidth: 0
+
+! Eliminate the border of the buttons in the menubar, so the only line around
+! the text is for the highlighted button:
+*MenuButton*borderWidth: 0
+
+! Set a border for the menus to make them simpler to distinguish against the
+! vt100 widget:
+*SimpleMenu*borderWidth: 2
+
+! xterm can switch at runtime between bitmap (default) and TrueType fonts.
+! The "faceSize" resource controls the size of the latter.  However, it was
+! originally given with a size that makes the two types of fonts different
+! sizes.  Uncomment this line to use the same size as "fixed".
+!*faceSize: 8
+
+! Here is a pattern that is useful for double-clicking on a URL:
+!*charClass: 33:48,35:48,37-38:48,43-47:48,58:48,61:48,63-64:48,95:48,126:48
+!
+! Alternatively,
+!*on2Clicks: regex [[:alpha:]]+://([[:alnum:]!#+,./=?@_~-]|(%[[:xdigit:]][[:xdigit:]]))+
+
+! VT100s and similar terminals recognize escape sequences and control
+! characters to which they reply to the host with other escape sequences,
+! to provide information.  The "resize" program uses this feature.
+!
+! In addition, xterm recognizes several escape sequences which can be used to
+! set fonts, window properties, return settings via escape sequences.  Some
+! find these useful; others are concerned with the possibility of unexpected
+! inputs.
+!
+! All of these features can be enabled or disabled via menus.
+!
+! Depending on your environment, you may wish to disable those by default by
+! uncommenting one or more of the resource settings below:
+!*allowFontOps: false
+!*allowTcapOps: false
+!*allowTitleOps: false
+!*allowWindowOps: false
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..e0800dc
--- /dev/null
@@ -0,0 +1,3280 @@
+dnl $XTermId: aclocal.m4,v 1.293 2010/11/19 10:44:13 tom Exp $
+dnl
+dnl ---------------------------------------------------------------------------
+dnl
+dnl Copyright 1997-2009,2010 by Thomas E. Dickey
+dnl
+dnl                         All Rights Reserved
+dnl
+dnl Permission is hereby granted, free of charge, to any person obtaining a
+dnl copy of this software and associated documentation files (the
+dnl "Software"), to deal in the Software without restriction, including
+dnl without limitation the rights to use, copy, modify, merge, publish,
+dnl distribute, sublicense, and/or sell copies of the Software, and to
+dnl permit persons to whom the Software is furnished to do so, subject to
+dnl the following conditions:
+dnl 
+dnl The above copyright notice and this permission notice shall be included
+dnl in all copies or substantial portions of the Software.
+dnl 
+dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+dnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+dnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+dnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+dnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+dnl 
+dnl Except as contained in this notice, the name(s) of the above copyright
+dnl holders shall not be used in advertising or otherwise to promote the
+dnl sale, use or other dealings in this Software without prior written
+dnl authorization.
+dnl
+dnl ---------------------------------------------------------------------------
+dnl See
+dnl            http://invisible-island.net/autoconf/autoconf.html
+dnl ---------------------------------------------------------------------------
+dnl ---------------------------------------------------------------------------
+dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
+dnl -------------------
+dnl Inserted as requested by gettext 0.10.40
+dnl File from /usr/share/aclocal
+dnl codeset.m4
+dnl ====================
+dnl serial AM1
+dnl
+dnl From Bruno Haible.
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
+    [AC_TRY_LINK([#include <langinfo.h>],
+      [char* cs = nl_langinfo(CODESET);],
+      am_cv_langinfo_codeset=yes,
+      am_cv_langinfo_codeset=no)
+    ])
+  if test $am_cv_langinfo_codeset = yes; then
+    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
+      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+  fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
+dnl -------------
+dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
+dnl The second parameter if given makes this macro verbose.
+dnl
+dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
+dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
+dnl confused by the quotes (which require backslashes to keep them usable).
+AC_DEFUN([CF_ADD_CFLAGS],
+[
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $1
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+                               CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+       ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+       ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+       ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+AC_SUBST(EXTRA_CPPFLAGS)
+
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
+dnl ----------
+dnl Add a library, used to enforce consistency.
+dnl
+dnl $1 = library to add, without the "-l"
+dnl $2 = variable to update (default $LIBS)
+AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
+dnl -----------
+dnl Add one or more libraries, used to enforce consistency.
+dnl
+dnl $1 = libraries to add, with the "-l", etc.
+dnl $2 = variable to update (default $LIBS)
+AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ADD_LIB_AFTER version: 2 updated: 2010/11/08 20:33:46
+dnl ----------------
+dnl Add a given library after another, e.g., following the one it satisfies a
+dnl dependency for.
+dnl
+dnl $1 = the first library
+dnl $2 = its dependency
+AC_DEFUN([CF_ADD_LIB_AFTER],[
+CF_VERBOSE(...before $LIBS)
+LIBS=`echo "$LIBS" | sed -e "s/[[      ]][[    ]]*/ /g" -e "s,$1 ,$1 $2 ," -e 's/  / /g'`
+CF_VERBOSE(...after  $LIBS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ANSI_CC_CHECK version: 10 updated: 2010/10/23 15:52:32
+dnl ----------------
+dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
+dnl in the sharutils 4.2 distribution.
+AC_DEFUN([CF_ANSI_CC_CHECK],
+[
+AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
+cf_cv_ansi_cc=no
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX                  -qlanglvl=ansi
+# Ultrix and OSF/1     -std1
+# HP-UX                        -Aa -D_HPUX_SOURCE
+# SVR4                 -Xc
+# UnixWare 1.2         (cannot use -Xc, since ANSI/POSIX clashes)
+for cf_arg in "-DCC_HAS_PROTOS" \
+       "" \
+       -qlanglvl=ansi \
+       -std1 \
+       -Ae \
+       "-Aa -D_HPUX_SOURCE" \
+       -Xc
+do
+       CF_ADD_CFLAGS($cf_arg)
+       AC_TRY_COMPILE(
+[
+#ifndef CC_HAS_PROTOS
+#if !defined(__STDC__) || (__STDC__ != 1)
+choke me
+#endif
+#endif
+],[
+       int test (int i, double x);
+       struct s1 {int (*f) (int a);};
+       struct s2 {int (*f) (double a);};],
+       [cf_cv_ansi_cc="$cf_arg"; break])
+done
+CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
+])
+
+if test "$cf_cv_ansi_cc" != "no"; then
+if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
+       CF_ADD_CFLAGS($cf_cv_ansi_cc)
+else
+       AC_DEFINE(CC_HAS_PROTOS)
+fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
+dnl --------------
+dnl Allow user to disable a normally-on option.
+AC_DEFUN([CF_ARG_DISABLE],
+[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
+dnl -------------
+dnl Allow user to enable a normally-off option.
+AC_DEFUN([CF_ARG_ENABLE],
+[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
+dnl -------------
+dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
+dnl values.
+dnl
+dnl Parameters:
+dnl $1 = option name
+dnl $2 = help-string
+dnl $3 = action to perform if option is not default
+dnl $4 = action if perform if option is default
+dnl $5 = default option value (either 'yes' or 'no')
+AC_DEFUN([CF_ARG_OPTION],
+[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
+  if test "$enableval" != "$5" ; then
+ifelse([$3],,[    :]dnl
+,[    $3]) ifelse([$4],,,[
+  else
+    $4])
+  fi],[enableval=$5 ifelse([$4],,,[
+  $4
+])dnl
+  ])])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
+dnl --------------
+dnl Check if we're accidentally using a cache from a different machine.
+dnl Derive the system name, as a check for reusing the autoconf cache.
+dnl
+dnl If we've packaged config.guess and config.sub, run that (since it does a
+dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
+dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
+dnl which is useful in cross-compiles.
+dnl
+dnl Note: we would use $ac_config_sub, but that is one of the places where
+dnl autoconf 2.5x broke compatibility with autoconf 2.13
+AC_DEFUN([CF_CHECK_CACHE],
+[
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+       ifelse([$1],,[AC_CANONICAL_HOST],[$1])
+       system_name="$host_os"
+else
+       system_name="`(uname -s -r) 2>/dev/null`"
+       if test -z "$system_name" ; then
+               system_name="`(hostname) 2>/dev/null`"
+       fi
+fi
+test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
+AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
+
+test -z "$system_name" && system_name="$cf_cv_system_name"
+test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
+
+if test ".$system_name" != ".$cf_cv_system_name" ; then
+       AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
+       AC_MSG_ERROR("Please remove config.cache and try again.")
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
+dnl ---------------
+dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
+dnl a build-configuration such as imake.  These have the pitfall that they
+dnl often contain compiler-specific options which we cannot use, mixed with
+dnl preprocessor options that we usually can.
+AC_DEFUN([CF_CHECK_CFLAGS],
+[
+CF_VERBOSE(checking additions to CFLAGS)
+cf_check_cflags="$CFLAGS"
+cf_check_cppflags="$CPPFLAGS"
+CF_ADD_CFLAGS($1,yes)
+if test "$cf_check_cflags" != "$CFLAGS" ; then
+AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
+       [CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
+        if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
+                CF_VERBOSE(but keeping change to \$CPPFLAGS)
+        fi
+        CFLAGS="$cf_check_flags"])
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CHECK_ERRNO version: 11 updated: 2010/05/26 05:38:42
+dnl --------------
+dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
+dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
+dnl ourselves.
+dnl
+dnl $1 = the name to check
+dnl $2 = the assumed type
+AC_DEFUN([CF_CHECK_ERRNO],
+[
+AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
+    AC_TRY_COMPILE([
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h> ],
+    ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
+    [cf_cv_dcl_$1=yes],
+    [cf_cv_dcl_$1=no])
+])
+
+if test "$cf_cv_dcl_$1" = no ; then
+    CF_UPPER(cf_result,decl_$1)
+    AC_DEFINE_UNQUOTED($cf_result)
+fi
+
+# It's possible (for near-UNIX clones) that the data doesn't exist
+CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
+dnl --------------------
+dnl Check for existence of external data in the current set of libraries.  If
+dnl we can modify it, it's real enough.
+dnl $1 = the name to check
+dnl $2 = its type
+AC_DEFUN([CF_CHECK_EXTERN_DATA],
+[
+AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
+    AC_TRY_LINK([
+#undef $1
+extern $2 $1;
+],
+    [$1 = 2],
+    [cf_cv_have_$1=yes],
+    [cf_cv_have_$1=no])
+])
+
+if test "$cf_cv_have_$1" = yes ; then
+    CF_UPPER(cf_result,have_$1)
+    AC_DEFINE_UNQUOTED($cf_result)
+fi
+
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
+dnl ---------------
+dnl You can always use "make -n" to see the actual options, but it's hard to
+dnl pick out/analyze warning messages when the compile-line is long.
+dnl
+dnl Sets:
+dnl    ECHO_LT - symbol to control if libtool is verbose
+dnl    ECHO_LD - symbol to prefix "cc -o" lines
+dnl    RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
+dnl    SHOW_CC - symbol to put before explicit "cc -c" lines
+dnl    ECHO_CC - symbol to put before any "cc" line
+dnl
+AC_DEFUN([CF_DISABLE_ECHO],[
+AC_MSG_CHECKING(if you want to see long compiling messages)
+CF_ARG_DISABLE(echo,
+       [  --disable-echo          display "compiling" commands],
+       [
+    ECHO_LT='--silent'
+    ECHO_LD='@echo linking [$]@;'
+    RULE_CC='@echo compiling [$]<'
+    SHOW_CC='@echo compiling [$]@'
+    ECHO_CC='@'
+],[
+    ECHO_LT=''
+    ECHO_LD=''
+    RULE_CC=''
+    SHOW_CC=''
+    ECHO_CC=''
+])
+AC_MSG_RESULT($enableval)
+AC_SUBST(ECHO_LT)
+AC_SUBST(ECHO_LD)
+AC_SUBST(RULE_CC)
+AC_SUBST(SHOW_CC)
+AC_SUBST(ECHO_CC)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_DISABLE_RPATH_HACK version: 1 updated: 2010/04/11 10:54:00
+dnl ---------------------
+dnl The rpath-hack makes it simpler to build programs, particularly with the
+dnl *BSD ports which may have essential libraries in unusual places.  But it
+dnl can interfere with building an executable for the base system.  Use this
+dnl option in that case.
+AC_DEFUN([CF_DISABLE_RPATH_HACK],
+[
+AC_MSG_CHECKING(if rpath should be not be set)
+CF_ARG_DISABLE(rpath-hack,
+       [  --disable-rpath-hack    don't add rpath options for additional libraries],
+       [cf_disable_rpath_hack=yes],
+       [cf_disable_rpath_hack=no])
+AC_MSG_RESULT($cf_disable_rpath_hack)
+if test "$cf_disable_rpath_hack" = no ; then
+       CF_RPATH_HACK
+fi
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_ENABLE_NARROWPROTO version: 3 updated: 2006/02/12 17:46:00
+dnl ---------------------
+dnl If this is not set properly, Xaw's scrollbars will not work.
+dnl The so-called "modular" configuration for X.org omits most of the
+dnl configure checks that would be needed to provide compatibility with
+dnl older X builds.  This one breaks things noticeably.
+AC_DEFUN([CF_ENABLE_NARROWPROTO],
+[
+AC_MSG_CHECKING(if you want narrow prototypes for X libraries)
+
+case `$ac_config_guess` in #(vi
+*cygwin*|*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*) #(vi
+       cf_default_narrowproto=yes
+       ;;
+*)
+       cf_default_narrowproto=no
+       ;;
+esac
+
+CF_ARG_OPTION(narrowproto,
+       [  --enable-narrowproto    enable narrow prototypes for X libraries],
+       [enable_narrowproto=$enableval],
+       [enable_narrowproto=$cf_default_narrowproto],
+       [$cf_default_narrowproto])
+AC_MSG_RESULT($enable_narrowproto)
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
+dnl --------
+dnl Check if 'errno' is declared in <errno.h>
+AC_DEFUN([CF_ERRNO],
+[
+CF_CHECK_ERRNO(errno)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
+dnl ---------------
+dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
+dnl is found, add our own version of memmove to the list of objects.
+AC_DEFUN([CF_FUNC_MEMMOVE],
+[
+AC_CHECK_FUNC(memmove,,[
+AC_CHECK_FUNC(bcopy,[
+       AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
+               AC_TRY_RUN([
+int main() {
+       static char data[] = "abcdefghijklmnopqrstuwwxyz";
+       char temp[40];
+       bcopy(data, temp, sizeof(data));
+       bcopy(temp+10, temp, 15);
+       bcopy(temp+5, temp+15, 10);
+       ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
+}
+               ],
+               [cf_cv_good_bcopy=yes],
+               [cf_cv_good_bcopy=no],
+               [cf_cv_good_bcopy=unknown])
+               ])
+       ],[cf_cv_good_bcopy=no])
+       if test "$cf_cv_good_bcopy" = yes ; then
+               AC_DEFINE(USE_OK_BCOPY)
+       else
+               AC_DEFINE(USE_MY_MEMMOVE)
+       fi
+])])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_TGETENT version: 15 updated: 2010/06/04 20:54:56
+dnl ---------------
+dnl Check for tgetent function in termcap library.  If we cannot find this,
+dnl we'll use the $LINES and $COLUMNS environment variables to pass screen
+dnl size information to subprocesses.  (We cannot use terminfo's compatibility
+dnl function, since it cannot provide the termcap-format data).
+dnl
+dnl If the --disable-full-tgetent option is given, we'll settle for the first
+dnl tgetent function we find.  Since the search list in that case does not
+dnl include the termcap library, that allows us to default to terminfo.
+AC_DEFUN([CF_FUNC_TGETENT],
+[
+# compute a reasonable value for $TERM to give tgetent(), since we may be
+# running in 'screen', which sets $TERMCAP to a specific entry that is not
+# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
+# discard $TERMCAP.
+cf_TERMVAR=vt100
+test -n "$TERMCAP" && cf_TERMVAR="$TERM"
+test -z "$cf_TERMVAR" && cf_TERMVAR=vt100
+
+AC_MSG_CHECKING(if we want full tgetent function)
+CF_ARG_DISABLE(full-tgetent,
+       [  --disable-full-tgetent  disable check for full tgetent function],
+       cf_full_tgetent=no,
+       cf_full_tgetent=yes,yes)
+AC_MSG_RESULT($cf_full_tgetent)
+
+if test "$cf_full_tgetent" = yes ; then
+       cf_test_message="full tgetent"
+else
+       cf_test_message="tgetent"
+fi
+
+AC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
+cf_save_LIBS="$LIBS"
+cf_cv_lib_tgetent=no
+if test "$cf_full_tgetent" = yes ; then
+       cf_TERMLIB="termcap termlib ncurses curses"
+       cf_TERMTST="buffer[[0]] == 0"
+else
+       cf_TERMLIB="termlib ncurses curses"
+       cf_TERMTST="0"
+fi
+for cf_termlib in '' $cf_TERMLIB ; do
+       LIBS="$cf_save_LIBS"
+       test -n "$cf_termlib" && CF_ADD_LIB($cf_termlib)
+       AC_TRY_RUN([
+/* terminfo implementations ignore the buffer argument, making it useless for
+ * the xterm application, which uses this information to make a new TERMCAP
+ * environment variable.
+ */
+int main()
+{
+       char buffer[1024];
+       buffer[0] = 0;
+       tgetent(buffer, "$cf_TERMVAR");
+       ${cf_cv_main_return:-return} ($cf_TERMTST); }],
+       [echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
+        if test -n "$cf_termlib" ; then
+               cf_cv_lib_tgetent="-l$cf_termlib"
+        else
+               cf_cv_lib_tgetent=yes
+        fi
+        break],
+       [echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
+       [echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
+done
+LIBS="$cf_save_LIBS"
+])
+
+# If we found a working tgetent(), set LIBS and check for termcap.h.
+# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
+# not have side effects other than setting the cache variable, because
+# they are not executed when a cached value exists.)
+if test "$cf_cv_lib_tgetent" != no ; then
+       test "$cf_cv_lib_tgetent" != yes && CF_ADD_LIBS($cf_cv_lib_tgetent)
+       AC_DEFINE(USE_TERMCAP)
+       if test "$cf_full_tgetent" = no ; then
+               AC_TRY_COMPILE([
+#include <termcap.h>],[
+#ifdef NCURSES_VERSION
+make an error
+#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
+       else
+               AC_CHECK_HEADERS(termcap.h)
+       fi
+else
+        # If we didn't find a tgetent() that supports the buffer
+        # argument, look again to see whether we can find even
+        # a crippled one.  A crippled tgetent() is still useful to
+        # validate values for the TERM environment variable given to
+        # child processes.
+       AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
+       cf_cv_lib_part_tgetent=no
+       for cf_termlib in $cf_TERMLIB ; do
+               LIBS="$cf_save_LIBS -l$cf_termlib"
+               AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
+                       [echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
+                        cf_cv_lib_part_tgetent="-l$cf_termlib"
+                        break])
+       done
+       LIBS="$cf_save_LIBS"
+       ])
+
+       if test "$cf_cv_lib_part_tgetent" != no ; then
+               CF_ADD_LIBS($cf_cv_lib_part_tgetent)
+               AC_CHECK_HEADERS(termcap.h)
+
+                # If this is linking against ncurses, we'll trigger the
+                # ifdef in resize.c that turns the termcap stuff back off.
+               AC_DEFINE(USE_TERMINFO)
+       fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
+dnl -----------------
+dnl Test for availability of useful gcc __attribute__ directives to quiet
+dnl compiler warnings.  Though useful, not all are supported -- and contrary
+dnl to documentation, unrecognized directives cause older compilers to barf.
+AC_DEFUN([CF_GCC_ATTRIBUTES],
+[
+if test "$GCC" = yes
+then
+cat > conftest.i <<EOF
+#ifndef GCC_PRINTF
+#define GCC_PRINTF 0
+#endif
+#ifndef GCC_SCANF
+#define GCC_SCANF 0
+#endif
+#ifndef GCC_NORETURN
+#define GCC_NORETURN /* nothing */
+#endif
+#ifndef GCC_UNUSED
+#define GCC_UNUSED /* nothing */
+#endif
+EOF
+if test "$GCC" = yes
+then
+       AC_CHECKING([for $CC __attribute__ directives])
+cat > conftest.$ac_ext <<EOF
+#line __oline__ "${as_me:-configure}"
+#include "confdefs.h"
+#include "conftest.h"
+#include "conftest.i"
+#if    GCC_PRINTF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+#else
+#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
+#endif
+#if    GCC_SCANF
+#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
+#else
+#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
+#endif
+extern void wow(char *,...) GCC_SCANFLIKE(1,2);
+extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern void foo(void) GCC_NORETURN;
+int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
+EOF
+       cf_printf_attribute=no
+       cf_scanf_attribute=no
+       for cf_attribute in scanf printf unused noreturn
+       do
+               CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
+               cf_directive="__attribute__(($cf_attribute))"
+               echo "checking for $CC $cf_directive" 1>&AC_FD_CC
+
+               case $cf_attribute in #(vi
+               printf) #(vi
+                       cf_printf_attribute=yes
+                       cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+                       ;;
+               scanf) #(vi
+                       cf_scanf_attribute=yes
+                       cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+                       ;;
+               *) #(vi
+                       cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE $cf_directive
+EOF
+                       ;;
+               esac
+
+               if AC_TRY_EVAL(ac_compile); then
+                       test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
+                       cat conftest.h >>confdefs.h
+                       case $cf_attribute in #(vi
+                       printf) #(vi
+                               if test "$cf_printf_attribute" = no ; then
+                                       cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) /* nothing */
+EOF
+                               else
+                                       cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+EOF
+                               fi
+                               ;;
+                       scanf) #(vi
+                               if test "$cf_scanf_attribute" = no ; then
+                                       cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var) /* nothing */
+EOF
+                               else
+                                       cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
+EOF
+                               fi
+                               ;;
+                       esac
+               fi
+       done
+else
+       fgrep define conftest.i >>confdefs.h
+fi
+rm -rf conftest*
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
+dnl --------------
+dnl Find version of gcc
+AC_DEFUN([CF_GCC_VERSION],[
+AC_REQUIRE([AC_PROG_CC])
+GCC_VERSION=none
+if test "$GCC" = yes ; then
+       AC_MSG_CHECKING(version of $CC)
+       GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
+       test -z "$GCC_VERSION" && GCC_VERSION=unknown
+       AC_MSG_RESULT($GCC_VERSION)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
+dnl ---------------
+dnl Check if the compiler supports useful warning options.  There's a few that
+dnl we don't use, simply because they're too noisy:
+dnl
+dnl    -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
+dnl    -Wredundant-decls (system headers make this too noisy)
+dnl    -Wtraditional (combines too many unrelated messages, only a few useful)
+dnl    -Wwrite-strings (too noisy, but should review occasionally).  This
+dnl            is enabled for ncurses using "--enable-const".
+dnl    -pedantic
+dnl
+dnl Parameter:
+dnl    $1 is an optional list of gcc warning flags that a particular
+dnl            application might want to use, e.g., "no-unused" for
+dnl            -Wno-unused
+dnl Special:
+dnl    If $with_ext_const is "yes", add a check for -Wwrite-strings
+dnl
+AC_DEFUN([CF_GCC_WARNINGS],
+[
+AC_REQUIRE([CF_GCC_VERSION])
+CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
+
+cat > conftest.$ac_ext <<EOF
+#line __oline__ "${as_me:-configure}"
+int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
+EOF
+
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
+# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #279: controlling expression is constant
+
+       AC_CHECKING([for $CC warning options])
+       cf_save_CFLAGS="$CFLAGS"
+       EXTRA_CFLAGS="-Wall"
+       for cf_opt in \
+               wd1419 \
+               wd1683 \
+               wd1684 \
+               wd193 \
+               wd593 \
+               wd279 \
+               wd810 \
+               wd869 \
+               wd981
+       do
+               CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+               if AC_TRY_EVAL(ac_compile); then
+                       test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
+                       EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+               fi
+       done
+       CFLAGS="$cf_save_CFLAGS"
+
+elif test "$GCC" = yes
+then
+       AC_CHECKING([for $CC warning options])
+       cf_save_CFLAGS="$CFLAGS"
+       EXTRA_CFLAGS=
+       cf_warn_CONST=""
+       test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
+       for cf_opt in W Wall \
+               Wbad-function-cast \
+               Wcast-align \
+               Wcast-qual \
+               Winline \
+               Wmissing-declarations \
+               Wmissing-prototypes \
+               Wnested-externs \
+               Wpointer-arith \
+               Wshadow \
+               Wstrict-prototypes \
+               Wundef $cf_warn_CONST $1
+       do
+               CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+               if AC_TRY_EVAL(ac_compile); then
+                       test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
+                       case $cf_opt in #(vi
+                       Wcast-qual) #(vi
+                               CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
+                               ;;
+                       Winline) #(vi
+                               case $GCC_VERSION in
+                               [[34]].*)
+                                       CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
+                                       continue;;
+                               esac
+                               ;;
+                       esac
+                       EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+               fi
+       done
+       CFLAGS="$cf_save_CFLAGS"
+fi
+rm -rf conftest*
+
+AC_SUBST(EXTRA_CFLAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
+dnl -------------
+dnl Check if we must define _GNU_SOURCE to get a reasonable value for
+dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
+dnl (or misfeature) of glibc2, which breaks portability of many applications,
+dnl since it is interwoven with GNU extensions.
+dnl
+dnl Well, yes we could work around it...
+AC_DEFUN([CF_GNU_SOURCE],
+[
+AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
+AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _XOPEN_SOURCE
+make an error
+#endif],
+       [cf_cv_gnu_source=no],
+       [cf_save="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+        AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _XOPEN_SOURCE
+make an error
+#endif],
+       [cf_cv_gnu_source=no],
+       [cf_cv_gnu_source=yes])
+       CPPFLAGS="$cf_save"
+       ])
+])
+test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
+dnl ---------------
+dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
+AC_DEFUN([CF_HELP_MESSAGE],
+[AC_DIVERT_HELP([$1])dnl
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_IMAKE_CFLAGS version: 31 updated: 2010/05/26 05:38:42
+dnl ---------------
+dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
+dnl get these, but if imake is properly configured there is no point in doing
+dnl this.
+dnl
+dnl Parameters (used in constructing a sample Imakefile):
+dnl    $1 = optional value to append to $IMAKE_CFLAGS
+dnl    $2 = optional value to append to $IMAKE_LOADFLAGS
+AC_DEFUN([CF_IMAKE_CFLAGS],
+[
+AC_PATH_PROGS(IMAKE,xmkmf imake)
+
+if test -n "$IMAKE" ; then
+
+case $IMAKE in # (vi
+*/imake)
+       cf_imake_opts="-DUseInstalled=YES" # (vi
+       ;;
+*/util/xmkmf)
+       # A single parameter tells xmkmf where the config-files are:
+       cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`" # (vi
+       ;;
+*)
+       cf_imake_opts=
+       ;;
+esac
+
+# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
+# config directory.
+if mkdir conftestdir; then
+       CDPATH=; export CDPATH
+       cf_makefile=`cd $srcdir;pwd`/Imakefile
+       cd conftestdir
+
+       cat >fix_cflags.sed <<'CF_EOF'
+s/\\//g
+s/[[   ]][[    ]]*/ /g
+s/"//g
+:pack
+s/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1     \2/g
+t pack
+s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
+s/^IMAKE[[ ]]/IMAKE_CFLAGS="/
+s/     / /g
+s/$/"/
+CF_EOF
+
+       cat >fix_lflags.sed <<'CF_EOF'
+s/^IMAKE[[     ]]*/IMAKE_LOADFLAGS="/
+s/$/"/
+CF_EOF
+
+       echo >./Imakefile
+       test -f $cf_makefile && cat $cf_makefile >>./Imakefile
+
+       cat >> ./Imakefile <<'CF_EOF'
+findstddefs:
+       @echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
+       @echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
+CF_EOF
+
+       if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
+       then
+               CF_VERBOSE(Using $IMAKE $cf_imake_opts)
+       else
+               # sometimes imake doesn't have the config path compiled in.  Find it.
+               cf_config=
+               for cf_libpath in $X_LIBS $LIBS ; do
+                       case $cf_libpath in # (vi
+                       -L*)
+                               cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
+                               cf_libpath=$cf_libpath/X11/config
+                               if test -d $cf_libpath ; then
+                                       cf_config=$cf_libpath
+                                       break
+                               fi
+                               ;;
+                       esac
+               done
+               if test -z "$cf_config" ; then
+                       AC_MSG_WARN(Could not find imake config-directory)
+               else
+                       cf_imake_opts="$cf_imake_opts -I$cf_config"
+                       if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
+                       then
+                               CF_VERBOSE(Using $IMAKE $cf_config)
+                       else
+                               AC_MSG_WARN(Cannot run $IMAKE)
+                       fi
+               fi
+       fi
+
+       # GNU make sometimes prints "make[1]: Entering...", which
+       # would confuse us.
+       eval `make findstddefs 2>/dev/null | grep -v make`
+
+       cd ..
+       rm -rf conftestdir
+
+       # We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
+       # declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
+       # modified it to support site.cf, adding a kludge for the /usr/include
+       # directory.  Try to filter that out, otherwise gcc won't find its
+       # headers.
+       if test -n "$GCC" ; then
+           if test -n "$IMAKE_CFLAGS" ; then
+               cf_nostdinc=""
+               cf_std_incl=""
+               cf_cpp_opts=""
+               for cf_opt in $IMAKE_CFLAGS
+               do
+                   case "$cf_opt" in
+                   -nostdinc) #(vi
+                       cf_nostdinc="$cf_opt"
+                       ;;
+                   -I/usr/include) #(vi
+                       cf_std_incl="$cf_opt"
+                       ;;
+                   *) #(vi
+                       cf_cpp_opts="$cf_cpp_opts $cf_opt"
+                       ;;
+                   esac
+               done
+               if test -z "$cf_nostdinc" ; then
+                   IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
+               elif test -z "$cf_std_incl" ; then
+                   IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
+               else
+                   CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
+                   IMAKE_CFLAGS="$cf_cpp_opts"
+               fi
+           fi
+       fi
+fi
+
+# Some imake configurations define PROJECTROOT with an empty value.  Remove
+# the empty definition.
+case $IMAKE_CFLAGS in
+*-DPROJECTROOT=/*)
+       ;;
+*)
+       IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[  ]], ,"`
+       ;;
+esac
+
+fi
+
+CF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
+CF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
+
+AC_SUBST(IMAKE_CFLAGS)
+AC_SUBST(IMAKE_LOADFLAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
+dnl ---------------
+dnl Check if the X libraries support input-method
+AC_DEFUN([CF_INPUT_METHOD],
+[
+AC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
+AC_TRY_LINK([
+#include <X11/IntrinsicP.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xaw/XawImP.h>
+],[
+{
+       XIM xim;
+       XIMStyles *xim_styles = 0;
+       XIMStyle input_style;
+       Widget w = 0;
+
+       XSetLocaleModifiers("@im=none");
+       xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
+       XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
+       XCloseIM(xim);
+       input_style = (XIMPreeditNothing | XIMStatusNothing);
+}
+],
+[cf_cv_input_method=yes],
+[cf_cv_input_method=no])])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
+dnl -----------------
+dnl Check if the given compiler is really the Intel compiler for Linux.  It
+dnl tries to imitate gcc, but does not return an error when it finds a mismatch
+dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
+dnl
+dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
+dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
+dnl the wrappers for gcc and g++ warnings.
+dnl
+dnl $1 = GCC (default) or GXX
+dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
+dnl $3 = CFLAGS (default) or CXXFLAGS
+AC_DEFUN([CF_INTEL_COMPILER],[
+ifelse([$2],,INTEL_COMPILER,[$2])=no
+
+if test "$ifelse([$1],,[$1],GCC)" = yes ; then
+       case $host_os in
+       linux*|gnu*)
+               AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
+               cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
+               ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
+               AC_TRY_COMPILE([],[
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
+],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+],[])
+               ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
+               AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
+               ;;
+       esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_LASTLOG version: 4 updated: 2002/10/27 23:21:42
+dnl ----------
+dnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
+dnl file exists.
+AC_DEFUN([CF_LASTLOG],
+[
+AC_CHECK_HEADERS(lastlog.h paths.h)
+AC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_LASTLOG_H
+#include <lastlog.h>
+#else
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+#endif],[char *path = _PATH_LASTLOG],
+       [cf_cv_path_lastlog="_PATH_LASTLOG"],
+       [if test -f /usr/adm/lastlog ; then
+               cf_cv_path_lastlog=/usr/adm/lastlog
+       else
+               cf_cv_path_lastlog=no
+       fi])
+])
+test $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_LD_RPATH_OPT version: 3 updated: 2010/06/02 05:03:05
+dnl ---------------
+dnl For the given system and compiler, find the compiler flags to pass to the
+dnl loader to use the "rpath" feature.
+AC_DEFUN([CF_LD_RPATH_OPT],
+[
+AC_REQUIRE([CF_CHECK_CACHE])
+
+LD_RPATH_OPT=
+AC_MSG_CHECKING(for an rpath option)
+case $cf_cv_system_name in #(vi
+irix*) #(vi
+       if test "$GCC" = yes; then
+               LD_RPATH_OPT="-Wl,-rpath,"
+       else
+               LD_RPATH_OPT="-rpath "
+       fi
+       ;;
+linux*|gnu*|k*bsd*-gnu) #(vi
+       LD_RPATH_OPT="-Wl,-rpath,"
+       ;;
+openbsd[[2-9]].*) #(vi
+       LD_RPATH_OPT="-Wl,-rpath,"
+       ;;
+freebsd*) #(vi
+       LD_RPATH_OPT="-rpath "
+       ;;
+netbsd*) #(vi
+       LD_RPATH_OPT="-Wl,-rpath,"
+       ;;
+osf*|mls+*) #(vi
+       LD_RPATH_OPT="-rpath "
+       ;;
+solaris2*) #(vi
+       LD_RPATH_OPT="-R"
+       ;;
+*)
+       ;;
+esac
+AC_MSG_RESULT($LD_RPATH_OPT)
+
+case "x$LD_RPATH_OPT" in #(vi
+x-R*)
+       AC_MSG_CHECKING(if we need a space after rpath option)
+       cf_save_LIBS="$LIBS"
+       CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
+       AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
+       LIBS="$cf_save_LIBS"
+       AC_MSG_RESULT($cf_rpath_space)
+       test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
+       ;;
+esac
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
+dnl ------------
+dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
+dnl a monocase filesystem.
+AC_DEFUN([CF_MAKE_TAGS],[
+AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
+
+AC_CHECK_PROGS(CTAGS, exctags ctags)
+AC_CHECK_PROGS(ETAGS, exetags etags)
+
+AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
+
+if test "$cf_cv_mixedcase" = yes ; then
+       AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
+else
+       MAKE_UPPER_TAGS=no
+fi
+
+if test "$MAKE_UPPER_TAGS" = yes ; then
+       MAKE_UPPER_TAGS=
+else
+       MAKE_UPPER_TAGS="#"
+fi
+
+if test "$MAKE_LOWER_TAGS" = yes ; then
+       MAKE_LOWER_TAGS=
+else
+       MAKE_LOWER_TAGS="#"
+fi
+
+AC_SUBST(CTAGS)
+AC_SUBST(ETAGS)
+
+AC_SUBST(MAKE_UPPER_TAGS)
+AC_SUBST(MAKE_LOWER_TAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
+dnl ----------------------
+dnl Check if the file-system supports mixed-case filenames.  If we're able to
+dnl create a lowercase name and see it as uppercase, it doesn't support that.
+AC_DEFUN([CF_MIXEDCASE_FILENAMES],
+[
+AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
+if test "$cross_compiling" = yes ; then
+       case $target_alias in #(vi
+       *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
+               cf_cv_mixedcase=no
+               ;;
+       *)
+               cf_cv_mixedcase=yes
+               ;;
+       esac
+else
+       rm -f conftest CONFTEST
+       echo test >conftest
+       if test -f CONFTEST ; then
+               cf_cv_mixedcase=no
+       else
+               cf_cv_mixedcase=yes
+       fi
+       rm -f conftest CONFTEST
+fi
+])
+test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
+dnl ----------
+dnl Write a debug message to config.log, along with the line number in the
+dnl configure script.
+AC_DEFUN([CF_MSG_LOG],[
+echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PATHSEP version: 5 updated: 2010/05/26 05:38:42
+dnl ----------
+dnl Provide a value for the $PATH and similar separator
+AC_DEFUN([CF_PATHSEP],
+[
+       case $cf_cv_system_name in
+       os2*)   PATH_SEPARATOR=';'  ;;
+       *)      PATH_SEPARATOR=':'  ;;
+       esac
+ifelse([$1],,,[$1=$PATH_SEPARATOR])
+       AC_SUBST(PATH_SEPARATOR)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PATH_PROG version: 8 updated: 2010/10/23 16:12:25
+dnl ------------
+dnl Check for a given program, defining corresponding symbol.
+dnl    $1 = environment variable, which is suffixed by "_PATH" in the #define.
+dnl    $2 = program name to find.
+dnl    $3 = optional list of additional program names to test.
+dnl
+dnl If there is more than one token in the result, #define the remaining tokens
+dnl to $1_ARGS.  We need this for 'install' in particular.
+dnl
+dnl FIXME: we should allow this to be overridden by environment variables
+dnl
+AC_DEFUN([CF_PATH_PROG],[
+AC_REQUIRE([CF_PATHSEP])
+test -z "[$]$1" && $1=$2
+AC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
+
+cf_path_prog=""
+cf_path_args=""
+IFS="${IFS:-   }"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
+for cf_temp in $ac_cv_path_$1
+do
+       if test -z "$cf_path_prog" ; then
+               if test "$with_full_paths" = yes ; then
+                       CF_PATH_SYNTAX(cf_temp,break)
+                       cf_path_prog="$cf_temp"
+               else
+                       cf_path_prog="`basename $cf_temp`"
+               fi
+       elif test -z "$cf_path_args" ; then
+               cf_path_args="$cf_temp"
+       else
+               cf_path_args="$cf_path_args $cf_temp"
+       fi
+done
+IFS="$cf_save_ifs"
+
+if test -n "$cf_path_prog" ; then
+       CF_MSG_LOG(defining path for ${cf_path_prog})
+       AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog")
+       test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args")
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
+dnl --------------
+dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
+dnl begins with one of the prefix/exec_prefix variables, and then again if the
+dnl result begins with 'NONE'.  This is necessary to work around autoconf's
+dnl delayed evaluation of those symbols.
+AC_DEFUN([CF_PATH_SYNTAX],[
+if test "x$prefix" != xNONE; then
+  cf_path_syntax="$prefix"
+else
+  cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".[$]$1" in #(vi
+.\[$]\(*\)*|.\'*\'*) #(vi
+  ;;
+..|./*|.\\*) #(vi
+  ;;
+.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
+  ;;
+.\[$]{*prefix}*) #(vi
+  eval $1="[$]$1"
+  case ".[$]$1" in #(vi
+  .NONE/*)
+    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
+    ;;
+  esac
+  ;; #(vi
+.no|.NONE/*)
+  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
+  ;;
+*)
+  ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
+  ;;
+esac
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PKG_CONFIG version: 3 updated: 2009/01/25 10:55:09
+dnl -------------
+dnl Check for the package-config program, unless disabled by command-line.
+AC_DEFUN([CF_PKG_CONFIG],
+[
+AC_MSG_CHECKING(if you want to use pkg-config)
+AC_ARG_WITH(pkg-config,
+       [  --with-pkg-config{=path} enable/disable use of pkg-config],
+       [cf_pkg_config=$withval],
+       [cf_pkg_config=yes])
+AC_MSG_RESULT($cf_pkg_config)
+
+case $cf_pkg_config in #(vi
+no) #(vi
+       PKG_CONFIG=none
+       ;;
+yes) #(vi
+       AC_PATH_PROG(PKG_CONFIG, pkg-config, none)
+       ;;
+*)
+       PKG_CONFIG=$withval
+       ;;
+esac
+
+test -z "$PKG_CONFIG" && PKG_CONFIG=none
+if test "$PKG_CONFIG" != none ; then
+       CF_PATH_SYNTAX(PKG_CONFIG)
+fi
+
+AC_SUBST(PKG_CONFIG)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
+dnl -----------------
+dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
+dnl
+dnl    POSIX.1-1990                            _POSIX_SOURCE
+dnl    POSIX.1-1990 and                        _POSIX_SOURCE and
+dnl            POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
+dnl            Bindings Option
+dnl    POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
+dnl    POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
+dnl    X/Open 2000                             _POSIX_C_SOURCE=200112L
+dnl
+dnl Parameters:
+dnl    $1 is the nominal value for _POSIX_C_SOURCE
+AC_DEFUN([CF_POSIX_C_SOURCE],
+[
+cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
+
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+
+CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
+CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
+
+AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
+       CF_MSG_LOG(if the symbol is already defined go no further)
+       AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif],
+       [cf_cv_posix_c_source=no],
+       [cf_want_posix_source=no
+        case .$cf_POSIX_C_SOURCE in #(vi
+        .[[12]]??*) #(vi
+               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+               ;;
+        .2) #(vi
+               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+               cf_want_posix_source=yes
+               ;;
+        .*)
+               cf_want_posix_source=yes
+               ;;
+        esac
+        if test "$cf_want_posix_source" = yes ; then
+               AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _POSIX_SOURCE
+make an error
+#endif],[],
+               cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
+        fi
+        CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
+        CFLAGS="$cf_trim_CFLAGS"
+        CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+        CF_MSG_LOG(if the second compile does not leave our definition intact error)
+        AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif],,
+        [cf_cv_posix_c_source=no])
+        CFLAGS="$cf_save_CFLAGS"
+        CPPFLAGS="$cf_save_CPPFLAGS"
+       ])
+])
+
+if test "$cf_cv_posix_c_source" != no ; then
+       CFLAGS="$cf_trim_CFLAGS"
+       CPPFLAGS="$cf_trim_CPPFLAGS"
+       CF_ADD_CFLAGS($cf_cv_posix_c_source)
+fi
+
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_POSIX_SAVED_IDS version: 7 updated: 2007/03/14 16:43:53
+dnl ------------------
+dnl
+dnl Check first if saved-ids are always supported.  Some systems
+dnl may require runtime checks.
+AC_DEFUN([CF_POSIX_SAVED_IDS],
+[
+AC_CHECK_HEADERS( \
+sys/param.h \
+)
+
+AC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
+AC_TRY_LINK(
+[
+#include <unistd.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>         /* this may define "BSD" */
+#endif
+],[
+#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
+       void *p = (void *) seteuid;
+       int x = seteuid(geteuid());
+#elif defined(BSD) && (BSD >= 199103)
+/* The BSD's may implement the runtime check - and it fails.
+ * However, saved-ids work almost like POSIX (close enough for most uses).
+ */
+#else
+make an error
+#endif
+],[cf_cv_posix_saved_ids=yes
+],[
+AC_TRY_RUN([
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <unistd.h>
+int main()
+{
+       void *p = (void *) seteuid;
+       long code = sysconf(_SC_SAVED_IDS);
+       ${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
+}],
+       cf_cv_posix_saved_ids=yes,
+       cf_cv_posix_saved_ids=no,
+       cf_cv_posix_saved_ids=unknown)
+])
+])
+
+test "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS)
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_POSIX_WAIT version: 2 updated: 2000/05/29 16:16:04
+dnl -------------
+dnl Check for POSIX wait support
+AC_DEFUN([CF_POSIX_WAIT],
+[
+AC_REQUIRE([AC_HEADER_SYS_WAIT])
+AC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
+AC_TRY_LINK([
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+],[
+       int stat_loc;
+       pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
+       pid_t pid2 = wait(&stat_loc);
+],
+[cf_cv_posix_wait=yes],
+[cf_cv_posix_wait=no])
+])
+test "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
+dnl -------------
+dnl Find /proc tree (may be in a different place) which implements the "cwd"
+dnl link.
+AC_DEFUN([CF_PROCFS_CWD],[
+AC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
+cf_cv_procfs_cwd=no
+for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
+do
+       if test -d $cf_path && \
+          test -d $cf_path/$$ && \
+          ( test -d $cf_path/$$/cwd || \
+            test -L $cf_path/$$/cwd ); then
+               cf_cv_procfs_cwd=$cf_path
+               break
+       fi
+done
+])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
+dnl --------------
+dnl Check if C (preprocessor) -U and -D options are processed in the order
+dnl given rather than by type of option.  Some compilers insist on apply all
+dnl of the -U options after all of the -D options.  Others allow mixing them,
+dnl and may predefine symbols that conflict with those we define.
+AC_DEFUN([CF_PROG_CC_U_D],
+[
+AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
+       cf_save_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
+       AC_TRY_COMPILE([],[
+#ifndef U_D_OPTIONS
+make an undefined-error
+#endif
+#ifdef  D_U_OPTIONS
+make a defined-error
+#endif
+       ],[
+       cf_cv_cc_u_d_options=yes],[
+       cf_cv_cc_u_d_options=no])
+       CPPFLAGS="$cf_save_CPPFLAGS"
+])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
+dnl -----------
+dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
+AC_DEFUN([CF_PROG_EXT],
+[
+AC_REQUIRE([CF_CHECK_CACHE])
+case $cf_cv_system_name in
+os2*)
+    CFLAGS="$CFLAGS -Zmt"
+    CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
+    CXXFLAGS="$CXXFLAGS -Zmt"
+    # autoconf's macro sets -Zexe and suffix both, which conflict:w
+    LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
+    ac_cv_exeext=.exe
+    ;;
+esac
+
+AC_EXEEXT
+AC_OBJEXT
+
+PROG_EXT="$EXEEXT"
+AC_SUBST(PROG_EXT)
+test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_REGEX version: 8 updated: 2010/08/07 14:09:44
+dnl --------
+dnl Attempt to determine if we've got one of the flavors of regular-expression
+dnl code that we can support.
+AC_DEFUN([CF_REGEX],
+[
+
+cf_regex_func=no
+
+cf_regex_libs="regex re"
+case $host_os in #(vi
+mingw*)
+       cf_regex_libs="regex.dll $cf_regex_libs"
+       ;;
+esac
+
+AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
+       for cf_regex_lib in $cf_regex_libs
+       do
+               AC_CHECK_LIB($cf_regex_lib,regcomp,[
+                               CF_ADD_LIB($cf_regex_lib)
+                               cf_regex_func=regcomp
+                               break])
+       done
+])
+
+if test "$cf_regex_func" = no ; then
+       AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
+               AC_CHECK_LIB(gen,compile,[
+                               CF_ADD_LIB(gen)
+                               cf_regex_func=compile])])
+fi
+
+if test "$cf_regex_func" = no ; then
+       AC_MSG_WARN(cannot find regular expression library)
+fi
+
+AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
+
+cf_cv_regex_hdrs=no
+case $cf_regex_func in #(vi
+compile) #(vi
+       for cf_regex_hdr in regexp.h regexpr.h
+       do
+               AC_TRY_LINK([#include <$cf_regex_hdr>],[
+                       char *p = compile("", "", "", 0);
+                       int x = step("", "");
+               ],[
+                       cf_cv_regex_hdrs=$cf_regex_hdr
+                       break
+               ])
+       done
+       ;;
+*)
+       for cf_regex_hdr in regex.h
+       do
+               AC_TRY_LINK([#include <sys/types.h>
+#include <$cf_regex_hdr>],[
+                       regex_t *p;
+                       int x = regcomp(p, "", 0);
+                       int y = regexec(p, "", 0, 0, 0);
+                       regfree(p);
+               ],[
+                       cf_cv_regex_hdrs=$cf_regex_hdr
+                       break
+               ])
+       done
+       ;;
+esac
+
+])
+
+case $cf_cv_regex_hdrs in #(vi
+    no)               AC_MSG_WARN(no regular expression header found) ;; #(vi
+    regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;; #(vi
+    regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;; #(vi
+    regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
+esac
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
+dnl ----------------
+dnl Remove all -U and -D options that refer to the given symbol from a list
+dnl of C compiler options.  This works around the problem that not all
+dnl compilers process -U and -D options from left-to-right, so a -U option
+dnl cannot be used to cancel the effect of a preceding -D option.
+dnl
+dnl $1 = target (which could be the same as the source variable)
+dnl $2 = source (including '$')
+dnl $3 = symbol to remove
+define([CF_REMOVE_DEFINE],
+[
+$1=`echo "$2" | \
+       sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
+               -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_RPATH_HACK version: 8 updated: 2010/04/17 15:38:58
+dnl -------------
+AC_DEFUN([CF_RPATH_HACK],
+[
+AC_REQUIRE([CF_LD_RPATH_OPT])
+AC_MSG_CHECKING(for updated LDFLAGS)
+if test -n "$LD_RPATH_OPT" ; then
+       AC_MSG_RESULT(maybe)
+
+       AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
+       cf_rpath_list="/usr/lib /lib"
+       if test "$cf_ldd_prog" != no
+       then
+AC_TRY_LINK([#include <stdio.h>],
+               [printf("Hello");],
+               [cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[     ]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort -u`])
+       fi
+
+       CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
+
+       CF_RPATH_HACK_2(LDFLAGS)
+       CF_RPATH_HACK_2(LIBS)
+
+       CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
+fi
+AC_SUBST(EXTRA_LDFLAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
+dnl ---------------
+dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
+dnl EXTRA_LDFLAGS for each -L option found.
+dnl
+dnl $cf_rpath_list contains a list of directories to ignore.
+dnl
+dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
+dnl      but LIBS often has misplaced -L options.
+AC_DEFUN([CF_RPATH_HACK_2],
+[
+CF_VERBOSE(...checking $1 [$]$1)
+
+cf_rpath_dst=
+for cf_rpath_src in [$]$1
+do
+       case $cf_rpath_src in #(vi
+       -L*) #(vi
+
+               # check if this refers to a directory which we will ignore
+               cf_rpath_skip=no
+               if test -n "$cf_rpath_list"
+               then
+                       for cf_rpath_item in $cf_rpath_list
+                       do
+                               if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
+                               then
+                                       cf_rpath_skip=yes
+                                       break
+                               fi
+                       done
+               fi
+
+               if test "$cf_rpath_skip" = no
+               then
+                       # transform the option
+                       if test "$LD_RPATH_OPT" = "-R " ; then
+                               cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
+                       else
+                               cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
+                       fi
+
+                       # if we have not already added this, add it now
+                       cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
+                       if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
+                       then
+                               CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
+                               EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
+                       fi
+               fi
+               ;;
+       esac
+       cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
+done
+$1=$cf_rpath_dst
+
+CF_VERBOSE(...checked $1 [$]$1)
+AC_SUBST(EXTRA_LDFLAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
+dnl -----------
+dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
+dnl programs need this test).
+dnl
+dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
+dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
+dnl winsize declaration is left alone - we may revisit this if Apple choose to
+dnl break that part of the interface as well.
+AC_DEFUN([CF_SIGWINCH],
+[
+AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/signal.h>
+],[int x = SIGWINCH],
+       [cf_cv_define_sigwinch=yes],
+       [AC_TRY_COMPILE([
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+],[int x = SIGWINCH],
+       [cf_cv_define_sigwinch=maybe],
+       [cf_cv_define_sigwinch=no])
+])
+])
+
+if test "$cf_cv_define_sigwinch" = maybe ; then
+AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
+cf_cv_fixup_sigwinch=unknown
+cf_sigwinch=32
+while test $cf_sigwinch != 1
+do
+       AC_TRY_COMPILE([
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+],[
+#if SIGWINCH != $cf_sigwinch
+make an error
+#endif
+int x = SIGWINCH],
+       [cf_cv_fixup_sigwinch=$cf_sigwinch
+        break])
+
+cf_sigwinch=`expr $cf_sigwinch - 1`
+done
+])
+
+       if test "$cf_cv_fixup_sigwinch" != unknown ; then
+               CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
+       fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
+dnl ---------------
+dnl signal handler, but there are some gcc depedencies in that recommendation.
+dnl Try anyway.
+AC_DEFUN([CF_SIG_ATOMIC_T],
+[
+AC_MSG_CHECKING(for signal global datatype)
+AC_CACHE_VAL(cf_cv_sig_atomic_t,[
+       for cf_type in \
+               "volatile sig_atomic_t" \
+               "sig_atomic_t" \
+               "int"
+       do
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <signal.h>
+#include <stdio.h>
+
+extern $cf_type x;
+$cf_type x;
+static void handler(int sig)
+{
+       x = 5;
+}],
+               [signal(SIGINT, handler);
+                x = 1],
+               [cf_cv_sig_atomic_t=$cf_type],
+               [cf_cv_sig_atomic_t=no])
+               test "$cf_cv_sig_atomic_t" != no && break
+       done
+       ])
+AC_MSG_RESULT($cf_cv_sig_atomic_t)
+test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SIZE_T version: 4 updated: 2000/01/22 00:19:54
+dnl ---------
+dnl    On both Ultrix and CLIX, I find size_t defined in <stdio.h>
+AC_DEFUN([CF_SIZE_T],
+[
+AC_MSG_CHECKING(for size_t in <sys/types.h> or <stdio.h>)
+AC_CACHE_VAL(cf_cv_type_size_t,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <stdio.h>],
+               [size_t x],
+               [cf_cv_type_size_t=yes],
+               [cf_cv_type_size_t=no])
+       ])
+AC_MSG_RESULT($cf_cv_type_size_t)
+test $cf_cv_type_size_t = no && AC_DEFINE(size_t, unsigned)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_STRUCT_LASTLOG version: 1 updated: 2006/03/12 17:46:43
+dnl -----------------
+dnl Check for header defining struct lastlog, ensure that its .ll_time member
+dnl is compatible with time().
+AC_DEFUN([CF_STRUCT_LASTLOG],
+[
+AC_CHECK_HEADERS(lastlog.h)
+AC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <time.h>
+#include <lastlog.h>
+
+int main()
+{
+       struct lastlog data;
+       return (sizeof(data.ll_time) != sizeof(time_t));
+}],[
+cf_cv_struct_lastlog=yes],[
+cf_cv_struct_lastlog=no],[
+cf_cv_struct_lastlog=unknown])])
+
+test $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SVR4 version: 3 updated: 2000/05/31 10:16:52
+dnl -------
+dnl Check if this is an SVR4 system.  We need the definition for xterm
+AC_DEFUN([CF_SVR4],
+[
+AC_CHECK_LIB(elf, elf_begin,[
+AC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
+AC_TRY_COMPILE([
+#include <elf.h>
+#include <sys/termio.h>
+],[
+static struct termio d_tio;
+       d_tio.c_cc[VINTR] = 0;
+       d_tio.c_cc[VQUIT] = 0;
+       d_tio.c_cc[VERASE] = 0;
+       d_tio.c_cc[VKILL] = 0;
+       d_tio.c_cc[VEOF] = 0;
+       d_tio.c_cc[VEOL] = 0;
+       d_tio.c_cc[VMIN] = 0;
+       d_tio.c_cc[VTIME] = 0;
+       d_tio.c_cc[VLNEXT] = 0;
+],
+[cf_cv_svr4=yes],
+[cf_cv_svr4=no])
+])
+])
+test "$cf_cv_svr4" = yes && AC_DEFINE(SVR4)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SYSV version: 13 updated: 2006/08/20 14:55:37
+dnl -------
+dnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
+dnl defining it will be helpful.  The following features are used to check:
+dnl
+dnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
+dnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
+dnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
+dnl a compile-time error will result from trying to assign to a const array.
+dnl
+dnl b) compile with headers that exist on SYSV hosts.
+dnl
+dnl c) compile with type definitions that differ on SYSV hosts from standard C.
+AC_DEFUN([CF_SYSV],
+[
+AC_CHECK_HEADERS( \
+termios.h \
+stdlib.h \
+X11/Intrinsic.h \
+)
+
+AC_REQUIRE([CF_SYS_ERRLIST])
+
+AC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
+AC_TRY_COMPILE([
+#undef  SYSV
+#define SYSV 1                 /* get Xos.h to declare sys_errlist[] */
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>            /* look for wchar_t */
+#endif
+#ifdef HAVE_X11_INTRINSIC_H
+#include <X11/Intrinsic.h>     /* Intrinsic.h has other traps... */
+#endif
+#ifdef HAVE_TERMIOS_H          /* needed for HPUX 10.20 */ 
+#include <termios.h> 
+#define STRUCT_TERMIOS struct termios 
+#else 
+#define STRUCT_TERMIOS struct termio 
+#endif 
+#include <curses.h>
+#include <term.h>              /* eliminate most BSD hacks */
+#include <errno.h>             /* declare sys_errlist on older systems */
+#include <sys/termio.h>                /* eliminate most of the remaining ones */
+],[
+static STRUCT_TERMIOS d_tio;
+       d_tio.c_cc[VINTR] = 0;
+       d_tio.c_cc[VQUIT] = 0;
+       d_tio.c_cc[VERASE] = 0;
+       d_tio.c_cc[VKILL] = 0;
+       d_tio.c_cc[VEOF] = 0;
+       d_tio.c_cc[VEOL] = 0;
+       d_tio.c_cc[VMIN] = 0;
+       d_tio.c_cc[VTIME] = 0;
+#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
+sys_errlist[0] = "";           /* Cygwin mis-declares this */
+#endif
+],
+[cf_cv_sysv=yes],
+[cf_cv_sysv=no])
+])
+test "$cf_cv_sysv" = yes && AC_DEFINE(SYSV)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SYSV_UTMP version: 5 updated: 2001/12/27 12:55:07
+dnl ------------
+dnl Check if this is a SYSV flavor of UTMP
+AC_DEFUN([CF_SYSV_UTMP],
+[
+AC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
+test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
+AC_TRY_LINK([
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>],[
+struct $cf_cv_have_utmp x;
+       set${cf_prefix}ent ();
+       get${cf_prefix}id(&x);
+       put${cf_prefix}line(&x);
+       end${cf_prefix}ent();],
+       [cf_cv_sysv_utmp=yes],
+       [cf_cv_sysv_utmp=no])
+])
+test $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
+dnl --------------
+dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
+dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
+dnl declaration.  Reported by Keith Bostic.
+AC_DEFUN([CF_SYS_ERRLIST],
+[
+    CF_CHECK_ERRNO(sys_nerr)
+    CF_CHECK_ERRNO(sys_errlist)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_TERMIO_C_ISPEED version: 2 updated: 2000/05/29 16:16:04
+dnl ------------------
+dnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
+dnl (there doesn't appear to be a useful predefined symbol).
+AC_DEFUN([CF_TERMIO_C_ISPEED],
+[
+AC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/termio.h>],[
+struct termio foo;
+foo.c_ispeed = B38400;
+foo.c_ospeed = B9600;
+],[cf_cv_termio_c_ispeed=yes
+],[cf_cv_termio_c_ispeed=no])
+])
+test "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED)
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_TRY_PKG_CONFIG version: 4 updated: 2010/06/14 17:42:30
+dnl -----------------
+dnl This is a simple wrapper to use for pkg-config, for libraries which may be
+dnl available in that form.
+dnl
+dnl $1 = package name
+dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
+dnl $3 = logic to use if pkg-config does not have the package
+AC_DEFUN([CF_TRY_PKG_CONFIG],[
+AC_REQUIRE([CF_PKG_CONFIG])
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
+       CF_VERBOSE(found package $1)
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
+       CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
+       CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
+       CF_ADD_CFLAGS($cf_pkgconfig_incs)
+       CF_ADD_LIBS($cf_pkgconfig_libs)
+       ifelse([$2],,:,[$2])
+else
+       ifelse([$3],,:,[$3])
+fi
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_TTY_GROUP version: 7 updated: 2007/03/14 16:43:59
+dnl ------------
+dnl Check if the system has a tty-group defined.  This is used in xterm when
+dnl setting pty ownership.
+AC_DEFUN([CF_TTY_GROUP],
+[
+AC_MSG_CHECKING(for explicit tty group name)
+AC_ARG_WITH(tty-group,
+       [  --with-tty-group=XXX    use XXX for the tty-group],
+       [cf_tty_group=$withval],
+       [cf_tty_group=auto...])
+test -z "$cf_tty_group"    && cf_tty_group=auto...
+test "$cf_tty_group" = yes && cf_tty_group=auto...
+AC_MSG_RESULT($cf_tty_group)
+
+if test "$cf_tty_group" = "auto..." ; then
+AC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
+
+# If we are configuring as root, it is hard to get a clue about the tty group.
+# But we'll guess based on how our connection is set up - assuming it is done
+# properly.
+
+cf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
+# )vi
+if test "$cf_uid" != 0 ; then
+cf_cv_tty_group_name=
+cf_tty_name=`tty`
+test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
+test -z "$cf_tty_name" && cf_tty_name=/dev/tty
+if test -c "$cf_tty_name"
+then
+       cf_option="-l -L"
+
+       # Expect listing to have fields like this:
+       #-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
+       ls $cf_option $cf_tty_name >conftest.out
+       read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
+       if test -z "$cf_rest" ; then
+               cf_option="$cf_option -g"
+               ls $cf_option $cf_tty_name >conftest.out
+               read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
+       fi
+       rm -f conftest.out
+       cf_cv_tty_group_name=$cf_grp
+fi
+fi
+
+# If we cannot deduce the tty group, fall back on hardcoded cases
+
+if test -z "$cf_cv_tty_group_name"
+then
+case $host_os in #(vi
+osf*) #(vi
+       cf_cv_tty_group_name="terminal"
+       ;;
+*)
+       cf_cv_tty_group_name="unknown"
+       if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
+               cf_cv_tty_group_name="tty"
+       fi
+       ;;
+esac
+fi
+])
+cf_tty_group="$cf_cv_tty_group_name"
+else
+       # if configure option, always do this
+       AC_DEFINE(USE_TTY_GROUP)
+fi
+
+AC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group")
+
+# This is only a double-check that the group-name we obtained above really
+# does apply to the device.  We cannot perform this test if we are in batch
+# mode, or if we are cross-compiling.
+
+AC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
+cf_tty_name=`tty`
+if test "$cf_tty_name" != "not a tty"
+then
+AC_TRY_RUN([
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <grp.h>
+int main()
+{
+       struct stat sb;
+       struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
+       char *name = ttyname(0);
+
+       endgrent();
+       if (ttygrp != 0
+        && name != 0
+        && stat(name, &sb) == 0
+        && sb.st_gid != getgid()
+        && sb.st_gid == ttygrp->gr_gid) {
+               ${cf_cv_main_return:-return} (0);
+       }
+       ${cf_cv_main_return:-return} (1);
+}
+       ],
+       [cf_cv_tty_group=yes],
+       [cf_cv_tty_group=no],
+       [cf_cv_tty_group=unknown])
+elif test "$cross_compiling" = yes; then
+       cf_cv_tty_group=unknown
+else
+       cf_cv_tty_group=yes
+fi
+])
+
+if test $cf_cv_tty_group = no ; then
+       AC_MSG_WARN(Cannot use $cf_tty_group group)
+else
+       AC_DEFINE(USE_TTY_GROUP)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_TYPE_FD_MASK version: 2 updated: 2008/03/25 20:59:57
+dnl ---------------
+dnl Check for the declaration of fd_mask, which is like fd_set, associated
+dnl with select().  The check for fd_set should have pulled in this as well,
+dnl but there is a special case for Mac OS X, possibly other BSD-derived
+dnl platforms.
+AC_DEFUN([CF_TYPE_FD_MASK],
+[
+AC_REQUIRE([CF_TYPE_FD_SET])
+
+AC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
+    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
+        AC_TRY_COMPILE([
+#include <X11/Xpoll.h>],[fd_mask x],,
+        [CF_MSG_LOG(if we must define CSRG_BASED)
+# Xosdefs.h on Mac OS X may not define this (but it should).
+            AC_TRY_COMPILE([
+#define CSRG_BASED
+#include <X11/Xpoll.h>],[fd_mask x],
+        cf_cv_type_fd_mask=CSRG_BASED)])
+    else
+        cf_cv_type_fd_mask=$cf_cv_type_fd_set
+    fi
+])
+if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
+    AC_DEFINE(CSRG_BASED)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_TYPE_FD_SET version: 4 updated: 2008/03/25 20:56:03
+dnl --------------
+dnl Check for the declaration of fd_set.  Some platforms declare it in
+dnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
+dnl Finally, if we are using this for an X application, Xpoll.h may include
+dnl <sys/select.h>, so we don't want to do it twice.
+AC_DEFUN([CF_TYPE_FD_SET],
+[
+AC_CHECK_HEADERS(X11/Xpoll.h)
+
+AC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
+       [CF_MSG_LOG(sys/types alone)
+AC_TRY_COMPILE([
+#include <sys/types.h>],
+       [fd_set x],
+       [cf_cv_type_fd_set=sys/types.h],
+       [CF_MSG_LOG(X11/Xpoll.h)
+AC_TRY_COMPILE([
+#ifdef HAVE_X11_XPOLL_H
+#include <X11/Xpoll.h>
+#endif],
+       [fd_set x],
+       [cf_cv_type_fd_set=X11/Xpoll.h],
+       [CF_MSG_LOG(sys/select.h)
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/select.h>],
+       [fd_set x],
+       [cf_cv_type_fd_set=sys/select.h],
+       [cf_cv_type_fd_set=unknown])])])])
+if test $cf_cv_type_fd_set = sys/select.h ; then
+       AC_DEFINE(USE_SYS_SELECT_H)
+fi
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
+dnl --------
+dnl Make an uppercase version of a variable
+dnl $1=uppercase($2)
+AC_DEFUN([CF_UPPER],
+[
+$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTEMPTER version: 3 updated: 2010/06/02 05:03:05
+dnl -----------
+dnl Try to link with utempter library
+AC_DEFUN([CF_UTEMPTER],
+[
+AC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
+cf_save_LIBS="$LIBS"
+CF_ADD_LIB(utempter)
+AC_TRY_LINK([
+#include <utempter.h>
+],[
+       addToUtmp("/dev/tty", 0, 1);
+       removeFromUtmp();
+],[
+       cf_cv_have_utempter=yes],[
+       cf_cv_have_utempter=no])
+LIBS="$cf_save_LIBS"
+])
+if test "$cf_cv_have_utempter" = yes ; then
+       AC_DEFINE(USE_UTEMPTER)
+       CF_ADD_LIB(utempter)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP version: 9 updated: 2008/01/25 17:18:00
+dnl -------
+dnl Check for UTMP/UTMPX headers
+AC_DEFUN([CF_UTMP],
+[
+AC_REQUIRE([CF_LASTLOG])
+
+AC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
+       cf_cv_have_utmp=no
+for cf_header in utmpx utmp ; do
+cf_utmp_includes="
+#include <sys/types.h>
+#include <${cf_header}.h>
+#define getutent getutxent
+#ifdef USE_LASTLOG
+#include <lastlog.h>   /* may conflict with utmpx.h on Linux */
+#endif
+"
+       AC_TRY_COMPILE([$cf_utmp_includes],
+       [struct $cf_header x;
+        char *name = x.ut_name; /* utmp.h and compatible definitions */
+       ],
+       [cf_cv_have_utmp=$cf_header
+        break],
+       [
+       AC_TRY_COMPILE([$cf_utmp_includes],
+       [struct $cf_header x;
+        char *name = x.ut_user; /* utmpx.h must declare this */
+       ],
+       [cf_cv_have_utmp=$cf_header
+        break
+       ])])
+done
+])
+
+if test $cf_cv_have_utmp != no ; then
+       AC_DEFINE(HAVE_UTMP)
+       test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP)
+       CF_UTMP_UT_HOST
+       CF_UTMP_UT_SYSLEN
+       CF_UTMP_UT_NAME
+       CF_UTMP_UT_XSTATUS
+       CF_UTMP_UT_XTIME
+       CF_UTMP_UT_SESSION
+       CF_SYSV_UTMP
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
+dnl -------------
+dnl Find the utmp/utmpx file and determine its group to allow setgid programs
+dnl to manipulate it, e.g., when there is no intermediary.
+AC_DEFUN([CF_UTMP_GROUP],[
+AC_REQUIRE([CF_UTMP])
+if test $cf_cv_have_utmp != no ; then
+AC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
+for cf_utmp_path in /var/adm /var/run
+do
+       for cf_utmp_file in utmpx utmp
+       do
+               if test -f $cf_utmp_path/$cf_utmp_file
+               then
+                       cf_cv_utmp_group=root
+
+                       cf_option="-l -L"
+
+                       # Expect listing to have fields like this:
+                       #-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
+                       ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
+                       read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
+                       if test -z "$cf_rest" ; then
+                               cf_option="$cf_option -g"
+                               ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
+                               read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
+                       fi
+                       rm -f conftest
+
+                       # If we have a pathname, and the date fields look right, assume we've
+                       # captured the group as well.
+                       if test -n "$cf_rest" ; then
+                               cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
+                               if test -z "$cf_test" ; then
+                                       cf_cv_utmp_group=$cf_grp;
+                               fi
+                       fi
+                       break
+               fi
+       done
+       test -n "$cf_cv_utmp_group" && break
+done
+])
+else
+       AC_MSG_ERROR(cannot find utmp group)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP_UT_HOST version: 7 updated: 2007/03/13 19:17:11
+dnl ---------------
+dnl Check if UTMP/UTMPX struct defines ut_host member
+AC_DEFUN([CF_UTMP_UT_HOST],
+[
+if test $cf_cv_have_utmp != no ; then
+AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
+AC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>],
+       [struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
+       [cf_cv_have_utmp_ut_host=yes],
+       [cf_cv_have_utmp_ut_host=no])
+       ])
+AC_MSG_RESULT($cf_cv_have_utmp_ut_host)
+test $cf_cv_have_utmp_ut_host != no && AC_DEFINE(HAVE_UTMP_UT_HOST)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP_UT_NAME version: 4 updated: 2007/03/13 19:17:11
+dnl ---------------
+dnl Check if UTMP/UTMPX struct defines ut_name member
+AC_DEFUN([CF_UTMP_UT_NAME],
+[
+if test $cf_cv_have_utmp != no ; then
+AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
+       cf_cv_have_utmp_ut_name=no
+cf_utmp_includes="
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+#define getutent getutxent
+#ifdef USE_LASTLOG
+#include <lastlog.h>           /* may conflict with utmpx.h on Linux */
+#endif
+"
+for cf_header in ut_name ut_user ; do
+       AC_TRY_COMPILE([$cf_utmp_includes],
+       [struct $cf_cv_have_utmp x;
+        char *name = x.$cf_header;
+       ],
+       [cf_cv_have_utmp_ut_name=$cf_header
+        break])
+done
+])
+
+case $cf_cv_have_utmp_ut_name in #(vi
+no) #(vi
+       AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
+       ;;
+ut_user)
+       AC_DEFINE(ut_name,ut_user)
+       ;;
+esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP_UT_SESSION version: 5 updated: 2007/03/13 19:17:11
+dnl ------------------
+dnl Check if UTMP/UTMPX struct defines ut_session member
+AC_DEFUN([CF_UTMP_UT_SESSION],
+[
+if test $cf_cv_have_utmp != no ; then
+AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>],
+       [struct $cf_cv_have_utmp x; long y = x.ut_session],
+       [cf_cv_have_utmp_ut_session=yes],
+       [cf_cv_have_utmp_ut_session=no])
+])
+if test $cf_cv_have_utmp_ut_session != no ; then
+       AC_DEFINE(HAVE_UTMP_UT_SESSION)
+fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP_UT_SYSLEN version: 1 updated: 2008/01/25 17:18:00
+dnl -----------------
+dnl Check if UTMP/UTMPX struct defines ut_syslen member
+AC_DEFUN([CF_UTMP_UT_SYSLEN],
+[
+if test $cf_cv_have_utmp != no ; then
+AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
+AC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>],
+       [struct $cf_cv_have_utmp x; int y = x.ut_syslen],
+       [cf_cv_have_utmp_ut_syslen=yes],
+       [cf_cv_have_utmp_ut_syslen=no])
+       ])
+AC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
+test $cf_cv_have_utmp_ut_syslen != no && AC_DEFINE(HAVE_UTMP_UT_SYSLEN)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP_UT_XSTATUS version: 3 updated: 2001/12/27 12:55:07
+dnl ------------------
+dnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
+dnl by various people:
+dnl
+dnl    ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
+dnl    ut_exit.e_exit (SVR4)
+dnl    ut_exit.ut_e_exit (os390 - Greg Smith)
+dnl    ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
+dnl
+dnl Note: utmp_xstatus is not a conventional compatibility definition in the
+dnl system header files.
+AC_DEFUN([CF_UTMP_UT_XSTATUS],
+[
+if test $cf_cv_have_utmp != no ; then
+AC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
+for cf_result in \
+       ut_exit.__e_exit \
+       ut_exit.e_exit \
+       ut_exit.ut_e_exit \
+       ut_exit.ut_exit
+do
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>],
+       [struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
+       [cf_cv_have_utmp_ut_xstatus=$cf_result
+        break],
+       [cf_cv_have_utmp_ut_xstatus=no])
+done
+])
+if test $cf_cv_have_utmp_ut_xstatus != no ; then
+       AC_DEFINE(HAVE_UTMP_UT_XSTATUS)
+       AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus)
+fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_UTMP_UT_XTIME version: 7 updated: 2007/03/13 19:17:11
+dnl ----------------
+dnl Check if UTMP/UTMPX struct defines ut_xtime member
+AC_DEFUN([CF_UTMP_UT_XTIME],
+[
+if test $cf_cv_have_utmp != no ; then
+AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
+       AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>],
+       [struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
+       [cf_cv_have_utmp_ut_xtime=yes],
+       [AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>],
+       [struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
+       [cf_cv_have_utmp_ut_xtime=define],
+       [cf_cv_have_utmp_ut_xtime=no])
+       ])
+])
+if test $cf_cv_have_utmp_ut_xtime != no ; then
+       AC_DEFINE(HAVE_UTMP_UT_XTIME)
+       if test $cf_cv_have_utmp_ut_xtime = define ; then
+               AC_DEFINE(ut_xtime,ut_tv.tv_sec)
+       fi
+fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
+dnl ----------
+dnl Use AC_VERBOSE w/o the warnings
+AC_DEFUN([CF_VERBOSE],
+[test -n "$verbose" && echo "  $1" 1>&AC_FD_MSG
+CF_MSG_LOG([$1])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_IMAKE_CFLAGS version: 9 updated: 2010/05/26 05:38:42
+dnl --------------------
+dnl xterm and similar programs build more readily when propped up with imake's
+dnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
+dnl most common definitions that we're not likely to do by autoconf tests.
+AC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
+AC_REQUIRE([CF_ENABLE_NARROWPROTO])
+
+AC_MSG_CHECKING(if we should use imake to help)
+CF_ARG_DISABLE(imake,
+       [  --disable-imake         disable use of imake for definitions],
+       [enable_imake=no],
+       [enable_imake=yes])
+AC_MSG_RESULT($enable_imake)
+
+if test "$enable_imake" = yes ; then
+       CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
+fi
+
+if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
+       CF_ADD_CFLAGS($IMAKE_CFLAGS)
+else
+       IMAKE_CFLAGS=
+       IMAKE_LOADFLAGS=
+       CF_VERBOSE(make fallback definitions)
+
+       # We prefer config.guess' values when we can get them, to avoid
+       # inconsistent results with uname (AIX for instance).  However,
+       # config.guess is not always consistent either.
+       case $host_os in
+       *[[0-9]].[[0-9]]*)
+               UNAME_RELEASE="$host_os"
+               ;;
+       *)
+               UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+               ;;
+       esac
+
+       case .$UNAME_RELEASE in
+       *[[0-9]].[[0-9]]*)
+               OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
+               OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
+               test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
+               test -z "$OSMINORVERSION" && OSMINORVERSION=0
+               IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
+               ;;
+       esac
+
+       # FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
+       # fallback/fragments for NeedPrototypes, etc.
+       IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
+
+       # If this is not set properly, Xaw's scrollbars will not work
+       if test "$enable_narrowproto" = yes ; then
+               IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
+       fi
+
+       # Other special definitions:
+       case $host_os in
+       aix*)
+               # imake on AIX 5.1 defines AIXV3.  really.
+               IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
+               ;;
+       irix[[56]].*) #(vi
+               # these are needed to make SIGWINCH work in xterm
+               IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
+               ;;
+       esac
+
+       CF_ADD_CFLAGS($IMAKE_CFLAGS)
+
+       AC_SUBST(IMAKE_CFLAGS)
+       AC_SUBST(IMAKE_LOADFLAGS)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_PATH version: 10 updated: 2010/10/23 15:44:18
+dnl ------------
+dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
+dnl defaulting to yes/no.
+dnl
+dnl $1 = option name
+dnl $2 = help-text
+dnl $3 = environment variable to set
+dnl $4 = default value, shown in the help-message, must be a constant
+dnl $5 = default value, if it's an expression & cannot be in the help-message
+dnl
+AC_DEFUN([CF_WITH_PATH],
+[AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
+ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
+if ifelse([$5],,true,[test -n "$5"]) ; then
+CF_PATH_SYNTAX(withval)
+fi
+$3="$withval"
+AC_SUBST($3)dnl
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_WITH_PCRE version: 8 updated: 2010/06/05 11:30:21
+dnl ------------
+dnl Add PCRE (Perl-compatible regular expressions) to the build if it is
+dnl available and the user requests it.  Assume the application will otherwise
+dnl use the POSIX interface.
+dnl
+dnl TODO allow $withval to specify package location
+AC_DEFUN([CF_WITH_PCRE],
+[
+AC_REQUIRE([CF_PKG_CONFIG])
+
+AC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
+AC_ARG_WITH(pcre,
+       [  --with-pcre             use PCRE for regular-expressions])
+test -z "$with_pcre" && with_pcre=no
+AC_MSG_RESULT($with_pcre)
+
+if test "$with_pcre" != no ; then
+       CF_TRY_PKG_CONFIG(libpcre,,[
+               AC_CHECK_LIB(pcre,pcre_compile,,
+                       AC_MSG_ERROR(Cannot find PCRE library))])
+
+               AC_DEFINE(HAVE_LIB_PCRE)
+
+               case $LIBS in #(vi
+               *pcreposix*) #(vi
+                       ;;
+               *)
+                       AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
+                               [AC_DEFINE(HAVE_PCREPOSIX_H)
+                                CF_ADD_LIB(pcreposix)],
+                               [AC_CHECK_LIB(pcreposix,regcomp,[
+                                       AC_DEFINE(HAVE_PCREPOSIX_H)
+                                       CF_ADD_LIB(pcreposix)],
+                                       AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
+                       ;;
+               esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_XKB_BELL_EXT version: 3 updated: 2009/02/13 16:00:39
+dnl ---------------
+dnl Check for XKB bell extension
+AC_DEFUN([CF_XKB_BELL_EXT],[
+AC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
+AC_TRY_LINK([
+#include <X11/Intrinsic.h>
+#include <X11/XKBlib.h>                /* has the prototype */
+#include <X11/extensions/XKBbells.h>   /* has the XkbBI_xxx definitions */
+],[
+       int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
+       Atom y;
+       XkbBell((Display *)0, (Widget)0, 0, y);
+],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
+])
+test "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT)
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_XOPEN_SOURCE version: 34 updated: 2010/05/26 05:38:42
+dnl ---------------
+dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
+dnl or adapt to the vendor's definitions to get equivalent functionality,
+dnl without losing the common non-POSIX features.
+dnl
+dnl Parameters:
+dnl    $1 is the nominal value for _XOPEN_SOURCE
+dnl    $2 is the nominal value for _POSIX_C_SOURCE
+AC_DEFUN([CF_XOPEN_SOURCE],[
+
+cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
+cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
+cf_xopen_source=
+
+case $host_os in #(vi
+aix[[456]]*) #(vi
+       cf_xopen_source="-D_ALL_SOURCE"
+       ;;
+darwin[[0-8]].*) #(vi
+       cf_xopen_source="-D_APPLE_C_SOURCE"
+       ;;
+darwin*) #(vi
+       cf_xopen_source="-D_DARWIN_C_SOURCE"
+       ;;
+freebsd*|dragonfly*) #(vi
+       # 5.x headers associate
+       #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+       #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+       cf_POSIX_C_SOURCE=200112L
+       cf_XOPEN_SOURCE=600
+       cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+       ;;
+hpux11*) #(vi
+       cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
+       ;;
+hpux*) #(vi
+       cf_xopen_source="-D_HPUX_SOURCE"
+       ;;
+irix[[56]].*) #(vi
+       cf_xopen_source="-D_SGI_SOURCE"
+       ;;
+linux*|gnu*|mint*|k*bsd*-gnu) #(vi
+       CF_GNU_SOURCE
+       ;;
+mirbsd*) #(vi
+       # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+       ;;
+netbsd*) #(vi
+       # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+       ;;
+openbsd*) #(vi
+       # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+       ;;
+osf[[45]]*) #(vi
+       cf_xopen_source="-D_OSF_SOURCE"
+       ;;
+nto-qnx*) #(vi
+       cf_xopen_source="-D_QNX_SOURCE"
+       ;;
+sco*) #(vi
+       # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+       ;;
+solaris2.1[[0-9]]) #(vi
+       cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+       ;;
+solaris2.[[1-9]]) #(vi
+       cf_xopen_source="-D__EXTENSIONS__"
+       ;;
+*)
+       AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
+       AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _XOPEN_SOURCE
+make an error
+#endif],
+       [cf_cv_xopen_source=no],
+       [cf_save="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+        AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _XOPEN_SOURCE
+make an error
+#endif],
+       [cf_cv_xopen_source=no],
+       [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
+       CPPFLAGS="$cf_save"
+       ])
+])
+       if test "$cf_cv_xopen_source" != no ; then
+               CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
+               CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
+               cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+               CF_ADD_CFLAGS($cf_temp_xopen_source)
+       fi
+       CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
+       ;;
+esac
+
+if test -n "$cf_xopen_source" ; then
+       CF_ADD_CFLAGS($cf_xopen_source)
+fi
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_X_ATHENA version: 20 updated: 2010/11/09 05:18:02
+dnl -----------
+dnl Check for Xaw (Athena) libraries
+dnl
+dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
+AC_DEFUN([CF_X_ATHENA],
+[
+cf_x_athena=${cf_x_athena:-Xaw}
+
+AC_MSG_CHECKING(if you want to link with Xaw 3d library)
+withval=
+AC_ARG_WITH(Xaw3d,
+       [  --with-Xaw3d            link with Xaw 3d library])
+if test "$withval" = yes ; then
+       cf_x_athena=Xaw3d
+       AC_MSG_RESULT(yes)
+else
+       AC_MSG_RESULT(no)
+fi
+
+AC_MSG_CHECKING(if you want to link with neXT Athena library)
+withval=
+AC_ARG_WITH(neXtaw,
+       [  --with-neXtaw           link with neXT Athena library])
+if test "$withval" = yes ; then
+       cf_x_athena=neXtaw
+       AC_MSG_RESULT(yes)
+else
+       AC_MSG_RESULT(no)
+fi
+
+AC_MSG_CHECKING(if you want to link with Athena-Plus library)
+withval=
+AC_ARG_WITH(XawPlus,
+       [  --with-XawPlus          link with Athena-Plus library])
+if test "$withval" = yes ; then
+       cf_x_athena=XawPlus
+       AC_MSG_RESULT(yes)
+else
+       AC_MSG_RESULT(no)
+fi
+
+cf_x_athena_lib=""
+
+if test "$PKG_CONFIG" != none ; then
+       cf_athena_list=
+       test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
+       for cf_athena_pkg in \
+               $cf_athena_list \
+               ${cf_x_athena} \
+               ${cf_x_athena}-devel \
+               lib${cf_x_athena} \
+               lib${cf_x_athena}-devel
+       do
+               CF_TRY_PKG_CONFIG($cf_athena_pkg,[
+                       cf_x_athena_lib="$cf_pkgconfig_libs"
+                       CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
+                       AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
+
+AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
+AC_TRY_LINK([
+#include <X11/Xmu/CharSet.h>
+],[
+int check = XmuCompareISOLatin1("big", "small")
+],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
+
+                       if test "$cf_cv_xaw_compat" = no
+                       then
+                               # workaround for broken ".pc" files...
+                               case "$cf_x_athena_lib" in #(vi
+                               *-lXmu*) #(vi
+                                       ;;
+                               *)
+                                       CF_VERBOSE(work around broken package)
+                                       CF_TRY_PKG_CONFIG(xmu,,[CF_ADD_LIB_AFTER(-lXt,-lXmu)])
+                                       ;;
+                               esac
+                       fi
+
+                       break])
+       done
+fi
+
+if test -z "$cf_x_athena_lib" ; then
+       CF_X_EXT
+       CF_X_TOOLKIT
+       CF_X_ATHENA_CPPFLAGS($cf_x_athena)
+       CF_X_ATHENA_LIBS($cf_x_athena)
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
+dnl --------------------
+dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
+dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
+AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
+[
+cf_x_athena_root=ifelse([$1],,Xaw,[$1])
+cf_x_athena_inc=""
+
+for cf_path in default \
+       /usr/contrib/X11R6 \
+       /usr/contrib/X11R5 \
+       /usr/lib/X11R5 \
+       /usr/local
+do
+       if test -z "$cf_x_athena_inc" ; then
+               cf_save="$CPPFLAGS"
+               cf_test=X11/$cf_x_athena_root/SimpleMenu.h
+               if test $cf_path != default ; then
+                       CPPFLAGS="$cf_save -I$cf_path/include"
+                       AC_MSG_CHECKING(for $cf_test in $cf_path)
+               else
+                       AC_MSG_CHECKING(for $cf_test)
+               fi
+               AC_TRY_COMPILE([
+#include <X11/Intrinsic.h>
+#include <$cf_test>],[],
+                       [cf_result=yes],
+                       [cf_result=no])
+               AC_MSG_RESULT($cf_result)
+               if test "$cf_result" = yes ; then
+                       cf_x_athena_inc=$cf_path
+                       break
+               else
+                       CPPFLAGS="$cf_save"
+               fi
+       fi
+done
+
+if test -z "$cf_x_athena_inc" ; then
+       AC_MSG_WARN(
+[Unable to successfully find Athena header files with test program])
+elif test "$cf_x_athena_inc" != default ; then
+       CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
+fi
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_X_ATHENA_LIBS version: 9 updated: 2010/06/02 05:03:05
+dnl ----------------
+dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
+dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
+AC_DEFUN([CF_X_ATHENA_LIBS],
+[AC_REQUIRE([CF_X_TOOLKIT])
+cf_x_athena_root=ifelse([$1],,Xaw,[$1])
+cf_x_athena_lib=""
+
+for cf_path in default \
+       /usr/contrib/X11R6 \
+       /usr/contrib/X11R5 \
+       /usr/lib/X11R5 \
+       /usr/local
+do
+       for cf_lib in \
+               "-l$cf_x_athena_root -lXmu" \
+               "-l$cf_x_athena_root -lXpm -lXmu" \
+               "-l${cf_x_athena_root}_s -lXmu_s"
+       do
+               if test -z "$cf_x_athena_lib" ; then
+                       cf_save="$LIBS"
+                       cf_test=XawSimpleMenuAddGlobalActions
+                       if test $cf_path != default ; then
+                               CF_ADD_LIBS(-L$cf_path/lib $cf_lib)
+                               AC_MSG_CHECKING(for $cf_lib in $cf_path)
+                       else
+                               CF_ADD_LIBS($cf_lib)
+                               AC_MSG_CHECKING(for $cf_test in $cf_lib)
+                       fi
+                       AC_TRY_LINK([],[$cf_test()],
+                               [cf_result=yes],
+                               [cf_result=no])
+                       AC_MSG_RESULT($cf_result)
+                       if test "$cf_result" = yes ; then
+                               cf_x_athena_lib="$cf_lib"
+                               break
+                       fi
+                       LIBS="$cf_save"
+               fi
+       done
+done
+
+if test -z "$cf_x_athena_lib" ; then
+       AC_MSG_ERROR(
+[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
+fi
+
+CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
+AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
+dnl --------
+AC_DEFUN([CF_X_EXT],[
+CF_TRY_PKG_CONFIG(Xext,,[
+       AC_CHECK_LIB(Xext,XextCreateExtension,
+               [CF_ADD_LIB(Xext)])])
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_X_FONTCONFIG version: 3 updated: 2010/11/09 05:18:02
+dnl ---------------
+dnl Check for fontconfig library, a dependency of the X FreeType library.
+AC_DEFUN([CF_X_FONTCONFIG],
+[
+AC_REQUIRE([CF_X_FREETYPE])
+
+AC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
+AC_TRY_LINK([
+#include <X11/Xft/Xft.h>
+],[
+       XftPattern *pat;
+       XftPatternBuild(pat,
+                                       XFT_FAMILY, XftTypeString, "mono",
+                                       (void *) 0);
+],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
+])
+
+if test "$cf_cv_xft_compat" = no
+then
+       # workaround for broken ".pc" files used for Xft.
+       case "$cf_cv_x_freetype_libs" in #(vi
+       *-lfontconfig*) #(vi
+               ;;
+       *)
+               CF_VERBOSE(work around broken package)
+               CF_TRY_PKG_CONFIG(fontconfig,,[CF_ADD_LIB_AFTER(-lXft,-lfontconfig)])
+               ;;
+       esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_X_FREETYPE version: 23 updated: 2010/11/08 20:19:21
+dnl -------------
+dnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
+dnl
+dnl First check for the appropriate config program, since the developers for
+dnl these libraries change their configuration (and config program) more or
+dnl less randomly.  If we cannot find the config program, do not bother trying
+dnl to guess the latest variation of include/lib directories.
+dnl
+dnl If either or both of these configure-script options are not given, rely on
+dnl the output of the config program to provide the cflags/libs options:
+dnl    --with-freetype-cflags
+dnl    --with-freetype-libs
+AC_DEFUN([CF_X_FREETYPE],
+[
+AC_REQUIRE([CF_PKG_CONFIG])
+
+cf_extra_freetype_libs=
+FREETYPE_CONFIG=none
+FREETYPE_PARAMS=
+
+AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
+AC_ARG_WITH(freetype-cflags,
+       [  --with-freetype-cflags  -D/-I options for compiling with FreeType],
+       [cf_cv_x_freetype_incs="$with_freetype_cflags"],
+       [cf_cv_x_freetype_incs=no])
+AC_MSG_RESULT($cf_cv_x_freetype_incs)
+
+
+AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
+AC_ARG_WITH(freetype-libs,
+       [  --with-freetype-libs    -L/-l options to link FreeType],
+       [cf_cv_x_freetype_libs="$with_freetype_libs"],
+       [cf_cv_x_freetype_libs=no])
+AC_MSG_RESULT($cf_cv_x_freetype_libs)
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
+       FREETYPE_CONFIG=$PKG_CONFIG
+       FREETYPE_PARAMS=xft
+else
+       AC_PATH_PROG(FREETYPE_XFT_CONFIG, xft-config, none)
+       if test "$FREETYPE_XFT_CONFIG" != none; then
+               FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
+       else
+               cf_extra_freetype_libs="-lXft"
+               AC_PATH_PROG(FREETYPE_OLD_CONFIG, freetype-config, none)
+               if test "$FREETYPE_OLD_CONFIG" != none; then
+                       FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
+               fi
+       fi
+fi
+AC_MSG_CHECKING(for FreeType config)
+AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
+
+if test "$FREETYPE_CONFIG" != none ; then
+
+       if test "$cf_cv_x_freetype_incs" = no ; then
+               AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
+               cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
+               AC_MSG_RESULT($cf_cv_x_freetype_incs)
+       fi
+
+       if test "$cf_cv_x_freetype_libs" = no ; then
+               AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
+               cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
+               AC_MSG_RESULT($cf_cv_x_freetype_libs)
+       fi
+
+fi
+
+if test "$cf_cv_x_freetype_incs" = no ; then
+       cf_cv_x_freetype_incs=
+fi
+
+if test "$cf_cv_x_freetype_libs" = no ; then
+       cf_cv_x_freetype_libs=-lXft
+fi
+
+AC_MSG_CHECKING(if we can link with FreeType libraries)
+
+cf_save_LIBS="$LIBS"
+cf_save_INCS="$CPPFLAGS"
+
+CF_ADD_LIBS($cf_cv_x_freetype_libs)
+CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
+
+AC_TRY_LINK([
+#include <X11/Xlib.h>
+#include <X11/extensions/Xrender.h>
+#include <X11/Xft/Xft.h>],[
+       XftPattern  *pat = XftNameParse ("name");],
+       [cf_cv_found_freetype=yes],
+       [cf_cv_found_freetype=no])
+AC_MSG_RESULT($cf_cv_found_freetype)
+
+LIBS="$cf_save_LIBS"
+CPPFLAGS="$cf_save_INCS"
+
+if test "$cf_cv_found_freetype" = yes ; then
+       CF_ADD_LIBS($cf_cv_x_freetype_libs)
+       CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
+       AC_DEFINE(XRENDERFONT)
+
+AC_CHECK_FUNCS( \
+       XftDrawCharSpec \
+       XftDrawSetClip \
+       XftDrawSetClipRectangles \
+)
+
+else
+       AC_MSG_WARN(No libraries found for FreeType)
+       CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
+fi
+
+# FIXME: revisit this if needed
+AC_SUBST(HAVE_TYPE_FCCHAR32)
+AC_SUBST(HAVE_TYPE_XFTCHARSPEC)
+])
+dnl ---------------------------------------------------------------------------
+dnl CF_X_TOOLKIT version: 20 updated: 2010/11/19 05:43:04
+dnl ------------
+dnl Check for X Toolkit libraries
+dnl
+AC_DEFUN([CF_X_TOOLKIT],
+[
+AC_REQUIRE([AC_PATH_XTRA])
+AC_REQUIRE([CF_CHECK_CACHE])
+
+cf_have_X_LIBS=no
+
+CF_TRY_PKG_CONFIG(xt,[
+
+       case "x$LIBS" in #(vi
+       *-lX11*) #(vi
+               ;;
+       *)
+# we have an "xt" package, but it may omit Xt's dependency on X11
+AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
+AC_TRY_LINK([
+#include <X11/Xlib.h>
+],[
+       int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
+       int rc2 = XClearWindow((Display*) 0, (Window) 0);
+       int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
+       int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
+],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
+               if test "$cf_cv_xt_x11_compat" = no
+               then
+                       CF_VERBOSE(work around broken X11 dependency)
+                       # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
+                       CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
+               fi
+               ;;
+       esac
+
+AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
+AC_TRY_LINK([
+#include <X11/Shell.h>
+],[int num = IceConnectionNumber(0)
+],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
+
+       if test "$cf_cv_xt_ice_compat" = no
+       then
+               # workaround for broken ".pc" files used for X Toolkit.
+               case "x$X_PRE_LIBS" in #(vi
+               *-lICE*)
+                       case "x$LIBS" in #(vi
+                       *-lICE*) #(vi
+                               ;;
+                       *)
+                               CF_VERBOSE(work around broken ICE dependency)
+                               CF_TRY_PKG_CONFIG(ice,
+                                       [CF_TRY_PKG_CONFIG(sm)],
+                                       [CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
+                               ;;
+                       esac
+                       ;;
+               esac
+       fi
+
+       cf_have_X_LIBS=yes
+],[
+
+       LDFLAGS="$X_LIBS $LDFLAGS"
+       CF_CHECK_CFLAGS($X_CFLAGS)
+
+       AC_CHECK_FUNC(XOpenDisplay,,[
+       AC_CHECK_LIB(X11,XOpenDisplay,
+               [CF_ADD_LIB(X11)],,
+               [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
+
+       AC_CHECK_FUNC(XtAppInitialize,,[
+       AC_CHECK_LIB(Xt, XtAppInitialize,
+               [AC_DEFINE(HAVE_LIBXT)
+                cf_have_X_LIBS=Xt
+                LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
+               [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
+])
+
+if test $cf_have_X_LIBS = no ; then
+       AC_MSG_WARN(
+[Unable to successfully link X Toolkit library (-lXt) with
+test program.  You will have to check and add the proper libraries by hand
+to makefile.])
+fi
+])dnl
diff --git a/button.c b/button.c
new file mode 100644 (file)
index 0000000..b0c3c95
--- /dev/null
+++ b/button.c
@@ -0,0 +1,4210 @@
+/* $XTermId: button.c,v 1.395 2011/02/09 10:15:46 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+button.c       Handles button events in the terminal emulator.
+               does cut/paste operations, change modes via menu,
+               passes button events through to some applications.
+                               J. Gettys.
+*/
+
+#include <xterm.h>
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <X11/Xatom.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/StdSel.h>
+
+#include <xutf8.h>
+#include <fontutils.h>
+
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <xcharmouse.h>
+#include <charclass.h>
+#include <xstrings.h>
+
+#if OPT_SELECT_REGEX
+#ifdef HAVE_PCREPOSIX_H
+#include <pcreposix.h>
+#else /* POSIX regex.h */
+#include <sys/types.h>
+#include <regex.h>
+#endif
+#endif
+
+#if OPT_WIDE_CHARS
+#include <ctype.h>
+#include <wcwidth.h>
+#else
+#define CharacterClass(value) \
+       charClass[value & ((sizeof(charClass)/sizeof(charClass[0]))-1)]
+#endif
+
+    /*
+     * We'll generally map rows to indices when doing selection.
+     * Simplify that with a macro.
+     *
+     * Note that ROW2INX() is safe to use with auto increment/decrement for
+     * the row expression since that is evaluated once.
+     */
+#define GET_LINEDATA(screen, row) \
+       getLineData(screen, ROW2INX(screen, row))
+
+    /*
+     * We reserve shift modifier for cut/paste operations.  In principle we
+     * can pass through control and meta modifiers, but in practice, the
+     * popup menu uses control, and the window manager is likely to use meta,
+     * so those events are not delivered to SendMousePosition.
+     */
+#define OurModifiers (ShiftMask | ControlMask | Mod1Mask)
+#define AllModifiers (ShiftMask | LockMask | ControlMask | Mod1Mask | \
+                     Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
+
+#define BtnModifiers(event) (event->state & OurModifiers)
+#define KeyModifiers(event) (event->xbutton.state & OurModifiers)
+
+#define IsBtnEvent(event) ((event)->type == ButtonPress || (event)->type == ButtonRelease)
+
+#define KeyState(x) (((int) ((x) & (ShiftMask|ControlMask))) \
+                         + (((x) & Mod1Mask) ? 2 : 0))
+    /* adds together the bits:
+       shift key -> 1
+       meta key  -> 2
+       control key -> 4 */
+
+#define        Coordinate(s,c) ((c)->row * MaxCols(s) + (c)->col)
+
+static const CELL zeroCELL =
+{0, 0};
+
+#if OPT_DEC_LOCATOR
+static Bool SendLocatorPosition(XtermWidget xw, XButtonEvent * event);
+static void CheckLocatorPosition(XtermWidget xw, XButtonEvent * event);
+#endif /* OPT_DEC_LOCATOR */
+
+/* Multi-click handling */
+#if OPT_READLINE
+static Time lastButtonDownTime = 0;
+static int ExtendingSelection = 0;
+static Time lastButton3UpTime = 0;
+static Time lastButton3DoubleDownTime = 0;
+static CELL lastButton3;       /* At the release time */
+#endif /* OPT_READLINE */
+
+static Char *SaveText(TScreen * screen, int row, int scol, int ecol,
+                     Char * lp, int *eol);
+static int Length(TScreen * screen, int row, int scol, int ecol);
+static void ComputeSelect(XtermWidget xw, CELL * startc, CELL * endc, Bool extend);
+static void EditorButton(XtermWidget xw, XButtonEvent * event);
+static void EndExtend(XtermWidget w, XEvent * event, String * params, Cardinal
+                     num_params, Bool use_cursor_loc);
+static void ExtendExtend(XtermWidget xw, const CELL * cell);
+static void PointToCELL(TScreen * screen, int y, int x, CELL * cell);
+static void ReHiliteText(XtermWidget xw, CELL * first, CELL * last);
+static void SaltTextAway(XtermWidget xw, CELL * cellc, CELL * cell,
+                        String * params, Cardinal num_params);
+static void SelectSet(XtermWidget xw, XEvent * event, String * params, Cardinal num_params);
+static void SelectionReceived PROTO_XT_SEL_CB_ARGS;
+static void StartSelect(XtermWidget xw, const CELL * cell);
+static void TrackDown(XtermWidget xw, XButtonEvent * event);
+static void TrackText(XtermWidget xw, const CELL * first, const CELL * last);
+static void _OwnSelection(XtermWidget xw, String * selections, Cardinal count);
+static void do_select_end(XtermWidget xw, XEvent * event, String * params,
+                         Cardinal *num_params, Bool use_cursor_loc);
+
+#define MOUSE_LIMIT (255 - 32)
+
+/* Send SET_EXT_SIZE_MOUSE to enable offsets up to EXT_MOUSE_LIMIT */
+#define EXT_MOUSE_LIMIT (2047 - 32)
+#define EXT_MOUSE_START (127 - 32)
+
+static unsigned
+EmitMousePosition(TScreen * screen, Char line[], unsigned count, int value)
+{
+    int mouse_limit = (screen->ext_mode_mouse
+                      ? EXT_MOUSE_LIMIT
+                      : MOUSE_LIMIT);
+
+    /*
+     * Add pointer position to key sequence
+     *
+     * In extended mode we encode large positions as two-byte UTF-8.
+     *
+     * NOTE: historically, it was possible to emit 256, which became
+     * zero by truncation to 8 bits. While this was arguably a bug,
+     * it's also somewhat useful as a past-end marker. We preserve
+     * this behavior for both normal and extended mouse modes.
+     */
+    if (value == mouse_limit) {
+       line[count++] = CharOf(0);
+    } else if (!screen->ext_mode_mouse || value < EXT_MOUSE_START) {
+       line[count++] = CharOf(' ' + value + 1);
+    } else {
+       value += ' ' + 1;
+       line[count++] = CharOf(0xC0 + (value >> 6));
+       line[count++] = CharOf(0x80 + (value & 0x3F));
+    }
+    return count;
+}
+
+Bool
+SendMousePosition(XtermWidget xw, XEvent * event)
+{
+    TScreen *screen = TScreenOf(xw);
+    XButtonEvent *my_event = (XButtonEvent *) event;
+    Bool result = False;
+
+    switch (screen->send_mouse_pos) {
+    case MOUSE_OFF:
+       /* If send_mouse_pos mode isn't on, we shouldn't be here */
+       break;
+
+    case BTN_EVENT_MOUSE:
+    case ANY_EVENT_MOUSE:
+       if (KeyModifiers(event) == 0 || KeyModifiers(event) == ControlMask) {
+           /* xterm extension for motion reporting. June 1998 */
+           /* EditorButton() will distinguish between the modes */
+           switch (event->type) {
+           case MotionNotify:
+               my_event->button = 0;
+               /* FALLTHRU */
+           case ButtonPress:
+               /* FALLTHRU */
+           case ButtonRelease:
+               EditorButton(xw, my_event);
+               result = True;
+               break;
+           }
+       }
+       break;
+
+    default:
+       /* Make sure the event is an appropriate type */
+       if (IsBtnEvent(event)) {
+           switch (screen->send_mouse_pos) {
+           case X10_MOUSE:     /* X10 compatibility sequences */
+
+               if (BtnModifiers(my_event) == 0) {
+                   if (my_event->type == ButtonPress)
+                       EditorButton(xw, my_event);
+                   result = True;
+               }
+               break;
+
+           case VT200_HIGHLIGHT_MOUSE: /* DEC vt200 hilite tracking */
+               if (my_event->type == ButtonPress &&
+                   BtnModifiers(my_event) == 0 &&
+                   my_event->button == Button1) {
+                   TrackDown(xw, my_event);
+                   result = True;
+               } else if (BtnModifiers(my_event) == 0
+                          || BtnModifiers(my_event) == ControlMask) {
+                   EditorButton(xw, my_event);
+                   result = True;
+               }
+               break;
+
+           case VT200_MOUSE:   /* DEC vt200 compatible */
+               if (BtnModifiers(my_event) == 0
+                   || BtnModifiers(my_event) == ControlMask) {
+                   EditorButton(xw, my_event);
+                   result = True;
+               }
+               break;
+
+#if OPT_DEC_LOCATOR
+           case DEC_LOCATOR:
+               result = SendLocatorPosition(xw, my_event);
+               break;
+#endif /* OPT_DEC_LOCATOR */
+           }
+       }
+    }
+    return result;
+}
+
+#if OPT_DEC_LOCATOR
+
+#define        LocatorCoords( row, col, x, y, oor )                    \
+    if( screen->locator_pixels ) {                             \
+       (oor)=False; (row) = (y)+1; (col) = (x)+1;              \
+       /* Limit to screen dimensions */                        \
+       if ((row) < 1) (row) = 1,(oor)=True;                    \
+       else if ((row) > screen->border*2+Height(screen))       \
+           (row) = screen->border*2+Height(screen),(oor)=True; \
+       if ((col) < 1) (col) = 1,(oor)=True;                    \
+       else if ((col) > OriginX(screen)*2+Width(screen))       \
+           (col) = OriginX(screen)*2+Width(screen),(oor)=True; \
+    } else {                                                   \
+       (oor)=False;                                            \
+       /* Compute character position of mouse pointer */       \
+       (row) = ((y) - screen->border) / FontHeight(screen);    \
+       (col) = ((x) - OriginX(screen)) / FontWidth(screen);    \
+       /* Limit to screen dimensions */                        \
+       if ((row) < 0) (row) = 0,(oor)=True;                    \
+       else if ((row) > screen->max_row)                       \
+           (row) = screen->max_row,(oor)=True;                 \
+       if ((col) < 0) (col) = 0,(oor)=True;                    \
+       else if ((col) > screen->max_col)                       \
+           (col) = screen->max_col,(oor)=True;                 \
+       (row)++; (col)++;                                       \
+    }
+
+static Bool
+SendLocatorPosition(XtermWidget xw, XButtonEvent * event)
+{
+    ANSI reply;
+    TScreen *screen = TScreenOf(xw);
+    int row, col;
+    Bool oor;
+    int button;
+    unsigned state;
+
+    /* Make sure the event is an appropriate type */
+    if ((!IsBtnEvent(event) &&
+        !screen->loc_filter) ||
+       (BtnModifiers(event) != 0 && BtnModifiers(event) != ControlMask))
+       return (False);
+
+    if ((event->type == ButtonPress &&
+        !(screen->locator_events & LOC_BTNS_DN)) ||
+       (event->type == ButtonRelease &&
+        !(screen->locator_events & LOC_BTNS_UP)))
+       return (True);
+
+    if (event->type == MotionNotify) {
+       CheckLocatorPosition(xw, event);
+       return (True);
+    }
+
+    /* get button # */
+    button = (int) event->button - 1;
+
+    LocatorCoords(row, col, event->x, event->y, oor);
+
+    /*
+     * DECterm mouse:
+     *
+     * ESCAPE '[' event ; mask ; row ; column '&' 'w'
+     */
+    memset(&reply, 0, sizeof(reply));
+    reply.a_type = ANSI_CSI;
+
+    if (oor) {
+       reply.a_nparam = 1;
+       reply.a_param[0] = 0;   /* Event - 0 = locator unavailable */
+       reply.a_inters = '&';
+       reply.a_final = 'w';
+       unparseseq(xw, &reply);
+
+       if (screen->locator_reset) {
+           MotionOff(screen, xw);
+           screen->send_mouse_pos = MOUSE_OFF;
+       }
+       return (True);
+    }
+
+    /*
+     * event:
+     *        1       no buttons
+     *        2       left button down
+     *        3       left button up
+     *        4       middle button down
+     *        5       middle button up
+     *        6       right button down
+     *        7       right button up
+     *        8       M4 down
+     *        9       M4 up
+     */
+    reply.a_nparam = 4;
+    switch (event->type) {
+    case ButtonPress:
+       reply.a_param[0] = (ParmType) (2 + (button << 1));
+       break;
+    case ButtonRelease:
+       reply.a_param[0] = (ParmType) (3 + (button << 1));
+       break;
+    default:
+       return (True);
+    }
+    /*
+     * mask:
+     * bit 7   bit 6   bit 5   bit 4   bit 3   bit 2       bit 1         bit 0
+     *                                 M4 down left down   middle down   right down
+     *
+     * Notice that Button1 (left) and Button3 (right) are swapped in the mask.
+     * Also, mask should be the state after the button press/release,
+     * X provides the state not including the button press/release.
+     */
+    state = (event->state
+            & (Button1Mask | Button2Mask | Button3Mask | Button4Mask)) >> 8;
+    /* update mask to "after" state */
+    state ^= ((unsigned) (1 << button));
+    /* swap Button1 & Button3 */
+    state = ((state & (unsigned) ~(4 | 1))
+            | ((state & 1) ? 4 : 0)
+            | ((state & 4) ? 1 : 0));
+
+    reply.a_param[1] = (ParmType) state;
+    reply.a_param[2] = (ParmType) row;
+    reply.a_param[3] = (ParmType) col;
+    reply.a_inters = '&';
+    reply.a_final = 'w';
+
+    unparseseq(xw, &reply);
+
+    if (screen->locator_reset) {
+       MotionOff(screen, xw);
+       screen->send_mouse_pos = MOUSE_OFF;
+    }
+
+    /*
+     * DECterm turns the Locator off if a button is pressed while a filter rectangle
+     * is active. This might be a bug, but I don't know, so I'll emulate it anyways.
+     */
+    if (screen->loc_filter) {
+       screen->send_mouse_pos = MOUSE_OFF;
+       screen->loc_filter = False;
+       screen->locator_events = 0;
+       MotionOff(screen, xw);
+    }
+
+    return (True);
+}
+
+/*
+ * mask:
+ * bit 7   bit 6   bit 5   bit 4   bit 3   bit 2       bit 1         bit 0
+ *                                 M4 down left down   middle down   right down
+ *
+ * Button1 (left) and Button3 (right) are swapped in the mask relative to X.
+ */
+#define        ButtonState(state, mask)        \
+{ (state) = (int) (((mask) & (Button1Mask | Button2Mask | Button3Mask | Button4Mask)) >> 8);   \
+  /* swap Button1 & Button3 */                                                         \
+  (state) = ((state) & ~(4|1)) | (((state)&1)?4:0) | (((state)&4)?1:0);                        \
+}
+
+void
+GetLocatorPosition(XtermWidget xw)
+{
+    ANSI reply;
+    TScreen *screen = TScreenOf(xw);
+    Window root, child;
+    int rx, ry, x, y;
+    unsigned int mask;
+    int row = 0, col = 0;
+    Bool oor = False;
+    Bool ret = False;
+    int state;
+
+    /*
+     * DECterm turns the Locator off if the position is requested while a filter rectangle
+     * is active.  This might be a bug, but I don't know, so I'll emulate it anyways.
+     */
+    if (screen->loc_filter) {
+       screen->send_mouse_pos = MOUSE_OFF;
+       screen->loc_filter = False;
+       screen->locator_events = 0;
+       MotionOff(screen, xw);
+    }
+
+    memset(&reply, 0, sizeof(reply));
+    reply.a_type = ANSI_CSI;
+
+    if (screen->send_mouse_pos == DEC_LOCATOR) {
+       ret = XQueryPointer(screen->display, VWindow(screen), &root,
+                           &child, &rx, &ry, &x, &y, &mask);
+       if (ret) {
+           LocatorCoords(row, col, x, y, oor);
+       }
+    }
+    if (ret == False || oor) {
+       reply.a_nparam = 1;
+       reply.a_param[0] = 0;   /* Event - 0 = locator unavailable */
+       reply.a_inters = '&';
+       reply.a_final = 'w';
+       unparseseq(xw, &reply);
+
+       if (screen->locator_reset) {
+           MotionOff(screen, xw);
+           screen->send_mouse_pos = MOUSE_OFF;
+       }
+       return;
+    }
+
+    ButtonState(state, mask);
+
+    reply.a_nparam = 4;
+    reply.a_param[0] = 1;      /* Event - 1 = response to locator request */
+    reply.a_param[1] = (ParmType) state;
+    reply.a_param[2] = (ParmType) row;
+    reply.a_param[3] = (ParmType) col;
+    reply.a_inters = '&';
+    reply.a_final = 'w';
+    unparseseq(xw, &reply);
+
+    if (screen->locator_reset) {
+       MotionOff(screen, xw);
+       screen->send_mouse_pos = MOUSE_OFF;
+    }
+}
+
+void
+InitLocatorFilter(XtermWidget xw)
+{
+    ANSI reply;
+    TScreen *screen = TScreenOf(xw);
+    Window root, child;
+    int rx, ry, x, y;
+    unsigned int mask;
+    int row = 0, col = 0;
+    Bool oor = 0;
+    Bool ret;
+    int state;
+
+    ret = XQueryPointer(screen->display, VWindow(screen),
+                       &root, &child, &rx, &ry, &x, &y, &mask);
+    if (ret) {
+       LocatorCoords(row, col, x, y, oor);
+    }
+    if (ret == False || oor) {
+       /* Locator is unavailable */
+
+       if (screen->loc_filter_top != LOC_FILTER_POS ||
+           screen->loc_filter_left != LOC_FILTER_POS ||
+           screen->loc_filter_bottom != LOC_FILTER_POS ||
+           screen->loc_filter_right != LOC_FILTER_POS) {
+           /*
+            * If any explicit coordinates were received,
+            * report immediately with no coordinates.
+            */
+           memset(&reply, 0, sizeof(reply));
+           reply.a_type = ANSI_CSI;
+           reply.a_nparam = 1;
+           reply.a_param[0] = 0;       /* Event - 0 = locator unavailable */
+           reply.a_inters = '&';
+           reply.a_final = 'w';
+           unparseseq(xw, &reply);
+
+           if (screen->locator_reset) {
+               MotionOff(screen, xw);
+               screen->send_mouse_pos = MOUSE_OFF;
+           }
+       } else {
+           /*
+            * No explicit coordinates were received, and the pointer is
+            * unavailable.  Report when the pointer re-enters the window.
+            */
+           screen->loc_filter = True;
+           MotionOn(screen, xw);
+       }
+       return;
+    }
+
+    /*
+     * Adjust rectangle coordinates:
+     *  1. Replace "LOC_FILTER_POS" with current coordinates
+     *  2. Limit coordinates to screen size
+     *  3. make sure top and left are less than bottom and right, resp.
+     */
+    if (screen->locator_pixels) {
+       rx = OriginX(screen) * 2 + Width(screen);
+       ry = screen->border * 2 + Height(screen);
+    } else {
+       rx = screen->max_col;
+       ry = screen->max_row;
+    }
+
+#define        Adjust( coord, def, max )                               \
+       if( (coord) == LOC_FILTER_POS ) (coord) = (def);        \
+       else if ((coord) < 1)           (coord) = 1;            \
+       else if ((coord) > (max))       (coord) = (max)
+
+    Adjust(screen->loc_filter_top, row, ry);
+    Adjust(screen->loc_filter_left, col, rx);
+    Adjust(screen->loc_filter_bottom, row, ry);
+    Adjust(screen->loc_filter_right, col, rx);
+
+    if (screen->loc_filter_top > screen->loc_filter_bottom) {
+       ry = screen->loc_filter_top;
+       screen->loc_filter_top = screen->loc_filter_bottom;
+       screen->loc_filter_bottom = ry;
+    }
+
+    if (screen->loc_filter_left > screen->loc_filter_right) {
+       rx = screen->loc_filter_left;
+       screen->loc_filter_left = screen->loc_filter_right;
+       screen->loc_filter_right = rx;
+    }
+
+    if ((col < screen->loc_filter_left) ||
+       (col > screen->loc_filter_right) ||
+       (row < screen->loc_filter_top) ||
+       (row > screen->loc_filter_bottom)) {
+       /* Pointer is already outside the rectangle - report immediately */
+       ButtonState(state, mask);
+
+       memset(&reply, 0, sizeof(reply));
+       reply.a_type = ANSI_CSI;
+       reply.a_nparam = 4;
+       reply.a_param[0] = 10;  /* Event - 10 = locator outside filter */
+       reply.a_param[1] = (ParmType) state;
+       reply.a_param[2] = (ParmType) row;
+       reply.a_param[3] = (ParmType) col;
+       reply.a_inters = '&';
+       reply.a_final = 'w';
+       unparseseq(xw, &reply);
+
+       if (screen->locator_reset) {
+           MotionOff(screen, xw);
+           screen->send_mouse_pos = MOUSE_OFF;
+       }
+       return;
+    }
+
+    /*
+     * Rectangle is set up.  Allow pointer tracking
+     * to detect if the mouse leaves the rectangle.
+     */
+    screen->loc_filter = True;
+    MotionOn(screen, xw);
+}
+
+static void
+CheckLocatorPosition(XtermWidget xw, XButtonEvent * event)
+{
+    ANSI reply;
+    TScreen *screen = TScreenOf(xw);
+    int row, col;
+    Bool oor;
+    int state;
+
+    LocatorCoords(row, col, event->x, event->y, oor);
+
+    /*
+     * Send report if the pointer left the filter rectangle, if
+     * the pointer left the window, or if the filter rectangle
+     * had no coordinates and the pointer re-entered the window.
+     */
+    if (oor || (screen->loc_filter_top == LOC_FILTER_POS) ||
+       (col < screen->loc_filter_left) ||
+       (col > screen->loc_filter_right) ||
+       (row < screen->loc_filter_top) ||
+       (row > screen->loc_filter_bottom)) {
+       /* Filter triggered - disable it */
+       screen->loc_filter = False;
+       MotionOff(screen, xw);
+
+       memset(&reply, 0, sizeof(reply));
+       reply.a_type = ANSI_CSI;
+       if (oor) {
+           reply.a_nparam = 1;
+           reply.a_param[0] = 0;       /* Event - 0 = locator unavailable */
+       } else {
+           ButtonState(state, event->state);
+
+           reply.a_nparam = 4;
+           reply.a_param[0] = 10;      /* Event - 10 = locator outside filter */
+           reply.a_param[1] = (ParmType) state;
+           reply.a_param[2] = (ParmType) row;
+           reply.a_param[3] = (ParmType) col;
+       }
+
+       reply.a_inters = '&';
+       reply.a_final = 'w';
+       unparseseq(xw, &reply);
+
+       if (screen->locator_reset) {
+           MotionOff(screen, xw);
+           screen->send_mouse_pos = MOUSE_OFF;
+       }
+    }
+}
+#endif /* OPT_DEC_LOCATOR */
+
+#if OPT_READLINE
+static int
+isClick1_clean(TScreen * screen, XButtonEvent * event)
+{
+    int delta;
+
+    if (!IsBtnEvent(event)
+    /* Disable on Shift-Click-1, including the application-mouse modes */
+       || (BtnModifiers(event) & ShiftMask)
+       || (screen->send_mouse_pos != MOUSE_OFF)        /* Kinda duplicate... */
+       ||ExtendingSelection)   /* Was moved */
+       return 0;
+
+    if (event->type != ButtonRelease)
+       return 0;
+
+    if (lastButtonDownTime == (Time) 0) {
+       /* first time or once in a blue moon */
+       delta = screen->multiClickTime + 1;
+    } else if (event->time > lastButtonDownTime) {
+       /* most of the time */
+       delta = (int) (event->time - lastButtonDownTime);
+    } else {
+       /* time has rolled over since lastButtonUpTime */
+       delta = (int) ((((Time) ~ 0) - lastButtonDownTime) + event->time);
+    }
+
+    return delta <= screen->multiClickTime;
+}
+
+static int
+isDoubleClick3(TScreen * screen, XButtonEvent * event)
+{
+    int delta;
+
+    if (event->type != ButtonRelease
+       || (BtnModifiers(event) & ShiftMask)
+       || event->button != Button3) {
+       lastButton3UpTime = 0;  /* Disable the cached info */
+       return 0;
+    }
+    /* Process Btn3Release. */
+    if (lastButton3DoubleDownTime == (Time) 0) {
+       /* No previous click or once in a blue moon */
+       delta = screen->multiClickTime + 1;
+    } else if (event->time > lastButton3DoubleDownTime) {
+       /* most of the time */
+       delta = (int) (event->time - lastButton3DoubleDownTime);
+    } else {
+       /* time has rolled over since lastButton3DoubleDownTime */
+       delta = (int) ((((Time) ~ 0) - lastButton3DoubleDownTime) + event->time);
+    }
+    if (delta <= screen->multiClickTime) {
+       /* Double click */
+       CELL cell;
+
+       /* Cannot check ExtendingSelection, since mouse-3 always sets it */
+       PointToCELL(screen, event->y, event->x, &cell);
+       if (isSameCELL(&cell, &lastButton3)) {
+           lastButton3DoubleDownTime = 0;      /* Disable the third click */
+           return 1;
+       }
+    }
+    /* Not a double click, memorize for future check. */
+    lastButton3UpTime = event->time;
+    PointToCELL(screen, event->y, event->x, &lastButton3);
+    return 0;
+}
+
+static int
+CheckSecondPress3(TScreen * screen, XEvent * event)
+{
+    int delta;
+
+    if (event->type != ButtonPress
+       || (KeyModifiers(event) & ShiftMask)
+       || event->xbutton.button != Button3) {
+       lastButton3DoubleDownTime = 0;  /* Disable the cached info */
+       return 0;
+    }
+    /* Process Btn3Press. */
+    if (lastButton3UpTime == (Time) 0) {
+       /* No previous click or once in a blue moon */
+       delta = screen->multiClickTime + 1;
+    } else if (event->xbutton.time > lastButton3UpTime) {
+       /* most of the time */
+       delta = (int) (event->xbutton.time - lastButton3UpTime);
+    } else {
+       /* time has rolled over since lastButton3UpTime */
+       delta = (int) ((((Time) ~ 0) - lastButton3UpTime) + event->xbutton.time);
+    }
+    if (delta <= screen->multiClickTime) {
+       CELL cell;
+
+       PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
+       if (isSameCELL(&cell, &lastButton3)) {
+           /* A candidate for a double-click */
+           lastButton3DoubleDownTime = event->xbutton.time;
+           PointToCELL(screen, event->xbutton.y, event->xbutton.x, &lastButton3);
+           return 1;
+       }
+       lastButton3UpTime = 0;  /* Disable the info about the previous click */
+    }
+    /* Either too long, or moved, disable. */
+    lastButton3DoubleDownTime = 0;
+    return 0;
+}
+
+static int
+rowOnCurrentLine(TScreen * screen,
+                int line,
+                int *deltap)   /* must be XButtonEvent */
+{
+    int result = 1;
+    int l1, l2;
+
+    *deltap = 0;
+    if (line != screen->cur_row) {
+       if (line < screen->cur_row)
+           l1 = line, l2 = screen->cur_row;
+       else
+           l2 = line, l1 = screen->cur_row;
+       l1--;
+       while (++l1 < l2) {
+           LineData *ld = GET_LINEDATA(screen, l1);
+           if (!LineTstWrapped(ld)) {
+               result = 0;
+               break;
+           }
+       }
+       if (result) {
+           /* Everything is on one "wrapped line" now */
+           *deltap = line - screen->cur_row;
+       }
+    }
+    return result;
+}
+
+static int
+eventRow(TScreen * screen, XEvent * event)     /* must be XButtonEvent */
+{
+    return (event->xbutton.y - screen->border) / FontHeight(screen);
+}
+
+static int
+eventColBetween(TScreen * screen, XEvent * event)      /* must be XButtonEvent */
+{
+    /* Correct by half a width - we are acting on a boundary, not on a cell. */
+    return ((event->xbutton.x - OriginX(screen) + (FontWidth(screen) - 1) / 2)
+           / FontWidth(screen));
+}
+
+static int
+ReadLineMovePoint(TScreen * screen, int col, int ldelta)
+{
+    Char line[6];
+    unsigned count = 0;
+
+    col += ldelta * MaxCols(screen) - screen->cur_col;
+    if (col == 0)
+       return 0;
+    if (screen->control_eight_bits) {
+       line[count++] = ANSI_CSI;
+    } else {
+       line[count++] = ANSI_ESC;
+       line[count++] = '[';    /* XXX maybe sometimes O is better? */
+    }
+    line[count] = CharOf(col > 0 ? 'C' : 'D');
+    if (col < 0)
+       col = -col;
+    while (col--)
+       v_write(screen->respond, line, 3);
+    return 1;
+}
+
+static int
+ReadLineDelete(TScreen * screen, CELL * cell1, CELL * cell2)
+{
+    int del;
+
+    del = (cell2->col - cell1->col) + ((cell2->row - cell1->row) * MaxCols(screen));
+    if (del <= 0)              /* Just in case... */
+       return 0;
+    while (del--)
+       v_write(screen->respond, (const Char *) "\177", 1);
+    return 1;
+}
+
+static void
+readlineExtend(TScreen * screen, XEvent * event)
+{
+    int ldelta1, ldelta2;
+
+    if (IsBtnEvent(event)) {
+       XButtonEvent *my_event = (XButtonEvent *) event;
+       if (isClick1_clean(screen, my_event)
+           && SCREEN_FLAG(screen, click1_moves)
+           && rowOnCurrentLine(screen, eventRow(screen, event), &ldelta1)) {
+           ReadLineMovePoint(screen, eventColBetween(screen, event), ldelta1);
+       }
+       if (isDoubleClick3(screen, my_event)
+           && SCREEN_FLAG(screen, dclick3_deletes)
+           && rowOnCurrentLine(screen, screen->startSel.row, &ldelta1)
+           && rowOnCurrentLine(screen, screen->endSel.row, &ldelta2)) {
+           ReadLineMovePoint(screen, screen->endSel.col, ldelta2);
+           ReadLineDelete(screen, &screen->startSel, &(screen->endSel));
+       }
+    }
+}
+
+#endif /* OPT_READLINE */
+
+/* ^XM-G<line+' '><col+' '> */
+void
+DiredButton(Widget w,
+           XEvent * event,     /* must be XButtonEvent */
+           String * params GCC_UNUSED,         /* selections */
+           Cardinal *num_params GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       Char Line[6];
+       unsigned line, col;
+
+       if (IsBtnEvent(event)
+           && (event->xbutton.y >= screen->border)
+           && (event->xbutton.x >= OriginX(screen))) {
+           line = (unsigned) ((event->xbutton.y - screen->border)
+                              / FontHeight(screen));
+           col = (unsigned) ((event->xbutton.x - OriginX(screen))
+                             / FontWidth(screen));
+           Line[0] = CONTROL('X');
+           Line[1] = ANSI_ESC;
+           Line[2] = 'G';
+           Line[3] = CharOf(' ' + col);
+           Line[4] = CharOf(' ' + line);
+           v_write(screen->respond, Line, 5);
+       }
+    }
+}
+
+#if OPT_READLINE
+void
+ReadLineButton(Widget w,
+              XEvent * event,  /* must be XButtonEvent */
+              String * params GCC_UNUSED,      /* selections */
+              Cardinal *num_params GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       Char Line[6];
+       int line, col, ldelta = 0;
+
+       if (!IsBtnEvent(event)
+           || (screen->send_mouse_pos != MOUSE_OFF) || ExtendingSelection)
+           goto finish;
+       if (event->type == ButtonRelease) {
+           int delta;
+
+           if (lastButtonDownTime == (Time) 0) {
+               /* first time and once in a blue moon */
+               delta = screen->multiClickTime + 1;
+           } else if (event->xbutton.time > lastButtonDownTime) {
+               /* most of the time */
+               delta = (int) (event->xbutton.time - lastButtonDownTime);
+           } else {
+               /* time has rolled over since lastButtonUpTime */
+               delta = (int) ((((Time) ~ 0) - lastButtonDownTime) + event->xbutton.time);
+           }
+           if (delta > screen->multiClickTime)
+               goto finish;    /* All this work for this... */
+       }
+       line = (event->xbutton.y - screen->border) / FontHeight(screen);
+       if (!rowOnCurrentLine(screen, line, &ldelta))
+           goto finish;
+       /* Correct by half a width - we are acting on a boundary, not on a cell. */
+       col = (event->xbutton.x - OriginX(screen) + (FontWidth(screen) - 1)
+              / 2)
+           / FontWidth(screen) - screen->cur_col + ldelta * MaxCols(screen);
+       if (col == 0)
+           goto finish;
+       Line[0] = ANSI_ESC;
+       /* XXX: sometimes it is better to send '['? */
+       Line[1] = 'O';
+       Line[2] = CharOf(col > 0 ? 'C' : 'D');
+       if (col < 0)
+           col = -col;
+       while (col--)
+           v_write(screen->respond, Line, 3);
+      finish:
+       if (event->type == ButtonRelease)
+           do_select_end(xw, event, params, num_params, False);
+    }
+}
+#endif /* OPT_READLINE */
+
+/* repeats <ESC>n or <ESC>p */
+void
+ViButton(Widget w,
+        XEvent * event,        /* must be XButtonEvent */
+        String * params GCC_UNUSED,    /* selections */
+        Cardinal *num_params GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       int pty = screen->respond;
+       Char Line[6];
+       int line;
+
+       if (IsBtnEvent(event)) {
+
+           line = screen->cur_row -
+               ((event->xbutton.y - screen->border) / FontHeight(screen));
+           if (line != 0) {
+               Line[0] = ANSI_ESC;     /* force an exit from insert-mode */
+               v_write(pty, Line, 1);
+
+               if (line < 0) {
+                   line = -line;
+                   Line[0] = CONTROL('n');
+               } else {
+                   Line[0] = CONTROL('p');
+               }
+               while (--line >= 0)
+                   v_write(pty, Line, 1);
+           }
+       }
+    }
+}
+
+/*
+ * This function handles button-motion events
+ */
+/*ARGSUSED*/
+void
+HandleSelectExtend(Widget w,
+                  XEvent * event,      /* must be XMotionEvent */
+                  String * params GCC_UNUSED,
+                  Cardinal *num_params GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       CELL cell;
+
+       screen->selection_time = event->xmotion.time;
+       switch (screen->eventMode) {
+           /* If not in one of the DEC mouse-reporting modes */
+       case LEFTEXTENSION:
+       case RIGHTEXTENSION:
+           PointToCELL(screen, event->xmotion.y, event->xmotion.x, &cell);
+           ExtendExtend(xw, &cell);
+           break;
+
+           /* If in motion reporting mode, send mouse position to
+              character process as a key sequence \E[M... */
+       case NORMAL:
+           /* will get here if send_mouse_pos != MOUSE_OFF */
+           if (screen->send_mouse_pos == BTN_EVENT_MOUSE
+               || screen->send_mouse_pos == ANY_EVENT_MOUSE) {
+               (void) SendMousePosition(xw, event);
+           }
+           break;
+       }
+    }
+}
+
+void
+HandleKeyboardSelectExtend(Widget w,
+                          XEvent * event GCC_UNUSED,   /* must be XButtonEvent */
+                          String * params GCC_UNUSED,
+                          Cardinal *num_params GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       ExtendExtend(xw, &screen->cursorp);
+    }
+}
+
+static void
+do_select_end(XtermWidget xw,
+             XEvent * event,   /* must be XButtonEvent */
+             String * params,  /* selections */
+             Cardinal *num_params,
+             Bool use_cursor_loc)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    screen->selection_time = event->xbutton.time;
+    switch (screen->eventMode) {
+    case NORMAL:
+       (void) SendMousePosition(xw, event);
+       break;
+    case LEFTEXTENSION:
+    case RIGHTEXTENSION:
+       EndExtend(xw, event, params, *num_params, use_cursor_loc);
+#if OPT_READLINE
+       readlineExtend(screen, event);
+#endif /* OPT_READLINE */
+       break;
+    }
+}
+
+void
+HandleSelectEnd(Widget w,
+               XEvent * event, /* must be XButtonEvent */
+               String * params,        /* selections */
+               Cardinal *num_params)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       do_select_end(xw, event, params, num_params, False);
+    }
+}
+
+void
+HandleKeyboardSelectEnd(Widget w,
+                       XEvent * event,         /* must be XButtonEvent */
+                       String * params,        /* selections */
+                       Cardinal *num_params)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       do_select_end(xw, event, params, num_params, True);
+    }
+}
+
+/*
+ * Copy the selection data to the given target(s).
+ */
+void
+HandleCopySelection(Widget w,
+                   XEvent * event,
+                   String * params,    /* list of targets */
+                   Cardinal *num_params)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       SelectSet(xw, event, params, *num_params);
+    }
+}
+
+struct _SelectionList {
+    String *params;
+    Cardinal count;
+    Atom *targets;
+    Time time;
+};
+
+static unsigned
+DECtoASCII(unsigned ch)
+{
+    if (xtermIsDecGraphic(ch)) {
+       ch = CharOf("###########+++++##-##++++|######"[ch]);
+       /*           01234567890123456789012345678901 */
+    }
+    return ch;
+}
+
+#if OPT_WIDE_CHARS
+static Cardinal
+addXtermChar(Char ** buffer, Cardinal *used, Cardinal offset, unsigned value)
+{
+    if (offset + 1 >= *used) {
+       *used = 1 + (2 * (offset + 1));
+       allocXtermChars(buffer, *used);
+    }
+    (*buffer)[offset++] = (Char) value;
+    return offset;
+}
+#define AddChar(buffer, used, offset, value) \
+       offset = addXtermChar(buffer, used, offset, (unsigned) value)
+
+/*
+ * Convert a UTF-8 string to Latin-1, replacing non Latin-1 characters by `#',
+ * or ASCII/Latin-1 equivalents for special cases.
+ */
+static Char *
+UTF8toLatin1(TScreen * screen, Char * s, unsigned long len, unsigned long *result)
+{
+    static Char *buffer;
+    static Cardinal used;
+
+    Cardinal offset = 0;
+
+    const Char *p;
+
+    if (len != 0) {
+       PtyData data;
+
+       fakePtyData(&data, s, s + len);
+       while (decodeUtf8(&data)) {
+           Bool fails = False;
+           Bool extra = False;
+           IChar value = skipPtyData(&data);
+           if (value == UCS_REPL) {
+               fails = True;
+           } else if (value < 256) {
+               AddChar(&buffer, &used, offset, CharOf(value));
+           } else {
+               unsigned eqv = ucs2dec(value);
+               if (xtermIsDecGraphic(eqv)) {
+                   AddChar(&buffer, &used, offset, DECtoASCII(eqv));
+               } else {
+                   eqv = AsciiEquivs(value);
+                   if (eqv == value) {
+                       fails = True;
+                   } else {
+                       AddChar(&buffer, &used, offset, eqv);
+                   }
+                   if (isWide((wchar_t) value))
+                       extra = True;
+               }
+           }
+
+           /*
+            * If we're not able to plug in a single-byte result, insert the
+            * defaultString (which normally is a single "#", but could be
+            * whatever the user wants).
+            */
+           if (fails) {
+               for (p = (const Char *) screen->default_string; *p != '\0'; ++p) {
+                   AddChar(&buffer, &used, offset, *p);
+               }
+           }
+           if (extra)
+               AddChar(&buffer, &used, offset, ' ');
+       }
+       AddChar(&buffer, &used, offset, '\0');
+       *result = (unsigned long) (offset - 1);
+    } else {
+       *result = 0;
+    }
+    return buffer;
+}
+
+int
+xtermUtf8ToTextList(XtermWidget xw,
+                   XTextProperty * text_prop,
+                   char ***text_list,
+                   int *text_list_count)
+{
+    TScreen *screen = TScreenOf(xw);
+    Display *dpy = screen->display;
+    int rc = -1;
+
+    if (text_prop->format == 8
+       && (rc = Xutf8TextPropertyToTextList(dpy, text_prop,
+                                            text_list,
+                                            text_list_count)) >= 0) {
+       if (*text_list != NULL && *text_list_count != 0) {
+           int i;
+           Char *data;
+           char **new_text_list, *tmp;
+           unsigned long size, new_size;
+
+           TRACE(("xtermUtf8ToTextList size %d\n", *text_list_count));
+
+           /*
+            * XLib StringList actually uses only two pointers, one for the
+            * list itself, and one for the data.  Pointer to the data is the
+            * first element of the list, the rest (if any) list elements point
+            * to the same memory block as the first element
+            */
+           new_size = 0;
+           for (i = 0; i < *text_list_count; ++i) {
+               data = (Char *) (*text_list)[i];
+               size = strlen((*text_list)[i]) + 1;
+               (void) UTF8toLatin1(screen, data, size, &size);
+               new_size += size + 1;
+           }
+           new_text_list = TypeXtMallocN(char *, *text_list_count);
+           new_text_list[0] = tmp = XtMalloc((Cardinal) new_size);
+           for (i = 0; i < (*text_list_count); ++i) {
+               data = (Char *) (*text_list)[i];
+               size = strlen((*text_list)[i]) + 1;
+               data = UTF8toLatin1(screen, data, size, &size);
+               memcpy(tmp, data, size + 1);
+               new_text_list[i] = tmp;
+               tmp += size + 1;
+           }
+           XFreeStringList((*text_list));
+           *text_list = new_text_list;
+       } else {
+           rc = -1;
+       }
+    }
+    return rc;
+}
+#endif /* OPT_WIDE_CHARS */
+
+static char *
+parseItem(char *value, char *nextc)
+{
+    char *nextp = value;
+    while (*nextp != '\0' && *nextp != ',') {
+       *nextp = x_toupper(*nextp);
+       ++nextp;
+    }
+    *nextc = *nextp;
+    *nextp = '\0';
+    x_strtrim(value);
+
+    return nextp;
+}
+
+/*
+ * All of the wanted strings are unique in the first character, so we can
+ * use simple abbreviations.
+ */
+static Bool
+sameItem(const char *actual, const char *wanted)
+{
+    Bool result = False;
+    size_t have = strlen(actual);
+    size_t need = strlen(wanted);
+
+    if (have != 0 && have <= need) {
+       if (!strncmp(actual, wanted, have)) {
+           TRACE(("...matched \"%s\"\n", wanted));
+           result = True;
+       }
+    }
+
+    return result;
+}
+
+/*
+ * Handle the eightBitSelectTypes or utf8SelectTypes resource values.
+ */
+static Bool
+overrideTargets(Widget w, String value, Atom ** resultp)
+{
+    Bool override = False;
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+
+       if (!IsEmpty(value)) {
+           char *copied = x_strdup(value);
+           if (copied != 0) {
+               Atom *result = 0;
+               Cardinal count = 1;
+               int n;
+
+               TRACE(("decoding SelectTypes \"%s\"\n", value));
+               for (n = 0; copied[n] != '\0'; ++n) {
+                   if (copied[n] == ',')
+                       ++count;
+               }
+               result = TypeXtMallocN(Atom, (2 * count) + 1);
+               if (result == NULL) {
+                   TRACE(("Couldn't allocate selection types\n"));
+               } else {
+                   char nextc = '?';
+                   char *listp = (char *) copied;
+                   count = 0;
+                   do {
+                       char *nextp = parseItem(listp, &nextc);
+                       size_t len = strlen(listp);
+
+                       if (len == 0) {
+                           /* EMPTY */ ;
+                       }
+#if OPT_WIDE_CHARS
+                       else if (sameItem(listp, "UTF8")) {
+                           result[count++] = XA_UTF8_STRING(XtDisplay(w));
+                       }
+#endif
+                       else if (sameItem(listp, "I18N")) {
+                           if (screen->i18nSelections) {
+                               result[count++] = XA_TEXT(XtDisplay(w));
+                               result[count++] = XA_COMPOUND_TEXT(XtDisplay(w));
+                           }
+                       } else if (sameItem(listp, "TEXT")) {
+                           result[count++] = XA_TEXT(XtDisplay(w));
+                       } else if (sameItem(listp, "COMPOUND_TEXT")) {
+                           result[count++] = XA_COMPOUND_TEXT(XtDisplay(w));
+                       } else if (sameItem(listp, "STRING")) {
+                           result[count++] = XA_STRING;
+                       }
+                       *nextp++ = nextc;
+                       listp = nextp;
+                   } while (nextc != '\0');
+                   if (count) {
+                       result[count] = None;
+                       override = True;
+                       *resultp = result;
+                   } else {
+                       XtFree((char *) result);
+                   }
+               }
+           } else {
+               TRACE(("Couldn't allocate copy of selection types\n"));
+           }
+       }
+    }
+    return override;
+}
+
+#if OPT_WIDE_CHARS
+static Atom *
+allocUtf8Targets(Widget w, TScreen * screen)
+{
+    Atom **resultp = &(screen->selection_targets_utf8);
+
+    if (*resultp == 0) {
+       Atom *result;
+
+       if (!overrideTargets(w, screen->utf8_select_types, &result)) {
+           result = TypeXtMallocN(Atom, 5);
+           if (result == NULL) {
+               TRACE(("Couldn't allocate utf-8 selection targets\n"));
+           } else {
+               int n = 0;
+
+               result[n++] = XA_UTF8_STRING(XtDisplay(w));
+#ifdef X_HAVE_UTF8_STRING
+               if (screen->i18nSelections) {
+                   result[n++] = XA_TEXT(XtDisplay(w));
+                   result[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
+               }
+#endif
+               result[n++] = XA_STRING;
+               result[n] = None;
+           }
+       }
+
+       *resultp = result;
+    }
+
+    return *resultp;
+}
+#endif
+
+static Atom *
+alloc8bitTargets(Widget w, TScreen * screen)
+{
+    Atom **resultp = &(screen->selection_targets_8bit);
+
+    if (*resultp == 0) {
+       Atom *result = 0;
+
+       if (!overrideTargets(w, screen->eightbit_select_types, &result)) {
+           result = TypeXtMallocN(Atom, 5);
+           if (result == NULL) {
+               TRACE(("Couldn't allocate 8bit selection targets\n"));
+           } else {
+               int n = 0;
+
+#ifdef X_HAVE_UTF8_STRING
+               result[n++] = XA_UTF8_STRING(XtDisplay(w));
+#endif
+               if (screen->i18nSelections) {
+                   result[n++] = XA_TEXT(XtDisplay(w));
+                   result[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
+               }
+               result[n++] = XA_STRING;
+               result[n] = None;
+           }
+       }
+
+       *resultp = result;
+    }
+
+    return *resultp;
+}
+
+static Atom *
+_SelectionTargets(Widget w)
+{
+    Atom *result;
+    TScreen *screen;
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) == 0) {
+       result = NULL;
+    } else {
+       screen = TScreenOf(xw);
+
+#if OPT_WIDE_CHARS
+       if (screen->wide_chars) {
+           result = allocUtf8Targets(w, screen);
+       } else
+#endif
+       {
+           /* not screen->wide_chars */
+           result = alloc8bitTargets(w, screen);
+       }
+    }
+
+    return result;
+}
+
+#define isSELECT(value) (!strcmp(value, "SELECT"))
+
+static void
+UnmapSelections(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Cardinal n;
+
+    if (screen->mappedSelect) {
+       for (n = 0; screen->mappedSelect[n] != 0; ++n)
+           free((void *) screen->mappedSelect[n]);
+       free(screen->mappedSelect);
+       screen->mappedSelect = 0;
+    }
+}
+
+/*
+ * xterm generally uses the primary selection.  Some applications prefer
+ * (or are limited to) the clipboard.  Since the translations resource is
+ * complicated, users seldom change the way it affects selection.  But it
+ * is simple to remap the choice between primary and clipboard before the
+ * call to XmuInternStrings().
+ */
+static String *
+MapSelections(XtermWidget xw, String * params, Cardinal num_params)
+{
+    String *result = params;
+
+    if (num_params > 0) {
+       Cardinal j;
+       Boolean map = False;
+
+       for (j = 0; j < num_params; ++j) {
+           TRACE(("param[%d]:%s\n", j, params[j]));
+           if (isSELECT(params[j])) {
+               map = True;
+               break;
+           }
+       }
+       if (map) {
+           TScreen *screen = TScreenOf(xw);
+           const char *mapTo = (screen->selectToClipboard
+                                ? "CLIPBOARD"
+                                : "PRIMARY");
+
+           UnmapSelections(xw);
+           if ((result = TypeMallocN(String, num_params + 1)) != 0) {
+               result[num_params] = 0;
+               for (j = 0; j < num_params; ++j) {
+                   result[j] = x_strdup((isSELECT(params[j])
+                                         ? mapTo
+                                         : params[j]));
+                   if (result[j] == 0) {
+                       UnmapSelections(xw);
+                       result = 0;
+                       break;
+                   }
+               }
+               screen->mappedSelect = result;
+           }
+       }
+    }
+    return result;
+}
+
+/*
+ * Lookup the cut-buffer number, which will be in the range 0-7.
+ * If it is not a cut-buffer, it is the primary selection (-1).
+ */
+static int
+CutBuffer(Atom code)
+{
+    int cutbuffer;
+    switch ((unsigned) code) {
+    case XA_CUT_BUFFER0:
+       cutbuffer = 0;
+       break;
+    case XA_CUT_BUFFER1:
+       cutbuffer = 1;
+       break;
+    case XA_CUT_BUFFER2:
+       cutbuffer = 2;
+       break;
+    case XA_CUT_BUFFER3:
+       cutbuffer = 3;
+       break;
+    case XA_CUT_BUFFER4:
+       cutbuffer = 4;
+       break;
+    case XA_CUT_BUFFER5:
+       cutbuffer = 5;
+       break;
+    case XA_CUT_BUFFER6:
+       cutbuffer = 6;
+       break;
+    case XA_CUT_BUFFER7:
+       cutbuffer = 7;
+       break;
+    default:
+       cutbuffer = -1;
+       break;
+    }
+    return cutbuffer;
+}
+
+#if OPT_PASTE64
+static void
+FinishPaste64(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("FinishPaste64(%d)\n", screen->base64_paste));
+    if (screen->base64_paste) {
+       screen->base64_paste = 0;
+       unparseputc1(xw, screen->base64_final);
+       unparse_end(xw);
+    }
+}
+#endif
+
+#if !OPT_PASTE64
+static
+#endif
+void
+xtermGetSelection(Widget w,
+                 Time ev_time,
+                 String * params,      /* selections in precedence order */
+                 Cardinal num_params,
+                 Atom * targets)
+{
+    Atom selection;
+    int cutbuffer;
+    Atom target;
+
+    XtermWidget xw;
+
+    if (num_params == 0)
+       return;
+    if ((xw = getXtermWidget(w)) == 0)
+       return;
+
+    TRACE(("xtermGetSelection num_params %d\n", num_params));
+    params = MapSelections(xw, params, num_params);
+
+    XmuInternStrings(XtDisplay(w), params, (Cardinal) 1, &selection);
+    cutbuffer = CutBuffer(selection);
+
+    TRACE(("Cutbuffer: %d, target: %s\n", cutbuffer,
+          (targets
+           ? visibleSelectionTarget(XtDisplay(w), targets[0])
+           : "None")));
+
+    if (cutbuffer >= 0) {
+       int inbytes;
+       unsigned long nbytes;
+       int fmt8 = 8;
+       Atom type = XA_STRING;
+       char *line;
+
+       /* 'line' is freed in SelectionReceived */
+       line = XFetchBuffer(XtDisplay(w), &inbytes, cutbuffer);
+       nbytes = (unsigned long) inbytes;
+
+       if (nbytes > 0)
+           SelectionReceived(w, NULL, &selection, &type, (XtPointer) line,
+                             &nbytes, &fmt8);
+       else if (num_params > 1) {
+           xtermGetSelection(w, ev_time, params + 1, num_params - 1, NULL);
+       }
+#if OPT_PASTE64
+       else {
+           FinishPaste64(xw);
+       }
+#endif
+       return;
+    } else {
+       struct _SelectionList *list;
+
+       if (targets == NULL || targets[0] == None) {
+           targets = _SelectionTargets(w);
+       }
+
+       if (targets != 0) {
+           target = targets[0];
+
+           if (targets[1] == None) {   /* last target in list */
+               params++;
+               num_params--;
+               targets = _SelectionTargets(w);
+           } else {
+               targets = &(targets[1]);
+           }
+
+           if (num_params) {
+               /* 'list' is freed in SelectionReceived */
+               list = TypeXtMalloc(struct _SelectionList);
+               if (list != 0) {
+                   list->params = params;
+                   list->count = num_params;
+                   list->targets = targets;
+                   list->time = ev_time;
+               }
+           } else {
+               list = NULL;
+           }
+
+           XtGetSelectionValue(w, selection,
+                               target,
+                               SelectionReceived,
+                               (XtPointer) list, ev_time);
+       }
+    }
+}
+
+#if OPT_TRACE && OPT_WIDE_CHARS
+static void
+GettingSelection(Display * dpy, Atom type, Char * line, unsigned long len)
+{
+    Char *cp;
+    char *name;
+
+    name = XGetAtomName(dpy, type);
+
+    TRACE(("Getting %s (%ld)\n", name, (long int) type));
+    for (cp = line; cp < line + len; cp++) {
+       TRACE(("[%d:%lu]", (int) (cp + 1 - line), len));
+       if (isprint(*cp)) {
+           TRACE(("%c\n", *cp));
+       } else {
+           TRACE(("\\x%02x\n", *cp));
+       }
+    }
+}
+#else
+#define GettingSelection(dpy,type,line,len)    /* nothing */
+#endif
+
+#ifdef VMS
+#  define tty_vwrite(pty,lag,l)                tt_write(lag,l)
+#else /* !( VMS ) */
+#  define tty_vwrite(pty,lag,l)                v_write(pty,lag,l)
+#endif /* defined VMS */
+
+#if OPT_PASTE64
+/* Return base64 code character given 6-bit number */
+static const char base64_code[] = "\
+ABCDEFGHIJKLMNOPQRSTUVWXYZ\
+abcdefghijklmnopqrstuvwxyz\
+0123456789+/";
+static void
+base64_flush(TScreen * screen)
+{
+    Char x;
+    switch (screen->base64_count) {
+    case 0:
+       break;
+    case 2:
+       x = CharOf(base64_code[screen->base64_accu << 4]);
+       tty_vwrite(screen->respond, &x, 1);
+       break;
+    case 4:
+       x = CharOf(base64_code[screen->base64_accu << 2]);
+       tty_vwrite(screen->respond, &x, 1);
+       break;
+    }
+    if (screen->base64_pad & 3)
+       tty_vwrite(screen->respond,
+                  (const Char *) "===",
+                  (unsigned) (4 - (screen->base64_pad & 3)));
+    screen->base64_count = 0;
+    screen->base64_accu = 0;
+    screen->base64_pad = 0;
+}
+#endif /* OPT_PASTE64 */
+
+static void
+_qWriteSelectionData(TScreen * screen, Char * lag, unsigned length)
+{
+#if OPT_PASTE64
+    if (screen->base64_paste) {
+       /* Send data as base64 */
+       Char *p = lag;
+       Char buf[64];
+       unsigned x = 0;
+       while (length--) {
+           switch (screen->base64_count) {
+           case 0:
+               buf[x++] = CharOf(base64_code[*p >> 2]);
+               screen->base64_accu = (unsigned) (*p & 0x3);
+               screen->base64_count = 2;
+               ++p;
+               break;
+           case 2:
+               buf[x++] = CharOf(base64_code[(screen->base64_accu << 4) +
+                                             (*p >> 4)]);
+               screen->base64_accu = (unsigned) (*p & 0xF);
+               screen->base64_count = 4;
+               ++p;
+               break;
+           case 4:
+               buf[x++] = CharOf(base64_code[(screen->base64_accu << 2) +
+                                             (*p >> 6)]);
+               buf[x++] = CharOf(base64_code[*p & 0x3F]);
+               screen->base64_accu = 0;
+               screen->base64_count = 0;
+               ++p;
+               break;
+           }
+           if (x >= 63) {
+               /* Write 63 or 64 characters */
+               screen->base64_pad += x;
+               tty_vwrite(screen->respond, buf, x);
+               x = 0;
+           }
+       }
+       if (x != 0) {
+           screen->base64_pad += x;
+           tty_vwrite(screen->respond, buf, x);
+       }
+    } else
+#endif /* OPT_PASTE64 */
+#if OPT_READLINE
+    if (SCREEN_FLAG(screen, paste_quotes)) {
+       while (length--) {
+           tty_vwrite(screen->respond, (const Char *) "\026", 1);      /* Control-V */
+           tty_vwrite(screen->respond, lag++, 1);
+       }
+    } else
+#endif
+       tty_vwrite(screen->respond, lag, length);
+}
+
+static void
+_WriteSelectionData(TScreen * screen, Char * line, size_t length)
+{
+    /* Write data to pty a line at a time. */
+    /* Doing this one line at a time may no longer be necessary
+       because v_write has been re-written. */
+
+    Char *lag, *end;
+
+    /* in the VMS version, if tt_pasting isn't set to True then qio
+       reads aren't blocked and an infinite loop is entered, where the
+       pasted text shows up as new input, goes in again, shows up
+       again, ad nauseum. */
+#ifdef VMS
+    tt_pasting = True;
+#endif
+
+    end = &line[length];
+    lag = line;
+
+#if OPT_PASTE64
+    if (screen->base64_paste) {
+       _qWriteSelectionData(screen, lag, (unsigned) (end - lag));
+       base64_flush(screen);
+    } else
+#endif
+    {
+       if (!SCREEN_FLAG(screen, paste_literal_nl)) {
+           Char *cp;
+           for (cp = line; cp != end; cp++) {
+               if (*cp == '\n') {
+                   *cp = '\r';
+                   _qWriteSelectionData(screen, lag, (unsigned) (cp - lag + 1));
+                   lag = cp + 1;
+               }
+           }
+       }
+
+       if (lag != end) {
+           _qWriteSelectionData(screen, lag, (unsigned) (end - lag));
+       }
+    }
+#ifdef VMS
+    tt_pasting = False;
+    tt_start_read();           /* reenable reads or a character may be lost */
+#endif
+}
+
+#if OPT_READLINE
+static void
+_WriteKey(TScreen * screen, const Char * in)
+{
+    Char line[16];
+    unsigned count = 0;
+    size_t length = strlen((const char *) in);
+
+    if (screen->control_eight_bits) {
+       line[count++] = ANSI_CSI;
+    } else {
+       line[count++] = ANSI_ESC;
+       line[count++] = '[';
+    }
+    while (length--)
+       line[count++] = *in++;
+    line[count++] = '~';
+    tty_vwrite(screen->respond, line, count);
+}
+#endif /* OPT_READLINE */
+
+/* SelectionReceived: stuff received selection text into pty */
+
+/* ARGSUSED */
+static void
+SelectionReceived(Widget w,
+                 XtPointer client_data,
+                 Atom * selection GCC_UNUSED,
+                 Atom * type,
+                 XtPointer value,
+                 unsigned long *length,
+                 int *format)
+{
+    char **text_list = NULL;
+    int text_list_count;
+    XTextProperty text_prop;
+    TScreen *screen;
+    Display *dpy;
+#if OPT_TRACE && OPT_WIDE_CHARS
+    Char *line = (Char *) value;
+#endif
+
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) == 0)
+       return;
+
+    screen = TScreenOf(xw);
+    dpy = XtDisplay(w);
+
+    if (*type == 0             /*XT_CONVERT_FAIL */
+       || *length == 0
+       || value == NULL)
+       goto fail;
+
+    text_prop.value = (unsigned char *) value;
+    text_prop.encoding = *type;
+    text_prop.format = *format;
+    text_prop.nitems = *length;
+
+    TRACE(("SelectionReceived %s format %d, nitems %ld\n",
+          visibleSelectionTarget(dpy, text_prop.encoding),
+          text_prop.format,
+          text_prop.nitems));
+
+#if OPT_WIDE_CHARS
+    if (screen->wide_chars) {
+       if (*type == XA_UTF8_STRING(dpy) ||
+           *type == XA_STRING ||
+           *type == XA_COMPOUND_TEXT(dpy)) {
+           GettingSelection(dpy, *type, line, *length);
+           if (Xutf8TextPropertyToTextList(dpy, &text_prop,
+                                           &text_list,
+                                           &text_list_count) < 0) {
+               TRACE(("Conversion failed\n"));
+               text_list = NULL;
+           }
+       }
+    } else
+#endif /* OPT_WIDE_CHARS */
+    {
+       /* Convert the selection to locale's multibyte encoding. */
+
+       if (*type == XA_UTF8_STRING(dpy) ||
+           *type == XA_STRING ||
+           *type == XA_COMPOUND_TEXT(dpy)) {
+           Status rc;
+
+           GettingSelection(dpy, *type, line, *length);
+
+#if OPT_WIDE_CHARS
+           if (*type == XA_UTF8_STRING(dpy) &&
+               !(screen->wide_chars || screen->c1_printable)) {
+               rc = xtermUtf8ToTextList(xw, &text_prop,
+                                        &text_list, &text_list_count);
+           } else
+#endif
+           if (*type == XA_STRING && screen->brokenSelections) {
+               rc = XTextPropertyToStringList(&text_prop,
+                                              &text_list, &text_list_count);
+           } else {
+               rc = XmbTextPropertyToTextList(dpy, &text_prop,
+                                              &text_list,
+                                              &text_list_count);
+           }
+           if (rc < 0) {
+               TRACE(("Conversion failed\n"));
+               text_list = NULL;
+           }
+       }
+    }
+
+    if (text_list != NULL && text_list_count != 0) {
+       int i;
+
+#if OPT_PASTE64
+       if (screen->base64_paste) {
+           /* EMPTY */ ;
+       } else
+#endif
+#if OPT_READLINE
+       if (SCREEN_FLAG(screen, paste_brackets)) {
+           _WriteKey(screen, (const Char *) "200");
+       }
+#endif
+       for (i = 0; i < text_list_count; i++) {
+           size_t len = strlen(text_list[i]);
+           _WriteSelectionData(screen, (Char *) text_list[i], len);
+       }
+#if OPT_PASTE64
+       if (screen->base64_paste) {
+           FinishPaste64(xw);
+       } else
+#endif
+#if OPT_READLINE
+       if (SCREEN_FLAG(screen, paste_brackets)) {
+           _WriteKey(screen, (const Char *) "201");
+       }
+#endif
+       XFreeStringList(text_list);
+    } else
+       goto fail;
+
+    XtFree((char *) client_data);
+    XtFree((char *) value);
+
+    return;
+
+  fail:
+    if (client_data != 0) {
+       struct _SelectionList *list = (struct _SelectionList *) client_data;
+
+       TRACE(("SelectionReceived ->xtermGetSelection\n"));
+       xtermGetSelection(w, list->time,
+                         list->params, list->count, list->targets);
+       XtFree((char *) client_data);
+#if OPT_PASTE64
+    } else {
+       FinishPaste64(xw);
+#endif
+    }
+    return;
+}
+
+void
+HandleInsertSelection(Widget w,
+                     XEvent * event,   /* assumed to be XButtonEvent* */
+                     String * params,  /* selections in precedence order */
+                     Cardinal *num_params)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       if (!SendMousePosition(xw, event)) {
+#if OPT_READLINE
+           int ldelta;
+           TScreen *screen = TScreenOf(xw);
+           if (IsBtnEvent(event)
+           /* Disable on Shift-mouse, including the application-mouse modes */
+               && !(KeyModifiers(event) & ShiftMask)
+               && (screen->send_mouse_pos == MOUSE_OFF)
+               && SCREEN_FLAG(screen, paste_moves)
+               && rowOnCurrentLine(screen, eventRow(screen, event), &ldelta))
+               ReadLineMovePoint(screen, eventColBetween(screen, event), ldelta);
+#endif /* OPT_READLINE */
+
+           xtermGetSelection(w, event->xbutton.time, params, *num_params, NULL);
+       }
+    }
+}
+
+static SelectUnit
+EvalSelectUnit(XtermWidget xw,
+              Time buttonDownTime,
+              SelectUnit defaultUnit,
+              unsigned int button)
+{
+    TScreen *screen = TScreenOf(xw);
+    SelectUnit result;
+    int delta;
+
+    if (button != screen->lastButton) {
+       delta = screen->multiClickTime + 1;
+    } else if (screen->lastButtonUpTime == (Time) 0) {
+       /* first time and once in a blue moon */
+       delta = screen->multiClickTime + 1;
+    } else if (buttonDownTime > screen->lastButtonUpTime) {
+       /* most of the time */
+       delta = (int) (buttonDownTime - screen->lastButtonUpTime);
+    } else {
+       /* time has rolled over since lastButtonUpTime */
+       delta = (int) ((((Time) ~ 0) - screen->lastButtonUpTime) + buttonDownTime);
+    }
+
+    if (delta > screen->multiClickTime) {
+       screen->numberOfClicks = 1;
+       result = defaultUnit;
+    } else {
+       result = screen->selectMap[screen->numberOfClicks % screen->maxClicks];
+       screen->numberOfClicks += 1;
+    }
+    TRACE(("EvalSelectUnit(%d) = %d\n", screen->numberOfClicks, result));
+    return result;
+}
+
+static void
+do_select_start(XtermWidget xw,
+               XEvent * event, /* must be XButtonEvent* */
+               CELL * cell)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (SendMousePosition(xw, event))
+       return;
+    screen->selectUnit = EvalSelectUnit(xw,
+                                       event->xbutton.time,
+                                       Select_CHAR,
+                                       event->xbutton.button);
+    screen->replyToEmacs = False;
+
+#if OPT_READLINE
+    lastButtonDownTime = event->xbutton.time;
+#endif
+
+    StartSelect(xw, cell);
+}
+
+/* ARGSUSED */
+void
+HandleSelectStart(Widget w,
+                 XEvent * event,       /* must be XButtonEvent* */
+                 String * params GCC_UNUSED,
+                 Cardinal *num_params GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       CELL cell;
+
+       screen->firstValidRow = 0;
+       screen->lastValidRow = screen->max_row;
+       PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
+
+#if OPT_READLINE
+       ExtendingSelection = 0;
+#endif
+
+       do_select_start(xw, event, &cell);
+    }
+}
+
+/* ARGSUSED */
+void
+HandleKeyboardSelectStart(Widget w,
+                         XEvent * event,       /* must be XButtonEvent* */
+                         String * params GCC_UNUSED,
+                         Cardinal *num_params GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       do_select_start(xw, event, &screen->cursorp);
+    }
+}
+
+static void
+TrackDown(XtermWidget xw, XButtonEvent * event)
+{
+    TScreen *screen = TScreenOf(xw);
+    CELL cell;
+
+    screen->selectUnit = EvalSelectUnit(xw,
+                                       event->time,
+                                       Select_CHAR,
+                                       event->button);
+    if (screen->numberOfClicks > 1) {
+       PointToCELL(screen, event->y, event->x, &cell);
+       screen->replyToEmacs = True;
+       StartSelect(xw, &cell);
+    } else {
+       screen->waitingForTrackInfo = True;
+       EditorButton(xw, event);
+    }
+}
+
+#define boundsCheck(x) if (x < 0) \
+                           x = 0; \
+                       else if (x >= screen->max_row) \
+                           x = screen->max_row
+
+void
+TrackMouse(XtermWidget xw,
+          int func,
+          CELL * start,
+          int firstrow,
+          int lastrow)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->waitingForTrackInfo) { /* if Timed, ignore */
+       screen->waitingForTrackInfo = False;
+
+       if (func != 0) {
+           CELL first = *start;
+
+           boundsCheck(first.row);
+           boundsCheck(firstrow);
+           boundsCheck(lastrow);
+           screen->firstValidRow = firstrow;
+           screen->lastValidRow = lastrow;
+           screen->replyToEmacs = True;
+           StartSelect(xw, &first);
+       }
+    }
+}
+
+static void
+StartSelect(XtermWidget xw, const CELL * cell)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("StartSelect row=%d, col=%d\n", cell->row, cell->col));
+    if (screen->cursor_state)
+       HideCursor();
+    if (screen->numberOfClicks == 1) {
+       /* set start of selection */
+       screen->rawPos = *cell;
+    }
+    /* else use old values in rawPos */
+    screen->saveStartR = screen->startExt = screen->rawPos;
+    screen->saveEndR = screen->endExt = screen->rawPos;
+    if (Coordinate(screen, cell) < Coordinate(screen, &(screen->rawPos))) {
+       screen->eventMode = LEFTEXTENSION;
+       screen->startExt = *cell;
+    } else {
+       screen->eventMode = RIGHTEXTENSION;
+       screen->endExt = *cell;
+    }
+    ComputeSelect(xw, &(screen->startExt), &(screen->endExt), False);
+}
+
+static void
+EndExtend(XtermWidget xw,
+         XEvent * event,       /* must be XButtonEvent */
+         String * params,      /* selections */
+         Cardinal num_params,
+         Bool use_cursor_loc)
+{
+    CELL cell;
+    unsigned count;
+    TScreen *screen = TScreenOf(xw);
+    Char line[20];
+
+    if (use_cursor_loc) {
+       cell = screen->cursorp;
+    } else {
+       PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
+    }
+    ExtendExtend(xw, &cell);
+    screen->lastButtonUpTime = event->xbutton.time;
+    screen->lastButton = event->xbutton.button;
+    if (!isSameCELL(&(screen->startSel), &(screen->endSel))) {
+       if (screen->replyToEmacs) {
+           count = 0;
+           if (screen->control_eight_bits) {
+               line[count++] = ANSI_CSI;
+           } else {
+               line[count++] = ANSI_ESC;
+               line[count++] = '[';
+           }
+           if (isSameCELL(&(screen->rawPos), &(screen->startSel))
+               && isSameCELL(&cell, &(screen->endSel))) {
+               /* Use short-form emacs select */
+               line[count++] = 't';
+               count = EmitMousePosition(screen, line, count, screen->endSel.col);
+               count = EmitMousePosition(screen, line, count, screen->endSel.row);
+           } else {
+               /* long-form, specify everything */
+               line[count++] = 'T';
+               count = EmitMousePosition(screen, line, count, screen->startSel.col);
+               count = EmitMousePosition(screen, line, count, screen->startSel.row);
+               count = EmitMousePosition(screen, line, count, screen->endSel.col);
+               count = EmitMousePosition(screen, line, count, screen->endSel.row);
+               count = EmitMousePosition(screen, line, count, cell.col);
+               count = EmitMousePosition(screen, line, count, cell.row);
+           }
+           v_write(screen->respond, line, count);
+           TrackText(xw, &zeroCELL, &zeroCELL);
+       }
+    }
+    SelectSet(xw, event, params, num_params);
+    screen->eventMode = NORMAL;
+}
+
+void
+HandleSelectSet(Widget w,
+               XEvent * event,
+               String * params,
+               Cardinal *num_params)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       SelectSet(xw, event, params, *num_params);
+    }
+}
+
+/* ARGSUSED */
+static void
+SelectSet(XtermWidget xw,
+         XEvent * event GCC_UNUSED,
+         String * params,
+         Cardinal num_params)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("SelectSet\n"));
+    /* Only do select stuff if non-null select */
+    if (!isSameCELL(&(screen->startSel), &(screen->endSel))) {
+       SaltTextAway(xw, &(screen->startSel), &(screen->endSel), params, num_params);
+    } else {
+       DisownSelection(xw);
+    }
+}
+
+#define Abs(x)         ((x) < 0 ? -(x) : (x))
+
+/* ARGSUSED */
+static void
+do_start_extend(XtermWidget xw,
+               XEvent * event, /* must be XButtonEvent* */
+               String * params GCC_UNUSED,
+               Cardinal *num_params GCC_UNUSED,
+               Bool use_cursor_loc)
+{
+    TScreen *screen = TScreenOf(xw);
+    int coord;
+    CELL cell;
+
+    if (SendMousePosition(xw, event))
+       return;
+
+    screen->firstValidRow = 0;
+    screen->lastValidRow = screen->max_row;
+#if OPT_READLINE
+    if ((KeyModifiers(event) & ShiftMask)
+       || event->xbutton.button != Button3
+       || !(SCREEN_FLAG(screen, dclick3_deletes)))
+#endif
+       screen->selectUnit = EvalSelectUnit(xw,
+                                           event->xbutton.time,
+                                           screen->selectUnit,
+                                           event->xbutton.button);
+    screen->replyToEmacs = False;
+
+#if OPT_READLINE
+    CheckSecondPress3(screen, event);
+#endif
+
+    if (screen->numberOfClicks == 1
+       || (SCREEN_FLAG(screen, dclick3_deletes)        /* Dclick special */
+           &&!(KeyModifiers(event) & ShiftMask))) {
+       /* Save existing selection so we can reestablish it if the guy
+          extends past the other end of the selection */
+       screen->saveStartR = screen->startExt = screen->startRaw;
+       screen->saveEndR = screen->endExt = screen->endRaw;
+    } else {
+       /* He just needed the selection mode changed, use old values. */
+       screen->startExt = screen->startRaw = screen->saveStartR;
+       screen->endExt = screen->endRaw = screen->saveEndR;
+    }
+    if (use_cursor_loc) {
+       cell = screen->cursorp;
+    } else {
+       PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
+    }
+    coord = Coordinate(screen, &cell);
+
+    if (Abs(coord - Coordinate(screen, &(screen->startSel)))
+       < Abs(coord - Coordinate(screen, &(screen->endSel)))
+       || coord < Coordinate(screen, &(screen->startSel))) {
+       /* point is close to left side of selection */
+       screen->eventMode = LEFTEXTENSION;
+       screen->startExt = cell;
+    } else {
+       /* point is close to left side of selection */
+       screen->eventMode = RIGHTEXTENSION;
+       screen->endExt = cell;
+    }
+    ComputeSelect(xw, &(screen->startExt), &(screen->endExt), True);
+
+#if OPT_READLINE
+    if (!isSameCELL(&(screen->startSel), &(screen->endSel)))
+       ExtendingSelection = 1;
+#endif
+}
+
+static void
+ExtendExtend(XtermWidget xw, const CELL * cell)
+{
+    TScreen *screen = TScreenOf(xw);
+    int coord = Coordinate(screen, cell);
+
+    TRACE(("ExtendExtend row=%d, col=%d\n", cell->row, cell->col));
+    if (screen->eventMode == LEFTEXTENSION
+       && ((coord + (screen->selectUnit != Select_CHAR))
+           > Coordinate(screen, &(screen->endSel)))) {
+       /* Whoops, he's changed his mind.  Do RIGHTEXTENSION */
+       screen->eventMode = RIGHTEXTENSION;
+       screen->startExt = screen->saveStartR;
+    } else if (screen->eventMode == RIGHTEXTENSION
+              && coord < Coordinate(screen, &(screen->startSel))) {
+       /* Whoops, he's changed his mind.  Do LEFTEXTENSION */
+       screen->eventMode = LEFTEXTENSION;
+       screen->endExt = screen->saveEndR;
+    }
+    if (screen->eventMode == LEFTEXTENSION) {
+       screen->startExt = *cell;
+    } else {
+       screen->endExt = *cell;
+    }
+    ComputeSelect(xw, &(screen->startExt), &(screen->endExt), False);
+
+#if OPT_READLINE
+    if (!isSameCELL(&(screen->startSel), &(screen->endSel)))
+       ExtendingSelection = 1;
+#endif
+}
+
+void
+HandleStartExtend(Widget w,
+                 XEvent * event,       /* must be XButtonEvent* */
+                 String * params,      /* unused */
+                 Cardinal *num_params)         /* unused */
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       do_start_extend(xw, event, params, num_params, False);
+    }
+}
+
+void
+HandleKeyboardStartExtend(Widget w,
+                         XEvent * event,       /* must be XButtonEvent* */
+                         String * params,      /* unused */
+                         Cardinal *num_params)         /* unused */
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       do_start_extend(xw, event, params, num_params, True);
+    }
+}
+
+void
+ScrollSelection(TScreen * screen, int amount, Bool always)
+{
+    int minrow = INX2ROW(screen, -screen->savedlines);
+    int maxrow = INX2ROW(screen, screen->max_row);
+    int maxcol = screen->max_col;
+
+#define scroll_update_one(cell) \
+       (cell)->row += amount; \
+       if ((cell)->row < minrow) { \
+           (cell)->row = minrow; \
+           (cell)->col = 0; \
+       } \
+       if ((cell)->row > maxrow) { \
+           (cell)->row = maxrow; \
+           (cell)->col = maxcol; \
+       }
+
+    scroll_update_one(&(screen->startRaw));
+    scroll_update_one(&(screen->endRaw));
+    scroll_update_one(&(screen->startSel));
+    scroll_update_one(&(screen->endSel));
+
+    scroll_update_one(&(screen->rawPos));
+
+    /*
+     * If we are told to scroll the selection but it lies outside the scrolling
+     * margins, then that could cause the selection to move (bad).  It is not
+     * simple to fix, because this function is called both for the scrollbar
+     * actions as well as application scrolling.  The 'always' flag is set in
+     * the former case.  The rest of the logic handles the latter.
+     */
+    if (ScrnHaveSelection(screen)) {
+       int adjust;
+
+       adjust = ROW2INX(screen, screen->startH.row);
+       if (always
+           || !ScrnHaveLineMargins(screen)
+           || ScrnIsLineInMargins(screen, adjust)) {
+           scroll_update_one(&screen->startH);
+       }
+       adjust = ROW2INX(screen, screen->endH.row);
+       if (always
+           || !ScrnHaveLineMargins(screen)
+           || ScrnIsLineInMargins(screen, adjust)) {
+           scroll_update_one(&screen->endH);
+       }
+    }
+
+    screen->startHCoord = Coordinate(screen, &screen->startH);
+    screen->endHCoord = Coordinate(screen, &screen->endH);
+}
+
+/*ARGSUSED*/
+void
+ResizeSelection(TScreen * screen GCC_UNUSED, int rows, int cols)
+{
+    rows--;                    /* decr to get 0-max */
+    cols--;
+
+    if (screen->startRaw.row > rows)
+       screen->startRaw.row = rows;
+    if (screen->startSel.row > rows)
+       screen->startSel.row = rows;
+    if (screen->endRaw.row > rows)
+       screen->endRaw.row = rows;
+    if (screen->endSel.row > rows)
+       screen->endSel.row = rows;
+    if (screen->rawPos.row > rows)
+       screen->rawPos.row = rows;
+
+    if (screen->startRaw.col > cols)
+       screen->startRaw.col = cols;
+    if (screen->startSel.col > cols)
+       screen->startSel.col = cols;
+    if (screen->endRaw.col > cols)
+       screen->endRaw.col = cols;
+    if (screen->endSel.col > cols)
+       screen->endSel.col = cols;
+    if (screen->rawPos.col > cols)
+       screen->rawPos.col = cols;
+}
+
+#if OPT_WIDE_CHARS
+Bool
+iswide(int i)
+{
+    return (i == HIDDEN_CHAR) || (WideCells(i) == 2);
+}
+
+#define isWideCell(row, col) iswide((int)XTERM_CELL(row, col))
+#endif
+
+static void
+PointToCELL(TScreen * screen,
+           int y,
+           int x,
+           CELL * cell)
+/* Convert pixel coordinates to character coordinates.
+   Rows are clipped between firstValidRow and lastValidRow.
+   Columns are clipped between to be 0 or greater, but are not clipped to some
+       maximum value. */
+{
+    cell->row = (y - screen->border) / FontHeight(screen);
+    if (cell->row < screen->firstValidRow)
+       cell->row = screen->firstValidRow;
+    else if (cell->row > screen->lastValidRow)
+       cell->row = screen->lastValidRow;
+    cell->col = (x - OriginX(screen)) / FontWidth(screen);
+    if (cell->col < 0)
+       cell->col = 0;
+    else if (cell->col > MaxCols(screen)) {
+       cell->col = MaxCols(screen);
+    }
+#if OPT_WIDE_CHARS
+    /*
+     * If we got a click on the right half of a doublewidth character,
+     * pretend it happened on the left half.
+     */
+    if (cell->col > 0
+       && isWideCell(cell->row, cell->col - 1)
+       && (XTERM_CELL(cell->row, cell->col) == HIDDEN_CHAR)) {
+       cell->col -= 1;
+    }
+#endif
+}
+
+/*
+ * Find the last column at which text was drawn on the given row.
+ */
+static int
+LastTextCol(TScreen * screen, LineData * ld, int row)
+{
+    int i = -1;
+    Char *ch;
+
+    if (ld != 0) {
+       if (okScrnRow(screen, row)) {
+           for (i = screen->max_col,
+                ch = ld->attribs + i;
+                i >= 0 && !(*ch & CHARDRAWN);
+                ch--, i--) {
+               ;
+           }
+#if OPT_DEC_CHRSET
+           if (CSET_DOUBLE(GetLineDblCS(ld))) {
+               i *= 2;
+           }
+#endif
+       }
+    }
+    return (i);
+}
+
+#if !OPT_WIDE_CHARS
+/*
+** double click table for cut and paste in 8 bits
+**
+** This table is divided in four parts :
+**
+**     - control characters    [0,0x1f] U [0x80,0x9f]
+**     - separators            [0x20,0x3f] U [0xa0,0xb9]
+**     - binding characters    [0x40,0x7f] U [0xc0,0xff]
+**     - exceptions
+*/
+/* *INDENT-OFF* */
+static int charClass[256] =
+{
+/* NUL  SOH  STX  ETX  EOT  ENQ  ACK  BEL */
+    32,  1,    1,   1,   1,   1,   1,   1,
+/*  BS   HT   NL   VT   NP   CR   SO   SI */
+     1,  32,   1,   1,   1,   1,   1,   1,
+/* DLE  DC1  DC2  DC3  DC4  NAK  SYN  ETB */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/* CAN   EM  SUB  ESC   FS   GS   RS   US */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/*  SP    !    "    #    $    %    &    ' */
+    32,  33,  34,  35,  36,  37,  38,  39,
+/*   (    )    *    +    ,    -    .    / */
+    40,  41,  42,  43,  44,  45,  46,  47,
+/*   0    1    2    3    4    5    6    7 */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/*   8    9    :    ;    <    =    >    ? */
+    48,  48,  58,  59,  60,  61,  62,  63,
+/*   @    A    B    C    D    E    F    G */
+    64,  48,  48,  48,  48,  48,  48,  48,
+/*   H    I    J    K    L    M    N    O */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/*   P    Q    R    S    T    U    V    W */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/*   X    Y    Z    [    \    ]    ^    _ */
+    48,  48,  48,  91,  92,  93,  94,  48,
+/*   `    a    b    c    d    e    f    g */
+    96,  48,  48,  48,  48,  48,  48,  48,
+/*   h    i    j    k    l    m    n    o */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/*   p    q    r    s    t    u    v    w */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/*   x    y    z    {    |    }    ~  DEL */
+    48,  48,  48, 123, 124, 125, 126,   1,
+/* x80  x81  x82  x83  IND  NEL  SSA  ESA */
+    1,    1,   1,   1,   1,   1,   1,   1,
+/* HTS  HTJ  VTS  PLD  PLU   RI  SS2  SS3 */
+    1,    1,   1,   1,   1,   1,   1,   1,
+/* DCS  PU1  PU2  STS  CCH   MW  SPA  EPA */
+    1,    1,   1,   1,   1,   1,   1,   1,
+/* x98  x99  x9A  CSI   ST  OSC   PM  APC */
+    1,    1,   1,   1,   1,   1,   1,   1,
+/*   -    i   c/    L   ox   Y-    |   So */
+    160, 161, 162, 163, 164, 165, 166, 167,
+/*  ..   c0   ip   <<    _        R0    - */
+    168, 169, 170, 171, 172, 173, 174, 175,
+/*   o   +-    2    3    '    u   q|    . */
+    176, 177, 178, 179, 180, 181, 182, 183,
+/*   ,    1    2   >>  1/4  1/2  3/4    ? */
+    184, 185, 186, 187, 188, 189, 190, 191,
+/*  A`   A'   A^   A~   A:   Ao   AE   C, */
+     48,  48,  48,  48,  48,  48,  48,  48,
+/*  E`   E'   E^   E:   I`   I'   I^   I: */
+     48,  48,  48,  48,  48,  48,  48,  48,
+/*  D-   N~   O`   O'   O^   O~   O:    X */
+     48,  48,  48,  48,  48,  48,  48, 215,
+/*  O/   U`   U'   U^   U:   Y'    P    B */
+     48,  48,  48,  48,  48,  48,  48,  48,
+/*  a`   a'   a^   a~   a:   ao   ae   c, */
+     48,  48,  48,  48,  48,  48,  48,  48,
+/*  e`   e'   e^   e:    i`  i'   i^   i: */
+     48,  48,  48,  48,  48,  48,  48,  48,
+/*   d   n~   o`   o'   o^   o~   o:   -: */
+     48,  48,  48,  48,  48,  48,  48, 247,
+/*  o/   u`   u'   u^   u:   y'    P   y: */
+     48,  48,  48,  48,  48,  48,  48,  48};
+/* *INDENT-ON* */
+
+int
+SetCharacterClassRange(int low,        /* in range of [0..255] */
+                      int high,
+                      int value)       /* arbitrary */
+{
+
+    if (low < 0 || high > 255 || high < low)
+       return (-1);
+
+    for (; low <= high; low++)
+       charClass[low] = value;
+
+    return (0);
+}
+#endif
+
+static int
+class_of(LineData * ld, CELL * cell)
+{
+    CELL temp = *cell;
+
+#if OPT_DEC_CHRSET
+    if (CSET_DOUBLE(GetLineDblCS(ld))) {
+       temp.col /= 2;
+    }
+#endif
+
+    assert(temp.col < ld->lineSize);
+    return CharacterClass((int) (ld->charData[temp.col]));
+}
+
+#if OPT_WIDE_CHARS
+#define CClassSelects(name, cclass) \
+        (CClassOf(name) == cclass \
+        || XTERM_CELL(screen->name.row, screen->name.col) == HIDDEN_CHAR)
+#else
+#define CClassSelects(name, cclass) \
+        (class_of(ld.name, &((screen->name))) == cclass)
+#endif
+
+#define CClassOf(name) class_of(ld.name, &((screen->name)))
+
+/*
+ * If the given column is past the end of text on the given row, bump to the
+ * beginning of the next line.
+ */
+static Boolean
+okPosition(TScreen * screen,
+          LineData ** ld,
+          CELL * cell)
+{
+    Boolean result = True;
+
+    if (cell->row > screen->max_row) {
+       result = False;
+    } else if (cell->col > (LastTextCol(screen, *ld, cell->row) + 1)) {
+       if (cell->row < screen->max_row) {
+           cell->col = 0;
+           *ld = GET_LINEDATA(screen, ++cell->row);
+           result = False;
+       }
+    }
+    return result;
+}
+
+static void
+trimLastLine(TScreen * screen,
+            LineData ** ld,
+            CELL * last)
+{
+    if (screen->cutNewline && last->row < screen->max_row) {
+       last->col = 0;
+       *ld = GET_LINEDATA(screen, ++last->row);
+    } else {
+       last->col = LastTextCol(screen, *ld, last->row) + 1;
+    }
+}
+
+#if OPT_SELECT_REGEX
+/*
+ * Returns the first row of a wrapped line.
+ */
+static int
+firstRowOfLine(TScreen * screen, int row, Bool visible)
+{
+    LineData *ld = 0;
+    int limit = visible ? 0 : -screen->savedlines;
+
+    while (row > limit &&
+          (ld = GET_LINEDATA(screen, row - 1)) != 0 &&
+          LineTstWrapped(ld)) {
+       --row;
+    }
+    return row;
+}
+
+/*
+ * Returns the last row of a wrapped line.
+ */
+static int
+lastRowOfLine(TScreen * screen, int row)
+{
+    LineData *ld;
+
+    while (row < screen->max_row &&
+          (ld = GET_LINEDATA(screen, row)) != 0 &&
+          LineTstWrapped(ld)) {
+       ++row;
+    }
+    return row;
+}
+
+/*
+ * Returns the number of cells on the range of rows.
+ */
+static unsigned
+lengthOfLines(TScreen * screen, int firstRow, int lastRow)
+{
+    unsigned length = 0;
+    int n;
+
+    for (n = firstRow; n <= lastRow; ++n) {
+       LineData *ld = GET_LINEDATA(screen, n);
+       int value = LastTextCol(screen, ld, n);
+       if (value >= 0)
+           length += (unsigned) (value + 1);
+    }
+    return length;
+}
+
+/*
+ * Make a copy of the wrapped-line which corresponds to the given row as a
+ * string of bytes.  Construct an index for the columns from the beginning of
+ * the line.
+ */
+static char *
+make_indexed_text(TScreen * screen, int row, unsigned length, int *indexed)
+{
+    Char *result = 0;
+    size_t need = (length + 1);
+
+    /*
+     * Get a quick upper bound to the number of bytes needed, if the whole
+     * string were UTF-8.
+     */
+    if_OPT_WIDE_CHARS(screen, {
+       need *= ((screen->lineExtra + 1) * 6);
+    });
+
+    if ((result = TypeCallocN(Char, need + 1)) != 0) {
+       LineData *ld = GET_LINEDATA(screen, row);
+       unsigned used = 0;
+       Char *last = result;
+
+       do {
+           int col = 0;
+           int limit = LastTextCol(screen, ld, row);
+
+           while (col <= limit) {
+               Char *next = last;
+               unsigned data = ld->charData[col];
+
+               assert(col < ld->lineSize);
+               /* some internal points may not be drawn */
+               if (data == 0)
+                   data = ' ';
+
+               if_WIDE_OR_NARROW(screen, {
+                   next = convertToUTF8(last, data);
+               }
+               , {
+                   *next++ = CharOf(data);
+               });
+
+               if_OPT_WIDE_CHARS(screen, {
+                   size_t off;
+                   for_each_combData(off, ld) {
+                       data = ld->combData[off][col];
+                       if (data == 0)
+                           break;
+                       next = convertToUTF8(next, data);
+                   }
+               });
+
+               indexed[used] = (int) (last - result);
+               *next = 0;
+               /* TRACE(("index[%d.%d] %d:%s\n", row, used, indexed[used], last)); */
+               last = next;
+               ++used;
+               ++col;
+               indexed[used] = (int) (next - result);
+           }
+       } while (used < length &&
+                LineTstWrapped(ld) &&
+                (ld = GET_LINEDATA(screen, ++row)) != 0 &&
+                row < screen->max_row);
+    }
+    /* TRACE(("result:%s\n", result)); */
+    return (char *) result;
+}
+
+/*
+ * Find the column given an offset into the character string by using the
+ * index constructed in make_indexed_text().
+ */
+static int
+indexToCol(int *indexed, int len, int off)
+{
+    int col = 0;
+    while (indexed[col] < len) {
+       if (indexed[col] >= off)
+           break;
+       ++col;
+    }
+    return col;
+}
+
+/*
+ * Given a row number, and a column offset from that (which may be wrapped),
+ * set the cell to the actual row/column values.
+ */
+static void
+columnToCell(TScreen * screen, int row, int col, CELL * cell)
+{
+    while (row < screen->max_row) {
+       LineData *ld = GET_LINEDATA(screen, row);
+       int last = LastTextCol(screen, ld, row);
+
+       /* TRACE(("last(%d) = %d, have %d\n", row, last, col)); */
+       if (col <= last) {
+           break;
+       }
+       /*
+        * Stop if the current row does not wrap (does not continue the current
+        * line).
+        */
+       if (!LineTstWrapped(ld)) {
+           col = last + 1;
+           break;
+       }
+       col -= (last + 1);
+       ++row;
+    }
+    if (col < 0)
+       col = 0;
+    cell->row = row;
+    cell->col = col;
+}
+
+/*
+ * Given a cell, find the corresponding column offset.
+ */
+static int
+cellToColumn(TScreen * screen, CELL * cell)
+{
+    LineData *ld = 0;
+    int col = cell->col;
+    int row = firstRowOfLine(screen, cell->row, False);
+    while (row < cell->row) {
+       ld = GET_LINEDATA(screen, row);
+       col += LastTextCol(screen, ld, row++);
+    }
+#if OPT_DEC_CHRSET
+    if (ld == 0)
+       ld = GET_LINEDATA(screen, row);
+    if (CSET_DOUBLE(GetLineDblCS(ld)))
+       col /= 2;
+#endif
+    return col;
+}
+
+static void
+do_select_regex(TScreen * screen, CELL * startc, CELL * endc)
+{
+    LineData *ld = GET_LINEDATA(screen, startc->row);
+    int inx = ((screen->numberOfClicks - 1) % screen->maxClicks);
+    char *expr = screen->selectExpr[inx];
+    regex_t preg;
+    regmatch_t match;
+    char *search;
+    int *indexed;
+
+    TRACE(("Select_REGEX:%s\n", NonNull(expr)));
+    if (okPosition(screen, &ld, startc) && expr != 0) {
+       if (regcomp(&preg, expr, REG_EXTENDED) == 0) {
+           int firstRow = firstRowOfLine(screen, startc->row, True);
+           int lastRow = lastRowOfLine(screen, firstRow);
+           unsigned size = lengthOfLines(screen, firstRow, lastRow);
+           int actual = cellToColumn(screen, startc);
+
+           TRACE(("regcomp ok rows %d..%d bytes %d\n",
+                  firstRow, lastRow, size));
+
+           if ((indexed = TypeCallocN(int, size + 1)) != 0) {
+               if ((search = make_indexed_text(screen,
+                                               firstRow,
+                                               size,
+                                               indexed)) != 0) {
+                   int len = (int) strlen(search);
+                   int col;
+                   int best_col = -1;
+                   int best_len = -1;
+
+                   for (col = 0; indexed[col] < len; ++col) {
+                       if (regexec(&preg,
+                                   search + indexed[col],
+                                   (size_t) 1, &match, 0) == 0) {
+                           int start_inx = match.rm_so + indexed[col];
+                           int finis_inx = match.rm_eo + indexed[col];
+                           int start_col = indexToCol(indexed, len, start_inx);
+                           int finis_col = indexToCol(indexed, len, finis_inx);
+
+                           if (start_col <= actual &&
+                               actual < finis_col) {
+                               int test = finis_col - start_col;
+                               if (best_len < test) {
+                                   best_len = test;
+                                   best_col = start_col;
+                                   TRACE(("match column %d len %d\n",
+                                          best_col,
+                                          best_len));
+                               }
+                           }
+                       }
+                   }
+                   if (best_col >= 0) {
+                       int best_nxt = best_col + best_len;
+                       columnToCell(screen, firstRow, best_col, startc);
+                       columnToCell(screen, firstRow, best_nxt, endc);
+                       TRACE(("search::%s\n", search));
+                       TRACE(("indexed:%d..%d -> %d..%d\n",
+                              best_col, best_nxt,
+                              indexed[best_col],
+                              indexed[best_nxt]));
+                       TRACE(("matched:%d:%s\n",
+                              indexed[best_nxt] + 1 -
+                              indexed[best_col],
+                              visibleChars((Char *) (search + indexed[best_col]),
+                                           (unsigned) (indexed[best_nxt] +
+                                                       1 -
+                                                       indexed[best_col]))));
+                   }
+                   free(search);
+               }
+               free(indexed);
+#if OPT_DEC_CHRSET
+               if ((ld = GET_LINEDATA(screen, startc->row)) != 0) {
+                   if (CSET_DOUBLE(GetLineDblCS(ld)))
+                       startc->col *= 2;
+               }
+               if ((ld = GET_LINEDATA(screen, endc->row)) != 0) {
+                   if (CSET_DOUBLE(GetLineDblCS(ld)))
+                       endc->col *= 2;
+               }
+#endif
+           }
+           regfree(&preg);
+       }
+    }
+}
+#endif /* OPT_SELECT_REGEX */
+
+#define InitRow(name) \
+       ld.name = GET_LINEDATA(screen, screen->name.row)
+
+#define NextRow(name) \
+       ld.name = GET_LINEDATA(screen, ++screen->name.row)
+
+#define PrevRow(name) \
+       ld.name = GET_LINEDATA(screen, --screen->name.row)
+
+#define MoreRows(name) \
+       (screen->name.row < screen->max_row)
+
+#define isPrevWrapped(name) \
+       (screen->name.row > 0 \
+          && (ltmp = GET_LINEDATA(screen, screen->name.row - 1)) != 0 \
+          && LineTstWrapped(ltmp))
+
+/*
+ * sets startSel endSel
+ * ensuring that they have legal values
+ */
+static void
+ComputeSelect(XtermWidget xw,
+             CELL * startc,
+             CELL * endc,
+             Bool extend)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    int length;
+    int cclass;
+    CELL first = *startc;
+    CELL last = *endc;
+    Boolean ignored = False;
+
+    struct {
+       LineData *startSel;
+       LineData *endSel;
+    } ld;
+    LineData *ltmp;
+
+    TRACE(("ComputeSelect(startRow=%d, startCol=%d, endRow=%d, endCol=%d, %sextend)\n",
+          first.row, first.col,
+          last.row, last.col,
+          extend ? "" : "no"));
+
+#if OPT_WIDE_CHARS
+    if (first.col > 1
+       && isWideCell(first.row, first.col - 1)
+       && XTERM_CELL(first.row, first.col - 0) == HIDDEN_CHAR) {
+       TRACE(("Adjusting start. Changing downwards from %i.\n", first.col));
+       first.col -= 1;
+       if (last.col == (first.col + 1))
+           last.col--;
+    }
+
+    if (last.col > 1
+       && isWideCell(last.row, last.col - 1)
+       && XTERM_CELL(last.row, last.col) == HIDDEN_CHAR) {
+       last.col += 1;
+    }
+#endif
+
+    if (Coordinate(screen, &first) <= Coordinate(screen, &last)) {
+       screen->startSel = screen->startRaw = first;
+       screen->endSel = screen->endRaw = last;
+    } else {                   /* Swap them */
+       screen->startSel = screen->startRaw = last;
+       screen->endSel = screen->endRaw = first;
+    }
+
+    InitRow(startSel);
+    InitRow(endSel);
+
+    switch (screen->selectUnit) {
+    case Select_CHAR:
+       (void) okPosition(screen, &(ld.startSel), &(screen->startSel));
+       (void) okPosition(screen, &(ld.endSel), &(screen->endSel));
+       break;
+
+    case Select_WORD:
+       TRACE(("Select_WORD\n"));
+       if (okPosition(screen, &(ld.startSel), &(screen->startSel))) {
+           cclass = CClassOf(startSel);
+           do {
+               --screen->startSel.col;
+               if (screen->startSel.col < 0
+                   && isPrevWrapped(startSel)) {
+                   PrevRow(startSel);
+                   screen->startSel.col = LastTextCol(screen, ld.startSel, screen->startSel.row);
+               }
+           } while (screen->startSel.col >= 0
+                    && CClassSelects(startSel, cclass));
+           ++screen->startSel.col;
+       }
+#if OPT_WIDE_CHARS
+       if (screen->startSel.col
+           && XTERM_CELL(screen->startSel.row,
+                         screen->startSel.col) == HIDDEN_CHAR)
+           screen->startSel.col++;
+#endif
+
+       if (okPosition(screen, &(ld.endSel), &(screen->endSel))) {
+           length = LastTextCol(screen, ld.endSel, screen->endSel.row);
+           cclass = CClassOf(endSel);
+           do {
+               ++screen->endSel.col;
+               if (screen->endSel.col > length
+                   && LineTstWrapped(ld.endSel)) {
+                   if (!MoreRows(endSel))
+                       break;
+                   screen->endSel.col = 0;
+                   NextRow(endSel);
+                   length = LastTextCol(screen, ld.endSel, screen->endSel.row);
+               }
+           } while (screen->endSel.col <= length
+                    && CClassSelects(endSel, cclass));
+           /* Word-select selects if pointing to any char in "word",
+            * especially note that it includes the last character in a word.
+            * So we do no --endSel.col and do special eol handling.
+            */
+           if (screen->endSel.col > length + 1
+               && MoreRows(endSel)) {
+               screen->endSel.col = 0;
+               NextRow(endSel);
+           }
+       }
+#if OPT_WIDE_CHARS
+       if (screen->endSel.col
+           && XTERM_CELL(screen->endSel.row,
+                         screen->endSel.col) == HIDDEN_CHAR)
+           screen->endSel.col++;
+#endif
+
+       screen->saveStartW = screen->startSel;
+       break;
+
+    case Select_LINE:
+       TRACE(("Select_LINE\n"));
+       while (LineTstWrapped(ld.endSel)
+              && MoreRows(endSel)) {
+           NextRow(endSel);
+       }
+       if (screen->cutToBeginningOfLine
+           || screen->startSel.row < screen->saveStartW.row) {
+           screen->startSel.col = 0;
+           while (isPrevWrapped(startSel)) {
+               PrevRow(startSel);
+           }
+       } else if (!extend) {
+           if ((first.row < screen->saveStartW.row)
+               || (isSameRow(&first, &(screen->saveStartW))
+                   && first.col < screen->saveStartW.col)) {
+               screen->startSel.col = 0;
+               while (isPrevWrapped(startSel)) {
+                   PrevRow(startSel);
+               }
+           } else {
+               screen->startSel = screen->saveStartW;
+           }
+       }
+       trimLastLine(screen, &(ld.endSel), &(screen->endSel));
+       break;
+
+    case Select_GROUP:         /* paragraph */
+       TRACE(("Select_GROUP\n"));
+       if (okPosition(screen, &(ld.startSel), &(screen->startSel))) {
+           /* scan backward for beginning of group */
+           while (screen->startSel.row > 0 &&
+                  (LastTextCol(screen, ld.startSel, screen->startSel.row -
+                               1) > 0 ||
+                   isPrevWrapped(startSel))) {
+               PrevRow(startSel);
+           }
+           screen->startSel.col = 0;
+           /* scan forward for end of group */
+           while (MoreRows(endSel) &&
+                  (LastTextCol(screen, ld.endSel, screen->endSel.row + 1) >
+                   0 ||
+                   LineTstWrapped(ld.endSel))) {
+               NextRow(endSel);
+           }
+           trimLastLine(screen, &(ld.endSel), &(screen->endSel));
+       }
+       break;
+
+    case Select_PAGE:          /* everything one can see */
+       TRACE(("Select_PAGE\n"));
+       screen->startSel.row = 0;
+       screen->startSel.col = 0;
+       screen->endSel.row = MaxRows(screen);
+       screen->endSel.col = 0;
+       break;
+
+    case Select_ALL:           /* counts scrollback if in normal screen */
+       TRACE(("Select_ALL\n"));
+       screen->startSel.row = -screen->savedlines;
+       screen->startSel.col = 0;
+       screen->endSel.row = MaxRows(screen);
+       screen->endSel.col = 0;
+       break;
+
+#if OPT_SELECT_REGEX
+    case Select_REGEX:
+       do_select_regex(screen, &(screen->startSel), &(screen->endSel));
+       break;
+#endif
+
+    case NSELECTUNITS:         /* always ignore */
+       ignored = True;
+       break;
+    }
+
+    if (!ignored) {
+       /* check boundaries */
+       ScrollSelection(screen, 0, False);
+       TrackText(xw, &(screen->startSel), &(screen->endSel));
+    }
+
+    return;
+}
+
+/* Guaranteed (first.row, first.col) <= (last.row, last.col) */
+static void
+TrackText(XtermWidget xw,
+         const CELL * firstp,
+         const CELL * lastp)
+{
+    TScreen *screen = TScreenOf(xw);
+    int from, to;
+    CELL old_start, old_end;
+    CELL first = *firstp;
+    CELL last = *lastp;
+
+    TRACE(("TrackText(first=%d,%d, last=%d,%d)\n",
+          first.row, first.col, last.row, last.col));
+
+    old_start = screen->startH;
+    old_end = screen->endH;
+    if (isSameCELL(&first, &old_start) &&
+       isSameCELL(&last, &old_end))
+       return;
+    screen->startH = first;
+    screen->endH = last;
+    from = Coordinate(screen, &screen->startH);
+    to = Coordinate(screen, &screen->endH);
+    if (to <= screen->startHCoord || from > screen->endHCoord) {
+       /* No overlap whatsoever between old and new hilite */
+       ReHiliteText(xw, &old_start, &old_end);
+       ReHiliteText(xw, &first, &last);
+    } else {
+       if (from < screen->startHCoord) {
+           /* Extend left end */
+           ReHiliteText(xw, &first, &old_start);
+       } else if (from > screen->startHCoord) {
+           /* Shorten left end */
+           ReHiliteText(xw, &old_start, &first);
+       }
+       if (to > screen->endHCoord) {
+           /* Extend right end */
+           ReHiliteText(xw, &old_end, &last);
+       } else if (to < screen->endHCoord) {
+           /* Shorten right end */
+           ReHiliteText(xw, &last, &old_end);
+       }
+    }
+    screen->startHCoord = from;
+    screen->endHCoord = to;
+}
+
+/* Guaranteed that (first->row, first->col) <= (last->row, last->col) */
+static void
+ReHiliteText(XtermWidget xw,
+            CELL * firstp,
+            CELL * lastp)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i;
+    CELL first = *firstp;
+    CELL last = *lastp;
+
+    TRACE(("ReHiliteText from %d.%d to %d.%d\n",
+          first.row, first.col, last.row, last.col));
+
+    if (first.row < 0)
+       first.row = first.col = 0;
+    else if (first.row > screen->max_row)
+       return;                 /* nothing to do, since last.row >= first.row */
+
+    if (last.row < 0)
+       return;                 /* nothing to do, since first.row <= last.row */
+    else if (last.row > screen->max_row) {
+       last.row = screen->max_row;
+       last.col = MaxCols(screen);
+    }
+    if (isSameCELL(&first, &last))
+       return;
+
+    if (!isSameRow(&first, &last)) {   /* do multiple rows */
+       if ((i = screen->max_col - first.col + 1) > 0) {        /* first row */
+           ScrnRefresh(xw, first.row, first.col, 1, i, True);
+       }
+       if ((i = last.row - first.row - 1) > 0) {       /* middle rows */
+           ScrnRefresh(xw, first.row + 1, 0, i, MaxCols(screen), True);
+       }
+       if (last.col > 0 && last.row <= screen->max_row) {      /* last row */
+           ScrnRefresh(xw, last.row, 0, 1, last.col, True);
+       }
+    } else {                   /* do single row */
+       ScrnRefresh(xw, first.row, first.col, 1, last.col - first.col, True);
+    }
+}
+
+/*
+ * Guaranteed that (cellc->row, cellc->col) <= (cell->row, cell->col), and that both points are valid
+ * (may have cell->row = screen->max_row+1, cell->col = 0).
+ */
+static void
+SaltTextAway(XtermWidget xw,
+            CELL * cellc,
+            CELL * cell,
+            String * params,   /* selections */
+            Cardinal num_params)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i, j = 0;
+    int eol;
+    int tmp;
+    Char *line;
+    Char *lp;
+    CELL first = *cellc;
+    CELL last = *cell;
+
+    if (isSameRow(&first, &last) && first.col > last.col) {
+       EXCHANGE(first.col, last.col, tmp);
+    }
+
+    --last.col;
+    /* first we need to know how long the string is before we can save it */
+
+    if (isSameRow(&last, &first)) {
+       j = Length(screen, first.row, first.col, last.col);
+    } else {                   /* two cases, cut is on same line, cut spans multiple lines */
+       j += Length(screen, first.row, first.col, screen->max_col) + 1;
+       for (i = first.row + 1; i < last.row; i++)
+           j += Length(screen, i, 0, screen->max_col) + 1;
+       if (last.col >= 0)
+           j += Length(screen, last.row, 0, last.col);
+    }
+
+    /* UTF-8 may require more space */
+    if_OPT_WIDE_CHARS(screen, {
+       j *= 4;
+    });
+
+    /* now get some memory to save it in */
+
+    if (screen->selection_size <= j) {
+       if ((line = (Char *) malloc((size_t) j + 1)) == 0)
+           SysError(ERROR_BMALLOC2);
+       XtFree((char *) screen->selection_data);
+       screen->selection_data = line;
+       screen->selection_size = j + 1;
+    } else {
+       line = screen->selection_data;
+    }
+
+    if ((line == 0)
+       || (j < 0))
+       return;
+
+    line[j] = '\0';            /* make sure it is null terminated */
+    lp = line;                 /* lp points to where to save the text */
+    if (isSameRow(&last, &first)) {
+       lp = SaveText(screen, last.row, first.col, last.col, lp, &eol);
+    } else {
+       lp = SaveText(screen, first.row, first.col, screen->max_col, lp, &eol);
+       if (eol)
+           *lp++ = '\n';       /* put in newline at end of line */
+       for (i = first.row + 1; i < last.row; i++) {
+           lp = SaveText(screen, i, 0, screen->max_col, lp, &eol);
+           if (eol)
+               *lp++ = '\n';
+       }
+       if (last.col >= 0)
+           lp = SaveText(screen, last.row, 0, last.col, lp, &eol);
+    }
+    *lp = '\0';                        /* make sure we have end marked */
+
+    TRACE(("Salted TEXT:%d:%s\n", (int) (lp - line),
+          visibleChars(line, (unsigned) (lp - line))));
+
+    screen->selection_length = (unsigned long) (lp - line);
+    _OwnSelection(xw, params, num_params);
+}
+
+#if OPT_PASTE64
+void
+ClearSelectionBuffer(TScreen * screen)
+{
+    screen->selection_length = 0;
+    screen->base64_count = 0;
+}
+
+static void
+AppendStrToSelectionBuffer(TScreen * screen, Char * text, size_t len)
+{
+    if (len != 0) {
+       int j = (int) (screen->selection_length + len);         /* New length */
+       int k = j + (j >> 2) + 80;      /* New size if we grow buffer: grow by ~50% */
+       if (j + 1 >= screen->selection_size) {
+           if (!screen->selection_length) {
+               /* New buffer */
+               Char *line;
+               if ((line = (Char *) malloc((size_t) k)) == 0)
+                   SysError(ERROR_BMALLOC2);
+               XtFree((char *) screen->selection_data);
+               screen->selection_data = line;
+           } else {
+               /* Realloc buffer */
+               screen->selection_data = (Char *)
+                   realloc(screen->selection_data,
+                           (size_t) k);
+               if (screen->selection_data == 0)
+                   SysError(ERROR_BMALLOC2);
+           }
+           screen->selection_size = k;
+       }
+       if (screen->selection_data != 0) {
+           memcpy(screen->selection_data + screen->selection_length, text, len);
+           screen->selection_length += len;
+           screen->selection_data[screen->selection_length] = 0;
+       }
+    }
+}
+
+void
+AppendToSelectionBuffer(TScreen * screen, unsigned c)
+{
+    unsigned six;
+    Char ch;
+
+    /* Decode base64 character */
+    if (c >= 'A' && c <= 'Z')
+       six = c - 'A';
+    else if (c >= 'a' && c <= 'z')
+       six = c - 'a' + 26;
+    else if (c >= '0' && c <= '9')
+       six = c - '0' + 52;
+    else if (c == '+')
+       six = 62;
+    else if (c == '/')
+       six = 63;
+    else
+       return;
+
+    /* Accumulate bytes */
+    switch (screen->base64_count) {
+    case 0:
+       screen->base64_accu = six;
+       screen->base64_count = 6;
+       break;
+
+    case 2:
+       ch = CharOf((screen->base64_accu << 6) + six);
+       screen->base64_count = 0;
+       AppendStrToSelectionBuffer(screen, &ch, (size_t) 1);
+       break;
+
+    case 4:
+       ch = CharOf((screen->base64_accu << 4) + (six >> 2));
+       screen->base64_accu = (six & 0x3);
+       screen->base64_count = 2;
+       AppendStrToSelectionBuffer(screen, &ch, (size_t) 1);
+       break;
+
+    case 6:
+       ch = CharOf((screen->base64_accu << 2) + (six >> 4));
+       screen->base64_accu = (six & 0xF);
+       screen->base64_count = 4;
+       AppendStrToSelectionBuffer(screen, &ch, (size_t) 1);
+       break;
+    }
+}
+
+void
+CompleteSelection(XtermWidget xw, String * args, Cardinal len)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    screen->base64_count = 0;
+    screen->base64_accu = 0;
+    _OwnSelection(xw, args, len);
+}
+#endif /* OPT_PASTE64 */
+
+static Bool
+_ConvertSelectionHelper(Widget w,
+                       Atom * type,
+                       XtPointer *value,
+                       unsigned long *length,
+                       int *format,
+                       int (*conversion_function) (Display *,
+                                                   char **, int,
+                                                   XICCEncodingStyle,
+                                                   XTextProperty *),
+                       XICCEncodingStyle conversion_style)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       Display *dpy = XtDisplay(w);
+       XTextProperty textprop;
+       char *the_data = (char *) screen->selection_data;
+
+       if (conversion_function(dpy, &the_data, 1,
+                               conversion_style,
+                               &textprop) >= Success) {
+           *value = (XtPointer) textprop.value;
+           *length = textprop.nitems;
+           *type = textprop.encoding;
+           *format = textprop.format;
+           return True;
+       }
+    }
+    return False;
+}
+
+static Boolean
+SaveConvertedLength(XtPointer *target, unsigned long source)
+{
+    Boolean result = False;
+
+    *target = XtMalloc(4);
+    if (*target != 0) {
+       result = True;
+       if (sizeof(unsigned long) == 4) {
+           *(unsigned long *) *target = source;
+       } else if (sizeof(unsigned) == 4) {
+           *(unsigned *) *target = (unsigned) source;
+       } else if (sizeof(unsigned short) == 4) {
+           *(unsigned short *) *target = (unsigned short) source;
+       } else {
+           /* FIXME - does this depend on byte-order? */
+           unsigned long temp = source;
+           memcpy((char *) *target,
+                  ((char *) &temp) + sizeof(temp) - 4,
+                  (size_t) 4);
+       }
+    }
+    return result;
+}
+
+static Boolean
+ConvertSelection(Widget w,
+                Atom * selection,
+                Atom * target,
+                Atom * type,
+                XtPointer *value,
+                unsigned long *length,
+                int *format)
+{
+    Display *dpy = XtDisplay(w);
+    TScreen *screen;
+    Bool result = False;
+
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) == 0)
+       return False;
+
+    screen = TScreenOf(xw);
+
+    if (screen->selection_data == NULL)
+       return False;           /* can this happen? */
+
+    TRACE(("ConvertSelection %s\n",
+          visibleSelectionTarget(dpy, *target)));
+
+    if (*target == XA_TARGETS(dpy)) {
+       Atom *allocP;
+       Atom *targetP;
+       Atom *std_targets;
+       XPointer std_return = 0;
+       unsigned long std_length;
+
+       if (XmuConvertStandardSelection(w, screen->selection_time, selection,
+                                       target, type, &std_return,
+                                       &std_length, format)) {
+           Atom *my_targets = _SelectionTargets(w);
+
+           TRACE(("XmuConvertStandardSelection - success\n"));
+           std_targets = (Atom *) (void *) (std_return);
+           *length = std_length + 6;
+
+           targetP = TypeXtMallocN(Atom, *length);
+           allocP = targetP;
+
+           *value = (XtPointer) targetP;
+
+           while (*my_targets != None) {
+               *targetP++ = *my_targets++;
+           }
+           *targetP++ = XA_LENGTH(dpy);
+           *targetP++ = XA_LIST_LENGTH(dpy);
+
+           *length = std_length + (unsigned long) (targetP - allocP);
+
+           memcpy(targetP, std_targets, sizeof(Atom) * std_length);
+           XtFree((char *) std_targets);
+           *type = XA_ATOM;
+           *format = 32;
+           result = True;
+       } else {
+           TRACE(("XmuConvertStandardSelection - failed\n"));
+       }
+    }
+#if OPT_WIDE_CHARS
+    else if (screen->wide_chars && *target == XA_STRING) {
+       result =
+           _ConvertSelectionHelper(w,
+                                   type, value, length, format,
+                                   Xutf8TextListToTextProperty,
+                                   XStringStyle);
+       TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
+    } else if (screen->wide_chars && *target == XA_UTF8_STRING(dpy)) {
+       result =
+           _ConvertSelectionHelper(w,
+                                   type, value, length, format,
+                                   Xutf8TextListToTextProperty,
+                                   XUTF8StringStyle);
+       TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
+    } else if (screen->wide_chars && *target == XA_TEXT(dpy)) {
+       result =
+           _ConvertSelectionHelper(w,
+                                   type, value, length, format,
+                                   Xutf8TextListToTextProperty,
+                                   XStdICCTextStyle);
+       TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
+    } else if (screen->wide_chars && *target == XA_COMPOUND_TEXT(dpy)) {
+       result =
+           _ConvertSelectionHelper(w,
+                                   type, value, length, format,
+                                   Xutf8TextListToTextProperty,
+                                   XCompoundTextStyle);
+       TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
+    }
+#endif
+
+    else if (*target == XA_STRING) {   /* not wide_chars */
+       /* We can only reach this point if the selection requestor
+          requested STRING before any of TEXT, COMPOUND_TEXT or
+          UTF8_STRING.  We therefore assume that the requestor is not
+          properly internationalised, and dump raw eight-bit data
+          with no conversion into the selection.  Yes, this breaks
+          the ICCCM in non-Latin-1 locales. */
+       *type = XA_STRING;
+       *value = (XtPointer) screen->selection_data;
+       *length = screen->selection_length;
+       *format = 8;
+       result = True;
+       TRACE(("...raw 8-bit data:%d\n", result));
+    } else if (*target == XA_TEXT(dpy)) {      /* not wide_chars */
+       result =
+           _ConvertSelectionHelper(w,
+                                   type, value, length, format,
+                                   XmbTextListToTextProperty,
+                                   XStdICCTextStyle);
+       TRACE(("...XmbTextListToTextProperty(StdICC):%d\n", result));
+    } else if (*target == XA_COMPOUND_TEXT(dpy)) {     /* not wide_chars */
+       result =
+           _ConvertSelectionHelper(w,
+                                   type, value, length, format,
+                                   XmbTextListToTextProperty,
+                                   XCompoundTextStyle);
+       TRACE(("...XmbTextListToTextProperty(Compound):%d\n", result));
+    }
+#ifdef X_HAVE_UTF8_STRING
+    else if (*target == XA_UTF8_STRING(dpy)) { /* not wide_chars */
+       result =
+           _ConvertSelectionHelper(w,
+                                   type, value, length, format,
+                                   XmbTextListToTextProperty,
+                                   XUTF8StringStyle);
+       TRACE(("...XmbTextListToTextProperty(UTF8):%d\n", result));
+    }
+#endif
+    else if (*target == XA_LIST_LENGTH(dpy)) {
+       result = SaveConvertedLength(value, (unsigned long) 1);
+       *type = XA_INTEGER;
+       *length = 1;
+       *format = 32;
+       TRACE(("...list of values:%d\n", result));
+    } else if (*target == XA_LENGTH(dpy)) {
+       /* This value is wrong if we have UTF-8 text */
+       result = SaveConvertedLength(value, screen->selection_length);
+       *type = XA_INTEGER;
+       *length = 1;
+       *format = 32;
+       TRACE(("...list of values:%d\n", result));
+    } else if (XmuConvertStandardSelection(w,
+                                          screen->selection_time, selection,
+                                          target, type, (XPointer *) value,
+                                          length, format)) {
+       result = True;
+       TRACE(("...XmuConvertStandardSelection:%d\n", result));
+    }
+
+    /* else */
+    return (Boolean) result;
+}
+
+static void
+LoseSelection(Widget w, Atom * selection)
+{
+    TScreen *screen;
+    Atom *atomP;
+    Cardinal i;
+
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) == 0)
+       return;
+
+    screen = TScreenOf(xw);
+    for (i = 0, atomP = screen->selection_atoms;
+        i < screen->selection_count; i++, atomP++) {
+       if (*selection == *atomP)
+           *atomP = (Atom) 0;
+       if (CutBuffer(*atomP) >= 0) {
+           *atomP = (Atom) 0;
+       }
+    }
+
+    for (i = screen->selection_count; i; i--) {
+       if (screen->selection_atoms[i - 1] != 0)
+           break;
+    }
+    screen->selection_count = i;
+
+    for (i = 0, atomP = screen->selection_atoms;
+        i < screen->selection_count; i++, atomP++) {
+       if (*atomP == (Atom) 0) {
+           *atomP = screen->selection_atoms[--screen->selection_count];
+       }
+    }
+
+    if (screen->selection_count == 0)
+       TrackText(xw, &zeroCELL, &zeroCELL);
+}
+
+/* ARGSUSED */
+static void
+SelectionDone(Widget w GCC_UNUSED,
+             Atom * selection GCC_UNUSED,
+             Atom * target GCC_UNUSED)
+{
+    /* empty proc so Intrinsics know we want to keep storage */
+}
+
+static void
+_OwnSelection(XtermWidget xw,
+             String * selections,
+             Cardinal count)
+{
+    TScreen *screen = TScreenOf(xw);
+    Atom *atoms = screen->selection_atoms;
+    Cardinal i;
+    Bool have_selection = False;
+
+    if (count == 0)
+       return;
+    if (screen->selection_length == 0)
+       return;
+
+    TRACE(("_OwnSelection count %d\n", count));
+    selections = MapSelections(xw, selections, count);
+
+    if (count > screen->sel_atoms_size) {
+       XtFree((char *) atoms);
+       atoms = TypeXtMallocN(Atom, count);
+       screen->selection_atoms = atoms;
+       screen->sel_atoms_size = count;
+    }
+    XmuInternStrings(XtDisplay((Widget) xw), selections, count, atoms);
+    for (i = 0; i < count; i++) {
+       int cutbuffer = CutBuffer(atoms[i]);
+       if (cutbuffer >= 0) {
+           unsigned long limit =
+           (unsigned long) (4 * XMaxRequestSize(XtDisplay((Widget) xw)) - 32);
+           if (screen->selection_length > limit) {
+               TRACE(("selection too big (%lu bytes), not storing in CUT_BUFFER%d\n",
+                      screen->selection_length, cutbuffer));
+               fprintf(stderr,
+                       "%s: selection too big (%lu bytes), not storing in CUT_BUFFER%d\n",
+                       xterm_name, screen->selection_length, cutbuffer);
+           } else {
+               /* This used to just use the UTF-8 data, which was totally
+                * broken as not even the corresponding paste code in Xterm
+                * understood this!  So now it converts to Latin1 first.
+                *   Robert Brady, 2000-09-05
+                */
+               unsigned long length = screen->selection_length;
+               Char *data = screen->selection_data;
+               if_OPT_WIDE_CHARS((screen), {
+                   data = UTF8toLatin1(screen, data, length, &length);
+               });
+               TRACE(("XStoreBuffer(%d)\n", cutbuffer));
+               XStoreBuffer(XtDisplay((Widget) xw),
+                            (char *) data,
+                            (int) length,
+                            cutbuffer);
+           }
+       } else if (!screen->replyToEmacs) {
+           have_selection |=
+               XtOwnSelection((Widget) xw, atoms[i],
+                              screen->selection_time,
+                              ConvertSelection, LoseSelection, SelectionDone);
+       }
+    }
+    if (!screen->replyToEmacs)
+       screen->selection_count = count;
+    if (!have_selection)
+       TrackText(xw, &zeroCELL, &zeroCELL);
+}
+
+static void
+ResetSelectionState(TScreen * screen)
+{
+    screen->selection_count = 0;
+    screen->startH = zeroCELL;
+    screen->endH = zeroCELL;
+}
+
+void
+DisownSelection(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Atom *atoms = screen->selection_atoms;
+    Cardinal count = screen->selection_count;
+    Cardinal i;
+
+    TRACE(("DisownSelection count %d, start %d.%d, end %d.%d\n",
+          count,
+          screen->startH.row,
+          screen->startH.col,
+          screen->endH.row,
+          screen->endH.col));
+
+    for (i = 0; i < count; i++) {
+       int cutbuffer = CutBuffer(atoms[i]);
+       if (cutbuffer < 0) {
+           XtDisownSelection((Widget) xw, atoms[i],
+                             screen->selection_time);
+       }
+    }
+    /*
+     * If none of the callbacks via XtDisownSelection() reset highlighting
+     * do it now.
+     */
+    if (ScrnHaveSelection(screen)) {
+       /* save data which will be reset */
+       CELL first = screen->startH;
+       CELL last = screen->endH;
+
+       ResetSelectionState(screen);
+       ReHiliteText(xw, &first, &last);
+    } else {
+       ResetSelectionState(screen);
+    }
+}
+
+void
+UnhiliteSelection(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (ScrnHaveSelection(screen)) {
+       CELL first = screen->startH;
+       CELL last = screen->endH;
+
+       screen->startH = zeroCELL;
+       screen->endH = zeroCELL;
+       ReHiliteText(xw, &first, &last);
+    }
+}
+
+/* returns number of chars in line from scol to ecol out */
+/* ARGSUSED */
+static int
+Length(TScreen * screen,
+       int row,
+       int scol,
+       int ecol)
+{
+    LineData *ld = GET_LINEDATA(screen, row);
+    int lastcol = LastTextCol(screen, ld, row);
+
+    if (ecol > lastcol)
+       ecol = lastcol;
+    return (ecol - scol + 1);
+}
+
+/* copies text into line, preallocated */
+static Char *
+SaveText(TScreen * screen,
+        int row,
+        int scol,
+        int ecol,
+        Char * lp,             /* pointer to where to put the text */
+        int *eol)
+{
+    LineData *ld;
+    int i = 0;
+    unsigned c;
+    Char *result = lp;
+#if OPT_WIDE_CHARS
+    unsigned previous = 0;
+#endif
+
+    ld = GET_LINEDATA(screen, row);
+    i = Length(screen, row, scol, ecol);
+    ecol = scol + i;
+#if OPT_DEC_CHRSET
+    if (CSET_DOUBLE(GetLineDblCS(ld))) {
+       scol = (scol + 0) / 2;
+       ecol = (ecol + 1) / 2;
+    }
+#endif
+    *eol = !LineTstWrapped(ld);
+    for (i = scol; i < ecol; i++) {
+       assert(i < ld->lineSize);
+       c = E2A(ld->charData[i]);
+#if OPT_WIDE_CHARS
+       /* We want to strip out every occurrence of HIDDEN_CHAR AFTER a
+        * wide character.
+        */
+       if (c == HIDDEN_CHAR && isWide((int) previous)) {
+           previous = c;
+           /* Combining characters attached to double-width characters
+              are in memory attached to the HIDDEN_CHAR */
+           if_OPT_WIDE_CHARS(screen, {
+               if (screen->utf8_mode != uFalse) {
+                   unsigned ch;
+                   size_t off;
+                   for_each_combData(off, ld) {
+                       ch = ld->combData[off][i];
+                       if (ch == 0)
+                           break;
+                       lp = convertToUTF8(lp, ch);
+                   }
+               }
+           });
+           continue;
+       }
+       previous = c;
+       if (screen->utf8_mode != uFalse) {
+           lp = convertToUTF8(lp, (c != 0) ? c : ' ');
+           if_OPT_WIDE_CHARS(screen, {
+               unsigned ch;
+               size_t off;
+               for_each_combData(off, ld) {
+                   ch = ld->combData[off][i];
+                   if (ch == 0)
+                       break;
+                   lp = convertToUTF8(lp, ch);
+               }
+           });
+       } else
+#endif
+       {
+           if (c == 0) {
+               c = E2A(' ');
+           } else if (c < E2A(' ')) {
+               c = DECtoASCII(c);
+           } else if (c == 0x7f) {
+               c = 0x5f;
+           }
+           *lp++ = CharOf(A2E(c));
+       }
+       if (c != E2A(' '))
+           result = lp;
+    }
+
+    /*
+     * If requested, trim trailing blanks from selected lines.  Do not do this
+     * if the line is wrapped.
+     */
+    if (!*eol || !screen->trim_selection)
+       result = lp;
+
+    return (result);
+}
+
+/* 32 + following 7-bit word:
+
+   1:0  Button no: 0, 1, 2.  3=release.
+     2  shift
+     3  meta
+     4  ctrl
+     5  set for motion notify
+     6  set for wheel
+*/
+
+/* Position: 32 - 255. */
+static int
+BtnCode(XButtonEvent * event, int button)
+{
+    int result = (int) (32 + (KeyState(event->state) << 2));
+
+    if (button < 0 || button > 5) {
+       result += 3;
+    } else {
+       if (button > 3)
+           result += (64 - 4);
+       if (event->type == MotionNotify)
+           result += 32;
+       result += button;
+    }
+    return result;
+}
+
+static unsigned
+EmitButtonCode(TScreen * screen, Char * line, unsigned count, XButtonEvent * event)
+{
+    int value = BtnCode(event, screen->mouse_button);
+
+    if (!screen->ext_mode_mouse || value < 128) {
+       line[count++] = CharOf(value);
+    } else {
+       line[count++] = CharOf(0xC0 + (value >> 6));
+       line[count++] = CharOf(0x80 + (value & 0x3F));
+    }
+    return count;
+}
+
+static void
+EditorButton(XtermWidget xw, XButtonEvent * event)
+{
+    TScreen *screen = TScreenOf(xw);
+    int pty = screen->respond;
+    int mouse_limit = screen->ext_mode_mouse ? EXT_MOUSE_LIMIT : MOUSE_LIMIT;
+    Char line[10];
+    int row, col;
+    int button;
+    unsigned count = 0;
+    Boolean changed = True;
+
+    /* If button event, get button # adjusted for DEC compatibility */
+    button = (int) (event->button - 1);
+    if (button >= 3)
+       button++;
+
+    /* Compute character position of mouse pointer */
+    row = (event->y - screen->border) / FontHeight(screen);
+    col = (event->x - OriginX(screen)) / FontWidth(screen);
+
+    /* Limit to screen dimensions */
+    if (row < 0)
+       row = 0;
+    else if (row > screen->max_row)
+       row = screen->max_row;
+
+    if (col < 0)
+       col = 0;
+    else if (col > screen->max_col)
+       col = screen->max_col;
+
+    /* Limit to representable mouse dimensions */
+    if (row > mouse_limit)
+       row = mouse_limit;
+    if (col > mouse_limit)
+       col = mouse_limit;
+
+    /* Build key sequence starting with \E[M */
+    if (screen->control_eight_bits) {
+       line[count++] = ANSI_CSI;
+    } else {
+       line[count++] = ANSI_ESC;
+       line[count++] = '[';
+    }
+#if OPT_SCO_FUNC_KEYS
+    if (xw->keyboard.type == keyboardIsSCO) {
+       /*
+        * SCO function key F1 is \E[M, which would conflict with xterm's
+        * normal kmous.
+        */
+       line[count++] = '>';
+    }
+#endif
+    line[count++] = 'M';
+
+    /* Add event code to key sequence */
+    if (screen->send_mouse_pos == X10_MOUSE) {
+       line[count++] = CharOf(' ' + button);
+    } else {
+       /* Button-Motion events */
+       switch (event->type) {
+       case ButtonPress:
+           screen->mouse_button = button;
+           count = EmitButtonCode(screen, line, count, event);
+           break;
+       case ButtonRelease:
+           /*
+            * Wheel mouse interface generates release-events for buttons
+            * 4 and 5, coded here as 3 and 4 respectively.  We change the
+            * release for buttons 1..3 to a -1.
+            */
+           if (button < 3)
+               button = -1;
+           screen->mouse_button = button;
+           count = EmitButtonCode(screen, line, count, event);
+           break;
+       case MotionNotify:
+           /* BTN_EVENT_MOUSE and ANY_EVENT_MOUSE modes send motion
+            * events only if character cell has changed.
+            */
+           if ((row == screen->mouse_row)
+               && (col == screen->mouse_col)) {
+               changed = False;
+           } else {
+               count = EmitButtonCode(screen, line, count, event);
+           }
+           break;
+       default:
+           changed = False;
+           break;
+       }
+    }
+
+    if (changed) {
+       screen->mouse_row = row;
+       screen->mouse_col = col;
+
+       TRACE(("mouse at %d,%d button+mask = %#x\n", row, col, line[count - 1]));
+
+       /* Add pointer position to key sequence */
+       count = EmitMousePosition(screen, line, count, col);
+       count = EmitMousePosition(screen, line, count, row);
+
+       /* Transmit key sequence to process running under xterm */
+       v_write(pty, line, count);
+    }
+    return;
+}
+
+#if OPT_FOCUS_EVENT
+void
+SendFocusButton(XtermWidget xw, XFocusChangeEvent * event)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->send_focus_pos) {
+       ANSI reply;
+
+       memset(&reply, 0, sizeof(reply));
+       reply.a_type = ANSI_CSI;
+
+#if OPT_SCO_FUNC_KEYS
+       if (xw->keyboard.type == keyboardIsSCO) {
+           reply.a_pintro = '>';
+       }
+#endif
+       reply.a_final = CharOf((event->type == FocusIn) ? 'I' : 'O');
+       unparseseq(xw, &reply);
+    }
+    return;
+}
+#endif /* OPT_FOCUS_EVENT */
diff --git a/cachedGCs.c b/cachedGCs.c
new file mode 100644 (file)
index 0000000..aca07aa
--- /dev/null
@@ -0,0 +1,866 @@
+/* $XTermId: cachedGCs.c,v 1.60 2011/02/09 10:11:44 tom Exp $ */
+
+/************************************************************
+
+Copyright 2007-2010,2011 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <data.h>
+#include <xstrings.h>
+
+#include <X11/Xmu/Drawing.h>
+
+#include <stdio.h>
+
+/*
+ * hide (or eliminate) calls to
+ *     XCreateGC()
+ *     XFreeGC()
+ *     XGetGCValues()
+ *     XSetBackground()
+ *     XSetFont()
+ *     XSetForeground()
+ *     XtGetGC()
+ *     XtReleaseGC()
+ * by associating an integer with each GC, maintaining a cache which
+ * reflects frequency of use rather than most recent usage.
+ *
+ * FIXME: XTermFonts should hold gc, font, fs.
+ */
+typedef struct {
+    GC gc;
+    unsigned used;
+    unsigned cset;
+    XTermFonts *font;
+    Pixel tile;
+    Pixel fg;
+    Pixel bg;
+} CgsCacheData;
+
+#define DEPTH 8
+#define ITEM()      (int) (me->data - me->list)
+#define LIST(item)  me->list[item]
+#define LINK(item)  me->data = (me->list + (item))
+#define THIS(field) me->data->field
+#define NEXT(field) me->next.field
+
+#define HaveFont(font) (Boolean) ((font) != 0 && (font)->fs != 0)
+
+#define GC_CSet GCFunction
+
+typedef struct {
+    CgsCacheData list[DEPTH];
+    CgsCacheData *data;                /* points to current list[] entry */
+    XtGCMask mask;             /* changes since the last getCgsGC() */
+    CgsCacheData next;         /* updated values, apply in getCgsGC() */
+} CgsCache;
+
+#if OPT_TRACE
+#define CASE(name) case gc##name: result = #name; break
+static const char *
+traceCgsEnum(CgsEnum value)
+{
+    const char *result = "?";
+    switch (value) {
+       CASE(Norm);
+       CASE(Bold);
+       CASE(NormReverse);
+       CASE(BoldReverse);
+#if OPT_BOX_CHARS
+       CASE(Line);
+       CASE(Dots);
+#endif
+#if OPT_DEC_CHRSET
+       CASE(CNorm);
+       CASE(CBold);
+#endif
+#if OPT_WIDE_CHARS
+       CASE(Wide);
+       CASE(WBold);
+       CASE(WideReverse);
+       CASE(WBoldReverse);
+#endif
+       CASE(VTcursNormal);
+       CASE(VTcursFilled);
+       CASE(VTcursReverse);
+       CASE(VTcursOutline);
+#if OPT_TEK4014
+       CASE(TKcurs);
+#endif
+       CASE(MAX);
+    }
+    return result;
+}
+
+#undef CASE
+
+static const char *
+traceVTwin(XtermWidget xw, VTwin * value)
+{
+    const char *result = "?";
+    if (value == 0)
+       result = "null";
+    else if (value == &(TScreenOf(xw)->fullVwin))
+       result = "fullVwin";
+#ifndef NO_ACTIVE_ICON
+    else if (value == &(TScreenOf(xw)->iconVwin))
+       result = "iconVwin";
+#endif
+    return result;
+}
+
+#if OPT_TRACE > 1
+static String
+traceCSet(unsigned cset)
+{
+    static char result[80];
+    switch (cset) {
+    case CSET_SWL:
+       strcpy(result, "SWL");
+       break;
+    case CSET_DHL_TOP:
+       strcpy(result, "DHL_TOP");
+       break;
+    case CSET_DHL_BOT:
+       strcpy(result, "DHL_BOT");
+       break;
+    case CSET_DWL:
+       strcpy(result, "DWL");
+       break;
+    default:
+       sprintf(result, "%#x", cset);
+       break;
+    }
+    return result;
+}
+
+static String
+traceFont(XTermFonts * font)
+{
+    static char result[80];
+
+    if (HaveFont(font)) {
+       XFontStruct *fs = font->fs;
+       sprintf(result, "%p(%dx%d %d %#lx)",
+               fs,
+               fs->max_bounds.width,
+               fs->max_bounds.ascent + fs->max_bounds.descent,
+               fs->max_bounds.descent,
+               (unsigned long) (fs->fid));
+    } else {
+       strcpy(result, "null");
+    }
+    return result;
+}
+
+static String
+tracePixel(XtermWidget xw, Pixel value)
+{
+#define CASE(name) { name, #name }
+    static struct {
+       TermColors code;
+       String name;
+    } t_colors[] = {
+       CASE(TEXT_FG),
+           CASE(TEXT_BG),
+           CASE(TEXT_CURSOR),
+           CASE(MOUSE_FG),
+           CASE(MOUSE_BG),
+#if OPT_TEK4014
+           CASE(TEK_FG),
+           CASE(TEK_BG),
+#endif
+#if OPT_HIGHLIGHT_COLOR
+           CASE(HIGHLIGHT_BG),
+           CASE(HIGHLIGHT_FG),
+#endif
+#if OPT_TEK4014
+           CASE(TEK_CURSOR),
+#endif
+    };
+    TScreen *screen = TScreenOf(xw);
+    String result = 0;
+    int n;
+
+    for (n = 0; n < NCOLORS; ++n) {
+       if (value == T_COLOR(screen, t_colors[n].code)) {
+           result = t_colors[n].name;
+           break;
+       }
+    }
+
+    if (result == 0) {
+       for (n = 0; n < MAXCOLORS; ++n) {
+#if OPT_COLOR_RES
+           if (screen->Acolors[n].mode > 0
+               && value == screen->Acolors[n].value) {
+               result = screen->Acolors[n].resource;
+               break;
+           }
+#else
+           if (value == screen->Acolors[n]) {
+               char temp[80];
+               sprintf(temp, "Acolors[%d]", n);
+               result = x_strdup(temp);
+               break;
+           }
+#endif
+       }
+    }
+
+    if (result == 0) {
+       char temp[80];
+       sprintf(temp, "%#lx", value);
+       result = x_strdup(temp);
+    }
+
+    return result;
+}
+
+#undef CASE
+
+#endif /* OPT_TRACE > 1 */
+#endif /* OPT_TRACE */
+
+static CgsCache *
+allocCache(void **cache_pointer)
+{
+    if (*cache_pointer == 0) {
+       *cache_pointer = TypeCallocN(CgsCache, gcMAX);
+       TRACE(("allocCache %p\n", *cache_pointer));
+    }
+    return *((CgsCache **) cache_pointer);
+}
+
+static int
+dataIndex(CgsCache * me)
+{
+    return ITEM();
+}
+
+static void
+relinkData(CgsCache * me, int item)
+{
+    LINK(item);
+}
+
+/*
+ * Returns the appropriate cache pointer.
+ */
+static CgsCache *
+myCache(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId)
+{
+    CgsCache *result = 0;
+
+    if ((int) cgsId >= 0 && cgsId < gcMAX) {
+#ifdef NO_ACTIVE_ICON
+       (void) xw;
+       (void) cgsWin;
+#else
+       if (cgsWin == &(TScreenOf(xw)->iconVwin))
+           result = allocCache(&(TScreenOf(xw)->icon_cgs_cache));
+       else
+#endif
+           result = allocCache(&(TScreenOf(xw)->main_cgs_cache));
+
+       result += cgsId;
+       if (result->data == 0) {
+           result->data = result->list;
+       }
+    }
+
+    return result;
+}
+
+static Display *
+myDisplay(XtermWidget xw)
+{
+    return TScreenOf(xw)->display;
+}
+
+static Drawable
+myDrawable(XtermWidget xw, VTwin * cgsWin)
+{
+    Drawable drawable = 0;
+
+    if (cgsWin != 0 && cgsWin->window != 0)
+       drawable = cgsWin->window;
+    if (drawable == 0)
+       drawable = RootWindowOfScreen(XtScreen(xw));
+    return drawable;
+}
+
+static GC
+newCache(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, CgsCache * me)
+{
+    XGCValues xgcv;
+    XtGCMask mask;
+
+    THIS(font) = NEXT(font);
+    THIS(cset) = NEXT(cset);
+    THIS(fg) = NEXT(fg);
+    THIS(bg) = NEXT(bg);
+
+    memset(&xgcv, 0, sizeof(xgcv));
+    xgcv.font = NEXT(font)->fs->fid;
+    mask = (GCForeground | GCBackground | GCFont);
+
+    switch (cgsId) {
+    case gcNorm:
+    case gcBold:
+    case gcNormReverse:
+    case gcBoldReverse:
+#if OPT_WIDE_CHARS
+    case gcWide:
+    case gcWBold:
+    case gcWideReverse:
+    case gcWBoldReverse:
+#endif
+       mask |= (GCGraphicsExposures | GCFunction);
+       xgcv.graphics_exposures = True;         /* default */
+       xgcv.function = GXcopy;
+       break;
+#if OPT_BOX_CHARS
+    case gcLine:
+       mask |= (GCGraphicsExposures | GCFunction);
+       xgcv.graphics_exposures = True;         /* default */
+       xgcv.function = GXcopy;
+       break;
+    case gcDots:
+       xgcv.fill_style = FillTiled;
+       xgcv.tile =
+           XmuCreateStippledPixmap(XtScreen((Widget) xw),
+                                   THIS(fg),
+                                   THIS(bg),
+                                   xw->core.depth);
+       THIS(tile) = xgcv.tile;
+       mask = (GCForeground | GCBackground);
+       mask |= (GCGraphicsExposures | GCFunction | GCTile | GCFillStyle);
+       xgcv.graphics_exposures = True;         /* default */
+       xgcv.function = GXcopy;
+       break;
+#endif
+#if OPT_DEC_CHRSET
+    case gcCNorm:
+    case gcCBold:
+       break;
+#endif
+    case gcVTcursNormal:       /* FALLTHRU */
+    case gcVTcursFilled:       /* FALLTHRU */
+    case gcVTcursReverse:      /* FALLTHRU */
+    case gcVTcursOutline:      /* FALLTHRU */
+       break;
+#if OPT_TEK4014
+    case gcTKcurs:             /* FALLTHRU */
+       /* FIXME */
+#endif
+    case gcMAX:                /* should not happen */
+       return 0;
+    }
+    xgcv.foreground = NEXT(fg);
+    xgcv.background = NEXT(bg);
+
+    THIS(gc) = XCreateGC(myDisplay(xw), myDrawable(xw, cgsWin), mask, &xgcv);
+    TRACE(("getCgsGC(%s) created gc %p(%d)\n",
+          traceCgsEnum(cgsId), (void *) THIS(gc), ITEM()));
+
+    THIS(used) = 0;
+    return THIS(gc);
+}
+
+static Boolean
+SameFont(XTermFonts * a, XTermFonts * b)
+{
+    return (Boolean) (HaveFont(a)
+                     && HaveFont(b)
+                     && ((a->fs == b->fs)
+                         || !memcmp(a->fs, b->fs, sizeof(*(a->fs)))));
+}
+
+#define SameColor(a,b) ((a) == (b))
+#define SameCSet(a,b)  ((a) == (b))
+
+static GC
+chgCache(XtermWidget xw, CgsEnum cgsId GCC_UNUSED, CgsCache * me, Bool both)
+{
+    XGCValues xgcv;
+    XtGCMask mask = (GCForeground | GCBackground | GCFont);
+
+    memset(&xgcv, 0, sizeof(xgcv));
+
+    TRACE2(("chgCache(%s) old data fg=%s, bg=%s, font=%s cset %s\n",
+           traceCgsEnum(cgsId),
+           tracePixel(xw, THIS(fg)),
+           tracePixel(xw, THIS(bg)),
+           traceFont(THIS(font)),
+           traceCSet(THIS(cset))));
+#if OPT_TRACE > 1
+    if (!SameFont(THIS(font), NEXT(font)))
+       TRACE2(("...chgCache new font=%s\n", traceFont(NEXT(font))));
+    if (!SameCSet(THIS(cset), NEXT(cset)))
+       TRACE2(("...chgCache new cset=%s\n", traceCSet(NEXT(cset))));
+    if (!SameColor(THIS(fg), NEXT(fg)))
+       TRACE2(("...chgCache new fg=%s\n", tracePixel(xw, NEXT(fg))));
+    if (!SameColor(THIS(bg), NEXT(bg)))
+       TRACE2(("...chgCache new bg=%s\n", tracePixel(xw, NEXT(bg))));
+#endif
+
+    if (both) {
+       THIS(font) = NEXT(font);
+       THIS(cset) = NEXT(cset);
+    }
+    THIS(fg) = NEXT(fg);
+    THIS(bg) = NEXT(bg);
+
+    xgcv.font = THIS(font)->fs->fid;
+    xgcv.foreground = THIS(fg);
+    xgcv.background = THIS(bg);
+
+    XChangeGC(myDisplay(xw), THIS(gc), mask, &xgcv);
+    TRACE2(("...chgCache(%s) updated gc %p(%d)\n",
+           traceCgsEnum(cgsId), THIS(gc), ITEM()));
+
+    THIS(used) = 0;
+    return THIS(gc);
+}
+/*
+ * Use the "setCgsXXXX()" calls to initialize parameters for a new GC.
+ */
+void
+setCgsFore(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, Pixel fg)
+{
+    CgsCache *me;
+
+    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
+       NEXT(fg) = fg;
+       me->mask |= GCForeground;
+    }
+}
+
+void
+setCgsBack(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, Pixel bg)
+{
+    CgsCache *me;
+
+    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
+       NEXT(bg) = bg;
+       me->mask |= GCBackground;
+    }
+}
+
+#if OPT_DEC_CHRSET
+void
+setCgsCSet(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, unsigned cset)
+{
+    CgsCache *me;
+
+    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
+       NEXT(cset) = cset;
+       me->mask |= GC_CSet;
+    }
+}
+#else
+#define setCgsCSet(xw, cgsWin, dstCgsId, cset) /* nothing */
+#endif
+
+void
+setCgsFont(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, XTermFonts * font)
+{
+    CgsCache *me;
+
+    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
+       if (!HaveFont(font)) {
+           if (cgsId != gcNorm)
+               (void) getCgsGC(xw, cgsWin, gcNorm);
+#ifndef NO_ACTIVE_ICON
+           if (cgsWin == &(TScreenOf(xw)->iconVwin))
+               font = &(TScreenOf(xw)->fnt_icon);
+           else
+#endif
+               font = &(TScreenOf(xw)->fnts[fNorm]);
+       }
+       if (HaveFont(font) && okFont(font->fs)) {
+           TRACE2(("...updated next font in %p for %s to %s\n",
+                   me, traceCgsEnum(cgsId), traceFont(font)));
+           TRACE2(("...next font was %s\n", traceFont(NEXT(font))));
+           NEXT(font) = font;
+           me->mask |= GCFont;
+       } else {
+           /* EMPTY */
+           TRACE2(("...NOT updated font for %s\n",
+                   traceCgsEnum(cgsId)));
+       }
+    }
+}
+
+/*
+ * Discard all of the font information, e.g., we are resizing the font.
+ * Keep the GC's so we can simply change them rather than creating new ones.
+ */
+void
+clrCgsFonts(XtermWidget xw, VTwin * cgsWin, XTermFonts * font)
+{
+    CgsCache *me;
+    int j, k;
+
+    if (HaveFont(font)) {
+       for_each_gc(j) {
+           if ((me = myCache(xw, cgsWin, (CgsEnum) j)) != 0) {
+               for (k = 0; k < DEPTH; ++k) {
+                   if (SameFont(LIST(k).font, font)) {
+                       TRACE2(("clrCgsFonts %s gc %p(%d) %s\n",
+                               traceCgsEnum((CgsEnum) j),
+                               LIST(k).gc,
+                               k,
+                               traceFont(font)));
+                       LIST(k).font = 0;
+                       LIST(k).cset = 0;
+                   }
+               }
+               if (SameFont(NEXT(font), font)) {
+                   TRACE2(("clrCgsFonts %s next %s\n",
+                           traceCgsEnum((CgsEnum) j),
+                           traceFont(font)));
+                   NEXT(font) = 0;
+                   NEXT(cset) = 0;
+                   me->mask &= (unsigned) ~(GCFont | GC_CSet);
+               }
+           }
+       }
+    }
+}
+
+/*
+ * Return a GC associated with the given id, allocating if needed.
+ */
+GC
+getCgsGC(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId)
+{
+    CgsCache *me;
+    GC result = 0;
+    int j, k;
+    unsigned used = 0;
+
+    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
+       TRACE2(("getCgsGC(%s, %s)\n",
+               traceVTwin(xw, cgsWin), traceCgsEnum(cgsId)));
+       if (me->mask != 0) {
+
+           /* fill in the unchanged fields */
+           if (!(me->mask & GC_CSet))
+               NEXT(cset) = 0; /* OPT_DEC_CHRSET */
+           if (!(me->mask & GCFont))
+               NEXT(font) = THIS(font);
+           if (!(me->mask & GCForeground))
+               NEXT(fg) = THIS(fg);
+           if (!(me->mask & GCBackground))
+               NEXT(bg) = THIS(bg);
+
+           if (NEXT(font) == 0) {
+               setCgsFont(xw, cgsWin, cgsId, 0);
+           }
+
+           TRACE2(("...Cgs new data fg=%s, bg=%s, font=%s cset %s\n",
+                   tracePixel(xw, NEXT(fg)),
+                   tracePixel(xw, NEXT(bg)),
+                   traceFont(NEXT(font)),
+                   traceCSet(NEXT(cset))));
+
+           /* try to find the given data in an already-created GC */
+           for (j = 0; j < DEPTH; ++j) {
+               if (LIST(j).gc != 0
+                   && SameFont(LIST(j).font, NEXT(font))
+                   && SameCSet(LIST(j).cset, NEXT(cset))
+                   && SameColor(LIST(j).fg, NEXT(fg))
+                   && SameColor(LIST(j).bg, NEXT(bg))) {
+                   LINK(j);
+                   result = THIS(gc);
+                   TRACE2(("getCgsGC existing %p(%d)\n", result, ITEM()));
+                   break;
+               }
+           }
+
+           if (result == 0) {
+               /* try to find an empty slot, to create a new GC */
+               used = 0;
+               for (j = 0; j < DEPTH; ++j) {
+                   if (LIST(j).gc == 0) {
+                       LINK(j);
+                       result = newCache(xw, cgsWin, cgsId, me);
+                       break;
+                   }
+                   if (used < LIST(j).used)
+                       used = LIST(j).used;
+               }
+           }
+
+           if (result == 0) {
+               /* if none were empty, pick the least-used slot, to modify */
+               for (j = 0, k = -1; j < DEPTH; ++j) {
+                   if (used >= LIST(j).used) {
+                       used = LIST(j).used;
+                       k = j;
+                   }
+               }
+               LINK(k);
+               TRACE2(("...getCgsGC least-used(%d) was %d\n", k, THIS(used)));
+               result = chgCache(xw, cgsId, me, True);
+           }
+           me->next = *(me->data);
+       } else {
+           result = THIS(gc);
+       }
+       me->mask = 0;
+       THIS(used) += 1;
+       TRACE2(("...getCgsGC(%s, %s) gc %p(%d), used %d\n",
+               traceVTwin(xw, cgsWin),
+               traceCgsEnum(cgsId), result, ITEM(), THIS(used)));
+    }
+    return result;
+}
+
+/*
+ * Return the font for the given GC.
+ */
+CgsEnum
+getCgsId(XtermWidget xw, VTwin * cgsWin, GC gc)
+{
+    int n;
+    CgsEnum result = gcNorm;
+
+    for_each_gc(n) {
+       CgsCache *me;
+
+       if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
+           if (THIS(gc) == gc) {
+               result = (CgsEnum) n;
+               break;
+           }
+       }
+    }
+    return result;
+}
+
+/*
+ * Return the font for the given GC.
+ */
+XTermFonts *
+getCgsFont(XtermWidget xw, VTwin * cgsWin, GC gc)
+{
+    int n;
+    XTermFonts *result = 0;
+
+    for_each_gc(n) {
+       CgsCache *me;
+
+       if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
+           if (THIS(gc) == gc) {
+               result = THIS(font);
+               break;
+           }
+       }
+    }
+    return result;
+}
+
+/*
+ * Return the foreground color for the given GC.
+ */
+Pixel
+getCgsFore(XtermWidget xw, VTwin * cgsWin, GC gc)
+{
+    int n;
+    Pixel result = 0;
+
+    for_each_gc(n) {
+       CgsCache *me;
+
+       if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
+           if (THIS(gc) == gc) {
+               result = THIS(fg);
+               break;
+           }
+       }
+    }
+    return result;
+}
+
+/*
+ * Return the background color for the given GC.
+ */
+Pixel
+getCgsBack(XtermWidget xw, VTwin * cgsWin, GC gc)
+{
+    int n;
+    Pixel result = 0;
+
+    for_each_gc(n) {
+       CgsCache *me;
+
+       if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
+           if (THIS(gc) == gc) {
+               result = THIS(bg);
+               break;
+           }
+       }
+    }
+    return result;
+}
+
+/*
+ * Copy the parameters (except GC of course) from one cache record to another.
+ */
+void
+copyCgs(XtermWidget xw, VTwin * cgsWin, CgsEnum dstCgsId, CgsEnum srcCgsId)
+{
+    if (dstCgsId != srcCgsId) {
+       CgsCache *me;
+
+       if ((me = myCache(xw, cgsWin, srcCgsId)) != 0) {
+           TRACE(("copyCgs from %s to %s\n",
+                  traceCgsEnum(srcCgsId),
+                  traceCgsEnum(dstCgsId)));
+           TRACE2(("copyCgs from %s (me %p, fg %s, bg %s, cset %s) to %s {{\n",
+                   traceCgsEnum(srcCgsId),
+                   me,
+                   tracePixel(xw, THIS(fg)),
+                   tracePixel(xw, THIS(bg)),
+                   traceCSet(THIS(cset)),
+                   traceCgsEnum(dstCgsId)));
+           setCgsCSet(xw, cgsWin, dstCgsId, THIS(cset));
+           setCgsFore(xw, cgsWin, dstCgsId, THIS(fg));
+           setCgsBack(xw, cgsWin, dstCgsId, THIS(bg));
+           setCgsFont(xw, cgsWin, dstCgsId, THIS(font));
+           TRACE2(("...copyCgs }}\n"));
+       }
+    }
+}
+
+/*
+ * Interchange colors in the cache, e.g., for reverse-video.
+ */
+void
+redoCgs(XtermWidget xw, Pixel fg, Pixel bg, CgsEnum cgsId)
+{
+    int n;
+    VTwin *cgsWin = WhichVWin(TScreenOf(xw));
+    CgsCache *me = myCache(xw, cgsWin, cgsId);
+
+    if (me != 0) {
+       CgsCacheData *save_data = me->data;
+
+       for (n = 0; n < DEPTH; ++n) {
+           if (LIST(n).gc != 0 && HaveFont(LIST(n).font)) {
+               LINK(n);
+
+               if (LIST(n).fg == fg
+                   && LIST(n).bg == bg) {
+                   setCgsFore(xw, cgsWin, cgsId, bg);
+                   setCgsBack(xw, cgsWin, cgsId, fg);
+               } else if (LIST(n).fg == bg
+                          && LIST(n).bg == fg) {
+                   setCgsFore(xw, cgsWin, cgsId, fg);
+                   setCgsBack(xw, cgsWin, cgsId, bg);
+               } else {
+                   continue;
+               }
+
+               (void) chgCache(xw, cgsId, me, False);
+           }
+       }
+       me->data = save_data;
+    }
+}
+
+/*
+ * Swap the cache records, e.g., when doing reverse-video.
+ */
+void
+swapCgs(XtermWidget xw, VTwin * cgsWin, CgsEnum dstCgsId, CgsEnum srcCgsId)
+{
+    if (dstCgsId != srcCgsId) {
+       CgsCache *dst;
+       CgsCache *src;
+       CgsCache tmp;
+
+       if ((src = myCache(xw, cgsWin, srcCgsId)) != 0) {
+           if ((dst = myCache(xw, cgsWin, dstCgsId)) != 0) {
+               int srcIndex = dataIndex(src);
+               int dstIndex = dataIndex(dst);
+
+               EXCHANGE(*src, *dst, tmp);
+
+               relinkData(src, dstIndex);
+               relinkData(dst, srcIndex);
+           }
+       }
+    }
+}
+
+/*
+ * Free any GC associated with the given id.
+ */
+GC
+freeCgs(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId)
+{
+    CgsCache *me;
+    int j;
+
+    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
+       for (j = 0; j < DEPTH; ++j) {
+           if (LIST(j).gc != 0) {
+               TRACE(("freeCgs(%s, %s) gc %p(%d)\n",
+                      traceVTwin(xw, cgsWin),
+                      traceCgsEnum(cgsId), (void *) LIST(j).gc, j));
+               clrCgsFonts(xw, cgsWin, LIST(j).font);
+#if OPT_BOX_CHARS
+               if (cgsId == gcDots) {
+                   XmuReleaseStippledPixmap(XtScreen((Widget) xw), LIST(j).tile);
+               }
+#endif
+               XFreeGC(TScreenOf(xw)->display, LIST(j).gc);
+               memset(&LIST(j), 0, sizeof(LIST(j)));
+           }
+           LINK(0);
+       }
+    }
+    return 0;
+}
+
+#ifdef NO_LEAKS
+void
+noleaks_cachedCgs(XtermWidget xw)
+{
+#ifndef NO_ACTIVE_ICON
+    free(TScreenOf(xw)->icon_cgs_cache);
+#endif
+    free(TScreenOf(xw)->main_cgs_cache);
+}
+#endif
diff --git a/charclass.c b/charclass.c
new file mode 100644 (file)
index 0000000..675ef17
--- /dev/null
@@ -0,0 +1,161 @@
+/* $XTermId: charclass.c,v 1.22 2009/11/05 23:46:15 tom Exp $ */
+
+/*
+ * Compact and efficient reimplementation of the
+ * xterm character class mechanism for large character sets
+ *
+ * Markus Kuhn -- mkuhn@acm.org -- 2000-07-03
+ *
+ * Xterm allows users to select entire words with a double-click on the left
+ * mouse button.  Opinions might differ on what type of characters are part of
+ * separate words, therefore xterm allows users to configure a class code for
+ * each 8-bit character.  Words are maximum length sequences of neighboring
+ * characters with identical class code.  Extending this mechanism to Unicode
+ * naively would create an at least 2^16 entries (128 kB) long class code
+ * table.
+ *
+ * Instead, we transform the character class table into a list of intervals,
+ * that will be accessed via a linear search.  Changes made to the table by the
+ * user will be appended.  A special class code IDENT (default) marks
+ * characters who have their code number as the class code.
+ *
+ * We could alternatively use a sorted table of non-overlapping intervals that
+ * can be accessed via binary search, but merging in new intervals is
+ * significantly more hassle and not worth the effort here.
+ */
+
+#include <xterm.h>
+#include <charclass.h>
+
+#if OPT_WIDE_CHARS
+
+static struct classentry {
+    int cclass;
+    int first;
+    int last;
+} *classtab;
+
+/*
+ * Special convention for classtab[0]:
+ * - classtab[0].cclass is the allocated number of entries in classtab
+ * - classtab[0].first = 1 (first used entry in classtab)
+ * - classtab[0].last is the last used entry in classtab
+ */
+
+int
+SetCharacterClassRange(int low, int high, int value)
+{
+    if (high < low)
+       return -1;              /* nothing to do */
+
+    /* make sure we have at least one free entry left at table end */
+    if (classtab[0].last > classtab[0].cclass - 2) {
+       classtab[0].cclass += 5 + classtab[0].cclass / 4;
+       classtab = TypeRealloc(struct classentry,
+                                (unsigned) classtab[0].cclass, classtab);
+       if (!classtab)
+           abort();
+    }
+
+    /* simply append new interval to end of interval array */
+    classtab[0].last++;
+    classtab[classtab[0].last].first = low;
+    classtab[classtab[0].last].last = high;
+    classtab[classtab[0].last].cclass = value;
+
+    return 0;
+}
+
+typedef enum {
+    IDENT = -1,
+    ALNUM = 48,
+    CNTRL = 1,
+    BLANK = 32
+} Classes;
+
+void
+init_classtab(void)
+{
+    const int size = 50;
+
+    classtab = TypeMallocN(struct classentry, (unsigned) size);
+    if (!classtab)
+       abort();
+    classtab[0].cclass = size;
+    classtab[0].first = 1;
+    classtab[0].last = 0;
+
+    /* old xterm default classes */
+    SetCharacterClassRange(0, 0, BLANK);
+    SetCharacterClassRange(1, 31, CNTRL);
+    SetCharacterClassRange('\t', '\t', BLANK);
+    SetCharacterClassRange('0', '9', ALNUM);
+    SetCharacterClassRange('A', 'Z', ALNUM);
+    SetCharacterClassRange('_', '_', ALNUM);
+    SetCharacterClassRange('a', 'z', ALNUM);
+    SetCharacterClassRange(127, 159, CNTRL);
+    SetCharacterClassRange(160, 191, IDENT);
+    SetCharacterClassRange(192, 255, ALNUM);
+    SetCharacterClassRange(215, 215, IDENT);
+    SetCharacterClassRange(247, 247, IDENT);
+
+    /* added Unicode classes */
+    SetCharacterClassRange(0x0100, 0xffdf, ALNUM);     /* mostly characters */
+    SetCharacterClassRange(0x037e, 0x037e, IDENT);     /* Greek question mark */
+    SetCharacterClassRange(0x0387, 0x0387, IDENT);     /* Greek ano teleia */
+    SetCharacterClassRange(0x055a, 0x055f, IDENT);     /* Armenian punctuation */
+    SetCharacterClassRange(0x0589, 0x0589, IDENT);     /* Armenian full stop */
+    SetCharacterClassRange(0x0700, 0x070d, IDENT);     /* Syriac punctuation */
+    SetCharacterClassRange(0x104a, 0x104f, IDENT);     /* Myanmar punctuation */
+    SetCharacterClassRange(0x10fb, 0x10fb, IDENT);     /* Georgian punctuation */
+    SetCharacterClassRange(0x1361, 0x1368, IDENT);     /* Ethiopic punctuation */
+    SetCharacterClassRange(0x166d, 0x166e, IDENT);     /* Canadian Syl. punctuation */
+    SetCharacterClassRange(0x17d4, 0x17dc, IDENT);     /* Khmer punctuation */
+    SetCharacterClassRange(0x1800, 0x180a, IDENT);     /* Mongolian punctuation */
+    SetCharacterClassRange(0x2000, 0x200a, BLANK);     /* spaces */
+    SetCharacterClassRange(0x200b, 0x27ff, IDENT);     /* punctuation and symbols */
+    SetCharacterClassRange(0x2070, 0x207f, 0x2070);    /* superscript */
+    SetCharacterClassRange(0x2080, 0x208f, 0x2080);    /* subscript */
+    SetCharacterClassRange(0x3000, 0x3000, BLANK);     /* ideographic space */
+    SetCharacterClassRange(0x3001, 0x3020, IDENT);     /* ideographic punctuation */
+    SetCharacterClassRange(0x3040, 0x309f, 0x3040);    /* Hiragana */
+    SetCharacterClassRange(0x30a0, 0x30ff, 0x30a0);    /* Katakana */
+    SetCharacterClassRange(0x3300, 0x9fff, 0x4e00);    /* CJK Ideographs */
+    SetCharacterClassRange(0xac00, 0xd7a3, 0xac00);    /* Hangul Syllables */
+    SetCharacterClassRange(0xf900, 0xfaff, 0x4e00);    /* CJK Ideographs */
+    SetCharacterClassRange(0xfe30, 0xfe6b, IDENT);     /* punctuation forms */
+    SetCharacterClassRange(0xff00, 0xff0f, IDENT);     /* half/fullwidth ASCII */
+    SetCharacterClassRange(0xff1a, 0xff20, IDENT);     /* half/fullwidth ASCII */
+    SetCharacterClassRange(0xff3b, 0xff40, IDENT);     /* half/fullwidth ASCII */
+    SetCharacterClassRange(0xff5b, 0xff64, IDENT);     /* half/fullwidth ASCII */
+
+    return;
+}
+
+int
+CharacterClass(int c)
+{
+    int i, cclass = IDENT;
+
+    for (i = classtab[0].first; i <= classtab[0].last; i++)
+       if (classtab[i].first <= c && classtab[i].last >= c)
+           cclass = classtab[i].cclass;
+
+    if (cclass < 0)
+       cclass = c;
+
+    return cclass;
+}
+
+#ifdef NO_LEAKS
+void
+noleaks_CharacterClass(void)
+{
+    if (classtab != 0) {
+       free(classtab);
+       classtab = 0;
+    }
+}
+#endif
+
+#endif /* OPT_WIDE_CHARS */
diff --git a/charclass.h b/charclass.h
new file mode 100644 (file)
index 0000000..0ba1804
--- /dev/null
@@ -0,0 +1,19 @@
+/* $XTermId: charclass.h,v 1.6 2006/02/13 01:14:58 tom Exp $ */
+
+/* $XFree86: xc/programs/xterm/charclass.h,v 1.3 2006/02/13 01:14:58 dickey Exp $ */
+
+#ifndef CHARCLASS_H
+#define CHARCLASS_H
+
+extern void init_classtab(void);
+/* intialise the table. needs calling before either of the 
+   others. */
+
+extern int SetCharacterClassRange(int low, int high, int value);
+extern int CharacterClass(int c);
+
+#ifdef NO_LEAKS
+extern void noleaks_CharacterClass(void);
+#endif
+
+#endif
diff --git a/charproc.c b/charproc.c
new file mode 100644 (file)
index 0000000..d11a221
--- /dev/null
@@ -0,0 +1,8839 @@
+/* $XTermId: charproc.c,v 1.1100 2011/02/09 10:15:36 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ * 
+ *                         All Rights Reserved
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ * 
+ * 
+ * Copyright 1988  The Open Group
+ * 
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of The Open Group shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from The Open Group.
+ * 
+ */
+/*
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* charproc.c */
+
+#include <version.h>
+#include <xterm.h>
+
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Converters.h>
+
+#if OPT_INPUT_METHOD
+
+#if defined(HAVE_LIB_XAW)
+#include <X11/Xaw/XawImP.h>
+#elif defined(HAVE_LIB_XAW3D)
+#include <X11/Xaw3d/XawImP.h>
+#elif defined(HAVE_LIB_NEXTAW)
+#include <X11/neXtaw/XawImP.h>
+#elif defined(HAVE_LIB_XAWPLUS)
+#include <X11/XawPlus/XawImP.h>
+#endif
+
+#endif
+
+#if OPT_WIDE_CHARS
+#include <wcwidth.h>
+#include <precompose.h>
+#ifdef HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+#endif
+
+#if OPT_INPUT_METHOD
+#include <X11/Xlocale.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <assert.h>
+
+#if defined(HAVE_SCHED_YIELD)
+#include <sched.h>
+#endif
+
+#include <VTparse.h>
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <main.h>
+#include <fontutils.h>
+#include <xcharmouse.h>
+#include <charclass.h>
+#include <xstrings.h>
+
+typedef struct {
+    const char *name;
+    int code;
+} FlagList;
+
+typedef void (*BitFunc) (unsigned * /* p */ ,
+                        unsigned /* mask */ );
+
+static IChar doinput(void);
+static int set_character_class(char * /*s */ );
+static void FromAlternate(XtermWidget /* xw */ );
+static void RequestResize(XtermWidget /* xw */ ,
+                         int /* rows */ ,
+                         int /* cols */ ,
+                         Bool /* text */ );
+static void SwitchBufs(XtermWidget /* xw */ ,
+                      int /* toBuf */ );
+static void ToAlternate(XtermWidget /* xw */ );
+static void ansi_modes(XtermWidget termw,
+                      BitFunc /* func */ );
+static void bitclr(unsigned *p, unsigned mask);
+static void bitcpy(unsigned *p, unsigned q, unsigned mask);
+static void bitset(unsigned *p, unsigned mask);
+static void dpmodes(XtermWidget /* xw */ ,
+                   BitFunc /* func */ );
+static void restoremodes(XtermWidget /* xw */ );
+static void savemodes(XtermWidget /* xw */ );
+static void window_ops(XtermWidget /* xw */ );
+
+#define DoStartBlinking(s) ((s)->cursor_blink ^ (s)->cursor_blink_esc)
+
+#if OPT_BLINK_CURS || OPT_BLINK_TEXT
+static void SetCursorBlink(TScreen * /* screen */ ,
+                          Bool /* enable */ );
+static void HandleBlinking(XtPointer /* closure */ ,
+                          XtIntervalId * /* id */ );
+static void StartBlinking(TScreen * /* screen */ );
+static void StopBlinking(TScreen * /* screen */ );
+#else
+#define StartBlinking(screen)  /* nothing */
+#define StopBlinking(screen)   /* nothing */
+#endif
+
+#if OPT_INPUT_METHOD
+static void PreeditPosition(TScreen * screen);
+#endif
+
+#define        DEFAULT         -1
+#define BELLSUPPRESSMSEC 200
+
+static int nparam;
+static ANSI reply;
+static int param[NPARAM];
+
+static jmp_buf vtjmpbuf;
+
+/* event handlers */
+static void HandleBell PROTO_XT_ACTIONS_ARGS;
+static void HandleIgnore PROTO_XT_ACTIONS_ARGS;
+static void HandleKeymapChange PROTO_XT_ACTIONS_ARGS;
+static void HandleVisualBell PROTO_XT_ACTIONS_ARGS;
+#if HANDLE_STRUCT_NOTIFY
+static void HandleStructNotify PROTO_XT_EV_HANDLER_ARGS;
+#endif
+
+/*
+ * NOTE: VTInitialize zeros out the entire ".screen" component of the
+ * XtermWidget, so make sure to add an assignment statement in VTInitialize()
+ * for each new ".screen" field added to this resource list.
+ */
+
+/* Defaults */
+#if OPT_ISO_COLORS
+
+/*
+ * If we default to colorMode enabled, compile-in defaults for the ANSI colors.
+ */
+#if DFT_COLORMODE
+#define DFT_COLOR(name) name
+#else
+#define DFT_COLOR(name) XtDefaultForeground
+#endif
+#endif
+
+static String _Font_Selected_ = "yes"; /* string is arbitrary */
+
+static char defaultTranslations[] =
+"\
+          Shift <KeyPress> Prior:scroll-back(1,halfpage) \n\
+           Shift <KeyPress> Next:scroll-forw(1,halfpage) \n\
+         Shift <KeyPress> Select:select-cursor-start() select-cursor-end(SELECT, CUT_BUFFER0) \n\
+         Shift <KeyPress> Insert:insert-selection(SELECT, CUT_BUFFER0) \n\
+"
+#if OPT_MAXIMIZE
+"\
+                 Alt <Key>Return:fullscreen() \n\
+"
+#endif
+#if OPT_SCROLL_LOCK
+"\
+        <KeyRelease> Scroll_Lock:scroll-lock() \n\
+"
+#endif
+#if OPT_SHIFT_FONTS
+"\
+    Shift~Ctrl <KeyPress> KP_Add:larger-vt-font() \n\
+    Shift Ctrl <KeyPress> KP_Add:smaller-vt-font() \n\
+    Shift <KeyPress> KP_Subtract:smaller-vt-font() \n\
+"
+#endif
+"\
+                ~Meta <KeyPress>:insert-seven-bit() \n\
+                 Meta <KeyPress>:insert-eight-bit() \n\
+                !Ctrl <Btn1Down>:popup-menu(mainMenu) \n\
+           !Lock Ctrl <Btn1Down>:popup-menu(mainMenu) \n\
+ !Lock Ctrl @Num_Lock <Btn1Down>:popup-menu(mainMenu) \n\
+     ! @Num_Lock Ctrl <Btn1Down>:popup-menu(mainMenu) \n\
+                ~Meta <Btn1Down>:select-start() \n\
+              ~Meta <Btn1Motion>:select-extend() \n\
+                !Ctrl <Btn2Down>:popup-menu(vtMenu) \n\
+           !Lock Ctrl <Btn2Down>:popup-menu(vtMenu) \n\
+ !Lock Ctrl @Num_Lock <Btn2Down>:popup-menu(vtMenu) \n\
+     ! @Num_Lock Ctrl <Btn2Down>:popup-menu(vtMenu) \n\
+          ~Ctrl ~Meta <Btn2Down>:ignore() \n\
+                 Meta <Btn2Down>:clear-saved-lines() \n\
+            ~Ctrl ~Meta <Btn2Up>:insert-selection(SELECT, CUT_BUFFER0) \n\
+                !Ctrl <Btn3Down>:popup-menu(fontMenu) \n\
+           !Lock Ctrl <Btn3Down>:popup-menu(fontMenu) \n\
+ !Lock Ctrl @Num_Lock <Btn3Down>:popup-menu(fontMenu) \n\
+     ! @Num_Lock Ctrl <Btn3Down>:popup-menu(fontMenu) \n\
+          ~Ctrl ~Meta <Btn3Down>:start-extend() \n\
+              ~Meta <Btn3Motion>:select-extend() \n\
+                 Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \n\
+            Lock Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \n\
+  Lock @Num_Lock Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \n\
+       @Num_Lock Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \n\
+                      <Btn4Down>:scroll-back(5,line,m)     \n\
+                 Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \n\
+            Lock Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \n\
+  Lock @Num_Lock Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \n\
+       @Num_Lock Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \n\
+                      <Btn5Down>:scroll-forw(5,line,m)     \n\
+                         <BtnUp>:select-end(SELECT, CUT_BUFFER0) \n\
+                       <BtnDown>:ignore() \
+";                             /* PROCURA added "Meta <Btn2Down>:clear-saved-lines()" */
+/* *INDENT-OFF* */
+static XtActionsRec actionsList[] = {
+    { "allow-send-events",     HandleAllowSends },
+    { "bell",                  HandleBell },
+    { "clear-saved-lines",     HandleClearSavedLines },
+    { "copy-selection",                HandleCopySelection },
+    { "create-menu",           HandleCreateMenu },
+    { "delete-is-del",         HandleDeleteIsDEL },
+    { "dired-button",          DiredButton },
+    { "hard-reset",            HandleHardReset },
+    { "ignore",                        HandleIgnore },
+    { "insert",                        HandleKeyPressed },  /* alias for insert-seven-bit */
+    { "insert-eight-bit",      HandleEightBitKeyPressed },
+    { "insert-selection",      HandleInsertSelection },
+    { "insert-seven-bit",      HandleKeyPressed },
+    { "interpret",             HandleInterpret },
+    { "keymap",                        HandleKeymapChange },
+    { "popup-menu",            HandlePopupMenu },
+    { "print",                 HandlePrintScreen },
+    { "print-everything",      HandlePrintEverything },
+    { "print-redir",           HandlePrintControlMode },
+    { "quit",                  HandleQuit },
+    { "redraw",                        HandleRedraw },
+    { "scroll-back",           HandleScrollBack },
+    { "scroll-forw",           HandleScrollForward },
+    { "secure",                        HandleSecure },
+    { "select-cursor-end",     HandleKeyboardSelectEnd },
+    { "select-cursor-extend",   HandleKeyboardSelectExtend },
+    { "select-cursor-start",   HandleKeyboardSelectStart },
+    { "select-end",            HandleSelectEnd },
+    { "select-extend",         HandleSelectExtend },
+    { "select-set",            HandleSelectSet },
+    { "select-start",          HandleSelectStart },
+    { "send-signal",           HandleSendSignal },
+    { "set-8-bit-control",     Handle8BitControl },
+    { "set-allow132",          HandleAllow132 },
+    { "set-altscreen",         HandleAltScreen },
+    { "set-appcursor",         HandleAppCursor },
+    { "set-appkeypad",         HandleAppKeypad },
+    { "set-autolinefeed",      HandleAutoLineFeed },
+    { "set-autowrap",          HandleAutoWrap },
+    { "set-backarrow",         HandleBackarrow },
+    { "set-bellIsUrgent",      HandleBellIsUrgent },
+    { "set-cursesemul",                HandleCursesEmul },
+    { "set-jumpscroll",                HandleJumpscroll },
+    { "set-keep-selection",    HandleKeepSelection },
+    { "set-marginbell",                HandleMarginBell },
+    { "set-old-function-keys", HandleOldFunctionKeys },
+    { "set-pop-on-bell",       HandleSetPopOnBell },
+    { "set-reverse-video",     HandleReverseVideo },
+    { "set-reversewrap",       HandleReverseWrap },
+    { "set-scroll-on-key",     HandleScrollKey },
+    { "set-scroll-on-tty-output", HandleScrollTtyOutput },
+    { "set-scrollbar",         HandleScrollbar },
+    { "set-select",            HandleSetSelect },
+    { "set-sun-keyboard",      HandleSunKeyboard },
+    { "set-titeInhibit",       HandleTiteInhibit },
+    { "set-visual-bell",       HandleSetVisualBell },
+    { "set-vt-font",           HandleSetFont },
+    { "soft-reset",            HandleSoftReset },
+    { "start-cursor-extend",   HandleKeyboardStartExtend },
+    { "start-extend",          HandleStartExtend },
+    { "string",                        HandleStringEvent },
+    { "vi-button",             ViButton },
+    { "visual-bell",           HandleVisualBell },
+#ifdef ALLOWLOGGING
+    { "set-logging",           HandleLogging },
+#endif
+#if OPT_ALLOW_XXX_OPS
+    { "allow-color-ops",       HandleAllowColorOps },
+    { "allow-font-ops",                HandleAllowFontOps },
+    { "allow-tcap-ops",                HandleAllowTcapOps },
+    { "allow-title-ops",       HandleAllowTitleOps },
+    { "allow-window-ops",      HandleAllowWindowOps },
+#endif
+#if OPT_BLINK_CURS
+    { "set-cursorblink",       HandleCursorBlink },
+#endif
+#if OPT_BOX_CHARS
+    { "set-font-linedrawing",  HandleFontBoxChars },
+    { "set-font-packed",       HandleFontPacked },
+#endif
+#if OPT_DABBREV
+    { "dabbrev-expand",                HandleDabbrevExpand },
+#endif
+#if OPT_DEC_CHRSET
+    { "set-font-doublesize",   HandleFontDoublesize },
+#endif
+#if OPT_DEC_SOFTFONT
+    { "set-font-loading",      HandleFontLoading },
+#endif
+#if OPT_EXEC_XTERM
+    { "spawn-new-terminal",    HandleSpawnTerminal },
+#endif
+#if OPT_HP_FUNC_KEYS
+    { "set-hp-function-keys",  HandleHpFunctionKeys },
+#endif
+#if OPT_LOAD_VTFONTS
+    { "load-vt-fonts",         HandleLoadVTFonts },
+#endif
+#if OPT_MAXIMIZE
+    { "deiconify",             HandleDeIconify },
+    { "fullscreen",            HandleFullscreen },
+    { "iconify",               HandleIconify },
+    { "maximize",              HandleMaximize },
+    { "restore",               HandleRestoreSize },
+#endif
+#if OPT_NUM_LOCK
+    { "alt-sends-escape",      HandleAltEsc },
+    { "meta-sends-escape",     HandleMetaEsc },
+    { "set-num-lock",          HandleNumLock },
+#endif
+#if OPT_READLINE
+    { "readline-button",       ReadLineButton },
+#endif
+#if OPT_RENDERFONT
+    { "set-render-font",       HandleRenderFont },
+#endif
+#if OPT_SCO_FUNC_KEYS
+    { "set-sco-function-keys", HandleScoFunctionKeys },
+#endif
+#if OPT_SCROLL_LOCK
+    { "scroll-lock",           HandleScrollLock },
+#endif
+#if OPT_SHIFT_FONTS
+    { "larger-vt-font",                HandleLargerFont },
+    { "smaller-vt-font",       HandleSmallerFont },
+#endif
+#if OPT_SUN_FUNC_KEYS
+    { "set-sun-function-keys", HandleSunFunctionKeys },
+#endif
+#if OPT_TEK4014
+    { "set-terminal-type",     HandleSetTerminalType },
+    { "set-visibility",                HandleVisibility },
+    { "set-tek-text",          HandleSetTekText },
+    { "tek-page",              HandleTekPage },
+    { "tek-reset",             HandleTekReset },
+    { "tek-copy",              HandleTekCopy },
+#endif
+#if OPT_TOOLBAR
+    { "set-toolbar",           HandleToolbar },
+#endif
+#if OPT_WIDE_CHARS
+    { "set-utf8-mode",         HandleUTF8Mode },
+    { "set-utf8-title",                HandleUTF8Title },
+#endif
+};
+/* *INDENT-ON* */
+
+static XtResource xterm_resources[] =
+{
+    Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False),
+    Bres(XtNallowColorOps, XtCAllowColorOps, screen.allowColorOp0, DEF_ALLOW_COLOR),
+    Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, DEF_ALLOW_FONT),
+    Bres(XtNallowTcapOps, XtCAllowTcapOps, screen.allowTcapOp0, DEF_ALLOW_TCAP),
+    Bres(XtNallowTitleOps, XtCAllowTitleOps, screen.allowTitleOp0, DEF_ALLOW_TITLE),
+    Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, DEF_ALLOW_WINDOW),
+    Bres(XtNaltIsNotMeta, XtCAltIsNotMeta, screen.alt_is_not_meta, False),
+    Bres(XtNaltSendsEscape, XtCAltSendsEscape, screen.alt_sends_esc, False),
+    Bres(XtNalwaysBoldMode, XtCAlwaysBoldMode, screen.always_bold_mode, False),
+    Bres(XtNalwaysHighlight, XtCAlwaysHighlight, screen.always_highlight, False),
+    Bres(XtNappcursorDefault, XtCAppcursorDefault, misc.appcursorDefault, False),
+    Bres(XtNappkeypadDefault, XtCAppkeypadDefault, misc.appkeypadDefault, False),
+    Bres(XtNautoWrap, XtCAutoWrap, misc.autoWrap, True),
+    Bres(XtNawaitInput, XtCAwaitInput, screen.awaitInput, False),
+    Bres(XtNfreeBoldBox, XtCFreeBoldBox, screen.free_bold_box, False),
+    Bres(XtNbackarrowKey, XtCBackarrowKey, screen.backarrow_key, True),
+    Bres(XtNbellIsUrgent, XtCBellIsUrgent, screen.bellIsUrgent, False),
+    Bres(XtNbellOnReset, XtCBellOnReset, screen.bellOnReset, True),
+    Bres(XtNboldMode, XtCBoldMode, screen.bold_mode, True),
+    Bres(XtNbrokenSelections, XtCBrokenSelections, screen.brokenSelections, False),
+    Bres(XtNc132, XtCC132, screen.c132, False),
+    Bres(XtNcurses, XtCCurses, screen.curses, False),
+    Bres(XtNcutNewline, XtCCutNewline, screen.cutNewline, True),
+    Bres(XtNcutToBeginningOfLine, XtCCutToBeginningOfLine,
+        screen.cutToBeginningOfLine, True),
+    Bres(XtNdeleteIsDEL, XtCDeleteIsDEL, screen.delete_is_del, DEFDELETE_DEL),
+    Bres(XtNdynamicColors, XtCDynamicColors, misc.dynamicColors, True),
+    Bres(XtNeightBitControl, XtCEightBitControl, screen.control_eight_bits, False),
+    Bres(XtNeightBitInput, XtCEightBitInput, screen.input_eight_bits, True),
+    Bres(XtNeightBitOutput, XtCEightBitOutput, screen.output_eight_bits, True),
+    Bres(XtNhighlightSelection, XtCHighlightSelection,
+        screen.highlight_selection, False),
+    Bres(XtNshowWrapMarks, XtCShowWrapMarks, screen.show_wrap_marks, False),
+    Bres(XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, screen.hp_ll_bc, False),
+    Bres(XtNi18nSelections, XtCI18nSelections, screen.i18nSelections, True),
+    Bres(XtNfastScroll, XtCFastScroll, screen.fastscroll, False),
+    Bres(XtNjumpScroll, XtCJumpScroll, screen.jumpscroll, True),
+    Bres(XtNkeepSelection, XtCKeepSelection, screen.keepSelection, True),
+    Bres(XtNloginShell, XtCLoginShell, misc.login_shell, False),
+    Bres(XtNmarginBell, XtCMarginBell, screen.marginbell, False),
+    Bres(XtNmetaSendsEscape, XtCMetaSendsEscape, screen.meta_sends_esc, False),
+    Bres(XtNmultiScroll, XtCMultiScroll, screen.multiscroll, False),
+    Bres(XtNoldXtermFKeys, XtCOldXtermFKeys, screen.old_fkeys, False),
+    Bres(XtNpopOnBell, XtCPopOnBell, screen.poponbell, False),
+    Bres(XtNprinterAutoClose, XtCPrinterAutoClose, screen.printer_autoclose, False),
+    Bres(XtNprinterExtent, XtCPrinterExtent, screen.printer_extent, False),
+    Bres(XtNprinterFormFeed, XtCPrinterFormFeed, screen.printer_formfeed, False),
+    Bres(XtNprinterNewLine, XtCPrinterNewLine, screen.printer_newline, True),
+    Bres(XtNquietGrab, XtCQuietGrab, screen.quiet_grab, False),
+    Bres(XtNreverseVideo, XtCReverseVideo, misc.re_verse, False),
+    Bres(XtNreverseWrap, XtCReverseWrap, misc.reverseWrap, False),
+    Bres(XtNscrollBar, XtCScrollBar, misc.scrollbar, False),
+    Bres(XtNscrollKey, XtCScrollCond, screen.scrollkey, False),
+    Bres(XtNscrollTtyOutput, XtCScrollCond, screen.scrollttyoutput, True),
+    Bres(XtNselectToClipboard, XtCSelectToClipboard,
+        screen.selectToClipboard, False),
+    Bres(XtNsignalInhibit, XtCSignalInhibit, misc.signalInhibit, False),
+    Bres(XtNtiteInhibit, XtCTiteInhibit, misc.titeInhibit, False),
+    Bres(XtNtiXtraScroll, XtCTiXtraScroll, misc.tiXtraScroll, False),
+    Bres(XtNtrimSelection, XtCTrimSelection, screen.trim_selection, False),
+    Bres(XtNunderLine, XtCUnderLine, screen.underline, True),
+    Bres(XtNvisualBell, XtCVisualBell, screen.visualbell, False),
+
+    Ires(XtNbellSuppressTime, XtCBellSuppressTime, screen.bellSuppressTime, BELLSUPPRESSMSEC),
+    Ires(XtNfontWarnings, XtCFontWarnings, misc.fontWarnings, fwResource),
+    Ires(XtNinternalBorder, XtCBorderWidth, screen.border, DEFBORDER),
+    Ires(XtNlimitResize, XtCLimitResize, misc.limit_resize, 1),
+    Ires(XtNmultiClickTime, XtCMultiClickTime, screen.multiClickTime, MULTICLICKTIME),
+    Ires(XtNnMarginBell, XtCColumn, screen.nmarginbell, N_MARGINBELL),
+    Ires(XtNpointerMode, XtCPointerMode, screen.pointer_mode, DEF_POINTER_MODE),
+    Ires(XtNprinterControlMode, XtCPrinterControlMode,
+        screen.printer_controlmode, 0),
+    Ires(XtNtitleModes, XtCTitleModes, screen.title_modes, DEF_TITLE_MODES),
+    Ires(XtNvisualBellDelay, XtCVisualBellDelay, screen.visualBellDelay, 100),
+    Ires(XtNsaveLines, XtCSaveLines, screen.savelines, SAVELINES),
+    Ires(XtNscrollBarBorder, XtCScrollBarBorder, screen.scrollBarBorder, 1),
+    Ires(XtNscrollLines, XtCScrollLines, screen.scrolllines, SCROLLLINES),
+
+    Sres(XtNinitialFont, XtCInitialFont, screen.initial_font, NULL),
+    Sres(XtNfont1, XtCFont1, screen.MenuFontName(fontMenu_font1), NULL),
+    Sres(XtNfont2, XtCFont2, screen.MenuFontName(fontMenu_font2), NULL),
+    Sres(XtNfont3, XtCFont3, screen.MenuFontName(fontMenu_font3), NULL),
+    Sres(XtNfont4, XtCFont4, screen.MenuFontName(fontMenu_font4), NULL),
+    Sres(XtNfont5, XtCFont5, screen.MenuFontName(fontMenu_font5), NULL),
+    Sres(XtNfont6, XtCFont6, screen.MenuFontName(fontMenu_font6), NULL),
+
+    Sres(XtNanswerbackString, XtCAnswerbackString, screen.answer_back, ""),
+    Sres(XtNboldFont, XtCBoldFont, misc.default_font.f_b, DEFBOLDFONT),
+    Sres(XtNcharClass, XtCCharClass, screen.charClass, NULL),
+    Sres(XtNdecTerminalID, XtCDecTerminalID, screen.term_id, DFT_DECID),
+    Sres(XtNdefaultString, XtCDefaultString, screen.default_string, "#"),
+    Sres(XtNdisallowedColorOps, XtCDisallowedColorOps,
+        screen.disallowedColorOps, DEF_DISALLOWED_COLOR),
+    Sres(XtNdisallowedFontOps, XtCDisallowedFontOps,
+        screen.disallowedFontOps, DEF_DISALLOWED_FONT),
+    Sres(XtNdisallowedTcapOps, XtCDisallowedTcapOps,
+        screen.disallowedTcapOps, DEF_DISALLOWED_TCAP),
+    Sres(XtNdisallowedWindowOps, XtCDisallowedWindowOps,
+        screen.disallowedWinOps, DEF_DISALLOWED_WINDOW),
+    Sres(XtNeightBitSelectTypes, XtCEightBitSelectTypes,
+        screen.eightbit_select_types, NULL),
+    Sres(XtNfont, XtCFont, misc.default_font.f_n, DEFFONT),
+    Sres(XtNgeometry, XtCGeometry, misc.geo_metry, NULL),
+    Sres(XtNkeyboardDialect, XtCKeyboardDialect, screen.keyboard_dialect, DFT_KBD_DIALECT),
+    Sres(XtNprinterCommand, XtCPrinterCommand, screen.printer_command, ""),
+    Sres(XtNtekGeometry, XtCGeometry, misc.T_geometry, NULL),
+
+    Tres(XtNcursorColor, XtCCursorColor, TEXT_CURSOR, XtDefaultForeground),
+    Tres(XtNforeground, XtCForeground, TEXT_FG, XtDefaultForeground),
+    Tres(XtNpointerColor, XtCPointerColor, MOUSE_FG, XtDefaultForeground),
+    Tres(XtNbackground, XtCBackground, TEXT_BG, XtDefaultBackground),
+    Tres(XtNpointerColorBackground, XtCBackground, MOUSE_BG, XtDefaultBackground),
+
+    {XtNresizeGravity, XtCResizeGravity, XtRGravity, sizeof(XtGravity),
+     XtOffsetOf(XtermWidgetRec, misc.resizeGravity),
+     XtRImmediate, (XtPointer) SouthWestGravity},
+
+    {XtNpointerShape, XtCCursor, XtRCursor, sizeof(Cursor),
+     XtOffsetOf(XtermWidgetRec, screen.pointer_cursor),
+     XtRString, (XtPointer) "xterm"},
+
+#ifdef ALLOWLOGGING
+    Bres(XtNlogInhibit, XtCLogInhibit, misc.logInhibit, False),
+    Bres(XtNlogging, XtCLogging, misc.log_on, False),
+    Sres(XtNlogFile, XtCLogfile, screen.logfile, NULL),
+#endif
+
+#ifndef NO_ACTIVE_ICON
+    Bres("activeIcon", "ActiveIcon", misc.active_icon, False),
+    Ires("iconBorderWidth", XtCBorderWidth, misc.icon_border_width, 2),
+    Sres("iconFont", "IconFont", screen.icon_fontname, "nil2"),
+    Cres("iconBorderColor", XtCBorderColor, misc.icon_border_pixel, XtDefaultBackground),
+#endif                         /* NO_ACTIVE_ICON */
+
+#if OPT_BLINK_CURS
+    Bres(XtNcursorBlink, XtCCursorBlink, screen.cursor_blink, False),
+#endif
+    Bres(XtNcursorUnderline, XtCCursorUnderline, screen.cursor_underline, False),
+
+#if OPT_BLINK_TEXT
+    Bres(XtNshowBlinkAsBold, XtCCursorBlink, screen.blink_as_bold, DEFBLINKASBOLD),
+#endif
+
+#if OPT_BLINK_CURS || OPT_BLINK_TEXT
+    Ires(XtNcursorOnTime, XtCCursorOnTime, screen.blink_on, 600),
+    Ires(XtNcursorOffTime, XtCCursorOffTime, screen.blink_off, 300),
+#endif
+
+#if OPT_BOX_CHARS
+    Bres(XtNforceBoxChars, XtCForceBoxChars, screen.force_box_chars, False),
+    Bres(XtNforcePackedFont, XtCForcePackedFont, screen.force_packed, True),
+    Bres(XtNshowMissingGlyphs, XtCShowMissingGlyphs, screen.force_all_chars, False),
+#endif
+
+#if OPT_BROKEN_OSC
+    Bres(XtNbrokenLinuxOSC, XtCBrokenLinuxOSC, screen.brokenLinuxOSC, True),
+#endif
+
+#if OPT_BROKEN_ST
+    Bres(XtNbrokenStringTerm, XtCBrokenStringTerm, screen.brokenStringTerm, True),
+#endif
+
+#if OPT_C1_PRINT
+    Bres(XtNallowC1Printable, XtCAllowC1Printable, screen.c1_printable, False),
+#endif
+
+#if OPT_CLIP_BOLD
+    Bres(XtNuseClipping, XtCUseClipping, screen.use_clipping, True),
+#endif
+
+#if OPT_DEC_CHRSET
+    Bres(XtNfontDoublesize, XtCFontDoublesize, screen.font_doublesize, True),
+    Ires(XtNcacheDoublesize, XtCCacheDoublesize, screen.cache_doublesize, NUM_CHRSET),
+#endif
+
+#if OPT_HIGHLIGHT_COLOR
+    Tres(XtNhighlightColor, XtCHighlightColor, HIGHLIGHT_BG, XtDefaultForeground),
+    Tres(XtNhighlightTextColor, XtCHighlightTextColor, HIGHLIGHT_FG, XtDefaultBackground),
+    Bres(XtNhighlightReverse, XtCHighlightReverse, screen.hilite_reverse, True),
+    Bres(XtNhighlightColorMode, XtCHighlightColorMode, screen.hilite_color, Maybe),
+#endif                         /* OPT_HIGHLIGHT_COLOR */
+
+#if OPT_INPUT_METHOD
+    Bres(XtNopenIm, XtCOpenIm, misc.open_im, True),
+    Sres(XtNinputMethod, XtCInputMethod, misc.input_method, NULL),
+    Sres(XtNpreeditType, XtCPreeditType, misc.preedit_type,
+        "OverTheSpot,Root"),
+    Ires(XtNretryInputMethod, XtCRetryInputMethod, misc.retry_im, 3),
+#endif
+
+#if OPT_ISO_COLORS
+    Bres(XtNboldColors, XtCColorMode, screen.boldColors, True),
+    Ires(XtNveryBoldColors, XtCVeryBoldColors, screen.veryBoldColors, 0),
+    Bres(XtNcolorMode, XtCColorMode, screen.colorMode, DFT_COLORMODE),
+
+    Bres(XtNcolorAttrMode, XtCColorAttrMode, screen.colorAttrMode, False),
+    Bres(XtNcolorBDMode, XtCColorAttrMode, screen.colorBDMode, False),
+    Bres(XtNcolorBLMode, XtCColorAttrMode, screen.colorBLMode, False),
+    Bres(XtNcolorRVMode, XtCColorAttrMode, screen.colorRVMode, False),
+    Bres(XtNcolorULMode, XtCColorAttrMode, screen.colorULMode, False),
+    Bres(XtNitalicULMode, XtCColorAttrMode, screen.italicULMode, False),
+
+    COLOR_RES("0", screen.Acolors[COLOR_0], DFT_COLOR("black")),
+    COLOR_RES("1", screen.Acolors[COLOR_1], DFT_COLOR("red3")),
+    COLOR_RES("2", screen.Acolors[COLOR_2], DFT_COLOR("green3")),
+    COLOR_RES("3", screen.Acolors[COLOR_3], DFT_COLOR("yellow3")),
+    COLOR_RES("4", screen.Acolors[COLOR_4], DFT_COLOR(DEF_COLOR4)),
+    COLOR_RES("5", screen.Acolors[COLOR_5], DFT_COLOR("magenta3")),
+    COLOR_RES("6", screen.Acolors[COLOR_6], DFT_COLOR("cyan3")),
+    COLOR_RES("7", screen.Acolors[COLOR_7], DFT_COLOR("gray90")),
+    COLOR_RES("8", screen.Acolors[COLOR_8], DFT_COLOR("gray50")),
+    COLOR_RES("9", screen.Acolors[COLOR_9], DFT_COLOR("red")),
+    COLOR_RES("10", screen.Acolors[COLOR_10], DFT_COLOR("green")),
+    COLOR_RES("11", screen.Acolors[COLOR_11], DFT_COLOR("yellow")),
+    COLOR_RES("12", screen.Acolors[COLOR_12], DFT_COLOR(DEF_COLOR12)),
+    COLOR_RES("13", screen.Acolors[COLOR_13], DFT_COLOR("magenta")),
+    COLOR_RES("14", screen.Acolors[COLOR_14], DFT_COLOR("cyan")),
+    COLOR_RES("15", screen.Acolors[COLOR_15], DFT_COLOR("white")),
+    COLOR_RES("BD", screen.Acolors[COLOR_BD], DFT_COLOR(XtDefaultForeground)),
+    COLOR_RES("BL", screen.Acolors[COLOR_BL], DFT_COLOR(XtDefaultForeground)),
+    COLOR_RES("UL", screen.Acolors[COLOR_UL], DFT_COLOR(XtDefaultForeground)),
+    COLOR_RES("RV", screen.Acolors[COLOR_RV], DFT_COLOR(XtDefaultForeground)),
+
+#if !OPT_COLOR_RES2
+#if OPT_256_COLORS
+# include <256colres.h>
+#elif OPT_88_COLORS
+# include <88colres.h>
+#endif
+#endif                         /* !OPT_COLOR_RES2 */
+
+#endif                         /* OPT_ISO_COLORS */
+
+    CLICK_RES("2", screen.onClick[1], "word"),
+    CLICK_RES("3", screen.onClick[2], "line"),
+    CLICK_RES("4", screen.onClick[3], 0),
+    CLICK_RES("5", screen.onClick[4], 0),
+
+#if OPT_MOD_FKEYS
+    Ires(XtNmodifyCursorKeys, XtCModifyCursorKeys,
+        keyboard.modify_1st.cursor_keys, 2),
+    Ires(XtNmodifyFunctionKeys, XtCModifyFunctionKeys,
+        keyboard.modify_1st.function_keys, 2),
+    Ires(XtNmodifyKeypadKeys, XtCModifyKeypadKeys,
+        keyboard.modify_1st.keypad_keys, 0),
+    Ires(XtNmodifyOtherKeys, XtCModifyOtherKeys,
+        keyboard.modify_1st.other_keys, 0),
+    Ires(XtNmodifyStringKeys, XtCModifyStringKeys,
+        keyboard.modify_1st.string_keys, 0),
+    Ires(XtNformatOtherKeys, XtCFormatOtherKeys,
+        keyboard.format_keys, 0),
+#endif
+
+#if OPT_NUM_LOCK
+    Bres(XtNalwaysUseMods, XtCAlwaysUseMods, misc.alwaysUseMods, False),
+    Bres(XtNnumLock, XtCNumLock, misc.real_NumLock, True),
+#endif
+
+#if OPT_PRINT_COLORS
+    Ires(XtNprintAttributes, XtCPrintAttributes, screen.print_attributes, 1),
+#endif
+
+#if OPT_SHIFT_FONTS
+    Bres(XtNshiftFonts, XtCShiftFonts, misc.shift_fonts, True),
+#endif
+
+#if OPT_SUNPC_KBD
+    Ires(XtNctrlFKeys, XtCCtrlFKeys, misc.ctrl_fkeys, 10),
+#endif
+
+#if OPT_TEK4014
+    Bres(XtNtekInhibit, XtCTekInhibit, misc.tekInhibit, False),
+    Bres(XtNtekSmall, XtCTekSmall, misc.tekSmall, False),
+    Bres(XtNtekStartup, XtCTekStartup, misc.TekEmu, False),
+#endif
+
+#if OPT_TOOLBAR
+    Wres(XtNmenuBar, XtCMenuBar, VT100_TB_INFO(menu_bar), 0),
+    Ires(XtNmenuHeight, XtCMenuHeight, VT100_TB_INFO(menu_height), 25),
+#endif
+
+#if OPT_WIDE_CHARS
+    Bres(XtNcjkWidth, XtCCjkWidth, misc.cjk_width, False),
+    Bres(XtNmkWidth, XtCMkWidth, misc.mk_width, False),
+    Bres(XtNutf8Latin1, XtCUtf8Latin1, screen.utf8_latin1, False),
+    Bres(XtNutf8Title, XtCUtf8Title, screen.utf8_title, False),
+    Bres(XtNvt100Graphics, XtCVT100Graphics, screen.vt100_graphics, True),
+    Bres(XtNwideChars, XtCWideChars, screen.wide_chars, False),
+    Ires(XtNcombiningChars, XtCCombiningChars, screen.max_combining, 2),
+    Ires(XtNmkSamplePass, XtCMkSamplePass, misc.mk_samplepass, 256),
+    Ires(XtNmkSampleSize, XtCMkSampleSize, misc.mk_samplesize, 1024),
+    Ires(XtNutf8, XtCUtf8, screen.utf8_mode, uDefault),
+    Sres(XtNwideBoldFont, XtCWideBoldFont, misc.default_font.f_wb, DEFWIDEBOLDFONT),
+    Sres(XtNwideFont, XtCWideFont, misc.default_font.f_w, DEFWIDEFONT),
+    Sres(XtNutf8SelectTypes, XtCUtf8SelectTypes, screen.utf8_select_types, NULL),
+#endif
+
+#if OPT_LUIT_PROG
+    Sres(XtNlocale, XtCLocale, misc.locale_str, "medium"),
+    Sres(XtNlocaleFilter, XtCLocaleFilter, misc.localefilter, DEFLOCALEFILTER),
+#endif
+
+#if OPT_INPUT_METHOD
+    Sres(XtNximFont, XtCXimFont, misc.f_x, DEFXIMFONT),
+#endif
+
+#if OPT_SCROLL_LOCK
+    Bres(XtNallowScrollLock, XtCAllowScrollLock, screen.allowScrollLock0, False),
+#endif
+
+#if OPT_XMC_GLITCH
+    Bres(XtNxmcInline, XtCXmcInline, screen.xmc_inline, False),
+    Bres(XtNxmcMoveSGR, XtCXmcMoveSGR, screen.move_sgr_ok, True),
+    Ires(XtNxmcAttributes, XtCXmcAttributes, screen.xmc_attributes, 1),
+    Ires(XtNxmcGlitch, XtCXmcGlitch, screen.xmc_glitch, 0),
+#endif
+
+#ifdef SCROLLBAR_RIGHT
+    Bres(XtNrightScrollBar, XtCRightScrollBar, misc.useRight, False),
+#endif
+
+#if OPT_RENDERFONT
+#define RES_FACESIZE(n) Dres(XtNfaceSize #n, XtCFaceSize #n, misc.face_size[n], "0.0")
+    RES_FACESIZE(1),
+    RES_FACESIZE(2),
+    RES_FACESIZE(3),
+    RES_FACESIZE(4),
+    RES_FACESIZE(5),
+    RES_FACESIZE(6),
+    Dres(XtNfaceSize, XtCFaceSize, misc.face_size[0], DEFFACESIZE),
+    Sres(XtNfaceName, XtCFaceName, misc.face_name, DEFFACENAME),
+    Sres(XtNfaceNameDoublesize, XtCFaceNameDoublesize, misc.face_wide_name, DEFFACENAME),
+    Sres(XtNrenderFont, XtCRenderFont, misc.render_font_s, "default"),
+#endif
+};
+
+static Boolean VTSetValues(Widget cur, Widget request, Widget new_arg,
+                          ArgList args, Cardinal *num_args);
+static void VTClassInit(void);
+static void VTDestroy(Widget w);
+static void VTExpose(Widget w, XEvent * event, Region region);
+static void VTInitialize(Widget wrequest, Widget new_arg, ArgList args,
+                        Cardinal *num_args);
+static void VTRealize(Widget w, XtValueMask * valuemask,
+                     XSetWindowAttributes * values);
+static void VTResize(Widget w);
+
+#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
+static void VTInitI18N(XtermWidget);
+#endif
+
+#ifdef VMS
+globaldef {
+    "xtermclassrec"
+} noshare
+
+#else
+static
+#endif                         /* VMS */
+WidgetClassRec xtermClassRec =
+{
+    {
+       /* core_class fields */
+       (WidgetClass) & widgetClassRec,         /* superclass   */
+       "VT100",                /* class_name                   */
+       sizeof(XtermWidgetRec), /* widget_size                  */
+       VTClassInit,            /* class_initialize             */
+       NULL,                   /* class_part_initialize        */
+       False,                  /* class_inited                 */
+       VTInitialize,           /* initialize                   */
+       NULL,                   /* initialize_hook              */
+       VTRealize,              /* realize                      */
+       actionsList,            /* actions                      */
+       XtNumber(actionsList),  /* num_actions                  */
+       xterm_resources,        /* resources                    */
+       XtNumber(xterm_resources),      /* num_resources        */
+       NULLQUARK,              /* xrm_class                    */
+       True,                   /* compress_motion              */
+       False,                  /* compress_exposure            */
+       True,                   /* compress_enterleave          */
+       False,                  /* visible_interest             */
+       VTDestroy,              /* destroy                      */
+       VTResize,               /* resize                       */
+       VTExpose,               /* expose                       */
+       VTSetValues,            /* set_values                   */
+       NULL,                   /* set_values_hook              */
+       XtInheritSetValuesAlmost,       /* set_values_almost    */
+       NULL,                   /* get_values_hook              */
+       NULL,                   /* accept_focus                 */
+       XtVersion,              /* version                      */
+       NULL,                   /* callback_offsets             */
+       defaultTranslations,    /* tm_table                     */
+       XtInheritQueryGeometry, /* query_geometry               */
+       XtInheritDisplayAccelerator,    /* display_accelerator  */
+       NULL                    /* extension                    */
+    }
+};
+
+#ifdef VMS
+globaldef {
+    "xtermwidgetclass"
+}
+noshare
+#endif /* VMS */
+WidgetClass xtermWidgetClass = (WidgetClass) & xtermClassRec;
+
+/*
+ * Add input-actions for widgets that are overlooked (scrollbar and toolbar):
+ *
+ *     a) Sometimes the scrollbar passes through translations, sometimes it
+ *        doesn't.  We add the KeyPress translations here, just to be sure.
+ *     b) In the normal (non-toolbar) configuration, the xterm widget covers
+ *        almost all of the window.  With a toolbar, there's a relatively
+ *        large area that the user would expect to enter keystrokes since the
+ *        program can get the focus.
+ */
+void
+xtermAddInput(Widget w)
+{
+    /* *INDENT-OFF* */
+    XtActionsRec input_actions[] = {
+       { "insert",                 HandleKeyPressed }, /* alias */
+       { "insert-eight-bit",       HandleEightBitKeyPressed },
+       { "insert-seven-bit",       HandleKeyPressed },
+       { "secure",                 HandleSecure },
+       { "string",                 HandleStringEvent },
+       { "scroll-back",            HandleScrollBack },
+       { "scroll-forw",            HandleScrollForward },
+       { "select-cursor-end",      HandleKeyboardSelectEnd },
+       { "select-cursor-extend",   HandleKeyboardSelectExtend },
+       { "select-cursor-start",    HandleKeyboardSelectStart },
+       { "insert-selection",       HandleInsertSelection },
+       { "select-start",           HandleSelectStart },
+       { "select-extend",          HandleSelectExtend },
+       { "start-extend",           HandleStartExtend },
+       { "select-end",             HandleSelectEnd },
+       { "clear-saved-lines",      HandleClearSavedLines },
+       { "popup-menu",             HandlePopupMenu },
+       { "bell",                   HandleBell },
+       { "ignore",                 HandleIgnore },
+#if OPT_DABBREV
+       { "dabbrev-expand",         HandleDabbrevExpand },
+#endif
+#if OPT_MAXIMIZE
+       { "fullscreen",             HandleFullscreen },
+#endif
+#if OPT_SCROLL_LOCK
+       { "scroll-lock",            HandleScrollLock },
+#endif
+#if OPT_SHIFT_FONTS
+       { "larger-vt-font",         HandleLargerFont },
+       { "smaller-vt-font",        HandleSmallerFont },
+#endif
+    };
+    /* *INDENT-ON* */
+
+    TRACE_TRANS("BEFORE", w);
+    XtAppAddActions(app_con, input_actions, XtNumber(input_actions));
+    XtAugmentTranslations(w, XtParseTranslationTable(defaultTranslations));
+    TRACE_TRANS("AFTER:", w);
+
+#if OPT_EXTRA_PASTE
+    if (term && term->keyboard.extra_translations)
+       XtOverrideTranslations((Widget) term, XtParseTranslationTable(term->keyboard.extra_translations));
+#endif
+}
+
+#if OPT_ISO_COLORS
+#ifdef EXP_BOGUS_FG
+static Bool
+CheckBogusForeground(TScreen * screen, const char *tag)
+{
+    int row = -1, col = -1, pass;
+    Bool isClear = True;
+
+    (void) tag;
+    for (pass = 0; pass < 2; ++pass) {
+       row = screen->cur_row;
+       for (; isClear && (row <= screen->max_row); ++row) {
+           LineData *ld = getLineData(screen, row)->;
+
+           if (ld != 0) {
+               Char *attribs = ld->attribs;
+
+               col = (row == screen->cur_row) ? screen->cur_col : 0;
+               for (; isClear && (col <= screen->max_col); ++col) {
+                   unsigned flags = attribs[col];
+                   if (pass) {
+                       flags &= ~FG_COLOR;
+                       attribs[col] = (Char) flags;
+                   } else if ((flags & BG_COLOR)) {
+                       isClear = False;
+                   } else if ((flags & FG_COLOR)) {
+                       unsigned ch = ld->charData[col];
+                       isClear = ((ch == ' ') || (ch == 0));
+                   } else {
+                       isClear = False;
+                   }
+               }
+           }
+       }
+    }
+    TRACE(("%s checked %d,%d to %d,%d %s pass %d\n",
+          tag, screen->cur_row, screen->cur_col,
+          row, col,
+          isClear && pass ? "cleared" : "unchanged",
+          pass));
+
+    return isClear;
+}
+#endif
+
+/*
+ * The terminal's foreground and background colors are set via two mechanisms:
+ *     text (cur_foreground, cur_background values that are passed down to
+ *             XDrawImageString and XDrawString)
+ *     area (X11 graphics context used in XClearArea and XFillRectangle)
+ */
+void
+SGR_Foreground(XtermWidget xw, int color)
+{
+    TScreen *screen = TScreenOf(xw);
+    Pixel fg;
+
+    if (color >= 0) {
+       UIntSet(xw->flags, FG_COLOR);
+    } else {
+       UIntClr(xw->flags, FG_COLOR);
+    }
+    fg = getXtermForeground(xw, xw->flags, color);
+    xw->cur_foreground = color;
+
+    setCgsFore(xw, WhichVWin(screen), gcNorm, fg);
+    setCgsBack(xw, WhichVWin(screen), gcNormReverse, fg);
+
+    setCgsFore(xw, WhichVWin(screen), gcBold, fg);
+    setCgsBack(xw, WhichVWin(screen), gcBoldReverse, fg);
+
+#ifdef EXP_BOGUS_FG
+    /*
+     * If we've just turned off the foreground color, check for blank cells
+     * which have no background color, but do have foreground color.  This
+     * could happen due to setting the foreground color just before scrolling.
+     *
+     * Those cells look uncolored, but will confuse ShowCursor(), which looks
+     * for the colors in the current cell, and will see the foreground color.
+     * In that case, remove the foreground color from the blank cells.
+     */
+    if (color < 0) {
+       CheckBogusForeground(screen, "SGR_Foreground");
+    }
+#endif
+}
+
+void
+SGR_Background(XtermWidget xw, int color)
+{
+    TScreen *screen = TScreenOf(xw);
+    Pixel bg;
+
+    /*
+     * An indexing operation may have set screen->scroll_amt, which would
+     * normally result in calling FlushScroll() in WriteText().  However,
+     * if we're changing the background color now, then the new value
+     * should not apply to the pending blank lines.
+     */
+    if (screen->scroll_amt && (color != xw->cur_background))
+       FlushScroll(xw);
+
+    if (color >= 0) {
+       UIntSet(xw->flags, BG_COLOR);
+    } else {
+       UIntClr(xw->flags, BG_COLOR);
+    }
+    bg = getXtermBackground(xw, xw->flags, color);
+    xw->cur_background = color;
+
+    setCgsBack(xw, WhichVWin(screen), gcNorm, bg);
+    setCgsFore(xw, WhichVWin(screen), gcNormReverse, bg);
+
+    setCgsBack(xw, WhichVWin(screen), gcBold, bg);
+    setCgsFore(xw, WhichVWin(screen), gcBoldReverse, bg);
+}
+
+/* Invoked after updating bold/underline flags, computes the extended color
+ * index to use for foreground.  (See also 'extract_fg()').
+ */
+static void
+setExtendedFG(XtermWidget xw)
+{
+    int fg = xw->sgr_foreground;
+
+    if (TScreenOf(xw)->colorAttrMode
+       || (fg < 0)) {
+       fg = MapToColorMode(fg, TScreenOf(xw), xw->flags);
+    }
+
+    /* This implements the IBM PC-style convention of 8-colors, with one
+     * bit for bold, thus mapping the 0-7 codes to 8-15.  It won't make
+     * much sense for 16-color applications, but we keep it to retain
+     * compatiblity with ANSI-color applications.
+     */
+#if OPT_PC_COLORS              /* XXXJTL should be settable at runtime (resource or OSC?) */
+    if (TScreenOf(xw)->boldColors
+       && (!xw->sgr_extended)
+       && (fg >= 0)
+       && (fg < 8)
+       && (xw->flags & BOLD))
+       fg |= 8;
+#endif
+
+    SGR_Foreground(xw, fg);
+}
+
+/* Invoked after updating inverse flag, computes the extended color
+ * index to use for background.  (See also 'extract_bg()').
+ */
+static void
+setExtendedBG(XtermWidget xw)
+{
+    int bg = xw->sgr_background;
+
+    if (TScreenOf(xw)->colorAttrMode
+       || (bg < 0)) {
+       if (TScreenOf(xw)->colorRVMode && (xw->flags & INVERSE))
+           bg = COLOR_RV;
+    }
+
+    SGR_Background(xw, bg);
+}
+
+static void
+reset_SGR_Foreground(XtermWidget xw)
+{
+    xw->sgr_foreground = -1;
+    xw->sgr_extended = False;
+    setExtendedFG(xw);
+}
+
+static void
+reset_SGR_Background(XtermWidget xw)
+{
+    xw->sgr_background = -1;
+    setExtendedBG(xw);
+}
+
+static void
+reset_SGR_Colors(XtermWidget xw)
+{
+    reset_SGR_Foreground(xw);
+    reset_SGR_Background(xw);
+}
+#endif /* OPT_ISO_COLORS */
+
+void
+resetCharsets(TScreen * screen)
+{
+    TRACE(("resetCharsets\n"));
+
+    screen->gsets[0] = 'B';    /* ASCII_G              */
+    screen->gsets[1] = 'B';    /* ASCII_G              */
+    screen->gsets[2] = 'B';    /* ASCII_G              */
+    screen->gsets[3] = 'B';    /* ASCII_G              */
+
+    screen->curgl = 0;         /* G0 => GL.            */
+    screen->curgr = 2;         /* G2 => GR.            */
+    screen->curss = 0;         /* No single shift.     */
+
+#if OPT_VT52_MODE
+    if (screen->vtXX_level == 0)
+       screen->gsets[1] = '0'; /* Graphics             */
+#endif
+}
+
+/*
+ * VT300 and up support three ANSI conformance levels, defined according to
+ * the dpANSI X3.134.1 standard.  DEC's manuals equate levels 1 and 2, and
+ * are unclear.  This code is written based on the manuals.
+ */
+static void
+set_ansi_conformance(TScreen * screen, int level)
+{
+    TRACE(("set_ansi_conformance(%d) terminal_id %d, ansi_level %d\n",
+          level,
+          screen->terminal_id,
+          screen->ansi_level));
+    if (screen->vtXX_level >= 3) {
+       switch (screen->ansi_level = level) {
+       case 1:
+           /* FALLTHRU */
+       case 2:
+           screen->gsets[0] = 'B';     /* G0 is ASCII */
+           screen->gsets[1] = 'B';     /* G1 is ISO Latin-1 (FIXME) */
+           screen->curgl = 0;
+           screen->curgr = 1;
+           break;
+       case 3:
+           screen->gsets[0] = 'B';     /* G0 is ASCII */
+           screen->curgl = 0;
+           break;
+       }
+    }
+}
+
+/*
+ * Set scrolling margins.  VTxxx terminals require that the top/bottom are
+ * different, so we have at least two lines in the scrolling region.
+ */
+void
+set_tb_margins(TScreen * screen, int top, int bottom)
+{
+    TRACE(("set_tb_margins %d..%d, prior %d..%d\n",
+          top, bottom,
+          screen->top_marg,
+          screen->bot_marg));
+    if (bottom > top) {
+       screen->top_marg = top;
+       screen->bot_marg = bottom;
+    }
+    if (screen->top_marg > screen->max_row)
+       screen->top_marg = screen->max_row;
+    if (screen->bot_marg > screen->max_row)
+       screen->bot_marg = screen->max_row;
+}
+
+void
+set_max_col(TScreen * screen, int cols)
+{
+    TRACE(("set_max_col %d, prior %d\n", cols, screen->max_col));
+    if (cols < 0)
+       cols = 0;
+    screen->max_col = cols;
+}
+
+void
+set_max_row(TScreen * screen, int rows)
+{
+    TRACE(("set_max_row %d, prior %d\n", rows, screen->max_row));
+    if (rows < 0)
+       rows = 0;
+    screen->max_row = rows;
+}
+
+#if OPT_MOD_FKEYS
+static void
+set_mod_fkeys(XtermWidget xw, int which, int what, Bool enabled)
+{
+#define SET_MOD_FKEYS(field) \
+    xw->keyboard.modify_now.field = ((what == DEFAULT) && enabled) \
+                                    ? xw->keyboard.modify_1st.field \
+                                    : what; \
+    TRACE(("set modify_now.%s to %d\n", #field, \
+          xw->keyboard.modify_now.field));
+
+    switch (which) {
+    case 1:
+       SET_MOD_FKEYS(cursor_keys);
+       break;
+    case 2:
+       SET_MOD_FKEYS(function_keys);
+       break;
+    case 3:
+       SET_MOD_FKEYS(keypad_keys);
+       break;
+    case 4:
+       SET_MOD_FKEYS(other_keys);
+       break;
+    case 5:
+       SET_MOD_FKEYS(string_keys);
+       break;
+    }
+}
+#endif /* OPT_MOD_FKEYS */
+
+#if OPT_TRACE
+#define WHICH_TABLE(name) if (table == name) result = #name
+static const char *
+which_table(Const PARSE_T * table)
+{
+    const char *result = "?";
+    /* *INDENT-OFF* */
+    WHICH_TABLE (ansi_table);
+    else WHICH_TABLE (cigtable);
+    else WHICH_TABLE (csi2_table);
+    else WHICH_TABLE (csi_ex_table);
+    else WHICH_TABLE (csi_quo_table);
+    else WHICH_TABLE (csi_table);
+    else WHICH_TABLE (dec2_table);
+    else WHICH_TABLE (dec3_table);
+    else WHICH_TABLE (dec_table);
+    else WHICH_TABLE (eigtable);
+    else WHICH_TABLE (esc_sp_table);
+    else WHICH_TABLE (esc_table);
+    else WHICH_TABLE (scrtable);
+    else WHICH_TABLE (scs96table);
+    else WHICH_TABLE (scstable);
+    else WHICH_TABLE (sos_table);
+#if OPT_BLINK_CURS
+    else WHICH_TABLE (csi_sp_table);
+#endif
+#if OPT_DEC_LOCATOR
+    else WHICH_TABLE (csi_tick_table);
+#endif
+#if OPT_DEC_RECTOPS
+    else WHICH_TABLE (csi_dollar_table);
+    else WHICH_TABLE (csi_star_table);
+    else WHICH_TABLE (csi_dec_dollar_table);
+#endif
+#if OPT_WIDE_CHARS
+    else WHICH_TABLE (esc_pct_table);
+#endif
+#if OPT_VT52_MODE
+    else WHICH_TABLE (vt52_table);
+    else WHICH_TABLE (vt52_esc_table);
+    else WHICH_TABLE (vt52_ignore_table);
+#endif
+    /* *INDENT-ON* */
+
+    return result;
+}
+#endif
+
+       /* allocate larger buffer if needed/possible */
+#define SafeAlloc(type, area, used, size) \
+               type *new_string = area; \
+               size_t new_length = size; \
+               if (new_length == 0) { \
+                   new_length = 256; \
+                   new_string = TypeMallocN(type, new_length); \
+               } else if (used+1 >= new_length) { \
+                   new_length = size * 2; \
+                   new_string = TypeMallocN(type, new_length); \
+                   if (new_string != 0 \
+                    && area != 0 \
+                    && used != 0) \
+                       memcpy(new_string, area, used * sizeof(type)); \
+               }
+
+#define WriteNow() {                                           \
+           unsigned single = 0;                                \
+                                                               \
+           if (screen->curss) {                                \
+               dotext(xw,                                      \
+                      screen->gsets[(int) (screen->curss)],    \
+                      sp->print_area,                          \
+                      (Cardinal) 1);                           \
+               screen->curss = 0;                              \
+               single++;                                       \
+           }                                                   \
+           if (sp->print_used > single) {                      \
+               dotext(xw,                                      \
+                      screen->gsets[(int) (screen->curgl)],    \
+                      sp->print_area + single,                 \
+                      (Cardinal) (sp->print_used - single));   \
+           }                                                   \
+           sp->print_used = 0;                                 \
+       }                                                       \
+
+struct ParseState {
+#if OPT_VT52_MODE
+    Bool vt52_cup;
+#endif
+    Const PARSE_T *groundtable;
+    Const PARSE_T *parsestate;
+    int scstype;
+    int scssize;
+    Bool private_function;     /* distinguish private-mode from standard */
+    int string_mode;           /* nonzero iff we're processing a string */
+    int lastchar;              /* positive iff we had a graphic character */
+    int nextstate;
+#if OPT_WIDE_CHARS
+    int last_was_wide;
+#endif
+    /* Buffer for processing printable text */
+    IChar *print_area;
+    size_t print_size;
+    size_t print_used;
+    /* Buffer for processing strings (e.g., OSC ... ST) */
+    Char *string_area;
+    size_t string_size;
+    size_t string_used;
+};
+
+static struct ParseState myState;
+
+static void
+init_groundtable(TScreen * screen, struct ParseState *sp)
+{
+    (void) screen;
+
+#if OPT_VT52_MODE
+    if (!(screen->vtXX_level)) {
+       sp->groundtable = vt52_table;
+    } else if (screen->terminal_id >= 100)
+#endif
+    {
+       sp->groundtable = ansi_table;
+    }
+}
+
+static void
+select_charset(struct ParseState *sp, int type, int size)
+{
+    TRACE(("select_charset %#x %d\n", type, size));
+    sp->scstype = type;
+    sp->scssize = size;
+    if (size == 94) {
+       sp->parsestate = scstable;
+    } else {
+       sp->parsestate = scs96table;
+    }
+}
+
+static int
+zero_if_default(int which)
+{
+    int result = (nparam > which) ? param[which] : 0;
+    if (result <= 0)
+       result = 0;
+    return result;
+}
+
+static int
+one_if_default(int which)
+{
+    int result = (nparam > which) ? param[which] : 0;
+    if (result <= 0)
+       result = 1;
+    return result;
+}
+
+#if OPT_C1_PRINT || OPT_WIDE_CHARS
+#define ParseSOS(screen) ((screen)->c1_printable == 0)
+#else
+#define ParseSOS(screen) 0
+#endif
+
+#define ResetState(sp) (sp)->parsestate = (sp)->groundtable
+
+static void
+illegal_parse(XtermWidget xw, unsigned c, struct ParseState *sp)
+{
+    ResetState(sp);
+    sp->nextstate = sp->parsestate[E2A(c)];
+    Bell(xw, XkbBI_MinorError, 0);
+}
+
+static Boolean
+doparsing(XtermWidget xw, unsigned c, struct ParseState *sp)
+{
+    TScreen *screen = TScreenOf(xw);
+    int row;
+    int col;
+    int top;
+    int bot;
+    int count;
+    int laststate;
+    int thischar = -1;
+    XTermRect myRect;
+
+    do {
+#if OPT_WIDE_CHARS
+       int this_is_wide = 0;
+
+       /*
+        * Handle zero-width combining characters.  Make it faster by noting
+        * that according to the Unicode charts, the majority of Western
+        * character sets do not use this feature.  There are some unassigned
+        * codes at 0x242, but no zero-width characters until past 0x300.
+        */
+       if (c >= 0x300 && screen->wide_chars
+           && my_wcwidth((int) c) == 0
+           && !isWideControl(c)) {
+           int prev, precomposed;
+
+           WriteNow();
+
+           prev = (int) XTERM_CELL(screen->last_written_row,
+                                   screen->last_written_col);
+           precomposed = do_precomposition(prev, (int) c);
+           TRACE(("do_precomposition (U+%04X [%d], U+%04X [%d]) -> U+%04X [%d]\n",
+                  prev, my_wcwidth(prev),
+                  (int) c, my_wcwidth((int) c),
+                  precomposed, my_wcwidth(precomposed)));
+
+           /* substitute combined character with precomposed character
+            * only if it does not change the width of the base character
+            */
+           if (precomposed != -1 && my_wcwidth(precomposed) == my_wcwidth(prev)) {
+               putXtermCell(screen,
+                            screen->last_written_row,
+                            screen->last_written_col, precomposed);
+           } else {
+               addXtermCombining(screen,
+                                 screen->last_written_row,
+                                 screen->last_written_col, c);
+           }
+
+           if (!screen->scroll_amt)
+               ScrnUpdate(xw,
+                          screen->last_written_row,
+                          screen->last_written_col, 1, 1, 1);
+           continue;
+       }
+#endif
+
+       /* Intercept characters for printer controller mode */
+       if (screen->printer_controlmode == 2) {
+           if ((c = (unsigned) xtermPrinterControl(xw, (int) c)) == 0)
+               continue;
+       }
+
+       /*
+        * VT52 is a little ugly in the one place it has a parameterized
+        * control sequence, since the parameter falls after the character
+        * that denotes the type of sequence.
+        */
+#if OPT_VT52_MODE
+       if (sp->vt52_cup) {
+           if (nparam < NPARAM)
+               param[nparam++] = (int) (c & 0x7f) - 32;
+           if (nparam < 2)
+               continue;
+           sp->vt52_cup = False;
+           if ((row = param[0]) < 0)
+               row = 0;
+           if ((col = param[1]) < 0)
+               col = 0;
+           CursorSet(screen, row, col, xw->flags);
+           sp->parsestate = vt52_table;
+           param[0] = 0;
+           param[1] = 0;
+           continue;
+       }
+#endif
+
+       laststate = sp->nextstate;
+       if (c == ANSI_DEL
+           && sp->parsestate == sp->groundtable
+           && sp->scssize == 96
+           && sp->scstype != 0) {
+           /*
+            * Handle special case of shifts for 96-character sets by checking
+            * if we have a DEL.  The other special case for SPACE will always
+            * be printable.
+            */
+           sp->nextstate = CASE_PRINT;
+       } else
+#if OPT_WIDE_CHARS
+       if (c > 255) {
+           /*
+            * The parsing tables all have 256 entries.  If we're supporting
+            * wide characters, we handle them by treating them the same as
+            * printing characters.
+            */
+           if (sp->parsestate == sp->groundtable) {
+               sp->nextstate = CASE_PRINT;
+           } else if (sp->parsestate == sos_table) {
+               c &= 0xffff;
+               if (c > 255) {
+                   TRACE(("Found code > 255 while in SOS state: %04X\n", c));
+                   c = '?';
+               }
+           } else {
+               sp->nextstate = CASE_GROUND_STATE;
+           }
+       } else
+#endif
+           sp->nextstate = sp->parsestate[E2A(c)];
+
+#if OPT_BROKEN_OSC
+       /*
+        * Linux console palette escape sequences start with an OSC, but do
+        * not terminate correctly.  Some scripts do not check before writing
+        * them, making xterm appear to hang (it's awaiting a valid string
+        * terminator).  Just ignore these if we see them - there's no point
+        * in emulating bad code.
+        */
+       if (screen->brokenLinuxOSC
+           && sp->parsestate == sos_table) {
+           if (sp->string_used) {
+               switch (sp->string_area[0]) {
+               case 'P':
+                   if (sp->string_used <= 7)
+                       break;
+                   /* FALLTHRU */
+               case 'R':
+                   illegal_parse(xw, c, sp);
+                   TRACE(("Reset to ground state (brokenLinuxOSC)\n"));
+                   break;
+               }
+           }
+       }
+#endif
+
+#if OPT_BROKEN_ST
+       /*
+        * Before patch #171, carriage control embedded within an OSC string
+        * would terminate it.  Some (buggy, of course) applications rely on
+        * this behavior.  Accommodate them by allowing one to compile xterm
+        * and emulate the old behavior.
+        */
+       if (screen->brokenStringTerm
+           && sp->parsestate == sos_table
+           && c < 32) {
+           switch (c) {
+           case ANSI_EOT:      /* FALLTHRU */
+           case ANSI_BS:       /* FALLTHRU */
+           case ANSI_HT:       /* FALLTHRU */
+           case ANSI_LF:       /* FALLTHRU */
+           case ANSI_VT:       /* FALLTHRU */
+           case ANSI_FF:       /* FALLTHRU */
+           case ANSI_CR:       /* FALLTHRU */
+           case ANSI_SO:       /* FALLTHRU */
+           case ANSI_SI:       /* FALLTHRU */
+           case ANSI_XON:      /* FALLTHRU */
+           case ANSI_CAN:
+               illegal_parse(xw, c, sp);
+               TRACE(("Reset to ground state (brokenStringTerm)\n"));
+               break;
+           }
+       }
+#endif
+
+#if OPT_C1_PRINT
+       /*
+        * This is not completely foolproof, but will allow an application
+        * with values in the C1 range to use them as printable characters,
+        * provided that they are not intermixed with an escape sequence.
+        */
+       if (screen->c1_printable
+           && (c >= 128 && c < 160)) {
+           sp->nextstate = (sp->parsestate == esc_table
+                            ? CASE_ESC_IGNORE
+                            : sp->parsestate[E2A(160)]);
+       }
+#endif
+
+#if OPT_WIDE_CHARS
+       /*
+        * If we have a C1 code and the c1_printable flag is not set, simply
+        * ignore it when it was translated from UTF-8.  That is because the
+        * value could not have been present as-is in the UTF-8.
+        *
+        * To see that CASE_IGNORE is a consistent value, note that it is
+        * always used for NUL and other uninteresting C0 controls.
+        */
+#if OPT_C1_PRINT
+       if (!screen->c1_printable)
+#endif
+           if (screen->wide_chars
+               && (c >= 128 && c < 160)) {
+               sp->nextstate = CASE_IGNORE;
+           }
+
+       /*
+        * If this character is a different width than the last one, put the
+        * previous text into the buffer and draw it now.
+        */
+       this_is_wide = isWide((int) c);
+       if (this_is_wide != sp->last_was_wide) {
+           WriteNow();
+       }
+#endif
+
+       /*
+        * Accumulate string for printable text.  This may be 8/16-bit
+        * characters.
+        */
+       if (sp->nextstate == CASE_PRINT) {
+           SafeAlloc(IChar, sp->print_area, sp->print_used, sp->print_size);
+           if (new_string == 0) {
+               fprintf(stderr,
+                       "Cannot allocate %lu bytes for printable text\n",
+                       (unsigned long) new_length);
+               continue;
+           }
+#if OPT_VT52_MODE
+           /*
+            * Strip output text to 7-bits for VT52.  We should do this for
+            * VT100 also (which is a 7-bit device), but xterm has been
+            * doing this for so long we shouldn't change this behavior.
+            */
+           if (screen->vtXX_level < 1)
+               c &= 0x7f;
+#endif
+           sp->print_area = new_string;
+           sp->print_size = new_length;
+           sp->print_area[sp->print_used++] = (IChar) c;
+           sp->lastchar = thischar = (int) c;
+#if OPT_WIDE_CHARS
+           sp->last_was_wide = this_is_wide;
+#endif
+           if (morePtyData(screen, VTbuffer)) {
+               continue;
+           }
+       }
+
+       if (sp->nextstate == CASE_PRINT
+           || (laststate == CASE_PRINT && sp->print_used)) {
+           WriteNow();
+       }
+
+       /*
+        * Accumulate string for APC, DCS, PM, OSC, SOS controls
+        * This should always be 8-bit characters.
+        */
+       if (sp->parsestate == sos_table) {
+           SafeAlloc(Char, sp->string_area, sp->string_used, sp->string_size);
+           if (new_string == 0) {
+               fprintf(stderr,
+                       "Cannot allocate %lu bytes for string mode %d\n",
+                       (unsigned long) new_length, sp->string_mode);
+               continue;
+           }
+#if OPT_WIDE_CHARS
+           /*
+            * We cannot display codes above 255, but let's try to
+            * accommodate the application a little by not aborting the
+            * string.
+            */
+           if ((c & 0xffff) > 255) {
+               sp->nextstate = CASE_PRINT;
+               c = '?';
+           }
+#endif
+           sp->string_area = new_string;
+           sp->string_size = new_length;
+           sp->string_area[(sp->string_used)++] = CharOf(c);
+       } else if (sp->parsestate != esc_table) {
+           /* if we were accumulating, we're not any more */
+           sp->string_mode = 0;
+           sp->string_used = 0;
+       }
+
+       TRACE(("parse %04X -> %d %s\n", c, sp->nextstate, which_table(sp->parsestate)));
+
+       switch (sp->nextstate) {
+       case CASE_PRINT:
+           TRACE(("CASE_PRINT - printable characters\n"));
+           break;
+
+       case CASE_GROUND_STATE:
+           TRACE(("CASE_GROUND_STATE - exit ignore mode\n"));
+           ResetState(sp);
+           break;
+
+       case CASE_IGNORE:
+           TRACE(("CASE_IGNORE - Ignore character %02X\n", c));
+           break;
+
+       case CASE_ENQ:
+           TRACE(("CASE_ENQ - answerback\n"));
+           for (count = 0; screen->answer_back[count] != 0; count++)
+               unparseputc(xw, screen->answer_back[count]);
+           unparse_end(xw);
+           break;
+
+       case CASE_BELL:
+           TRACE(("CASE_BELL - bell\n"));
+           if (sp->string_mode == ANSI_OSC) {
+               if (sp->string_used)
+                   sp->string_area[--(sp->string_used)] = '\0';
+               do_osc(xw, sp->string_area, sp->string_used, (int) c);
+               ResetState(sp);
+           } else {
+               /* bell */
+               Bell(xw, XkbBI_TerminalBell, 0);
+           }
+           break;
+
+       case CASE_BS:
+           TRACE(("CASE_BS - backspace\n"));
+           CursorBack(xw, 1);
+           break;
+
+       case CASE_CR:
+           /* CR */
+           CarriageReturn(screen);
+           break;
+
+       case CASE_ESC:
+           if_OPT_VT52_MODE(screen, {
+               sp->parsestate = vt52_esc_table;
+               break;
+           });
+           sp->parsestate = esc_table;
+           break;
+
+#if OPT_VT52_MODE
+       case CASE_VT52_CUP:
+           TRACE(("CASE_VT52_CUP - VT52 cursor addressing\n"));
+           sp->vt52_cup = True;
+           nparam = 0;
+           break;
+
+       case CASE_VT52_IGNORE:
+           TRACE(("CASE_VT52_IGNORE - VT52 ignore-character\n"));
+           sp->parsestate = vt52_ignore_table;
+           break;
+#endif
+
+       case CASE_VMOT:
+           /*
+            * form feed, line feed, vertical tab
+            */
+           xtermAutoPrint(xw, c);
+           xtermIndex(xw, 1);
+           if (xw->flags & LINEFEED)
+               CarriageReturn(screen);
+           else
+               do_xevents();
+           break;
+
+       case CASE_CBT:
+           /* cursor backward tabulation */
+           if ((count = param[0]) == DEFAULT)
+               count = 1;
+           while ((count-- > 0)
+                  && (TabToPrevStop(xw))) ;
+           ResetState(sp);
+           break;
+
+       case CASE_CHT:
+           /* cursor forward tabulation */
+           if ((count = param[0]) == DEFAULT)
+               count = 1;
+           while ((count-- > 0)
+                  && (TabToNextStop(xw))) ;
+           ResetState(sp);
+           break;
+
+       case CASE_TAB:
+           /* tab */
+           TabToNextStop(xw);
+           break;
+
+       case CASE_SI:
+           screen->curgl = 0;
+           if_OPT_VT52_MODE(screen, {
+               ResetState(sp);
+           });
+           break;
+
+       case CASE_SO:
+           screen->curgl = 1;
+           if_OPT_VT52_MODE(screen, {
+               ResetState(sp);
+           });
+           break;
+
+       case CASE_DECDHL:
+           xterm_DECDHL(xw, c == '3');
+           ResetState(sp);
+           break;
+
+       case CASE_DECSWL:
+           xterm_DECSWL(xw);
+           ResetState(sp);
+           break;
+
+       case CASE_DECDWL:
+           xterm_DECDWL(xw);
+           ResetState(sp);
+           break;
+
+       case CASE_SCR_STATE:
+           /* enter scr state */
+           sp->parsestate = scrtable;
+           break;
+
+       case CASE_SCS0_STATE:
+           /* enter scs state 0 */
+           select_charset(sp, 0, 94);
+           break;
+
+       case CASE_SCS1_STATE:
+           /* enter scs state 1 */
+           select_charset(sp, 1, 94);
+           break;
+
+       case CASE_SCS2_STATE:
+           /* enter scs state 2 */
+           select_charset(sp, 2, 94);
+           break;
+
+       case CASE_SCS3_STATE:
+           /* enter scs state 3 */
+           select_charset(sp, 3, 94);
+           break;
+
+       case CASE_SCS1A_STATE:
+           /* enter scs state 1 */
+           select_charset(sp, 1, 96);
+           break;
+
+       case CASE_SCS2A_STATE:
+           /* enter scs state 2 */
+           select_charset(sp, 2, 96);
+           break;
+
+       case CASE_SCS3A_STATE:
+           /* enter scs state 3 */
+           select_charset(sp, 3, 96);
+           break;
+
+       case CASE_ESC_IGNORE:
+           /* unknown escape sequence */
+           sp->parsestate = eigtable;
+           break;
+
+       case CASE_ESC_DIGIT:
+           /* digit in csi or dec mode */
+           if (nparam > 0) {
+               if ((row = param[nparam - 1]) == DEFAULT)
+                   row = 0;
+               param[nparam - 1] = (10 * row) + ((int) c - '0');
+               if (param[nparam - 1] > 65535)
+                   param[nparam - 1] = 65535;
+               if (sp->parsestate == csi_table)
+                   sp->parsestate = csi2_table;
+           }
+           break;
+
+       case CASE_ESC_SEMI:
+           /* semicolon in csi or dec mode */
+           if (nparam < NPARAM)
+               param[nparam++] = DEFAULT;
+           if (sp->parsestate == csi_table)
+               sp->parsestate = csi2_table;
+           break;
+
+       case CASE_DEC_STATE:
+           /* enter dec mode */
+           sp->parsestate = dec_table;
+           break;
+
+       case CASE_DEC2_STATE:
+           /* enter dec2 mode */
+           sp->parsestate = dec2_table;
+           break;
+
+       case CASE_DEC3_STATE:
+           /* enter dec3 mode */
+           sp->parsestate = dec3_table;
+           break;
+
+       case CASE_ICH:
+           TRACE(("CASE_ICH - insert char\n"));
+           if ((row = param[0]) < 1)
+               row = 1;
+           InsertChar(xw, (unsigned) row);
+           ResetState(sp);
+           break;
+
+       case CASE_CUU:
+           TRACE(("CASE_CUU - cursor up\n"));
+           if ((row = param[0]) < 1)
+               row = 1;
+           CursorUp(screen, row);
+           ResetState(sp);
+           break;
+
+       case CASE_CUD:
+           TRACE(("CASE_CUD - cursor down\n"));
+           if ((row = param[0]) < 1)
+               row = 1;
+           CursorDown(screen, row);
+           ResetState(sp);
+           break;
+
+       case CASE_CUF:
+           TRACE(("CASE_CUF - cursor forward\n"));
+           if ((col = param[0]) < 1)
+               col = 1;
+           CursorForward(screen, col);
+           ResetState(sp);
+           break;
+
+       case CASE_CUB:
+           TRACE(("CASE_CUB - cursor backward\n"));
+           if ((col = param[0]) < 1)
+               col = 1;
+           CursorBack(xw, col);
+           ResetState(sp);
+           break;
+
+       case CASE_CUP:
+           TRACE(("CASE_CUP - cursor position\n"));
+           if_OPT_XMC_GLITCH(screen, {
+               Jump_XMC(xw);
+           });
+           if ((row = param[0]) < 1)
+               row = 1;
+           if (nparam < 2 || (col = param[1]) < 1)
+               col = 1;
+           CursorSet(screen, row - 1, col - 1, xw->flags);
+           ResetState(sp);
+           break;
+
+       case CASE_VPA:
+           TRACE(("CASE_VPA - vertical position\n"));
+           if ((row = param[0]) < 1)
+               row = 1;
+           CursorSet(screen, row - 1, screen->cur_col, xw->flags);
+           ResetState(sp);
+           break;
+
+       case CASE_HPA:
+           TRACE(("CASE_HPA - horizontal position\n"));
+           if ((col = param[0]) < 1)
+               col = 1;
+           CursorSet(screen, screen->cur_row, col - 1, xw->flags);
+           ResetState(sp);
+           break;
+
+       case CASE_HP_BUGGY_LL:
+           TRACE(("CASE_HP_BUGGY_LL\n"));
+           /* Some HP-UX applications have the bug that they
+              assume ESC F goes to the lower left corner of
+              the screen, regardless of what terminfo says. */
+           if (screen->hp_ll_bc)
+               CursorSet(screen, screen->max_row, 0, xw->flags);
+           ResetState(sp);
+           break;
+
+       case CASE_ED:
+           TRACE(("CASE_ED - erase display\n"));
+           do_erase_display(xw, param[0], OFF_PROTECT);
+           ResetState(sp);
+           break;
+
+       case CASE_EL:
+           TRACE(("CASE_EL - erase line\n"));
+           do_erase_line(xw, param[0], OFF_PROTECT);
+           ResetState(sp);
+           break;
+
+       case CASE_ECH:
+           TRACE(("CASE_ECH - erase char\n"));
+           /* ECH */
+           ClearRight(xw, param[0] < 1 ? 1 : param[0]);
+           ResetState(sp);
+           break;
+
+       case CASE_IL:
+           TRACE(("CASE_IL - insert line\n"));
+           if ((row = param[0]) < 1)
+               row = 1;
+           InsertLine(xw, row);
+           ResetState(sp);
+           break;
+
+       case CASE_DL:
+           TRACE(("CASE_DL - delete line\n"));
+           if ((row = param[0]) < 1)
+               row = 1;
+           DeleteLine(xw, row);
+           ResetState(sp);
+           break;
+
+       case CASE_DCH:
+           TRACE(("CASE_DCH - delete char\n"));
+           if ((row = param[0]) < 1)
+               row = 1;
+           DeleteChar(xw, (unsigned) row);
+           ResetState(sp);
+           break;
+
+       case CASE_TRACK_MOUSE:
+           /*
+            * A single parameter other than zero is always scroll-down.
+            * A zero-parameter is used to reset the mouse mode, and is
+            * not useful for scrolling anyway.
+            */
+           if (nparam > 1 || param[0] == 0) {
+               CELL start;
+
+               TRACE(("CASE_TRACK_MOUSE\n"));
+               /* Track mouse as long as in window and between
+                * specified rows
+                */
+               start.row = one_if_default(2) - 1;
+               start.col = param[1] - 1;
+               TrackMouse(xw,
+                          param[0],
+                          &start,
+                          param[3] - 1, param[4] - 2);
+           } else {
+               TRACE(("CASE_SD - scroll down\n"));
+               /* SD */
+               if ((count = param[0]) < 1)
+                   count = 1;
+               RevScroll(xw, count);
+               do_xevents();
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECID:
+           TRACE(("CASE_DECID\n"));
+           if_OPT_VT52_MODE(screen, {
+               unparseputc(xw, ANSI_ESC);
+               unparseputc(xw, '/');
+               unparseputc(xw, 'Z');
+               unparse_end(xw);
+               ResetState(sp);
+               break;
+           });
+           param[0] = DEFAULT; /* Default ID parameter */
+           /* FALLTHRU */
+       case CASE_DA1:
+           TRACE(("CASE_DA1\n"));
+           if (param[0] <= 0) {        /* less than means DEFAULT */
+               count = 0;
+               reply.a_type = ANSI_CSI;
+               reply.a_pintro = '?';
+
+               /* The first param corresponds to the highest
+                * operating level (i.e., service level) of the
+                * emulation.  A DEC terminal can be setup to
+                * respond with a different DA response, but
+                * there's no control sequence that modifies this.
+                * We set it via a resource.
+                */
+               if (screen->terminal_id < 200) {
+                   switch (screen->terminal_id) {
+                   case 102:
+                       reply.a_param[count++] = 6;     /* VT102 */
+                       break;
+                   case 101:
+                       reply.a_param[count++] = 1;     /* VT101 */
+                       reply.a_param[count++] = 0;     /* no options */
+                       break;
+                   default:    /* VT100 */
+                       reply.a_param[count++] = 1;     /* VT100 */
+                       reply.a_param[count++] = 2;     /* AVO */
+                       break;
+                   }
+               } else {
+                   reply.a_param[count++] = (ParmType) (60
+                                                        + screen->terminal_id
+                                                        / 100);
+                   reply.a_param[count++] = 1;         /* 132-columns */
+                   reply.a_param[count++] = 2;         /* printer */
+                   reply.a_param[count++] = 6;         /* selective-erase */
+#if OPT_SUNPC_KBD
+                   if (xw->keyboard.type == keyboardIsVT220)
+#endif
+                       reply.a_param[count++] = 8;     /* user-defined-keys */
+                   reply.a_param[count++] = 9;         /* national replacement charsets */
+                   reply.a_param[count++] = 15;        /* technical characters */
+                   if_OPT_ISO_COLORS(screen, {
+                       reply.a_param[count++] = 22;    /* ANSI color, VT525 */
+                   });
+#if OPT_DEC_LOCATOR
+                   reply.a_param[count++] = 29;        /* ANSI text locator */
+#endif
+               }
+               reply.a_nparam = (ParmType) count;
+               reply.a_inters = 0;
+               reply.a_final = 'c';
+               unparseseq(xw, &reply);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DA2:
+           TRACE(("CASE_DA2\n"));
+           if (param[0] <= 0) {        /* less than means DEFAULT */
+               count = 0;
+               reply.a_type = ANSI_CSI;
+               reply.a_pintro = '>';
+
+               if (screen->terminal_id >= 200)
+                   reply.a_param[count++] = 1;         /* VT220 */
+               else
+                   reply.a_param[count++] = 0;         /* VT100 (nonstandard) */
+               reply.a_param[count++] = XTERM_PATCH;   /* Version */
+               reply.a_param[count++] = 0;     /* options (none) */
+               reply.a_nparam = (ParmType) count;
+               reply.a_inters = 0;
+               reply.a_final = 'c';
+               unparseseq(xw, &reply);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECRPTUI:
+           TRACE(("CASE_DECRPTUI\n"));
+           if ((screen->terminal_id >= 400)
+               && (param[0] <= 0)) {   /* less than means DEFAULT */
+               unparseputc1(xw, ANSI_DCS);
+               unparseputc(xw, '!');
+               unparseputc(xw, '|');
+               unparseputc(xw, '0');
+               unparseputc1(xw, ANSI_ST);
+               unparse_end(xw);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_TBC:
+           TRACE(("CASE_TBC - tab clear\n"));
+           if ((row = param[0]) <= 0)  /* less than means default */
+               TabClear(xw->tabs, screen->cur_col);
+           else if (row == 3)
+               TabZonk(xw->tabs);
+           ResetState(sp);
+           break;
+
+       case CASE_SET:
+           TRACE(("CASE_SET - set mode\n"));
+           ansi_modes(xw, bitset);
+           ResetState(sp);
+           break;
+
+       case CASE_RST:
+           TRACE(("CASE_RST - reset mode\n"));
+           ansi_modes(xw, bitclr);
+           ResetState(sp);
+           break;
+
+       case CASE_SGR:
+           for (row = 0; row < nparam; ++row) {
+               if_OPT_XMC_GLITCH(screen, {
+                   Mark_XMC(xw, param[row]);
+               });
+               TRACE(("CASE_SGR %d\n", param[row]));
+               switch (param[row]) {
+               case DEFAULT:
+               case 0:
+                   UIntClr(xw->flags,
+                           (INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE));
+                   if_OPT_ISO_COLORS(screen, {
+                       reset_SGR_Colors(xw);
+                   });
+                   break;
+               case 1: /* Bold                 */
+                   xw->flags |= BOLD;
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 5: /* Blink                */
+                   xw->flags |= BLINK;
+                   StartBlinking(screen);
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 4: /* Underscore           */
+                   xw->flags |= UNDERLINE;
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 7:
+                   xw->flags |= INVERSE;
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedBG(xw);
+                   });
+                   break;
+               case 8:
+                   xw->flags |= INVISIBLE;
+                   break;
+               case 22:        /* reset 'bold' */
+                   UIntClr(xw->flags, BOLD);
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 24:
+                   UIntClr(xw->flags, UNDERLINE);
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 25:        /* reset 'blink' */
+                   UIntClr(xw->flags, BLINK);
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 27:
+                   UIntClr(xw->flags, INVERSE);
+                   if_OPT_ISO_COLORS(screen, {
+                       setExtendedBG(xw);
+                   });
+                   break;
+               case 28:
+                   UIntClr(xw->flags, INVISIBLE);
+                   break;
+               case 30:
+               case 31:
+               case 32:
+               case 33:
+               case 34:
+               case 35:
+               case 36:
+               case 37:
+                   if_OPT_ISO_COLORS(screen, {
+                       xw->sgr_foreground = (param[row] - 30);
+                       xw->sgr_extended = False;
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 38:
+                   /* This is more complicated than I'd
+                      like, but it should properly eat all
+                      the parameters for unsupported modes
+                    */
+                   if_OPT_ISO_COLORS(screen, {
+                       row++;
+                       if (row < nparam) {
+                           switch (param[row]) {
+                           case 5:
+                               row++;
+                               if (row < nparam &&
+                                   param[row] < NUM_ANSI_COLORS) {
+                                   xw->sgr_foreground = param[row];
+                                   xw->sgr_extended = True;
+                                   setExtendedFG(xw);
+                               }
+                               break;
+                           default:
+                               row += 7;
+                               break;
+                           }
+                       }
+                   });
+                   break;
+               case 39:
+                   if_OPT_ISO_COLORS(screen, {
+                       reset_SGR_Foreground(xw);
+                   });
+                   break;
+               case 40:
+               case 41:
+               case 42:
+               case 43:
+               case 44:
+               case 45:
+               case 46:
+               case 47:
+                   if_OPT_ISO_COLORS(screen, {
+                       xw->sgr_background = (param[row] - 40);
+                       setExtendedBG(xw);
+                   });
+                   break;
+               case 48:
+                   if_OPT_ISO_COLORS(screen, {
+                       row++;
+                       if (row < nparam) {
+                           switch (param[row]) {
+                           case 5:
+                               row++;
+                               if (row < nparam &&
+                                   param[row] < NUM_ANSI_COLORS) {
+                                   xw->sgr_background = param[row];
+                                   setExtendedBG(xw);
+                               }
+                               break;
+                           default:
+                               row += 7;
+                               break;
+                           }
+                       }
+                   });
+                   break;
+               case 49:
+                   if_OPT_ISO_COLORS(screen, {
+                       reset_SGR_Background(xw);
+                   });
+                   break;
+               case 90:
+               case 91:
+               case 92:
+               case 93:
+               case 94:
+               case 95:
+               case 96:
+               case 97:
+                   if_OPT_AIX_COLORS(screen, {
+                       xw->sgr_foreground = (param[row] - 90 + 8);
+                       xw->sgr_extended = False;
+                       setExtendedFG(xw);
+                   });
+                   break;
+               case 100:
+#if !OPT_AIX_COLORS
+                   if_OPT_ISO_COLORS(screen, {
+                       reset_SGR_Foreground(xw);
+                       reset_SGR_Background(xw);
+                   });
+                   break;
+#endif
+               case 101:
+               case 102:
+               case 103:
+               case 104:
+               case 105:
+               case 106:
+               case 107:
+                   if_OPT_AIX_COLORS(screen, {
+                       xw->sgr_background = (param[row] - 100 + 8);
+                       setExtendedBG(xw);
+                   });
+                   break;
+               }
+           }
+           ResetState(sp);
+           break;
+
+           /* DSR (except for the '?') is a superset of CPR */
+       case CASE_DSR:
+           sp->private_function = True;
+
+           /* FALLTHRU */
+       case CASE_CPR:
+           TRACE(("CASE_CPR - cursor position\n"));
+           count = 0;
+           reply.a_type = ANSI_CSI;
+           reply.a_pintro = CharOf(sp->private_function ? '?' : 0);
+           reply.a_inters = 0;
+           reply.a_final = 'n';
+
+           switch (param[0]) {
+           case 5:
+               /* operating status */
+               reply.a_param[count++] = 0;     /* (no malfunction ;-) */
+               break;
+           case 6:
+               /* CPR */
+               /* DECXCPR (with page=0) */
+               reply.a_param[count++] = (ParmType) (screen->cur_row + 1);
+               reply.a_param[count++] = (ParmType) (screen->cur_col + 1);
+               reply.a_final = 'R';
+               break;
+           case 15:
+               /* printer status */
+               if (screen->terminal_id >= 200) {       /* VT220 */
+                   reply.a_param[count++] = 13;        /* implement printer */
+               }
+               break;
+           case 25:
+               /* UDK status */
+               if (screen->terminal_id >= 200) {       /* VT220 */
+                   reply.a_param[count++] = 20;        /* UDK always unlocked */
+               }
+               break;
+           case 26:
+               /* keyboard status */
+               if (screen->terminal_id >= 200) {       /* VT220 */
+                   reply.a_param[count++] = 27;
+                   reply.a_param[count++] = 1;         /* North American */
+                   if (screen->terminal_id >= 400) {
+                       reply.a_param[count++] = 0;     /* ready */
+                       reply.a_param[count++] = 0;     /* LK201 */
+                   }
+               }
+               break;
+           case 53:
+               /* Locator status */
+               if (screen->terminal_id >= 200) {       /* VT220 */
+#if OPT_DEC_LOCATOR
+                   reply.a_param[count++] = 50;        /* locator ready */
+#else
+                   reply.a_param[count++] = 53;        /* no locator */
+#endif
+               }
+               break;
+           default:
+               break;
+           }
+
+           if ((reply.a_nparam = (ParmType) count) != 0)
+               unparseseq(xw, &reply);
+
+           ResetState(sp);
+           sp->private_function = False;
+           break;
+
+       case CASE_MC:
+           TRACE(("CASE_MC - media control\n"));
+           xtermMediaControl(xw, param[0], False);
+           ResetState(sp);
+           break;
+
+       case CASE_DEC_MC:
+           TRACE(("CASE_DEC_MC - DEC media control\n"));
+           xtermMediaControl(xw, param[0], True);
+           ResetState(sp);
+           break;
+
+       case CASE_HP_MEM_LOCK:
+       case CASE_HP_MEM_UNLOCK:
+           TRACE(("%s\n", ((sp->parsestate[c] == CASE_HP_MEM_LOCK)
+                           ? "CASE_HP_MEM_LOCK"
+                           : "CASE_HP_MEM_UNLOCK")));
+           if (screen->scroll_amt)
+               FlushScroll(xw);
+           if (sp->parsestate[c] == CASE_HP_MEM_LOCK)
+               set_tb_margins(screen, screen->cur_row, screen->bot_marg);
+           else
+               set_tb_margins(screen, 0, screen->bot_marg);
+           ResetState(sp);
+           break;
+
+       case CASE_DECSTBM:
+           TRACE(("CASE_DECSTBM - set scrolling region\n"));
+           if ((top = param[0]) < 1)
+               top = 1;
+           if (nparam < 2 || (bot = param[1]) == DEFAULT
+               || bot > MaxRows(screen)
+               || bot == 0)
+               bot = MaxRows(screen);
+           if (bot > top) {
+               if (screen->scroll_amt)
+                   FlushScroll(xw);
+               set_tb_margins(screen, top - 1, bot - 1);
+               CursorSet(screen, 0, 0, xw->flags);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECREQTPARM:
+           TRACE(("CASE_DECREQTPARM\n"));
+           if (screen->terminal_id < 200) {    /* VT102 */
+               if ((row = param[0]) == DEFAULT)
+                   row = 0;
+               if (row == 0 || row == 1) {
+                   reply.a_type = ANSI_CSI;
+                   reply.a_pintro = 0;
+                   reply.a_nparam = 7;
+                   reply.a_param[0] = (ParmType) (row + 2);
+                   reply.a_param[1] = 1;       /* no parity */
+                   reply.a_param[2] = 1;       /* eight bits */
+                   reply.a_param[3] = 128;     /* transmit 38.4k baud */
+                   reply.a_param[4] = 128;     /* receive 38.4k baud */
+                   reply.a_param[5] = 1;       /* clock multiplier ? */
+                   reply.a_param[6] = 0;       /* STP flags ? */
+                   reply.a_inters = 0;
+                   reply.a_final = 'x';
+                   unparseseq(xw, &reply);
+               }
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECSET:
+           /* DECSET */
+#if OPT_VT52_MODE
+           if (screen->vtXX_level != 0)
+#endif
+               dpmodes(xw, bitset);
+           ResetState(sp);
+#if OPT_TEK4014
+           if (TEK4014_ACTIVE(xw))
+               return False;
+#endif
+           break;
+
+       case CASE_DECRST:
+           /* DECRST */
+           dpmodes(xw, bitclr);
+           init_groundtable(screen, sp);
+           ResetState(sp);
+           break;
+
+       case CASE_DECALN:
+           TRACE(("CASE_DECALN - alignment test\n"));
+           if (screen->cursor_state)
+               HideCursor();
+           set_tb_margins(screen, 0, screen->max_row);
+           CursorSet(screen, 0, 0, xw->flags);
+           xtermParseRect(xw, 0, 0, &myRect);
+           ScrnFillRectangle(xw, &myRect, 'E', 0, False);
+           ResetState(sp);
+           break;
+
+       case CASE_GSETS:
+           TRACE(("CASE_GSETS(%d) = '%c'\n", sp->scstype, c));
+           if (screen->vtXX_level != 0)
+               screen->gsets[sp->scstype] = CharOf(c);
+           ResetState(sp);
+           break;
+
+       case CASE_DECSC:
+           TRACE(("CASE_DECSC - save cursor\n"));
+           CursorSave(xw);
+           ResetState(sp);
+           break;
+
+       case CASE_DECRC:
+           TRACE(("CASE_DECRC - restore cursor\n"));
+           CursorRestore(xw);
+           if_OPT_ISO_COLORS(screen, {
+               setExtendedFG(xw);
+           });
+           ResetState(sp);
+           break;
+
+       case CASE_DECKPAM:
+           TRACE(("CASE_DECKPAM\n"));
+           xw->keyboard.flags |= MODE_DECKPAM;
+           update_appkeypad();
+           ResetState(sp);
+           break;
+
+       case CASE_DECKPNM:
+           TRACE(("CASE_DECKPNM\n"));
+           UIntClr(xw->keyboard.flags, MODE_DECKPAM);
+           update_appkeypad();
+           ResetState(sp);
+           break;
+
+       case CASE_CSI_QUOTE_STATE:
+           sp->parsestate = csi_quo_table;
+           break;
+
+#if OPT_BLINK_CURS
+       case CASE_CSI_SPACE_STATE:
+           sp->parsestate = csi_sp_table;
+           break;
+
+       case CASE_DECSCUSR:
+           TRACE(("CASE_DECSCUSR\n"));
+           {
+               Boolean change = True;
+               Boolean blinks = screen->cursor_blink;
+
+               HideCursor();
+
+               switch (param[0]) {
+               case 0:
+               case 1:
+               case DEFAULT:
+                   /* blinking block */
+                   screen->cursor_underline = False;
+                   blinks = True;
+                   break;
+               case 2:
+                   /* steady block */
+                   screen->cursor_underline = False;
+                   blinks = False;
+                   break;
+               case 3:
+                   /* blinking underline */
+                   screen->cursor_underline = True;
+                   blinks = True;
+                   break;
+               case 4:
+                   /* steady underline */
+                   screen->cursor_underline = True;
+                   blinks = False;
+                   break;
+               default:
+                   change = False;
+                   break;
+               }
+
+               if (change) {
+                   xtermSetCursorBox(screen);
+                   SetCursorBlink(screen, blinks);
+               }
+           }
+           ResetState(sp);
+           break;
+#endif
+
+#if OPT_SCROLL_LOCK
+       case CASE_DECLL:
+           TRACE(("CASE_DECLL\n"));
+           if (nparam > 0) {
+               for (count = 0; count < nparam; ++count) {
+                   switch (param[count]) {
+                   case 0:
+                   case DEFAULT:
+                       xtermClearLEDs(screen);
+                       break;
+                   case 1:
+                   case 2:
+                   case 3:
+                       xtermShowLED(screen, (Cardinal) param[count], True);
+                       break;
+                   case 21:
+                   case 22:
+                   case 23:
+                       xtermShowLED(screen, (Cardinal) (param[count] - 20), True);
+                       break;
+                   }
+               }
+           } else {
+               xtermClearLEDs(screen);
+           }
+           ResetState(sp);
+           break;
+#endif
+
+#if OPT_VT52_MODE
+       case CASE_VT52_FINISH:
+           TRACE(("CASE_VT52_FINISH terminal_id %d, vtXX_level %d\n",
+                  screen->terminal_id,
+                  screen->vtXX_level));
+           if (screen->terminal_id >= 100
+               && screen->vtXX_level == 0) {
+               sp->groundtable =
+                   sp->parsestate = ansi_table;
+               screen->vtXX_level = screen->vt52_save_level;
+               screen->curgl = screen->vt52_save_curgl;
+               screen->curgr = screen->vt52_save_curgr;
+               screen->curss = screen->vt52_save_curss;
+               memmove(screen->gsets, screen->vt52_save_gsets, sizeof(screen->gsets));
+           }
+           break;
+#endif
+
+       case CASE_ANSI_LEVEL_1:
+           TRACE(("CASE_ANSI_LEVEL_1\n"));
+           set_ansi_conformance(screen, 1);
+           ResetState(sp);
+           break;
+
+       case CASE_ANSI_LEVEL_2:
+           TRACE(("CASE_ANSI_LEVEL_2\n"));
+           set_ansi_conformance(screen, 2);
+           ResetState(sp);
+           break;
+
+       case CASE_ANSI_LEVEL_3:
+           TRACE(("CASE_ANSI_LEVEL_3\n"));
+           set_ansi_conformance(screen, 3);
+           ResetState(sp);
+           break;
+
+       case CASE_DECSCL:
+           TRACE(("CASE_DECSCL(%d,%d)\n", param[0], param[1]));
+           if (param[0] >= 61 && param[0] <= 65) {
+               /*
+                * VT300, VT420, VT520 manuals claim that DECSCL does a hard
+                * reset (RIS).  VT220 manual states that it is a soft reset.
+                * Perhaps both are right (unlikely).  Kermit says it's soft.
+                */
+               VTReset(xw, False, False);
+               screen->vtXX_level = param[0] - 60;
+               if (param[0] > 61) {
+                   switch (zero_if_default(1)) {
+                   case 1:
+                       show_8bit_control(False);
+                       break;
+                   case 0:
+                   case 2:
+                       show_8bit_control(True);
+                       break;
+                   }
+               }
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECSCA:
+           TRACE(("CASE_DECSCA\n"));
+           screen->protected_mode = DEC_PROTECT;
+           if (param[0] <= 0 || param[0] == 2)
+               UIntClr(xw->flags, PROTECTED);
+           else if (param[0] == 1)
+               xw->flags |= PROTECTED;
+           ResetState(sp);
+           break;
+
+       case CASE_DECSED:
+           TRACE(("CASE_DECSED\n"));
+           do_erase_display(xw, param[0], DEC_PROTECT);
+           ResetState(sp);
+           break;
+
+       case CASE_DECSEL:
+           TRACE(("CASE_DECSEL\n"));
+           do_erase_line(xw, param[0], DEC_PROTECT);
+           ResetState(sp);
+           break;
+
+       case CASE_ST:
+           TRACE(("CASE_ST: End of String (%lu bytes)\n", (unsigned long) sp->string_used));
+           ResetState(sp);
+           if (!sp->string_used)
+               break;
+           sp->string_area[--(sp->string_used)] = '\0';
+           switch (sp->string_mode) {
+           case ANSI_APC:
+               /* ignored */
+               break;
+           case ANSI_DCS:
+               do_dcs(xw, sp->string_area, sp->string_used);
+               break;
+           case ANSI_OSC:
+               do_osc(xw, sp->string_area, sp->string_used, ANSI_ST);
+               break;
+           case ANSI_PM:
+               /* ignored */
+               break;
+           case ANSI_SOS:
+               /* ignored */
+               break;
+           }
+           break;
+
+       case CASE_SOS:
+           TRACE(("CASE_SOS: Start of String\n"));
+           if (ParseSOS(screen)) {
+               sp->string_mode = ANSI_SOS;
+               sp->parsestate = sos_table;
+           } else {
+               illegal_parse(xw, c, sp);
+           }
+           break;
+
+       case CASE_PM:
+           TRACE(("CASE_PM: Privacy Message\n"));
+           if (ParseSOS(screen)) {
+               sp->string_mode = ANSI_PM;
+               sp->parsestate = sos_table;
+           } else {
+               illegal_parse(xw, c, sp);
+           }
+           break;
+
+       case CASE_DCS:
+           TRACE(("CASE_DCS: Device Control String\n"));
+           sp->string_mode = ANSI_DCS;
+           sp->parsestate = sos_table;
+           break;
+
+       case CASE_APC:
+           TRACE(("CASE_APC: Application Program Command\n"));
+           if (ParseSOS(screen)) {
+               sp->string_mode = ANSI_APC;
+               sp->parsestate = sos_table;
+           } else {
+               illegal_parse(xw, c, sp);
+           }
+           break;
+
+       case CASE_SPA:
+           TRACE(("CASE_SPA - start protected area\n"));
+           screen->protected_mode = ISO_PROTECT;
+           xw->flags |= PROTECTED;
+           ResetState(sp);
+           break;
+
+       case CASE_EPA:
+           TRACE(("CASE_EPA - end protected area\n"));
+           UIntClr(xw->flags, PROTECTED);
+           ResetState(sp);
+           break;
+
+       case CASE_SU:
+           TRACE(("CASE_SU - scroll up\n"));
+           if ((count = param[0]) < 1)
+               count = 1;
+           xtermScroll(xw, count);
+           ResetState(sp);
+           break;
+
+       case CASE_IND:
+           TRACE(("CASE_IND - index\n"));
+           xtermIndex(xw, 1);
+           do_xevents();
+           ResetState(sp);
+           break;
+
+       case CASE_CPL:
+           TRACE(("CASE_CPL - cursor prev line\n"));
+           CursorPrevLine(screen, param[0]);
+           ResetState(sp);
+           break;
+
+       case CASE_CNL:
+           TRACE(("CASE_CNL - cursor next line\n"));
+           CursorNextLine(screen, param[0]);
+           ResetState(sp);
+           break;
+
+       case CASE_NEL:
+           TRACE(("CASE_NEL\n"));
+           xtermIndex(xw, 1);
+           CarriageReturn(screen);
+           ResetState(sp);
+           break;
+
+       case CASE_HTS:
+           TRACE(("CASE_HTS - horizontal tab set\n"));
+           TabSet(xw->tabs, screen->cur_col);
+           ResetState(sp);
+           break;
+
+       case CASE_RI:
+           TRACE(("CASE_RI - reverse index\n"));
+           RevIndex(xw, 1);
+           ResetState(sp);
+           break;
+
+       case CASE_SS2:
+           TRACE(("CASE_SS2\n"));
+           screen->curss = 2;
+           ResetState(sp);
+           break;
+
+       case CASE_SS3:
+           TRACE(("CASE_SS3\n"));
+           screen->curss = 3;
+           ResetState(sp);
+           break;
+
+       case CASE_CSI_STATE:
+           /* enter csi state */
+           nparam = 1;
+           param[0] = DEFAULT;
+           sp->parsestate = csi_table;
+           break;
+
+       case CASE_ESC_SP_STATE:
+           /* esc space */
+           sp->parsestate = esc_sp_table;
+           break;
+
+       case CASE_CSI_EX_STATE:
+           /* csi exclamation */
+           sp->parsestate = csi_ex_table;
+           break;
+
+#if OPT_DEC_LOCATOR
+       case CASE_CSI_TICK_STATE:
+           /* csi tick (') */
+           sp->parsestate = csi_tick_table;
+           break;
+
+       case CASE_DECEFR:
+           TRACE(("CASE_DECEFR - Enable Filter Rectangle\n"));
+           if (screen->send_mouse_pos == DEC_LOCATOR) {
+               MotionOff(screen, xw);
+               if ((screen->loc_filter_top = param[0]) < 1)
+                   screen->loc_filter_top = LOC_FILTER_POS;
+               if (nparam < 2 || (screen->loc_filter_left = param[1]) < 1)
+                   screen->loc_filter_left = LOC_FILTER_POS;
+               if (nparam < 3 || (screen->loc_filter_bottom = param[2]) < 1)
+                   screen->loc_filter_bottom = LOC_FILTER_POS;
+               if (nparam < 4 || (screen->loc_filter_right = param[3]) < 1)
+                   screen->loc_filter_right = LOC_FILTER_POS;
+               InitLocatorFilter(xw);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECELR:
+           MotionOff(screen, xw);
+           if (param[0] <= 0 || param[0] > 2) {
+               screen->send_mouse_pos = MOUSE_OFF;
+               TRACE(("DECELR - Disable Locator Reports\n"));
+           } else {
+               TRACE(("DECELR - Enable Locator Reports\n"));
+               screen->send_mouse_pos = DEC_LOCATOR;
+               xtermShowPointer(xw, True);
+               if (param[0] == 2) {
+                   screen->locator_reset = True;
+               } else {
+                   screen->locator_reset = False;
+               }
+               if (nparam < 2 || param[1] != 1) {
+                   screen->locator_pixels = False;
+               } else {
+                   screen->locator_pixels = True;
+               }
+               screen->loc_filter = False;
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECSLE:
+           TRACE(("DECSLE - Select Locator Events\n"));
+           for (count = 0; count < nparam; ++count) {
+               switch (param[count]) {
+               case DEFAULT:
+               case 0:
+                   MotionOff(screen, xw);
+                   screen->loc_filter = False;
+                   screen->locator_events = 0;
+                   break;
+               case 1:
+                   screen->locator_events |= LOC_BTNS_DN;
+                   break;
+               case 2:
+                   UIntClr(screen->locator_events, LOC_BTNS_DN);
+                   break;
+               case 3:
+                   screen->locator_events |= LOC_BTNS_UP;
+                   break;
+               case 4:
+                   UIntClr(screen->locator_events, LOC_BTNS_UP);
+                   break;
+               }
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECRQLP:
+           TRACE(("DECRQLP - Request Locator Position\n"));
+           if (param[0] < 2) {
+               /* Issue DECLRP Locator Position Report */
+               GetLocatorPosition(xw);
+           }
+           ResetState(sp);
+           break;
+#endif /* OPT_DEC_LOCATOR */
+
+#if OPT_DEC_RECTOPS
+       case CASE_CSI_DOLLAR_STATE:
+           TRACE(("CASE_CSI_DOLLAR_STATE\n"));
+           /* csi dollar ($) */
+           if (screen->vtXX_level >= 3)
+               sp->parsestate = csi_dollar_table;
+           else
+               sp->parsestate = eigtable;
+           break;
+
+       case CASE_CSI_STAR_STATE:
+           TRACE(("CASE_CSI_STAR_STATE\n"));
+           /* csi star (*) */
+           if (screen->vtXX_level >= 4)
+               sp->parsestate = csi_star_table;
+           else
+               sp->parsestate = eigtable;
+           break;
+
+       case CASE_DECCRA:
+           if (screen->vtXX_level >= 4) {
+               TRACE(("CASE_DECCRA - Copy rectangular area\n"));
+               xtermParseRect(xw, nparam, param, &myRect);
+               ScrnCopyRectangle(xw, &myRect, nparam - 5, param + 5);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECERA:
+           if (screen->vtXX_level >= 4) {
+               TRACE(("CASE_DECERA - Erase rectangular area\n"));
+               xtermParseRect(xw, nparam, param, &myRect);
+               ScrnFillRectangle(xw, &myRect, ' ', 0, True);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECFRA:
+           if (screen->vtXX_level >= 4) {
+               TRACE(("CASE_DECFRA - Fill rectangular area\n"));
+               if (nparam > 0
+                   && ((param[0] >= 32 && param[0] <= 126)
+                       || (param[0] >= 160 && param[0] <= 255))) {
+                   xtermParseRect(xw, nparam - 1, param + 1, &myRect);
+                   ScrnFillRectangle(xw, &myRect, param[0], xw->flags, True);
+               }
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECSERA:
+           if (screen->vtXX_level >= 4) {
+               TRACE(("CASE_DECSERA - Selective erase rectangular area\n"));
+               xtermParseRect(xw, nparam > 4 ? 4 : nparam, param, &myRect);
+               ScrnWipeRectangle(xw, &myRect);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECSACE:
+           TRACE(("CASE_DECSACE - Select attribute change extent\n"));
+           screen->cur_decsace = param[0];
+           ResetState(sp);
+           break;
+
+       case CASE_DECCARA:
+           if (screen->vtXX_level >= 4) {
+               TRACE(("CASE_DECCARA - Change attributes in rectangular area\n"));
+               xtermParseRect(xw, nparam > 4 ? 4 : nparam, param, &myRect);
+               ScrnMarkRectangle(xw, &myRect, False, nparam - 4, param + 4);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_DECRARA:
+           if (screen->vtXX_level >= 4) {
+               TRACE(("CASE_DECRARA - Reverse attributes in rectangular area\n"));
+               xtermParseRect(xw, nparam > 4 ? 4 : nparam, param, &myRect);
+               ScrnMarkRectangle(xw, &myRect, True, nparam - 4, param + 4);
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_RQM:
+           TRACE(("CASE_RQM\n"));
+           do_rpm(xw, nparam, param);
+           ResetState(sp);
+           break;
+
+       case CASE_DECRQM:
+           TRACE(("CASE_DECRQM\n"));
+           do_decrpm(xw, nparam, param);
+           ResetState(sp);
+           break;
+
+       case CASE_CSI_DEC_DOLLAR_STATE:
+           TRACE(("CASE_CSI_DEC_DOLLAR_STATE\n"));
+           /* csi ? dollar ($) */
+           sp->parsestate = csi_dec_dollar_table;
+           break;
+#else
+       case CASE_CSI_DOLLAR_STATE:
+           /* csi dollar ($) */
+           sp->parsestate = eigtable;
+           break;
+
+       case CASE_CSI_STAR_STATE:
+           /* csi dollar (*) */
+           sp->parsestate = eigtable;
+           break;
+
+       case CASE_CSI_DEC_DOLLAR_STATE:
+           /* csi ? dollar ($) */
+           sp->parsestate = eigtable;
+           break;
+#endif /* OPT_DEC_RECTOPS */
+
+       case CASE_S7C1T:
+           TRACE(("CASE_S7C1T\n"));
+           show_8bit_control(False);
+           ResetState(sp);
+           break;
+
+       case CASE_S8C1T:
+           TRACE(("CASE_S8C1T\n"));
+#if OPT_VT52_MODE
+           if (screen->vtXX_level <= 1)
+               break;
+#endif
+           show_8bit_control(True);
+           ResetState(sp);
+           break;
+
+       case CASE_OSC:
+           TRACE(("CASE_OSC: Operating System Command\n"));
+           sp->parsestate = sos_table;
+           sp->string_mode = ANSI_OSC;
+           break;
+
+       case CASE_RIS:
+           TRACE(("CASE_RIS\n"));
+           VTReset(xw, True, True);
+           ResetState(sp);
+           break;
+
+       case CASE_DECSTR:
+           TRACE(("CASE_DECSTR\n"));
+           VTReset(xw, False, False);
+           ResetState(sp);
+           break;
+
+       case CASE_REP:
+           TRACE(("CASE_REP\n"));
+           if (sp->lastchar >= 0 &&
+               sp->lastchar < 256 &&
+               sp->groundtable[E2A(sp->lastchar)] == CASE_PRINT) {
+               IChar repeated[2];
+               count = (param[0] < 1) ? 1 : param[0];
+               repeated[0] = (IChar) sp->lastchar;
+               while (count-- > 0) {
+                   dotext(xw,
+                          screen->gsets[(int) (screen->curgl)],
+                          repeated, 1);
+               }
+           }
+           ResetState(sp);
+           break;
+
+       case CASE_LS2:
+           TRACE(("CASE_LS2\n"));
+           screen->curgl = 2;
+           ResetState(sp);
+           break;
+
+       case CASE_LS3:
+           TRACE(("CASE_LS3\n"));
+           screen->curgl = 3;
+           ResetState(sp);
+           break;
+
+       case CASE_LS3R:
+           TRACE(("CASE_LS3R\n"));
+           screen->curgr = 3;
+           ResetState(sp);
+           break;
+
+       case CASE_LS2R:
+           TRACE(("CASE_LS2R\n"));
+           screen->curgr = 2;
+           ResetState(sp);
+           break;
+
+       case CASE_LS1R:
+           TRACE(("CASE_LS1R\n"));
+           screen->curgr = 1;
+           ResetState(sp);
+           break;
+
+       case CASE_XTERM_SAVE:
+           savemodes(xw);
+           ResetState(sp);
+           break;
+
+       case CASE_XTERM_RESTORE:
+           restoremodes(xw);
+           ResetState(sp);
+           break;
+
+       case CASE_XTERM_WINOPS:
+           TRACE(("CASE_XTERM_WINOPS\n"));
+           window_ops(xw);
+           ResetState(sp);
+           break;
+#if OPT_WIDE_CHARS
+       case CASE_ESC_PERCENT:
+           sp->parsestate = esc_pct_table;
+           break;
+
+       case CASE_UTF8:
+           /* If we did not set UTF-8 mode from resource or the
+            * command-line, allow it to be enabled/disabled by
+            * control sequence.
+            */
+           if (screen->wide_chars
+               && screen->utf8_mode != uAlways) {
+               if (!screen->wide_chars) {
+                   WriteNow();
+                   ChangeToWide(xw);
+               }
+               switchPtyData(screen, c == 'G');
+               TRACE(("UTF8 mode %s\n",
+                      BtoS(screen->utf8_mode)));
+           } else {
+               TRACE(("UTF8 mode NOT turned %s (%s)\n",
+                      BtoS(c == 'G'),
+                      (screen->utf8_mode == uAlways)
+                      ? "UTF-8 mode set from command-line"
+                      : "wideChars resource was not set"));
+           }
+           ResetState(sp);
+           break;
+#endif
+#if OPT_MOD_FKEYS
+       case CASE_SET_MOD_FKEYS:
+           TRACE(("CASE_SET_MOD_FKEYS\n"));
+           if (nparam >= 1) {
+               set_mod_fkeys(xw, param[0], nparam > 1 ? param[1] : DEFAULT, True);
+           } else {
+               for (row = 1; row <= 5; ++row)
+                   set_mod_fkeys(xw, row, DEFAULT, True);
+           }
+           break;
+       case CASE_SET_MOD_FKEYS0:
+           TRACE(("CASE_SET_MOD_FKEYS0\n"));
+           if (nparam >= 1 && param[0] != DEFAULT) {
+               set_mod_fkeys(xw, param[0], -1, False);
+           } else {
+               xw->keyboard.modify_now.function_keys = -1;
+           }
+           break;
+#endif
+       case CASE_HIDE_POINTER:
+           TRACE(("CASE_HIDE_POINTER\n"));
+           if (nparam >= 1 && param[0] != DEFAULT) {
+               screen->pointer_mode = param[0];
+           } else {
+               screen->pointer_mode = DEF_POINTER_MODE;
+           }
+           break;
+
+       case CASE_SM_TITLE:
+           TRACE(("CASE_SM_TITLE\n"));
+           if (nparam >= 1) {
+               int n;
+               for (n = 0; n < nparam; ++n) {
+                   if (param[n] != DEFAULT)
+                       screen->title_modes |= (1 << param[n]);
+               }
+           } else {
+               screen->title_modes = DEF_TITLE_MODES;
+           }
+           TRACE(("...title_modes %#x\n", screen->title_modes));
+           break;
+
+       case CASE_RM_TITLE:
+           TRACE(("CASE_RM_TITLE\n"));
+           if (nparam >= 1) {
+               int n;
+               for (n = 0; n < nparam; ++n) {
+                   if (param[n] != DEFAULT)
+                       screen->title_modes &= ~(1 << param[n]);
+               }
+           } else {
+               screen->title_modes = DEF_TITLE_MODES;
+           }
+           TRACE(("...title_modes %#x\n", screen->title_modes));
+           break;
+
+       case CASE_CSI_IGNORE:
+           sp->parsestate = cigtable;
+           break;
+
+       case CASE_DECSWBV:
+           TRACE(("CASE_DECSWBV\n"));
+           switch ((nparam >= 1) ? param[0] : DEFAULT) {
+           case 2:
+           case 3:
+           case 4:
+               screen->warningVolume = bvLow;
+               break;
+           case 5:
+           case 6:
+           case 7:
+           case 8:
+               screen->warningVolume = bvHigh;
+               break;
+           default:
+               screen->warningVolume = bvOff;
+               break;
+           }
+           TRACE(("...warningVolume %d\n", screen->warningVolume));
+           ResetState(sp);
+           break;
+
+       case CASE_DECSMBV:
+           TRACE(("CASE_DECSMBV\n"));
+           switch ((nparam >= 1) ? param[0] : DEFAULT) {
+           case 2:
+           case 3:
+           case 4:
+               screen->marginVolume = bvLow;
+               break;
+           case 0:
+           case DEFAULT:
+           case 5:
+           case 6:
+           case 7:
+           case 8:
+               screen->marginVolume = bvHigh;
+               break;
+           default:
+               screen->marginVolume = bvOff;
+               break;
+           }
+           TRACE(("...marginVolume %d\n", screen->marginVolume));
+           ResetState(sp);
+           break;
+       }
+       if (sp->parsestate == sp->groundtable)
+           sp->lastchar = thischar;
+    } while (0);
+
+#if OPT_WIDE_CHARS
+    screen->utf8_inparse = (Boolean) ((screen->utf8_mode != uFalse)
+                                     && (sp->parsestate != sos_table));
+#endif
+
+    return True;
+}
+
+static void
+VTparse(XtermWidget xw)
+{
+    TScreen *screen;
+
+    /* We longjmp back to this point in VTReset() */
+    (void) setjmp(vtjmpbuf);
+    screen = TScreenOf(xw);
+    memset(&myState, 0, sizeof(myState));
+    myState.scssize = 94;      /* number of printable/nonspace ASCII */
+    myState.lastchar = -1;     /* not a legal IChar */
+    myState.nextstate = -1;    /* not a legal state */
+
+    init_groundtable(screen, &myState);
+    myState.parsestate = myState.groundtable;
+
+    do {
+    } while (doparsing(xw, doinput(), &myState));
+}
+
+static Char *v_buffer;         /* pointer to physical buffer */
+static Char *v_bufstr = NULL;  /* beginning of area to write */
+static Char *v_bufptr;         /* end of area to write */
+static Char *v_bufend;         /* end of physical buffer */
+
+/* Write data to the pty as typed by the user, pasted with the mouse,
+   or generated by us in response to a query ESC sequence. */
+
+void
+v_write(int f, const Char * data, unsigned len)
+{
+    int riten;
+
+    TRACE2(("v_write(%d:%s)\n", len, visibleChars(data, len)));
+    if (v_bufstr == NULL && len > 0) {
+       v_buffer = (Char *) XtMalloc((Cardinal) len);
+       v_bufstr = v_buffer;
+       v_bufptr = v_buffer;
+       v_bufend = v_buffer + len;
+    }
+#ifdef DEBUG
+    if (debug) {
+       fprintf(stderr, "v_write called with %d bytes (%d left over)",
+               len, v_bufptr - v_bufstr);
+       if (len > 1 && len < 10)
+           fprintf(stderr, " \"%.*s\"", len, (const char *) data);
+       fprintf(stderr, "\n");
+    }
+#endif
+
+#ifdef VMS
+    if ((1 << f) != pty_mask) {
+       tt_write((const char *) data, len);
+       return;
+    }
+#else /* VMS */
+    if (!FD_ISSET(f, &pty_mask)) {
+       IGNORE_RC(write(f, (const char *) data, (size_t) len));
+       return;
+    }
+#endif /* VMS */
+
+    /*
+     * Append to the block we already have.
+     * Always doing this simplifies the code, and
+     * isn't too bad, either.  If this is a short
+     * block, it isn't too expensive, and if this is
+     * a long block, we won't be able to write it all
+     * anyway.
+     */
+
+    if (len > 0) {
+#if OPT_DABBREV
+       TScreenOf(term)->dabbrev_working = False;       /* break dabbrev sequence */
+#endif
+       if (v_bufend < v_bufptr + len) {        /* we've run out of room */
+           if (v_bufstr != v_buffer) {
+               /* there is unused space, move everything down */
+               /* possibly overlapping memmove here */
+#ifdef DEBUG
+               if (debug)
+                   fprintf(stderr, "moving data down %d\n",
+                           v_bufstr - v_buffer);
+#endif
+               memmove(v_buffer, v_bufstr, (size_t) (v_bufptr - v_bufstr));
+               v_bufptr -= v_bufstr - v_buffer;
+               v_bufstr = v_buffer;
+           }
+           if (v_bufend < v_bufptr + len) {
+               /* still won't fit: get more space */
+               /* Don't use XtRealloc because an error is not fatal. */
+               unsigned size = (unsigned) (v_bufptr - v_buffer);
+               v_buffer = TypeRealloc(Char, size + len, v_buffer);
+               if (v_buffer) {
+#ifdef DEBUG
+                   if (debug)
+                       fprintf(stderr, "expanded buffer to %d\n",
+                               size + len);
+#endif
+                   v_bufstr = v_buffer;
+                   v_bufptr = v_buffer + size;
+                   v_bufend = v_bufptr + len;
+               } else {
+                   /* no memory: ignore entire write request */
+                   fprintf(stderr, "%s: cannot allocate buffer space\n",
+                           xterm_name);
+                   v_buffer = v_bufstr;        /* restore clobbered pointer */
+               }
+           }
+       }
+       if (v_bufend >= v_bufptr + len) {
+           /* new stuff will fit */
+           memmove(v_bufptr, data, (size_t) len);
+           v_bufptr += len;
+       }
+    }
+
+    /*
+     * Write out as much of the buffer as we can.
+     * Be careful not to overflow the pty's input silo.
+     * We are conservative here and only write
+     * a small amount at a time.
+     *
+     * If we can't push all the data into the pty yet, we expect write
+     * to return a non-negative number less than the length requested
+     * (if some data written) or -1 and set errno to EAGAIN,
+     * EWOULDBLOCK, or EINTR (if no data written).
+     *
+     * (Not all systems do this, sigh, so the code is actually
+     * a little more forgiving.)
+     */
+
+#define MAX_PTY_WRITE 128      /* 1/2 POSIX minimum MAX_INPUT */
+
+    if (v_bufptr > v_bufstr) {
+#ifdef VMS
+       riten = tt_write(v_bufstr,
+                        ((v_bufptr - v_bufstr <= VMS_TERM_BUFFER_SIZE)
+                         ? v_bufptr - v_bufstr
+                         : VMS_TERM_BUFFER_SIZE));
+       if (riten == 0)
+           return (riten);
+#else /* VMS */
+       riten = (int) write(f, v_bufstr,
+                           (size_t) ((v_bufptr - v_bufstr <= MAX_PTY_WRITE)
+                                     ? v_bufptr - v_bufstr
+                                     : MAX_PTY_WRITE));
+       if (riten < 0)
+#endif /* VMS */
+       {
+#ifdef DEBUG
+           if (debug)
+               perror("write");
+#endif
+           riten = 0;
+       }
+#ifdef DEBUG
+       if (debug)
+           fprintf(stderr, "write called with %d, wrote %d\n",
+                   v_bufptr - v_bufstr <= MAX_PTY_WRITE ?
+                   v_bufptr - v_bufstr : MAX_PTY_WRITE,
+                   riten);
+#endif
+       v_bufstr += riten;
+       if (v_bufstr >= v_bufptr)       /* we wrote it all */
+           v_bufstr = v_bufptr = v_buffer;
+    }
+
+    /*
+     * If we have lots of unused memory allocated, return it
+     */
+    if (v_bufend - v_bufptr > 1024) {  /* arbitrary hysteresis */
+       /* save pointers across realloc */
+       int start = (int) (v_bufstr - v_buffer);
+       int size = (int) (v_bufptr - v_buffer);
+       unsigned allocsize = (unsigned) (size ? size : 1);
+
+       v_buffer = TypeRealloc(Char, allocsize, v_buffer);
+       if (v_buffer) {
+           v_bufstr = v_buffer + start;
+           v_bufptr = v_buffer + size;
+           v_bufend = v_buffer + allocsize;
+#ifdef DEBUG
+           if (debug)
+               fprintf(stderr, "shrunk buffer to %d\n", allocsize);
+#endif
+       } else {
+           /* should we print a warning if couldn't return memory? */
+           v_buffer = v_bufstr - start;        /* restore clobbered pointer */
+       }
+    }
+}
+
+#ifdef VMS
+#define        ptymask()       (v_bufptr > v_bufstr ? pty_mask : 0)
+
+static void
+in_put(XtermWidget xw)
+{
+    static PtySelect select_mask;
+    static PtySelect write_mask;
+    int update = VTbuffer->update;
+    int size;
+
+    int status;
+    Dimension replyWidth, replyHeight;
+    XtGeometryResult stat;
+
+    TScreen *screen = TScreenOf(xw);
+    char *cp;
+    int i;
+
+    select_mask = pty_mask;    /* force initial read */
+    for (;;) {
+
+       /* if the terminal changed size, resize the widget */
+       if (tt_changed) {
+           tt_changed = False;
+
+           stat = REQ_RESIZE((Widget) xw,
+                             ((Dimension) FontWidth(screen)
+                              * (tt_width)
+                              + 2 * screen->border
+                              + screen->fullVwin.sb_info.width),
+                             ((Dimension) FontHeight(screen)
+                              * (tt_length)
+                              + 2 * screen->border),
+                             &replyWidth, &replyHeight);
+
+           if (stat == XtGeometryYes || stat == XtGeometryDone) {
+               xw->core.width = replyWidth;
+               xw->core.height = replyHeight;
+
+               ScreenResize(xw, replyWidth, replyHeight, &xw->flags);
+           }
+           repairSizeHints();
+       }
+
+       if (screen->eventMode == NORMAL
+           && readPtyData(xw, &select_mask, VTbuffer)) {
+           if (screen->scrollWidget
+               && screen->scrollttyoutput
+               && screen->topline < 0)
+               /* Scroll to bottom */
+               WindowScroll(xw, 0, False);
+           break;
+       }
+       if (screen->scroll_amt)
+           FlushScroll(xw);
+       if (screen->cursor_set && CursorMoved(screen)) {
+           if (screen->cursor_state)
+               HideCursor();
+           ShowCursor();
+#if OPT_INPUT_METHOD
+           PreeditPosition(screen);
+#endif
+       } else if (screen->cursor_set != screen->cursor_state) {
+           if (screen->cursor_set)
+               ShowCursor();
+           else
+               HideCursor();
+       }
+
+       if (QLength(screen->display)) {
+           select_mask = X_mask;
+       } else {
+           write_mask = ptymask();
+           XFlush(screen->display);
+           select_mask = Select_mask;
+           if (screen->eventMode != NORMAL)
+               select_mask = X_mask;
+       }
+       if (write_mask & ptymask()) {
+           v_write(screen->respond, 0, 0);     /* flush buffer */
+       }
+
+       if (select_mask & X_mask) {
+           xevents();
+           if (VTbuffer->update != update)
+               break;
+       }
+    }
+}
+#else /* VMS */
+
+static void
+in_put(XtermWidget xw)
+{
+    static PtySelect select_mask;
+    static PtySelect write_mask;
+
+    TScreen *screen = TScreenOf(xw);
+    int i, time_select;
+    int size;
+    int update = VTbuffer->update;
+
+    static struct timeval select_timeout;
+
+#if OPT_BLINK_CURS
+    /*
+     * Compute the timeout for the blinking cursor to be much smaller than
+     * the "on" or "off" interval.
+     */
+    int tick = ((screen->blink_on < screen->blink_off)
+               ? screen->blink_on
+               : screen->blink_off);
+    tick *= (1000 / 8);                /* 1000 for msec/usec, 8 for "much" smaller */
+    if (tick < 1)
+       tick = 1;
+#endif
+
+    for (;;) {
+       if (screen->eventMode == NORMAL
+           && (size = readPtyData(xw, &select_mask, VTbuffer)) != 0) {
+           if (screen->scrollWidget
+               && screen->scrollttyoutput
+               && screen->topline < 0)
+               WindowScroll(xw, 0, False);     /* Scroll to bottom */
+           /* stop speed reading at some point to look for X stuff */
+           TRACE(("VTbuffer uses %ld/%d\n",
+                  (long) (VTbuffer->last - VTbuffer->buffer),
+                  BUF_SIZE));
+           if ((VTbuffer->last - VTbuffer->buffer) > BUF_SIZE) {
+               FD_CLR(screen->respond, &select_mask);
+               break;
+           }
+#if defined(HAVE_SCHED_YIELD)
+           /*
+            * If we've read a full (small/fragment) buffer, let the operating
+            * system have a turn, and we'll resume reading until we've either
+            * read only a fragment of the buffer, or we've filled the large
+            * buffer (see above).  Doing this helps keep up with large bursts
+            * of output.
+            */
+           if (size == FRG_SIZE) {
+               select_timeout.tv_sec = 0;
+               i = Select(max_plus1, &select_mask, &write_mask, 0,
+                          &select_timeout);
+               if (i > 0) {
+                   sched_yield();
+               } else
+                   break;
+           } else {
+               break;
+           }
+#else
+           (void) size;        /* unused in this branch */
+           break;
+#endif
+       }
+       /* update the screen */
+       if (screen->scroll_amt)
+           FlushScroll(xw);
+       if (screen->cursor_set && CursorMoved(screen)) {
+           if (screen->cursor_state)
+               HideCursor();
+           ShowCursor();
+#if OPT_INPUT_METHOD
+           PreeditPosition(screen);
+#endif
+       } else if (screen->cursor_set != screen->cursor_state) {
+           if (screen->cursor_set)
+               ShowCursor();
+           else
+               HideCursor();
+       }
+
+       XFlush(screen->display);        /* always flush writes before waiting */
+
+       /* Update the masks and, unless X events are already in the queue,
+          wait for I/O to be possible. */
+       XFD_COPYSET(&Select_mask, &select_mask);
+       /* in selection mode xterm does not read pty */
+       if (screen->eventMode != NORMAL)
+           FD_CLR(screen->respond, &select_mask);
+
+       if (v_bufptr > v_bufstr) {
+           XFD_COPYSET(&pty_mask, &write_mask);
+       } else
+           FD_ZERO(&write_mask);
+       select_timeout.tv_sec = 0;
+       time_select = 0;
+
+       /*
+        * if there's either an XEvent or an XtTimeout pending, just take
+        * a quick peek, i.e. timeout from the select() immediately.  If
+        * there's nothing pending, let select() block a little while, but
+        * for a shorter interval than the arrow-style scrollbar timeout.
+        * The blocking is optional, because it tends to increase the load
+        * on the host.
+        */
+       if (XtAppPending(app_con)) {
+           select_timeout.tv_usec = 0;
+           time_select = 1;
+       } else if (screen->awaitInput) {
+           select_timeout.tv_usec = 50000;
+           time_select = 1;
+#if OPT_BLINK_CURS
+       } else if ((screen->blink_timer != 0 &&
+                   ((screen->select & FOCUS) || screen->always_highlight)) ||
+                  (screen->cursor_state == BLINKED_OFF)) {
+           select_timeout.tv_usec = tick;
+           while (select_timeout.tv_usec > 1000000) {
+               select_timeout.tv_usec -= 1000000;
+               select_timeout.tv_sec++;
+           }
+           time_select = 1;
+#endif
+#if OPT_SESSION_MGT
+       } else if (resource.sessionMgt) {
+           if (ice_fd >= 0)
+               FD_SET(ice_fd, &select_mask);
+#endif
+       }
+       if (need_cleanup)
+           Cleanup(0);
+       i = Select(max_plus1, &select_mask, &write_mask, 0,
+                  (time_select ? &select_timeout : 0));
+       if (i < 0) {
+           if (errno != EINTR)
+               SysError(ERROR_SELECT);
+           continue;
+       }
+
+       /* if there is room to write more data to the pty, go write more */
+       if (FD_ISSET(screen->respond, &write_mask)) {
+           v_write(screen->respond, (Char *) 0, 0);    /* flush buffer */
+       }
+
+       /* if there are X events already in our queue, it
+          counts as being readable */
+       if (XtAppPending(app_con) ||
+           FD_ISSET(ConnectionNumber(screen->display), &select_mask)) {
+           xevents();
+           if (VTbuffer->update != update)     /* HandleInterpret */
+               break;
+       }
+
+    }
+}
+#endif /* VMS */
+
+static IChar
+doinput(void)
+{
+    TScreen *screen = TScreenOf(term);
+
+    while (!morePtyData(screen, VTbuffer))
+       in_put(term);
+    return nextPtyData(screen, VTbuffer);
+}
+
+#if OPT_INPUT_METHOD
+/*
+ *  For OverTheSpot, client has to inform the position for XIM preedit.
+ */
+static void
+PreeditPosition(TScreen * screen)
+{
+    LineData *ld;
+    XPoint spot;
+    XVaNestedList list;
+
+    if (screen->xic
+       && (ld = getLineData(screen, screen->cur_row)) != 0) {
+       spot.x = (short) LineCursorX(screen, ld, screen->cur_col);
+       spot.y = (short) (CursorY(screen, screen->cur_row) + screen->fs_ascent);
+       list = XVaCreateNestedList(0,
+                                  XNSpotLocation, &spot,
+                                  XNForeground, T_COLOR(screen, TEXT_FG),
+                                  XNBackground, T_COLOR(screen, TEXT_BG),
+                                  NULL);
+       XSetICValues(screen->xic, XNPreeditAttributes, list, NULL);
+       XFree(list);
+    }
+}
+#endif
+
+static void
+WrapLine(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld = getLineData(screen, screen->cur_row);
+
+    if (ld != 0) {
+       /* mark that we had to wrap this line */
+       LineSetFlag(ld, LINEWRAPPED);
+       if (screen->show_wrap_marks) {
+           ShowWrapMarks(xw, screen->cur_row, ld);
+       }
+       xtermAutoPrint(xw, '\n');
+       xtermIndex(xw, 1);
+       set_cur_col(screen, 0);
+    }
+}
+
+/*
+ * process a string of characters according to the character set indicated
+ * by charset.  worry about end of line conditions (wraparound if selected).
+ */
+void
+dotext(XtermWidget xw,
+       int charset,
+       IChar * buf,            /* start of characters to process */
+       Cardinal len)           /* end */
+{
+    TScreen *screen = TScreenOf(xw);
+#if OPT_WIDE_CHARS
+    Cardinal chars_chomped = 1;
+    int next_col = screen->cur_col;
+#else
+    int next_col, last_col, this_col;  /* must be signed */
+#endif
+    Cardinal offset;
+
+#if OPT_WIDE_CHARS
+    /* don't translate if we use UTF-8, and are not handling legacy support
+     * for line-drawing characters.
+     */
+    if ((screen->utf8_mode == uFalse)
+       || (screen->vt100_graphics))
+#endif
+       if (!xtermCharSetOut(xw, buf, buf + len, charset))
+           return;
+
+    if_OPT_XMC_GLITCH(screen, {
+       Cardinal n;
+       if (charset != '?') {
+           for (n = 0; n < len; n++) {
+               if (buf[n] == XMC_GLITCH)
+                   buf[n] = XMC_GLITCH + 1;
+           }
+       }
+    });
+
+#if OPT_WIDE_CHARS
+    for (offset = 0;
+        offset < len && (chars_chomped > 0 || screen->do_wrap);
+        offset += chars_chomped) {
+       int width_available = MaxCols(screen) - screen->cur_col;
+       int width_here = 0;
+       Boolean need_wrap = False;
+       int last_chomp = 0;
+       chars_chomped = 0;
+
+       if (screen->do_wrap) {
+           screen->do_wrap = False;
+           if ((xw->flags & WRAPAROUND)) {
+               WrapLine(xw);
+               width_available = MaxCols(screen) - screen->cur_col;
+               next_col = screen->cur_col;
+           }
+       }
+
+       while (width_here <= width_available && chars_chomped < (len - offset)) {
+           if (!screen->utf8_mode
+               || (screen->vt100_graphics && charset == '0'))
+               last_chomp = 1;
+           else
+               last_chomp = my_wcwidth((int) buf[chars_chomped + offset]);
+           width_here += last_chomp;
+           chars_chomped++;
+       }
+
+       if (width_here > width_available) {
+           if (last_chomp > MaxCols(screen))
+               break;          /* give up - it is too big */
+           chars_chomped--;
+           width_here -= last_chomp;
+           if (chars_chomped > 0) {
+               need_wrap = True;
+           }
+       } else if (width_here == width_available) {
+           need_wrap = True;
+       } else if (chars_chomped != (len - offset)) {
+           need_wrap = True;
+       }
+
+       /*
+        * Split the wide characters back into separate arrays of 8-bit
+        * characters so we can use the existing interface.
+        *
+        * FIXME:  If we rewrote this interface, it would involve
+        * rewriting all of the memory-management for the screen
+        * buffers (perhaps this is simpler).
+        */
+       if (chars_chomped != 0 && next_col <= screen->max_col) {
+           WriteText(xw, buf + offset, chars_chomped);
+       }
+       next_col += width_here;
+       screen->do_wrap = need_wrap;
+    }
+#else /* ! OPT_WIDE_CHARS */
+
+    for (offset = 0; offset < len; offset += this_col) {
+#if OPT_DEC_CHRSET
+       LineData *ld = getLineData(screen, screen->cur_row);
+#endif
+
+       last_col = LineMaxCol(screen, ld);
+       this_col = last_col - screen->cur_col + 1;
+       if (this_col <= 1) {
+           if (screen->do_wrap) {
+               screen->do_wrap = False;
+               if ((xw->flags & WRAPAROUND)) {
+                   WrapLine(xw);
+               }
+           }
+           this_col = 1;
+       }
+       if (offset + this_col > len) {
+           this_col = len - offset;
+       }
+       next_col = screen->cur_col + this_col;
+
+       WriteText(xw, buf + offset, (unsigned) this_col);
+
+       /*
+        * The call to WriteText updates screen->cur_col.
+        * If screen->cur_col is less than next_col, we must have
+        * hit the right margin - so set the do_wrap flag.
+        */
+       screen->do_wrap = (screen->cur_col < next_col);
+    }
+
+#endif /* OPT_WIDE_CHARS */
+}
+
+#if OPT_WIDE_CHARS
+unsigned
+visual_width(IChar * str, Cardinal len)
+{
+    /* returns the visual width of a string (doublewide characters count
+       as 2, normalwide characters count as 1) */
+    unsigned my_len = 0;
+    while (len) {
+       int ch = (int) *str++;
+       if (isWide(ch))
+           my_len += 2;
+       else
+           my_len++;
+       len--;
+    }
+    return my_len;
+}
+#endif
+
+#if HANDLE_STRUCT_NOTIFY
+/* Flag icon name with "***" on window output when iconified.
+ */
+static void
+HandleStructNotify(Widget w GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XEvent * event,
+                  Boolean * cont GCC_UNUSED)
+{
+    static char *icon_name;
+    static Arg args[] =
+    {
+       {XtNiconName, (XtArgVal) & icon_name}
+    };
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    switch (event->type) {
+    case MapNotify:
+       TRACE(("HandleStructNotify(MapNotify)\n"));
+#if OPT_ZICONBEEP
+       if (screen->zIconBeep_flagged) {
+           screen->zIconBeep_flagged = False;
+           icon_name = NULL;
+           XtGetValues(toplevel, args, XtNumber(args));
+           if (icon_name != NULL) {
+               char *buf = CastMallocN(char, strlen(icon_name));
+               if (buf == NULL) {
+                   screen->zIconBeep_flagged = True;
+                   return;
+               }
+               strcpy(buf, icon_name + 4);
+               ChangeIconName(xw, buf);
+               free(buf);
+           }
+       }
+#endif /* OPT_ZICONBEEP */
+       mapstate = !IsUnmapped;
+       break;
+    case UnmapNotify:
+       TRACE(("HandleStructNotify(UnmapNotify)\n"));
+       mapstate = IsUnmapped;
+       break;
+    case ConfigureNotify:
+       if (event->xconfigure.window == XtWindow(toplevel)) {
+#if !OPT_TOOLBAR
+           int height, width;
+
+           height = event->xconfigure.height;
+           width = event->xconfigure.width;
+#endif
+           TRACE(("HandleStructNotify(ConfigureNotify) %d,%d %dx%d\n",
+                  event->xconfigure.y, event->xconfigure.x,
+                  event->xconfigure.height, event->xconfigure.width));
+
+#if OPT_TOOLBAR
+           /*
+            * The notification is for the top-level widget, but we care about
+            * vt100 (ignore the tek4014 window).
+            */
+           if (TScreenOf(xw)->Vshow) {
+               VTwin *Vwin = WhichVWin(TScreenOf(xw));
+               TbInfo *info = &(Vwin->tb_info);
+               TbInfo save = *info;
+
+               if (info->menu_bar) {
+                   XtVaGetValues(info->menu_bar,
+                                 XtNheight, &info->menu_height,
+                                 XtNborderWidth, &info->menu_border,
+                                 (XtPointer) 0);
+
+                   if (save.menu_height != info->menu_height
+                       || save.menu_border != info->menu_border) {
+
+                       TRACE(("...menu_height %d\n", info->menu_height));
+                       TRACE(("...menu_border %d\n", info->menu_border));
+                       TRACE(("...had height  %d, border %d\n",
+                              save.menu_height,
+                              save.menu_border));
+
+                       /*
+                        * FIXME:  Window manager still may be using the old
+                        * values.  Try to fool it.
+                        */
+                       REQ_RESIZE((Widget) xw,
+                                  screen->fullVwin.fullwidth,
+                                  (Dimension) (info->menu_height
+                                               - save.menu_height
+                                               + screen->fullVwin.fullheight),
+                                  NULL, NULL);
+                       repairSizeHints();
+                   }
+               }
+           }
+#else
+           if (height != xw->hints.height || width != xw->hints.width)
+               RequestResize(xw, height, width, False);
+#endif /* OPT_TOOLBAR */
+       }
+       break;
+    case ReparentNotify:
+       TRACE(("HandleStructNotify(ReparentNotify)\n"));
+       break;
+    default:
+       TRACE(("HandleStructNotify(event %s)\n",
+              visibleEventType(event->type)));
+       break;
+    }
+}
+#endif /* HANDLE_STRUCT_NOTIFY */
+
+#if OPT_BLINK_CURS
+static void
+SetCursorBlink(TScreen * screen, Bool enable)
+{
+    screen->cursor_blink = (Boolean) enable;
+    if (DoStartBlinking(screen)) {
+       StartBlinking(screen);
+    } else {
+       /* EMPTY */
+#if !OPT_BLINK_TEXT
+       StopBlinking(screen);
+#endif
+    }
+    update_cursorblink();
+}
+
+void
+ToggleCursorBlink(TScreen * screen)
+{
+    SetCursorBlink(screen, (Bool) (!(screen->cursor_blink)));
+}
+#endif
+
+/*
+ * process ANSI modes set, reset
+ */
+static void
+ansi_modes(XtermWidget xw, BitFunc func)
+{
+    int i;
+
+    for (i = 0; i < nparam; ++i) {
+       switch (param[i]) {
+       case 2:         /* KAM (if set, keyboard locked */
+           (*func) (&xw->keyboard.flags, MODE_KAM);
+           break;
+
+       case 4:         /* IRM                          */
+           (*func) (&xw->flags, INSERT);
+           break;
+
+       case 12:                /* SRM (if set, local echo      */
+           (*func) (&xw->keyboard.flags, MODE_SRM);
+           break;
+
+       case 20:                /* LNM                          */
+           (*func) (&xw->flags, LINEFEED);
+           update_autolinefeed();
+           break;
+       }
+    }
+}
+
+#define IsSM() (func == bitset)
+
+#define set_bool_mode(flag) \
+       flag = (Boolean) IsSM()
+
+static void
+really_set_mousemode(XtermWidget xw,
+                    Bool enabled,
+                    XtermMouseModes mode)
+{
+    TScreenOf(xw)->send_mouse_pos = enabled ? mode : MOUSE_OFF;
+    if (TScreenOf(xw)->send_mouse_pos != MOUSE_OFF)
+       xtermShowPointer(xw, True);
+}
+
+#define set_mousemode(mode) really_set_mousemode(xw, IsSM(), mode)
+
+#if OPT_READLINE
+#define set_mouseflag(f)               \
+       (IsSM()                         \
+        ? SCREEN_FLAG_set(screen, f)   \
+        : SCREEN_FLAG_unset(screen, f))
+#endif
+
+/*
+ * process DEC private modes set, reset
+ */
+static void
+dpmodes(XtermWidget xw, BitFunc func)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i, j;
+    unsigned myflags;
+
+    for (i = 0; i < nparam; ++i) {
+       TRACE(("%s %d\n", IsSM()? "DECSET" : "DECRST", param[i]));
+       switch (param[i]) {
+       case 1:         /* DECCKM                       */
+           (*func) (&xw->keyboard.flags, MODE_DECCKM);
+           update_appcursor();
+           break;
+       case 2:         /* DECANM - ANSI/VT52 mode      */
+           if (IsSM()) {       /* ANSI (VT100) */
+               /*
+                * Setting DECANM should have no effect, since this function
+                * cannot be reached from vt52 mode.
+                */
+               /* EMPTY */ ;
+           }
+#if OPT_VT52_MODE
+           else if (screen->terminal_id >= 100) {      /* VT52 */
+               TRACE(("DECANM terminal_id %d, vtXX_level %d\n",
+                      screen->terminal_id,
+                      screen->vtXX_level));
+               screen->vt52_save_level = screen->vtXX_level;
+               screen->vtXX_level = 0;
+               screen->vt52_save_curgl = screen->curgl;
+               screen->vt52_save_curgr = screen->curgr;
+               screen->vt52_save_curss = screen->curss;
+               memmove(screen->vt52_save_gsets, screen->gsets, sizeof(screen->gsets));
+               resetCharsets(screen);
+               nparam = 0;     /* ignore the remaining params, if any */
+           }
+#endif
+           break;
+       case 3:         /* DECCOLM                      */
+           if (screen->c132) {
+               ClearScreen(xw);
+               CursorSet(screen, 0, 0, xw->flags);
+               if ((j = IsSM()? 132 : 80) !=
+                   ((xw->flags & IN132COLUMNS) ? 132 : 80) ||
+                   j != MaxCols(screen))
+                   RequestResize(xw, -1, j, True);
+               (*func) (&xw->flags, IN132COLUMNS);
+           }
+           break;
+       case 4:         /* DECSCLM (slow scroll)        */
+           if (IsSM()) {
+               screen->jumpscroll = 0;
+               if (screen->scroll_amt)
+                   FlushScroll(xw);
+           } else
+               screen->jumpscroll = 1;
+           (*func) (&xw->flags, SMOOTHSCROLL);
+           update_jumpscroll();
+           break;
+       case 5:         /* DECSCNM                      */
+           myflags = xw->flags;
+           (*func) (&xw->flags, REVERSE_VIDEO);
+           if ((xw->flags ^ myflags) & REVERSE_VIDEO)
+               ReverseVideo(xw);
+           /* update_reversevideo done in RevVid */
+           break;
+
+       case 6:         /* DECOM                        */
+           (*func) (&xw->flags, ORIGIN);
+           CursorSet(screen, 0, 0, xw->flags);
+           break;
+
+       case 7:         /* DECAWM                       */
+           (*func) (&xw->flags, WRAPAROUND);
+           update_autowrap();
+           break;
+       case 8:         /* DECARM                       */
+           /* ignore autorepeat
+            * XAutoRepeatOn() and XAutoRepeatOff() can do this, but only
+            * for the whole display - not limited to a given window.
+            */
+           break;
+       case SET_X10_MOUSE:     /* MIT bogus sequence           */
+           MotionOff(screen, xw);
+           set_mousemode(X10_MOUSE);
+           break;
+#if OPT_TOOLBAR
+       case 10:                /* rxvt */
+           ShowToolbar(IsSM());
+           break;
+#endif
+#if OPT_BLINK_CURS
+       case 12:                /* att610: Start/stop blinking cursor */
+           if (screen->cursor_blink_res) {
+               set_bool_mode(screen->cursor_blink_esc);
+               SetCursorBlink(screen, screen->cursor_blink);
+           }
+           break;
+#endif
+       case 18:                /* DECPFF: print form feed */
+           set_bool_mode(screen->printer_formfeed);
+           break;
+       case 19:                /* DECPEX: print extent */
+           set_bool_mode(screen->printer_extent);
+           break;
+       case 25:                /* DECTCEM: Show/hide cursor (VT200) */
+           set_bool_mode(screen->cursor_set);
+           break;
+       case 30:                /* rxvt */
+           if (screen->fullVwin.sb_info.width != (IsSM()? ON : OFF))
+               ToggleScrollBar(xw);
+           break;
+#if OPT_SHIFT_FONTS
+       case 35:                /* rxvt */
+           set_bool_mode(xw->misc.shift_fonts);
+           break;
+#endif
+       case 38:                /* DECTEK                       */
+#if OPT_TEK4014
+           if (IsSM() && !(screen->inhibit & I_TEK)) {
+               FlushLog(xw);
+               TEK4014_ACTIVE(xw) = True;
+           }
+#endif
+           break;
+       case 40:                /* 132 column mode              */
+           set_bool_mode(screen->c132);
+           update_allow132();
+           break;
+       case 41:                /* curses hack                  */
+           set_bool_mode(screen->curses);
+           update_cursesemul();
+           break;
+       case 42:                /* DECNRCM national charset (VT220) */
+           (*func) (&xw->flags, NATIONAL);
+           break;
+       case 44:                /* margin bell                  */
+           set_bool_mode(screen->marginbell);
+           if (!screen->marginbell)
+               screen->bellArmed = -1;
+           update_marginbell();
+           break;
+       case 45:                /* reverse wraparound   */
+           (*func) (&xw->flags, REVERSEWRAP);
+           update_reversewrap();
+           break;
+#ifdef ALLOWLOGGING
+       case 46:                /* logging              */
+#ifdef ALLOWLOGFILEONOFF
+           /*
+            * if this feature is enabled, logging may be
+            * enabled and disabled via escape sequences.
+            */
+           if (IsSM())
+               StartLog(xw);
+           else
+               CloseLog(xw);
+#else
+           Bell(xw, XkbBI_Info, 0);
+           Bell(xw, XkbBI_Info, 0);
+#endif /* ALLOWLOGFILEONOFF */
+           break;
+#endif
+       case 1049:              /* alternate buffer & cursor */
+           if (!xw->misc.titeInhibit) {
+               if (IsSM()) {
+                   CursorSave(xw);
+                   ToAlternate(xw);
+                   ClearScreen(xw);
+               } else {
+                   FromAlternate(xw);
+                   CursorRestore(xw);
+               }
+           } else if (xw->misc.tiXtraScroll) {
+               if (IsSM()) {
+                   xtermScroll(xw, screen->max_row);
+               }
+           }
+           break;
+       case 1047:
+           /* FALLTHRU */
+       case 47:                /* alternate buffer */
+           if (!xw->misc.titeInhibit) {
+               if (IsSM()) {
+                   ToAlternate(xw);
+               } else {
+                   if (screen->whichBuf
+                       && (param[i] == 1047))
+                       ClearScreen(xw);
+                   FromAlternate(xw);
+               }
+           } else if (xw->misc.tiXtraScroll) {
+               if (IsSM()) {
+                   xtermScroll(xw, screen->max_row);
+               }
+           }
+           break;
+       case 66:                /* DECNKM */
+           (*func) (&xw->keyboard.flags, MODE_DECKPAM);
+           update_appkeypad();
+           break;
+       case 67:                /* DECBKM */
+           /* back-arrow mapped to backspace or delete(D) */
+           (*func) (&xw->keyboard.flags, MODE_DECBKM);
+           TRACE(("DECSET DECBKM %s\n",
+                  BtoS(xw->keyboard.flags & MODE_DECBKM)));
+           update_decbkm();
+           break;
+       case SET_VT200_MOUSE:   /* xterm bogus sequence         */
+           MotionOff(screen, xw);
+           set_mousemode(VT200_MOUSE);
+           break;
+       case SET_VT200_HIGHLIGHT_MOUSE: /* xterm sequence w/hilite tracking */
+           MotionOff(screen, xw);
+           set_mousemode(VT200_HIGHLIGHT_MOUSE);
+           break;
+       case SET_BTN_EVENT_MOUSE:
+           MotionOff(screen, xw);
+           set_mousemode(BTN_EVENT_MOUSE);
+           break;
+       case SET_ANY_EVENT_MOUSE:
+           set_mousemode(ANY_EVENT_MOUSE);
+           if (screen->send_mouse_pos == MOUSE_OFF) {
+               MotionOff(screen, xw);
+           } else {
+               MotionOn(screen, xw);
+           }
+           break;
+#if OPT_FOCUS_EVENT
+       case SET_FOCUS_EVENT_MOUSE:
+           set_bool_mode(screen->send_focus_pos);
+           break;
+#endif
+       case SET_EXT_MODE_MOUSE:
+           set_bool_mode(screen->ext_mode_mouse);
+           break;
+       case 1010:              /* rxvt */
+           set_bool_mode(screen->scrollttyoutput);
+           update_scrollttyoutput();
+           break;
+       case 1011:              /* rxvt */
+           set_bool_mode(screen->scrollkey);
+           update_scrollkey();
+           break;
+       case 1034:
+           set_bool_mode(screen->input_eight_bits);
+           update_alt_esc();
+           break;
+#if OPT_NUM_LOCK
+       case 1035:
+           set_bool_mode(xw->misc.real_NumLock);
+           update_num_lock();
+           break;
+       case 1036:
+           set_bool_mode(screen->meta_sends_esc);
+           update_meta_esc();
+           break;
+#endif
+       case 1037:
+           set_bool_mode(screen->delete_is_del);
+           update_delete_del();
+           break;
+#if OPT_NUM_LOCK
+       case 1039:
+           set_bool_mode(screen->alt_sends_esc);
+           update_alt_esc();
+           break;
+#endif
+       case 1040:
+           set_bool_mode(screen->keepSelection);
+           update_keepSelection();
+           break;
+       case 1041:
+           set_bool_mode(screen->selectToClipboard);
+           update_selectToClipboard();
+           break;
+       case 1042:
+           set_bool_mode(screen->bellIsUrgent);
+           update_bellIsUrgent();
+           break;
+       case 1043:
+           set_bool_mode(screen->poponbell);
+           update_poponbell();
+           break;
+       case 1048:
+           if (!xw->misc.titeInhibit) {
+               if (IsSM())
+                   CursorSave(xw);
+               else
+                   CursorRestore(xw);
+           }
+           break;
+#if OPT_TCAP_FKEYS
+       case 1050:
+           set_keyboard_type(xw, keyboardIsTermcap, IsSM());
+           break;
+#endif
+#if OPT_SUN_FUNC_KEYS
+       case 1051:
+           set_keyboard_type(xw, keyboardIsSun, IsSM());
+           break;
+#endif
+#if OPT_HP_FUNC_KEYS
+       case 1052:
+           set_keyboard_type(xw, keyboardIsHP, IsSM());
+           break;
+#endif
+#if OPT_SCO_FUNC_KEYS
+       case 1053:
+           set_keyboard_type(xw, keyboardIsSCO, IsSM());
+           break;
+#endif
+       case 1060:
+           set_keyboard_type(xw, keyboardIsLegacy, IsSM());
+           break;
+#if OPT_SUNPC_KBD
+       case 1061:
+           set_keyboard_type(xw, keyboardIsVT220, IsSM());
+           break;
+#endif
+#if OPT_READLINE
+       case SET_BUTTON1_MOVE_POINT:
+           set_mouseflag(click1_moves);
+           break;
+       case SET_BUTTON2_MOVE_POINT:
+           set_mouseflag(paste_moves);
+           break;
+       case SET_DBUTTON3_DELETE:
+           set_mouseflag(dclick3_deletes);
+           break;
+       case SET_PASTE_IN_BRACKET:
+           set_mouseflag(paste_brackets);
+           break;
+       case SET_PASTE_QUOTE:
+           set_mouseflag(paste_quotes);
+           break;
+       case SET_PASTE_LITERAL_NL:
+           set_mouseflag(paste_literal_nl);
+           break;
+#endif /* OPT_READLINE */
+       }
+    }
+}
+
+/*
+ * process xterm private modes save
+ */
+static void
+savemodes(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i;
+
+    for (i = 0; i < nparam; i++) {
+       TRACE(("savemodes %d\n", param[i]));
+       switch (param[i]) {
+       case 1:         /* DECCKM                       */
+           DoSM(DP_DECCKM, xw->keyboard.flags & MODE_DECCKM);
+           break;
+       case 3:         /* DECCOLM                      */
+           if (screen->c132)
+               DoSM(DP_DECCOLM, xw->flags & IN132COLUMNS);
+           break;
+       case 4:         /* DECSCLM (slow scroll)        */
+           DoSM(DP_DECSCLM, xw->flags & SMOOTHSCROLL);
+           break;
+       case 5:         /* DECSCNM                      */
+           DoSM(DP_DECSCNM, xw->flags & REVERSE_VIDEO);
+           break;
+       case 6:         /* DECOM                        */
+           DoSM(DP_DECOM, xw->flags & ORIGIN);
+           break;
+       case 7:         /* DECAWM                       */
+           DoSM(DP_DECAWM, xw->flags & WRAPAROUND);
+           break;
+       case 8:         /* DECARM                       */
+           /* ignore autorepeat */
+           break;
+       case SET_X10_MOUSE:     /* mouse bogus sequence */
+           DoSM(DP_X_X10MSE, screen->send_mouse_pos);
+           break;
+#if OPT_TOOLBAR
+       case 10:                /* rxvt */
+           DoSM(DP_TOOLBAR, resource.toolBar);
+           break;
+#endif
+#if OPT_BLINK_CURS
+       case 12:                /* att610: Start/stop blinking cursor */
+           if (screen->cursor_blink_res) {
+               DoSM(DP_CRS_BLINK, screen->cursor_blink_esc);
+           }
+           break;
+#endif
+       case 18:                /* DECPFF: print form feed */
+           DoSM(DP_PRN_FORMFEED, screen->printer_formfeed);
+           break;
+       case 19:                /* DECPEX: print extent */
+           DoSM(DP_PRN_EXTENT, screen->printer_extent);
+           break;
+       case 25:                /* DECTCEM: Show/hide cursor (VT200) */
+           DoSM(DP_CRS_VISIBLE, screen->cursor_set);
+           break;
+       case 40:                /* 132 column mode              */
+           DoSM(DP_X_DECCOLM, screen->c132);
+           break;
+       case 41:                /* curses hack                  */
+           DoSM(DP_X_MORE, screen->curses);
+           break;
+       case 42:                /* DECNRCM national charset (VT220) */
+           /* do nothing */
+           break;
+       case 44:                /* margin bell                  */
+           DoSM(DP_X_MARGIN, screen->marginbell);
+           break;
+       case 45:                /* reverse wraparound   */
+           DoSM(DP_X_REVWRAP, xw->flags & REVERSEWRAP);
+           break;
+#ifdef ALLOWLOGGING
+       case 46:                /* logging              */
+           DoSM(DP_X_LOGGING, screen->logging);
+           break;
+#endif
+       case 1047:              /* alternate buffer             */
+           /* FALLTHRU */
+       case 47:                /* alternate buffer             */
+           DoSM(DP_X_ALTSCRN, screen->whichBuf);
+           break;
+       case SET_VT200_MOUSE:   /* mouse bogus sequence         */
+       case SET_VT200_HIGHLIGHT_MOUSE:
+       case SET_BTN_EVENT_MOUSE:
+       case SET_ANY_EVENT_MOUSE:
+           DoSM(DP_X_MOUSE, screen->send_mouse_pos);
+           break;
+#if OPT_FOCUS_EVENT
+       case SET_FOCUS_EVENT_MOUSE:
+           DoSM(DP_X_FOCUS, screen->send_focus_pos);
+           break;
+#endif
+       case SET_EXT_MODE_MOUSE:
+           DoSM(DP_X_EXT_MOUSE, screen->ext_mode_mouse);
+           break;
+       case 1048:
+           if (!xw->misc.titeInhibit) {
+               CursorSave(xw);
+           }
+           break;
+#if OPT_READLINE
+       case SET_BUTTON1_MOVE_POINT:
+           SCREEN_FLAG_save(screen, click1_moves);
+           break;
+       case SET_BUTTON2_MOVE_POINT:
+           SCREEN_FLAG_save(screen, paste_moves);
+           break;
+       case SET_DBUTTON3_DELETE:
+           SCREEN_FLAG_save(screen, dclick3_deletes);
+           break;
+       case SET_PASTE_IN_BRACKET:
+           SCREEN_FLAG_save(screen, paste_brackets);
+           break;
+       case SET_PASTE_QUOTE:
+           SCREEN_FLAG_save(screen, paste_quotes);
+           break;
+       case SET_PASTE_LITERAL_NL:
+           SCREEN_FLAG_save(screen, paste_literal_nl);
+           break;
+#endif /* OPT_READLINE */
+       }
+    }
+}
+
+/*
+ * process xterm private modes restore
+ */
+static void
+restoremodes(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i, j;
+
+    for (i = 0; i < nparam; i++) {
+       TRACE(("restoremodes %d\n", param[i]));
+       switch (param[i]) {
+       case 1:         /* DECCKM                       */
+           bitcpy(&xw->keyboard.flags,
+                  screen->save_modes[DP_DECCKM], MODE_DECCKM);
+           update_appcursor();
+           break;
+       case 3:         /* DECCOLM                      */
+           if (screen->c132) {
+               ClearScreen(xw);
+               CursorSet(screen, 0, 0, xw->flags);
+               if ((j = (screen->save_modes[DP_DECCOLM] & IN132COLUMNS)
+                    ? 132 : 80) != ((xw->flags & IN132COLUMNS)
+                                    ? 132 : 80) || j != MaxCols(screen))
+                   RequestResize(xw, -1, j, True);
+               bitcpy(&xw->flags,
+                      screen->save_modes[DP_DECCOLM],
+                      IN132COLUMNS);
+           }
+           break;
+       case 4:         /* DECSCLM (slow scroll)        */
+           if (screen->save_modes[DP_DECSCLM] & SMOOTHSCROLL) {
+               screen->jumpscroll = 0;
+               if (screen->scroll_amt)
+                   FlushScroll(xw);
+           } else
+               screen->jumpscroll = 1;
+           bitcpy(&xw->flags, screen->save_modes[DP_DECSCLM], SMOOTHSCROLL);
+           update_jumpscroll();
+           break;
+       case 5:         /* DECSCNM                      */
+           if ((screen->save_modes[DP_DECSCNM] ^ xw->flags) & REVERSE_VIDEO) {
+               bitcpy(&xw->flags, screen->save_modes[DP_DECSCNM], REVERSE_VIDEO);
+               ReverseVideo(xw);
+               /* update_reversevideo done in RevVid */
+           }
+           break;
+       case 6:         /* DECOM                        */
+           bitcpy(&xw->flags, screen->save_modes[DP_DECOM], ORIGIN);
+           CursorSet(screen, 0, 0, xw->flags);
+           break;
+
+       case 7:         /* DECAWM                       */
+           bitcpy(&xw->flags, screen->save_modes[DP_DECAWM], WRAPAROUND);
+           update_autowrap();
+           break;
+       case 8:         /* DECARM                       */
+           /* ignore autorepeat */
+           break;
+       case SET_X10_MOUSE:     /* MIT bogus sequence           */
+           DoRM0(DP_X_X10MSE, screen->send_mouse_pos);
+           break;
+#if OPT_TOOLBAR
+       case 10:                /* rxvt */
+           DoRM(DP_TOOLBAR, resource.toolBar);
+           ShowToolbar(resource.toolBar);
+           break;
+#endif
+#if OPT_BLINK_CURS
+       case 12:                /* att610: Start/stop blinking cursor */
+           if (screen->cursor_blink_res) {
+               DoRM(DP_CRS_BLINK, screen->cursor_blink_esc);
+               SetCursorBlink(screen, screen->cursor_blink);
+           }
+           break;
+#endif
+       case 18:                /* DECPFF: print form feed */
+           DoRM(DP_PRN_FORMFEED, screen->printer_formfeed);
+           break;
+       case 19:                /* DECPEX: print extent */
+           DoRM(DP_PRN_EXTENT, screen->printer_extent);
+           break;
+       case 25:                /* DECTCEM: Show/hide cursor (VT200) */
+           DoRM(DP_CRS_VISIBLE, screen->cursor_set);
+           break;
+       case 40:                /* 132 column mode              */
+           DoRM(DP_X_DECCOLM, screen->c132);
+           update_allow132();
+           break;
+       case 41:                /* curses hack                  */
+           DoRM(DP_X_MORE, screen->curses);
+           update_cursesemul();
+           break;
+       case 44:                /* margin bell                  */
+           if ((DoRM(DP_X_MARGIN, screen->marginbell)) == 0)
+               screen->bellArmed = -1;
+           update_marginbell();
+           break;
+       case 45:                /* reverse wraparound   */
+           bitcpy(&xw->flags, screen->save_modes[DP_X_REVWRAP], REVERSEWRAP);
+           update_reversewrap();
+           break;
+#ifdef ALLOWLOGGING
+       case 46:                /* logging              */
+#ifdef ALLOWLOGFILEONOFF
+           if (screen->save_modes[DP_X_LOGGING])
+               StartLog(xw);
+           else
+               CloseLog(xw);
+#endif /* ALLOWLOGFILEONOFF */
+           /* update_logging done by StartLog and CloseLog */
+           break;
+#endif
+       case 1047:              /* alternate buffer */
+           /* FALLTHRU */
+       case 47:                /* alternate buffer */
+           if (!xw->misc.titeInhibit) {
+               if (screen->save_modes[DP_X_ALTSCRN])
+                   ToAlternate(xw);
+               else
+                   FromAlternate(xw);
+               /* update_altscreen done by ToAlt and FromAlt */
+           } else if (xw->misc.tiXtraScroll) {
+               if (screen->save_modes[DP_X_ALTSCRN]) {
+                   xtermScroll(xw, screen->max_row);
+               }
+           }
+           break;
+       case SET_VT200_MOUSE:   /* mouse bogus sequence         */
+       case SET_VT200_HIGHLIGHT_MOUSE:
+       case SET_BTN_EVENT_MOUSE:
+       case SET_ANY_EVENT_MOUSE:
+           DoRM0(DP_X_MOUSE, screen->send_mouse_pos);
+           break;
+#if OPT_FOCUS_EVENT
+       case SET_FOCUS_EVENT_MOUSE:
+           DoRM(DP_X_FOCUS, screen->send_focus_pos);
+           break;
+#endif
+       case SET_EXT_MODE_MOUSE:
+           DoRM(DP_X_EXT_MOUSE, screen->ext_mode_mouse);
+           break;
+       case 1048:
+           if (!xw->misc.titeInhibit) {
+               CursorRestore(xw);
+           }
+           break;
+#if OPT_READLINE
+       case SET_BUTTON1_MOVE_POINT:
+           SCREEN_FLAG_restore(screen, click1_moves);
+           break;
+       case SET_BUTTON2_MOVE_POINT:
+           SCREEN_FLAG_restore(screen, paste_moves);
+           break;
+       case SET_DBUTTON3_DELETE:
+           SCREEN_FLAG_restore(screen, dclick3_deletes);
+           break;
+       case SET_PASTE_IN_BRACKET:
+           SCREEN_FLAG_restore(screen, paste_brackets);
+           break;
+       case SET_PASTE_QUOTE:
+           SCREEN_FLAG_restore(screen, paste_quotes);
+           break;
+       case SET_PASTE_LITERAL_NL:
+           SCREEN_FLAG_restore(screen, paste_literal_nl);
+           break;
+#endif /* OPT_READLINE */
+       }
+    }
+}
+
+/*
+ * Convert an XTextProperty to a string.
+ *
+ * This frees the data owned by the XTextProperty, and returns in its place the
+ * string, which must be freed by the caller.
+ */
+static char *
+property_to_string(XtermWidget xw, XTextProperty * text)
+{
+    TScreen *screen = TScreenOf(xw);
+    Display *dpy = screen->display;
+    char *result = 0;
+    char **list;
+    int length = 0;
+    int rc;
+
+    TRACE(("property_to_string value %p, encoding %s, format %d, nitems %ld\n",
+          text->value,
+          XGetAtomName(dpy, text->encoding),
+          text->format,
+          text->nitems));
+
+#if OPT_WIDE_CHARS
+    /*
+     * We will use the XmbTextPropertyToTextList call to extract UTF-8 data.
+     * The xtermUtf8ToTextList() call is used to convert UTF-8 explicitly to
+     * ISO-8859-1.
+     */
+    if ((text->format != 8)
+       || IsTitleMode(xw, tmGetUtf8)
+       || (rc = xtermUtf8ToTextList(xw, text, &list, &length)) < 0)
+#endif
+       if ((rc = XmbTextPropertyToTextList(dpy, text, &list, &length)) < 0)
+           rc = XTextPropertyToStringList(text, &list, &length);
+
+    if (rc >= 0) {
+       int n, c, pass;
+       size_t need = 0;
+
+       for (pass = 0; pass < 2; ++pass) {
+           for (n = 0, need = 0; n < length; n++) {
+               char *s = list[n];
+               while ((c = *s++) != '\0') {
+                   if (pass)
+                       result[need] = (char) c;
+                   ++need;
+               }
+           }
+           if (pass)
+               result[need] = '\0';
+           else
+               result = malloc(need + 1);
+           if (result == 0)
+               break;
+       }
+       XFreeStringList(list);
+    }
+    if (text->value != 0)
+       XFree(text->value);
+
+    return result;
+}
+
+static char *
+get_icon_label(XtermWidget xw)
+{
+    XTextProperty text;
+    char *result = 0;
+
+    if (XGetWMIconName(TScreenOf(xw)->display, VShellWindow(xw), &text)) {
+       result = property_to_string(xw, &text);
+    }
+    return result;
+}
+
+static char *
+get_window_label(XtermWidget xw)
+{
+    XTextProperty text;
+    char *result = 0;
+
+    if (XGetWMName(TScreenOf(xw)->display, VShellWindow(xw), &text)) {
+       result = property_to_string(xw, &text);
+    }
+    return result;
+}
+
+/*
+ * Report window label (icon or title) in dtterm protocol
+ * ESC ] code label ESC backslash
+ */
+static void
+report_win_label(XtermWidget xw,
+                int code,
+                char *text)
+{
+    reply.a_type = ANSI_ESC;
+    unparseputc(xw, ANSI_ESC);
+    unparseputc(xw, ']');
+    unparseputc(xw, code);
+
+    if (text != 0) {
+       int copy = IsTitleMode(xw, tmGetBase16);
+       if (copy) {
+           TRACE(("Encoding hex:%s\n", text));
+           text = x_encode_hex(text);
+       }
+       unparseputs(xw, text);
+       if (copy)
+           free(text);
+    }
+
+    unparseputc(xw, ANSI_ESC);
+    unparseputc(xw, '\\');     /* should be ST */
+    unparse_end(xw);
+}
+
+/*
+ * Window operations (from CDE dtterm description, as well as extensions).
+ * See also "allowWindowOps" resource.
+ */
+static void
+window_ops(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    XWindowChanges values;
+    XWindowAttributes win_attrs;
+    unsigned value_mask;
+#if OPT_MAXIMIZE
+    unsigned root_width;
+    unsigned root_height;
+#endif
+
+    TRACE(("window_ops %d\n", param[0]));
+    switch (param[0]) {
+    case ewRestoreWin:         /* Restore (de-iconify) window */
+       if (AllowWindowOps(xw, ewRestoreWin)) {
+           TRACE(("...de-iconify window\n"));
+           XMapWindow(screen->display,
+                      VShellWindow(xw));
+       }
+       break;
+
+    case ewMinimizeWin:        /* Minimize (iconify) window */
+       if (AllowWindowOps(xw, ewMinimizeWin)) {
+           TRACE(("...iconify window\n"));
+           XIconifyWindow(screen->display,
+                          VShellWindow(xw),
+                          DefaultScreen(screen->display));
+       }
+       break;
+
+    case ewSetWinPosition:     /* Move the window to the given position */
+       if (AllowWindowOps(xw, ewSetWinPosition)) {
+           values.x = zero_if_default(1);
+           values.y = zero_if_default(2);
+           TRACE(("...move window to %d,%d\n", values.x, values.y));
+           value_mask = (CWX | CWY);
+           XReconfigureWMWindow(screen->display,
+                                VShellWindow(xw),
+                                DefaultScreen(screen->display),
+                                value_mask,
+                                &values);
+       }
+       break;
+
+    case ewSetWinSizePixels:   /* Resize the window to given size in pixels */
+       if (AllowWindowOps(xw, ewSetWinSizePixels)) {
+           RequestResize(xw, zero_if_default(1), zero_if_default(2), False);
+       }
+       break;
+
+    case ewRaiseWin:           /* Raise the window to the front of the stack */
+       if (AllowWindowOps(xw, ewRaiseWin)) {
+           TRACE(("...raise window\n"));
+           XRaiseWindow(screen->display, VShellWindow(xw));
+       }
+       break;
+
+    case ewLowerWin:           /* Lower the window to the bottom of the stack */
+       if (AllowWindowOps(xw, ewLowerWin)) {
+           TRACE(("...lower window\n"));
+           XLowerWindow(screen->display, VShellWindow(xw));
+       }
+       break;
+
+    case ewRefreshWin:         /* Refresh the window */
+       if (AllowWindowOps(xw, ewRefreshWin)) {
+           TRACE(("...redraw window\n"));
+           Redraw();
+       }
+       break;
+
+    case ewSetWinSizeChars:    /* Resize the text-area, in characters */
+       if (AllowWindowOps(xw, ewSetWinSizeChars)) {
+           RequestResize(xw, zero_if_default(1), zero_if_default(2), True);
+       }
+       break;
+
+#if OPT_MAXIMIZE
+    case ewMaximizeWin:        /* Maximize or restore */
+       if (AllowWindowOps(xw, ewMaximizeWin)) {
+           RequestMaximize(xw, zero_if_default(1));
+       }
+       break;
+#endif
+
+    case ewGetWinState:        /* Report the window's state */
+       if (AllowWindowOps(xw, ewGetWinState)) {
+           TRACE(("...get window attributes\n"));
+           XGetWindowAttributes(screen->display,
+                                VWindow(screen),
+                                &win_attrs);
+           reply.a_type = ANSI_CSI;
+           reply.a_pintro = 0;
+           reply.a_nparam = 1;
+           reply.a_param[0] = (ParmType) ((win_attrs.map_state == IsViewable)
+                                          ? 1
+                                          : 2);
+           reply.a_inters = 0;
+           reply.a_final = 't';
+           unparseseq(xw, &reply);
+       }
+       break;
+
+    case ewGetWinPosition:     /* Report the window's position */
+       if (AllowWindowOps(xw, ewGetWinPosition)) {
+           TRACE(("...get window position\n"));
+           XGetWindowAttributes(screen->display,
+                                WMFrameWindow(xw),
+                                &win_attrs);
+           reply.a_type = ANSI_CSI;
+           reply.a_pintro = 0;
+           reply.a_nparam = 3;
+           reply.a_param[0] = 3;
+           reply.a_param[1] = (ParmType) win_attrs.x;
+           reply.a_param[2] = (ParmType) win_attrs.y;
+           reply.a_inters = 0;
+           reply.a_final = 't';
+           unparseseq(xw, &reply);
+       }
+       break;
+
+    case ewGetWinSizePixels:   /* Report the window's size in pixels */
+       if (AllowWindowOps(xw, ewGetWinSizePixels)) {
+           TRACE(("...get window size in pixels\n"));
+           XGetWindowAttributes(screen->display,
+                                VWindow(screen),
+                                &win_attrs);
+           reply.a_type = ANSI_CSI;
+           reply.a_pintro = 0;
+           reply.a_nparam = 3;
+           reply.a_param[0] = 4;
+           /*FIXME: find if dtterm uses
+            *    win_attrs.height or Height
+            *      win_attrs.width  or Width
+            */
+           reply.a_param[1] = (ParmType) Height(screen);
+           reply.a_param[2] = (ParmType) Width(screen);
+           reply.a_inters = 0;
+           reply.a_final = 't';
+           unparseseq(xw, &reply);
+       }
+       break;
+
+    case ewGetWinSizeChars:    /* Report the text's size in characters */
+       if (AllowWindowOps(xw, ewGetWinSizeChars)) {
+           TRACE(("...get window size in characters\n"));
+           reply.a_type = ANSI_CSI;
+           reply.a_pintro = 0;
+           reply.a_nparam = 3;
+           reply.a_param[0] = 8;
+           reply.a_param[1] = (ParmType) MaxRows(screen);
+           reply.a_param[2] = (ParmType) MaxCols(screen);
+           reply.a_inters = 0;
+           reply.a_final = 't';
+           unparseseq(xw, &reply);
+       }
+       break;
+
+#if OPT_MAXIMIZE
+    case ewGetScreenSizeChars: /* Report the screen's size, in characters */
+       if (AllowWindowOps(xw, ewGetScreenSizeChars)) {
+           TRACE(("...get screen size in characters\n"));
+           if (!QueryMaximize(xw, &root_height, &root_width)) {
+               root_height = 0;
+               root_width = 0;
+           }
+           reply.a_type = ANSI_CSI;
+           reply.a_pintro = 0;
+           reply.a_nparam = 3;
+           reply.a_param[0] = 9;
+           reply.a_param[1] = (ParmType) (root_height
+                                          / (unsigned) FontHeight(screen));
+           reply.a_param[2] = (ParmType) (root_width
+                                          / (unsigned) FontWidth(screen));
+           reply.a_inters = 0;
+           reply.a_final = 't';
+           unparseseq(xw, &reply);
+       }
+       break;
+#endif
+
+    case ewGetIconTitle:       /* Report the icon's label */
+       if (AllowWindowOps(xw, ewGetIconTitle)) {
+           TRACE(("...get icon's label\n"));
+           report_win_label(xw, 'L', get_icon_label(xw));
+       }
+       break;
+
+    case ewGetWinTitle:        /* Report the window's title */
+       if (AllowWindowOps(xw, ewGetWinTitle)) {
+           TRACE(("...get window's label\n"));
+           report_win_label(xw, 'l', get_window_label(xw));
+       }
+       break;
+
+    case ewPushTitle:          /* save the window's title(s) on stack */
+       if (AllowWindowOps(xw, ewPushTitle)) {
+           SaveTitle *last = screen->save_title;
+           SaveTitle *item = TypeCalloc(SaveTitle);
+
+           TRACE(("...push title onto stack\n"));
+           if (item != 0) {
+               switch (zero_if_default(1)) {
+               case 0:
+                   item->iconName = get_icon_label(xw);
+                   item->windowName = get_window_label(xw);
+                   break;
+               case 1:
+                   item->iconName = get_icon_label(xw);
+                   break;
+               case 2:
+                   item->windowName = get_window_label(xw);
+                   break;
+               }
+               item->next = last;
+               if (item->iconName == 0) {
+                   item->iconName = ((last == 0)
+                                     ? get_icon_label(xw)
+                                     : x_strdup(last->iconName));
+               }
+               if (item->windowName == 0) {
+                   item->windowName = ((last == 0)
+                                       ? get_window_label(xw)
+                                       : x_strdup(last->windowName));
+               }
+               screen->save_title = item;
+           }
+       }
+       break;
+
+    case ewPopTitle:           /* restore the window's title(s) from stack */
+       if (AllowWindowOps(xw, ewPopTitle)) {
+           SaveTitle *item = screen->save_title;
+
+           TRACE(("...pop title off stack\n"));
+           if (item != 0) {
+               switch (zero_if_default(1)) {
+               case 0:
+                   ChangeIconName(xw, item->iconName);
+                   ChangeTitle(xw, item->windowName);
+                   break;
+               case 1:
+                   ChangeIconName(xw, item->iconName);
+                   break;
+               case 2:
+                   ChangeTitle(xw, item->windowName);
+                   break;
+               }
+               screen->save_title = item->next;
+               free(item->iconName);
+               free(item->windowName);
+               free(item);
+           }
+       }
+       break;
+
+    default:                   /* DECSLPP (24, 25, 36, 48, 72, 144) */
+       if (AllowWindowOps(xw, ewSetWinLines)) {
+           if (param[0] >= 24)
+               RequestResize(xw, param[0], -1, True);
+       }
+       break;
+    }
+}
+
+/*
+ * set a bit in a word given a pointer to the word and a mask.
+ */
+static void
+bitset(unsigned *p, unsigned mask)
+{
+    *p |= mask;
+}
+
+/*
+ * clear a bit in a word given a pointer to the word and a mask.
+ */
+static void
+bitclr(unsigned *p, unsigned mask)
+{
+    *p &= ~mask;
+}
+
+/*
+ * Copy bits from one word to another, given a mask
+ */
+static void
+bitcpy(unsigned *p, unsigned q, unsigned mask)
+{
+    bitclr(p, mask);
+    bitset(p, q & mask);
+}
+
+void
+unparseputc1(XtermWidget xw, int c)
+{
+    if (c >= 0x80 && c <= 0x9F) {
+       if (!TScreenOf(xw)->control_eight_bits) {
+           unparseputc(xw, A2E(ANSI_ESC));
+           c = A2E(c - 0x40);
+       }
+    }
+    unparseputc(xw, c);
+}
+
+void
+unparseseq(XtermWidget xw, ANSI * ap)
+{
+    int c;
+    int i;
+    int inters;
+
+    unparseputc1(xw, c = ap->a_type);
+    if (c == ANSI_ESC
+       || c == ANSI_DCS
+       || c == ANSI_CSI
+       || c == ANSI_OSC
+       || c == ANSI_PM
+       || c == ANSI_APC
+       || c == ANSI_SS3) {
+       if (ap->a_pintro != 0)
+           unparseputc(xw, ap->a_pintro);
+       for (i = 0; i < ap->a_nparam; ++i) {
+           if (i != 0)
+               unparseputc(xw, ';');
+           unparseputn(xw, (unsigned int) ap->a_param[i]);
+       }
+       if ((inters = ap->a_inters) != 0) {
+           for (i = 3; i >= 0; --i) {
+               c = CharOf(inters >> (8 * i));
+               if (c != 0)
+                   unparseputc(xw, c);
+           }
+       }
+       unparseputc(xw, (char) ap->a_final);
+    }
+    unparse_end(xw);
+}
+
+void
+unparseputn(XtermWidget xw, unsigned int n)
+{
+    unsigned int q;
+
+    q = n / 10;
+    if (q != 0)
+       unparseputn(xw, q);
+    unparseputc(xw, (char) ('0' + (n % 10)));
+}
+
+void
+unparseputs(XtermWidget xw, const char *s)
+{
+    if (s != 0) {
+       while (*s)
+           unparseputc(xw, *s++);
+    }
+}
+
+void
+unparseputc(XtermWidget xw, int c)
+{
+    TScreen *screen = TScreenOf(xw);
+    IChar *buf = screen->unparse_bfr;
+    unsigned len;
+
+    if ((screen->unparse_len + 2) >= sizeof(screen->unparse_bfr))
+       unparse_end(xw);
+
+    len = screen->unparse_len;
+
+#if OPT_TCAP_QUERY
+    /*
+     * If we're returning a termcap string, it has to be translated since
+     * a DCS must not contain any characters except for the normal 7-bit
+     * printable ASCII (counting tab, carriage return, etc).  For now,
+     * just use hexadecimal for the whole thing.
+     */
+    if (screen->tc_query_code >= 0) {
+       char tmp[3];
+       sprintf(tmp, "%02X", c & 0xFF);
+       buf[len++] = CharOf(tmp[0]);
+       buf[len++] = CharOf(tmp[1]);
+    } else
+#endif
+    if ((buf[len++] = (IChar) c) == '\r' && (xw->flags & LINEFEED)) {
+       buf[len++] = '\n';
+    }
+
+    screen->unparse_len = len;
+
+    /* If send/receive mode is reset, we echo characters locally */
+    if ((xw->keyboard.flags & MODE_SRM) == 0) {
+       (void) doparsing(xw, (unsigned) c, &myState);
+    }
+}
+
+void
+unparse_end(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->unparse_len) {
+#ifdef VMS
+       tt_write(screen->unparse_bfr, screen->unparse_len);
+#else /* VMS */
+       writePtyData(screen->respond, screen->unparse_bfr, screen->unparse_len);
+#endif /* VMS */
+       screen->unparse_len = 0;
+    }
+}
+
+void
+ToggleAlternate(XtermWidget xw)
+{
+    if (TScreenOf(xw)->whichBuf)
+       FromAlternate(xw);
+    else
+       ToAlternate(xw);
+}
+
+static void
+ToAlternate(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->whichBuf == 0) {
+       TRACE(("ToAlternate\n"));
+       if (!screen->editBuf_index[1])
+           screen->editBuf_index[1] = allocScrnBuf(xw,
+                                                   (unsigned) MaxRows(screen),
+                                                   (unsigned) MaxCols(screen),
+                                                   &screen->editBuf_data[1]);
+       SwitchBufs(xw, 1);
+       screen->whichBuf = 1;
+#if OPT_SAVE_LINES
+       screen->visbuf = screen->editBuf_index[screen->whichBuf];
+#endif
+       update_altscreen();
+    }
+}
+
+static void
+FromAlternate(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->whichBuf != 0) {
+       TRACE(("FromAlternate\n"));
+       if (screen->scroll_amt)
+           FlushScroll(xw);
+       screen->whichBuf = 0;
+       SwitchBufs(xw, 0);
+#if OPT_SAVE_LINES
+       screen->visbuf = screen->editBuf_index[screen->whichBuf];
+#endif
+       update_altscreen();
+    }
+}
+
+static void
+SwitchBufs(XtermWidget xw, int toBuf)
+{
+    TScreen *screen = TScreenOf(xw);
+    int rows, top;
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    rows = MaxRows(screen);
+    SwitchBufPtrs(screen, toBuf);
+
+    if ((top = INX2ROW(screen, 0)) < rows) {
+       if (screen->scroll_amt) {
+           FlushScroll(xw);
+       }
+       XClearArea(screen->display,
+                  VWindow(screen),
+                  (int) OriginX(screen),
+                  (int) top * FontHeight(screen) + screen->border,
+                  (unsigned) Width(screen),
+                  (unsigned) ((rows - top) * FontHeight(screen)),
+                  False);
+    }
+    ScrnUpdate(xw, 0, 0, rows, MaxCols(screen), False);
+}
+
+Bool
+CheckBufPtrs(TScreen * screen)
+{
+    return (screen->visbuf != 0
+#if OPT_SAVE_LINES
+           && screen->editBuf_index[0] != 0
+#endif
+           && screen->editBuf_index[1] != 0);
+}
+
+/*
+ * Swap buffer line pointers between alternate and regular screens.
+ */
+void
+SwitchBufPtrs(TScreen * screen, int toBuf GCC_UNUSED)
+{
+    if (CheckBufPtrs(screen)) {
+#if OPT_SAVE_LINES
+       screen->visbuf = screen->editBuf_index[toBuf];
+#else
+       size_t len = ScrnPointers(screen, (size_t) MaxRows(screen));
+
+       memcpy(screen->save_ptr, screen->visbuf, len);
+       memcpy(screen->visbuf, screen->editBuf_index[1], len);
+       memcpy(screen->editBuf_index[1], screen->save_ptr, len);
+#endif
+    }
+}
+
+void
+VTRun(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("VTRun ...\n"));
+
+    if (!screen->Vshow) {
+       set_vt_visibility(True);
+    }
+    update_vttekmode();
+    update_vtshow();
+    update_tekshow();
+    set_vthide_sensitivity();
+
+    ScrnAllocBuf(xw);
+
+    screen->cursor_state = OFF;
+    screen->cursor_set = ON;
+#if OPT_BLINK_CURS
+    if (DoStartBlinking(screen))
+       StartBlinking(screen);
+#endif
+
+#if OPT_TEK4014
+    if (Tpushb > Tpushback) {
+       fillPtyData(xw, VTbuffer, (char *) Tpushback, (int) (Tpushb - Tpushback));
+       Tpushb = Tpushback;
+    }
+#endif
+    screen->is_running = True;
+    if (!setjmp(VTend))
+       VTparse(xw);
+    StopBlinking(screen);
+    HideCursor();
+    screen->cursor_set = OFF;
+    TRACE(("... VTRun\n"));
+}
+
+/*ARGSUSED*/
+static void
+VTExpose(Widget w GCC_UNUSED,
+        XEvent * event,
+        Region region GCC_UNUSED)
+{
+#ifdef DEBUG
+    if (debug)
+       fputs("Expose\n", stderr);
+#endif /* DEBUG */
+    if (event->type == Expose)
+       HandleExposure(term, event);
+}
+
+static void
+VTGraphicsOrNoExpose(XEvent * event)
+{
+    TScreen *screen = TScreenOf(term);
+    if (screen->incopy <= 0) {
+       screen->incopy = 1;
+       if (screen->scrolls > 0)
+           screen->scrolls--;
+    }
+    if (event->type == GraphicsExpose)
+       if (HandleExposure(term, event))
+           screen->cursor_state = OFF;
+    if ((event->type == NoExpose)
+       || ((XGraphicsExposeEvent *) event)->count == 0) {
+       if (screen->incopy <= 0 && screen->scrolls > 0)
+           screen->scrolls--;
+       if (screen->scrolls)
+           screen->incopy = -1;
+       else
+           screen->incopy = 0;
+    }
+}
+
+/*ARGSUSED*/
+static void
+VTNonMaskableEvent(Widget w GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XEvent * event,
+                  Boolean * cont GCC_UNUSED)
+{
+    switch (event->type) {
+    case GraphicsExpose:
+    case NoExpose:
+       VTGraphicsOrNoExpose(event);
+       break;
+    }
+}
+
+static void
+VTResize(Widget w)
+{
+    if (XtIsRealized(w)) {
+       XtermWidget xw = (XtermWidget) w;
+       ScreenResize(xw, xw->core.width, xw->core.height, &xw->flags);
+    }
+}
+
+#define okDimension(src,dst) ((src <= 32767) \
+                         && ((dst = (Dimension) src) == src))
+
+static void
+RequestResize(XtermWidget xw, int rows, int cols, Bool text)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned long value;
+    Dimension replyWidth, replyHeight;
+    Dimension askedWidth, askedHeight;
+    XtGeometryResult status;
+    XWindowAttributes attrs;
+
+    TRACE(("RequestResize(rows=%d, cols=%d, text=%d)\n", rows, cols, text));
+
+    if ((int) (askedWidth = (Dimension) cols) < cols
+       || (int) (askedHeight = (Dimension) rows) < rows)
+       return;
+
+    if (askedHeight == 0
+       || askedWidth == 0
+       || xw->misc.limit_resize > 0) {
+       XGetWindowAttributes(XtDisplay(xw),
+                            RootWindowOfScreen(XtScreen(xw)), &attrs);
+    }
+
+    if (text) {
+       if ((value = (unsigned long) rows) != 0) {
+           if (rows < 0)
+               value = (unsigned long) MaxRows(screen);
+           value *= (unsigned long) FontHeight(screen);
+           value += (unsigned long) (2 * screen->border);
+           if (!okDimension(value, askedHeight))
+               return;
+       }
+
+       if ((value = (unsigned long) cols) != 0) {
+           if (cols < 0)
+               value = (unsigned long) MaxCols(screen);
+           value *= (unsigned long) FontWidth(screen);
+           value += (unsigned long) ((2 * screen->border)
+                                     + ScrollbarWidth(screen));
+           if (!okDimension(value, askedWidth))
+               return;
+       }
+
+    } else {
+       if (rows < 0)
+           askedHeight = FullHeight(screen);
+       if (cols < 0)
+           askedWidth = FullWidth(screen);
+    }
+
+    if (rows == 0)
+       askedHeight = (Dimension) attrs.height;
+    if (cols == 0)
+       askedWidth = (Dimension) attrs.width;
+
+    if (xw->misc.limit_resize > 0) {
+       Dimension high = (Dimension) (xw->misc.limit_resize * attrs.height);
+       Dimension wide = (Dimension) (xw->misc.limit_resize * attrs.width);
+       if ((int) high < attrs.height)
+           high = (Dimension) attrs.height;
+       if (askedHeight > high)
+           askedHeight = high;
+       if ((int) wide < attrs.width)
+           wide = (Dimension) attrs.width;
+       if (askedWidth > wide)
+           askedWidth = wide;
+    }
+#ifndef nothack
+    getXtermSizeHints(xw);
+#endif
+
+    TRACE(("...requesting resize %dx%d\n", askedHeight, askedWidth));
+    status = REQ_RESIZE((Widget) xw,
+                       askedWidth, askedHeight,
+                       &replyWidth, &replyHeight);
+
+    if (status == XtGeometryYes ||
+       status == XtGeometryDone) {
+       ScreenResize(xw, replyWidth, replyHeight, &xw->flags);
+    }
+#ifndef nothack
+    /*
+     * XtMakeResizeRequest() has the undesirable side-effect of clearing
+     * the window manager's hints, even on a failed request.  This would
+     * presumably be fixed if the shell did its own work.
+     */
+    if (xw->hints.flags
+       && replyHeight
+       && replyWidth) {
+       xw->hints.height = replyHeight;
+       xw->hints.width = replyWidth;
+
+       TRACE(("%s@%d -- ", __FILE__, __LINE__));
+       TRACE_HINTS(&xw->hints);
+       XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints);
+       TRACE(("%s@%d -- ", __FILE__, __LINE__));
+       TRACE_WM_HINTS(xw);
+    }
+#endif
+
+    XSync(screen->display, False);     /* synchronize */
+    if (XtAppPending(app_con))
+       xevents();
+
+    TRACE(("...RequestResize done\n"));
+}
+
+static String xterm_trans =
+"<ClientMessage>WM_PROTOCOLS: DeleteWindow()\n\
+     <MappingNotify>: KeyboardMapping()\n";
+
+int
+VTInit(XtermWidget xw)
+{
+    Widget vtparent = SHELL_OF(xw);
+
+    TRACE(("VTInit {{\n"));
+
+    XtRealizeWidget(vtparent);
+    XtOverrideTranslations(vtparent, XtParseTranslationTable(xterm_trans));
+    (void) XSetWMProtocols(XtDisplay(vtparent), XtWindow(vtparent),
+                          &wm_delete_window, 1);
+    TRACE_TRANS("shell", vtparent);
+    TRACE_TRANS("vt100", (Widget) (xw));
+
+    ScrnAllocBuf(xw);
+
+    TRACE(("...}} VTInit\n"));
+    return (1);
+}
+
+static void
+VTClassInit(void)
+{
+    XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity,
+                  (XtConvertArgList) NULL, (Cardinal) 0);
+}
+
+#if OPT_COLOR_RES
+/*
+ * Override the use of XtDefaultForeground/XtDefaultBackground to make some
+ * colors, such as cursor color, use the actual foreground/background value
+ * if there is no explicit resource value used.
+ */
+static Pixel
+fill_Tres(XtermWidget target, XtermWidget source, int offset)
+{
+    char *name;
+    ScrnColors temp;
+
+    TScreenOf(target)->Tcolors[offset] = TScreenOf(source)->Tcolors[offset];
+    TScreenOf(target)->Tcolors[offset].mode = False;
+
+    if ((name = x_strtrim(TScreenOf(target)->Tcolors[offset].resource)) != 0)
+       TScreenOf(target)->Tcolors[offset].resource = name;
+
+    if (name == 0) {
+       TScreenOf(target)->Tcolors[offset].value = target->dft_foreground;
+    } else if (isDefaultForeground(name)) {
+       TScreenOf(target)->Tcolors[offset].value =
+           ((offset == TEXT_FG || offset == TEXT_BG)
+            ? target->dft_foreground
+            : TScreenOf(target)->Tcolors[TEXT_FG].value);
+    } else if (isDefaultBackground(name)) {
+       TScreenOf(target)->Tcolors[offset].value =
+           ((offset == TEXT_FG || offset == TEXT_BG)
+            ? target->dft_background
+            : TScreenOf(target)->Tcolors[TEXT_BG].value);
+    } else {
+       memset(&temp, 0, sizeof(temp));
+       if (AllocateTermColor(target, &temp, offset, name, True)) {
+           if (COLOR_DEFINED(&(temp), offset))
+               free(temp.names[offset]);
+           TScreenOf(target)->Tcolors[offset].value = temp.colors[offset];
+       }
+    }
+    return TScreenOf(target)->Tcolors[offset].value;
+}
+#else
+#define fill_Tres(target, source, offset) \
+       TScreenOf(target)->Tcolors[offset] = TScreenOf(source)->Tcolors[offset]
+#endif
+
+#if OPT_WIDE_CHARS
+static void
+VTInitialize_locale(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Bool is_utf8 = xtermEnvUTF8();
+
+    TRACE(("VTInitialize_locale\n"));
+    TRACE(("... request screen.utf8_mode = %d\n", screen->utf8_mode));
+
+    if (screen->utf8_mode < 0)
+       screen->utf8_mode = uFalse;
+
+    if (screen->utf8_mode > 3)
+       screen->utf8_mode = uDefault;
+
+    screen->latin9_mode = 0;
+    screen->unicode_font = 0;
+#if OPT_LUIT_PROG
+    xw->misc.callfilter = 0;
+    xw->misc.use_encoding = 0;
+
+    TRACE(("... setup for luit:\n"));
+    TRACE(("... request misc.locale_str = \"%s\"\n", xw->misc.locale_str));
+
+    if (screen->utf8_mode == uFalse) {
+       TRACE(("... command-line +u8 overrides\n"));
+    } else
+#if OPT_MINI_LUIT
+    if (x_strcasecmp(xw->misc.locale_str, "CHECKFONT") == 0) {
+       int fl = (xw->misc.default_font.f_n
+                 ? (int) strlen(xw->misc.default_font.f_n)
+                 : 0);
+       if (fl > 11
+           && x_strcasecmp(xw->misc.default_font.f_n + fl - 11,
+                           "-ISO10646-1") == 0) {
+           screen->unicode_font = 1;
+           /* unicode font, use True */
+#ifdef HAVE_LANGINFO_CODESET
+           if (!strcmp(xtermEnvEncoding(), "ANSI_X3.4-1968")
+               || !strcmp(xtermEnvEncoding(), "ISO-8859-1")) {
+               if (screen->utf8_mode == uDefault)
+                   screen->utf8_mode = uFalse;
+           } else if (!strcmp(xtermEnvEncoding(), "ISO-8859-15")) {
+               if (screen->utf8_mode == uDefault)
+                   screen->utf8_mode = uFalse;
+               screen->latin9_mode = 1;
+           } else {
+               xw->misc.callfilter = (Boolean) (is_utf8 ? 0 : 1);
+               screen->utf8_mode = uAlways;
+           }
+#else
+           xw->misc.callfilter = is_utf8 ? 0 : 1;
+           screen->utf8_mode = uAlways;
+#endif
+       } else {
+           /* other encoding, use False */
+           if (screen->utf8_mode == uDefault) {
+               screen->utf8_mode = is_utf8 ? uAlways : uFalse;
+           }
+       }
+    } else
+#endif /* OPT_MINI_LUIT */
+       if (x_strcasecmp(xw->misc.locale_str, "TRUE") == 0 ||
+           x_strcasecmp(xw->misc.locale_str, "ON") == 0 ||
+           x_strcasecmp(xw->misc.locale_str, "YES") == 0 ||
+           x_strcasecmp(xw->misc.locale_str, "AUTO") == 0 ||
+           strcmp(xw->misc.locale_str, "1") == 0) {
+       /* when true ... fully obeying LC_CTYPE locale */
+       xw->misc.callfilter = (Boolean) (is_utf8 ? 0 : 1);
+       screen->utf8_mode = uAlways;
+    } else if (x_strcasecmp(xw->misc.locale_str, "FALSE") == 0 ||
+              x_strcasecmp(xw->misc.locale_str, "OFF") == 0 ||
+              x_strcasecmp(xw->misc.locale_str, "NO") == 0 ||
+              strcmp(xw->misc.locale_str, "0") == 0) {
+       /* when false ... original value of utf8_mode is effective */
+       if (screen->utf8_mode == uDefault) {
+           screen->utf8_mode = is_utf8 ? uAlways : uFalse;
+       }
+    } else if (x_strcasecmp(xw->misc.locale_str, "MEDIUM") == 0 ||
+              x_strcasecmp(xw->misc.locale_str, "SEMIAUTO") == 0) {
+       /* when medium ... obeying locale only for UTF-8 and Asian */
+       if (is_utf8) {
+           screen->utf8_mode = uAlways;
+       } else if (
+#ifdef MB_CUR_MAX
+                     MB_CUR_MAX > 1 ||
+#else
+                     !strncmp(xtermEnvLocale(), "ja", (size_t) 2) ||
+                     !strncmp(xtermEnvLocale(), "ko", (size_t) 2) ||
+                     !strncmp(xtermEnvLocale(), "zh", (size_t) 2) ||
+#endif
+                     !strncmp(xtermEnvLocale(), "th", (size_t) 2) ||
+                     !strncmp(xtermEnvLocale(), "vi", (size_t) 2)) {
+           xw->misc.callfilter = 1;
+           screen->utf8_mode = uAlways;
+       } else {
+           screen->utf8_mode = uFalse;
+       }
+    } else if (x_strcasecmp(xw->misc.locale_str, "UTF-8") == 0 ||
+              x_strcasecmp(xw->misc.locale_str, "UTF8") == 0) {
+       /* when UTF-8 ... UTF-8 mode */
+       screen->utf8_mode = uAlways;
+    } else {
+       /* other words are regarded as encoding name passed to luit */
+       xw->misc.callfilter = 1;
+       screen->utf8_mode = uAlways;
+       xw->misc.use_encoding = 1;
+    }
+    TRACE(("... updated misc.callfilter = %s\n", BtoS(xw->misc.callfilter)));
+    TRACE(("... updated misc.use_encoding = %s\n", BtoS(xw->misc.use_encoding)));
+#else
+    if (screen->utf8_mode == uDefault) {
+       screen->utf8_mode = is_utf8 ? uAlways : uFalse;
+    }
+#endif /* OPT_LUIT_PROG */
+
+    screen->utf8_inparse = (Boolean) (screen->utf8_mode != uFalse);
+
+    TRACE(("... updated screen.utf8_mode = %d\n", screen->utf8_mode));
+    TRACE(("...VTInitialize_locale done\n"));
+}
+#endif
+
+static void
+ParseOnClicks(XtermWidget wnew, XtermWidget wreq, Cardinal item)
+{
+    /* *INDENT-OFF* */
+    static struct {
+       const char *    name;
+       SelectUnit      code;
+    } table[] = {
+       { "char",       Select_CHAR },
+       { "word",       Select_WORD },
+       { "line",       Select_LINE },
+       { "group",      Select_GROUP },
+       { "page",       Select_PAGE },
+       { "all",        Select_ALL },
+#if OPT_SELECT_REGEX
+       { "regex",      Select_REGEX },
+#endif
+    };
+    /* *INDENT-ON* */
+
+    String res = TScreenOf(wreq)->onClick[item];
+    String next = x_skip_nonblanks(res);
+    Cardinal n;
+
+    TScreenOf(wnew)->selectMap[item] = NSELECTUNITS;
+    for (n = 0; n < XtNumber(table); ++n) {
+       if (!x_strncasecmp(table[n].name, res, (unsigned) (next - res))) {
+           TScreenOf(wnew)->selectMap[item] = table[n].code;
+#if OPT_SELECT_REGEX
+           if (table[n].code == Select_REGEX) {
+               TScreenOf(wnew)->selectExpr[item] = x_strtrim(next);
+               TRACE(("Parsed regex \"%s\"\n", TScreenOf(wnew)->selectExpr[item]));
+           }
+#endif
+           break;
+       }
+    }
+}
+
+/*
+ * Parse a comma-separated list, returning a string which the caller must
+ * free, and updating the source pointer.
+ */
+static char *
+ParseList(const char **source)
+{
+    const char *base = *source;
+    const char *next;
+    size_t size;
+    char *value = 0;
+    char *result;
+
+    /* ignore empty values */
+    while (*base == ',')
+       ++base;
+    if (*base != '\0') {
+       next = base;
+       while (*next != '\0' && *next != ',')
+           ++next;
+       size = (size_t) (1 + next - base);
+       value = malloc(size);
+       if (value != 0) {
+           memcpy(value, base, size);
+           value[size - 1] = '\0';
+       }
+       *source = next;
+    } else {
+       *source = base;
+    }
+    result = x_strtrim(value);
+    free(value);
+    return result;
+}
+
+static void
+set_flags_from_list(char *target,
+                   const char *source,
+                   FlagList * list,
+                   Cardinal limit)
+{
+    Cardinal n;
+    int value = -1;
+
+    while (*source != '\0') {
+       char *next = ParseList(&source);
+       Boolean found = False;
+
+       if (next == 0)
+           break;
+       if (isdigit(CharOf(*next))) {
+           char *temp;
+
+           value = (int) strtol(next, &temp, 0);
+           if (!IsEmpty(temp)) {
+               fprintf(stderr, "Expected a number: %s\n", next);
+           } else {
+               for (n = 0; n < limit; ++n) {
+                   if (list[n].code == value) {
+                       target[value] = 1;
+                       found = True;
+                       break;
+                   }
+               }
+           }
+       } else {
+           for (n = 0; n < limit; ++n) {
+               if (!x_strcasecmp(next, list[n].name)) {
+                   value = list[n].code;
+                   target[value] = 1;
+                   found = True;
+                   break;
+               }
+           }
+       }
+       if (!found) {
+           fprintf(stderr, "Unrecognized keyword: %s\n", next);
+       } else {
+           TRACE(("...found %s (%d)\n", next, value));
+       }
+       free(next);
+    }
+}
+
+/*
+ * Extend a (normally) boolean resource value by checking for additional values
+ * which will be mapped into true/false.
+ */
+#if OPT_RENDERFONT
+static int
+extendedBoolean(const char *value, FlagList * table, Cardinal limit)
+{
+    int result = -1;
+    long check;
+    char *next;
+    Cardinal n;
+
+    if ((x_strcasecmp(value, "true") == 0)
+       || (x_strcasecmp(value, "yes") == 0)
+       || (x_strcasecmp(value, "on") == 0)) {
+       result = True;
+    } else if ((x_strcasecmp(value, "false") == 0)
+              || (x_strcasecmp(value, "no") == 0)
+              || (x_strcasecmp(value, "off") == 0)) {
+       result = False;
+    } else if ((check = strtol(value, &next, 0)) >= 0 && *next == '\0') {
+       if (check >= (long) limit)
+           check = True;
+       result = (int) check;
+    } else {
+       for (n = 0; n < limit; ++n) {
+           if (x_strcasecmp(value, table[n].name) == 0) {
+               result = table[n].code;
+               break;
+           }
+       }
+    }
+
+    if (result < 0) {
+       fprintf(stderr, "Unrecognized keyword: %s\n", value);
+       result = False;
+    }
+
+    return result;
+}
+#endif /* OPT_RENDERFONT */
+
+/* ARGSUSED */
+static void
+VTInitialize(Widget wrequest,
+            Widget new_arg,
+            ArgList args GCC_UNUSED,
+            Cardinal *num_args GCC_UNUSED)
+{
+#define Kolor(name) TScreenOf(wnew)->name.resource
+#define TxtFg(name) !x_strcasecmp(Kolor(Tcolors[TEXT_FG]), Kolor(name))
+#define TxtBg(name) !x_strcasecmp(Kolor(Tcolors[TEXT_BG]), Kolor(name))
+#define DftFg(name) isDefaultForeground(Kolor(name))
+#define DftBg(name) isDefaultBackground(Kolor(name))
+
+#define DATA(name) { #name, ec##name }
+    static FlagList tblColorOps[] =
+    {
+       DATA(SetColor)
+       ,DATA(GetColor)
+       ,DATA(GetAnsiColor)
+    };
+#undef DATA
+
+#define DATA(name) { #name, ef##name }
+    static FlagList tblFontOps[] =
+    {
+       DATA(SetFont)
+       ,DATA(GetFont)
+    };
+#undef DATA
+
+#define DATA(name) { #name, et##name }
+    static FlagList tblTcapOps[] =
+    {
+       DATA(SetTcap)
+       ,DATA(GetTcap)
+    };
+#undef DATA
+
+#define DATA(name) { #name, ew##name }
+    static FlagList tblWindowOps[] =
+    {
+       DATA(RestoreWin)
+       ,DATA(MinimizeWin)
+       ,DATA(SetWinPosition)
+       ,DATA(SetWinSizePixels)
+       ,DATA(RaiseWin)
+       ,DATA(LowerWin)
+       ,DATA(RefreshWin)
+       ,DATA(SetWinSizeChars)
+#if OPT_MAXIMIZE
+       ,DATA(MaximizeWin)
+#endif
+       ,DATA(GetWinState)
+       ,DATA(GetWinPosition)
+       ,DATA(GetWinSizePixels)
+       ,DATA(GetWinSizeChars)
+#if OPT_MAXIMIZE
+       ,DATA(GetScreenSizeChars)
+#endif
+       ,DATA(GetIconTitle)
+       ,DATA(GetWinTitle)
+       ,DATA(PushTitle)
+       ,DATA(PopTitle)
+       ,DATA(SetWinLines)
+       ,DATA(SetXprop)
+       ,DATA(GetSelection)
+       ,DATA(SetSelection)
+    };
+#undef DATA
+
+#if OPT_RENDERFONT
+#define DATA(name) { #name, er##name }
+    static FlagList tblRenderFont[] =
+    {
+       DATA(Default)
+    };
+#undef DATA
+#endif
+
+    XtermWidget request = (XtermWidget) wrequest;
+    XtermWidget wnew = (XtermWidget) new_arg;
+    Widget my_parent = SHELL_OF(wnew);
+    int i;
+    const char *s;
+
+#if OPT_ISO_COLORS
+    Bool color_ok;
+#endif
+
+#if OPT_COLOR_RES2
+    static XtResource fake_resources[] =
+    {
+#if OPT_256_COLORS
+# include <256colres.h>
+#elif OPT_88_COLORS
+# include <88colres.h>
+#endif
+    };
+#endif /* OPT_COLOR_RES2 */
+
+    TRACE(("VTInitialize wnew %p, %d / %d resources\n",
+          (void *) wnew, XtNumber(xterm_resources), MAXRESOURCES));
+    assert(XtNumber(xterm_resources) < MAXRESOURCES);
+
+    /* Zero out the entire "screen" component of "wnew" widget, then do
+     * field-by-field assignment of "screen" fields that are named in the
+     * resource list.
+     */
+    memset(TScreenOf(wnew), 0, sizeof(wnew->screen));
+
+    /* DESCO Sys#67660
+     * Zero out the entire "keyboard" component of "wnew" widget.
+     */
+    memset(&wnew->keyboard, 0, sizeof(wnew->keyboard));
+
+    /* dummy values so that we don't try to Realize the parent shell with height
+     * or width of 0, which is illegal in X.  The real size is computed in the
+     * xtermWidget's Realize proc, but the shell's Realize proc is called first,
+     * and must see a valid size.
+     */
+    wnew->core.height = wnew->core.width = 1;
+
+    /*
+     * The definition of -rv now is that it changes the definition of
+     * XtDefaultForeground and XtDefaultBackground.  So, we no longer
+     * need to do anything special.
+     */
+    TScreenOf(wnew)->display = wnew->core.screen->display;
+
+    /*
+     * We use the default foreground/background colors to compare/check if a
+     * color-resource has been set.
+     */
+#define MyBlackPixel(dpy) BlackPixel(dpy,DefaultScreen(dpy))
+#define MyWhitePixel(dpy) WhitePixel(dpy,DefaultScreen(dpy))
+
+    if (request->misc.re_verse) {
+       wnew->dft_foreground = MyWhitePixel(TScreenOf(wnew)->display);
+       wnew->dft_background = MyBlackPixel(TScreenOf(wnew)->display);
+    } else {
+       wnew->dft_foreground = MyBlackPixel(TScreenOf(wnew)->display);
+       wnew->dft_background = MyWhitePixel(TScreenOf(wnew)->display);
+    }
+    init_Tres(TEXT_FG);
+    init_Tres(TEXT_BG);
+
+    TRACE(("Color resource initialization:\n"));
+    TRACE(("   Default foreground %#lx\n", wnew->dft_foreground));
+    TRACE(("   Default background %#lx\n", wnew->dft_background));
+    TRACE(("   Screen foreground  %#lx\n", T_COLOR(TScreenOf(wnew), TEXT_FG)));
+    TRACE(("   Screen background  %#lx\n", T_COLOR(TScreenOf(wnew), TEXT_BG)));
+
+    TScreenOf(wnew)->mouse_button = -1;
+    TScreenOf(wnew)->mouse_row = -1;
+    TScreenOf(wnew)->mouse_col = -1;
+
+#if OPT_BOX_CHARS
+    init_Bres(screen.force_box_chars);
+    init_Bres(screen.force_packed);
+    init_Bres(screen.force_all_chars);
+#endif
+    init_Bres(screen.free_bold_box);
+
+    init_Bres(screen.c132);
+    init_Bres(screen.curses);
+    init_Bres(screen.hp_ll_bc);
+#if OPT_XMC_GLITCH
+    init_Ires(screen.xmc_glitch);
+    init_Ires(screen.xmc_attributes);
+    init_Bres(screen.xmc_inline);
+    init_Bres(screen.move_sgr_ok);
+#endif
+#if OPT_BLINK_CURS
+    init_Bres(screen.cursor_blink);
+    init_Ires(screen.blink_on);
+    init_Ires(screen.blink_off);
+    TScreenOf(wnew)->cursor_blink_res = TScreenOf(wnew)->cursor_blink;
+#endif
+    init_Bres(screen.cursor_underline);
+#if OPT_BLINK_TEXT
+    init_Ires(screen.blink_as_bold);
+#endif
+    init_Ires(screen.border);
+    init_Bres(screen.jumpscroll);
+    init_Bres(screen.fastscroll);
+    init_Bres(screen.old_fkeys);
+    init_Bres(screen.delete_is_del);
+    wnew->keyboard.type = TScreenOf(wnew)->old_fkeys
+       ? keyboardIsLegacy
+       : keyboardIsDefault;
+#ifdef ALLOWLOGGING
+    init_Bres(misc.logInhibit);
+    init_Bres(misc.log_on);
+    init_Sres(screen.logfile);
+#endif
+    init_Bres(screen.bellIsUrgent);
+    init_Bres(screen.bellOnReset);
+    init_Bres(screen.marginbell);
+    init_Bres(screen.multiscroll);
+    init_Ires(screen.nmarginbell);
+    init_Ires(screen.savelines);
+    init_Ires(screen.scrollBarBorder);
+    init_Ires(screen.scrolllines);
+    init_Bres(screen.scrollttyoutput);
+    init_Bres(screen.scrollkey);
+
+    init_Bres(misc.autoWrap);
+    init_Bres(misc.login_shell);
+    init_Bres(misc.reverseWrap);
+    init_Bres(misc.scrollbar);
+    init_Sres(misc.geo_metry);
+    init_Sres(misc.T_geometry);
+
+    init_Sres(screen.term_id);
+    for (s = TScreenOf(request)->term_id; *s; s++) {
+       if (!isalpha(CharOf(*s)))
+           break;
+    }
+    TScreenOf(wnew)->terminal_id = atoi(s);
+    if (TScreenOf(wnew)->terminal_id < MIN_DECID)
+       TScreenOf(wnew)->terminal_id = MIN_DECID;
+    if (TScreenOf(wnew)->terminal_id > MAX_DECID)
+       TScreenOf(wnew)->terminal_id = MAX_DECID;
+    TRACE(("term_id '%s' -> terminal_id %d\n",
+          TScreenOf(wnew)->term_id,
+          TScreenOf(wnew)->terminal_id));
+
+    TScreenOf(wnew)->vtXX_level = (TScreenOf(wnew)->terminal_id / 100);
+
+    init_Ires(screen.title_modes);
+    init_Bres(screen.visualbell);
+    init_Ires(screen.visualBellDelay);
+    init_Bres(screen.poponbell);
+    init_Ires(misc.limit_resize);
+
+#if OPT_NUM_LOCK
+    init_Bres(misc.real_NumLock);
+    init_Bres(misc.alwaysUseMods);
+    wnew->misc.num_lock = 0;
+    wnew->misc.alt_mods = 0;
+    wnew->misc.meta_mods = 0;
+    wnew->misc.other_mods = 0;
+#endif
+
+#if OPT_INPUT_METHOD
+    init_Bres(misc.open_im);
+    init_Ires(misc.retry_im);
+    init_Sres(misc.f_x);
+    init_Sres(misc.input_method);
+    init_Sres(misc.preedit_type);
+#endif
+
+#if OPT_SHIFT_FONTS
+    init_Bres(misc.shift_fonts);
+#endif
+#if OPT_SUNPC_KBD
+    init_Ires(misc.ctrl_fkeys);
+#endif
+#if OPT_TEK4014
+    TEK4014_SHOWN(wnew) = False;       /* not a resource... */
+    init_Bres(misc.tekInhibit);
+    init_Bres(misc.tekSmall);
+    init_Bres(misc.TekEmu);
+#endif
+#if OPT_TCAP_QUERY
+    TScreenOf(wnew)->tc_query_code = -1;
+#endif
+    wnew->misc.re_verse0 = request->misc.re_verse;
+    init_Bres(misc.re_verse);
+    init_Ires(screen.multiClickTime);
+    init_Ires(screen.bellSuppressTime);
+    init_Sres(screen.charClass);
+
+    init_Bres(screen.always_highlight);
+    init_Bres(screen.brokenSelections);
+    init_Bres(screen.cutNewline);
+    init_Bres(screen.cutToBeginningOfLine);
+    init_Bres(screen.highlight_selection);
+    init_Bres(screen.show_wrap_marks);
+    init_Bres(screen.i18nSelections);
+    init_Bres(screen.keepSelection);
+    init_Bres(screen.selectToClipboard);
+    init_Bres(screen.trim_selection);
+
+    TScreenOf(wnew)->pointer_cursor = TScreenOf(request)->pointer_cursor;
+    init_Ires(screen.pointer_mode);
+
+    init_Sres(screen.answer_back);
+
+    init_Sres(screen.printer_command);
+    init_Bres(screen.printer_autoclose);
+    init_Bres(screen.printer_extent);
+    init_Bres(screen.printer_formfeed);
+    init_Bres(screen.printer_newline);
+    init_Ires(screen.printer_controlmode);
+#if OPT_PRINT_COLORS
+    init_Ires(screen.print_attributes);
+#endif
+
+    init_Sres(screen.keyboard_dialect);
+
+    init_Bres(screen.input_eight_bits);
+    init_Bres(screen.output_eight_bits);
+    init_Bres(screen.control_eight_bits);
+    init_Bres(screen.backarrow_key);
+    init_Bres(screen.alt_is_not_meta);
+    init_Bres(screen.alt_sends_esc);
+    init_Bres(screen.meta_sends_esc);
+
+    init_Bres(screen.allowSendEvent0);
+    init_Bres(screen.allowColorOp0);
+    init_Bres(screen.allowFontOp0);
+    init_Bres(screen.allowTcapOp0);
+    init_Bres(screen.allowTitleOp0);
+    init_Bres(screen.allowWindowOp0);
+
+#if OPT_SCROLL_LOCK
+    init_Bres(screen.allowScrollLock0);
+#endif
+
+    init_Sres(screen.disallowedColorOps);
+
+    set_flags_from_list(TScreenOf(wnew)->disallow_color_ops,
+                       TScreenOf(wnew)->disallowedColorOps,
+                       tblColorOps,
+                       ecLAST);
+
+    init_Sres(screen.disallowedFontOps);
+
+    set_flags_from_list(TScreenOf(wnew)->disallow_font_ops,
+                       TScreenOf(wnew)->disallowedFontOps,
+                       tblFontOps,
+                       efLAST);
+
+    init_Sres(screen.disallowedTcapOps);
+
+    set_flags_from_list(TScreenOf(wnew)->disallow_tcap_ops,
+                       TScreenOf(wnew)->disallowedTcapOps,
+                       tblTcapOps,
+                       etLAST);
+
+    init_Sres(screen.disallowedWinOps);
+
+    set_flags_from_list(TScreenOf(wnew)->disallow_win_ops,
+                       TScreenOf(wnew)->disallowedWinOps,
+                       tblWindowOps,
+                       ewLAST);
+
+    init_Sres(screen.default_string);
+    init_Sres(screen.eightbit_select_types);
+#if OPT_WIDE_CHARS
+    init_Sres(screen.utf8_select_types);
+#endif
+
+    /* make a copy so that editres cannot change the resource after startup */
+    TScreenOf(wnew)->allowSendEvents = TScreenOf(wnew)->allowSendEvent0;
+    TScreenOf(wnew)->allowColorOps = TScreenOf(wnew)->allowColorOp0;
+    TScreenOf(wnew)->allowFontOps = TScreenOf(wnew)->allowFontOp0;
+    TScreenOf(wnew)->allowTcapOps = TScreenOf(wnew)->allowTcapOp0;
+    TScreenOf(wnew)->allowTitleOps = TScreenOf(wnew)->allowTitleOp0;
+    TScreenOf(wnew)->allowWindowOps = TScreenOf(wnew)->allowWindowOp0;
+
+#if OPT_SCROLL_LOCK
+    TScreenOf(wnew)->allowScrollLock = TScreenOf(wnew)->allowScrollLock0;
+#endif
+
+    init_Bres(screen.quiet_grab);
+
+#ifndef NO_ACTIVE_ICON
+    init_Sres(screen.icon_fontname);
+    TScreenOf(wnew)->fnt_icon.fs = XLoadQueryFont(TScreenOf(wnew)->display,
+                                                 TScreenOf(wnew)->icon_fontname);
+    TRACE(("iconFont '%s' %sloaded successfully\n",
+          TScreenOf(wnew)->icon_fontname,
+          TScreenOf(wnew)->fnt_icon.fs ? "" : "NOT "));
+    init_Bres(misc.active_icon);
+    init_Ires(misc.icon_border_width);
+    wnew->misc.icon_border_pixel = request->misc.icon_border_pixel;
+#endif /* NO_ACTIVE_ICON */
+
+    init_Bres(misc.signalInhibit);
+    init_Bres(misc.titeInhibit);
+    init_Bres(misc.tiXtraScroll);
+    init_Bres(misc.dynamicColors);
+    for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) {
+       init_Sres2(screen.MenuFontName, i);
+    }
+    init_Ires(misc.fontWarnings);
+#define DefaultFontNames TScreenOf(wnew)->menu_font_names[fontMenu_default]
+    init_Sres(misc.default_font.f_n);
+    init_Sres(misc.default_font.f_b);
+    DefaultFontNames[fNorm] = x_strdup(wnew->misc.default_font.f_n);
+    DefaultFontNames[fBold] = x_strdup(wnew->misc.default_font.f_b);
+#if OPT_WIDE_CHARS
+    init_Sres(misc.default_font.f_w);
+    init_Sres(misc.default_font.f_wb);
+    DefaultFontNames[fWide] = x_strdup(wnew->misc.default_font.f_w);
+    DefaultFontNames[fWBold] = x_strdup(wnew->misc.default_font.f_wb);
+#endif
+    TScreenOf(wnew)->MenuFontName(fontMenu_fontescape) = NULL;
+    TScreenOf(wnew)->MenuFontName(fontMenu_fontsel) = NULL;
+
+    TScreenOf(wnew)->menu_font_number = fontMenu_default;
+    init_Sres(screen.initial_font);
+    if (TScreenOf(wnew)->initial_font != 0) {
+       int result = xtermGetFont(TScreenOf(wnew)->initial_font);
+       if (result >= 0)
+           TScreenOf(wnew)->menu_font_number = result;
+    }
+#if OPT_BROKEN_OSC
+    init_Bres(screen.brokenLinuxOSC);
+#endif
+
+#if OPT_BROKEN_ST
+    init_Bres(screen.brokenStringTerm);
+#endif
+
+#if OPT_C1_PRINT
+    init_Bres(screen.c1_printable);
+#endif
+
+#if OPT_CLIP_BOLD
+    init_Bres(screen.use_clipping);
+#endif
+
+#if OPT_DEC_CHRSET
+    init_Bres(screen.font_doublesize);
+    init_Ires(screen.cache_doublesize);
+    if (TScreenOf(wnew)->cache_doublesize > NUM_CHRSET)
+       TScreenOf(wnew)->cache_doublesize = NUM_CHRSET;
+    if (TScreenOf(wnew)->cache_doublesize == 0)
+       TScreenOf(wnew)->font_doublesize = False;
+    TRACE(("Doublesize%s enabled, up to %d fonts\n",
+          TScreenOf(wnew)->font_doublesize ? "" : " not",
+          TScreenOf(wnew)->cache_doublesize));
+#endif
+
+#if OPT_ISO_COLORS
+    init_Ires(screen.veryBoldColors);
+    init_Bres(screen.boldColors);
+    init_Bres(screen.colorAttrMode);
+    init_Bres(screen.colorBDMode);
+    init_Bres(screen.colorBLMode);
+    init_Bres(screen.colorMode);
+    init_Bres(screen.colorULMode);
+    init_Bres(screen.italicULMode);
+    init_Bres(screen.colorRVMode);
+
+#if OPT_COLOR_RES2
+    TRACE(("...will fake resources for color%d to color%d\n",
+          MIN_ANSI_COLORS,
+          NUM_ANSI_COLORS - 1));
+#endif
+    for (i = 0, color_ok = False; i < MAXCOLORS; i++) {
+
+#if OPT_COLOR_RES2
+       /*
+        * Xt has a hardcoded limit on the maximum number of resources that can
+        * be used in a widget.  If we configure both luit (which implies
+        * wide-characters) and 256-colors, it goes over that limit.  Most
+        * people would not need a resource-file with 256-colors; the default
+        * values in our table are sufficient.  In that case, fake the resource
+        * setting by copying the default value from the table.  The #define's
+        * can be overridden to make these true resources.
+        */
+       if (i >= MIN_ANSI_COLORS && i < NUM_ANSI_COLORS) {
+           TScreenOf(wnew)->Acolors[i].resource =
+               x_strtrim(fake_resources[i - MIN_ANSI_COLORS].default_addr);
+           if (TScreenOf(wnew)->Acolors[i].resource == 0)
+               TScreenOf(wnew)->Acolors[i].resource = XtDefaultForeground;
+       } else
+#endif /* OPT_COLOR_RES2 */
+       {
+           TScreenOf(wnew)->Acolors[i] = TScreenOf(request)->Acolors[i];
+           TScreenOf(wnew)->Acolors[i].resource =
+               x_strtrim(TScreenOf(wnew)->Acolors[i].resource);
+       }
+
+#if OPT_COLOR_RES
+       TRACE(("Acolors[%d] = %s\n", i, TScreenOf(wnew)->Acolors[i].resource));
+       TScreenOf(wnew)->Acolors[i].mode = False;
+       if (DftFg(Acolors[i])) {
+           TScreenOf(wnew)->Acolors[i].value = T_COLOR(TScreenOf(wnew), TEXT_FG);
+           TScreenOf(wnew)->Acolors[i].mode = True;
+       } else if (DftBg(Acolors[i])) {
+           TScreenOf(wnew)->Acolors[i].value = T_COLOR(TScreenOf(wnew), TEXT_BG);
+           TScreenOf(wnew)->Acolors[i].mode = True;
+       } else {
+           color_ok = True;
+       }
+#else
+       TRACE(("Acolors[%d] = %#lx\n", i, TScreenOf(request)->Acolors[i]));
+       if (TScreenOf(wnew)->Acolors[i] != wnew->dft_foreground &&
+           TScreenOf(wnew)->Acolors[i] != T_COLOR(TScreenOf(wnew), TEXT_FG) &&
+           TScreenOf(wnew)->Acolors[i] != T_COLOR(TScreenOf(wnew), TEXT_BG))
+           color_ok = True;
+#endif
+    }
+
+    /*
+     * Check if we're trying to use color in a monochrome screen.  Disable
+     * color in that case, since that would make ANSI colors unusable.  A 4-bit
+     * or 8-bit display is usable, so we do not have to check for anything more
+     * specific.
+     */
+    if (color_ok) {
+       Display *display = TScreenOf(wnew)->display;
+       XVisualInfo myTemplate, *visInfoPtr;
+       int numFound;
+
+       myTemplate.visualid = XVisualIDFromVisual(DefaultVisual(display,
+                                                               XDefaultScreen(display)));
+       visInfoPtr = XGetVisualInfo(display, (long) VisualIDMask,
+                                   &myTemplate, &numFound);
+       if (visInfoPtr == 0
+           || numFound == 0
+           || visInfoPtr->depth <= 1) {
+           TRACE(("disabling color since screen is monochrome\n"));
+           color_ok = False;
+       } else {
+           XFree(visInfoPtr);
+       }
+    }
+
+    /* If none of the colors are anything other than the foreground or
+     * background, we'll assume this isn't color, no matter what the colorMode
+     * resource says.  (There doesn't seem to be any good way to determine if
+     * the resource lookup failed versus the user having misconfigured this).
+     */
+    if (!color_ok) {
+       TScreenOf(wnew)->colorMode = False;
+       TRACE(("All colors are foreground or background: disable colorMode\n"));
+    }
+    wnew->sgr_foreground = -1;
+    wnew->sgr_background = -1;
+    wnew->sgr_extended = False;
+#endif /* OPT_ISO_COLORS */
+
+    /*
+     * Decode the resources that control the behavior on multiple mouse clicks.
+     * A single click is always bound to normal character selection, but the
+     * other flavors can be changed.
+     */
+    for (i = 0; i < NSELECTUNITS; ++i) {
+       int ck = (i + 1);
+       TScreenOf(wnew)->maxClicks = ck;
+       if (i == Select_CHAR)
+           TScreenOf(wnew)->selectMap[i] = Select_CHAR;
+       else if (TScreenOf(request)->onClick[i] != 0)
+           ParseOnClicks(wnew, request, (unsigned) i);
+       else if (i <= Select_LINE)
+           TScreenOf(wnew)->selectMap[i] = (SelectUnit) i;
+       else
+           break;
+       TRACE(("on%dClicks %s=%d\n", ck,
+              NonNull(TScreenOf(request)->onClick[i]),
+              TScreenOf(wnew)->selectMap[i]));
+       if (TScreenOf(wnew)->selectMap[i] == NSELECTUNITS)
+           break;
+    }
+    TRACE(("maxClicks %d\n", TScreenOf(wnew)->maxClicks));
+
+    init_Tres(MOUSE_FG);
+    init_Tres(MOUSE_BG);
+    init_Tres(TEXT_CURSOR);
+#if OPT_HIGHLIGHT_COLOR
+    init_Tres(HIGHLIGHT_BG);
+    init_Tres(HIGHLIGHT_FG);
+    init_Bres(screen.hilite_reverse);
+    init_Bres(screen.hilite_color);
+    if (TScreenOf(wnew)->hilite_color == Maybe) {
+       TScreenOf(wnew)->hilite_color = False;
+#if OPT_COLOR_RES
+       /*
+        * If the highlight text/background are both set, and if they are
+        * not equal to either the text/background or background/text, then
+        * set the highlightColorMode automatically.
+        */
+       if (!DftFg(Tcolors[HIGHLIGHT_BG])
+           && !DftBg(Tcolors[HIGHLIGHT_FG])
+           && !TxtFg(Tcolors[HIGHLIGHT_BG])
+           && !TxtBg(Tcolors[HIGHLIGHT_FG])
+           && !TxtBg(Tcolors[HIGHLIGHT_BG])
+           && !TxtFg(Tcolors[HIGHLIGHT_FG])) {
+           TRACE(("...setting hilite_color automatically\n"));
+           TScreenOf(wnew)->hilite_color = True;
+       }
+#endif
+    }
+#endif
+
+#if OPT_TEK4014
+    /*
+     * The Tek4014 window has no separate resources for foreground, background
+     * and cursor color.  Since xterm always creates the vt100 widget first, we
+     * can set the Tektronix colors here.  That lets us use escape sequences to
+     * set its dynamic colors and get consistent behavior whether or not the
+     * window is displayed.
+     */
+    TScreenOf(wnew)->Tcolors[TEK_BG] = TScreenOf(wnew)->Tcolors[TEXT_BG];
+    TScreenOf(wnew)->Tcolors[TEK_FG] = TScreenOf(wnew)->Tcolors[TEXT_FG];
+    TScreenOf(wnew)->Tcolors[TEK_CURSOR] = TScreenOf(wnew)->Tcolors[TEXT_CURSOR];
+#endif
+
+#ifdef SCROLLBAR_RIGHT
+    init_Bres(misc.useRight);
+#endif
+
+#if OPT_RENDERFONT
+    for (i = 0; i <= fontMenu_lastBuiltin; ++i) {
+       init_Dres2(misc.face_size, i);
+    }
+    init_Sres(misc.face_name);
+    init_Sres(misc.face_wide_name);
+    init_Sres(misc.render_font_s);
+    wnew->misc.render_font =
+       (Boolean) extendedBoolean(wnew->misc.render_font_s,
+                                 tblRenderFont, erLast);
+    if (wnew->misc.render_font == erDefault) {
+       if (IsEmpty(wnew->misc.face_name)) {
+           wnew->misc.face_name = x_strdup(DEFFACENAME_AUTO);
+           TRACE(("will allow runtime switch to render_font using \"%s\"\n",
+                  wnew->misc.face_name));
+       } else {
+           wnew->misc.render_font = erTrue;
+           TRACE(("initially using TrueType font\n"));
+       }
+    }
+    /* minor tweak to make debug traces consistent: */
+    if (wnew->misc.render_font) {
+       if (IsEmpty(wnew->misc.face_name)) {
+           wnew->misc.render_font = False;
+           TRACE(("reset render_font since there is no face_name\n"));
+       }
+    }
+#endif
+
+#if OPT_WIDE_CHARS
+    VTInitialize_locale(request);
+    init_Bres(screen.utf8_latin1);
+    init_Bres(screen.utf8_title);
+
+#if OPT_LUIT_PROG
+    init_Bres(misc.callfilter);
+    init_Bres(misc.use_encoding);
+    init_Sres(misc.locale_str);
+    init_Sres(misc.localefilter);
+#endif
+
+    init_Ires(screen.utf8_inparse);
+    init_Ires(screen.utf8_mode);
+    init_Ires(screen.max_combining);
+
+    if (TScreenOf(wnew)->max_combining < 0) {
+       TScreenOf(wnew)->max_combining = 0;
+    }
+    if (TScreenOf(wnew)->max_combining > 5) {
+       TScreenOf(wnew)->max_combining = 5;
+    }
+
+    init_Bres(screen.vt100_graphics);
+    init_Bres(screen.wide_chars);
+    init_Bres(misc.mk_width);
+    init_Bres(misc.cjk_width);
+
+    init_Ires(misc.mk_samplesize);
+    init_Ires(misc.mk_samplepass);
+
+    if (wnew->misc.mk_samplesize > 0xffff)
+       wnew->misc.mk_samplesize = 0xffff;
+    if (wnew->misc.mk_samplesize < 0)
+       wnew->misc.mk_samplesize = 0;
+
+    if (wnew->misc.mk_samplepass > wnew->misc.mk_samplesize)
+       wnew->misc.mk_samplepass = wnew->misc.mk_samplesize;
+    if (wnew->misc.mk_samplepass < 0)
+       wnew->misc.mk_samplepass = 0;
+
+    if (TScreenOf(request)->utf8_mode) {
+       TRACE(("setting wide_chars on\n"));
+       TScreenOf(wnew)->wide_chars = True;
+    } else {
+       TRACE(("setting utf8_mode to 0\n"));
+       TScreenOf(wnew)->utf8_mode = uFalse;
+    }
+    TRACE(("initialized UTF-8 mode to %d\n", TScreenOf(wnew)->utf8_mode));
+
+#if OPT_MINI_LUIT
+    if (TScreenOf(request)->latin9_mode) {
+       TScreenOf(wnew)->latin9_mode = True;
+    }
+    if (TScreenOf(request)->unicode_font) {
+       TScreenOf(wnew)->unicode_font = True;
+    }
+    TRACE(("initialized Latin9 mode to %d\n", TScreenOf(wnew)->latin9_mode));
+    TRACE(("initialized unicode_font to %d\n", TScreenOf(wnew)->unicode_font));
+#endif
+
+    decode_wcwidth(wnew);
+#endif /* OPT_WIDE_CHARS */
+
+    init_Bres(screen.always_bold_mode);
+    init_Bres(screen.bold_mode);
+    init_Bres(screen.underline);
+
+    wnew->cur_foreground = 0;
+    wnew->cur_background = 0;
+
+    wnew->keyboard.flags = MODE_SRM;
+    if (TScreenOf(wnew)->backarrow_key)
+       wnew->keyboard.flags |= MODE_DECBKM;
+    TRACE(("initialized DECBKM %s\n",
+          BtoS(wnew->keyboard.flags & MODE_DECBKM)));
+
+    /* look for focus related events on the shell, because we need
+     * to care about the shell's border being part of our focus.
+     */
+    TRACE(("adding event handlers for my_parent %p\n", (void *) my_parent));
+    XtAddEventHandler(my_parent, EnterWindowMask, False,
+                     HandleEnterWindow, (Opaque) NULL);
+    XtAddEventHandler(my_parent, LeaveWindowMask, False,
+                     HandleLeaveWindow, (Opaque) NULL);
+    XtAddEventHandler(my_parent, FocusChangeMask, False,
+                     HandleFocusChange, (Opaque) NULL);
+    XtAddEventHandler((Widget) wnew, 0L, True,
+                     VTNonMaskableEvent, (Opaque) NULL);
+    XtAddEventHandler((Widget) wnew, PropertyChangeMask, False,
+                     HandleBellPropertyChange, (Opaque) NULL);
+
+#if HANDLE_STRUCT_NOTIFY
+#if OPT_TOOLBAR
+    wnew->VT100_TB_INFO(menu_bar) = request->VT100_TB_INFO(menu_bar);
+    init_Ires(VT100_TB_INFO(menu_height));
+#else
+    /* Flag icon name with "***"  on window output when iconified.
+     * Put in a handler that will tell us when we get Map/Unmap events.
+     */
+    if (resource.zIconBeep)
+#endif
+       XtAddEventHandler(my_parent, StructureNotifyMask, False,
+                         HandleStructNotify, (Opaque) 0);
+#endif /* HANDLE_STRUCT_NOTIFY */
+
+    TScreenOf(wnew)->bellInProgress = False;
+
+    set_character_class(TScreenOf(wnew)->charClass);
+
+    /* create it, but don't realize it */
+    ScrollBarOn(wnew, True);
+
+    /* make sure that the resize gravity acceptable */
+    if (!GravityIsNorthWest(wnew) &&
+       !GravityIsSouthWest(wnew)) {
+       char value[80];
+       String temp[2];
+       Cardinal nparams = 1;
+
+       sprintf(value, "%d", wnew->misc.resizeGravity);
+       temp[0] = value;
+       temp[1] = 0;
+       XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError",
+                       "unsupported resizeGravity resource value (%s)",
+                       temp, &nparams);
+       wnew->misc.resizeGravity = SouthWestGravity;
+    }
+#ifndef NO_ACTIVE_ICON
+    TScreenOf(wnew)->whichVwin = &TScreenOf(wnew)->fullVwin;
+#endif /* NO_ACTIVE_ICON */
+
+    if (TScreenOf(wnew)->savelines < 0)
+       TScreenOf(wnew)->savelines = 0;
+
+    init_Bres(screen.awaitInput);
+
+    wnew->flags = 0;
+    if (!TScreenOf(wnew)->jumpscroll)
+       wnew->flags |= SMOOTHSCROLL;
+    if (wnew->misc.reverseWrap)
+       wnew->flags |= REVERSEWRAP;
+    if (wnew->misc.autoWrap)
+       wnew->flags |= WRAPAROUND;
+    if (wnew->misc.re_verse != wnew->misc.re_verse0)
+       wnew->flags |= REVERSE_VIDEO;
+    if (TScreenOf(wnew)->c132)
+       wnew->flags |= IN132COLUMNS;
+
+    wnew->initflags = wnew->flags;
+
+#if OPT_MOD_FKEYS
+    init_Ires(keyboard.modify_1st.cursor_keys);
+    init_Ires(keyboard.modify_1st.function_keys);
+    init_Ires(keyboard.modify_1st.keypad_keys);
+    init_Ires(keyboard.modify_1st.other_keys);
+    init_Ires(keyboard.modify_1st.string_keys);
+    init_Ires(keyboard.format_keys);
+    wnew->keyboard.modify_now = wnew->keyboard.modify_1st;
+#endif
+
+    init_Ires(misc.appcursorDefault);
+    if (wnew->misc.appcursorDefault)
+       wnew->keyboard.flags |= MODE_DECCKM;
+
+    init_Ires(misc.appkeypadDefault);
+    if (wnew->misc.appkeypadDefault)
+       wnew->keyboard.flags |= MODE_DECKPAM;
+
+    initLineData(wnew);
+    return;
+}
+
+void
+releaseCursorGCs(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+    int n;
+
+    for_each_curs_gc(n) {
+       freeCgs(xw, win, (CgsEnum) n);
+    }
+}
+
+void
+releaseWindowGCs(XtermWidget xw, VTwin * win)
+{
+    int n;
+
+    for_each_text_gc(n) {
+       freeCgs(xw, win, (CgsEnum) n);
+    }
+}
+
+#define TRACE_FREE_LEAK(name) \
+       if (name) { \
+           free((void *) name); \
+           name = 0; \
+           TRACE(("freed " #name "\n")); \
+       }
+
+#define FREE_LEAK(name) \
+       if (name) { \
+           free((void *) name); \
+           name = 0; \
+       }
+
+#if OPT_INPUT_METHOD
+static void
+cleanupInputMethod(TScreen * screen)
+{
+    if (screen->xim) {
+       XCloseIM(screen->xim);
+       screen->xim = 0;
+       TRACE(("freed screen->xim\n"));
+    }
+}
+#endif
+
+static void
+VTDestroy(Widget w GCC_UNUSED)
+{
+#ifdef NO_LEAKS
+    XtermWidget xw = (XtermWidget) w;
+    TScreen *screen = TScreenOf(xw);
+    Cardinal n;
+
+    StopBlinking(screen);
+
+    if (screen->scrollWidget) {
+       XtUninstallTranslations(screen->scrollWidget);
+       XtDestroyWidget(screen->scrollWidget);
+    }
+#if OPT_FIFO_LINES
+    while (screen->saved_fifo-- > 0) {
+       deleteScrollback(screen, 0);
+    }
+#endif
+    while (screen->save_title != 0) {
+       SaveTitle *last = screen->save_title;
+       screen->save_title = last->next;
+       free(last->iconName);
+       free(last->windowName);
+       free(last);
+    }
+    TRACE_FREE_LEAK(screen->save_ptr);
+    TRACE_FREE_LEAK(screen->saveBuf_data);
+    TRACE_FREE_LEAK(screen->saveBuf_index);
+    for (n = 0; n < 2; ++n) {
+       TRACE_FREE_LEAK(screen->editBuf_data[n]);
+       TRACE_FREE_LEAK(screen->editBuf_index[n]);
+    }
+    TRACE_FREE_LEAK(screen->keyboard_dialect);
+    TRACE_FREE_LEAK(screen->term_id);
+#if OPT_WIDE_CHARS
+#if OPT_LUIT_PROG
+    TRACE_FREE_LEAK(xw->misc.locale_str);
+    TRACE_FREE_LEAK(xw->misc.localefilter);
+#endif
+#endif
+#if OPT_INPUT_METHOD
+    cleanupInputMethod(screen);
+#endif
+    releaseCursorGCs(xw);
+    releaseWindowGCs(xw, &(screen->fullVwin));
+#ifndef NO_ACTIVE_ICON
+    releaseWindowGCs(xw, &(screen->iconVwin));
+#endif
+    XtUninstallTranslations((Widget) xw);
+#if OPT_TOOLBAR
+    XtUninstallTranslations((Widget) XtParent(xw));
+#endif
+    XtUninstallTranslations((Widget) SHELL_OF(xw));
+
+    if (screen->hidden_cursor)
+       XFreeCursor(screen->display, screen->hidden_cursor);
+
+    xtermCloseFonts(xw, screen->fnts);
+    noleaks_cachedCgs(xw);
+
+#if OPT_RENDERFONT
+    for (n = 0; n < NMENUFONTS; ++n) {
+       xtermCloseXft(screen, &(screen->renderFontNorm[n]));
+       xtermCloseXft(screen, &(screen->renderFontBold[n]));
+       xtermCloseXft(screen, &(screen->renderFontItal[n]));
+#if OPT_RENDERWIDE
+       xtermCloseXft(screen, &(screen->renderWideNorm[n]));
+       xtermCloseXft(screen, &(screen->renderWideBold[n]));
+       xtermCloseXft(screen, &(screen->renderWideItal[n]));
+#endif
+    }
+#endif
+
+    /* free things allocated via init_Sres or Init_Sres2 */
+#ifdef ALLOWLOGGING
+    TRACE_FREE_LEAK(screen->logfile);
+#endif
+    TRACE_FREE_LEAK(screen->term_id);
+    TRACE_FREE_LEAK(screen->charClass);
+    TRACE_FREE_LEAK(screen->answer_back);
+    TRACE_FREE_LEAK(screen->printer_command);
+    TRACE_FREE_LEAK(screen->keyboard_dialect);
+    TRACE_FREE_LEAK(screen->disallowedColorOps);
+    TRACE_FREE_LEAK(screen->disallowedFontOps);
+    TRACE_FREE_LEAK(screen->disallowedTcapOps);
+    TRACE_FREE_LEAK(screen->disallowedWinOps);
+    TRACE_FREE_LEAK(screen->default_string);
+    TRACE_FREE_LEAK(screen->eightbit_select_types);
+#if OPT_WIDE_CHARS
+    TRACE_FREE_LEAK(screen->utf8_select_types);
+#endif
+#if 0
+    for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; n++) {
+       TRACE_FREE_LEAK(screen->MenuFontName(n));
+    }
+#endif
+    TRACE_FREE_LEAK(screen->initial_font);
+#if OPT_LUIT_PROG
+    TRACE_FREE_LEAK(xw->misc.locale_str);
+    TRACE_FREE_LEAK(xw->misc.localefilter);
+#endif
+#if OPT_RENDERFONT
+    TRACE_FREE_LEAK(xw->misc.face_name);
+    TRACE_FREE_LEAK(xw->misc.face_wide_name);
+#endif
+
+#if OPT_SELECT_REGEX
+    for (n = 0; n < NSELECTUNITS; ++n) {
+       FREE_LEAK(screen->selectExpr[n]);
+    }
+#endif
+
+    if (screen->selection_atoms)
+       XtFree((char *) (screen->selection_atoms));
+
+    XtFree((char *) (screen->selection_data));
+
+    TRACE_FREE_LEAK(xw->keyboard.extra_translations);
+    TRACE_FREE_LEAK(xw->keyboard.shell_translations);
+    TRACE_FREE_LEAK(xw->keyboard.xterm_translations);
+
+#if OPT_WIDE_CHARS
+    FreeTypedBuffer(XChar2b);
+    FreeTypedBuffer(char);
+#endif
+#if OPT_RENDERFONT
+#if OPT_RENDERWIDE
+    FreeTypedBuffer(XftCharSpec);
+#else
+    FreeTypedBuffer(XftChar8);
+#endif
+#endif
+
+    TRACE_FREE_LEAK(myState.print_area);
+    TRACE_FREE_LEAK(myState.string_area);
+    memset(&myState, 0, sizeof(myState));
+
+#endif /* defined(NO_LEAKS) */
+}
+
+/*ARGSUSED*/
+static void
+VTRealize(Widget w,
+         XtValueMask * valuemask,
+         XSetWindowAttributes * values)
+{
+    XtermWidget xw = (XtermWidget) w;
+    TScreen *screen = TScreenOf(xw);
+
+    const VTFontNames *myfont;
+    unsigned width, height;
+    int xpos, ypos, pr;
+    Atom pid_atom;
+    int i;
+
+    TRACE(("VTRealize\n"));
+
+    TabReset(xw->tabs);
+
+    if (screen->menu_font_number == fontMenu_default) {
+       myfont = &(xw->misc.default_font);
+    } else {
+       myfont = xtermFontName(screen->MenuFontName(screen->menu_font_number));
+    }
+    memset(screen->fnts, 0, sizeof(screen->fnts));
+
+    if (!xtermLoadFont(xw,
+                      myfont,
+                      False,
+                      screen->menu_font_number)) {
+       if (XmuCompareISOLatin1(myfont->f_n, DEFFONT) != 0) {
+           char *use_font = x_strdup(DEFFONT);
+           fprintf(stderr,
+                   "%s:  unable to open font \"%s\", trying \"%s\"....\n",
+                   xterm_name, myfont->f_n, use_font);
+           (void) xtermLoadFont(xw,
+                                xtermFontName(use_font),
+                                False,
+                                screen->menu_font_number);
+           screen->MenuFontName(screen->menu_font_number) = use_font;
+       }
+    }
+
+    /* really screwed if we couldn't open default font */
+    if (!screen->fnts[fNorm].fs) {
+       fprintf(stderr, "%s:  unable to locate a suitable font\n",
+               xterm_name);
+       Exit(1);
+    }
+#if OPT_WIDE_CHARS
+    if (TScreenOf(xw)->utf8_mode) {
+       TRACE(("check if this is a wide font, if not try again\n"));
+       if (xtermLoadWideFonts(xw, False))
+           SetVTFont(xw, screen->menu_font_number, True, NULL);
+    }
+#endif
+
+    /* making cursor */
+    if (!screen->pointer_cursor) {
+       screen->pointer_cursor =
+           make_colored_cursor(XC_xterm,
+                               T_COLOR(screen, MOUSE_FG),
+                               T_COLOR(screen, MOUSE_BG));
+    } else {
+       recolor_cursor(screen,
+                      screen->pointer_cursor,
+                      T_COLOR(screen, MOUSE_FG),
+                      T_COLOR(screen, MOUSE_BG));
+    }
+
+    /* set defaults */
+    xpos = 1;
+    ypos = 1;
+    width = 80;
+    height = 24;
+
+    TRACE(("parsing geo_metry %s\n", NonNull(xw->misc.geo_metry)));
+    pr = XParseGeometry(xw->misc.geo_metry, &xpos, &ypos,
+                       &width, &height);
+    TRACE(("... position %d,%d size %dx%d\n", ypos, xpos, height, width));
+
+    set_max_col(screen, (int) (width - 1));    /* units in character cells */
+    set_max_row(screen, (int) (height - 1));   /* units in character cells */
+    xtermUpdateFontInfo(xw, False);
+
+    width = screen->fullVwin.fullwidth;
+    height = screen->fullVwin.fullheight;
+
+    TRACE(("... border widget %d parent %d shell %d\n",
+          BorderWidth(xw),
+          BorderWidth(XtParent(xw)),
+          BorderWidth(SHELL_OF(xw))));
+
+    if ((pr & XValue) && (XNegative & pr)) {
+       xpos += (DisplayWidth(screen->display, DefaultScreen(screen->display))
+                - (int) width
+                - (BorderWidth(XtParent(xw)) * 2));
+    }
+    if ((pr & YValue) && (YNegative & pr)) {
+       ypos += (DisplayHeight(screen->display, DefaultScreen(screen->display))
+                - (int) height
+                - (BorderWidth(XtParent(xw)) * 2));
+    }
+
+    /* set up size hints for window manager; min 1 char by 1 char */
+    getXtermSizeHints(xw);
+    xtermSizeHints(xw, (xw->misc.scrollbar
+                       ? (screen->scrollWidget->core.width
+                          + BorderWidth(screen->scrollWidget))
+                       : 0));
+
+    xw->hints.x = xpos;
+    xw->hints.y = ypos;
+#if OPT_MAXIMIZE
+    /* assure single-increment resize for fullscreen */
+    if (term->screen.fullscreen) {
+       xw->hints.width_inc = 1;
+       xw->hints.height_inc = 1;
+    }
+#endif
+    if ((XValue & pr) || (YValue & pr)) {
+       xw->hints.flags |= USSize | USPosition;
+       xw->hints.flags |= PWinGravity;
+       switch (pr & (XNegative | YNegative)) {
+       case 0:
+           xw->hints.win_gravity = NorthWestGravity;
+           break;
+       case XNegative:
+           xw->hints.win_gravity = NorthEastGravity;
+           break;
+       case YNegative:
+           xw->hints.win_gravity = SouthWestGravity;
+           break;
+       default:
+           xw->hints.win_gravity = SouthEastGravity;
+           break;
+       }
+    } else {
+       /* set a default size, but do *not* set position */
+       xw->hints.flags |= PSize;
+    }
+    xw->hints.height = xw->hints.base_height
+       + xw->hints.height_inc * MaxRows(screen);
+    xw->hints.width = xw->hints.base_width
+       + xw->hints.width_inc * MaxCols(screen);
+
+    if ((WidthValue & pr) || (HeightValue & pr))
+       xw->hints.flags |= USSize;
+    else
+       xw->hints.flags |= PSize;
+
+    /*
+     * Note that the size-hints are for the shell, while the resize-request
+     * is for the vt100 widget.  They are not the same size.
+     */
+    (void) REQ_RESIZE((Widget) xw,
+                     (Dimension) width, (Dimension) height,
+                     &xw->core.width, &xw->core.height);
+
+    /* XXX This is bogus.  We are parsing geometries too late.  This
+     * is information that the shell widget ought to have before we get
+     * realized, so that it can do the right thing.
+     */
+    if (xw->hints.flags & USPosition)
+       XMoveWindow(XtDisplay(xw), VShellWindow(xw),
+                   xw->hints.x, xw->hints.y);
+
+    TRACE(("%s@%d -- ", __FILE__, __LINE__));
+    TRACE_HINTS(&xw->hints);
+    XSetWMNormalHints(XtDisplay(xw), VShellWindow(xw), &xw->hints);
+    TRACE(("%s@%d -- ", __FILE__, __LINE__));
+    TRACE_WM_HINTS(xw);
+
+    if ((pid_atom = XInternAtom(XtDisplay(xw), "_NET_WM_PID", False)) != None) {
+       /* XChangeProperty format 32 really is "long" */
+       unsigned long pid_l = (unsigned long) getpid();
+       TRACE(("Setting _NET_WM_PID property to %lu\n", pid_l));
+       XChangeProperty(XtDisplay(xw), VShellWindow(xw),
+                       pid_atom, XA_CARDINAL, 32, PropModeReplace,
+                       (unsigned char *) &pid_l, 1);
+    }
+
+    XFlush(XtDisplay(xw));     /* get it out to window manager */
+
+    /* use ForgetGravity instead of SouthWestGravity because translating
+       the Expose events for ConfigureNotifys is too hard */
+    values->bit_gravity = (GravityIsNorthWest(xw)
+                          ? NorthWestGravity
+                          : ForgetGravity);
+    TScreenOf(xw)->fullVwin.window = XtWindow(xw) =
+       XCreateWindow(XtDisplay(xw), XtWindow(XtParent(xw)),
+                     xw->core.x, xw->core.y,
+                     xw->core.width, xw->core.height, BorderWidth(xw),
+                     (int) xw->core.depth,
+                     InputOutput, CopyFromParent,
+                     *valuemask | CWBitGravity, values);
+    screen->event_mask = values->event_mask;
+
+#ifndef NO_ACTIVE_ICON
+    /*
+     * Normally, the font-number for icon fonts does not correspond with any of
+     * the menu-selectable fonts.  If we cannot load the font given for the
+     * iconFont resource, try with font1 aka "Unreadable".
+     */
+    screen->icon_fontnum = -1;
+    if (screen->fnt_icon.fs == 0) {
+       screen->fnt_icon.fs = XLoadQueryFont(screen->display,
+                                            screen->MenuFontName(fontMenu_font1));
+       TRACE(("%susing font1 '%s' as iconFont\n",
+              (screen->fnt_icon.fs
+               ? ""
+               : "NOT "),
+              screen->MenuFontName(fontMenu_font1)));
+    }
+#if OPT_RENDERFONT
+    /*
+     * If we still have no result from iconFont resource (perhaps because fonts
+     * are missing) but are using Xft, try to use that instead.  We prefer
+     * bitmap fonts in any case, since scaled fonts are usually less readable,
+     * particularly at small sizes.
+     */
+    if (UsingRenderFont(xw)
+       && screen->fnt_icon.fs == 0) {
+       screen->icon_fontnum = fontMenu_default;
+       screen->fnt_icon.fs = screen->fnts[0].fs;       /* need for next-if */
+       TRACE(("using TrueType font as iconFont\n"));
+    }
+#endif
+    if (xw->misc.active_icon && screen->fnt_icon.fs) {
+       int iconX = 0, iconY = 0;
+       Widget shell = SHELL_OF(xw);
+       VTwin *win = &(screen->iconVwin);
+       int save_fontnum = screen->menu_font_number;
+
+       TRACE(("Initializing active-icon %d\n", screen->icon_fontnum));
+       screen->menu_font_number = screen->icon_fontnum;
+       XtVaGetValues(shell,
+                     XtNiconX, &iconX,
+                     XtNiconY, &iconY,
+                     (XtPointer) 0);
+       xtermComputeFontInfo(xw, &(screen->iconVwin), screen->fnt_icon.fs, 0);
+       screen->menu_font_number = save_fontnum;
+
+       /* since only one client is permitted to select for Button
+        * events, we have to let the window manager get 'em...
+        */
+       values->event_mask &= ~(ButtonPressMask | ButtonReleaseMask);
+       values->border_pixel = xw->misc.icon_border_pixel;
+
+       screen->iconVwin.window =
+           XCreateWindow(XtDisplay(xw),
+                         RootWindowOfScreen(XtScreen(shell)),
+                         iconX, iconY,
+                         screen->iconVwin.fullwidth,
+                         screen->iconVwin.fullheight,
+                         xw->misc.icon_border_width,
+                         (int) xw->core.depth,
+                         InputOutput, CopyFromParent,
+                         *valuemask | CWBitGravity | CWBorderPixel,
+                         values);
+       XtVaSetValues(shell,
+                     XtNiconWindow, screen->iconVwin.window,
+                     (XtPointer) 0);
+       XtRegisterDrawable(XtDisplay(xw), screen->iconVwin.window, w);
+
+       setCgsFont(xw, win, gcNorm, &(screen->fnt_icon));
+       setCgsFore(xw, win, gcNorm, T_COLOR(screen, TEXT_FG));
+       setCgsBack(xw, win, gcNorm, T_COLOR(screen, TEXT_BG));
+
+       copyCgs(xw, win, gcBold, gcNorm);
+
+       setCgsFont(xw, win, gcNormReverse, &(screen->fnt_icon));
+       setCgsFore(xw, win, gcNormReverse, T_COLOR(screen, TEXT_BG));
+       setCgsBack(xw, win, gcNormReverse, T_COLOR(screen, TEXT_FG));
+
+       copyCgs(xw, win, gcBoldReverse, gcNormReverse);
+
+#if OPT_TOOLBAR
+       /*
+        * Toolbar is initialized before we get here.  Enable the menu item
+        * and set it properly.
+        */
+       SetItemSensitivity(vtMenuEntries[vtMenu_activeicon].widget, True);
+       update_activeicon();
+#endif
+    } else {
+       TRACE(("Disabled active-icon\n"));
+       xw->misc.active_icon = False;
+    }
+#endif /* NO_ACTIVE_ICON */
+
+#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
+    VTInitI18N(xw);
+#else
+    TScreenOf(xw)->xic = NULL;
+#endif
+#if OPT_NUM_LOCK
+    VTInitModifiers(xw);
+#if OPT_EXTRA_PASTE
+    if (xw->keyboard.extra_translations) {
+       XtOverrideTranslations((Widget) xw,
+                              XtParseTranslationTable(xw->keyboard.extra_translations));
+    }
+#endif
+#endif
+
+    set_cursor_gcs(xw);
+
+    /* Reset variables used by ANSI emulation. */
+
+    resetCharsets(screen);
+
+    XDefineCursor(screen->display, VShellWindow(xw), screen->pointer_cursor);
+
+    set_cur_col(screen, 0);
+    set_cur_row(screen, 0);
+    set_max_col(screen, Width(screen) / screen->fullVwin.f_width - 1);
+    set_max_row(screen, Height(screen) / screen->fullVwin.f_height - 1);
+    set_tb_margins(screen, 0, screen->max_row);
+
+    memset(screen->sc, 0, sizeof(screen->sc));
+
+    /* Mark screen buffer as unallocated.  We wait until the run loop so
+       that the child process does not fork and exec with all the dynamic
+       memory it will never use.  If we were to do it here, the
+       swap space for new process would be huge for huge savelines. */
+#if OPT_TEK4014
+    if (!tekWidget)            /* if not called after fork */
+#endif
+    {
+       screen->visbuf = NULL;
+       screen->saveBuf_index = NULL;
+    }
+
+    screen->do_wrap = False;
+    screen->scrolls = screen->incopy = 0;
+    xtermSetCursorBox(screen);
+
+    screen->savedlines = 0;
+
+    for (i = 0; i < 2; ++i) {
+       screen->whichBuf = !screen->whichBuf;
+       CursorSave(xw);
+    }
+
+    /*
+     * Do this last, since it may change the layout via a resize.
+     */
+    if (xw->misc.scrollbar) {
+       screen->fullVwin.sb_info.width = 0;
+       ScrollBarOn(xw, False);
+    }
+    return;
+}
+
+#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
+
+/* limit this feature to recent XFree86 since X11R6.x core dumps */
+#if defined(XtSpecificationRelease) && XtSpecificationRelease >= 6 && defined(X_HAVE_UTF8_STRING)
+#define USE_XIM_INSTANTIATE_CB
+
+static void
+xim_instantiate_cb(Display * display,
+                  XPointer client_data GCC_UNUSED,
+                  XPointer call_data GCC_UNUSED)
+{
+    if (display != XtDisplay(term))
+       return;
+
+    VTInitI18N(term);
+}
+
+static void
+xim_destroy_cb(XIM im GCC_UNUSED,
+              XPointer client_data GCC_UNUSED,
+              XPointer call_data GCC_UNUSED)
+{
+    TScreenOf(term)->xic = NULL;
+
+    XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL,
+                                  xim_instantiate_cb, NULL);
+}
+#endif /* X11R6+ */
+
+static void
+xim_real_init(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned i, j;
+    char *p, *s, *t, *ns, *end, buf[32];
+    XIMStyles *xim_styles;
+    XIMStyle input_style = 0;
+    Bool found;
+    static struct {
+       const char *name;
+       unsigned long code;
+    } known_style[] = {
+       {
+           "OverTheSpot", (XIMPreeditPosition | XIMStatusNothing)
+       },
+       {
+           "OffTheSpot", (XIMPreeditArea | XIMStatusArea)
+       },
+       {
+           "Root", (XIMPreeditNothing | XIMStatusNothing)
+       },
+    };
+
+    screen->xic = NULL;
+
+    if (xw->misc.cannot_im) {
+       return;
+    }
+
+    if (!xw->misc.input_method || !*xw->misc.input_method) {
+       if ((p = XSetLocaleModifiers("")) != NULL && *p)
+           screen->xim = XOpenIM(XtDisplay(xw), NULL, NULL, NULL);
+    } else {
+       s = xw->misc.input_method;
+       i = 5 + (unsigned) strlen(s);
+
+       t = (char *) MyStackAlloc(i, buf);
+       if (t == NULL) {
+           SysError(ERROR_VINIT);
+       } else {
+
+           for (ns = s; ns && *s;) {
+               while (*s && isspace(CharOf(*s)))
+                   s++;
+               if (!*s)
+                   break;
+               if ((ns = end = strchr(s, ',')) == 0)
+                   end = s + strlen(s);
+               while ((end != s) && isspace(CharOf(end[-1])))
+                   end--;
+
+               if (end != s) {
+                   strcpy(t, "@im=");
+                   strncat(t, s, (size_t) (end - s));
+
+                   if ((p = XSetLocaleModifiers(t)) != 0 && *p
+                       && (screen->xim = XOpenIM(XtDisplay(xw),
+                                                 NULL,
+                                                 NULL,
+                                                 NULL)) != 0)
+                       break;
+
+               }
+               s = ns + 1;
+           }
+           MyStackFree(t, buf);
+       }
+    }
+
+    if (screen->xim == NULL
+       && (p = XSetLocaleModifiers("@im=none")) != NULL
+       && *p) {
+       screen->xim = XOpenIM(XtDisplay(xw), NULL, NULL, NULL);
+    }
+
+    if (!screen->xim) {
+       fprintf(stderr, "Failed to open input method\n");
+       return;
+    }
+    TRACE(("VTInitI18N opened input method\n"));
+
+    if (XGetIMValues(screen->xim, XNQueryInputStyle, &xim_styles, NULL)
+       || !xim_styles
+       || !xim_styles->count_styles) {
+       fprintf(stderr, "input method doesn't support any style\n");
+       cleanupInputMethod(screen);
+       xw->misc.cannot_im = True;
+       return;
+    }
+
+    found = False;
+    for (s = xw->misc.preedit_type; s && !found;) {
+       while (*s && isspace(CharOf(*s)))
+           s++;
+       if (!*s)
+           break;
+       if ((ns = end = strchr(s, ',')) != 0)
+           ns++;
+       else
+           end = s + strlen(s);
+       while ((end != s) && isspace(CharOf(end[-1])))
+           end--;
+
+       if (end != s) {         /* just in case we have a spurious comma */
+           TRACE(("looking for style '%.*s'\n", (int) (end - s), s));
+           for (i = 0; i < XtNumber(known_style); i++) {
+               if ((int) strlen(known_style[i].name) == (end - s)
+                   && !strncmp(s, known_style[i].name, (size_t) (end - s))) {
+                   input_style = known_style[i].code;
+                   for (j = 0; j < xim_styles->count_styles; j++) {
+                       if (input_style == xim_styles->supported_styles[j]) {
+                           found = True;
+                           break;
+                       }
+                   }
+                   if (found)
+                       break;
+               }
+           }
+       }
+
+       s = ns;
+    }
+    XFree(xim_styles);
+
+    if (!found) {
+       fprintf(stderr,
+               "input method doesn't support my preedit type (%s)\n",
+               xw->misc.preedit_type);
+       cleanupInputMethod(screen);
+       xw->misc.cannot_im = True;
+       return;
+    }
+
+    /*
+     * Check for styles we do not yet support.
+     */
+    TRACE(("input_style %#lx\n", input_style));
+    if (input_style == (XIMPreeditArea | XIMStatusArea)) {
+       fprintf(stderr,
+               "This program doesn't support the 'OffTheSpot' preedit type\n");
+       cleanupInputMethod(screen);
+       xw->misc.cannot_im = True;
+       return;
+    }
+
+    /*
+     * For XIMPreeditPosition (or OverTheSpot), XIM client has to
+     * prepare a font.
+     * The font has to be locale-dependent XFontSet, whereas
+     * XTerm use Unicode font.  This leads a problem that the
+     * same font cannot be used for XIM preedit.
+     */
+    if (input_style != (XIMPreeditNothing | XIMStatusNothing)) {
+       char **missing_charset_list;
+       int missing_charset_count;
+       char *def_string;
+       XVaNestedList p_list;
+       XPoint spot =
+       {0, 0};
+       XFontStruct **fonts;
+       char **font_name_list;
+
+       screen->fs = XCreateFontSet(XtDisplay(xw),
+                                   xw->misc.f_x,
+                                   &missing_charset_list,
+                                   &missing_charset_count,
+                                   &def_string);
+       if (screen->fs == NULL) {
+           fprintf(stderr, "Preparation of font set "
+                   "\"%s\" for XIM failed.\n", xw->misc.f_x);
+           screen->fs = XCreateFontSet(XtDisplay(xw),
+                                       DEFXIMFONT,
+                                       &missing_charset_list,
+                                       &missing_charset_count,
+                                       &def_string);
+       }
+       if (screen->fs == NULL) {
+           fprintf(stderr, "Preparation of default font set "
+                   "\"%s\" for XIM failed.\n", DEFXIMFONT);
+           cleanupInputMethod(screen);
+           xw->misc.cannot_im = True;
+           return;
+       }
+       (void) XExtentsOfFontSet(screen->fs);
+       j = (unsigned) XFontsOfFontSet(screen->fs, &fonts, &font_name_list);
+       for (i = 0, screen->fs_ascent = 0; i < j; i++) {
+           if (screen->fs_ascent < (*fonts)->ascent)
+               screen->fs_ascent = (*fonts)->ascent;
+       }
+       p_list = XVaCreateNestedList(0,
+                                    XNSpotLocation, &spot,
+                                    XNFontSet, screen->fs,
+                                    NULL);
+       screen->xic = XCreateIC(screen->xim,
+                               XNInputStyle, input_style,
+                               XNClientWindow, XtWindow(xw),
+                               XNFocusWindow, XtWindow(xw),
+                               XNPreeditAttributes, p_list,
+                               NULL);
+    } else {
+       screen->xic = XCreateIC(screen->xim, XNInputStyle, input_style,
+                               XNClientWindow, XtWindow(xw),
+                               XNFocusWindow, XtWindow(xw),
+                               NULL);
+    }
+
+    if (!screen->xic) {
+       fprintf(stderr, "Failed to create input context\n");
+       cleanupInputMethod(screen);
+    }
+#if defined(USE_XIM_INSTANTIATE_CB)
+    else {
+       XIMCallback destroy_cb;
+
+       destroy_cb.callback = xim_destroy_cb;
+       destroy_cb.client_data = NULL;
+       if (XSetIMValues(screen->xim, XNDestroyCallback, &destroy_cb, NULL))
+           fprintf(stderr, "Could not set destroy callback to IM\n");
+    }
+#endif
+
+    return;
+}
+
+static void
+VTInitI18N(XtermWidget xw)
+{
+    if (xw->misc.open_im) {
+       xim_real_init(xw);
+
+#if defined(USE_XIM_INSTANTIATE_CB)
+       if (TScreenOf(xw)->xic == NULL
+           && !xw->misc.cannot_im
+           && xw->misc.retry_im-- > 0) {
+           sleep(3);
+           XRegisterIMInstantiateCallback(XtDisplay(xw), NULL, NULL, NULL,
+                                          xim_instantiate_cb, NULL);
+       }
+#endif
+    }
+}
+#endif /* OPT_I18N_SUPPORT && OPT_INPUT_METHOD */
+
+static void
+set_cursor_outline_gc(XtermWidget xw,
+                     Boolean filled,
+                     Pixel fg,
+                     Pixel bg,
+                     Pixel cc)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+    CgsEnum cgsId = gcVTcursOutline;
+
+    if (cc == bg)
+       cc = fg;
+
+    if (filled) {
+       setCgsFore(xw, win, cgsId, bg);
+       setCgsBack(xw, win, cgsId, cc);
+    } else {
+       setCgsFore(xw, win, cgsId, cc);
+       setCgsBack(xw, win, cgsId, bg);
+    }
+}
+
+static Boolean
+VTSetValues(Widget cur,
+           Widget request GCC_UNUSED,
+           Widget wnew,
+           ArgList args GCC_UNUSED,
+           Cardinal *num_args GCC_UNUSED)
+{
+    XtermWidget curvt = (XtermWidget) cur;
+    XtermWidget newvt = (XtermWidget) wnew;
+    Boolean refresh_needed = False;
+    Boolean fonts_redone = False;
+
+    if ((T_COLOR(TScreenOf(curvt), TEXT_BG) !=
+        T_COLOR(TScreenOf(newvt), TEXT_BG)) ||
+       (T_COLOR(TScreenOf(curvt), TEXT_FG) !=
+        T_COLOR(TScreenOf(newvt), TEXT_FG)) ||
+       (TScreenOf(curvt)->MenuFontName(TScreenOf(curvt)->menu_font_number) !=
+        TScreenOf(newvt)->MenuFontName(TScreenOf(newvt)->menu_font_number)) ||
+       (curvt->misc.default_font.f_n != newvt->misc.default_font.f_n)) {
+       if (curvt->misc.default_font.f_n != newvt->misc.default_font.f_n)
+           TScreenOf(newvt)->MenuFontName(fontMenu_default) = newvt->misc.default_font.f_n;
+       if (xtermLoadFont(newvt,
+                         xtermFontName(TScreenOf(newvt)->MenuFontName(TScreenOf(curvt)->menu_font_number)),
+                         True, TScreenOf(newvt)->menu_font_number)) {
+           /* resizing does the redisplay, so don't ask for it here */
+           refresh_needed = True;
+           fonts_redone = True;
+       } else if (curvt->misc.default_font.f_n != newvt->misc.default_font.f_n)
+           TScreenOf(newvt)->MenuFontName(fontMenu_default) = curvt->misc.default_font.f_n;
+    }
+    if (!fonts_redone
+       && (T_COLOR(TScreenOf(curvt), TEXT_CURSOR) !=
+           T_COLOR(TScreenOf(newvt), TEXT_CURSOR))) {
+       if (set_cursor_gcs(newvt))
+           refresh_needed = True;
+    }
+    if (curvt->misc.re_verse != newvt->misc.re_verse) {
+       newvt->flags ^= REVERSE_VIDEO;
+       ReverseVideo(newvt);
+       /* ReverseVideo toggles */
+       newvt->misc.re_verse = (Boolean) (!newvt->misc.re_verse);
+       refresh_needed = True;
+    }
+    if ((T_COLOR(TScreenOf(curvt), MOUSE_FG) !=
+        T_COLOR(TScreenOf(newvt), MOUSE_FG)) ||
+       (T_COLOR(TScreenOf(curvt), MOUSE_BG) !=
+        T_COLOR(TScreenOf(newvt), MOUSE_BG))) {
+       recolor_cursor(TScreenOf(newvt),
+                      TScreenOf(newvt)->pointer_cursor,
+                      T_COLOR(TScreenOf(newvt), MOUSE_FG),
+                      T_COLOR(TScreenOf(newvt), MOUSE_BG));
+       refresh_needed = True;
+    }
+    if (curvt->misc.scrollbar != newvt->misc.scrollbar) {
+       ToggleScrollBar(newvt);
+    }
+
+    return refresh_needed;
+}
+
+#define setGC(code) set_at = __LINE__, currentCgs = code
+
+#define OutsideSelection(screen,srow,scol)  \
+        ((srow) > (screen)->endH.row || \
+         ((srow) == (screen)->endH.row && \
+          (scol) >= (screen)->endH.col) || \
+         (srow) < (screen)->startH.row || \
+         ((srow) == (screen)->startH.row && \
+          (scol) < (screen)->startH.col))
+
+/*
+ * Shows cursor at new cursor position in screen.
+ */
+void
+ShowCursor(void)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    int x, y;
+    IChar base;
+    unsigned flags;
+    CellColor fg_bg = 0;
+    GC currentGC;
+    GC outlineGC;
+    CgsEnum currentCgs = gcMAX;
+    VTwin *currentWin = WhichVWin(screen);
+    int set_at;
+    Bool in_selection;
+    Bool reversed;
+    Bool filled;
+    Pixel fg_pix;
+    Pixel bg_pix;
+    Pixel tmp;
+#if OPT_HIGHLIGHT_COLOR
+    Pixel selbg_pix = T_COLOR(screen, HIGHLIGHT_BG);
+    Pixel selfg_pix = T_COLOR(screen, HIGHLIGHT_FG);
+    Boolean use_selbg;
+    Boolean use_selfg;
+#endif
+#if OPT_WIDE_CHARS
+    size_t off;
+    int my_col = 0;
+#endif
+    int cursor_col;
+    LineData *ld = 0;
+
+    if (screen->cursor_state == BLINKED_OFF)
+       return;
+
+    if (screen->eventMode != NORMAL)
+       return;
+
+    if (INX2ROW(screen, screen->cur_row) > screen->max_row)
+       return;
+
+    screen->cursorp.row = screen->cur_row;
+    cursor_col = screen->cursorp.col = screen->cur_col;
+    screen->cursor_moved = False;
+
+#ifndef NO_ACTIVE_ICON
+    if (IsIcon(screen)) {
+       screen->cursor_state = ON;
+       return;
+    }
+#endif /* NO_ACTIVE_ICON */
+
+    ld = getLineData(screen, screen->cur_row);
+
+    base = ld->charData[cursor_col];
+    flags = ld->attribs[cursor_col];
+
+    if_OPT_WIDE_CHARS(screen, {
+       if (base == HIDDEN_CHAR && cursor_col > 0) {
+           /* if cursor points to non-initial part of wide character,
+            * back it up
+            */
+           --cursor_col;
+           base = ld->charData[cursor_col];
+       }
+       my_col = cursor_col;
+       if (base == 0)
+           base = ' ';
+       if (isWide((int) base))
+           my_col += 1;
+    });
+
+    if (base == 0) {
+       base = ' ';
+    }
+#if OPT_ISO_COLORS
+#ifdef EXP_BOGUS_FG
+    /*
+     * If the cursor happens to be on blanks, and we have not set both
+     * foreground and background color, do not treat it as a colored cell.
+     */
+    if (base == ' ') {
+       if ((flags & (FG_COLOR | BG_COLOR)) == BG_COLOR) {
+           TRACE(("ShowCursor - do not treat as a colored cell\n"));
+           flags &= ~(FG_COLOR | BG_COLOR);
+       } else if ((flags & (FG_COLOR | BG_COLOR)) == FG_COLOR) {
+           TRACE(("ShowCursor - should we treat as a colored cell?\n"));
+           if (!(xw->flags & FG_COLOR))
+               if (CheckBogusForeground(screen, "ShowCursor"))
+                   flags &= ~(FG_COLOR | BG_COLOR);
+       }
+    }
+#else /* !EXP_BOGUS_FG */
+    /*
+     * If the cursor happens to be on blanks, and the foreground color is set
+     * but not the background, do not treat it as a colored cell.
+     */
+    if ((flags & TERM_COLOR_FLAGS(xw)) == BG_COLOR
+       && base == ' ') {
+       flags &= ~TERM_COLOR_FLAGS(xw);
+    }
+#endif
+#endif
+
+    /*
+     * Compare the current cell to the last set of colors used for the
+     * cursor and update the GC's if needed.
+     */
+    if_OPT_ISO_COLORS(screen, {
+       fg_bg = ld->color[cursor_col];
+    });
+
+    fg_pix = getXtermForeground(xw, flags, extract_fg(xw, fg_bg, flags));
+    bg_pix = getXtermBackground(xw, flags, extract_bg(xw, fg_bg, flags));
+
+    if (OutsideSelection(screen, screen->cur_row, screen->cur_col))
+       in_selection = False;
+    else
+       in_selection = True;
+
+    reversed = ReverseOrHilite(screen, flags, in_selection);
+
+    /* This is like updatedXtermGC(), except that we have to worry about
+     * whether the window has focus, since in that case we want just an
+     * outline for the cursor.
+     */
+    filled = (screen->select || screen->always_highlight) && !screen->cursor_underline;
+#if OPT_HIGHLIGHT_COLOR
+    use_selbg = isNotForeground(xw, fg_pix, bg_pix, selbg_pix);
+    use_selfg = isNotBackground(xw, fg_pix, bg_pix, selfg_pix);
+#endif
+    if (filled) {
+       if (reversed) {         /* text is reverse video */
+           if (getCgsGC(xw, currentWin, gcVTcursNormal)) {
+               setGC(gcVTcursNormal);
+           } else {
+               if (flags & BOLDATTR(screen)) {
+                   setGC(gcBold);
+               } else {
+                   setGC(gcNorm);
+               }
+           }
+           EXCHANGE(fg_pix, bg_pix, tmp);
+#if OPT_HIGHLIGHT_COLOR
+           if (screen->hilite_reverse) {
+               if (use_selbg && !use_selfg)
+                   fg_pix = bg_pix;
+               if (use_selfg && !use_selbg)
+                   bg_pix = fg_pix;
+               if (use_selbg)
+                   bg_pix = selbg_pix;
+               if (use_selfg)
+                   fg_pix = selfg_pix;
+           }
+#endif
+       } else {                /* normal video */
+           if (getCgsGC(xw, currentWin, gcVTcursReverse)) {
+               setGC(gcVTcursReverse);
+           } else {
+               if (flags & BOLDATTR(screen)) {
+                   setGC(gcBoldReverse);
+               } else {
+                   setGC(gcNormReverse);
+               }
+           }
+       }
+       if (T_COLOR(screen, TEXT_CURSOR) == xw->dft_foreground) {
+           setCgsBack(xw, currentWin, currentCgs, fg_pix);
+       }
+       setCgsFore(xw, currentWin, currentCgs, bg_pix);
+    } else {                   /* not selected */
+       if (reversed) {         /* text is reverse video */
+           EXCHANGE(fg_pix, bg_pix, tmp);
+           setGC(gcNormReverse);
+       } else {                /* normal video */
+           setGC(gcNorm);
+       }
+#if OPT_HIGHLIGHT_COLOR
+       if (screen->hilite_reverse) {
+           if (in_selection && !reversed) {
+               /* EMPTY */
+               /* really INVERSE ... */
+               ;
+           } else if (in_selection || reversed) {
+               if (use_selbg) {
+                   if (use_selfg) {
+                       bg_pix = fg_pix;
+                   } else {
+                       fg_pix = bg_pix;
+                   }
+               }
+               if (use_selbg) {
+                   bg_pix = selbg_pix;
+               }
+               if (use_selfg) {
+                   fg_pix = selfg_pix;
+               }
+           }
+       } else {
+           if (in_selection) {
+               if (use_selbg) {
+                   bg_pix = selbg_pix;
+               }
+               if (use_selfg) {
+                   fg_pix = selfg_pix;
+               }
+           }
+       }
+#endif
+       setCgsFore(xw, currentWin, currentCgs, fg_pix);
+       setCgsBack(xw, currentWin, currentCgs, bg_pix);
+    }
+
+    if (screen->cursor_busy == 0
+       && (screen->cursor_state != ON || screen->cursor_GC != set_at)) {
+
+       screen->cursor_GC = set_at;
+       TRACE(("ShowCursor calling drawXtermText cur(%d,%d) %s-%s, set_at %d\n",
+              screen->cur_row, screen->cur_col,
+              (filled ? "filled" : "outline"),
+              (screen->cursor_underline ? "underline" : "box"),
+              set_at));
+
+       currentGC = getCgsGC(xw, currentWin, currentCgs);
+       x = LineCursorX(screen, ld, cursor_col);
+       y = CursorY(screen, screen->cur_row);
+
+       if (screen->cursor_underline) {
+           /*
+            * Overriding the combination of filled, reversed, in_selection is
+            * too complicated since the underline and the text-cell use
+            * different rules.  Just redraw the text-cell, and draw the
+            * underline on top of it.
+            */
+           HideCursor();
+
+           /*
+            * Our current-GC is likely to have been modified in HideCursor().
+            * Set up a new request.
+            */
+           if (filled) {
+               if (T_COLOR(screen, TEXT_CURSOR) == xw->dft_foreground) {
+                   setCgsBack(xw, currentWin, currentCgs, fg_pix);
+               }
+               setCgsFore(xw, currentWin, currentCgs, bg_pix);
+           } else {
+               setCgsFore(xw, currentWin, currentCgs, fg_pix);
+               setCgsBack(xw, currentWin, currentCgs, bg_pix);
+           }
+       }
+
+       /*
+        * Update the outline-gc, to keep the cursor color distinct from the
+        * background color.
+        */
+       set_cursor_outline_gc(xw,
+                             filled,
+                             fg_pix,
+                             bg_pix,
+                             T_COLOR(screen, TEXT_CURSOR));
+
+       outlineGC = getCgsGC(xw, currentWin, gcVTcursOutline);
+       if (outlineGC == 0)
+           outlineGC = currentGC;
+
+       if (screen->cursor_underline) {
+
+           /*
+            * Finally, draw the underline.
+            */
+           screen->box->x = (short) x;
+           screen->box->y = (short) (y + FontHeight(screen) - 2);
+           XDrawLines(screen->display, VWindow(screen), outlineGC,
+                      screen->box, NBOX, CoordModePrevious);
+       } else {
+
+           drawXtermText(xw, flags & DRAWX_MASK,
+                         currentGC, x, y,
+                         LineCharSet(screen, ld),
+                         &base, 1, 0);
+
+#if OPT_WIDE_CHARS
+           if_OPT_WIDE_CHARS(screen, {
+               for_each_combData(off, ld) {
+                   if (!(ld->combData[off][my_col]))
+                       break;
+                   drawXtermText(xw, (flags & DRAWX_MASK) | NOBACKGROUND,
+                                 currentGC, x, y,
+                                 LineCharSet(screen, ld),
+                                 ld->combData[off] + my_col,
+                                 1, isWide((int) base));
+               }
+           });
+#endif
+
+           if (!filled) {
+               screen->box->x = (short) x;
+               screen->box->y = (short) y;
+               XDrawLines(screen->display, VWindow(screen), outlineGC,
+                          screen->box, NBOX, CoordModePrevious);
+           }
+       }
+    }
+    screen->cursor_state = ON;
+
+    return;
+}
+
+/*
+ * hide cursor at previous cursor position in screen.
+ */
+void
+HideCursor(void)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    GC currentGC;
+    int x, y;
+    IChar base;
+    unsigned flags;
+    CellColor fg_bg = 0;
+    Bool in_selection;
+#if OPT_WIDE_CHARS
+    size_t off;
+    int my_col = 0;
+#endif
+    int cursor_col;
+    LineData *ld = 0;
+
+    if (screen->cursor_state == OFF)
+       return;
+    if (INX2ROW(screen, screen->cursorp.row) > screen->max_row)
+       return;
+
+    cursor_col = screen->cursorp.col;
+
+#ifndef NO_ACTIVE_ICON
+    if (IsIcon(screen)) {
+       screen->cursor_state = OFF;
+       return;
+    }
+#endif /* NO_ACTIVE_ICON */
+
+    ld = getLineData(screen, screen->cursorp.row);
+
+    base = ld->charData[cursor_col];
+    flags = ld->attribs[cursor_col];
+
+    if_OPT_WIDE_CHARS(screen, {
+       if (base == HIDDEN_CHAR && cursor_col > 0) {
+           /* if cursor points to non-initial part of wide character,
+            * back it up
+            */
+           --cursor_col;
+           base = ld->charData[cursor_col];
+       }
+       my_col = cursor_col;
+       if (base == 0)
+           base = ' ';
+       if (isWide((int) base))
+           my_col += 1;
+    });
+
+    if (base == 0) {
+       base = ' ';
+    }
+#ifdef EXP_BOGUS_FG
+    /*
+     * If the cursor happens to be on blanks, and we have not set both
+     * foreground and background color, do not treat it as a colored cell.
+     */
+#if OPT_ISO_COLORS
+    if (base == ' ') {
+       if ((flags & (FG_COLOR | BG_COLOR)) == BG_COLOR) {
+           TRACE(("HideCursor - do not treat as a colored cell\n"));
+           flags &= ~(FG_COLOR | BG_COLOR);
+       } else if ((flags & (FG_COLOR | BG_COLOR)) == FG_COLOR) {
+           TRACE(("HideCursor - should we treat as a colored cell?\n"));
+           if (!(xw->flags & FG_COLOR))
+               if (CheckBogusForeground(screen, "HideCursor"))
+                   flags &= ~(FG_COLOR | BG_COLOR);
+       }
+    }
+#endif
+#endif
+#if OPT_ISO_COLORS
+    fg_bg = 0;
+#endif
+
+    /*
+     * Compare the current cell to the last set of colors used for the
+     * cursor and update the GC's if needed.
+     */
+    if_OPT_ISO_COLORS(screen, {
+       fg_bg = ld->color[cursor_col];
+    });
+
+    if (OutsideSelection(screen, screen->cursorp.row, screen->cursorp.col))
+       in_selection = False;
+    else
+       in_selection = True;
+
+    currentGC = updatedXtermGC(xw, flags, fg_bg, in_selection);
+
+    TRACE(("HideCursor calling drawXtermText cur(%d,%d)\n",
+          screen->cursorp.row, screen->cursorp.col));
+
+    x = LineCursorX(screen, ld, cursor_col);
+    y = CursorY(screen, screen->cursorp.row);
+
+    drawXtermText(xw, flags & DRAWX_MASK,
+                 currentGC, x, y,
+                 LineCharSet(screen, ld),
+                 &base, 1, 0);
+
+#if OPT_WIDE_CHARS
+    if_OPT_WIDE_CHARS(screen, {
+       for_each_combData(off, ld) {
+           if (!(ld->combData[off][my_col]))
+               break;
+           drawXtermText(xw, (flags & DRAWX_MASK) | NOBACKGROUND,
+                         currentGC, x, y,
+                         LineCharSet(screen, ld),
+                         ld->combData[off] + my_col,
+                         1, isWide((int) base));
+       }
+    });
+#endif
+    screen->cursor_state = OFF;
+    resetXtermGC(xw, flags, in_selection);
+
+    return;
+}
+
+#if OPT_BLINK_CURS || OPT_BLINK_TEXT
+static void
+StartBlinking(TScreen * screen)
+{
+    if (screen->blink_timer == 0) {
+       unsigned long interval = (unsigned long) ((screen->cursor_state == ON)
+                                                 ? screen->blink_on
+                                                 : screen->blink_off);
+       if (interval == 0)      /* wow! */
+           interval = 1;       /* let's humor him anyway */
+       screen->blink_timer = XtAppAddTimeOut(app_con,
+                                             interval,
+                                             HandleBlinking,
+                                             screen);
+    }
+}
+
+static void
+StopBlinking(TScreen * screen)
+{
+    if (screen->blink_timer)
+       XtRemoveTimeOut(screen->blink_timer);
+    screen->blink_timer = 0;
+}
+
+#if OPT_BLINK_TEXT
+static Bool
+LineHasBlinking(TScreen * screen, LineData * ld)
+{
+    int col;
+    Bool result = False;
+
+    for (col = 0; col < MaxCols(screen); ++col) {
+       if (ld->attribs[col] & BLINK) {
+           result = True;
+           break;
+       }
+    }
+    return result;
+}
+#endif
+
+/*
+ * Blink the cursor by alternately showing/hiding cursor.  We leave the timer
+ * running all the time (even though that's a little inefficient) to make the
+ * logic simple.
+ */
+static void
+HandleBlinking(XtPointer closure, XtIntervalId * id GCC_UNUSED)
+{
+    TScreen *screen = (TScreen *) closure;
+    Bool resume = False;
+
+    screen->blink_timer = 0;
+    screen->blink_state = !screen->blink_state;
+
+#if OPT_BLINK_CURS
+    if (DoStartBlinking(screen)) {
+       if (screen->cursor_state == ON) {
+           if (screen->select || screen->always_highlight) {
+               HideCursor();
+               if (screen->cursor_state == OFF)
+                   screen->cursor_state = BLINKED_OFF;
+           }
+       } else if (screen->cursor_state == BLINKED_OFF) {
+           screen->cursor_state = OFF;
+           ShowCursor();
+           if (screen->cursor_state == OFF)
+               screen->cursor_state = BLINKED_OFF;
+       }
+       resume = True;
+    }
+#endif
+
+#if OPT_BLINK_TEXT
+    /*
+     * Inspect the lines on the current screen to see if any have the BLINK flag
+     * associated with them.  Prune off any that have had the corresponding
+     * cells reset.  If any are left, repaint those lines with ScrnRefresh().
+     */
+    if (!(screen->blink_as_bold)) {
+       int row;
+       int first_row = screen->max_row;
+       int last_row = -1;
+
+       for (row = screen->max_row; row >= 0; row--) {
+           LineData *ld = getLineData(screen, ROW2INX(screen, row));
+
+           if (ld != 0 && LineTstBlinked(ld)) {
+               if (LineHasBlinking(screen, ld)) {
+                   resume = True;
+                   if (row > last_row)
+                       last_row = row;
+                   if (row < first_row)
+                       first_row = row;
+               } else {
+                   LineClrBlinked(ld);
+               }
+           }
+       }
+       /*
+        * FIXME: this could be a little more efficient, e.g,. by limiting the
+        * columns which are updated.
+        */
+       if (first_row <= last_row) {
+           ScrnRefresh(term,
+                       first_row,
+                       0,
+                       last_row + 1 - first_row,
+                       MaxCols(screen),
+                       True);
+       }
+    }
+#endif
+
+    /*
+     * If either the cursor or text is blinking, restart the timer.
+     */
+    if (resume)
+       StartBlinking(screen);
+}
+#endif /* OPT_BLINK_CURS || OPT_BLINK_TEXT */
+
+void
+RestartBlinking(TScreen * screen GCC_UNUSED)
+{
+#if OPT_BLINK_CURS || OPT_BLINK_TEXT
+    if (screen->blink_timer == 0) {
+       Bool resume = False;
+
+#if OPT_BLINK_CURS
+       if (DoStartBlinking(screen)) {
+           resume = True;
+       }
+#endif
+#if OPT_BLINK_TEXT
+       if (!resume) {
+           int row;
+
+           for (row = screen->max_row; row >= 0; row--) {
+               LineData *ld = getLineData(screen, ROW2INX(screen, row));
+
+               if (ld != 0 && LineTstBlinked(ld)) {
+                   if (LineHasBlinking(screen, ld)) {
+                       resume = True;
+                       break;
+                   }
+               }
+           }
+       }
+#endif
+       if (resume)
+           StartBlinking(screen);
+    }
+#endif
+}
+
+/*
+ * Implement soft or hard (full) reset of the VTxxx emulation.  There are a
+ * couple of differences from real DEC VTxxx terminals (to avoid breaking
+ * applications which have come to rely on xterm doing this):
+ *
+ *     + autowrap mode should be reset (instead it's reset to the resource
+ *       default).
+ *     + the popup menu offers a choice of resetting the savedLines, or not.
+ *       (but the control sequence does this anyway).
+ */
+void
+VTReset(XtermWidget xw, Bool full, Bool saved)
+{
+    static char empty[1];
+
+    TScreen *screen = TScreenOf(xw);
+
+    if (!XtIsRealized((Widget) xw) || (CURRENT_EMU() != (Widget) xw)) {
+       Bell(xw, XkbBI_MinorError, 0);
+       return;
+    }
+
+    if (saved) {
+       screen->savedlines = 0;
+       ScrollBarDrawThumb(screen->scrollWidget);
+    }
+
+    /* make cursor visible */
+    screen->cursor_set = ON;
+
+    /* reset scrolling region */
+    set_tb_margins(screen, 0, screen->max_row);
+
+    bitclr(&xw->flags, ORIGIN);
+
+    if_OPT_ISO_COLORS(screen, {
+       reset_SGR_Colors(xw);
+       if (ResetAnsiColorRequest(xw, empty, 0))
+           xtermRepaint(xw);
+    });
+
+    /* Reset character-sets to initial state */
+    resetCharsets(screen);
+
+#if OPT_MOD_FKEYS
+    /* Reset modifier-resources to initial state */
+    xw->keyboard.modify_now = xw->keyboard.modify_1st;
+#endif
+
+    /* Reset DECSCA */
+    bitclr(&xw->flags, PROTECTED);
+    screen->protected_mode = OFF_PROTECT;
+
+    if (full) {                        /* RIS */
+       if (screen->bellOnReset)
+           Bell(xw, XkbBI_TerminalBell, 0);
+
+       /* reset the mouse mode */
+       screen->send_mouse_pos = MOUSE_OFF;
+       screen->send_focus_pos = OFF;
+       screen->ext_mode_mouse = OFF;
+       screen->waitingForTrackInfo = False;
+       screen->eventMode = NORMAL;
+
+       xtermShowPointer(xw, True);
+
+       TabReset(xw->tabs);
+       xw->keyboard.flags = MODE_SRM;
+#if OPT_INITIAL_ERASE
+       if (xw->keyboard.reset_DECBKM == 1)
+           xw->keyboard.flags |= MODE_DECBKM;
+       else if (xw->keyboard.reset_DECBKM == 2)
+#endif
+           if (TScreenOf(xw)->backarrow_key)
+               xw->keyboard.flags |= MODE_DECBKM;
+       TRACE(("full reset DECBKM %s\n",
+              BtoS(xw->keyboard.flags & MODE_DECBKM)));
+       update_appcursor();
+       update_appkeypad();
+       update_decbkm();
+       show_8bit_control(False);
+       reset_decudk();
+
+       FromAlternate(xw);
+       ClearScreen(xw);
+       screen->cursor_state = OFF;
+       if (xw->flags & REVERSE_VIDEO)
+           ReverseVideo(xw);
+
+       xw->flags = xw->initflags;
+       update_reversevideo();
+       update_autowrap();
+       update_reversewrap();
+       update_autolinefeed();
+
+       screen->jumpscroll = (Boolean) (!(xw->flags & SMOOTHSCROLL));
+       update_jumpscroll();
+
+       if (screen->c132 && (xw->flags & IN132COLUMNS)) {
+           Dimension reqWidth = (Dimension) (80 * FontWidth(screen)
+                                             + 2 * screen->border
+                                             + ScrollbarWidth(screen));
+           Dimension reqHeight = (Dimension) (FontHeight(screen)
+                                              * MaxRows(screen)
+                                              + 2 * screen->border);
+           Dimension replyWidth;
+           Dimension replyHeight;
+
+           TRACE(("Making resize-request to restore 80-columns %dx%d\n",
+                  reqHeight, reqWidth));
+           REQ_RESIZE((Widget) xw,
+                      reqWidth,
+                      reqHeight,
+                      &replyWidth, &replyHeight);
+           repairSizeHints();
+           XSync(screen->display, False);      /* synchronize */
+           if (XtAppPending(app_con))
+               xevents();
+       }
+
+       CursorSet(screen, 0, 0, xw->flags);
+       CursorSave(xw);
+    } else {                   /* DECSTR */
+       /*
+        * There's a tiny difference, to accommodate usage of xterm.
+        * We reset autowrap to the resource values rather than turning
+        * it off.
+        */
+       UIntClr(xw->keyboard.flags, (MODE_DECCKM | MODE_KAM | MODE_DECKPAM));
+       bitcpy(&xw->flags, xw->initflags, WRAPAROUND | REVERSEWRAP);
+       bitclr(&xw->flags, INSERT | INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE);
+       if_OPT_ISO_COLORS(screen, {
+           reset_SGR_Colors(xw);
+       });
+       update_appcursor();
+       update_autowrap();
+       update_reversewrap();
+
+       CursorSave(xw);
+       screen->sc[screen->whichBuf].row =
+           screen->sc[screen->whichBuf].col = 0;
+    }
+    longjmp(vtjmpbuf, 1);      /* force ground state in parser */
+}
+
+/*
+ * set_character_class - takes a string of the form
+ *
+ *   low[-high]:val[,low[-high]:val[...]]
+ *
+ * and sets the indicated ranges to the indicated values.
+ */
+static int
+set_character_class(char *s)
+{
+    int i;                     /* iterator, index into s */
+    int len;                   /* length of s */
+    int acc;                   /* accumulator */
+    int low, high;             /* bounds of range [0..127] */
+    int base;                  /* 8, 10, 16 (octal, decimal, hex) */
+    int numbers;               /* count of numbers per range */
+    int digits;                        /* count of digits in a number */
+    static const char errfmt[] = "%s:  %s in range string \"%s\" (position %d)\n";
+
+    if (!s || !s[0])
+       return -1;
+
+    base = 10;                 /* in case we ever add octal, hex */
+    low = high = -1;           /* out of range */
+
+    for (i = 0, len = (int) strlen(s), acc = 0, numbers = digits = 0;
+        i < len; i++) {
+       Char c = CharOf(s[i]);
+
+       if (isspace(c)) {
+           continue;
+       } else if (isdigit(c)) {
+           acc = acc * base + (c - '0');
+           digits++;
+           continue;
+       } else if (c == '-') {
+           low = acc;
+           acc = 0;
+           if (digits == 0) {
+               fprintf(stderr, errfmt, ProgramName, "missing number", s, i);
+               return (-1);
+           }
+           digits = 0;
+           numbers++;
+           continue;
+       } else if (c == ':') {
+           if (numbers == 0)
+               low = acc;
+           else if (numbers == 1)
+               high = acc;
+           else {
+               fprintf(stderr, errfmt, ProgramName, "too many numbers",
+                       s, i);
+               return (-1);
+           }
+           digits = 0;
+           numbers++;
+           acc = 0;
+           continue;
+       } else if (c == ',') {
+           /*
+            * now, process it
+            */
+
+           if (high < 0) {
+               high = low;
+               numbers++;
+           }
+           if (numbers != 2) {
+               fprintf(stderr, errfmt, ProgramName, "bad value number",
+                       s, i);
+           } else if (SetCharacterClassRange(low, high, acc) != 0) {
+               fprintf(stderr, errfmt, ProgramName, "bad range", s, i);
+           }
+
+           low = high = -1;
+           acc = 0;
+           digits = 0;
+           numbers = 0;
+           continue;
+       } else {
+           fprintf(stderr, errfmt, ProgramName, "bad character", s, i);
+           return (-1);
+       }                       /* end if else if ... else */
+
+    }
+
+    if (low < 0 && high < 0)
+       return (0);
+
+    /*
+     * now, process it
+     */
+
+    if (high < 0)
+       high = low;
+    if (numbers < 1 || numbers > 2) {
+       fprintf(stderr, errfmt, ProgramName, "bad value number", s, i);
+    } else if (SetCharacterClassRange(low, high, acc) != 0) {
+       fprintf(stderr, errfmt, ProgramName, "bad range", s, i);
+    }
+
+    return (0);
+}
+
+/* ARGSUSED */
+static void
+HandleKeymapChange(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    static XtTranslations keymap, original;
+    static XtResource key_resources[] =
+    {
+       {XtNtranslations, XtCTranslations, XtRTranslationTable,
+        sizeof(XtTranslations), 0, XtRTranslationTable, (XtPointer) NULL}
+    };
+    char mapName[1000];
+    char mapClass[1000];
+    char *pmapName;
+    char *pmapClass;
+    size_t len;
+
+    if (*param_count != 1)
+       return;
+
+    if (original == NULL)
+       original = w->core.tm.translations;
+
+    if (strcmp(params[0], "None") == 0) {
+       XtOverrideTranslations(w, original);
+       return;
+    }
+
+    len = strlen(params[0]) + 7;
+
+    pmapName = (char *) MyStackAlloc(len, mapName);
+    pmapClass = (char *) MyStackAlloc(len, mapClass);
+    if (pmapName == NULL
+       || pmapClass == NULL) {
+       SysError(ERROR_KMMALLOC1);
+    } else {
+
+       (void) sprintf(pmapName, "%sKeymap", params[0]);
+       (void) strcpy(pmapClass, pmapName);
+       if (islower(CharOf(pmapClass[0])))
+           pmapClass[0] = x_toupper(pmapClass[0]);
+       XtGetSubresources(w, (XtPointer) &keymap, pmapName, pmapClass,
+                         key_resources, (Cardinal) 1, NULL, (Cardinal) 0);
+       if (keymap != NULL)
+           XtOverrideTranslations(w, keymap);
+
+       MyStackFree(pmapName, mapName);
+       MyStackFree(pmapClass, mapClass);
+    }
+}
+
+/* ARGSUSED */
+static void
+HandleBell(Widget w GCC_UNUSED,
+          XEvent * event GCC_UNUSED,
+          String * params,     /* [0] = volume */
+          Cardinal *param_count)       /* 0 or 1 */
+{
+    int percent = (*param_count) ? atoi(params[0]) : 0;
+
+    Bell(term, XkbBI_TerminalBell, percent);
+}
+
+/* ARGSUSED */
+static void
+HandleVisualBell(Widget w GCC_UNUSED,
+                XEvent * event GCC_UNUSED,
+                String * params GCC_UNUSED,
+                Cardinal *param_count GCC_UNUSED)
+{
+    VisualBell();
+}
+
+/* ARGSUSED */
+static void
+HandleIgnore(Widget w,
+            XEvent * event,
+            String * params GCC_UNUSED,
+            Cardinal *param_count GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    TRACE(("Handle ignore for %p\n", (void *) w));
+    if ((xw = getXtermWidget(w)) != 0) {
+       /* do nothing, but check for funny escape sequences */
+       (void) SendMousePosition(xw, event);
+    }
+}
+
+/* ARGSUSED */
+static void
+DoSetSelectedFont(Widget w,
+                 XtPointer client_data GCC_UNUSED,
+                 Atom * selection GCC_UNUSED,
+                 Atom * type,
+                 XtPointer value,
+                 unsigned long *length,
+                 int *format)
+{
+    XtermWidget xw = getXtermWidget(w);
+
+    if ((xw == 0) || *type != XA_STRING || *format != 8) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+       Boolean failed = False;
+       int oldFont = TScreenOf(xw)->menu_font_number;
+       String save = TScreenOf(xw)->MenuFontName(fontMenu_fontsel);
+       char *val;
+       char *test = 0;
+       char *used = 0;
+       unsigned len = (unsigned) *length;
+       unsigned tst;
+
+       /*
+        * Some versions of X deliver null-terminated selections, some do not.
+        */
+       for (tst = 0; tst < len; ++tst) {
+           if (((char *) value)[tst] == '\0') {
+               len = tst;
+               break;
+           }
+       }
+
+       if (len > 0 && (val = TypeMallocN(char, len + 1)) != 0) {
+           memcpy(val, value, (size_t) len);
+           val[len] = '\0';
+           used = x_strtrim(val);
+           TRACE(("DoSetSelectedFont(%s)\n", used));
+           /* Do some sanity checking to avoid sending a long selection
+              back to the server in an OpenFont that is unlikely to succeed.
+              XLFD allows up to 255 characters and no control characters;
+              we are a little more liberal here. */
+           if (len < 1000
+               && !strchr(used, '\n')
+               && (test = x_strdup(used)) != 0) {
+               TScreenOf(xw)->MenuFontName(fontMenu_fontsel) = test;
+               if (!xtermLoadFont(term,
+                                  xtermFontName(used),
+                                  True,
+                                  fontMenu_fontsel)) {
+                   failed = True;
+                   free(test);
+                   TScreenOf(xw)->MenuFontName(fontMenu_fontsel) = save;
+               }
+           } else {
+               failed = True;
+           }
+           if (failed) {
+               (void) xtermLoadFont(term,
+                                    xtermFontName(TScreenOf(xw)->MenuFontName(oldFont)),
+                                    True,
+                                    oldFont);
+               Bell(xw, XkbBI_MinorError, 0);
+           }
+           free(used);
+           free(val);
+       }
+    }
+}
+
+void
+FindFontSelection(XtermWidget xw, const char *atom_name, Bool justprobe)
+{
+    TScreen *screen = TScreenOf(xw);
+    static AtomPtr *atoms;
+    unsigned int atomCount = 0;
+    AtomPtr *pAtom;
+    unsigned a;
+    Atom target;
+
+    if (!atom_name)
+       atom_name = (screen->mappedSelect
+                    ? screen->mappedSelect[0]
+                    : "PRIMARY");
+    TRACE(("FindFontSelection(%s)\n", atom_name));
+
+    for (pAtom = atoms, a = atomCount; a; a--, pAtom++) {
+       if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0)
+           break;
+    }
+    if (!a) {
+       atoms = TypeXtReallocN(AtomPtr, atoms, atomCount + 1);
+       *(pAtom = &atoms[atomCount]) = XmuMakeAtom(atom_name);
+    }
+
+    target = XmuInternAtom(XtDisplay(xw), *pAtom);
+    if (justprobe) {
+       screen->MenuFontName(fontMenu_fontsel) =
+           XGetSelectionOwner(XtDisplay(xw), target) ? _Font_Selected_ : 0;
+       TRACE(("...selected fontname '%s'\n",
+              NonNull(screen->MenuFontName(fontMenu_fontsel))));
+    } else {
+       XtGetSelectionValue((Widget) xw, target, XA_STRING,
+                           DoSetSelectedFont, NULL,
+                           XtLastTimestampProcessed(XtDisplay(xw)));
+    }
+    return;
+}
+
+Bool
+set_cursor_gcs(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+
+    Pixel cc = T_COLOR(screen, TEXT_CURSOR);
+    Pixel fg = T_COLOR(screen, TEXT_FG);
+    Pixel bg = T_COLOR(screen, TEXT_BG);
+    Bool changed = False;
+
+    /*
+     * Let's see, there are three things that have "color":
+     *
+     *     background
+     *     text
+     *     cursorblock
+     *
+     * And, there are four situations when drawing a cursor, if we decide
+     * that we like have a solid block of cursor color with the letter
+     * that it is highlighting shown in the background color to make it
+     * stand out:
+     *
+     *     selected window, normal video - background on cursor
+     *     selected window, reverse video - foreground on cursor
+     *     unselected window, normal video - foreground on background
+     *     unselected window, reverse video - background on foreground
+     *
+     * Since the last two are really just normalGC and reverseGC, we only
+     * need two new GC's.  Under monochrome, we get the same effect as
+     * above by setting cursor color to foreground.
+     */
+
+    TRACE(("set_cursor_gcs cc=%#lx, fg=%#lx, bg=%#lx\n", cc, fg, bg));
+    if (win != 0 && (cc != bg)) {
+       /* set the fonts to the current one */
+       setCgsFont(xw, win, gcVTcursNormal, 0);
+       setCgsFont(xw, win, gcVTcursFilled, 0);
+       setCgsFont(xw, win, gcVTcursReverse, 0);
+       setCgsFont(xw, win, gcVTcursOutline, 0);
+
+       /* we have a colored cursor */
+       setCgsFore(xw, win, gcVTcursNormal, fg);
+       setCgsBack(xw, win, gcVTcursNormal, cc);
+
+       setCgsFore(xw, win, gcVTcursFilled, cc);
+       setCgsBack(xw, win, gcVTcursFilled, fg);
+
+       if (screen->always_highlight) {
+           /* both GC's use the same color */
+           setCgsFore(xw, win, gcVTcursReverse, bg);
+           setCgsBack(xw, win, gcVTcursReverse, cc);
+       } else {
+           setCgsFore(xw, win, gcVTcursReverse, bg);
+           setCgsBack(xw, win, gcVTcursReverse, cc);
+       }
+       set_cursor_outline_gc(xw, screen->always_highlight, fg, bg, cc);
+       changed = True;
+    }
+
+    if (changed) {
+       TRACE(("...set_cursor_gcs - done\n"));
+    }
+    return changed;
+}
+
+#ifdef NO_LEAKS
+void
+noleaks_charproc(void)
+{
+    if (v_buffer != 0)
+       free(v_buffer);
+}
+#endif
diff --git a/charsets.c b/charsets.c
new file mode 100644 (file)
index 0000000..ff8cd88
--- /dev/null
@@ -0,0 +1,486 @@
+/* $XTermId: charsets.c,v 1.41 2009/01/25 23:39:12 tom Exp $ */
+
+/************************************************************
+
+Copyright 1998-2008,2009 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <xterm.h>
+#include <data.h>
+#include <fontutils.h>
+
+#include <X11/keysym.h>
+
+/*
+ * This module performs translation as needed to support the DEC VT220 national
+ * replacement character sets.  We assume that xterm's font is based on the ISO
+ * 8859-1 (Latin 1) character set, which is almost the same as the DEC
+ * multinational character set.  Glyph positions 0-31 have to be the DEC
+ * graphic characters, though.
+ *
+ * References:
+ *     "VT220 Programmer Pocket Guide" EK-VT220-HR-002 (2nd ed., 1984), which
+ *             contains character charts for the national character sets.
+ *     "VT330/VT340 Programmer Reference Manual Volume 1: Text Programming"
+ *             EK-VT3XX-TP-001 (1st ed, 1987), which contains a table (2-1)
+ *             listing the glyphs which are mapped from the multinational
+ *             character set to the national character set.
+ *
+ * The latter reference, though easier to read, has a few errors and omissions.
+ */
+
+/*
+ * Translate an input keysym to the corresponding NRC keysym.
+ */
+unsigned
+xtermCharSetIn(unsigned code, int charset)
+{
+#define MAP(to, from) case from: code = to; break
+
+    if (code >= 128 && code < 256) {
+       switch (charset) {
+       case 'A':               /* United Kingdom set (or Latin 1)      */
+           if (code == XK_sterling)
+               code = 0x23;
+           code &= 0x7f;
+           break;
+
+#if OPT_XMC_GLITCH
+       case '?':
+#endif
+       case '1':               /* Alternate Character ROM standard characters */
+       case '2':               /* Alternate Character ROM special graphics */
+       case 'B':               /* ASCII set                            */
+           break;
+
+       case '0':               /* special graphics (line drawing)      */
+           break;
+
+       case '4':               /* Dutch */
+           switch (code) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_threequarters);
+               MAP(0x5b, XK_ydiaeresis);
+               MAP(0x5c, XK_onehalf);
+               MAP(0x5d, XK_bar);      /* glyph is not ISO-8859-1 */
+               MAP(0x7b, XK_diaeresis);
+               MAP(0x7c, XK_f);        /* glyph is not ISO-8859-1 */
+               MAP(0x7d, XK_onequarter);
+               MAP(0x7e, XK_acute);
+           }
+           break;
+
+       case 'C':
+       case '5':               /* Finnish */
+           switch (code) {
+               MAP(0x5b, XK_Adiaeresis);
+               MAP(0x5c, XK_Odiaeresis);
+               MAP(0x5d, XK_Aring);
+               MAP(0x5e, XK_Udiaeresis);
+               MAP(0x60, XK_eacute);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_aring);
+               MAP(0x7e, XK_udiaeresis);
+           }
+           break;
+
+       case 'R':               /* French */
+           switch (code) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_agrave);
+               MAP(0x5b, XK_degree);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_section);
+               MAP(0x7b, XK_eacute);
+               MAP(0x7c, XK_ugrave);
+               MAP(0x7d, XK_egrave);
+               MAP(0x7e, XK_diaeresis);
+           }
+           break;
+
+       case 'Q':               /* French Canadian */
+           switch (code) {
+               MAP(0x40, XK_agrave);
+               MAP(0x5b, XK_acircumflex);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_ecircumflex);
+               MAP(0x5e, XK_icircumflex);
+               MAP(0x60, XK_ocircumflex);
+               MAP(0x7b, XK_eacute);
+               MAP(0x7c, XK_ugrave);
+               MAP(0x7d, XK_egrave);
+               MAP(0x7e, XK_ucircumflex);
+           }
+           break;
+
+       case 'K':               /* German */
+           switch (code) {
+               MAP(0x40, XK_section);
+               MAP(0x5b, XK_Adiaeresis);
+               MAP(0x5c, XK_Odiaeresis);
+               MAP(0x5d, XK_Udiaeresis);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_udiaeresis);
+               MAP(0x7e, XK_ssharp);
+           }
+           break;
+
+       case 'Y':               /* Italian */
+           switch (code) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_section);
+               MAP(0x5b, XK_degree);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_eacute);
+               MAP(0x60, XK_ugrave);
+               MAP(0x7b, XK_agrave);
+               MAP(0x7c, XK_ograve);
+               MAP(0x7d, XK_egrave);
+               MAP(0x7e, XK_igrave);
+           }
+           break;
+
+       case 'E':
+       case '6':               /* Norwegian/Danish */
+           switch (code) {
+               MAP(0x40, XK_Adiaeresis);
+               MAP(0x5b, XK_AE);
+               MAP(0x5c, XK_Ooblique);
+               MAP(0x5d, XK_Aring);
+               MAP(0x5e, XK_Udiaeresis);
+               MAP(0x60, XK_adiaeresis);
+               MAP(0x7b, XK_ae);
+               MAP(0x7c, XK_oslash);
+               MAP(0x7d, XK_aring);
+               MAP(0x7e, XK_udiaeresis);
+           }
+           break;
+
+       case 'Z':               /* Spanish */
+           switch (code) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_section);
+               MAP(0x5b, XK_exclamdown);
+               MAP(0x5c, XK_Ntilde);
+               MAP(0x5d, XK_questiondown);
+               MAP(0x7b, XK_degree);
+               MAP(0x7c, XK_ntilde);
+               MAP(0x7d, XK_ccedilla);
+           }
+           break;
+
+       case 'H':
+       case '7':               /* Swedish */
+           switch (code) {
+               MAP(0x40, XK_Eacute);
+               MAP(0x5b, XK_Adiaeresis);
+               MAP(0x5c, XK_Odiaeresis);
+               MAP(0x5d, XK_Aring);
+               MAP(0x5e, XK_Udiaeresis);
+               MAP(0x60, XK_eacute);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_aring);
+               MAP(0x7e, XK_udiaeresis);
+           }
+           break;
+
+       case '=':               /* Swiss */
+           switch (code) {
+               MAP(0x23, XK_ugrave);
+               MAP(0x40, XK_agrave);
+               MAP(0x5b, XK_eacute);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_ecircumflex);
+               MAP(0x5e, XK_icircumflex);
+               MAP(0x5f, XK_egrave);
+               MAP(0x60, XK_ocircumflex);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_udiaeresis);
+               MAP(0x7e, XK_ucircumflex);
+           }
+           break;
+
+       default:                /* any character sets we don't recognize */
+           break;
+       }
+       code &= 0x7f;           /* NRC in any case is 7-bit */
+    }
+    return code;
+#undef MAP
+}
+
+/*
+ * Translate a string to the display form.  This assumes the font has the
+ * DEC graphic characters in cells 0-31, and otherwise is ISO-8859-1.
+ */
+int
+xtermCharSetOut(XtermWidget xw, IChar * buf, IChar * ptr, int leftset)
+{
+    IChar *s;
+    TScreen *screen = TScreenOf(xw);
+    int count = 0;
+    int rightset = screen->gsets[(int) (screen->curgr)];
+
+#define MAP(from, to) case from: chr = to; break
+
+    TRACE(("CHARSET GL=%c(G%d) GR=%c(G%d) SS%d\n\t%s\n",
+          leftset, screen->curgl,
+          rightset, screen->curgr,
+          screen->curss,
+          visibleIChar(buf, (unsigned) (ptr - buf))));
+
+    for (s = buf; s < ptr; ++s) {
+       int eight = CharOf(E2A(*s));
+       int seven = eight & 0x7f;
+       int cs = (eight >= 128) ? rightset : leftset;
+       int chr = eight;
+
+       count++;
+#if OPT_WIDE_CHARS
+       /*
+        * This is only partly right - prevent inadvertant remapping of
+        * the replacement character and other non-8bit codes into bogus
+        * 8bit codes.
+        */
+       if (screen->utf8_mode) {
+           if (*s > 255)
+               continue;
+       }
+#endif
+       switch (cs) {
+       case 'A':               /* United Kingdom set (or Latin 1)      */
+           if ((xw->flags & NATIONAL)
+               || (screen->vtXX_level <= 1)) {
+               if (chr == 0x23) {
+#if OPT_WIDE_CHARS
+                   chr = (screen->utf8_mode
+                          ? 0xa3
+                          : XTERM_POUND);
+#else
+                   chr = XTERM_POUND;
+#endif
+               }
+           } else {
+               chr = (seven | 0x80);
+           }
+           break;
+
+#if OPT_XMC_GLITCH
+       case '?':
+#endif
+       case '1':               /* Alternate Character ROM standard characters */
+       case '2':               /* Alternate Character ROM special graphics */
+       case 'B':               /* ASCII set                            */
+           break;
+
+       case '0':               /* special graphics (line drawing)      */
+           if (seven > 0x5f && seven <= 0x7e) {
+#if OPT_WIDE_CHARS
+               if (screen->utf8_mode)
+                   chr = (int) dec2ucs((unsigned) (seven - 0x5f));
+               else
+#endif
+                   chr = seven - 0x5f;
+           } else {
+               chr = seven;
+           }
+           break;
+
+       case '4':               /* Dutch */
+           switch (chr = seven) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_threequarters);
+               MAP(0x5b, XK_ydiaeresis);
+               MAP(0x5c, XK_onehalf);
+               MAP(0x5d, XK_bar);
+               MAP(0x7b, XK_diaeresis);
+               MAP(0x7c, XK_f);
+               MAP(0x7d, XK_onequarter);
+               MAP(0x7e, XK_acute);
+           }
+           break;
+
+       case 'C':
+       case '5':               /* Finnish */
+           switch (chr = seven) {
+               MAP(0x5b, XK_Adiaeresis);
+               MAP(0x5c, XK_Odiaeresis);
+               MAP(0x5d, XK_Aring);
+               MAP(0x5e, XK_Udiaeresis);
+               MAP(0x60, XK_eacute);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_aring);
+               MAP(0x7e, XK_udiaeresis);
+           }
+           break;
+
+       case 'R':               /* French */
+           switch (chr = seven) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_agrave);
+               MAP(0x5b, XK_degree);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_section);
+               MAP(0x7b, XK_eacute);
+               MAP(0x7c, XK_ugrave);
+               MAP(0x7d, XK_egrave);
+               MAP(0x7e, XK_diaeresis);
+           }
+           break;
+
+       case 'Q':               /* French Canadian */
+           switch (chr = seven) {
+               MAP(0x40, XK_agrave);
+               MAP(0x5b, XK_acircumflex);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_ecircumflex);
+               MAP(0x5e, XK_icircumflex);
+               MAP(0x60, XK_ocircumflex);
+               MAP(0x7b, XK_eacute);
+               MAP(0x7c, XK_ugrave);
+               MAP(0x7d, XK_egrave);
+               MAP(0x7e, XK_ucircumflex);
+           }
+           break;
+
+       case 'K':               /* German */
+           switch (chr = seven) {
+               MAP(0x40, XK_section);
+               MAP(0x5b, XK_Adiaeresis);
+               MAP(0x5c, XK_Odiaeresis);
+               MAP(0x5d, XK_Udiaeresis);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_udiaeresis);
+               MAP(0x7e, XK_ssharp);
+           }
+           break;
+
+       case 'Y':               /* Italian */
+           switch (chr = seven) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_section);
+               MAP(0x5b, XK_degree);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_eacute);
+               MAP(0x60, XK_ugrave);
+               MAP(0x7b, XK_agrave);
+               MAP(0x7c, XK_ograve);
+               MAP(0x7d, XK_egrave);
+               MAP(0x7e, XK_igrave);
+           }
+           break;
+
+       case 'E':
+       case '6':               /* Norwegian/Danish */
+           switch (chr = seven) {
+               MAP(0x40, XK_Adiaeresis);
+               MAP(0x5b, XK_AE);
+               MAP(0x5c, XK_Ooblique);
+               MAP(0x5d, XK_Aring);
+               MAP(0x5e, XK_Udiaeresis);
+               MAP(0x60, XK_adiaeresis);
+               MAP(0x7b, XK_ae);
+               MAP(0x7c, XK_oslash);
+               MAP(0x7d, XK_aring);
+               MAP(0x7e, XK_udiaeresis);
+           }
+           break;
+
+       case 'Z':               /* Spanish */
+           switch (chr = seven) {
+               MAP(0x23, XK_sterling);
+               MAP(0x40, XK_section);
+               MAP(0x5b, XK_exclamdown);
+               MAP(0x5c, XK_Ntilde);
+               MAP(0x5d, XK_questiondown);
+               MAP(0x7b, XK_degree);
+               MAP(0x7c, XK_ntilde);
+               MAP(0x7d, XK_ccedilla);
+           }
+           break;
+
+       case 'H':
+       case '7':               /* Swedish */
+           switch (chr = seven) {
+               MAP(0x40, XK_Eacute);
+               MAP(0x5b, XK_Adiaeresis);
+               MAP(0x5c, XK_Odiaeresis);
+               MAP(0x5d, XK_Aring);
+               MAP(0x5e, XK_Udiaeresis);
+               MAP(0x60, XK_eacute);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_aring);
+               MAP(0x7e, XK_udiaeresis);
+           }
+           break;
+
+       case '=':               /* Swiss */
+           switch (chr = seven) {
+               MAP(0x23, XK_ugrave);
+               MAP(0x40, XK_agrave);
+               MAP(0x5b, XK_eacute);
+               MAP(0x5c, XK_ccedilla);
+               MAP(0x5d, XK_ecircumflex);
+               MAP(0x5e, XK_icircumflex);
+               MAP(0x5f, XK_egrave);
+               MAP(0x60, XK_ocircumflex);
+               MAP(0x7b, XK_adiaeresis);
+               MAP(0x7c, XK_odiaeresis);
+               MAP(0x7d, XK_udiaeresis);
+               MAP(0x7e, XK_ucircumflex);
+           }
+           break;
+
+       default:                /* any character sets we don't recognize */
+           count--;
+           break;
+       }
+       /*
+        * The state machine already treated DEL as a nonprinting and
+        * nonspacing character.  If we have DEL now, simply render
+        * it as a blank.
+        */
+       if (chr == ANSI_DEL)
+           chr = ' ';
+       *s = (IChar) A2E(chr);
+    }
+    TRACE(("%d\t%s\n",
+          count,
+          visibleIChar(buf, (unsigned) (ptr - buf))));
+    return count;
+#undef MAP
+}
diff --git a/config.guess b/config.guess
new file mode 100755 (executable)
index 0000000..c2246a4
--- /dev/null
@@ -0,0 +1,1502 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+#   Free Software Foundation, Inc.
+
+timestamp='2009-12-30'
+
+# This file 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.
+#
+# This program 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
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner.  Please send patches (context
+# diff format) to <config-patches@gnu.org> and include a ChangeLog
+# entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep -q __ELF__
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    *:SolidBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    s390x:SunOS:*:*)
+       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+       echo i386-pc-auroraux${UNAME_RELEASE}
+       exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+       eval $set_cc_for_build
+       SUN_ARCH="i386"
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH="x86_64"
+           fi
+       fi
+       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[456])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep -q __LP64__
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       case ${UNAME_MACHINE} in
+           pc98)
+               echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           amd64)
+               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           *)
+               echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+       esac
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    *:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    *:Interix*:*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           authenticamd | genuineintel | EM64T)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+           IA64)
+               echo ia64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    8664:Windows_NT:*)
+       echo x86_64-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep -q ld.so.1
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
+    arm*:Linux:*:*)
+       eval $set_cc_for_build
+       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_EABI__
+       then
+           echo ${UNAME_MACHINE}-unknown-linux-gnu
+       else
+           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+       fi
+       exit ;;
+    avr32*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo crisv32-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo frv-unknown-linux-gnu
+       exit ;;
+    i*86:Linux:*:*)
+       LIBC=gnu
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #ifdef __dietlibc__
+       LIBC=dietlibc
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+       echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef ${UNAME_MACHINE}
+       #undef ${UNAME_MACHINE}el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=${UNAME_MACHINE}el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=${UNAME_MACHINE}
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    or32:Linux:*:*)
+       echo or32-unknown-linux-gnu
+       exit ;;
+    padre:Linux:*:*)
+       echo sparc-unknown-linux-gnu
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    vax:Linux:*:*)
+       echo ${UNAME_MACHINE}-dec-linux-gnu
+       exit ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit ;;
+    xtensa*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i586.
+       # Note: whatever this is, it MUST be the same as what config.sub
+       # prints for the "djgpp" host, or else GDB configury will decide that
+       # this is a cross-build.
+       echo i586-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+       OS_REL='.3'
+       test -r /etc/.relid \
+           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
+       echo i586-pc-haiku
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           i386)
+               eval $set_cc_for_build
+               if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+                 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+                     (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+                     grep IS_64BIT_ARCH >/dev/null
+                 then
+                     UNAME_PROCESSOR="x86_64"
+                 fi
+               fi ;;
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+    i*86:rdos:*:*)
+       echo ${UNAME_MACHINE}-pc-rdos
+       exit ;;
+    i*86:AROS:*:*)
+       echo ${UNAME_MACHINE}-pc-aros
+       exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.sub b/config.sub
new file mode 100755 (executable)
index 0000000..8518609
--- /dev/null
@@ -0,0 +1,1708 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+#   Free Software Foundation, Inc.
+
+timestamp='2009-12-31'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file 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.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted GNU ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis | -knuth | -cray | -microblaze)
+               os=
+               basic_machine=$1
+               ;;
+        -bluegene*)
+               os=-cnk
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco6)
+               os=-sco5v6
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5v6*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | am33_2.0 \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+       | bfin \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | fido | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k | iq2000 \
+       | lm32 \
+       | m32c | m32r | m32rle | m68000 | m68k | m88k \
+       | maxq | mb | microblaze | mcore | mep | metag \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64octeon | mips64octeonel \
+       | mips64orion | mips64orionel \
+       | mips64r5900 | mips64r5900el \
+       | mips64vr | mips64vrel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | moxie \
+       | mt \
+       | msp430 \
+       | nios | nios2 \
+       | ns16k | ns32k \
+       | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | rx \
+       | score \
+       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+       | spu | strongarm \
+       | tahoe | thumb | tic4x | tic80 | tron \
+       | ubicom32 \
+       | v850 | v850e \
+       | we32k \
+       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | z8k | z80)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12 | picochip)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+       ms1)
+               basic_machine=mt-unknown
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* | avr32-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | clipper-* | craynv-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* | iq2000-* \
+       | lm32-* \
+       | m32c-* | m32r-* | m32rle-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64octeon-* | mips64octeonel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64r5900-* | mips64r5900el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | mt-* \
+       | msp430-* \
+       | nios-* | nios2-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* | rx-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+       | tahoe-* | thumb-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+       | tron-* \
+       | ubicom32-* \
+       | v850-* | v850e-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | xstormy16-* | xtensa*-* \
+       | ymp-* \
+       | z8k-* | z80-*)
+               ;;
+       # Recognize the basic CPU types without company name, with glob match.
+       xtensa*)
+               basic_machine=$basic_machine-unknown
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aros)
+               basic_machine=i386-pc
+               os=-aros
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       blackfin)
+               basic_machine=bfin-unknown
+               os=-linux
+               ;;
+       blackfin-*)
+               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       bluegene*)
+               basic_machine=powerpc-ibm
+               os=-cnk
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+        cegcc)
+               basic_machine=arm-unknown
+               os=-cegcc
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16)
+               basic_machine=cr16-unknown
+               os=-elf
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dicos)
+               basic_machine=i686-pc
+               os=-dicos
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m68knommu)
+               basic_machine=m68k-unknown
+               os=-linux
+               ;;
+       m68knommu-*)
+               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+        microblaze)
+               basic_machine=microblaze-xilinx
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       mingw32ce)
+               basic_machine=arm-unknown
+               os=-mingw32ce
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       ms1-*)
+               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       openrisc | openrisc-*)
+               basic_machine=or32-unknown
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       parisc)
+               basic_machine=hppa-unknown
+               os=-linux
+               ;;
+       parisc-*)
+               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pc98)
+               basic_machine=i386-pc
+               ;;
+       pc98-*)
+               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rdos)
+               basic_machine=i386-pc
+               os=-rdos
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sde)
+               basic_machine=mipsisa32-sde
+               os=-elf
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh5el)
+               basic_machine=sh5le-unknown
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tic55x | c55x*)
+               basic_machine=tic55x-unknown
+               os=-coff
+               ;;
+       tic6x | c6x*)
+               basic_machine=tic6x-unknown
+               os=-coff
+               ;;
+       tile*)
+               basic_machine=tile-unknown
+               os=-linux-gnu
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       z80-*-coff)
+               basic_machine=z80-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+        -auroraux)
+               os=-auroraux
+               ;;
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+             | -sym* | -kopensolaris* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* | -aros* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+             | -openbsd* | -solidbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* | -cegcc* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+             | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+        -os400*)
+               os=-os400
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -syllable*)
+               os=-syllable
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+        -tpf*)
+               os=-tpf
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -kaos*)
+               os=-kaos
+               ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -dicos*)
+               os=-dicos
+               ;;
+        -nacl*)
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+               os=-elf
+               ;;
+        spu-*)
+               os=-elf
+               ;;
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+        c4x-* | tic4x-*)
+               os=-coff
+               ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+        mep-*)
+               os=-elf
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-haiku)
+               os=-haiku
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-knuth)
+               os=-mmixware
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -cnk*|-aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..f818a1f
--- /dev/null
+++ b/configure
@@ -0,0 +1,16869 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by Autoconf 2.52.20101001.
+#
+# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Name of the executable.
+as_me=`echo "$0" |sed 's,.*[\\/],,'`
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+as_executable_p="test -f"
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+# NLS nuisances.
+$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
+$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
+$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
+$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
+$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
+$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
+$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
+$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS="  $as_nl"
+
+# CDPATH.
+$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+cross_compiling=no
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete.  It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+ac_unique_file="charproc.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_prev=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval "$ac_prev=\$ac_option"
+    ac_prev=
+    continue
+  fi
+
+  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_option in
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    eval "enable_$ac_feature=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+   { (exit 1); exit 1; }; }
+    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_$ac_feature='$ac_optarg'" ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case $ac_option in
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_$ac_package='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid package name: $ac_package" >&2
+   { (exit 1); exit 1; }; }
+    ac_package=`echo $ac_package | sed 's/-/_/g'`
+    eval "with_$ac_package=no" ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; }
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+   { (exit 1); exit 1; }; }
+    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+    eval "$ac_envvar='$ac_optarg'"
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  { echo "$as_me: error: missing argument to $ac_option" >&2
+   { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+              localstatedir libdir includedir oldincludedir infodir mandir
+do
+  eval ac_val=$`echo $ac_var`
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* ) ;;
+    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: should be removed in autoconf 3.0.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then its parent.
+  ac_prog=$0
+  ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'`
+  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  srcdir=$ac_confdir
+  if test ! -r $srcdir/$ac_unique_file; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2
+   { (exit 1); exit 1; }; }
+  else
+    { echo "$as_me: error: cannot find sources in $srcdir" >&2
+   { (exit 1); exit 1; }; }
+  fi
+fi
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<EOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+EOF
+
+  cat <<EOF
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --infodir=DIR           info documentation [PREFIX/info]
+  --mandir=DIR            man documentation [PREFIX/man]
+EOF
+
+  cat <<\EOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+X features:
+  --x-includes=DIR    X include files are in DIR
+  --x-libraries=DIR   X library files are in DIR
+
+System types:
+  --build=BUILD           configure for building on BUILD [guessed]
+  --host=HOST       build programs to run on HOST [BUILD]
+EOF
+fi
+
+if test -n "$ac_init_help"; then
+
+  cat <<\EOF
+
+Optional Features:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+
+Compile/Install Options:
+  --disable-full-tgetent  disable check for full tgetent function
+  --with-app-defaults=DIR directory in which to install resource files (default: EPREFIX/lib/X11/app-defaults)
+  --with-icondir=DIR      directory in which to install icons (default: EPREFIX/share/pixmaps)
+  --disable-desktop       disable install of xterm desktop files
+  --with-reference=XXX    program to use as permissions-reference
+  --with-xterm-symlink=XXX make symbolic link to installed xterm
+  --disable-setuid        disable setuid in xterm, do not install setuid/setgid
+  --disable-setgid        disable setgid in xterm, do not install setuid/setgid
+  --with-setuid=XXX       use the given setuid user
+  --with-utmp-setgid=XXX  use setgid to match utmp/utmpx file
+  --with-utempter         use utempter library for access to utmp
+  --with-tty-group=XXX    use XXX for the tty-group
+  --with-x                use the X Window System
+  --with-pkg-config{=path} enable/disable use of pkg-config
+  --with-Xaw3d            link with Xaw 3d library
+  --with-neXtaw           link with neXT Athena library
+  --with-XawPlus          link with Athena-Plus library
+  --enable-narrowproto    enable narrow prototypes for X libraries
+  --disable-imake         disable use of imake for definitions
+Terminal Configuration:
+  --with-terminal-id=V    set default decTerminalID (default: vt100)
+  --with-terminal-type=T  set default $TERM (default: xterm)
+  --with-own-terminfo=P   set default $TERMINFO (default: from environment)
+Optional Features:
+  --disable-active-icon   disable X11R6.3 active-icon feature
+  --disable-ansi-color    disable ANSI color
+  --disable-16-color      disable 16-color support
+  --enable-256-color      enable 256-color support
+  --enable-88-color       enable 88-color support
+  --disable-blink-cursor  disable support for blinking cursor
+  --enable-broken-osc     allow broken Linux OSC-strings
+  --disable-broken-st     disallow broken string-terminators
+  --disable-c1-print      disallow -k8 option for printable 128-159
+  --disable-bold-color    disable PC-style mapping of bold colors
+  --disable-color-class   disable separate color class resources
+  --disable-color-mode    disable default colorMode resource
+  --disable-highlighting  disable support for color highlighting
+  --disable-doublechars   disable support for double-size chars
+  --disable-boxchars      disable fallback-support for box chars
+  --enable-exec-xterm     enable "spawn-new-terminal" action
+  --disable-freetype      disable freetype library-support
+  --with-freetype-cflags  -D/-I options for compiling with FreeType
+  --with-freetype-libs    -L/-l options to link FreeType
+  --enable-hp-fkeys       enable support for HP-style function keys
+  --enable-sco-fkeys      enable support for SCO-style function keys
+  --disable-sun-fkeys     disable support for Sun-style function keys
+  --disable-fifo-lines    disable FIFO-storage for saved-lines
+  --disable-i18n          disable internationalization
+  --disable-initial-erase disable setup for stty erase
+  --disable-input-method  disable input-method
+  --enable-load-vt-fonts  enable load-vt-fonts() action
+  --enable-logging        enable logging
+  --enable-logfile-exec   enable exec'd logfile filter
+  --disable-maximize      disable actions for iconify/deiconify/maximize/restore
+  --disable-num-lock      disable NumLock keypad support
+  --disable-paste64       disable get/set base64 selection data
+  --disable-pty-handshake disable pty-handshake support
+  --enable-readline-mouse enable support for mouse in readline applications
+  --disable-regex         disable regular-expression selections
+  --with-pcre             use PCRE for regular-expressions
+  --disable-rightbar      disable right-scrollbar support
+  --disable-samename      disable check for redundant name-change
+  --disable-session-mgt   disable support for session management
+  --disable-tcap-fkeys    disable termcap function-keys support
+  --disable-tcap-query    disable compiled-in termcap-query support
+  --disable-tek4014       disable tek4014 emulation
+  --enable-toolbar        compile-in toolbar for pulldown menus
+  --disable-vt52          disable VT52 emulation
+  --enable-mini-luit      enable mini-luit (built-in Latin9 support)
+  --enable-luit           enable luit filter (Unicode translation)
+  --enable-wide-chars     enable wide-character support
+  --enable-16bit-chars    enable 16-bit character support
+  --enable-dabbrev        enable dynamic-abbreviation support
+  --enable-dec-locator    enable DECterm Locator support
+  --disable-rectangles    disable VT420 rectangle support
+  --disable-ziconbeep     disable -ziconbeep option
+Testing/development Options:
+  --enable-trace          test: set to enable debugging traces
+  --disable-leaks         test: set to test memory leaks
+  --disable-echo          display "compiling" commands
+  --enable-xmc-glitch     test: enable xmc magic-cookie emulation
+  --enable-warnings       test: turn on GCC compiler warnings
+  --disable-rpath-hack    don't add rpath options for additional libraries
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
+              headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+EOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  ac_popdir=`pwd`
+  for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue
+    cd $ac_subdir
+    # A "../" for each directory in /$ac_subdir.
+    ac_dots=`echo $ac_subdir |
+             sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'`
+
+    case $srcdir in
+    .) # No --srcdir option.  We are building in place.
+      ac_sub_srcdir=$srcdir ;;
+    [\\/]* | ?:[\\/]* ) # Absolute path.
+      ac_sub_srcdir=$srcdir/$ac_subdir ;;
+    *) # Relative path.
+      ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;;
+    esac
+
+    # Check for guested configure; otherwise get Cygnus style configure.
+    if test -f $ac_sub_srcdir/configure.gnu; then
+      echo
+      $SHELL $ac_sub_srcdir/configure.gnu  --help=recursive
+    elif test -f $ac_sub_srcdir/configure; then
+      echo
+      $SHELL $ac_sub_srcdir/configure  --help=recursive
+    elif test -f $ac_sub_srcdir/configure.ac ||
+           test -f $ac_sub_srcdir/configure.in; then
+      echo
+      $ac_configure --help
+    else
+      echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2
+    fi
+    cd $ac_popdir
+  done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+  cat <<\EOF
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+EOF
+  exit 0
+fi
+exec 5>config.log
+cat >&5 <<EOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.52.20101001.  Invocation command line was
+
+  $ $0 $@
+
+EOF
+{
+cat <<_ASUNAME
+## ---------- ##
+## Platform.  ##
+## ---------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+PATH = $PATH
+
+_ASUNAME
+} >&5
+
+cat >&5 <<EOF
+## ------------ ##
+## Core tests.  ##
+## ------------ ##
+
+EOF
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell meta-characters.
+ac_configure_args=
+ac_sep=
+for ac_arg
+do
+  case $ac_arg in
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c) ;;
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+    ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
+    ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+    ac_sep=" " ;;
+  *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg"
+     ac_sep=" " ;;
+  esac
+  # Get rid of the leading space.
+done
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  echo >&5
+  echo "## ----------------- ##" >&5
+  echo "## Cache variables.  ##" >&5
+  echo "## ----------------- ##" >&5
+  echo >&5
+  # The following way of writing the cache mishandles newlines in values,
+{
+  (set) 2>&1 |
+    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      sed -n \
+        "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+      ;;
+    *)
+      sed -n \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} >&5
+  sed "/^$/d" confdefs.h >conftest.log
+  if test -s conftest.log; then
+    echo >&5
+    echo "## ------------ ##" >&5
+    echo "## confdefs.h.  ##" >&5
+    echo "## ------------ ##" >&5
+    echo >&5
+    cat conftest.log >&5
+  fi
+  (echo; echo) >&5
+  test "$ac_signal" != 0 &&
+    echo "$as_me: caught signal $ac_signal" >&5
+  echo "$as_me: exit $exit_status" >&5
+  rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files &&
+    exit $exit_status
+     ' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    { echo "$as_me:961: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+    cat "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special
+  # files actually), so we avoid doing that.
+  if test -f "$cache_file"; then
+    { echo "$as_me:972: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . $cache_file;;
+      *)                      . ./$cache_file;;
+    esac
+  fi
+else
+  { echo "$as_me:980: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+               sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+  eval ac_new_val="\$ac_env_${ac_var}_value"
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { echo "$as_me:996: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { echo "$as_me:1000: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+        { echo "$as_me:1006: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+        { echo "$as_me:1008:   former value:  $ac_old_val" >&5
+echo "$as_me:   former value:  $ac_old_val" >&2;}
+        { echo "$as_me:1010:   current value: $ac_new_val" >&5
+echo "$as_me:   current value: $ac_new_val" >&2;}
+        ac_cache_corrupted=:
+      fi;;
+  esac
+  # Pass precious variables to config.status.  It doesn't matter if
+  # we pass some twice (in addition to the command line arguments).
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *" "*|*"   "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"`
+      ac_configure_args="$ac_configure_args '$ac_arg'"
+      ;;
+    *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val"
+       ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { echo "$as_me:1029: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  { { echo "$as_me:1031: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T='     ' ;;
+  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+  *)      ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+echo "#! $SHELL" >conftest.sh
+echo  "exit 0"   >>conftest.sh
+chmod +x conftest.sh
+if { (echo "$as_me:1052: PATH=\".;.\"; conftest.sh") >&5
+  (PATH=".;."; conftest.sh) 2>&5
+  ac_status=$?
+  echo "$as_me:1055: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  ac_path_separator=';'
+else
+  ac_path_separator=:
+fi
+PATH_SEPARATOR="$ac_path_separator"
+rm -f conftest.sh
+
+ac_config_headers="$ac_config_headers xtermcfg.h:xtermcfg.hin"
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+  if test -f $ac_dir/install-sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f $ac_dir/install.sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  elif test -f $ac_dir/shtool; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/shtool install -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { { echo "$as_me:1083: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:1093: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+   { (exit 1); exit 1; }; }
+
+echo "$as_me:1097: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+  ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+  { { echo "$as_me:1106: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+   { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+  { { echo "$as_me:1110: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:1115: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+       echo "$as_me:1123: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+  ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+  { { echo "$as_me:1132: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:1137: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+       system_name="$host_os"
+else
+       system_name="`(uname -s -r) 2>/dev/null`"
+       if test -z "$system_name" ; then
+               system_name="`(hostname) 2>/dev/null`"
+       fi
+fi
+test -n "$system_name" && cat >>confdefs.h <<EOF
+#define SYSTEM_NAME "$system_name"
+EOF
+
+if test "${cf_cv_system_name+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cf_cv_system_name="$system_name"
+fi
+
+test -z "$system_name" && system_name="$cf_cv_system_name"
+test -n "$cf_cv_system_name" && echo "$as_me:1162: result: Configuring for $cf_cv_system_name" >&5
+echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6
+
+if test ".$system_name" != ".$cf_cv_system_name" ; then
+       echo "$as_me:1166: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
+echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
+       { { echo "$as_me:1168: error: \"Please remove config.cache and try again.\"" >&5
+echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+###    checks for alternative programs
+
+case "$host_os" in
+openedition)   : ${CFLAGS="-O2 -Wc,dll -Wl,EDIT=NO"}
+               : ${CPPFLAGS="-D_ALL_SOURCE"}
+               : ${LIBS="/usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x"}
+               : ${CC=c89};;
+darwin*)
+               : ${LDFLAGS}="${LDFLAGS} -Wl,-bind_at_load";;
+esac
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:1193: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="${ac_tool_prefix}gcc"
+echo "$as_me:1208: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:1216: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:1219: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:1228: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="gcc"
+echo "$as_me:1243: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:1251: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:1254: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:1267: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="${ac_tool_prefix}cc"
+echo "$as_me:1282: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:1290: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:1293: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:1302: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="cc"
+echo "$as_me:1317: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:1325: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:1328: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  CC=$ac_ct_CC
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:1341: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+  ac_prog_rejected=yes
+  continue
+fi
+ac_cv_prog_CC="cc"
+echo "$as_me:1361: found $ac_dir/$ac_word" >&5
+break
+done
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    set dummy "$ac_dir/$ac_word" ${1+"$@"}
+    shift
+    ac_cv_prog_CC="$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:1383: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:1386: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:1397: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+echo "$as_me:1412: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  echo "$as_me:1420: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+  echo "$as_me:1423: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:1436: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ac_ct_CC="$ac_prog"
+echo "$as_me:1451: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  echo "$as_me:1459: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+  echo "$as_me:1462: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$ac_ct_CC" && break
+done
+
+  CC=$ac_ct_CC
+fi
+
+fi
+
+test -z "$CC" && { { echo "$as_me:1474: error: no acceptable cc found in \$PATH" >&5
+echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
+   { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:1479:" \
+     "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:1482: \"$ac_compiler --version </dev/null >&5\"") >&5
+  (eval $ac_compiler --version </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:1485: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:1487: \"$ac_compiler -v </dev/null >&5\"") >&5
+  (eval $ac_compiler -v </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:1490: \$? = $ac_status" >&5
+  (exit $ac_status); }
+{ (eval echo "$as_me:1492: \"$ac_compiler -V </dev/null >&5\"") >&5
+  (eval $ac_compiler -V </dev/null >&5) 2>&5
+  ac_status=$?
+  echo "$as_me:1495: \$? = $ac_status" >&5
+  (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 1499 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:1515: checking for C compiler default output" >&5
+echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:1518: \"$ac_link_default\"") >&5
+  (eval $ac_link_default) 2>&5
+  ac_status=$?
+  echo "$as_me:1521: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # Find the output, starting from the most likely.  This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+for ac_file in `ls a.exe conftest.exe 2>/dev/null;
+                ls a.out conftest 2>/dev/null;
+                ls a.* conftest.* 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    a.out ) # We found the default executable, but exeext='' is most
+            # certainly right.
+            break;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+          # FIXME: I believe we export ac_cv_exeext for Libtool --akim.
+          export ac_cv_exeext
+          break;;
+    * ) break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+{ { echo "$as_me:1544: error: C compiler cannot create executables" >&5
+echo "$as_me: error: C compiler cannot create executables" >&2;}
+   { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:1550: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:1555: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+  if { ac_try='./$ac_file'
+  { (eval echo "$as_me:1561: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1564: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { echo "$as_me:1571: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'." >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+  fi
+fi
+echo "$as_me:1579: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:1586: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:1588: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:1591: checking for executable suffix" >&5
+echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
+if { (eval echo "$as_me:1593: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:1596: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+          export ac_cv_exeext
+          break;;
+    * ) break;;
+  esac
+done
+else
+  { { echo "$as_me:1612: error: cannot compute EXEEXT: cannot compile and link" >&5
+echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:1618: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:1624: checking for object suffix" >&5
+echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1630 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:1642: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1645: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.map | *.inf ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+{ { echo "$as_me:1657: error: cannot compute OBJEXT: cannot compile" >&5
+echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:1664: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:1668: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1674 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1689: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1692: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1695: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1698: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_compiler_gnu=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_compiler_gnu=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:1710: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:1716: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1722 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1734: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1737: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1740: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1743: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:1753: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+  choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1780: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1783: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1786: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1789: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  for ac_declaration in \
+   ''\
+   '#include <stdlib.h>' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1801 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1814: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1817: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1820: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1823: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+continue
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1833 "configure"
+#include "confdefs.h"
+$ac_declaration
+int
+main ()
+{
+exit (42);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:1845: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:1848: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:1851: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:1854: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+rm -rf conftest*
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+echo "$as_me:1888: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1909 "configure"
+#include "confdefs.h"
+#include <assert.h>
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:1914: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:1920: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 1943 "configure"
+#include "confdefs.h"
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:1947: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:1953: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:1990: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2000 "configure"
+#include "confdefs.h"
+#include <assert.h>
+                     Syntax error
+_ACEOF
+if { (eval echo "$as_me:2005: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:2011: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether non-existent headers
+  # can be detected and how.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2034 "configure"
+#include "confdefs.h"
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:2038: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:2044: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # Broken: success on invalid input.
+continue
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+  :
+else
+  { { echo "$as_me:2072: error: C preprocessor \"$CPP\" fails sanity check" >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_main_return=return
+
+if test $ac_cv_c_compiler_gnu = yes; then
+    echo "$as_me:2085: checking whether $CC needs -traditional" >&5
+echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6
+if test "${ac_cv_prog_gcc_traditional+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+    ac_pattern="Autoconf.*'x'"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2092 "configure"
+#include "confdefs.h"
+#include <sgtty.h>
+int Autoconf = TIOCGETP;
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "$ac_pattern" >/dev/null 2>&1; then
+  ac_cv_prog_gcc_traditional=yes
+else
+  ac_cv_prog_gcc_traditional=no
+fi
+rm -rf conftest*
+
+  if test $ac_cv_prog_gcc_traditional = no; then
+    cat >conftest.$ac_ext <<_ACEOF
+#line 2107 "configure"
+#include "confdefs.h"
+#include <termio.h>
+int Autoconf = TCGETA;
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "$ac_pattern" >/dev/null 2>&1; then
+  ac_cv_prog_gcc_traditional=yes
+fi
+rm -rf conftest*
+
+  fi
+fi
+echo "$as_me:2120: result: $ac_cv_prog_gcc_traditional" >&5
+echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
+  if test $ac_cv_prog_gcc_traditional = yes; then
+    CC="$CC -traditional"
+  fi
+fi
+
+for ac_prog in mawk gawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:2131: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_AWK+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_AWK="$ac_prog"
+echo "$as_me:2146: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  echo "$as_me:2154: result: $AWK" >&5
+echo "${ECHO_T}$AWK" >&6
+else
+  echo "$as_me:2157: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$AWK" && break
+done
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:2176: checking for a BSD compatible install" >&5
+echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+    ac_save_IFS=$IFS; IFS=$ac_path_separator
+  for ac_dir in $PATH; do
+    IFS=$ac_save_IFS
+    # Account for people who put trailing slashes in PATH elements.
+    case $ac_dir/ in
+    / | ./ | .// | /cC/* \
+    | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \
+    | /usr/ucb/* ) ;;
+    *)
+      # OSF1 and SCO ODT 3.0 have their own names for install.
+      # Don't use installbsd from OSF since it installs stuff as root
+      # by default.
+      for ac_prog in ginstall scoinst install; do
+        if $as_executable_p "$ac_dir/$ac_prog"; then
+         if test $ac_prog = install &&
+            grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           ac_cv_path_install="$ac_dir/$ac_prog -c"
+           break 2
+         fi
+       fi
+      done
+      ;;
+    esac
+  done
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  We don't cache a
+    # path for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the path is relative.
+    INSTALL=$ac_install_sh
+  fi
+fi
+echo "$as_me:2225: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+echo "$as_me:2236: checking whether ln -s works" >&5
+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  echo "$as_me:2240: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:2243: result: no, using $LN_S" >&5
+echo "${ECHO_T}no, using $LN_S" >&6
+fi
+
+test "$program_prefix" != NONE &&
+  program_transform_name="s,^,$program_prefix,;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s,\$,$program_suffix,;$program_transform_name"
+# Double any \ or $.  echo might interpret backslashes.
+# By default was `s,x,x', remove it if useless.
+cat <<\_ACEOF >conftest.sed
+s/[\\$]/&&/g;s/;s,x,x,$//
+_ACEOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm conftest.sed
+
+for ac_prog in tdlint lint alint
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:2264: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_LINT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$LINT"; then
+  ac_cv_prog_LINT="$LINT" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_LINT="$ac_prog"
+echo "$as_me:2279: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+LINT=$ac_cv_prog_LINT
+if test -n "$LINT"; then
+  echo "$as_me:2287: result: $LINT" >&5
+echo "${ECHO_T}$LINT" >&6
+else
+  echo "$as_me:2290: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$LINT" && break
+done
+
+###    checks for UNIX variants that set C preprocessor variables
+
+echo "$as_me:2299: checking for AIX" >&5
+echo $ECHO_N "checking for AIX... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 2302 "configure"
+#include "confdefs.h"
+#ifdef _AIX
+  yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "yes" >/dev/null 2>&1; then
+  echo "$as_me:2311: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+cat >>confdefs.h <<\EOF
+#define _ALL_SOURCE 1
+EOF
+
+else
+  echo "$as_me:2318: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -rf conftest*
+
+echo "$as_me:2323: checking for POSIXized ISC" >&5
+echo $ECHO_N "checking for POSIXized ISC... $ECHO_C" >&6
+if test -d /etc/conf/kconfig.d &&
+   grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+then
+  echo "$as_me:2328: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+  ISC=yes # If later tests want to check for ISC.
+
+cat >>confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+  if test "$GCC" = yes; then
+    CC="$CC -posix"
+  else
+    CC="$CC -Xp"
+  fi
+else
+  echo "$as_me:2342: result: no" >&5
+echo "${ECHO_T}no" >&6
+  ISC=
+fi
+
+###    checks for compiler characteristics
+
+echo "$as_me:2349: checking for ${CC:-cc} option to accept ANSI C" >&5
+echo $ECHO_N "checking for ${CC:-cc} option to accept ANSI C... $ECHO_C" >&6
+if test "${cf_cv_ansi_cc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_ansi_cc=no
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX                  -qlanglvl=ansi
+# Ultrix and OSF/1     -std1
+# HP-UX                        -Aa -D_HPUX_SOURCE
+# SVR4                 -Xc
+# UnixWare 1.2         (cannot use -Xc, since ANSI/POSIX clashes)
+for cf_arg in "-DCC_HAS_PROTOS" \
+       "" \
+       -qlanglvl=ansi \
+       -std1 \
+       -Ae \
+       "-Aa -D_HPUX_SOURCE" \
+       -Xc
+do
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_arg
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 2453 "configure"
+#include "confdefs.h"
+
+#ifndef CC_HAS_PROTOS
+#if !defined(__STDC__) || (__STDC__ != 1)
+choke me
+#endif
+#endif
+
+int
+main ()
+{
+
+       int test (int i, double x);
+       struct s1 {int (*f) (int a);};
+       struct s2 {int (*f) (double a);};
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2474: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2477: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2480: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2483: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_ansi_cc="$cf_arg"; break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
+
+fi
+echo "$as_me:2496: result: $cf_cv_ansi_cc" >&5
+echo "${ECHO_T}$cf_cv_ansi_cc" >&6
+
+if test "$cf_cv_ansi_cc" != "no"; then
+if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_cv_ansi_cc
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+else
+       cat >>confdefs.h <<\EOF
+#define CC_HAS_PROTOS 1
+EOF
+
+fi
+fi
+
+echo "$as_me:2588: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+#line 2596 "configure"
+#include "confdefs.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX                  -qlanglvl=ansi
+# Ultrix and OSF/1     -std1
+# HP-UX 10.20 and later        -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4                 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2645: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2648: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2651: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2654: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+  x|xno)
+    echo "$as_me:2671: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+  *)
+    echo "$as_me:2674: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+    CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+echo "$as_me:2679: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 2685 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset x;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *ccp;
+  char **p;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  ccp = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++ccp;
+  p = (char**) ccp;
+  ccp = (char const *const *) p;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+  }
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2743: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2746: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2749: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2752: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_c_const=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_c_const=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:2762: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+case $cf_cv_system_name in
+os2*)
+    CFLAGS="$CFLAGS -Zmt"
+    CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
+    CXXFLAGS="$CXXFLAGS -Zmt"
+    # autoconf's macro sets -Zexe and suffix both, which conflict:w
+    LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
+    ac_cv_exeext=.exe
+    ;;
+esac
+
+PROG_EXT="$EXEEXT"
+
+test -n "$PROG_EXT" && cat >>confdefs.h <<EOF
+#define PROG_EXT "$PROG_EXT"
+EOF
+
+cf_XOPEN_SOURCE=500
+cf_POSIX_C_SOURCE=199506L
+cf_xopen_source=
+
+case $host_os in #(vi
+aix[456]*) #(vi
+       cf_xopen_source="-D_ALL_SOURCE"
+       ;;
+darwin[0-8].*) #(vi
+       cf_xopen_source="-D_APPLE_C_SOURCE"
+       ;;
+darwin*) #(vi
+       cf_xopen_source="-D_DARWIN_C_SOURCE"
+       ;;
+freebsd*|dragonfly*) #(vi
+       # 5.x headers associate
+       #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+       #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+       cf_POSIX_C_SOURCE=200112L
+       cf_XOPEN_SOURCE=600
+       cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+       ;;
+hpux11*) #(vi
+       cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
+       ;;
+hpux*) #(vi
+       cf_xopen_source="-D_HPUX_SOURCE"
+       ;;
+irix[56].*) #(vi
+       cf_xopen_source="-D_SGI_SOURCE"
+       ;;
+linux*|gnu*|mint*|k*bsd*-gnu) #(vi
+
+echo "$as_me:2822: checking if we must define _GNU_SOURCE" >&5
+echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_gnu_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 2829 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2844: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2847: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2850: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2853: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_gnu_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_save="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+        cat >conftest.$ac_ext <<_ACEOF
+#line 2862 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2877: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2880: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2883: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2886: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_gnu_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_gnu_source=yes
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+       CPPFLAGS="$cf_save"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:2901: result: $cf_cv_gnu_source" >&5
+echo "${ECHO_T}$cf_cv_gnu_source" >&6
+test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+
+       ;;
+mirbsd*) #(vi
+       # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+       ;;
+netbsd*) #(vi
+       # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+       ;;
+openbsd*) #(vi
+       # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+       ;;
+osf[45]*) #(vi
+       cf_xopen_source="-D_OSF_SOURCE"
+       ;;
+nto-qnx*) #(vi
+       cf_xopen_source="-D_QNX_SOURCE"
+       ;;
+sco*) #(vi
+       # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+       ;;
+solaris2.1[0-9]) #(vi
+       cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+       ;;
+solaris2.[1-9]) #(vi
+       cf_xopen_source="-D__EXTENSIONS__"
+       ;;
+*)
+       echo "$as_me:2931: checking if we should define _XOPEN_SOURCE" >&5
+echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_xopen_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 2938 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2953: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2956: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2959: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2962: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xopen_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_save="$CPPFLAGS"
+        CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+        cat >conftest.$ac_ext <<_ACEOF
+#line 2971 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:2986: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:2989: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:2992: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2995: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xopen_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xopen_source=$cf_XOPEN_SOURCE
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+       CPPFLAGS="$cf_save"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:3010: result: $cf_cv_xopen_source" >&5
+echo "${ECHO_T}$cf_cv_xopen_source" >&6
+       if test "$cf_cv_xopen_source" != no ; then
+
+CFLAGS=`echo "$CFLAGS" | \
+       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^       ]*\)\?$//g'`
+
+               cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_temp_xopen_source
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       fi
+
+cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
+
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+
+cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \
+       sed     -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?$//g'`
+
+cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
+       sed     -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^     ]*\)\?$//g'`
+
+echo "$as_me:3117: checking if we should define _POSIX_C_SOURCE" >&5
+echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_posix_c_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+echo "${as_me:-configure}:3123: testing if the symbol is already defined go no further ..." 1>&5
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 3126 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3141: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3144: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3147: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3150: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_posix_c_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_want_posix_source=no
+        case .$cf_POSIX_C_SOURCE in #(vi
+        .[12]??*) #(vi
+               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+               ;;
+        .2) #(vi
+               cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+               cf_want_posix_source=yes
+               ;;
+        .*)
+               cf_want_posix_source=yes
+               ;;
+        esac
+        if test "$cf_want_posix_source" = yes ; then
+               cat >conftest.$ac_ext <<_ACEOF
+#line 3171 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifdef _POSIX_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3186: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3189: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3192: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3195: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+        fi
+
+echo "${as_me:-configure}:3206: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+
+        CFLAGS="$cf_trim_CFLAGS"
+        CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
+
+echo "${as_me:-configure}:3211: testing if the second compile does not leave our definition intact error ..." 1>&5
+
+        cat >conftest.$ac_ext <<_ACEOF
+#line 3214 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3229: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3232: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3235: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3238: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_c_source=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+        CFLAGS="$cf_save_CFLAGS"
+        CPPFLAGS="$cf_save_CPPFLAGS"
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:3254: result: $cf_cv_posix_c_source" >&5
+echo "${ECHO_T}$cf_cv_posix_c_source" >&6
+
+if test "$cf_cv_posix_c_source" != no ; then
+       CFLAGS="$cf_trim_CFLAGS"
+       CPPFLAGS="$cf_trim_CPPFLAGS"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_cv_posix_c_source
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+fi
+
+       ;;
+esac
+
+if test -n "$cf_xopen_source" ; then
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_xopen_source
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+fi
+
+echo "$as_me:3426: checking if SIGWINCH is defined" >&5
+echo $ECHO_N "checking if SIGWINCH is defined... $ECHO_C" >&6
+if test "${cf_cv_define_sigwinch+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 3433 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <sys/signal.h>
+
+int
+main ()
+{
+int x = SIGWINCH
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3448: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3451: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3454: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3457: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_define_sigwinch=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line 3464 "configure"
+#include "confdefs.h"
+
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+
+int
+main ()
+{
+int x = SIGWINCH
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3482: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3485: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3488: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3491: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_define_sigwinch=maybe
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_define_sigwinch=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:3505: result: $cf_cv_define_sigwinch" >&5
+echo "${ECHO_T}$cf_cv_define_sigwinch" >&6
+
+if test "$cf_cv_define_sigwinch" = maybe ; then
+echo "$as_me:3509: checking for actual SIGWINCH definition" >&5
+echo $ECHO_N "checking for actual SIGWINCH definition... $ECHO_C" >&6
+if test "${cf_cv_fixup_sigwinch+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_fixup_sigwinch=unknown
+cf_sigwinch=32
+while test $cf_sigwinch != 1
+do
+       cat >conftest.$ac_ext <<_ACEOF
+#line 3520 "configure"
+#include "confdefs.h"
+
+#undef _XOPEN_SOURCE
+#undef _POSIX_SOURCE
+#undef _POSIX_C_SOURCE
+#include <sys/types.h>
+#include <sys/signal.h>
+
+int
+main ()
+{
+
+#if SIGWINCH != $cf_sigwinch
+make an error
+#endif
+int x = SIGWINCH
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3542: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3545: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3548: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3551: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_fixup_sigwinch=$cf_sigwinch
+        break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+cf_sigwinch=`expr $cf_sigwinch - 1`
+done
+
+fi
+echo "$as_me:3565: result: $cf_cv_fixup_sigwinch" >&5
+echo "${ECHO_T}$cf_cv_fixup_sigwinch" >&6
+
+       if test "$cf_cv_fixup_sigwinch" != unknown ; then
+               CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
+       fi
+fi
+
+###    checks for header files
+
+for ac_header in \
+ncurses/term.h \
+stdlib.h \
+sys/ttydefaults.h \
+term.h \
+termios.h \
+unistd.h \
+wchar.h \
+
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:3586: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3592 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:3596: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:3602: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:3621: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:3631: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
+if test "${ac_cv_header_time+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3637 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3653: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3656: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3659: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3662: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_time=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_header_time=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:3672: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6
+if test $ac_cv_header_time = yes; then
+
+cat >>confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+  echo "$as_me:3682: checking for nl_langinfo and CODESET" >&5
+echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
+if test "${am_cv_langinfo_codeset+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3688 "configure"
+#include "confdefs.h"
+#include <langinfo.h>
+int
+main ()
+{
+char* cs = nl_langinfo(CODESET);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:3700: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3703: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:3706: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3709: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  am_cv_langinfo_codeset=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+am_cv_langinfo_codeset=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:3720: result: $am_cv_langinfo_codeset" >&5
+echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
+  if test $am_cv_langinfo_codeset = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_LANGINFO_CODESET 1
+EOF
+
+  fi
+
+###    checks for typedefs
+
+echo "$as_me:3732: checking for signal global datatype" >&5
+echo $ECHO_N "checking for signal global datatype... $ECHO_C" >&6
+if test "${cf_cv_sig_atomic_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       for cf_type in \
+               "volatile sig_atomic_t" \
+               "sig_atomic_t" \
+               "int"
+       do
+       cat >conftest.$ac_ext <<_ACEOF
+#line 3744 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <signal.h>
+#include <stdio.h>
+
+extern $cf_type x;
+$cf_type x;
+static void handler(int sig)
+{
+       x = 5;
+}
+int
+main ()
+{
+signal(SIGINT, handler);
+                x = 1
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3767: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3770: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3773: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3776: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_sig_atomic_t=$cf_type
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_sig_atomic_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+               test "$cf_cv_sig_atomic_t" != no && break
+       done
+
+fi
+
+echo "$as_me:3790: result: $cf_cv_sig_atomic_t" >&5
+echo "${ECHO_T}$cf_cv_sig_atomic_t" >&6
+test "$cf_cv_sig_atomic_t" != no && cat >>confdefs.h <<EOF
+#define SIG_ATOMIC_T $cf_cv_sig_atomic_t
+EOF
+
+echo "$as_me:3796: checking for size_t in <sys/types.h> or <stdio.h>" >&5
+echo $ECHO_N "checking for size_t in <sys/types.h> or <stdio.h>... $ECHO_C" >&6
+if test "${cf_cv_type_size_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 3803 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <stdio.h>
+int
+main ()
+{
+size_t x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:3821: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:3824: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:3827: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3830: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_type_size_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_type_size_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+echo "$as_me:3842: result: $cf_cv_type_size_t" >&5
+echo "${ECHO_T}$cf_cv_type_size_t" >&6
+test $cf_cv_type_size_t = no && cat >>confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+echo "$as_me:3848: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3854 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+_ACEOF
+if { (eval echo "$as_me:3862: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:3868: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_stdc=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3890 "configure"
+#include "confdefs.h"
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "memchr" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -rf conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3908 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "free" >/dev/null 2>&1; then
+  :
+else
+  ac_cv_header_stdc=no
+fi
+rm -rf conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then
+  :
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3929 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
+                     || ('j' <= (c) && (c) <= 'r') \
+                     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+        || toupper (i) != TOUPPER (i))
+      $ac_main_return(2);
+  $ac_main_return (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:3955: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:3958: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:3960: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:3963: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_header_stdc=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:3976: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                  inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:3992: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 3998 "configure"
+#include "confdefs.h"
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4004: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4007: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4010: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4013: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:4023: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:4033: checking for time_t" >&5
+echo $ECHO_N "checking for time_t... $ECHO_C" >&6
+if test "${ac_cv_type_time_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4039 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main ()
+{
+if ((time_t *) 0)
+  return 0;
+if (sizeof (time_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4054: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4057: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4060: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4063: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_time_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_time_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:4073: result: $ac_cv_type_time_t" >&5
+echo "${ECHO_T}$ac_cv_type_time_t" >&6
+if test $ac_cv_type_time_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<EOF
+#define time_t long
+EOF
+
+fi
+
+echo "$as_me:4085: checking for mode_t" >&5
+echo $ECHO_N "checking for mode_t... $ECHO_C" >&6
+if test "${ac_cv_type_mode_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4091 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main ()
+{
+if ((mode_t *) 0)
+  return 0;
+if (sizeof (mode_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4106: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4109: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4112: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4115: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_mode_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_mode_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:4125: result: $ac_cv_type_mode_t" >&5
+echo "${ECHO_T}$ac_cv_type_mode_t" >&6
+if test $ac_cv_type_mode_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<EOF
+#define mode_t int
+EOF
+
+fi
+
+echo "$as_me:4137: checking for pid_t" >&5
+echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
+if test "${ac_cv_type_pid_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4143 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main ()
+{
+if ((pid_t *) 0)
+  return 0;
+if (sizeof (pid_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4158: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4161: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4164: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4167: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_pid_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_pid_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:4177: result: $ac_cv_type_pid_t" >&5
+echo "${ECHO_T}$ac_cv_type_pid_t" >&6
+if test $ac_cv_type_pid_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<EOF
+#define pid_t int
+EOF
+
+fi
+
+echo "$as_me:4189: checking for uid_t in sys/types.h" >&5
+echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6
+if test "${ac_cv_type_uid_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4195 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "uid_t" >/dev/null 2>&1; then
+  ac_cv_type_uid_t=yes
+else
+  ac_cv_type_uid_t=no
+fi
+rm -rf conftest*
+
+fi
+echo "$as_me:4209: result: $ac_cv_type_uid_t" >&5
+echo "${ECHO_T}$ac_cv_type_uid_t" >&6
+if test $ac_cv_type_uid_t = no; then
+
+cat >>confdefs.h <<\EOF
+#define uid_t int
+EOF
+
+cat >>confdefs.h <<\EOF
+#define gid_t int
+EOF
+
+fi
+
+echo "$as_me:4223: checking for off_t" >&5
+echo $ECHO_N "checking for off_t... $ECHO_C" >&6
+if test "${ac_cv_type_off_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4229 "configure"
+#include "confdefs.h"
+$ac_includes_default
+int
+main ()
+{
+if ((off_t *) 0)
+  return 0;
+if (sizeof (off_t))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4244: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4247: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4250: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4253: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_type_off_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_off_t=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:4263: result: $ac_cv_type_off_t" >&5
+echo "${ECHO_T}$ac_cv_type_off_t" >&6
+if test $ac_cv_type_off_t = yes; then
+  :
+else
+
+cat >>confdefs.h <<EOF
+#define off_t long
+EOF
+
+fi
+
+###    checks for library functions
+
+for ac_func in \
+       bcopy \
+       gethostname \
+       getlogin \
+       memmove \
+       putenv \
+       sched_yield \
+       strerror \
+       strftime \
+       tcgetattr \
+       waitpid \
+       wcswidth \
+       wcwidth
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:4292: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4298 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4329: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4332: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4335: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4338: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:4348: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:4358: checking for memmove" >&5
+echo $ECHO_N "checking for memmove... $ECHO_C" >&6
+if test "${ac_cv_func_memmove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4364 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char memmove (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char memmove ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_memmove) || defined (__stub___memmove)
+choke me
+#else
+f = memmove;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4395: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4398: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4401: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4404: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_memmove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_memmove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:4414: result: $ac_cv_func_memmove" >&5
+echo "${ECHO_T}$ac_cv_func_memmove" >&6
+if test $ac_cv_func_memmove = yes; then
+  :
+else
+
+echo "$as_me:4420: checking for bcopy" >&5
+echo $ECHO_N "checking for bcopy... $ECHO_C" >&6
+if test "${ac_cv_func_bcopy+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4426 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char bcopy (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char bcopy ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_bcopy) || defined (__stub___bcopy)
+choke me
+#else
+f = bcopy;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4457: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4460: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4463: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4466: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_bcopy=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_bcopy=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:4476: result: $ac_cv_func_bcopy" >&5
+echo "${ECHO_T}$ac_cv_func_bcopy" >&6
+if test $ac_cv_func_bcopy = yes; then
+
+       echo "$as_me:4480: checking if bcopy does overlapping moves" >&5
+echo $ECHO_N "checking if bcopy does overlapping moves... $ECHO_C" >&6
+if test "${cf_cv_good_bcopy+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+               if test "$cross_compiling" = yes; then
+  cf_cv_good_bcopy=unknown
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4490 "configure"
+#include "confdefs.h"
+
+int main() {
+       static char data[] = "abcdefghijklmnopqrstuwwxyz";
+       char temp[40];
+       bcopy(data, temp, sizeof(data));
+       bcopy(temp+10, temp, 15);
+       bcopy(temp+5, temp+15, 10);
+       ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:4504: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4507: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:4509: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4512: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_good_bcopy=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_good_bcopy=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+fi
+echo "$as_me:4525: result: $cf_cv_good_bcopy" >&5
+echo "${ECHO_T}$cf_cv_good_bcopy" >&6
+
+else
+  cf_cv_good_bcopy=no
+fi
+
+       if test "$cf_cv_good_bcopy" = yes ; then
+               cat >>confdefs.h <<\EOF
+#define USE_OK_BCOPY 1
+EOF
+
+       else
+               cat >>confdefs.h <<\EOF
+#define USE_MY_MEMMOVE 1
+EOF
+
+       fi
+
+fi
+
+for ac_header in lastlog.h paths.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:4549: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4555 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:4559: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:4565: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4584: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:4594: checking for lastlog path" >&5
+echo $ECHO_N "checking for lastlog path... $ECHO_C" >&6
+if test "${cf_cv_path_lastlog+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 4601 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#ifdef HAVE_LASTLOG_H
+#include <lastlog.h>
+#else
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+#endif
+int
+main ()
+{
+char *path = _PATH_LASTLOG
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4621: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4624: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4627: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4630: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_path_lastlog="_PATH_LASTLOG"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+if test -f /usr/adm/lastlog ; then
+               cf_cv_path_lastlog=/usr/adm/lastlog
+       else
+               cf_cv_path_lastlog=no
+       fi
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:4645: result: $cf_cv_path_lastlog" >&5
+echo "${ECHO_T}$cf_cv_path_lastlog" >&6
+test $cf_cv_path_lastlog != no && cat >>confdefs.h <<\EOF
+#define USE_LASTLOG 1
+EOF
+
+echo "$as_me:4651: checking for utmp implementation" >&5
+echo $ECHO_N "checking for utmp implementation... $ECHO_C" >&6
+if test "${cf_cv_have_utmp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cf_cv_have_utmp=no
+for cf_header in utmpx utmp ; do
+cf_utmp_includes="
+#include <sys/types.h>
+#include <${cf_header}.h>
+#define getutent getutxent
+#ifdef USE_LASTLOG
+#include <lastlog.h>   /* may conflict with utmpx.h on Linux */
+#endif
+"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4668 "configure"
+#include "confdefs.h"
+$cf_utmp_includes
+int
+main ()
+{
+struct $cf_header x;
+        char *name = x.ut_name; /* utmp.h and compatible definitions */
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4682: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4685: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4688: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4691: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp=$cf_header
+        break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4700 "configure"
+#include "confdefs.h"
+$cf_utmp_includes
+int
+main ()
+{
+struct $cf_header x;
+        char *name = x.ut_user; /* utmpx.h must declare this */
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4714: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4717: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4720: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4723: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp=$cf_header
+        break
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
+fi
+echo "$as_me:4738: result: $cf_cv_have_utmp" >&5
+echo "${ECHO_T}$cf_cv_have_utmp" >&6
+
+if test $cf_cv_have_utmp != no ; then
+       cat >>confdefs.h <<\EOF
+#define HAVE_UTMP 1
+EOF
+
+       test $cf_cv_have_utmp = utmpx && cat >>confdefs.h <<\EOF
+#define UTMPX_FOR_UTMP 1
+EOF
+
+if test $cf_cv_have_utmp != no ; then
+echo "$as_me:4751: checking if ${cf_cv_have_utmp}.ut_host is declared" >&5
+echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_host is declared... $ECHO_C" >&6
+if test "${cf_cv_have_utmp_ut_host+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4758 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+int
+main ()
+{
+struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4772: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4775: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4778: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4781: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp_ut_host=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_utmp_ut_host=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+echo "$as_me:4793: result: $cf_cv_have_utmp_ut_host" >&5
+echo "${ECHO_T}$cf_cv_have_utmp_ut_host" >&6
+test $cf_cv_have_utmp_ut_host != no && cat >>confdefs.h <<\EOF
+#define HAVE_UTMP_UT_HOST 1
+EOF
+
+fi
+
+if test $cf_cv_have_utmp != no ; then
+echo "$as_me:4802: checking if ${cf_cv_have_utmp}.ut_syslen is declared" >&5
+echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_syslen is declared... $ECHO_C" >&6
+if test "${cf_cv_have_utmp_ut_syslen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4809 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+int
+main ()
+{
+struct $cf_cv_have_utmp x; int y = x.ut_syslen
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4823: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4826: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4829: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4832: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp_ut_syslen=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_utmp_ut_syslen=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+echo "$as_me:4844: result: $cf_cv_have_utmp_ut_syslen" >&5
+echo "${ECHO_T}$cf_cv_have_utmp_ut_syslen" >&6
+test $cf_cv_have_utmp_ut_syslen != no && cat >>confdefs.h <<\EOF
+#define HAVE_UTMP_UT_SYSLEN 1
+EOF
+
+fi
+
+if test $cf_cv_have_utmp != no ; then
+echo "$as_me:4853: checking if ${cf_cv_have_utmp}.ut_name is declared" >&5
+echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_name is declared... $ECHO_C" >&6
+if test "${cf_cv_have_utmp_ut_name+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cf_cv_have_utmp_ut_name=no
+cf_utmp_includes="
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+#define getutent getutxent
+#ifdef USE_LASTLOG
+#include <lastlog.h>           /* may conflict with utmpx.h on Linux */
+#endif
+"
+for cf_header in ut_name ut_user ; do
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4870 "configure"
+#include "confdefs.h"
+$cf_utmp_includes
+int
+main ()
+{
+struct $cf_cv_have_utmp x;
+        char *name = x.$cf_header;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4884: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4887: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4890: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4893: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp_ut_name=$cf_header
+        break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
+fi
+echo "$as_me:4905: result: $cf_cv_have_utmp_ut_name" >&5
+echo "${ECHO_T}$cf_cv_have_utmp_ut_name" >&6
+
+case $cf_cv_have_utmp_ut_name in #(vi
+no) #(vi
+       { { echo "$as_me:4910: error: Cannot find declaration for ut.ut_name" >&5
+echo "$as_me: error: Cannot find declaration for ut.ut_name" >&2;}
+   { (exit 1); exit 1; }; }
+       ;;
+ut_user)
+       cat >>confdefs.h <<\EOF
+#define ut_name ut_user
+EOF
+
+       ;;
+esac
+fi
+
+if test $cf_cv_have_utmp != no ; then
+echo "$as_me:4924: checking for exit-status in $cf_cv_have_utmp" >&5
+echo $ECHO_N "checking for exit-status in $cf_cv_have_utmp... $ECHO_C" >&6
+if test "${cf_cv_have_utmp_ut_xstatus+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+for cf_result in \
+       ut_exit.__e_exit \
+       ut_exit.e_exit \
+       ut_exit.ut_e_exit \
+       ut_exit.ut_exit
+do
+cat >conftest.$ac_ext <<_ACEOF
+#line 4937 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+int
+main ()
+{
+struct $cf_cv_have_utmp x; long y = x.$cf_result = 0
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4951: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4954: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4957: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4960: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp_ut_xstatus=$cf_result
+        break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_utmp_ut_xstatus=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+done
+
+fi
+echo "$as_me:4973: result: $cf_cv_have_utmp_ut_xstatus" >&5
+echo "${ECHO_T}$cf_cv_have_utmp_ut_xstatus" >&6
+if test $cf_cv_have_utmp_ut_xstatus != no ; then
+       cat >>confdefs.h <<\EOF
+#define HAVE_UTMP_UT_XSTATUS 1
+EOF
+
+       cat >>confdefs.h <<EOF
+#define ut_xstatus $cf_cv_have_utmp_ut_xstatus
+EOF
+
+fi
+fi
+
+if test $cf_cv_have_utmp != no ; then
+echo "$as_me:4988: checking if ${cf_cv_have_utmp}.ut_xtime is declared" >&5
+echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_xtime is declared... $ECHO_C" >&6
+if test "${cf_cv_have_utmp_ut_xtime+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 4995 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+int
+main ()
+{
+struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5009: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:5012: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5015: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5018: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp_ut_xtime=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line 5025 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+int
+main ()
+{
+struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5039: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:5042: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5045: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5048: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp_ut_xtime=define
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_utmp_ut_xtime=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:5062: result: $cf_cv_have_utmp_ut_xtime" >&5
+echo "${ECHO_T}$cf_cv_have_utmp_ut_xtime" >&6
+if test $cf_cv_have_utmp_ut_xtime != no ; then
+       cat >>confdefs.h <<\EOF
+#define HAVE_UTMP_UT_XTIME 1
+EOF
+
+       if test $cf_cv_have_utmp_ut_xtime = define ; then
+               cat >>confdefs.h <<\EOF
+#define ut_xtime ut_tv.tv_sec
+EOF
+
+       fi
+fi
+fi
+
+if test $cf_cv_have_utmp != no ; then
+echo "$as_me:5079: checking if ${cf_cv_have_utmp}.ut_session is declared" >&5
+echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_session is declared... $ECHO_C" >&6
+if test "${cf_cv_have_utmp_ut_session+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cat >conftest.$ac_ext <<_ACEOF
+#line 5086 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+int
+main ()
+{
+struct $cf_cv_have_utmp x; long y = x.ut_session
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5100: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:5103: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5106: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5109: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_utmp_ut_session=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_utmp_ut_session=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:5120: result: $cf_cv_have_utmp_ut_session" >&5
+echo "${ECHO_T}$cf_cv_have_utmp_ut_session" >&6
+if test $cf_cv_have_utmp_ut_session != no ; then
+       cat >>confdefs.h <<\EOF
+#define HAVE_UTMP_UT_SESSION 1
+EOF
+
+fi
+fi
+
+echo "$as_me:5130: checking if $cf_cv_have_utmp is SYSV flavor" >&5
+echo $ECHO_N "checking if $cf_cv_have_utmp is SYSV flavor... $ECHO_C" >&6
+if test "${cf_cv_sysv_utmp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
+cat >conftest.$ac_ext <<_ACEOF
+#line 5138 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <${cf_cv_have_utmp}.h>
+int
+main ()
+{
+
+struct $cf_cv_have_utmp x;
+       set${cf_prefix}ent ();
+       get${cf_prefix}id(&x);
+       put${cf_prefix}line(&x);
+       end${cf_prefix}ent();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:5157: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:5160: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:5163: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5166: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_sysv_utmp=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_sysv_utmp=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:5177: result: $cf_cv_sysv_utmp" >&5
+echo "${ECHO_T}$cf_cv_sysv_utmp" >&6
+test $cf_cv_sysv_utmp = yes && cat >>confdefs.h <<\EOF
+#define USE_SYSV_UTMP 1
+EOF
+
+fi
+
+for ac_header in lastlog.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:5188: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5194 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:5198: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:5204: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:5223: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:5233: checking for struct lastlog" >&5
+echo $ECHO_N "checking for struct lastlog... $ECHO_C" >&6
+if test "${cf_cv_struct_lastlog+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+if test "$cross_compiling" = yes; then
+
+cf_cv_struct_lastlog=unknown
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5244 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <time.h>
+#include <lastlog.h>
+
+int main()
+{
+       struct lastlog data;
+       return (sizeof(data.ll_time) != sizeof(time_t));
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:5258: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:5261: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:5263: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5266: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+cf_cv_struct_lastlog=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+cf_cv_struct_lastlog=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+echo "$as_me:5280: result: $cf_cv_struct_lastlog" >&5
+echo "${ECHO_T}$cf_cv_struct_lastlog" >&6
+
+test $cf_cv_struct_lastlog != no && cat >>confdefs.h <<\EOF
+#define USE_STRUCT_LASTLOG 1
+EOF
+
+for ac_header in \
+sys/param.h \
+
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:5292: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5298 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:5302: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:5308: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:5327: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:5337: checking if POSIX saved-ids are supported" >&5
+echo $ECHO_N "checking if POSIX saved-ids are supported... $ECHO_C" >&6
+if test "${cf_cv_posix_saved_ids+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 5344 "configure"
+#include "confdefs.h"
+
+#include <unistd.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>         /* this may define "BSD" */
+#endif
+
+int
+main ()
+{
+
+#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
+       void *p = (void *) seteuid;
+       int x = seteuid(geteuid());
+#elif defined(BSD) && (BSD >= 199103)
+/* The BSD's may implement the runtime check - and it fails.
+ * However, saved-ids work almost like POSIX (close enough for most uses).
+ */
+#else
+make an error
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:5372: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:5375: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:5378: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5381: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_posix_saved_ids=yes
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+if test "$cross_compiling" = yes; then
+  cf_cv_posix_saved_ids=unknown
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5393 "configure"
+#include "confdefs.h"
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <unistd.h>
+int main()
+{
+       void *p = (void *) seteuid;
+       long code = sysconf(_SC_SAVED_IDS);
+       ${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:5408: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:5411: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:5413: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5416: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_posix_saved_ids=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_saved_ids=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:5432: result: $cf_cv_posix_saved_ids" >&5
+echo "${ECHO_T}$cf_cv_posix_saved_ids" >&6
+
+test "$cf_cv_posix_saved_ids" = yes && cat >>confdefs.h <<\EOF
+#define HAVE_POSIX_SAVED_IDS 1
+EOF
+
+# compute a reasonable value for $TERM to give tgetent(), since we may be
+# running in 'screen', which sets $TERMCAP to a specific entry that is not
+# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
+# discard $TERMCAP.
+cf_TERMVAR=vt100
+test -n "$TERMCAP" && cf_TERMVAR="$TERM"
+test -z "$cf_TERMVAR" && cf_TERMVAR=vt100
+
+echo "$as_me:5447: checking if we want full tgetent function" >&5
+echo $ECHO_N "checking if we want full tgetent function... $ECHO_C" >&6
+
+# Check whether --enable-full-tgetent or --disable-full-tgetent was given.
+if test "${enable_full_tgetent+set}" = set; then
+  enableval="$enable_full_tgetent"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    cf_full_tgetent=no
+  else
+    cf_full_tgetent=yes
+  fi
+else
+  enableval=yes
+  cf_full_tgetent=yes
+
+fi;
+echo "$as_me:5464: result: $cf_full_tgetent" >&5
+echo "${ECHO_T}$cf_full_tgetent" >&6
+
+if test "$cf_full_tgetent" = yes ; then
+       cf_test_message="full tgetent"
+else
+       cf_test_message="tgetent"
+fi
+
+echo "$as_me:5473: checking for $cf_test_message function" >&5
+echo $ECHO_N "checking for $cf_test_message function... $ECHO_C" >&6
+if test "${cf_cv_lib_tgetent+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_save_LIBS="$LIBS"
+cf_cv_lib_tgetent=no
+if test "$cf_full_tgetent" = yes ; then
+       cf_TERMLIB="termcap termlib ncurses curses"
+       cf_TERMTST="buffer[0] == 0"
+else
+       cf_TERMLIB="termlib ncurses curses"
+       cf_TERMTST="0"
+fi
+for cf_termlib in '' $cf_TERMLIB ; do
+       LIBS="$cf_save_LIBS"
+       test -n "$cf_termlib" && LIBS="-l$cf_termlib $LIBS"
+       if test "$cross_compiling" = yes; then
+  echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&5
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5495 "configure"
+#include "confdefs.h"
+
+/* terminfo implementations ignore the buffer argument, making it useless for
+ * the xterm application, which uses this information to make a new TERMCAP
+ * environment variable.
+ */
+int main()
+{
+       char buffer[1024];
+       buffer[0] = 0;
+       tgetent(buffer, "$cf_TERMVAR");
+       ${cf_cv_main_return:-return} ($cf_TERMTST); }
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:5510: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:5513: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:5515: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5518: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&5
+        if test -n "$cf_termlib" ; then
+               cf_cv_lib_tgetent="-l$cf_termlib"
+        else
+               cf_cv_lib_tgetent=yes
+        fi
+        break
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "no, there is no termcap/tgetent in $cf_termlib" 1>&5
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+done
+LIBS="$cf_save_LIBS"
+
+fi
+echo "$as_me:5539: result: $cf_cv_lib_tgetent" >&5
+echo "${ECHO_T}$cf_cv_lib_tgetent" >&6
+
+# If we found a working tgetent(), set LIBS and check for termcap.h.
+# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
+# not have side effects other than setting the cache variable, because
+# they are not executed when a cached value exists.)
+if test "$cf_cv_lib_tgetent" != no ; then
+       test "$cf_cv_lib_tgetent" != yes && LIBS="$cf_cv_lib_tgetent $LIBS"
+       cat >>confdefs.h <<\EOF
+#define USE_TERMCAP 1
+EOF
+
+       if test "$cf_full_tgetent" = no ; then
+               cat >conftest.$ac_ext <<_ACEOF
+#line 5554 "configure"
+#include "confdefs.h"
+
+#include <termcap.h>
+int
+main ()
+{
+
+#ifdef NCURSES_VERSION
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5570: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:5573: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5576: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5579: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cat >>confdefs.h <<\EOF
+#define HAVE_TERMCAP_H 1
+EOF
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+       else
+
+for ac_header in termcap.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:5595: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5601 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:5605: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:5611: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:5630: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+       fi
+else
+        # If we didn't find a tgetent() that supports the buffer
+        # argument, look again to see whether we can find even
+        # a crippled one.  A crippled tgetent() is still useful to
+        # validate values for the TERM environment variable given to
+        # child processes.
+       echo "$as_me:5647: checking for partial tgetent function" >&5
+echo $ECHO_N "checking for partial tgetent function... $ECHO_C" >&6
+if test "${cf_cv_lib_part_tgetent+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+       cf_cv_lib_part_tgetent=no
+       for cf_termlib in $cf_TERMLIB ; do
+               LIBS="$cf_save_LIBS -l$cf_termlib"
+               cat >conftest.$ac_ext <<_ACEOF
+#line 5657 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+tgetent(0, "$cf_TERMVAR")
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:5669: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:5672: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:5675: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5678: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  echo "there is a terminfo/tgetent in $cf_termlib" 1>&5
+                        cf_cv_lib_part_tgetent="-l$cf_termlib"
+                        break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       done
+       LIBS="$cf_save_LIBS"
+
+fi
+echo "$as_me:5692: result: $cf_cv_lib_part_tgetent" >&5
+echo "${ECHO_T}$cf_cv_lib_part_tgetent" >&6
+
+       if test "$cf_cv_lib_part_tgetent" != no ; then
+               LIBS="$cf_cv_lib_part_tgetent $LIBS"
+
+for ac_header in termcap.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:5701: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 5707 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:5711: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:5717: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:5736: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+                # If this is linking against ncurses, we'll trigger the
+                # ifdef in resize.c that turns the termcap stuff back off.
+               cat >>confdefs.h <<\EOF
+#define USE_TERMINFO 1
+EOF
+
+       fi
+fi
+
+echo "$as_me:5755: checking for directory to install resource files" >&5
+echo $ECHO_N "checking for directory to install resource files... $ECHO_C" >&6
+
+# Check whether --with-app-defaults or --without-app-defaults was given.
+if test "${with_app_defaults+set}" = set; then
+  withval="$with_app_defaults"
+
+else
+  withval="${appsdir:-'\$(exec_prefix)/lib/X11/app-defaults'}"
+fi; if test -n "'\$(exec_prefix)/lib/X11/app-defaults'" ; then
+
+if test "x$prefix" != xNONE; then
+  cf_path_syntax="$prefix"
+else
+  cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".$withval" in #(vi
+.\$\(*\)*|.\'*\'*) #(vi
+  ;;
+..|./*|.\\*) #(vi
+  ;;
+.[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
+  ;;
+.\${*prefix}*) #(vi
+  eval withval="$withval"
+  case ".$withval" in #(vi
+  .NONE/*)
+    withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
+    ;;
+  esac
+  ;; #(vi
+.no|.NONE/*)
+  withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
+  ;;
+*)
+  { { echo "$as_me:5791: error: expected a pathname, not \"$withval\"" >&5
+echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
+   { (exit 1); exit 1; }; }
+  ;;
+esac
+
+fi
+appsdir="$withval"
+
+echo "$as_me:5800: result: $appsdir" >&5
+echo "${ECHO_T}$appsdir" >&6
+
+no_appsdir=
+test "$appsdir" = no && no_appsdir="#"
+
+echo "$as_me:5806: checking for directory to install icons" >&5
+echo $ECHO_N "checking for directory to install icons... $ECHO_C" >&6
+
+# Check whether --with-icondir or --without-icondir was given.
+if test "${with_icondir+set}" = set; then
+  withval="$with_icondir"
+
+else
+  withval="${icondir:-'\$(exec_prefix)/share/pixmaps'}"
+fi; if test -n "'\$(exec_prefix)/share/pixmaps'" ; then
+
+if test "x$prefix" != xNONE; then
+  cf_path_syntax="$prefix"
+else
+  cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".$withval" in #(vi
+.\$\(*\)*|.\'*\'*) #(vi
+  ;;
+..|./*|.\\*) #(vi
+  ;;
+.[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
+  ;;
+.\${*prefix}*) #(vi
+  eval withval="$withval"
+  case ".$withval" in #(vi
+  .NONE/*)
+    withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
+    ;;
+  esac
+  ;; #(vi
+.no|.NONE/*)
+  withval=`echo $withval | sed -e s%NONE%$cf_path_syntax%`
+  ;;
+*)
+  { { echo "$as_me:5842: error: expected a pathname, not \"$withval\"" >&5
+echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
+   { (exit 1); exit 1; }; }
+  ;;
+esac
+
+fi
+icondir="$withval"
+
+echo "$as_me:5851: result: $icondir" >&5
+echo "${ECHO_T}$icondir" >&6
+
+no_icondir=
+test "$icondir" = no && no_icondir="#"
+
+# Comment-out the install-desktop rule if the desktop-utils are not found.
+echo "$as_me:5858: checking if you want to install desktop files" >&5
+echo $ECHO_N "checking if you want to install desktop files... $ECHO_C" >&6
+
+# Check whether --enable-desktop or --disable-desktop was given.
+if test "${enable_desktop+set}" = set; then
+  enableval="$enable_desktop"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_desktop=$enableval
+  else
+    enable_desktop=$enableval
+  fi
+else
+  enableval=yes
+  enable_desktop=$enableval
+
+fi;
+echo "$as_me:5875: result: $enable_desktop" >&5
+echo "${ECHO_T}$enable_desktop" >&6
+
+desktop_utils=
+if test "$enable_desktop" = yes ; then
+# Extract the first word of "desktop-file-install", so it can be a program name with args.
+set dummy desktop-file-install; ac_word=$2
+echo "$as_me:5882: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_desktop_utils+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$desktop_utils"; then
+  ac_cv_prog_desktop_utils="$desktop_utils" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_desktop_utils="yes"
+echo "$as_me:5897: found $ac_dir/$ac_word" >&5
+break
+done
+
+  test -z "$ac_cv_prog_desktop_utils" && ac_cv_prog_desktop_utils="no"
+fi
+fi
+desktop_utils=$ac_cv_prog_desktop_utils
+if test -n "$desktop_utils"; then
+  echo "$as_me:5906: result: $desktop_utils" >&5
+echo "${ECHO_T}$desktop_utils" >&6
+else
+  echo "$as_me:5909: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+
+test "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
+
+# inherit SINSTALL_OPTS from environment to allow packager to customize it.
+
+echo "$as_me:5919: checking for install-permissions reference" >&5
+echo $ECHO_N "checking for install-permissions reference... $ECHO_C" >&6
+
+# Check whether --with-reference or --without-reference was given.
+if test "${with_reference+set}" = set; then
+  withval="$with_reference"
+  with_reference=$withval
+else
+  with_reference=xterm
+fi;
+echo "$as_me:5929: result: $with_reference" >&5
+echo "${ECHO_T}$with_reference" >&6
+
+with_full_paths=yes
+
+       case $cf_cv_system_name in
+       os2*)   PATH_SEPARATOR=';'  ;;
+       *)      PATH_SEPARATOR=':'  ;;
+       esac
+
+test -z "$XTERM_PATH" && XTERM_PATH=$with_reference
+for ac_prog in $XTERM_PATH $with_reference
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:5944: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_XTERM_PATH+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $XTERM_PATH in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_XTERM_PATH="$XTERM_PATH" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_XTERM_PATH="$ac_dir/$ac_word"
+   echo "$as_me:5961: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  ;;
+esac
+fi
+XTERM_PATH=$ac_cv_path_XTERM_PATH
+
+if test -n "$XTERM_PATH"; then
+  echo "$as_me:5972: result: $XTERM_PATH" >&5
+echo "${ECHO_T}$XTERM_PATH" >&6
+else
+  echo "$as_me:5975: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$XTERM_PATH" && break
+done
+test -n "$XTERM_PATH" || XTERM_PATH="$XTERM_PATH"
+
+cf_path_prog=""
+cf_path_args=""
+IFS="${IFS:-   }"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
+for cf_temp in $ac_cv_path_XTERM_PATH
+do
+       if test -z "$cf_path_prog" ; then
+               if test "$with_full_paths" = yes ; then
+
+if test "x$prefix" != xNONE; then
+  cf_path_syntax="$prefix"
+else
+  cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".$cf_temp" in #(vi
+.\$\(*\)*|.\'*\'*) #(vi
+  ;;
+..|./*|.\\*) #(vi
+  ;;
+.[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
+  ;;
+.\${*prefix}*) #(vi
+  eval cf_temp="$cf_temp"
+  case ".$cf_temp" in #(vi
+  .NONE/*)
+    cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
+    ;;
+  esac
+  ;; #(vi
+.no|.NONE/*)
+  cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
+  ;;
+*)
+  break
+  ;;
+esac
+
+                       cf_path_prog="$cf_temp"
+               else
+                       cf_path_prog="`basename $cf_temp`"
+               fi
+       elif test -z "$cf_path_args" ; then
+               cf_path_args="$cf_temp"
+       else
+               cf_path_args="$cf_path_args $cf_temp"
+       fi
+done
+IFS="$cf_save_ifs"
+
+if test -n "$cf_path_prog" ; then
+
+echo "${as_me:-configure}:6034: testing defining path for ${cf_path_prog} ..." 1>&5
+
+       cat >>confdefs.h <<EOF
+#define XTERM_PATH_PATH "$cf_path_prog"
+EOF
+
+       test -n "$cf_path_args" && cat >>confdefs.h <<EOF
+#define XTERM_PATH_ARGS "$cf_path_args"
+EOF
+
+fi
+
+# If any of --program-prefix, --program-suffix or --program-transform-name is
+# given, accept an option tell the makefile to create a symbolic link, e.g.,
+# to "xterm" on install.
+XTERM_SYMLINK=NONE
+
+if test "$program_transform_name" != "'s,,,'" ; then
+cf_name=`echo "$program_transform_name" | sed -e 's,\\$\\$,$,g'`
+cf_name=`echo xterm |sed -e "$cf_name"`
+echo "$as_me:6054: checking for symbolic link to create to $cf_name" >&5
+echo $ECHO_N "checking for symbolic link to create to $cf_name... $ECHO_C" >&6
+
+# Check whether --with-xterm-symlink or --without-xterm-symlink was given.
+if test "${with_xterm_symlink+set}" = set; then
+  withval="$with_xterm_symlink"
+  with_symlink=$withval
+else
+  with_symlink=xterm
+fi;
+echo "$as_me:6064: result: $with_symlink" >&5
+echo "${ECHO_T}$with_symlink" >&6
+test "$with_symlink" = yes && with_symlink=xterm
+test -n "$with_symlink" && \
+       test "$with_symlink" != no && \
+       test "$with_symlink" != $cf_name && \
+       XTERM_SYMLINK="$with_symlink"
+fi
+
+echo "$as_me:6073: checking if you want to disable setuid" >&5
+echo $ECHO_N "checking if you want to disable setuid... $ECHO_C" >&6
+
+# Check whether --enable-setuid or --disable-setuid was given.
+if test "${enable_setuid+set}" = set; then
+  enableval="$enable_setuid"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    disable_setuid=yes
+  else
+    disable_setuid=no
+  fi
+else
+  enableval=yes
+  disable_setuid=no
+
+fi;
+echo "$as_me:6090: result: $disable_setuid" >&5
+echo "${ECHO_T}$disable_setuid" >&6
+
+echo "$as_me:6093: checking if you want to disable setgid" >&5
+echo $ECHO_N "checking if you want to disable setgid... $ECHO_C" >&6
+
+# Check whether --enable-setgid or --disable-setgid was given.
+if test "${enable_setgid+set}" = set; then
+  enableval="$enable_setgid"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    disable_setgid=yes
+  else
+    disable_setgid=no
+  fi
+else
+  enableval=yes
+  disable_setgid=no
+
+fi;
+echo "$as_me:6110: result: $disable_setgid" >&5
+echo "${ECHO_T}$disable_setgid" >&6
+
+echo "$as_me:6113: checking if you want to run xterm setuid to a given user" >&5
+echo $ECHO_N "checking if you want to run xterm setuid to a given user... $ECHO_C" >&6
+
+# Check whether --with-setuid or --without-setuid was given.
+if test "${with_setuid+set}" = set; then
+  withval="$with_setuid"
+  use_given_setuid=$withval
+else
+  use_given_setuid=no
+fi;
+echo "$as_me:6123: result: $use_given_setuid" >&5
+echo "${ECHO_T}$use_given_setuid" >&6
+
+if test "$use_given_setuid" != no ; then
+       if test "$use_given_setuid" = yes ; then
+               cf_cv_given_setuid=root
+       else
+               cf_cv_given_setuid=$use_given_setuid
+       fi
+       SINSTALL_OPTS="$SINSTALL_OPTS u+s -u $cf_cv_given_setuid"
+fi
+
+echo "$as_me:6135: checking if you want to run xterm setgid to match utmp/utmpx file" >&5
+echo $ECHO_N "checking if you want to run xterm setgid to match utmp/utmpx file... $ECHO_C" >&6
+
+# Check whether --with-utmp-setgid or --without-utmp-setgid was given.
+if test "${with_utmp_setgid+set}" = set; then
+  withval="$with_utmp_setgid"
+  use_utmp_setgid=$withval
+else
+  use_utmp_setgid=no
+fi;
+echo "$as_me:6145: result: $use_utmp_setgid" >&5
+echo "${ECHO_T}$use_utmp_setgid" >&6
+
+if test "$use_utmp_setgid" != no ; then
+       if test "$use_utmp_setgid" = yes ; then
+
+if test $cf_cv_have_utmp != no ; then
+echo "$as_me:6152: checking for utmp/utmpx group" >&5
+echo $ECHO_N "checking for utmp/utmpx group... $ECHO_C" >&6
+if test "${cf_cv_utmp_group+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+for cf_utmp_path in /var/adm /var/run
+do
+       for cf_utmp_file in utmpx utmp
+       do
+               if test -f $cf_utmp_path/$cf_utmp_file
+               then
+                       cf_cv_utmp_group=root
+
+                       cf_option="-l -L"
+
+                       # Expect listing to have fields like this:
+                       #-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
+                       ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
+                       read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
+                       if test -z "$cf_rest" ; then
+                               cf_option="$cf_option -g"
+                               ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
+                               read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
+                       fi
+                       rm -f conftest
+
+                       # If we have a pathname, and the date fields look right, assume we've
+                       # captured the group as well.
+                       if test -n "$cf_rest" ; then
+                               cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[0-9:]//g'`
+                               if test -z "$cf_test" ; then
+                                       cf_cv_utmp_group=$cf_grp;
+                               fi
+                       fi
+                       break
+               fi
+       done
+       test -n "$cf_cv_utmp_group" && break
+done
+
+fi
+echo "$as_me:6194: result: $cf_cv_utmp_group" >&5
+echo "${ECHO_T}$cf_cv_utmp_group" >&6
+else
+       { { echo "$as_me:6197: error: cannot find utmp group" >&5
+echo "$as_me: error: cannot find utmp group" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+       else
+               cf_cv_utmp_group=$use_utmp_setgid
+       fi
+       if test "$cf_cv_posix_saved_ids" != yes ; then
+               { { echo "$as_me:6206: error: Your system does not support POSIX saved-ids" >&5
+echo "$as_me: error: Your system does not support POSIX saved-ids" >&2;}
+   { (exit 1); exit 1; }; }
+       fi
+       cat >>confdefs.h <<\EOF
+#define USE_UTMP_SETGID 1
+EOF
+
+       SINSTALL_OPTS="$SINSTALL_OPTS g+s -g $cf_cv_utmp_group"
+fi
+
+echo "$as_me:6217: checking if you want to link with utempter" >&5
+echo $ECHO_N "checking if you want to link with utempter... $ECHO_C" >&6
+
+# Check whether --with-utempter or --without-utempter was given.
+if test "${with_utempter+set}" = set; then
+  withval="$with_utempter"
+  use_utempter=$withval
+else
+  use_utempter=no
+fi;
+echo "$as_me:6227: result: $use_utempter" >&5
+echo "${ECHO_T}$use_utempter" >&6
+
+if test "$use_utempter" = yes ; then
+
+echo "$as_me:6232: checking if we can link with utempter library" >&5
+echo $ECHO_N "checking if we can link with utempter library... $ECHO_C" >&6
+if test "${cf_cv_have_utempter+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_save_LIBS="$LIBS"
+LIBS="-lutempter $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 6241 "configure"
+#include "confdefs.h"
+
+#include <utempter.h>
+
+int
+main ()
+{
+
+       addToUtmp("/dev/tty", 0, 1);
+       removeFromUtmp();
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6258: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6261: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6264: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6267: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+       cf_cv_have_utempter=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+       cf_cv_have_utempter=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS="$cf_save_LIBS"
+
+fi
+echo "$as_me:6281: result: $cf_cv_have_utempter" >&5
+echo "${ECHO_T}$cf_cv_have_utempter" >&6
+if test "$cf_cv_have_utempter" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define USE_UTEMPTER 1
+EOF
+
+       LIBS="-lutempter $LIBS"
+fi
+
+       test "$cf_cv_have_utempter" != yes && use_utempter=no
+else
+       use_utempter=no
+fi
+
+# Some configurations permit (or require) either setuid or setgid mode.
+# Let the user decide.
+if test "$use_utempter" = yes ; then
+       if test "${enable_setuid+set}" != set ; then
+               disable_setuid=yes
+               test -n "$verbose" && echo "    No --disable-setuid option given, force to yes" 1>&6
+
+echo "${as_me:-configure}:6303: testing No --disable-setuid option given, force to yes ..." 1>&5
+
+       fi
+fi
+
+###    checks for external data
+
+echo "$as_me:6310: checking if external errno is declared" >&5
+echo $ECHO_N "checking if external errno is declared... $ECHO_C" >&6
+if test "${cf_cv_dcl_errno+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    cat >conftest.$ac_ext <<_ACEOF
+#line 6317 "configure"
+#include "confdefs.h"
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+int
+main ()
+{
+int x = (int) errno
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6335: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6338: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6341: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6344: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_dcl_errno=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_dcl_errno=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:6355: result: $cf_cv_dcl_errno" >&5
+echo "${ECHO_T}$cf_cv_dcl_errno" >&6
+
+if test "$cf_cv_dcl_errno" = no ; then
+
+cf_result=`echo "decl_errno" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+    cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+fi
+
+# It's possible (for near-UNIX clones) that the data doesn't exist
+
+echo "$as_me:6370: checking if external errno exists" >&5
+echo $ECHO_N "checking if external errno exists... $ECHO_C" >&6
+if test "${cf_cv_have_errno+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    cat >conftest.$ac_ext <<_ACEOF
+#line 6377 "configure"
+#include "confdefs.h"
+
+#undef errno
+extern int errno;
+
+int
+main ()
+{
+errno = 2
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6392: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6395: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6398: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6401: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_errno=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_errno=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:6412: result: $cf_cv_have_errno" >&5
+echo "${ECHO_T}$cf_cv_have_errno" >&6
+
+if test "$cf_cv_have_errno" = yes ; then
+
+cf_result=`echo "have_errno" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+    cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+fi
+
+echo "$as_me:6425: checking for explicit tty group name" >&5
+echo $ECHO_N "checking for explicit tty group name... $ECHO_C" >&6
+
+# Check whether --with-tty-group or --without-tty-group was given.
+if test "${with_tty_group+set}" = set; then
+  withval="$with_tty_group"
+  cf_tty_group=$withval
+else
+  cf_tty_group=auto...
+fi;
+test -z "$cf_tty_group"    && cf_tty_group=auto...
+test "$cf_tty_group" = yes && cf_tty_group=auto...
+echo "$as_me:6437: result: $cf_tty_group" >&5
+echo "${ECHO_T}$cf_tty_group" >&6
+
+if test "$cf_tty_group" = "auto..." ; then
+echo "$as_me:6441: checking for tty group name" >&5
+echo $ECHO_N "checking for tty group name... $ECHO_C" >&6
+if test "${cf_cv_tty_group_name+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+# If we are configuring as root, it is hard to get a clue about the tty group.
+# But we'll guess based on how our connection is set up - assuming it is done
+# properly.
+
+cf_uid=`id | sed -e 's/^^=*=//' -e 's/(.*$//'`
+# )vi
+if test "$cf_uid" != 0 ; then
+cf_cv_tty_group_name=
+cf_tty_name=`tty`
+test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
+test -z "$cf_tty_name" && cf_tty_name=/dev/tty
+if test -c "$cf_tty_name"
+then
+       cf_option="-l -L"
+
+       # Expect listing to have fields like this:
+       #-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
+       ls $cf_option $cf_tty_name >conftest.out
+       read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
+       if test -z "$cf_rest" ; then
+               cf_option="$cf_option -g"
+               ls $cf_option $cf_tty_name >conftest.out
+               read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
+       fi
+       rm -f conftest.out
+       cf_cv_tty_group_name=$cf_grp
+fi
+fi
+
+# If we cannot deduce the tty group, fall back on hardcoded cases
+
+if test -z "$cf_cv_tty_group_name"
+then
+case $host_os in #(vi
+osf*) #(vi
+       cf_cv_tty_group_name="terminal"
+       ;;
+*)
+       cf_cv_tty_group_name="unknown"
+       if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
+               cf_cv_tty_group_name="tty"
+       fi
+       ;;
+esac
+fi
+
+fi
+echo "$as_me:6494: result: $cf_cv_tty_group_name" >&5
+echo "${ECHO_T}$cf_cv_tty_group_name" >&6
+cf_tty_group="$cf_cv_tty_group_name"
+else
+       # if configure option, always do this
+       cat >>confdefs.h <<\EOF
+#define USE_TTY_GROUP 1
+EOF
+
+fi
+
+cat >>confdefs.h <<EOF
+#define TTY_GROUP_NAME "$cf_tty_group"
+EOF
+
+# This is only a double-check that the group-name we obtained above really
+# does apply to the device.  We cannot perform this test if we are in batch
+# mode, or if we are cross-compiling.
+
+echo "$as_me:6513: checking if we may use the $cf_tty_group group" >&5
+echo $ECHO_N "checking if we may use the $cf_tty_group group... $ECHO_C" >&6
+if test "${cf_cv_tty_group+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_tty_name=`tty`
+if test "$cf_tty_name" != "not a tty"
+then
+if test "$cross_compiling" = yes; then
+  cf_cv_tty_group=unknown
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6526 "configure"
+#include "confdefs.h"
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <grp.h>
+int main()
+{
+       struct stat sb;
+       struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
+       char *name = ttyname(0);
+
+       endgrent();
+       if (ttygrp != 0
+        && name != 0
+        && stat(name, &sb) == 0
+        && sb.st_gid != getgid()
+        && sb.st_gid == ttygrp->gr_gid) {
+               ${cf_cv_main_return:-return} (0);
+       }
+       ${cf_cv_main_return:-return} (1);
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:6552: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6555: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:6557: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6560: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_tty_group=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_tty_group=no
+fi
+rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+elif test "$cross_compiling" = yes; then
+       cf_cv_tty_group=unknown
+else
+       cf_cv_tty_group=yes
+fi
+
+fi
+echo "$as_me:6578: result: $cf_cv_tty_group" >&5
+echo "${ECHO_T}$cf_cv_tty_group" >&6
+
+if test $cf_cv_tty_group = no ; then
+       { echo "$as_me:6582: WARNING: Cannot use $cf_tty_group group" >&5
+echo "$as_me: WARNING: Cannot use $cf_tty_group group" >&2;}
+else
+       cat >>confdefs.h <<\EOF
+#define USE_TTY_GROUP 1
+EOF
+
+fi
+
+###    checks for system services and user specified options
+
+echo "$as_me:6593: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6
+if test "${ac_cv_header_sys_wait_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6599 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+int
+main ()
+{
+  int s;
+  wait (&s);
+  s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6621: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6624: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6627: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6630: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_sys_wait_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_header_sys_wait_h=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:6640: result: $ac_cv_header_sys_wait_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6
+if test $ac_cv_header_sys_wait_h = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_SYS_WAIT_H 1
+EOF
+
+fi
+
+echo "$as_me:6650: checking for POSIX wait functions" >&5
+echo $ECHO_N "checking for POSIX wait functions... $ECHO_C" >&6
+if test "${cf_cv_posix_wait+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 6657 "configure"
+#include "confdefs.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+int
+main ()
+{
+
+       int stat_loc;
+       pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
+       pid_t pid2 = wait(&stat_loc);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6680: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6683: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6686: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6689: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_posix_wait=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_wait=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:6700: result: $cf_cv_posix_wait" >&5
+echo "${ECHO_T}$cf_cv_posix_wait" >&6
+test "$cf_cv_posix_wait" = yes && cat >>confdefs.h <<\EOF
+#define USE_POSIX_WAIT 1
+EOF
+
+echo "$as_me:6706: checking if external sys_nerr is declared" >&5
+echo $ECHO_N "checking if external sys_nerr is declared... $ECHO_C" >&6
+if test "${cf_cv_dcl_sys_nerr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    cat >conftest.$ac_ext <<_ACEOF
+#line 6713 "configure"
+#include "confdefs.h"
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+int
+main ()
+{
+int x = (int) sys_nerr
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6731: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6734: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6737: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6740: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_dcl_sys_nerr=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_dcl_sys_nerr=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:6751: result: $cf_cv_dcl_sys_nerr" >&5
+echo "${ECHO_T}$cf_cv_dcl_sys_nerr" >&6
+
+if test "$cf_cv_dcl_sys_nerr" = no ; then
+
+cf_result=`echo "decl_sys_nerr" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+    cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+fi
+
+# It's possible (for near-UNIX clones) that the data doesn't exist
+
+echo "$as_me:6766: checking if external sys_nerr exists" >&5
+echo $ECHO_N "checking if external sys_nerr exists... $ECHO_C" >&6
+if test "${cf_cv_have_sys_nerr+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    cat >conftest.$ac_ext <<_ACEOF
+#line 6773 "configure"
+#include "confdefs.h"
+
+#undef sys_nerr
+extern int sys_nerr;
+
+int
+main ()
+{
+sys_nerr = 2
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6788: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6791: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6794: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6797: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_sys_nerr=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_sys_nerr=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:6808: result: $cf_cv_have_sys_nerr" >&5
+echo "${ECHO_T}$cf_cv_have_sys_nerr" >&6
+
+if test "$cf_cv_have_sys_nerr" = yes ; then
+
+cf_result=`echo "have_sys_nerr" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+    cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+fi
+
+echo "$as_me:6821: checking if external sys_errlist is declared" >&5
+echo $ECHO_N "checking if external sys_errlist is declared... $ECHO_C" >&6
+if test "${cf_cv_dcl_sys_errlist+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    cat >conftest.$ac_ext <<_ACEOF
+#line 6828 "configure"
+#include "confdefs.h"
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+int
+main ()
+{
+int x = (int) sys_errlist
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6846: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6849: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6852: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6855: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_dcl_sys_errlist=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_dcl_sys_errlist=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:6866: result: $cf_cv_dcl_sys_errlist" >&5
+echo "${ECHO_T}$cf_cv_dcl_sys_errlist" >&6
+
+if test "$cf_cv_dcl_sys_errlist" = no ; then
+
+cf_result=`echo "decl_sys_errlist" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+    cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+fi
+
+# It's possible (for near-UNIX clones) that the data doesn't exist
+
+echo "$as_me:6881: checking if external sys_errlist exists" >&5
+echo $ECHO_N "checking if external sys_errlist exists... $ECHO_C" >&6
+if test "${cf_cv_have_sys_errlist+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    cat >conftest.$ac_ext <<_ACEOF
+#line 6888 "configure"
+#include "confdefs.h"
+
+#undef sys_errlist
+extern int sys_errlist;
+
+int
+main ()
+{
+sys_errlist = 2
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6903: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6906: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6909: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6912: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_have_sys_errlist=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_have_sys_errlist=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:6923: result: $cf_cv_have_sys_errlist" >&5
+echo "${ECHO_T}$cf_cv_have_sys_errlist" >&6
+
+if test "$cf_cv_have_sys_errlist" = yes ; then
+
+cf_result=`echo "have_sys_errlist" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+    cat >>confdefs.h <<EOF
+#define $cf_result 1
+EOF
+
+fi
+
+for ac_header in \
+termios.h \
+stdlib.h \
+X11/Intrinsic.h \
+
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:6943: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6949 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:6953: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:6959: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:6978: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:6988: checking if we should define SYSV" >&5
+echo $ECHO_N "checking if we should define SYSV... $ECHO_C" >&6
+if test "${cf_cv_sysv+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 6995 "configure"
+#include "confdefs.h"
+
+#undef  SYSV
+#define SYSV 1                 /* get Xos.h to declare sys_errlist[] */
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>            /* look for wchar_t */
+#endif
+#ifdef HAVE_X11_INTRINSIC_H
+#include <X11/Intrinsic.h>     /* Intrinsic.h has other traps... */
+#endif
+#ifdef HAVE_TERMIOS_H          /* needed for HPUX 10.20 */
+#include <termios.h>
+#define STRUCT_TERMIOS struct termios
+#else
+#define STRUCT_TERMIOS struct termio
+#endif
+#include <curses.h>
+#include <term.h>              /* eliminate most BSD hacks */
+#include <errno.h>             /* declare sys_errlist on older systems */
+#include <sys/termio.h>                /* eliminate most of the remaining ones */
+
+int
+main ()
+{
+
+static STRUCT_TERMIOS d_tio;
+       d_tio.c_cc[VINTR] = 0;
+       d_tio.c_cc[VQUIT] = 0;
+       d_tio.c_cc[VERASE] = 0;
+       d_tio.c_cc[VKILL] = 0;
+       d_tio.c_cc[VEOF] = 0;
+       d_tio.c_cc[VEOL] = 0;
+       d_tio.c_cc[VMIN] = 0;
+       d_tio.c_cc[VTIME] = 0;
+#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
+sys_errlist[0] = "";           /* Cygwin mis-declares this */
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7039: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:7042: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7045: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7048: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_sysv=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_sysv=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:7059: result: $cf_cv_sysv" >&5
+echo "${ECHO_T}$cf_cv_sysv" >&6
+test "$cf_cv_sysv" = yes && cat >>confdefs.h <<\EOF
+#define SYSV 1
+EOF
+
+echo "$as_me:7065: checking for elf_begin in -lelf" >&5
+echo $ECHO_N "checking for elf_begin in -lelf... $ECHO_C" >&6
+if test "${ac_cv_lib_elf_elf_begin+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lelf  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7073 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char elf_begin ();
+int
+main ()
+{
+elf_begin ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7092: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7095: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7098: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7101: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_elf_elf_begin=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_elf_elf_begin=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:7112: result: $ac_cv_lib_elf_elf_begin" >&5
+echo "${ECHO_T}$ac_cv_lib_elf_elf_begin" >&6
+if test $ac_cv_lib_elf_elf_begin = yes; then
+
+echo "$as_me:7116: checking if this is an SVR4 system" >&5
+echo $ECHO_N "checking if this is an SVR4 system... $ECHO_C" >&6
+if test "${cf_cv_svr4+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 7123 "configure"
+#include "confdefs.h"
+
+#include <elf.h>
+#include <sys/termio.h>
+
+int
+main ()
+{
+
+static struct termio d_tio;
+       d_tio.c_cc[VINTR] = 0;
+       d_tio.c_cc[VQUIT] = 0;
+       d_tio.c_cc[VERASE] = 0;
+       d_tio.c_cc[VKILL] = 0;
+       d_tio.c_cc[VEOF] = 0;
+       d_tio.c_cc[VEOL] = 0;
+       d_tio.c_cc[VMIN] = 0;
+       d_tio.c_cc[VTIME] = 0;
+       d_tio.c_cc[VLNEXT] = 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7149: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:7152: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7155: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7158: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_svr4=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_svr4=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:7169: result: $cf_cv_svr4" >&5
+echo "${ECHO_T}$cf_cv_svr4" >&6
+
+fi
+
+test "$cf_cv_svr4" = yes && cat >>confdefs.h <<\EOF
+#define SVR4 1
+EOF
+
+echo "$as_me:7178: checking for X" >&5
+echo $ECHO_N "checking for X... $ECHO_C" >&6
+
+# Check whether --with-x or --without-x was given.
+if test "${with_x+set}" = set; then
+  withval="$with_x"
+
+fi;
+# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
+if test "x$with_x" = xno; then
+  # The user explicitly disabled X.
+  have_x=disabled
+else
+  if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
+    # Both variables are already set.
+    have_x=yes
+  else
+    if test "${ac_cv_have_x+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  # One or both of the vars are not set, and there is no cached value.
+ac_x_includes=no ac_x_libraries=no
+rm -fr conftest.dir
+if mkdir conftest.dir; then
+  cd conftest.dir
+  # Make sure to not put "make" in the Imakefile rules, since we grep it out.
+  cat >Imakefile <<'EOF'
+acfindx:
+       @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
+EOF
+  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
+    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+    eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
+    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
+    for ac_extension in a so sl dylib dll; do
+      if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
+         test -f $ac_im_libdir/libX11.$ac_extension; then
+        ac_im_usrlibdir=$ac_im_libdir; break
+      fi
+    done
+    # Screen out bogus values from the imake configuration.  They are
+    # bogus both because they are the default anyway, and because
+    # using them would break gcc on systems where it needs fixed includes.
+    case $ac_im_incroot in
+       /usr/include) ;;
+       *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
+    esac
+    case $ac_im_usrlibdir in
+       /usr/lib | /lib) ;;
+       *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
+    esac
+  fi
+  cd ..
+  rm -fr conftest.dir
+fi
+
+# Standard set of common directories for X headers.
+# Check X11 before X11Rn because it is often a symlink to the current release.
+ac_x_header_dirs='
+/usr/X11/include
+/usr/X11R6/include
+/usr/X11R5/include
+/usr/X11R4/include
+
+/usr/include/X11
+/usr/include/X11R6
+/usr/include/X11R5
+/usr/include/X11R4
+
+/usr/local/X11/include
+/usr/local/X11R6/include
+/usr/local/X11R5/include
+/usr/local/X11R4/include
+
+/usr/local/include/X11
+/usr/local/include/X11R6
+/usr/local/include/X11R5
+/usr/local/include/X11R4
+
+/usr/X386/include
+/usr/x386/include
+/usr/XFree86/include/X11
+
+/usr/include
+/usr/local/include
+/usr/unsupported/include
+/usr/athena/include
+/usr/local/x11r5/include
+/usr/lpp/Xamples/include
+
+/usr/openwin/include
+/usr/openwin/share/include'
+
+if test "$ac_x_includes" = no; then
+  # Guess where to find include files, by looking for Intrinsic.h.
+  # First, try using that file with no special directory specified.
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7275 "configure"
+#include "confdefs.h"
+#include <X11/Intrinsic.h>
+_ACEOF
+if { (eval echo "$as_me:7279: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:7285: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  # We can compile using X headers with no special include directory.
+ac_x_includes=
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  for ac_dir in $ac_x_header_dirs; do
+  if test -r "$ac_dir/X11/Intrinsic.h"; then
+    ac_x_includes=$ac_dir
+    break
+  fi
+done
+fi
+rm -f conftest.err conftest.$ac_ext
+fi # $ac_x_includes = no
+
+if test "$ac_x_libraries" = no; then
+  # Check for the libraries.
+  # See if we find them without any special options.
+  # Don't add to $LIBS permanently.
+  ac_save_LIBS=$LIBS
+  LIBS="-lXt $LIBS"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7318 "configure"
+#include "confdefs.h"
+#include <X11/Intrinsic.h>
+int
+main ()
+{
+XtMalloc (0)
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7330: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7333: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7336: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7339: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  LIBS=$ac_save_LIBS
+# We can link X programs with no special library path.
+ac_x_libraries=
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+LIBS=$ac_save_LIBS
+for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
+do
+  # Don't even attempt the hair of trying to link an X program!
+  for ac_extension in a so sl dylib dll; do
+    if test -r $ac_dir/libXt.$ac_extension; then
+      ac_x_libraries=$ac_dir
+      break 2
+    fi
+  done
+done
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi # $ac_x_libraries = no
+
+if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
+  # Didn't find X anywhere.  Cache the known absence of X.
+  ac_cv_have_x="have_x=no"
+else
+  # Record where we found X for the cache.
+  ac_cv_have_x="have_x=yes \
+               ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
+fi
+fi
+
+  fi
+  eval "$ac_cv_have_x"
+fi # $with_x != no
+
+if test "$have_x" != yes; then
+  echo "$as_me:7377: result: $have_x" >&5
+echo "${ECHO_T}$have_x" >&6
+  no_x=yes
+else
+  # If each of the values was on the command line, it overrides each guess.
+  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
+  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
+  # Update the cache value to reflect the command line values.
+  ac_cv_have_x="have_x=yes \
+               ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
+  echo "$as_me:7387: result: libraries $x_libraries, headers $x_includes" >&5
+echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
+fi
+
+if test "$no_x" = yes; then
+  # Not all programs may use this symbol, but it does not hurt to define it.
+
+cat >>confdefs.h <<\EOF
+#define X_DISPLAY_MISSING 1
+EOF
+
+  X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
+else
+  if test -n "$x_includes"; then
+    X_CFLAGS="$X_CFLAGS -I$x_includes"
+  fi
+
+  # It would also be nice to do this for all -L options, not just this one.
+  if test -n "$x_libraries"; then
+    X_LIBS="$X_LIBS -L$x_libraries"
+    # For Solaris; some versions of Sun CC require a space after -R and
+    # others require no space.  Words are not sufficient . . . .
+    case `(uname -sr) 2>/dev/null` in
+    "SunOS 5"*)
+      echo "$as_me:7411: checking whether -R must be followed by a space" >&5
+echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
+      ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
+      cat >conftest.$ac_ext <<_ACEOF
+#line 7415 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7427: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7430: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7433: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7436: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_nospace=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_R_nospace=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+      if test $ac_R_nospace = yes; then
+       echo "$as_me:7446: result: no" >&5
+echo "${ECHO_T}no" >&6
+       X_LIBS="$X_LIBS -R$x_libraries"
+      else
+       LIBS="$ac_xsave_LIBS -R $x_libraries"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 7452 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7464: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7467: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7470: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7473: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_R_space=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_R_space=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       if test $ac_R_space = yes; then
+         echo "$as_me:7483: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+         X_LIBS="$X_LIBS -R $x_libraries"
+       else
+         echo "$as_me:7487: result: neither works" >&5
+echo "${ECHO_T}neither works" >&6
+       fi
+      fi
+      LIBS=$ac_xsave_LIBS
+    esac
+  fi
+
+  # Check for system-dependent libraries X programs must link with.
+  # Do this before checking for the system-independent R6 libraries
+  # (-lICE), since we may need -lsocket or whatever for X linking.
+
+  if test "$ISC" = yes; then
+    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
+  else
+    # Martyn Johnson says this is needed for Ultrix, if the X
+    # libraries were built with DECnet support.  And Karl Berry says
+    # the Alpha needs dnet_stub (dnet does not exist).
+    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
+    cat >conftest.$ac_ext <<_ACEOF
+#line 7507 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+int
+main ()
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7526: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7529: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7532: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7535: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+echo "$as_me:7541: checking for dnet_ntoa in -ldnet" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7549 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main ()
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7568: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7571: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7574: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7577: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dnet_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dnet_dnet_ntoa=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:7588: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
+fi
+
+    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
+      echo "$as_me:7595: checking for dnet_ntoa in -ldnet_stub" >&5
+echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
+if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldnet_stub  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7603 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dnet_ntoa ();
+int
+main ()
+{
+dnet_ntoa ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7622: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7625: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7628: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7631: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dnet_stub_dnet_ntoa=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dnet_stub_dnet_ntoa=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:7642: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
+echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
+if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
+fi
+
+    fi
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_xsave_LIBS"
+
+    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
+    # to get the SysV transport functions.
+    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
+    # needs -lnsl.
+    # The nsl library prevents programs from opening the X display
+    # on Irix 5.2, according to T.E. Dickey.
+    # The functions gethostbyname, getservbyname, and inet_addr are
+    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
+    echo "$as_me:7661: checking for gethostbyname" >&5
+echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
+if test "${ac_cv_func_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7667 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char gethostbyname (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
+choke me
+#else
+f = gethostbyname;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7698: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7701: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7704: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7707: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:7717: result: $ac_cv_func_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6
+
+    if test $ac_cv_func_gethostbyname = no; then
+      echo "$as_me:7721: checking for gethostbyname in -lnsl" >&5
+echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
+if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnsl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7729 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+int
+main ()
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7748: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7751: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7754: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7757: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_nsl_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_nsl_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:7768: result: $ac_cv_lib_nsl_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
+if test $ac_cv_lib_nsl_gethostbyname = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
+fi
+
+      if test $ac_cv_lib_nsl_gethostbyname = no; then
+        echo "$as_me:7775: checking for gethostbyname in -lbsd" >&5
+echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
+if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbsd  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7783 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char gethostbyname ();
+int
+main ()
+{
+gethostbyname ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7802: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7805: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7808: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7811: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_bsd_gethostbyname=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_bsd_gethostbyname=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:7822: result: $ac_cv_lib_bsd_gethostbyname" >&5
+echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
+if test $ac_cv_lib_bsd_gethostbyname = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
+fi
+
+      fi
+    fi
+
+    # lieder@skyler.mavd.honeywell.com says without -lsocket,
+    # socket/setsockopt and other routines are undefined under SCO ODT
+    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
+    # on later versions), says Simon Leinen: it contains gethostby*
+    # variants that don't use the nameserver (or something).  -lsocket
+    # must be given before -lnsl if both are needed.  We assume that
+    # if connect needs -lnsl, so does gethostbyname.
+    echo "$as_me:7838: checking for connect" >&5
+echo $ECHO_N "checking for connect... $ECHO_C" >&6
+if test "${ac_cv_func_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7844 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char connect (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_connect) || defined (__stub___connect)
+choke me
+#else
+f = connect;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7875: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7878: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7881: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7884: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_connect=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:7894: result: $ac_cv_func_connect" >&5
+echo "${ECHO_T}$ac_cv_func_connect" >&6
+
+    if test $ac_cv_func_connect = no; then
+      echo "$as_me:7898: checking for connect in -lsocket" >&5
+echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
+if test "${ac_cv_lib_socket_connect+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 7906 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char connect ();
+int
+main ()
+{
+connect ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7925: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7928: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7931: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7934: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_socket_connect=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_socket_connect=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:7945: result: $ac_cv_lib_socket_connect" >&5
+echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
+if test $ac_cv_lib_socket_connect = yes; then
+  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
+fi
+
+    fi
+
+    # Guillermo Gomez says -lposix is necessary on A/UX.
+    echo "$as_me:7954: checking for remove" >&5
+echo $ECHO_N "checking for remove... $ECHO_C" >&6
+if test "${ac_cv_func_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7960 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char remove (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_remove) || defined (__stub___remove)
+choke me
+#else
+f = remove;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7991: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7994: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7997: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8000: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_remove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:8010: result: $ac_cv_func_remove" >&5
+echo "${ECHO_T}$ac_cv_func_remove" >&6
+
+    if test $ac_cv_func_remove = no; then
+      echo "$as_me:8014: checking for remove in -lposix" >&5
+echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
+if test "${ac_cv_lib_posix_remove+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lposix  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 8022 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char remove ();
+int
+main ()
+{
+remove ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:8041: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8044: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:8047: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8050: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_posix_remove=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_posix_remove=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:8061: result: $ac_cv_lib_posix_remove" >&5
+echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
+if test $ac_cv_lib_posix_remove = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
+fi
+
+    fi
+
+    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
+    echo "$as_me:8070: checking for shmat" >&5
+echo $ECHO_N "checking for shmat... $ECHO_C" >&6
+if test "${ac_cv_func_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 8076 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shmat (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shmat) || defined (__stub___shmat)
+choke me
+#else
+f = shmat;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:8107: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8110: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:8113: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8116: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_shmat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:8126: result: $ac_cv_func_shmat" >&5
+echo "${ECHO_T}$ac_cv_func_shmat" >&6
+
+    if test $ac_cv_func_shmat = no; then
+      echo "$as_me:8130: checking for shmat in -lipc" >&5
+echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
+if test "${ac_cv_lib_ipc_shmat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lipc  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 8138 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char shmat ();
+int
+main ()
+{
+shmat ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:8157: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8160: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:8163: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8166: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ipc_shmat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_ipc_shmat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:8177: result: $ac_cv_lib_ipc_shmat" >&5
+echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
+if test $ac_cv_lib_ipc_shmat = yes; then
+  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
+fi
+
+    fi
+  fi
+
+  # Check for libraries that X11R6 Xt/Xaw programs need.
+  ac_save_LDFLAGS=$LDFLAGS
+  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
+  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
+  # check for ICE first), but we must link in the order -lSM -lICE or
+  # we get undefined symbols.  So assume we have SM if we have ICE.
+  # These have to be linked with before -lX11, unlike the other
+  # libraries we check for below, so use a different variable.
+  # John Interrante, Karl Berry
+  echo "$as_me:8195: checking for IceConnectionNumber in -lICE" >&5
+echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
+if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 8203 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char IceConnectionNumber ();
+int
+main ()
+{
+IceConnectionNumber ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:8222: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8225: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:8228: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8231: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ICE_IceConnectionNumber=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_ICE_IceConnectionNumber=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:8242: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
+echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
+if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
+  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
+fi
+
+  LDFLAGS=$ac_save_LDFLAGS
+
+fi
+
+echo "$as_me:8252: checking if you want to use pkg-config" >&5
+echo $ECHO_N "checking if you want to use pkg-config... $ECHO_C" >&6
+
+# Check whether --with-pkg-config or --without-pkg-config was given.
+if test "${with_pkg_config+set}" = set; then
+  withval="$with_pkg_config"
+  cf_pkg_config=$withval
+else
+  cf_pkg_config=yes
+fi;
+echo "$as_me:8262: result: $cf_pkg_config" >&5
+echo "${ECHO_T}$cf_pkg_config" >&6
+
+case $cf_pkg_config in #(vi
+no) #(vi
+       PKG_CONFIG=none
+       ;;
+yes) #(vi
+       # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:8272: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
+   echo "$as_me:8289: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="none"
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+  echo "$as_me:8301: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+  echo "$as_me:8304: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+       ;;
+*)
+       PKG_CONFIG=$withval
+       ;;
+esac
+
+test -z "$PKG_CONFIG" && PKG_CONFIG=none
+if test "$PKG_CONFIG" != none ; then
+
+if test "x$prefix" != xNONE; then
+  cf_path_syntax="$prefix"
+else
+  cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".$PKG_CONFIG" in #(vi
+.\$\(*\)*|.\'*\'*) #(vi
+  ;;
+..|./*|.\\*) #(vi
+  ;;
+.[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
+  ;;
+.\${*prefix}*) #(vi
+  eval PKG_CONFIG="$PKG_CONFIG"
+  case ".$PKG_CONFIG" in #(vi
+  .NONE/*)
+    PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
+    ;;
+  esac
+  ;; #(vi
+.no|.NONE/*)
+  PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
+  ;;
+*)
+  { { echo "$as_me:8342: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
+echo "$as_me: error: expected a pathname, not \"$PKG_CONFIG\"" >&2;}
+   { (exit 1); exit 1; }; }
+  ;;
+esac
+
+fi
+
+cf_have_X_LIBS=no
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
+       test -n "$verbose" && echo "    found package xt" 1>&6
+
+echo "${as_me:-configure}:8355: testing found package xt ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
+       test -n "$verbose" && echo "    package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:8361: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package xt LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:8365: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+
+       case "x$LIBS" in #(vi
+       *-lX11*) #(vi
+               ;;
+       *)
+# we have an "xt" package, but it may omit Xt's dependency on X11
+echo "$as_me:8452: checking for usable X dependency" >&5
+echo $ECHO_N "checking for usable X dependency... $ECHO_C" >&6
+if test "${cf_cv_xt_x11_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 8459 "configure"
+#include "confdefs.h"
+
+#include <X11/Xlib.h>
+
+int
+main ()
+{
+
+       int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
+       int rc2 = XClearWindow((Display*) 0, (Window) 0);
+       int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
+       int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:8478: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8481: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:8484: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8487: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xt_x11_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xt_x11_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:8497: result: $cf_cv_xt_x11_compat" >&5
+echo "${ECHO_T}$cf_cv_xt_x11_compat" >&6
+               if test "$cf_cv_xt_x11_compat" = no
+               then
+                       test -n "$verbose" && echo "    work around broken X11 dependency" 1>&6
+
+echo "${as_me:-configure}:8503: testing work around broken X11 dependency ..." 1>&5
+
+                       # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
+       test -n "$verbose" && echo "    found package x11" 1>&6
+
+echo "${as_me:-configure}:8510: testing found package x11 ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
+       test -n "$verbose" && echo "    package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:8516: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package x11 LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:8520: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:8606: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s,-lXt ,-lXt -lX11 ," -e 's/  / /g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:8611: testing ...after  $LIBS ..." 1>&5
+
+fi
+
+               fi
+               ;;
+       esac
+
+echo "$as_me:8619: checking for usable X Toolkit package" >&5
+echo $ECHO_N "checking for usable X Toolkit package... $ECHO_C" >&6
+if test "${cf_cv_xt_ice_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 8626 "configure"
+#include "confdefs.h"
+
+#include <X11/Shell.h>
+
+int
+main ()
+{
+int num = IceConnectionNumber(0)
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:8641: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:8644: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:8647: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:8650: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xt_ice_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xt_ice_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:8660: result: $cf_cv_xt_ice_compat" >&5
+echo "${ECHO_T}$cf_cv_xt_ice_compat" >&6
+
+       if test "$cf_cv_xt_ice_compat" = no
+       then
+               # workaround for broken ".pc" files used for X Toolkit.
+               case "x$X_PRE_LIBS" in #(vi
+               *-lICE*)
+                       case "x$LIBS" in #(vi
+                       *-lICE*) #(vi
+                               ;;
+                       *)
+                               test -n "$verbose" && echo "    work around broken ICE dependency" 1>&6
+
+echo "${as_me:-configure}:8674: testing work around broken ICE dependency ..." 1>&5
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
+       test -n "$verbose" && echo "    found package ice" 1>&6
+
+echo "${as_me:-configure}:8679: testing found package ice ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
+       test -n "$verbose" && echo "    package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:8685: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package ice LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:8689: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
+       test -n "$verbose" && echo "    found package sm" 1>&6
+
+echo "${as_me:-configure}:8774: testing found package sm ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
+       test -n "$verbose" && echo "    package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:8780: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package sm LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:8784: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+       :
+fi
+
+else
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:8874: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s,-lXt ,-lXt $X_PRE_LIBS ," -e 's/  / /g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:8879: testing ...after  $LIBS ..." 1>&5
+
+fi
+
+                               ;;
+                       esac
+                       ;;
+               esac
+       fi
+
+       cf_have_X_LIBS=yes
+
+else
+
+       LDFLAGS="$X_LIBS $LDFLAGS"
+
+test -n "$verbose" && echo "   checking additions to CFLAGS" 1>&6
+
+echo "${as_me:-configure}:8897: testing checking additions to CFLAGS ..." 1>&5
+
+cf_check_cflags="$CFLAGS"
+cf_check_cppflags="$CPPFLAGS"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $X_CFLAGS
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+       test -n "$verbose" && echo "    add to \$CFLAGS $cf_new_cflags" 1>&6
+
+echo "${as_me:-configure}:8968: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$CPPFLAGS $cf_new_cppflags" 1>&6
+
+echo "${as_me:-configure}:8976: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
+
+echo "${as_me:-configure}:8984: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+if test "$cf_check_cflags" != "$CFLAGS" ; then
+cat >conftest.$ac_ext <<_ACEOF
+#line 8991 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int
+main ()
+{
+printf("Hello world");
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9003: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9006: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9009: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9012: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+test -n "$verbose" && echo "   test-compile failed.  Undoing change to \$CFLAGS" 1>&6
+
+echo "${as_me:-configure}:9020: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
+
+        if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
+                test -n "$verbose" && echo "   but keeping change to \$CPPFLAGS" 1>&6
+
+echo "${as_me:-configure}:9025: testing but keeping change to \$CPPFLAGS ..." 1>&5
+
+        fi
+        CFLAGS="$cf_check_flags"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+
+       echo "$as_me:9033: checking for XOpenDisplay" >&5
+echo $ECHO_N "checking for XOpenDisplay... $ECHO_C" >&6
+if test "${ac_cv_func_XOpenDisplay+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 9039 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char XOpenDisplay (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
+choke me
+#else
+f = XOpenDisplay;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9070: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9073: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9076: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9079: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_XOpenDisplay=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_XOpenDisplay=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:9089: result: $ac_cv_func_XOpenDisplay" >&5
+echo "${ECHO_T}$ac_cv_func_XOpenDisplay" >&6
+if test $ac_cv_func_XOpenDisplay = yes; then
+  :
+else
+
+       echo "$as_me:9095: checking for XOpenDisplay in -lX11" >&5
+echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
+if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 9103 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+int
+main ()
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9122: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9125: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9128: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9131: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_X11_XOpenDisplay=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_X11_XOpenDisplay=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:9142: result: $ac_cv_lib_X11_XOpenDisplay" >&5
+echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
+if test $ac_cv_lib_X11_XOpenDisplay = yes; then
+  LIBS="-lX11 $LIBS"
+fi
+
+fi
+
+       echo "$as_me:9150: checking for XtAppInitialize" >&5
+echo $ECHO_N "checking for XtAppInitialize... $ECHO_C" >&6
+if test "${ac_cv_func_XtAppInitialize+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 9156 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char XtAppInitialize (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XtAppInitialize ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
+choke me
+#else
+f = XtAppInitialize;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9187: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9190: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9193: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9196: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_XtAppInitialize=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_XtAppInitialize=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:9206: result: $ac_cv_func_XtAppInitialize" >&5
+echo "${ECHO_T}$ac_cv_func_XtAppInitialize" >&6
+if test $ac_cv_func_XtAppInitialize = yes; then
+  :
+else
+
+       echo "$as_me:9212: checking for XtAppInitialize in -lXt" >&5
+echo $ECHO_N "checking for XtAppInitialize in -lXt... $ECHO_C" >&6
+if test "${ac_cv_lib_Xt_XtAppInitialize+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 9220 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XtAppInitialize ();
+int
+main ()
+{
+XtAppInitialize ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9239: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9242: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9245: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9248: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_Xt_XtAppInitialize=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_Xt_XtAppInitialize=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:9259: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
+echo "${ECHO_T}$ac_cv_lib_Xt_XtAppInitialize" >&6
+if test $ac_cv_lib_Xt_XtAppInitialize = yes; then
+  cat >>confdefs.h <<\EOF
+#define HAVE_LIBXT 1
+EOF
+
+                cf_have_X_LIBS=Xt
+                LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
+fi
+
+fi
+
+fi
+
+if test $cf_have_X_LIBS = no ; then
+       { echo "$as_me:9275: WARNING: Unable to successfully link X Toolkit library (-lXt) with
+test program.  You will have to check and add the proper libraries by hand
+to makefile." >&5
+echo "$as_me: WARNING: Unable to successfully link X Toolkit library (-lXt) with
+test program.  You will have to check and add the proper libraries by hand
+to makefile." >&2;}
+fi
+
+for ac_header in \
+       X11/DECkeysym.h \
+       X11/Sunkeysym.h \
+       X11/XF86keysym.h \
+       X11/XKBlib.h \
+       X11/Xpoll.h \
+       X11/extensions/XKB.h \
+
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:9293: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 9299 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:9303: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:9309: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:9328: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+cf_x_athena=${cf_x_athena:-Xaw}
+
+echo "$as_me:9340: checking if you want to link with Xaw 3d library" >&5
+echo $ECHO_N "checking if you want to link with Xaw 3d library... $ECHO_C" >&6
+withval=
+
+# Check whether --with-Xaw3d or --without-Xaw3d was given.
+if test "${with_Xaw3d+set}" = set; then
+  withval="$with_Xaw3d"
+
+fi;
+if test "$withval" = yes ; then
+       cf_x_athena=Xaw3d
+       echo "$as_me:9351: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+       echo "$as_me:9354: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+echo "$as_me:9358: checking if you want to link with neXT Athena library" >&5
+echo $ECHO_N "checking if you want to link with neXT Athena library... $ECHO_C" >&6
+withval=
+
+# Check whether --with-neXtaw or --without-neXtaw was given.
+if test "${with_neXtaw+set}" = set; then
+  withval="$with_neXtaw"
+
+fi;
+if test "$withval" = yes ; then
+       cf_x_athena=neXtaw
+       echo "$as_me:9369: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+       echo "$as_me:9372: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+echo "$as_me:9376: checking if you want to link with Athena-Plus library" >&5
+echo $ECHO_N "checking if you want to link with Athena-Plus library... $ECHO_C" >&6
+withval=
+
+# Check whether --with-XawPlus or --without-XawPlus was given.
+if test "${with_XawPlus+set}" = set; then
+  withval="$with_XawPlus"
+
+fi;
+if test "$withval" = yes ; then
+       cf_x_athena=XawPlus
+       echo "$as_me:9387: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+       echo "$as_me:9390: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+cf_x_athena_lib=""
+
+if test "$PKG_CONFIG" != none ; then
+       cf_athena_list=
+       test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
+       for cf_athena_pkg in \
+               $cf_athena_list \
+               ${cf_x_athena} \
+               ${cf_x_athena}-devel \
+               lib${cf_x_athena} \
+               lib${cf_x_athena}-devel
+       do
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $cf_athena_pkg; then
+       test -n "$verbose" && echo "    found package $cf_athena_pkg" 1>&6
+
+echo "${as_me:-configure}:9410: testing found package $cf_athena_pkg ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags $cf_athena_pkg 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   $cf_athena_pkg 2>/dev/null`"
+       test -n "$verbose" && echo "    package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:9416: testing package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package $cf_athena_pkg LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:9420: testing package $cf_athena_pkg LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+
+                       cf_x_athena_lib="$cf_pkgconfig_libs"
+
+cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+                       cat >>confdefs.h <<EOF
+#define $cf_x_athena_LIBS 1
+EOF
+
+echo "$as_me:9510: checking for usable $cf_x_athena/Xmu package" >&5
+echo $ECHO_N "checking for usable $cf_x_athena/Xmu package... $ECHO_C" >&6
+if test "${cf_cv_xaw_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 9517 "configure"
+#include "confdefs.h"
+
+#include <X11/Xmu/CharSet.h>
+
+int
+main ()
+{
+
+int check = XmuCompareISOLatin1("big", "small")
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9533: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9536: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9539: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9542: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xaw_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xaw_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:9552: result: $cf_cv_xaw_compat" >&5
+echo "${ECHO_T}$cf_cv_xaw_compat" >&6
+
+                       if test "$cf_cv_xaw_compat" = no
+                       then
+                               # workaround for broken ".pc" files...
+                               case "$cf_x_athena_lib" in #(vi
+                               *-lXmu*) #(vi
+                                       ;;
+                               *)
+                                       test -n "$verbose" && echo "    work around broken package" 1>&6
+
+echo "${as_me:-configure}:9564: testing work around broken package ..." 1>&5
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xmu; then
+       test -n "$verbose" && echo "    found package xmu" 1>&6
+
+echo "${as_me:-configure}:9569: testing found package xmu ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xmu 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xmu 2>/dev/null`"
+       test -n "$verbose" && echo "    package xmu CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:9575: testing package xmu CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package xmu LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:9579: testing package xmu LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:9665: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s,-lXt ,-lXt -lXmu ," -e 's/  / /g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:9670: testing ...after  $LIBS ..." 1>&5
+
+fi
+
+                                       ;;
+                               esac
+                       fi
+
+                       break
+else
+       :
+fi
+
+       done
+fi
+
+if test -z "$cf_x_athena_lib" ; then
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists Xext; then
+       test -n "$verbose" && echo "    found package Xext" 1>&6
+
+echo "${as_me:-configure}:9691: testing found package Xext ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags Xext 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   Xext 2>/dev/null`"
+       test -n "$verbose" && echo "    package Xext CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:9697: testing package Xext CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package Xext LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:9701: testing package Xext LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+
+       echo "$as_me:9785: checking for XextCreateExtension in -lXext" >&5
+echo $ECHO_N "checking for XextCreateExtension in -lXext... $ECHO_C" >&6
+if test "${ac_cv_lib_Xext_XextCreateExtension+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXext  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 9793 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XextCreateExtension ();
+int
+main ()
+{
+XextCreateExtension ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9812: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9815: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9818: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9821: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_Xext_XextCreateExtension=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_Xext_XextCreateExtension=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:9832: result: $ac_cv_lib_Xext_XextCreateExtension" >&5
+echo "${ECHO_T}$ac_cv_lib_Xext_XextCreateExtension" >&6
+if test $ac_cv_lib_Xext_XextCreateExtension = yes; then
+  LIBS="-lXext $LIBS"
+fi
+
+fi
+
+cf_have_X_LIBS=no
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
+       test -n "$verbose" && echo "    found package xt" 1>&6
+
+echo "${as_me:-configure}:9845: testing found package xt ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
+       test -n "$verbose" && echo "    package xt CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:9851: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package xt LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:9855: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+
+       case "x$LIBS" in #(vi
+       *-lX11*) #(vi
+               ;;
+       *)
+# we have an "xt" package, but it may omit Xt's dependency on X11
+echo "$as_me:9942: checking for usable X dependency" >&5
+echo $ECHO_N "checking for usable X dependency... $ECHO_C" >&6
+if test "${cf_cv_xt_x11_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 9949 "configure"
+#include "confdefs.h"
+
+#include <X11/Xlib.h>
+
+int
+main ()
+{
+
+       int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
+       int rc2 = XClearWindow((Display*) 0, (Window) 0);
+       int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
+       int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:9968: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:9971: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:9974: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:9977: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xt_x11_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xt_x11_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:9987: result: $cf_cv_xt_x11_compat" >&5
+echo "${ECHO_T}$cf_cv_xt_x11_compat" >&6
+               if test "$cf_cv_xt_x11_compat" = no
+               then
+                       test -n "$verbose" && echo "    work around broken X11 dependency" 1>&6
+
+echo "${as_me:-configure}:9993: testing work around broken X11 dependency ..." 1>&5
+
+                       # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
+       test -n "$verbose" && echo "    found package x11" 1>&6
+
+echo "${as_me:-configure}:10000: testing found package x11 ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
+       test -n "$verbose" && echo "    package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:10006: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package x11 LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:10010: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:10096: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s,-lXt ,-lXt -lX11 ," -e 's/  / /g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:10101: testing ...after  $LIBS ..." 1>&5
+
+fi
+
+               fi
+               ;;
+       esac
+
+echo "$as_me:10109: checking for usable X Toolkit package" >&5
+echo $ECHO_N "checking for usable X Toolkit package... $ECHO_C" >&6
+if test "${cf_cv_xt_ice_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 10116 "configure"
+#include "confdefs.h"
+
+#include <X11/Shell.h>
+
+int
+main ()
+{
+int num = IceConnectionNumber(0)
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10131: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10134: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10137: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10140: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xt_ice_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xt_ice_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:10150: result: $cf_cv_xt_ice_compat" >&5
+echo "${ECHO_T}$cf_cv_xt_ice_compat" >&6
+
+       if test "$cf_cv_xt_ice_compat" = no
+       then
+               # workaround for broken ".pc" files used for X Toolkit.
+               case "x$X_PRE_LIBS" in #(vi
+               *-lICE*)
+                       case "x$LIBS" in #(vi
+                       *-lICE*) #(vi
+                               ;;
+                       *)
+                               test -n "$verbose" && echo "    work around broken ICE dependency" 1>&6
+
+echo "${as_me:-configure}:10164: testing work around broken ICE dependency ..." 1>&5
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
+       test -n "$verbose" && echo "    found package ice" 1>&6
+
+echo "${as_me:-configure}:10169: testing found package ice ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
+       test -n "$verbose" && echo "    package ice CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:10175: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package ice LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:10179: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
+       test -n "$verbose" && echo "    found package sm" 1>&6
+
+echo "${as_me:-configure}:10264: testing found package sm ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
+       test -n "$verbose" && echo "    package sm CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:10270: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package sm LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:10274: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+       :
+fi
+
+else
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:10364: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s,-lXt ,-lXt $X_PRE_LIBS ," -e 's/  / /g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:10369: testing ...after  $LIBS ..." 1>&5
+
+fi
+
+                               ;;
+                       esac
+                       ;;
+               esac
+       fi
+
+       cf_have_X_LIBS=yes
+
+else
+
+       LDFLAGS="$X_LIBS $LDFLAGS"
+
+test -n "$verbose" && echo "   checking additions to CFLAGS" 1>&6
+
+echo "${as_me:-configure}:10387: testing checking additions to CFLAGS ..." 1>&5
+
+cf_check_cflags="$CFLAGS"
+cf_check_cppflags="$CPPFLAGS"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $X_CFLAGS
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+       test -n "$verbose" && echo "    add to \$CFLAGS $cf_new_cflags" 1>&6
+
+echo "${as_me:-configure}:10458: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$CPPFLAGS $cf_new_cppflags" 1>&6
+
+echo "${as_me:-configure}:10466: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+       test -n "$verbose" && echo "    add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6
+
+echo "${as_me:-configure}:10474: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+if test "$cf_check_cflags" != "$CFLAGS" ; then
+cat >conftest.$ac_ext <<_ACEOF
+#line 10481 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int
+main ()
+{
+printf("Hello world");
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10493: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10496: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10499: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10502: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+test -n "$verbose" && echo "   test-compile failed.  Undoing change to \$CFLAGS" 1>&6
+
+echo "${as_me:-configure}:10510: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5
+
+        if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
+                test -n "$verbose" && echo "   but keeping change to \$CPPFLAGS" 1>&6
+
+echo "${as_me:-configure}:10515: testing but keeping change to \$CPPFLAGS ..." 1>&5
+
+        fi
+        CFLAGS="$cf_check_flags"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+
+       echo "$as_me:10523: checking for XOpenDisplay" >&5
+echo $ECHO_N "checking for XOpenDisplay... $ECHO_C" >&6
+if test "${ac_cv_func_XOpenDisplay+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10529 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char XOpenDisplay (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
+choke me
+#else
+f = XOpenDisplay;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10560: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10563: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10566: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10569: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_XOpenDisplay=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_XOpenDisplay=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:10579: result: $ac_cv_func_XOpenDisplay" >&5
+echo "${ECHO_T}$ac_cv_func_XOpenDisplay" >&6
+if test $ac_cv_func_XOpenDisplay = yes; then
+  :
+else
+
+       echo "$as_me:10585: checking for XOpenDisplay in -lX11" >&5
+echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
+if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10593 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XOpenDisplay ();
+int
+main ()
+{
+XOpenDisplay ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10612: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10615: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10618: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10621: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_X11_XOpenDisplay=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_X11_XOpenDisplay=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10632: result: $ac_cv_lib_X11_XOpenDisplay" >&5
+echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
+if test $ac_cv_lib_X11_XOpenDisplay = yes; then
+  LIBS="-lX11 $LIBS"
+fi
+
+fi
+
+       echo "$as_me:10640: checking for XtAppInitialize" >&5
+echo $ECHO_N "checking for XtAppInitialize... $ECHO_C" >&6
+if test "${ac_cv_func_XtAppInitialize+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10646 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char XtAppInitialize (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XtAppInitialize ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
+choke me
+#else
+f = XtAppInitialize;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10677: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10680: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10683: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10686: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_XtAppInitialize=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_XtAppInitialize=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:10696: result: $ac_cv_func_XtAppInitialize" >&5
+echo "${ECHO_T}$ac_cv_func_XtAppInitialize" >&6
+if test $ac_cv_func_XtAppInitialize = yes; then
+  :
+else
+
+       echo "$as_me:10702: checking for XtAppInitialize in -lXt" >&5
+echo $ECHO_N "checking for XtAppInitialize in -lXt... $ECHO_C" >&6
+if test "${ac_cv_lib_Xt_XtAppInitialize+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 10710 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char XtAppInitialize ();
+int
+main ()
+{
+XtAppInitialize ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10729: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10732: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10735: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10738: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_Xt_XtAppInitialize=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_Xt_XtAppInitialize=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:10749: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
+echo "${ECHO_T}$ac_cv_lib_Xt_XtAppInitialize" >&6
+if test $ac_cv_lib_Xt_XtAppInitialize = yes; then
+  cat >>confdefs.h <<\EOF
+#define HAVE_LIBXT 1
+EOF
+
+                cf_have_X_LIBS=Xt
+                LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
+fi
+
+fi
+
+fi
+
+if test $cf_have_X_LIBS = no ; then
+       { echo "$as_me:10765: WARNING: Unable to successfully link X Toolkit library (-lXt) with
+test program.  You will have to check and add the proper libraries by hand
+to makefile." >&5
+echo "$as_me: WARNING: Unable to successfully link X Toolkit library (-lXt) with
+test program.  You will have to check and add the proper libraries by hand
+to makefile." >&2;}
+fi
+
+cf_x_athena_root=$cf_x_athena
+cf_x_athena_inc=""
+
+for cf_path in default \
+       /usr/contrib/X11R6 \
+       /usr/contrib/X11R5 \
+       /usr/lib/X11R5 \
+       /usr/local
+do
+       if test -z "$cf_x_athena_inc" ; then
+               cf_save="$CPPFLAGS"
+               cf_test=X11/$cf_x_athena_root/SimpleMenu.h
+               if test $cf_path != default ; then
+                       CPPFLAGS="$cf_save -I$cf_path/include"
+                       echo "$as_me:10787: checking for $cf_test in $cf_path" >&5
+echo $ECHO_N "checking for $cf_test in $cf_path... $ECHO_C" >&6
+               else
+                       echo "$as_me:10790: checking for $cf_test" >&5
+echo $ECHO_N "checking for $cf_test... $ECHO_C" >&6
+               fi
+               cat >conftest.$ac_ext <<_ACEOF
+#line 10794 "configure"
+#include "confdefs.h"
+
+#include <X11/Intrinsic.h>
+#include <$cf_test>
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:10808: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:10811: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:10814: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10817: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_result=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_result=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+               echo "$as_me:10826: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+               if test "$cf_result" = yes ; then
+                       cf_x_athena_inc=$cf_path
+                       break
+               else
+                       CPPFLAGS="$cf_save"
+               fi
+       fi
+done
+
+if test -z "$cf_x_athena_inc" ; then
+       { echo "$as_me:10838: WARNING: Unable to successfully find Athena header files with test program" >&5
+echo "$as_me: WARNING: Unable to successfully find Athena header files with test program" >&2;}
+elif test "$cf_x_athena_inc" != default ; then
+       CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
+fi
+
+cf_x_athena_root=$cf_x_athena
+cf_x_athena_lib=""
+
+for cf_path in default \
+       /usr/contrib/X11R6 \
+       /usr/contrib/X11R5 \
+       /usr/lib/X11R5 \
+       /usr/local
+do
+       for cf_lib in \
+               "-l$cf_x_athena_root -lXmu" \
+               "-l$cf_x_athena_root -lXpm -lXmu" \
+               "-l${cf_x_athena_root}_s -lXmu_s"
+       do
+               if test -z "$cf_x_athena_lib" ; then
+                       cf_save="$LIBS"
+                       cf_test=XawSimpleMenuAddGlobalActions
+                       if test $cf_path != default ; then
+                               LIBS="-L$cf_path/lib $cf_lib $LIBS"
+                               echo "$as_me:10863: checking for $cf_lib in $cf_path" >&5
+echo $ECHO_N "checking for $cf_lib in $cf_path... $ECHO_C" >&6
+                       else
+                               LIBS="$cf_lib $LIBS"
+                               echo "$as_me:10867: checking for $cf_test in $cf_lib" >&5
+echo $ECHO_N "checking for $cf_test in $cf_lib... $ECHO_C" >&6
+                       fi
+                       cat >conftest.$ac_ext <<_ACEOF
+#line 10871 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+$cf_test()
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:10883: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:10886: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:10889: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:10892: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_result=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_result=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+                       echo "$as_me:10901: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+                       if test "$cf_result" = yes ; then
+                               cf_x_athena_lib="$cf_lib"
+                               break
+                       fi
+                       LIBS="$cf_save"
+               fi
+       done
+done
+
+if test -z "$cf_x_athena_lib" ; then
+       { { echo "$as_me:10913: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&5
+echo "$as_me: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+cat >>confdefs.h <<EOF
+#define $cf_x_athena_LIBS 1
+EOF
+
+fi
+
+for ac_header in X11/Xpoll.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:10929: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 10935 "configure"
+#include "confdefs.h"
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:10939: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:10945: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  eval "$as_ac_Header=yes"
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:10964: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:10974: checking for declaration of fd_set" >&5
+echo $ECHO_N "checking for declaration of fd_set... $ECHO_C" >&6
+if test "${cf_cv_type_fd_set+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+echo "${as_me:-configure}:10980: testing sys/types alone ..." 1>&5
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 10983 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+int
+main ()
+{
+fd_set x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:10996: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:10999: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:11002: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11005: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_type_fd_set=sys/types.h
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+echo "${as_me:-configure}:11012: testing X11/Xpoll.h ..." 1>&5
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 11015 "configure"
+#include "confdefs.h"
+
+#ifdef HAVE_X11_XPOLL_H
+#include <X11/Xpoll.h>
+#endif
+int
+main ()
+{
+fd_set x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:11030: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:11033: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:11036: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11039: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_type_fd_set=X11/Xpoll.h
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+echo "${as_me:-configure}:11046: testing sys/select.h ..." 1>&5
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 11049 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <sys/select.h>
+int
+main ()
+{
+fd_set x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:11063: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:11066: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:11069: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11072: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_type_fd_set=sys/select.h
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_type_fd_set=unknown
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:11086: result: $cf_cv_type_fd_set" >&5
+echo "${ECHO_T}$cf_cv_type_fd_set" >&6
+if test $cf_cv_type_fd_set = sys/select.h ; then
+       cat >>confdefs.h <<\EOF
+#define USE_SYS_SELECT_H 1
+EOF
+
+fi
+
+echo "$as_me:11095: checking for declaration of fd_mask" >&5
+echo $ECHO_N "checking for declaration of fd_mask... $ECHO_C" >&6
+if test "${cf_cv_type_fd_mask+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
+        cat >conftest.$ac_ext <<_ACEOF
+#line 11103 "configure"
+#include "confdefs.h"
+
+#include <X11/Xpoll.h>
+int
+main ()
+{
+fd_mask x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:11116: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:11119: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:11122: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11125: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+echo "${as_me:-configure}:11132: testing if we must define CSRG_BASED ..." 1>&5
+
+# Xosdefs.h on Mac OS X may not define this (but it should).
+            cat >conftest.$ac_ext <<_ACEOF
+#line 11136 "configure"
+#include "confdefs.h"
+
+#define CSRG_BASED
+#include <X11/Xpoll.h>
+int
+main ()
+{
+fd_mask x
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:11150: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:11153: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:11156: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11159: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_type_fd_mask=CSRG_BASED
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+    else
+        cf_cv_type_fd_mask=$cf_cv_type_fd_set
+    fi
+
+fi
+echo "$as_me:11174: result: $cf_cv_type_fd_mask" >&5
+echo "${ECHO_T}$cf_cv_type_fd_mask" >&6
+if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
+    cat >>confdefs.h <<\EOF
+#define CSRG_BASED 1
+EOF
+
+fi
+
+echo "$as_me:11183: checking for IRIX 6.5 baud-rate redefinitions" >&5
+echo $ECHO_N "checking for IRIX 6.5 baud-rate redefinitions... $ECHO_C" >&6
+if test "${cf_cv_termio_c_ispeed+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 11190 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <sys/termio.h>
+int
+main ()
+{
+
+struct termio foo;
+foo.c_ispeed = B38400;
+foo.c_ospeed = B9600;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:11208: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:11211: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:11214: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11217: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_termio_c_ispeed=yes
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_termio_c_ispeed=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:11229: result: $cf_cv_termio_c_ispeed" >&5
+echo "${ECHO_T}$cf_cv_termio_c_ispeed" >&6
+test "$cf_cv_termio_c_ispeed" = yes && cat >>confdefs.h <<\EOF
+#define HAVE_TERMIO_C_ISPEED 1
+EOF
+
+LIBS="$LIBS $X_EXTRA_LIBS"
+
+# Check for openpty() in -lutil if the UNIX98-style pty functions are not
+# available. E.g. for GNU libc 2.0.
+case $host_os in #(vi
+freebsd*|netbsd*|dragonfly*) # 2004/8/15 - revisit this if/when grantpt is known to work.
+
+echo "$as_me:11242: checking for openpty in -lutil" >&5
+echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6
+if test "${ac_cv_lib_util_openpty+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lutil  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 11250 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char openpty ();
+int
+main ()
+{
+openpty ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11269: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11272: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11275: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11278: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_util_openpty=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_util_openpty=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:11289: result: $ac_cv_lib_util_openpty" >&5
+echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6
+if test $ac_cv_lib_util_openpty = yes; then
+  cat >>confdefs.h <<EOF
+#define HAVE_LIBUTIL 1
+EOF
+
+  LIBS="-lutil $LIBS"
+
+fi
+
+       ;;
+*)
+
+for ac_func in grantpt
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:11306: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 11312 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11343: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11346: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11349: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11352: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:11362: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+else
+
+echo "$as_me:11371: checking for openpty in -lutil" >&5
+echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6
+if test "${ac_cv_lib_util_openpty+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lutil  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 11379 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char openpty ();
+int
+main ()
+{
+openpty ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11398: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11401: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11404: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11407: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_util_openpty=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_util_openpty=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:11418: result: $ac_cv_lib_util_openpty" >&5
+echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6
+if test $ac_cv_lib_util_openpty = yes; then
+  cat >>confdefs.h <<EOF
+#define HAVE_LIBUTIL 1
+EOF
+
+  LIBS="-lutil $LIBS"
+
+fi
+
+fi
+done
+
+       ;;
+esac
+
+for ac_func in XkbQueryExtension
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:11438: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 11444 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11475: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11478: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11481: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11484: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:11494: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+echo "$as_me:11504: checking for XKB Bell extension" >&5
+echo $ECHO_N "checking for XKB Bell extension... $ECHO_C" >&6
+if test "${cf_cv_xkb_bell_ext+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 11511 "configure"
+#include "confdefs.h"
+
+#include <X11/Intrinsic.h>
+#include <X11/XKBlib.h>                /* has the prototype */
+#include <X11/extensions/XKBbells.h>   /* has the XkbBI_xxx definitions */
+
+int
+main ()
+{
+
+       int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
+       Atom y;
+       XkbBell((Display *)0, (Widget)0, 0, y);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11531: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11534: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11537: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11540: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xkb_bell_ext=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xkb_bell_ext=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:11551: result: $cf_cv_xkb_bell_ext" >&5
+echo "${ECHO_T}$cf_cv_xkb_bell_ext" >&6
+test "$cf_cv_xkb_bell_ext" = yes && cat >>confdefs.h <<\EOF
+#define HAVE_XKB_BELL_EXT 1
+EOF
+
+for ac_func in Xutf8LookupString
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:11560: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 11566 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:11597: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:11600: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:11603: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11606: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:11616: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+else
+
+       EXTRAHDRS="$EXTRAHDRS xutf8.h"
+       EXTRASRCS="$EXTRASRCS xutf8.c"
+       EXTRAOBJS="$EXTRAOBJS xutf8.o"
+
+fi
+done
+
+echo "$as_me:11632: checking if you want narrow prototypes for X libraries" >&5
+echo $ECHO_N "checking if you want narrow prototypes for X libraries... $ECHO_C" >&6
+
+case `$ac_config_guess` in #(vi
+*cygwin*|*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*) #(vi
+       cf_default_narrowproto=yes
+       ;;
+*)
+       cf_default_narrowproto=no
+       ;;
+esac
+
+# Check whether --enable-narrowproto or --disable-narrowproto was given.
+if test "${enable_narrowproto+set}" = set; then
+  enableval="$enable_narrowproto"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "$cf_default_narrowproto" ; then
+    enable_narrowproto=$enableval
+  else
+    enable_narrowproto=$cf_default_narrowproto
+  fi
+else
+  enableval=$cf_default_narrowproto
+  enable_narrowproto=$cf_default_narrowproto
+
+fi;
+echo "$as_me:11658: result: $enable_narrowproto" >&5
+echo "${ECHO_T}$enable_narrowproto" >&6
+
+echo "$as_me:11661: checking if we should use imake to help" >&5
+echo $ECHO_N "checking if we should use imake to help... $ECHO_C" >&6
+
+# Check whether --enable-imake or --disable-imake was given.
+if test "${enable_imake+set}" = set; then
+  enableval="$enable_imake"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_imake=no
+  else
+    enable_imake=yes
+  fi
+else
+  enableval=yes
+  enable_imake=yes
+
+fi;
+echo "$as_me:11678: result: $enable_imake" >&5
+echo "${ECHO_T}$enable_imake" >&6
+
+if test "$enable_imake" = yes ; then
+
+for ac_prog in xmkmf imake
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:11687: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_IMAKE+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $IMAKE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_IMAKE="$IMAKE" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_IMAKE="$ac_dir/$ac_word"
+   echo "$as_me:11704: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  ;;
+esac
+fi
+IMAKE=$ac_cv_path_IMAKE
+
+if test -n "$IMAKE"; then
+  echo "$as_me:11715: result: $IMAKE" >&5
+echo "${ECHO_T}$IMAKE" >&6
+else
+  echo "$as_me:11718: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$IMAKE" && break
+done
+
+if test -n "$IMAKE" ; then
+
+case $IMAKE in # (vi
+*/imake)
+       cf_imake_opts="-DUseInstalled=YES" # (vi
+       ;;
+*/util/xmkmf)
+       # A single parameter tells xmkmf where the config-files are:
+       cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`" # (vi
+       ;;
+*)
+       cf_imake_opts=
+       ;;
+esac
+
+# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
+# config directory.
+if mkdir conftestdir; then
+       CDPATH=; export CDPATH
+       cf_makefile=`cd $srcdir;pwd`/Imakefile
+       cd conftestdir
+
+       cat >fix_cflags.sed <<'CF_EOF'
+s/\\//g
+s/[    ][      ]*/ /g
+s/"//g
+:pack
+s/\(=[^ ][^ ]*\) \([^-]\)/\1   \2/g
+t pack
+s/\(-D[a-zA-Z0-9_][a-zA-Z0-9_]*\)=\([^\'0-9 ][^ ]*\)/\1='\\"\2\\"'/g
+s/^IMAKE[ ]/IMAKE_CFLAGS="/
+s/     / /g
+s/$/"/
+CF_EOF
+
+       cat >fix_lflags.sed <<'CF_EOF'
+s/^IMAKE[      ]*/IMAKE_LOADFLAGS="/
+s/$/"/
+CF_EOF
+
+       echo >./Imakefile
+       test -f $cf_makefile && cat $cf_makefile >>./Imakefile
+
+       cat >> ./Imakefile <<'CF_EOF'
+findstddefs:
+       @echo IMAKE ${ALLDEFINES} $(MAIN_DEFINES) $(VENDORMANDEFS)       | sed -f fix_cflags.sed
+       @echo IMAKE ${EXTRA_LOAD_FLAGS} | sed -f fix_lflags.sed
+CF_EOF
+
+       if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&5 && test -f Makefile)
+       then
+               test -n "$verbose" && echo "    Using $IMAKE $cf_imake_opts" 1>&6
+
+echo "${as_me:-configure}:11778: testing Using $IMAKE $cf_imake_opts ..." 1>&5
+
+       else
+               # sometimes imake doesn't have the config path compiled in.  Find it.
+               cf_config=
+               for cf_libpath in $X_LIBS $LIBS ; do
+                       case $cf_libpath in # (vi
+                       -L*)
+                               cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
+                               cf_libpath=$cf_libpath/X11/config
+                               if test -d $cf_libpath ; then
+                                       cf_config=$cf_libpath
+                                       break
+                               fi
+                               ;;
+                       esac
+               done
+               if test -z "$cf_config" ; then
+                       { echo "$as_me:11796: WARNING: Could not find imake config-directory" >&5
+echo "$as_me: WARNING: Could not find imake config-directory" >&2;}
+               else
+                       cf_imake_opts="$cf_imake_opts -I$cf_config"
+                       if ( $IMAKE -v $cf_imake_opts 2>&5)
+                       then
+                               test -n "$verbose" && echo "    Using $IMAKE $cf_config" 1>&6
+
+echo "${as_me:-configure}:11804: testing Using $IMAKE $cf_config ..." 1>&5
+
+                       else
+                               { echo "$as_me:11807: WARNING: Cannot run $IMAKE" >&5
+echo "$as_me: WARNING: Cannot run $IMAKE" >&2;}
+                       fi
+               fi
+       fi
+
+       # GNU make sometimes prints "make[1]: Entering...", which
+       # would confuse us.
+       eval `make findstddefs 2>/dev/null | grep -v make`
+
+       cd ..
+       rm -rf conftestdir
+
+       # We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
+       # declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
+       # modified it to support site.cf, adding a kludge for the /usr/include
+       # directory.  Try to filter that out, otherwise gcc won't find its
+       # headers.
+       if test -n "$GCC" ; then
+           if test -n "$IMAKE_CFLAGS" ; then
+               cf_nostdinc=""
+               cf_std_incl=""
+               cf_cpp_opts=""
+               for cf_opt in $IMAKE_CFLAGS
+               do
+                   case "$cf_opt" in
+                   -nostdinc) #(vi
+                       cf_nostdinc="$cf_opt"
+                       ;;
+                   -I/usr/include) #(vi
+                       cf_std_incl="$cf_opt"
+                       ;;
+                   *) #(vi
+                       cf_cpp_opts="$cf_cpp_opts $cf_opt"
+                       ;;
+                   esac
+               done
+               if test -z "$cf_nostdinc" ; then
+                   IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
+               elif test -z "$cf_std_incl" ; then
+                   IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
+               else
+                   test -n "$verbose" && echo "        suppressed \"$cf_nostdinc\" and \"$cf_std_incl\"" 1>&6
+
+echo "${as_me:-configure}:11851: testing suppressed \"$cf_nostdinc\" and \"$cf_std_incl\" ..." 1>&5
+
+                   IMAKE_CFLAGS="$cf_cpp_opts"
+               fi
+           fi
+       fi
+fi
+
+# Some imake configurations define PROJECTROOT with an empty value.  Remove
+# the empty definition.
+case $IMAKE_CFLAGS in
+*-DPROJECTROOT=/*)
+       ;;
+*)
+       IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[   ], ,"`
+       ;;
+esac
+
+fi
+
+test -n "$verbose" && echo "   IMAKE_CFLAGS $IMAKE_CFLAGS" 1>&6
+
+echo "${as_me:-configure}:11873: testing IMAKE_CFLAGS $IMAKE_CFLAGS ..." 1>&5
+
+test -n "$verbose" && echo "   IMAKE_LOADFLAGS $IMAKE_LOADFLAGS" 1>&6
+
+echo "${as_me:-configure}:11877: testing IMAKE_LOADFLAGS $IMAKE_LOADFLAGS ..." 1>&5
+
+fi
+
+if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $IMAKE_CFLAGS
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+else
+       IMAKE_CFLAGS=
+       IMAKE_LOADFLAGS=
+       test -n "$verbose" && echo "    make fallback definitions" 1>&6
+
+echo "${as_me:-configure}:11966: testing make fallback definitions ..." 1>&5
+
+       # We prefer config.guess' values when we can get them, to avoid
+       # inconsistent results with uname (AIX for instance).  However,
+       # config.guess is not always consistent either.
+       case $host_os in
+       *[0-9].[0-9]*)
+               UNAME_RELEASE="$host_os"
+               ;;
+       *)
+               UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+               ;;
+       esac
+
+       case .$UNAME_RELEASE in
+       *[0-9].[0-9]*)
+               OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[^0-9]*//' -e 's/\..*//'`
+               OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[^0-9]*//' -e 's/^[^.]*\.//' -e 's/\..*//' -e 's/[^0-9].*//' `
+               test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
+               test -z "$OSMINORVERSION" && OSMINORVERSION=0
+               IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
+               ;;
+       esac
+
+       # FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
+       # fallback/fragments for NeedPrototypes, etc.
+       IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
+
+       # If this is not set properly, Xaw's scrollbars will not work
+       if test "$enable_narrowproto" = yes ; then
+               IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
+       fi
+
+       # Other special definitions:
+       case $host_os in
+       aix*)
+               # imake on AIX 5.1 defines AIXV3.  really.
+               IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
+               ;;
+       irix[56].*) #(vi
+               # these are needed to make SIGWINCH work in xterm
+               IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
+               ;;
+       esac
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $IMAKE_CFLAGS
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+fi
+
+echo "$as_me:12091: checking for default terminal-id" >&5
+echo $ECHO_N "checking for default terminal-id... $ECHO_C" >&6
+
+# Check whether --with-terminal-id or --without-terminal-id was given.
+if test "${with_terminal_id+set}" = set; then
+  withval="$with_terminal_id"
+  default_termid=$withval
+else
+  default_termid=vt100
+fi;
+echo "$as_me:12101: result: $default_termid" >&5
+echo "${ECHO_T}$default_termid" >&6
+case $default_termid in
+vt*)   default_termid=`echo $default_termid | sed -e 's/^..//'`
+       ;;
+esac
+cat >>confdefs.h <<EOF
+#define DFT_DECID "$default_termid"
+EOF
+
+echo "$as_me:12111: checking for default terminal-type" >&5
+echo $ECHO_N "checking for default terminal-type... $ECHO_C" >&6
+
+# Check whether --with-terminal-type or --without-terminal-type was given.
+if test "${with_terminal_type+set}" = set; then
+  withval="$with_terminal_type"
+  default_TERM=$withval
+else
+  default_TERM=xterm
+fi;
+echo "$as_me:12121: result: $default_TERM" >&5
+echo "${ECHO_T}$default_TERM" >&6
+cat >>confdefs.h <<EOF
+#define DFT_TERMTYPE "$default_TERM"
+EOF
+
+# Extract the first word of "tic", so it can be a program name with args.
+set dummy tic; ac_word=$2
+echo "$as_me:12129: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_cf_tic_prog+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$cf_tic_prog"; then
+  ac_cv_prog_cf_tic_prog="$cf_tic_prog" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_cf_tic_prog="yes"
+echo "$as_me:12144: found $ac_dir/$ac_word" >&5
+break
+done
+
+  test -z "$ac_cv_prog_cf_tic_prog" && ac_cv_prog_cf_tic_prog="no"
+fi
+fi
+cf_tic_prog=$ac_cv_prog_cf_tic_prog
+if test -n "$cf_tic_prog"; then
+  echo "$as_me:12153: result: $cf_tic_prog" >&5
+echo "${ECHO_T}$cf_tic_prog" >&6
+else
+  echo "$as_me:12156: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "$cf_tic_prog" = yes ; then
+       echo "$as_me:12161: checking for private terminfo-directory" >&5
+echo $ECHO_N "checking for private terminfo-directory... $ECHO_C" >&6
+
+# Check whether --with-own-terminfo or --without-own-terminfo was given.
+if test "${with_own_terminfo+set}" = set; then
+  withval="$with_own_terminfo"
+  TERMINFO_DIR=$withval
+else
+  TERMINFO_DIR=${TERMINFO-none}
+fi;
+       echo "$as_me:12171: result: $TERMINFO_DIR" >&5
+echo "${ECHO_T}$TERMINFO_DIR" >&6
+       if test "$TERMINFO_DIR" = yes ; then
+               { echo "$as_me:12174: WARNING: no value given" >&5
+echo "$as_me: WARNING: no value given" >&2;}
+       elif test "$TERMINFO_DIR" != none ; then
+               if test -d $TERMINFO_DIR ; then
+                       cat >>confdefs.h <<EOF
+#define OWN_TERMINFO_DIR "$TERMINFO_DIR"
+EOF
+
+               else
+                       { echo "$as_me:12183: WARNING: not a directory" >&5
+echo "$as_me: WARNING: not a directory" >&2;}
+               fi
+       elif test "$prefix" != NONE ; then
+               TERMINFO_DIR='${prefix}/lib/terminfo'
+       elif test -d /usr/lib/terminfo ; then
+               TERMINFO_DIR=/usr/lib/terminfo
+       else
+               TERMINFO_DIR=
+       fi
+       SET_TERMINFO=
+       if test -n "$TERMINFO_DIR" ; then
+               TERMINFO_DIR='$(DESTDIR)'$TERMINFO_DIR
+               SET_TERMINFO='TERMINFO=$(TERMINFO_DIR)'
+       fi
+       no_ticprog=
+else
+       no_ticprog="#"
+       TERMINFO_DIR=
+       SET_TERMINFO=
+fi
+
+###############################################################################
+
+echo "$as_me:12207: checking if you want active-icons" >&5
+echo $ECHO_N "checking if you want active-icons... $ECHO_C" >&6
+
+# Check whether --enable-active-icon or --disable-active-icon was given.
+if test "${enable_active_icon+set}" = set; then
+  enableval="$enable_active_icon"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_active_icon=no
+  else
+    enable_active_icon=yes
+  fi
+else
+  enableval=yes
+  enable_active_icon=yes
+
+fi;
+echo "$as_me:12224: result: $enable_active_icon" >&5
+echo "${ECHO_T}$enable_active_icon" >&6
+if test "$enable_active_icon" = no ; then
+       cat >>confdefs.h <<\EOF
+#define NO_ACTIVE_ICON 1
+EOF
+
+fi
+
+echo "$as_me:12233: checking if you want ANSI color" >&5
+echo $ECHO_N "checking if you want ANSI color... $ECHO_C" >&6
+
+# Check whether --enable-ansi-color or --disable-ansi-color was given.
+if test "${enable_ansi_color+set}" = set; then
+  enableval="$enable_ansi_color"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_ansi_color=no
+  else
+    enable_ansi_color=yes
+  fi
+else
+  enableval=yes
+  enable_ansi_color=yes
+
+fi;
+echo "$as_me:12250: result: $enable_ansi_color" >&5
+echo "${ECHO_T}$enable_ansi_color" >&6
+test "$enable_ansi_color" = no && cat >>confdefs.h <<\EOF
+#define OPT_ISO_COLORS 0
+EOF
+
+if test "$enable_ansi_color" = yes ; then
+
+       echo "$as_me:12258: checking if you want 16 colors like aixterm" >&5
+echo $ECHO_N "checking if you want 16 colors like aixterm... $ECHO_C" >&6
+
+# Check whether --enable-16-color or --disable-16-color was given.
+if test "${enable_16_color+set}" = set; then
+  enableval="$enable_16_color"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_16_color=no
+  else
+    enable_16_color=yes
+  fi
+else
+  enableval=yes
+  enable_16_color=yes
+
+fi;
+       echo "$as_me:12275: result: $enable_16_color" >&5
+echo "${ECHO_T}$enable_16_color" >&6
+       test "$enable_16_color" = no && cat >>confdefs.h <<\EOF
+#define OPT_AIX_COLORS 0
+EOF
+
+       echo "$as_me:12281: checking if you want 256 colors" >&5
+echo $ECHO_N "checking if you want 256 colors... $ECHO_C" >&6
+
+# Check whether --enable-256-color or --disable-256-color was given.
+if test "${enable_256_color+set}" = set; then
+  enableval="$enable_256_color"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_256_color=yes
+  else
+    enable_256_color=no
+  fi
+else
+  enableval=no
+  enable_256_color=no
+
+fi;
+       echo "$as_me:12298: result: $enable_256_color" >&5
+echo "${ECHO_T}$enable_256_color" >&6
+       if test "$enable_256_color" = yes ; then
+               CHARPROC_DEPS="$CHARPROC_DEPS 256colres.h"
+               EXTRAHDRS="$EXTRAHDRS 256colres.h"
+               cat >>confdefs.h <<\EOF
+#define OPT_256_COLORS 1
+EOF
+
+       else
+       echo "$as_me:12308: checking if you want 88 colors" >&5
+echo $ECHO_N "checking if you want 88 colors... $ECHO_C" >&6
+
+# Check whether --enable-88-color or --disable-88-color was given.
+if test "${enable_88_color+set}" = set; then
+  enableval="$enable_88_color"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_88_color=yes
+  else
+    enable_88_color=no
+  fi
+else
+  enableval=no
+  enable_88_color=no
+
+fi;
+       echo "$as_me:12325: result: $enable_88_color" >&5
+echo "${ECHO_T}$enable_88_color" >&6
+       if test "$enable_88_color" = yes ; then
+               CHARPROC_DEPS="$CHARPROC_DEPS 88colres.h"
+               EXTRAHDRS="$EXTRAHDRS 88colres.h"
+               cat >>confdefs.h <<\EOF
+#define OPT_88_COLORS 1
+EOF
+
+       fi
+       fi
+
+fi
+
+echo "$as_me:12339: checking if you want blinking cursor" >&5
+echo $ECHO_N "checking if you want blinking cursor... $ECHO_C" >&6
+
+# Check whether --enable-blink-cursor or --disable-blink-cursor was given.
+if test "${enable_blink_cursor+set}" = set; then
+  enableval="$enable_blink_cursor"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_blink_curs=no
+  else
+    enable_blink_curs=yes
+  fi
+else
+  enableval=yes
+  enable_blink_curs=yes
+
+fi;
+echo "$as_me:12356: result: $enable_blink_curs" >&5
+echo "${ECHO_T}$enable_blink_curs" >&6
+test "$enable_blink_curs" = no && cat >>confdefs.h <<\EOF
+#define OPT_BLINK_CURS 0
+EOF
+
+echo "$as_me:12362: checking if you want to ignore Linux's broken palette-strings" >&5
+echo $ECHO_N "checking if you want to ignore Linux's broken palette-strings... $ECHO_C" >&6
+
+case $host_os in #(vi
+linux*)
+       assume_broken_osc=yes ;; #(vi
+*)
+       assume_broken_osc=no ;;
+esac
+
+# Check whether --enable-broken-osc or --disable-broken-osc was given.
+if test "${enable_broken_osc+set}" = set; then
+  enableval="$enable_broken_osc"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "$assume_broken_osc" ; then
+    enable_broken_osc=$enableval
+  else
+    enable_broken_osc=$enableval
+  fi
+else
+  enableval=$assume_broken_osc
+  enable_broken_osc=$enableval
+
+fi;
+echo "$as_me:12386: result: $enable_broken_osc" >&5
+echo "${ECHO_T}$enable_broken_osc" >&6
+if test "$enable_broken_osc" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_BROKEN_OSC 1
+EOF
+
+else
+       cat >>confdefs.h <<\EOF
+#define OPT_BROKEN_OSC 0
+EOF
+
+fi
+
+echo "$as_me:12400: checking if you want to allow broken string-terminators" >&5
+echo $ECHO_N "checking if you want to allow broken string-terminators... $ECHO_C" >&6
+
+# Check whether --enable-broken-st or --disable-broken-st was given.
+if test "${enable_broken_st+set}" = set; then
+  enableval="$enable_broken_st"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_broken_st=no
+  else
+    enable_broken_st=yes
+  fi
+else
+  enableval=no
+  enable_broken_st=yes
+
+fi;
+echo "$as_me:12417: result: $enable_broken_st" >&5
+echo "${ECHO_T}$enable_broken_st" >&6
+test "$enable_broken_st" = no && cat >>confdefs.h <<\EOF
+#define OPT_BROKEN_ST 0
+EOF
+
+echo "$as_me:12423: checking if you want printable 128-159" >&5
+echo $ECHO_N "checking if you want printable 128-159... $ECHO_C" >&6
+
+# Check whether --enable-c1-print or --disable-c1-print was given.
+if test "${enable_c1_print+set}" = set; then
+  enableval="$enable_c1_print"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_c1_print=no
+  else
+    enable_c1_print=yes
+  fi
+else
+  enableval=yes
+  enable_c1_print=yes
+
+fi;
+echo "$as_me:12440: result: $enable_c1_print" >&5
+echo "${ECHO_T}$enable_c1_print" >&6
+test "$enable_c1_print" = no && cat >>confdefs.h <<\EOF
+#define OPT_C1_PRINT 0
+EOF
+
+if test "$enable_ansi_color" = yes ; then
+
+       echo "$as_me:12448: checking if you want bold colors mapped like IBM PC" >&5
+echo $ECHO_N "checking if you want bold colors mapped like IBM PC... $ECHO_C" >&6
+
+# Check whether --enable-bold-color or --disable-bold-color was given.
+if test "${enable_bold_color+set}" = set; then
+  enableval="$enable_bold_color"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_pc_color=no
+  else
+    enable_pc_color=yes
+  fi
+else
+  enableval=yes
+  enable_pc_color=yes
+
+fi;
+       echo "$as_me:12465: result: $enable_pc_color" >&5
+echo "${ECHO_T}$enable_pc_color" >&6
+       test "$enable_pc_color" = no && cat >>confdefs.h <<\EOF
+#define OPT_PC_COLORS 0
+EOF
+
+       echo "$as_me:12471: checking if you want separate color-classes" >&5
+echo $ECHO_N "checking if you want separate color-classes... $ECHO_C" >&6
+
+# Check whether --enable-color-class or --disable-color-class was given.
+if test "${enable_color_class+set}" = set; then
+  enableval="$enable_color_class"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_color_class=no
+  else
+    enable_color_class=yes
+  fi
+else
+  enableval=yes
+  enable_color_class=yes
+
+fi;
+       echo "$as_me:12488: result: $enable_color_class" >&5
+echo "${ECHO_T}$enable_color_class" >&6
+       test "$enable_color_class" = no && cat >>confdefs.h <<\EOF
+#define OPT_COLOR_CLASS FALSE
+EOF
+
+       echo "$as_me:12494: checking if you want color-mode enabled by default" >&5
+echo $ECHO_N "checking if you want color-mode enabled by default... $ECHO_C" >&6
+
+# Check whether --enable-color-mode or --disable-color-mode was given.
+if test "${enable_color_mode+set}" = set; then
+  enableval="$enable_color_mode"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    default_colormode=no
+  else
+    default_colormode=yes
+  fi
+else
+  enableval=yes
+  default_colormode=yes
+
+fi;
+       echo "$as_me:12511: result: $default_colormode" >&5
+echo "${ECHO_T}$default_colormode" >&6
+       test "$default_colormode" = no && cat >>confdefs.h <<\EOF
+#define DFT_COLORMODE FALSE
+EOF
+
+fi
+
+echo "$as_me:12519: checking if you want support for color highlighting" >&5
+echo $ECHO_N "checking if you want support for color highlighting... $ECHO_C" >&6
+
+# Check whether --enable-highlighting or --disable-highlighting was given.
+if test "${enable_highlighting+set}" = set; then
+  enableval="$enable_highlighting"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    default_highlight=no
+  else
+    default_highlight=yes
+  fi
+else
+  enableval=yes
+  default_highlight=yes
+
+fi;
+echo "$as_me:12536: result: $default_highlight" >&5
+echo "${ECHO_T}$default_highlight" >&6
+test "$default_highlight" = no && cat >>confdefs.h <<\EOF
+#define OPT_HIGHLIGHT_COLOR 0
+EOF
+
+echo "$as_me:12542: checking if you want support for doublesize characters" >&5
+echo $ECHO_N "checking if you want support for doublesize characters... $ECHO_C" >&6
+
+# Check whether --enable-doublechars or --disable-doublechars was given.
+if test "${enable_doublechars+set}" = set; then
+  enableval="$enable_doublechars"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_doublechars=no
+  else
+    enable_doublechars=yes
+  fi
+else
+  enableval=yes
+  enable_doublechars=yes
+
+fi;
+echo "$as_me:12559: result: $enable_doublechars" >&5
+echo "${ECHO_T}$enable_doublechars" >&6
+test "$enable_doublechars" = no && cat >>confdefs.h <<\EOF
+#define OPT_DEC_CHRSET 0
+EOF
+
+echo "$as_me:12565: checking if you want fallback-support for box characters" >&5
+echo $ECHO_N "checking if you want fallback-support for box characters... $ECHO_C" >&6
+
+# Check whether --enable-boxchars or --disable-boxchars was given.
+if test "${enable_boxchars+set}" = set; then
+  enableval="$enable_boxchars"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_boxchars=no
+  else
+    enable_boxchars=yes
+  fi
+else
+  enableval=yes
+  enable_boxchars=yes
+
+fi;
+echo "$as_me:12582: result: $enable_boxchars" >&5
+echo "${ECHO_T}$enable_boxchars" >&6
+test "$enable_boxchars" = no && cat >>confdefs.h <<\EOF
+#define OPT_BOX_CHARS 0
+EOF
+
+echo "$as_me:12588: checking if you want to allow spawning new xterms" >&5
+echo $ECHO_N "checking if you want to allow spawning new xterms... $ECHO_C" >&6
+
+# Check whether --enable-exec-xterm or --disable-exec-xterm was given.
+if test "${enable_exec_xterm+set}" = set; then
+  enableval="$enable_exec_xterm"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_exec_xterm=yes
+  else
+    enable_exec_xterm=no
+  fi
+else
+  enableval=no
+  enable_exec_xterm=no
+
+fi;
+echo "$as_me:12605: result: $enable_exec_xterm" >&5
+echo "${ECHO_T}$enable_exec_xterm" >&6
+if test "$enable_exec_xterm" = yes ; then
+
+echo "$as_me:12609: checking for proc tree with cwd-support" >&5
+echo $ECHO_N "checking for proc tree with cwd-support... $ECHO_C" >&6
+if test "${cf_cv_procfs_cwd+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_procfs_cwd=no
+for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
+do
+       if test -d $cf_path && \
+          test -d $cf_path/$$ && \
+          ( test -d $cf_path/$$/cwd || \
+            test -L $cf_path/$$/cwd ); then
+               cf_cv_procfs_cwd=$cf_path
+               break
+       fi
+done
+
+fi
+echo "$as_me:12628: result: $cf_cv_procfs_cwd" >&5
+echo "${ECHO_T}$cf_cv_procfs_cwd" >&6
+
+       if test "$cf_cv_procfs_cwd" = no ; then
+               { echo "$as_me:12632: WARNING: no suitable proc filesystem found" >&5
+echo "$as_me: WARNING: no suitable proc filesystem found" >&2;}
+       else
+               cat >>confdefs.h <<EOF
+#define PROCFS_ROOT "$cf_cv_procfs_cwd"
+EOF
+
+               cat >>confdefs.h <<\EOF
+#define OPT_EXEC_XTERM 1
+EOF
+
+       fi
+fi
+
+echo "$as_me:12646: checking if you want to use FreeType library" >&5
+echo $ECHO_N "checking if you want to use FreeType library... $ECHO_C" >&6
+
+# Check whether --enable-freetype or --disable-freetype was given.
+if test "${enable_freetype+set}" = set; then
+  enableval="$enable_freetype"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_freetype=no
+  else
+    enable_freetype=yes
+  fi
+else
+  enableval=yes
+  enable_freetype=yes
+
+fi;
+echo "$as_me:12663: result: $enable_freetype" >&5
+echo "${ECHO_T}$enable_freetype" >&6
+if test "$enable_freetype" = yes ; then
+
+cf_extra_freetype_libs=
+FREETYPE_CONFIG=none
+FREETYPE_PARAMS=
+
+echo "$as_me:12671: checking if you specified -D/-I options for FreeType" >&5
+echo $ECHO_N "checking if you specified -D/-I options for FreeType... $ECHO_C" >&6
+
+# Check whether --with-freetype-cflags or --without-freetype-cflags was given.
+if test "${with_freetype_cflags+set}" = set; then
+  withval="$with_freetype_cflags"
+  cf_cv_x_freetype_incs="$with_freetype_cflags"
+else
+  cf_cv_x_freetype_incs=no
+fi;
+echo "$as_me:12681: result: $cf_cv_x_freetype_incs" >&5
+echo "${ECHO_T}$cf_cv_x_freetype_incs" >&6
+
+echo "$as_me:12684: checking if you specified -L/-l options for FreeType" >&5
+echo $ECHO_N "checking if you specified -L/-l options for FreeType... $ECHO_C" >&6
+
+# Check whether --with-freetype-libs or --without-freetype-libs was given.
+if test "${with_freetype_libs+set}" = set; then
+  withval="$with_freetype_libs"
+  cf_cv_x_freetype_libs="$with_freetype_libs"
+else
+  cf_cv_x_freetype_libs=no
+fi;
+echo "$as_me:12694: result: $cf_cv_x_freetype_libs" >&5
+echo "${ECHO_T}$cf_cv_x_freetype_libs" >&6
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
+       FREETYPE_CONFIG=$PKG_CONFIG
+       FREETYPE_PARAMS=xft
+else
+       # Extract the first word of "xft-config", so it can be a program name with args.
+set dummy xft-config; ac_word=$2
+echo "$as_me:12703: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_FREETYPE_XFT_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $FREETYPE_XFT_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FREETYPE_XFT_CONFIG="$FREETYPE_XFT_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_FREETYPE_XFT_CONFIG="$ac_dir/$ac_word"
+   echo "$as_me:12720: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  test -z "$ac_cv_path_FREETYPE_XFT_CONFIG" && ac_cv_path_FREETYPE_XFT_CONFIG="none"
+  ;;
+esac
+fi
+FREETYPE_XFT_CONFIG=$ac_cv_path_FREETYPE_XFT_CONFIG
+
+if test -n "$FREETYPE_XFT_CONFIG"; then
+  echo "$as_me:12732: result: $FREETYPE_XFT_CONFIG" >&5
+echo "${ECHO_T}$FREETYPE_XFT_CONFIG" >&6
+else
+  echo "$as_me:12735: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+       if test "$FREETYPE_XFT_CONFIG" != none; then
+               FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
+       else
+               cf_extra_freetype_libs="-lXft"
+               # Extract the first word of "freetype-config", so it can be a program name with args.
+set dummy freetype-config; ac_word=$2
+echo "$as_me:12745: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_FREETYPE_OLD_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $FREETYPE_OLD_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FREETYPE_OLD_CONFIG="$FREETYPE_OLD_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_FREETYPE_OLD_CONFIG="$ac_dir/$ac_word"
+   echo "$as_me:12762: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  test -z "$ac_cv_path_FREETYPE_OLD_CONFIG" && ac_cv_path_FREETYPE_OLD_CONFIG="none"
+  ;;
+esac
+fi
+FREETYPE_OLD_CONFIG=$ac_cv_path_FREETYPE_OLD_CONFIG
+
+if test -n "$FREETYPE_OLD_CONFIG"; then
+  echo "$as_me:12774: result: $FREETYPE_OLD_CONFIG" >&5
+echo "${ECHO_T}$FREETYPE_OLD_CONFIG" >&6
+else
+  echo "$as_me:12777: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+               if test "$FREETYPE_OLD_CONFIG" != none; then
+                       FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
+               fi
+       fi
+fi
+echo "$as_me:12786: checking for FreeType config" >&5
+echo $ECHO_N "checking for FreeType config... $ECHO_C" >&6
+echo "$as_me:12788: result: $FREETYPE_CONFIG $FREETYPE_PARAMS" >&5
+echo "${ECHO_T}$FREETYPE_CONFIG $FREETYPE_PARAMS" >&6
+
+if test "$FREETYPE_CONFIG" != none ; then
+
+       if test "$cf_cv_x_freetype_incs" = no ; then
+               echo "$as_me:12794: checking for $FREETYPE_CONFIG cflags" >&5
+echo $ECHO_N "checking for $FREETYPE_CONFIG cflags... $ECHO_C" >&6
+               cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
+               echo "$as_me:12797: result: $cf_cv_x_freetype_incs" >&5
+echo "${ECHO_T}$cf_cv_x_freetype_incs" >&6
+       fi
+
+       if test "$cf_cv_x_freetype_libs" = no ; then
+               echo "$as_me:12802: checking for $FREETYPE_CONFIG libs" >&5
+echo $ECHO_N "checking for $FREETYPE_CONFIG libs... $ECHO_C" >&6
+               cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
+               echo "$as_me:12805: result: $cf_cv_x_freetype_libs" >&5
+echo "${ECHO_T}$cf_cv_x_freetype_libs" >&6
+       fi
+
+fi
+
+if test "$cf_cv_x_freetype_incs" = no ; then
+       cf_cv_x_freetype_incs=
+fi
+
+if test "$cf_cv_x_freetype_libs" = no ; then
+       cf_cv_x_freetype_libs=-lXft
+fi
+
+echo "$as_me:12819: checking if we can link with FreeType libraries" >&5
+echo $ECHO_N "checking if we can link with FreeType libraries... $ECHO_C" >&6
+
+cf_save_LIBS="$LIBS"
+cf_save_INCS="$CPPFLAGS"
+
+LIBS="$cf_cv_x_freetype_libs $LIBS"
+CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 12829 "configure"
+#include "confdefs.h"
+
+#include <X11/Xlib.h>
+#include <X11/extensions/Xrender.h>
+#include <X11/Xft/Xft.h>
+int
+main ()
+{
+
+       XftPattern  *pat = XftNameParse ("name");
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:12845: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:12848: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:12851: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:12854: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_found_freetype=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_found_freetype=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+echo "$as_me:12863: result: $cf_cv_found_freetype" >&5
+echo "${ECHO_T}$cf_cv_found_freetype" >&6
+
+LIBS="$cf_save_LIBS"
+CPPFLAGS="$cf_save_INCS"
+
+if test "$cf_cv_found_freetype" = yes ; then
+       LIBS="$cf_cv_x_freetype_libs $LIBS"
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_cv_x_freetype_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       cat >>confdefs.h <<\EOF
+#define XRENDERFONT 1
+EOF
+
+for ac_func in \
+       XftDrawCharSpec \
+       XftDrawSetClip \
+       XftDrawSetClipRectangles \
+
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:12961: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 12967 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:12998: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13001: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13004: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13007: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:13017: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+else
+       { echo "$as_me:13028: WARNING: No libraries found for FreeType" >&5
+echo "$as_me: WARNING: No libraries found for FreeType" >&2;}
+       CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
+fi
+
+# FIXME: revisit this if needed
+
+echo "$as_me:13035: checking for usable Xft/fontconfig package" >&5
+echo $ECHO_N "checking for usable Xft/fontconfig package... $ECHO_C" >&6
+if test "${cf_cv_xft_compat+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 13042 "configure"
+#include "confdefs.h"
+
+#include <X11/Xft/Xft.h>
+
+int
+main ()
+{
+
+       XftPattern *pat;
+       XftPatternBuild(pat,
+                                       XFT_FAMILY, XftTypeString, "mono",
+                                       (void *) 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13061: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13064: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13067: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13070: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xft_compat=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xft_compat=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+fi
+echo "$as_me:13081: result: $cf_cv_xft_compat" >&5
+echo "${ECHO_T}$cf_cv_xft_compat" >&6
+
+if test "$cf_cv_xft_compat" = no
+then
+       # workaround for broken ".pc" files used for Xft.
+       case "$cf_cv_x_freetype_libs" in #(vi
+       *-lfontconfig*) #(vi
+               ;;
+       *)
+               test -n "$verbose" && echo "    work around broken package" 1>&6
+
+echo "${as_me:-configure}:13093: testing work around broken package ..." 1>&5
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists fontconfig; then
+       test -n "$verbose" && echo "    found package fontconfig" 1>&6
+
+echo "${as_me:-configure}:13098: testing found package fontconfig ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags fontconfig 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   fontconfig 2>/dev/null`"
+       test -n "$verbose" && echo "    package fontconfig CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:13104: testing package fontconfig CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package fontconfig LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:13108: testing package fontconfig LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+
+test -n "$verbose" && echo "   ...before $LIBS" 1>&6
+
+echo "${as_me:-configure}:13194: testing ...before $LIBS ..." 1>&5
+
+LIBS=`echo "$LIBS" | sed -e "s/[       ][      ]*/ /g" -e "s,-lXft ,-lXft -lfontconfig ," -e 's/  / /g'`
+test -n "$verbose" && echo "   ...after  $LIBS" 1>&6
+
+echo "${as_me:-configure}:13199: testing ...after  $LIBS ..." 1>&5
+
+fi
+
+               ;;
+       esac
+fi
+
+else
+       CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
+fi
+
+echo "$as_me:13211: checking if you want support for HP-style function keys" >&5
+echo $ECHO_N "checking if you want support for HP-style function keys... $ECHO_C" >&6
+
+# Check whether --enable-hp-fkeys or --disable-hp-fkeys was given.
+if test "${enable_hp_fkeys+set}" = set; then
+  enableval="$enable_hp_fkeys"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_hp_fkeys=yes
+  else
+    enable_hp_fkeys=no
+  fi
+else
+  enableval=no
+  enable_hp_fkeys=no
+
+fi;
+echo "$as_me:13228: result: $enable_hp_fkeys" >&5
+echo "${ECHO_T}$enable_hp_fkeys" >&6
+if test "$enable_hp_fkeys" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_HP_FUNC_KEYS 1
+EOF
+
+fi
+
+echo "$as_me:13237: checking if you want support for SCO-style function keys" >&5
+echo $ECHO_N "checking if you want support for SCO-style function keys... $ECHO_C" >&6
+
+# Check whether --enable-sco-fkeys or --disable-sco-fkeys was given.
+if test "${enable_sco_fkeys+set}" = set; then
+  enableval="$enable_sco_fkeys"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_sco_fkeys=yes
+  else
+    enable_sco_fkeys=no
+  fi
+else
+  enableval=no
+  enable_sco_fkeys=no
+
+fi;
+echo "$as_me:13254: result: $enable_sco_fkeys" >&5
+echo "${ECHO_T}$enable_sco_fkeys" >&6
+if test "$enable_sco_fkeys" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_SCO_FUNC_KEYS 1
+EOF
+
+fi
+
+echo "$as_me:13263: checking if you want support for Sun-style function keys" >&5
+echo $ECHO_N "checking if you want support for Sun-style function keys... $ECHO_C" >&6
+
+# Check whether --enable-sun-fkeys or --disable-sun-fkeys was given.
+if test "${enable_sun_fkeys+set}" = set; then
+  enableval="$enable_sun_fkeys"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_sun_fkeys=no
+  else
+    enable_sun_fkeys=yes
+  fi
+else
+  enableval=yes
+  enable_sun_fkeys=yes
+
+fi;
+echo "$as_me:13280: result: $enable_sun_fkeys" >&5
+echo "${ECHO_T}$enable_sun_fkeys" >&6
+if test "$enable_sun_fkeys" = no ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_SUN_FUNC_KEYS 0
+EOF
+
+fi
+
+echo "$as_me:13289: checking if you want saved-lines stored as a FIFO" >&5
+echo $ECHO_N "checking if you want saved-lines stored as a FIFO... $ECHO_C" >&6
+
+# Check whether --enable-fifo-lines or --disable-fifo-lines was given.
+if test "${enable_fifo_lines+set}" = set; then
+  enableval="$enable_fifo_lines"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_fifo_lines=no
+  else
+    enable_fifo_lines=yes
+  fi
+else
+  enableval=yes
+  enable_fifo_lines=yes
+
+fi;
+echo "$as_me:13306: result: $enable_fifo_lines" >&5
+echo "${ECHO_T}$enable_fifo_lines" >&6
+if test "$enable_fifo_lines" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_FIFO_LINES 1
+EOF
+
+fi
+
+echo "$as_me:13315: checking if you want support for internationalization" >&5
+echo $ECHO_N "checking if you want support for internationalization... $ECHO_C" >&6
+
+# Check whether --enable-i18n or --disable-i18n was given.
+if test "${enable_i18n+set}" = set; then
+  enableval="$enable_i18n"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_i18n=no
+  else
+    enable_i18n=yes
+  fi
+else
+  enableval=yes
+  enable_i18n=yes
+
+fi;
+echo "$as_me:13332: result: $enable_i18n" >&5
+echo "${ECHO_T}$enable_i18n" >&6
+if test "$enable_i18n" = no ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_I18N_SUPPORT 0
+EOF
+
+fi
+
+echo "$as_me:13341: checking if you want support for initial-erase setup" >&5
+echo $ECHO_N "checking if you want support for initial-erase setup... $ECHO_C" >&6
+
+# Check whether --enable-initial-erase or --disable-initial-erase was given.
+if test "${enable_initial_erase+set}" = set; then
+  enableval="$enable_initial_erase"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_ie=no
+  else
+    enable_ie=yes
+  fi
+else
+  enableval=yes
+  enable_ie=yes
+
+fi;
+echo "$as_me:13358: result: $enable_ie" >&5
+echo "${ECHO_T}$enable_ie" >&6
+if test "$enable_ie" = no ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_INITIAL_ERASE 0
+EOF
+
+fi
+
+echo "$as_me:13367: checking if you want support for input-method" >&5
+echo $ECHO_N "checking if you want support for input-method... $ECHO_C" >&6
+
+# Check whether --enable-input-method or --disable-input-method was given.
+if test "${enable_input_method+set}" = set; then
+  enableval="$enable_input_method"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_ximp=no
+  else
+    enable_ximp=yes
+  fi
+else
+  enableval=yes
+  enable_ximp=yes
+
+fi;
+echo "$as_me:13384: result: $enable_ximp" >&5
+echo "${ECHO_T}$enable_ximp" >&6
+
+echo "$as_me:13387: checking if X libraries support input-method" >&5
+echo $ECHO_N "checking if X libraries support input-method... $ECHO_C" >&6
+if test "${cf_cv_input_method+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+#line 13394 "configure"
+#include "confdefs.h"
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/Converters.h>
+#include <X11/Xaw/XawImP.h>
+
+int
+main ()
+{
+
+{
+       XIM xim;
+       XIMStyles *xim_styles = 0;
+       XIMStyle input_style;
+       Widget w = 0;
+
+       XSetLocaleModifiers("@im=none");
+       xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
+       XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
+       XCloseIM(xim);
+       input_style = (XIMPreeditNothing | XIMStatusNothing);
+}
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13426: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13429: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13432: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13435: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_input_method=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_input_method=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:13445: result: $cf_cv_input_method" >&5
+echo "${ECHO_T}$cf_cv_input_method" >&6
+
+test "$cf_cv_input_method" = no && enable_ximp=no
+if test "$enable_ximp" = no ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_INPUT_METHOD 0
+EOF
+
+fi
+
+echo "$as_me:13456: checking if you want support for load-vt-fonts" >&5
+echo $ECHO_N "checking if you want support for load-vt-fonts... $ECHO_C" >&6
+
+# Check whether --enable-load-vt-fonts or --disable-load-vt-fonts was given.
+if test "${enable_load_vt_fonts+set}" = set; then
+  enableval="$enable_load_vt_fonts"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_load_vt_fonts=yes
+  else
+    enable_load_vt_fonts=no
+  fi
+else
+  enableval=no
+  enable_load_vt_fonts=no
+
+fi;
+echo "$as_me:13473: result: $enable_load_vt_fonts" >&5
+echo "${ECHO_T}$enable_load_vt_fonts" >&6
+if test "$enable_load_vt_fonts" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_LOAD_VTFONTS 1
+EOF
+
+fi
+
+echo "$as_me:13482: checking if you want support for logging" >&5
+echo $ECHO_N "checking if you want support for logging... $ECHO_C" >&6
+
+# Check whether --enable-logging or --disable-logging was given.
+if test "${enable_logging+set}" = set; then
+  enableval="$enable_logging"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_logging=yes
+  else
+    enable_logging=no
+  fi
+else
+  enableval=no
+  enable_logging=no
+
+fi;
+echo "$as_me:13499: result: $enable_logging" >&5
+echo "${ECHO_T}$enable_logging" >&6
+if test "$enable_logging" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define ALLOWLOGGING 1
+EOF
+
+       echo "$as_me:13506: checking if you want to allow logging via a pipe" >&5
+echo $ECHO_N "checking if you want to allow logging via a pipe... $ECHO_C" >&6
+
+# Check whether --enable-logfile-exec or --disable-logfile-exec was given.
+if test "${enable_logfile_exec+set}" = set; then
+  enableval="$enable_logfile_exec"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_log_exec=yes
+  else
+    enable_log_exec=no
+  fi
+else
+  enableval=no
+  enable_log_exec=no
+
+fi;
+       echo "$as_me:13523: result: $enable_log_exec" >&5
+echo "${ECHO_T}$enable_log_exec" >&6
+       if test "$enable_log_exec" = yes ; then
+               cat >>confdefs.h <<\EOF
+#define ALLOWLOGFILEEXEC 1
+EOF
+
+       fi
+fi
+
+echo "$as_me:13533: checking if you want support for iconify/maximize translations" >&5
+echo $ECHO_N "checking if you want support for iconify/maximize translations... $ECHO_C" >&6
+
+# Check whether --enable-maximize or --disable-maximize was given.
+if test "${enable_maximize+set}" = set; then
+  enableval="$enable_maximize"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_maximize=no
+  else
+    enable_maximize=yes
+  fi
+else
+  enableval=yes
+  enable_maximize=yes
+
+fi;
+echo "$as_me:13550: result: $enable_maximize" >&5
+echo "${ECHO_T}$enable_maximize" >&6
+test "$enable_maximize" = no && cat >>confdefs.h <<\EOF
+#define OPT_MAXIMIZE 0
+EOF
+
+echo "$as_me:13556: checking if you want NumLock to override keyboard tables" >&5
+echo $ECHO_N "checking if you want NumLock to override keyboard tables... $ECHO_C" >&6
+
+# Check whether --enable-num-lock or --disable-num-lock was given.
+if test "${enable_num_lock+set}" = set; then
+  enableval="$enable_num_lock"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_numlock=no
+  else
+    enable_numlock=yes
+  fi
+else
+  enableval=yes
+  enable_numlock=yes
+
+fi;
+echo "$as_me:13573: result: $enable_numlock" >&5
+echo "${ECHO_T}$enable_numlock" >&6
+test "$enable_numlock" = no && cat >>confdefs.h <<\EOF
+#define OPT_NUM_LOCK 0
+EOF
+
+echo "$as_me:13579: checking if you want support for get/set of base64 selection data" >&5
+echo $ECHO_N "checking if you want support for get/set of base64 selection data... $ECHO_C" >&6
+
+# Check whether --enable-paste64 or --disable-paste64 was given.
+if test "${enable_paste64+set}" = set; then
+  enableval="$enable_paste64"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_paste64=no
+  else
+    enable_paste64=yes
+  fi
+else
+  enableval=yes
+  enable_paste64=yes
+
+fi;
+echo "$as_me:13596: result: $enable_paste64" >&5
+echo "${ECHO_T}$enable_paste64" >&6
+if test "$enable_paste64" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_PASTE64 1
+EOF
+
+else
+       cat >>confdefs.h <<\EOF
+#define OPT_PASTE64 0
+EOF
+
+fi
+
+echo "$as_me:13610: checking if you want support for pty-handshaking" >&5
+echo $ECHO_N "checking if you want support for pty-handshaking... $ECHO_C" >&6
+
+# Check whether --enable-pty-handshake or --disable-pty-handshake was given.
+if test "${enable_pty_handshake+set}" = set; then
+  enableval="$enable_pty_handshake"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_pty_handshake=no
+  else
+    enable_pty_handshake=yes
+  fi
+else
+  enableval=yes
+  enable_pty_handshake=yes
+
+fi;
+echo "$as_me:13627: result: $enable_pty_handshake" >&5
+echo "${ECHO_T}$enable_pty_handshake" >&6
+if test "$enable_pty_handshake" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_PTY_HANDSHAKE 1
+EOF
+
+else
+       cat >>confdefs.h <<\EOF
+#define OPT_PTY_HANDSHAKE 0
+EOF
+
+fi
+
+echo "$as_me:13641: checking if you want support for mouse in readline applications" >&5
+echo $ECHO_N "checking if you want support for mouse in readline applications... $ECHO_C" >&6
+
+# Check whether --enable-readline-mouse or --disable-readline-mouse was given.
+if test "${enable_readline_mouse+set}" = set; then
+  enableval="$enable_readline_mouse"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_readline_mouse=yes
+  else
+    enable_readline_mouse=no
+  fi
+else
+  enableval=no
+  enable_readline_mouse=no
+
+fi;
+echo "$as_me:13658: result: $enable_readline_mouse" >&5
+echo "${ECHO_T}$enable_readline_mouse" >&6
+if test "$enable_readline_mouse" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_READLINE 1
+EOF
+
+fi
+
+echo "$as_me:13667: checking if you want support for regular-expression selections" >&5
+echo $ECHO_N "checking if you want support for regular-expression selections... $ECHO_C" >&6
+
+# Check whether --enable-regex or --disable-regex was given.
+if test "${enable_regex+set}" = set; then
+  enableval="$enable_regex"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_regex=no
+  else
+    enable_regex=yes
+  fi
+else
+  enableval=yes
+  enable_regex=yes
+
+fi;
+echo "$as_me:13684: result: $enable_regex" >&5
+echo "${ECHO_T}$enable_regex" >&6
+if test "$enable_regex" = yes ; then
+
+echo "$as_me:13688: checking if you want to use PCRE for regular-expressions" >&5
+echo $ECHO_N "checking if you want to use PCRE for regular-expressions... $ECHO_C" >&6
+
+# Check whether --with-pcre or --without-pcre was given.
+if test "${with_pcre+set}" = set; then
+  withval="$with_pcre"
+
+fi;
+test -z "$with_pcre" && with_pcre=no
+echo "$as_me:13697: result: $with_pcre" >&5
+echo "${ECHO_T}$with_pcre" >&6
+
+if test "$with_pcre" != no ; then
+
+if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists libpcre; then
+       test -n "$verbose" && echo "    found package libpcre" 1>&6
+
+echo "${as_me:-configure}:13705: testing found package libpcre ..." 1>&5
+
+       cf_pkgconfig_incs="`$PKG_CONFIG --cflags libpcre 2>/dev/null`"
+       cf_pkgconfig_libs="`$PKG_CONFIG --libs   libpcre 2>/dev/null`"
+       test -n "$verbose" && echo "    package libpcre CFLAGS: $cf_pkgconfig_incs" 1>&6
+
+echo "${as_me:-configure}:13711: testing package libpcre CFLAGS: $cf_pkgconfig_incs ..." 1>&5
+
+       test -n "$verbose" && echo "    package libpcre LIBS: $cf_pkgconfig_libs" 1>&6
+
+echo "${as_me:-configure}:13715: testing package libpcre LIBS: $cf_pkgconfig_libs ..." 1>&5
+
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_pkgconfig_incs
+do
+case $cf_fix_cppflags in
+no)
+       case $cf_add_cflags in #(vi
+       -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+               case $cf_add_cflags in
+               -D*)
+                       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+                       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+                               && test -z "${cf_tst_cflags}" \
+                               && cf_fix_cppflags=yes
+
+                       if test $cf_fix_cppflags = yes ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       elif test "${cf_tst_cflags}" = "\"'" ; then
+                               cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+                               continue
+                       fi
+                       ;;
+               esac
+               case "$CPPFLAGS" in
+               *$cf_add_cflags) #(vi
+                       ;;
+               *) #(vi
+                       case $cf_add_cflags in #(vi
+                       -D*)
+                               cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
+
+CPPFLAGS=`echo "$CPPFLAGS" | \
+       sed     -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?[         ]/ /g' \
+               -e 's/-[UD]'"$cf_tst_cppflags"'\(=[^    ]*\)\?$//g'`
+
+                               ;;
+                       esac
+                       cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+                       ;;
+               esac
+               ;;
+       *)
+               cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+               ;;
+       esac
+       ;;
+yes)
+       cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+       cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+       test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+               && test -z "${cf_tst_cflags}" \
+               && cf_fix_cppflags=no
+       ;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+
+       CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+
+       CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+
+       EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+       LIBS="$cf_pkgconfig_libs $LIBS"
+       :
+else
+
+echo "$as_me:13799: checking for pcre_compile in -lpcre" >&5
+echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6
+if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpcre  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 13807 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char pcre_compile ();
+int
+main ()
+{
+pcre_compile ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13826: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13829: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13832: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13835: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_pcre_pcre_compile=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_pcre_pcre_compile=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:13846: result: $ac_cv_lib_pcre_pcre_compile" >&5
+echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6
+if test $ac_cv_lib_pcre_pcre_compile = yes; then
+  cat >>confdefs.h <<EOF
+#define HAVE_LIBPCRE 1
+EOF
+
+  LIBS="-lpcre $LIBS"
+
+else
+  { { echo "$as_me:13856: error: Cannot find PCRE library" >&5
+echo "$as_me: error: Cannot find PCRE library" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+
+               cat >>confdefs.h <<\EOF
+#define HAVE_LIB_PCRE 1
+EOF
+
+               case $LIBS in #(vi
+               *pcreposix*) #(vi
+                       ;;
+               *)
+                       echo "$as_me:13871: checking for pcreposix_regcomp in -lpcreposix" >&5
+echo $ECHO_N "checking for pcreposix_regcomp in -lpcreposix... $ECHO_C" >&6
+if test "${ac_cv_lib_pcreposix_pcreposix_regcomp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpcreposix  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 13879 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char pcreposix_regcomp ();
+int
+main ()
+{
+pcreposix_regcomp ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13898: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13901: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13904: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13907: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_pcreposix_pcreposix_regcomp=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_pcreposix_pcreposix_regcomp=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:13918: result: $ac_cv_lib_pcreposix_pcreposix_regcomp" >&5
+echo "${ECHO_T}$ac_cv_lib_pcreposix_pcreposix_regcomp" >&6
+if test $ac_cv_lib_pcreposix_pcreposix_regcomp = yes; then
+  cat >>confdefs.h <<\EOF
+#define HAVE_PCREPOSIX_H 1
+EOF
+
+                                LIBS="-lpcreposix $LIBS"
+else
+  echo "$as_me:13927: checking for regcomp in -lpcreposix" >&5
+echo $ECHO_N "checking for regcomp in -lpcreposix... $ECHO_C" >&6
+if test "${ac_cv_lib_pcreposix_regcomp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpcreposix  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 13935 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char regcomp ();
+int
+main ()
+{
+regcomp ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:13954: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:13957: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:13960: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:13963: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_pcreposix_regcomp=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_pcreposix_regcomp=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:13974: result: $ac_cv_lib_pcreposix_regcomp" >&5
+echo "${ECHO_T}$ac_cv_lib_pcreposix_regcomp" >&6
+if test $ac_cv_lib_pcreposix_regcomp = yes; then
+
+                                       cat >>confdefs.h <<\EOF
+#define HAVE_PCREPOSIX_H 1
+EOF
+
+                                       LIBS="-lpcreposix $LIBS"
+else
+  { { echo "$as_me:13984: error: Cannot find PCRE POSIX library" >&5
+echo "$as_me: error: Cannot find PCRE POSIX library" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+
+                       ;;
+               esac
+fi
+
+       if test "$with_pcre" = no ; then
+
+cf_regex_func=no
+
+cf_regex_libs="regex re"
+case $host_os in #(vi
+mingw*)
+       cf_regex_libs="regex.dll $cf_regex_libs"
+       ;;
+esac
+
+echo "$as_me:14006: checking for regcomp" >&5
+echo $ECHO_N "checking for regcomp... $ECHO_C" >&6
+if test "${ac_cv_func_regcomp+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14012 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char regcomp (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char regcomp ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_regcomp) || defined (__stub___regcomp)
+choke me
+#else
+f = regcomp;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14043: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:14046: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14049: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:14052: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_regcomp=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_regcomp=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:14062: result: $ac_cv_func_regcomp" >&5
+echo "${ECHO_T}$ac_cv_func_regcomp" >&6
+if test $ac_cv_func_regcomp = yes; then
+  cf_regex_func=regcomp
+else
+
+       for cf_regex_lib in $cf_regex_libs
+       do
+               as_ac_Lib=`echo "ac_cv_lib_$cf_regex_lib''_regcomp" | $as_tr_sh`
+echo "$as_me:14071: checking for regcomp in -l$cf_regex_lib" >&5
+echo $ECHO_N "checking for regcomp in -l$cf_regex_lib... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$cf_regex_lib  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 14079 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char regcomp ();
+int
+main ()
+{
+regcomp ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14098: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:14101: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14104: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:14107: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_Lib=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_Lib=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:14118: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+
+                               LIBS="-l$cf_regex_lib $LIBS"
+                               cf_regex_func=regcomp
+                               break
+fi
+
+       done
+
+fi
+
+if test "$cf_regex_func" = no ; then
+       echo "$as_me:14132: checking for compile" >&5
+echo $ECHO_N "checking for compile... $ECHO_C" >&6
+if test "${ac_cv_func_compile+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 14138 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char compile (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char compile ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_compile) || defined (__stub___compile)
+choke me
+#else
+f = compile;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14169: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:14172: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14175: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:14178: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_compile=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_compile=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:14188: result: $ac_cv_func_compile" >&5
+echo "${ECHO_T}$ac_cv_func_compile" >&6
+if test $ac_cv_func_compile = yes; then
+  cf_regex_func=compile
+else
+
+               echo "$as_me:14194: checking for compile in -lgen" >&5
+echo $ECHO_N "checking for compile in -lgen... $ECHO_C" >&6
+if test "${ac_cv_lib_gen_compile+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgen  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 14202 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char compile ();
+int
+main ()
+{
+compile ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14221: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:14224: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14227: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:14230: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_gen_compile=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_gen_compile=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:14241: result: $ac_cv_lib_gen_compile" >&5
+echo "${ECHO_T}$ac_cv_lib_gen_compile" >&6
+if test $ac_cv_lib_gen_compile = yes; then
+
+                               LIBS="-lgen $LIBS"
+                               cf_regex_func=compile
+fi
+
+fi
+
+fi
+
+if test "$cf_regex_func" = no ; then
+       { echo "$as_me:14254: WARNING: cannot find regular expression library" >&5
+echo "$as_me: WARNING: cannot find regular expression library" >&2;}
+fi
+
+echo "$as_me:14258: checking for regular-expression headers" >&5
+echo $ECHO_N "checking for regular-expression headers... $ECHO_C" >&6
+if test "${cf_cv_regex_hdrs+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cf_cv_regex_hdrs=no
+case $cf_regex_func in #(vi
+compile) #(vi
+       for cf_regex_hdr in regexp.h regexpr.h
+       do
+               cat >conftest.$ac_ext <<_ACEOF
+#line 14270 "configure"
+#include "confdefs.h"
+#include <$cf_regex_hdr>
+int
+main ()
+{
+
+                       char *p = compile("", "", "", 0);
+                       int x = step("", "");
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14285: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:14288: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14291: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:14294: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+                       cf_cv_regex_hdrs=$cf_regex_hdr
+                       break
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       done
+       ;;
+*)
+       for cf_regex_hdr in regex.h
+       do
+               cat >conftest.$ac_ext <<_ACEOF
+#line 14311 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <$cf_regex_hdr>
+int
+main ()
+{
+
+                       regex_t *p;
+                       int x = regcomp(p, "", 0);
+                       int y = regexec(p, "", 0, 0, 0);
+                       regfree(p);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:14329: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:14332: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:14335: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:14338: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+                       cf_cv_regex_hdrs=$cf_regex_hdr
+                       break
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       done
+       ;;
+esac
+
+fi
+echo "$as_me:14354: result: $cf_cv_regex_hdrs" >&5
+echo "${ECHO_T}$cf_cv_regex_hdrs" >&6
+
+case $cf_cv_regex_hdrs in #(vi
+    no)               { echo "$as_me:14358: WARNING: no regular expression header found" >&5
+echo "$as_me: WARNING: no regular expression header found" >&2;} ;; #(vi
+    regex.h)   cat >>confdefs.h <<\EOF
+#define HAVE_REGEX_H_FUNCS 1
+EOF
+ ;; #(vi
+    regexp.h)  cat >>confdefs.h <<\EOF
+#define HAVE_REGEXP_H_FUNCS 1
+EOF
+ ;; #(vi
+    regexpr.h) cat >>confdefs.h <<\EOF
+#define HAVE_REGEXPR_H_FUNCS 1
+EOF
+ ;;
+esac
+
+               if test "X$cf_cv_regex_hdrs" != "Xregex.h" ; then
+                       { { echo "$as_me:14375: error: Only POSIX or PCRE regular expressions are supported" >&5
+echo "$as_me: error: Only POSIX or PCRE regular expressions are supported" >&2;}
+   { (exit 1); exit 1; }; }
+               fi
+       fi
+       cat >>confdefs.h <<\EOF
+#define OPT_SELECT_REGEX 1
+EOF
+
+fi
+
+echo "$as_me:14386: checking if you want support for right-scrollbar" >&5
+echo $ECHO_N "checking if you want support for right-scrollbar... $ECHO_C" >&6
+
+# Check whether --enable-rightbar or --disable-rightbar was given.
+if test "${enable_rightbar+set}" = set; then
+  enableval="$enable_rightbar"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_rightbar=no
+  else
+    enable_rightbar=yes
+  fi
+else
+  enableval=yes
+  enable_rightbar=yes
+
+fi;
+echo "$as_me:14403: result: $enable_rightbar" >&5
+echo "${ECHO_T}$enable_rightbar" >&6
+if test "$enable_rightbar" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define SCROLLBAR_RIGHT 1
+EOF
+
+fi
+
+echo "$as_me:14412: checking if you want check for redundant name-change" >&5
+echo $ECHO_N "checking if you want check for redundant name-change... $ECHO_C" >&6
+
+# Check whether --enable-samename or --disable-samename was given.
+if test "${enable_samename+set}" = set; then
+  enableval="$enable_samename"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_samename=no
+  else
+    enable_samename=yes
+  fi
+else
+  enableval=yes
+  enable_samename=yes
+
+fi;
+echo "$as_me:14429: result: $enable_samename" >&5
+echo "${ECHO_T}$enable_samename" >&6
+test "$enable_samename" = no && cat >>confdefs.h <<\EOF
+#define OPT_SAME_NAME 0
+EOF
+
+echo "$as_me:14435: checking if you want support for session management" >&5
+echo $ECHO_N "checking if you want support for session management... $ECHO_C" >&6
+
+# Check whether --enable-session-mgt or --disable-session-mgt was given.
+if test "${enable_session_mgt+set}" = set; then
+  enableval="$enable_session_mgt"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_session_mgt=no
+  else
+    enable_session_mgt=yes
+  fi
+else
+  enableval=yes
+  enable_session_mgt=yes
+
+fi;
+echo "$as_me:14452: result: $enable_session_mgt" >&5
+echo "${ECHO_T}$enable_session_mgt" >&6
+test "$enable_session_mgt" = no && cat >>confdefs.h <<\EOF
+#define OPT_SESSION_MGT 0
+EOF
+
+echo "$as_me:14458: checking if you want to use termcap function-keys" >&5
+echo $ECHO_N "checking if you want to use termcap function-keys... $ECHO_C" >&6
+
+# Check whether --enable-tcap-fkeys or --disable-tcap-fkeys was given.
+if test "${enable_tcap_fkeys+set}" = set; then
+  enableval="$enable_tcap_fkeys"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_tcap_fkeys=no
+  else
+    enable_tcap_fkeys=yes
+  fi
+else
+  enableval=yes
+  enable_tcap_fkeys=yes
+
+fi;
+echo "$as_me:14475: result: $enable_tcap_fkeys" >&5
+echo "${ECHO_T}$enable_tcap_fkeys" >&6
+test "$enable_tcap_fkeys" = yes && cat >>confdefs.h <<\EOF
+#define OPT_TCAP_FKEYS 1
+EOF
+
+echo "$as_me:14481: checking if you want to use termcap-query/report" >&5
+echo $ECHO_N "checking if you want to use termcap-query/report... $ECHO_C" >&6
+
+# Check whether --enable-tcap-query or --disable-tcap-query was given.
+if test "${enable_tcap_query+set}" = set; then
+  enableval="$enable_tcap_query"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_tcap_query=no
+  else
+    enable_tcap_query=yes
+  fi
+else
+  enableval=yes
+  enable_tcap_query=yes
+
+fi;
+echo "$as_me:14498: result: $enable_tcap_query" >&5
+echo "${ECHO_T}$enable_tcap_query" >&6
+test "$enable_tcap_query" = yes && cat >>confdefs.h <<\EOF
+#define OPT_TCAP_QUERY 1
+EOF
+
+echo "$as_me:14504: checking if you want support for tek4014" >&5
+echo $ECHO_N "checking if you want support for tek4014... $ECHO_C" >&6
+
+# Check whether --enable-tek4014 or --disable-tek4014 was given.
+if test "${enable_tek4014+set}" = set; then
+  enableval="$enable_tek4014"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_tek4014=no
+  else
+    enable_tek4014=yes
+  fi
+else
+  enableval=yes
+  enable_tek4014=yes
+
+fi;
+echo "$as_me:14521: result: $enable_tek4014" >&5
+echo "${ECHO_T}$enable_tek4014" >&6
+if test "$enable_tek4014" = no ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_TEK4014 0
+EOF
+
+else
+       EXTRAHDRS="$EXTRAHDRS Tekparse.h"
+       EXTRASRCS="$EXTRASRCS TekPrsTbl.c Tekproc.c"
+       EXTRAOBJS="$EXTRAOBJS TekPrsTbl.o Tekproc.o"
+fi
+
+echo "$as_me:14534: checking if you want pulldown menus with a toolbar" >&5
+echo $ECHO_N "checking if you want pulldown menus with a toolbar... $ECHO_C" >&6
+
+# Check whether --enable-toolbar or --disable-toolbar was given.
+if test "${enable_toolbar+set}" = set; then
+  enableval="$enable_toolbar"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_toolbar=yes
+  else
+    enable_toolbar=no
+  fi
+else
+  enableval=no
+  enable_toolbar=no
+
+fi;
+echo "$as_me:14551: result: $enable_toolbar" >&5
+echo "${ECHO_T}$enable_toolbar" >&6
+if test "$enable_toolbar" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_TOOLBAR 1
+EOF
+
+fi
+
+echo "$as_me:14560: checking if you want VT52 emulation" >&5
+echo $ECHO_N "checking if you want VT52 emulation... $ECHO_C" >&6
+
+# Check whether --enable-vt52 or --disable-vt52 was given.
+if test "${enable_vt52+set}" = set; then
+  enableval="$enable_vt52"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_vt52=no
+  else
+    enable_vt52=yes
+  fi
+else
+  enableval=yes
+  enable_vt52=yes
+
+fi;
+echo "$as_me:14577: result: $enable_vt52" >&5
+echo "${ECHO_T}$enable_vt52" >&6
+test "$enable_vt52" = no && cat >>confdefs.h <<\EOF
+#define OPT_VT52_MODE 0
+EOF
+
+echo "$as_me:14583: checking if you want to use mini-luit/Latin9 built-in support" >&5
+echo $ECHO_N "checking if you want to use mini-luit/Latin9 built-in support... $ECHO_C" >&6
+
+# Check whether --enable-mini-luit or --disable-mini-luit was given.
+if test "${enable_mini_luit+set}" = set; then
+  enableval="$enable_mini_luit"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_mini_luit=yes
+  else
+    enable_mini_luit=no
+  fi
+else
+  enableval=no
+  enable_mini_luit=no
+
+fi;
+echo "$as_me:14600: result: $enable_mini_luit" >&5
+echo "${ECHO_T}$enable_mini_luit" >&6
+if test "$enable_mini_luit" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_MINI_LUIT 1
+EOF
+
+fi
+
+echo "$as_me:14609: checking if you want to use luit" >&5
+echo $ECHO_N "checking if you want to use luit... $ECHO_C" >&6
+
+# Check whether --enable-luit or --disable-luit was given.
+if test "${enable_luit+set}" = set; then
+  enableval="$enable_luit"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_luit=yes
+  else
+    enable_luit=$enable_mini_luit
+  fi
+else
+  enableval=no
+  enable_luit=$enable_mini_luit
+
+fi;
+echo "$as_me:14626: result: $enable_luit" >&5
+echo "${ECHO_T}$enable_luit" >&6
+if test "$enable_luit" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_LUIT_PROG 1
+EOF
+
+test -z "$LUIT" && LUIT=xterm-filter
+for ac_prog in $LUIT xterm-filter bluit luit
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:14638: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_LUIT+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $LUIT in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LUIT="$LUIT" # Let the user override the test with a path.
+  ;;
+  *)
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  if $as_executable_p "$ac_dir/$ac_word"; then
+   ac_cv_path_LUIT="$ac_dir/$ac_word"
+   echo "$as_me:14655: found $ac_dir/$ac_word" >&5
+   break
+fi
+done
+
+  ;;
+esac
+fi
+LUIT=$ac_cv_path_LUIT
+
+if test -n "$LUIT"; then
+  echo "$as_me:14666: result: $LUIT" >&5
+echo "${ECHO_T}$LUIT" >&6
+else
+  echo "$as_me:14669: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$LUIT" && break
+done
+test -n "$LUIT" || LUIT="$LUIT"
+
+cf_path_prog=""
+cf_path_args=""
+IFS="${IFS:-   }"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
+for cf_temp in $ac_cv_path_LUIT
+do
+       if test -z "$cf_path_prog" ; then
+               if test "$with_full_paths" = yes ; then
+
+if test "x$prefix" != xNONE; then
+  cf_path_syntax="$prefix"
+else
+  cf_path_syntax="$ac_default_prefix"
+fi
+
+case ".$cf_temp" in #(vi
+.\$\(*\)*|.\'*\'*) #(vi
+  ;;
+..|./*|.\\*) #(vi
+  ;;
+.[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
+  ;;
+.\${*prefix}*) #(vi
+  eval cf_temp="$cf_temp"
+  case ".$cf_temp" in #(vi
+  .NONE/*)
+    cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
+    ;;
+  esac
+  ;; #(vi
+.no|.NONE/*)
+  cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
+  ;;
+*)
+  break
+  ;;
+esac
+
+                       cf_path_prog="$cf_temp"
+               else
+                       cf_path_prog="`basename $cf_temp`"
+               fi
+       elif test -z "$cf_path_args" ; then
+               cf_path_args="$cf_temp"
+       else
+               cf_path_args="$cf_path_args $cf_temp"
+       fi
+done
+IFS="$cf_save_ifs"
+
+if test -n "$cf_path_prog" ; then
+
+echo "${as_me:-configure}:14728: testing defining path for ${cf_path_prog} ..." 1>&5
+
+       cat >>confdefs.h <<EOF
+#define LUIT_PATH "$cf_path_prog"
+EOF
+
+       test -n "$cf_path_args" && cat >>confdefs.h <<EOF
+#define LUIT_ARGS "$cf_path_args"
+EOF
+
+fi
+
+fi
+
+echo "$as_me:14742: checking if you want wide-character support" >&5
+echo $ECHO_N "checking if you want wide-character support... $ECHO_C" >&6
+
+# Check whether --enable-wide-chars or --disable-wide-chars was given.
+if test "${enable_wide_chars+set}" = set; then
+  enableval="$enable_wide_chars"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "$enable_luit" ; then
+    enable_wchar=yes
+  else
+    enable_wchar=$enable_luit
+  fi
+else
+  enableval=$enable_luit
+  enable_wchar=$enable_luit
+
+fi;
+echo "$as_me:14759: result: $enable_wchar" >&5
+echo "${ECHO_T}$enable_wchar" >&6
+
+echo "$as_me:14762: checking if you want only 16-bit character support" >&5
+echo $ECHO_N "checking if you want only 16-bit character support... $ECHO_C" >&6
+
+# Check whether --enable-16bit-chars or --disable-16bit-chars was given.
+if test "${enable_16bit_chars+set}" = set; then
+  enableval="$enable_16bit_chars"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_16bit_chars=yes
+  else
+    enable_16bit_chars=no
+  fi
+else
+  enableval=no
+  enable_16bit_chars=no
+
+fi;
+echo "$as_me:14779: result: $enable_16bit_chars" >&5
+echo "${ECHO_T}$enable_16bit_chars" >&6
+
+if test "$enable_16bit_chars" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_WIDER_ICHAR 0
+EOF
+
+       enable_wchar=yes
+fi
+
+if test "$enable_wchar" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_WIDE_CHARS 1
+EOF
+
+       EXTRAHDRS="$EXTRAHDRS charclass.h precompose.h wcwidth.h"
+       EXTRASRCS="$EXTRASRCS charclass.c precompose.c wcwidth.c"
+       EXTRAOBJS="$EXTRAOBJS charclass.o precompose.o wcwidth.o"
+fi
+
+echo "$as_me:14800: checking if you want dynamic-abbreviation support" >&5
+echo $ECHO_N "checking if you want dynamic-abbreviation support... $ECHO_C" >&6
+
+# Check whether --enable-dabbrev or --disable-dabbrev was given.
+if test "${enable_dabbrev+set}" = set; then
+  enableval="$enable_dabbrev"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_dabbrev=yes
+  else
+    enable_dabbrev=no
+  fi
+else
+  enableval=no
+  enable_dabbrev=no
+
+fi;
+echo "$as_me:14817: result: $enable_dabbrev" >&5
+echo "${ECHO_T}$enable_dabbrev" >&6
+if test "$enable_dabbrev" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_DABBREV 1
+EOF
+
+fi
+
+echo "$as_me:14826: checking if you want DECterm Locator support" >&5
+echo $ECHO_N "checking if you want DECterm Locator support... $ECHO_C" >&6
+
+# Check whether --enable-dec-locator or --disable-dec-locator was given.
+if test "${enable_dec_locator+set}" = set; then
+  enableval="$enable_dec_locator"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_dec_locator=yes
+  else
+    enable_dec_locator=no
+  fi
+else
+  enableval=no
+  enable_dec_locator=no
+
+fi;
+echo "$as_me:14843: result: $enable_dec_locator" >&5
+echo "${ECHO_T}$enable_dec_locator" >&6
+if test "$enable_dec_locator" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_DEC_LOCATOR 1
+EOF
+
+fi
+
+echo "$as_me:14852: checking if you want VT420 rectangle support" >&5
+echo $ECHO_N "checking if you want VT420 rectangle support... $ECHO_C" >&6
+
+# Check whether --enable-rectangles or --disable-rectangles was given.
+if test "${enable_rectangles+set}" = set; then
+  enableval="$enable_rectangles"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_rectangles=no
+  else
+    enable_rectangles=yes
+  fi
+else
+  enableval=yes
+  enable_rectangles=yes
+
+fi;
+echo "$as_me:14869: result: $enable_rectangles" >&5
+echo "${ECHO_T}$enable_rectangles" >&6
+if test "$enable_rectangles" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_DEC_RECTOPS 1
+EOF
+
+fi
+
+echo "$as_me:14878: checking if you want -ziconbeep option" >&5
+echo $ECHO_N "checking if you want -ziconbeep option... $ECHO_C" >&6
+
+# Check whether --enable-ziconbeep or --disable-ziconbeep was given.
+if test "${enable_ziconbeep+set}" = set; then
+  enableval="$enable_ziconbeep"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    enable_ziconbeep=no
+  else
+    enable_ziconbeep=yes
+  fi
+else
+  enableval=yes
+  enable_ziconbeep=yes
+
+fi;
+echo "$as_me:14895: result: $enable_ziconbeep" >&5
+echo "${ECHO_T}$enable_ziconbeep" >&6
+test "$enable_ziconbeep" = no && cat >>confdefs.h <<\EOF
+#define OPT_ZICONBEEP 0
+EOF
+
+###############################################################################
+
+echo "$as_me:14903: checking if you want debugging traces" >&5
+echo $ECHO_N "checking if you want debugging traces... $ECHO_C" >&6
+
+# Check whether --enable-trace or --disable-trace was given.
+if test "${enable_trace+set}" = set; then
+  enableval="$enable_trace"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_trace=yes
+  else
+    enable_trace=no
+  fi
+else
+  enableval=no
+  enable_trace=no
+
+fi;
+echo "$as_me:14920: result: $enable_trace" >&5
+echo "${ECHO_T}$enable_trace" >&6
+if test "$enable_trace" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_TRACE 1
+EOF
+
+       EXTRASRCS="$EXTRASRCS trace.c"
+       EXTRAOBJS="$EXTRAOBJS trace.o"
+fi
+
+echo "$as_me:14931: checking if you want to test memory leaks" >&5
+echo $ECHO_N "checking if you want to test memory leaks... $ECHO_C" >&6
+
+# Check whether --enable-leaks or --disable-leaks was given.
+if test "${enable_leaks+set}" = set; then
+  enableval="$enable_leaks"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    disable_leaks=yes
+  else
+    disable_leaks=no
+  fi
+else
+  enableval=yes
+  disable_leaks=no
+
+fi;
+echo "$as_me:14948: result: $disable_leaks" >&5
+echo "${ECHO_T}$disable_leaks" >&6
+if test "$disable_leaks" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define NO_LEAKS 1
+EOF
+
+fi
+
+echo "$as_me:14957: checking if you want to see long compiling messages" >&5
+echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6
+
+# Check whether --enable-echo or --disable-echo was given.
+if test "${enable_echo+set}" = set; then
+  enableval="$enable_echo"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+
+    ECHO_LT='--silent'
+    ECHO_LD='@echo linking $@;'
+    RULE_CC='@echo compiling $<'
+    SHOW_CC='@echo compiling $@'
+    ECHO_CC='@'
+
+  else
+
+    ECHO_LT=''
+    ECHO_LD=''
+    RULE_CC=''
+    SHOW_CC=''
+    ECHO_CC=''
+
+  fi
+else
+  enableval=yes
+
+    ECHO_LT=''
+    ECHO_LD=''
+    RULE_CC=''
+    SHOW_CC=''
+    ECHO_CC=''
+
+fi;
+echo "$as_me:14991: result: $enableval" >&5
+echo "${ECHO_T}$enableval" >&6
+
+echo "$as_me:14994: checking if you want magic cookie emulation" >&5
+echo $ECHO_N "checking if you want magic cookie emulation... $ECHO_C" >&6
+
+# Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
+if test "${enable_xmc_glitch+set}" = set; then
+  enableval="$enable_xmc_glitch"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    enable_xmc=yes
+  else
+    enable_xmc=no
+  fi
+else
+  enableval=no
+  enable_xmc=no
+
+fi;
+echo "$as_me:15011: result: $enable_xmc" >&5
+echo "${ECHO_T}$enable_xmc" >&6
+if test "$enable_xmc" = yes ; then
+       cat >>confdefs.h <<\EOF
+#define OPT_XMC_GLITCH 1
+EOF
+
+       EXTRASRCS="$EXTRASRCS testxmc.c"
+       EXTRAOBJS="$EXTRAOBJS testxmc.o"
+fi
+
+for ac_func in tigetstr
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:15025: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 15031 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:15062: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:15065: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:15068: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:15071: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:15081: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+if test -n "$cf_cv_lib_part_tgetent"; then
+
+for ac_func in use_extended_names
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:15096: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 15102 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
+
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:15133: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:15136: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:15139: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:15142: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:15152: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
+
+fi
+done
+
+fi
+
+if test -n "$GCC" ; then
+echo "$as_me:15165: checking if you want to turn on gcc warnings" >&5
+echo $ECHO_N "checking if you want to turn on gcc warnings... $ECHO_C" >&6
+
+# Check whether --enable-warnings or --disable-warnings was given.
+if test "${enable_warnings+set}" = set; then
+  enableval="$enable_warnings"
+  test "$enableval" != yes && enableval=no
+  if test "$enableval" != "no" ; then
+    with_warnings=yes
+  else
+    with_warnings=no
+  fi
+else
+  enableval=no
+  with_warnings=no
+
+fi;
+echo "$as_me:15182: result: $with_warnings" >&5
+echo "${ECHO_T}$with_warnings" >&6
+if test "$with_warnings" = yes
+then
+
+if test "$GCC" = yes
+then
+cat > conftest.i <<EOF
+#ifndef GCC_PRINTF
+#define GCC_PRINTF 0
+#endif
+#ifndef GCC_SCANF
+#define GCC_SCANF 0
+#endif
+#ifndef GCC_NORETURN
+#define GCC_NORETURN /* nothing */
+#endif
+#ifndef GCC_UNUSED
+#define GCC_UNUSED /* nothing */
+#endif
+EOF
+if test "$GCC" = yes
+then
+       { echo "$as_me:15205: checking for $CC __attribute__ directives..." >&5
+echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
+cat > conftest.$ac_ext <<EOF
+#line 15208 "${as_me:-configure}"
+#include "confdefs.h"
+#include "conftest.h"
+#include "conftest.i"
+#if    GCC_PRINTF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+#else
+#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
+#endif
+#if    GCC_SCANF
+#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
+#else
+#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
+#endif
+extern void wow(char *,...) GCC_SCANFLIKE(1,2);
+extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
+extern void foo(void) GCC_NORETURN;
+int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
+EOF
+       cf_printf_attribute=no
+       cf_scanf_attribute=no
+       for cf_attribute in scanf printf unused noreturn
+       do
+
+cf_ATTRIBUTE=`echo "$cf_attribute" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+
+               cf_directive="__attribute__(($cf_attribute))"
+               echo "checking for $CC $cf_directive" 1>&5
+
+               case $cf_attribute in #(vi
+               printf) #(vi
+                       cf_printf_attribute=yes
+                       cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+                       ;;
+               scanf) #(vi
+                       cf_scanf_attribute=yes
+                       cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE 1
+EOF
+                       ;;
+               *) #(vi
+                       cat >conftest.h <<EOF
+#define GCC_$cf_ATTRIBUTE $cf_directive
+EOF
+                       ;;
+               esac
+
+               if { (eval echo "$as_me:15257: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:15260: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+                       test -n "$verbose" && echo "$as_me:15262: result: ... $cf_attribute" >&5
+echo "${ECHO_T}... $cf_attribute" >&6
+                       cat conftest.h >>confdefs.h
+                       case $cf_attribute in #(vi
+                       printf) #(vi
+                               if test "$cf_printf_attribute" = no ; then
+                                       cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) /* nothing */
+EOF
+                               else
+                                       cat >>confdefs.h <<EOF
+#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
+EOF
+                               fi
+                               ;;
+                       scanf) #(vi
+                               if test "$cf_scanf_attribute" = no ; then
+                                       cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var) /* nothing */
+EOF
+                               else
+                                       cat >>confdefs.h <<EOF
+#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
+EOF
+                               fi
+                               ;;
+                       esac
+               fi
+       done
+else
+       fgrep define conftest.i >>confdefs.h
+fi
+rm -rf conftest*
+fi
+
+GCC_VERSION=none
+if test "$GCC" = yes ; then
+       echo "$as_me:15299: checking version of $CC" >&5
+echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
+       GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
+       test -z "$GCC_VERSION" && GCC_VERSION=unknown
+       echo "$as_me:15303: result: $GCC_VERSION" >&5
+echo "${ECHO_T}$GCC_VERSION" >&6
+fi
+
+INTEL_COMPILER=no
+
+if test "$GCC" = yes ; then
+       case $host_os in
+       linux*|gnu*)
+               echo "$as_me:15312: checking if this is really Intel C compiler" >&5
+echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6
+               cf_save_CFLAGS="$CFLAGS"
+               CFLAGS="$CFLAGS -no-gcc"
+               cat >conftest.$ac_ext <<_ACEOF
+#line 15317 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:15334: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:15337: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:15340: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:15343: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  INTEL_COMPILER=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+               CFLAGS="$cf_save_CFLAGS"
+               echo "$as_me:15354: result: $INTEL_COMPILER" >&5
+echo "${ECHO_T}$INTEL_COMPILER" >&6
+               ;;
+       esac
+fi
+
+cat > conftest.$ac_ext <<EOF
+#line 15361 "${as_me:-configure}"
+int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
+EOF
+
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
+# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #279: controlling expression is constant
+
+       { echo "$as_me:15378: checking for $CC warning options..." >&5
+echo "$as_me: checking for $CC warning options..." >&6;}
+       cf_save_CFLAGS="$CFLAGS"
+       EXTRA_CFLAGS="-Wall"
+       for cf_opt in \
+               wd1419 \
+               wd1683 \
+               wd1684 \
+               wd193 \
+               wd593 \
+               wd279 \
+               wd810 \
+               wd869 \
+               wd981
+       do
+               CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+               if { (eval echo "$as_me:15394: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:15397: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+                       test -n "$verbose" && echo "$as_me:15399: result: ... -$cf_opt" >&5
+echo "${ECHO_T}... -$cf_opt" >&6
+                       EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+               fi
+       done
+       CFLAGS="$cf_save_CFLAGS"
+
+elif test "$GCC" = yes
+then
+       { echo "$as_me:15408: checking for $CC warning options..." >&5
+echo "$as_me: checking for $CC warning options..." >&6;}
+       cf_save_CFLAGS="$CFLAGS"
+       EXTRA_CFLAGS=
+       cf_warn_CONST=""
+       test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
+       for cf_opt in W Wall \
+               Wbad-function-cast \
+               Wcast-align \
+               Wcast-qual \
+               Winline \
+               Wmissing-declarations \
+               Wmissing-prototypes \
+               Wnested-externs \
+               Wpointer-arith \
+               Wshadow \
+               Wstrict-prototypes \
+               Wundef $cf_warn_CONST Wdeclaration-after-statement Wextra Wno-unknown-pragmas Wswitch-enum
+       do
+               CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+               if { (eval echo "$as_me:15428: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:15431: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+                       test -n "$verbose" && echo "$as_me:15433: result: ... -$cf_opt" >&5
+echo "${ECHO_T}... -$cf_opt" >&6
+                       case $cf_opt in #(vi
+                       Wcast-qual) #(vi
+                               CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
+                               ;;
+                       Winline) #(vi
+                               case $GCC_VERSION in
+                               [34].*)
+                                       test -n "$verbose" && echo "    feature is broken in gcc $GCC_VERSION" 1>&6
+
+echo "${as_me:-configure}:15444: testing feature is broken in gcc $GCC_VERSION ..." 1>&5
+
+                                       continue;;
+                               esac
+                               ;;
+                       esac
+                       EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
+               fi
+       done
+       CFLAGS="$cf_save_CFLAGS"
+fi
+rm -rf conftest*
+
+fi
+fi
+
+test "$disable_setuid" = yes && cat >>confdefs.h <<\EOF
+#define DISABLE_SETUID 1
+EOF
+
+test "$disable_setgid" = yes && cat >>confdefs.h <<\EOF
+#define DISABLE_SETGID 1
+EOF
+
+if test $disable_setuid = yes ; then
+       MAY_SETUID="#"
+       NOT_SETUID=
+elif test $disable_setgid = yes ; then
+       MAY_SETUID="#"
+       NOT_SETUID=
+else
+       MAY_SETUID=
+       NOT_SETUID="#"
+fi
+
+###    remove from CPPFLAGS the optional features we define in xtermcfg.h
+###    or other conflicting symbols that may be defined via imake:
+for cf_def in \
+       __STDC__ \
+       ALLOWLOGGING \
+       ALLOWLOGFILEEXEC \
+       OPT_LUIT_PROG \
+       OPT_WIDE_CHARS \
+       SCROLLBAR_RIGHT \
+       USE_TTY_GROUP \
+       USE_UTEMPTER \
+       XRENDERFONT
+do
+       CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-D$cf_def//`
+done
+
+echo "$as_me:15495: checking if filesystem supports mixed-case filenames" >&5
+echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
+if test "${cf_cv_mixedcase+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+if test "$cross_compiling" = yes ; then
+       case $target_alias in #(vi
+       *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
+               cf_cv_mixedcase=no
+               ;;
+       *)
+               cf_cv_mixedcase=yes
+               ;;
+       esac
+else
+       rm -f conftest CONFTEST
+       echo test >conftest
+       if test -f CONFTEST ; then
+               cf_cv_mixedcase=no
+       else
+               cf_cv_mixedcase=yes
+       fi
+       rm -f conftest CONFTEST
+fi
+
+fi
+echo "$as_me:15522: result: $cf_cv_mixedcase" >&5
+echo "${ECHO_T}$cf_cv_mixedcase" >&6
+test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF
+#define MIXEDCASE_FILENAMES 1
+EOF
+
+for ac_prog in exctags ctags
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:15532: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CTAGS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$CTAGS"; then
+  ac_cv_prog_CTAGS="$CTAGS" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_CTAGS="$ac_prog"
+echo "$as_me:15547: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+CTAGS=$ac_cv_prog_CTAGS
+if test -n "$CTAGS"; then
+  echo "$as_me:15555: result: $CTAGS" >&5
+echo "${ECHO_T}$CTAGS" >&6
+else
+  echo "$as_me:15558: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$CTAGS" && break
+done
+
+for ac_prog in exetags etags
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:15569: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ETAGS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$ETAGS"; then
+  ac_cv_prog_ETAGS="$ETAGS" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_ETAGS="$ac_prog"
+echo "$as_me:15584: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+ETAGS=$ac_cv_prog_ETAGS
+if test -n "$ETAGS"; then
+  echo "$as_me:15592: result: $ETAGS" >&5
+echo "${ECHO_T}$ETAGS" >&6
+else
+  echo "$as_me:15595: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$ETAGS" && break
+done
+
+# Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args.
+set dummy ${CTAGS:-ctags}; ac_word=$2
+echo "$as_me:15604: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$MAKE_LOWER_TAGS"; then
+  ac_cv_prog_MAKE_LOWER_TAGS="$MAKE_LOWER_TAGS" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_MAKE_LOWER_TAGS="yes"
+echo "$as_me:15619: found $ac_dir/$ac_word" >&5
+break
+done
+
+  test -z "$ac_cv_prog_MAKE_LOWER_TAGS" && ac_cv_prog_MAKE_LOWER_TAGS="no"
+fi
+fi
+MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
+if test -n "$MAKE_LOWER_TAGS"; then
+  echo "$as_me:15628: result: $MAKE_LOWER_TAGS" >&5
+echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
+else
+  echo "$as_me:15631: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+if test "$cf_cv_mixedcase" = yes ; then
+       # Extract the first word of "${ETAGS:-etags}", so it can be a program name with args.
+set dummy ${ETAGS:-etags}; ac_word=$2
+echo "$as_me:15638: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$MAKE_UPPER_TAGS"; then
+  ac_cv_prog_MAKE_UPPER_TAGS="$MAKE_UPPER_TAGS" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_MAKE_UPPER_TAGS="yes"
+echo "$as_me:15653: found $ac_dir/$ac_word" >&5
+break
+done
+
+  test -z "$ac_cv_prog_MAKE_UPPER_TAGS" && ac_cv_prog_MAKE_UPPER_TAGS="no"
+fi
+fi
+MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
+if test -n "$MAKE_UPPER_TAGS"; then
+  echo "$as_me:15662: result: $MAKE_UPPER_TAGS" >&5
+echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
+else
+  echo "$as_me:15665: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+else
+       MAKE_UPPER_TAGS=no
+fi
+
+if test "$MAKE_UPPER_TAGS" = yes ; then
+       MAKE_UPPER_TAGS=
+else
+       MAKE_UPPER_TAGS="#"
+fi
+
+if test "$MAKE_LOWER_TAGS" = yes ; then
+       MAKE_LOWER_TAGS=
+else
+       MAKE_LOWER_TAGS="#"
+fi
+
+LD_RPATH_OPT=
+echo "$as_me:15686: checking for an rpath option" >&5
+echo $ECHO_N "checking for an rpath option... $ECHO_C" >&6
+case $cf_cv_system_name in #(vi
+irix*) #(vi
+       if test "$GCC" = yes; then
+               LD_RPATH_OPT="-Wl,-rpath,"
+       else
+               LD_RPATH_OPT="-rpath "
+       fi
+       ;;
+linux*|gnu*|k*bsd*-gnu) #(vi
+       LD_RPATH_OPT="-Wl,-rpath,"
+       ;;
+openbsd[2-9].*) #(vi
+       LD_RPATH_OPT="-Wl,-rpath,"
+       ;;
+freebsd*) #(vi
+       LD_RPATH_OPT="-rpath "
+       ;;
+netbsd*) #(vi
+       LD_RPATH_OPT="-Wl,-rpath,"
+       ;;
+osf*|mls+*) #(vi
+       LD_RPATH_OPT="-rpath "
+       ;;
+solaris2*) #(vi
+       LD_RPATH_OPT="-R"
+       ;;
+*)
+       ;;
+esac
+echo "$as_me:15717: result: $LD_RPATH_OPT" >&5
+echo "${ECHO_T}$LD_RPATH_OPT" >&6
+
+case "x$LD_RPATH_OPT" in #(vi
+x-R*)
+       echo "$as_me:15722: checking if we need a space after rpath option" >&5
+echo $ECHO_N "checking if we need a space after rpath option... $ECHO_C" >&6
+       cf_save_LIBS="$LIBS"
+       LIBS="${LD_RPATH_OPT}$libdir $LIBS"
+       cat >conftest.$ac_ext <<_ACEOF
+#line 15727 "configure"
+#include "confdefs.h"
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:15739: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:15742: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:15745: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:15748: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_rpath_space=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_rpath_space=yes
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       LIBS="$cf_save_LIBS"
+       echo "$as_me:15758: result: $cf_rpath_space" >&5
+echo "${ECHO_T}$cf_rpath_space" >&6
+       test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
+       ;;
+esac
+
+echo "$as_me:15764: checking if rpath should be not be set" >&5
+echo $ECHO_N "checking if rpath should be not be set... $ECHO_C" >&6
+
+# Check whether --enable-rpath-hack or --disable-rpath-hack was given.
+if test "${enable_rpath_hack+set}" = set; then
+  enableval="$enable_rpath_hack"
+  test "$enableval" != no && enableval=yes
+  if test "$enableval" != "yes" ; then
+    cf_disable_rpath_hack=yes
+  else
+    cf_disable_rpath_hack=no
+  fi
+else
+  enableval=yes
+  cf_disable_rpath_hack=no
+
+fi;
+echo "$as_me:15781: result: $cf_disable_rpath_hack" >&5
+echo "${ECHO_T}$cf_disable_rpath_hack" >&6
+if test "$cf_disable_rpath_hack" = no ; then
+
+echo "$as_me:15785: checking for updated LDFLAGS" >&5
+echo $ECHO_N "checking for updated LDFLAGS... $ECHO_C" >&6
+if test -n "$LD_RPATH_OPT" ; then
+       echo "$as_me:15788: result: maybe" >&5
+echo "${ECHO_T}maybe" >&6
+
+       for ac_prog in ldd
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:15795: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_cf_ldd_prog+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -n "$cf_ldd_prog"; then
+  ac_cv_prog_cf_ldd_prog="$cf_ldd_prog" # Let the user override the test.
+else
+  ac_save_IFS=$IFS; IFS=$ac_path_separator
+ac_dummy="$PATH"
+for ac_dir in $ac_dummy; do
+  IFS=$ac_save_IFS
+  test -z "$ac_dir" && ac_dir=.
+  $as_executable_p "$ac_dir/$ac_word" || continue
+ac_cv_prog_cf_ldd_prog="$ac_prog"
+echo "$as_me:15810: found $ac_dir/$ac_word" >&5
+break
+done
+
+fi
+fi
+cf_ldd_prog=$ac_cv_prog_cf_ldd_prog
+if test -n "$cf_ldd_prog"; then
+  echo "$as_me:15818: result: $cf_ldd_prog" >&5
+echo "${ECHO_T}$cf_ldd_prog" >&6
+else
+  echo "$as_me:15821: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  test -n "$cf_ldd_prog" && break
+done
+test -n "$cf_ldd_prog" || cf_ldd_prog="no"
+
+       cf_rpath_list="/usr/lib /lib"
+       if test "$cf_ldd_prog" != no
+       then
+cat >conftest.$ac_ext <<_ACEOF
+#line 15833 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int
+main ()
+{
+printf("Hello");
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:15845: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:15848: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:15851: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:15854: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[    ]/%/%' -e 's%/[^/][^/]*$%%' |sort -u`
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+       fi
+
+       test -n "$verbose" && echo "    ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
+
+echo "${as_me:-configure}:15866: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+
+test -n "$verbose" && echo "   ...checking LDFLAGS $LDFLAGS" 1>&6
+
+echo "${as_me:-configure}:15870: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5
+
+cf_rpath_dst=
+for cf_rpath_src in $LDFLAGS
+do
+       case $cf_rpath_src in #(vi
+       -L*) #(vi
+
+               # check if this refers to a directory which we will ignore
+               cf_rpath_skip=no
+               if test -n "$cf_rpath_list"
+               then
+                       for cf_rpath_item in $cf_rpath_list
+                       do
+                               if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
+                               then
+                                       cf_rpath_skip=yes
+                                       break
+                               fi
+                       done
+               fi
+
+               if test "$cf_rpath_skip" = no
+               then
+                       # transform the option
+                       if test "$LD_RPATH_OPT" = "-R " ; then
+                               cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
+                       else
+                               cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
+                       fi
+
+                       # if we have not already added this, add it now
+                       cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
+                       if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
+                       then
+                               test -n "$verbose" && echo "    ...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
+
+echo "${as_me:-configure}:15907: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+
+                               EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
+                       fi
+               fi
+               ;;
+       esac
+       cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
+done
+LDFLAGS=$cf_rpath_dst
+
+test -n "$verbose" && echo "   ...checked LDFLAGS $LDFLAGS" 1>&6
+
+echo "${as_me:-configure}:15920: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5
+
+test -n "$verbose" && echo "   ...checking LIBS $LIBS" 1>&6
+
+echo "${as_me:-configure}:15924: testing ...checking LIBS $LIBS ..." 1>&5
+
+cf_rpath_dst=
+for cf_rpath_src in $LIBS
+do
+       case $cf_rpath_src in #(vi
+       -L*) #(vi
+
+               # check if this refers to a directory which we will ignore
+               cf_rpath_skip=no
+               if test -n "$cf_rpath_list"
+               then
+                       for cf_rpath_item in $cf_rpath_list
+                       do
+                               if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
+                               then
+                                       cf_rpath_skip=yes
+                                       break
+                               fi
+                       done
+               fi
+
+               if test "$cf_rpath_skip" = no
+               then
+                       # transform the option
+                       if test "$LD_RPATH_OPT" = "-R " ; then
+                               cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
+                       else
+                               cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
+                       fi
+
+                       # if we have not already added this, add it now
+                       cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
+                       if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
+                       then
+                               test -n "$verbose" && echo "    ...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6
+
+echo "${as_me:-configure}:15961: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5
+
+                               EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
+                       fi
+               fi
+               ;;
+       esac
+       cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
+done
+LIBS=$cf_rpath_dst
+
+test -n "$verbose" && echo "   ...checked LIBS $LIBS" 1>&6
+
+echo "${as_me:-configure}:15974: testing ...checked LIBS $LIBS ..." 1>&5
+
+       test -n "$verbose" && echo "    ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6
+
+echo "${as_me:-configure}:15978: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5
+
+fi
+
+fi
+
+# Force plink.sh to not trim pcre's libraries, which have the same symbol
+# names as the system regexp.
+if test "$with_pcre" != no
+then
+       LIBS=`echo "$LIBS" | sed -e 's/-lpcre/-kpcre/g'`
+fi
+
+###    output Makefile and xtermcfg.h
+ac_config_files="$ac_config_files Makefile"
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overriden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+  (set) 2>&1 |
+    case `(ac_space=' '; set | grep ac_space) 2>&1` in
+    *ac_space=\ *)
+      # `set' does not quote correctly, so add quotes (double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \).
+      sed -n \
+        "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;;
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n \
+        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      ;;
+    esac;
+} |
+  sed '
+     t clear
+     : clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     : end' >>confcache
+if cmp -s $cache_file confcache; then :; else
+  if test -w $cache_file; then
+    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+    cat confcache >$cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[        ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[   ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[     ]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:16072: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+ac_cs_invocation="\$0 \$@"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+  set -o posix
+fi
+
+# Name of the executable.
+as_me=`echo "$0" |sed 's,.*[\\/],,'`
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+  # We could just check for DJGPP; but this test a) works b) is more generic
+  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+  if test -f conf$$.exe; then
+    # Don't use ln at all; we don't have any links
+    as_ln_s='cp -p'
+  else
+    as_ln_s='ln -s'
+  fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+  as_ln_s=ln
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+as_executable_p="test -f"
+
+# Support unset when possible.
+if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
+  as_unset=unset
+else
+  as_unset=false
+fi
+
+# NLS nuisances.
+$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
+$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
+$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
+$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
+$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
+$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
+$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
+$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS="  $as_nl"
+
+# CDPATH.
+$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
+
+exec 6>&1
+
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\EOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number, then exit
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+  --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+  --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to <dickey@invisible-island.net>."
+EOF
+
+cat >>$CONFIG_STATUS <<EOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.52.20101001,
+  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+EOF
+
+cat >>$CONFIG_STATUS <<\EOF
+# If no file are specified by the user, then we need to provide default
+# value.  By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "x$1" : 'x\([^=]*\)='`
+    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+    shift
+    set dummy "$ac_option" "$ac_optarg" ${1+"$@"}
+    shift
+    ;;
+  -*);;
+  *) # This is not an option, so the user has probably given explicit
+     # arguments.
+     ac_need_defaults=false;;
+  esac
+
+  case $1 in
+  # Handling of the options.
+EOF
+cat >>$CONFIG_STATUS <<EOF
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion"
+    exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;;
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+  --version | --vers* | -V )
+    echo "$ac_cs_version"; exit 0 ;;
+  --he | --h)
+    # Conflict between --help and --header
+    { { echo "$as_me:16245: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit 0 ;;
+  --debug | --d* | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    shift
+    CONFIG_FILES="$CONFIG_FILES $1"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    shift
+    CONFIG_HEADERS="$CONFIG_HEADERS $1"
+    ac_need_defaults=false;;
+
+  # This is an error.
+  -*) { { echo "$as_me:16264: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+   { (exit 1); exit 1; }; } ;;
+
+  *) ac_config_targets="$ac_config_targets $1" ;;
+
+  esac
+  shift
+done
+
+exec 5>>config.log
+cat >&5 << _ACEOF
+
+## ----------------------- ##
+## Running config.status.  ##
+## ----------------------- ##
+
+This file was extended by $as_me 2.52.20101001, executed with
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  > $ac_cs_invocation
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+
+_ACEOF
+EOF
+
+cat >>$CONFIG_STATUS <<\EOF
+for ac_config_target in $ac_config_targets
+do
+  case "$ac_config_target" in
+  # Handling of arguments.
+  "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+  "xtermcfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS xtermcfg.h:xtermcfg.hin" ;;
+  *) { { echo "$as_me:16301: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+   { (exit 1); exit 1; }; };;
+  esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+: ${TMPDIR=/tmp}
+{
+  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=$TMPDIR/cs$$-$RANDOM
+  (umask 077 && mkdir $tmp)
+} ||
+{
+   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
+   { (exit 1); exit 1; }
+}
+
+EOF
+
+cat >>$CONFIG_STATUS <<EOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+  # Protect against being on the right side of a sed subst in config.status.
+  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@DEFS@,$DEFS,;t t
+s,@LIBS@,$LIBS,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@CPP@,$CPP,;t t
+s,@AWK@,$AWK,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@LN_S@,$LN_S,;t t
+s,@LINT@,$LINT,;t t
+s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t
+s,@PROG_EXT@,$PROG_EXT,;t t
+s,@appsdir@,$appsdir,;t t
+s,@no_appsdir@,$no_appsdir,;t t
+s,@icondir@,$icondir,;t t
+s,@no_icondir@,$no_icondir,;t t
+s,@desktop_utils@,$desktop_utils,;t t
+s,@DESKTOP_FLAGS@,$DESKTOP_FLAGS,;t t
+s,@XTERM_PATH@,$XTERM_PATH,;t t
+s,@XTERM_SYMLINK@,$XTERM_SYMLINK,;t t
+s,@SINSTALL_OPTS@,$SINSTALL_OPTS,;t t
+s,@X_CFLAGS@,$X_CFLAGS,;t t
+s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t
+s,@X_LIBS@,$X_LIBS,;t t
+s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
+s,@PKG_CONFIG@,$PKG_CONFIG,;t t
+s,@IMAKE@,$IMAKE,;t t
+s,@IMAKE_CFLAGS@,$IMAKE_CFLAGS,;t t
+s,@IMAKE_LOADFLAGS@,$IMAKE_LOADFLAGS,;t t
+s,@cf_tic_prog@,$cf_tic_prog,;t t
+s,@no_ticprog@,$no_ticprog,;t t
+s,@TERMINFO_DIR@,$TERMINFO_DIR,;t t
+s,@SET_TERMINFO@,$SET_TERMINFO,;t t
+s,@FREETYPE_XFT_CONFIG@,$FREETYPE_XFT_CONFIG,;t t
+s,@FREETYPE_OLD_CONFIG@,$FREETYPE_OLD_CONFIG,;t t
+s,@HAVE_TYPE_FCCHAR32@,$HAVE_TYPE_FCCHAR32,;t t
+s,@HAVE_TYPE_XFTCHARSPEC@,$HAVE_TYPE_XFTCHARSPEC,;t t
+s,@LUIT@,$LUIT,;t t
+s,@ECHO_LT@,$ECHO_LT,;t t
+s,@ECHO_LD@,$ECHO_LD,;t t
+s,@RULE_CC@,$RULE_CC,;t t
+s,@SHOW_CC@,$SHOW_CC,;t t
+s,@ECHO_CC@,$ECHO_CC,;t t
+s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
+s,@CHARPROC_DEPS@,$CHARPROC_DEPS,;t t
+s,@EXTRAHDRS@,$EXTRAHDRS,;t t
+s,@EXTRASRCS@,$EXTRASRCS,;t t
+s,@EXTRAOBJS@,$EXTRAOBJS,;t t
+s,@MAY_SETUID@,$MAY_SETUID,;t t
+s,@NOT_SETUID@,$NOT_SETUID,;t t
+s,@CTAGS@,$CTAGS,;t t
+s,@ETAGS@,$ETAGS,;t t
+s,@MAKE_LOWER_TAGS@,$MAKE_LOWER_TAGS,;t t
+s,@MAKE_UPPER_TAGS@,$MAKE_UPPER_TAGS,;t t
+s,@cf_ldd_prog@,$cf_ldd_prog,;t t
+s,@EXTRA_LDFLAGS@,$EXTRA_LDFLAGS,;t t
+CEOF
+
+EOF
+
+  cat >>$CONFIG_STATUS <<\EOF
+  # Split the substitutions into bite-sized pieces for seds with
+  # small command number limits, like on Digital OSF/1 and HP-UX.
+  ac_max_sed_lines=48
+  ac_sed_frag=1 # Number of current file.
+  ac_beg=1 # First line for current file.
+  ac_end=$ac_max_sed_lines # Line after last line for current file.
+  ac_more_lines=:
+  ac_sed_cmds=
+  while $ac_more_lines; do
+    if test $ac_beg -gt 1; then
+      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    else
+      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+    fi
+    if test ! -s $tmp/subs.frag; then
+      ac_more_lines=false
+    else
+      # The purpose of the label and of the branching condition is to
+      # speed up the sed processing (if there are no `@' at all, there
+      # is no need to browse any of the substitutions).
+      # These are the two extra sed commands mentioned above.
+      (echo ':t
+  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+      if test -z "$ac_sed_cmds"; then
+       ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+      else
+       ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+      fi
+      ac_sed_frag=`expr $ac_sed_frag + 1`
+      ac_beg=$ac_end
+      ac_end=`expr $ac_end + $ac_max_sed_lines`
+    fi
+  done
+  if test -z "$ac_sed_cmds"; then
+    ac_sed_cmds=cat
+  fi
+fi # test -n "$CONFIG_FILES"
+
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
+  esac
+
+  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+  ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+    { case "$ac_dir" in
+  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
+  *)                      as_incr_dir=.;;
+esac
+as_dummy="$ac_dir"
+for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
+  case $as_mkdir_dir in
+    # Skip DOS drivespec
+    ?:) as_incr_dir=$as_mkdir_dir ;;
+    *)
+      as_incr_dir=$as_incr_dir/$as_mkdir_dir
+      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
+    ;;
+  esac
+done; }
+
+    ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
+    # A "../" for each directory in $ac_dir_suffix.
+    ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
+  else
+    ac_dir_suffix= ac_dots=
+  fi
+
+  case $srcdir in
+  .)  ac_srcdir=.
+      if test -z "$ac_dots"; then
+         ac_top_srcdir=.
+      else
+         ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
+      fi ;;
+  [\\/]* | ?:[\\/]* )
+      ac_srcdir=$srcdir$ac_dir_suffix;
+      ac_top_srcdir=$srcdir ;;
+  *) # Relative path.
+    ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_dots$srcdir ;;
+  esac
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_dots$INSTALL ;;
+  esac
+
+  if test x"$ac_file" != x-; then
+    { echo "$as_me:16564: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    rm -f "$ac_file"
+  fi
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated automatically by config.status.  */
+  configure_input="Generated automatically from `echo $ac_file_in |
+                                                 sed 's,.*/,,'` by configure."
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:16582: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:16595: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+EOF
+cat >>$CONFIG_STATUS <<EOF
+  sed "$ac_vpsub
+$extrasub
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+  rm -f $tmp/stdin
+  if test x"$ac_file" != x-; then
+    mv $tmp/out $ac_file
+  else
+    cat $tmp/out
+    rm -f $tmp/out
+  fi
+
+done
+EOF
+cat >>$CONFIG_STATUS <<\EOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([  ]*\)#\([        ]*define[       ][      ]*\)'
+ac_dB='[       ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_i turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_iA='s,^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_iB='\([     ]\),\1#\2define\3'
+ac_iC=' '
+ac_iD='\4,;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([  ]*\)#\([        ]*\)undef\([    ][      ]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case $ac_file in
+  - | *:- | *:-:* ) # input from stdin
+        cat >$tmp/stdin
+        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+  * )   ac_file_in=$ac_file.in ;;
+  esac
+
+  test x"$ac_file" != x- && { echo "$as_me:16661: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+  # First look for the input files in the build tree, otherwise in the
+  # src tree.
+  ac_file_inputs=`IFS=:
+    for f in $ac_file_in; do
+      case $f in
+      -) echo $tmp/stdin ;;
+      [\\/$]*)
+         # Absolute (can't be DOS-style, as IFS=:)
+         test -f "$f" || { { echo "$as_me:16672: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         echo $f;;
+      *) # Relative
+         if test -f "$f"; then
+           # Build tree
+           echo $f
+         elif test -f "$srcdir/$f"; then
+           # Source tree
+           echo $srcdir/$f
+         else
+           # /dev/null tree
+           { { echo "$as_me:16685: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+   { (exit 1); exit 1; }; }
+         fi;;
+      esac
+    done` || { (exit 1); exit 1; }
+  # Remove the trailing spaces.
+  sed 's/[     ]*$//' $ac_file_inputs >$tmp/in
+
+EOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h.  The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status.  Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\EOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[   ]*#[    ]*define[       ][      ]*\(\([^        (][^    (]*\)([^)]*)\)[         ]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp
+t end
+s,^[   ]*#[    ]*define[       ][      ]*\([^  ][^     ]*\)[   ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+EOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless.  Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+sed 's/ac_d/ac_i/g' conftest.defines >>conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >>conftest.undefs <<\EOF
+s,^[   ]*#[    ]*undef[        ][      ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+EOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo '  if egrep "^[   ]*#[    ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo '  :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+  # Write a limited-size here document to $tmp/defines.sed.
+  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#define' lines.
+  echo '/^[    ]*#[    ]*define/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/defines.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+  rm -f conftest.defines
+  mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo '  fi # egrep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+  # Write a limited-size here document to $tmp/undefs.sed.
+  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+  # Speed up: don't consider the non `#undef'
+  echo '/^[    ]*#[    ]*undef/!b' >>$CONFIG_STATUS
+  # Work around the forget-to-reset-the-flag bug.
+  echo 't clr' >>$CONFIG_STATUS
+  echo ': clr' >>$CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+  echo 'CEOF
+  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+  rm -f $tmp/in
+  mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+  rm -f conftest.undefs
+  mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\EOF
+  # Let's still pretend it is `configure' which instantiates (i.e., don't
+  # use $as_me), people would be surprised to read:
+  #    /* config.h.  Generated automatically by config.status.  */
+  if test x"$ac_file" = x-; then
+    echo "/* Generated automatically by configure.  */" >$tmp/config.h
+  else
+    echo "/* $ac_file.  Generated automatically by configure.  */" >$tmp/config.h
+  fi
+  cat $tmp/in >>$tmp/config.h
+  rm -f $tmp/in
+  if test x"$ac_file" != x-; then
+    if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
+      { echo "$as_me:16803: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+         X"$ac_file" : 'X\(//\)[^/]' \| \
+         X"$ac_file" : 'X\(//\)$' \| \
+         X"$ac_file" : 'X\(/\)' \| \
+         .     : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+         /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+         /^X\(\/\/\)$/{ s//\1/; q; }
+         /^X\(\/\).*/{ s//\1/; q; }
+         s/.*/./; q'`
+      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+        { case "$ac_dir" in
+  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
+  *)                      as_incr_dir=.;;
+esac
+as_dummy="$ac_dir"
+for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
+  case $as_mkdir_dir in
+    # Skip DOS drivespec
+    ?:) as_incr_dir=$as_mkdir_dir ;;
+    *)
+      as_incr_dir=$as_incr_dir/$as_mkdir_dir
+      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
+    ;;
+  esac
+done; }
+
+      fi
+      rm -f $ac_file
+      mv $tmp/config.h $ac_file
+    fi
+  else
+    cat $tmp/config.h
+    rm -f $tmp/config.h
+  fi
+done
+EOF
+
+cat >>$CONFIG_STATUS <<\EOF
+
+{ (exit 0); exit 0; }
+EOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || { (exit 1); exit 1; }
+fi
+
diff --git a/configure.in b/configure.in
new file mode 100644 (file)
index 0000000..0610431
--- /dev/null
@@ -0,0 +1,1000 @@
+dnl $XTermId: configure.in,v 1.267 2010/11/09 01:00:48 tom Exp $
+dnl
+dnl -----------------------------------------------------------------------------
+dnl this file is part of xterm
+dnl
+dnl Copyright 1997-2009,2010 by Thomas E. Dickey
+dnl 
+dnl                         All Rights Reserved
+dnl 
+dnl Permission is hereby granted, free of charge, to any person obtaining a
+dnl copy of this software and associated documentation files (the
+dnl "Software"), to deal in the Software without restriction, including
+dnl without limitation the rights to use, copy, modify, merge, publish,
+dnl distribute, sublicense, and/or sell copies of the Software, and to
+dnl permit persons to whom the Software is furnished to do so, subject to
+dnl the following conditions:
+dnl 
+dnl The above copyright notice and this permission notice shall be included
+dnl in all copies or substantial portions of the Software.
+dnl 
+dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+dnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+dnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+dnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+dnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+dnl 
+dnl Except as contained in this notice, the name(s) of the above copyright
+dnl holders shall not be used in advertising or otherwise to promote the
+dnl sale, use or other dealings in this Software without prior written
+dnl authorization.
+dnl ---------------------------------------------------------------------------
+dnl Process this file with autoconf to produce a configure script.
+dnl
+AC_PREREQ(2.13.20030927)
+AC_INIT(charproc.c)
+AC_CONFIG_HEADER(xtermcfg.h:xtermcfg.hin)
+CF_CHECK_CACHE
+
+###    checks for alternative programs
+
+dnl Only add to this case statement when a system has a compiler that is not
+dnl detected by AC_PROG_CC.
+case "$host_os" in
+openedition)   : ${CFLAGS="-O2 -Wc,dll -Wl,EDIT=NO"}
+               : ${CPPFLAGS="-D_ALL_SOURCE"}
+               : ${LIBS="/usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x"}
+               : ${CC=c89};;
+darwin*)
+               : ${LDFLAGS}="${LDFLAGS} -Wl,-bind_at_load";;
+esac
+
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_AWK
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_ARG_PROGRAM
+AC_CHECK_PROGS(LINT, tdlint lint alint)
+
+###    checks for UNIX variants that set C preprocessor variables
+AC_AIX
+AC_ISC_POSIX
+
+###    checks for compiler characteristics
+CF_ANSI_CC_CHECK
+AC_C_CONST
+CF_PROG_EXT
+CF_XOPEN_SOURCE
+CF_SIGWINCH
+
+###    checks for header files
+AC_CHECK_HEADERS( \
+ncurses/term.h \
+stdlib.h \
+sys/ttydefaults.h \
+term.h \
+termios.h \
+unistd.h \
+wchar.h \
+)
+AC_HEADER_TIME
+AM_LANGINFO_CODESET
+
+###    checks for typedefs
+CF_SIG_ATOMIC_T
+CF_SIZE_T
+AC_CHECK_TYPE(time_t, long)
+AC_TYPE_MODE_T
+AC_TYPE_PID_T
+AC_TYPE_UID_T
+AC_TYPE_OFF_T
+
+###    checks for library functions
+AC_CHECK_FUNCS( \
+       bcopy \
+       gethostname \
+       getlogin \
+       memmove \
+       putenv \
+       sched_yield \
+       strerror \
+       strftime \
+       tcgetattr \
+       waitpid \
+       wcswidth \
+       wcwidth )
+CF_FUNC_MEMMOVE
+CF_UTMP
+CF_STRUCT_LASTLOG
+CF_POSIX_SAVED_IDS
+
+CF_HELP_MESSAGE(Compile/Install Options:)
+CF_FUNC_TGETENT
+
+AC_MSG_CHECKING(for directory to install resource files)
+CF_WITH_PATH(app-defaults,
+       [  --with-app-defaults=DIR directory in which to install resource files],
+       [appsdir],[EPREFIX/lib/X11/app-defaults],
+       ['\$(exec_prefix)/lib/X11/app-defaults'])
+AC_MSG_RESULT($appsdir)
+AC_SUBST(appsdir)
+
+no_appsdir=
+test "$appsdir" = no && no_appsdir="#"
+AC_SUBST(no_appsdir)
+
+AC_MSG_CHECKING(for directory to install icons)
+CF_WITH_PATH(icondir,
+       [  --with-icondir=DIR      directory in which to install icons],
+       [icondir],[EPREFIX/share/pixmaps],
+       ['\$(exec_prefix)/share/pixmaps'])
+AC_MSG_RESULT($icondir)
+AC_SUBST(icondir)
+
+no_icondir=
+test "$icondir" = no && no_icondir="#"
+AC_SUBST(no_icondir)
+
+# Comment-out the install-desktop rule if the desktop-utils are not found.
+AC_MSG_CHECKING(if you want to install desktop files)
+CF_ARG_OPTION(desktop,
+       [  --disable-desktop       disable install of xterm desktop files],
+       [enable_desktop=$enableval],
+       [enable_desktop=$enableval],yes)
+AC_MSG_RESULT($enable_desktop)
+
+desktop_utils=
+if test "$enable_desktop" = yes ; then
+AC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
+fi
+
+test "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
+AC_SUBST(DESKTOP_FLAGS)
+
+# inherit SINSTALL_OPTS from environment to allow packager to customize it.
+
+AC_MSG_CHECKING(for install-permissions reference)
+AC_ARG_WITH(reference,
+       [  --with-reference=XXX    program to use as permissions-reference],
+       [with_reference=$withval],
+       [with_reference=xterm])
+AC_MSG_RESULT($with_reference)
+
+with_full_paths=yes
+CF_PATH_PROG(XTERM_PATH,$with_reference)
+
+# If any of --program-prefix, --program-suffix or --program-transform-name is
+# given, accept an option tell the makefile to create a symbolic link, e.g.,
+# to "xterm" on install.
+XTERM_SYMLINK=NONE
+AC_SUBST(XTERM_SYMLINK)
+if test "$program_transform_name" != "'s,,,'" ; then
+cf_name=`echo "$program_transform_name" | sed -e '[s,\\$\\$,$,g]'`
+cf_name=`echo xterm |sed -e "$cf_name"`
+AC_MSG_CHECKING(for symbolic link to create to $cf_name)
+AC_ARG_WITH(xterm-symlink,
+       [  --with-xterm-symlink=XXX make symbolic link to installed xterm],
+       [with_symlink=$withval],
+       [with_symlink=xterm])
+AC_MSG_RESULT($with_symlink)
+test "$with_symlink" = yes && with_symlink=xterm
+test -n "$with_symlink" && \
+       test "$with_symlink" != no && \
+       test "$with_symlink" != $cf_name && \
+       XTERM_SYMLINK="$with_symlink"
+fi
+
+AC_MSG_CHECKING(if you want to disable setuid)
+CF_ARG_DISABLE(setuid,
+       [  --disable-setuid        disable setuid in xterm, do not install setuid/setgid],
+       [disable_setuid=yes],
+       [disable_setuid=no],
+       no)
+AC_MSG_RESULT($disable_setuid)
+
+AC_MSG_CHECKING(if you want to disable setgid)
+CF_ARG_DISABLE(setgid,
+       [  --disable-setgid        disable setgid in xterm, do not install setuid/setgid],
+       [disable_setgid=yes],
+       [disable_setgid=no],
+       no)
+AC_MSG_RESULT($disable_setgid)
+
+AC_MSG_CHECKING(if you want to run xterm setuid to a given user)
+AC_ARG_WITH(setuid,
+       [  --with-setuid=XXX       use the given setuid user],
+       [use_given_setuid=$withval],
+       [use_given_setuid=no])
+AC_MSG_RESULT($use_given_setuid)
+
+if test "$use_given_setuid" != no ; then
+       if test "$use_given_setuid" = yes ; then
+               cf_cv_given_setuid=root
+       else
+               cf_cv_given_setuid=$use_given_setuid
+       fi
+       SINSTALL_OPTS="$SINSTALL_OPTS u+s -u $cf_cv_given_setuid"
+fi
+
+AC_MSG_CHECKING(if you want to run xterm setgid to match utmp/utmpx file)
+AC_ARG_WITH(utmp-setgid,
+       [  --with-utmp-setgid=XXX  use setgid to match utmp/utmpx file],
+       [use_utmp_setgid=$withval],
+       [use_utmp_setgid=no])
+AC_MSG_RESULT($use_utmp_setgid)
+
+if test "$use_utmp_setgid" != no ; then
+       if test "$use_utmp_setgid" = yes ; then
+               CF_UTMP_GROUP
+       else
+               cf_cv_utmp_group=$use_utmp_setgid
+       fi
+       if test "$cf_cv_posix_saved_ids" != yes ; then
+               AC_MSG_ERROR(Your system does not support POSIX saved-ids)
+       fi
+       AC_DEFINE(USE_UTMP_SETGID)
+       SINSTALL_OPTS="$SINSTALL_OPTS g+s -g $cf_cv_utmp_group"
+fi
+
+AC_SUBST(SINSTALL_OPTS)
+
+AC_MSG_CHECKING(if you want to link with utempter)
+AC_ARG_WITH(utempter,
+       [  --with-utempter         use utempter library for access to utmp],
+       [use_utempter=$withval],
+       [use_utempter=no])
+AC_MSG_RESULT($use_utempter)
+
+if test "$use_utempter" = yes ; then
+       CF_UTEMPTER
+       test "$cf_cv_have_utempter" != yes && use_utempter=no
+else
+       use_utempter=no
+fi
+
+# Some configurations permit (or require) either setuid or setgid mode.
+# Let the user decide.
+if test "$use_utempter" = yes ; then
+       if test "${enable_setuid+set}" != set ; then
+               disable_setuid=yes
+               CF_VERBOSE([No --disable-setuid option given, force to yes])
+       fi
+fi
+
+###    checks for external data
+CF_ERRNO
+CF_TTY_GROUP
+
+###    checks for system services and user specified options
+
+CF_POSIX_WAIT
+CF_SYSV
+CF_SVR4
+CF_X_TOOLKIT
+
+AC_CHECK_HEADERS( \
+       X11/DECkeysym.h \
+       X11/Sunkeysym.h \
+       X11/XF86keysym.h \
+       X11/XKBlib.h \
+       X11/Xpoll.h \
+       X11/extensions/XKB.h \
+       )
+
+CF_X_ATHENA
+CF_TYPE_FD_MASK
+CF_TERMIO_C_ISPEED
+
+LIBS="$LIBS $X_EXTRA_LIBS"
+
+# Check for openpty() in -lutil if the UNIX98-style pty functions are not
+# available. E.g. for GNU libc 2.0.
+case $host_os in #(vi
+freebsd*|netbsd*|dragonfly*) # 2004/8/15 - revisit this if/when grantpt is known to work.
+       AC_CHECK_LIB(util,openpty)
+       ;;
+*)
+       AC_CHECK_FUNCS(grantpt, [], AC_CHECK_LIB(util,openpty))
+       ;;
+esac
+
+AC_CHECK_FUNCS(XkbQueryExtension)
+
+CF_XKB_BELL_EXT
+
+AC_CHECK_FUNCS(Xutf8LookupString, [],[
+       EXTRAHDRS="$EXTRAHDRS xutf8.h"
+       EXTRASRCS="$EXTRASRCS xutf8.c"
+       EXTRAOBJS="$EXTRAOBJS xutf8.o"
+])
+
+CF_WITH_IMAKE_CFLAGS($(MAIN_DEFINES) $(VENDORMANDEFS))
+
+CF_HELP_MESSAGE(Terminal Configuration:)
+
+AC_MSG_CHECKING(for default terminal-id)
+AC_ARG_WITH(terminal-id,
+       [  --with-terminal-id=V    set default decTerminalID (default: vt100)],
+       [default_termid=$withval],
+       [default_termid=vt100])
+AC_MSG_RESULT($default_termid)
+case $default_termid in
+vt*)   default_termid=`echo $default_termid | sed -e 's/^..//'`
+       ;;
+esac
+AC_DEFINE_UNQUOTED(DFT_DECID,"$default_termid")
+
+AC_MSG_CHECKING(for default terminal-type)
+AC_ARG_WITH(terminal-type,
+       [  --with-terminal-type=T  set default $TERM (default: xterm)],
+       [default_TERM=$withval],
+       [default_TERM=xterm])
+AC_MSG_RESULT($default_TERM)
+AC_DEFINE_UNQUOTED(DFT_TERMTYPE,"$default_TERM")
+
+AC_CHECK_PROG(cf_tic_prog,tic,yes,no)
+if test "$cf_tic_prog" = yes ; then
+       AC_MSG_CHECKING(for private terminfo-directory)
+       AC_ARG_WITH(own-terminfo,
+               [  --with-own-terminfo=P   set default $TERMINFO (default: from environment)],
+               [TERMINFO_DIR=$withval],
+               [TERMINFO_DIR=${TERMINFO-none}])
+       AC_MSG_RESULT($TERMINFO_DIR)
+       if test "$TERMINFO_DIR" = yes ; then
+               AC_MSG_WARN(no value given)
+       elif test "$TERMINFO_DIR" != none ; then
+               if test -d $TERMINFO_DIR ; then
+                       AC_DEFINE_UNQUOTED(OWN_TERMINFO_DIR,"$TERMINFO_DIR")
+               else
+                       AC_MSG_WARN(not a directory)
+               fi
+       elif test "$prefix" != NONE ; then
+               TERMINFO_DIR='${prefix}/lib/terminfo'
+       elif test -d /usr/lib/terminfo ; then
+               TERMINFO_DIR=/usr/lib/terminfo
+       else
+               TERMINFO_DIR=
+       fi
+       SET_TERMINFO=
+       if test -n "$TERMINFO_DIR" ; then
+               TERMINFO_DIR='$(DESTDIR)'$TERMINFO_DIR
+               SET_TERMINFO='TERMINFO=$(TERMINFO_DIR)'
+       fi
+       no_ticprog=
+else
+       no_ticprog="#"
+       TERMINFO_DIR=
+       SET_TERMINFO=
+fi
+AC_SUBST(no_ticprog)
+AC_SUBST(TERMINFO_DIR)
+AC_SUBST(SET_TERMINFO)
+
+###############################################################################
+CF_HELP_MESSAGE(Optional Features:)
+
+AC_MSG_CHECKING(if you want active-icons)
+CF_ARG_DISABLE(active-icon,
+       [  --disable-active-icon   disable X11R6.3 active-icon feature],
+       [enable_active_icon=no],
+       [enable_active_icon=yes])
+AC_MSG_RESULT($enable_active_icon)
+if test "$enable_active_icon" = no ; then
+       AC_DEFINE(NO_ACTIVE_ICON)
+fi
+
+AC_MSG_CHECKING(if you want ANSI color)
+CF_ARG_DISABLE(ansi-color,
+       [  --disable-ansi-color    disable ANSI color],
+       [enable_ansi_color=no],
+       [enable_ansi_color=yes])
+AC_MSG_RESULT($enable_ansi_color)
+test "$enable_ansi_color" = no && AC_DEFINE(OPT_ISO_COLORS,0)
+
+if test "$enable_ansi_color" = yes ; then
+
+       AC_MSG_CHECKING(if you want 16 colors like aixterm)
+       CF_ARG_DISABLE(16-color,
+               [  --disable-16-color      disable 16-color support],
+               [enable_16_color=no],
+               [enable_16_color=yes])
+       AC_MSG_RESULT($enable_16_color)
+       test "$enable_16_color" = no && AC_DEFINE(OPT_AIX_COLORS,0)
+
+       AC_MSG_CHECKING(if you want 256 colors)
+       CF_ARG_ENABLE(256-color,
+               [  --enable-256-color      enable 256-color support],
+               [enable_256_color=yes],
+               [enable_256_color=no])
+       AC_MSG_RESULT($enable_256_color)
+       if test "$enable_256_color" = yes ; then
+               CHARPROC_DEPS="$CHARPROC_DEPS 256colres.h"
+               EXTRAHDRS="$EXTRAHDRS 256colres.h"
+               AC_DEFINE(OPT_256_COLORS,1)
+       else
+       AC_MSG_CHECKING(if you want 88 colors)
+       CF_ARG_ENABLE(88-color,
+               [  --enable-88-color       enable 88-color support],
+               [enable_88_color=yes],
+               [enable_88_color=no])
+       AC_MSG_RESULT($enable_88_color)
+       if test "$enable_88_color" = yes ; then
+               CHARPROC_DEPS="$CHARPROC_DEPS 88colres.h"
+               EXTRAHDRS="$EXTRAHDRS 88colres.h"
+               AC_DEFINE(OPT_88_COLORS,1)
+       fi
+       fi
+
+fi
+
+AC_MSG_CHECKING(if you want blinking cursor)
+CF_ARG_DISABLE(blink-cursor,
+       [  --disable-blink-cursor  disable support for blinking cursor],
+       [enable_blink_curs=no],
+       [enable_blink_curs=yes])
+AC_MSG_RESULT($enable_blink_curs)
+test "$enable_blink_curs" = no && AC_DEFINE(OPT_BLINK_CURS,0)
+
+AC_MSG_CHECKING(if you want to ignore Linux's broken palette-strings)
+
+case $host_os in #(vi
+linux*)
+       assume_broken_osc=yes ;; #(vi
+*)
+       assume_broken_osc=no ;;
+esac
+
+CF_ARG_OPTION(broken-osc,
+       [  --enable-broken-osc     allow broken Linux OSC-strings],
+       [enable_broken_osc=$enableval],
+       [enable_broken_osc=$enableval],
+       [$assume_broken_osc])
+AC_MSG_RESULT($enable_broken_osc)
+if test "$enable_broken_osc" = yes ; then
+       AC_DEFINE(OPT_BROKEN_OSC,1)
+else
+       AC_DEFINE(OPT_BROKEN_OSC,0)
+fi
+
+AC_MSG_CHECKING(if you want to allow broken string-terminators)
+CF_ARG_ENABLE(broken-st,
+       [  --disable-broken-st     disallow broken string-terminators],
+       [enable_broken_st=no],
+       [enable_broken_st=yes])
+AC_MSG_RESULT($enable_broken_st)
+test "$enable_broken_st" = no && AC_DEFINE(OPT_BROKEN_ST,0)
+
+AC_MSG_CHECKING(if you want printable 128-159)
+CF_ARG_DISABLE(c1-print,
+       [  --disable-c1-print      disallow -k8 option for printable 128-159],
+       [enable_c1_print=no],
+       [enable_c1_print=yes])
+AC_MSG_RESULT($enable_c1_print)
+test "$enable_c1_print" = no && AC_DEFINE(OPT_C1_PRINT,0)
+
+if test "$enable_ansi_color" = yes ; then
+
+       AC_MSG_CHECKING(if you want bold colors mapped like IBM PC)
+       CF_ARG_DISABLE(bold-color,
+               [  --disable-bold-color    disable PC-style mapping of bold colors],
+               [enable_pc_color=no],
+               [enable_pc_color=yes])
+       AC_MSG_RESULT($enable_pc_color)
+       test "$enable_pc_color" = no && AC_DEFINE(OPT_PC_COLORS,0)
+
+       AC_MSG_CHECKING(if you want separate color-classes)
+       CF_ARG_DISABLE(color-class,
+               [  --disable-color-class   disable separate color class resources],
+               [enable_color_class=no],
+               [enable_color_class=yes])
+       AC_MSG_RESULT($enable_color_class)
+       test "$enable_color_class" = no && AC_DEFINE(OPT_COLOR_CLASS,FALSE)
+
+       AC_MSG_CHECKING(if you want color-mode enabled by default)
+       CF_ARG_DISABLE(color-mode,
+               [  --disable-color-mode    disable default colorMode resource],
+               [default_colormode=no],
+               [default_colormode=yes])
+       AC_MSG_RESULT($default_colormode)
+       test "$default_colormode" = no && AC_DEFINE(DFT_COLORMODE,FALSE)
+
+fi
+
+AC_MSG_CHECKING(if you want support for color highlighting)
+CF_ARG_DISABLE(highlighting,
+       [  --disable-highlighting  disable support for color highlighting],
+       [default_highlight=no],
+       [default_highlight=yes])
+AC_MSG_RESULT($default_highlight)
+test "$default_highlight" = no && AC_DEFINE(OPT_HIGHLIGHT_COLOR,0)
+
+AC_MSG_CHECKING(if you want support for doublesize characters)
+CF_ARG_DISABLE(doublechars,
+       [  --disable-doublechars   disable support for double-size chars],
+       [enable_doublechars=no],
+       [enable_doublechars=yes])
+AC_MSG_RESULT($enable_doublechars)
+test "$enable_doublechars" = no && AC_DEFINE(OPT_DEC_CHRSET,0)
+
+AC_MSG_CHECKING(if you want fallback-support for box characters)
+CF_ARG_DISABLE(boxchars,
+       [  --disable-boxchars      disable fallback-support for box chars],
+       [enable_boxchars=no],
+       [enable_boxchars=yes])
+AC_MSG_RESULT($enable_boxchars)
+test "$enable_boxchars" = no && AC_DEFINE(OPT_BOX_CHARS,0)
+
+AC_MSG_CHECKING(if you want to allow spawning new xterms)
+CF_ARG_ENABLE(exec-xterm,
+       [  --enable-exec-xterm     enable "spawn-new-terminal" action],
+       [enable_exec_xterm=yes],
+       [enable_exec_xterm=no])
+AC_MSG_RESULT($enable_exec_xterm)
+if test "$enable_exec_xterm" = yes ; then
+       CF_PROCFS_CWD
+       if test "$cf_cv_procfs_cwd" = no ; then
+               AC_MSG_WARN(no suitable proc filesystem found)
+       else
+               AC_DEFINE_UNQUOTED(PROCFS_ROOT,"$cf_cv_procfs_cwd")
+               AC_DEFINE(OPT_EXEC_XTERM)
+       fi
+fi
+
+AC_MSG_CHECKING(if you want to use FreeType library)
+CF_ARG_DISABLE(freetype,
+       [  --disable-freetype      disable freetype library-support],
+       [enable_freetype=no],
+       [enable_freetype=yes])
+AC_MSG_RESULT($enable_freetype)
+if test "$enable_freetype" = yes ; then
+       CF_X_FONTCONFIG
+else
+       CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
+fi
+
+AC_MSG_CHECKING(if you want support for HP-style function keys)
+CF_ARG_ENABLE(hp-fkeys,
+       [  --enable-hp-fkeys       enable support for HP-style function keys],
+       [enable_hp_fkeys=yes],
+       [enable_hp_fkeys=no])
+AC_MSG_RESULT($enable_hp_fkeys)
+if test "$enable_hp_fkeys" = yes ; then
+       AC_DEFINE(OPT_HP_FUNC_KEYS,1)
+fi
+
+AC_MSG_CHECKING(if you want support for SCO-style function keys)
+CF_ARG_ENABLE(sco-fkeys,
+       [  --enable-sco-fkeys      enable support for SCO-style function keys],
+       [enable_sco_fkeys=yes],
+       [enable_sco_fkeys=no])
+AC_MSG_RESULT($enable_sco_fkeys)
+if test "$enable_sco_fkeys" = yes ; then
+       AC_DEFINE(OPT_SCO_FUNC_KEYS,1)
+fi
+
+AC_MSG_CHECKING(if you want support for Sun-style function keys)
+CF_ARG_DISABLE(sun-fkeys,
+       [  --disable-sun-fkeys     disable support for Sun-style function keys],
+       [enable_sun_fkeys=no],
+       [enable_sun_fkeys=yes])
+AC_MSG_RESULT($enable_sun_fkeys)
+if test "$enable_sun_fkeys" = no ; then
+       AC_DEFINE(OPT_SUN_FUNC_KEYS,0)
+fi
+
+AC_MSG_CHECKING(if you want saved-lines stored as a FIFO)
+CF_ARG_DISABLE(fifo-lines,
+       [  --disable-fifo-lines    disable FIFO-storage for saved-lines],
+       [enable_fifo_lines=no],
+       [enable_fifo_lines=yes])
+AC_MSG_RESULT($enable_fifo_lines)
+if test "$enable_fifo_lines" = yes ; then
+       AC_DEFINE(OPT_FIFO_LINES,1)
+fi
+
+AC_MSG_CHECKING(if you want support for internationalization)
+CF_ARG_DISABLE(i18n,
+       [  --disable-i18n          disable internationalization],
+       [enable_i18n=no],
+       [enable_i18n=yes])
+AC_MSG_RESULT($enable_i18n)
+if test "$enable_i18n" = no ; then
+       AC_DEFINE(OPT_I18N_SUPPORT,0)
+fi
+
+AC_MSG_CHECKING(if you want support for initial-erase setup)
+CF_ARG_DISABLE(initial-erase,
+       [  --disable-initial-erase disable setup for stty erase],
+       [enable_ie=no],
+       [enable_ie=yes])
+AC_MSG_RESULT($enable_ie)
+if test "$enable_ie" = no ; then
+       AC_DEFINE(OPT_INITIAL_ERASE,0)
+fi
+
+AC_MSG_CHECKING(if you want support for input-method)
+CF_ARG_DISABLE(input-method,
+       [  --disable-input-method  disable input-method],
+       [enable_ximp=no],
+       [enable_ximp=yes])
+AC_MSG_RESULT($enable_ximp)
+CF_INPUT_METHOD
+test "$cf_cv_input_method" = no && enable_ximp=no
+if test "$enable_ximp" = no ; then
+       AC_DEFINE(OPT_INPUT_METHOD,0)
+fi
+
+AC_MSG_CHECKING(if you want support for load-vt-fonts)
+CF_ARG_ENABLE(load-vt-fonts,
+       [  --enable-load-vt-fonts  enable load-vt-fonts() action],
+       [enable_load_vt_fonts=yes],
+       [enable_load_vt_fonts=no])
+AC_MSG_RESULT($enable_load_vt_fonts)
+if test "$enable_load_vt_fonts" = yes ; then
+       AC_DEFINE(OPT_LOAD_VTFONTS,1)
+fi
+
+AC_MSG_CHECKING(if you want support for logging)
+CF_ARG_ENABLE(logging,
+       [  --enable-logging        enable logging],
+       [enable_logging=yes],
+       [enable_logging=no])
+AC_MSG_RESULT($enable_logging)
+if test "$enable_logging" = yes ; then
+       AC_DEFINE(ALLOWLOGGING)
+       AC_MSG_CHECKING(if you want to allow logging via a pipe)
+       CF_ARG_ENABLE(logfile-exec,
+               [  --enable-logfile-exec   enable exec'd logfile filter],
+               [enable_log_exec=yes],
+               [enable_log_exec=no])
+       AC_MSG_RESULT($enable_log_exec)
+       if test "$enable_log_exec" = yes ; then
+               AC_DEFINE(ALLOWLOGFILEEXEC)
+       fi
+fi
+
+AC_MSG_CHECKING(if you want support for iconify/maximize translations)
+CF_ARG_DISABLE(maximize,
+       [  --disable-maximize      disable actions for iconify/deiconify/maximize/restore],
+       [enable_maximize=no],
+       [enable_maximize=yes])
+AC_MSG_RESULT($enable_maximize)
+test "$enable_maximize" = no && AC_DEFINE(OPT_MAXIMIZE,0)
+
+AC_MSG_CHECKING(if you want NumLock to override keyboard tables)
+CF_ARG_DISABLE(num-lock,
+       [  --disable-num-lock      disable NumLock keypad support],
+       [enable_numlock=no],
+       [enable_numlock=yes])
+AC_MSG_RESULT($enable_numlock)
+test "$enable_numlock" = no && AC_DEFINE(OPT_NUM_LOCK,0)
+
+AC_MSG_CHECKING(if you want support for get/set of base64 selection data)
+
+CF_ARG_DISABLE(paste64,
+       [  --disable-paste64       disable get/set base64 selection data],
+       [enable_paste64=no],
+       [enable_paste64=yes])
+AC_MSG_RESULT($enable_paste64)
+if test "$enable_paste64" = yes ; then
+       AC_DEFINE(OPT_PASTE64,1)
+else
+       AC_DEFINE(OPT_PASTE64,0)
+fi
+
+AC_MSG_CHECKING(if you want support for pty-handshaking)
+
+CF_ARG_DISABLE(pty-handshake,
+       [  --disable-pty-handshake disable pty-handshake support],
+       [enable_pty_handshake=no],
+       [enable_pty_handshake=yes])
+AC_MSG_RESULT($enable_pty_handshake)
+if test "$enable_pty_handshake" = yes ; then
+       AC_DEFINE(OPT_PTY_HANDSHAKE,1)
+else
+       AC_DEFINE(OPT_PTY_HANDSHAKE,0)
+fi
+
+AC_MSG_CHECKING(if you want support for mouse in readline applications)
+CF_ARG_ENABLE(readline-mouse,
+       [  --enable-readline-mouse enable support for mouse in readline applications],
+       [enable_readline_mouse=yes],
+       [enable_readline_mouse=no])
+AC_MSG_RESULT($enable_readline_mouse)
+if test "$enable_readline_mouse" = yes ; then
+       AC_DEFINE(OPT_READLINE,1)
+fi
+
+AC_MSG_CHECKING(if you want support for regular-expression selections)
+CF_ARG_DISABLE(regex,
+       [  --disable-regex         disable regular-expression selections],
+       [enable_regex=no],
+       [enable_regex=yes])
+AC_MSG_RESULT($enable_regex)
+if test "$enable_regex" = yes ; then
+       CF_WITH_PCRE
+       if test "$with_pcre" = no ; then
+               CF_REGEX
+               if test "X$cf_cv_regex_hdrs" != "Xregex.h" ; then
+                       AC_MSG_ERROR(Only POSIX or PCRE regular expressions are supported)
+               fi
+       fi
+       AC_DEFINE(OPT_SELECT_REGEX)
+fi
+
+AC_MSG_CHECKING(if you want support for right-scrollbar)
+CF_ARG_DISABLE(rightbar,
+       [  --disable-rightbar      disable right-scrollbar support],
+       [enable_rightbar=no],
+       [enable_rightbar=yes])
+AC_MSG_RESULT($enable_rightbar)
+if test "$enable_rightbar" = yes ; then
+       AC_DEFINE(SCROLLBAR_RIGHT)
+fi
+
+AC_MSG_CHECKING(if you want check for redundant name-change)
+CF_ARG_DISABLE(samename,
+       [  --disable-samename      disable check for redundant name-change],
+       [enable_samename=no],
+       [enable_samename=yes])
+AC_MSG_RESULT($enable_samename)
+test "$enable_samename" = no && AC_DEFINE(OPT_SAME_NAME,0)
+
+AC_MSG_CHECKING(if you want support for session management)
+CF_ARG_DISABLE(session-mgt,
+       [  --disable-session-mgt   disable support for session management],
+       [enable_session_mgt=no],
+       [enable_session_mgt=yes])
+AC_MSG_RESULT($enable_session_mgt)
+test "$enable_session_mgt" = no && AC_DEFINE(OPT_SESSION_MGT,0)
+
+AC_MSG_CHECKING(if you want to use termcap function-keys)
+CF_ARG_DISABLE(tcap-fkeys,
+       [  --disable-tcap-fkeys    disable termcap function-keys support],
+       [enable_tcap_fkeys=no],
+       [enable_tcap_fkeys=yes])
+AC_MSG_RESULT($enable_tcap_fkeys)
+test "$enable_tcap_fkeys" = yes && AC_DEFINE(OPT_TCAP_FKEYS,1)
+
+AC_MSG_CHECKING(if you want to use termcap-query/report)
+CF_ARG_DISABLE(tcap-query,
+       [  --disable-tcap-query    disable compiled-in termcap-query support],
+       [enable_tcap_query=no],
+       [enable_tcap_query=yes])
+AC_MSG_RESULT($enable_tcap_query)
+test "$enable_tcap_query" = yes && AC_DEFINE(OPT_TCAP_QUERY,1)
+
+AC_MSG_CHECKING(if you want support for tek4014)
+CF_ARG_DISABLE(tek4014,
+       [  --disable-tek4014       disable tek4014 emulation],
+       [enable_tek4014=no],
+       [enable_tek4014=yes])
+AC_MSG_RESULT($enable_tek4014)
+if test "$enable_tek4014" = no ; then
+       AC_DEFINE(OPT_TEK4014,0)
+else
+       EXTRAHDRS="$EXTRAHDRS Tekparse.h"
+       EXTRASRCS="$EXTRASRCS TekPrsTbl.c Tekproc.c"
+       EXTRAOBJS="$EXTRAOBJS TekPrsTbl.o Tekproc.o"
+fi
+
+AC_MSG_CHECKING(if you want pulldown menus with a toolbar)
+CF_ARG_ENABLE(toolbar,
+       [  --enable-toolbar        compile-in toolbar for pulldown menus],
+       [enable_toolbar=yes],
+       [enable_toolbar=no])
+AC_MSG_RESULT($enable_toolbar)
+if test "$enable_toolbar" = yes ; then
+       AC_DEFINE(OPT_TOOLBAR,1)
+fi
+
+AC_MSG_CHECKING(if you want VT52 emulation)
+CF_ARG_DISABLE(vt52,
+       [  --disable-vt52          disable VT52 emulation],
+       [enable_vt52=no],
+       [enable_vt52=yes])
+AC_MSG_RESULT($enable_vt52)
+test "$enable_vt52" = no && AC_DEFINE(OPT_VT52_MODE,0)
+
+AC_MSG_CHECKING(if you want to use mini-luit/Latin9 built-in support)
+CF_ARG_ENABLE(mini-luit,
+       [  --enable-mini-luit      enable mini-luit (built-in Latin9 support)],
+       [enable_mini_luit=yes],
+       [enable_mini_luit=no])
+AC_MSG_RESULT($enable_mini_luit)
+if test "$enable_mini_luit" = yes ; then
+       AC_DEFINE(OPT_MINI_LUIT,1)
+fi
+
+AC_MSG_CHECKING(if you want to use luit)
+CF_ARG_ENABLE(luit,
+       [  --enable-luit           enable luit filter (Unicode translation)],
+       [enable_luit=yes],
+       [enable_luit=$enable_mini_luit])
+AC_MSG_RESULT($enable_luit)
+if test "$enable_luit" = yes ; then
+       AC_DEFINE(OPT_LUIT_PROG,1)
+       CF_PATH_PROG(LUIT,xterm-filter,bluit luit)
+fi
+
+AC_MSG_CHECKING(if you want wide-character support)
+CF_ARG_OPTION(wide-chars,
+       [  --enable-wide-chars     enable wide-character support],
+       [enable_wchar=yes],
+       [enable_wchar=$enable_luit],
+       [$enable_luit])
+AC_MSG_RESULT($enable_wchar)
+
+AC_MSG_CHECKING(if you want only 16-bit character support)
+CF_ARG_ENABLE(16bit-chars,
+       [  --enable-16bit-chars    enable 16-bit character support],
+       [enable_16bit_chars=yes],
+       [enable_16bit_chars=no])
+AC_MSG_RESULT($enable_16bit_chars)
+
+if test "$enable_16bit_chars" = yes ; then
+       AC_DEFINE(OPT_WIDER_ICHAR,0)
+       enable_wchar=yes
+fi
+
+if test "$enable_wchar" = yes ; then
+       AC_DEFINE(OPT_WIDE_CHARS,1)
+       EXTRAHDRS="$EXTRAHDRS charclass.h precompose.h wcwidth.h"
+       EXTRASRCS="$EXTRASRCS charclass.c precompose.c wcwidth.c"
+       EXTRAOBJS="$EXTRAOBJS charclass.o precompose.o wcwidth.o"
+fi
+
+AC_MSG_CHECKING(if you want dynamic-abbreviation support)
+CF_ARG_ENABLE(dabbrev,
+       [  --enable-dabbrev        enable dynamic-abbreviation support],
+       [enable_dabbrev=yes],
+       [enable_dabbrev=no])
+AC_MSG_RESULT($enable_dabbrev)
+if test "$enable_dabbrev" = yes ; then
+       AC_DEFINE(OPT_DABBREV,1)
+fi
+
+AC_MSG_CHECKING(if you want DECterm Locator support)
+CF_ARG_ENABLE(dec-locator,
+       [  --enable-dec-locator    enable DECterm Locator support],
+       [enable_dec_locator=yes],
+       [enable_dec_locator=no])
+AC_MSG_RESULT($enable_dec_locator)
+if test "$enable_dec_locator" = yes ; then
+       AC_DEFINE(OPT_DEC_LOCATOR,1)
+fi
+
+AC_MSG_CHECKING(if you want VT420 rectangle support)
+CF_ARG_DISABLE(rectangles,
+       [  --disable-rectangles    disable VT420 rectangle support],
+       [enable_rectangles=no],
+       [enable_rectangles=yes])
+AC_MSG_RESULT($enable_rectangles)
+if test "$enable_rectangles" = yes ; then
+       AC_DEFINE(OPT_DEC_RECTOPS,1)
+fi
+
+AC_MSG_CHECKING(if you want -ziconbeep option)
+CF_ARG_DISABLE(ziconbeep,
+       [  --disable-ziconbeep     disable -ziconbeep option],
+       [enable_ziconbeep=no],
+       [enable_ziconbeep=yes])
+AC_MSG_RESULT($enable_ziconbeep)
+test "$enable_ziconbeep" = no && AC_DEFINE(OPT_ZICONBEEP,0)
+
+###############################################################################
+CF_HELP_MESSAGE(Testing/development Options:)
+
+AC_MSG_CHECKING(if you want debugging traces)
+CF_ARG_ENABLE(trace,
+       [  --enable-trace          test: set to enable debugging traces],
+       [enable_trace=yes],
+       [enable_trace=no])
+AC_MSG_RESULT($enable_trace)
+if test "$enable_trace" = yes ; then
+       AC_DEFINE(OPT_TRACE)
+       EXTRASRCS="$EXTRASRCS trace.c"
+       EXTRAOBJS="$EXTRAOBJS trace.o"
+fi
+
+AC_MSG_CHECKING(if you want to test memory leaks)
+CF_ARG_DISABLE(leaks,
+       [  --disable-leaks         test: set to test memory leaks],
+       [disable_leaks=yes],
+       [disable_leaks=no])
+AC_MSG_RESULT($disable_leaks)
+if test "$disable_leaks" = yes ; then
+       AC_DEFINE(NO_LEAKS)
+fi
+
+CF_DISABLE_ECHO
+
+AC_MSG_CHECKING(if you want magic cookie emulation)
+CF_ARG_ENABLE(xmc-glitch,
+       [  --enable-xmc-glitch     test: enable xmc magic-cookie emulation],
+       [enable_xmc=yes],
+       [enable_xmc=no])
+AC_MSG_RESULT($enable_xmc)
+if test "$enable_xmc" = yes ; then
+       AC_DEFINE(OPT_XMC_GLITCH,1)
+       EXTRASRCS="$EXTRASRCS testxmc.c"
+       EXTRAOBJS="$EXTRAOBJS testxmc.o"
+fi
+
+dnl FIXME - extra test needed to make tcap-fkeys work on HPUX
+AC_CHECK_FUNCS(tigetstr)
+
+dnl only check for ncurses' use_extended_names if really not using termcap
+if test -n "$cf_cv_lib_part_tgetent"; then
+    AC_CHECK_FUNCS(use_extended_names)
+fi
+
+if test -n "$GCC" ; then
+AC_MSG_CHECKING(if you want to turn on gcc warnings)
+CF_ARG_ENABLE(warnings,
+       [  --enable-warnings       test: turn on GCC compiler warnings],
+       [with_warnings=yes],
+       [with_warnings=no])
+AC_MSG_RESULT($with_warnings)
+if test "$with_warnings" = yes
+then
+       CF_GCC_ATTRIBUTES
+       CF_GCC_WARNINGS(Wdeclaration-after-statement Wextra Wno-unknown-pragmas Wswitch-enum)
+fi
+fi
+
+AC_SUBST(EXTRA_CFLAGS)
+AC_SUBST(CHARPROC_DEPS)
+AC_SUBST(EXTRAHDRS)
+AC_SUBST(EXTRASRCS)
+AC_SUBST(EXTRAOBJS)
+
+test "$disable_setuid" = yes && AC_DEFINE(DISABLE_SETUID)
+test "$disable_setgid" = yes && AC_DEFINE(DISABLE_SETGID)
+
+if test $disable_setuid = yes ; then
+       MAY_SETUID="#"
+       NOT_SETUID=
+elif test $disable_setgid = yes ; then
+       MAY_SETUID="#"
+       NOT_SETUID=
+else
+       MAY_SETUID=
+       NOT_SETUID="#"
+fi
+
+AC_SUBST(MAY_SETUID)
+AC_SUBST(NOT_SETUID)
+
+###    remove from CPPFLAGS the optional features we define in xtermcfg.h
+###    or other conflicting symbols that may be defined via imake:
+for cf_def in \
+       __STDC__ \
+       ALLOWLOGGING \
+       ALLOWLOGFILEEXEC \
+       OPT_LUIT_PROG \
+       OPT_WIDE_CHARS \
+       SCROLLBAR_RIGHT \
+       USE_TTY_GROUP \
+       USE_UTEMPTER \
+       XRENDERFONT
+do
+       CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-D$cf_def//`
+done
+
+CF_MAKE_TAGS
+CF_DISABLE_RPATH_HACK
+
+# Force plink.sh to not trim pcre's libraries, which have the same symbol
+# names as the system regexp.
+if test "$with_pcre" != no
+then
+       LIBS=`echo "$LIBS" | sed -e 's/-lpcre/-kpcre/g'`
+fi
+
+###    output Makefile and xtermcfg.h
+AC_OUTPUT(Makefile)
diff --git a/ctlseqs.ms b/ctlseqs.ms
new file mode 100644 (file)
index 0000000..3c564ea
--- /dev/null
@@ -0,0 +1,2289 @@
+.\"#! troff -ms $1             -*- Nroff -*-
+.\" "Xterm Control Sequences" document
+.\" $XTermId: ctlseqs.ms,v 1.237 2011/01/26 09:54:31 tom Exp $
+.\"
+.\"
+.\" Copyright 1996-2010,2011 by Thomas E. Dickey
+.\"
+.\"                         All Rights Reserved
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name(s) of the above copyright
+.\" holders shall not be used in advertising or otherwise to promote the
+.\" sale, use or other dealings in this Software without prior written
+.\" authorization.
+.\"
+.\"
+.\" Copyright 1991, 1994 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be
+.\" included in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" X Window System is a trademark of X Consortium, Inc.
+.\"
+.\" Originally written by Edward Moy, University of California,
+.\" Berkeley, edmoy@violet.berkeley.edu, for the X.V10R4 xterm.
+.\" The X Consortium staff has since updated it for X11.
+.\" Updated by Thomas E. Dickey for XFree86 3.2 - XFree86 4.3, and afterward.
+.\"
+.\" Run this file through troff and use the -ms macro package.
+.\"
+.if n .pl 9999v                \" no page breaks in nroff
+.ND
+.\" Start a list of controls
+.de St
+.sp
+.nr PD 0
+.nr PI 1.0i
+.nr VS 16
+..
+.\" End a list of controls
+.de Ed
+.nr PD .3v
+.nr VS 12
+..
+.\" Bulleted paragraph
+.de bP
+.IP \(bu 4
+..
+.\" Normal leading paragraph
+.de lP
+.if n .sp
+.LP
+..
+.\" Normal internal paragraph
+.de sP
+.if n .sp
+.if t .sp 0.5
+..
+.\" Section header
+.de Sh
+.ds RH \\$1
+.br
+.SH
+\\$1
+..
+.\" Subsection header
+.de Ss
+.LP
+.B
+..
+.ds CH \" as nothing
+.ds LH Xterm Control Sequences
+.nr s 6*\n(PS/10
+.ds L \s\nsBEL\s0
+.ds E \s\nsESC\s0
+.ds T \s\nsTAB\s0
+.ds X \s\nsETX\s0
+.ds N \s\nsENQ\s0
+.ds e \s\nsETB\s0
+.ds C \s\nsCAN\s0
+.ds S \s\nsSUB\s0
+.\" space between chars
+.ie t .ds s \|
+.el .ds s " \"
+.nr [W \w'\*L'u
+.nr w \w'\*E'u
+.if \nw>\n([W .nr [W \nw
+.nr w \w'\*T'u
+.if \nw>\n([W .nr [W \nw
+.nr w \w'\*X'u
+.if \nw>\n([W .nr [W \nw
+.nr w \w'\*N'u
+.if \nw>\n([W .nr [W \nw
+.nr w \w'\*e'u
+.if \nw>\n([W .nr [W \nw
+.nr w \w'\*C'u
+.if \nw>\n([W .nr [W \nw
+.nr w \w'\*S'u
+.if \nw>\n([W .nr [W \nw
+.nr [W +\w'\|\|'u
+.de []
+.nr w \w'\\$2'
+.nr H \\n([Wu-\\nwu
+.nr h \\nHu/2u
+.\" do fancy box in troff
+.ie t .ds \\$1 \(br\v'-1p'\(br\v'1p'\h'\\nhu'\\$2\h'\\nHu-\\nhu'\(br\l'-\\n([Wu\(ul'\v'-1p'\(br\l'-\\n([Wu\(rn'\v'1p'\*s
+.el .ds \\$1 \\$2\*s
+..
+.[] Et \v'-1p'\*X\v'1p'
+.[] En \v'-1p'\*N\v'1p'
+.[] Be \v'-1p'\*L\v'1p'
+.[] AP \v'-1p'\s\nsAPC\s0\v'1p'
+.[] Bs \v'-1p'\s\nsBS\s0\v'1p'
+.[] Cs \v'-1p'\s\nsCSI\s0\v'1p'
+.[] S2 \v'-1p'\s\nsSS2\s0\v'1p'
+.[] S3 \v'-1p'\s\nsSS3\s0\v'1p'
+.[] SS \v'-1p'\s\nsSOS\s0\v'1p'
+.[] Eg \v'-1p'\s\nsEPA\s0\v'1p'
+.[] Sg \v'-1p'\s\nsSPA\s0\v'1p'
+.[] Dc \v'-1p'\s\nsDCS\s0\v'1p'
+.[] Ht \v'-1p'\s\nsHTS\s0\v'1p'
+.[] ID \v'-1p'\s\nsIND\s0\v'1p'
+.[] Nl \v'-1p'\s\nsNEL\s0\v'1p'
+.[] Os \v'-1p'\s\nsOSC\s0\v'1p'
+.[] RI \v'-1p'\s\nsRI\s0\v'1p'
+.[] PM \v'-1p'\s\nsPM\s0\v'1p'
+.[] ST \v'-1p'\s\nsST\s0\v'1p'
+.[] Ta \v'-1p'\*T\v'1p'
+.[] Lf \v'-1p'\s\nsLF\s0\v'1p'
+.[] Vt \v'-1p'\s\nsVT\s0\v'1p'
+.[] Ff \v'-1p'\s\nsFF\s0\v'1p'
+.[] Cr \v'-1p'\s\nsCR\s0\v'1p'
+.[] So \v'-1p'\s\nsSO\s0\v'1p'
+.[] Sp \v'-1p'\s\nsSP\s0\v'1p'
+.[] Si \v'-1p'\s\nsSI\s0\v'1p'
+.[] Eb \v'-1p'\*e\v'1p'
+.[] Ca \v'-1p'\*C\v'1p'
+.[] Su \v'-1p'\*S\v'1p'
+.[] Es \v'-1p'\*E\v'1p'
+.[] Fs \v'-1p'\s\nsFS\s0\v'1p'
+.[] Gs \v'-1p'\s\nsGS\s0\v'1p'
+.[] Rs \v'-1p'\s\nsRS\s0\v'1p'
+.[] Us \v'-1p'\s\nsUS\s0\v'1p'
+.[] XX \v'-1p'\s\nsXX\s0\v'1p'
+.[] $ $
+.[] # #
+.[] % %
+.[] (( (
+.[] ) )
+.[] * *
+.[] + +
+.[] , ,
+.[] - -
+.[] . .
+.[] 0 0
+.[] 1 1
+.[] 2 2
+.[] 3 3
+.[] 4 4
+.[] 5 5
+.[] 6 6
+.[] 7 7
+.[] 8 8
+.[] 9 9
+.[] : :
+.[] ; ;
+.[] = =
+.[] / /
+.[] < <
+.[] > >
+.[] ? ?
+.[] @ @
+.[] A A
+.[] cB B
+.[] C C
+.[] D D
+.[] E E
+.[] F F
+.[] G G
+.[] H H
+.[] I I
+.[] J J
+.[] K K
+.[] L L
+.[] M M
+.[] N N
+.[] O O
+.[] P P
+.[] Q Q
+.[] R R
+.[] S S
+.[] T T
+.[] V V
+.[] W W
+.[] XX X
+.[] Y Y
+.[] Z Z
+.[] [[ [
+.[] ]] ]
+.[] bS \\e
+.[] { {
+.[] ] ]
+.[] & &
+.[] ^ ^
+.[] _ _
+.[] qu \&'
+.[] ` \`
+.[] a a
+.[] b b
+.[] c c
+.[] d d
+.[] f f
+.[] g g
+.[] h h
+.[] i i
+.[] j j
+.[] k k
+.[] l l
+.[] m m
+.[] n n
+.[] o o
+.[] p p
+.[] q q
+.[] r r
+.[] cs s
+.[] t t
+.[] u u
+.[] v v
+.[] w w
+.[] x x
+.[] y y
+.[] z z
+.[] | |
+.[] } }
+.[] ! !
+.[] c" \(lq
+.[] c~ ~
+.[] Sc \fIc\fP
+.ds Cc \fIC\fP
+.ds Cb \fIC\v'.3m'\h'-.2m'\s-2b\s0\v'-.3m'\fP
+.ds Cx \fIC\v'.3m'\h'-.2m'\s-2x\s0\v'-.3m'\fP
+.ds Cy \fIC\v'.3m'\h'-.2m'\s-2y\s0\v'-.3m'\fP
+.ds Pb \fIP\v'.3m'\h'-.2m'\s-2b\s0\v'-.3m'\fP
+.ds Pc \fIP\v'.3m'\h'-.2m'\s-2c\s0\v'-.3m'\fP
+.ds Pd \fIP\v'.3m'\h'-.2m'\s-2d\s0\v'-.3m'\fP
+.ds Pe \fIP\v'.3m'\h'-.2m'\s-2e\s0\v'-.3m'\fP
+.ds Pl \fIP\v'.3m'\h'-.2m'\s-2l\s0\v'-.3m'\fP
+.ds Pm \fIP\v'.3m'\h'-.2m'\s-2m\s0\v'-.3m'\fP
+.ds Pn \fIP\v'.3m'\h'-.2m'\s-2n\s0\v'-.3m'\fP
+.ds Pp \fIP\v'.3m'\h'-.2m'\s-2p\s0\v'-.3m'\fP
+.ds Pr \fIP\v'.3m'\h'-.2m'\s-2r\s0\v'-.3m'\fP
+.ds Ps \fIP\v'.3m'\h'-.2m'\s-2s\s0\v'-.3m'\fP
+.ds Pt \fIP\v'.3m'\h'-.2m'\s-2t\s0\v'-.3m'\fP
+.ds Pu \fIP\v'.3m'\h'-.2m'\s-2u\s0\v'-.3m'\fP
+.ds Pv \fIP\v'.3m'\h'-.2m'\s-2v\s0\v'-.3m'\fP
+.ds Ix \fIx\fP
+.ds Iy \fIy\fP
+.ds Iw \fIw\fP
+.ds Ih \fIh\fP
+.ds Ir \fIr\fP
+.ds Ic \fIc\fP
+.ie t .nr LL 6.5i
+.el .nr LL 72m
+.if n .na
+.TL
+Xterm Control Sequences
+.AU
+Edward Moy
+.AI
+University of California, Berkeley
+.sp
+Revised by
+.AU
+Stephen Gildea
+.AI
+X Consortium (1994)
+.AU
+Thomas Dickey
+.AI
+XFree86 Project (1996-2006)
+invisible-island.net (2006-2010)
+.AU
+.
+.am BT                  \" add page numbers after first page
+.ds CF %
+..
+.Sh "Definitions"
+.IP \*(Sc
+The literal character \fIc\fP.
+.IP \*(Cc
+A single (required) character.
+.IP \*(Ps
+A single (usually optional) numeric parameter, composed of one of more digits.
+.IP \*(Pm
+A multiple numeric parameter composed of any number of single numeric
+parameters, separated by \*; character(s).
+Individual values for the parameters are listed with \*(Ps .
+.IP \*(Pt
+A text parameter composed of printable characters.
+.
+.Sh "C1 (8-Bit) Control Characters"
+.LP
+The \fIxterm\fP 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 equivalent:
+.St
+.IP \\*(Es\\*D
+Index (\*(ID is 0x84).
+.IP \\*(Es\\*E
+Next Line (\*(Nl is 0x85).
+.IP \\*(Es\\*H
+Tab Set (\*(Ht is 0x88).
+.IP \\*(Es\\*M
+Reverse Index (\*(RI is 0x8d).
+.IP \\*(Es\\*N
+Single Shift Select of G2 Character Set (\*(S2 is 0x8e).  This affects next character only.
+.IP \\*(Es\\*O
+Single Shift Select of G3 Character Set (\*(S3 is 0x8f).  This affects next character only.
+.IP \\*(Es\\*P
+Device Control String (\*(Dc is 0x90).
+.IP \\*(Es\\*V
+Start of Guarded Area (\*(Sg is 0x96).
+.IP \\*(Es\\*W
+End of Guarded Area (\*(Eg is 0x97).
+.IP \\*(Es\\*(XX
+Start of String (\*(SS is 0x98).
+.IP \\*(Es\\*Z
+Return Terminal ID (DECID is 0x9a).
+Obsolete form of \*(Cs\*c (DA).
+.IP \\*(Es\\*([[
+Control Sequence Introducer (\*(Cs is 0x9b).
+.IP \\*(Es\\*(bS
+String Terminator (\*(ST is 0x9c).
+.IP \\*(Es\\*(]]
+Operating System Command (\*(Os is 0x9d).
+.IP \\*(Es\\*^
+Privacy Message (\*(PM is 0x9e).
+.IP \\*(Es\\*_
+Application Program Command (\*(AP is 0x9f).
+.Ed
+.sp
+.LP
+These control characters are used in the vtXXX emulation.
+.
+.Sh "VT100 Mode"
+.LP
+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 \fIaixterm\fP color controls.
+The only VT102 feature not supported is auto-repeat,
+since the only way X provides for this will affect all windows.
+There are additional control sequences to provide
+\fIxterm-\fPdependent 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
+discussion of character sets.
+.
+.St
+.\"
+.Ss
+Single-character functions
+.\"
+.IP \\*(Be
+Bell (Ctrl-G).
+.
+.IP \\*(Bs
+Backspace (Ctrl-H).
+.
+.IP \\*(Cr
+Carriage Return (Ctrl-M).
+.
+.IP \\*(En
+Return Terminal Status (Ctrl-E).
+Default response is an empty string, but may be overridden
+by a resource \fBanswerbackString\fP.
+.
+.IP \\*(Ff
+Form Feed or New Page (NP).  Ctrl-L is treated the same as LF.
+.
+.IP \\*(Lf
+Line Feed or New Line (NL).  (LF is Ctrl-J).
+.
+.IP \\*(Si
+Shift In (Ctrl-O) \(-> Switch to Standard Character Set.  This invokes the
+G0 character set (the default).
+.
+.IP \\*(So
+Shift Out (Ctrl-N) \(-> Switch to Alternate Character Set.  This invokes the
+G1 character set.
+.
+.IP \\*(Sp
+Space.
+.
+.IP \\*(Ta
+Horizontal Tab (HT) (Ctrl-I).
+.
+.IP \\*(Vt
+Vertical Tab (Ctrl-K).  This is treated the same as LF.
+.Ed
+.\"
+.\"
+.\"
+.St
+.Ss
+Controls beginning with ESC
+.LP
+This excludes controls where ESC is part of a 7-bit equivalent to 8-bit C1 controls, ordered by the final character(s).
+.\"
+.IP \\*(Es\\*(Sp\\*F
+7-bit controls (S7C1T).
+.
+.IP \\*(Es\\*(Sp\\*G
+8-bit controls (S8C1T).
+.
+.IP \\*(Es\\*(Sp\\*L
+Set ANSI conformance level 1 (dpANS X3.134.1).
+.
+.IP \\*(Es\\*(Sp\\*M
+Set ANSI conformance level 2 (dpANS X3.134.1).
+.
+.IP \\*(Es\\*(Sp\\*N
+Set ANSI conformance level 3 (dpANS X3.134.1).
+.
+.IP \\*(Es\\*#\\*3
+DEC double-height line, top half (DECDHL).
+.
+.IP \\*(Es\\*#\\*4
+DEC double-height line, bottom half (DECDHL).
+.
+.IP \\*(Es\\*#\\*5
+DEC single-width line (DECSWL).
+.
+.IP \\*(Es\\*#\\*6
+DEC double-width line (DECDWL).
+.
+.IP \\*(Es\\*#\\*8
+DEC Screen Alignment Test (DECALN).
+.
+.IP \\*(Es\\*%\\*@
+Select default character set.  That is ISO 8859-1 (ISO 2022).
+.
+.IP \\*(Es\\*%\\*G
+Select UTF-8 character set (ISO 2022).
+.
+.IP \\*(Es\\*(((\\*(Cc
+Designate G0 Character Set (ISO 2022, VT100).
+.br
+Final character \*(Cc for designating 94-character sets.
+In this list, \*0, \*A and \*(cB apply to VT100 and up, the remainder to VT220 and up:
+  \*(Cc = \*0 \(-> DEC Special Character and Line Drawing Set.
+  \*(Cc = \*A \(-> United Kingdom (UK).
+  \*(Cc = \*(cB \(-> United States (USASCII).
+  \*(Cc = \*4 \(-> Dutch.
+  \*(Cc = \*C or \*5 \(-> Finnish.
+  \*(Cc = \*R \(-> French.
+  \*(Cc = \*Q \(-> French Canadian.
+  \*(Cc = \*K \(-> German.
+  \*(Cc = \*Y \(-> Italian.
+  \*(Cc = \*E or \*6 \(-> Norwegian/Danish.
+  \*(Cc = \*Z \(-> Spanish.
+  \*(Cc = \*H or \*7 \(-> Swedish.
+  \*(Cc = \*= \(-> Swiss.
+.\" VT3xx and VT5xx (see vttest) add more selections, not implemented here.
+.IP \\*(Es\\*)\\*(Cc
+Designate G1 Character Set (ISO 2022, VT100).
+.br
+The same character sets apply as for \*(Es\*(((\*(Cc.
+.
+.IP \\*(Es\\**\\*(Cc
+Designate G2 Character Set (ISO 2022, VT220).
+.br
+The same character sets apply as for \*(Es\*(((\*(Cc.
+.
+.IP \\*(Es\\*+\\*(Cc
+Designate G3 Character Set (ISO 2022, VT220).
+.br
+The same character sets apply as for \*(Es\*(((\*(Cc.
+.
+.IP \\*(Es\\*-\\*(Cc
+Designate G1 Character Set (VT300).
+.br
+The same character sets apply as for \*(Es\*(((\*(Cc.
+.
+.IP \\*(Es\\*.\\*(Cc
+Designate G2 Character Set (VT300).
+.br
+The same character sets apply as for \*(Es\*(((\*(Cc.
+.
+.IP \\*(Es\\*/\\*(Cc
+Designate G3 Character Set (VT300).
+.br
+These work for 96-character sets only.
+  \*(Cc = \*A \(-> ISO Latin-1 Supplemental.
+.\" VT5xx would implement these:
+.\"  \*(Cc = \*F \(-> ISO Greek Supplemental
+.\"  \*(Cc = \*H \(-> ISO Hebrew Supplemental
+.\"  \*(Cc = \*M \(-> ISO Latin-5 Supplemental
+.\"  \*(Cc = \*L \(-> ISO Latin-Cyrillic
+.
+.IP \\*(Es\\*7
+Save Cursor (DECSC).
+.
+.IP \\*(Es\\*8
+Restore Cursor (DECRC).
+.
+.IP \\*(Es\\*=
+Application Keypad (DECPAM).
+.
+.IP \\*(Es\\*>
+Normal Keypad (DECPNM).
+.
+.IP \\*(Es\\*F
+Cursor to lower left corner of screen.  This is
+enabled by the \fBhpLowerleftBugCompat\fP resource.
+.
+.IP \\*(Es\\*c
+Full Reset (RIS).
+.
+.IP \\*(Es\\*l
+Memory Lock (per HP terminals).
+Locks memory above the cursor.
+.
+.IP \\*(Es\\*m
+Memory Unlock (per HP terminals).
+.
+.IP \\*(Es\\*n
+Invoke the G2 Character Set as GL (LS2).
+.
+.IP \\*(Es\\*o
+Invoke the G3 Character Set as GL (LS3).
+.
+.IP \\*(Es\\*|
+Invoke the G3 Character Set as GR (LS3R).
+.
+.IP \\*(Es\\*}
+Invoke the G2 Character Set as GR (LS2R).
+.
+.IP \\*(Es\\*(c~
+Invoke the G1 Character Set as GR (LS1R).
+.Ed
+.
+.St
+.Ss
+Application Program-Control functions
+.IP \\*(AP\\*(Pt\\*s\\*(ST
+None.  \fIxterm\fP implements no \*(AP functions; \*(Pt is ignored.
+\*(Pt need not be printable characters.
+.Ed
+.
+.St
+.Ss
+Device-Control functions
+.IP \\*(Dc\\*(Ps\\*;\\*(Ps\\*|\\*(Pt\\*s\\*(ST
+User-Defined Keys (DECUDK).
+The first parameter:
+  \*(Ps = \*0 \(-> Clear all UDK definitions before starting (default).
+  \*(Ps = \*1 \(-> Erase Below (default).
+.br
+The second parameter:
+  \*(Ps = \*0 \(<- Lock the keys (default).
+  \*(Ps = \*1 \(<- Do not lock.
+.br
+The third parameter is a ';'-separated list of strings denoting
+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).
+.
+.IP \\*(Dc\\*$\\*q\\*(Pt\\*s\\*(ST
+Request Status String (DECRQSS).
+The string following the "q" is one of the following:
+  \*(c"\*q     \(-> DECSCA
+  \*(c"\*p     \(-> DECSCL
+  \*r          \(-> DECSTBM
+  \*m          \(-> SGR
+.br
+\fIxterm\fP responds with
+\*(Dc\*1\*$\*r\*(Pt\*s\*(ST
+for valid requests, replacing the \*(Pt with the corresponding \*(Cs
+string,
+or
+\*(Dc\*0\*$\*r\*(Pt\*s\*(ST
+for invalid requests.
+.
+.IP \\*(Dc\\*+\\*p\\*(Pt\\*s\\*(ST
+Set Termcap/Terminfo Data (xterm, experimental).
+The string following the "p" is a name to use for retrieving data from
+the terminal database.
+The data will be used for the "tcap" keyboard
+configuration's function- and special-keys, as well as by the
+Request Termcap/Terminfo String control.
+.
+.IP \\*(Dc\\*+\\*q\\*(Pt\\*s\\*(ST
+Request Termcap/Terminfo String (xterm, experimental).
+The string following the "q" is a list of names
+encoded in hexadecimal (2 digits per character)
+separated by \*;
+which correspond to termcap or terminfo key names.
+.br
+Two special features are also recognized, which are not key names:
+\fICo\fP for termcap colors (or \fIcolors\fP for terminfo colors),
+and
+\fITN\fP for termcap name (or \fIname\fP for terminfo name).
+.br
+\fIxterm\fP responds with
+\*(Dc\*1\*+\*r\*(Pt\*s\*(ST
+for valid requests, adding to \*(Pt an \*=,
+and the value of the corresponding string that xterm would send,
+or
+\*(Dc\*0\*+\*r\*(Pt\*s\*(ST
+for invalid requests.
+The strings are encoded in hexadecimal (2 digits per character).
+.Ed
+.\"
+.St
+.Ss
+Functions using \*(Cs, ordered by the final character(s)
+.IP \\*(Cs\\*(Ps\\*s\\*@
+Insert \*(Ps (Blank) Character(s) (default = 1) (ICH).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*A
+Cursor Up \*(Ps Times (default = 1) (CUU).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*(cB
+Cursor Down \*(Ps Times (default = 1) (CUD).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*C
+Cursor Forward \*(Ps Times (default = 1) (CUF).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*D
+Cursor Backward \*(Ps Times (default = 1) (CUB).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*E
+Cursor Next Line \*(Ps Times (default = 1) (CNL).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*F
+Cursor Preceding Line \*(Ps Times (default = 1) (CPL).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*G
+Cursor Character Absolute  [column] (default = [row,1]) (CHA).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*H
+Cursor Position [row;column] (default = [1,1]) (CUP).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*I
+Cursor Forward Tabulation \*(Ps tab stops (default = 1) (CHT).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*J
+Erase in Display (ED).
+  \*(Ps = \*0 \(-> Erase Below (default).
+  \*(Ps = \*1 \(-> Erase Above.
+  \*(Ps = \*2 \(-> Erase All.
+  \*(Ps = \*3 \(-> Erase Saved Lines (xterm).
+.
+.IP \\*(Cs\\*?\\*(Ps\\*s\\*J
+Erase in Display (DECSED).
+  \*(Ps = \*0 \(-> Selective Erase Below (default).
+  \*(Ps = \*1 \(-> Selective Erase Above.
+  \*(Ps = \*2 \(-> Selective Erase All.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*K
+Erase in Line (EL).
+  \*(Ps = \*0 \(-> Erase to Right (default).
+  \*(Ps = \*1 \(-> Erase to Left.
+  \*(Ps = \*2 \(-> Erase All.
+.
+.IP \\*(Cs\\*?\\*(Ps\\*s\\*K
+Erase in Line (DECSEL).
+  \*(Ps = \*0 \(-> Selective Erase to Right (default).
+  \*(Ps = \*1 \(-> Selective Erase to Left.
+  \*(Ps = \*2 \(-> Selective Erase All.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*L
+Insert \*(Ps Line(s) (default = 1) (IL).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*M
+Delete \*(Ps Line(s) (default = 1) (DL).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*P
+Delete \*(Ps Character(s) (default = 1) (DCH).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*S
+Scroll up \*(Ps lines (default = 1) (SU).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*T
+Scroll down \*(Ps lines (default = 1) (SD).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*T
+Initiate highlight mouse tracking.
+Parameters are [func;startx;starty;firstrow;lastrow].
+See the section \fBMouse Tracking\fP.
+.
+.IP \\*(Cs\\*>\\*(Ps\\*;\\*(Ps\\*s\\*T
+Reset one or more features of the title modes to the default value.
+Normally, "reset" disables the feature.
+It is possible to disable the ability to reset features
+by compiling a different default for the title modes into \fIxterm\fP.
+  \*(Ps = \*0 \(-> Do not set window/icon labels using hexadecimal.
+  \*(Ps = \*1 \(-> Do not query window/icon labels using hexadecimal.
+  \*(Ps = \*2 \(-> Do not set window/icon labels using UTF-8.
+  \*(Ps = \*3 \(-> Do not query window/icon labels using UTF-8.
+(See discussion of "Title Modes").
+.
+.IP \\*(Cs\\*(Ps\\*s\\*(XX
+Erase \*(Ps Character(s) (default = 1) (ECH).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*Z
+Cursor Backward Tabulation \*(Ps tab stops (default = 1) (CBT).
+.
+.IP \\*(Cs\\*(Pm\\*s\\*`
+Character Position Absolute  [column] (default = [row,1]) (HPA).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*b
+Repeat the preceding graphic character \*(Ps times (REP).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*c
+Send Device Attributes (Primary DA).
+  \*(Ps = \*0 or omitted \(-> request attributes from terminal.
+The response depends on the \fBdecTerminalID\fP resource setting.
+  \(-> \*(Cs\*?\*1\*;\*2\*c (``VT100 with Advanced Video Option'')
+  \(-> \*(Cs\*?\*1\*;\*0\*c (``VT101 with No Options'')
+  \(-> \*(Cs\*?\*6\*c (``VT102'')
+  \(->\ \*(Cs\*?\*6\*0\*;\*1\*;\*2\*;\*6\*;\*8\*;\*9\*;\*1\*5\*;\*c (``VT220'')
+.br
+The VT100-style response parameters do not mean anything by themselves.
+VT220 parameters do, telling the host what features the terminal supports:
+  \*(Ps = \*1 \(-> 132-columns.
+  \*(Ps = \*2 \(-> Printer.
+  \*(Ps = \*6 \(-> Selective erase.
+  \*(Ps = \*8 \(-> User-defined keys.
+  \*(Ps = \*9 \(-> National replacement character sets.
+  \*(Ps = \*1\*5 \(-> Technical characters.
+  \*(Ps = \*2\*2 \(-> ANSI color, e.g., VT525.
+  \*(Ps = \*2\*9 \(-> ANSI text locator (i.e., DEC Locator mode).
+.
+.IP \\*(Cs\\*>\\*(Ps\\*s\\*c
+Send Device Attributes (Secondary DA).
+  \*(Ps = \*0 or omitted \(-> request the terminal's identification code.
+The response depends on the \fBdecTerminalID\fP resource setting.
+It should apply only to VT220 and up, but \fIxterm\fP extends this to VT100.
+  \(-> \*(Cs\*s\*>\*(Pp\*s\*;\*(Pv\*s\*;\*(Pc\*s\*c
+.br
+where \*(Pp denotes the terminal type
+  \*(Pp = \*0 \(-> ``VT100''.
+  \*(Pp = \*1 \(-> ``VT220''.
+.br
+and \*(Pv is the firmware version (for \fIxterm\fP, this was originally
+the XFree86 patch number, starting with 95).
+In a DEC terminal, \*(Pc indicates the ROM cartridge
+registration number and is always zero.
+.
+.IP \\*(Cs\\*(Pm\\*s\\*d
+Line Position Absolute  [row] (default = [1,column]) (VPA).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*f
+Horizontal and Vertical Position [row;column] (default = [1,1]) (HVP).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*g
+Tab Clear (TBC).
+  \*(Ps = \*0 \(-> Clear Current Column (default).
+  \*(Ps = \*3 \(-> Clear All.
+.
+.IP \\*(Cs\\*(Pm\\*s\\*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).
+.
+.IP \\*(Cs\\*?\\*(Pm\\*s\\*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 section \fBMouse Tracking\fP.
+  \*(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 \z\(<-\(-> 132 Mode.
+  \*(Ps = \*4\*1 \(-> \fImore\fP(1) fix (see \fBcurses\fP resource).
+  \*(Ps = \*4\*2 \(-> Enable Nation Replacement Character sets (DECNRCM).
+  \*(Ps = \*4\*4 \(-> Turn On Margin Bell.
+  \*(Ps = \*4\*5 \(-> Reverse-wraparound Mode.
+  \*(Ps = \*4\*6 \(-> Start Logging.
+This is normally disabled by a compile-time option.
+  \*(Ps = \*4\*7 \(-> Use Alternate Screen Buffer.  (This may be
+disabled by the \fBtiteInhibit\fP 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 \fBMouse Tracking\fP.
+  \*(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\*0\*5 \(-> Enable Extended Mouse Mode.
+  \*(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 \fBeightBitInput\fP resource).
+  \*(Ps = \*1\*0\*3\*5 \(-> Enable special modifiers for Alt and NumLock keys.
+(This enables the \fBnumLock\fP resource).
+  \*(Ps = \*1\*0\*3\*6 \(-> Send ESC when Meta modifies a key.
+(This enables the \fBmetaSendsEscape\fP 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.
+(This enables the \fBaltSendsEscape\fP resource).
+  \*(Ps = \*1\*0\*4\*0 \(-> Keep selection even if not highlighted.
+(This enables the \fBkeepSelection\fP resource).
+  \*(Ps = \*1\*0\*4\*1 \(-> Use the CLIPBOARD selection.
+(This enables the \fBselectToClipboard\fP resource).
+  \*(Ps = \*1\*0\*4\*2 \(-> Enable Urgency window manager hint when Control-G is received.
+(This enables the \fBbellIsUrgent\fP resource).
+  \*(Ps = \*1\*0\*4\*3 \(-> Enable raising of the window when Control-G is received.
+(enables the \fBpopOnBell\fP resource).
+  \*(Ps = \*1\*0\*4\*7 \(-> Use Alternate Screen Buffer.  (This may be
+disabled by the \fBtiteInhibit\fP resource).
+  \*(Ps = \*1\*0\*4\*8 \(-> Save cursor as in DECSC.  (This may be
+disabled by the \fBtiteInhibit\fP resource).
+  \*(Ps = \*1\*0\*4\*9 \(-> Save cursor as in DECSC
+and use Alternate Screen Buffer, clearing it first.  (This may be
+disabled by the \fBtiteInhibit\fP 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 \(-> 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.
+.
+.IP \\*(Cs\\*(Pm\\*s\\*i
+Media Copy (MC).
+  \*(Ps = \*0 \(-> Print screen (default).
+  \*(Ps = \*4 \(-> Turn off printer controller mode.
+  \*(Ps = \*5 \(-> Turn on printer controller mode.
+.
+.IP \\*(Cs\\*?\\*(Pm\\*s\\*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.
+.
+.IP \\*(Cs\\*(Pm\\*s\\*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).
+.
+.IP \\*(Cs\\*?\\*(Pm\\*s\\*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 \z\(<-\(-> 132 Mode.
+  \*(Ps = \*4\*1 \(-> No \fImore\fP(1) fix (see \fBcurses\fP resource).
+  \*(Ps = \*4\*2 \(-> Disable Nation Replacement Character sets (DECNRCM).
+  \*(Ps = \*4\*4 \(-> Turn Off Margin Bell.
+  \*(Ps = \*4\*5 \(-> No Reverse-wraparound Mode.
+  \*(Ps = \*4\*6 \(-> Stop Logging.
+(This is 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 \fBMouse Tracking\fP.
+  \*(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\*0\*5 \(-> Disable Extended Mouse Mode.
+  \*(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.
+(This disables the \fBeightBitInput\fP resource).
+  \*(Ps = \*1\*0\*3\*5 \(-> Disable special modifiers for Alt and NumLock keys.
+(This disables the \fBnumLock\fP resource).
+  \*(Ps = \*1\*0\*3\*6 \(-> Don't send ESC when Meta modifies a key.
+(This disables the \fBmetaSendsEscape\fP 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.
+(This disables the \fBaltSendsEscape\fP resource).
+  \*(Ps = \*1\*0\*4\*0 \(-> Do not keep selection when not highlighted.
+(This disables the \fBkeepSelection\fP resource).
+  \*(Ps = \*1\*0\*4\*1 \(-> Use the PRIMARY selection.
+(This disables the \fBselectToClipboard\fP resource).
+  \*(Ps = \*1\*0\*4\*2 \(-> Disable Urgency window manager hint when Control-G is received.
+(This disables the \fBbellIsUrgent\fP resource).
+  \*(Ps = \*1\*0\*4\*3 \(-> Disable raising of the window when Control-G is received.
+(This disables the \fBpopOnBell\fP resource).
+  \*(Ps = \*1\*0\*4\*7 \(-> Use Normal Screen Buffer, clearing screen
+first if in the Alternate Screen.  (This may be
+disabled by the \fBtiteInhibit\fP resource).
+  \*(Ps = \*1\*0\*4\*8 \(-> Restore cursor as in DECRC.  (This may be
+disabled by the \fBtiteInhibit\fP resource).
+  \*(Ps = \*1\*0\*4\*9 \(-> Use Normal Screen Buffer and restore cursor
+as in DECRC.  (This may be disabled by the \fBtiteInhibit\fP 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.
+.
+.IP \\*(Cs\\*(Pm\\*s\\*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).
+.sP
+If 16-color support is compiled, the following apply.
+Assume that \fIxterm\fP's resources
+are set so that the ISO color codes are the first 8 of a set of 16.
+Then the \fIaixterm\fP 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.
+.sP
+If \fIxterm\fP is compiled with the 16-color support disabled, it supports
+the following, from \fIrxvt\fP:
+  \*(Ps = \*1\*0\*0 \(-> Set foreground and background color to default.
+.sP
+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.
+.sp
+.
+.IP \\*(Cs\\*>\\*(Ps\\*;\\*(Ps\\*s\\*m
+Set or reset resource-values used by \fIxterm\fP to decide whether to
+construct escape sequences holding information about the modifiers
+pressed with a given key.
+The first parameter identifies 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.
+  \*(Ps = \*1 \(-> modifyCursorKeys.
+  \*(Ps = \*2 \(-> modifyFunctionKeys.
+  \*(Ps = \*4 \(-> modifyOtherKeys.
+.br
+If no parameters are given, all resources are reset to their initial values.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*n
+Device Status Report (DSR).
+  \*(Ps = \*5 \(-> Status Report.  Result (``OK'') is
+.br
+\*(Cs\*0\*n
+  \*(Ps = \*6 \(-> Report Cursor Position (CPR) [row;column].  Result is
+.br
+\*(Cs\*(Ir\*s\*;\*(Ic\*s\*R
+.
+.IP \\*(Cs\\*>\\*(Ps\\*s\\*n
+Disable modifiers which may be enabled via the
+\*(Cs\*>\*(Ps\*;\*(Ps\*s\*m
+sequence.
+This corresponds to a resource value of "-1", which cannot be set with
+the other sequence.
+The parameter identifies the resource to be disabled:
+  \*(Ps = \*1 \(-> modifyCursorKeys.
+  \*(Ps = \*2 \(-> modifyFunctionKeys.
+  \*(Ps = \*4 \(-> modifyOtherKeys.
+.br
+If the parameter is omitted, \fBmodifyFunctionKeys\fP is disabled.
+When \fBmodifyFunctionKeys\fP is disabled, \fIxterm\fP uses the
+modifier keys to make an extended sequence of functions rather
+than adding a parameter to each function key to denote the modifiers.
+.
+.IP \\*(Cs\\*?\\*(Ps\\*s\\*n
+Device Status Report (DSR, DEC-specific).
+  \*(Ps = \*6 \(-> Report Cursor Position (CPR) [row;column] as
+\*(Cs\*?\*(Ir\*s\*;\*(Ic\*s\*R
+(assumes page is zero).
+  \*(Ps = \*1\*5 \(-> Report Printer status as
+\*(Cs\*?\*1\*0\*s\*n (ready).
+or
+\*(Cs\*?\*1\*1\*s\*n (not ready).
+  \*(Ps = \*2\*5 \(-> Report UDK status as
+\*(Cs\*?\*2\*0\*s\*n (unlocked)
+or
+\*(Cs\*?\*2\*1\*s\*n (locked).
+  \*(Ps = \*2\*6 \(-> Report Keyboard status as
+.br
+\*(Cs\*?\*2\*7\*s\*;\*s\*1\*s\*;\*s\*0\*s\*;\*s\*0\*s\*n (North American).
+.br
+The last two parameters apply to VT400 & up, and denote keyboard ready and LK01 respectively.
+  \*(Ps = \*5\*3 \(-> Report Locator status as
+.br
+\*(Cs\*?\*5\*3\*s\*n Locator available, if compiled-in, or
+.br
+\*(Cs\*?\*5\*0\*s\*n No Locator, if not.
+.
+.IP \\*(Cs\\*>\\*(Ps\\*s\\*p
+Set resource value \fIpointerMode\fP.
+This is used by \fIxterm\fP 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, \fIxterm\fP uses the default,
+which is \*1.
+.
+.IP \\*(Cs\\*!\\*p
+Soft terminal reset (DECSTR).
+.
+.IP \\*(Cs\\*(Ps\\*$\\*p
+.br
+Request ANSI mode (DECRQM).
+For VT300 and up, reply is
+.br
+  \*(Cs\*(Ps\*;\*(Pm\*$\*y
+.br
+where \*(Ps is the mode number as in RM,
+and \*(Pm is the mode value:
+.br
+  0 - not recognized
+  1 - set
+  2 - reset
+  3 - permanently set
+  4 - permanently reset
+.
+.IP \\*(Cs\\*?\\*(Ps\\*$\\*p
+Request DEC private mode (DECRQM).
+For VT300 and up, reply is
+.br
+  \*(Cs\*?\*(Ps\*;\*(Pm\*$\*p
+.br
+where \*(Ps is the mode number as in DECSET,
+\*(Pm is the mode value as in the ANSI DECRQM.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*(c"\\*p
+Set conformance level (DECSCL).
+Valid values for the first parameter:
+  \*(Ps = \*6\*1 \(-> VT100.
+  \*(Ps = \*6\*2 \(-> VT200.
+  \*(Ps = \*6\*3 \(-> VT300.
+.br
+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.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*q
+Load LEDs (DECLL).
+  \*(Ps = \*0 \(-> Clear all LEDS (default).
+  \*(Ps = \*1 \(-> Light Num Lock.
+  \*(Ps = \*2 \(-> Light Caps Lock.
+  \*(Ps = \*3 \(-> Light Scroll Lock.
+  \*(Ps = \*2 \*1 \(-> Extinguish Num Lock.
+  \*(Ps = \*2 \*2 \(-> Extinguish Caps Lock.
+  \*(Ps = \*2 \*3 \(-> Extinguish Scroll Lock.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*(Sp\\*q
+Set cursor style (DECSCUSR, VT520).
+  \*(Ps = \*0 \(-> blinking block.
+  \*(Ps = \*1 \(-> blinking block (default).
+  \*(Ps = \*2 \(-> steady block.
+  \*(Ps = \*3 \(-> blinking underline.
+  \*(Ps = \*4 \(-> steady underline.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*(c"\\*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.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*r
+Set Scrolling Region [top;bottom] (default = full size of window) (DECSTBM).
+.
+.IP \\*(Cs\\*?\\*(Pm\\*s\\*r
+Restore DEC Private Mode Values.
+The value of \*(Ps previously saved is restored.
+\*(Ps values are the same as for DECSET.
+.
+.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Ps\\*$\\*r
+Change Attributes in Rectangular Area (DECCARA), VT400 and up.
+  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
+  \*(Ps denotes the SGR attributes to change: 0, 1, 4, 5, 7.
+.
+.IP \\*(Cs\\*(cs
+Save cursor (ANSI.SYS).
+.
+.IP \\*(Cs\\*?\\*(Pm\\*s\\*(cs
+Save DEC Private Mode Values.
+\*(Ps values are the same as for DECSET.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*t
+Window manipulation (from \fIdtterm\fP, as well as extensions).
+These controls may be disabled using the \fIallowWindowOps\fP resource.
+Valid values for the first (and any additional parameters) are:
+  \*(Ps = \*1 \(-> De-iconify window.
+  \*(Ps = \*2 \(-> Iconify window.
+  \*(Ps = \*3\*s\*;\*s\fIx\*s\*;\*sy\fP \(-> Move window to [x, y].
+  \*(Ps = \*4\*s\*;\*s\fIheight\*s\*;\*swidth\fP \(-> Resize the \fIxterm\fP window to height and width in pixels.
+  \*(Ps = \*5 \(-> Raise the \fIxterm\fP window to the front of the stacking order.
+  \*(Ps = \*6 \(-> Lower the \fIxterm\fP window to the bottom of the stacking order.
+  \*(Ps = \*7 \(-> Refresh the \fIxterm\fP window.
+  \*(Ps = \*8\*s\*;\*s\fIheight\*s\*;\*swidth\fP \(-> Resize the text area to [height;width] in characters.
+  \*(Ps = \*9\*s\*;\*s\*0 \(-> Restore maximized window.
+  \*(Ps = \*9\*s\*;\*s\*1 \(-> Maximize window (i.e., resize to screen size).
+  \*(Ps = \*1\*1 \(-> Report \fIxterm\fP window state.
+If the \fIxterm\fP window is open (non-iconified), it returns \*(Cs\*1\*t.
+If the \fIxterm\fP window is iconified, it returns \*(Cs\*2\*t.
+  \*(Ps = \*1\*3 \(-> Report \fIxterm\fP window position.  Result is
+\*(Cs\*3\*;\*(Ix\*s\*;\*(Iy\*s\*t
+  \*(Ps = \*1\*4 \(-> Report \fIxterm\fP window in pixels.  Result is
+\*(Cs\*s\*4\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t
+  \*(Ps = \*1\*8 \(-> Report the size of the text area in characters.  Result is
+\*(Cs\*s\*8\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t
+  \*(Ps = \*1\*9 \(-> Report the size of the screen in characters.  Result is
+\*(Cs\*s\*9\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t
+  \*(Ps = \*2\*0 \(-> Report \fIxterm\fP window's icon label.  Result is
+\*(Os\*s\*L\*s\fIlabel\fP\*s\*(ST
+  \*(Ps = \*2\*1 \(-> Report \fIxterm\fP window's title.  Result is
+\*(Os\*s\*l\*s\fIlabel\fP\*s\*(ST
+  \*(Ps = \*2\*2\*s\*;\*s\*0 \(-> Save \fIxterm\fP icon and window title on stack.
+  \*(Ps = \*2\*2\*s\*;\*s\*1 \(-> Save \fIxterm\fP icon title on stack.
+  \*(Ps = \*2\*2\*s\*;\*s\*2 \(-> Save \fIxterm\fP window title on stack.
+  \*(Ps = \*2\*3\*s\*;\*s\*0 \(-> Restore \fIxterm\fP icon and window title from stack.
+  \*(Ps = \*2\*3\*s\*;\*s\*1 \(-> Restore \fIxterm\fP icon title from stack.
+  \*(Ps = \*2\*3\*s\*;\*s\*2 \(-> Restore \fIxterm\fP window title from stack.
+  \*(Ps >= \*2\*4 \(-> Resize to \*(Ps lines (DECSLPP).
+.
+.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Ps\\*$\\*t
+Reverse Attributes in Rectangular Area (DECRARA), VT400 and up.
+  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
+  \*(Ps denotes the attributes to reverse, i.e.,  1, 4, 5, 7.
+.
+.IP \\*(Cs\\*>\\*(Ps\\*;\\*(Ps\\*s\\*t
+Set one or more features of the title modes.
+Each parameter enables a single feature.
+  \*(Ps = \*0 \(-> Set window/icon labels using hexadecimal.
+  \*(Ps = \*1 \(-> Query window/icon labels using hexadecimal.
+  \*(Ps = \*2 \(-> Set window/icon labels using UTF-8.
+  \*(Ps = \*3 \(-> Query window/icon labels using UTF-8.
+(See discussion of "Title Modes")
+.
+.IP \\*(Cs\\*(Ps\\*s\\*(Sp\\*t
+Set warning-bell volume (DECSWBV, VT520).
+  \*(Ps = \*0 or \*1 \(-> off.
+  \*(Ps = \*2, \*3 or \*4 \(-> low.
+  \*(Ps = \*5, \*6, \*7, or \*8 \(-> high.
+.
+.IP \\*(Cs\\*u
+Restore cursor (ANSI.SYS).
+.
+.IP \\*(Cs\\*(Ps\\*s\\*(Sp\\*u
+Set margin-bell volume (DECSMBV, VT520).
+  \*(Ps = \*1 \(-> off.
+  \*(Ps = \*2, \*3 or \*4 \(-> low.
+  \*(Ps = \*0, \*5, \*6, \*7, or \*8 \(-> high.
+.
+.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Pp\\*;\\*(Pt\\*;\\*(Pl\\*;\\*(Pp\\*$\\*v
+Copy Rectangular Area (DECCRA, VT400 and up).
+  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
+  \*(Pp denotes the source page.
+  \*(Pt\*;\*(Pl denotes the target location.
+  \*(Pp denotes the target page.
+.
+.IP \\*(Cs\\*(Pt\\*s\\*;\\*(Pl\\*s\\*;\\*(Pb\\*s\\*;\\*(Pr\\*s\\*(qu\\*w
+Enable Filter Rectangle (DECEFR), VT420 and up.
+.br
+Parameters are [top;left;bottom;right].
+.br
+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 omitted, any locator motion will be reported.
+DECELR always cancels any prevous rectangle definition.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*x
+Request Terminal Parameters (DECREQTPARM).
+.br
+if \*(Ps is a "0" (default) or "1", and \fBxterm\fR 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.
+  \*(Pn = \*1 \(<- no parity.
+  \*(Pn = \*1 \(<- eight bits.
+  \*(Pn = \*1 \(<- \*2 \*8 transmit 38.4k baud.
+  \*(Pn = \*1 \(<- \*2 \*8 receive 38.4k baud.
+  \*(Pn = \*1 \(<- clock multiplier.
+  \*(Pn = \*0 \(<- STP flags.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*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).
+.
+.IP \\*(Cs\\*(Pc\\*;\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*$\\*x
+Fill Rectangular Area (DECFRA), VT420 and up.
+  \*(Pc is the character to use.
+  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Pu\\*s\\*(qu\\*z
+Enable Locator Reporting (DECELR).
+.br
+Valid values for the first parameter:
+  \*(Ps = \*0 \(-> Locator disabled (default).
+  \*(Ps = \*1 \(-> Locator enabled.
+  \*(Ps = \*2 \(-> Locator enabled for one report, then disabled.
+.br
+The second parameter specifies the coordinate unit for locator reports.
+.br
+Valid values for the second parameter:
+  \*(Pu = \*0 \(<- or omitted \(-> default to character cells.
+  \*(Pu = \*1 \(<- device physical pixels.
+  \*(Pu = \*2 \(<- character cells.
+.
+.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*$\\*z
+Erase Rectangular Area (DECERA), VT400 and up.
+  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
+.
+.IP \\*(Cs\\*(Pm\\*s\\*(qu\\*{
+Select Locator Events (DECSLE).
+.br
+Valid values for the first (and any additional parameters) are:
+  \*(Ps = \*0 \(-> only respond to explicit host requests (DECRQLP).
+             (This is default).  It 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.
+.
+.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*$\\*{
+Selective Erase Rectangular Area (DECSERA), VT400 and up.
+  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
+.
+.IP \\*(Cs\\*(Ps\\*s\\*(qu\\*|
+Request Locator Position (DECRQLP).
+.br
+Valid values for the parameter are:
+  \*(Ps = \*0, 1 or omitted \(-> transmit a single DECLRP locator report.
+.sP
+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.
+.sP
+  \(-> \*(Cs\*(Pe\*s\*;\*(Pb\*s\*;\*(Pr\*s\*;\*(Pc\*s\*;\*(Pp\*s\*&\*s\*w
+.sP
+Parameters are [event;button;row;column;page].
+.br
+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.
+.br
+``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.
+.br
+``row'' and ``column'' parameters are the coordinates of the locator
+position in the xterm window, encoded as ASCII decimal.
+.br
+The ``page'' parameter is not used by xterm, and will be omitted.
+.
+.Ed
+.
+.St
+.Ss
+Operating System Controls
+.
+.IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(ST
+.IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(Be
+Set Text Parameters.
+For colors and font,
+if \*(Pt is a "?", the control sequence elicits a response which consists
+of the control sequence which would set the corresponding value.
+The \fIdtterm\fP 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
+"\fIprop=value\fP", or just "\fIprop\fP" to delete the property
+  \*(Ps = \*4 ; \fIc ; spec\fP \(-> Change Color Number \fIc\fP to
+the color specified by \fIspec\fP.
+This can be a name or RGB specification as per \fIXParseColor\fP.
+Any number of \fIc name\fP 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.
+.sP
+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, \fBxterm\fR can make more than one reply.
+.sP
+  \*(Ps = \*5 ; \fIc ; spec\fP \(-> Change Special Color Number \fIc\fP to
+the color specified by \fIspec\fP.
+This can be a name or RGB specification as per \fIXParseColor\fP.
+Any number of \fIc name\fP pairs may be given.
+The special colors can also be set by adding the maximum number of colors
+to these codes in an \*(Os\*4 control:
+.sP
+  \*(Pc = \*0 \(<- resource \fBcolorBD\fP (BOLD).
+  \*(Pc = \*1 \(<- resource \fBcolorUL\fP (UNDERLINE).
+  \*(Pc = \*2 \(<- resource \fBcolorBL\fP (BLINK).
+  \*(Pc = \*3 \(<- resource \fBcolorRV\fP (REVERSE).
+.sP
+The 8 colors (below) which may be set or queried
+using \*1\*0 through \*1\*7 are
+denoted \fIdynamic colors\fR, since the corresponding control sequences
+were the first means for setting \fBxterm\fR's colors dynamically,
+i.e., after it was started.
+They are not the same as the ANSI colors.
+These controls may be disabled using the \fIallowColorOps\fP resource.
+At least one parameter 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 \fIXParseColor\fP.
+.sP
+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, \fBxterm\fR can make more than one reply.
+.sP
+  \*(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 background color to \*(Pt.
+  \*(Ps = \*1\*8 \(-> Change Tektronix cursor color to \*(Pt.
+  \*(Ps = \*1\*9 \(-> Change highlight foreground color to \*(Pt.
+.sP
+  \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt.  (This is normally disabled by a
+compile-time option).
+.sP
+  \*(Ps = \*5\*0 \(-> Set Font to \*(Pt.
+These controls may be disabled using the \fIallowFontOps\fP resource.
+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).
+.br
+The same rule (plus or minus sign, optional number) is used when
+querying the font.
+The remainder of \*(Pt is ignored.
+.br
+A font can be specified after a "#" index expression,
+by adding a space and then the font specifier.
+.br
+If the "TrueType Fonts" menu entry is set (the \fBrenderFont\fP resource),
+then this control sets/queries the \fBfaceName\fP resource.
+.sP
+  \*(Ps = \*5\*1 (reserved for Emacs shell).
+.sP
+  \*(Ps = \*5\*2 \(-> Manipulate Selection Data.
+These controls may be disabled using the \fIallowWindowOps\fP resource.
+The parameter \*(Pt is parsed as
+.br
+       \*(Pc\*;\*(Pd
+.br
+The first, \*(Pc, may contain any character from the
+set \*c \*p \*(cs \*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, \fIxterm\fP uses \*(cs\*0,
+to specify the configurable primary/clipboard selection and cut buffer 0.
+.br
+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 applications.
+.br
+If the second parameter is a \*?,
+\fIxterm\fP replies to the host with the selection
+data encoded using the same protocol.
+.Ed
+.sP
+  \*(Ps = \*1\*0\*4 ; \fIc\fP \(-> Reset Color Number \fIc\fP.  It is reset to
+the color specified by the corresponding X resource.
+Any number of \fIc\fP parameters may be given.
+These parameters 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 no parameters are given, the entire table will be reset.
+.sP
+  \*(Ps = \*1\*0\*5 ; \fIc\fP \(-> Reset Special Color Number \fIc\fP.  It is reset to
+the color specified by the corresponding X resource.
+Any number of \fIc\fP parameters may be given.
+These parameters correspond to the special colors which can be set
+using an \*(Os\*5 control (or by adding the maximum number of colors
+using an \*(Os\*4 control).
+.sP
+The \fIdynamic colors\fR can also be reset to their default (resource) values:
+  \*(Ps = \*1\*1\*0 \(-> Reset VT100 text foreground color.
+  \*(Ps = \*1\*1\*1 \(-> Reset VT100 text background color.
+  \*(Ps = \*1\*1\*2 \(-> Reset text cursor color.
+  \*(Ps = \*1\*1\*3 \(-> Reset mouse foreground color.
+  \*(Ps = \*1\*1\*4 \(-> Reset mouse background color.
+  \*(Ps = \*1\*1\*5 \(-> Reset Tektronix foreground color.
+  \*(Ps = \*1\*1\*6 \(-> Reset Tektronix background color.
+  \*(Ps = \*1\*1\*7 \(-> Reset highlight color.
+  \*(Ps = \*1\*1\*8 \(-> Reset Tektronix cursor color.
+.
+.St
+.Ss
+Privacy Message
+.IP \\*(PM\\*(Pt\\*s\\*(ST
+\fIxterm\fP implements no \*(PM functions; \*(Pt is ignored.
+\*(Pt need not be printable characters.
+.Ed
+.
+.Sh "Alt and Meta Keys"
+.LP
+Many keyboards have keys labeled "Alt".
+Few have keys labeled "Meta".
+However, \fIxterm\fP's default translations use the \fIMeta\fP modifier.
+Common keyboard configurations assign the \fIMeta\fP modifier to an "Alt" key.
+By using \fIxmodmap\fP one may have the modifier assigned to a different key,
+and have "real" alt and meta keys.
+Here is an example:
+.DS B
+! 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
+.DE
+.lP
+The \fBmetaSendsEscape\fP resource
+(and \fBaltSendsEscape\fP if \fBaltIsNotMeta\fP is set)
+can be used to control the way the \fIMeta\fP modifier applies to ordinary
+keys unless the \fBmodifyOtherKeys\fP resource is set:
+.IP
+-
+prefix a key with the \*(Es character.
+.IP
+-
+shift the key from codes 0-127 to 128-255 by adding 128.
+.lP
+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 \fBaltIsNotMeta\fP is set:
+.ne 18
+.TS
+center;
+lf3    lf3     lf3     lf3
+lf3w(2c)       lf3w(2c)        lf3w(2c)        lf3w(2c) .
+_
+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     \*(Es x
+Alt+Meta-x     ON      off     \*(Es shift
+x      off     ON      x
+Meta-x off     ON      \*(Es x
+Alt-x  off     ON      shift
+Alt+Meta-x     off     ON      \*(Es shift
+x      ON      ON      x
+Meta-x ON      ON      \*(Es x
+Alt-x  ON      ON      \*(Es x
+Alt+Meta-x     ON      ON      \*(Es x
+_
+.TE
+.Sh "PC-Style Function Keys"
+.LP
+If \fIxterm\fP 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.
+.lP
+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 \fBnumLock\fP resource,
+or by the "DECSET \*1\*0\*3\*5" control sequence.
+.lP
+The cursor keys transmit the following escape sequences depending on the
+mode specified via the \fBDECCKM\fP escape sequence.
+.TS
+center;
+cf3    cf3     cf3
+lf3w(2c)       lf3w(2c)        lf3w(2c) .
+Key    Normal  Application
+_
+Cursor Up      \*(Cs\*A        \*(S3\*A
+Cursor Down    \*(Cs\*(cB      \*(S3\*(cB
+Cursor Right   \*(Cs\*C        \*(S3\*C
+Cursor Left    \*(Cs\*D        \*(S3\*D
+_
+.TE
+The home- and end-keys
+(unlike PageUp and other keys also on the 6-key editing keypad)
+are considered "cursor keys" by \fIxterm\fP.
+Their mode is also controlled by the \fBDECCKM\fP escape sequence:
+.TS
+center;
+cf3    cf3     cf3
+lf3w(2c)       lf3w(2c)        lf3w(2c) .
+Key    Normal  Application
+_
+Home   \*(Cs\*H        \*(S3\*H
+End    \*(Cs\*F        \*(S3\*F
+_
+.TE
+.lP
+The application keypad transmits the following escape sequences depending on the
+mode specified via the \fBDECPNM\fP and \fBDECPAM\fP escape sequences.
+Use the NumLock key to override the application mode.
+.lP
+Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are supported by
+the program.
+.ne 30
+.TS
+center;
+cf3    cf3     cf3     cf3     cf3
+lf3w(2c)       lf3w(2c)        lf3w(2c)        lf3w(2c)        lf3w(2c) .
+Key    Numeric Application     Terminfo        Termcap
+_
+Space  \*(Sp   \*(S3\*(Sp      -       -
+Tab    \*(Ta   \*(S3\*I        -       -
+Enter  \*(Cr   \*(S3\*M        kent    @8
+PF1    \*(S3\*P        \*(S3\*P        kf1     k1
+PF2    \*(S3\*Q        \*(S3\*Q        kf2     k2
+PF3    \*(S3\*R        \*(S3\*R        kf3     k3
+PF4    \*(S3\*S        \*(S3\*S        kf4     k4
+* \f1(multiply)\fP     \**     \*(S3\*j        -       -
++ \f1(add)\fP  \*+     \*(S3\*k        -       -
+, \f1(comma)\fP        \*,     \*(S3\*l        -       -
+- \f1(minus)\fP        \*-     \*(S3\*m        -       -
+\&. \f1(Delete)\fP     \*.     \*(Cs\*3\*(c~   -       -
+/ \f1(divide)\fP       \*/     \*(S3\*o        -       -
+0 \f1(Insert)\fP       \*0     \*(Cs\*2\*(c~   -       -
+1 \f1(End)\fP  \*1     \*(S3\*F        kc1     K4
+2 \f1(DownArrow)\fP    \*2     \*(Cs\*(cB      -       -
+3 \f1(PageDown)\fP     \*3     \*(Cs\*6\*(c~   kc3     K5
+4 \f1(LeftArrow)\fP    \*4     \*(Cs\*D        -       -
+5 \f1(Begin)\fP        \*5     \*(Cs\*E        kb2     K2
+6 \f1(RightArrow)\fP   \*6     \*(Cs\*C        -       -
+7 \f1(Home)\fP \*7     \*(S3\*H        ka1     K1
+8 \f1(UpArrow)\fP      \*8     \*(Cs\*A        -       -
+9 \f1(PageUp)\fP       \*9     \*(Cs\*5\*(c~   ka3     K3
+= (equal)      \*=     \*(S3\*(XX      -       -
+_
+.TE
+.br
+They also provide 12 function keys, as well as a few other special-purpose keys:
+.ne 16
+.TS
+center;
+cf3    cf3
+lf3w(2c)       lf3w(2c) .
+Key    Escape Sequence
+_
+F1     \*(S3\*P
+F2     \*(S3\*Q
+F3     \*(S3\*R
+F4     \*(S3\*S
+F5     \*(Cs\*1\*5\*(c~
+F6     \*(Cs\*1\*7\*(c~
+F7     \*(Cs\*1\*8\*(c~
+F8     \*(Cs\*1\*9\*(c~
+F9     \*(Cs\*2\*0\*(c~
+F10    \*(Cs\*2\*1\*(c~
+F11    \*(Cs\*2\*3\*(c~
+F12    \*(Cs\*2\*4\*(c~
+_
+.TE
+.sP
+Older versions of \fIxterm\fP implement different escape sequences for F1 through F4.
+These can be activated by setting the \fBoldXtermFKeys\fP resource.
+However, since they do not correspond to any hardware terminal, they have been deprecated.
+(The DEC VT220 reserves F1 through F5 for local functions such as \fBSetup\fP).
+.ne 6
+.TS
+center;
+cf3    cf3
+lf3w(2c)       lf3w(2c) .
+Key    Escape Sequence
+_
+F1     \*(Cs\*1\*1\*(c~
+F2     \*(Cs\*1\*2\*(c~
+F3     \*(Cs\*1\*3\*(c~
+F4     \*(Cs\*1\*4\*(c~
+_
+.TE
+In normal mode, i.e., a Sun/PC keyboard
+when the \fBsunKeyboard\fP resource is false,
+\fIxterm\fP recognizes function key modifiers
+which are parameters appended before the final character
+of the control sequence.
+.TS
+center;
+cf3    lf3
+cf3w(2c)       lf3w(2c) .
+Code   Modifiers
+_
+2      Shift
+3      Alt
+4      Shift + Alt
+5      Control
+6      Shift + Control
+7      Alt + Control
+8      Shift + Alt + Control
+_
+.TE
+For example, shift-F5 would be sent as
+\*(Cs\*1\*5\*;\*2\*(c~
+.lP
+If the \fBalwaysUseMods\fP resource is set, the Meta modifier also is
+recognized, making parameters 9 through 16.
+.Sh "VT220-Style Function Keys"
+.LP
+However, \fIxterm\fP is most useful as a DEC VT102 or VT220 emulator.
+Set the \fBsunKeyboard\fP resource to true to force a Sun/PC keyboard
+to act like a VT220 keyboard.
+.lP
+The VT102/VT220 application keypad transmits unique escape sequences in
+application mode, which are distinct from the cursor and scrolling keypad:
+.ne 31
+.TS
+center;
+cf3    cf3     cf3
+lf3w(2c)       lf3w(2c)        lf3w(2c) .
+Key    Numeric Application
+_
+Space  \*(Sp   \*(S3\*(Sp
+Tab    \*(Ta   \*(S3\*I
+Enter  \*(Cr   \*(S3\*M
+PF1    \*(S3\*P        \*(S3\*P
+PF2    \*(S3\*Q        \*(S3\*Q
+PF3    \*(S3\*R        \*(S3\*R
+PF4    \*(S3\*S        \*(S3\*S
+* \f1(multiply)\fP     \**     \*(S3\*j
++ \f1(add)\fP  \*+     \*(S3\*k
+, \f1(comma)\fP        \*,     \*(S3\*l
+- \f1(minus)\fP        \*-     \*(S3\*m
+\&. \f1(period)\fP     \*.     \*(S3\*n
+/ \f1(divide)\fP       \*/     \*(S3\*o
+0      \*0     \*(S3\*p
+1      \*1     \*(S3\*q
+2      \*2     \*(S3\*r
+3      \*3     \*(S3\*(cs
+4      \*4     \*(S3\*t
+5      \*5     \*(S3\*u
+6      \*6     \*(S3\*v
+7      \*7     \*(S3\*w
+8      \*8     \*(S3\*x
+9      \*9     \*(S3\*y
+= (equal)      \*=     \*(S3\*(XX
+_
+.TE
+The VT220 provides a 6-key editing keypad,
+which is analogous to that on the PC keyboard.
+It is not affected by \fBDECCKM\fP or \fBDECPNM\fP/\fBDECPAM\fP:
+.ne 10
+.TS
+center;
+cf3    cf3     cf3
+lf3w(2c)       lf3w(2c)        lf3w(2c) .
+Key    Normal  Application
+_
+\f1Insert\fP   \*(Cs\*2\*(c~   \*(Cs\*2\*(c~
+\f1Delete\fP   \*(Cs\*3\*(c~   \*(Cs\*3\*(c~
+\f1Home\fP     \*(Cs\*1\*(c~   \*(Cs\*1\*(c~
+\f1End\fP      \*(Cs\*4\*(c~   \*(Cs\*4\*(c~
+\f1PageUp\fP   \*(Cs\*5\*(c~   \*(Cs\*5\*(c~
+\f1PageDown\fP \*(Cs\*6\*(c~   \*(Cs\*6\*(c~
+_
+.TE
+.LP
+The VT220 provides 8 additional function keys.
+With a Sun/PC keyboard, access these keys by Control/F1 for F13, etc.
+.ne 16
+.TS
+center;
+cf3    cf3
+lf3w(2c)       lf3w(2c) .
+Key    Escape Sequence
+_
+F13    \*(Cs\*2\*5\*(c~
+F14    \*(Cs\*2\*6\*(c~
+F15    \*(Cs\*2\*8\*(c~
+F16    \*(Cs\*2\*9\*(c~
+F17    \*(Cs\*3\*1\*(c~
+F18    \*(Cs\*3\*2\*(c~
+F19    \*(Cs\*3\*3\*(c~
+F20    \*(Cs\*3\*4\*(c~
+_
+.TE
+.Sh "VT52-Style Function Keys"
+.LP
+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:
+.ne 10
+.TS
+center;
+cf3    cf3
+lf3w(2c)       lf3w(2c) .
+Key    Normal/Application
+_
+Cursor Up      \*(Es\*A
+Cursor Down    \*(Es\*(cB
+Cursor Right   \*(Es\*C
+Cursor Left    \*(Es\*D
+_
+.TE
+The keypad is similar:
+.TS
+center;
+cf3    cf3     cf3
+lf3w(2c)       lf3w(2c)        lf3w(2c) .
+Key    Numeric Application
+_
+Space  \*(Sp   \*(Es\*?\*(Sp
+Tab    \*(Ta   \*(Es\*?\*I
+Enter  \*(Cr   \*(Es\*?\*M
+PF1    \*(Es\*P        \*(Es\*P
+PF2    \*(Es\*Q        \*(Es\*Q
+PF3    \*(Es\*R        \*(Es\*R
+PF4    \*(Es\*S        \*(Es\*S
+* \f1(multiply)\fP     \**     \*(Es\*?\*j
++ \f1(add)\fP  \*+     \*(Es\*?\*k
+, \f1(comma)\fP        \*,     \*(Es\*?\*l
+- \f1(minus)\fP        \*-     \*(Es\*?\*m
+\&. \f1(period)\fP     \*.     \*(Es\*?\*n
+/ \f1(divide)\fP       \*/     \*(Es\*?\*o
+0      \*0     \*(Es\*?\*p
+1      \*1     \*(Es\*?\*q
+2      \*2     \*(Es\*?\*r
+3      \*3     \*(Es\*?\*(cs
+4      \*4     \*(Es\*?\*t
+5      \*5     \*(Es\*?\*u
+6      \*6     \*(Es\*?\*v
+7      \*7     \*(Es\*?\*w
+8      \*8     \*(Es\*?\*x
+9      \*9     \*(Es\*?\*y
+= (equal)      \*=     \*(Es\*?\*(XX
+_
+.TE
+.Sh "Sun-Style Function Keys"
+.LP
+The \fIxterm\fP 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 \fIsun\fP and \fIVT100\fP emulations are not really
+compatible.
+For example, their wrap-margin behavior differs.
+.lP
+Only function keys are altered; keypad and cursor keys are the same.
+The emulation responds identically.
+See the xterm-sun terminfo entry for details.
+.Sh "HP-Style Function Keys"
+.LP
+Similarly, \fIxterm\fP can be compiled to support HP keyboards.
+See the xterm-hp terminfo entry for details.
+.Sh "The Alternate Screen Buffer"
+.LP
+\fBXterm\fP 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 \fBsaveLines\fP 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.
+\fBXterm\fP provides control sequences and menu entries
+for switching between the two.
+.lP
+Most full-screen applications use terminfo or termcap to obtain
+strings used to start/stop full-screen mode,
+i.e., \fIsmcup\fP and \fIrmcup\fP for terminfo,
+or the corresponding \fIti\fP and \fIte\fP for termcap.
+The \fBtiteInhibit\fP resource removes the \fIti\fP and \fIte\fP strings
+from the TERMCAP string which is set in the environment for some platforms.
+That is not done when \fBxterm\fP 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 terminfo anyway, since terminfo data is not passed
+in environment variables;
+setting an environment variable in this manner would have no effect on
+the application's ability to switch between normal and alternate screen
+buffers.
+Instead, the newer private mode controls
+(such as \*1\*0\*4\*9)
+for switching between normal
+and alternate screen buffers simply disable the switching.
+They add other features such as clearing the display for the same reason:
+to make the details of switching independent of the application that
+requests the switch.
+.
+.Sh "Bracketed Paste Mode"
+.LP
+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 ~,
+.br
+followed by the pasted text, followed by
+   ESC [ 201 ~.
+.
+.Sh "Title Modes"
+.LP
+The window- and icon-labels can be set or queried using control sequences.
+As a VT220-emulator, \fIxterm\fP "should" limit the character encoding for
+the corresponding strings to ISO-8859-1.
+Indeed, it used to be the case (and was documented) that
+window titles had to be ISO-8859-1.
+This is no longer the case.
+However, there are many applications which still assume that titles are
+set using ISO-8859-1.
+So that is the default behavior.
+.lP
+If \fIxterm\fP is running with UTF-8 encoding,
+it is possible to use window- and icon-labels encoded using UTF-8.
+That is because the underlying X libraries (and many, but not all)
+window managers support this feature.
+.lP
+The \fButf8Title\fP X resource setting tells \fIxterm\fP to disable
+a reconversion of the title string back to ISO-8859-1,
+allowing the title strings to be interpreted as UTF-8.
+The same feature can be enabled using the title mode control sequence
+described in this summary.
+.lP
+Separate from the ability to set the titles,
+\fIxterm\fP provides the ability to query the titles,
+returning them either in ISO-8859-1 or UTF-8.
+This choice is available only while \fIxterm\fP is using UTF-8 encoding.
+.lP
+Finally, the characters sent to, or returned by a title control
+are less constrained than the rest of the control sequences.
+To make them more manageable (and constrained), for use in shell scripts,
+\fIxterm\fP has an optional feature which decodes the string from hexadecimal
+(for setting titles) or for encoding the title into hexadecimal when querying
+the value.
+.
+.Sh "Mouse Tracking"
+.LP
+The VT widget can be set to send the mouse position and other
+information on button presses.
+These modes are typically used by
+editors and other full-screen applications that want to make use of
+the mouse.
+.lP
+There are six mutually exclusive modes.
+One is DEC Locator mode, enabled by the
+DECELR \*(Cs\*(Ps\*s\*;\*(Ps\*s\*s\*(qu\*s\*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
+the "DECSET \*(Cs\*?\*(Pm\*s\*h"
+or
+"DECRST \*(Cs\*?\*(Pm\*s\*l"
+control sequence.
+.lP
+Manifest constants for the parameter values
+are defined in \fBxcharmouse.h\fP as follows:
+.
+.DS B
+#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
+
+#define SET_EXT_MODE_MOUSE          1005
+.DE
+.br
+The motion reporting modes are strictly \fIxterm\fP extensions, and are not
+part of any standard, though they are analogous to the DEC VT200 DECELR
+locator reports.
+.lP
+Parameters (such as pointer position and button number) for all mouse
+tracking escape sequences generated by \fIxterm\fP
+encode numeric parameters in a single character as
+\fIvalue\fP+32.
+For example, \*! specifies the value 1.
+The upper left character position on the terminal is denoted as 1,1.
+.lP
+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, \fIxterm\fP sends
+\*(Cs\*M\*(Cb\*(Cx\*(Cy (6 characters).
+.bP
+\*(Cb is button\-1.
+.bP
+\*(Cx and \*(Cy are the x and y coordinates of the mouse when the
+button was pressed.
+.lP
+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, \fIxterm\fP sends
+\*(Cs\*M\*(Cb\*(Cx\*(Cy.
+.bP
+The low two bits of \*(Cb encode button information:
+0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release.
+.bP
+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 \fIxterm\fP uses the control modifier with mouse for popup menus,
+and the shift modifier is used in the default translations for button events.
+The \fIMeta\fP modifier recognized by \fIxterm\fP is the \fImod1\fP mask,
+and is not necessarily the "Meta" key (see \fIxmodmap\fP).
+.bP
+\*(Cx and \*(Cy are the x and y coordinates of the mouse event, encoded as
+in X10 mode.
+.lP
+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.
+.lP
+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 button events
+can be received.
+.sP
+\fBWarning:\fP use of this mode requires a cooperating program or it will
+hang \fIxterm.\fP
+.sP
+On button press, the same information as for normal tracking is
+generated; \fIxterm\fP then waits for the program to send mouse
+tracking information.
+\fIAll X events are ignored until the proper escape sequence is
+received from the pty:\fP
+\*(Cs\*(Ps\*s\*;\*(Ps\*s\*;\*(Ps\*s\*;\*(Ps\*s\*;\*(Ps\*s\*T.
+The parameters are \fIfunc, startx, starty, firstrow,\fP and \fIlastrow.\fP
+\fIfunc\fP is non-zero to initiate highlight tracking and zero to abort.
+\fIstartx\fP and \fIstarty\fP give the starting x and y location for
+the highlighted region.
+The ending location tracks the mouse, but
+will never be above row \fIfirstrow\fP and will always be above row
+\fIlastrow.\fP
+(The top of the screen is row 1.)
+When the button is released, \fIxterm\fP reports the ending position
+one of two ways:
+.bP
+if the start and end coordinates are the same locations:
+.br
+\*(Cs\*t\*(Cx\*(Cy.
+.bP
+otherwise:
+.br
+\*(Cs\*T\*(Cx\*(Cy\*(Cx\*(Cy\*(Cx\*(Cy.
+.br
+The parameters are \fIstartx, starty, endx, endy, mousex,\fP and \fImousey.\fP
+.RS
+.IP \- 5
+\fIstartx, starty, endx, \fPand\fI endy\fP give the starting and
+ending character positions of the region.
+.IP \- 5
+\fImousex\fP and \fImousey\fP
+give the location of the mouse at button up, which may not be over a
+character.
+.RE
+.lP
+Button-event tracking is essentially the same as normal tracking, but
+\fIxterm\fP 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, \fIxterm\fP sends the same codes used by normal
+tracking mode.
+.bP
+On button-motion events, \fIxterm\fP adds 32 to the event code
+(the third character, \*(Cb).
+.bP
+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 \*(Cs\*M\*@\*(Cx\*(Cy.
+(\ \*@ = 32 + 0 (button 1) + 32 (motion indicator)\ ).
+Similarly, motion with button 3
+down is reported as \*(Cs\*M\*(cB\*(Cx\*(Cy.
+(\ \*(cB = 32 + 2 (button 3) + 32 (motion indicator)\ ).
+.lP
+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.
+.lP
+FocusIn/FocusOut can be combined with any of the mouse events since
+it uses a different protocol.
+When set, it causes \fIxterm\fP to send
+\*(Cs\*I when the terminal gains focus, and
+\*(Cs\*O when it loses focus.
+.lP
+Extended mouse mode enables UTF-8 encoding for \*(Cx and \*(Cy under
+all tracking modes, expanding the maximum encodable position from 223 to 2015.
+For positions less than 95, the resulting output is identical under both modes.
+Under extended mouse mode, positions greater than 95
+generate "extra" bytes which will confuse applications which do not treat
+their input as a UTF-8 stream.
+Likewise, \*(Cb will be UTF-8 encoded,
+to reduce confusion with wheel mouse events.
+.lP
+NOTE: Under normal mouse mode, positions outside (160,94) result in
+byte pairs which can be interpreted as a single UTF-8 character;
+applications
+which do treat their input as UTF-8 will almost certainly be confused
+unless extended mouse mode is active.
+.
+.Sh "Tektronix 4014 Mode"
+.LP
+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.
+.St
+.IP \\*(Be
+Bell (Ctrl-G).
+.IP \\*(Bs
+Backspace (Ctrl-H).
+.IP \\*(Ta
+Horizontal Tab (Ctrl-I).
+.IP \\*(Lf
+Line Feed or New Line (Ctrl-J).
+.IP \\*(Vt
+Cursor up (Ctrl-K).
+.IP \\*(Ff
+Form Feed or New Page (Ctrl-L).
+.IP \\*(Cr
+Carriage Return (Ctrl-M).
+.IP \\*(Es\\*(Et
+Switch to VT100 Mode (ESC Ctrl-C).
+.IP \\*(Es\\*(En
+Return Terminal Status (ESC Ctrl-E).
+.IP \\*(Es\\*(Ff
+PAGE (Clear Screen) (ESC Ctrl-L).
+.IP \\*(Es\\*(So
+Begin 4015 APL mode (ESC Ctrl-N).  (This is ignored by \fIxterm\fP).
+.IP \\*(Es\\*(Si
+End 4015 APL mode (ESC Ctrl-O).  (This is ignored by \fIxterm\fP).
+.IP \\*(Es\\*(Eb
+COPY (Save Tektronix Codes to file COPYyyyy-mm-dd.hh:mm:ss).
+  \*(Eb (end transmission block) is the same as Ctrl-W.
+.IP \\*(Es\\*(Ca
+Bypass Condition (ESC Ctrl-X).
+.IP \\*(Es\\*(Su
+GIN mode (ESC Ctrl-Z).
+.IP \\*(Es\\*(Fs
+Special Point Plot Mode (ESC Ctrl-\e).
+.IP \\*(Es\\*8
+Select Large Character Set.
+.IP \\*(Es\\*9
+Select #2 Character Set.
+.IP \\*(Es\\*:
+Select #3 Character Set.
+.IP \\*(Es\\*;
+Select Small Character Set.
+.IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(Be
+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.  (This is normally disabled by a
+compile-time option).
+.IP \\*(Es\\*`
+Normal Z Axis and Normal (solid) Vectors.
+.IP \\*(Es\\*a
+Normal Z Axis and Dotted Line Vectors.
+.IP \\*(Es\\*b
+Normal Z Axis and Dot-Dashed Vectors.
+.IP \\*(Es\\*c
+Normal Z Axis and Short-Dashed Vectors.
+.IP \\*(Es\\*d
+Normal Z Axis and Long-Dashed Vectors.
+.IP \\*(Es\\*h
+Defocused Z Axis and Normal (solid) Vectors.
+.IP \\*(Es\\*i
+Defocused Z Axis and Dotted Line Vectors.
+.IP \\*(Es\\*j
+Defocused Z Axis and Dot-Dashed Vectors.
+.IP \\*(Es\\*k
+Defocused Z Axis and Short-Dashed Vectors.
+.IP \\*(Es\\*l
+Defocused Z Axis and Long-Dashed Vectors.
+.IP \\*(Es\\*p
+Write-Thru Mode and Normal (solid) Vectors.
+.IP \\*(Es\\*q
+Write-Thru Mode and Dotted Line Vectors.
+.IP \\*(Es\\*r
+Write-Thru Mode and Dot-Dashed Vectors.
+.IP \\*(Es\\*(cs
+Write-Thru Mode and Short-Dashed Vectors.
+.IP \\*(Es\\*t
+Write-Thru Mode and Long-Dashed Vectors.
+.IP \\*(Fs
+Point Plot Mode (Ctrl-\e).
+.IP \\*(Gs
+Graph Mode (Ctrl-]).
+.IP \\*(Rs
+Incremental Plot Mode (Ctrl-^).
+.IP \\*(Us
+Alpha Mode (Ctrl-_).
+.Ed
+.
+.
+.Sh "VT52 Mode"
+.LP
+Parameters for cursor movement are at the end of the \*(Es\*Y escape sequence.
+Each ordinate is encoded in a single character as \fIvalue\fP+32.
+For example, \*! is 1.
+The screen coordinate system is 0-based.
+.St
+.IP \\*(Es\\*A
+Cursor up.
+.IP \\*(Es\\*(cB
+Cursor down.
+.IP \\*(Es\\*C
+Cursor right.
+.IP \\*(Es\\*D
+Cursor left.
+.IP \\*(Es\\*F
+Enter graphics mode.
+.IP \\*(Es\\*G
+Exit graphics mode.
+.IP \\*(Es\\*H
+Move the cursor to the home position.
+.IP \\*(Es\\*I
+Reverse line feed.
+.IP \\*(Es\\*J
+Erase from the cursor to the end of the screen.
+.IP \\*(Es\\*K
+Erase from the cursor to the end of the line.
+.IP \\*(Es\\*Y\\*(Ps\\*s\\*(Ps
+Move the cursor to given row and column.
+.IP \\*(Es\\*Z
+Identify.
+  \(-> \*(Es\*s\*/\*s\*Z (``I am a VT52.'').
+.IP \\*(Es\\*=
+Enter alternate keypad mode.
+.IP \\*(Es\\*>
+Exit alternate keypad mode.
+.IP \\*(Es\\*<
+Exit VT52 mode (Enter VT100 mode).
+.Ed
+.
+.if n .pl \n(nlu+1v
diff --git a/ctlseqs.txt b/ctlseqs.txt
new file mode 100644 (file)
index 0000000..be4fa2c
--- /dev/null
@@ -0,0 +1,1536 @@
+
+
+
+
+
+
+
+
+
+                        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-2010)
+
+
+
+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).  This
+     affects next character only.
+ESC O
+     Single Shift Select of G3 Character Set (SS3  is 0x8f).  This
+     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
+feature 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 is treated the same as LF.
+LF        Line Feed or New Line (NL).  (LF is Ctrl-J).
+SI        Shift In (Ctrl-O) -> Switch to Standard Character Set.  This
+          invokes the G0 character set (the default).
+SO        Shift Out (Ctrl-N) -> Switch to Alternate Character Set.  This
+          invokes the G1 character set.
+SP        Space.
+TAB       Horizontal Tab (HT) (Ctrl-I).
+VT        Vertical Tab (Ctrl-K).  This is treated the same as LF.
+
+Controls beginning with ESC
+This excludes controls where ESC is part of a 7-bit equivalent to 8-bit
+C1 controls, ordered by the final character(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.  That is ISO 8859-1 (ISO 2022).
+ESC % G   Select UTF-8 character set (ISO 2022).
+ESC ( C   Designate G0 Character Set (ISO 2022, VT100).
+          Final character C for designating 94-character sets.  In this
+          list, 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 (ISO 2022, VT100).
+          The same character sets apply as for ESC ( C.
+ESC * C   Designate G2 Character Set (ISO 2022, VT220).
+          The same character sets apply as for ESC ( C.
+ESC + C   Designate G3 Character Set (ISO 2022, VT220).
+          The same character sets apply as for ESC ( C.
+ESC - C   Designate G1 Character Set (VT300).
+          The same character sets apply as for ESC ( C.
+ESC . C   Designate G2 Character Set (VT300).
+          The same character sets apply as for ESC ( C.
+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.  This is 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 None.  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 + p Pt ST
+          Set Termcap/Terminfo Data (xterm, experimental).  The string
+          following the "p" is a name to use for retrieving data from
+          the terminal database.  The data will be used for the "tcap"
+          keyboard configuration's function- and special-keys, as well
+          as by the Request Termcap/Terminfo String control.
+DCS + q Pt ST
+          Request Termcap/Terminfo String (xterm, experimental).  The
+          string following the "q" is a list of names encoded in hexa-
+          decimal (2 digits per character) separated by ; which corre-
+          spond to termcap or terminfo key names.
+          Two special features are also recognized, which are not key
+          names: Co for termcap colors (or colors for terminfo colors),
+          and TN for termcap name (or name for terminfo name).
+          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; Ps T
+          Reset one or more features of the title modes to the default
+          value.  Normally, "reset" disables the feature.  It is possi-
+          ble to disable the ability to reset features by compiling a
+          different default for the title modes into xterm.
+            Ps = 0  -> Do not set window/icon labels using hexadecimal.
+            Ps = 1  -> Do not query window/icon labels using hexadeci-
+          mal.
+            Ps = 2  -> Do not set window/icon labels using UTF-8.
+            Ps = 3  -> Do not query window/icon labels using UTF-8.
+          (See discussion of "Title Modes").
+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:
+            Ps = 1  -> 132-columns.
+            Ps = 2  -> Printer.
+            Ps = 6  -> Selective erase.
+            Ps = 8  -> User-defined keys.
+            Ps = 9  -> National replacement character sets.
+            Ps = 1 5  -> Technical characters.
+            Ps = 2 2  -> ANSI color, e.g., VT525.
+            Ps = 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
+            Pp = 0  -> ``VT100''.
+            Pp = 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.  This is normally disabled by a
+          compile-time option.
+            Ps = 4 7  -> Use Alternate Screen Buffer.  (This may be dis-
+          abled 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 0 5  -> Enable Extended Mouse Mode.
+            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.  (This enables the numLock resource).
+            Ps = 1 0 3 6  -> Send ESC when Meta modifies a key.  (This
+          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.  (This
+          enables the altSendsEscape resource).
+            Ps = 1 0 4 0  -> Keep selection even if not highlighted.
+          (This enables the keepSelection resource).
+            Ps = 1 0 4 1  -> Use the CLIPBOARD selection.  (This enables
+          the selectToClipboard resource).
+            Ps = 1 0 4 2  -> Enable Urgency window manager hint when
+          Control-G is received.  (This 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.  (This may be
+          disabled by the titeInhibit resource).
+            Ps = 1 0 4 8  -> Save cursor as in DECSC.  (This may be dis-
+          abled by the titeInhibit resource).
+            Ps = 1 0 4 9  -> Save cursor as in DECSC and use Alternate
+          Screen Buffer, clearing it first.  (This may be 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  -> 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.  (This is 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 0 5  -> Disable Extended Mouse Mode.
+            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.  (This disables
+          the eightBitInput resource).
+            Ps = 1 0 3 5  -> Disable special modifiers for Alt and Num-
+          Lock keys.  (This disables the numLock resource).
+            Ps = 1 0 3 6  -> Don't send ESC when Meta modifies a key.
+          (This 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.
+          (This disables the altSendsEscape resource).
+            Ps = 1 0 4 0  -> Do not keep selection when not highlighted.
+          (This disables the keepSelection resource).
+            Ps = 1 0 4 1  -> Use the PRIMARY selection.  (This disables
+          the selectToClipboard resource).
+            Ps = 1 0 4 2  -> Disable Urgency window manager hint when
+          Control-G is received.  (This disables the bellIsUrgent
+          resource).
+            Ps = 1 0 4 3  -> Disable raising of the window when Control-
+          G is received.  (This disables the popOnBell resource).
+            Ps = 1 0 4 7  -> Use Normal Screen Buffer, clearing screen
+          first if in the Alternate Screen.  (This may be disabled by
+          the titeInhibit resource).
+            Ps = 1 0 4 8  -> Restore cursor as in DECRC.  (This may be
+          disabled by the titeInhibit resource).
+            Ps = 1 0 4 9  -> Use Normal Screen Buffer and restore cursor
+          as in DECRC.  (This may be 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.
+            Ps = 1  -> modifyCursorKeys.
+            Ps = 2  -> modifyFunctionKeys.
+            Ps = 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.  Result (``OK'') is
+          CSI 0 n
+            Ps = 6  -> Report Cursor Position (CPR) [row;column].
+          Result is
+          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:
+            Ps = 1  -> modifyCursorKeys.
+            Ps = 2  -> modifyFunctionKeys.
+            Ps = 4  -> modifyOtherKeys.
+          If the parameter is omitted, modifyFunctionKeys is disabled.
+          When modifyFunctionKeys is disabled, xterm uses the modifier
+          keys to make an extended sequence of functions rather than
+          adding a parameter to each function key to denote the modi-
+          fiers.
+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.  This is 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$ p
+          Request ANSI mode (DECRQM).  For VT300 and up, reply is
+            CSI Ps; Pm$ y
+          where Ps is the mode number as in RM, and Pm is the mode
+          value:
+            0 - not recognized
+            1 - set
+            2 - reset
+            3 - permanently set
+            4 - permanently reset
+CSI ? Ps$ p
+          Request DEC private mode (DECRQM).  For VT300 and up, reply is
+            CSI ? Ps; Pm$ p
+          where Ps is the mode number as in DECSET, Pm is the mode value
+          as in the ANSI DECRQM.
+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  Load LEDs (DECLL).
+            Ps = 0  -> Clear all LEDS (default).
+            Ps = 1  -> Light Num Lock.
+            Ps = 2  -> Light Caps Lock.
+            Ps = 3  -> Light Scroll Lock.
+            Ps = 2  1  -> Extinguish Num Lock.
+            Ps = 2  2  -> Extinguish Caps Lock.
+            Ps = 2  3  -> Extinguish Scroll Lock.
+CSI Ps SP q
+          Set cursor style (DECSCUSR, VT520).
+            Ps = 0  -> blinking block.
+            Ps = 1  -> blinking block (default).
+            Ps = 2  -> steady block.
+            Ps = 3  -> blinking underline.
+            Ps = 4  -> steady underline.
+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), VT400 and up.
+            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.  Result is CSI 3
+          ; x ; y t
+            Ps = 1 4  -> Report xterm window in pixels.  Result is CSI
+          4  ;  height ;  width t
+            Ps = 1 8  -> Report the size of the text area in characters.
+          Result is CSI  8  ;  height ;  width t
+            Ps = 1 9  -> Report the size of the screen in characters.
+          Result is CSI  9  ;  height ;  width t
+            Ps = 2 0  -> Report xterm window's icon label.  Result is
+          OSC  L  label ST
+            Ps = 2 1  -> Report xterm window's title.  Result is OSC  l
+          label ST
+            Ps = 2 2  ;  0  -> Save xterm icon and window title on
+          stack.
+            Ps = 2 2  ;  1  -> Save xterm icon title on stack.
+            Ps = 2 2  ;  2  -> Save xterm window title on stack.
+            Ps = 2 3  ;  0  -> Restore xterm icon and window title from
+          stack.
+            Ps = 2 3  ;  1  -> Restore xterm icon title from stack.
+            Ps = 2 3  ;  2  -> Restore xterm window title from stack.
+            Ps >= 2 4  -> Resize to Ps lines (DECSLPP).
+CSI Pt; Pl; Pb; Pr; Ps$ t
+          Reverse Attributes in Rectangular Area (DECRARA), VT400 and
+          up.
+            Pt; Pl; Pb; Pr denotes the rectangle.
+            Ps denotes the attributes to reverse, i.e.,  1, 4, 5, 7.
+CSI > Ps; Ps t
+          Set one or more features of the title modes.  Each parameter
+          enables a single feature.
+            Ps = 0  -> Set window/icon labels using hexadecimal.
+            Ps = 1  -> Query window/icon labels using hexadecimal.
+            Ps = 2  -> Set window/icon labels using UTF-8.
+            Ps = 3  -> Query window/icon labels using UTF-8.  (See dis-
+          cussion of "Title Modes")
+CSI Ps SP t
+          Set warning-bell volume (DECSWBV, VT520).
+            Ps = 0  or 1  -> off.
+            Ps = 2 , 3  or 4  -> low.
+            Ps = 5 , 6 , 7 , or 8  -> high.
+CSI u     Restore cursor (ANSI.SYS).
+CSI Ps SP u
+          Set margin-bell volume (DECSMBV, VT520).
+            Ps = 1  -> off.
+            Ps = 2 , 3  or 4  -> low.
+            Ps = 0 , 5 , 6 , 7 , or 8  -> high.
+CSI Pt; Pl; Pb; Pr; Pp; Pt; Pl; Pp$ v
+          Copy Rectangular Area (DECCRA, VT400 and up).
+            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), VT420 and up.
+          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.
+            Pn = 1  <- no parity.
+            Pn = 1  <- eight bits.
+            Pn = 1  <- 2  8  transmit 38.4k baud.
+            Pn = 1  <- 2  8  receive 38.4k baud.
+            Pn = 1  <- clock multiplier.
+            Pn = 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), VT420 and up.
+            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), VT400 and up.
+            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).
+                       (This is default).  It 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), VT400 and up.
+            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.  This can be 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.
+
+            Ps = 5  ; c ; spec -> Change Special Color Number c to the
+          color specified by spec.  This can be a name or RGB specifica-
+          tion as per XParseColor.  Any number of c name pairs may be
+          given.  The special colors can also be set by adding the maxi-
+          mum number of colors to these codes in an OSC 4  control:
+
+            Pc = 0  <- resource colorBD (BOLD).
+            Pc = 1  <- resource colorUL (UNDERLINE).
+            Pc = 2  <- resource colorBL (BLINK).
+            Pc = 3  <- resource colorRV (REVERSE).
+
+          The 8 colors (below) which may be set or queried using 1 0
+          through 1 7  are denoted dynamic colors, since the correspond-
+          ing 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.  These controls may be disabled
+          using the allowColorOps resource.  At least one parameter 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 specifi-
+          cation 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 background color to Pt.
+            Ps = 1 8  -> Change Tektronix cursor color to Pt.
+            Ps = 1 9  -> Change highlight foreground color to Pt.
+
+            Ps = 4 6  -> Change Log File to Pt.  (This is normally dis-
+          abled by a compile-time option).
+
+            Ps = 5 0  -> Set Font to Pt.  These controls may be disabled
+          using the allowFontOps resource.  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).
+          The same rule (plus or minus sign, optional number) is used
+          when querying the font.  The remainder of Pt is ignored.
+          A font can be specified after a "#" index expression, by
+          adding a space and then the font specifier.
+          If the "TrueType Fonts" menu entry is set (the renderFont
+          resource), then this control sets/queries the faceName
+          resource.
+
+            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.
+
+            Ps = 1 0 4  ; c -> Reset Color Number c.  It is reset to the
+          color specified by the corresponding X resource.  Any number
+          of c parameters may be given.  These parameters correspond to
+          the ANSI colors 0-7, their bright versions 8-15, and if sup-
+          ported, the remainder of the 88-color or 256-color table.  If
+          no parameters are given, the entire table will be reset.
+
+            Ps = 1 0 5  ; c -> Reset Special Color Number c.  It is
+          reset to the color specified by the corresponding X resource.
+          Any number of c parameters may be given.  These parameters
+          correspond to the special colors which can be set using an OSC
+          5  control (or by adding the maximum number of colors using an
+          OSC 4  control).
+
+          The dynamic colors can also be reset to their default
+          (resource) values:
+            Ps = 1 1 0  -> Reset VT100 text foreground color.
+            Ps = 1 1 1  -> Reset VT100 text background color.
+            Ps = 1 1 2  -> Reset text cursor color.
+            Ps = 1 1 3  -> Reset mouse foreground color.
+            Ps = 1 1 4  -> Reset mouse background color.
+            Ps = 1 1 5  -> Reset Tektronix foreground color.
+            Ps = 1 1 6  -> Reset Tektronix background color.
+            Ps = 1 1 7  -> Reset highlight color.
+            Ps = 1 1 8  -> Reset Tektronix cursor color.
+
+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 ~.
+
+Title Modes
+The window- and icon-labels can be set or queried using control
+sequences.  As a VT220-emulator, xterm "should" limit the character
+encoding for the corresponding strings to ISO-8859-1.  Indeed, it used
+to be the case (and was documented) that window titles had to be
+ISO-8859-1.  This is no longer the case.  However, there are many appli-
+cations which still assume that titles are set using ISO-8859-1.  So
+that is the default behavior.
+
+If xterm is running with UTF-8 encoding, it is possible to use window-
+and icon-labels encoded using UTF-8.  That is because the underlying X
+libraries (and many, but not all) window managers support this feature.
+
+The utf8Title X resource setting tells xterm to disable a reconversion
+of the title string back to ISO-8859-1, allowing the title strings to be
+interpreted as UTF-8.  The same feature can be enabled using the title
+mode control sequence described in this summary.
+
+Separate from the ability to set the titles, xterm provides the ability
+to query the titles, returning them either in ISO-8859-1 or UTF-8.  This
+choice is available only while xterm is using UTF-8 encoding.
+
+Finally, the characters sent to, or returned by a title control are less
+constrained than the rest of the control sequences.  To make them more
+manageable (and constrained), for use in shell scripts, xterm has an
+optional feature which decodes the string from hexadecimal (for setting
+titles) or for encoding the title into hexadecimal when querying the
+value.
+
+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
+the "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
+
+                #define SET_EXT_MODE_MOUSE          1005
+
+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).
+o   Cb is button-1.
+o   Cx and Cy are the x and y coordinates 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.
+o   The low two bits of Cb encode button information: 0=MB1 pressed,
+    1=MB2 pressed, 2=MB3 pressed, 3=release.
+o   The next three bits encode the modifiers which were down when the
+    button was pressed and are added together:  4=Shift, 8=Meta, 16=Con-
+    trol.  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 transla-
+    tions for button events.  The Meta modifier recognized by xterm is
+    the mod1 mask, and is not necessarily the "Meta" key (see xmodmap).
+o   Cx and Cy are the x and y coordinates 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 cooperating program or it will hang
+xterm.
+
+On button press, the same information as for normal tracking is gener-
+ated; xterm then waits for the program to send mouse tracking informa-
+tion.  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:
+o   if the start and end coordinates are the same locations:
+    CSI t CxCy.
+o   otherwise:
+    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.
+o   On button-motion events, xterm adds 32 to the event code (the third
+    character, Cb).
+o   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.
+
+Extended mouse mode enables UTF-8 encoding for Cx and Cy under all
+tracking modes, expanding the maximum encodable position from 223 to
+2015.  For positions less than 95, the resulting output is identical
+under both modes.  Under extended mouse mode, positions greater than 95
+generate "extra" bytes which will confuse applications which do not
+treat their input as a UTF-8 stream.  Likewise, Cb will be UTF-8
+encoded, to reduce confusion with wheel mouse events.
+
+NOTE: Under normal mouse mode, positions outside (160,94) result in byte
+pairs which can be interpreted as a single UTF-8 character; applications
+which do treat their input as UTF-8 will almost certainly be confused
+unless extended mouse mode is active.
+
+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 (ESC Ctrl-N).  (This is ignored by xterm).
+ESC SI    End 4015 APL mode (ESC Ctrl-O).  (This is ignored by xterm).
+ESC ETB   COPY (Save Tektronix Codes to file COPYyyyy-mm-dd.hh:mm:ss).
+            ETB  (end transmission block) is the same as 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.  (This is normally dis-
+          abled 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).
diff --git a/cursor.c b/cursor.c
new file mode 100644 (file)
index 0000000..e25a9f8
--- /dev/null
+++ b/cursor.c
@@ -0,0 +1,375 @@
+/* $XTermId: cursor.c,v 1.55 2010/04/17 17:12:01 tom Exp $ */
+
+/*
+ * Copyright 2002-2009,2010 by Thomas E. Dickey
+ * 
+ *                         All Rights Reserved
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ * 
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* cursor.c */
+
+#include <xterm.h>
+#include <data.h>
+#include <menu.h>
+
+#include <assert.h>
+
+/*
+ * Moves the cursor to the specified position, checking for bounds.
+ * (this includes scrolling regions)
+ * The origin is considered to be 0, 0 for this procedure.
+ */
+void
+CursorSet(TScreen * screen, int row, int col, unsigned flags)
+{
+    int use_row = row;
+    int max_row;
+
+    col = (col < 0 ? 0 : col);
+    set_cur_col(screen, (col <= screen->max_col ? col : screen->max_col));
+    max_row = screen->max_row;
+    if (flags & ORIGIN) {
+       use_row += screen->top_marg;
+       max_row = screen->bot_marg;
+    }
+    use_row = (use_row < 0 ? 0 : use_row);
+    set_cur_row(screen, (use_row <= max_row ? use_row : max_row));
+    screen->do_wrap = False;
+
+    TRACE(("CursorSet(%d,%d) margins [%d..%d] -> %d,%d %s\n",
+          row, col,
+          screen->top_marg,
+          screen->bot_marg,
+          screen->cur_row,
+          screen->cur_col,
+          (flags & ORIGIN ? "origin" : "normal")));
+}
+
+/*
+ * moves the cursor left n, no wrap around
+ */
+void
+CursorBack(XtermWidget xw, int n)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i, j, k, rev;
+
+    if ((rev = (xw->flags & (REVERSEWRAP | WRAPAROUND)) ==
+        (REVERSEWRAP | WRAPAROUND)) != 0
+       && screen->do_wrap)
+       n--;
+    if ((screen->cur_col -= n) < 0) {
+       if (rev) {
+           if ((i = ((j = MaxCols(screen))
+                     * screen->cur_row) + screen->cur_col) < 0) {
+               k = j * MaxRows(screen);
+               i += ((-i) / k + 1) * k;
+           }
+           set_cur_row(screen, i / j);
+           set_cur_col(screen, i % j);
+           do_xevents();
+       } else {
+           set_cur_col(screen, 0);
+       }
+    }
+    screen->do_wrap = False;
+}
+
+/*
+ * moves the cursor forward n, no wraparound
+ */
+void
+CursorForward(TScreen * screen, int n)
+{
+#if OPT_DEC_CHRSET
+    LineData *ld = getLineData(screen, screen->cur_row);
+#endif
+    int next = screen->cur_col + n;
+    int max = LineMaxCol(screen, ld);
+
+    if (next > max)
+       next = max;
+
+    set_cur_col(screen, next);
+    screen->do_wrap = False;
+}
+
+/*
+ * moves the cursor down n, no scrolling.
+ * Won't pass bottom margin or bottom of screen.
+ */
+void
+CursorDown(TScreen * screen, int n)
+{
+    int max;
+    int next = screen->cur_row + n;
+
+    max = (screen->cur_row > screen->bot_marg ?
+          screen->max_row : screen->bot_marg);
+    if (next > max)
+       next = max;
+    if (next > screen->max_row)
+       next = screen->max_row;
+
+    set_cur_row(screen, next);
+    screen->do_wrap = False;
+}
+
+/*
+ * moves the cursor up n, no linestarving.
+ * Won't pass top margin or top of screen.
+ */
+void
+CursorUp(TScreen * screen, int n)
+{
+    int min;
+    int next = screen->cur_row - n;
+
+    min = ((screen->cur_row < screen->top_marg)
+          ? 0
+          : screen->top_marg);
+    if (next < min)
+       next = min;
+    if (next < 0)
+       next = 0;
+
+    set_cur_row(screen, next);
+    screen->do_wrap = False;
+}
+
+/*
+ * Moves cursor down amount lines, scrolls if necessary.
+ * Won't leave scrolling region. No carriage return.
+ */
+void
+xtermIndex(XtermWidget xw, int amount)
+{
+    TScreen *screen = TScreenOf(xw);
+    int j;
+
+    /*
+     * indexing when below scrolling region is cursor down.
+     * if cursor high enough, no scrolling necessary.
+     */
+    if (screen->cur_row > screen->bot_marg
+       || screen->cur_row + amount <= screen->bot_marg) {
+       CursorDown(screen, amount);
+       return;
+    }
+
+    CursorDown(screen, j = screen->bot_marg - screen->cur_row);
+    xtermScroll(xw, amount - j);
+}
+
+/*
+ * Moves cursor up amount lines, reverse scrolls if necessary.
+ * Won't leave scrolling region. No carriage return.
+ */
+void
+RevIndex(XtermWidget xw, int amount)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    /*
+     * reverse indexing when above scrolling region is cursor up.
+     * if cursor low enough, no reverse indexing needed
+     */
+    if (screen->cur_row < screen->top_marg
+       || screen->cur_row - amount >= screen->top_marg) {
+       CursorUp(screen, amount);
+       return;
+    }
+
+    RevScroll(xw, amount - (screen->cur_row - screen->top_marg));
+    CursorUp(screen, screen->cur_row - screen->top_marg);
+}
+
+/*
+ * Moves Cursor To First Column In Line
+ * (Note: xterm doesn't implement SLH, SLL which would affect use of this)
+ */
+void
+CarriageReturn(TScreen * screen)
+{
+    set_cur_col(screen, 0);
+    screen->do_wrap = False;
+    do_xevents();
+}
+
+/*
+ * When resizing the window, if we're showing the alternate screen, we still
+ * have to adjust the saved cursor from the normal screen to account for
+ * shifting of the saved-line region in/out of the viewable window.
+ */
+void
+AdjustSavedCursor(XtermWidget xw, int adjust)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->whichBuf) {
+       SavedCursor *sc = &screen->sc[0];
+
+       if (adjust > 0) {
+           TRACE(("AdjustSavedCursor %d -> %d\n", sc->row, sc->row - adjust));
+           sc->row += adjust;
+       }
+    }
+}
+
+/*
+ * Save Cursor and Attributes
+ */
+void
+CursorSave(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    SavedCursor *sc = &screen->sc[screen->whichBuf];
+
+    sc->saved = True;
+    sc->row = screen->cur_row;
+    sc->col = screen->cur_col;
+    sc->flags = xw->flags;
+    sc->curgl = screen->curgl;
+    sc->curgr = screen->curgr;
+#if OPT_ISO_COLORS
+    sc->cur_foreground = xw->cur_foreground;
+    sc->cur_background = xw->cur_background;
+    sc->sgr_foreground = xw->sgr_foreground;
+#endif
+    memmove(sc->gsets, screen->gsets, sizeof(screen->gsets));
+}
+
+/*
+ * We save/restore all visible attributes, plus wrapping, origin mode, and the
+ * selective erase attribute.
+ */
+#define DECSC_FLAGS (ATTRIBUTES|ORIGIN|WRAPAROUND|PROTECTED)
+
+/*
+ * Restore Cursor and Attributes
+ */
+void
+CursorRestore(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    SavedCursor *sc = &screen->sc[screen->whichBuf];
+
+    /* Restore the character sets, unless we never did a save-cursor op.
+     * In that case, we'll reset the character sets.
+     */
+    if (sc->saved) {
+       memmove(screen->gsets, sc->gsets, sizeof(screen->gsets));
+       screen->curgl = sc->curgl;
+       screen->curgr = sc->curgr;
+    } else {
+       resetCharsets(screen);
+    }
+
+    UIntClr(xw->flags, DECSC_FLAGS);
+    UIntSet(xw->flags, sc->flags & DECSC_FLAGS);
+    CursorSet(screen,
+             ((xw->flags & ORIGIN)
+              ? sc->row - screen->top_marg
+              : sc->row),
+             sc->col, xw->flags);
+
+#if OPT_ISO_COLORS
+    xw->sgr_foreground = sc->sgr_foreground;
+    SGR_Foreground(xw, xw->flags & FG_COLOR ? sc->cur_foreground : -1);
+    SGR_Background(xw, xw->flags & BG_COLOR ? sc->cur_background : -1);
+#endif
+    update_autowrap();
+}
+
+/*
+ * Move the cursor to the first column of the n-th next line.
+ */
+void
+CursorNextLine(TScreen * screen, int count)
+{
+    CursorDown(screen, count < 1 ? 1 : count);
+    CarriageReturn(screen);
+    do_xevents();
+}
+
+/*
+ * Move the cursor to the first column of the n-th previous line.
+ */
+void
+CursorPrevLine(TScreen * screen, int count)
+{
+    CursorUp(screen, count < 1 ? 1 : count);
+    CarriageReturn(screen);
+    do_xevents();
+}
+
+#if OPT_TRACE
+int
+set_cur_row(TScreen * screen, int value)
+{
+    TRACE(("set_cur_row %d vs %d\n", value, screen ? screen->max_row : -1));
+
+    assert(screen != 0);
+    assert(value >= 0);
+    assert(value <= screen->max_row);
+    screen->cur_row = value;
+    return value;
+}
+
+int
+set_cur_col(TScreen * screen, int value)
+{
+    TRACE(("set_cur_col %d vs %d\n", value, screen ? screen->max_col : -1));
+
+    assert(screen != 0);
+    assert(value >= 0);
+    assert(value <= screen->max_col);
+    screen->cur_col = value;
+    return value;
+}
+#endif /* OPT_TRACE */
diff --git a/data.c b/data.c
new file mode 100644 (file)
index 0000000..7840f8b
--- /dev/null
+++ b/data.c
@@ -0,0 +1,116 @@
+/* $XTermId: data.c,v 1.91 2009/10/12 00:33:20 tom Exp $ */
+
+/*
+ * Copyright 2002-2006,2007 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <data.h>
+
+Widget toplevel;               /* top-most widget in xterm */
+
+#if OPT_TEK4014
+Char *Tpushb;
+Char *Tpushback;
+TekLink *tekRefreshList;
+TekWidget tekWidget;
+Widget tekshellwidget;
+int T_lastx = -1;
+int T_lasty = -1;
+int Ttoggled = 0;
+jmp_buf Tekend;
+#endif
+
+char *ProgramName;
+
+Arg ourTopLevelShellArgs[] =
+{
+    {XtNallowShellResize, (XtArgVal) True},
+    {XtNinput, (XtArgVal) True},
+};
+Cardinal number_ourTopLevelShellArgs = 2;
+
+Atom wm_delete_window;         /* for ICCCM delete window */
+
+XTERM_RESOURCE resource;
+
+PtyData *VTbuffer;
+
+jmp_buf VTend;
+
+#ifdef DEBUG
+int debug = 0;                 /* true causes error messages to be displayed */
+#endif /* DEBUG */
+
+XtAppContext app_con;
+XtermWidget term;              /* master data structure for client */
+char *xterm_name;              /* argv[0] */
+
+int hold_screen;
+SIG_ATOMIC_T need_cleanup = False;
+
+int am_slave = -1;             /* set to file-descriptor if we're a slave process */
+int max_plus1;
+PtySelect Select_mask;
+PtySelect X_mask;
+PtySelect pty_mask;
+char *ptydev;
+char *ttydev;
+
+#if HANDLE_STRUCT_NOTIFY
+int mapstate = -1;
+#endif /* HANDLE_STRUCT_NOTIFY */
+
+#if OPT_SESSION_MGT
+int ice_fd = -1;
+#endif
+
+#ifdef USE_IGNORE_RC
+int ignore_unused;
+#endif
diff --git a/data.h b/data.h
new file mode 100644 (file)
index 0000000..edeefe8
--- /dev/null
+++ b/data.h
@@ -0,0 +1,218 @@
+/* $XTermId: data.h,v 1.110 2009/10/12 00:33:08 tom Exp $ */
+
+/*
+ * Copyright 2002-2007,2009 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef included_data_h
+#define included_data_h 1
+
+#include <xterm.h>
+
+extern Widget toplevel;
+
+extern XtAppContext app_con;
+
+#ifdef VMS
+/* actually in vms.c */
+extern int tt_width;
+extern int tt_length;
+extern int tt_changed;
+extern int tt_pasting;
+extern int tt_new_output;
+#define VMS_TERM_BUFFER_SIZE   500
+struct q_head {
+    int flink;
+    int blink;
+};
+extern struct q_head read_queue;
+#endif
+
+#if OPT_TEK4014
+extern Char *Tpushb;
+extern Char *Tpushback;
+extern TekLink *tekRefreshList;
+extern TekWidget tekWidget;
+extern Widget tekshellwidget;
+extern int T_lastx;
+extern int T_lasty;
+extern int Ttoggled;
+extern jmp_buf Tekend;
+#endif
+
+extern char *ptydev;
+extern char *ttydev;
+extern char *xterm_name;
+extern int hold_screen;
+
+extern PtyData *VTbuffer;
+extern int am_slave;
+extern int max_plus1;
+extern jmp_buf VTend;
+
+#ifdef DEBUG
+extern int debug;
+#endif /* DEBUG */
+
+extern PtySelect Select_mask;
+extern PtySelect X_mask;
+extern PtySelect pty_mask;
+
+extern int ice_fd;
+
+extern XtermWidget term;
+
+extern SIG_ATOMIC_T need_cleanup;
+
+#if defined(HAVE_XKB_BELL_EXT)
+#include <X11/XKBlib.h>                /* has the prototype */
+#include <X11/extensions/XKBbells.h>   /* has the XkbBI_xxx definitions */
+#endif
+
+#ifndef XkbBI_Info
+#define        XkbBI_Info                      0
+#define        XkbBI_MinorError                1
+#define        XkbBI_MajorError                2
+#define        XkbBI_TerminalBell              9
+#define        XkbBI_MarginBell                10
+#endif
+
+extern char *ProgramName;
+extern Arg ourTopLevelShellArgs[];
+extern Cardinal number_ourTopLevelShellArgs;
+extern Atom wm_delete_window;
+
+#if HANDLE_STRUCT_NOTIFY
+/* Flag icon name with "*** "  on window output when iconified.
+ * I'd like to do something like reverse video, but I don't
+ * know how to tell this to window managers in general.
+ *
+ * mapstate can be IsUnmapped, !IsUnmapped, or -1;
+ * -1 means no change; the other two are set by event handlers
+ * and indicate a new mapstate.  !IsMapped is done in the handler.
+ * we worry about IsUnmapped when output occurs.  -IAN!
+ */
+extern int mapstate;
+#endif /* HANDLE_STRUCT_NOTIFY */
+
+typedef struct XTERM_RESOURCE {
+    char *xterm_name;
+    char *icon_geometry;
+    char *title;
+    char *icon_name;
+    char *term_name;
+    char *tty_modes;
+
+    int minBufSize;
+    int maxBufSize;
+
+    Boolean hold_screen;       /* true if we keep window open  */
+    Boolean utmpInhibit;
+    Boolean utmpDisplayId;
+    Boolean messages;
+
+    String menuLocale;
+
+    String keyboardType;
+#if OPT_SUNPC_KBD
+    Boolean sunKeyboard;
+#endif
+#if OPT_HP_FUNC_KEYS
+    Boolean hpFunctionKeys;
+#endif
+#if OPT_SCO_FUNC_KEYS
+    Boolean scoFunctionKeys;
+#endif
+#if OPT_SUN_FUNC_KEYS
+    Boolean sunFunctionKeys;   /* %%% should be VT100 widget resource? */
+#endif
+#if OPT_TCAP_FKEYS
+    Boolean termcapKeys;
+#endif
+
+#if OPT_INITIAL_ERASE
+    Boolean ptyInitialErase;   /* if true, use pty's sense of erase char */
+    Boolean backarrow_is_erase;        /* override backspace/delete */
+#endif
+    Boolean useInsertMode;
+#if OPT_ZICONBEEP
+    int zIconBeep;             /* beep level when output while iconified */
+#endif
+#if OPT_PTY_HANDSHAKE
+    Boolean wait_for_map;
+    Boolean wait_for_map0;     /* ...initial value of .wait_for_map */
+    Boolean ptyHandshake;      /* use pty-handshaking */
+    Boolean ptySttySize;       /* reset TTY size after pty handshake */
+#endif
+#if OPT_SAME_NAME
+    Boolean sameName;          /* Don't change the title or icon name if it is
+                                * the same.  This prevents flicker on the
+                                * screen at the cost of an extra request to
+                                * the server.
+                                */
+#endif
+#if OPT_SESSION_MGT
+    Boolean sessionMgt;
+#endif
+#if OPT_TOOLBAR
+    Boolean toolBar;
+#endif
+#if OPT_MAXIMIZE
+    Boolean maximized;
+#endif
+} XTERM_RESOURCE;
+
+extern XTERM_RESOURCE resource;
+
+#ifdef USE_IGNORE_RC
+extern int ignore_unused;
+#endif
+
+#endif /* included_data_h */
diff --git a/doublechr.c b/doublechr.c
new file mode 100644 (file)
index 0000000..6b1d030
--- /dev/null
@@ -0,0 +1,303 @@
+/* $XTermId: doublechr.c,v 1.75 2010/06/15 10:58:13 tom Exp $ */
+
+/************************************************************
+
+Copyright 1997-2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <xterm.h>
+#include <data.h>
+#include <fontutils.h>
+
+#include <assert.h>
+
+#define WhichCgsId(flag) (((flag) & BOLD) ? gcCBold : gcCNorm)
+
+/*
+ * The first column is all that matters for double-size characters (since the
+ * controls apply to a whole line).  However, it's easier to maintain the
+ * information for special fonts by writing to all cells.
+ */
+#if OPT_DEC_CHRSET
+
+static void
+repaint_line(XtermWidget xw, unsigned newChrSet)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    int curcol = screen->cur_col;
+    int currow = screen->cur_row;
+    int width = MaxCols(screen);
+    unsigned len = (unsigned) width;
+
+    assert(width > 0);
+
+    /*
+     * Ignore repetition.
+     */
+    if ((ld = getLineData(screen, currow)) != 0) {
+       unsigned oldChrSet = GetLineDblCS(ld);
+
+       if (oldChrSet != newChrSet) {
+           TRACE(("repaint_line(%2d,%2d) (%s -> %s)\n", currow, screen->cur_col,
+                  visibleChrsetName(oldChrSet),
+                  visibleChrsetName(newChrSet)));
+           HideCursor();
+
+           /* If switching from single-width, keep the cursor in the visible part
+            * of the line.
+            */
+           if (CSET_DOUBLE(newChrSet)) {
+               width /= 2;
+               if (curcol > width)
+                   curcol = width;
+           }
+
+           /*
+            * ScrnRefresh won't paint blanks for us if we're switching between a
+            * single-size and double-size font.  So we paint our own.
+            */
+           ClearCurBackground(xw,
+                              CursorY(screen, currow),
+                              LineCursorX(screen, ld, 0),
+                              (unsigned) FontHeight(screen),
+                              len * (unsigned) LineFontWidth(screen, ld));
+
+           SetLineDblCS(ld, newChrSet);
+
+           set_cur_col(screen, 0);
+           ScrnUpdate(xw, currow, 0, 1, (int) len, True);
+           set_cur_col(screen, curcol);
+       }
+    }
+}
+#endif
+
+/*
+ * Set the line to double-height characters.  The 'top' flag denotes whether
+ * we'll be using it for the top (true) or bottom (false) of the line.
+ */
+void
+xterm_DECDHL(XtermWidget xw GCC_UNUSED, Bool top)
+{
+#if OPT_DEC_CHRSET
+    repaint_line(xw, (unsigned) (top ? CSET_DHL_TOP : CSET_DHL_BOT));
+#else
+    (void) top;
+#endif
+}
+
+/*
+ * Set the line to single-width characters (the normal state).
+ */
+void
+xterm_DECSWL(XtermWidget xw GCC_UNUSED)
+{
+#if OPT_DEC_CHRSET
+    repaint_line(xw, CSET_SWL);
+#endif
+}
+
+/*
+ * Set the line to double-width characters
+ */
+void
+xterm_DECDWL(XtermWidget xw GCC_UNUSED)
+{
+#if OPT_DEC_CHRSET
+    repaint_line(xw, CSET_DWL);
+#endif
+}
+
+#if OPT_DEC_CHRSET
+static void
+discard_font(XtermWidget xw, int n)
+{
+    TScreen *screen = TScreenOf(xw);
+    XTermFonts *data = &(screen->double_fonts[n]);
+
+    TRACE(("discard_font chrset=%d %s\n", data->chrset,
+          (data->fn != 0) ? data->fn : "<no-name>"));
+
+    data->chrset = 0;
+    data->flags = 0;
+    if (data->fn != 0) {
+       free(data->fn);
+       data->fn = 0;
+    }
+    (void) xtermCloseFont(xw, data);
+
+    screen->fonts_used -= 1;
+    while (n < screen->fonts_used) {
+       screen->double_fonts[n] = screen->double_fonts[n + 1];
+       ++n;
+    }
+}
+
+/* push back existing fonts and create a new entry */
+static XTermFonts *
+pushback_font(XtermWidget xw, XTermFonts * source)
+{
+    TScreen *screen = TScreenOf(xw);
+    XTermFonts *data = screen->double_fonts;
+    int n;
+
+    if (screen->fonts_used >= screen->cache_doublesize) {
+       TRACE(("pushback_font: discard oldest\n"));
+       discard_font(xw, screen->fonts_used - 1);
+    } else {
+       screen->fonts_used += 1;
+    }
+
+    for (n = screen->fonts_used; n > 0; n--)
+       data[n] = data[n - 1];
+    data[0] = *source;
+
+    TRACE(("pushback_font -> (NEW:%d)\n", screen->fonts_used));
+
+    return data;
+}
+
+int
+xterm_Double_index(XtermWidget xw, unsigned chrset, unsigned flags)
+{
+    int n;
+    int result = -1;
+    TScreen *screen = TScreenOf(xw);
+    XTermFonts *data = screen->double_fonts;
+
+    flags &= BOLD;
+    TRACE(("xterm_Double_index chrset=%#x, flags=%#x\n", chrset, flags));
+
+    for (n = 0; n < screen->fonts_used; n++) {
+       if (data[n].chrset == chrset
+           && data[n].flags == flags) {
+           if (n != 0) {
+               XTermFonts save;
+               TRACE(("...xterm_Double_index -> %d (OLD:%d)\n", n, screen->fonts_used));
+               save = data[n];
+               while (n > 0) {
+                   data[n] = data[n - 1];
+                   n--;
+               }
+               data[n] = save;
+           }
+           result = n;
+           break;
+       }
+    }
+
+    return result;
+}
+
+/*
+ * Lookup/cache a GC for the double-size character display.  We save up to
+ * NUM_CHRSET values.
+ */
+GC
+xterm_DoubleGC(XtermWidget xw,
+              unsigned chrset,
+              unsigned flags,
+              GC old_gc,
+              int *inxp)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *cgsWin = WhichVWin(screen);
+    int n;
+    char *name;
+    XTermFonts *data = 0;
+    GC result = 0;
+
+    if ((name = xtermSpecialFont(screen, flags, chrset)) != 0) {
+       CgsEnum cgsId = WhichCgsId(flags);
+       Boolean found = False;
+
+       if ((n = xterm_Double_index(xw, chrset, flags)) >= 0) {
+           data = &(screen->double_fonts[n]);
+           if (data->fn != 0) {
+               if (!strcmp(data->fn, name)
+                   && data->fs != 0) {
+                   found = True;
+                   free(name);
+               } else {
+                   discard_font(xw, n);
+               }
+           }
+       }
+
+       if (!found) {
+           XTermFonts temp;
+
+           TRACE(("xterm_DoubleGC %s %d: %s\n",
+                  flags & BOLD ? "BOLD" : "NORM", n, name));
+
+           memset(&temp, 0, sizeof(temp));
+           temp.fn = name;
+           temp.chrset = chrset;
+           temp.flags = (flags & BOLD);
+
+           if (!xtermOpenFont(xw, name, &temp, fwAlways, False)) {
+               /* Retry with * in resolutions */
+               char *nname = xtermSpecialFont(screen, flags | NORESOLUTION, chrset);
+
+               if (nname != 0) {
+                   found = (Boolean) xtermOpenFont(xw, nname, &temp,
+                                                   fwAlways, False);
+                   free(nname);
+               }
+           } else {
+               found = True;
+           }
+           free(name);
+
+           if (found) {
+               n = 0;
+               data = pushback_font(xw, &temp);
+           }
+
+           TRACE(("-> %s\n", found ? "OK" : "FAIL"));
+       }
+
+       if (found) {
+           setCgsCSet(xw, cgsWin, cgsId, chrset);
+           setCgsFont(xw, cgsWin, cgsId, data);
+           setCgsFore(xw, cgsWin, cgsId, getCgsFore(xw, cgsWin, old_gc));
+           setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, old_gc));
+           result = getCgsGC(xw, cgsWin, cgsId);
+           *inxp = n;
+       } else if (flags & BOLD) {
+           UIntClr(flags, BOLD);
+           result = xterm_DoubleGC(xw, chrset, flags, old_gc, inxp);
+       }
+    }
+
+    return result;
+}
+#endif
diff --git a/error.h b/error.h
new file mode 100644 (file)
index 0000000..0ab85bb
--- /dev/null
+++ b/error.h
@@ -0,0 +1,79 @@
+/* $XTermId: error.h,v 1.23 2010/05/21 21:03:27 tom Exp $ */
+
+/*
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* @(#)error.h X10/6.6 11/6/86 */
+
+/* main.c */
+#define        ERROR_FIONBIO   11      /* main: ioctl() failed on FIONBIO */
+#define        ERROR_F_GETFL   12      /* main: ioctl() failed on F_GETFL */
+#define        ERROR_F_SETFL   13      /* main: ioctl() failed on F_SETFL */
+#define        ERROR_OPDEVTTY  14      /* spawn: open() failed on /dev/tty */
+#define        ERROR_TIOCGETP  15      /* spawn: ioctl() failed on TIOCGETP */
+#define ERROR_PTSNAME   17     /* spawn: ptsname() failed */
+#define ERROR_OPPTSNAME 18     /* spawn: open() failed on ptsname */
+#define ERROR_PTEM      19     /* spawn: ioctl() failed on I_PUSH/"ptem" */
+#define ERROR_CONSEM    20     /* spawn: ioctl() failed on I_PUSH/"consem" */
+#define ERROR_LDTERM    21     /* spawn: ioctl() failed on I_PUSH/"ldterm" */
+#define ERROR_TTCOMPAT  22     /* spawn: ioctl() failed on I_PUSH/"ttcompat" */
+#define        ERROR_TIOCSETP  23      /* spawn: ioctl() failed on TIOCSETP */
+#define        ERROR_TIOCSETC  24      /* spawn: ioctl() failed on TIOCSETC */
+#define        ERROR_TIOCSETD  25      /* spawn: ioctl() failed on TIOCSETD */
+#define        ERROR_TIOCSLTC  26      /* spawn: ioctl() failed on TIOCSLTC */
+#define        ERROR_TIOCLSET  27      /* spawn: ioctl() failed on TIOCLSET */
+#define        ERROR_INIGROUPS 28      /* spawn: initgroups() failed */
+#define        ERROR_FORK      29      /* spawn: fork() failed */
+#define        ERROR_EXEC      30      /* spawn: exec() failed */
+#define        ERROR_PTYS      32      /* get_pty: not enough ptys */
+#define ERROR_PTY_EXEC 34      /* waiting for initial map */
+#define        ERROR_SETUID    35      /* spawn: setuid() failed */
+#define        ERROR_INIT      36      /* spawn: can't initialize window */
+#define        ERROR_TIOCKSET  46      /* spawn: ioctl() failed on TIOCKSET */
+#define        ERROR_TIOCKSETC 47      /* spawn: ioctl() failed on TIOCKSETC */
+#define        ERROR_LUMALLOC  49      /* luit: command-line malloc failed */
+
+/* charproc.c */
+#define        ERROR_SELECT    50      /* in_put: select() failed */
+#define        ERROR_VINIT     54      /* VTInit: can't initialize window */
+#define        ERROR_KMMALLOC1 57      /* HandleKeymapChange: malloc failed */
+
+/* Tekproc.c */
+#define        ERROR_TSELECT   60      /* Tinput: select() failed */
+#define        ERROR_TINIT     64      /* TekInit: can't initialize window */
+
+/* button.c */
+#define        ERROR_BMALLOC2  71      /* SaltTextAway: malloc() failed */
+
+/* misc.c */
+#define        ERROR_LOGEXEC   80      /* StartLog: exec() failed */
+#define        ERROR_XERROR    83      /* xerror: XError event */
+#define        ERROR_XIOERROR  84      /* xioerror: X I/O error */
+
+/* screen.c */
+#define        ERROR_SCALLOC   90      /* Alloc: calloc() failed on base */
+#define        ERROR_SCALLOC2  91      /* Alloc: calloc() failed on rows */
+#define        ERROR_SAVE_PTR  102     /* ScrnPointers: malloc/realloc() failed */
+
+/* util.c */
+#define        ERROR_MMALLOC   121     /* my_memmove: malloc/realloc failed */
diff --git a/fontutils.c b/fontutils.c
new file mode 100644 (file)
index 0000000..87d99a3
--- /dev/null
@@ -0,0 +1,3068 @@
+/* $XTermId: fontutils.c,v 1.353 2010/10/23 00:27:22 tom Exp $ */
+
+/************************************************************
+
+Copyright 1998-2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+/*
+ * A portion of this module (for FontNameProperties) was adapted from EMU 1.3;
+ * it constructs font names with specific properties changed, e.g., for bold
+ * and double-size characters.
+ */
+
+#define RES_OFFSET(field)      XtOffsetOf(SubResourceRec, field)
+
+#include <fontutils.h>
+#include <X11/Xmu/Drawing.h>
+#include <X11/Xmu/CharSet.h>
+
+#include <main.h>
+#include <data.h>
+#include <menu.h>
+#include <xstrings.h>
+#include <xterm.h>
+
+#include <stdio.h>
+#include <ctype.h>
+
+/* from X11/Xlibint.h - not all vendors install this file */
+#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
+                            (((cs)->rbearing|(cs)->lbearing| \
+                              (cs)->ascent|(cs)->descent) == 0))
+
+#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
+{ \
+    cs = def; \
+    if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+       if (fs->per_char == NULL) { \
+           cs = &fs->min_bounds; \
+       } else { \
+           cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
+           if (CI_NONEXISTCHAR(cs)) cs = def; \
+       } \
+    } \
+}
+
+#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
+{ \
+    cs = def; \
+    if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
+       col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+       if (fs->per_char == NULL) { \
+           cs = &fs->min_bounds; \
+       } else { \
+           cs = &fs->per_char[((row - fs->min_byte1) * \
+                               (fs->max_char_or_byte2 - \
+                                fs->min_char_or_byte2 + 1)) + \
+                              (col - fs->min_char_or_byte2)]; \
+           if (CI_NONEXISTCHAR(cs)) cs = def; \
+       } \
+    } \
+}
+
+#define MAX_FONTNAME 200
+
+/*
+ * A structure to hold the relevant properties from a font
+ * we need to make a well formed font name for it.
+ */
+typedef struct {
+    /* registry, foundry, family */
+    char *beginning;
+    /* weight */
+    char *weight;
+    /* slant */
+    char *slant;
+    /* wideness */
+    char *wideness;
+    /* add style */
+    char *add_style;
+    int pixel_size;
+    char *point_size;
+    int res_x;
+    int res_y;
+    char *spacing;
+    int average_width;
+    /* charset registry, charset encoding */
+    char *end;
+} FontNameProperties;
+
+#if OPT_SHIFT_FONTS
+static void lookupOneFontSize(XtermWidget, int);
+#endif
+
+#if OPT_WIDE_CHARS
+static unsigned
+countGlyphs(XFontStruct * fp)
+{
+    unsigned count = 0;
+
+    if (fp != 0) {
+       if (fp->min_byte1 == 0 && fp->max_byte1 == 0) {
+           count = fp->max_char_or_byte2 - fp->min_char_or_byte2;
+       } else if (fp->min_char_or_byte2 < 256
+                  && fp->max_char_or_byte2 < 256) {
+           unsigned first = (fp->min_byte1 << 8) + fp->min_char_or_byte2;
+           unsigned last = (fp->max_byte1 << 8) + fp->max_char_or_byte2;
+           count = last + 1 - first;
+       }
+    }
+    return count;
+}
+
+/*
+ * Verify that the wide-bold font is at least a bold font with roughly as many
+ * glyphs as the wide font.  The counts should be the same, but settle for
+ * filtering out the worst of the font mismatches.
+ */
+static Bool
+compatibleWideCounts(XFontStruct * wfs, XFontStruct * wbfs)
+{
+    unsigned count_w = countGlyphs(wfs);
+    unsigned count_wb = countGlyphs(wbfs);
+    if (count_w <= 256 ||
+       count_wb <= 256 ||
+       ((count_w / 4) * 3) > count_wb) {
+       TRACE(("...font server lied (count wide %u vs wide-bold %u)\n",
+              count_w, count_wb));
+       return False;
+    }
+    return True;
+}
+#endif /* OPT_WIDE_CHARS */
+
+#if OPT_BOX_CHARS
+static void
+setupPackedFonts(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Bool value = False;
+
+#if OPT_RENDERFONT
+#define MIXED(name) screen->name[fontnum].map.mixed
+    if (xw->misc.render_font == True) {
+       int fontnum = screen->menu_font_number;
+
+       screen->allow_packing = (Boolean) (MIXED(renderFontNorm)
+                                          || MIXED(renderFontBold)
+                                          || MIXED(renderFontItal)
+#if OPT_RENDERWIDE
+                                          || MIXED(renderWideNorm)
+                                          || MIXED(renderWideBold)
+                                          || MIXED(renderWideItal)
+#endif
+           );
+#undef MIXED
+    }
+#endif /* OPT_RENDERFONT */
+
+    value = screen->allow_packing;
+
+    SetItemSensitivity(fontMenuEntries[fontMenu_font_packedfont].widget, value);
+}
+#endif
+
+/*
+ * Returns the fields from start to stop in a dash- separated string.  This
+ * function will modify the source, putting '\0's in the appropiate place and
+ * moving the beginning forward to after the '\0'
+ *
+ * This will NOT work for the last field (but we won't need it).
+ */
+static char *
+n_fields(char **source, int start, int stop)
+{
+    int i;
+    char *str, *str1;
+
+    /*
+     * find the start-1th dash
+     */
+    for (i = start - 1, str = *source; i; i--, str++)
+       if ((str = strchr(str, '-')) == 0)
+           return 0;
+
+    /*
+     * find the stopth dash
+     */
+    for (i = stop - start + 1, str1 = str; i; i--, str1++)
+       if ((str1 = strchr(str1, '-')) == 0)
+           return 0;
+
+    /*
+     * put a \0 at the end of the fields
+     */
+    *(str1 - 1) = '\0';
+
+    /*
+     * move source forward
+     */
+    *source = str1;
+
+    return str;
+}
+
+static Boolean
+check_fontname(const char *name)
+{
+    Boolean result = True;
+
+    if (IsEmpty(name)) {
+       TRACE(("fontname missing\n"));
+       result = False;
+    } else if (strlen(name) >= MAX_FONTNAME - 1) {
+       TRACE(("fontname too large: %s\n", name));
+       result = False;
+    }
+    return result;
+}
+
+/*
+ * Gets the font properties from a given font structure.  We use the FONT name
+ * to find them out, since that seems easier.
+ *
+ * Returns a pointer to a static FontNameProperties structure
+ * or NULL on error.
+ */
+static FontNameProperties *
+get_font_name_props(Display * dpy, XFontStruct * fs, char *result)
+{
+    static FontNameProperties props;
+    static char *last_name;
+
+    XFontProp *fp;
+    int i;
+    Atom fontatom = XInternAtom(dpy, "FONT", False);
+    char *name = 0;
+    char *str;
+
+    /*
+     * first get the full font name
+     */
+    if (fontatom != 0) {
+       for (i = 0, fp = fs->properties; i < fs->n_properties; i++, fp++) {
+           if (fp->name == fontatom) {
+               name = XGetAtomName(dpy, fp->card32);
+               break;
+           }
+       }
+    }
+
+    if (name == 0)
+       return 0;
+
+    /*
+     * XGetAtomName allocates memory - don't leak
+     */
+    if (last_name != 0)
+       XFree(last_name);
+    last_name = name;
+
+    if (result != 0) {
+       if (!check_fontname(name))
+           return 0;
+       strcpy(result, name);
+    }
+
+    /*
+     * Now split it up into parts and put them in
+     * their places. Since we are using parts of
+     * the original string, we must not free the Atom Name
+     */
+
+    /* registry, foundry, family */
+    if ((props.beginning = n_fields(&name, 1, 3)) == 0)
+       return 0;
+
+    /* weight is the next */
+    if ((props.weight = n_fields(&name, 1, 1)) == 0)
+       return 0;
+
+    /* slant */
+    if ((props.slant = n_fields(&name, 1, 1)) == 0)
+       return 0;
+
+    /* width */
+    if ((props.wideness = n_fields(&name, 1, 1)) == 0)
+       return 0;
+
+    /* add style */
+    if ((props.add_style = n_fields(&name, 1, 1)) == 0)
+       return 0;
+
+    /* pixel size */
+    if ((str = n_fields(&name, 1, 1)) == 0)
+       return 0;
+    if ((props.pixel_size = atoi(str)) == 0)
+       return 0;
+
+    /* point size */
+    if ((props.point_size = n_fields(&name, 1, 1)) == 0)
+       return 0;
+
+    /* res_x */
+    if ((str = n_fields(&name, 1, 1)) == 0)
+       return 0;
+    if ((props.res_x = atoi(str)) == 0)
+       return 0;
+
+    /* res_y */
+    if ((str = n_fields(&name, 1, 1)) == 0)
+       return 0;
+    if ((props.res_y = atoi(str)) == 0)
+       return 0;
+
+    /* spacing */
+    if ((props.spacing = n_fields(&name, 1, 1)) == 0)
+       return 0;
+
+    /* average width */
+    if ((str = n_fields(&name, 1, 1)) == 0)
+       return 0;
+    if ((props.average_width = atoi(str)) == 0)
+       return 0;
+
+    /* the rest: charset registry and charset encoding */
+    props.end = name;
+
+    return &props;
+}
+
+#define ALLOCHUNK(n) ((n | 127) + 1)
+
+static void
+alloca_fontname(char **result, size_t next)
+{
+    size_t last = (*result != 0) ? strlen(*result) : 0;
+    size_t have = (*result != 0) ? ALLOCHUNK(last) : 0;
+    size_t want = last + next + 2;
+
+    if (want >= have) {
+       want = ALLOCHUNK(want);
+       if (last != 0) {
+           *result = TypeRealloc(char, want, *result);
+       } else {
+           if ((*result = TypeMallocN(char, want)) != 0)
+               **result = '\0';
+       }
+    }
+}
+
+static void
+append_fontname_str(char **result, const char *value)
+{
+    if (value == 0)
+       value = "*";
+    alloca_fontname(result, strlen(value));
+    if (*result != 0) {
+       if (**result != '\0')
+           strcat(*result, "-");
+       strcat(*result, value);
+    }
+}
+
+static void
+append_fontname_num(char **result, int value)
+{
+    if (value < 0) {
+       append_fontname_str(result, "*");
+    } else {
+       char temp[100];
+       sprintf(temp, "%d", value);
+       append_fontname_str(result, temp);
+    }
+}
+
+/*
+ * Take the given font props and try to make a well formed font name specifying
+ * the same base font and size and everything, but with different weight/width
+ * according to the parameters.  The return value is allocated, should be freed
+ * by the caller.
+ */
+static char *
+derive_font_name(FontNameProperties * props,
+                const char *use_weight,
+                int use_average_width,
+                const char *use_encoding)
+{
+    char *result = 0;
+
+    append_fontname_str(&result, props->beginning);
+    append_fontname_str(&result, use_weight);
+    append_fontname_str(&result, props->slant);
+    append_fontname_str(&result, 0);
+    append_fontname_str(&result, 0);
+    append_fontname_num(&result, props->pixel_size);
+    append_fontname_str(&result, props->point_size);
+    append_fontname_num(&result, props->res_x);
+    append_fontname_num(&result, props->res_y);
+    append_fontname_str(&result, props->spacing);
+    append_fontname_num(&result, use_average_width);
+    append_fontname_str(&result, use_encoding);
+
+    return result;
+}
+
+static char *
+bold_font_name(FontNameProperties * props, int use_average_width)
+{
+    return derive_font_name(props, "bold", use_average_width, props->end);
+}
+
+#if OPT_WIDE_CHARS
+#define derive_wide_font(props, weight) \
+       derive_font_name(props, weight, props->average_width * 2, "ISO10646-1")
+
+static char *
+wide_font_name(FontNameProperties * props)
+{
+    return derive_wide_font(props, "medium");
+}
+
+static char *
+widebold_font_name(FontNameProperties * props)
+{
+    return derive_wide_font(props, "bold");
+}
+#endif /* OPT_WIDE_CHARS */
+
+#if OPT_DEC_CHRSET
+/*
+ * Take the given font props and try to make a well formed font name specifying
+ * the same base font but changed depending on the given attributes and chrset.
+ *
+ * For double width fonts, we just double the X-resolution, for double height
+ * fonts we double the pixel-size and Y-resolution
+ */
+char *
+xtermSpecialFont(TScreen * screen, unsigned atts, unsigned chrset)
+{
+#if OPT_TRACE
+    static char old_spacing[80];
+    static FontNameProperties old_props;
+#endif
+    FontNameProperties *props;
+    char *result = 0;
+    const char *weight;
+    int pixel_size;
+    int res_x;
+    int res_y;
+
+    props = get_font_name_props(screen->display, screen->fnts[fNorm].fs, 0);
+    if (props == 0)
+       return result;
+
+    pixel_size = props->pixel_size;
+    res_x = props->res_x;
+    res_y = props->res_y;
+    if (atts & BOLD)
+       weight = "bold";
+    else
+       weight = props->weight;
+
+    if (CSET_DOUBLE(chrset))
+       res_x *= 2;
+
+    if (chrset == CSET_DHL_TOP
+       || chrset == CSET_DHL_BOT) {
+       res_y *= 2;
+       pixel_size *= 2;
+    }
+#if OPT_TRACE
+    if (old_props.res_x != res_x
+       || old_props.res_x != res_y
+       || old_props.pixel_size != pixel_size
+       || strcmp(old_props.spacing, props->spacing)) {
+       TRACE(("xtermSpecialFont(atts = %#x, chrset = %#x)\n", atts, chrset));
+       TRACE(("res_x      = %d\n", res_x));
+       TRACE(("res_y      = %d\n", res_y));
+       TRACE(("point_size = %s\n", props->point_size));
+       TRACE(("pixel_size = %d\n", pixel_size));
+       TRACE(("spacing    = %s\n", props->spacing));
+       old_props.res_x = res_x;
+       old_props.res_x = res_y;
+       old_props.pixel_size = pixel_size;
+       old_props.spacing = strcpy(old_spacing, props->spacing);
+    }
+#endif
+
+    append_fontname_str(&result, props->beginning);
+    append_fontname_str(&result, weight);
+    append_fontname_str(&result, props->slant);
+    append_fontname_str(&result, props->wideness);
+    append_fontname_str(&result, props->add_style);
+    append_fontname_num(&result, pixel_size);
+    append_fontname_str(&result, props->point_size);
+    append_fontname_num(&result, (atts & NORESOLUTION) ? -1 : res_x);
+    append_fontname_num(&result, (atts & NORESOLUTION) ? -1 : res_y);
+    append_fontname_str(&result, props->spacing);
+    append_fontname_str(&result, 0);
+    append_fontname_str(&result, props->end);
+
+    return result;
+}
+#endif /* OPT_DEC_CHRSET */
+
+/*
+ * Case-independent comparison for font-names, including wildcards.
+ * XLFD allows '?' as a wildcard, but we do not handle that (no one seems
+ * to use it).
+ */
+static Bool
+same_font_name(const char *pattern, const char *match)
+{
+    Bool result = False;
+
+    if (pattern && match) {
+       while (*pattern && *match) {
+           if (*pattern == *match) {
+               pattern++;
+               match++;
+           } else if (*pattern == '*' || *match == '*') {
+               if (same_font_name(pattern + 1, match)) {
+                   return True;
+               } else if (same_font_name(pattern, match + 1)) {
+                   return True;
+               } else {
+                   return False;
+               }
+           } else {
+               int p = x_toupper(*pattern++);
+               int m = x_toupper(*match++);
+               if (p != m)
+                   return False;
+           }
+       }
+       result = (*pattern == *match);  /* both should be NUL */
+    }
+    return result;
+}
+
+/*
+ * Double-check the fontname that we asked for versus what the font server
+ * actually gave us.  The larger fixed fonts do not always have a matching bold
+ * font, and the font server may try to scale another font or otherwise
+ * substitute a mismatched font.
+ *
+ * If we cannot get what we requested, we will fallback to the original
+ * behavior, which simulates bold by overstriking each character at one pixel
+ * offset.
+ */
+static int
+got_bold_font(Display * dpy, XFontStruct * fs, String requested)
+{
+    char actual[MAX_FONTNAME];
+    int got;
+
+    if (get_font_name_props(dpy, fs, actual) == 0)
+       got = 0;
+    else
+       got = same_font_name(requested, actual);
+    return got;
+}
+
+/*
+ * If the font server tries to adjust another font, it may not adjust it
+ * properly.  Check that the bounding boxes are compatible.  Otherwise we'll
+ * leave trash on the display when we mix normal and bold fonts.
+ */
+static int
+same_font_size(XtermWidget xw, XFontStruct * nfs, XFontStruct * bfs)
+{
+    TScreen *screen = TScreenOf(xw);
+    TRACE(("same_font_size height %d/%d, min %d/%d max %d/%d\n",
+          nfs->ascent + nfs->descent,
+          bfs->ascent + bfs->descent,
+          nfs->min_bounds.width, bfs->min_bounds.width,
+          nfs->max_bounds.width, bfs->max_bounds.width));
+    return screen->free_bold_box
+       || ((nfs->ascent + nfs->descent) == (bfs->ascent + bfs->descent)
+           && (nfs->min_bounds.width == bfs->min_bounds.width
+               || nfs->min_bounds.width == bfs->min_bounds.width + 1)
+           && (nfs->max_bounds.width == bfs->max_bounds.width
+               || nfs->max_bounds.width == bfs->max_bounds.width + 1));
+}
+
+/*
+ * Check if the font looks like it has fixed width
+ */
+static int
+is_fixed_font(XFontStruct * fs)
+{
+    if (fs)
+       return (fs->min_bounds.width == fs->max_bounds.width);
+    return 1;
+}
+
+/*
+ * Check if the font looks like a double width font (i.e. contains
+ * characters of width X and 2X
+ */
+#if OPT_WIDE_CHARS
+static int
+is_double_width_font(XFontStruct * fs)
+{
+    return ((2 * fs->min_bounds.width) == fs->max_bounds.width);
+}
+#else
+#define is_double_width_font(fs) 0
+#endif
+
+#if OPT_WIDE_CHARS && OPT_RENDERFONT && defined(HAVE_TYPE_FCCHAR32)
+#define HALF_WIDTH_TEST_STRING "1234567890"
+
+/* '1234567890' in Chinese characters in UTF-8 */
+#define FULL_WIDTH_TEST_STRING "\xe4\xb8\x80\xe4\xba\x8c\xe4\xb8\x89" \
+                               "\xe5\x9b\x9b\xe4\xba\x94" \
+                              "\xef\xa7\x91\xe4\xb8\x83\xe5\x85\xab" \
+                              "\xe4\xb9\x9d\xef\xa6\xb2"
+
+/* '1234567890' in Korean script in UTF-8 */
+#define FULL_WIDTH_TEST_STRING2 "\xec\x9d\xbc\xec\x9d\xb4\xec\x82\xbc" \
+                                "\xec\x82\xac\xec\x98\xa4" \
+                               "\xec\x9c\xa1\xec\xb9\xa0\xed\x8c\x94" \
+                               "\xea\xb5\xac\xec\x98\x81"
+
+#define HALF_WIDTH_CHAR1  0x0031       /* '1' */
+#define HALF_WIDTH_CHAR2  0x0057       /* 'W' */
+#define FULL_WIDTH_CHAR1  0x4E00       /* CJK Ideograph 'number one' */
+#define FULL_WIDTH_CHAR2  0xAC00       /* Korean script syllable 'Ka' */
+
+static Bool
+is_double_width_font_xft(Display * dpy, XftFont * font)
+{
+    XGlyphInfo gi1, gi2;
+    FcChar32 c1 = HALF_WIDTH_CHAR1, c2 = HALF_WIDTH_CHAR2;
+    char *fwstr = FULL_WIDTH_TEST_STRING;
+    char *hwstr = HALF_WIDTH_TEST_STRING;
+
+    /* Some Korean fonts don't have Chinese characters at all. */
+    if (!XftCharExists(dpy, font, FULL_WIDTH_CHAR1)) {
+       if (!XftCharExists(dpy, font, FULL_WIDTH_CHAR2))
+           return False;       /* Not a CJK font */
+       else                    /* a Korean font without CJK Ideographs */
+           fwstr = FULL_WIDTH_TEST_STRING2;
+    }
+
+    XftTextExtents32(dpy, font, &c1, 1, &gi1);
+    XftTextExtents32(dpy, font, &c2, 1, &gi2);
+    if (gi1.xOff != gi2.xOff)  /* Not a fixed-width font */
+       return False;
+
+    XftTextExtentsUtf8(dpy, font, (FcChar8 *) hwstr, (int) strlen(hwstr), &gi1);
+    XftTextExtentsUtf8(dpy, font, (FcChar8 *) fwstr, (int) strlen(fwstr), &gi2);
+
+    /*
+     * fontconfig and Xft prior to 2.2(?) set the width of half-width
+     * characters identical to that of full-width character in CJK double-width
+     * (bi-width / monospace) font even though the former is half as wide as
+     * the latter.  This was fixed sometime before the release of fontconfig
+     * 2.2 in early 2003.  See
+     *  http://bugzilla.mozilla.org/show_bug.cgi?id=196312
+     * In the meantime, we have to check both possibilities.
+     */
+    return ((2 * gi1.xOff == gi2.xOff) || (gi1.xOff == gi2.xOff));
+}
+#else
+#define is_double_width_font_xft(dpy, xftfont) 0
+#endif
+
+#define EmptyFont(fs) (fs != 0 \
+                  && ((fs)->ascent + (fs)->descent == 0 \
+                   || (fs)->max_bounds.width == 0))
+
+#define FontSize(fs) (((fs)->ascent + (fs)->descent) \
+                   *  (fs)->max_bounds.width)
+
+const VTFontNames *
+xtermFontName(const char *normal)
+{
+    static VTFontNames data;
+    if (data.f_n)
+       free((void *) data.f_n);
+    memset(&data, 0, sizeof(data));
+    data.f_n = x_strdup(normal);
+    return &data;
+}
+
+static void
+cache_menu_font_name(TScreen * screen, int fontnum, int which, const char *name)
+{
+    if (name != 0) {
+       char *last = (char *) screen->menu_font_names[fontnum][which];
+       if (last != 0) {
+           if (strcmp(last, name)) {
+               free(last);
+               TRACE(("caching menu fontname %d.%d %s\n", fontnum, which, name));
+               screen->menu_font_names[fontnum][which] = x_strdup(name);
+           }
+       } else {
+           TRACE(("caching menu fontname %d.%d %s\n", fontnum, which, name));
+           screen->menu_font_names[fontnum][which] = x_strdup(name);
+       }
+    }
+}
+
+/*
+ * Open the given font and verify that it is non-empty.  Return a null on
+ * failure.
+ */
+Bool
+xtermOpenFont(XtermWidget xw,
+             const char *name,
+             XTermFonts * result,
+             fontWarningTypes warn,
+             Bool force)
+{
+    Bool code = False;
+    TScreen *screen = TScreenOf(xw);
+
+    if (!IsEmpty(name)) {
+       if ((result->fs = XLoadQueryFont(screen->display, name)) != 0) {
+           code = True;
+           if (EmptyFont(result->fs)) {
+               (void) xtermCloseFont(xw, result);
+               code = False;
+           } else {
+               result->fn = x_strdup(name);
+           }
+       } else if (XmuCompareISOLatin1(name, DEFFONT) != 0) {
+           if (warn <= xw->misc.fontWarnings
+#if OPT_RENDERFONT
+               && !UsingRenderFont(xw)
+#endif
+               ) {
+               TRACE(("OOPS: cannot load font %s\n", name));
+               fprintf(stderr, "%s: cannot load font '%s'\n", ProgramName, name);
+#if OPT_RENDERFONT
+               /*
+                * Do a sanity check in case someone's mixed up xterm with
+                * one of those programs that read their resource data from
+                * xterm's namespace.
+                */
+               if (strchr(name, ':') != 0 || strchr(name, '=') != 0) {
+                   fprintf(stderr,
+                           "Use the \"-fa\" option for the Xft fonts\n");
+               }
+#endif
+           } else {
+               TRACE(("xtermOpenFont: cannot load font '%s'\n", name));
+           }
+           if (force) {
+               code = xtermOpenFont(xw, DEFFONT, result, fwAlways, True);
+           }
+       }
+    }
+    return code;
+}
+
+/*
+ * Close the font and free the font info.
+ */
+XTermFonts *
+xtermCloseFont(XtermWidget xw, XTermFonts * fnt)
+{
+    if (fnt != 0 && fnt->fs != 0) {
+       TScreen *screen = TScreenOf(xw);
+
+       clrCgsFonts(xw, WhichVWin(screen), fnt);
+       XFreeFont(screen->display, fnt->fs);
+       xtermFreeFontInfo(fnt);
+    }
+    return 0;
+}
+
+/*
+ * Close the listed fonts, noting that some may use copies of the pointer.
+ */
+void
+xtermCloseFonts(XtermWidget xw, XTermFonts * fnts)
+{
+    int j, k;
+
+    for (j = 0; j < fMAX; ++j) {
+       /*
+        * Need to save the pointer since xtermCloseFont zeroes it
+        */
+       XFontStruct *thisFont = fnts[j].fs;
+       if (thisFont != 0) {
+           xtermCloseFont(xw, &fnts[j]);
+           for (k = j + 1; k < fMAX; ++k) {
+               if (thisFont == fnts[k].fs)
+                   xtermFreeFontInfo(&fnts[k]);
+           }
+       }
+    }
+}
+
+/*
+ * Make a copy of the source, assuming the XFontStruct's to be unique, but
+ * ensuring that the names are reallocated to simplify freeing.
+ */
+void
+xtermCopyFontInfo(XTermFonts * target, XTermFonts * source)
+{
+    xtermFreeFontInfo(target);
+    target->chrset = source->chrset;
+    target->flags = source->flags;
+    target->fn = x_strdup(source->fn);
+    target->fs = source->fs;
+}
+
+void
+xtermFreeFontInfo(XTermFonts * target)
+{
+    target->chrset = 0;
+    target->flags = 0;
+    if (target->fn != 0) {
+       free(target->fn);
+       target->fn = 0;
+    }
+    target->fs = 0;
+}
+
+int
+xtermLoadFont(XtermWidget xw,
+             const VTFontNames * fonts,
+             Bool doresize,
+             int fontnum)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+
+    VTFontNames myfonts;
+    FontNameProperties *fp;
+    XTermFonts fnts[fMAX];
+    Pixel new_normal;
+    Pixel new_revers;
+    char *tmpname = NULL;
+    char normal[MAX_FONTNAME];
+    Boolean proportional = False;
+    fontWarningTypes warn[fMAX];
+    int j;
+
+    memset(&myfonts, 0, sizeof(myfonts));
+    memset(fnts, 0, sizeof(fnts));
+
+    if (fonts != 0)
+       myfonts = *fonts;
+    if (!check_fontname(myfonts.f_n))
+       return 0;
+
+    /*
+     * Check the font names against the resource values, to see which were
+     * derived in a previous call.  If so, we'll only warn about those if
+     * the warning level is set to "always".
+     */
+    for (j = 0; j < fMAX; ++j) {
+       warn[j] = fwAlways;
+    }
+#define CmpResource(field, index) \
+    if (same_font_name(screen->menu_font_names[fontnum][index], myfonts.field)) \
+       warn[index] = fwResource
+
+    CmpResource(f_n, fNorm);
+    if (fontnum == fontMenu_default) {
+       CmpResource(f_b, fBold);
+#if OPT_WIDE_CHARS
+       CmpResource(f_b, fWide);
+       CmpResource(f_b, fWBold);
+#endif
+    }
+
+    if (fontnum == fontMenu_fontescape
+       && myfonts.f_n != screen->MenuFontName(fontnum)) {
+       if ((tmpname = x_strdup(myfonts.f_n)) == 0)
+           return 0;
+    }
+
+    TRACE(("Begin Cgs - xtermLoadFont(%s)\n", myfonts.f_n));
+    releaseWindowGCs(xw, win);
+
+#define DbgResource(name, field, index) \
+    TRACE(("xtermLoadFont #%d "name" %s%s\n", \
+          fontnum, \
+          (warn[index] == fwResource) ? "*" : " ", \
+          NonNull(myfonts.field)))
+    DbgResource("normal", f_n, fNorm);
+    DbgResource("bold  ", f_b, fBold);
+#if OPT_WIDE_CHARS
+    DbgResource("wide  ", f_w, fWide);
+    DbgResource("w/bold", f_wb, fWBold);
+#endif
+
+    if (!xtermOpenFont(xw, myfonts.f_n, &fnts[fNorm], warn[fNorm], True))
+       goto bad;
+
+    strcpy(normal, myfonts.f_n);
+    if (!check_fontname(myfonts.f_b)) {
+       warn[fBold] = fwAlways;
+       fp = get_font_name_props(screen->display, fnts[fNorm].fs, normal);
+       if (fp != 0) {
+           myfonts.f_b = bold_font_name(fp, fp->average_width);
+           if (!xtermOpenFont(xw, myfonts.f_b, &fnts[fBold], fwAlways, False)) {
+               myfonts.f_b = bold_font_name(fp, -1);
+               xtermOpenFont(xw, myfonts.f_b, &fnts[fBold], fwAlways, False);
+           }
+           TRACE(("...derived bold '%s'\n", NonNull(myfonts.f_b)));
+       }
+       if (fp == 0 || fnts[fBold].fs == 0) {
+           xtermCopyFontInfo(&fnts[fBold], &fnts[fNorm]);
+           TRACE(("...cannot load a matching bold font\n"));
+       } else if (same_font_size(xw, fnts[fNorm].fs, fnts[fBold].fs)
+                  && got_bold_font(screen->display, fnts[fBold].fs, myfonts.f_b)) {
+           TRACE(("...got a matching bold font\n"));
+           cache_menu_font_name(screen, fontnum, fBold, myfonts.f_b);
+       } else {
+           xtermCloseFont(xw, &fnts[fBold]);
+           fnts[fBold] = fnts[fNorm];
+           TRACE(("...did not get a matching bold font\n"));
+       }
+    } else if (!xtermOpenFont(xw, myfonts.f_b, &fnts[fBold], warn[fBold], False)) {
+       xtermCopyFontInfo(&fnts[fBold], &fnts[fNorm]);
+       warn[fBold] = fwAlways;
+       TRACE(("...cannot load bold font '%s'\n", NonNull(myfonts.f_b)));
+    } else {
+       cache_menu_font_name(screen, fontnum, fBold, myfonts.f_b);
+    }
+
+    /*
+     * If there is no widefont specified, fake it by doubling AVERAGE_WIDTH
+     * of normal fonts XLFD, and asking for it.  This plucks out 18x18ja
+     * and 12x13ja as the corresponding fonts for 9x18 and 6x13.
+     */
+    if_OPT_WIDE_CHARS(screen, {
+       Bool derived;
+       char bold[MAX_FONTNAME];
+
+       if (check_fontname(myfonts.f_w)) {
+           cache_menu_font_name(screen, fontnum, fWide, myfonts.f_w);
+       } else if (!is_double_width_font(fnts[fNorm].fs)) {
+           fp = get_font_name_props(screen->display, fnts[fNorm].fs, normal);
+           if (fp != 0) {
+               myfonts.f_w = wide_font_name(fp);
+               warn[fWide] = fwAlways;
+               TRACE(("...derived wide %s\n", NonNull(myfonts.f_w)));
+               cache_menu_font_name(screen, fontnum, fWide, myfonts.f_w);
+           }
+       }
+
+       if (check_fontname(myfonts.f_w)) {
+           (void) xtermOpenFont(xw, myfonts.f_w, &fnts[fWide], warn[fWide], False);
+       } else {
+           xtermCopyFontInfo(&fnts[fWide], &fnts[fNorm]);
+           warn[fWide] = fwAlways;
+       }
+
+       derived = False;
+       if (!check_fontname(myfonts.f_wb)) {
+           fp = get_font_name_props(screen->display, fnts[fBold].fs, bold);
+           if (fp != 0) {
+               myfonts.f_wb = widebold_font_name(fp);
+               warn[fWBold] = fwAlways;
+               derived = True;
+           }
+       }
+
+       if (check_fontname(myfonts.f_wb)) {
+
+           xtermOpenFont(xw, myfonts.f_wb, &fnts[fWBold], warn[fWBold], False);
+
+           if (derived
+               && !compatibleWideCounts(fnts[fWide].fs, fnts[fWBold].fs)) {
+               xtermCloseFont(xw, &fnts[fWBold]);
+           }
+           if (fnts[fWBold].fs == 0) {
+               myfonts.f_wb = myfonts.f_w;
+               warn[fWBold] = fwAlways;
+               xtermCopyFontInfo(&fnts[fWBold], &fnts[fWide]);
+               TRACE(("...cannot load wide-bold, use wide %s\n", NonNull(myfonts.f_w)));
+           } else {
+               TRACE(("...%s wide/bold %s\n",
+                      derived ? "derived" : "given",
+                      NonNull(myfonts.f_wb)));
+               cache_menu_font_name(screen, fontnum, fWBold, myfonts.f_wb);
+           }
+       } else if (is_double_width_font(fnts[fBold].fs)) {
+           xtermCopyFontInfo(&fnts[fWBold], &fnts[fBold]);
+           warn[fWBold] = fwAlways;
+           TRACE(("...bold font is double-width, use it %s\n", NonNull(myfonts.f_b)));
+       } else {
+           xtermCopyFontInfo(&fnts[fWBold], &fnts[fWide]);
+           warn[fWBold] = fwAlways;
+           TRACE(("...cannot load wide bold font, use wide %s\n", NonNull(myfonts.f_w)));
+       }
+
+       if (EmptyFont(fnts[fWBold].fs))
+           goto bad;           /* can't use a 0-sized font */
+    });
+
+    /*
+     * Most of the time this call to load the font will succeed, even if
+     * there is no wide font :  the X server doubles the width of the
+     * normal font, or similar.
+     *
+     * But if it did fail for some reason, then nevermind.
+     */
+    if (EmptyFont(fnts[fBold].fs))
+       goto bad;               /* can't use a 0-sized font */
+
+    if (!same_font_size(xw, fnts[fNorm].fs, fnts[fBold].fs)
+       && (is_fixed_font(fnts[fNorm].fs) && is_fixed_font(fnts[fBold].fs))) {
+       TRACE(("...ignoring mismatched normal/bold fonts\n"));
+       xtermCloseFont(xw, &fnts[fBold]);
+       xtermCopyFontInfo(&fnts[fBold], &fnts[fNorm]);
+    }
+
+    if_OPT_WIDE_CHARS(screen, {
+       if (fnts[fWide].fs != 0
+           && fnts[fWBold].fs != 0
+           && !same_font_size(xw, fnts[fWide].fs, fnts[fWBold].fs)
+           && (is_fixed_font(fnts[fWide].fs) && is_fixed_font(fnts[fWBold].fs))) {
+           TRACE(("...ignoring mismatched normal/bold wide fonts\n"));
+           xtermCloseFont(xw, &fnts[fWBold]);
+           xtermCopyFontInfo(&fnts[fWBold], &fnts[fWide]);
+       }
+    });
+
+    /*
+     * Normal/bold fonts should be the same width.  Also, the min/max
+     * values should be the same.
+     */
+    if (!is_fixed_font(fnts[fNorm].fs)
+       || !is_fixed_font(fnts[fBold].fs)
+       || fnts[fNorm].fs->max_bounds.width != fnts[fBold].fs->max_bounds.width) {
+       TRACE(("Proportional font! normal %d/%d, bold %d/%d\n",
+              fnts[fNorm].fs->min_bounds.width,
+              fnts[fNorm].fs->max_bounds.width,
+              fnts[fBold].fs->min_bounds.width,
+              fnts[fBold].fs->max_bounds.width));
+       proportional = True;
+    }
+
+    if_OPT_WIDE_CHARS(screen, {
+       if (fnts[fWide].fs != 0
+           && fnts[fWBold].fs != 0
+           && (!is_fixed_font(fnts[fWide].fs)
+               || !is_fixed_font(fnts[fWBold].fs)
+               || fnts[fWide].fs->max_bounds.width != fnts[fWBold].fs->max_bounds.width)) {
+           TRACE(("Proportional font! wide %d/%d, wide bold %d/%d\n",
+                  fnts[fWide].fs->min_bounds.width,
+                  fnts[fWide].fs->max_bounds.width,
+                  fnts[fWBold].fs->min_bounds.width,
+                  fnts[fWBold].fs->max_bounds.width));
+           proportional = True;
+       }
+    });
+
+    /* TODO : enforce that the width of the wide font is 2* the width
+       of the narrow font */
+
+    /*
+     * If we're switching fonts, free the old ones.  Otherwise we'll leak
+     * the memory that is associated with the old fonts.  The
+     * XLoadQueryFont call allocates a new XFontStruct.
+     */
+    xtermCloseFonts(xw, screen->fnts);
+
+    xtermCopyFontInfo(&(screen->fnts[fNorm]), &fnts[fNorm]);
+    xtermCopyFontInfo(&(screen->fnts[fBold]), &fnts[fBold]);
+#if OPT_WIDE_CHARS
+    xtermCopyFontInfo(&(screen->fnts[fWide]), &fnts[fWide]);
+    if (fnts[fWBold].fs == NULL)
+       xtermCopyFontInfo(&fnts[fWBold], &fnts[fWide]);
+    xtermCopyFontInfo(&(screen->fnts[fWBold]), &fnts[fWBold]);
+#endif
+
+    new_normal = getXtermForeground(xw, xw->flags, xw->cur_foreground);
+    new_revers = getXtermBackground(xw, xw->flags, xw->cur_background);
+
+    setCgsFore(xw, win, gcNorm, new_normal);
+    setCgsBack(xw, win, gcNorm, new_revers);
+    setCgsFont(xw, win, gcNorm, &(screen->fnts[fNorm]));
+
+    copyCgs(xw, win, gcBold, gcNorm);
+    setCgsFont(xw, win, gcBold, &(screen->fnts[fBold]));
+
+    setCgsFore(xw, win, gcNormReverse, new_revers);
+    setCgsBack(xw, win, gcNormReverse, new_normal);
+    setCgsFont(xw, win, gcNormReverse, &(screen->fnts[fNorm]));
+
+    copyCgs(xw, win, gcBoldReverse, gcNormReverse);
+    setCgsFont(xw, win, gcBoldReverse, &(screen->fnts[fBold]));
+
+    if_OPT_WIDE_CHARS(screen, {
+       if (screen->fnts[fWide].fs != 0
+           && screen->fnts[fWBold].fs != 0) {
+           setCgsFore(xw, win, gcWide, new_normal);
+           setCgsBack(xw, win, gcWide, new_revers);
+           setCgsFont(xw, win, gcWide, &(screen->fnts[fWide]));
+
+           copyCgs(xw, win, gcWBold, gcWide);
+           setCgsFont(xw, win, gcWBold, &(screen->fnts[fWBold]));
+
+           setCgsFore(xw, win, gcWideReverse, new_revers);
+           setCgsBack(xw, win, gcWideReverse, new_normal);
+           setCgsFont(xw, win, gcWideReverse, &(screen->fnts[fWide]));
+
+           copyCgs(xw, win, gcWBoldReverse, gcWideReverse);
+           setCgsFont(xw, win, gcWBoldReverse, &(screen->fnts[fWBold]));
+       }
+    });
+
+#if OPT_BOX_CHARS
+    screen->allow_packing = proportional;
+    setupPackedFonts(xw);
+#endif
+    screen->fnt_prop = (Boolean) (proportional && !(screen->force_packed));
+    screen->fnt_boxes = True;
+
+#if OPT_BOX_CHARS
+    /*
+     * Xterm uses character positions 1-31 of a font for the line-drawing
+     * characters.  Check that they are all present.  The null character
+     * (0) is special, and is not used.
+     */
+#if OPT_RENDERFONT
+    if (UsingRenderFont(xw)) {
+       /*
+        * FIXME: we shouldn't even be here if we're using Xft.
+        */
+       screen->fnt_boxes = False;
+       TRACE(("assume Xft missing line-drawing chars\n"));
+    } else
+#endif
+    {
+       unsigned ch;
+
+       for (ch = 1; ch < 32; ch++) {
+           unsigned n = ch;
+#if OPT_WIDE_CHARS
+           if (screen->utf8_mode || screen->unicode_font) {
+               n = dec2ucs(ch);
+               if (n == UCS_REPL)
+                   continue;
+           }
+#endif
+           if (IsXtermMissingChar(screen, n, &fnts[fNorm])) {
+               TRACE(("missing normal char #%d\n", n));
+               screen->fnt_boxes = False;
+               break;
+           }
+           if (IsXtermMissingChar(screen, n, &fnts[fBold])) {
+               TRACE(("missing bold char #%d\n", n));
+               screen->fnt_boxes = False;
+               break;
+           }
+       }
+    }
+    TRACE(("Will %suse internal line-drawing characters\n",
+          screen->fnt_boxes ? "not " : ""));
+#endif
+
+    if (screen->always_bold_mode) {
+       screen->enbolden = screen->bold_mode;
+    } else {
+       screen->enbolden = screen->bold_mode
+           && ((fnts[fNorm].fs == fnts[fBold].fs)
+               || same_font_name(normal, myfonts.f_b));
+    }
+    TRACE(("Will %suse 1-pixel offset/overstrike to simulate bold\n",
+          screen->enbolden ? "" : "not "));
+
+    set_menu_font(False);
+    screen->menu_font_number = fontnum;
+    set_menu_font(True);
+    if (tmpname) {             /* if setting escape or sel */
+       if (screen->MenuFontName(fontnum))
+           free((void *) screen->MenuFontName(fontnum));
+       screen->MenuFontName(fontnum) = tmpname;
+       if (fontnum == fontMenu_fontescape) {
+           SetItemSensitivity(fontMenuEntries[fontMenu_fontescape].widget,
+                              True);
+       }
+#if OPT_SHIFT_FONTS
+       screen->menu_font_sizes[fontnum] = FontSize(fnts[fNorm].fs);
+#endif
+    }
+    set_cursor_gcs(xw);
+    xtermUpdateFontInfo(xw, doresize);
+    TRACE(("Success Cgs - xtermLoadFont\n"));
+    return 1;
+
+  bad:
+    if (tmpname)
+       free(tmpname);
+    releaseWindowGCs(xw, win);
+
+    xtermCloseFonts(xw, fnts);
+    TRACE(("Fail Cgs - xtermLoadFont\n"));
+    return 0;
+}
+
+#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS
+/*
+ * Collect font-names that we can modify with the load-vt-fonts() action.
+ */
+typedef struct {
+    VTFontNames default_font;
+    String menu_font_names[fontMenu_lastBuiltin + 1][fMAX];
+} SubResourceRec;
+
+#define MERGE_SUBFONT(src,dst,name) \
+       if (IsEmpty(dst.name)) { \
+           TRACE(("MERGE_SUBFONT " #dst "." #name " merge %s\n", NonNull(src.name))); \
+           dst.name = src.name; \
+       } else { \
+           TRACE(("MERGE_SUBFONT " #dst "." #name " found %s\n", NonNull(dst.name))); \
+       }
+
+#define COPY_MENU_FONTS(src,dst) \
+       TRACE(("COPY_MENU_FONTS " #src " to " #dst "\n")); \
+       for (n = fontMenu_default; n <= fontMenu_lastBuiltin; ++n) { \
+           for (m = 0; m < fMAX; ++m) { \
+               dst.menu_font_names[n][m] = x_strdup(src.menu_font_names[n][m]); \
+           } \
+       }
+
+/*
+ * Load the "VT" font names from the given subresource name/class.  These
+ * correspond to the VT100 resources.
+ */
+static Bool
+xtermLoadVTFonts(XtermWidget xw, String myName, String myClass)
+{
+    static Bool initialized = False;
+    static SubResourceRec original, referenceRec, subresourceRec;
+
+    /*
+     * These are duplicates of the VT100 font resources, but with a special
+     * application/classname passed in to distinguish them.
+     */
+    static XtResource font_resources[] =
+    {
+       Sres(XtNfont, XtCFont, default_font.f_n, DEFFONT),
+       Sres(XtNboldFont, XtCBoldFont, default_font.f_b, DEFBOLDFONT),
+#if OPT_WIDE_CHARS
+       Sres(XtNwideFont, XtCWideFont, default_font.f_w, DEFWIDEFONT),
+       Sres(XtNwideBoldFont, XtCWideBoldFont, default_font.f_wb, DEFWIDEBOLDFONT),
+#endif
+       Sres(XtNfont1, XtCFont1, MenuFontName(fontMenu_font1), NULL),
+       Sres(XtNfont2, XtCFont2, MenuFontName(fontMenu_font2), NULL),
+       Sres(XtNfont3, XtCFont3, MenuFontName(fontMenu_font3), NULL),
+       Sres(XtNfont4, XtCFont4, MenuFontName(fontMenu_font4), NULL),
+       Sres(XtNfont5, XtCFont5, MenuFontName(fontMenu_font5), NULL),
+       Sres(XtNfont6, XtCFont6, MenuFontName(fontMenu_font6), NULL),
+    };
+    Cardinal n, m;
+    Bool status = True;
+    TScreen *screen = TScreenOf(xw);
+
+    if (!initialized) {
+
+       initialized = True;
+       TRACE(("xtermLoadVTFonts saving original\n"));
+       original.default_font = xw->misc.default_font;
+       COPY_MENU_FONTS(xw->screen, original);
+    }
+
+    if (IsEmpty(myName)) {
+       TRACE(("xtermLoadVTFonts restoring original\n"));
+       xw->misc.default_font = original.default_font;
+       COPY_MENU_FONTS(original, xw->screen);
+       for (n = 0; n < XtNumber(original.menu_font_names); ++n)
+           screen->MenuFontName(n) = original.MenuFontName(n);
+    } else {
+       TRACE(("xtermLoadVTFonts(%s, %s)\n", myName, myClass));
+
+       memset(&subresourceRec, 0, sizeof(subresourceRec));
+       XtGetSubresources((Widget) xw, (XtPointer) &subresourceRec,
+                         myName, myClass,
+                         font_resources,
+                         (Cardinal) XtNumber(font_resources),
+                         NULL, (Cardinal) 0);
+
+       if (memcmp(&referenceRec, &subresourceRec, sizeof(referenceRec))) {
+
+           /*
+            * If a particular resource value was not found, use the original.
+            */
+           MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_n);
+           MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_b);
+#if OPT_WIDE_CHARS
+           MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_w);
+           MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_wb);
+#endif
+           for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; ++n)
+               MERGE_SUBFONT(xw->screen, subresourceRec, MenuFontName(n));
+
+           /*
+            * Finally, copy the subresource data to the widget.
+            */
+           xw->misc.default_font = subresourceRec.default_font;
+           COPY_MENU_FONTS(subresourceRec, xw->screen);
+           screen->MenuFontName(fontMenu_default) = x_strdup(xw->misc.default_font.f_n);
+           screen->menu_font_names[0][fBold] = x_strdup(xw->misc.default_font.f_b);
+#if OPT_WIDE_CHARS
+           screen->menu_font_names[0][fWide] = x_strdup(xw->misc.default_font.f_w);
+           screen->menu_font_names[0][fWBold] = x_strdup(xw->misc.default_font.f_wb);
+#endif
+       } else {
+           TRACE(("...no resources found\n"));
+           status = False;
+       }
+    }
+    return status;
+}
+
+#if OPT_WIDE_CHARS
+static Bool
+isWideFont(XFontStruct * fp, const char *tag, Bool nullOk)
+{
+    Bool result = False;
+
+    (void) tag;
+    if (okFont(fp)) {
+       unsigned count = countGlyphs(fp);
+       TRACE(("isWideFont(%s) found %d cells\n", tag, count));
+       result = (count > 256) ? True : False;
+    } else {
+       result = nullOk;
+    }
+    return result;
+}
+
+/*
+ * If the current fonts are not wide, load the UTF8 fonts.
+ *
+ * Called during initialization (for wide-character mode), the fonts have not
+ * been setup, so we pass nullOk=True to isWideFont().
+ *
+ * Called after initialization, e.g., in response to the UTF-8 menu entry
+ * (starting from narrow character mode), it checks if the fonts are not wide.
+ */
+Bool
+xtermLoadWideFonts(XtermWidget xw, Bool nullOk)
+{
+    TScreen *screen = TScreenOf(xw);
+    Bool result;
+
+    if (EmptyFont(screen->fnts[fWide].fs)) {
+       result = (isWideFont(screen->fnts[fNorm].fs, "normal", nullOk)
+                 && isWideFont(screen->fnts[fBold].fs, "bold", nullOk));
+    } else {
+       result = (isWideFont(screen->fnts[fWide].fs, "wide", nullOk)
+                 && isWideFont(screen->fnts[fWBold].fs, "wide-bold", nullOk));
+       if (result && !screen->utf8_latin1) {
+           result = (isWideFont(screen->fnts[fNorm].fs, "normal", nullOk)
+                     && isWideFont(screen->fnts[fBold].fs, "bold", nullOk));
+       }
+    }
+    if (!result) {
+       TRACE(("current fonts are not all wide%s\n", nullOk ? " nullOk" : ""));
+       result = xtermLoadVTFonts(xw, "utf8Fonts", "Utf8Fonts");
+    }
+    TRACE(("xtermLoadWideFonts:%d\n", result));
+    return result;
+}
+#endif /* OPT_WIDE_CHARS */
+
+/*
+ * Restore the default fonts, i.e., if we had switched to wide-fonts.
+ */
+Bool
+xtermLoadDefaultFonts(XtermWidget xw)
+{
+    Bool result;
+    result = xtermLoadVTFonts(xw, NULL, NULL);
+    TRACE(("xtermLoadDefaultFonts:%d\n", result));
+    return result;
+}
+#endif /* OPT_LOAD_VTFONTS || OPT_WIDE_CHARS */
+
+#if OPT_LOAD_VTFONTS
+void
+HandleLoadVTFonts(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params GCC_UNUSED,
+                 Cardinal *param_count GCC_UNUSED)
+{
+    static char empty[] = "";  /* appease strict compilers */
+
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       char name_buf[80];
+       char class_buf[80];
+       String name = (String) ((*param_count > 0) ? params[0] : empty);
+       char *myName = (char *) MyStackAlloc(strlen(name), name_buf);
+       String convert = (String) ((*param_count > 1) ? params[1] : myName);
+       char *myClass = (char *) MyStackAlloc(strlen(convert), class_buf);
+       int n;
+
+       TRACE(("HandleLoadVTFonts(%d)\n", *param_count));
+       strcpy(myName, name);
+       strcpy(myClass, convert);
+       if (*param_count == 1)
+           myClass[0] = x_toupper(myClass[0]);
+
+       if (xtermLoadVTFonts(xw, myName, myClass)) {
+           /*
+            * When switching fonts, try to preserve the font-menu selection, since
+            * it is less surprising to do that (if the font-switching can be
+            * undone) than to switch to "Default".
+            */
+           int font_number = screen->menu_font_number;
+           if (font_number > fontMenu_lastBuiltin)
+               font_number = fontMenu_lastBuiltin;
+           for (n = 0; n < NMENUFONTS; ++n)
+               screen->menu_font_sizes[n] = 0;
+           SetVTFont(xw, font_number, True,
+                     ((font_number == fontMenu_default)
+                      ? &(xw->misc.default_font)
+                      : NULL));
+       }
+
+       MyStackFree(myName, name_buf);
+       MyStackFree(myClass, class_buf);
+    }
+}
+#endif /* OPT_LOAD_VTFONTS */
+
+/*
+ * Set the limits for the box that outlines the cursor.
+ */
+void
+xtermSetCursorBox(TScreen * screen)
+{
+    static XPoint VTbox[NBOX];
+    XPoint *vp;
+    int fw = FontWidth(screen) - 1;
+    int fh = FontHeight(screen) - 1;
+    int hh = screen->cursor_underline ? 1 : fh;
+
+    vp = &VTbox[1];
+    (vp++)->x = (short) fw;
+    (vp++)->y = (short) hh;
+    (vp++)->x = (short) -fw;
+    vp->y = (short) -hh;
+
+    screen->box = VTbox;
+}
+
+#define CACHE_XFT(dst,src) if (src != 0) {\
+           checkXft(xw, &(dst[fontnum]), src);\
+           TRACE(("Xft metrics %s[%d] = %d (%d,%d) advance %d, actual %d%s\n",\
+               #dst,\
+               fontnum,\
+               src->height,\
+               src->ascent,\
+               src->descent,\
+               src->max_advance_width,\
+               dst[fontnum].map.min_width,\
+               dst[fontnum].map.mixed ? " mixed" : ""));\
+       }
+
+#if OPT_RENDERFONT
+
+#if OPT_TRACE > 1
+static FcChar32
+xtermXftFirstChar(XftFont * xft)
+{
+    FcChar32 map[FC_CHARSET_MAP_SIZE];
+    FcChar32 next;
+    FcChar32 first;
+    int i;
+
+    first = FcCharSetFirstPage(xft->charset, map, &next);
+    for (i = 0; i < FC_CHARSET_MAP_SIZE; i++)
+       if (map[i]) {
+           FcChar32 bits = map[i];
+           first += i * 32;
+           while (!(bits & 0x1)) {
+               bits >>= 1;
+               first++;
+           }
+           break;
+       }
+    return first;
+}
+
+static FcChar32
+xtermXftLastChar(XftFont * xft)
+{
+    FcChar32 this, last, next;
+    FcChar32 map[FC_CHARSET_MAP_SIZE];
+    int i;
+    last = FcCharSetFirstPage(xft->charset, map, &next);
+    while ((this = FcCharSetNextPage(xft->charset, map, &next)) != FC_CHARSET_DONE)
+       last = this;
+    last &= ~0xff;
+    for (i = FC_CHARSET_MAP_SIZE - 1; i >= 0; i--)
+       if (map[i]) {
+           FcChar32 bits = map[i];
+           last += i * 32 + 31;
+           while (!(bits & 0x80000000)) {
+               last--;
+               bits <<= 1;
+           }
+           break;
+       }
+    return (long) last;
+}
+
+static void
+dumpXft(XtermWidget xw, XTermXftFonts * data)
+{
+    XftFont *xft = data->font;
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+
+    FcChar32 c;
+    FcChar32 first = xtermXftFirstChar(xft);
+    FcChar32 last = xtermXftLastChar(xft);
+    unsigned count = 0;
+    unsigned outside = 0;
+
+    TRACE(("dumpXft {{\n"));
+    TRACE(("   data range %#6x..%#6x\n", first, last));
+    for (c = first; c <= last; ++c) {
+       if (FcCharSetHasChar(xft->charset, c)) {
+           int width = my_wcwidth((int) c);
+           XGlyphInfo extents;
+
+           XftTextExtents32(XtDisplay(xw), xft, &c, 1, &extents);
+           TRACE(("%#6x  %2d  %.1f\n", c, width,
+                  ((double) extents.width) / win->f_width));
+           if (extents.width > win->f_width)
+               ++outside;
+           ++count;
+       }
+    }
+    TRACE(("}} %u total, %u outside\n", count, outside));
+}
+#define DUMP_XFT(xw, data) dumpXft(xw, data)
+#else
+#define DUMP_XFT(xw, data)     /* nothing */
+#endif
+
+static void
+checkXft(XtermWidget xw, XTermXftFonts * data, XftFont * xft)
+{
+    FcChar32 c;
+    Dimension width = 0;
+
+    data->font = xft;
+    data->map.min_width = 0;
+    data->map.max_width = (Dimension) xft->max_advance_width;
+
+    /*
+     * For each ASCII or ISO-8859-1 printable code, ask what its width is.
+     * Given the maximum width for those, we have a reasonable estimate of
+     * the single-column width.
+     *
+     * Ignore control characters - their extent information is misleading.
+     */
+    for (c = 32; c < 256; ++c) {
+       if (c >= 127 && c <= 159)
+           continue;
+       if (FcCharSetHasChar(xft->charset, c)) {
+           XGlyphInfo extents;
+
+           XftTextExtents32(XtDisplay(xw), xft, &c, 1, &extents);
+           if (width < extents.width && extents.width <= data->map.max_width) {
+               width = extents.width;
+           }
+       }
+    }
+    data->map.min_width = width;
+    data->map.mixed = (data->map.max_width >= (data->map.min_width + 1));
+}
+
+static XftFont *
+xtermOpenXft(XtermWidget xw, const char *name, XftPattern * pat, const char *tag)
+{
+    TScreen *screen = TScreenOf(xw);
+    Display *dpy = screen->display;
+    XftPattern *match;
+    XftResult status;
+    XftFont *result = 0;
+
+    if (pat != 0) {
+       match = XftFontMatch(dpy, DefaultScreen(dpy), pat, &status);
+       if (match != 0) {
+           result = XftFontOpenPattern(dpy, match);
+           if (result != 0) {
+               TRACE(("...matched %s font\n", tag));
+           } else {
+               TRACE(("...could did not open %s font\n", tag));
+               XftPatternDestroy(match);
+               if (xw->misc.fontWarnings >= fwAlways) {
+                   TRACE(("OOPS cannot open %s font \"%s\"\n", tag, name));
+                   fprintf(stderr, "%s: cannot open %s font \"%s\"\n",
+                           ProgramName, tag, name);
+               }
+           }
+       } else {
+           TRACE(("...did not match %s font\n", tag));
+           if (xw->misc.fontWarnings >= fwResource) {
+               TRACE(("OOPS: cannot match %s font \"%s\"\n", tag, name));
+               fprintf(stderr, "%s: cannot match %s font \"%s\"\n",
+                       ProgramName, tag, name);
+           }
+       }
+    }
+    return result;
+}
+#endif
+
+#if OPT_RENDERFONT
+#if OPT_SHIFT_FONTS
+/*
+ * Don't make a dependency on the math library for a single function.
+ * (Newton Raphson).
+ */
+static double
+mySquareRoot(double value)
+{
+    double result = 0.0;
+    if (value > 0.0) {
+       int n;
+       double older = value;
+       for (n = 0; n < 10; ++n) {
+           double delta = (older * older - value) / (2.0 * older);
+           double newer = older - delta;
+           older = newer;
+           result = newer;
+           if (delta > -0.001 && delta < 0.001)
+               break;
+       }
+    }
+    return result;
+}
+#endif
+
+/*
+ * Given the Xft font metrics, determine the actual font size.  This is used
+ * for each font to ensure that normal, bold and italic fonts follow the same
+ * rule.
+ */
+static void
+setRenderFontsize(TScreen * screen, VTwin * win, XftFont * font, const char *tag)
+{
+    if (font != 0) {
+       int width, height, ascent, descent;
+
+       (void) screen;
+
+       width = font->max_advance_width;
+       height = font->height;
+       ascent = font->ascent;
+       descent = font->descent;
+       if (height < ascent + descent) {
+           TRACE(("...increase height from %d\n", height));
+           height = ascent + descent;
+       }
+       if (is_double_width_font_xft(screen->display, font)) {
+           TRACE(("...reduced width from %d\n", width));
+           width >>= 1;
+       }
+       if (tag == 0) {
+           win->f_width = width;
+           win->f_height = height;
+           win->f_ascent = ascent;
+           win->f_descent = descent;
+           TRACE(("setRenderFontsize result %dx%d (%d+%d)\n",
+                  width, height, ascent, descent));
+       } else if (win->f_width < width ||
+                  win->f_height < height ||
+                  win->f_ascent < ascent ||
+                  win->f_descent < descent) {
+           TRACE(("setRenderFontsize %s changed %dx%d (%d+%d) to %dx%d (%d+%d)\n",
+                  tag,
+                  win->f_width, win->f_height, win->f_ascent, win->f_descent,
+                  width, height, ascent, descent));
+
+           win->f_width = width;
+           win->f_height = height;
+           win->f_ascent = ascent;
+           win->f_descent = descent;
+       } else {
+           TRACE(("setRenderFontsize %s unchanged\n", tag));
+       }
+    }
+}
+#endif
+
+static void
+checkFontInfo(int value, const char *tag)
+{
+    if (value == 0) {
+       fprintf(stderr,
+               "Selected font has no non-zero %s for ISO-8859-1 encoding\n", tag);
+       exit(1);
+    }
+}
+
+#if OPT_RENDERFONT
+void
+xtermCloseXft(TScreen * screen, XTermXftFonts * pub)
+{
+    if (pub->font != 0) {
+       XftFontClose(screen->display, pub->font);
+       pub->font = 0;
+    }
+}
+
+/*
+ * Get the faceName/faceDoublesize resource setting.  Strip off "xft:", which
+ * is not recognized by XftParseName().
+ */
+String
+getFaceName(XtermWidget xw, Bool wideName GCC_UNUSED)
+{
+#if OPT_RENDERWIDE
+    String result = (wideName
+                    ? xw->misc.face_wide_name
+                    : xw->misc.face_name);
+#else
+    String result = xw->misc.face_name;
+#endif
+    if (!IsEmpty(result) && !strncmp(result, "xft:", (size_t) 4))
+       result += 4;
+    return x_nonempty(result);
+}
+
+/*
+ * If we change the faceName, we'll have to re-acquire all of the fonts that
+ * are derived from it.
+ */
+void
+setFaceName(XtermWidget xw, const char *value)
+{
+    TScreen *screen = TScreenOf(xw);
+    int n;
+
+    xw->misc.face_name = x_strdup(value);
+    for (n = 0; n < NMENUFONTS; ++n) {
+       xw->misc.face_size[n] = -1.0;
+       xtermCloseXft(screen, &(screen->renderFontNorm[n]));
+       xtermCloseXft(screen, &(screen->renderFontBold[n]));
+       xtermCloseXft(screen, &(screen->renderFontBold[n]));
+#if OPT_RENDERWIDE
+       xtermCloseXft(screen, &(screen->renderWideNorm[n]));
+       xtermCloseXft(screen, &(screen->renderWideBold[n]));
+       xtermCloseXft(screen, &(screen->renderWideItal[n]));
+#endif
+    }
+}
+#endif
+
+/*
+ * Compute useful values for the font/window sizes
+ */
+void
+xtermComputeFontInfo(XtermWidget xw,
+                    VTwin * win,
+                    XFontStruct * font,
+                    int sbwidth)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    int i, j, width, height;
+#if OPT_RENDERFONT
+    int fontnum = screen->menu_font_number;
+#endif
+
+#if OPT_RENDERFONT
+    /*
+     * xterm contains a lot of references to fonts, assuming they are fixed
+     * size.  This chunk of code overrides the actual font-selection (see
+     * drawXtermText()), if the user has selected render-font.  All of the
+     * font-loading for fixed-fonts still goes on whether or not this chunk
+     * overrides it.
+     */
+    if (UsingRenderFont(xw) && fontnum >= 0) {
+       String face_name = getFaceName(xw, False);
+       XftFont *norm = screen->renderFontNorm[fontnum].font;
+       XftFont *bold = screen->renderFontBold[fontnum].font;
+       XftFont *ital = screen->renderFontItal[fontnum].font;
+#if OPT_RENDERWIDE
+       XftFont *wnorm = screen->renderWideNorm[fontnum].font;
+       XftFont *wbold = screen->renderWideBold[fontnum].font;
+       XftFont *wital = screen->renderWideItal[fontnum].font;
+#endif
+
+       if (norm == 0 && face_name) {
+           XftPattern *pat;
+           double face_size = xw->misc.face_size[fontnum];
+
+           TRACE(("xtermComputeFontInfo font %d: norm(face %s, size %f)\n",
+                  fontnum, face_name,
+                  xw->misc.face_size[fontnum]));
+
+           if (face_size <= 0.0) {
+#if OPT_SHIFT_FONTS
+               /*
+                * If the user is switching font-sizes, make it follow by
+                * default the same ratios to the default as the fixed fonts
+                * would, for easy comparison.  There will be some differences
+                * since the fixed fonts have a variety of height/width ratios,
+                * but this is simpler than adding another resource value - and
+                * as noted above, the data for the fixed fonts are available.
+                */
+               lookupOneFontSize(xw, 0);
+               lookupOneFontSize(xw, fontnum);
+               if (fontnum == fontMenu_default) {
+                   face_size = 14.0;
+               } else {
+                   double ratio;
+                   long num = screen->menu_font_sizes[fontnum];
+                   long den = screen->menu_font_sizes[0];
+
+                   if (den <= 0)
+                       den = 1;
+                   ratio = mySquareRoot((double) num / (double) den);
+
+                   face_size = (ratio * xw->misc.face_size[0]);
+                   TRACE(("scaled using %3ld/%ld = %.2f -> %f\n",
+                          num, den, ratio, face_size));
+               }
+#else
+               switch (fontnum) {
+               case fontMenu_font1:
+                   face_size = 8.0;
+                   break;
+               case fontMenu_font2:
+                   face_size = 10.0;
+                   break;
+               case fontMenu_font3:
+                   face_size = 12.0;
+                   break;
+               default:
+                   face_size = 14.0;
+                   break;
+               case fontMenu_font4:
+                   face_size = 16.0;
+                   break;
+               case fontMenu_font5:
+                   face_size = 18.0;
+                   break;
+               case fontMenu_font6:
+                   face_size = 20.0;
+                   break;
+               }
+#endif
+               xw->misc.face_size[fontnum] = (float) face_size;
+           }
+
+           /*
+            * By observation (there is no documentation), XftPatternBuild is
+            * cumulative.  Build the bold- and italic-patterns on top of the
+            * normal pattern.
+            */
+#define NormXftPattern \
+           XFT_FAMILY, XftTypeString, "mono", \
+           XFT_SIZE, XftTypeDouble, face_size, \
+           XFT_SPACING, XftTypeInteger, XFT_MONO
+
+#define BoldXftPattern(norm) \
+           XFT_WEIGHT, XftTypeInteger, XFT_WEIGHT_BOLD, \
+           XFT_CHAR_WIDTH, XftTypeInteger, norm->max_advance_width
+
+#define ItalXftPattern(norm) \
+           XFT_SLANT, XftTypeInteger, XFT_SLANT_ITALIC, \
+           XFT_CHAR_WIDTH, XftTypeInteger, norm->max_advance_width
+
+           if ((pat = XftNameParse(face_name)) != 0) {
+#define OPEN_XFT(tag) xtermOpenXft(xw, face_name, pat, tag)
+               XftPatternBuild(pat,
+                               NormXftPattern,
+                               (void *) 0);
+               norm = OPEN_XFT("normal");
+
+               if (norm != 0) {
+                   XftPatternBuild(pat,
+                                   BoldXftPattern(norm),
+                                   (void *) 0);
+                   bold = OPEN_XFT("bold");
+
+#if OPT_ISO_COLORS
+                   if (screen->italicULMode
+                       && (pat = XftNameParse(face_name)) != 0) {
+                       XftPatternBuild(pat,
+                                       NormXftPattern,
+                                       ItalXftPattern(norm),
+                                       (void *) 0);
+                       ital = OPEN_XFT("italic");
+                   }
+#endif /* OPT_ISO_COLORS */
+#undef OPEN_XFT
+
+                   /*
+                    * FIXME:  just assume that the corresponding font has no
+                    * graphics characters.
+                    */
+                   if (screen->fnt_boxes) {
+                       screen->fnt_boxes = False;
+                       TRACE(("Xft opened - will %suse internal line-drawing characters\n",
+                              screen->fnt_boxes ? "not " : ""));
+                   }
+               }
+
+               XftPatternDestroy(pat);
+           }
+
+           CACHE_XFT(screen->renderFontNorm, norm);
+           CACHE_XFT(screen->renderFontBold, bold);
+           CACHE_XFT(screen->renderFontItal, ital);
+
+           /*
+            * See xtermXftDrawString().
+            */
+#if OPT_RENDERWIDE
+           if (norm != 0 && screen->wide_chars) {
+               int char_width = norm->max_advance_width * 2;
+#ifdef FC_ASPECT
+               double aspect = ((xw->misc.face_wide_name
+                                 || screen->renderFontNorm[fontnum].map.mixed)
+                                ? 1.0
+                                : 2.0);
+#endif
+
+               face_name = getFaceName(xw, True);
+               TRACE(("xtermComputeFontInfo wide(face %s, char_width %d)\n",
+                      NonNull(face_name),
+                      char_width));
+
+#define WideXftPattern \
+               XFT_FAMILY, XftTypeString, "mono", \
+               XFT_SIZE, XftTypeDouble, face_size, \
+               XFT_SPACING, XftTypeInteger, XFT_MONO
+
+               if (face_name && (pat = XftNameParse(face_name)) != 0) {
+#define OPEN_XFT(tag) xtermOpenXft(xw, face_name, pat, tag)
+                   XftPatternBuild(pat,
+                                   WideXftPattern,
+                                   XFT_CHAR_WIDTH, XftTypeInteger, char_width,
+#ifdef FC_ASPECT
+                                   FC_ASPECT, XftTypeDouble, aspect,
+#endif
+                                   (void *) 0);
+                   wnorm = OPEN_XFT("wide");
+
+                   if (wnorm != 0) {
+                       XftPatternBuild(pat,
+                                       WideXftPattern,
+                                       BoldXftPattern(wnorm),
+                                       (void *) 0);
+                       wbold = OPEN_XFT("wide-bold");
+
+#if OPT_ISO_COLORS
+                       if (screen->italicULMode
+                           && (pat = XftNameParse(face_name)) != 0) {
+                           XftPatternBuild(pat,
+                                           WideXftPattern,
+                                           ItalXftPattern(wnorm),
+                                           (void *) 0);
+                           wital = OPEN_XFT("wide-italic");
+                       }
+#endif
+#undef OPEN_XFT
+                   }
+                   XftPatternDestroy(pat);
+               }
+
+               CACHE_XFT(screen->renderWideNorm, wnorm);
+               CACHE_XFT(screen->renderWideBold, wbold);
+               CACHE_XFT(screen->renderWideItal, wital);
+           }
+#endif /* OPT_RENDERWIDE */
+       }
+       if (norm == 0) {
+           TRACE(("...no TrueType font found for number %d, disable menu entry\n", fontnum));
+           xw->misc.render_font = False;
+           update_font_renderfont();
+           /* now we will fall through into the bitmap fonts */
+       } else {
+           setRenderFontsize(screen, win, norm, NULL);
+           setRenderFontsize(screen, win, bold, "bold");
+           setRenderFontsize(screen, win, ital, "ital");
+#if OPT_BOX_CHARS
+           setupPackedFonts(xw);
+
+           if (screen->force_packed) {
+               XTermXftFonts *use = &(screen->renderFontNorm[fontnum]);
+               win->f_height = use->font->ascent + use->font->descent;
+               win->f_width = use->map.min_width;
+               TRACE(("...packed TrueType font %dx%d vs %d\n",
+                      win->f_height,
+                      win->f_width,
+                      use->map.max_width));
+           }
+#endif
+           DUMP_XFT(xw, &(screen->renderFontNorm[fontnum]));
+       }
+    }
+    /*
+     * Are we handling a bitmap font?
+     */
+    else
+#endif /* OPT_RENDERFONT */
+    {
+       if (is_double_width_font(font) && !(screen->fnt_prop)) {
+           win->f_width = (font->min_bounds.width);
+       } else {
+           win->f_width = (font->max_bounds.width);
+       }
+       win->f_height = (font->ascent + font->descent);
+       win->f_ascent = font->ascent;
+       win->f_descent = font->descent;
+    }
+    i = 2 * screen->border + sbwidth;
+    j = 2 * screen->border;
+    width = MaxCols(screen) * win->f_width + i;
+    height = MaxRows(screen) * win->f_height + j;
+    win->fullwidth = (Dimension) width;
+    win->fullheight = (Dimension) height;
+    win->width = width - i;
+    win->height = height - j;
+
+    TRACE(("xtermComputeFontInfo window %dx%d (full %dx%d), fontsize %dx%d (asc %d, dsc %d)\n",
+          win->height,
+          win->width,
+          win->fullheight,
+          win->fullwidth,
+          win->f_height,
+          win->f_width,
+          win->f_ascent,
+          win->f_descent));
+
+    checkFontInfo(win->f_height, "height");
+    checkFontInfo(win->f_width, "width");
+}
+
+/* save this information as a side-effect for double-sized characters */
+void
+xtermSaveFontInfo(TScreen * screen, XFontStruct * font)
+{
+    screen->fnt_wide = (Dimension) (font->max_bounds.width);
+    screen->fnt_high = (Dimension) (font->ascent + font->descent);
+    TRACE(("xtermSaveFontInfo %dx%d\n", screen->fnt_high, screen->fnt_wide));
+}
+
+/*
+ * After loading a new font, update the structures that use its size.
+ */
+void
+xtermUpdateFontInfo(XtermWidget xw, Bool doresize)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    int scrollbar_width;
+    VTwin *win = &(screen->fullVwin);
+
+    scrollbar_width = (xw->misc.scrollbar
+                      ? (screen->scrollWidget->core.width +
+                         BorderWidth(screen->scrollWidget))
+                      : 0);
+    xtermComputeFontInfo(xw, win, screen->fnts[fNorm].fs, scrollbar_width);
+    xtermSaveFontInfo(screen, screen->fnts[fNorm].fs);
+
+    if (doresize) {
+       if (VWindow(screen)) {
+           xtermClear(xw);
+       }
+       TRACE(("xtermUpdateFontInfo {{\n"));
+       DoResizeScreen(xw);     /* set to the new natural size */
+       ResizeScrollBar(xw);
+       Redraw();
+       TRACE(("... }} xtermUpdateFontInfo\n"));
+#ifdef SCROLLBAR_RIGHT
+       updateRightScrollbar(xw);
+#endif
+    }
+    xtermSetCursorBox(screen);
+}
+
+#if OPT_BOX_CHARS
+
+/*
+ * Returns true if the given character is missing from the specified font.
+ */
+Bool
+xtermMissingChar(unsigned ch, XTermFonts * font)
+{
+    Bool result = False;
+    XFontStruct *fs = font->fs;
+    static XCharStruct dft, *tmp = &dft, *pc = 0;
+
+    if (fs->max_byte1 == 0) {
+#if OPT_WIDE_CHARS
+       if (ch > 255) {
+           TRACE(("xtermMissingChar %#04x (row)\n", ch));
+           return True;
+       }
+#endif
+       CI_GET_CHAR_INFO_1D(fs, E2A(ch), tmp, pc);
+    }
+#if OPT_WIDE_CHARS
+    else {
+       CI_GET_CHAR_INFO_2D(fs, HI_BYTE(ch), LO_BYTE(ch), tmp, pc);
+    }
+#else
+
+    if (!pc)
+       return False;           /* Urgh! */
+#endif
+
+    if (CI_NONEXISTCHAR(pc)) {
+       TRACE(("xtermMissingChar %#04x (!exists)\n", ch));
+       result = True;
+    }
+    if (ch < 256) {
+       font->known_missing[ch] = (Char) (result ? 2 : 1);
+    }
+    return result;
+}
+
+/*
+ * The grid is arbitrary, enough resolution that nothing's lost in
+ * initialization.
+ */
+#define BOX_HIGH 60
+#define BOX_WIDE 60
+
+#define MID_HIGH (BOX_HIGH/2)
+#define MID_WIDE (BOX_WIDE/2)
+
+#define CHR_WIDE ((9*BOX_WIDE)/10)
+#define CHR_HIGH ((9*BOX_HIGH)/10)
+
+/*
+ * ...since we'll scale the values anyway.
+ */
+#define SCALE_X(n) n = (n * (((int) font_width) - 1)) / (BOX_WIDE-1)
+#define SCALE_Y(n) n = (n * (((int) font_height) - 1)) / (BOX_HIGH-1)
+
+#define SEG(x0,y0,x1,y1) x0,y0, x1,y1
+
+/*
+ * Draw the given graphic character, if it is simple enough (i.e., a
+ * line-drawing character).
+ */
+void
+xtermDrawBoxChar(XtermWidget xw,
+                unsigned ch,
+                unsigned flags,
+                GC gc,
+                int x,
+                int y,
+                int cells)
+{
+    TScreen *screen = TScreenOf(xw);
+    /* *INDENT-OFF* */
+    static const short glyph_ht[] = {
+       SEG(1*BOX_WIDE/10,  0,          1*BOX_WIDE/10,5*MID_HIGH/6),    /* H */
+       SEG(6*BOX_WIDE/10,  0,          6*BOX_WIDE/10,5*MID_HIGH/6),
+       SEG(1*BOX_WIDE/10,5*MID_HIGH/12,6*BOX_WIDE/10,5*MID_HIGH/12),
+       SEG(2*BOX_WIDE/10,  MID_HIGH,     CHR_WIDE,     MID_HIGH),      /* T */
+       SEG(6*BOX_WIDE/10,  MID_HIGH,   6*BOX_WIDE/10,  CHR_HIGH),
+       -1
+    }, glyph_ff[] = {
+       SEG(1*BOX_WIDE/10,  0,          6*BOX_WIDE/10,  0),             /* F */
+       SEG(1*BOX_WIDE/10,5*MID_HIGH/12,6*CHR_WIDE/12,5*MID_HIGH/12),
+       SEG(1*BOX_WIDE/10,  0,          0*BOX_WIDE/3, 5*MID_HIGH/6),
+       SEG(1*BOX_WIDE/3,   MID_HIGH,     CHR_WIDE,     MID_HIGH),      /* F */
+       SEG(1*BOX_WIDE/3, 8*MID_HIGH/6,10*CHR_WIDE/12,8*MID_HIGH/6),
+       SEG(1*BOX_WIDE/3,   MID_HIGH,   1*BOX_WIDE/3,   CHR_HIGH),
+       -1
+    }, glyph_lf[] = {
+       SEG(1*BOX_WIDE/10,  0,          1*BOX_WIDE/10,9*MID_HIGH/12),   /* L */
+       SEG(1*BOX_WIDE/10,9*MID_HIGH/12,6*BOX_WIDE/10,9*MID_HIGH/12),
+       SEG(1*BOX_WIDE/3,   MID_HIGH,     CHR_WIDE,     MID_HIGH),      /* F */
+       SEG(1*BOX_WIDE/3, 8*MID_HIGH/6,10*CHR_WIDE/12,8*MID_HIGH/6),
+       SEG(1*BOX_WIDE/3,   MID_HIGH,   1*BOX_WIDE/3,   CHR_HIGH),
+       -1
+    }, glyph_nl[] = {
+       SEG(1*BOX_WIDE/10,5*MID_HIGH/6, 1*BOX_WIDE/10,  0),             /* N */
+       SEG(1*BOX_WIDE/10,  0,          5*BOX_WIDE/6, 5*MID_HIGH/6),
+       SEG(5*BOX_WIDE/6, 5*MID_HIGH/6, 5*BOX_WIDE/6,   0),
+       SEG(1*BOX_WIDE/3,   MID_HIGH,   1*BOX_WIDE/3,   CHR_HIGH),      /* L */
+       SEG(1*BOX_WIDE/3,   CHR_HIGH,     CHR_WIDE,     CHR_HIGH),
+       -1
+    }, glyph_vt[] = {
+       SEG(1*BOX_WIDE/10,   0,         5*BOX_WIDE/12,5*MID_HIGH/6),    /* V */
+       SEG(5*BOX_WIDE/12,5*MID_HIGH/6, 5*BOX_WIDE/6,   0),
+       SEG(2*BOX_WIDE/10,  MID_HIGH,     CHR_WIDE,     MID_HIGH),      /* T */
+       SEG(6*BOX_WIDE/10,  MID_HIGH,   6*BOX_WIDE/10,  CHR_HIGH),
+       -1
+    }, plus_or_minus[] =
+    {
+       SEG(  0,          5*BOX_HIGH/6,   CHR_WIDE,   5*BOX_HIGH/6),
+       SEG(  MID_WIDE,   2*BOX_HIGH/6,   MID_WIDE,   4*BOX_HIGH/6),
+       SEG(  0,          3*BOX_HIGH/6,   CHR_WIDE,   3*BOX_HIGH/6),
+       -1
+    }, lower_right_corner[] =
+    {
+       SEG(  0,            MID_HIGH,     MID_WIDE,     MID_HIGH),
+       SEG(  MID_WIDE,     MID_HIGH,     MID_WIDE,     0),
+       -1
+    }, upper_right_corner[] =
+    {
+       SEG(  0,            MID_HIGH,     MID_WIDE,     MID_HIGH),
+       SEG( MID_WIDE,      MID_HIGH,     MID_WIDE,     BOX_HIGH),
+       -1
+    }, upper_left_corner[] =
+    {
+       SEG(  MID_WIDE,     MID_HIGH,     BOX_WIDE,     MID_HIGH),
+       SEG(  MID_WIDE,     MID_HIGH,     MID_WIDE,     BOX_HIGH),
+       -1
+    }, lower_left_corner[] =
+    {
+       SEG(  MID_WIDE,     0,            MID_WIDE,     MID_HIGH),
+       SEG(  MID_WIDE,     MID_WIDE,     BOX_WIDE,     MID_HIGH),
+       -1
+    }, cross[] =
+    {
+       SEG(  0,            MID_HIGH,     BOX_WIDE,     MID_HIGH),
+       SEG(  MID_WIDE,     0,            MID_WIDE,     BOX_HIGH),
+       -1
+    }, scan_line_1[] =
+    {
+       SEG(  0,            0,            BOX_WIDE,     0),
+       -1
+    }, scan_line_3[] =
+    {
+       SEG(  0,            BOX_HIGH/4,   BOX_WIDE,     BOX_HIGH/4),
+       -1
+    }, scan_line_7[] =
+    {
+       SEG( 0,             MID_HIGH,     BOX_WIDE,     MID_HIGH),
+       -1
+    }, scan_line_9[] =
+    {
+       SEG(  0,          3*BOX_HIGH/4,   BOX_WIDE,   3*BOX_HIGH/4),
+       -1
+    }, horizontal_line[] =
+    {
+       SEG(  0,            BOX_HIGH,     BOX_WIDE,     BOX_HIGH),
+       -1
+    }, left_tee[] =
+    {
+       SEG(  MID_WIDE,     0,            MID_WIDE,     BOX_HIGH),
+       SEG(  MID_WIDE,     MID_HIGH,     BOX_WIDE,     MID_HIGH),
+       -1
+    }, right_tee[] =
+    {
+       SEG(  MID_WIDE,     0,            MID_WIDE,     BOX_HIGH),
+       SEG(  MID_WIDE,     MID_HIGH,     0,            MID_HIGH),
+       -1
+    }, bottom_tee[] =
+    {
+       SEG(  0,            MID_HIGH,     BOX_WIDE,     MID_HIGH),
+       SEG(  MID_WIDE,     0,            MID_WIDE,     MID_HIGH),
+       -1
+    }, top_tee[] =
+    {
+       SEG(  0,            MID_HIGH,     BOX_WIDE,     MID_HIGH),
+       SEG(  MID_WIDE,     MID_HIGH,     MID_WIDE,     BOX_HIGH),
+       -1
+    }, vertical_line[] =
+    {
+       SEG(  MID_WIDE,     0,            MID_WIDE,     BOX_HIGH),
+       -1
+    }, less_than_or_equal[] =
+    {
+       SEG(  CHR_WIDE,     BOX_HIGH/3,   0,            MID_HIGH),
+       SEG(  CHR_WIDE,   2*BOX_HIGH/3,   0,            MID_HIGH),
+       SEG(  0,          3*BOX_HIGH/4,   CHR_WIDE,   3*BOX_HIGH/4),
+       -1
+    }, greater_than_or_equal[] =
+    {
+       SEG(  0,            BOX_HIGH/3,   CHR_WIDE,     MID_HIGH),
+       SEG(  0,          2*BOX_HIGH/3,   CHR_WIDE,     MID_HIGH),
+       SEG(  0,          3*BOX_HIGH/4,   CHR_WIDE,   3*BOX_HIGH/4),
+       -1
+    }, greek_pi[] =
+    {
+       SEG(  0,            MID_HIGH,     CHR_WIDE,     MID_HIGH),
+       SEG(5*CHR_WIDE/6,   MID_HIGH,   5*CHR_WIDE/6,   CHR_HIGH),
+       SEG(2*CHR_WIDE/6,   MID_HIGH,   2*CHR_WIDE/6,   CHR_HIGH),
+       -1
+    }, not_equal_to[] =
+    {
+       SEG(2*BOX_WIDE/3, 1*BOX_HIGH/3, 1*BOX_WIDE/3,   CHR_HIGH),
+       SEG(  0,          2*BOX_HIGH/3,   CHR_WIDE,   2*BOX_HIGH/3),
+       SEG(  0,            MID_HIGH,     CHR_WIDE,     MID_HIGH),
+       -1
+    };
+    /* *INDENT-ON* */
+
+    static const short *lines[] =
+    {
+       0,                      /* 00 (unused) */
+       0,                      /* 01 diamond */
+       0,                      /* 02 box */
+       glyph_ht,               /* 03 HT */
+       glyph_ff,               /* 04 FF */
+       0,                      /* 05 CR */
+       glyph_lf,               /* 06 LF */
+       0,                      /* 07 degrees (small circle) */
+       plus_or_minus,          /* 08 */
+       glyph_nl,               /* 09 */
+       glyph_vt,               /* 0A */
+       lower_right_corner,     /* 0B */
+       upper_right_corner,     /* 0C */
+       upper_left_corner,      /* 0D */
+       lower_left_corner,      /* 0E */
+       cross,                  /* 0F */
+       scan_line_1,            /* 10 */
+       scan_line_3,            /* 11 */
+       scan_line_7,            /* 12 */
+       scan_line_9,            /* 13 */
+       horizontal_line,        /* 14 */
+       left_tee,               /* 15 */
+       right_tee,              /* 16 */
+       bottom_tee,             /* 17 */
+       top_tee,                /* 18 */
+       vertical_line,          /* 19 */
+       less_than_or_equal,     /* 1A */
+       greater_than_or_equal,  /* 1B */
+       greek_pi,               /* 1C */
+       not_equal_to,           /* 1D */
+       0,                      /* 1E LB */
+       0,                      /* 1F bullet */
+    };
+
+    GC gc2;
+    CgsEnum cgsId = (ch == 2) ? gcDots : gcLine;
+    VTwin *cgsWin = WhichVWin(screen);
+    const short *p;
+    unsigned font_width = (unsigned) (((flags & DOUBLEWFONT) ? 2 : 1) * screen->fnt_wide);
+    unsigned font_height = (unsigned) (((flags & DOUBLEHFONT) ? 2 : 1) * screen->fnt_high);
+
+    if (cells > 1)
+       font_width *= (unsigned) cells;
+
+#if OPT_WIDE_CHARS
+    /*
+     * Try to show line-drawing characters if we happen to be in UTF-8
+     * mode, but have gotten an old-style font.
+     */
+    if (screen->utf8_mode
+#if OPT_RENDERFONT
+       && !UsingRenderFont(xw)
+#endif
+       && (ch > 127)
+       && (ch != UCS_REPL)) {
+       unsigned n;
+       for (n = 1; n < 32; n++) {
+           if (dec2ucs(n) == ch
+               && !((flags & BOLD)
+                    ? IsXtermMissingChar(screen, n, &screen->fnts[fBold])
+                    : IsXtermMissingChar(screen, n, &screen->fnts[fNorm]))) {
+               TRACE(("...use xterm-style linedrawing\n"));
+               ch = n;
+               break;
+           }
+       }
+    }
+#endif
+
+    TRACE(("DRAW_BOX(%d) cell %dx%d at %d,%d%s\n",
+          ch, font_height, font_width, y, x,
+          (ch >= (sizeof(lines) / sizeof(lines[0]))
+           ? "-BAD"
+           : "")));
+
+    if (cgsId == gcDots) {
+       setCgsFont(xw, cgsWin, cgsId, getCgsFont(xw, cgsWin, gc));
+       setCgsFore(xw, cgsWin, cgsId, getCgsFore(xw, cgsWin, gc));
+       setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc));
+    } else {
+       setCgsFont(xw, cgsWin, cgsId, getCgsFont(xw, cgsWin, gc));
+       setCgsFore(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc));
+       setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc));
+    }
+    gc2 = getCgsGC(xw, cgsWin, cgsId);
+
+    if (!(flags & NOBACKGROUND)) {
+       XFillRectangle(screen->display, VWindow(screen), gc2, x, y,
+                      font_width,
+                      font_height);
+    }
+
+    setCgsFont(xw, cgsWin, cgsId, getCgsFont(xw, cgsWin, gc));
+    setCgsFore(xw, cgsWin, cgsId, getCgsFore(xw, cgsWin, gc));
+    setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc));
+    gc2 = getCgsGC(xw, cgsWin, cgsId);
+
+    XSetLineAttributes(screen->display, gc2,
+                      (flags & BOLD)
+                      ? ((font_height > 12)
+                         ? font_height / 12
+                         : 1)
+                      : ((font_height > 16)
+                         ? font_height / 16
+                         : 1),
+                      LineSolid,
+                      CapProjecting,
+                      JoinMiter);
+
+    if (ch == 1) {             /* diamond */
+       XPoint points[5];
+       int npoints = 5, n;
+
+       points[0].x = MID_WIDE;
+       points[0].y = BOX_HIGH / 4;
+
+       points[1].x = 8 * BOX_WIDE / 8;
+       points[1].y = MID_HIGH;
+
+       points[2].x = points[0].x;
+       points[2].y = 3 * BOX_HIGH / 4;
+
+       points[3].x = 0 * BOX_WIDE / 8;
+       points[3].y = points[1].y;
+
+       points[4].x = points[0].x;
+       points[4].y = points[0].y;
+
+       for (n = 0; n < npoints; ++n) {
+           SCALE_X(points[n].x);
+           SCALE_Y(points[n].y);
+           points[n].x += x;
+           points[n].y += y;
+       }
+
+       XFillPolygon(screen->display,
+                    VWindow(screen), gc2,
+                    points, npoints,
+                    Convex, CoordModeOrigin);
+    } else if (ch == 7) {      /* degrees */
+       unsigned width = (BOX_WIDE / 3);
+       int x_coord = MID_WIDE - (int) (width / 2);
+       int y_coord = MID_HIGH - (int) width;
+
+       SCALE_X(x_coord);
+       SCALE_Y(y_coord);
+       SCALE_X(width);
+
+       XDrawArc(screen->display,
+                VWindow(screen), gc2,
+                x + x_coord, y + y_coord, width, width,
+                0,
+                360 * 64);
+    } else if (ch == 0x1f) {   /* bullet */
+       unsigned width = 7 * BOX_WIDE / 10;
+       int x_coord = MID_WIDE - (int) (width / 3);
+       int y_coord = MID_HIGH - (int) (width / 3);
+
+       SCALE_X(x_coord);
+       SCALE_Y(y_coord);
+       SCALE_X(width);
+
+       XDrawArc(screen->display,
+                VWindow(screen), gc2,
+                x + x_coord, y + y_coord, width, width,
+                0,
+                360 * 64);
+    } else if (ch < (sizeof(lines) / sizeof(lines[0]))
+              && (p = lines[ch]) != 0) {
+       int coord[4];
+       int n = 0;
+       while (*p >= 0) {
+           coord[n++] = *p++;
+           if (n == 4) {
+               SCALE_X(coord[0]);
+               SCALE_Y(coord[1]);
+               SCALE_X(coord[2]);
+               SCALE_Y(coord[3]);
+               XDrawLine(screen->display,
+                         VWindow(screen), gc2,
+                         x + coord[0], y + coord[1],
+                         x + coord[2], y + coord[3]);
+               n = 0;
+           }
+       }
+    } else if (screen->force_all_chars) {
+       /* bounding rectangle, for debugging */
+       XDrawRectangle(screen->display, VWindow(screen), gc2, x, y,
+                      font_width - 1,
+                      font_height - 1);
+    }
+}
+
+#if OPT_RENDERFONT
+
+/*
+ * Check if the given character has a glyph known to Xft.
+ *
+ * see xc/lib/Xft/xftglyphs.c
+ */
+Bool
+xtermXftMissing(XtermWidget xw, XftFont * font, unsigned wc)
+{
+    Bool result = False;
+
+    if (font != 0) {
+       TScreen *screen = TScreenOf(xw);
+       if (!XftGlyphExists(screen->display, font, wc)) {
+#if OPT_WIDE_CHARS
+           TRACE(("xtermXftMissing %d (dec=%#x, ucs=%#x)\n",
+                  wc, ucs2dec(wc), dec2ucs(wc)));
+#else
+           TRACE(("xtermXftMissing %d\n", wc));
+#endif
+           result = True;
+       }
+    }
+    return result;
+}
+#endif /* OPT_RENDERFONT && OPT_WIDE_CHARS */
+
+#endif /* OPT_BOX_CHARS */
+
+#if OPT_WIDE_CHARS
+#define MY_UCS(ucs,dec) case ucs: result = dec; break
+unsigned
+ucs2dec(unsigned ch)
+{
+    unsigned result = ch;
+    if ((ch > 127)
+       && (ch != UCS_REPL)) {
+       switch (ch) {
+           MY_UCS(0x25ae, 0);  /* black vertical rectangle                   */
+           MY_UCS(0x25c6, 1);  /* black diamond                              */
+           MY_UCS(0x2592, 2);  /* medium shade                               */
+           MY_UCS(0x2409, 3);  /* symbol for horizontal tabulation           */
+           MY_UCS(0x240c, 4);  /* symbol for form feed                       */
+           MY_UCS(0x240d, 5);  /* symbol for carriage return                 */
+           MY_UCS(0x240a, 6);  /* symbol for line feed                       */
+           MY_UCS(0x00b0, 7);  /* degree sign                                */
+           MY_UCS(0x00b1, 8);  /* plus-minus sign                            */
+           MY_UCS(0x2424, 9);  /* symbol for newline                         */
+           MY_UCS(0x240b, 10); /* symbol for vertical tabulation             */
+           MY_UCS(0x2518, 11); /* box drawings light up and left             */
+           MY_UCS(0x2510, 12); /* box drawings light down and left           */
+           MY_UCS(0x250c, 13); /* box drawings light down and right          */
+           MY_UCS(0x2514, 14); /* box drawings light up and right            */
+           MY_UCS(0x253c, 15); /* box drawings light vertical and horizontal */
+           MY_UCS(0x23ba, 16); /* box drawings scan 1                        */
+           MY_UCS(0x23bb, 17); /* box drawings scan 3                        */
+           MY_UCS(0x2500, 18); /* box drawings light horizontal              */
+           MY_UCS(0x23bc, 19); /* box drawings scan 7                        */
+           MY_UCS(0x23bd, 20); /* box drawings scan 9                        */
+           MY_UCS(0x251c, 21); /* box drawings light vertical and right      */
+           MY_UCS(0x2524, 22); /* box drawings light vertical and left       */
+           MY_UCS(0x2534, 23); /* box drawings light up and horizontal       */
+           MY_UCS(0x252c, 24); /* box drawings light down and horizontal     */
+           MY_UCS(0x2502, 25); /* box drawings light vertical                */
+           MY_UCS(0x2264, 26); /* less-than or equal to                      */
+           MY_UCS(0x2265, 27); /* greater-than or equal to                   */
+           MY_UCS(0x03c0, 28); /* greek small letter pi                      */
+           MY_UCS(0x2260, 29); /* not equal to                               */
+           MY_UCS(0x00a3, 30); /* pound sign                                 */
+           MY_UCS(0x00b7, 31); /* middle dot                                 */
+       }
+    }
+    return result;
+}
+
+#undef  MY_UCS
+#define MY_UCS(ucs,dec) case dec: result = ucs; break
+
+unsigned
+dec2ucs(unsigned ch)
+{
+    unsigned result = ch;
+    if (xtermIsDecGraphic(ch)) {
+       switch (ch) {
+           MY_UCS(0x25ae, 0);  /* black vertical rectangle                   */
+           MY_UCS(0x25c6, 1);  /* black diamond                              */
+           MY_UCS(0x2592, 2);  /* medium shade                               */
+           MY_UCS(0x2409, 3);  /* symbol for horizontal tabulation           */
+           MY_UCS(0x240c, 4);  /* symbol for form feed                       */
+           MY_UCS(0x240d, 5);  /* symbol for carriage return                 */
+           MY_UCS(0x240a, 6);  /* symbol for line feed                       */
+           MY_UCS(0x00b0, 7);  /* degree sign                                */
+           MY_UCS(0x00b1, 8);  /* plus-minus sign                            */
+           MY_UCS(0x2424, 9);  /* symbol for newline                         */
+           MY_UCS(0x240b, 10); /* symbol for vertical tabulation             */
+           MY_UCS(0x2518, 11); /* box drawings light up and left             */
+           MY_UCS(0x2510, 12); /* box drawings light down and left           */
+           MY_UCS(0x250c, 13); /* box drawings light down and right          */
+           MY_UCS(0x2514, 14); /* box drawings light up and right            */
+           MY_UCS(0x253c, 15); /* box drawings light vertical and horizontal */
+           MY_UCS(0x23ba, 16); /* box drawings scan 1                        */
+           MY_UCS(0x23bb, 17); /* box drawings scan 3                        */
+           MY_UCS(0x2500, 18); /* box drawings light horizontal              */
+           MY_UCS(0x23bc, 19); /* box drawings scan 7                        */
+           MY_UCS(0x23bd, 20); /* box drawings scan 9                        */
+           MY_UCS(0x251c, 21); /* box drawings light vertical and right      */
+           MY_UCS(0x2524, 22); /* box drawings light vertical and left       */
+           MY_UCS(0x2534, 23); /* box drawings light up and horizontal       */
+           MY_UCS(0x252c, 24); /* box drawings light down and horizontal     */
+           MY_UCS(0x2502, 25); /* box drawings light vertical                */
+           MY_UCS(0x2264, 26); /* less-than or equal to                      */
+           MY_UCS(0x2265, 27); /* greater-than or equal to                   */
+           MY_UCS(0x03c0, 28); /* greek small letter pi                      */
+           MY_UCS(0x2260, 29); /* not equal to                               */
+           MY_UCS(0x00a3, 30); /* pound sign                                 */
+           MY_UCS(0x00b7, 31); /* middle dot                                 */
+       }
+    }
+    return result;
+}
+
+#endif /* OPT_WIDE_CHARS */
+
+#if OPT_SHIFT_FONTS
+static void
+lookupOneFontSize(XtermWidget xw, int fontnum)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->menu_font_sizes[fontnum] == 0) {
+       XTermFonts fnt;
+
+       memset(&fnt, 0, sizeof(fnt));
+       screen->menu_font_sizes[fontnum] = -1;
+       if (xtermOpenFont(xw, screen->MenuFontName(fontnum), &fnt, fwAlways, True)) {
+           if (fontnum <= fontMenu_lastBuiltin
+               || strcmp(fnt.fn, DEFFONT))
+               screen->menu_font_sizes[fontnum] = FontSize(fnt.fs);
+           xtermCloseFont(xw, &fnt);
+       }
+    }
+}
+
+/*
+ * Cache the font-sizes so subsequent larger/smaller font actions will go fast.
+ */
+static void
+lookupFontSizes(XtermWidget xw)
+{
+    int n;
+
+    for (n = 0; n < NMENUFONTS; n++) {
+       lookupOneFontSize(xw, n);
+    }
+}
+
+#if OPT_RENDERFONT
+#define NMENU_RENDERFONTS (NMENUFONTS - 2)     /* no selection or escape */
+static Boolean
+useFaceSizes(XtermWidget xw)
+{
+    Boolean result = False;
+    int n;
+
+    if (UsingRenderFont(xw)) {
+       result = True;
+       for (n = 0; n < NMENU_RENDERFONTS; ++n) {
+           if (xw->misc.face_size[n] <= 0.0) {
+               result = False;
+               break;
+           }
+       }
+       if (!result) {
+           Boolean broken_fonts = True;
+           TScreen *screen = TScreenOf(xw);
+           long first = screen->menu_font_sizes[0];
+
+           lookupFontSizes(xw);
+           for (n = 0; n < NMENUFONTS; n++) {
+               if (screen->menu_font_sizes[n] > 0
+                   && screen->menu_font_sizes[n] != first) {
+                   broken_fonts = False;
+                   break;
+               }
+           }
+
+           /*
+            * Workaround for breakage in font-packages - check if all of the
+            * bitmap font sizes are the same, and if we're using TrueType
+            * fonts. 
+            */
+           if (broken_fonts) {
+               float lo_value = (float) 9.0e9;
+               float hi_value = (float) 0.0;
+               float value;
+
+               TRACE(("bitmap fonts are broken - set faceSize resources\n"));
+               for (n = 0; n < NMENUFONTS; n++) {
+                   value = xw->misc.face_size[n];
+                   if (value > 0.0) {
+                       if (lo_value > value)
+                           lo_value = value;
+                       if (hi_value < value)
+                           hi_value = value;
+                   }
+               }
+
+               if (hi_value <= 0.0)
+                   sscanf(DEFFACESIZE, "%f", &value);
+               else
+                   value = (float) ((hi_value + lo_value) / 2.0);
+               if (value <= 0)
+                   value = (float) 14.0;
+
+               for (n = 0; n < NMENUFONTS; n++) {
+                   TRACE(("setting faceSize%d %.1f\n", n, value));
+                   xw->misc.face_size[n] = value;
+                   value = (float) (value * 1.1);
+               }
+               result = True;
+           }
+       }
+    }
+    return result;
+}
+#endif
+
+/*
+ * Find the index of a larger/smaller font (according to the sign of 'relative'
+ * and its magnitude), starting from the 'old' index.
+ */
+int
+lookupRelativeFontSize(XtermWidget xw, int old, int relative)
+{
+    TScreen *screen = TScreenOf(xw);
+    int n, m = -1;
+
+    TRACE(("lookupRelativeFontSize(old=%d, relative=%d)\n", old, relative));
+    if (!IsIcon(screen)) {
+#if OPT_RENDERFONT
+       if (useFaceSizes(xw)) {
+           TRACE(("...using FaceSize\n"));
+           if (relative != 0) {
+               for (n = 0; n < NMENU_RENDERFONTS; ++n) {
+                   if (xw->misc.face_size[n] > 0 &&
+                       xw->misc.face_size[n] != xw->misc.face_size[old]) {
+                       int cmp_0 = ((xw->misc.face_size[n] >
+                                     xw->misc.face_size[old])
+                                    ? relative
+                                    : -relative);
+                       int cmp_m = ((m < 0)
+                                    ? 1
+                                    : ((xw->misc.face_size[n] <
+                                        xw->misc.face_size[m])
+                                       ? relative
+                                       : -relative));
+                       if (cmp_0 > 0 && cmp_m > 0) {
+                           m = n;
+                       }
+                   }
+               }
+           }
+       } else
+#endif
+       {
+           TRACE(("...using bitmap areas\n"));
+           lookupFontSizes(xw);
+           if (relative != 0) {
+               for (n = 0; n < NMENUFONTS; ++n) {
+                   if (screen->menu_font_sizes[n] > 0 &&
+                       screen->menu_font_sizes[n] !=
+                       screen->menu_font_sizes[old]) {
+                       int cmp_0 = ((screen->menu_font_sizes[n] >
+                                     screen->menu_font_sizes[old])
+                                    ? relative
+                                    : -relative);
+                       int cmp_m = ((m < 0)
+                                    ? 1
+                                    : ((screen->menu_font_sizes[n] <
+                                        screen->menu_font_sizes[m])
+                                       ? relative
+                                       : -relative));
+                       if (cmp_0 > 0 && cmp_m > 0) {
+                           m = n;
+                       }
+                   }
+               }
+           }
+       }
+       TRACE(("...new index %d\n", m));
+       if (m >= 0) {
+           if (relative > 1)
+               m = lookupRelativeFontSize(xw, m, relative - 1);
+           else if (relative < -1)
+               m = lookupRelativeFontSize(xw, m, relative + 1);
+       }
+    }
+    return m;
+}
+
+/* ARGSUSED */
+void
+HandleLargerFont(Widget w GCC_UNUSED,
+                XEvent * event GCC_UNUSED,
+                String * params GCC_UNUSED,
+                Cardinal *param_count GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    TRACE(("Handle larger-vt-font for %p\n", (void *) w));
+    if ((xw = getXtermWidget(w)) != 0) {
+       if (xw->misc.shift_fonts) {
+           TScreen *screen = TScreenOf(xw);
+           int m;
+
+           m = lookupRelativeFontSize(xw, screen->menu_font_number, 1);
+           if (m >= 0) {
+               SetVTFont(xw, m, True, NULL);
+           } else {
+               Bell(xw, XkbBI_MinorError, 0);
+           }
+       }
+    }
+}
+
+/* ARGSUSED */
+void
+HandleSmallerFont(Widget w GCC_UNUSED,
+                 XEvent * event GCC_UNUSED,
+                 String * params GCC_UNUSED,
+                 Cardinal *param_count GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    TRACE(("Handle smaller-vt-font for %p\n", (void *) w));
+    if ((xw = getXtermWidget(w)) != 0) {
+       if (xw->misc.shift_fonts) {
+           TScreen *screen = TScreenOf(xw);
+           int m;
+
+           m = lookupRelativeFontSize(xw, screen->menu_font_number, -1);
+           if (m >= 0) {
+               SetVTFont(xw, m, True, NULL);
+           } else {
+               Bell(xw, XkbBI_MinorError, 0);
+           }
+       }
+    }
+}
+#endif
+
+int
+xtermGetFont(const char *param)
+{
+    int fontnum;
+
+    switch (param[0]) {
+    case 'd':
+    case 'D':
+    case '0':
+       fontnum = fontMenu_default;
+       break;
+    case '1':
+       fontnum = fontMenu_font1;
+       break;
+    case '2':
+       fontnum = fontMenu_font2;
+       break;
+    case '3':
+       fontnum = fontMenu_font3;
+       break;
+    case '4':
+       fontnum = fontMenu_font4;
+       break;
+    case '5':
+       fontnum = fontMenu_font5;
+       break;
+    case '6':
+       fontnum = fontMenu_font6;
+       break;
+    case 'e':
+    case 'E':
+       fontnum = fontMenu_fontescape;
+       break;
+    case 's':
+    case 'S':
+       fontnum = fontMenu_fontsel;
+       break;
+    default:
+       fontnum = -1;
+       break;
+    }
+    return fontnum;
+}
+
+/* ARGSUSED */
+void
+HandleSetFont(Widget w GCC_UNUSED,
+             XEvent * event GCC_UNUSED,
+             String * params,
+             Cardinal *param_count)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       int fontnum;
+       VTFontNames fonts;
+
+       memset(&fonts, 0, sizeof(fonts));
+
+       if (*param_count == 0) {
+           fontnum = fontMenu_default;
+       } else {
+           Cardinal maxparams = 1;     /* total number of params allowed */
+           int result = xtermGetFont(params[0]);
+
+           switch (result) {
+           case fontMenu_default:      /* FALLTHRU */
+           case fontMenu_font1:        /* FALLTHRU */
+           case fontMenu_font2:        /* FALLTHRU */
+           case fontMenu_font3:        /* FALLTHRU */
+           case fontMenu_font4:        /* FALLTHRU */
+           case fontMenu_font5:        /* FALLTHRU */
+           case fontMenu_font6:        /* FALLTHRU */
+               break;
+           case fontMenu_fontescape:
+#if OPT_WIDE_CHARS
+               maxparams = 5;
+#else
+               maxparams = 3;
+#endif
+               break;
+           case fontMenu_fontsel:
+               maxparams = 2;
+               break;
+           default:
+               Bell(xw, XkbBI_MinorError, 0);
+               return;
+           }
+           fontnum = result;
+
+           if (*param_count > maxparams) {     /* see if extra args given */
+               Bell(xw, XkbBI_MinorError, 0);
+               return;
+           }
+           switch (*param_count) {     /* assign 'em */
+#if OPT_WIDE_CHARS
+           case 5:
+               fonts.f_wb = params[4];
+               /* FALLTHRU */
+           case 4:
+               fonts.f_w = params[3];
+               /* FALLTHRU */
+#endif
+           case 3:
+               fonts.f_b = params[2];
+               /* FALLTHRU */
+           case 2:
+               fonts.f_n = params[1];
+               break;
+           }
+       }
+
+       SetVTFont(xw, fontnum, True, &fonts);
+    }
+}
+
+void
+SetVTFont(XtermWidget xw,
+         int which,
+         Bool doresize,
+         const VTFontNames * fonts)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("SetVTFont(which=%d, f_n=%s, f_b=%s)\n", which,
+          (fonts && fonts->f_n) ? fonts->f_n : "<null>",
+          (fonts && fonts->f_b) ? fonts->f_b : "<null>"));
+
+    if (IsIcon(screen)) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else if (which >= 0 && which < NMENUFONTS) {
+       VTFontNames myfonts;
+
+       memset(&myfonts, 0, sizeof(myfonts));
+       if (fonts != 0)
+           myfonts = *fonts;
+
+       if (which == fontMenu_fontsel) {        /* go get the selection */
+           FindFontSelection(xw, myfonts.f_n, False);
+       } else {
+           int oldFont = screen->menu_font_number;
+
+#define USE_CACHED(field, name) \
+           if (myfonts.field == 0) { \
+               myfonts.field = x_strdup(screen->menu_font_names[which][name]); \
+               TRACE(("set myfonts." #field " from menu_font_names[%d][" #name "] %s\n", \
+                      which, NonNull(myfonts.field))); \
+           } else { \
+               TRACE(("set myfonts." #field " reused\n")); \
+           }
+#define SAVE_FNAME(field, name) \
+           if (myfonts.field != 0) { \
+               if (screen->menu_font_names[which][name] == 0 \
+                || strcmp(screen->menu_font_names[which][name], myfonts.field)) { \
+                   TRACE(("updating menu_font_names[%d][" #name "] to %s\n", \
+                          which, myfonts.field)); \
+                   screen->menu_font_names[which][name] = x_strdup(myfonts.field); \
+               } \
+           }
+
+           USE_CACHED(f_n, fNorm);
+           USE_CACHED(f_b, fBold);
+#if OPT_WIDE_CHARS
+           USE_CACHED(f_w, fWide);
+           USE_CACHED(f_wb, fWBold);
+#endif
+           if (xtermLoadFont(xw,
+                             &myfonts,
+                             doresize, which)) {
+               /*
+                * If successful, save the data so that a subsequent query via
+                * OSC-50 will return the expected values.
+                */
+               SAVE_FNAME(f_n, fNorm);
+               SAVE_FNAME(f_b, fBold);
+#if OPT_WIDE_CHARS
+               SAVE_FNAME(f_w, fWide);
+               SAVE_FNAME(f_wb, fWBold);
+#endif
+           } else {
+               xtermLoadFont(xw,
+                             xtermFontName(screen->MenuFontName(oldFont)),
+                             doresize, oldFont);
+               Bell(xw, XkbBI_MinorError, 0);
+           }
+       }
+    } else {
+       Bell(xw, XkbBI_MinorError, 0);
+    }
+    return;
+}
diff --git a/fontutils.h b/fontutils.h
new file mode 100644 (file)
index 0000000..c9a87a5
--- /dev/null
@@ -0,0 +1,119 @@
+/* $XTermId: fontutils.h,v 1.82 2010/10/11 08:13:54 tom Exp $ */
+
+/************************************************************
+
+Copyright 1998-2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#ifndef included_fontutils_h
+#define included_fontutils_h 1
+
+#include <xterm.h>
+
+extern Bool xtermLoadDefaultFonts (XtermWidget /* xw */);
+extern Bool xtermOpenFont (XtermWidget /* xw */, const char */* name */, XTermFonts * /* result */, fontWarningTypes /* warn */, Bool /* force */);
+extern XTermFonts * xtermCloseFont (XtermWidget /* xw */, XTermFonts * /* fnt */);
+extern const VTFontNames * xtermFontName (const char */* normal */);
+extern int lookupRelativeFontSize (XtermWidget /* xw */, int /* old */, int /* relative */);
+extern int xtermGetFont(const char * /* param */);
+extern int xtermLoadFont (XtermWidget /* xw */, const VTFontNames */* fonts */, Bool /* doresize */, int /* fontnum */);
+extern void HandleSetFont PROTO_XT_ACTIONS_ARGS;
+extern void SetVTFont (XtermWidget /* xw */, int /* i */, Bool /* doresize */, const VTFontNames */* fonts */);
+extern void xtermCloseFonts (XtermWidget /* xw */, XTermFonts * /* fnts[fMAX] */);
+extern void xtermComputeFontInfo (XtermWidget /* xw */, VTwin */* win */, XFontStruct */* font */, int /* sbwidth */);
+extern void xtermCopyFontInfo (XTermFonts * /* target */, XTermFonts * /* source */);
+extern void xtermFreeFontInfo (XTermFonts * /* target */);
+extern void xtermSaveFontInfo (TScreen * /* screen */, XFontStruct */* font */);
+extern void xtermSetCursorBox (TScreen * /* screen */);
+extern void xtermUpdateFontInfo (XtermWidget /* xw */, Bool /* doresize */);
+
+#if OPT_DEC_CHRSET
+extern char *xtermSpecialFont (TScreen */* screen */, unsigned /* atts */, unsigned /* chrset */);
+#endif
+
+#if OPT_BOX_CHARS
+
+#define FontIsIncomplete(font) \
+       ((font)->fs != 0 \
+        && (font)->fs->per_char != 0 \
+        && !(font)->fs->all_chars_exist)
+
+#define ForceBoxChars(screen,ch) \
+       (xtermIsDecGraphic(ch) \
+        && (screen)->force_box_chars)
+
+#if OPT_WIDE_CHARS
+#define CharKnownMissing(font, ch) \
+        (((ch) < 256) && ((font)->known_missing[(Char)(ch)] > 1))
+#else
+#define CharKnownMissing(font, ch) \
+        ((font)->known_missing[(Char)(ch)] > 1)
+#endif
+
+#define IsXtermMissingChar(screen, ch, font) \
+        (CharKnownMissing(font, ch) \
+         ? ((font)->known_missing[(Char)(ch)] > 1) \
+         : ((FontIsIncomplete(font) && xtermMissingChar(ch, font)) \
+          || ForceBoxChars(screen, ch)))
+
+extern Bool xtermMissingChar (unsigned /* ch */, XTermFonts */* font */);
+extern void xtermDrawBoxChar (XtermWidget /* xw */, unsigned /* ch */, unsigned /* flags */, GC /* gc */, int /* x */, int /* y */, int /* cols */);
+#else
+#define IsXtermMissingChar(screen, ch, font) False
+#endif
+
+#if OPT_LOAD_VTFONTS
+extern void HandleLoadVTFonts PROTO_XT_ACTIONS_ARGS;
+#endif
+
+#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS
+extern Bool xtermLoadWideFonts (XtermWidget /* w */, Bool /* nullOk */);
+#endif
+
+#define xtermIsDecGraphic(ch)  ((ch) > 0 && (ch) < 32)
+
+#if OPT_RENDERFONT
+extern Bool xtermXftMissing (XtermWidget /* xw */, XftFont * /* font */, unsigned /* wc */);
+extern void xtermCloseXft(TScreen * /* screen */, XTermXftFonts * /* pub */);
+#endif
+
+#if OPT_SHIFT_FONTS
+extern String getFaceName(XtermWidget /* xw */, Bool /* wideName */);
+extern void HandleLargerFont PROTO_XT_ACTIONS_ARGS;
+extern void HandleSmallerFont PROTO_XT_ACTIONS_ARGS;
+extern void setFaceName(XtermWidget /* xw */, const char * /*value */);
+#endif
+
+#if OPT_WIDE_CHARS
+extern unsigned ucs2dec (unsigned);
+extern unsigned dec2ucs (unsigned);
+#endif
+
+#endif /* included_fontutils_h */
diff --git a/gen-pc-fkeys.pl b/gen-pc-fkeys.pl
new file mode 100755 (executable)
index 0000000..1cc5b47
--- /dev/null
@@ -0,0 +1,364 @@
+#! /usr/bin/perl -w
+# $XTermId: gen-pc-fkeys.pl,v 1.22 2007/11/30 23:03:55 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2004-2005,2007 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# Construct a list of function-key definitions corresponding to xterm's
+# Sun/PC keyboard.  This uses ncurses' infocmp to obtain the strings (including
+# extensions) to modify (and verify).
+use strict;
+
+my($max_modifier, $terminfo);
+my(@old_fkeys, $opt_fkeys, $min_fkeys, $max_fkeys);
+my(%old_ckeys, $opt_ckeys, $min_ckeys, $max_ckeys);
+my(%old_ekeys, $opt_ekeys, $min_ekeys, $max_ekeys);
+
+my(@ckey_names);
+@ckey_names = (
+       'kcud1', 'kcub1', 'kcuf1', 'kcuu1',     # 1 = no modifiers
+       'kDN',   'kLFT',  'kRIT',  'kUP',       # 2 = shift
+       # make_ckey_names() repeats this row, appending the modifier code
+       );
+my %ckey_names;
+my(@ckey_known);
+@ckey_known = (
+       'kind',  'kLFT',  'kRIT',  'kri',       # 2 = shift (standard)
+       );
+
+my(@ekey_names);
+@ekey_names = (
+       'khome', 'kend',  'knp',   'kpp',   'kdch1', 'kich1', # 1 = no modifiers
+       'kHOM',  'kEND',  'kNXT',  'kPRV',  'kDC',   'kIC',   # 2 = shift
+       # make_ekey_names() repeats this row, appending the modifier code
+);
+my %ekey_names;
+
+$min_fkeys=12;         # the number of "real" function keys on your keyboard
+$max_fkeys=64;         # the number of function-keys terminfo can support
+$max_modifier=8;       # modifier 1 + (1=shift, 2=alt, 4=control 8=meta)
+
+$min_ckeys=4;          # the number of "real" cursor keys on your keyboard
+$max_ckeys=($min_ckeys * ($max_modifier - 1));
+
+$min_ekeys=6;          # the number of "real" editing keys on your keyboard
+$max_ekeys=($min_ekeys * ($max_modifier - 1));
+
+$opt_ckeys=2;          # xterm's modifyCursorKeys resource
+$opt_ekeys=2;          # xterm's modifyCursorKeys resource
+$opt_fkeys=2;          # xterm's modifyFunctionKeys resource
+$terminfo="xterm-new"; # the terminfo entry to use
+
+# apply the given modifier to the terminfo string, return the result
+sub modify_fkey($$$) {
+       my $code = $_[0];
+       my $text = $_[1];
+       my $opts = $_[2];
+       if (not defined($text)) {
+               $text = "";
+       } elsif ($code != 1) {
+               $text =~ s/\\EO/\\E\[/ if ($opts >= 1);
+
+               my $piece = substr $text, 0, length ($text) - 1;
+               my $final = substr $text, length ($text) - 1;
+               my $check = substr $piece, length ($piece) - 1;
+               if ($check =~ /[0-9]/) {
+                       $code = ";" . $code;
+               } elsif ( $check =~ /\[/ and $opts >= 2) {
+                       $code = "1;" . $code;
+               }
+               if ( $opts >= 3 ) {
+                       $code = ">" . $code;
+               }
+               $text = $piece . $code . $final;
+               $text =~ s/([\d;]+)>/>$1/;
+       }
+       return $text;
+}
+
+# compute the next modifier value -
+# Cycling through the modifiers is not just like counting.  Users prefer
+# pressing one modifier (even if using Emacs).  So first we cycle through
+# the individual modifiers, then for completeness two, three, etc.
+sub next_modifier {
+       my $code = $_[0];
+       my $mask = $code - 1;
+       if ($mask == 0) {
+               $mask = 1;      # shift
+       } elsif ($mask == 1) {
+               $mask = 4;      # control
+       } elsif ($mask == 2) {
+               $mask = 3;      # shift+alt
+       } elsif ($mask == 4) {
+               $mask = 5;      # shift+control
+       } elsif ($mask == 5) {
+               $mask = 2;      # alt
+       }
+       # printf ("# next_modifier(%d) = %d\n", $code, $mask + 1);
+       return $mask + 1;
+}
+
+sub make_ckey_names() {
+       my ($j, $k);
+       my $min = $min_ckeys * 2;
+       my $max = $max_ckeys - 1;
+
+       # printf "# make_ckey_names\n";
+       for $j ($min..$max) {
+               $k = 1 + substr($j / $min_ckeys, 0, 1);
+               $ckey_names[$j] = $ckey_names[$min_ckeys + ($j % $min_ckeys)] . $k;
+               # printf "# make %d:%s\n", $j, $ckey_names[$j];
+       }
+       for $j (0..$#ckey_names) {
+               # printf "# %d:%s\n", $j, $ckey_names[$j];
+               $ckey_names{$ckey_names[$j]} = $j;
+       }
+}
+
+sub make_ekey_names() {
+       my ($j, $k);
+       my $min = $min_ekeys * 2;
+       my $max = $max_ekeys - 1;
+
+       # printf "# make_ekey_names\n";
+       for $j ($min..$max) {
+               $k = 1 + substr($j / $min_ekeys, 0, 1);
+               $ekey_names[$j] = $ekey_names[$min_ekeys + ($j % $min_ekeys)] . $k;
+               # printf "# make %d:%s\n", $j, $ekey_names[$j];
+       }
+       for $j (0..$#ekey_names) {
+               # printf "# %d:%s\n", $j, $ekey_names[$j];
+               $ekey_names{$ekey_names[$j]} = $j;
+       }
+}
+
+# Read the terminfo entry's list of function keys $old_fkeys[].
+# We could handle $old_fkeys[0], but choose to start numbering from 1.
+sub readterm($) {
+       my $term = $_[0];
+       my($key, $n, $str);
+       my(@list) = `infocmp -x -1 $term`;
+
+       for $n (0..$#list) {
+               chop $list[$n];
+               $list[$n] =~ s/^[[:space:]]//;
+
+               $key = $list[$n];
+               $key =~ s/=.*//;
+
+               $str = $list[$n];
+               $str =~ s/^[^=]+=//;
+               $str =~ s/,$//;
+
+               if ( $list[$n] =~ /^kf[[:digit:]]+=/ ) {
+                       $key =~ s/^kf//;
+                       # printf "# $n:%s(%d)(%s)\n", $list[$n], $key, $str;
+                       $old_fkeys[$key] = $str;
+               } elsif ( $key =~ /^kc[[:alpha:]]+1/
+                       or $key =~ /^k(LFT|RIT|UP|DN)\d?/) {
+                       # printf "# $n:%s(%d)(%s)\n", $list[$n], $key, $str;
+                       $old_ckeys{$key} = $str;
+               } elsif ( defined $ekey_names{$key} ) {
+                       # printf "# $n:%s(%s)(%s)\n", $list[$n], $key, $str;
+                       $old_ekeys{$key} = $str;
+               }
+       }
+       # printf ("last index:%d\n", $#old_fkeys);
+}
+
+# read the whole terminfo to ensure we get the non-modified stuff, then read
+# the part that contains modifiers.
+sub read_part($) {
+       my $part = $_[0];
+
+       %old_ckeys = ();
+       @old_fkeys = ();
+       readterm($terminfo);
+       readterm($part);
+}
+
+sub nameof_ckeys($) {
+       my $opts = $_[0];
+       my $optname = "xterm+pcc" . ($opts >= 0 ? $opts : "n");
+       return $optname;
+}
+
+sub generate_ckeys($) {
+       my $opts = $_[0];
+       my($modifier, $cur_ckey, $index);
+
+       printf "%s|fragment with modifyCursorKeys:%s,\n",
+               nameof_ckeys($opts), $opts;
+
+       # show the standard cursor definitions
+       $modifier = 1;
+       for ($index = 0; $index < $min_ckeys; ++$index) {
+               $cur_ckey = $index + ($modifier * $min_ckeys);
+               my $name = $ckey_known[$index];
+               my $input = $old_ckeys{$ckey_names[$index]};
+               my $result = modify_fkey($modifier + 1, $input, $opts);
+               printf "\t%s=%s,\n", $name, $result;
+               if (defined $old_ckeys{$name}) {
+                       if ($old_ckeys{$name} ne $result) {
+                               printf "# found %s=%s\n", $name, $old_ckeys{$name};
+                       }
+               }
+       }
+
+       # show the extended cursor definitions
+       for ($index = 0; $index < $min_ckeys; ++$index) {
+               for ($modifier = 1; $modifier < $max_modifier; ++$modifier) {
+                       $cur_ckey = $index + ($modifier * $min_ckeys);
+                       if (defined $ckey_names[$cur_ckey] and
+                               $ckey_names[$cur_ckey] ne "kLFT" and
+                               $ckey_names[$cur_ckey] ne "kRIT" ) {
+                               my $name = $ckey_names[$cur_ckey];
+                               my $input = $old_ckeys{$ckey_names[$index]};
+                               my $result = modify_fkey($modifier + 1, $input, $opts);
+                               printf "\t%s=%s,\n", $name, $result;
+                               if (defined $old_ckeys{$name}) {
+                                       if ($old_ckeys{$name} ne $result) {
+                                               printf "# found %s=%s\n", $name, $old_ckeys{$name};
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+sub nameof_ekeys($) {
+       my $opts = $_[0];
+       my $optname = "xterm+pce" . ($opts >= 0 ? $opts : "n");
+       return $optname;
+}
+
+sub generate_ekeys($) {
+       my $opts = $_[0];
+       my($modifier, $cur_ekey, $index);
+
+       printf "%s|fragment with modifyCursorKeys:%s,\n",
+               nameof_ekeys($opts), $opts;
+
+       for ($index = 0; $index < $min_ekeys; ++$index) {
+               for ($modifier = 1; $modifier < $max_modifier; ++$modifier) {
+                       $cur_ekey = $index + ($modifier * $min_ekeys);
+                       if (defined $ekey_names[$cur_ekey] ) {
+                               my $name = $ekey_names[$cur_ekey];
+                               my $input = $old_ekeys{$ekey_names[$index]};
+                               my $result = modify_fkey($modifier + 1, $input, $opts);
+                               printf "\t%s=%s,\n", $name, $result;
+                               if (defined $old_ekeys{$name}) {
+                                       if ($old_ekeys{$name} ne $result) {
+                                               printf "# found %s=%s\n", $name, $old_ekeys{$name};
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+sub nameof_fkeys($) {
+       my $opts = $_[0];
+       my $optname = "xterm+pcf" . ($opts >= 0 ? $opts : "n");
+       return $optname;
+}
+
+sub generate_fkeys($) {
+       my $opts = $_[0];
+       my($modifier, $cur_fkey);
+
+       printf "%s|fragment with modifyFunctionKeys:%s and ctrlFKeys:10,\n",
+               nameof_fkeys($opts), $opts;
+
+       for ($cur_fkey = 1, $modifier = 1; $cur_fkey < $max_fkeys; ++$cur_fkey) {
+               my $index = (($cur_fkey - 1) % $min_fkeys);
+               if ($index == 0 && $cur_fkey != 1) {
+                       $modifier = next_modifier($modifier);
+               }
+               if (defined $old_fkeys[$index + 1]) {
+                       my $input = $old_fkeys[$index + 1];
+                       my $result = modify_fkey($modifier, $input, $opts);
+                       printf "\tkf%d=%s,\n", $cur_fkey, $result;
+                       if (defined $old_fkeys[$cur_fkey]) {
+                               if ($old_fkeys[$cur_fkey] ne $result) {
+                                       printf "# found kf%d=%s\n", $cur_fkey, $old_fkeys[$cur_fkey];
+                               }
+                       }
+               }
+       }
+}
+
+sub show_default() {
+       readterm($terminfo);
+
+       printf "xterm+pcfkeys|fragment for PC-style keys,\n";
+       printf "\tuse=%s,\n", nameof_ckeys($opt_ckeys);
+       printf "\tuse=%s,\n", nameof_ekeys($opt_ekeys);
+       printf "\tuse=%s,\n", nameof_fkeys($opt_fkeys);
+
+       generate_ckeys($opt_ckeys);
+       generate_ekeys($opt_ekeys);
+       generate_fkeys($opt_fkeys);
+}
+
+sub show_nondefault()
+{
+       my $opts;
+
+       for ($opts = 0; $opts <= 3; ++$opts) {
+               if ($opts != $opt_ckeys) {
+                       read_part(nameof_ckeys($opts));
+                       generate_ckeys($opts);
+               }
+       }
+
+       for ($opts = 0; $opts <= 3; ++$opts) {
+               if ($opts != $opt_ekeys) {
+                       read_part(nameof_ekeys($opts));
+                       generate_ekeys($opts);
+               }
+       }
+
+       for ($opts = 0; $opts <= 3; ++$opts) {
+               if ($opts != $opt_fkeys) {
+                       read_part(nameof_fkeys($opts));
+                       generate_fkeys($opts);
+               }
+       }
+}
+
+make_ckey_names();
+make_ekey_names();
+
+printf "# gen-pc-fkeys.pl\n";
+printf "# %s:timode\n", "vile";
+show_default();
+show_nondefault();
diff --git a/icons/xterm-color_32x32.xcf b/icons/xterm-color_32x32.xcf
new file mode 100644 (file)
index 0000000..f13ef5d
Binary files /dev/null and b/icons/xterm-color_32x32.xcf differ
diff --git a/icons/xterm-color_32x32.xpm b/icons/xterm-color_32x32.xpm
new file mode 100644 (file)
index 0000000..7824f6c
--- /dev/null
@@ -0,0 +1,46 @@
+/* XPM */
+static char * xterm_color_32x32_xpm[] = {
+"32 32 11 1",
+"      c None",
+".     c #555500",
+"+     c #000000",
+"@     c #FFFFFF",
+"#     c #FF0000",
+"$     c #980000",
+"%     c #FF5E00",
+"&     c #49FF00",
+"*     c #2FA300",
+"=     c #60B7FF",
+"-     c #3A709B",
+"................................",
+".....+++++++++++++++++++++++....",
+"....+@@+++++++++++++++++++@@++..",
+"....+@+++++++++++++++++++++@+@+.",
+"....+++++++++++++++++++++++++@@+",
+"....+++#$+$#+++++++++++++++++@@+",
+"....++++$#$++++++++++++++++++@@+",
+"....++++$#+++++++++++++++++++@@+",
+"....++++$#$++++++++++++++++++@@+",
+"....+++#$+$#+++++++++++++++++@@+",
+"....+++++++++++++++++++++++++@@+",
+"....+++++++++++++++++++++++++@@+",
+"....+++++++++++++++++++++++++@@+",
+"....+++@@@@+%%%+&&&*+=++=++++@@+",
+"....+++++@++%+++&+&*+=-==++++@@+",
+"....+++++@++%%%+&&&*+==-=++++@@+",
+"....+++++@++%+++&+&++=++=++++@@+",
+"....+++++@++%%%+&+*&+=++=++++@@+",
+"....+++++++++++++++++++++++++@+.",
+"....+++++++++++++++++++++++++@+.",
+"....+@+++++++++++++++++++++@++..",
+"....+@@+++++++++++++++++++@@+...",
+".....+++++++++++++++++++++++....",
+"................................",
+".....++++++++++++++++++++++++...",
+"....+@@@@@@@@@@@@@@@@@@@@@@@+...",
+"...+@@@@@@@@@@@@@@@@@@@@@@@+....",
+"...+@@++@@++@++@@++@@+@@++@+....",
+"..+@++@@++@@+@@++@@++@++@@@+....",
+"..+@@@@@@@@@@@@@@@@@@@@@@@+.+...",
+".+@@@@@@@@@@@@@@@@@@@@@@@+......",
+".++++++++++++++++++++++++++....."};
diff --git a/icons/xterm-color_48x48.xcf b/icons/xterm-color_48x48.xcf
new file mode 100644 (file)
index 0000000..574d9f2
Binary files /dev/null and b/icons/xterm-color_48x48.xcf differ
diff --git a/icons/xterm-color_48x48.xpm b/icons/xterm-color_48x48.xpm
new file mode 100644 (file)
index 0000000..126e454
--- /dev/null
@@ -0,0 +1,61 @@
+/* XPM */
+static char * xterm_color_48x48_xpm[] = {
+"48 48 10 1",
+"      c None",
+".     c #555500",
+"+     c #000000",
+"@     c #FFFFFF",
+"#     c #FF0000",
+"$     c #070700",
+"%     c #0B0B00",
+"&     c #FF8400",
+"*     c #49FF00",
+"=     c #60B7FF",
+"................................................",
+"......++++++++++++++++++++++++++++++++++........",
+".....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++......",
+".....+@@@++++++++++++++++++++++++++++@@@+@+.....",
+".....+@@++++++++++++++++++++++++++++++@@+@@+....",
+".....+@++++++++++++++++++++++++++++++++@+@@@+...",
+".....+@++###++++###++++++++++++++++++++@+@@@@+..",
+".....+@+++##++++##+++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@++++++##++++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@+++++####+++++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@++++##++##++++++++++++++++++++++@+@@@@+..",
+".....+@+++##++++##+++++++++++++++++++++@+@@@@+..",
+".....+@++###++++###++++++++++++++++++++@+@@@@+..",
+".....+@++++++++++++++++++++++++++++++++@+@@@@+..",
+".....+@$+++++++++++++++++++++++++++++++@+@@@@+..",
+".....+@%@@@@@@@+&&&&&++****+++==+++==++@+@@@@+..",
+".....+@++++@++++&++++++*+++*++==+++==++@+@@@@+..",
+".....+@++++@++++&++++++*+++*++=+=+=+=++@+@@@@+..",
+".....+@++++@++++&&&&+++****+++=+=+=+=++@+@@@@+..",
+".....+@++++@++++&++++++*+*++++=++=++=++@+@@@+...",
+".....+@++++@++++&++++++*++*+++=++=++=++@+@@@+...",
+".....+@++++@++++&&&&&++*+++*++=+++++=++@+@@+....",
+".....+@++++++++++++++++++++++++++++++++@+@@+....",
+".....+@++++++++++++++++++++++++++++++++@+@+.....",
+".....+@@++++++++++++++++++++++++++++++@@+@+.....",
+".....+@@@++++++++++++++++++++++++++++@@@++......",
+".....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++......",
+"......++++++++++++++++++++++++++++++++++........",
+"................................................",
+"................................................",
+"......++++++++++++++++++++++++++++++++++++......",
+".....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@++......",
+".....+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@@++......",
+"....+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@+......",
+"....+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@@+@+......",
+"...+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@@+......",
+"...+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@+@@+@@+......",
+"..+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@@+.......",
+"..+@++@++++++++++++++++++++++++++@++@+@+........",
+".+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@+@+.........",
+".+++++++++++++++++++++++++++++++++++++..........",
+"................................................"};
diff --git a/icons/xterm_32x32.xcf b/icons/xterm_32x32.xcf
new file mode 100644 (file)
index 0000000..7a5a5a7
Binary files /dev/null and b/icons/xterm_32x32.xcf differ
diff --git a/icons/xterm_32x32.xpm b/icons/xterm_32x32.xpm
new file mode 100644 (file)
index 0000000..3610936
--- /dev/null
@@ -0,0 +1,95 @@
+/* XPM */
+static char * xterm_32x32_xpm[] = {
+"32 32 60 1",
+"      c None",
+".     c #FFFFFF",
+"+     c #000000",
+"@     c #EFEFEF",
+"#     c #FEFEFE",
+"$     c #FBFBFB",
+"%     c #F3F3F3",
+"&     c #ADADAD",
+"*     c #909090",
+"=     c #737373",
+"-     c #D2D2D2",
+";     c #646464",
+">     c #9A9A9A",
+",     c #8D8D8D",
+"'     c #D3D3D3",
+")     c #0E0E0E",
+"!     c #F6F6F6",
+"~     c #5E5E5E",
+"{     c #B1B1B1",
+"]     c #777777",
+"^     c #949494",
+"/     c #757575",
+"(     c #C4C4C4",
+"_     c #E7E7E7",
+":     c #F1F1F1",
+"<     c #F8F8F8",
+"[     c #EEEEEE",
+"}     c #F0F0F0",
+"|     c #FAFAFA",
+"1     c #7B7B7B",
+"2     c #3D3D3D",
+"3     c #868686",
+"4     c #4F4F4F",
+"5     c #ABABAB",
+"6     c #545454",
+"7     c #5B5B5B",
+"8     c #AFAFAF",
+"9     c #292929",
+"0     c #181818",
+"a     c #C7C7C7",
+"b     c #CFCFCF",
+"c     c #7F7F7F",
+"d     c #A3A3A3",
+"e     c #4D4D4D",
+"f     c #6A6A6A",
+"g     c #A1A1A1",
+"h     c #8E8E8E",
+"i     c #696969",
+"j     c #474747",
+"k     c #5A5A5A",
+"l     c #959595",
+"m     c #767676",
+"n     c #8B8B8B",
+"o     c #BCBCBC",
+"p     c #BFBFBF",
+"q     c #D7D7D7",
+"r     c #404040",
+"s     c #636363",
+"t     c #989898",
+"u     c #8A8A8A",
+"................................",
+".....+++++++++++++++++++++++....",
+"....+..+++++++++++++++++++..++..",
+"....+.+...................+.+.+.",
+"....++.@#.$%................+..+",
+"....++.&*.=-................+..+",
+"....++..;>,.................+..+",
+"....++..')!.................+..+",
+"....++.#~{].................+..+",
+"....++.^{./(................+..+",
+"....++......................+..+",
+"....++......................+..+",
+"....++.____:___<_[..<}..[|..+..+",
+"....++.1;21341156]7.89$:0a..+..+",
+"....++..bc.8^__8d.e.8fghia..+..+",
+"....++..bc.84115jkl.887mna..+..+",
+"....++..bc.8d..8dof.88pqna..+..+",
+"....++..bc.8rss5d.tu88..na..+...",
+"....++......................+.+.",
+"....++......................+.+.",
+"....+.+...................+.++..",
+"....+..+++++++++++++++++++..+...",
+".....+++++++++++++++++++++++....",
+"................................",
+".....++++++++++++++++++++++++...",
+"....+.......................+...",
+"...+.......................+....",
+"...+..++..++.++..++..+..++.+....",
+"....++..++..+..++..++.++........",
+"..+.......................+.+...",
+".+.......................+......",
+".++++++++++++++++++++++++++....."};
diff --git a/icons/xterm_48x48.xcf b/icons/xterm_48x48.xcf
new file mode 100644 (file)
index 0000000..a4dc88e
Binary files /dev/null and b/icons/xterm_48x48.xcf differ
diff --git a/icons/xterm_48x48.xpm b/icons/xterm_48x48.xpm
new file mode 100644 (file)
index 0000000..44fb810
--- /dev/null
@@ -0,0 +1,53 @@
+/* XPM */
+static char * xterm_48x48_xpm[] = {
+"48 48 2 1",
+"      c #000000",
+".     c #FFFFFF",
+"................................................",
+"......                                  ........",
+"..... ..................................  ......",
+"..... ...                            ... . .....",
+"..... .. ............................ .. .. ....",
+"..... . .............................. . ... ...",
+"..... . .   ....   ................... . .... ..",
+"..... . ..  ....  .................... . .... ..",
+"..... . ...  ..  ..................... . .... ..",
+"..... . ...  ..  ..................... . .... ..",
+"..... . ....    ...................... . .... ..",
+"..... . ....    ...................... . .... ..",
+"..... . .....  ....................... . .... ..",
+"..... . ....    ...................... . .... ..",
+"..... . ....    ...................... . .... ..",
+"..... . ...  ..  ..................... . .... ..",
+"..... . ...  ..  ..................... . .... ..",
+"..... . ..  ....  .................... . .... ..",
+"..... . .   ....   ................... . .... ..",
+"..... . .............................. . .... ..",
+"..... . .............................. . .... ..",
+"..... . .      .     ..    ...  ...  . . .... ..",
+"..... . ... .... ...... ... ..  ...  . . .... ..",
+"..... . ... .... ...... ... .. . . . . . .... ..",
+"..... . ... ....    ...    ... . . . . . .... ..",
+"..... . ... .... ...... . .... .. .. . . ... ...",
+"..... . ... .... ...... .. ... .. .. . . ... ...",
+"..... . ... ....     .. ... .. ..... . . .. ....",
+"..... . .............................. . .. ....",
+"..... . .............................. . . .....",
+"..... .. ............................ .. . .....",
+"..... ...                            ...  ......",
+"..... ..................................  ......",
+"......                                  ........",
+"................................................",
+"................................................",
+"......                                    ......",
+"..... ..................................  ......",
+"..... . . . . . . . . . . . . . . . . ..  ......",
+".... .................................. . ......",
+".... . . . . . . . . . . . . . . . . .. . ......",
+"... .................................. .. ......",
+"... . . . . . . . . . . . . . . . . .. .. ......",
+".. .................................. .. .......",
+".. .  .                          .  . . ........",
+". .................................. . .........",
+".                                     ..........",
+"................................................"};
diff --git a/input.c b/input.c
new file mode 100644 (file)
index 0000000..ffbddb7
--- /dev/null
+++ b/input.c
@@ -0,0 +1,2062 @@
+/* $XTermId: input.c,v 1.327 2011/02/09 10:15:07 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* input.c */
+
+#include <xterm.h>
+
+#include <X11/keysym.h>
+
+#ifdef VMS
+#include <X11/keysymdef.h>
+#endif
+
+#if HAVE_X11_DECKEYSYM_H
+#include <X11/DECkeysym.h>
+#endif
+
+#if HAVE_X11_SUNKEYSYM_H
+#include <X11/Sunkeysym.h>
+#endif
+
+#if HAVE_X11_XF86KEYSYM_H
+#include <X11/XF86keysym.h>
+#endif
+
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include <xutf8.h>
+
+#include <data.h>
+#include <fontutils.h>
+#include <xstrings.h>
+#include <xtermcap.h>
+
+/*
+ * Xutil.h has no macro to check for the complete set of function- and
+ * modifier-keys that might be returned.  Fake it.
+ */
+#ifdef XK_ISO_Lock
+#define IsPredefinedKey(n) ((n) >= XK_ISO_Lock && (n) <= XK_Delete)
+#else
+#define IsPredefinedKey(n) ((n) >= XK_BackSpace && (n) <= XK_Delete)
+#endif
+
+#ifdef XK_ISO_Left_Tab
+#define IsTabKey(n) ((n) == XK_Tab || (n) == XK_ISO_Left_Tab)
+#else
+#define IsTabKey(n) ((n) == XK_Tab)
+#endif
+
+#ifndef IsPrivateKeypadKey
+#define IsPrivateKeypadKey(k) (0)
+#endif
+
+#define IsBackarrowToggle(keyboard, keysym, state) \
+       ((((keyboard->flags & MODE_DECBKM) == 0) \
+           ^ ((state & ControlMask) != 0)) \
+       && (keysym == XK_BackSpace))
+
+#define MAP(from, to) case from: result = to; break
+#define Masked(value,mask) ((value) & (unsigned) (~(mask)))
+
+#define KEYSYM_FMT "0x%04lX"   /* simplify matching <X11/keysymdef.h> */
+
+#define TEK4014_GIN(tw) (tw != 0 && TekScreenOf(tw)->TekGIN)
+
+typedef struct {
+    KeySym keysym;
+    Bool is_fkey;
+    int nbytes;
+#define STRBUFSIZE 500
+    char strbuf[STRBUFSIZE];
+} KEY_DATA;
+
+static
+const char *kypd_num = " XXXXXXXX\tXXX\rXXXxxxxXXXXXXXXXXXXXXXXXXXXX*+,-./0123456789XXX=";
+/*                      0123456789 abc def0123456789abcdef0123456789abcdef0123456789abcd */
+static
+const char *kypd_apl = " ABCDEFGHIJKLMNOPQRSTUVWXYZ??????abcdefghijklmnopqrstuvwxyzXXX";
+/*                      0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd */
+static
+const char *curfinal = "HDACB  FE";
+
+static int decfuncvalue(KEY_DATA *);
+static void sunfuncvalue(ANSI *, KEY_DATA *);
+static void hpfuncvalue(ANSI *, KEY_DATA *);
+static void scofuncvalue(ANSI *, KEY_DATA *);
+
+#if OPT_TRACE
+static const char *
+ModifierName(unsigned modifier)
+{
+    const char *s = "";
+    if (modifier & ShiftMask)
+       s = " Shift";
+    else if (modifier & LockMask)
+       s = " Lock";
+    else if (modifier & ControlMask)
+       s = " Control";
+    else if (modifier & Mod1Mask)
+       s = " Mod1";
+    else if (modifier & Mod2Mask)
+       s = " Mod2";
+    else if (modifier & Mod3Mask)
+       s = " Mod3";
+    else if (modifier & Mod4Mask)
+       s = " Mod4";
+    else if (modifier & Mod5Mask)
+       s = " Mod5";
+    return s;
+}
+
+#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s"
+#define ARG_MODIFIER_NAMES(state) \
+          ModifierName(state & ShiftMask), \
+          ModifierName(state & LockMask), \
+          ModifierName(state & ControlMask), \
+          ModifierName(state & Mod1Mask), \
+          ModifierName(state & Mod2Mask), \
+          ModifierName(state & Mod3Mask), \
+          ModifierName(state & Mod4Mask), \
+          ModifierName(state & Mod5Mask)
+#endif
+
+static void
+AdjustAfterInput(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->scrollkey && screen->topline != 0)
+       WindowScroll(xw, 0, False);
+    if (screen->marginbell) {
+       int col = screen->max_col - screen->nmarginbell;
+       if (screen->bellArmed >= 0) {
+           if (screen->bellArmed == screen->cur_row) {
+               if (screen->cur_col >= col) {
+                   Bell(xw, XkbBI_MarginBell, 0);
+                   screen->bellArmed = -1;
+               }
+           } else {
+               screen->bellArmed =
+                   screen->cur_col < col ? screen->cur_row : -1;
+           }
+       } else if (screen->cur_col < col)
+           screen->bellArmed = screen->cur_row;
+    }
+}
+
+/*
+ * Return true if the key is on the editing keypad.  This overlaps with
+ * IsCursorKey() and IsKeypadKey() and must be tested before those macro to
+ * distinguish it from them.
+ */
+static Bool
+IsEditFunctionKey(KeySym keysym)
+{
+    switch (keysym) {
+    case XK_Prior:             /* editing keypad */
+    case XK_Next:              /* editing keypad */
+    case XK_Insert:            /* editing keypad */
+    case XK_Find:              /* editing keypad */
+    case XK_Select:            /* editing keypad */
+#ifdef DXK_Remove
+    case DXK_Remove:           /* editing keypad */
+#endif
+#ifdef XK_KP_Delete
+    case XK_KP_Delete:         /* editing key on numeric keypad */
+    case XK_KP_Insert:         /* editing key on numeric keypad */
+#endif
+#ifdef XK_ISO_Left_Tab
+    case XK_ISO_Left_Tab:
+#endif
+       return True;
+    default:
+       return False;
+    }
+}
+
+#if OPT_MOD_FKEYS
+#define IS_CTRL(n) ((n) < ANSI_SPA || ((n) >= 0x7f && (n) <= 0x9f))
+
+/*
+ * Return true if the keysym corresponds to one of the control characters,
+ * or one of the common ASCII characters that is combined with control to
+ * make a control character.
+ */
+static Bool
+IsControlInput(KEY_DATA * kd)
+{
+    return ((kd->keysym) >= 0x40 && (kd->keysym) <= 0x7f);
+}
+
+static Bool
+IsControlOutput(KEY_DATA * kd)
+{
+    return IS_CTRL(kd->keysym);
+}
+
+/*
+ * X "normally" has some built-in translations, which the user may want to
+ * suppress when processing the modifyOtherKeys resource.  In particular, the
+ * control modifier applied to some of the keyboard digits gives results for
+ * control characters.
+ *
+ * control 2   0    NUL
+ * control SPC 0    NUL
+ * control @   0    NUL
+ * control `   0    NUL
+ * control 3   0x1b ESC
+ * control 4   0x1c FS
+ * control \   0x1c FS
+ * control 5   0x1d GS
+ * control 6   0x1e RS
+ * control ^   0x1e RS
+ * control ~   0x1e RS
+ * control 7   0x1f US
+ * control /   0x1f US
+ * control _   0x1f US
+ * control 8   0x7f DEL
+ *
+ * It is possible that some other keyboards do not work for these combinations,
+ * but they do work with modifyOtherKeys=2 for the US keyboard:
+ *
+ * control `   0    NUL
+ * control [   0x1b ESC
+ * control \   0x1c FS
+ * control ]   0x1d GS
+ * control ?   0x7f DEL
+ */
+static Bool
+IsControlAlias(KEY_DATA * kd)
+{
+    Bool result = False;
+
+    if (kd->nbytes == 1) {
+       result = IS_CTRL(CharOf(kd->strbuf[0]));
+    }
+    return result;
+}
+
+/*
+ * If we are in the non-VT220/VT52 keyboard state, allow modifiers to add a
+ * parameter to the function-key control sequences.
+ *
+ * Note that we generally cannot capture the Shift-modifier for the numeric
+ * keypad since this is commonly used to act as a type of NumLock, e.g.,
+ * making the keypad send "7" (actually XK_KP_7) where the unshifted code
+ * would be Home (XK_KP_Home).  The other modifiers work, subject to the
+ * usual window-manager assignments.
+ */
+static Bool
+allowModifierParm(XtermWidget xw, KEY_DATA * kd)
+{
+    TKeyboard *keyboard = &(xw->keyboard);
+    TScreen *screen = TScreenOf(xw);
+    int keypad_mode = ((keyboard->flags & MODE_DECKPAM) != 0);
+
+    Bool result = False;
+
+    (void) screen;
+    if (!(IsKeypadKey(kd->keysym) && keypad_mode)
+#if OPT_SUNPC_KBD
+       && keyboard->type != keyboardIsVT220
+#endif
+#if OPT_VT52_MODE
+       && screen->vtXX_level != 0
+#endif
+       ) {
+       result = True;
+    }
+    return result;
+}
+
+/*
+* Modifier codes:
+*       None                  1
+*       Shift                 2 = 1(None)+1(Shift)
+*       Alt                   3 = 1(None)+2(Alt)
+*       Alt+Shift             4 = 1(None)+1(Shift)+2(Alt)
+*       Ctrl                  5 = 1(None)+4(Ctrl)
+*       Ctrl+Shift            6 = 1(None)+1(Shift)+4(Ctrl)
+*       Ctrl+Alt              7 = 1(None)+2(Alt)+4(Ctrl)
+*       Ctrl+Alt+Shift        8 = 1(None)+1(Shift)+2(Alt)+4(Ctrl)
+*       Meta                  9 = 1(None)+8(Meta)
+*       Meta+Shift           10 = 1(None)+8(Meta)+1(Shift)
+*       Meta+Alt             11 = 1(None)+8(Meta)+2(Alt)
+*       Meta+Alt+Shift       12 = 1(None)+8(Meta)+1(Shift)+2(Alt)
+*       Meta+Ctrl            13 = 1(None)+8(Meta)+4(Ctrl)
+*       Meta+Ctrl+Shift      14 = 1(None)+8(Meta)+1(Shift)+4(Ctrl)
+*       Meta+Ctrl+Alt        15 = 1(None)+8(Meta)+2(Alt)+4(Ctrl)
+*       Meta+Ctrl+Alt+Shift  16 = 1(None)+8(Meta)+1(Shift)+2(Alt)+4(Ctrl)
+*/
+
+unsigned
+xtermParamToState(XtermWidget xw, unsigned param)
+{
+    unsigned result = 0;
+#if OPT_NUM_LOCK
+    if (param > MOD_NONE
+       && ((ShiftMask
+            | ControlMask
+            | xw->misc.alt_mods
+            | xw->misc.meta_mods) & xw->misc.other_mods) == 0) {
+       if ((param - MOD_NONE) & MOD_SHIFT)
+           UIntSet(result, ShiftMask);
+       if ((param - MOD_NONE) & MOD_CTRL)
+           UIntSet(result, ControlMask);
+       if ((param - MOD_NONE) & MOD_ALT)
+           UIntSet(result, xw->misc.alt_mods);
+       if ((param - MOD_NONE) & MOD_META)
+           UIntSet(result, xw->misc.meta_mods);
+    }
+#else
+    (void) xw;
+    (void) param;
+#endif
+    TRACE(("xtermParamToState(%d) %s%s%s%s -> %#x\n", param,
+          MODIFIER_NAME(param, MOD_SHIFT),
+          MODIFIER_NAME(param, MOD_ALT),
+          MODIFIER_NAME(param, MOD_CTRL),
+          MODIFIER_NAME(param, MOD_META),
+          result));
+    return result;
+}
+
+unsigned
+xtermStateToParam(XtermWidget xw, unsigned state)
+{
+    unsigned modify_parm = MOD_NONE;
+
+    TRACE(("xtermStateToParam %#x\n", state));
+#if OPT_NUM_LOCK
+    if ((state & xw->misc.other_mods) == 0) {
+       if (state & ShiftMask) {
+           modify_parm += MOD_SHIFT;
+           UIntClr(state, ShiftMask);
+       }
+       if (state & ControlMask) {
+           modify_parm += MOD_CTRL;
+           UIntClr(state, ControlMask);
+       }
+       if ((state & xw->misc.alt_mods) != 0) {
+           modify_parm += MOD_ALT;
+           UIntClr(state, xw->misc.alt_mods);
+       }
+       if ((state & xw->misc.meta_mods) != 0) {
+           modify_parm += MOD_META;
+           UIntClr(state, xw->misc.meta_mods);
+       }
+    }
+    if (modify_parm == MOD_NONE)
+       modify_parm = 0;
+#else
+    (void) xw;
+    (void) state;
+#endif
+    TRACE(("...xtermStateToParam %d%s%s%s%s\n", modify_parm,
+          MODIFIER_NAME(modify_parm, MOD_SHIFT),
+          MODIFIER_NAME(modify_parm, MOD_ALT),
+          MODIFIER_NAME(modify_parm, MOD_CTRL),
+          MODIFIER_NAME(modify_parm, MOD_META)));
+    return modify_parm;
+}
+
+#define computeMaskedModifier(xw, state, mask) \
+       xtermStateToParam(xw, Masked(state, mask))
+
+#if OPT_NUM_LOCK
+static unsigned
+filterAltMeta(unsigned result, unsigned mask, Bool enable, KEY_DATA * kd)
+{
+    if ((result & mask) != 0) {
+       /*
+        * metaSendsEscape makes the meta key independent of
+        * modifyOtherKeys.
+        */
+       if (enable) {
+           result &= ~mask;
+       }
+       /*
+        * A bare meta-modifier is independent of modifyOtherKeys.  If it
+        * is combined with other modifiers, make it depend.
+        */
+       if ((result & ~(mask)) == 0) {
+           result &= ~mask;
+       }
+       /*
+        * Check for special cases of control+meta which are used by some
+        * applications, e.g., emacs.
+        */
+       if ((IsControlInput(kd)
+            || IsControlOutput(kd))
+           && (result & ControlMask) != 0) {
+           result &= ~(mask | ControlMask);
+       }
+       if (kd->keysym == XK_Return || kd->keysym == XK_Tab) {
+           result &= ~(mask | ControlMask);
+       }
+    }
+    return result;
+}
+#endif /* OPT_NUM_LOCK */
+
+/*
+ * Single characters (not function-keys) are allowed fewer modifiers when
+ * interpreting modifyOtherKeys due to pre-existing associations with some
+ * modifiers.
+ */
+static unsigned
+allowedCharModifiers(XtermWidget xw, unsigned state, KEY_DATA * kd)
+{
+#if OPT_NUM_LOCK
+    unsigned a_or_m = (state & (xw->misc.meta_mods | xw->misc.alt_mods));
+#else
+    unsigned a_or_m = 0;
+#endif
+    /*
+     * Start by limiting the result to the modifiers we might want to use.
+     */
+    unsigned result = (state & (ControlMask
+                               | ShiftMask
+                               | a_or_m));
+
+    /*
+     * If modifyOtherKeys is off or medium (0 or 1), moderate its effects by
+     * excluding the common cases for modifiers.
+     */
+    if (xw->keyboard.modify_now.other_keys <= 1) {
+       if (IsControlInput(kd)
+           && Masked(result, ControlMask) == 0) {
+           /* These keys are already associated with the control-key */
+           if (xw->keyboard.modify_now.other_keys == 0) {
+               UIntClr(result, ControlMask);
+           }
+       } else if (kd->keysym == XK_Tab || kd->keysym == XK_Return) {
+           /* EMPTY */ ;
+       } else if (IsControlAlias(kd)) {
+           /* Things like "^_" work here... */
+           if (Masked(result, (ControlMask | ShiftMask)) == 0) {
+               result = 0;
+           }
+       } else if (!IsControlOutput(kd) && !IsPredefinedKey(kd->keysym)) {
+           /* Printable keys are already associated with the shift-key */
+           if (!(result & ControlMask)) {
+               UIntClr(result, ShiftMask);
+           }
+       }
+#if OPT_NUM_LOCK
+       result = filterAltMeta(result,
+                              xw->misc.meta_mods,
+                              TScreenOf(xw)->meta_sends_esc, kd);
+       if (TScreenOf(xw)->alt_is_not_meta) {
+           result = filterAltMeta(result,
+                                  xw->misc.alt_mods,
+                                  TScreenOf(xw)->alt_sends_esc, kd);
+       }
+#endif
+    }
+    TRACE(("...allowedCharModifiers(state=%u" FMT_MODIFIER_NAMES
+          ", ch=" KEYSYM_FMT ") ->"
+          "%u" FMT_MODIFIER_NAMES "\n",
+          state, ARG_MODIFIER_NAMES(state), kd->keysym,
+          result, ARG_MODIFIER_NAMES(result)));
+    return result;
+}
+
+/*
+ * Decide if we should generate a special escape sequence for "other" keys
+ * than cursor-, function-keys, etc., as per the modifyOtherKeys resource.
+ */
+static Bool
+ModifyOtherKeys(XtermWidget xw,
+               unsigned state,
+               KEY_DATA * kd,
+               unsigned modify_parm)
+{
+    TKeyboard *keyboard = &(xw->keyboard);
+    Bool result = False;
+
+    /*
+     * Exclude the keys already covered by a modifier.
+     */
+    if (kd->is_fkey
+       || IsEditFunctionKey(kd->keysym)
+       || IsKeypadKey(kd->keysym)
+       || IsCursorKey(kd->keysym)
+       || IsPFKey(kd->keysym)
+       || IsMiscFunctionKey(kd->keysym)
+       || IsPrivateKeypadKey(kd->keysym)
+#if OPT_NUM_LOCK
+       || (state & xw->misc.other_mods) != 0
+#endif
+       ) {
+       result = False;
+    } else if (modify_parm != 0) {
+       if (IsBackarrowToggle(keyboard, kd->keysym, state)) {
+           kd->keysym = XK_Delete;
+           UIntClr(state, ControlMask);
+       }
+       if (!IsPredefinedKey(kd->keysym)) {
+           state = allowedCharModifiers(xw, state, kd);
+       }
+       if (state != 0) {
+           switch (keyboard->modify_now.other_keys) {
+           default:
+               break;
+           case 1:
+               switch (kd->keysym) {
+               case XK_BackSpace:
+               case XK_Delete:
+                   result = False;
+                   break;
+#ifdef XK_ISO_Left_Tab
+               case XK_ISO_Left_Tab:
+                   if (computeMaskedModifier(xw, state, ShiftMask))
+                       result = True;
+                   break;
+#endif
+               case XK_Return:
+               case XK_Tab:
+                   result = (modify_parm != 0);
+                   break;
+               default:
+                   if (IsControlInput(kd)) {
+                       if (state == ControlMask || state == ShiftMask) {
+                           result = False;
+                       } else {
+                           result = (modify_parm != 0);
+                       }
+                   } else if (IsControlAlias(kd)) {
+                       if (state == ShiftMask)
+                           result = False;
+                       else if (computeMaskedModifier(xw, state, ControlMask)) {
+                           result = True;
+                       }
+                   } else {
+                       result = True;
+                   }
+                   break;
+               }
+               break;
+           case 2:
+               switch (kd->keysym) {
+               case XK_BackSpace:
+                   /* strip ControlMask as per IsBackarrowToggle() */
+                   if (computeMaskedModifier(xw, state, ControlMask))
+                       result = True;
+                   break;
+               case XK_Delete:
+                   result = (xtermStateToParam(xw, state) != 0);
+                   break;
+#ifdef XK_ISO_Left_Tab
+               case XK_ISO_Left_Tab:
+                   if (computeMaskedModifier(xw, state, ShiftMask))
+                       result = True;
+                   break;
+#endif
+               case XK_Return:
+               case XK_Tab:
+                   result = (modify_parm != 0);
+                   break;
+               default:
+                   if (IsControlInput(kd)) {
+                       result = True;
+                   } else if (state == ShiftMask) {
+                       result = (kd->keysym == ' ' || kd->keysym == XK_Return);
+                   } else if (computeMaskedModifier(xw, state, ShiftMask)) {
+                       result = True;
+                   }
+                   break;
+               }
+               break;
+           }
+       }
+    }
+    TRACE(("...ModifyOtherKeys(%d,%d) %s\n",
+          keyboard->modify_now.other_keys,
+          modify_parm,
+          BtoS(result)));
+    return result;
+}
+
+#define APPEND_PARM(number) \
+           reply->a_param[reply->a_nparam] = (ParmType) number; \
+           reply->a_nparam++
+
+/*
+ * Function-key code 27 happens to not be used in the vt220-style encoding.
+ * xterm uses this to represent modified non-function-keys such as control/+ in
+ * the Sun/PC keyboard layout.  See the modifyOtherKeys resource in the manpage
+ * for more information.
+ */
+static Bool
+modifyOtherKey(ANSI * reply, int input_char, unsigned modify_parm, int format_keys)
+{
+    Bool result = False;
+
+    if (input_char >= 0) {
+       reply->a_type = ANSI_CSI;
+       if (format_keys) {
+           APPEND_PARM(input_char);
+           APPEND_PARM(modify_parm);
+           reply->a_final = 'u';
+       } else {
+           APPEND_PARM(27);
+           APPEND_PARM(modify_parm);
+           APPEND_PARM(input_char);
+           reply->a_final = '~';
+       }
+
+       result = True;
+    }
+    return result;
+}
+
+static void
+modifyCursorKey(ANSI * reply, int modify, unsigned *modify_parm)
+{
+    if (*modify_parm != 0) {
+       if (modify < 0) {
+           *modify_parm = 0;
+       }
+       if (modify > 0) {
+           reply->a_type = ANSI_CSI;   /* SS3 should not have params */
+       }
+       if (modify > 1 && reply->a_nparam == 0) {
+           APPEND_PARM(1);     /* force modifier to 2nd param */
+       }
+       if (modify > 2) {
+           reply->a_pintro = '>';      /* mark this as "private" */
+       }
+    }
+}
+#else
+#define modifyCursorKey(reply, modify, parm)   /* nothing */
+#endif /* OPT_MOD_FKEYS */
+
+#if OPT_SUNPC_KBD
+/*
+ * If we have told xterm that our keyboard is really a Sun/PC keyboard, this is
+ * enough to make a reasonable approximation to DEC vt220 numeric and editing
+ * keypads.
+ */
+static KeySym
+TranslateFromSUNPC(KeySym keysym)
+{
+    /* *INDENT-OFF* */
+    static struct {
+           KeySym before, after;
+    } table[] = {
+#ifdef DXK_Remove
+       { XK_Delete,       DXK_Remove },
+#endif
+       { XK_Home,         XK_Find },
+       { XK_End,          XK_Select },
+#ifdef XK_KP_Home
+       { XK_Delete,       XK_KP_Decimal },
+       { XK_KP_Delete,    XK_KP_Decimal },
+       { XK_KP_Insert,    XK_KP_0 },
+       { XK_KP_End,       XK_KP_1 },
+       { XK_KP_Down,      XK_KP_2 },
+       { XK_KP_Next,      XK_KP_3 },
+       { XK_KP_Left,      XK_KP_4 },
+       { XK_KP_Begin,     XK_KP_5 },
+       { XK_KP_Right,     XK_KP_6 },
+       { XK_KP_Home,      XK_KP_7 },
+       { XK_KP_Up,        XK_KP_8 },
+       { XK_KP_Prior,     XK_KP_9 },
+#endif
+    };
+    /* *INDENT-ON* */
+
+    unsigned n;
+
+    for (n = 0; n < sizeof(table) / sizeof(table[0]); n++) {
+       if (table[n].before == keysym) {
+           TRACE(("...Input keypad before was " KEYSYM_FMT "\n", keysym));
+           keysym = table[n].after;
+           TRACE(("...Input keypad changed to " KEYSYM_FMT "\n", keysym));
+           break;
+       }
+    }
+    return keysym;
+}
+#endif /* OPT_SUNPC_KBD */
+
+#define VT52_KEYPAD \
+       if_OPT_VT52_MODE(screen,{ \
+               reply.a_type = ANSI_ESC; \
+               reply.a_pintro = '?'; \
+               })
+
+#define VT52_CURSOR_KEYS \
+       if_OPT_VT52_MODE(screen,{ \
+               reply.a_type = ANSI_ESC; \
+               })
+
+#undef  APPEND_PARM
+#define APPEND_PARM(number) \
+           reply.a_param[reply.a_nparam] = (ParmType) number, \
+           reply.a_nparam++
+
+#if OPT_MOD_FKEYS
+#define MODIFIER_PARM \
+       if (modify_parm != 0) APPEND_PARM(modify_parm)
+#else
+#define MODIFIER_PARM          /*nothing */
+#endif
+
+/*
+ * Determine if we use the \E[3~ sequence for Delete, or the legacy ^?.  We
+ * maintain the delete_is_del value as 3 states:  unspecified(2), true and
+ * false.  If unspecified, it is handled differently according to whether the
+ * legacy keyboard support is enabled, or if xterm emulates a VT220.
+ *
+ * Once the user (or application) has specified delete_is_del via resource
+ * setting, popup menu or escape sequence, it overrides the keyboard type
+ * rather than the reverse.
+ */
+Bool
+xtermDeleteIsDEL(XtermWidget xw)
+{
+    Bool result = True;
+
+    if (xw->keyboard.type == keyboardIsDefault
+       || xw->keyboard.type == keyboardIsVT220)
+       result = (TScreenOf(xw)->delete_is_del == True);
+
+    if (xw->keyboard.type == keyboardIsLegacy)
+       result = (TScreenOf(xw)->delete_is_del != False);
+
+    TRACE(("xtermDeleteIsDEL(%d/%d) = %d\n",
+          xw->keyboard.type,
+          TScreenOf(xw)->delete_is_del,
+          result));
+
+    return result;
+}
+
+void
+Input(XtermWidget xw,
+      XKeyEvent * event,
+      Bool eightbit)
+{
+    Char *string;
+
+    TKeyboard *keyboard = &(xw->keyboard);
+    TScreen *screen = TScreenOf(xw);
+
+    int j;
+    int key = False;
+    ANSI reply;
+    int dec_code;
+    unsigned modify_parm = 0;
+    int keypad_mode = ((keyboard->flags & MODE_DECKPAM) != 0);
+    unsigned evt_state = event->state;
+    unsigned mod_state;
+    KEY_DATA kd;
+
+    /* Ignore characters typed at the keyboard */
+    if (keyboard->flags & MODE_KAM)
+       return;
+
+    kd.keysym = 0;
+    kd.is_fkey = False;
+#if OPT_TCAP_QUERY
+    if (screen->tc_query_code >= 0) {
+       kd.keysym = (KeySym) screen->tc_query_code;
+       kd.is_fkey = screen->tc_query_fkey;
+       if (kd.keysym != XK_BackSpace) {
+           kd.nbytes = 0;
+           kd.strbuf[0] = 0;
+       } else {
+           kd.nbytes = 1;
+           kd.strbuf[0] = 8;
+       }
+    } else
+#endif
+    {
+#if OPT_I18N_SUPPORT
+       if (screen->xic) {
+           Status status_return;
+#if OPT_WIDE_CHARS
+           if (screen->utf8_mode) {
+               kd.nbytes = Xutf8LookupString(screen->xic, event,
+                                             kd.strbuf, (int) sizeof(kd.strbuf),
+                                             &kd.keysym, &status_return);
+           } else
+#endif
+           {
+               kd.nbytes = XmbLookupString(screen->xic, event,
+                                           kd.strbuf, (int) sizeof(kd.strbuf),
+                                           &kd.keysym, &status_return);
+           }
+#if OPT_MOD_FKEYS
+           /*
+            * Fill-in some code useful with IsControlAlias():
+            */
+           if (status_return == XLookupBoth
+               && kd.nbytes <= 1
+               && !IsPredefinedKey(kd.keysym)
+               && (keyboard->modify_now.other_keys > 1)
+               && !IsControlInput(&kd)) {
+               kd.nbytes = 1;
+               kd.strbuf[0] = (char) kd.keysym;
+           }
+#endif /* OPT_MOD_FKEYS */
+       } else
+#endif /* OPT_I18N_SUPPORT */
+       {
+           static XComposeStatus compose_status =
+           {NULL, 0};
+           kd.nbytes = XLookupString(event, kd.strbuf, (int) sizeof(kd.strbuf),
+                                     &kd.keysym, &compose_status);
+       }
+       kd.is_fkey = IsFunctionKey(kd.keysym);
+    }
+
+    memset(&reply, 0, sizeof(reply));
+
+    TRACE(("Input keysym "
+          KEYSYM_FMT
+          ", %d:'%s'%s" FMT_MODIFIER_NAMES "%s%s%s%s%s%s\n",
+          kd.keysym,
+          kd.nbytes,
+          visibleChars((Char *) kd.strbuf,
+                       ((kd.nbytes > 0)
+                        ? (unsigned) kd.nbytes
+                        : 0)),
+          ARG_MODIFIER_NAMES(evt_state),
+          eightbit ? " 8bit" : " 7bit",
+          IsKeypadKey(kd.keysym) ? " KeypadKey" : "",
+          IsCursorKey(kd.keysym) ? " CursorKey" : "",
+          IsPFKey(kd.keysym) ? " PFKey" : "",
+          kd.is_fkey ? " FKey" : "",
+          IsMiscFunctionKey(kd.keysym) ? " MiscFKey" : "",
+          IsEditFunctionKey(kd.keysym) ? " EditFkey" : ""));
+
+#if OPT_SUNPC_KBD
+    /*
+     * DEC keyboards don't have keypad(+), but do have keypad(,) instead.
+     * Other (Sun, PC) keyboards commonly have keypad(+), but no keypad(,)
+     * - it's a pain for users to work around.
+     */
+    if (keyboard->type == keyboardIsVT220
+       && (evt_state & ShiftMask) == 0) {
+       if (kd.keysym == XK_KP_Add) {
+           kd.keysym = XK_KP_Separator;
+           UIntClr(evt_state, ShiftMask);
+           TRACE(("...Input keypad(+), change keysym to "
+                  KEYSYM_FMT
+                  "\n",
+                  kd.keysym));
+       }
+       if ((evt_state & ControlMask) != 0
+           && kd.keysym == XK_KP_Separator) {
+           kd.keysym = XK_KP_Subtract;
+           UIntClr(evt_state, ControlMask);
+           TRACE(("...Input control/keypad(,), change keysym to "
+                  KEYSYM_FMT
+                  "\n",
+                  kd.keysym));
+       }
+    }
+#endif
+
+    /*
+     * The keyboard tables may give us different keypad codes according to
+     * whether NumLock is pressed.  Use this check to simplify the process
+     * of determining whether we generate an escape sequence for a keypad
+     * key, or force it to the value kypd_num[].  There is no fixed
+     * modifier for this feature, so we assume that it is the one assigned
+     * to the NumLock key.
+     *
+     * This check used to try to return the contents of strbuf, but that
+     * does not work properly when a control modifier is given (trash is
+     * returned in the buffer in some cases -- perhaps an X bug).
+     */
+#if OPT_NUM_LOCK
+    if (kd.nbytes == 1
+       && IsKeypadKey(kd.keysym)
+       && xw->misc.real_NumLock
+       && (xw->misc.num_lock & evt_state) != 0) {
+       keypad_mode = 0;
+       TRACE(("...Input num_lock, force keypad_mode off\n"));
+    }
+#endif
+
+#if OPT_MOD_FKEYS
+    if (evt_state != 0
+       && allowModifierParm(xw, &kd)) {
+       modify_parm = xtermStateToParam(xw, evt_state);
+    }
+
+    /*
+     * Shift-tab is often mapped to XK_ISO_Left_Tab which is classified as
+     * IsEditFunctionKey(), and the conversion does not produce any bytes.
+     * Check for this special case so we have data when handling the
+     * modifyOtherKeys resource.
+     */
+    if (keyboard->modify_now.other_keys > 1) {
+       if (IsTabKey(kd.keysym) && kd.nbytes == 0) {
+           kd.nbytes = 1;
+           kd.strbuf[0] = '\t';
+       }
+    }
+#endif /* OPT_MOD_FKEYS */
+
+    /* VT300 & up: backarrow toggle */
+    if ((kd.nbytes == 1)
+       && IsBackarrowToggle(keyboard, kd.keysym, evt_state)) {
+       kd.strbuf[0] = ANSI_DEL;
+       TRACE(("...Input backarrow changed to %d\n", kd.strbuf[0]));
+    }
+#if OPT_SUNPC_KBD
+    /* make an DEC editing-keypad from a Sun or PC editing-keypad */
+    if (keyboard->type == keyboardIsVT220
+       && (kd.keysym != XK_Delete || !xtermDeleteIsDEL(xw)))
+       kd.keysym = TranslateFromSUNPC(kd.keysym);
+    else
+#endif
+    {
+#ifdef XK_KP_Home
+       if (kd.keysym >= XK_KP_Home && kd.keysym <= XK_KP_Begin) {
+           TRACE(("...Input keypad before was " KEYSYM_FMT "\n", kd.keysym));
+           kd.keysym += (KeySym) (XK_Home - XK_KP_Home);
+           TRACE(("...Input keypad changed to " KEYSYM_FMT "\n", kd.keysym));
+       }
+#endif
+    }
+
+    /*
+     * Map the Sun afterthought-keys in as F36 and F37.
+     */
+#ifdef SunXK_F36
+    if (!kd.is_fkey) {
+       if (kd.keysym == SunXK_F36) {
+           kd.keysym = XK_Fn(36);
+           kd.is_fkey = True;
+       }
+       if (kd.keysym == SunXK_F37) {
+           kd.keysym = XK_Fn(37);
+           kd.is_fkey = True;
+       }
+    }
+#endif
+
+    /*
+     * Use the control- and shift-modifiers to obtain more function keys than
+     * the keyboard provides.  We can do this if there is no conflicting use of
+     * those modifiers:
+     *
+     * a) for VT220 keyboard, we use only the control-modifier.  The keyboard
+     * uses shift-modifier for UDK's.
+     *
+     * b) for non-VT220 keyboards, we only have to check if the
+     * modifyFunctionKeys resource is inactive.
+     *
+     * Thereafter, we note when we have a function-key and keep that
+     * distinction when testing for "function-key" values.
+     */
+    if ((evt_state & (ControlMask | ShiftMask)) != 0
+       && kd.is_fkey) {
+
+       /* VT220 keyboard uses shift for UDK */
+       if (keyboard->type == keyboardIsVT220
+           || keyboard->type == keyboardIsLegacy) {
+
+           TRACE(("...map XK_F%ld", kd.keysym - XK_Fn(1) + 1));
+           if (evt_state & ControlMask) {
+               kd.keysym += (KeySym) xw->misc.ctrl_fkeys;
+               UIntClr(evt_state, ControlMask);
+           }
+           TRACE((" to XK_F%ld\n", kd.keysym - XK_Fn(1) + 1));
+
+       }
+#if OPT_MOD_FKEYS
+       else if (keyboard->modify_now.function_keys < 0) {
+
+           TRACE(("...map XK_F%ld", kd.keysym - XK_Fn(1) + 1));
+           if (evt_state & ShiftMask) {
+               kd.keysym += (KeySym) (xw->misc.ctrl_fkeys * 1);
+               UIntClr(evt_state, ShiftMask);
+           }
+           if (evt_state & ControlMask) {
+               kd.keysym += (KeySym) (xw->misc.ctrl_fkeys * 2);
+               UIntClr(evt_state, ControlMask);
+           }
+           TRACE((" to XK_F%ld\n", kd.keysym - XK_Fn(1) + 1));
+
+       }
+       /*
+        * Reevaluate the modifier parameter, stripping off the modifiers
+        * that we just used.
+        */
+       if (modify_parm)
+           modify_parm = xtermStateToParam(xw, evt_state);
+#endif /* OPT_MOD_FKEYS */
+    }
+
+    /*
+     * Test for one of the keyboard variants.
+     */
+    switch (keyboard->type) {
+    case keyboardIsHP:
+       hpfuncvalue(&reply, &kd);
+       break;
+    case keyboardIsSCO:
+       scofuncvalue(&reply, &kd);
+       break;
+    case keyboardIsSun:
+       sunfuncvalue(&reply, &kd);
+       break;
+    case keyboardIsTermcap:
+#if OPT_TCAP_FKEYS
+       if (xtermcapString(xw, (int) kd.keysym, evt_state))
+           return;
+#endif
+       break;
+    case keyboardIsDefault:
+    case keyboardIsLegacy:
+    case keyboardIsVT220:
+       break;
+    }
+
+    if (reply.a_final) {
+       /*
+        * The key symbol matches one of the variants.  Most of those are
+        * function-keys, though some cursor- and editing-keys are mixed in.
+        */
+       modifyCursorKey(&reply,
+                       ((kd.is_fkey
+                         || IsMiscFunctionKey(kd.keysym)
+                         || IsEditFunctionKey(kd.keysym))
+                        ? keyboard->modify_now.function_keys
+                        : keyboard->modify_now.cursor_keys),
+                       &modify_parm);
+       MODIFIER_PARM;
+       unparseseq(xw, &reply);
+    } else if (((kd.is_fkey
+                || IsMiscFunctionKey(kd.keysym)
+                || IsEditFunctionKey(kd.keysym))
+#if OPT_MOD_FKEYS
+               && !ModifyOtherKeys(xw, evt_state, &kd, modify_parm)
+#endif
+              ) || (kd.keysym == XK_Delete
+                    && ((modify_parm != 0)
+                        || !xtermDeleteIsDEL(xw)))) {
+       dec_code = decfuncvalue(&kd);
+       if ((evt_state & ShiftMask)
+#if OPT_SUNPC_KBD
+           && keyboard->type == keyboardIsVT220
+#endif
+           && ((string = (Char *) udk_lookup(dec_code, &kd.nbytes)) != 0)) {
+           UIntClr(evt_state, ShiftMask);
+           while (kd.nbytes-- > 0)
+               unparseputc(xw, CharOf(*string++));
+       }
+       /*
+        * Interpret F1-F4 as PF1-PF4 for VT52, VT100
+        */
+       else if (keyboard->type != keyboardIsLegacy
+                && (dec_code >= 11 && dec_code <= 14)) {
+           reply.a_type = ANSI_SS3;
+           VT52_CURSOR_KEYS;
+           reply.a_final = (Char) A2E(dec_code - 11 + E2A('P'));
+           modifyCursorKey(&reply,
+                           keyboard->modify_now.function_keys,
+                           &modify_parm);
+           MODIFIER_PARM;
+           unparseseq(xw, &reply);
+       } else {
+           reply.a_type = ANSI_CSI;
+           reply.a_final = 0;
+
+#ifdef XK_ISO_Left_Tab
+           if (kd.keysym == XK_ISO_Left_Tab) {
+               reply.a_nparam = 0;
+               reply.a_final = 'Z';
+#if OPT_MOD_FKEYS
+               if (keyboard->modify_now.other_keys > 1
+                   && computeMaskedModifier(xw, evt_state, ShiftMask))
+                   modifyOtherKey(&reply, '\t', modify_parm, keyboard->format_keys);
+#endif
+           } else
+#endif /* XK_ISO_Left_Tab */
+           {
+               reply.a_nparam = 1;
+#if OPT_MOD_FKEYS
+               if (kd.is_fkey) {
+                   modifyCursorKey(&reply,
+                                   keyboard->modify_now.function_keys,
+                                   &modify_parm);
+               }
+               MODIFIER_PARM;
+#endif
+               reply.a_param[0] = (ParmType) dec_code;
+               reply.a_final = '~';
+           }
+           if (reply.a_final != 0
+               && (reply.a_nparam == 0 || reply.a_param[0] >= 0))
+               unparseseq(xw, &reply);
+       }
+       key = True;
+    } else if (IsPFKey(kd.keysym)) {
+       reply.a_type = ANSI_SS3;
+       reply.a_final = (Char) ((kd.keysym - XK_KP_F1) + 'P');
+       VT52_CURSOR_KEYS;
+       MODIFIER_PARM;
+       unparseseq(xw, &reply);
+       key = True;
+    } else if (IsKeypadKey(kd.keysym)) {
+       if (keypad_mode) {
+           reply.a_type = ANSI_SS3;
+           reply.a_final = (Char) (kypd_apl[kd.keysym - XK_KP_Space]);
+           VT52_KEYPAD;
+           MODIFIER_PARM;
+           unparseseq(xw, &reply);
+       } else {
+           unparseputc(xw, kypd_num[kd.keysym - XK_KP_Space]);
+       }
+       key = True;
+    } else if (IsCursorKey(kd.keysym)) {
+       if (keyboard->flags & MODE_DECCKM) {
+           reply.a_type = ANSI_SS3;
+       } else {
+           reply.a_type = ANSI_CSI;
+       }
+       modifyCursorKey(&reply, keyboard->modify_now.cursor_keys, &modify_parm);
+       reply.a_final = (Char) (curfinal[kd.keysym - XK_Home]);
+       VT52_CURSOR_KEYS;
+       MODIFIER_PARM;
+       unparseseq(xw, &reply);
+       key = True;
+    } else if (kd.nbytes > 0) {
+       int prefix = 0;
+
+#if OPT_TEK4014
+       if (TEK4014_GIN(tekWidget)) {
+           TekEnqMouse(tekWidget, kd.strbuf[0]);
+           TekGINoff(tekWidget);
+           kd.nbytes--;
+           for (j = 0; j < kd.nbytes; ++j) {
+               kd.strbuf[j] = kd.strbuf[j + 1];
+           }
+       }
+#endif
+#if OPT_MOD_FKEYS
+       if ((keyboard->modify_now.other_keys > 0)
+           && ModifyOtherKeys(xw, evt_state, &kd, modify_parm)
+           && (mod_state = allowedCharModifiers(xw, evt_state, &kd)) != 0) {
+           int input_char;
+
+           evt_state = mod_state;
+
+           modify_parm = xtermStateToParam(xw, evt_state);
+
+           /*
+            * We want to show a keycode that corresponds to the 8-bit value
+            * of the key.  If the keysym is less than 256, that is good
+            * enough.  Special keys such as Tab may result in a value that
+            * is usable as well.  For the latter (special cases), try to use
+            * the result from the X library lookup.
+            */
+           input_char = ((kd.keysym < 256)
+                         ? (int) kd.keysym
+                         : ((kd.nbytes == 1)
+                            ? CharOf(kd.strbuf[0])
+                            : -1));
+
+           TRACE(("...modifyOtherKeys %d;%d\n", modify_parm, input_char));
+           if (modifyOtherKey(&reply, input_char, modify_parm, keyboard->format_keys)) {
+               unparseseq(xw, &reply);
+           } else {
+               Bell(xw, XkbBI_MinorError, 0);
+           }
+       } else
+#endif /* OPT_MOD_FKEYS */
+       {
+#if OPT_NUM_LOCK
+           /*
+            * Send ESC if we have a META modifier and metaSendsEcape is true.
+            * Like eightBitInput, except that it is not associated with
+            * terminal settings.
+            */
+           if (kd.nbytes != 0) {
+               if (screen->meta_sends_esc
+                   && (evt_state & xw->misc.meta_mods) != 0) {
+                   TRACE(("...input-char is modified by META\n"));
+                   UIntClr(evt_state, xw->misc.meta_mods);
+                   eightbit = False;
+                   prefix = ANSI_ESC;
+               } else if (eightbit) {
+                   /* it might be overridden, but this helps for debugging */
+                   TRACE(("...input-char is shifted by META\n"));
+               }
+               if (screen->alt_is_not_meta
+                   && (evt_state & xw->misc.alt_mods) != 0) {
+                   UIntClr(evt_state, xw->misc.alt_mods);
+                   if (screen->alt_sends_esc) {
+                       TRACE(("...input-char is modified by ALT\n"));
+                       eightbit = False;
+                       prefix = ANSI_ESC;
+                   } else if (!eightbit) {
+                       TRACE(("...input-char is shifted by ALT\n"));
+                       eightbit = True;
+                   }
+               }
+           }
+#endif
+           /*
+            * If metaSendsEscape is false, fall through to this chunk, which
+            * implements the eightBitInput resource.
+            *
+            * It is normally executed when the user presses Meta plus a
+            * printable key, e.g., Meta+space.  The presence of the Meta
+            * modifier is not guaranteed since what really happens is the
+            * "insert-eight-bit" or "insert-seven-bit" action, which we
+            * distinguish by the eightbit parameter to this function.  So the
+            * eightBitInput resource really means that we use this shifting
+            * logic in the "insert-eight-bit" action.
+            */
+           if (eightbit && (kd.nbytes == 1) && screen->input_eight_bits) {
+               IChar ch = CharOf(kd.strbuf[0]);
+               if (ch < 128) {
+                   kd.strbuf[0] |= (char) 0x80;
+                   TRACE(("...input shift from %d to %d (%#x to %#x)\n",
+                          ch, CharOf(kd.strbuf[0]),
+                          ch, CharOf(kd.strbuf[0])));
+#if OPT_WIDE_CHARS
+                   if (screen->utf8_mode) {
+                       /*
+                        * We could interpret the incoming code as "in the
+                        * current locale", but it's simpler to treat it as
+                        * a Unicode value to translate to UTF-8.
+                        */
+                       ch = CharOf(kd.strbuf[0]);
+                       kd.nbytes = 2;
+                       kd.strbuf[0] = (char) (0xc0 | ((ch >> 6) & 0x3));
+                       kd.strbuf[1] = (char) (0x80 | (ch & 0x3f));
+                       TRACE(("...encoded %#x in UTF-8 as %#x,%#x\n",
+                              ch, CharOf(kd.strbuf[0]), CharOf(kd.strbuf[1])));
+                   }
+#endif
+               }
+               eightbit = False;
+           }
+#if OPT_WIDE_CHARS
+           if (kd.nbytes == 1) /* cannot do NRC on UTF-8, for instance */
+#endif
+           {
+               /* VT220 & up: National Replacement Characters */
+               if ((xw->flags & NATIONAL) != 0) {
+                   unsigned cmp = xtermCharSetIn(CharOf(kd.strbuf[0]),
+                                                 screen->keyboard_dialect[0]);
+                   TRACE(("...input NRC %d, %s %d\n",
+                          CharOf(kd.strbuf[0]),
+                          (CharOf(kd.strbuf[0]) == cmp)
+                          ? "unchanged"
+                          : "changed to",
+                          CharOf(cmp)));
+                   kd.strbuf[0] = (char) cmp;
+               } else if (eightbit) {
+                   prefix = ANSI_ESC;
+               } else if (kd.strbuf[0] == '?'
+                          && (evt_state & ControlMask) != 0) {
+                   kd.strbuf[0] = ANSI_DEL;
+                   UIntClr(evt_state, ControlMask);
+               }
+           }
+           if (prefix != 0)
+               unparseputc(xw, prefix);        /* escape */
+           for (j = 0; j < kd.nbytes; ++j)
+               unparseputc(xw, CharOf(kd.strbuf[j]));
+       }
+       key = ((kd.keysym != ANSI_XOFF) && (kd.keysym != ANSI_XON));
+    }
+    unparse_end(xw);
+
+    if (key && !TEK4014_ACTIVE(xw))
+       AdjustAfterInput(xw);
+
+    xtermShowPointer(xw, False);
+    return;
+}
+
+void
+StringInput(XtermWidget xw, const Char * string, size_t nbytes)
+{
+    TRACE(("InputString (%s,%lu)\n",
+          visibleChars(string, (unsigned) nbytes),
+          (unsigned long) nbytes));
+#if OPT_TEK4014
+    if (nbytes && TEK4014_GIN(tekWidget)) {
+       TekEnqMouse(tekWidget, *string++);
+       TekGINoff(tekWidget);
+       nbytes--;
+    }
+#endif
+    while (nbytes-- != 0)
+       unparseputc(xw, *string++);
+    if (!TEK4014_ACTIVE(xw))
+       AdjustAfterInput(xw);
+    unparse_end(xw);
+}
+
+/* These definitions are DEC-style (e.g., vt320) */
+static int
+decfuncvalue(KEY_DATA * kd)
+{
+    int result;
+
+    if (kd->is_fkey) {
+       switch (kd->keysym) {
+           MAP(XK_Fn(1), 11);
+           MAP(XK_Fn(2), 12);
+           MAP(XK_Fn(3), 13);
+           MAP(XK_Fn(4), 14);
+           MAP(XK_Fn(5), 15);
+           MAP(XK_Fn(6), 17);
+           MAP(XK_Fn(7), 18);
+           MAP(XK_Fn(8), 19);
+           MAP(XK_Fn(9), 20);
+           MAP(XK_Fn(10), 21);
+           MAP(XK_Fn(11), 23);
+           MAP(XK_Fn(12), 24);
+           MAP(XK_Fn(13), 25);
+           MAP(XK_Fn(14), 26);
+           MAP(XK_Fn(15), 28);
+           MAP(XK_Fn(16), 29);
+           MAP(XK_Fn(17), 31);
+           MAP(XK_Fn(18), 32);
+           MAP(XK_Fn(19), 33);
+           MAP(XK_Fn(20), 34);
+       default:
+           /* after F20 the codes are made up and do not correspond to any
+            * real terminal.  So they are simply numbered sequentially.
+            */
+           result = 42 + (int) (kd->keysym - XK_Fn(21));
+           break;
+       }
+    } else {
+       switch (kd->keysym) {
+           MAP(XK_Find, 1);
+           MAP(XK_Insert, 2);
+           MAP(XK_Delete, 3);
+#ifdef XK_KP_Insert
+           MAP(XK_KP_Insert, 2);
+           MAP(XK_KP_Delete, 3);
+#endif
+#ifdef DXK_Remove
+           MAP(DXK_Remove, 3);
+#endif
+           MAP(XK_Select, 4);
+           MAP(XK_Prior, 5);
+           MAP(XK_Next, 6);
+#ifdef XK_ISO_Left_Tab
+           MAP(XK_ISO_Left_Tab, 'Z');
+#endif
+           MAP(XK_Help, 28);
+           MAP(XK_Menu, 29);
+       default:
+           result = -1;
+           break;
+       }
+    }
+    return result;
+}
+
+static void
+hpfuncvalue(ANSI * reply, KEY_DATA * kd)
+{
+#if OPT_HP_FUNC_KEYS
+    int result;
+
+    if (kd->is_fkey) {
+       switch (kd->keysym) {
+           MAP(XK_Fn(1), 'p');
+           MAP(XK_Fn(2), 'q');
+           MAP(XK_Fn(3), 'r');
+           MAP(XK_Fn(4), 's');
+           MAP(XK_Fn(5), 't');
+           MAP(XK_Fn(6), 'u');
+           MAP(XK_Fn(7), 'v');
+           MAP(XK_Fn(8), 'w');
+       default:
+           result = -1;
+           break;
+       }
+    } else {
+       switch (kd->keysym) {
+           MAP(XK_Up, 'A');
+           MAP(XK_Down, 'B');
+           MAP(XK_Right, 'C');
+           MAP(XK_Left, 'D');
+           MAP(XK_End, 'F');
+           MAP(XK_Clear, 'J');
+           MAP(XK_Delete, 'P');
+           MAP(XK_Insert, 'Q');
+           MAP(XK_Next, 'S');
+           MAP(XK_Prior, 'T');
+           MAP(XK_Home, 'h');
+#ifdef XK_KP_Insert
+           MAP(XK_KP_Delete, 'P');
+           MAP(XK_KP_Insert, 'Q');
+#endif
+#ifdef DXK_Remove
+           MAP(DXK_Remove, 'P');
+#endif
+           MAP(XK_Select, 'F');
+           MAP(XK_Find, 'h');
+       default:
+           result = -1;
+           break;
+       }
+    }
+    if (result > 0) {
+       reply->a_type = ANSI_ESC;
+       reply->a_final = (Char) result;
+    }
+#else
+    (void) reply;
+    (void) kd;
+#endif /* OPT_HP_FUNC_KEYS */
+}
+
+static void
+scofuncvalue(ANSI * reply, KEY_DATA * kd)
+{
+#if OPT_SCO_FUNC_KEYS
+    int result;
+
+    if (kd->is_fkey) {
+       switch (kd->keysym) {
+           MAP(XK_Fn(1), 'M');
+           MAP(XK_Fn(2), 'N');
+           MAP(XK_Fn(3), 'O');
+           MAP(XK_Fn(4), 'P');
+           MAP(XK_Fn(5), 'Q');
+           MAP(XK_Fn(6), 'R');
+           MAP(XK_Fn(7), 'S');
+           MAP(XK_Fn(8), 'T');
+           MAP(XK_Fn(9), 'U');
+           MAP(XK_Fn(10), 'V');
+           MAP(XK_Fn(11), 'W');
+           MAP(XK_Fn(12), 'X');
+           MAP(XK_Fn(13), 'Y');
+           MAP(XK_Fn(14), 'Z');
+           MAP(XK_Fn(15), 'a');
+           MAP(XK_Fn(16), 'b');
+           MAP(XK_Fn(17), 'c');
+           MAP(XK_Fn(18), 'd');
+           MAP(XK_Fn(19), 'e');
+           MAP(XK_Fn(20), 'f');
+           MAP(XK_Fn(21), 'g');
+           MAP(XK_Fn(22), 'h');
+           MAP(XK_Fn(23), 'i');
+           MAP(XK_Fn(24), 'j');
+           MAP(XK_Fn(25), 'k');
+           MAP(XK_Fn(26), 'l');
+           MAP(XK_Fn(27), 'm');
+           MAP(XK_Fn(28), 'n');
+           MAP(XK_Fn(29), 'o');
+           MAP(XK_Fn(30), 'p');
+           MAP(XK_Fn(31), 'q');
+           MAP(XK_Fn(32), 'r');
+           MAP(XK_Fn(33), 's');
+           MAP(XK_Fn(34), 't');
+           MAP(XK_Fn(35), 'u');
+           MAP(XK_Fn(36), 'v');
+           MAP(XK_Fn(37), 'w');
+           MAP(XK_Fn(38), 'x');
+           MAP(XK_Fn(39), 'y');
+           MAP(XK_Fn(40), 'z');
+           MAP(XK_Fn(41), '@');
+           MAP(XK_Fn(42), '[');
+           MAP(XK_Fn(43), '\\');
+           MAP(XK_Fn(44), ']');
+           MAP(XK_Fn(45), '^');
+           MAP(XK_Fn(46), '_');
+           MAP(XK_Fn(47), '`');
+           MAP(XK_Fn(48), '{');        /* no matching '}' */
+       default:
+           result = -1;
+           break;
+       }
+    } else {
+       switch (kd->keysym) {
+           MAP(XK_Up, 'A');
+           MAP(XK_Down, 'B');
+           MAP(XK_Right, 'C');
+           MAP(XK_Left, 'D');
+           MAP(XK_Begin, 'E');
+           MAP(XK_End, 'F');
+           MAP(XK_Insert, 'L');
+           MAP(XK_Next, 'G');
+           MAP(XK_Prior, 'I');
+           MAP(XK_Home, 'H');
+#ifdef XK_KP_Insert
+           MAP(XK_KP_Insert, 'L');
+#endif
+       default:
+           result = -1;
+           break;
+       }
+    }
+    if (result > 0) {
+       reply->a_type = ANSI_CSI;
+       reply->a_final = (Char) result;
+    }
+#else
+    (void) reply;
+    (void) kd;
+#endif /* OPT_SCO_FUNC_KEYS */
+}
+
+static void
+sunfuncvalue(ANSI * reply, KEY_DATA * kd)
+{
+#if OPT_SUN_FUNC_KEYS
+    ParmType result;
+
+    if (kd->is_fkey) {
+       switch (kd->keysym) {
+           /* kf1-kf20 are numbered sequentially */
+           MAP(XK_Fn(1), 224);
+           MAP(XK_Fn(2), 225);
+           MAP(XK_Fn(3), 226);
+           MAP(XK_Fn(4), 227);
+           MAP(XK_Fn(5), 228);
+           MAP(XK_Fn(6), 229);
+           MAP(XK_Fn(7), 230);
+           MAP(XK_Fn(8), 231);
+           MAP(XK_Fn(9), 232);
+           MAP(XK_Fn(10), 233);
+           MAP(XK_Fn(11), 192);
+           MAP(XK_Fn(12), 193);
+           MAP(XK_Fn(13), 194);
+           MAP(XK_Fn(14), 195);        /* kund */
+           MAP(XK_Fn(15), 196);
+           MAP(XK_Fn(16), 197);        /* kcpy */
+           MAP(XK_Fn(17), 198);
+           MAP(XK_Fn(18), 199);
+           MAP(XK_Fn(19), 200);        /* kfnd */
+           MAP(XK_Fn(20), 201);
+
+           /* kf31-kf36 are numbered sequentially */
+           MAP(XK_Fn(21), 208);        /* kf31 */
+           MAP(XK_Fn(22), 209);
+           MAP(XK_Fn(23), 210);
+           MAP(XK_Fn(24), 211);
+           MAP(XK_Fn(25), 212);
+           MAP(XK_Fn(26), 213);        /* kf36 */
+
+           /* kf37-kf47 are interspersed with keypad keys */
+           MAP(XK_Fn(27), 214);        /* khome */
+           MAP(XK_Fn(28), 215);        /* kf38 */
+           MAP(XK_Fn(29), 216);        /* kpp */
+           MAP(XK_Fn(30), 217);        /* kf40 */
+           MAP(XK_Fn(31), 218);        /* kb2 */
+           MAP(XK_Fn(32), 219);        /* kf42 */
+           MAP(XK_Fn(33), 220);        /* kend */
+           MAP(XK_Fn(34), 221);        /* kf44 */
+           MAP(XK_Fn(35), 222);        /* knp */
+           MAP(XK_Fn(36), 234);        /* kf46 */
+           MAP(XK_Fn(37), 235);        /* kf47 */
+       default:
+           result = -1;
+           break;
+       }
+    } else {
+       switch (kd->keysym) {
+           MAP(XK_Help, 196);  /* khlp */
+           MAP(XK_Menu, 197);
+
+           MAP(XK_Find, 1);
+           MAP(XK_Insert, 2);  /* kich1 */
+           MAP(XK_Delete, 3);
+#ifdef XK_KP_Insert
+           MAP(XK_KP_Insert, 2);
+           MAP(XK_KP_Delete, 3);
+#endif
+#ifdef DXK_Remove
+           MAP(DXK_Remove, 3);
+#endif
+           MAP(XK_Select, 4);
+
+           MAP(XK_Prior, 216);
+           MAP(XK_Next, 222);
+           MAP(XK_Home, 214);
+           MAP(XK_End, 220);
+           MAP(XK_Begin, 218); /* kf41=kb2 */
+
+       default:
+           result = -1;
+           break;
+       }
+    }
+    if (result > 0) {
+       reply->a_type = ANSI_CSI;
+       reply->a_nparam = 1;
+       reply->a_param[0] = result;
+       reply->a_final = 'z';
+    } else if (IsCursorKey(kd->keysym)) {
+       reply->a_type = ANSI_SS3;
+       reply->a_final = (Char) curfinal[kd->keysym - XK_Home];
+    }
+#else
+    (void) reply;
+    (void) kd;
+#endif /* OPT_SUN_FUNC_KEYS */
+}
+
+#if OPT_NUM_LOCK
+#define isName(c) ((c) == '_' || (c) == '-' || isalnum(CharOf(c)))
+
+static const char *
+skipName(const char *s)
+{
+    while (*s != '\0' && isName(CharOf(*s)))
+       ++s;
+    return s;
+}
+
+/*
+ * Found a ":" in a translation, check what is past it to see if it contains
+ * any of the insert-text action names.
+ */
+static Boolean
+keyCanInsert(const char *parse)
+{
+    Boolean result = False;
+    int ch;
+    Boolean escape = False;
+    Boolean quoted = False;
+
+    static const char *table[] =
+    {
+       "insert",
+       "insert-seven-bit",
+       "insert-eight-bit",
+       "string",
+    };
+    Cardinal n;
+
+    while (*parse != '\0' && *parse != '\n') {
+       ch = CharOf(*parse++);
+       if (escape) {
+           escape = False;
+       } else if (ch == '\\') {
+           escape = True;
+       } else if (ch == '"') {
+           quoted = (Boolean) ! quoted;
+       } else if (!quoted && isName(ch)) {
+           const char *next = skipName(--parse);
+           size_t need = (size_t) (next - parse);
+
+           for (n = 0; n < XtNumber(table); ++n) {
+               if (need == strlen(table[n])
+                   && !strncmp(parse, table[n], need)) {
+                   result = True;
+                   break;
+               }
+           }
+           parse = next;
+       }
+
+    }
+    return result;
+}
+
+/*
+ * Strip the entire action, to avoid matching it.
+ */
+static char *
+stripAction(char *base, char *last)
+{
+    while (last != base) {
+       if (*--last == '\n') {
+           break;
+       }
+    }
+    return last;
+}
+
+static char *
+stripBlanks(char *base, char *last)
+{
+    while (last != base) {
+       int ch = CharOf(last[-1]);
+       if (ch != ' ' && ch != '\t')
+           break;
+       --last;
+    }
+    return last;
+}
+
+/*
+ * Strip unneeded whitespace from a translations resource, mono-casing and
+ * returning a malloc'd copy of the result.
+ */
+static char *
+stripTranslations(const char *s, Bool onlyInsert)
+{
+    char *dst = 0;
+
+    if (s != 0) {
+       dst = TypeMallocN(char, strlen(s) + 1);
+
+       if (dst != 0) {
+           int state = 0;
+           int ch = 0;
+           int prv = 0;
+           char *d = dst;
+
+           TRACE(("stripping:\n%s\n", s));
+           while (*s != '\0') {
+               ch = *s++;
+               if (ch == '\n') {
+                   if (d != dst)
+                       *d++ = (char) ch;
+                   state = 0;
+               } else if (strchr(":!#", ch) != 0) {
+                   d = stripBlanks(dst, d);
+                   if (onlyInsert && (ch == ':') && !keyCanInsert(s)) {
+                       d = stripAction(dst, d);
+                   }
+                   state = -1;
+               } else if (state >= 0) {
+                   if (isspace(CharOf(ch))) {
+                       if (state == 0 || strchr("<>~ \t", prv))
+                           continue;
+                   } else if (strchr("<>~", ch)) {
+                       d = stripBlanks(dst, d);
+                   }
+                   *d++ = x_toupper(ch);
+                   ++state;
+               }
+               prv = ch;
+           }
+           *d = '\0';
+           TRACE(("...result:\n%s\n", dst));
+       }
+    }
+    return dst;
+}
+
+/*
+ * Make a simple check to see if a given translations keyword appears in
+ * xterm's translations resource.  It does not attempt to parse the strings,
+ * just makes a case-independent check and ensures that the ends of the match
+ * are on token-boundaries.
+ *
+ * That this can only retrieve translations that are given as resource values;
+ * the default translations in charproc.c for example are not retrievable by
+ * any interface to X.
+ *
+ * Also:  We can retrieve only the most-specified translation resource.  For
+ * example, if the resource file specifies both "*translations" and
+ * "XTerm*translations", we see only the latter.
+ */
+static Bool
+TranslationsUseKeyword(Widget w, char **cache, const char *keyword, Bool onlyInsert)
+{
+    static String data;
+    static XtResource key_resources[] =
+    {
+       {XtNtranslations, XtCTranslations, XtRString,
+        sizeof(data), 0, XtRString, (XtPointer) NULL}
+    };
+    Bool result = False;
+    char *copy;
+    char *test;
+
+    if ((test = stripTranslations(keyword, onlyInsert)) != 0) {
+       if (*cache == 0) {
+           XtGetSubresources(w,
+                             (XtPointer) &data,
+                             "vt100",
+                             "VT100",
+                             key_resources,
+                             XtNumber(key_resources),
+                             NULL,
+                             (Cardinal) 0);
+           if (data != 0 && (copy = stripTranslations(data, onlyInsert)) != 0) {
+               *cache = copy;
+           }
+       }
+
+       if (*cache != 0) {
+           char *p = *cache;
+           int state = 0;
+           int now = ' ', prv;
+
+           while (*p != 0) {
+               prv = now;
+               now = *p++;
+               if (now == ':'
+                   || now == '!') {
+                   state = -1;
+               } else if (now == '\n') {
+                   state = 0;
+               } else if (state >= 0) {
+                   if (now == test[state]) {
+                       if ((state != 0
+                            || !isName(prv))
+                           && ((test[++state] == 0)
+                               && !isName(*p))) {
+                           result = True;
+                           break;
+                       }
+                   } else {
+                       state = 0;
+                   }
+               }
+           }
+       }
+       free(test);
+    }
+    TRACE(("TranslationsUseKeyword(%p, %s) = %d\n",
+          (void *) w, keyword, result));
+    return result;
+}
+
+static Bool
+xtermHasTranslation(XtermWidget xw, const char *keyword, Bool onlyInsert)
+{
+    return (TranslationsUseKeyword(SHELL_OF(xw),
+                                  &(xw->keyboard.shell_translations),
+                                  keyword,
+                                  onlyInsert)
+           || TranslationsUseKeyword((Widget) xw,
+                                     &(xw->keyboard.xterm_translations),
+                                     keyword,
+                                     onlyInsert));
+}
+
+#if OPT_EXTRA_PASTE
+static void
+addTranslation(XtermWidget xw, const char *fromString, const char *toString)
+{
+    size_t have = (xw->keyboard.extra_translations
+                  ? strlen(xw->keyboard.extra_translations)
+                  : 0);
+    size_t need = (((have != 0) ? (have + 4) : 0)
+                  + strlen(fromString)
+                  + strlen(toString)
+                  + 6);
+
+    if (!xtermHasTranslation(xw, fromString, False)) {
+       xw->keyboard.extra_translations
+           = TypeRealloc(char, need, xw->keyboard.extra_translations);
+       if ((xw->keyboard.extra_translations) != 0) {
+           TRACE(("adding %s: %s\n", fromString, toString));
+           if (have)
+               strcat(xw->keyboard.extra_translations, " \\n\\");
+           sprintf(xw->keyboard.extra_translations, "%s: %s",
+                   fromString, toString);
+           TRACE(("...{%s}\n", xw->keyboard.extra_translations));
+       }
+    }
+}
+#endif
+
+#define SaveMask(name) xw->misc.name |= (unsigned) mask;\
+                       TRACE(("SaveMask(%s) %#x (%#x is%s modifier)\n", \
+                               #name, \
+                               xw->misc.name, (unsigned) mask, \
+                               ModifierName((unsigned) mask)));
+/*
+ * Determine which modifier mask (if any) applies to the Num_Lock keysym.
+ *
+ * Also, determine which modifiers are associated with the ALT keys, so we can
+ * send that information as a parameter for special keys in Sun/PC keyboard
+ * mode.  However, if the ALT modifier is used in translations, we do not want
+ * to confuse things by sending the parameter.
+ */
+void
+VTInitModifiers(XtermWidget xw)
+{
+    Display *dpy = XtDisplay(xw);
+    XModifierKeymap *keymap = XGetModifierMapping(dpy);
+    int i, j, k, l;
+    KeySym keysym;
+    unsigned long mask;
+    int min_keycode, max_keycode, keysyms_per_keycode = 0;
+
+    if (keymap != 0) {
+       KeySym *theMap;
+       int keycode_count;
+
+       TRACE(("VTInitModifiers\n"));
+
+       XDisplayKeycodes(dpy, &min_keycode, &max_keycode);
+       keycode_count = (max_keycode - min_keycode + 1);
+       theMap = XGetKeyboardMapping(dpy,
+                                    (KeyCode) min_keycode,
+                                    keycode_count,
+                                    &keysyms_per_keycode);
+
+       if (theMap != 0) {
+
+#if OPT_EXTRA_PASTE
+           /*
+            * Assume that if we can find the paste keysym in the X keyboard
+            * mapping that the server allows the corresponding translations
+            * resource.
+            */
+           int limit = (max_keycode - min_keycode) * keysyms_per_keycode;
+           for (i = 0; i < limit; ++i) {
+#ifdef XF86XK_Paste
+               if (theMap[i] == XF86XK_Paste) {
+                   TRACE(("keyboard has XF86XK_Paste\n"));
+                   addTranslation(xw,
+                                  "<KeyPress> XF86Paste",
+                                  "insert-selection(SELECT, CUT_BUFFER0)");
+               }
+#endif
+#ifdef SunXK_Paste
+               if (theMap[i] == SunXK_Paste) {
+                   TRACE(("keyboard has SunXK_Paste\n"));
+                   addTranslation(xw,
+                                  "<KeyPress> SunPaste",
+                                  "insert-selection(SELECT, CUT_BUFFER0)");
+               }
+#endif
+           }
+#endif /* OPT_EXTRA_PASTE */
+
+           for (i = k = 0, mask = 1; i < 8; i++, mask <<= 1) {
+               for (j = 0; j < keymap->max_keypermod; j++) {
+                   KeyCode code = keymap->modifiermap[k++];
+                   if (code == 0)
+                       continue;
+
+                   for (l = 0; l < keysyms_per_keycode; ++l) {
+                       keysym = XKeycodeToKeysym(dpy, code, l);
+                       if (keysym == NoSymbol) {
+                           /* EMPTY */ ;
+                       } else if (keysym == XK_Num_Lock) {
+                           SaveMask(num_lock);
+                       } else if (keysym == XK_Alt_L || keysym == XK_Alt_R) {
+                           SaveMask(alt_mods);
+                       } else if (keysym == XK_Meta_L || keysym == XK_Meta_R) {
+                           SaveMask(meta_mods);
+                       } else if (mask == ShiftMask
+                                  && (keysym == XK_Shift_L
+                                      || keysym == XK_Shift_R)) {
+                           /* EMPTY */ ;
+                       } else if (mask == ControlMask
+                                  && (keysym == XK_Control_L
+                                      || keysym == XK_Control_R)) {
+                           /* EMPTY */ ;
+                       } else if (mask == LockMask
+                                  && (keysym == XK_Caps_Lock)) {
+                           /* EMPTY */ ;
+                       } else if (keysym == XK_Mode_switch
+#ifdef XK_ISO_Level3_Shift
+                                  || keysym == XK_ISO_Level3_Shift
+#endif
+                           ) {
+                           SaveMask(other_mods);
+                       }
+                   }
+               }
+           }
+           XFree(theMap);
+       }
+
+       /* Don't disable any mods if "alwaysUseMods" is true. */
+       if (!xw->misc.alwaysUseMods) {
+
+           /*
+            * Force TranslationsUseKeyword() to reload.
+            */
+           if (xw->keyboard.shell_translations) {
+               free(xw->keyboard.shell_translations);
+               xw->keyboard.shell_translations = 0;
+           }
+           if (xw->keyboard.xterm_translations) {
+               free(xw->keyboard.xterm_translations);
+               xw->keyboard.xterm_translations = 0;
+           }
+
+           /*
+            * If the Alt modifier is used in translations, we would rather not
+            * use it to modify function-keys when NumLock is active.
+            */
+           if ((xw->misc.alt_mods != 0)
+               && xtermHasTranslation(xw, "alt", True)) {
+               TRACE(("ALT is used as a modifier in translations (ignore mask)\n"));
+               xw->misc.alt_mods = 0;
+           }
+
+           /*
+            * If the Meta modifier is used in translations, we would rather not
+            * use it to modify function-keys.
+            */
+           if ((xw->misc.meta_mods != 0)
+               && xtermHasTranslation(xw, "meta", True)) {
+               TRACE(("META is used as a modifier in translations\n"));
+               xw->misc.meta_mods = 0;
+           }
+       }
+
+       XFreeModifiermap(keymap);
+    }
+}
+#endif /* OPT_NUM_LOCK */
diff --git a/install-sh b/install-sh
new file mode 100755 (executable)
index 0000000..462fa9c
--- /dev/null
@@ -0,0 +1,294 @@
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+#
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+       -c) instcmd=$cpprog
+           shift
+           continue;;
+
+       -d) dir_arg=true
+           shift
+           continue;;
+
+       -m) chmodcmd="$chmodprog $2"
+           shift
+           shift
+           continue;;
+
+       -o) chowncmd="$chownprog $2"
+           shift
+           shift
+           continue;;
+
+       -g) chgrpcmd="$chgrpprog $2"
+           shift
+           shift
+           continue;;
+
+       -s) stripcmd=$stripprog
+           shift
+           continue;;
+
+       -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+           shift
+           continue;;
+
+       -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+           shift
+           continue;;
+
+       *)  if [ x"$src" = x ]
+           then
+               src=$1
+           else
+               # this colon is to work around a 386BSD /bin/sh bug
+               :
+               dst=$1
+           fi
+           shift
+           continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+       echo "$0: no input file specified" >&2
+       exit 1
+else
+       :
+fi
+
+if [ x"$dir_arg" != x ]; then
+       dst=$src
+       src=""
+
+       if [ -d "$dst" ]; then
+               instcmd=:
+               chmodcmd=""
+       else
+               instcmd=$mkdirprog
+       fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+       if [ -f "$src" ] || [ -d "$src" ]
+       then
+               :
+       else
+               echo "$0: $src does not exist" >&2
+               exit 1
+       fi
+
+       if [ x"$dst" = x ]
+       then
+               echo "$0: no destination specified" >&2
+               exit 1
+       else
+               :
+       fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+       if [ -d "$dst" ]
+       then
+               dst=$dst/`basename "$src"`
+       else
+               :
+       fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+       '
+IFS="${IFS-$defaultIFS}"
+
+oIFS=$IFS
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS=$oIFS
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+       pathcomp=$pathcomp$1
+       shift
+
+       if [ ! -d "$pathcomp" ] ;
+        then
+               $mkdirprog "$pathcomp"
+       else
+               :
+       fi
+
+       pathcomp=$pathcomp/
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+       $doit $instcmd "$dst" &&
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+       if [ x"$transformarg" = x ]
+       then
+               dstfile=`basename "$dst"`
+       else
+               dstfile=`basename "$dst" $transformbasename |
+                       sed $transformarg`$transformbasename
+       fi
+
+# don't allow the sed command to completely eliminate the filename
+
+       if [ x"$dstfile" = x ]
+       then
+               dstfile=`basename "$dst"`
+       else
+               :
+       fi
+
+# Make a couple of temp file names in the proper directory.
+
+       dsttmp=$dstdir/#inst.$$#
+       rmtmp=$dstdir/#rm.$$#
+
+# Trap to clean up temp files at exit.
+
+       trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
+       trap '(exit $?); exit' 1 2 13 15
+
+# Move or copy the file name to the temp name
+
+       $doit $instcmd "$src" "$dsttmp" &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
+
+# Now remove or move aside any old file at destination location.  We try this
+# two ways since rm can't unlink itself on some systems and the destination
+# file might be busy for other reasons.  In this case, the final cleanup
+# might fail but the new file should still install successfully.
+
+{
+       if [ -f "$dstdir/$dstfile" ]
+       then
+               $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
+               $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
+               {
+                 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+                 (exit 1); exit
+               }
+       else
+               :
+       fi
+} &&
+
+# Now rename the file to the real destination.
+
+       $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+
+fi &&
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+
+{
+       (exit 0); exit
+}
diff --git a/keysym2ucs.c b/keysym2ucs.c
new file mode 100644 (file)
index 0000000..69cf161
--- /dev/null
@@ -0,0 +1,871 @@
+/* $XTermId: keysym2ucs.c,v 1.15 2007/06/13 00:16:56 tom Exp $
+ * This module converts keysym values into the corresponding ISO 10646
+ * (UCS, Unicode) values.
+ *
+ * The array keysymtab[] contains pairs of X11 keysym values for graphical
+ * characters and the corresponding Unicode value. The function
+ * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
+ * therefore keysymtab[] must remain SORTED by keysym value.
+ *
+ * The keysym -> UTF-8 conversion will hopefully one day be provided
+ * by Xlib via XmbLookupString() and should ideally not have to be
+ * done in X applications. But we are not there yet.
+ *
+ * We allow to represent any UCS character in the range U-00000000 to
+ * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
+ * This admittedly does not cover the entire 31-bit space of UCS, but
+ * it does cover all of the characters up to U-10FFFF, which can be
+ * represented by UTF-16, and more, and it is very unlikely that higher
+ * UCS codes will ever be assigned by ISO. So to get Unicode character
+ * U+ABCD you can directly use keysym 0x0100abcd.
+ *
+ * NOTE: The comments in the table below contain the actual character
+ * encoded in UTF-8, so for viewing and editing best use an editor in
+ * UTF-8 mode.
+ *
+ * Author: Markus G. Kuhn <mkuhn@acm.org>, University of Cambridge, April 2001
+ *
+ * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
+ * an initial draft of the mapping table.
+ *
+ * This software is in the public domain. Share and enjoy!
+ *
+ * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl)
+ */
+
+#ifndef KEYSYM2UCS_INCLUDED
+  
+#include "keysym2ucs.h"
+#define VISIBLE /* */
+
+#else
+
+#define VISIBLE static
+
+#endif
+
+static struct codepair {
+  unsigned short keysym;
+  unsigned short ucs;
+} keysymtab[] = {
+  { 0x01a1, 0x0104 }, /*                     Aogonek Ą LATIN CAPITAL LETTER A WITH OGONEK */
+  { 0x01a2, 0x02d8 }, /*                       breve ˘ BREVE */
+  { 0x01a3, 0x0141 }, /*                     Lstroke Ł LATIN CAPITAL LETTER L WITH STROKE */
+  { 0x01a5, 0x013d }, /*                      Lcaron Ľ LATIN CAPITAL LETTER L WITH CARON */
+  { 0x01a6, 0x015a }, /*                      Sacute Ś LATIN CAPITAL LETTER S WITH ACUTE */
+  { 0x01a9, 0x0160 }, /*                      Scaron Š LATIN CAPITAL LETTER S WITH CARON */
+  { 0x01aa, 0x015e }, /*                    Scedilla Ş LATIN CAPITAL LETTER S WITH CEDILLA */
+  { 0x01ab, 0x0164 }, /*                      Tcaron Ť LATIN CAPITAL LETTER T WITH CARON */
+  { 0x01ac, 0x0179 }, /*                      Zacute Ź LATIN CAPITAL LETTER Z WITH ACUTE */
+  { 0x01ae, 0x017d }, /*                      Zcaron Ž LATIN CAPITAL LETTER Z WITH CARON */
+  { 0x01af, 0x017b }, /*                   Zabovedot Ż LATIN CAPITAL LETTER Z WITH DOT ABOVE */
+  { 0x01b1, 0x0105 }, /*                     aogonek ą LATIN SMALL LETTER A WITH OGONEK */
+  { 0x01b2, 0x02db }, /*                      ogonek ˛ OGONEK */
+  { 0x01b3, 0x0142 }, /*                     lstroke ł LATIN SMALL LETTER L WITH STROKE */
+  { 0x01b5, 0x013e }, /*                      lcaron ľ LATIN SMALL LETTER L WITH CARON */
+  { 0x01b6, 0x015b }, /*                      sacute ś LATIN SMALL LETTER S WITH ACUTE */
+  { 0x01b7, 0x02c7 }, /*                       caron ˇ CARON */
+  { 0x01b9, 0x0161 }, /*                      scaron š LATIN SMALL LETTER S WITH CARON */
+  { 0x01ba, 0x015f }, /*                    scedilla ş LATIN SMALL LETTER S WITH CEDILLA */
+  { 0x01bb, 0x0165 }, /*                      tcaron ť LATIN SMALL LETTER T WITH CARON */
+  { 0x01bc, 0x017a }, /*                      zacute ź LATIN SMALL LETTER Z WITH ACUTE */
+  { 0x01bd, 0x02dd }, /*                 doubleacute ˝ DOUBLE ACUTE ACCENT */
+  { 0x01be, 0x017e }, /*                      zcaron ž LATIN SMALL LETTER Z WITH CARON */
+  { 0x01bf, 0x017c }, /*                   zabovedot ż LATIN SMALL LETTER Z WITH DOT ABOVE */
+  { 0x01c0, 0x0154 }, /*                      Racute Ŕ LATIN CAPITAL LETTER R WITH ACUTE */
+  { 0x01c3, 0x0102 }, /*                      Abreve Ă LATIN CAPITAL LETTER A WITH BREVE */
+  { 0x01c5, 0x0139 }, /*                      Lacute Ĺ LATIN CAPITAL LETTER L WITH ACUTE */
+  { 0x01c6, 0x0106 }, /*                      Cacute Ć LATIN CAPITAL LETTER C WITH ACUTE */
+  { 0x01c8, 0x010c }, /*                      Ccaron Č LATIN CAPITAL LETTER C WITH CARON */
+  { 0x01ca, 0x0118 }, /*                     Eogonek Ę LATIN CAPITAL LETTER E WITH OGONEK */
+  { 0x01cc, 0x011a }, /*                      Ecaron Ě LATIN CAPITAL LETTER E WITH CARON */
+  { 0x01cf, 0x010e }, /*                      Dcaron Ď LATIN CAPITAL LETTER D WITH CARON */
+  { 0x01d0, 0x0110 }, /*                     Dstroke Đ LATIN CAPITAL LETTER D WITH STROKE */
+  { 0x01d1, 0x0143 }, /*                      Nacute Ń LATIN CAPITAL LETTER N WITH ACUTE */
+  { 0x01d2, 0x0147 }, /*                      Ncaron Ň LATIN CAPITAL LETTER N WITH CARON */
+  { 0x01d5, 0x0150 }, /*                Odoubleacute Ő LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */
+  { 0x01d8, 0x0158 }, /*                      Rcaron Ř LATIN CAPITAL LETTER R WITH CARON */
+  { 0x01d9, 0x016e }, /*                       Uring Ů LATIN CAPITAL LETTER U WITH RING ABOVE */
+  { 0x01db, 0x0170 }, /*                Udoubleacute Ű LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */
+  { 0x01de, 0x0162 }, /*                    Tcedilla Ţ LATIN CAPITAL LETTER T WITH CEDILLA */
+  { 0x01e0, 0x0155 }, /*                      racute ŕ LATIN SMALL LETTER R WITH ACUTE */
+  { 0x01e3, 0x0103 }, /*                      abreve ă LATIN SMALL LETTER A WITH BREVE */
+  { 0x01e5, 0x013a }, /*                      lacute ĺ LATIN SMALL LETTER L WITH ACUTE */
+  { 0x01e6, 0x0107 }, /*                      cacute ć LATIN SMALL LETTER C WITH ACUTE */
+  { 0x01e8, 0x010d }, /*                      ccaron č LATIN SMALL LETTER C WITH CARON */
+  { 0x01ea, 0x0119 }, /*                     eogonek ę LATIN SMALL LETTER E WITH OGONEK */
+  { 0x01ec, 0x011b }, /*                      ecaron ě LATIN SMALL LETTER E WITH CARON */
+  { 0x01ef, 0x010f }, /*                      dcaron ď LATIN SMALL LETTER D WITH CARON */
+  { 0x01f0, 0x0111 }, /*                     dstroke đ LATIN SMALL LETTER D WITH STROKE */
+  { 0x01f1, 0x0144 }, /*                      nacute ń LATIN SMALL LETTER N WITH ACUTE */
+  { 0x01f2, 0x0148 }, /*                      ncaron ň LATIN SMALL LETTER N WITH CARON */
+  { 0x01f5, 0x0151 }, /*                odoubleacute ő LATIN SMALL LETTER O WITH DOUBLE ACUTE */
+  { 0x01f8, 0x0159 }, /*                      rcaron ř LATIN SMALL LETTER R WITH CARON */
+  { 0x01f9, 0x016f }, /*                       uring ů LATIN SMALL LETTER U WITH RING ABOVE */
+  { 0x01fb, 0x0171 }, /*                udoubleacute ű LATIN SMALL LETTER U WITH DOUBLE ACUTE */
+  { 0x01fe, 0x0163 }, /*                    tcedilla ţ LATIN SMALL LETTER T WITH CEDILLA */
+  { 0x01ff, 0x02d9 }, /*                    abovedot ˙ DOT ABOVE */
+  { 0x02a1, 0x0126 }, /*                     Hstroke Ħ LATIN CAPITAL LETTER H WITH STROKE */
+  { 0x02a6, 0x0124 }, /*                 Hcircumflex Ĥ LATIN CAPITAL LETTER H WITH CIRCUMFLEX */
+  { 0x02a9, 0x0130 }, /*                   Iabovedot İ LATIN CAPITAL LETTER I WITH DOT ABOVE */
+  { 0x02ab, 0x011e }, /*                      Gbreve Ğ LATIN CAPITAL LETTER G WITH BREVE */
+  { 0x02ac, 0x0134 }, /*                 Jcircumflex Ĵ LATIN CAPITAL LETTER J WITH CIRCUMFLEX */
+  { 0x02b1, 0x0127 }, /*                     hstroke ħ LATIN SMALL LETTER H WITH STROKE */
+  { 0x02b6, 0x0125 }, /*                 hcircumflex ĥ LATIN SMALL LETTER H WITH CIRCUMFLEX */
+  { 0x02b9, 0x0131 }, /*                    idotless ı LATIN SMALL LETTER DOTLESS I */
+  { 0x02bb, 0x011f }, /*                      gbreve ğ LATIN SMALL LETTER G WITH BREVE */
+  { 0x02bc, 0x0135 }, /*                 jcircumflex ĵ LATIN SMALL LETTER J WITH CIRCUMFLEX */
+  { 0x02c5, 0x010a }, /*                   Cabovedot Ċ LATIN CAPITAL LETTER C WITH DOT ABOVE */
+  { 0x02c6, 0x0108 }, /*                 Ccircumflex Ĉ LATIN CAPITAL LETTER C WITH CIRCUMFLEX */
+  { 0x02d5, 0x0120 }, /*                   Gabovedot Ġ LATIN CAPITAL LETTER G WITH DOT ABOVE */
+  { 0x02d8, 0x011c }, /*                 Gcircumflex Ĝ LATIN CAPITAL LETTER G WITH CIRCUMFLEX */
+  { 0x02dd, 0x016c }, /*                      Ubreve Ŭ LATIN CAPITAL LETTER U WITH BREVE */
+  { 0x02de, 0x015c }, /*                 Scircumflex Ŝ LATIN CAPITAL LETTER S WITH CIRCUMFLEX */
+  { 0x02e5, 0x010b }, /*                   cabovedot ċ LATIN SMALL LETTER C WITH DOT ABOVE */
+  { 0x02e6, 0x0109 }, /*                 ccircumflex ĉ LATIN SMALL LETTER C WITH CIRCUMFLEX */
+  { 0x02f5, 0x0121 }, /*                   gabovedot ġ LATIN SMALL LETTER G WITH DOT ABOVE */
+  { 0x02f8, 0x011d }, /*                 gcircumflex ĝ LATIN SMALL LETTER G WITH CIRCUMFLEX */
+  { 0x02fd, 0x016d }, /*                      ubreve ŭ LATIN SMALL LETTER U WITH BREVE */
+  { 0x02fe, 0x015d }, /*                 scircumflex ŝ LATIN SMALL LETTER S WITH CIRCUMFLEX */
+  { 0x03a2, 0x0138 }, /*                         kra ĸ LATIN SMALL LETTER KRA */
+  { 0x03a3, 0x0156 }, /*                    Rcedilla Ŗ LATIN CAPITAL LETTER R WITH CEDILLA */
+  { 0x03a5, 0x0128 }, /*                      Itilde Ĩ LATIN CAPITAL LETTER I WITH TILDE */
+  { 0x03a6, 0x013b }, /*                    Lcedilla Ļ LATIN CAPITAL LETTER L WITH CEDILLA */
+  { 0x03aa, 0x0112 }, /*                     Emacron Ē LATIN CAPITAL LETTER E WITH MACRON */
+  { 0x03ab, 0x0122 }, /*                    Gcedilla Ģ LATIN CAPITAL LETTER G WITH CEDILLA */
+  { 0x03ac, 0x0166 }, /*                      Tslash Ŧ LATIN CAPITAL LETTER T WITH STROKE */
+  { 0x03b3, 0x0157 }, /*                    rcedilla ŗ LATIN SMALL LETTER R WITH CEDILLA */
+  { 0x03b5, 0x0129 }, /*                      itilde ĩ LATIN SMALL LETTER I WITH TILDE */
+  { 0x03b6, 0x013c }, /*                    lcedilla ļ LATIN SMALL LETTER L WITH CEDILLA */
+  { 0x03ba, 0x0113 }, /*                     emacron ē LATIN SMALL LETTER E WITH MACRON */
+  { 0x03bb, 0x0123 }, /*                    gcedilla ģ LATIN SMALL LETTER G WITH CEDILLA */
+  { 0x03bc, 0x0167 }, /*                      tslash ŧ LATIN SMALL LETTER T WITH STROKE */
+  { 0x03bd, 0x014a }, /*                         ENG Ŋ LATIN CAPITAL LETTER ENG */
+  { 0x03bf, 0x014b }, /*                         eng ŋ LATIN SMALL LETTER ENG */
+  { 0x03c0, 0x0100 }, /*                     Amacron Ā LATIN CAPITAL LETTER A WITH MACRON */
+  { 0x03c7, 0x012e }, /*                     Iogonek Į LATIN CAPITAL LETTER I WITH OGONEK */
+  { 0x03cc, 0x0116 }, /*                   Eabovedot Ė LATIN CAPITAL LETTER E WITH DOT ABOVE */
+  { 0x03cf, 0x012a }, /*                     Imacron Ī LATIN CAPITAL LETTER I WITH MACRON */
+  { 0x03d1, 0x0145 }, /*                    Ncedilla Ņ LATIN CAPITAL LETTER N WITH CEDILLA */
+  { 0x03d2, 0x014c }, /*                     Omacron Ō LATIN CAPITAL LETTER O WITH MACRON */
+  { 0x03d3, 0x0136 }, /*                    Kcedilla Ķ LATIN CAPITAL LETTER K WITH CEDILLA */
+  { 0x03d9, 0x0172 }, /*                     Uogonek Ų LATIN CAPITAL LETTER U WITH OGONEK */
+  { 0x03dd, 0x0168 }, /*                      Utilde Ũ LATIN CAPITAL LETTER U WITH TILDE */
+  { 0x03de, 0x016a }, /*                     Umacron Ū LATIN CAPITAL LETTER U WITH MACRON */
+  { 0x03e0, 0x0101 }, /*                     amacron ā LATIN SMALL LETTER A WITH MACRON */
+  { 0x03e7, 0x012f }, /*                     iogonek į LATIN SMALL LETTER I WITH OGONEK */
+  { 0x03ec, 0x0117 }, /*                   eabovedot ė LATIN SMALL LETTER E WITH DOT ABOVE */
+  { 0x03ef, 0x012b }, /*                     imacron ī LATIN SMALL LETTER I WITH MACRON */
+  { 0x03f1, 0x0146 }, /*                    ncedilla ņ LATIN SMALL LETTER N WITH CEDILLA */
+  { 0x03f2, 0x014d }, /*                     omacron ō LATIN SMALL LETTER O WITH MACRON */
+  { 0x03f3, 0x0137 }, /*                    kcedilla ķ LATIN SMALL LETTER K WITH CEDILLA */
+  { 0x03f9, 0x0173 }, /*                     uogonek ų LATIN SMALL LETTER U WITH OGONEK */
+  { 0x03fd, 0x0169 }, /*                      utilde ũ LATIN SMALL LETTER U WITH TILDE */
+  { 0x03fe, 0x016b }, /*                     umacron ū LATIN SMALL LETTER U WITH MACRON */
+  { 0x047e, 0x203e }, /*                    overline ‾ OVERLINE */
+  { 0x04a1, 0x3002 }, /*               kana_fullstop 。 IDEOGRAPHIC FULL STOP */
+  { 0x04a2, 0x300c }, /*         kana_openingbracket 「 LEFT CORNER BRACKET */
+  { 0x04a3, 0x300d }, /*         kana_closingbracket 」 RIGHT CORNER BRACKET */
+  { 0x04a4, 0x3001 }, /*                  kana_comma 、 IDEOGRAPHIC COMMA */
+  { 0x04a5, 0x30fb }, /*            kana_conjunctive ・ KATAKANA MIDDLE DOT */
+  { 0x04a6, 0x30f2 }, /*                     kana_WO ヲ KATAKANA LETTER WO */
+  { 0x04a7, 0x30a1 }, /*                      kana_a ァ KATAKANA LETTER SMALL A */
+  { 0x04a8, 0x30a3 }, /*                      kana_i ィ KATAKANA LETTER SMALL I */
+  { 0x04a9, 0x30a5 }, /*                      kana_u ゥ KATAKANA LETTER SMALL U */
+  { 0x04aa, 0x30a7 }, /*                      kana_e ェ KATAKANA LETTER SMALL E */
+  { 0x04ab, 0x30a9 }, /*                      kana_o ォ KATAKANA LETTER SMALL O */
+  { 0x04ac, 0x30e3 }, /*                     kana_ya ャ KATAKANA LETTER SMALL YA */
+  { 0x04ad, 0x30e5 }, /*                     kana_yu ュ KATAKANA LETTER SMALL YU */
+  { 0x04ae, 0x30e7 }, /*                     kana_yo ョ KATAKANA LETTER SMALL YO */
+  { 0x04af, 0x30c3 }, /*                    kana_tsu ッ KATAKANA LETTER SMALL TU */
+  { 0x04b0, 0x30fc }, /*              prolongedsound ー KATAKANA-HIRAGANA PROLONGED SOUND MARK */
+  { 0x04b1, 0x30a2 }, /*                      kana_A ア KATAKANA LETTER A */
+  { 0x04b2, 0x30a4 }, /*                      kana_I イ KATAKANA LETTER I */
+  { 0x04b3, 0x30a6 }, /*                      kana_U ウ KATAKANA LETTER U */
+  { 0x04b4, 0x30a8 }, /*                      kana_E エ KATAKANA LETTER E */
+  { 0x04b5, 0x30aa }, /*                      kana_O オ KATAKANA LETTER O */
+  { 0x04b6, 0x30ab }, /*                     kana_KA カ KATAKANA LETTER KA */
+  { 0x04b7, 0x30ad }, /*                     kana_KI キ KATAKANA LETTER KI */
+  { 0x04b8, 0x30af }, /*                     kana_KU ク KATAKANA LETTER KU */
+  { 0x04b9, 0x30b1 }, /*                     kana_KE ケ KATAKANA LETTER KE */
+  { 0x04ba, 0x30b3 }, /*                     kana_KO コ KATAKANA LETTER KO */
+  { 0x04bb, 0x30b5 }, /*                     kana_SA サ KATAKANA LETTER SA */
+  { 0x04bc, 0x30b7 }, /*                    kana_SHI シ KATAKANA LETTER SI */
+  { 0x04bd, 0x30b9 }, /*                     kana_SU ス KATAKANA LETTER SU */
+  { 0x04be, 0x30bb }, /*                     kana_SE セ KATAKANA LETTER SE */
+  { 0x04bf, 0x30bd }, /*                     kana_SO ソ KATAKANA LETTER SO */
+  { 0x04c0, 0x30bf }, /*                     kana_TA タ KATAKANA LETTER TA */
+  { 0x04c1, 0x30c1 }, /*                    kana_CHI チ KATAKANA LETTER TI */
+  { 0x04c2, 0x30c4 }, /*                    kana_TSU ツ KATAKANA LETTER TU */
+  { 0x04c3, 0x30c6 }, /*                     kana_TE テ KATAKANA LETTER TE */
+  { 0x04c4, 0x30c8 }, /*                     kana_TO ト KATAKANA LETTER TO */
+  { 0x04c5, 0x30ca }, /*                     kana_NA ナ KATAKANA LETTER NA */
+  { 0x04c6, 0x30cb }, /*                     kana_NI ニ KATAKANA LETTER NI */
+  { 0x04c7, 0x30cc }, /*                     kana_NU ヌ KATAKANA LETTER NU */
+  { 0x04c8, 0x30cd }, /*                     kana_NE ネ KATAKANA LETTER NE */
+  { 0x04c9, 0x30ce }, /*                     kana_NO ノ KATAKANA LETTER NO */
+  { 0x04ca, 0x30cf }, /*                     kana_HA ハ KATAKANA LETTER HA */
+  { 0x04cb, 0x30d2 }, /*                     kana_HI ヒ KATAKANA LETTER HI */
+  { 0x04cc, 0x30d5 }, /*                     kana_FU フ KATAKANA LETTER HU */
+  { 0x04cd, 0x30d8 }, /*                     kana_HE ヘ KATAKANA LETTER HE */
+  { 0x04ce, 0x30db }, /*                     kana_HO ホ KATAKANA LETTER HO */
+  { 0x04cf, 0x30de }, /*                     kana_MA マ KATAKANA LETTER MA */
+  { 0x04d0, 0x30df }, /*                     kana_MI ミ KATAKANA LETTER MI */
+  { 0x04d1, 0x30e0 }, /*                     kana_MU ム KATAKANA LETTER MU */
+  { 0x04d2, 0x30e1 }, /*                     kana_ME メ KATAKANA LETTER ME */
+  { 0x04d3, 0x30e2 }, /*                     kana_MO モ KATAKANA LETTER MO */
+  { 0x04d4, 0x30e4 }, /*                     kana_YA ヤ KATAKANA LETTER YA */
+  { 0x04d5, 0x30e6 }, /*                     kana_YU ユ KATAKANA LETTER YU */
+  { 0x04d6, 0x30e8 }, /*                     kana_YO ヨ KATAKANA LETTER YO */
+  { 0x04d7, 0x30e9 }, /*                     kana_RA ラ KATAKANA LETTER RA */
+  { 0x04d8, 0x30ea }, /*                     kana_RI リ KATAKANA LETTER RI */
+  { 0x04d9, 0x30eb }, /*                     kana_RU ル KATAKANA LETTER RU */
+  { 0x04da, 0x30ec }, /*                     kana_RE レ KATAKANA LETTER RE */
+  { 0x04db, 0x30ed }, /*                     kana_RO ロ KATAKANA LETTER RO */
+  { 0x04dc, 0x30ef }, /*                     kana_WA ワ KATAKANA LETTER WA */
+  { 0x04dd, 0x30f3 }, /*                      kana_N ン KATAKANA LETTER N */
+  { 0x04de, 0x309b }, /*                 voicedsound ゛ KATAKANA-HIRAGANA VOICED SOUND MARK */
+  { 0x04df, 0x309c }, /*             semivoicedsound ゜ KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */
+  { 0x05ac, 0x060c }, /*                Arabic_comma ، ARABIC COMMA */
+  { 0x05bb, 0x061b }, /*            Arabic_semicolon ؛ ARABIC SEMICOLON */
+  { 0x05bf, 0x061f }, /*        Arabic_question_mark ؟ ARABIC QUESTION MARK */
+  { 0x05c1, 0x0621 }, /*                Arabic_hamza ء ARABIC LETTER HAMZA */
+  { 0x05c2, 0x0622 }, /*          Arabic_maddaonalef آ ARABIC LETTER ALEF WITH MADDA ABOVE */
+  { 0x05c3, 0x0623 }, /*          Arabic_hamzaonalef أ ARABIC LETTER ALEF WITH HAMZA ABOVE */
+  { 0x05c4, 0x0624 }, /*           Arabic_hamzaonwaw ؤ ARABIC LETTER WAW WITH HAMZA ABOVE */
+  { 0x05c5, 0x0625 }, /*       Arabic_hamzaunderalef إ ARABIC LETTER ALEF WITH HAMZA BELOW */
+  { 0x05c6, 0x0626 }, /*           Arabic_hamzaonyeh ئ ARABIC LETTER YEH WITH HAMZA ABOVE */
+  { 0x05c7, 0x0627 }, /*                 Arabic_alef ا ARABIC LETTER ALEF */
+  { 0x05c8, 0x0628 }, /*                  Arabic_beh ب ARABIC LETTER BEH */
+  { 0x05c9, 0x0629 }, /*           Arabic_tehmarbuta ة ARABIC LETTER TEH MARBUTA */
+  { 0x05ca, 0x062a }, /*                  Arabic_teh ت ARABIC LETTER TEH */
+  { 0x05cb, 0x062b }, /*                 Arabic_theh ث ARABIC LETTER THEH */
+  { 0x05cc, 0x062c }, /*                 Arabic_jeem ج ARABIC LETTER JEEM */
+  { 0x05cd, 0x062d }, /*                  Arabic_hah ح ARABIC LETTER HAH */
+  { 0x05ce, 0x062e }, /*                 Arabic_khah خ ARABIC LETTER KHAH */
+  { 0x05cf, 0x062f }, /*                  Arabic_dal د ARABIC LETTER DAL */
+  { 0x05d0, 0x0630 }, /*                 Arabic_thal ذ ARABIC LETTER THAL */
+  { 0x05d1, 0x0631 }, /*                   Arabic_ra ر ARABIC LETTER REH */
+  { 0x05d2, 0x0632 }, /*                 Arabic_zain ز ARABIC LETTER ZAIN */
+  { 0x05d3, 0x0633 }, /*                 Arabic_seen س ARABIC LETTER SEEN */
+  { 0x05d4, 0x0634 }, /*                Arabic_sheen ش ARABIC LETTER SHEEN */
+  { 0x05d5, 0x0635 }, /*                  Arabic_sad ص ARABIC LETTER SAD */
+  { 0x05d6, 0x0636 }, /*                  Arabic_dad ض ARABIC LETTER DAD */
+  { 0x05d7, 0x0637 }, /*                  Arabic_tah ط ARABIC LETTER TAH */
+  { 0x05d8, 0x0638 }, /*                  Arabic_zah ظ ARABIC LETTER ZAH */
+  { 0x05d9, 0x0639 }, /*                  Arabic_ain ع ARABIC LETTER AIN */
+  { 0x05da, 0x063a }, /*                Arabic_ghain غ ARABIC LETTER GHAIN */
+  { 0x05e0, 0x0640 }, /*              Arabic_tatweel ـ ARABIC TATWEEL */
+  { 0x05e1, 0x0641 }, /*                  Arabic_feh ف ARABIC LETTER FEH */
+  { 0x05e2, 0x0642 }, /*                  Arabic_qaf ق ARABIC LETTER QAF */
+  { 0x05e3, 0x0643 }, /*                  Arabic_kaf ك ARABIC LETTER KAF */
+  { 0x05e4, 0x0644 }, /*                  Arabic_lam ل ARABIC LETTER LAM */
+  { 0x05e5, 0x0645 }, /*                 Arabic_meem م ARABIC LETTER MEEM */
+  { 0x05e6, 0x0646 }, /*                 Arabic_noon ن ARABIC LETTER NOON */
+  { 0x05e7, 0x0647 }, /*                   Arabic_ha ه ARABIC LETTER HEH */
+  { 0x05e8, 0x0648 }, /*                  Arabic_waw و ARABIC LETTER WAW */
+  { 0x05e9, 0x0649 }, /*          Arabic_alefmaksura ى ARABIC LETTER ALEF MAKSURA */
+  { 0x05ea, 0x064a }, /*                  Arabic_yeh ي ARABIC LETTER YEH */
+  { 0x05eb, 0x064b }, /*             Arabic_fathatan ً ARABIC FATHATAN */
+  { 0x05ec, 0x064c }, /*             Arabic_dammatan ٌ ARABIC DAMMATAN */
+  { 0x05ed, 0x064d }, /*             Arabic_kasratan ٍ ARABIC KASRATAN */
+  { 0x05ee, 0x064e }, /*                Arabic_fatha َ ARABIC FATHA */
+  { 0x05ef, 0x064f }, /*                Arabic_damma ُ ARABIC DAMMA */
+  { 0x05f0, 0x0650 }, /*                Arabic_kasra ِ ARABIC KASRA */
+  { 0x05f1, 0x0651 }, /*               Arabic_shadda ّ ARABIC SHADDA */
+  { 0x05f2, 0x0652 }, /*                Arabic_sukun ْ ARABIC SUKUN */
+  { 0x06a1, 0x0452 }, /*                 Serbian_dje ђ CYRILLIC SMALL LETTER DJE */
+  { 0x06a2, 0x0453 }, /*               Macedonia_gje ѓ CYRILLIC SMALL LETTER GJE */
+  { 0x06a3, 0x0451 }, /*                 Cyrillic_io ё CYRILLIC SMALL LETTER IO */
+  { 0x06a4, 0x0454 }, /*                Ukrainian_ie є CYRILLIC SMALL LETTER UKRAINIAN IE */
+  { 0x06a5, 0x0455 }, /*               Macedonia_dse ѕ CYRILLIC SMALL LETTER DZE */
+  { 0x06a6, 0x0456 }, /*                 Ukrainian_i і CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */
+  { 0x06a7, 0x0457 }, /*                Ukrainian_yi ї CYRILLIC SMALL LETTER YI */
+  { 0x06a8, 0x0458 }, /*                 Cyrillic_je ј CYRILLIC SMALL LETTER JE */
+  { 0x06a9, 0x0459 }, /*                Cyrillic_lje љ CYRILLIC SMALL LETTER LJE */
+  { 0x06aa, 0x045a }, /*                Cyrillic_nje њ CYRILLIC SMALL LETTER NJE */
+  { 0x06ab, 0x045b }, /*                Serbian_tshe ћ CYRILLIC SMALL LETTER TSHE */
+  { 0x06ac, 0x045c }, /*               Macedonia_kje ќ CYRILLIC SMALL LETTER KJE */
+  { 0x06ad, 0x0491 }, /*   Ukrainian_ghe_with_upturn ґ CYRILLIC SMALL LETTER GHE WITH UPTURN */
+  { 0x06ae, 0x045e }, /*         Byelorussian_shortu ў CYRILLIC SMALL LETTER SHORT U */
+  { 0x06af, 0x045f }, /*               Cyrillic_dzhe џ CYRILLIC SMALL LETTER DZHE */
+  { 0x06b0, 0x2116 }, /*                  numerosign № NUMERO SIGN */
+  { 0x06b1, 0x0402 }, /*                 Serbian_DJE Ђ CYRILLIC CAPITAL LETTER DJE */
+  { 0x06b2, 0x0403 }, /*               Macedonia_GJE Ѓ CYRILLIC CAPITAL LETTER GJE */
+  { 0x06b3, 0x0401 }, /*                 Cyrillic_IO Ё CYRILLIC CAPITAL LETTER IO */
+  { 0x06b4, 0x0404 }, /*                Ukrainian_IE Є CYRILLIC CAPITAL LETTER UKRAINIAN IE */
+  { 0x06b5, 0x0405 }, /*               Macedonia_DSE Ѕ CYRILLIC CAPITAL LETTER DZE */
+  { 0x06b6, 0x0406 }, /*                 Ukrainian_I І CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */
+  { 0x06b7, 0x0407 }, /*                Ukrainian_YI Ї CYRILLIC CAPITAL LETTER YI */
+  { 0x06b8, 0x0408 }, /*                 Cyrillic_JE Ј CYRILLIC CAPITAL LETTER JE */
+  { 0x06b9, 0x0409 }, /*                Cyrillic_LJE Љ CYRILLIC CAPITAL LETTER LJE */
+  { 0x06ba, 0x040a }, /*                Cyrillic_NJE Њ CYRILLIC CAPITAL LETTER NJE */
+  { 0x06bb, 0x040b }, /*                Serbian_TSHE Ћ CYRILLIC CAPITAL LETTER TSHE */
+  { 0x06bc, 0x040c }, /*               Macedonia_KJE Ќ CYRILLIC CAPITAL LETTER KJE */
+  { 0x06bd, 0x0490 }, /*   Ukrainian_GHE_WITH_UPTURN Ґ CYRILLIC CAPITAL LETTER GHE WITH UPTURN */
+  { 0x06be, 0x040e }, /*         Byelorussian_SHORTU Ў CYRILLIC CAPITAL LETTER SHORT U */
+  { 0x06bf, 0x040f }, /*               Cyrillic_DZHE Џ CYRILLIC CAPITAL LETTER DZHE */
+  { 0x06c0, 0x044e }, /*                 Cyrillic_yu ю CYRILLIC SMALL LETTER YU */
+  { 0x06c1, 0x0430 }, /*                  Cyrillic_a а CYRILLIC SMALL LETTER A */
+  { 0x06c2, 0x0431 }, /*                 Cyrillic_be б CYRILLIC SMALL LETTER BE */
+  { 0x06c3, 0x0446 }, /*                Cyrillic_tse ц CYRILLIC SMALL LETTER TSE */
+  { 0x06c4, 0x0434 }, /*                 Cyrillic_de д CYRILLIC SMALL LETTER DE */
+  { 0x06c5, 0x0435 }, /*                 Cyrillic_ie е CYRILLIC SMALL LETTER IE */
+  { 0x06c6, 0x0444 }, /*                 Cyrillic_ef ф CYRILLIC SMALL LETTER EF */
+  { 0x06c7, 0x0433 }, /*                Cyrillic_ghe г CYRILLIC SMALL LETTER GHE */
+  { 0x06c8, 0x0445 }, /*                 Cyrillic_ha х CYRILLIC SMALL LETTER HA */
+  { 0x06c9, 0x0438 }, /*                  Cyrillic_i и CYRILLIC SMALL LETTER I */
+  { 0x06ca, 0x0439 }, /*             Cyrillic_shorti й CYRILLIC SMALL LETTER SHORT I */
+  { 0x06cb, 0x043a }, /*                 Cyrillic_ka к CYRILLIC SMALL LETTER KA */
+  { 0x06cc, 0x043b }, /*                 Cyrillic_el л CYRILLIC SMALL LETTER EL */
+  { 0x06cd, 0x043c }, /*                 Cyrillic_em м CYRILLIC SMALL LETTER EM */
+  { 0x06ce, 0x043d }, /*                 Cyrillic_en н CYRILLIC SMALL LETTER EN */
+  { 0x06cf, 0x043e }, /*                  Cyrillic_o о CYRILLIC SMALL LETTER O */
+  { 0x06d0, 0x043f }, /*                 Cyrillic_pe п CYRILLIC SMALL LETTER PE */
+  { 0x06d1, 0x044f }, /*                 Cyrillic_ya я CYRILLIC SMALL LETTER YA */
+  { 0x06d2, 0x0440 }, /*                 Cyrillic_er р CYRILLIC SMALL LETTER ER */
+  { 0x06d3, 0x0441 }, /*                 Cyrillic_es с CYRILLIC SMALL LETTER ES */
+  { 0x06d4, 0x0442 }, /*                 Cyrillic_te т CYRILLIC SMALL LETTER TE */
+  { 0x06d5, 0x0443 }, /*                  Cyrillic_u у CYRILLIC SMALL LETTER U */
+  { 0x06d6, 0x0436 }, /*                Cyrillic_zhe ж CYRILLIC SMALL LETTER ZHE */
+  { 0x06d7, 0x0432 }, /*                 Cyrillic_ve в CYRILLIC SMALL LETTER VE */
+  { 0x06d8, 0x044c }, /*           Cyrillic_softsign ь CYRILLIC SMALL LETTER SOFT SIGN */
+  { 0x06d9, 0x044b }, /*               Cyrillic_yeru ы CYRILLIC SMALL LETTER YERU */
+  { 0x06da, 0x0437 }, /*                 Cyrillic_ze з CYRILLIC SMALL LETTER ZE */
+  { 0x06db, 0x0448 }, /*                Cyrillic_sha ш CYRILLIC SMALL LETTER SHA */
+  { 0x06dc, 0x044d }, /*                  Cyrillic_e э CYRILLIC SMALL LETTER E */
+  { 0x06dd, 0x0449 }, /*              Cyrillic_shcha щ CYRILLIC SMALL LETTER SHCHA */
+  { 0x06de, 0x0447 }, /*                Cyrillic_che ч CYRILLIC SMALL LETTER CHE */
+  { 0x06df, 0x044a }, /*           Cyrillic_hardsign ъ CYRILLIC SMALL LETTER HARD SIGN */
+  { 0x06e0, 0x042e }, /*                 Cyrillic_YU Ю CYRILLIC CAPITAL LETTER YU */
+  { 0x06e1, 0x0410 }, /*                  Cyrillic_A А CYRILLIC CAPITAL LETTER A */
+  { 0x06e2, 0x0411 }, /*                 Cyrillic_BE Б CYRILLIC CAPITAL LETTER BE */
+  { 0x06e3, 0x0426 }, /*                Cyrillic_TSE Ц CYRILLIC CAPITAL LETTER TSE */
+  { 0x06e4, 0x0414 }, /*                 Cyrillic_DE Д CYRILLIC CAPITAL LETTER DE */
+  { 0x06e5, 0x0415 }, /*                 Cyrillic_IE Е CYRILLIC CAPITAL LETTER IE */
+  { 0x06e6, 0x0424 }, /*                 Cyrillic_EF Ф CYRILLIC CAPITAL LETTER EF */
+  { 0x06e7, 0x0413 }, /*                Cyrillic_GHE Г CYRILLIC CAPITAL LETTER GHE */
+  { 0x06e8, 0x0425 }, /*                 Cyrillic_HA Х CYRILLIC CAPITAL LETTER HA */
+  { 0x06e9, 0x0418 }, /*                  Cyrillic_I И CYRILLIC CAPITAL LETTER I */
+  { 0x06ea, 0x0419 }, /*             Cyrillic_SHORTI Й CYRILLIC CAPITAL LETTER SHORT I */
+  { 0x06eb, 0x041a }, /*                 Cyrillic_KA К CYRILLIC CAPITAL LETTER KA */
+  { 0x06ec, 0x041b }, /*                 Cyrillic_EL Л CYRILLIC CAPITAL LETTER EL */
+  { 0x06ed, 0x041c }, /*                 Cyrillic_EM М CYRILLIC CAPITAL LETTER EM */
+  { 0x06ee, 0x041d }, /*                 Cyrillic_EN Н CYRILLIC CAPITAL LETTER EN */
+  { 0x06ef, 0x041e }, /*                  Cyrillic_O О CYRILLIC CAPITAL LETTER O */
+  { 0x06f0, 0x041f }, /*                 Cyrillic_PE П CYRILLIC CAPITAL LETTER PE */
+  { 0x06f1, 0x042f }, /*                 Cyrillic_YA Я CYRILLIC CAPITAL LETTER YA */
+  { 0x06f2, 0x0420 }, /*                 Cyrillic_ER Р CYRILLIC CAPITAL LETTER ER */
+  { 0x06f3, 0x0421 }, /*                 Cyrillic_ES С CYRILLIC CAPITAL LETTER ES */
+  { 0x06f4, 0x0422 }, /*                 Cyrillic_TE Т CYRILLIC CAPITAL LETTER TE */
+  { 0x06f5, 0x0423 }, /*                  Cyrillic_U У CYRILLIC CAPITAL LETTER U */
+  { 0x06f6, 0x0416 }, /*                Cyrillic_ZHE Ж CYRILLIC CAPITAL LETTER ZHE */
+  { 0x06f7, 0x0412 }, /*                 Cyrillic_VE В CYRILLIC CAPITAL LETTER VE */
+  { 0x06f8, 0x042c }, /*           Cyrillic_SOFTSIGN Ь CYRILLIC CAPITAL LETTER SOFT SIGN */
+  { 0x06f9, 0x042b }, /*               Cyrillic_YERU Ы CYRILLIC CAPITAL LETTER YERU */
+  { 0x06fa, 0x0417 }, /*                 Cyrillic_ZE З CYRILLIC CAPITAL LETTER ZE */
+  { 0x06fb, 0x0428 }, /*                Cyrillic_SHA Ш CYRILLIC CAPITAL LETTER SHA */
+  { 0x06fc, 0x042d }, /*                  Cyrillic_E Э CYRILLIC CAPITAL LETTER E */
+  { 0x06fd, 0x0429 }, /*              Cyrillic_SHCHA Щ CYRILLIC CAPITAL LETTER SHCHA */
+  { 0x06fe, 0x0427 }, /*                Cyrillic_CHE Ч CYRILLIC CAPITAL LETTER CHE */
+  { 0x06ff, 0x042a }, /*           Cyrillic_HARDSIGN Ъ CYRILLIC CAPITAL LETTER HARD SIGN */
+  { 0x07a1, 0x0386 }, /*           Greek_ALPHAaccent Ά GREEK CAPITAL LETTER ALPHA WITH TONOS */
+  { 0x07a2, 0x0388 }, /*         Greek_EPSILONaccent Έ GREEK CAPITAL LETTER EPSILON WITH TONOS */
+  { 0x07a3, 0x0389 }, /*             Greek_ETAaccent Ή GREEK CAPITAL LETTER ETA WITH TONOS */
+  { 0x07a4, 0x038a }, /*            Greek_IOTAaccent Ί GREEK CAPITAL LETTER IOTA WITH TONOS */
+  { 0x07a5, 0x03aa }, /*         Greek_IOTAdiaeresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
+  { 0x07a7, 0x038c }, /*         Greek_OMICRONaccent Ό GREEK CAPITAL LETTER OMICRON WITH TONOS */
+  { 0x07a8, 0x038e }, /*         Greek_UPSILONaccent Ύ GREEK CAPITAL LETTER UPSILON WITH TONOS */
+  { 0x07a9, 0x03ab }, /*       Greek_UPSILONdieresis Ϋ GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */
+  { 0x07ab, 0x038f }, /*           Greek_OMEGAaccent Ώ GREEK CAPITAL LETTER OMEGA WITH TONOS */
+  { 0x07ae, 0x0385 }, /*        Greek_accentdieresis ΅ GREEK DIALYTIKA TONOS */
+  { 0x07af, 0x2015 }, /*              Greek_horizbar ― HORIZONTAL BAR */
+  { 0x07b1, 0x03ac }, /*           Greek_alphaaccent ά GREEK SMALL LETTER ALPHA WITH TONOS */
+  { 0x07b2, 0x03ad }, /*         Greek_epsilonaccent έ GREEK SMALL LETTER EPSILON WITH TONOS */
+  { 0x07b3, 0x03ae }, /*             Greek_etaaccent ή GREEK SMALL LETTER ETA WITH TONOS */
+  { 0x07b4, 0x03af }, /*            Greek_iotaaccent ί GREEK SMALL LETTER IOTA WITH TONOS */
+  { 0x07b5, 0x03ca }, /*          Greek_iotadieresis ϊ GREEK SMALL LETTER IOTA WITH DIALYTIKA */
+  { 0x07b6, 0x0390 }, /*    Greek_iotaaccentdieresis ΐ GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */
+  { 0x07b7, 0x03cc }, /*         Greek_omicronaccent ό GREEK SMALL LETTER OMICRON WITH TONOS */
+  { 0x07b8, 0x03cd }, /*         Greek_upsilonaccent ύ GREEK SMALL LETTER UPSILON WITH TONOS */
+  { 0x07b9, 0x03cb }, /*       Greek_upsilondieresis ϋ GREEK SMALL LETTER UPSILON WITH DIALYTIKA */
+  { 0x07ba, 0x03b0 }, /* Greek_upsilonaccentdieresis ΰ GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */
+  { 0x07bb, 0x03ce }, /*           Greek_omegaaccent ώ GREEK SMALL LETTER OMEGA WITH TONOS */
+  { 0x07c1, 0x0391 }, /*                 Greek_ALPHA Α GREEK CAPITAL LETTER ALPHA */
+  { 0x07c2, 0x0392 }, /*                  Greek_BETA Β GREEK CAPITAL LETTER BETA */
+  { 0x07c3, 0x0393 }, /*                 Greek_GAMMA Γ GREEK CAPITAL LETTER GAMMA */
+  { 0x07c4, 0x0394 }, /*                 Greek_DELTA Δ GREEK CAPITAL LETTER DELTA */
+  { 0x07c5, 0x0395 }, /*               Greek_EPSILON Ε GREEK CAPITAL LETTER EPSILON */
+  { 0x07c6, 0x0396 }, /*                  Greek_ZETA Ζ GREEK CAPITAL LETTER ZETA */
+  { 0x07c7, 0x0397 }, /*                   Greek_ETA Η GREEK CAPITAL LETTER ETA */
+  { 0x07c8, 0x0398 }, /*                 Greek_THETA Θ GREEK CAPITAL LETTER THETA */
+  { 0x07c9, 0x0399 }, /*                  Greek_IOTA Ι GREEK CAPITAL LETTER IOTA */
+  { 0x07ca, 0x039a }, /*                 Greek_KAPPA Κ GREEK CAPITAL LETTER KAPPA */
+  { 0x07cb, 0x039b }, /*                Greek_LAMBDA Λ GREEK CAPITAL LETTER LAMDA */
+  { 0x07cc, 0x039c }, /*                    Greek_MU Μ GREEK CAPITAL LETTER MU */
+  { 0x07cd, 0x039d }, /*                    Greek_NU Ν GREEK CAPITAL LETTER NU */
+  { 0x07ce, 0x039e }, /*                    Greek_XI Ξ GREEK CAPITAL LETTER XI */
+  { 0x07cf, 0x039f }, /*               Greek_OMICRON Ο GREEK CAPITAL LETTER OMICRON */
+  { 0x07d0, 0x03a0 }, /*                    Greek_PI Π GREEK CAPITAL LETTER PI */
+  { 0x07d1, 0x03a1 }, /*                   Greek_RHO Ρ GREEK CAPITAL LETTER RHO */
+  { 0x07d2, 0x03a3 }, /*                 Greek_SIGMA Σ GREEK CAPITAL LETTER SIGMA */
+  { 0x07d4, 0x03a4 }, /*                   Greek_TAU Τ GREEK CAPITAL LETTER TAU */
+  { 0x07d5, 0x03a5 }, /*               Greek_UPSILON Υ GREEK CAPITAL LETTER UPSILON */
+  { 0x07d6, 0x03a6 }, /*                   Greek_PHI Φ GREEK CAPITAL LETTER PHI */
+  { 0x07d7, 0x03a7 }, /*                   Greek_CHI Χ GREEK CAPITAL LETTER CHI */
+  { 0x07d8, 0x03a8 }, /*                   Greek_PSI Ψ GREEK CAPITAL LETTER PSI */
+  { 0x07d9, 0x03a9 }, /*                 Greek_OMEGA Ω GREEK CAPITAL LETTER OMEGA */
+  { 0x07e1, 0x03b1 }, /*                 Greek_alpha α GREEK SMALL LETTER ALPHA */
+  { 0x07e2, 0x03b2 }, /*                  Greek_beta β GREEK SMALL LETTER BETA */
+  { 0x07e3, 0x03b3 }, /*                 Greek_gamma γ GREEK SMALL LETTER GAMMA */
+  { 0x07e4, 0x03b4 }, /*                 Greek_delta δ GREEK SMALL LETTER DELTA */
+  { 0x07e5, 0x03b5 }, /*               Greek_epsilon ε GREEK SMALL LETTER EPSILON */
+  { 0x07e6, 0x03b6 }, /*                  Greek_zeta ζ GREEK SMALL LETTER ZETA */
+  { 0x07e7, 0x03b7 }, /*                   Greek_eta η GREEK SMALL LETTER ETA */
+  { 0x07e8, 0x03b8 }, /*                 Greek_theta θ GREEK SMALL LETTER THETA */
+  { 0x07e9, 0x03b9 }, /*                  Greek_iota ι GREEK SMALL LETTER IOTA */
+  { 0x07ea, 0x03ba }, /*                 Greek_kappa κ GREEK SMALL LETTER KAPPA */
+  { 0x07eb, 0x03bb }, /*                Greek_lambda λ GREEK SMALL LETTER LAMDA */
+  { 0x07ec, 0x03bc }, /*                    Greek_mu μ GREEK SMALL LETTER MU */
+  { 0x07ed, 0x03bd }, /*                    Greek_nu ν GREEK SMALL LETTER NU */
+  { 0x07ee, 0x03be }, /*                    Greek_xi ξ GREEK SMALL LETTER XI */
+  { 0x07ef, 0x03bf }, /*               Greek_omicron ο GREEK SMALL LETTER OMICRON */
+  { 0x07f0, 0x03c0 }, /*                    Greek_pi π GREEK SMALL LETTER PI */
+  { 0x07f1, 0x03c1 }, /*                   Greek_rho ρ GREEK SMALL LETTER RHO */
+  { 0x07f2, 0x03c3 }, /*                 Greek_sigma σ GREEK SMALL LETTER SIGMA */
+  { 0x07f3, 0x03c2 }, /*       Greek_finalsmallsigma ς GREEK SMALL LETTER FINAL SIGMA */
+  { 0x07f4, 0x03c4 }, /*                   Greek_tau τ GREEK SMALL LETTER TAU */
+  { 0x07f5, 0x03c5 }, /*               Greek_upsilon υ GREEK SMALL LETTER UPSILON */
+  { 0x07f6, 0x03c6 }, /*                   Greek_phi φ GREEK SMALL LETTER PHI */
+  { 0x07f7, 0x03c7 }, /*                   Greek_chi χ GREEK SMALL LETTER CHI */
+  { 0x07f8, 0x03c8 }, /*                   Greek_psi ψ GREEK SMALL LETTER PSI */
+  { 0x07f9, 0x03c9 }, /*                 Greek_omega ω GREEK SMALL LETTER OMEGA */
+  { 0x08a1, 0x23b7 }, /*                 leftradical ⎷ RADICAL SYMBOL BOTTOM */
+  { 0x08a2, 0x250c }, /*              topleftradical ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */
+  { 0x08a3, 0x2500 }, /*              horizconnector ─ BOX DRAWINGS LIGHT HORIZONTAL */
+  { 0x08a4, 0x2320 }, /*                 topintegral ⌠ TOP HALF INTEGRAL */
+  { 0x08a5, 0x2321 }, /*                 botintegral ⌡ BOTTOM HALF INTEGRAL */
+  { 0x08a6, 0x2502 }, /*               vertconnector │ BOX DRAWINGS LIGHT VERTICAL */
+  { 0x08a7, 0x23a1 }, /*            topleftsqbracket ⎡ LEFT SQUARE BRACKET UPPER CORNER */
+  { 0x08a8, 0x23a3 }, /*            botleftsqbracket ⎣ LEFT SQUARE BRACKET LOWER CORNER */
+  { 0x08a9, 0x23a4 }, /*           toprightsqbracket ⎤ RIGHT SQUARE BRACKET UPPER CORNER */
+  { 0x08aa, 0x23a6 }, /*           botrightsqbracket ⎦ RIGHT SQUARE BRACKET LOWER CORNER */
+  { 0x08ab, 0x239b }, /*               topleftparens ⎛ LEFT PARENTHESIS UPPER HOOK */
+  { 0x08ac, 0x239d }, /*               botleftparens ⎝ LEFT PARENTHESIS LOWER HOOK */
+  { 0x08ad, 0x239e }, /*              toprightparens ⎞ RIGHT PARENTHESIS UPPER HOOK */
+  { 0x08ae, 0x23a0 }, /*              botrightparens ⎠ RIGHT PARENTHESIS LOWER HOOK */
+  { 0x08af, 0x23a8 }, /*        leftmiddlecurlybrace ⎨ LEFT CURLY BRACKET MIDDLE PIECE */
+  { 0x08b0, 0x23ac }, /*       rightmiddlecurlybrace ⎬ RIGHT CURLY BRACKET MIDDLE PIECE */
+/*  0x08b1                          topleftsummation ? ??? */
+/*  0x08b2                          botleftsummation ? ??? */
+/*  0x08b3                 topvertsummationconnector ? ??? */
+/*  0x08b4                 botvertsummationconnector ? ??? */
+/*  0x08b5                         toprightsummation ? ??? */
+/*  0x08b6                         botrightsummation ? ??? */
+/*  0x08b7                      rightmiddlesummation ? ??? */
+  { 0x08bc, 0x2264 }, /*               lessthanequal ≤ LESS-THAN OR EQUAL TO */
+  { 0x08bd, 0x2260 }, /*                    notequal ≠ NOT EQUAL TO */
+  { 0x08be, 0x2265 }, /*            greaterthanequal ≥ GREATER-THAN OR EQUAL TO */
+  { 0x08bf, 0x222b }, /*                    integral ∫ INTEGRAL */
+  { 0x08c0, 0x2234 }, /*                   therefore ∴ THEREFORE */
+  { 0x08c1, 0x221d }, /*                   variation ∝ PROPORTIONAL TO */
+  { 0x08c2, 0x221e }, /*                    infinity ∞ INFINITY */
+  { 0x08c5, 0x2207 }, /*                       nabla ∇ NABLA */
+  { 0x08c8, 0x223c }, /*                 approximate ∼ TILDE OPERATOR */
+  { 0x08c9, 0x2243 }, /*                similarequal ≃ ASYMPTOTICALLY EQUAL TO */
+  { 0x08cd, 0x21d4 }, /*                    ifonlyif ⇔ LEFT RIGHT DOUBLE ARROW */
+  { 0x08ce, 0x21d2 }, /*                     implies ⇒ RIGHTWARDS DOUBLE ARROW */
+  { 0x08cf, 0x2261 }, /*                   identical ≡ IDENTICAL TO */
+  { 0x08d6, 0x221a }, /*                     radical √ SQUARE ROOT */
+  { 0x08da, 0x2282 }, /*                  includedin ⊂ SUBSET OF */
+  { 0x08db, 0x2283 }, /*                    includes ⊃ SUPERSET OF */
+  { 0x08dc, 0x2229 }, /*                intersection ∩ INTERSECTION */
+  { 0x08dd, 0x222a }, /*                       union ∪ UNION */
+  { 0x08de, 0x2227 }, /*                  logicaland ∧ LOGICAL AND */
+  { 0x08df, 0x2228 }, /*                   logicalor ∨ LOGICAL OR */
+  { 0x08ef, 0x2202 }, /*           partialderivative ∂ PARTIAL DIFFERENTIAL */
+  { 0x08f6, 0x0192 }, /*                    function ƒ LATIN SMALL LETTER F WITH HOOK */
+  { 0x08fb, 0x2190 }, /*                   leftarrow ← LEFTWARDS ARROW */
+  { 0x08fc, 0x2191 }, /*                     uparrow ↑ UPWARDS ARROW */
+  { 0x08fd, 0x2192 }, /*                  rightarrow → RIGHTWARDS ARROW */
+  { 0x08fe, 0x2193 }, /*                   downarrow ↓ DOWNWARDS ARROW */
+  { 0x09df, 0x2422 }, /*                       blank ␢ BLANK SYMBOL */
+  { 0x09e0, 0x25c6 }, /*                soliddiamond ◆ BLACK DIAMOND */
+  { 0x09e1, 0x2592 }, /*                checkerboard ▒ MEDIUM SHADE */
+  { 0x09e2, 0x2409 }, /*                          ht ␉ SYMBOL FOR HORIZONTAL TABULATION */
+  { 0x09e3, 0x240c }, /*                          ff ␌ SYMBOL FOR FORM FEED */
+  { 0x09e4, 0x240d }, /*                          cr ␍ SYMBOL FOR CARRIAGE RETURN */
+  { 0x09e5, 0x240a }, /*                          lf ␊ SYMBOL FOR LINE FEED */
+  { 0x09e8, 0x2424 }, /*                          nl ␤ SYMBOL FOR NEWLINE */
+  { 0x09e9, 0x240b }, /*                          vt ␋ SYMBOL FOR VERTICAL TABULATION */
+  { 0x09ea, 0x2518 }, /*              lowrightcorner ┘ BOX DRAWINGS LIGHT UP AND LEFT */
+  { 0x09eb, 0x2510 }, /*               uprightcorner ┐ BOX DRAWINGS LIGHT DOWN AND LEFT */
+  { 0x09ec, 0x250c }, /*                upleftcorner ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */
+  { 0x09ed, 0x2514 }, /*               lowleftcorner └ BOX DRAWINGS LIGHT UP AND RIGHT */
+  { 0x09ee, 0x253c }, /*               crossinglines ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
+  { 0x09ef, 0x23ba }, /*              horizlinescan1 ⎺ HORIZONTAL SCAN LINE-1 */
+  { 0x09f0, 0x23bb }, /*              horizlinescan3 ⎻ HORIZONTAL SCAN LINE-3 */
+  { 0x09f1, 0x2500 }, /*              horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */
+  { 0x09f2, 0x23bc }, /*              horizlinescan7 ⎼ HORIZONTAL SCAN LINE-7 */
+  { 0x09f3, 0x23bd }, /*              horizlinescan9 ⎽ HORIZONTAL SCAN LINE-9 */
+  { 0x09f4, 0x251c }, /*                       leftt ├ BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
+  { 0x09f5, 0x2524 }, /*                      rightt ┤ BOX DRAWINGS LIGHT VERTICAL AND LEFT */
+  { 0x09f6, 0x2534 }, /*                        bott ┴ BOX DRAWINGS LIGHT UP AND HORIZONTAL */
+  { 0x09f7, 0x252c }, /*                        topt ┬ BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */
+  { 0x09f8, 0x2502 }, /*                     vertbar │ BOX DRAWINGS LIGHT VERTICAL */
+  { 0x0aa1, 0x2003 }, /*                     emspace   EM SPACE */
+  { 0x0aa2, 0x2002 }, /*                     enspace   EN SPACE */
+  { 0x0aa3, 0x2004 }, /*                    em3space   THREE-PER-EM SPACE */
+  { 0x0aa4, 0x2005 }, /*                    em4space   FOUR-PER-EM SPACE */
+  { 0x0aa5, 0x2007 }, /*                  digitspace   FIGURE SPACE */
+  { 0x0aa6, 0x2008 }, /*                  punctspace   PUNCTUATION SPACE */
+  { 0x0aa7, 0x2009 }, /*                   thinspace   THIN SPACE */
+  { 0x0aa8, 0x200a }, /*                   hairspace   HAIR SPACE */
+  { 0x0aa9, 0x2014 }, /*                      emdash — EM DASH */
+  { 0x0aaa, 0x2013 }, /*                      endash – EN DASH */
+  { 0x0aac, 0x2423 }, /*                 signifblank ␣ OPEN BOX */
+  { 0x0aae, 0x2026 }, /*                    ellipsis … HORIZONTAL ELLIPSIS */
+  { 0x0aaf, 0x2025 }, /*             doubbaselinedot ‥ TWO DOT LEADER */
+  { 0x0ab0, 0x2153 }, /*                    onethird ⅓ VULGAR FRACTION ONE THIRD */
+  { 0x0ab1, 0x2154 }, /*                   twothirds ⅔ VULGAR FRACTION TWO THIRDS */
+  { 0x0ab2, 0x2155 }, /*                    onefifth ⅕ VULGAR FRACTION ONE FIFTH */
+  { 0x0ab3, 0x2156 }, /*                   twofifths ⅖ VULGAR FRACTION TWO FIFTHS */
+  { 0x0ab4, 0x2157 }, /*                 threefifths ⅗ VULGAR FRACTION THREE FIFTHS */
+  { 0x0ab5, 0x2158 }, /*                  fourfifths ⅘ VULGAR FRACTION FOUR FIFTHS */
+  { 0x0ab6, 0x2159 }, /*                    onesixth ⅙ VULGAR FRACTION ONE SIXTH */
+  { 0x0ab7, 0x215a }, /*                  fivesixths ⅚ VULGAR FRACTION FIVE SIXTHS */
+  { 0x0ab8, 0x2105 }, /*                      careof ℅ CARE OF */
+  { 0x0abb, 0x2012 }, /*                     figdash ‒ FIGURE DASH */
+  { 0x0abc, 0x2329 }, /*            leftanglebracket 〈 LEFT-POINTING ANGLE BRACKET */
+  { 0x0abd, 0x002e }, /*                decimalpoint . FULL STOP */
+  { 0x0abe, 0x232a }, /*           rightanglebracket 〉 RIGHT-POINTING ANGLE BRACKET */
+/*  0x0abf                                    marker ? ??? */
+  { 0x0ac3, 0x215b }, /*                   oneeighth ⅛ VULGAR FRACTION ONE EIGHTH */
+  { 0x0ac4, 0x215c }, /*                threeeighths ⅜ VULGAR FRACTION THREE EIGHTHS */
+  { 0x0ac5, 0x215d }, /*                 fiveeighths ⅝ VULGAR FRACTION FIVE EIGHTHS */
+  { 0x0ac6, 0x215e }, /*                seveneighths ⅞ VULGAR FRACTION SEVEN EIGHTHS */
+  { 0x0ac9, 0x2122 }, /*                   trademark ™ TRADE MARK SIGN */
+  { 0x0aca, 0x2613 }, /*               signaturemark ☓ SALTIRE */
+/*  0x0acb                         trademarkincircle ? ??? */
+  { 0x0acc, 0x25c1 }, /*            leftopentriangle ◁ WHITE LEFT-POINTING TRIANGLE */
+  { 0x0acd, 0x25b7 }, /*           rightopentriangle ▷ WHITE RIGHT-POINTING TRIANGLE */
+  { 0x0ace, 0x25cb }, /*                emopencircle ○ WHITE CIRCLE */
+  { 0x0acf, 0x25af }, /*             emopenrectangle ▯ WHITE VERTICAL RECTANGLE */
+  { 0x0ad0, 0x2018 }, /*         leftsinglequotemark ‘ LEFT SINGLE QUOTATION MARK */
+  { 0x0ad1, 0x2019 }, /*        rightsinglequotemark ’ RIGHT SINGLE QUOTATION MARK */
+  { 0x0ad2, 0x201c }, /*         leftdoublequotemark “ LEFT DOUBLE QUOTATION MARK */
+  { 0x0ad3, 0x201d }, /*        rightdoublequotemark ” RIGHT DOUBLE QUOTATION MARK */
+  { 0x0ad4, 0x211e }, /*                prescription ℞ PRESCRIPTION TAKE */
+  { 0x0ad6, 0x2032 }, /*                     minutes ′ PRIME */
+  { 0x0ad7, 0x2033 }, /*                     seconds ″ DOUBLE PRIME */
+  { 0x0ad9, 0x271d }, /*                  latincross ✝ LATIN CROSS */
+/*  0x0ada                                  hexagram ? ??? */
+  { 0x0adb, 0x25ac }, /*            filledrectbullet ▬ BLACK RECTANGLE */
+  { 0x0adc, 0x25c0 }, /*         filledlefttribullet ◀ BLACK LEFT-POINTING TRIANGLE */
+  { 0x0add, 0x25b6 }, /*        filledrighttribullet ▶ BLACK RIGHT-POINTING TRIANGLE */
+  { 0x0ade, 0x25cf }, /*              emfilledcircle ● BLACK CIRCLE */
+  { 0x0adf, 0x25ae }, /*                emfilledrect ▮ BLACK VERTICAL RECTANGLE */
+  { 0x0ae0, 0x25e6 }, /*            enopencircbullet ◦ WHITE BULLET */
+  { 0x0ae1, 0x25ab }, /*          enopensquarebullet ▫ WHITE SMALL SQUARE */
+  { 0x0ae2, 0x25ad }, /*              openrectbullet ▭ WHITE RECTANGLE */
+  { 0x0ae3, 0x25b3 }, /*             opentribulletup △ WHITE UP-POINTING TRIANGLE */
+  { 0x0ae4, 0x25bd }, /*           opentribulletdown ▽ WHITE DOWN-POINTING TRIANGLE */
+  { 0x0ae5, 0x2606 }, /*                    openstar ☆ WHITE STAR */
+  { 0x0ae6, 0x2022 }, /*          enfilledcircbullet • BULLET */
+  { 0x0ae7, 0x25aa }, /*            enfilledsqbullet ▪ BLACK SMALL SQUARE */
+  { 0x0ae8, 0x25b2 }, /*           filledtribulletup ▲ BLACK UP-POINTING TRIANGLE */
+  { 0x0ae9, 0x25bc }, /*         filledtribulletdown ▼ BLACK DOWN-POINTING TRIANGLE */
+  { 0x0aea, 0x261c }, /*                 leftpointer ☜ WHITE LEFT POINTING INDEX */
+  { 0x0aeb, 0x261e }, /*                rightpointer ☞ WHITE RIGHT POINTING INDEX */
+  { 0x0aec, 0x2663 }, /*                        club ♣ BLACK CLUB SUIT */
+  { 0x0aed, 0x2666 }, /*                     diamond ♦ BLACK DIAMOND SUIT */
+  { 0x0aee, 0x2665 }, /*                       heart ♥ BLACK HEART SUIT */
+  { 0x0af0, 0x2720 }, /*                maltesecross ✠ MALTESE CROSS */
+  { 0x0af1, 0x2020 }, /*                      dagger † DAGGER */
+  { 0x0af2, 0x2021 }, /*                doubledagger ‡ DOUBLE DAGGER */
+  { 0x0af3, 0x2713 }, /*                   checkmark ✓ CHECK MARK */
+  { 0x0af4, 0x2717 }, /*                 ballotcross ✗ BALLOT X */
+  { 0x0af5, 0x266f }, /*                musicalsharp ♯ MUSIC SHARP SIGN */
+  { 0x0af6, 0x266d }, /*                 musicalflat ♭ MUSIC FLAT SIGN */
+  { 0x0af7, 0x2642 }, /*                  malesymbol ♂ MALE SIGN */
+  { 0x0af8, 0x2640 }, /*                femalesymbol ♀ FEMALE SIGN */
+  { 0x0af9, 0x260e }, /*                   telephone ☎ BLACK TELEPHONE */
+  { 0x0afa, 0x2315 }, /*           telephonerecorder ⌕ TELEPHONE RECORDER */
+  { 0x0afb, 0x2117 }, /*         phonographcopyright ℗ SOUND RECORDING COPYRIGHT */
+  { 0x0afc, 0x2038 }, /*                       caret ‸ CARET */
+  { 0x0afd, 0x201a }, /*          singlelowquotemark ‚ SINGLE LOW-9 QUOTATION MARK */
+  { 0x0afe, 0x201e }, /*          doublelowquotemark „ DOUBLE LOW-9 QUOTATION MARK */
+/*  0x0aff                                    cursor ? ??? */
+  { 0x0ba3, 0x003c }, /*                   leftcaret < LESS-THAN SIGN */
+  { 0x0ba6, 0x003e }, /*                  rightcaret > GREATER-THAN SIGN */
+  { 0x0ba8, 0x2228 }, /*                   downcaret ∨ LOGICAL OR */
+  { 0x0ba9, 0x2227 }, /*                     upcaret ∧ LOGICAL AND */
+  { 0x0bc0, 0x00af }, /*                     overbar ¯ MACRON */
+  { 0x0bc2, 0x22a5 }, /*                    downtack ⊥ UP TACK */
+  { 0x0bc3, 0x2229 }, /*                      upshoe ∩ INTERSECTION */
+  { 0x0bc4, 0x230a }, /*                   downstile ⌊ LEFT FLOOR */
+  { 0x0bc6, 0x005f }, /*                    underbar _ LOW LINE */
+  { 0x0bca, 0x2218 }, /*                         jot ∘ RING OPERATOR */
+  { 0x0bcc, 0x2395 }, /*                        quad ⎕ APL FUNCTIONAL SYMBOL QUAD */
+  { 0x0bce, 0x22a4 }, /*                      uptack ⊤ DOWN TACK */
+  { 0x0bcf, 0x25cb }, /*                      circle ○ WHITE CIRCLE */
+  { 0x0bd3, 0x2308 }, /*                     upstile ⌈ LEFT CEILING */
+  { 0x0bd6, 0x222a }, /*                    downshoe ∪ UNION */
+  { 0x0bd8, 0x2283 }, /*                   rightshoe ⊃ SUPERSET OF */
+  { 0x0bda, 0x2282 }, /*                    leftshoe ⊂ SUBSET OF */
+  { 0x0bdc, 0x22a2 }, /*                    lefttack ⊢ RIGHT TACK */
+  { 0x0bfc, 0x22a3 }, /*                   righttack ⊣ LEFT TACK */
+  { 0x0cdf, 0x2017 }, /*        hebrew_doublelowline ‗ DOUBLE LOW LINE */
+  { 0x0ce0, 0x05d0 }, /*                hebrew_aleph א HEBREW LETTER ALEF */
+  { 0x0ce1, 0x05d1 }, /*                  hebrew_bet ב HEBREW LETTER BET */
+  { 0x0ce2, 0x05d2 }, /*                hebrew_gimel ג HEBREW LETTER GIMEL */
+  { 0x0ce3, 0x05d3 }, /*                hebrew_dalet ד HEBREW LETTER DALET */
+  { 0x0ce4, 0x05d4 }, /*                   hebrew_he ה HEBREW LETTER HE */
+  { 0x0ce5, 0x05d5 }, /*                  hebrew_waw ו HEBREW LETTER VAV */
+  { 0x0ce6, 0x05d6 }, /*                 hebrew_zain ז HEBREW LETTER ZAYIN */
+  { 0x0ce7, 0x05d7 }, /*                 hebrew_chet ח HEBREW LETTER HET */
+  { 0x0ce8, 0x05d8 }, /*                  hebrew_tet ט HEBREW LETTER TET */
+  { 0x0ce9, 0x05d9 }, /*                  hebrew_yod י HEBREW LETTER YOD */
+  { 0x0cea, 0x05da }, /*            hebrew_finalkaph ך HEBREW LETTER FINAL KAF */
+  { 0x0ceb, 0x05db }, /*                 hebrew_kaph כ HEBREW LETTER KAF */
+  { 0x0cec, 0x05dc }, /*                hebrew_lamed ל HEBREW LETTER LAMED */
+  { 0x0ced, 0x05dd }, /*             hebrew_finalmem ם HEBREW LETTER FINAL MEM */
+  { 0x0cee, 0x05de }, /*                  hebrew_mem מ HEBREW LETTER MEM */
+  { 0x0cef, 0x05df }, /*             hebrew_finalnun ן HEBREW LETTER FINAL NUN */
+  { 0x0cf0, 0x05e0 }, /*                  hebrew_nun נ HEBREW LETTER NUN */
+  { 0x0cf1, 0x05e1 }, /*               hebrew_samech ס HEBREW LETTER SAMEKH */
+  { 0x0cf2, 0x05e2 }, /*                 hebrew_ayin ע HEBREW LETTER AYIN */
+  { 0x0cf3, 0x05e3 }, /*              hebrew_finalpe ף HEBREW LETTER FINAL PE */
+  { 0x0cf4, 0x05e4 }, /*                   hebrew_pe פ HEBREW LETTER PE */
+  { 0x0cf5, 0x05e5 }, /*            hebrew_finalzade ץ HEBREW LETTER FINAL TSADI */
+  { 0x0cf6, 0x05e6 }, /*                 hebrew_zade צ HEBREW LETTER TSADI */
+  { 0x0cf7, 0x05e7 }, /*                 hebrew_qoph ק HEBREW LETTER QOF */
+  { 0x0cf8, 0x05e8 }, /*                 hebrew_resh ר HEBREW LETTER RESH */
+  { 0x0cf9, 0x05e9 }, /*                 hebrew_shin ש HEBREW LETTER SHIN */
+  { 0x0cfa, 0x05ea }, /*                  hebrew_taw ת HEBREW LETTER TAV */
+  { 0x0da1, 0x0e01 }, /*                  Thai_kokai ก THAI CHARACTER KO KAI */
+  { 0x0da2, 0x0e02 }, /*                Thai_khokhai ข THAI CHARACTER KHO KHAI */
+  { 0x0da3, 0x0e03 }, /*               Thai_khokhuat ฃ THAI CHARACTER KHO KHUAT */
+  { 0x0da4, 0x0e04 }, /*               Thai_khokhwai ค THAI CHARACTER KHO KHWAI */
+  { 0x0da5, 0x0e05 }, /*                Thai_khokhon ฅ THAI CHARACTER KHO KHON */
+  { 0x0da6, 0x0e06 }, /*             Thai_khorakhang ฆ THAI CHARACTER KHO RAKHANG */
+  { 0x0da7, 0x0e07 }, /*                 Thai_ngongu ง THAI CHARACTER NGO NGU */
+  { 0x0da8, 0x0e08 }, /*                Thai_chochan จ THAI CHARACTER CHO CHAN */
+  { 0x0da9, 0x0e09 }, /*               Thai_choching ฉ THAI CHARACTER CHO CHING */
+  { 0x0daa, 0x0e0a }, /*               Thai_chochang ช THAI CHARACTER CHO CHANG */
+  { 0x0dab, 0x0e0b }, /*                   Thai_soso ซ THAI CHARACTER SO SO */
+  { 0x0dac, 0x0e0c }, /*                Thai_chochoe ฌ THAI CHARACTER CHO CHOE */
+  { 0x0dad, 0x0e0d }, /*                 Thai_yoying ญ THAI CHARACTER YO YING */
+  { 0x0dae, 0x0e0e }, /*                Thai_dochada ฎ THAI CHARACTER DO CHADA */
+  { 0x0daf, 0x0e0f }, /*                Thai_topatak ฏ THAI CHARACTER TO PATAK */
+  { 0x0db0, 0x0e10 }, /*                Thai_thothan ฐ THAI CHARACTER THO THAN */
+  { 0x0db1, 0x0e11 }, /*          Thai_thonangmontho ฑ THAI CHARACTER THO NANGMONTHO */
+  { 0x0db2, 0x0e12 }, /*             Thai_thophuthao ฒ THAI CHARACTER THO PHUTHAO */
+  { 0x0db3, 0x0e13 }, /*                  Thai_nonen ณ THAI CHARACTER NO NEN */
+  { 0x0db4, 0x0e14 }, /*                  Thai_dodek ด THAI CHARACTER DO DEK */
+  { 0x0db5, 0x0e15 }, /*                  Thai_totao ต THAI CHARACTER TO TAO */
+  { 0x0db6, 0x0e16 }, /*               Thai_thothung ถ THAI CHARACTER THO THUNG */
+  { 0x0db7, 0x0e17 }, /*              Thai_thothahan ท THAI CHARACTER THO THAHAN */
+  { 0x0db8, 0x0e18 }, /*               Thai_thothong ธ THAI CHARACTER THO THONG */
+  { 0x0db9, 0x0e19 }, /*                   Thai_nonu น THAI CHARACTER NO NU */
+  { 0x0dba, 0x0e1a }, /*               Thai_bobaimai บ THAI CHARACTER BO BAIMAI */
+  { 0x0dbb, 0x0e1b }, /*                  Thai_popla ป THAI CHARACTER PO PLA */
+  { 0x0dbc, 0x0e1c }, /*               Thai_phophung ผ THAI CHARACTER PHO PHUNG */
+  { 0x0dbd, 0x0e1d }, /*                   Thai_fofa ฝ THAI CHARACTER FO FA */
+  { 0x0dbe, 0x0e1e }, /*                Thai_phophan พ THAI CHARACTER PHO PHAN */
+  { 0x0dbf, 0x0e1f }, /*                  Thai_fofan ฟ THAI CHARACTER FO FAN */
+  { 0x0dc0, 0x0e20 }, /*             Thai_phosamphao ภ THAI CHARACTER PHO SAMPHAO */
+  { 0x0dc1, 0x0e21 }, /*                   Thai_moma ม THAI CHARACTER MO MA */
+  { 0x0dc2, 0x0e22 }, /*                  Thai_yoyak ย THAI CHARACTER YO YAK */
+  { 0x0dc3, 0x0e23 }, /*                  Thai_rorua ร THAI CHARACTER RO RUA */
+  { 0x0dc4, 0x0e24 }, /*                     Thai_ru ฤ THAI CHARACTER RU */
+  { 0x0dc5, 0x0e25 }, /*                 Thai_loling ล THAI CHARACTER LO LING */
+  { 0x0dc6, 0x0e26 }, /*                     Thai_lu ฦ THAI CHARACTER LU */
+  { 0x0dc7, 0x0e27 }, /*                 Thai_wowaen ว THAI CHARACTER WO WAEN */
+  { 0x0dc8, 0x0e28 }, /*                 Thai_sosala ศ THAI CHARACTER SO SALA */
+  { 0x0dc9, 0x0e29 }, /*                 Thai_sorusi ษ THAI CHARACTER SO RUSI */
+  { 0x0dca, 0x0e2a }, /*                  Thai_sosua ส THAI CHARACTER SO SUA */
+  { 0x0dcb, 0x0e2b }, /*                  Thai_hohip ห THAI CHARACTER HO HIP */
+  { 0x0dcc, 0x0e2c }, /*                Thai_lochula ฬ THAI CHARACTER LO CHULA */
+  { 0x0dcd, 0x0e2d }, /*                   Thai_oang อ THAI CHARACTER O ANG */
+  { 0x0dce, 0x0e2e }, /*               Thai_honokhuk ฮ THAI CHARACTER HO NOKHUK */
+  { 0x0dcf, 0x0e2f }, /*              Thai_paiyannoi ฯ THAI CHARACTER PAIYANNOI */
+  { 0x0dd0, 0x0e30 }, /*                  Thai_saraa ะ THAI CHARACTER SARA A */
+  { 0x0dd1, 0x0e31 }, /*             Thai_maihanakat ั THAI CHARACTER MAI HAN-AKAT */
+  { 0x0dd2, 0x0e32 }, /*                 Thai_saraaa า THAI CHARACTER SARA AA */
+  { 0x0dd3, 0x0e33 }, /*                 Thai_saraam ำ THAI CHARACTER SARA AM */
+  { 0x0dd4, 0x0e34 }, /*                  Thai_sarai ิ THAI CHARACTER SARA I */
+  { 0x0dd5, 0x0e35 }, /*                 Thai_saraii ี THAI CHARACTER SARA II */
+  { 0x0dd6, 0x0e36 }, /*                 Thai_saraue ึ THAI CHARACTER SARA UE */
+  { 0x0dd7, 0x0e37 }, /*                Thai_sarauee ื THAI CHARACTER SARA UEE */
+  { 0x0dd8, 0x0e38 }, /*                  Thai_sarau ุ THAI CHARACTER SARA U */
+  { 0x0dd9, 0x0e39 }, /*                 Thai_sarauu ู THAI CHARACTER SARA UU */
+  { 0x0dda, 0x0e3a }, /*                Thai_phinthu ฺ THAI CHARACTER PHINTHU */
+  { 0x0dde, 0x0e3e }, /*      Thai_maihanakat_maitho ฾ ??? */
+  { 0x0ddf, 0x0e3f }, /*                   Thai_baht ฿ THAI CURRENCY SYMBOL BAHT */
+  { 0x0de0, 0x0e40 }, /*                  Thai_sarae เ THAI CHARACTER SARA E */
+  { 0x0de1, 0x0e41 }, /*                 Thai_saraae แ THAI CHARACTER SARA AE */
+  { 0x0de2, 0x0e42 }, /*                  Thai_sarao โ THAI CHARACTER SARA O */
+  { 0x0de3, 0x0e43 }, /*          Thai_saraaimaimuan ใ THAI CHARACTER SARA AI MAIMUAN */
+  { 0x0de4, 0x0e44 }, /*         Thai_saraaimaimalai ไ THAI CHARACTER SARA AI MAIMALAI */
+  { 0x0de5, 0x0e45 }, /*            Thai_lakkhangyao ๅ THAI CHARACTER LAKKHANGYAO */
+  { 0x0de6, 0x0e46 }, /*               Thai_maiyamok ๆ THAI CHARACTER MAIYAMOK */
+  { 0x0de7, 0x0e47 }, /*              Thai_maitaikhu ็ THAI CHARACTER MAITAIKHU */
+  { 0x0de8, 0x0e48 }, /*                  Thai_maiek ่ THAI CHARACTER MAI EK */
+  { 0x0de9, 0x0e49 }, /*                 Thai_maitho ้ THAI CHARACTER MAI THO */
+  { 0x0dea, 0x0e4a }, /*                 Thai_maitri ๊ THAI CHARACTER MAI TRI */
+  { 0x0deb, 0x0e4b }, /*            Thai_maichattawa ๋ THAI CHARACTER MAI CHATTAWA */
+  { 0x0dec, 0x0e4c }, /*            Thai_thanthakhat ์ THAI CHARACTER THANTHAKHAT */
+  { 0x0ded, 0x0e4d }, /*               Thai_nikhahit ํ THAI CHARACTER NIKHAHIT */
+  { 0x0df0, 0x0e50 }, /*                 Thai_leksun ๐ THAI DIGIT ZERO */
+  { 0x0df1, 0x0e51 }, /*                Thai_leknung ๑ THAI DIGIT ONE */
+  { 0x0df2, 0x0e52 }, /*                Thai_leksong ๒ THAI DIGIT TWO */
+  { 0x0df3, 0x0e53 }, /*                 Thai_leksam ๓ THAI DIGIT THREE */
+  { 0x0df4, 0x0e54 }, /*                  Thai_leksi ๔ THAI DIGIT FOUR */
+  { 0x0df5, 0x0e55 }, /*                  Thai_lekha ๕ THAI DIGIT FIVE */
+  { 0x0df6, 0x0e56 }, /*                 Thai_lekhok ๖ THAI DIGIT SIX */
+  { 0x0df7, 0x0e57 }, /*                Thai_lekchet ๗ THAI DIGIT SEVEN */
+  { 0x0df8, 0x0e58 }, /*                Thai_lekpaet ๘ THAI DIGIT EIGHT */
+  { 0x0df9, 0x0e59 }, /*                 Thai_lekkao ๙ THAI DIGIT NINE */
+  { 0x0ea1, 0x3131 }, /*               Hangul_Kiyeog ㄱ HANGUL LETTER KIYEOK */
+  { 0x0ea2, 0x3132 }, /*          Hangul_SsangKiyeog ㄲ HANGUL LETTER SSANGKIYEOK */
+  { 0x0ea3, 0x3133 }, /*           Hangul_KiyeogSios ㄳ HANGUL LETTER KIYEOK-SIOS */
+  { 0x0ea4, 0x3134 }, /*                Hangul_Nieun ㄴ HANGUL LETTER NIEUN */
+  { 0x0ea5, 0x3135 }, /*           Hangul_NieunJieuj ㄵ HANGUL LETTER NIEUN-CIEUC */
+  { 0x0ea6, 0x3136 }, /*           Hangul_NieunHieuh ㄶ HANGUL LETTER NIEUN-HIEUH */
+  { 0x0ea7, 0x3137 }, /*               Hangul_Dikeud ㄷ HANGUL LETTER TIKEUT */
+  { 0x0ea8, 0x3138 }, /*          Hangul_SsangDikeud ㄸ HANGUL LETTER SSANGTIKEUT */
+  { 0x0ea9, 0x3139 }, /*                Hangul_Rieul ㄹ HANGUL LETTER RIEUL */
+  { 0x0eaa, 0x313a }, /*          Hangul_RieulKiyeog ㄺ HANGUL LETTER RIEUL-KIYEOK */
+  { 0x0eab, 0x313b }, /*           Hangul_RieulMieum ㄻ HANGUL LETTER RIEUL-MIEUM */
+  { 0x0eac, 0x313c }, /*           Hangul_RieulPieub ㄼ HANGUL LETTER RIEUL-PIEUP */
+  { 0x0ead, 0x313d }, /*            Hangul_RieulSios ㄽ HANGUL LETTER RIEUL-SIOS */
+  { 0x0eae, 0x313e }, /*           Hangul_RieulTieut ㄾ HANGUL LETTER RIEUL-THIEUTH */
+  { 0x0eaf, 0x313f }, /*          Hangul_RieulPhieuf ㄿ HANGUL LETTER RIEUL-PHIEUPH */
+  { 0x0eb0, 0x3140 }, /*           Hangul_RieulHieuh ㅀ HANGUL LETTER RIEUL-HIEUH */
+  { 0x0eb1, 0x3141 }, /*                Hangul_Mieum ㅁ HANGUL LETTER MIEUM */
+  { 0x0eb2, 0x3142 }, /*                Hangul_Pieub ㅂ HANGUL LETTER PIEUP */
+  { 0x0eb3, 0x3143 }, /*           Hangul_SsangPieub ㅃ HANGUL LETTER SSANGPIEUP */
+  { 0x0eb4, 0x3144 }, /*            Hangul_PieubSios ㅄ HANGUL LETTER PIEUP-SIOS */
+  { 0x0eb5, 0x3145 }, /*                 Hangul_Sios ㅅ HANGUL LETTER SIOS */
+  { 0x0eb6, 0x3146 }, /*            Hangul_SsangSios ㅆ HANGUL LETTER SSANGSIOS */
+  { 0x0eb7, 0x3147 }, /*                Hangul_Ieung ㅇ HANGUL LETTER IEUNG */
+  { 0x0eb8, 0x3148 }, /*                Hangul_Jieuj ㅈ HANGUL LETTER CIEUC */
+  { 0x0eb9, 0x3149 }, /*           Hangul_SsangJieuj ㅉ HANGUL LETTER SSANGCIEUC */
+  { 0x0eba, 0x314a }, /*                Hangul_Cieuc ㅊ HANGUL LETTER CHIEUCH */
+  { 0x0ebb, 0x314b }, /*               Hangul_Khieuq ㅋ HANGUL LETTER KHIEUKH */
+  { 0x0ebc, 0x314c }, /*                Hangul_Tieut ㅌ HANGUL LETTER THIEUTH */
+  { 0x0ebd, 0x314d }, /*               Hangul_Phieuf ㅍ HANGUL LETTER PHIEUPH */
+  { 0x0ebe, 0x314e }, /*                Hangul_Hieuh ㅎ HANGUL LETTER HIEUH */
+  { 0x0ebf, 0x314f }, /*                    Hangul_A ㅏ HANGUL LETTER A */
+  { 0x0ec0, 0x3150 }, /*                   Hangul_AE ㅐ HANGUL LETTER AE */
+  { 0x0ec1, 0x3151 }, /*                   Hangul_YA ㅑ HANGUL LETTER YA */
+  { 0x0ec2, 0x3152 }, /*                  Hangul_YAE ㅒ HANGUL LETTER YAE */
+  { 0x0ec3, 0x3153 }, /*                   Hangul_EO ㅓ HANGUL LETTER EO */
+  { 0x0ec4, 0x3154 }, /*                    Hangul_E ㅔ HANGUL LETTER E */
+  { 0x0ec5, 0x3155 }, /*                  Hangul_YEO ㅕ HANGUL LETTER YEO */
+  { 0x0ec6, 0x3156 }, /*                   Hangul_YE ㅖ HANGUL LETTER YE */
+  { 0x0ec7, 0x3157 }, /*                    Hangul_O ㅗ HANGUL LETTER O */
+  { 0x0ec8, 0x3158 }, /*                   Hangul_WA ㅘ HANGUL LETTER WA */
+  { 0x0ec9, 0x3159 }, /*                  Hangul_WAE ㅙ HANGUL LETTER WAE */
+  { 0x0eca, 0x315a }, /*                   Hangul_OE ㅚ HANGUL LETTER OE */
+  { 0x0ecb, 0x315b }, /*                   Hangul_YO ㅛ HANGUL LETTER YO */
+  { 0x0ecc, 0x315c }, /*                    Hangul_U ㅜ HANGUL LETTER U */
+  { 0x0ecd, 0x315d }, /*                  Hangul_WEO ㅝ HANGUL LETTER WEO */
+  { 0x0ece, 0x315e }, /*                   Hangul_WE ㅞ HANGUL LETTER WE */
+  { 0x0ecf, 0x315f }, /*                   Hangul_WI ㅟ HANGUL LETTER WI */
+  { 0x0ed0, 0x3160 }, /*                   Hangul_YU ㅠ HANGUL LETTER YU */
+  { 0x0ed1, 0x3161 }, /*                   Hangul_EU ㅡ HANGUL LETTER EU */
+  { 0x0ed2, 0x3162 }, /*                   Hangul_YI ㅢ HANGUL LETTER YI */
+  { 0x0ed3, 0x3163 }, /*                    Hangul_I ㅣ HANGUL LETTER I */
+  { 0x0ed4, 0x11a8 }, /*             Hangul_J_Kiyeog ᆨ HANGUL JONGSEONG KIYEOK */
+  { 0x0ed5, 0x11a9 }, /*        Hangul_J_SsangKiyeog ᆩ HANGUL JONGSEONG SSANGKIYEOK */
+  { 0x0ed6, 0x11aa }, /*         Hangul_J_KiyeogSios ᆪ HANGUL JONGSEONG KIYEOK-SIOS */
+  { 0x0ed7, 0x11ab }, /*              Hangul_J_Nieun ᆫ HANGUL JONGSEONG NIEUN */
+  { 0x0ed8, 0x11ac }, /*         Hangul_J_NieunJieuj ᆬ HANGUL JONGSEONG NIEUN-CIEUC */
+  { 0x0ed9, 0x11ad }, /*         Hangul_J_NieunHieuh ᆭ HANGUL JONGSEONG NIEUN-HIEUH */
+  { 0x0eda, 0x11ae }, /*             Hangul_J_Dikeud ᆮ HANGUL JONGSEONG TIKEUT */
+  { 0x0edb, 0x11af }, /*              Hangul_J_Rieul ᆯ HANGUL JONGSEONG RIEUL */
+  { 0x0edc, 0x11b0 }, /*        Hangul_J_RieulKiyeog ᆰ HANGUL JONGSEONG RIEUL-KIYEOK */
+  { 0x0edd, 0x11b1 }, /*         Hangul_J_RieulMieum ᆱ HANGUL JONGSEONG RIEUL-MIEUM */
+  { 0x0ede, 0x11b2 }, /*         Hangul_J_RieulPieub ᆲ HANGUL JONGSEONG RIEUL-PIEUP */
+  { 0x0edf, 0x11b3 }, /*          Hangul_J_RieulSios ᆳ HANGUL JONGSEONG RIEUL-SIOS */
+  { 0x0ee0, 0x11b4 }, /*         Hangul_J_RieulTieut ᆴ HANGUL JONGSEONG RIEUL-THIEUTH */
+  { 0x0ee1, 0x11b5 }, /*        Hangul_J_RieulPhieuf ᆵ HANGUL JONGSEONG RIEUL-PHIEUPH */
+  { 0x0ee2, 0x11b6 }, /*         Hangul_J_RieulHieuh ᆶ HANGUL JONGSEONG RIEUL-HIEUH */
+  { 0x0ee3, 0x11b7 }, /*              Hangul_J_Mieum ᆷ HANGUL JONGSEONG MIEUM */
+  { 0x0ee4, 0x11b8 }, /*              Hangul_J_Pieub ᆸ HANGUL JONGSEONG PIEUP */
+  { 0x0ee5, 0x11b9 }, /*          Hangul_J_PieubSios ᆹ HANGUL JONGSEONG PIEUP-SIOS */
+  { 0x0ee6, 0x11ba }, /*               Hangul_J_Sios ᆺ HANGUL JONGSEONG SIOS */
+  { 0x0ee7, 0x11bb }, /*          Hangul_J_SsangSios ᆻ HANGUL JONGSEONG SSANGSIOS */
+  { 0x0ee8, 0x11bc }, /*              Hangul_J_Ieung ᆼ HANGUL JONGSEONG IEUNG */
+  { 0x0ee9, 0x11bd }, /*              Hangul_J_Jieuj ᆽ HANGUL JONGSEONG CIEUC */
+  { 0x0eea, 0x11be }, /*              Hangul_J_Cieuc ᆾ HANGUL JONGSEONG CHIEUCH */
+  { 0x0eeb, 0x11bf }, /*             Hangul_J_Khieuq ᆿ HANGUL JONGSEONG KHIEUKH */
+  { 0x0eec, 0x11c0 }, /*              Hangul_J_Tieut ᇀ HANGUL JONGSEONG THIEUTH */
+  { 0x0eed, 0x11c1 }, /*             Hangul_J_Phieuf ᇁ HANGUL JONGSEONG PHIEUPH */
+  { 0x0eee, 0x11c2 }, /*              Hangul_J_Hieuh ᇂ HANGUL JONGSEONG HIEUH */
+  { 0x0eef, 0x316d }, /*     Hangul_RieulYeorinHieuh ㅭ HANGUL LETTER RIEUL-YEORINHIEUH */
+  { 0x0ef0, 0x3171 }, /*    Hangul_SunkyeongeumMieum ㅱ HANGUL LETTER KAPYEOUNMIEUM */
+  { 0x0ef1, 0x3178 }, /*    Hangul_SunkyeongeumPieub ㅸ HANGUL LETTER KAPYEOUNPIEUP */
+  { 0x0ef2, 0x317f }, /*              Hangul_PanSios ㅿ HANGUL LETTER PANSIOS */
+  { 0x0ef3, 0x3181 }, /*    Hangul_KkogjiDalrinIeung ㆁ HANGUL LETTER YESIEUNG */
+  { 0x0ef4, 0x3184 }, /*   Hangul_SunkyeongeumPhieuf ㆄ HANGUL LETTER KAPYEOUNPHIEUPH */
+  { 0x0ef5, 0x3186 }, /*          Hangul_YeorinHieuh ㆆ HANGUL LETTER YEORINHIEUH */
+  { 0x0ef6, 0x318d }, /*                Hangul_AraeA ㆍ HANGUL LETTER ARAEA */
+  { 0x0ef7, 0x318e }, /*               Hangul_AraeAE ㆎ HANGUL LETTER ARAEAE */
+  { 0x0ef8, 0x11eb }, /*            Hangul_J_PanSios ᇫ HANGUL JONGSEONG PANSIOS */
+  { 0x0ef9, 0x11f0 }, /*  Hangul_J_KkogjiDalrinIeung ᇰ HANGUL JONGSEONG YESIEUNG */
+  { 0x0efa, 0x11f9 }, /*        Hangul_J_YeorinHieuh ᇹ HANGUL JONGSEONG YEORINHIEUH */
+  { 0x0eff, 0x20a9 }, /*                  Korean_Won ₩ WON SIGN */
+  { 0x13a4, 0x20ac }, /*                        Euro € EURO SIGN */
+  { 0x13bc, 0x0152 }, /*                          OE Œ LATIN CAPITAL LIGATURE OE */
+  { 0x13bd, 0x0153 }, /*                          oe œ LATIN SMALL LIGATURE OE */
+  { 0x13be, 0x0178 }, /*                  Ydiaeresis Ÿ LATIN CAPITAL LETTER Y WITH DIAERESIS */
+  { 0x20a0, 0x20a0 }, /*                     EcuSign ₠ EURO-CURRENCY SIGN */
+  { 0x20a1, 0x20a1 }, /*                   ColonSign ₡ COLON SIGN */
+  { 0x20a2, 0x20a2 }, /*                CruzeiroSign ₢ CRUZEIRO SIGN */
+  { 0x20a3, 0x20a3 }, /*                  FFrancSign ₣ FRENCH FRANC SIGN */
+  { 0x20a4, 0x20a4 }, /*                    LiraSign ₤ LIRA SIGN */
+  { 0x20a5, 0x20a5 }, /*                    MillSign ₥ MILL SIGN */
+  { 0x20a6, 0x20a6 }, /*                   NairaSign ₦ NAIRA SIGN */
+  { 0x20a7, 0x20a7 }, /*                  PesetaSign ₧ PESETA SIGN */
+  { 0x20a8, 0x20a8 }, /*                   RupeeSign ₨ RUPEE SIGN */
+  { 0x20a9, 0x20a9 }, /*                     WonSign ₩ WON SIGN */
+  { 0x20aa, 0x20aa }, /*               NewSheqelSign ₪ NEW SHEQEL SIGN */
+  { 0x20ab, 0x20ab }, /*                    DongSign ₫ DONG SIGN */
+  { 0x20ac, 0x20ac }, /*                    EuroSign € EURO SIGN */
+};
+
+VISIBLE
+long keysym2ucs(KeySym keysym)
+{
+    int min = 0;
+    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
+    int mid;
+
+    /* first check for Latin-1 characters (1:1 mapping) */
+    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
+        (keysym >= 0x00a0 && keysym <= 0x00ff))
+        return keysym;
+
+    /* also check for directly encoded 24-bit UCS characters */
+    if ((keysym & 0xff000000) == 0x01000000)
+       return keysym & 0x00ffffff;
+
+    /* binary search in table */
+    while (max >= min) {
+       mid = (min + max) / 2;
+       if (keysymtab[mid].keysym < keysym)
+           min = mid + 1;
+       else if (keysymtab[mid].keysym > keysym)
+           max = mid - 1;
+       else {
+           /* found it */
+           return keysymtab[mid].ucs;
+       }
+    }
+
+    /* no matching Unicode value found */
+    return -1;
+}
diff --git a/keysym2ucs.h b/keysym2ucs.h
new file mode 100644 (file)
index 0000000..1f23ac6
--- /dev/null
@@ -0,0 +1,9 @@
+/* $XFree86: xc/programs/xterm/keysym2ucs.h,v 1.1 1999/06/12 15:37:18 dawes Exp $ */
+/*
+ * This module converts keysym values into the corresponding ISO 10646-1
+ * (UCS, Unicode) values.
+ */
+
+#include <X11/X.h>
+
+long keysym2ucs(KeySym keysym);
diff --git a/koi8rxterm b/koi8rxterm
new file mode 100755 (executable)
index 0000000..98f85ca
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/sh
+# $XTermId: koi8rxterm,v 1.5 2007/12/30 16:33:06 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2007 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# This is a wrapper script to set up xterm with a KOI8-R locale; based on
+# uxterm by Branden Robinson.
+
+whoami=koi8rxterm
+
+: ${XTERM_PROGRAM=xterm}
+
+# Check if there is a workable locale program.  If there is not, we will read
+# something via the standard error.  Ignore whatever is written to the
+# standard output.
+locale=`sh -c "LC_ALL=C LC_CTYPE=C LANG=C locale >/dev/null" 2>&1`
+found=no
+
+# Check for -version and -help options, to provide a simple return without
+# requiring the program to create a window:
+if test $# = 1
+then
+       case $1 in
+       -v|-ver*|-h|-he*)
+               $XTERM_PROGRAM "$@"
+               exit $?
+               ;;
+       esac
+fi
+
+# Check environment variables that xterm does, in the same order:
+for name in LC_ALL LC_CTYPE LANG
+do
+       eval 'value=$'$name
+       if test -n "$value" ; then
+               case $value in
+               *.koi8r|*.KOI8R|*.koi8-r|*.KOI8-R)
+                       found=yes
+                       ;;
+               *.koi8r@*|*.KOI8R@*|*.koi8-r@*|*.KOI8-R*)
+                       found=yes
+                       ;;
+               *)
+                       # The user may not have configured his or her
+                       # locale; try to muddle through anyway.
+                       value=ru_RU.KOI8-R
+                       ;;
+               esac
+               break
+       fi
+done
+
+# If we didn't find one that uses KOI8-R, modify the safest one.  Not everyone
+# has a KOI8-R locale installed (and there appears to be no trivial/portable
+# way to determine whether it is, from a shell script).  We could check if the
+# user's shell does not reset unknown locale specifiers, but not all shells do.
+if test $found != yes ; then
+       if test -n "$value" ; then
+               value=`echo ${value} |sed -e 's/[.@].*//'`.KOI8-R
+       else
+               name="LC_CTYPE"
+               value="ru_RU.KOI8-R"
+       fi
+       eval save=\$${name}
+       eval ${name}=${value}
+       eval export ${name}
+       if test -z "$locale" ; then
+               # The 'locale' program tries to do a sanity check.
+               check=`sh -c "locale >/dev/null" 2>&1`
+               if test -n "$check" ; then
+                       eval ${name}=${save}
+                       eval export ${name}
+
+                       echo "$whoami tried to use locale $value by setting \$$name" >&2
+                       xmessage -file - <<EOF
+$whoami tried unsuccessfully to use locale $value
+by setting \$$name to "${value}".
+EOF
+                       exit 1
+               fi
+       fi
+fi
+
+# for testing:
+#test -f ./xterm && XTERM_PROGRAM=./xterm
+
+exec $XTERM_PROGRAM -class KOI8RXTerm -title $whoami -k8 "$@"
diff --git a/koi8rxterm.man b/koi8rxterm.man
new file mode 100644 (file)
index 0000000..169df49
--- /dev/null
@@ -0,0 +1,97 @@
+.\" $XTermId: koi8rxterm.man,v 1.3 2007/12/30 15:46:00 tom Exp $
+.\"
+.\" Copyright 2004 Branden Robinson
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the "Software"),
+.\" to deal in the Software without restriction, including without limitation
+.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
+.\" and/or sell copies of the Software, and to permit persons to whom the
+.\" Software is furnished to do so, subject to the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included in
+.\" all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+.\" SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+.\" DEALINGS IN THE SOFTWARE.
+.TH koi8rxterm 1 "2004-12-19" "Debian Project"
+.SH NAME
+koi8rxterm \- X terminal emulator for KOI8-R environments
+.SH SYNOPSIS
+.B koi8rxterm
+[
+.I xterm-options
+]
+.SH DESCRIPTION
+.B koi8rxterm
+is a wrapper around the
+.BR xterm(1)
+program that invokes the latter program with the \(oqKOI8RXTerm\(cq X
+resource class set.
+All arguments to
+.B koi8rxterm
+are passed to
+.B xterm
+without processing; the
+.B \-class
+and
+.B \-k8
+options should not be specified because they are used by the wrapper.
+See the
+.BR xterm
+manual page for more information on
+.IR xterm-options .
+.PP
+The environment's locale settings (see \(lqENVIRONMENT\(rq below) are
+used to discern the locale's character set.
+If no current locale can be determined, the locale \(oqru_RU.KOI8-R\(cq
+(the Russian language as used in the territory of Russia, with the KOI8-R
+character set) is assumed.
+The
+.BR locale(1)
+utility is used to determine whether the system supports the selected
+locale.
+If it does not,
+.B koi8rxterm
+will exit with an error and report the output of
+.BR locale .
+.PP
+.B Note: koi8rxterm
+may produce unexpected results if the current locale is set to one in which
+the KOI8-R character encoding is not supported, or if fonts using that
+encoding are not available.
+In the Debian system, the \(oqxfonts\-cyrillic\(cq package provides the
+fonts that
+.B koi8rxterm
+uses by default.
+To change the fonts
+.B koi8rxterm
+uses, edit the
+.I __apploaddir__/KOI8RXTerm
+file.
+.PP
+A similar wrapper,
+.BR uxterm(1),
+is available for Unicode UTF-8 environments.
+.SH ENVIRONMENT
+.TP
+.B LC_ALL\fR, \fBLC_CTYPE\fR, \fBLANG
+The values of these variables are checked, in order, to determine the
+character set used by the current locale.
+.SH AUTHOR
+.B koi8rxterm
+was written by Branden Robinson and is very heavily based on
+.BR uxterm ,
+by Thomas Dickey.
+The assistance of Jurij Smakov was invaluable in sanity-checking its
+operation.
+.SH "SEE ALSO"
+.BR locale(1),
+.BR locale(7),
+.BR uxterm(1),
+.BR xterm(1)
diff --git a/linedata.c b/linedata.c
new file mode 100644 (file)
index 0000000..5d47d1a
--- /dev/null
@@ -0,0 +1,253 @@
+/* $XTermId: linedata.c,v 1.79 2011/01/21 00:07:35 tom Exp $ */
+
+/************************************************************
+
+Copyright 2009-2010,2011 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <xterm.h>
+#include <data.h>              /* FIXME - needed for 'term' */
+
+#include <assert.h>
+
+/*
+ * Given a row-number, find the corresponding data for the line in the VT100
+ * widget.  Row numbers can be positive or negative.
+ *
+ * If the data comes from the scrollback, defer that to getScrollback().
+ */
+LineData *
+getLineData(TScreen * screen, int row)
+{
+    LineData *result = 0;
+    ScrnBuf buffer;
+    int max_row = screen->max_row;
+
+    if (row >= 0) {
+       buffer = screen->visbuf;
+    } else {
+#if OPT_FIFO_LINES
+       buffer = 0;
+       result = getScrollback(screen, row);
+#else
+       buffer = screen->saveBuf_index;
+       row += screen->savelines;
+       max_row += screen->savelines;
+#endif
+    }
+    if (row >= 0 && row <= max_row) {
+       result = (LineData *) scrnHeadAddr(screen, buffer, (unsigned) row);
+       if (result != 0) {
+#if 1                          /* FIXME - these should be done in setupLineData, etc. */
+           result->lineSize = (Dimension) MaxCols(screen);
+#if OPT_WIDE_CHARS
+           if (screen->wide_chars) {
+               result->combSize = (Char) screen->max_combining;
+           } else {
+               result->combSize = 0;
+           }
+#endif
+#endif /* FIXME */
+       }
+    }
+
+    return result;
+}
+
+/*
+ * Copy line's data, e.g., from one screen buffer to another, given the preset
+ * pointers for the destination.
+ *
+ * TODO: optionally prune unused combining character data from the result.
+ */
+void
+copyLineData(LineData * dst, LineData * src)
+{
+    dst->bufHead = src->bufHead;
+
+#if OPT_WIDE_CHARS
+    dst->combSize = src->combSize;
+#endif
+
+    /*
+     * Usually we're copying the same-sized line; a memcpy is faster than
+     * several loops.
+     */
+    if (dst->lineSize == src->lineSize) {
+       size_t size = (sizeof(dst->attribs[0])
+#if OPT_ISO_COLORS
+                      + sizeof(dst->color[0])
+#endif
+                      + sizeof(dst->charData[0])
+#if OPT_WIDE_CHARS
+                      + sizeof(dst->combData[0][0]) * dst->combSize
+#endif
+       );
+
+       memcpy(dst->attribs, src->attribs, size * dst->lineSize);
+    } else {
+       Dimension col;
+       Dimension limit = ((dst->lineSize < src->lineSize)
+                          ? dst->lineSize
+                          : src->lineSize);
+#if OPT_WIDE_CHARS
+       Char comb;
+#endif
+
+       for (col = 0; col < limit; ++col) {
+           dst->attribs[col] = src->attribs[col];
+#if OPT_ISO_COLORS
+           dst->color[col] = src->color[col];
+#endif
+           dst->charData[col] = src->charData[col];
+#if OPT_WIDE_CHARS
+           for (comb = 0; comb < dst->combSize; ++comb) {
+               dst->combData[comb][col] = src->combData[comb][col];
+           }
+#endif
+       }
+       for (col = limit; col < dst->lineSize; ++col) {
+           dst->attribs[col] = 0;
+#if OPT_ISO_COLORS
+           dst->color[col] = 0;
+#endif
+           dst->charData[col] = 0;
+#if OPT_WIDE_CHARS
+           for (comb = 0; comb < dst->combSize; ++comb) {
+               dst->combData[comb][col] = 0;
+           }
+#endif
+       }
+    }
+}
+
+#if OPT_WIDE_CHARS
+#define initLineExtra(screen) \
+    screen->lineExtra = ((size_t) (screen->max_combining) * sizeof(IChar *))
+#else
+#define initLineExtra(screen) \
+    screen->lineExtra = 0
+#endif
+
+void
+initLineData(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    initLineExtra(screen);
+
+    TRACE(("initLineData %lu\n", (unsigned long) screen->lineExtra));
+    TRACE(("...sizeof(LineData)  %lu\n", (unsigned long) sizeof(LineData)));
+#if OPT_ISO_COLORS
+    TRACE(("...sizeof(CellColor) %lu\n", (unsigned long) sizeof(CellColor)));
+#endif
+    TRACE(("...sizeof(RowData)   %lu\n", (unsigned long) sizeof(RowData)));
+    TRACE(("...offset(lineSize)  %lu\n", (unsigned long) offsetof(LineData, lineSize)));
+    TRACE(("...offset(bufHead)   %lu\n", (unsigned long) offsetof(LineData, bufHead)));
+#if OPT_WIDE_CHARS
+    TRACE(("...offset(combSize)  %lu\n", (unsigned long) offsetof(LineData, combSize)));
+#endif
+    TRACE(("...offset(attribs)   %lu\n", (unsigned long) offsetof(LineData, attribs)));
+#if OPT_ISO_COLORS
+    TRACE(("...offset(color)     %lu\n", (unsigned long) offsetof(LineData, color)));
+#endif
+    TRACE(("...offset(charData)  %lu\n", (unsigned long) offsetof(LineData, charData)));
+    TRACE(("...offset(combData)  %lu\n", (unsigned long) offsetof(LineData, combData)));
+}
+
+/*
+ * CellData size depends on the "combiningChars" resource.
+ * FIXME - revise this to reduce arithmetic...
+ */
+#define CellDataSize(screen) (SizeOfCellData + screen->lineExtra)
+
+#define CellDataAddr(screen, data, cell) \
+       (CellData *)(void *) ((char *)data + (cell * CellDataSize(screen)))
+
+CellData *
+newCellData(XtermWidget xw, Cardinal count)
+{
+    CellData *result;
+    TScreen *screen = TScreenOf(xw);
+
+    initLineExtra(screen);
+    result = (CellData *) calloc((size_t) count, (size_t) CellDataSize(screen));
+    return result;
+}
+
+void
+saveCellData(TScreen * screen,
+            CellData * data,
+            Cardinal cell,
+            LineData * ld,
+            int column)
+{
+    CellData *item = CellDataAddr(screen, data, cell);
+
+    if (column < MaxCols(screen)) {
+       item->attribs = ld->attribs[column];
+#if OPT_ISO_COLORS
+       item->color = ld->color[column];
+#endif
+       item->charData = ld->charData[column];
+       if_OPT_WIDE_CHARS(screen, {
+           size_t off;
+           item->combSize = ld->combSize;
+           for_each_combData(off, ld) {
+               item->combData[off] = ld->combData[off][column];
+           }
+       })
+    }
+}
+
+void
+restoreCellData(TScreen * screen,
+               CellData * data,
+               Cardinal cell,
+               LineData * ld,
+               int column)
+{
+    CellData *item = CellDataAddr(screen, data, cell);
+
+    if (column < MaxCols(screen)) {
+       ld->attribs[column] = item->attribs;
+#if OPT_ISO_COLORS
+       ld->color[column] = item->color;
+#endif
+       ld->charData[column] = item->charData;
+       if_OPT_WIDE_CHARS(screen, {
+           size_t off;
+           ld->combSize = item->combSize;
+           for_each_combData(off, ld) {
+               ld->combData[off][column] = item->combData[off];
+           }
+       })
+    }
+}
diff --git a/link_axp.com b/link_axp.com
new file mode 100644 (file)
index 0000000..1f493a9
--- /dev/null
@@ -0,0 +1,107 @@
+$! $XFree86: xc/programs/xterm/link_axp.com,v 1.1 2000/02/08 17:19:35 dawes Exp $
+$ SAVE_VERIFY='F$VERIFY(0)
+$ if p1 .Eqs. "CLEAN" then goto clean
+$ if p1 .Eqs. "CLOBBER" then goto clobber
+$ if p1 .Eqs. "INSTALL" then goto install
+$!
+$!     Compile the X11R4 Xterm application
+$!
+$ Set Symbol/Scope=NoGlobal
+$!
+$!  Define logicals pointing to the needed directories
+$!
+$ x11lib_device = f$parse("[.lib]",,,"DEVICE")
+$ x11lib_directory = f$parse("[.lib]",,,"DIRECTORY")
+$ define/nolog x11lib 'x11lib_device''x11lib_directory'
+$!
+$ x11inc_device = f$parse("[]",,,"DEVICE")
+$ x11inc_directory = f$parse("[]",,,"DIRECTORY")
+$ define/nolog x11inc 'x11inc_device''x11inc_directory'
+$!
+$ xmu_device = f$parse("[.lib.xmu]",,,"DEVICE")
+$ xmu_directory = f$parse("[.lib.xmu]",,,"DIRECTORY")
+$ define/nolog x11xmu 'xmu_device''xmu_directory'
+$!
+$ xbm_device = f$parse("[.lib.x11]",,,"DEVICE")
+$ xbm_directory = f$parse("[.lib.x11]",,,"DIRECTORY")
+$ define/nolog x11xbm 'xbm_device''xbm_directory'
+$!
+$ xaw_device = f$parse("[.lib.xaw]",,,"DEVICE")
+$ xaw_directory = f$parse("[.lib.xaw]",,,"DIRECTORY")
+$ define/nolog x11xaw 'xaw_device''xaw_directory'
+$!
+$ x11vms_device = f$parse("[.lib.misc]",,,"DEVICE")
+$ x11vms_directory = f$parse("[.lib.misc]",,,"DIRECTORY")
+$ define/nolog x11vms 'x11vms_device''x11vms_directory'
+$!
+$!  Get the compiler options via the logical name COPTS
+$!
+$ cc_options = f$trnlnm("COPTS")
+$!
+$!  Get the linker options via the logical name LOPTS
+$!
+$ link_options = f$trnlnm("LOPTS")
+$!
+$ write sys$output "Building XTERM Image"
+$ CALL MAKE XTERM.EXE  "LINK ''link_options' /EXE=XTERM.EXE_AXP/CROSS/FULL/MAP=XTERM.MAP XTERM_AXP/OPT" *.OBJ
+$!
+$ deassign x11lib
+$ deassign x11vms
+$ deassign x11xmu
+$ deassign x11xbm
+$ deassign x11xaw
+$!
+$ exit
+$!
+$ Clobber:     ! Delete executables, Purge directory and clean up object files and listings
+$ Delete/noconfirm/log *.exe;*
+$!
+$ Clean:       ! Purge directory, clean up object files and listings
+$ Purge
+$ Delete/noconfirm/log *.lis;*
+$ Delete/noconfirm/log *.obj;*
+$!
+$ exit
+$!
+$ Install:
+$ Copy/log *.exe x11bin:
+$ exit
+$!
+$MAKE: SUBROUTINE   !SUBROUTINE TO CHECK DEPENDENCIES
+$ V = 'F$Verify(0)
+$! P1 = What we are trying to make
+$! P2 = Command to make it
+$! P3 - P8  What it depends on
+$
+$ If F$Search(P1) .Eqs. "" Then Goto Makeit
+$ Time = F$CvTime(F$File(P1,"RDT"))
+$arg=3
+$Loop:
+$      Argument = P'arg
+$      If Argument .Eqs. "" Then Goto Exit
+$      El=0
+$Loop2:
+$      File = F$Element(El," ",Argument)
+$      If File .Eqs. " " Then Goto Endl
+$      AFile = ""
+$Loop3:
+$      OFile = AFile
+$      AFile = F$Search(File)
+$      If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
+$      If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
+$      Goto Loop3
+$NextEL:
+$      El = El + 1
+$      Goto Loop2
+$EndL:
+$ arg=arg+1
+$ If arg .Le. 8 Then Goto Loop
+$ Goto Exit
+$
+$Makeit:
+$ Set Verify
+$ 'P2
+$ VV='F$Verify(0)
+$Exit:
+$ If V Then Set Verify
+$ENDSUBROUTINE
diff --git a/main.c b/main.c
new file mode 100644 (file)
index 0000000..99fb224
--- /dev/null
+++ b/main.c
@@ -0,0 +1,5054 @@
+/* $XTermId: main.c,v 1.620 2011/02/09 10:13:32 tom Exp $ */
+
+/*
+ *                              W A R N I N G
+ *
+ * If you think you know what all of this code is doing, you are
+ * probably very mistaken.  There be serious and nasty dragons here.
+ *
+ * This client is *not* to be taken as an example of how to write X
+ * Toolkit applications.  It is in need of a substantial rewrite,
+ * ideally to create a generic tty widget with several different parsing
+ * widgets so that you can plug 'em together any way you want.  Don't
+ * hold your breath, though....
+ */
+
+/***********************************************************
+
+Copyright 2002-2010,2011 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+Copyright 1987, 1988  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be used in
+advertising or publicity pertaining to distribution of the software
+without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* main.c */
+
+#define RES_OFFSET(field)      XtOffsetOf(XTERM_RESOURCE, field)
+
+#include <xterm.h>
+
+#include <X11/cursorfont.h>
+#include <X11/Xlocale.h>
+
+#if OPT_TOOLBAR
+
+#if defined(HAVE_LIB_XAW)
+#include <X11/Xaw/Form.h>
+#elif defined(HAVE_LIB_XAW3D)
+#include <X11/Xaw3d/Form.h>
+#elif defined(HAVE_LIB_NEXTAW)
+#include <X11/neXtaw/Form.h>
+#elif defined(HAVE_LIB_XAWPLUS)
+#include <X11/XawPlus/Form.h>
+#endif
+
+#endif /* OPT_TOOLBAR */
+
+#include <pwd.h>
+#include <ctype.h>
+
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <main.h>
+#include <xstrings.h>
+#include <xtermcap.h>
+#include <xterm_io.h>
+
+#if OPT_WIDE_CHARS
+#include <charclass.h>
+#endif
+
+#ifdef __osf__
+#define USE_SYSV_SIGNALS
+#define WTMP
+#include <pty.h>               /* openpty() */
+#endif
+
+#ifdef __sgi
+#include <grp.h>               /* initgroups() */
+#endif
+
+#ifdef USE_ISPTS_FLAG
+static Bool IsPts = False;
+#endif
+
+#if defined(__SCO__) || defined(SVR4) || defined(_POSIX_SOURCE)
+#define USE_POSIX_SIGNALS
+#endif
+
+#if defined(SYSV) && !defined(SVR4) && !defined(ISC22) && !defined(ISC30)
+/* older SYSV systems cannot ignore SIGHUP.
+   Shell hangs, or you get extra shells, or something like that */
+#define USE_SYSV_SIGHUP
+#endif
+
+#if defined(sony) && defined(bsd43) && !defined(KANJI)
+#define KANJI
+#endif
+
+#ifdef linux
+#define USE_SYSV_PGRP
+#define USE_SYSV_SIGNALS
+#define WTMP
+#ifdef __GLIBC__
+#if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
+#include <pty.h>
+#endif
+#endif
+#endif
+
+#ifdef __MVS__
+#define USE_SYSV_PGRP
+#define USE_SYSV_SIGNALS
+#endif
+
+#ifdef __CYGWIN__
+#define WTMP
+#endif
+
+#ifdef __SCO__
+#ifndef _SVID3
+#define _SVID3
+#endif
+#endif
+
+#if defined(__GLIBC__) && !defined(linux)
+#define USE_SYSV_PGRP
+#define WTMP
+#define HAS_BSD_GROUPS
+#endif
+
+#if defined(USE_TTY_GROUP) || defined(USE_UTMP_SETGID)
+#include <grp.h>
+#endif
+
+#ifndef TTY_GROUP_NAME
+#define TTY_GROUP_NAME "tty"
+#endif
+
+#include <sys/stat.h>
+
+#ifdef Lynx
+#ifndef BSDLY
+#define BSDLY  0
+#endif
+#ifndef VTDLY
+#define VTDLY  0
+#endif
+#ifndef FFDLY
+#define FFDLY  0
+#endif
+#endif
+
+#ifdef SYSV                    /* { */
+
+#ifdef USE_USG_PTYS            /* AT&T SYSV has no ptyio.h */
+#include <sys/stropts.h>       /* for I_PUSH */
+#include <poll.h>              /* for POLLIN */
+#endif /* USE_USG_PTYS */
+
+#define USE_SYSV_SIGNALS
+#define        USE_SYSV_PGRP
+
+#if !defined(TIOCSWINSZ) || defined(__SCO__) || defined(__UNIXWARE__)
+#define USE_SYSV_ENVVARS       /* COLUMNS/LINES vs. TERMCAP */
+#endif
+
+/*
+ * now get system-specific includes
+ */
+#ifdef CRAY
+#define HAS_BSD_GROUPS
+#endif
+
+#ifdef macII
+#define HAS_BSD_GROUPS
+#include <sys/ttychars.h>
+#undef USE_SYSV_ENVVARS
+#undef FIOCLEX
+#undef FIONCLEX
+#define setpgrp2 setpgrp
+#include <sgtty.h>
+#include <sys/resource.h>
+#endif
+
+#ifdef __hpux
+#define HAS_BSD_GROUPS
+#include <sys/ptyio.h>
+#endif /* __hpux */
+
+#ifdef __osf__
+#define HAS_BSD_GROUPS
+#undef  USE_SYSV_PGRP
+#define setpgrp setpgid
+#endif
+
+#ifdef __sgi
+#define HAS_BSD_GROUPS
+#include <sys/sysmacros.h>
+#endif /* __sgi */
+
+#ifdef sun
+#include <sys/strredir.h>
+#endif
+
+#else  /* } !SYSV { */ /* BSD systems */
+
+#ifdef __QNX__
+
+#ifndef __QNXNTO__
+#define ttyslot() 1
+#else
+#define USE_SYSV_PGRP
+extern __inline__
+int
+ttyslot(void)
+{
+    return 1;                  /* yuk */
+}
+#endif
+
+#else
+
+#if defined(__INTERIX) || defined(__APPLE__)
+#define setpgrp setpgid
+#endif
+
+#ifndef linux
+#ifndef VMS
+#ifndef USE_POSIX_TERMIOS
+#ifndef USE_ANY_SYSV_TERMIO
+#include <sgtty.h>
+#endif
+#endif /* USE_POSIX_TERMIOS */
+#ifdef Lynx
+#include <resource.h>
+#else
+#include <sys/resource.h>
+#endif
+#ifndef __INTERIX
+#define HAS_BSD_GROUPS
+#endif
+#endif /* !VMS */
+#endif /* !linux */
+
+#endif /* __QNX__ */
+
+#endif /* } !SYSV */
+
+/* Xpoll.h and <sys/param.h> on glibc 2.1 systems have colliding NBBY's */
+#if defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
+#ifndef NOFILE
+#define NOFILE OPEN_MAX
+#endif
+#elif !(defined(VMS) || defined(WIN32) || defined(Lynx) || defined(__GNU__) || defined(__MVS__))
+#include <sys/param.h>         /* for NOFILE */
+#endif
+
+#if defined(BSD) && (BSD >= 199103)
+#define WTMP
+#endif
+
+#include <stdio.h>
+
+#ifdef __hpux
+#include <sys/utsname.h>
+#endif /* __hpux */
+
+#if defined(apollo) && (OSMAJORVERSION == 10) && (OSMINORVERSION < 4)
+#define ttyslot() 1
+#endif /* apollo */
+
+#if defined(UTMPX_FOR_UTMP)
+#define UTMP_STR utmpx
+#else
+#define UTMP_STR utmp
+#endif
+
+#if defined(USE_UTEMPTER)
+#include <utempter.h>
+#endif
+
+#if defined(UTMPX_FOR_UTMP)
+
+#include <utmpx.h>
+
+#define call_endutent  endutxent
+#define call_getutid   getutxid
+#define call_pututline pututxline
+#define call_setutent  setutxent
+#define call_updwtmp   updwtmpx
+
+#elif defined(HAVE_UTMP)
+
+#include <utmp.h>
+
+#if defined(_CRAY) && (OSMAJORVERSION < 8)
+extern struct utmp *getutid __((struct utmp * _Id));
+#endif
+
+#define call_endutent  endutent
+#define call_getutid   getutid
+#define call_pututline pututline
+#define call_setutent  setutent
+#define call_updwtmp   updwtmp
+
+#endif
+
+#if defined(USE_LASTLOG) && defined(HAVE_LASTLOG_H)
+#include <lastlog.h>           /* caution: glibc includes utmp.h here */
+#endif
+
+#ifndef USE_LASTLOGX
+#if defined(_NETBSD_SOURCE) && defined(_PATH_LASTLOGX)
+#define USE_LASTLOGX 1
+#endif
+#endif
+
+#ifdef  PUCC_PTYD
+#include <local/openpty.h>
+#endif /* PUCC_PTYD */
+
+#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
+#include <util.h>              /* openpty() */
+#endif
+
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+#include <libutil.h>           /* openpty() */
+#endif
+
+#if !defined(UTMP_FILENAME)
+#if defined(UTMP_FILE)
+#define UTMP_FILENAME UTMP_FILE
+#elif defined(_PATH_UTMP)
+#define UTMP_FILENAME _PATH_UTMP
+#else
+#define UTMP_FILENAME "/etc/utmp"
+#endif
+#endif
+
+#ifndef LASTLOG_FILENAME
+#ifdef _PATH_LASTLOG
+#define LASTLOG_FILENAME _PATH_LASTLOG
+#else
+#define LASTLOG_FILENAME "/usr/adm/lastlog"    /* only on BSD systems */
+#endif
+#endif
+
+#if !defined(WTMP_FILENAME)
+#if defined(WTMP_FILE)
+#define WTMP_FILENAME WTMP_FILE
+#elif defined(_PATH_WTMP)
+#define WTMP_FILENAME _PATH_WTMP
+#elif defined(SYSV)
+#define WTMP_FILENAME "/etc/wtmp"
+#else
+#define WTMP_FILENAME "/usr/adm/wtmp"
+#endif
+#endif
+
+#include <signal.h>
+
+#if defined(__SCO__) || (defined(ISC) && !defined(_POSIX_SOURCE))
+#undef SIGTSTP                 /* defined, but not the BSD way */
+#endif
+
+#ifdef SIGTSTP
+#include <sys/wait.h>
+#endif
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#undef ECHOKE
+#undef ECHOCTL
+#endif
+
+#if defined(HAVE_SYS_TTYDEFAULTS_H) && !defined(CEOF)
+#include <sys/ttydefaults.h>
+#endif
+
+#ifdef X_NOT_POSIX
+extern long lseek();
+#if defined(USG) || defined(SVR4)
+extern unsigned sleep();
+#else
+extern void sleep();
+#endif
+extern char *ttyname();
+#endif
+
+#if defined(SYSV) && defined(DECL_PTSNAME)
+extern char *ptsname(int);
+#endif
+
+#ifndef VMS
+static SIGNAL_T reapchild(int /* n */ );
+static int spawnXTerm(XtermWidget /* xw */ );
+static void remove_termcap_entry(char *, const char *);
+#ifdef USE_PTY_SEARCH
+static int pty_search(int * /* pty */ );
+#endif
+#endif /* ! VMS */
+
+static int get_pty(int *pty, char *from);
+static void resize_termcap(XtermWidget xw);
+static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode);
+
+static Bool added_utmp_entry = False;
+
+#ifdef HAVE_POSIX_SAVED_IDS
+static uid_t save_euid;
+static gid_t save_egid;
+#endif
+
+static uid_t save_ruid;
+static gid_t save_rgid;
+
+#if defined(USE_UTMP_SETGID)
+static int really_get_pty(int *pty, char *from);
+#endif
+
+#if defined(USE_SYSV_UTMP) && !defined(USE_UTEMPTER)
+static Bool xterm_exiting = False;
+#endif
+
+static char *explicit_shname = NULL;
+
+/*
+** Ordinarily it should be okay to omit the assignment in the following
+** statement. Apparently the c89 compiler on AIX 4.1.3 has a bug, or does
+** it? Without the assignment though the compiler will init command_to_exec
+** to 0xffffffff instead of NULL; and subsequent usage, e.g. in spawnXTerm() to
+** SEGV.
+*/
+static char **command_to_exec = NULL;
+
+#if OPT_LUIT_PROG
+static char **command_to_exec_with_luit = NULL;
+#endif
+
+#define TERMCAP_ERASE "kb"
+#define VAL_INITIAL_ERASE A2E(8)
+
+/* choose a nice default value for speed - if we make it too low, users who
+ * mistakenly use $TERM set to vt100 will get padding delays.  Setting it to a
+ * higher value is not useful since legacy applications (termcap) that care
+ * about padding generally store the code in a short, which does not have
+ * enough bits for the extended values.
+ */
+#ifdef B38400                  /* everyone should define this */
+#define VAL_LINE_SPEED B38400
+#else /* ...but xterm's used this for a long time */
+#define VAL_LINE_SPEED B9600
+#endif
+
+/*
+ * Allow use of system default characters if defined and reasonable.
+ * These are based on the BSD ttydefaults.h
+ */
+#ifndef CBRK
+#define CBRK     0xff          /* was 0 */
+#endif
+#ifndef CDISCARD
+#define CDISCARD CONTROL('O')
+#endif
+#ifndef CDSUSP
+#define CDSUSP   CONTROL('Y')
+#endif
+#ifndef CEOF
+#define CEOF     CONTROL('D')
+#endif
+#ifndef CEOL
+#define CEOL    0xff           /* was 0 */
+#endif
+#ifndef CERASE
+#define CERASE   0177
+#endif
+#ifndef CERASE2
+#define        CERASE2  CONTROL('H')
+#endif
+#ifndef CFLUSH
+#define CFLUSH   CONTROL('O')
+#endif
+#ifndef CINTR
+#define CINTR    CONTROL('C')
+#endif
+#ifndef CKILL
+#define CKILL   CONTROL('U')   /* was '@' */
+#endif
+#ifndef CLNEXT
+#define CLNEXT   CONTROL('V')
+#endif
+#ifndef CNUL
+#define CNUL     0
+#endif
+#ifndef CQUIT
+#define CQUIT    CONTROL('\\')
+#endif
+#ifndef CRPRNT
+#define CRPRNT   CONTROL('R')
+#endif
+#ifndef CREPRINT
+#define CREPRINT CRPRNT
+#endif
+#ifndef CSTART
+#define CSTART   CONTROL('Q')
+#endif
+#ifndef CSTATUS
+#define        CSTATUS  CONTROL('T')
+#endif
+#ifndef CSTOP
+#define CSTOP    CONTROL('S')
+#endif
+#ifndef CSUSP
+#define CSUSP    CONTROL('Z')
+#endif
+#ifndef CSWTCH
+#define CSWTCH   0
+#endif
+#ifndef CWERASE
+#define CWERASE  CONTROL('W')
+#endif
+
+#ifdef USE_ANY_SYSV_TERMIO
+#define TERMIO_STRUCT struct termio
+#define ttySetAttr(fd, datap) ioctl(fd, TCSETA, datap)
+#define ttyGetAttr(fd, datap) ioctl(fd, TCGETA, datap)
+#define ttyFlush(fd)          ioctl(fd, TCFLSH, 1)
+#elif defined(USE_POSIX_TERMIOS)
+#define TERMIO_STRUCT struct termios
+#define ttySetAttr(fd, datap) tcsetattr(fd, TCSANOW, datap)
+#define ttyGetAttr(fd, datap) tcgetattr(fd, datap)
+#define ttyFlush(fd)          tcflush(fd, TCOFLUSH)
+#endif /* USE_ANY_SYSV_TERMIO */
+
+#ifndef VMS
+#ifdef TERMIO_STRUCT
+/* The following structures are initialized in main() in order
+** to eliminate any assumptions about the internal order of their
+** contents.
+*/
+static TERMIO_STRUCT d_tio;
+
+#ifdef HAS_LTCHARS
+static struct ltchars d_ltc;
+#endif /* HAS_LTCHARS */
+
+#ifdef TIOCLSET
+static unsigned int d_lmode;
+#endif /* TIOCLSET */
+
+#else /* !TERMIO_STRUCT */
+static struct sgttyb d_sg =
+{
+    0, 0, 0177, CKILL, (EVENP | ODDP | ECHO | XTABS | CRMOD)
+};
+static struct tchars d_tc =
+{
+    CINTR, CQUIT, CSTART,
+    CSTOP, CEOF, CBRK
+};
+static struct ltchars d_ltc =
+{
+    CSUSP, CDSUSP, CRPRNT,
+    CFLUSH, CWERASE, CLNEXT
+};
+static int d_disipline = NTTYDISC;
+static long int d_lmode = LCRTBS | LCRTERA | LCRTKIL | LCTLECH;
+#ifdef sony
+static long int d_jmode = KM_SYSSJIS | KM_ASCII;
+static struct jtchars d_jtc =
+{
+    'J', 'B'
+};
+#endif /* sony */
+#endif /* TERMIO_STRUCT */
+#endif /* ! VMS */
+
+/*
+ * SYSV has the termio.c_cc[V] and ltchars; BSD has tchars and ltchars;
+ * SVR4 has only termio.c_cc, but it includes everything from ltchars.
+ * POSIX termios has termios.c_cc, which is similar to SVR4.
+ */
+#define TTYMODE(name) { name, sizeof(name)-1, 0, 0 }
+static Boolean override_tty_modes = False;
+/* *INDENT-OFF* */
+static struct _xttymodes {
+    const char *name;
+    size_t len;
+    int set;
+    int value;
+} ttymodelist[] = {
+    TTYMODE("intr"),           /* tchars.t_intrc ; VINTR */
+#define XTTYMODE_intr  0
+    TTYMODE("quit"),           /* tchars.t_quitc ; VQUIT */
+#define XTTYMODE_quit  1
+    TTYMODE("erase"),          /* sgttyb.sg_erase ; VERASE */
+#define XTTYMODE_erase 2
+    TTYMODE("kill"),           /* sgttyb.sg_kill ; VKILL */
+#define XTTYMODE_kill  3
+    TTYMODE("eof"),            /* tchars.t_eofc ; VEOF */
+#define XTTYMODE_eof   4
+    TTYMODE("eol"),            /* VEOL */
+#define XTTYMODE_eol   5
+    TTYMODE("swtch"),          /* VSWTCH */
+#define XTTYMODE_swtch 6
+    TTYMODE("start"),          /* tchars.t_startc ; VSTART */
+#define XTTYMODE_start 7
+    TTYMODE("stop"),           /* tchars.t_stopc ; VSTOP */
+#define XTTYMODE_stop  8
+    TTYMODE("brk"),            /* tchars.t_brkc */
+#define XTTYMODE_brk   9
+    TTYMODE("susp"),           /* ltchars.t_suspc ; VSUSP */
+#define XTTYMODE_susp  10
+    TTYMODE("dsusp"),          /* ltchars.t_dsuspc ; VDSUSP */
+#define XTTYMODE_dsusp 11
+    TTYMODE("rprnt"),          /* ltchars.t_rprntc ; VREPRINT */
+#define XTTYMODE_rprnt 12
+    TTYMODE("flush"),          /* ltchars.t_flushc ; VDISCARD */
+#define XTTYMODE_flush 13
+    TTYMODE("weras"),          /* ltchars.t_werasc ; VWERASE */
+#define XTTYMODE_weras 14
+    TTYMODE("lnext"),          /* ltchars.t_lnextc ; VLNEXT */
+#define XTTYMODE_lnext 15
+    TTYMODE("status"),         /* VSTATUS */
+#define XTTYMODE_status        16
+    TTYMODE("erase2"),         /* VERASE2 */
+#define XTTYMODE_erase2        17
+    TTYMODE("eol2"),           /* VEOL2 */
+#define XTTYMODE_eol2  18
+    { NULL,    0, 0, '\0' },   /* end of data */
+};
+
+#define validTtyChar(data, n) \
+           (known_ttyChars[n].sysMode >= 0 && \
+            known_ttyChars[n].sysMode < (int) XtNumber(data.c_cc))
+
+static const struct {
+    int sysMode;
+    int myMode;
+    int myDefault;
+} known_ttyChars[] = {
+#ifdef VINTR
+    { VINTR,    XTTYMODE_intr,   CINTR },
+#endif
+#ifdef VQUIT
+    { VQUIT,    XTTYMODE_quit,   CQUIT },
+#endif
+#ifdef VERASE
+    { VERASE,   XTTYMODE_erase,  CERASE },
+#endif
+#ifdef VKILL
+    { VKILL,    XTTYMODE_kill,   CKILL },
+#endif
+#ifdef VEOF
+    { VEOF,     XTTYMODE_eof,    CEOF },
+#endif
+#ifdef VEOL
+    { VEOL,     XTTYMODE_eol,    CEOL },
+#endif
+#ifdef VSWTCH
+    { VSWTCH,   XTTYMODE_swtch,  CNUL },
+#endif
+#ifdef VSTART
+    { VSTART,   XTTYMODE_start,  CSTART },
+#endif
+#ifdef VSTOP
+    { VSTOP,    XTTYMODE_stop,   CSTOP },
+#endif
+#ifdef VSUSP
+    { VSUSP,    XTTYMODE_susp,   CSUSP },
+#endif
+#ifdef VDSUSP
+    { VDSUSP,   XTTYMODE_dsusp,  CDSUSP },
+#endif
+#ifdef VREPRINT
+    { VREPRINT, XTTYMODE_rprnt,  CREPRINT },
+#endif
+#ifdef VDISCARD
+    { VDISCARD, XTTYMODE_flush,  CDISCARD },
+#endif
+#ifdef VWERASE
+    { VWERASE,  XTTYMODE_weras,  CWERASE },
+#endif
+#ifdef VLNEXT
+    { VLNEXT,   XTTYMODE_lnext,  CLNEXT },
+#endif
+#ifdef VSTATUS
+    { VSTATUS,  XTTYMODE_status, CSTATUS },
+#endif
+#ifdef VERASE2
+    { VERASE2,  XTTYMODE_erase2, CERASE2 },
+#endif
+#ifdef VEOL2
+    { VEOL2,    XTTYMODE_eol2,   CNUL },
+#endif
+};
+/* *INDENT-ON* */
+
+#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value
+
+static int parse_tty_modes(char *s, struct _xttymodes *modelist);
+
+#ifndef USE_UTEMPTER
+#ifdef USE_SYSV_UTMP
+#if (defined(AIXV3) && (OSMAJORVERSION < 4)) && !(defined(getutid))
+extern struct utmp *getutid();
+#endif /* AIXV3 */
+
+#else /* not USE_SYSV_UTMP */
+static char etc_utmp[] = UTMP_FILENAME;
+#endif /* USE_SYSV_UTMP */
+
+#if defined(USE_LASTLOG) && defined(USE_STRUCT_LASTLOG)
+static char etc_lastlog[] = LASTLOG_FILENAME;
+#else
+#undef USE_LASTLOG
+#endif
+
+#ifdef WTMP
+static char etc_wtmp[] = WTMP_FILENAME;
+#endif
+#endif /* !USE_UTEMPTER */
+
+/*
+ * Some people with 4.3bsd /bin/login seem to like to use login -p -f user
+ * to implement xterm -ls.  They can turn on USE_LOGIN_DASH_P and turn off
+ * WTMP and USE_LASTLOG.
+ */
+#ifdef USE_LOGIN_DASH_P
+#ifndef LOGIN_FILENAME
+#define LOGIN_FILENAME "/bin/login"
+#endif
+static char bin_login[] = LOGIN_FILENAME;
+#endif
+
+static char passedPty[PTYCHARLEN + 1]; /* name if pty if slave */
+
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+static int Console;
+#include <X11/Xmu/SysUtil.h>   /* XmuGetHostname */
+#define MIT_CONSOLE_LEN        12
+#define MIT_CONSOLE "MIT_CONSOLE_"
+static char mit_console_name[255 + MIT_CONSOLE_LEN + 1] = MIT_CONSOLE;
+static Atom mit_console;
+#endif /* TIOCCONS */
+
+#ifndef USE_SYSV_UTMP
+static int tslot;
+#endif /* USE_SYSV_UTMP */
+static sigjmp_buf env;
+
+#define SetUtmpHost(dst, screen) \
+       { \
+           char host[sizeof(dst) + 1]; \
+           strncpy(host, DisplayString(screen->display), sizeof(host)); \
+           TRACE(("DisplayString(%s)\n", host)); \
+           if (!resource.utmpDisplayId) { \
+               char *endptr = strrchr(host, ':'); \
+               if (endptr) { \
+                   TRACE(("trimming display-id '%s'\n", host)); \
+                   *endptr = '\0'; \
+               } \
+           } \
+           strncpy(dst, host, sizeof(dst)); \
+       }
+
+#ifdef HAVE_UTMP_UT_SYSLEN
+#  define SetUtmpSysLen(utmp)                     \
+       { \
+           utmp.ut_host[sizeof(utmp.ut_host)-1] = '\0'; \
+           utmp.ut_syslen = strlen(utmp.ut_host) + 1; \
+       }
+#endif
+
+/* used by VT (charproc.c) */
+
+static XtResource application_resources[] =
+{
+    Sres("name", "Name", xterm_name, DFT_TERMTYPE),
+    Sres("iconGeometry", "IconGeometry", icon_geometry, NULL),
+    Sres(XtNtitle, XtCTitle, title, NULL),
+    Sres(XtNiconName, XtCIconName, icon_name, NULL),
+    Sres("termName", "TermName", term_name, NULL),
+    Sres("ttyModes", "TtyModes", tty_modes, NULL),
+    Bres("hold", "Hold", hold_screen, False),
+    Bres("utmpInhibit", "UtmpInhibit", utmpInhibit, False),
+    Bres("utmpDisplayId", "UtmpDisplayId", utmpDisplayId, True),
+    Bres("messages", "Messages", messages, True),
+    Ires("minBufSize", "MinBufSize", minBufSize, 4096),
+    Ires("maxBufSize", "MaxBufSize", maxBufSize, 32768),
+    Sres("menuLocale", "MenuLocale", menuLocale, DEF_MENU_LOCALE),
+    Sres("keyboardType", "KeyboardType", keyboardType, "unknown"),
+#if OPT_SUNPC_KBD
+    Bres("sunKeyboard", "SunKeyboard", sunKeyboard, False),
+#endif
+#if OPT_HP_FUNC_KEYS
+    Bres("hpFunctionKeys", "HpFunctionKeys", hpFunctionKeys, False),
+#endif
+#if OPT_SCO_FUNC_KEYS
+    Bres("scoFunctionKeys", "ScoFunctionKeys", scoFunctionKeys, False),
+#endif
+#if OPT_SUN_FUNC_KEYS
+    Bres("sunFunctionKeys", "SunFunctionKeys", sunFunctionKeys, False),
+#endif
+#if OPT_TCAP_FKEYS
+    Bres("tcapFunctionKeys", "TcapFunctionKeys", termcapKeys, False),
+#endif
+#if OPT_INITIAL_ERASE
+    Bres("ptyInitialErase", "PtyInitialErase", ptyInitialErase, DEF_INITIAL_ERASE),
+    Bres("backarrowKeyIsErase", "BackarrowKeyIsErase", backarrow_is_erase, DEF_BACKARO_ERASE),
+#endif
+    Bres("useInsertMode", "UseInsertMode", useInsertMode, False),
+#if OPT_ZICONBEEP
+    Ires("zIconBeep", "ZIconBeep", zIconBeep, 0),
+#endif
+#if OPT_PTY_HANDSHAKE
+    Bres("waitForMap", "WaitForMap", wait_for_map, False),
+    Bres("ptyHandshake", "PtyHandshake", ptyHandshake, True),
+    Bres("ptySttySize", "PtySttySize", ptySttySize, DEF_PTY_STTY_SIZE),
+#endif
+#if OPT_SAME_NAME
+    Bres("sameName", "SameName", sameName, True),
+#endif
+#if OPT_SESSION_MGT
+    Bres("sessionMgt", "SessionMgt", sessionMgt, True),
+#endif
+#if OPT_TOOLBAR
+    Bres(XtNtoolBar, XtCToolBar, toolBar, True),
+#endif
+#if OPT_MAXIMIZE
+    Bres(XtNmaximized, XtCMaximized, maximized, False),
+#endif
+};
+
+static String fallback_resources[] =
+{
+    "*SimpleMenu*menuLabel.vertSpace: 100",
+    "*SimpleMenu*HorizontalMargins: 16",
+    "*SimpleMenu*Sme.height: 16",
+    "*SimpleMenu*Cursor: left_ptr",
+    "*mainMenu.Label:  Main Options (no app-defaults)",
+    "*vtMenu.Label:  VT Options (no app-defaults)",
+    "*fontMenu.Label:  VT Fonts (no app-defaults)",
+#if OPT_TEK4014
+    "*tekMenu.Label:  Tek Options (no app-defaults)",
+#endif
+    NULL
+};
+
+/* Command line options table.  Only resources are entered here...there is a
+   pass over the remaining options after XrmParseCommand is let loose. */
+/* *INDENT-OFF* */
+static XrmOptionDescRec optionDescList[] = {
+{"-geometry",  "*vt100.geometry",XrmoptionSepArg,      (XPointer) NULL},
+{"-132",       "*c132",        XrmoptionNoArg,         (XPointer) "on"},
+{"+132",       "*c132",        XrmoptionNoArg,         (XPointer) "off"},
+{"-ah",                "*alwaysHighlight", XrmoptionNoArg,     (XPointer) "on"},
+{"+ah",                "*alwaysHighlight", XrmoptionNoArg,     (XPointer) "off"},
+{"-aw",                "*autoWrap",    XrmoptionNoArg,         (XPointer) "on"},
+{"+aw",                "*autoWrap",    XrmoptionNoArg,         (XPointer) "off"},
+#ifndef NO_ACTIVE_ICON
+{"-ai",                "*activeIcon",  XrmoptionNoArg,         (XPointer) "off"},
+{"+ai",                "*activeIcon",  XrmoptionNoArg,         (XPointer) "on"},
+#endif /* NO_ACTIVE_ICON */
+{"-b",         "*internalBorder",XrmoptionSepArg,      (XPointer) NULL},
+{"-bc",                "*cursorBlink", XrmoptionNoArg,         (XPointer) "on"},
+{"+bc",                "*cursorBlink", XrmoptionNoArg,         (XPointer) "off"},
+{"-bcf",       "*cursorOffTime",XrmoptionSepArg,       (XPointer) NULL},
+{"-bcn",       "*cursorOnTime",XrmoptionSepArg,        (XPointer) NULL},
+{"-bdc",       "*colorBDMode", XrmoptionNoArg,         (XPointer) "off"},
+{"+bdc",       "*colorBDMode", XrmoptionNoArg,         (XPointer) "on"},
+{"-cb",                "*cutToBeginningOfLine", XrmoptionNoArg, (XPointer) "off"},
+{"+cb",                "*cutToBeginningOfLine", XrmoptionNoArg, (XPointer) "on"},
+{"-cc",                "*charClass",   XrmoptionSepArg,        (XPointer) NULL},
+{"-cm",                "*colorMode",   XrmoptionNoArg,         (XPointer) "off"},
+{"+cm",                "*colorMode",   XrmoptionNoArg,         (XPointer) "on"},
+{"-cn",                "*cutNewline",  XrmoptionNoArg,         (XPointer) "off"},
+{"+cn",                "*cutNewline",  XrmoptionNoArg,         (XPointer) "on"},
+{"-cr",                "*cursorColor", XrmoptionSepArg,        (XPointer) NULL},
+{"-cu",                "*curses",      XrmoptionNoArg,         (XPointer) "on"},
+{"+cu",                "*curses",      XrmoptionNoArg,         (XPointer) "off"},
+{"-dc",                "*dynamicColors",XrmoptionNoArg,        (XPointer) "off"},
+{"+dc",                "*dynamicColors",XrmoptionNoArg,        (XPointer) "on"},
+{"-fb",                "*boldFont",    XrmoptionSepArg,        (XPointer) NULL},
+{"-fbb",       "*freeBoldBox", XrmoptionNoArg,         (XPointer)"off"},
+{"+fbb",       "*freeBoldBox", XrmoptionNoArg,         (XPointer)"on"},
+{"-fbx",       "*forceBoxChars", XrmoptionNoArg,       (XPointer)"off"},
+{"+fbx",       "*forceBoxChars", XrmoptionNoArg,       (XPointer)"on"},
+#ifndef NO_ACTIVE_ICON
+{"-fi",                "*iconFont",    XrmoptionSepArg,        (XPointer) NULL},
+#endif /* NO_ACTIVE_ICON */
+#if OPT_RENDERFONT
+{"-fa",                "*faceName",    XrmoptionSepArg,        (XPointer) NULL},
+{"-fd",                "*faceNameDoublesize", XrmoptionSepArg, (XPointer) NULL},
+{"-fs",                "*faceSize",    XrmoptionSepArg,        (XPointer) NULL},
+#endif
+#if OPT_WIDE_CHARS
+{"-fw",                "*wideFont",    XrmoptionSepArg,        (XPointer) NULL},
+{"-fwb",       "*wideBoldFont", XrmoptionSepArg,       (XPointer) NULL},
+#endif
+#if OPT_INPUT_METHOD
+{"-fx",                "*ximFont",     XrmoptionSepArg,        (XPointer) NULL},
+#endif
+#if OPT_HIGHLIGHT_COLOR
+{"-hc",                "*highlightColor", XrmoptionSepArg,     (XPointer) NULL},
+{"-hm",                "*highlightColorMode", XrmoptionNoArg,  (XPointer) "on"},
+{"+hm",                "*highlightColorMode", XrmoptionNoArg,  (XPointer) "off"},
+{"-selfg",     "*highlightTextColor", XrmoptionSepArg, (XPointer) NULL},
+{"-selbg",     "*highlightColor", XrmoptionSepArg,     (XPointer) NULL},
+#endif
+#if OPT_HP_FUNC_KEYS
+{"-hf",                "*hpFunctionKeys",XrmoptionNoArg,       (XPointer) "on"},
+{"+hf",                "*hpFunctionKeys",XrmoptionNoArg,       (XPointer) "off"},
+#endif
+{"-hold",      "*hold",        XrmoptionNoArg,         (XPointer) "on"},
+{"+hold",      "*hold",        XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_INITIAL_ERASE
+{"-ie",                "*ptyInitialErase", XrmoptionNoArg,     (XPointer) "on"},
+{"+ie",                "*ptyInitialErase", XrmoptionNoArg,     (XPointer) "off"},
+#endif
+{"-j",         "*jumpScroll",  XrmoptionNoArg,         (XPointer) "on"},
+{"+j",         "*jumpScroll",  XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_C1_PRINT
+{"-k8",                "*allowC1Printable", XrmoptionNoArg,    (XPointer) "on"},
+{"+k8",                "*allowC1Printable", XrmoptionNoArg,    (XPointer) "off"},
+#endif
+{"-kt",                "*keyboardType", XrmoptionSepArg,       (XPointer) NULL},
+{"+kt",                "*keyboardType", XrmoptionSepArg,       (XPointer) NULL},
+/* parse logging options anyway for compatibility */
+{"-l",         "*logging",     XrmoptionNoArg,         (XPointer) "on"},
+{"+l",         "*logging",     XrmoptionNoArg,         (XPointer) "off"},
+{"-lf",                "*logFile",     XrmoptionSepArg,        (XPointer) NULL},
+{"-ls",                "*loginShell",  XrmoptionNoArg,         (XPointer) "on"},
+{"+ls",                "*loginShell",  XrmoptionNoArg,         (XPointer) "off"},
+{"-mb",                "*marginBell",  XrmoptionNoArg,         (XPointer) "on"},
+{"+mb",                "*marginBell",  XrmoptionNoArg,         (XPointer) "off"},
+{"-mc",                "*multiClickTime", XrmoptionSepArg,     (XPointer) NULL},
+{"-mesg",      "*messages",    XrmoptionNoArg,         (XPointer) "off"},
+{"+mesg",      "*messages",    XrmoptionNoArg,         (XPointer) "on"},
+{"-ms",                "*pointerColor",XrmoptionSepArg,        (XPointer) NULL},
+{"-nb",                "*nMarginBell", XrmoptionSepArg,        (XPointer) NULL},
+{"-nul",       "*underLine",   XrmoptionNoArg,         (XPointer) "off"},
+{"+nul",       "*underLine",   XrmoptionNoArg,         (XPointer) "on"},
+{"-pc",                "*boldColors",  XrmoptionNoArg,         (XPointer) "on"},
+{"+pc",                "*boldColors",  XrmoptionNoArg,         (XPointer) "off"},
+{"-rw",                "*reverseWrap", XrmoptionNoArg,         (XPointer) "on"},
+{"+rw",                "*reverseWrap", XrmoptionNoArg,         (XPointer) "off"},
+{"-s",         "*multiScroll", XrmoptionNoArg,         (XPointer) "on"},
+{"+s",         "*multiScroll", XrmoptionNoArg,         (XPointer) "off"},
+{"-sb",                "*scrollBar",   XrmoptionNoArg,         (XPointer) "on"},
+{"+sb",                "*scrollBar",   XrmoptionNoArg,         (XPointer) "off"},
+#ifdef SCROLLBAR_RIGHT
+{"-leftbar",   "*rightScrollBar", XrmoptionNoArg,      (XPointer) "off"},
+{"-rightbar",  "*rightScrollBar", XrmoptionNoArg,      (XPointer) "on"},
+#endif
+{"-rvc",       "*colorRVMode", XrmoptionNoArg,         (XPointer) "off"},
+{"+rvc",       "*colorRVMode", XrmoptionNoArg,         (XPointer) "on"},
+{"-sf",                "*sunFunctionKeys", XrmoptionNoArg,     (XPointer) "on"},
+{"+sf",                "*sunFunctionKeys", XrmoptionNoArg,     (XPointer) "off"},
+{"-si",                "*scrollTtyOutput", XrmoptionNoArg,     (XPointer) "off"},
+{"+si",                "*scrollTtyOutput", XrmoptionNoArg,     (XPointer) "on"},
+{"-sk",                "*scrollKey",   XrmoptionNoArg,         (XPointer) "on"},
+{"+sk",                "*scrollKey",   XrmoptionNoArg,         (XPointer) "off"},
+{"-sl",                "*saveLines",   XrmoptionSepArg,        (XPointer) NULL},
+#if OPT_SUNPC_KBD
+{"-sp",                "*sunKeyboard", XrmoptionNoArg,         (XPointer) "on"},
+{"+sp",                "*sunKeyboard", XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_TEK4014
+{"-t",         "*tekStartup",  XrmoptionNoArg,         (XPointer) "on"},
+{"+t",         "*tekStartup",  XrmoptionNoArg,         (XPointer) "off"},
+#endif
+{"-ti",                "*decTerminalID",XrmoptionSepArg,       (XPointer) NULL},
+{"-tm",                "*ttyModes",    XrmoptionSepArg,        (XPointer) NULL},
+{"-tn",                "*termName",    XrmoptionSepArg,        (XPointer) NULL},
+#if OPT_WIDE_CHARS
+{"-u8",                "*utf8",        XrmoptionNoArg,         (XPointer) "2"},
+{"+u8",                "*utf8",        XrmoptionNoArg,         (XPointer) "0"},
+#endif
+#if OPT_LUIT_PROG
+{"-lc",                "*locale",      XrmoptionNoArg,         (XPointer) "on"},
+{"+lc",                "*locale",      XrmoptionNoArg,         (XPointer) "off"},
+{"-lcc",       "*localeFilter",XrmoptionSepArg,        (XPointer) NULL},
+{"-en",                "*locale",      XrmoptionSepArg,        (XPointer) NULL},
+#endif
+{"-uc",                "*cursorUnderLine", XrmoptionNoArg,     (XPointer) "on"},
+{"+uc",                "*cursorUnderLine", XrmoptionNoArg,     (XPointer) "off"},
+{"-ulc",       "*colorULMode", XrmoptionNoArg,         (XPointer) "off"},
+{"+ulc",       "*colorULMode", XrmoptionNoArg,         (XPointer) "on"},
+{"-ulit",       "*italicULMode", XrmoptionNoArg,        (XPointer) "off"},
+{"+ulit",       "*italicULMode", XrmoptionNoArg,        (XPointer) "on"},
+{"-ut",                "*utmpInhibit", XrmoptionNoArg,         (XPointer) "on"},
+{"+ut",                "*utmpInhibit", XrmoptionNoArg,         (XPointer) "off"},
+{"-im",                "*useInsertMode", XrmoptionNoArg,       (XPointer) "on"},
+{"+im",                "*useInsertMode", XrmoptionNoArg,       (XPointer) "off"},
+{"-vb",                "*visualBell",  XrmoptionNoArg,         (XPointer) "on"},
+{"+vb",                "*visualBell",  XrmoptionNoArg,         (XPointer) "off"},
+{"-pob",       "*popOnBell",   XrmoptionNoArg,         (XPointer) "on"},
+{"+pob",       "*popOnBell",   XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_WIDE_CHARS
+{"-wc",                "*wideChars",   XrmoptionNoArg,         (XPointer) "on"},
+{"+wc",                "*wideChars",   XrmoptionNoArg,         (XPointer) "off"},
+{"-mk_width",  "*mkWidth",     XrmoptionNoArg,         (XPointer) "on"},
+{"+mk_width",  "*mkWidth",     XrmoptionNoArg,         (XPointer) "off"},
+{"-cjk_width", "*cjkWidth",    XrmoptionNoArg,         (XPointer) "on"},
+{"+cjk_width", "*cjkWidth",    XrmoptionNoArg,         (XPointer) "off"},
+#endif
+{"-wf",                "*waitForMap",  XrmoptionNoArg,         (XPointer) "on"},
+{"+wf",                "*waitForMap",  XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_ZICONBEEP
+{"-ziconbeep", "*zIconBeep",   XrmoptionSepArg,        (XPointer) NULL},
+#endif
+#if OPT_SAME_NAME
+{"-samename",  "*sameName",    XrmoptionNoArg,         (XPointer) "on"},
+{"+samename",  "*sameName",    XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_SESSION_MGT
+{"-sm",                "*sessionMgt",  XrmoptionNoArg,         (XPointer) "on"},
+{"+sm",                "*sessionMgt",  XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_TOOLBAR
+{"-tb",                "*"XtNtoolBar,  XrmoptionNoArg,         (XPointer) "on"},
+{"+tb",                "*"XtNtoolBar,  XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_MAXIMIZE
+{"-maximized", "*maximized",   XrmoptionNoArg,         (XPointer) "on"},
+{"+maximized", "*maximized",   XrmoptionNoArg,         (XPointer) "off"},
+#endif
+/* options that we process ourselves */
+{"-help",      NULL,           XrmoptionSkipNArgs,     (XPointer) NULL},
+{"-version",   NULL,           XrmoptionSkipNArgs,     (XPointer) NULL},
+{"-class",     NULL,           XrmoptionSkipArg,       (XPointer) NULL},
+{"-e",         NULL,           XrmoptionSkipLine,      (XPointer) NULL},
+{"-into",      NULL,           XrmoptionSkipArg,       (XPointer) NULL},
+/* bogus old compatibility stuff for which there are
+   standard XtOpenApplication options now */
+{"%",          "*tekGeometry", XrmoptionStickyArg,     (XPointer) NULL},
+{"#",          ".iconGeometry",XrmoptionStickyArg,     (XPointer) NULL},
+{"-T",         ".title",       XrmoptionSepArg,        (XPointer) NULL},
+{"-n",         "*iconName",    XrmoptionSepArg,        (XPointer) NULL},
+{"-r",         "*reverseVideo",XrmoptionNoArg,         (XPointer) "on"},
+{"+r",         "*reverseVideo",XrmoptionNoArg,         (XPointer) "off"},
+{"-rv",                "*reverseVideo",XrmoptionNoArg,         (XPointer) "on"},
+{"+rv",                "*reverseVideo",XrmoptionNoArg,         (XPointer) "off"},
+{"-w",         ".borderWidth", XrmoptionSepArg,        (XPointer) NULL},
+};
+
+static OptionHelp xtermOptions[] = {
+{ "-version",              "print the version number" },
+{ "-help",                 "print out this message" },
+{ "-display displayname",  "X server to contact" },
+{ "-geometry geom",        "size (in characters) and position" },
+{ "-/+rv",                 "turn on/off reverse video" },
+{ "-bg color",             "background color" },
+{ "-fg color",             "foreground color" },
+{ "-bd color",             "border color" },
+{ "-bw number",            "border width in pixels" },
+{ "-fn fontname",          "normal text font" },
+{ "-fb fontname",          "bold text font" },
+{ "-/+fbb",                "turn on/off normal/bold font comparison inhibit"},
+{ "-/+fbx",                "turn off/on linedrawing characters"},
+#if OPT_RENDERFONT
+{ "-fa pattern",           "FreeType font-selection pattern" },
+{ "-fd pattern",           "FreeType Doublesize font-selection pattern" },
+{ "-fs size",              "FreeType font-size" },
+#endif
+#if OPT_WIDE_CHARS
+{ "-fw fontname",          "doublewidth text font" },
+{ "-fwb fontname",         "doublewidth bold text font" },
+#endif
+#if OPT_INPUT_METHOD
+{ "-fx fontname",          "XIM fontset" },
+#endif
+{ "-iconic",               "start iconic" },
+{ "-name string",          "client instance, icon, and title strings" },
+{ "-class string",         "class string (XTerm)" },
+{ "-title string",         "title string" },
+{ "-xrm resourcestring",   "additional resource specifications" },
+{ "-/+132",                "turn on/off 80/132 column switching" },
+{ "-/+ah",                 "turn on/off always highlight" },
+#ifndef NO_ACTIVE_ICON
+{ "-/+ai",                 "turn off/on active icon" },
+{ "-fi fontname",          "icon font for active icon" },
+#endif /* NO_ACTIVE_ICON */
+{ "-b number",             "internal border in pixels" },
+{ "-/+bc",                 "turn on/off text cursor blinking" },
+{ "-bcf milliseconds",     "time text cursor is off when blinking"},
+{ "-bcn milliseconds",     "time text cursor is on when blinking"},
+{ "-/+bdc",                "turn off/on display of bold as color"},
+{ "-/+cb",                 "turn on/off cut-to-beginning-of-line inhibit" },
+{ "-cc classrange",        "specify additional character classes" },
+{ "-/+cm",                 "turn off/on ANSI color mode" },
+{ "-/+cn",                 "turn on/off cut newline inhibit" },
+{ "-cr color",             "text cursor color" },
+{ "-/+cu",                 "turn on/off curses emulation" },
+{ "-/+dc",                 "turn off/on dynamic color selection" },
+#if OPT_HIGHLIGHT_COLOR
+{ "-/+hm",                 "turn on/off selection-color override" },
+{ "-selbg color",          "selection background color" },
+{ "-selfg color",          "selection foreground color" },
+#endif
+#if OPT_HP_FUNC_KEYS
+{ "-/+hf",                 "turn on/off HP Function Key escape codes" },
+#endif
+{ "-/+hold",               "turn on/off logic that retains window after exit" },
+#if OPT_INITIAL_ERASE
+{ "-/+ie",                 "turn on/off initialization of 'erase' from pty" },
+#endif
+{ "-/+im",                 "use insert mode for TERMCAP" },
+{ "-/+j",                  "turn on/off jump scroll" },
+#if OPT_C1_PRINT
+{ "-/+k8",                 "turn on/off C1-printable classification"},
+#endif
+{ "-kt keyboardtype",      "set keyboard type:" KEYBOARD_TYPES },
+#ifdef ALLOWLOGGING
+{ "-/+l",                  "turn on/off logging" },
+{ "-lf filename",          "logging filename" },
+#else
+{ "-/+l",                  "turn on/off logging (not supported)" },
+{ "-lf filename",          "logging filename (not supported)" },
+#endif
+{ "-/+ls",                 "turn on/off login shell" },
+{ "-/+mb",                 "turn on/off margin bell" },
+{ "-mc milliseconds",      "multiclick time in milliseconds" },
+{ "-/+mesg",               "forbid/allow messages" },
+{ "-ms color",             "pointer color" },
+{ "-nb number",            "margin bell in characters from right end" },
+{ "-/+nul",                "turn off/on display of underlining" },
+{ "-/+aw",                 "turn on/off auto wraparound" },
+{ "-/+pc",                 "turn on/off PC-style bold colors" },
+{ "-/+rw",                 "turn on/off reverse wraparound" },
+{ "-/+s",                  "turn on/off multiscroll" },
+{ "-/+sb",                 "turn on/off scrollbar" },
+#ifdef SCROLLBAR_RIGHT
+{ "-rightbar",             "force scrollbar right (default left)" },
+{ "-leftbar",              "force scrollbar left" },
+#endif
+{ "-/+rvc",                "turn off/on display of reverse as color" },
+{ "-/+sf",                 "turn on/off Sun Function Key escape codes" },
+{ "-/+si",                 "turn on/off scroll-on-tty-output inhibit" },
+{ "-/+sk",                 "turn on/off scroll-on-keypress" },
+{ "-sl number",            "number of scrolled lines to save" },
+#if OPT_SUNPC_KBD
+{ "-/+sp",                 "turn on/off Sun/PC Function/Keypad mapping" },
+#endif
+#if OPT_TEK4014
+{ "-/+t",                  "turn on/off Tek emulation window" },
+#endif
+#if OPT_TOOLBAR
+{ "-/+tb",                 "turn on/off toolbar" },
+#endif
+{ "-ti termid",            "terminal identifier" },
+{ "-tm string",            "terminal mode keywords and characters" },
+{ "-tn name",              "TERM environment variable name" },
+#if OPT_WIDE_CHARS
+{ "-/+u8",                 "turn on/off UTF-8 mode (implies wide-characters)" },
+#endif
+#if OPT_LUIT_PROG
+{ "-/+lc",                 "turn on/off locale mode using luit" },
+{ "-lcc path",             "filename of locale converter (" DEFLOCALEFILTER ")" },
+#endif
+{ "-/+uc",                 "turn on/off underline cursor" },
+{ "-/+ulc",                "turn off/on display of underline as color" },
+{ "-/+ulit",               "turn off/on display of underline as italics" },
+#ifdef HAVE_UTMP
+{ "-/+ut",                 "turn on/off utmp support" },
+#else
+{ "-/+ut",                 "turn on/off utmp support (not available)" },
+#endif
+{ "-/+vb",                 "turn on/off visual bell" },
+{ "-/+pob",                "turn on/off pop on bell" },
+#if OPT_WIDE_CHARS
+{ "-/+wc",                 "turn on/off wide-character mode" },
+{ "-/+mk_width",           "turn on/off simple width convention" },
+{ "-/+cjk_width",          "turn on/off legacy CJK width convention" },
+#endif
+{ "-/+wf",                 "turn on/off wait for map before command exec" },
+{ "-e command args ...",   "command to execute" },
+#if OPT_TEK4014
+{ "%geom",                 "Tek window geometry" },
+#endif
+{ "#geom",                 "icon window geometry" },
+{ "-T string",             "title name for window" },
+{ "-n string",             "icon name for window" },
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+{ "-C",                    "intercept console messages" },
+#else
+{ "-C",                    "intercept console messages (not supported)" },
+#endif
+{ "-Sccn",                 "slave mode on \"ttycc\", file descriptor \"n\"" },
+{ "-into windowId",        "use the window id given to -into as the parent window rather than the default root window" },
+#if OPT_ZICONBEEP
+{ "-ziconbeep percent",    "beep and flag icon of window having hidden output" },
+#endif
+#if OPT_SAME_NAME
+{ "-/+samename",           "turn on/off the no-flicker option for title and icon name" },
+#endif
+#if OPT_SESSION_MGT
+{ "-/+sm",                 "turn on/off the session-management support" },
+#endif
+#if OPT_MAXIMIZE
+{"-/+maximized",           "turn on/off maxmize on startup" },
+#endif
+{ NULL, NULL }};
+/* *INDENT-ON* */
+
+static const char *message[] =
+{
+    "Fonts should be fixed width and, if both normal and bold are specified, should",
+    "have the same size.  If only a normal font is specified, it will be used for",
+    "both normal and bold text (by doing overstriking).  The -e option, if given,",
+    "must appear at the end of the command line, otherwise the user's default shell",
+    "will be started.  Options that start with a plus sign (+) restore the default.",
+    NULL};
+
+/*
+ * Decode a key-definition.  This combines the termcap and ttyModes, for
+ * comparison.  Note that octal escapes in ttyModes are done by the normal
+ * resource translation.  Also, ttyModes allows '^-' as a synonym for disabled.
+ */
+static int
+decode_keyvalue(char **ptr, int termcap)
+{
+    char *string = *ptr;
+    int value = -1;
+
+    TRACE(("decode_keyvalue '%s'\n", string));
+    if (*string == '^') {
+       switch (*++string) {
+       case '?':
+           value = A2E(ANSI_DEL);
+           break;
+       case '-':
+           if (!termcap) {
+               errno = 0;
+#if defined(_POSIX_VDISABLE) && defined(HAVE_UNISTD_H)
+               value = _POSIX_VDISABLE;
+#endif
+#if defined(_PC_VDISABLE)
+               if (value == -1) {
+                   value = (int) fpathconf(0, _PC_VDISABLE);
+                   if (value == -1) {
+                       if (errno != 0)
+                           break;      /* skip this (error) */
+                       value = 0377;
+                   }
+               }
+#elif defined(VDISABLE)
+               if (value == -1)
+                   value = VDISABLE;
+#endif
+               break;
+           }
+           /* FALLTHRU */
+       default:
+           value = CONTROL(*string);
+           break;
+       }
+       ++string;
+    } else if (termcap && (*string == '\\')) {
+       char *d;
+       int temp = (int) strtol(string + 1, &d, 8);
+       if (temp > 0 && d != string) {
+           value = temp;
+           string = d;
+       }
+    } else {
+       value = CharOf(*string);
+       ++string;
+    }
+    *ptr = string;
+    TRACE(("...decode_keyvalue %#x\n", value));
+    return value;
+}
+
+static int
+abbrev(const char *tst, const char *cmp, size_t need)
+{
+    size_t len = strlen(tst);
+    return ((len >= need) && (!strncmp(tst, cmp, len)));
+}
+
+static void
+Syntax(char *badOption)
+{
+    OptionHelp *opt;
+    OptionHelp *list = sortedOpts(xtermOptions, optionDescList, XtNumber(optionDescList));
+    int col;
+
+    fprintf(stderr, "%s:  bad command line option \"%s\"\r\n\n",
+           ProgramName, badOption);
+
+    fprintf(stderr, "usage:  %s", ProgramName);
+    col = 8 + (int) strlen(ProgramName);
+    for (opt = list; opt->opt; opt++) {
+       int len = 3 + (int) strlen(opt->opt);   /* space [ string ] */
+       if (col + len > 79) {
+           fprintf(stderr, "\r\n   ");         /* 3 spaces */
+           col = 3;
+       }
+       fprintf(stderr, " [%s]", opt->opt);
+       col += len;
+    }
+
+    fprintf(stderr, "\r\n\nType %s -help for a full description.\r\n\n",
+           ProgramName);
+    exit(1);
+}
+
+static void
+Version(void)
+{
+    printf("%s\n", xtermVersion());
+    fflush(stdout);
+}
+
+static void
+Help(void)
+{
+    OptionHelp *opt;
+    OptionHelp *list = sortedOpts(xtermOptions, optionDescList, XtNumber(optionDescList));
+    const char **cpp;
+
+    printf("%s usage:\n    %s [-options ...] [-e command args]\n\n",
+          xtermVersion(), ProgramName);
+    printf("where options include:\n");
+    for (opt = list; opt->opt; opt++) {
+       printf("    %-28s %s\n", opt->opt, opt->desc);
+    }
+
+    putchar('\n');
+    for (cpp = message; *cpp; cpp++)
+       puts(*cpp);
+    putchar('\n');
+    fflush(stdout);
+}
+
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+/* ARGSUSED */
+static Boolean
+ConvertConsoleSelection(Widget w GCC_UNUSED,
+                       Atom * selection GCC_UNUSED,
+                       Atom * target GCC_UNUSED,
+                       Atom * type GCC_UNUSED,
+                       XtPointer *value GCC_UNUSED,
+                       unsigned long *length GCC_UNUSED,
+                       int *format GCC_UNUSED)
+{
+    /* we don't save console output, so can't offer it */
+    return False;
+}
+#endif /* TIOCCONS */
+
+#if OPT_SESSION_MGT
+static void
+die_callback(Widget w GCC_UNUSED,
+            XtPointer client_data GCC_UNUSED,
+            XtPointer call_data GCC_UNUSED)
+{
+    Cleanup(0);
+}
+
+static void
+save_callback(Widget w GCC_UNUSED,
+             XtPointer client_data GCC_UNUSED,
+             XtPointer call_data)
+{
+    XtCheckpointToken token = (XtCheckpointToken) call_data;
+    /* we have nothing to save */
+    token->save_success = True;
+}
+
+static void
+icewatch(IceConn iceConn,
+        IcePointer clientData GCC_UNUSED,
+        Bool opening,
+        IcePointer * watchData GCC_UNUSED)
+{
+    if (opening) {
+       ice_fd = IceConnectionNumber(iceConn);
+       TRACE(("got IceConnectionNumber %d\n", ice_fd));
+    } else {
+       ice_fd = -1;
+       TRACE(("reset IceConnectionNumber\n"));
+    }
+}
+
+#endif /* OPT_SESSION_MGT */
+
+/*
+ * DeleteWindow(): Action proc to implement ICCCM delete_window.
+ */
+/* ARGSUSED */
+static void
+DeleteWindow(Widget w,
+            XEvent * event GCC_UNUSED,
+            String * params GCC_UNUSED,
+            Cardinal *num_params GCC_UNUSED)
+{
+#if OPT_TEK4014
+    if (w == toplevel) {
+       if (TEK4014_SHOWN(term))
+           hide_vt_window();
+       else
+           do_hangup(w, (XtPointer) 0, (XtPointer) 0);
+    } else if (TScreenOf(term)->Vshow)
+       hide_tek_window();
+    else
+#endif
+       do_hangup(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+static void
+KeyboardMapping(Widget w GCC_UNUSED,
+               XEvent * event,
+               String * params GCC_UNUSED,
+               Cardinal *num_params GCC_UNUSED)
+{
+    switch (event->type) {
+    case MappingNotify:
+       XRefreshKeyboardMapping(&event->xmapping);
+       break;
+    }
+}
+
+static XtActionsRec actionProcs[] =
+{
+    {"DeleteWindow", DeleteWindow},
+    {"KeyboardMapping", KeyboardMapping},
+};
+
+/*
+ * Some platforms use names such as /dev/tty01, others /dev/pts/1.  Parse off
+ * the "tty01" or "pts/1" portion, and return that for use as an identifier for
+ * utmp.
+ */
+static char *
+my_pty_name(char *device)
+{
+    size_t len = strlen(device);
+    Bool name = False;
+
+    while (len != 0) {
+       int ch = device[len - 1];
+       if (isdigit(ch)) {
+           len--;
+       } else if (ch == '/') {
+           if (name)
+               break;
+           len--;
+       } else if (isalpha(ch)) {
+           name = True;
+           len--;
+       } else {
+           break;
+       }
+    }
+    TRACE(("my_pty_name(%s) -> '%s'\n", device, device + len));
+    return device + len;
+}
+
+/*
+ * If the name contains a '/', it is a "pts/1" case.  Otherwise, return the
+ * last few characters for a utmp identifier.
+ */
+static char *
+my_pty_id(char *device)
+{
+    char *name = my_pty_name(device);
+    char *leaf = x_basename(name);
+
+    if (name == leaf) {                /* no '/' in the name */
+       int len = (int) strlen(leaf);
+       if (PTYCHARLEN < len)
+           leaf = leaf + (len - PTYCHARLEN);
+    }
+    TRACE(("my_pty_id  (%s) -> '%s'\n", device, leaf));
+    return leaf;
+}
+
+/*
+ * Set the tty/pty identifier
+ */
+static void
+set_pty_id(char *device, char *id)
+{
+    char *name = my_pty_name(device);
+    char *leaf = x_basename(name);
+
+    if (name == leaf) {
+       strcpy(my_pty_id(device), id);
+    } else {
+       strcpy(leaf, id);
+    }
+    TRACE(("set_pty_id(%s) -> '%s'\n", id, device));
+}
+
+/*
+ * The original -S option accepts two characters to identify the pty, and a
+ * file-descriptor (assumed to be nonzero).  That is not general enough, so we
+ * check first if the option contains a '/' to delimit the two fields, and if
+ * not, fall-thru to the original logic.
+ */
+static Bool
+ParseSccn(char *option)
+{
+    char *leaf = x_basename(option);
+    Bool code = False;
+
+    if (leaf != option) {
+       if (leaf - option > 0
+           && isdigit(CharOf(*leaf))
+           && sscanf(leaf, "%d", &am_slave) == 1) {
+           size_t len = (size_t) (leaf - option - 1);
+           /*
+            * If we have a slash, we only care about the part after the slash,
+            * which is a file-descriptor.  The part before the slash can be
+            * the /dev/pts/XXX value, but since we do not need to reopen it,
+            * it is useful mainly for display in a "ps -ef".
+            */
+           strncpy(passedPty, option, len);
+           passedPty[len] = 0;
+           code = True;
+       }
+    } else {
+       code = (sscanf(option, "%c%c%d",
+                      passedPty, passedPty + 1, &am_slave) == 3);
+    }
+    TRACE(("ParseSccn(%s) = '%s' %d (%s)\n", option,
+          passedPty, am_slave, code ? "OK" : "ERR"));
+    return code;
+}
+
+#if defined(USE_SYSV_UTMP) && !defined(USE_UTEMPTER)
+/*
+ * From "man utmp":
+ * xterm and other terminal emulators directly create a USER_PROCESS record
+ * and generate the ut_id by using the last two letters of /dev/ttyp%c or by
+ * using p%d for /dev/pts/%d.  If they find a DEAD_PROCESS for this id, they
+ * recycle it, otherwise they create a new entry.  If they can, they will mark
+ * it as DEAD_PROCESS on exiting and it is advised that they null ut_line,
+ * ut_time, ut_user and ut_host as well.
+ *
+ * Generally ut_id allows no more than 3 characters (plus null), even if the
+ * pty implementation allows more than 3 digits.
+ */
+static char *
+my_utmp_id(char *device)
+{
+    typedef struct UTMP_STR UTMP_STRUCT;
+#define        UTIDSIZE        (sizeof(((UTMP_STRUCT *)NULL)->ut_id))
+    static char result[UTIDSIZE + 1];
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+    /*
+     * Legend does not support old-style pty's, has no related compatibility
+     * issues, and can use the available space in ut_id differently from the
+     * default convention.
+     *
+     * This scheme is intended to avoid conflicts both with other users of
+     * utmpx as well as between multiple xterms.  First, Legend uses all of the
+     * characters of ut_id, and adds no terminating NUL is required (the
+     * default scheme may add a trailing NUL).  Second, all xterm entries will
+     * start with the letter 'x' followed by three digits, which will be the
+     * last three digits of the device name, regardless of the format of the
+     * device name, with leading 0's added where necessary.  For instance, an
+     * xterm on /dev/pts/3 will have a ut_id of x003; an xterm on /dev/pts123
+     * will have a ut_id of x123.  Under the other convention, /dev/pts/3 would
+     * have a ut_id of p3 and /dev/pts123 would have a ut_id of p123.
+     */
+    int len, n;
+
+    len = strlen(device);
+    n = UTIDSIZE;
+    result[n] = '\0';
+    while ((n > 0) && (len > 0) && isdigit(device[len - 1]))
+       result[--n] = device[--len];
+    while (n > 0)
+       result[--n] = '0';
+    result[0] = 'x';
+#else
+    char *name = my_pty_name(device);
+    char *leaf = x_basename(name);
+    size_t len = strlen(leaf);
+
+    if ((UTIDSIZE - 1) < len)
+       leaf = leaf + (len - (UTIDSIZE - 1));
+    sprintf(result, "p%s", leaf);
+#endif
+
+    TRACE(("my_utmp_id (%s) -> '%s'\n", device, result));
+    return result;
+}
+#endif /* USE_SYSV_UTMP */
+
+#ifdef USE_POSIX_SIGNALS
+
+typedef void (*sigfunc) (int);
+
+/* make sure we sure we ignore SIGCHLD for the cases parent
+   has just been stopped and not actually killed */
+
+static sigfunc
+posix_signal(int signo, sigfunc func)
+{
+    struct sigaction act, oact;
+
+    act.sa_handler = func;
+    sigemptyset(&act.sa_mask);
+#ifdef SA_RESTART
+    act.sa_flags = SA_NOCLDSTOP | SA_RESTART;
+#else
+    act.sa_flags = SA_NOCLDSTOP;
+#endif
+    if (sigaction(signo, &act, &oact) < 0)
+       return (SIG_ERR);
+    return (oact.sa_handler);
+}
+
+#endif /* linux && _POSIX_SOURCE */
+
+#if defined(DISABLE_SETUID) || defined(USE_UTMP_SETGID)
+static void
+disableSetUid(void)
+{
+    TRACE(("process %d disableSetUid\n", (int) getpid()));
+    if (setuid(save_ruid) == -1) {
+       fprintf(stderr, "%s: unable to reset uid\n", ProgramName);
+       exit(1);
+    }
+    TRACE_IDS;
+}
+#else
+#define disableSetUid()                /* nothing */
+#endif /* DISABLE_SETUID */
+
+#if defined(DISABLE_SETGID) || defined(USE_UTMP_SETGID)
+static void
+disableSetGid(void)
+{
+    TRACE(("process %d disableSetGid\n", (int) getpid()));
+    if (setegid(save_rgid) == -1) {
+       fprintf(stderr, "%s: unable to reset effective gid\n", ProgramName);
+       exit(1);
+    }
+    TRACE_IDS;
+}
+#else
+#define disableSetGid()                /* nothing */
+#endif /* DISABLE_SETGID */
+
+#if defined(HAVE_POSIX_SAVED_IDS)
+#if (!defined(USE_UTEMPTER) || !defined(DISABLE_SETGID))
+static void
+setEffectiveGroup(gid_t group)
+{
+    TRACE(("process %d setEffectiveGroup(%d)\n", (int) getpid(), (int) group));
+    if (setegid(group) == -1) {
+#ifdef __MVS__
+       if (!(errno == EMVSERR))        /* could happen if _BPX_SHAREAS=REUSE */
+#endif
+       {
+           (void) fprintf(stderr, "setegid(%d): %s\n",
+                          (int) group, strerror(errno));
+       }
+    }
+    TRACE_IDS;
+}
+#endif
+
+#if !defined(USE_UTMP_SETGID) && (!defined(USE_UTEMPTER) || !defined(DISABLE_SETUID))
+static void
+setEffectiveUser(uid_t user)
+{
+    TRACE(("process %d setEffectiveUser(%d)\n", (int) getpid(), (int) user));
+    if (seteuid(user) == -1) {
+#ifdef __MVS__
+       if (!(errno == EMVSERR))
+#endif
+       {
+           (void) fprintf(stderr, "seteuid(%d): %s\n",
+                          (int) user, strerror(errno));
+       }
+    }
+    TRACE_IDS;
+}
+#endif
+#endif /* HAVE_POSIX_SAVED_IDS */
+
+int
+main(int argc, char *argv[]ENVP_ARG)
+{
+    Widget form_top, menu_top;
+    Dimension menu_high;
+    TScreen *screen;
+    int mode;
+    char *my_class = DEFCLASS;
+    Window winToEmbedInto = None;
+
+    ProgramName = argv[0];
+
+#ifdef HAVE_POSIX_SAVED_IDS
+    save_euid = geteuid();
+    save_egid = getegid();
+#endif
+
+    save_ruid = getuid();
+    save_rgid = getgid();
+
+#if defined(DISABLE_SETUID) || defined(DISABLE_SETGID)
+#if defined(DISABLE_SETUID)
+    disableSetUid();
+#endif
+#if defined(DISABLE_SETGID)
+    disableSetGid();
+#endif
+    TRACE_IDS;
+#endif
+
+    /* extra length in case longer tty name like /dev/ttyq255 */
+    ttydev = TypeMallocN(char, sizeof(TTYDEV) + 80);
+#ifdef USE_PTY_DEVICE
+    ptydev = TypeMallocN(char, sizeof(PTYDEV) + 80);
+    if (!ttydev || !ptydev)
+#else
+    if (!ttydev)
+#endif
+    {
+       fprintf(stderr,
+               "%s: unable to allocate memory for ttydev or ptydev\n",
+               ProgramName);
+       exit(1);
+    }
+    strcpy(ttydev, TTYDEV);
+#ifdef USE_PTY_DEVICE
+    strcpy(ptydev, PTYDEV);
+#endif
+
+#if defined(USE_UTMP_SETGID)
+    get_pty(NULL, NULL);
+    disableSetUid();
+    disableSetGid();
+    TRACE_IDS;
+#define get_pty(pty, from) really_get_pty(pty, from)
+#endif
+
+    /* Do these first, since we may not be able to open the display */
+    TRACE_OPTS(xtermOptions, optionDescList, XtNumber(optionDescList));
+    TRACE_ARGV("Before XtOpenApplication", argv);
+    if (argc > 1) {
+       int n;
+       size_t unique = 2;
+       Bool quit = True;
+
+       for (n = 1; n < argc; n++) {
+           TRACE(("parsing %s\n", argv[n]));
+           if (abbrev(argv[n], "-version", unique)) {
+               Version();
+           } else if (abbrev(argv[n], "-help", unique)) {
+               Help();
+           } else if (abbrev(argv[n], "-class", (size_t) 3)) {
+               if ((my_class = argv[++n]) == 0) {
+                   Help();
+               } else {
+                   quit = False;
+               }
+               unique = 3;
+           } else {
+               quit = False;
+               unique = 3;
+           }
+       }
+       if (quit)
+           exit(0);
+    }
+
+    /* This dumps core on HP-UX 9.05 with X11R5 */
+#if OPT_I18N_SUPPORT
+    XtSetLanguageProc(NULL, NULL, NULL);
+#endif
+
+#ifdef TERMIO_STRUCT           /* { */
+    /* Initialization is done here rather than above in order
+     * to prevent any assumptions about the order of the contents
+     * of the various terminal structures (which may change from
+     * implementation to implementation).
+     */
+    memset(&d_tio, 0, sizeof(d_tio));
+    d_tio.c_iflag = ICRNL | IXON;
+#ifdef TAB3
+    d_tio.c_oflag = OPOST | ONLCR | TAB3;
+#else
+#ifdef ONLCR
+    d_tio.c_oflag = OPOST | ONLCR;
+#else
+    d_tio.c_oflag = OPOST;
+#endif
+#endif
+    {
+       Cardinal nn;
+
+       /* fill in default-values */
+       for (nn = 0; nn < XtNumber(known_ttyChars); ++nn) {
+           if (validTtyChar(d_tio, nn)) {
+               d_tio.c_cc[known_ttyChars[nn].sysMode] =
+                   known_ttyChars[nn].myDefault;
+           }
+       }
+    }
+#if defined(macII) || defined(ATT) || defined(CRAY)    /* { */
+    d_tio.c_cflag = VAL_LINE_SPEED | CS8 | CREAD | PARENB | HUPCL;
+    d_tio.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK;
+#ifdef ECHOKE
+    d_tio.c_lflag |= ECHOKE | IEXTEN;
+#endif
+#ifdef ECHOCTL
+    d_tio.c_lflag |= ECHOCTL | IEXTEN;
+#endif
+#ifndef USE_TERMIOS            /* { */
+    d_tio.c_line = 0;
+#endif /* } */
+#ifdef HAS_LTCHARS             /* { */
+    d_ltc.t_suspc = CSUSP;     /* t_suspc */
+    d_ltc.t_dsuspc = CDSUSP;   /* t_dsuspc */
+    d_ltc.t_rprntc = CRPRNT;
+    d_ltc.t_flushc = CFLUSH;
+    d_ltc.t_werasc = CWERASE;
+    d_ltc.t_lnextc = CLNEXT;
+#endif /* } HAS_LTCHARS */
+#ifdef TIOCLSET                        /* { */
+    d_lmode = 0;
+#endif /* } TIOCLSET */
+#else /* }{ else !macII, ATT, CRAY */
+#ifndef USE_POSIX_TERMIOS
+#ifdef BAUD_0                  /* { */
+    d_tio.c_cflag = CS8 | CREAD | PARENB | HUPCL;
+#else /* }{ !BAUD_0 */
+    d_tio.c_cflag = VAL_LINE_SPEED | CS8 | CREAD | PARENB | HUPCL;
+#endif /* } !BAUD_0 */
+#else /* USE_POSIX_TERMIOS */
+    d_tio.c_cflag = CS8 | CREAD | PARENB | HUPCL;
+    cfsetispeed(&d_tio, VAL_LINE_SPEED);
+    cfsetospeed(&d_tio, VAL_LINE_SPEED);
+#endif
+    d_tio.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK;
+#ifdef ECHOKE
+    d_tio.c_lflag |= ECHOKE | IEXTEN;
+#endif
+#ifdef ECHOCTL
+    d_tio.c_lflag |= ECHOCTL | IEXTEN;
+#endif
+#ifndef USE_POSIX_TERMIOS
+#ifdef NTTYDISC
+    d_tio.c_line = NTTYDISC;
+#else
+    d_tio.c_line = 0;
+#endif
+#endif /* USE_POSIX_TERMIOS */
+#ifdef __sgi
+    d_tio.c_cflag &= ~(HUPCL | PARENB);
+    d_tio.c_iflag |= BRKINT | ISTRIP | IGNPAR;
+#endif
+#ifdef __MVS__
+    d_tio.c_cflag &= ~(HUPCL | PARENB);
+#endif
+    {
+       Cardinal nn;
+       int i;
+
+       /* try to inherit tty settings */
+       for (i = 0; i <= 2; i++) {
+           TERMIO_STRUCT deftio;
+           if (ttyGetAttr(i, &deftio) == 0) {
+               for (nn = 0; nn < XtNumber(known_ttyChars); ++nn) {
+                   if (validTtyChar(d_tio, nn)) {
+                       d_tio.c_cc[known_ttyChars[nn].sysMode] =
+                           deftio.c_cc[known_ttyChars[nn].sysMode];
+                   }
+               }
+               break;
+           }
+       }
+    }
+#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */
+    d_tio.c_cc[VMIN] = 1;
+    d_tio.c_cc[VTIME] = 0;
+#endif /* } */
+#ifdef HAS_LTCHARS             /* { */
+    d_ltc.t_suspc = CharOf('\000');    /* t_suspc */
+    d_ltc.t_dsuspc = CharOf('\000');   /* t_dsuspc */
+    d_ltc.t_rprntc = CharOf('\377');   /* reserved... */
+    d_ltc.t_flushc = CharOf('\377');
+    d_ltc.t_werasc = CharOf('\377');
+    d_ltc.t_lnextc = CharOf('\377');
+#endif /* } HAS_LTCHARS */
+
+#ifdef TIOCLSET                        /* { */
+    d_lmode = 0;
+#endif /* } TIOCLSET */
+#endif /* } macII, ATT, CRAY */
+#endif /* } TERMIO_STRUCT */
+
+    /* Init the Toolkit. */
+    {
+#if defined(HAVE_POSIX_SAVED_IDS) && !defined(USE_UTMP_SETGID) && !defined(USE_UTEMPTER)
+       setEffectiveGroup(save_rgid);
+       setEffectiveUser(save_ruid);
+       TRACE_IDS;
+#endif
+
+       XtSetErrorHandler(xt_error);
+#if OPT_SESSION_MGT
+       toplevel = XtOpenApplication(&app_con, my_class,
+                                    optionDescList,
+                                    XtNumber(optionDescList),
+                                    &argc, argv, fallback_resources,
+                                    sessionShellWidgetClass,
+                                    NULL, 0);
+       IceAddConnectionWatch(icewatch, NULL);
+#else
+       toplevel = XtAppInitialize(&app_con, my_class,
+                                  optionDescList,
+                                  XtNumber(optionDescList),
+                                  &argc, argv, fallback_resources,
+                                  NULL, 0);
+#endif /* OPT_SESSION_MGT */
+       XtSetErrorHandler((XtErrorHandler) 0);
+
+       XtGetApplicationResources(toplevel, (XtPointer) &resource,
+                                 application_resources,
+                                 XtNumber(application_resources), NULL, 0);
+       TRACE_XRES();
+#if OPT_PTY_HANDSHAKE
+       resource.wait_for_map0 = resource.wait_for_map;
+#endif
+
+#if defined(HAVE_POSIX_SAVED_IDS) && !defined(USE_UTMP_SETGID)
+#if !defined(DISABLE_SETUID) || !defined(DISABLE_SETGID)
+#if !defined(DISABLE_SETUID)
+       setEffectiveUser(save_euid);
+#endif
+#if !defined(DISABLE_SETGID)
+       setEffectiveGroup(save_egid);
+#endif
+       TRACE_IDS;
+#endif
+#endif
+    }
+
+    /*
+     * ICCCM delete_window.
+     */
+    XtAppAddActions(app_con, actionProcs, XtNumber(actionProcs));
+
+    /*
+     * fill in terminal modes
+     */
+    if (resource.tty_modes) {
+       int n = parse_tty_modes(resource.tty_modes, ttymodelist);
+       if (n < 0) {
+           fprintf(stderr, "%s:  bad tty modes \"%s\"\n",
+                   ProgramName, resource.tty_modes);
+       } else if (n > 0) {
+           override_tty_modes = True;
+       }
+    }
+#if OPT_ZICONBEEP
+    if (resource.zIconBeep > 100 || resource.zIconBeep < -100) {
+       resource.zIconBeep = 0; /* was 100, but I prefer to defaulting off. */
+       fprintf(stderr,
+               "a number between -100 and 100 is required for zIconBeep.  0 used by default\n");
+    }
+#endif /* OPT_ZICONBEEP */
+    hold_screen = resource.hold_screen ? 1 : 0;
+    xterm_name = resource.xterm_name;
+    if (strcmp(xterm_name, "-") == 0)
+       xterm_name = DFT_TERMTYPE;
+    if (resource.icon_geometry != NULL) {
+       int scr, junk;
+       int ix, iy;
+       Arg args[2];
+
+       for (scr = 0;           /* yyuucchh */
+            XtScreen(toplevel) != ScreenOfDisplay(XtDisplay(toplevel), scr);
+            scr++) ;
+
+       args[0].name = XtNiconX;
+       args[1].name = XtNiconY;
+       XGeometry(XtDisplay(toplevel), scr, resource.icon_geometry, "",
+                 0, 0, 0, 0, 0, &ix, &iy, &junk, &junk);
+       args[0].value = (XtArgVal) ix;
+       args[1].value = (XtArgVal) iy;
+       XtSetValues(toplevel, args, 2);
+    }
+
+    XtSetValues(toplevel, ourTopLevelShellArgs,
+               number_ourTopLevelShellArgs);
+
+#if OPT_WIDE_CHARS
+    /* seems as good a place as any */
+    init_classtab();
+#endif
+
+    /* Parse the rest of the command line */
+    TRACE_ARGV("After XtOpenApplication", argv);
+    for (argc--, argv++; argc > 0; argc--, argv++) {
+#ifdef VMS
+       if (**argv != '-')
+           Syntax(*argv);
+#else
+       if (**argv != '-') {
+           if (argc > 1)
+               Syntax(*argv);
+           if (command_to_exec == 0)   /* if no "-e" option */
+               explicit_shname = xtermFindShell(*argv, True);
+           continue;
+       }
+#endif
+
+       TRACE(("parsing %s\n", argv[0]));
+       switch (argv[0][1]) {
+       case 'h':               /* -help */
+           Help();
+           continue;
+       case 'v':               /* -version */
+           Version();
+           continue;
+       case 'C':
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+#ifndef __sgi
+           {
+               struct stat sbuf;
+
+               /* Must be owner and have read/write permission.
+                  xdm cooperates to give the console the right user. */
+               if (!stat("/dev/console", &sbuf) &&
+                   (sbuf.st_uid == save_ruid) &&
+                   !access("/dev/console", R_OK | W_OK)) {
+                   Console = True;
+               } else
+                   Console = False;
+           }
+#else /* __sgi */
+           Console = True;
+#endif /* __sgi */
+#endif /* TIOCCONS */
+           continue;
+       case 'S':
+           if (!ParseSccn(*argv + 2))
+               Syntax(*argv);
+           continue;
+#ifdef DEBUG
+       case 'D':
+           debug = True;
+           continue;
+#endif /* DEBUG */
+       case 'c':               /* -class param */
+           if (strcmp(argv[0] + 1, "class") == 0)
+               argc--, argv++;
+           else
+               Syntax(*argv);
+           continue;
+       case 'e':
+           if (argc <= 1)
+               Syntax(*argv);
+           command_to_exec = ++argv;
+           break;
+       case 'i':
+           if (argc <= 1) {
+               Syntax(*argv);
+           } else {
+               char *endPtr;
+               --argc;
+               ++argv;
+               winToEmbedInto = (Window) strtol(argv[0], &endPtr, 10);
+           }
+           continue;
+
+       default:
+           Syntax(*argv);
+       }
+       break;
+    }
+
+    SetupMenus(toplevel, &form_top, &menu_top, &menu_high);
+
+    term = (XtermWidget) XtVaCreateManagedWidget("vt100", xtermWidgetClass,
+                                                form_top,
+#if OPT_TOOLBAR
+                                                XtNmenuBar, menu_top,
+                                                XtNresizable, True,
+                                                XtNfromVert, menu_top,
+                                                XtNleft, XawChainLeft,
+                                                XtNright, XawChainRight,
+                                                XtNtop, XawChainTop,
+                                                XtNbottom, XawChainBottom,
+                                                XtNmenuHeight, menu_high,
+#endif
+                                                (XtPointer) 0);
+    decode_keyboard_type(term, &resource);
+
+    screen = TScreenOf(term);
+    screen->inhibit = 0;
+
+#ifdef ALLOWLOGGING
+    if (term->misc.logInhibit)
+       screen->inhibit |= I_LOG;
+#endif
+    if (term->misc.signalInhibit)
+       screen->inhibit |= I_SIGNAL;
+#if OPT_TEK4014
+    if (term->misc.tekInhibit)
+       screen->inhibit |= I_TEK;
+#endif
+
+    /*
+     * We might start by showing the tek4014 window.
+     */
+#if OPT_TEK4014
+    if (screen->inhibit & I_TEK)
+       TEK4014_ACTIVE(term) = False;
+
+    if (TEK4014_ACTIVE(term) && !TekInit())
+       SysError(ERROR_INIT);
+#endif
+
+    /*
+     * Start the toolbar at this point, after the first window has been setup.
+     */
+#if OPT_TOOLBAR
+    ShowToolbar(resource.toolBar);
+#endif
+
+#if OPT_SESSION_MGT
+    if (resource.sessionMgt) {
+       TRACE(("Enabling session-management callbacks\n"));
+       XtAddCallback(toplevel, XtNdieCallback, die_callback, NULL);
+       XtAddCallback(toplevel, XtNsaveCallback, save_callback, NULL);
+    }
+#endif
+
+    /*
+     * Set title and icon name if not specified
+     */
+    if (command_to_exec) {
+       Arg args[2];
+
+       if (!resource.title) {
+           if (command_to_exec) {
+               resource.title = x_basename(command_to_exec[0]);
+           }                   /* else not reached */
+       }
+
+       if (!resource.icon_name)
+           resource.icon_name = resource.title;
+       XtSetArg(args[0], XtNtitle, resource.title);
+       XtSetArg(args[1], XtNiconName, resource.icon_name);
+
+       TRACE(("setting:\n\ttitle \"%s\"\n\ticon \"%s\"\n\tbased on command \"%s\"\n",
+              resource.title,
+              resource.icon_name,
+              *command_to_exec));
+
+       XtSetValues(toplevel, args, 2);
+    }
+#if OPT_LUIT_PROG
+    if (term->misc.callfilter) {
+       int u = (term->misc.use_encoding ? 2 : 0);
+       if (command_to_exec) {
+           int n;
+           char **c;
+           for (n = 0, c = command_to_exec; *c; n++, c++) ;
+           c = TypeMallocN(char *, (unsigned) (n + 3 + u));
+           if (c == NULL)
+               SysError(ERROR_LUMALLOC);
+           memcpy(c + 2 + u, command_to_exec, (unsigned) (n + 1) * sizeof(char *));
+           c[0] = term->misc.localefilter;
+           if (u) {
+               c[1] = "-encoding";
+               c[2] = term->misc.locale_str;
+           }
+           c[1 + u] = "--";
+           command_to_exec_with_luit = c;
+       } else {
+           static char *luit[6];
+           luit[0] = term->misc.localefilter;
+           if (u) {
+               luit[1] = "-encoding";
+               luit[2] = term->misc.locale_str;
+               luit[3] = NULL;
+           } else
+               luit[1] = NULL;
+           command_to_exec_with_luit = luit;
+       }
+    }
+#endif
+
+#ifdef DEBUG
+    {
+       /* Set up stderr properly.  Opening this log file cannot be
+          done securely by a privileged xterm process (although we try),
+          so the debug feature is disabled by default. */
+       char dbglogfile[45];
+       int i = -1;
+       if (debug) {
+           timestamp_filename(dbglogfile, "xterm.debug.log.");
+           if (creat_as(save_ruid, save_rgid, False, dbglogfile, 0666) > 0) {
+               i = open(dbglogfile, O_WRONLY | O_TRUNC);
+           }
+       }
+       if (i >= 0) {
+           dup2(i, 2);
+
+           /* mark this file as close on exec */
+           (void) fcntl(i, F_SETFD, 1);
+       }
+    }
+#endif /* DEBUG */
+
+    spawnXTerm(term);
+
+#ifndef VMS
+    /* Child process is out there, let's catch its termination */
+
+#ifdef USE_POSIX_SIGNALS
+    (void) posix_signal(SIGCHLD, reapchild);
+#else
+    (void) signal(SIGCHLD, reapchild);
+#endif
+    /* Realize procs have now been executed */
+
+    if (am_slave >= 0) {       /* Write window id so master end can read and use */
+       char buf[80];
+
+       buf[0] = '\0';
+       sprintf(buf, "%lx\n", XtWindow(SHELL_OF(CURRENT_EMU())));
+       IGNORE_RC(write(screen->respond, buf, strlen(buf)));
+    }
+#ifdef AIXV3
+#if (OSMAJORVERSION < 4)
+    /* In AIXV3, xterms started from /dev/console have CLOCAL set.
+     * This means we need to clear CLOCAL so that SIGHUP gets sent
+     * to the slave-pty process when xterm exits.
+     */
+
+    {
+       TERMIO_STRUCT tio;
+
+       if (ttyGetAttr(screen->respond, &tio) == -1)
+           SysError(ERROR_TIOCGETP);
+
+       tio.c_cflag &= ~(CLOCAL);
+
+       if (ttySetAttr(screen->respond, &tio) == -1)
+           SysError(ERROR_TIOCSETP);
+    }
+#endif
+#endif
+#if defined(USE_ANY_SYSV_TERMIO) || defined(__MVS__)
+    if (0 > (mode = fcntl(screen->respond, F_GETFL, 0)))
+       SysError(ERROR_F_GETFL);
+#ifdef O_NDELAY
+    mode |= O_NDELAY;
+#else
+    mode |= O_NONBLOCK;
+#endif /* O_NDELAY */
+    if (fcntl(screen->respond, F_SETFL, mode))
+       SysError(ERROR_F_SETFL);
+#else /* !USE_ANY_SYSV_TERMIO */
+    mode = 1;
+    if (ioctl(screen->respond, FIONBIO, (char *) &mode) == -1)
+       SysError(ERROR_FIONBIO);
+#endif /* USE_ANY_SYSV_TERMIO, etc */
+
+    /* The erase character is used to delete the current completion */
+#if OPT_DABBREV
+#ifdef TERMIO_STRUCT
+    screen->dabbrev_erase_char = d_tio.c_cc[VERASE];
+#else
+    screen->dabbrev_erase_char = d_sg.sg_erase;
+#endif
+    TRACE(("set dabbrev erase_char %#x\n", screen->dabbrev_erase_char));
+#endif
+
+    FD_ZERO(&pty_mask);
+    FD_ZERO(&X_mask);
+    FD_ZERO(&Select_mask);
+    FD_SET(screen->respond, &pty_mask);
+    FD_SET(ConnectionNumber(screen->display), &X_mask);
+    FD_SET(screen->respond, &Select_mask);
+    FD_SET(ConnectionNumber(screen->display), &Select_mask);
+    max_plus1 = ((screen->respond < ConnectionNumber(screen->display))
+                ? (1 + ConnectionNumber(screen->display))
+                : (1 + screen->respond));
+
+#endif /* !VMS */
+#ifdef DEBUG
+    if (debug)
+       printf("debugging on\n");
+#endif /* DEBUG */
+    XSetErrorHandler(xerror);
+    XSetIOErrorHandler(xioerror);
+
+    initPtyData(&VTbuffer);
+#ifdef ALLOWLOGGING
+    if (term->misc.log_on) {
+       StartLog(term);
+    }
+#endif
+
+    if (winToEmbedInto != None) {
+       XtRealizeWidget(toplevel);
+       /*
+        * This should probably query the tree or check the attributes of
+        * winToEmbedInto in order to verify that it exists, but I'm still not
+        * certain what is the best way to do it -GPS
+        */
+       XReparentWindow(XtDisplay(toplevel),
+                       XtWindow(toplevel),
+                       winToEmbedInto, 0, 0);
+    }
+#if OPT_COLOR_RES
+    TRACE(("checking reverseVideo before rv %s fg %s, bg %s\n",
+          term->misc.re_verse0 ? "reverse" : "normal",
+          NonNull(TScreenOf(term)->Tcolors[TEXT_FG].resource),
+          NonNull(TScreenOf(term)->Tcolors[TEXT_BG].resource)));
+
+    if (term->misc.re_verse0) {
+       if (isDefaultForeground(TScreenOf(term)->Tcolors[TEXT_FG].resource)
+           && isDefaultBackground(TScreenOf(term)->Tcolors[TEXT_BG].resource)) {
+           TScreenOf(term)->Tcolors[TEXT_FG].resource = x_strdup(XtDefaultBackground);
+           TScreenOf(term)->Tcolors[TEXT_BG].resource = x_strdup(XtDefaultForeground);
+       } else {
+           ReverseVideo(term);
+       }
+       term->misc.re_verse = True;
+       update_reversevideo();
+       TRACE(("updated  reverseVideo after  rv %s fg %s, bg %s\n",
+              term->misc.re_verse ? "reverse" : "normal",
+              NonNull(TScreenOf(term)->Tcolors[TEXT_FG].resource),
+              NonNull(TScreenOf(term)->Tcolors[TEXT_BG].resource)));
+    }
+#endif /* OPT_COLOR_RES */
+
+#if OPT_MAXIMIZE
+    if (resource.maximized)
+       RequestMaximize(term, True);
+#endif
+    for (;;) {
+#if OPT_TEK4014
+       if (TEK4014_ACTIVE(term))
+           TekRun();
+       else
+#endif
+           VTRun(term);
+    }
+}
+
+#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+#define USE_OPENPTY 1
+static int opened_tty = -1;
+#endif
+
+/*
+ * This function opens up a pty master and stuffs its value into pty.
+ *
+ * If it finds one, it returns a value of 0.  If it does not find one,
+ * it returns a value of !0.  This routine is designed to be re-entrant,
+ * so that if a pty master is found and later, we find that the slave
+ * has problems, we can re-enter this function and get another one.
+ */
+static int
+get_pty(int *pty, char *from GCC_UNUSED)
+{
+    int result = 1;
+
+#if defined(PUCC_PTYD)
+
+    result = ((*pty = openrpty(ttydev, ptydev,
+                              (resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN),
+                              save_ruid, from)) < 0);
+
+#elif defined(USE_OPENPTY)
+
+    result = openpty(pty, &opened_tty, ttydev, NULL, NULL);
+
+#elif defined(__QNXNTO__)
+
+    result = pty_search(pty);
+
+#else
+#if defined(USE_ISPTS_FLAG)
+
+    /*
+       The order of this code is *important*.  On SYSV/386 we want to open
+       a /dev/ttyp? first if at all possible.  If none are available, then
+       we'll try to open a /dev/pts??? device.
+
+       The reason for this is because /dev/ttyp? works correctly, where
+       as /dev/pts??? devices have a number of bugs, (won't update
+       screen correcly, will hang -- it more or less works, but you
+       really don't want to use it).
+
+       Most importantly, for boxes of this nature, one of the major
+       "features" is that you can emulate a 8086 by spawning off a UNIX
+       program on 80386/80486 in v86 mode.  In other words, you can spawn
+       off multiple MS-DOS environments.  On ISC the program that does
+       this is named "vpix."  The catcher is that "vpix" will *not* work
+       with a /dev/pts??? device, will only work with a /dev/ttyp? device.
+
+       Since we can open either a /dev/ttyp? or a /dev/pts??? device,
+       the flag "IsPts" is set here so that we know which type of
+       device we're dealing with in routine spawnXTerm().  That's the reason
+       for the "if (IsPts)" statement in spawnXTerm(); we have two different
+       device types which need to be handled differently.
+     */
+    result = pty_search(pty);
+    if (!result)
+       IsPts = 0;
+
+#endif
+#if defined(USE_USG_PTYS) || defined(__CYGWIN__)
+#ifdef __GLIBC__               /* if __GLIBC__ and USE_USG_PTYS, we know glibc >= 2.1 */
+    /* GNU libc 2 allows us to abstract away from having to know the
+       master pty device name. */
+    if ((*pty = getpt()) >= 0) {
+       char *name = ptsname(*pty);
+       if (name != 0) {        /* if filesystem is trashed, this may be null */
+           strcpy(ttydev, name);
+           result = 0;
+       }
+    }
+#elif defined(__MVS__)
+    result = pty_search(pty);
+#else
+#if defined(USE_ISPTS_FLAG)
+    if (result) {
+#endif
+       result = ((*pty = open("/dev/ptmx", O_RDWR)) < 0);
+#endif
+#if defined(SVR4) || defined(__SCO__) || defined(USE_ISPTS_FLAG)
+       if (!result)
+           strcpy(ttydev, ptsname(*pty));
+#ifdef USE_ISPTS_FLAG
+       IsPts = !result;        /* true if we're successful */
+    }
+#endif
+#endif
+
+#elif defined(AIXV3)
+
+    if ((*pty = open("/dev/ptc", O_RDWR)) >= 0) {
+       strcpy(ttydev, ttyname(*pty));
+       result = 0;
+    }
+#elif defined(__convex__)
+
+    char *pty_name;
+    extern char *getpty(void);
+
+    while ((pty_name = getpty()) != NULL) {
+       if ((*pty = open(pty_name, O_RDWR)) >= 0) {
+           strcpy(ptydev, pty_name);
+           strcpy(ttydev, pty_name);
+           *x_basename(ttydev) = 't';
+           result = 0;
+           break;
+       }
+    }
+
+#elif defined(sequent)
+
+    result = ((*pty = getpseudotty(&ttydev, &ptydev)) < 0);
+
+#elif defined(__sgi) && (OSMAJORVERSION >= 4)
+
+    char *tty_name;
+
+    tty_name = _getpty(pty, O_RDWR, 0622, 0);
+    if (tty_name != 0) {
+       strcpy(ttydev, tty_name);
+       result = 0;
+    }
+#elif (defined(__sgi) && (OSMAJORVERSION < 4)) || (defined(umips) && defined (SYSTYPE_SYSV))
+
+    struct stat fstat_buf;
+
+    *pty = open("/dev/ptc", O_RDWR);
+    if (*pty >= 0 && (fstat(*pty, &fstat_buf)) >= 0) {
+       result = 0;
+       sprintf(ttydev, "/dev/ttyq%d", minor(fstat_buf.st_rdev));
+    }
+#elif defined(__hpux)
+
+    /*
+     * Use the clone device if it works, otherwise use pty_search logic.
+     */
+    if ((*pty = open("/dev/ptym/clone", O_RDWR)) >= 0) {
+       char *name = ptsname(*pty);
+       if (name != 0) {
+           strcpy(ttydev, name);
+           result = 0;
+       } else {                /* permissions, or other unexpected problem */
+           close(*pty);
+           *pty = -1;
+           result = pty_search(pty);
+       }
+    } else {
+       result = pty_search(pty);
+    }
+
+#else
+
+    result = pty_search(pty);
+
+#endif
+#endif
+
+    TRACE(("get_pty(ttydev=%s, ptydev=%s) %s fd=%d\n",
+          ttydev != 0 ? ttydev : "?",
+          ptydev != 0 ? ptydev : "?",
+          result ? "FAIL" : "OK",
+          pty != 0 ? *pty : -1));
+    return result;
+}
+
+static void
+set_pty_permissions(uid_t uid, gid_t gid, mode_t mode)
+{
+#ifdef USE_TTY_GROUP
+    struct group *ttygrp;
+
+    if ((ttygrp = getgrnam(TTY_GROUP_NAME)) != 0) {
+       gid = ttygrp->gr_gid;
+       mode &= 0660U;
+    }
+    endgrent();
+#endif /* USE_TTY_GROUP */
+
+    TRACE_IDS;
+    set_owner(ttydev, uid, gid, mode);
+}
+
+#ifdef get_pty                 /* USE_UTMP_SETGID */
+#undef get_pty
+/*
+ * Call the real get_pty() before relinquishing root-setuid, caching the
+ * result.
+ */
+static int
+get_pty(int *pty, char *from)
+{
+    static int m_pty = -1;
+    int result = -1;
+
+    if (pty == NULL) {
+       result = really_get_pty(&m_pty, from);
+
+       seteuid(0);
+       set_pty_permissions(save_ruid, save_rgid, 0600U);
+       seteuid(save_ruid);
+       TRACE_IDS;
+
+#ifdef USE_OPENPTY
+       if (opened_tty >= 0) {
+           close(opened_tty);
+           opened_tty = -1;
+       }
+#endif
+    } else if (m_pty != -1) {
+       *pty = m_pty;
+       result = 0;
+    } else {
+       result = -1;
+    }
+    return result;
+}
+#endif
+
+/*
+ * Called from get_pty to iterate over likely pseudo terminals
+ * we might allocate.  Used on those systems that do not have
+ * a functional interface for allocating a pty.
+ * Returns 0 if found a pty, 1 if fails.
+ */
+#ifdef USE_PTY_SEARCH
+static int
+pty_search(int *pty)
+{
+    static int devindex = 0, letter = 0;
+
+#if defined(CRAY) || defined(__MVS__)
+    while (devindex < MAXPTTYS) {
+       sprintf(ttydev, TTYFORMAT, devindex);
+       sprintf(ptydev, PTYFORMAT, devindex);
+       devindex++;
+
+       TRACE(("pty_search(ttydev=%s, ptydev=%s)\n", ttydev, ptydev));
+       if ((*pty = open(ptydev, O_RDWR)) >= 0) {
+           return 0;
+       }
+    }
+#else /* CRAY || __MVS__ */
+    while (PTYCHAR1[letter]) {
+       ttydev[strlen(ttydev) - 2] =
+           ptydev[strlen(ptydev) - 2] = PTYCHAR1[letter];
+
+       while (PTYCHAR2[devindex]) {
+           ttydev[strlen(ttydev) - 1] =
+               ptydev[strlen(ptydev) - 1] = PTYCHAR2[devindex];
+           devindex++;
+
+           TRACE(("pty_search(ttydev=%s, ptydev=%s)\n", ttydev, ptydev));
+           if ((*pty = open(ptydev, O_RDWR)) >= 0) {
+#ifdef sun
+               /* Need to check the process group of the pty.
+                * If it exists, then the slave pty is in use,
+                * and we need to get another one.
+                */
+               int pgrp_rtn;
+               if (ioctl(*pty, TIOCGPGRP, &pgrp_rtn) == 0 || errno != EIO) {
+                   close(*pty);
+                   continue;
+               }
+#endif /* sun */
+               return 0;
+           }
+       }
+       devindex = 0;
+       letter++;
+    }
+#endif /* CRAY else */
+    /*
+     * We were unable to allocate a pty master!  Return an error
+     * condition and let our caller terminate cleanly.
+     */
+    return 1;
+}
+#endif /* USE_PTY_SEARCH */
+
+/*
+ * The only difference in /etc/termcap between 4014 and 4015 is that
+ * the latter has support for switching character sets.  We support the
+ * 4015 protocol, but ignore the character switches.  Therefore, we
+ * choose 4014 over 4015.
+ *
+ * Features of the 4014 over the 4012: larger (19") screen, 12-bit
+ * graphics addressing (compatible with 4012 10-bit addressing),
+ * special point plot mode, incremental plot mode (not implemented in
+ * later Tektronix terminals), and 4 character sizes.
+ * All of these are supported by xterm.
+ */
+
+#if OPT_TEK4014
+static const char *tekterm[] =
+{
+    "tek4014",
+    "tek4015",                 /* 4014 with APL character set support */
+    "tek4012",                 /* 4010 with lower case */
+    "tek4013",                 /* 4012 with APL character set support */
+    "tek4010",                 /* small screen, upper-case only */
+    "dumb",
+    0
+};
+#endif
+
+/* The VT102 is a VT100 with the Advanced Video Option included standard.
+ * It also adds Escape sequences for insert/delete character/line.
+ * The VT220 adds 8-bit character sets, selective erase.
+ * The VT320 adds a 25th status line, terminal state interrogation.
+ * The VT420 has up to 48 lines on the screen.
+ */
+
+static const char *vtterm[] =
+{
+#ifdef USE_X11TERM
+    "x11term",                 /* for people who want special term name */
+#endif
+    DFT_TERMTYPE,              /* for people who want special term name */
+    "xterm",                   /* the prefered name, should be fastest */
+    "vt102",
+    "vt100",
+    "ansi",
+    "dumb",
+    0
+};
+
+/* ARGSUSED */
+static SIGNAL_T
+hungtty(int i GCC_UNUSED)
+{
+    siglongjmp(env, 1);
+    SIGNAL_RETURN;
+}
+
+#if OPT_PTY_HANDSHAKE
+#define NO_FDS {-1, -1}
+
+static int cp_pipe[2] = NO_FDS;        /* this pipe is used for child to parent transfer */
+static int pc_pipe[2] = NO_FDS;        /* this pipe is used for parent to child transfer */
+
+typedef enum {                 /* c == child, p == parent                        */
+    PTY_BAD,                   /* c->p: can't open pty slave for some reason     */
+    PTY_FATALERROR,            /* c->p: we had a fatal error with the pty        */
+    PTY_GOOD,                  /* c->p: we have a good pty, let's go on          */
+    PTY_NEW,                   /* p->c: here is a new pty slave, try this        */
+    PTY_NOMORE,                        /* p->c; no more pty's, terminate                 */
+    UTMP_ADDED,                        /* c->p: utmp entry has been added                */
+    UTMP_TTYSLOT,              /* c->p: here is my ttyslot                       */
+    PTY_EXEC                   /* p->c: window has been mapped the first time    */
+} status_t;
+
+typedef struct {
+    status_t status;
+    int error;
+    int fatal_error;
+    int tty_slot;
+    int rows;
+    int cols;
+    char buffer[1024];
+} handshake_t;
+
+#if OPT_TRACE
+static void
+trace_handshake(const char *tag, handshake_t * data)
+{
+    const char *status = "?";
+    switch (data->status) {
+    case PTY_BAD:
+       status = "PTY_BAD";
+       break;
+    case PTY_FATALERROR:
+       status = "PTY_FATALERROR";
+       break;
+    case PTY_GOOD:
+       status = "PTY_GOOD";
+       break;
+    case PTY_NEW:
+       status = "PTY_NEW";
+       break;
+    case PTY_NOMORE:
+       status = "PTY_NOMORE";
+       break;
+    case UTMP_ADDED:
+       status = "UTMP_ADDED";
+       break;
+    case UTMP_TTYSLOT:
+       status = "UTMP_TTYSLOT";
+       break;
+    case PTY_EXEC:
+       status = "PTY_EXEC";
+       break;
+    }
+    TRACE(("handshake %s %s errno=%d, error=%d device \"%s\"\n",
+          tag,
+          status,
+          data->error,
+          data->fatal_error,
+          data->buffer));
+}
+#define TRACE_HANDSHAKE(tag, data) trace_handshake(tag, data)
+#else
+#define TRACE_HANDSHAKE(tag, data)     /* nothing */
+#endif
+
+/* HsSysError()
+ *
+ * This routine does the equivalent of a SysError but it handshakes
+ * over the errno and error exit to the master process so that it can
+ * display our error message and exit with our exit code so that the
+ * user can see it.
+ */
+
+static void
+HsSysError(int error)
+{
+    handshake_t handshake;
+
+    memset(&handshake, 0, sizeof(handshake));
+    handshake.status = PTY_FATALERROR;
+    handshake.error = errno;
+    handshake.fatal_error = error;
+    strcpy(handshake.buffer, ttydev);
+
+    if (resource.ptyHandshake && (cp_pipe[1] >= 0)) {
+       TRACE(("HsSysError errno=%d, error=%d device \"%s\"\n",
+              handshake.error,
+              handshake.fatal_error,
+              handshake.buffer));
+       TRACE_HANDSHAKE("writing", &handshake);
+       IGNORE_RC(write(cp_pipe[1],
+                       (const char *) &handshake,
+                       sizeof(handshake)));
+    } else {
+       fprintf(stderr,
+               "%s: fatal pty error errno=%d, error=%d device \"%s\"\n",
+               ProgramName,
+               handshake.error,
+               handshake.fatal_error,
+               handshake.buffer);
+       fprintf(stderr, "%s\n", SysErrorMsg(handshake.error));
+       fprintf(stderr, "Reason: %s\n", SysReasonMsg(handshake.fatal_error));
+    }
+    exit(error);
+}
+
+void
+first_map_occurred(void)
+{
+    if (resource.wait_for_map) {
+       handshake_t handshake;
+       TScreen *screen = TScreenOf(term);
+
+       memset(&handshake, 0, sizeof(handshake));
+       handshake.status = PTY_EXEC;
+       handshake.rows = screen->max_row;
+       handshake.cols = screen->max_col;
+
+       if (pc_pipe[1] >= 0) {
+           TRACE(("first_map_occurred: %dx%d\n", handshake.rows, handshake.cols));
+           TRACE_HANDSHAKE("writing", &handshake);
+           IGNORE_RC(write(pc_pipe[1],
+                           (const char *) &handshake,
+                           sizeof(handshake)));
+           close(cp_pipe[0]);
+           close(pc_pipe[1]);
+       }
+       resource.wait_for_map = False;
+    }
+}
+#else
+/*
+ * temporary hack to get xterm working on att ptys
+ */
+static void
+HsSysError(int error)
+{
+    fprintf(stderr, "%s: fatal pty error %d (errno=%d) on tty %s\n",
+           ProgramName, error, errno, ttydev);
+    exit(error);
+}
+#endif /* OPT_PTY_HANDSHAKE else !OPT_PTY_HANDSHAKE */
+
+#ifndef VMS
+static void
+set_owner(char *device, uid_t uid, gid_t gid, mode_t mode)
+{
+    int why;
+
+    TRACE_IDS;
+    TRACE(("set_owner(%s, uid=%d, gid=%d, mode=%#o\n",
+          device, uid, gid, (unsigned) mode));
+
+    if (chown(device, uid, gid) < 0) {
+       why = errno;
+       if (why != ENOENT
+           && save_ruid == 0) {
+           fprintf(stderr, "Cannot chown %s to %ld,%ld: %s\n",
+                   device, (long) uid, (long) gid,
+                   strerror(why));
+       }
+       TRACE(("...chown failed: %s\n", strerror(why)));
+    }
+    if (chmod(device, mode) < 0) {
+       why = errno;
+       if (why != ENOENT) {
+           struct stat sb;
+           if (stat(device, &sb) < 0) {
+               fprintf(stderr, "Cannot chmod %s to %03o: %s\n",
+                       device, (unsigned) mode,
+                       strerror(why));
+           } else if (mode != (sb.st_mode & 0777U)) {
+               fprintf(stderr,
+                       "Cannot chmod %s to %03lo currently %03lo: %s\n",
+                       device,
+                       (unsigned long) mode,
+                       (unsigned long) (sb.st_mode & 0777U),
+                       strerror(why));
+               TRACE(("...stat uid=%d, gid=%d, mode=%#o\n",
+                      sb.st_uid, sb.st_gid, (unsigned) sb.st_mode));
+           }
+       }
+       TRACE(("...chmod failed: %s\n", strerror(why)));
+    }
+}
+
+#if defined(HAVE_UTMP) && defined(USE_SYSV_UTMP) && !defined(USE_UTEMPTER)
+/*
+ * getutid() only looks at ut_type and ut_id.
+ * But we'll also check ut_line in find_utmp().
+ */
+static void
+init_utmp(int type, struct UTMP_STR *tofind)
+{
+    memset(tofind, 0, sizeof(*tofind));
+    tofind->ut_type = type;
+    (void) strncpy(tofind->ut_id, my_utmp_id(ttydev), sizeof(tofind->ut_id));
+    (void) strncpy(tofind->ut_line, my_pty_name(ttydev), sizeof(tofind->ut_line));
+}
+
+/*
+ * We could use getutline() if we didn't support old systems.
+ */
+static struct UTMP_STR *
+find_utmp(struct UTMP_STR *tofind)
+{
+    struct UTMP_STR *result;
+    struct UTMP_STR working;
+
+    for (;;) {
+       memset(&working, 0, sizeof(working));
+       working.ut_type = tofind->ut_type;
+       memcpy(working.ut_id, tofind->ut_id, sizeof(tofind->ut_id));
+#if defined(__digital__) && defined(__unix__) && (defined(OSMAJORVERSION) && OSMAJORVERSION < 5)
+       working.ut_type = 0;
+#endif
+       if ((result = call_getutid(&working)) == 0)
+           break;
+       if (!strcmp(result->ut_line, tofind->ut_line))
+           break;
+       /*
+        * Solaris, IRIX64 and HPUX manpages say to fill the static area
+        * pointed to by the return-value to zeros if searching for multiple
+        * occurrences.  Otherwise it will continue to return the same value.
+        */
+       memset(result, 0, sizeof(*result));
+    }
+    return result;
+}
+#endif /* HAVE_UTMP... */
+
+#define close_fd(fd) close(fd), fd = -1
+
+#if defined(TIOCNOTTY) && (!defined(__GLIBC__) || (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
+#define USE_NO_DEV_TTY 1
+#else
+#define USE_NO_DEV_TTY 0
+#endif
+
+/*
+ *  Inits pty and tty and forks a login process.
+ *  Does not close fd Xsocket.
+ *  If slave, the pty named in passedPty is already open for use
+ */
+static int
+spawnXTerm(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Cardinal nn;
+#if OPT_PTY_HANDSHAKE
+    Bool got_handshake_size = False;
+    handshake_t handshake;
+    int done;
+#endif
+#if OPT_INITIAL_ERASE
+    int initial_erase = VAL_INITIAL_ERASE;
+    Bool setInitialErase;
+#endif
+    int rc = 0;
+    int ttyfd = -1;
+    Bool ok_termcap;
+    char *newtc;
+
+#ifdef TERMIO_STRUCT
+    TERMIO_STRUCT tio;
+#ifdef __MVS__
+    TERMIO_STRUCT gio;
+#endif /* __MVS__ */
+#ifdef TIOCLSET
+    unsigned lmode;
+#endif /* TIOCLSET */
+#ifdef HAS_LTCHARS
+    struct ltchars ltc;
+#endif /* HAS_LTCHARS */
+#else /* !TERMIO_STRUCT */
+    int ldisc = 0;
+    int discipline;
+    unsigned lmode;
+    struct tchars tc;
+    struct ltchars ltc;
+    struct sgttyb sg;
+#ifdef sony
+    int jmode;
+    struct jtchars jtc;
+#endif /* sony */
+#endif /* TERMIO_STRUCT */
+
+    char *ptr, *shname, *shname_minus;
+    int i;
+#if USE_NO_DEV_TTY
+    int no_dev_tty = False;
+#endif
+    const char **envnew;       /* new environment */
+    char buf[64];
+    char *TermName = NULL;
+#ifdef TTYSIZE_STRUCT
+    TTYSIZE_STRUCT ts;
+#endif
+    struct passwd *pw = NULL;
+    char *login_name = NULL;
+#ifndef USE_UTEMPTER
+#ifdef HAVE_UTMP
+    struct UTMP_STR utmp;
+#ifdef USE_SYSV_UTMP
+    struct UTMP_STR *utret = NULL;
+#endif
+#ifdef USE_LASTLOG
+    struct lastlog lastlog;
+#endif
+#ifdef USE_LASTLOGX
+    struct lastlogx lastlogx;
+#endif /* USE_LASTLOG */
+#endif /* HAVE_UTMP */
+#endif /* !USE_UTEMPTER */
+
+    /* Noisy compilers (suppress some unused-variable warnings) */
+    (void) rc;
+#if defined(HAVE_UTMP) && defined(USE_SYSV_UTMP) && !defined(USE_UTEMPTER)
+    (void) utret;
+#endif
+
+    screen->uid = save_ruid;
+    screen->gid = save_rgid;
+
+#ifdef SIGTTOU
+    /* so that TIOCSWINSZ || TIOCSIZE doesn't block */
+    signal(SIGTTOU, SIG_IGN);
+#endif
+
+#if OPT_PTY_HANDSHAKE
+    memset(&handshake, 0, sizeof(handshake));
+#endif
+
+    if (am_slave >= 0) {
+       screen->respond = am_slave;
+       set_pty_id(ttydev, passedPty);
+#ifdef USE_PTY_DEVICE
+       set_pty_id(ptydev, passedPty);
+#endif
+       if (xtermResetIds(screen) < 0)
+           exit(1);
+    } else {
+       Bool tty_got_hung;
+
+       /*
+        * Sometimes /dev/tty hangs on open (as in the case of a pty
+        * that has gone away).  Simply make up some reasonable
+        * defaults.
+        */
+
+       signal(SIGALRM, hungtty);
+       alarm(2);               /* alarm(1) might return too soon */
+       if (!sigsetjmp(env, 1)) {
+           ttyfd = open("/dev/tty", O_RDWR);
+           alarm(0);
+           tty_got_hung = False;
+       } else {
+           tty_got_hung = True;
+           ttyfd = -1;
+           errno = ENXIO;
+       }
+       pw = NULL;
+#if OPT_PTY_HANDSHAKE
+       got_handshake_size = False;
+#endif /* OPT_PTY_HANDSHAKE */
+#if OPT_INITIAL_ERASE
+       initial_erase = VAL_INITIAL_ERASE;
+#endif
+       signal(SIGALRM, SIG_DFL);
+
+       /*
+        * Check results and ignore current control terminal if
+        * necessary.  ENXIO is what is normally returned if there is
+        * no controlling terminal, but some systems (e.g. SunOS 4.0)
+        * seem to return EIO.  Solaris 2.3 is said to return EINVAL.
+        * Cygwin returns ENOENT.
+        */
+#if USE_NO_DEV_TTY
+       no_dev_tty = False;
+#endif
+       if (ttyfd < 0) {
+           if (tty_got_hung || errno == ENXIO || errno == EIO ||
+#ifdef ENODEV
+               errno == ENODEV ||
+#endif
+#ifdef __CYGWIN__
+               errno == ENOENT ||
+#endif
+               errno == EINVAL || errno == ENOTTY || errno == EACCES) {
+#if USE_NO_DEV_TTY
+               no_dev_tty = True;
+#endif
+#ifdef HAS_LTCHARS
+               ltc = d_ltc;
+#endif /* HAS_LTCHARS */
+#ifdef TIOCLSET
+               lmode = d_lmode;
+#endif /* TIOCLSET */
+#ifdef TERMIO_STRUCT
+               tio = d_tio;
+#else /* !TERMIO_STRUCT */
+               sg = d_sg;
+               tc = d_tc;
+               discipline = d_disipline;
+#ifdef sony
+               jmode = d_jmode;
+               jtc = d_jtc;
+#endif /* sony */
+#endif /* TERMIO_STRUCT */
+           } else {
+               SysError(ERROR_OPDEVTTY);
+           }
+       } else {
+
+           /* Get a copy of the current terminal's state,
+            * if we can.  Some systems (e.g., SVR4 and MacII)
+            * may not have a controlling terminal at this point
+            * if started directly from xdm or xinit,
+            * in which case we just use the defaults as above.
+            */
+#ifdef HAS_LTCHARS
+           if (ioctl(ttyfd, TIOCGLTC, &ltc) == -1)
+               ltc = d_ltc;
+#endif /* HAS_LTCHARS */
+#ifdef TIOCLSET
+           if (ioctl(ttyfd, TIOCLGET, &lmode) == -1)
+               lmode = d_lmode;
+#endif /* TIOCLSET */
+#ifdef TERMIO_STRUCT
+           rc = ttyGetAttr(ttyfd, &tio);
+           if (rc == -1)
+               tio = d_tio;
+#else /* !TERMIO_STRUCT */
+           rc = ioctl(ttyfd, TIOCGETP, (char *) &sg);
+           if (rc == -1)
+               sg = d_sg;
+           if (ioctl(ttyfd, TIOCGETC, (char *) &tc) == -1)
+               tc = d_tc;
+           if (ioctl(ttyfd, TIOCGETD, (char *) &discipline) == -1)
+               discipline = d_disipline;
+#ifdef sony
+           if (ioctl(ttyfd, TIOCKGET, (char *) &jmode) == -1)
+               jmode = d_jmode;
+           if (ioctl(ttyfd, TIOCKGETC, (char *) &jtc) == -1)
+               jtc = d_jtc;
+#endif /* sony */
+#endif /* TERMIO_STRUCT */
+
+           /*
+            * If ptyInitialErase is set, we want to get the pty's
+            * erase value.  Just in case that will fail, first get
+            * the value from /dev/tty, so we will have something
+            * at least.
+            */
+#if OPT_INITIAL_ERASE
+           if (resource.ptyInitialErase) {
+#ifdef TERMIO_STRUCT
+               initial_erase = tio.c_cc[VERASE];
+#else /* !TERMIO_STRUCT */
+               initial_erase = sg.sg_erase;
+#endif /* TERMIO_STRUCT */
+               TRACE(("%s initial_erase:%d (from /dev/tty)\n",
+                      rc == 0 ? "OK" : "FAIL",
+                      initial_erase));
+           }
+#endif
+#ifdef __MVS__
+           if (ttyGetAttr(ttyfd, &gio) == 0) {
+               gio.c_cflag &= ~(HUPCL | PARENB);
+               ttySetAttr(ttyfd, &gio);
+           }
+#endif /* __MVS__ */
+
+           close_fd(ttyfd);
+       }
+
+       if (get_pty(&screen->respond, XDisplayString(screen->display))) {
+           SysError(ERROR_PTYS);
+       }
+#if OPT_INITIAL_ERASE
+       if (resource.ptyInitialErase) {
+#ifdef TERMIO_STRUCT
+           TERMIO_STRUCT my_tio;
+           rc = ttyGetAttr(screen->respond, &my_tio);
+           if (rc == 0)
+               initial_erase = my_tio.c_cc[VERASE];
+#else /* !TERMIO_STRUCT */
+           struct sgttyb my_sg;
+           rc = ioctl(screen->respond, TIOCGETP, (char *) &my_sg);
+           if (rc == 0)
+               initial_erase = my_sg.sg_erase;
+#endif /* TERMIO_STRUCT */
+           TRACE(("%s initial_erase:%d (from pty)\n",
+                  (rc == 0) ? "OK" : "FAIL",
+                  initial_erase));
+       }
+#endif /* OPT_INITIAL_ERASE */
+    }
+
+    /* avoid double MapWindow requests */
+    XtSetMappedWhenManaged(SHELL_OF(CURRENT_EMU()), False);
+
+    wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
+                                  False);
+
+    if (!TEK4014_ACTIVE(xw))
+       VTInit(xw);             /* realize now so know window size for tty driver */
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+    if (Console) {
+       /*
+        * Inform any running xconsole program
+        * that we are going to steal the console.
+        */
+       XmuGetHostname(mit_console_name + MIT_CONSOLE_LEN, 255);
+       mit_console = XInternAtom(screen->display, mit_console_name, False);
+       /* the user told us to be the console, so we can use CurrentTime */
+       XtOwnSelection(SHELL_OF(CURRENT_EMU()),
+                      mit_console, CurrentTime,
+                      ConvertConsoleSelection, NULL, NULL);
+    }
+#endif
+#if OPT_TEK4014
+    if (TEK4014_ACTIVE(xw)) {
+       envnew = tekterm;
+    } else
+#endif
+    {
+       envnew = vtterm;
+    }
+
+    /*
+     * This used to exit if no termcap entry was found for the specified
+     * terminal name.  That's a little unfriendly, so instead we'll allow
+     * the program to proceed (but not to set $TERMCAP) if the termcap
+     * entry is not found.
+     */
+    ok_termcap = True;
+    if (!get_termcap(xw, TermName = resource.term_name)) {
+       const char *last = NULL;
+       char *next;
+
+       TermName = x_strdup(*envnew);
+       ok_termcap = False;
+       while (*envnew != NULL) {
+           if (last == NULL || strcmp(last, *envnew)) {
+               next = x_strdup(*envnew);
+               if (get_termcap(xw, next)) {
+                   free(TermName);
+                   TermName = next;
+                   ok_termcap = True;
+                   break;
+               } else {
+                   free(next);
+               }
+           }
+           last = *envnew;
+           envnew++;
+       }
+    }
+    if (ok_termcap) {
+       resize_termcap(xw);
+    }
+
+    /*
+     * Check if ptyInitialErase is not set.  If so, we rely on the termcap
+     * (or terminfo) to tell us what the erase mode should be set to.
+     */
+#if OPT_INITIAL_ERASE
+    TRACE(("resource ptyInitialErase is %sset\n",
+          resource.ptyInitialErase ? "" : "not "));
+    setInitialErase = False;
+    if (override_tty_modes && ttymodelist[XTTYMODE_erase].set) {
+       initial_erase = ttymodelist[XTTYMODE_erase].value;
+       setInitialErase = True;
+    } else if (resource.ptyInitialErase) {
+       /* EMPTY */ ;
+    } else if (ok_termcap) {
+       char *s = get_tcap_erase(xw);
+       TRACE(("...extracting initial_erase value from termcap\n"));
+       if (s != 0) {
+           char *save = s;
+           initial_erase = decode_keyvalue(&s, True);
+           setInitialErase = True;
+           free(save);
+       }
+    }
+    TRACE(("...initial_erase:%d\n", initial_erase));
+
+    TRACE(("resource backarrowKeyIsErase is %sset\n",
+          resource.backarrow_is_erase ? "" : "not "));
+    if (resource.backarrow_is_erase) { /* see input.c */
+       if (initial_erase == ANSI_DEL) {
+           UIntClr(xw->keyboard.flags, MODE_DECBKM);
+       } else {
+           xw->keyboard.flags |= MODE_DECBKM;
+           xw->keyboard.reset_DECBKM = 1;
+       }
+       TRACE(("...sets DECBKM %s\n",
+              (xw->keyboard.flags & MODE_DECBKM) ? "on" : "off"));
+    } else {
+       xw->keyboard.reset_DECBKM = 2;
+    }
+#endif /* OPT_INITIAL_ERASE */
+
+#ifdef TTYSIZE_STRUCT
+    /* tell tty how big window is */
+#if OPT_TEK4014
+    if (TEK4014_ACTIVE(xw)) {
+       TTYSIZE_ROWS(ts) = 38;
+       TTYSIZE_COLS(ts) = 81;
+#if defined(USE_STRUCT_WINSIZE)
+       ts.ws_xpixel = TFullWidth(TekScreenOf(tekWidget));
+       ts.ws_ypixel = TFullHeight(TekScreenOf(tekWidget));
+#endif
+    } else
+#endif
+    {
+       TTYSIZE_ROWS(ts) = (ttySize_t) MaxRows(screen);
+       TTYSIZE_COLS(ts) = (ttySize_t) MaxCols(screen);
+#if defined(USE_STRUCT_WINSIZE)
+       ts.ws_xpixel = (ttySize_t) FullWidth(screen);
+       ts.ws_ypixel = (ttySize_t) FullHeight(screen);
+#endif
+    }
+    TRACE_RC(i, SET_TTYSIZE(screen->respond, ts));
+    TRACE(("spawn SET_TTYSIZE %dx%d return %d\n",
+          TTYSIZE_ROWS(ts),
+          TTYSIZE_COLS(ts), i));
+#endif /* TTYSIZE_STRUCT */
+
+    added_utmp_entry = False;
+#if defined(USE_UTEMPTER)
+#undef UTMP
+    if (!resource.utmpInhibit) {
+       struct UTMP_STR dummy;
+
+       /* Note: utempter may trim it anyway */
+       SetUtmpHost(dummy.ut_host, screen);
+       addToUtmp(ttydev, dummy.ut_host, screen->respond);
+       added_utmp_entry = True;
+    }
+#endif
+
+    if (am_slave < 0) {
+#if OPT_PTY_HANDSHAKE
+       if (resource.ptyHandshake && (pipe(pc_pipe) || pipe(cp_pipe)))
+           SysError(ERROR_FORK);
+#endif
+       TRACE(("Forking...\n"));
+       if ((screen->pid = fork()) == -1)
+           SysError(ERROR_FORK);
+
+       if (screen->pid == 0) {
+#ifdef USE_USG_PTYS
+           int ptyfd = -1;
+           char *pty_name;
+#endif
+           /*
+            * now in child process
+            */
+#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__)
+           int pgrp = setsid();        /* variable may not be used... */
+#else
+           int pgrp = getpid();
+#endif
+           TRACE_CHILD
+
+#ifdef USE_USG_PTYS
+#ifdef USE_ISPTS_FLAG
+               if (IsPts) {    /* SYSV386 supports both, which did we open? */
+#endif
+               setpgrp();
+               grantpt(screen->respond);
+               unlockpt(screen->respond);
+               if ((pty_name = ptsname(screen->respond)) == 0) {
+                   SysError(ERROR_PTSNAME);
+               } else if ((ptyfd = open(pty_name, O_RDWR)) < 0) {
+                   SysError(ERROR_OPPTSNAME);
+               }
+#ifdef I_PUSH
+               else if (ioctl(ptyfd, I_PUSH, "ptem") < 0) {
+                   SysError(ERROR_PTEM);
+               }
+#if !defined(SVR4) && !(defined(SYSV) && defined(i386))
+               else if (!x_getenv("CONSEM")
+                        && ioctl(ptyfd, I_PUSH, "consem") < 0) {
+                   SysError(ERROR_CONSEM);
+               }
+#endif /* !SVR4 */
+               else if (ioctl(ptyfd, I_PUSH, "ldterm") < 0) {
+                   SysError(ERROR_LDTERM);
+               }
+#ifdef SVR4                    /* from Sony */
+               else if (ioctl(ptyfd, I_PUSH, "ttcompat") < 0) {
+                   SysError(ERROR_TTCOMPAT);
+               }
+#endif /* SVR4 */
+#endif /* I_PUSH */
+               ttyfd = ptyfd;
+#ifndef __MVS__
+               close_fd(screen->respond);
+#endif /* __MVS__ */
+
+#ifdef TTYSIZE_STRUCT
+               /* tell tty how big window is */
+#if OPT_TEK4014
+               if (TEK4014_ACTIVE(xw)) {
+                   TTYSIZE_ROWS(ts) = 24;
+                   TTYSIZE_COLS(ts) = 80;
+#ifdef USE_STRUCT_WINSIZE
+                   ts.ws_xpixel = TFullWidth(TekScreenOf(tekWidget));
+                   ts.ws_ypixel = TFullHeight(TekScreenOf(tekWidget));
+#endif
+               } else
+#endif /* OPT_TEK4014 */
+               {
+                   TTYSIZE_ROWS(ts) = (ttySize_t) MaxRows(screen);
+                   TTYSIZE_COLS(ts) = (ttySize_t) MaxCols(screen);
+#ifdef USE_STRUCT_WINSIZE
+                   ts.ws_xpixel = (ttySize_t) FullWidth(screen);
+                   ts.ws_ypixel = (ttySize_t) FullHeight(screen);
+#endif
+               }
+#endif /* TTYSIZE_STRUCT */
+
+#ifdef USE_ISPTS_FLAG
+           } else {            /* else pty, not pts */
+#endif
+#endif /* USE_USG_PTYS */
+
+               (void) pgrp;    /* not all branches use this variable */
+
+#if OPT_PTY_HANDSHAKE          /* warning, goes for a long ways */
+               if (resource.ptyHandshake) {
+                   /* close parent's sides of the pipes */
+                   close(cp_pipe[0]);
+                   close(pc_pipe[1]);
+
+                   /* Make sure that our sides of the pipes are not in the
+                    * 0, 1, 2 range so that we don't fight with stdin, out
+                    * or err.
+                    */
+                   if (cp_pipe[1] <= 2) {
+                       if ((i = fcntl(cp_pipe[1], F_DUPFD, 3)) >= 0) {
+                           IGNORE_RC(close(cp_pipe[1]));
+                           cp_pipe[1] = i;
+                       }
+                   }
+                   if (pc_pipe[0] <= 2) {
+                       if ((i = fcntl(pc_pipe[0], F_DUPFD, 3)) >= 0) {
+                           IGNORE_RC(close(pc_pipe[0]));
+                           pc_pipe[0] = i;
+                       }
+                   }
+
+                   /* we don't need the socket, or the pty master anymore */
+                   close(ConnectionNumber(screen->display));
+#ifndef __MVS__
+                   if (screen->respond >= 0)
+                       close(screen->respond);
+#endif /* __MVS__ */
+
+                   /* Now is the time to set up our process group and
+                    * open up the pty slave.
+                    */
+#ifdef USE_SYSV_PGRP
+#if defined(CRAY) && (OSMAJORVERSION > 5)
+                   IGNORE_RC(setsid());
+#else
+                   IGNORE_RC(setpgrp());
+#endif
+#endif /* USE_SYSV_PGRP */
+
+#if defined(__QNX__) && !defined(__QNXNTO__)
+                   qsetlogin(getlogin(), ttydev);
+#endif
+                   if (ttyfd >= 0) {
+#ifdef __MVS__
+                       if (ttyGetAttr(ttyfd, &gio) == 0) {
+                           gio.c_cflag &= ~(HUPCL | PARENB);
+                           ttySetAttr(ttyfd, &gio);
+                       }
+#else /* !__MVS__ */
+                       close_fd(ttyfd);
+#endif /* __MVS__ */
+                   }
+
+                   for (;;) {
+#if USE_NO_DEV_TTY
+                       if (!no_dev_tty
+                           && (ttyfd = open("/dev/tty", O_RDWR)) >= 0) {
+                           ioctl(ttyfd, TIOCNOTTY, (char *) NULL);
+                           close_fd(ttyfd);
+                       }
+#endif /* USE_NO_DEV_TTY */
+#ifdef CSRG_BASED
+                       IGNORE_RC(revoke(ttydev));
+#endif
+                       if ((ttyfd = open(ttydev, O_RDWR)) >= 0) {
+#if defined(CRAY) && defined(TCSETCTTY)
+                           /* make /dev/tty work */
+                           ioctl(ttyfd, TCSETCTTY, 0);
+#endif
+#if ((defined(__GLIBC__) && defined(__FreeBSD_kernel__)) || defined(__GNU__)) && defined(TIOCSCTTY)
+                           /* make /dev/tty work */
+                           ioctl(ttyfd, TIOCSCTTY, 0);
+#endif
+#ifdef USE_SYSV_PGRP
+                           /* We need to make sure that we are actually
+                            * the process group leader for the pty.  If
+                            * we are, then we should now be able to open
+                            * /dev/tty.
+                            */
+                           if ((i = open("/dev/tty", O_RDWR)) >= 0) {
+                               /* success! */
+                               close(i);
+                               break;
+                           }
+#else /* USE_SYSV_PGRP */
+                           break;
+#endif /* USE_SYSV_PGRP */
+                       }
+                       perror("open ttydev");
+#ifdef TIOCSCTTY
+                       ioctl(ttyfd, TIOCSCTTY, 0);
+#endif
+                       /* let our master know that the open failed */
+                       handshake.status = PTY_BAD;
+                       handshake.error = errno;
+                       strcpy(handshake.buffer, ttydev);
+                       TRACE_HANDSHAKE("writing", &handshake);
+                       IGNORE_RC(write(cp_pipe[1],
+                                       (const char *) &handshake,
+                                       sizeof(handshake)));
+
+                       /* get reply from parent */
+                       i = (int) read(pc_pipe[0], (char *) &handshake,
+                                      sizeof(handshake));
+                       if (i <= 0) {
+                           /* parent terminated */
+                           exit(1);
+                       }
+
+                       if (handshake.status == PTY_NOMORE) {
+                           /* No more ptys, let's shutdown. */
+                           exit(1);
+                       }
+
+                       /* We have a new pty to try */
+                       free(ttydev);
+                       ttydev = x_strdup(handshake.buffer);
+                   }
+
+                   /* use the same tty name that everyone else will use
+                    * (from ttyname)
+                    */
+                   if ((ptr = ttyname(ttyfd)) != 0) {
+                       free(ttydev);
+                       ttydev = x_strdup(ptr);
+                   }
+               }
+#endif /* OPT_PTY_HANDSHAKE -- from near fork */
+
+#ifdef USE_ISPTS_FLAG
+           }                   /* end of IsPts else clause */
+#endif
+
+           set_pty_permissions(screen->uid,
+                               screen->gid,
+                               (resource.messages
+                                ? 0622U
+                                : 0600U));
+
+           /*
+            * set up the tty modes
+            */
+           {
+#ifdef TERMIO_STRUCT
+#if defined(umips) || defined(CRAY) || defined(linux)
+               /* If the control tty had its modes screwed around with,
+                  eg. by lineedit in the shell, or emacs, etc. then tio
+                  will have bad values.  Let's just get termio from the
+                  new tty and tailor it.  */
+               if (ttyGetAttr(ttyfd, &tio) == -1)
+                   SysError(ERROR_TIOCGETP);
+               tio.c_lflag |= ECHOE;
+#endif /* umips */
+               /* Now is also the time to change the modes of the
+                * child pty.
+                */
+               /* input: nl->nl, don't ignore cr, cr->nl */
+               UIntClr(tio.c_iflag, (INLCR | IGNCR));
+               tio.c_iflag |= ICRNL;
+#if OPT_WIDE_CHARS && defined(linux) && defined(IUTF8)
+#if OPT_LUIT_PROG
+               if (command_to_exec_with_luit == 0)
+#endif
+                   if (screen->utf8_mode)
+                       tio.c_iflag |= IUTF8;
+#endif
+               /* ouput: cr->cr, nl is not return, no delays, ln->cr/nl */
+#ifndef USE_POSIX_TERMIOS
+               UIntClr(tio.c_oflag,
+                       (OCRNL
+                        | ONLRET
+                        | NLDLY
+                        | CRDLY
+                        | TABDLY
+                        | BSDLY
+                        | VTDLY
+                        | FFDLY));
+#endif /* USE_POSIX_TERMIOS */
+#ifdef ONLCR
+               tio.c_oflag |= ONLCR;
+#endif /* ONLCR */
+#ifdef OPOST
+               tio.c_oflag |= OPOST;
+#endif /* OPOST */
+#ifndef USE_POSIX_TERMIOS
+# if defined(Lynx) && !defined(CBAUD)
+#  define CBAUD V_CBAUD
+# endif
+               UIntClr(tio.c_cflag, CBAUD);
+#ifdef BAUD_0
+               /* baud rate is 0 (don't care) */
+#elif defined(HAVE_TERMIO_C_ISPEED)
+               tio.c_ispeed = tio.c_ospeed = VAL_LINE_SPEED;
+#else /* !BAUD_0 */
+               tio.c_cflag |= VAL_LINE_SPEED;
+#endif /* !BAUD_0 */
+#else /* USE_POSIX_TERMIOS */
+               cfsetispeed(&tio, VAL_LINE_SPEED);
+               cfsetospeed(&tio, VAL_LINE_SPEED);
+#ifdef __MVS__
+               /* turn off bits that can't be set from the slave side */
+               tio.c_cflag &= ~(PACKET | PKT3270 | PTU3270 | PKTXTND);
+#endif /* __MVS__ */
+               /* Clear CLOCAL so that SIGHUP is sent to us
+                  when the xterm ends */
+               tio.c_cflag &= ~CLOCAL;
+#endif /* USE_POSIX_TERMIOS */
+               /* enable signals, canonical processing (erase, kill, etc),
+                * echo
+                */
+               tio.c_lflag |= ISIG | ICANON | ECHO | ECHOE | ECHOK;
+#ifdef ECHOKE
+               tio.c_lflag |= ECHOKE | IEXTEN;
+#endif
+#ifdef ECHOCTL
+               tio.c_lflag |= ECHOCTL | IEXTEN;
+#endif
+               for (nn = 0; nn < XtNumber(known_ttyChars); ++nn) {
+                   if (validTtyChar(tio, nn)) {
+                       int sysMode = known_ttyChars[nn].sysMode;
+#ifdef __MVS__
+                       if (tio.c_cc[sysMode] != 0) {
+                           switch (sysMode) {
+                           case VEOL:
+                           case VEOF:
+                               continue;
+                           }
+                       }
+#endif
+                       tio.c_cc[sysMode] = known_ttyChars[nn].myDefault;
+                   }
+               }
+
+               if (override_tty_modes) {
+                   for (nn = 0; nn < XtNumber(known_ttyChars); ++nn) {
+                       if (validTtyChar(tio, nn)) {
+                           TMODE(known_ttyChars[nn].myMode,
+                                 tio.c_cc[known_ttyChars[nn].sysMode]);
+                       }
+                   }
+#ifdef HAS_LTCHARS
+                   /* both SYSV and BSD have ltchars */
+                   TMODE(XTTYMODE_susp, ltc.t_suspc);
+                   TMODE(XTTYMODE_dsusp, ltc.t_dsuspc);
+                   TMODE(XTTYMODE_rprnt, ltc.t_rprntc);
+                   TMODE(XTTYMODE_flush, ltc.t_flushc);
+                   TMODE(XTTYMODE_weras, ltc.t_werasc);
+                   TMODE(XTTYMODE_lnext, ltc.t_lnextc);
+#endif
+               }
+#ifdef HAS_LTCHARS
+#ifdef __hpux
+               /* ioctl chokes when the "reserved" process group controls
+                * are not set to _POSIX_VDISABLE */
+               ltc.t_rprntc = ltc.t_rprntc = ltc.t_flushc =
+                   ltc.t_werasc = ltc.t_lnextc = _POSIX_VDISABLE;
+#endif /* __hpux */
+               if (ioctl(ttyfd, TIOCSLTC, &ltc) == -1)
+                   HsSysError(ERROR_TIOCSETC);
+#endif /* HAS_LTCHARS */
+#ifdef TIOCLSET
+               if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1)
+                   HsSysError(ERROR_TIOCLSET);
+#endif /* TIOCLSET */
+               if (ttySetAttr(ttyfd, &tio) == -1)
+                   HsSysError(ERROR_TIOCSETP);
+
+               /* ignore errors here - some platforms don't work */
+               UIntClr(tio.c_cflag, CSIZE);
+               if (screen->input_eight_bits)
+                   tio.c_cflag |= CS8;
+               else
+                   tio.c_cflag |= CS7;
+               (void) ttySetAttr(ttyfd, &tio);
+
+#else /* !TERMIO_STRUCT */
+               sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW);
+               sg.sg_flags |= ECHO | CRMOD;
+               /* make sure speed is set on pty so that editors work right */
+               sg.sg_ispeed = VAL_LINE_SPEED;
+               sg.sg_ospeed = VAL_LINE_SPEED;
+               /* reset t_brkc to default value */
+               tc.t_brkc = -1;
+#ifdef LPASS8
+               if (screen->input_eight_bits)
+                   lmode |= LPASS8;
+               else
+                   lmode &= ~(LPASS8);
+#endif
+#ifdef sony
+               jmode &= ~KM_KANJI;
+#endif /* sony */
+
+               ltc = d_ltc;
+
+               if (override_tty_modes) {
+                   TMODE(XTTYMODE_intr, tc.t_intrc);
+                   TMODE(XTTYMODE_quit, tc.t_quitc);
+                   TMODE(XTTYMODE_erase, sg.sg_erase);
+                   TMODE(XTTYMODE_kill, sg.sg_kill);
+                   TMODE(XTTYMODE_eof, tc.t_eofc);
+                   TMODE(XTTYMODE_start, tc.t_startc);
+                   TMODE(XTTYMODE_stop, tc.t_stopc);
+                   TMODE(XTTYMODE_brk, tc.t_brkc);
+                   /* both SYSV and BSD have ltchars */
+                   TMODE(XTTYMODE_susp, ltc.t_suspc);
+                   TMODE(XTTYMODE_dsusp, ltc.t_dsuspc);
+                   TMODE(XTTYMODE_rprnt, ltc.t_rprntc);
+                   TMODE(XTTYMODE_flush, ltc.t_flushc);
+                   TMODE(XTTYMODE_weras, ltc.t_werasc);
+                   TMODE(XTTYMODE_lnext, ltc.t_lnextc);
+               }
+
+               if (ioctl(ttyfd, TIOCSETP, (char *) &sg) == -1)
+                   HsSysError(ERROR_TIOCSETP);
+               if (ioctl(ttyfd, TIOCSETC, (char *) &tc) == -1)
+                   HsSysError(ERROR_TIOCSETC);
+               if (ioctl(ttyfd, TIOCSETD, (char *) &discipline) == -1)
+                   HsSysError(ERROR_TIOCSETD);
+               if (ioctl(ttyfd, TIOCSLTC, (char *) &ltc) == -1)
+                   HsSysError(ERROR_TIOCSLTC);
+               if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1)
+                   HsSysError(ERROR_TIOCLSET);
+#ifdef sony
+               if (ioctl(ttyfd, TIOCKSET, (char *) &jmode) == -1)
+                   HsSysError(ERROR_TIOCKSET);
+               if (ioctl(ttyfd, TIOCKSETC, (char *) &jtc) == -1)
+                   HsSysError(ERROR_TIOCKSETC);
+#endif /* sony */
+#endif /* TERMIO_STRUCT */
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+               if (Console) {
+#ifdef TIOCCONS
+                   int on = 1;
+                   if (ioctl(ttyfd, TIOCCONS, (char *) &on) == -1)
+                       fprintf(stderr, "%s: cannot open console: %s\n",
+                               ProgramName, strerror(errno));
+#endif
+#ifdef SRIOCSREDIR
+                   int fd = open("/dev/console", O_RDWR);
+                   if (fd == -1 || ioctl(fd, SRIOCSREDIR, ttyfd) == -1)
+                       fprintf(stderr, "%s: cannot open console: %s\n",
+                               ProgramName, strerror(errno));
+                   IGNORE_RC(close(fd));
+#endif
+               }
+#endif /* TIOCCONS */
+           }
+
+           signal(SIGCHLD, SIG_DFL);
+#ifdef USE_SYSV_SIGHUP
+           /* watch out for extra shells (I don't understand either) */
+           signal(SIGHUP, SIG_DFL);
+#else
+           signal(SIGHUP, SIG_IGN);
+#endif
+           /* restore various signals to their defaults */
+           signal(SIGINT, SIG_DFL);
+           signal(SIGQUIT, SIG_DFL);
+           signal(SIGTERM, SIG_DFL);
+
+           /*
+            * If we're not asked to let the parent process set the terminal's
+            * erase mode, or if we had the ttyModes erase resource, then set
+            * the terminal's erase mode from our best guess.
+            */
+#if OPT_INITIAL_ERASE
+           TRACE(("check if we should set erase to %d:%s\n\tptyInitialErase:%d,\n\toveride_tty_modes:%d,\n\tXTTYMODE_erase:%d\n",
+                  initial_erase,
+                  setInitialErase ? "YES" : "NO",
+                  resource.ptyInitialErase,
+                  override_tty_modes,
+                  ttymodelist[XTTYMODE_erase].set));
+           if (setInitialErase) {
+#if OPT_TRACE
+               int old_erase;
+#endif
+#ifdef TERMIO_STRUCT
+               if (ttyGetAttr(ttyfd, &tio) == -1)
+                   tio = d_tio;
+#if OPT_TRACE
+               old_erase = tio.c_cc[VERASE];
+#endif
+               tio.c_cc[VERASE] = initial_erase;
+               TRACE_RC(rc, ttySetAttr(ttyfd, &tio));
+#else /* !TERMIO_STRUCT */
+               if (ioctl(ttyfd, TIOCGETP, (char *) &sg) == -1)
+                   sg = d_sg;
+#if OPT_TRACE
+               old_erase = sg.sg_erase;
+#endif
+               sg.sg_erase = initial_erase;
+               rc = ioctl(ttyfd, TIOCSETP, (char *) &sg);
+#endif /* TERMIO_STRUCT */
+               TRACE(("%s setting erase to %d (was %d)\n",
+                      rc ? "FAIL" : "OK", initial_erase, old_erase));
+           }
+#endif
+
+           xtermCopyEnv(environ);
+
+           xtermSetenv("TERM", TermName);
+           if (!TermName)
+               *get_tcap_buffer(xw) = 0;
+
+           sprintf(buf, "%lu",
+                   ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU()))));
+           xtermSetenv("WINDOWID", buf);
+
+           /* put the display into the environment of the shell */
+           xtermSetenv("DISPLAY", XDisplayString(screen->display));
+
+           xtermSetenv("XTERM_VERSION", xtermVersion());
+           xtermSetenv("XTERM_LOCALE", xtermEnvLocale());
+
+           signal(SIGTERM, SIG_DFL);
+
+           /* this is the time to go and set up stdin, out, and err
+            */
+           {
+#if defined(CRAY) && (OSMAJORVERSION >= 6)
+               close_fd(ttyfd);
+
+               IGNORE_RC(close(0));
+
+               if (open("/dev/tty", O_RDWR)) {
+                   SysError(ERROR_OPDEVTTY);
+               }
+               IGNORE_RC(close(1));
+               IGNORE_RC(close(2));
+               dup(0);
+               dup(0);
+#else
+               /* dup the tty */
+               for (i = 0; i <= 2; i++)
+                   if (i != ttyfd) {
+                       IGNORE_RC(close(i));
+                       IGNORE_RC(dup(ttyfd));
+                   }
+#ifndef ATT
+               /* and close the tty */
+               if (ttyfd > 2)
+                   close_fd(ttyfd);
+#endif
+#endif /* CRAY */
+           }
+
+#if !defined(USE_SYSV_PGRP)
+#ifdef TIOCSCTTY
+           setsid();
+           ioctl(0, TIOCSCTTY, 0);
+#endif
+           ioctl(0, TIOCSPGRP, (char *) &pgrp);
+           setpgrp(0, 0);
+           close(open(ttydev, O_WRONLY));
+           setpgrp(0, pgrp);
+#if defined(__QNX__)
+           tcsetpgrp(0, pgrp /*setsid() */ );
+#endif
+#endif /* !USE_SYSV_PGRP */
+
+#ifdef Lynx
+           {
+               TERMIO_STRUCT t;
+               if (ttyGetAttr(0, &t) >= 0) {
+                   /* this gets lost somewhere on our way... */
+                   t.c_oflag |= OPOST;
+                   ttySetAttr(0, &t);
+               }
+           }
+#endif
+
+#ifdef HAVE_UTMP
+           pw = getpwuid(screen->uid);
+           login_name = NULL;
+           if (pw && pw->pw_name) {
+#ifdef HAVE_GETLOGIN
+               /*
+                * If the value from getlogin() differs from the value we
+                * get by looking in the password file, check if it does
+                * correspond to the same uid.  If so, allow that as an
+                * alias for the uid.
+                *
+                * Of course getlogin() will fail if we're started from
+                * a window-manager, since there's no controlling terminal
+                * to fuss with.  In that case, try to get something useful
+                * from the user's $LOGNAME or $USER environment variables.
+                */
+               if (((login_name = getlogin()) != NULL
+                    || (login_name = x_getenv("LOGNAME")) != NULL
+                    || (login_name = x_getenv("USER")) != NULL)
+                   && strcmp(login_name, pw->pw_name)) {
+                   struct passwd *pw2 = getpwnam(login_name);
+                   if (pw2 != 0) {
+                       uid_t uid2 = pw2->pw_uid;
+                       pw = getpwuid(screen->uid);
+                       if ((uid_t) pw->pw_uid != uid2)
+                           login_name = NULL;
+                   } else {
+                       pw = getpwuid(screen->uid);
+                   }
+               }
+#endif
+               if (login_name == NULL)
+                   login_name = pw->pw_name;
+               if (login_name != NULL)
+                   login_name = x_strdup(login_name);
+           }
+           if (login_name != NULL) {
+               xtermSetenv("LOGNAME", login_name);     /* for POSIX */
+           }
+#ifndef USE_UTEMPTER
+#ifdef USE_UTMP_SETGID
+           setEffectiveGroup(save_egid);
+           TRACE_IDS;
+#endif
+#ifdef USE_SYSV_UTMP
+           /* Set up our utmp entry now.  We need to do it here
+            * for the following reasons:
+            *   - It needs to have our correct process id (for
+            *     login).
+            *   - If our parent was to set it after the fork(),
+            *     it might make it out before we need it.
+            *   - We need to do it before we go and change our
+            *     user and group id's.
+            */
+           (void) call_setutent();
+           init_utmp(DEAD_PROCESS, &utmp);
+
+           /* position to entry in utmp file */
+           /* Test return value: beware of entries left behind: PSz 9 Mar 00 */
+           utret = find_utmp(&utmp);
+           if (utret == 0) {
+               (void) call_setutent();
+               init_utmp(USER_PROCESS, &utmp);
+               utret = find_utmp(&utmp);
+               if (utret == 0) {
+                   (void) call_setutent();
+               }
+           }
+#if OPT_TRACE
+           if (!utret)
+               TRACE(("getutid: NULL\n"));
+           else
+               TRACE(("getutid: pid=%d type=%d user=%s line=%s id=%s\n",
+                      (int) utret->ut_pid, utret->ut_type, utret->ut_user,
+                      utret->ut_line, utret->ut_id));
+#endif
+
+           /* set up the new entry */
+           utmp.ut_type = USER_PROCESS;
+#ifdef HAVE_UTMP_UT_XSTATUS
+           utmp.ut_xstatus = 2;
+#endif
+           (void) strncpy(utmp.ut_user,
+                          (login_name != NULL) ? login_name : "????",
+                          sizeof(utmp.ut_user));
+           /* why are we copying this string again?  (see above) */
+           (void) strncpy(utmp.ut_id, my_utmp_id(ttydev), sizeof(utmp.ut_id));
+           (void) strncpy(utmp.ut_line,
+                          my_pty_name(ttydev), sizeof(utmp.ut_line));
+
+#ifdef HAVE_UTMP_UT_HOST
+           SetUtmpHost(utmp.ut_host, screen);
+#endif
+#ifdef HAVE_UTMP_UT_SYSLEN
+           SetUtmpSysLen(utmp);
+#endif
+
+           (void) strncpy(utmp.ut_name,
+                          (login_name) ? login_name : "????",
+                          sizeof(utmp.ut_name));
+
+           utmp.ut_pid = getpid();
+#if defined(HAVE_UTMP_UT_XTIME)
+#if defined(HAVE_UTMP_UT_SESSION)
+           utmp.ut_session = getsid(0);
+#endif
+           utmp.ut_xtime = time((time_t *) 0);
+           utmp.ut_tv.tv_usec = 0;
+#else
+           utmp.ut_time = time((time_t *) 0);
+#endif
+
+           /* write out the entry */
+           if (!resource.utmpInhibit) {
+               errno = 0;
+               call_pututline(&utmp);
+               TRACE(("pututline: id %s, line %s, pid %ld, errno %d %s\n",
+                      utmp.ut_id,
+                      utmp.ut_line,
+                      (long) utmp.ut_pid,
+                      errno, (errno != 0) ? strerror(errno) : ""));
+           }
+#ifdef WTMP
+#if defined(WTMPX_FILE) && (defined(SVR4) || defined(__SCO__))
+           if (xw->misc.login_shell)
+               updwtmpx(WTMPX_FILE, &utmp);
+#elif defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0))
+           if (xw->misc.login_shell)
+               call_updwtmp(etc_wtmp, &utmp);
+#else
+           if (xw->misc.login_shell &&
+               (i = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+               write(i, (char *) &utmp, sizeof(utmp));
+               close(i);
+           }
+#endif
+#endif
+           /* close the file */
+           (void) call_endutent();
+
+#else /* USE_SYSV_UTMP */
+           /* We can now get our ttyslot!  We can also set the initial
+            * utmp entry.
+            */
+           tslot = ttyslot();
+           added_utmp_entry = False;
+           {
+               if (tslot > 0 && pw && !resource.utmpInhibit &&
+                   (i = open(etc_utmp, O_WRONLY)) >= 0) {
+                   memset(&utmp, 0, sizeof(utmp));
+                   (void) strncpy(utmp.ut_line,
+                                  my_pty_name(ttydev),
+                                  sizeof(utmp.ut_line));
+                   (void) strncpy(utmp.ut_name, login_name,
+                                  sizeof(utmp.ut_name));
+#ifdef HAVE_UTMP_UT_HOST
+                   SetUtmpHost(utmp.ut_host, screen);
+#endif
+#ifdef HAVE_UTMP_UT_SYSLEN
+                   SetUtmpSysLen(utmp);
+#endif
+
+                   utmp.ut_time = time((time_t *) 0);
+                   lseek(i, (long) (tslot * sizeof(utmp)), 0);
+                   write(i, (char *) &utmp, sizeof(utmp));
+                   close(i);
+                   added_utmp_entry = True;
+#if defined(WTMP)
+                   if (xw->misc.login_shell &&
+                       (i = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+                       int status;
+                       status = write(i, (char *) &utmp, sizeof(utmp));
+                       status = close(i);
+                   }
+#elif defined(MNX_LASTLOG)
+                   if (xw->misc.login_shell &&
+                       (i = open(_U_LASTLOG, O_WRONLY)) >= 0) {
+                       lseek(i, (long) (screen->uid *
+                                        sizeof(utmp)), 0);
+                       write(i, (char *) &utmp, sizeof(utmp));
+                       close(i);
+                   }
+#endif /* WTMP or MNX_LASTLOG */
+               } else
+                   tslot = -tslot;
+           }
+
+           /* Let's pass our ttyslot to our parent so that it can
+            * clean up after us.
+            */
+#if OPT_PTY_HANDSHAKE
+           if (resource.ptyHandshake) {
+               handshake.tty_slot = tslot;
+           }
+#endif /* OPT_PTY_HANDSHAKE */
+#endif /* USE_SYSV_UTMP */
+
+#ifdef USE_LASTLOGX
+           if (xw->misc.login_shell) {
+               memset(&lastlogx, 0, sizeof(lastlogx));
+               (void) strncpy(lastlogx.ll_line,
+                              my_pty_name(ttydev),
+                              sizeof(lastlogx.ll_line));
+               X_GETTIMEOFDAY(&lastlogx.ll_tv);
+               SetUtmpHost(lastlogx.ll_host, screen);
+               updlastlogx(_PATH_LASTLOGX, screen->uid, &lastlogx);
+           }
+#endif
+
+#ifdef USE_LASTLOG
+           if (xw->misc.login_shell &&
+               (i = open(etc_lastlog, O_WRONLY)) >= 0) {
+               size_t size = sizeof(struct lastlog);
+               off_t offset = (screen->uid * size);
+
+               memset(&lastlog, 0, size);
+               (void) strncpy(lastlog.ll_line,
+                              my_pty_name(ttydev),
+                              sizeof(lastlog.ll_line));
+               SetUtmpHost(lastlog.ll_host, screen);
+               lastlog.ll_time = time((time_t *) 0);
+               if (lseek(i, offset, 0) != (off_t) (-1)) {
+                   write(i, (char *) &lastlog, size);
+               }
+               close(i);
+           }
+#endif /* USE_LASTLOG */
+
+#if defined(USE_UTMP_SETGID)
+           disableSetGid();
+           TRACE_IDS;
+#endif
+
+#if OPT_PTY_HANDSHAKE
+           /* Let our parent know that we set up our utmp entry
+            * so that it can clean up after us.
+            */
+           if (resource.ptyHandshake) {
+               handshake.status = UTMP_ADDED;
+               handshake.error = 0;
+               strcpy(handshake.buffer, ttydev);
+               TRACE_HANDSHAKE("writing", &handshake);
+               IGNORE_RC(write(cp_pipe[1], (char *) &handshake, sizeof(handshake)));
+           }
+#endif /* OPT_PTY_HANDSHAKE */
+#endif /* USE_UTEMPTER */
+#endif /* HAVE_UTMP */
+
+           IGNORE_RC(setgid(screen->gid));
+           TRACE_IDS;
+#ifdef HAS_BSD_GROUPS
+           if (geteuid() == 0 && pw) {
+               if (initgroups(login_name, pw->pw_gid)) {
+                   perror("initgroups failed");
+                   SysError(ERROR_INIGROUPS);
+               }
+           }
+#endif
+           if (setuid(screen->uid)) {
+               SysError(ERROR_SETUID);
+           }
+           TRACE_IDS;
+#if OPT_PTY_HANDSHAKE
+           if (resource.ptyHandshake) {
+               /* mark the pipes as close on exec */
+               fcntl(cp_pipe[1], F_SETFD, 1);
+               fcntl(pc_pipe[0], F_SETFD, 1);
+
+               /* We are at the point where we are going to
+                * exec our shell (or whatever).  Let our parent
+                * know we arrived safely.
+                */
+               handshake.status = PTY_GOOD;
+               handshake.error = 0;
+               (void) strcpy(handshake.buffer, ttydev);
+               TRACE_HANDSHAKE("writing", &handshake);
+               IGNORE_RC(write(cp_pipe[1],
+                               (const char *) &handshake,
+                               sizeof(handshake)));
+
+               if (resource.wait_for_map) {
+                   i = (int) read(pc_pipe[0], (char *) &handshake,
+                                  sizeof(handshake));
+                   if (i != sizeof(handshake) ||
+                       handshake.status != PTY_EXEC) {
+                       /* some very bad problem occurred */
+                       exit(ERROR_PTY_EXEC);
+                   }
+                   if (handshake.rows > 0 && handshake.cols > 0) {
+                       TRACE(("handshake ttysize: %dx%d\n",
+                              handshake.rows, handshake.cols));
+                       set_max_row(screen, handshake.rows);
+                       set_max_col(screen, handshake.cols);
+#ifdef TTYSIZE_STRUCT
+                       got_handshake_size = True;
+                       TTYSIZE_ROWS(ts) = (ttySize_t) MaxRows(screen);
+                       TTYSIZE_COLS(ts) = (ttySize_t) MaxCols(screen);
+#if defined(USE_STRUCT_WINSIZE)
+                       ts.ws_xpixel = (ttySize_t) FullWidth(screen);
+                       ts.ws_ypixel = (ttySize_t) FullHeight(screen);
+#endif
+#endif /* TTYSIZE_STRUCT */
+                   }
+               }
+           }
+#endif /* OPT_PTY_HANDSHAKE */
+
+#ifdef USE_SYSV_ENVVARS
+           {
+               char numbuf[12];
+               sprintf(numbuf, "%d", MaxCols(screen));
+               xtermSetenv("COLUMNS", numbuf);
+               sprintf(numbuf, "%d", MaxRows(screen));
+               xtermSetenv("LINES", numbuf);
+           }
+#ifdef HAVE_UTMP
+           if (pw) {           /* SVR4 doesn't provide these */
+               if (!x_getenv("HOME"))
+                   xtermSetenv("HOME", pw->pw_dir);
+               if (!x_getenv("SHELL"))
+                   xtermSetenv("SHELL", pw->pw_shell);
+           }
+#endif /* HAVE_UTMP */
+#ifdef OWN_TERMINFO_DIR
+           xtermSetenv("TERMINFO", OWN_TERMINFO_DIR);
+#endif
+#else /* USE_SYSV_ENVVARS */
+           if (*(newtc = get_tcap_buffer(xw)) != '\0') {
+               resize_termcap(xw);
+               if (xw->misc.titeInhibit && !xw->misc.tiXtraScroll) {
+                   remove_termcap_entry(newtc, "ti=");
+                   remove_termcap_entry(newtc, "te=");
+               }
+               /*
+                * work around broken termcap entries */
+               if (resource.useInsertMode) {
+                   remove_termcap_entry(newtc, "ic=");
+                   /* don't get duplicates */
+                   remove_termcap_entry(newtc, "im=");
+                   remove_termcap_entry(newtc, "ei=");
+                   remove_termcap_entry(newtc, "mi");
+                   if (*newtc)
+                       strcat(newtc, ":im=\\E[4h:ei=\\E[4l:mi:");
+               }
+               if (*newtc) {
+#if OPT_INITIAL_ERASE
+                   unsigned len;
+                   remove_termcap_entry(newtc, TERMCAP_ERASE "=");
+                   len = (unsigned) strlen(newtc);
+                   if (len != 0 && newtc[len - 1] == ':')
+                       len--;
+                   sprintf(newtc + len, ":%s=\\%03o:",
+                           TERMCAP_ERASE,
+                           CharOf(initial_erase));
+#endif
+                   xtermSetenv("TERMCAP", newtc);
+               }
+           }
+#endif /* USE_SYSV_ENVVARS */
+
+#if OPT_PTY_HANDSHAKE
+           /*
+            * Need to reset after all the ioctl bashing we did above.
+            *
+            * If we expect the waitForMap logic to set the handshake-size,
+            * use that to prevent races.
+            */
+           if (resource.ptyHandshake
+               && resource.ptySttySize
+               && (got_handshake_size || !resource.wait_for_map0)) {
+#ifdef TTYSIZE_STRUCT
+               TRACE_RC(i, SET_TTYSIZE(0, ts));
+               TRACE(("ptyHandshake SET_TTYSIZE %dx%d return %d\n",
+                      TTYSIZE_ROWS(ts),
+                      TTYSIZE_COLS(ts), i));
+#endif /* TTYSIZE_STRUCT */
+           }
+#endif /* OPT_PTY_HANDSHAKE */
+           signal(SIGHUP, SIG_DFL);
+
+           if ((ptr = explicit_shname) == NULL) {
+               if (((ptr = x_getenv("SHELL")) == NULL) &&
+                   ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) ||
+                    *(ptr = pw->pw_shell) == 0)) {
+                   ptr = x_strdup("/bin/sh");
+               }
+           } else {
+               xtermSetenv("SHELL", explicit_shname);
+           }
+           xtermSetenv("XTERM_SHELL", ptr);
+
+           shname = x_basename(ptr);
+           TRACE(("shell path '%s' leaf '%s'\n", ptr, shname));
+
+#if OPT_LUIT_PROG
+           /*
+            * Use two copies of command_to_exec, in case luit is not actually
+            * there, or refuses to run.  In that case we will fall-through to
+            * to command that the user gave anyway.
+            */
+           if (command_to_exec_with_luit && command_to_exec) {
+               xtermSetenv("XTERM_SHELL",
+                           xtermFindShell(*command_to_exec_with_luit, False));
+               TRACE(("spawning command \"%s\"\n", *command_to_exec_with_luit));
+               execvp(*command_to_exec_with_luit, command_to_exec_with_luit);
+               /* print error message on screen */
+               fprintf(stderr, "%s: Can't execvp %s: %s\n",
+                       ProgramName, *command_to_exec_with_luit, strerror(errno));
+               fprintf(stderr, "%s: cannot support your locale.\n",
+                       ProgramName);
+           }
+#endif
+           if (command_to_exec) {
+               xtermSetenv("XTERM_SHELL",
+                           xtermFindShell(*command_to_exec, False));
+               TRACE(("spawning command \"%s\"\n", *command_to_exec));
+               execvp(*command_to_exec, command_to_exec);
+               if (command_to_exec[1] == 0)
+                   execlp(ptr, shname, "-c", command_to_exec[0], (void *) 0);
+               /* print error message on screen */
+               fprintf(stderr, "%s: Can't execvp %s: %s\n",
+                       ProgramName, *command_to_exec, strerror(errno));
+           }
+#ifdef USE_SYSV_SIGHUP
+           /* fix pts sh hanging around */
+           signal(SIGHUP, SIG_DFL);
+#endif
+
+           shname_minus = CastMallocN(char, strlen(shname) + 2);
+           (void) strcpy(shname_minus, "-");
+           (void) strcat(shname_minus, shname);
+#ifndef TERMIO_STRUCT
+           ldisc = XStrCmp("csh", shname + strlen(shname) - 3) == 0 ?
+               NTTYDISC : 0;
+           ioctl(0, TIOCSETD, (char *) &ldisc);
+#endif /* !TERMIO_STRUCT */
+
+#ifdef USE_LOGIN_DASH_P
+           if (xw->misc.login_shell && pw && added_utmp_entry)
+               execl(bin_login, "login", "-p", "-f", login_name, (void *) 0);
+#endif
+
+#if OPT_LUIT_PROG
+           if (command_to_exec_with_luit) {
+               if (xw->misc.login_shell) {
+                   int u;
+                   u = (term->misc.use_encoding ? 2 : 0);
+                   command_to_exec_with_luit[u + 1] = x_strdup("-argv0");
+                   command_to_exec_with_luit[u + 2] = shname_minus;
+                   command_to_exec_with_luit[u + 3] = NULL;
+               }
+               execvp(*command_to_exec_with_luit, command_to_exec_with_luit);
+               /* Exec failed. */
+               fprintf(stderr, "%s: Can't execvp %s: %s\n", ProgramName,
+                       *command_to_exec_with_luit, strerror(errno));
+           }
+#endif
+           execlp(ptr,
+                  (xw->misc.login_shell ? shname_minus : shname),
+                  (void *) 0);
+
+           /* Exec failed. */
+           fprintf(stderr, "%s: Could not exec %s: %s\n", ProgramName,
+                   ptr, strerror(errno));
+           IGNORE_RC(sleep(5));
+           exit(ERROR_EXEC);
+       }
+       /* end if in child after fork */
+#if OPT_PTY_HANDSHAKE
+       if (resource.ptyHandshake) {
+           /* Parent process.  Let's handle handshaked requests to our
+            * child process.
+            */
+
+           /* close childs's sides of the pipes */
+           close(cp_pipe[1]);
+           close(pc_pipe[0]);
+
+           for (done = 0; !done;) {
+               if (read(cp_pipe[0],
+                        (char *) &handshake,
+                        sizeof(handshake)) <= 0) {
+                   /* Our child is done talking to us.  If it terminated
+                    * due to an error, we will catch the death of child
+                    * and clean up.
+                    */
+                   break;
+               }
+
+               TRACE_HANDSHAKE("read", &handshake);
+               switch (handshake.status) {
+               case PTY_GOOD:
+                   /* Success!  Let's free up resources and
+                    * continue.
+                    */
+                   done = 1;
+                   break;
+
+               case PTY_BAD:
+                   /* The open of the pty failed!  Let's get
+                    * another one.
+                    */
+                   IGNORE_RC(close(screen->respond));
+                   if (get_pty(&screen->respond, XDisplayString(screen->display))) {
+                       /* no more ptys! */
+                       fprintf(stderr,
+                               "%s: child process can find no available ptys: %s\n",
+                               ProgramName, strerror(errno));
+                       handshake.status = PTY_NOMORE;
+                       TRACE_HANDSHAKE("writing", &handshake);
+                       IGNORE_RC(write(pc_pipe[1],
+                                       (const char *) &handshake,
+                                       sizeof(handshake)));
+                       exit(ERROR_PTYS);
+                   }
+                   handshake.status = PTY_NEW;
+                   (void) strcpy(handshake.buffer, ttydev);
+                   TRACE_HANDSHAKE("writing", &handshake);
+                   IGNORE_RC(write(pc_pipe[1],
+                                   (const char *) &handshake,
+                                   sizeof(handshake)));
+                   break;
+
+               case PTY_FATALERROR:
+                   errno = handshake.error;
+                   close(cp_pipe[0]);
+                   close(pc_pipe[1]);
+                   SysError(handshake.fatal_error);
+                   /*NOTREACHED */
+
+               case UTMP_ADDED:
+                   /* The utmp entry was set by our slave.  Remember
+                    * this so that we can reset it later.
+                    */
+                   added_utmp_entry = True;
+#ifndef        USE_SYSV_UTMP
+                   tslot = handshake.tty_slot;
+#endif /* USE_SYSV_UTMP */
+                   free(ttydev);
+                   ttydev = x_strdup(handshake.buffer);
+                   break;
+               case PTY_NEW:
+               case PTY_NOMORE:
+               case UTMP_TTYSLOT:
+               case PTY_EXEC:
+               default:
+                   fprintf(stderr, "%s: unexpected handshake status %d\n",
+                           ProgramName,
+                           (int) handshake.status);
+               }
+           }
+           /* close our sides of the pipes */
+           if (!resource.wait_for_map) {
+               close(cp_pipe[0]);
+               close(pc_pipe[1]);
+           }
+       }
+#endif /* OPT_PTY_HANDSHAKE */
+    }
+
+    /* end if no slave */
+    /*
+     * still in parent (xterm process)
+     */
+#ifdef USE_SYSV_SIGHUP
+    /* hung sh problem? */
+    signal(SIGHUP, SIG_DFL);
+#else
+    signal(SIGHUP, SIG_IGN);
+#endif
+
+/*
+ * Unfortunately, System V seems to have trouble divorcing the child process
+ * from the process group of xterm.  This is a problem because hitting the
+ * INTR or QUIT characters on the keyboard will cause xterm to go away if we
+ * don't ignore the signals.  This is annoying.
+ */
+
+#if defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP)
+    signal(SIGINT, SIG_IGN);
+
+#ifndef SYSV
+    /* hung shell problem */
+    signal(SIGQUIT, SIG_IGN);
+#endif
+    signal(SIGTERM, SIG_IGN);
+#elif defined(SYSV) || defined(__osf__)
+    /* if we were spawned by a jobcontrol smart shell (like ksh or csh),
+     * then our pgrp and pid will be the same.  If we were spawned by
+     * a jobcontrol dumb shell (like /bin/sh), then we will be in our
+     * parent's pgrp, and we must ignore keyboard signals, or we will
+     * tank on everything.
+     */
+    if (getpid() == getpgrp()) {
+       (void) signal(SIGINT, Exit);
+       (void) signal(SIGQUIT, Exit);
+       (void) signal(SIGTERM, Exit);
+    } else {
+       (void) signal(SIGINT, SIG_IGN);
+       (void) signal(SIGQUIT, SIG_IGN);
+       (void) signal(SIGTERM, SIG_IGN);
+    }
+    (void) signal(SIGPIPE, Exit);
+#else /* SYSV */
+    signal(SIGINT, Exit);
+    signal(SIGQUIT, Exit);
+    signal(SIGTERM, Exit);
+    signal(SIGPIPE, Exit);
+#endif /* USE_SYSV_SIGNALS and not SIGTSTP */
+
+    return 0;
+}                              /* end spawnXTerm */
+
+SIGNAL_T
+Exit(int n)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+#ifdef USE_UTEMPTER
+    if (!resource.utmpInhibit && added_utmp_entry)
+       removeFromUtmp();
+#elif defined(HAVE_UTMP)
+#ifdef USE_SYSV_UTMP
+    struct UTMP_STR utmp;
+    struct UTMP_STR *utptr;
+
+    /* don't do this more than once */
+    if (xterm_exiting)
+       SIGNAL_RETURN;
+    xterm_exiting = True;
+
+#ifdef PUCC_PTYD
+    closepty(ttydev, ptydev, (resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN), screen->respond);
+#endif /* PUCC_PTYD */
+
+    /* cleanup the utmp entry we forged earlier */
+    if (!resource.utmpInhibit
+#if OPT_PTY_HANDSHAKE          /* without handshake, no way to know */
+       && (resource.ptyHandshake && added_utmp_entry)
+#endif /* OPT_PTY_HANDSHAKE */
+       ) {
+#if defined(USE_UTMP_SETGID)
+       setEffectiveGroup(save_egid);
+       TRACE_IDS;
+#endif
+       init_utmp(USER_PROCESS, &utmp);
+       (void) call_setutent();
+
+       /*
+        * We could use getutline() if we didn't support old systems.
+        */
+       while ((utptr = find_utmp(&utmp)) != 0) {
+           if (utptr->ut_pid == screen->pid) {
+               utptr->ut_type = DEAD_PROCESS;
+#if defined(HAVE_UTMP_UT_XTIME)
+#if defined(HAVE_UTMP_UT_SESSION)
+               utptr->ut_session = getsid(0);
+#endif
+               utptr->ut_xtime = time((time_t *) 0);
+               utptr->ut_tv.tv_usec = 0;
+#else
+               *utptr->ut_user = 0;
+               utptr->ut_time = time((time_t *) 0);
+#endif
+               (void) call_pututline(utptr);
+#ifdef WTMP
+#if defined(WTMPX_FILE) && (defined(SVR4) || defined(__SCO__))
+               if (xw->misc.login_shell)
+                   updwtmpx(WTMPX_FILE, utptr);
+#elif defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0))
+               strncpy(utmp.ut_line, utptr->ut_line, sizeof(utmp.ut_line));
+               if (xw->misc.login_shell)
+                   call_updwtmp(etc_wtmp, utptr);
+#else
+               /* set wtmp entry if wtmp file exists */
+               if (xw->misc.login_shell) {
+                   int fd;
+                   if ((fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+                       write(fd, utptr, sizeof(*utptr));
+                       close(fd);
+                   }
+               }
+#endif
+#endif
+               break;
+           }
+           memset(utptr, 0, sizeof(*utptr));   /* keep searching */
+       }
+       (void) call_endutent();
+#ifdef USE_UTMP_SETGID
+       disableSetGid();
+       TRACE_IDS;
+#endif
+    }
+#else /* not USE_SYSV_UTMP */
+    int wfd;
+    struct utmp utmp;
+
+    if (!resource.utmpInhibit && added_utmp_entry &&
+       (am_slave < 0 && tslot > 0)) {
+#if defined(USE_UTMP_SETGID)
+       setEffectiveGroup(save_egid);
+       TRACE_IDS;
+#endif
+       if ((wfd = open(etc_utmp, O_WRONLY)) >= 0) {
+           memset(&utmp, 0, sizeof(utmp));
+           lseek(wfd, (long) (tslot * sizeof(utmp)), 0);
+           write(wfd, (char *) &utmp, sizeof(utmp));
+           close(wfd);
+       }
+#ifdef WTMP
+       if (xw->misc.login_shell &&
+           (wfd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+           (void) strncpy(utmp.ut_line,
+                          my_pty_name(ttydev),
+                          sizeof(utmp.ut_line));
+           utmp.ut_time = time((time_t *) 0);
+           write(wfd, (char *) &utmp, sizeof(utmp));
+           close(wfd);
+       }
+#endif /* WTMP */
+#ifdef USE_UTMP_SETGID
+       disableSetGid();
+       TRACE_IDS;
+#endif
+    }
+#endif /* USE_SYSV_UTMP */
+#endif /* HAVE_UTMP */
+
+    /*
+     * Flush pending data before releasing ownership, so nobody else can write
+     * in the middle of the data.
+     */
+    ttyFlush(screen->respond);
+
+    if (am_slave < 0) {
+       TRACE_IDS;
+       /* restore ownership of tty and pty */
+       set_owner(ttydev, 0, 0, 0666U);
+#if (defined(USE_PTY_DEVICE) && !defined(__sgi) && !defined(__hpux))
+       set_owner(ptydev, 0, 0, 0666U);
+#endif
+    }
+
+    /*
+     * Close after releasing ownership to avoid race condition: other programs 
+     * grabbing it, and *then* having us release ownership....
+     */
+    close(screen->respond);    /* close explicitly to avoid race with slave side */
+#ifdef ALLOWLOGGING
+    if (screen->logging)
+       CloseLog(xw);
+#endif
+
+#ifdef NO_LEAKS
+    if (n == 0) {
+       TRACE(("Freeing memory leaks\n"));
+       if (xw != 0) {
+           Display *dpy = TScreenOf(xw)->display;
+
+           if (toplevel) {
+               XtDestroyWidget(toplevel);
+               TRACE(("destroyed top-level widget\n"));
+           }
+           sortedOpts(0, 0, 0);
+           noleaks_charproc();
+           noleaks_ptydata();
+#if OPT_WIDE_CHARS
+           noleaks_CharacterClass();
+#endif
+           /* XrmSetDatabase(dpy, 0); increases leaks ;-) */
+           XtCloseDisplay(dpy);
+           XtDestroyApplicationContext(app_con);
+#if OPT_SESSION_MGT
+           IceRemoveConnectionWatch(icewatch, NULL);
+#endif
+           TRACE(("closed display\n"));
+       }
+       TRACE_CLOSE();
+    }
+#endif
+
+    exit(n);
+    SIGNAL_RETURN;
+}
+
+/* ARGSUSED */
+static void
+resize_termcap(XtermWidget xw)
+{
+    char *newtc = get_tcap_buffer(xw);
+
+#ifndef USE_SYSV_ENVVARS
+    if (!TEK4014_ACTIVE(xw) && *newtc) {
+       TScreen *screen = TScreenOf(xw);
+       char *ptr1, *ptr2;
+       size_t i;
+       int li_first = 0;
+       char *temp;
+       char oldtc[TERMCAP_SIZE];
+
+       strcpy(oldtc, newtc);
+       TRACE(("resize %s\n", oldtc));
+       if ((ptr1 = x_strindex(oldtc, "co#")) == NULL) {
+           strcat(oldtc, "co#80:");
+           ptr1 = x_strindex(oldtc, "co#");
+       }
+       if ((ptr2 = x_strindex(oldtc, "li#")) == NULL) {
+           strcat(oldtc, "li#24:");
+           ptr2 = x_strindex(oldtc, "li#");
+       }
+       if (ptr1 > ptr2) {
+           li_first++;
+           temp = ptr1;
+           ptr1 = ptr2;
+           ptr2 = temp;
+       }
+       ptr1 += 3;
+       ptr2 += 3;
+       strncpy(newtc, oldtc, i = (size_t) (ptr1 - oldtc));
+       temp = newtc + i;
+       sprintf(temp, "%d", (li_first
+                            ? MaxRows(screen)
+                            : MaxCols(screen)));
+       temp += strlen(temp);
+       ptr1 = strchr(ptr1, ':');
+       strncpy(temp, ptr1, i = (size_t) (ptr2 - ptr1));
+       temp += i;
+       sprintf(temp, "%d", (li_first
+                            ? MaxCols(screen)
+                            : MaxRows(screen)));
+       ptr2 = strchr(ptr2, ':');
+       strcat(temp, ptr2);
+       TRACE(("   ==> %s\n", newtc));
+       TRACE(("   new size %dx%d\n", MaxRows(screen), MaxCols(screen)));
+    }
+#endif /* USE_SYSV_ENVVARS */
+}
+
+#endif /* ! VMS */
+
+/*
+ * Does a non-blocking wait for a child process.  If the system
+ * doesn't support non-blocking wait, do nothing.
+ * Returns the pid of the child, or 0 or -1 if none or error.
+ */
+int
+nonblocking_wait(void)
+{
+#ifdef USE_POSIX_WAIT
+    pid_t pid;
+
+    pid = waitpid(-1, NULL, WNOHANG);
+#elif defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP))
+    /* cannot do non-blocking wait */
+    int pid = 0;
+#else /* defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP)) */
+#if defined(Lynx)
+    int status;
+#else
+    union wait status;
+#endif
+    int pid;
+
+    pid = wait3(&status, WNOHANG, (struct rusage *) NULL);
+#endif /* USE_POSIX_WAIT else */
+    return pid;
+}
+
+#ifndef VMS
+
+/* ARGSUSED */
+static SIGNAL_T
+reapchild(int n GCC_UNUSED)
+{
+    int olderrno = errno;
+    int pid;
+
+    pid = wait(NULL);
+
+#ifdef USE_SYSV_SIGNALS
+    /* cannot re-enable signal before waiting for child
+     * because then SVR4 loops.  Sigh.  HP-UX 9.01 too.
+     */
+    (void) signal(SIGCHLD, reapchild);
+#endif
+
+    do {
+       if (pid == TScreenOf(term)->pid) {
+#ifdef DEBUG
+           if (debug)
+               fputs("Exiting\n", stderr);
+#endif
+           if (!hold_screen)
+               need_cleanup = True;
+       }
+    } while ((pid = nonblocking_wait()) > 0);
+
+    errno = olderrno;
+    SIGNAL_RETURN;
+}
+#endif /* !VMS */
+
+static void
+remove_termcap_entry(char *buf, const char *str)
+{
+    char *base = buf;
+    char *first = base;
+    int count = 0;
+    size_t len = strlen(str);
+
+    TRACE(("*** remove_termcap_entry('%s', '%s')\n", str, buf));
+
+    while (*buf != 0) {
+       if (!count && !strncmp(buf, str, len)) {
+           while (*buf != 0) {
+               if (*buf == '\\')
+                   buf++;
+               else if (*buf == ':')
+                   break;
+               if (*buf != 0)
+                   buf++;
+           }
+           while ((*first++ = *buf++) != 0) ;
+           TRACE(("...removed_termcap_entry('%s', '%s')\n", str, base));
+           return;
+       } else if (*buf == '\\') {
+           buf++;
+       } else if (*buf == ':') {
+           first = buf;
+           count = 0;
+       } else if (!isspace(CharOf(*buf))) {
+           count++;
+       }
+       if (*buf != 0)
+           buf++;
+    }
+    TRACE(("...cannot remove\n"));
+}
+
+/*
+ * parse_tty_modes accepts lines of the following form:
+ *
+ *         [SETTING] ...
+ *
+ * where setting consists of the words in the modelist followed by a character
+ * or ^char.
+ */
+static int
+parse_tty_modes(char *s, struct _xttymodes *modelist)
+{
+    struct _xttymodes *mp;
+    int c;
+    int count = 0;
+
+    TRACE(("parse_tty_modes\n"));
+    for (;;) {
+       size_t len;
+
+       while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s)))
+           s++;
+       if (!*s)
+           return count;
+
+       for (len = 0; isalnum(CharOf(s[len])); ++len) ;
+       for (mp = modelist; mp->name; mp++) {
+           if (len == mp->len
+               && strncmp(s, mp->name, mp->len) == 0)
+               break;
+       }
+       if (!mp->name)
+           return -1;
+
+       s += mp->len;
+       while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s)))
+           s++;
+       if (!*s)
+           return -1;
+
+       if ((c = decode_keyvalue(&s, False)) != -1) {
+           mp->value = c;
+           mp->set = 1;
+           count++;
+           TRACE(("...parsed #%d: %s=%#x\n", count, mp->name, c));
+       }
+    }
+}
+
+#ifndef VMS                    /* don't use pipes on OpenVMS */
+int
+GetBytesAvailable(int fd)
+{
+#if defined(FIONREAD)
+    int arg;
+    ioctl(fd, FIONREAD, (char *) &arg);
+    return (int) arg;
+#elif defined(__CYGWIN__)
+    fd_set set;
+    struct timeval select_timeout =
+    {0, 0};
+
+    FD_ZERO(&set);
+    FD_SET(fd, &set);
+    if (Select(fd + 1, &set, NULL, NULL, &select_timeout) > 0)
+       return 1;
+    else
+       return 0;
+#elif defined(FIORDCK)
+    return (ioctl(fd, FIORDCHK, NULL));
+#else /* !FIORDCK */
+    struct pollfd pollfds[1];
+
+    pollfds[0].fd = fd;
+    pollfds[0].events = POLLIN;
+    return poll(pollfds, 1, 0);
+#endif
+}
+#endif /* !VMS */
+
+/* Utility function to try to hide system differences from
+   everybody who used to call killpg() */
+
+int
+kill_process_group(int pid, int sig)
+{
+    TRACE(("kill_process_group(pid=%d, sig=%d)\n", pid, sig));
+#if defined(SVR4) || defined(SYSV) || !defined(X_NOT_POSIX)
+    return kill(-pid, sig);
+#else
+    return killpg(pid, sig);
+#endif
+}
+
+#if OPT_EBCDIC
+int
+A2E(int x)
+{
+    char c;
+    c = x;
+    __atoe_l(&c, 1);
+    return c;
+}
+
+int
+E2A(int x)
+{
+    char c;
+    c = x;
+    __etoa_l(&c, 1);
+    return c;
+}
+#endif
+
+#if defined(__QNX__) && !defined(__QNXNTO__)
+#include <sys/types.h>
+#include <sys/proc_msg.h>
+#include <sys/kernel.h>
+#include <string.h>
+#include <errno.h>
+
+struct _proc_session ps;
+struct _proc_session_reply rps;
+
+int
+qsetlogin(char *login, char *ttyname)
+{
+    int v = getsid(getpid());
+
+    memset(&ps, 0, sizeof(ps));
+    memset(&rps, 0, sizeof(rps));
+
+    ps.type = _PROC_SESSION;
+    ps.subtype = _PROC_SUB_ACTION1;
+    ps.sid = v;
+    strcpy(ps.name, login);
+
+    Send(1, &ps, &rps, sizeof(ps), sizeof(rps));
+
+    if (rps.status < 0)
+       return (rps.status);
+
+    ps.type = _PROC_SESSION;
+    ps.subtype = _PROC_SUB_ACTION2;
+    ps.sid = v;
+    sprintf(ps.name, "//%d%s", getnid(), ttyname);
+    Send(1, &ps, &rps, sizeof(ps), sizeof(rps));
+
+    return (rps.status);
+}
+#endif
diff --git a/main.h b/main.h
new file mode 100644 (file)
index 0000000..f90d7f4
--- /dev/null
+++ b/main.h
@@ -0,0 +1,213 @@
+/* $XTermId: main.h,v 1.54 2010/06/20 20:22:32 tom Exp $ */
+
+/*
+ * Copyright 2000-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+#ifndef included_main_h
+#define included_main_h
+
+#include <xterm.h>
+
+#ifndef DEFCLASS
+#define DEFCLASS               "XTerm"
+#endif
+
+#ifndef DEFFONT
+#define DEFFONT                        "fixed"
+#endif
+
+#ifndef DEFWIDEFONT
+#define DEFWIDEFONT            NULL    /* grab one which is 2x as wide */
+#endif
+
+#ifndef DEFWIDEBOLDFONT
+#define DEFWIDEBOLDFONT                NULL
+#endif
+
+#ifndef DEFXIMFONT
+#define DEFXIMFONT             "fixed"
+#endif
+
+#ifndef DEFBOLDFONT
+#define DEFBOLDFONT            NULL    /* no bold font uses overstriking */
+#endif
+
+#ifndef DEFBORDER
+#define DEFBORDER              2
+#endif
+
+#ifndef DEFFACENAME
+#define DEFFACENAME            NULL
+#endif
+
+#ifndef DEFFACENAME_AUTO
+#define DEFFACENAME_AUTO       "mono"
+#endif
+
+#ifndef DEFFACESIZE
+#define DEFFACESIZE            "14.0"
+#endif
+
+#ifndef DEFFACESIZE
+#define DEFFACESIZE_AUTO       "8.0"
+#endif
+
+#ifndef DEF_ALLOW_COLOR
+#define DEF_ALLOW_COLOR                True
+#endif
+
+#ifndef DEF_ALLOW_FONT
+#define DEF_ALLOW_FONT         True
+#endif
+
+#ifndef DEF_ALLOW_TCAP
+#define DEF_ALLOW_TCAP         True
+#endif
+
+#ifndef DEF_ALLOW_TITLE
+#define DEF_ALLOW_TITLE                True
+#endif
+
+#ifndef DEF_ALLOW_WINDOW
+#define DEF_ALLOW_WINDOW       False
+#endif
+
+#ifndef DEF_DISALLOWED_COLOR
+#define DEF_DISALLOWED_COLOR   "SetColor,GetColor,GetAnsiColor"
+#endif
+
+#ifndef DEF_DISALLOWED_FONT
+#define DEF_DISALLOWED_FONT    "SetFont,GetFont"
+#endif
+
+#ifndef DEF_DISALLOWED_TCAP
+#define DEF_DISALLOWED_TCAP    "SetTcap,GetTcap"
+#endif
+
+#ifndef DEF_DISALLOWED_WINDOW
+#define DEF_DISALLOWED_WINDOW  "20,21,SetXprop,SetSelection"
+#endif
+
+#if OPT_BLINK_TEXT
+#define DEFBLINKASBOLD         False
+#else
+#define DEFBLINKASBOLD         True
+#endif
+
+#ifndef DEFDELETE_DEL
+#define DEFDELETE_DEL          Maybe
+#endif
+
+#ifndef DEF_BACKARO_ERASE
+#define DEF_BACKARO_ERASE      False
+#endif
+
+#ifndef DEF_COLOR4
+#define DEF_COLOR4             "blue2"         /* see XTerm-col.ad */
+#endif
+
+#ifndef DEF_COLOR12
+#define DEF_COLOR12            "rgb:5c/5c/ff"  /* see XTerm-col.ad */
+#endif
+
+#ifndef DEF_INITIAL_ERASE
+#define DEF_INITIAL_ERASE      False
+#endif
+
+#ifndef DEF_MENU_LOCALE
+#define DEF_MENU_LOCALE                "C"
+#endif
+
+#ifndef DEF_POINTER_MODE
+#define DEF_POINTER_MODE       pNoMouse
+#endif
+
+#ifndef DEF_PTY_STTY_SIZE
+#if defined(linux) || defined(__APPLE__)
+#define DEF_PTY_STTY_SIZE      False
+#else
+#define DEF_PTY_STTY_SIZE      True
+#endif
+#endif
+
+#ifndef DEF_TITLE_MODES
+#define DEF_TITLE_MODES                0
+#endif
+
+#ifndef PROJECTROOT
+#define PROJECTROOT            "/usr/X11R6"
+#endif
+
+/*
+ * The configure script quotes PROJECTROOT's value.
+ * imake does not quote PROJECTROOT's value.
+ */
+#ifdef HAVE_CONFIG_H
+#define DEFLOCALEFILTER2(x)    x
+#else
+#define DEFLOCALEFILTER2(x)    #x
+#endif
+
+/*
+ * If the configure script finds luit, we have the path directly.
+ */
+#ifdef LUIT_PATH
+#define DEFLOCALEFILTER                LUIT_PATH
+#else
+#define DEFLOCALEFILTER1(x)    DEFLOCALEFILTER2(x)
+#define DEFLOCALEFILTER                DEFLOCALEFILTER1(PROJECTROOT) "/bin/luit"
+#endif
+
+/*
+ * See lib/Xt/Resources.c
+ */
+#define MAXRESOURCES            400
+
+#endif /* included_main_h */
diff --git a/make.com b/make.com
new file mode 100644 (file)
index 0000000..d2b662b
--- /dev/null
+++ b/make.com
@@ -0,0 +1,90 @@
+$! make.com
+$! 25-JAN-2000, David Mathog
+$! builds xaw3d, xmu, and then xterm.
+$!
+$! $XFree86: xc/programs/xterm/make.com,v 1.1 2000/02/08 17:19:37 dawes Exp $
+$!
+$!************************************************************
+$!
+$! set up logicals for XAW, XMU and so forth
+$!
+$ define x11_directory decw$include
+$ thisfile = f$environment("PROCEDURE")
+$ thisis   = f$parse(thisfile,,,"DEVICE") + f$parse(thisfile,,,"DIRECTORY")
+$ thisis = thisis - "]"
+$ define xaw_directory "''thisis'.lib.xaw3d]"
+$ define xmu_directory "''thisis'.lib.xmu]"
+$ define bitmap_directory "''thisis'.lib.bitmaps]"
+$ define/trans=(concealed) thisX11 "''thisis.lib.]"
+$ define X11 thisx11,decw$include
+$!
+$! note, ansi doesn't work with this variant of X11R5.
+$!
+$! don't build libs in debug mode
+$ if(P1 .eqs. "" .AND. P2 .eqs. "")
+$ then
+$!
+$! build XMU
+$!
+$ set ver
+$ set def [.lib.xmu]
+$ @make
+$!
+$! build XAW3D
+$!
+$ set def [-.xaw3d]
+$ @make
+$ set def [--]
+$ set nover
+$!
+$! move the two libraries to this level
+$!
+$ rename [.lib...]*.olb []
+$ endif
+$!
+$ if(P1 .nes. "")
+$ then
+$   ccstub := cc/standard=vaxc/include=[]/debug/noopt
+$   mylink :== link/debug
+$ else
+$   ccstub := cc/standard=vaxc/include=[]
+$   mylink :== link
+$ endif
+$ mycc :== 'ccstub' -
+/define=(VMS,OPT_TEK4014,ALLOWLOGGING,OPT_NUM_LOCK)
+$!
+$! OPT_TOOLBAR doesn't work - it pulls in calls through Xaw3d and Xmu for
+$! XSHAPECOMBINEMASK and XSHAPEQUERYEXTENSION
+$! which seem not to exist in DW MOtif 1.2-5
+$!
+$!
+$ set ver
+$ mycc BUTTON.C
+$ mycc CHARPROC.C
+$ mycc CHARSETS.C
+$ mycc CURSOR.C
+$ mycc DATA.C
+$ mycc DOUBLECHR.C
+$ mycc FONTUTILS.C
+$ mycc INPUT.C
+$ mycc KEYSYM2UCS.C
+$ mycc MAIN.C
+$ mycc MENU.C
+$ mycc MISC.C
+$ mycc PRINT.C
+$ mycc PTYDATA.C
+$! mycc RESIZE.C
+$ mycc SCREEN.C
+$ mycc SCROLLBAR.C
+$ mycc TABS.C
+$ mycc TEKPROC.C
+$ mycc TEKPRSTBL.C
+$ mycc TRACE.C
+$ mycc TTYSVR.C
+$ mycc UTIL.C
+$ mycc VMS.C
+$ mycc VTPRSTBL.C
+$!
+$ mylink/exe=xterm.exe xterm_axp.opt/option
+$ set nover
+$ exit
diff --git a/menu.c b/menu.c
new file mode 100644 (file)
index 0000000..c4ed7e0
--- /dev/null
+++ b/menu.c
@@ -0,0 +1,3726 @@
+/* $XTermId: menu.c,v 1.279 2011/02/09 10:00:58 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1989  The Open Group
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of The Open Group shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from The Open Group.
+ */
+
+#include <xterm.h>
+#include <data.h>
+#include <menu.h>
+#include <fontutils.h>
+#include <xstrings.h>
+
+#include <locale.h>
+
+#include <X11/Xmu/CharSet.h>
+
+#define app_con Xaw_app_con    /* quiet a warning from SimpleMenu.h */
+
+#if defined(HAVE_LIB_XAW)
+
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/Box.h>
+#include <X11/Xaw/SmeBSB.h>
+#include <X11/Xaw/SmeLine.h>
+
+#if OPT_MAXIMIZE
+#include <X11/Xatom.h>
+#include <X11/Xmd.h>
+#endif
+
+#if OPT_TOOLBAR
+#include <X11/Xaw/MenuButton.h>
+#include <X11/Xaw/Form.h>
+#endif
+
+#elif defined(HAVE_LIB_XAW3D)
+
+#include <X11/Xaw3d/SimpleMenu.h>
+#include <X11/Xaw3d/Box.h>
+#include <X11/Xaw3d/SmeBSB.h>
+#include <X11/Xaw3d/SmeLine.h>
+
+#if OPT_TOOLBAR
+#include <X11/Xaw3d/MenuButton.h>
+#include <X11/Xaw3d/Form.h>
+#endif
+
+#elif defined(HAVE_LIB_NEXTAW)
+
+#include <X11/neXtaw/SimpleMenu.h>
+#include <X11/neXtaw/Box.h>
+#include <X11/neXtaw/SmeBSB.h>
+#include <X11/neXtaw/SmeLine.h>
+
+#if OPT_TOOLBAR
+#include <X11/neXtaw/MenuButton.h>
+#include <X11/neXtaw/Form.h>
+#endif
+
+#elif defined(HAVE_LIB_XAWPLUS)
+
+#include <X11/XawPlus/SimpleMenu.h>
+#include <X11/XawPlus/Box.h>
+#include <X11/XawPlus/SmeBSB.h>
+#include <X11/XawPlus/SmeLine.h>
+
+#if OPT_TOOLBAR
+#include <X11/XawPlus/MenuButton.h>
+#include <X11/XawPlus/Form.h>
+#endif
+
+#endif
+
+#undef app_con
+
+#include <stdio.h>
+#include <signal.h>
+
+#if OPT_TRACE
+#define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(func, mn, mi, val)
+#else
+#define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(mn, mi, val)
+#endif
+
+#define ToggleFlag(flag) flag = (Boolean) !flag
+/* *INDENT-OFF* */
+static void do_8bit_control    PROTO_XT_CALLBACK_ARGS;
+static void do_allow132        PROTO_XT_CALLBACK_ARGS;
+static void do_allowsends      PROTO_XT_CALLBACK_ARGS;
+static void do_altscreen       PROTO_XT_CALLBACK_ARGS;
+static void do_appcursor       PROTO_XT_CALLBACK_ARGS;
+static void do_appkeypad       PROTO_XT_CALLBACK_ARGS;
+static void do_autolinefeed    PROTO_XT_CALLBACK_ARGS;
+static void do_autowrap        PROTO_XT_CALLBACK_ARGS;
+static void do_backarrow       PROTO_XT_CALLBACK_ARGS;
+static void do_bellIsUrgent    PROTO_XT_CALLBACK_ARGS;
+static void do_clearsavedlines PROTO_XT_CALLBACK_ARGS;
+static void do_continue        PROTO_XT_CALLBACK_ARGS;
+static void do_delete_del      PROTO_XT_CALLBACK_ARGS;
+static void do_hardreset       PROTO_XT_CALLBACK_ARGS;
+static void do_interrupt       PROTO_XT_CALLBACK_ARGS;
+static void do_jumpscroll      PROTO_XT_CALLBACK_ARGS;
+static void do_kill            PROTO_XT_CALLBACK_ARGS;
+static void do_old_fkeys       PROTO_XT_CALLBACK_ARGS;
+static void do_poponbell       PROTO_XT_CALLBACK_ARGS;
+static void do_print           PROTO_XT_CALLBACK_ARGS;
+static void do_print_redir     PROTO_XT_CALLBACK_ARGS;
+static void do_quit            PROTO_XT_CALLBACK_ARGS;
+static void do_redraw          PROTO_XT_CALLBACK_ARGS;
+static void do_reversevideo    PROTO_XT_CALLBACK_ARGS;
+static void do_reversewrap     PROTO_XT_CALLBACK_ARGS;
+static void do_scrollbar       PROTO_XT_CALLBACK_ARGS;
+static void do_scrollkey       PROTO_XT_CALLBACK_ARGS;
+static void do_scrollttyoutput PROTO_XT_CALLBACK_ARGS;
+static void do_securekbd       PROTO_XT_CALLBACK_ARGS;
+static void do_keepSelection   PROTO_XT_CALLBACK_ARGS;
+static void do_selectClipboard PROTO_XT_CALLBACK_ARGS;
+static void do_softreset       PROTO_XT_CALLBACK_ARGS;
+static void do_suspend         PROTO_XT_CALLBACK_ARGS;
+static void do_terminate       PROTO_XT_CALLBACK_ARGS;
+static void do_titeInhibit     PROTO_XT_CALLBACK_ARGS;
+static void do_visualbell      PROTO_XT_CALLBACK_ARGS;
+static void do_vtfont          PROTO_XT_CALLBACK_ARGS;
+
+#ifdef ALLOWLOGGING
+static void do_logging         PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#ifndef NO_ACTIVE_ICON
+static void do_activeicon      PROTO_XT_CALLBACK_ARGS;
+#endif /* NO_ACTIVE_ICON */
+
+#if OPT_ALLOW_XXX_OPS
+static void enable_allow_xxx_ops (Bool);
+static void do_allowColorOps   PROTO_XT_CALLBACK_ARGS;
+static void do_allowFontOps    PROTO_XT_CALLBACK_ARGS;
+static void do_allowTcapOps    PROTO_XT_CALLBACK_ARGS;
+static void do_allowTitleOps   PROTO_XT_CALLBACK_ARGS;
+static void do_allowWindowOps  PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_BLINK_CURS
+static void do_cursorblink     PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_BOX_CHARS
+static void do_font_boxchars   PROTO_XT_CALLBACK_ARGS;
+static void do_font_packed     PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_DEC_CHRSET
+static void do_font_doublesize PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_DEC_SOFTFONT
+static void do_font_loadable   PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_HP_FUNC_KEYS
+static void do_hp_fkeys        PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_MAXIMIZE
+static void do_fullscreen      PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_NUM_LOCK
+static void do_alt_esc         PROTO_XT_CALLBACK_ARGS;
+static void do_num_lock        PROTO_XT_CALLBACK_ARGS;
+static void do_meta_esc        PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_RENDERFONT
+static void do_font_renderfont PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_SCO_FUNC_KEYS
+static void do_sco_fkeys       PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_SUN_FUNC_KEYS
+static void do_sun_fkeys       PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_SUNPC_KBD
+static void do_sun_kbd         PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_TCAP_FKEYS
+static void do_tcap_fkeys      PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_TEK4014
+static void do_tekcopy         PROTO_XT_CALLBACK_ARGS;
+static void do_tekhide         PROTO_XT_CALLBACK_ARGS;
+static void do_tekmode         PROTO_XT_CALLBACK_ARGS;
+static void do_tekonoff        PROTO_XT_CALLBACK_ARGS;
+static void do_tekpage         PROTO_XT_CALLBACK_ARGS;
+static void do_tekreset        PROTO_XT_CALLBACK_ARGS;
+static void do_tekshow         PROTO_XT_CALLBACK_ARGS;
+static void do_tektext2        PROTO_XT_CALLBACK_ARGS;
+static void do_tektext3        PROTO_XT_CALLBACK_ARGS;
+static void do_tektextlarge    PROTO_XT_CALLBACK_ARGS;
+static void do_tektextsmall    PROTO_XT_CALLBACK_ARGS;
+static void do_vthide          PROTO_XT_CALLBACK_ARGS;
+static void do_vtmode          PROTO_XT_CALLBACK_ARGS;
+static void do_vtonoff         PROTO_XT_CALLBACK_ARGS;
+static void do_vtshow          PROTO_XT_CALLBACK_ARGS;
+static void handle_tekshow     (Widget gw, Bool allowswitch);
+static void handle_vtshow      (Widget gw, Bool allowswitch);
+#endif
+
+#if OPT_TOOLBAR
+static void do_toolbar         PROTO_XT_CALLBACK_ARGS;
+#endif
+
+#if OPT_WIDE_CHARS
+static void do_font_utf8_mode  PROTO_XT_CALLBACK_ARGS;
+static void do_font_utf8_title PROTO_XT_CALLBACK_ARGS;
+#endif
+
+/*
+ * The order of entries MUST match the values given in menu.h
+ */
+MenuEntry mainMenuEntries[] = {
+#if OPT_TOOLBAR
+    { "toolbar",       do_toolbar,     NULL },
+#endif
+#if OPT_MAXIMIZE
+    { "fullscreen",    do_fullscreen,  NULL },
+#endif
+    { "securekbd",     do_securekbd,   NULL },
+    { "allowsends",    do_allowsends,  NULL },
+    { "redraw",                do_redraw,      NULL },
+    { "line1",         NULL,           NULL },
+#ifdef ALLOWLOGGING
+    { "logging",       do_logging,     NULL },
+#endif
+    { "print",         do_print,       NULL },
+    { "print-redir",   do_print_redir, NULL },
+    { "line2",         NULL,           NULL },
+    { "8-bit control", do_8bit_control,NULL },
+    { "backarrow key", do_backarrow,   NULL },
+#if OPT_NUM_LOCK
+    { "num-lock",      do_num_lock,    NULL },
+    { "alt-esc",       do_alt_esc,     NULL },
+    { "meta-esc",      do_meta_esc,    NULL },
+#endif
+    { "delete-is-del", do_delete_del,  NULL },
+    { "oldFunctionKeys",do_old_fkeys,  NULL },
+#if OPT_TCAP_FKEYS
+    { "tcapFunctionKeys",do_tcap_fkeys,        NULL },
+#endif
+#if OPT_HP_FUNC_KEYS
+    { "hpFunctionKeys",        do_hp_fkeys,    NULL },
+#endif
+#if OPT_SCO_FUNC_KEYS
+    { "scoFunctionKeys",do_sco_fkeys,  NULL },
+#endif
+#if OPT_SUN_FUNC_KEYS
+    { "sunFunctionKeys",do_sun_fkeys,  NULL },
+#endif
+#if OPT_SUNPC_KBD
+    { "sunKeyboard",   do_sun_kbd,     NULL },
+#endif
+    { "line3",         NULL,           NULL },
+    { "suspend",       do_suspend,     NULL },
+    { "continue",      do_continue,    NULL },
+    { "interrupt",     do_interrupt,   NULL },
+    { "hangup",                do_hangup,      NULL },
+    { "terminate",     do_terminate,   NULL },
+    { "kill",          do_kill,        NULL },
+    { "line4",         NULL,           NULL },
+    { "quit",          do_quit,        NULL }};
+
+MenuEntry vtMenuEntries[] = {
+    { "scrollbar",     do_scrollbar,   NULL },
+    { "jumpscroll",    do_jumpscroll,  NULL },
+    { "reversevideo",  do_reversevideo, NULL },
+    { "autowrap",      do_autowrap,    NULL },
+    { "reversewrap",   do_reversewrap, NULL },
+    { "autolinefeed",  do_autolinefeed, NULL },
+    { "appcursor",     do_appcursor,   NULL },
+    { "appkeypad",     do_appkeypad,   NULL },
+    { "scrollkey",     do_scrollkey,   NULL },
+    { "scrollttyoutput",do_scrollttyoutput, NULL },
+    { "allow132",      do_allow132,    NULL },
+    { "keepSelection", do_keepSelection, NULL },
+    { "selectToClipboard",do_selectClipboard, NULL },
+    { "visualbell",    do_visualbell,  NULL },
+    { "bellIsUrgent",  do_bellIsUrgent, NULL },
+    { "poponbell",     do_poponbell,   NULL },
+#if OPT_BLINK_CURS
+    { "cursorblink",   do_cursorblink, NULL },
+#endif
+    { "titeInhibit",   do_titeInhibit, NULL },
+#ifndef NO_ACTIVE_ICON
+    { "activeicon",    do_activeicon,  NULL },
+#endif /* NO_ACTIVE_ICON */
+    { "line1",         NULL,           NULL },
+    { "softreset",     do_softreset,   NULL },
+    { "hardreset",     do_hardreset,   NULL },
+    { "clearsavedlines",do_clearsavedlines, NULL },
+    { "line2",         NULL,           NULL },
+#if OPT_TEK4014
+    { "tekshow",       do_tekshow,     NULL },
+    { "tekmode",       do_tekmode,     NULL },
+    { "vthide",                do_vthide,      NULL },
+#endif
+    { "altscreen",     do_altscreen,   NULL },
+    };
+
+MenuEntry fontMenuEntries[] = {
+    { "fontdefault",   do_vtfont,      NULL },
+    { "font1",         do_vtfont,      NULL },
+    { "font2",         do_vtfont,      NULL },
+    { "font3",         do_vtfont,      NULL },
+    { "font4",         do_vtfont,      NULL },
+    { "font5",         do_vtfont,      NULL },
+    { "font6",         do_vtfont,      NULL },
+    /* this is after the last builtin font; the other entries are special */
+    { "fontescape",    do_vtfont,      NULL },
+    { "fontsel",       do_vtfont,      NULL },
+    /* down to here should match NMENUFONTS in ptyx.h */
+
+#if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT
+    { "line1",         NULL,           NULL },
+#if OPT_BOX_CHARS
+    { "font-linedrawing",do_font_boxchars,NULL },
+    { "font-packed",   do_font_packed,NULL },
+#endif
+#if OPT_DEC_CHRSET
+    { "font-doublesize",do_font_doublesize,NULL },
+#endif
+#if OPT_DEC_SOFTFONT
+    { "font-loadable", do_font_loadable,NULL },
+#endif
+#endif /* toggles for DEC font extensions */
+
+#if OPT_RENDERFONT || OPT_WIDE_CHARS
+    { "line2",         NULL,           NULL },
+#if OPT_RENDERFONT
+    { "render-font",   do_font_renderfont,NULL },
+#endif
+#if OPT_WIDE_CHARS
+    { "utf8-mode",     do_font_utf8_mode,NULL },
+    { "utf8-title",    do_font_utf8_title,NULL },
+#endif
+#endif /* toggles for other font extensions */
+
+#if OPT_ALLOW_XXX_OPS
+    { "line3",         NULL,           NULL },
+    { "allow-color-ops",do_allowColorOps,NULL },
+    { "allow-font-ops",        do_allowFontOps,NULL },
+    { "allow-tcap-ops",        do_allowTcapOps,NULL },
+    { "allow-title-ops",do_allowTitleOps,NULL },
+    { "allow-window-ops",do_allowWindowOps,NULL },
+#endif
+
+    };
+
+#if OPT_TEK4014
+MenuEntry tekMenuEntries[] = {
+    { "tektextlarge",  do_tektextlarge, NULL },
+    { "tektext2",      do_tektext2,    NULL },
+    { "tektext3",      do_tektext3,    NULL },
+    { "tektextsmall",  do_tektextsmall, NULL },
+    { "line1",         NULL,           NULL },
+    { "tekpage",       do_tekpage,     NULL },
+    { "tekreset",      do_tekreset,    NULL },
+    { "tekcopy",       do_tekcopy,     NULL },
+    { "line2",         NULL,           NULL },
+    { "vtshow",                do_vtshow,      NULL },
+    { "vtmode",                do_vtmode,      NULL },
+    { "tekhide",       do_tekhide,     NULL }};
+#endif
+
+typedef struct {
+    char *internal_name;
+    MenuEntry *entry_list;
+    Cardinal entry_len;
+} MenuHeader;
+
+    /* This table is ordered to correspond with MenuIndex */
+static MenuHeader menu_names[] = {
+    { "mainMenu", mainMenuEntries, XtNumber(mainMenuEntries) },
+    { "vtMenu",   vtMenuEntries,   XtNumber(vtMenuEntries)   },
+    { "fontMenu", fontMenuEntries, XtNumber(fontMenuEntries) },
+#if OPT_TEK4014
+    { "tekMenu",  tekMenuEntries,  XtNumber(tekMenuEntries)  },
+#endif
+    { 0,          0,               0 },
+};
+/* *INDENT-ON* */
+
+/*
+ * FIXME:  These are global data rather than in the xterm widget because they
+ * are initialized before the widget is created.
+ */
+typedef struct {
+    Widget b;                  /* the toolbar's buttons */
+    Widget w;                  /* the popup shell activated by the button */
+    Cardinal entries;
+} MenuList;
+
+static MenuList vt_shell[NUM_POPUP_MENUS];
+
+#if OPT_TEK4014 && OPT_TOOLBAR
+static MenuList tek_shell[NUM_POPUP_MENUS];
+#endif
+
+static String
+setMenuLocale(Bool before, String substitute)
+{
+    String result = setlocale(LC_CTYPE, 0);
+
+    if (before) {
+       result = x_strdup(result);
+    }
+    (void) setlocale(LC_CTYPE, substitute);
+    TRACE(("setMenuLocale %s:%s\n",
+          (before
+           ? "before"
+           : "after"),
+          NonNull(result)));
+    if (!before) {
+       free((void *) substitute);
+    }
+    return result;
+}
+
+/*
+ * Returns a pointer to the MenuList entry that matches the popup menu.
+ */
+static MenuList *
+select_menu(Widget w GCC_UNUSED, MenuIndex num)
+{
+#if OPT_TEK4014 && OPT_TOOLBAR
+    while (w != 0) {
+       if (w == tekshellwidget) {
+           return &tek_shell[num];
+       }
+       w = XtParent(w);
+    }
+#endif
+    return &vt_shell[num];
+}
+
+/*
+ * Returns a pointer to the given popup menu shell
+ */
+static Widget
+obtain_menu(Widget w, MenuIndex num)
+{
+    return select_menu(w, num)->w;
+}
+
+/*
+ * Returns the number of entries in the given popup menu shell
+ */
+static Cardinal
+sizeof_menu(Widget w, MenuIndex num)
+{
+    return select_menu(w, num)->entries;
+}
+
+/*
+ * create_menu - create a popup shell and stuff the menu into it.
+ */
+
+static Widget
+create_menu(Widget w, XtermWidget xtw, MenuIndex num)
+{
+    static XtCallbackRec cb[2] =
+    {
+       {NULL, NULL},
+       {NULL, NULL}};
+    static Arg arg =
+    {XtNcallback, (XtArgVal) cb};
+
+    TScreen *screen = TScreenOf(xtw);
+    MenuHeader *data = &menu_names[num];
+    MenuList *list = select_menu(w, num);
+    struct _MenuEntry *entries = data->entry_list;
+    Cardinal nentries = data->entry_len;
+#if !OPT_TOOLBAR
+    String saveLocale;
+#endif
+
+    if (screen->menu_item_bitmap == None) {
+       /*
+        * we really want to do these dynamically
+        */
+#define check_width 9
+#define check_height 8
+       static unsigned char check_bits[] =
+       {
+           0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0x60, 0x00,
+           0x31, 0x00, 0x1b, 0x00, 0x0e, 0x00, 0x04, 0x00
+       };
+
+       screen->menu_item_bitmap =
+           XCreateBitmapFromData(XtDisplay(xtw),
+                                 RootWindowOfScreen(XtScreen(xtw)),
+                                 (char *) check_bits, check_width, check_height);
+    }
+#if !OPT_TOOLBAR
+    saveLocale = setMenuLocale(True, resource.menuLocale);
+    list->w = XtCreatePopupShell(data->internal_name,
+                                simpleMenuWidgetClass,
+                                toplevel,
+                                NULL, 0);
+#endif
+    if (list->w != 0) {
+       list->entries = nentries;
+
+       for (; nentries > 0; nentries--, entries++) {
+           cb[0].callback = (XtCallbackProc) entries->function;
+           cb[0].closure = (caddr_t) entries->name;
+           entries->widget = XtCreateManagedWidget(entries->name,
+                                                   (entries->function
+                                                    ? smeBSBObjectClass
+                                                    : smeLineObjectClass),
+                                                   list->w,
+                                                   &arg, (Cardinal) 1);
+       }
+    }
+#if !OPT_TOOLBAR
+    (void) setMenuLocale(False, saveLocale);
+#endif
+
+    /* do not realize at this point */
+    return list->w;
+}
+
+static MenuIndex
+indexOfMenu(String menuName)
+{
+    MenuIndex me;
+    switch (*menuName) {
+    case 'm':
+       me = mainMenu;
+       break;
+    case 'v':
+       me = vtMenu;
+       break;
+    case 'f':
+       me = fontMenu;
+       break;
+#if OPT_TEK4014
+    case 't':
+       me = tekMenu;
+       break;
+#endif
+    default:
+       me = noMenu;
+    }
+    return (me);
+}
+
+/* ARGSUSED */
+static Bool
+domenu(Widget w,
+       XEvent * event GCC_UNUSED,
+       String * params,                /* mainMenu, vtMenu, or tekMenu */
+       Cardinal *param_count)  /* 0 or 1 */
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    MenuIndex me;
+    Bool created = False;
+    Widget mw;
+
+    if (*param_count != 1) {
+       Bell(xw, XkbBI_MinorError, 0);
+       return False;
+    }
+
+    if ((me = indexOfMenu(params[0])) == noMenu) {
+       Bell(xw, XkbBI_MinorError, 0);
+       return False;
+    }
+
+    if ((mw = obtain_menu(w, me)) == 0
+       || sizeof_menu(w, me) == 0) {
+       mw = create_menu(w, xw, me);
+       created = (mw != 0);
+    }
+    if (mw == 0)
+       return False;
+
+    TRACE(("domenu(%s) %s\n", params[0], created ? "create" : "update"));
+    switch (me) {
+    case mainMenu:
+       if (created) {
+           update_toolbar();
+           update_fullscreen();
+           update_securekbd();
+           update_allowsends();
+           update_logging();
+           update_print_redir();
+           update_8bit_control();
+           update_decbkm();
+           update_num_lock();
+           update_alt_esc();
+           update_meta_esc();
+           update_delete_del();
+           update_keyboard_type();
+#if OPT_NUM_LOCK
+           if (!screen->alt_is_not_meta) {
+               SetItemSensitivity(mainMenuEntries[mainMenu_alt_esc].widget,
+                                  False);
+           }
+#endif
+           if (!xtermHasPrinter(xw)) {
+               SetItemSensitivity(mainMenuEntries[mainMenu_print].widget,
+                                  False);
+               SetItemSensitivity(mainMenuEntries[mainMenu_print_redir].widget,
+                                  False);
+           }
+           if (screen->terminal_id < 200) {
+               SetItemSensitivity(
+                                     mainMenuEntries[mainMenu_8bit_ctrl].widget,
+                                     False);
+           }
+#if !defined(SIGTSTP)
+           SetItemSensitivity(
+                                 mainMenuEntries[mainMenu_suspend].widget, False);
+#endif
+#if !defined(SIGCONT)
+           SetItemSensitivity(
+                                 mainMenuEntries[mainMenu_continue].widget, False);
+#endif
+#ifdef ALLOWLOGGING
+           if (screen->inhibit & I_LOG) {
+               SetItemSensitivity(
+                                     mainMenuEntries[mainMenu_logging].widget, False);
+           }
+#endif
+           if (screen->inhibit & I_SIGNAL) {
+               int n;
+               for (n = (int) mainMenu_suspend; n <= (int) mainMenu_quit; ++n) {
+                   SetItemSensitivity(mainMenuEntries[n].widget, False);
+               }
+           }
+       }
+       break;
+
+    case vtMenu:
+       if (created) {
+           update_scrollbar();
+           update_jumpscroll();
+           update_reversevideo();
+           update_autowrap();
+           update_reversewrap();
+           update_autolinefeed();
+           update_appcursor();
+           update_appkeypad();
+           update_scrollkey();
+           update_scrollttyoutput();
+           update_allow132();
+           update_cursesemul();
+           update_keepSelection();
+           update_selectToClipboard();
+           update_visualbell();
+           update_poponbell();
+           update_bellIsUrgent();
+           update_cursorblink();
+           update_altscreen();
+           update_titeInhibit();
+#ifndef NO_ACTIVE_ICON
+           if (!screen->fnt_icon.fs || !screen->iconVwin.window) {
+               SetItemSensitivity(
+                                     vtMenuEntries[vtMenu_activeicon].widget,
+                                     False);
+           } else
+               update_activeicon();
+#endif /* NO_ACTIVE_ICON */
+#if OPT_TEK4014
+           if (screen->inhibit & I_TEK) {
+               int n;
+               for (n = (int) vtMenu_tekshow; n <= (int) vtMenu_vthide; ++n) {
+                   SetItemSensitivity(vtMenuEntries[n].widget, False);
+               }
+           }
+#endif
+       }
+       break;
+
+    case fontMenu:
+       if (created) {
+           set_menu_font(True);
+           SetItemSensitivity(
+                                 fontMenuEntries[fontMenu_fontescape].widget,
+                                 (screen->menu_font_names[fontMenu_fontescape][fNorm]
+                                  ? True : False));
+#if OPT_BOX_CHARS
+           update_font_boxchars();
+           SetItemSensitivity(
+                                 fontMenuEntries[fontMenu_font_boxchars].widget,
+                                 True);
+           update_font_packed();
+           SetItemSensitivity(
+                                 fontMenuEntries[fontMenu_font_packedfont].widget,
+                                 True);
+#endif
+#if OPT_DEC_SOFTFONT           /* FIXME: not implemented */
+           update_font_loadable();
+           SetItemSensitivity(
+                                 fontMenuEntries[fontMenu_font_loadable].widget,
+                                 False);
+#endif
+#if OPT_DEC_CHRSET
+           update_font_doublesize();
+           if (TScreenOf(xw)->cache_doublesize == 0)
+               SetItemSensitivity(
+                                     fontMenuEntries[fontMenu_font_doublesize].widget,
+                                     False);
+#endif
+#if OPT_RENDERFONT
+           update_font_renderfont();
+#endif
+#if OPT_WIDE_CHARS
+           update_font_utf8_mode();
+           update_font_utf8_title();
+#endif
+#if OPT_ALLOW_XXX_OPS
+           update_menu_allowColorOps();
+           update_menu_allowFontOps();
+           update_menu_allowTcapOps();
+           update_menu_allowTitleOps();
+           update_menu_allowWindowOps();
+           enable_allow_xxx_ops(!(screen->allowSendEvents));
+#endif
+       }
+       FindFontSelection(xw, NULL, True);
+       SetItemSensitivity(
+                             fontMenuEntries[fontMenu_fontsel].widget,
+                             (screen->menu_font_names[fontMenu_fontsel]
+                              ? True : False));
+       break;
+
+#if OPT_TEK4014
+    case tekMenu:
+       if (created && tekWidget) {
+           set_tekfont_menu_item(TekScreenOf(tekWidget)->cur.fontsize, True);
+           update_vtshow();
+       }
+       break;
+#endif
+    case noMenu:
+    default:
+       break;
+    }
+
+    return True;
+}
+
+/*
+ * public interfaces
+ */
+
+void
+HandleCreateMenu(Widget w,
+                XEvent * event,
+                String * params,       /* mainMenu, vtMenu, or tekMenu */
+                Cardinal *param_count)         /* 0 or 1 */
+{
+    TRACE(("HandleCreateMenu\n"));
+    (void) domenu(w, event, params, param_count);
+}
+
+void
+HandlePopupMenu(Widget w,
+               XEvent * event,
+               String * params,        /* mainMenu, vtMenu, or tekMenu */
+               Cardinal *param_count)  /* 0 or 1 */
+{
+    TRACE(("HandlePopupMenu\n"));
+    if (domenu(w, event, params, param_count)) {
+#if OPT_TOOLBAR
+       w = select_menu(w, mainMenu)->w;
+#endif
+       XtCallActionProc(w, "XawPositionSimpleMenu", event, params, 1);
+       XtCallActionProc(w, "MenuPopup", event, params, 1);
+    }
+}
+
+/*
+ * private interfaces - keep out!
+ */
+
+/* ARGSUSED */
+static void
+handle_send_signal(Widget gw GCC_UNUSED, int sig)
+{
+#ifndef VMS
+    TScreen *screen = TScreenOf(term);
+
+    if (hold_screen > 1)
+       hold_screen = 0;
+    if (screen->pid > 1)
+       kill_process_group(screen->pid, sig);
+#endif
+}
+
+static void
+UpdateMenuItem(
+#if OPT_TRACE
+                 const char *func,
+#endif
+                 MenuEntry * menu,
+                 int which,
+                 Bool val)
+{
+    static Arg menuArgs =
+    {XtNleftBitmap, (XtArgVal) 0};
+    Widget mi = menu[which].widget;
+
+    if (mi) {
+       menuArgs.value = (XtArgVal) ((val)
+                                    ? TScreenOf(term)->menu_item_bitmap
+                                    : None);
+       XtSetValues(mi, &menuArgs, (Cardinal) 1);
+    }
+    TRACE(("%s(%d): %s\n", func, which, BtoS(val)));
+}
+
+void
+SetItemSensitivity(Widget mi, Bool val)
+{
+    static Arg menuArgs =
+    {XtNsensitive, (XtArgVal) 0};
+
+    if (mi) {
+       menuArgs.value = (XtArgVal) (val);
+       XtSetValues(mi, &menuArgs, (Cardinal) 1);
+    }
+}
+
+/*
+ * action routines
+ */
+
+#if OPT_MAXIMIZE
+
+static void
+set_resize_increments(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int min_width = (2 * screen->border) + screen->fullVwin.sb_info.width;
+    int min_height = (2 * screen->border);
+    XSizeHints sizehints;
+
+    memset(&sizehints, 0, sizeof(XSizeHints));
+    sizehints.width_inc = FontWidth(screen);
+    sizehints.height_inc = FontHeight(screen);
+    sizehints.flags = PResizeInc;
+    XSetWMNormalHints(screen->display, VShellWindow(xw), &sizehints);
+
+    XtVaSetValues(SHELL_OF(xw),
+                 XtNbaseWidth, min_width,
+                 XtNbaseHeight, min_height,
+                 XtNminWidth, min_width + FontWidth(screen),
+                 XtNminHeight, min_height + FontHeight(screen),
+                 XtNwidthInc, FontWidth(screen),
+                 XtNheightInc, FontHeight(screen),
+                 (XtPointer) 0);
+
+    XFlush(XtDisplay(xw));
+}
+
+static void
+unset_resize_increments(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    XSizeHints sizehints;
+
+    memset(&sizehints, 0, sizeof(XSizeHints));
+    sizehints.width_inc = 1;
+    sizehints.height_inc = 1;
+    sizehints.flags = PResizeInc;
+    XSetWMNormalHints(screen->display, VShellWindow(xw), &sizehints);
+
+    XtVaSetValues(SHELL_OF(xw),
+                 XtNwidthInc, 1,
+                 XtNheightInc, 1,
+                 (XtPointer) 0);
+
+    XFlush(XtDisplay(xw));
+}
+
+static void
+netwm_fullscreen(XtermWidget xw, int operation)
+{
+    TScreen *screen = TScreenOf(xw);
+    XEvent e;
+    Display *dpy = screen->display;
+    Window window = VShellWindow(xw);
+    Atom atom_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
+    Atom atom_state = XInternAtom(dpy, "_NET_WM_STATE", False);
+
+    memset(&e, 0, sizeof(e));
+    e.xclient.type = ClientMessage;
+    e.xclient.message_type = atom_state;
+    e.xclient.display = dpy;
+    e.xclient.window = window;
+    e.xclient.format = 32;
+    e.xclient.data.l[0] = operation;
+    e.xclient.data.l[1] = (long) atom_fullscreen;
+
+    XSendEvent(dpy, DefaultRootWindow(dpy), False,
+              SubstructureRedirectMask, &e);
+}
+
+static Boolean
+probe_netwm_fullscreen_capability(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Display *dpy = screen->display;
+    Atom atom_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
+    Atom atom_supported = XInternAtom(dpy, "_NET_SUPPORTED", False);
+    Atom actual_type;
+    int actual_format;
+    long long_offset = 0;
+    long long_length = 128;    /* number of items to ask for at a time */
+    unsigned int i;
+    unsigned long nitems, bytes_after;
+    unsigned char *args;
+    CARD32 *ldata;
+    Boolean netwm_fullscreen_capability = False;
+    int rc;
+
+    while (!netwm_fullscreen_capability) {
+       rc = XGetWindowProperty(dpy,
+                               DefaultRootWindow(dpy),
+                               atom_supported,
+                               long_offset,
+                               long_length,
+                               False,  /* do not delete */
+                               AnyPropertyType,        /* req_type */
+                               &actual_type,   /* actual_type_return */
+                               &actual_format,         /* actual_format_return */
+                               &nitems,        /* nitems_return */
+                               &bytes_after,   /* bytes_after_return */
+                               &args   /* prop_return */
+           );
+       if (rc != Success
+           || actual_type != XA_ATOM) {
+           break;
+       }
+
+       ldata = (CARD32 *) (void *) args;
+       for (i = 0; i < nitems; i++) {
+           if (ldata[i] == atom_fullscreen) {
+               netwm_fullscreen_capability = True;
+               break;
+           }
+       }
+       XFree(ldata);
+
+       if (!netwm_fullscreen_capability) {
+           if (bytes_after != 0) {
+               long remaining = (long) (bytes_after / sizeof(CARD32));
+               if (long_length > remaining)
+                   long_length = remaining;
+               long_offset += (long) nitems;
+           } else {
+               break;
+           }
+       }
+    }
+
+    return netwm_fullscreen_capability;
+}
+
+static void
+do_fullscreen(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    static Boolean initialized = False;
+    static Boolean netwm_fullscreen_capability = False;
+
+    if (!initialized) {
+       initialized = True;
+       netwm_fullscreen_capability = probe_netwm_fullscreen_capability(xw);
+    }
+
+    if (netwm_fullscreen_capability) {
+       if (screen->fullscreen) {
+           set_resize_increments(xw);
+           netwm_fullscreen(xw, 0);
+       } else {
+           unset_resize_increments(xw);
+           netwm_fullscreen(xw, 1);
+       }
+       screen->fullscreen = !screen->fullscreen;
+       update_fullscreen();
+    } else {
+       Bell(xw, XkbBI_MinorError, 100);
+    }
+}
+
+/* ARGSUSED */
+void
+HandleFullscreen(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params GCC_UNUSED,
+                Cardinal *param_count GCC_UNUSED)
+{
+    do_fullscreen(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+void
+update_fullscreen(void)
+{
+    UpdateCheckbox("update_fullscreen",
+                  mainMenuEntries,
+                  mainMenu_fullscreen,
+                  TScreenOf(term)->fullscreen);
+}
+
+#endif /* OPT_MAXIMIZE */
+
+static void
+do_securekbd(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    Time now = CurrentTime;    /* XXX - wrong */
+
+    if (screen->grabbedKbd) {
+       XUngrabKeyboard(screen->display, now);
+       ReverseVideo(xw);
+       screen->grabbedKbd = False;
+    } else {
+       if (XGrabKeyboard(screen->display, XtWindow(CURRENT_EMU()),
+                         True, GrabModeAsync, GrabModeAsync, now)
+           != GrabSuccess) {
+           Bell(xw, XkbBI_MinorError, 100);
+       } else {
+           ReverseVideo(xw);
+           screen->grabbedKbd = True;
+       }
+    }
+    update_securekbd();
+}
+
+/* ARGSUSED */
+void
+HandleSecure(Widget w GCC_UNUSED,
+            XEvent * event GCC_UNUSED,         /* unused */
+            String * params GCC_UNUSED,        /* [0] = volume */
+            Cardinal *param_count GCC_UNUSED)  /* 0 or 1 */
+{
+#if 0
+    Time ev_time = CurrentTime;
+
+    if ((event->xany.type == KeyPress) ||
+       (event->xany.type == KeyRelease))
+       ev_time = event->xkey.time;
+    else if ((event->xany.type == ButtonPress) ||
+            (event->xany.type == ButtonRelease))
+       ev_time = event->xbutton.time;
+#endif
+    do_securekbd(vt_shell[mainMenu].w, (XtPointer) 0, (XtPointer) 0);
+}
+
+static void
+do_allowsends(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->allowSendEvents);
+    update_allowsends();
+#if OPT_ALLOW_XXX_OPS
+    enable_allow_xxx_ops(!(screen->allowSendEvents));
+#endif
+}
+
+static void
+do_visualbell(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->visualbell);
+    update_visualbell();
+}
+
+static void
+do_bellIsUrgent(Widget gw GCC_UNUSED,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->bellIsUrgent);
+    update_bellIsUrgent();
+}
+
+static void
+do_poponbell(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->poponbell);
+    update_poponbell();
+}
+
+#ifdef ALLOWLOGGING
+static void
+do_logging(Widget gw GCC_UNUSED,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->logging) {
+       CloseLog(xw);
+    } else {
+       StartLog(xw);
+    }
+    /* update_logging done by CloseLog and StartLog */
+}
+#endif
+
+static void
+do_print(Widget gw GCC_UNUSED,
+        XtPointer closure GCC_UNUSED,
+        XtPointer data GCC_UNUSED)
+{
+    xtermPrintScreen(term, True, getPrinterFlags(term, NULL, 0));
+}
+
+static void
+do_print_redir(Widget gw GCC_UNUSED,
+              XtPointer closure GCC_UNUSED,
+              XtPointer data GCC_UNUSED)
+{
+    setPrinterControlMode(term, TScreenOf(term)->printer_controlmode ? 0 : 2);
+}
+
+static void
+do_redraw(Widget gw GCC_UNUSED,
+         XtPointer closure GCC_UNUSED,
+         XtPointer data GCC_UNUSED)
+{
+    Redraw();
+}
+
+void
+show_8bit_control(Bool value)
+{
+    if (TScreenOf(term)->control_eight_bits != value) {
+       TScreenOf(term)->control_eight_bits = (Boolean) value;
+       update_8bit_control();
+    }
+}
+
+static void
+do_8bit_control(Widget gw GCC_UNUSED,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    show_8bit_control(!TScreenOf(term)->control_eight_bits);
+}
+
+static void
+do_backarrow(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    term->keyboard.flags ^= MODE_DECBKM;
+    update_decbkm();
+}
+
+#if OPT_NUM_LOCK
+static void
+do_num_lock(Widget gw GCC_UNUSED,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    ToggleFlag(term->misc.real_NumLock);
+    update_num_lock();
+}
+
+static void
+do_alt_esc(Widget gw GCC_UNUSED,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    ToggleFlag(TScreenOf(term)->alt_sends_esc);
+    update_alt_esc();
+}
+
+static void
+do_meta_esc(Widget gw GCC_UNUSED,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    ToggleFlag(TScreenOf(term)->meta_sends_esc);
+    update_meta_esc();
+}
+#endif
+
+static void
+do_delete_del(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    if (xtermDeleteIsDEL(term))
+       TScreenOf(term)->delete_is_del = False;
+    else
+       TScreenOf(term)->delete_is_del = True;
+    update_delete_del();
+}
+
+static void
+do_old_fkeys(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    toggle_keyboard_type(term, keyboardIsLegacy);
+}
+
+#if OPT_HP_FUNC_KEYS
+static void
+do_hp_fkeys(Widget gw GCC_UNUSED,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    toggle_keyboard_type(term, keyboardIsHP);
+}
+#endif
+
+#if OPT_SCO_FUNC_KEYS
+static void
+do_sco_fkeys(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    toggle_keyboard_type(term, keyboardIsSCO);
+}
+#endif
+
+#if OPT_SUN_FUNC_KEYS
+static void
+do_sun_fkeys(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    toggle_keyboard_type(term, keyboardIsSun);
+}
+#endif
+
+#if OPT_SUNPC_KBD
+/*
+ * This really means "Sun/PC keyboard emulating VT220".
+ */
+static void
+do_sun_kbd(Widget gw GCC_UNUSED,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    toggle_keyboard_type(term, keyboardIsVT220);
+}
+#endif
+
+#if OPT_TCAP_FKEYS
+static void
+do_tcap_fkeys(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    toggle_keyboard_type(term, keyboardIsTermcap);
+}
+#endif
+
+/*
+ * The following cases use the pid instead of the process group so that we
+ * don't get hosed by programs that change their process group
+ */
+
+/* ARGSUSED */
+static void
+do_suspend(Widget gw,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+#if defined(SIGTSTP)
+    handle_send_signal(gw, SIGTSTP);
+#endif
+}
+
+/* ARGSUSED */
+static void
+do_continue(Widget gw,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+#if defined(SIGCONT)
+    handle_send_signal(gw, SIGCONT);
+#endif
+}
+
+/* ARGSUSED */
+static void
+do_interrupt(Widget gw,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    handle_send_signal(gw, SIGINT);
+}
+
+/* ARGSUSED */
+void
+do_hangup(Widget gw,
+         XtPointer closure GCC_UNUSED,
+         XtPointer data GCC_UNUSED)
+{
+    handle_send_signal(gw, SIGHUP);
+}
+
+/* ARGSUSED */
+static void
+do_terminate(Widget gw,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    handle_send_signal(gw, SIGTERM);
+}
+
+/* ARGSUSED */
+static void
+do_kill(Widget gw,
+       XtPointer closure GCC_UNUSED,
+       XtPointer data GCC_UNUSED)
+{
+    handle_send_signal(gw, SIGKILL);
+}
+
+static void
+do_quit(Widget gw GCC_UNUSED,
+       XtPointer closure GCC_UNUSED,
+       XtPointer data GCC_UNUSED)
+{
+    Cleanup(SIGHUP);
+}
+
+/*
+ * vt menu callbacks
+ */
+
+static void
+do_scrollbar(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    ToggleScrollBar(term);
+}
+
+static void
+do_jumpscroll(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    term->flags ^= SMOOTHSCROLL;
+    if (term->flags & SMOOTHSCROLL) {
+       screen->jumpscroll = False;
+       if (screen->scroll_amt)
+           FlushScroll(term);
+    } else {
+       screen->jumpscroll = True;
+    }
+    update_jumpscroll();
+}
+
+static void
+do_reversevideo(Widget gw GCC_UNUSED,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    ReverseVideo(term);
+}
+
+static void
+do_autowrap(Widget gw GCC_UNUSED,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    term->flags ^= WRAPAROUND;
+    update_autowrap();
+}
+
+static void
+do_reversewrap(Widget gw GCC_UNUSED,
+              XtPointer closure GCC_UNUSED,
+              XtPointer data GCC_UNUSED)
+{
+    term->flags ^= REVERSEWRAP;
+    update_reversewrap();
+}
+
+static void
+do_autolinefeed(Widget gw GCC_UNUSED,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    term->flags ^= LINEFEED;
+    update_autolinefeed();
+}
+
+static void
+do_appcursor(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    term->keyboard.flags ^= MODE_DECCKM;
+    update_appcursor();
+}
+
+static void
+do_appkeypad(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    term->keyboard.flags ^= MODE_DECKPAM;
+    update_appkeypad();
+}
+
+static void
+do_scrollkey(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->scrollkey);
+    update_scrollkey();
+}
+
+static void
+do_scrollttyoutput(Widget gw GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->scrollttyoutput);
+    update_scrollttyoutput();
+}
+
+static void
+do_keepSelection(Widget gw GCC_UNUSED,
+                XtPointer closure GCC_UNUSED,
+                XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->keepSelection);
+    update_keepSelection();
+}
+
+static void
+do_selectClipboard(Widget gw GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->selectToClipboard);
+    update_selectToClipboard();
+}
+
+static void
+do_allow132(Widget gw GCC_UNUSED,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->c132);
+    update_allow132();
+}
+
+static void
+do_cursesemul(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->curses);
+    update_cursesemul();
+}
+
+static void
+do_marginbell(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    if ((ToggleFlag(screen->marginbell)) == 0)
+       screen->bellArmed = -1;
+    update_marginbell();
+}
+
+#if OPT_TEK4014
+static void
+handle_tekshow(Widget gw GCC_UNUSED, Bool allowswitch)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("Show tek-window\n"));
+    if (!TEK4014_SHOWN(xw)) {  /* not showing, turn on */
+       set_tek_visibility(True);
+    } else if (screen->Vshow || allowswitch) { /* is showing, turn off */
+       set_tek_visibility(False);
+       end_tek_mode();         /* WARNING: this does a longjmp */
+    } else
+       Bell(xw, XkbBI_MinorError, 0);
+}
+
+/* ARGSUSED */
+static void
+do_tekshow(Widget gw,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    handle_tekshow(gw, True);
+}
+
+/* ARGSUSED */
+static void
+do_tekonoff(Widget gw,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    handle_tekshow(gw, False);
+}
+#endif /* OPT_TEK4014 */
+
+#if OPT_BLINK_CURS
+/* ARGSUSED */
+static void
+do_cursorblink(Widget gw GCC_UNUSED,
+              XtPointer closure GCC_UNUSED,
+              XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+    ToggleCursorBlink(screen);
+}
+#endif
+
+/* ARGSUSED */
+static void
+do_altscreen(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    ToggleAlternate(term);
+}
+
+/* ARGSUSED */
+static void
+do_titeInhibit(Widget gw GCC_UNUSED,
+              XtPointer closure GCC_UNUSED,
+              XtPointer data GCC_UNUSED)
+{
+    ToggleFlag(term->misc.titeInhibit);
+    update_titeInhibit();
+}
+
+#ifndef NO_ACTIVE_ICON
+/* ARGSUSED */
+static void
+do_activeicon(Widget gw GCC_UNUSED,
+             XtPointer closure GCC_UNUSED,
+             XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    if (screen->iconVwin.window) {
+       Widget shell = XtParent(term);
+       ToggleFlag(term->misc.active_icon);
+       XtVaSetValues(shell, XtNiconWindow,
+                     term->misc.active_icon ? screen->iconVwin.window : None,
+                     (XtPointer) 0);
+       update_activeicon();
+    }
+}
+#endif /* NO_ACTIVE_ICON */
+
+static void
+do_softreset(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    VTReset(term, False, False);
+}
+
+static void
+do_hardreset(Widget gw GCC_UNUSED,
+            XtPointer closure GCC_UNUSED,
+            XtPointer data GCC_UNUSED)
+{
+    VTReset(term, True, False);
+}
+
+static void
+do_clearsavedlines(Widget gw GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XtPointer data GCC_UNUSED)
+{
+    VTReset(term, True, True);
+}
+
+#if OPT_TEK4014
+static void
+do_tekmode(Widget gw GCC_UNUSED,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    switch_modes(TEK4014_ACTIVE(term));                /* switch to tek mode */
+}
+
+/* ARGSUSED */
+static void
+do_vthide(Widget gw GCC_UNUSED,
+         XtPointer closure GCC_UNUSED,
+         XtPointer data GCC_UNUSED)
+{
+    hide_vt_window();
+}
+#endif /* OPT_TEK4014 */
+
+/*
+ * vtfont menu
+ */
+
+static void
+do_vtfont(Widget gw GCC_UNUSED,
+         XtPointer closure,
+         XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = term;
+    char *entryname = (char *) closure;
+    int i;
+
+    for (i = 0; i < NMENUFONTS; i++) {
+       if (strcmp(entryname, fontMenuEntries[i].name) == 0) {
+           SetVTFont(xw, i, True, NULL);
+           return;
+       }
+    }
+    Bell(xw, XkbBI_MinorError, 0);
+}
+
+#if OPT_DEC_CHRSET
+static void
+do_font_doublesize(Widget gw GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = term;
+
+    if (TScreenOf(xw)->cache_doublesize != 0)
+       ToggleFlag(TScreenOf(xw)->font_doublesize);
+    update_font_doublesize();
+    Redraw();
+}
+#endif
+
+#if OPT_BOX_CHARS
+static void
+do_font_boxchars(Widget gw GCC_UNUSED,
+                XtPointer closure GCC_UNUSED,
+                XtPointer data GCC_UNUSED)
+{
+    ToggleFlag(TScreenOf(term)->force_box_chars);
+    update_font_boxchars();
+    Redraw();
+}
+
+static void
+do_font_packed(Widget gw GCC_UNUSED,
+              XtPointer closure GCC_UNUSED,
+              XtPointer data GCC_UNUSED)
+{
+    ToggleFlag(TScreenOf(term)->force_packed);
+    update_font_packed();
+    SetVTFont(term, TScreenOf(term)->menu_font_number, True, NULL);
+}
+#endif
+
+#if OPT_DEC_SOFTFONT
+static void
+do_font_loadable(Widget gw GCC_UNUSED,
+                XtPointer closure GCC_UNUSED,
+                XtPointer data GCC_UNUSED)
+{
+    ToggleFlag(term->misc.font_loadable);
+    update_font_loadable();
+}
+#endif
+
+#if OPT_RENDERFONT
+static void
+do_font_renderfont(Widget gw GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = (XtermWidget) term;
+    TScreen *screen = TScreenOf(xw);
+    int fontnum = screen->menu_font_number;
+    String name = TScreenOf(xw)->MenuFontName(fontnum);
+
+    DefaultRenderFont(xw);
+    ToggleFlag(xw->misc.render_font);
+    update_font_renderfont();
+    xtermLoadFont(xw, xtermFontName(name), True, fontnum);
+    ScrnRefresh(term, 0, 0,
+               MaxRows(screen),
+               MaxCols(screen), True);
+}
+#endif
+
+#if OPT_WIDE_CHARS
+static void
+do_font_utf8_mode(Widget gw GCC_UNUSED,
+                 XtPointer closure GCC_UNUSED,
+                 XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    /*
+     * If xterm was started with -wc option, it might not have the wide fonts.
+     * If xterm was not started with -wc, it might not have wide cells.
+     */
+    if (!screen->utf8_mode) {
+       if (screen->wide_chars) {
+           if (xtermLoadWideFonts(term, True)) {
+               SetVTFont(term, screen->menu_font_number, True, NULL);
+           }
+       } else {
+           ChangeToWide(term);
+       }
+    }
+    switchPtyData(screen, !screen->utf8_mode);
+    /*
+     * We don't repaint the screen when switching UTF-8 on/off.  When switching
+     * on - the Latin-1 codes should paint as-is.  When switching off, that's
+     * hard to do properly.
+     */
+}
+
+static void
+do_font_utf8_title(Widget gw GCC_UNUSED,
+                  XtPointer closure GCC_UNUSED,
+                  XtPointer data GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    ToggleFlag(screen->utf8_title);
+    update_font_utf8_title();
+}
+#endif
+
+/*
+ * tek menu
+ */
+
+#if OPT_TEK4014
+static void
+do_tektextlarge(Widget gw,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    TekSetFontSize(getTekWidget(gw), True, tekMenu_tektextlarge);
+}
+
+static void
+do_tektext2(Widget gw,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    TekSetFontSize(getTekWidget(gw), True, tekMenu_tektext2);
+}
+
+static void
+do_tektext3(Widget gw,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    TekSetFontSize(getTekWidget(gw), True, tekMenu_tektext3);
+}
+
+static void
+do_tektextsmall(Widget gw,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    TekSetFontSize(getTekWidget(gw), True, tekMenu_tektextsmall);
+}
+
+static void
+do_tekpage(Widget gw,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    TekSimulatePageButton(getTekWidget(gw), False);
+}
+
+static void
+do_tekreset(Widget gw,
+           XtPointer closure GCC_UNUSED,
+           XtPointer data GCC_UNUSED)
+{
+    TekSimulatePageButton(getTekWidget(gw), True);
+}
+
+static void
+do_tekcopy(Widget gw,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    TekCopy(getTekWidget(gw));
+}
+
+static void
+handle_vtshow(Widget gw GCC_UNUSED, Bool allowswitch)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("Show vt-window\n"));
+    if (!screen->Vshow) {      /* not showing, turn on */
+       set_vt_visibility(True);
+    } else if (TEK4014_SHOWN(xw) || allowswitch) {     /* is showing, turn off */
+       set_vt_visibility(False);
+       if (!TEK4014_ACTIVE(xw) && tekRefreshList)
+           TekRefresh(tekWidget);
+       end_vt_mode();          /* WARNING: this does a longjmp... */
+    } else
+       Bell(xw, XkbBI_MinorError, 0);
+}
+
+static void
+do_vtshow(Widget gw,
+         XtPointer closure GCC_UNUSED,
+         XtPointer data GCC_UNUSED)
+{
+    handle_vtshow(gw, True);
+}
+
+static void
+do_vtonoff(Widget gw,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    handle_vtshow(gw, False);
+}
+
+static void
+do_vtmode(Widget gw GCC_UNUSED,
+         XtPointer closure GCC_UNUSED,
+         XtPointer data GCC_UNUSED)
+{
+    switch_modes(TEK4014_ACTIVE(term));                /* switch to vt, or from */
+}
+
+/* ARGSUSED */
+static void
+do_tekhide(Widget gw GCC_UNUSED,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    hide_tek_window();
+}
+#endif /* OPT_TEK4014 */
+
+/*
+ * public handler routines
+ */
+
+static void
+handle_toggle(void (*proc) PROTO_XT_CALLBACK_ARGS,
+             int var,
+             String * params,
+             Cardinal nparams,
+             Widget w,
+             XtPointer closure,
+             XtPointer data)
+{
+    XtermWidget xw = term;
+    int dir = -2;
+
+    switch (nparams) {
+    case 0:
+       dir = -1;
+       break;
+    case 1:
+       if (XmuCompareISOLatin1(params[0], "on") == 0)
+           dir = 1;
+       else if (XmuCompareISOLatin1(params[0], "off") == 0)
+           dir = 0;
+       else if (XmuCompareISOLatin1(params[0], "toggle") == 0)
+           dir = -1;
+       break;
+    }
+
+    switch (dir) {
+    case -2:
+       Bell(xw, XkbBI_MinorError, 0);
+       break;
+
+    case -1:
+       (*proc) (w, closure, data);
+       break;
+
+    case 0:
+       if (var)
+           (*proc) (w, closure, data);
+       else
+           Bell(xw, XkbBI_MinorError, 0);
+       break;
+
+    case 1:
+       if (!var)
+           (*proc) (w, closure, data);
+       else
+           Bell(xw, XkbBI_MinorError, 0);
+       break;
+    }
+    return;
+}
+
+#define handle_vt_toggle(proc, var, params, nparams, w) \
+       handle_toggle(proc, (int) (var), params, nparams, w, (XtPointer)0, (XtPointer)0)
+
+#define HANDLE_VT_TOGGLE(name) \
+       handle_vt_toggle(do_##name, TScreenOf(term)->name, params, *param_count, w)
+
+#define handle_tek_toggle(proc, var, params, nparams, w) \
+       handle_toggle(proc, (int) (var), params, nparams, w, (XtPointer)0, (XtPointer)0)
+
+void
+HandleAllowSends(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    handle_vt_toggle(do_allowsends, TScreenOf(term)->allowSendEvents,
+                    params, *param_count, w);
+}
+
+void
+HandleSetVisualBell(Widget w,
+                   XEvent * event GCC_UNUSED,
+                   String * params,
+                   Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(visualbell);
+}
+
+void
+HandleSetPopOnBell(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(poponbell);
+}
+
+#ifdef ALLOWLOGGING
+void
+HandleLogging(Widget w,
+             XEvent * event GCC_UNUSED,
+             String * params,
+             Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(logging);
+}
+#endif
+
+/* ARGSUSED */
+void
+HandlePrintScreen(Widget w GCC_UNUSED,
+                 XEvent * event GCC_UNUSED,
+                 String * params GCC_UNUSED,
+                 Cardinal *param_count GCC_UNUSED)
+{
+    xtermPrintScreen(term, True, getPrinterFlags(term, params, param_count));
+}
+
+/* ARGSUSED */
+void
+HandlePrintEverything(Widget w GCC_UNUSED,
+                     XEvent * event GCC_UNUSED,
+                     String * params,
+                     Cardinal *param_count)
+{
+    xtermPrintEverything(term, getPrinterFlags(term, params, param_count));
+}
+
+/* ARGSUSED */
+void
+HandlePrintControlMode(Widget w,
+                      XEvent * event GCC_UNUSED,
+                      String * params GCC_UNUSED,
+                      Cardinal *param_count GCC_UNUSED)
+{
+    do_print_redir(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+void
+HandleRedraw(Widget w,
+            XEvent * event GCC_UNUSED,
+            String * params GCC_UNUSED,
+            Cardinal *param_count GCC_UNUSED)
+{
+    do_redraw(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+void
+HandleSendSignal(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    /* *INDENT-OFF* */
+    static struct sigtab {
+       const char *name;
+       int sig;
+    } signals[] = {
+#ifdef SIGTSTP
+       { "suspend",    SIGTSTP },
+       { "tstp",       SIGTSTP },
+#endif
+#ifdef SIGCONT
+       { "cont",       SIGCONT },
+#endif
+       { "int",        SIGINT },
+       { "hup",        SIGHUP },
+       { "quit",       SIGQUIT },
+       { "alrm",       SIGALRM },
+       { "alarm",      SIGALRM },
+       { "term",       SIGTERM },
+       { "kill",       SIGKILL },
+       { NULL, 0 },
+    };
+    /* *INDENT-ON* */
+
+    if (*param_count == 1) {
+       struct sigtab *st;
+
+       for (st = signals; st->name; st++) {
+           if (XmuCompareISOLatin1(st->name, params[0]) == 0) {
+               handle_send_signal(w, st->sig);
+               return;
+           }
+       }
+       /* one could allow numeric values, but that would be a security hole */
+    }
+
+    Bell(term, XkbBI_MinorError, 0);
+}
+
+/* ARGSUSED */
+void
+HandleQuit(Widget w,
+          XEvent * event GCC_UNUSED,
+          String * params GCC_UNUSED,
+          Cardinal *param_count GCC_UNUSED)
+{
+    do_quit(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+void
+Handle8BitControl(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *param_count)
+{
+    handle_vt_toggle(do_8bit_control, TScreenOf(term)->control_eight_bits,
+                    params, *param_count, w);
+}
+
+void
+HandleBackarrow(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    handle_vt_toggle(do_backarrow, term->keyboard.flags & MODE_DECBKM,
+                    params, *param_count, w);
+}
+
+#if OPT_SUN_FUNC_KEYS
+void
+HandleSunFunctionKeys(Widget w,
+                     XEvent * event GCC_UNUSED,
+                     String * params,
+                     Cardinal *param_count)
+{
+    handle_vt_toggle(do_sun_fkeys, term->keyboard.type == keyboardIsSun,
+                    params, *param_count, w);
+}
+#endif
+
+#if OPT_NUM_LOCK
+void
+HandleNumLock(Widget w,
+             XEvent * event GCC_UNUSED,
+             String * params,
+             Cardinal *param_count)
+{
+    handle_vt_toggle(do_num_lock, term->misc.real_NumLock,
+                    params, *param_count, w);
+}
+
+void
+HandleAltEsc(Widget w,
+            XEvent * event GCC_UNUSED,
+            String * params,
+            Cardinal *param_count)
+{
+    handle_vt_toggle(do_alt_esc, !TScreenOf(term)->input_eight_bits,
+                    params, *param_count, w);
+}
+
+void
+HandleMetaEsc(Widget w,
+             XEvent * event GCC_UNUSED,
+             String * params,
+             Cardinal *param_count)
+{
+    handle_vt_toggle(do_meta_esc, TScreenOf(term)->meta_sends_esc,
+                    params, *param_count, w);
+}
+#endif
+
+void
+HandleDeleteIsDEL(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *param_count)
+{
+    handle_vt_toggle(do_delete_del, TScreenOf(term)->delete_is_del,
+                    params, *param_count, w);
+}
+
+void
+HandleOldFunctionKeys(Widget w,
+                     XEvent * event GCC_UNUSED,
+                     String * params,
+                     Cardinal *param_count)
+{
+    handle_vt_toggle(do_old_fkeys, term->keyboard.type == keyboardIsLegacy,
+                    params, *param_count, w);
+}
+
+#if OPT_SUNPC_KBD
+void
+HandleSunKeyboard(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *param_count)
+{
+    handle_vt_toggle(do_sun_kbd, term->keyboard.type == keyboardIsVT220,
+                    params, *param_count, w);
+}
+#endif
+
+#if OPT_HP_FUNC_KEYS
+void
+HandleHpFunctionKeys(Widget w,
+                    XEvent * event GCC_UNUSED,
+                    String * params,
+                    Cardinal *param_count)
+{
+    handle_vt_toggle(do_hp_fkeys, term->keyboard.type == keyboardIsHP,
+                    params, *param_count, w);
+}
+#endif
+
+#if OPT_SCO_FUNC_KEYS
+void
+HandleScoFunctionKeys(Widget w,
+                     XEvent * event GCC_UNUSED,
+                     String * params,
+                     Cardinal *param_count)
+{
+    handle_vt_toggle(do_sco_fkeys, term->keyboard.type == keyboardIsSCO,
+                    params, *param_count, w);
+}
+#endif
+
+void
+HandleScrollbar(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    XtermWidget xw = term;
+
+    if (IsIcon(TScreenOf(xw))) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+       handle_vt_toggle(do_scrollbar, TScreenOf(xw)->fullVwin.sb_info.width,
+                        params, *param_count, w);
+    }
+}
+
+void
+HandleJumpscroll(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(jumpscroll);
+}
+
+void
+HandleKeepSelection(Widget w,
+                   XEvent * event GCC_UNUSED,
+                   String * params,
+                   Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(keepSelection);
+}
+
+void
+HandleSetSelect(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    handle_vt_toggle(do_selectClipboard, TScreenOf(term)->selectToClipboard,
+                    params, *param_count, w);
+}
+
+void
+HandleReverseVideo(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    handle_vt_toggle(do_reversevideo, (term->misc.re_verse0),
+                    params, *param_count, w);
+}
+
+void
+HandleAutoWrap(Widget w,
+              XEvent * event GCC_UNUSED,
+              String * params,
+              Cardinal *param_count)
+{
+    handle_vt_toggle(do_autowrap, (term->flags & WRAPAROUND),
+                    params, *param_count, w);
+}
+
+void
+HandleReverseWrap(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *param_count)
+{
+    handle_vt_toggle(do_reversewrap, (term->flags & REVERSEWRAP),
+                    params, *param_count, w);
+}
+
+void
+HandleAutoLineFeed(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    handle_vt_toggle(do_autolinefeed, (term->flags & LINEFEED),
+                    params, *param_count, w);
+}
+
+void
+HandleAppCursor(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    handle_vt_toggle(do_appcursor, (term->keyboard.flags & MODE_DECCKM),
+                    params, *param_count, w);
+}
+
+void
+HandleAppKeypad(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    handle_vt_toggle(do_appkeypad, (term->keyboard.flags & MODE_DECKPAM),
+                    params, *param_count, w);
+}
+
+void
+HandleScrollKey(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(scrollkey);
+}
+
+void
+HandleScrollTtyOutput(Widget w,
+                     XEvent * event GCC_UNUSED,
+                     String * params,
+                     Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(scrollttyoutput);
+}
+
+void
+HandleAllow132(Widget w,
+              XEvent * event GCC_UNUSED,
+              String * params,
+              Cardinal *param_count)
+{
+    handle_vt_toggle(do_allow132, TScreenOf(term)->c132,
+                    params, *param_count, w);
+}
+
+void
+HandleCursesEmul(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    handle_vt_toggle(do_cursesemul, TScreenOf(term)->curses,
+                    params, *param_count, w);
+}
+
+void
+HandleBellIsUrgent(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(bellIsUrgent);
+}
+
+void
+HandleMarginBell(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(marginbell);
+}
+
+#if OPT_BLINK_CURS
+void
+HandleCursorBlink(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *param_count)
+{
+    /* eventually want to see if sensitive or not */
+    handle_vt_toggle(do_cursorblink, TScreenOf(term)->cursor_blink,
+                    params, *param_count, w);
+}
+#endif
+
+void
+HandleAltScreen(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    /* eventually want to see if sensitive or not */
+    handle_vt_toggle(do_altscreen, TScreenOf(term)->whichBuf,
+                    params, *param_count, w);
+}
+
+void
+HandleTiteInhibit(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *param_count)
+{
+    /* eventually want to see if sensitive or not */
+    handle_vt_toggle(do_titeInhibit, !(term->misc.titeInhibit),
+                    params, *param_count, w);
+}
+
+/* ARGSUSED */
+void
+HandleSoftReset(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params GCC_UNUSED,
+               Cardinal *param_count GCC_UNUSED)
+{
+    do_softreset(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+void
+HandleHardReset(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params GCC_UNUSED,
+               Cardinal *param_count GCC_UNUSED)
+{
+    do_hardreset(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+void
+HandleClearSavedLines(Widget w,
+                     XEvent * event GCC_UNUSED,
+                     String * params GCC_UNUSED,
+                     Cardinal *param_count GCC_UNUSED)
+{
+    do_clearsavedlines(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+#if OPT_DEC_CHRSET
+void
+HandleFontDoublesize(Widget w,
+                    XEvent * event GCC_UNUSED,
+                    String * params,
+                    Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(font_doublesize);
+}
+#endif
+
+#if OPT_BOX_CHARS
+void
+HandleFontBoxChars(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    handle_vt_toggle(do_font_boxchars, TScreenOf(term)->force_box_chars,
+                    params, *param_count, w);
+}
+
+void
+HandleFontPacked(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    handle_vt_toggle(do_font_packed, TScreenOf(term)->force_packed,
+                    params, *param_count, w);
+}
+#endif
+
+#if OPT_DEC_SOFTFONT
+void
+HandleFontLoading(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *param_count)
+{
+    handle_vt_toggle(do_font_loadable, term->misc.font_loadable,
+                    params, *param_count, w);
+}
+#endif
+
+#if OPT_RENDERFONT
+void
+HandleRenderFont(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    XtermWidget xw = (XtermWidget) term;
+
+    DefaultRenderFont(xw);
+
+    handle_vt_toggle(do_font_renderfont, xw->misc.render_font,
+                    params, *param_count, w);
+}
+#endif
+
+#if OPT_WIDE_CHARS
+void
+HandleUTF8Mode(Widget w,
+              XEvent * event GCC_UNUSED,
+              String * params,
+              Cardinal *param_count)
+{
+    handle_vt_toggle(do_font_utf8_mode, TScreenOf(term)->utf8_mode,
+                    params, *param_count, w);
+}
+
+void
+HandleUTF8Title(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    handle_vt_toggle(do_font_utf8_title, TScreenOf(term)->utf8_title,
+                    params, *param_count, w);
+}
+#endif
+
+#if OPT_TEK4014
+void
+HandleSetTerminalType(Widget w,
+                     XEvent * event GCC_UNUSED,
+                     String * params,
+                     Cardinal *param_count)
+{
+    XtermWidget xw = term;
+
+    if (*param_count == 1) {
+       switch (params[0][0]) {
+       case 'v':
+       case 'V':
+           if (TEK4014_ACTIVE(xw))
+               do_vtmode(w, (XtPointer) 0, (XtPointer) 0);
+           break;
+       case 't':
+       case 'T':
+           if (!TEK4014_ACTIVE(xw))
+               do_tekmode(w, (XtPointer) 0, (XtPointer) 0);
+           break;
+       default:
+           Bell(xw, XkbBI_MinorError, 0);
+       }
+    } else {
+       Bell(xw, XkbBI_MinorError, 0);
+    }
+}
+
+void
+HandleVisibility(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    XtermWidget xw = term;
+
+    if (*param_count == 2) {
+       switch (params[0][0]) {
+       case 'v':
+       case 'V':
+           handle_tek_toggle(do_vtonoff, (int) TScreenOf(xw)->Vshow,
+                             params + 1, (*param_count) - 1, w);
+           break;
+       case 't':
+       case 'T':
+           handle_tek_toggle(do_tekonoff, (int) TEK4014_SHOWN(xw),
+                             params + 1, (*param_count) - 1, w);
+           break;
+       default:
+           Bell(xw, XkbBI_MinorError, 0);
+       }
+    } else {
+       Bell(xw, XkbBI_MinorError, 0);
+    }
+}
+
+/* ARGSUSED */
+void
+HandleSetTekText(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    XtermWidget xw = term;
+    void (*proc) PROTO_XT_CALLBACK_ARGS = 0;
+
+    switch (*param_count) {
+    case 0:
+       proc = do_tektextlarge;
+       break;
+    case 1:
+       switch (TekGetFontSize(params[0])) {
+       case TEK_FONT_LARGE:
+           proc = do_tektextlarge;
+           break;
+       case TEK_FONT_2:
+           proc = do_tektext2;
+           break;
+       case TEK_FONT_3:
+           proc = do_tektext3;
+           break;
+       case TEK_FONT_SMALL:
+           proc = do_tektextsmall;
+           break;
+       }
+       break;
+    }
+    if (proc)
+       (*proc) (w, (XtPointer) 0, (XtPointer) 0);
+    else
+       Bell(xw, XkbBI_MinorError, 0);
+}
+
+/* ARGSUSED */
+void
+HandleTekPage(Widget w,
+             XEvent * event GCC_UNUSED,
+             String * params GCC_UNUSED,
+             Cardinal *param_count GCC_UNUSED)
+{
+    do_tekpage(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+void
+HandleTekReset(Widget w,
+              XEvent * event GCC_UNUSED,
+              String * params GCC_UNUSED,
+              Cardinal *param_count GCC_UNUSED)
+{
+    do_tekreset(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+void
+HandleTekCopy(Widget w,
+             XEvent * event GCC_UNUSED,
+             String * params GCC_UNUSED,
+             Cardinal *param_count GCC_UNUSED)
+{
+    do_tekcopy(w, (XtPointer) 0, (XtPointer) 0);
+}
+#endif /* OPT_TEK4014 */
+
+#if OPT_TOOLBAR
+/*
+ * The normal style of xterm popup menu delays initialization until the menu is
+ * first requested.  When using a toolbar, we can use the same initialization,
+ * though on the first popup there will be a little geometry layout jitter,
+ * since the menu is already managed when this callback is invoked.
+ */
+static void
+InitPopup(Widget gw,
+         XtPointer closure,
+         XtPointer data GCC_UNUSED)
+{
+    String params[2];
+    Cardinal count = 1;
+
+    params[0] = (char *) closure;
+    params[1] = 0;
+    TRACE(("InitPopup(%s)\n", params[0]));
+
+    domenu(gw, (XEvent *) 0, params, &count);
+
+    if (gw)
+       XtRemoveCallback(gw, XtNpopupCallback, InitPopup, closure);
+}
+
+static Dimension
+SetupShell(Widget *menus, MenuList * shell, int n, int m)
+{
+    char temp[80];
+    char *external_name = 0;
+    Dimension button_height;
+    Dimension button_border;
+    String saveLocale = setMenuLocale(True, resource.menuLocale);
+
+    shell[n].w = XtVaCreatePopupShell(menu_names[n].internal_name,
+                                     simpleMenuWidgetClass,
+                                     *menus,
+                                     XtNgeometry, NULL,
+                                     (XtPointer) 0);
+
+    XtAddCallback(shell[n].w, XtNpopupCallback, InitPopup, menu_names[n].internal_name);
+    XtVaGetValues(shell[n].w,
+                 XtNlabel, &external_name,
+                 (XtPointer) 0);
+
+    TRACE(("...SetupShell(%s) -> %s -> %#lx\n",
+          menu_names[n].internal_name,
+          external_name,
+          (long) shell[n].w));
+
+    sprintf(temp, "%sButton", menu_names[n].internal_name);
+    shell[n].b = XtVaCreateManagedWidget(temp,
+                                        menuButtonWidgetClass,
+                                        *menus,
+                                        XtNfromHoriz, ((m >= 0)
+                                                       ? shell[m].b
+                                                       : 0),
+                                        XtNmenuName, menu_names[n].internal_name,
+                                        XtNlabel, external_name,
+                                        (XtPointer) 0);
+    XtVaGetValues(shell[n].b,
+                 XtNheight, &button_height,
+                 XtNborderWidth, &button_border,
+                 (XtPointer) 0);
+
+    (void) setMenuLocale(False, saveLocale);
+    return (Dimension) (button_height + (button_border * 2));
+}
+#endif /* OPT_TOOLBAR */
+
+void
+SetupMenus(Widget shell, Widget *forms, Widget *menus, Dimension * menu_high)
+{
+#if OPT_TOOLBAR
+    Dimension button_height = 0;
+    Dimension toolbar_hSpace;
+    Arg args[10];
+#endif
+
+    TRACE(("SetupMenus(%s)\n", shell == toplevel ? "vt100" : "tek4014"));
+
+    *menu_high = 0;
+
+    if (shell == toplevel) {
+       XawSimpleMenuAddGlobalActions(app_con);
+       XtRegisterGrabAction(HandlePopupMenu, True,
+                            (ButtonPressMask | ButtonReleaseMask),
+                            GrabModeAsync, GrabModeAsync);
+    }
+#if OPT_TOOLBAR
+    *forms = XtVaCreateManagedWidget("form",
+                                    formWidgetClass, shell,
+                                    (XtPointer) 0);
+    xtermAddInput(*forms);
+
+    /*
+     * Set a nominal value for the preferred pane size, which lets the
+     * buttons determine the actual height of the menu bar.  We don't show
+     * the grip, because it's too easy to make the toolbar look bad that
+     * way.
+     */
+    XtSetArg(args[0], XtNorientation, XtorientHorizontal);
+    XtSetArg(args[1], XtNtop, XawChainTop);
+    XtSetArg(args[2], XtNbottom, XawChainTop);
+    XtSetArg(args[3], XtNleft, XawChainLeft);
+    XtSetArg(args[4], XtNright, XawChainLeft);
+
+    if (resource.toolBar) {
+       *menus = XtCreateManagedWidget("menubar", boxWidgetClass, *forms,
+                                      args, 5);
+    } else {
+       *menus = XtCreateWidget("menubar", boxWidgetClass, *forms, args, 5);
+    }
+
+    /*
+     * The toolbar widget's height is not necessarily known yet.  If the
+     * toolbar is not created as a managed widget, we can still make a good
+     * guess about its height by collecting the widget's other resource values.
+     */
+    XtVaGetValues(*menus,
+                 XtNhSpace, &toolbar_hSpace,
+                 (XtPointer) 0);
+
+    if (shell == toplevel) {   /* vt100 */
+       int j;
+       for (j = mainMenu; j <= fontMenu; j++) {
+           button_height = SetupShell(menus, vt_shell, j, j - 1);
+       }
+    }
+#if OPT_TEK4014
+    else {                     /* tek4014 */
+       (void) SetupShell(menus, tek_shell, mainMenu, -1);
+       button_height = SetupShell(menus, tek_shell, tekMenu, mainMenu);
+    }
+#endif
+
+    /*
+     * Tell the main program how high the toolbar is, to help with the initial
+     * layout.
+     */
+    *menu_high = (Dimension) (button_height + 2 * (toolbar_hSpace));
+    TRACE(("...menuHeight:%d = (%d + 2 * %d)\n",
+          *menu_high, button_height, toolbar_hSpace));
+
+#else /* !OPT_TOOLBAR */
+    *forms = shell;
+    *menus = shell;
+#endif
+
+    TRACE(("...shell=%#lx\n", (long) shell));
+    TRACE(("...forms=%#lx\n", (long) *forms));
+    TRACE(("...menus=%#lx\n", (long) *menus));
+}
+
+void
+repairSizeHints(void)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    if (XtIsRealized((Widget) xw)) {
+       getXtermSizeHints(xw);
+       xtermSizeHints(xw, ScrollbarWidth(screen));
+
+       XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints);
+    }
+}
+
+#if OPT_TOOLBAR
+#define INIT_POPUP(s, n) InitPopup(s[n].w, menu_names[n].internal_name, 0)
+
+static Bool
+InitWidgetMenu(Widget shell)
+{
+    Bool result = False;
+
+    TRACE(("InitWidgetMenu(%p)\n", (void *) shell));
+    if (term != 0) {
+       if (shell == toplevel) {        /* vt100 */
+           if (!term->init_menu) {
+               INIT_POPUP(vt_shell, mainMenu);
+               INIT_POPUP(vt_shell, vtMenu);
+               INIT_POPUP(vt_shell, fontMenu);
+               term->init_menu = True;
+               TRACE(("...InitWidgetMenu(vt)\n"));
+           }
+           result = term->init_menu;
+       }
+#if OPT_TEK4014
+       else if (tekWidget) {   /* tek4014 */
+           if (!tekWidget->init_menu) {
+               INIT_POPUP(tek_shell, mainMenu);
+               INIT_POPUP(tek_shell, tekMenu);
+               tekWidget->init_menu = True;
+               TRACE(("...InitWidgetMenu(tek)\n"));
+           }
+           result = tekWidget->init_menu;
+       }
+#endif
+    }
+    TRACE(("...InitWidgetMenu ->%d\n", result));
+    return result;
+}
+
+static TbInfo *
+toolbar_info(Widget w)
+{
+    TRACE(("...getting toolbar_info\n"));
+#if OPT_TEK4014
+    if (w != (Widget) term)
+       return &(tekWidget->tek.tb_info);
+#else
+    (void) w;
+#endif
+    return &(WhichVWin(TScreenOf(term))->tb_info);
+}
+
+static void
+hide_toolbar(Widget w)
+{
+    if (w != 0) {
+       TbInfo *info = toolbar_info(w);
+
+       TRACE(("hiding toolbar\n"));
+       XtVaSetValues(w,
+                     XtNfromVert, (Widget) 0,
+                     (XtPointer) 0);
+
+       if (info->menu_bar != 0) {
+           repairSizeHints();
+           XtUnmanageChild(info->menu_bar);
+           if (XtIsRealized(info->menu_bar)) {
+               XtUnmapWidget(info->menu_bar);
+           }
+       }
+       TRACE(("...hiding toolbar (done)\n"));
+    }
+}
+
+static void
+show_toolbar(Widget w)
+{
+    if (w != 0) {
+       TbInfo *info = toolbar_info(w);
+
+       TRACE(("showing toolbar\n"));
+       if (info->menu_bar != 0) {
+           XtVaSetValues(w,
+                         XtNfromVert, info->menu_bar,
+                         (XtPointer) 0);
+           if (XtIsRealized(info->menu_bar))
+               repairSizeHints();
+           XtManageChild(info->menu_bar);
+           if (XtIsRealized(info->menu_bar)) {
+               XtMapWidget(info->menu_bar);
+           }
+       }
+       /*
+        * This is needed to make the terminal widget move down below the
+        * toolbar.
+        */
+       XawFormDoLayout(XtParent(w), True);
+       TRACE(("...showing toolbar (done)\n"));
+    }
+}
+
+/*
+ * Make the toolbar visible or invisible in the current window(s).
+ */
+void
+ShowToolbar(Bool enable)
+{
+    XtermWidget xw = term;
+
+    TRACE(("ShowToolbar(%d)\n", enable));
+
+    if (IsIcon(TScreenOf(xw))) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+       if (enable) {
+           if (InitWidgetMenu(toplevel))
+               show_toolbar((Widget) xw);
+#if OPT_TEK4014
+           if (InitWidgetMenu(tekshellwidget))
+               show_toolbar((Widget) tekWidget);
+#endif
+       } else {
+           hide_toolbar((Widget) xw);
+#if OPT_TEK4014
+           hide_toolbar((Widget) tekWidget);
+#endif
+       }
+       resource.toolBar = (Boolean) enable;
+       update_toolbar();
+    }
+}
+
+void
+HandleToolbar(Widget w,
+             XEvent * event GCC_UNUSED,
+             String * params GCC_UNUSED,
+             Cardinal *param_count GCC_UNUSED)
+{
+    XtermWidget xw = term;
+
+    if (IsIcon(TScreenOf(xw))) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+       handle_vt_toggle(do_toolbar, resource.toolBar,
+                        params, *param_count, w);
+    }
+}
+
+/* ARGSUSED */
+static void
+do_toolbar(Widget gw GCC_UNUSED,
+          XtPointer closure GCC_UNUSED,
+          XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = term;
+
+    /*
+     * Toggle toolbars for both vt100 and tek windows, since they share the
+     * menu which contains the checkbox indicating whether the toolbar is
+     * active.
+     */
+    if (IsIcon(TScreenOf(xw))) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+       ShowToolbar(ToggleFlag(resource.toolBar));
+    }
+}
+
+void
+update_toolbar(void)
+{
+    UpdateCheckbox("update_toolbar",
+                  mainMenuEntries,
+                  mainMenu_toolbar,
+                  resource.toolBar);
+}
+#endif /* OPT_TOOLBAR */
+
+void
+update_securekbd(void)
+{
+    UpdateCheckbox("update_securekbd",
+                  mainMenuEntries,
+                  mainMenu_securekbd,
+                  TScreenOf(term)->grabbedKbd);
+}
+
+void
+update_allowsends(void)
+{
+    UpdateCheckbox("update_allowsends",
+                  mainMenuEntries,
+                  mainMenu_allowsends,
+                  TScreenOf(term)->allowSendEvents);
+}
+
+#ifdef ALLOWLOGGING
+void
+update_logging(void)
+{
+    UpdateCheckbox("update_logging",
+                  mainMenuEntries,
+                  mainMenu_logging,
+                  TScreenOf(term)->logging);
+}
+#endif
+
+void
+update_print_redir(void)
+{
+    UpdateCheckbox("update_print_redir",
+                  mainMenuEntries,
+                  mainMenu_print_redir,
+                  TScreenOf(term)->printer_controlmode);
+}
+
+void
+update_8bit_control(void)
+{
+    UpdateCheckbox("update_8bit_control",
+                  mainMenuEntries,
+                  mainMenu_8bit_ctrl,
+                  TScreenOf(term)->control_eight_bits);
+}
+
+void
+update_decbkm(void)
+{
+    UpdateCheckbox("update_decbkm",
+                  mainMenuEntries,
+                  mainMenu_backarrow,
+                  (term->keyboard.flags & MODE_DECBKM) != 0);
+}
+
+#if OPT_NUM_LOCK
+void
+update_num_lock(void)
+{
+    UpdateCheckbox("update_num_lock",
+                  mainMenuEntries,
+                  mainMenu_num_lock,
+                  term->misc.real_NumLock);
+}
+
+void
+update_alt_esc(void)
+{
+    UpdateCheckbox("update_alt_esc",
+                  mainMenuEntries,
+                  mainMenu_alt_esc,
+                  TScreenOf(term)->alt_sends_esc);
+}
+
+void
+update_meta_esc(void)
+{
+    UpdateCheckbox("update_meta_esc",
+                  mainMenuEntries,
+                  mainMenu_meta_esc,
+                  TScreenOf(term)->meta_sends_esc);
+}
+#endif
+
+#if OPT_SUN_FUNC_KEYS
+void
+update_sun_fkeys(void)
+{
+    UpdateCheckbox("update_sun_fkeys",
+                  mainMenuEntries,
+                  mainMenu_sun_fkeys,
+                  term->keyboard.type == keyboardIsSun);
+}
+#endif
+
+#if OPT_TCAP_FKEYS
+void
+update_tcap_fkeys(void)
+{
+    UpdateCheckbox("update_tcap_fkeys",
+                  mainMenuEntries,
+                  mainMenu_tcap_fkeys,
+                  term->keyboard.type == keyboardIsTermcap);
+}
+#endif
+
+void
+update_old_fkeys(void)
+{
+    UpdateCheckbox("update_old_fkeys",
+                  mainMenuEntries,
+                  mainMenu_old_fkeys,
+                  term->keyboard.type == keyboardIsLegacy);
+}
+
+void
+update_delete_del(void)
+{
+    UpdateCheckbox("update_delete_del",
+                  mainMenuEntries,
+                  mainMenu_delete_del,
+                  xtermDeleteIsDEL(term));
+}
+
+#if OPT_SUNPC_KBD
+void
+update_sun_kbd(void)
+{
+    UpdateCheckbox("update_sun_kbd",
+                  mainMenuEntries,
+                  mainMenu_sun_kbd,
+                  term->keyboard.type == keyboardIsVT220);
+}
+#endif
+
+#if OPT_HP_FUNC_KEYS
+void
+update_hp_fkeys(void)
+{
+    UpdateCheckbox("update_hp_fkeys",
+                  mainMenuEntries,
+                  mainMenu_hp_fkeys,
+                  term->keyboard.type == keyboardIsHP);
+}
+#endif
+
+#if OPT_SCO_FUNC_KEYS
+void
+update_sco_fkeys(void)
+{
+    UpdateCheckbox("update_sco_fkeys",
+                  mainMenuEntries,
+                  mainMenu_sco_fkeys,
+                  term->keyboard.type == keyboardIsSCO);
+}
+#endif
+
+void
+update_scrollbar(void)
+{
+    UpdateCheckbox("update_scrollbar",
+                  vtMenuEntries,
+                  vtMenu_scrollbar,
+                  ScrollbarWidth(TScreenOf(term)));
+}
+
+void
+update_jumpscroll(void)
+{
+    UpdateCheckbox("update_jumpscroll",
+                  vtMenuEntries,
+                  vtMenu_jumpscroll,
+                  TScreenOf(term)->jumpscroll);
+}
+
+void
+update_reversevideo(void)
+{
+    UpdateCheckbox("update_reversevideo",
+                  vtMenuEntries,
+                  vtMenu_reversevideo,
+                  (term->misc.re_verse));
+}
+
+void
+update_autowrap(void)
+{
+    UpdateCheckbox("update_autowrap",
+                  vtMenuEntries,
+                  vtMenu_autowrap,
+                  (term->flags & WRAPAROUND) != 0);
+}
+
+void
+update_reversewrap(void)
+{
+    UpdateCheckbox("update_reversewrap",
+                  vtMenuEntries,
+                  vtMenu_reversewrap,
+                  (term->flags & REVERSEWRAP) != 0);
+}
+
+void
+update_autolinefeed(void)
+{
+    UpdateCheckbox("update_autolinefeed",
+                  vtMenuEntries,
+                  vtMenu_autolinefeed,
+                  (term->flags & LINEFEED) != 0);
+}
+
+void
+update_appcursor(void)
+{
+    UpdateCheckbox("update_appcursor",
+                  vtMenuEntries,
+                  vtMenu_appcursor,
+                  (term->keyboard.flags & MODE_DECCKM) != 0);
+}
+
+void
+update_appkeypad(void)
+{
+    UpdateCheckbox("update_appkeypad",
+                  vtMenuEntries,
+                  vtMenu_appkeypad,
+                  (term->keyboard.flags & MODE_DECKPAM) != 0);
+}
+
+void
+update_scrollkey(void)
+{
+    UpdateCheckbox("update_scrollkey",
+                  vtMenuEntries,
+                  vtMenu_scrollkey,
+                  TScreenOf(term)->scrollkey);
+}
+
+void
+update_scrollttyoutput(void)
+{
+    UpdateCheckbox("update_scrollttyoutput",
+                  vtMenuEntries,
+                  vtMenu_scrollttyoutput,
+                  TScreenOf(term)->scrollttyoutput);
+}
+
+void
+update_keepSelection(void)
+{
+    UpdateCheckbox("update_keepSelection",
+                  vtMenuEntries,
+                  vtMenu_keepSelection,
+                  TScreenOf(term)->keepSelection);
+}
+
+void
+update_selectToClipboard(void)
+{
+    UpdateCheckbox("update_selectToClipboard",
+                  vtMenuEntries,
+                  vtMenu_selectToClipboard,
+                  TScreenOf(term)->selectToClipboard);
+}
+
+void
+update_allow132(void)
+{
+    UpdateCheckbox("update_allow132",
+                  vtMenuEntries,
+                  vtMenu_allow132,
+                  TScreenOf(term)->c132);
+}
+
+void
+update_cursesemul(void)
+{
+#if 0                          /* 2006-2-12: no longer menu entry */
+    UpdateMenuItem("update_cursesemul", vtMenuEntries, vtMenu_cursesemul,
+                  TScreenOf(term)->curses);
+#endif
+}
+
+void
+update_visualbell(void)
+{
+    UpdateCheckbox("update_visualbell",
+                  vtMenuEntries,
+                  vtMenu_visualbell,
+                  TScreenOf(term)->visualbell);
+}
+
+void
+update_bellIsUrgent(void)
+{
+    UpdateCheckbox("update_bellIsUrgent",
+                  vtMenuEntries,
+                  vtMenu_bellIsUrgent,
+                  TScreenOf(term)->bellIsUrgent);
+}
+
+void
+update_poponbell(void)
+{
+    UpdateCheckbox("update_poponbell",
+                  vtMenuEntries,
+                  vtMenu_poponbell,
+                  TScreenOf(term)->poponbell);
+}
+
+#ifndef update_marginbell      /* 2007-3-7: no longer menu entry */
+void
+update_marginbell(void)
+{
+    UpdateCheckbox("update_marginbell",
+                  vtMenuEntries,
+                  vtMenu_marginbell,
+                  TScreenOf(term)->marginbell);
+}
+#endif
+
+#if OPT_BLINK_CURS
+void
+update_cursorblink(void)
+{
+    UpdateCheckbox("update_cursorblink",
+                  vtMenuEntries,
+                  vtMenu_cursorblink,
+                  TScreenOf(term)->cursor_blink);
+}
+#endif
+
+void
+update_altscreen(void)
+{
+    UpdateCheckbox("update_altscreen",
+                  vtMenuEntries,
+                  vtMenu_altscreen,
+                  TScreenOf(term)->whichBuf);
+}
+
+void
+update_titeInhibit(void)
+{
+    UpdateCheckbox("update_titeInhibit",
+                  vtMenuEntries,
+                  vtMenu_titeInhibit,
+                  !(term->misc.titeInhibit));
+}
+
+#ifndef NO_ACTIVE_ICON
+void
+update_activeicon(void)
+{
+    UpdateCheckbox("update_activeicon",
+                  vtMenuEntries,
+                  vtMenu_activeicon,
+                  term->misc.active_icon);
+}
+#endif /* NO_ACTIVE_ICON */
+
+#if OPT_DEC_CHRSET
+void
+update_font_doublesize(void)
+{
+    UpdateCheckbox("update_font_doublesize",
+                  fontMenuEntries,
+                  fontMenu_font_doublesize,
+                  TScreenOf(term)->font_doublesize);
+}
+#endif
+
+#if OPT_BOX_CHARS
+void
+update_font_boxchars(void)
+{
+    UpdateCheckbox("update_font_boxchars",
+                  fontMenuEntries,
+                  fontMenu_font_boxchars,
+                  TScreenOf(term)->force_box_chars);
+}
+
+void
+update_font_packed(void)
+{
+    UpdateCheckbox("update_font_packed",
+                  fontMenuEntries,
+                  fontMenu_font_packedfont,
+                  TScreenOf(term)->force_packed);
+}
+#endif
+
+#if OPT_DEC_SOFTFONT
+void
+update_font_loadable(void)
+{
+    UpdateCheckbox("update_font_loadable",
+                  fontMenuEntries,
+                  fontMenu_font_loadable,
+                  term->misc.font_loadable);
+}
+#endif
+
+#if OPT_RENDERFONT
+void
+update_font_renderfont(void)
+{
+    UpdateCheckbox("update_font_renderfont",
+                  fontMenuEntries,
+                  fontMenu_render_font,
+                  (term->misc.render_font == True));
+    SetItemSensitivity(fontMenuEntries[fontMenu_render_font].widget,
+                      !IsEmpty(term->misc.face_name));
+}
+#endif
+
+#if OPT_WIDE_CHARS
+void
+update_font_utf8_mode(void)
+{
+    Bool active = (TScreenOf(term)->utf8_mode != uAlways);
+    Bool enable = (TScreenOf(term)->utf8_mode != uFalse);
+
+    TRACE(("update_font_utf8_mode active %d, enable %d\n", active, enable));
+    SetItemSensitivity(fontMenuEntries[fontMenu_wide_chars].widget, active);
+    UpdateCheckbox("update_font_utf8_mode",
+                  fontMenuEntries,
+                  fontMenu_wide_chars,
+                  enable);
+}
+
+void
+update_font_utf8_title(void)
+{
+    Bool active = (TScreenOf(term)->utf8_mode != uFalse);
+    Bool enable = (TScreenOf(term)->utf8_title);
+
+    TRACE(("update_font_utf8_title active %d, enable %d\n", active, enable));
+    SetItemSensitivity(fontMenuEntries[fontMenu_wide_title].widget, active);
+    UpdateCheckbox("update_font_utf8_title",
+                  fontMenuEntries,
+                  fontMenu_wide_title,
+                  enable);
+}
+#endif
+
+#if OPT_ALLOW_XXX_OPS
+static void
+enable_allow_xxx_ops(Bool enable)
+{
+    SetItemSensitivity(fontMenuEntries[fontMenu_allowFontOps].widget, enable);
+    SetItemSensitivity(fontMenuEntries[fontMenu_allowTcapOps].widget, enable);
+    SetItemSensitivity(fontMenuEntries[fontMenu_allowTitleOps].widget, enable);
+    SetItemSensitivity(fontMenuEntries[fontMenu_allowWindowOps].widget, enable);
+}
+
+static void
+do_allowColorOps(Widget w,
+                XtPointer closure GCC_UNUSED,
+                XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = getXtermWidget(w);
+    if (xw != 0) {
+       ToggleFlag(TScreenOf(xw)->allowColorOps);
+       update_menu_allowColorOps();
+    }
+}
+
+static void
+do_allowFontOps(Widget w,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = getXtermWidget(w);
+    if (xw != 0) {
+       ToggleFlag(TScreenOf(xw)->allowFontOps);
+       update_menu_allowFontOps();
+    }
+}
+
+static void
+do_allowTcapOps(Widget w,
+               XtPointer closure GCC_UNUSED,
+               XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = getXtermWidget(w);
+    if (xw != 0) {
+       ToggleFlag(TScreenOf(xw)->allowTcapOps);
+       update_menu_allowTcapOps();
+    }
+}
+
+static void
+do_allowTitleOps(Widget w,
+                XtPointer closure GCC_UNUSED,
+                XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = getXtermWidget(w);
+    if (xw != 0) {
+       ToggleFlag(TScreenOf(xw)->allowTitleOps);
+       update_menu_allowTitleOps();
+    }
+}
+
+static void
+do_allowWindowOps(Widget w,
+                 XtPointer closure GCC_UNUSED,
+                 XtPointer data GCC_UNUSED)
+{
+    XtermWidget xw = getXtermWidget(w);
+    if (xw != 0) {
+       ToggleFlag(TScreenOf(xw)->allowWindowOps);
+       update_menu_allowWindowOps();
+    }
+}
+
+void
+HandleAllowColorOps(Widget w,
+                   XEvent * event GCC_UNUSED,
+                   String * params,
+                   Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(allowColorOps);
+}
+
+void
+HandleAllowFontOps(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(allowFontOps);
+}
+
+void
+HandleAllowTcapOps(Widget w,
+                  XEvent * event GCC_UNUSED,
+                  String * params,
+                  Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(allowTcapOps);
+}
+
+void
+HandleAllowTitleOps(Widget w,
+                   XEvent * event GCC_UNUSED,
+                   String * params,
+                   Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(allowTitleOps);
+}
+
+void
+HandleAllowWindowOps(Widget w,
+                    XEvent * event GCC_UNUSED,
+                    String * params,
+                    Cardinal *param_count)
+{
+    HANDLE_VT_TOGGLE(allowWindowOps);
+}
+
+void
+update_menu_allowColorOps(void)
+{
+    UpdateCheckbox("update_menu_allowColorOps",
+                  fontMenuEntries,
+                  fontMenu_allowColorOps,
+                  TScreenOf(term)->allowColorOps);
+}
+
+void
+update_menu_allowFontOps(void)
+{
+    UpdateCheckbox("update_menu_allowFontOps",
+                  fontMenuEntries,
+                  fontMenu_allowFontOps,
+                  TScreenOf(term)->allowFontOps);
+}
+
+void
+update_menu_allowTcapOps(void)
+{
+    UpdateCheckbox("update_menu_allowTcapOps",
+                  fontMenuEntries,
+                  fontMenu_allowTcapOps,
+                  TScreenOf(term)->allowTcapOps);
+}
+
+void
+update_menu_allowTitleOps(void)
+{
+    UpdateCheckbox("update_menu_allowTitleOps",
+                  fontMenuEntries,
+                  fontMenu_allowTitleOps,
+                  TScreenOf(term)->allowTitleOps);
+}
+
+void
+update_menu_allowWindowOps(void)
+{
+    UpdateCheckbox("update_menu_allowWindowOps",
+                  fontMenuEntries,
+                  fontMenu_allowWindowOps,
+                  TScreenOf(term)->allowWindowOps);
+}
+#endif
+
+#if OPT_TEK4014
+void
+update_tekshow(void)
+{
+    if (!(TScreenOf(term)->inhibit & I_TEK)) {
+       UpdateCheckbox("update_tekshow",
+                      vtMenuEntries,
+                      vtMenu_tekshow,
+                      TEK4014_SHOWN(term));
+    }
+}
+
+void
+update_vttekmode(void)
+{
+    if (!(TScreenOf(term)->inhibit & I_TEK)) {
+       UpdateCheckbox("update_vtmode",
+                      vtMenuEntries,
+                      vtMenu_tekmode,
+                      TEK4014_ACTIVE(term));
+       UpdateCheckbox("update_tekmode",
+                      tekMenuEntries,
+                      tekMenu_vtmode,
+                      !TEK4014_ACTIVE(term));
+    }
+}
+
+void
+update_vtshow(void)
+{
+    if (!(TScreenOf(term)->inhibit & I_TEK)) {
+       UpdateCheckbox("update_vtshow",
+                      tekMenuEntries,
+                      tekMenu_vtshow,
+                      TScreenOf(term)->Vshow);
+    }
+}
+
+void
+set_vthide_sensitivity(void)
+{
+    if (!(TScreenOf(term)->inhibit & I_TEK)) {
+       SetItemSensitivity(
+                             vtMenuEntries[vtMenu_vthide].widget,
+                             TEK4014_SHOWN(term));
+    }
+}
+
+void
+set_tekhide_sensitivity(void)
+{
+    if (!(TScreenOf(term)->inhibit & I_TEK)) {
+       SetItemSensitivity(
+                             tekMenuEntries[tekMenu_tekhide].widget,
+                             TScreenOf(term)->Vshow);
+    }
+}
+
+void
+set_tekfont_menu_item(int n, int val)
+{
+    if (!(TScreenOf(term)->inhibit & I_TEK)) {
+       UpdateCheckbox("set_tekfont_menu_item", tekMenuEntries, FS2MI(n),
+                      (val));
+    }
+}
+#endif /* OPT_TEK4014 */
+
+void
+set_menu_font(int val)
+{
+    UpdateCheckbox("set_menu_font",
+                  fontMenuEntries,
+                  TScreenOf(term)->menu_font_number,
+                  (val));
+}
diff --git a/menu.h b/menu.h
new file mode 100644 (file)
index 0000000..f894a95
--- /dev/null
+++ b/menu.h
@@ -0,0 +1,507 @@
+/* $XTermId: menu.h,v 1.122 2011/01/20 09:42:50 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1989  The Open Group
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation.
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of The Open Group shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization
+ * from The Open Group.
+ *
+ */
+
+#ifndef included_menu_h
+#define included_menu_h
+/* *INDENT-OFF* */
+
+#include <xterm.h>
+
+typedef struct _MenuEntry {
+    const char *name;
+    void (*function) PROTO_XT_CALLBACK_ARGS;
+    Widget widget;
+} MenuEntry;
+
+extern MenuEntry mainMenuEntries[], vtMenuEntries[];
+extern MenuEntry fontMenuEntries[];
+#if OPT_TEK4014
+extern MenuEntry tekMenuEntries[];
+#endif
+
+extern void Handle8BitControl      PROTO_XT_ACTIONS_ARGS;
+extern void HandleAllow132         PROTO_XT_ACTIONS_ARGS;
+extern void HandleAllowColorOps    PROTO_XT_ACTIONS_ARGS;
+extern void HandleAllowFontOps     PROTO_XT_ACTIONS_ARGS;
+extern void HandleAllowSends       PROTO_XT_ACTIONS_ARGS;
+extern void HandleAllowTcapOps     PROTO_XT_ACTIONS_ARGS;
+extern void HandleAllowTitleOps    PROTO_XT_ACTIONS_ARGS;
+extern void HandleAllowWindowOps   PROTO_XT_ACTIONS_ARGS;
+extern void HandleAltEsc           PROTO_XT_ACTIONS_ARGS;
+extern void HandleAltScreen        PROTO_XT_ACTIONS_ARGS;
+extern void HandleAppCursor        PROTO_XT_ACTIONS_ARGS;
+extern void HandleAppKeypad        PROTO_XT_ACTIONS_ARGS;
+extern void HandleAutoLineFeed     PROTO_XT_ACTIONS_ARGS;
+extern void HandleAutoWrap         PROTO_XT_ACTIONS_ARGS;
+extern void HandleBackarrow        PROTO_XT_ACTIONS_ARGS;
+extern void HandleBellIsUrgent     PROTO_XT_ACTIONS_ARGS;
+extern void HandleClearSavedLines  PROTO_XT_ACTIONS_ARGS;
+extern void HandleCreateMenu       PROTO_XT_ACTIONS_ARGS;
+extern void HandleCursesEmul       PROTO_XT_ACTIONS_ARGS;
+extern void HandleCursorBlink      PROTO_XT_ACTIONS_ARGS;
+extern void HandleDeleteIsDEL      PROTO_XT_ACTIONS_ARGS;
+extern void HandleFontBoxChars     PROTO_XT_ACTIONS_ARGS;
+extern void HandleFontDoublesize   PROTO_XT_ACTIONS_ARGS;
+extern void HandleFontLoading      PROTO_XT_ACTIONS_ARGS;
+extern void HandleFontPacked       PROTO_XT_ACTIONS_ARGS;
+extern void HandleFullscreen       PROTO_XT_ACTIONS_ARGS;
+extern void HandleHardReset        PROTO_XT_ACTIONS_ARGS;
+extern void HandleHpFunctionKeys   PROTO_XT_ACTIONS_ARGS;
+extern void HandleJumpscroll       PROTO_XT_ACTIONS_ARGS;
+extern void HandleKeepSelection    PROTO_XT_ACTIONS_ARGS;
+extern void HandleLogging          PROTO_XT_ACTIONS_ARGS;
+extern void HandleMarginBell       PROTO_XT_ACTIONS_ARGS;
+extern void HandleMetaEsc          PROTO_XT_ACTIONS_ARGS;
+extern void HandleNumLock          PROTO_XT_ACTIONS_ARGS;
+extern void HandleOldFunctionKeys  PROTO_XT_ACTIONS_ARGS;
+extern void HandlePopupMenu        PROTO_XT_ACTIONS_ARGS;
+extern void HandlePrintControlMode PROTO_XT_ACTIONS_ARGS;
+extern void HandlePrintEverything  PROTO_XT_ACTIONS_ARGS;
+extern void HandlePrintScreen      PROTO_XT_ACTIONS_ARGS;
+extern void HandleQuit             PROTO_XT_ACTIONS_ARGS;
+extern void HandleRedraw           PROTO_XT_ACTIONS_ARGS;
+extern void HandleRenderFont       PROTO_XT_ACTIONS_ARGS;
+extern void HandleReverseVideo     PROTO_XT_ACTIONS_ARGS;
+extern void HandleReverseWrap      PROTO_XT_ACTIONS_ARGS;
+extern void HandleScoFunctionKeys  PROTO_XT_ACTIONS_ARGS;
+extern void HandleScrollKey        PROTO_XT_ACTIONS_ARGS;
+extern void HandleScrollTtyOutput  PROTO_XT_ACTIONS_ARGS;
+extern void HandleScrollbar        PROTO_XT_ACTIONS_ARGS;
+extern void HandleSecure           PROTO_XT_ACTIONS_ARGS;
+extern void HandleSendSignal       PROTO_XT_ACTIONS_ARGS;
+extern void HandleSetPopOnBell     PROTO_XT_ACTIONS_ARGS;
+extern void HandleSetSelect        PROTO_XT_ACTIONS_ARGS;
+extern void HandleSetTekText       PROTO_XT_ACTIONS_ARGS;
+extern void HandleSetTerminalType  PROTO_XT_ACTIONS_ARGS;
+extern void HandleSetVisualBell    PROTO_XT_ACTIONS_ARGS;
+extern void HandleSoftReset        PROTO_XT_ACTIONS_ARGS;
+extern void HandleSunFunctionKeys  PROTO_XT_ACTIONS_ARGS;
+extern void HandleSunKeyboard      PROTO_XT_ACTIONS_ARGS;
+extern void HandleTekCopy          PROTO_XT_ACTIONS_ARGS;
+extern void HandleTekPage          PROTO_XT_ACTIONS_ARGS;
+extern void HandleTekReset         PROTO_XT_ACTIONS_ARGS;
+extern void HandleTiteInhibit      PROTO_XT_ACTIONS_ARGS;
+extern void HandleToolbar          PROTO_XT_ACTIONS_ARGS;
+extern void HandleUTF8Mode         PROTO_XT_ACTIONS_ARGS;
+extern void HandleUTF8Title        PROTO_XT_ACTIONS_ARGS;
+extern void HandleVisibility       PROTO_XT_ACTIONS_ARGS;
+
+extern void SetupMenus (Widget /*shell*/, Widget */*forms*/, Widget */*menus*/, Dimension * /*menu_high*/);
+
+#if OPT_TOOLBAR
+extern void ShowToolbar(Bool);
+#endif
+
+/*
+ * The following definitions MUST match the order of entries given in
+ * the mainMenuEntries, vtMenuEntries, and tekMenuEntries arrays in menu.c.
+ */
+
+/*
+ * items in primary menu
+ */
+typedef enum {
+#if OPT_TOOLBAR
+    mainMenu_toolbar,
+#endif
+#if OPT_MAXIMIZE
+    mainMenu_fullscreen,
+#endif
+    mainMenu_securekbd,
+    mainMenu_allowsends,
+    mainMenu_redraw,
+    mainMenu_line1,
+#ifdef ALLOWLOGGING
+    mainMenu_logging,
+#endif
+    mainMenu_print,
+    mainMenu_print_redir,
+    mainMenu_line2,
+    mainMenu_8bit_ctrl,
+    mainMenu_backarrow,
+#if OPT_NUM_LOCK
+    mainMenu_num_lock,
+    mainMenu_alt_esc,
+    mainMenu_meta_esc,
+#endif
+    mainMenu_delete_del,
+    mainMenu_old_fkeys,
+#if OPT_TCAP_FKEYS
+    mainMenu_tcap_fkeys,
+#endif
+#if OPT_HP_FUNC_KEYS
+    mainMenu_hp_fkeys,
+#endif
+#if OPT_SCO_FUNC_KEYS
+    mainMenu_sco_fkeys,
+#endif
+#if OPT_SUN_FUNC_KEYS
+    mainMenu_sun_fkeys,
+#endif
+#if OPT_SUNPC_KBD
+    mainMenu_sun_kbd,
+#endif
+    mainMenu_line3,
+    mainMenu_suspend,
+    mainMenu_continue,
+    mainMenu_interrupt,
+    mainMenu_hangup,
+    mainMenu_terminate,
+    mainMenu_kill,
+    mainMenu_line4,
+    mainMenu_quit,
+    mainMenu_LAST
+} mainMenuIndices;
+
+
+/*
+ * items in vt100 mode menu
+ */
+typedef enum {
+    vtMenu_scrollbar,
+    vtMenu_jumpscroll,
+    vtMenu_reversevideo,
+    vtMenu_autowrap,
+    vtMenu_reversewrap,
+    vtMenu_autolinefeed,
+    vtMenu_appcursor,
+    vtMenu_appkeypad,
+    vtMenu_scrollkey,
+    vtMenu_scrollttyoutput,
+    vtMenu_allow132,
+    vtMenu_keepSelection,
+    vtMenu_selectToClipboard,
+    vtMenu_visualbell,
+    vtMenu_bellIsUrgent,
+    vtMenu_poponbell,
+#if OPT_BLINK_CURS
+    vtMenu_cursorblink,
+#endif
+    vtMenu_titeInhibit,
+#ifndef NO_ACTIVE_ICON
+    vtMenu_activeicon,
+#endif /* NO_ACTIVE_ICON */
+    vtMenu_line1,
+    vtMenu_softreset,
+    vtMenu_hardreset,
+    vtMenu_clearsavedlines,
+    vtMenu_line2,
+#if OPT_TEK4014
+    vtMenu_tekshow,
+    vtMenu_tekmode,
+    vtMenu_vthide,
+#endif
+    vtMenu_altscreen,
+    vtMenu_LAST
+} vtMenuIndices;
+
+/*
+ * items in vt100 font menu
+ */
+typedef enum {
+    fontMenu_default,
+    fontMenu_font1,
+    fontMenu_font2,
+    fontMenu_font3,
+    fontMenu_font4,
+    fontMenu_font5,
+    fontMenu_font6,
+#define fontMenu_lastBuiltin fontMenu_font6
+    fontMenu_fontescape,
+    fontMenu_fontsel,
+/* number of non-line items down to here should match NMENUFONTS in ptyx.h */
+
+#if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT
+    fontMenu_line1,
+#if OPT_BOX_CHARS
+    fontMenu_font_boxchars,
+    fontMenu_font_packedfont,
+#endif
+#if OPT_DEC_CHRSET
+    fontMenu_font_doublesize,
+#endif
+#if OPT_DEC_SOFTFONT
+    fontMenu_font_loadable,
+#endif
+#endif
+
+#if OPT_RENDERFONT || OPT_WIDE_CHARS
+    fontMenu_line2,
+#if OPT_RENDERFONT
+    fontMenu_render_font,
+#endif
+#if OPT_WIDE_CHARS
+    fontMenu_wide_chars,
+    fontMenu_wide_title,
+#endif
+#endif
+#if OPT_ALLOW_XXX_OPS
+    fontMenu_line3,
+    fontMenu_allowColorOps,
+    fontMenu_allowFontOps,
+    fontMenu_allowTcapOps,
+    fontMenu_allowTitleOps,
+    fontMenu_allowWindowOps,
+#endif
+
+    fontMenu_LAST
+} fontMenuIndices;
+
+/*
+ * items in tek4014 mode menu
+ */
+#if OPT_TEK4014
+typedef enum {
+    tekMenu_tektextlarge,
+    tekMenu_tektext2,
+    tekMenu_tektext3,
+    tekMenu_tektextsmall,
+    tekMenu_line1,
+    tekMenu_tekpage,
+    tekMenu_tekreset,
+    tekMenu_tekcopy,
+    tekMenu_line2,
+    tekMenu_vtshow,
+    tekMenu_vtmode,
+    tekMenu_tekhide,
+    tekMenu_LAST
+} tekMenuIndices;
+#endif
+
+
+/*
+ * functions for updating menus
+ */
+
+extern void SetItemSensitivity(Widget mi, Bool val);
+
+/*
+ * there should be one of each of the following for each checkable item
+ */
+#if OPT_TOOLBAR
+extern void update_toolbar(void);
+#else
+#define update_toolbar() /* nothing */
+#endif
+
+#if OPT_MAXIMIZE
+extern void update_fullscreen(void);
+#else
+#define update_fullscreen() /* nothing */
+#endif
+
+extern void update_securekbd(void);
+extern void update_allowsends(void);
+
+#ifdef ALLOWLOGGING
+extern void update_logging(void);
+#else
+#define update_logging() /*nothing*/
+#endif
+
+extern void update_print_redir(void);
+extern void update_8bit_control(void);
+extern void update_decbkm(void);
+
+#if OPT_NUM_LOCK
+extern void update_num_lock(void);
+extern void update_alt_esc(void);
+extern void update_meta_esc(void);
+#else
+#define update_num_lock() /*nothing*/
+#define update_alt_esc()  /*nothing*/
+#define update_meta_esc() /*nothing*/
+#endif
+
+extern void update_old_fkeys(void);
+extern void update_delete_del(void);
+
+#if OPT_SUNPC_KBD
+extern void update_sun_kbd(void);
+#endif
+
+#if OPT_HP_FUNC_KEYS
+extern void update_hp_fkeys(void);
+#else
+#define update_hp_fkeys() /*nothing*/
+#endif
+
+#if OPT_SCO_FUNC_KEYS
+extern void update_sco_fkeys(void);
+#else
+#define update_sco_fkeys() /*nothing*/
+#endif
+
+#if OPT_SUN_FUNC_KEYS
+extern void update_sun_fkeys(void);
+#else
+#define update_sun_fkeys() /*nothing*/
+#endif
+
+#if OPT_TCAP_FKEYS
+extern void update_tcap_fkeys(void);
+#else
+#define update_tcap_fkeys() /*nothing*/
+#endif
+
+extern void update_scrollbar(void);
+extern void update_jumpscroll(void);
+extern void update_reversevideo(void);
+extern void update_autowrap(void);
+extern void update_reversewrap(void);
+extern void update_autolinefeed(void);
+extern void update_appcursor(void);
+extern void update_appkeypad(void);
+extern void update_scrollkey(void);
+extern void update_keepSelection(void);
+extern void update_selectToClipboard(void);
+extern void update_scrollttyoutput(void);
+extern void update_allow132(void);
+extern void update_cursesemul(void);
+extern void update_visualbell(void);
+extern void update_bellIsUrgent(void);
+extern void update_poponbell(void);
+
+#define update_marginbell() /* nothing */
+
+#if OPT_ALLOW_XXX_OPS
+extern void update_menu_allowColorOps(void);
+extern void update_menu_allowFontOps(void);
+extern void update_menu_allowTcapOps(void);
+extern void update_menu_allowTitleOps(void);
+extern void update_menu_allowWindowOps(void);
+#endif
+
+#if OPT_BLINK_CURS
+extern void update_cursorblink(void);
+#else
+#define update_cursorblink() /* nothing */
+#endif
+
+extern void update_altscreen(void);
+extern void update_titeInhibit(void);
+
+#ifndef NO_ACTIVE_ICON
+extern void update_activeicon(void);
+#endif /* NO_ACTIVE_ICON */
+
+#if OPT_DEC_CHRSET
+extern void update_font_doublesize(void);
+#else
+#define update_font_doublesize() /* nothing */
+#endif
+
+#if OPT_BOX_CHARS
+extern void update_font_boxchars(void);
+extern void update_font_packed(void);
+#else
+#define update_font_boxchars() /* nothing */
+#define update_font_packed() /* nothing */
+#endif
+
+#if OPT_DEC_SOFTFONT
+extern void update_font_loadable(void);
+#else
+#define update_font_loadable() /* nothing */
+#endif
+
+#if OPT_RENDERFONT
+extern void update_font_renderfont(void);
+#else
+#define update_font_renderfont() /* nothing */
+#endif
+
+#if OPT_WIDE_CHARS
+extern void update_font_utf8_mode(void);
+extern void update_font_utf8_title(void);
+#else
+#define update_font_utf8_mode() /* nothing */
+#define update_font_utf8_title() /* nothing */
+#endif
+
+#if OPT_TEK4014
+extern void update_tekshow(void);
+extern void update_vttekmode(void);
+extern void update_vtshow(void);
+extern void set_vthide_sensitivity(void);
+extern void set_tekhide_sensitivity(void);
+#else
+#define update_tekshow() /*nothing*/
+#define update_vttekmode() /*nothing*/
+#define update_vtshow() /*nothing*/
+#define set_vthide_sensitivity() /*nothing*/
+#define set_tekhide_sensitivity() /*nothing*/
+#endif
+
+/*
+ * macros for mapping font size to tekMenu placement
+ */
+#define FS2MI(n) (n)                   /* font_size_to_menu_item */
+#define MI2FS(n) (n)                   /* menu_item_to_font_size */
+
+#if OPT_TEK4014
+extern void set_tekfont_menu_item(int n,int val);
+#else
+#define set_tekfont_menu_item(n,val) /*nothing*/
+#endif
+
+extern void set_menu_font(int val);
+
+/* *INDENT-ON* */
+
+#endif /* included_menu_h */
diff --git a/minstall.sh b/minstall.sh
new file mode 100755 (executable)
index 0000000..8c94219
--- /dev/null
@@ -0,0 +1,125 @@
+#!/bin/sh
+# $XTermId: minstall.sh,v 1.20 2010/03/03 23:44:49 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2001-2009,2010 by Thomas E. Dickey
+#
+#                         All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# Install manpages, substituting a reasonable section value since XFree86 4.x
+# and derived imakes do not use constants...
+#
+# Parameters:
+#      $1 = program to invoke as "install"
+#      $2 = manpage to install
+#      $3 = final installed-path
+#      $4 = app-defaults directory
+#
+
+# override locale...
+LANG=C;                export LANG
+LANGUAGE=C;    export LANGUAGE
+LC_ALL=C;      export LC_ALL
+LC_CTYPE=C;    export LC_CTYPE
+XTERM_LOCALE=C export XTERM_LOCALE
+
+# avoid interference by the "man" command.
+for p in /bin /usr/bin
+do
+if test -f $p/cat ; then
+MANPAGER=cat;   export MANPAGER
+PAGER=cat;      export PAGER
+break
+fi
+done
+
+# get parameters
+MINSTALL="$1"
+OLD_FILE="$2"
+END_FILE="$3"
+APPS_DIR="$4"
+
+suffix=`echo "$END_FILE" | sed -e 's%^.*\.%%'`
+NEW_FILE=temp$$
+
+MY_MANSECT=$suffix
+
+# utmp and wtmp have different pathnames on different systems, but there
+# are only a few common choices.  Note that they may not necessarily appear
+# in the same directories.  Prefer utmpx/wtmpx to utmp/wtmp, since that's
+# the way the configure script is designed.
+UTMP_NAME=utmp
+UTMP_PATH=/etc
+for name in /etc /var/adm /var/run /var/log
+do
+       if test -f $name/utmpx ; then
+               UTMP_NAME=utmpx
+               UTMP_PATH=$name
+               break
+       elif test -f $name/utmp ; then
+               UTMP_PATH=$name
+               break
+       fi
+done
+UTMP_PATH=$UTMP_PATH/$UTMP_NAME
+
+WTMP_NAME=wtmp
+WTMP_PATH=/etc
+for name in /etc /var/adm /var/run /var/log
+do
+       if test -f $name/wtmpx ; then
+               WTMP_NAME=wtmpx
+               WTMP_PATH=$name
+               break
+       elif test -f $name/wtmp ; then
+               WTMP_PATH=$name
+               break
+       fi
+done
+WTMP_PATH=$WTMP_PATH/$WTMP_NAME
+
+# "X" is usually in the miscellaneous section, along with "undocumented".
+# Use that to guess an appropriate section.
+X_MANSECT=`man X 2>&1 | tr '\012' '\020' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
+test -z "$X_MANSECT" && X_MANSECT=$suffix
+
+sed    -e 's%__vendorversion__%"X Window System"%' \
+       -e s%__apploaddir__%$APPS_DIR% \
+       -e s%__mansuffix__%$MY_MANSECT%g \
+       -e s%__miscmansuffix__%$X_MANSECT%g \
+       -e s%fIutmp'\\%fI'$UTMP_NAME'\\%g' \
+       -e s%/etc/utmp%$UTMP_PATH%g \
+       -e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \
+       -e s%/etc/wtmp%$WTMP_PATH%g \
+       $OLD_FILE >$NEW_FILE
+
+echo "$MINSTALL $OLD_FILE $END_FILE"
+eval "$MINSTALL $NEW_FILE $END_FILE"
+
+rm -f $NEW_FILE
diff --git a/misc.c b/misc.c
new file mode 100644 (file)
index 0000000..0ba0fc5
--- /dev/null
+++ b/misc.c
@@ -0,0 +1,4733 @@
+/* $XTermId: misc.c,v 1.517 2011/02/09 10:14:20 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <version.h>
+#include <main.h>
+#include <xterm.h>
+
+#include <sys/stat.h>
+#include <stdio.h>
+#include <signal.h>
+#include <ctype.h>
+#include <pwd.h>
+#include <sys/wait.h>
+
+#include <X11/keysym.h>
+#include <X11/Xatom.h>
+#include <X11/cursorfont.h>
+#include <X11/Xlocale.h>
+
+#include <X11/Xmu/Error.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xmu/WinUtil.h>
+#include <X11/Xmu/Xmu.h>
+#if HAVE_X11_SUNKEYSYM_H
+#include <X11/Sunkeysym.h>
+#endif
+
+#ifdef HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
+#include <xutf8.h>
+
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <fontutils.h>
+#include <xcharmouse.h>
+#include <xstrings.h>
+#include <xtermcap.h>
+#include <VTparse.h>
+
+#include <assert.h>
+
+#if (XtSpecificationRelease < 6)
+#ifndef X_GETTIMEOFDAY
+#define X_GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *)0)
+#endif
+#endif
+
+#ifdef VMS
+#define XTERM_VMS_LOGFILE "SYS$SCRATCH:XTERM_LOG.TXT"
+#ifdef ALLOWLOGFILEEXEC
+#undef ALLOWLOGFILEEXEC
+#endif
+#endif /* VMS */
+
+#if OPT_TEK4014
+#define OUR_EVENT(event,Type) \
+               (event.type == Type && \
+                 (event.xcrossing.window == XtWindow(XtParent(xw)) || \
+                   (tekWidget && \
+                    event.xcrossing.window == XtWindow(XtParent(tekWidget)))))
+#else
+#define OUR_EVENT(event,Type) \
+               (event.type == Type && \
+                  (event.xcrossing.window == XtWindow(XtParent(xw))))
+#endif
+
+static Cursor make_hidden_cursor(XtermWidget);
+
+#if OPT_EXEC_XTERM
+/* Like readlink(2), but returns a malloc()ed buffer, or NULL on
+   error; adapted from libc docs */
+static char *
+Readlink(const char *filename)
+{
+    char *buf = NULL;
+    size_t size = 100;
+    int n;
+
+    for (;;) {
+       buf = TypeRealloc(char, size, buf);
+       memset(buf, 0, size);
+
+       n = (int) readlink(filename, buf, size);
+       if (n < 0) {
+           free(buf);
+           return NULL;
+       }
+
+       if ((unsigned) n < size) {
+           return buf;
+       }
+
+       size *= 2;
+    }
+}
+#endif /* OPT_EXEC_XTERM */
+
+static void
+Sleep(int msec)
+{
+    static struct timeval select_timeout;
+
+    select_timeout.tv_sec = 0;
+    select_timeout.tv_usec = msec * 1000;
+    select(0, 0, 0, 0, &select_timeout);
+}
+
+static void
+selectwindow(TScreen * screen, int flag)
+{
+    TRACE(("selectwindow(%d) flag=%d\n", screen->select, flag));
+
+#if OPT_TEK4014
+    if (TEK4014_ACTIVE(term)) {
+       if (!Ttoggled)
+           TCursorToggle(tekWidget, TOGGLE);
+       screen->select |= flag;
+       if (!Ttoggled)
+           TCursorToggle(tekWidget, TOGGLE);
+    } else
+#endif
+    {
+       if (screen->xic)
+           XSetICFocus(screen->xic);
+
+       if (screen->cursor_state && CursorMoved(screen))
+           HideCursor();
+       screen->select |= flag;
+       if (screen->cursor_state)
+           ShowCursor();
+    }
+    GetScrollLock(screen);
+}
+
+static void
+unselectwindow(TScreen * screen, int flag)
+{
+    TRACE(("unselectwindow(%d) flag=%d\n", screen->select, flag));
+
+    if (screen->hide_pointer) {
+       screen->hide_pointer = False;
+       xtermDisplayCursor(term);
+    }
+
+    if (!screen->always_highlight) {
+#if OPT_TEK4014
+       if (TEK4014_ACTIVE(term)) {
+           if (!Ttoggled)
+               TCursorToggle(tekWidget, TOGGLE);
+           screen->select &= ~flag;
+           if (!Ttoggled)
+               TCursorToggle(tekWidget, TOGGLE);
+       } else
+#endif
+       {
+           if (screen->xic)
+               XUnsetICFocus(screen->xic);
+
+           screen->select &= ~flag;
+           if (screen->cursor_state && CursorMoved(screen))
+               HideCursor();
+           if (screen->cursor_state)
+               ShowCursor();
+       }
+    }
+}
+
+static void
+DoSpecialEnterNotify(XtermWidget xw, XEnterWindowEvent * ev)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("DoSpecialEnterNotify(%d)\n", screen->select));
+    TRACE_FOCUS(xw, ev);
+    if (((ev->detail) != NotifyInferior) &&
+       ev->focus &&
+       !(screen->select & FOCUS))
+       selectwindow(screen, INWINDOW);
+}
+
+static void
+DoSpecialLeaveNotify(XtermWidget xw, XEnterWindowEvent * ev)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("DoSpecialLeaveNotify(%d)\n", screen->select));
+    TRACE_FOCUS(xw, ev);
+    if (((ev->detail) != NotifyInferior) &&
+       ev->focus &&
+       !(screen->select & FOCUS))
+       unselectwindow(screen, INWINDOW);
+}
+
+#ifndef XUrgencyHint
+#define XUrgencyHint (1L << 8) /* X11R5 does not define */
+#endif
+
+static void
+setXUrgency(XtermWidget xw, Bool enable)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->bellIsUrgent) {
+       XWMHints *h = XGetWMHints(screen->display, VShellWindow(xw));
+       if (h != 0) {
+           if (enable && !(screen->select & FOCUS)) {
+               h->flags |= XUrgencyHint;
+           } else {
+               h->flags &= ~XUrgencyHint;
+           }
+           XSetWMHints(screen->display, VShellWindow(xw), h);
+       }
+    }
+}
+
+void
+do_xevents(void)
+{
+    TScreen *screen = TScreenOf(term);
+
+    if (XtAppPending(app_con)
+       ||
+#if defined(VMS) || defined(__VMS)
+       screen->display->qlen > 0
+#else
+       GetBytesAvailable(ConnectionNumber(screen->display)) > 0
+#endif
+       )
+       xevents();
+}
+
+void
+xtermDisplayCursor(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->Vshow) {
+       if (screen->hide_pointer) {
+           TRACE(("Display hidden_cursor\n"));
+           XDefineCursor(screen->display, VWindow(screen), screen->hidden_cursor);
+       } else {
+           TRACE(("Display pointer_cursor\n"));
+           recolor_cursor(screen,
+                          screen->pointer_cursor,
+                          T_COLOR(screen, MOUSE_FG),
+                          T_COLOR(screen, MOUSE_BG));
+           XDefineCursor(screen->display, VWindow(screen), screen->pointer_cursor);
+       }
+    }
+}
+
+void
+xtermShowPointer(XtermWidget xw, Bool enable)
+{
+    static int tried = -1;
+    TScreen *screen = TScreenOf(xw);
+
+#if OPT_TEK4014
+    if (TEK4014_SHOWN(xw))
+       enable = True;
+#endif
+
+    /*
+     * Whether we actually hide the pointer depends on the pointer-mode and
+     * the mouse-mode:
+     */
+    if (!enable) {
+       switch (screen->pointer_mode) {
+       case pNever:
+           enable = True;
+           break;
+       case pNoMouse:
+           if (screen->send_mouse_pos != MOUSE_OFF)
+               enable = True;
+           break;
+       case pAlways:
+           break;
+       }
+    }
+
+    if (enable) {
+       if (screen->hide_pointer) {
+           screen->hide_pointer = False;
+           xtermDisplayCursor(xw);
+           switch (screen->send_mouse_pos) {
+           case ANY_EVENT_MOUSE:
+               break;
+           default:
+               MotionOff(screen, xw);
+               break;
+           }
+       }
+    } else if (!(screen->hide_pointer) && (tried <= 0)) {
+       if (screen->hidden_cursor == 0) {
+           screen->hidden_cursor = make_hidden_cursor(xw);
+       }
+       if (screen->hidden_cursor == 0) {
+           tried = 1;
+       } else {
+           tried = 0;
+           screen->hide_pointer = True;
+           xtermDisplayCursor(xw);
+           MotionOn(screen, xw);
+       }
+    }
+}
+
+void
+xevents(void)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    XEvent event;
+    XtInputMask input_mask;
+
+    if (need_cleanup)
+       Cleanup(0);
+
+    if (screen->scroll_amt)
+       FlushScroll(xw);
+    /*
+     * process timeouts, relying on the fact that XtAppProcessEvent
+     * will process the timeout and return without blockng on the
+     * XEvent queue.  Other sources i.e., the pty are handled elsewhere
+     * with select().
+     */
+    while ((input_mask = XtAppPending(app_con)) != 0) {
+       if (input_mask & XtIMTimer)
+           XtAppProcessEvent(app_con, (XtInputMask) XtIMTimer);
+#if OPT_SESSION_MGT
+       /*
+        * Session management events are alternative input events. Deal with
+        * them in the same way.
+        */
+       else if (input_mask & XtIMAlternateInput)
+           XtAppProcessEvent(app_con, (XtInputMask) XtIMAlternateInput);
+#endif
+       else
+           break;
+    }
+
+    /*
+     * If there's no XEvents, don't wait around...
+     */
+    if ((input_mask & XtIMXEvent) != XtIMXEvent)
+       return;
+    do {
+       /*
+        * This check makes xterm hang when in mouse hilite tracking mode.
+        * We simply ignore all events except for those not passed down to
+        * this function, e.g., those handled in in_put().
+        */
+       if (screen->waitingForTrackInfo) {
+           Sleep(10);
+           return;
+       }
+       XtAppNextEvent(app_con, &event);
+       /*
+        * Hack to get around problems with the toolkit throwing away
+        * eventing during the exclusive grab of the menu popup.  By
+        * looking at the event ourselves we make sure that we can
+        * do the right thing.
+        */
+       if (OUR_EVENT(event, EnterNotify)) {
+           DoSpecialEnterNotify(xw, &event.xcrossing);
+       } else if (OUR_EVENT(event, LeaveNotify)) {
+           DoSpecialLeaveNotify(xw, &event.xcrossing);
+       } else if ((screen->send_mouse_pos == ANY_EVENT_MOUSE
+#if OPT_DEC_LOCATOR
+                   || screen->send_mouse_pos == DEC_LOCATOR
+#endif /* OPT_DEC_LOCATOR */
+                  )
+                  && event.xany.type == MotionNotify
+                  && event.xcrossing.window == XtWindow(xw)) {
+           SendMousePosition(xw, &event);
+           xtermShowPointer(xw, True);
+           continue;
+       }
+
+       /*
+        * If the event is interesting (and not a keyboard event), turn the
+        * mouse pointer back on.
+        */
+       if (screen->hide_pointer) {
+           switch (event.xany.type) {
+           case KeyPress:
+           case KeyRelease:
+           case ButtonPress:
+           case ButtonRelease:
+               /* also these... */
+           case Expose:
+           case NoExpose:
+           case PropertyNotify:
+           case ClientMessage:
+               break;
+           default:
+               xtermShowPointer(xw, True);
+               break;
+           }
+       }
+
+       if (!event.xany.send_event ||
+           screen->allowSendEvents ||
+           ((event.xany.type != KeyPress) &&
+            (event.xany.type != KeyRelease) &&
+            (event.xany.type != ButtonPress) &&
+            (event.xany.type != ButtonRelease))) {
+
+           XtDispatchEvent(&event);
+       }
+    } while (XtAppPending(app_con) & XtIMXEvent);
+}
+
+static Cursor
+make_hidden_cursor(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Cursor c;
+    Display *dpy = screen->display;
+    XFontStruct *fn;
+
+    static XColor dummy;
+
+    /*
+     * Prefer nil2 (which is normally available) to "fixed" (which is supposed
+     * to be "always" available), since it's a smaller glyph in case the
+     * server insists on drawing _something_.
+     */
+    TRACE(("Ask for nil2 font\n"));
+    if ((fn = XLoadQueryFont(dpy, "nil2")) == 0) {
+       TRACE(("...Ask for fixed font\n"));
+       fn = XLoadQueryFont(dpy, DEFFONT);
+    }
+
+    if (fn != 0) {
+       /* a space character seems to work as a cursor (dots are not needed) */
+       c = XCreateGlyphCursor(dpy, fn->fid, fn->fid, 'X', ' ', &dummy, &dummy);
+       XFreeFont(dpy, fn);
+    } else {
+       c = 0;
+    }
+    TRACE(("XCreateGlyphCursor ->%#lx\n", c));
+    return (c);
+}
+
+Cursor
+make_colored_cursor(unsigned cursorindex,      /* index into font */
+                   unsigned long fg,   /* pixel value */
+                   unsigned long bg)   /* pixel value */
+{
+    TScreen *screen = TScreenOf(term);
+    Cursor c;
+    Display *dpy = screen->display;
+
+    c = XCreateFontCursor(dpy, cursorindex);
+    if (c != None) {
+       recolor_cursor(screen, c, fg, bg);
+    }
+    return (c);
+}
+
+/* ARGSUSED */
+void
+HandleKeyPressed(Widget w GCC_UNUSED,
+                XEvent * event,
+                String * params GCC_UNUSED,
+                Cardinal *nparams GCC_UNUSED)
+{
+    TRACE(("Handle insert-seven-bit for %p\n", (void *) w));
+    Input(term, &event->xkey, False);
+}
+
+/* ARGSUSED */
+void
+HandleEightBitKeyPressed(Widget w GCC_UNUSED,
+                        XEvent * event,
+                        String * params GCC_UNUSED,
+                        Cardinal *nparams GCC_UNUSED)
+{
+    TRACE(("Handle insert-eight-bit for %p\n", (void *) w));
+    Input(term, &event->xkey, True);
+}
+
+/* ARGSUSED */
+void
+HandleStringEvent(Widget w GCC_UNUSED,
+                 XEvent * event GCC_UNUSED,
+                 String * params,
+                 Cardinal *nparams)
+{
+
+    if (*nparams != 1)
+       return;
+
+    if ((*params)[0] == '0' && (*params)[1] == 'x' && (*params)[2] != '\0') {
+       const char *abcdef = "ABCDEF";
+       const char *xxxxxx;
+       Char c;
+       UString p;
+       unsigned value = 0;
+
+       for (p = (UString) (*params + 2); (c = CharOf(x_toupper(*p))) !=
+            '\0'; p++) {
+           value *= 16;
+           if (c >= '0' && c <= '9')
+               value += (unsigned) (c - '0');
+           else if ((xxxxxx = strchr(abcdef, c)) != 0)
+               value += (unsigned) (xxxxxx - abcdef) + 10;
+           else
+               break;
+       }
+       if (c == '\0') {
+           Char hexval[2];
+           hexval[0] = (Char) value;
+           hexval[1] = 0;
+           StringInput(term, hexval, (size_t) 1);
+       }
+    } else {
+       StringInput(term, (const Char *) *params, strlen(*params));
+    }
+}
+
+#if OPT_EXEC_XTERM
+
+#ifndef PROCFS_ROOT
+#define PROCFS_ROOT "/proc"
+#endif
+
+/* ARGSUSED */
+void
+HandleSpawnTerminal(Widget w GCC_UNUSED,
+                   XEvent * event GCC_UNUSED,
+                   String * params,
+                   Cardinal *nparams)
+{
+    TScreen *screen = TScreenOf(term);
+    char *child_cwd = NULL;
+    char *child_exe;
+    pid_t pid;
+
+    /*
+     * Try to find the actual program which is running in the child process.
+     * This works for Linux.  If we cannot find the program, fall back to the
+     * xterm program (which is usually adequate).  Give up if we are given only
+     * a relative path to xterm, since that would not always match $PATH.
+     */
+    child_exe = Readlink(PROCFS_ROOT "/self/exe");
+    if (!child_exe) {
+       if (strncmp(ProgramName, "./", (size_t) 2)
+           && strncmp(ProgramName, "../", (size_t) 3)) {
+           child_exe = xtermFindShell(ProgramName, True);
+       } else {
+           fprintf(stderr, "Cannot exec-xterm given %s\n", ProgramName);
+       }
+       if (child_exe == 0)
+           return;
+    }
+
+    /*
+     * Determine the current working directory of the child so that we can
+     * spawn a new terminal in the same directory.
+     *
+     * If we cannot get the CWD of the child, just use our own.
+     */
+    if (screen->pid) {
+       char child_cwd_link[sizeof(PROCFS_ROOT) + 80];
+       sprintf(child_cwd_link, PROCFS_ROOT "/%lu/cwd", (unsigned long) screen->pid);
+       child_cwd = Readlink(child_cwd_link);
+    }
+
+    /* The reaper will take care of cleaning up the child */
+    pid = fork();
+    if (pid == -1) {
+       fprintf(stderr, "Could not fork: %s\n", SysErrorMsg(errno));
+    } else if (!pid) {
+       /* We are the child */
+       if (child_cwd) {
+           IGNORE_RC(chdir(child_cwd));        /* We don't care if this fails */
+       }
+
+       if (setuid(screen->uid) == -1
+           || setgid(screen->gid) == -1) {
+           fprintf(stderr, "Cannot reset uid/gid\n");
+       } else {
+           unsigned myargc = *nparams + 1;
+           char **myargv = TypeMallocN(char *, myargc + 1);
+           unsigned n = 0;
+
+           myargv[n++] = child_exe;
+
+           while (n < myargc) {
+               myargv[n++] = *params++;
+           }
+
+           myargv[n] = 0;
+           execv(child_exe, myargv);
+
+           /* If we get here, we've failed */
+           fprintf(stderr, "exec of '%s': %s\n", child_exe, SysErrorMsg(errno));
+       }
+       _exit(0);
+    } else {
+       /* We are the parent; clean up */
+       if (child_cwd)
+           free(child_cwd);
+       if (child_exe)
+           free(child_exe);
+    }
+}
+#endif /* OPT_EXEC_XTERM */
+
+/*
+ * Rather than sending characters to the host, put them directly into our
+ * input queue.  That lets a user have access to any of the control sequences
+ * for a key binding.  This is the equivalent of local function key support.
+ *
+ * NOTE:  This code does not support the hexadecimal kludge used in
+ * HandleStringEvent because it prevents us from sending an arbitrary string
+ * (but it appears in a lot of examples - so we are stuck with it).  The
+ * standard string converter does recognize "\" for newline ("\n") and for
+ * octal constants (e.g., "\007" for BEL).  So we assume the user can make do
+ * without a specialized converter.  (Don't try to use \000, though).
+ */
+/* ARGSUSED */
+void
+HandleInterpret(Widget w GCC_UNUSED,
+               XEvent * event GCC_UNUSED,
+               String * params,
+               Cardinal *param_count)
+{
+    if (*param_count == 1) {
+       const char *value = params[0];
+       int need = (int) strlen(value);
+       int used = (int) (VTbuffer->next - VTbuffer->buffer);
+       int have = (int) (VTbuffer->last - VTbuffer->buffer);
+
+       if (have - used + need < BUF_SIZE) {
+
+           fillPtyData(term, VTbuffer, value, (int) strlen(value));
+
+           TRACE(("Interpret %s\n", value));
+           VTbuffer->update++;
+       }
+    }
+}
+
+/*ARGSUSED*/
+void
+HandleEnterWindow(Widget w GCC_UNUSED,
+                 XtPointer eventdata GCC_UNUSED,
+                 XEvent * event GCC_UNUSED,
+                 Boolean * cont GCC_UNUSED)
+{
+    /* NOP since we handled it above */
+    TRACE(("HandleEnterWindow ignored\n"));
+    TRACE_FOCUS(w, event);
+}
+
+/*ARGSUSED*/
+void
+HandleLeaveWindow(Widget w GCC_UNUSED,
+                 XtPointer eventdata GCC_UNUSED,
+                 XEvent * event GCC_UNUSED,
+                 Boolean * cont GCC_UNUSED)
+{
+    /* NOP since we handled it above */
+    TRACE(("HandleLeaveWindow ignored\n"));
+    TRACE_FOCUS(w, event);
+}
+
+/*ARGSUSED*/
+void
+HandleFocusChange(Widget w GCC_UNUSED,
+                 XtPointer eventdata GCC_UNUSED,
+                 XEvent * ev,
+                 Boolean * cont GCC_UNUSED)
+{
+    XFocusChangeEvent *event = (XFocusChangeEvent *) ev;
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("HandleFocusChange type=%s, mode=%d, detail=%d\n",
+          visibleEventType(event->type),
+          event->mode,
+          event->detail));
+    TRACE_FOCUS(xw, event);
+
+    if (screen->quiet_grab
+       && (event->mode == NotifyGrab || event->mode == NotifyUngrab)) {
+       /* EMPTY */ ;
+    } else if (event->type == FocusIn) {
+       setXUrgency(xw, False);
+
+       /*
+        * NotifyNonlinear only happens (on FocusIn) if the pointer was not in
+        * one of our windows.  Use this to reset a case where one xterm is
+        * partly obscuring another, and X gets (us) confused about whether the
+        * pointer was in the window.  In particular, this can happen if the
+        * user is resizing the obscuring window, causing some events to not be
+        * delivered to the obscured window.
+        */
+       if (event->detail == NotifyNonlinear
+           && (screen->select & INWINDOW) != 0) {
+           unselectwindow(screen, INWINDOW);
+       }
+       selectwindow(screen,
+                    ((event->detail == NotifyPointer)
+                     ? INWINDOW
+                     : FOCUS));
+       SendFocusButton(xw, event);
+    } else {
+#if OPT_FOCUS_EVENT
+       if (event->type == FocusOut) {
+           SendFocusButton(xw, event);
+       }
+#endif
+       /*
+        * XGrabKeyboard() will generate NotifyGrab event that we want to
+        * ignore.
+        */
+       if (event->mode != NotifyGrab) {
+           unselectwindow(screen,
+                          ((event->detail == NotifyPointer)
+                           ? INWINDOW
+                           : FOCUS));
+       }
+       if (screen->grabbedKbd && (event->mode == NotifyUngrab)) {
+           Bell(xw, XkbBI_Info, 100);
+           ReverseVideo(xw);
+           screen->grabbedKbd = False;
+           update_securekbd();
+       }
+    }
+}
+
+static long lastBellTime;      /* in milliseconds */
+
+#if defined(HAVE_XKB_BELL_EXT)
+static Atom
+AtomBell(XtermWidget xw, int which)
+{
+#define DATA(name) { XkbBI_##name, XkbBN_##name }
+    static struct {
+       int value;
+       const char *name;
+    } table[] = {
+       DATA(Info),
+           DATA(MarginBell),
+           DATA(MinorError),
+           DATA(TerminalBell)
+    };
+    Cardinal n;
+    Atom result = None;
+
+    for (n = 0; n < XtNumber(table); ++n) {
+       if (table[n].value == which) {
+           result = XInternAtom(XtDisplay(xw), table[n].name, False);
+           break;
+       }
+    }
+    return result;
+}
+#endif
+
+void
+xtermBell(XtermWidget xw, int which, int percent)
+{
+    TScreen *screen = TScreenOf(xw);
+#if defined(HAVE_XKB_BELL_EXT)
+    Atom tony = AtomBell(xw, which);
+#endif
+
+    switch (which) {
+    case XkbBI_Info:
+    case XkbBI_MinorError:
+    case XkbBI_MajorError:
+    case XkbBI_TerminalBell:
+       switch (screen->warningVolume) {
+       case bvOff:
+           percent = -100;
+           break;
+       case bvLow:
+           break;
+       case bvHigh:
+           percent = 100;
+           break;
+       }
+       break;
+    case XkbBI_MarginBell:
+       switch (screen->marginVolume) {
+       case bvOff:
+           percent = -100;
+           break;
+       case bvLow:
+           break;
+       case bvHigh:
+           percent = 100;
+           break;
+       }
+       break;
+    default:
+       break;
+    }
+
+#if defined(HAVE_XKB_BELL_EXT)
+    if (tony != None) {
+       XkbBell(screen->display, VShellWindow(xw), percent, tony);
+    } else
+#endif
+       XBell(screen->display, percent);
+}
+
+void
+Bell(XtermWidget xw, int which, int percent)
+{
+    TScreen *screen = TScreenOf(xw);
+    struct timeval curtime;
+    long now_msecs;
+
+    TRACE(("BELL %d %d%%\n", which, percent));
+    if (!XtIsRealized((Widget) xw)) {
+       return;
+    }
+
+    setXUrgency(xw, True);
+
+    /* has enough time gone by that we are allowed to ring
+       the bell again? */
+    if (screen->bellSuppressTime) {
+       if (screen->bellInProgress) {
+           do_xevents();
+           if (screen->bellInProgress) {       /* even after new events? */
+               return;
+           }
+       }
+       X_GETTIMEOFDAY(&curtime);
+       now_msecs = 1000 * curtime.tv_sec + curtime.tv_usec / 1000;
+       if (lastBellTime != 0 && now_msecs - lastBellTime >= 0 &&
+           now_msecs - lastBellTime < screen->bellSuppressTime) {
+           return;
+       }
+       lastBellTime = now_msecs;
+    }
+
+    if (screen->visualbell) {
+       VisualBell();
+    } else {
+       xtermBell(xw, which, percent);
+    }
+
+    if (screen->poponbell)
+       XRaiseWindow(screen->display, VShellWindow(xw));
+
+    if (screen->bellSuppressTime) {
+       /* now we change a property and wait for the notify event to come
+          back.  If the server is suspending operations while the bell
+          is being emitted (problematic for audio bell), this lets us
+          know when the previous bell has finished */
+       Widget w = CURRENT_EMU();
+       XChangeProperty(XtDisplay(w), XtWindow(w),
+                       XA_NOTICE, XA_NOTICE, 8, PropModeAppend, NULL, 0);
+       screen->bellInProgress = True;
+    }
+}
+
+#define VB_DELAY screen->visualBellDelay
+
+static void
+flashWindow(TScreen * screen, Window window, GC visualGC, unsigned width, unsigned height)
+{
+    XFillRectangle(screen->display, window, visualGC, 0, 0, width, height);
+    XFlush(screen->display);
+    Sleep(VB_DELAY);
+    XFillRectangle(screen->display, window, visualGC, 0, 0, width, height);
+}
+
+void
+VisualBell(void)
+{
+    TScreen *screen = TScreenOf(term);
+
+    if (VB_DELAY > 0) {
+       Pixel xorPixel = (T_COLOR(screen, TEXT_FG) ^
+                         T_COLOR(screen, TEXT_BG));
+       XGCValues gcval;
+       GC visualGC;
+
+       gcval.function = GXxor;
+       gcval.foreground = xorPixel;
+       visualGC = XtGetGC((Widget) term, GCFunction + GCForeground, &gcval);
+#if OPT_TEK4014
+       if (TEK4014_ACTIVE(term)) {
+           TekScreen *tekscr = TekScreenOf(tekWidget);
+           flashWindow(screen, TWindow(tekscr), visualGC,
+                       TFullWidth(tekscr),
+                       TFullHeight(tekscr));
+       } else
+#endif
+       {
+           flashWindow(screen, VWindow(screen), visualGC,
+                       FullWidth(screen),
+                       FullHeight(screen));
+       }
+       XtReleaseGC((Widget) term, visualGC);
+    }
+}
+
+/* ARGSUSED */
+void
+HandleBellPropertyChange(Widget w GCC_UNUSED,
+                        XtPointer data GCC_UNUSED,
+                        XEvent * ev,
+                        Boolean * more GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(term);
+
+    if (ev->xproperty.atom == XA_NOTICE) {
+       screen->bellInProgress = False;
+    }
+}
+
+Window
+WMFrameWindow(XtermWidget xw)
+{
+    Window win_root, win_current, *children;
+    Window win_parent = 0;
+    unsigned int nchildren;
+
+    win_current = XtWindow(xw);
+
+    /* find the parent which is child of root */
+    do {
+       if (win_parent)
+           win_current = win_parent;
+       XQueryTree(TScreenOf(xw)->display,
+                  win_current,
+                  &win_root,
+                  &win_parent,
+                  &children,
+                  &nchildren);
+       XFree(children);
+    } while (win_root != win_parent);
+
+    return win_current;
+}
+
+#if OPT_DABBREV
+/*
+ * The following code implements `dynamic abbreviation' expansion a la
+ * Emacs.  It looks in the preceding visible screen and its scrollback
+ * to find expansions of a typed word.  It compares consecutive
+ * expansions and ignores one of them if they are identical.
+ * (Tomasz J. Cholewo, t.cholewo@ieee.org)
+ */
+
+#define IS_WORD_CONSTITUENT(x) ((x) != ' ' && (x) != '\0')
+#define MAXWLEN 1024           /* maximum word length as in tcsh */
+
+static int
+dabbrev_prev_char(TScreen * screen, CELL * cell, LineData ** ld)
+{
+    int result = -1;
+    int firstLine = -(screen->savedlines);
+
+    *ld = getLineData(screen, cell->row);
+    while (cell->row >= firstLine) {
+       if (--(cell->col) >= 0) {
+           result = (int) (*ld)->charData[cell->col];
+           break;
+       }
+       if (--(cell->row) < firstLine)
+           break;              /* ...there is no previous line */
+       *ld = getLineData(screen, cell->row);
+       cell->col = MaxCols(screen);
+       if (!LineTstWrapped(*ld)) {
+           result = ' ';       /* treat lines as separate */
+           break;
+       }
+    }
+    return result;
+}
+
+static char *
+dabbrev_prev_word(TScreen * screen, CELL * cell, LineData ** ld)
+{
+    static char ab[MAXWLEN];
+
+    char *abword;
+    int c;
+    char *ab_end = (ab + MAXWLEN - 1);
+    char *result = 0;
+
+    abword = ab_end;
+    *abword = '\0';            /* end of string marker */
+
+    while ((c = dabbrev_prev_char(screen, cell, ld)) >= 0 &&
+          IS_WORD_CONSTITUENT(c)) {
+       if (abword > ab)        /* store only |MAXWLEN| last chars */
+           *(--abword) = (char) c;
+    }
+
+    if (c >= 0) {
+       result = abword;
+    } else if (abword != ab_end) {
+       result = abword;
+    }
+
+    if (result != 0) {
+       while ((c = dabbrev_prev_char(screen, cell, ld)) >= 0 &&
+              !IS_WORD_CONSTITUENT(c)) {
+           ;                   /* skip preceding spaces */
+       }
+       (cell->col)++;          /* can be | > screen->max_col| */
+    }
+    return result;
+}
+
+static int
+dabbrev_expand(TScreen * screen)
+{
+    int pty = screen->respond; /* file descriptor of pty */
+
+    static CELL cell;
+    static char *dabbrev_hint = 0, *lastexpansion = 0;
+    static unsigned int expansions;
+
+    char *expansion;
+    Char *copybuffer;
+    size_t hint_len;
+    size_t del_cnt;
+    size_t buf_cnt;
+    int result = 0;
+    LineData *ld;
+
+    if (!screen->dabbrev_working) {    /* initialize */
+       expansions = 0;
+       cell.col = screen->cur_col;
+       cell.row = screen->cur_row;
+
+       if (dabbrev_hint != 0)
+           free(dabbrev_hint);
+
+       if ((dabbrev_hint = dabbrev_prev_word(screen, &cell, &ld)) != 0) {
+
+           if (lastexpansion != 0)
+               free(lastexpansion);
+
+           if ((lastexpansion = strdup(dabbrev_hint)) != 0) {
+
+               /* make own copy */
+               if ((dabbrev_hint = strdup(dabbrev_hint)) != 0) {
+                   screen->dabbrev_working = True;
+                   /* we are in the middle of dabbrev process */
+               }
+           } else {
+               return result;
+           }
+       } else {
+           return result;
+       }
+       if (!screen->dabbrev_working) {
+           if (lastexpansion != 0) {
+               free(lastexpansion);
+               lastexpansion = 0;
+           }
+           return result;
+       }
+    }
+
+    if (dabbrev_hint == 0)
+       return result;
+
+    hint_len = strlen(dabbrev_hint);
+    for (;;) {
+       if ((expansion = dabbrev_prev_word(screen, &cell, &ld)) == 0) {
+           if (expansions >= 2) {
+               expansions = 0;
+               cell.col = screen->cur_col;
+               cell.row = screen->cur_row;
+               continue;
+           }
+           break;
+       }
+       if (!strncmp(dabbrev_hint, expansion, hint_len) &&      /* empty hint matches everything */
+           strlen(expansion) > hint_len &&     /* trivial expansion disallowed */
+           strcmp(expansion, lastexpansion))   /* different from previous */
+           break;
+    }
+
+    if (expansion != 0) {
+       del_cnt = strlen(lastexpansion) - hint_len;
+       buf_cnt = del_cnt + strlen(expansion) - hint_len;
+
+       if ((copybuffer = TypeMallocN(Char, buf_cnt)) != 0) {
+           /* delete previous expansion */
+           memset(copybuffer, screen->dabbrev_erase_char, del_cnt);
+           memmove(copybuffer + del_cnt,
+                   expansion + hint_len,
+                   strlen(expansion) - hint_len);
+           v_write(pty, copybuffer, (unsigned) buf_cnt);
+           /* v_write() just reset our flag */
+           screen->dabbrev_working = True;
+           free(copybuffer);
+
+           free(lastexpansion);
+
+           if ((lastexpansion = strdup(expansion)) != 0) {
+               result = 1;
+               expansions++;
+           }
+       }
+    }
+
+    return result;
+}
+
+/*ARGSUSED*/
+void
+HandleDabbrevExpand(Widget w,
+                   XEvent * event GCC_UNUSED,
+                   String * params GCC_UNUSED,
+                   Cardinal *nparams GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    TRACE(("Handle dabbrev-expand for %p\n", (void *) w));
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       if (!dabbrev_expand(screen))
+           Bell(xw, XkbBI_TerminalBell, 0);
+    }
+}
+#endif /* OPT_DABBREV */
+
+#if OPT_MAXIMIZE
+/*ARGSUSED*/
+void
+HandleDeIconify(Widget w,
+               XEvent * event GCC_UNUSED,
+               String * params GCC_UNUSED,
+               Cardinal *nparams GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       XMapWindow(screen->display, VShellWindow(xw));
+    }
+}
+
+/*ARGSUSED*/
+void
+HandleIconify(Widget w,
+             XEvent * event GCC_UNUSED,
+             String * params GCC_UNUSED,
+             Cardinal *nparams GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       XIconifyWindow(screen->display,
+                      VShellWindow(xw),
+                      DefaultScreen(screen->display));
+    }
+}
+
+int
+QueryMaximize(XtermWidget xw, unsigned *width, unsigned *height)
+{
+    TScreen *screen = TScreenOf(xw);
+    XSizeHints hints;
+    long supp = 0;
+    Window root_win;
+    int root_x = -1;           /* saved co-ordinates */
+    int root_y = -1;
+    unsigned root_border;
+    unsigned root_depth;
+
+    if (XGetGeometry(screen->display,
+                    RootWindowOfScreen(XtScreen(xw)),
+                    &root_win,
+                    &root_x,
+                    &root_y,
+                    width,
+                    height,
+                    &root_border,
+                    &root_depth)) {
+       TRACE(("QueryMaximize: XGetGeometry position %d,%d size %d,%d border %d\n",
+              root_x,
+              root_y,
+              *width,
+              *height,
+              root_border));
+
+       *width -= (root_border * 2);
+       *height -= (root_border * 2);
+
+       hints.flags = PMaxSize;
+       if (XGetWMNormalHints(screen->display,
+                             VShellWindow(xw),
+                             &hints,
+                             &supp)
+           && (hints.flags & PMaxSize) != 0) {
+
+           TRACE(("QueryMaximize: WM hints max_w %#x max_h %#x\n",
+                  hints.max_width,
+                  hints.max_height));
+
+           if ((unsigned) hints.max_width < *width)
+               *width = (unsigned) hints.max_width;
+           if ((unsigned) hints.max_height < *height)
+               *height = (unsigned) hints.max_height;
+       }
+       return 1;
+    }
+    return 0;
+}
+
+void
+RequestMaximize(XtermWidget xw, int maximize)
+{
+    TScreen *screen = TScreenOf(xw);
+    XWindowAttributes wm_attrs, vshell_attrs;
+    unsigned root_width, root_height;
+
+    TRACE(("RequestMaximize %s\n", maximize ? "maximize" : "restore"));
+
+    if (maximize) {
+
+       if (QueryMaximize(xw, &root_width, &root_height)) {
+
+           if (XGetWindowAttributes(screen->display,
+                                    WMFrameWindow(xw),
+                                    &wm_attrs)) {
+
+               if (XGetWindowAttributes(screen->display,
+                                        VShellWindow(xw),
+                                        &vshell_attrs)) {
+
+                   if (screen->restore_data != True
+                       || screen->restore_width != root_width
+                       || screen->restore_height != root_height) {
+                       screen->restore_data = True;
+                       screen->restore_x = wm_attrs.x + wm_attrs.border_width;
+                       screen->restore_y = wm_attrs.y + wm_attrs.border_width;
+                       screen->restore_width = (unsigned) vshell_attrs.width;
+                       screen->restore_height = (unsigned) vshell_attrs.height;
+                       TRACE(("HandleMaximize: save window position %d,%d size %d,%d\n",
+                              screen->restore_x,
+                              screen->restore_y,
+                              screen->restore_width,
+                              screen->restore_height));
+                   }
+
+                   /* subtract wm decoration dimensions */
+                   root_width -=
+                       (unsigned) ((wm_attrs.width - vshell_attrs.width)
+                                   + (wm_attrs.border_width * 2));
+                   root_height -=
+                       (unsigned) ((wm_attrs.height - vshell_attrs.height)
+                                   + (wm_attrs.border_width * 2));
+
+                   XMoveResizeWindow(screen->display, VShellWindow(xw),
+                                     0 + wm_attrs.border_width,        /* x */
+                                     0 + wm_attrs.border_width,        /* y */
+                                     root_width,
+                                     root_height);
+               }
+           }
+       }
+    } else {
+       if (screen->restore_data) {
+           TRACE(("HandleRestoreSize: position %d,%d size %d,%d\n",
+                  screen->restore_x,
+                  screen->restore_y,
+                  screen->restore_width,
+                  screen->restore_height));
+           screen->restore_data = False;
+
+           XMoveResizeWindow(screen->display,
+                             VShellWindow(xw),
+                             screen->restore_x,
+                             screen->restore_y,
+                             screen->restore_width,
+                             screen->restore_height);
+       }
+    }
+}
+
+/*ARGSUSED*/
+void
+HandleMaximize(Widget w,
+              XEvent * event GCC_UNUSED,
+              String * params GCC_UNUSED,
+              Cardinal *nparams GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       RequestMaximize(xw, 1);
+    }
+}
+
+/*ARGSUSED*/
+void
+HandleRestoreSize(Widget w,
+                 XEvent * event GCC_UNUSED,
+                 String * params GCC_UNUSED,
+                 Cardinal *nparams GCC_UNUSED)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       RequestMaximize(xw, 0);
+    }
+}
+#endif /* OPT_MAXIMIZE */
+
+void
+Redraw(void)
+{
+    TScreen *screen = TScreenOf(term);
+    XExposeEvent event;
+
+    TRACE(("Redraw\n"));
+
+    event.type = Expose;
+    event.display = screen->display;
+    event.x = 0;
+    event.y = 0;
+    event.count = 0;
+
+    if (VWindow(screen)) {
+       event.window = VWindow(screen);
+       event.width = term->core.width;
+       event.height = term->core.height;
+       (*term->core.widget_class->core_class.expose) ((Widget) term,
+                                                      (XEvent *) & event,
+                                                      NULL);
+       if (ScrollbarWidth(screen)) {
+           (screen->scrollWidget->core.widget_class->core_class.expose)
+               (screen->scrollWidget, (XEvent *) & event, NULL);
+       }
+    }
+#if OPT_TEK4014
+    if (TEK4014_SHOWN(term)) {
+       TekScreen *tekscr = TekScreenOf(tekWidget);
+       event.window = TWindow(tekscr);
+       event.width = tekWidget->core.width;
+       event.height = tekWidget->core.height;
+       TekExpose((Widget) tekWidget, (XEvent *) & event, NULL);
+    }
+#endif
+}
+
+#ifdef VMS
+#define TIMESTAMP_FMT "%s%d-%02d-%02d-%02d-%02d-%02d"
+#else
+#define TIMESTAMP_FMT "%s%d-%02d-%02d.%02d:%02d:%02d"
+#endif
+
+void
+timestamp_filename(char *dst, const char *src)
+{
+    time_t tstamp;
+    struct tm *tstruct;
+
+    tstamp = time((time_t *) 0);
+    tstruct = localtime(&tstamp);
+    sprintf(dst, TIMESTAMP_FMT,
+           src,
+           tstruct->tm_year + 1900,
+           tstruct->tm_mon + 1,
+           tstruct->tm_mday,
+           tstruct->tm_hour,
+           tstruct->tm_min,
+           tstruct->tm_sec);
+}
+
+int
+open_userfile(uid_t uid, gid_t gid, char *path, Bool append)
+{
+    int fd;
+    struct stat sb;
+
+#ifdef VMS
+    if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) {
+       int the_error = errno;
+       fprintf(stderr, "%s: cannot open %s: %d:%s\n",
+               xterm_name,
+               path,
+               the_error,
+               SysErrorMsg(the_error));
+       return -1;
+    }
+    chown(path, uid, gid);
+#else
+    if ((access(path, F_OK) != 0 && (errno != ENOENT))
+       || (creat_as(uid, gid, append, path, 0644) <= 0)
+       || ((fd = open(path, O_WRONLY | O_APPEND)) < 0)) {
+       int the_error = errno;
+       fprintf(stderr, "%s: cannot open %s: %d:%s\n",
+               xterm_name,
+               path,
+               the_error,
+               SysErrorMsg(the_error));
+       return -1;
+    }
+#endif
+
+    /*
+     * Doublecheck that the user really owns the file that we've opened before
+     * we do any damage, and that it is not world-writable.
+     */
+    if (fstat(fd, &sb) < 0
+       || sb.st_uid != uid
+       || (sb.st_mode & 022) != 0) {
+       fprintf(stderr, "%s: you do not own %s\n", xterm_name, path);
+       close(fd);
+       return -1;
+    }
+    return fd;
+}
+
+#ifndef VMS
+/*
+ * Create a file only if we could with the permissions of the real user id.
+ * We could emulate this with careful use of access() and following
+ * symbolic links, but that is messy and has race conditions.
+ * Forking is messy, too, but we can't count on setreuid() or saved set-uids
+ * being available.
+ *
+ * Note: When called for user logging, we have ensured that the real and
+ * effective user ids are the same, so this remains as a convenience function
+ * for the debug logs.
+ *
+ * Returns
+ *      1 if we can proceed to open the file in relative safety,
+ *     -1 on error, e.g., cannot fork
+ *      0 otherwise.
+ */
+int
+creat_as(uid_t uid, gid_t gid, Bool append, char *pathname, int mode)
+{
+    int fd;
+    pid_t pid;
+    int retval = 0;
+    int childstat = 0;
+#ifndef HAVE_WAITPID
+    int waited;
+    SIGNAL_T(*chldfunc) (int);
+
+    chldfunc = signal(SIGCHLD, SIG_DFL);
+#endif /* HAVE_WAITPID */
+
+    TRACE(("creat_as(uid=%d/%d, gid=%d/%d, append=%d, pathname=%s, mode=%#o)\n",
+          (int) uid, (int) geteuid(),
+          (int) gid, (int) getegid(),
+          append,
+          pathname,
+          mode));
+
+    if (uid == geteuid() && gid == getegid()) {
+       fd = open(pathname,
+                 O_WRONLY | O_CREAT | (append ? O_APPEND : O_EXCL),
+                 mode);
+       if (fd >= 0)
+           close(fd);
+       return (fd >= 0);
+    }
+
+    pid = fork();
+    switch (pid) {
+    case 0:                    /* child */
+       if (setgid(gid) == -1
+           || setuid(uid) == -1) {
+           /* we cannot report an error here via stderr, just quit */
+           retval = 1;
+       } else {
+           fd = open(pathname,
+                     O_WRONLY | O_CREAT | (append ? O_APPEND : O_EXCL),
+                     mode);
+           if (fd >= 0) {
+               close(fd);
+               retval = 0;
+           } else {
+               retval = 1;
+           }
+       }
+       _exit(retval);
+       /* NOTREACHED */
+    case -1:                   /* error */
+       return retval;
+    default:                   /* parent */
+#ifdef HAVE_WAITPID
+       while (waitpid(pid, &childstat, 0) < 0) {
+#ifdef EINTR
+           if (errno == EINTR)
+               continue;
+#endif /* EINTR */
+#ifdef ERESTARTSYS
+           if (errno == ERESTARTSYS)
+               continue;
+#endif /* ERESTARTSYS */
+           break;
+       }
+#else /* HAVE_WAITPID */
+       waited = wait(&childstat);
+       signal(SIGCHLD, chldfunc);
+       /*
+          Since we had the signal handler uninstalled for a while,
+          we might have missed the termination of our screen child.
+          If we can check for this possibility without hanging, do so.
+        */
+       do
+           if (waited == TScreenOf(term)->pid)
+               Cleanup(0);
+       while ((waited = nonblocking_wait()) > 0) ;
+#endif /* HAVE_WAITPID */
+#ifndef WIFEXITED
+#define WIFEXITED(status) ((status & 0xff) != 0)
+#endif
+       if (WIFEXITED(childstat))
+           retval = 1;
+       return retval;
+    }
+}
+#endif /* !VMS */
+
+int
+xtermResetIds(TScreen * screen)
+{
+    int result = 0;
+    if (setgid(screen->gid) == -1) {
+       fprintf(stderr, "%s: unable to reset group-id\n", ProgramName);
+       result = -1;
+    }
+    if (setuid(screen->uid) == -1) {
+       fprintf(stderr, "%s: unable to reset user-id\n", ProgramName);
+       result = -1;
+    }
+    return result;
+}
+
+#ifdef ALLOWLOGGING
+
+/*
+ * Logging is a security hole, since it allows a setuid program to write
+ * arbitrary data to an arbitrary file.  So it is disabled by default.
+ */
+
+#ifdef ALLOWLOGFILEEXEC
+static SIGNAL_T
+logpipe(int sig GCC_UNUSED)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+#ifdef SYSV
+    (void) signal(SIGPIPE, SIG_IGN);
+#endif /* SYSV */
+    if (screen->logging)
+       CloseLog(xw);
+}
+#endif /* ALLOWLOGFILEEXEC */
+
+void
+StartLog(XtermWidget xw)
+{
+    static char *log_default;
+#ifdef ALLOWLOGFILEEXEC
+    char *cp;
+#endif /* ALLOWLOGFILEEXEC */
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->logging || (screen->inhibit & I_LOG))
+       return;
+#ifdef VMS                     /* file name is fixed in VMS variant */
+    screen->logfd = open(XTERM_VMS_LOGFILE,
+                        O_CREAT | O_TRUNC | O_APPEND | O_RDWR,
+                        0640);
+    if (screen->logfd < 0)
+       return;                 /* open failed */
+#else /*VMS */
+    if (screen->logfile == NULL || *screen->logfile == 0) {
+       if (screen->logfile)
+           free(screen->logfile);
+       if (log_default == NULL) {
+#if defined(HAVE_GETHOSTNAME) && defined(HAVE_STRFTIME)
+           char log_def_name[512];     /* see sprintf below */
+           char hostname[255 + 1];     /* Internet standard limit (RFC 1035):
+                                          ``To simplify implementations, the
+                                          total length of a domain name (i.e.,
+                                          label octets and label length
+                                          octets) is restricted to 255 octets
+                                          or less.'' */
+           char yyyy_mm_dd_hh_mm_ss[4 + 5 * (1 + 2) + 1];
+           time_t now;
+           struct tm *ltm;
+
+           now = time((time_t *) 0);
+           ltm = (struct tm *) localtime(&now);
+           if ((gethostname(hostname, sizeof(hostname)) == 0) &&
+               (strftime(yyyy_mm_dd_hh_mm_ss,
+                         sizeof(yyyy_mm_dd_hh_mm_ss),
+                         "%Y.%m.%d.%H.%M.%S", ltm) > 0)) {
+               (void) sprintf(log_def_name, "Xterm.log.%.255s.%.20s.%d",
+                              hostname, yyyy_mm_dd_hh_mm_ss, (int) getpid());
+           }
+           if ((log_default = x_strdup(log_def_name)) == NULL)
+               return;
+#else
+           const char *log_def_name = "XtermLog.XXXXXX";
+           if ((log_default = x_strdup(log_def_name)) == NULL)
+               return;
+
+           mktemp(log_default);
+#endif
+       }
+       if ((screen->logfile = x_strdup(log_default)) == 0)
+           return;
+    }
+    if (*screen->logfile == '|') {     /* exec command */
+#ifdef ALLOWLOGFILEEXEC
+       /*
+        * Warning, enabling this "feature" allows arbitrary programs
+        * to be run.  If ALLOWLOGFILECHANGES is enabled, this can be
+        * done through escape sequences....  You have been warned.
+        */
+       int pid;
+       int p[2];
+       static char *shell;
+       struct passwd *pw;
+
+       if (pipe(p) < 0 || (pid = fork()) < 0)
+           return;
+       if (pid == 0) {         /* child */
+           /*
+            * Close our output (we won't be talking back to the
+            * parent), and redirect our child's output to the
+            * original stderr.
+            */
+           close(p[1]);
+           dup2(p[0], 0);
+           close(p[0]);
+           dup2(fileno(stderr), 1);
+           dup2(fileno(stderr), 2);
+
+           close(fileno(stderr));
+           close(ConnectionNumber(screen->display));
+           close(screen->respond);
+
+           if ((((cp = x_getenv("SHELL")) == NULL)
+                && ((pw = getpwuid(screen->uid)) == NULL
+                    || *(cp = pw->pw_shell) == 0))
+               || (shell = CastMallocN(char, strlen(cp))) == 0) {
+               static char dummy[] = "/bin/sh";
+               shell = dummy;
+           } else {
+               strcpy(shell, cp);
+           }
+
+           signal(SIGHUP, SIG_DFL);
+           signal(SIGCHLD, SIG_DFL);
+
+           /* (this is redundant) */
+           if (xtermResetIds(screen) < 0)
+               exit(ERROR_SETUID);
+
+           execl(shell, shell, "-c", &screen->logfile[1], (void *) 0);
+
+           fprintf(stderr, "%s: Can't exec `%s'\n", xterm_name,
+                   &screen->logfile[1]);
+           exit(ERROR_LOGEXEC);
+       }
+       close(p[0]);
+       screen->logfd = p[1];
+       signal(SIGPIPE, logpipe);
+#else
+       Bell(xw, XkbBI_Info, 0);
+       Bell(xw, XkbBI_Info, 0);
+       return;
+#endif
+    } else {
+       if ((screen->logfd = open_userfile(screen->uid,
+                                          screen->gid,
+                                          screen->logfile,
+                                          (log_default != 0))) < 0)
+           return;
+    }
+#endif /*VMS */
+    screen->logstart = VTbuffer->next;
+    screen->logging = True;
+    update_logging();
+}
+
+void
+CloseLog(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (!screen->logging || (screen->inhibit & I_LOG))
+       return;
+    FlushLog(xw);
+    close(screen->logfd);
+    screen->logging = False;
+    update_logging();
+}
+
+void
+FlushLog(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->logging && !(screen->inhibit & I_LOG)) {
+       Char *cp;
+       int i;
+
+#ifdef VMS                     /* avoid logging output loops which otherwise occur sometimes
+                                  when there is no output and cp/screen->logstart are 1 apart */
+       if (!tt_new_output)
+           return;
+       tt_new_output = False;
+#endif /* VMS */
+       cp = VTbuffer->next;
+       if (screen->logstart != 0
+           && (i = (int) (cp - screen->logstart)) > 0) {
+           IGNORE_RC(write(screen->logfd, screen->logstart, (size_t) i));
+       }
+       screen->logstart = VTbuffer->next;
+    }
+}
+
+#endif /* ALLOWLOGGING */
+
+/***====================================================================***/
+
+#if OPT_ISO_COLORS
+static void
+ReportAnsiColorRequest(XtermWidget xw, int colornum, int final)
+{
+    if (AllowColorOps(xw, ecGetAnsiColor)) {
+       XColor color;
+       Colormap cmap = xw->core.colormap;
+       char buffer[80];
+
+       TRACE(("ReportAnsiColorRequest %d\n", colornum));
+       color.pixel = GET_COLOR_RES(xw, TScreenOf(xw)->Acolors[colornum]);
+       XQueryColor(TScreenOf(xw)->display, cmap, &color);
+       sprintf(buffer, "4;%d;rgb:%04x/%04x/%04x",
+               colornum,
+               color.red,
+               color.green,
+               color.blue);
+       unparseputc1(xw, ANSI_OSC);
+       unparseputs(xw, buffer);
+       unparseputc1(xw, final);
+       unparse_end(xw);
+    }
+}
+
+static unsigned
+getColormapSize(Display * display)
+{
+    unsigned result;
+    int numFound;
+    XVisualInfo myTemplate, *visInfoPtr;
+
+    myTemplate.visualid = XVisualIDFromVisual(DefaultVisual(display,
+                                                           XDefaultScreen(display)));
+    visInfoPtr = XGetVisualInfo(display, (long) VisualIDMask,
+                               &myTemplate, &numFound);
+    result = (numFound >= 1) ? (unsigned) visInfoPtr->colormap_size : 0;
+
+    XFree((char *) visInfoPtr);
+    return result;
+}
+
+/*
+ * Find closest color for "def" in "cmap".
+ * Set "def" to the resulting color.
+ *
+ * Based on Monish Shah's "find_closest_color()" for Vim 6.0,
+ * modified with ideas from David Tong's "noflash" library.
+ * The code from Vim in turn was derived from FindClosestColor() in Tcl/Tk.
+ *
+ * These provide some introduction:
+ *     http://en.wikipedia.org/wiki/YIQ
+ *             for an introduction to YIQ weights.
+ *     http://en.wikipedia.org/wiki/Luminance_(video)
+ *             for a discussion of luma.
+ *     http://en.wikipedia.org/wiki/YUV
+ *
+ * Return False if not able to find or allocate a color.
+ */
+static Boolean
+find_closest_color(Display * dpy, Colormap cmap, XColor * def)
+{
+    Boolean result = False;
+    XColor *colortable;
+    char *tried;
+    double diff, thisRGB, bestRGB;
+    unsigned attempts;
+    unsigned bestInx;
+    unsigned cmap_size;
+    unsigned i;
+
+    cmap_size = getColormapSize(dpy);
+    if (cmap_size != 0) {
+
+       colortable = TypeMallocN(XColor, (size_t) cmap_size);
+       if (colortable != 0) {
+
+           tried = TypeCallocN(char, (size_t) cmap_size);
+           if (tried != 0) {
+
+               for (i = 0; i < cmap_size; i++) {
+                   colortable[i].pixel = (unsigned long) i;
+               }
+               XQueryColors(dpy, cmap, colortable, (int) cmap_size);
+
+               /*
+                * Try (possibly each entry in the color map) to find the best
+                * approximation to the requested color.
+                */
+               for (attempts = 0; attempts < cmap_size; attempts++) {
+                   Boolean first = True;
+
+                   bestRGB = 0.0;
+                   bestInx = 0;
+                   for (i = 0; i < cmap_size; i++) {
+                       if (!tried[bestInx]) {
+                           /*
+                            * Look for the best match based on luminance.
+                            * Measure this by the least-squares difference of
+                            * the weighted R/G/B components from the color map
+                            * versus the requested color.  Use the Y (luma)
+                            * component of the YIQ color space model for
+                            * weights that correspond to the luminance.
+                            */
+#define AddColorWeight(weight, color) \
+                           diff = weight * (int) ((def->color) - colortable[i].color); \
+                           thisRGB = diff * diff
+
+                           AddColorWeight(0.30, red);
+                           AddColorWeight(0.61, green);
+                           AddColorWeight(0.11, blue);
+
+                           if (first || (thisRGB < bestRGB)) {
+                               first = False;
+                               bestInx = i;
+                               bestRGB = thisRGB;
+                           }
+                       }
+                   }
+                   if (XAllocColor(dpy, cmap, &colortable[bestInx]) != 0) {
+                       *def = colortable[bestInx];
+                       result = True;
+                       break;
+                   }
+                   /*
+                    * It failed - either the color map entry was readonly, or
+                    * another client has allocated the entry.  Mark the entry
+                    * so we will ignore it
+                    */
+                   tried[bestInx] = True;
+               }
+               free(tried);
+           }
+           free(colortable);
+       }
+    }
+    return result;
+}
+
+/*
+ * Allocate a color for the "ANSI" colors.  That actually includes colors up
+ * to 256.
+ *
+ * Returns
+ *     -1 on error
+ *     0 on no change
+ *     1 if a new color was allocated.
+ */
+static int
+AllocateAnsiColor(XtermWidget xw,
+                 ColorRes * res,
+                 const char *spec)
+{
+    int result;
+    XColor def;
+    TScreen *screen = TScreenOf(xw);
+    Colormap cmap = xw->core.colormap;
+
+    if (XParseColor(screen->display, cmap, spec, &def)
+       && (XAllocColor(screen->display, cmap, &def)
+           || find_closest_color(screen->display, cmap, &def))) {
+       if (
+#if OPT_COLOR_RES
+              res->mode == True &&
+#endif
+              EQL_COLOR_RES(res, def.pixel)) {
+           result = 0;
+       } else {
+           result = 1;
+           SET_COLOR_RES(res, def.pixel);
+           TRACE(("AllocateAnsiColor[%d] %s (pixel %#lx)\n",
+                  (int) (res - screen->Acolors), spec, def.pixel));
+#if OPT_COLOR_RES
+           if (!res->mode)
+               result = 0;
+           res->mode = True;
+#endif
+       }
+    } else {
+       TRACE(("AllocateAnsiColor %s (failed)\n", spec));
+       result = -1;
+    }
+    return (result);
+}
+
+#if OPT_COLOR_RES
+Pixel
+xtermGetColorRes(XtermWidget xw, ColorRes * res)
+{
+    Pixel result = 0;
+
+    if (res->mode) {
+       result = res->value;
+    } else {
+       TRACE(("xtermGetColorRes for Acolors[%d]\n",
+              (int) (res - TScreenOf(xw)->Acolors)));
+
+       if (res >= TScreenOf(xw)->Acolors) {
+           assert(res - TScreenOf(xw)->Acolors < MAXCOLORS);
+
+           if (AllocateAnsiColor(xw, res, res->resource) < 0) {
+               res->value = TScreenOf(xw)->Tcolors[TEXT_FG].value;
+               res->mode = -True;
+               fprintf(stderr,
+                       "%s: Cannot allocate color \"%s\"\n",
+                       xterm_name,
+                       NonNull(res->resource));
+           }
+           result = res->value;
+       } else {
+           result = 0;
+       }
+    }
+    return result;
+}
+#endif
+
+static int
+ChangeOneAnsiColor(XtermWidget xw, int color, const char *name)
+{
+    int code;
+
+    if (color < 0 || color >= MAXCOLORS) {
+       code = -1;
+    } else {
+       ColorRes *res = &(TScreenOf(xw)->Acolors[color]);
+
+       TRACE(("ChangeAnsiColor for Acolors[%d]\n", color));
+       code = AllocateAnsiColor(xw, res, name);
+    }
+    return code;
+}
+
+/*
+ * Set or query entries in the Acolors[] array by parsing pairs of color/name
+ * values from the given buffer.
+ *
+ * The color can be any legal index into Acolors[], which consists of the
+ * 16/88/256 "ANSI" colors, followed by special color values for the various
+ * colorXX resources.  The indices for the special color values are not
+ * simple to work with, so an alternative is to use the calls which pass in
+ * 'first' set to the beginning of those indices.
+ *
+ * If the name is "?", report to the host the current value for the color.
+ */
+static Bool
+ChangeAnsiColorRequest(XtermWidget xw,
+                      char *buf,
+                      int first,
+                      int final)
+{
+    char *name;
+    int color;
+    int repaint = False;
+    int code;
+    int last = (MAXCOLORS - first);
+
+    TRACE(("ChangeAnsiColorRequest string='%s'\n", buf));
+
+    while (buf && *buf) {
+       name = strchr(buf, ';');
+       if (name == NULL)
+           break;
+       *name = '\0';
+       name++;
+       color = atoi(buf);
+       if (color < 0 || color >= last)
+           break;              /* quit on any error */
+       buf = strchr(name, ';');
+       if (buf) {
+           *buf = '\0';
+           buf++;
+       }
+       if (!strcmp(name, "?")) {
+           ReportAnsiColorRequest(xw, color + first, final);
+       } else {
+           code = ChangeOneAnsiColor(xw, color + first, name);
+           if (code < 0) {
+               /* stop on any error */
+               break;
+           } else if (code > 0) {
+               repaint = True;
+           }
+           /* FIXME:  free old color somehow?  We aren't for the other color
+            * change style (dynamic colors).
+            */
+       }
+    }
+
+    return (repaint);
+}
+
+static Bool
+ResetOneAnsiColor(XtermWidget xw, int color, int start)
+{
+    Bool repaint = False;
+    int last = MAXCOLORS - start;
+
+    if (color >= 0 && color < last) {
+       ColorRes *res = &(TScreenOf(xw)->Acolors[color + start]);
+
+       if (res->mode) {
+           /* a color has been allocated for this slot - test further... */
+           if (ChangeOneAnsiColor(xw, color + start, res->resource) > 0) {
+               repaint = True;
+           }
+       }
+    }
+    return repaint;
+}
+
+int
+ResetAnsiColorRequest(XtermWidget xw, char *buf, int start)
+{
+    int repaint = 0;
+    int color;
+
+    TRACE(("ResetAnsiColorRequest(%s)\n", buf));
+    if (*buf != '\0') {
+       /* reset specific colors */
+       while (!IsEmpty(buf)) {
+           char *next;
+
+           color = (int) strtol(buf, &next, 10);
+           if ((next == buf) || (color < 0))
+               break;          /* no number at all */
+           if (next != 0) {
+               if (strchr(";", *next) == 0)
+                   break;      /* unexpected delimiter */
+               ++next;
+           }
+
+           if (ResetOneAnsiColor(xw, color, start)) {
+               ++repaint;
+           }
+           buf = next;
+       }
+    } else {
+       TRACE(("...resetting all %d colors\n", MAXCOLORS));
+       for (color = 0; color < MAXCOLORS; ++color) {
+           if (ResetOneAnsiColor(xw, color, start)) {
+               ++repaint;
+           }
+       }
+    }
+    TRACE(("...ResetAnsiColorRequest ->%d\n", repaint));
+    return repaint;
+}
+#else
+#define find_closest_color(display, cmap, def) 0
+#endif /* OPT_ISO_COLORS */
+
+#if OPT_PASTE64
+static void
+ManipulateSelectionData(XtermWidget xw, TScreen * screen, char *buf, int final)
+{
+#define PDATA(a,b) { a, #b }
+    static struct {
+       char given;
+       String result;
+    } table[] = {
+       PDATA('s', SELECT),
+           PDATA('p', PRIMARY),
+           PDATA('c', CLIPBOARD),
+           PDATA('0', CUT_BUFFER0),
+           PDATA('1', CUT_BUFFER1),
+           PDATA('2', CUT_BUFFER2),
+           PDATA('3', CUT_BUFFER3),
+           PDATA('4', CUT_BUFFER4),
+           PDATA('5', CUT_BUFFER5),
+           PDATA('6', CUT_BUFFER6),
+           PDATA('7', CUT_BUFFER7),
+    };
+
+    const char *base = buf;
+    char *used = x_strdup(base);
+    Cardinal j, n = 0;
+    String *select_args = 0;
+
+    TRACE(("Manipulate selection data\n"));
+
+    while (*buf != ';' && *buf != '\0') {
+       ++buf;
+    }
+
+    if (*buf == ';') {
+       *buf++ = '\0';
+
+       if (*base == '\0')
+           base = "s0";
+       if ((select_args = TypeCallocN(String, 1 + strlen(base))) == 0)
+           return;
+       while (*base != '\0') {
+           for (j = 0; j < XtNumber(table); ++j) {
+               if (*base == table[j].given) {
+                   used[n] = *base;
+                   select_args[n++] = table[j].result;
+                   TRACE(("atom[%d] %s\n", n, table[j].result));
+                   break;
+               }
+           }
+           ++base;
+       }
+       used[n] = 0;
+
+       if (!strcmp(buf, "?")) {
+           if (AllowWindowOps(xw, ewGetSelection)) {
+               TRACE(("Getting selection\n"));
+               unparseputc1(xw, ANSI_OSC);
+               unparseputs(xw, "52");
+               unparseputc(xw, ';');
+
+               unparseputs(xw, used);
+               unparseputc(xw, ';');
+
+               /* Tell xtermGetSelection data is base64 encoded */
+               screen->base64_paste = n;
+               screen->base64_final = final;
+
+               /* terminator will be written in this call */
+               xtermGetSelection((Widget) xw, (Time) 0, select_args, n, NULL);
+           }
+       } else {
+           if (AllowWindowOps(xw, ewSetSelection)) {
+               TRACE(("Setting selection with %s\n", buf));
+               ClearSelectionBuffer(screen);
+               while (*buf != '\0')
+                   AppendToSelectionBuffer(screen, CharOf(*buf++));
+               CompleteSelection(xw, select_args, n);
+           }
+       }
+    }
+}
+#endif /* OPT_PASTE64 */
+
+/***====================================================================***/
+
+#define IsSetUtf8Title(xw) (IsTitleMode(xw, tmSetUtf8) || (xw->screen.utf8_title))
+
+static Bool
+xtermIsPrintable(XtermWidget xw, Char ** bufp, Char * last)
+{
+    TScreen *screen = TScreenOf(xw);
+    Bool result = False;
+    Char *cp = *bufp;
+    Char *next = cp;
+
+    (void) screen;
+    (void) last;
+
+#if OPT_WIDE_CHARS
+    if (xtermEnvUTF8() && IsSetUtf8Title(xw)) {
+       PtyData data;
+
+       if (decodeUtf8(fakePtyData(&data, cp, last))) {
+           if (data.utf_data != UCS_REPL
+               && (data.utf_data >= 128 ||
+                   ansi_table[data.utf_data] == CASE_PRINT)) {
+               next += (data.utf_size - 1);
+               result = True;
+           } else {
+               result = False;
+           }
+       } else {
+           result = False;
+       }
+    } else
+#endif
+#if OPT_C1_PRINT
+       if (screen->c1_printable
+           && (*cp >= 128 && *cp < 160)) {
+       result = True;
+    } else
+#endif
+    if (ansi_table[*cp] == CASE_PRINT) {
+       result = True;
+    }
+    *bufp = next;
+    return result;
+}
+
+/***====================================================================***/
+
+/*
+ * Enum corresponding to the actual OSC codes rather than the internal
+ * array indices.  Compare with TermColors.
+ */
+typedef enum {
+    OSC_TEXT_FG = 10
+    ,OSC_TEXT_BG
+    ,OSC_TEXT_CURSOR
+    ,OSC_MOUSE_FG
+    ,OSC_MOUSE_BG
+#if OPT_TEK4014
+    ,OSC_TEK_FG = 15
+    ,OSC_TEK_BG
+#endif
+#if OPT_HIGHLIGHT_COLOR
+    ,OSC_HIGHLIGHT_BG = 17
+#endif
+#if OPT_TEK4014
+    ,OSC_TEK_CURSOR = 18
+#endif
+#if OPT_HIGHLIGHT_COLOR
+    ,OSC_HIGHLIGHT_FG = 19
+#endif
+    ,OSC_NCOLORS
+} OscTextColors;
+
+/*
+ * Map codes to OSC controls that can reset colors.
+ */
+#define OSC_RESET 100
+#define OSC_Reset(code) (code) + OSC_RESET
+
+static ScrnColors *pOldColors = NULL;
+
+static Bool
+GetOldColors(XtermWidget xw)
+{
+    int i;
+    if (pOldColors == NULL) {
+       pOldColors = TypeXtMalloc(ScrnColors);
+       if (pOldColors == NULL) {
+           fprintf(stderr, "allocation failure in GetOldColors\n");
+           return (False);
+       }
+       pOldColors->which = 0;
+       for (i = 0; i < NCOLORS; i++) {
+           pOldColors->colors[i] = 0;
+           pOldColors->names[i] = NULL;
+       }
+       GetColors(xw, pOldColors);
+    }
+    return (True);
+}
+
+static int
+oppositeColor(int n)
+{
+    switch (n) {
+    case TEXT_FG:
+       n = TEXT_BG;
+       break;
+    case TEXT_BG:
+       n = TEXT_FG;
+       break;
+    case MOUSE_FG:
+       n = MOUSE_BG;
+       break;
+    case MOUSE_BG:
+       n = MOUSE_FG;
+       break;
+#if OPT_TEK4014
+    case TEK_FG:
+       n = TEK_BG;
+       break;
+    case TEK_BG:
+       n = TEK_FG;
+       break;
+#endif
+#if OPT_HIGHLIGHT_COLOR
+    case HIGHLIGHT_FG:
+       n = HIGHLIGHT_BG;
+       break;
+    case HIGHLIGHT_BG:
+       n = HIGHLIGHT_FG;
+       break;
+#endif
+    default:
+       break;
+    }
+    return n;
+}
+
+static void
+ReportColorRequest(XtermWidget xw, int ndx, int final)
+{
+    if (AllowColorOps(xw, ecGetColor)) {
+       XColor color;
+       Colormap cmap = xw->core.colormap;
+       char buffer[80];
+
+       /*
+        * ChangeColorsRequest() has "always" chosen the opposite color when
+        * reverse-video is set.  Report this as the original color index, but
+        * reporting the opposite color which would be used.
+        */
+       int i = (xw->misc.re_verse) ? oppositeColor(ndx) : ndx;
+
+       GetOldColors(xw);
+       color.pixel = pOldColors->colors[ndx];
+       XQueryColor(TScreenOf(xw)->display, cmap, &color);
+       sprintf(buffer, "%d;rgb:%04x/%04x/%04x", i + 10,
+               color.red,
+               color.green,
+               color.blue);
+       TRACE(("ReportColors %d: %#lx as %s\n",
+              ndx, pOldColors->colors[ndx], buffer));
+       unparseputc1(xw, ANSI_OSC);
+       unparseputs(xw, buffer);
+       unparseputc1(xw, final);
+       unparse_end(xw);
+    }
+}
+
+static Bool
+UpdateOldColors(XtermWidget xw GCC_UNUSED, ScrnColors * pNew)
+{
+    int i;
+
+    /* if we were going to free old colors, this would be the place to
+     * do it.   I've decided not to (for now), because it seems likely
+     * that we'd have a small set of colors we use over and over, and that
+     * we could save some overhead this way.   The only case in which this
+     * (clearly) fails is if someone is trying a boatload of colors, in
+     * which case they can restart xterm
+     */
+    for (i = 0; i < NCOLORS; i++) {
+       if (COLOR_DEFINED(pNew, i)) {
+           if (pOldColors->names[i] != NULL) {
+               XtFree(pOldColors->names[i]);
+               pOldColors->names[i] = NULL;
+           }
+           if (pNew->names[i]) {
+               pOldColors->names[i] = pNew->names[i];
+           }
+           pOldColors->colors[i] = pNew->colors[i];
+       }
+    }
+    return (True);
+}
+
+/*
+ * OSC codes are constant, but the indices for the color arrays depend on how
+ * xterm is compiled.
+ */
+static int
+OscToColorIndex(OscTextColors mode)
+{
+    int result = 0;
+
+#define CASE(name) case OSC_##name: result = name; break
+    switch (mode) {
+       CASE(TEXT_FG);
+       CASE(TEXT_BG);
+       CASE(TEXT_CURSOR);
+       CASE(MOUSE_FG);
+       CASE(MOUSE_BG);
+#if OPT_TEK4014
+       CASE(TEK_FG);
+       CASE(TEK_BG);
+#endif
+#if OPT_HIGHLIGHT_COLOR
+       CASE(HIGHLIGHT_BG);
+       CASE(HIGHLIGHT_FG);
+#endif
+#if OPT_TEK4014
+       CASE(TEK_CURSOR);
+#endif
+    case OSC_NCOLORS:
+       break;
+    }
+    return result;
+}
+
+static Bool
+ChangeColorsRequest(XtermWidget xw,
+                   int start,
+                   char *names,
+                   int final)
+{
+    Bool result = False;
+    char *thisName;
+    ScrnColors newColors;
+    int i, ndx;
+
+    TRACE(("ChangeColorsRequest start=%d, names='%s'\n", start, names));
+
+    if (GetOldColors(xw)) {
+       newColors.which = 0;
+       for (i = 0; i < NCOLORS; i++) {
+           newColors.names[i] = NULL;
+       }
+       for (i = start; i < OSC_NCOLORS; i++) {
+           ndx = OscToColorIndex((OscTextColors) i);
+           if (xw->misc.re_verse)
+               ndx = oppositeColor(ndx);
+
+           if (IsEmpty(names)) {
+               newColors.names[ndx] = NULL;
+           } else {
+               if (names[0] == ';')
+                   thisName = NULL;
+               else
+                   thisName = names;
+               names = strchr(names, ';');
+               if (names != NULL) {
+                   *names++ = '\0';
+               }
+               if (thisName != 0 && !strcmp(thisName, "?")) {
+                   ReportColorRequest(xw, ndx, final);
+               } else if (!pOldColors->names[ndx]
+                          || (thisName
+                              && strcmp(thisName, pOldColors->names[ndx]))) {
+                   AllocateTermColor(xw, &newColors, ndx, thisName, False);
+               }
+           }
+       }
+
+       if (newColors.which != 0) {
+           ChangeColors(xw, &newColors);
+           UpdateOldColors(xw, &newColors);
+       }
+       result = True;
+    }
+    return result;
+}
+
+static Bool
+ResetColorsRequest(XtermWidget xw,
+                  int code)
+{
+    Bool result = False;
+    const char *thisName;
+    ScrnColors newColors;
+    int ndx;
+
+    TRACE(("ResetColorsRequest code=%d\n", code));
+
+#if OPT_COLOR_RES
+    if (GetOldColors(xw)) {
+       ndx = OscToColorIndex((OscTextColors) (code - OSC_RESET));
+       if (xw->misc.re_verse)
+           ndx = oppositeColor(ndx);
+
+       thisName = xw->screen.Tcolors[ndx].resource;
+
+       newColors.which = 0;
+       newColors.names[ndx] = NULL;
+
+       if (thisName != 0
+           && pOldColors->names[ndx] != 0
+           && strcmp(thisName, pOldColors->names[ndx])) {
+           AllocateTermColor(xw, &newColors, ndx, thisName, False);
+
+           if (newColors.which != 0) {
+               ChangeColors(xw, &newColors);
+               UpdateOldColors(xw, &newColors);
+           }
+       }
+       result = True;
+    }
+#endif
+    return result;
+}
+
+#if OPT_SHIFT_FONTS
+/*
+ * Initially, 'source' points to '#' or '?'.
+ *
+ * Look for an optional sign and optional number.  If those are found, lookup
+ * the corresponding menu font entry.
+ */
+static int
+ParseShiftedFont(XtermWidget xw, String source, String * target)
+{
+    TScreen *screen = TScreenOf(xw);
+    int num = screen->menu_font_number;
+    int rel = 0;
+
+    if (*++source == '+') {
+       rel = 1;
+       source++;
+    } else if (*source == '-') {
+       rel = -1;
+       source++;
+    }
+
+    if (isdigit(CharOf(*source))) {
+       int val = atoi(source);
+       if (rel > 0)
+           rel = val;
+       else if (rel < 0)
+           rel = -val;
+       else
+           num = val;
+    }
+
+    if (rel != 0) {
+       num = lookupRelativeFontSize(xw,
+                                    screen->menu_font_number, rel);
+
+    }
+    TRACE(("ParseShiftedFont(%s) ->%d (%s)\n", *target, num, source));
+    *target = source;
+    return num;
+}
+
+static void
+QueryFontRequest(XtermWidget xw, String buf, int final)
+{
+    if (AllowFontOps(xw, efGetFont)) {
+       TScreen *screen = TScreenOf(xw);
+       Bool success = True;
+       int num;
+       String base = buf + 1;
+       const char *name = 0;
+       char temp[10];
+
+       num = ParseShiftedFont(xw, buf, &buf);
+       if (num < 0
+           || num > fontMenu_lastBuiltin) {
+           Bell(xw, XkbBI_MinorError, 0);
+           success = False;
+       } else {
+#if OPT_RENDERFONT
+           if (UsingRenderFont(xw)) {
+               name = getFaceName(xw, False);
+           } else
+#endif
+           if ((name = screen->MenuFontName(num)) == 0) {
+               success = False;
+           }
+       }
+
+       unparseputc1(xw, ANSI_OSC);
+       unparseputs(xw, "50");
+
+       if (success) {
+           unparseputc(xw, ';');
+           if (buf >= base) {
+               /* identify the font-entry, unless it is the current one */
+               if (*buf != '\0') {
+                   unparseputc(xw, '#');
+                   sprintf(temp, "%d", num);
+                   unparseputs(xw, temp);
+                   if (*name != '\0')
+                       unparseputc(xw, ' ');
+               }
+           }
+           unparseputs(xw, name);
+       }
+
+       unparseputc1(xw, final);
+       unparse_end(xw);
+    }
+}
+
+static void
+ChangeFontRequest(XtermWidget xw, String buf)
+{
+    if (AllowFontOps(xw, efSetFont)) {
+       TScreen *screen = TScreenOf(xw);
+       Bool success = True;
+       int num;
+       VTFontNames fonts;
+       char *name;
+
+       /*
+        * If the font specification is a "#", followed by an optional sign and
+        * optional number, lookup the corresponding menu font entry.
+        *
+        * Further, if the "#", etc., is followed by a font name, use that
+        * to load the font entry.
+        */
+       if (*buf == '#') {
+           num = ParseShiftedFont(xw, buf, &buf);
+
+           if (num < 0
+               || num > fontMenu_lastBuiltin) {
+               Bell(xw, XkbBI_MinorError, 0);
+               success = False;
+           } else {
+               /*
+                * Skip past the optional number, and any whitespace to look
+                * for a font specification within the control.
+                */
+               while (isdigit(CharOf(*buf))) {
+                   ++buf;
+               }
+               while (isspace(CharOf(*buf))) {
+                   ++buf;
+               }
+#if OPT_RENDERFONT
+               if (UsingRenderFont(xw)) {
+                   /* EMPTY */
+                   /* there is only one font entry to load */
+                   ;
+               } else
+#endif
+               {
+                   /*
+                    * Normally there is no font specified in the control.
+                    * But if there is, simply overwrite the font entry.
+                    */
+                   if (*buf == '\0') {
+                       if ((buf = screen->MenuFontName(num)) == 0) {
+                           success = False;
+                       }
+                   }
+               }
+           }
+       } else {
+           num = screen->menu_font_number;
+       }
+       name = x_strtrim(buf);
+       if (success && !IsEmpty(name)) {
+#if OPT_RENDERFONT
+           if (UsingRenderFont(xw)) {
+               setFaceName(xw, name);
+               xtermUpdateFontInfo(xw, True);
+           } else
+#endif
+           {
+               memset(&fonts, 0, sizeof(fonts));
+               fonts.f_n = name;
+               SetVTFont(xw, num, True, &fonts);
+           }
+       } else {
+           Bell(xw, XkbBI_MinorError, 0);
+       }
+       free(name);
+    }
+}
+#endif /* OPT_SHIFT_FONTS */
+
+/***====================================================================***/
+
+void
+do_osc(XtermWidget xw, Char * oscbuf, size_t len, int final)
+{
+    TScreen *screen = TScreenOf(xw);
+    int mode;
+    Char *cp;
+    int state = 0;
+    char *buf = 0;
+    char temp[2];
+#if OPT_ISO_COLORS
+    int ansi_colors = 0;
+#endif
+    Bool need_data = True;
+
+    TRACE(("do_osc %s\n", oscbuf));
+
+    /*
+     * Lines should be of the form <OSC> number ; string <ST>, however
+     * older xterms can accept <BEL> as a final character.  We will respond
+     * with the same final character as the application sends to make this
+     * work better with shell scripts, which may have trouble reading an
+     * <ESC><backslash>, which is the 7-bit equivalent to <ST>.
+     */
+    mode = 0;
+    for (cp = oscbuf; *cp != '\0'; cp++) {
+       switch (state) {
+       case 0:
+           if (isdigit(*cp)) {
+               mode = 10 * mode + (*cp - '0');
+               if (mode > 65535) {
+                   TRACE(("do_osc found unknown mode %d\n", mode));
+                   return;
+               }
+               break;
+           }
+           /* FALLTHRU */
+       case 1:
+           if (*cp != ';') {
+               TRACE(("do_osc did not find semicolon offset %d\n",
+                      (int) (cp - oscbuf)));
+               return;
+           }
+           state = 2;
+           break;
+       case 2:
+           buf = (char *) cp;
+           state = 3;
+           /* FALLTHRU */
+       default:
+           if (!xtermIsPrintable(xw, &cp, oscbuf + len)) {
+               switch (mode) {
+               case 0:
+               case 1:
+               case 2:
+                   break;
+               default:
+                   TRACE(("do_osc found nonprinting char %02X offset %d\n",
+                          CharOf(*cp),
+                          (int) (cp - oscbuf)));
+                   return;
+               }
+           }
+       }
+    }
+
+    /*
+     * Most OSC controls other than resets require data.  Handle the others as
+     * a special case.
+     */
+    switch (mode) {
+#if OPT_ISO_COLORS
+    case OSC_Reset(4):
+    case OSC_Reset(5):
+    case OSC_Reset(OSC_TEXT_FG):
+    case OSC_Reset(OSC_TEXT_BG):
+    case OSC_Reset(OSC_TEXT_CURSOR):
+    case OSC_Reset(OSC_MOUSE_FG):
+    case OSC_Reset(OSC_MOUSE_BG):
+#if OPT_HIGHLIGHT_COLOR
+    case OSC_Reset(OSC_HIGHLIGHT_BG):
+    case OSC_Reset(OSC_HIGHLIGHT_FG):
+#endif
+#if OPT_TEK4014
+    case OSC_Reset(OSC_TEK_FG):
+    case OSC_Reset(OSC_TEK_BG):
+    case OSC_Reset(OSC_TEK_CURSOR):
+#endif
+       need_data = False;
+       break;
+#endif
+    default:
+       break;
+    }
+
+    /*
+     * Check if we have data when we want, and not when we do not want it.
+     * Either way, that is a malformed control sequence, and will be ignored.
+     */
+    if (IsEmpty(buf)) {
+       if (need_data) {
+           TRACE(("do_osc found no data\n"));
+           return;
+       }
+       temp[0] = '\0';
+       buf = temp;
+    } else if (!need_data) {
+       TRACE(("do_osc found found unwanted data\n"));
+       return;
+    }
+
+    switch (mode) {
+    case 0:                    /* new icon name and title */
+       ChangeIconName(xw, buf);
+       ChangeTitle(xw, buf);
+       break;
+
+    case 1:                    /* new icon name only */
+       ChangeIconName(xw, buf);
+       break;
+
+    case 2:                    /* new title only */
+       ChangeTitle(xw, buf);
+       break;
+
+    case 3:                    /* change X property */
+       if (AllowWindowOps(xw, ewSetXprop))
+           ChangeXprop(buf);
+       break;
+#if OPT_ISO_COLORS
+    case 5:
+       ansi_colors = NUM_ANSI_COLORS;
+       /* FALLTHRU */
+    case 4:
+       if (ChangeAnsiColorRequest(xw, buf, ansi_colors, final))
+           xtermRepaint(xw);
+       break;
+    case OSC_Reset(5):
+       ansi_colors = NUM_ANSI_COLORS;
+       /* FALLTHRU */
+    case OSC_Reset(4):
+       if (ResetAnsiColorRequest(xw, buf, ansi_colors))
+           xtermRepaint(xw);
+       break;
+#endif
+    case OSC_TEXT_FG:
+    case OSC_TEXT_BG:
+    case OSC_TEXT_CURSOR:
+    case OSC_MOUSE_FG:
+    case OSC_MOUSE_BG:
+#if OPT_HIGHLIGHT_COLOR
+    case OSC_HIGHLIGHT_BG:
+    case OSC_HIGHLIGHT_FG:
+#endif
+#if OPT_TEK4014
+    case OSC_TEK_FG:
+    case OSC_TEK_BG:
+    case OSC_TEK_CURSOR:
+#endif
+       if (xw->misc.dynamicColors) {
+           ChangeColorsRequest(xw, mode, buf, final);
+       }
+       break;
+    case OSC_Reset(OSC_TEXT_FG):
+    case OSC_Reset(OSC_TEXT_BG):
+    case OSC_Reset(OSC_TEXT_CURSOR):
+    case OSC_Reset(OSC_MOUSE_FG):
+    case OSC_Reset(OSC_MOUSE_BG):
+#if OPT_HIGHLIGHT_COLOR
+    case OSC_Reset(OSC_HIGHLIGHT_BG):
+    case OSC_Reset(OSC_HIGHLIGHT_FG):
+#endif
+#if OPT_TEK4014
+    case OSC_Reset(OSC_TEK_FG):
+    case OSC_Reset(OSC_TEK_BG):
+    case OSC_Reset(OSC_TEK_CURSOR):
+#endif
+       if (xw->misc.dynamicColors) {
+           ResetColorsRequest(xw, mode);
+       }
+       break;
+
+    case 30:
+    case 31:
+       /* reserved for Konsole (Stephan Binner <Stephan.Binner@gmx.de>) */
+       break;
+
+#ifdef ALLOWLOGGING
+    case 46:                   /* new log file */
+#ifdef ALLOWLOGFILECHANGES
+       /*
+        * Warning, enabling this feature allows people to overwrite
+        * arbitrary files accessible to the person running xterm.
+        */
+       if (strcmp(buf, "?")
+           && (cp = CastMallocN(char, strlen(buf)) != NULL)) {
+           strcpy(cp, buf);
+           if (screen->logfile)
+               free(screen->logfile);
+           screen->logfile = cp;
+           break;
+       }
+#endif
+       Bell(xw, XkbBI_Info, 0);
+       Bell(xw, XkbBI_Info, 0);
+       break;
+#endif /* ALLOWLOGGING */
+
+    case 50:
+#if OPT_SHIFT_FONTS
+       if (*buf == '?') {
+           QueryFontRequest(xw, buf, final);
+       } else if (xw->misc.shift_fonts) {
+           ChangeFontRequest(xw, buf);
+       }
+#endif /* OPT_SHIFT_FONTS */
+       break;
+    case 51:
+       /* reserved for Emacs shell (Rob Mayoff <mayoff@dqd.com>) */
+       break;
+
+#if OPT_PASTE64
+    case 52:
+       ManipulateSelectionData(xw, screen, buf, final);
+       break;
+#endif
+       /*
+        * One could write code to send back the display and host names,
+        * but that could potentially open a fairly nasty security hole.
+        */
+    default:
+       TRACE(("do_osc - unrecognized code\n"));
+       break;
+    }
+    unparse_end(xw);
+}
+
+#ifdef SunXK_F36
+#define MAX_UDK 37
+#else
+#define MAX_UDK 35
+#endif
+static struct {
+    char *str;
+    int len;
+} user_keys[MAX_UDK];
+
+/*
+ * Parse one nibble of a hex byte from the OSC string.  We have removed the
+ * string-terminator (replacing it with a null), so the only other delimiter
+ * that is expected is semicolon.  Ignore other characters (Ray Neuman says
+ * "real" terminals accept commas in the string definitions).
+ */
+static int
+udk_value(const char **cp)
+{
+    int result = -1;
+    int c;
+
+    for (;;) {
+       if ((c = **cp) != '\0')
+           *cp = *cp + 1;
+       if (c == ';' || c == '\0')
+           break;
+       if ((result = x_hex2int(c)) >= 0)
+           break;
+    }
+
+    return result;
+}
+
+void
+reset_decudk(void)
+{
+    int n;
+    for (n = 0; n < MAX_UDK; n++) {
+       if (user_keys[n].str != 0) {
+           free(user_keys[n].str);
+           user_keys[n].str = 0;
+           user_keys[n].len = 0;
+       }
+    }
+}
+
+/*
+ * Parse the data for DECUDK (user-defined keys).
+ */
+static void
+parse_decudk(const char *cp)
+{
+    while (*cp) {
+       const char *base = cp;
+       char *str = CastMallocN(char, strlen(cp) + 1);
+       unsigned key = 0;
+       int lo, hi;
+       int len = 0;
+
+       while (isdigit(CharOf(*cp)))
+           key = (key * 10) + (unsigned) (*cp++ - '0');
+       if (*cp == '/') {
+           cp++;
+           while ((hi = udk_value(&cp)) >= 0
+                  && (lo = udk_value(&cp)) >= 0) {
+               str[len++] = (char) ((hi << 4) | lo);
+           }
+       }
+       if (len > 0 && key < MAX_UDK) {
+           if (user_keys[key].str != 0)
+               free(user_keys[key].str);
+           user_keys[key].str = str;
+           user_keys[key].len = len;
+       } else {
+           free(str);
+       }
+       if (*cp == ';')
+           cp++;
+       if (cp == base)         /* badly-formed sequence - bail out */
+           break;
+    }
+}
+
+#if OPT_TRACE
+#define SOFT_WIDE 10
+#define SOFT_HIGH 20
+
+static void
+parse_decdld(ANSI * params, const char *string)
+{
+    char DscsName[8];
+    int len;
+    int Pfn = params->a_param[0];
+    int Pcn = params->a_param[1];
+    int Pe = params->a_param[2];
+    int Pcmw = params->a_param[3];
+    int Pw = params->a_param[4];
+    int Pt = params->a_param[5];
+    int Pcmh = params->a_param[6];
+    int Pcss = params->a_param[7];
+
+    int start_char = Pcn + 0x20;
+    int char_wide = ((Pcmw == 0)
+                    ? (Pcss ? 6 : 10)
+                    : (Pcmw > 4
+                       ? Pcmw
+                       : (Pcmw + 3)));
+    int char_high = ((Pcmh == 0)
+                    ? ((Pcmw >= 2 || Pcmw <= 4)
+                       ? 10
+                       : 20)
+                    : Pcmh);
+    Char ch;
+    Char bits[SOFT_HIGH][SOFT_WIDE];
+    Bool first = True;
+    Bool prior = False;
+    int row = 0, col = 0;
+
+    TRACE(("Parsing DECDLD\n"));
+    TRACE(("  font number   %d\n", Pfn));
+    TRACE(("  starting char %d\n", Pcn));
+    TRACE(("  erase control %d\n", Pe));
+    TRACE(("  char-width    %d\n", Pcmw));
+    TRACE(("  font-width    %d\n", Pw));
+    TRACE(("  text/full     %d\n", Pt));
+    TRACE(("  char-height   %d\n", Pcmh));
+    TRACE(("  charset-size  %d\n", Pcss));
+
+    if (Pfn > 1
+       || Pcn > 95
+       || Pe > 2
+       || Pcmw > 10
+       || Pcmw == 1
+       || Pt > 2
+       || Pcmh > 20
+       || Pcss > 1
+       || char_wide > SOFT_WIDE
+       || char_high > SOFT_HIGH) {
+       TRACE(("DECDLD illegal parameter\n"));
+       return;
+    }
+
+    len = 0;
+    while (*string != '\0') {
+       ch = CharOf(*string++);
+       if (ch >= ANSI_SPA && ch <= 0x2f) {
+           if (len < 2)
+               DscsName[len++] = (char) ch;
+       } else if (ch >= 0x30 && ch <= 0x7e) {
+           DscsName[len++] = (char) ch;
+           break;
+       }
+    }
+    DscsName[len] = 0;
+    TRACE(("  Dscs name     '%s'\n", DscsName));
+
+    TRACE(("  character matrix %dx%d\n", char_high, char_wide));
+    while (*string != '\0') {
+       if (first) {
+           TRACE(("Char %d:\n", start_char));
+           if (prior) {
+               for (row = 0; row < char_high; ++row) {
+                   TRACE(("%.*s\n", char_wide, bits[row]));
+               }
+           }
+           prior = False;
+           first = False;
+           for (row = 0; row < char_high; ++row) {
+               for (col = 0; col < char_wide; ++col) {
+                   bits[row][col] = '.';
+               }
+           }
+           row = col = 0;
+       }
+       ch = CharOf(*string++);
+       if (ch >= 0x3f && ch <= 0x7e) {
+           int n;
+
+           ch = CharOf(ch - 0x3f);
+           for (n = 0; n < 6; ++n) {
+               bits[row + n][col] = CharOf((ch & (1 << n)) ? '*' : '.');
+           }
+           col += 1;
+           prior = True;
+       } else if (ch == '/') {
+           row += 6;
+           col = 0;
+       } else if (ch == ';') {
+           first = True;
+           ++start_char;
+       }
+    }
+}
+#else
+#define parse_decdld(p,q)      /* nothing */
+#endif
+
+/*
+ * Parse numeric parameters.  Normally we use a state machine to simplify
+ * interspersing with control characters, but have the string already.
+ */
+static void
+parse_ansi_params(ANSI * params, const char **string)
+{
+    const char *cp = *string;
+    ParmType nparam = 0;
+
+    memset(params, 0, sizeof(*params));
+    while (*cp != '\0') {
+       Char ch = CharOf(*cp++);
+
+       if (isdigit(ch)) {
+           if (nparam < NPARAM) {
+               params->a_param[nparam] =
+                   (ParmType) ((params->a_param[nparam] * 10)
+                               + (ch - '0'));
+           }
+       } else if (ch == ';') {
+           if (++nparam < NPARAM)
+               params->a_nparam = nparam;
+       } else if (ch < 32) {
+           /* EMPTY */ ;
+       } else {
+           /* should be 0x30 to 0x7e */
+           params->a_final = ch;
+           break;
+       }
+    }
+    *string = cp;
+}
+
+void
+do_dcs(XtermWidget xw, Char * dcsbuf, size_t dcslen)
+{
+    TScreen *screen = TScreenOf(xw);
+    char reply[BUFSIZ];
+    const char *cp = (const char *) dcsbuf;
+    Bool okay;
+    ANSI params;
+
+    TRACE(("do_dcs(%s:%lu)\n", (char *) dcsbuf, (unsigned long) dcslen));
+
+    if (dcslen != strlen(cp))
+       /* shouldn't have nulls in the string */
+       return;
+
+    switch (*cp) {             /* intermediate character, or parameter */
+    case '$':                  /* DECRQSS */
+       okay = True;
+
+       cp++;
+       if (*cp++ == 'q') {
+           if (!strcmp(cp, "\"q")) {   /* DECSCA */
+               sprintf(reply, "%d%s",
+                       (screen->protected_mode == DEC_PROTECT)
+                       && (xw->flags & PROTECTED) ? 1 : 0,
+                       cp);
+           } else if (!strcmp(cp, "\"p")) {    /* DECSCL */
+               sprintf(reply, "%d%s%s",
+                       (screen->vtXX_level ?
+                        screen->vtXX_level : 1) + 60,
+                       (screen->vtXX_level >= 2)
+                       ? (screen->control_eight_bits
+                          ? ";0" : ";1")
+                       : "",
+                       cp);
+           } else if (!strcmp(cp, "r")) {      /* DECSTBM */
+               sprintf(reply, "%d;%dr",
+                       screen->top_marg + 1,
+                       screen->bot_marg + 1);
+           } else if (!strcmp(cp, "m")) {      /* SGR */
+               strcpy(reply, "0");
+               if (xw->flags & BOLD)
+                   strcat(reply, ";1");
+               if (xw->flags & UNDERLINE)
+                   strcat(reply, ";4");
+               if (xw->flags & BLINK)
+                   strcat(reply, ";5");
+               if (xw->flags & INVERSE)
+                   strcat(reply, ";7");
+               if (xw->flags & INVISIBLE)
+                   strcat(reply, ";8");
+#if OPT_256_COLORS || OPT_88_COLORS
+               if_OPT_ISO_COLORS(screen, {
+                   if (xw->flags & FG_COLOR) {
+                       if (xw->cur_foreground >= 16)
+                           sprintf(reply + strlen(reply),
+                                   ";38;5;%d", xw->cur_foreground);
+                       else
+                           sprintf(reply + strlen(reply),
+                                   ";%d%d",
+                                   xw->cur_foreground >= 8 ? 9 : 3,
+                                   xw->cur_foreground >= 8 ?
+                                   xw->cur_foreground - 8 :
+                                   xw->cur_foreground);
+                   }
+                   if (xw->flags & BG_COLOR) {
+                       if (xw->cur_background >= 16)
+                           sprintf(reply + strlen(reply),
+                                   ";48;5;%d", xw->cur_foreground);
+                       else
+                           sprintf(reply + strlen(reply),
+                                   ";%d%d",
+                                   xw->cur_background >= 8 ? 10 : 4,
+                                   xw->cur_background >= 8 ?
+                                   xw->cur_background - 8 :
+                                   xw->cur_background);
+                   }
+               });
+#elif OPT_ISO_COLORS
+               if_OPT_ISO_COLORS(screen, {
+                   if (xw->flags & FG_COLOR)
+                       sprintf(reply + strlen(reply),
+                               ";%d%d",
+                               xw->cur_foreground >= 8 ? 9 : 3,
+                               xw->cur_foreground >= 8 ?
+                               xw->cur_foreground - 8 :
+                               xw->cur_foreground);
+                   if (xw->flags & BG_COLOR)
+                       sprintf(reply + strlen(reply),
+                               ";%d%d",
+                               xw->cur_background >= 8 ? 10 : 4,
+                               xw->cur_background >= 8 ?
+                               xw->cur_background - 8 :
+                               xw->cur_background);
+               });
+#endif
+               strcat(reply, "m");
+           } else
+               okay = False;
+
+           if (okay) {
+               unparseputc1(xw, ANSI_DCS);
+               unparseputc(xw, okay ? '1' : '0');
+               unparseputc(xw, '$');
+               unparseputc(xw, 'r');
+               cp = reply;
+               unparseputs(xw, cp);
+               unparseputc1(xw, ANSI_ST);
+           } else {
+               unparseputc(xw, ANSI_CAN);
+           }
+       } else {
+           unparseputc(xw, ANSI_CAN);
+       }
+       break;
+#if OPT_TCAP_QUERY
+    case '+':
+       cp++;
+       switch (*cp) {
+       case 'p':
+           if (AllowTcapOps(xw, etSetTcap)) {
+               set_termcap(xw, cp + 1);
+           }
+           break;
+       case 'q':
+           if (AllowTcapOps(xw, etGetTcap)) {
+               Bool fkey;
+               unsigned state;
+               int code;
+               const char *tmp;
+               const char *parsed = ++cp;
+
+               code = xtermcapKeycode(xw, &parsed, &state, &fkey);
+
+               unparseputc1(xw, ANSI_DCS);
+
+               unparseputc(xw, code >= 0 ? '1' : '0');
+
+               unparseputc(xw, '+');
+               unparseputc(xw, 'r');
+
+               while (*cp != 0 && (code >= -1)) {
+                   if (cp == parsed)
+                       break;  /* no data found, error */
+
+                   for (tmp = cp; tmp != parsed; ++tmp)
+                       unparseputc(xw, *tmp);
+
+                   if (code >= 0) {
+                       unparseputc(xw, '=');
+                       screen->tc_query_code = code;
+                       screen->tc_query_fkey = fkey;
+#if OPT_ISO_COLORS
+                       /* XK_COLORS is a fake code for the "Co" entry (maximum
+                        * number of colors) */
+                       if (code == XK_COLORS) {
+                           unparseputn(xw, NUM_ANSI_COLORS);
+                       } else
+#endif
+                       if (code == XK_TCAPNAME) {
+                           unparseputs(xw, xterm_name);
+                       } else {
+                           XKeyEvent event;
+                           event.state = state;
+                           Input(xw, &event, False);
+                       }
+                       screen->tc_query_code = -1;
+                   } else {
+                       break;  /* no match found, error */
+                   }
+
+                   cp = parsed;
+                   if (*parsed == ';') {
+                       unparseputc(xw, *parsed++);
+                       cp = parsed;
+                       code = xtermcapKeycode(xw, &parsed, &state, &fkey);
+                   }
+               }
+               unparseputc1(xw, ANSI_ST);
+           }
+           break;
+       }
+       break;
+#endif
+    default:
+       if (screen->terminal_id >= 200) {       /* VT220 */
+           parse_ansi_params(&params, &cp);
+           switch (params.a_final) {
+           case '|':           /* DECUDK */
+               if (params.a_param[0] == 0)
+                   reset_decudk();
+               parse_decudk(cp);
+               break;
+           case '{':           /* DECDLD (no '}' case though) */
+               parse_decdld(&params, cp);
+               break;
+           }
+       }
+       break;
+    }
+    unparse_end(xw);
+}
+
+#if OPT_DEC_RECTOPS
+enum {
+    mdUnknown = 0,
+    mdMaybeSet = 1,
+    mdMaybeReset = 2,
+    mdAlwaysSet = 3,
+    mdAlwaysReset = 4
+};
+
+#define MdBool(bool)      ((bool) ? mdMaybeSet : mdMaybeReset)
+#define MdFlag(mode,flag) MdBool(xw->keyboard.flags & MODE_KAM)
+
+/*
+ * Reply is the same format as the query, with pair of mode/value:
+ * 0 - not recognized
+ * 1 - set
+ * 2 - reset
+ * 3 - permanently set
+ * 4 - permanently reset
+ * Only one mode can be reported at a time.
+ */
+void
+do_rpm(XtermWidget xw, int nparams, int *params)
+{
+    ANSI reply;
+    int result = 0;
+    int count = 0;
+
+    TRACE(("do_rpm %d:%d\n", nparams, params[0]));
+    memset(&reply, 0, sizeof(reply));
+    if (nparams >= 1) {
+       switch (params[0]) {
+       case 1:         /* GATM */
+           result = mdAlwaysReset;
+           break;
+       case 2:
+           result = MdFlag(xw->keyboard.flags, MODE_KAM);
+           break;
+       case 3:         /* CRM */
+           result = mdMaybeReset;
+           break;
+       case 4:
+           result = MdFlag(xw->flags, INSERT);
+           break;
+       case 5:         /* SRTM */
+       case 7:         /* VEM */
+       case 10:                /* HEM */
+       case 11:                /* PUM */
+           result = mdAlwaysReset;
+           break;
+       case 12:
+           result = MdFlag(xw->keyboard.flags, MODE_SRM);
+           break;
+       case 13:                /* FEAM */
+       case 14:                /* FETM */
+       case 15:                /* MATM */
+       case 16:                /* TTM */
+       case 17:                /* SATM */
+       case 18:                /* TSM */
+       case 19:                /* EBM */
+           result = mdAlwaysReset;
+           break;
+       case 20:
+           result = MdFlag(xw->flags, LINEFEED);
+           break;
+       }
+       reply.a_param[count++] = (ParmType) params[0];
+       reply.a_param[count++] = (ParmType) result;
+    }
+    reply.a_type = ANSI_CSI;
+    reply.a_nparam = (ParmType) count;
+    reply.a_inters = '$';
+    reply.a_final = 'y';
+    unparseseq(xw, &reply);
+}
+
+void
+do_decrpm(XtermWidget xw, int nparams, int *params)
+{
+    ANSI reply;
+    int result = 0;
+    int count = 0;
+
+    TRACE(("do_decrpm %d:%d\n", nparams, params[0]));
+    memset(&reply, 0, sizeof(reply));
+    if (nparams >= 1) {
+       TScreen *screen = TScreenOf(xw);
+
+       switch (params[0]) {
+       case 1:         /* DECCKM                       */
+           result = MdFlag(xw->keyboard.flags, MODE_DECCKM);
+           break;
+       case 2:         /* DECANM - ANSI/VT52 mode      */
+#if OPT_VT52_MODE
+           result = MdBool(screen->terminal_id >= 100);
+#else
+           result = mdMaybeSet;
+#endif
+           break;
+       case 3:         /* DECCOLM                      */
+           result = MdFlag(xw->flags, IN132COLUMNS);
+           break;
+       case 4:         /* DECSCLM (slow scroll)        */
+           result = MdFlag(xw->flags, SMOOTHSCROLL);
+           break;
+       case 5:         /* DECSCNM                      */
+           result = MdFlag(xw->flags, REVERSE_VIDEO);
+           break;
+       case 6:         /* DECOM                        */
+           result = MdFlag(xw->flags, ORIGIN);
+           break;
+       case 7:         /* DECAWM                       */
+           result = MdFlag(xw->flags, WRAPAROUND);
+           break;
+       case 8:         /* DECARM                       */
+           result = mdAlwaysReset;
+           break;
+       case SET_X10_MOUSE:     /* X10 mouse                    */
+           result = MdBool(screen->send_mouse_pos == X10_MOUSE);
+           break;
+#if OPT_TOOLBAR
+       case 10:                /* rxvt */
+           result = MdBool(resource.toolBar);
+           break;
+#endif
+#if OPT_BLINK_CURS
+       case 12:                /* att610: Start/stop blinking cursor */
+           result = MdBool(screen->cursor_blink_res);
+           break;
+#endif
+       case 18:                /* DECPFF: print form feed */
+           result = MdBool(screen->printer_formfeed);
+           break;
+       case 19:                /* DECPEX: print extent */
+           result = MdBool(screen->printer_extent);
+           break;
+       case 25:                /* DECTCEM: Show/hide cursor (VT200) */
+           result = MdBool(screen->cursor_set);
+           break;
+       case 30:                /* rxvt */
+           result = MdBool(screen->fullVwin.sb_info.width != OFF);
+           break;
+#if OPT_SHIFT_FONTS
+       case 35:                /* rxvt */
+           result = MdBool(xw->misc.shift_fonts);
+           break;
+#endif
+#if OPT_TEK4014
+       case 38:                /* DECTEK                       */
+           result = MdBool(TEK4014_ACTIVE(xw));
+           break;
+#endif
+       case 40:                /* 132 column mode              */
+           result = MdBool(screen->c132);
+           break;
+       case 41:                /* curses hack                  */
+           result = MdBool(screen->curses);
+           break;
+       case 42:                /* DECNRCM national charset (VT220) */
+           result = MdFlag(xw->flags, NATIONAL);
+           break;
+       case 44:                /* margin bell                  */
+           result = MdBool(screen->marginbell);
+           break;
+       case 45:                /* reverse wraparound   */
+           result = MdFlag(xw->flags, REVERSEWRAP);
+           break;
+#ifdef ALLOWLOGGING
+       case 46:                /* logging              */
+#ifdef ALLOWLOGFILEONOFF
+           result = MdBool(screen->logging);
+#endif /* ALLOWLOGFILEONOFF */
+           break;
+#endif
+       case 1049:              /* alternate buffer & cursor */
+           /* FALLTHRU */
+       case 1047:
+           /* FALLTHRU */
+       case 47:                /* alternate buffer */
+           result = MdBool(screen->whichBuf);
+           break;
+       case 66:                /* DECNKM */
+           result = MdFlag(xw->keyboard.flags, MODE_DECKPAM);
+           break;
+       case 67:                /* DECBKM */
+           result = MdFlag(xw->keyboard.flags, MODE_DECBKM);
+           break;
+       case SET_VT200_MOUSE:   /* xterm bogus sequence         */
+           result = MdBool(screen->send_mouse_pos == VT200_MOUSE);
+           break;
+       case SET_VT200_HIGHLIGHT_MOUSE: /* xterm sequence w/hilite tracking */
+           result = MdBool(screen->send_mouse_pos == VT200_HIGHLIGHT_MOUSE);
+           break;
+       case SET_BTN_EVENT_MOUSE:
+           result = MdBool(screen->send_mouse_pos == BTN_EVENT_MOUSE);
+           break;
+       case SET_ANY_EVENT_MOUSE:
+           result = MdBool(screen->send_mouse_pos == ANY_EVENT_MOUSE);
+           break;
+#if OPT_FOCUS_EVENT
+       case SET_FOCUS_EVENT_MOUSE:
+           result = MdBool(screen->send_focus_pos);
+           break;
+#endif
+       case SET_EXT_MODE_MOUSE:
+           result = MdBool(screen->ext_mode_mouse);
+           break;
+       case 1010:              /* rxvt */
+           result = MdBool(screen->scrollttyoutput);
+           break;
+       case 1011:              /* rxvt */
+           result = MdBool(screen->scrollkey);
+           break;
+       case 1034:
+           result = MdBool(screen->input_eight_bits);
+           break;
+#if OPT_NUM_LOCK
+       case 1035:
+           result = MdBool(xw->misc.real_NumLock);
+           break;
+       case 1036:
+           result = MdBool(screen->meta_sends_esc);
+           break;
+#endif
+       case 1037:
+           result = MdBool(screen->delete_is_del);
+           break;
+#if OPT_NUM_LOCK
+       case 1039:
+           result = MdBool(screen->alt_sends_esc);
+           break;
+#endif
+       case 1040:
+           result = MdBool(screen->keepSelection);
+           break;
+       case 1041:
+           result = MdBool(screen->selectToClipboard);
+           break;
+       case 1042:
+           result = MdBool(screen->bellIsUrgent);
+           break;
+       case 1043:
+           result = MdBool(screen->poponbell);
+           break;
+       case 1048:
+           result = MdBool(screen->sc[screen->whichBuf].saved);
+           break;
+#if OPT_TCAP_FKEYS
+       case 1050:
+           result = MdBool(xw->keyboard.type == keyboardIsTermcap);
+           break;
+#endif
+#if OPT_SUN_FUNC_KEYS
+       case 1051:
+           result = MdBool(xw->keyboard.type == keyboardIsSun);
+           break;
+#endif
+#if OPT_HP_FUNC_KEYS
+       case 1052:
+           result = MdBool(xw->keyboard.type == keyboardIsHP);
+           break;
+#endif
+#if OPT_SCO_FUNC_KEYS
+       case 1053:
+           result = MdBool(xw->keyboard.type == keyboardIsSCO);
+           break;
+#endif
+       case 1060:
+           result = MdBool(xw->keyboard.type == keyboardIsLegacy);
+           break;
+#if OPT_SUNPC_KBD
+       case 1061:
+           result = MdBool(xw->keyboard.type == keyboardIsVT220);
+           break;
+#endif
+#if OPT_READLINE
+       case SET_BUTTON1_MOVE_POINT:
+           result = MdBool(screen->click1_moves);
+           break;
+       case SET_BUTTON2_MOVE_POINT:
+           result = MdBool(screen->paste_moves);
+           break;
+       case SET_DBUTTON3_DELETE:
+           result = MdBool(screen->dclick3_deletes);
+           break;
+       case SET_PASTE_IN_BRACKET:
+           result = MdBool(screen->paste_brackets);
+           break;
+       case SET_PASTE_QUOTE:
+           result = MdBool(screen->paste_quotes);
+           break;
+       case SET_PASTE_LITERAL_NL:
+           result = MdBool(screen->paste_literal_nl);
+           break;
+#endif /* OPT_READLINE */
+       }
+       reply.a_param[count++] = (ParmType) params[0];
+       reply.a_param[count++] = (ParmType) result;
+    }
+    reply.a_type = ANSI_CSI;
+    reply.a_pintro = '?';
+    reply.a_nparam = (ParmType) count;
+    reply.a_inters = '$';
+    reply.a_final = 'y';
+    unparseseq(xw, &reply);
+}
+#endif /* OPT_DEC_RECTOPS */
+
+char *
+udk_lookup(int keycode, int *len)
+{
+    if (keycode >= 0 && keycode < MAX_UDK) {
+       *len = user_keys[keycode].len;
+       return user_keys[keycode].str;
+    }
+    return 0;
+}
+
+static void
+ChangeGroup(XtermWidget xw, const char *attribute, char *value)
+{
+#if OPT_WIDE_CHARS
+    static Char *converted;    /* NO_LEAKS */
+#endif
+    static char empty[1];
+
+    Arg args[1];
+    Boolean changed = True;
+    Widget w = CURRENT_EMU();
+    Widget top = SHELL_OF(w);
+
+    char *my_attr;
+    char *name;
+    size_t limit;
+    Char *c1;
+    Char *cp;
+
+    if (!AllowTitleOps(xw))
+       return;
+
+    if (value == 0)
+       value = empty;
+    if (IsTitleMode(xw, tmSetBase16)) {
+       const char *temp;
+       char *test;
+
+       value = x_decode_hex(value, &temp);
+       if (*temp != '\0')
+           return;
+       for (test = value; *test != '\0'; ++test) {
+           if (CharOf(*test) < 32) {
+               *test = '\0';
+               break;
+           }
+       }
+    }
+
+    c1 = (Char *) value;
+    name = value;
+    limit = strlen(name);
+    my_attr = x_strdup(attribute);
+
+    TRACE(("ChangeGroup(attribute=%s, value=%s)\n", my_attr, name));
+
+    /*
+     * Ignore titles that are too long to be plausible requests.
+     */
+    if (limit > 0 && limit < 1024) {
+
+       /*
+        * After all decoding, overwrite nonprintable characters with '?'.
+        */
+       for (cp = c1; *cp != 0; ++cp) {
+           Char *c2 = cp;
+           if (!xtermIsPrintable(xw, &cp, c1 + limit)) {
+               memset(c2, '?', (size_t) (cp + 1 - c2));
+           }
+       }
+
+#if OPT_WIDE_CHARS
+       /*
+        * If we're running in UTF-8 mode, and have not been told that the
+        * title string is in UTF-8, it is likely that non-ASCII text in the
+        * string will be rejected because it is not printable in the current
+        * locale.  So we convert it to UTF-8, allowing the X library to
+        * convert it back.
+        */
+       if (xtermEnvUTF8() && !IsSetUtf8Title(xw)) {
+           int n;
+
+           for (n = 0; name[n] != '\0'; ++n) {
+               if (CharOf(name[n]) > 127) {
+                   if (converted != 0)
+                       free(converted);
+                   if ((converted = TypeMallocN(Char, 1 + (6 * limit))) != 0) {
+                       Char *temp = converted;
+                       while (*name != 0) {
+                           temp = convertToUTF8(temp, CharOf(*name));
+                           ++name;
+                       }
+                       *temp = 0;
+                       name = (char *) converted;
+                       TRACE(("...converted{%s}\n", name));
+                   }
+                   break;
+               }
+           }
+       }
+#endif
+
+#if OPT_SAME_NAME
+       /* If the attribute isn't going to change, then don't bother... */
+
+       if (resource.sameName) {
+           char *buf = 0;
+           XtSetArg(args[0], my_attr, &buf);
+           XtGetValues(top, args, 1);
+           TRACE(("...comparing{%s}\n", buf));
+           if (buf != 0 && strcmp(name, buf) == 0)
+               changed = False;
+       }
+#endif /* OPT_SAME_NAME */
+
+       if (changed) {
+           TRACE(("...updating %s\n", my_attr));
+           TRACE(("...value is %s\n", name));
+           XtSetArg(args[0], my_attr, name);
+           XtSetValues(top, args, 1);
+
+#if OPT_WIDE_CHARS
+           if (xtermEnvUTF8()) {
+               Display *dpy = XtDisplay(xw);
+               Atom my_atom;
+
+               const char *propname = (!strcmp(my_attr, XtNtitle)
+                                       ? "_NET_WM_NAME"
+                                       : "_NET_WM_ICON_NAME");
+               if ((my_atom = XInternAtom(dpy, propname, False)) != None) {
+                   if (IsSetUtf8Title(xw)) {
+                       TRACE(("...updating %s\n", propname));
+                       TRACE(("...value is %s\n", value));
+                       XChangeProperty(dpy, VShellWindow(xw), my_atom,
+                                       XA_UTF8_STRING(dpy), 8,
+                                       PropModeReplace,
+                                       (Char *) value,
+                                       (int) strlen(value));
+                   } else {
+                       TRACE(("...deleting %s\n", propname));
+                       XDeleteProperty(dpy, VShellWindow(xw), my_atom);
+                   }
+               }
+           }
+#endif
+       }
+
+       free(my_attr);
+
+       if (IsTitleMode(xw, tmSetBase16))
+           free(value);
+
+    }
+    return;
+}
+
+void
+ChangeIconName(XtermWidget xw, char *name)
+{
+    if (name == 0) {
+       static char dummy[] = "";
+       name = dummy;
+    }
+#if OPT_ZICONBEEP              /* If warning should be given then give it */
+    if (resource.zIconBeep && TScreenOf(xw)->zIconBeep_flagged) {
+       char *newname = CastMallocN(char, strlen(name) + 4);
+       if (!newname) {
+           fprintf(stderr, "malloc failed in ChangeIconName\n");
+           return;
+       }
+       strcpy(newname, "*** ");
+       strcat(newname, name);
+       ChangeGroup(xw, XtNiconName, newname);
+       free(newname);
+    } else
+#endif /* OPT_ZICONBEEP */
+       ChangeGroup(xw, XtNiconName, name);
+}
+
+void
+ChangeTitle(XtermWidget xw, char *name)
+{
+    ChangeGroup(xw, XtNtitle, name);
+}
+
+#define Strlen(s) strlen((char *)(s))
+
+void
+ChangeXprop(char *buf)
+{
+    Display *dpy = XtDisplay(toplevel);
+    Window w = XtWindow(toplevel);
+    XTextProperty text_prop;
+    Atom aprop;
+    Char *pchEndPropName = (Char *) strchr(buf, '=');
+
+    if (pchEndPropName)
+       *pchEndPropName = '\0';
+    aprop = XInternAtom(dpy, buf, False);
+    if (pchEndPropName == NULL) {
+       /* no "=value" given, so delete the property */
+       XDeleteProperty(dpy, w, aprop);
+    } else {
+       text_prop.value = pchEndPropName + 1;
+       text_prop.encoding = XA_STRING;
+       text_prop.format = 8;
+       text_prop.nitems = Strlen(text_prop.value);
+       XSetTextProperty(dpy, w, &text_prop, aprop);
+    }
+}
+
+/***====================================================================***/
+
+/*
+ * This is part of ReverseVideo().  It reverses the data stored for the old
+ * "dynamic" colors that might have been retrieved using OSC 10-18.
+ */
+void
+ReverseOldColors(void)
+{
+    ScrnColors *pOld = pOldColors;
+    Pixel tmpPix;
+    char *tmpName;
+
+    if (pOld) {
+       /* change text cursor, if necesary */
+       if (pOld->colors[TEXT_CURSOR] == pOld->colors[TEXT_FG]) {
+           pOld->colors[TEXT_CURSOR] = pOld->colors[TEXT_BG];
+           if (pOld->names[TEXT_CURSOR]) {
+               XtFree(pOldColors->names[TEXT_CURSOR]);
+               pOld->names[TEXT_CURSOR] = NULL;
+           }
+           if (pOld->names[TEXT_BG]) {
+               if ((tmpName = x_strdup(pOld->names[TEXT_BG])) != 0) {
+                   pOld->names[TEXT_CURSOR] = tmpName;
+               }
+           }
+       }
+
+       EXCHANGE(pOld->colors[TEXT_FG], pOld->colors[TEXT_BG], tmpPix);
+       EXCHANGE(pOld->names[TEXT_FG], pOld->names[TEXT_BG], tmpName);
+
+       EXCHANGE(pOld->colors[MOUSE_FG], pOld->colors[MOUSE_BG], tmpPix);
+       EXCHANGE(pOld->names[MOUSE_FG], pOld->names[MOUSE_BG], tmpName);
+
+#if OPT_TEK4014
+       EXCHANGE(pOld->colors[TEK_FG], pOld->colors[TEK_BG], tmpPix);
+       EXCHANGE(pOld->names[TEK_FG], pOld->names[TEK_BG], tmpName);
+#endif
+    }
+    return;
+}
+
+Bool
+AllocateTermColor(XtermWidget xw,
+                 ScrnColors * pNew,
+                 int ndx,
+                 const char *name,
+                 Bool always)
+{
+    Bool result = False;
+
+    if (always || AllowColorOps(xw, ecSetColor)) {
+       XColor def;
+       TScreen *screen = TScreenOf(xw);
+       Colormap cmap = xw->core.colormap;
+       char *newName;
+
+       if (XParseColor(screen->display, cmap, name, &def)
+           && (XAllocColor(screen->display, cmap, &def)
+               || find_closest_color(screen->display, cmap, &def))
+           && (newName = x_strdup(name)) != 0) {
+           if (COLOR_DEFINED(pNew, ndx))
+               free(pNew->names[ndx]);
+           SET_COLOR_VALUE(pNew, ndx, def.pixel);
+           SET_COLOR_NAME(pNew, ndx, newName);
+           TRACE(("AllocateTermColor #%d: %s (pixel %#lx)\n", ndx, newName, def.pixel));
+           result = True;
+       } else {
+           TRACE(("AllocateTermColor #%d: %s (failed)\n", ndx, name));
+       }
+    }
+    return result;
+}
+/***====================================================================***/
+
+/* ARGSUSED */
+void
+Panic(const char *s GCC_UNUSED, int a GCC_UNUSED)
+{
+#ifdef DEBUG
+    if (debug) {
+       fprintf(stderr, "%s: PANIC!\t", xterm_name);
+       fprintf(stderr, s, a);
+       fputs("\r\n", stderr);
+       fflush(stderr);
+    }
+#endif /* DEBUG */
+}
+
+const char *
+SysErrorMsg(int code)
+{
+    static char unknown[] = "unknown error";
+    char *s = strerror(code);
+    return s ? s : unknown;
+}
+
+const char *
+SysReasonMsg(int code)
+{
+    /* *INDENT-OFF* */
+    static const struct {
+       int code;
+       const char *name;
+    } table[] = {
+       { ERROR_FIONBIO,        "main:  ioctl() failed on FIONBIO" },
+       { ERROR_F_GETFL,        "main: ioctl() failed on F_GETFL" },
+       { ERROR_F_SETFL,        "main: ioctl() failed on F_SETFL", },
+       { ERROR_OPDEVTTY,       "spawn: open() failed on /dev/tty", },
+       { ERROR_TIOCGETP,       "spawn: ioctl() failed on TIOCGETP", },
+       { ERROR_PTSNAME,        "spawn: ptsname() failed", },
+       { ERROR_OPPTSNAME,      "spawn: open() failed on ptsname", },
+       { ERROR_PTEM,           "spawn: ioctl() failed on I_PUSH/\"ptem\"" },
+       { ERROR_CONSEM,         "spawn: ioctl() failed on I_PUSH/\"consem\"" },
+       { ERROR_LDTERM,         "spawn: ioctl() failed on I_PUSH/\"ldterm\"" },
+       { ERROR_TTCOMPAT,       "spawn: ioctl() failed on I_PUSH/\"ttcompat\"" },
+       { ERROR_TIOCSETP,       "spawn: ioctl() failed on TIOCSETP" },
+       { ERROR_TIOCSETC,       "spawn: ioctl() failed on TIOCSETC" },
+       { ERROR_TIOCSETD,       "spawn: ioctl() failed on TIOCSETD" },
+       { ERROR_TIOCSLTC,       "spawn: ioctl() failed on TIOCSLTC" },
+       { ERROR_TIOCLSET,       "spawn: ioctl() failed on TIOCLSET" },
+       { ERROR_INIGROUPS,      "spawn: initgroups() failed" },
+       { ERROR_FORK,           "spawn: fork() failed" },
+       { ERROR_EXEC,           "spawn: exec() failed" },
+       { ERROR_PTYS,           "get_pty: not enough ptys" },
+       { ERROR_PTY_EXEC,       "waiting for initial map" },
+       { ERROR_SETUID,         "spawn: setuid() failed" },
+       { ERROR_INIT,           "spawn: can't initialize window" },
+       { ERROR_TIOCKSET,       "spawn: ioctl() failed on TIOCKSET" },
+       { ERROR_TIOCKSETC,      "spawn: ioctl() failed on TIOCKSETC" },
+       { ERROR_LUMALLOC,       "luit: command-line malloc failed" },
+       { ERROR_SELECT,         "in_put: select() failed" },
+       { ERROR_VINIT,          "VTInit: can't initialize window" },
+       { ERROR_KMMALLOC1,      "HandleKeymapChange: malloc failed" },
+       { ERROR_TSELECT,        "Tinput: select() failed" },
+       { ERROR_TINIT,          "TekInit: can't initialize window" },
+       { ERROR_BMALLOC2,       "SaltTextAway: malloc() failed" },
+       { ERROR_LOGEXEC,        "StartLog: exec() failed" },
+       { ERROR_XERROR,         "xerror: XError event" },
+       { ERROR_XIOERROR,       "xioerror: X I/O error" },
+       { ERROR_SCALLOC,        "Alloc: calloc() failed on base" },
+       { ERROR_SCALLOC2,       "Alloc: calloc() failed on rows" },
+       { ERROR_SAVE_PTR,       "ScrnPointers: malloc/realloc() failed" },
+       { ERROR_MMALLOC,        "my_memmove: malloc/realloc failed" },
+    };
+    /* *INDENT-ON* */
+
+    Cardinal n;
+    const char *result = "?";
+
+    for (n = 0; n < XtNumber(table); ++n) {
+       if (code == table[n].code) {
+           result = table[n].name;
+           break;
+       }
+    }
+    return result;
+}
+
+void
+SysError(int code)
+{
+    int oerrno = errno;
+
+    fprintf(stderr, "%s: Error %d, errno %d: ", xterm_name, code, oerrno);
+    fprintf(stderr, "%s\n", SysErrorMsg(oerrno));
+    fprintf(stderr, "Reason: %s\n", SysReasonMsg(code));
+
+    Cleanup(code);
+}
+
+/*
+ * cleanup by sending SIGHUP to client processes
+ */
+void
+Cleanup(int code)
+{
+    static Bool cleaning;
+    TScreen *screen = TScreenOf(term);
+
+    /*
+     * Process "-hold" and session cleanup only for a normal exit.
+     */
+    if (code == 0) {
+       if (cleaning) {
+           hold_screen = 0;
+           return;
+       }
+
+       cleaning = True;
+       need_cleanup = False;
+
+       TRACE(("Cleanup %d\n", code));
+
+       if (hold_screen) {
+           hold_screen = 2;
+           while (hold_screen) {
+               xevents();
+               Sleep(10);
+           }
+       }
+#if OPT_SESSION_MGT
+       if (resource.sessionMgt) {
+           XtVaSetValues(toplevel,
+                         XtNjoinSession, False,
+                         NULL);
+       }
+#endif
+    }
+
+    if (screen->pid > 1) {
+       (void) kill_process_group(screen->pid, SIGHUP);
+    }
+    Exit(code);
+}
+
+#ifndef VMS
+char *
+xtermFindShell(char *leaf, Bool warning)
+{
+    char *s;
+    char *d;
+    char *tmp;
+    char *result = leaf;
+
+    TRACE(("xtermFindShell(%s)\n", leaf));
+    if (*result != '\0' && strchr("+/-", *result) == 0) {
+       /* find it in $PATH */
+       if ((s = x_getenv("PATH")) != 0) {
+           if ((tmp = TypeMallocN(char, strlen(leaf) + strlen(s) + 2)) != 0) {
+               Bool found = False;
+               while (*s != '\0') {
+                   strcpy(tmp, s);
+                   for (d = tmp;; ++d) {
+                       if (*d == ':' || *d == '\0') {
+                           int skip = (*d != '\0');
+                           *d = '/';
+                           strcpy(d + 1, leaf);
+                           if (skip)
+                               ++d;
+                           s += (d - tmp);
+                           if (*tmp == '/'
+                               && strstr(tmp, "..") == 0
+                               && access(tmp, X_OK) == 0) {
+                               result = x_strdup(tmp);
+                               found = True;
+                           }
+                           break;
+                       }
+                       if (found)
+                           break;
+                   }
+                   if (found)
+                       break;
+               }
+               free(tmp);
+           }
+       }
+    }
+    TRACE(("...xtermFindShell(%s)\n", result));
+    if (*result != '/'
+       || strstr(result, "..") != 0
+       || access(result, X_OK) != 0) {
+       if (warning)
+           fprintf(stderr, "No absolute path found for shell: %s\n", result);
+       result = 0;
+    }
+    return result;
+}
+#endif /* VMS */
+
+#define ENV_HUNK(n)    (unsigned) ((((n) + 1) | 31) + 1)
+
+/*
+ * copy the environment before Setenv'ing.
+ */
+void
+xtermCopyEnv(char **oldenv)
+{
+    unsigned size;
+    char **newenv;
+
+    for (size = 0; oldenv[size] != NULL; size++) {
+       ;
+    }
+
+    newenv = TypeCallocN(char *, ENV_HUNK(size));
+    memmove(newenv, oldenv, size * sizeof(char *));
+    environ = newenv;
+}
+
+/*
+ * sets the value of var to be arg in the Unix 4.2 BSD environment env.
+ * Var should end with '=' (bindings are of the form "var=value").
+ * This procedure assumes the memory for the first level of environ
+ * was allocated using calloc, with enough extra room at the end so not
+ * to have to do a realloc().
+ */
+void
+xtermSetenv(const char *var, const char *value)
+{
+    if (value != 0) {
+       char *test;
+       int envindex = 0;
+       size_t len = strlen(var);
+       int found = -1;
+
+       TRACE(("xtermSetenv(%s=%s)\n", var, value));
+
+       while ((test = environ[envindex]) != NULL) {
+           if (strncmp(test, var, len) == 0 && test[len] == '=') {
+               found = envindex;
+               break;
+           }
+           envindex++;
+       }
+
+       if (found < 0) {
+           unsigned need = ENV_HUNK(envindex + 1);
+           unsigned have = ENV_HUNK(envindex);
+
+           if (need > have) {
+               char **newenv;
+               newenv = TypeMallocN(char *, need);
+               if (newenv == 0) {
+                   fprintf(stderr, "Cannot increase environment\n");
+                   return;
+               }
+               memmove(newenv, environ, have * sizeof(*newenv));
+               free(environ);
+               environ = newenv;
+           }
+
+           found = envindex;
+           environ[found + 1] = NULL;
+           environ = environ;
+       }
+
+       environ[found] = CastMallocN(char, 1 + len + strlen(value));
+       if (environ[found] == 0) {
+           fprintf(stderr, "Cannot allocate environment %s\n", var);
+           return;
+       }
+       sprintf(environ[found], "%s=%s", var, value);
+    }
+}
+
+/*ARGSUSED*/
+int
+xerror(Display * d, XErrorEvent * ev)
+{
+    fprintf(stderr, "%s:  warning, error event received:\n", xterm_name);
+    (void) XmuPrintDefaultErrorMessage(d, ev, stderr);
+    Exit(ERROR_XERROR);
+    return 0;                  /* appease the compiler */
+}
+
+/*ARGSUSED*/
+int
+xioerror(Display * dpy)
+{
+    int the_error = errno;
+
+    (void) fprintf(stderr,
+                  "%s:  fatal IO error %d (%s) or KillClient on X server \"%s\"\r\n",
+                  xterm_name, the_error, SysErrorMsg(the_error),
+                  DisplayString(dpy));
+
+    Exit(ERROR_XIOERROR);
+    return 0;                  /* appease the compiler */
+}
+
+void
+xt_error(String message)
+{
+    (void) fprintf(stderr, "%s Xt error: %s\n", ProgramName, message);
+
+    /*
+     * Check for the obvious - Xt does a poor job of reporting this.
+     */
+    if (x_getenv("DISPLAY") == 0) {
+       fprintf(stderr, "%s:  DISPLAY is not set\n", ProgramName);
+    }
+    exit(1);
+}
+
+int
+XStrCmp(char *s1, char *s2)
+{
+    if (s1 && s2)
+       return (strcmp(s1, s2));
+    if (s1 && *s1)
+       return (1);
+    if (s2 && *s2)
+       return (-1);
+    return (0);
+}
+
+#if OPT_TEK4014
+static void
+withdraw_window(Display * dpy, Window w, int scr)
+{
+    TRACE(("withdraw_window %#lx\n", (long) w));
+    (void) XmuUpdateMapHints(dpy, w, NULL);
+    XWithdrawWindow(dpy, w, scr);
+    return;
+}
+#endif
+
+void
+set_vt_visibility(Bool on)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("set_vt_visibility(%d)\n", on));
+    if (on) {
+       if (!screen->Vshow && xw) {
+           VTInit(xw);
+           XtMapWidget(XtParent(xw));
+#if OPT_TOOLBAR
+           /* we need both of these during initialization */
+           XtMapWidget(SHELL_OF(xw));
+           ShowToolbar(resource.toolBar);
+#endif
+           screen->Vshow = True;
+       }
+    }
+#if OPT_TEK4014
+    else {
+       if (screen->Vshow && xw) {
+           withdraw_window(XtDisplay(xw),
+                           VShellWindow(xw),
+                           XScreenNumberOfScreen(XtScreen(xw)));
+           screen->Vshow = False;
+       }
+    }
+    set_vthide_sensitivity();
+    set_tekhide_sensitivity();
+    update_vttekmode();
+    update_tekshow();
+    update_vtshow();
+#endif
+    return;
+}
+
+#if OPT_TEK4014
+void
+set_tek_visibility(Bool on)
+{
+    TRACE(("set_tek_visibility(%d)\n", on));
+
+    if (on) {
+       if (!TEK4014_SHOWN(term)) {
+           if (tekWidget == 0) {
+               TekInit();      /* will exit on failure */
+           }
+           if (tekWidget != 0) {
+               Widget tekParent = SHELL_OF(tekWidget);
+               XtRealizeWidget(tekParent);
+               XtMapWidget(XtParent(tekWidget));
+#if OPT_TOOLBAR
+               /* we need both of these during initialization */
+               XtMapWidget(tekParent);
+               XtMapWidget(tekWidget);
+#endif
+               XtOverrideTranslations(tekParent,
+                                      XtParseTranslationTable
+                                      ("<Message>WM_PROTOCOLS: DeleteWindow()"));
+               (void) XSetWMProtocols(XtDisplay(tekParent),
+                                      XtWindow(tekParent),
+                                      &wm_delete_window, 1);
+               TEK4014_SHOWN(term) = True;
+           }
+       }
+    } else {
+       if (TEK4014_SHOWN(term) && tekWidget) {
+           withdraw_window(XtDisplay(tekWidget),
+                           TShellWindow,
+                           XScreenNumberOfScreen(XtScreen(tekWidget)));
+           TEK4014_SHOWN(term) = False;
+       }
+    }
+    set_tekhide_sensitivity();
+    set_vthide_sensitivity();
+    update_vtshow();
+    update_tekshow();
+    update_vttekmode();
+    return;
+}
+
+void
+end_tek_mode(void)
+{
+    XtermWidget xw = term;
+
+    if (TEK4014_ACTIVE(xw)) {
+       FlushLog(xw);
+       longjmp(Tekend, 1);
+    }
+    return;
+}
+
+void
+end_vt_mode(void)
+{
+    XtermWidget xw = term;
+
+    if (!TEK4014_ACTIVE(xw)) {
+       FlushLog(xw);
+       TEK4014_ACTIVE(xw) = True;
+       longjmp(VTend, 1);
+    }
+    return;
+}
+
+void
+switch_modes(Bool tovt)                /* if true, then become vt mode */
+{
+    if (tovt) {
+       if (tekRefreshList)
+           TekRefresh(tekWidget);
+       end_tek_mode();         /* WARNING: this does a longjmp... */
+    } else {
+       end_vt_mode();          /* WARNING: this does a longjmp... */
+    }
+}
+
+void
+hide_vt_window(void)
+{
+    set_vt_visibility(False);
+    if (!TEK4014_ACTIVE(term))
+       switch_modes(False);    /* switch to tek mode */
+}
+
+void
+hide_tek_window(void)
+{
+    set_tek_visibility(False);
+    tekRefreshList = (TekLink *) 0;
+    if (TEK4014_ACTIVE(term))
+       switch_modes(True);     /* does longjmp to vt mode */
+}
+#endif /* OPT_TEK4014 */
+
+static const char *
+skip_punct(const char *s)
+{
+    while (*s == '-' || *s == '/' || *s == '+' || *s == '#' || *s == '%') {
+       ++s;
+    }
+    return s;
+}
+
+static int
+cmp_options(const void *a, const void *b)
+{
+    const char *s1 = skip_punct(((const OptionHelp *) a)->opt);
+    const char *s2 = skip_punct(((const OptionHelp *) b)->opt);
+    return strcmp(s1, s2);
+}
+
+static int
+cmp_resources(const void *a, const void *b)
+{
+    return strcmp(((const XrmOptionDescRec *) a)->option,
+                 ((const XrmOptionDescRec *) b)->option);
+}
+
+XrmOptionDescRec *
+sortedOptDescs(XrmOptionDescRec * descs, Cardinal res_count)
+{
+    static XrmOptionDescRec *res_array = 0;
+
+#ifdef NO_LEAKS
+    if (descs == 0) {
+       if (res_array != 0) {
+           free(res_array);
+           res_array = 0;
+       }
+    } else
+#endif
+    if (res_array == 0) {
+       Cardinal j;
+
+       /* make a sorted index to 'resources' */
+       res_array = TypeCallocN(XrmOptionDescRec, res_count);
+       if (res_array != 0) {
+           for (j = 0; j < res_count; j++)
+               res_array[j] = descs[j];
+           qsort(res_array, (size_t) res_count, sizeof(*res_array), cmp_resources);
+       }
+    }
+    return res_array;
+}
+
+/*
+ * The first time this is called, construct sorted index to the main program's
+ * list of options, taking into account the on/off options which will be
+ * compressed into one token.  It's a lot simpler to do it this way than
+ * maintain the list in sorted form with lots of ifdef's.
+ */
+OptionHelp *
+sortedOpts(OptionHelp * options, XrmOptionDescRec * descs, Cardinal numDescs)
+{
+    static OptionHelp *opt_array = 0;
+
+#ifdef NO_LEAKS
+    if (descs == 0 && opt_array != 0) {
+       sortedOptDescs(descs, numDescs);
+       free(opt_array);
+       opt_array = 0;
+       return 0;
+    } else if (options == 0 || descs == 0) {
+       return 0;
+    }
+#endif
+
+    if (opt_array == 0) {
+       size_t opt_count, j;
+#if OPT_TRACE
+       Cardinal k;
+       XrmOptionDescRec *res_array = sortedOptDescs(descs, numDescs);
+       int code;
+       const char *mesg;
+#else
+       (void) descs;
+       (void) numDescs;
+#endif
+
+       /* count 'options' and make a sorted index to it */
+       for (opt_count = 0; options[opt_count].opt != 0; ++opt_count) {
+           ;
+       }
+       opt_array = TypeCallocN(OptionHelp, opt_count + 1);
+       for (j = 0; j < opt_count; j++)
+           opt_array[j] = options[j];
+       qsort(opt_array, opt_count, sizeof(OptionHelp), cmp_options);
+
+       /* supply the "turn on/off" strings if needed */
+#if OPT_TRACE
+       for (j = 0; j < opt_count; j++) {
+           if (!strncmp(opt_array[j].opt, "-/+", 3)) {
+               char temp[80];
+               const char *name = opt_array[j].opt + 3;
+               for (k = 0; k < numDescs; ++k) {
+                   const char *value = res_array[k].value;
+                   if (res_array[k].option[0] == '-') {
+                       code = -1;
+                   } else if (res_array[k].option[0] == '+') {
+                       code = 1;
+                   } else {
+                       code = 0;
+                   }
+                   strcpy(temp, opt_array[j].desc);
+                   if (x_strindex(temp, "inhibit") != 0)
+                       code = -code;
+                   if (code != 0
+                       && res_array[k].value != 0
+                       && !strcmp(name, res_array[k].option + 1)) {
+                       if (((code < 0) && !strcmp(value, "on"))
+                           || ((code > 0) && !strcmp(value, "off"))
+                           || ((code > 0) && !strcmp(value, "0"))) {
+                           mesg = "turn on/off";
+                       } else {
+                           mesg = "turn off/on";
+                       }
+                       if (strncmp(mesg, opt_array[j].desc, strlen(mesg))) {
+                           if (strncmp(opt_array[j].desc, "turn ", 5)) {
+                               char *s = CastMallocN(char,
+                                                     strlen(mesg)
+                                                     + 1
+                                                     + strlen(opt_array[j].desc));
+                               if (s != 0) {
+                                   sprintf(s, "%s %s", mesg, opt_array[j].desc);
+                                   opt_array[j].desc = s;
+                               }
+                           } else {
+                               TRACE(("OOPS "));
+                           }
+                       }
+                       TRACE(("%s: %s %s: %s (%s)\n",
+                              mesg,
+                              res_array[k].option,
+                              res_array[k].value,
+                              opt_array[j].opt,
+                              opt_array[j].desc));
+                       break;
+                   }
+               }
+           }
+       }
+#endif
+    }
+    return opt_array;
+}
+
+/*
+ * Report the character-type locale that xterm was started in.
+ */
+char *
+xtermEnvLocale(void)
+{
+    static char *result;
+
+    if (result == 0) {
+       if ((result = x_nonempty(setlocale(LC_CTYPE, 0))) == 0) {
+           result = x_strdup("C");
+       } else {
+           result = x_strdup(result);
+       }
+       TRACE(("xtermEnvLocale ->%s\n", result));
+    }
+    return result;
+}
+
+char *
+xtermEnvEncoding(void)
+{
+    static char *result;
+
+    if (result == 0) {
+#ifdef HAVE_LANGINFO_CODESET
+       result = nl_langinfo(CODESET);
+#else
+       char *locale = xtermEnvLocale();
+       if (!strcmp(locale, "C") || !strcmp(locale, "POSIX")) {
+           result = "ASCII";
+       } else {
+           result = "ISO-8859-1";
+       }
+#endif
+       TRACE(("xtermEnvEncoding ->%s\n", result));
+    }
+    return result;
+}
+
+#if OPT_WIDE_CHARS
+/*
+ * Tell whether xterm was started in a locale that uses UTF-8 encoding for
+ * characters.  That environment is inherited by subprocesses and used in
+ * various library calls.
+ */
+Bool
+xtermEnvUTF8(void)
+{
+    static Bool init = False;
+    static Bool result = False;
+
+    if (!init) {
+       init = True;
+#ifdef HAVE_LANGINFO_CODESET
+       result = (strcmp(xtermEnvEncoding(), "UTF-8") == 0);
+#else
+       result = (strstr(xtermEnvLocale(), "UTF-8") != NULL);
+#endif
+       TRACE(("xtermEnvUTF8 ->%s\n", BtoS(result)));
+    }
+    return result;
+}
+#endif /* OPT_WIDE_CHARS */
+
+/*
+ * Returns the version-string used in the "-v' message as well as a few other
+ * places.  It is derived (when possible) from the __vendorversion__ symbol
+ * that some newer imake configurations define.
+ */
+char *
+xtermVersion(void)
+{
+    static char vendor_version[] = __vendorversion__;
+    static char *result;
+
+    if (result == 0) {
+       char *vendor = vendor_version;
+       char first[BUFSIZ];
+       char second[BUFSIZ];
+
+       result = CastMallocN(char, strlen(vendor) + 9);
+       if (result == 0)
+           result = vendor;
+       else {
+           /* some vendors leave trash in this string */
+           for (;;) {
+               if (!strncmp(vendor, "Version ", (size_t) 8))
+                   vendor += 8;
+               else if (isspace(CharOf(*vendor)))
+                   ++vendor;
+               else
+                   break;
+           }
+           if (strlen(vendor) < BUFSIZ &&
+               sscanf(vendor, "%[0-9.] %[A-Za-z_0-9.]", first, second) == 2)
+               sprintf(result, "%s %s(%d)", second, first, XTERM_PATCH);
+           else
+               sprintf(result, "%s(%d)", vendor, XTERM_PATCH);
+       }
+    }
+    return result;
+}
+
+/*
+ * Check if the current widget, or any parent, is the VT100 "xterm" widget.
+ */
+XtermWidget
+getXtermWidget(Widget w)
+{
+    XtermWidget xw;
+
+    if (w == 0) {
+       xw = (XtermWidget) CURRENT_EMU();
+       if (!IsXtermWidget(xw)) {
+           xw = 0;
+       }
+    } else if (IsXtermWidget(w)) {
+       xw = (XtermWidget) w;
+    } else {
+       xw = getXtermWidget(XtParent(w));
+    }
+    TRACE2(("getXtermWidget %p -> %p\n", w, xw));
+    return xw;
+}
diff --git a/os2main.c b/os2main.c
new file mode 100644 (file)
index 0000000..d560e8c
--- /dev/null
+++ b/os2main.c
@@ -0,0 +1,2218 @@
+/* $XTermId: os2main.c,v 1.265 2010/06/20 21:27:07 tom Exp $ */
+
+/* removed all foreign stuff to get the code more clear (hv)
+ * and did some rewrite for the obscure OS/2 environment
+ */
+
+/***********************************************************
+
+Copyright (c) 1987, 1988  X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be used in
+advertising or publicity pertaining to distribution of the software
+without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* os2main.c */
+#define INCL_DOSFILEMGR
+#define INCL_DOSDEVIOCTL
+#define INCL_DOSSEMAPHORES
+#ifdef __INNOTEK_LIBC__
+#define INCL_DOSDEVICES
+#endif
+#define I_NEED_OS2_H
+#include <os2.h>
+#define XTERM_MAIN
+
+#define RES_OFFSET(field)      XtOffsetOf(XTERM_RESOURCE, field)
+
+#include <xterm.h>
+
+#include <X11/cursorfont.h>
+#ifdef I18N
+#include <X11/Xlocale.h>
+#endif
+
+#if OPT_TOOLBAR
+
+#if defined(HAVE_LIB_XAW)
+#include <X11/Xaw/Form.h>
+#elif defined(HAVE_LIB_XAW3D)
+#include <X11/Xaw3d/Form.h>
+#elif defined(HAVE_LIB_NEXTAW)
+#include <X11/neXtaw/Form.h>
+#elif defined(HAVE_LIB_XAWPLUS)
+#include <X11/XawPlus/Form.h>
+#endif
+
+#endif /* OPT_TOOLBAR */
+
+#include <pwd.h>
+#include <ctype.h>
+
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <main.h>
+#include <xstrings.h>
+#include <xtermcap.h>
+#include <xterm_io.h>
+
+#if OPT_WIDE_CHARS
+#include <charclass.h>
+#endif
+
+int
+setpgrp(pid_t pid, gid_t pgid)
+{
+    return 0;
+}
+
+int
+chown(const char *fn, pid_t pid, gid_t gid)
+{
+    return 0;
+}
+
+char *
+ttyname(int fd)
+{
+    return "/dev/tty";
+}
+
+#include <sys/stat.h>
+#include <sys/param.h>         /* for NOFILE */
+#include <stdio.h>
+#include <signal.h>
+
+static SIGNAL_T reapchild(int n);
+static int spawnXTerm(XtermWidget /* xw */ );
+static void resize_termcap(XtermWidget xw);
+static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode);
+
+static Bool added_utmp_entry = False;
+
+static uid_t save_ruid;
+static gid_t save_rgid;
+
+/*
+** Ordinarily it should be okay to omit the assignment in the following
+** statement. Apparently the c89 compiler on AIX 4.1.3 has a bug, or does
+** it? Without the assignment though the compiler will init command_to_exec
+** to 0xffffffff instead of NULL; and subsequent usage, e.g. in spawnXTerm() to
+** SEGV.
+*/
+static char **command_to_exec = NULL;
+
+#if OPT_LUIT_PROG
+static char **command_to_exec_with_luit = NULL;
+#endif
+
+/* The following structures are initialized in main() in order
+** to eliminate any assumptions about the internal order of their
+** contents.
+*/
+static struct termio d_tio;
+
+/* allow use of system default characters if defined and reasonable */
+#ifndef CEOF
+#define CEOF CONTROL('D')
+#endif
+#ifndef CEOL
+#define CEOL 0
+#endif
+#ifndef CFLUSH
+#define CFLUSH CONTROL('O')
+#endif
+#ifndef CLNEXT
+#define CLNEXT CONTROL('V')
+#endif
+#ifndef CNUL
+#define CNUL 0
+#endif
+#ifndef CQUIT
+#define CQUIT CONTROL('\\')
+#endif
+#ifndef CRPRNT
+#define CRPRNT CONTROL('R')
+#endif
+#ifndef CSTART
+#define CSTART CONTROL('Q')
+#endif
+#ifndef CSTOP
+#define CSTOP CONTROL('S')
+#endif
+#ifndef CSUSP
+#define CSUSP CONTROL('Z')
+#endif
+#ifndef CSWTCH
+#define CSWTCH 0
+#endif
+#ifndef CWERASE
+#define CWERASE CONTROL('W')
+#endif
+
+#define TERMIO_STRUCT struct termio
+
+/*
+ * SYSV has the termio.c_cc[V] and ltchars; BSD has tchars and ltchars;
+ * SVR4 has only termio.c_cc, but it includes everything from ltchars.
+ * POSIX termios has termios.c_cc, which is similar to SVR4.
+ */
+#define TTYMODE(name) { name, sizeof(name)-1, 0, 0 }
+static Boolean override_tty_modes = False;
+/* *INDENT-OFF* */
+static struct _xttymodes {
+    const char *name;
+    size_t len;
+    int set;
+    int value;
+} ttymodelist[] = {
+    TTYMODE("intr"),           /* tchars.t_intrc ; VINTR */
+#define XTTYMODE_intr  0
+    TTYMODE("quit"),           /* tchars.t_quitc ; VQUIT */
+#define XTTYMODE_quit  1
+    TTYMODE("erase"),          /* sgttyb.sg_erase ; VERASE */
+#define XTTYMODE_erase 2
+    TTYMODE("kill"),           /* sgttyb.sg_kill ; VKILL */
+#define XTTYMODE_kill  3
+    TTYMODE("eof"),            /* tchars.t_eofc ; VEOF */
+#define XTTYMODE_eof   4
+    TTYMODE("eol"),            /* VEOL */
+#define XTTYMODE_eol   5
+    TTYMODE("swtch"),          /* VSWTCH */
+#define XTTYMODE_swtch 6
+    TTYMODE("start"),          /* tchars.t_startc ; VSTART */
+#define XTTYMODE_start 7
+    TTYMODE("stop"),           /* tchars.t_stopc ; VSTOP */
+#define XTTYMODE_stop  8
+    TTYMODE("brk"),            /* tchars.t_brkc */
+#define XTTYMODE_brk   9
+    TTYMODE("susp"),           /* ltchars.t_suspc ; VSUSP */
+#define XTTYMODE_susp  10
+    TTYMODE("dsusp"),          /* ltchars.t_dsuspc ; VDSUSP */
+#define XTTYMODE_dsusp 11
+    TTYMODE("rprnt"),          /* ltchars.t_rprntc ; VREPRINT */
+#define XTTYMODE_rprnt 12
+    TTYMODE("flush"),          /* ltchars.t_flushc ; VDISCARD */
+#define XTTYMODE_flush 13
+    TTYMODE("weras"),          /* ltchars.t_werasc ; VWERASE */
+#define XTTYMODE_weras 14
+    TTYMODE("lnext"),          /* ltchars.t_lnextc ; VLNEXT */
+#define XTTYMODE_lnext 15
+    { NULL,    0, 0, '\0' },   /* end of data */
+};
+/* *INDENT-ON* */
+
+#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value
+
+static int parse_tty_modes(char *s, struct _xttymodes *modelist);
+
+static char passedPty[2];      /* name if pty if slave */
+
+static int Console;
+#include <X11/Xmu/SysUtil.h>   /* XmuGetHostname */
+#define MIT_CONSOLE_LEN        12
+#define MIT_CONSOLE "MIT_CONSOLE_"
+static char mit_console_name[255 + MIT_CONSOLE_LEN + 1] = MIT_CONSOLE;
+static Atom mit_console;
+
+static int tslot;
+static jmp_buf env;
+
+/* used by VT (charproc.c) */
+
+static XtResource application_resources[] =
+{
+    Sres("name", "Name", xterm_name, DFT_TERMTYPE),
+    Sres("iconGeometry", "IconGeometry", icon_geometry, NULL),
+    Sres(XtNtitle, XtCTitle, title, NULL),
+    Sres(XtNiconName, XtCIconName, icon_name, NULL),
+    Sres("termName", "TermName", term_name, NULL),
+    Sres("ttyModes", "TtyModes", tty_modes, NULL),
+    Bres("hold", "Hold", hold_screen, False),
+    Bres("utmpInhibit", "UtmpInhibit", utmpInhibit, False),
+    Bres("utmpDisplayId", "UtmpDisplayId", utmpDisplayId, True),
+    Bres("messages", "Messages", messages, True),
+    Ires("minBufSize", "MinBufSize", minBufSize, 4096),
+    Ires("maxBufSize", "MaxBufSize", maxBufSize, 32768),
+    Sres("menuLocale", "MenuLocale", menuLocale, ""),
+    Sres("keyboardType", "KeyboardType", keyboardType, "unknown"),
+#if OPT_SUNPC_KBD
+    Bres("sunKeyboard", "SunKeyboard", sunKeyboard, False),
+#endif
+#if OPT_HP_FUNC_KEYS
+    Bres("hpFunctionKeys", "HpFunctionKeys", hpFunctionKeys, False),
+#endif
+#if OPT_SCO_FUNC_KEYS
+    Bres("scoFunctionKeys", "ScoFunctionKeys", scoFunctionKeys, False),
+#endif
+#if OPT_SUN_FUNC_KEYS
+    Bres("sunFunctionKeys", "SunFunctionKeys", sunFunctionKeys, False),
+#endif
+#if OPT_TCAP_FKEYS
+    Bres("tcapFunctionKeys", "TcapFunctionKeys", termcapKeys, False),
+#endif
+#if OPT_INITIAL_ERASE
+    Bres("ptyInitialErase", "PtyInitialErase", ptyInitialErase, DEF_INITIAL_ERASE),
+    Bres("backarrowKeyIsErase", "BackarrowKeyIsErase", backarrow_is_erase, DEF_BACKARO_ERASE),
+#endif
+    Bres("useInsertMode", "UseInsertMode", useInsertMode, False),
+#if OPT_ZICONBEEP
+    Ires("zIconBeep", "ZIconBeep", zIconBeep, 0),
+#endif
+#if OPT_PTY_HANDSHAKE
+    Bres("waitForMap", "WaitForMap", wait_for_map, False),
+    Bres("ptyHandshake", "PtyHandshake", ptyHandshake, True),
+    Bres("ptySttySize", "PtySttySize", ptySttySize, DEF_PTY_STTY_SIZE),
+#endif
+#if OPT_SAME_NAME
+    Bres("sameName", "SameName", sameName, True),
+#endif
+#if OPT_SESSION_MGT
+    Bres("sessionMgt", "SessionMgt", sessionMgt, True),
+#endif
+#if OPT_TOOLBAR
+    Bres(XtNtoolBar, XtCToolBar, toolBar, True),
+#endif
+#if OPT_MAXIMIZE
+    Bres(XtNmaximized, XtCMaximized, maximized, False),
+#endif
+};
+
+static String fallback_resources[] =
+{
+    "*SimpleMenu*menuLabel.vertSpace: 100",
+    "*SimpleMenu*HorizontalMargins: 16",
+    "*SimpleMenu*Sme.height: 16",
+    "*SimpleMenu*Cursor: left_ptr",
+    "*mainMenu.Label:  Main Options (no app-defaults)",
+    "*vtMenu.Label:  VT Options (no app-defaults)",
+    "*fontMenu.Label:  VT Fonts (no app-defaults)",
+#if OPT_TEK4014
+    "*tekMenu.Label:  Tek Options (no app-defaults)",
+#endif
+    NULL
+};
+
+/* Command line options table.  Only resources are entered here...there is a
+   pass over the remaining options after XrmParseCommand is let loose. */
+/* *INDENT-OFF* */
+static XrmOptionDescRec optionDescList[] = {
+{"-geometry",  "*vt100.geometry",XrmoptionSepArg,      (XPointer) NULL},
+{"-132",       "*c132",        XrmoptionNoArg,         (XPointer) "on"},
+{"+132",       "*c132",        XrmoptionNoArg,         (XPointer) "off"},
+{"-ah",                "*alwaysHighlight", XrmoptionNoArg,     (XPointer) "on"},
+{"+ah",                "*alwaysHighlight", XrmoptionNoArg,     (XPointer) "off"},
+{"-aw",                "*autoWrap",    XrmoptionNoArg,         (XPointer) "on"},
+{"+aw",                "*autoWrap",    XrmoptionNoArg,         (XPointer) "off"},
+#ifndef NO_ACTIVE_ICON
+{"-ai",                "*activeIcon",  XrmoptionNoArg,         (XPointer) "off"},
+{"+ai",                "*activeIcon",  XrmoptionNoArg,         (XPointer) "on"},
+#endif /* NO_ACTIVE_ICON */
+{"-b",         "*internalBorder",XrmoptionSepArg,      (XPointer) NULL},
+{"-bc",                "*cursorBlink", XrmoptionNoArg,         (XPointer) "on"},
+{"+bc",                "*cursorBlink", XrmoptionNoArg,         (XPointer) "off"},
+{"-bcf",       "*cursorOffTime",XrmoptionSepArg,       (XPointer) NULL},
+{"-bcn",       "*cursorOnTime",XrmoptionSepArg,        (XPointer) NULL},
+{"-bdc",       "*colorBDMode", XrmoptionNoArg,         (XPointer) "off"},
+{"+bdc",       "*colorBDMode", XrmoptionNoArg,         (XPointer) "on"},
+{"-cb",                "*cutToBeginningOfLine", XrmoptionNoArg, (XPointer) "off"},
+{"+cb",                "*cutToBeginningOfLine", XrmoptionNoArg, (XPointer) "on"},
+{"-cc",                "*charClass",   XrmoptionSepArg,        (XPointer) NULL},
+{"-cm",                "*colorMode",   XrmoptionNoArg,         (XPointer) "off"},
+{"+cm",                "*colorMode",   XrmoptionNoArg,         (XPointer) "on"},
+{"-cn",                "*cutNewline",  XrmoptionNoArg,         (XPointer) "off"},
+{"+cn",                "*cutNewline",  XrmoptionNoArg,         (XPointer) "on"},
+{"-cr",                "*cursorColor", XrmoptionSepArg,        (XPointer) NULL},
+{"-cu",                "*curses",      XrmoptionNoArg,         (XPointer) "on"},
+{"+cu",                "*curses",      XrmoptionNoArg,         (XPointer) "off"},
+{"-dc",                "*dynamicColors",XrmoptionNoArg,        (XPointer) "off"},
+{"+dc",                "*dynamicColors",XrmoptionNoArg,        (XPointer) "on"},
+{"-fb",                "*boldFont",    XrmoptionSepArg,        (XPointer) NULL},
+{"-fbb",       "*freeBoldBox", XrmoptionNoArg,         (XPointer)"off"},
+{"+fbb",       "*freeBoldBox", XrmoptionNoArg,         (XPointer)"on"},
+{"-fbx",       "*forceBoxChars", XrmoptionNoArg,       (XPointer)"off"},
+{"+fbx",       "*forceBoxChars", XrmoptionNoArg,       (XPointer)"on"},
+#ifndef NO_ACTIVE_ICON
+{"-fi",                "*iconFont",    XrmoptionSepArg,        (XPointer) NULL},
+#endif /* NO_ACTIVE_ICON */
+#if OPT_RENDERFONT
+{"-fa",                "*faceName",    XrmoptionSepArg,        (XPointer) NULL},
+{"-fd",                "*faceNameDoublesize", XrmoptionSepArg, (XPointer) NULL},
+{"-fs",                "*faceSize",    XrmoptionSepArg,        (XPointer) NULL},
+#endif
+#if OPT_WIDE_CHARS
+{"-fw",                "*wideFont",    XrmoptionSepArg,        (XPointer) NULL},
+{"-fwb",       "*wideBoldFont", XrmoptionSepArg,       (XPointer) NULL},
+#endif
+#if OPT_INPUT_METHOD
+{"-fx",                "*ximFont",     XrmoptionSepArg,        (XPointer) NULL},
+#endif
+#if OPT_HIGHLIGHT_COLOR
+{"-hc",                "*highlightColor", XrmoptionSepArg,     (XPointer) NULL},
+{"-hm",                "*highlightColorMode", XrmoptionNoArg,  (XPointer) "on"},
+{"+hm",                "*highlightColorMode", XrmoptionNoArg,  (XPointer) "off"},
+{"-selfg",     "*highlightTextColor", XrmoptionSepArg, (XPointer) NULL},
+{"-selbg",     "*highlightColor", XrmoptionSepArg,     (XPointer) NULL},
+#endif
+#if OPT_HP_FUNC_KEYS
+{"-hf",                "*hpFunctionKeys",XrmoptionNoArg,       (XPointer) "on"},
+{"+hf",                "*hpFunctionKeys",XrmoptionNoArg,       (XPointer) "off"},
+#endif
+{"-hold",      "*hold",        XrmoptionNoArg,         (XPointer) "on"},
+{"+hold",      "*hold",        XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_INITIAL_ERASE
+{"-ie",                "*ptyInitialErase", XrmoptionNoArg,     (XPointer) "on"},
+{"+ie",                "*ptyInitialErase", XrmoptionNoArg,     (XPointer) "off"},
+#endif
+{"-j",         "*jumpScroll",  XrmoptionNoArg,         (XPointer) "on"},
+{"+j",         "*jumpScroll",  XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_C1_PRINT
+{"-k8",                "*allowC1Printable", XrmoptionNoArg,    (XPointer) "on"},
+{"+k8",                "*allowC1Printable", XrmoptionNoArg,    (XPointer) "off"},
+#endif
+{"-kt",                "*keyboardType", XrmoptionSepArg,       (XPointer) NULL},
+{"+kt",                "*keyboardType", XrmoptionSepArg,       (XPointer) NULL},
+/* parse logging options anyway for compatibility */
+{"-l",         "*logging",     XrmoptionNoArg,         (XPointer) "on"},
+{"+l",         "*logging",     XrmoptionNoArg,         (XPointer) "off"},
+{"-lf",                "*logFile",     XrmoptionSepArg,        (XPointer) NULL},
+{"-ls",                "*loginShell",  XrmoptionNoArg,         (XPointer) "on"},
+{"+ls",                "*loginShell",  XrmoptionNoArg,         (XPointer) "off"},
+{"-mb",                "*marginBell",  XrmoptionNoArg,         (XPointer) "on"},
+{"+mb",                "*marginBell",  XrmoptionNoArg,         (XPointer) "off"},
+{"-mc",                "*multiClickTime", XrmoptionSepArg,     (XPointer) NULL},
+{"-mesg",      "*messages",    XrmoptionNoArg,         (XPointer) "off"},
+{"+mesg",      "*messages",    XrmoptionNoArg,         (XPointer) "on"},
+{"-ms",                "*pointerColor",XrmoptionSepArg,        (XPointer) NULL},
+{"-nb",                "*nMarginBell", XrmoptionSepArg,        (XPointer) NULL},
+{"-nul",       "*underLine",   XrmoptionNoArg,         (XPointer) "off"},
+{"+nul",       "*underLine",   XrmoptionNoArg,         (XPointer) "on"},
+{"-pc",                "*boldColors",  XrmoptionNoArg,         (XPointer) "on"},
+{"+pc",                "*boldColors",  XrmoptionNoArg,         (XPointer) "off"},
+{"-rw",                "*reverseWrap", XrmoptionNoArg,         (XPointer) "on"},
+{"+rw",                "*reverseWrap", XrmoptionNoArg,         (XPointer) "off"},
+{"-s",         "*multiScroll", XrmoptionNoArg,         (XPointer) "on"},
+{"+s",         "*multiScroll", XrmoptionNoArg,         (XPointer) "off"},
+{"-sb",                "*scrollBar",   XrmoptionNoArg,         (XPointer) "on"},
+{"+sb",                "*scrollBar",   XrmoptionNoArg,         (XPointer) "off"},
+#ifdef SCROLLBAR_RIGHT
+{"-leftbar",   "*rightScrollBar", XrmoptionNoArg,      (XPointer) "off"},
+{"-rightbar",  "*rightScrollBar", XrmoptionNoArg,      (XPointer) "on"},
+#endif
+{"-rvc",       "*colorRVMode", XrmoptionNoArg,         (XPointer) "off"},
+{"+rvc",       "*colorRVMode", XrmoptionNoArg,         (XPointer) "on"},
+{"-sf",                "*sunFunctionKeys", XrmoptionNoArg,     (XPointer) "on"},
+{"+sf",                "*sunFunctionKeys", XrmoptionNoArg,     (XPointer) "off"},
+{"-si",                "*scrollTtyOutput", XrmoptionNoArg,     (XPointer) "off"},
+{"+si",                "*scrollTtyOutput", XrmoptionNoArg,     (XPointer) "on"},
+{"-sk",                "*scrollKey",   XrmoptionNoArg,         (XPointer) "on"},
+{"+sk",                "*scrollKey",   XrmoptionNoArg,         (XPointer) "off"},
+{"-sl",                "*saveLines",   XrmoptionSepArg,        (XPointer) NULL},
+#if OPT_SUNPC_KBD
+{"-sp",                "*sunKeyboard", XrmoptionNoArg,         (XPointer) "on"},
+{"+sp",                "*sunKeyboard", XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_TEK4014
+{"-t",         "*tekStartup",  XrmoptionNoArg,         (XPointer) "on"},
+{"+t",         "*tekStartup",  XrmoptionNoArg,         (XPointer) "off"},
+#endif
+{"-ti",                "*decTerminalID",XrmoptionSepArg,       (XPointer) NULL},
+{"-tm",                "*ttyModes",    XrmoptionSepArg,        (XPointer) NULL},
+{"-tn",                "*termName",    XrmoptionSepArg,        (XPointer) NULL},
+#if OPT_WIDE_CHARS
+{"-u8",                "*utf8",        XrmoptionNoArg,         (XPointer) "2"},
+{"+u8",                "*utf8",        XrmoptionNoArg,         (XPointer) "0"},
+#endif
+#if OPT_LUIT_PROG
+{"-lc",                "*locale",      XrmoptionNoArg,         (XPointer) "on"},
+{"+lc",                "*locale",      XrmoptionNoArg,         (XPointer) "off"},
+{"-lcc",       "*localeFilter",XrmoptionSepArg,        (XPointer) NULL},
+{"-en",                "*locale",      XrmoptionSepArg,        (XPointer) NULL},
+#endif
+{"-uc",                "*cursorUnderLine", XrmoptionNoArg,     (XPointer) "on"},
+{"+uc",                "*cursorUnderLine", XrmoptionNoArg,     (XPointer) "off"},
+{"-ulc",       "*colorULMode", XrmoptionNoArg,         (XPointer) "off"},
+{"+ulc",       "*colorULMode", XrmoptionNoArg,         (XPointer) "on"},
+{"-ulit",       "*italicULMode", XrmoptionNoArg,        (XPointer) "off"},
+{"+ulit",       "*italicULMode", XrmoptionNoArg,        (XPointer) "on"},
+{"-ut",                "*utmpInhibit", XrmoptionNoArg,         (XPointer) "on"},
+{"+ut",                "*utmpInhibit", XrmoptionNoArg,         (XPointer) "off"},
+{"-im",                "*useInsertMode", XrmoptionNoArg,       (XPointer) "on"},
+{"+im",                "*useInsertMode", XrmoptionNoArg,       (XPointer) "off"},
+{"-vb",                "*visualBell",  XrmoptionNoArg,         (XPointer) "on"},
+{"+vb",                "*visualBell",  XrmoptionNoArg,         (XPointer) "off"},
+{"-pob",       "*popOnBell",   XrmoptionNoArg,         (XPointer) "on"},
+{"+pob",       "*popOnBell",   XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_WIDE_CHARS
+{"-wc",                "*wideChars",   XrmoptionNoArg,         (XPointer) "on"},
+{"+wc",                "*wideChars",   XrmoptionNoArg,         (XPointer) "off"},
+{"-mk_width",  "*mkWidth",     XrmoptionNoArg,         (XPointer) "on"},
+{"+mk_width",  "*mkWidth",     XrmoptionNoArg,         (XPointer) "off"},
+{"-cjk_width", "*cjkWidth",    XrmoptionNoArg,         (XPointer) "on"},
+{"+cjk_width", "*cjkWidth",    XrmoptionNoArg,         (XPointer) "off"},
+#endif
+{"-wf",                "*waitForMap",  XrmoptionNoArg,         (XPointer) "on"},
+{"+wf",                "*waitForMap",  XrmoptionNoArg,         (XPointer) "off"},
+#if OPT_ZICONBEEP
+{"-ziconbeep", "*zIconBeep",   XrmoptionSepArg,        (XPointer) NULL},
+#endif
+#if OPT_SAME_NAME
+{"-samename",  "*sameName",    XrmoptionNoArg,         (XPointer) "on"},
+{"+samename",  "*sameName",    XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_SESSION_MGT
+{"-sm",                "*sessionMgt",  XrmoptionNoArg,         (XPointer) "on"},
+{"+sm",                "*sessionMgt",  XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_TOOLBAR
+{"-tb",                "*"XtNtoolBar,  XrmoptionNoArg,         (XPointer) "on"},
+{"+tb",                "*"XtNtoolBar,  XrmoptionNoArg,         (XPointer) "off"},
+#endif
+#if OPT_MAXIMIZE
+{"-maximized", "*maximized",   XrmoptionNoArg,         (XPointer) "on"},
+{"+maximized", "*maximized",   XrmoptionNoArg,         (XPointer) "off"},
+#endif
+/* options that we process ourselves */
+{"-help",      NULL,           XrmoptionSkipNArgs,     (XPointer) NULL},
+{"-version",   NULL,           XrmoptionSkipNArgs,     (XPointer) NULL},
+{"-class",     NULL,           XrmoptionSkipArg,       (XPointer) NULL},
+{"-e",         NULL,           XrmoptionSkipLine,      (XPointer) NULL},
+{"-into",      NULL,           XrmoptionSkipArg,       (XPointer) NULL},
+/* bogus old compatibility stuff for which there are
+   standard XtOpenApplication options now */
+{"%",          "*tekGeometry", XrmoptionStickyArg,     (XPointer) NULL},
+{"#",          ".iconGeometry",XrmoptionStickyArg,     (XPointer) NULL},
+{"-T",         ".title",       XrmoptionSepArg,        (XPointer) NULL},
+{"-n",         "*iconName",    XrmoptionSepArg,        (XPointer) NULL},
+{"-r",         "*reverseVideo",XrmoptionNoArg,         (XPointer) "on"},
+{"+r",         "*reverseVideo",XrmoptionNoArg,         (XPointer) "off"},
+{"-rv",                "*reverseVideo",XrmoptionNoArg,         (XPointer) "on"},
+{"+rv",                "*reverseVideo",XrmoptionNoArg,         (XPointer) "off"},
+{"-w",         ".borderWidth", XrmoptionSepArg,        (XPointer) NULL},
+};
+
+static OptionHelp xtermOptions[] = {
+{ "-version",              "print the version number" },
+{ "-help",                 "print out this message" },
+{ "-display displayname",  "X server to contact" },
+{ "-geometry geom",        "size (in characters) and position" },
+{ "-/+rv",                 "turn on/off reverse video" },
+{ "-bg color",             "background color" },
+{ "-fg color",             "foreground color" },
+{ "-bd color",             "border color" },
+{ "-bw number",            "border width in pixels" },
+{ "-fn fontname",          "normal text font" },
+{ "-fb fontname",          "bold text font" },
+{ "-/+fbb",                "turn on/off normal/bold font comparison inhibit"},
+{ "-/+fbx",                "turn off/on linedrawing characters"},
+#if OPT_RENDERFONT
+{ "-fa pattern",           "FreeType font-selection pattern" },
+{ "-fd pattern",           "FreeType Doublesize font-selection pattern" },
+{ "-fs size",              "FreeType font-size" },
+#endif
+#if OPT_WIDE_CHARS
+{ "-fw fontname",          "doublewidth text font" },
+{ "-fwb fontname",         "doublewidth bold text font" },
+#endif
+#if OPT_INPUT_METHOD
+{ "-fx fontname",          "XIM fontset" },
+#endif
+{ "-iconic",               "start iconic" },
+{ "-name string",          "client instance, icon, and title strings" },
+{ "-class string",         "class string (XTerm)" },
+{ "-title string",         "title string" },
+{ "-xrm resourcestring",   "additional resource specifications" },
+{ "-/+132",                "turn on/off 80/132 column switching" },
+{ "-/+ah",                 "turn on/off always highlight" },
+#ifndef NO_ACTIVE_ICON
+{ "-/+ai",                 "turn off/on active icon" },
+{ "-fi fontname",          "icon font for active icon" },
+#endif /* NO_ACTIVE_ICON */
+{ "-b number",             "internal border in pixels" },
+{ "-/+bc",                 "turn on/off text cursor blinking" },
+{ "-bcf milliseconds",     "time text cursor is off when blinking"},
+{ "-bcn milliseconds",     "time text cursor is on when blinking"},
+{ "-/+bdc",                "turn off/on display of bold as color"},
+{ "-/+cb",                 "turn on/off cut-to-beginning-of-line inhibit" },
+{ "-cc classrange",        "specify additional character classes" },
+{ "-/+cm",                 "turn off/on ANSI color mode" },
+{ "-/+cn",                 "turn on/off cut newline inhibit" },
+{ "-cr color",             "text cursor color" },
+{ "-/+cu",                 "turn on/off curses emulation" },
+{ "-/+dc",                 "turn off/on dynamic color selection" },
+#if OPT_HIGHLIGHT_COLOR
+{ "-/+hm",                 "turn on/off selection-color override" },
+{ "-selbg color",          "selection background color" },
+{ "-selfg color",          "selection foreground color" },
+#endif
+#if OPT_HP_FUNC_KEYS
+{ "-/+hf",                 "turn on/off HP Function Key escape codes" },
+#endif
+{ "-/+hold",               "turn on/off logic that retains window after exit" },
+#if OPT_INITIAL_ERASE
+{ "-/+ie",                 "turn on/off initialization of 'erase' from pty" },
+#endif
+{ "-/+im",                 "use insert mode for TERMCAP" },
+{ "-/+j",                  "turn on/off jump scroll" },
+#if OPT_C1_PRINT
+{ "-/+k8",                 "turn on/off C1-printable classification"},
+#endif
+{ "-kt keyboardtype",      "set keyboard type:" KEYBOARD_TYPES },
+#ifdef ALLOWLOGGING
+{ "-/+l",                  "turn on/off logging" },
+{ "-lf filename",          "logging filename" },
+#else
+{ "-/+l",                  "turn on/off logging (not supported)" },
+{ "-lf filename",          "logging filename (not supported)" },
+#endif
+{ "-/+ls",                 "turn on/off login shell" },
+{ "-/+mb",                 "turn on/off margin bell" },
+{ "-mc milliseconds",      "multiclick time in milliseconds" },
+{ "-/+mesg",               "forbid/allow messages" },
+{ "-ms color",             "pointer color" },
+{ "-nb number",            "margin bell in characters from right end" },
+{ "-/+nul",                "turn off/on display of underlining" },
+{ "-/+aw",                 "turn on/off auto wraparound" },
+{ "-/+pc",                 "turn on/off PC-style bold colors" },
+{ "-/+rw",                 "turn on/off reverse wraparound" },
+{ "-/+s",                  "turn on/off multiscroll" },
+{ "-/+sb",                 "turn on/off scrollbar" },
+#ifdef SCROLLBAR_RIGHT
+{ "-rightbar",             "force scrollbar right (default left)" },
+{ "-leftbar",              "force scrollbar left" },
+#endif
+{ "-/+rvc",                "turn off/on display of reverse as color" },
+{ "-/+sf",                 "turn on/off Sun Function Key escape codes" },
+{ "-/+si",                 "turn on/off scroll-on-tty-output inhibit" },
+{ "-/+sk",                 "turn on/off scroll-on-keypress" },
+{ "-sl number",            "number of scrolled lines to save" },
+#if OPT_SUNPC_KBD
+{ "-/+sp",                 "turn on/off Sun/PC Function/Keypad mapping" },
+#endif
+#if OPT_TEK4014
+{ "-/+t",                  "turn on/off Tek emulation window" },
+#endif
+#if OPT_TOOLBAR
+{ "-/+tb",                 "turn on/off toolbar" },
+#endif
+{ "-ti termid",            "terminal identifier" },
+{ "-tm string",            "terminal mode keywords and characters" },
+{ "-tn name",              "TERM environment variable name" },
+#if OPT_WIDE_CHARS
+{ "-/+u8",                 "turn on/off UTF-8 mode (implies wide-characters)" },
+#endif
+#if OPT_LUIT_PROG
+{ "-/+lc",                 "turn on/off locale mode using luit" },
+{ "-lcc path",             "filename of locale converter (" DEFLOCALEFILTER ")" },
+#endif
+{ "-/+uc",                 "turn on/off underline cursor" },
+{ "-/+ulc",                "turn off/on display of underline as color" },
+{ "-/+ut",                 "turn on/off utmp inhibit (not supported)" },
+{ "-/+ulit",               "turn off/on display of underline as italics" },
+{ "-/+vb",                 "turn on/off visual bell" },
+{ "-/+pob",                "turn on/off pop on bell" },
+#if OPT_WIDE_CHARS
+{ "-/+wc",                 "turn on/off wide-character mode" },
+{ "-/+mk_width",           "turn on/off simple width convention" },
+{ "-/+cjk_width",          "turn on/off legacy CJK width convention" },
+#endif
+{ "-/+wf",                 "turn on/off wait for map before command exec" },
+{ "-e command args ...",   "command to execute" },
+#if OPT_TEK4014
+{ "%geom",                 "Tek window geometry" },
+#endif
+{ "#geom",                 "icon window geometry" },
+{ "-T string",             "title name for window" },
+{ "-n string",             "icon name for window" },
+{ "-C",                    "intercept console messages" },
+{ "-Sccn",                 "slave mode on \"ttycc\", file descriptor \"n\"" },
+{ "-into windowId",        "use the window id given to -into as the parent window rather than the default root window" },
+#if OPT_ZICONBEEP
+{ "-ziconbeep percent",    "beep and flag icon of window having hidden output" },
+#endif
+#if OPT_SAME_NAME
+{ "-/+samename",           "turn on/off the no-flicker option for title and icon name" },
+#endif
+#if OPT_SESSION_MGT
+{ "-/+sm",                 "turn on/off the session-management support" },
+#endif
+#if OPT_MAXIMIZE
+{"-/+maximized",           "turn on/off maxmize on startup" },
+#endif
+{ NULL, NULL }};
+/* *INDENT-ON* */
+
+#ifdef DBG_CONSOLE
+FILE *confd;
+
+static void
+closecons(void)
+{
+    if (confs != 0) {
+       fclose(confd);
+       confd = 0;
+    }
+}
+static void
+opencons(void)
+{
+    closecons();
+    if ((confd = fopen("/dev/console$", "w")) < 0) {
+       fputs("!!! Cannot open console device.\n",
+             stderr);
+       exit(1);
+    }
+}
+#else
+#define opencons()             /* nothing */
+#define closecons()            /* nothing */
+#endif
+
+static const char *message[] =
+{
+    "Fonts should be fixed width and, if both normal and bold are specified, should",
+    "have the same size.  If only a normal font is specified, it will be used for",
+    "both normal and bold text (by doing overstriking).  The -e option, if given,",
+    "must appear at the end of the command line, otherwise the user's default shell",
+    "will be started.  Options that start with a plus sign (+) restore the default.",
+    NULL};
+
+/*
+ * Decode a key-definition.  This combines the termcap and ttyModes, for
+ * comparison.  Note that octal escapes in ttyModes are done by the normal
+ * resource translation.  Also, ttyModes allows '^-' as a synonym for disabled.
+ */
+static int
+decode_keyvalue(char **ptr, int termcap)
+{
+    char *string = *ptr;
+    int value = -1;
+
+    TRACE(("...decode '%s'\n", string));
+    if (*string == '^') {
+       switch (*++string) {
+       case '?':
+           value = A2E(ANSI_DEL);
+           break;
+       case '-':
+           if (!termcap) {
+               errno = 0;
+#if defined(_POSIX_VDISABLE) && defined(HAVE_UNISTD_H)
+               value = _POSIX_VDISABLE;
+#endif
+#if defined(_PC_VDISABLE)
+               if (value == -1) {
+                   value = fpathconf(0, _PC_VDISABLE);
+                   if (value == -1) {
+                       if (errno != 0)
+                           break;      /* skip this (error) */
+                       value = 0377;
+                   }
+               }
+#elif defined(VDISABLE)
+               if (value == -1)
+                   value = VDISABLE;
+#endif
+               break;
+           }
+           /* FALLTHRU */
+       default:
+           value = CONTROL(*string);
+           break;
+       }
+       ++string;
+    } else if (termcap && (*string == '\\')) {
+       char *d;
+       int temp = strtol(string + 1, &d, 8);
+       if (temp > 0 && d != string) {
+           value = temp;
+           string = d;
+       }
+    } else {
+       value = CharOf(*string);
+       ++string;
+    }
+    *ptr = string;
+    return value;
+}
+
+static int
+abbrev(const char *tst, const char *cmp, size_t need)
+{
+    size_t len = strlen(tst);
+    return ((len >= need) && (!strncmp(tst, cmp, len)));
+}
+
+static void
+Syntax(char *badOption)
+{
+    OptionHelp *opt;
+    OptionHelp *list = sortedOpts(xtermOptions, optionDescList, XtNumber(optionDescList));
+    int col;
+
+    fprintf(stderr, "%s:  bad command line option \"%s\"\r\n\n",
+           ProgramName, badOption);
+
+    fprintf(stderr, "usage:  %s", ProgramName);
+    col = 8 + (int) strlen(ProgramName);
+    for (opt = list; opt->opt; opt++) {
+       int len = 3 + (int) strlen(opt->opt);   /* space [ string ] */
+       if (col + len > 79) {
+           fprintf(stderr, "\r\n   ");         /* 3 spaces */
+           col = 3;
+       }
+       fprintf(stderr, " [%s]", opt->opt);
+       col += len;
+    }
+
+    fprintf(stderr, "\r\n\nType %s -help for a full description.\r\n\n",
+           ProgramName);
+    exit(1);
+}
+
+static void
+Version(void)
+{
+    printf("%s\n", xtermVersion());
+    fflush(stdout);
+}
+
+static void
+Help(void)
+{
+    OptionHelp *opt;
+    OptionHelp *list = sortedOpts(xtermOptions, optionDescList, XtNumber(optionDescList));
+    const char **cpp;
+
+    printf("%s usage:\n    %s [-options ...] [-e command args]\n\n",
+          xtermVersion(), ProgramName);
+    printf("where options include:\n");
+    for (opt = list; opt->opt; opt++) {
+       printf("    %-28s %s\n", opt->opt, opt->desc);
+    }
+
+    putchar('\n');
+    for (cpp = message; *cpp; cpp++)
+       puts(*cpp);
+    putchar('\n');
+    fflush(stdout);
+}
+
+/* ARGSUSED */
+static Boolean
+ConvertConsoleSelection(Widget w GCC_UNUSED,
+                       Atom * selection GCC_UNUSED,
+                       Atom * target GCC_UNUSED,
+                       Atom * type GCC_UNUSED,
+                       XtPointer *value GCC_UNUSED,
+                       unsigned long *length GCC_UNUSED,
+                       int *format GCC_UNUSED)
+{
+    /* we don't save console output, so can't offer it */
+    return False;
+}
+
+#if OPT_SESSION_MGT
+static void
+die_callback(Widget w GCC_UNUSED,
+            XtPointer client_data GCC_UNUSED,
+            XtPointer call_data GCC_UNUSED)
+{
+    Cleanup(0);
+}
+
+static void
+save_callback(Widget w GCC_UNUSED,
+             XtPointer client_data GCC_UNUSED,
+             XtPointer call_data)
+{
+    XtCheckpointToken token = (XtCheckpointToken) call_data;
+    /* we have nothing to save */
+    token->save_success = True;
+}
+
+static void
+icewatch(IceConn iceConn,
+        IcePointer clientData GCC_UNUSED,
+        Bool opening,
+        IcePointer * watchData GCC_UNUSED)
+{
+    if (opening) {
+       ice_fd = IceConnectionNumber(iceConn);
+       TRACE(("got IceConnectionNumber %d\n", ice_fd));
+    } else {
+       ice_fd = -1;
+       TRACE(("reset IceConnectionNumber\n"));
+    }
+}
+
+#endif /* OPT_SESSION_MGT */
+
+/*
+ * DeleteWindow(): Action proc to implement ICCCM delete_window.
+ */
+/* ARGSUSED */
+static void
+DeleteWindow(Widget w,
+            XEvent * event GCC_UNUSED,
+            String * params GCC_UNUSED,
+            Cardinal *num_params GCC_UNUSED)
+{
+#if OPT_TEK4014
+    if (w == toplevel) {
+       if (TEK4014_SHOWN(term))
+           hide_vt_window();
+       else
+           do_hangup(w, (XtPointer) 0, (XtPointer) 0);
+    } else if (TScreenOf(term)->Vshow)
+       hide_tek_window();
+    else
+#endif
+       do_hangup(w, (XtPointer) 0, (XtPointer) 0);
+}
+
+/* ARGSUSED */
+static void
+KeyboardMapping(Widget w GCC_UNUSED,
+               XEvent * event,
+               String * params GCC_UNUSED,
+               Cardinal *num_params GCC_UNUSED)
+{
+    switch (event->type) {
+    case MappingNotify:
+       XRefreshKeyboardMapping(&event->xmapping);
+       break;
+    }
+}
+
+static XtActionsRec actionProcs[] =
+{
+    {"DeleteWindow", DeleteWindow},
+    {"KeyboardMapping", KeyboardMapping},
+};
+
+char **gblenvp;
+
+int
+main(int argc, char **argv ENVP_ARG)
+{
+    Widget form_top, menu_top;
+    Dimension menu_high;
+    TScreen *screen;
+    int mode;
+    char *my_class = DEFCLASS;
+    Window winToEmbedInto = None;
+#if OPT_COLOR_RES
+    Bool reversed = False;
+#endif
+
+    ProgramName = argv[0];
+
+    save_ruid = getuid();
+    save_rgid = getgid();
+
+    /* Do these first, since we may not be able to open the display */
+    TRACE_OPTS(xtermOptions, optionDescList, XtNumber(optionDescList));
+    TRACE_ARGV("Before XtOpenApplication", argv);
+    if (argc > 1) {
+       int n;
+       unsigned unique = 2;
+       Bool quit = True;
+
+       for (n = 1; n < argc; n++) {
+           TRACE(("parsing %s\n", argv[n]));
+           if (abbrev(argv[n], "-version", unique)) {
+               Version();
+           } else if (abbrev(argv[n], "-help", unique)) {
+               Help();
+           } else if (abbrev(argv[n], "-class", 3)) {
+               if ((my_class = argv[++n]) == 0) {
+                   Help();
+               } else {
+                   quit = False;
+               }
+               unique = 3;
+           } else {
+#if OPT_COLOR_RES
+               if (abbrev(argv[n], "-reverse", 2)
+                   || !strcmp("-rv", argv[n])) {
+                   reversed = True;
+               } else if (!strcmp("+rv", argv[n])) {
+                   reversed = False;
+               }
+#endif
+               quit = False;
+               unique = 3;
+           }
+       }
+       if (quit)
+           exit(0);
+    }
+
+    /* XXX: for some obscure reason EMX seems to lose the value of
+     * the environ variable, don't understand why, so save it recently
+     */
+    gblenvp = envp;
+
+#ifdef I18N
+    setlocale(LC_ALL, NULL);
+#endif
+
+    opencons();
+
+    ttydev = TypeMallocN(char, PTMS_BUFSZ);
+    ptydev = TypeMallocN(char, PTMS_BUFSZ);
+    if (!ttydev || !ptydev) {
+       fprintf(stderr,
+               "%s:  unable to allocate memory for ttydev or ptydev\n",
+               ProgramName);
+       exit(1);
+    }
+    strcpy(ttydev, TTYDEV);
+    strcpy(ptydev, PTYDEV);
+
+    /* Initialization is done here rather than above in order
+     * to prevent any assumptions about the order of the contents
+     * of the various terminal structures (which may change from
+     * implementation to implementation).
+     */
+    d_tio.c_iflag = ICRNL | IXON;
+    d_tio.c_oflag = OPOST | ONLCR | TAB3;
+    d_tio.c_cflag = B38400 | CS8 | CREAD | PARENB | HUPCL;
+    d_tio.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK;
+    d_tio.c_line = 0;
+    d_tio.c_cc[VINTR] = CONTROL('C');  /* '^C' */
+    d_tio.c_cc[VERASE] = ANSI_DEL;     /* DEL  */
+    d_tio.c_cc[VKILL] = CONTROL('U');  /* '^U' */
+    d_tio.c_cc[VQUIT] = CQUIT; /* '^\' */
+    d_tio.c_cc[VEOF] = CEOF;   /* '^D' */
+    d_tio.c_cc[VEOL] = CEOL;   /* '^@' */
+
+    XtSetErrorHandler(xt_error);
+#if OPT_SESSION_MGT
+    toplevel = XtOpenApplication(&app_con, my_class,
+                                optionDescList,
+                                XtNumber(optionDescList),
+                                &argc, argv, fallback_resources,
+                                sessionShellWidgetClass,
+                                NULL, 0);
+    IceAddConnectionWatch(icewatch, NULL);
+#else
+    toplevel = XtAppInitialize(&app_con, my_class,
+                              optionDescList,
+                              XtNumber(optionDescList),
+                              &argc, argv, fallback_resources,
+                              NULL, 0);
+#endif /* OPT_SESSION_MGT */
+    XtSetErrorHandler((XtErrorHandler) 0);
+
+    XtGetApplicationResources(toplevel, (XtPointer) &resource,
+                             application_resources,
+                             XtNumber(application_resources), NULL, 0);
+    TRACE_XRES();
+
+    /*
+     * ICCCM delete_window.
+     */
+    XtAppAddActions(app_con, actionProcs, XtNumber(actionProcs));
+
+    /*
+     * fill in terminal modes
+     */
+    if (resource.tty_modes) {
+       int n = parse_tty_modes(resource.tty_modes, ttymodelist);
+       if (n < 0) {
+           fprintf(stderr, "%s:  bad tty modes \"%s\"\n",
+                   ProgramName, resource.tty_modes);
+       } else if (n > 0) {
+           override_tty_modes = True;
+       }
+    }
+#if OPT_ZICONBEEP
+    if (resource.zIconBeep > 100 || resource.zIconBeep < -100) {
+       resource.zIconBeep = 0; /* was 100, but I prefer to defaulting off. */
+       fprintf(stderr,
+               "a number between -100 and 100 is required for zIconBeep.  0 used by default\n");
+    }
+#endif /* OPT_ZICONBEEP */
+    hold_screen = resource.hold_screen ? 1 : 0;
+    xterm_name = resource.xterm_name;
+    if (strcmp(xterm_name, "-") == 0)
+       xterm_name = DFT_TERMTYPE;
+    if (resource.icon_geometry != NULL) {
+       int scr, junk;
+       int ix, iy;
+       Arg args[2];
+
+       for (scr = 0;           /* yyuucchh */
+            XtScreen(toplevel) != ScreenOfDisplay(XtDisplay(toplevel), scr);
+            scr++) ;
+
+       args[0].name = XtNiconX;
+       args[1].name = XtNiconY;
+       XGeometry(XtDisplay(toplevel), scr, resource.icon_geometry, "",
+                 0, 0, 0, 0, 0, &ix, &iy, &junk, &junk);
+       args[0].value = (XtArgVal) ix;
+       args[1].value = (XtArgVal) iy;
+       XtSetValues(toplevel, args, 2);
+    }
+
+    XtSetValues(toplevel, ourTopLevelShellArgs,
+               number_ourTopLevelShellArgs);
+
+#if OPT_WIDE_CHARS
+    /* seems as good a place as any */
+    init_classtab();
+#endif
+
+    /* Parse the rest of the command line */
+    TRACE_ARGV("After XtOpenApplication", argv);
+    for (argc--, argv++; argc > 0; argc--, argv++) {
+       if (**argv != '-')
+           Syntax(*argv);
+
+       TRACE(("parsing %s\n", argv[0]));
+       switch (argv[0][1]) {
+       case 'h':               /* -help */
+           Help();
+           continue;
+       case 'v':               /* -version */
+           Version();
+           continue;
+       case 'C':
+           {
+               struct stat sbuf;
+
+               /* Must be owner and have read/write permission.
+                  xdm cooperates to give the console the right user. */
+               if (!stat("/dev/console", &sbuf) &&
+                   (sbuf.st_uid == save_ruid) &&
+                   !access("/dev/console", R_OK | W_OK)) {
+                   Console = True;
+               } else
+                   Console = False;
+           }
+           continue;
+       case 'S':
+           if (sscanf(*argv + 2, "%c%c%d", passedPty, passedPty + 1,
+                      &am_slave) != 3)
+               Syntax(*argv);
+           continue;
+#ifdef DEBUG
+       case 'D':
+           debug = True;
+           continue;
+#endif /* DEBUG */
+       case 'c':               /* -class param */
+           if (strcmp(argv[0] + 1, "class") == 0)
+               argc--, argv++;
+           else
+               Syntax(*argv);
+           continue;
+       case 'e':
+           if (argc <= 1)
+               Syntax(*argv);
+           command_to_exec = ++argv;
+           break;
+       case 'i':
+           if (argc <= 1) {
+               Syntax(*argv);
+           } else {
+               char *endPtr;
+               --argc;
+               ++argv;
+               winToEmbedInto = (Window) strtol(argv[0], &endPtr, 10);
+           }
+           continue;
+
+       default:
+           Syntax(*argv);
+       }
+       break;
+    }
+
+    SetupMenus(toplevel, &form_top, &menu_top, &menu_high);
+
+    term = (XtermWidget) XtVaCreateManagedWidget("vt100", xtermWidgetClass,
+                                                form_top,
+#if OPT_TOOLBAR
+                                                XtNmenuBar, menu_top,
+                                                XtNresizable, True,
+                                                XtNfromVert, menu_top,
+                                                XtNleft, XawChainLeft,
+                                                XtNright, XawChainRight,
+                                                XtNtop, XawChainTop,
+                                                XtNbottom, XawChainBottom,
+                                                XtNmenuHeight, menu_high,
+#endif
+                                                (XtPointer) 0);
+    decode_keyboard_type(term, &resource);
+
+    screen = TScreenOf(term);
+    screen->inhibit = 0;
+
+#ifdef ALLOWLOGGING
+    if (term->misc.logInhibit)
+       screen->inhibit |= I_LOG;
+#endif
+    if (term->misc.signalInhibit)
+       screen->inhibit |= I_SIGNAL;
+#if OPT_TEK4014
+    if (term->misc.tekInhibit)
+       screen->inhibit |= I_TEK;
+#endif
+
+    /*
+     * We might start by showing the tek4014 window.
+     */
+#if OPT_TEK4014
+    if (screen->inhibit & I_TEK)
+       TEK4014_ACTIVE(term) = False;
+
+    if (TEK4014_ACTIVE(term) && !TekInit())
+       SysError(ERROR_INIT);
+#endif
+
+    /*
+     * Start the toolbar at this point, after the first window has been setup.
+     */
+#if OPT_TOOLBAR
+    ShowToolbar(resource.toolBar);
+#endif
+
+#if OPT_SESSION_MGT
+    if (resource.sessionMgt) {
+       TRACE(("Enabling session-management callbacks\n"));
+       XtAddCallback(toplevel, XtNdieCallback, die_callback, NULL);
+       XtAddCallback(toplevel, XtNsaveCallback, save_callback, NULL);
+    }
+#endif
+
+    /*
+     * Set title and icon name if not specified
+     */
+    if (command_to_exec) {
+       Arg args[2];
+
+       if (!resource.title) {
+           if (command_to_exec) {
+               resource.title = x_basename(command_to_exec[0]);
+           }                   /* else not reached */
+       }
+
+       if (!resource.icon_name)
+           resource.icon_name = resource.title;
+       XtSetArg(args[0], XtNtitle, resource.title);
+       XtSetArg(args[1], XtNiconName, resource.icon_name);
+
+       TRACE(("setting:\n\ttitle \"%s\"\n\ticon \"%s\"\n\tbased on command \"%s\"\n",
+              resource.title,
+              resource.icon_name,
+              *command_to_exec));
+
+       XtSetValues(toplevel, args, 2);
+    }
+#if OPT_LUIT_PROG
+    if (term->misc.callfilter) {
+       int u = (term->misc.use_encoding ? 2 : 0);
+       if (command_to_exec) {
+           int n;
+           char **c;
+           for (n = 0, c = command_to_exec; *c; n++, c++) ;
+           c = TypeMallocN(char *, n + 3 + u);
+           if (c == NULL)
+               SysError(ERROR_LUMALLOC);
+           memcpy(c + 2 + u, command_to_exec, (n + 1) * sizeof(char *));
+           c[0] = term->misc.localefilter;
+           if (u) {
+               c[1] = "-encoding";
+               c[2] = term->misc.locale_str;
+           }
+           c[1 + u] = "--";
+           command_to_exec_with_luit = c;
+       } else {
+           static char *luit[6];
+           luit[0] = term->misc.localefilter;
+           if (u) {
+               luit[1] = "-encoding";
+               luit[2] = term->misc.locale_str;
+               luit[3] = NULL;
+           } else
+               luit[1] = NULL;
+           command_to_exec_with_luit = luit;
+       }
+    }
+#endif
+
+#ifdef DEBUG
+    {
+       /* Set up stderr properly.  Opening this log file cannot be
+          done securely by a privileged xterm process (although we try),
+          so the debug feature is disabled by default. */
+       char dbglogfile[45];
+       int i = -1;
+       if (debug) {
+           timestamp_filename(dbglogfile, "xterm.debug.log.");
+           if (creat_as(save_ruid, save_rgid, False, dbglogfile, 0666) > 0) {
+               i = open(dbglogfile, O_WRONLY | O_TRUNC);
+           }
+       }
+       if (i >= 0) {
+           dup2(i, 2);
+
+           /* mark this file as close on exec */
+           (void) fcntl(i, F_SETFD, 1);
+       }
+    }
+#endif /* DEBUG */
+
+    spawnXTerm(term);
+
+    /* Child process is out there, let's catch its termination */
+    (void) signal(SIGCHLD, reapchild);
+
+    /* Realize procs have now been executed */
+
+    if (am_slave >= 0) {       /* Write window id so master end can read and use */
+       char buf[80];
+
+       buf[0] = '\0';
+       sprintf(buf, "%lx\n", XtWindow(SHELL_OF(CURRENT_EMU())));
+       IGNORE_RC(write(screen->respond, buf, strlen(buf)));
+    }
+
+    if (0 > (mode = fcntl(screen->respond, F_GETFL, 0)))
+       SysError(ERROR_F_GETFL);
+    mode |= O_NDELAY;
+
+    if (fcntl(screen->respond, F_SETFL, mode))
+       SysError(ERROR_F_SETFL);
+
+    FD_ZERO(&pty_mask);
+    FD_ZERO(&X_mask);
+    FD_ZERO(&Select_mask);
+    FD_SET(screen->respond, &pty_mask);
+    FD_SET(ConnectionNumber(screen->display), &X_mask);
+    FD_SET(screen->respond, &Select_mask);
+    FD_SET(ConnectionNumber(screen->display), &Select_mask);
+    max_plus1 = ((screen->respond < ConnectionNumber(screen->display))
+                ? (1 + ConnectionNumber(screen->display))
+                : (1 + screen->respond));
+
+#ifdef DEBUG
+    if (debug)
+       printf("debugging on\n");
+#endif /* DEBUG */
+    XSetErrorHandler(xerror);
+    XSetIOErrorHandler(xioerror);
+
+    initPtyData(&VTbuffer);
+#ifdef ALLOWLOGGING
+    if (term->misc.log_on) {
+       StartLog(term);
+    }
+#endif
+
+    if (winToEmbedInto != None) {
+       XtRealizeWidget(toplevel);
+       /*
+        * This should probably query the tree or check the attributes of
+        * winToEmbedInto in order to verify that it exists, but I'm still not
+        * certain what is the best way to do it -GPS
+        */
+       XReparentWindow(XtDisplay(toplevel),
+                       XtWindow(toplevel),
+                       winToEmbedInto, 0, 0);
+    }
+#if OPT_COLOR_RES
+    TRACE(("checking resource values rv %s fg %s, bg %s\n",
+          BtoS(term->misc.re_verse0),
+          NonNull(TScreenOf(term)->Tcolors[TEXT_FG].resource),
+          NonNull(TScreenOf(term)->Tcolors[TEXT_BG].resource)));
+
+    if ((reversed && term->misc.re_verse0)
+       && ((TScreenOf(term)->Tcolors[TEXT_FG].resource
+            && !isDefaultForeground(TScreenOf(term)->Tcolors[TEXT_FG].resource))
+           || (TScreenOf(term)->Tcolors[TEXT_BG].resource
+               && !isDefaultBackground(TScreenOf(term)->Tcolors[TEXT_BG].resource))
+       ))
+       ReverseVideo(term);
+#endif /* OPT_COLOR_RES */
+
+#if OPT_MAXIMIZE
+    if (resource.maximized)
+       RequestMaximize(term, True);
+#endif
+    for (;;) {
+#if OPT_TEK4014
+       if (TEK4014_ACTIVE(term))
+           TekRun();
+       else
+#endif
+           VTRun(term);
+    }
+    return 0;
+}
+
+/*
+ * Called from get_pty to iterate over likely pseudo terminals
+ * we might allocate.  Used on those systems that do not have
+ * a functional interface for allocating a pty.
+ * Returns 0 if found a pty, 1 if fails.
+ */
+static int
+pty_search(int *pty)
+{
+    char namebuf[PTMS_BUFSZ];
+
+    /* ask the PTY manager */
+    int fd = open("/dev/ptms$", 0);
+    if (fd && ptioctl(fd, PTMS_GETPTY, namebuf) == 0) {
+       strcpy(ttydev, namebuf);
+       strcpy(ptydev, namebuf);
+       *x_basename(ttydev) = 't';
+       close(fd);
+       if ((*pty = open(ptydev, O_RDWR)) >= 0) {
+#ifdef PTYDEBUG
+           ptioctl(*pty, XTY_TRACE, 0);
+#endif
+           return 0;
+       } else {
+           fprintf(stderr, "Unable to open %s, errno=%d\n", ptydev, errno);
+       }
+    }
+    return 1;
+}
+
+/*
+ * This function opens up a pty master and stuffs its value into pty.
+ *
+ * If it finds one, it returns a value of 0.  If it does not find one,
+ * it returns a value of !0.  This routine is designed to be re-entrant,
+ * so that if a pty master is found and later, we find that the slave
+ * has problems, we can re-enter this function and get another one.
+ */
+static int
+get_pty(int *pty)
+{
+    return pty_search(pty);
+}
+
+/*
+ * The only difference in /etc/termcap between 4014 and 4015 is that
+ * the latter has support for switching character sets.  We support the
+ * 4015 protocol, but ignore the character switches.  Therefore, we
+ * choose 4014 over 4015.
+ *
+ * Features of the 4014 over the 4012: larger (19") screen, 12-bit
+ * graphics addressing (compatible with 4012 10-bit addressing),
+ * special point plot mode, incremental plot mode (not implemented in
+ * later Tektronix terminals), and 4 character sizes.
+ * All of these are supported by xterm.
+ */
+
+#if OPT_TEK4014
+static char *tekterm[] =
+{
+    "tek4014",
+    "tek4015",                 /* 4014 with APL character set support */
+    "tek4012",                 /* 4010 with lower case */
+    "tek4013",                 /* 4012 with APL character set support */
+    "tek4010",                 /* small screen, upper-case only */
+    "dumb",
+    0
+};
+#endif
+
+/* The VT102 is a VT100 with the Advanced Video Option included standard.
+ * It also adds Escape sequences for insert/delete character/line.
+ * The VT220 adds 8-bit character sets, selective erase.
+ * The VT320 adds a 25th status line, terminal state interrogation.
+ * The VT420 has up to 48 lines on the screen.
+ */
+
+static char *vtterm[] =
+{
+#ifdef USE_X11TERM
+    "x11term",                 /* for people who want special term name */
+#endif
+    DFT_TERMTYPE,              /* for people who want special term name */
+    "xterm",                   /* the prefered name, should be fastest */
+    "vt102",
+    "vt100",
+    "ansi",
+    "dumb",
+    0
+};
+
+/* ARGSUSED */
+static SIGNAL_T
+hungtty(int i GCC_UNUSED)
+{
+    longjmp(env, 1);
+    SIGNAL_RETURN;
+}
+
+#if OPT_PTY_HANDSHAKE
+struct {
+    int rows;
+    int cols;
+} handshake = {
+
+    -1, -1
+};
+
+void
+first_map_occurred(void)
+{
+    if (resource.wait_for_map) {
+       TScreen *screen = TScreenOf(term);
+       handshake.rows = screen->max_row;
+       handshake.cols = screen->max_col;
+       resource.wait_for_map = False;
+    }
+}
+#endif /* OPT_PTY_HANDSHAKE else !OPT_PTY_HANDSHAKE */
+
+static void
+set_owner(char *device, uid_t uid, gid_t gid, mode_t mode)
+{
+    int why;
+
+    if (chown(device, uid, gid) < 0) {
+       why = errno;
+       if (why != ENOENT
+           && save_ruid == 0) {
+           fprintf(stderr, "Cannot chown %s to %ld,%ld: %s\n",
+                   device, (long) uid, (long) gid,
+                   strerror(why));
+       }
+    }
+}
+
+#define THE_PARENT 1
+#define THE_CHILD  2
+int whoami = -1;
+
+SIGNAL_T
+killit(int sig)
+{
+    switch (whoami) {
+    case -1:
+       signal(sig, killit);
+       kill(-getpid(), sig);
+       break;
+    case THE_PARENT:
+       wait(NULL);
+       signal(SIGTERM, SIG_DFL);
+       kill(-getpid(), SIGTERM);
+       Exit(0);
+       break;
+    case THE_CHILD:
+       signal(SIGTERM, SIG_DFL);
+       kill(-getppid(), SIGTERM);
+       Exit(0);
+       break;
+    }
+
+    SIGNAL_RETURN;
+}
+
+#define close_fd(fd) close(fd), fd = -1
+
+static int
+spawnXTerm(XtermWidget xw)
+/*
+ *  Inits pty and tty and forks a login process.
+ *  Does not close fd Xsocket.
+ *  If slave, the pty named in passedPty is already open for use
+ */
+{
+    TScreen *screen = TScreenOf(xw);
+    int Xsocket = ConnectionNumber(screen->display);
+
+    int ttyfd = -1;
+    TERMIO_STRUCT tio;
+    int status;
+    Bool ok_termcap;
+
+    char *TermName = NULL;
+    char *ptr, *shname, buf[64];
+    int i, no_dev_tty = False;
+    char *dev_tty_name = (char *) 0;
+    TTYSIZE_STRUCT ts;
+    int pgrp = getpid();
+    char numbuf[12], **envnew;
+
+    screen->uid = save_ruid;
+    screen->gid = save_rgid;
+
+    if (am_slave >= 0) {
+       screen->respond = am_slave;
+       ptydev[strlen(ptydev) - 2] =
+           ttydev[strlen(ttydev) - 2] = passedPty[0];
+       ptydev[strlen(ptydev) - 1] =
+           ttydev[strlen(ttydev) - 1] = passedPty[1];
+
+       (void) xtermResetIds(screen);
+    } else {
+       Bool tty_got_hung;
+
+       /*
+        * Sometimes /dev/tty hangs on open (as in the case of a pty
+        * that has gone away).  Simply make up some reasonable
+        * defaults.
+        */
+
+       signal(SIGALRM, hungtty);
+       alarm(2);               /* alarm(1) might return too soon */
+       if (!setjmp(env)) {
+           ttyfd = open("/dev/tty", O_RDWR);
+           alarm(0);
+           tty_got_hung = False;
+       } else {
+           tty_got_hung = True;
+           ttyfd = -1;
+           errno = ENXIO;
+       }
+       signal(SIGALRM, SIG_DFL);
+
+       /*
+        * Check results and ignore current control terminal if
+        * necessary.  ENXIO is what is normally returned if there is
+        * no controlling terminal, but some systems (e.g. SunOS 4.0)
+        * seem to return EIO.  Solaris 2.3 is said to return EINVAL.
+        */
+       if (ttyfd < 0) {
+           if (tty_got_hung || errno == ENXIO || errno == EIO ||
+               errno == EINVAL || errno == ENOTTY) {
+               no_dev_tty = True;
+               tio = d_tio;
+           } else {
+               SysError(ERROR_OPDEVTTY);
+           }
+       } else {
+
+           /* Get a copy of the current terminal's state,
+            * if we can.  Some systems (e.g., SVR4 and MacII)
+            * may not have a controlling terminal at this point
+            * if started directly from xdm or xinit,
+            * in which case we just use the defaults as above.
+            */
+           if (ioctl(ttyfd, TCGETA, &tio) == -1)
+               tio = d_tio;
+
+           close_fd(ttyfd);
+       }
+
+       if (get_pty(&screen->respond)) {
+           /*  no ptys! */
+           exit(ERROR_PTYS);
+       }
+    }
+
+    /* avoid double MapWindow requests */
+    XtSetMappedWhenManaged(SHELL_OF(CURRENT_EMU()), False);
+
+    wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
+                                  False);
+
+    if (!TEK4014_ACTIVE(xw))
+       VTInit(xw);             /* realize now so know window size for tty driver */
+
+    if (Console) {
+       /*
+        * Inform any running xconsole program
+        * that we are going to steal the console.
+        */
+       XmuGetHostname(mit_console_name + MIT_CONSOLE_LEN, 255);
+       mit_console = XInternAtom(screen->display, mit_console_name, False);
+       /* the user told us to be the console, so we can use CurrentTime */
+       XtOwnSelection(SHELL_OF(CURRENT_EMU()),
+                      mit_console, CurrentTime,
+                      ConvertConsoleSelection, NULL, NULL);
+    }
+#if OPT_TEK4014
+    if (TEK4014_ACTIVE(xw)) {
+       envnew = tekterm;
+    } else
+#endif
+    {
+       envnew = vtterm;
+    }
+
+    /*
+     * This used to exit if no termcap entry was found for the specified
+     * terminal name.  That's a little unfriendly, so instead we'll allow
+     * the program to proceed (but not to set $TERMCAP) if the termcap
+     * entry is not found.
+     */
+    ok_termcap = True;
+    if (!get_termcap(TermName = resource.term_name)) {
+       char *last = NULL;
+       TermName = *envnew;
+       ok_termcap = False;
+       while (*envnew != NULL) {
+           if ((last == NULL || strcmp(last, *envnew))
+               && get_termcap(*envnew)) {
+               TermName = *envnew;
+               ok_termcap = True;
+               break;
+           }
+           last = *envnew;
+           envnew++;
+       }
+    }
+    if (ok_termcap) {
+       resize_termcap(xw);
+    }
+
+    /* tell tty how big window is */
+#if OPT_TEK4014
+    if (TEK4014_ACTIVE(xw)) {
+       TTYSIZE_ROWS(ts) = 38;
+       TTYSIZE_COLS(ts) = 81;
+       ts.ws_xpixel = TFullWidth(TekScreenOf(tekWidget));
+       ts.ws_ypixel = TFullHeight(TekScreenOf(tekWidget));
+    } else
+#endif
+    {
+       TTYSIZE_ROWS(ts) = MaxRows(screen);
+       TTYSIZE_COLS(ts) = MaxCols(screen);
+       ts.ws_xpixel = FullWidth(screen);
+       ts.ws_ypixel = FullHeight(screen);
+    }
+
+    if (am_slave < 0) {
+
+       char sema[40];
+       HEV sev;
+       /* start a child process
+        * use an event sema for sync
+        */
+       sprintf(sema, "\\SEM32\\xterm%s", &ptydev[8]);
+       if (DosCreateEventSem(sema, &sev, DC_SEM_SHARED, False))
+           SysError(ERROR_FORK);
+
+       switch ((screen->pid = fork())) {
+       case -1:                /* error */
+           SysError(ERROR_FORK);
+       default:                /* parent */
+           whoami = THE_PARENT;
+           DosWaitEventSem(sev, 1000L);
+           DosCloseEventSem(sev);
+           break;
+       case 0:         /* child */
+           whoami = THE_CHILD;
+
+           opencons();
+           /* we don't need the socket, or the pty master anymore */
+           close(ConnectionNumber(screen->display));
+           close(screen->respond);
+
+           /* Now is the time to set up our process group and
+            * open up the pty slave.
+            */
+           if ((ttyfd = open(ttydev, O_RDWR)) < 0) {
+               /* dumm gelaufen */
+               fprintf(stderr, "Cannot open slave side of PTY\n");
+               exit(1);
+           }
+
+           /* use the same tty name that everyone else will use
+            * (from ttyname)
+            */
+#ifdef EMXNOTBOGUS
+           if ((ptr = ttyname(ttyfd)) != 0) {
+               ttydev = x_strdup(ptr);
+           }
+#else
+           ptr = ttydev;
+#endif
+           /* for safety: enable DUPs */
+           ptioctl(ttyfd, XTY_ENADUP, 0);
+
+           /* change ownership of tty to real group and user id */
+           set_owner(ttydev, screen->uid, screen->gid,
+                     (resource.messages ? 0622U : 0600U));
+
+           /* for the xf86sup-pty, we set the pty to bypass: OS/2 does
+            * not have a line discipline structure
+            */
+           {
+               TERMIO_STRUCT t, t1;
+               if (ptioctl(ttyfd, TCGETA, (char *) &t) < 0)
+                   t = d_tio;
+
+               t.c_iflag = ICRNL;
+               t.c_oflag = OPOST | ONLCR;
+               t.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK;
+
+               /* ignore error code, user will see it :-) */
+               ptioctl(ttyfd, TCSETA, (char *) &t);
+
+               /* set the console mode */
+               if (Console) {
+                   int on = 1;
+                   if (ioctl(ttyfd, TIOCCONS, (char *) &on) == -1)
+                       fprintf(stderr, "%s: cannot open console: %s\n",
+                               ProgramName, strerror(errno));
+               }
+           }
+
+           signal(SIGCHLD, SIG_DFL);
+           signal(SIGHUP, SIG_IGN);
+
+           /* restore various signals to their defaults */
+           signal(SIGINT, SIG_DFL);
+           signal(SIGQUIT, SIG_DFL);
+           signal(SIGTERM, SIG_DFL);
+
+           xtermCopyEnv(gblenvp);
+
+           xtermSetenv("TERM", TermName);
+           if (!TermName)
+               *get_tcap_buffer(xw) = 0;
+
+           sprintf(buf, "%lu",
+                   ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU()))));
+           xtermSetenv("WINDOWID", buf);
+
+           /* put the display into the environment of the shell */
+           xtermSetenv("DISPLAY", XDisplayString(screen->display));
+
+           xtermSetenv("XTERM_VERSION", xtermVersion());
+           xtermSetenv("XTERM_LOCALE", xtermEnvLocale());
+
+           signal(SIGTERM, SIG_DFL);
+
+           /* this is the time to go and set up stdin, out, and err
+            */
+           /* dup the tty */
+           for (i = 0; i <= 2; i++)
+               if (i != ttyfd) {
+                   (void) close(i);
+                   IGNORE_RC(dup(ttyfd));
+               }
+
+           /* and close the tty */
+           if (ttyfd > 2)
+               close_fd(ttyfd);
+
+           setpgrp(0, pgrp);
+           (void) xtermResetIds(screen);
+
+           if (handshake.rows > 0 && handshake.cols > 0) {
+               TRACE(("handshake ttysize: %dx%d\n",
+                      handshake.rows, handshake.cols));
+               set_max_row(screen, handshake.rows);
+               set_max_col(screen, handshake.cols);
+               TTYSIZE_ROWS(ts) = MaxRows(screen);
+               TTYSIZE_COLS(ts) = MaxCols(screen);
+               ts.ws_xpixel = FullWidth(screen);
+               ts.ws_ypixel = FullHeight(screen);
+           }
+
+           sprintf(numbuf, "%d", MaxCols(screen));
+           xtermSetenv("COLUMNS", numbuf);
+           sprintf(numbuf, "%d", MaxRows(screen));
+           xtermSetenv("LINES", numbuf);
+
+           gblenvp = environ;
+
+           /* need to reset after all the ioctl bashing we did above */
+           ptioctl(0, TIOCSWINSZ, (char *) &ts);
+
+           signal(SIGHUP, SIG_DFL);
+
+           /* okay everything seems right, so tell the parent, we are going */
+           {
+               char sema[40];
+               HEV sev;
+               sprintf(sema, "\\SEM32\\xterm%s", &ttydev[8]);
+               DosOpenEventSem(sema, &sev);
+               DosPostEventSem(sev);
+               DosCloseEventSem(sev);
+           }
+
+#if OPT_LUIT_PROG
+           /*
+            * Use two copies of command_to_exec, in case luit is not actually
+            * there, or refuses to run.  In that case we will fall-through to
+            * to command that the user gave anyway.
+            */
+           if (command_to_exec_with_luit) {
+               xtermSetenv("XTERM_SHELL",
+                           xtermFindShell(*command_to_exec_with_luit, False));
+               TRACE(("spawning command \"%s\"\n", *command_to_exec_with_luit));
+               execvp(*command_to_exec_with_luit, command_to_exec_with_luit);
+               /* print error message on screen */
+               fprintf(stderr, "%s: Can't execvp %s: %s\n",
+                       ProgramName, *command_to_exec_with_luit, strerror(errno));
+               fprintf(stderr, "%s: cannot support your locale.\n",
+                       ProgramName);
+           }
+#endif
+           if (command_to_exec) {
+               xtermSetenv("XTERM_SHELL",
+                           xtermFindShell(*command_to_exec, False));
+               TRACE(("spawning command \"%s\"\n", *command_to_exec));
+               execvpe(*command_to_exec, command_to_exec, gblenvp);
+
+               /* print error message on screen */
+               fprintf(stderr, "%s: Can't execvp %s\n",
+                       ProgramName, *command_to_exec);
+           }
+
+           /* use a layered mechanism to find a shell */
+           ptr = x_getenv("X11SHELL");
+           if (!ptr)
+               ptr = x_getenv("SHELL");
+           if (!ptr)
+               ptr = x_getenv("OS2_SHELL");
+           if (!ptr)
+               ptr = "SORRY_NO_SHELL_FOUND";
+           xtermSetenv("XTERM_SHELL", ptr);
+
+           shname = x_basename(ptr);
+           if (command_to_exec) {
+               char *exargv[10];       /*XXX */
+
+               exargv[0] = ptr;
+               exargv[1] = "/C";
+               exargv[2] = command_to_exec[0];
+               exargv[3] = command_to_exec[1];
+               exargv[4] = command_to_exec[2];
+               exargv[5] = command_to_exec[3];
+               exargv[6] = command_to_exec[4];
+               exargv[7] = command_to_exec[5];
+               exargv[8] = command_to_exec[6];
+               exargv[9] = 0;
+               execvpe(exargv[0], exargv, gblenvp);
+
+               /* print error message on screen */
+               fprintf(stderr, "%s: Can't execvp %s\n",
+                       ProgramName, *command_to_exec);
+           } else {
+               execlpe(ptr, shname, 0, gblenvp);
+
+               /* Exec failed. */
+               fprintf(stderr, "%s: Could not exec %s!\n",
+                       ProgramName, ptr);
+           }
+           sleep(5);
+
+           /* preventively shoot the parent */
+           kill(-getppid(), SIGTERM);
+
+           exit(ERROR_EXEC);
+       }                       /* endcase */
+    }
+    /* !am_slave */
+    signal(SIGHUP, SIG_IGN);
+/*
+ * Unfortunately, System V seems to have trouble divorcing the child process
+ * from the process group of xterm.  This is a problem because hitting the
+ * INTR or QUIT characters on the keyboard will cause xterm to go away if we
+ * don't ignore the signals.  This is annoying.
+ */
+
+/*  signal (SIGINT, SIG_IGN);*/
+    signal(SIGINT, killit);
+    signal(SIGTERM, killit);
+
+    /* hung shell problem */
+    signal(SIGQUIT, SIG_IGN);
+/*  signal (SIGTERM, SIG_IGN);*/
+    return 0;
+}                              /* end spawnXTerm */
+
+SIGNAL_T
+Exit(int n)
+{
+    XtermWidget xw = term;
+    TScreen *screen = TScreenOf(xw);
+    int pty = TScreenOf(xw)->respond;
+    close(pty);                        /* close explicitly to avoid race with slave side */
+#ifdef ALLOWLOGGING
+    if (screen->logging)
+       CloseLog(xw);
+#endif
+    if (am_slave < 0) {
+       /* restore ownership of tty and pty */
+       set_owner(ttydev, 0, 0, 0666U);
+       set_owner(ptydev, 0, 0, 0666U);
+    }
+
+    /*
+     * Close after releasing ownership to avoid race condition: other programs 
+     * grabbing it, and *then* having us release ownership....
+     */
+    close(screen->respond);    /* close explicitly to avoid race with slave side */
+#ifdef ALLOWLOGGING
+    if (screen->logging)
+       CloseLog(xw);
+#endif
+
+#ifdef NO_LEAKS
+    if (n == 0) {
+       TRACE(("Freeing memory leaks\n"));
+       if (xw != 0) {
+           Display *dpy = TScreenOf(xw)->display;
+
+           if (toplevel) {
+               XtDestroyWidget(toplevel);
+               TRACE(("destroyed top-level widget\n"));
+           }
+           sortedOpts(0, 0, 0);
+           noleaks_charproc();
+           noleaks_ptydata();
+#if OPT_WIDE_CHARS
+           noleaks_CharacterClass();
+#endif
+           /* XrmSetDatabase(dpy, 0); increases leaks ;-) */
+           XtCloseDisplay(dpy);
+           XtDestroyApplicationContext(app_con);
+#if OPT_SESSION_MGT
+           IceRemoveConnectionWatch(icewatch, NULL);
+#endif
+           TRACE(("closed display\n"));
+       }
+       TRACE((0));
+    }
+#endif
+
+    exit(n);
+    SIGNAL_RETURN;
+}
+
+/* ARGSUSED */
+static void
+resize_termcap(XtermWidget xw)
+{
+}
+
+/*
+ * Does a non-blocking wait for a child process.  If the system
+ * doesn't support non-blocking wait, do nothing.
+ * Returns the pid of the child, or 0 or -1 if none or error.
+ */
+int
+nonblocking_wait(void)
+{
+    pid_t pid;
+
+    pid = waitpid(-1, NULL, WNOHANG);
+    return pid;
+}
+
+/* ARGSUSED */
+static SIGNAL_T
+reapchild(int n GCC_UNUSED)
+{
+    int olderrno = errno;
+    int pid;
+
+    pid = wait(NULL);
+
+    /* cannot re-enable signal before waiting for child
+     * because then SVR4 loops.  Sigh.  HP-UX 9.01 too.
+     */
+    (void) signal(SIGCHLD, reapchild);
+
+    do {
+       if (pid == TScreenOf(term)->pid) {
+#ifdef DEBUG
+           if (debug)
+               fputs("Exiting\n", stderr);
+#endif
+           if (!hold_screen)
+               need_cleanup = True;
+       }
+    } while ((pid = nonblocking_wait()) > 0);
+
+    errno = olderrno;
+    SIGNAL_RETURN;
+}
+
+/*
+ * parse_tty_modes accepts lines of the following form:
+ *
+ *         [SETTING] ...
+ *
+ * where setting consists of the words in the modelist followed by a character
+ * or ^char.
+ */
+static int
+parse_tty_modes(char *s, struct _xttymodes *modelist)
+{
+    struct _xttymodes *mp;
+    int c;
+    int count = 0;
+
+    TRACE(("parse_tty_modes\n"));
+    while (1) {
+       size_t len;
+
+       while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s)))
+           s++;
+       if (!*s)
+           return count;
+
+       for (len = 0; isalnum(CharOf(s[len])); ++len) ;
+       for (mp = modelist; mp->name; mp++) {
+           if (len == mp->len
+               && strncmp(s, mp->name, mp->len) == 0)
+               break;
+       }
+       if (!mp->name)
+           return -1;
+
+       s += mp->len;
+       while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s)))
+           s++;
+       if (!*s)
+           return -1;
+
+       if ((c = decode_keyvalue(&s, False)) != -1) {
+           mp->value = c;
+           mp->set = 1;
+           count++;
+           TRACE(("...parsed #%d: %s=%#x\n", count, mp->name, c));
+       }
+    }
+}
+
+int
+GetBytesAvailable(int fd)
+{
+    long arg;
+    ioctl(fd, FIONREAD, (char *) &arg);
+    return (int) arg;
+}
+
+/* Utility function to try to hide system differences from
+   everybody who used to call killpg() */
+
+int
+kill_process_group(int pid, int sig)
+{
+    return kill(-pid, sig);
+}
+
+int
+ptioctl(int fd, int func, void *data)
+{
+    APIRET rc;
+    ULONG len;
+    struct pt_termios pt;
+    TERMIO_STRUCT *t;
+    int i;
+
+    switch (func) {
+    case TCGETA:
+       rc = DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCGETA,
+                        NULL, 0, NULL,
+                        (ULONG *) & pt, sizeof(struct pt_termios), &len);
+       if (rc)
+           return -1;
+       t = (TERMIO_STRUCT *) data;
+       t->c_iflag = pt.c_iflag;
+       t->c_oflag = pt.c_oflag;
+       t->c_cflag = pt.c_cflag;
+       t->c_lflag = pt.c_lflag;
+       for (i = 0; i < NCC; i++)
+           t->c_cc[i] = pt.c_cc[i];
+       return 0;
+    case TCSETA:
+    case TCSETAW:
+    case TCSETAF:
+       t = (TERMIO_STRUCT *) data;
+       pt.c_iflag = t->c_iflag;
+       pt.c_oflag = t->c_oflag;
+       pt.c_cflag = t->c_cflag;
+       pt.c_lflag = t->c_lflag;
+
+       for (i = 0; i < NCC; i++)
+           pt.c_cc[i] = t->c_cc[i];
+       if (func == TCSETA)
+           i = XTY_TIOCSETA;
+       else if (func == TCSETAW)
+           i = XTY_TIOCSETAW;
+       else
+           i = XTY_TIOCSETAF;
+       rc = DosDevIOCtl(fd, XFREE86_PTY, i,
+                        (ULONG *) & pt, sizeof(struct pt_termios), &len,
+                        NULL, 0, NULL);
+       return (rc) ? -1 : 0;
+    case TIOCCONS:
+       return DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCCONS,
+                          (ULONG *) data, sizeof(ULONG), &len,
+                          NULL, 0, NULL);
+    case TIOCSWINSZ:
+       return DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCSWINSZ,
+                          (ULONG *) data, sizeof(TTYSIZE_STRUCT), &len,
+                          NULL, 0, NULL);
+    case TIOCGWINSZ:
+       return DosDevIOCtl(fd, XFREE86_PTY, XTY_TIOCGWINSZ,
+                          NULL, 0, NULL,
+                          (ULONG *) data, sizeof(TTYSIZE_STRUCT), &len);
+    case XTY_ENADUP:
+       i = 1;
+       return DosDevIOCtl(fd, XFREE86_PTY, XTY_ENADUP,
+                          (ULONG *) & i, sizeof(ULONG), &len,
+                          NULL, 0, NULL);
+    case XTY_TRACE:
+       i = 2;
+       return DosDevIOCtl(fd, XFREE86_PTY, XTY_TRACE,
+                          (ULONG *) & i, sizeof(ULONG), &len,
+                          NULL, 0, NULL);
+    case PTMS_GETPTY:
+       i = 1;
+       return DosDevIOCtl(fd, XFREE86_PTY, PTMS_GETPTY,
+                          (ULONG *) & i, sizeof(ULONG), &len,
+                          (UCHAR *) data, 14, &len);
+    default:
+       return -1;
+    }
+}
diff --git a/package/debian/changelog b/package/debian/changelog
new file mode 100644 (file)
index 0000000..752dc21
--- /dev/null
@@ -0,0 +1,17 @@
+xterm-dev (268) unstable; urgency=low
+
+  * build-fixes, etc.
+
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Wed, 24 Nov 2010 06:17:16 -0500
+
+xterm-dev (267) unstable; urgency=low
+
+  * build-fixes, etc.
+
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Wed, 10 Nov 2010 18:46:41 -0500
+
+xterm-dev (266) unstable; urgency=low
+
+  * add build-script for testing, adapted from Debian xterm package.
+
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Fri, 22 Oct 2010 17:15:59 -0400
diff --git a/package/debian/color.sed b/package/debian/color.sed
new file mode 100644 (file)
index 0000000..6029c59
--- /dev/null
@@ -0,0 +1,4 @@
+s/! Uncomment this for "white" text on a dark background./! Set the default text foreground and background colors./
+s/!\*VT100\*foreground: gray90/*VT100*foreground: gray90/
+s/!\*VT100\*background: black/*VT100*background: black/
+/!\*VT100.scrollbar.thumb:[    ]*vlines2/,/!lines[     ]*-1,0,0,0,0,-1/s/!//
diff --git a/package/debian/compat b/package/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/package/debian/control b/package/debian/control
new file mode 100644 (file)
index 0000000..f511533
--- /dev/null
@@ -0,0 +1,21 @@
+Source: xterm-dev
+Section: x11
+Priority: optional
+Maintainer: Thomas E. Dickey <dickey@invisible-island.net>
+Homepage: http://invisible-island.net/xterm/
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.8.2
+
+Package: xterm-dev
+Architecture: any
+Depends: ${misc:Depends}
+Provides: x-terminal-emulator
+Recommends: x11-utils | xutils | bluit
+Description: X terminal emulator (development version)
+ xterm is the standard terminal emulator for the X Window System.
+ It provides DEC VT102 and Tektronix 4014 compatible terminals for
+ programs that cannot use the window system directly.  This version
+ implements ISO/ANSI colors, Unicode, and most of the control sequences
+ used by DEC VT220 terminals.
+ .
+ This package contains a development version of xterm.
diff --git a/package/debian/copyright b/package/debian/copyright
new file mode 100644 (file)
index 0000000..fef8e13
--- /dev/null
@@ -0,0 +1,221 @@
+Upstream source http://invisible-island.net/xterm/xterm.html
+
+-------------------------------------------------------------------------------
+Except as noted below, all copyrights use the same wording, denoted MIT-X11.
+That is not in Debian's list under /usr/share/licenses.  Here is the common
+wording:
+
+All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+-------------------------------------------------------------------------------
+Files: * */*
+License: MIT-X11
+
+Copyright 1996-2010 by Thomas E. Dickey
+
+(date ranges vary, depending on when the respective files were first changed
+significantly, and run through the most recent change date).
+
+-------------------------------------------------------------------------------
+Files: 88colres.pl
+License: MIT-X11
+
+Copyright 1999-2005,2007 by Thomas E. Dickey
+Copyright 1999-2000 by Steve Wall
+
+-------------------------------------------------------------------------------
+Files: vttests/88colors2.pl
+License: MIT-X11
+
+Copyright 1999-2007,2009 by Thomas E. Dickey
+Copyright 1999 by Steve Wall
+
+-------------------------------------------------------------------------------
+Files: vttests/256colors2.pl
+License: MIT-X11
+
+Copyright 1999-2007,2009 by Thomas E. Dickey
+Copyright 2002 by Steve Wall
+Copyright 1999 by Todd Larason
+
+-------------------------------------------------------------------------------
+Files: xcharmouse.h
+
+Copyright 1998 by Jason Bacon <acadix@execpc.com>
+
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+
+-------------------------------------------------------------------------------
+Files: xutf8.*
+License: MIT-X11
+
+Copyright (C) 2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+-------------------------------------------------------------------------------
+Files: ctlseqs.ms install-sh
+License: MIT-X11
+
+Copyright 1984-1994 X Consortium
+
+-------------------------------------------------------------------------------
+Copyright 1987,1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital Equipment
+Corporation not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+-------------------------------------------------------------------------------
+Copyright 1988,1989  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+-------------------------------------------------------------------------------
+Files: koi8rxterm.man uxterm.man
+License: MIT-X11
+
+Copyright 2001, 2004 Branden Robinson
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+-------------------------------------------------------------------------------
+Files: charclass.*
+
+Markus Kuhn -- 2000-07-03
+
+Permission to use, copy, modify, and distribute this software
+for any purpose and without fee is hereby granted. The author
+disclaims all warranties with regard to this software.
+
+-------------------------------------------------------------------------------
+Files: wcwidth.*
+
+Markus Kuhn -- 2007-05-25
+
+Permission to use, copy, modify, and distribute this software
+for any purpose and without fee is hereby granted. The author
+disclaims all warranties with regard to this software.
+
+-------------------------------------------------------------------------------
+Files: config.guess config.sub
+License: GPL-2+
+
+       Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+       2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+       Free Software Foundation, Inc.
+
+-------------------------------------------------------------------------------
+Files: configure
+License: GPL-2+
+
+       Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+       Free Software Foundation, Inc.
+
+-------------------------------------------------------------------------------
diff --git a/package/debian/rules b/package/debian/rules
new file mode 100755 (executable)
index 0000000..ad0d680
--- /dev/null
@@ -0,0 +1,185 @@
+#!/usr/bin/make -f
+# Made with the aid of dh_make, by Craig Small
+# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
+# Some lines taken from debmake, by Cristoph Lameter.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+DESKTOP_VENDOR  = dickey
+
+PKG_SUFFIX     = -dev
+
+PACKAGE                := $(shell dpkg-parsechangelog| \
+                       sed -n 's/^Source: \(.*\)$$/\1/p')
+
+PKG_APPDEFAULTS        := /etc/X11/app-defaults
+PKG_DESKTOP    := /usr/share/applications
+
+DSTDIR         := $(CURDIR)/debian/$(PACKAGE)
+MY_DESKTOP     := $(DSTDIR)/usr/share/applications
+
+CFLAGS =
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+DEBOP=--enable-debug
+else
+DEBOP=
+endif
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+        CFLAGS += -O0
+else
+        CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+        INSTALL_PROGRAM += -s
+endif
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+
+       ./configure \
+               --host=$(DEB_HOST_GNU_TYPE) \
+               --build=$(DEB_BUILD_GNU_TYPE) \
+               --program-suffix=$(PKG_SUFFIX) \
+               --prefix=/usr \
+               --libexecdir=\$${prefix}/lib \
+               --mandir=\$${prefix}/share/man \
+               --sysconfdir=/etc/$(PACKAGE) \
+               --localstatedir=/var \
+               --libdir=/etc/$(PACKAGE) \
+               --without-xterm-symlink \
+               --enable-256-color \
+               --enable-88-color \
+               --enable-dabbrev \
+               --enable-dec-locator \
+               --enable-exec-xterm \
+               --enable-hp-fkeys \
+               --enable-load-vt-fonts \
+               --enable-logfile-exec \
+               --enable-logging \
+               --enable-mini-luit \
+               --enable-paste64 \
+               --enable-rectangles \
+               --enable-sco-fkeys \
+               --enable-tcap-fkeys \
+               --enable-tcap-query \
+               --enable-toolbar \
+               --enable-wide-chars \
+               --enable-xmc-glitch \
+               --with-app-defaults=$(PKG_APPDEFAULTS) \
+               --with-icondir=\$${prefix}/share/pixmaps \
+               --with-own-terminfo=\$${prefix}/share/terminfo \
+               --with-terminal-type=xterm-new \
+               --with-utempter \
+               ${DEBOP}
+
+       touch configure-stamp
+
+build: build-stamp
+build-stamp: configure-stamp
+       dh_testdir
+
+       $(MAKE)
+
+       touch build-stamp
+
+clean:
+       dh_testdir
+       dh_testroot
+
+       [ ! -f Makefile ] || $(MAKE) distclean
+
+       dh_clean
+
+install: install-stamp
+install-stamp: build-stamp
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       $(MAKE) install \
+               DESTDIR=$(CURDIR)/debian/$(PACKAGE)
+
+       touch install-stamp
+
+install: install-indep install-arch
+install-indep:
+
+install-arch:
+       dh_testdir
+       dh_testroot
+       dh_prep -s 
+       dh_installdirs -s
+
+       $(MAKE) install-bin \
+               DESTDIR=$(DSTDIR)
+
+# Build architecture-independent files here.
+binary-indep: build install
+       dh_testdir
+       dh_testroot
+
+       # This overwrites the Debian package's copy of app-defaults and icons.
+       # But the resources are not the same; they are patched.
+       sed -i -f package/debian/color.sed XTerm-col.ad
+       sed -i -f package/debian/xterm-xres.sed XTerm.ad
+
+       $(MAKE) install-app \
+               install-icon \
+               install-man \
+               DESTDIR=$(DSTDIR)
+
+       # Follow-up with a check against the installed resource files.
+       ( cd $(DSTDIR)$(PKG_APPDEFAULTS) && $(SHELL) -c 'for p in *;do diff -u $$p $(PKG_APPDEFAULTS)/; done' ; exit 0 )
+
+       # The Debian package does not install desktop files.
+       # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=486317
+       $(SHELL) -c 'for p in *.desktop;do \
+               sed -i \
+                       -e "s/Categories=System;/Categories=Application;Utility;/" \
+                       -e "s/^\\(Name=.*\\)/\\1$(PKG_SUFFIX)/" \
+                       -e "s/^\\(Exec=.*\\)/\\1$(PKG_SUFFIX)/" \
+               $$p; done'
+
+       $(MAKE) install-desktop \
+               DESKTOP_FLAGS="--vendor='$(DESKTOP_VENDOR)' --dir $(MY_DESKTOP)"
+
+       ( cd $(DSTDIR)$(PKG_DESKTOP) \
+         && $(SHELL) -c 'for p in *;do \
+               test -n "$(PKG_SUFFIX)" && mv $$p `basename $$p .desktop`$(PKG_SUFFIX).desktop; \
+               diff -u $$p $(PKG_DESKTOP)/; \
+               done' ; \
+         exit 0 )
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installdebconf
+       dh_installdocs
+       dh_installmenu
+       dh_installmime
+       dh_installexamples tektests vttests
+       dh_installchangelogs
+       dh_install
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install install-stamp
diff --git a/package/debian/source/format b/package/debian/source/format
new file mode 100644 (file)
index 0000000..89ae9db
--- /dev/null
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/package/debian/watch b/package/debian/watch
new file mode 100644 (file)
index 0000000..6c46327
--- /dev/null
@@ -0,0 +1,4 @@
+version=3
+
+opts=passive ftp://invisible-island.net/xterm/current/xterm\.tar.gz \
+ debian  uupdate
diff --git a/package/debian/xterm-dev.docs b/package/debian/xterm-dev.docs
new file mode 100644 (file)
index 0000000..b29b135
--- /dev/null
@@ -0,0 +1,8 @@
+INSTALL
+README.i18n
+THANKS
+ctlseqs.ms
+ctlseqs.txt
+termcap
+terminfo
+xterm.log.html
diff --git a/package/debian/xterm-xres.sed b/package/debian/xterm-xres.sed
new file mode 100644 (file)
index 0000000..745cb58
--- /dev/null
@@ -0,0 +1,8 @@
+/\*tek4014\*fontSmall:[        ]*6x10/a\
+\
+! Debian package customizations follow.\
+*backarrowKeyIsErase: true\
+*ptyInitialErase: true
+/!*allowWindowOps: false/a\
+*allowWindowOps: true\
+*activeIcon: true
diff --git a/package/xterm.spec b/package/xterm.spec
new file mode 100644 (file)
index 0000000..668cb42
--- /dev/null
@@ -0,0 +1,175 @@
+# $XTermId: xterm.spec,v 1.7 2010/11/24 11:16:58 tom Exp $
+Summary: A text-based Web browser
+Name: xterm
+Version: dev
+Release: 268
+License: X11
+Group: Applications/Internet
+Source: xterm-%{release}.tgz
+# URL: http://invisible-island.net/xterm/
+Provides: x-terminal-emulator
+
+%description
+xterm is the standard terminal emulator for the X Window System.
+It provides DEC VT102 and Tektronix 4014 compatible terminals for
+programs that cannot use the window system directly.  This version
+implements ISO/ANSI colors, Unicode, and most of the control sequences
+used by DEC VT220 terminals.
+
+This package provides four commands:
+ a) xterm, which is the actual terminal emulator
+ b) uxterm, which is a wrapper around xterm which sets xterm to use UTF-8
+    encoding when the user's locale supports this,
+ c) koi8rxterm, a wrapper similar to uxterm for locales that use the
+    KOI8-R character set, and
+ d) resize.
+
+A complete list of control sequences supported by the X terminal emulator
+is provided in /usr/share/doc/xterm.
+
+The xterm program uses bitmap images provided by the xbitmaps package.
+
+Those interested in using koi8rxterm will likely want to install the
+xfonts-cyrillic package as well.
+
+%prep
+
+%define my_suffix -dev
+
+%define desktop_vendor  dickey
+%define desktop_utils   %(if which desktop-file-install 2>&1 >/dev/null ; then echo "yes" ; fi)
+
+%define apps_shared %(test -d /usr/share/X11/app-defaults && echo 1 || echo 0)
+%define apps_syscnf %(test -d /etc/X11/app-defaults && echo 1 || echo 0)
+
+%if %{apps_shared}
+%define _xresdir    %{_datadir}/X11/app-defaults
+%else
+%define _xresdir    %{_sysconfdir}/X11/app-defaults
+%endif
+
+%define _iconsdir   %{_datadir}/icons
+%define _pixmapsdir %{_datadir}/pixmaps
+%define my_docdir   %{_datadir}/doc/xterm%{my_suffix}
+
+%setup -q -n xterm-%{release}
+
+%build
+CPPFLAGS="-DMISC_EXP -DEXP_HTTP_HEADERS" \
+%configure \
+       --target %{_target_platform} \
+       --prefix=%{_prefix} \
+       --bindir=%{_bindir} \
+       --datadir=%{_datadir} \
+       --mandir=%{_mandir} \
+%if "%{my_suffix}" != ""
+       --program-suffix=%{my_suffix} \
+       --without-xterm-symlink \
+%endif
+       --enable-256-color \
+       --enable-88-color \
+       --enable-dabbrev \
+       --enable-dec-locator \
+       --enable-exec-xterm \
+       --enable-hp-fkeys \
+       --enable-load-vt-fonts \
+       --enable-logfile-exec \
+       --enable-logging \
+       --enable-mini-luit \
+       --enable-paste64 \
+       --enable-rectangles \
+       --enable-sco-fkeys \
+       --enable-tcap-fkeys \
+       --enable-tcap-query \
+       --enable-toolbar \
+       --enable-wide-chars \
+       --enable-xmc-glitch \
+       --with-app-defaults=%{_xresdir} \
+       --with-icondir=%{_pixmapsdir} \
+       --with-own-terminfo=%{_datadir}/terminfo \
+       --with-terminal-type=xterm-new \
+       --with-utempter
+make
+
+chmod u+w XTerm.ad
+cat >>XTerm.ad <<EOF
+*backarrowKeyIsErase: true
+*ptyInitialErase: true
+EOF
+ls -l *.ad
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+# Usually do not use install-ti, since that will conflict with ncurses.
+make install-bin install-man install-app install-icon \
+%if "%{install_ti}" == "yes"
+       install-ti \
+%endif
+       DESTDIR=$RPM_BUILD_ROOT \
+       TERMINFO=%{_datadir}/terminfo
+
+       mkdir -p $RPM_BUILD_ROOT%{my_docdir}
+       cp \
+               ctlseqs.txt \
+               README.i18n \
+               THANKS \
+               xterm.log.html \
+       $RPM_BUILD_ROOT%{my_docdir}/
+
+       cp -r vttests \
+       $RPM_BUILD_ROOT%{my_docdir}/
+
+       # The scripts are readable, but not executable, to let find-requires
+       # know that they do not depend on Perl packages.
+       chmod 644 $RPM_BUILD_ROOT%{my_docdir}/vttests/*
+
+%if "%{desktop_utils}" == "yes"
+for p in *.desktop
+do
+       sed -i \
+               -e 's/Categories=System;/Categories=Application;Utility;/' \
+               -e 's/^\\(Name=.*\\)/\\1%{my_suffix}/' \
+               -e 's/^\\(Exec=.*\\)/\\1%{my_suffix}/' \
+       $p
+done
+
+make install-desktop \
+       DESKTOP_FLAGS="--vendor='%{desktop_vendor}' --dir $RPM_BUILD_ROOT%{_datadir}/applications"
+
+test -n "%{my_suffix}" && \
+( cd $RPM_BUILD_ROOT%{_datadir}/applications
+       for p in *.desktop
+       do
+               mv $p `basename $p .desktop`%{my_suffix}.desktop
+       done
+)
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/koi8rxterm%{my_suffix}
+%{_bindir}/xterm%{my_suffix}
+%{_bindir}/uxterm%{my_suffix}
+%{_bindir}/resize%{my_suffix}
+%{_mandir}/*/*
+%{my_docdir}/*
+%{_pixmapsdir}/xterm*.xpm
+%{_xresdir}/*XTerm*
+
+%if "%{install_ti}" == "yes"
+%{_datadir}/terminfo/*
+%endif
+
+%if "%{desktop_utils}" == "yes"
+%config(missingok) %{_datadir}/applications/%{desktop_vendor}-xterm%{my_suffix}.desktop
+%config(missingok) %{_datadir}/applications/%{desktop_vendor}-uxterm%{my_suffix}.desktop
+%endif
+
+%changelog
+
+* Fri Oct 22 2010 Thomas E. Dickey
+- initial version.
diff --git a/packaging/16colors.txt b/packaging/16colors.txt
new file mode 100644 (file)
index 0000000..9b09e77
--- /dev/null
@@ -0,0 +1,24 @@
+\e[0;037;040mANSI-Colors v1.0
+\e[0;037;040m(c)1994  by: Pablo Ariel Kohan
+\e[0;037;040m   |3 9 3 9 3 9 3 9 3 9 3 9 3 9 3 9|
+\e[0;037;040m   |0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7|
+\e[0;037;040m---+-------------------------------+---
+\e[0;037;040m040|\e[0;030;040mX \e[0;090;040mX \e[0;031;040mX \e[0;091;040mX \e[0;032;040mX \e[0;092;040mX \e[0;033;040mX \e[0;093;040mX \e[0;034;040mX \e[0;094;040mX \e[0;035;040mX \e[0;095;040mX \e[0;036;040mX \e[0;096;040mX \e[0;037;040mX \e[0;097;040mX\e[0;037;040m|040 
+\e[0;037;040m100|\e[0;030;100mX \e[0;090;100mX \e[0;031;100mX \e[0;091;100mX \e[0;032;100mX \e[0;092;100mX \e[0;033;100mX \e[0;093;100mX \e[0;034;100mX \e[0;094;100mX \e[0;035;100mX \e[0;095;100mX \e[0;036;100mX \e[0;096;100mX \e[0;037;100mX \e[0;097;100mX\e[0;037;040m|100
+\e[0;037;040m041|\e[0;030;041mX \e[0;090;041mX \e[0;031;041mX \e[0;091;041mX \e[0;032;041mX \e[0;092;041mX \e[0;033;041mX \e[0;093;041mX \e[0;034;041mX \e[0;094;041mX \e[0;035;041mX \e[0;095;041mX \e[0;036;041mX \e[0;096;041mX \e[0;037;041mX \e[0;097;041mX\e[0;037;040m|041 
+\e[0;037;040m101|\e[0;030;101mX \e[0;090;101mX \e[0;031;101mX \e[0;091;101mX \e[0;032;101mX \e[0;092;101mX \e[0;033;101mX \e[0;093;101mX \e[0;034;101mX \e[0;094;101mX \e[0;035;101mX \e[0;095;101mX \e[0;036;101mX \e[0;096;101mX \e[0;037;101mX \e[0;097;101mX\e[0;037;040m|101
+\e[0;037;040m042|\e[0;030;042mX \e[0;090;042mX \e[0;031;042mX \e[0;091;042mX \e[0;032;042mX \e[0;092;042mX \e[0;033;042mX \e[0;093;042mX \e[0;034;042mX \e[0;094;042mX \e[0;035;042mX \e[0;095;042mX \e[0;036;042mX \e[0;096;042mX \e[0;037;042mX \e[0;097;042mX\e[0;037;040m|042 
+\e[0;037;040m102|\e[0;030;102mX \e[0;090;102mX \e[0;031;102mX \e[0;091;102mX \e[0;032;102mX \e[0;092;102mX \e[0;033;102mX \e[0;093;102mX \e[0;034;102mX \e[0;094;102mX \e[0;035;102mX \e[0;095;102mX \e[0;036;102mX \e[0;096;102mX \e[0;037;102mX \e[0;097;102mX\e[0;037;040m|102
+\e[0;037;040m043|\e[0;030;043mX \e[0;090;043mX \e[0;031;043mX \e[0;091;043mX \e[0;032;043mX \e[0;092;043mX \e[0;033;043mX \e[0;093;043mX \e[0;034;043mX \e[0;094;043mX \e[0;035;043mX \e[0;095;043mX \e[0;036;043mX \e[0;096;043mX \e[0;037;043mX \e[0;097;043mX\e[0;037;040m|043 
+\e[0;037;040m103|\e[0;030;103mX \e[0;090;103mX \e[0;031;103mX \e[0;091;103mX \e[0;032;103mX \e[0;092;103mX \e[0;033;103mX \e[0;093;103mX \e[0;034;103mX \e[0;094;103mX \e[0;035;103mX \e[0;095;103mX \e[0;036;103mX \e[0;096;103mX \e[0;037;103mX \e[0;097;103mX\e[0;037;040m|103
+\e[0;037;040m044|\e[0;030;044mX \e[0;090;044mX \e[0;031;044mX \e[0;091;044mX \e[0;032;044mX \e[0;092;044mX \e[0;033;044mX \e[0;093;044mX \e[0;034;044mX \e[0;094;044mX \e[0;035;044mX \e[0;095;044mX \e[0;036;044mX \e[0;096;044mX \e[0;037;044mX \e[0;097;044mX\e[0;037;040m|044 
+\e[0;037;040m104|\e[0;030;104mX \e[0;090;104mX \e[0;031;104mX \e[0;091;104mX \e[0;032;104mX \e[0;092;104mX \e[0;033;104mX \e[0;093;104mX \e[0;034;104mX \e[0;094;104mX \e[0;035;104mX \e[0;095;104mX \e[0;036;104mX \e[0;096;104mX \e[0;037;104mX \e[0;097;104mX\e[0;037;040m|104
+\e[0;037;040m045|\e[0;030;045mX \e[0;090;045mX \e[0;031;045mX \e[0;091;045mX \e[0;032;045mX \e[0;092;045mX \e[0;033;045mX \e[0;093;045mX \e[0;034;045mX \e[0;094;045mX \e[0;035;045mX \e[0;095;045mX \e[0;036;045mX \e[0;096;045mX \e[0;037;045mX \e[0;097;045mX\e[0;037;040m|045 
+\e[0;037;040m105|\e[0;030;105mX \e[0;090;105mX \e[0;031;105mX \e[0;091;105mX \e[0;032;105mX \e[0;092;105mX \e[0;033;105mX \e[0;093;105mX \e[0;034;105mX \e[0;094;105mX \e[0;035;105mX \e[0;095;105mX \e[0;036;105mX \e[0;096;105mX \e[0;037;105mX \e[0;097;105mX\e[0;037;040m|105
+\e[0;037;040m046|\e[0;030;046mX \e[0;090;046mX \e[0;031;046mX \e[0;091;046mX \e[0;032;046mX \e[0;092;046mX \e[0;033;046mX \e[0;093;046mX \e[0;034;046mX \e[0;094;046mX \e[0;035;046mX \e[0;095;046mX \e[0;036;046mX \e[0;096;046mX \e[0;037;046mX \e[0;097;046mX\e[0;037;040m|046 
+\e[0;037;040m106|\e[0;030;106mX \e[0;090;106mX \e[0;031;106mX \e[0;091;106mX \e[0;032;106mX \e[0;092;106mX \e[0;033;106mX \e[0;093;106mX \e[0;034;106mX \e[0;094;106mX \e[0;035;106mX \e[0;095;106mX \e[0;036;106mX \e[0;096;106mX \e[0;037;106mX \e[0;097;106mX\e[0;037;040m|106
+\e[0;037;040m047|\e[0;030;047mX \e[0;090;047mX \e[0;031;047mX \e[0;091;047mX \e[0;032;047mX \e[0;092;047mX \e[0;033;047mX \e[0;093;047mX \e[0;034;047mX \e[0;094;047mX \e[0;035;047mX \e[0;095;047mX \e[0;036;047mX \e[0;096;047mX \e[0;037;047mX \e[0;097;047mX\e[0;037;040m|047 
+\e[0;037;040m107|\e[0;030;107mX \e[0;090;107mX \e[0;031;107mX \e[0;091;107mX \e[0;032;107mX \e[0;092;107mX \e[0;033;107mX \e[0;093;107mX \e[0;034;107mX \e[0;094;107mX \e[0;035;107mX \e[0;095;107mX \e[0;036;107mX \e[0;096;107mX \e[0;037;107mX \e[0;097;107mX\e[0;037;040m|107
+\e[0;037;040m---+-------------------------------+---
+\e[0;037;040m   |3 9 3 9 3 9 3 9 3 9 3 9 3 9 3 9|
+\e[0;037;040m   |0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7|
diff --git a/packaging/buildfix.patch b/packaging/buildfix.patch
new file mode 100644 (file)
index 0000000..bffe191
--- /dev/null
@@ -0,0 +1,15 @@
+--- xterm-261/Makefile.in.ori  2010-08-16 12:42:01.000000000 +0800
++++ xterm-261/Makefile.in      2010-08-16 12:42:44.000000000 +0800
+@@ -160,10 +160,10 @@
+ main$o resize$o screen$o : xterm_io.h
+ xterm$x : $(OBJS1)
+-      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(LIBS) $(EXTRA_LOADFLAGS)
++      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(LIBS) $(EXTRA_LOADFLAGS) -ltinfo
+ resize$x : $(OBJS2)
+-      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(LIBS)
++      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(LIBS) -ltinfo
+ 256colres.h :
+       -rm -f $@
diff --git a/packaging/failsafe.desktop b/packaging/failsafe.desktop
new file mode 100644 (file)
index 0000000..513327a
--- /dev/null
@@ -0,0 +1,4 @@
+[Desktop entry]
+Name=failsafe X session
+Comment=This X session provides a fallback to a single xterm
+Exec=/usr/bin/xterm
diff --git a/packaging/xterm-256-man-page_paths.patch b/packaging/xterm-256-man-page_paths.patch
new file mode 100644 (file)
index 0000000..6bfd46d
--- /dev/null
@@ -0,0 +1,48 @@
+diff -up xterm-256/minstall.sh.man-page_paths xterm-256/minstall.sh
+--- xterm-256/minstall.sh.man-page_paths       2010-03-04 00:44:49.000000000 +0100
++++ xterm-256/minstall.sh      2010-03-09 12:11:26.000000000 +0100
+@@ -109,6 +109,10 @@ WTMP_PATH=$WTMP_PATH/$WTMP_NAME
+ X_MANSECT=`man X 2>&1 | tr '\012' '\020' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
+ test -z "$X_MANSECT" && X_MANSECT=$suffix
++fontpath=/usr/share/X11/fonts
++xorgcfgdir=/etc/X11
++xorgcfgfil=xorg.conf
++X_MANSECT=7
+ sed   -e 's%__vendorversion__%"X Window System"%' \
+       -e s%__apploaddir__%$APPS_DIR% \
+       -e s%__mansuffix__%$MY_MANSECT%g \
+@@ -117,6 +121,9 @@ sed        -e 's%__vendorversion__%"X Window Sy
+       -e s%/etc/utmp%$UTMP_PATH%g \
+       -e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \
+       -e s%/etc/wtmp%$WTMP_PATH%g \
++      -e s%__fontpath__%$fontpath%g \
++      -e s%__xorgcfgdir__%$xorgcfgdir%g \
++      -e s%__xorgcfgfil__%$xorgcfgfil%g \
+       $OLD_FILE >$NEW_FILE
+ echo "$MINSTALL $OLD_FILE $END_FILE"
+diff -up xterm-256/xterm.man.man-page_paths xterm-256/xterm.man
+--- xterm-256/xterm.man.man-page_paths 2010-03-03 23:30:35.000000000 +0100
++++ xterm-256/xterm.man        2010-03-09 12:11:26.000000000 +0100
+@@ -1699,17 +1699,17 @@ Since X11R6, bitmap fonts have been scal
+ The font server claims to provide the bold font that \fIxterm\fP requests,
+ but the result is not always readable.
+ XFree86 provides a feature which can be used to suppress the scaling.
+-In the X server's configuration file (e.g., "/etc/X11/XFree86"), you
++In the X server's configuration file (e.g., __xorgcfgdir__/__xorgcfgfil__), you
+ can add ":unscaled" to the end of the directory specification for the
+ "misc" fonts, which comprise the fixed-pitch fonts that are used by \fIxterm\fP.
+ For example
+ .RS
+-      FontPath        "/usr/lib/X11/fonts/misc/"
++      FontPath        "__fontpath__"
+ .RE
+ .IP
+ would become
+ .RS
+-      FontPath        "/usr/lib/X11/fonts/misc/:unscaled"
++      FontPath        "__fontpath__/misc/:unscaled"
+ .RE
+ .IP
+ Depending on your configuration, the font server may have its own configuration
diff --git a/packaging/xterm-261-resources.patch b/packaging/xterm-261-resources.patch
new file mode 100644 (file)
index 0000000..91b7808
--- /dev/null
@@ -0,0 +1,17 @@
+--- xterm-261/XTerm.ad.ori     2010-08-12 14:48:34.000000000 +0800
++++ xterm-261/XTerm.ad 2010-08-12 14:50:49.000000000 +0800
+@@ -249,3 +249,14 @@
+ !*allowTcapOps: false
+ !*allowTitleOps: false
+ !*allowWindowOps: false
++
++! MeeGo Defaults:
++*allowFontOps: false
++*allowTcapOps: false
++*allowTitleOps: false
++*allowWindowOps: false
++*VT100*eightBitInput: false
++*VT100*metaSendsEscape: true
++*VT100*backarrowKey: false
++*VT100*scrollBar: true
++*VT100*utf8Title: true
diff --git a/packaging/xterm.changes b/packaging/xterm.changes
new file mode 100644 (file)
index 0000000..5bb55d4
--- /dev/null
@@ -0,0 +1,15 @@
+* Fri May 18 22:18:09 UTC 2012 - tracy.graydon@intel.com
+- Make that tar.bz2 
+
+* Fri May 18 22:10:09 UTC 2012 - tracy.graydon@intel.com
+- Change the tarball to .bz2 
+
+* Fri May 18 20:57:48 UTC 2012 - tracy.graydon@intel.com
+- More spec fixing 
+
+* Fri May 18 04:36:40 UTC 2012 - tracy.graydon@intel.com
+- fix packaging 
+
+* Fri May 18 04:25:31 UTC 2012 - tracy.graydon@intel.com
+- obs/gerrit sync 
+
diff --git a/packaging/xterm.desktop b/packaging/xterm.desktop
new file mode 100644 (file)
index 0000000..3e7c0fb
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=xterm Terminal
+GenericName=Terminal
+Comment=Terminal emulator for the X Window System
+Exec=xterm
+Icon=icons-Applications-xterminal
+Type=Application
+Categories=System;Utility;
+NoDisplay=false
+NotShowIn=X-MEEGO-NB;
diff --git a/packaging/xterm.spec b/packaging/xterm.spec
new file mode 100644 (file)
index 0000000..75da4b5
--- /dev/null
@@ -0,0 +1,91 @@
+%define x11_app_defaults_dir %(pkg-config --variable appdefaultdir xt)
+
+Name:       xterm
+Summary:    Terminal emulator for the X Window System
+Version:    268
+Release:    2.5
+Group:      System/X
+License:    MIT
+URL:        http://dickey.his.com/xterm
+Source0:    %{name}-%{version}.tar.bz2
+Source1:    16colors.txt
+Source2:    xterm.desktop
+Source3:    failsafe.desktop
+Patch0:     xterm-261-resources.patch
+Patch1:     xterm-256-man-page_paths.patch
+Patch2:     buildfix.patch
+BuildRequires:  pkgconfig(xft)
+BuildRequires:  pkgconfig(xaw7)
+BuildRequires:  pkgconfig(xext)
+BuildRequires:  pkgconfig(ncurses)
+BuildRequires:  pkgconfig(xkbfile)
+BuildRequires:  imake
+BuildRequires:  desktop-file-utils
+
+
+%description
+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 not use the window system directly.
+
+
+%prep
+%setup -q
+
+# xterm-261-resources.patch
+%patch0 -p1
+# xterm-256-man-page_paths.patch
+%patch1 -p1
+# buildfix.patch
+%patch2 -p1
+
+%build
+
+%configure --disable-static \
+    --with-app-defaults=%{x11_app_defaults_dir} \
+    --enable-256-color \
+    --enable-exec-xterm \
+    --enable-luit \
+    --enable-warnings \
+    --enable-wide-chars \
+    --with-tty-group=tty \
+    --disable-full-tgetent
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+mkdir -p %{buildroot}%{_datadir}/applications/
+install -m 644 %{SOURCE2} %{buildroot}%{_datadir}/applications/
+mkdir -p %{buildroot}%{_datadir}/xsessions/
+install -m 644 %{SOURCE3} %{buildroot}%{_datadir}/xsessions/
+
+cp -fp %{SOURCE1} 16colors.txt
+
+desktop-file-install --delete-original       \
+  --dir %{buildroot}%{_datadir}/applications             \
+   %{buildroot}%{_datadir}/applications/*.desktop
+
+
+%files
+%defattr(-,root,root,-)
+%doc xterm.log.html ctlseqs.txt 16colors.txt README.i18n
+%{_bindir}/xterm
+%{_bindir}/koi8rxterm
+%{_bindir}/resize
+%{_bindir}/uxterm
+%doc %{_mandir}/man1/koi8rxterm.1*
+%doc %{_mandir}/man1/resize.1*
+%doc %{_mandir}/man1/uxterm.1*
+%doc %{_mandir}/man1/xterm.1*
+%{_datadir}/applications/xterm.desktop
+%{_datadir}/xsessions/failsafe.desktop
+%{_datadir}/pixmaps/*
+%{x11_app_defaults_dir}/KOI8RXTerm*
+%{x11_app_defaults_dir}/UXTerm*
+%{x11_app_defaults_dir}/XTerm*
+
+
diff --git a/plink.sh b/plink.sh
new file mode 100755 (executable)
index 0000000..c3c991b
--- /dev/null
+++ b/plink.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+# $XTermId: plink.sh,v 1.7 2010/11/28 23:55:35 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2001-2005,2010 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# Reduce the number of dynamic libraries used to link an executable.
+LINKIT=
+while test $# != 0
+do
+       OPT="$1"
+       shift
+       case $OPT in
+       -k*)
+               OPT=`echo "$OPT" | sed -e 's/^-k/-l/'`
+               LINKIT="$LINKIT $OPT"
+               ;;
+       -l*)
+               echo "testing if $OPT is needed"
+               if ( eval $LINKIT $* >/dev/null 2>/dev/null )
+               then
+                       : echo ...no
+               else
+                       echo ...yes
+                       LINKIT="$LINKIT $OPT"
+               fi
+               ;;
+       *)
+               LINKIT="$LINKIT $OPT"
+               ;;
+       esac
+done
+eval $LINKIT
diff --git a/precompose.c b/precompose.c
new file mode 100644 (file)
index 0000000..da0d346
--- /dev/null
@@ -0,0 +1,1055 @@
+/*
+ * Canonical Compositions
+ *
+ * DO NOT EDIT BY HAND! This is generated by the script
+ * unicode/make-precompose.sh
+ */
+/* $XTermId: precompose.c,v 1.8 2007/02/05 01:06:36 Thomas.Wolff Exp $ */
+/* $XFree86$ */
+
+#include <precompose.h>
+
+static struct {
+  int replacement;
+  int base;
+  int comb; 
+} precompositions[] = {
+{ 0x226E, 0x003C, 0x0338},
+{ 0x2260, 0x003D, 0x0338},
+{ 0x226F, 0x003E, 0x0338},
+{ 0x00C0, 0x0041, 0x0300},
+{ 0x00C1, 0x0041, 0x0301},
+{ 0x00C2, 0x0041, 0x0302},
+{ 0x00C3, 0x0041, 0x0303},
+{ 0x0100, 0x0041, 0x0304},
+{ 0x0102, 0x0041, 0x0306},
+{ 0x0226, 0x0041, 0x0307},
+{ 0x00C4, 0x0041, 0x0308},
+{ 0x1EA2, 0x0041, 0x0309},
+{ 0x00C5, 0x0041, 0x030A},
+{ 0x01CD, 0x0041, 0x030C},
+{ 0x0200, 0x0041, 0x030F},
+{ 0x0202, 0x0041, 0x0311},
+{ 0x1EA0, 0x0041, 0x0323},
+{ 0x1E00, 0x0041, 0x0325},
+{ 0x0104, 0x0041, 0x0328},
+{ 0x1E02, 0x0042, 0x0307},
+{ 0x1E04, 0x0042, 0x0323},
+{ 0x1E06, 0x0042, 0x0331},
+{ 0x0106, 0x0043, 0x0301},
+{ 0x0108, 0x0043, 0x0302},
+{ 0x010A, 0x0043, 0x0307},
+{ 0x010C, 0x0043, 0x030C},
+{ 0x00C7, 0x0043, 0x0327},
+{ 0x1E0A, 0x0044, 0x0307},
+{ 0x010E, 0x0044, 0x030C},
+{ 0x1E0C, 0x0044, 0x0323},
+{ 0x1E10, 0x0044, 0x0327},
+{ 0x1E12, 0x0044, 0x032D},
+{ 0x1E0E, 0x0044, 0x0331},
+{ 0x00C8, 0x0045, 0x0300},
+{ 0x00C9, 0x0045, 0x0301},
+{ 0x00CA, 0x0045, 0x0302},
+{ 0x1EBC, 0x0045, 0x0303},
+{ 0x0112, 0x0045, 0x0304},
+{ 0x0114, 0x0045, 0x0306},
+{ 0x0116, 0x0045, 0x0307},
+{ 0x00CB, 0x0045, 0x0308},
+{ 0x1EBA, 0x0045, 0x0309},
+{ 0x011A, 0x0045, 0x030C},
+{ 0x0204, 0x0045, 0x030F},
+{ 0x0206, 0x0045, 0x0311},
+{ 0x1EB8, 0x0045, 0x0323},
+{ 0x0228, 0x0045, 0x0327},
+{ 0x0118, 0x0045, 0x0328},
+{ 0x1E18, 0x0045, 0x032D},
+{ 0x1E1A, 0x0045, 0x0330},
+{ 0x1E1E, 0x0046, 0x0307},
+{ 0x01F4, 0x0047, 0x0301},
+{ 0x011C, 0x0047, 0x0302},
+{ 0x1E20, 0x0047, 0x0304},
+{ 0x011E, 0x0047, 0x0306},
+{ 0x0120, 0x0047, 0x0307},
+{ 0x01E6, 0x0047, 0x030C},
+{ 0x0122, 0x0047, 0x0327},
+{ 0x0124, 0x0048, 0x0302},
+{ 0x1E22, 0x0048, 0x0307},
+{ 0x1E26, 0x0048, 0x0308},
+{ 0x021E, 0x0048, 0x030C},
+{ 0x1E24, 0x0048, 0x0323},
+{ 0x1E28, 0x0048, 0x0327},
+{ 0x1E2A, 0x0048, 0x032E},
+{ 0x00CC, 0x0049, 0x0300},
+{ 0x00CD, 0x0049, 0x0301},
+{ 0x00CE, 0x0049, 0x0302},
+{ 0x0128, 0x0049, 0x0303},
+{ 0x012A, 0x0049, 0x0304},
+{ 0x012C, 0x0049, 0x0306},
+{ 0x0130, 0x0049, 0x0307},
+{ 0x00CF, 0x0049, 0x0308},
+{ 0x1EC8, 0x0049, 0x0309},
+{ 0x01CF, 0x0049, 0x030C},
+{ 0x0208, 0x0049, 0x030F},
+{ 0x020A, 0x0049, 0x0311},
+{ 0x1ECA, 0x0049, 0x0323},
+{ 0x012E, 0x0049, 0x0328},
+{ 0x1E2C, 0x0049, 0x0330},
+{ 0x0134, 0x004A, 0x0302},
+{ 0x1E30, 0x004B, 0x0301},
+{ 0x01E8, 0x004B, 0x030C},
+{ 0x1E32, 0x004B, 0x0323},
+{ 0x0136, 0x004B, 0x0327},
+{ 0x1E34, 0x004B, 0x0331},
+{ 0x0139, 0x004C, 0x0301},
+{ 0x013D, 0x004C, 0x030C},
+{ 0x1E36, 0x004C, 0x0323},
+{ 0x013B, 0x004C, 0x0327},
+{ 0x1E3C, 0x004C, 0x032D},
+{ 0x1E3A, 0x004C, 0x0331},
+{ 0x1E3E, 0x004D, 0x0301},
+{ 0x1E40, 0x004D, 0x0307},
+{ 0x1E42, 0x004D, 0x0323},
+{ 0x01F8, 0x004E, 0x0300},
+{ 0x0143, 0x004E, 0x0301},
+{ 0x00D1, 0x004E, 0x0303},
+{ 0x1E44, 0x004E, 0x0307},
+{ 0x0147, 0x004E, 0x030C},
+{ 0x1E46, 0x004E, 0x0323},
+{ 0x0145, 0x004E, 0x0327},
+{ 0x1E4A, 0x004E, 0x032D},
+{ 0x1E48, 0x004E, 0x0331},
+{ 0x00D2, 0x004F, 0x0300},
+{ 0x00D3, 0x004F, 0x0301},
+{ 0x00D4, 0x004F, 0x0302},
+{ 0x00D5, 0x004F, 0x0303},
+{ 0x014C, 0x004F, 0x0304},
+{ 0x014E, 0x004F, 0x0306},
+{ 0x022E, 0x004F, 0x0307},
+{ 0x00D6, 0x004F, 0x0308},
+{ 0x1ECE, 0x004F, 0x0309},
+{ 0x0150, 0x004F, 0x030B},
+{ 0x01D1, 0x004F, 0x030C},
+{ 0x020C, 0x004F, 0x030F},
+{ 0x020E, 0x004F, 0x0311},
+{ 0x01A0, 0x004F, 0x031B},
+{ 0x1ECC, 0x004F, 0x0323},
+{ 0x01EA, 0x004F, 0x0328},
+{ 0x1E54, 0x0050, 0x0301},
+{ 0x1E56, 0x0050, 0x0307},
+{ 0x0154, 0x0052, 0x0301},
+{ 0x1E58, 0x0052, 0x0307},
+{ 0x0158, 0x0052, 0x030C},
+{ 0x0210, 0x0052, 0x030F},
+{ 0x0212, 0x0052, 0x0311},
+{ 0x1E5A, 0x0052, 0x0323},
+{ 0x0156, 0x0052, 0x0327},
+{ 0x1E5E, 0x0052, 0x0331},
+{ 0x015A, 0x0053, 0x0301},
+{ 0x015C, 0x0053, 0x0302},
+{ 0x1E60, 0x0053, 0x0307},
+{ 0x0160, 0x0053, 0x030C},
+{ 0x1E62, 0x0053, 0x0323},
+{ 0x0218, 0x0053, 0x0326},
+{ 0x015E, 0x0053, 0x0327},
+{ 0x1E6A, 0x0054, 0x0307},
+{ 0x0164, 0x0054, 0x030C},
+{ 0x1E6C, 0x0054, 0x0323},
+{ 0x021A, 0x0054, 0x0326},
+{ 0x0162, 0x0054, 0x0327},
+{ 0x1E70, 0x0054, 0x032D},
+{ 0x1E6E, 0x0054, 0x0331},
+{ 0x00D9, 0x0055, 0x0300},
+{ 0x00DA, 0x0055, 0x0301},
+{ 0x00DB, 0x0055, 0x0302},
+{ 0x0168, 0x0055, 0x0303},
+{ 0x016A, 0x0055, 0x0304},
+{ 0x016C, 0x0055, 0x0306},
+{ 0x00DC, 0x0055, 0x0308},
+{ 0x1EE6, 0x0055, 0x0309},
+{ 0x016E, 0x0055, 0x030A},
+{ 0x0170, 0x0055, 0x030B},
+{ 0x01D3, 0x0055, 0x030C},
+{ 0x0214, 0x0055, 0x030F},
+{ 0x0216, 0x0055, 0x0311},
+{ 0x01AF, 0x0055, 0x031B},
+{ 0x1EE4, 0x0055, 0x0323},
+{ 0x1E72, 0x0055, 0x0324},
+{ 0x0172, 0x0055, 0x0328},
+{ 0x1E76, 0x0055, 0x032D},
+{ 0x1E74, 0x0055, 0x0330},
+{ 0x1E7C, 0x0056, 0x0303},
+{ 0x1E7E, 0x0056, 0x0323},
+{ 0x1E80, 0x0057, 0x0300},
+{ 0x1E82, 0x0057, 0x0301},
+{ 0x0174, 0x0057, 0x0302},
+{ 0x1E86, 0x0057, 0x0307},
+{ 0x1E84, 0x0057, 0x0308},
+{ 0x1E88, 0x0057, 0x0323},
+{ 0x1E8A, 0x0058, 0x0307},
+{ 0x1E8C, 0x0058, 0x0308},
+{ 0x1EF2, 0x0059, 0x0300},
+{ 0x00DD, 0x0059, 0x0301},
+{ 0x0176, 0x0059, 0x0302},
+{ 0x1EF8, 0x0059, 0x0303},
+{ 0x0232, 0x0059, 0x0304},
+{ 0x1E8E, 0x0059, 0x0307},
+{ 0x0178, 0x0059, 0x0308},
+{ 0x1EF6, 0x0059, 0x0309},
+{ 0x1EF4, 0x0059, 0x0323},
+{ 0x0179, 0x005A, 0x0301},
+{ 0x1E90, 0x005A, 0x0302},
+{ 0x017B, 0x005A, 0x0307},
+{ 0x017D, 0x005A, 0x030C},
+{ 0x1E92, 0x005A, 0x0323},
+{ 0x1E94, 0x005A, 0x0331},
+{ 0x00E0, 0x0061, 0x0300},
+{ 0x00E1, 0x0061, 0x0301},
+{ 0x00E2, 0x0061, 0x0302},
+{ 0x00E3, 0x0061, 0x0303},
+{ 0x0101, 0x0061, 0x0304},
+{ 0x0103, 0x0061, 0x0306},
+{ 0x0227, 0x0061, 0x0307},
+{ 0x00E4, 0x0061, 0x0308},
+{ 0x1EA3, 0x0061, 0x0309},
+{ 0x00E5, 0x0061, 0x030A},
+{ 0x01CE, 0x0061, 0x030C},
+{ 0x0201, 0x0061, 0x030F},
+{ 0x0203, 0x0061, 0x0311},
+{ 0x1EA1, 0x0061, 0x0323},
+{ 0x1E01, 0x0061, 0x0325},
+{ 0x0105, 0x0061, 0x0328},
+{ 0x1E03, 0x0062, 0x0307},
+{ 0x1E05, 0x0062, 0x0323},
+{ 0x1E07, 0x0062, 0x0331},
+{ 0x0107, 0x0063, 0x0301},
+{ 0x0109, 0x0063, 0x0302},
+{ 0x010B, 0x0063, 0x0307},
+{ 0x010D, 0x0063, 0x030C},
+{ 0x00E7, 0x0063, 0x0327},
+{ 0x1E0B, 0x0064, 0x0307},
+{ 0x010F, 0x0064, 0x030C},
+{ 0x1E0D, 0x0064, 0x0323},
+{ 0x1E11, 0x0064, 0x0327},
+{ 0x1E13, 0x0064, 0x032D},
+{ 0x1E0F, 0x0064, 0x0331},
+{ 0x00E8, 0x0065, 0x0300},
+{ 0x00E9, 0x0065, 0x0301},
+{ 0x00EA, 0x0065, 0x0302},
+{ 0x1EBD, 0x0065, 0x0303},
+{ 0x0113, 0x0065, 0x0304},
+{ 0x0115, 0x0065, 0x0306},
+{ 0x0117, 0x0065, 0x0307},
+{ 0x00EB, 0x0065, 0x0308},
+{ 0x1EBB, 0x0065, 0x0309},
+{ 0x011B, 0x0065, 0x030C},
+{ 0x0205, 0x0065, 0x030F},
+{ 0x0207, 0x0065, 0x0311},
+{ 0x1EB9, 0x0065, 0x0323},
+{ 0x0229, 0x0065, 0x0327},
+{ 0x0119, 0x0065, 0x0328},
+{ 0x1E19, 0x0065, 0x032D},
+{ 0x1E1B, 0x0065, 0x0330},
+{ 0x1E1F, 0x0066, 0x0307},
+{ 0x01F5, 0x0067, 0x0301},
+{ 0x011D, 0x0067, 0x0302},
+{ 0x1E21, 0x0067, 0x0304},
+{ 0x011F, 0x0067, 0x0306},
+{ 0x0121, 0x0067, 0x0307},
+{ 0x01E7, 0x0067, 0x030C},
+{ 0x0123, 0x0067, 0x0327},
+{ 0x0125, 0x0068, 0x0302},
+{ 0x1E23, 0x0068, 0x0307},
+{ 0x1E27, 0x0068, 0x0308},
+{ 0x021F, 0x0068, 0x030C},
+{ 0x1E25, 0x0068, 0x0323},
+{ 0x1E29, 0x0068, 0x0327},
+{ 0x1E2B, 0x0068, 0x032E},
+{ 0x1E96, 0x0068, 0x0331},
+{ 0x00EC, 0x0069, 0x0300},
+{ 0x00ED, 0x0069, 0x0301},
+{ 0x00EE, 0x0069, 0x0302},
+{ 0x0129, 0x0069, 0x0303},
+{ 0x012B, 0x0069, 0x0304},
+{ 0x012D, 0x0069, 0x0306},
+{ 0x00EF, 0x0069, 0x0308},
+{ 0x1EC9, 0x0069, 0x0309},
+{ 0x01D0, 0x0069, 0x030C},
+{ 0x0209, 0x0069, 0x030F},
+{ 0x020B, 0x0069, 0x0311},
+{ 0x1ECB, 0x0069, 0x0323},
+{ 0x012F, 0x0069, 0x0328},
+{ 0x1E2D, 0x0069, 0x0330},
+{ 0x0135, 0x006A, 0x0302},
+{ 0x01F0, 0x006A, 0x030C},
+{ 0x1E31, 0x006B, 0x0301},
+{ 0x01E9, 0x006B, 0x030C},
+{ 0x1E33, 0x006B, 0x0323},
+{ 0x0137, 0x006B, 0x0327},
+{ 0x1E35, 0x006B, 0x0331},
+{ 0x013A, 0x006C, 0x0301},
+{ 0x013E, 0x006C, 0x030C},
+{ 0x1E37, 0x006C, 0x0323},
+{ 0x013C, 0x006C, 0x0327},
+{ 0x1E3D, 0x006C, 0x032D},
+{ 0x1E3B, 0x006C, 0x0331},
+{ 0x1E3F, 0x006D, 0x0301},
+{ 0x1E41, 0x006D, 0x0307},
+{ 0x1E43, 0x006D, 0x0323},
+{ 0x01F9, 0x006E, 0x0300},
+{ 0x0144, 0x006E, 0x0301},
+{ 0x00F1, 0x006E, 0x0303},
+{ 0x1E45, 0x006E, 0x0307},
+{ 0x0148, 0x006E, 0x030C},
+{ 0x1E47, 0x006E, 0x0323},
+{ 0x0146, 0x006E, 0x0327},
+{ 0x1E4B, 0x006E, 0x032D},
+{ 0x1E49, 0x006E, 0x0331},
+{ 0x00F2, 0x006F, 0x0300},
+{ 0x00F3, 0x006F, 0x0301},
+{ 0x00F4, 0x006F, 0x0302},
+{ 0x00F5, 0x006F, 0x0303},
+{ 0x014D, 0x006F, 0x0304},
+{ 0x014F, 0x006F, 0x0306},
+{ 0x022F, 0x006F, 0x0307},
+{ 0x00F6, 0x006F, 0x0308},
+{ 0x1ECF, 0x006F, 0x0309},
+{ 0x0151, 0x006F, 0x030B},
+{ 0x01D2, 0x006F, 0x030C},
+{ 0x020D, 0x006F, 0x030F},
+{ 0x020F, 0x006F, 0x0311},
+{ 0x01A1, 0x006F, 0x031B},
+{ 0x1ECD, 0x006F, 0x0323},
+{ 0x01EB, 0x006F, 0x0328},
+{ 0x1E55, 0x0070, 0x0301},
+{ 0x1E57, 0x0070, 0x0307},
+{ 0x0155, 0x0072, 0x0301},
+{ 0x1E59, 0x0072, 0x0307},
+{ 0x0159, 0x0072, 0x030C},
+{ 0x0211, 0x0072, 0x030F},
+{ 0x0213, 0x0072, 0x0311},
+{ 0x1E5B, 0x0072, 0x0323},
+{ 0x0157, 0x0072, 0x0327},
+{ 0x1E5F, 0x0072, 0x0331},
+{ 0x015B, 0x0073, 0x0301},
+{ 0x015D, 0x0073, 0x0302},
+{ 0x1E61, 0x0073, 0x0307},
+{ 0x0161, 0x0073, 0x030C},
+{ 0x1E63, 0x0073, 0x0323},
+{ 0x0219, 0x0073, 0x0326},
+{ 0x015F, 0x0073, 0x0327},
+{ 0x1E6B, 0x0074, 0x0307},
+{ 0x1E97, 0x0074, 0x0308},
+{ 0x0165, 0x0074, 0x030C},
+{ 0x1E6D, 0x0074, 0x0323},
+{ 0x021B, 0x0074, 0x0326},
+{ 0x0163, 0x0074, 0x0327},
+{ 0x1E71, 0x0074, 0x032D},
+{ 0x1E6F, 0x0074, 0x0331},
+{ 0x00F9, 0x0075, 0x0300},
+{ 0x00FA, 0x0075, 0x0301},
+{ 0x00FB, 0x0075, 0x0302},
+{ 0x0169, 0x0075, 0x0303},
+{ 0x016B, 0x0075, 0x0304},
+{ 0x016D, 0x0075, 0x0306},
+{ 0x00FC, 0x0075, 0x0308},
+{ 0x1EE7, 0x0075, 0x0309},
+{ 0x016F, 0x0075, 0x030A},
+{ 0x0171, 0x0075, 0x030B},
+{ 0x01D4, 0x0075, 0x030C},
+{ 0x0215, 0x0075, 0x030F},
+{ 0x0217, 0x0075, 0x0311},
+{ 0x01B0, 0x0075, 0x031B},
+{ 0x1EE5, 0x0075, 0x0323},
+{ 0x1E73, 0x0075, 0x0324},
+{ 0x0173, 0x0075, 0x0328},
+{ 0x1E77, 0x0075, 0x032D},
+{ 0x1E75, 0x0075, 0x0330},
+{ 0x1E7D, 0x0076, 0x0303},
+{ 0x1E7F, 0x0076, 0x0323},
+{ 0x1E81, 0x0077, 0x0300},
+{ 0x1E83, 0x0077, 0x0301},
+{ 0x0175, 0x0077, 0x0302},
+{ 0x1E87, 0x0077, 0x0307},
+{ 0x1E85, 0x0077, 0x0308},
+{ 0x1E98, 0x0077, 0x030A},
+{ 0x1E89, 0x0077, 0x0323},
+{ 0x1E8B, 0x0078, 0x0307},
+{ 0x1E8D, 0x0078, 0x0308},
+{ 0x1EF3, 0x0079, 0x0300},
+{ 0x00FD, 0x0079, 0x0301},
+{ 0x0177, 0x0079, 0x0302},
+{ 0x1EF9, 0x0079, 0x0303},
+{ 0x0233, 0x0079, 0x0304},
+{ 0x1E8F, 0x0079, 0x0307},
+{ 0x00FF, 0x0079, 0x0308},
+{ 0x1EF7, 0x0079, 0x0309},
+{ 0x1E99, 0x0079, 0x030A},
+{ 0x1EF5, 0x0079, 0x0323},
+{ 0x017A, 0x007A, 0x0301},
+{ 0x1E91, 0x007A, 0x0302},
+{ 0x017C, 0x007A, 0x0307},
+{ 0x017E, 0x007A, 0x030C},
+{ 0x1E93, 0x007A, 0x0323},
+{ 0x1E95, 0x007A, 0x0331},
+{ 0x1FED, 0x00A8, 0x0300},
+{ 0x0385, 0x00A8, 0x0301},
+{ 0x1FC1, 0x00A8, 0x0342},
+{ 0x1EA6, 0x00C2, 0x0300},
+{ 0x1EA4, 0x00C2, 0x0301},
+{ 0x1EAA, 0x00C2, 0x0303},
+{ 0x1EA8, 0x00C2, 0x0309},
+{ 0x01DE, 0x00C4, 0x0304},
+{ 0x01FA, 0x00C5, 0x0301},
+{ 0x01FC, 0x00C6, 0x0301},
+{ 0x01E2, 0x00C6, 0x0304},
+{ 0x1E08, 0x00C7, 0x0301},
+{ 0x1EC0, 0x00CA, 0x0300},
+{ 0x1EBE, 0x00CA, 0x0301},
+{ 0x1EC4, 0x00CA, 0x0303},
+{ 0x1EC2, 0x00CA, 0x0309},
+{ 0x1E2E, 0x00CF, 0x0301},
+{ 0x1ED2, 0x00D4, 0x0300},
+{ 0x1ED0, 0x00D4, 0x0301},
+{ 0x1ED6, 0x00D4, 0x0303},
+{ 0x1ED4, 0x00D4, 0x0309},
+{ 0x1E4C, 0x00D5, 0x0301},
+{ 0x022C, 0x00D5, 0x0304},
+{ 0x1E4E, 0x00D5, 0x0308},
+{ 0x022A, 0x00D6, 0x0304},
+{ 0x01FE, 0x00D8, 0x0301},
+{ 0x01DB, 0x00DC, 0x0300},
+{ 0x01D7, 0x00DC, 0x0301},
+{ 0x01D5, 0x00DC, 0x0304},
+{ 0x01D9, 0x00DC, 0x030C},
+{ 0x1EA7, 0x00E2, 0x0300},
+{ 0x1EA5, 0x00E2, 0x0301},
+{ 0x1EAB, 0x00E2, 0x0303},
+{ 0x1EA9, 0x00E2, 0x0309},
+{ 0x01DF, 0x00E4, 0x0304},
+{ 0x01FB, 0x00E5, 0x0301},
+{ 0x01FD, 0x00E6, 0x0301},
+{ 0x01E3, 0x00E6, 0x0304},
+{ 0x1E09, 0x00E7, 0x0301},
+{ 0x1EC1, 0x00EA, 0x0300},
+{ 0x1EBF, 0x00EA, 0x0301},
+{ 0x1EC5, 0x00EA, 0x0303},
+{ 0x1EC3, 0x00EA, 0x0309},
+{ 0x1E2F, 0x00EF, 0x0301},
+{ 0x1ED3, 0x00F4, 0x0300},
+{ 0x1ED1, 0x00F4, 0x0301},
+{ 0x1ED7, 0x00F4, 0x0303},
+{ 0x1ED5, 0x00F4, 0x0309},
+{ 0x1E4D, 0x00F5, 0x0301},
+{ 0x022D, 0x00F5, 0x0304},
+{ 0x1E4F, 0x00F5, 0x0308},
+{ 0x022B, 0x00F6, 0x0304},
+{ 0x01FF, 0x00F8, 0x0301},
+{ 0x01DC, 0x00FC, 0x0300},
+{ 0x01D8, 0x00FC, 0x0301},
+{ 0x01D6, 0x00FC, 0x0304},
+{ 0x01DA, 0x00FC, 0x030C},
+{ 0x1EB0, 0x0102, 0x0300},
+{ 0x1EAE, 0x0102, 0x0301},
+{ 0x1EB4, 0x0102, 0x0303},
+{ 0x1EB2, 0x0102, 0x0309},
+{ 0x1EB1, 0x0103, 0x0300},
+{ 0x1EAF, 0x0103, 0x0301},
+{ 0x1EB5, 0x0103, 0x0303},
+{ 0x1EB3, 0x0103, 0x0309},
+{ 0x1E14, 0x0112, 0x0300},
+{ 0x1E16, 0x0112, 0x0301},
+{ 0x1E15, 0x0113, 0x0300},
+{ 0x1E17, 0x0113, 0x0301},
+{ 0x1E50, 0x014C, 0x0300},
+{ 0x1E52, 0x014C, 0x0301},
+{ 0x1E51, 0x014D, 0x0300},
+{ 0x1E53, 0x014D, 0x0301},
+{ 0x1E64, 0x015A, 0x0307},
+{ 0x1E65, 0x015B, 0x0307},
+{ 0x1E66, 0x0160, 0x0307},
+{ 0x1E67, 0x0161, 0x0307},
+{ 0x1E78, 0x0168, 0x0301},
+{ 0x1E79, 0x0169, 0x0301},
+{ 0x1E7A, 0x016A, 0x0308},
+{ 0x1E7B, 0x016B, 0x0308},
+{ 0x1E9B, 0x017F, 0x0307},
+{ 0x1EDC, 0x01A0, 0x0300},
+{ 0x1EDA, 0x01A0, 0x0301},
+{ 0x1EE0, 0x01A0, 0x0303},
+{ 0x1EDE, 0x01A0, 0x0309},
+{ 0x1EE2, 0x01A0, 0x0323},
+{ 0x1EDD, 0x01A1, 0x0300},
+{ 0x1EDB, 0x01A1, 0x0301},
+{ 0x1EE1, 0x01A1, 0x0303},
+{ 0x1EDF, 0x01A1, 0x0309},
+{ 0x1EE3, 0x01A1, 0x0323},
+{ 0x1EEA, 0x01AF, 0x0300},
+{ 0x1EE8, 0x01AF, 0x0301},
+{ 0x1EEE, 0x01AF, 0x0303},
+{ 0x1EEC, 0x01AF, 0x0309},
+{ 0x1EF0, 0x01AF, 0x0323},
+{ 0x1EEB, 0x01B0, 0x0300},
+{ 0x1EE9, 0x01B0, 0x0301},
+{ 0x1EEF, 0x01B0, 0x0303},
+{ 0x1EED, 0x01B0, 0x0309},
+{ 0x1EF1, 0x01B0, 0x0323},
+{ 0x01EE, 0x01B7, 0x030C},
+{ 0x01EC, 0x01EA, 0x0304},
+{ 0x01ED, 0x01EB, 0x0304},
+{ 0x01E0, 0x0226, 0x0304},
+{ 0x01E1, 0x0227, 0x0304},
+{ 0x1E1C, 0x0228, 0x0306},
+{ 0x1E1D, 0x0229, 0x0306},
+{ 0x0230, 0x022E, 0x0304},
+{ 0x0231, 0x022F, 0x0304},
+{ 0x01EF, 0x0292, 0x030C},
+{ 0x0344, 0x0308, 0x0301},
+{ 0x1FBA, 0x0391, 0x0300},
+{ 0x0386, 0x0391, 0x0301},
+{ 0x1FB9, 0x0391, 0x0304},
+{ 0x1FB8, 0x0391, 0x0306},
+{ 0x1F08, 0x0391, 0x0313},
+{ 0x1F09, 0x0391, 0x0314},
+{ 0x1FBC, 0x0391, 0x0345},
+{ 0x1FC8, 0x0395, 0x0300},
+{ 0x0388, 0x0395, 0x0301},
+{ 0x1F18, 0x0395, 0x0313},
+{ 0x1F19, 0x0395, 0x0314},
+{ 0x1FCA, 0x0397, 0x0300},
+{ 0x0389, 0x0397, 0x0301},
+{ 0x1F28, 0x0397, 0x0313},
+{ 0x1F29, 0x0397, 0x0314},
+{ 0x1FCC, 0x0397, 0x0345},
+{ 0x1FDA, 0x0399, 0x0300},
+{ 0x038A, 0x0399, 0x0301},
+{ 0x1FD9, 0x0399, 0x0304},
+{ 0x1FD8, 0x0399, 0x0306},
+{ 0x03AA, 0x0399, 0x0308},
+{ 0x1F38, 0x0399, 0x0313},
+{ 0x1F39, 0x0399, 0x0314},
+{ 0x1FF8, 0x039F, 0x0300},
+{ 0x038C, 0x039F, 0x0301},
+{ 0x1F48, 0x039F, 0x0313},
+{ 0x1F49, 0x039F, 0x0314},
+{ 0x1FEC, 0x03A1, 0x0314},
+{ 0x1FEA, 0x03A5, 0x0300},
+{ 0x038E, 0x03A5, 0x0301},
+{ 0x1FE9, 0x03A5, 0x0304},
+{ 0x1FE8, 0x03A5, 0x0306},
+{ 0x03AB, 0x03A5, 0x0308},
+{ 0x1F59, 0x03A5, 0x0314},
+{ 0x1FFA, 0x03A9, 0x0300},
+{ 0x038F, 0x03A9, 0x0301},
+{ 0x1F68, 0x03A9, 0x0313},
+{ 0x1F69, 0x03A9, 0x0314},
+{ 0x1FFC, 0x03A9, 0x0345},
+{ 0x1FB4, 0x03AC, 0x0345},
+{ 0x1FC4, 0x03AE, 0x0345},
+{ 0x1F70, 0x03B1, 0x0300},
+{ 0x03AC, 0x03B1, 0x0301},
+{ 0x1FB1, 0x03B1, 0x0304},
+{ 0x1FB0, 0x03B1, 0x0306},
+{ 0x1F00, 0x03B1, 0x0313},
+{ 0x1F01, 0x03B1, 0x0314},
+{ 0x1FB6, 0x03B1, 0x0342},
+{ 0x1FB3, 0x03B1, 0x0345},
+{ 0x1F72, 0x03B5, 0x0300},
+{ 0x03AD, 0x03B5, 0x0301},
+{ 0x1F10, 0x03B5, 0x0313},
+{ 0x1F11, 0x03B5, 0x0314},
+{ 0x1F74, 0x03B7, 0x0300},
+{ 0x03AE, 0x03B7, 0x0301},
+{ 0x1F20, 0x03B7, 0x0313},
+{ 0x1F21, 0x03B7, 0x0314},
+{ 0x1FC6, 0x03B7, 0x0342},
+{ 0x1FC3, 0x03B7, 0x0345},
+{ 0x1F76, 0x03B9, 0x0300},
+{ 0x03AF, 0x03B9, 0x0301},
+{ 0x1FD1, 0x03B9, 0x0304},
+{ 0x1FD0, 0x03B9, 0x0306},
+{ 0x03CA, 0x03B9, 0x0308},
+{ 0x1F30, 0x03B9, 0x0313},
+{ 0x1F31, 0x03B9, 0x0314},
+{ 0x1FD6, 0x03B9, 0x0342},
+{ 0x1F78, 0x03BF, 0x0300},
+{ 0x03CC, 0x03BF, 0x0301},
+{ 0x1F40, 0x03BF, 0x0313},
+{ 0x1F41, 0x03BF, 0x0314},
+{ 0x1FE4, 0x03C1, 0x0313},
+{ 0x1FE5, 0x03C1, 0x0314},
+{ 0x1F7A, 0x03C5, 0x0300},
+{ 0x03CD, 0x03C5, 0x0301},
+{ 0x1FE1, 0x03C5, 0x0304},
+{ 0x1FE0, 0x03C5, 0x0306},
+{ 0x03CB, 0x03C5, 0x0308},
+{ 0x1F50, 0x03C5, 0x0313},
+{ 0x1F51, 0x03C5, 0x0314},
+{ 0x1FE6, 0x03C5, 0x0342},
+{ 0x1F7C, 0x03C9, 0x0300},
+{ 0x03CE, 0x03C9, 0x0301},
+{ 0x1F60, 0x03C9, 0x0313},
+{ 0x1F61, 0x03C9, 0x0314},
+{ 0x1FF6, 0x03C9, 0x0342},
+{ 0x1FF3, 0x03C9, 0x0345},
+{ 0x1FD2, 0x03CA, 0x0300},
+{ 0x0390, 0x03CA, 0x0301},
+{ 0x1FD7, 0x03CA, 0x0342},
+{ 0x1FE2, 0x03CB, 0x0300},
+{ 0x03B0, 0x03CB, 0x0301},
+{ 0x1FE7, 0x03CB, 0x0342},
+{ 0x1FF4, 0x03CE, 0x0345},
+{ 0x03D3, 0x03D2, 0x0301},
+{ 0x03D4, 0x03D2, 0x0308},
+{ 0x0407, 0x0406, 0x0308},
+{ 0x04D0, 0x0410, 0x0306},
+{ 0x04D2, 0x0410, 0x0308},
+{ 0x0403, 0x0413, 0x0301},
+{ 0x0400, 0x0415, 0x0300},
+{ 0x04D6, 0x0415, 0x0306},
+{ 0x0401, 0x0415, 0x0308},
+{ 0x04C1, 0x0416, 0x0306},
+{ 0x04DC, 0x0416, 0x0308},
+{ 0x04DE, 0x0417, 0x0308},
+{ 0x040D, 0x0418, 0x0300},
+{ 0x04E2, 0x0418, 0x0304},
+{ 0x0419, 0x0418, 0x0306},
+{ 0x04E4, 0x0418, 0x0308},
+{ 0x040C, 0x041A, 0x0301},
+{ 0x04E6, 0x041E, 0x0308},
+{ 0x04EE, 0x0423, 0x0304},
+{ 0x040E, 0x0423, 0x0306},
+{ 0x04F0, 0x0423, 0x0308},
+{ 0x04F2, 0x0423, 0x030B},
+{ 0x04F4, 0x0427, 0x0308},
+{ 0x04F8, 0x042B, 0x0308},
+{ 0x04EC, 0x042D, 0x0308},
+{ 0x04D1, 0x0430, 0x0306},
+{ 0x04D3, 0x0430, 0x0308},
+{ 0x0453, 0x0433, 0x0301},
+{ 0x0450, 0x0435, 0x0300},
+{ 0x04D7, 0x0435, 0x0306},
+{ 0x0451, 0x0435, 0x0308},
+{ 0x04C2, 0x0436, 0x0306},
+{ 0x04DD, 0x0436, 0x0308},
+{ 0x04DF, 0x0437, 0x0308},
+{ 0x045D, 0x0438, 0x0300},
+{ 0x04E3, 0x0438, 0x0304},
+{ 0x0439, 0x0438, 0x0306},
+{ 0x04E5, 0x0438, 0x0308},
+{ 0x045C, 0x043A, 0x0301},
+{ 0x04E7, 0x043E, 0x0308},
+{ 0x04EF, 0x0443, 0x0304},
+{ 0x045E, 0x0443, 0x0306},
+{ 0x04F1, 0x0443, 0x0308},
+{ 0x04F3, 0x0443, 0x030B},
+{ 0x04F5, 0x0447, 0x0308},
+{ 0x04F9, 0x044B, 0x0308},
+{ 0x04ED, 0x044D, 0x0308},
+{ 0x0457, 0x0456, 0x0308},
+{ 0x0476, 0x0474, 0x030F},
+{ 0x0477, 0x0475, 0x030F},
+{ 0x04DA, 0x04D8, 0x0308},
+{ 0x04DB, 0x04D9, 0x0308},
+{ 0x04EA, 0x04E8, 0x0308},
+{ 0x04EB, 0x04E9, 0x0308},
+{ 0xFB2E, 0x05D0, 0x05B7},
+{ 0xFB2F, 0x05D0, 0x05B8},
+{ 0xFB30, 0x05D0, 0x05BC},
+{ 0xFB31, 0x05D1, 0x05BC},
+{ 0xFB4C, 0x05D1, 0x05BF},
+{ 0xFB32, 0x05D2, 0x05BC},
+{ 0xFB33, 0x05D3, 0x05BC},
+{ 0xFB34, 0x05D4, 0x05BC},
+{ 0xFB4B, 0x05D5, 0x05B9},
+{ 0xFB35, 0x05D5, 0x05BC},
+{ 0xFB36, 0x05D6, 0x05BC},
+{ 0xFB38, 0x05D8, 0x05BC},
+{ 0xFB1D, 0x05D9, 0x05B4},
+{ 0xFB39, 0x05D9, 0x05BC},
+{ 0xFB3A, 0x05DA, 0x05BC},
+{ 0xFB3B, 0x05DB, 0x05BC},
+{ 0xFB4D, 0x05DB, 0x05BF},
+{ 0xFB3C, 0x05DC, 0x05BC},
+{ 0xFB3E, 0x05DE, 0x05BC},
+{ 0xFB40, 0x05E0, 0x05BC},
+{ 0xFB41, 0x05E1, 0x05BC},
+{ 0xFB43, 0x05E3, 0x05BC},
+{ 0xFB44, 0x05E4, 0x05BC},
+{ 0xFB4E, 0x05E4, 0x05BF},
+{ 0xFB46, 0x05E6, 0x05BC},
+{ 0xFB47, 0x05E7, 0x05BC},
+{ 0xFB48, 0x05E8, 0x05BC},
+{ 0xFB49, 0x05E9, 0x05BC},
+{ 0xFB2A, 0x05E9, 0x05C1},
+{ 0xFB2B, 0x05E9, 0x05C2},
+{ 0xFB4A, 0x05EA, 0x05BC},
+{ 0xFB1F, 0x05F2, 0x05B7},
+{ 0x0622, 0x0627, 0x0653},
+{ 0x0623, 0x0627, 0x0654},
+{ 0x0625, 0x0627, 0x0655},
+{ 0x0624, 0x0648, 0x0654},
+{ 0x0626, 0x064A, 0x0654},
+{ 0x06C2, 0x06C1, 0x0654},
+{ 0x06D3, 0x06D2, 0x0654},
+{ 0x06C0, 0x06D5, 0x0654},
+{ 0x0958, 0x0915, 0x093C},
+{ 0x0959, 0x0916, 0x093C},
+{ 0x095A, 0x0917, 0x093C},
+{ 0x095B, 0x091C, 0x093C},
+{ 0x095C, 0x0921, 0x093C},
+{ 0x095D, 0x0922, 0x093C},
+{ 0x0929, 0x0928, 0x093C},
+{ 0x095E, 0x092B, 0x093C},
+{ 0x095F, 0x092F, 0x093C},
+{ 0x0931, 0x0930, 0x093C},
+{ 0x0934, 0x0933, 0x093C},
+{ 0x09DC, 0x09A1, 0x09BC},
+{ 0x09DD, 0x09A2, 0x09BC},
+{ 0x09DF, 0x09AF, 0x09BC},
+{ 0x09CB, 0x09C7, 0x09BE},
+{ 0x09CC, 0x09C7, 0x09D7},
+{ 0x0A59, 0x0A16, 0x0A3C},
+{ 0x0A5A, 0x0A17, 0x0A3C},
+{ 0x0A5B, 0x0A1C, 0x0A3C},
+{ 0x0A5E, 0x0A2B, 0x0A3C},
+{ 0x0A33, 0x0A32, 0x0A3C},
+{ 0x0A36, 0x0A38, 0x0A3C},
+{ 0x0B5C, 0x0B21, 0x0B3C},
+{ 0x0B5D, 0x0B22, 0x0B3C},
+{ 0x0B4B, 0x0B47, 0x0B3E},
+{ 0x0B48, 0x0B47, 0x0B56},
+{ 0x0B4C, 0x0B47, 0x0B57},
+{ 0x0B94, 0x0B92, 0x0BD7},
+{ 0x0BCA, 0x0BC6, 0x0BBE},
+{ 0x0BCC, 0x0BC6, 0x0BD7},
+{ 0x0BCB, 0x0BC7, 0x0BBE},
+{ 0x0C48, 0x0C46, 0x0C56},
+{ 0x0CC0, 0x0CBF, 0x0CD5},
+{ 0x0CCA, 0x0CC6, 0x0CC2},
+{ 0x0CC7, 0x0CC6, 0x0CD5},
+{ 0x0CC8, 0x0CC6, 0x0CD6},
+{ 0x0CCB, 0x0CCA, 0x0CD5},
+{ 0x0D4A, 0x0D46, 0x0D3E},
+{ 0x0D4C, 0x0D46, 0x0D57},
+{ 0x0D4B, 0x0D47, 0x0D3E},
+{ 0x0DDA, 0x0DD9, 0x0DCA},
+{ 0x0DDC, 0x0DD9, 0x0DCF},
+{ 0x0DDE, 0x0DD9, 0x0DDF},
+{ 0x0DDD, 0x0DDC, 0x0DCA},
+{ 0x0F69, 0x0F40, 0x0FB5},
+{ 0x0F43, 0x0F42, 0x0FB7},
+{ 0x0F4D, 0x0F4C, 0x0FB7},
+{ 0x0F52, 0x0F51, 0x0FB7},
+{ 0x0F57, 0x0F56, 0x0FB7},
+{ 0x0F5C, 0x0F5B, 0x0FB7},
+{ 0x0F73, 0x0F71, 0x0F72},
+{ 0x0F75, 0x0F71, 0x0F74},
+{ 0x0F81, 0x0F71, 0x0F80},
+{ 0x0FB9, 0x0F90, 0x0FB5},
+{ 0x0F93, 0x0F92, 0x0FB7},
+{ 0x0F9D, 0x0F9C, 0x0FB7},
+{ 0x0FA2, 0x0FA1, 0x0FB7},
+{ 0x0FA7, 0x0FA6, 0x0FB7},
+{ 0x0FAC, 0x0FAB, 0x0FB7},
+{ 0x0F76, 0x0FB2, 0x0F80},
+{ 0x0F78, 0x0FB3, 0x0F80},
+{ 0x1026, 0x1025, 0x102E},
+{ 0x1B06, 0x1B05, 0x1B35},
+{ 0x1B08, 0x1B07, 0x1B35},
+{ 0x1B0A, 0x1B09, 0x1B35},
+{ 0x1B0C, 0x1B0B, 0x1B35},
+{ 0x1B0E, 0x1B0D, 0x1B35},
+{ 0x1B12, 0x1B11, 0x1B35},
+{ 0x1B3B, 0x1B3A, 0x1B35},
+{ 0x1B3D, 0x1B3C, 0x1B35},
+{ 0x1B40, 0x1B3E, 0x1B35},
+{ 0x1B41, 0x1B3F, 0x1B35},
+{ 0x1B43, 0x1B42, 0x1B35},
+{ 0x1E38, 0x1E36, 0x0304},
+{ 0x1E39, 0x1E37, 0x0304},
+{ 0x1E5C, 0x1E5A, 0x0304},
+{ 0x1E5D, 0x1E5B, 0x0304},
+{ 0x1E68, 0x1E62, 0x0307},
+{ 0x1E69, 0x1E63, 0x0307},
+{ 0x1EAC, 0x1EA0, 0x0302},
+{ 0x1EB6, 0x1EA0, 0x0306},
+{ 0x1EAD, 0x1EA1, 0x0302},
+{ 0x1EB7, 0x1EA1, 0x0306},
+{ 0x1EC6, 0x1EB8, 0x0302},
+{ 0x1EC7, 0x1EB9, 0x0302},
+{ 0x1ED8, 0x1ECC, 0x0302},
+{ 0x1ED9, 0x1ECD, 0x0302},
+{ 0x1F02, 0x1F00, 0x0300},
+{ 0x1F04, 0x1F00, 0x0301},
+{ 0x1F06, 0x1F00, 0x0342},
+{ 0x1F80, 0x1F00, 0x0345},
+{ 0x1F03, 0x1F01, 0x0300},
+{ 0x1F05, 0x1F01, 0x0301},
+{ 0x1F07, 0x1F01, 0x0342},
+{ 0x1F81, 0x1F01, 0x0345},
+{ 0x1F82, 0x1F02, 0x0345},
+{ 0x1F83, 0x1F03, 0x0345},
+{ 0x1F84, 0x1F04, 0x0345},
+{ 0x1F85, 0x1F05, 0x0345},
+{ 0x1F86, 0x1F06, 0x0345},
+{ 0x1F87, 0x1F07, 0x0345},
+{ 0x1F0A, 0x1F08, 0x0300},
+{ 0x1F0C, 0x1F08, 0x0301},
+{ 0x1F0E, 0x1F08, 0x0342},
+{ 0x1F88, 0x1F08, 0x0345},
+{ 0x1F0B, 0x1F09, 0x0300},
+{ 0x1F0D, 0x1F09, 0x0301},
+{ 0x1F0F, 0x1F09, 0x0342},
+{ 0x1F89, 0x1F09, 0x0345},
+{ 0x1F8A, 0x1F0A, 0x0345},
+{ 0x1F8B, 0x1F0B, 0x0345},
+{ 0x1F8C, 0x1F0C, 0x0345},
+{ 0x1F8D, 0x1F0D, 0x0345},
+{ 0x1F8E, 0x1F0E, 0x0345},
+{ 0x1F8F, 0x1F0F, 0x0345},
+{ 0x1F12, 0x1F10, 0x0300},
+{ 0x1F14, 0x1F10, 0x0301},
+{ 0x1F13, 0x1F11, 0x0300},
+{ 0x1F15, 0x1F11, 0x0301},
+{ 0x1F1A, 0x1F18, 0x0300},
+{ 0x1F1C, 0x1F18, 0x0301},
+{ 0x1F1B, 0x1F19, 0x0300},
+{ 0x1F1D, 0x1F19, 0x0301},
+{ 0x1F22, 0x1F20, 0x0300},
+{ 0x1F24, 0x1F20, 0x0301},
+{ 0x1F26, 0x1F20, 0x0342},
+{ 0x1F90, 0x1F20, 0x0345},
+{ 0x1F23, 0x1F21, 0x0300},
+{ 0x1F25, 0x1F21, 0x0301},
+{ 0x1F27, 0x1F21, 0x0342},
+{ 0x1F91, 0x1F21, 0x0345},
+{ 0x1F92, 0x1F22, 0x0345},
+{ 0x1F93, 0x1F23, 0x0345},
+{ 0x1F94, 0x1F24, 0x0345},
+{ 0x1F95, 0x1F25, 0x0345},
+{ 0x1F96, 0x1F26, 0x0345},
+{ 0x1F97, 0x1F27, 0x0345},
+{ 0x1F2A, 0x1F28, 0x0300},
+{ 0x1F2C, 0x1F28, 0x0301},
+{ 0x1F2E, 0x1F28, 0x0342},
+{ 0x1F98, 0x1F28, 0x0345},
+{ 0x1F2B, 0x1F29, 0x0300},
+{ 0x1F2D, 0x1F29, 0x0301},
+{ 0x1F2F, 0x1F29, 0x0342},
+{ 0x1F99, 0x1F29, 0x0345},
+{ 0x1F9A, 0x1F2A, 0x0345},
+{ 0x1F9B, 0x1F2B, 0x0345},
+{ 0x1F9C, 0x1F2C, 0x0345},
+{ 0x1F9D, 0x1F2D, 0x0345},
+{ 0x1F9E, 0x1F2E, 0x0345},
+{ 0x1F9F, 0x1F2F, 0x0345},
+{ 0x1F32, 0x1F30, 0x0300},
+{ 0x1F34, 0x1F30, 0x0301},
+{ 0x1F36, 0x1F30, 0x0342},
+{ 0x1F33, 0x1F31, 0x0300},
+{ 0x1F35, 0x1F31, 0x0301},
+{ 0x1F37, 0x1F31, 0x0342},
+{ 0x1F3A, 0x1F38, 0x0300},
+{ 0x1F3C, 0x1F38, 0x0301},
+{ 0x1F3E, 0x1F38, 0x0342},
+{ 0x1F3B, 0x1F39, 0x0300},
+{ 0x1F3D, 0x1F39, 0x0301},
+{ 0x1F3F, 0x1F39, 0x0342},
+{ 0x1F42, 0x1F40, 0x0300},
+{ 0x1F44, 0x1F40, 0x0301},
+{ 0x1F43, 0x1F41, 0x0300},
+{ 0x1F45, 0x1F41, 0x0301},
+{ 0x1F4A, 0x1F48, 0x0300},
+{ 0x1F4C, 0x1F48, 0x0301},
+{ 0x1F4B, 0x1F49, 0x0300},
+{ 0x1F4D, 0x1F49, 0x0301},
+{ 0x1F52, 0x1F50, 0x0300},
+{ 0x1F54, 0x1F50, 0x0301},
+{ 0x1F56, 0x1F50, 0x0342},
+{ 0x1F53, 0x1F51, 0x0300},
+{ 0x1F55, 0x1F51, 0x0301},
+{ 0x1F57, 0x1F51, 0x0342},
+{ 0x1F5B, 0x1F59, 0x0300},
+{ 0x1F5D, 0x1F59, 0x0301},
+{ 0x1F5F, 0x1F59, 0x0342},
+{ 0x1F62, 0x1F60, 0x0300},
+{ 0x1F64, 0x1F60, 0x0301},
+{ 0x1F66, 0x1F60, 0x0342},
+{ 0x1FA0, 0x1F60, 0x0345},
+{ 0x1F63, 0x1F61, 0x0300},
+{ 0x1F65, 0x1F61, 0x0301},
+{ 0x1F67, 0x1F61, 0x0342},
+{ 0x1FA1, 0x1F61, 0x0345},
+{ 0x1FA2, 0x1F62, 0x0345},
+{ 0x1FA3, 0x1F63, 0x0345},
+{ 0x1FA4, 0x1F64, 0x0345},
+{ 0x1FA5, 0x1F65, 0x0345},
+{ 0x1FA6, 0x1F66, 0x0345},
+{ 0x1FA7, 0x1F67, 0x0345},
+{ 0x1F6A, 0x1F68, 0x0300},
+{ 0x1F6C, 0x1F68, 0x0301},
+{ 0x1F6E, 0x1F68, 0x0342},
+{ 0x1FA8, 0x1F68, 0x0345},
+{ 0x1F6B, 0x1F69, 0x0300},
+{ 0x1F6D, 0x1F69, 0x0301},
+{ 0x1F6F, 0x1F69, 0x0342},
+{ 0x1FA9, 0x1F69, 0x0345},
+{ 0x1FAA, 0x1F6A, 0x0345},
+{ 0x1FAB, 0x1F6B, 0x0345},
+{ 0x1FAC, 0x1F6C, 0x0345},
+{ 0x1FAD, 0x1F6D, 0x0345},
+{ 0x1FAE, 0x1F6E, 0x0345},
+{ 0x1FAF, 0x1F6F, 0x0345},
+{ 0x1FB2, 0x1F70, 0x0345},
+{ 0x1FC2, 0x1F74, 0x0345},
+{ 0x1FF2, 0x1F7C, 0x0345},
+{ 0x1FB7, 0x1FB6, 0x0345},
+{ 0x1FCD, 0x1FBF, 0x0300},
+{ 0x1FCE, 0x1FBF, 0x0301},
+{ 0x1FCF, 0x1FBF, 0x0342},
+{ 0x1FC7, 0x1FC6, 0x0345},
+{ 0x1FF7, 0x1FF6, 0x0345},
+{ 0x1FDD, 0x1FFE, 0x0300},
+{ 0x1FDE, 0x1FFE, 0x0301},
+{ 0x1FDF, 0x1FFE, 0x0342},
+{ 0x219A, 0x2190, 0x0338},
+{ 0x219B, 0x2192, 0x0338},
+{ 0x21AE, 0x2194, 0x0338},
+{ 0x21CD, 0x21D0, 0x0338},
+{ 0x21CF, 0x21D2, 0x0338},
+{ 0x21CE, 0x21D4, 0x0338},
+{ 0x2204, 0x2203, 0x0338},
+{ 0x2209, 0x2208, 0x0338},
+{ 0x220C, 0x220B, 0x0338},
+{ 0x2224, 0x2223, 0x0338},
+{ 0x2226, 0x2225, 0x0338},
+{ 0x2241, 0x223C, 0x0338},
+{ 0x2244, 0x2243, 0x0338},
+{ 0x2247, 0x2245, 0x0338},
+{ 0x2249, 0x2248, 0x0338},
+{ 0x226D, 0x224D, 0x0338},
+{ 0x2262, 0x2261, 0x0338},
+{ 0x2270, 0x2264, 0x0338},
+{ 0x2271, 0x2265, 0x0338},
+{ 0x2274, 0x2272, 0x0338},
+{ 0x2275, 0x2273, 0x0338},
+{ 0x2278, 0x2276, 0x0338},
+{ 0x2279, 0x2277, 0x0338},
+{ 0x2280, 0x227A, 0x0338},
+{ 0x2281, 0x227B, 0x0338},
+{ 0x22E0, 0x227C, 0x0338},
+{ 0x22E1, 0x227D, 0x0338},
+{ 0x2284, 0x2282, 0x0338},
+{ 0x2285, 0x2283, 0x0338},
+{ 0x2288, 0x2286, 0x0338},
+{ 0x2289, 0x2287, 0x0338},
+{ 0x22E2, 0x2291, 0x0338},
+{ 0x22E3, 0x2292, 0x0338},
+{ 0x22AC, 0x22A2, 0x0338},
+{ 0x22AD, 0x22A8, 0x0338},
+{ 0x22AE, 0x22A9, 0x0338},
+{ 0x22AF, 0x22AB, 0x0338},
+{ 0x22EA, 0x22B2, 0x0338},
+{ 0x22EB, 0x22B3, 0x0338},
+{ 0x22EC, 0x22B4, 0x0338},
+{ 0x22ED, 0x22B5, 0x0338},
+{ 0x2ADC, 0x2ADD, 0x0338},
+{ 0x3094, 0x3046, 0x3099},
+{ 0x304C, 0x304B, 0x3099},
+{ 0x304E, 0x304D, 0x3099},
+{ 0x3050, 0x304F, 0x3099},
+{ 0x3052, 0x3051, 0x3099},
+{ 0x3054, 0x3053, 0x3099},
+{ 0x3056, 0x3055, 0x3099},
+{ 0x3058, 0x3057, 0x3099},
+{ 0x305A, 0x3059, 0x3099},
+{ 0x305C, 0x305B, 0x3099},
+{ 0x305E, 0x305D, 0x3099},
+{ 0x3060, 0x305F, 0x3099},
+{ 0x3062, 0x3061, 0x3099},
+{ 0x3065, 0x3064, 0x3099},
+{ 0x3067, 0x3066, 0x3099},
+{ 0x3069, 0x3068, 0x3099},
+{ 0x3070, 0x306F, 0x3099},
+{ 0x3071, 0x306F, 0x309A},
+{ 0x3073, 0x3072, 0x3099},
+{ 0x3074, 0x3072, 0x309A},
+{ 0x3076, 0x3075, 0x3099},
+{ 0x3077, 0x3075, 0x309A},
+{ 0x3079, 0x3078, 0x3099},
+{ 0x307A, 0x3078, 0x309A},
+{ 0x307C, 0x307B, 0x3099},
+{ 0x307D, 0x307B, 0x309A},
+{ 0x309E, 0x309D, 0x3099},
+{ 0x30F4, 0x30A6, 0x3099},
+{ 0x30AC, 0x30AB, 0x3099},
+{ 0x30AE, 0x30AD, 0x3099},
+{ 0x30B0, 0x30AF, 0x3099},
+{ 0x30B2, 0x30B1, 0x3099},
+{ 0x30B4, 0x30B3, 0x3099},
+{ 0x30B6, 0x30B5, 0x3099},
+{ 0x30B8, 0x30B7, 0x3099},
+{ 0x30BA, 0x30B9, 0x3099},
+{ 0x30BC, 0x30BB, 0x3099},
+{ 0x30BE, 0x30BD, 0x3099},
+{ 0x30C0, 0x30BF, 0x3099},
+{ 0x30C2, 0x30C1, 0x3099},
+{ 0x30C5, 0x30C4, 0x3099},
+{ 0x30C7, 0x30C6, 0x3099},
+{ 0x30C9, 0x30C8, 0x3099},
+{ 0x30D0, 0x30CF, 0x3099},
+{ 0x30D1, 0x30CF, 0x309A},
+{ 0x30D3, 0x30D2, 0x3099},
+{ 0x30D4, 0x30D2, 0x309A},
+{ 0x30D6, 0x30D5, 0x3099},
+{ 0x30D7, 0x30D5, 0x309A},
+{ 0x30D9, 0x30D8, 0x3099},
+{ 0x30DA, 0x30D8, 0x309A},
+{ 0x30DC, 0x30DB, 0x3099},
+{ 0x30DD, 0x30DB, 0x309A},
+{ 0x30F7, 0x30EF, 0x3099},
+{ 0x30F8, 0x30F0, 0x3099},
+{ 0x30F9, 0x30F1, 0x3099},
+{ 0x30FA, 0x30F2, 0x3099},
+{ 0x30FE, 0x30FD, 0x3099},
+{ 0xFB2C, 0xFB49, 0x05C1},
+{ 0xFB2D, 0xFB49, 0x05C2},
+{ 0x1D15E, 0x1D157, 0x1D165},
+{ 0x1D15F, 0x1D158, 0x1D165},
+{ 0x1D160, 0x1D15F, 0x1D16E},
+{ 0x1D161, 0x1D15F, 0x1D16F},
+{ 0x1D162, 0x1D15F, 0x1D170},
+{ 0x1D163, 0x1D15F, 0x1D171},
+{ 0x1D164, 0x1D15F, 0x1D172},
+{ 0x1D1BB, 0x1D1B9, 0x1D165},
+{ 0x1D1BC, 0x1D1BA, 0x1D165},
+{ 0x1D1BD, 0x1D1BB, 0x1D16E},
+{ 0x1D1BF, 0x1D1BB, 0x1D16F},
+{ 0x1D1BE, 0x1D1BC, 0x1D16E},
+{ 0x1D1C0, 0x1D1BC, 0x1D16F},
+};
+
+#define UNICODE_SHIFT 21
+
+int do_precomposition(int base, int comb) {
+  int min = 0;
+  int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
+  int mid;
+  unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb;
+  unsigned long that;
+
+  /* binary search */
+  while (max >= min) {
+    mid = (min + max) / 2;
+    that = ((unsigned) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb);
+    if (that < sought) {
+      min = mid + 1;
+    } else if (that > sought) {
+      max = mid - 1;
+    } else {
+      return precompositions[mid].replacement;
+    }
+  }
+  /* no match */
+  return -1;
+}
diff --git a/precompose.h b/precompose.h
new file mode 100644 (file)
index 0000000..661bbb1
--- /dev/null
@@ -0,0 +1,11 @@
+/* $XFree86: xc/programs/xterm/precompose.h,v 1.1 2000/08/26 04:33:54 dawes Exp $ */
+
+#ifndef PRECOMPOSE_H
+#define PRECOMPOSE_H
+
+int do_precomposition(int base, int comb);
+
+/* returns unicode value if a canonical composition exists,
+   otherwise -1 */
+
+#endif
diff --git a/print.c b/print.c
new file mode 100644 (file)
index 0000000..99b17f2
--- /dev/null
+++ b/print.c
@@ -0,0 +1,687 @@
+/* $XTermId: print.c,v 1.121 2011/02/09 10:11:44 tom Exp $ */
+
+/************************************************************
+
+Copyright 1997-2010,2011 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <xterm.h>
+#include <data.h>
+#include <menu.h>
+#include <error.h>
+#include <xstrings.h>
+
+#include <stdio.h>
+
+#undef  CTRL
+#define        CTRL(c) ((c) & 0x1f)
+
+#define SHIFT_IN  '\017'
+#define SHIFT_OUT '\016'
+
+#define CSET_IN   'A'
+#define CSET_OUT  '0'
+
+#define isForm(c)      ((c) == '\r' || (c) == '\n' || (c) == '\f')
+#define Strlen(a)      strlen((char *)a)
+#define Strcmp(a,b)    strcmp((char *)a,(char *)b)
+#define Strncmp(a,b,c) strncmp((char *)a,(char *)b,c)
+
+#ifdef VMS
+#define VMS_TEMP_PRINT_FILE "sys$scratch:xterm_print.txt"
+#endif
+
+static void charToPrinter(XtermWidget /* xw */ ,
+                         unsigned /* chr */ );
+static void printLine(XtermWidget /* xw */ ,
+                     int /* row */ ,
+                     unsigned /* chr */ ,
+                     PrinterFlags * /* p */ );
+static void send_CharSet(XtermWidget /* xw */ ,
+                        LineData * /* ld */ );
+static void send_SGR(XtermWidget /* xw */ ,
+                    unsigned /* attr */ ,
+                    unsigned /* fg */ ,
+                    unsigned /* bg */ );
+static void stringToPrinter(XtermWidget /* xw */ ,
+                           const char * /*str */ );
+
+static FILE *Printer;
+static pid_t Printer_pid;
+static int initialized;
+
+static void
+closePrinter(XtermWidget xw GCC_UNUSED)
+{
+    if (xtermHasPrinter(xw) != 0) {
+#ifdef VMS
+       TScreen *screen = TScreenOf(xw);
+
+       char pcommand[256];
+       (void) sprintf(pcommand, "%s %s;",
+                      screen->printer_command,
+                      VMS_TEMP_PRINT_FILE);
+#endif
+
+       if (Printer != 0) {
+           fclose(Printer);
+           TRACE(("closed printer, waiting...\n"));
+#ifdef VMS                     /* This is a quick hack, really should use
+                                  spawn and check status or system services
+                                  and go straight to the queue */
+           (void) system(pcommand);
+#else /* VMS */
+           while (nonblocking_wait() > 0)
+#endif /* VMS */
+               ;
+           Printer = 0;
+           initialized = 0;
+           TRACE(("closed printer\n"));
+       }
+    }
+}
+
+static void
+printCursorLine(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("printCursorLine\n"));
+    printLine(xw, screen->cur_row, '\n', getPrinterFlags(xw, NULL, 0));
+}
+
+#define NO_COLOR       ((unsigned)-1)
+
+/*
+ * DEC's manual doesn't document whether trailing blanks are removed, or what
+ * happens with a line that is entirely blank.  This function prints the
+ * characters that xterm would allow as a selection (which may include blanks).
+ */
+static void
+printLine(XtermWidget xw, int row, unsigned chr, PrinterFlags * p)
+{
+    TScreen *screen = TScreenOf(xw);
+    int inx = ROW2INX(screen, row);
+    LineData *ld;
+    Char attr = 0;
+    unsigned ch;
+    int last = MaxCols(screen);
+    int col;
+#if OPT_ISO_COLORS && OPT_PRINT_COLORS
+#define ColorOf(ld,col) (ld->color[col])
+#endif
+    unsigned fg = NO_COLOR, last_fg = NO_COLOR;
+    unsigned bg = NO_COLOR, last_bg = NO_COLOR;
+    int cs = CSET_IN;
+    int last_cs = CSET_IN;
+
+    ld = getLineData(screen, inx);
+    if (ld == 0)
+       return;
+
+    TRACE(("printLine(row=%d/%d, top=%d:%d, chr=%d):%s\n",
+          row, ROW2INX(screen, row), screen->topline, screen->max_row, chr,
+          visibleIChars(ld->charData, (unsigned) last)));
+
+    while (last > 0) {
+       if ((ld->attribs[last - 1] & CHARDRAWN) == 0)
+           last--;
+       else
+           break;
+    }
+    if (last) {
+       if (p->print_attributes) {
+           send_CharSet(xw, ld);
+           send_SGR(xw, 0, NO_COLOR, NO_COLOR);
+       }
+       for (col = 0; col < last; col++) {
+           ch = ld->charData[col];
+#if OPT_PRINT_COLORS
+           if (screen->colorMode) {
+               if (p->print_attributes > 1) {
+                   fg = (ld->attribs[col] & FG_COLOR)
+                       ? extract_fg(xw, ColorOf(ld, col), ld->attribs[col])
+                       : NO_COLOR;
+                   bg = (ld->attribs[col] & BG_COLOR)
+                       ? extract_bg(xw, ColorOf(ld, col), ld->attribs[col])
+                       : NO_COLOR;
+               }
+           }
+#endif
+           if ((((ld->attribs[col] & SGR_MASK) != attr)
+#if OPT_PRINT_COLORS
+                || (last_fg != fg) || (last_bg != bg)
+#endif
+               )
+               && ch) {
+               attr = CharOf(ld->attribs[col] & SGR_MASK);
+#if OPT_PRINT_COLORS
+               last_fg = fg;
+               last_bg = bg;
+#endif
+               if (p->print_attributes)
+                   send_SGR(xw, attr, fg, bg);
+           }
+
+           if (ch == 0)
+               ch = ' ';
+
+#if OPT_WIDE_CHARS
+           if (screen->utf8_mode)
+               cs = CSET_IN;
+           else
+#endif
+               cs = (ch >= ' ' && ch != ANSI_DEL) ? CSET_IN : CSET_OUT;
+           if (last_cs != cs) {
+               if (p->print_attributes) {
+                   charToPrinter(xw,
+                                 (unsigned) ((cs == CSET_OUT)
+                                             ? SHIFT_OUT
+                                             : SHIFT_IN));
+               }
+               last_cs = cs;
+           }
+
+           /* FIXME:  we shouldn't have to map back from the
+            * alternate character set, except that the
+            * corresponding charset information is not encoded
+            * into the CSETS array.
+            */
+           charToPrinter(xw,
+                         ((cs == CSET_OUT)
+                          ? (ch == ANSI_DEL ? 0x5f : (ch + 0x5f))
+                          : ch));
+           if_OPT_WIDE_CHARS(screen, {
+               size_t off;
+               for_each_combData(off, ld) {
+                   ch = ld->combData[off][col];
+                   if (ch == 0)
+                       break;
+                   charToPrinter(xw, ch);
+               }
+           });
+       }
+       if (p->print_attributes) {
+           send_SGR(xw, 0, NO_COLOR, NO_COLOR);
+           if (cs != CSET_IN)
+               charToPrinter(xw, SHIFT_IN);
+       }
+    }
+
+    /* finish line (protocol for attributes needs a CR */
+    if (p->print_attributes)
+       charToPrinter(xw, '\r');
+
+    if (chr && !(p->printer_newline)) {
+       if (LineTstWrapped(ld))
+           chr = '\0';
+    }
+
+    if (chr)
+       charToPrinter(xw, chr);
+
+    return;
+}
+
+#define PrintNewLine() (unsigned) (((top < bot) || p->printer_newline) ? '\n' : '\0')
+
+void
+xtermPrintScreen(XtermWidget xw, Bool use_DECPEX, PrinterFlags * p)
+{
+    if (XtIsRealized((Widget) xw)) {
+       TScreen *screen = TScreenOf(xw);
+       Bool extent = (use_DECPEX && p->printer_extent);
+       int top = extent ? 0 : screen->top_marg;
+       int bot = extent ? screen->max_row : screen->bot_marg;
+       int was_open = initialized;
+
+       TRACE(("xtermPrintScreen, rows %d..%d\n", top, bot));
+
+       while (top <= bot) {
+           printLine(xw, top, PrintNewLine(), p);
+           ++top;
+       }
+       if (p->printer_formfeed)
+           charToPrinter(xw, '\f');
+
+       if (!was_open || screen->printer_autoclose) {
+           closePrinter(xw);
+       }
+    } else {
+       Bell(xw, XkbBI_MinorError, 0);
+    }
+}
+
+/*
+ * If the alternate screen is active, we'll print only that.  Otherwise, print
+ * the normal screen plus all scrolled-back lines.  The distinction is made
+ * because the normal screen's buffer is part of the overall scrollback buffer.
+ */
+void
+xtermPrintEverything(XtermWidget xw, PrinterFlags * p)
+{
+    TScreen *screen = TScreenOf(xw);
+    int top = 0;
+    int bot = screen->max_row;
+    int was_open = initialized;
+
+    if (!screen->whichBuf) {
+       top = -screen->savedlines - screen->topline;
+       bot -= screen->topline;
+    }
+
+    TRACE(("xtermPrintEverything, rows %d..%d\n", top, bot));
+    while (top <= bot) {
+       printLine(xw, top, PrintNewLine(), p);
+       ++top;
+    }
+    if (p->printer_formfeed)
+       charToPrinter(xw, '\f');
+
+    if (!was_open || screen->printer_autoclose) {
+       closePrinter(xw);
+    }
+}
+
+static void
+send_CharSet(XtermWidget xw, LineData * ld)
+{
+#if OPT_DEC_CHRSET
+    const char *msg = 0;
+
+    switch (GetLineDblCS(ld)) {
+    case CSET_SWL:
+       msg = "\033#5";
+       break;
+    case CSET_DHL_TOP:
+       msg = "\033#3";
+       break;
+    case CSET_DHL_BOT:
+       msg = "\033#4";
+       break;
+    case CSET_DWL:
+       msg = "\033#6";
+       break;
+    }
+    if (msg != 0)
+       stringToPrinter(xw, msg);
+#else
+    (void) xw;
+    (void) ld;
+#endif /* OPT_DEC_CHRSET */
+}
+
+static void
+send_SGR(XtermWidget xw, unsigned attr, unsigned fg, unsigned bg)
+{
+    char msg[80];
+    strcpy(msg, "\033[0");
+    if (attr & BOLD)
+       strcat(msg, ";1");
+    if (attr & UNDERLINE)
+       strcat(msg, ";4");      /* typo? DEC documents this as '2' */
+    if (attr & BLINK)
+       strcat(msg, ";5");
+    if (attr & INVERSE)                /* typo? DEC documents this as invisible */
+       strcat(msg, ";7");
+#if OPT_PRINT_COLORS
+    if (bg != NO_COLOR) {
+       sprintf(msg + strlen(msg), ";%u", (bg < 8) ? (40 + bg) : (92 + bg));
+    }
+    if (fg != NO_COLOR) {
+#if OPT_PC_COLORS
+       if (TScreenOf(xw)->boldColors
+           && fg > 8
+           && (attr & BOLD) != 0)
+           fg -= 8;
+#endif
+       sprintf(msg + strlen(msg), ";%u", (fg < 8) ? (30 + fg) : (82 + fg));
+    }
+#else
+    (void) bg;
+    (void) fg;
+#endif
+    strcat(msg, "m");
+    stringToPrinter(xw, msg);
+}
+
+/*
+ * This implementation only knows how to write to a pipe.
+ */
+static void
+charToPrinter(XtermWidget xw, unsigned chr)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (!initialized && xtermHasPrinter(xw)) {
+#if defined(VMS)
+       /*
+        * This implementation only knows how to write to a file.  When the
+        * file is closed the print command executes.  Print command must be of
+        * the form:
+        *   print/que=name/delete [/otherflags].
+        */
+       Printer = fopen(VMS_TEMP_PRINT_FILE, "w");
+#else
+       /*
+        * This implementation only knows how to write to a pipe.
+        */
+       FILE *input;
+       int my_pipe[2];
+       int c;
+
+       if (pipe(my_pipe))
+           SysError(ERROR_FORK);
+       if ((Printer_pid = fork()) < 0)
+           SysError(ERROR_FORK);
+
+       if (Printer_pid == 0) {
+           TRACE_CLOSE();
+           close(my_pipe[1]);  /* printer is silent */
+           close(screen->respond);
+
+           close(fileno(stdout));
+           dup2(fileno(stderr), 1);
+
+           if (fileno(stderr) != 2) {
+               dup2(fileno(stderr), 2);
+               close(fileno(stderr));
+           }
+
+           /* don't want privileges! */
+           if (xtermResetIds(screen) < 0)
+               exit(1);
+
+           Printer = popen(screen->printer_command, "w");
+           input = fdopen(my_pipe[0], "r");
+           while ((c = fgetc(input)) != EOF) {
+               fputc(c, Printer);
+               if (isForm(c))
+                   fflush(Printer);
+           }
+           pclose(Printer);
+           exit(0);
+       } else {
+           close(my_pipe[0]);  /* won't read from printer */
+           Printer = fdopen(my_pipe[1], "w");
+           TRACE(("opened printer from pid %d/%d\n",
+                  (int) getpid(), (int) Printer_pid));
+       }
+#endif
+       initialized++;
+    }
+    if (Printer != 0) {
+#if OPT_WIDE_CHARS
+       if (chr > 127) {
+           Char temp[10];
+           *convertToUTF8(temp, chr) = 0;
+           fputs((char *) temp, Printer);
+       } else
+#endif
+           fputc((int) chr, Printer);
+       if (isForm(chr))
+           fflush(Printer);
+    }
+}
+
+static void
+stringToPrinter(XtermWidget xw, const char *str)
+{
+    while (*str)
+       charToPrinter(xw, CharOf(*str++));
+}
+
+/*
+ * This module implements the MC (Media Copy) and related printing control
+ * sequences for VTxxx emulation.  This is based on the description in the
+ * VT330/VT340 Programmer Reference Manual EK-VT3XX-TP-001 (Digital Equipment
+ * Corp., March 1987).
+ */
+void
+xtermMediaControl(XtermWidget xw, int param, int private_seq)
+{
+    TRACE(("MediaCopy param=%d, private=%d\n", param, private_seq));
+
+    if (private_seq) {
+       switch (param) {
+       case 1:
+           printCursorLine(xw);
+           break;
+       case 4:
+           setPrinterControlMode(xw, 0);
+           break;
+       case 5:
+           setPrinterControlMode(xw, 1);
+           break;
+       case 10:                /* VT320 */
+           xtermPrintScreen(xw, False, getPrinterFlags(xw, NULL, 0));
+           break;
+       case 11:                /* VT320 */
+           xtermPrintEverything(xw, getPrinterFlags(xw, NULL, 0));
+           break;
+       }
+    } else {
+       switch (param) {
+       case -1:
+       case 0:
+           xtermPrintScreen(xw, True, getPrinterFlags(xw, NULL, 0));
+           break;
+       case 4:
+           setPrinterControlMode(xw, 0);
+           break;
+       case 5:
+           setPrinterControlMode(xw, 2);
+           break;
+       }
+    }
+}
+
+/*
+ * When in autoprint mode, the printer prints a line from the screen when you
+ * move the cursor off that line with an LF, FF, or VT character, or an
+ * autowrap occurs.  The printed line ends with a CR and the character (LF, FF
+ * or VT) that moved the cursor off the previous line.
+ */
+void
+xtermAutoPrint(XtermWidget xw, unsigned chr)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->printer_controlmode == 1) {
+       TRACE(("AutoPrint %d\n", chr));
+       printLine(xw, screen->cursorp.row, chr, getPrinterFlags(xw, NULL, 0));
+       if (Printer != 0)
+           fflush(Printer);
+    }
+}
+
+/*
+ * When in printer controller mode, the terminal sends received characters to
+ * the printer without displaying them on the screen. The terminal sends all
+ * characters and control sequences to the printer, except NUL, XON, XOFF, and
+ * the printer controller sequences.
+ *
+ * This function eats characters, returning 0 as long as it must buffer or
+ * divert to the printer.  We're only invoked here when in printer controller
+ * mode, and handle the exit from that mode.
+ */
+#define LB '['
+
+int
+xtermPrinterControl(XtermWidget xw, int chr)
+{
+    TScreen *screen = TScreenOf(xw);
+    /* *INDENT-OFF* */
+    static struct {
+       Char seq[5];
+       int active;
+    } tbl[] = {
+       { { ANSI_CSI, '5', 'i'      }, 2 },
+       { { ANSI_CSI, '4', 'i'      }, 0 },
+       { { ANSI_ESC, LB,  '5', 'i' }, 2 },
+       { { ANSI_ESC, LB,  '4', 'i' }, 0 },
+    };
+    /* *INDENT-ON* */
+
+    static Char bfr[10];
+    static size_t length;
+    size_t n;
+
+    TRACE(("In printer:%04X\n", chr));
+
+    switch (chr) {
+    case 0:
+    case CTRL('Q'):
+    case CTRL('S'):
+       return 0;               /* ignored by application */
+
+    case ANSI_CSI:
+    case ANSI_ESC:
+    case '[':
+    case '4':
+    case '5':
+    case 'i':
+       bfr[length++] = CharOf(chr);
+       for (n = 0; n < sizeof(tbl) / sizeof(tbl[0]); n++) {
+           size_t len = Strlen(tbl[n].seq);
+
+           if (length == len
+               && Strcmp(bfr, tbl[n].seq) == 0) {
+               setPrinterControlMode(xw, tbl[n].active);
+               if (screen->printer_autoclose
+                   && screen->printer_controlmode == 0)
+                   closePrinter(xw);
+               length = 0;
+               return 0;
+           } else if (len > length
+                      && Strncmp(bfr, tbl[n].seq, length) == 0) {
+               return 0;
+           }
+       }
+       length--;
+
+       /* FALLTHRU */
+
+    default:
+       for (n = 0; n < length; n++)
+           charToPrinter(xw, bfr[n]);
+       bfr[0] = CharOf(chr);
+       length = 1;
+       return 0;
+    }
+}
+
+/*
+ * If there is no printer command, we will ignore printer controls.
+ */
+Bool
+xtermHasPrinter(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    return (strlen(screen->printer_command) != 0);
+}
+
+#define showPrinterControlMode(mode) \
+               (((mode) == 0) \
+                ? "normal" \
+                : ((mode) == 1 \
+                   ? "autoprint" \
+                   : "printer controller"))
+
+void
+setPrinterControlMode(XtermWidget xw, int mode)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (xtermHasPrinter(xw)
+       && screen->printer_controlmode != mode) {
+       TRACE(("%s %s mode\n",
+              (mode
+               ? "set"
+               : "reset"),
+              (mode
+               ? showPrinterControlMode(mode)
+               : showPrinterControlMode(screen->printer_controlmode))));
+       screen->printer_controlmode = mode;
+       update_print_redir();
+    }
+}
+
+PrinterFlags *
+getPrinterFlags(XtermWidget xw, String * params, Cardinal *param_count)
+{
+    /* *INDENT-OFF* */
+    static const struct {
+       const char *name;
+       unsigned    offset;
+       int         value;
+    } table[] = {
+       { "noFormFeed", XtOffsetOf(PrinterFlags, printer_formfeed), 0 },
+       { "FormFeed",   XtOffsetOf(PrinterFlags, printer_formfeed), 1 },
+       { "noNewLine",  XtOffsetOf(PrinterFlags, printer_newline),  0 },
+       { "NewLine",    XtOffsetOf(PrinterFlags, printer_newline),  1 },
+       { "noAttrs",    XtOffsetOf(PrinterFlags, print_attributes), 0 },
+       { "monoAttrs",  XtOffsetOf(PrinterFlags, print_attributes), 1 },
+       { "colorAttrs", XtOffsetOf(PrinterFlags, print_attributes), 2 },
+    };
+    /* *INDENT-ON* */
+
+    TScreen *screen = TScreenOf(xw);
+    PrinterFlags *result = &(screen->printer_flags);
+
+    TRACE(("getPrinterFlags %d params\n", param_count ? *param_count : 0));
+
+    result->printer_extent = screen->printer_extent;
+    result->printer_formfeed = screen->printer_formfeed;
+    result->printer_newline = screen->printer_newline;
+    result->print_attributes = screen->print_attributes;
+
+    if (param_count != 0 && *param_count != 0) {
+       Cardinal j;
+       unsigned k;
+       for (j = 0; j < *param_count; ++j) {
+           TRACE(("param%d:%s\n", j, params[j]));
+           for (k = 0; k < XtNumber(table); ++k) {
+               if (!x_strcasecmp(params[j], table[k].name)) {
+                   int *ptr = (int *) (void *) ((char *) result + table[k].offset);
+                   TRACE(("...PrinterFlags(%s) %d->%d\n",
+                          table[k].name,
+                          *ptr,
+                          table[k].value));
+                   *ptr = table[k].value;
+                   break;
+               }
+           }
+       }
+    }
+
+    return result;
+}
diff --git a/proto.h b/proto.h
new file mode 100644 (file)
index 0000000..d2463ce
--- /dev/null
+++ b/proto.h
@@ -0,0 +1,62 @@
+/*
+ * $XTermId: proto.h,v 1.10 2003/10/27 01:07:57 tom Exp $
+ * ----------------------------------------------------------------------------
+ * this file is part of xterm
+ *
+ * Copyright 1996-2008,2003 by Thomas E. Dickey
+ * 
+ *                         All Rights Reserved
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ * ----------------------------------------------------------------------------
+ */
+
+#ifndef included_proto_h
+#define included_proto_h
+
+#define PROTO_XT_ACTIONS_ARGS \
+       (Widget w, XEvent *event, String *params, Cardinal *num_params)
+
+#define PROTO_XT_CALLBACK_ARGS \
+       (Widget gw, XtPointer closure, XtPointer data)
+
+#define PROTO_XT_CVT_SELECT_ARGS \
+       (Widget w, Atom *selection, Atom *target, Atom *type, XtPointer *value, unsigned long *length, int *format)
+
+#define PROTO_XT_EV_HANDLER_ARGS \
+       (Widget w, XtPointer closure, XEvent *event, Boolean *cont)
+
+#define PROTO_XT_SEL_CB_ARGS \
+       (Widget w, XtPointer client_data, Atom *selection, Atom *type, XtPointer value, unsigned long *length, int *format)
+
+#ifdef SIGNALRETURNSINT
+#define SIGNAL_T int
+#define SIGNAL_RETURN return 0
+#else
+#define SIGNAL_T void
+#define SIGNAL_RETURN return
+#endif
+
+#endif/*included_proto_h*/
diff --git a/ptydata.c b/ptydata.c
new file mode 100644 (file)
index 0000000..9e26120
--- /dev/null
+++ b/ptydata.c
@@ -0,0 +1,512 @@
+/* $XTermId: ptydata.c,v 1.100 2011/02/02 01:45:14 tom Exp $ */
+
+/************************************************************
+
+Copyright 1999-2010,2011 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <data.h>
+
+#if OPT_WIDE_CHARS
+#include <menu.h>
+#endif
+
+/*
+ * Check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN.
+ * Note that this macro may evaluate its argument more than once.
+ */
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define E_TEST(err) ((err) == EAGAIN || (err) == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define E_TEST(err) ((err) == EAGAIN)
+#else
+#define E_TEST(err) ((err) == EWOULDBLOCK)
+#endif
+#endif
+
+#if OPT_WIDE_CHARS
+/*
+ * Convert the 8-bit codes in data->buffer[] into Unicode in data->utf_data.
+ * The number of bytes converted will be nonzero iff there is data.
+ */
+Bool
+decodeUtf8(PtyData * data)
+{
+    int i;
+    int length = (int) (data->last - data->next);
+    int utf_count = 0;
+    unsigned utf_char = 0;
+
+    data->utf_size = 0;
+    for (i = 0; i < length; i++) {
+       unsigned c = data->next[i];
+
+       /* Combine UTF-8 into Unicode */
+       if (c < 0x80) {
+           /* We received an ASCII character */
+           if (utf_count > 0) {
+               data->utf_data = UCS_REPL;      /* prev. sequence incomplete */
+               data->utf_size = i;
+           } else {
+               data->utf_data = (IChar) c;
+               data->utf_size = 1;
+           }
+           break;
+       } else if (c < 0xc0) {
+           /* We received a continuation byte */
+           if (utf_count < 1) {
+               /*
+                * We received a continuation byte before receiving a sequence
+                * state.  Or an attempt to use a C1 control string.  Either
+                * way, it is mapped to the replacement character.
+                */
+               data->utf_data = UCS_REPL;      /* ... unexpectedly */
+               data->utf_size = (i + 1);
+               break;
+           } else {
+               /* Check for overlong UTF-8 sequences for which a shorter
+                * encoding would exist and replace them with UCS_REPL.
+                * An overlong UTF-8 sequence can have any of the following
+                * forms:
+                *   1100000x 10xxxxxx
+                *   11100000 100xxxxx 10xxxxxx
+                *   11110000 1000xxxx 10xxxxxx 10xxxxxx
+                *   11111000 10000xxx 10xxxxxx 10xxxxxx 10xxxxxx
+                *   11111100 100000xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+                */
+               if (!utf_char && !((c & 0x7f) >> (7 - utf_count))) {
+                   utf_char = UCS_REPL;
+               }
+               utf_char <<= 6;
+               utf_char |= (c & 0x3f);
+               if ((utf_char >= 0xd800 &&
+                    utf_char <= 0xdfff) ||
+                   (utf_char == 0xfffe) ||
+                   (utf_char == HIDDEN_CHAR)) {
+                   utf_char = UCS_REPL;
+               }
+               utf_count--;
+               if (utf_count == 0) {
+#if !OPT_WIDER_ICHAR
+                   /* characters outside UCS-2 become UCS_REPL */
+                   if (utf_char > 0xffff) {
+                       TRACE(("using replacement for %#x\n", utf_char));
+                       utf_char = UCS_REPL;
+                   }
+#endif
+                   data->utf_data = (IChar) utf_char;
+                   data->utf_size = (i + 1);
+                   break;
+               }
+           }
+       } else {
+           /* We received a sequence start byte */
+           if (utf_count > 0) {
+               data->utf_data = UCS_REPL;      /* prev. sequence incomplete */
+               data->utf_size = (i + 1);
+               break;
+           }
+           if (c < 0xe0) {
+               utf_count = 1;
+               utf_char = (c & 0x1f);
+               if (!(c & 0x1e)) {
+                   utf_char = UCS_REPL;        /* overlong sequence */
+               }
+           } else if (c < 0xf0) {
+               utf_count = 2;
+               utf_char = (c & 0x0f);
+           } else if (c < 0xf8) {
+               utf_count = 3;
+               utf_char = (c & 0x07);
+           } else if (c < 0xfc) {
+               utf_count = 4;
+               utf_char = (c & 0x03);
+           } else if (c < 0xfe) {
+               utf_count = 5;
+               utf_char = (c & 0x01);
+           } else {
+               data->utf_data = UCS_REPL;
+               data->utf_size = (i + 1);
+               break;
+           }
+       }
+    }
+#if OPT_TRACE > 1
+    TRACE(("UTF-8 char %04X [%d..%d]\n",
+          data->utf_data,
+          data->next - data->buffer,
+          data->next - data->buffer + data->utf_size - 1));
+#endif
+
+    return (data->utf_size != 0);
+}
+#endif
+
+int
+readPtyData(XtermWidget xw, PtySelect * select_mask, PtyData * data)
+{
+    TScreen *screen = TScreenOf(xw);
+    int size = 0;
+
+#ifdef VMS
+    if (*select_mask & pty_mask) {
+       trimPtyData(xw, data);
+       if (read_queue.flink != 0) {
+           size = tt_read(data->next);
+           if (size == 0) {
+               Panic("input: read returned zero\n", 0);
+           }
+       } else {
+           sys$hiber();
+       }
+    }
+#else /* !VMS */
+    if (FD_ISSET(screen->respond, select_mask)) {
+       int save_err;
+       trimPtyData(xw, data);
+
+       size = (int) read(screen->respond, (char *) data->last, (size_t) FRG_SIZE);
+       save_err = errno;
+#if (defined(i386) && defined(SVR4) && defined(sun)) || defined(__CYGWIN__)
+       /*
+        * Yes, I know this is a majorly f*ugly hack, however it seems to
+        * be necessary for Solaris x86.  DWH 11/15/94
+        * Dunno why though..
+        * (and now CYGWIN, alanh@xfree86.org 08/15/01
+        */
+       if (size <= 0) {
+           if (save_err == EIO || save_err == 0)
+               Cleanup(0);
+           else if (!E_TEST(save_err))
+               Panic("input: read returned unexpected error (%d)\n", save_err);
+           size = 0;
+       }
+#else /* !f*ugly */
+       if (size < 0) {
+           if (save_err == EIO)
+               Cleanup(0);
+           else if (!E_TEST(save_err))
+               Panic("input: read returned unexpected error (%d)\n", save_err);
+           size = 0;
+       } else if (size == 0) {
+#if defined(__UNIXOS2__) || defined(__FreeBSD__)
+           Cleanup(0);
+#else
+           Panic("input: read returned zero\n", 0);
+#endif
+       }
+#endif /* f*ugly */
+    }
+#endif /* VMS */
+
+    if (size) {
+#if OPT_TRACE
+       int i;
+
+       TRACE(("read %d bytes from pty\n", size));
+       for (i = 0; i < size; i++) {
+           if (!(i % 16))
+               TRACE(("%s", i ? "\n    " : "READ"));
+           TRACE((" %02X", data->last[i]));
+       }
+       TRACE(("\n"));
+#endif
+       data->last += size;
+#ifdef ALLOWLOGGING
+       TScreenOf(term)->logstart = VTbuffer->next;
+#endif
+    }
+
+    return (size);
+}
+
+/*
+ * Return the next value from the input buffer.  Note that morePtyData() is
+ * always called before this function, so we can do the UTF-8 input conversion
+ * in that function and simply return the result here.
+ */
+#if OPT_WIDE_CHARS
+IChar
+nextPtyData(TScreen * screen, PtyData * data)
+{
+    IChar result;
+    if (screen->utf8_inparse) {
+       result = skipPtyData(data);
+    } else {
+       result = *((data)->next++);
+       if (!screen->output_eight_bits) {
+           result = (IChar) (result & 0x7f);
+       }
+    }
+    TRACE2(("nextPtyData returns %#x\n", result));
+    return result;
+}
+
+/*
+ * Simply return the data and skip past it.
+ */
+IChar
+skipPtyData(PtyData * data)
+{
+    IChar result = data->utf_data;
+
+    data->next += data->utf_size;
+    data->utf_size = 0;
+
+    return result;
+}
+#endif
+
+#if OPT_WIDE_CHARS
+/*
+ * Called when UTF-8 mode has been turned on/off.
+ */
+void
+switchPtyData(TScreen * screen, int flag)
+{
+    if (screen->utf8_mode != flag) {
+       screen->utf8_mode = flag;
+       screen->utf8_inparse = (Boolean) (flag != 0);
+
+       TRACE(("turning UTF-8 mode %s\n", BtoS(flag)));
+       update_font_utf8_mode();
+    }
+}
+#endif
+
+/*
+ * Allocate a buffer.
+ */
+void
+initPtyData(PtyData ** result)
+{
+    PtyData *data;
+
+    TRACE(("initPtyData given minBufSize %d, maxBufSize %d\n",
+          FRG_SIZE, BUF_SIZE));
+
+    if (FRG_SIZE < 64)
+       FRG_SIZE = 64;
+    if (BUF_SIZE < FRG_SIZE)
+       BUF_SIZE = FRG_SIZE;
+    if (BUF_SIZE % FRG_SIZE)
+       BUF_SIZE = BUF_SIZE + FRG_SIZE - (BUF_SIZE % FRG_SIZE);
+
+    TRACE(("initPtyData using minBufSize %d, maxBufSize %d\n",
+          FRG_SIZE, BUF_SIZE));
+
+    data = TypeXtMallocX(PtyData, (BUF_SIZE + FRG_SIZE));
+
+    memset(data, 0, sizeof(*data));
+    data->next = data->buffer;
+    data->last = data->buffer;
+    *result = data;
+}
+
+/*
+ * Initialize a buffer for the caller, using its data in 'next'.
+ */
+#if OPT_WIDE_CHARS
+PtyData *
+fakePtyData(PtyData * result, Char * next, Char * last)
+{
+    PtyData *data = result;
+
+    memset(data, 0, sizeof(*data));
+    data->next = next;
+    data->last = last;
+
+    return data;
+}
+#endif
+
+/*
+ * Remove used data by shifting the buffer down, to make room for more data,
+ * e.g., a continuation-read.
+ */
+void
+trimPtyData(XtermWidget xw GCC_UNUSED, PtyData * data)
+{
+    int i;
+
+    FlushLog(xw);
+
+    if (data->next != data->buffer) {
+       int n = (int) (data->last - data->next);
+
+       TRACE(("shifting buffer down by %d\n", n));
+       for (i = 0; i < n; ++i) {
+           data->buffer[i] = data->next[i];
+       }
+       data->next = data->buffer;
+       data->last = data->next + n;
+    }
+
+}
+
+/*
+ * Insert new data into the input buffer so the next calls to morePtyData()
+ * and nextPtyData() will return that.
+ */
+void
+fillPtyData(XtermWidget xw, PtyData * data, const char *value, int length)
+{
+    int size;
+    int n;
+
+    /* remove the used portion of the buffer */
+    trimPtyData(xw, data);
+
+    VTbuffer->last += length;
+    size = (int) (VTbuffer->last - VTbuffer->next);
+
+    /* shift the unused portion up to make room */
+    for (n = size; n >= length; --n)
+       VTbuffer->next[n] = VTbuffer->next[n - length];
+
+    /* insert the new bytes to interpret */
+    for (n = 0; n < length; n++)
+       VTbuffer->next[n] = CharOf(value[n]);
+}
+
+#if OPT_WIDE_CHARS
+Char *
+convertToUTF8(Char * lp, unsigned c)
+{
+#define CH(n) (Char)((c) >> ((n) * 8))
+    if (c < 0x80) {
+       /*  0*******  */
+       *lp++ = (Char) CH(0);
+    } else if (c < 0x800) {
+       /*  110***** 10******  */
+       *lp++ = (Char) (0xc0 | (CH(0) >> 6) | ((CH(1) & 0x07) << 2));
+       *lp++ = (Char) (0x80 | (CH(0) & 0x3f));
+    } else if (c < 0x00010000) {
+       /*  1110**** 10****** 10******  */
+       *lp++ = (Char) (0xe0 | ((int) (CH(1) & 0xf0) >> 4));
+       *lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+       *lp++ = (Char) (0x80 | (CH(0) & 0x3f));
+    } else if (c < 0x00200000) {
+       *lp++ = (Char) (0xf0 | ((int) (CH(2) & 0x1f) >> 2));
+       *lp++ = (Char) (0x80 |
+                       ((int) (CH(1) & 0xf0) >> 4) |
+                       ((int) (CH(2) & 0x03) << 4));
+       *lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+       *lp++ = (Char) (0x80 | (CH(0) & 0x3f));
+    } else if (c < 0x04000000) {
+       *lp++ = (Char) (0xf8 | (CH(3) & 0x03));
+       *lp++ = (Char) (0x80 | (CH(2) >> 2));
+       *lp++ = (Char) (0x80 |
+                       ((int) (CH(1) & 0xf0) >> 4) |
+                       ((int) (CH(2) & 0x03) << 4));
+       *lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+       *lp++ = (Char) (0x80 | (CH(0) & 0x3f));
+    } else {
+       *lp++ = (Char) (0xfc | ((int) (CH(3) & 0x40) >> 6));
+       *lp++ = (Char) (0x80 | (CH(3) & 0x3f));
+       *lp++ = (Char) (0x80 | (CH(2) >> 2));
+       *lp++ = (Char) (0x80 | (CH(1) >> 4) | ((CH(2) & 0x03) << 4));
+       *lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
+       *lp++ = (Char) (0x80 | (CH(0) & 0x3f));
+    }
+    return lp;
+#undef CH
+}
+
+/*
+ * Write data back to the PTY
+ */
+void
+writePtyData(int f, IChar * d, unsigned len)
+{
+    unsigned n = (len << 1);
+
+    if (VTbuffer->write_len <= len) {
+       VTbuffer->write_len = n;
+       VTbuffer->write_buf = (Char *) XtRealloc((char *)
+                                                VTbuffer->write_buf, VTbuffer->write_len);
+    }
+
+    for (n = 0; n < len; n++)
+       VTbuffer->write_buf[n] = (Char) d[n];
+
+    TRACE(("writePtyData %d:%s\n", n,
+          visibleChars(VTbuffer->write_buf, n)));
+    v_write(f, VTbuffer->write_buf, n);
+}
+#endif /* OPT_WIDE_CHARS */
+
+#ifdef NO_LEAKS
+void
+noleaks_ptydata(void)
+{
+    if (VTbuffer != 0) {
+#if OPT_WIDE_CHARS
+       if (VTbuffer->write_buf != 0)
+           free(VTbuffer->write_buf);
+#endif
+       free(VTbuffer);
+       VTbuffer = 0;
+    }
+}
+#endif
+
+#if 0
+void
+test_ptydata(void)
+{
+    PtyData *data;
+    unsigned code;
+
+    initPtyData(&data);
+    TRACE(("test_ptydata\n"));
+    for (code = 0; code <= 0x7fffffff; ++code) {
+       int use_size;
+
+       memset(data, 0, sizeof(*data));
+       data->next = data->buffer;
+       data->last = convertToUTF8(data->buffer, code);
+
+       use_size = (data->last - data->next);
+
+       if (decodeUtf8(data)) {
+           if (code != data->utf_data) {
+               TRACE(("code %#x ->%#x\n", code, data->utf_data));
+           } else if (use_size != data->utf_size) {
+               TRACE(("size %#x %d->%d\n", code, use_size, data->utf_size));
+           }
+       } else {
+           TRACE(("fail %#x\n", code));
+       }
+    }
+}
+#endif
diff --git a/ptyx.h b/ptyx.h
new file mode 100644 (file)
index 0000000..792684a
--- /dev/null
+++ b/ptyx.h
@@ -0,0 +1,2618 @@
+/* $XTermId: ptyx.h,v 1.682 2011/01/21 00:41:45 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef included_ptyx_h
+#define included_ptyx_h 1
+
+#ifdef HAVE_CONFIG_H
+#include <xtermcfg.h>
+#endif
+
+/* ptyx.h */
+/* *INDENT-OFF* */
+/* @(#)ptyx.h  X10/6.6 11/10/86 */
+
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>         /* for XtNdieCallback, etc. */
+#include <X11/StringDefs.h>    /* for standard resource names */
+#include <X11/Xmu/Misc.h>      /* For Max() and Min(). */
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+#include <X11/Xmu/Converters.h>
+#ifdef XRENDERFONT
+#include <X11/Xft/Xft.h>
+#endif
+
+/* adapted from IntrinsicI.h */
+#define MyStackAlloc(size, stack_cache_array)     \
+    ((size) <= sizeof(stack_cache_array)         \
+    ?  (XtPointer)(stack_cache_array)            \
+    :  (XtPointer)malloc((size_t)(size)))
+
+#define MyStackFree(pointer, stack_cache_array) \
+    if ((pointer) != ((char *)(stack_cache_array))) free(pointer)
+
+/* adapted from vile (vi-like-emacs) */
+#define TypeCallocN(type,n)    (type *)calloc((size_t) (n), sizeof(type))
+#define TypeCalloc(type)       TypeCallocN(type, 1)
+
+#define TypeMallocN(type,n)    (type *)malloc(sizeof(type) * (size_t) (n))
+#define TypeMalloc(type)       TypeMallocN(type, 1)
+
+#define TypeRealloc(type,n,p)  (type *)realloc(p, (n) * sizeof(type))
+
+#define TypeXtReallocN(t,p,n)  (t *)(void *)XtRealloc((char *)(p), (Cardinal)(sizeof(t) * (size_t) (n)))
+
+#define TypeXtMallocX(type,n)  (type *)(void *)XtMalloc((Cardinal)(sizeof(type) + (size_t) (n)))
+#define TypeXtMallocN(type,n)  (type *)(void *)XtMalloc((Cardinal)(sizeof(type) * (size_t) (n)))
+#define TypeXtMalloc(type)     TypeXtMallocN(type, 1)
+
+/* use these to allocate partly-structured data */
+#define CastMallocN(type,n)    (type *)malloc(sizeof(type) + (size_t) (n))
+#define CastMalloc(type)       CastMallocN(type,0)
+
+#define BumpBuffer(type, buffer, size, want) \
+       if (want >= size) { \
+           size = 1 + (want * 2); \
+           buffer = TypeRealloc(type, size, buffer); \
+       }
+
+#define BfBuf(type) screen->bf_buf_##type
+#define BfLen(type) screen->bf_len_##type
+
+#define TypedBuffer(type) \
+       type            *bf_buf_##type; \
+       Cardinal        bf_len_##type
+
+#define BumpTypedBuffer(type, want) \
+       BumpBuffer(type, BfBuf(type), BfLen(type), want)
+
+#define FreeTypedBuffer(type) \
+       if (BfBuf(type) != 0) { \
+           free(BfBuf(type)); \
+           BfBuf(type) = 0; \
+       } \
+       BfLen(type) = 0
+
+/*
+** System V definitions
+*/
+
+#ifdef att
+#define ATT
+#endif
+
+#ifdef SVR4
+#undef  SYSV                   /* predefined on Solaris 2.4 */
+#define SYSV                   /* SVR4 is (approx) superset of SVR3 */
+#define ATT
+#endif
+
+#ifdef SYSV
+#ifdef X_NOT_POSIX
+#if !defined(CRAY) && !defined(SVR4)
+#define        dup2(fd1,fd2)   ((fd1 == fd2) ? fd1 : \
+                               (close(fd2), fcntl(fd1, F_DUPFD, fd2)))
+#endif
+#endif
+#endif /* SYSV */
+
+/*
+ * Newer versions of <X11/Xft/Xft.h> have a version number.  We use certain
+ * features from that.
+ */
+#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
+#define HAVE_TYPE_FCCHAR32     1       /* compatible: XftChar16 */
+#define HAVE_TYPE_XFTCHARSPEC  1       /* new type XftCharSpec */
+#endif
+
+/*
+** Definitions to simplify ifdef's for pty's.
+*/
+#define USE_PTY_DEVICE 1
+#define USE_PTY_SEARCH 1
+
+#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+#undef USE_PTY_DEVICE
+#undef USE_PTY_SEARCH
+#define USE_PTS_DEVICE 1
+#elif defined(VMS)
+#undef USE_PTY_DEVICE
+#undef USE_PTY_SEARCH
+#elif defined(PUCC_PTYD)
+#undef USE_PTY_SEARCH
+#elif (defined(sun) && defined(SVR4)) || defined(_ALL_SOURCE) || defined(__CYGWIN__)
+#undef USE_PTY_SEARCH
+#endif
+
+#if defined(SYSV) && defined(i386) && !defined(SVR4)
+#define ATT
+#define USE_HANDSHAKE 1
+#define USE_ISPTS_FLAG 1
+#endif
+
+#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
+#define USE_USG_PTYS
+#define USE_HANDSHAKE 0        /* "recent" Linux systems do not require handshaking */
+#elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386))
+#define USE_USG_PTYS
+#else
+#define USE_HANDSHAKE 1
+#endif
+
+/*
+ * More systems than not require pty-handshaking.
+ */
+#ifndef USE_HANDSHAKE
+#define USE_HANDSHAKE 1
+#endif
+
+/*
+** allow for mobility of the pty master/slave directories
+*/
+#ifndef PTYDEV
+#if defined(__hpux)
+#define        PTYDEV          "/dev/ptym/ptyxx"
+#elif defined(__MVS__)
+#define        PTYDEV          "/dev/ptypxxxx"
+#else
+#define        PTYDEV          "/dev/ptyxx"
+#endif
+#endif /* !PTYDEV */
+
+#ifndef TTYDEV
+#if defined(__hpux)
+#define TTYDEV         "/dev/pty/ttyxx"
+#elif defined(__MVS__)
+#define TTYDEV         "/dev/ptypxxxx"
+#elif defined(USE_PTS_DEVICE)
+#define TTYDEV         "/dev/pts/0"
+#else
+#define        TTYDEV          "/dev/ttyxx"
+#endif
+#endif /* !TTYDEV */
+
+#ifndef PTYCHAR1
+#ifdef __hpux
+#define PTYCHAR1       "zyxwvutsrqp"
+#else  /* !__hpux */
+#ifdef __UNIXOS2__
+#define PTYCHAR1       "pq"
+#else
+#define        PTYCHAR1        "pqrstuvwxyzPQRSTUVWXYZ"
+#endif  /* !__UNIXOS2__ */
+#endif /* !__hpux */
+#endif /* !PTYCHAR1 */
+
+#ifndef PTYCHAR2
+#ifdef __hpux
+#define        PTYCHAR2        "fedcba9876543210"
+#else  /* !__hpux */
+#if defined(__DragonFly__) || defined(__FreeBSD__)
+#define        PTYCHAR2        "0123456789abcdefghijklmnopqrstuv"
+#else /* !__FreeBSD__ */
+#define        PTYCHAR2        "0123456789abcdef"
+#endif /* !__FreeBSD__ */
+#endif /* !__hpux */
+#endif /* !PTYCHAR2 */
+
+#ifndef TTYFORMAT
+#if defined(CRAY)
+#define TTYFORMAT "/dev/ttyp%03d"
+#elif defined(__MVS__)
+#define TTYFORMAT "/dev/ttyp%04d"
+#else
+#define TTYFORMAT "/dev/ttyp%d"
+#endif
+#endif /* TTYFORMAT */
+
+#ifndef PTYFORMAT
+#ifdef CRAY
+#define PTYFORMAT "/dev/pty/%03d"
+#elif defined(__MVS__)
+#define PTYFORMAT "/dev/ptyp%04d"
+#else
+#define PTYFORMAT "/dev/ptyp%d"
+#endif
+#endif /* PTYFORMAT */
+
+#ifndef PTYCHARLEN
+#ifdef CRAY
+#define PTYCHARLEN 3
+#elif defined(__MVS__)
+#define PTYCHARLEN 8     /* OS/390 stores, e.g. ut_id="ttyp1234"  */
+#else
+#define PTYCHARLEN 2
+#endif
+#endif
+
+#ifndef MAXPTTYS
+#ifdef CRAY
+#define MAXPTTYS 256
+#else
+#define MAXPTTYS 2048
+#endif
+#endif
+
+/* Until the translation manager comes along, I have to do my own translation of
+ * mouse events into the proper routines. */
+
+typedef enum {
+    NORMAL = 0
+    , LEFTEXTENSION
+    , RIGHTEXTENSION
+} EventMode;
+
+/*
+ * The origin of a screen is 0, 0.  Therefore, the number of rows
+ * on a screen is screen->max_row + 1, and similarly for columns.
+ */
+#define MaxCols(screen)                ((screen)->max_col + 1)
+#define MaxRows(screen)                ((screen)->max_row + 1)
+
+typedef unsigned char Char;            /* to support 8 bit chars */
+typedef Char *ScrnPtr;
+typedef ScrnPtr *ScrnBuf;
+
+/*
+ * Declare an X String, but for unsigned chars.
+ */
+#ifdef _CONST_X_STRING
+typedef const Char *UString;
+#else
+typedef Char *UString;
+#endif
+
+#define IsEmpty(s) ((s) == 0 || *(s) == '\0')
+
+#define CharOf(n) ((unsigned char)(n))
+
+typedef struct {
+    int row;
+    int col;
+} CELL;
+
+#define isSameRow(a,b)         ((a)->row == (b)->row)
+#define isSameCol(a,b)         ((a)->col == (b)->col)
+#define isSameCELL(a,b)                (isSameRow(a,b) && isSameCol(a,b))
+
+#define xBIT(n)         (1 << (n))
+
+/*
+ * ANSI emulation, special character codes
+ */
+#define ANSI_EOT       0x04
+#define ANSI_BEL       0x07
+#define ANSI_BS                0x08
+#define ANSI_HT                0x09
+#define ANSI_LF                0x0A
+#define ANSI_VT                0x0B
+#define        ANSI_FF         0x0C            /* C0, C1 control names         */
+#define ANSI_CR                0x0D
+#define ANSI_SO                0x0E
+#define ANSI_SI                0x0F
+#define        ANSI_XON        0x11            /* DC1 */
+#define        ANSI_XOFF       0x13            /* DC3 */
+#define        ANSI_NAK        0x15
+#define        ANSI_CAN        0x18
+#define        ANSI_ESC        0x1B
+#define        ANSI_SPA        0x20
+#define XTERM_POUND    0x1E            /* internal mapping for '#'     */
+#define        ANSI_DEL        0x7F
+#define        ANSI_SS2        0x8E
+#define        ANSI_SS3        0x8F
+#define        ANSI_DCS        0x90
+#define        ANSI_SOS        0x98
+#define        ANSI_CSI        0x9B
+#define        ANSI_ST         0x9C
+#define        ANSI_OSC        0x9D
+#define        ANSI_PM         0x9E
+#define        ANSI_APC        0x9F
+
+#define MIN_DECID  52                  /* can emulate VT52 */
+#define MAX_DECID 420                  /* ...through VT420 */
+
+#ifndef DFT_DECID
+#define DFT_DECID "vt100"              /* default VT100 */
+#endif
+
+#ifndef DFT_KBD_DIALECT
+#define DFT_KBD_DIALECT "B"            /* default USASCII */
+#endif
+
+/* constants used for utf8 mode */
+#define UCS_REPL       0xfffd
+#define UCS_LIMIT      0x80000000U     /* both limit and flag for non-UCS */
+
+#define TERMCAP_SIZE 1500              /* 1023 is standard; 'screen' exceeds */
+
+#define NMENUFONTS 9                   /* font entries in fontMenu */
+
+#define        NBOX    5                       /* Number of Points in box      */
+#define        NPARAM  30                      /* Max. parameters              */
+
+typedef struct {
+       String opt;
+       String desc;
+} OptionHelp;
+
+typedef short ParmType;
+
+typedef struct {
+       Char            a_type;         /* CSI, etc., see unparseq()    */
+       Char            a_pintro;       /* private-mode char, if any    */
+       Char            a_inters;       /* special (before final-char)  */
+       Char            a_final;        /* final-char                   */
+       ParmType        a_nparam;       /* # of parameters              */
+       ParmType        a_param[NPARAM]; /* Parameters                  */
+} ANSI;
+
+#define TEK_FONT_LARGE 0
+#define TEK_FONT_2 1
+#define TEK_FONT_3 2
+#define TEK_FONT_SMALL 3
+#define        TEKNUMFONTS 4
+
+/* Actually there are 5 types of lines, but four are non-solid lines */
+#define        TEKNUMLINES     4
+
+typedef struct {
+       int     x;
+       int     y;
+       int     fontsize;
+       unsigned linetype;
+} Tmodes;
+
+typedef struct {
+       int Twidth;
+       int Theight;
+} T_fontsize;
+
+typedef struct {
+       short *bits;
+       int x;
+       int y;
+       int width;
+       int height;
+} BitmapBits;
+
+#define        SAVELINES               64      /* default # lines to save      */
+#define SCROLLLINES 1                  /* default # lines to scroll    */
+
+#define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp
+
+/***====================================================================***/
+
+#if (XtSpecificationRelease < 6)
+#ifndef NO_ACTIVE_ICON
+#define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */
+#endif
+#endif
+
+#ifndef OPT_AIX_COLORS
+#define OPT_AIX_COLORS  1 /* true if xterm is configured with AIX (16) colors */
+#endif
+
+#ifndef OPT_ALLOW_XXX_OPS
+#define OPT_ALLOW_XXX_OPS 1 /* true if xterm adds "Allow XXX Ops" submenu */
+#endif
+
+#ifndef OPT_BLINK_CURS
+#define OPT_BLINK_CURS  1 /* true if xterm has blinking cursor capability */
+#endif
+
+#ifndef OPT_BLINK_TEXT
+#define OPT_BLINK_TEXT  OPT_BLINK_CURS /* true if xterm has blinking text capability */
+#endif
+
+#ifndef OPT_BOX_CHARS
+#define OPT_BOX_CHARS  1 /* true if xterm can simulate box-characters */
+#endif
+
+#ifndef OPT_BROKEN_OSC
+#ifdef linux
+#define OPT_BROKEN_OSC 1 /* man console_codes, 1st paragraph - cf: ECMA-48 */
+#else
+#define OPT_BROKEN_OSC 0 /* true if xterm allows Linux's broken OSC parsing */
+#endif
+#endif
+
+#ifndef OPT_BROKEN_ST
+#define OPT_BROKEN_ST  1 /* true if xterm allows old/broken OSC parsing */
+#endif
+
+#ifndef OPT_C1_PRINT
+#define OPT_C1_PRINT   1 /* true if xterm allows C1 controls to be printable */
+#endif
+
+#ifndef OPT_CLIP_BOLD
+#define OPT_CLIP_BOLD  1 /* true if xterm uses clipping to avoid bold-trash */
+#endif
+
+#ifndef OPT_COLOR_CLASS
+#define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */
+#endif
+
+#ifndef OPT_COLOR_RES
+#define OPT_COLOR_RES   1 /* true if xterm delays color-resource evaluation */
+#endif
+
+#ifndef OPT_DABBREV
+#define OPT_DABBREV 0  /* dynamic abbreviations */
+#endif
+
+#ifndef OPT_DEC_CHRSET
+#define OPT_DEC_CHRSET  1 /* true if xterm is configured for DEC charset */
+#endif
+
+#ifndef OPT_DEC_LOCATOR
+#define        OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */
+#endif
+
+#ifndef OPT_DEC_RECTOPS
+#define OPT_DEC_RECTOPS 0 /* true if xterm is configured for VT420 rectangles */
+#endif
+
+#ifndef OPT_DEC_SOFTFONT
+#define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */
+#endif
+
+#ifndef OPT_EBCDIC
+#ifdef __MVS__
+#define OPT_EBCDIC 1
+#else
+#define OPT_EBCDIC 0
+#endif
+#endif
+
+#ifndef OPT_EXEC_XTERM
+#define OPT_EXEC_XTERM 0 /* true if xterm can fork/exec copies of itself */
+#endif
+
+#ifndef OPT_EXTRA_PASTE
+#define OPT_EXTRA_PASTE 1
+#endif
+
+#ifndef OPT_FIFO_LINES
+#define OPT_FIFO_LINES 0 /* optimize save-lines feature using FIFO */
+#endif
+
+#ifndef OPT_FOCUS_EVENT
+#define OPT_FOCUS_EVENT        1 /* focus in/out events */
+#endif
+
+#ifndef OPT_HP_FUNC_KEYS
+#define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */
+#endif
+
+#ifndef OPT_I18N_SUPPORT
+#if (XtSpecificationRelease >= 5)
+#define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */
+#else
+#define OPT_I18N_SUPPORT 0
+#endif
+#endif
+
+#ifndef OPT_INITIAL_ERASE
+#define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */
+#endif
+
+#ifndef OPT_INPUT_METHOD
+#if (XtSpecificationRelease >= 6)
+#define OPT_INPUT_METHOD 1 /* true if xterm uses input-method support */
+#else
+#define OPT_INPUT_METHOD 0
+#endif
+#endif
+
+#ifndef OPT_ISO_COLORS
+#define OPT_ISO_COLORS  1 /* true if xterm is configured with ISO colors */
+#endif
+
+#ifndef OPT_256_COLORS
+#define OPT_256_COLORS  0 /* true if xterm is configured with 256 colors */
+#endif
+
+#ifndef OPT_88_COLORS
+#define OPT_88_COLORS  0 /* true if xterm is configured with 88 colors */
+#endif
+
+#ifndef OPT_HIGHLIGHT_COLOR
+#define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */
+#endif
+
+#ifndef OPT_LOAD_VTFONTS
+#define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */
+#endif
+
+#ifndef OPT_LUIT_PROG
+#define OPT_LUIT_PROG   0 /* true if xterm supports luit */
+#endif
+
+#ifndef OPT_MAXIMIZE
+#define OPT_MAXIMIZE   1 /* add actions for iconify ... maximize */
+#endif
+
+#ifndef OPT_MINI_LUIT
+#define OPT_MINI_LUIT   0 /* true if xterm supports built-in mini-luit */
+#endif
+
+#ifndef OPT_MOD_FKEYS
+#define OPT_MOD_FKEYS  1 /* modify cursor- and function-keys in normal mode */
+#endif
+
+#ifndef OPT_NUM_LOCK
+#define OPT_NUM_LOCK   1 /* use NumLock key only for numeric-keypad */
+#endif
+
+#ifndef OPT_PASTE64
+#define OPT_PASTE64    0 /* program control of select/paste via base64 */
+#endif
+
+#ifndef OPT_PC_COLORS
+#define OPT_PC_COLORS   1 /* true if xterm supports PC-style (bold) colors */
+#endif
+
+#ifndef OPT_PTY_HANDSHAKE
+#define OPT_PTY_HANDSHAKE USE_HANDSHAKE        /* avoid pty races on older systems */
+#endif
+
+#ifndef OPT_PRINT_COLORS
+#define OPT_PRINT_COLORS 1 /* true if we print color information */
+#endif
+
+#ifndef OPT_READLINE
+#define OPT_READLINE   0 /* mouse-click/paste support for readline */
+#endif
+
+#ifndef OPT_RENDERFONT
+#ifdef XRENDERFONT
+#define OPT_RENDERFONT 1
+#else
+#define OPT_RENDERFONT 0
+#endif
+#endif
+
+#ifndef OPT_RENDERWIDE
+#if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC)
+#define OPT_RENDERWIDE 1
+#else
+#define OPT_RENDERWIDE 0
+#endif
+#endif
+
+#ifndef OPT_SAME_NAME
+#define OPT_SAME_NAME   1 /* suppress redundant updates of title, icon, etc. */
+#endif
+
+#ifndef OPT_SAVE_LINES
+#define OPT_SAVE_LINES OPT_FIFO_LINES /* optimize save-lines feature */
+#endif
+
+#ifndef OPT_SCO_FUNC_KEYS
+#define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */
+#endif
+
+#ifndef OPT_SUN_FUNC_KEYS
+#define OPT_SUN_FUNC_KEYS 1 /* true if xterm supports Sun-style function keys */
+#endif
+
+#ifndef OPT_SCROLL_LOCK
+#define OPT_SCROLL_LOCK 1 /* true if xterm interprets fontsize-shifting */
+#endif
+
+#ifndef OPT_SELECT_REGEX
+#define OPT_SELECT_REGEX 0 /* true if xterm supports regular-expression selects */
+#endif
+
+#ifndef OPT_SESSION_MGT
+#if defined(XtNdieCallback) && defined(XtNsaveCallback)
+#define OPT_SESSION_MGT 1
+#else
+#define OPT_SESSION_MGT 0
+#endif
+#endif
+
+#ifndef OPT_SHIFT_FONTS
+#define OPT_SHIFT_FONTS 1 /* true if xterm interprets fontsize-shifting */
+#endif
+
+#ifndef OPT_SUNPC_KBD
+#define OPT_SUNPC_KBD  1 /* true if xterm supports Sun/PC keyboard map */
+#endif
+
+#ifndef OPT_TCAP_FKEYS
+#define OPT_TCAP_FKEYS 0 /* true for experimental termcap function-keys */
+#endif
+
+#ifndef OPT_TCAP_QUERY
+#define OPT_TCAP_QUERY 0 /* true for experimental termcap query */
+#endif
+
+#ifndef OPT_TEK4014
+#define OPT_TEK4014     1 /* true if we're using tek4014 emulation */
+#endif
+
+#ifndef OPT_TOOLBAR
+#define OPT_TOOLBAR    0 /* true if xterm supports toolbar menus */
+#endif
+
+#ifndef OPT_TRACE
+#define OPT_TRACE       0 /* true if we're using debugging traces */
+#endif
+
+#ifndef OPT_TRACE_FLAGS
+#define OPT_TRACE_FLAGS 0 /* additional tracing used for SCRN_BUF_FLAGS */
+#endif
+
+#ifndef OPT_VT52_MODE
+#define OPT_VT52_MODE   1 /* true if xterm supports VT52 emulation */
+#endif
+
+#ifndef OPT_WIDE_CHARS
+#define OPT_WIDE_CHARS  0 /* true if xterm supports 16-bit characters */
+#endif
+
+#ifndef OPT_WIDER_ICHAR
+#define OPT_WIDER_ICHAR 1 /* true if xterm uses 32-bits for wide-chars */
+#endif
+
+#ifndef OPT_XMC_GLITCH
+#define OPT_XMC_GLITCH 0 /* true if xterm supports xmc (magic cookie glitch) */
+#endif
+
+#ifndef OPT_ZICONBEEP
+#define OPT_ZICONBEEP   1 /* true if xterm supports "-ziconbeep" option */
+#endif
+
+/***====================================================================***/
+
+#if OPT_AIX_COLORS && !OPT_ISO_COLORS
+/* You must have ANSI/ISO colors to support AIX colors */
+#undef  OPT_AIX_COLORS
+#define OPT_AIX_COLORS 0
+#endif
+
+#if OPT_COLOR_RES && !OPT_ISO_COLORS
+/* You must have ANSI/ISO colors to support ColorRes logic */
+#undef  OPT_COLOR_RES
+#define OPT_COLOR_RES 0
+#endif
+
+#if OPT_256_COLORS && (OPT_WIDE_CHARS || OPT_RENDERFONT || OPT_XMC_GLITCH)
+/* It's actually more complicated than that - but by trimming options you can
+ * have 256 color resources though.
+ */
+#define OPT_COLOR_RES2 1
+#else
+#define OPT_COLOR_RES2 0
+#endif
+
+#if OPT_PASTE64 && !OPT_READLINE
+/* OPT_PASTE64 uses logic from OPT_READLINE */
+#undef  OPT_READLINE
+#define OPT_READLINE 1
+#endif
+
+#if OPT_PC_COLORS && !OPT_ISO_COLORS
+/* You must have ANSI/ISO colors to support PC colors */
+#undef  OPT_PC_COLORS
+#define OPT_PC_COLORS 0
+#endif
+
+#if OPT_PRINT_COLORS && !OPT_ISO_COLORS
+/* You must have ANSI/ISO colors to be able to print them */
+#undef  OPT_PRINT_COLORS
+#define OPT_PRINT_COLORS 0
+#endif
+
+#if OPT_256_COLORS && !OPT_ISO_COLORS
+/* You must have ANSI/ISO colors to support 256 colors */
+#undef  OPT_256_COLORS
+#define OPT_256_COLORS 0
+#endif
+
+#if OPT_88_COLORS && !OPT_ISO_COLORS
+/* You must have ANSI/ISO colors to support 88 colors */
+#undef  OPT_88_COLORS
+#define OPT_88_COLORS 0
+#endif
+
+#if OPT_88_COLORS && OPT_256_COLORS
+/* 256 colors supersedes 88 colors */
+#undef  OPT_88_COLORS
+#define OPT_88_COLORS 0
+#endif
+
+/***====================================================================***/
+
+/*
+ * Indices for menu_font_names[][]
+ */
+typedef enum {
+    fNorm = 0                  /* normal font */
+    , fBold                    /* bold font */
+#if OPT_WIDE_CHARS
+    , fWide                    /* double-width font */
+    , fWBold                   /* double-width bold font */
+#endif
+    , fMAX
+} VTFontEnum;
+
+/*
+ * Indices for cachedGCs.c (unrelated to VTFontEnum).
+ */
+typedef enum {
+    gcNorm = 0
+    , gcBold
+    , gcNormReverse
+    , gcBoldReverse
+#if OPT_BOX_CHARS
+    , gcLine
+    , gcDots
+#endif
+#if OPT_DEC_CHRSET
+    , gcCNorm
+    , gcCBold
+#endif
+#if OPT_WIDE_CHARS
+    , gcWide
+    , gcWBold
+    , gcWideReverse
+    , gcWBoldReverse
+#endif
+    , gcVTcursNormal
+    , gcVTcursFilled
+    , gcVTcursReverse
+    , gcVTcursOutline
+#if OPT_TEK4014
+    , gcTKcurs
+#endif
+    , gcMAX
+} CgsEnum;
+
+#define for_each_text_gc(n) for (n = gcNorm; n < gcVTcursNormal; ++n)
+#define for_each_curs_gc(n) for (n = gcVTcursNormal; n <= gcVTcursOutline; ++n)
+#define for_each_gc(n)      for (n = gcNorm; n < gcMAX; ++n)
+
+/*
+ * Indices for the normal terminal colors in screen.Tcolors[].
+ * See also OscTextColors, which has corresponding values.
+ */
+typedef enum {
+    TEXT_FG = 0                        /* text foreground */
+    , TEXT_BG                  /* text background */
+    , TEXT_CURSOR              /* text cursor */
+    , MOUSE_FG                 /* mouse foreground */
+    , MOUSE_BG                 /* mouse background */
+#if OPT_TEK4014
+    , TEK_FG                   /* tektronix foreground */
+    , TEK_BG                   /* tektronix background */
+    , TEK_CURSOR               /* tektronix cursor */
+#endif
+#if OPT_HIGHLIGHT_COLOR
+    , HIGHLIGHT_BG             /* highlight background */
+    , HIGHLIGHT_FG             /* highlight foreground */
+#endif
+    , NCOLORS                  /* total number of colors */
+} TermColors;
+
+/*
+ * Constants for titleModes resource
+ */
+typedef enum {
+    tmSetBase16 = 1            /* set title using hex-string */
+    , tmGetBase16 = 2          /* get title using hex-string */
+#if OPT_WIDE_CHARS
+    , tmSetUtf8 = 4            /* like utf8Title, but controllable */
+    , tmGetUtf8 = 8            /* retrieve title encoded as UTF-8 */
+#endif
+} TitleModes;
+
+#define IsTitleMode(xw,mode) (((xw)->screen.title_modes & mode) != 0)
+
+/* indices for mapping multiple clicks to selection types */
+typedef enum {
+    Select_CHAR=0
+    ,Select_WORD
+    ,Select_LINE
+    ,Select_GROUP
+    ,Select_PAGE
+    ,Select_ALL
+#if OPT_SELECT_REGEX
+    ,Select_REGEX
+#endif
+    ,NSELECTUNITS
+} SelectUnit;
+
+typedef enum {
+    ecSetColor = 1
+    , ecGetColor
+    , ecGetAnsiColor
+    , ecLAST
+} ColorOps;
+
+typedef enum {
+    efSetFont = 1
+    , efGetFont
+    , efLAST
+} FontOps;
+
+typedef enum {
+    etSetTcap = 1
+    , etGetTcap
+    , etLAST
+} TcapOps;
+
+typedef enum {
+    /* 1-21 are chosen to be the same as the control-sequence coding */
+    ewRestoreWin = 1
+    , ewMinimizeWin = 2
+    , ewSetWinPosition = 3
+    , ewSetWinSizePixels = 4
+    , ewRaiseWin = 5
+    , ewLowerWin = 6
+    , ewRefreshWin = 7
+    , ewSetWinSizeChars = 8
+#if OPT_MAXIMIZE
+    , ewMaximizeWin = 9
+#endif
+    , ewGetWinState = 11
+    , ewGetWinPosition = 13
+    , ewGetWinSizePixels = 14
+    , ewGetWinSizeChars = 18
+#if OPT_MAXIMIZE
+    , ewGetScreenSizeChars = 19
+#endif
+    , ewGetIconTitle = 20
+    , ewGetWinTitle = 21
+    , ewPushTitle = 22
+    , ewPopTitle = 23
+    /* these do not fit into that scheme, which is why we use an array */
+    , ewSetWinLines
+    , ewSetXprop
+    , ewGetSelection
+    , ewSetSelection
+    /* get the size of the array... */
+    , ewLAST
+} WindowOps;
+
+#define        COLOR_DEFINED(s,w)      ((s)->which & (unsigned) (1<<(w)))
+#define        COLOR_VALUE(s,w)        ((s)->colors[w])
+#define        SET_COLOR_VALUE(s,w,v)  (((s)->colors[w] = (v)), UIntSet((s)->which, (1<<(w))))
+
+#define        COLOR_NAME(s,w)         ((s)->names[w])
+#define        SET_COLOR_NAME(s,w,v)   (((s)->names[w] = (v)), ((s)->which |= (unsigned) (1<<(w))))
+
+#define        UNDEFINE_COLOR(s,w)     ((s)->which &= (~((w)<<1)))
+
+/***====================================================================***/
+
+#if OPT_ISO_COLORS
+#define TERM_COLOR_FLAGS(xw)   ((xw)->flags & (FG_COLOR|BG_COLOR))
+#define COLOR_0                0
+#define COLOR_1                1
+#define COLOR_2                2
+#define COLOR_3                3
+#define COLOR_4                4
+#define COLOR_5                5
+#define COLOR_6                6
+#define COLOR_7                7
+#define COLOR_8                8
+#define COLOR_9                9
+#define COLOR_10       10
+#define COLOR_11       11
+#define COLOR_12       12
+#define COLOR_13       13
+#define COLOR_14       14
+#define COLOR_15       15
+#define MIN_ANSI_COLORS 16
+
+#if OPT_256_COLORS
+# define NUM_ANSI_COLORS 256
+#elif OPT_88_COLORS
+# define NUM_ANSI_COLORS 88
+#else
+# define NUM_ANSI_COLORS MIN_ANSI_COLORS
+#endif
+
+#if NUM_ANSI_COLORS > MIN_ANSI_COLORS
+# define OPT_EXT_COLORS  1
+#else
+# define OPT_EXT_COLORS  0
+#endif
+
+#define COLOR_BD       (NUM_ANSI_COLORS)       /* BOLD */
+#define COLOR_UL       (NUM_ANSI_COLORS+1)     /* UNDERLINE */
+#define COLOR_BL       (NUM_ANSI_COLORS+2)     /* BLINK */
+#define COLOR_RV       (NUM_ANSI_COLORS+3)     /* REVERSE */
+#define MAXCOLORS      (NUM_ANSI_COLORS+4)
+#ifndef DFT_COLORMODE
+#define DFT_COLORMODE True     /* default colorMode resource */
+#endif
+
+#define ReverseOrHilite(screen,flags,hilite) \
+               (( screen->colorRVMode && hilite ) || \
+                   ( !screen->colorRVMode && \
+                     (( (flags & INVERSE) && !hilite) || \
+                      (!(flags & INVERSE) &&  hilite)) ))
+
+/* Define a fake XK code, we need it for the fake color response in
+ * xtermcapKeycode(). */
+#if OPT_TCAP_QUERY && OPT_ISO_COLORS
+# define XK_COLORS 0x0003
+#endif
+
+#else  /* !OPT_ISO_COLORS */
+
+#define TERM_COLOR_FLAGS(xw) 0
+
+#define ReverseOrHilite(screen,flags,hilite) \
+                     (( (flags & INVERSE) && !hilite) || \
+                      (!(flags & INVERSE) &&  hilite))
+
+#endif /* OPT_ISO_COLORS */
+
+# define XK_TCAPNAME 0x0004
+
+#if OPT_AIX_COLORS
+#define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code
+#else
+#define if_OPT_AIX_COLORS(screen, code) /* nothing */
+#endif
+
+#if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS
+# define if_OPT_ISO_COLORS(screen, code) if (screen->colorMode) code
+#else
+# define if_OPT_ISO_COLORS(screen, code) /* nothing */
+#endif
+
+#define COLOR_RES_NAME(root) "color" root
+
+#if OPT_COLOR_CLASS
+#define COLOR_RES_CLASS(root) "Color" root
+#else
+#define COLOR_RES_CLASS(root) XtCForeground
+#endif
+
+#if OPT_COLOR_RES
+#define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value)
+#define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value)
+#else
+#define COLOR_RES(root,offset,value) Cres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset, value)
+#define COLOR_RES2(name,class,offset,value) Cres(name, class, offset, value)
+#endif
+
+#define CLICK_RES_NAME(count)  "on" count "Clicks"
+#define CLICK_RES_CLASS(count) "On" count "Clicks"
+#define CLICK_RES(count,offset,value) Sres(CLICK_RES_NAME(count), CLICK_RES_CLASS(count), offset, value)
+
+/***====================================================================***/
+
+#if OPT_DEC_CHRSET
+#define if_OPT_DEC_CHRSET(code) code
+       /* Use 2 bits for encoding the double high/wide sense of characters */
+#define CSET_SWL        0
+#define CSET_DHL_TOP    1
+#define CSET_DHL_BOT    2
+#define CSET_DWL        3
+#define NUM_CHRSET      8      /* normal/bold and 4 CSET_xxx values */
+
+       /* Use remaining bits for encoding the other character-sets */
+#define CSET_NORMAL(code)  ((code) == CSET_SWL)
+#define CSET_DOUBLE(code)  (!CSET_NORMAL(code) && !CSET_EXTEND(code))
+#define CSET_EXTEND(code)  ((int)(code) > CSET_DWL)
+
+#define DBLCS_BITS            4
+#define DBLCS_MASK            BITS2MASK(DBLCS_BITS)
+
+#define GetLineDblCS(ld)      (((ld)->bufHead >> LINEFLAG_BITS) & DBLCS_MASK)
+#define SetLineDblCS(ld,cs)   (ld)->bufHead = (RowData) ((ld->bufHead & LINEFLAG_MASK) | (cs << LINEFLAG_BITS))
+
+#define LineCharSet(screen, ld) \
+       ((CSET_DOUBLE(GetLineDblCS(ld))) \
+               ? GetLineDblCS(ld) \
+               : (screen)->cur_chrset)
+#define LineMaxCol(screen, ld) \
+       (CSET_DOUBLE(GetLineDblCS(ld)) \
+        ? (screen->max_col / 2) \
+        : (screen->max_col))
+#define LineCursorX(screen, ld, col) \
+       (CSET_DOUBLE(GetLineDblCS(ld)) \
+        ? CursorX(screen, 2*(col)) \
+        : CursorX(screen, (col)))
+#define LineFontWidth(screen, ld) \
+       (CSET_DOUBLE(GetLineDblCS(ld)) \
+        ? 2*FontWidth(screen) \
+        : FontWidth(screen))
+#else
+
+#define if_OPT_DEC_CHRSET(code) /*nothing*/
+
+#define GetLineDblCS(ld)       0
+
+#define LineCharSet(screen, ld)         0
+#define LineMaxCol(screen, ld)          screen->max_col
+#define LineCursorX(screen, ld, col)    CursorX(screen, col)
+#define LineFontWidth(screen, ld)       FontWidth(screen)
+
+#endif
+
+#if OPT_LUIT_PROG && !OPT_WIDE_CHARS
+#error Luit requires the wide-chars configuration
+#endif
+
+/***====================================================================***/
+
+#if OPT_EBCDIC
+extern int E2A(int);
+extern int A2E(int);
+#else
+#define E2A(a) (a)
+#define A2E(a) (a)
+#endif
+
+#define CONTROL(a) (A2E(E2A(a)&037))
+
+/***====================================================================***/
+
+#if OPT_TEK4014
+#define TEK4014_ACTIVE(xw)      ((xw)->misc.TekEmu)
+#define TEK4014_SHOWN(xw)       ((xw)->misc.Tshow)
+#define CURRENT_EMU_VAL(tek,vt) (TEK4014_ACTIVE(term) ? tek : vt)
+#define CURRENT_EMU()           CURRENT_EMU_VAL((Widget)tekWidget, (Widget)term)
+#else
+#define TEK4014_ACTIVE(screen)  0
+#define TEK4014_SHOWN(xw)       0
+#define CURRENT_EMU_VAL(tek,vt) (vt)
+#define CURRENT_EMU()           ((Widget)term)
+#endif
+
+/***====================================================================***/
+
+#if OPT_TOOLBAR
+#define SHELL_OF(widget) XtParent(XtParent(widget))
+#else
+#define SHELL_OF(widget) XtParent(widget)
+#endif
+
+/***====================================================================***/
+
+#if OPT_VT52_MODE
+#define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code
+#else
+#define if_OPT_VT52_MODE(screen, code) /* nothing */
+#endif
+
+/***====================================================================***/
+
+#if OPT_XMC_GLITCH
+#define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code
+#define XMC_GLITCH 1   /* the character we'll show */
+#define XMC_FLAGS (INVERSE|UNDERLINE|BOLD|BLINK)
+#else
+#define if_OPT_XMC_GLITCH(screen, code) /* nothing */
+#endif
+
+/***====================================================================***/
+
+#define LO_BYTE(ch) CharOf((ch) & 0xff)
+#define HI_BYTE(ch) CharOf((ch) >> 8)
+
+#if OPT_WIDE_CHARS
+#define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code
+#define if_WIDE_OR_NARROW(screen, wide, narrow) if(screen->wide_chars) wide else narrow
+#if OPT_WIDER_ICHAR
+typedef unsigned IChar;                /* for 8-21 bit characters */
+#else
+typedef unsigned short IChar;  /* for 8-16 bit characters */
+#endif
+#else
+#define if_OPT_WIDE_CHARS(screen, code) /* nothing */
+#define if_WIDE_OR_NARROW(screen, wide, narrow) narrow
+typedef unsigned char IChar;   /* for 8-bit characters */
+#endif
+
+/***====================================================================***/
+
+#ifndef RES_OFFSET
+#define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset)
+#endif
+
+#define RES_NAME(name) name
+#define RES_CLASS(name) name
+
+#define Bres(name, class, offset, dftvalue) \
+       {RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \
+        RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
+
+#define Cres(name, class, offset, dftvalue) \
+       {RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \
+        RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
+
+#define Tres(name, class, offset, dftvalue) \
+       COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \
+
+#define Fres(name, class, offset, dftvalue) \
+       {RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \
+        RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
+
+#define Ires(name, class, offset, dftvalue) \
+       {RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
+        RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}
+
+#define Dres(name, class, offset, dftvalue) \
+       {RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \
+        RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
+
+#define Sres(name, class, offset, dftvalue) \
+       {RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
+        RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
+
+#define Wres(name, class, offset, dftvalue) \
+       {RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \
+        RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue}
+
+/***====================================================================***/
+
+#define FRG_SIZE resource.minBufSize
+#define BUF_SIZE resource.maxBufSize
+
+typedef struct {
+       Char *  next;
+       Char *  last;
+       int     update;         /* HandleInterpret */
+#if OPT_WIDE_CHARS
+       IChar   utf_data;       /* resulting character */
+       int     utf_size;       /* ...number of bytes decoded */
+       Char    *write_buf;
+       unsigned write_len;
+#endif
+       Char    buffer[1];
+} PtyData;
+
+/***====================================================================***/
+
+#if OPT_ISO_COLORS
+#if OPT_256_COLORS || OPT_88_COLORS
+#define COLOR_BITS 8
+typedef unsigned short CellColor;
+#else
+#define COLOR_BITS 4
+typedef Char CellColor;
+#endif
+#else
+typedef int CellColor;
+#endif
+
+#define BITS2MASK(b)          ((1 << b) - 1)
+
+#define COLOR_MASK            BITS2MASK(COLOR_BITS)
+
+#define GetCellColorFG(src)   ((src) & COLOR_MASK)
+#define GetCellColorBG(src)   (((src) >> COLOR_BITS) & COLOR_MASK)
+
+typedef Char RowData;          /* wrap/blink, and DEC single-double chars */
+
+#define LINEFLAG_BITS         4
+#define LINEFLAG_MASK         BITS2MASK(LINEFLAG_BITS)
+
+#define GetLineFlags(ld)      ((ld)->bufHead & LINEFLAG_MASK)
+
+#if OPT_DEC_CHRSET
+#define SetLineFlags(ld,xx)   (ld)->bufHead = (RowData) ((ld->bufHead & (DBLCS_MASK << LINEFLAG_BITS)) | (xx & LINEFLAG_MASK))
+#else
+#define SetLineFlags(ld,xx)   (ld)->bufHead = (RowData) (xx & LINEFLAG_MASK)
+#endif
+
+typedef IChar CharData;
+
+/*
+ * This is the xterm line-data/scrollback structure.
+ */
+typedef struct {
+       Dimension lineSize;     /* number of columns in this row */
+       RowData bufHead;        /* flag for wrapped lines */
+#if OPT_WIDE_CHARS
+       Char combSize;          /* number of items in combData[] */
+#endif
+       Char *attribs;          /* video attributes */
+#if OPT_ISO_COLORS
+       CellColor *color;       /* foreground+background color numbers */
+#endif
+       CharData *charData;     /* cell's base character */
+       CharData *combData[1];  /* first enum past fixed-offsets */
+} LineData;
+
+/*
+ * We use CellData in a few places, when copying a cell's data to a temporary
+ * variable.
+ */
+typedef struct {
+       Char attribs;
+#if OPT_WIDE_CHARS
+       Char combSize;          /* number of items in combData[] */
+#endif
+#if OPT_ISO_COLORS
+       CellColor color;        /* color-array */
+#endif
+       CharData charData;      /* cell's base character */
+       CharData combData[1];   /* array of combining chars */
+} CellData;
+
+#define for_each_combData(off, ld) for (off = 0; off < ld->combSize; ++off)
+
+/*
+ * Accommodate older compilers by not using variable-length arrays.
+ */
+#define SizeOfLineData  offsetof(LineData, combData)
+#define SizeOfCellData  offsetof(CellData, combData)
+
+       /*
+        * A "row" is the index within the visible part of the screen, and an
+        * "inx" is the index within the whole set of scrollable lines.
+        */
+#define ROW2INX(screen, row)   ((row) + (screen)->topline)
+#define INX2ROW(screen, inx)   ((inx) - (screen)->topline)
+
+#define ROW2ABS(screen, row)   ((row) + (screen)->savedlines)
+#define INX2ABS(screen, inx)   ROW2ABS(screen, INX2ROW(screen, inx))
+
+#define okScrnRow(screen, row) \
+       ((row) <= ((screen)->max_row - (screen)->topline) \
+      && (row) >= -((screen)->savedlines))
+
+       /*
+        * Cache data for "proportional" and other fonts containing a mixture
+        * of widths.
+        */
+typedef struct {
+       Bool            mixed;
+       Dimension       min_width;      /* nominal cell width for 0..255 */
+       Dimension       max_width;      /* maximum cell width */
+} FontMap;
+
+typedef struct {
+       unsigned        chrset;
+       unsigned        flags;
+       XFontStruct *   fs;
+       char *          fn;
+       FontMap         map;
+       Char            known_missing[256];
+} XTermFonts;
+
+#if OPT_RENDERFONT
+typedef enum {
+       erFalse = 0
+       , erTrue
+       , erDefault
+       , erLast
+} RenderFont;
+
+#define DefaultRenderFont(xw) \
+       if ((xw)->misc.render_font == erDefault) \
+           (xw)->misc.render_font = erFalse
+
+typedef struct {
+       XftFont *       font;
+       FontMap         map;
+} XTermXftFonts;
+#endif
+
+typedef struct {
+       int             top;
+       int             left;
+       int             bottom;
+       int             right;
+} XTermRect;
+
+       /* indices into save_modes[] */
+typedef enum {
+       DP_CRS_VISIBLE,
+       DP_DECANM,
+       DP_DECARM,
+       DP_DECAWM,
+       DP_DECBKM,
+       DP_DECCKM,
+       DP_DECCOLM,     /* IN132COLUMNS */
+       DP_DECOM,
+       DP_DECPEX,
+       DP_DECPFF,
+       DP_DECSCLM,
+       DP_DECSCNM,
+       DP_DECTCEM,
+       DP_DECTEK,
+       DP_PRN_EXTENT,
+       DP_PRN_FORMFEED,
+       DP_X_ALTSCRN,
+       DP_X_DECCOLM,
+       DP_X_LOGGING,
+       DP_X_MARGIN,
+       DP_X_MORE,
+       DP_X_MOUSE,
+       DP_X_EXT_MOUSE,
+       DP_X_REVWRAP,
+       DP_X_X10MSE,
+#if OPT_BLINK_CURS
+       DP_CRS_BLINK,
+#endif
+#if OPT_FOCUS_EVENT
+       DP_X_FOCUS,
+#endif
+#if OPT_TOOLBAR
+       DP_TOOLBAR,
+#endif
+       DP_LAST
+} SaveModes;
+
+#define DoSM(code,value)  screen->save_modes[code] = (unsigned) (value)
+#define DoRM(code,value)  value = (Boolean) screen->save_modes[code]
+#define DoRM0(code,value) value = screen->save_modes[code]
+
+       /* index into vt_shell[] or tek_shell[] */
+typedef enum {
+       noMenu = -1,
+       mainMenu,
+       vtMenu,
+       fontMenu,
+#if OPT_TEK4014
+       tekMenu
+#endif
+} MenuIndex;
+
+typedef enum {
+       bvOff = -1,
+       bvLow = 0,
+       bvHigh
+} BellVolume;
+
+#define NUM_POPUP_MENUS 4
+
+#if OPT_COLOR_RES
+typedef struct {
+       String          resource;
+       Pixel           value;
+       int             mode;           /* -1=invalid, 0=unset, 1=set   */
+} ColorRes;
+#else
+#define ColorRes Pixel
+#endif
+
+/* these are set in getPrinterFlags */
+typedef struct {
+       int     printer_extent;         /* print complete page          */
+       int     printer_formfeed;       /* print formfeed per function  */
+       int     printer_newline;        /* print newline per function   */
+       int     print_attributes;       /* 0=off, 1=normal, 2=color     */
+} PrinterFlags;
+
+typedef struct {
+       unsigned        which;          /* must have NCOLORS bits */
+       Pixel           colors[NCOLORS];
+       char            *names[NCOLORS];
+} ScrnColors;
+
+typedef struct {
+       Boolean         saved;
+       int             row;
+       int             col;
+       unsigned        flags;          /* VTxxx saves graphics rendition */
+       Char            curgl;
+       Char            curgr;
+       Char            gsets[4];
+#if OPT_ISO_COLORS
+       int             cur_foreground; /* current foreground color     */
+       int             cur_background; /* current background color     */
+       int             sgr_foreground; /* current SGR foreground color */
+       int             sgr_background; /* current SGR background color */
+       Boolean         sgr_extended;   /* SGR set with extended codes? */
+#endif
+} SavedCursor;
+
+typedef struct _SaveTitle {
+       struct _SaveTitle *next;
+       char            *iconName;
+       char            *windowName;
+} SaveTitle;
+
+#define SAVED_CURSORS 2
+
+typedef struct {
+       int             width;          /* if > 0, width of scrollbar,  */
+                                       /* and scrollbar is showing     */
+       Boolean         rv_cached;      /* see ScrollBarReverseVideo    */
+       int             rv_active;      /* ...current reverse-video     */
+       Pixel           bg;             /* ...cached background color   */
+       Pixel           fg;             /* ...cached foreground color   */
+       Pixel           bdr;            /* ...cached border color       */
+       Pixmap          bdpix;          /* ...cached border pixmap      */
+} SbInfo;
+
+#if OPT_TOOLBAR
+typedef struct {
+       Widget          menu_bar;       /* toolbar, if initialized      */
+       Dimension       menu_height;    /* ...and its height            */
+       Dimension       menu_border;    /* ...and its border            */
+} TbInfo;
+#define VT100_TB_INFO(name) screen.fullVwin.tb_info.name
+#endif
+
+typedef struct {
+       Window          window;         /* X window id                  */
+       int             width;          /* width of columns             */
+       int             height;         /* height of rows               */
+       Dimension       fullwidth;      /* full width of window         */
+       Dimension       fullheight;     /* full height of window        */
+       int             f_width;        /* width of fonts in pixels     */
+       int             f_height;       /* height of fonts in pixels    */
+       int             f_ascent;       /* ascent of font in pixels     */
+       int             f_descent;      /* descent of font in pixels    */
+       SbInfo          sb_info;
+#if OPT_TOOLBAR
+       Boolean         active;         /* true if toolbars are used    */
+       TbInfo          tb_info;        /* toolbar information          */
+#endif
+} VTwin;
+
+typedef struct {
+       Window          window;         /* X window id                  */
+       int             width;          /* width of columns             */
+       int             height;         /* height of rows               */
+       Dimension       fullwidth;      /* full width of window         */
+       Dimension       fullheight;     /* full height of window        */
+       double          tekscale;       /* scale factor Tek -> vs100    */
+} TKwin;
+
+typedef struct {
+/* These parameters apply to both windows */
+       Display         *display;       /* X display for screen         */
+       int             respond;        /* socket for responses
+                                          (position report, etc.)      */
+/* These parameters apply to VT100 window */
+       IChar           unparse_bfr[256];
+       unsigned        unparse_len;
+
+#if OPT_TCAP_QUERY
+       int             tc_query_code;
+       Bool            tc_query_fkey;
+#endif
+       pid_t           pid;            /* pid of process on far side   */
+       uid_t           uid;            /* user id of actual person     */
+       gid_t           gid;            /* group id of actual person    */
+       ColorRes        Tcolors[NCOLORS]; /* terminal colors            */
+#if OPT_HIGHLIGHT_COLOR
+       Boolean         hilite_color;   /* hilite colors override       */
+       Boolean         hilite_reverse; /* hilite overrides reverse     */
+#endif
+#if OPT_ISO_COLORS
+       ColorRes        Acolors[MAXCOLORS]; /* ANSI color emulation     */
+       int             veryBoldColors; /* modifier for boldColors      */
+       Boolean         boldColors;     /* can we make bold colors?     */
+       Boolean         colorMode;      /* are we using color mode?     */
+       Boolean         colorULMode;    /* use color for underline?     */
+       Boolean         italicULMode;   /* italic font for underline?   */
+       Boolean         colorBDMode;    /* use color for bold?          */
+       Boolean         colorBLMode;    /* use color for blink?         */
+       Boolean         colorRVMode;    /* use color for reverse?       */
+       Boolean         colorAttrMode;  /* prefer colorUL/BD to SGR     */
+#endif
+#if OPT_DEC_CHRSET
+       Boolean         font_doublesize;/* enable font-scaling          */
+       int             cache_doublesize;/* limit of our cache          */
+       Char            cur_chrset;     /* character-set index & code   */
+       int             fonts_used;     /* count items in double_fonts  */
+       XTermFonts      double_fonts[NUM_CHRSET];
+#endif
+#if OPT_DEC_RECTOPS
+       int             cur_decsace;    /* parameter for DECSACE        */
+#endif
+#if OPT_WIDE_CHARS
+       Boolean         wide_chars;     /* true when 16-bit chars       */
+       Boolean         vt100_graphics; /* true to allow vt100-graphics */
+       Boolean         utf8_inparse;   /* true to enable UTF-8 parser  */
+       int             utf8_mode;      /* use UTF-8 decode/encode: 0-2 */
+       int             max_combining;  /* maximum # of combining chars */
+       Boolean         utf8_latin1;    /* use UTF-8 with Latin-1 bias  */
+       Boolean         utf8_title;     /* use UTF-8 titles             */
+       int             latin9_mode;    /* poor man's luit, latin9      */
+       int             unicode_font;   /* font uses unicode encoding   */
+       int             utf_count;      /* state of utf_char            */
+       IChar           utf_char;       /* in-progress character        */
+       int             last_written_col;
+       int             last_written_row;
+       TypedBuffer(XChar2b);
+       TypedBuffer(char);
+#endif
+#if OPT_BROKEN_OSC
+       Boolean         brokenLinuxOSC; /* true to ignore Linux palette ctls */
+#endif
+#if OPT_BROKEN_ST
+       Boolean         brokenStringTerm; /* true to match old OSC parse */
+#endif
+#if OPT_C1_PRINT || OPT_WIDE_CHARS
+       Boolean         c1_printable;   /* true if we treat C1 as print */
+#endif
+       int             border;         /* inner border                 */
+       int             scrollBarBorder; /* scrollBar border            */
+       long            event_mask;
+       unsigned        send_mouse_pos; /* user wants mouse transition  */
+                                       /* and position information     */
+       Boolean         ext_mode_mouse; /* support large terminals      */
+       Boolean         send_focus_pos; /* user wants focus in/out info */
+       Boolean         quiet_grab;     /* true if no cursor change on focus */
+#if OPT_PASTE64
+       Cardinal        base64_paste;   /* set to send paste in base64  */
+       int             base64_final;   /* string-terminator for paste  */
+       /* _qWriteSelectionData expects these to be initialized to zero.
+        * base64_flush() is the last step of the conversion, it clears these
+        * variables.
+        */
+       unsigned        base64_accu;
+       unsigned        base64_count;
+       unsigned        base64_pad;
+#endif
+#if OPT_READLINE
+       unsigned        click1_moves;
+       unsigned        paste_moves;
+       unsigned        dclick3_deletes;
+       unsigned        paste_brackets;
+       unsigned        paste_quotes;
+       unsigned        paste_literal_nl;
+#endif /* OPT_READLINE */
+#if OPT_DEC_LOCATOR
+       Boolean         locator_reset;  /* turn mouse off after 1 report? */
+       Boolean         locator_pixels; /* report in pixels?            */
+                                       /* if false, report in cells    */
+       unsigned        locator_events; /* what events to report        */
+       Boolean         loc_filter;     /* is filter rectangle active?  */
+       int             loc_filter_top; /* filter rectangle for DEC Locator */
+       int             loc_filter_left;
+       int             loc_filter_bottom;
+       int             loc_filter_right;
+#endif /* OPT_DEC_LOCATOR */
+       int             mouse_button;   /* current button pressed       */
+       int             mouse_row;      /* ...and its row               */
+       int             mouse_col;      /* ...and its column            */
+       int             select;         /* xterm selected               */
+       Boolean         bellOnReset;    /* bellOnReset                  */
+       Boolean         visualbell;     /* visual bell mode             */
+       Boolean         poponbell;      /* pop on bell mode             */
+
+       Boolean         allowColorOps;  /* ColorOps mode                */
+       Boolean         allowFontOps;   /* FontOps mode                 */
+       Boolean         allowSendEvents;/* SendEvent mode               */
+       Boolean         allowTcapOps;   /* TcapOps mode                 */
+       Boolean         allowTitleOps;  /* TitleOps mode                */
+       Boolean         allowWindowOps; /* WindowOps mode               */
+
+       Boolean         allowColorOp0;  /* initial ColorOps mode        */
+       Boolean         allowFontOp0;   /* initial FontOps mode         */
+       Boolean         allowSendEvent0;/* initial SendEvent mode       */
+       Boolean         allowTcapOp0;   /* initial TcapOps mode         */
+       Boolean         allowTitleOp0;  /* initial TitleOps mode        */
+       Boolean         allowWindowOp0; /* initial WindowOps mode       */
+
+       String          disallowedColorOps;
+       char            disallow_color_ops[ecLAST];
+
+       String          disallowedFontOps;
+       char            disallow_font_ops[efLAST];
+
+       String          disallowedTcapOps;
+       char            disallow_tcap_ops[etLAST];
+
+       String          disallowedWinOps;
+       char            disallow_win_ops[ewLAST];
+
+       Boolean         awaitInput;     /* select-timeout mode          */
+       Boolean         grabbedKbd;     /* keyboard is grabbed          */
+#if OPT_MAXIMIZE
+       Boolean         fullscreen;     /* window is fullscreen         */
+#endif
+#ifdef ALLOWLOGGING
+       int             logging;        /* logging mode                 */
+       int             logfd;          /* file descriptor of log       */
+       char            *logfile;       /* log file name                */
+       Char            *logstart;      /* current start of log buffer  */
+#endif
+       int             inhibit;        /* flags for inhibiting changes */
+
+/* VT window parameters */
+       Boolean         Vshow;          /* VT window showing            */
+       VTwin           fullVwin;
+#ifndef NO_ACTIVE_ICON
+       VTwin           iconVwin;
+       VTwin           *whichVwin;
+#endif /* NO_ACTIVE_ICON */
+
+       int             pointer_mode;   /* when to use hidden_cursor    */
+       Boolean         hide_pointer;   /* true to use "hidden_cursor"  */
+       Cursor          pointer_cursor; /* pointer cursor in window     */
+       Cursor          hidden_cursor;  /* hidden cursor in window      */
+
+       String  answer_back;            /* response to ENQ              */
+       String  printer_command;        /* pipe/shell command string    */
+       Boolean printer_autoclose;      /* close printer when offline   */
+       Boolean printer_extent;         /* print complete page          */
+       Boolean printer_formfeed;       /* print formfeed per function  */
+       Boolean printer_newline;        /* print newline per function   */
+       int     printer_controlmode;    /* 0=off, 1=auto, 2=controller  */
+       int     print_attributes;       /* 0=off, 1=normal, 2=color     */
+
+       PrinterFlags    printer_flags;  /* working copy of printer flags */
+
+       Boolean         fnt_prop;       /* true if proportional fonts   */
+       Boolean         fnt_boxes;      /* true if font has box-chars   */
+       Boolean         force_packed;   /* true to override proportional */
+#if OPT_BOX_CHARS
+       Boolean         force_box_chars;/* true if we assume that       */
+       Boolean         force_all_chars;/* true to outline missing chars */
+       Boolean         allow_packing;  /* true to allow packed-fonts   */
+#endif
+       Dimension       fnt_wide;
+       Dimension       fnt_high;
+       XTermFonts      fnts[fMAX];     /* normal/bold/etc for terminal */
+       Boolean         free_bold_box;  /* same_font_size's austerity   */
+#ifndef NO_ACTIVE_ICON
+       XTermFonts      fnt_icon;       /* icon font                    */
+       String          icon_fontname;  /* name of icon font            */
+       int             icon_fontnum;   /* number to use for icon font  */
+#endif /* NO_ACTIVE_ICON */
+       int             enbolden;       /* overstrike for bold font     */
+       XPoint          *box;           /* draw unselected cursor       */
+
+       int             cursor_state;   /* ON, OFF, or BLINKED_OFF      */
+       int             cursor_busy;    /* do not redraw...             */
+       Boolean         cursor_underline; /* true if cursor is in underline mode */
+#if OPT_BLINK_CURS
+       Boolean         cursor_blink;   /* cursor blink enable          */
+       Boolean         cursor_blink_res; /* initial cursor blink value */
+       Boolean         cursor_blink_esc; /* cursor blink escape-state  */
+#endif
+#if OPT_BLINK_TEXT
+       Boolean         blink_as_bold;  /* text blink disable           */
+#endif
+#if OPT_BLINK_CURS || OPT_BLINK_TEXT
+       int             blink_state;    /* ON, OFF, or BLINKED_OFF      */
+       int             blink_on;       /* cursor on time (msecs)       */
+       int             blink_off;      /* cursor off time (msecs)      */
+       XtIntervalId    blink_timer;    /* timer-id for cursor-proc     */
+#endif
+#if OPT_ZICONBEEP
+       Boolean         zIconBeep_flagged; /* True if icon name was changed */
+#endif /* OPT_ZICONBEEP */
+       int             cursor_GC;      /* see ShowCursor()             */
+       int             cursor_set;     /* requested state              */
+       CELL            cursorp;        /* previous cursor row/column   */
+       int             cur_col;        /* current cursor column        */
+       int             cur_row;        /* current cursor row           */
+       int             max_col;        /* rightmost column             */
+       int             max_row;        /* bottom row                   */
+       int             top_marg;       /* top line of scrolling region */
+       int             bot_marg;       /* bottom line of  "        "   */
+       Widget          scrollWidget;   /* pointer to scrollbar struct  */
+       /*
+        * Indices used to keep track of the top of the vt100 window and
+        * the saved lines, taking scrolling into account.
+        */
+       int             topline;        /* line number of top, <= 0     */
+       long            saved_fifo;     /* number of lines that've been saved */
+       int             savedlines;     /* number of lines that've been saved */
+       int             savelines;      /* number of lines off top to save */
+       int             scroll_amt;     /* amount to scroll             */
+       int             refresh_amt;    /* amount to refresh            */
+       /*
+        * Working variables for getLineData().
+        */
+       size_t          lineExtra;      /* extra space for combining chars */
+       /*
+        * Pointer to the current visible buffer.
+        */
+       ScrnBuf         visbuf;         /* ptr to visible screen buf (main) */
+       /*
+        * Data for the normal buffer, which may have saved lines to which
+        * the user can scroll.
+        */
+       ScrnBuf         saveBuf_index;
+       Char            *saveBuf_data;
+       /*
+        * Data for visible and alternate buffer.
+        */
+       ScrnBuf         editBuf_index[2];
+       Char            *editBuf_data[2];
+       int             whichBuf;       /* 0/1 for normal/alternate buf */
+       Boolean         is_running;     /* true when buffers are legal  */
+       /*
+        * Workspace used for screen operations.
+        */
+       Char            **save_ptr;     /* workspace for save-pointers  */
+       size_t          save_len;       /* ...and its length            */
+
+       int             scrolllines;    /* number of lines to button scroll */
+       Boolean         scrollttyoutput; /* scroll to bottom on tty output */
+       Boolean         scrollkey;      /* scroll to bottom on key      */
+       Boolean         cursor_moved;   /* scrolling makes cursor move  */
+
+       Boolean         do_wrap;        /* true if cursor in last column
+                                           and character just output    */
+
+       int             incopy;         /* 0 idle; 1 XCopyArea issued;
+                                           -1 first GraphicsExpose seen,
+                                           but last not seen           */
+       int             copy_src_x;     /* params from last XCopyArea ... */
+       int             copy_src_y;
+       unsigned int    copy_width;
+       unsigned int    copy_height;
+       int             copy_dest_x;
+       int             copy_dest_y;
+
+       Boolean         c132;           /* allow change to 132 columns  */
+       Boolean         curses;         /* kludge line wrap for more    */
+       Boolean         hp_ll_bc;       /* kludge HP-style ll for xdb   */
+       Boolean         marginbell;     /* true if margin bell on       */
+       int             nmarginbell;    /* columns from right margin    */
+       int             bellArmed;      /* cursor below bell margin     */
+       BellVolume      marginVolume;   /* margin-bell volume           */
+       BellVolume      warningVolume;  /* warning-bell volume          */
+       Boolean         multiscroll;    /* true if multi-scroll         */
+       int             scrolls;        /* outstanding scroll count,
+                                           used only with multiscroll  */
+       SavedCursor     sc[SAVED_CURSORS]; /* data for restore cursor   */
+       unsigned        save_modes[DP_LAST]; /* save dec/xterm private modes */
+
+       int             title_modes;    /* control set/get of titles    */
+       SaveTitle       *save_title;
+
+       /* Improved VT100 emulation stuff.                              */
+       String          keyboard_dialect; /* default keyboard dialect   */
+       Char            gsets[4];       /* G0 through G3.               */
+       Char            curgl;          /* Current GL setting.          */
+       Char            curgr;          /* Current GR setting.          */
+       Char            curss;          /* Current single shift.        */
+       String          term_id;        /* resource for terminal_id     */
+       int             terminal_id;    /* 100=vt100, 220=vt220, etc.   */
+       int             vtXX_level;     /* 0=vt52, 1,2,3 = vt100 ... vt320 */
+       int             ansi_level;     /* levels 1,2,3                 */
+       int             protected_mode; /* 0=off, 1=DEC, 2=ISO          */
+       Boolean         always_bold_mode; /* compare normal/bold font   */
+       Boolean         always_highlight; /* whether to highlight cursor */
+       Boolean         bold_mode;      /* use bold font or overstrike  */
+       Boolean         delete_is_del;  /* true for compatible Delete key */
+       Boolean         jumpscroll;     /* whether we should jumpscroll */
+       Boolean         fastscroll;     /* whether we should fastscroll */
+       Boolean         old_fkeys;      /* true for compatible fkeys    */
+       Boolean         underline;      /* whether to underline text    */
+
+#if OPT_MAXIMIZE
+       Boolean         restore_data;
+       int             restore_x;
+       int             restore_y;
+       unsigned        restore_width;
+       unsigned        restore_height;
+#endif
+
+#if OPT_SCROLL_LOCK
+       Boolean         allowScrollLock;/* ScrollLock mode              */
+       Boolean         allowScrollLock0;/* initial ScrollLock mode     */
+       Boolean         scroll_lock;    /* true to keep buffer in view  */
+       Boolean         scroll_dirty;   /* scrolling makes screen dirty */
+#endif
+
+#if OPT_VT52_MODE
+       int             vt52_save_level; /* save-area for DECANM        */
+       Char            vt52_save_curgl;
+       Char            vt52_save_curgr;
+       Char            vt52_save_curss;
+       Char            vt52_save_gsets[4];
+#endif
+       /* Testing */
+#if OPT_XMC_GLITCH
+       unsigned        xmc_glitch;     /* # of spaces to pad on SGR's  */
+       int             xmc_attributes; /* attrs that make a glitch     */
+       Boolean         xmc_inline;     /* SGR's propagate only to eol  */
+       Boolean         move_sgr_ok;    /* SGR is reset on move         */
+#endif
+
+       /*
+        * Bell
+        */
+       int             visualBellDelay; /* msecs to delay for visibleBell */
+       int             bellSuppressTime; /* msecs after Bell before another allowed */
+       Boolean         bellInProgress; /* still ringing/flashing prev bell? */
+       Boolean         bellIsUrgent;   /* set XUrgency WM hint on bell */
+       /*
+        * Select/paste state.
+        */
+       Boolean         selectToClipboard; /* primary vs clipboard */
+       String          *mappedSelect;  /* mapping for "SELECT" to "PRIMARY" */
+
+       Boolean         waitingForTrackInfo;
+       int             numberOfClicks;
+       int             maxClicks;
+       int             multiClickTime; /* time between multiclick selects */
+       SelectUnit      selectUnit;
+       SelectUnit      selectMap[NSELECTUNITS];
+       String          onClick[NSELECTUNITS + 1];
+
+       char            *charClass;     /* for overriding word selection */
+       Boolean         cutNewline;     /* whether or not line cut has \n */
+       Boolean         cutToBeginningOfLine;  /* line cuts to BOL? */
+       Boolean         highlight_selection; /* controls appearance of selection */
+       Boolean         show_wrap_marks; /* show lines which are wrapped */
+       Boolean         trim_selection; /* controls trimming of selection */
+       Boolean         i18nSelections;
+       Boolean         brokenSelections;
+       Boolean         keepSelection;  /* do not lose selection on output */
+       Boolean         replyToEmacs;   /* Send emacs escape code when done selecting or extending? */
+       Char            *selection_data; /* the current selection */
+       int             selection_size; /* size of allocated buffer */
+       unsigned long   selection_length; /* number of significant bytes */
+       EventMode       eventMode;
+       Time            selection_time; /* latest event timestamp */
+       Time            lastButtonUpTime;
+       unsigned        lastButton;
+
+       CELL            rawPos;         /* raw position for selection start */
+       CELL            startRaw;       /* area before selectUnit processing */
+       CELL            endRaw;         /* " " */
+       CELL            startSel;       /* area after selectUnit processing */
+       CELL            endSel;         /* " " */
+       CELL            startH;         /* start highlighted text */
+       CELL            endH;           /* end highlighted text */
+       CELL            saveStartW;     /* saved WORD state, for LINE */
+       CELL            startExt;       /* Start, end of extension */
+       CELL            endExt;         /* " " */
+       CELL            saveStartR;     /* Saved values of raw selection for extend to restore to */
+       CELL            saveEndR;       /* " " */
+       int             startHCoord, endHCoord;
+       int             firstValidRow;  /* Valid rows for selection clipping */
+       int             lastValidRow;   /* " " */
+
+       String          default_string;
+       String          eightbit_select_types;
+       Atom*           selection_targets_8bit;
+#if OPT_WIDE_CHARS
+       String          utf8_select_types;
+       Atom*           selection_targets_utf8;
+#endif
+       Atom*           selection_atoms; /* which selections we own */
+       Cardinal        sel_atoms_size; /*  how many atoms allocated */
+       Cardinal        selection_count; /* how many atoms in use */
+#if OPT_SELECT_REGEX
+       char *          selectExpr[NSELECTUNITS];
+#endif
+       /*
+        * Input/output state.
+        */
+       Boolean         input_eight_bits;/* use 8th bit instead of ESC prefix */
+       Boolean         output_eight_bits; /* honor all bits or strip */
+       Boolean         control_eight_bits; /* send CSI as 8-bits */
+       Boolean         backarrow_key;          /* backspace/delete */
+       Boolean         alt_is_not_meta;        /* use both Alt- and Meta-key */
+       Boolean         alt_sends_esc;          /* Alt-key sends ESC prefix */
+       Boolean         meta_sends_esc;         /* Meta-key sends ESC prefix */
+       /*
+        * Fonts
+        */
+       Pixmap          menu_item_bitmap;       /* mask for checking items */
+       String          initial_font;
+       String          menu_font_names[NMENUFONTS][fMAX];
+#define MenuFontName(n) menu_font_names[n][fNorm]
+       long            menu_font_sizes[NMENUFONTS];
+       int             menu_font_number;
+#if OPT_CLIP_BOLD
+       Boolean         use_clipping;
+#endif
+       void *          main_cgs_cache;
+#ifndef NO_ACTIVE_ICON
+       void *          icon_cgs_cache;
+#endif
+#if OPT_RENDERFONT
+       XTermXftFonts   renderFontNorm[NMENUFONTS];
+       XTermXftFonts   renderFontBold[NMENUFONTS];
+       XTermXftFonts   renderFontItal[NMENUFONTS];
+#if OPT_RENDERWIDE
+       XTermXftFonts   renderWideNorm[NMENUFONTS];
+       XTermXftFonts   renderWideBold[NMENUFONTS];
+       XTermXftFonts   renderWideItal[NMENUFONTS];
+       TypedBuffer(XftCharSpec);
+#else
+       TypedBuffer(XftChar8);
+#endif
+       XftDraw *       renderDraw;
+#endif
+#if OPT_INPUT_METHOD
+       XIM             xim;
+       XFontSet        fs;             /* fontset for XIM preedit */
+       int             fs_ascent;      /* ascent of fs */
+#endif
+       XIC             xic;            /* this is used even without XIM */
+#if OPT_DABBREV
+       Boolean         dabbrev_working;        /* nonzero during dabbrev process */
+       unsigned char   dabbrev_erase_char;     /* used for deleting inserted completion */
+#endif
+       char            tcapbuf[TERMCAP_SIZE];
+#if OPT_TCAP_FKEYS
+       char **         tcap_fkeys;
+       char            tcap_area[TERMCAP_SIZE];
+#endif
+} TScreen;
+
+typedef struct _TekPart {
+       XFontStruct *   Tfont[TEKNUMFONTS];
+       int             tobaseline[TEKNUMFONTS]; /* top-baseline, each font */
+       char *          initial_font;           /* large, 2, 3, small */
+       char *          gin_terminator_str;     /* ginTerminator resource */
+#if OPT_TOOLBAR
+       TbInfo          tb_info;        /* toolbar information          */
+#endif
+} TekPart;
+
+/* Tektronix window parameters */
+typedef struct _TekScreen {
+       GC              TnormalGC;      /* normal painting              */
+       GC              TcursorGC;      /* normal cursor painting       */
+
+       Boolean         waitrefresh;    /* postpone refresh             */
+       TKwin           fullTwin;
+#ifndef NO_ACTIVE_ICON
+       TKwin           iconTwin;
+       TKwin           *whichTwin;
+#endif /* NO_ACTIVE_ICON */
+
+       Cursor          arrow;          /* arrow cursor                 */
+       GC              linepat[TEKNUMLINES]; /* line patterns          */
+       int             cur_X;          /* current x                    */
+       int             cur_Y;          /* current y                    */
+       Tmodes          cur;            /* current tek modes            */
+       Tmodes          page;           /* starting tek modes on page   */
+       int             margin;         /* 0 -> margin 1, 1 -> margin 2 */
+       int             pen;            /* current Tektronix pen 0=up, 1=dn */
+       char            *TekGIN;        /* nonzero if Tektronix GIN mode*/
+       int             gin_terminator; /* Tek strap option */
+       char            tcapbuf[TERMCAP_SIZE];
+} TekScreen;
+
+#if OPT_READLINE
+#define SCREEN_FLAG(screenp,f)         (1&(screenp)->f)
+#define SCREEN_FLAG_set(screenp,f)     ((screenp)->f |= 1)
+#define SCREEN_FLAG_unset(screenp,f)   ((screenp)->f &= (unsigned) ~1L)
+#define SCREEN_FLAG_save(screenp,f)    \
+       ((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f))
+#define SCREEN_FLAG_restore(screenp,f) ((screenp)->f = (((screenp)->f)>>1))
+#else
+#define SCREEN_FLAG(screenp,f)         (0)
+#endif
+
+/* meaning of bits in screen.select flag */
+#define        INWINDOW        01      /* the mouse is in one of the windows */
+#define        FOCUS           02      /* one of the windows is the focus window */
+
+#define MULTICLICKTIME 250     /* milliseconds */
+
+typedef enum {
+    fwNever = 0,
+    fwResource,
+    fwAlways
+} fontWarningTypes;
+
+typedef enum {
+    keyboardIsLegacy,          /* bogus vt220 codes for F1-F4, etc. */
+    keyboardIsDefault,
+    keyboardIsHP,
+    keyboardIsSCO,
+    keyboardIsSun,
+    keyboardIsTermcap,
+    keyboardIsVT220
+} xtermKeyboardType;
+
+typedef enum {                 /* legal values for screen.pointer_mode */
+    pNever = 0,
+    pNoMouse = 1,
+    pAlways = 2
+} pointerModeTypes;
+
+typedef enum {                 /* legal values for screen.utf8_mode */
+    uFalse = 0,
+    uTrue = 1,
+    uAlways = 2,
+    uDefault = 3
+} utf8ModeTypes;
+
+#if OPT_HP_FUNC_KEYS
+#define NAME_HP_KT " hp"
+#else
+#define NAME_HP_KT /*nothing*/
+#endif
+
+#if OPT_SCO_FUNC_KEYS
+#define NAME_SCO_KT " sco"
+#else
+#define NAME_SCO_KT /*nothing*/
+#endif
+
+#if OPT_SUN_FUNC_KEYS
+#define NAME_SUN_KT " sun"
+#else
+#define NAME_SUN_KT /*nothing*/
+#endif
+
+#if OPT_SUNPC_KBD
+#define NAME_VT220_KT " vt220"
+#else
+#define NAME_VT220_KT /*nothing*/
+#endif
+
+#if OPT_TCAP_FKEYS
+#define NAME_TCAP_KT " tcap"
+#else
+#define NAME_TCAP_KT /*nothing*/
+#endif
+
+#define KEYBOARD_TYPES NAME_TCAP_KT NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT
+
+#if OPT_TRACE
+#define TRACE_RC(code,func) code = func
+#else
+#define TRACE_RC(code,func) func
+#endif
+
+#if OPT_TRACE
+extern const char * visibleKeyboardType(xtermKeyboardType);
+#endif
+
+typedef struct
+{
+    int cursor_keys;           /* how to handle cursor-key modifiers */
+    int function_keys;         /* how to handle function-key modifiers */
+    int keypad_keys;           /* how to handle keypad key-modifiers */
+    int other_keys;            /* how to handle other key-modifiers */
+    int string_keys;           /* how to handle string() modifiers */
+} TModify;
+
+typedef struct
+{
+    xtermKeyboardType type;
+    unsigned flags;
+    char *shell_translations;
+    char *xterm_translations;
+    char *extra_translations;
+#if OPT_INITIAL_ERASE
+    int        reset_DECBKM;           /* reset should set DECBKM */
+#endif
+#if OPT_MOD_FKEYS
+    TModify modify_now;                /* current modifier value */
+    TModify modify_1st;                /* original modifier value, for resets */
+    int format_keys;           /* format of modifyOtherKeys */
+#endif
+} TKeyboard;
+
+typedef struct {
+    String f_n;                        /* the normal font */
+    String f_b;                        /* the bold font */
+#if OPT_WIDE_CHARS
+    String f_w;                        /* the normal wide font */
+    String f_wb;               /* the bold wide font */
+#endif
+} VTFontNames;
+
+#define GravityIsNorthWest(w) ((w)->misc.resizeGravity == NorthWestGravity)
+#define GravityIsSouthWest(w) ((w)->misc.resizeGravity == SouthWestGravity)
+
+typedef struct _Misc {
+    VTFontNames default_font;
+    char *geo_metry;
+    char *T_geometry;
+#if OPT_WIDE_CHARS
+    Boolean cjk_width;         /* true for built-in CJK wcwidth() */
+    Boolean mk_width;          /* true for simpler built-in wcwidth() */
+    int mk_samplesize;
+    int mk_samplepass;
+#endif
+#if OPT_LUIT_PROG
+    Boolean callfilter;                /* true to invoke luit */
+    Boolean use_encoding;      /* true to use -encoding option for luit */
+    char *locale_str;          /* "locale" resource */
+    char *localefilter;                /* path for luit */
+#endif
+    fontWarningTypes fontWarnings;
+    int limit_resize;
+#ifdef ALLOWLOGGING
+    Boolean log_on;
+#endif
+    Boolean login_shell;
+    Boolean re_verse;
+    Boolean re_verse0;         /* initial value of "-rv" */
+    XtGravity resizeGravity;
+    Boolean reverseWrap;
+    Boolean autoWrap;
+    Boolean logInhibit;
+    Boolean signalInhibit;
+#if OPT_TEK4014
+    Boolean tekInhibit;
+    Boolean tekSmall;          /* start tek window in small size */
+    Boolean TekEmu;            /* true if Tektronix emulation  */
+    Boolean Tshow;             /* Tek window showing           */
+#endif
+    Boolean scrollbar;
+#ifdef SCROLLBAR_RIGHT
+    Boolean useRight;
+#endif
+    Boolean titeInhibit;
+    Boolean tiXtraScroll;
+    Boolean appcursorDefault;
+    Boolean appkeypadDefault;
+#if OPT_INPUT_METHOD
+    char* f_x;                 /* font for XIM */
+    char* input_method;
+    char* preedit_type;
+    Boolean open_im;           /* true if input-method is opened */
+    Boolean cannot_im;         /* true if we cannot use input-method */
+    int retry_im;
+#endif
+    Boolean dynamicColors;
+    Boolean shared_ic;
+#ifndef NO_ACTIVE_ICON
+    Boolean active_icon;       /* use application icon window  */
+    unsigned icon_border_width;
+    Pixel icon_border_pixel;
+#endif /* NO_ACTIVE_ICON */
+#if OPT_DEC_SOFTFONT
+    Boolean font_loadable;
+#endif
+#if OPT_SHIFT_FONTS
+    Boolean shift_fonts;       /* true if we interpret fontsize-shifting */
+#endif
+#if OPT_SUNPC_KBD
+    int ctrl_fkeys;            /* amount to add to XK_F1 for ctrl modifier */
+#endif
+#if OPT_NUM_LOCK
+    Boolean real_NumLock;      /* true if we treat NumLock key specially */
+    Boolean alwaysUseMods;     /* true if we always want f-key modifiers */
+    unsigned num_lock;         /* modifier for Num_Lock */
+    unsigned alt_mods;         /* modifier for Alt_L or Alt_R */
+    unsigned meta_mods;                /* modifier for Meta_L or Meta_R */
+    unsigned other_mods;       /* conflicting modifiers, e.g., Mode_Switch */
+#endif
+#if OPT_RENDERFONT
+    char *face_name;
+    char *face_wide_name;
+    float face_size[NMENUFONTS];
+    char *render_font_s;
+    Boolean render_font;
+#endif
+} Misc;
+
+typedef struct {int foo;} XtermClassPart, TekClassPart;
+
+typedef struct _XtermClassRec {
+    CoreClassPart  core_class;
+    XtermClassPart xterm_class;
+} XtermClassRec;
+
+extern WidgetClass xtermWidgetClass;
+
+#define IsXtermWidget(w) (XtClass(w) == xtermWidgetClass)
+
+#if OPT_TEK4014
+typedef struct _TekClassRec {
+    CoreClassPart core_class;
+    TekClassPart tek_class;
+} TekClassRec;
+
+extern WidgetClass tekWidgetClass;
+
+#define IsTekWidget(w) (XtClass(w) == tekWidgetClass)
+
+#endif
+
+/* define masks for keyboard.flags */
+#define MODE_KAM       xBIT(0) /* keyboard action mode */
+#define MODE_DECKPAM   xBIT(1) /* keypad application mode */
+#define MODE_DECCKM    xBIT(2) /* cursor keys */
+#define MODE_SRM       xBIT(3) /* send-receive mode */
+#define MODE_DECBKM    xBIT(4) /* backarrow */
+
+
+#define N_MARGINBELL   10
+
+#define TAB_BITS_SHIFT 5       /* FIXME: 2**5 == 32 (should derive) */
+#define TAB_BITS_WIDTH (1 << TAB_BITS_SHIFT)
+#define TAB_ARRAY_SIZE (1024 / TAB_BITS_WIDTH)
+#define MAX_TABS       (TAB_BITS_WIDTH * TAB_ARRAY_SIZE)
+
+typedef unsigned Tabs [TAB_ARRAY_SIZE];
+
+typedef struct _XtermWidgetRec {
+    CorePart   core;
+    XSizeHints hints;
+    Bool       init_menu;
+    TKeyboard  keyboard;       /* terminal keyboard            */
+    TScreen    screen;         /* terminal screen              */
+    unsigned   flags;          /* mode flags                   */
+    int                cur_foreground; /* current foreground color     */
+    int                cur_background; /* current background color     */
+    Pixel      dft_foreground; /* default foreground color     */
+    Pixel      dft_background; /* default background color     */
+#if OPT_ISO_COLORS
+    int                sgr_foreground; /* current SGR foreground color */
+    int                sgr_background; /* current SGR background color */
+    Boolean    sgr_extended;   /* SGR set with extended codes? */
+#endif
+    unsigned   initflags;      /* initial mode flags           */
+    Tabs       tabs;           /* tabstops of the terminal     */
+    Misc       misc;           /* miscellaneous parameters     */
+} XtermWidgetRec, *XtermWidget;
+
+#if OPT_TEK4014
+typedef struct _TekWidgetRec {
+    CorePart   core;
+    TekPart    tek;            /* contains resources */
+    TekScreen  screen;         /* contains working data (no resources) */
+    Bool       init_menu;
+    XSizeHints hints;
+} TekWidgetRec, *TekWidget;
+#endif /* OPT_TEK4014 */
+
+/*
+ * terminal flags
+ * There are actually two namespaces mixed together here.
+ * One is the set of flags that can go in screen->visbuf attributes
+ * and which must fit in a char (see OFF_ATTRS).
+ * The other is the global setting stored in
+ * term->flags and screen->save_modes.  This need only fit in an unsigned.
+ */
+
+#define AttrBIT(n)     xBIT(n)         /* text-attributes */
+#define DrawBIT(n)     xBIT(n + 8)     /* drawXtermText flags */
+#define MiscBIT(n)     xBIT(n + 16)    /* miscellaneous state flags */
+
+/* global flags and character flags (visible character attributes) */
+#define INVERSE                AttrBIT(0)      /* invert the characters to be output */
+#define UNDERLINE      AttrBIT(1)      /* true if underlining */
+#define BOLD           AttrBIT(2)
+#define BLINK          AttrBIT(3)
+/* global flags (also character attributes) */
+#define BG_COLOR       AttrBIT(4)      /* true if background set */
+#define FG_COLOR       AttrBIT(5)      /* true if foreground set */
+
+/* character flags (internal attributes) */
+#define PROTECTED      AttrBIT(6)      /* a character that cannot be erased */
+#define CHARDRAWN      AttrBIT(7)      /* a character has been drawn here on
+                                          the screen.  Used to distinguish
+                                          blanks from empty parts of the
+                                          screen when selecting */
+
+/* The following attributes are used in the argument of drawXtermText()  */
+#define NOBACKGROUND   DrawBIT(0)      /* Used for overstrike */
+#define NOTRANSLATION  DrawBIT(1)      /* No scan for chars missing in font */
+#define DOUBLEWFONT    DrawBIT(2)      /* The actual X-font is double-width */
+#define DOUBLEHFONT    DrawBIT(3)      /* The actual X-font is double-height */
+#define CHARBYCHAR     DrawBIT(4)      /* Draw chars one-by-one */
+
+/* The following attribute is used in the argument of xtermSpecialFont etc */
+#define NORESOLUTION   DrawBIT(5)      /* find the font without resolution */
+
+/*
+ * Other flags
+ */
+#define WRAPAROUND     MiscBIT(0)      /* true if auto wraparound mode */
+#define        REVERSEWRAP     MiscBIT(1)      /* true if reverse wraparound mode */
+#define REVERSE_VIDEO  MiscBIT(2)      /* true if screen white on black */
+#define LINEFEED       MiscBIT(3)      /* true if in auto linefeed mode */
+#define ORIGIN         MiscBIT(4)      /* true if in origin mode */
+#define INSERT         MiscBIT(5)      /* true if in insert mode */
+#define SMOOTHSCROLL   MiscBIT(6)      /* true if in smooth scroll mode */
+#define IN132COLUMNS   MiscBIT(7)      /* true if in 132 column mode */
+#define INVISIBLE      MiscBIT(8)      /* true if writing invisible text */
+#define NATIONAL        MiscBIT(9)     /* true if writing national charset */
+
+/*
+ * Groups of attributes
+ */
+                       /* mask for video-attributes only */
+#define SGR_MASK       (BOLD | BLINK | UNDERLINE | INVERSE)
+
+                       /* mask: user-visible attributes */
+#define        ATTRIBUTES      (SGR_MASK | BG_COLOR | FG_COLOR | INVISIBLE | PROTECTED)
+
+/* The toplevel-call to drawXtermText() should have text-attributes guarded: */
+#define DRAWX_MASK     (ATTRIBUTES | CHARDRAWN)
+
+#if OPT_BLINK_TEXT
+#define BOLDATTR(screen) (BOLD | ((screen)->blink_as_bold ? BLINK : 0))
+#else
+#define BOLDATTR(screen) (BOLD | BLINK)
+#endif
+
+/*
+ * Per-line flags
+ */
+#define LINEWRAPPED    AttrBIT(0)
+/* used once per line to indicate that it wraps onto the next line so we can
+ * tell the difference between lines that have wrapped around and lines that
+ * have ended naturally with a CR at column max_col.
+ */
+#define LINEBLINKED    AttrBIT(1)
+/* set when the line contains blinking text.
+ */
+
+#if OPT_ZICONBEEP || OPT_TOOLBAR
+#define HANDLE_STRUCT_NOTIFY 1
+#else
+#define HANDLE_STRUCT_NOTIFY 0
+#endif
+
+/*
+ * If we've set protected attributes with the DEC-style DECSCA, then we'll have
+ * to use DECSED or DECSEL to erase preserving protected text.  (The normal ED,
+ * EL won't preserve protected-text).  If we've used SPA, then normal ED and EL
+ * will preserve protected-text.  To keep things simple, just remember the last
+ * control that was used to begin protected-text, and use that to determine how
+ * erases are performed (otherwise we'd need 2 bits per protected character).
+ */
+#define OFF_PROTECT 0
+#define DEC_PROTECT 1
+#define ISO_PROTECT 2
+
+#define TScreenOf(xw)  (&(xw)->screen)
+#define TekScreenOf(tw) (&(tw)->screen)
+
+#ifdef SCROLLBAR_RIGHT
+#define OriginX(screen) (((term->misc.useRight)?0:ScrollbarWidth(screen)) + screen->border)
+#else
+#define OriginX(screen) (ScrollbarWidth(screen) + screen->border)
+#endif
+
+#define OriginY(screen) (screen->border)
+
+#define CursorMoved(screen) \
+               ((screen)->cursor_moved || \
+                   ((screen)->cursorp.col != (screen)->cur_col || \
+                    (screen)->cursorp.row != (screen)->cur_row))
+
+#define CursorX(screen,col) ((col) * FontWidth(screen) + OriginX(screen))
+#define CursorY(screen,row) ((INX2ROW(screen, row) * FontHeight(screen)) \
+                       + screen->border)
+
+/*
+ * These definitions depend on whether xterm supports active-icon.
+ */
+#ifndef NO_ACTIVE_ICON
+#define IsIconWin(screen,win)  ((win) == &(screen)->iconVwin)
+#define IsIcon(screen)         (WhichVWin(screen) == &(screen)->iconVwin)
+#define WhichVWin(screen)      ((screen)->whichVwin)
+#define WhichTWin(screen)      ((screen)->whichTwin)
+
+#define WhichVFont(screen,name)        (IsIcon(screen) ? (screen)->fnt_icon.fs \
+                                               : (screen)->name)
+#define FontAscent(screen)     (IsIcon(screen) ? (screen)->fnt_icon.fs->ascent \
+                                               : WhichVWin(screen)->f_ascent)
+#define FontDescent(screen)    (IsIcon(screen) ? (screen)->fnt_icon.fs->descent \
+                                               : WhichVWin(screen)->f_descent)
+#else /* NO_ACTIVE_ICON */
+
+#define IsIconWin(screen,win)  (False)
+#define IsIcon(screen)         (False)
+#define WhichVWin(screen)      (&((screen)->fullVwin))
+#define WhichTWin(screen)      (&((screen)->fullTwin))
+
+#define WhichVFont(screen,name)        ((screen)->name)
+#define FontAscent(screen)     WhichVWin(screen)->f_ascent
+#define FontDescent(screen)    WhichVWin(screen)->f_descent
+
+#endif /* NO_ACTIVE_ICON */
+
+#define okFont(font) ((font) != 0 && (font)->fid != 0)
+
+/*
+ * Macro to check if we are iconified; do not use render for that case.
+ */
+#define UsingRenderFont(xw)    (((xw)->misc.render_font == True) && !IsIcon(TScreenOf(xw)))
+
+/*
+ * These definitions do not depend on whether xterm supports active-icon.
+ */
+#define VWindow(screen)                WhichVWin(screen)->window
+#define VShellWindow(xw)       XtWindow(SHELL_OF(xw))
+#define TWindow(screen)                WhichTWin(screen)->window
+#define TShellWindow           XtWindow(SHELL_OF(tekWidget))
+
+#define Width(screen)          WhichVWin(screen)->width
+#define Height(screen)         WhichVWin(screen)->height
+#define FullWidth(screen)      WhichVWin(screen)->fullwidth
+#define FullHeight(screen)     WhichVWin(screen)->fullheight
+#define FontWidth(screen)      WhichVWin(screen)->f_width
+#define FontHeight(screen)     WhichVWin(screen)->f_height
+
+#define NormalFont(screen)     WhichVFont(screen, fnts[fNorm].fs)
+#define BoldFont(screen)       WhichVFont(screen, fnts[fBold].fs)
+
+#if OPT_WIDE_CHARS
+#define NormalWFont(screen)    WhichVFont(screen, fnts[fWide].fs)
+#define BoldWFont(screen)      WhichVFont(screen, fnts[fWBold].fs)
+#endif
+
+#define ScrollbarWidth(screen) WhichVWin(screen)->sb_info.width
+
+#define NormalGC(w,sp)         getCgsGC(w, WhichVWin(sp), gcNorm)
+#define ReverseGC(w,sp)                getCgsGC(w, WhichVWin(sp), gcNormReverse)
+#define NormalBoldGC(w,sp)     getCgsGC(w, WhichVWin(sp), gcBold)
+#define ReverseBoldGC(w,sp)    getCgsGC(w, WhichVWin(sp), gcBoldReverse)
+
+#define TWidth(screen)         WhichTWin(screen)->width
+#define THeight(screen)                WhichTWin(screen)->height
+#define TFullWidth(screen)     WhichTWin(screen)->fullwidth
+#define TFullHeight(screen)    WhichTWin(screen)->fullheight
+#define TekScale(screen)       WhichTWin(screen)->tekscale
+
+#define BorderWidth(w)         ((w)->core.border_width)
+#define BorderPixel(w)         ((w)->core.border_pixel)
+
+#define AllowXtermOps(w,name)  (TScreenOf(w)->name && !TScreenOf(w)->allowSendEvents)
+
+#define AllowColorOps(w,name)  (AllowXtermOps(w, allowColorOps) || \
+                                !TScreenOf(w)->disallow_color_ops[name])
+
+#define AllowFontOps(w,name)   (AllowXtermOps(w, allowFontOps) || \
+                                !TScreenOf(w)->disallow_font_ops[name])
+
+#define AllowTcapOps(w,name)   (AllowXtermOps(w, allowTcapOps) || \
+                                !TScreenOf(w)->disallow_tcap_ops[name])
+
+#define AllowTitleOps(w)       AllowXtermOps(w, allowTitleOps)
+
+#define AllowWindowOps(w,name) (AllowXtermOps(w, allowWindowOps) || \
+                                !TScreenOf(w)->disallow_win_ops[name])
+
+#if OPT_TOOLBAR
+#define ToolbarHeight(w)       ((resource.toolBar) \
+                                ? ((w)->VT100_TB_INFO(menu_height) \
+                                 + (w)->VT100_TB_INFO(menu_border) * 2) \
+                                : 0)
+#else
+#define ToolbarHeight(w) 0
+#endif
+
+#if OPT_TEK4014
+#define TEK_LINK_BLOCK_SIZE 1024
+
+typedef struct Tek_Link
+{
+       struct Tek_Link *next;  /* pointer to next TekLink in list
+                                  NULL <=> this is last TekLink */
+       unsigned short fontsize;/* character size, 0-3 */
+       unsigned short count;   /* number of chars in data */
+       char *ptr;              /* current pointer into data */
+       char data [TEK_LINK_BLOCK_SIZE];
+} TekLink;
+#endif /* OPT_TEK4014 */
+
+/* flags for cursors */
+#define        OFF             0
+#define        ON              1
+#define        BLINKED_OFF     2
+#define        CLEAR           0
+#define        TOGGLE          1
+
+/* flags for inhibit */
+#ifdef ALLOWLOGGING
+#define        I_LOG           0x01
+#endif
+#define        I_SIGNAL        0x02
+#define        I_TEK           0x04
+
+/***====================================================================***/
+
+#if OPT_TRACE
+#undef NDEBUG                  /* turn on assert's */
+#else
+#ifndef NDEBUG
+#define NDEBUG                 /* not debugging, don't do assert's */
+#endif
+#endif
+
+#include <trace.h>
+
+#ifndef TRACE
+#define TRACE(p) /*nothing*/
+#endif
+
+#ifndef TRACE_CLOSE
+#define TRACE_CLOSE() /*nothing*/
+#endif
+
+#ifndef TRACE_ARGV
+#define TRACE_ARGV(tag,argv) /*nothing*/
+#endif
+
+#ifndef TRACE_CHILD
+#define TRACE_CHILD /*nothing*/
+#endif
+
+#ifndef TRACE_FOCUS
+#define TRACE_FOCUS(w,e) /*nothing*/
+#endif
+
+#ifndef TRACE_HINTS
+#define TRACE_HINTS(hints) /*nothing*/
+#endif
+
+#ifndef TRACE_IDS
+#define TRACE_IDS /*nothing*/
+#endif
+
+#ifndef TRACE_OPTS
+#define TRACE_OPTS(opts,ress,lens) /*nothing*/
+#endif
+
+#ifndef TRACE_TRANS
+#define TRACE_TRANS(name,w) /*nothing*/
+#endif
+
+#ifndef TRACE_WM_HINTS
+#define TRACE_WM_HINTS(w) /*nothing*/
+#endif
+
+#ifndef TRACE_XRES
+#define TRACE_XRES() /*nothing*/
+#endif
+
+#ifndef TRACE2
+#define TRACE2(p) /*nothing*/
+#endif
+
+/* *INDENT-ON* */
+
+#endif /* included_ptyx_h */
diff --git a/resize.c b/resize.c
new file mode 100644 (file)
index 0000000..20cef5e
--- /dev/null
+++ b/resize.c
@@ -0,0 +1,583 @@
+/* $XTermId: resize.c,v 1.114 2010/05/23 16:04:32 tom Exp $ */
+
+/*
+ * Copyright 2003-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* resize.c */
+
+#include <xterm.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <xstrings.h>
+#include <xtermcap.h>
+#include <xterm_io.h>
+
+#ifdef APOLLO_SR9
+#define CANT_OPEN_DEV_TTY
+#endif
+
+#ifndef USE_TERMINFO           /* avoid conflict with configure script */
+#if defined(__QNX__) || defined(__SCO__) || defined(linux) || defined(__OpenBSD__) || defined(__UNIXWARE__)
+#define USE_TERMINFO
+#endif
+#endif
+
+#if defined(__QNX__)
+#include <unix.h>
+#endif
+
+/*
+ * Some OS's may want to use both, like SCO for example.  We catch here anyone
+ * who hasn't decided what they want.
+ */
+#if !defined(USE_TERMCAP) && !defined(USE_TERMINFO)
+#define USE_TERMINFO
+#endif
+
+#include <signal.h>
+#include <pwd.h>
+
+#ifdef USE_IGNORE_RC
+int ignore_unused;
+#endif
+
+#ifdef X_NOT_POSIX
+#if !defined(SYSV) && !defined(i386)
+extern struct passwd *getpwuid();      /* does ANYBODY need this? */
+#endif /* SYSV && i386 */
+#endif /* X_NOT_POSIX */
+
+#ifdef __MVS__
+#define ESCAPE(string) "\047" string
+#else
+#define ESCAPE(string) "\033" string
+#endif
+
+#define        EMULATIONS      2
+#define        SUN             1
+#define        VT100           0
+
+#define        TIMEOUT         10
+
+#define        SHELL_UNKNOWN   0
+#define        SHELL_C         1
+#define        SHELL_BOURNE    2
+/* *INDENT-OFF* */
+static struct {
+    const char *name;
+    int type;
+} shell_list[] = {
+    { "csh",   SHELL_C },      /* vanilla cshell */
+    { "tcsh",   SHELL_C },
+    { "jcsh",   SHELL_C },
+    { "sh",    SHELL_BOURNE }, /* vanilla Bourne shell */
+    { "ksh",   SHELL_BOURNE }, /* Korn shell (from AT&T toolchest) */
+    { "ksh-i", SHELL_BOURNE }, /* other name for latest Korn shell */
+    { "bash",  SHELL_BOURNE }, /* GNU Bourne again shell */
+    { "jsh",    SHELL_BOURNE },
+    { NULL,    SHELL_BOURNE }  /* default (same as xterm's) */
+};
+/* *INDENT-ON* */
+
+static const char *emuname[EMULATIONS] =
+{
+    "VT100",
+    "Sun",
+};
+static char *myname;
+static int shell_type = SHELL_UNKNOWN;
+static const char *getsize[EMULATIONS] =
+{
+    ESCAPE("7") ESCAPE("[r") ESCAPE("[999;999H") ESCAPE("[6n"),
+    ESCAPE("[18t"),
+};
+#if defined(USE_STRUCT_TTYSIZE)
+#elif defined(USE_STRUCT_WINSIZE)
+static const char *getwsize[EMULATIONS] =
+{                              /* size in pixels */
+    0,
+    ESCAPE("[14t"),
+};
+#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */
+static const char *restore[EMULATIONS] =
+{
+    ESCAPE("8"),
+    0,
+};
+static const char *setname = "";
+static const char *setsize[EMULATIONS] =
+{
+    0,
+    ESCAPE("[8;%s;%st"),
+};
+
+#ifdef USE_ANY_SYSV_TERMIO
+static struct termio tioorig;
+#elif defined(USE_TERMIOS)
+static struct termios tioorig;
+#else
+static struct sgttyb sgorig;
+#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
+
+static const char *size[EMULATIONS] =
+{
+    ESCAPE("[%d;%dR"),
+    ESCAPE("[8;%d;%dt"),
+};
+static char sunname[] = "sunsize";
+static int tty;
+static FILE *ttyfp;
+
+#if defined(USE_STRUCT_TTYSIZE)
+#elif defined(USE_STRUCT_WINSIZE)
+static const char *wsize[EMULATIONS] =
+{
+    0,
+    ESCAPE("[4;%hd;%hdt"),
+};
+#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */
+
+static SIGNAL_T onintr(int sig);
+static SIGNAL_T resize_timeout(int sig);
+static int checkdigits(char *str);
+static void Usage(void);
+static void readstring(FILE *fp, char *buf, const char *str);
+
+#ifdef USE_TERMCAP
+static void
+print_termcap(const char *termcap)
+{
+    int ch;
+
+    putchar('\'');
+    while ((ch = *termcap++) != '\0') {
+       switch (ch & 0xff) {
+       case 127:               /* undo bug in GNU termcap */
+           printf("^?");
+           break;
+       case '\'':              /* must escape anyway (unlikely) */
+           /* FALLTHRU */
+       case '!':               /* must escape for SunOS csh */
+           putchar('\\');
+           /* FALLTHRU */
+       default:
+           putchar(ch);
+           break;
+       }
+    }
+    putchar('\'');
+}
+#endif /* USE_TERMCAP */
+
+/*
+   resets termcap string to reflect current screen size
+ */
+int
+main(int argc, char **argv ENVP_ARG)
+{
+#ifdef USE_TERMCAP
+    char *env;
+#endif
+    char *ptr;
+    int emu = VT100;
+    char *shell;
+    struct passwd *pw;
+    int i;
+    int rows, cols;
+#ifdef USE_ANY_SYSV_TERMIO
+    struct termio tio;
+#elif defined(USE_TERMIOS)
+    struct termios tio;
+#else
+    struct sgttyb sg;
+#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
+#ifdef USE_TERMCAP
+    int ok_tcap = 1;
+    char termcap[TERMCAP_SIZE];
+    char newtc[TERMCAP_SIZE];
+#endif /* USE_TERMCAP */
+    char buf[BUFSIZ];
+#ifdef TTYSIZE_STRUCT
+    TTYSIZE_STRUCT ts;
+#endif
+    char *name_of_tty;
+#ifdef CANT_OPEN_DEV_TTY
+    extern char *ttyname();
+#endif
+
+    myname = x_basename(argv[0]);
+    if (strcmp(myname, sunname) == 0)
+       emu = SUN;
+    for (argv++, argc--; argc > 0 && **argv == '-'; argv++, argc--) {
+       switch ((*argv)[1]) {
+       case 's':               /* Sun emulation */
+           if (emu == SUN)
+               Usage();        /* Never returns */
+           emu = SUN;
+           break;
+       case 'u':               /* Bourne (Unix) shell */
+           shell_type = SHELL_BOURNE;
+           break;
+       case 'c':               /* C shell */
+           shell_type = SHELL_C;
+           break;
+       default:
+           Usage();            /* Never returns */
+       }
+    }
+
+    if (SHELL_UNKNOWN == shell_type) {
+       /* Find out what kind of shell this user is running.
+        * This is the same algorithm that xterm uses.
+        */
+       if (((ptr = x_getenv("SHELL")) == NULL) &&
+           (((pw = getpwuid(getuid())) == NULL) ||
+            *(ptr = pw->pw_shell) == 0))
+           /* this is the same default that xterm uses */
+           ptr = x_strdup("/bin/sh");
+
+       shell = x_basename(ptr);
+
+       /* now that we know, what kind is it? */
+       for (i = 0; shell_list[i].name; i++)
+           if (!strcmp(shell_list[i].name, shell))
+               break;
+       shell_type = shell_list[i].type;
+    }
+
+    if (argc == 2) {
+       if (!setsize[emu]) {
+           fprintf(stderr,
+                   "%s: Can't set window size under %s emulation\n",
+                   myname, emuname[emu]);
+           exit(1);
+       }
+       if (!checkdigits(argv[0]) || !checkdigits(argv[1]))
+           Usage();            /* Never returns */
+    } else if (argc != 0)
+       Usage();                /* Never returns */
+
+#ifdef CANT_OPEN_DEV_TTY
+    if ((name_of_tty = ttyname(fileno(stderr))) == NULL)
+#endif
+       name_of_tty = x_strdup("/dev/tty");
+
+    if ((ttyfp = fopen(name_of_tty, "r+")) == NULL) {
+       fprintf(stderr, "%s:  can't open terminal %s\n",
+               myname, name_of_tty);
+       exit(1);
+    }
+    tty = fileno(ttyfp);
+#ifdef USE_TERMCAP
+    if ((env = x_getenv("TERM")) == 0) {
+       env = DFT_TERMTYPE;
+       if (SHELL_BOURNE == shell_type)
+           setname = "TERM=" DFT_TERMTYPE ";\nexport TERM;\n";
+       else
+           setname = "setenv TERM " DFT_TERMTYPE ";\n";
+    }
+    termcap[0] = 0;            /* ...just in case we've accidentally gotten terminfo */
+    if (tgetent(termcap, env) <= 0 || termcap[0] == 0)
+       ok_tcap = 0;
+#endif /* USE_TERMCAP */
+#ifdef USE_TERMINFO
+    if (x_getenv("TERM") == 0) {
+       if (SHELL_BOURNE == shell_type)
+           setname = "TERM=" DFT_TERMTYPE ";\nexport TERM;\n";
+       else
+           setname = "setenv TERM " DFT_TERMTYPE ";\n";
+    }
+#endif /* USE_TERMINFO */
+
+#ifdef USE_ANY_SYSV_TERMIO
+    ioctl(tty, TCGETA, &tioorig);
+    tio = tioorig;
+    UIntClr(tio.c_iflag, (ICRNL | IUCLC));
+    UIntClr(tio.c_lflag, (ICANON | ECHO));
+    tio.c_cflag |= CS8;
+    tio.c_cc[VMIN] = 6;
+    tio.c_cc[VTIME] = 1;
+#elif defined(USE_TERMIOS)
+    tcgetattr(tty, &tioorig);
+    tio = tioorig;
+    UIntClr(tio.c_iflag, ICRNL);
+    UIntClr(tio.c_lflag, (ICANON | ECHO));
+    tio.c_cflag |= CS8;
+    tio.c_cc[VMIN] = 6;
+    tio.c_cc[VTIME] = 1;
+#else /* not USE_TERMIOS */
+    ioctl(tty, TIOCGETP, &sgorig);
+    sg = sgorig;
+    sg.sg_flags |= RAW;
+    UIntClr(sg.sg_flags, ECHO);
+#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
+    signal(SIGINT, onintr);
+    signal(SIGQUIT, onintr);
+    signal(SIGTERM, onintr);
+#ifdef USE_ANY_SYSV_TERMIO
+    ioctl(tty, TCSETAW, &tio);
+#elif defined(USE_TERMIOS)
+    tcsetattr(tty, TCSADRAIN, &tio);
+#else /* not USE_TERMIOS */
+    ioctl(tty, TIOCSETP, &sg);
+#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
+
+    if (argc == 2) {
+       char *tmpbuf = TypeMallocN(char,
+                                  strlen(setsize[emu]) +
+                                  strlen(argv[0]) +
+                                  strlen(argv[1]) +
+                                  1);
+       if (tmpbuf == 0) {
+           fprintf(stderr, "%s: Cannot query size\n", myname);
+           onintr(0);
+       } else {
+           sprintf(tmpbuf, setsize[emu], argv[0], argv[1]);
+           IGNORE_RC(write(tty, tmpbuf, strlen(tmpbuf)));
+           free(tmpbuf);
+       }
+    }
+    IGNORE_RC(write(tty, getsize[emu], strlen(getsize[emu])));
+    readstring(ttyfp, buf, size[emu]);
+    if (sscanf(buf, size[emu], &rows, &cols) != 2) {
+       fprintf(stderr, "%s: Can't get rows and columns\r\n", myname);
+       onintr(0);
+    }
+    if (restore[emu])
+       IGNORE_RC(write(tty, restore[emu], strlen(restore[emu])));
+#if defined(USE_STRUCT_TTYSIZE)
+    /* finally, set the tty's window size */
+    if (ioctl(tty, TIOCGSIZE, &ts) != -1) {
+       TTYSIZE_ROWS(ts) = rows;
+       TTYSIZE_COLS(ts) = cols;
+       SET_TTYSIZE(tty, ts);
+    }
+#elif defined(USE_STRUCT_WINSIZE)
+    /* finally, set the tty's window size */
+    if (getwsize[emu]) {
+       /* get the window size in pixels */
+       IGNORE_RC(write(tty, getwsize[emu], strlen(getwsize[emu])));
+       readstring(ttyfp, buf, wsize[emu]);
+       if (sscanf(buf, wsize[emu], &ts.ws_xpixel, &ts.ws_ypixel) != 2) {
+           fprintf(stderr, "%s: Can't get window size\r\n", myname);
+           onintr(0);
+       }
+       TTYSIZE_ROWS(ts) = (ttySize_t) rows;
+       TTYSIZE_COLS(ts) = (ttySize_t) cols;
+       SET_TTYSIZE(tty, ts);
+    } else if (ioctl(tty, TIOCGWINSZ, &ts) != -1) {
+       /* we don't have any way of directly finding out
+          the current height & width of the window in pixels.  We try
+          our best by computing the font height and width from the "old"
+          window-size values, and multiplying by these ratios... */
+       if (TTYSIZE_COLS(ts) != 0)
+           ts.ws_xpixel = (ttySize_t) (cols * (ts.ws_xpixel / TTYSIZE_COLS(ts)));
+       if (TTYSIZE_ROWS(ts) != 0)
+           ts.ws_ypixel = (ttySize_t) (rows * (ts.ws_ypixel / TTYSIZE_ROWS(ts)));
+       TTYSIZE_ROWS(ts) = (ttySize_t) rows;
+       TTYSIZE_COLS(ts) = (ttySize_t) cols;
+       SET_TTYSIZE(tty, ts);
+    }
+#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */
+
+#ifdef USE_ANY_SYSV_TERMIO
+    ioctl(tty, TCSETAW, &tioorig);
+#elif defined(USE_TERMIOS)
+    tcsetattr(tty, TCSADRAIN, &tioorig);
+#else /* not USE_TERMIOS */
+    ioctl(tty, TIOCSETP, &sgorig);
+#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
+    signal(SIGINT, SIG_DFL);
+    signal(SIGQUIT, SIG_DFL);
+    signal(SIGTERM, SIG_DFL);
+
+#ifdef USE_TERMCAP
+    if (ok_tcap) {
+       /* update termcap string */
+       /* first do columns */
+       if ((ptr = x_strindex(termcap, "co#")) == NULL) {
+           fprintf(stderr, "%s: No `co#'\n", myname);
+           exit(1);
+       }
+
+       i = ptr - termcap + 3;
+       strncpy(newtc, termcap, (size_t) i);
+       sprintf(newtc + i, "%d", cols);
+       ptr = strchr(ptr, ':');
+       strcat(newtc, ptr);
+
+       /* now do lines */
+       if ((ptr = x_strindex(newtc, "li#")) == NULL) {
+           fprintf(stderr, "%s: No `li#'\n", myname);
+           exit(1);
+       }
+
+       i = ptr - newtc + 3;
+       strncpy(termcap, newtc, (size_t) i);
+       sprintf(termcap + i, "%d", rows);
+       ptr = strchr(ptr, ':');
+       strcat(termcap, ptr);
+    }
+#endif /* USE_TERMCAP */
+
+    if (SHELL_BOURNE == shell_type) {
+
+#ifdef USE_TERMCAP
+       if (ok_tcap) {
+           printf("%sTERMCAP=", setname);
+           print_termcap(termcap);
+           printf(";\nexport TERMCAP;\n");
+       }
+#endif /* USE_TERMCAP */
+#ifdef USE_TERMINFO
+       printf("%sCOLUMNS=%d;\nLINES=%d;\nexport COLUMNS LINES;\n",
+              setname, cols, rows);
+#endif /* USE_TERMINFO */
+
+    } else {                   /* not Bourne shell */
+
+#ifdef USE_TERMCAP
+       if (ok_tcap) {
+           printf("set noglob;\n%ssetenv TERMCAP ", setname);
+           print_termcap(termcap);
+           printf(";\nunset noglob;\n");
+       }
+#endif /* USE_TERMCAP */
+#ifdef USE_TERMINFO
+       printf("set noglob;\n%ssetenv COLUMNS '%d';\nsetenv LINES '%d';\nunset noglob;\n",
+              setname, cols, rows);
+#endif /* USE_TERMINFO */
+    }
+    exit(0);
+}
+
+static int
+checkdigits(char *str)
+{
+    while (*str) {
+       if (!isdigit(CharOf(*str)))
+           return (0);
+       str++;
+    }
+    return (1);
+}
+
+static void
+readstring(FILE *fp, char *buf, const char *str)
+{
+    int last, c;
+#if !defined(USG) && !defined(__UNIXOS2__)
+    /* What is the advantage of setitimer() over alarm()? */
+    struct itimerval it;
+#endif
+
+    signal(SIGALRM, resize_timeout);
+#if defined(USG) || defined(__UNIXOS2__)
+    alarm(TIMEOUT);
+#else
+    memset((char *) &it, 0, sizeof(struct itimerval));
+    it.it_value.tv_sec = TIMEOUT;
+    setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);
+#endif
+    if ((c = getc(fp)) == 0233) {      /* meta-escape, CSI */
+       c = ESCAPE("")[0];
+       *buf++ = (char) c;
+       *buf++ = '[';
+    } else {
+       *buf++ = (char) c;
+    }
+    if (c != *str) {
+       fprintf(stderr, "%s: unknown character, exiting.\r\n", myname);
+       onintr(0);
+    }
+    last = str[strlen(str) - 1];
+    while ((*buf++ = (char) getc(fp)) != last) {
+       ;
+    }
+#if defined(USG) || defined(__UNIXOS2__)
+    alarm(0);
+#else
+    memset((char *) &it, 0, sizeof(struct itimerval));
+    setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);
+#endif
+    *buf = 0;
+}
+
+static void
+Usage(void)
+{
+    fprintf(stderr, strcmp(myname, sunname) == 0 ?
+           "Usage: %s [rows cols]\n" :
+           "Usage: %s [-u] [-c] [-s [rows cols]]\n", myname);
+    exit(1);
+}
+
+static SIGNAL_T
+resize_timeout(int sig)
+{
+    fprintf(stderr, "\n%s: Time out occurred\r\n", myname);
+    onintr(sig);
+}
+
+/* ARGSUSED */
+static SIGNAL_T
+onintr(int sig GCC_UNUSED)
+{
+#ifdef USE_ANY_SYSV_TERMIO
+    ioctl(tty, TCSETAW, &tioorig);
+#elif defined(USE_TERMIOS)
+    tcsetattr(tty, TCSADRAIN, &tioorig);
+#else /* not USE_TERMIOS */
+    ioctl(tty, TIOCSETP, &sgorig);
+#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
+    exit(1);
+}
diff --git a/resize.man b/resize.man
new file mode 100644 (file)
index 0000000..56d95d1
--- /dev/null
@@ -0,0 +1,91 @@
+.\" $XTermId: resize.man,v 1.17 2009/04/11 17:43:39 tom Exp $
+.\"
+.\" updated by Thomas E. Dickey for XFree86, 1998-2006.
+.\"
+.\" $XFree86: xc/programs/xterm/resize.man,v 1.12 2006/02/13 01:14:59 dickey Exp $
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds AQ \(aq
+.el       .ds AQ '
+.ie \n(.g .ds `` \(lq
+.el       .ds `` ``
+.ie \n(.g .ds '' \(rq
+.el       .ds '' ''
+.TH RESIZE 1 __vendorversion__
+.SH NAME
+resize \- set TERMCAP and terminal settings to current xterm window size
+.SH SYNOPSIS
+.B resize
+[ \fB\-u\fP | \fB\-c\fP ] [ \fB\-s\fP [ \fIrow col\fP ] ]
+.SH DESCRIPTION
+.I Resize
+prints a shell command for setting the TERM and TERMCAP environment variables
+to indicate the current size of \fIxterm\fP window from which the command
+is run.  For this output to take effect, \fIresize\fP must either be evaluated
+as part of the command line (usually done with a shell alias or function) or
+else redirected to a file which can then be read in.  From the C shell (usually
+known as \fI/bin/csh\fP), the following alias could be defined in the 
+user's \fI.cshrc\fP:
+.sp
+.nf
+        %  alias rs \*(AQset noglob; eval \fC\`\fPresize\fC\`\fP\*(AQ
+.fi
+.sp
+After resizing the window, the user would type:
+.sp
+.nf
+        %  rs
+.fi
+.sp
+Users of versions of the Bourne shell (usually known as \fI/bin/sh\fP) that 
+don't have command
+functions will need to send the output to a temporary file and then read it back
+in with the \*(``.\*('' command:
+.sp
+.nf
+        $  resize > /tmp/out
+        $  .\0/tmp/out
+.fi
+.SH OPTIONS
+The following options may be used with \fIresize\fP:
+.TP 8
+.B \-u
+This option indicates that Bourne shell commands should be generated even if 
+the user's current shell isn't \fI/bin/sh\fP.
+.TP 8
+.B \-c
+This option indicates that C shell commands should be generated even if the
+user's current shell isn't \fI/bin/csh\fP.
+.TP 8
+.B \-s \fR[\fIrows columns\fP]
+This option indicates that Sun console escape sequences will be used 
+instead of the VT100-style \fIxterm\fP escape codes.
+If \fIrows\fP and
+\fIcolumns\fP are given, \fIresize\fP will ask the \fIxterm\fP to resize
+itself.  However, the window manager may choose to disallow the change.
+.sp
+Note that the Sun console escape sequences are recognized
+by XFree86 \fIxterm\fP and
+by \fIdtterm\fP.
+The \fIresize\fP program may be installed as \fIsunsize\fP,
+which causes makes it assume the \fB\-s\fP option.
+.sp
+The \fIrows\fP and
+\fIcolumns\fP arguments must appear last; though they are normally
+associated with the \fB\-s\fP option, they are parsed separately.
+.SH FILES
+.TP 15
+/etc/termcap
+for the base termcap entry to modify.
+.TP 15
+~/.cshrc
+user's alias for the command.
+.SH "SEE ALSO"
+csh(1), tset(1), xterm(__mansuffix__)
+.SH AUTHORS
+Mark Vandevoorde (MIT-Athena), Edward Moy (Berkeley)
+.br
+Copyright (c) 1984, 1985 by X Consortium
+.br
+See
+.IR X (__miscmansuffix__)
+for a complete copyright notice.
diff --git a/run-tic.sh b/run-tic.sh
new file mode 100755 (executable)
index 0000000..1a224d5
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+# $XTermId: run-tic.sh,v 1.4 2007/06/17 15:30:03 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2006,2007 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# Run tic, either using ncurses' extension feature or filtering out harmless
+# messages for the extensions which are otherwise ignored by other versions of
+# tic.
+
+TMP=run-tic$$.log
+VER=`tic -V 2>/dev/null`
+OPT=
+
+case .$VER in
+.ncurses*)
+       OPT="-x"
+       ;;
+esac
+
+echo "** tic $OPT" "$@"
+tic $OPT "$@" 2>$TMP
+RET=$?
+
+fgrep -v 'Unknown Capability' $TMP | \
+fgrep -v 'Capability is not recognized:' | \
+fgrep -v 'tic: Warning near line ' >&2
+rm -f $TMP
+
+exit $RET
diff --git a/screen.c b/screen.c
new file mode 100644 (file)
index 0000000..dbe1f48
--- /dev/null
+++ b/screen.c
@@ -0,0 +1,2574 @@
+/* $XTermId: screen.c,v 1.431 2011/02/09 09:57:05 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* screen.c */
+
+#include <stdio.h>
+#include <xterm.h>
+#include <error.h>
+#include <data.h>
+#include <xcharmouse.h>
+#include <xterm_io.h>
+
+#if OPT_WIDE_CHARS
+#include <fontutils.h>
+#include <menu.h>
+#endif
+
+#include <assert.h>
+#include <signal.h>
+
+#define inSaveBuf(screen, buf, inx) \
+       ((buf) == (screen)->saveBuf_index && \
+        ((inx) < (screen)->savelines || (screen)->savelines == 0))
+
+#define getMinRow(screen) ((xw->flags & ORIGIN) ? (screen)->top_marg : 0)
+#define getMaxRow(screen) ((xw->flags & ORIGIN) ? (screen)->bot_marg : (screen)->max_row)
+#define getMinCol(screen) 0
+#define getMaxCol(screen) ((screen)->max_col)
+
+#define MoveLineData(base, dst, src, len) \
+       memmove(scrnHeadAddr(screen, base, (unsigned) (dst)), \
+               scrnHeadAddr(screen, base, (unsigned) (src)), \
+               (size_t) scrnHeadSize(screen, (unsigned) (len)))
+
+#define SaveLineData(base, src, len) \
+       (void) ScrnPointers(screen, len); \
+       memcpy (screen->save_ptr, \
+               scrnHeadAddr(screen, base, src), \
+               (size_t) scrnHeadSize(screen, (unsigned) (len)))
+
+#define RestoreLineData(base, dst, len) \
+       memcpy (scrnHeadAddr(screen, base, dst), \
+               screen->save_ptr, \
+               (size_t) scrnHeadSize(screen, (unsigned) (len)))
+
+#if OPT_SAVE_LINES
+#define VisBuf(screen) screen->editBuf_index[screen->whichBuf]
+#else
+#define VisBuf(screen) scrnHeadAddr(screen, screen->saveBuf_index, (unsigned) savelines)
+#endif
+
+/*
+ * ScrnPtr's can point to different types of data.
+ */
+#define SizeofScrnPtr(name) \
+       (unsigned) sizeof(*((LineData *)0)->name)
+
+/*
+ * The pointers in LineData point into a block of text allocated as a single
+ * chunk for the given number of rows.  Ensure that these pointers are aligned
+ * at least to int-boundaries.
+ */
+#define AlignMask()      (sizeof(int) - 1)
+#define IsAligned(value) (((unsigned long) (value) & AlignMask()) == 0)
+
+#define AlignValue(value) \
+               if (!IsAligned(value)) \
+                   value = (value | (unsigned) AlignMask()) + 1
+
+#define SetupScrnPtr(dst,src,type) \
+               dst = (type *) (void *) src; \
+               assert(IsAligned(dst)); \
+               src += skipNcol##type
+
+#define ScrnBufAddr(ptrs, offset)  (ScrnBuf)    ((void *) ((char *) (ptrs) + (offset)))
+#define LineDataAddr(ptrs, offset) (LineData *) ((void *) ((char *) (ptrs) + (offset)))
+
+#if OPT_TRACE > 1
+static void
+traceScrnBuf(const char *tag, TScreen * screen, ScrnBuf sb, unsigned len)
+{
+    unsigned j;
+
+    TRACE(("traceScrnBuf %s\n", tag));
+    for (j = 0; j < len; ++j) {
+       LineData *src = (LineData *) scrnHeadAddr(screen, sb, j);
+       TRACE(("%p %s%3d:%s\n",
+              src, ((int) j >= screen->savelines) ? "*" : " ",
+              j, visibleIChars(src->charData, src->lineSize)));
+    }
+    TRACE(("...traceScrnBuf %s\n", tag));
+}
+
+#define TRACE_SCRNBUF(tag, screen, sb, len) traceScrnBuf(tag, screen, sb, len)
+#else
+#define TRACE_SCRNBUF(tag, screen, sb, len)    /*nothing */
+#endif
+
+static unsigned
+scrnHeadSize(TScreen * screen, unsigned count)
+{
+    unsigned result = SizeOfLineData;
+
+    (void) screen;
+
+#if OPT_WIDE_CHARS
+    if (screen->wide_chars) {
+       result += (unsigned) screen->lineExtra;
+    }
+#endif
+    result *= count;
+
+    return result;
+}
+
+ScrnBuf
+scrnHeadAddr(TScreen * screen, ScrnBuf base, unsigned offset)
+{
+    unsigned size = scrnHeadSize(screen, offset);
+    ScrnBuf result = ScrnBufAddr(base, size);
+
+    assert((int) offset >= 0);
+
+    return result;
+}
+
+/*
+ * Given a block of data, build index to it in the 'base' parameter.
+ */
+void
+setupLineData(TScreen * screen, ScrnBuf base, Char * data, unsigned nrow, unsigned ncol)
+{
+    unsigned i;
+    unsigned offset = 0;
+    unsigned jump = scrnHeadSize(screen, 1);
+    LineData *ptr;
+#if OPT_WIDE_CHARS
+    unsigned j;
+#endif
+    /* these names are based on types */
+    unsigned skipNcolChar = (ncol * SizeofScrnPtr(attribs));
+    unsigned skipNcolCharData = (ncol * SizeofScrnPtr(charData));
+#if OPT_ISO_COLORS
+    unsigned skipNcolCellColor = (ncol * SizeofScrnPtr(color));
+#endif
+
+    AlignValue(skipNcolChar);
+#if OPT_ISO_COLORS
+    AlignValue(skipNcolCellColor);
+#endif
+    AlignValue(skipNcolCharData);
+
+    for (i = 0; i < nrow; i++, offset += jump) {
+       ptr = LineDataAddr(base, offset);
+
+       ptr->lineSize = (Dimension) ncol;
+       ptr->bufHead = 0;
+#if OPT_DEC_CHRSET
+       SetLineDblCS(ptr, 0);
+#endif
+       SetupScrnPtr(ptr->attribs, data, Char);
+#if OPT_ISO_COLORS
+       SetupScrnPtr(ptr->color, data, CellColor);
+#endif
+       SetupScrnPtr(ptr->charData, data, CharData);
+#if OPT_WIDE_CHARS
+       if (screen->wide_chars) {
+           unsigned extra = (unsigned) screen->max_combining;
+
+           ptr->combSize = (Char) extra;
+           for (j = 0; j < extra; ++j) {
+               SetupScrnPtr(ptr->combData[j], data, CharData);
+           }
+       }
+#endif
+    }
+}
+
+#define ExtractScrnData(name) \
+               memcpy(dstPtrs->name, \
+                      ((LineData *) srcPtrs)->name,\
+                      dstCols * sizeof(dstPtrs->name[0])); \
+               nextPtr += (srcCols * sizeof(dstPtrs->name[0]))
+
+/*
+ * As part of reallocating the screen buffer when resizing, extract from
+ * the old copy of the screen buffer the data which will be used in the
+ * new copy of the screen buffer.
+ */
+static void
+extractScrnData(TScreen * screen,
+               ScrnBuf dstPtrs,
+               ScrnBuf srcPtrs,
+               unsigned nrows,
+               unsigned move_down)
+{
+    unsigned j;
+
+    TRACE(("extractScrnData(nrows %d)\n", nrows));
+
+    TRACE_SCRNBUF("extract from", screen, srcPtrs, nrows);
+    for (j = 0; j < nrows; j++) {
+       LineData *dst = (LineData *) scrnHeadAddr(screen,
+                                                 dstPtrs, j + move_down);
+       LineData *src = (LineData *) scrnHeadAddr(screen,
+                                                 srcPtrs, j);
+       copyLineData(dst, src);
+    }
+}
+
+static ScrnPtr *
+allocScrnHead(TScreen * screen, unsigned nrow)
+{
+    ScrnPtr *result;
+    unsigned size = scrnHeadSize(screen, 1);
+
+    result = (ScrnPtr *) calloc((size_t) nrow, (size_t) size);
+    if (result == 0)
+       SysError(ERROR_SCALLOC);
+
+    TRACE(("allocScrnHead %d -> %d -> %p..%p\n", nrow, nrow * size,
+          (void *) result,
+          (char *) result + (nrow * size) - 1));
+    return result;
+}
+
+/*
+ * Return the size of a line's data.
+ */
+static unsigned
+sizeofScrnRow(TScreen * screen, unsigned ncol)
+{
+    unsigned result;
+    unsigned sizeAttribs;
+#if OPT_ISO_COLORS
+    unsigned sizeColors;
+#endif
+
+    (void) screen;
+
+    result = (ncol * (unsigned) sizeof(CharData));
+    AlignValue(result);
+
+#if OPT_WIDE_CHARS
+    if (screen->wide_chars) {
+       result *= (unsigned) (1 + screen->max_combining);
+    }
+#endif
+
+    sizeAttribs = (ncol * SizeofScrnPtr(attribs));
+    AlignValue(sizeAttribs);
+    result += sizeAttribs;
+
+#if OPT_ISO_COLORS
+    sizeColors = (ncol * SizeofScrnPtr(color));
+    AlignValue(sizeColors);
+    result += sizeColors;
+#endif
+
+    return result;
+}
+
+Char *
+allocScrnData(TScreen * screen, unsigned nrow, unsigned ncol)
+{
+    Char *result;
+    size_t length = (nrow * sizeofScrnRow(screen, ncol));
+
+    if ((result = (Char *) calloc(length, sizeof(Char))) == 0)
+       SysError(ERROR_SCALLOC2);
+
+    TRACE(("allocScrnData %ux%u -> %lu -> %p..%p\n",
+          nrow, ncol, (unsigned long) length, result, result + length - 1));
+    return result;
+}
+
+/*
+ * Allocates memory for a 2-dimensional array of chars and returns a pointer
+ * thereto.  Each line is formed from a set of char arrays, with an index
+ * (i.e., the ScrnBuf type).  The first pointer in the index is reserved for
+ * per-line flags, and does not point to data.
+ *
+ * After the per-line flags, we have a series of pointers to char arrays:  The
+ * first one is the actual character array, the second one is the attributes,
+ * the third is the foreground and background colors, and the fourth denotes
+ * the character set.
+ *
+ * We store it all as pointers, because of alignment considerations.
+ */
+ScrnBuf
+allocScrnBuf(XtermWidget xw, unsigned nrow, unsigned ncol, Char ** addr)
+{
+    TScreen *screen = TScreenOf(xw);
+    ScrnBuf base = 0;
+
+    if (nrow != 0) {
+       base = allocScrnHead(screen, nrow);
+       *addr = allocScrnData(screen, nrow, ncol);
+
+       setupLineData(screen, base, *addr, nrow, ncol);
+    }
+
+    TRACE(("allocScrnBuf %dx%d ->%p\n", nrow, ncol, (void *) base));
+    return (base);
+}
+
+#if OPT_SAVE_LINES
+/*
+ * Copy line-data from the visible (edit) buffer to the save-lines buffer.
+ */
+static void
+saveEditBufLines(TScreen * screen, ScrnBuf sb, unsigned n)
+{
+    unsigned j;
+
+    TRACE(("...copying %d lines from editBuf to saveBuf\n", n));
+#if OPT_FIFO_LINES
+    (void) sb;
+#endif
+    for (j = 0; j < n; ++j) {
+#if OPT_FIFO_LINES
+       LineData *dst = addScrollback(screen);
+#else
+       unsigned k = (screen->savelines + j - n);
+       LineData *dst = (LineData *) scrnHeadAddr(screen, sb, k);
+#endif
+       LineData *src = getLineData(screen, (int) j);
+       copyLineData(dst, src);
+    }
+}
+
+/*
+ * Copy line-data from the save-lines buffer to the visible (edit) buffer.
+ */
+static void
+unsaveEditBufLines(TScreen * screen, ScrnBuf sb, unsigned n)
+{
+    unsigned j;
+
+    TRACE(("...copying %d lines from saveBuf to editBuf\n", n));
+    for (j = 0; j < n; ++j) {
+       int extra = (int) (n - j);
+       LineData *dst = (LineData *) scrnHeadAddr(screen, sb, j);
+#if OPT_FIFO_LINES
+       LineData *src;
+
+       if ((screen->saved_fifo - extra) <= 0) {
+           TRACE(("...FIXME: must clear text!\n"));
+           continue;
+       }
+       src = getScrollback(screen, -extra);
+#else
+       unsigned k = (screen->savelines - extra);
+       LineData *src = (LineData *) scrnHeadAddr(screen,
+                                                 screen->saveBuf_index, k);
+#endif
+       copyLineData(dst, src);
+    }
+}
+#endif
+
+/*
+ *  This is called when the screen is resized.
+ *  Returns the number of lines the text was moved down (neg for up).
+ *  (Return value only necessary with SouthWestGravity.)
+ */
+static int
+Reallocate(XtermWidget xw,
+          ScrnBuf * sbuf,
+          Char ** sbufaddr,
+          unsigned nrow,
+          unsigned ncol,
+          unsigned oldrow)
+{
+    TScreen *screen = TScreenOf(xw);
+    ScrnBuf oldBufHead;
+    ScrnBuf newBufHead;
+    Char *newBufData;
+    unsigned minrows;
+    Char *oldBufData;
+    int move_down = 0, move_up = 0;
+
+    if (sbuf == NULL || *sbuf == NULL) {
+       return 0;
+    }
+
+    oldBufData = *sbufaddr;
+
+    TRACE(("Reallocate %dx%d -> %dx%d\n", oldrow, MaxCols(screen), nrow, ncol));
+
+    /*
+     * realloc sbuf, the pointers to all the lines.
+     * If the screen shrinks, remove lines off the top of the buffer
+     * if resizeGravity resource says to do so.
+     */
+    TRACE(("Check move_up, nrow %d vs oldrow %d (resizeGravity %s)\n",
+          nrow, oldrow,
+          BtoS(GravityIsSouthWest(xw))));
+    if (GravityIsSouthWest(xw)) {
+       if (nrow < oldrow) {
+           /* Remove lines off the top of the buffer if necessary. */
+           move_up = (int) (oldrow - nrow)
+               - (TScreenOf(xw)->max_row - TScreenOf(xw)->cur_row);
+           if (move_up < 0)
+               move_up = 0;
+           /* Overlapping move here! */
+           TRACE(("move_up %d\n", move_up));
+           if (move_up) {
+               ScrnBuf dst = *sbuf;
+               unsigned len = (unsigned) ((int) oldrow - move_up);
+
+               TRACE_SCRNBUF("before move_up", screen, dst, oldrow);
+               SaveLineData(dst, 0, (size_t) move_up);
+               MoveLineData(dst, 0, (size_t) move_up, len);
+               RestoreLineData(dst, len, (size_t) move_up);
+               TRACE_SCRNBUF("after move_up", screen, dst, oldrow);
+           }
+       }
+    }
+    oldBufHead = *sbuf;
+    *sbuf = allocScrnHead(screen, (unsigned) nrow);
+    newBufHead = *sbuf;
+
+    /*
+     * Create the new buffer space and copy old buffer contents there, line by
+     * line.
+     */
+    newBufData = allocScrnData(screen, nrow, ncol);
+    *sbufaddr = newBufData;
+
+    minrows = (oldrow < nrow) ? oldrow : nrow;
+    if (GravityIsSouthWest(xw)) {
+       if (nrow > oldrow) {
+           /* move data down to bottom of expanded screen */
+           move_down = Min((int) (nrow - oldrow), TScreenOf(xw)->savedlines);
+       }
+    }
+
+    setupLineData(screen, newBufHead, *sbufaddr, nrow, ncol);
+    extractScrnData(screen, newBufHead, oldBufHead, minrows,
+#if OPT_SAVE_LINES
+                   0
+#else
+                   (unsigned) move_down
+#endif
+       );
+    free(oldBufHead);
+
+    /* Now free the old data */
+    free(oldBufData);
+
+    TRACE(("...Reallocate %dx%d ->%p\n", nrow, ncol, (void *) newBufHead));
+    return move_down ? move_down : -move_up;   /* convert to rows */
+}
+
+#if OPT_WIDE_CHARS
+/*
+ * This function reallocates memory if changing the number of Buf offsets.
+ * The code is based on Reallocate().
+ */
+static void
+ReallocateBufOffsets(XtermWidget xw,
+                    ScrnBuf * sbuf,
+                    Char ** sbufaddr,
+                    unsigned nrow,
+                    unsigned ncol)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned i;
+    ScrnBuf newBufHead;
+    Char *oldBufData;
+    ScrnBuf oldBufHead;
+
+    unsigned old_jump = scrnHeadSize(screen, 1);
+    unsigned new_jump;
+    unsigned new_ptrs = 1 + (unsigned) (screen->max_combining);
+    unsigned dstCols = ncol;
+    unsigned srcCols = ncol;
+    LineData *dstPtrs;
+    LineData *srcPtrs;
+    Char *nextPtr;
+
+    assert(nrow != 0);
+    assert(ncol != 0);
+
+    oldBufData = *sbufaddr;
+    oldBufHead = *sbuf;
+
+    /*
+     * Allocate a new LineData array, retain the old one until we've copied
+     * the data that it points to, as well as non-pointer data, e.g., bufHead.
+     *
+     * Turn on wide-chars temporarily when constructing pointers, since that is
+     * used to decide whether to address the combData[] array, which affects
+     * the length of the LineData structure.
+     */
+    screen->wide_chars = True;
+
+    new_jump = scrnHeadSize(screen, 1);
+    newBufHead = allocScrnHead(screen, nrow);
+    *sbufaddr = allocScrnData(screen, nrow, ncol);
+    setupLineData(screen, newBufHead, *sbufaddr, nrow, ncol);
+
+    screen->wide_chars = False;
+
+    nextPtr = *sbufaddr;
+
+    srcPtrs = (LineData *) oldBufHead;
+    dstPtrs = (LineData *) newBufHead;
+    for (i = 0; i < nrow; i++) {
+       dstPtrs->bufHead = srcPtrs->bufHead;
+       ExtractScrnData(attribs);
+#if OPT_ISO_COLORS
+       ExtractScrnData(color);
+#endif
+       ExtractScrnData(charData);
+
+       nextPtr += ncol * new_ptrs;
+       srcPtrs = LineDataAddr(srcPtrs, old_jump);
+       dstPtrs = LineDataAddr(dstPtrs, new_jump);
+    }
+
+    /* Now free the old data */
+    free(oldBufData);
+    free(oldBufHead);
+
+    *sbuf = newBufHead;
+
+    TRACE(("ReallocateBufOffsets %dx%d ->%p\n", nrow, ncol, *sbufaddr));
+}
+
+#if OPT_FIFO_LINES
+/*
+ * Allocate a new FIFO index.
+ */
+static void
+ReallocateFifoIndex(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->savelines > 0 && screen->saveBuf_index != 0) {
+       ScrnBuf newBufHead;
+       LineData *dstPtrs;
+       LineData *srcPtrs;
+       unsigned i;
+       unsigned old_jump = scrnHeadSize(screen, 1);
+       unsigned new_jump;
+
+       screen->wide_chars = True;
+       newBufHead = allocScrnHead(screen, (unsigned) screen->savelines);
+       new_jump = scrnHeadSize(screen, 1);
+
+       srcPtrs = (LineData *) screen->saveBuf_index;
+       dstPtrs = (LineData *) newBufHead;
+
+       for (i = 0; i < (unsigned) screen->savelines; ++i) {
+           memcpy(dstPtrs, srcPtrs, SizeOfLineData);
+           srcPtrs = LineDataAddr(srcPtrs, old_jump);
+           dstPtrs = LineDataAddr(dstPtrs, new_jump);
+       }
+
+       screen->wide_chars = False;
+       free(screen->saveBuf_index);
+       screen->saveBuf_index = newBufHead;
+    }
+}
+#endif
+
+/*
+ * This function dynamically adds support for wide-characters.
+ */
+void
+ChangeToWide(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->wide_chars)
+       return;
+
+    TRACE(("ChangeToWide\n"));
+    if (xtermLoadWideFonts(xw, True)) {
+       int whichBuf = screen->whichBuf;
+
+#if !OPT_FIFO_LINES || !OPT_SAVE_LINES
+       int savelines = screen->scrollWidget ? screen->savelines : 0;
+
+       if (savelines < 0)
+           savelines = 0;
+#endif
+
+       /*
+        * If we're displaying the alternate screen, switch the pointers back
+        * temporarily so ReallocateBufOffsets() will operate on the proper
+        * data in the alternate buffer.
+        */
+       if (screen->whichBuf)
+           SwitchBufPtrs(screen, 0);
+
+#if OPT_SAVE_LINES
+#if OPT_FIFO_LINES
+       ReallocateFifoIndex(xw);
+#else
+       ReallocateBufOffsets(xw,
+                            &screen->saveBuf_index,
+                            &screen->saveBuf_data,
+                            (unsigned) savelines,
+                            (unsigned) MaxCols(screen));
+#endif
+       if (screen->editBuf_index[0]) {
+           ReallocateBufOffsets(xw,
+                                &screen->editBuf_index[0],
+                                &screen->editBuf_data[0],
+                                (unsigned) MaxRows(screen),
+                                (unsigned) MaxCols(screen));
+       }
+#else
+       ReallocateBufOffsets(xw,
+                            &screen->saveBuf_index,
+                            &screen->saveBuf_data,
+                            (unsigned) (MaxRows(screen) + savelines),
+                            (unsigned) MaxCols(screen));
+#endif
+       if (screen->editBuf_index[1]) {
+           ReallocateBufOffsets(xw,
+                                &screen->editBuf_index[1],
+                                &screen->editBuf_data[1],
+                                (unsigned) MaxRows(screen),
+                                (unsigned) MaxCols(screen));
+       }
+
+       screen->wide_chars = True;
+       screen->visbuf = VisBuf(screen);
+
+       /*
+        * Switch the pointers back before we start painting on the screen.
+        */
+       if (whichBuf)
+           SwitchBufPtrs(screen, whichBuf);
+
+       update_font_utf8_mode();
+       SetVTFont(xw, screen->menu_font_number, True, NULL);
+    }
+    TRACE(("...ChangeToWide\n"));
+}
+#endif
+
+/*
+ * Clear cells, no side-effects.
+ */
+void
+ClearCells(XtermWidget xw, int flags, unsigned len, int row, int col)
+{
+    if (len != 0) {
+       TScreen *screen = TScreenOf(xw);
+       LineData *ld;
+       unsigned n;
+
+       ld = getLineData(screen, row);
+
+       flags = (int) ((unsigned) flags | TERM_COLOR_FLAGS(xw));
+
+       for (n = 0; n < len; ++n)
+           ld->charData[(unsigned) col + n] = (CharData) ' ';
+
+       memset(ld->attribs + col, flags, (size_t) len);
+
+       if_OPT_ISO_COLORS(screen, {
+           CellColor p = xtermColorPair(xw);
+           for (n = 0; n < len; ++n) {
+               ld->color[(unsigned) col + n] = p;
+           }
+       });
+       if_OPT_WIDE_CHARS(screen, {
+           size_t off;
+           for_each_combData(off, ld) {
+               memset(ld->combData[off] + col, 0, (size_t) len * sizeof(CharData));
+           }
+       });
+    }
+}
+
+/*
+ * Clear data in the screen-structure (no I/O).
+ * Check for wide-character damage as well, clearing the damaged cells.
+ */
+void
+ScrnClearCells(XtermWidget xw, int row, int col, unsigned len)
+{
+#if OPT_WIDE_CHARS
+    TScreen *screen = TScreenOf(xw);
+#endif
+    int flags = 0;
+
+    if_OPT_WIDE_CHARS(screen, {
+       int kl;
+       int kr;
+
+       if (DamagedCells(screen, len, &kl, &kr, row, col)
+           && kr >= kl) {
+           ClearCells(xw, flags, (unsigned) (kr - kl + 1), row, kl);
+       }
+    });
+    ClearCells(xw, flags, len, row, col);
+}
+
+/*
+ * Disown the selection and repaint the area that is highlighted so it is no
+ * longer highlighted.
+ */
+void
+ScrnDisownSelection(XtermWidget xw)
+{
+    if (ScrnHaveSelection(TScreenOf(xw))) {
+       if (TScreenOf(xw)->keepSelection) {
+           UnhiliteSelection(xw);
+       } else {
+           DisownSelection(xw);
+       }
+    }
+}
+
+/*
+ * Writes str into buf at screen's current row and column.  Characters are set
+ * to match flags.
+ */
+void
+ScrnWriteText(XtermWidget xw,
+             IChar * str,
+             unsigned flags,
+             unsigned cur_fg_bg,
+             unsigned length)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    Char *attrs;
+    int avail = MaxCols(screen) - screen->cur_col;
+    IChar *chars;
+#if OPT_WIDE_CHARS
+    IChar starcol1;
+#endif
+    unsigned n;
+    unsigned real_width = visual_width(str, length);
+
+    (void) cur_fg_bg;
+
+    if (real_width + (unsigned) screen->cur_col > (unsigned) MaxCols(screen)) {
+       real_width = (unsigned) (MaxCols(screen) - screen->cur_col);
+    }
+
+    if (avail <= 0)
+       return;
+    if (length > (unsigned) avail)
+       length = (unsigned) avail;
+    if (length == 0 || real_width == 0)
+       return;
+
+    ld = getLineData(screen, screen->cur_row);
+
+    chars = ld->charData + screen->cur_col;
+    attrs = ld->attribs + screen->cur_col;
+
+#if OPT_WIDE_CHARS
+    starcol1 = *chars;
+#endif
+
+    /* write blanks if we're writing invisible text */
+    for (n = 0; n < length; ++n) {
+       if ((flags & INVISIBLE))
+           chars[n] = ' ';
+       else
+           chars[n] = str[n];
+    }
+
+#if OPT_BLINK_TEXT
+    if ((flags & BLINK) && !(screen->blink_as_bold)) {
+       LineSetBlinked(ld);
+    }
+#endif
+
+    if_OPT_WIDE_CHARS(screen, {
+
+       if (real_width != length) {
+           IChar *char1 = chars;
+           if (screen->cur_col
+               && starcol1 == HIDDEN_CHAR
+               && isWide((int) char1[-1])) {
+               char1[-1] = (CharData) ' ';
+           }
+           /* if we are overwriting the right hand half of a
+              wide character, make the other half vanish */
+           while (length) {
+               int ch = (int) str[0];
+
+               *char1++ = *str++;
+               length--;
+
+               if (isWide(ch)) {
+                   *char1++ = (CharData) HIDDEN_CHAR;
+               }
+           }
+
+           if (*char1 == HIDDEN_CHAR
+               && char1[-1] == HIDDEN_CHAR) {
+               *char1 = (CharData) ' ';
+           }
+           /* if we are overwriting the left hand half of a
+              wide character, make the other half vanish */
+       } else {
+           if (screen->cur_col
+               && starcol1 == HIDDEN_CHAR
+               && isWide((int) chars[-1])) {
+               chars[-1] = (CharData) ' ';
+           }
+           /* if we are overwriting the right hand half of a
+              wide character, make the other half vanish */
+           if (chars[length] == HIDDEN_CHAR
+               && isWide((int) chars[length - 1])) {
+               chars[length] = (CharData) ' ';
+           }
+       }
+    });
+
+    flags &= ATTRIBUTES;
+    flags |= CHARDRAWN;
+    memset(attrs, (Char) flags, (size_t) real_width);
+
+    if_OPT_WIDE_CHARS(screen, {
+       size_t off;
+       for_each_combData(off, ld) {
+           memset(ld->combData[off] + screen->cur_col,
+                  0,
+                  real_width * sizeof(CharData));
+       }
+    });
+    if_OPT_ISO_COLORS(screen, {
+       unsigned j;
+       for (j = 0; j < real_width; ++j)
+           ld->color[screen->cur_col + (int) j] = (CellColor) cur_fg_bg;
+    });
+
+    if_OPT_WIDE_CHARS(screen, {
+       screen->last_written_col = screen->cur_col + (int) real_width - 1;
+       screen->last_written_row = screen->cur_row;
+    });
+
+    if_OPT_XMC_GLITCH(screen, {
+       Resolve_XMC(xw);
+    });
+
+    return;
+}
+
+/*
+ * Saves pointers to the n lines beginning at sb + where, and clears the lines
+ */
+static void
+ScrnClearLines(XtermWidget xw, ScrnBuf sb, int where, unsigned n, unsigned size)
+{
+    TScreen *screen = TScreenOf(xw);
+    ScrnPtr *base;
+    unsigned jump = scrnHeadSize(screen, 1);
+    unsigned i;
+    LineData *work;
+    unsigned flags = TERM_COLOR_FLAGS(xw);
+#if OPT_ISO_COLORS
+    unsigned j;
+#endif
+
+    TRACE(("ScrnClearLines(%s:where %d, n %d, size %d)\n",
+          (sb == screen->saveBuf_index) ? "save" : "edit",
+          where, n, size));
+
+    assert(n != 0);
+    assert(size != 0);
+
+    /* save n lines at where */
+    SaveLineData(sb, (unsigned) where, (size_t) n);
+
+    /* clear contents of old rows */
+    base = screen->save_ptr;
+    for (i = 0; i < n; ++i) {
+       work = (LineData *) base;
+       work->bufHead = 0;
+#if OPT_DEC_CHRSET
+       SetLineDblCS(work, 0);
+#endif
+
+       memset(work->charData, 0, size * sizeof(CharData));
+       if (TERM_COLOR_FLAGS(xw)) {
+           memset(work->attribs, (int) flags, (size_t) size);
+#if OPT_ISO_COLORS
+           {
+               CellColor p = xtermColorPair(xw);
+               for (j = 0; j < size; ++j) {
+                   work->color[j] = p;
+               }
+           }
+#endif
+       } else {
+           memset(work->attribs, 0, (size_t) size);
+#if OPT_ISO_COLORS
+           memset(work->color, 0, size * sizeof(work->color[0]));
+#endif
+       }
+#if OPT_WIDE_CHARS
+       if (screen->wide_chars) {
+           size_t off;
+
+           for (off = 0; off < work->combSize; ++off) {
+               memset(work->combData[off], 0, size * sizeof(CharData));
+           }
+       }
+#endif
+       base = ScrnBufAddr(base, jump);
+    }
+}
+
+/*
+ * We're always ensured of having a visible buffer, but may not have saved
+ * lines.  Check the pointer that's sure to work.
+ */
+#if OPT_SAVE_LINES
+#define OkAllocBuf(screen) (screen->editBuf_index[0] != 0)
+#else
+#define OkAllocBuf(screen) (screen->saveBuf_index != 0)
+#endif
+
+void
+ScrnAllocBuf(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (!OkAllocBuf(screen)) {
+       int nrows = MaxRows(screen);
+#if !OPT_SAVE_LINES
+       int savelines = screen->scrollWidget ? screen->savelines : 0;
+#endif
+
+       TRACE(("ScrnAllocBuf %dx%d (%d)\n",
+              nrows, MaxCols(screen), screen->savelines));
+
+#if OPT_SAVE_LINES
+       if (screen->savelines != 0) {
+#if OPT_FIFO_LINES
+           /* for FIFO, we only need space for the index - addScrollback inits */
+           screen->saveBuf_index = allocScrnHead(screen,
+                                                 (unsigned) (screen->savelines));
+#else
+           screen->saveBuf_index = allocScrnBuf(xw,
+                                                (unsigned) screen->savelines,
+                                                (unsigned) MaxCols(screen),
+                                                &screen->saveBuf_data);
+#endif
+       } else {
+           screen->saveBuf_index = 0;
+       }
+       screen->editBuf_index[0] = allocScrnBuf(xw,
+                                               (unsigned) nrows,
+                                               (unsigned) MaxCols(screen),
+                                               &screen->editBuf_data[0]);
+#else /* !OPT_SAVE_LINES */
+       screen->saveBuf_index = allocScrnBuf(xw,
+                                            (unsigned) (nrows + screen->savelines),
+                                            (unsigned) (MaxCols(screen)),
+                                            &screen->saveBuf_data);
+#endif /* OPT_SAVE_LINES */
+       screen->visbuf = VisBuf(screen);
+    }
+    return;
+}
+
+size_t
+ScrnPointers(TScreen * screen, size_t len)
+{
+    size_t result = scrnHeadSize(screen, (unsigned) len);
+
+    if (result > screen->save_len) {
+       if (screen->save_len)
+           screen->save_ptr = (ScrnPtr *) realloc(screen->save_ptr, result);
+       else
+           screen->save_ptr = (ScrnPtr *) malloc(result);
+       screen->save_len = len;
+       if (screen->save_ptr == 0)
+           SysError(ERROR_SAVE_PTR);
+    }
+    TRACE2(("ScrnPointers %ld ->%p\n", (long) len, screen->save_ptr));
+    return result;
+}
+
+/*
+ * Inserts n blank lines at sb + where, treating last as a bottom margin.
+ */
+void
+ScrnInsertLine(XtermWidget xw, ScrnBuf sb, int last, int where, unsigned n)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned size = (unsigned) MaxCols(screen);
+
+    TRACE(("ScrnInsertLine(last %d, where %d, n %d, size %d)\n",
+          last, where, n, size));
+
+    assert(where >= 0);
+    assert(last >= (int) n);
+    assert(last >= where);
+
+    assert(n != 0);
+    assert(size != 0);
+
+    /* save n lines at bottom */
+    ScrnClearLines(xw, sb, (last -= (int) n - 1), n, size);
+
+    /*
+     * WARNING, overlapping copy operation.  Move down lines (pointers).
+     *
+     *   +----|---------|--------+
+     *
+     * is copied in the array to:
+     *
+     *   +--------|---------|----+
+     */
+    assert(last >= where);
+    /*
+     * This will never shift from the saveBuf to editBuf, so there is no need
+     * to handle that case.
+     */
+    MoveLineData(sb,
+                (unsigned) (where + (int) n),
+                (unsigned) where,
+                (unsigned) (last - where));
+
+    /* reuse storage for new lines at where */
+    RestoreLineData(sb, (unsigned) where, n);
+}
+
+/*
+ * Deletes n lines at sb + where, treating last as a bottom margin.
+ */
+void
+ScrnDeleteLine(XtermWidget xw, ScrnBuf sb, int last, int where, unsigned n)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned size = (unsigned) MaxCols(screen);
+
+    TRACE(("ScrnDeleteLine(%s:last %d, where %d, n %d, size %d)\n",
+          (sb == screen->saveBuf_index) ? "save" : "edit",
+          last, where, n, size));
+
+    assert(where >= 0);
+    assert(last >= where + (int) n - 1);
+
+    assert(n != 0);
+    assert(size != 0);
+
+    /* move up lines */
+    last -= ((int) n - 1);
+#if OPT_SAVE_LINES
+    if (inSaveBuf(screen, sb, where)) {
+#if !OPT_FIFO_LINES
+       int from = where + n;
+#endif
+
+       /* we shouldn't be editing the saveBuf, only scroll into it */
+       assert(last >= screen->savelines);
+
+       if (sb != 0) {
+#if OPT_FIFO_LINES
+           /* copy lines from editBuf to saveBuf (allocating as we go...) */
+           saveEditBufLines(screen, sb, n);
+#else
+           ScrnClearLines(xw, sb, where, n, size);
+
+           /* move the pointers within saveBuf */
+           TRACE(("...%smoving pointers in saveBuf (compare %d %d)\n",
+                  ((screen->savelines > from)
+                   ? ""
+                   : "SKIP "),
+                  screen->savelines,
+                  from));
+           if (screen->savelines > from) {
+               MoveLineData(sb,
+                            (unsigned) where,
+                            (unsigned) from,
+                            (unsigned) (screen->savelines - from));
+           }
+
+           /* reuse storage in saveBuf */
+           TRACE(("...reuse %d lines storage in saveBuf\n", n));
+           RestoreLineData(sb, (unsigned) screen->savelines - n, n);
+
+           /* copy lines from editBuf to saveBuf (into the reused storage) */
+           saveEditBufLines(screen, sb, n);
+#endif
+       }
+
+       /* adjust variables to fall-thru into changes only to editBuf */
+       TRACE(("...adjusting variables, to work on editBuf alone\n"));
+       last -= screen->savelines;
+       where = 0;
+       sb = screen->visbuf;
+    }
+#endif
+    /*
+     * Scroll the visible buffer (editBuf).
+     */
+    ScrnClearLines(xw, sb, where, n, size);
+
+    MoveLineData(sb,
+                (unsigned) where,
+                (unsigned) (where + (int) n),
+                (size_t) (last - where));
+
+    /* reuse storage for new bottom lines */
+    RestoreLineData(sb, (unsigned) last, n);
+}
+
+/*
+ * Inserts n blanks in screen at current row, col.  Size is the size of each
+ * row.
+ */
+void
+ScrnInsertChar(XtermWidget xw, unsigned n)
+{
+#define MemMove(data) \
+       for (j = last - 1; j >= (col + (int) n); --j) \
+           data[j] = data[j - (int) n]
+
+    TScreen *screen = TScreenOf(xw);
+    int last = MaxCols(screen);
+    int row = screen->cur_row;
+    int col = screen->cur_col;
+    int j;
+    LineData *ld;
+
+    if (last <= (col + (int) n)) {
+       if (last <= col)
+           return;
+       n = (unsigned) (last - col);
+    }
+
+    assert(screen->cur_col >= 0);
+    assert(screen->cur_row >= 0);
+    assert(n > 0);
+    assert(last > (int) n);
+
+    if_OPT_WIDE_CHARS(screen, {
+       int xx = screen->cur_row;
+       int kl;
+       int kr = screen->cur_col;
+       if (DamagedCells(screen, n, &kl, (int *) 0, xx, kr) && kr > kl) {
+           ClearCells(xw, 0, (unsigned) (kr - kl + 1), row, kl);
+       }
+       kr = screen->max_col - (int) n + 1;
+       if (DamagedCells(screen, n, &kl, (int *) 0, xx, kr) && kr > kl) {
+           ClearCells(xw, 0, (unsigned) (kr - kl + 1), row, kl);
+       }
+    });
+
+    if ((ld = getLineData(screen, row)) != 0) {
+       MemMove(ld->charData);
+       MemMove(ld->attribs);
+
+       if_OPT_ISO_COLORS(screen, {
+           MemMove(ld->color);
+       });
+       if_OPT_WIDE_CHARS(screen, {
+           size_t off;
+           for_each_combData(off, ld) {
+               MemMove(ld->combData[off]);
+           }
+       });
+    }
+    ClearCells(xw, CHARDRAWN, n, row, col);
+
+#undef MemMove
+}
+
+/*
+ * Deletes n characters at current row, col.
+ */
+void
+ScrnDeleteChar(XtermWidget xw, unsigned n)
+{
+#define MemMove(data) \
+       for (j = col; j < last - (int) n; ++j) \
+           data[j] = data[j + (int) n]
+
+    TScreen *screen = TScreenOf(xw);
+    int last = MaxCols(screen);
+    int row = screen->cur_row;
+    int col = screen->cur_col;
+    int j;
+    LineData *ld;
+
+    if (last <= (col + (int) n)) {
+       if (last <= col)
+           return;
+       n = (unsigned) (last - col);
+    }
+
+    assert(screen->cur_col >= 0);
+    assert(screen->cur_row >= 0);
+    assert(n > 0);
+    assert(last > (int) n);
+
+    if_OPT_WIDE_CHARS(screen, {
+       int kl;
+       int kr;
+       if (DamagedCells(screen, n, &kl, &kr,
+                        screen->cur_row,
+                        screen->cur_col))
+           ClearCells(xw, 0, (unsigned) (kr - kl + 1), row, kl);
+    });
+
+    if ((ld = getLineData(screen, row)) != 0) {
+       MemMove(ld->charData);
+       MemMove(ld->attribs);
+
+       if_OPT_ISO_COLORS(screen, {
+           MemMove(ld->color);
+       });
+       if_OPT_WIDE_CHARS(screen, {
+           size_t off;
+           for_each_combData(off, ld) {
+               MemMove(ld->combData[off]);
+           }
+       });
+       LineClrWrapped(ld);
+       if (screen->show_wrap_marks) {
+           ShowWrapMarks(xw, row, ld);
+       }
+    }
+    ClearCells(xw, 0, n, row, (last - (int) n));
+
+#undef MemMove
+}
+
+/*
+ * This is useful for debugging both xterm and applications that may manipulate
+ * its line-wrapping state.
+ */
+void
+ShowWrapMarks(XtermWidget xw, int row, LineData * ld)
+{
+    TScreen *screen = TScreenOf(xw);
+    Boolean set = LineTstWrapped(ld);
+    CgsEnum cgsId = set ? gcVTcursFilled : gcVTcursReverse;
+    VTwin *currentWin = WhichVWin(screen);
+    int y = row * FontHeight(screen) + screen->border;
+    int x = LineCursorX(screen, ld, screen->max_col + 1);
+
+    TRACE2(("ShowWrapMarks %d:%s\n", row, BtoS(set)));
+
+    XFillRectangle(screen->display, VWindow(screen),
+                  getCgsGC(xw, currentWin, cgsId),
+                  x, y,
+                  (unsigned) screen->border,
+                  (unsigned) FontHeight(screen));
+}
+
+/*
+ * Repaints the area enclosed by the parameters.
+ * Requires: (toprow, leftcol), (toprow + nrows, leftcol + ncols) are
+ *          coordinates of characters in screen;
+ *          nrows and ncols positive.
+ *          all dimensions are based on single-characters.
+ */
+void
+ScrnRefresh(XtermWidget xw,
+           int toprow,
+           int leftcol,
+           int nrows,
+           int ncols,
+           Bool force)         /* ... leading/trailing spaces */
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    int y = toprow * FontHeight(screen) + screen->border;
+    int row;
+    int maxrow = toprow + nrows - 1;
+    int scrollamt = screen->scroll_amt;
+    unsigned gc_changes = 0;
+#ifdef __CYGWIN__
+    static char first_time = 1;
+#endif
+    static int recurse = 0;
+
+    TRACE(("ScrnRefresh top %d (%d,%d) - (%d,%d)%s {{\n",
+          screen->topline, toprow, leftcol,
+          nrows, ncols,
+          force ? " force" : ""));
+
+    if (screen->cursorp.col >= leftcol
+       && screen->cursorp.col <= (leftcol + ncols - 1)
+       && screen->cursorp.row >= ROW2INX(screen, toprow)
+       && screen->cursorp.row <= ROW2INX(screen, maxrow))
+       screen->cursor_state = OFF;
+
+    for (row = toprow; row <= maxrow; y += FontHeight(screen), row++) {
+#if OPT_ISO_COLORS
+       CellColor *fb = 0;
+#define ColorOf(col) (CellColor) (fb ? fb[col] : 0)
+#endif
+#if OPT_WIDE_CHARS
+       int wideness = 0;
+#endif
+#define BLANK_CEL(cell) (chars[cell] == ' ')
+       IChar *chars;
+       Char *attrs;
+       int col = leftcol;
+       int maxcol = leftcol + ncols - 1;
+       int hi_col = maxcol;
+       int lastind;
+       unsigned flags;
+       unsigned test;
+       CellColor fg_bg = 0;
+       unsigned fg = 0, bg = 0;
+       int x;
+       GC gc;
+       Bool hilite;
+
+       (void) fg;
+       (void) bg;
+#if !OPT_ISO_COLORS
+       fg_bg = 0;
+#endif
+
+       if (row < screen->top_marg || row > screen->bot_marg)
+           lastind = row;
+       else
+           lastind = row - scrollamt;
+
+       if (lastind < 0 || lastind > screen->max_row)
+           continue;
+
+       TRACE2(("ScrnRefresh row=%d lastind=%d ->%d\n",
+               row, lastind, ROW2INX(screen, lastind)));
+
+       if ((ld = getLineData(screen, ROW2INX(screen, lastind))) == 0
+           || ld->charData == 0
+           || ld->attribs == 0) {
+           break;
+       }
+
+       if (screen->show_wrap_marks) {
+           ShowWrapMarks(xw, lastind, ld);
+       }
+
+       if (maxcol >= (int) ld->lineSize) {
+           maxcol = ld->lineSize - 1;
+           hi_col = maxcol;
+       }
+
+       chars = ld->charData;
+       attrs = ld->attribs;
+
+       if_OPT_WIDE_CHARS(screen, {
+           /* This fixes an infinite recursion bug, that leads
+              to display anomalies. It seems to be related to
+              problems with the selection. */
+           if (recurse < 3) {
+               /* adjust to redraw all of a widechar if we just wanted
+                  to draw the right hand half */
+               if (leftcol > 0 &&
+                   chars[leftcol] == HIDDEN_CHAR &&
+                   isWide((int) chars[leftcol - 1])) {
+                   leftcol--;
+                   ncols++;
+                   col = leftcol;
+               }
+           } else {
+               fprintf(stderr, "This should not happen. Why is it so?\n");
+           }
+       });
+
+       if (row < screen->startH.row || row > screen->endH.row ||
+           (row == screen->startH.row && maxcol < screen->startH.col) ||
+           (row == screen->endH.row && col >= screen->endH.col)) {
+#if OPT_DEC_CHRSET
+           /*
+            * Temporarily change dimensions to double-sized characters so
+            * we can reuse the recursion on this function.
+            */
+           if (CSET_DOUBLE(GetLineDblCS(ld))) {
+               col /= 2;
+               maxcol /= 2;
+           }
+#endif
+           /*
+            * If row does not intersect selection; don't hilite blanks.
+            */
+           if (!force) {
+               while (col <= maxcol && (attrs[col] & ~BOLD) == 0 &&
+                      BLANK_CEL(col))
+                   col++;
+
+               while (col <= maxcol && (attrs[maxcol] & ~BOLD) == 0 &&
+                      BLANK_CEL(maxcol))
+                   maxcol--;
+           }
+#if OPT_DEC_CHRSET
+           if (CSET_DOUBLE(GetLineDblCS(ld))) {
+               col *= 2;
+               maxcol *= 2;
+           }
+#endif
+           hilite = False;
+       } else {
+           /* row intersects selection; split into pieces of single type */
+           if (row == screen->startH.row && col < screen->startH.col) {
+               recurse++;
+               ScrnRefresh(xw, row, col, 1, screen->startH.col - col,
+                           force);
+               col = screen->startH.col;
+           }
+           if (row == screen->endH.row && maxcol >= screen->endH.col) {
+               recurse++;
+               ScrnRefresh(xw, row, screen->endH.col, 1,
+                           maxcol - screen->endH.col + 1, force);
+               maxcol = screen->endH.col - 1;
+           }
+
+           /*
+            * If we're highlighting because the user is doing cut/paste,
+            * trim the trailing blanks from the highlighted region so we're
+            * showing the actual extent of the text that'll be cut.  If
+            * we're selecting a blank line, we'll highlight one column
+            * anyway.
+            *
+            * We don't do this if the mouse-hilite mode is set because that
+            * would be too confusing.
+            *
+            * The default if the highlightSelection resource isn't set will
+            * highlight the whole width of the terminal, which is easy to
+            * see, but harder to use (because trailing blanks aren't as
+            * apparent).
+            */
+           if (screen->highlight_selection
+               && screen->send_mouse_pos != VT200_HIGHLIGHT_MOUSE) {
+               hi_col = screen->max_col;
+               while (hi_col > 0 && !(attrs[hi_col] & CHARDRAWN))
+                   hi_col--;
+           }
+
+           /* remaining piece should be hilited */
+           hilite = True;
+       }
+
+       if (col > maxcol)
+           continue;
+
+       /*
+        * Go back to double-sized character dimensions if the line has
+        * double-width characters.  Note that 'hi_col' is already in the
+        * right units.
+        */
+       if_OPT_DEC_CHRSET({
+           if (CSET_DOUBLE(GetLineDblCS(ld))) {
+               col /= 2;
+               maxcol /= 2;
+           }
+       });
+
+       flags = attrs[col];
+
+       if_OPT_WIDE_CHARS(screen, {
+           wideness = isWide((int) chars[col]);
+       });
+
+       if_OPT_ISO_COLORS(screen, {
+           fb = ld->color;
+           fg_bg = ColorOf(col);
+           fg = extract_fg(xw, fg_bg, flags);
+           bg = extract_bg(xw, fg_bg, flags);
+       });
+
+       gc = updatedXtermGC(xw, flags, fg_bg, hilite);
+       gc_changes |= (flags & (FG_COLOR | BG_COLOR));
+
+       x = LineCursorX(screen, ld, col);
+       lastind = col;
+
+       for (; col <= maxcol; col++) {
+           if ((attrs[col] != flags)
+               || (hilite && (col > hi_col))
+#if OPT_ISO_COLORS
+               || ((flags & FG_COLOR)
+                   && (extract_fg(xw, ColorOf(col), attrs[col]) != fg))
+               || ((flags & BG_COLOR)
+                   && (extract_bg(xw, ColorOf(col), attrs[col]) != bg))
+#endif
+#if OPT_WIDE_CHARS
+               || (isWide((int) chars[col]) != wideness
+                   && chars[col] != HIDDEN_CHAR)
+#endif
+               ) {
+               assert(col >= lastind);
+               TRACE(("ScrnRefresh looping drawXtermText %d..%d:%s\n",
+                      lastind, col,
+                      visibleIChars((&chars[lastind]),
+                                    (unsigned) (col - lastind))));
+
+               test = flags;
+               checkVeryBoldColors(test, fg);
+
+               x = drawXtermText(xw, test & DRAWX_MASK, gc, x, y,
+                                 GetLineDblCS(ld),
+                                 &chars[lastind],
+                                 (unsigned) (col - lastind), 0);
+
+               if_OPT_WIDE_CHARS(screen, {
+                   int i;
+                   size_t off;
+
+                   for_each_combData(off, ld) {
+                       IChar *com_off = ld->combData[off];
+
+                       for (i = lastind; i < col; i++) {
+                           int my_x = LineCursorX(screen, ld, i);
+                           IChar base = chars[i];
+
+                           if (isWide((int) base))
+                               my_x = LineCursorX(screen, ld, i - 1);
+
+                           if (com_off[i] != 0)
+                               drawXtermText(xw,
+                                             (test & DRAWX_MASK)
+                                             | NOBACKGROUND,
+                                             gc, my_x, y,
+                                             GetLineDblCS(ld),
+                                             com_off + i,
+                                             1, isWide((int) base));
+                       }
+                   }
+               });
+
+               resetXtermGC(xw, flags, hilite);
+
+               lastind = col;
+
+               if (hilite && (col > hi_col))
+                   hilite = False;
+
+               flags = attrs[col];
+               if_OPT_ISO_COLORS(screen, {
+                   fg_bg = ColorOf(col);
+                   fg = extract_fg(xw, fg_bg, flags);
+                   bg = extract_bg(xw, fg_bg, flags);
+               });
+               if_OPT_WIDE_CHARS(screen, {
+                   wideness = isWide((int) chars[col]);
+               });
+
+               gc = updatedXtermGC(xw, flags, fg_bg, hilite);
+               gc_changes |= (flags & (FG_COLOR | BG_COLOR));
+           }
+
+           if (chars[col] == 0) {
+               chars[col] = ' ';
+           }
+       }
+
+       assert(col >= lastind);
+       TRACE(("ScrnRefresh calling drawXtermText %d..%d:%s\n",
+              lastind, col,
+              visibleIChars(&chars[lastind], (unsigned) (col - lastind))));
+
+       test = flags;
+       checkVeryBoldColors(test, fg);
+
+       drawXtermText(xw, test & DRAWX_MASK, gc, x, y,
+                     GetLineDblCS(ld),
+                     &chars[lastind],
+                     (unsigned) (col - lastind), 0);
+
+       if_OPT_WIDE_CHARS(screen, {
+           int i;
+           size_t off;
+
+           for_each_combData(off, ld) {
+               IChar *com_off = ld->combData[off];
+
+               for (i = lastind; i < col; i++) {
+                   int my_x = LineCursorX(screen, ld, i);
+                   int base = (int) chars[i];
+
+                   if (isWide(base))
+                       my_x = LineCursorX(screen, ld, i - 1);
+
+                   if (com_off[i] != 0)
+                       drawXtermText(xw,
+                                     (test & DRAWX_MASK)
+                                     | NOBACKGROUND,
+                                     gc, my_x, y,
+                                     GetLineDblCS(ld),
+                                     com_off + i,
+                                     1, isWide(base));
+               }
+           }
+       });
+
+       resetXtermGC(xw, flags, hilite);
+    }
+
+    /*
+     * If we're in color mode, reset the various GC's to the current
+     * screen foreground and background so that other functions (e.g.,
+     * ClearRight) will get the correct colors.
+     */
+    if_OPT_ISO_COLORS(screen, {
+       if (gc_changes & FG_COLOR)
+           SGR_Foreground(xw, xw->cur_foreground);
+       if (gc_changes & BG_COLOR)
+           SGR_Background(xw, xw->cur_background);
+    });
+
+#if defined(__CYGWIN__) && defined(TIOCSWINSZ)
+    if (first_time == 1) {
+       TTYSIZE_STRUCT ts;
+
+       first_time = 0;
+       TTYSIZE_ROWS(ts) = nrows;
+       TTYSIZE_COLS(ts) = ncols;
+       ts.ws_xpixel = xw->core.width;
+       ts.ws_ypixel = xw->core.height;
+       SET_TTYSIZE(screen->respond, ts);
+    }
+#endif
+    recurse--;
+
+    TRACE(("...}} ScrnRefresh\n"));
+    return;
+}
+
+/*
+ * Call this wrapper to ScrnRefresh() when the data has changed.  If the
+ * refresh region overlaps the selection, we will release the primary selection.
+ */
+void
+ScrnUpdate(XtermWidget xw,
+          int toprow,
+          int leftcol,
+          int nrows,
+          int ncols,
+          Bool force)          /* ... leading/trailing spaces */
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (ScrnHaveSelection(screen)
+       && (toprow <= screen->endH.row)
+       && (toprow + nrows - 1 >= screen->startH.row)) {
+       ScrnDisownSelection(xw);
+    }
+    ScrnRefresh(xw, toprow, leftcol, nrows, ncols, force);
+}
+
+/*
+ * Sets the rows first though last of the buffer of screen to spaces.
+ * Requires first <= last; first, last are rows of screen->buf.
+ */
+void
+ClearBufRows(XtermWidget xw,
+            int first,
+            int last)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned len = (unsigned) MaxCols(screen);
+    int row;
+
+    TRACE(("ClearBufRows %d..%d\n", first, last));
+    for (row = first; row <= last; row++) {
+       LineData *ld = getLineData(screen, row);
+       if (ld != 0) {
+           if_OPT_DEC_CHRSET({
+               /* clearing the whole row resets the doublesize characters */
+               SetLineDblCS(ld, CSET_SWL);
+           });
+           LineClrWrapped(ld);
+           if (screen->show_wrap_marks) {
+               ShowWrapMarks(xw, row, ld);
+           }
+           ClearCells(xw, 0, len, row, 0);
+       }
+    }
+}
+
+/*
+  Resizes screen:
+  1. If new window would have fractional characters, sets window size so as to
+  discard fractional characters and returns -1.
+  Minimum screen size is 1 X 1.
+  Note that this causes another ExposeWindow event.
+  2. Enlarges screen->buf if necessary.  New space is appended to the bottom
+  and to the right
+  3. Reduces  screen->buf if necessary.  Old space is removed from the bottom
+  and from the right
+  4. Cursor is positioned as closely to its former position as possible
+  5. Sets screen->max_row and screen->max_col to reflect new size
+  6. Maintains the inner border (and clears the border on the screen).
+  7. Clears origin mode and sets scrolling region to be entire screen.
+  8. Returns 0
+  */
+int
+ScreenResize(XtermWidget xw,
+            int width,
+            int height,
+            unsigned *flags)
+{
+    TScreen *screen = TScreenOf(xw);
+    int code, rows, cols;
+    int border = 2 * screen->border;
+    int move_down_by = 0;
+#ifdef TTYSIZE_STRUCT
+    TTYSIZE_STRUCT ts;
+#endif
+    Window tw = VWindow(screen);
+
+    TRACE(("ScreenResize %dx%d border %d font %dx%d\n",
+          height, width, border,
+          FontHeight(screen), FontWidth(screen)));
+
+    assert(width > 0);
+    assert(height > 0);
+
+    if (screen->is_running) {
+       /* clear the right and bottom internal border because of NorthWest
+          gravity might have left junk on the right and bottom edges */
+       if (width >= (int) FullWidth(screen)) {
+           XClearArea(screen->display, tw,
+                      FullWidth(screen), 0,    /* right edge */
+                      0, (unsigned) height,    /* from top to bottom */
+                      False);
+       }
+       if (height >= (int) FullHeight(screen)) {
+           XClearArea(screen->display, tw,
+                      0, FullHeight(screen),   /* bottom */
+                      (unsigned) width, 0,     /* all across the bottom */
+                      False);
+       }
+    }
+
+    TRACE(("...computing rows/cols: %.2f %.2f\n",
+          (double) (height - border) / FontHeight(screen),
+          (double) (width - border - ScrollbarWidth(screen)) / FontWidth(screen)));
+
+    rows = (height - border) / FontHeight(screen);
+    cols = (width - border - ScrollbarWidth(screen)) / FontWidth(screen);
+    if (rows < 1)
+       rows = 1;
+    if (cols < 1)
+       cols = 1;
+
+    /* update buffers if the screen has changed size */
+    if (MaxRows(screen) != rows || MaxCols(screen) != cols) {
+       int whichBuf = 0;
+       int delta_rows = rows - MaxRows(screen);
+#if OPT_TRACE
+       int delta_cols = cols - MaxCols(screen);
+#endif
+
+       TRACE(("...ScreenResize chars %dx%d delta %dx%d\n",
+              rows, cols, delta_rows, delta_cols));
+
+       if (screen->is_running) {
+#if !OPT_FIFO_LINES
+           int savelines = (screen->scrollWidget
+                            ? screen->savelines
+                            : 0);
+#endif
+           if (screen->cursor_state)
+               HideCursor();
+#if OPT_SAVE_LINES
+           /*
+            * The non-visible buffer is simple, since we will not copy data
+            * to/from the saved-lines.  Do that first.
+            */
+           if (screen->editBuf_index[!screen->whichBuf]) {
+               (void) Reallocate(xw,
+                                 &screen->editBuf_index[!screen->whichBuf],
+                                 &screen->editBuf_data[!screen->whichBuf],
+                                 (unsigned) rows,
+                                 (unsigned) cols,
+                                 (unsigned) MaxRows(screen));
+           }
+
+           /*
+            * The save-lines buffer may change width, but will not change its
+            * height.  Deal with the cases where we copy data to/from the
+            * saved-lines buffer.
+            */
+           if (GravityIsSouthWest(xw)
+               && delta_rows
+               && screen->saveBuf_index != 0) {
+
+               if (delta_rows < 0) {
+                   unsigned move_up = (unsigned) (-delta_rows);
+                   ScrnBuf dst = screen->saveBuf_index;
+
+#if OPT_FIFO_LINES
+                   int amount = ((MaxRows(screen) - (int) move_up - 1)
+                                 - screen->cur_row);
+
+                   if (amount < 0) {
+                       /* move line-data from visible-buffer to save-buffer */
+                       saveEditBufLines(screen, dst, (unsigned) -amount);
+                       move_down_by = amount;
+                   } else {
+                       move_down_by = 0;
+                   }
+#else /* !OPT_FIFO_LINES */
+                   int amount = screen->savelines - (int) move_up;
+
+                   TRACE_SCRNBUF("before save", screen, dst, screen->savelines);
+
+                   /* shift lines in save-buffer to make room */
+                   TRACE(("...%smoving pointers in saveBuf (compare %d %d)\n",
+                          (amount > 0
+                           ? ""
+                           : "SKIP "),
+                          screen->savelines,
+                          move_up));
+                   if (amount > 0) {
+                       SaveLineData(dst, 0, move_up);
+
+                       MoveLineData(dst,
+                                    0,
+                                    move_up,
+                                    (unsigned) amount);
+
+                       TRACE(("...reuse %d lines storage in saveBuf\n", move_up));
+                       RestoreLineData(dst,
+                                       (unsigned) amount,
+                                       move_up);
+                       TRACE_SCRNBUF("restoresave", screen, dst, screen->savelines);
+                   }
+
+                   /* copy line-data from visible-buffer to save-buffer */
+                   saveEditBufLines(screen, dst, move_up);
+
+                   /* after data is copied, reallocate saved-lines */
+                   (void) Reallocate(xw,
+                                     &screen->saveBuf_index,
+                                     &screen->saveBuf_data,
+                                     (unsigned) savelines,
+                                     (unsigned) cols,
+                                     (unsigned) savelines);
+                   TRACE_SCRNBUF("reallocSAVE",
+                                 screen,
+                                 screen->saveBuf_index,
+                                 savelines);
+#endif /* OPT_FIFO_LINES */
+
+                   /* decrease size of visible-buffer */
+                   (void) Reallocate(xw,
+                                     &screen->editBuf_index[screen->whichBuf],
+                                     &screen->editBuf_data[screen->whichBuf],
+                                     (unsigned) rows,
+                                     (unsigned) cols,
+                                     (unsigned) MaxRows(screen));
+                   TRACE_SCRNBUF("reallocEDIT",
+                                 screen,
+                                 screen->editBuf_index[screen->whichBuf],
+                                 rows);
+               } else {
+                   unsigned move_down = (unsigned) delta_rows;
+#if OPT_FIFO_LINES
+                   long unsave_fifo;
+#else
+                   ScrnBuf src = screen->saveBuf_index;
+#endif
+                   ScrnBuf dst;
+                   int amount;
+
+                   if ((int) move_down > screen->savedlines) {
+                       move_down = (unsigned) screen->savedlines;
+                   }
+                   move_down_by = (int) move_down;
+                   amount = rows - (int) move_down;
+
+                   /* increase size of visible-buffer */
+                   (void) Reallocate(xw,
+                                     &screen->editBuf_index[screen->whichBuf],
+                                     &screen->editBuf_data[screen->whichBuf],
+                                     (unsigned) rows,
+                                     (unsigned) cols,
+                                     (unsigned) MaxRows(screen));
+
+                   dst = screen->editBuf_index[screen->whichBuf];
+                   TRACE_SCRNBUF("reallocEDIT", screen, dst, rows);
+
+                   TRACE(("...%smoving pointers in editBuf (compare %d %d)\n",
+                          (amount > 0
+                           ? ""
+                           : "SKIP "),
+                          rows,
+                          move_down));
+                   if (amount > 0) {
+                       /* shift lines in visible-buffer to make room */
+                       SaveLineData(dst, (unsigned) amount, (size_t) move_down);
+
+                       MoveLineData(dst,
+                                    move_down,
+                                    0,
+                                    (unsigned) amount);
+
+                       TRACE(("...reuse %d lines storage in editBuf\n", move_down));
+                       RestoreLineData(dst,
+                                       0,
+                                       move_down);
+
+                       TRACE_SCRNBUF("shifted", screen, dst, rows);
+                   }
+
+                   /* copy line-data from save-buffer to visible-buffer */
+                   unsaveEditBufLines(screen, dst, move_down);
+                   TRACE_SCRNBUF("copied", screen, dst, rows);
+
+#if OPT_FIFO_LINES
+                   unsave_fifo = (long) move_down;
+                   if (screen->saved_fifo < (int) unsave_fifo)
+                       unsave_fifo = screen->saved_fifo;
+
+                   /* free up storage in fifo from the copied lines */
+                   while (unsave_fifo-- > 0) {
+                       deleteScrollback(screen, -1);
+                       screen->saved_fifo--;
+                   }
+#else
+                   amount = (screen->savelines - (int) move_down);
+                   TRACE(("...%smoving pointers in saveBuf (compare %d %d)\n",
+                          (amount > 0
+                           ? ""
+                           : "SKIP "),
+                          rows,
+                          move_down));
+                   if (amount > 0) {
+                       /* shift lines in save-buffer to account for copy */
+                       src = screen->saveBuf_index;
+                       SaveLineData(src, amount, move_down);
+
+                       MoveLineData(src,
+                                    move_down,
+                                    0,
+                                    (unsigned) amount);
+
+                       TRACE(("...reuse %d lines storage in saveBuf\n", move_down));
+                       RestoreLineData(src,
+                                       0,
+                                       move_down);
+                   }
+#endif
+
+                   /* recover storage in save-buffer */
+               }
+           } else {
+#if !OPT_FIFO_LINES
+               (void) Reallocate(xw,
+                                 &screen->saveBuf_index,
+                                 &screen->saveBuf_data,
+                                 (unsigned) savelines,
+                                 (unsigned) cols,
+                                 (unsigned) savelines);
+#endif
+               (void) Reallocate(xw,
+                                 &screen->editBuf_index[screen->whichBuf],
+                                 &screen->editBuf_data[screen->whichBuf],
+                                 (unsigned) rows,
+                                 (unsigned) cols,
+                                 (unsigned) MaxRows(screen));
+           }
+#else /* !OPT_SAVE_LINES */
+           if (screen->whichBuf
+               && GravityIsSouthWest(xw)) {
+               /* swap buffer pointers back to make this work */
+               whichBuf = screen->whichBuf;
+               SwitchBufPtrs(screen, 0);
+           } else {
+               whichBuf = 0;
+           }
+           if (screen->editBuf_index[1])
+               (void) Reallocate(xw,
+                                 &screen->editBuf_index[1],
+                                 &screen->editBuf_data[1],
+                                 (unsigned) rows,
+                                 (unsigned) cols,
+                                 (unsigned) MaxRows(screen));
+           move_down_by = Reallocate(xw,
+                                     &screen->saveBuf_index,
+                                     &screen->saveBuf_data,
+                                     (unsigned) (rows + savelines),
+                                     (unsigned) cols,
+                                     (unsigned) (MaxRows(screen) + savelines));
+#endif /* OPT_SAVE_LINES */
+           screen->visbuf = VisBuf(screen);
+       }
+
+       AdjustSavedCursor(xw, move_down_by);
+       set_max_row(screen, screen->max_row + delta_rows);
+       set_max_col(screen, cols - 1);
+
+       if (screen->is_running) {
+           if (GravityIsSouthWest(xw)) {
+               screen->savedlines -= move_down_by;
+               if (screen->savedlines < 0)
+                   screen->savedlines = 0;
+               if (screen->savedlines > screen->savelines)
+                   screen->savedlines = screen->savelines;
+               if (screen->topline < -screen->savedlines)
+                   screen->topline = -screen->savedlines;
+               set_cur_row(screen, screen->cur_row + move_down_by);
+               screen->cursorp.row += move_down_by;
+               ScrollSelection(screen, move_down_by, True);
+
+               if (whichBuf)
+                   SwitchBufPtrs(screen, whichBuf);    /* put the pointers back */
+           }
+       }
+
+       /* adjust scrolling region */
+       set_tb_margins(screen, 0, screen->max_row);
+       UIntClr(*flags, ORIGIN);
+
+       if (screen->cur_row > screen->max_row)
+           set_cur_row(screen, screen->max_row);
+       if (screen->cur_col > screen->max_col)
+           set_cur_col(screen, screen->max_col);
+
+       screen->fullVwin.height = height - border;
+       screen->fullVwin.width = width - border - screen->fullVwin.sb_info.width;
+
+    } else if (FullHeight(screen) == height && FullWidth(screen) == width)
+       return (0);             /* nothing has changed at all */
+
+    screen->fullVwin.fullheight = (Dimension) height;
+    screen->fullVwin.fullwidth = (Dimension) width;
+
+    ResizeScrollBar(xw);
+    ResizeSelection(screen, rows, cols);
+
+#ifndef NO_ACTIVE_ICON
+    if (screen->iconVwin.window) {
+       XWindowChanges changes;
+       screen->iconVwin.width =
+           MaxCols(screen) * screen->iconVwin.f_width;
+
+       screen->iconVwin.height =
+           MaxRows(screen) * screen->iconVwin.f_height;
+
+       changes.width = screen->iconVwin.fullwidth =
+           (Dimension) ((unsigned) screen->iconVwin.width
+                        + 2 * xw->misc.icon_border_width);
+
+       changes.height = screen->iconVwin.fullheight =
+           (Dimension) ((unsigned) screen->iconVwin.height
+                        + 2 * xw->misc.icon_border_width);
+
+       changes.border_width = (int) xw->misc.icon_border_width;
+
+       TRACE(("resizing icon window %dx%d\n", changes.height, changes.width));
+       XConfigureWindow(XtDisplay(xw), screen->iconVwin.window,
+                        CWWidth | CWHeight | CWBorderWidth, &changes);
+    }
+#endif /* NO_ACTIVE_ICON */
+
+#ifdef TTYSIZE_STRUCT
+    /* Set tty's idea of window size */
+    TTYSIZE_ROWS(ts) = (ttySize_t) rows;
+    TTYSIZE_COLS(ts) = (ttySize_t) cols;
+#ifdef USE_STRUCT_WINSIZE
+    ts.ws_xpixel = (ttySize_t) width;
+    ts.ws_ypixel = (ttySize_t) height;
+#endif
+    code = SET_TTYSIZE(screen->respond, ts);
+    TRACE(("return %d from SET_TTYSIZE %dx%d\n", code, rows, cols));
+    (void) code;
+
+#if defined(SIGWINCH) && defined(USE_STRUCT_TTYSIZE)
+    if (screen->pid > 1) {
+       int pgrp;
+
+       TRACE(("getting process-group\n"));
+       if (ioctl(screen->respond, TIOCGPGRP, &pgrp) != -1) {
+           TRACE(("sending SIGWINCH to process group %d\n", pgrp));
+           kill_process_group(pgrp, SIGWINCH);
+       }
+    }
+#endif /* SIGWINCH */
+
+#else
+    TRACE(("ScreenResize cannot do anything to pty\n"));
+#endif /* TTYSIZE_STRUCT */
+    return (0);
+}
+
+/*
+ * Return true if any character cell starting at [row,col], for len-cells is
+ * nonnull.
+ */
+Bool
+non_blank_line(TScreen * screen,
+              int row,
+              int col,
+              int len)
+{
+    int i;
+    Bool found = False;
+    LineData *ld = getLineData(screen, row);
+
+    if (ld != 0) {
+       for (i = col; i < len; i++) {
+           if (ld->charData[i]) {
+               found = True;
+               break;
+           }
+       }
+    }
+    return found;
+}
+
+/*
+ * Rectangle parameters start from one.
+ */
+#define minRectRow(screen) (getMinRow(screen) + 1)
+#define minRectCol(screen) (getMinCol(screen) + 1)
+#define maxRectRow(screen) (getMaxRow(screen) + 1)
+#define maxRectCol(screen) (getMaxCol(screen) + 1)
+
+static int
+limitedParseRow(XtermWidget xw, TScreen * screen, int row)
+{
+    int min_row = minRectRow(screen);
+    int max_row = maxRectRow(screen);
+
+    if (row < min_row)
+       row = min_row;
+    else if (row > max_row)
+       row = max_row;
+    return row;
+}
+
+static int
+limitedParseCol(XtermWidget xw, TScreen * screen, int col)
+{
+    int min_col = minRectCol(screen);
+    int max_col = maxRectCol(screen);
+
+    (void) xw;
+    if (col < min_col)
+       col = min_col;
+    else if (col > max_col)
+       col = max_col;
+    return col;
+}
+
+#define LimitedParse(num, func, dft) \
+       func(xw, screen, (nparams > num) ? params[num] : dft)
+
+/*
+ * Copy the rectangle boundaries into a struct, providing default values as
+ * needed.
+ */
+void
+xtermParseRect(XtermWidget xw, int nparams, int *params, XTermRect * target)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    memset(target, 0, sizeof(*target));
+    target->top = LimitedParse(0, limitedParseRow, minRectRow(screen));
+    target->left = LimitedParse(1, limitedParseCol, minRectCol(screen));
+    target->bottom = LimitedParse(2, limitedParseRow, maxRectRow(screen));
+    target->right = LimitedParse(3, limitedParseCol, maxRectCol(screen));
+    TRACE(("parsed rectangle %d,%d %d,%d\n",
+          target->top,
+          target->left,
+          target->bottom,
+          target->right));
+}
+
+static Bool
+validRect(XtermWidget xw, XTermRect * target)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("comparing against screensize %dx%d\n",
+          maxRectRow(screen),
+          maxRectCol(screen)));
+    return (target != 0
+           && target->top >= minRectRow(screen)
+           && target->left >= minRectCol(screen)
+           && target->top <= target->bottom
+           && target->left <= target->right
+           && target->top <= maxRectRow(screen)
+           && target->right <= maxRectCol(screen));
+}
+
+/*
+ * Fills a rectangle with the given 8-bit character and video-attributes.
+ * Colors and double-size attribute are unmodified.
+ */
+void
+ScrnFillRectangle(XtermWidget xw,
+                 XTermRect * target,
+                 int value,
+                 unsigned flags,
+                 Bool keepColors)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("filling rectangle with '%c' flags %#x\n", value, flags));
+    if (validRect(xw, target)) {
+       LineData *ld;
+       unsigned left = (unsigned) (target->left - 1);
+       unsigned size = (unsigned) (target->right - (int) left);
+       unsigned attrs = flags;
+       int row, col;
+
+       (void) size;
+
+       attrs &= ATTRIBUTES;
+       attrs |= CHARDRAWN;
+       for (row = target->bottom - 1; row >= (target->top - 1); row--) {
+           ld = getLineData(screen, row);
+
+           TRACE(("filling %d [%d..%d]\n", row, left, left + size));
+
+           /*
+            * Fill attributes, preserving "protected" flag, as well as
+            * colors if asked.
+            */
+           for (col = (int) left; col < target->right; ++col) {
+               unsigned temp = ld->attribs[col];
+
+               if (!keepColors) {
+                   UIntClr(temp, (FG_COLOR | BG_COLOR));
+               }
+               temp = attrs | (temp & (FG_COLOR | BG_COLOR | PROTECTED));
+               temp |= CHARDRAWN;
+               ld->attribs[col] = (Char) temp;
+#if OPT_ISO_COLORS
+               if (attrs & (FG_COLOR | BG_COLOR)) {
+                   if_OPT_ISO_COLORS(screen, {
+                       ld->color[col] = xtermColorPair(xw);
+                   });
+               }
+#endif
+           }
+
+           for (col = (int) left; col < target->right; ++col)
+               ld->charData[col] = (CharData) value;
+
+           if_OPT_WIDE_CHARS(screen, {
+               size_t off;
+               for_each_combData(off, ld) {
+                   memset(ld->combData[off] + left, 0, size * sizeof(CharData));
+               }
+           })
+       }
+       ScrnUpdate(xw,
+                  target->top - 1,
+                  target->left - 1,
+                  (target->bottom - target->top) + 1,
+                  (target->right - target->left) + 1,
+                  False);
+    }
+}
+
+#if OPT_DEC_RECTOPS
+/*
+ * Copies the source rectangle to the target location, including video
+ * attributes.
+ *
+ * This implementation ignores page numbers.
+ *
+ * The reference manual does not indicate if it handles overlapping copy
+ * properly - so we make a local copy of the source rectangle first, then apply
+ * the target from that.
+ */
+void
+ScrnCopyRectangle(XtermWidget xw, XTermRect * source, int nparam, int *params)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("copying rectangle\n"));
+
+    if (validRect(xw, source)) {
+       XTermRect target;
+       xtermParseRect(xw,
+                      ((nparam > 3) ? 2 : (nparam - 1)),
+                      params,
+                      &target);
+       if (validRect(xw, &target)) {
+           Cardinal high = (Cardinal) (source->bottom - source->top) + 1;
+           Cardinal wide = (Cardinal) (source->right - source->left) + 1;
+           Cardinal size = (high * wide);
+           int row, col;
+           Cardinal j, k;
+           LineData *ld;
+
+           CellData *cells = newCellData(xw, size);
+
+           if (cells != 0) {
+
+               TRACE(("OK - make copy %dx%d\n", high, wide));
+               target.bottom = target.top + (int) (high - 1);
+               target.right = target.left + (int) (wide - 1);
+
+               for (row = source->top - 1; row < source->bottom; ++row) {
+                   ld = getLineData(screen, row);
+                   j = (Cardinal) (row - (source->top - 1));
+                   for (col = source->left - 1; col < source->right; ++col) {
+                       k = (Cardinal) (col - (source->left - 1));
+                       saveCellData(screen, cells,
+                                    (j * wide) + k,
+                                    ld, col);
+                   }
+               }
+               for (row = target.top - 1; row < target.bottom; ++row) {
+                   ld = getLineData(screen, row);
+                   j = (Cardinal) (row - (target.top - 1));
+                   for (col = target.left - 1; col < target.right; ++col) {
+                       k = (Cardinal) (col - (target.left - 1));
+                       if (row >= getMinRow(screen)
+                           && row <= getMaxRow(screen)
+                           && col >= getMinCol(screen)
+                           && col <= getMaxCol(screen)) {
+                           if (j < high && k < wide) {
+                               restoreCellData(screen, cells,
+                                               (j * wide) + k,
+                                               ld, col);
+                           } else {
+                               /* EMPTY */
+                               /* FIXME - clear the target cell? */
+                           }
+                           ld->attribs[col] |= CHARDRAWN;
+                       }
+                   }
+               }
+               free(cells);
+
+               ScrnUpdate(xw,
+                          (target.top - 1),
+                          (target.left - 1),
+                          (target.bottom - target.top) + 1,
+                          ((target.right - target.left) + 1),
+                          False);
+           }
+       }
+    }
+}
+
+/*
+ * Modifies the video-attributes only - so selection (not a video attribute) is
+ * unaffected.  Colors and double-size flags are unaffected as well.
+ *
+ * FIXME: our representation for "invisible" does not work with this operation,
+ * since the attribute byte is fully-allocated for other flags.  The logic
+ * is shown for INVISIBLE because it's harmless, and useful in case the
+ * CHARDRAWN or PROTECTED flags are reassigned.
+ */
+void
+ScrnMarkRectangle(XtermWidget xw,
+                 XTermRect * target,
+                 Bool reverse,
+                 int nparam,
+                 int *params)
+{
+    TScreen *screen = TScreenOf(xw);
+    Bool exact = (screen->cur_decsace == 2);
+
+    TRACE(("%s %s\n",
+          reverse ? "reversing" : "marking",
+          (exact
+           ? "rectangle"
+           : "region")));
+
+    if (validRect(xw, target)) {
+       LineData *ld;
+       int top = target->top - 1;
+       int bottom = target->bottom - 1;
+       int row, col;
+       int n;
+
+       for (row = top; row <= bottom; ++row) {
+           int left = ((exact || (row == top))
+                       ? (target->left - 1)
+                       : getMinCol(screen));
+           int right = ((exact || (row == bottom))
+                        ? (target->right - 1)
+                        : getMaxCol(screen));
+
+           ld = getLineData(screen, row);
+
+           TRACE(("marking %d [%d..%d]\n", row, left, right));
+           for (col = left; col <= right; ++col) {
+               unsigned flags = ld->attribs[col];
+
+               for (n = 0; n < nparam; ++n) {
+#if OPT_TRACE
+                   if (row == top && col == left)
+                       TRACE(("attr param[%d] %d\n", n + 1, params[n]));
+#endif
+                   if (reverse) {
+                       switch (params[n]) {
+                       case 1:
+                           flags ^= BOLD;
+                           break;
+                       case 4:
+                           flags ^= UNDERLINE;
+                           break;
+                       case 5:
+                           flags ^= BLINK;
+                           break;
+                       case 7:
+                           flags ^= INVERSE;
+                           break;
+                       case 8:
+                           flags ^= INVISIBLE;
+                           break;
+                       }
+                   } else {
+                       switch (params[n]) {
+                       case 0:
+                           UIntClr(flags, SGR_MASK);
+                           break;
+                       case 1:
+                           flags |= BOLD;
+                           break;
+                       case 4:
+                           flags |= UNDERLINE;
+                           break;
+                       case 5:
+                           flags |= BLINK;
+                           break;
+                       case 7:
+                           flags |= INVERSE;
+                           break;
+                       case 8:
+                           flags |= INVISIBLE;
+                           break;
+                       case 22:
+                           UIntClr(flags, BOLD);
+                           break;
+                       case 24:
+                           UIntClr(flags, UNDERLINE);
+                           break;
+                       case 25:
+                           UIntClr(flags, BLINK);
+                           break;
+                       case 27:
+                           UIntClr(flags, INVERSE);
+                           break;
+                       case 28:
+                           UIntClr(flags, INVISIBLE);
+                           break;
+                       }
+                   }
+               }
+#if OPT_TRACE
+               if (row == top && col == left)
+                   TRACE(("first mask-change is %#x\n",
+                          ld->attribs[col] ^ flags));
+#endif
+               ld->attribs[col] = (Char) flags;
+           }
+       }
+       ScrnRefresh(xw,
+                   (target->top - 1),
+                   (exact ? (target->left - 1) : getMinCol(screen)),
+                   (target->bottom - target->top) + 1,
+                   (exact
+                    ? ((target->right - target->left) + 1)
+                    : (getMaxCol(screen) - getMinCol(screen) + 1)),
+                   False);
+    }
+}
+
+/*
+ * Resets characters to space, except where prohibited by DECSCA.  Video
+ * attributes (including color) are untouched.
+ */
+void
+ScrnWipeRectangle(XtermWidget xw,
+                 XTermRect * target)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("wiping rectangle\n"));
+
+    if (validRect(xw, target)) {
+       LineData *ld;
+       int top = target->top - 1;
+       int bottom = target->bottom - 1;
+       int row, col;
+
+       for (row = top; row <= bottom; ++row) {
+           int left = (target->left - 1);
+           int right = (target->right - 1);
+
+           TRACE(("wiping %d [%d..%d]\n", row, left, right));
+
+           ld = getLineData(screen, row);
+           for (col = left; col <= right; ++col) {
+               if (!((screen->protected_mode == DEC_PROTECT)
+                     && (ld->attribs[col] & PROTECTED))) {
+                   ld->attribs[col] |= CHARDRAWN;
+                   ld->charData[col] = ' ';
+                   if_OPT_WIDE_CHARS(screen, {
+                       size_t off;
+                       for_each_combData(off, ld) {
+                           ld->combData[off][col] = '\0';
+                       }
+                   })
+               }
+           }
+       }
+       ScrnUpdate(xw,
+                  (target->top - 1),
+                  (target->left - 1),
+                  (target->bottom - target->top) + 1,
+                  ((target->right - target->left) + 1),
+                  False);
+    }
+}
+#endif /* OPT_DEC_RECTOPS */
diff --git a/scrollback.c b/scrollback.c
new file mode 100644 (file)
index 0000000..a28ec7e
--- /dev/null
@@ -0,0 +1,126 @@
+/* $XTermId: scrollback.c,v 1.14 2010/04/28 21:47:09 tom Exp $ */
+
+/************************************************************
+
+Copyright 2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <xterm.h>
+
+#define REAL_ROW(screen, row) ((row) + 1 + (screen)->saved_fifo)
+#define ROW2FIFO(screen, row) \
+       (unsigned) (REAL_ROW(screen, row) % (screen)->savelines)
+
+/*
+ * Given a row-number, find the corresponding data for the line in the VT100
+ * widget's saved-line FIFO.  The row-number (from getLineData) is negative.
+ * So we just count backwards from the last saved line.
+ */
+LineData *
+getScrollback(TScreen * screen, int row)
+{
+    LineData *result = 0;
+
+    if (screen->saved_fifo > 0 && REAL_ROW(screen, row) >= 0) {
+       unsigned which = ROW2FIFO(screen, row);
+       ScrnBuf where = scrnHeadAddr(screen, screen->saveBuf_index, which);
+       result = (LineData *) where;
+    }
+
+    TRACE(("getScrollback %d -> %d -> %p\n",
+          row, ROW2FIFO(screen, row),
+          (void *) result));
+    return result;
+}
+
+/*
+ * Allocate a new row in the scrollback FIFO, returning a pointer to it.
+ */
+LineData *
+addScrollback(TScreen * screen)
+{
+    ScrnBuf where = 0;
+    unsigned which;
+    unsigned ncols = (unsigned) MaxCols(screen);
+    Char *block;
+
+    if (screen->saveBuf_index != 0) {
+       screen->saved_fifo++;
+       TRACE(("addScrollback %lu\n", screen->saved_fifo));
+
+       /* first, see which index we'll use */
+       which = (unsigned) (screen->saved_fifo % screen->savelines);
+       where = scrnHeadAddr(screen, screen->saveBuf_index, which);
+
+       /* discard any obsolete index data */
+       if (screen->saved_fifo > screen->savelines) {
+           LineData *prior = (LineData *) where;
+           /*
+            * setupLineData uses the attribs as the first address used from the
+            * data block.
+            */
+           if (prior->attribs != 0) {
+               TRACE(("...freeing prior FIFO data in slot %d: %p->%p\n",
+                      which, (void *) prior, prior->attribs));
+               free(prior->attribs);
+               prior->attribs = 0;
+           }
+       }
+
+       /* allocate the new data */
+       block = allocScrnData(screen, 1, ncols);
+
+       /* record the new data in the index */
+       setupLineData(screen, where, (Char *) block, 1, ncols);
+
+       TRACE(("...storing new FIFO data in slot %d: %p->%p\n",
+              which, (void *) where, block));
+
+    }
+    return (LineData *) where;
+}
+
+void
+deleteScrollback(TScreen * screen, int row)
+{
+    unsigned which = ROW2FIFO(screen, row);
+    ScrnBuf where = scrnHeadAddr(screen, screen->saveBuf_index, which);
+    LineData *prior = (LineData *) where;
+    /*
+     * setupLineData uses the attribs as the first address used from the
+     * data block.
+     */
+    if (prior->attribs != 0) {
+       TRACE(("...freeing prior FIFO data in slot %d: %p->%p\n",
+              which, (void *) prior, prior->attribs));
+       free(prior->attribs);
+       prior->attribs = 0;
+    }
+}
diff --git a/scrollbar.c b/scrollbar.c
new file mode 100644 (file)
index 0000000..65e91a5
--- /dev/null
@@ -0,0 +1,950 @@
+/* $XTermId: scrollbar.c,v 1.179 2011/02/09 10:05:19 tom Exp $ */
+
+/*
+ * Copyright 2000-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#include <xterm.h>
+
+#include <X11/Xatom.h>
+
+#if defined(HAVE_LIB_XAW)
+#include <X11/Xaw/Scrollbar.h>
+#elif defined(HAVE_LIB_XAW3D)
+#include <X11/Xaw3d/Scrollbar.h>
+#elif defined(HAVE_LIB_NEXTAW)
+#include <X11/neXtaw/Scrollbar.h>
+#elif defined(HAVE_LIB_XAWPLUS)
+#include <X11/XawPlus/Scrollbar.h>
+#endif
+
+#if defined(HAVE_XKBQUERYEXTENSION) && defined(HAVE_X11_XKBLIB_H) && defined(HAVE_X11_EXTENSIONS_XKB_H)
+#include <X11/extensions/XKB.h>
+#include <X11/XKBlib.h>
+#else
+#undef HAVE_XKBQUERYEXTENSION
+#endif
+
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <xcharmouse.h>
+#include <xstrings.h>
+
+/*
+ * The scrollbar's border overlaps the border of the vt100 window.  If there
+ * is no border for the vt100, there can be no border for the scrollbar.
+ */
+#define SCROLLBAR_BORDER(xw) (TScreenOf(xw)->scrollBarBorder)
+#if OPT_TOOLBAR
+#define ScrollBarBorder(xw) (BorderWidth(xw) ? SCROLLBAR_BORDER(xw) : 0)
+#else
+#define ScrollBarBorder(xw) SCROLLBAR_BORDER(xw)
+#endif
+
+/* Event handlers */
+
+static void ScrollTextTo PROTO_XT_CALLBACK_ARGS;
+static void ScrollTextUpDownBy PROTO_XT_CALLBACK_ARGS;
+
+/* Resize the text window for a terminal screen, modifying the
+ * appropriate WM_SIZE_HINTS and taking advantage of bit gravity.
+ */
+void
+DoResizeScreen(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    int border = 2 * screen->border;
+    int min_wide = border + screen->fullVwin.sb_info.width;
+    int min_high = border;
+    XtGeometryResult geomreqresult;
+    Dimension reqWidth, reqHeight, repWidth, repHeight;
+#ifndef NO_ACTIVE_ICON
+    VTwin *saveWin = WhichVWin(screen);
+
+    /* all units here want to be in the normal font units */
+    WhichVWin(screen) = &screen->fullVwin;
+#endif /* NO_ACTIVE_ICON */
+
+    /*
+     * I'm going to try to explain, as I understand it, why we
+     * have to do XGetWMNormalHints and XSetWMNormalHints here,
+     * although I can't guarantee that I've got it right.
+     *
+     * In a correctly written toolkit program, the Shell widget
+     * parses the user supplied geometry argument.  However,
+     * because of the way xterm does things, the VT100 widget does
+     * the parsing of the geometry option, not the Shell widget.
+     * The result of this is that the Shell widget doesn't set the
+     * correct window manager hints, and doesn't know that the
+     * user has specified a geometry.
+     *
+     * The XtVaSetValues call below tells the Shell widget to
+     * change its hints.  However, since it's confused about the
+     * hints to begin with, it doesn't get them all right when it
+     * does the SetValues -- it undoes some of what the VT100
+     * widget did when it originally set the hints.
+     *
+     * To fix this, we do the following:
+     *
+     * 1. Get the sizehints directly from the window, going around
+     *    the (confused) shell widget.
+     * 2. Call XtVaSetValues to let the shell widget know which
+     *    hints have changed.  Note that this may not even be
+     *    necessary, since we're going to right ahead after that
+     *    and set the hints ourselves, but it's good to put it
+     *    here anyway, so that when we finally do fix the code so
+     *    that the Shell does the right thing with hints, we
+     *    already have the XtVaSetValues in place.
+     * 3. We set the sizehints directly, this fixing up whatever
+     *    damage was done by the Shell widget during the
+     *    XtVaSetValues.
+     *
+     * Gross, huh?
+     *
+     * The correct fix is to redo VTRealize, VTInitialize and
+     * VTSetValues so that font processing happens early enough to
+     * give back responsibility for the size hints to the Shell.
+     *
+     * Someday, we hope to have time to do this.  Someday, we hope
+     * to have time to completely rewrite xterm.
+     */
+
+    TRACE(("DoResizeScreen\n"));
+
+#if 1                          /* ndef nothack */
+    /*
+     * NOTE: the hints and the XtVaSetValues() must match.
+     */
+    TRACE(("%s@%d -- ", __FILE__, __LINE__));
+    TRACE_WM_HINTS(xw);
+    getXtermSizeHints(xw);
+
+    xtermSizeHints(xw, ScrollbarWidth(screen));
+
+    /* These are obsolete, but old clients may use them */
+    xw->hints.width = MaxCols(screen) * FontWidth(screen) + xw->hints.min_width;
+    xw->hints.height = MaxRows(screen) * FontHeight(screen) + xw->hints.min_height;
+#if OPT_MAXIMIZE
+    /* assure single-increment resize for fullscreen */
+    if (xw->screen.fullscreen) {
+       xw->hints.width_inc = 1;
+       xw->hints.height_inc = 1;
+    }
+#endif /* OPT_MAXIMIZE */
+#endif
+
+    XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints);
+
+    reqWidth = (Dimension) (MaxCols(screen) * FontWidth(screen) + min_wide);
+    reqHeight = (Dimension) (MaxRows(screen) * FontHeight(screen) + min_high);
+
+#if OPT_MAXIMIZE
+    /* compensate for fullscreen mode */
+    if (screen->fullscreen) {
+       Screen *xscreen = DefaultScreenOfDisplay(xw->screen.display);
+       reqWidth = (Dimension) WidthOfScreen(xscreen);
+       reqHeight = (Dimension) HeightOfScreen(xscreen);
+       ScreenResize(xw, reqWidth, reqHeight, &xw->flags);
+    }
+#endif /* OPT_MAXIMIZE */
+
+    TRACE(("...requesting screensize chars %dx%d, pixels %dx%d\n",
+          MaxRows(screen),
+          MaxCols(screen),
+          reqHeight, reqWidth));
+
+    geomreqresult = REQ_RESIZE((Widget) xw, reqWidth, reqHeight,
+                              &repWidth, &repHeight);
+
+    if (geomreqresult == XtGeometryAlmost) {
+       TRACE(("...almost, retry screensize %dx%d\n", repHeight, repWidth));
+       geomreqresult = REQ_RESIZE((Widget) xw, repWidth,
+                                  repHeight, NULL, NULL);
+    }
+
+    if (geomreqresult != XtGeometryYes) {
+       /* The resize wasn't successful, so we might need to adjust
+          our idea of how large the screen is. */
+       TRACE(("...still no (%d) - resize the core-class\n", geomreqresult));
+       xw->core.widget_class->core_class.resize((Widget) xw);
+    }
+#if 1                          /* ndef nothack */
+    /*
+     * XtMakeResizeRequest() has the undesirable side-effect of clearing
+     * the window manager's hints, even on a failed request.  This would
+     * presumably be fixed if the shell did its own work.
+     */
+    if (xw->hints.flags
+       && repHeight
+       && repWidth) {
+       xw->hints.height = repHeight;
+       xw->hints.width = repWidth;
+       TRACE_HINTS(&xw->hints);
+       XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints);
+    }
+#endif
+    XSync(screen->display, False);     /* synchronize */
+    if (XtAppPending(app_con))
+       xevents();
+
+#ifndef NO_ACTIVE_ICON
+    WhichVWin(screen) = saveWin;
+#endif /* NO_ACTIVE_ICON */
+}
+
+static Widget
+CreateScrollBar(XtermWidget xw, int x, int y, int height)
+{
+    Widget result;
+    Arg args[6];
+
+    XtSetArg(args[0], XtNx, x);
+    XtSetArg(args[1], XtNy, y);
+    XtSetArg(args[2], XtNheight, height);
+    XtSetArg(args[3], XtNreverseVideo, xw->misc.re_verse);
+    XtSetArg(args[4], XtNorientation, XtorientVertical);
+    XtSetArg(args[5], XtNborderWidth, ScrollBarBorder(xw));
+
+    result = XtCreateWidget("scrollbar", scrollbarWidgetClass,
+                           (Widget) xw, args, XtNumber(args));
+    XtAddCallback(result, XtNscrollProc, ScrollTextUpDownBy, 0);
+    XtAddCallback(result, XtNjumpProc, ScrollTextTo, 0);
+    return (result);
+}
+
+void
+ScrollBarReverseVideo(Widget scrollWidget)
+{
+    XtermWidget xw = getXtermWidget(scrollWidget);
+
+    if (xw != 0) {
+       SbInfo *sb = &(TScreenOf(xw)->fullVwin.sb_info);
+       Arg args[4];
+       Cardinal nargs = XtNumber(args);
+
+       /*
+        * Remember the scrollbar's original colors.
+        */
+       if (sb->rv_cached == False) {
+           XtSetArg(args[0], XtNbackground, &(sb->bg));
+           XtSetArg(args[1], XtNforeground, &(sb->fg));
+           XtSetArg(args[2], XtNborderColor, &(sb->bdr));
+           XtSetArg(args[3], XtNborderPixmap, &(sb->bdpix));
+           XtGetValues(scrollWidget, args, nargs);
+           sb->rv_cached = True;
+           sb->rv_active = 0;
+       }
+
+       sb->rv_active = !(sb->rv_active);
+       XtSetArg(args[!(sb->rv_active)], XtNbackground, sb->bg);
+       XtSetArg(args[(sb->rv_active)], XtNforeground, sb->fg);
+       nargs = 2;              /* don't set border_pixmap */
+       if (sb->bdpix == XtUnspecifiedPixmap) {
+           /* if not pixmap then pixel */
+           if (sb->rv_active) {
+               /* keep border visible */
+               XtSetArg(args[2], XtNborderColor, args[1].value);
+           } else {
+               XtSetArg(args[2], XtNborderColor, sb->bdr);
+           }
+           nargs = 3;
+       }
+       XtSetValues(scrollWidget, args, nargs);
+    }
+}
+
+void
+ScrollBarDrawThumb(Widget scrollWidget)
+{
+    XtermWidget xw = getXtermWidget(scrollWidget);
+
+    if (xw != 0) {
+       TScreen *screen = TScreenOf(xw);
+       int thumbTop, thumbHeight, totalHeight;
+
+       thumbTop = ROW2INX(screen, screen->savedlines);
+       thumbHeight = MaxRows(screen);
+       totalHeight = thumbHeight + screen->savedlines;
+
+       XawScrollbarSetThumb(scrollWidget,
+                            ((float) thumbTop) / (float) totalHeight,
+                            ((float) thumbHeight) / (float) totalHeight);
+    }
+}
+
+void
+ResizeScrollBar(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->scrollWidget != 0) {
+       int height = screen->fullVwin.height + screen->border * 2;
+       int width = screen->scrollWidget->core.width;
+       int ypos = -ScrollBarBorder(xw);
+#ifdef SCROLLBAR_RIGHT
+       int xpos = ((xw->misc.useRight)
+                   ? (screen->fullVwin.fullwidth -
+                      screen->scrollWidget->core.width -
+                      BorderWidth(screen->scrollWidget))
+                   : -ScrollBarBorder(xw));
+#else
+       int xpos = -ScrollBarBorder(xw);
+#endif
+
+       TRACE(("ResizeScrollBar at %d,%d %dx%d\n", ypos, xpos, height, width));
+
+       XtConfigureWidget(
+                            screen->scrollWidget,
+                            (Position) xpos,
+                            (Position) ypos,
+                            (Dimension) width,
+                            (Dimension) height,
+                            BorderWidth(screen->scrollWidget));
+       ScrollBarDrawThumb(screen->scrollWidget);
+    }
+}
+
+void
+WindowScroll(XtermWidget xw, int top, Bool always GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i, lines;
+    int scrolltop, scrollheight, refreshtop;
+
+#if OPT_SCROLL_LOCK
+    if (screen->allowScrollLock && (screen->scroll_lock && !always)) {
+       if (screen->scroll_dirty) {
+           screen->scroll_dirty = False;
+           ScrnRefresh(xw, 0, 0, MaxRows(screen), MaxCols(screen), False);
+       }
+    } else
+#endif
+    {
+       if (top < -screen->savedlines) {
+           top = -screen->savedlines;
+       } else if (top > 0) {
+           top = 0;
+       }
+
+       if ((i = screen->topline - top) != 0) {
+
+           if (screen->cursor_state)
+               HideCursor();
+           lines = i > 0 ? i : -i;
+           if (lines > MaxRows(screen))
+               lines = MaxRows(screen);
+           scrollheight = screen->max_row - lines + 1;
+           if (i > 0)
+               refreshtop = scrolltop = 0;
+           else {
+               scrolltop = lines;
+               refreshtop = scrollheight;
+           }
+           scrolling_copy_area(xw, scrolltop, scrollheight, -i);
+           screen->topline = top;
+
+           ScrollSelection(screen, i, True);
+
+           XClearArea(
+                         screen->display,
+                         VWindow(screen),
+                         OriginX(screen),
+                         OriginY(screen) + refreshtop * FontHeight(screen),
+                         (unsigned) Width(screen),
+                         (unsigned) (lines * FontHeight(screen)),
+                         False);
+           ScrnRefresh(xw, refreshtop, 0, lines, MaxCols(screen), False);
+
+#if OPT_BLINK_CURS || OPT_BLINK_TEXT
+           RestartBlinking(screen);
+#endif
+       }
+    }
+    ScrollBarDrawThumb(screen->scrollWidget);
+}
+
+#ifdef SCROLLBAR_RIGHT
+/*
+ * Adjust the scrollbar position if we're asked to turn on scrollbars for the
+ * first time (or after resizing) after the xterm is already running.  That
+ * makes the window grow after we've initially configured the scrollbar's
+ * position.  (There must be a better way).
+ */
+void
+updateRightScrollbar(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (xw->misc.useRight
+       && screen->fullVwin.fullwidth < xw->core.width)
+       XtVaSetValues(screen->scrollWidget,
+                     XtNx, screen->fullVwin.fullwidth - BorderWidth(screen->scrollWidget),
+                     (XtPointer) 0);
+}
+#endif
+
+void
+ScrollBarOn(XtermWidget xw, Bool init)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->fullVwin.sb_info.width || IsIcon(screen))
+       return;
+
+    TRACE(("ScrollBarOn(init %s)\n", BtoS(init)));
+    if (init) {                        /* then create it only */
+       if (screen->scrollWidget == 0) {
+           /* make it a dummy size and resize later */
+           screen->scrollWidget = CreateScrollBar(xw,
+                                                  -ScrollBarBorder(xw),
+                                                  -ScrollBarBorder(xw),
+                                                  5);
+           if (screen->scrollWidget == NULL) {
+               Bell(xw, XkbBI_MinorError, 0);
+           }
+       }
+    } else if (!screen->scrollWidget || !XtIsRealized((Widget) xw)) {
+       Bell(xw, XkbBI_MinorError, 0);
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+
+       ResizeScrollBar(xw);
+       xtermAddInput(screen->scrollWidget);
+       XtRealizeWidget(screen->scrollWidget);
+       TRACE_TRANS("scrollbar", screen->scrollWidget);
+
+       screen->fullVwin.sb_info.rv_cached = False;
+
+       screen->fullVwin.sb_info.width = (screen->scrollWidget->core.width
+                                         + BorderWidth(screen->scrollWidget));
+
+       TRACE(("setting scrollbar width %d = %d + %d\n",
+              screen->fullVwin.sb_info.width,
+              screen->scrollWidget->core.width,
+              BorderWidth(screen->scrollWidget)));
+
+       ScrollBarDrawThumb(screen->scrollWidget);
+       DoResizeScreen(xw);
+
+#ifdef SCROLLBAR_RIGHT
+       updateRightScrollbar(xw);
+#endif
+
+       XtMapWidget(screen->scrollWidget);
+       update_scrollbar();
+       if (screen->visbuf) {
+           xtermClear(xw);
+           Redraw();
+       }
+    }
+}
+
+void
+ScrollBarOff(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (!screen->fullVwin.sb_info.width || IsIcon(screen))
+       return;
+
+    TRACE(("ScrollBarOff\n"));
+    if (XtIsRealized((Widget) xw)) {
+       XtUnmapWidget(screen->scrollWidget);
+       screen->fullVwin.sb_info.width = 0;
+       DoResizeScreen(xw);
+       update_scrollbar();
+       if (screen->visbuf) {
+           xtermClear(xw);
+           Redraw();
+       }
+    } else {
+       Bell(xw, XkbBI_MinorError, 0);
+    }
+}
+
+/*
+ * Toggle the visibility of the scrollbars.
+ */
+void
+ToggleScrollBar(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (IsIcon(screen)) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+       TRACE(("ToggleScrollBar{{\n"));
+       if (screen->fullVwin.sb_info.width) {
+           ScrollBarOff(xw);
+       } else {
+           ScrollBarOn(xw, False);
+       }
+       update_scrollbar();
+       TRACE(("...ToggleScrollBar}}\n"));
+    }
+}
+
+/*ARGSUSED*/
+static void
+ScrollTextTo(
+               Widget scrollbarWidget,
+               XtPointer client_data GCC_UNUSED,
+               XtPointer call_data)
+{
+    XtermWidget xw = getXtermWidget(scrollbarWidget);
+
+    if (xw != 0) {
+       float *topPercent = (float *) call_data;
+       TScreen *screen = TScreenOf(xw);
+       int thumbTop;           /* relative to first saved line */
+       int newTopLine;
+
+       /*
+        * screen->savedlines : Number of offscreen text lines,
+        * MaxRows(screen)    : Number of onscreen  text lines,
+        */
+       thumbTop = (int) (*topPercent
+                         * (float) (screen->savedlines + MaxRows(screen)));
+       newTopLine = thumbTop - screen->savedlines;
+       WindowScroll(xw, newTopLine, True);
+    }
+}
+
+/*ARGSUSED*/
+static void
+ScrollTextUpDownBy(
+                     Widget scrollbarWidget,
+                     XtPointer client_data GCC_UNUSED,
+                     XtPointer call_data)
+{
+    XtermWidget xw = getXtermWidget(scrollbarWidget);
+
+    if (xw != 0) {
+       long pixels = (long) call_data;
+
+       TScreen *screen = TScreenOf(xw);
+       int rowOnScreen, newTopLine;
+
+       rowOnScreen = (int) (pixels / FontHeight(screen));
+       if (rowOnScreen == 0) {
+           if (pixels < 0)
+               rowOnScreen = -1;
+           else if (pixels > 0)
+               rowOnScreen = 1;
+       }
+       newTopLine = ROW2INX(screen, rowOnScreen);
+       WindowScroll(xw, newTopLine, True);
+    }
+}
+
+/*
+ * assume that b is alphabetic and allow plural
+ */
+static int
+CompareWidths(const char *a, const char *b, int *modifier)
+{
+    int result;
+    char ca, cb;
+
+    *modifier = 0;
+    if (!a || !b)
+       return 0;
+
+    for (;;) {
+       ca = x_toupper(*a);
+       cb = x_toupper(*b);
+       if (ca != cb || ca == '\0')
+           break;              /* if not eq else both nul */
+       a++, b++;
+    }
+    if (cb != '\0')
+       return 0;
+
+    if (ca == 'S')
+       ca = *++a;
+
+    switch (ca) {
+    case '+':
+    case '-':
+       *modifier = (ca == '-' ? -1 : 1) * atoi(a + 1);
+       result = 1;
+       break;
+
+    case '\0':
+       result = 1;
+       break;
+
+    default:
+       result = 0;
+       break;
+    }
+    return result;
+}
+
+static long
+params_to_pixels(TScreen * screen, String * params, Cardinal n)
+{
+    int mult = 1;
+    const char *s;
+    int modifier;
+
+    switch (n > 2 ? 2 : n) {
+    case 2:
+       s = params[1];
+       if (CompareWidths(s, "PAGE", &modifier)) {
+           mult = (MaxRows(screen) + modifier) * FontHeight(screen);
+       } else if (CompareWidths(s, "HALFPAGE", &modifier)) {
+           mult = ((MaxRows(screen) + modifier) * FontHeight(screen)) / 2;
+       } else if (CompareWidths(s, "PIXEL", &modifier)) {
+           mult = 1;
+       } else {
+           /* else assume that it is Line */
+           mult = FontHeight(screen);
+       }
+       mult *= atoi(params[0]);
+       break;
+    case 1:
+       mult = atoi(params[0]) * FontHeight(screen);    /* lines */
+       break;
+    default:
+       mult = screen->scrolllines * FontHeight(screen);
+       break;
+    }
+    return mult;
+}
+
+static long
+AmountToScroll(Widget w, String * params, Cardinal nparams)
+{
+    long result = 0;
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+       if (nparams <= 2
+           || screen->send_mouse_pos == MOUSE_OFF) {
+           result = params_to_pixels(screen, params, nparams);
+       }
+    }
+    return result;
+}
+
+/*ARGSUSED*/
+void
+HandleScrollForward(
+                      Widget xw,
+                      XEvent * event GCC_UNUSED,
+                      String * params,
+                      Cardinal *nparams)
+{
+    long amount;
+
+    if ((amount = AmountToScroll(xw, params, *nparams)) != 0) {
+       ScrollTextUpDownBy(xw, (XtPointer) 0, (XtPointer) amount);
+    }
+}
+
+/*ARGSUSED*/
+void
+HandleScrollBack(
+                   Widget xw,
+                   XEvent * event GCC_UNUSED,
+                   String * params,
+                   Cardinal *nparams)
+{
+    long amount;
+
+    if ((amount = -AmountToScroll(xw, params, *nparams)) != 0) {
+       ScrollTextUpDownBy(xw, (XtPointer) 0, (XtPointer) amount);
+    }
+}
+
+#if OPT_SCROLL_LOCK
+#define SCROLL_LOCK_LED 3
+
+#ifdef HAVE_XKBQUERYEXTENSION
+/*
+ * Check for Xkb on client and server.
+ */
+static int
+have_xkb(Display * dpy)
+{
+    static int initialized = -1;
+
+    if (initialized < 0) {
+       int xkbmajor = XkbMajorVersion;
+       int xkbminor = XkbMinorVersion;
+       int xkbopcode, xkbevent, xkberror;
+
+       initialized = 0;
+       if (XkbLibraryVersion(&xkbmajor, &xkbminor)
+           && XkbQueryExtension(dpy,
+                                &xkbopcode,
+                                &xkbevent,
+                                &xkberror,
+                                &xkbmajor,
+                                &xkbminor)) {
+           TRACE(("we have Xkb\n"));
+           initialized = 1;
+#if OPT_TRACE
+           {
+               XkbDescPtr xkb;
+               unsigned int mask;
+               int n;
+               char *modStr;
+
+               xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
+               if (xkb != NULL) {
+
+                   TRACE(("XkbGetKeyboard ok\n"));
+                   for (n = 0; n < XkbNumVirtualMods; ++n) {
+                       if (xkb->names->vmods[n] != 0) {
+                           modStr = XGetAtomName(xkb->dpy,
+                                                 xkb->names->vmods[n]);
+                           if (modStr != 0) {
+                               XkbVirtualModsToReal(xkb,
+                                                    (unsigned) (1 << n),
+                                                    &mask);
+                               TRACE(("  name[%d] %s (%#x)\n", n, modStr, mask));
+                           }
+                       }
+                   }
+                   XkbFreeKeyboard(xkb, 0, True);
+               }
+           }
+#endif
+       }
+    }
+    return initialized;
+}
+
+static Boolean
+getXkbLED(Display * dpy, const char *name, Boolean * result)
+{
+    Atom my_atom;
+    Boolean success = False;
+    Bool state;
+
+    if (have_xkb(dpy)) {
+       my_atom = XInternAtom(dpy, name, False);
+       if ((my_atom != None) &&
+           XkbGetNamedIndicator(dpy, my_atom, NULL, &state, NULL, NULL)) {
+           *result = (Boolean) state;
+           success = True;
+       }
+    }
+
+    return success;
+}
+
+/*
+ * Use Xkb if we have it (still unreliable, but slightly better than hardcoded).
+ */
+static Boolean
+showXkbLED(Display * dpy, const char *name, Bool enable)
+{
+    Atom my_atom;
+    Boolean result = False;
+
+    if (have_xkb(dpy)) {
+       my_atom = XInternAtom(dpy, name, False);
+       if ((my_atom != None) &&
+           XkbGetNamedIndicator(dpy, my_atom, NULL, NULL, NULL, NULL) &&
+           XkbSetNamedIndicator(dpy, my_atom, True, enable, False, NULL)) {
+           result = True;
+       }
+    }
+
+    return result;
+}
+#endif
+
+/*
+ * xlsatoms agrees with this list.  However Num/Caps lock are generally
+ * unusable due to special treatment in X.  They are used here for
+ * completeness.
+ */
+static const char *led_table[] =
+{
+    "Num Lock",
+    "Caps Lock",
+    "Scroll Lock"
+};
+
+static Boolean
+xtermGetLED(TScreen * screen, Cardinal led_number)
+{
+    Display *dpy = screen->display;
+    Boolean result = False;
+
+#ifdef HAVE_XKBQUERYEXTENSION
+    if (!getXkbLED(dpy, led_table[led_number - 1], &result))
+#endif
+    {
+       XKeyboardState state;
+       unsigned long my_bit = (unsigned long) (1 << (led_number - 1));
+
+       XGetKeyboardControl(dpy, &state);
+
+       result = (Boolean) ((state.led_mask & my_bit) != 0);
+    }
+
+    TRACE(("xtermGetLED %d:%s\n", led_number, BtoS(result)));
+    return result;
+}
+
+/*
+ * Display the given LED, preferably independent of keyboard state.
+ */
+void
+xtermShowLED(TScreen * screen, Cardinal led_number, Bool enable)
+{
+    TRACE(("xtermShowLED %d:%s\n", led_number, BtoS(enable)));
+    if ((led_number >= 1) && (led_number <= XtNumber(led_table))) {
+       Display *dpy = screen->display;
+
+#ifdef HAVE_XKBQUERYEXTENSION
+       if (!showXkbLED(dpy, led_table[led_number - 1], enable))
+#endif
+       {
+           XKeyboardState state;
+           XKeyboardControl values;
+           unsigned long use_mask;
+           unsigned long my_bit = (unsigned long) (1 << (led_number - 1));
+
+           XGetKeyboardControl(dpy, &state);
+           use_mask = state.led_mask;
+           if (enable) {
+               use_mask |= my_bit;
+           } else {
+               use_mask &= ~my_bit;
+           }
+
+           if (state.led_mask != use_mask) {
+               values.led = (int) led_number;
+               values.led_mode = enable;
+               XChangeKeyboardControl(dpy, KBLed | KBLedMode, &values);
+           }
+       }
+    }
+}
+
+void
+xtermClearLEDs(TScreen * screen)
+{
+    Display *dpy = screen->display;
+    XKeyboardControl values;
+
+    TRACE(("xtermClearLEDs\n"));
+#ifdef HAVE_XKBQUERYEXTENSION
+    ShowScrollLock(screen, False);
+#endif
+    memset(&values, 0, sizeof(values));
+    XChangeKeyboardControl(dpy, KBLedMode, &values);
+}
+
+void
+ShowScrollLock(TScreen * screen, Bool enable)
+{
+    xtermShowLED(screen, SCROLL_LOCK_LED, enable);
+}
+
+void
+GetScrollLock(TScreen * screen)
+{
+    if (screen->allowScrollLock)
+       screen->scroll_lock = xtermGetLED(screen, SCROLL_LOCK_LED);
+}
+
+void
+SetScrollLock(TScreen * screen, Bool enable)
+{
+    if (screen->allowScrollLock) {
+       if (screen->scroll_lock != enable) {
+           screen->scroll_lock = (Boolean) enable;
+           ShowScrollLock(screen, enable);
+       }
+    }
+}
+
+/* ARGSUSED */
+void
+HandleScrollLock(Widget w,
+                XEvent * event GCC_UNUSED,
+                String * params,
+                Cardinal *param_count)
+{
+    XtermWidget xw;
+
+    if ((xw = getXtermWidget(w)) != 0) {
+       TScreen *screen = TScreenOf(xw);
+
+       if (screen->allowScrollLock) {
+           /*
+            * The default action (used with KeyRelease event) is to cycle the
+            * state on/off.
+            */
+           if (*param_count == 0) {
+               SetScrollLock(screen, !screen->scroll_lock);
+               TRACE(("HandleScrollLock ->%d\n",
+                      screen->scroll_lock));
+           } else {
+               SetScrollLock(screen, atoi(params[0]));
+               TRACE(("HandleScrollLock(%s) ->%d\n",
+                      params[0],
+                      screen->scroll_lock));
+           }
+       }
+    }
+}
+#endif
diff --git a/sinstall.sh b/sinstall.sh
new file mode 100755 (executable)
index 0000000..fa85ec7
--- /dev/null
@@ -0,0 +1,198 @@
+#!/bin/sh
+# $XTermId: sinstall.sh,v 1.18 2010/03/06 16:19:13 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2008,2010 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# Install program setuid if the installer is running as root, and if xterm is
+# already installed on the system with setuid privilege.  This is a safeguard
+# for ordinary users installing xterm for themselves on systems where the
+# setuid is not needed to access a PTY, but only for things like utmp.
+#
+# Options:
+#      u+s, g+s as in chmod
+#      -u, -g and -m as in install.  If any options are given, $3 is ignored.
+#
+# Parameters:
+#      $1 = program to invoke as "install"
+#      $2 = program to install
+#      $3 = previously-installed program, for reference
+#      $4 = final installed-path, if different from reference
+
+trace=:
+trace=echo
+
+# override locale...
+# (otherwise GNU ls displays date column in a locale-dependent manner).
+LANG=C;                export LANG
+LANGUAGE=C;    export LANGUAGE
+LC_ALL=C;      export LC_ALL
+LC_CTYPE=C;    export LC_CTYPE
+
+OPTS_SUID=
+OPTS_SGID=
+OPTS_MODE=
+OPTS_USR=
+OPTS_GRP=
+
+while test $# != 0
+do
+       case $1 in
+       -*)
+               OPT="$1"
+               shift
+               if test $# != 0
+               then
+                       case $OPT in
+                       -u)     OPTS_USR="$1"; shift;;
+                       -g)     OPTS_GRP="$1"; shift;;
+                       -m)     OPTS_MODE="$1"; shift;;
+                       esac
+               else
+                       break
+               fi
+               ;;
+       u+s)    shift;  OPTS_SUID=4000;;
+       g+s)    shift;  OPTS_SGID=2000;;
+       *)      break
+               ;;
+       esac
+done
+
+SINSTALL="$1"
+SRC_PROG="$2"
+REF_PROG="$3"
+DST_PROG="$4"
+
+test -z "$SINSTALL" && SINSTALL=install
+test -z "$SRC_PROG" && SRC_PROG=xterm
+test -z "$REF_PROG" && REF_PROG=/usr/bin/X11/xterm
+test -z "$DST_PROG" && DST_PROG="$REF_PROG"
+
+test -n "$OPTS_SUID" && test -n "$OPTS_USR" && REF_PROG=
+test -n "$OPTS_SGID" && test -n "$OPTS_GRP" && REF_PROG=
+
+echo checking for presumed installation-mode
+
+PROG_SUID=
+PROG_SGID=
+PROG_MODE=
+PROG_USR=
+PROG_GRP=
+
+if test -z "$REF_PROG" ; then
+       $trace "... reference program not used"
+elif test -f "$REF_PROG" ; then
+       cf_option="-l -L"
+       MYTEMP=${TMPDIR-/tmp}/sinstall$$
+
+       # Expect listing to have fields like this:
+       #-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
+       ls $cf_option $REF_PROG
+       ls $cf_option $REF_PROG >$MYTEMP
+       read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <$MYTEMP
+       $trace "... if \"$cf_rest\" is null, try the ls -g option"
+       if test -z "$cf_rest" ; then
+               cf_option="$cf_option -g"
+               ls $cf_option $REF_PROG
+               ls $cf_option $REF_PROG >$MYTEMP
+               read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <$MYTEMP
+       fi
+       rm -f $MYTEMP
+
+       # If we have a pathname, and the date fields look right, assume we've
+       # captured the group as well.
+       $trace "... if \"$cf_rest\" is null, we do not look for group"
+       if test -n "$cf_rest" ; then
+               cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[0-9:]//g'`
+               $trace "... if we have date in proper columns ($cf_date1 $cf_date2 $cf_date3), \"$cf_test\" is null"
+               if test -z "$cf_test" ; then
+                       PROG_USR=$cf_usr;
+                       PROG_GRP=$cf_grp;
+               fi
+       fi
+       $trace "... derived user \"$PROG_USR\", group \"$PROG_GRP\" of previously-installed $SRC_PROG"
+
+       $trace "... see if mode \"$cf_mode\" has s-bit set"
+       case ".$cf_mode" in #(vi
+       .???s??s*) #(vi
+               $trace "... both setuid/setgid"
+               PROG_SUID=4000
+               PROG_SGID=2000
+               ;;
+       .???s*) #(vi
+               $trace "... setuid"
+               PROG_SUID=4000
+               PROG_GRP=
+               ;;
+       .??????s*)
+               $trace "... setgid"
+               PROG_SGID=2000
+               PROG_USR=
+               ;;
+       esac
+       PROG_MODE=`echo ".$cf_mode" | sed -e 's/^..//' -e 's/rw./7/g' -e 's/r-./5/g' -e 's/---/0/g' -e 's/--[sxt]/1/g' -e 's/[^0-7]//g'`
+fi
+
+# passed-in options override the reference
+test -n "$OPTS_SUID" && PROG_SUID="$OPTS_SUID"
+test -n "$OPTS_SGID" && PROG_SGID="$OPTS_SGID"
+test -n "$OPTS_MODE" && PROG_MODE="$OPTS_MODE"
+test -n "$OPTS_USR"  && PROG_USR="$OPTS_USR"
+test -n "$OPTS_GRP"  && PROG_GRP="$OPTS_GRP"
+
+# we always need a mode
+test -z "$PROG_MODE" && PROG_MODE=755
+
+if test -n "${PROG_USR}${PROG_GRP}" ; then
+       cf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
+       cf_usr=`id | sed -e 's/^[^(]*(//' -e 's/).*$//'`
+       cf_grp=`id | sed -e 's/^.* gid=[^(]*(//' -e 's/).*$//'`
+       $trace "... installing $SRC_PROG as user \"$cf_usr\", group \"$cf_grp\""
+       if test "$cf_uid" != 0 ; then
+               PROG_SUID=
+               PROG_SGID=
+               PROG_USR=""
+               PROG_GRP=""
+       fi
+       test "$PROG_USR" = "$cf_usr" && PROG_USR=""
+       test "$PROG_GRP" = "$cf_grp" && PROG_GRP=""
+fi
+
+test -n "${PROG_SUID}${PROG_SGID}" && PROG_MODE=`expr $PROG_MODE % 1000`
+test -n "$PROG_SUID" && PROG_MODE=`expr $PROG_SUID + $PROG_MODE`
+test -n "$PROG_SGID" && PROG_MODE=`expr $PROG_SGID + $PROG_MODE`
+
+test -n "$PROG_USR" && PROG_USR="-o $PROG_USR"
+test -n "$PROG_GRP" && PROG_GRP="-g $PROG_GRP"
+
+echo "$SINSTALL -m $PROG_MODE $PROG_USR $PROG_GRP $SRC_PROG $DST_PROG"
+eval "$SINSTALL -m $PROG_MODE $PROG_USR $PROG_GRP $SRC_PROG $DST_PROG"
diff --git a/tabs.c b/tabs.c
new file mode 100644 (file)
index 0000000..70d3e1e
--- /dev/null
+++ b/tabs.c
@@ -0,0 +1,179 @@
+/* $XTermId: tabs.c,v 1.38 2010/04/17 17:11:43 tom Exp $ */
+
+/*
+ * Copyright 2000-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* tabs.c */
+
+#include <xterm.h>
+#include <data.h>
+
+#define TAB_INDEX(n) ((n) >> TAB_BITS_SHIFT)
+#define TAB_MASK(n)  (1 << ((n) & (TAB_BITS_WIDTH-1)))
+
+#define SET_TAB(tabs,n) UIntSet(tabs[TAB_INDEX(n)], TAB_MASK(n))
+#define CLR_TAB(tabs,n) UIntClr(tabs[TAB_INDEX(n)], TAB_MASK(n))
+#define TST_TAB(tabs,n) (tabs[TAB_INDEX(n)] & (unsigned) TAB_MASK(n))
+
+/*
+ * places tabstops at only every 8 columns
+ */
+void
+TabReset(Tabs tabs)
+{
+    int i;
+
+    TabZonk(tabs);
+
+    for (i = 0; i < MAX_TABS; i += 8)
+       TabSet(tabs, i);
+}
+
+/*
+ * places a tabstop at col
+ */
+void
+TabSet(Tabs tabs, int col)
+{
+    if (col >= 0 && col < MAX_TABS) {
+       SET_TAB(tabs, col);
+    }
+}
+
+/*
+ * clears a tabstop at col
+ */
+void
+TabClear(Tabs tabs, int col)
+{
+    if (col >= 0 && col < MAX_TABS) {
+       CLR_TAB(tabs, col);
+    }
+}
+
+/*
+ * returns the column of the next tabstop
+ * (or MAX_TABS - 1 if there are no more).
+ * A tabstop at col is ignored.
+ */
+static int
+TabNext(XtermWidget xw, Tabs tabs, int col)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->curses && screen->do_wrap && (xw->flags & WRAPAROUND)) {
+       xtermIndex(xw, 1);
+       set_cur_col(screen, 0);
+       col = 0;
+       screen->do_wrap = False;
+    }
+    for (++col; col < MAX_TABS; ++col)
+       if (TST_TAB(tabs, col))
+           return (col);
+
+    return (MAX_TABS - 1);
+}
+
+/*
+ * returns the column of the previous tabstop
+ * (or 0 if there are no more).
+ * A tabstop at col is ignored.
+ */
+static int
+TabPrev(Tabs tabs, int col)
+{
+    for (--col; col >= 0; --col)
+       if ((col < MAX_TABS) && TST_TAB(tabs, col))
+           return (col);
+
+    return (0);
+}
+
+/*
+ * Tab to the next stop, returning true if the cursor moved
+ */
+Bool
+TabToNextStop(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int saved_column = screen->cur_col;
+    int next = TabNext(xw, xw->tabs, screen->cur_col);
+    int max = LineMaxCol(screen, getLineData(screen, screen->cur_row));
+
+    if (next > max)
+       next = max;
+    set_cur_col(screen, next);
+
+    return (screen->cur_col > saved_column);
+}
+
+/*
+ * Tab to the previous stop, returning true if the cursor moved
+ */
+Bool
+TabToPrevStop(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int saved_column = screen->cur_col;
+
+    set_cur_col(screen, TabPrev(xw->tabs, screen->cur_col));
+
+    return (screen->cur_col < saved_column);
+}
+
+/*
+ * clears all tabs
+ */
+void
+TabZonk(Tabs tabs)
+{
+    memset(tabs, 0, sizeof(*tabs) * TAB_ARRAY_SIZE);
+}
diff --git a/tektests/aitest.tek b/tektests/aitest.tek
new file mode 100644 (file)
index 0000000..254c4ec
--- /dev/null
@@ -0,0 +1 @@
+\e\f\1f\e1\1d,`g ],`g?C\1d3`t0@$`z0@\1f\1d,cg-F,cj-F,`m-G,lo-G,lr-G,lu-G,mx-G,m{-G,j~-G-ka-G-kd-G-hg-H-ej-H-fm-H-gp-H-as-I-bv-I-cy-I-m{-J-n~-J.la-K.id-K.kg-K.ej-L.gm-L.ep-M.cs-M.av-N.lx-O.j{-O.h~-P/ga-P/bd-Q/`g-R/oi-R/jl-S/eo-T/dr-U/cu-U/nw-V/jz-W/e}-X0``-Y0lb-Z0he-[0gh-[0ck-\0km-]0gp-^0cs-_0hu.A0dx.B0`{.C0i}.D1e`.E1nb.F1ge.G1`h.I1hj.J1bm.K1ko.L1`r.N1it.O1cw.P1hy.R1b|.S1h~.U2ba.V2gc.W2ne.Y2`h.[2jj.\2ll.^2go._2jq/A2ls/C2cv/D2fx/F2iz/H2l|/J2`\7f/L3ga/M3gc/O3je/Q3ng/S3ni/U3nk/W3bn/Y3cp/[3cr/]3`t0@\1f\1d,cg-F,cd-F,`a-G+d~-G+d{-G+dx-G+eu-G+er-G+jo-G+kl-G+ki-G+hf-H+mc-H+n`-H*o}-H*a{-I*bx-I*cu-I*er-J*fo-J*dl-K*ii-K*kf-K*mc-L*o`-L)m}-M)c{-M)ax-N)du-O)jr-O)ho-P)ol-P)bj-Q)`g-R)gd-R)ja-S(m~-T(l{-U(cy-U(fv-V(js-W(mp-X(`n-Y(dk-Z(hh-[(oe-[(cc-\(k`-]'o}-^'c{-_'hx.A'lu.B'`s.C'ip.D'mm.E'fk.F'oh.G'`f.I'hc.J'ba.K&k~.L&`|.N&iy.O&cw.P&ht.R&br.S&ho.U&bm.V&oj.W&fh.Y&`f.[&jc.\&da.^%o~._%j|/A%dz/C%cx/D%nu/F%is/H%dq/J%`o/L%ol/M%oj/O%jh/Q%ff/S%fd/U%fb/W%b`/Y$c~/[$c|/]$`z0@\1f\1d,ag2Y,ad2Y,`a2Y+d~2Y+d{2Y+dx2Y+gu2X+gr2X+jo2X+il2X+ii2X+hf2X+oc2W+n`2W*m}2W*c{2V*bx2V*au2V*gr2U*fo2U*dl2U*ki2T*if2T*oc2S*m`2S)o}2R)a{2R)cx2Q)du2Q)jr2P)ho2P)ml2O)bj2N)`g2N)ed2M)ja2L(o~2K(l{2K(ay2J(fv2I(js2H(op2G(`n2G(dk2F(hh2E(me2D(ac2C(i`2B'm}2A'a{2@'hx1_'lu1^'`s1]'kp1['om1Z'fk1Y'mh1X'`f1W'hc1V'ba1T&i~1S&`|1R&ky1P&aw1O&ht1N&br1L&ho1K&bm1I&mj1H&fh1F&`f1E&jc1C&da1B%m~1@%j|0^%dz0]%ax0[%nu0Y%ks0W%dq0V%`o0T%ml0R%mj0P%jh0N%ff0L%fd0J%fb0H%b`0F$a~0D$a|0B$`z0@\1f\1d,ag2Y,aj2Y,`m2Y,lo2Y,lr2Y,lu2Y,ox2X,o{2X,j~2X-ia2X-id2X-hg2X-gj2W-fm2W-ep2W-cs2V-bv2V-ay2V-o{2U-n~2U.la2U.kd2T.ig2T.gj2S.em2S.gp2R.as2R.cv2Q.lx2Q.j{2P.h~2P/ea2O/bd2N/`g2N/mi2M/jl2L/go2K/dr2K/au2J/nw2I/jz2H/g}2G0``2G0lb2F0he2E0eh2D0ak2C0im2B0ep2A0as2@0hu1_0dx1^0`{1]0k}1[1g`1Z1nb1Y1ee1X1`h1W1hj1V1bm1T1io1S1`r1R1kt1P1aw1O1hy1N1b|1L1h~1K2ba1I2ec1H2ne1F2`h1E2jj1C2ll1B2eo1@2jq0^2ls0]2av0[2fx0Y2kz0W2l|0V2`\7f0T3ea0R3ec0P3je0N3ng0L3ni0J3nk0H3bn0F3ap0D3ar0B3`t0@\1f\1d,ag*O,aj*O,am*O,bp*O,bs*O,gv*O,dy*P,e|*P,f\7f*P-db*Q-ee*Q-gh*Q-ek*R-gn*R-eq*S-gt*S-fw*T-ez*U-d}*V.g`*V.fc*W.ef*X.ai*Y.al*Z.ao*[.ar*\.au*].mw*^.nz*_.o}+@/h`+B/ic+C/ff+D/gi+E/al+G/co+H/mq+J/ot+K/iw+M/dz+O/b}+P0a`+R0lb+T0ke+U0gh+W0bk+Y0nm+[0jp+]0fs+_0nu,A0jx,C0g{,E0l},H1i`,J1bc,L1oe,N1eh,Q1nj,S1hm,V1bp,X1ir,[1cu,]1jw-@1`z-C1g|-E1o~-H2fa-K2jc-N2bf-Q2fh-T2jj-W2bm-Z2go-]2hq.A2ms.D2bv.G2`x.K2ez.N2k|.Q2i~.U3h`.Y3nb.\3md/@3lf/D3oh/G3oj/K3kl/O3kn/S3gp/W3gr/[3`t0@\1f\1d,ag*O,ad*O,aa*O+b~*O+b{*O+ow*O+lt*P+mq*P+nn*P+lk*Q+mh*Q+oe*Q+mb*R*o\7f*R*m|*S*oy*S*nv*T*ms*U*lp*V*om*V*nj*W*mg*X*ae*Y*ab*Z)a\7f*[)a|*\)ay*])ev*^)fs*_)gp+@)hm+B)ij+C)ng+D)od+E)ab+G(c\7f+H(e|+J(gy+K(iv+M(ls+O(bq+P(an+R(dk+T(kh+U(oe+W(bc+Y(f`+['j}+]'nz+_'fx,A'ju,C'or,E'dp,H'im,J'bk,L'gh,N'me,Q'fc,S'h`,V&b~,X&i{,[&cy,]&jv-@&`t-C&oq-E&go-H&nl-K&jj-N&bh-Q&ne-T&jc-W&ba-Z%o~-]%h|.A%ez.D%bx.G%`v.K%ms.N%kq.Q%io.U%hm.Y%fk.\%ei/@%dg/D%ge/G%gc/K%ka/O$k\7f/S$o}/W$o{/[$`z0@\1f\1d,cg5P,cd5P,ca5P+b~5P+b{5P+mw5P+lt5P+oq5O+nn5O+lk5O+oh5N+me5N+ob5M*m\7f5M*o|5L*my5L*nv5K*os5J*lp5J*mm5I*nj5H*og5G*ce5F*cb5E)c\7f5D)c|5C)cy5B)gv5A)fs5@)ep4_)hm4^)kj4\)ng4[)md4Z)cb4X(a\7f4W(g|4U(ey4T(kv4R(ls4Q(bq4O(cn4M(dk4L(ih4J(me4H(bc4F(f`4D'j}4B'nz4@'fx3^'ju3\'mr3Z'dp3X'km3U'bk3S'eh3Q'oe3N'fc3L'h`3J&b~3G&k{3D&ay3B&jv2_&`t2]&mq2Z&eo2W&nl2T&jj2Q&bh2N&ne2K&jc2H&ba2E%m~2B%h|1_%gz1[%bx1X%`v1U%os1Q%iq1N%ko1J%hm1G%fk1C%gi0_%dg0\%ee0X%ec0T%ia0P$i\7f0L$m}0H$m{0D$`z0@\1f\1d,cg5P,cj5P,cm5P,bp5P,bs5P,ev5P,dy5P,g|5O,f\7f5O-db5O-ge5N-eh5N-gk5M-en5M-gq5L-et5L-fw5K-gz5J-d}5J.e`5I.fc5H.gf5G.ci5F.cl5E.co5D.cr5C.cu5B.ow5A.nz5@.m}4_/h`4^/kc4\/ff4[/ei4Z/cl4X/ao4W/oq4U/mt4T/kw4R/dz4Q/b}4O0c`4M0lb4L0ie4J0eh4H0bk4F0nm4D0jp4B0fs4@0nu3^0jx3\0e{3Z0l}3X1k`3U1bc3S1me3Q1gh3N1nj3L1hm3J1bp3G1kr3D1au3B1jw2_1`z2]1e|2Z1m~2W2fa2T2jc2Q2bf2N2fh2K2jj2H2bm2E2eo2B2hq1_2os1[2bv1X2`x1U2gz1Q2i|1N2k~1J3h`1G3nb1C3od0_3lf0\3mh0X3mj0T3il0P3in0L3ep0H3er0D3`t0@\1f\1d,bg'Z,gj'Z,gm'Z,hp'[,ls'[,nv'[,cz'[,e}'\-f`'\-ic']-kf']-ni'^-am'_-`p(@-gs(@-gv(A-ky(B-k|(C-o\7f(D.lb(F.me(G.bi(H.`l(J.ao(K.gr(L.eu(N.dx(P.g{(Q.f~(S/ea(U/dd(W/dg(Y/dj([/dm(]/ep(_/es)A/cv)C/`y)F/a|)H/o~)J0ma)M0kd)O0jg)R0ej)U0`m)X0oo)Z0kr)]0gu*@0cx*C0oz*F0h}*J1e`*M1bc*P1ke*S1eh*W1oj*Z1em*^1`p+B1kr+E1bu+I1iw+M1`z+Q1d|+U1l~+Y2aa+]2ic,A2ne,E2`h,J2ij,N2ol,R2mn,W2cq,[2fs-@2du-E2hw-J2ky-N2k{-S2k}-X2k\7f-]3ka.B3dc.H3ae.M3cg.R3lh.X3jj.]3dl/C3om/H3jo/N3aq/T3hr/Z3`t0@\1f\1d,bg'Z,oc'Z,o`'Z+h}'[+dz'[+fw'[+ct'[+mp'\+nm'\+ij']+kg']+fd'^+aa'_*`~(@*oz(@*ow(A*kt(B*kq(C*gn(D*dk(F*eh(G*be(H*`b(J)a\7f(K)o{(L)mx(N)lu(P)or(Q)no(S)ml(U)li(W)lf(Y)lc([)l`(](m}(_(mz)A(cx)C(`u)F(ar)H(go)J(el)M(ki)O(jf)R(mc)U(`a)X'g~)Z'k{)]'ox*@'cv*C'gs*F'hp*J'mm*M'bk*P'kh*S'me*W'gc*Z'm`*^&`~+B&k{+E&by+I&iv+M&`t+Q&lq+U&do+Y&am+]&ij,A&fh,E&`f,J&ic,N&ga,R%e\7f,W%c},[%nz-@%lx-E%hv-J%kt-N%kr-S%kp-X%kn-]%kl.B%lj.H%ai.M%cg.R%de.X%jc.]%la/C%g`/H$j~/N$a}/T$h{/Z$`z0@\1f\1d,bg8E,mc8E,m`8E+h}8E+dz8E+fw8D+at8D+op8C+nm8C+kj8B+ig8B+fd8A+ca8@*`~8@*mz7_*mw7^*it7]*iq7\*en7[*dk7Z*gh7X*be7W*`b7V)c\7f7T)m{7S)ox7Q)lu7P)mr7N)no7L)ol7J)li7I)lf7G)lc7E)l`7C(o}7@(oz6^(ax6\(`u6Z(cr6W(eo6U(gl6R(ii6P(jf6M(oc6J(`a6H'e~6E'i{6B'mx5_'av5\'es5Y'hp5V'om5R'bk5O'ih5L'oe5H'ec5E'o`5A&`~4^&i{4Z&by4V&kv4R&`t4O&lq4K&do4G&cm4B&kj3^&fh3Z&`f3V&kc3Q&ea3M%g\7f3H%a}3D%nz2_%lx2[%hv2V%it2Q%ir2L%ip2G%in2B%il1]%lj1X%ci1R%ag1M%de1H%jc1B%la0]%e`0W$j~0Q$c}0K$h{0F$`z0@\1f\1d,bg8E,ej8E,em8E,hp8E,ls8E,nv8D,az8D,g}8C-f`8C-kc8B-if8B-ni8A-cm8@-`p8@-es7_-ev7^-iy7]-i|7\-m\7f7[.lb7Z.oe7X.bi7W.`l7V.co7T.er7S.gu7Q.dx7P.e{7N.f~7L/ga7J/dd7I/dg7G/dj7E/dm7C/gp7@/gs6^/av6\/`y6Z/c|6W/m~6U0oa6R0id6P0jg6M0gj6J0`m6H0mo6E0ir6B0eu5_0ax5\0mz5Y0h}5V1g`5R1bc5O1ie5L1gh5H1mj5E1gm5A1`p4^1ir4Z1bu4V1kw4R1`z4O1d|4K1l~4G2ca4B2kc3^2ne3Z2`h3V2kj3Q2ml3M2on3H2aq3D2fs2_2du2[2hw2V2iy2Q2i{2L2i}2G2i\7f2B3ia1]3dc1X3ce1R3ag1M3lh1H3jj1B3dl0]3mm0W3jo0Q3cq0K3hr0F3`t0@\1f\1d,bg%J,jj%J,om%J,gq%J,it%K,bx%K,d{%L,j~%L-ab%M-de%N-oh%N-cl%O-ko%P-or%Q-`v%S-ey%T-n|%U.``%W.fc%X.hf%Z.oi%[.fm%].jp%_.ms&A.nv&C.bz&E.g}&G/h`&J/nc&L/of&N/bj&Q/dm&T/gp&V/fs&Y/jv&\/jy&_/j|'B/j\7f'E0kb'H0ie'L0jh'O0hk'S0jn'V0eq'Z0dt'^0cw(A0oy(E0o|(I0k\7f(M1gb(Q1`e(V1ng(Z1gj(^1am)C1ko)G1fr)L1mt)Q1dw)V1ly)[1d|*@1h~*E2`a*J2ec*O2ne*T2`h*Z2fj*_2dl+E2jn+J2mp+P2lr+V2ot+[2ov,A2ox,G2oz,M2h|,T2i~,Z3f`-@3cb-F3mc-M3ge-S3ag-Z3hh.A3cj.G3jk.N3nl.U3an.\3io/C3np/J3nq/Q3cs/X3`t0@\1f\1d,bg%J,jc%J,g`%J+o|%J+iy%K+bv%K+lr%L+jo%L+al%M+lh%N+ge%N+cb%O*k~%P*g{%Q*`x%S*mt%T*fq%U*`n%W*nj%X*hg%Z*gd%[*n`%])j}%_)ez&A)fw&C)bt&E)op&G)hm&J)fj&L)gg&N)bd&Q)l`&T(o}&V(nz&Y(jw&\(jt&_(jq'B(jn'E(kk'H(ih'L(je'O(hb'S'j\7f'V'm|'Z'ly'^'cw(A'gt(E'gq(I'kn(M'ok(Q'`i(V'ff(Z'oc(^'aa)C&k~)G&n{)L&ey)Q&lv)V&dt)[&lq*@&ho*E&`m*J&mj*O&fh*T&`f*Z&nc*_&la+E%j\7f+J%e}+P%d{+V%gy+[%gw,A%gu,G%gs,M%hq,T%io,Z%nm-@%cl-F%ej-M%oh-S%ag-Z%he.A%cd.G%jb.N%fa.U%a`.\$i~/C$f}/J$f|/Q$c{/X$`z0@\1f\1d,bg:U,jc:U,e`:U+m|:U+ky:T+bv:T+lr:T+jo:S+cl:R+lh:R+ee:Q+ab:P*i~:O*e{:N*`x:M*ot:K*fq:J*`n:I*nj:G*hg:F*ed:D*n`:B)j}:@)gz9^)fw9\)bt9Z)mp9X)hm9V)fj9S)eg9Q)bd9N)l`9L(m}9I(nz9F(jw9C(jt9@(jq8](jn8Z(ik8W(kh8S(je8P(hb8M'j\7f8I'o|8E'ly8B'aw7^'et7Z'eq7V'in7R'mk7N'`i7J'ff7E'mc7A'ca6\&i~6X&n{6S&gy6N&lv6J&dt6E&lq6@&ho5[&`m5V&oj5P&fh5K&`f5F&nc5@&la4[%j\7f4U%g}4O%d{4J%ey4D%ew3^%eu3X%es3R%hq3L%ko3E%nm2_%al2Y%gj2R%mh2L%cg2E%he1_%ad1X%jb1Q%fa1J%c`1C$k~0\$f}0U$f|0N$a{0G$`z0@\1f\1d,bg:U,jj:U,mm:U,eq:U,kt:T,bx:T,d{:T,j~:S-cb:R-de:R-mh:Q-al:P-io:O-mr:N-`v:M-gy:K-n|:J.``:I.fc:G.hf:F.mi:D.fm:B.jp:@.os9^.nv9\.bz9Z.e}9X/h`9V/nc9S/mf9Q/bj9N/dm9L/ep9I/fs9F/jv9C/jy9@/j|8]/j\7f8Z0ib8W0ke8S0jh8P0hk8M0jn8I0gq8E0dt8B0aw7^0my7Z0m|7V0i\7f7R1eb7N1`e7J1ng7E1ej7A1cm6\1io6X1fr6S1ot6N1dw6J1ly6E1d|6@1h~5[2`a5V2gc5P2ne5K2`h5F2fj5@2dl4[2jn4U2op4O2lr4J2mt4D2mv3^2mx3X2mz3R2h|3L2k~3E3f`2_3ab2Y3oc2R3ee2L3cg2E3hh1_3aj1X3jk1Q3nl1J3cn1C3ko0\3np0U3nq0N3as0G3`t0@\1f\1d,ag#@,mj#@,fn#@,cr#@,lu#A,jy#A,a}#B-l`#C-kd#C-ch#D-ok#E-ho#G-as#H-ov#I-ez#K-l}#M.ka#N.be#P.jh#R.fl#T.oo#V.ds#Y.nv#[.dz#^.o}$@/fa$C/id$F/ah$I/ik$L/nn$O/cr$R/iu$V/ox$Y/a|$]/d\7f%A0kb%D0oe%H0oh%L0`l%Q0ao%U0fr%Y0du%^0fx&B0d{&G0g~&K1ca&P1cd&U1of&Z1ki&_1hl'E1ao'J1oq'O1it'U1cw'Z1ny(@1e|(F1m~(L2`a(R2ic(X2me(^2fh)D2kj)J2il)Q2on)W2mp)^2cs*D2bu*K2aw*R2mx*Y2lz+@2h|+G2e~+N3a`+U3ja+\3cc,C3hd,K3bf,R3hg,Z3nh-A3`j-I3gk-P3jl-X3im.@3hn.H3ho.P3kp.W3gq._3cr/G3or/O3hs/X3`t0@\1f\1d,ag#@,ec#@+n\7f#@+c|#@+dx#A+jt#A+aq#B+dm#C+ki#C+cf#D+gb#E*h~#G*a{#H*gw#I*ms#K*dp#M*kl#N*bi#P*je#R*na#T)g~#V)lz#Y)fw#[)ls#^)gp$@)nl$C)ii$F)af$I)ib$L(f\7f$O(c|$R(ix$V(gu$Y(ar$](ln%A(kk%D(gh%H(ge%L(`b%Q'a\7f%U'n{%Y'lx%^'nu&B'lr&G'oo&K'cm&P'cj&U'gg&Z'kd&_'ha'E&a\7f'J&g|'O&iy'U&cw'Z&ft(@&mq(F&eo(L&`m(R&ij(X&eh(^&ne)D&kc)J&ia)Q%g\7f)W%e})^%c{*D%by*K%aw*R%eu*Y%ds+@%hq+G%mo+N%an+U%jl+\%ck,C%hi,K%bh,R%hf,Z%fe-A%`d-I%ob-P%ja-X%i`.@$h\7f.H$h~.P$k}.W$o|._$c|/G$g{/O$hz/X$`z0@\1f\1d,cg<_,gc<_+n\7f<_+a|<_+dx<_+jt<^+cq<]+dm<]+ii<\+af<[+eb<Z*h~<Y*c{<W*ew<V*os<T*dp<S*il<Q*bi<O*je<M*na<K)e~<I)lz<G)fw<D)ls<B)ep;_)nl;\)ki;Y)cf;V)kb;S(f\7f;P(a|;M(kx;I(eu;F(cr;B(ln:_(ik:[(eh:W(ee:S(`b:O'c\7f:J'n{:F'lx:B'nu9]'lr9Y'mo9T'am9O'aj9J'eg9E'id9@'ha8[&c\7f8U&e|8P&ky8J&aw8E&ft7_&oq7Y&go7S&`m7N&kj7G&gh7A&ne6[&ic6U&ka6N%e\7f6H%g}6A%a{5[%by5T%cw5M%gu5F%ds5@%hq4Y%oo4Q%cn4J%jl4C%ak3\%hi3U%bh3M%hf3F%fe2^%`d2W%mb2O%ja2G%k`1_$h\7f1X$h~1P$i}1H$m|1@$a|0X$e{0P$hz0H$`z0@\1f\1d,cg<_,oj<_,fn<_,ar<_,lu<_,jy<^,c}<]-l`<]-id<\-ah<[-mk<Z-ho<Y-cs<W-mv<V-gz<T-l}<S.ia<Q.be<O.jh<M.fl<K.mo<I.ds<G.nv<D.dz<B.m};_/fa;\/kd;Y/ch;V/kk;S/nn;P/ar;M/ku;I/mx;F/c|;B/d\7f:_0ib:[0me:W0mh:S0`l:O0co:J0fr:F0du:B0fx9]0d{9Y0e~9T1aa9O1ad9J1mf9E1ii9@1hl8[1co8U1mq8P1kt8J1aw8E1ny7_1g|7Y1o~7S2`a7N2kc7G2oe7A2fh6[2ij6U2kl6N2mn6H2op6A2as5[2bu5T2cw5M2ox5F2lz5@2h|4Y2g~4Q3c`4J3ja4C3ac3\3hd3U3bf3M3hg3F3nh2^3`j2W3ek2O3jl2G3km1_3hn1X3ho1P3ip1H3eq1@3ar0X3mr0P3hs0H3`t0@\1f\1d,`g ],dk ],eo ],ks ],iw ^,o{ ^,o\7f _-bd!@-ch!A-`l!C-ep!D-gt!E-fx!G-f|!I.e`!K.fd!M.gh!O.dl!R.gp!T.et!W.ax!Z.`|!].m\7f"@/jc"C/kg"F/ek"J/`o"N/kr"Q/fv"U/bz"Y/k}"]0`a#B0jd#F0`h#K0jk#O0ao#T0er#Y0mu#^0by$C0g|$H0d\7f$N1jb$S1he$Y1oh$^1nk%D1jn%J1jq%P1ft%V1gw%\1ly&C1j|&I1d\7f&P2oa&V2ed&]2lf'D2di'K2hk'R2lm'Y2`p(@2er(G2ft(N2gv(U2ex(]2gz)D2a|)L2l})T2j\7f)[3ea*C3lb*K3dd*S3oe*Z3cg+B3kh+J3oi+R3oj+Z3`l,C3am,K3an,S3nn,[3oo-C3ip-L3bq-T3oq-\3er.E3nr.M3`s.V3is.^3os/F3ms/O3bt/W3`t0@\1f\1d,`g ],lb ]+m~ ]+kz ]+iv ^+gr ^+gn _+bj!@+cf!A+`b!C*m}!D*oy!E*nu!G*nq!I*mm!K*ni!M*oe!O*la!R)o}!T)my!W)av!Z)`r!])en"@)jj"C)kf"F)mb"J(`\7f"N(k{"Q(nw"U(bt"Y(kp"](`m#B(ji#F(`f#K(jb#O'a\7f#T'm{#Y'ex#^'bu$C'oq$H'ln$N'jk$S'hh$Y'ge$^'fb%D&j\7f%J&j|%P&ny%V&ov%\&dt&C&jq&I&ln&P&gl&V&mi&]&dg'D&ld'K&hb'R&d`'Y%`~(@%m{(G%ny(N%ow(U%mu(]%os)D%ar)L%dp)T%jn)[%ml*C%dk*K%li*S%gh*Z%cg+B%ke+J%gd+R%gc+Z%`b,C%aa,K%a`,S$f\7f,[$g~-C$i}-L$b}-T$g|-\$m{.E$f{.M$`{.V$iz.^$gz/F$ez/O$bz/W$`z0@\1f\1d,`g?C,lb?C+o~?B+iz?B+kv?A+er?A+en?@+bj>_+af>^+`b>]*o}>[*my>Z*nu>X*nq>V*om>T*ni>R*me>P*la>N)m}>K)oy>H)cv>E)`r>C)gn=_)jj=\)if=Y)ob=U(`\7f=R(i{=N(nw=J(bt=F(ip=B(`m<^(ji<Y(`f<U(jb<P'c\7f<K'o{<F'gx<A'bu;\'mq;W'ln;R'jk;L'hh;G'ee;A'fb:[&j\7f:U&j|:O&ny:I&mv:C&dt9]&jq9V&ln9P&el9I&oi9B&dg8\&ld8U&hb8N&d`8G%`~8@%o{7X%ny7Q%mw7J%ou7B%ms6[%cr6S%dp6L%jn6D%ol5\%dk5U%li5M%eh5E%ag4]%ie4U%ed4M%ec4E%`b3]%ca3T%c`3L$f\7f3D$e~2\$k}2S$b}2K$e|2C$o{1Z$f{1R$`{1J$kz1A$ez0Y$gz0P$bz0H$`z0@\1f\1d,`g?C,dk?C,go?B,is?B,kw?A,m{?A,m\7f?@-bd>_-ah>^-`l>]-gp>[-et>Z-fx>X-f|>V.g`>T.fd>R.eh>P.dl>N.ep>K.gt>H.cx>E.`|>C.o\7f=_/jc=\/ig=Y/gk=U/`o=R/ir=N/fv=J/bz=F/i}=B0`a<^0jd<Y0`h<U0jk<P0co<K0gr<F0ou<A0by;\0e|;W0d\7f;R1jb;L1he;G1mh;A1nk:[1jn:U1jq:O1ft:I1ew:C1ly9]1j|9V1d\7f9P2ma9I2gd9B2lf8\2di8U2hk8N2lm8G2`p8@2gr7X2ft7Q2ev7J2gx7B2ez6[2c|6S2l}6L2j\7f6D3ga5\3lb5U3dd5M3me5E3ag4]3ih4U3mi4M3mj4E3`l3]3cm3T3cn3L3nn3D3mo2\3kp2S3bq2K3mq2C3gr1Z3nr1R3`s1J3ks1A3ms0Y3os0P3bt0H3`t0@\1f\1d.l}0@.o}/Z.m}/U.l}/P.o}/J.m}/E.l}/@.b~.Z.a~.U.`~.P.c~.J.a~.E.d~.@.g~-Z.f~-U.h~-P.k~-J.n~-E.m~-@.l~,[.c\7f,U.b\7f,P.e\7f,K.h\7f,F.h\7f,A.o\7f+[.n\7f+V/a`+Q/e`+L/h`+G/h`+B/o`*\/ca*W/fa*R/ja*M/na*H/na*C/bb)^/fb)Y/jb)T/bc)O/fc)J/kc)E/oc)@/`d(\/dd(W/md(R/be(M/ge(H/le(D/af'_/ff'Z/of'U/ag'Q/jg'L/lg'H/eh'C/oh&^/ai&Z/ki&U/bj&Q/hj&M/bk&H/ik&D/`l&@/kl%[/bm%W/im%S/`n%O/kn%J/co%F/oo%B/gp$^/op$Z/kq$V/cr$R/lr$O/is$K/at$G/nt$C/hu$@/ev#\/cw#X/mw#U/kx#Q/ey#N/cz#J/b{#G/m{#D/h|#A/k}"]\1f\1d)dp0@)gp/Z)ep/U)dp/P)gp/J)ep/E)dp/@)bp.Z)ap.U)`p.P)cp.J)ap.E)lo.@)oo-Z)no-U)ho-P)ko-J)fo-E)eo-@)do,[)co,U)bo,P)mn,K)hn,F)hn,A)gn+[)fn+V)an+Q)mm+L)hm+G)hm+B)gm*\)cm*W)nl*R)jl*M)fl*H)fl*C)bl)^)nk)Y)jk)T)bk)O)nj)J)kj)E)gj)@)`j(\)li(W)ei(R)bi(M)oh(H)dh(D)ah'_)ng'Z)gg'U)ag'Q)jf'L)df'H)me'C)ge&^)ae&Z)kd&U)bd&Q)hc&M)bc&H)ib&D)`b&@)ka%[)ba%W)i`%S)``%O(k\7f%J(c\7f%F(g~%B(o}$^(g}$Z(k|$V(c|$R(d{$O(iz$K(az$G(fy$C(hx$@(mw#\(cw#X(ev#U(ku#Q(mt#N(ct#J(bs#G(er#D(hq#A(kp"]\1f\1d)dp0@)ep0E)gp0J)dp0P)ep0U)gp0Z)dp1@)bp1E)cp1J)`p1P)ap1U)cp1Z)lo2@)mo2E)no2J)ho2P)io2U)fo2Z)go2_)do3E)ao3J)bo3O)on3T)hn3Z)hn3_)en4D)fn4I)cn4N)om4S)hm4Y)hm4^)em5C)am5H)nl5M)jl5R)fl5W)fl5\)bl6A)nk6F)jk6K)bk6P)nj6U)ij6Z)ej6_)`j7D)li7I)gi7M)bi7R)mh7W)dh7\)ch8@)ng8E)eg8J)cg8N)jf8S)df8X)oe8\)ee9A)ce9E)id9J)bd9N)hc9S)bc9W)kb9[)`b:@)ia:D)ba:H)k`:L)``:Q(i\7f:U(a\7f:Y(e~:](m};A(e};E(i|;I(a|;M(d{;Q(kz;T(cz;X(fy;\(hx<@(ow<C(aw<G(gv<J(iu<N(ot<Q(at<U(bs<X(gr<[(hq<_(ip=B\1f\1d.l}0@.m}0E.o}0J.l}0P.m}0U.o}0Z.l}1@.b~1E.c~1J.`~1P.a~1U.c~1Z.d~2@.e~2E.f~2J.h~2P.i~2U.n~2Z.o~2_.l~3E.a\7f3J.b\7f3O.g\7f3T.h\7f3Z.h\7f3_.m\7f4D.n\7f4I/c`4N/g`4S/h`4Y/h`4^/m`5C/aa5H/fa5M/ja5R/na5W/na5\/bb6A/fb6F/jb6K/bc6P/fc6U/ic6Z/mc6_/`d7D/dd7I/od7M/be7R/ee7W/le7\/cf8@/ff8E/mf8J/cg8N/jg8S/lg8X/gh8\/mh9A/ci9E/ii9J/bj9N/hj9S/bk9W/kk9[/`l:@/il:D/bm:H/km:L/`n:Q/in:U/ao:Y/mo:]/ep;A/mp;E/iq;I/ar;M/lr;Q/ks;T/ct;X/nt;\/hu<@/gv<C/aw<G/ow<J/ix<N/gy<Q/az<U/b{<X/o{<[/h|<_/i}=B\1f\1d1hn0@1jn/\1hn/Y1kn/U1mn/R1on/N1mn/K1ln/H1nn/D1`o/A1co.]1ao.Z1go.V1fo.S1ho.P1ko.L1mo.I1lo.F1bp.B1ep-_1gp-[1jp-X1mp-U1lp-R1bq-N1eq-K1hq-H1oq-D1br-A1er,^1ir,[1lr,X1cs,T1fs,Q1js,N1at,K1et,H1it,E1lt,B1du+_1hu+\1`v+Y1dv+V1lv+S1aw+P1iw+M1mw+J1fx+G1ox+D1cy+A1hy*_1az*\1jz*Y1`{*W1i{*T1b|*Q1h|*O1b}*L1h}*J1b~*G1h~*E1f\7f*B1l\7f*@2g`)]2ba)[2ia)Y2`b)W2ob)T2fc)R2bd)P2md)N2ee)L2af)J2mf)H2ig)F2fh)D2oh)B2hi)A2ej(_2bk(]2cl([2ml(Z2km(X2en(W2co(U2bp(T2mp(S2hq(R2kr(P2fs(O2ft(N\1f\1d&h\7f0@&j\7f/\&h\7f/Y&k\7f/U&e\7f/R&g\7f/N&e\7f/K&d\7f/H&f\7f/D&`\7f/A&c\7f.]&a\7f.Z&o~.V&n~.S&h~.P&k~.L&e~.I&d~.F&b~.B&m}-_&o}-[&j}-X&e}-U&d}-R&b}-N&m|-K&h|-H&g|-D&b|-A&m{,^&i{,[&d{,X&c{,T&nz,Q&jz,N&az,K&my,H&iy,E&dy,B&lx+_&hx+\&`x+Y&lw+V&dw+S&aw+P&iv+M&ev+J&nu+G&gu+D&cu+A&ht*_&at*\&js*Y&`s*W&ir*T&br*Q&hq*O&bq*L&hp*J&bp*G&ho*E&nn*B&dn*@&om)]&bm)[&il)Y&`l)W&gk)T&nj)R&bj)P&ei)N&mh)L&ah)J&eg)H&if)F&ne)D&ge)B&hd)A&mc(_&bc(]&cb([&ea(Z&k`(X%m\7f(W%c\7f(U%b~(T%e}(S%h|(R%k{(P%nz(O%ny(N\1f\1d&h\7f0@&j\7f0C&h\7f0G&i\7f0J&g\7f0M&e\7f0Q&g\7f0T&d\7f0X&f\7f0[&`\7f0_&a\7f1B&c\7f1E&m~1I&n~1L&h~1P&i~1S&g~1V&d~1Z&b~1]&o}2@&m}2D&j}2G&g}2J&d}2N&b}2Q&o|2T&h|2X&e|2[&b|2^&o{3A&k{3D&d{3H&a{3K&nz3N&jz3Q&cz3T&oy3W&ky3Z&dy3^&lx4A&hx4D&`x4G&lw4J&dw4M&cw4O&kv4R&gv4U&nu4X&eu4[&au4^&ht5A&ct5C&js5F&`s5I&kr5K&br5N&hq5Q&bq5S&hp5V&bp5X&ho5[&nn5]&dn6@&mm6B&bm6D&kl6F&`l6I&ek6K&nj6M&bj6O&gi6Q&oh6S&ch6U&gg6W&kf6Y&ne6[&ee6]&hd6_&oc7@&bc7B&ab7D&ga7E&i`7G%o\7f7H%a\7f7J%b~7K%g}7L%h|7N%i{7O%nz7P%ny7Q\1f\1d1hn0@1jn0C1hn0G1in0J1on0M1mn0Q1on0T1ln0X1nn0[1`o0_1ao1B1co1E1eo1I1fo1L1ho1P1io1S1oo1V1lo1Z1bp1]1gp2@1ep2D1jp2G1op2J1lp2N1bq2Q1gq2T1hq2X1mq2[1br2^1gr3A1kr3D1lr3H1as3K1fs3N1js3Q1ct3T1gt3W1kt3Z1lt3^1du4A1hu4D1`v4G1dv4J1lv4M1cw4O1kw4R1ow4U1fx4X1mx4[1ay4^1hy5A1cz5C1jz5F1`{5I1k{5K1b|5N1h|5Q1b}5S1h}5V1b~5X1h~5[1f\7f5]1l\7f6@2e`6B2ba6D2ka6F2`b6I2mb6K2fc6M2bd6O2od6Q2ge6S2cf6U2of6W2kg6Y2fh6[2mh6]2hi6_2gj7@2bk7B2al7D2ol7E2im7G2gn7H2ao7J2bp7K2op7L2hq7N2ir7O2fs7P2ft7Q\1d,`l0E\1f0\1d,`l(E\1f90\1d3`y/Z\1fN\1d$`f/Z\1fS\1f\1f\1d2lt.U2mt.Q2nt.M2nt.I2et.E2os.@2`s-\2br-W2bq-R2bp-M2jn-H2fm-C2nk,^2bj,Y2fh,T2jf,O2jd,J2jb,E2k`,@1e~+\1b|+W1ly+S1kw+N1bu+J1jr+F1bp+B1km*^1ak*[1kh*W1me*T1ec*Q1i`*N0m}*K0b{*H0dx*F0ku*C0nr*A0bp)_0fm)]0kj)[0mg)Z0ce)X0fb)W/j\7f)V/b})U/gz)T/hw)T/bu)S/er)S/lo)S/gm)R/lj)S/dh)S/ne)S/gc)S/ba)T.i~)U.d|)V.`z)W.lw)X.lu)Y.ms)Z.kq)[.io)].om)^.mk*@.`j*B.dh*D.kf*E.ce*G.kc*I.`b*L.i`*N-f\7f*P-c~*R-m|*U-j{*W-hz*Z-ky*\-mx*_-lw+B-bw+D-ev+G-lu+J-du+M-ot+O-ft+R-bt+U-ms+X-ms+[-is+^-is,A-ms,D-ls,G-`t,J-dt,M-lt,P-du,S-lu,V-dv,Y-`w,\-lw,_\1d-lw,_-hx-B-hy-E-gz-G-g{-J-k|-M-j}-P-n~-S.a`-V.ha-Y.ob-[.fd-^.me.A.hg.D.ci.F.mj.I.kl.K.en.N.gp.P.ar.S.ct.U.`v.X.bx.Z.gz.\.g|.^.h~/A/l`/C/ac/E/ee/G/hg/I/li/K/gl/L/jn/N/`q/P/ks/Q/av/S/jx/T/`{/V/i}/W0b`/X0nb/Y0fe/Z0ng/[0jj/\0am/]0oo/]0fr/^0`u/_0iw/_0gz/_0o|/_0h\7f0@1`b0@1hd0@1gg/_1ni/_1dl/_1nn/^1dq/^1ms/]1av/\1jx/[1mz/Z1a}/Y1g\7f/W2ja/V2hc/U2ie/S2jg/Q2ki/O2gk/M2nl/K2en/I2lo/G2bq/D2cr/A2cs.^2os.[2ft.X2lt.U2nt.Q\1d `` @\1f\1f\1d*ir;P*or;M*mr;K*or;H*hr;F*fr;C*cr;@*hq:^*aq:[*jp:X*oo:U*co:R*dn:P*dm:M*el:J*ek:G*ej:D*ai:A*mg9^*if9[*`e9X*hc9U*`b9R*k`9N)n~9K)b}9H)e{9E)hy9B)ow8^)nu8[)ms8X)lq8U)oo8Q)mm8N)hk8K)fi8G)ag8D)od8@)ib7])d`7Z(n}7V(h{7S(by7O(lv7L(ft7H(lq7E(fo7A(ll6^(aj6Z(kg6V(ae6S(gb6O'l\7f6L'f}6H'hz6E'ax6A'gu5]'mr5Z'bp5V'hm5S'nj5O'dh5L'je5H'`c5E'j`5A&l}4^&f{4Z&lx4W&gv4S&ns4P&eq4M&ln4J&kl4F&cj4C&og4@&he3^&ec3[&ba3X%`\7f3V%o|3S%b{3Q%cy3O%dw3N%ku3L%ns3K%dr3K%bq3J%oo3J%in3K%jm3L%ml3N%bl3P%ek3S%nj3V%ij3Z%gj3^%fj4C%gj4H%ij4N%ak4T%fk4Z%`l5A\1d%`l5A%ol5G%jm5N%jn5U%ko5\%hp6D%br6K%gs6R%mt6Z%kv7A%dx7I%bz7P%c|7W%`~7_&a`8F&eb8M&id8T&ag8[&hi9B&bl9H&ln9O&iq9U&ft9[&aw:A&ly:G&o|:L&l\7f:R'mb:W'me:\'`i;A'cl;E'do;J'er;N'iu;R'lx;V'n{;Y'c\7f;\(db<@(ge<B(jh<E(hk<H(in<J(mq<L(mt<N(hw<P(iz<Q(k}<R)g`<S)cc<T)ne<U)hh<V)ak<V)jm<V)cp<V)jr<V)mt<V)`w<V)by<U)g{<T)d}<T)d\7f<S*`a<R*lb<Q*kd<O*af<N*kg<L*mh<K*gj<I*dk<H*il<F*im<D*in<B*eo<@*ap;^*lp;\*gq;Y*nq;W*ar;U*kr;R*ir;P*or;M\1d `` @\1f
\ No newline at end of file
diff --git a/tektests/dmerc.tek b/tektests/dmerc.tek
new file mode 100644 (file)
index 0000000..515895c
--- /dev/null
@@ -0,0 +1 @@
+\1d*hi?H*hi T\1d*hl [\1f-60\1d-``?H-`` T\1d-`c [\1f-40\1d.d\7f?H.d\7f T\1d/db [\1f-20\1d0lv?H0lv T\1d0ly [\1f 0\1d2dn?H2dn T\1d2dq [\1f20\1d4hm?H4hm T\1d4hp [\1f40\1d7`d?H7`d T\1d6`p [\1f60\1d*hi?H7`d?H\1d7`g>Y\1f180\1d*ji=Q7bd=Q\1d7bg=B\1f200\1d*hi;[7`d;[\1d7`g;L\1f220\1d*ji:D7bd:D\1d7bg9U\1f240\1d*hi8N7`d8N\1d7`g7_\1f260\1d*ki6W7cd6W\1d7cg6H\1f280\1d*ii5A7ad5A\1d7ag4R\1f300\1d*ki3J7cd3J\1d7cg2[\1f320\1d*ii1T7ad1T\1d7ag1E\1f340\1d*hi/^7`d/^\1d7`g/O\1f 0\1d*ki.G7cd.G\1d7cg-X\1f20\1d*ii,Q7ad,Q\1d7ag,B\1f40\1d*ki*Z7cd*Z\1d7cg*K\1f60\1d*ii)D7ad)D\1d7ag(U\1f80\1d*hi'N7`d'N\1d7`g&_\1f100\1d*ji%W7bd%W\1d7bg%H\1f120\1d*hi$A7`d$A\1d7`g#R\1f140\1d*ji"J7bd"J\1d7bg![\1f160\1d*hi T7`d T\1d7`g E\1f180\1d0d\7f.B\1fP\1d0f|4@\1d0fh1P\1fP+20\1d0f|4@1ga4@1kf4@1kk4@1lp4A1cv4@1g{4@2j`4@2me4@2dk4@2kp3_2av3_2k{3^3da3^3bg3]3nl3\3or3[3ox3Z3n~3Y4ae3X4hk3W4ar3U4ox3S4k\7f3Q5jf3O5mm3M5cu3J5o|3G6jd3D6kl3@6cu2\6i}2X\1d6i})K6cu)F6kl)B6hd(_5o|([5`u(Y5mm(V5hf(T4h\7f(R4lx(P4ar(N4kk(L4ae(K3l~(J3lx(I3lr(H3ll(G3ag(F3fa(E2h{(E2av(D2hp(D2fk(C2me(C2h`(C1g{(B1cv(B1op(B1kk(B1kf(B1da(C0e|(C0bw(C0gr(C0am(D0bh(D0lb(E/o}(E/ix(F/ds(G/gn(G/ci(H/kc(I.g~(J.cy(K.hs(M.bn(N.kh(O.mb(Q-d}(S-kw(T-kq(V-hk(Y-ie([,k\7f(],ey)@,mr)C,jl)F,cf)I+f\7f)M+jx)Q+lq)V+oj)Z+lc*@*o|*E*`v*L*co*R\1d*co1P*bv1W*o|1]+nc2C+oj2H+oq2M+hx2R+d\7f2V,cf2Y,il2],mr3@,ey3C,h\7f3F-je3H-kk3J-kq3L-kw3N-f}3P.mb3R.kh3S.an3U.js3V.cy3W.d~3Y/hc3Z/ci3Z/gn3[/fs3\/ix3]/l}3^0nb3^0`h3_0bm3_0gr3_0aw4@0f|4@\1d/gt7U\1fS\1d0js>O\1d/j\7f;_\1fS-10\1d0js>O0jx>N0m}>M1`c>L1gh>J1im>I1lr>H1bx>F1d}>E2nb>C2ch>A2im>@2bs=^2kx=\2c~=Z3kc=X3gi=V3bo=T3`u=R3b{=O4`a=M4ag=J4em=G4ls=D4cz=@5l`<]5eg<Y5`n<U5bu<P5c|<K6bc<F6gj<@6jq;Z6ox;S7b`;L\1d7``3_6ox3W6hq3Q6gj3J6`c3E5c|2_5`u2[5bn2V5eg2R5m`2N4cz2J4ms2G4em2D4ag2A4ba1^3c{1[3bu1Y3`o1W3gi1T3kc1R2c~1P2kx1N2`s1M2im1K2bh1I2lb1H1f}1F1`x1E1nr1C1im1B1gh1@1bc0_0m}0^0hx0]0hs0\0gn0Z0bi0Y0nc0X/j~0W/ey0V/ms0U/en0T/mh0S/ec0R.m}0Q.ax0P.fr0O.jl0N.jf0M.j`0L-fz0K-ns0J-jm0I-of0H-c`0G,ox0F,kq0E,bj0D,fb0C+fz0B+ar0A+di0@+c`/^*gv/]*el/\\1d*fl [*ev Z+`` Y+gi W+br V+ez U,eb T\1d,cj?F,kq?E,ox?D-c`?C-of?B-km?A-ls?A-dz?@.h`>_.hf>^.hl>].dr>\.ax>[.m}>Z/ec>Y/mh>X/en>W/ms>V/dy>U/h~>T0lc>S0ci>Q0gn>P0js>O\1d+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+ge*C+mr*B,kb*K,ih*F,mv*Q,iy*M,e|*U-gd*T-fd*_-gk+C-js*_-cr+G-lr+K.fe+Y.`o+Z.gw,K/l`,R/at,U/o\7f,^0oe,^0jh,]0ln,R0lp,I0ln,E0mr,D0ot+\0dr+X0er+S0or+X0dv+Z0gv+T0ft+P0az+U0i{+U0h\7f+R1be+N1ef+F1oi*^1om*Z1gm*X1`p*X1ds*T1`t*V1at*O1mr*Q1es*K1es*D1dv*A1dx)_1dv)_1ot)\1fo)[1do)Z1gv)Z1kw)\1ay)\1fx)Y1nt)P1kl)M1kp)G1gq)E\1d+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+ob*E+ad*@+ma)^+ge)Z+lh)V+em)S+ls)R+fy)P,hb)P,hc)T,hg)T,jg)P,hj)R,ki)V,`v)X,lx)X,hy)V-m`)U-dd)V-ii)U-lm)X-j|)Y.be)[.jm)[.nu)].l{)_/ic)^/jh)Y/dl)R/jp)N/aq)M/c})I0fe)P0if)O0ek)O0`n)R0ho)R0ap)O0et)O0lx)R0oz)G0b~)H1f`)J1cg)K1hl)I1hn)G\1d1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1ap)D1hn)A1hn(_1nt(Y2b`([2cb(X2ob(T2bb(L2hj(P2dn(P2ip(Q2ir(Q2kr(I2kp(G2ll(G2bj']2jj'Y2fn'W2kr'T2lz'T2n}'U3fb'U3jg'Y3fi'[3nj'[3oj'\3cj'\3jk'_3lj(C3kk(C3oj(E3gi(E3fi(H3gi(K3nj(J3bm(H3am(M3ln(N3fl(N3am(Q3am(U3oj(V3gl(X3ei(\3kd(\3eb(^2n})A2l})C3ia)D3lj)A3ep)@3et)B3hw)G3gy)I3k{)K3k|)M3f})L3e})O3a\7f)O4n`)L4n`)N4gb)M4gc)M4ae)M4oe)M4gh)K4ig)M4ol)M4gh)M4me)O4dc)P4hg)R4ak)S4ko)T4ko)X4dp)Z4gp)T4br)Y4cr)Z4bt)[4bs)]\1d4bs)]4`s)_4lt)_4at)^4nu)]4iz)^4f~*H5ba*H5bd*N5cb*M5ab*Q5ca*M4g~*I4e{*K4e~*O5b`*W5ca*V5bd*[5cf*Z5bf*Y5bh*Y5bf*W5bb*W5`b*V5`c*V5`d*P5`e*P5ah*M5ch*K5bk*N5ak*M5cj*K5`l*I5bm*J5cl*K5`n*P5`p*P5aq*M5bp*H5an*D5`l*A5bf)[5bk)_5ao*B5`q*E5`q*G5du*I5fu*N5et*Q5eu*U5gt*V5gt*Z5ly+C5o{+E5e\7f+F6ib+F6oc+G6od+C6nc+A6`f+C6bf*_6kb*\6kb*X6cf*\6fg*_6eh+B6nk*Y6dn*Z6lp*V6br*W6jt*W6ou*T6dx*V7ea*O7`d*P\1f\1d7lc*M7gc*L7cc*L7kb*L7gb*L7na*L7fa*L7ba*L7i`*L7e`*L6m\7f*L6e\7f*L6`\7f*L6h~*L6d~*L6l}*L6g}*K6nz*H6m~*B6e\7f*B6i\7f*B7b`*B7j`*B7ba*B7ja*B7bb*B7jb*B7bc*B7gc*B7oc*B\1f\1d7bd)L7nc)L7jc)L7fc)L7bc)L7bc)L7nb)L7fb)N7fb)L7ga)I7c`)I6o~)G6ky)K6kt)M6io)M6gk)I6nj)H6dh)E6he)G6ha)G5b~)H5d{)G5ly)G5cz)E5oz)E5my)D5ly)C5m{)B5b}(_5b~)@6n`(]6ed(^6dk(_6hl(V6`m(V6ho(P6np(N6fs(J6kt(E6gs(A6iy(B6e~(@6f}']6m~']6m~'Z7a`'\7ad'\\1f\1d7bd!_7lb!_7mb"B7mb"B7ac"B7ac"B7ec"B7ec"B7jc"B7nc"B7nc"B7bd"B\1f\1d7cd"C7oc"C7nc"C7jc"C7fc"C7fc"C7bc"C7mb"C7mb"C7ib"C7eb"C7eb"C7ab"C7la"C7da"C6k\7f"B6h}"C6`|"E6a|"F6e}"G6n~"I6j}"I6`}"K6e~"L6a}"L6e{"M6d{"N6b}"M6`\7f"O6g}"N6i|"O6g~"R6iy"P6`v"P6es"M6fp"I6io"I6gn"I6`n"H6eo"G6km"C6`l"C6gk"@6gj"@6fk"D6`m"F6kl"F6fk"F6jl"I6cn"J6il"K6kn"L6ko"N6ip"O6op"N6as"R6et"T6iu"T6iu"S6kv"V6iy"Z6a{"Z6k|"\6k}"\6e\7f"Z7l`"\7j`"\7ad"^\1f\1d7cd#A7nc#A7jc#A7jc#A7ec#A7ec#A7ac#A7lb#A7lb#A7hb#A7hb#A7ja#A7ha#C6e\7f#@6a\7f#B6o\7f#C7l`#D7da#F7ic#H7kc#I7oc#I7oc#I7`d#J\1f\1d7cd#V7jc#Y7bd#[7ob#_7`d$C7kb$C7da$C7lb$B7c`$A6j\7f$D6c}$G6i{$I6b{$J6j|$J6e}$I6n~$I6e}$J6d}$L6b{$L6mz$N6n{$N6f\7f$M7``$L7e`$M6n~$N6b|$O6iz$O6hz$Q6i|$R6j}$R6m~$S6k~$S6c}$R6f}$R6bw$S6dx$R6ou$R6du$R6ds$T6mp$W6ap$V6mm$U6jm$V6bo$W6ko$X6dn$Z6il$Z6lk$Y6nj$Y\1d6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6ja$U5j}$W5o|$X5g}$Y5n}$Y5i~$X5g\7f$X5h\7f$X6ba$W6ia$X6jb$W\1d6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6mf$V6`d$U6nf$U6lf$S6ke$R6be$S6`c$S6hb$U6bb$U6fc$W6fg$W\1d6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6kn$W6ml$W6al$X6fm$Y6on$X\1d6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6ho$R6cm$R6gi$T6di$V6lj$V6`n$T6`p$S\1d6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6gs$P6cq$P6aq$Q6ko$P6io$Q6hp$R6ds$R\1d6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6kt$O6aw$Q6nw$P6ex$Q6bz$O\1d6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6hv$N6mu$M6ht$N6es$M6`q$N6cp$O6ht$P6it$O6mu$O\1d6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6ky"\6dz#A6b{#@6nz"_6`|"_\1d6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6`y"]6bx"\6ix"[6ev"[6ew"Z6ou"X6gs"X6at"Z6hr"Z6iu"]6mu"]6nu"^6`w#@6aw"^6dx"_\1d6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6mg!^6fi!_6hh"A6oj!_6mj!^6`h!]\1d6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6`f!X6ke!V6jd!W6gb!T6fc!U6od!Y\1d6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6kc!T6`a!R6kc!R6`d!T\1d6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P5e~!O6a`!O6c`!P6k`!P\1d6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6d`!N5e\7f!M5g\7f!M6c`!N\1d5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5a~!G5i}!H5a~!I5f~!H\1d5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5k|!F5i|!E5b}!D5g}!F\1d5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5f\7f!D5g\7f!C5k|!A5k|!C5f\7f!D\1d5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5fz [5k{ ]5h| ]\1d5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5`{ Z5hz Z5j{ [5m{ [\1d5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5e{ X5dz Y5m{ Y\1d5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5fz?E5oy?F5my?G5oz?E\1d5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5n{?@5k{>]5mz>_5j{?@5c|?@\1d7ad!V7bd!V7nc!V7oc!V7lc!W7lc!W7ic!W7jc!W7jc!W7gc!W7gc!W7dc!X7ec!X7ac!X7bc!X7cc!X7cc!X7lb!Y7mb!Y7mb!Y7`d![\1f\1d6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6gy$L6kz$L6gz$J6`y$K6cy$I6lv$K6`v$R6ex$L6mv$O6jy$N\1d5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5my+D5iv+B5er+@5an*\5an*^5ak*\5aj*\5`j+E5`i+E5ai+F5`j+G5bj+H5cg+E5`g+G5bj+J5cf+K5cf+M5ak+O5cm+M5`k+K5co+M5`o+K5er+M5fs+H5gr+E5dt+G5du+E5ds+C5lz+G\1d5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5af*O5ae*Q5be*R5`d*T5`f*V5af*Q5`h*P\1d2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2bt(Y2nt(Y2gv(\2iu(^2hr)G2bq)H2no)L2gn)I2`o)T2aq)O2mq)O2nw)A2nw([2ct(V\1d2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2ff)H2ie)K2je)N2ff)N2ng)L2ng)J2bg)H\1d2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2kh*G2og*I2ei*K2aj*K2jj*J2cj*G\1d2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2cj)R2kh)T2hh)Z2cg)Z2ih)\2aj)\2jj)]2ei)^2di*C2gk*C2gn)\2gn)V2ll)X2hj)X2kj)V2gk)R\1d1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1go)E1em)B1ck)C1jj)A1hl)A1nk(_1fm(]1kl(\1mm(\1gm(Z1mm(Z1in(Z1lr(V1gq(V1or(T1ct(T1`t(T1hu(T1jy(N1ez(O1n{(N1`{(N1l{(I1`}(G1h|(E2ic'^2nb']2ic'\2fd'[2nb'Y2lb'T2ke'K2ih'I2kh'G2kj'C2dk'C2`l'A2bo&]2fs&_2`t&_2dv&_2g|&X2d|&X2l}&X2j~&U2f\7f&U2g\7f&T3``&T3ka&T3ha&T3eb&S3cc&R3id&Q3af&O3nj&L3fp&J3bq&H3oq&G3oq&E3dl&G3ig&K3kd&K3`c&N3ha&N3ja&N2i~&O2o}&P2mz&Q2h{&R2ey&S2ow&R2lw&R2c}&K3o`&K3cc&I3eb&I3fe&D3de&G3bf&F3hg&G3gi&E\1d3gi&E3ik&B3am&B3lr%_3av%^3dx%]3oz%X3lz%V3d}%V4o`%R4gb%R4ec%Q4oe%P4`e%R4hf%R4kg%R4ig%Q4kf%P4dh%N4ak%M4im%M4jn%L4fp%L4`r%N4iw%K4e}%M5`d%N5ae%M5bf%N5bi%L5`m%L5bm%N5bk%N5ak%O5ai%O5cj%P5ao%Q5ap%O5er%O5bq%N5bq%L5dr%N5du%N5eu%M5es%M5ds%L5du%L5jw%J5gu%I5jv%F5iw%I5kw%C5oy%C5m{%B5f\7f%D5d\7f%A6lc$_6jb$]6af$\6fg$]6gg$Z6eh$Z6bm$]6nj$Y\1d5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5an%M5bp%H5bq%F5fr%F5hv%A5hw%A5iw%B5fu%F5et%I5fr%J5ap%M5bn%N\1d4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4gp&K4fq&J4br&J4cs&I4ct&I4bs&J4ct&K4fq&L\1d4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4jz)N4ky)I4hy)E4kz)E4f|)H4g|)I4e{)K4f})L4d~)P4d})P\1d4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4mt)B4bt)A4as)@4ar(\4as(\4bs([4ct(Z4mt(\4bt(]4nt(_4lv)A4`v)C4lv)C4cw)E\1d5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5lf(G5ch(G5hg(G5cg(E5gg(C5ci(E5bj(F5`k(I5al(J5cn(J5jn(L5cm(K5cn(L5am(M5hn(N5mo(M5`p(N5kn(P5ao(Q5bo(R5bl(S5kk(T5`l(V5bj(W5kf(V5ce(X5be(_5bd(_5bd)A5bb)A5`b)C4d~)C4f~)A5`a)@5`a(_4e~(_4ky(^4kx(\4g|(\4f|([4g{(Z4e{(Z4f~([5b`([5ba(Z5ia(Y5kb(V5ab(U5ca(U4h\7f(T5h`(T4g}(R4lv(S4at(Q4`t(P4nv(N4d{(P4e|(O5aa(Q4h}(N5a`(O5jc(P5hc(R5hb(R5ad(S5ed(U5gc(V5ed(X5ke(V5ae(U5ef(U5if(S5`f(R5ff(O5eg(M5ii(O5ei(M5bh(K5cg(I\1d5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5hv'X5k{'W5b}'V6e`'U6kb'T6dc'T6ld'T6be'U6jf'U6af'S6bg'S6gg'T6fh'S6gg'R6ge'R6af'P6ia'O6da'R6f`'P6a`'Q5j{'S5i}'T5b{'U5oy'T5mz'V5oy'V5hx'V5gw'V5gu'V\1d6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6`a'K5k\7f'K6i`'L5d~'M5e\7f'N5j}'N5e}'M5a{'M5gz'O5jy'P5mw'P5`v'R5ot'Q5lt'S5mu'S5ow'R5nw'Q5kx'Q5mz'P5h}'P5e{'O5d}'O5f~'O6d`'O6ma'M6cb'J\1d7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7jb&W7fa&W7o`&U7hb&V7nb&T7a`&Q6c\7f&P6`~&N6e}&R6i~&R6o\7f&T6f\7f&U6n\7f&X7f`&X7g`&[6m\7f&\7m`&]\1d2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2bl"W2cl"X2ao"W2`o"V2dn"V2im"U2bl"U2ik"V\1d2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2jp"S2bq"S2`q"T2kp"T2mo"U2mo"T\1d2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2jq"R2hq"T2lq"T2br"R2mq"R\1d2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2lr"O2nr"P2fr"P2`r"O\1d2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2lt"K2ht"L2ct"K2gt"J\1d/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/kg?C/`g?C/jg?B/eg?A/de?@/fd?@/ed?A/ed?C/me?D/bg?D/hg?D\1d-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-li?C-ji?A-kg>_-`h>_-ch>]-`l>]-ol>[-dj>\-mj>[-cl>Z-om>Y-fp>Y-`q>X-as>V-cs>T-op>U-oo>U-el>X-nl>Y-ok>Y-ek>Y-lh>Z-bg>Y-ad>Y-eb>W-ba>W-o`>X,c\7f>Z,h{>Z,hz>[,f|>]-`a?@-fa>_-ac?@-mb?A-`d?B-nd?A-de?C-eg?D-ah?D-bi?D\1d,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,j{>W,k{>V,c}>V,c|>T,g}>T,j}>S,l~>T,c~>R,g|>R,iz>P,mx>P,gt>L,fr>I,mp>G,io>G,lm>F,il>D,kj>B,lh>C,mh>E,ji>E,fh>F,nh>G,bh>J,hi>N,en>P,mo>P,gq>Q,fr>T,cs>T,ds>T,`t>T,mv>V,cy>W\1d,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,kw<R,iz<R,m|<R,h}<Q,n|<O,o|<M,m{<M,j}<I,k}<G,jz<H,mx<I,`v<J,`t<K,bs<K,gr<L,nr<M,dt<N,ft<O,`v<P,cv<P,nu<Q,et<Q,dt<R,bv<R,kw<Q,mx<R,kw<R\1d-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-ej<V-bi<U-jh<T-jh<R-oe<P-od<K-fd<K-fd<L-bc<L-kc<J-af<I-de<H-af<G-ag<H-dh<H-`g<F-cf<F-dd<D-ne;_-fe;^-ag;\-ej;Y-gk;Y-in;X-co;U-gp;V-js;U-jp;T-jp;Q-ar;R-oq;S-ns;S-fu;T-jv;T-ov;T-iw;U-ey;T-hw;T-mu;S-iu;R-ft;P-mr;P-ar;O-gq;O-cq;O-kq;M-br;M-fr;N-`t;N-ku;L-dx;K-hx;L-dy;L-gy;J-bz;J-jz;I-`z;I-az;H-f{;G-jz;F-lz;F-k|;C-e|;C-d|:_-j|:^-n{:[-lz:[-`z:X-az:T-jw:O-lu:N-nt:M-eu:K-gu:I-gu:E-et:C-ms:C-cs:B-bs:A-`r:A-bq9_-cq9[\1d-cq9[-ks9X-ks9W-lv9W-mv9X-ow9X-oz9X-l{9Y-j}9X-k~9W.`e9V.li9T.dm9R.hm9R.`m9S.on9R.nn9S.em9T.gn9T.ip9S.js9R.gu9R.fv9S.ew9S.fy9S.ez9T.ax9T.jy9U.bz9U.g{9V.l}9[.n}9[.l}9\.h~:@.j~:A.d\7f:B.n\7f:D/ba:G/eb:I/ic:I/dd:K/of:J/aj:L/`j:M/`g:N/aj:N/ki:P/dj:P/im:R/jn:R/fo:S/hn:T/mp:T/`q:U/jp:U/hp:W/hr:W/oq:W/bq:X/kp:Y/co:Y/gn:Z/ml:Z/mm:[/in:[/jm:^/co:^/ko:]/dr:_/dr;A/fs;@/ht;A/`u;B/bv;B/lv;F/ow;F/cx;D/ox;D/fy;F/ex;G/ex;H/fw;H/dw;J/cv;M/dv;N/gv;O/ju;O/jt;P/lt;Q/cv;P/ev;Q/au;R/bt;Q/is;R/bs;Q/cs;O/bq;O/cq;O/kp;O/mo;O/fn;N\1d/fn;N/ak;R/gk;R/di;U/di;V/ah;X/fg;X/bf;Z/lf;]/jm;_/dn;_/lq;_/kv;_/jv<@/cy<@/dz<B/ey<B/lv<C/jv<C/gu<C/ls<E/er<E/`r<E/bo<E/`o<F/jo<F/lo<G/in<I/kl<I/ej<J/di<J/ch<J/ah<K/`f<L/dd<L/eb<L/ca<N.d\7f<S.b|<T.jy<T.fx<U.dy<V.my<V.ax<W.ax<X.jw<X.nu<X.dt<Z.ht<[.`r<].ip<].gp<].bo<^.kn<^.hj<_.of<_.dd=@.mb<_.ea<_-j\7f<^-f~<^-az<\-ey<[-kx<[-kw<Z-js<X-aq<X-ml<V-gl<V-ej<V\1d+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+h|5^+j}5]+m|5[+o}5Z+i}5Z+b\7f5Y+g{5X+jz5X+i|5Y+hz5Y+d|5Z+`|5[+k{5[+h|5^\1d.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.ln3Y.oo3Y.hp3^.hs3_.nx4@.o}4A/l`4B/cd4C/kg4C/ei4E/il4D/il4E/ek4E/gk4E/nl4F/js4E/jv4C/kv4B/ju4B/gu4A/ls4B/mr4A/fs4@/or3_/oq4@/ip4@/io4@/`o4A/ln4@/mm3_/kn3^/hm3^/nl3^/dl3^/am3]/el3\/dj3]/aj3\/el3[/hk3Y/ej3V/mh3V/bh3U/jd3U/gc3U/ja3U/i`3V.o\7f3U.`\7f3V.f}3U.f}3T.m{3T.k{3S.iy3S.fx3S.ev3T.ds3T.nq3T.oo3U.do3W.in3W.ln3Y\1d1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1dq6X1lo6X1lo6V1kn6V1gm6V1il6V1`i6W1ag6W1df6Y1bg6Z1bi6\1jj6\1il6[1lm6[1ho6Z1gp6Y1eq6Y1dq6X\1d3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3mk2V3ck2U3dh2W3df2Y3nd2Y3la2[2j~2\2n{2^2hw3@2aw3A2es3C2ir3D2ir3C2bo3C2`l3D2cl3D2di3G2cf3H2cc3I2ia3J2hb3K2ab3K2n`3K2a`3M1e\7f3M1h~3O1n}3O1h|3R1lz3S1dz3T1ky3T1ox3T1fx3S1jw3R1iw3T1ot3U1ht3W1jt3X1ku3[1ku3\1`v3^1mu4@1ev4A1bv4C1`w4G1nw4G1bx4I1kw4J1ms4I1ms4J1es4J1lr4I1kp4H1om4F1fm4E1`k4E1ci4C1`f4C1kd4A1bc4A1cb3_0m\7f3^0k\7f3\0o}3[0j{3W0lv3S0hs3P0`s3O0`r3O0hq3N0gp3K0ko3K0en3K0ch3F0`d3H0e`3H/c{3I/b{3K/`z3L/nx3K/aq3K/kp3K\1d/kp3K/jo3K/io3L/in3L/jm3K/im3L/hi3M/ki3K/eg3G/ff3C/be3B.n\7f2\.n\7f2[.l~2[.c~2[.i|2].k{2\.e{2].jx2].ix2^.kw2].jv2^.ft2].et2^.nr2].bp2Z.go2X.im2V.fm2W.mf2V.fc2S-g}2O-c|2M-my2L-fu2F-fu2D-bt2D-bt2A-js2A-hs2@-os1^-hs1^-ks1[-os1Z-or1W-or1U-nq1T-mq1R-er1R-nr1P-os1O-fs1O-eu1O-`x1N-by1O-m{1O.k`1L.`b1L.fh1H.ll1F.bu1D.dv1D.iw1D.gx1C.k|1B.j\7f1A/fd0^/kh0]/ai0^/lj0^/gl0^/dr1@/du1C/mw1C/hz1C/j}1A/g~1A/j~1B0l`1B0nc1@0jf0_0cg1@0fg0_0hi0^0ij0]0al0\0hn0Y0`o0Y0bo0X0hq0V0lr0V0fs0U0nt0U0lu0W0ov0V0gw0V0ew0X0fx0W0jx0X0n{0X0l|0Y\1d0l|0Y0c~0X0h\7f0Y1m`0X1ja0X1cb0W1la0W1kb0U1cc0U1dc0T1`c0T1cc0P1dd0P1id0M1kf0L1ch0H1lg0C1gf0@1he/^1md/\1fd/Z1ac/Y1ac/X1kd/T1jd/P1ib/J1dd/E1dg/B1ci.^1ii._1oj.\1ok.\1gl.Z1gm.Z1lm.Z1fq.Y1ir.W1ht.W1eu.V1au.U1hu.U1lu.T1cw.S1kw.R1`y.Q1b{.P1i|.Q1m}.Q1a\7f.O2a`.O2bc.Q2be.Q2hh.S2il.R2bo.R2kq.P2`q.P2kr.O2ou.Q2`w.R2ay.S2fy.R2c}.U3k`.V3ja.W3gb.X3df.[3ig.^3ni/A3im/D3jp/C3et/E3ax/H3fy/K3h~/N3j\7f/O3b~/Q3c~/T3e~/V3b~/Z3a\7f/[4f`/]4da0@4ac0H4lb0I4dc0K4ob0L4nc0O4lb0Q4hc0Q4`c0S4bc0U4be0X4ce0Y4jb0Z4nc0[4oc0\4m`0[3a\7f0[3n}0\3o|0\\1d3o|0\3k{0[3cz0Y3gx0Z3gy0[3hx0]3jw0]3bw0^3jv1@3dv1B3mt1G3`q1I3`p1M3bm1Q3go1T3mq1S3is1S3bu1T3iu1W3av1\3at1]3mr2@3or2B3nq2C3nq2E3go2N3no2O3lo2Q3np2Q3`q2S3gp2U\1d3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3el2V3gi2X3ag2X3hc2[3cf2[3kf2[3hk2]3af2\3cf2]2i}3C2h|3C2lz3D2dy3F2mu3H2`t3H2jr3H2er3H2do3J2bo3J2`o3K2kp3L2ih3O2lf3Q2gh3Q2nb3R2ab3R1b}3S1g|3S1iy3T1jy3X1k{3Z1h{3]1c|3^1f}4@1c}4A1n~4C2ma4L2cd4L2ke4R2je4S2ef4T2jg4T2ah4W2nj4X2ek4[2en4[2bp4\2jo4\2do4]2ku5@2hu5@2lx4^2`z4Y2i}4W3i`4W2dz4Q2hz4M2`z4K2jz4J2b{4I2b}4J2m\7f4J3j`4I2h~4H2e|4H3a`4F3na4F3ie4A3ie4@3`k4A3fl4@3el4B3mm4C3lm4D3dm4D3im4C3dl4E3ml4F3`h4I3bf4I3ha4S3hc4W\1d3hc4W3`c4Y2g\7f4Y2d}5E2l}5V2i|5S2g|5U2bz5U2kv5Z2kv5[2aw5]2`u5Z2dp5_2mq6B2mt6C2mo6D2gn6C2lb6F1c}6H1kw6J1`o6O1nl6Q1jm6R1io6S1cp6U1kp6T1lr6V1mr6W1iw6W1jz6X1c{6W1d\7f6Y2jb6Y2`b6Z2lb6X2dc6X2oc6[2ic6\2kd6]2ge6]2ki7B2dl7E2dn7I2gp7J2mq7J2mr7K2js7S2dv7V2gv7V2oo7Y2en7[2cn7\2ng7_2mb7^2kb8A2fe8E2kf8E2kb8G1k~8H1a|8I1i}8I1cy8J1by8J1dw8K1`r8J1`r8K1ao8I1fl8I1om8I1hg8O1dd8O0k\7f8Q0f\7f8Q0fz8W0gz8Y0a\7f8W1ed8W1mi8R1bj8P1fj8O1gp8M1dp8L1g{8M1o{8P1gy8P1dy8S1dt8W1ds8X1os8X1cr8[1`n8[1nu9F1dz9H2ca9F2ki8^2bm8]2ms9F2hr9I2iq9H2nn9I2oo9J\1d2oo9J2`q9J2hu9U2dv9V2ku9V2jv9W2bv9X2ov9X2dw9[2ey9Z2nz9_2e{9_2o{9_2m{:@2o{:@2d|:A2k|:@2k|:A2c}:A2o}:A2o}:B2j~:B2o~:B2f~:C2b\7f:C3b`:C3n`:C3ba:D3bb:C3kb:D3ha:D3ab:E3kb:D3kc:E3cf:F3fg:G3lf:H3jf:G3gf:G3cg:H3cg:H3fh:H3di:I3ni:H3cj:H3ei:I3ek:I3nj:H3al:J3kl:H3em:H3gm:G3ol:F3ml:F3lm:F3fm:E3jm:E3km:F3hn:H3co:I3ep:I3mq:G3br:F3or:F3er:G3dr:H3nq:I3nr:I3is:H3at:H3lt:G3ez:E3h{:C3k|:B3h\7f:E4g`:D4j`:E4b`:E4f`:F4ga:F4dc:J4hb:K4fc:K4kd:K4ae:J4od:H4bf:F4hd:D4kc:C4ic:B4id:A4le:B4kg9^4ij9^4oj:A4hm:D4cq:G4ko:J4nl:H4ni:I4em:P\1d4em:P4el:S4ag:Q4gf:U4ec:W4mb:U3o\7f:V3kz:U3iz:V3`{:]3n\7f:^3m\7f:^4hc:^4mh:[4`k:V4am:Y4kp:^4or:^4fs:^4nu;A4m\7f;E4dw;C4hz;N5bd;U5en;[5gt;\5iw;\5c};^6cc;^6dg;[6gg;W6bd;S6eh;T6de;R6hh;R6ji;M6`s;V6ky;[6e{;\6oz;_6e|;_6g~;_7a`<B6l{<K7b`<J6e\7f<K7a`<L7aa<L7a`<O7ca<Q7g`<Q7m`<S7jb<T7ha<X7ea<W7ga<X7na<X7ca<Z7b`<Z6j\7f<\6d\7f<Y6n}<Y6j\7f<\6e~<^6k\7f<_6o~=A6k\7f=A6d\7f<_7ca=C7aa=A7ad=B\1f\1d7nc=T7dc=T7ob=S7ab=S7ka=R7aa=R7h`=R6n\7f=Q6d\7f=Q6o~=P6a~=P6k}=O6a}=O6h|=O6n{=N6d{=N6dx=J6mx=I6gx=H6ev=I6iz=F6mj=E6d`=G5hz=H5dx=I5c|=L5`~=N6fb=Q6hd=Q6ch=T6oh=T6ih=V6ji=W6ml=V6ip=X6ko=Y6jp=Z6es=Z6bs=Y6nu=Z6ix=Z6fy=X6mx=X6hy=W7bd=[7`c=_7ec=_7ic=_7jc=_7oc=_7cd=_\1f\1d3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3fy;B3jx;B3fw;C3`x;D3nw;D3bw;D3`w;D3ov;C3ov;D3iu;E3ls;D3gr;C3ar;C3jp;C3cq;B3jp;B3kp;B3jo;A3hp;B3cq;A3gq;A3dq;B3nq;A3aq;A3fp;A3ip;@3jp;@3gq;@3as;@3nt;A3jt;A3eu;A3iv;@3dv;@3gu;@3it;@3kt:_3ht:_3it:_3bw:^3fy;B\1d3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ky;G3ix;H3ey;I3cz;I3gz;J3my;L3jx;L3lv;K3ow;I3ow;H3gu;G3`u;G3iw;F3dx;G3ky;G\1d3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3ey;B3jz;B3kz;C3m};G3l~;K3f~;O3l~;P3l\7f;P4lb;R4hd;R4be;S4hc;S4ob;R4kb;S4`c;T4cd;V4df;X4bg;Y4hk;[4il;[4fm;Z4dn;[4hp;[4jp;[4`r;\4cr;\4hp;]4fq;]4lp;^4er;^4oq;_4es<@4jr;^4lr;_4ho;_4bm<@4jk<@4lh;_4hg;_4bh;^4jf;]4bc;]4n`;\3m~;]3m};\3`};\3f|;Z3i};Z3i~;[3n~;X3d};Z3m};Y3c{;W3n|;W3l|;W3`{;V3c{;R3m{;R3i|;R3h|;R3b{;Q3iz;R3ey;R3jw;O3fy;M3b{;N3i{;N3f{;M3n{;L3oy;F3jz;F3cz;E3gy;E3ey;B\1d4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ot<C4ew;_4bv;]4cw;\4aw;\4nu;[4fu;\4du;]4et;^4os;]4gt;\4nr;[4ds;[4mt;[4av;Z4fw;Z4ix;\4gy;[4my;\4`y;^4`z;_4j{;^4m{;_4g\7f;_5aa;_5bb<@4h}<D4o{<G4j}<I4k{<H4hy<J4hx<G4dx<F4hw<E4mu<D4ot<C\1d2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2os:F2bv:G2gv:G2fx:H2n{:I2i|:I2c}:I2o}:H2g}:G2a}:G2cy:D2gw:D2mu:E2au:F2os:F\1d0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jr;U0jp;Z0mp;[0no;]0hl<F0kl<F0cl<F0oi<J0bh<J0ah<K0lf<P0je<P0nd<P0md<N0lc<N0mc<N0kb<N0aa<Q/j\7f<Q/d\7f<R/a~<R/a~<T/m|<T/e|<V/n{<U/mz<X/iz<W/`z<X/hy<W/cz<U/ez<V/e{<Q/g{<P/d~<M0aa<K0db<G0ma<F0eb<E0ba<E0k`<D0a`<C/a\7f<D/e~<D/h}<B/o};]0h`;[0``;X0``;X0b`;T0ba;U0`b;V0ob;V0mb;X0fc;W0dc;X0`d;W0kd;W0ke;V0kf;V0bh;U0ji;Y0li;R0hj;P0mj;M0bl;L0gl;J0jm;I0ok;H0kk;G0`m;G0cm;G0mm;G0lm;G0ao;F0ao;E0ko;E0ko;F0eo;G0fp;H0cp;I0mp;J0lp;F\1d0lp;F0dr;E0bs;C0lr;C0et;A0ks;B0mt;D0`v;F0lu;G0`u;I0cu;J0es;K0gr;J0ip;K0ln;L0`p;L0bp;L0on;L0`o;M0`n;M0km;N0om;N0no;P0np;Q0jq;S0ar;S0mr;U0jr;U\1d0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0lz9L0a~9M0e\7f9Q1mb9T1ec9T1id9W1oc9V1be9Y1de9X1bf9X1me9Y1ch9Z1gh9Z1oi9[1kh9[1oi9\1gh9]1bh9^1jg9^1lf9^1`g9_1df9_1hf:@1je:B1be:B1bd9_1cc:@1lb9^1o`9^0n\7f9]0m|9_0f|9^0gy:A0`y9_0bv9]0lu9^0fr9Z0gr9Z0aq9[0cm9Y0jk9U0cm9U0mm9T0im9S0kn9Q0im9P0nm9O0am9N0ln9N0ln9J0is9I0ks9G0lv9G0lx9F0b|9G0e{9I0lz9L\1d0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0of8]0ch8\0eg8\0og8Z0lf8[0of8Z0al8T0am8T0aq8P0jq8P0ls8O0lt8O0bv8M0mv8M0gw8K0c{8J0m|8H0g}8G0j~8G1n`8E1n`8D1hd8A1le8A1bf8A1`e8D1be8G1nb8I1ab8I0l~8N0d~8N0b|8P0n|8P0l|8Q0nv8X0jv8W0bv8X0au8W0dt8Z0`q8[0ip8]0cn8^0dm8^0ll8^0il8^0of8]\1d0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0og:D0ai:E0gj:E0cn:D0`o:E0no:F0jo:G0en:G0om:F0cl:H0fj:H0li:J0mi:J0dj:J0oi:K0lj:L0ak:L0mk:L0hk:L0em:J0en:K0hq:N0kt:L0kt:L0bt:M0ot:M0eu:M0lt:I0bs:G0as:F0kt:E0et:E0nu:D0ov:D0`x:F0ax:E0fw:M0gw:N0cx:P0lz:S0d{:R0by:O0iy:I0fz:H0dz:G0lx:F0fy:E0dw:D0cu:C0os:B0jq:B0mo:B0no:A0fo:A0eo:A0gm:A0om:B0bl:C0gh:B0kg:C0og:D\1d0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0jf8^0oe9D0id9E0bd9J0de9K0he9L0nd9L0mc9P0gc9P0`c9S0kc9S0bd9T0`d9Q0jc9P0gc9P0oa9Q0ab9T0ia9U0m`9U0o`9V0aa9W0``9X/b\7f9W0m`9U/b\7f9U0d`9R0b`9P0ma9E0ha9E0nb8_0oc8_0dd8]0jf8^\1d1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1mg:U1ii:U1jj:V1dn:U1co:U1jq:S1ko:S1ko:R1on:R1go:Q1mm:Q1bn:P1cm:O1bm:O1kl:N1ll:O1gn:N1kn:M1nm:M1`n:M1cm:L1jl:J1kj:I1cj:I1ji:J1mk:K1lk:L1`k:L1ak:K1lk:M1dk:M1oj:M1`l:N1lj:P1ni:O1bi:O1bh:O1jf:R1fg:R1dg:S1`g:S1kf:R1me:S1`g:T1lg:T1mh:S1nj:T1hi:U1di:U1mg:U\1d1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1by:O1jz:M1b{:M1b|:M1a}:K1e|:K1nz:K1b|:J1a}:I1`|:H1m}:F1i~:G1d\7f:F1e~:F1f~:E1k\7f:D2ob:C2ad:D2mb:E2gc:E2aj:F2gj:G2di:J2bj:J2di:K2jh:J2nf:J2hf:K2me:K2fc:J2gb:H2`b:I2n`:H1i}:I1n|:J1l}:K1m}:L1c}:L1o|:L1j|:M1f}:M1b|:O1d}:P1j|:P1m{:P1b|:O1e|:N1m{:N1`y:P1by:O\1d1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ay:P1ow:P1mv:R1iu:Q1ev:P1gt:P1mt:Q1ns:Q1fr:Q1br:R1bs:R1jr:R1lr:S1at:R1iu:R1ku:R1cu:R1cu:S1jw:S1gy:R1ay:P\1d1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1`r:K1er:L1jt:L1et:N1dt:N1lp:M1fp:M1ho:M1dq:K1`r:K\1d1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1bv:O1nr:O1br:N1fp:M1bv:O\1d1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1nq:O1br:O1gr:O1er:P1`r:Q1dq:Q1`q:O1iq:O1nq:O\1d1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1gm9\1ln9_1jo9_1lo:@1`q:A1mq:A1ar:B1or:B1bs:C1ks:C1av:C1ks:B1`p9_1cp9^1gm9\\1d1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1cs:I1mv:J1bw:I1hw:J1fv:K1hv:L1av:L1hv:M1du:M1dt:L1cs:I\1d1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1n{:E1`x:H1gy:H1cy:H1m{:G1n{:E\1d4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4dh4C4ij4C4an4D4nn4E4kn4F4lo4F4oo4D4ix3_4i{3_4d~3]4f\7f3^5nb3_5mf4F5gh4H5dg4L5bh4L5mf4N5ib4M5ia4L5cb4J5ka4I4o\7f4H4j~4I4e~4I4o~4F4o}4F4e}4H4g|4H4bz4I4by4I4by4J4ax4K4fw4M4gu4L4`s4M4hq4N4ep4N4fp4O4op4O4lo4P4gp4Q4cq4Q4gq4R4`s4Q4fu4P4ct4M4hq4N4jn4M4jm4M4jm4O4gm4O4il4O4bl4P4ok4N4fk4N4gk4O4li4Q4jf4P4`c4Q4na4K4jb4H4jd4F4je4C4dh4C\1d3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3gp2U3bn2X3fn2Z3`z3@3m{2_3l\7f3A3l\7f3A4`a2_4ab3@4lb3@4ja2]4jb2\4f`2Y3m\7f2W4nb2Q4o`2P4f`2N4jb2K4oa2I4eb2J4ab2H4dc2K4`c2H4kc2H4je2G4hf2H4ig2E4ci2E4ah2F4fh2G4bi2F4ni2G4cj2F4ek2F4`l2G4ok2D4hm2E4ao2F4eo2M4io2L4dp2O4gp2M4fq2O4lq2M4hs2J4kv2H5kb2N5af2Q5`f2T5dd2V5ed2Y5ee2Y5ia2V5n`2Y4n~2X4f~2[4m~2]5``2^5h`3A5ia3A5ma2]5ce2Y5ae2]5bi3H5bg3D5ce3E5ia3C5la3B5n`3A4kw3N4is3O4cq3J4hq3I4nq3E4eu2]4bu2X4op2R4`r2M4fq2O4fq2K4kq2J4`q2J\1d4`q2J4eq2I4cq2H4`p2H4ao2F4hm2E4mn2E4oo2F4oo2D4ip2G4eq2B4op2@4bq2@4ep1_4jp1^4`n2@4on1^4nn1^4im1_4hm1_4en1^4fn1]4fm1^4hm1]4jn1]4ko1[4jm1[4nj1]4ij1]4ek1\4oj1Z4bj1\4mi1[4dh1^4hh1^4ji1]4hi1\4ej1]4ei1^4bi1_4dg2@4cg2@4if2@4ah1_4dh1^4fg1_4ie1_4lf1^4ff1\4`f1]4ge1\4od1]4dd1]4kd1\4od1\4ge1[4kb1\4jb1\4ga1\4kb1[4ib1[4aa1[4ka1Z4gb1Z4dc1Z4fb1Y4lb1Y4nc1X4dd1Y4ef1W4eg1X4bg1X4mg1Y4if1\4lf1\4`g1]4ah1[4mg1W4kn1R4`t1S4kz1J4iz1I4d}1G4g}1G4a~1G4f\7f1F5b`1F4k\7f1C5cb1B5ib1C5gc1B5na0_5c`0_4f\7f0_4i\7f0_4b}0_4e|1@4c{1B4hw1D4jv1D4ot1F\1d4ot1F4jt1G4nt1I4kt1I4`t1J4is1I4mr1I4`p1O4an1P4ll1P4hm1O4kn1N4co1L4eo1L4en1K4lm1K4kl1J4gl1J4fl1K4jk1L4oi1L4ni1L4li1L4`i1K4`h1K4gf1H4jf1H4ig1H4jf1B4dg1B4fg1A4ag1A4lf1A4fg1@4hf1@4cf0_4ae1@4`e1A4kc1C4kc1D4ib1E4`b1G4lb1G4jc1G4od1F4ig1H4gi1H4ih1I4lh1I4di1J4mm1H4km1G4jn1F4co1F4`p1F4ho1E4gp1D4mp1E4hp1D4ar1C4br1A4jx0Z4f|0Y4o}0U4o{0S4mz0Q4nx0N4kz0H4hx0F4jt0F4gr0C4fq0@4nk/]4cj/]4fi/]4og/\4de/\4hd/Z4gb/Y4ob/X4fb/V4db/V4ia/Q4ja/P4`b/P4b`/O3l\7f/O4g`/M4fb/L4kb/L4`d/K\1d4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4`d/K4bc/H4hc/G4hc/G4fc/E4eh/F4`h/E4ei/D4jk/D4bm/E4fq/F4gu/E4mu/F4ou/E4iv/F4kv/E4dw/F4bw/E4bw/E4nw/E4kx/D4k{/H4nz/J4oz/M4`{/N4cz/Q4iz/T4ly/V4ez/V4iy/X4hz/Z4ay/Z5eb/[5ob/Z5mc/[5ce/Z5af/Y5jg/X5ch/X5ii/W5bj/W5oi/V5jk/T5`k/R5dl/Q5jl/R5bm/Q5dm/R5dm/Q5en/Q5lo/V5gn/V5on/W5ln/Z5ds/Y5cs/Z5kr/Z5lq/[5hq/^5br/^5dr/^5as/^5os/_5ct0@5`u0B5`x0B5kx0B5jz0G5a{0G5f}0I5e~0J6ga0J6aa0K6na0L6gb0L6ec0N6fc0N6jc0P6ad0Q6od0S6fe0U6cf0U\1d6cf0U6hg0U6fh0V6hi0U6ll0U6hm0T6dn0T6ho0T6ho0T6hs0T6au0U6fu0W6dw0Y6fw0Y6gx0Z6ew0Z6jv0Z6ju0Z6`v0Z6dr0Z6br0Z6`r0[6kq0[6`q0[6mp0Z6on0Y6an0Y6`n0X6fm0X6hm0Z6el0[6`k0[6ak0Y6em0X6ck0W6bk0X6bj0Z6`j0X6hi0Y6di0Y6ch0X6lg0\6ag0\6af0[6af0]6dh1@6dh1A6bi1B6if1C6kg1B6mf1B6kf1B6mf1C6oe1D6bg1I6gh1J6li1P6ng1P6lg1S6`i1T6mj1U6bn1W6hs1W6hw1Y6ex1[6cv1\6gu1\6at1^6iu2@6f{2@6nz1_6`}1^6l\7f1^7la2E7l`2J7mb2J7ad2M7`c2P7ad2P7bd2O\1f\1d7`d1^7mc1]7`d1]\1f\1d7`d1R7`d1R7lc1R7lc1R7lc1R7lc1R7kc1Q7kc1Q7kc1Q7gc1Q7gc1Q7gc1Q7gc1Q7cc1Q7cc1Q7cc1Q7cc1Q7ob1Q7ob1Q7ob1Q7da1S7d`1Q6l~1O6j}1N6`~1N6i|1L6`|1L6j{1K6jr1J6ap1I6fp1H6dp1F6ko1E6no1E6fn1D6hm1E6dl1D6nl1C6el1B6hl1A6hm1A6mm1A6mo1@6io1@6ap0_6ko0^6`o0]6jo0\6ao0]6dn0]6fn0[6om0[6mm0\6en0\6jl0\6el0\6jk0\6ok0\6kk0]6mj0^6ni0]6fj0\6dj0\6ki0[6mh0Z6`i0^6jh0^6fi0^6jj0_6dj1@6lj1@6gk0^6ok0_6fl0_6ll0_6om0_6am1@6im1@6io1@6mo1@6cq0_6jp1@6iq1@6oq1@6cv0^6bv0^6j{0\6l~0\7ja0Z7b`0Z6o~0Y6m~0X6az0T6iy0R6bz0O6b{0P6lz0P6j|0M6h}0M6a\7f0M6c~0N\1d6c~0N6`\7f0N7b`0N7i`0N6i\7f0L7fa0M7mb0M7`b0L7ob0K7`c0L7`c0L7`c0L7ac0L7ec0L7ec0L7fc0L7jc0L7jc0L7jc0L7kc0L7oc0L7oc0L7lc0M7`d0M7`d0M\1f\1d7ad0N7gc0L7kc0L7nc0L7nc0L\1f\1d6e|+W\1d6i~+W6f|+Y6g|+]6h~,@7lb,@7ce+]7be+Y7ag+W7ei+W7jk+Y7kk+]7di,@\1d6e|,D\1d6e|,Q\1d7mc+W7fc+W7`c+X7jb+X7gb+X7ab+Y7ka+Y7da+Z6nz,A6it,H6in,N6ci,S6hc,Y5k~,]5my-B5bu-F5jp-J5el-N5gh-Q5ed-U5f`-X4j|-[4cy-^4fu.A4br.D4in.G4dk.J4bh.L4ae.O4cb.Q3`\7f.T3b|.V3`y.Y3ev.[3js.]3op._3`n/B3ik/D3nh/F3gf/H3oc/J3da/M2m~/O2e|/Q2my/S2jw/U2bu/W2or/Y2kp/[2`n/^2ok/_2ki0A2dg0D2`e0F2mb0H2i`0J1j~0L1g|0N1`z0Q1mw0S1mu0U1ks0W1hq0Z1eo0\1fm0^1`k1A1bi1C1lf1F1nd1H1hb1K1j`1M0e~1P0`|1S0cz1U0ow1X0cv1[0os1^0lq2B0io2E0fm2H0ak2L0oh2O0of2S0kd2W0db2\/o\7f3@/j}3E/d{3K/ox3P/ev3W/ns3^/bq4G/dn4S/bk5G\1d7oc.N7dc.O7ac.O7jb.O7fb.O7oa.O7ha.P7ea.P7m`.P7j`.P7c`.P6l\7f.Q6d\7f.Q6a\7f.Q6n~.Q6g~.Q6c~.Q6h}.R6e}.R6kv.U6hp.Y6hj.\6`e._5o\7f/A5nz/D5mu/G5gq/I5ml/L5kh/N5hd/Q5i`/S4n|/U4cy/W4du/Z4mq/\4hn/^4ak0@4mg0B4md0D4ja0F3j~0H3j{0J3jx0L3nu0N3bs0P3gp0R3km0T3oj0V3ch0X3ke0Z3`c0]3d`0_2m}1A2e{1C2by1E2jv1G2ct1I2lq1L2eo1N2bm1P2kj1R2eh1U2bf1W2lc1Z2ja1\1d\7f1_1c}2A1nz2D1hx2G1dv2J1ct2L1oq2O1ho2S1em2V1fk2Y1`i2]1of3@1kd3D1gb3H1a`3M0o}3Q0h{3W0by3\0lv4C0jt4J0cr4S0eo5A\1d7nc1F7jc1F7bc1F7nb1F6i{1G6`u1H6ln1I6lh1J6dc1K5a~1L5by1M5ct1N5ho1P5bk1Q5lf1S5mb1T4l~1V4nz1W4`w1Y4ks1Z4bp1\4il1^4di2@4cf2A4nb2C3j\7f2E3j|2G3jy2I3jv2K3js2M3op2O3`n2R3ek2T3jh2V3le2Y3bc2[3h`2^2o}3@2f{3C2nx3F2fv3I2os3L2dq3P2on3S2fl3W2ni3[2dg4@2od4D2eb4J1n\7f4P1e}4X1hz5C\1d#`x6U\1fPluto occultation\1d"`}6U\1fAug  19 1985 17:50 UT\1d"`b6U\1fDoug Mink Oct 16 1985\1d#`d @\1f
\ No newline at end of file
diff --git a/tektests/fotest.tek b/tektests/fotest.tek
new file mode 100644 (file)
index 0000000..557adfa
Binary files /dev/null and b/tektests/fotest.tek differ
diff --git a/tektests/imtest.tek b/tektests/imtest.tek
new file mode 100644 (file)
index 0000000..24951ad
--- /dev/null
@@ -0,0 +1 @@
+\1d ` @ `?_\1d `?_8m?_\1d8m?_8m @\1d8m @ ` @\1d!r#D\1f(0,0)\1d ` @8m?_\1d `?_8m @\1d,p @\1f
diff --git a/tektests/imtesth.tek b/tektests/imtesth.tek
new file mode 100644 (file)
index 0000000..bdf4e94
--- /dev/null
@@ -0,0 +1 @@
+\1d `` @ c`?_\1d c`?_8om?_\1d8om?_8lm @\1d8lm @ `` @\1d!`r#D\1f(0,0)\1d `` @8om?_\1d c`?_8lm @\1d,`p @\1f
diff --git a/tektests/ocpred.tek b/tektests/ocpred.tek
new file mode 100644 (file)
index 0000000..25dee06
--- /dev/null
@@ -0,0 +1,3 @@
+\1d+gd5U+fd6T\1d+fi6T*f\7f6T\1d+fd6T+dd7S\1d+di7S*d\7f7S\1d+dd7S+gd8Q\1d+gi8Q*g\7f8Q\1d+gd8Q+ed9P\1d+ei9P*e\7f9P\1d+ed9P+dd:O\1d+di:O*d\7f:O\1d+dd:O+fd;M\1d+fi;M*f\7f;M\1d+fd;M+ed<L\1d+ei<L*e\7f<L\1d+ed<L+gd=J\1d+gi=J*g\7f=J\1d+gd=J+fd>I\1d+fi>I*f\7f>I\1d+fd>I+dd?H\1d+di?H*d\7f?H\1d+dd?H\1d+dd?H\1d+gd5U,cc5U\1d,cc5Z,cc5P\1d,cc5U-ka5U\1d-ka5Z-ka5P\1d-ka5U.g`5U\1d.g`5Z.g`5P\1d.g`5U.o~5U\1d.o~5Z.o~5P\1d.o~5U/k}5U\1d/k}5Z/k}5P\1d/k}5U0c|5U\1d0c|5Z0c|5P\1d0c|5U1oz5U\1d1oz5Z1oz5P\1d1oz5U2gy5U\1d2gy5Z2gy5P\1d2gy5U3cx5U\1d3cx5Z3cx5P\1d3cx5U4kv5U\1d4kv5Z4kv5P\1d4kv5U\1d4kv5U\1d+gd5U+ed4W\1d*e\7f4W+ei4W\1d+ed4W+fd3X\1d*f\7f3X+fi3X\1d+fd3X+dd2Z\1d*d\7f2Z+di2Z\1d+dd2Z+ed1[\1d*e\7f1[+ei1[\1d+ed1[+gd0\\1d*g\7f0\+gi0\\1d+gd0\+dd/^\1d*d\7f/^+di/^\1d+dd/^+fd._\1d*f\7f._+fi._\1d+fd._+gd.@\1d*g\7f.@+gi.@\1d+gd.@+ed-B\1d*e\7f-B+ei-B\1d+ed-B+fd,C\1d*f\7f,C+fi,C\1d+fd,C\1d+fd,C\1d+gd5U*oe5U\1d*oe5P*oe5Z\1d*oe5U)cg5U\1d)cg5P)cg5Z\1d)cg5U(kh5U\1d(kh5P(kh5Z\1d(kh5U'oi5U\1d'oi5P'oi5Z\1d'oi5U&gk5U\1d&gk5P&gk5Z\1d&gk5U%kl5U\1d%kl5P%kl5Z\1d%kl5U$cn5U\1d$cn5P$cn5Z\1d$cn5U#go5U\1d#go5P#go5Z\1d#go5U"op5U\1d"op5P"op5Z\1d"op5U!cr5U\1d!cr5P!cr5Z\1d!cr5U\1d!cr5U\1d4kv5U\1d4k{5P\1fN\1d+fd,C\1d*hl,F\1fE\1d!cr5U\1d cy5P\1fS\1d+dd?H\1d*hl>Y\1fW\1d%`o @\1d,cc5U,nb5T,nb5S,mb5R,ib5Q,db5P,`b5O,oa5M,ka5L,fa5K,o`5J,k`5I,``5I+h\7f5H+`\7f5G+h~5F+a~5E+j}5D+c}5C+g|5B+h{5B+a{5A+fz5@+ky4_+lx4_+bx4^+gw4]+iv4]+ju4\+lt4\+bt4[+ds4[+fr4Z+dq4Z+fp4Y+eo4Y+kn4X+fm4X+el4X+`k4X+cj4W+nh4W+mg4W+if4W+ie4W+ed4W+ac4W+ab4W+m`4W*n\7f4W*k~4W*h}4X*e|4X*f{4X*cz4X*ey4Y*fx4Y*hw4Z*jv4Z*hu4[*jt4[*ls4\*bs4\*dr4]*gq4]*jp4^*lo4_*co4_*fn5@*im5A*`m5B*gl5B*nk5C*bk5D*ij5E*`j5F*ki5F*ci5G*kh5H*ch5I*og5J*fg5K*cg5L*of5M*hf5O*df5P*af5Q*me5R*ne5S*ne5T*oe5U*le5W*le5X*me5Y*af5Z*ff5[*jf5\*of5]*cg5^*dg6@*og6@\1d*og6@*ch6A*jh6B*bi6C*ji6D*bj6E*ij6F*`k6G*kk6G*gl6H*bm6I*im6J*dn6K*co6K*no6L*hp6M*gq6M*ar6N*`s6O*ns6O*ht6P*fu6P*dv6Q*fw6Q*dx6R*ey6R*cz6R*d{6S*e|6S*j}6S*k~6S*l\7f6T+m`6T+ab6T+ac6T+fd6T+ie6T+if6T+mg6T+lh6T+cj6S+bk6S+el6S+dm6S+kn6R+eo6R+dp6R+bq6Q+`r6Q+bs6P+`t6P+nt6O+hu6O+fv6N+gw6M+`x6M+nx6L+ky6K+dz6K+a{6J+j{6I+g|6H+l|6H+h}6G+a~6F+j~6E+c\7f6D+k\7f6C,c`6B,k`6A,o`6@,da6@,ka5^,oa5],bb5\,fb5[,ib5Z,mb5Y,lb5X,lb5W,cc5U\1d$`l?@$`l?J\1d$`l?E%`u?E\1d%`u?@%`u?J\1d%`j9Y\1f        0.1"\1d$`t9Y\1f     2148 km\1d#`v9Y\1fStar position\1d#``9Y\1fin sky plane\1d"`j9Y\1fFrom  2:40: 0\1d!`t9Y\1fEach  0: 1: 0\1d+fd,C\1d+fi,R\1fSUN->\1f\1d.ke7[\1d.di7[.na7\\1d.ke7[\1d-k{8@\1fSAA\1d.ke7[.`b7L\1d.me7K-g~7L\1d.`b7L-h~6\\1d.eb6[-oz6\\1d-h~6\-lz6L\1d-i~6K-cw6L\1d-lz6L-dw5\\1d-a{5[-ks5\\1d-dw5\-ms5L\1d-jw5K-`p5M\1d-ms5L-ap4\\1d-ns4[-dl4]\1d-ap4\-il4L\1d-fp4K-lh4M\1d-il4L-ai3\\1d-nl3[-de3]\1d-ai3\-fe3L\1d-ci3K-ia3M\1d-fe3L-na2\\1d-ke2[,a~2]\1d-na2\,b~2L\1d-oa2K,ez2M\1d,b~2L,kz1\\1d,d~1\,nv1]\1d,kz1\,cw1L\1d,lz1L,fs1M\1d,cw1L,ds0]\1d,aw0\,ko0]\1d,ds0],lo0M\1d,is0L,cl0M\1d,lo0M,dl/]\1d,ap/\,kh/]\1d,dl/],ih/M\1d,fl/L,ld/N\1d,ih/M,ae.]\1d,nh.\,da.^\1d,ae.],fa.M\1d,ce.L+i}.N\1d,fa.M+n}-]\1d,ka-\+az-^\1d+n}-]+gz-M\1d+`~-M+jv-N\1d+gz-M+kv,]\1d+dz,]+nr,^\1d+kv,]+`s,N\1d+mv,M+go,N\1d+`s,N\1d7lv @\1fMay  4 1986 Occultation of nepklem 1026 by Triton (N1)\1d7h` @\1fObserved from SAAO Sutherland 74" Long= -20 48 44.3  Lat= -32 22 43.4\1d6dj @\1f13.11-magnitude    star at RA= 18h 24m 16.1231s  Dec=-22d 13' 22.807" 
+\r\1d5`t @\1f                    (1950) RA= 18h 22m  5.3070s  Dec=-22d 14' 27.910" 
+\r\1d4l} @\1fClosest at  2:45:30 U.T. \1d4hg @\1f Radial=   4158.7 km =   0.19"\1d3dq @\1f Planet=   1600.0 km =   0.07"\1d2`{ @\1f ET - UT = 56.1709 sec  DE-118\1d2ld @\1f P.A.=  12.7 deg.\1d1hn @\1f Phase =   1.5 deg = 100.0%\1d0dx @\1f Alt= 75 d, Az= -36 d\1d0`b @\1f Sun alt=-30 d, Az=  90 d\1d/lk @\1f Sun:127.8 d, Moon: 11.9 d\1d.hu @\1f V =0.0007 "/s = 14.22 km/s\1d-d\7f @\1f D = 29.619079 A.U.\1d-`i @\1fDoug Mink 16: 4 Nov 11 1985\1d-`i @\1f\r
diff --git a/tektests/usmap.tek b/tektests/usmap.tek
new file mode 100644 (file)
index 0000000..0e62344
Binary files /dev/null and b/tektests/usmap.tek differ
diff --git a/termcap b/termcap
new file mode 100644 (file)
index 0000000..91111ae
--- /dev/null
+++ b/termcap
@@ -0,0 +1,237 @@
+# $XTermId: termcap,v 1.78 2009/11/09 00:24:26 tom Exp $
+#
+# These are termcap entries that correspond to xterm's terminfo file.
+# The file is formatted using ncurses' "tic -CNx", but is not mechanically
+# derived from the terminfo.
+#
+#------------------------------------------------------------------------------
+# Copyright 1996-2007,2009 by Thomas E. Dickey
+#
+#                         All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+#------------------------------------------------------------------------------
+#
+# Note:
+#      termcap format is limited to 1023 characters.  This set of descriptions
+#      is a subset of the terminfo, since not all features can be fit into
+#      that limit.  The 'xterm' description supports color.  The monochrome
+#      'xterm-mono' drops color in favor of additional function keys.  If you
+#      need both, use terminfo.
+#
+#      The 1023-character limit applies to each entry after resolving the
+#      "tc=" strings.  Some implementations may discount all or part of the
+#      formatting characters in the entry (i.e., the backslash newline tab
+#      colon).  GNU termcap does not have this limit.
+#
+#      I checked the limits using ncurses "captoinfo -CrTUvx", which prints
+#      the resolved length of each entry in a comment at the end - T.Dickey
+#
+xf|xterm-new|modern xterm:\
+       :*6=\EOF:@7=\EOF:F1=\E[23~:F2=\E[24~:K2=\EOE:Km=\E[M:\
+       :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\
+       :k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:kH=\EOF:kI=\E[2~:\
+       :kN=\E[6~:kP=\E[5~:kd=\EOB:kh=\EOH:kl=\EOD:kr=\EOC:ku=\EOA:\
+       :tc=xterm-basic:
+#
+# This chunk is used for building the VT220/Sun/PC keyboard variants.
+xb|xterm-basic|modern xterm common:\
+       :am:bs:km:mi:ms:ut:xn:AX:\
+       :Co#8:co#80:kn#12:li#24:pa#64:\
+       :AB=\E[4%dm:AF=\E[3%dm:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\
+       :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=\E(B:al=\E[L:\
+       :as=\E(0:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\
+       :cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\
+       :ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>:\
+       :kD=\E[3~:kb=^H:ke=\E[?1l\E>:ks=\E[?1h\E=:le=^H:md=\E[1m:\
+       :me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:op=\E[39;49m:\
+       :rc=\E8:rs=\E[!p\E[?3;4l\E[4l\E>:sc=\E7:se=\E[27m:sf=^J:\
+       :so=\E[7m:sr=\EM:st=\EH:te=\E[?1049l:ti=\E[?1049h:\
+       :ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?12l\E[?25h:vi=\E[?25l:vs=\E[?12;25h:
+
+# The xterm-new description has all of the features, but is not completely
+# compatible with vt220.  If you are using a Sun or PC keyboard, set the
+# sunKeyboard resource to true:
+#      + maps the editing keypad
+#      + interprets control-function-key as a second array of keys, so a
+#        12-fkey keyboard can support vt220's 20-fkeys.
+#      + maps numeric keypad "+" to ",".
+#      + uses DEC-style control sequences for the application keypad.
+#
+vt|xterm-vt220|xterm emulating vt220:\
+       :*6=\E[4~:@7=\E[4~:K2=\EOu:Km=\E[M:kH=\E[4~:kh=\E[1~:\
+       :tc=xterm-basic:
+
+v1|xterm-24|xterms|vs100|24x80 xterm:\
+       :li#24:tc=xterm-old:
+v2|xterm-65|65x80 xterm:\
+       :li#65:tc=xterm-old:
+vb|xterm-bold|xterm with bold for underline:\
+       :so=\E[7m:us=\E[1m:tc=xterm-old:
+vB|xterm-boldso|xterm with bold for standout:\
+       :se=\E[m:so=\E[1m:tc=xterm-old:
+vm|xterm-mono|monochrome xterm:\
+       :ut@:\
+       :Co@:NC@:kn#20:pa@:\
+       :AB@:AF@:Sb@:Sf@:op@:st@:tc=xterm-old:
+#
+# Alternate terminal description that "works" for interactive shells such as
+# tcsh and bash.
+xn|xterm-noapp|xterm with cursor keys in normal mode:\
+       :kd=\E[B:ke=\E>:kl=\E[D:kr=\E[C:ks=\E=:ku=\E[A:te@:ti@:\
+       :tc=xterm:
+#
+# This should work for the commonly used "color xterm" variations (XFree86
+# xterm, color_xterm, nxterm, rxvt).  Note that it does not set 'bce', so for
+# XFree86 and rxvt, some applications that use colors will be less efficient,
+# and in a few special cases (with "smart" optimization) the wrong color will
+# be painted in spots.
+vc|xterm-color|generic "ANSI" color xterm:\
+       :Co#8:NC@:pa#64:\
+       :AB=\E[4%dm:AF=\E[3%dm:ac=:op=\E[m:tc=xterm-r6:
+#
+# These aliases are for compatibility with the terminfo; termcap cannot provide
+# the extra features such as color initialization, but termcap applications
+# still want the names.
+x1|xterm-16color|xterm alias:\
+       :tc=xterm-new:
+
+x2|xterm-88color|xterm alias:\
+       :Co#88:pa#7744:tc=xterm-256color:
+
+x3|xterm-256color|xterm alias:\
+       :Co#256:pa#32767:\
+       :AB=\E[48;5;%dm:AF=\E[38;5;%dm:tc=xterm-new:
+
+xi|xterm-nrc|xterm alias:\
+       :tc=xterm:
+xr|xterm-rep|xterm alias:\
+       :tc=xterm:
+xx|xterm-xmc|xterm alias:\
+       :sg#1:tc=xterm:
+#
+# An 8-bit description is doable with termcap, but there are probably no
+# termcap (or BSD curses) applications that are able to use it.
+x8|xterm-8bit|xterm terminal emulator 8-bit controls (X Window System):\
+       :am:km:mi:ms:xn:\
+       :co#80:it#8:li#24:\
+       :AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:IC=\233%d@:\
+       :K2=\217y:Km=\233M:LE=\233%dD:RI=\233%dC:UP=\233%dA:\
+       :ae=\E(B:al=\233L:as=\E(0:bl=^G:bt=\233Z:cd=\233J:ce=\233K:\
+       :cl=\233H\2332J:cm=\233%i%d;%dH:cr=^M:cs=\233%i%d;%dr:\
+       :ct=\2333g:dc=\233P:dl=\233M:do=^J:ei=\2334l:ho=\233H:\
+       :im=\2334h:\
+       :is=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8:\
+       :k1=\23311~:k2=\23312~:k3=\23313~:k4=\23314~:k5=\23315~:\
+       :k6=\23317~:k7=\23318~:k8=\23319~:k9=\23320~:kD=\2333~:\
+       :kI=\2332~:kN=\2336~:kP=\2335~:kb=^H:kd=\217B:\
+       :ke=\233?1l\E>:kh=\2331~:kl=\217D:kr=\217C:ks=\233?1h\E=:\
+       :ku=\217A:le=^H:mb=\2335m:md=\2331m:me=\233m:mr=\2337m:\
+       :nd=\233C:rc=\E8:sc=\E7:se=\23327m:sf=^J:so=\2337m:sr=\215:\
+       :st=\210:ta=^I:te=\233?1049l:ti=\233?1049h:ue=\23324m:\
+       :up=\233A:us=\2334m:vb=\233?5h\233?5l:ve=\233?25l\233?25h:\
+       :vs=\233?12;25h:vi=\233?25l:
+#
+hp|xterm-hp|xterm with hpterm function keys:\
+       :@7=\EF:k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:\
+       :k8=\Ew:kC=\EJ:kD=\EP:kI=\EQ:kN=\ES:kP=\ET:kd=\EB:kh=\Eh:\
+       :kl=\ED:kr=\EC:ku=\EA:tc=xterm-basic:
+#
+xS|xterm-sco|xterm with SCO function keys:\
+       :@7=\E[F:F1=\E[W:F2=\E[X:F3=\E[Y:F5=\E[a:F6=\E[b:F7=\E[c:\
+       :F8=\E[d:F9=\E[e:FA=\E[f:FB=\E[g:FC=\E[h:FD=\E[i:FE=\E[j:\
+       :FF=\E[k:ac=:k1=\E[M:k2=\E[N:k3=\E[O:k4=\E[P:k5=\E[Q:\
+       :k6=\E[R:k7=\E[S:k8=\E[T:k9=\E[U:k;=\E[V:kD=\177:kI=\E[L:\
+       :kN=\E[G:kP=\E[I:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\
+       :tc=xterm-basic:
+#
+v5|xterm-vt52|xterm emulating vt52:\
+       :bs:\
+       :co#80:it#8:li#24:\
+       :ae=\EG:as=\EF:bl=^G:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :\
+       :cr=^M:do=\EB:ho=\EH:kb=^H:kd=\EB:kl=\ED:kr=\EC:ku=\EA:\
+       :le=\ED:nd=\EC:nw=^M^J:sf=^J:sr=\EI:ta=^I:up=\EA:
+#
+xs|xterm-sun|xterm with Sun functionkeys:\
+       :%1=\E[196z:&8=\E[195z:@0=\E[200z:@5=\E[197z:@7=\E[220z:\
+       :F1=\E[192z:F2=\E[193z:K2=\E[218z:Km=\E[M:k1=\E[224z:\
+       :k2=\E[225z:k3=\E[226z:k4=\E[227z:k5=\E[228z:k6=\E[229z:\
+       :k7=\E[230z:k8=\E[231z:k9=\E[232z:k;=\E[233z:kD=\E[3z:\
+       :kI=\E[2z:kN=\E[222z:kP=\E[216z:kh=\E[214z:\
+       :tc=xterm-basic:
+#
+# vi may work better with this entry, because vi doesn't use insert mode much.
+# |xterm-ic|xterm-vi|xterm with insert character instead of insert mode:\
+vi|xterm-ic|xterm-vi|xterm with insert char:\
+       :mi@:\
+       :IC=\E[%d@:ei@:ic=\E[@:im@:tc=xterm:
+#
+# Compatible with the X11R6.3 xterm
+r6|xterm-r6|xterm-old|X11R6 xterm:\
+       :am:bs:km:mi:ms:pt:xn:\
+       :co#80:kn#20:li#24:\
+       :*6=\E[4~:@0=\E[1~:@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\
+       :DO=\E[%dB:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:\
+       :F5=\E[28~:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:\
+       :FA=\E[34~:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:\
+       :as=^N:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:\
+       :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:eA=\E)0:ei=\E[4l:\
+       :ho=\E[H:im=\E[4h:\
+       :is=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:\
+       :k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:\
+       :k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\
+       :kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kb=^H:kd=\EOB:\
+       :ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:\
+       :ku=\EOA:md=\E[1m:me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:\
+       :rc=\E8:rs=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:\
+       :sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\
+       :ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:
+#
+# Compatible with the R5 xterm
+r5|xterm-r5|X11R5 xterm X11R5:\
+       :am:bs:km:mi:ms:pt:xn:\
+       :co#80:kn#4:li#24:\
+       :@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\
+       :IC=\E[%d@:UP=\E[%dA:al=\E[L:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\
+       :cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\
+       :ei=\E[4l:ho=\E[H:im=\E[4h:\
+       :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\
+       :k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:kb=^H:kd=\EOB:\
+       :ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:\
+       :ku=\EOA:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:rc=\E8:\
+       :rs=\E>\E[?1;3;4;5;6l\E[4l\E[?7h\E[m\E[r\E[2J\E[H:\
+       :sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\
+       :ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:
+#
+# Customization begins here.
+x0|xterm-xfree86|xterm terminal emulator (XFree86):\
+       :tc=xterm-new:
+#
+# This is the only entry which you should have to customize, since "xterm"
+# is widely used for a variety of incompatible terminal emulations including
+# color_xterm and rxvt.
+v0|xterm|X11 terminal emulator:\
+       :tc=xterm-new:
+#      :tc=xterm-r6:
diff --git a/terminfo b/terminfo
new file mode 100644 (file)
index 0000000..88bee44
--- /dev/null
+++ b/terminfo
@@ -0,0 +1,1939 @@
+# $XTermId: terminfo,v 1.155 2007/11/11 23:26:52 tom Exp $
+#
+# $XFree86: xc/programs/xterm/terminfo,v 3.59 2006/02/13 01:14:59 dickey Exp $
+#
+# Updates/notes/new entries (e.g., xterm-8bit, xterm-16color, xterm-256color)
+# - Thomas E. Dickey
+#
+#------------------------------------------------------------------------------
+# Copyright 1996-2006,2007 by Thomas E. Dickey
+#
+#                         All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+#------------------------------------------------------------------------------
+#
+# Special Capabilities:
+# --------------------
+# ich has a corresponding capability that inserts a single blank.  We could
+#      have used ich1=\E[@, which works with ncurses, but that is not standard
+#      behavior.  If it is set, then SVr4 vi (e.g., Solaris 2.6) emits both
+#      smir/rmir and ich1.
+# meml locks memory above the cursor; memu unlocks (ala HP terminals).  This
+#      is not recognized by some older (e.g., SVr3) tic programs, but none
+#      do more than warn about it.  Ignore the warning.
+# smcup clears memory before switching to the alternate screen.  The older
+#      (deprecated) \E[?47h did not do this, requiring applications to
+#      embed a \E[2J in the rmcup string.  However, that behavior cannot
+#      be disabled via titeInhibit, making that resource not function as
+#      intended on systems with terminfo.
+# rs2/is2 are shorter with XFree86 xterm because it supports DECSTR.  We
+#      use the shorter sequence for compatibility with the termcap, which
+#      is trimmed to keep it shorter than 1023 characters.  It (escape \E[!p)
+#      replaces these in the conventional vt100 reset-string:
+#              \E7     - save cursor (fixes origin-mode side-effect)
+#              \E[r    - reset scrolling margins
+#              \E[m    - reset SGR (including color)
+#              \E[?7h  - reset wraparound mode (DECAWM)
+#              \E[?1l  - reset application cursor keys (DECCKM)
+#              \E[?6l  - reset origin mode (DECOM)
+#              \E8     - restore cursor
+#      DECSTR is recognized by XFree86 xterm even in vt52 mode.
+#
+# Editing Keypad:
+# --------------
+# XFree86 xterm emulates vt220 if the decTerminalID resource is set to 200 or
+# higher.  Otherwise it emulates a vt100 or vt52 depending on the value of the
+# resource.  When emulating a vt220, we support the editing keypad.  Sun and PC
+# keyboards have an editing keypad which is similar to the vt220:
+#
+#      VT220 editing keypad
+#      ----------------------------
+#      Find      Insert      Remove
+#      Select    Prev        Next
+#      ----------------------------
+#
+#      Sun/PC editing keypad
+#      ----------------------------
+#      Insert    Home        PageUp
+#      Delete    End         PageDn
+#      ----------------------------
+#
+# If the sunKeyboard resource is true, we map it this way (adjusting the values
+# of Home, End and Delete):
+#      VT220                 Sun/PC
+#      ----------------------------
+#      Find                  Home
+#      Select                End
+#      Insert                Insert
+#      Remove                Delete
+#      Prev                  PageUp
+#      Next                  PageDn
+#      ----------------------------
+#
+# Note that all of the keys on the editing keypad transmit escape sequences.  A
+# vt220 does this only when in vt220 mode; when emulating a vt100 the editing
+# keypad is inactive.
+#
+# Alternative keycodes:
+# --------------------
+# Several of the function keys have alternative names, depending on the type of
+# host which your xterm is connected to.  DEC (i.e., the VMS system) uses F15
+# as the HELP key, F16 as the DO key.  Unix applications generally do not do
+# this.  Curses applications in particular, assign a unique keycode to each
+# capability string.  These terminal descriptions do not have conflicting
+# definitions, to ensure that Unix curses applications use a consistent set of
+# keycodes.  To get a VMS-bias, make these substitutions:
+#      1. change khome to kfnd
+#      2. change kend to kslt
+# The original xterm-r6 entry does in fact have a VMS bias.
+#
+# Some legacy applications using the termcap emulation may expect kll where
+# we have specified kend.
+#
+# Function keys with modifiers (Sun/PC):
+# -------------------------------------
+#      Shift-Fx          - kf{12+x}
+#      Control-Fx        - kf{24+x}
+#      Shift-Control-Fx  - kf{36+x}
+#
+# The terminfo defines some special keys which are documented as "shifted",
+# e.g., kDC is shifted-delete-character.
+#
+# Note however, that even though the terminfo says a key might be sent, there
+# may be conflicts which prevent this.  For example, it is common to use
+# shifted pageup and pagedown for window manager functions.  The default
+# translation for xterm since X11R4 has overridden shifted Insert, Select,
+# PageUp and PageDown, which correspond to terminfo kIC, kEND, kPRV and kNXT
+# respectively.
+#
+xterm-new|modern xterm terminal emulator,
+       npc,
+       indn=\E[%p1%dS,
+       kb2=\EOE,
+       kcbt=\E[Z,
+       kent=\EOM,
+       rin=\E[%p1%dT,
+       use=xterm+pcfkeys,
+       use=xterm-basic,
+#
+# Encode modifiers using parameters (see "Xterm Control Sequences" ctlseqs.ms).
+# Note that this is unrelated to PCTERM.
+#
+# Some names are extensions allowed by ncurses, e.g.,
+#      kDN, kDN5, kDN6, kLFT5, kLFT6, kRIT5, kRIT6, kUP, kUP5, kUP6
+#
+# The uppercase names are made up, since there are no standards that apply.
+# If they were limited to two characters, they could in principle be translated
+# to termcap.  However, termcap sizes are limited to 1023 bytes, so there is
+# little point in ensuring that extended key names can be translated to
+# termcap.  A terminfo file can be up to 4096 bytes; using all extended keys
+# that xterm can generate would in fact exceed that limit.
+#
+# The numbers correspond to the modifier parameters documented in Xterm
+# Control Sequences:
+#
+#      2       Shift
+#      3       Alt
+#      4       Shift + Alt
+#      5       Control
+#      6       Shift + Control
+#      7       Alt + Control
+#      8       Shift + Alt + Control
+#
+# X/Open Curses defines some shift combinations, which are also used here
+# where applicable.  Since it does define some shift combinations, no number
+# (2) is used for suffixing the made-up names.  Some combinations are not
+# useful, e.g., they may reboot your computer, or they may require too many
+# fingers.  I stopped at modifier 7, just to keep things simple -TD
+#
+# XTerm resources:
+# ---------------
+# The xterm+pcfn, xterm+pcf0, xterm+pcf1, xterm+pcf2 and xterm+pcf3 fragments
+# correspond to default resource settings for xterm on a 104-key PC keyboard
+# with 12 function-keys:
+#
+#      *sunKeyboard:false
+#      *oldXtermFKeys:false
+#      *modifyCursorKeys:2
+#      *modifyFunctionKeys:2
+#      *ctrlFKeys:10
+#
+# The key numbers are computed based on the modifiers:
+#
+#      kf1-kf12 are F1-F12
+#      kf13-kf24 are shift F1-F12
+#      kf25-kf36 are control F1-F12
+#      kf37-kf48 are control+shift F1-F12
+#      kf49-kf60 are alt F1-F12
+#      kf61-kf63 are shift-alt F1-F3
+#
+# Note that ncurses would allow definition of kf64 and beyond, if there were
+# an application that required it.
+#
+xterm+pcfkeys|fragment for PC-style keys,
+       use=xterm+app,
+       use=xterm+pcf2,
+       use=xterm+pce2,
+       use=xterm+pcc2,
+#
+# The ctrlFKeys resource is only relevant to the xterm+pcfn and xterm+pcfN
+# entries, since the modifyFunctionKeys resource overrides ctrlFKeys when it is
+# positive.  A different choice of ctrlFKeys would give a different set of
+# function-key strings.
+xterm+pcfn|fragment with modifyFunctionKeys:-1 and ctrlFKeys:10,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\E[25~,
+       kf14=\E[26~,
+       kf15=\E[28~,
+       kf16=\E[29~,
+       kf17=\E[31~,
+       kf18=\E[32~,
+       kf19=\E[33~,
+       kf2=\EOQ,
+       kf20=\E[34~,
+       kf21=\E[42~,
+       kf22=\E[43~,
+       kf23=\E[44~,
+       kf24=\E[45~,
+       kf25=\E[46~,
+       kf26=\E[47~,
+       kf27=\E[48~,
+       kf28=\E[49~,
+       kf29=\E[50~,
+       kf3=\EOR,
+       kf30=\E[51~,
+       kf31=\E[52~,
+       kf32=\E[53~,
+       kf33=\E[54~,
+       kf34=\E[55~,
+       kf35=\E[56~,
+       kf36=\E[57~,
+       kf37=\E[58~,
+       kf38=\E[59~,
+       kf39=\E[60~,
+       kf4=\EOS,
+       kf40=\E[61~,
+       kf41=\E[62~,
+       kf42=\E[63~,
+       kf43=\E[64~,
+       kf44=\E[65~,
+       kf45=\E[66~,
+       kf46=\E[67~,
+       kf47=\E[68~,
+       kf48=\E[69~,
+       kf5=\E[15~,
+       kf6=\E[17~,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+
+# Changing ctrlFKeys to 12 would let us number the keys using just shift- and
+# control- modifiers:
+#      kf1-kf12 are F1-F12
+#      kf13-kf24 are shift F1-F12
+#      kf25-kf36 are control F1-F12
+#      kf37-kf48 are control+shift F1-F12
+xterm+pcfN|fragment with modifyFunctionKeys:-1 and ctrlFKeys:12,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\E[25~,
+       kf14=\E[26~,
+       kf15=\E[28~,
+       kf16=\E[29~,
+       kf17=\E[31~,
+       kf18=\E[32~,
+       kf19=\E[33~,
+       kf2=\EOQ,
+       kf20=\E[34~,
+       kf21=\E[42~,
+       kf22=\E[43~,
+       kf23=\E[44~,
+       kf24=\E[45~,
+       kf25=\E[46~,
+       kf26=\E[47~,
+       kf27=\E[48~,
+       kf28=\E[49~,
+       kf29=\E[50~,
+       kf3=\EOR,
+       kf30=\E[51~,
+       kf31=\E[52~,
+       kf32=\E[53~,
+       kf33=\E[54~,
+       kf34=\E[55~,
+       kf35=\E[56~,
+       kf36=\E[57~,
+       kf37=\E[58~,
+       kf38=\E[59~,
+       kf39=\E[60~,
+       kf4=\EOS,
+       kf40=\E[61~,
+       kf41=\E[62~,
+       kf42=\E[63~,
+       kf43=\E[64~,
+       kf44=\E[65~,
+       kf45=\E[66~,
+       kf46=\E[67~,
+       kf47=\E[68~,
+       kf48=\E[69~,
+       kf5=\E[15~,
+       kf6=\E[17~,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+
+xterm+pcf0|fragment with modifyFunctionKeys:0,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\EO2P,
+       kf14=\EO2Q,
+       kf15=\EO2R,
+       kf16=\EO2S,
+       kf17=\E[15;2~,
+       kf18=\E[17;2~,
+       kf19=\E[18;2~,
+       kf2=\EOQ,
+       kf20=\E[19;2~,
+       kf21=\E[20;2~,
+       kf22=\E[21;2~,
+       kf23=\E[23;2~,
+       kf24=\E[24;2~,
+       kf25=\EO5P,
+       kf26=\EO5Q,
+       kf27=\EO5R,
+       kf28=\EO5S,
+       kf29=\E[15;5~,
+       kf3=\EOR,
+       kf30=\E[17;5~,
+       kf31=\E[18;5~,
+       kf32=\E[19;5~,
+       kf33=\E[20;5~,
+       kf34=\E[21;5~,
+       kf35=\E[23;5~,
+       kf36=\E[24;5~,
+       kf37=\EO6P,
+       kf38=\EO6Q,
+       kf39=\EO6R,
+       kf4=\EOS,
+       kf40=\EO6S,
+       kf41=\E[15;6~,
+       kf42=\E[17;6~,
+       kf43=\E[18;6~,
+       kf44=\E[19;6~,
+       kf45=\E[20;6~,
+       kf46=\E[21;6~,
+       kf47=\E[23;6~,
+       kf48=\E[24;6~,
+       kf49=\EO3P,
+       kf5=\E[15~,
+       kf50=\EO3Q,
+       kf51=\EO3R,
+       kf52=\EO3S,
+       kf53=\E[15;3~,
+       kf54=\E[17;3~,
+       kf55=\E[18;3~,
+       kf56=\E[19;3~,
+       kf57=\E[20;3~,
+       kf58=\E[21;3~,
+       kf59=\E[23;3~,
+       kf6=\E[17~,
+       kf60=\E[24;3~,
+       kf61=\EO4P,
+       kf62=\EO4Q,
+       kf63=\EO4R,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+
+# This is almost the same as xterm+pcf2 because the unmodified keys all happen
+# to have a pattern that forces the modifier to the same position.
+xterm+pcf1|fragment with modifyFunctionKeys:1,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\E[2P,
+       kf14=\E[2Q,
+       kf15=\E[2R,
+       kf16=\E[2S,
+       kf17=\E[15;2~,
+       kf18=\E[17;2~,
+       kf19=\E[18;2~,
+       kf2=\EOQ,
+       kf20=\E[19;2~,
+       kf21=\E[20;2~,
+       kf22=\E[21;2~,
+       kf23=\E[23;2~,
+       kf24=\E[24;2~,
+       kf25=\E[5P,
+       kf26=\E[5Q,
+       kf27=\E[5R,
+       kf28=\E[5S,
+       kf29=\E[15;5~,
+       kf3=\EOR,
+       kf30=\E[17;5~,
+       kf31=\E[18;5~,
+       kf32=\E[19;5~,
+       kf33=\E[20;5~,
+       kf34=\E[21;5~,
+       kf35=\E[23;5~,
+       kf36=\E[24;5~,
+       kf37=\E[6P,
+       kf38=\E[6Q,
+       kf39=\E[6R,
+       kf4=\EOS,
+       kf40=\E[6S,
+       kf41=\E[15;6~,
+       kf42=\E[17;6~,
+       kf43=\E[18;6~,
+       kf44=\E[19;6~,
+       kf45=\E[20;6~,
+       kf46=\E[21;6~,
+       kf47=\E[23;6~,
+       kf48=\E[24;6~,
+       kf49=\E[3P,
+       kf5=\E[15~,
+       kf50=\E[3Q,
+       kf51=\E[3R,
+       kf52=\E[3S,
+       kf53=\E[15;3~,
+       kf54=\E[17;3~,
+       kf55=\E[18;3~,
+       kf56=\E[19;3~,
+       kf57=\E[20;3~,
+       kf58=\E[21;3~,
+       kf59=\E[23;3~,
+       kf6=\E[17~,
+       kf60=\E[24;3~,
+       kf61=\E[4P,
+       kf62=\E[4Q,
+       kf63=\E[4R,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+
+xterm+pcf2|fragment with modifyFunctionKeys:2,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\E[1;2P,
+       kf14=\E[1;2Q,
+       kf15=\E[1;2R,
+       kf16=\E[1;2S,
+       kf17=\E[15;2~,
+       kf18=\E[17;2~,
+       kf19=\E[18;2~,
+       kf2=\EOQ,
+       kf20=\E[19;2~,
+       kf21=\E[20;2~,
+       kf22=\E[21;2~,
+       kf23=\E[23;2~,
+       kf24=\E[24;2~,
+       kf25=\E[1;5P,
+       kf26=\E[1;5Q,
+       kf27=\E[1;5R,
+       kf28=\E[1;5S,
+       kf29=\E[15;5~,
+       kf3=\EOR,
+       kf30=\E[17;5~,
+       kf31=\E[18;5~,
+       kf32=\E[19;5~,
+       kf33=\E[20;5~,
+       kf34=\E[21;5~,
+       kf35=\E[23;5~,
+       kf36=\E[24;5~,
+       kf37=\E[1;6P,
+       kf38=\E[1;6Q,
+       kf39=\E[1;6R,
+       kf4=\EOS,
+       kf40=\E[1;6S,
+       kf41=\E[15;6~,
+       kf42=\E[17;6~,
+       kf43=\E[18;6~,
+       kf44=\E[19;6~,
+       kf45=\E[20;6~,
+       kf46=\E[21;6~,
+       kf47=\E[23;6~,
+       kf48=\E[24;6~,
+       kf49=\E[1;3P,
+       kf5=\E[15~,
+       kf50=\E[1;3Q,
+       kf51=\E[1;3R,
+       kf52=\E[1;3S,
+       kf53=\E[15;3~,
+       kf54=\E[17;3~,
+       kf55=\E[18;3~,
+       kf56=\E[19;3~,
+       kf57=\E[20;3~,
+       kf58=\E[21;3~,
+       kf59=\E[23;3~,
+       kf6=\E[17~,
+       kf60=\E[24;3~,
+       kf61=\E[1;4P,
+       kf62=\E[1;4Q,
+       kf63=\E[1;4R,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+
+xterm+pcf3|fragment with modifyFunctionKeys:3,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\E[>1;2P,
+       kf14=\E[>1;2Q,
+       kf15=\E[>1;2R,
+       kf16=\E[>1;2S,
+       kf17=\E[>15;2~,
+       kf18=\E[>17;2~,
+       kf19=\E[>18;2~,
+       kf2=\EOQ,
+       kf20=\E[>19;2~,
+       kf21=\E[>20;2~,
+       kf22=\E[>21;2~,
+       kf23=\E[>23;2~,
+       kf24=\E[>24;2~,
+       kf25=\E[>1;5P,
+       kf26=\E[>1;5Q,
+       kf27=\E[>1;5R,
+       kf28=\E[>1;5S,
+       kf29=\E[>15;5~,
+       kf3=\EOR,
+       kf30=\E[>17;5~,
+       kf31=\E[>18;5~,
+       kf32=\E[>19;5~,
+       kf33=\E[>20;5~,
+       kf34=\E[>21;5~,
+       kf35=\E[>23;5~,
+       kf36=\E[>24;5~,
+       kf37=\E[>1;6P,
+       kf38=\E[>1;6Q,
+       kf39=\E[>1;6R,
+       kf4=\EOS,
+       kf40=\E[>1;6S,
+       kf41=\E[>15;6~,
+       kf42=\E[>17;6~,
+       kf43=\E[>18;6~,
+       kf44=\E[>19;6~,
+       kf45=\E[>20;6~,
+       kf46=\E[>21;6~,
+       kf47=\E[>23;6~,
+       kf48=\E[>24;6~,
+       kf49=\E[>1;3P,
+       kf5=\E[15~,
+       kf50=\E[>1;3Q,
+       kf51=\E[>1;3R,
+       kf52=\E[>1;3S,
+       kf53=\E[>15;3~,
+       kf54=\E[>17;3~,
+       kf55=\E[>18;3~,
+       kf56=\E[>19;3~,
+       kf57=\E[>20;3~,
+       kf58=\E[>21;3~,
+       kf59=\E[>23;3~,
+       kf6=\E[17~,
+       kf60=\E[>24;3~,
+       kf61=\E[>1;4P,
+       kf62=\E[>1;4Q,
+       kf63=\E[>1;4R,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+#
+# The "PC-style" modifier scheme was introduced in xterm patch #94 (1999/3/27)
+# and revised in patch #167 (2002/8/24).
+#
+# The original assignments from patch #94 for cursor-keys had some technical
+# issues:
+#
+#      A parameter for a function-key to represent a modifier is just more
+#      bits.  But for a cursor-key it may change the behavior of the
+#      application.  For instance, emacs decodes the first parameter of a
+#      cursor-key as a repeat count.
+#
+#      A parameterized string should (really) not begin with SS3 (\EO).
+#      Rather, CSI (\E[) should be used.
+#
+# For these reasons, the original assignments were deprecated.  For
+# compatibility reasons, they are still available as a setting of xterm's
+# modifyCursorKeys resource.  These fragments list the modified cursor-keys
+# that might apply to xterm+pcfkeys with different values of that resource.
+xterm+pcc3|fragment with modifyCursorKeys:3,
+       kLFT=\E[>1;2D,
+       kRIT=\E[>1;2C,
+       kind=\E[>1;2B,
+       kri=\E[>1;2A,
+       kDN=\E[>1;2B,
+       kDN3=\E[>1;3B,
+       kDN4=\E[>1;4B,
+       kDN5=\E[>1;5B,
+       kDN6=\E[>1;6B,
+       kDN7=\E[>1;7B,
+       kLFT3=\E[>1;3D,
+       kLFT4=\E[>1;4D,
+       kLFT5=\E[>1;5D,
+       kLFT6=\E[>1;6D,
+       kLFT7=\E[>1;7D,
+       kRIT3=\E[>1;3C,
+       kRIT4=\E[>1;4C,
+       kRIT5=\E[>1;5C,
+       kRIT6=\E[>1;6C,
+       kRIT7=\E[>1;7C,
+       kUP=\E[>1;2A,
+       kUP3=\E[>1;3A,
+       kUP4=\E[>1;4A,
+       kUP5=\E[>1;5A,
+       kUP6=\E[>1;6A,
+       kUP7=\E[>1;7A,
+
+xterm+pcc2|fragment with modifyCursorKeys:2,
+       kLFT=\E[1;2D,
+       kRIT=\E[1;2C,
+       kind=\E[1;2B,
+       kri=\E[1;2A,
+       kDN=\E[1;2B,
+       kDN3=\E[1;3B,
+       kDN4=\E[1;4B,
+       kDN5=\E[1;5B,
+       kDN6=\E[1;6B,
+       kDN7=\E[1;7B,
+       kLFT3=\E[1;3D,
+       kLFT4=\E[1;4D,
+       kLFT5=\E[1;5D,
+       kLFT6=\E[1;6D,
+       kLFT7=\E[1;7D,
+       kRIT3=\E[1;3C,
+       kRIT4=\E[1;4C,
+       kRIT5=\E[1;5C,
+       kRIT6=\E[1;6C,
+       kRIT7=\E[1;7C,
+       kUP=\E[1;2A,
+       kUP3=\E[1;3A,
+       kUP4=\E[1;4A,
+       kUP5=\E[1;5A,
+       kUP6=\E[1;6A,
+       kUP7=\E[1;7A,
+
+xterm+pcc1|fragment with modifyCursorKeys:1,
+       kLFT=\E[2D,
+       kRIT=\E[2C,
+       kind=\E[2B,
+       kri=\E[2A,
+       kDN=\E[2B,
+       kDN3=\E[3B,
+       kDN4=\E[4B,
+       kDN5=\E[5B,
+       kDN6=\E[6B,
+       kDN7=\E[7B,
+       kLFT3=\E[3D,
+       kLFT4=\E[4D,
+       kLFT5=\E[5D,
+       kLFT6=\E[6D,
+       kLFT7=\E[7D,
+       kRIT3=\E[3C,
+       kRIT4=\E[4C,
+       kRIT5=\E[5C,
+       kRIT6=\E[6C,
+       kRIT7=\E[7C,
+       kUP=\E[2A,
+       kUP3=\E[3A,
+       kUP4=\E[4A,
+       kUP5=\E[5A,
+       kUP6=\E[6A,
+       kUP7=\E[7A,
+
+xterm+pcc0|fragment with modifyCursorKeys:0,
+       kLFT=\EO2D,
+       kRIT=\EO2C,
+       kind=\EO2B,
+       kri=\EO2A,
+       kDN=\EO2B,
+       kDN3=\EO3B,
+       kDN4=\EO4B,
+       kDN5=\EO5B,
+       kDN6=\EO6B,
+       kDN7=\EO7B,
+       kLFT3=\EO3D,
+       kLFT4=\EO4D,
+       kLFT5=\EO5D,
+       kLFT6=\EO6D,
+       kLFT7=\EO7D,
+       kRIT3=\EO3C,
+       kRIT4=\EO4C,
+       kRIT5=\EO5C,
+       kRIT6=\EO6C,
+       kRIT7=\EO7C,
+       kUP=\EO2A,
+       kUP3=\EO3A,
+       kUP4=\EO4A,
+       kUP5=\EO5A,
+       kUP6=\EO6A,
+       kUP7=\EO7A,
+
+# The home/end keys on the editing keypad are also treated as cursor keys.
+xterm+pce3|fragment with modifyCursorKeys:3,
+       kDC=\E[>3;2~,
+       kEND=\E[>1;2F,
+       kHOM=\E[>1;2H,
+       kIC=\E[>2;2~,
+       kNXT=\E[>6;2~,
+       kPRV=\E[>5;2~,
+       kDC3=\E[>3;3~,
+       kDC4=\E[>3;4~,
+       kDC5=\E[>3;5~,
+       kDC6=\E[>3;6~,
+       kDC7=\E[>3;7~,
+       kEND3=\E[>1;3F,
+       kEND4=\E[>1;4F,
+       kEND5=\E[>1;5F,
+       kEND6=\E[>1;6F,
+       kEND7=\E[>1;7F,
+       kHOM3=\E[>1;3H,
+       kHOM4=\E[>1;4H,
+       kHOM5=\E[>1;5H,
+       kHOM6=\E[>1;6H,
+       kHOM7=\E[>1;7H,
+       kIC3=\E[>2;3~,
+       kIC4=\E[>2;4~,
+       kIC5=\E[>2;5~,
+       kIC6=\E[>2;6~,
+       kIC7=\E[>2;7~,
+       kNXT3=\E[>6;3~,
+       kNXT4=\E[>6;4~,
+       kNXT5=\E[>6;5~,
+       kNXT6=\E[>6;6~,
+       kNXT7=\E[>6;7~,
+       kPRV3=\E[>5;3~,
+       kPRV4=\E[>5;4~,
+       kPRV5=\E[>5;5~,
+       kPRV6=\E[>5;6~,
+       kPRV7=\E[>5;7~,
+       use=xterm+pce0,
+
+xterm+pce2|fragment with modifyCursorKeys:2,
+       kDC=\E[3;2~,
+       kEND=\E[1;2F,
+       kHOM=\E[1;2H,
+       kIC=\E[2;2~,
+       kNXT=\E[6;2~,
+       kPRV=\E[5;2~,
+       kDC3=\E[3;3~,
+       kDC4=\E[3;4~,
+       kDC5=\E[3;5~,
+       kDC6=\E[3;6~,
+       kDC7=\E[3;7~,
+       kEND3=\E[1;3F,
+       kEND4=\E[1;4F,
+       kEND5=\E[1;5F,
+       kEND6=\E[1;6F,
+       kEND7=\E[1;7F,
+       kHOM3=\E[1;3H,
+       kHOM4=\E[1;4H,
+       kHOM5=\E[1;5H,
+       kHOM6=\E[1;6H,
+       kHOM7=\E[1;7H,
+       kIC3=\E[2;3~,
+       kIC4=\E[2;4~,
+       kIC5=\E[2;5~,
+       kIC6=\E[2;6~,
+       kIC7=\E[2;7~,
+       kNXT3=\E[6;3~,
+       kNXT4=\E[6;4~,
+       kNXT5=\E[6;5~,
+       kNXT6=\E[6;6~,
+       kNXT7=\E[6;7~,
+       kPRV3=\E[5;3~,
+       kPRV4=\E[5;4~,
+       kPRV5=\E[5;5~,
+       kPRV6=\E[5;6~,
+       kPRV7=\E[5;7~,
+       use=xterm+pce0,
+
+xterm+pce1|fragment with modifyCursorKeys:1,
+       kDC=\E[3;2~,
+       kEND=\E[2F,
+       kHOM=\E[2H,
+       kIC=\E[2;2~,
+       kNXT=\E[6;2~,
+       kPRV=\E[5;2~,
+       kDC3=\E[3;3~,
+       kDC4=\E[3;4~,
+       kDC5=\E[3;5~,
+       kDC6=\E[3;6~,
+       kDC7=\E[3;7~,
+       kEND3=\E[3F,
+       kEND4=\E[4F,
+       kEND5=\E[5F,
+       kEND6=\E[6F,
+       kEND7=\E[7F,
+       kHOM3=\E[3H,
+       kHOM4=\E[4H,
+       kHOM5=\E[5H,
+       kHOM6=\E[6H,
+       kHOM7=\E[7H,
+       kIC3=\E[2;3~,
+       kIC4=\E[2;4~,
+       kIC5=\E[2;5~,
+       kIC6=\E[2;6~,
+       kIC7=\E[2;7~,
+       kNXT3=\E[6;3~,
+       kNXT4=\E[6;4~,
+       kNXT5=\E[6;5~,
+       kNXT6=\E[6;6~,
+       kNXT7=\E[6;7~,
+       kPRV3=\E[5;3~,
+       kPRV4=\E[5;4~,
+       kPRV5=\E[5;5~,
+       kPRV6=\E[5;6~,
+       kPRV7=\E[5;7~,
+       use=xterm+pce0,
+
+xterm+pce0|fragment with modifyCursorKeys:0,
+       kDC=\E[3;2~,
+       kEND=\EO2F,
+       kHOM=\EO2H,
+       kIC=\E[2;2~,
+       kNXT=\E[6;2~,
+       kPRV=\E[5;2~,
+       kDC3=\E[3;3~,
+       kDC4=\E[3;4~,
+       kDC5=\E[3;5~,
+       kDC6=\E[3;6~,
+       kDC7=\E[3;7~,
+       kEND3=\EO3F,
+       kEND4=\EO4F,
+       kEND5=\EO5F,
+       kEND6=\EO6F,
+       kEND7=\EO7F,
+       kHOM3=\EO3H,
+       kHOM4=\EO4H,
+       kHOM5=\EO5H,
+       kHOM6=\EO6H,
+       kHOM7=\EO7H,
+       kIC3=\E[2;3~,
+       kIC4=\E[2;4~,
+       kIC5=\E[2;5~,
+       kIC6=\E[2;6~,
+       kIC7=\E[2;7~,
+       kNXT3=\E[6;3~,
+       kNXT4=\E[6;4~,
+       kNXT5=\E[6;5~,
+       kNXT6=\E[6;6~,
+       kNXT7=\E[6;7~,
+       kPRV3=\E[5;3~,
+       kPRV4=\E[5;4~,
+       kPRV5=\E[5;5~,
+       kPRV6=\E[5;6~,
+       kPRV7=\E[5;7~,
+       use=xterm+edit,
+#
+# This chunk is used for building the VT220/Sun/PC keyboard variants.
+xterm-basic|modern xterm terminal emulator - common,
+       OTbs,
+       am,
+       bce,
+       km,
+       mc5i,
+       mir,
+       msgr,
+       xenl,
+       AX,
+       colors#8,
+       cols#80,
+       it#8,
+       lines#24,
+       pairs#64,
+       acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+       bel=^G,
+       blink=\E[5m,
+       bold=\E[1m,
+       cbt=\E[Z,
+       civis=\E[?25l,
+       clear=\E[H\E[2J,
+       cnorm=\E[?12l\E[?25h,
+       cr=^M,
+       csr=\E[%i%p1%d;%p2%dr,
+       cub=\E[%p1%dD,
+       cub1=^H,
+       cud=\E[%p1%dB,
+       cud1=^J,
+       cuf=\E[%p1%dC,
+       cuf1=\E[C,
+       cup=\E[%i%p1%d;%p2%dH,
+       cuu=\E[%p1%dA,
+       cuu1=\E[A,
+       cvvis=\E[?12;25h,
+       dch=\E[%p1%dP,
+       dch1=\E[P,
+       dl=\E[%p1%dM,
+       dl1=\E[M,
+       ech=\E[%p1%dX,
+       ed=\E[J,
+       el=\E[K,
+       el1=\E[1K,
+       flash=\E[?5h$<100/>\E[?5l,
+       home=\E[H,
+       hpa=\E[%i%p1%dG,
+       ht=^I,
+       hts=\EH,
+       ich=\E[%p1%d@,
+       il=\E[%p1%dL,
+       il1=\E[L,
+       ind=^J,
+       invis=\E[8m,
+       is2=\E[!p\E[?3;4l\E[4l\E>,
+       kbs=^H,
+       kmous=\E[M,
+       mc0=\E[i,
+       mc4=\E[4i,
+       mc5=\E[5i,
+       meml=\El,
+       memu=\Em,
+       op=\E[39;49m,
+       rc=\E8,
+       rev=\E[7m,
+       ri=\EM,
+       rmacs=\E(B,
+       rmam=\E[?7l,
+       rmcup=\E[?1049l,
+       rmir=\E[4l,
+       rmkx=\E[?1l\E>,
+       rmm=\E[?1034l,
+       rmso=\E[27m,
+       rmul=\E[24m,
+       rs1=\Ec,
+       rs2=\E[!p\E[?3;4l\E[4l\E>,
+       sc=\E7,
+       setab=\E[4%p1%dm,
+       setaf=\E[3%p1%dm,
+       setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+       setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+       sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
+       sgr0=\E(B\E[m,
+       smacs=\E(0,
+       smam=\E[?7h,
+       smcup=\E[?1049h,
+       smir=\E[4h,
+       smkx=\E[?1h\E=,
+       smm=\E[?1034h,
+       smso=\E[7m,
+       smul=\E[4m,
+       tbc=\E[3g,
+       u6=\E[%i%d;%dR,
+       u7=\E[6n,
+       u8=\E[?1;2c,
+       u9=\E[c,
+       vpa=\E[%i%p1%dd,
+#
+# The xterm-new description has all of the features, but is not completely
+# compatible with vt220.  If you are using a Sun or PC keyboard, set the
+# sunKeyboard resource to true:
+#      + maps the editing keypad
+#      + interprets control-function-key as a second array of keys, so a
+#        12-fkey keyboard can support vt220's 20-fkeys.
+#      + maps numeric keypad "+" to ",".
+#      + uses DEC-style control sequences for the application keypad.
+#
+# Some packagers modify xterm's resource definitions to provide extra function
+# keys by using the shift-modifier in the translations resource.  However, that
+# interferes with the DECUDK functionality.
+#
+xterm-vt220|xterm emulating vt220,
+       ka1=\EOw,
+       ka3=\EOy,
+       kb2=\EOu,
+       kc1=\EOq,
+       kc3=\EOs,
+       kcbt=\E[Z,
+       kend=\E[4~,
+       kent=\EOM,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\E[25~,
+       kf14=\E[26~,
+       kf15=\E[28~,
+       kf16=\E[29~,
+       kf17=\E[31~,
+       kf18=\E[32~,
+       kf19=\E[33~,
+       kf2=\EOQ,
+       kf20=\E[34~,
+       kf3=\EOR,
+       kf4=\EOS,
+       kf5=\E[15~,
+       kf6=\E[17~,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+       khome=\E[1~,
+       kich1=\E[2~,
+       knp=\E[6~,
+       kpp=\E[5~,
+       ka2=\EOx,
+       kb1=\EOt,
+       kb3=\EOv,
+       kc2=\EOr,
+       use=xterm+app,
+       use=xterm+edit,
+       use=xterm-basic,
+#
+xterm-vt52|xterm emulating dec vt52,
+       cols#80,
+       it#8,
+       lines#24,
+       acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+       bel=^G,
+       clear=\EH\EJ,
+       cr=^M,
+       cub1=\ED,
+       cud1=\EB,
+       cuf1=\EC,
+       cup=\EY%p1%' '%+%c%p2%' '%+%c,
+       cuu1=\EA,
+       ed=\EJ,
+       el=\EK,
+       home=\EH,
+       ht=^I,
+       ind=^J,
+       kbs=^H,
+       kcub1=\ED,
+       kcud1=\EB,
+       kcuf1=\EC,
+       kcuu1=\EA,
+       nel=^M^J,
+       ri=\EI,
+       rmacs=\EG,
+       smacs=\EF,
+#
+# Sun does not number the function keys this way in their sparse termcap; their
+# terminal descriptions ignore the keypads.  kb(7M) states that there are codes
+# reserved for 64 function keys, 16 each in left, right, top and bottom.  Each
+# keyboard type has a different number of function keys in different
+# arrangements.  Using xkeycaps for reference:
+#
+# Type 3:  left 10, top 9, right 15
+# ------
+# kf1-kf9 are XK_F1-XK_F9
+# There is no kf10 on this keyboard type.
+# kf11-kf20 are keysyms XK_L1 through XK_L10.
+# kf31-kf45 are keysyms XK_R1 through XK_R15.
+#
+# However, X's keysymdef.h is hard-coded to make
+#      XK_L1==XK_F11 and
+#      XK_R1==XK_F21,
+# by someone who was unfamiliar with terminal types other than Sun's.  So
+# xterm uses the internal X keysymbols, but the terminfo entry uses the Sun
+# numbering scheme.
+#
+# Type 4:  left 11, top 12, right 15
+# ------
+# The left-keypad contains an unnumbered Help-key.
+# The right-keypad also contains NumLock, Ins, Del, Enter, + and - keys which
+# do not appear to be part of the R-sequence.
+#
+# Type 5:  left 9, top 12, right (more than one keypad)
+# ------
+# These keyboards do not use the same naming convention, look like a hybrid of
+# the type 4 and IBM keyboards.
+#
+# XTerm resources:
+# ---------------
+# Set the modifyFunctionKeys resource to negative (-1) to make it simple to
+# enter the higher function-key values using shift- and control-modifiers.
+#
+xterm-sun|xterm with sun function keys,
+       kb2=\E[218z,
+       kcpy=\E[197z,
+       kcub1=\EOD,
+       kcud1=\EOB,
+       kcuf1=\EOC,
+       kcuu1=\EOA,
+       kdch1=\E[3z,
+       kend=\E[220z,
+       kent=\EOM,
+       kf1=\E[224z,
+       kf10=\E[233z,
+       kf11=\E[192z,
+       kf12=\E[193z,
+       kf13=\E[194z,
+       kf14=\E[195z,
+       kf15=\E[196z,
+       kf17=\E[198z,
+       kf18=\E[199z,
+       kf19=\E[200z,
+       kf2=\E[225z,
+       kf20=\E[201z,
+       kf3=\E[226z,
+       kf31=\E[208z,
+       kf32=\E[209z,
+       kf33=\E[210z,
+       kf34=\E[211z,
+       kf35=\E[212z,
+       kf36=\E[213z,
+       kf38=\E[215z,
+       kf4=\E[227z,
+       kf40=\E[217z,
+       kf42=\E[219z,
+       kf44=\E[221z,
+       kf45=\E[222z,
+       kf46=\E[234z,
+       kf47=\E[235z,
+       kf5=\E[228z,
+       kf6=\E[229z,
+       kf7=\E[230z,
+       kf8=\E[231z,
+       kf9=\E[232z,
+       kfnd=\E[200z,
+       khlp=\E[196z,
+       khome=\E[214z,
+       kich1=\E[2z,
+       knp=\E[222z,
+       kpp=\E[216z,
+       kund=\E[195z,
+       use=xterm-basic,
+#
+xterm-hp|xterm with hpterm function keys,
+       kclr=\EJ,
+       kcub1=\ED,
+       kcud1=\EB,
+       kcuf1=\EC,
+       kcuu1=\EA,
+       kdch1=\EP,
+       kend=\EF,
+       kf1=\Ep,
+       kf2=\Eq,
+       kf3=\Er,
+       kf4=\Es,
+       kf5=\Et,
+       kf6=\Eu,
+       kf7=\Ev,
+       kf8=\Ew,
+       khome=\Eh,
+       kich1=\EQ,
+       knp=\ES,
+       kpp=\ET,
+       use=xterm-basic,
+#
+# scoterm implements 48 function-keys using shift- and control-modifiers to
+# multiple 12 function-keys.  X has a hard-coded limit of 35 function-keys,
+# but xterm can represent larger values.
+#
+# XTerm resources:
+# ---------------
+# Set the modifyFunctionKeys resource to negative (-1) to make it simple to
+# enter the higher function-key values using shift- and control-modifiers.
+#
+# Also, set ctrlFKeys resource to 12 (the default is 10) to make xterm see 48
+# function-keys on a keyboard with 12 function-keys and 4 control/shift
+# modifier combinations.
+#
+xterm-sco|xterm with SCO function keys,
+       kbeg=\E[E,
+       kdch1=\177,
+       kf1=\E[M,
+       kf10=\E[V,
+       kf11=\E[W,
+       kf12=\E[X,
+       kf13=\E[Y,
+       kf14=\E[Z,
+       kf15=\E[a,
+       kf16=\E[b,
+       kf17=\E[c,
+       kf18=\E[d,
+       kf19=\E[e,
+       kf2=\E[N,
+       kf20=\E[f,
+       kf21=\E[g,
+       kf22=\E[h,
+       kf23=\E[i,
+       kf24=\E[j,
+       kf25=\E[k,
+       kf26=\E[l,
+       kf27=\E[m,
+       kf28=\E[n,
+       kf29=\E[o,
+       kf3=\E[O,
+       kf30=\E[p,
+       kf31=\E[q,
+       kf32=\E[r,
+       kf33=\E[s,
+       kf34=\E[t,
+       kf35=\E[u,
+       kf36=\E[v,
+       kf37=\E[w,
+       kf38=\E[x,
+       kf39=\E[y,
+       kf4=\E[P,
+       kf40=\E[z,
+       kf41=\E[@,
+       kf42=\E[[,
+       kf43=\E[\\,
+       kf44=\E[],
+       kf45=\E[\^,
+       kf46=\E[_,
+       kf47=\E[`,
+       kf48=\E[{,
+       kf5=\E[Q,
+       kf6=\E[R,
+       kf7=\E[S,
+       kf8=\E[T,
+       kf9=\E[U,
+       kich1=\E[L,
+       kmous=\E[>M,
+       knp=\E[G,
+       kpp=\E[I,
+       use=xterm+noapp,
+       use=xterm-basic,
+#
+# Other variants (these are all very old entries, from X11R5):
+xterm-24|xterms|vs100|xterm terminal emulator (X Window System),
+       lines#24,
+       use=xterm-old,
+xterm-65|xterm with tall window 65x80 (X Window System),
+       lines#65,
+       use=xterm-old,
+xterm-bold|xterm with bold instead of underline (X Window System),
+       smso=\E[7m,
+       smul=\E[1m,
+       use=xterm-old,
+xterm-boldso|xterm with bold for standout (X Window System),
+       rmso=\E[m,
+       smso=\E[1m,
+       use=xterm-old,
+xterm-mono|monochrome xterm,
+       bce@,
+       colors@,
+       ncv@,
+       pairs@,
+       op@,
+       setab@,
+       setaf@,
+       setb@,
+       setf@,
+       sgr@,
+       use=xterm-old,
+#
+# VTxxx terminals are usually set up so that full-screen applications will use
+# the cursor application mode strings.  This is good for full-screen
+# applications, including legacy applications which may have hard-coded
+# behavior, but bad for interactive shells (e.g., tcsh, bash) which use arrow
+# keys to scroll through a history of command strings.
+#
+# To see the difference between normal/application modes, consider this example:
+#      + In normal (non-application) mode, the terminal transmits a down-arrow
+#        as \E[C, which happens to echo as a down-arrow.
+#      + In application mode the terminal transmits \EOC, which echoes as C.
+#        That is because the \EO is the SS3 control, which says to use the
+#        character from the G3 character set for the next cell.
+#
+# One example of hard-coded behavior would be for applications written to work
+# with VT52 and VT100 terminals.  If the application's parser ignores 'O' and
+# '?' characters after the escape, then the cursor and keypad strings for the
+# two terminals are the same.  (Indeed, one of the first curses applications
+# which I used did something like this to cover "ANSI" terminals -TD).
+#
+# To make this work (leaving the cursor keys in normal mode), we have to adjust
+# the terminal initialization sequences:
+#
+#      smkx/rmkx set/reset the cursor and keypad application modes.  We retain
+#              the latter (otherwise many applications fail).
+#
+#      smcup/rmcup set/restore cursor-addressing mode for full-screen
+#              applications.  For xterm, this normally means the alternate
+#              screen, which is not compatible with interactive shells.  Some
+#              programs are "smart" and disable these.
+#
+xterm-noapp|xterm with cursor keys in normal mode,
+       rmcup@,
+       rmkx=\E>,
+       smcup@,
+       smkx=\E=,
+       use=xterm+noapp,
+       use=xterm,
+
+xterm+noapp|fragment with cursor keys in normal mode,
+       kcub1=\E[D,
+       kcud1=\E[B,
+       kcuf1=\E[C,
+       kcuu1=\E[A,
+       use=xterm+noapp+pc,
+
+xterm+app|fragment with cursor keys in application mode,
+       kcub1=\EOD,
+       kcud1=\EOB,
+       kcuf1=\EOC,
+       kcuu1=\EOA,
+       use=xterm+app+pc,
+
+xterm+noapp+pc|fragment for noapp pc-style home/end,
+       kend=\E[F,
+       khome=\E[H,
+
+xterm+app+pc|fragment for app pc-style home/end,
+       kend=\EOF,
+       khome=\EOH,
+
+xterm+edit|fragment for 6-key editing-keypad,
+       kdch1=\E[3~,
+       kich1=\E[2~,
+       knp=\E[6~,
+       kpp=\E[5~,
+       use=xterm+pc+edit,
+
+xterm+decedit|fragment for vt220 6-key editing-keypad,
+       kdch1=\E[3~,
+       kich1=\E[2~,
+       knp=\E[6~,
+       kpp=\E[5~,
+       use=xterm+vt+edit,
+
+xterm+pc+edit|fragment for pc-style editing keypad,
+       kend=\E[4~,
+       khome=\E[1~,
+
+xterm+vt+edit|fragment for vt220-style editing keypad,
+       kfnd=\E[1~,
+       kslt=\E[4~,
+
+#
+# This should work for the commonly used "color xterm" variations (XFree86
+# xterm, color_xterm, nxterm, rxvt).  Note that it does not set 'bce', so for
+# XFree86 and and rxvt, some applications that use colors will be less
+# efficient, and in a few special cases (with "smart" optimization) the wrong
+# color will be painted in spots.
+xterm-color|generic "ANSI" color xterm (X Window System),
+       colors#8,
+       ncv@,
+       pairs#64,
+       op=\E[m,
+       setab=\E[4%p1%dm,
+       setaf=\E[3%p1%dm,
+       use=xterm-r6,
+#
+# vi may work better with this entry, because vi
+# doesn't use insert mode much
+xterm-ic|xterm-vi|xterm with insert character instead of insert mode,
+       mir@,
+       ich=\E[%p1%d@,
+       ich1=\E[@,
+       rmir@,
+       smir@,
+       use=xterm,
+#
+# This is used only for testing (it's not relevant to DEC VTxxx terminals, but
+# to ncurses).
+xterm-xmc|xterm with magic-cookie glitch,
+       xmc#1,
+       use=xterm-new,
+#
+# This one also is primarily for testing ncurses; while the ISO 6429 defines
+# the REP control, none of the DEC VTxxx terminals (VT52 through VT420) support
+# it.
+xterm-rep|xterm with repeat-character control,
+       rep=%p1%c\E[%p2%{1}%-%db,
+       use=xterm-new,
+#
+# This is mainly for testing xterm; the real VT220 will not let you switch
+# character sets without first altering the keyboard language in the setup
+# screen.  Some emulators allow this anyway.  (Note that these strings are
+# normally used only for printers).  The parameter to csnm and scs is the same
+# in both cases:  the keyboard language parameter returned by CSI ? 2 6 n.
+xterm-nrc|xterm with VT220 national replacement character sets,
+       csnm=%?%p1%{1}%=%tNorth American%e%p1%{2}%=%tBritish%e%p1%{3}%=%tFlemish%e%p1%{4}%=%tFrench Canadian%e%p1%{5}%=%tDanish%e%p1%{6}%=%tFinnish%e%p1%{7}%=%tGerman%e%p1%{8}%=%tDutch%e%p1%{9}%=%tItalian%e%p1%{10}%=%tSwiss (French)%e%p1%{11}%=%tSwiss (German)%e%p1%{12}%=%tSwedish%e%p1%{13}%=%tNorwegian%e%p1%{14}%=%tFrench/Belgian%e%p1%{15}%=%tSpanish%;,
+       scs=%?%p1%{1}%=%t\E(B%e%p1%{2}%=%t\E(A%e%p1%{3}%=%t\E(R%e%p1%{4}%=%t\E(9%e%p1%{5}%=%t\E(E%e%p1%{6}%=%t\E(5%e%p1%{7}%=%t\E(K%e%p1%{8}%=%t\E(4%e%p1%{9}%=%t\E(Y%e%p1%{10}%=%t\E(=%e%p1%{11}%=%t\E(=%e%p1%{12}%=%t\E(7%e%p1%{13}%=%t\E(E%e%p1%{14}%=%t\E(R%e%p1%{15}%=%t\E(Z%;,
+       use=xterm-new,
+#
+# Foreground 0-15 maps (with toggles) into 30-37 & 90-97
+# Background 0-15 maps (with toggles) into 40-47 & 100-107
+#
+# Originally I suppressed setaf/setab, since ANSI specifies only 8 colors, but
+# Stephen Marley persuaded me to allow the "ANSI" color controls to extend to
+# 16 colors.  (Note that ncurses 4.2 uses setf/setb from this description;
+# however 5.0 selects either according to their availability).  - T.Dickey
+#
+# SVr4 curses does not use more than 8 colors anyway, so using 16 colors is
+# either for terminfo-level applications or via ncurses.
+xterm-16color|xterm with 16 colors,
+       colors#16,
+       pairs#256,
+       setab=\E[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm,
+       setaf=\E[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm,
+       setb=%p1%{8}%/%{6}%*%{4}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m,
+       setf=%p1%{8}%/%{6}%*%{3}%+\E[%d%p1%{8}%m%Pa%?%ga%{1}%=%t4%e%ga%{3}%=%t6%e%ga%{4}%=%t1%e%ga%{6}%=%t3%e%ga%d%;m,
+       use=xterm-new,
+#
+# This uses RGB values 0..1000
+#
+# 256 colors should give 65536 pairs, but terminfo stores numbers in a signed
+# short.  Most people will not notice problems with only 32767 pairs.
+xterm-256color|xterm with 256 colors,
+       ccc,
+       colors#256,
+       pairs#32767,
+       initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
+       setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
+       setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
+       setb@,
+       setf@,
+       use=xterm-new,
+xterm-88color|xterm with 88 colors,
+       colors#88,
+       pairs#7744,
+       use=xterm-256color,
+#
+# This is an 8-bit version of xterm, which emulates DEC vt220 with ANSI color.
+# To use it, your decTerminalID resource must be set to 200 or above, and the
+# sunKeyboard resource set to true.
+#
+#      HTS     \E H    \210
+#      RI      \E M    \215
+#      SS3     \E O    \217
+#      CSI     \E [    \233
+#
+xterm-8bit|xterm terminal emulator with 8-bit controls (X Window System),
+       OTbs,
+       am,
+       bce,
+       km,
+       mc5i,
+       mir,
+       msgr,
+       npc,
+       xenl,
+       AX,
+       colors#8,
+       cols#80,
+       it#8,
+       lines#24,
+       pairs#64,
+       acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+       bel=^G,
+       blink=\2335m,
+       bold=\2331m,
+       cbt=\233Z,
+       civis=\233?25l,
+       clear=\233H\2332J,
+       cnorm=\233?25l\233?25h,
+       cr=^M,
+       csr=\233%i%p1%d;%p2%dr,
+       cub=\233%p1%dD,
+       cub1=^H,
+       cud=\233%p1%dB,
+       cud1=^J,
+       cuf=\233%p1%dC,
+       cuf1=\233C,
+       cup=\233%i%p1%d;%p2%dH,
+       cuu=\233%p1%dA,
+       cuu1=\233A,
+       cvvis=\233?12;25h,
+       dch=\233%p1%dP,
+       dch1=\233P,
+       dl=\233%p1%dM,
+       dl1=\233M,
+       ech=\233%p1%dX,
+       ed=\233J,
+       el=\233K,
+       el1=\2331K,
+       flash=\233?5h$<100/>\233?5l,
+       home=\233H,
+       hpa=\233%i%p1%dG,
+       ht=^I,
+       hts=\210,
+       ich=\233%p1%d@,
+       il=\233%p1%dL,
+       il1=\233L,
+       ind=^J,
+       invis=\2338m,
+       is2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8,
+       ka1=\217w,
+       ka3=\217u,
+       kb2=\217y,
+       kbeg=\217E,
+       kbs=^H,
+       kc1=\217q,
+       kc3=\217s,
+       kcbt=\233Z,
+       kcub1=\217D,
+       kcud1=\217B,
+       kcuf1=\217C,
+       kcuu1=\217A,
+       kdch1=\2333~,
+       kend=\2334~,
+       kent=\217M,
+       kf1=\23311~,
+       kf10=\23321~,
+       kf11=\23323~,
+       kf12=\23324~,
+       kf13=\23325~,
+       kf14=\23326~,
+       kf15=\23328~,
+       kf16=\23329~,
+       kf17=\23331~,
+       kf18=\23332~,
+       kf19=\23333~,
+       kf2=\23312~,
+       kf20=\23334~,
+       kf3=\23313~,
+       kf4=\23314~,
+       kf5=\23315~,
+       kf6=\23317~,
+       kf7=\23318~,
+       kf8=\23319~,
+       kf9=\23320~,
+       khome=\2331~,
+       kich1=\2332~,
+       kmous=\233M,
+       knp=\2336~,
+       kpp=\2335~,
+       mc0=\233i,
+       mc4=\2334i,
+       mc5=\2335i,
+       meml=\El,
+       memu=\Em,
+       op=\23339;49m,
+       rc=\E8,
+       rev=\2337m,
+       ri=\215,
+       rmacs=\E(B,
+       rmam=\233?7l,
+       rmcup=\233?1049l,
+       rmir=\2334l,
+       rmkx=\233?1l\E>,
+       rmso=\23327m,
+       rmul=\23324m,
+       rs1=\Ec,
+       rs2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8,
+       sc=\E7,
+       setab=\2334%p1%dm,
+       setaf=\2333%p1%dm,
+       setb=\2334%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+       setf=\2333%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+       sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
+       sgr0=\2330m\E(B,
+       smacs=\E(0,
+       smam=\233?7h,
+       smcup=\233?1049h,
+       smir=\2334h,
+       smkx=\233?1h\E=,
+       smso=\2337m,
+       smul=\2334m,
+       tbc=\2333g,
+       u6=\233[%i%d;%dR,
+       u7=\E[6n,
+       u8=\233[?1;2c,
+       u9=\E[c,
+       vpa=\233%i%p1%dd,
+#
+xterm-xf86-v44|xterm terminal emulator (XFree86 4.4 Window System),
+       OTbs,
+       am,
+       bce,
+       km,
+       mc5i,
+       mir,
+       msgr,
+       npc,
+       xenl,
+       AX,
+       colors#8,
+       cols#80,
+       it#8,
+       lines#24,
+       pairs#64,
+       acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+       bel=^G,
+       blink=\E[5m,
+       bold=\E[1m,
+       cbt=\E[Z,
+       civis=\E[?25l,
+       clear=\E[H\E[2J,
+       cnorm=\E[?12l\E[?25h,
+       cr=^M,
+       csr=\E[%i%p1%d;%p2%dr,
+       cub=\E[%p1%dD,
+       cub1=^H,
+       cud=\E[%p1%dB,
+       cud1=^J,
+       cuf=\E[%p1%dC,
+       cuf1=\E[C,
+       cup=\E[%i%p1%d;%p2%dH,
+       cuu=\E[%p1%dA,
+       cuu1=\E[A,
+       cvvis=\E[?12;25h,
+       dch=\E[%p1%dP,
+       dch1=\E[P,
+       dl=\E[%p1%dM,
+       dl1=\E[M,
+       ech=\E[%p1%dX,
+       ed=\E[J,
+       el=\E[K,
+       el1=\E[1K,
+       enacs=\E(B\E)0,
+       flash=\E[?5h$<100/>\E[?5l,
+       home=\E[H,
+       hpa=\E[%i%p1%dG,
+       ht=^I,
+       hts=\EH,
+       ich=\E[%p1%d@,
+       il=\E[%p1%dL,
+       il1=\E[L,
+       ind=^J,
+       indn=\E[%p1%dS,
+       invis=\E[8m,
+       is2=\E[!p\E[?3;4l\E[4l\E>,
+       kDC=\E[3;2~,
+       kEND=\E[1;2F,
+       kHOM=\E[1;2H,
+       kIC=\E[2;2~,
+       kLFT=\E[1;2D,
+       kNXT=\E[6;2~,
+       kPRV=\E[5;2~,
+       kRIT=\E[1;2C,
+       kb2=\EOE,
+       kbs=^H,
+       kcbt=\E[Z,
+       kcub1=\EOD,
+       kcud1=\EOB,
+       kcuf1=\EOC,
+       kcuu1=\EOA,
+       kdch1=\E[3~,
+       kend=\EOF,
+       kent=\EOM,
+       kf1=\EOP,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\EO2P,
+       kf14=\EO2Q,
+       kf15=\EO2R,
+       kf16=\EO2S,
+       kf17=\E[15;2~,
+       kf18=\E[17;2~,
+       kf19=\E[18;2~,
+       kf2=\EOQ,
+       kf20=\E[19;2~,
+       kf21=\E[20;2~,
+       kf22=\E[21;2~,
+       kf23=\E[23;2~,
+       kf24=\E[24;2~,
+       kf25=\EO5P,
+       kf26=\EO5Q,
+       kf27=\EO5R,
+       kf28=\EO5S,
+       kf29=\E[15;5~,
+       kf3=\EOR,
+       kf30=\E[17;5~,
+       kf31=\E[18;5~,
+       kf32=\E[19;5~,
+       kf33=\E[20;5~,
+       kf34=\E[21;5~,
+       kf35=\E[23;5~,
+       kf36=\E[24;5~,
+       kf37=\EO6P,
+       kf38=\EO6Q,
+       kf39=\EO6R,
+       kf4=\EOS,
+       kf40=\EO6S,
+       kf41=\E[15;6~,
+       kf42=\E[17;6~,
+       kf43=\E[18;6~,
+       kf44=\E[19;6~,
+       kf45=\E[20;6~,
+       kf46=\E[21;6~,
+       kf47=\E[23;6~,
+       kf48=\E[24;6~,
+       kf5=\E[15~,
+       kf6=\E[17~,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+       khome=\EOH,
+       kich1=\E[2~,
+       kmous=\E[M,
+       knp=\E[6~,
+       kpp=\E[5~,
+       mc0=\E[i,
+       mc4=\E[4i,
+       mc5=\E[5i,
+       meml=\El,
+       memu=\Em,
+       op=\E[39;49m,
+       rc=\E8,
+       rev=\E[7m,
+       ri=\EM,
+       rin=\E[%p1%dT,
+       rmacs=^O,
+       rmam=\E[?7l,
+       rmcup=\E[?1049l,
+       rmir=\E[4l,
+       rmkx=\E[?1l\E>,
+       rmso=\E[27m,
+       rmul=\E[24m,
+       rs1=\Ec,
+       rs2=\E[!p\E[?3;4l\E[4l\E>,
+       sc=\E7,
+       setab=\E[4%p1%dm,
+       setaf=\E[3%p1%dm,
+       setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+       setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+       sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
+       sgr0=\E[m\017,
+       smacs=^N,
+       smam=\E[?7h,
+       smcup=\E[?1049h,
+       smir=\E[4h,
+       smkx=\E[?1h\E=,
+       smso=\E[7m,
+       smul=\E[4m,
+       tbc=\E[3g,
+       u6=\E[%i%d;%dR,
+       u7=\E[6n,
+       u8=\E[?1;2c,
+       u9=\E[c,
+       vpa=\E[%i%p1%dd,
+       ka2=\EOx,
+       kb1=\EOt,
+       kb3=\EOv,
+       kc2=\EOr,
+xterm-xfree86|xterm terminal emulator (XFree86 4.4 Window System),
+       use=xterm-xf86-v44,
+#
+# Compatible with the R6 xterm, with the following changes:
+#      + added acsc (perhaps some versions of tic assume the standard vt100
+#        alternate character set)
+#      + added u6, u7, u8, u9 strings for Daniel Weaver's tack program.
+#      + added kmous string for ncurses.
+#      + added khome/kend strings (which conflict with kfnd/kslt, see note).
+xterm-r6|xterm-old|xterm X11R6 version,
+       OTbs,
+       am,
+       km,
+       mir,
+       msgr,
+       xenl,
+       cols#80,
+       it#8,
+       lines#24,
+       acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+       bel=^G,
+       bold=\E[1m,
+       clear=\E[H\E[2J,
+       cr=^M,
+       csr=\E[%i%p1%d;%p2%dr,
+       cub=\E[%p1%dD,
+       cub1=^H,
+       cud=\E[%p1%dB,
+       cud1=^J,
+       cuf=\E[%p1%dC,
+       cuf1=\E[C,
+       cup=\E[%i%p1%d;%p2%dH,
+       cuu=\E[%p1%dA,
+       cuu1=\E[A,
+       dch=\E[%p1%dP,
+       dch1=\E[P,
+       dl=\E[%p1%dM,
+       dl1=\E[M,
+       ed=\E[J,
+       el=\E[K,
+       enacs=\E)0,
+       home=\E[H,
+       ht=^I,
+       hts=\EH,
+       il=\E[%p1%dL,
+       il1=\E[L,
+       ind=^J,
+       is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
+       kbs=^H,
+       kcub1=\EOD,
+       kcud1=\EOB,
+       kcuf1=\EOC,
+       kcuu1=\EOA,
+       kdch1=\E[3~,
+       kf1=\E[11~,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf13=\E[25~,
+       kf14=\E[26~,
+       kf15=\E[28~,
+       kf16=\E[29~,
+       kf17=\E[31~,
+       kf18=\E[32~,
+       kf19=\E[33~,
+       kf2=\E[12~,
+       kf20=\E[34~,
+       kf3=\E[13~,
+       kf4=\E[14~,
+       kf5=\E[15~,
+       kf6=\E[17~,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+       kmous=\E[M,
+       meml=\El,
+       memu=\Em,
+       rc=\E8,
+       rev=\E[7m,
+       ri=\EM,
+       rmacs=^O,
+       rmcup=\E[2J\E[?47l\E8,
+       rmir=\E[4l,
+       rmkx=\E[?1l\E>,
+       rmso=\E[m,
+       rmul=\E[m,
+       rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
+       sc=\E7,
+       sgr0=\E[m,
+       smacs=^N,
+       smcup=\E7\E[?47h,
+       smir=\E[4h,
+       smkx=\E[?1h\E=,
+       smso=\E[7m,
+       smul=\E[4m,
+       tbc=\E[3g,
+       u6=\E[%i%d;%dR,
+       u7=\E[6n,
+       u8=\E[?1;2c,
+       u9=\E[c,
+       use=xterm+decedit,
+#
+# Compatible with the R5 xterm, with the following changes:
+#      + changed 'blink=@', to 'blink@' (the former meant that "@" would start
+#        a blink, the latter that it is not supported).
+#      + changed kf1 through kf4 to correspond with actual usage.  Though X
+#        supports keypad symbols for PF1 to PF4, and xterm interprets these
+#        correctly, the F1 to F4 codes are commonly (but incorrectly) used.
+#      + moved reset string from rs1 to rs2, to correlate better with termcap.
+#      + make khome consistent with other entries.
+#      + use rmul/smul, rmir/smir from termcap, but not rmcup/smcup because
+#        not everyone wants the alternate screen.
+#      + added u6, u7, u8, u9 strings for Daniel Weaver's tack program.
+#      + added kmous string for ncurses.
+xterm-r5|xterm R5 version,
+       OTbs,
+       am,
+       km,
+       msgr,
+       xenl,
+       cols#80,
+       it#8,
+       lines#24,
+       bel=^G,
+       bold=\E[1m,
+       clear=\E[H\E[2J,
+       cr=^M,
+       csr=\E[%i%p1%d;%p2%dr,
+       cub=\E[%p1%dD,
+       cub1=^H,
+       cud=\E[%p1%dB,
+       cud1=^J,
+       cuf=\E[%p1%dC,
+       cuf1=\E[C,
+       cup=\E[%i%p1%d;%p2%dH,
+       cuu=\E[%p1%dA,
+       cuu1=\E[A,
+       dch=\E[%p1%dP,
+       dch1=\E[P,
+       dl=\E[%p1%dM,
+       dl1=\E[M,
+       ed=\E[J,
+       el=\E[K,
+       home=\E[H,
+       ht=^I,
+       hts=\EH,
+       ich=\E[%p1%d@,
+       ich1=\E[@,
+       il=\E[%p1%dL,
+       il1=\E[L,
+       ind=^J,
+       kbs=^H,
+       kcub1=\EOD,
+       kcud1=\EOB,
+       kcuf1=\EOC,
+       kcuu1=\EOA,
+       kdch1=\E[3~,
+       kdl1=\E[31~,
+       kel=\E[8~,
+       kend=\E[4~,
+       kf0=\EOq,
+       kf1=\E[11~,
+       kf10=\E[21~,
+       kf11=\E[23~,
+       kf12=\E[24~,
+       kf2=\E[12~,
+       kf3=\E[13~,
+       kf4=\E[14~,
+       kf5=\E[15~,
+       kf6=\E[17~,
+       kf7=\E[18~,
+       kf8=\E[19~,
+       kf9=\E[20~,
+       khome=\E[1~,
+       kich1=\E[2~,
+       kil1=\E[30~,
+       kmous=\E[M,
+       knp=\E[6~,
+       kpp=\E[5~,
+       rc=\E8,
+       rev=\E[7m,
+       ri=\EM,
+       rmir=\E[4l,
+       rmkx=\E[?1l\E>,
+       rmso=\E[m,
+       rmul=\E[m,
+       rs2=\E>\E[?1;3;4;5;6l\E[4l\E[?7h\E[m\E[r\E[2J\E[H,
+       sc=\E7,
+       sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;m,
+       sgr0=\E[m,
+       smir=\E[4h,
+       smkx=\E[?1h\E=,
+       smso=\E[7m,
+       smul=\E[4m,
+       tbc=\E[3g,
+       u6=\E[%i%d;%dR,
+       u7=\E[6n,
+       u8=\E[?1;2c,
+       u9=\E[c,
+#
+#
+# Customization begins here.
+#
+# This is the only entry which you should have to customize, since "xterm"
+# is widely used for a variety of incompatible terminal emulations including
+# color_xterm and rxvt.
+xterm|X11 terminal emulator,
+       use=xterm-new,
+#      use=xterm-r6,
diff --git a/testxmc.c b/testxmc.c
new file mode 100644 (file)
index 0000000..44e4919
--- /dev/null
+++ b/testxmc.c
@@ -0,0 +1,229 @@
+/* $XTermId: testxmc.c,v 1.47 2010/04/17 17:11:33 tom Exp $ */
+
+/************************************************************
+
+Copyright 1997-2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+/*
+ * This module provides test support for curses applications that must work
+ * with terminals that have the xmc (magic cookie) glitch.  The xmc_glitch
+ * resource denotes the number of spaces that are emitted when switching to or
+ * from standout (reverse) mode.  Some terminals implement this by storing the
+ * attribute controls in the character cell that is skipped.  So if the cell is
+ * overwritten by text, then the attribute change in the cell is cancelled,
+ * causing attributes to the left of the change to propagate.
+ *
+ * We implement the glitch by writing a character that won't be mistaken for
+ * other normal characters (and mapping normal writes to that character to a
+ * different one).
+ *
+ * Since xmc isn't normally part of xterm, we document it here rather than in
+ * the man-page.  This module is driven by resources rather than by the
+ * termcap/terminfo description to make it a little more flexible for testing
+ * purposes.
+ *
+ * Resources:
+ *
+ * xmcGlitch (class XmcGlitch)
+ *     When true, enables this extension.  The default is `0', which disables
+ *     the module.  (termcap sg, terminfo xmc).
+ *
+ * xmcAttributes (class XmcAttributes)
+ *     The attributes for which we'll generate a glitch, as a bitmask.
+ *
+ *             INVERSE         1
+ *             UNDERLINE       2
+ *             BOLD            4
+ *             BLINK           8
+ *
+ *     The default is `1' (INVERSE).  Some terminals emit glitches for
+ *     underline.  Just for completeness, we recognize all of the video
+ *     attributes.
+ *
+ * xmcInline (class XmcInline)
+ *     When true, limits the extent of an SGR change to the current line.
+ *     The default is `false'.  (No termcap or terminfo equivalent, though
+ *     there are comments in some entries relating to this issue).
+ *
+ * xmcMoveSGR (class XmcMoveSGR)
+ *     When false, a cursor movement will leave a glitch when SGR's are
+ *     active.  The default is `true'.  (termcap ms, terminfo msgr).
+ *
+ * TODO:
+ *     When xmc is active, the terminfo max_attributes (ma) capability is
+ *     assumed to be 1.
+ *
+ *     The xmcAttributes resource should also apply to alternate character
+ *     sets and to color.
+ */
+
+#include <xterm.h>
+#include <data.h>
+
+#define MARK_ON(a)  (Bool) ((my_attrs & a) != 0 && (xw->flags & (whichone = CharOf(a))) == 0)
+#define MARK_OFF(a) (Bool) ((my_attrs & a) != 0 && (xw->flags & (whichone = CharOf(a))) != 0)
+
+void
+Mark_XMC(XtermWidget xw, int param)
+{
+    static IChar *glitch;
+
+    TScreen *screen = TScreenOf(xw);
+    Bool found = False;
+    unsigned my_attrs = CharOf(screen->xmc_attributes & XMC_FLAGS);
+    unsigned whichone = 0;
+
+    if (glitch == 0) {
+       unsigned len = screen->xmc_glitch;
+       glitch = TypeMallocN(IChar, len);
+       while (len--)
+           glitch[len] = XMC_GLITCH;
+    }
+    switch (param) {
+    case -1:                   /* DEFAULT */
+    case 0:                    /* FALLTHRU */
+       found = MARK_OFF((xw->flags & XMC_FLAGS));
+       break;
+    case 1:
+       found = MARK_ON(BOLD);
+       break;
+    case 4:
+       found = MARK_ON(UNDERLINE);
+       break;
+    case 5:
+       found = MARK_ON(BLINK);
+       break;
+    case 7:
+       found = MARK_ON(INVERSE);
+       break;
+    case 22:
+       found = MARK_OFF(BOLD);
+       break;
+    case 24:
+       found = MARK_OFF(UNDERLINE);
+       break;
+    case 25:
+       found = MARK_OFF(BLINK);
+       break;
+    case 27:
+       found = MARK_OFF(INVERSE);
+       break;
+    }
+
+    /*
+     * Write a glitch with the attributes temporarily set to the new(er)
+     * ones.
+     */
+    if (found) {
+       unsigned save = xw->flags;
+       xw->flags ^= whichone;
+       TRACE(("XMC Writing glitch (%d/%d) after SGR %d\n", my_attrs,
+              whichone, param));
+       dotext(xw, '?', glitch, screen->xmc_glitch);
+       xw->flags = save;
+    }
+}
+
+/*
+ * Force a glitch on cursor movement when we're in standout mode and not at the
+ * end of a line.
+ */
+void
+Jump_XMC(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    if (!screen->move_sgr_ok
+       && screen->cur_col <= LineMaxCol(screen,
+                                        getLineData(screen, screen->cur_row))) {
+       Mark_XMC(xw, -1);
+    }
+}
+
+/*
+ * After writing text to the screen, resolve mismatch between the current
+ * location and any attributes that would have been set by preceding locations.
+ */
+void
+Resolve_XMC(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    Bool changed = False;
+    Char start;
+    Char my_attrs = CharOf(screen->xmc_attributes & XMC_FLAGS);
+    int row = screen->cur_row;
+    int col = screen->cur_col;
+
+    /* Find the preceding cell.
+     */
+    ld = getLineData(screen, row);
+    if (ld->charData[col] != XMC_GLITCH) {
+       if (col != 0) {
+           col--;
+       } else if (!screen->xmc_inline && row != 0) {
+           ld = getLineData(screen, --row);
+           col = LineMaxCol(screen, ld);
+       }
+    }
+    start = (ld->attribs[col] & my_attrs);
+
+    /* Now propagate the starting state until we reach a cell which holds
+     * a glitch.
+     */
+    for (;;) {
+       if (col < LineMaxCol(screen, ld)) {
+           col++;
+       } else if (!screen->xmc_inline && row < screen->max_row) {
+           col = 0;
+           ld = getLineData(screen, ++row);
+       } else
+           break;
+       if (ld->charData[col] == XMC_GLITCH)
+           break;
+       if ((ld->attribs[col] & my_attrs) != start) {
+           ld->attribs[col] =
+               CharOf(start | (ld->attribs[col] & ~my_attrs));
+           changed = True;
+       }
+    }
+
+    TRACE(("XMC %s (%s:%d/%d) from %d,%d to %d,%d\n",
+          changed ? "Ripple" : "Nochange",
+          BtoS(xw->flags & my_attrs),
+          my_attrs, start,
+          screen->cur_row, screen->cur_col,
+          row, col));
+
+    if (changed) {
+       ScrnUpdate(xw, screen->cur_row, 0, row + 1 - screen->cur_row,
+                  MaxCols(screen), True);
+    }
+}
diff --git a/trace.c b/trace.c
new file mode 100644 (file)
index 0000000..4a60aa6
--- /dev/null
+++ b/trace.c
@@ -0,0 +1,845 @@
+/* $XTermId: trace.c,v 1.119 2011/02/09 10:04:50 tom Exp $ */
+
+/*
+ * Copyright 1997-2010,2011 by Thomas E. Dickey
+ * 
+ *                         All Rights Reserved
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ * 
+ */
+
+/*
+ * debugging support via TRACE macro.
+ */
+
+#include <xterm.h>             /* for definition of GCC_UNUSED */
+
+#if OPT_TRACE
+
+#include <data.h>
+#include <trace.h>
+
+#include <time.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include <X11/Xatom.h>
+#include <X11/Xmu/Atoms.h>
+
+#ifdef HAVE_X11_TRANSLATEI_H
+#include <X11/TranslateI.h>
+#else
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    extern String _XtPrintXlations(Widget w,
+                                  XtTranslations xlations,
+                                  Widget accelWidget,
+                                  _XtBoolean includeRHS);
+#ifdef __cplusplus
+}
+#endif
+#endif
+const char *trace_who = "parent";
+
+static FILE *trace_fp;
+
+void
+Trace(const char *fmt,...)
+{
+    static const char *trace_out;
+    va_list ap;
+
+    if (trace_fp != 0
+       && trace_who != trace_out) {
+       fclose(trace_fp);
+       trace_fp = 0;
+    }
+    trace_out = trace_who;
+
+    if (!trace_fp) {
+       char name[BUFSIZ];
+#if 0                          /* usually I do not want unique names */
+       int unique;
+       for (unique = 0;; ++unique) {
+           if (unique)
+               sprintf(name, "Trace-%s.out-%d", trace_who, unique);
+           else
+               sprintf(name, "Trace-%s.out", trace_who);
+           if ((trace_fp = fopen(name, "r")) == 0) {
+               break;
+           }
+           fclose(trace_fp);
+       }
+#else
+       sprintf(name, "Trace-%s.out", trace_who);
+#endif
+       trace_fp = fopen(name, "w");
+       if (trace_fp != 0) {
+           fprintf(trace_fp, "%s\n", xtermVersion());
+           TraceIds(NULL, 0);
+       }
+    }
+    if (!trace_fp)
+       abort();
+
+    va_start(ap, fmt);
+    vfprintf(trace_fp, fmt, ap);
+    (void) fflush(trace_fp);
+    va_end(ap);
+}
+
+void
+TraceClose(void)
+{
+    if (trace_fp != 0) {
+       (void) fclose(trace_fp);
+       (void) fflush(stdout);
+       (void) fflush(stderr);
+       (void) visibleChars(NULL, 0);
+       (void) visibleIChars(NULL, 0);
+       (void) visibleIChar(NULL, 0);
+       trace_fp = 0;
+    }
+}
+
+void
+TraceIds(const char *fname, int lnum)
+{
+    Trace("process %d ", (int) getpid());
+#ifdef HAVE_UNISTD_H
+    Trace("real (%u/%u) effective (%u/%u)",
+         (unsigned) getuid(), (unsigned) getgid(),
+         (unsigned) geteuid(), (unsigned) getegid());
+#endif
+    if (fname != 0) {
+       Trace(" (%s@%d)\n", fname, lnum);
+    } else {
+       time_t now = time((time_t *) 0);
+       Trace("-- %s", ctime(&now));
+    }
+}
+
+static void
+formatAscii(char *dst, unsigned value)
+{
+    switch (value) {
+    case '\\':
+       sprintf(dst, "\\\\");
+       break;
+    case '\b':
+       sprintf(dst, "\\b");
+       break;
+    case '\n':
+       sprintf(dst, "\\n");
+       break;
+    case '\r':
+       sprintf(dst, "\\r");
+       break;
+    case '\t':
+       sprintf(dst, "\\t");
+       break;
+    default:
+       if (E2A(value) < 32 || (E2A(value) >= 127 && E2A(value) < 160))
+           sprintf(dst, "\\%03o", value);
+       else
+           sprintf(dst, "%c", CharOf(value));
+       break;
+    }
+}
+
+#if OPT_DEC_CHRSET
+
+const char *
+visibleChrsetName(unsigned chrset)
+{
+    const char *result = "?";
+    switch (chrset) {
+    case CSET_SWL:
+       result = "CSET_SWL";
+       break;
+    case CSET_DHL_TOP:
+       result = "CSET_DHL_TOP";
+       break;
+    case CSET_DHL_BOT:
+       result = "CSET_DHL_BOT";
+       break;
+    case CSET_DWL:
+       result = "CSET_DWL";
+       break;
+    }
+    return result;
+}
+#endif
+
+char *
+visibleChars(const Char * buf, unsigned len)
+{
+    static char *result;
+    static unsigned used;
+
+    if (buf != 0) {
+       unsigned limit = ((len + 1) * 8) + 1;
+       char *dst;
+
+       if (limit > used) {
+           used = limit;
+           result = XtRealloc(result, used);
+       }
+       if (result != 0) {
+           dst = result;
+           *dst = '\0';
+           while (len--) {
+               unsigned value = *buf++;
+               formatAscii(dst, value);
+               dst += strlen(dst);
+           }
+       }
+    } else if (result != 0) {
+       free(result);
+       result = 0;
+       used = 0;
+    }
+    return result;
+}
+
+char *
+visibleIChars(IChar * buf, unsigned len)
+{
+    static char *result;
+    static unsigned used;
+
+    if (buf != 0) {
+       unsigned limit = ((len + 1) * 8) + 1;
+       char *dst;
+
+       if (limit > used) {
+           used = limit;
+           result = XtRealloc(result, used);
+       }
+       if (result != 0) {
+           dst = result;
+           *dst = '\0';
+           while (len--) {
+               unsigned value = *buf++;
+#if OPT_WIDE_CHARS
+               if (value > 255)
+                   sprintf(dst, "\\u+%04X", value);
+               else
+#endif
+                   formatAscii(dst, value);
+               dst += strlen(dst);
+           }
+       }
+    } else if (result != 0) {
+       free(result);
+       result = 0;
+       used = 0;
+    }
+    return result;
+}
+
+char *
+visibleIChar(IChar * buf, unsigned len)
+{
+    static char *result;
+    static unsigned used;
+
+    if (buf != 0) {
+       unsigned limit = ((len + 1) * 8) + 1;
+       char *dst;
+
+       if (limit > used) {
+           used = limit;
+           result = XtRealloc(result, used);
+       }
+       if (result != 0) {
+           dst = result;
+           while (len--) {
+               unsigned value = *buf++;
+#if OPT_WIDE_CHARS
+               if (value > 255)
+                   sprintf(dst, "\\u+%04X", value);
+               else
+#endif
+                   formatAscii(dst, value);
+               dst += strlen(dst);
+           }
+       }
+    } else if (result != 0) {
+       free(result);
+       result = 0;
+       used = 0;
+    }
+    return result;
+}
+
+#define CASETYPE(name) case name: result = #name; break
+
+const char *
+visibleKeyboardType(xtermKeyboardType type)
+{
+    const char *result = "?";
+    switch (type) {
+       CASETYPE(keyboardIsLegacy);     /* bogus vt220 codes for F1-F4, etc. */
+       CASETYPE(keyboardIsDefault);
+       CASETYPE(keyboardIsHP);
+       CASETYPE(keyboardIsSCO);
+       CASETYPE(keyboardIsSun);
+       CASETYPE(keyboardIsTermcap);
+       CASETYPE(keyboardIsVT220);
+    }
+    return result;
+}
+
+const char *
+visibleEventType(int type)
+{
+    const char *result = "?";
+    switch (type) {
+       CASETYPE(KeyPress);
+       CASETYPE(KeyRelease);
+       CASETYPE(ButtonPress);
+       CASETYPE(ButtonRelease);
+       CASETYPE(MotionNotify);
+       CASETYPE(EnterNotify);
+       CASETYPE(LeaveNotify);
+       CASETYPE(FocusIn);
+       CASETYPE(FocusOut);
+       CASETYPE(KeymapNotify);
+       CASETYPE(Expose);
+       CASETYPE(GraphicsExpose);
+       CASETYPE(NoExpose);
+       CASETYPE(VisibilityNotify);
+       CASETYPE(CreateNotify);
+       CASETYPE(DestroyNotify);
+       CASETYPE(UnmapNotify);
+       CASETYPE(MapNotify);
+       CASETYPE(MapRequest);
+       CASETYPE(ReparentNotify);
+       CASETYPE(ConfigureNotify);
+       CASETYPE(ConfigureRequest);
+       CASETYPE(GravityNotify);
+       CASETYPE(ResizeRequest);
+       CASETYPE(CirculateNotify);
+       CASETYPE(CirculateRequest);
+       CASETYPE(PropertyNotify);
+       CASETYPE(SelectionClear);
+       CASETYPE(SelectionRequest);
+       CASETYPE(SelectionNotify);
+       CASETYPE(ColormapNotify);
+       CASETYPE(ClientMessage);
+       CASETYPE(MappingNotify);
+    }
+    return result;
+}
+
+const char *
+visibleNotifyDetail(int code)
+{
+    const char *result = "?";
+    switch (code) {
+       CASETYPE(NotifyAncestor);
+       CASETYPE(NotifyVirtual);
+       CASETYPE(NotifyInferior);
+       CASETYPE(NotifyNonlinear);
+       CASETYPE(NotifyNonlinearVirtual);
+       CASETYPE(NotifyPointer);
+       CASETYPE(NotifyPointerRoot);
+       CASETYPE(NotifyDetailNone);
+    }
+    return result;
+}
+
+const char *
+visibleSelectionTarget(Display * d, Atom a)
+{
+    const char *result = "?";
+
+    if (a == XA_STRING) {
+       result = "XA_STRING";
+    } else if (a == XA_TEXT(d)) {
+       result = "XA_TEXT()";
+    } else if (a == XA_COMPOUND_TEXT(d)) {
+       result = "XA_COMPOUND_TEXT()";
+    } else if (a == XA_UTF8_STRING(d)) {
+       result = "XA_UTF8_STRING()";
+    } else if (a == XA_TARGETS(d)) {
+       result = "XA_TARGETS()";
+    }
+
+    return result;
+}
+
+const char *
+visibleXError(int code)
+{
+    static char temp[80];
+    const char *result = "?";
+    switch (code) {
+       CASETYPE(Success);
+       CASETYPE(BadRequest);
+       CASETYPE(BadValue);
+       CASETYPE(BadWindow);
+       CASETYPE(BadPixmap);
+       CASETYPE(BadAtom);
+       CASETYPE(BadCursor);
+       CASETYPE(BadFont);
+       CASETYPE(BadMatch);
+       CASETYPE(BadDrawable);
+       CASETYPE(BadAccess);
+       CASETYPE(BadAlloc);
+       CASETYPE(BadColor);
+       CASETYPE(BadGC);
+       CASETYPE(BadIDChoice);
+       CASETYPE(BadName);
+       CASETYPE(BadLength);
+       CASETYPE(BadImplementation);
+    default:
+       sprintf(temp, "%d", code);
+       result = temp;
+       break;
+    }
+    return result;
+}
+
+#if OPT_TRACE_FLAGS
+#define isScrnFlag(flag) ((flag) == LINEWRAPPED)
+
+static char *
+ScrnText(LineData * ld)
+{
+    return visibleIChars(ld->charData, ld->lineSize);
+}
+
+#define SHOW_BAD_LINE(name, ld) \
+       Trace("OOPS " #name " bad row\n")
+
+#define SHOW_SCRN_FLAG(name,code) \
+       Trace(#name " %s:%s\n", \
+             code ? "*" : "", \
+             ScrnText(ld))
+
+void
+LineClrFlag(LineData * ld, int flag)
+{
+    if (ld == 0) {
+       SHOW_BAD_LINE(LineClrFlag, ld);
+       assert(0);
+    } else if (isScrnFlag(flag)) {
+       SHOW_SCRN_FLAG(LineClrFlag, 0);
+    }
+
+    LineFlags(ld) &= ~flag;
+}
+
+void
+LineSetFlag(LineData * ld, int flag)
+{
+    if (ld == 0) {
+       SHOW_BAD_LINE(LineSetFlag, ld);
+       assert(0);
+    } else if (isScrnFlag(flag)) {
+       SHOW_SCRN_FLAG(LineSetFlag, 1);
+    }
+
+    LineFlags(ld) |= flag;
+}
+
+int
+LineTstFlag(LineData ld, int flag)
+{
+    int code = 0;
+    if (ld == 0) {
+       SHOW_BAD_LINE(LineTstFlag, ld);
+    } else {
+       code = LineFlags(ld);
+
+       if (isScrnFlag(flag)) {
+           SHOW_SCRN_FLAG(LineTstFlag, code);
+       }
+    }
+    return code;
+}
+#endif /* OPT_TRACE_FLAGS */
+
+void
+TraceFocus(Widget w, XEvent * ev)
+{
+    TRACE(("trace_focus event type %d:%s\n",
+          ev->type, visibleEventType(ev->type)));
+    switch (ev->type) {
+    case FocusIn:
+    case FocusOut:
+       {
+           XFocusChangeEvent *event = (XFocusChangeEvent *) ev;
+           TRACE(("\tdetail: %s\n", visibleNotifyDetail(event->detail)));
+           TRACE(("\tmode:   %d\n", event->mode));
+           TRACE(("\twindow: %#lx\n", event->window));
+       }
+       break;
+    case EnterNotify:
+    case LeaveNotify:
+       {
+           XCrossingEvent *event = (XCrossingEvent *) ev;
+           TRACE(("\tdetail:    %s\n", visibleNotifyDetail(event->detail)));
+           TRACE(("\tmode:      %d\n", event->mode));
+           TRACE(("\twindow:    %#lx\n", event->window));
+           TRACE(("\troot:      %#lx\n", event->root));
+           TRACE(("\tsubwindow: %#lx\n", event->subwindow));
+       }
+       break;
+    }
+    while (w != 0) {
+       TRACE(("w %p -> %#lx\n", (void *) w, XtWindow(w)));
+       w = XtParent(w);
+    }
+}
+
+void
+TraceSizeHints(XSizeHints * hints)
+{
+    TRACE(("size hints:\n"));
+    if (hints->flags & (USPosition | PPosition))
+       TRACE(("   position   %d,%d%s%s\n", hints->y, hints->x,
+              hints->flags & USPosition ? " user" : "",
+              hints->flags & PPosition ? " prog" : ""));
+    if (hints->flags & (USSize | PSize))
+       TRACE(("   size       %d,%d%s%s\n", hints->height, hints->width,
+              hints->flags & USSize ? " user" : "",
+              hints->flags & PSize ? " prog" : ""));
+    if (hints->flags & PMinSize)
+       TRACE(("   min        %d,%d\n", hints->min_height, hints->min_width));
+    if (hints->flags & PMaxSize)
+       TRACE(("   max        %d,%d\n", hints->max_height, hints->max_width));
+    if (hints->flags & PResizeInc)
+       TRACE(("   inc        %d,%d\n", hints->height_inc, hints->width_inc));
+    else
+       TRACE(("   inc        NONE!\n"));
+    if (hints->flags & PAspect)
+       TRACE(("   min aspect %d/%d\n", hints->min_aspect.y, hints->min_aspect.y));
+    if (hints->flags & PAspect)
+       TRACE(("   max aspect %d/%d\n", hints->max_aspect.y, hints->max_aspect.y));
+    if (hints->flags & PBaseSize)
+       TRACE(("   base       %d,%d\n", hints->base_height, hints->base_width));
+    if (hints->flags & PWinGravity)
+       TRACE(("   gravity    %d\n", hints->win_gravity));
+}
+
+void
+TraceWMSizeHints(XtermWidget xw)
+{
+    XSizeHints sizehints = xw->hints;
+
+    getXtermSizeHints(xw);
+    TraceSizeHints(&xw->hints);
+    xw->hints = sizehints;
+}
+
+/*
+ * Some calls to XGetAtom() will fail, and we don't want to stop.  So we use
+ * our own error-handler.
+ */
+/* ARGSUSED */
+static int
+no_error(Display * dpy GCC_UNUSED, XErrorEvent * event GCC_UNUSED)
+{
+    return 1;
+}
+
+void
+TraceTranslations(const char *name, Widget w)
+{
+    String result;
+    XErrorHandler save = XSetErrorHandler(no_error);
+    XtTranslations xlations;
+    Widget xcelerat;
+
+    TRACE(("TraceTranslations for %s (widget %#lx) {{\n", name, (long) w));
+    if (w) {
+       XtVaGetValues(w,
+                     XtNtranslations, &xlations,
+                     XtNaccelerators, &xcelerat,
+                     (XtPointer) 0);
+       TRACE(("... xlations %#08lx\n", (long) xlations));
+       TRACE(("... xcelerat %#08lx\n", (long) xcelerat));
+       result = _XtPrintXlations(w, xlations, xcelerat, True);
+       TRACE(("%s\n", NonNull(result)));
+       if (result)
+           XFree((char *) result);
+    } else {
+       TRACE(("none (widget is null)\n"));
+    }
+    TRACE(("}}\n"));
+    XSetErrorHandler(save);
+}
+
+int
+TraceResizeRequest(const char *fn, int ln, Widget w,
+                  Dimension reqwide,
+                  Dimension reqhigh,
+                  Dimension * gotwide,
+                  Dimension * gothigh)
+{
+    int rc;
+
+    TRACE(("%s@%d ResizeRequest %dx%d\n", fn, ln, reqhigh, reqwide));
+    rc = XtMakeResizeRequest((Widget) w, reqwide, reqhigh, gotwide, gothigh);
+    TRACE(("... ResizeRequest -> "));
+    if (gothigh && gotwide)
+       TRACE(("%dx%d ", *gothigh, *gotwide));
+    TRACE(("(%d)\n", rc));
+    return rc;
+}
+
+#define XRES_S(name) Trace(#name " = %s\n", NonNull(resp->name))
+#define XRES_B(name) Trace(#name " = %s\n", BtoS(resp->name))
+#define XRES_I(name) Trace(#name " = %d\n", resp->name)
+
+void
+TraceXtermResources(void)
+{
+    XTERM_RESOURCE *resp = &resource;
+
+    Trace("XTERM_RESOURCE settings:\n");
+    XRES_S(xterm_name);
+    XRES_S(icon_geometry);
+    XRES_S(title);
+    XRES_S(icon_name);
+    XRES_S(term_name);
+    XRES_S(tty_modes);
+    XRES_B(hold_screen);
+    XRES_B(utmpInhibit);
+    XRES_B(utmpDisplayId);
+    XRES_B(messages);
+#if OPT_SUNPC_KBD
+    XRES_B(sunKeyboard);
+#endif
+#if OPT_HP_FUNC_KEYS
+    XRES_B(hpFunctionKeys);
+#endif
+#if OPT_SCO_FUNC_KEYS
+    XRES_B(scoFunctionKeys);
+#endif
+#if OPT_SUN_FUNC_KEYS
+    XRES_B(sunFunctionKeys);
+#endif
+#if OPT_INITIAL_ERASE
+    XRES_B(ptyInitialErase);
+    XRES_B(backarrow_is_erase);
+#endif
+    XRES_B(useInsertMode);
+#if OPT_ZICONBEEP
+    XRES_I(zIconBeep);
+#endif
+#if OPT_PTY_HANDSHAKE
+    XRES_B(wait_for_map);
+    XRES_B(ptyHandshake);
+    XRES_B(ptySttySize);
+#endif
+#if OPT_SAME_NAME
+    XRES_B(sameName);
+#endif
+#if OPT_SESSION_MGT
+    XRES_B(sessionMgt);
+#endif
+}
+
+void
+TraceArgv(const char *tag, char **argv)
+{
+    int n = 0;
+
+    TRACE(("%s:\n", tag));
+    while (*argv != 0) {
+       TRACE(("  %d:%s\n", n++, *argv++));
+    }
+}
+
+static char *
+parse_option(char *dst, String src, int first)
+{
+    char *s;
+
+    if (!strncmp(src, "-/+", (size_t) 3)) {
+       dst[0] = (char) first;
+       strcpy(dst + 1, src + 3);
+    } else {
+       strcpy(dst, src);
+    }
+    for (s = dst; *s != '\0'; s++) {
+       if (*s == '#' || *s == '%' || *s == 'S') {
+           s[1] = '\0';
+       } else if (*s == ' ') {
+           *s = '\0';
+           break;
+       }
+    }
+    return dst;
+}
+
+static Bool
+same_option(OptionHelp * opt, XrmOptionDescRec * res)
+{
+    char temp[BUFSIZ];
+    return !strcmp(parse_option(temp, opt->opt, res->option[0]), res->option);
+}
+
+static Bool
+standard_option(String opt)
+{
+    static const char *table[] =
+    {
+       "+rv",
+       "+synchronous",
+       "-background",
+       "-bd",
+       "-bg",
+       "-bordercolor",
+       "-borderwidth",
+       "-bw",
+       "-display",
+       "-fg",
+       "-fn",
+       "-font",
+       "-foreground",
+       "-geometry",
+       "-iconic",
+       "-name",
+       "-reverse",
+       "-rv",
+       "-selectionTimeout",
+       "-synchronous",
+       "-title",
+       "-xnllanguage",
+       "-xrm",
+       "-xtsessionID",
+    };
+    Cardinal n;
+    char temp[BUFSIZ];
+
+    opt = parse_option(temp, opt, '-');
+    for (n = 0; n < XtNumber(table); n++) {
+       if (!strcmp(opt, table[n]))
+           return True;
+    }
+    return False;
+}
+
+/*
+ * Analyse the options/help messages for inconsistencies.
+ */
+void
+TraceOptions(OptionHelp * options, XrmOptionDescRec * resources, Cardinal res_count)
+{
+    OptionHelp *opt_array = sortedOpts(options, resources, res_count);
+    size_t j, k;
+    XrmOptionDescRec *res_array = sortedOptDescs(resources, res_count);
+    Bool first, found;
+
+    TRACE(("Checking options-tables for inconsistencies:\n"));
+
+#if 0
+    TRACE(("Options listed in help-message:\n"));
+    for (j = 0; options[j].opt != 0; j++)
+       TRACE(("%5d %-28s %s\n", j, opt_array[j].opt, opt_array[j].desc));
+    TRACE(("Options listed in resource-table:\n"));
+    for (j = 0; j < res_count; j++)
+       TRACE(("%5d %-28s %s\n", j, res_array[j].option, res_array[j].specifier));
+#endif
+
+    /* list all options[] not found in resources[] */
+    for (j = 0, first = True; options[j].opt != 0; j++) {
+       found = False;
+       for (k = 0; k < res_count; k++) {
+           if (same_option(&opt_array[j], &res_array[k])) {
+               found = True;
+               break;
+           }
+       }
+       if (!found) {
+           if (first) {
+               TRACE(("Options listed in help, not found in resource list:\n"));
+               first = False;
+           }
+           TRACE(("  %-28s%s\n", opt_array[j].opt,
+                  standard_option(opt_array[j].opt) ? " (standard)" : ""));
+       }
+    }
+
+    /* list all resources[] not found in options[] */
+    for (j = 0, first = True; j < res_count; j++) {
+       found = False;
+       for (k = 0; options[k].opt != 0; k++) {
+           if (same_option(&opt_array[k], &res_array[j])) {
+               found = True;
+               break;
+           }
+       }
+       if (!found) {
+           if (first) {
+               TRACE(("Resource list items not found in options-help:\n"));
+               first = False;
+           }
+           TRACE(("  %s\n", res_array[j].option));
+       }
+    }
+
+    TRACE(("Resource list items that will be ignored by XtOpenApplication:\n"));
+    for (j = 0; j < res_count; j++) {
+       switch (res_array[j].argKind) {
+       case XrmoptionSkipArg:
+           TRACE(("  %-28s {param}\n", res_array[j].option));
+           break;
+       case XrmoptionSkipNArgs:
+           TRACE(("  %-28s {%ld params}\n", res_array[j].option, (long)
+                  res_array[j].value));
+           break;
+       case XrmoptionSkipLine:
+           TRACE(("  %-28s {remainder of line}\n", res_array[j].option));
+           break;
+       case XrmoptionIsArg:
+       case XrmoptionNoArg:
+       case XrmoptionResArg:
+       case XrmoptionSepArg:
+       case XrmoptionStickyArg:
+       default:
+           break;
+       }
+    }
+}
+#else
+extern void empty_trace(void);
+void
+empty_trace(void)
+{
+}
+#endif
diff --git a/trace.h b/trace.h
new file mode 100644 (file)
index 0000000..f359ef4
--- /dev/null
+++ b/trace.h
@@ -0,0 +1,157 @@
+/* $XTermId: trace.h,v 1.56 2010/11/11 01:10:52 tom Exp $ */
+
+/*
+ *
+ * Copyright 1997-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ */
+
+/*
+ * Common/useful definitions for XTERM application
+ */
+#ifndef        included_trace_h
+#define        included_trace_h
+
+#include <xterm.h>
+
+#if OPT_TRACE
+
+extern void    Trace ( const char *, ... ) GCC_PRINTFLIKE(1,2);
+
+#undef  TRACE
+#define TRACE(p) Trace p
+
+extern void    TraceClose (void);
+
+#undef  TRACE_CLOSE
+#define TRACE_CLOSE TraceClose
+
+#if OPT_TRACE > 1
+#define TRACE2(p) Trace p
+#endif
+
+extern char *  visibleChars (const Char * /* buf */, unsigned /* len */);
+extern char *  visibleIChar (IChar *, unsigned);
+extern char *  visibleIChars (IChar * /* buf */, unsigned /* len */);
+extern const char * visibleChrsetName(unsigned /* chrset */);
+extern const char * visibleEventType (int);
+extern const char * visibleNotifyDetail(int /* code */);
+extern const char * visibleSelectionTarget(Display * /* d */, Atom /* a */);
+extern const char * visibleXError (int /* code */);
+
+extern void    TraceArgv(const char * /* tag */, char ** /* argv */);
+#undef  TRACE_ARGV
+#define        TRACE_ARGV(tag,argv) TraceArgv(tag,argv)
+
+extern const   char *trace_who;
+#undef  TRACE_CHILD
+#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; (void) tracing_child;
+
+extern void    TraceFocus(Widget, XEvent *);
+#undef  TRACE_FOCUS
+#define        TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e)
+
+extern void    TraceSizeHints(XSizeHints *);
+#undef  TRACE_HINTS
+#define        TRACE_HINTS(hints) TraceSizeHints(hints)
+
+extern void    TraceIds(const char * /* fname */, int  /* lnum */);
+#undef  TRACE_IDS
+#define        TRACE_IDS TraceIds(__FILE__, __LINE__)
+
+extern void    TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal  /* count */);
+#undef  TRACE_OPTS
+#define        TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens)
+
+extern void    TraceTranslations(const char *, Widget);
+#undef  TRACE_TRANS
+#define        TRACE_TRANS(name,w) TraceTranslations(name,w)
+
+extern void    TraceWMSizeHints(XtermWidget);
+#undef  TRACE_WM_HINTS
+#define        TRACE_WM_HINTS(w) TraceWMSizeHints(w)
+
+extern void    TraceXtermResources(void);
+#undef  TRACE_XRES
+#define        TRACE_XRES() TraceXtermResources()
+
+extern int     TraceResizeRequest(const char * /* fn */, int  /* ln */, Widget  /* w */, Dimension  /* reqwide */, Dimension  /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */);
+#undef  REQ_RESIZE
+#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
+       TraceResizeRequest(__FILE__, __LINE__, w, \
+                          (Dimension) (reqwide), (Dimension) (reqhigh), \
+                          (gotwide), (gothigh))
+
+#else
+
+#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
+       XtMakeResizeRequest((Widget) (w), \
+                           (Dimension) (reqwide), (Dimension) (reqhigh), \
+                           (gotwide), (gothigh))
+
+#endif
+
+/*
+ * The whole wnew->screen struct is zeroed in VTInitialize.  Use these macros
+ * where applicable for copying the pieces from the request widget into the
+ * new widget.  We do not have to use them for wnew->misc, but the associated
+ * traces are very useful for debugging.
+ */
+#if OPT_TRACE
+#define init_Bres(name) \
+       TRACE(("init " #name " = %s\n", \
+               BtoS(wnew->name = request->name)))
+#define init_Dres2(name,i) \
+       TRACE(("init " #name "[%d] = %f\n", i, \
+               wnew->name[i] = request->name[i]))
+#define init_Ires(name) \
+       TRACE(("init " #name " = %d\n", \
+               wnew->name = request->name))
+#define init_Sres(name) \
+       TRACE(("init " #name " = \"%s\"\n", \
+               (wnew->name = x_strtrim(request->name)) != NULL \
+                       ? wnew->name : "<null>"))
+#define init_Sres2(name,i) \
+       TRACE(("init " #name "[%d] = \"%s\"\n", i, \
+               (wnew->name(i) = x_strtrim(request->name(i))) != NULL \
+                       ? wnew->name(i) : "<null>"))
+#define init_Tres(offset) \
+       TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \
+               fill_Tres(wnew, request, offset)))
+#else
+#define init_Bres(name)    wnew->name = request->name
+#define init_Dres2(name,i) wnew->name[i] = request->name[i]
+#define init_Ires(name)    wnew->name = request->name
+#define init_Sres(name)    wnew->name = x_strtrim(request->name)
+#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i))
+#define init_Tres(offset)  fill_Tres(wnew, request, offset)
+#endif
+
+
+#endif /* included_trace_h */
diff --git a/unicode/README b/unicode/README
new file mode 100644 (file)
index 0000000..a6b4fb1
--- /dev/null
@@ -0,0 +1,24 @@
+-- $XTermId: README,v 1.10 2004/12/01 01:27:49 tom Exp $
+-- $XFree86: xc/programs/xterm/unicode/README,v 1.5 2004/12/01 01:27:49 dickey Exp $
+-- Thomas E. Dickey
+
+These are some scripts and datafiles used for generating tables used in the
+experimental UTF-8 implementation in xterm.
+
+To run the convmap.pl script, you will need a copy of UnicodeData-Latest.txt
+which is currently available as
+
+         ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
+
+It is a large file (~877kb), so it is not included in this distribution.
+
+convmap.pl is used to generate ../keysym2ucs.c, e.g.,
+
+       ./convmap.pl >../keysym2ucs.c
+
+keysym.map is input data for convmap.pl
+
+
+The make-precompose.sh script makes the precompose.c file, which is used to
+handle canonical composition. This also needs UnicodeData-Latest.txt. It uses
+precompose.c.head and precompose.c.tail as templates.
diff --git a/unicode/convmap.pl b/unicode/convmap.pl
new file mode 100755 (executable)
index 0000000..a473491
--- /dev/null
@@ -0,0 +1,206 @@
+#!/usr/bin/perl -w
+# $XTermId: convmap.pl,v 1.13 2007/06/11 23:30:44 tom Exp $
+#
+# Generate keysym2ucs.c file
+#
+# See also:
+# http://mail.nl.linux.org/linux-utf8/2001-04/msg00248.html
+#
+# $XFree86: xc/programs/xterm/unicode/convmap.pl,v 1.5 2000/01/24 22:22:05 dawes Exp $
+
+use strict;
+
+our $keysym;
+our %name;
+our %keysym_to_ucs;
+our %keysym_to_keysymname;
+
+sub utf8 ($);
+
+sub utf8 ($) {
+    my $c = shift(@_);
+
+    if ($c < 0x80) {
+        return sprintf("%c", $c);
+    } elsif ($c < 0x800) {
+        return sprintf("%c%c", 0xc0 | ($c >> 6), 0x80 | ($c & 0x3f));
+    } elsif ($c < 0x10000) {
+        return sprintf("%c%c%c",
+                       0xe0 |  ($c >> 12),
+                       0x80 | (($c >>  6) & 0x3f),
+                       0x80 | ( $c        & 0x3f));
+    } elsif ($c < 0x200000) {
+        return sprintf("%c%c%c%c",
+                       0xf0 |  ($c >> 18),
+                       0x80 | (($c >> 12) & 0x3f),
+                       0x80 | (($c >>  6) & 0x3f),
+                       0x80 | ( $c        & 0x3f));
+    } elsif ($c < 0x4000000) {
+        return sprintf("%c%c%c%c%c",
+                       0xf8 |  ($c >> 24),
+                       0x80 | (($c >> 18) & 0x3f),
+                       0x80 | (($c >> 12) & 0x3f),
+                       0x80 | (($c >>  6) & 0x3f),
+                       0x80 | ( $c        & 0x3f));
+
+    } elsif ($c < 0x80000000) {
+        return sprintf("%c%c%c%c%c%c",
+                       0xfe |  ($c >> 30),
+                       0x80 | (($c >> 24) & 0x3f),
+                       0x80 | (($c >> 18) & 0x3f),
+                       0x80 | (($c >> 12) & 0x3f),
+                       0x80 | (($c >> 6)  & 0x3f),
+                       0x80 | ( $c        & 0x3f));
+    } else {
+        return utf8(0xfffd);
+    }
+}
+
+my $unicodedata = "UnicodeData-Latest.txt";
+
+# read list of all Unicode names
+if (!open(UDATA, $unicodedata) && !open(UDATA, "$unicodedata")) {
+    die ("Can't open Unicode database '$unicodedata':\n$!\n\n" .
+         "Please make sure that you have downloaded the file\n" .
+         "ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData-Latest.txt\n");
+}
+while (<UDATA>) {
+    if (/^([0-9,A-F]{4,6});([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*)$/) {
+        $name{hex($1)} = $2;
+    } else {
+        die("Syntax error in line '$_' in file '$unicodedata'");
+    }
+}
+close(UDATA);
+
+# read mapping (from http://wsinwp07.win.tue.nl:1234/unicode/keysym.map)
+open(LIST, "<keysym.map") || die ("Can't open map file:\n$!\n");
+while (<LIST>) {
+    if (/^0x([0-9a-f]{4})\s+U([0-9a-f]{4})\s*(\#.*)?$/){
+        my $keysym = hex($1);
+        my $ucs = hex($2);
+       my $comment = $3;
+       $comment =~ s/^#\s*//;
+        $keysym_to_ucs{$keysym} = $ucs;
+       $keysym_to_keysymname{$keysym} = $comment;
+    } elsif (/^\s*\#/ || /^\s*$/) {
+    } else {
+        die("Syntax error in 'list' in line\n$_\n");
+    }
+}
+close(LIST);
+
+# read entries in keysymdef.h
+open(LIST, "</usr/include/X11/keysymdef.h") || die ("Can't open keysymdef.h:\n$!\n");
+while (<LIST>) {
+    if (/^\#define\s+XK_([A-Za-z_0-9]+)\s+0x([0-9a-fA-F]+)\s*(\/.*)?$/) {
+       next if /\/\* deprecated \*\//;
+       my $keysymname = $1;
+       my $keysym = hex($2);
+       $keysym_to_keysymname{$keysym} = $keysymname;
+    }
+}
+close(LIST);
+
+print <<EOT;
+/* \$XTermId\$
+ * This module converts keysym values into the corresponding ISO 10646
+ * (UCS, Unicode) values.
+ *
+ * The array keysymtab[] contains pairs of X11 keysym values for graphical
+ * characters and the corresponding Unicode value. The function
+ * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
+ * therefore keysymtab[] must remain SORTED by keysym value.
+ *
+ * The keysym -> UTF-8 conversion will hopefully one day be provided
+ * by Xlib via XmbLookupString() and should ideally not have to be
+ * done in X applications. But we are not there yet.
+ *
+ * We allow to represent any UCS character in the range U-00000000 to
+ * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
+ * This admittedly does not cover the entire 31-bit space of UCS, but
+ * it does cover all of the characters up to U-10FFFF, which can be
+ * represented by UTF-16, and more, and it is very unlikely that higher
+ * UCS codes will ever be assigned by ISO. So to get Unicode character
+ * U+ABCD you can directly use keysym 0x0100abcd.
+ *
+ * NOTE: The comments in the table below contain the actual character
+ * encoded in UTF-8, so for viewing and editing best use an editor in
+ * UTF-8 mode.
+ *
+ * Author: Markus G. Kuhn <mkuhn\@acm.org>, University of Cambridge, April 2001
+ *
+ * Special thanks to Richard Verhoeven <river\@win.tue.nl> for preparing
+ * an initial draft of the mapping table.
+ *
+ * This software is in the public domain. Share and enjoy!
+ *
+ * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl)
+ */
+
+#ifndef KEYSYM2UCS_INCLUDED
+  
+#include "keysym2ucs.h"
+#define VISIBLE /* */
+
+#else
+
+#define VISIBLE static
+
+#endif
+
+static struct codepair {
+  unsigned short keysym;
+  unsigned short ucs;
+} keysymtab[] = {
+EOT
+
+for $keysym (sort {$a <=> $b} keys(%keysym_to_keysymname)) {
+    my $ucs = $keysym_to_ucs{$keysym};
+    next if $keysym >= 0xf000 || $keysym < 0x100;
+    if ($ucs) {
+       printf("  { 0x%04x, 0x%04x }, /*%28s %s %s */\n",
+              $keysym, $ucs, $keysym_to_keysymname{$keysym}, utf8($ucs),
+              defined($name{$ucs}) ? $name{$ucs} : "???" );
+    } else {
+       printf("/*  0x%04x   %39s ? ??? */\n",
+              $keysym, $keysym_to_keysymname{$keysym});
+    }
+}
+
+print <<EOT;
+};
+
+VISIBLE
+long keysym2ucs(KeySym keysym)
+{
+    int min = 0;
+    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
+    int mid;
+
+    /* first check for Latin-1 characters (1:1 mapping) */
+    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
+        (keysym >= 0x00a0 && keysym <= 0x00ff))
+        return keysym;
+
+    /* also check for directly encoded 24-bit UCS characters */
+    if ((keysym & 0xff000000) == 0x01000000)
+       return keysym & 0x00ffffff;
+
+    /* binary search in table */
+    while (max >= min) {
+       mid = (min + max) / 2;
+       if (keysymtab[mid].keysym < keysym)
+           min = mid + 1;
+       else if (keysymtab[mid].keysym > keysym)
+           max = mid - 1;
+       else {
+           /* found it */
+           return keysymtab[mid].ucs;
+       }
+    }
+
+    /* no matching Unicode value found */
+    return -1;
+}
+EOT
diff --git a/unicode/keysym.map b/unicode/keysym.map
new file mode 100644 (file)
index 0000000..f06e26e
--- /dev/null
@@ -0,0 +1,1052 @@
+# $XTermId: keysym.map,v 1.8 2007/06/13 00:52:16 tom Exp $
+#
+# This list can be used to convert X11 Keysyms to Unicode 2.1 character.
+# The list is not checked for correctness by Unicode officials.  Use it
+# at your own risk and the creator is not responsible for any damage that
+# occurred due to using this list.
+#
+# The list is created by looking at the Keysym names and the Unicode data
+# file.  Other mapping tables were used as a reference where needed.
+# Due to a lack of knowledge of the Hebrew, Thai and Hangul symbols,
+# expect errors in these sections.  The mapping of the keypad keys
+# might also require some adjustments.
+#
+# The following fields are used:
+# 1    The X11 keysym numbers from the include file keysymdef.h
+# 2    The Unicode (2.1) position (U0000 means unknown Unicode position)
+# #
+# 3    the name of the X11 keysym (without XK_)
+#
+# Authors:  Richard Verhoeven, TUE, <river@win.tue.nl>
+#           Markus Kuhn, University of Cambridge, <mkuhn@acm.org>
+#
+# You are free to use and modify this table.  If you introduce errors
+# in the table, please remove the copyright line. If you remove errors,
+# please let me know, so I can update my version.
+#
+# $XFree86: xc/programs/xterm/unicode/keysym.map,v 1.1 1999/06/12 15:37:24 dawes Exp $
+#
+0x0020     U0020  # space
+0x0021     U0021  # exclam
+0x0022     U0022  # quotedbl
+0x0023     U0023  # numbersign
+0x0024     U0024  # dollar
+0x0025     U0025  # percent
+0x0026     U0026  # ampersand
+0x0027     U0027  # apostrophe
+0x0028     U0028  # parenleft
+0x0029     U0029  # parenright
+0x002a     U002a  # asterisk
+0x002b     U002b  # plus
+0x002c     U002c  # comma
+0x002d     U002d  # minus
+0x002e     U002e  # period
+0x002f     U002f  # slash
+0x0030     U0030  # 0
+0x0031     U0031  # 1
+0x0032     U0032  # 2
+0x0033     U0033  # 3
+0x0034     U0034  # 4
+0x0035     U0035  # 5
+0x0036     U0036  # 6
+0x0037     U0037  # 7
+0x0038     U0038  # 8
+0x0039     U0039  # 9
+0x003a     U003a  # colon
+0x003b     U003b  # semicolon
+0x003c     U003c  # less
+0x003d     U003d  # equal
+0x003e     U003e  # greater
+0x003f     U003f  # question
+0x0040     U0040  # at
+0x0041     U0041  # A
+0x0042     U0042  # B
+0x0043     U0043  # C
+0x0044     U0044  # D
+0x0045     U0045  # E
+0x0046     U0046  # F
+0x0047     U0047  # G
+0x0048     U0048  # H
+0x0049     U0049  # I
+0x004a     U004a  # J
+0x004b     U004b  # K
+0x004c     U004c  # L
+0x004d     U004d  # M
+0x004e     U004e  # N
+0x004f     U004f  # O
+0x0050     U0050  # P
+0x0051     U0051  # Q
+0x0052     U0052  # R
+0x0053     U0053  # S
+0x0054     U0054  # T
+0x0055     U0055  # U
+0x0056     U0056  # V
+0x0057     U0057  # W
+0x0058     U0058  # X
+0x0059     U0059  # Y
+0x005a     U005a  # Z
+0x005b     U005b  # bracketleft
+0x005c     U005c  # backslash
+0x005d     U005d  # bracketright
+0x005e     U005e  # asciicircum
+0x005f     U005f  # underscore
+0x0060     U0060  # grave
+0x0061     U0061  # a
+0x0062     U0062  # b
+0x0063     U0063  # c
+0x0064     U0064  # d
+0x0065     U0065  # e
+0x0066     U0066  # f
+0x0067     U0067  # g
+0x0068     U0068  # h
+0x0069     U0069  # i
+0x006a     U006a  # j
+0x006b     U006b  # k
+0x006c     U006c  # l
+0x006d     U006d  # m
+0x006e     U006e  # n
+0x006f     U006f  # o
+0x0070     U0070  # p
+0x0071     U0071  # q
+0x0072     U0072  # r
+0x0073     U0073  # s
+0x0074     U0074  # t
+0x0075     U0075  # u
+0x0076     U0076  # v
+0x0077     U0077  # w
+0x0078     U0078  # x
+0x0079     U0079  # y
+0x007a     U007a  # z
+0x007b     U007b  # braceleft
+0x007c     U007c  # bar
+0x007d     U007d  # braceright
+0x007e     U007e  # asciitilde
+0x00a0     U00a0  # nobreakspace
+0x00a1     U00a1  # exclamdown
+0x00a2     U00a2  # cent
+0x00a3     U00a3  # sterling
+0x00a4     U00a4  # currency
+0x00a5     U00a5  # yen
+0x00a6     U00a6  # brokenbar
+0x00a7     U00a7  # section
+0x00a8     U00a8  # diaeresis
+0x00a9     U00a9  # copyright
+0x00aa     U00aa  # ordfeminine
+0x00ab     U00ab  # guillemotleft      /* left angle quotation mark */
+0x00ac     U00ac  # notsign
+0x00ad     U00ad  # hyphen
+0x00ae     U00ae  # registered
+0x00af     U00af  # macron
+0x00b0     U00b0  # degree
+0x00b1     U00b1  # plusminus
+0x00b2     U00b2  # twosuperior
+0x00b3     U00b3  # threesuperior
+0x00b4     U00b4  # acute
+0x00b5     U00b5  # mu
+0x00b6     U00b6  # paragraph
+0x00b7     U00b7  # periodcentered
+0x00b8     U00b8  # cedilla
+0x00b9     U00b9  # onesuperior
+0x00ba     U00ba  # masculine
+0x00bb     U00bb  # guillemotright     /* right angle quotation mark */
+0x00bc     U00bc  # onequarter
+0x00bd     U00bd  # onehalf
+0x00be     U00be  # threequarters
+0x00bf     U00bf  # questiondown
+0x00c0     U00c0  # Agrave
+0x00c1     U00c1  # Aacute
+0x00c2     U00c2  # Acircumflex
+0x00c3     U00c3  # Atilde
+0x00c4     U00c4  # Adiaeresis
+0x00c5     U00c5  # Aring
+0x00c6     U00c6  # AE
+0x00c7     U00c7  # Ccedilla
+0x00c8     U00c8  # Egrave
+0x00c9     U00c9  # Eacute
+0x00ca     U00ca  # Ecircumflex
+0x00cb     U00cb  # Ediaeresis
+0x00cc     U00cc  # Igrave
+0x00cd     U00cd  # Iacute
+0x00ce     U00ce  # Icircumflex
+0x00cf     U00cf  # Idiaeresis
+0x00d0     U00d0  # ETH
+0x00d1     U00d1  # Ntilde
+0x00d2     U00d2  # Ograve
+0x00d3     U00d3  # Oacute
+0x00d4     U00d4  # Ocircumflex
+0x00d5     U00d5  # Otilde
+0x00d6     U00d6  # Odiaeresis
+0x00d7     U00d7  # multiply
+0x00d8     U00d8  # Oslash
+0x00d9     U00d9  # Ugrave
+0x00da     U00da  # Uacute
+0x00db     U00db  # Ucircumflex
+0x00dc     U00dc  # Udiaeresis
+0x00dd     U00dd  # Yacute
+0x00de     U00de  # THORN
+0x00df     U00df  # ssharp
+0x00e0     U00e0  # agrave
+0x00e1     U00e1  # aacute
+0x00e2     U00e2  # acircumflex
+0x00e3     U00e3  # atilde
+0x00e4     U00e4  # adiaeresis
+0x00e5     U00e5  # aring
+0x00e6     U00e6  # ae
+0x00e7     U00e7  # ccedilla
+0x00e8     U00e8  # egrave
+0x00e9     U00e9  # eacute
+0x00ea     U00ea  # ecircumflex
+0x00eb     U00eb  # ediaeresis
+0x00ec     U00ec  # igrave
+0x00ed     U00ed  # iacute
+0x00ee     U00ee  # icircumflex
+0x00ef     U00ef  # idiaeresis
+0x00f0     U00f0  # eth
+0x00f1     U00f1  # ntilde
+0x00f2     U00f2  # ograve
+0x00f3     U00f3  # oacute
+0x00f4     U00f4  # ocircumflex
+0x00f5     U00f5  # otilde
+0x00f6     U00f6  # odiaeresis
+0x00f7     U00f7  # division
+0x00f8     U00f8  # oslash
+0x00f9     U00f9  # ugrave
+0x00fa     U00fa  # uacute
+0x00fb     U00fb  # ucircumflex
+0x00fc     U00fc  # udiaeresis
+0x00fd     U00fd  # yacute
+0x00fe     U00fe  # thorn
+0x00ff     U00ff  # ydiaeresis
+0x01a1     U0104  # Aogonek
+0x01a2     U02d8  # breve
+0x01a3     U0141  # Lstroke
+0x01a5     U013d  # Lcaron
+0x01a6     U015a  # Sacute
+0x01a9     U0160  # Scaron
+0x01aa     U015e  # Scedilla
+0x01ab     U0164  # Tcaron
+0x01ac     U0179  # Zacute
+0x01ae     U017d  # Zcaron
+0x01af     U017b  # Zabovedot
+0x01b1     U0105  # aogonek
+0x01b2     U02db  # ogonek
+0x01b3     U0142  # lstroke
+0x01b5     U013e  # lcaron
+0x01b6     U015b  # sacute
+0x01b7     U02c7  # caron
+0x01b9     U0161  # scaron
+0x01ba     U015f  # scedilla
+0x01bb     U0165  # tcaron
+0x01bc     U017a  # zacute
+0x01bd     U02dd  # doubleacute
+0x01be     U017e  # zcaron
+0x01bf     U017c  # zabovedot
+0x01c0     U0154  # Racute
+0x01c3     U0102  # Abreve
+0x01c5     U0139  # Lacute
+0x01c6     U0106  # Cacute
+0x01c8     U010c  # Ccaron
+0x01ca     U0118  # Eogonek
+0x01cc     U011a  # Ecaron
+0x01cf     U010e  # Dcaron
+0x01d0     U0110  # Dstroke
+0x01d1     U0143  # Nacute
+0x01d2     U0147  # Ncaron
+0x01d5     U0150  # Odoubleacute
+0x01d8     U0158  # Rcaron
+0x01d9     U016e  # Uring
+0x01db     U0170  # Udoubleacute
+0x01de     U0162  # Tcedilla
+0x01e0     U0155  # racute
+0x01e3     U0103  # abreve
+0x01e5     U013a  # lacute
+0x01e6     U0107  # cacute
+0x01e8     U010d  # ccaron
+0x01ea     U0119  # eogonek
+0x01ec     U011b  # ecaron
+0x01ef     U010f  # dcaron
+0x01f0     U0111  # dstroke
+0x01f1     U0144  # nacute
+0x01f2     U0148  # ncaron
+0x01f5     U0151  # odoubleacute
+0x01f8     U0159  # rcaron
+0x01f9     U016f  # uring
+0x01fb     U0171  # udoubleacute
+0x01fe     U0163  # tcedilla
+0x01ff     U02d9  # abovedot
+0x02a1     U0126  # Hstroke
+0x02a6     U0124  # Hcircumflex
+0x02a9     U0130  # Iabovedot
+0x02ab     U011e  # Gbreve
+0x02ac     U0134  # Jcircumflex
+0x02b1     U0127  # hstroke
+0x02b6     U0125  # hcircumflex
+0x02b9     U0131  # idotless
+0x02bb     U011f  # gbreve
+0x02bc     U0135  # jcircumflex
+0x02c5     U010a  # Cabovedot
+0x02c6     U0108  # Ccircumflex
+0x02d5     U0120  # Gabovedot
+0x02d8     U011c  # Gcircumflex
+0x02dd     U016c  # Ubreve
+0x02de     U015c  # Scircumflex
+0x02e5     U010b  # cabovedot
+0x02e6     U0109  # ccircumflex
+0x02f5     U0121  # gabovedot
+0x02f8     U011d  # gcircumflex
+0x02fd     U016d  # ubreve
+0x02fe     U015d  # scircumflex
+0x03a2     U0138  # kra
+0x03a3     U0156  # Rcedilla
+0x03a5     U0128  # Itilde
+0x03a6     U013b  # Lcedilla
+0x03aa     U0112  # Emacron
+0x03ab     U0122  # Gcedilla
+0x03ac     U0166  # Tslash
+0x03b3     U0157  # rcedilla
+0x03b5     U0129  # itilde
+0x03b6     U013c  # lcedilla
+0x03ba     U0113  # emacron
+0x03bb     U0123  # gcedilla
+0x03bc     U0167  # tslash
+0x03bd     U014a  # ENG
+0x03bf     U014b  # eng
+0x03c0     U0100  # Amacron
+0x03c7     U012e  # Iogonek
+0x03cc     U0116  # Eabovedot
+0x03cf     U012a  # Imacron
+0x03d1     U0145  # Ncedilla
+0x03d2     U014c  # Omacron
+0x03d3     U0136  # Kcedilla
+0x03d9     U0172  # Uogonek
+0x03dd     U0168  # Utilde
+0x03de     U016a  # Umacron
+0x03e0     U0101  # amacron
+0x03e7     U012f  # iogonek
+0x03ec     U0117  # eabovedot
+0x03ef     U012b  # imacron
+0x03f1     U0146  # ncedilla
+0x03f2     U014d  # omacron
+0x03f3     U0137  # kcedilla
+0x03f9     U0173  # uogonek
+0x03fd     U0169  # utilde
+0x03fe     U016b  # umacron
+0x047e     U203e  # overline
+0x04a1     U3002  # kana_fullstop
+0x04a2     U300c  # kana_openingbracket
+0x04a3     U300d  # kana_closingbracket
+0x04a4     U3001  # kana_comma
+0x04a5     U30fb  # kana_conjunctive
+0x04a6     U30f2  # kana_WO
+0x04a7     U30a1  # kana_a
+0x04a8     U30a3  # kana_i
+0x04a9     U30a5  # kana_u
+0x04aa     U30a7  # kana_e
+0x04ab     U30a9  # kana_o
+0x04ac     U30e3  # kana_ya
+0x04ad     U30e5  # kana_yu
+0x04ae     U30e7  # kana_yo
+0x04af     U30c3  # kana_tsu
+0x04b0     U30fc  # prolongedsound
+0x04b1     U30a2  # kana_A
+0x04b2     U30a4  # kana_I
+0x04b3     U30a6  # kana_U
+0x04b4     U30a8  # kana_E
+0x04b5     U30aa  # kana_O
+0x04b6     U30ab  # kana_KA
+0x04b7     U30ad  # kana_KI
+0x04b8     U30af  # kana_KU
+0x04b9     U30b1  # kana_KE
+0x04ba     U30b3  # kana_KO
+0x04bb     U30b5  # kana_SA
+0x04bc     U30b7  # kana_SHI
+0x04bd     U30b9  # kana_SU
+0x04be     U30bb  # kana_SE
+0x04bf     U30bd  # kana_SO
+0x04c0     U30bf  # kana_TA
+0x04c1     U30c1  # kana_CHI
+0x04c2     U30c4  # kana_TSU
+0x04c3     U30c6  # kana_TE
+0x04c4     U30c8  # kana_TO
+0x04c5     U30ca  # kana_NA
+0x04c6     U30cb  # kana_NI
+0x04c7     U30cc  # kana_NU
+0x04c8     U30cd  # kana_NE
+0x04c9     U30ce  # kana_NO
+0x04ca     U30cf  # kana_HA
+0x04cb     U30d2  # kana_HI
+0x04cc     U30d5  # kana_FU
+0x04cd     U30d8  # kana_HE
+0x04ce     U30db  # kana_HO
+0x04cf     U30de  # kana_MA
+0x04d0     U30df  # kana_MI
+0x04d1     U30e0  # kana_MU
+0x04d2     U30e1  # kana_ME
+0x04d3     U30e2  # kana_MO
+0x04d4     U30e4  # kana_YA
+0x04d5     U30e6  # kana_YU
+0x04d6     U30e8  # kana_YO
+0x04d7     U30e9  # kana_RA
+0x04d8     U30ea  # kana_RI
+0x04d9     U30eb  # kana_RU
+0x04da     U30ec  # kana_RE
+0x04db     U30ed  # kana_RO
+0x04dc     U30ef  # kana_WA
+0x04dd     U30f3  # kana_N
+0x04de     U309b  # voicedsound
+0x04df     U309c  # semivoicedsound
+0x05ac     U060c  # Arabic_comma
+0x05bb     U061b  # Arabic_semicolon
+0x05bf     U061f  # Arabic_question_mark
+0x05c1     U0621  # Arabic_hamza
+0x05c2     U0622  # Arabic_maddaonalef
+0x05c3     U0623  # Arabic_hamzaonalef
+0x05c4     U0624  # Arabic_hamzaonwaw
+0x05c5     U0625  # Arabic_hamzaunderalef
+0x05c6     U0626  # Arabic_hamzaonyeh
+0x05c7     U0627  # Arabic_alef
+0x05c8     U0628  # Arabic_beh
+0x05c9     U0629  # Arabic_tehmarbuta
+0x05ca     U062a  # Arabic_teh
+0x05cb     U062b  # Arabic_theh
+0x05cc     U062c  # Arabic_jeem
+0x05cd     U062d  # Arabic_hah
+0x05ce     U062e  # Arabic_khah
+0x05cf     U062f  # Arabic_dal
+0x05d0     U0630  # Arabic_thal
+0x05d1     U0631  # Arabic_ra
+0x05d2     U0632  # Arabic_zain
+0x05d3     U0633  # Arabic_seen
+0x05d4     U0634  # Arabic_sheen
+0x05d5     U0635  # Arabic_sad
+0x05d6     U0636  # Arabic_dad
+0x05d7     U0637  # Arabic_tah
+0x05d8     U0638  # Arabic_zah
+0x05d9     U0639  # Arabic_ain
+0x05da     U063a  # Arabic_ghain
+0x05e0     U0640  # Arabic_tatweel
+0x05e1     U0641  # Arabic_feh
+0x05e2     U0642  # Arabic_qaf
+0x05e3     U0643  # Arabic_kaf
+0x05e4     U0644  # Arabic_lam
+0x05e5     U0645  # Arabic_meem
+0x05e6     U0646  # Arabic_noon
+0x05e7     U0647  # Arabic_ha
+0x05e8     U0648  # Arabic_waw
+0x05e9     U0649  # Arabic_alefmaksura
+0x05ea     U064a  # Arabic_yeh
+0x05eb     U064b  # Arabic_fathatan
+0x05ec     U064c  # Arabic_dammatan
+0x05ed     U064d  # Arabic_kasratan
+0x05ee     U064e  # Arabic_fatha
+0x05ef     U064f  # Arabic_damma
+0x05f0     U0650  # Arabic_kasra
+0x05f1     U0651  # Arabic_shadda
+0x05f2     U0652  # Arabic_sukun
+0x06a1     U0452  # Serbian_dje
+0x06a2     U0453  # Macedonia_gje
+0x06a3     U0451  # Cyrillic_io
+0x06a4     U0454  # Ukrainian_ie
+0x06a5     U0455  # Macedonia_dse
+0x06a6     U0456  # Ukrainian_i
+0x06a7     U0457  # Ukrainian_yi
+0x06a8     U0458  # Cyrillic_je
+0x06a9     U0459  # Cyrillic_lje
+0x06aa     U045a  # Cyrillic_nje
+0x06ab     U045b  # Serbian_tshe
+0x06ac     U045c  # Macedonia_kje
+0x06ad     U0491  # Ukrainian_ghe_with_upturn
+0x06ae     U045e  # Byelorussian_shortu
+0x06af     U045f  # Cyrillic_dzhe
+0x06b0     U2116  # numerosign
+0x06b1     U0402  # Serbian_DJE
+0x06b2     U0403  # Macedonia_GJE
+0x06b3     U0401  # Cyrillic_IO
+0x06b4     U0404  # Ukrainian_IE
+0x06b5     U0405  # Macedonia_DSE
+0x06b6     U0406  # Ukrainian_I
+0x06b7     U0407  # Ukrainian_YI
+0x06b8     U0408  # Cyrillic_JE
+0x06b9     U0409  # Cyrillic_LJE
+0x06ba     U040a  # Cyrillic_NJE
+0x06bb     U040b  # Serbian_TSHE
+0x06bc     U040c  # Macedonia_KJE
+0x06bd     U0490  # Ukrainian_GHE_WITH_UPTURN
+0x06be     U040e  # Byelorussian_SHORTU
+0x06bf     U040f  # Cyrillic_DZHE
+0x06c0     U044e  # Cyrillic_yu
+0x06c1     U0430  # Cyrillic_a
+0x06c2     U0431  # Cyrillic_be
+0x06c3     U0446  # Cyrillic_tse
+0x06c4     U0434  # Cyrillic_de
+0x06c5     U0435  # Cyrillic_ie
+0x06c6     U0444  # Cyrillic_ef
+0x06c7     U0433  # Cyrillic_ghe
+0x06c8     U0445  # Cyrillic_ha
+0x06c9     U0438  # Cyrillic_i
+0x06ca     U0439  # Cyrillic_shorti
+0x06cb     U043a  # Cyrillic_ka
+0x06cc     U043b  # Cyrillic_el
+0x06cd     U043c  # Cyrillic_em
+0x06ce     U043d  # Cyrillic_en
+0x06cf     U043e  # Cyrillic_o
+0x06d0     U043f  # Cyrillic_pe
+0x06d1     U044f  # Cyrillic_ya
+0x06d2     U0440  # Cyrillic_er
+0x06d3     U0441  # Cyrillic_es
+0x06d4     U0442  # Cyrillic_te
+0x06d5     U0443  # Cyrillic_u
+0x06d6     U0436  # Cyrillic_zhe
+0x06d7     U0432  # Cyrillic_ve
+0x06d8     U044c  # Cyrillic_softsign
+0x06d9     U044b  # Cyrillic_yeru
+0x06da     U0437  # Cyrillic_ze
+0x06db     U0448  # Cyrillic_sha
+0x06dc     U044d  # Cyrillic_e
+0x06dd     U0449  # Cyrillic_shcha
+0x06de     U0447  # Cyrillic_che
+0x06df     U044a  # Cyrillic_hardsign
+0x06e0     U042e  # Cyrillic_YU
+0x06e1     U0410  # Cyrillic_A
+0x06e2     U0411  # Cyrillic_BE
+0x06e3     U0426  # Cyrillic_TSE
+0x06e4     U0414  # Cyrillic_DE
+0x06e5     U0415  # Cyrillic_IE
+0x06e6     U0424  # Cyrillic_EF
+0x06e7     U0413  # Cyrillic_GHE
+0x06e8     U0425  # Cyrillic_HA
+0x06e9     U0418  # Cyrillic_I
+0x06ea     U0419  # Cyrillic_SHORTI
+0x06eb     U041a  # Cyrillic_KA
+0x06ec     U041b  # Cyrillic_EL
+0x06ed     U041c  # Cyrillic_EM
+0x06ee     U041d  # Cyrillic_EN
+0x06ef     U041e  # Cyrillic_O
+0x06f0     U041f  # Cyrillic_PE
+0x06f1     U042f  # Cyrillic_YA
+0x06f2     U0420  # Cyrillic_ER
+0x06f3     U0421  # Cyrillic_ES
+0x06f4     U0422  # Cyrillic_TE
+0x06f5     U0423  # Cyrillic_U
+0x06f6     U0416  # Cyrillic_ZHE
+0x06f7     U0412  # Cyrillic_VE
+0x06f8     U042c  # Cyrillic_SOFTSIGN
+0x06f9     U042b  # Cyrillic_YERU
+0x06fa     U0417  # Cyrillic_ZE
+0x06fb     U0428  # Cyrillic_SHA
+0x06fc     U042d  # Cyrillic_E
+0x06fd     U0429  # Cyrillic_SHCHA
+0x06fe     U0427  # Cyrillic_CHE
+0x06ff     U042a  # Cyrillic_HARDSIGN
+0x07a1     U0386  # Greek_ALPHAaccent
+0x07a2     U0388  # Greek_EPSILONaccent
+0x07a3     U0389  # Greek_ETAaccent
+0x07a4     U038a  # Greek_IOTAaccent
+0x07a5     U03aa  # Greek_IOTAdieresis
+0x07a7     U038c  # Greek_OMICRONaccent
+0x07a8     U038e  # Greek_UPSILONaccent
+0x07a9     U03ab  # Greek_UPSILONdieresis
+0x07ab     U038f  # Greek_OMEGAaccent
+0x07ae     U0385  # Greek_accentdieresis
+0x07af     U2015  # Greek_horizbar
+0x07b1     U03ac  # Greek_alphaaccent
+0x07b2     U03ad  # Greek_epsilonaccent
+0x07b3     U03ae  # Greek_etaaccent
+0x07b4     U03af  # Greek_iotaaccent
+0x07b5     U03ca  # Greek_IOTAdieresis
+0x07b6     U0390  # Greek_iotaaccentdieresis
+0x07b7     U03cc  # Greek_omicronaccent
+0x07b8     U03cd  # Greek_upsilonaccent
+0x07b9     U03cb  # Greek_upsilondieresis
+0x07ba     U03b0  # Greek_upsilonaccentdieresis
+0x07bb     U03ce  # Greek_omegaaccent
+0x07c1     U0391  # Greek_ALPHA
+0x07c2     U0392  # Greek_BETA
+0x07c3     U0393  # Greek_GAMMA
+0x07c4     U0394  # Greek_DELTA
+0x07c5     U0395  # Greek_EPSILON
+0x07c6     U0396  # Greek_ZETA
+0x07c7     U0397  # Greek_ETA
+0x07c8     U0398  # Greek_THETA
+0x07c9     U0399  # Greek_IOTA
+0x07ca     U039a  # Greek_KAPPA
+0x07cb     U039b  # Greek_LAMBDA
+0x07cb     U039b  # Greek_LAMDA
+0x07cc     U039c  # Greek_MU
+0x07cd     U039d  # Greek_NU
+0x07ce     U039e  # Greek_XI
+0x07cf     U039f  # Greek_OMICRON
+0x07d0     U03a0  # Greek_PI
+0x07d1     U03a1  # Greek_RHO
+0x07d2     U03a3  # Greek_SIGMA
+0x07d4     U03a4  # Greek_TAU
+0x07d5     U03a5  # Greek_UPSILON
+0x07d6     U03a6  # Greek_PHI
+0x07d7     U03a7  # Greek_CHI
+0x07d8     U03a8  # Greek_PSI
+0x07d9     U03a9  # Greek_OMEGA
+0x07e1     U03b1  # Greek_alpha
+0x07e2     U03b2  # Greek_beta
+0x07e3     U03b3  # Greek_gamma
+0x07e4     U03b4  # Greek_delta
+0x07e5     U03b5  # Greek_epsilon
+0x07e6     U03b6  # Greek_zeta
+0x07e7     U03b7  # Greek_eta
+0x07e8     U03b8  # Greek_theta
+0x07e9     U03b9  # Greek_iota
+0x07ea     U03ba  # Greek_kappa
+0x07eb     U03bb  # Greek_lambda
+0x07ec     U03bc  # Greek_mu
+0x07ed     U03bd  # Greek_nu
+0x07ee     U03be  # Greek_xi
+0x07ef     U03bf  # Greek_omicron
+0x07f0     U03c0  # Greek_pi
+0x07f1     U03c1  # Greek_rho
+0x07f2     U03c3  # Greek_sigma
+0x07f3     U03c2  # Greek_finalsmallsigma
+0x07f4     U03c4  # Greek_tau
+0x07f5     U03c5  # Greek_upsilon
+0x07f6     U03c6  # Greek_phi
+0x07f7     U03c7  # Greek_chi
+0x07f8     U03c8  # Greek_psi
+0x07f9     U03c9  # Greek_omega
+0x08a1     U23b7  # leftradical
+0x08a2     U250c  # topleftradical
+0x08a3     U2500  # horizconnector
+0x08a4     U2320  # topintegral
+0x08a5     U2321  # botintegral
+0x08a6     U2502  # vertconnector
+0x08a7     U23a1  # topleftsqbracket
+0x08a8     U23a3  # botleftsqbracket
+0x08a9     U23a4  # toprightsqbracket
+0x08aa     U23a6  # botrightsqbracket
+0x08ab     U239b  # topleftparens
+0x08ac     U239d  # botleftparens
+0x08ad     U239e  # toprightparens
+0x08ae     U23a0  # botrightparens
+0x08af     U23a8  # leftmiddlecurlybrace
+0x08b0     U23ac  # rightmiddlecurlybrace
+0x08b1     U0000  # topleftsummation
+0x08b2     U0000  # botleftsummation
+0x08b3     U0000  # topvertsummationconnector
+0x08b4     U0000  # botvertsummationconnector
+0x08b5     U0000  # toprightsummation
+0x08b6     U0000  # botrightsummation
+0x08b7     U0000  # rightmiddlesummation
+0x08bc     U2264  # lessthanequal
+0x08bd     U2260  # notequal
+0x08be     U2265  # greaterthanequal
+0x08bf     U222b  # integral
+0x08c0     U2234  # therefore
+0x08c1     U221d  # variation
+0x08c2     U221e  # infinity
+0x08c5     U2207  # nabla
+0x08c8     U223c  # approximate
+0x08c9     U2243  # similarequal
+0x08cd     U21d4  # ifonlyif
+0x08ce     U21d2  # implies
+0x08cf     U2261  # identical
+0x08d6     U221a  # radical
+0x08da     U2282  # includedin
+0x08db     U2283  # includes
+0x08dc     U2229  # intersection
+0x08dd     U222a  # union
+0x08de     U2227  # logicaland
+0x08df     U2228  # logicalor
+0x08ef     U2202  # partialderivative
+0x08f6     U0192  # function
+0x08fb     U2190  # leftarrow
+0x08fc     U2191  # uparrow
+0x08fd     U2192  # rightarrow
+0x08fe     U2193  # downarrow
+0x09df     U2422  # blank
+0x09e0     U25c6  # soliddiamond
+0x09e1     U2592  # checkerboard
+0x09e2     U2409  # ht
+0x09e3     U240c  # ff
+0x09e4     U240d  # cr
+0x09e5     U240a  # lf
+0x09e8     U2424  # nl
+0x09e9     U240b  # vt
+0x09ea     U2518  # lowrightcorner
+0x09eb     U2510  # uprightcorner
+0x09ec     U250c  # upleftcorner
+0x09ed     U2514  # lowleftcorner
+0x09ee     U253c  # crossinglines
+0x09ef     U23ba  # horizlinescan1
+0x09f0     U23bb  # horizlinescan3
+0x09f1     U2500  # horizlinescan5
+0x09f2     U23bc  # horizlinescan7
+0x09f3     U23bd  # horizlinescan9
+0x09f4     U251c  # leftt
+0x09f5     U2524  # rightt
+0x09f6     U2534  # bott
+0x09f7     U252c  # topt
+0x09f8     U2502  # vertbar
+0x0aa1     U2003  # emspace
+0x0aa2     U2002  # enspace
+0x0aa3     U2004  # em3space
+0x0aa4     U2005  # em4space
+0x0aa5     U2007  # digitspace
+0x0aa6     U2008  # punctspace
+0x0aa7     U2009  # thinspace
+0x0aa8     U200a  # hairspace
+0x0aa9     U2014  # emdash
+0x0aaa     U2013  # endash
+0x0aac     U2423  # signifblank
+0x0aae     U2026  # ellipsis
+0x0aaf     U2025  # doubbaselinedot
+0x0ab0     U2153  # onethird
+0x0ab1     U2154  # twothirds
+0x0ab2     U2155  # onefifth
+0x0ab3     U2156  # twofifths
+0x0ab4     U2157  # threefifths
+0x0ab5     U2158  # fourfifths
+0x0ab6     U2159  # onesixth
+0x0ab7     U215a  # fivesixths
+0x0ab8     U2105  # careof
+0x0abb     U2012  # figdash
+0x0abc     U2329  # leftanglebracket (not U+27E8)
+0x0abd     U002e  # decimalpoint
+0x0abe     U232a  # rightanglebracket (not U+27E9)
+0x0abf     U0000  # marker
+0x0ac3     U215b  # oneeighth
+0x0ac4     U215c  # threeeighths
+0x0ac5     U215d  # fiveeighths
+0x0ac6     U215e  # seveneighths
+0x0ac9     U2122  # trademark
+0x0aca     U2613  # signaturemark
+0x0acb     U0000  # trademarkincircle
+0x0acc     U25c1  # leftopentriangle
+0x0acd     U25b7  # rightopentriangle
+0x0ace     U25cb  # emopencircle
+0x0acf     U25af  # emopenrectangle
+0x0ad0     U2018  # leftsinglequotemark
+0x0ad1     U2019  # rightsinglequotemark
+0x0ad2     U201c  # leftdoublequotemark
+0x0ad3     U201d  # rightdoublequotemark
+0x0ad4     U211e  # prescription
+0x0ad6     U2032  # minutes
+0x0ad7     U2033  # seconds
+0x0ad9     U271d  # latincross
+0x0ada     U0000  # hexagram
+0x0adb     U25ac  # filledrectbullet
+0x0adc     U25c0  # filledlefttribullet
+0x0add     U25b6  # filledrighttribullet
+0x0ade     U25cf  # emfilledcircle
+0x0adf     U25ae  # emfilledrect
+0x0ae0     U25e6  # enopencircbullet
+0x0ae1     U25ab  # enopensquarebullet
+0x0ae2     U25ad  # openrectbullet
+0x0ae3     U25b3  # opentribulletup
+0x0ae4     U25bd  # opentribulletdown
+0x0ae5     U2606  # openstar
+0x0ae6     U2022  # enfilledcircbullet
+0x0ae7     U25aa  # enfilledsqbullet
+0x0ae8     U25b2  # filledtribulletup
+0x0ae9     U25bc  # filledtribulletdown
+0x0aea     U261c  # leftpointer
+0x0aeb     U261e  # rightpointer
+0x0aec     U2663  # club
+0x0aed     U2666  # diamond
+0x0aee     U2665  # heart
+0x0af0     U2720  # maltesecross
+0x0af1     U2020  # dagger
+0x0af2     U2021  # doubledagger
+0x0af3     U2713  # checkmark
+0x0af4     U2717  # ballotcross
+0x0af5     U266f  # musicalsharp
+0x0af6     U266d  # musicalflat
+0x0af7     U2642  # malesymbol
+0x0af8     U2640  # femalesymbol
+0x0af9     U260e  # telephone
+0x0afa     U2315  # telephonerecorder
+0x0afb     U2117  # phonographcopyright
+0x0afc     U2038  # caret
+0x0afd     U201a  # singlelowquotemark
+0x0afe     U201e  # doublelowquotemark
+0x0aff     U0000  # cursor
+0x0ba3     U003c  # leftcaret
+0x0ba6     U003e  # rightcaret
+0x0ba8     U2228  # downcaret
+0x0ba9     U2227  # upcaret
+0x0bc0     U00af  # overbar
+0x0bc2     U22a5  # downtack
+0x0bc3     U2229  # upshoe
+0x0bc4     U230a  # downstile
+0x0bc6     U005f  # underbar
+0x0bca     U2218  # jot
+0x0bcc     U2395  # quad
+0x0bce     U22a4  # uptack
+0x0bcf     U25cb  # circle
+0x0bd3     U2308  # upstile
+0x0bd6     U222a  # downshoe
+0x0bd8     U2283  # rightshoe
+0x0bda     U2282  # leftshoe
+0x0bdc     U22a2  # lefttack
+0x0bfc     U22a3  # righttack
+0x0cdf     U2017  # hebrew_doublelowline
+0x0ce0     U05d0  # hebrew_aleph
+0x0ce1     U05d1  # hebrew_bet
+0x0ce2     U05d2  # hebrew_gimel
+0x0ce3     U05d3  # hebrew_dalet
+0x0ce4     U05d4  # hebrew_he
+0x0ce5     U05d5  # hebrew_waw
+0x0ce6     U05d6  # hebrew_zain
+0x0ce7     U05d7  # hebrew_chet
+0x0ce8     U05d8  # hebrew_tet
+0x0ce9     U05d9  # hebrew_yod
+0x0cea     U05da  # hebrew_finalkaph
+0x0ceb     U05db  # hebrew_kaph
+0x0cec     U05dc  # hebrew_lamed
+0x0ced     U05dd  # hebrew_finalmem
+0x0cee     U05de  # hebrew_mem
+0x0cef     U05df  # hebrew_finalnun
+0x0cf0     U05e0  # hebrew_nun
+0x0cf1     U05e1  # hebrew_samech
+0x0cf2     U05e2  # hebrew_ayin
+0x0cf3     U05e3  # hebrew_finalpe
+0x0cf4     U05e4  # hebrew_pe
+0x0cf5     U05e5  # hebrew_finalzade
+0x0cf6     U05e6  # hebrew_zade
+0x0cf7     U05e7  # hebrew_qoph
+0x0cf8     U05e8  # hebrew_resh
+0x0cf9     U05e9  # hebrew_shin
+0x0cfa     U05ea  # hebrew_taw
+0x0da1     U0e01  # Thai_kokai
+0x0da2     U0e02  # Thai_khokhai
+0x0da3     U0e03  # Thai_khokhuat
+0x0da4     U0e04  # Thai_khokhwai
+0x0da5     U0e05  # Thai_khokhon
+0x0da6     U0e06  # Thai_khorakhang
+0x0da7     U0e07  # Thai_ngongu
+0x0da8     U0e08  # Thai_chochan
+0x0da9     U0e09  # Thai_choching
+0x0daa     U0e0a  # Thai_chochang
+0x0dab     U0e0b  # Thai_soso
+0x0dac     U0e0c  # Thai_chochoe
+0x0dad     U0e0d  # Thai_yoying
+0x0dae     U0e0e  # Thai_dochada
+0x0daf     U0e0f  # Thai_topatak
+0x0db0     U0e10  # Thai_thothan
+0x0db1     U0e11  # Thai_thonangmontho
+0x0db2     U0e12  # Thai_thophuthao
+0x0db3     U0e13  # Thai_nonen
+0x0db4     U0e14  # Thai_dodek
+0x0db5     U0e15  # Thai_totao
+0x0db6     U0e16  # Thai_thothung
+0x0db7     U0e17  # Thai_thothahan
+0x0db8     U0e18  # Thai_thothong
+0x0db9     U0e19  # Thai_nonu
+0x0dba     U0e1a  # Thai_bobaimai
+0x0dbb     U0e1b  # Thai_popla
+0x0dbc     U0e1c  # Thai_phophung
+0x0dbd     U0e1d  # Thai_fofa
+0x0dbe     U0e1e  # Thai_phophan
+0x0dbf     U0e1f  # Thai_fofan
+0x0dc0     U0e20  # Thai_phosamphao
+0x0dc1     U0e21  # Thai_moma
+0x0dc2     U0e22  # Thai_yoyak
+0x0dc3     U0e23  # Thai_rorua
+0x0dc4     U0e24  # Thai_ru
+0x0dc5     U0e25  # Thai_loling
+0x0dc6     U0e26  # Thai_lu
+0x0dc7     U0e27  # Thai_wowaen
+0x0dc8     U0e28  # Thai_sosala
+0x0dc9     U0e29  # Thai_sorusi
+0x0dca     U0e2a  # Thai_sosua
+0x0dcb     U0e2b  # Thai_hohip
+0x0dcc     U0e2c  # Thai_lochula
+0x0dcd     U0e2d  # Thai_oang
+0x0dce     U0e2e  # Thai_honokhuk
+0x0dcf     U0e2f  # Thai_paiyannoi
+0x0dd0     U0e30  # Thai_saraa
+0x0dd1     U0e31  # Thai_maihanakat
+0x0dd2     U0e32  # Thai_saraaa
+0x0dd3     U0e33  # Thai_saraam
+0x0dd4     U0e34  # Thai_sarai
+0x0dd5     U0e35  # Thai_saraii
+0x0dd6     U0e36  # Thai_saraue
+0x0dd7     U0e37  # Thai_sarauee
+0x0dd8     U0e38  # Thai_sarau
+0x0dd9     U0e39  # Thai_sarauu
+0x0dda     U0e3a  # Thai_phinthu
+0x0dde     U0e3e  # Thai_maihanakat_maitho
+0x0ddf     U0e3f  # Thai_baht
+0x0de0     U0e40  # Thai_sarae
+0x0de1     U0e41  # Thai_saraae
+0x0de2     U0e42  # Thai_sarao
+0x0de3     U0e43  # Thai_saraaimaimuan
+0x0de4     U0e44  # Thai_saraaimaimalai
+0x0de5     U0e45  # Thai_lakkhangyao
+0x0de6     U0e46  # Thai_maiyamok
+0x0de7     U0e47  # Thai_maitaikhu
+0x0de8     U0e48  # Thai_maiek
+0x0de9     U0e49  # Thai_maitho
+0x0dea     U0e4a  # Thai_maitri
+0x0deb     U0e4b  # Thai_maichattawa
+0x0dec     U0e4c  # Thai_thanthakhat
+0x0ded     U0e4d  # Thai_nikhahit
+0x0df0     U0e50  # Thai_leksun
+0x0df1     U0e51  # Thai_leknung
+0x0df2     U0e52  # Thai_leksong
+0x0df3     U0e53  # Thai_leksam
+0x0df4     U0e54  # Thai_leksi
+0x0df5     U0e55  # Thai_lekha
+0x0df6     U0e56  # Thai_lekhok
+0x0df7     U0e57  # Thai_lekchet
+0x0df8     U0e58  # Thai_lekpaet
+0x0df9     U0e59  # Thai_lekkao
+0x0ea1     U3131  # Hangul_Kiyeog
+0x0ea2     U3132  # Hangul_SsangKiyeog
+0x0ea3     U3133  # Hangul_KiyeogSios
+0x0ea4     U3134  # Hangul_Nieun
+0x0ea5     U3135  # Hangul_NieunJieuj
+0x0ea6     U3136  # Hangul_NieunHieuh
+0x0ea7     U3137  # Hangul_Dikeud
+0x0ea8     U3138  # Hangul_SsangDikeud
+0x0ea9     U3139  # Hangul_Rieul
+0x0eaa     U313a  # Hangul_RieulKiyeog
+0x0eab     U313b  # Hangul_RieulMieum
+0x0eac     U313c  # Hangul_RieulPieub
+0x0ead     U313d  # Hangul_RieulSios
+0x0eae     U313e  # Hangul_RieulTieut
+0x0eaf     U313f  # Hangul_RieulPhieuf
+0x0eb0     U3140  # Hangul_RieulHieuh
+0x0eb1     U3141  # Hangul_Mieum
+0x0eb2     U3142  # Hangul_Pieub
+0x0eb3     U3143  # Hangul_SsangPieub
+0x0eb4     U3144  # Hangul_PieubSios
+0x0eb5     U3145  # Hangul_Sios
+0x0eb6     U3146  # Hangul_SsangSios
+0x0eb7     U3147  # Hangul_Ieung
+0x0eb8     U3148  # Hangul_Jieuj
+0x0eb9     U3149  # Hangul_SsangJieuj
+0x0eba     U314a  # Hangul_Cieuc
+0x0ebb     U314b  # Hangul_Khieuq
+0x0ebc     U314c  # Hangul_Tieut
+0x0ebd     U314d  # Hangul_Phieuf
+0x0ebe     U314e  # Hangul_Hieuh
+0x0ebf     U314f  # Hangul_A
+0x0ec0     U3150  # Hangul_AE
+0x0ec1     U3151  # Hangul_YA
+0x0ec2     U3152  # Hangul_YAE
+0x0ec3     U3153  # Hangul_EO
+0x0ec4     U3154  # Hangul_E
+0x0ec5     U3155  # Hangul_YEO
+0x0ec6     U3156  # Hangul_YE
+0x0ec7     U3157  # Hangul_O
+0x0ec8     U3158  # Hangul_WA
+0x0ec9     U3159  # Hangul_WAE
+0x0eca     U315a  # Hangul_OE
+0x0ecb     U315b  # Hangul_YO
+0x0ecc     U315c  # Hangul_U
+0x0ecd     U315d  # Hangul_WEO
+0x0ece     U315e  # Hangul_WE
+0x0ecf     U315f  # Hangul_WI
+0x0ed0     U3160  # Hangul_YU
+0x0ed1     U3161  # Hangul_EU
+0x0ed2     U3162  # Hangul_YI
+0x0ed3     U3163  # Hangul_I
+0x0ed4     U11a8  # Hangul_J_Kiyeog
+0x0ed5     U11a9  # Hangul_J_SsangKiyeog
+0x0ed6     U11aa  # Hangul_J_KiyeogSios
+0x0ed7     U11ab  # Hangul_J_Nieun
+0x0ed8     U11ac  # Hangul_J_NieunJieuj
+0x0ed9     U11ad  # Hangul_J_NieunHieuh
+0x0eda     U11ae  # Hangul_J_Dikeud
+0x0edb     U11af  # Hangul_J_Rieul
+0x0edc     U11b0  # Hangul_J_RieulKiyeog
+0x0edd     U11b1  # Hangul_J_RieulMieum
+0x0ede     U11b2  # Hangul_J_RieulPieub
+0x0edf     U11b3  # Hangul_J_RieulSios
+0x0ee0     U11b4  # Hangul_J_RieulTieut
+0x0ee1     U11b5  # Hangul_J_RieulPhieuf
+0x0ee2     U11b6  # Hangul_J_RieulHieuh
+0x0ee3     U11b7  # Hangul_J_Mieum
+0x0ee4     U11b8  # Hangul_J_Pieub
+0x0ee5     U11b9  # Hangul_J_PieubSios
+0x0ee6     U11ba  # Hangul_J_Sios
+0x0ee7     U11bb  # Hangul_J_SsangSios
+0x0ee8     U11bc  # Hangul_J_Ieung
+0x0ee9     U11bd  # Hangul_J_Jieuj
+0x0eea     U11be  # Hangul_J_Cieuc
+0x0eeb     U11bf  # Hangul_J_Khieuq
+0x0eec     U11c0  # Hangul_J_Tieut
+0x0eed     U11c1  # Hangul_J_Phieuf
+0x0eee     U11c2  # Hangul_J_Hieuh
+0x0eef     U316d  # Hangul_RieulYeorinHieuh
+0x0ef0     U3171  # Hangul_SunkyeongeumMieum
+0x0ef1     U3178  # Hangul_SunkyeongeumPieub
+0x0ef2     U317f  # Hangul_PanSios
+0x0ef3     U3181  # Hangul_KkogjiDalrinIeung
+0x0ef4     U3184  # Hangul_SunkyeongeumPhieuf
+0x0ef5     U3186  # Hangul_YeorinHieuh
+0x0ef6     U318d  # Hangul_AraeA
+0x0ef7     U318e  # Hangul_AraeAE
+0x0ef8     U11eb  # Hangul_J_PanSios
+0x0ef9     U11f0  # Hangul_J_KkogjiDalrinIeung
+0x0efa     U11f9  # Hangul_J_YeorinHieuh
+0x0eff     U20a9  # Korean_Won
+0x13a4     U20ac  # Euro
+0x13bc     U0152  # OE
+0x13bd     U0153  # oe
+0x13be     U0178  # Ydiaeresis
+0x20a0     U20a0  # EcuSign
+0x20a1     U20a1  # ColonSign
+0x20a2     U20a2  # CruzeiroSign
+0x20a3     U20a3  # FFrancSign
+0x20a4     U20a4  # LiraSign
+0x20a5     U20a5  # MillSign
+0x20a6     U20a6  # NairaSign
+0x20a7     U20a7  # PesetaSign
+0x20a8     U20a8  # RupeeSign
+0x20a9     U20a9  # WonSign
+0x20aa     U20aa  # NewSheqelSign
+0x20ab     U20ab  # DongSign
+0x20ac     U20ac  # EuroSign
+0xfe50     U0300  # dead_grave
+0xfe51     U0301  # dead_acute
+0xfe52     U0302  # dead_circumflex
+0xfe53     U0303  # dead_tilde
+0xfe54     U0304  # dead_macron
+0xfe55     U0306  # dead_breve
+0xfe56     U0307  # dead_abovedot
+0xfe57     U0308  # dead_diaeresis
+0xfe58     U030a  # dead_abovering
+0xfe59     U030b  # dead_doubleacute
+0xfe5a     U030c  # dead_caron
+0xfe5b     U0327  # dead_cedilla
+0xfe5c     U0328  # dead_ogonek
+0xfe5d     U0345  # dead_iota
+0xfe5e     U3099  # dead_voiced_sound
+0xfe5f     U309a  # dead_semivoiced_sound
+0xff08     U0008  # BackSpace  /* back space, back char */
+0xff09     U0009  # Tab
+0xff0a     U000a  # Linefeed   /* Linefeed, LF */
+0xff0b     U000b  # Clear
+0xff0d     U000d  # Return     /* Return, enter */
+0xff13     U0013  # Pause      /* Pause, hold */
+0xff14     U0014  # Scroll_Lock
+0xff15     U0015  # Sys_Req
+0xff1b     U001b  # Escape
+0xff80     U0032  # KP_Space   /* space */
+0xff89     U0009  # KP_Tab
+0xff8d     U000d  # KP_Enter   /* enter */
+0xffaa     U002a  # KP_Multiply
+0xffab     U002b  # KP_Add
+0xffac     U002c  # KP_Separator       /* separator, often comma */
+0xffad     U002d  # KP_Subtract
+0xffae     U002e  # KP_Decimal
+0xffaf     U002f  # KP_Divide
+0xffb0     U0030  # KP_0
+0xffb1     U0031  # KP_1
+0xffb2     U0032  # KP_2
+0xffb3     U0033  # KP_3
+0xffb4     U0034  # KP_4
+0xffb5     U0035  # KP_5
+0xffb6     U0036  # KP_6
+0xffb7     U0037  # KP_7
+0xffb8     U0038  # KP_8
+0xffb9     U0039  # KP_9
+0xffbd     U003d  # KP_Equal   /* equals */
diff --git a/unicode/make-precompose.sh b/unicode/make-precompose.sh
new file mode 100755 (executable)
index 0000000..7c513c4
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+# $XTermId: make-precompose.sh,v 1.6 2007/02/05 01:06:36 Thomas.Wolff Exp $
+# $XFree86: xc/programs/xterm/unicode/make-precompose.sh,v 1.4 2005/03/29 04:00:32 tsi Exp $
+
+cat precompose.c.head | sed -e's/@/$/g'
+
+# extract canonical decomposition data from UnicodeData.txt,
+# pad hex values to 5 digits,
+# sort numerically on base character, then combining character,
+# then reduce to 4 digits again where possible
+cut UnicodeData.txt -d ";" -f 1,6 |
+ grep ";[0-9,A-F]" | grep " " |
+ sed -e "s/ /, 0x/;s/^/{ 0x/;s/;/, 0x/;s/$/},/" |
+ sed -e "s,0x\(....\)\([^0-9A-Fa-f]\),0x0\1\2,g" |
+ (sort -k 3 || sort +2) |
+ sed -e "s,0x0\(...[0-9A-Fa-f]\),0x\1,g"
+
+cat precompose.c.tail
diff --git a/unicode/precompose.c.head b/unicode/precompose.c.head
new file mode 100644 (file)
index 0000000..c51f752
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Canonical Compositions
+ *
+ * DO NOT EDIT BY HAND! This is generated by the script
+ * unicode/make-precompose.sh
+ */
+/* @XTermId@ */
+/* @XFree86@ */
+
+#include <precompose.h>
+
+static struct {
+  int replacement;
+  int base;
+  int comb; 
+} precompositions[] = {
diff --git a/unicode/precompose.c.tail b/unicode/precompose.c.tail
new file mode 100644 (file)
index 0000000..1f530f1
--- /dev/null
@@ -0,0 +1,26 @@
+};
+
+#define UNICODE_SHIFT 21
+
+int do_precomposition(int base, int comb) {
+  int min = 0;
+  int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
+  int mid;
+  unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb;
+  unsigned long that;
+
+  /* binary search */
+  while (max >= min) {
+    mid = (min + max) / 2;
+    that = ((unsigned) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb);
+    if (that < sought) {
+      min = mid + 1;
+    } else if (that > sought) {
+      max = mid - 1;
+    } else {
+      return precompositions[mid].replacement;
+    }
+  }
+  /* no match */
+  return -1;
+}
diff --git a/util.c b/util.c
new file mode 100644 (file)
index 0000000..c8c5667
--- /dev/null
+++ b/util.c
@@ -0,0 +1,3971 @@
+/* $XTermId: util.c,v 1.543 2011/02/09 10:11:44 tom Exp $ */
+
+/*
+ * Copyright 1999-2010,2011 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ *                         All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* util.c */
+
+#include <xterm.h>
+
+#include <data.h>
+#include <error.h>
+#include <menu.h>
+#include <fontutils.h>
+#include <xstrings.h>
+
+#include <stdio.h>
+#include <ctype.h>
+#include <assert.h>
+
+#if OPT_WIDE_CHARS
+#if defined(HAVE_WCHAR_H) && defined(HAVE_WCWIDTH)
+#include <wchar.h>
+#endif
+#include <wcwidth.h>
+#endif
+
+static int handle_translated_exposure(XtermWidget xw,
+                                     int rect_x,
+                                     int rect_y,
+                                     int rect_width,
+                                     int rect_height);
+static void ClearLeft(XtermWidget xw);
+static void CopyWait(XtermWidget xw);
+static void horizontal_copy_area(XtermWidget xw,
+                                int firstchar,
+                                int nchars,
+                                int amount);
+static void vertical_copy_area(XtermWidget xw,
+                              int firstline,
+                              int nlines,
+                              int amount);
+
+#if OPT_WIDE_CHARS
+unsigned first_widechar;
+int (*my_wcwidth) (wchar_t);
+#endif
+
+#if OPT_WIDE_CHARS
+/*
+ * We will modify the 'n' cells beginning at the current position.
+ * Some of those cells may be part of multi-column characters, including
+ * carryover from the left.  Find the limits of the multi-column characters
+ * that we should fill with blanks, return true if filling is needed.
+ */
+int
+DamagedCells(TScreen * screen, unsigned n, int *klp, int *krp, int row, int col)
+{
+    LineData *ld = getLineData(screen, row);
+    int result = False;
+
+    assert(ld);
+    if (col < (int) ld->lineSize) {
+       int nn = (int) n;
+       int kl = col;
+       int kr = col + nn;
+
+       if (kr >= ld->lineSize) {
+           nn = (ld->lineSize - col - 1);
+           kr = col + nn;
+       }
+
+       if (nn > 0) {
+           assert(kl < ld->lineSize);
+           if (ld->charData[kl] == HIDDEN_CHAR) {
+               while (kl > 0) {
+                   if (ld->charData[--kl] != HIDDEN_CHAR) {
+                       break;
+                   }
+               }
+           } else {
+               kl = col + 1;
+           }
+
+           assert(kr < (int) ld->lineSize);
+           if (ld->charData[kr] == HIDDEN_CHAR) {
+               while (kr < screen->max_col) {
+                   assert((kr + 1) < (int) ld->lineSize);
+                   if (ld->charData[++kr] != HIDDEN_CHAR) {
+                       --kr;
+                       break;
+                   }
+               }
+           } else {
+               kr = col - 1;
+           }
+
+           if (klp)
+               *klp = kl;
+           if (krp)
+               *krp = kr;
+           result = (kr >= kl);
+       }
+    }
+
+    return result;
+}
+
+int
+DamagedCurCells(TScreen * screen, unsigned n, int *klp, int *krp)
+{
+    return DamagedCells(screen, n, klp, krp, screen->cur_row, screen->cur_col);
+}
+#endif /* OPT_WIDE_CHARS */
+
+/*
+ * These routines are used for the jump scroll feature
+ */
+void
+FlushScroll(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i;
+    int shift = INX2ROW(screen, 0);
+    int bot = screen->max_row - shift;
+    int refreshtop;
+    int refreshheight;
+    int scrolltop;
+    int scrollheight;
+
+    if (screen->cursor_state)
+       HideCursor();
+    if (screen->scroll_amt > 0) {
+       refreshheight = screen->refresh_amt;
+       scrollheight = screen->bot_marg - screen->top_marg -
+           refreshheight + 1;
+       if ((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
+           (i = screen->max_row - screen->scroll_amt + 1))
+           refreshtop = i;
+       if (screen->scrollWidget
+           && !screen->whichBuf
+           && screen->top_marg == 0) {
+           scrolltop = 0;
+           if ((scrollheight += shift) > i)
+               scrollheight = i;
+           if ((i = screen->bot_marg - bot) > 0 &&
+               (refreshheight -= i) < screen->scroll_amt)
+               refreshheight = screen->scroll_amt;
+           if ((i = screen->savedlines) < screen->savelines) {
+               if ((i += screen->scroll_amt) >
+                   screen->savelines)
+                   i = screen->savelines;
+               screen->savedlines = i;
+               ScrollBarDrawThumb(screen->scrollWidget);
+           }
+       } else {
+           scrolltop = screen->top_marg + shift;
+           if ((i = bot - (screen->bot_marg - screen->refresh_amt +
+                           screen->scroll_amt)) > 0) {
+               if (bot < screen->bot_marg)
+                   refreshheight = screen->scroll_amt + i;
+           } else {
+               scrollheight += i;
+               refreshheight = screen->scroll_amt;
+               if ((i = screen->top_marg + screen->scroll_amt -
+                    1 - bot) > 0) {
+                   refreshtop += i;
+                   refreshheight -= i;
+               }
+           }
+       }
+    } else {
+       refreshheight = -screen->refresh_amt;
+       scrollheight = screen->bot_marg - screen->top_marg -
+           refreshheight + 1;
+       refreshtop = screen->top_marg + shift;
+       scrolltop = refreshtop + refreshheight;
+       if ((i = screen->bot_marg - bot) > 0)
+           scrollheight -= i;
+       if ((i = screen->top_marg + refreshheight - 1 - bot) > 0)
+           refreshheight -= i;
+    }
+    scrolling_copy_area(xw, scrolltop + screen->scroll_amt,
+                       scrollheight, screen->scroll_amt);
+    ScrollSelection(screen, -(screen->scroll_amt), False);
+    screen->scroll_amt = 0;
+    screen->refresh_amt = 0;
+    if (refreshheight > 0) {
+       ClearCurBackground(xw,
+                          (int) refreshtop * FontHeight(screen) + screen->border,
+                          (int) OriginX(screen),
+                          (unsigned) (refreshheight * FontHeight(screen)),
+                          (unsigned) Width(screen));
+       ScrnRefresh(xw, refreshtop, 0, refreshheight,
+                   MaxCols(screen), False);
+    }
+    return;
+}
+
+/*
+ * Returns true if there are lines off-screen due to scrolling which should
+ * include the current line.  If false, the line is visible and we should
+ * paint it now rather than waiting for the line to become visible.
+ */
+int
+AddToRefresh(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int amount = screen->refresh_amt;
+    int row = screen->cur_row;
+    int result;
+
+    if (amount == 0) {
+       result = 0;
+    } else if (amount > 0) {
+       int bottom;
+
+       if (row == (bottom = screen->bot_marg) - amount) {
+           screen->refresh_amt++;
+           result = 1;
+       } else {
+           result = (row >= bottom - amount + 1 && row <= bottom);
+       }
+    } else {
+       int top;
+
+       amount = -amount;
+       if (row == (top = screen->top_marg) + amount) {
+           screen->refresh_amt--;
+           result = 1;
+       } else {
+           result = (row <= top + amount - 1 && row >= top);
+       }
+    }
+
+    /*
+     * If this line is visible, and there are scrolled-off lines, flush out
+     * those which are now visible.
+     */
+    if (!result && screen->scroll_amt)
+       FlushScroll(xw);
+
+    return result;
+}
+
+/*
+ * Returns true if the current row is in the visible area (it should be for
+ * screen operations) and incidentally flush the scrolled-in lines which
+ * have newly become visible.
+ */
+static Bool
+AddToVisible(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    Bool result = False;
+
+    if (INX2ROW(screen, screen->cur_row) <= screen->max_row) {
+       if (!AddToRefresh(xw)) {
+           result = True;
+       }
+    }
+    return result;
+}
+
+/*
+ * If we're scrolling, leave the selection intact if possible.
+ * If it will bump into one of the extremes of the saved-lines, truncate that.
+ * If the selection is not contained within the scrolled region, clear it.
+ */
+static void
+adjustHiliteOnFwdScroll(XtermWidget xw, int amount, Bool all_lines)
+{
+    TScreen *screen = TScreenOf(xw);
+    int lo_row = (all_lines
+                 ? (screen->bot_marg - screen->savelines)
+                 : screen->top_marg);
+    int hi_row = screen->bot_marg;
+
+    TRACE2(("adjustSelection FWD %s by %d (%s)\n",
+           screen->whichBuf ? "alternate" : "normal",
+           amount,
+           all_lines ? "all" : "visible"));
+    TRACE2(("  before highlite %d.%d .. %d.%d\n",
+           screen->startH.row,
+           screen->startH.col,
+           screen->endH.row,
+           screen->endH.col));
+    TRACE2(("  margins %d..%d\n", screen->top_marg, screen->bot_marg));
+    TRACE2(("  limits  %d..%d\n", lo_row, hi_row));
+
+    if (screen->startH.row >= lo_row
+       && screen->startH.row - amount < lo_row) {
+       /* truncate the selection because its start would move out of region */
+       if (lo_row + amount <= screen->endH.row) {
+           TRACE2(("truncate selection by changing start %d.%d to %d.%d\n",
+                   screen->startH.row,
+                   screen->startH.col,
+                   lo_row + amount,
+                   0));
+           screen->startH.row = lo_row + amount;
+           screen->startH.col = 0;
+       } else {
+           TRACE2(("deselect because %d.%d .. %d.%d shifted %d is outside margins %d..%d\n",
+                   screen->startH.row,
+                   screen->startH.col,
+                   screen->endH.row,
+                   screen->endH.col,
+                   -amount,
+                   lo_row,
+                   hi_row));
+           ScrnDisownSelection(xw);
+       }
+    } else if (screen->startH.row <= hi_row && screen->endH.row > hi_row) {
+       ScrnDisownSelection(xw);
+    } else if (screen->startH.row < lo_row && screen->endH.row > lo_row) {
+       ScrnDisownSelection(xw);
+    }
+
+    TRACE2(("  after highlite %d.%d .. %d.%d\n",
+           screen->startH.row,
+           screen->startH.col,
+           screen->endH.row,
+           screen->endH.col));
+}
+
+/*
+ * This is the same as adjustHiliteOnFwdScroll(), but reversed.  In this case,
+ * only the visible lines are affected.
+ */
+static void
+adjustHiliteOnBakScroll(XtermWidget xw, int amount)
+{
+    TScreen *screen = TScreenOf(xw);
+    int lo_row = screen->top_marg;
+    int hi_row = screen->bot_marg;
+
+    TRACE2(("adjustSelection BAK %s by %d (%s)\n",
+           screen->whichBuf ? "alternate" : "normal",
+           amount,
+           "visible"));
+    TRACE2(("  before highlite %d.%d .. %d.%d\n",
+           screen->startH.row,
+           screen->startH.col,
+           screen->endH.row,
+           screen->endH.col));
+    TRACE2(("  margins %d..%d\n", screen->top_marg, screen->bot_marg));
+
+    if (screen->endH.row >= hi_row
+       && screen->endH.row + amount > hi_row) {
+       /* truncate the selection because its start would move out of region */
+       if (hi_row - amount >= screen->startH.row) {
+           TRACE2(("truncate selection by changing start %d.%d to %d.%d\n",
+                   screen->startH.row,
+                   screen->startH.col,
+                   hi_row - amount,
+                   0));
+           screen->endH.row = hi_row - amount;
+           screen->endH.col = 0;
+       } else {
+           TRACE2(("deselect because %d.%d .. %d.%d shifted %d is outside margins %d..%d\n",
+                   screen->startH.row,
+                   screen->startH.col,
+                   screen->endH.row,
+                   screen->endH.col,
+                   amount,
+                   lo_row,
+                   hi_row));
+           ScrnDisownSelection(xw);
+       }
+    } else if (screen->endH.row >= lo_row && screen->startH.row < lo_row) {
+       ScrnDisownSelection(xw);
+    } else if (screen->endH.row > hi_row && screen->startH.row > hi_row) {
+       ScrnDisownSelection(xw);
+    }
+
+    TRACE2(("  after highlite %d.%d .. %d.%d\n",
+           screen->startH.row,
+           screen->startH.col,
+           screen->endH.row,
+           screen->endH.col));
+}
+
+/*
+ * scrolls the screen by amount lines, erases bottom, doesn't alter
+ * cursor position (i.e. cursor moves down amount relative to text).
+ * All done within the scrolling region, of course.
+ * requires: amount > 0
+ */
+void
+xtermScroll(XtermWidget xw, int amount)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i = screen->bot_marg - screen->top_marg + 1;
+    int shift;
+    int bot;
+    int refreshtop = 0;
+    int refreshheight;
+    int scrolltop;
+    int scrollheight;
+    Boolean scroll_all_lines = (Boolean) (screen->scrollWidget
+                                         && !screen->whichBuf
+                                         && screen->top_marg == 0);
+
+    TRACE(("xtermScroll count=%d\n", amount));
+
+    screen->cursor_busy += 1;
+    screen->cursor_moved = True;
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    if (amount > i)
+       amount = i;
+
+#if OPT_SCROLL_LOCK
+    if (screen->allowScrollLock && screen->scroll_lock) {
+       refreshheight = 0;
+       screen->scroll_amt = 0;
+       screen->refresh_amt = 0;
+       if (--(screen->topline) < -screen->savelines) {
+           screen->topline = -screen->savelines;
+           screen->scroll_dirty = True;
+       }
+       if (++(screen->savedlines) > screen->savelines) {
+           screen->savedlines = screen->savelines;
+       }
+    } else
+#endif
+    {
+       if (ScrnHaveSelection(screen))
+           adjustHiliteOnFwdScroll(xw, amount, scroll_all_lines);
+
+       if (screen->jumpscroll) {
+           if (screen->scroll_amt > 0) {
+               if (!screen->fastscroll) {
+                   if (screen->refresh_amt + amount > i)
+                       FlushScroll(xw);
+               }
+               screen->scroll_amt += amount;
+               screen->refresh_amt += amount;
+           } else {
+               if (!screen->fastscroll) {
+                   if (screen->scroll_amt < 0)
+                       FlushScroll(xw);
+               }
+               screen->scroll_amt = amount;
+               screen->refresh_amt = amount;
+           }
+           refreshheight = 0;
+       } else {
+           ScrollSelection(screen, -(amount), False);
+           if (amount == i) {
+               ClearScreen(xw);
+               screen->cursor_busy -= 1;
+               return;
+           }
+
+           shift = INX2ROW(screen, 0);
+           bot = screen->max_row - shift;
+           scrollheight = i - amount;
+           refreshheight = amount;
+
+           if ((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
+               (i = screen->max_row - refreshheight + 1))
+               refreshtop = i;
+
+           if (scroll_all_lines) {
+               scrolltop = 0;
+               if ((scrollheight += shift) > i)
+                   scrollheight = i;
+               if ((i = screen->savedlines) < screen->savelines) {
+                   if ((i += amount) > screen->savelines)
+                       i = screen->savelines;
+                   screen->savedlines = i;
+                   ScrollBarDrawThumb(screen->scrollWidget);
+               }
+           } else {
+               scrolltop = screen->top_marg + shift;
+               if ((i = screen->bot_marg - bot) > 0) {
+                   scrollheight -= i;
+                   if ((i = screen->top_marg + amount - 1 - bot) >= 0) {
+                       refreshtop += i;
+                       refreshheight -= i;
+                   }
+               }
+           }
+
+           if (screen->multiscroll && amount == 1 &&
+               screen->topline == 0 && screen->top_marg == 0 &&
+               screen->bot_marg == screen->max_row) {
+               if (screen->incopy < 0 && screen->scrolls == 0)
+                   CopyWait(xw);
+               screen->scrolls++;
+           }
+
+           scrolling_copy_area(xw, scrolltop + amount, scrollheight, amount);
+
+           if (refreshheight > 0) {
+               ClearCurBackground(xw,
+                                  (int) refreshtop * FontHeight(screen) + screen->border,
+                                  (int) OriginX(screen),
+                                  (unsigned) (refreshheight * FontHeight(screen)),
+                                  (unsigned) Width(screen));
+               if (refreshheight > shift)
+                   refreshheight = shift;
+           }
+       }
+    }
+
+    if (amount > 0) {
+       if (scroll_all_lines) {
+           ScrnDeleteLine(xw,
+                          screen->saveBuf_index,
+                          screen->bot_marg + screen->savelines,
+                          0,
+                          (unsigned) amount);
+       } else {
+           ScrnDeleteLine(xw,
+                          screen->visbuf,
+                          screen->bot_marg,
+                          screen->top_marg,
+                          (unsigned) amount);
+       }
+    }
+
+    if (refreshheight > 0) {
+       ScrnRefresh(xw, refreshtop, 0, refreshheight,
+                   MaxCols(screen), False);
+    }
+
+    screen->cursor_busy -= 1;
+    return;
+}
+
+/*
+ * Reverse scrolls the screen by amount lines, erases top, doesn't alter
+ * cursor position (i.e. cursor moves up amount relative to text).
+ * All done within the scrolling region, of course.
+ * Requires: amount > 0
+ */
+void
+RevScroll(XtermWidget xw, int amount)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i = screen->bot_marg - screen->top_marg + 1;
+    int shift;
+    int bot;
+    int refreshtop;
+    int refreshheight;
+    int scrolltop;
+    int scrollheight;
+
+    TRACE(("RevScroll count=%d\n", amount));
+
+    screen->cursor_busy += 1;
+    screen->cursor_moved = True;
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    if (amount > i)
+       amount = i;
+
+    if (ScrnHaveSelection(screen))
+       adjustHiliteOnBakScroll(xw, amount);
+
+    if (screen->jumpscroll) {
+       if (screen->scroll_amt < 0) {
+           if (-screen->refresh_amt + amount > i)
+               FlushScroll(xw);
+           screen->scroll_amt -= amount;
+           screen->refresh_amt -= amount;
+       } else {
+           if (screen->scroll_amt > 0)
+               FlushScroll(xw);
+           screen->scroll_amt = -amount;
+           screen->refresh_amt = -amount;
+       }
+    } else {
+       shift = INX2ROW(screen, 0);
+       bot = screen->max_row - shift;
+       refreshheight = amount;
+       scrollheight = screen->bot_marg - screen->top_marg -
+           refreshheight + 1;
+       refreshtop = screen->top_marg + shift;
+       scrolltop = refreshtop + refreshheight;
+       if ((i = screen->bot_marg - bot) > 0)
+           scrollheight -= i;
+       if ((i = screen->top_marg + refreshheight - 1 - bot) > 0)
+           refreshheight -= i;
+
+       if (screen->multiscroll && amount == 1 &&
+           screen->topline == 0 && screen->top_marg == 0 &&
+           screen->bot_marg == screen->max_row) {
+           if (screen->incopy < 0 && screen->scrolls == 0)
+               CopyWait(xw);
+           screen->scrolls++;
+       }
+
+       scrolling_copy_area(xw, scrolltop - amount, scrollheight, -amount);
+
+       if (refreshheight > 0) {
+           ClearCurBackground(xw,
+                              (int) refreshtop * FontHeight(screen) + screen->border,
+                              (int) OriginX(screen),
+                              (unsigned) (refreshheight * FontHeight(screen)),
+                              (unsigned) Width(screen));
+       }
+    }
+    if (amount > 0) {
+       ScrnInsertLine(xw,
+                      screen->visbuf,
+                      screen->bot_marg,
+                      screen->top_marg,
+                      (unsigned) amount);
+    }
+    screen->cursor_busy -= 1;
+    return;
+}
+
+/*
+ * write a string str of length len onto the screen at
+ * the current cursor position.  update cursor position.
+ */
+void
+WriteText(XtermWidget xw, IChar * str, Cardinal len)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld = 0;
+    int fg;
+    unsigned test;
+    unsigned flags = xw->flags;
+    CellColor fg_bg = makeColorPair(xw->cur_foreground, xw->cur_background);
+    unsigned cells = visual_width(str, len);
+    GC currentGC;
+
+    TRACE(("WriteText %d (%2d,%2d) %3d:%s\n",
+          screen->topline,
+          screen->cur_row,
+          screen->cur_col,
+          len, visibleIChar(str, len)));
+
+    if (cells + (unsigned) screen->cur_col > (unsigned) MaxCols(screen)) {
+       cells = (unsigned) (MaxCols(screen) - screen->cur_col);
+    }
+
+    if (ScrnHaveSelection(screen)
+       && ScrnIsLineInSelection(screen, INX2ROW(screen, screen->cur_row))) {
+       ScrnDisownSelection(xw);
+    }
+
+    /* if we are in insert-mode, reserve space for the new cells */
+    if (flags & INSERT) {
+       InsertChar(xw, cells);
+    }
+
+    if (AddToVisible(xw)
+       && ((ld = getLineData(screen, screen->cur_row))) != 0) {
+       if (screen->cursor_state)
+           HideCursor();
+
+       /*
+        * If we overwrite part of a multi-column character, fill the rest
+        * of it with blanks.
+        */
+       if_OPT_WIDE_CHARS(screen, {
+           int kl;
+           int kr;
+           if (DamagedCurCells(screen, cells, &kl, &kr))
+               ClearInLine(xw, screen->cur_row, kl, (unsigned) (kr - kl + 1));
+       });
+
+       if (flags & INVISIBLE) {
+           Cardinal n;
+           for (n = 0; n < cells; ++n)
+               str[n] = ' ';
+       }
+
+       TRACE(("WriteText calling drawXtermText (%d) (%d,%d)\n",
+              LineCharSet(screen, ld),
+              screen->cur_col,
+              screen->cur_row));
+
+       test = flags;
+#if OPT_ISO_COLORS
+       if (screen->colorAttrMode) {
+           fg = MapToColorMode(xw->cur_foreground, screen, flags);
+       } else {
+           fg = xw->cur_foreground;
+       }
+       checkVeryBoldColors(test, fg);
+#endif
+
+       /* make sure that the correct GC is current */
+       currentGC = updatedXtermGC(xw, flags, fg_bg, False);
+
+       drawXtermText(xw, test & DRAWX_MASK, currentGC,
+                     LineCursorX(screen, ld, screen->cur_col),
+                     CursorY(screen, screen->cur_row),
+                     LineCharSet(screen, ld),
+                     str, len, 0);
+
+       resetXtermGC(xw, flags, False);
+    }
+
+    ScrnWriteText(xw, str, flags, fg_bg, len);
+    CursorForward(screen, (int) cells);
+#if OPT_ZICONBEEP
+    /* Flag icon name with "***"  on window output when iconified.
+     */
+    if (resource.zIconBeep && mapstate == IsUnmapped && !screen->zIconBeep_flagged) {
+       static char *icon_name;
+       static Arg args[] =
+       {
+           {XtNiconName, (XtArgVal) & icon_name}
+       };
+
+       icon_name = NULL;
+       XtGetValues(toplevel, args, XtNumber(args));
+
+       if (icon_name != NULL) {
+           screen->zIconBeep_flagged = True;
+           ChangeIconName(xw, icon_name);
+       }
+       xtermBell(xw, XkbBI_Info, 0);
+    }
+    mapstate = -1;
+#endif /* OPT_ZICONBEEP */
+    return;
+}
+
+/*
+ * If cursor not in scrolling region, returns.  Else,
+ * inserts n blank lines at the cursor's position.  Lines above the
+ * bottom margin are lost.
+ */
+void
+InsertLine(XtermWidget xw, int n)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i;
+    int shift;
+    int bot;
+    int refreshtop;
+    int refreshheight;
+    int scrolltop;
+    int scrollheight;
+
+    if (!ScrnIsLineInMargins(screen, screen->cur_row))
+       return;
+
+    TRACE(("InsertLine count=%d\n", n));
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    if (ScrnHaveSelection(screen)
+       && ScrnAreLinesInSelection(screen,
+                                  INX2ROW(screen, screen->top_marg),
+                                  INX2ROW(screen, screen->cur_row - 1))
+       && ScrnAreLinesInSelection(screen,
+                                  INX2ROW(screen, screen->cur_row),
+                                  INX2ROW(screen, screen->bot_marg))) {
+       ScrnDisownSelection(xw);
+    }
+
+    screen->do_wrap = False;
+    if (n > (i = screen->bot_marg - screen->cur_row + 1))
+       n = i;
+    if (screen->jumpscroll) {
+       if (screen->scroll_amt <= 0 &&
+           screen->cur_row <= -screen->refresh_amt) {
+           if (-screen->refresh_amt + n > MaxRows(screen))
+               FlushScroll(xw);
+           screen->scroll_amt -= n;
+           screen->refresh_amt -= n;
+       } else {
+           if (screen->scroll_amt)
+               FlushScroll(xw);
+       }
+    }
+    if (!screen->scroll_amt) {
+       shift = INX2ROW(screen, 0);
+       bot = screen->max_row - shift;
+       refreshheight = n;
+       scrollheight = screen->bot_marg - screen->cur_row - refreshheight + 1;
+       refreshtop = screen->cur_row + shift;
+       scrolltop = refreshtop + refreshheight;
+       if ((i = screen->bot_marg - bot) > 0)
+           scrollheight -= i;
+       if ((i = screen->cur_row + refreshheight - 1 - bot) > 0)
+           refreshheight -= i;
+       vertical_copy_area(xw, scrolltop - n, scrollheight, -n);
+       if (refreshheight > 0) {
+           ClearCurBackground(xw,
+                              (int) refreshtop * FontHeight(screen) + screen->border,
+                              (int) OriginX(screen),
+                              (unsigned) (refreshheight * FontHeight(screen)),
+                              (unsigned) Width(screen));
+       }
+    }
+    if (n > 0) {
+       ScrnInsertLine(xw,
+                      screen->visbuf,
+                      screen->bot_marg,
+                      screen->cur_row,
+                      (unsigned) n);
+    }
+}
+
+/*
+ * If cursor not in scrolling region, returns.  Else, deletes n lines
+ * at the cursor's position, lines added at bottom margin are blank.
+ */
+void
+DeleteLine(XtermWidget xw, int n)
+{
+    TScreen *screen = TScreenOf(xw);
+    int i;
+    int shift;
+    int bot;
+    int refreshtop;
+    int refreshheight;
+    int scrolltop;
+    int scrollheight;
+    Boolean scroll_all_lines = (Boolean) (screen->scrollWidget
+                                         && !screen->whichBuf
+                                         && screen->cur_row == 0);
+
+    if (!ScrnIsLineInMargins(screen, screen->cur_row))
+       return;
+
+    TRACE(("DeleteLine count=%d\n", n));
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    if (n > (i = screen->bot_marg - screen->cur_row + 1)) {
+       n = i;
+    }
+    if (ScrnHaveSelection(screen)
+       && ScrnAreLinesInSelection(screen,
+                                  INX2ROW(screen, screen->cur_row),
+                                  INX2ROW(screen, screen->cur_row + n - 1))) {
+       ScrnDisownSelection(xw);
+    }
+
+    screen->do_wrap = False;
+    if (screen->jumpscroll) {
+       if (screen->scroll_amt >= 0 && screen->cur_row == screen->top_marg) {
+           if (screen->refresh_amt + n > MaxRows(screen))
+               FlushScroll(xw);
+           screen->scroll_amt += n;
+           screen->refresh_amt += n;
+       } else {
+           if (screen->scroll_amt)
+               FlushScroll(xw);
+       }
+    }
+
+    /* adjust screen->buf */
+    if (n > 0) {
+       if (scroll_all_lines)
+           ScrnDeleteLine(xw,
+                          screen->saveBuf_index,
+                          screen->bot_marg + screen->savelines,
+                          0,
+                          (unsigned) n);
+       else
+           ScrnDeleteLine(xw,
+                          screen->visbuf,
+                          screen->bot_marg,
+                          screen->cur_row,
+                          (unsigned) n);
+    }
+
+    /* repaint the screen, as needed */
+    if (!screen->scroll_amt) {
+       shift = INX2ROW(screen, 0);
+       bot = screen->max_row - shift;
+       scrollheight = i - n;
+       refreshheight = n;
+       if ((refreshtop = screen->bot_marg - refreshheight + 1 + shift) >
+           (i = screen->max_row - refreshheight + 1))
+           refreshtop = i;
+       if (scroll_all_lines) {
+           scrolltop = 0;
+           if ((scrollheight += shift) > i)
+               scrollheight = i;
+           if ((i = screen->savedlines) < screen->savelines) {
+               if ((i += n) > screen->savelines)
+                   i = screen->savelines;
+               screen->savedlines = i;
+               ScrollBarDrawThumb(screen->scrollWidget);
+           }
+       } else {
+           scrolltop = screen->cur_row + shift;
+           if ((i = screen->bot_marg - bot) > 0) {
+               scrollheight -= i;
+               if ((i = screen->cur_row + n - 1 - bot) >= 0) {
+                   refreshheight -= i;
+               }
+           }
+       }
+       vertical_copy_area(xw, scrolltop + n, scrollheight, n);
+       if (shift > 0 && refreshheight > 0) {
+           int rows = refreshheight;
+           if (rows > shift)
+               rows = shift;
+           ScrnUpdate(xw, refreshtop, 0, rows, MaxCols(screen), True);
+           refreshtop += shift;
+           refreshheight -= shift;
+       }
+       if (refreshheight > 0) {
+           ClearCurBackground(xw,
+                              (int) refreshtop * FontHeight(screen) + screen->border,
+                              (int) OriginX(screen),
+                              (unsigned) (refreshheight * FontHeight(screen)),
+                              (unsigned) Width(screen));
+       }
+    }
+}
+
+/*
+ * Insert n blanks at the cursor's position, no wraparound
+ */
+void
+InsertChar(XtermWidget xw, unsigned n)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    unsigned limit;
+    int row = INX2ROW(screen, screen->cur_row);
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    TRACE(("InsertChar count=%d\n", n));
+
+    if (ScrnHaveSelection(screen)
+       && ScrnIsLineInSelection(screen, row)) {
+       ScrnDisownSelection(xw);
+    }
+    screen->do_wrap = False;
+
+    assert(screen->cur_col <= screen->max_col);
+    limit = (unsigned) (MaxCols(screen) - screen->cur_col);
+
+    if (n > limit)
+       n = limit;
+
+    assert(n != 0);
+    if (AddToVisible(xw)
+       && (ld = getLineData(screen, screen->cur_row)) != 0) {
+       int col = MaxCols(screen) - (int) n;
+
+       /*
+        * If we shift part of a multi-column character, fill the rest
+        * of it with blanks.  Do similar repair for the text which will
+        * be shifted into the right-margin.
+        */
+       if_OPT_WIDE_CHARS(screen, {
+           int kl;
+           int kr = screen->cur_col;
+           if (DamagedCurCells(screen, n, &kl, (int *) 0) && kr > kl) {
+               ClearInLine(xw, screen->cur_row, kl, (unsigned) (kr - kl + 1));
+           }
+           kr = screen->max_col - (int) n + 1;
+           if (DamagedCells(screen, n, &kl, (int *) 0,
+                            screen->cur_row,
+                            kr) && kr > kl) {
+               ClearInLine(xw, screen->cur_row, kl, (unsigned) (kr - kl + 1));
+           }
+       });
+
+#if OPT_DEC_CHRSET
+       if (CSET_DOUBLE(GetLineDblCS(ld))) {
+           col = MaxCols(screen) / 2 - (int) n;
+       }
+#endif
+       /*
+        * prevent InsertChar from shifting the end of a line over
+        * if it is being appended to
+        */
+       if (non_blank_line(screen, screen->cur_row,
+                          screen->cur_col, MaxCols(screen))) {
+           horizontal_copy_area(xw, screen->cur_col,
+                                col - screen->cur_col,
+                                (int) n);
+       }
+
+       ClearCurBackground(xw,
+                          CursorY(screen, screen->cur_row),
+                          LineCursorX(screen, ld, screen->cur_col),
+                          (unsigned) FontHeight(screen),
+                          n * (unsigned) LineFontWidth(screen, ld));
+    }
+    /* adjust screen->buf */
+    ScrnInsertChar(xw, n);
+}
+
+/*
+ * Deletes n chars at the cursor's position, no wraparound.
+ */
+void
+DeleteChar(XtermWidget xw, unsigned n)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    unsigned limit;
+    int row = INX2ROW(screen, screen->cur_row);
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    TRACE(("DeleteChar count=%d\n", n));
+
+    if (ScrnHaveSelection(screen)
+       && ScrnIsLineInSelection(screen, row)) {
+       ScrnDisownSelection(xw);
+    }
+    screen->do_wrap = False;
+
+    assert(screen->cur_col <= screen->max_col);
+    limit = (unsigned) (MaxCols(screen) - screen->cur_col);
+
+    if (n > limit)
+       n = limit;
+
+    assert(n != 0);
+    if (AddToVisible(xw)
+       && (ld = getLineData(screen, screen->cur_row)) != 0) {
+       int col = MaxCols(screen) - (int) n;
+
+       /*
+        * If we delete part of a multi-column character, fill the rest
+        * of it with blanks.
+        */
+       if_OPT_WIDE_CHARS(screen, {
+           int kl;
+           int kr;
+           if (DamagedCurCells(screen, n, &kl, &kr))
+               ClearInLine(xw, screen->cur_row, kl, (unsigned) (kr - kl + 1));
+       });
+
+#if OPT_DEC_CHRSET
+       if (CSET_DOUBLE(GetLineDblCS(ld))) {
+           col = MaxCols(screen) / 2 - (int) n;
+       }
+#endif
+       horizontal_copy_area(xw,
+                            (screen->cur_col + (int) n),
+                            col - screen->cur_col,
+                            -((int) n));
+
+       ClearCurBackground(xw,
+                          CursorY(screen, screen->cur_row),
+                          LineCursorX(screen, ld, col),
+                          (unsigned) FontHeight(screen),
+                          n * (unsigned) LineFontWidth(screen, ld));
+    }
+    if (n != 0) {
+       /* adjust screen->buf */
+       ScrnDeleteChar(xw, n);
+    }
+}
+
+/*
+ * Clear from cursor position to beginning of display, inclusive.
+ */
+static void
+ClearAbove(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->protected_mode != OFF_PROTECT) {
+       int row;
+       unsigned len = (unsigned) MaxCols(screen);
+
+       assert(screen->max_col >= 0);
+       for (row = 0; row <= screen->max_row; row++)
+           ClearInLine(xw, row, 0, len);
+    } else {
+       int top, height;
+
+       if (screen->cursor_state)
+           HideCursor();
+       if ((top = INX2ROW(screen, 0)) <= screen->max_row) {
+           if (screen->scroll_amt)
+               FlushScroll(xw);
+           if ((height = screen->cur_row + top) > screen->max_row)
+               height = screen->max_row + 1;
+           if ((height -= top) > 0) {
+               ClearCurBackground(xw,
+                                  top * FontHeight(screen) + screen->border,
+                                  OriginX(screen),
+                                  (unsigned) (height * FontHeight(screen)),
+                                  (unsigned) (Width(screen)));
+           }
+       }
+       ClearBufRows(xw, 0, screen->cur_row - 1);
+    }
+
+    ClearLeft(xw);
+}
+
+/*
+ * Clear from cursor position to end of display, inclusive.
+ */
+static void
+ClearBelow(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    ClearRight(xw, -1);
+
+    if (screen->protected_mode != OFF_PROTECT) {
+       int row;
+       unsigned len = (unsigned) MaxCols(screen);
+
+       assert(screen->max_col >= 0);
+       for (row = screen->cur_row + 1; row <= screen->max_row; row++)
+           ClearInLine(xw, row, 0, len);
+    } else {
+       int top;
+
+       if ((top = INX2ROW(screen, screen->cur_row)) <= screen->max_row) {
+           if (screen->scroll_amt)
+               FlushScroll(xw);
+           if (++top <= screen->max_row) {
+               ClearCurBackground(xw,
+                                  top * FontHeight(screen) + screen->border,
+                                  OriginX(screen),
+                                  (unsigned) ((screen->max_row - top + 1)
+                                              * FontHeight(screen)),
+                                  (unsigned) (Width(screen)));
+           }
+       }
+       ClearBufRows(xw, screen->cur_row + 1, screen->max_row);
+    }
+}
+
+/*
+ * Clear the given row, for the given range of columns, returning 1 if no
+ * protected characters were found, 0 otherwise.
+ */
+static int
+ClearInLine2(XtermWidget xw, int flags, int row, int col, unsigned len)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    int rc = 1;
+
+    TRACE(("ClearInLine(row=%d, col=%d, len=%d) vs %d..%d\n",
+          row, col, len,
+          screen->startH.row,
+          screen->startH.col));
+
+    if (ScrnHaveSelection(screen)
+       && ScrnIsLineInSelection(screen, row)) {
+       ScrnDisownSelection(xw);
+    }
+
+    if (col + (int) len >= MaxCols(screen)) {
+       len = (unsigned) (MaxCols(screen) - col);
+    }
+
+    /* If we've marked protected text on the screen, we'll have to
+     * check each time we do an erase.
+     */
+    if (screen->protected_mode != OFF_PROTECT) {
+       unsigned n;
+       Char *attrs = getLineData(screen, row)->attribs + col;
+       int saved_mode = screen->protected_mode;
+       Bool done;
+
+       /* disable this branch during recursion */
+       screen->protected_mode = OFF_PROTECT;
+
+       do {
+           done = True;
+           for (n = 0; n < len; n++) {
+               if (attrs[n] & PROTECTED) {
+                   rc = 0;     /* found a protected segment */
+                   if (n != 0) {
+                       ClearInLine(xw, row, col, n);
+                   }
+                   while ((n < len)
+                          && (attrs[n] & PROTECTED)) {
+                       n++;
+                   }
+                   done = False;
+                   break;
+               }
+           }
+           /* setup for another segment, past the protected text */
+           if (!done) {
+               attrs += n;
+               col += (int) n;
+               len -= n;
+           }
+       } while (!done);
+
+       screen->protected_mode = saved_mode;
+       if ((int) len <= 0) {
+           return 0;
+       }
+    }
+    /* fall through to the final non-protected segment */
+
+    if (screen->cursor_state)
+       HideCursor();
+    screen->do_wrap = False;
+
+    if (AddToVisible(xw)
+       && (ld = getLineData(screen, row)) != 0) {
+
+       ClearCurBackground(xw,
+                          CursorY(screen, row),
+                          LineCursorX(screen, ld, col),
+                          (unsigned) FontHeight(screen),
+                          len * (unsigned) LineFontWidth(screen, ld));
+    }
+
+    if (len != 0) {
+       ClearCells(xw, flags, len, row, col);
+    }
+
+    return rc;
+}
+
+int
+ClearInLine(XtermWidget xw, int row, int col, unsigned len)
+{
+    TScreen *screen = TScreenOf(xw);
+    int flags = 0;
+
+    /*
+     * If we're clearing to the end of the line, we won't count this as
+     * "drawn" characters.  We'll only do cut/paste on "drawn" characters,
+     * so this has the effect of suppressing trailing blanks from a
+     * selection.
+     */
+    if (col + (int) len < MaxCols(screen)) {
+       flags |= CHARDRAWN;
+    }
+    return ClearInLine2(xw, flags, row, col, len);
+}
+
+/*
+ * Clear the next n characters on the cursor's line, including the cursor's
+ * position.
+ */
+void
+ClearRight(XtermWidget xw, int n)
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+    unsigned len = (unsigned) (MaxCols(screen) - screen->cur_col);
+
+    assert(screen->max_col >= 0);
+    assert(screen->max_col >= screen->cur_col);
+
+    if (n < 0)                 /* the remainder of the line */
+       n = MaxCols(screen);
+    if (n == 0)                        /* default for 'ECH' */
+       n = 1;
+
+    if (len > (unsigned) n)
+       len = (unsigned) n;
+
+    ld = getLineData(screen, screen->cur_row);
+    if (AddToVisible(xw)) {
+       if_OPT_WIDE_CHARS(screen, {
+           int col = screen->cur_col;
+           int row = screen->cur_row;
+           int kl;
+           int kr;
+           int xx;
+           if (DamagedCurCells(screen, len, &kl, &kr) && kr >= kl) {
+               xx = col;
+               if (kl < xx) {
+                   ClearInLine2(xw, 0, row, kl, (unsigned) (xx - kl));
+               }
+               xx = col + (int) len - 1;
+               if (kr > xx) {
+                   ClearInLine2(xw, 0, row, xx + 1, (unsigned) (kr - xx));
+               }
+           }
+       });
+       (void) ClearInLine(xw, screen->cur_row, screen->cur_col, len);
+    } else {
+       ScrnClearCells(xw, screen->cur_row, screen->cur_col, len);
+    }
+
+    /* with the right part cleared, we can't be wrapping */
+    LineClrWrapped(ld);
+    if (screen->show_wrap_marks) {
+       ShowWrapMarks(xw, screen->cur_row, ld);
+    }
+    screen->do_wrap = False;
+}
+
+/*
+ * Clear first part of cursor's line, inclusive.
+ */
+static void
+ClearLeft(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned len = (unsigned) screen->cur_col + 1;
+
+    assert(screen->cur_col >= 0);
+    if (AddToVisible(xw)) {
+       if_OPT_WIDE_CHARS(screen, {
+           int row = screen->cur_row;
+           int kl;
+           int kr;
+           if (DamagedCurCells(screen, 1, &kl, &kr) && kr >= kl) {
+               ClearInLine2(xw, 0, row, kl, (unsigned) (kr - kl + 1));
+           }
+       });
+       (void) ClearInLine(xw, screen->cur_row, 0, len);
+    } else {
+       ScrnClearCells(xw, screen->cur_row, 0, len);
+    }
+}
+
+/*
+ * Erase the cursor's line.
+ */
+static void
+ClearLine(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    unsigned len = (unsigned) MaxCols(screen);
+
+    assert(screen->max_col >= 0);
+    (void) ClearInLine(xw, screen->cur_row, 0, len);
+}
+
+void
+ClearScreen(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    int top;
+
+    if (screen->cursor_state)
+       HideCursor();
+
+    ScrnDisownSelection(xw);
+    screen->do_wrap = False;
+    if ((top = INX2ROW(screen, 0)) <= screen->max_row) {
+       if (screen->scroll_amt)
+           FlushScroll(xw);
+       ClearCurBackground(xw,
+                          top * FontHeight(screen) + screen->border,
+                          OriginX(screen),
+                          (unsigned) ((screen->max_row - top + 1)
+                                      * FontHeight(screen)),
+                          (unsigned) Width(screen));
+    }
+    ClearBufRows(xw, 0, screen->max_row);
+}
+
+/*
+ * If we've written protected text DEC-style, and are issuing a non-DEC
+ * erase, temporarily reset the protected_mode flag so that the erase will
+ * ignore the protected flags.
+ */
+void
+do_erase_line(XtermWidget xw, int param, int mode)
+{
+    TScreen *screen = TScreenOf(xw);
+    int saved_mode = screen->protected_mode;
+
+    if (saved_mode == DEC_PROTECT
+       && saved_mode != mode) {
+       screen->protected_mode = OFF_PROTECT;
+    }
+
+    switch (param) {
+    case -1:                   /* DEFAULT */
+    case 0:
+       ClearRight(xw, -1);
+       break;
+    case 1:
+       ClearLeft(xw);
+       break;
+    case 2:
+       ClearLine(xw);
+       break;
+    }
+    screen->protected_mode = saved_mode;
+}
+
+/*
+ * Just like 'do_erase_line()', except that this intercepts ED controls.  If we
+ * clear the whole screen, we'll get the return-value from ClearInLine, and
+ * find if there were any protected characters left.  If not, reset the
+ * protected mode flag in the screen data (it's slower).
+ */
+void
+do_erase_display(XtermWidget xw, int param, int mode)
+{
+    TScreen *screen = TScreenOf(xw);
+    int saved_mode = screen->protected_mode;
+
+    if (saved_mode == DEC_PROTECT
+       && saved_mode != mode)
+       screen->protected_mode = OFF_PROTECT;
+
+    switch (param) {
+    case -1:                   /* DEFAULT */
+    case 0:
+       if (screen->cur_row == 0
+           && screen->cur_col == 0) {
+           screen->protected_mode = saved_mode;
+           do_erase_display(xw, 2, mode);
+           saved_mode = screen->protected_mode;
+       } else
+           ClearBelow(xw);
+       break;
+
+    case 1:
+       if (screen->cur_row == screen->max_row
+           && screen->cur_col == screen->max_col) {
+           screen->protected_mode = saved_mode;
+           do_erase_display(xw, 2, mode);
+           saved_mode = screen->protected_mode;
+       } else
+           ClearAbove(xw);
+       break;
+
+    case 2:
+       /*
+        * We use 'ClearScreen()' throughout the remainder of the
+        * program for places where we don't care if the characters are
+        * protected or not.  So we modify the logic around this call
+        * on 'ClearScreen()' to handle protected characters.
+        */
+       if (screen->protected_mode != OFF_PROTECT) {
+           int row;
+           int rc = 1;
+           unsigned len = (unsigned) MaxCols(screen);
+
+           assert(screen->max_col >= 0);
+           for (row = 0; row <= screen->max_row; row++)
+               rc &= ClearInLine(xw, row, 0, len);
+           if (rc != 0)
+               saved_mode = OFF_PROTECT;
+       } else {
+           ClearScreen(xw);
+       }
+       break;
+
+    case 3:
+       /* xterm addition - erase saved lines. */
+       screen->savedlines = 0;
+       ScrollBarDrawThumb(screen->scrollWidget);
+       break;
+    }
+    screen->protected_mode = saved_mode;
+}
+
+static void
+CopyWait(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    XEvent reply;
+    XEvent *rep = &reply;
+
+    for (;;) {
+       XWindowEvent(screen->display, VWindow(screen),
+                    ExposureMask, &reply);
+       switch (reply.type) {
+       case Expose:
+           HandleExposure(xw, &reply);
+           break;
+       case NoExpose:
+       case GraphicsExpose:
+           if (screen->incopy <= 0) {
+               screen->incopy = 1;
+               if (screen->scrolls > 0)
+                   screen->scrolls--;
+           }
+           if (reply.type == GraphicsExpose)
+               HandleExposure(xw, &reply);
+
+           if ((reply.type == NoExpose) ||
+               ((XExposeEvent *) rep)->count == 0) {
+               if (screen->incopy <= 0 && screen->scrolls > 0)
+                   screen->scrolls--;
+               if (screen->scrolls == 0) {
+                   screen->incopy = 0;
+                   return;
+               }
+               screen->incopy = -1;
+           }
+           break;
+       }
+    }
+}
+
+/*
+ * used by vertical_copy_area and and horizontal_copy_area
+ */
+static void
+copy_area(XtermWidget xw,
+         int src_x,
+         int src_y,
+         unsigned width,
+         unsigned height,
+         int dest_x,
+         int dest_y)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (width != 0 && height != 0) {
+       /* wait for previous CopyArea to complete unless
+          multiscroll is enabled and active */
+       if (screen->incopy && screen->scrolls == 0)
+           CopyWait(xw);
+       screen->incopy = -1;
+
+       /* save for translating Expose events */
+       screen->copy_src_x = src_x;
+       screen->copy_src_y = src_y;
+       screen->copy_width = width;
+       screen->copy_height = height;
+       screen->copy_dest_x = dest_x;
+       screen->copy_dest_y = dest_y;
+
+       XCopyArea(screen->display,
+                 VWindow(screen), VWindow(screen),
+                 NormalGC(xw, screen),
+                 src_x, src_y, width, height, dest_x, dest_y);
+    }
+}
+
+/*
+ * use when inserting or deleting characters on the current line
+ */
+static void
+horizontal_copy_area(XtermWidget xw,
+                    int firstchar,     /* char pos on screen to start copying at */
+                    int nchars,
+                    int amount)        /* number of characters to move right */
+{
+    TScreen *screen = TScreenOf(xw);
+    LineData *ld;
+
+    if ((ld = getLineData(screen, screen->cur_row)) != 0) {
+       int src_x = LineCursorX(screen, ld, firstchar);
+       int src_y = CursorY(screen, screen->cur_row);
+
+       copy_area(xw, src_x, src_y,
+                 (unsigned) (nchars * LineFontWidth(screen, ld)),
+                 (unsigned) FontHeight(screen),
+                 src_x + amount * LineFontWidth(screen, ld), src_y);
+    }
+}
+
+/*
+ * use when inserting or deleting lines from the screen
+ */
+static void
+vertical_copy_area(XtermWidget xw,
+                  int firstline,       /* line on screen to start copying at */
+                  int nlines,
+                  int amount)  /* number of lines to move up (neg=down) */
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (nlines > 0) {
+       int src_x = OriginX(screen);
+       int src_y = firstline * FontHeight(screen) + screen->border;
+
+       copy_area(xw, src_x, src_y,
+                 (unsigned) Width(screen),
+                 (unsigned) (nlines * FontHeight(screen)),
+                 src_x, src_y - amount * FontHeight(screen));
+       if (screen->show_wrap_marks) {
+           LineData *ld;
+           int row;
+           for (row = firstline; row < firstline + nlines; ++row) {
+               if ((ld = getLineData(screen, row)) != 0) {
+                   ShowWrapMarks(xw, row, ld);
+               }
+           }
+       }
+    }
+}
+
+/*
+ * use when scrolling the entire screen
+ */
+void
+scrolling_copy_area(XtermWidget xw,
+                   int firstline,      /* line on screen to start copying at */
+                   int nlines,
+                   int amount) /* number of lines to move up (neg=down) */
+{
+
+    if (nlines > 0) {
+       vertical_copy_area(xw, firstline, nlines, amount);
+    }
+}
+
+/*
+ * Handler for Expose events on the VT widget.
+ * Returns 1 iff the area where the cursor was got refreshed.
+ */
+int
+HandleExposure(XtermWidget xw, XEvent * event)
+{
+    TScreen *screen = TScreenOf(xw);
+    XExposeEvent *reply = (XExposeEvent *) event;
+
+#ifndef NO_ACTIVE_ICON
+    if (reply->window == screen->iconVwin.window) {
+       WhichVWin(screen) = &screen->iconVwin;
+       TRACE(("HandleExposure - icon"));
+    } else {
+       WhichVWin(screen) = &screen->fullVwin;
+       TRACE(("HandleExposure - normal"));
+    }
+    TRACE((" event %d,%d %dx%d\n",
+          reply->y,
+          reply->x,
+          reply->height,
+          reply->width));
+#endif /* NO_ACTIVE_ICON */
+
+    /* if not doing CopyArea or if this is a GraphicsExpose, don't translate */
+    if (!screen->incopy || event->type != Expose)
+       return handle_translated_exposure(xw, reply->x, reply->y,
+                                         reply->width,
+                                         reply->height);
+    else {
+       /* compute intersection of area being copied with
+          area being exposed. */
+       int both_x1 = Max(screen->copy_src_x, reply->x);
+       int both_y1 = Max(screen->copy_src_y, reply->y);
+       int both_x2 = Min(screen->copy_src_x + (int) screen->copy_width,
+                         (reply->x + (int) reply->width));
+       int both_y2 = Min(screen->copy_src_y + (int) screen->copy_height,
+                         (reply->y + (int) reply->height));
+       int value = 0;
+
+       /* was anything copied affected? */
+       if (both_x2 > both_x1 && both_y2 > both_y1) {
+           /* do the copied area */
+           value = handle_translated_exposure
+               (xw, reply->x + screen->copy_dest_x - screen->copy_src_x,
+                reply->y + screen->copy_dest_y - screen->copy_src_y,
+                reply->width, reply->height);
+       }
+       /* was anything not copied affected? */
+       if (reply->x < both_x1 || reply->y < both_y1
+           || reply->x + reply->width > both_x2
+           || reply->y + reply->height > both_y2)
+           value = handle_translated_exposure(xw, reply->x, reply->y,
+                                              reply->width, reply->height);
+
+       return value;
+    }
+}
+
+static void
+set_background(XtermWidget xw, int color GCC_UNUSED)
+{
+    TScreen *screen = TScreenOf(xw);
+    Pixel c = getXtermBackground(xw, xw->flags, color);
+
+    TRACE(("set_background(%d) %#lx\n", color, c));
+    XSetWindowBackground(screen->display, VShellWindow(xw), c);
+    XSetWindowBackground(screen->display, VWindow(screen), c);
+}
+
+/*
+ * Called by the ExposeHandler to do the actual repaint after the coordinates
+ * have been translated to allow for any CopyArea in progress.
+ * The rectangle passed in is pixel coordinates.
+ */
+static int
+handle_translated_exposure(XtermWidget xw,
+                          int rect_x,
+                          int rect_y,
+                          int rect_width,
+                          int rect_height)
+{
+    TScreen *screen = TScreenOf(xw);
+    int toprow, leftcol, nrows, ncols;
+    int x0, x1;
+    int y0, y1;
+    int result = 0;
+
+    TRACE(("handle_translated_exposure at %d,%d size %dx%d\n",
+          rect_y, rect_x, rect_height, rect_width));
+
+    x0 = (rect_x - OriginX(screen));
+    x1 = (x0 + rect_width);
+
+    y0 = (rect_y - OriginY(screen));
+    y1 = (y0 + rect_height);
+
+    if ((x0 < 0 ||
+        y0 < 0 ||
+        x1 > Width(screen) ||
+        y1 > Height(screen))) {
+       set_background(xw, -1);
+       XClearArea(screen->display, VWindow(screen),
+                  rect_x,
+                  rect_y,
+                  (unsigned) rect_width,
+                  (unsigned) rect_height, False);
+    }
+    toprow = y0 / FontHeight(screen);
+    if (toprow < 0)
+       toprow = 0;
+
+    leftcol = x0 / FontWidth(screen);
+    if (leftcol < 0)
+       leftcol = 0;
+
+    nrows = (y1 - 1) / FontHeight(screen) - toprow + 1;
+    ncols = (x1 - 1) / FontWidth(screen) - leftcol + 1;
+    toprow -= screen->scrolls;
+    if (toprow < 0) {
+       nrows += toprow;
+       toprow = 0;
+    }
+    if (toprow + nrows > MaxRows(screen))
+       nrows = MaxRows(screen) - toprow;
+    if (leftcol + ncols > MaxCols(screen))
+       ncols = MaxCols(screen) - leftcol;
+
+    if (nrows > 0 && ncols > 0) {
+       ScrnRefresh(xw, toprow, leftcol, nrows, ncols, True);
+       first_map_occurred();
+       if (screen->cur_row >= toprow &&
+           screen->cur_row < toprow + nrows &&
+           screen->cur_col >= leftcol &&
+           screen->cur_col < leftcol + ncols) {
+           result = 1;
+       }
+
+    }
+    TRACE(("...handle_translated_exposure %d\n", result));
+    return (result);
+}
+
+/***====================================================================***/
+
+void
+GetColors(XtermWidget xw, ScrnColors * pColors)
+{
+    TScreen *screen = TScreenOf(xw);
+    int n;
+
+    pColors->which = 0;
+    for (n = 0; n < NCOLORS; ++n) {
+       SET_COLOR_VALUE(pColors, n, T_COLOR(screen, n));
+    }
+}
+
+void
+ChangeColors(XtermWidget xw, ScrnColors * pNew)
+{
+    Bool repaint = False;
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+
+    TRACE(("ChangeColors\n"));
+
+    if (COLOR_DEFINED(pNew, TEXT_CURSOR)) {
+       T_COLOR(screen, TEXT_CURSOR) = COLOR_VALUE(pNew, TEXT_CURSOR);
+       TRACE(("... TEXT_CURSOR: %#lx\n", T_COLOR(screen, TEXT_CURSOR)));
+       /* no repaint needed */
+    } else if ((T_COLOR(screen, TEXT_CURSOR) == T_COLOR(screen, TEXT_FG)) &&
+              (COLOR_DEFINED(pNew, TEXT_FG))) {
+       if (T_COLOR(screen, TEXT_CURSOR) != COLOR_VALUE(pNew, TEXT_FG)) {
+           T_COLOR(screen, TEXT_CURSOR) = COLOR_VALUE(pNew, TEXT_FG);
+           TRACE(("... TEXT_CURSOR: %#lx\n", T_COLOR(screen, TEXT_CURSOR)));
+           if (screen->Vshow)
+               repaint = True;
+       }
+    }
+
+    if (COLOR_DEFINED(pNew, TEXT_FG)) {
+       Pixel fg = COLOR_VALUE(pNew, TEXT_FG);
+       T_COLOR(screen, TEXT_FG) = fg;
+       TRACE(("... TEXT_FG: %#lx\n", T_COLOR(screen, TEXT_FG)));
+       if (screen->Vshow) {
+           setCgsFore(xw, win, gcNorm, fg);
+           setCgsBack(xw, win, gcNormReverse, fg);
+           setCgsFore(xw, win, gcBold, fg);
+           setCgsBack(xw, win, gcBoldReverse, fg);
+           repaint = True;
+       }
+    }
+
+    if (COLOR_DEFINED(pNew, TEXT_BG)) {
+       Pixel bg = COLOR_VALUE(pNew, TEXT_BG);
+       T_COLOR(screen, TEXT_BG) = bg;
+       TRACE(("... TEXT_BG: %#lx\n", T_COLOR(screen, TEXT_BG)));
+       if (screen->Vshow) {
+           setCgsBack(xw, win, gcNorm, bg);
+           setCgsFore(xw, win, gcNormReverse, bg);
+           setCgsBack(xw, win, gcBold, bg);
+           setCgsFore(xw, win, gcBoldReverse, bg);
+           set_background(xw, -1);
+           repaint = True;
+       }
+    }
+#if OPT_HIGHLIGHT_COLOR
+    if (COLOR_DEFINED(pNew, HIGHLIGHT_BG)) {
+       if (T_COLOR(screen, HIGHLIGHT_BG) != COLOR_VALUE(pNew, HIGHLIGHT_BG)) {
+           T_COLOR(screen, HIGHLIGHT_BG) = COLOR_VALUE(pNew, HIGHLIGHT_BG);
+           TRACE(("... HIGHLIGHT_BG: %#lx\n", T_COLOR(screen, HIGHLIGHT_BG)));
+           if (screen->Vshow)
+               repaint = True;
+       }
+    }
+    if (COLOR_DEFINED(pNew, HIGHLIGHT_FG)) {
+       if (T_COLOR(screen, HIGHLIGHT_FG) != COLOR_VALUE(pNew, HIGHLIGHT_FG)) {
+           T_COLOR(screen, HIGHLIGHT_FG) = COLOR_VALUE(pNew, HIGHLIGHT_FG);
+           TRACE(("... HIGHLIGHT_FG: %#lx\n", T_COLOR(screen, HIGHLIGHT_FG)));
+           if (screen->Vshow)
+               repaint = True;
+       }
+    }
+#endif
+
+    if (COLOR_DEFINED(pNew, MOUSE_FG) || (COLOR_DEFINED(pNew, MOUSE_BG))) {
+       if (COLOR_DEFINED(pNew, MOUSE_FG)) {
+           T_COLOR(screen, MOUSE_FG) = COLOR_VALUE(pNew, MOUSE_FG);
+           TRACE(("... MOUSE_FG: %#lx\n", T_COLOR(screen, MOUSE_FG)));
+       }
+       if (COLOR_DEFINED(pNew, MOUSE_BG)) {
+           T_COLOR(screen, MOUSE_BG) = COLOR_VALUE(pNew, MOUSE_BG);
+           TRACE(("... MOUSE_BG: %#lx\n", T_COLOR(screen, MOUSE_BG)));
+       }
+
+       if (screen->Vshow) {
+           recolor_cursor(screen,
+                          screen->pointer_cursor,
+                          T_COLOR(screen, MOUSE_FG),
+                          T_COLOR(screen, MOUSE_BG));
+           XDefineCursor(screen->display, VWindow(screen),
+                         screen->pointer_cursor);
+       }
+#if OPT_TEK4014
+       if (TEK4014_SHOWN(xw)) {
+           TekScreen *tekscr = TekScreenOf(tekWidget);
+           Window tekwin = TWindow(tekscr);
+           if (tekwin) {
+               recolor_cursor(screen,
+                              tekscr->arrow,
+                              T_COLOR(screen, MOUSE_FG),
+                              T_COLOR(screen, MOUSE_BG));
+               XDefineCursor(screen->display, tekwin, tekscr->arrow);
+           }
+       }
+#endif
+       /* no repaint needed */
+    }
+
+    if (COLOR_DEFINED(pNew, TEXT_FG) ||
+       COLOR_DEFINED(pNew, TEXT_BG) ||
+       COLOR_DEFINED(pNew, TEXT_CURSOR)) {
+       if (set_cursor_gcs(xw) && screen->Vshow) {
+           repaint = True;
+       }
+    }
+#if OPT_TEK4014
+    if (COLOR_DEFINED(pNew, TEK_FG) ||
+       COLOR_DEFINED(pNew, TEK_BG)) {
+       ChangeTekColors(tekWidget, screen, pNew);
+       if (TEK4014_SHOWN(xw)) {
+           TekRepaint(tekWidget);
+       }
+    } else if (COLOR_DEFINED(pNew, TEK_CURSOR)) {
+       ChangeTekColors(tekWidget, screen, pNew);
+    }
+#endif
+    if (repaint)
+       xtermRepaint(xw);
+}
+
+void
+xtermClear(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("xtermClear\n"));
+    XClearWindow(screen->display, VWindow(screen));
+}
+
+void
+xtermRepaint(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("xtermRepaint\n"));
+    xtermClear(xw);
+    ScrnRefresh(xw, 0, 0, MaxRows(screen), MaxCols(screen), True);
+}
+
+/***====================================================================***/
+
+Boolean
+isDefaultForeground(const char *name)
+{
+    return (Boolean) ! x_strcasecmp(name, XtDefaultForeground);
+}
+
+Boolean
+isDefaultBackground(const char *name)
+{
+    return (Boolean) ! x_strcasecmp(name, XtDefaultBackground);
+}
+
+#if OPT_WIDE_CHARS
+/*
+ * Check for Unicode BIDI control characters, which may be miscategorized via
+ * wcwidth() and iswprint() as zero-width printable characters.
+ */
+Boolean
+isWideControl(unsigned ch)
+{
+    Boolean result;
+
+    switch (ch) {
+    case 0x200E:
+    case 0x200F:
+    case 0x202A:
+    case 0x202B:
+    case 0x202C:
+    case 0x202D:
+    case 0x202E:
+       result = True;
+       break;
+    default:
+       result = False;
+       break;
+    }
+    return result;
+}
+#endif
+
+/***====================================================================***/
+
+typedef struct {
+    Pixel fg;
+    Pixel bg;
+} ToSwap;
+
+#if OPT_HIGHLIGHT_COLOR
+#define hc_param ,Bool hilite_color
+#define hc_value ,screen->hilite_color
+#else
+#define hc_param               /* nothing */
+#define hc_value               /* nothing */
+#endif
+
+/*
+ * Use this to swap the foreground/background color values in the resource
+ * data, and to build up a list of the pairs which must be swapped in the
+ * GC cache.
+ */
+static void
+swapLocally(ToSwap * list, int *count, ColorRes * fg, ColorRes * bg hc_param)
+{
+    ColorRes tmp;
+    int n;
+    Boolean found = False;
+
+#if OPT_COLOR_RES
+    Pixel fg_color = fg->value;
+    Pixel bg_color = bg->value;
+#else
+    Pixel fg_color = *fg;
+    Pixel bg_color = *bg;
+#endif
+
+#if OPT_HIGHLIGHT_COLOR
+    if ((fg_color != bg_color) || !hilite_color)
+#endif
+    {
+       EXCHANGE(*fg, *bg, tmp);
+       for (n = 0; n < *count; ++n) {
+           if ((list[n].fg == fg_color && list[n].bg == bg_color)
+               || (list[n].fg == bg_color && list[n].bg == fg_color)) {
+               found = True;
+               break;
+           }
+       }
+       if (!found) {
+           list[*count].fg = fg_color;
+           list[*count].bg = bg_color;
+           *count = *count + 1;
+           TRACE(("swapLocally fg %#lx, bg %#lx ->%d\n",
+                  fg_color, bg_color, *count));
+       }
+    }
+}
+
+static void
+reallySwapColors(XtermWidget xw, ToSwap * list, int count)
+{
+    int j, k;
+
+    TRACE(("reallySwapColors\n"));
+    for (j = 0; j < count; ++j) {
+       for_each_text_gc(k) {
+           redoCgs(xw, list[j].fg, list[j].bg, (CgsEnum) k);
+       }
+    }
+}
+
+static void
+swapVTwinGCs(XtermWidget xw, VTwin * win)
+{
+    swapCgs(xw, win, gcNorm, gcNormReverse);
+    swapCgs(xw, win, gcBold, gcBoldReverse);
+}
+
+void
+ReverseVideo(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    ToSwap listToSwap[5];
+    int numToSwap = 0;
+
+    TRACE(("ReverseVideo\n"));
+
+    /*
+     * Swap SGR foreground and background colors.  By convention, these are
+     * the colors assigned to "black" (SGR #0) and "white" (SGR #7).  Also,
+     * SGR #8 and SGR #15 are the bold (or bright) versions of SGR #0 and
+     * #7, respectively.
+     *
+     * We don't swap colors that happen to match the screen's foreground
+     * and background because that tends to produce bizarre effects.
+     */
+#define swapAnyColor(name,a,b) swapLocally(listToSwap, &numToSwap, &(screen->name[a]), &(screen->name[b]) hc_value)
+#define swapAColor(a,b) swapAnyColor(Acolors, a, b)
+    if_OPT_ISO_COLORS(screen, {
+       swapAColor(0, 7);
+       swapAColor(8, 15);
+    });
+
+    if (T_COLOR(screen, TEXT_CURSOR) == T_COLOR(screen, TEXT_FG))
+       T_COLOR(screen, TEXT_CURSOR) = T_COLOR(screen, TEXT_BG);
+
+#define swapTColor(a,b) swapAnyColor(Tcolors, a, b)
+    swapTColor(TEXT_FG, TEXT_BG);
+    swapTColor(MOUSE_FG, MOUSE_BG);
+
+    reallySwapColors(xw, listToSwap, numToSwap);
+
+    swapVTwinGCs(xw, &(screen->fullVwin));
+#ifndef NO_ACTIVE_ICON
+    swapVTwinGCs(xw, &(screen->iconVwin));
+#endif /* NO_ACTIVE_ICON */
+
+    xw->misc.re_verse = (Boolean) ! xw->misc.re_verse;
+
+    if (XtIsRealized((Widget) xw)) {
+       xtermDisplayCursor(xw);
+    }
+#if OPT_TEK4014
+    if (TEK4014_SHOWN(xw)) {
+       TekScreen *tekscr = TekScreenOf(tekWidget);
+       Window tekwin = TWindow(tekscr);
+       recolor_cursor(screen,
+                      tekscr->arrow,
+                      T_COLOR(screen, MOUSE_FG),
+                      T_COLOR(screen, MOUSE_BG));
+       XDefineCursor(screen->display, tekwin, tekscr->arrow);
+    }
+#endif
+
+    if (screen->scrollWidget)
+       ScrollBarReverseVideo(screen->scrollWidget);
+
+    if (XtIsRealized((Widget) xw)) {
+       set_background(xw, -1);
+    }
+#if OPT_TEK4014
+    TekReverseVideo(tekWidget);
+#endif
+    if (XtIsRealized((Widget) xw)) {
+       xtermRepaint(xw);
+    }
+#if OPT_TEK4014
+    if (TEK4014_SHOWN(xw)) {
+       TekRepaint(tekWidget);
+    }
+#endif
+    ReverseOldColors();
+    set_cursor_gcs(xw);
+    update_reversevideo();
+    TRACE(("...ReverseVideo\n"));
+}
+
+void
+recolor_cursor(TScreen * screen,
+              Cursor cursor,   /* X cursor ID to set */
+              unsigned long fg,        /* pixel indexes to look up */
+              unsigned long bg)        /* pixel indexes to look up */
+{
+    Display *dpy = screen->display;
+    XColor colordefs[2];       /* 0 is foreground, 1 is background */
+
+    colordefs[0].pixel = fg;
+    colordefs[1].pixel = bg;
+    XQueryColors(dpy, DefaultColormap(dpy, DefaultScreen(dpy)),
+                colordefs, 2);
+    XRecolorCursor(dpy, cursor, colordefs, colordefs + 1);
+    return;
+}
+
+#if OPT_RENDERFONT
+static XftColor *
+getXftColor(XtermWidget xw, Pixel pixel)
+{
+#define CACHE_SIZE  4
+    static struct {
+       XftColor color;
+       int use;
+    } cache[CACHE_SIZE];
+    static int use;
+    int i;
+    int oldest, oldestuse;
+    XColor color;
+
+    oldestuse = 0x7fffffff;
+    oldest = 0;
+    for (i = 0; i < CACHE_SIZE; i++) {
+       if (cache[i].use) {
+           if (cache[i].color.pixel == pixel) {
+               cache[i].use = ++use;
+               return &cache[i].color;
+           }
+       }
+       if (cache[i].use < oldestuse) {
+           oldestuse = cache[i].use;
+           oldest = i;
+       }
+    }
+    i = oldest;
+    color.pixel = pixel;
+    XQueryColor(TScreenOf(xw)->display, xw->core.colormap, &color);
+    cache[i].color.color.red = color.red;
+    cache[i].color.color.green = color.green;
+    cache[i].color.color.blue = color.blue;
+    cache[i].color.color.alpha = 0xffff;
+    cache[i].color.pixel = pixel;
+    cache[i].use = ++use;
+    return &cache[i].color;
+}
+
+/*
+ * The cell-width is related to, but not the same as the wide-character width.
+ * We will only get useful values from wcwidth() for codes above 255.
+ * Otherwise, interpret according to internal data.
+ */
+#if OPT_RENDERWIDE
+
+#if OPT_C1_PRINT
+#define XtermCellWidth(xw, ch) \
+       (((ch) == 0 || (ch) == 127) \
+         ? 0 \
+         : (((ch) < 256) \
+             ? (((ch) >= 128 && (ch) < 160) \
+                 ? (TScreenOf(xw)->c1_printable ? 1 : 0) \
+                 : 1) \
+             : my_wcwidth(ch)))
+#else
+#define XtermCellWidth(xw, ch) \
+       (((ch) == 0 || (ch) == 127) \
+         ? 0 \
+         : (((ch) < 256) \
+             ? 1 \
+             : my_wcwidth(ch)))
+#endif
+
+#endif /* OPT_RENDERWIDE */
+
+#define XFT_FONT(name) screen->name.font
+
+#if OPT_ISO_COLORS
+#define UseBoldFont(screen) (!(screen)->colorBDMode || ((screen)->veryBoldColors & BOLD))
+#else
+#define UseBoldFont(screen) 1
+#endif
+/*
+ * fontconfig/Xft combination prior to 2.2 has a problem with
+ * CJK truetype 'double-width' (bi-width/monospace) fonts leading
+ * to the 's p a c e d o u t' rendering. Consequently, we can't
+ * rely on XftDrawString8/16  when one of  those fonts is used.
+ * Instead, we need to roll out our own using XftDrawCharSpec.
+ * A patch in the same spirit (but in a rather different form)
+ * was applied to gnome vte and gtk2 port of vim.
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=196312
+ */
+static int
+xtermXftDrawString(XtermWidget xw,
+                  unsigned flags GCC_UNUSED,
+                  XftColor * color,
+                  XftFont * font,
+                  int x,
+                  int y,
+                  IChar * text,
+                  Cardinal len,
+                  Bool really)
+{
+    TScreen *screen = TScreenOf(xw);
+    int ncells = 0;
+
+    if (len != 0) {
+#if OPT_RENDERWIDE
+       XftCharSpec *sbuf;
+       XftFont *wfont;
+       Cardinal src, dst;
+       XftFont *lastFont = 0;
+       XftFont *currFont = 0;
+       Cardinal start = 0;
+       int charWidth;
+       int fontnum = screen->menu_font_number;
+       int fwidth = FontWidth(screen);
+
+#if OPT_ISO_COLORS
+       if ((flags & UNDERLINE)
+           && !screen->colorULMode
+           && screen->italicULMode
+           && XFT_FONT(renderWideItal[fontnum])) {
+           wfont = XFT_FONT(renderWideItal[fontnum]);
+       } else
+#endif
+           if ((flags & BOLDATTR(screen))
+               && UseBoldFont(screen)
+               && XFT_FONT(renderWideBold[fontnum])) {
+           wfont = XFT_FONT(renderWideBold[fontnum]);
+       } else {
+           wfont = XFT_FONT(renderWideNorm[fontnum]);
+       }
+
+       BumpTypedBuffer(XftCharSpec, len);
+       sbuf = BfBuf(XftCharSpec);
+
+       for (src = dst = 0; src < len; src++) {
+           FcChar32 wc = *text++;
+
+           charWidth = XtermCellWidth(xw, (wchar_t) wc);
+           if (charWidth < 0)
+               continue;
+
+           sbuf[dst].ucs4 = wc;
+           sbuf[dst].x = (short) (x + fwidth * ncells);
+           sbuf[dst].y = (short) (y);
+
+           currFont = (charWidth == 2 && wfont != 0) ? wfont : font;
+           ncells += charWidth;
+
+           if (lastFont != currFont) {
+               if ((lastFont != 0) && really) {
+                   XftDrawCharSpec(screen->renderDraw,
+                                   color,
+                                   lastFont,
+                                   sbuf + start,
+                                   (int) (dst - start));
+               }
+               start = dst;
+               lastFont = currFont;
+           }
+           ++dst;
+       }
+       if ((dst != start) && really) {
+           XftDrawCharSpec(screen->renderDraw,
+                           color,
+                           lastFont,
+                           sbuf + start,
+                           (int) (dst - start));
+       }
+#else /* !OPT_RENDERWIDE */
+       if (really) {
+           XftChar8 *buffer;
+           int dst;
+
+           BumpTypedBuffer(XftChar8, len);
+           buffer = BfBuf(XftChar8);
+
+           for (dst = 0; dst < (int) len; ++dst)
+               buffer[dst] = CharOf(text[dst]);
+
+           XftDrawString8(screen->renderDraw,
+                          color,
+                          font,
+                          x, y, buffer, (int) len);
+       }
+       ncells = (int) len;
+#endif
+    }
+    return ncells;
+}
+#define xtermXftWidth(xw, flags, color, font, x, y, chars, len) \
+   xtermXftDrawString(xw, flags, color, font, x, y, chars, len, False)
+#endif /* OPT_RENDERFONT */
+
+#if OPT_WIDE_CHARS
+/*
+ * Map characters commonly "fixed" by groff back to their ASCII equivalents.
+ * Also map other useful equivalents.
+ */
+unsigned
+AsciiEquivs(unsigned ch)
+{
+    switch (ch) {
+    case 0x2010:               /* groff "-" */
+    case 0x2011:
+    case 0x2012:
+    case 0x2013:
+    case 0x2014:
+    case 0x2015:
+    case 0x2212:               /* groff "\-" */
+       ch = '-';
+       break;
+    case 0x2018:               /* groff "`" */
+       ch = '`';
+       break;
+    case 0x2019:               /* groff ' */
+       ch = '\'';
+       break;
+    case 0x201C:               /* groff lq */
+    case 0x201D:               /* groff rq */
+       ch = '"';
+       break;
+    case 0x2329:               /* groff ".URL" */
+       ch = '<';
+       break;
+    case 0x232a:               /* groff ".URL" */
+       ch = '>';
+       break;
+    default:
+       if (ch >= 0xff01 && ch <= 0xff5e) {
+           /* "Fullwidth" codes (actually double-width) */
+           ch -= 0xff00;
+           ch += ANSI_SPA;
+           break;
+       }
+    }
+    return ch;
+}
+
+/*
+ * Actually this should be called "groff_workaround()" - for the places where
+ * groff stomps on compatibility.  Still, if enough people get used to it,
+ * this might someday become a quasi-standard.
+ */
+static int
+ucs_workaround(XtermWidget xw,
+              unsigned ch,
+              unsigned flags,
+              GC gc,
+              int x,
+              int y,
+              int chrset,
+              int on_wide)
+{
+    TScreen *screen = TScreenOf(xw);
+    int fixed = False;
+
+    if (screen->wide_chars && screen->utf8_mode && ch > 256) {
+       IChar eqv = (IChar) AsciiEquivs(ch);
+
+       if (eqv != (IChar) ch) {
+           int width = my_wcwidth((int) ch);
+
+           do {
+               drawXtermText(xw,
+                             flags,
+                             gc,
+                             x,
+                             y,
+                             chrset,
+                             &eqv,
+                             1,
+                             on_wide);
+               x += FontWidth(screen);
+               eqv = '?';
+           } while (width-- > 1);
+
+           fixed = True;
+       } else if (ch == HIDDEN_CHAR) {
+           fixed = True;
+       }
+    }
+    return fixed;
+}
+#endif
+
+/*
+ * Use this when the characters will not fill the cell area properly.  Fill the
+ * area where we'll write the characters, otherwise we'll get gaps between
+ * them, e.g., in the original background color.
+ *
+ * The cursor is a special case, because the XFillRectangle call only uses the
+ * foreground, while we've set the cursor color in the background.  So we need
+ * a special GC for that.
+ */
+static void
+xtermFillCells(XtermWidget xw,
+              unsigned flags,
+              GC gc,
+              int x,
+              int y,
+              Cardinal len)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *currentWin = WhichVWin(screen);
+
+    if (!(flags & NOBACKGROUND)) {
+       CgsEnum srcId = getCgsId(xw, currentWin, gc);
+       CgsEnum dstId = gcMAX;
+       Pixel fg = getCgsFore(xw, currentWin, gc);
+       Pixel bg = getCgsBack(xw, currentWin, gc);
+
+       switch (srcId) {
+       case gcVTcursNormal:
+       case gcVTcursReverse:
+           dstId = gcVTcursOutline;
+           break;
+       case gcVTcursFilled:
+       case gcVTcursOutline:
+           /* FIXME */
+           break;
+       case gcNorm:
+           dstId = gcNormReverse;
+           break;
+       case gcNormReverse:
+           dstId = gcNorm;
+           break;
+       case gcBold:
+           dstId = gcBoldReverse;
+           break;
+       case gcBoldReverse:
+           dstId = gcBold;
+           break;
+#if OPT_BOX_CHARS
+       case gcLine:
+       case gcDots:
+           /* FIXME */
+           break;
+#endif
+#if OPT_DEC_CHRSET
+       case gcCNorm:
+       case gcCBold:
+           /* FIXME */
+           break;
+#endif
+#if OPT_WIDE_CHARS
+       case gcWide:
+           dstId = gcWideReverse;
+           break;
+       case gcWBold:
+           dstId = gcBoldReverse;
+           break;
+       case gcWideReverse:
+       case gcWBoldReverse:
+           /* FIXME */
+           break;
+#endif
+#if OPT_TEK4014
+       case gcTKcurs:
+           /* FIXME */
+           break;
+#endif
+       case gcMAX:
+           break;
+       }
+
+       if (dstId != gcMAX) {
+           setCgsFore(xw, currentWin, dstId, bg);
+           setCgsBack(xw, currentWin, dstId, fg);
+
+           XFillRectangle(screen->display, VWindow(screen),
+                          getCgsGC(xw, currentWin, dstId),
+                          x, y,
+                          len * (Cardinal) FontWidth(screen),
+                          (unsigned) FontHeight(screen));
+       }
+    }
+}
+
+#if OPT_TRACE
+static void
+xtermSetClipRectangles(Display * dpy,
+                      GC gc,
+                      int x,
+                      int y,
+                      XRectangle * rp,
+                      Cardinal nr,
+                      int order)
+{
+#if 0
+    TScreen *screen = TScreenOf(term);
+    Drawable draw = VWindow(screen);
+
+    XSetClipMask(dpy, gc, None);
+    XDrawRectangle(screen->display, draw, gc,
+                  x + rp->x - 1,
+                  y + rp->y - 1,
+                  rp->width,
+                  rp->height);
+#endif
+
+    XSetClipRectangles(dpy, gc,
+                      x, y, rp, (int) nr, order);
+    TRACE(("clipping @(%3d,%3d) (%3d,%3d)..(%3d,%3d)\n",
+          y, x,
+          rp->y, rp->x, rp->height, rp->width));
+}
+
+#else
+#define xtermSetClipRectangles(dpy, gc, x, y, rp, nr, order) \
+           XSetClipRectangles(dpy, gc, x, y, rp, (int) nr, order)
+#endif
+
+#if OPT_CLIP_BOLD
+/*
+ * This special case is a couple of percent slower, but avoids a lot of pixel
+ * trash in rxcurses' hanoi.cmd demo (e.g., 10x20 font).
+ */
+#define beginClipping(screen,gc,pwidth,plength) \
+           if (screen->use_clipping && (pwidth > 2)) { \
+               XRectangle clip; \
+               int clip_x = x; \
+               int clip_y = y - FontHeight(screen) + FontDescent(screen); \
+               clip.x = 0; \
+               clip.y = 0; \
+               clip.height = (unsigned short) FontHeight(screen); \
+               clip.width = (unsigned short) (pwidth * plength); \
+               xtermSetClipRectangles(screen->display, gc, \
+                                      clip_x, clip_y, \
+                                      &clip, 1, Unsorted); \
+           }
+#define endClipping(screen,gc) \
+           XSetClipMask(screen->display, gc, None)
+#else
+#define beginClipping(screen,gc,pwidth,plength)                /* nothing */
+#define endClipping(screen,gc) /* nothing */
+#endif /* OPT_CLIP_BOLD */
+
+#if OPT_CLIP_BOLD && OPT_RENDERFONT && defined(HAVE_XFTDRAWSETCLIP) && defined(HAVE_XFTDRAWSETCLIPRECTANGLES)
+#define beginXftClipping(screen,px,py,plength) \
+           if (screen->use_clipping && (FontWidth(screen) > 2)) { \
+               XRectangle clip; \
+               int clip_x = px; \
+               int clip_y = py - FontHeight(screen) + FontDescent(screen); \
+               clip.x = 0; \
+               clip.y = 0; \
+               clip.height = (unsigned short) (FontHeight(screen)); \
+               clip.width = (unsigned short) (FontWidth(screen) * plength); \
+               XftDrawSetClipRectangles (screen->renderDraw, \
+                                         clip_x, clip_y, \
+                                         &clip, 1); \
+           }
+#define endXftClipping(screen) \
+           XftDrawSetClip (screen->renderDraw, 0)
+#else
+#define beginXftClipping(screen,px,py,plength) /* nothing */
+#define endXftClipping(screen) /* nothing */
+#endif /* OPT_CLIP_BOLD */
+
+#if OPT_RENDERFONT
+static int
+drawClippedXftString(XtermWidget xw,
+                    unsigned flags,
+                    XftFont * font,
+                    XftColor * fg_color,
+                    int x,
+                    int y,
+                    IChar * text,
+                    Cardinal len)
+{
+    int ncells = xtermXftWidth(xw, flags,
+                              fg_color,
+                              font, x, y,
+                              text,
+                              len);
+    TScreen *screen = TScreenOf(xw);
+
+    beginXftClipping(screen, x, y, ncells);
+    xtermXftDrawString(xw, flags,
+                      fg_color,
+                      font, x, y,
+                      text,
+                      len,
+                      True);
+    endXftClipping(screen);
+    return ncells;
+}
+#endif
+
+#ifndef NO_ACTIVE_ICON
+#define WhichVFontData(screen,name) \
+               (IsIcon(screen) ? &((screen)->fnt_icon) \
+                               : &((screen)->name))
+#else
+#define WhichVFontData(screen,name) \
+                               (&((screen)->name))
+#endif
+
+/*
+ * Draws text with the specified combination of bold/underline.  The return
+ * value is the updated x position.
+ */
+int
+drawXtermText(XtermWidget xw,
+             unsigned flags,
+             GC gc,
+             int x,
+             int y,
+             int chrset,
+             IChar * text,
+             Cardinal len,
+             int on_wide)
+{
+    TScreen *screen = TScreenOf(xw);
+    Cardinal real_length = len;
+    Cardinal underline_len = 0;
+    /* Intended width of the font to draw (as opposed to the actual width of
+       the X font, and the width of the default font) */
+    int font_width = ((flags & DOUBLEWFONT) ? 2 : 1) * screen->fnt_wide;
+    Bool did_ul = False;
+
+#if OPT_WIDE_CHARS
+    if (text == 0)
+       return 0;
+#endif
+#if OPT_DEC_CHRSET
+    if (CSET_DOUBLE(chrset)) {
+       /* We could try drawing double-size characters in the icon, but
+        * given that the icon font is usually nil or nil2, there
+        * doesn't seem to be much point.
+        */
+       int inx = 0;
+       GC gc2 = ((!IsIcon(screen) && screen->font_doublesize)
+                 ? xterm_DoubleGC(xw, (unsigned) chrset, flags, gc, &inx)
+                 : 0);
+
+       TRACE(("DRAWTEXT%c[%4d,%4d] (%d)%3d:%s\n",
+              screen->cursor_state == OFF ? ' ' : '*',
+              y, x, chrset, len,
+              visibleIChars(text, len)));
+
+       if (gc2 != 0) {         /* draw actual double-sized characters */
+           XFontStruct *fs = screen->double_fonts[inx].fs;
+
+#if OPT_RENDERFONT
+           if (!UsingRenderFont(xw))
+#endif
+           {
+               XRectangle rect, *rp = &rect;
+               Cardinal nr = 1;
+
+               font_width *= 2;
+               flags |= DOUBLEWFONT;
+
+               rect.x = 0;
+               rect.y = 0;
+               rect.width = (unsigned short) ((int) len * font_width);
+               rect.height = (unsigned short) (FontHeight(screen));
+
+               TRACE(("drawing %s\n", visibleChrsetName((unsigned) chrset)));
+               switch (chrset) {
+               case CSET_DHL_TOP:
+                   rect.y = (short) -(fs->ascent / 2);
+                   y -= rect.y;
+                   flags |= DOUBLEHFONT;
+                   break;
+               case CSET_DHL_BOT:
+                   rect.y = (short) (rect.height - (fs->ascent / 2));
+                   y -= rect.y;
+                   flags |= DOUBLEHFONT;
+                   break;
+               default:
+                   nr = 0;
+                   break;
+               }
+
+               if (nr) {
+                   xtermSetClipRectangles(screen->display, gc2,
+                                          x, y, rp, nr, YXBanded);
+               } else {
+                   XSetClipMask(screen->display, gc2, None);
+               }
+           }
+
+           /* Call ourselves recursively with the new gc */
+
+           /*
+            * If we're trying to use proportional font, or if the
+            * font server didn't give us what we asked for wrt
+            * width, position each character independently.
+            */
+           if (screen->fnt_prop
+               || (fs->min_bounds.width != fs->max_bounds.width)
+               || (fs->min_bounds.width != 2 * FontWidth(screen))) {
+               /* It is hard to fall-through to the main
+                  branch: in a lot of places the check
+                  for the cached font info is for
+                  normal/bold fonts only. */
+               while (len--) {
+                   x = drawXtermText(xw, flags, gc2,
+                                     x, y, 0,
+                                     text++,
+                                     1, on_wide);
+                   x += FontWidth(screen);
+               }
+           } else {
+               x = drawXtermText(xw, flags, gc2,
+                                 x, y, 0,
+                                 text,
+                                 len, on_wide);
+               x += (int) len *FontWidth(screen);
+           }
+
+           TRACE(("drawtext [%4d,%4d]\n", y, x));
+       } else {                /* simulate double-sized characters */
+           unsigned need = 2 * len;
+           IChar *temp = TypeMallocN(IChar, need);
+           unsigned n = 0;
+
+           while (len--) {
+               temp[n++] = *text++;
+               temp[n++] = ' ';
+           }
+           x = drawXtermText(xw,
+                             flags,
+                             gc,
+                             x, y,
+                             0,
+                             temp,
+                             n,
+                             on_wide);
+           free(temp);
+       }
+       return x;
+    }
+#endif
+#if OPT_RENDERFONT
+    if (UsingRenderFont(xw)) {
+       VTwin *currentWin = WhichVWin(screen);
+       Display *dpy = screen->display;
+       XftFont *font;
+       XGCValues values;
+       int fontnum = screen->menu_font_number;
+       int ncells;
+
+       if (!screen->renderDraw) {
+           int scr;
+           Drawable draw = VWindow(screen);
+           Visual *visual;
+
+           scr = DefaultScreen(dpy);
+           visual = DefaultVisual(dpy, scr);
+           screen->renderDraw = XftDrawCreate(dpy, draw, visual,
+                                              DefaultColormap(dpy, scr));
+       }
+#if OPT_ISO_COLORS
+       if ((flags & UNDERLINE)
+           && !screen->colorULMode
+           && screen->italicULMode
+           && XFT_FONT(renderFontItal[fontnum])) {
+           font = XFT_FONT(renderFontItal[fontnum]);
+           did_ul = True;
+       } else
+#endif
+           if ((flags & BOLDATTR(screen))
+               && UseBoldFont(screen)
+               && XFT_FONT(renderFontBold[fontnum])) {
+           font = XFT_FONT(renderFontBold[fontnum]);
+       } else {
+           font = XFT_FONT(renderFontNorm[fontnum]);
+       }
+       values.foreground = getCgsFore(xw, currentWin, gc);
+       values.background = getCgsBack(xw, currentWin, gc);
+
+       if (!(flags & NOBACKGROUND)) {
+           XftColor *bg_color = getXftColor(xw, values.background);
+           ncells = xtermXftWidth(xw, flags,
+                                  bg_color,
+                                  font, x, y,
+                                  text,
+                                  len);
+           XftDrawRect(screen->renderDraw,
+                       bg_color,
+                       x, y,
+                       (unsigned) (ncells * FontWidth(screen)),
+                       (unsigned) FontHeight(screen));
+       }
+
+       y += font->ascent;
+#if OPT_BOX_CHARS
+       {
+           /* adding code to substitute simulated line-drawing characters */
+           int last, first = 0;
+           Dimension old_wide, old_high = 0;
+           int curX = x;
+
+           for (last = 0; last < (int) len; last++) {
+               Boolean replace = False;
+               Boolean missing = False;
+               unsigned ch = (unsigned) text[last];
+               int nc;
+#if OPT_WIDE_CHARS
+
+               if (xtermIsDecGraphic(ch)) {
+                   /*
+                    * Xft generally does not have the line-drawing characters
+                    * in cells 1-31.  Assume this (we cannot inspect the
+                    * picture easily...), and attempt to fill in from real
+                    * line-drawing character in the font at the Unicode
+                    * position.  Failing that, use our own box-characters.
+                    */
+                   if (screen->force_box_chars
+                       || xtermXftMissing(xw, font, dec2ucs(ch))) {
+                       missing = 1;
+                   } else {
+                       ch = dec2ucs(ch);
+                       replace = True;
+                   }
+               } else if (ch >= 256) {
+                   /*
+                    * If we're reading UTF-8 from the client, we may have a
+                    * line-drawing character.  Translate it back to our
+                    * box-code if Xft tells us that the glyph is missing.
+                    */
+                   if_OPT_WIDE_CHARS(screen, {
+                       unsigned part = ucs2dec(ch);
+                       if (xtermIsDecGraphic(part) &&
+                           (screen->force_box_chars
+                            || xtermXftMissing(xw, font, ch))) {
+                           ch = part;
+                           missing = True;
+                       }
+                   });
+               }
+#else
+               if (xtermIsDecGraphic(ch)) {
+                   /*
+                    * Xft generally does not have the line-drawing characters
+                    * in cells 1-31.  Check for this, and attempt to fill in
+                    * from real line-drawing character in the font at the
+                    * Unicode position.  Failing that, use our own
+                    * box-characters.
+                    */
+                   if (xtermXftMissing(xw, font, ch)) {
+                       missing = 1;
+                   }
+               }
+#endif
+
+               /*
+                * If we now have one of our box-codes, draw it directly.
+                */
+               if (missing || replace) {
+                   /* line drawing character time */
+                   if (last > first) {
+                       nc = drawClippedXftString(xw,
+                                                 flags,
+                                                 font,
+                                                 getXftColor(xw, values.foreground),
+                                                 curX,
+                                                 y,
+                                                 text + first,
+                                                 (Cardinal) (last - first));
+                       curX += nc * FontWidth(screen);
+                       underline_len += (Cardinal) nc;
+                   }
+                   if (missing) {
+                       old_wide = screen->fnt_wide;
+                       old_high = screen->fnt_high;
+                       screen->fnt_wide = (Dimension) FontWidth(screen);
+                       screen->fnt_high = (Dimension) FontHeight(screen);
+                       xtermDrawBoxChar(xw, ch, flags, gc,
+                                        curX, y - FontAscent(screen), 1);
+                       curX += FontWidth(screen);
+                       underline_len += 1;
+                       screen->fnt_wide = old_wide;
+                       screen->fnt_high = old_high;
+                   } else {
+                       IChar ch2 = (IChar) ch;
+                       nc = drawClippedXftString(xw,
+                                                 flags,
+                                                 font,
+                                                 getXftColor(xw, values.foreground),
+                                                 curX,
+                                                 y,
+                                                 &ch2,
+                                                 1);
+                       curX += nc * FontWidth(screen);
+                       underline_len += (Cardinal) nc;
+                   }
+                   first = last + 1;
+               }
+           }
+           if (last > first) {
+               underline_len += (Cardinal)
+                   drawClippedXftString(xw,
+                                        flags,
+                                        font,
+                                        getXftColor(xw, values.foreground),
+                                        curX,
+                                        y,
+                                        text + first,
+                                        (Cardinal) (last - first));
+           }
+       }
+#else
+       {
+           underline_len += (Cardinal)
+               drawClippedXftString(xw,
+                                    flags,
+                                    font,
+                                    getXftColor(xw, values.foreground),
+                                    x,
+                                    y,
+                                    text,
+                                    len);
+       }
+#endif /* OPT_BOX_CHARS */
+
+       if ((flags & UNDERLINE) && screen->underline && !did_ul) {
+           if (FontDescent(screen) > 1)
+               y++;
+           XDrawLine(screen->display, VWindow(screen), gc,
+                     x, y,
+                     x + (int) underline_len * FontWidth(screen) - 1,
+                     y);
+       }
+       return x + (int) len *FontWidth(screen);
+    }
+#endif /* OPT_RENDERFONT */
+    /*
+     * If we're asked to display a proportional font, do this with a fixed
+     * pitch.  Yes, it's ugly.  But we cannot distinguish the use of xterm
+     * as a dumb terminal vs its use as in fullscreen programs such as vi.
+     * Hint: do not try to use a proportional font in the icon.
+     */
+    if (!IsIcon(screen) && !(flags & CHARBYCHAR) && screen->fnt_prop) {
+       int adj, width;
+       XTermFonts *font = ((flags & BOLDATTR(screen))
+                           ? WhichVFontData(screen, fnts[fBold])
+                           : WhichVFontData(screen, fnts[fNorm]));
+
+       while (len--) {
+           int cells = WideCells(*text);
+#if OPT_BOX_CHARS
+#if OPT_WIDE_CHARS
+           if (*text == HIDDEN_CHAR) {
+               ++text;
+               continue;
+           } else
+#endif
+           if (IsXtermMissingChar(screen, *text, font)) {
+               adj = 0;
+           } else
+#endif
+           {
+               if_WIDE_OR_NARROW(screen, {
+                   XChar2b temp[1];
+                   temp[0].byte2 = LO_BYTE(*text);
+                   temp[0].byte1 = HI_BYTE(*text);
+                   width = XTextWidth16(font->fs, temp, 1);
+               }
+               , {
+                   char temp[1];
+                   temp[0] = (char) LO_BYTE(*text);
+                   width = XTextWidth(font->fs, temp, 1);
+               });
+               adj = (FontWidth(screen) - width) / 2;
+               if (adj < 0)
+                   adj = 0;
+           }
+           xtermFillCells(xw, flags, gc, x, y, (Cardinal) cells);
+           x = drawXtermText(xw,
+                             flags | NOBACKGROUND | CHARBYCHAR,
+                             gc, x + adj, y, chrset,
+                             text++, 1, on_wide) - adj;
+       }
+       return x;
+    }
+#if OPT_BOX_CHARS
+    /* If the font is incomplete, draw some substitutions */
+    if (!IsIcon(screen)
+       && !(flags & NOTRANSLATION)
+       && (!screen->fnt_boxes || screen->force_box_chars)) {
+       /* Fill in missing box-characters.
+          Find regions without missing characters, and draw
+          them calling ourselves recursively.  Draw missing
+          characters via xtermDrawBoxChar(). */
+       XTermFonts *font = ((flags & BOLDATTR(screen))
+                           ? WhichVFontData(screen, fnts[fBold])
+                           : WhichVFontData(screen, fnts[fNorm]));
+       int last, first = 0;
+       Bool drewBoxes = False;
+
+       for (last = 0; last < (int) len; last++) {
+           unsigned ch = (unsigned) text[last];
+           Bool isMissing;
+           int ch_width;
+#if OPT_WIDE_CHARS
+
+           if (ch == HIDDEN_CHAR) {
+               if (last > first) {
+                   x = drawXtermText(xw, flags | NOTRANSLATION, gc,
+                                     x, y,
+                                     chrset, text + first,
+                                     (unsigned) (last - first), on_wide);
+               }
+               first = last + 1;
+               drewBoxes = True;
+               continue;
+           }
+           ch_width = my_wcwidth((int) ch);
+           isMissing =
+               IsXtermMissingChar(screen, ch,
+                                  ((on_wide || ch_width > 1)
+                                   && okFont(NormalWFont(screen)))
+                                  ? WhichVFontData(screen, fnts[fWide])
+                                  : font);
+#else
+           isMissing = IsXtermMissingChar(screen, ch, font);
+           ch_width = 1;
+#endif
+           /*
+            * If the character is not missing, but we're in wide-character
+            * mode and the character happens to be a wide-character that
+            * corresponds to the line-drawing set, allow the forceBoxChars
+            * resource (or menu entry) to force it to display using our
+            * tables.
+            */
+           if_OPT_WIDE_CHARS(screen, {
+               if (!isMissing
+                   && ch > 255
+                   && ucs2dec(ch) < 32
+                   && TScreenOf(xw)->force_box_chars) {
+                   ch = ucs2dec(ch);
+                   isMissing = True;
+               }
+           });
+
+           if (isMissing) {
+               if (last > first) {
+                   x = drawXtermText(xw, flags | NOTRANSLATION, gc,
+                                     x, y,
+                                     chrset, text + first,
+                                     (unsigned) (last - first), on_wide);
+               }
+#if OPT_WIDE_CHARS
+               if (ucs_workaround(xw, ch, flags, gc,
+                                  x, y,
+                                  chrset, on_wide)) {
+                   /*
+                    * if true, we drew at least one cell whether or not it is
+                    * printable
+                    */
+                   if (ch_width <= 0)
+                       ch_width = 1;
+               } else
+#endif
+               {
+                   if (ch_width <= 0)
+                       ch_width = 1;
+                   xtermDrawBoxChar(xw, ch, flags, gc,
+                                    x, y,
+                                    ch_width);
+               }
+               x += (ch_width * FontWidth(screen));
+               first = last + 1;
+               drewBoxes = True;
+           }
+       }
+       if (last <= first) {
+           return x;
+       }
+       text += first;
+       len = (Cardinal) (last - first);
+       flags |= NOTRANSLATION;
+       if (drewBoxes) {
+           return drawXtermText(xw,
+                                flags,
+                                gc,
+                                x,
+                                y,
+                                chrset,
+                                text,
+                                len,
+                                on_wide);
+       }
+    }
+#endif /* OPT_BOX_CHARS */
+    /*
+     * Behave as if the font has (maybe Unicode-replacements for) drawing
+     * characters in the range 1-31 (either we were not asked to ignore them,
+     * or the caller made sure that there is none).
+     */
+    TRACE(("drawtext%c[%4d,%4d] (%d) %d:%s\n",
+          screen->cursor_state == OFF ? ' ' : '*',
+          y, x, chrset, len,
+          visibleIChars(text, len)));
+    y += FontAscent(screen);
+
+#if OPT_WIDE_CHARS
+
+    if (screen->wide_chars || screen->unicode_font) {
+       XChar2b *buffer;
+       Bool needWide = False;
+       int ascent_adjust = 0;
+       int src, dst;
+
+       BumpTypedBuffer(XChar2b, len);
+       buffer = BfBuf(XChar2b);
+
+       for (src = dst = 0; src < (int) len; src++) {
+           IChar ch = text[src];
+
+           if (ch == HIDDEN_CHAR)
+               continue;
+
+           if (!needWide
+               && !IsIcon(screen)
+               && ((on_wide || my_wcwidth((int) ch) > 1)
+                   && okFont(NormalWFont(screen)))) {
+               needWide = True;
+           }
+
+           /*
+            * bitmap-fonts are limited to 16-bits.
+            */
+#if OPT_WIDER_ICHAR
+           if (ch > 0xffff) {
+               ch = UCS_REPL;
+           }
+#endif
+           buffer[dst].byte2 = LO_BYTE(ch);
+           buffer[dst].byte1 = HI_BYTE(ch);
+#if OPT_MINI_LUIT
+#define UCS2SBUF(value)        buffer[dst].byte2 = LO_BYTE(value);\
+                       buffer[dst].byte1 = HI_BYTE(value)
+
+#define Map2Sbuf(from,to) (text[src] == from) { UCS2SBUF(to); }
+
+           if (screen->latin9_mode && !screen->utf8_mode && text[src] < 256) {
+
+               /* see http://www.cs.tut.fi/~jkorpela/latin9.html */
+               /* *INDENT-OFF* */
+               if Map2Sbuf(0xa4, 0x20ac)
+               else if Map2Sbuf(0xa6, 0x0160)
+               else if Map2Sbuf(0xa8, 0x0161)
+               else if Map2Sbuf(0xb4, 0x017d)
+               else if Map2Sbuf(0xb8, 0x017e)
+               else if Map2Sbuf(0xbc, 0x0152)
+               else if Map2Sbuf(0xbd, 0x0153)
+               else if Map2Sbuf(0xbe, 0x0178)
+               /* *INDENT-ON* */
+
+           }
+           if (screen->unicode_font
+               && (text[src] == ANSI_DEL ||
+                   text[src] < ANSI_SPA)) {
+               unsigned ni = dec2ucs((unsigned) ((text[src] == ANSI_DEL)
+                                                 ? 0
+                                                 : text[src]));
+               UCS2SBUF(ni);
+           }
+#endif /* OPT_MINI_LUIT */
+           ++dst;
+       }
+       /* FIXME This is probably wrong. But it works. */
+       underline_len = len;
+
+       /* Set the drawing font */
+       if (!(flags & (DOUBLEHFONT | DOUBLEWFONT))) {
+           VTwin *currentWin = WhichVWin(screen);
+           VTFontEnum fntId;
+           CgsEnum cgsId;
+           Pixel fg = getCgsFore(xw, currentWin, gc);
+           Pixel bg = getCgsBack(xw, currentWin, gc);
+
+           if (needWide
+               && (okFont(NormalWFont(screen)) || okFont(BoldWFont(screen)))) {
+               if ((flags & BOLDATTR(screen)) != 0
+                   && okFont(BoldWFont(screen))) {
+                   fntId = fWBold;
+                   cgsId = gcWBold;
+               } else {
+                   fntId = fWide;
+                   cgsId = gcWide;
+               }
+           } else if ((flags & BOLDATTR(screen)) != 0
+                      && okFont(BoldFont(screen))) {
+               fntId = fBold;
+               cgsId = gcBold;
+           } else {
+               fntId = fNorm;
+               cgsId = gcNorm;
+           }
+
+           setCgsFore(xw, currentWin, cgsId, fg);
+           setCgsBack(xw, currentWin, cgsId, bg);
+           gc = getCgsGC(xw, currentWin, cgsId);
+
+           if (fntId != fNorm) {
+               XFontStruct *thisFp = WhichVFont(screen, fnts[fntId].fs);
+               ascent_adjust = (thisFp->ascent
+                                - NormalFont(screen)->ascent);
+               if (thisFp->max_bounds.width ==
+                   NormalFont(screen)->max_bounds.width * 2) {
+                   underline_len = real_length = (Cardinal) (dst * 2);
+               } else if (cgsId == gcWide || cgsId == gcWBold) {
+                   underline_len = real_length = (Cardinal) (dst * 2);
+                   xtermFillCells(xw,
+                                  flags,
+                                  gc,
+                                  x,
+                                  y - thisFp->ascent,
+                                  real_length);
+               }
+           }
+       }
+
+       if (flags & NOBACKGROUND) {
+           XDrawString16(screen->display,
+                         VWindow(screen), gc,
+                         x, y + ascent_adjust,
+                         buffer, dst);
+       } else {
+           XDrawImageString16(screen->display,
+                              VWindow(screen), gc,
+                              x, y + ascent_adjust,
+                              buffer, dst);
+       }
+
+       if ((flags & BOLDATTR(screen)) && screen->enbolden) {
+           beginClipping(screen, gc, (Cardinal) font_width, len);
+           XDrawString16(screen->display, VWindow(screen), gc,
+                         x + 1,
+                         y + ascent_adjust,
+                         buffer, dst);
+           endClipping(screen, gc);
+       }
+
+    } else
+#endif /* OPT_WIDE_CHARS */
+    {
+       int length = (int) len; /* X should have used unsigned */
+#if OPT_WIDE_CHARS
+       char *buffer;
+       int dst;
+
+       BumpTypedBuffer(char, len);
+       buffer = BfBuf(char);
+
+       for (dst = 0; dst < length; ++dst)
+           buffer[dst] = (char) LO_BYTE(text[dst]);
+#else
+       char *buffer = (char *) text;
+#endif
+
+       if (flags & NOBACKGROUND) {
+           XDrawString(screen->display, VWindow(screen), gc,
+                       x, y, buffer, length);
+       } else {
+           XDrawImageString(screen->display, VWindow(screen), gc,
+                            x, y, buffer, length);
+       }
+       underline_len = (Cardinal) length;
+       if ((flags & BOLDATTR(screen)) && screen->enbolden) {
+           beginClipping(screen, gc, font_width, length);
+           XDrawString(screen->display, VWindow(screen), gc,
+                       x + 1, y, buffer, length);
+           endClipping(screen, gc);
+       }
+    }
+
+    if ((flags & UNDERLINE) && screen->underline && !did_ul) {
+       if (FontDescent(screen) > 1)
+           y++;
+       XDrawLine(screen->display, VWindow(screen), gc,
+                 x, y, (x + (int) underline_len * font_width - 1), y);
+    }
+
+    return x + (int) real_length *FontWidth(screen);
+}
+
+#if OPT_WIDE_CHARS
+/*
+ * Allocate buffer - workaround for wide-character interfaces.
+ */
+void
+allocXtermChars(ScrnPtr * buffer, Cardinal length)
+{
+    if (*buffer == 0) {
+       *buffer = (ScrnPtr) XtMalloc(length);
+    } else {
+       *buffer = (ScrnPtr) XtRealloc((char *) *buffer, length);
+    }
+}
+#endif
+
+/* set up size hints for window manager; min 1 char by 1 char */
+void
+xtermSizeHints(XtermWidget xw, int scrollbarWidth)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("xtermSizeHints\n"));
+    TRACE(("   border    %d\n", xw->core.border_width));
+    TRACE(("   scrollbar %d\n", scrollbarWidth));
+
+    xw->hints.base_width = 2 * screen->border + scrollbarWidth;
+    xw->hints.base_height = 2 * screen->border;
+
+#if OPT_TOOLBAR
+    TRACE(("   toolbar   %d\n", ToolbarHeight(xw)));
+
+    xw->hints.base_height += ToolbarHeight(xw);
+    xw->hints.base_height += BorderWidth(xw) * 2;
+    xw->hints.base_width += BorderWidth(xw) * 2;
+#endif
+
+    xw->hints.width_inc = FontWidth(screen);
+    xw->hints.height_inc = FontHeight(screen);
+    xw->hints.min_width = xw->hints.base_width + xw->hints.width_inc;
+    xw->hints.min_height = xw->hints.base_height + xw->hints.height_inc;
+
+    xw->hints.width = MaxCols(screen) * FontWidth(screen) + xw->hints.min_width;
+    xw->hints.height = MaxRows(screen) * FontHeight(screen) + xw->hints.min_height;
+
+    xw->hints.flags |= (PSize | PBaseSize | PMinSize | PResizeInc);
+
+    TRACE_HINTS(&(xw->hints));
+}
+
+void
+getXtermSizeHints(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    long supp;
+
+    if (!XGetWMNormalHints(screen->display, VShellWindow(xw),
+                          &xw->hints, &supp))
+       memset(&xw->hints, 0, sizeof(xw->hints));
+    TRACE_HINTS(&(xw->hints));
+}
+
+/*
+ * Returns a GC, selected according to the font (reverse/bold/normal) that is
+ * required for the current position (implied).  The GC is updated with the
+ * current screen foreground and background colors.
+ */
+GC
+updatedXtermGC(XtermWidget xw, unsigned flags, unsigned fg_bg, Bool hilite)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+    CgsEnum cgsId = gcMAX;
+    unsigned my_fg = extract_fg(xw, fg_bg, flags);
+    unsigned my_bg = extract_bg(xw, fg_bg, flags);
+    Pixel fg_pix = getXtermForeground(xw, flags, my_fg);
+    Pixel bg_pix = getXtermBackground(xw, flags, my_bg);
+    Pixel xx_pix;
+#if OPT_HIGHLIGHT_COLOR
+    Pixel selbg_pix = T_COLOR(screen, HIGHLIGHT_BG);
+    Pixel selfg_pix = T_COLOR(screen, HIGHLIGHT_FG);
+    Boolean always = screen->hilite_color;
+    Boolean use_selbg = (Boolean) (always ||
+                                  isNotForeground(xw, fg_pix, bg_pix, selbg_pix));
+    Boolean use_selfg = (Boolean) (always &&
+                                  isNotBackground(xw, fg_pix, bg_pix, selfg_pix));
+#endif
+
+    (void) fg_bg;
+    (void) my_bg;
+    (void) my_fg;
+
+    /*
+     * Discard video attributes overridden by colorXXXMode's.
+     */
+    checkVeryBoldColors(flags, my_fg);
+
+    if (ReverseOrHilite(screen, flags, hilite)) {
+       if (flags & BOLDATTR(screen)) {
+           cgsId = gcBoldReverse;
+       } else {
+           cgsId = gcNormReverse;
+       }
+
+#if OPT_HIGHLIGHT_COLOR
+       if (!screen->hilite_color) {
+           if (selbg_pix != T_COLOR(screen, TEXT_FG)
+               && selbg_pix != fg_pix
+               && selbg_pix != bg_pix
+               && selbg_pix != xw->dft_foreground) {
+               bg_pix = fg_pix;
+               fg_pix = selbg_pix;
+           }
+       }
+#endif
+       EXCHANGE(fg_pix, bg_pix, xx_pix);
+#if OPT_HIGHLIGHT_COLOR
+       if (screen->hilite_color) {
+           if (screen->hilite_reverse) {
+               if (use_selbg) {
+                   if (use_selfg)
+                       bg_pix = fg_pix;
+                   else
+                       fg_pix = bg_pix;
+               }
+               if (use_selbg)
+                   bg_pix = selbg_pix;
+               if (use_selfg)
+                   fg_pix = selfg_pix;
+           }
+       }
+#endif
+    } else {
+       if (flags & BOLDATTR(screen)) {
+           cgsId = gcBold;
+       } else {
+           cgsId = gcNorm;
+       }
+    }
+#if OPT_HIGHLIGHT_COLOR
+    if (!screen->hilite_color || !screen->hilite_reverse) {
+       if (hilite && !screen->hilite_reverse) {
+           if (use_selbg)
+               bg_pix = selbg_pix;
+           if (use_selfg)
+               fg_pix = selfg_pix;
+       }
+    }
+#endif
+
+#if OPT_BLINK_TEXT
+    if ((screen->blink_state == ON) && (!screen->blink_as_bold) && (flags & BLINK)) {
+       fg_pix = bg_pix;
+    }
+#endif
+
+    setCgsFore(xw, win, cgsId, fg_pix);
+    setCgsBack(xw, win, cgsId, bg_pix);
+    return getCgsGC(xw, win, cgsId);
+}
+
+/*
+ * Resets the foreground/background of the GC returned by 'updatedXtermGC()'
+ * to the values that would be set in SGR_Foreground and SGR_Background. This
+ * duplicates some logic, but only modifies 1/4 as many GC's.
+ */
+void
+resetXtermGC(XtermWidget xw, unsigned flags, Bool hilite)
+{
+    TScreen *screen = TScreenOf(xw);
+    VTwin *win = WhichVWin(screen);
+    CgsEnum cgsId = gcMAX;
+    Pixel fg_pix = getXtermForeground(xw, flags, xw->cur_foreground);
+    Pixel bg_pix = getXtermBackground(xw, flags, xw->cur_background);
+
+    checkVeryBoldColors(flags, xw->cur_foreground);
+
+    if (ReverseOrHilite(screen, flags, hilite)) {
+       if (flags & BOLDATTR(screen)) {
+           cgsId = gcBoldReverse;
+       } else {
+           cgsId = gcNormReverse;
+       }
+
+       setCgsFore(xw, win, cgsId, bg_pix);
+       setCgsBack(xw, win, cgsId, fg_pix);
+
+    } else {
+       if (flags & BOLDATTR(screen)) {
+           cgsId = gcBold;
+       } else {
+           cgsId = gcNorm;
+       }
+
+       setCgsFore(xw, win, cgsId, fg_pix);
+       setCgsBack(xw, win, cgsId, bg_pix);
+    }
+}
+
+#if OPT_ISO_COLORS
+/*
+ * Extract the foreground-color index from a color pair.
+ * If we've got BOLD or UNDERLINE color-mode active, those will be used.
+ */
+unsigned
+extract_fg(XtermWidget xw, unsigned color, unsigned flags)
+{
+    unsigned fg = ExtractForeground(color);
+
+    if (TScreenOf(xw)->colorAttrMode
+       || (fg == ExtractBackground(color))) {
+       fg = MapToColorMode(fg, TScreenOf(xw), flags);
+    }
+    return fg;
+}
+
+/*
+ * Extract the background-color index from a color pair.
+ * If we've got INVERSE color-mode active, that will be used.
+ */
+unsigned
+extract_bg(XtermWidget xw, unsigned color, unsigned flags)
+{
+    unsigned bg = ExtractBackground(color);
+
+    if (TScreenOf(xw)->colorAttrMode
+       || (bg == ExtractForeground(color))) {
+       if (TScreenOf(xw)->colorRVMode && (flags & INVERSE))
+           bg = COLOR_RV;
+    }
+    return bg;
+}
+
+/*
+ * Combine the current foreground and background into a single 8-bit number.
+ * Note that we're storing the SGR foreground, since cur_foreground may be set
+ * to COLOR_UL, COLOR_BD or COLOR_BL, which would make the code larger than 8
+ * bits.
+ *
+ * This assumes that fg/bg are equal when we override with one of the special
+ * attribute colors.
+ */
+CellColor
+makeColorPair(int fg, int bg)
+{
+    unsigned my_bg = (bg >= 0) && (bg < NUM_ANSI_COLORS) ? (unsigned) bg : 0;
+    unsigned my_fg = (fg >= 0) && (fg < NUM_ANSI_COLORS) ? (unsigned) fg : my_bg;
+
+    return (CellColor) (my_fg | (my_bg << COLOR_BITS));
+}
+
+/*
+ * Using the "current" SGR background, clear a rectangle.
+ */
+void
+ClearCurBackground(XtermWidget xw,
+                  int top,
+                  int left,
+                  unsigned height,
+                  unsigned width)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    TRACE(("ClearCurBackground(%d,%d,%d,%d) %d\n",
+          top, left, height, width, xw->cur_background));
+
+    if (VWindow(screen)) {
+       set_background(xw, xw->cur_background);
+
+       XClearArea(screen->display, VWindow(screen),
+                  left, top, width, height, False);
+
+       set_background(xw, -1);
+    }
+}
+#endif /* OPT_ISO_COLORS */
+
+/*
+ * Returns a single base character for the given cell.
+ */
+unsigned
+getXtermCell(TScreen * screen, int row, int col)
+{
+    LineData *ld = getLineData(screen, row);
+
+    assert(ld && (col < (int) ld->lineSize));
+    return ((ld && (col < (int) ld->lineSize))
+           ? ld->charData[col]
+           : (unsigned) ' ');
+}
+
+/*
+ * Sets a single base character for the given cell.
+ */
+void
+putXtermCell(TScreen * screen, int row, int col, int ch)
+{
+    LineData *ld = getLineData(screen, row);
+
+    assert(ld && (col < (int) ld->lineSize));
+    if (ld && (col < (int) ld->lineSize)) {
+       ld->charData[col] = (CharData) ch;
+       if_OPT_WIDE_CHARS(screen, {
+           size_t off;
+           for_each_combData(off, ld) {
+               ld->combData[off][col] = 0;
+           }
+       });
+    }
+}
+
+#if OPT_WIDE_CHARS
+/*
+ * Add a combining character for the given cell
+ */
+void
+addXtermCombining(TScreen * screen, int row, int col, unsigned ch)
+{
+    if (ch != 0) {
+       LineData *ld = getLineData(screen, row);
+       size_t off;
+
+       TRACE(("addXtermCombining %d,%d %#x (%d)\n",
+              row, col, ch, my_wcwidth((wchar_t) ch)));
+
+       for_each_combData(off, ld) {
+           if (!ld->combData[off][col]) {
+               ld->combData[off][col] = (CharData) ch;
+               break;
+           }
+       }
+    }
+}
+#endif
+
+#ifdef HAVE_CONFIG_H
+#ifdef USE_MY_MEMMOVE
+void *
+my_memmove(void *s1, void *s2, size_t n)
+{
+    if (n != 0) {
+       char *p1 = (char *) s1;
+       char *p2 = (char *) s2;
+
+       if ((p1 + n > p2) && (p2 + n > p1)) {
+           static char *bfr;
+           static size_t length;
+           size_t j;
+           if (length < n) {
+               length = (n * 3) / 2;
+               bfr = ((bfr != 0)
+                      ? TypeRealloc(char, length, bfr)
+                      : TypeMallocN(char, length));
+               if (bfr == NULL)
+                   SysError(ERROR_MMALLOC);
+           }
+           for (j = 0; j < n; j++)
+               bfr[j] = p2[j];
+           p2 = bfr;
+       }
+       while (n-- != 0)
+           p1[n] = p2[n];
+    }
+    return s1;
+}
+#endif /* USE_MY_MEMMOVE */
+
+#ifndef HAVE_STRERROR
+char *
+my_strerror(int n)
+{
+    extern char *sys_errlist[];
+    extern int sys_nerr;
+    if (n > 0 && n < sys_nerr)
+       return sys_errlist[n];
+    return "?";
+}
+#endif
+#endif
+
+void
+update_keyboard_type(void)
+{
+    update_delete_del();
+    update_tcap_fkeys();
+    update_old_fkeys();
+    update_hp_fkeys();
+    update_sco_fkeys();
+    update_sun_fkeys();
+    update_sun_kbd();
+}
+
+void
+set_keyboard_type(XtermWidget xw, xtermKeyboardType type, Bool set)
+{
+    xtermKeyboardType save = xw->keyboard.type;
+
+    TRACE(("set_keyboard_type(%s, %s) currently %s\n",
+          visibleKeyboardType(type),
+          BtoS(set),
+          visibleKeyboardType(xw->keyboard.type)));
+    if (set) {
+       xw->keyboard.type = type;
+    } else {
+       xw->keyboard.type = keyboardIsDefault;
+    }
+
+    if (save != xw->keyboard.type) {
+       update_keyboard_type();
+    }
+}
+
+void
+toggle_keyboard_type(XtermWidget xw, xtermKeyboardType type)
+{
+    xtermKeyboardType save = xw->keyboard.type;
+
+    TRACE(("toggle_keyboard_type(%s) currently %s\n",
+          visibleKeyboardType(type),
+          visibleKeyboardType(xw->keyboard.type)));
+    if (xw->keyboard.type == type) {
+       xw->keyboard.type = keyboardIsDefault;
+    } else {
+       xw->keyboard.type = type;
+    }
+
+    if (save != xw->keyboard.type) {
+       update_keyboard_type();
+    }
+}
+
+void
+init_keyboard_type(XtermWidget xw, xtermKeyboardType type, Bool set)
+{
+    static Bool wasSet = False;
+
+    TRACE(("init_keyboard_type(%s, %s) currently %s\n",
+          visibleKeyboardType(type),
+          BtoS(set),
+          visibleKeyboardType(xw->keyboard.type)));
+    if (set) {
+       if (wasSet) {
+           fprintf(stderr, "Conflicting keyboard type option (%u/%u)\n",
+                   xw->keyboard.type, type);
+       }
+       xw->keyboard.type = type;
+       wasSet = True;
+       update_keyboard_type();
+    }
+}
+
+/*
+ * If the keyboardType resource is set, use that, overriding the individual
+ * boolean resources for different keyboard types.
+ */
+void
+decode_keyboard_type(XtermWidget xw, XTERM_RESOURCE * rp)
+{
+#define DATA(n, t, f) { n, t, XtOffsetOf(XTERM_RESOURCE, f) }
+#define FLAG(n) *(Boolean *)(((char *)rp) + table[n].offset)
+    static struct {
+       const char *name;
+       xtermKeyboardType type;
+       unsigned offset;
+    } table[] = {
+#if OPT_HP_FUNC_KEYS
+       DATA(NAME_HP_KT, keyboardIsHP, hpFunctionKeys),
+#endif
+#if OPT_SCO_FUNC_KEYS
+           DATA(NAME_SCO_KT, keyboardIsSCO, scoFunctionKeys),
+#endif
+#if OPT_SUN_FUNC_KEYS
+           DATA(NAME_SUN_KT, keyboardIsSun, sunFunctionKeys),
+#endif
+#if OPT_SUNPC_KBD
+           DATA(NAME_VT220_KT, keyboardIsVT220, sunKeyboard),
+#endif
+#if OPT_TCAP_FKEYS
+           DATA(NAME_TCAP_KT, keyboardIsTermcap, termcapKeys),
+#endif
+    };
+    Cardinal n;
+
+    TRACE(("decode_keyboard_type(%s)\n", rp->keyboardType));
+    if (!x_strcasecmp(rp->keyboardType, "unknown")) {
+       /*
+        * Let the individual resources comprise the keyboard-type.
+        */
+       for (n = 0; n < XtNumber(table); ++n)
+           init_keyboard_type(xw, table[n].type, FLAG(n));
+    } else if (!x_strcasecmp(rp->keyboardType, "default")) {
+       /*
+        * Set the keyboard-type to the Sun/PC type, allowing modified
+        * function keys, etc.
+        */
+       for (n = 0; n < XtNumber(table); ++n)
+           init_keyboard_type(xw, table[n].type, False);
+    } else {
+       Bool found = False;
+
+       /*
+        * Choose an individual keyboard type.
+        */
+       for (n = 0; n < XtNumber(table); ++n) {
+           if (!x_strcasecmp(rp->keyboardType, table[n].name + 1)) {
+               FLAG(n) = True;
+               found = True;
+           } else {
+               FLAG(n) = False;
+           }
+           init_keyboard_type(xw, table[n].type, FLAG(n));
+       }
+       if (!found) {
+           fprintf(stderr,
+                   "KeyboardType resource \"%s\" not found\n",
+                   rp->keyboardType);
+       }
+    }
+#undef DATA
+#undef FLAG
+}
+
+#if OPT_WIDE_CHARS
+#if defined(HAVE_WCHAR_H) && defined(HAVE_WCWIDTH)
+/*
+ * If xterm is running in a UTF-8 locale, it is still possible to encounter
+ * old runtime configurations which yield incomplete or inaccurate data.
+ */
+static Bool
+systemWcwidthOk(int samplesize, int samplepass)
+{
+    wchar_t n;
+    int oops = 0;
+
+    for (n = 21; n <= 25; ++n) {
+       int code = (int) dec2ucs((unsigned) n);
+       int system_code = wcwidth(code);
+       int intern_code = mk_wcwidth(code);
+
+       /*
+        * Solaris 10 wcwidth() returns "2" for all of the line-drawing (page
+        * 0x2500) and most of the geometric shapes (a few are excluded, just
+        * to make it more difficult to use).  Do a sanity check to avoid using
+        * it.
+        */
+       if ((system_code < 0 && intern_code >= 1)
+           || (system_code >= 0 && intern_code != system_code)) {
+           TRACE(("systemWcwidthOk: broken system line-drawing wcwidth\n"));
+           oops += (samplepass + 1);
+           break;
+       }
+    }
+
+    for (n = 0; n < (wchar_t) samplesize; ++n) {
+       int system_code = wcwidth(n);
+       int intern_code = mk_wcwidth(n);
+
+       /*
+        * Since mk_wcwidth() is designed to check for nonspacing characters,
+        * and has rough range-checks for double-width characters, it will
+        * generally not detect cases where a code has not been assigned.
+        *
+        * Some experimentation with GNU libc suggests that up to 1/4 of the
+        * codes would differ, simply because the runtime library would have a
+        * table listing the unassigned codes, and return -1 for those.  If
+        * mk_wcwidth() has no information about a code, it returns 1.  On the
+        * other hand, if the runtime returns a positive number, the two should
+        * agree.
+        *
+        * The "up to" is measured for 4k, 8k, 16k of data.  With only 1k, the
+        * number of differences was only 77.  However, that is only one
+        * system, and this is only a sanity check to avoid using broken
+        * libraries.
+        */
+       if ((system_code < 0 && intern_code >= 1)
+           || (system_code >= 0 && intern_code != system_code)) {
+           ++oops;
+       }
+    }
+    TRACE(("systemWcwidthOk: %d/%d mismatches, allowed %d\n",
+          oops, samplesize, samplepass));
+    return (oops <= samplepass);
+}
+#endif /* HAVE_WCWIDTH */
+
+void
+decode_wcwidth(XtermWidget xw)
+{
+    int mode = ((xw->misc.cjk_width ? 2 : 0)
+               + (xw->misc.mk_width ? 1 : 0)
+               + 1);
+
+    switch (mode) {
+    default:
+#if defined(HAVE_WCHAR_H) && defined(HAVE_WCWIDTH)
+       if (xtermEnvUTF8() &&
+           systemWcwidthOk(xw->misc.mk_samplesize, xw->misc.mk_samplepass)) {
+           my_wcwidth = wcwidth;
+           TRACE(("using system wcwidth() function\n"));
+           break;
+       }
+       /* FALLTHRU */
+#endif
+    case 2:
+       my_wcwidth = &mk_wcwidth;
+       TRACE(("using MK wcwidth() function\n"));
+       break;
+    case 3:
+    case 4:
+       my_wcwidth = &mk_wcwidth_cjk;
+       TRACE(("using MK-CJK wcwidth() function\n"));
+       break;
+    }
+
+    for (first_widechar = 128; first_widechar < 4500; ++first_widechar) {
+       if (my_wcwidth((int) first_widechar) > 1) {
+           TRACE(("first_widechar %#x\n", first_widechar));
+           break;
+       }
+    }
+}
+#endif
diff --git a/uxterm b/uxterm
new file mode 100755 (executable)
index 0000000..aa07d1d
--- /dev/null
+++ b/uxterm
@@ -0,0 +1,115 @@
+#!/bin/sh
+# $XTermId: uxterm,v 1.26 2007/12/30 16:33:36 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2001-2006,2007 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# wrapper script to setup xterm with UTF-8 locale
+
+whoami=uxterm
+
+: ${XTERM_PROGRAM=xterm}
+
+# Check if there is a workable locale program.  If there is not, we will read
+# something via the standard error.  Ignore whatever is written to the
+# standard output.
+locale=`sh -c "LC_ALL=C LC_CTYPE=C LANG=C locale >/dev/null" 2>&1`
+found=no
+
+# Check for -version and -help options, to provide a simple return without
+# requiring the program to create a window:
+if test $# = 1
+then
+       case $1 in
+       -v|-ver*|-h|-he*)
+               $XTERM_PROGRAM "$@"
+               exit $?
+               ;;
+       esac
+fi
+
+# Check environment variables that xterm does, in the same order:
+for name in LC_ALL LC_CTYPE LANG
+do
+       eval 'value=$'$name
+       if test -n "$value" ; then
+               case $value in
+               *.utf8|*.UTF8|*.utf-8|*.UTF-8)
+                       found=yes
+                       ;;
+               *.utf8@*|*.UTF8@*|*.utf-8@*|*.UTF-8@*)
+                       found=yes
+                       ;;
+               C|POSIX)
+                       # Yes, I know this is not the same - but why are you
+                       # here then?
+                       value=en_US
+                       ;;
+               esac
+               break
+       fi
+done
+
+# If we didn't find one that used UTF-8, modify the safest one.  Not everyone
+# has a UTF-8 locale installed (and there appears to be no trivial/portable way
+# to determine whether it is, from a shell script).  We could check if the
+# user's shell does not reset unknown locale specifiers, but not all shells do.
+if test $found != yes ; then
+       if test -n "$value" ; then
+               value=`echo ${value} |sed -e 's/[.@].*//'`.UTF-8
+       else
+               name="LC_CTYPE"
+               value="en_US.UTF-8"
+       fi
+       eval save=\$${name}
+       eval ${name}=${value}
+       eval export ${name}
+       if test -z "$locale" ; then
+               # The 'locale' program tries to do a sanity check.
+               check=`sh -c "locale >/dev/null" 2>&1`
+               if test -n "$check" ; then
+                       eval ${name}=${save}
+                       eval export ${name}
+
+                       echo "$whoami tried to use locale $value by setting \$$name" >&2
+                       xmessage -file - <<EOF
+$whoami tried unsuccessfully to use locale $value
+by setting \$$name to "${value}".
+EOF
+                       exit 1
+               fi
+       fi
+fi
+
+# for testing:
+#test -f ./xterm && XTERM_PROGRAM=./xterm
+
+exec $XTERM_PROGRAM -class UXTerm -title $whoami -u8 "$@"
diff --git a/uxterm.desktop b/uxterm.desktop
new file mode 100644 (file)
index 0000000..6937f21
--- /dev/null
@@ -0,0 +1,41 @@
+# $XTermId: uxterm.desktop,v 1.9 2010/06/15 10:58:13 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2006-2007,2010 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+[Desktop Entry]
+Name=UXTerm
+Comment=standard terminal emulator for the X window system
+Exec=uxterm
+Terminal=false
+Type=Application
+Encoding=UTF-8
+Icon=xterm-color_48x48
+Categories=System;TerminalEmulator;
diff --git a/uxterm.man b/uxterm.man
new file mode 100644 (file)
index 0000000..c9e4cf0
--- /dev/null
@@ -0,0 +1,91 @@
+.\" $XTermId: uxterm.man,v 1.3 2007/12/30 15:55:21 tom Exp $
+.\"
+.\" Copyright 2001, 2004 Branden Robinson
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the "Software"),
+.\" to deal in the Software without restriction, including without limitation
+.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
+.\" and/or sell copies of the Software, and to permit persons to whom the
+.\" Software is furnished to do so, subject to the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included in
+.\" all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+.\" SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+.\" DEALINGS IN THE SOFTWARE.
+.TH uxterm 1 "2004-12-19" "Debian Project"
+.SH NAME
+uxterm \- X terminal emulator for Unicode (UTF-8) environments
+.SH SYNOPSIS
+.B uxterm
+[
+.I xterm-options
+]
+.SH DESCRIPTION
+.B uxterm
+is a wrapper around the
+.BR xterm(1)
+program that invokes the latter program with the \(oqUXTerm\(cq X resource
+class set.
+All arguments to
+.B uxterm
+are passed to
+.B xterm
+without processing; the
+.B \-class
+and
+.B \-u8
+options should not be specified because they are used by the wrapper.
+See the
+.B xterm
+manual page for more information on
+.IR xterm-options .
+.PP
+The environment's locale settings (see \(lqENVIRONMENT\(rq below) are
+used to discern the locale's character set.
+If no current locale can be determined, the locale \(oqen_US\(cq (the
+English language as used in the territory of the United States) is assumed.
+The
+.BR locale(1)
+utility is used to determine whether the system supports the selected
+locale.
+If it does not,
+.B uxterm
+will exit with an error and report the output of
+.BR locale .
+.PP
+.B Note: uxterm
+may produce unexpected results if the current locale is set to one in which
+the UTF-8 character encoding is not supported, or if fonts using the ISO
+10646-1 character set are not available.
+In the Debian system, the \(oqxfonts\-base\(cq package provides the fonts
+that
+.B uxterm
+uses by default.
+To change the fonts
+.B uxterm
+uses, edit the
+.I __apploaddir__/UXTerm
+file.
+.PP
+A similar wrapper,
+.BR koi8rxterm(1),
+is available for KOI8-R environments.
+.SH ENVIRONMENT
+.TP
+.B LC_ALL\fR, \fBLC_CTYPE\fR, \fBLANG
+The values of these variables are checked, in order, to determine the
+character set used by the current locale.
+.SH AUTHOR
+Thomas Dickey
+.SH "SEE ALSO"
+.BR locale(1),
+.BR locale(7),
+.BR koi8rxterm(1),
+.BR xterm(1)
diff --git a/version.h b/version.h
new file mode 100644 (file)
index 0000000..c50076c
--- /dev/null
+++ b/version.h
@@ -0,0 +1,46 @@
+/*
+ * $XTermId: version.h,v 1.326 2010/11/24 11:16:32 tom Exp $
+ * ----------------------------------------------------------------------------
+ * this file is part of xterm
+ *
+ * Copyright 1998-2009,2010 by Thomas E. Dickey
+ * 
+ *                         All Rights Reserved
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ * These definitions are used to build the string that's printed in response to
+ * "xterm -version", or embedded in "xterm -help".  It usually indicates the
+ * version of X to which this version of xterm has been built.  The number in
+ * parentheses is my patch number (Thomas E. Dickey).
+ */
+#define XTERM_PATCH   268
+
+#ifndef __vendorversion__
+#define __vendorversion__ "XTerm"
+#endif
diff --git a/vms.c b/vms.c
new file mode 100644 (file)
index 0000000..6f89e9e
--- /dev/null
+++ b/vms.c
@@ -0,0 +1,724 @@
+/* $XTermId: vms.c,v 1.13 2010/10/11 08:05:35 tom Exp $ */
+
+/*  vms.c
+ *
+ * This module contains the VMS version of the routine SPAWN (from the module
+ * MAIN.C) and the routines that do IO to the pseudo terminal.
+ *
+ * Modification History:
+ * Stephan Jansen 1-Mar-1990  Original version
+ * Hal R. Brand   5-Sep-1990  Added code to propagate DECW$DISPLAY
+ * Aaron Leonard 11-Sep-1990  Fix string descriptor lengths
+ * Stephan Jansen 2-Dec-1991  Modify to use new Pseudo terminal drivers
+ *                            (patterned after photo.c by Forrest A. Kenney)
+ * Patrick Mahan  7-Jan-1991  Removed reference to <dvidef.h> from VMS.C
+ *                           Forced device type to be VT102 since that is
+ *                           what we are emulating.
+ */
+
+#include <libdef.h>
+#include <lnmdef.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "xterm.h"
+#include "data.h"
+#include "vms.h"
+
+#define PTD$C_SEND_XON         0       /* Pseudo Terminal Driver event      */
+#define PTD$C_SEND_BELL                1
+#define PTD$C_SEND_XOFF        2
+#define PTD$C_STOP_OUTPUT      3
+#define PTD$C_RESUME_OUTPUT    4
+#define PTD$C_CHAR_CHANGED     5
+#define PTD$C_ABORT_OUTPUT     6
+#define PTD$C_START_READ       7
+#define PTD$C_MIDDLE_READ      8
+#define PTD$C_END_READ                 9
+#define PTD$C_ENABLE_READ      10
+#define PTD$C_DISABLE_READ     11
+#define PTD$C_MAX_EVENTS       12
+
+#define        BUFFERS                 6
+#define        PAGE                    512
+
+typedef struct tt_buffer
+{
+unsigned int   flink;
+unsigned int   blink;
+short  int     status;
+short  int     length;
+char           data[VMS_TERM_BUFFER_SIZE];
+} TT_BUF_STRUCT;
+
+TT_BUF_STRUCT          *tt_w_buff;
+struct q_head           _align(QUADWORD)       buffer_queue = (0,0);
+struct q_head           _align(QUADWORD)       read_queue = (0,0);
+
+static char          tt_name[64];
+static $DESCRIPTOR   (tt_name_desc, &tt_name);
+
+static char          ws_name[64];
+static $DESCRIPTOR   (ws_name_desc, &ws_name);
+
+static struct        tt_char {
+   char        class;
+   char        type;
+   short int   page_width;
+   char        characteristics[3];
+   char        length;
+   int         extended;
+ } tt_mode, tt_chars, orig_tt_chars;
+
+struct mem_region
+{
+  TT_BUF_STRUCT *start;
+  TT_BUF_STRUCT *end;
+} ret_addr;
+
+int read_stopped = False;
+int write_stopped = False;
+
+int tt_width;
+int tt_length;
+int tt_changed;
+int tt_pasting=False;         /* drm */
+int tt_new_output=False;      /* Cleared by flushlog(), set whenever something new
+   goes to the screen through tt_write */
+
+int trnlnm(char *in,int id,char *out);
+void spawn (void);
+
+static void tt_echo_ast(TT_BUF_STRUCT *buff_addr);
+static void tt_read_ast(TT_BUF_STRUCT *buff_addr);
+
+/*
+static void tt_start_read(void);
+*/
+void tt_start_read(void);
+int tt_read(char *buffer);
+static void send_xon(void);
+static void send_xoff(void);
+static void send_bell(void);
+static void char_change(void);
+static void freeBuff (TT_BUF_STRUCT *buff_addr);
+TT_BUF_STRUCT *getBuff(void);
+static void CloseDown(int exit_status);
+static void mbx_read_ast(void);
+static void mbx_read(void);
+
+
+
+#define DESCRIPTOR(name,string) struct dsc$descriptor_s name = \
+{ strlen(string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string }
+
+int trnlnm(char *in, int id, char *out)
+{
+  int status, num, len, attr = LNM$M_CASE_BLIND, foo = id;
+  short outlen;
+  struct itemlist
+    {
+      short buffer_length;
+      short item_code;
+      char  *buffer_addr;
+      int   *return_length;
+    } itmlst[] =
+      {
+       4  , LNM$_INDEX    , &foo, 0,
+       255, LNM$_STRING   , out , &outlen,
+       4  , LNM$_MAX_INDEX, &num, &len,
+       0  , 0
+       };
+  DESCRIPTOR(lognam,in);
+  DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL");
+
+  status = sys$trnlnm(&attr,&tabnam,&lognam,0,itmlst);
+  if(status != SS$_NORMAL) return(-1);   /* error status */
+  out[outlen] = 0;         /* terminate the output string */
+  return(++num);         /* return number of translations */
+}
+
+static int           pty;
+static int           Xsocket;
+
+void spawn (void)
+{
+  int                  status;
+  static $DESCRIPTOR   (dtime, "0 00:00:00.01");
+  static int           delta[2];
+  register TScreen     *screen = TScreenOf(term);
+  static struct IOSB   iosb;
+  static unsigned int  flags;
+  static unsigned int  uic;
+  static char          imagename[64];
+  static int           privs;
+  static $DESCRIPTOR(device, "FTA0:");
+  static int           type;
+  static int           class;
+  static int           devdepend;
+  static int           mem_size;
+  int                  i;
+
+  /* if pid and mbx_chan are nonzero then close them in CloseDown() */
+  pid = 0;
+  mbx_chan = 0;
+
+  status = SYS$EXPREG (BUFFERS, &ret_addr, 0, 0);
+  if(!(status & SS$_NORMAL)) lib$signal(status);
+
+  tt_w_buff = (char *)ret_addr.end - PAGE + 1;
+
+  /* use one buffer for writing, the reset go in the free buffer queue */
+  for(i=0; i < BUFFERS-1; i++)
+    {
+      freeBuff((char *)ret_addr.start +i*PAGE);
+    }
+
+  /* avoid double MapWindow requests, for wm's that care... */
+  XtSetMappedWhenManaged( screen->TekEmu ? XtParent(tekWidget) :
+                        XtParent(term), False );
+  /* Realize the Tek or VT widget, depending on which mode we're in.
+     If VT mode, this calls VTRealize (the widget's Realize proc) */
+  XtRealizeWidget (screen->TekEmu ? XtParent(tekWidget) :
+                  XtParent(term));
+
+  /* get the default device characteristics of the pseudo terminal */
+
+  itemlist[0].buflen      = 4;
+  itemlist[0].code        = DVI$_DEVTYPE;
+  itemlist[0].buffer      = &type;
+  itemlist[0].return_addr = &tt_name_desc.dsc$w_length;
+
+  itemlist[1].buflen      = 4;
+  itemlist[1].code        = DVI$_DEVCLASS;
+  itemlist[1].buffer      = &class;
+  itemlist[1].return_addr = &tt_name_desc.dsc$w_length;
+
+  itemlist[2].buflen      = 4;
+  itemlist[2].code        = DVI$_DEVDEPEND;
+  itemlist[2].buffer      = &devdepend;
+  itemlist[2].return_addr = &tt_name_desc.dsc$w_length;
+
+  itemlist[3].buflen      = 4;
+  itemlist[3].code        = DVI$_DEVDEPEND2;
+  itemlist[3].buffer      = &tt_chars.extended;
+  itemlist[3].return_addr = &tt_name_desc.dsc$w_length;
+
+  itemlist[4].buflen      = 0;
+  itemlist[4].code        = 0;
+
+
+  status = sys$getdviw(0,0,&device,&itemlist,&iosb,0,0,0);
+  if(!(status & SS$_NORMAL)) lib$signal(status);
+  if(!(iosb.status & SS$_NORMAL)) lib$signal(iosb.status);
+
+  tt_chars.type        = DT$_VT102; /* XTerm supports VT102 mode */
+  tt_chars.class       = class;
+  tt_chars.page_width  = screen->max_col+1;
+  tt_chars.length      = screen->max_row+1;
+
+  /* copy the default char's along with the created window size */
+
+  bcopy(&devdepend, &tt_chars.characteristics, 3);
+
+  tt_chars.extended |= TT2$M_ANSICRT | TT2$M_AVO | TT2$M_DECCRT;
+
+
+  /* create the pseudo terminal with the proper char's */
+  status = ptd$create(&tt_chan,0,&tt_chars,12,0,0,0,&ret_addr);
+  if(!(status & SS$_NORMAL)) lib$signal(status);
+
+
+  /* get the device name of the Pseudo Terminal */
+
+  itemlist[0].buflen      = 64;
+  itemlist[0].code        = DVI$_DEVNAM;
+  itemlist[0].buffer      = &tt_name;
+  itemlist[0].return_addr = &tt_name_desc.dsc$w_length;
+
+  /* terminate the list */
+  itemlist[1].buflen      = 0;
+  itemlist[1].code        = 0;
+
+  status = sys$getdviw(0,tt_chan,0,&itemlist,&iosb,0,0,0);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+  if(!(iosb.status & SS$_NORMAL)) CloseDown(iosb.status);
+
+  /*
+   * set up AST's for XON, XOFF, BELL and characteristics change.
+   */
+
+  status = ptd$set_event_notification(tt_chan,&send_xon,0,0,PTD$C_SEND_XON);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+
+  status = ptd$set_event_notification(tt_chan,&send_xoff,0,0,PTD$C_SEND_XOFF);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+
+  status = ptd$set_event_notification(tt_chan,&send_bell,0,0,PTD$C_SEND_BELL);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+
+  status = ptd$set_event_notification(tt_chan,&char_change,0,0,PTD$C_CHAR_CHANGED);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+
+  /* create a mailbox for the detached process to detect hangup */
+
+  status = sys$crembx(0,&mbx_chan,ACC$K_TERMLEN,0,255,0,0);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+
+
+  /*
+   * get the device unit number for created process completion
+   * status to be sent to.
+   */
+
+  itemlist[0].buflen      = 4;
+  itemlist[0].code        = DVI$_UNIT;
+  itemlist[0].buffer      = &mbxunit;
+  itemlist[0].return_addr = 0;
+
+  /* terminate the list */
+  itemlist[1].buflen      = 0;
+  itemlist[1].code        = 0;
+
+  status = sys$getdviw(0,mbx_chan,0,&itemlist,&iosb,0,0,0);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+  if(!(iosb.status & SS$_NORMAL)) CloseDown(iosb.status);
+
+
+  tt_start_read();
+
+  /*
+   * find the current process's UIC so that it can be used in the
+   * call to sys$creprc
+   */
+  itemlist[0].buflen = 4;
+  itemlist[0].code = JPI$_UIC;
+  itemlist[0].buffer = &uic;
+  itemlist[0].return_addr = 0;
+
+  /* terminate the list */
+  itemlist[1].buflen      = 0;
+  itemlist[1].code        = 0;
+
+  status = sys$getjpiw(0,0,0,&itemlist,0,0,0);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+
+  /* Complete a descriptor for the WS (DECW$DISPLAY) device */
+
+  trnlnm("DECW$DISPLAY",0,ws_name);
+  ws_name_desc.dsc$w_length = strlen(ws_name);
+
+  /* create the process */
+  /*  Set sys$error to be the WS (DECW$DISPLAY) device. LOGINOUT  */
+  /*  has special code for DECWINDOWS that will:                  */
+  /*    1) do a DEFINE/JOB DECW$DISPLAY 'f$trnlnm(sys$error)'     */
+  /*    2) then redefine SYS$ERROR to match SYS$OUTPUT!           */
+  /*  This will propogate DECW$DISPLAY to the XTERM process!!!    */
+  /*  Thanks go to Joel M Snyder who posted this info to INFO-VAX */
+
+  flags = PRC$M_INTER | PRC$M_NOPASSWORD | PRC$M_DETACH;
+  status = sys$creprc(&pid,&image,&tt_name_desc,&tt_name_desc,
+                     &ws_name_desc,0,0,0,4,uic,mbxunit,flags);
+  if(!(status & SS$_NORMAL)) CloseDown(status);
+
+
+  /* hang a read on the mailbox waiting for completion */
+  mbx_read();
+
+
+/* set time value and schedule a periodic wakeup (every 1/100 of a second)
+ * this is used to prevent the controlling process from using up all the
+ * CPU.  The controlling process will hibernate at strategic points in
+ * the program when it is just waiting for input.
+ */
+
+  status = sys$bintim(&dtime,&delta);
+  if (!(status & SS$_NORMAL)) CloseDown(status);
+
+  status = sys$schdwk(0,0,&delta,&delta);
+  if (!(status & SS$_NORMAL)) CloseDown(status);
+
+
+  /*
+   * This is rather funky, but it saves me from having to totally
+   * rewrite some parts of the code (namely in_put in module CHARPROC.C)
+   */
+  pty = 1;
+  screen->respond = pty;
+  pty_mask = 1 << pty;
+  Select_mask = pty_mask;
+  X_mask = 1 << Xsocket;
+
+}
+
+
+/*
+ * This routine handles completion of write with echo.  It takes the
+ * echo buffer and puts it on the read queue.  It will then be processed
+ * by the routine tt_read.  If the echo buffer is empty, it is put back
+ * on the free buffer queue.
+ */
+
+static void tt_echo_ast(TT_BUF_STRUCT *buff_addr)
+{
+  int status;
+
+  if (buff_addr->length != 0)
+    {
+      status = LIB$INSQTI(buff_addr, &read_queue);
+      if((status != SS$_NORMAL) && (status != LIB$_ONEENTQUE))
+       {
+         CloseDown(status);
+       }
+    }
+  else
+    {
+      freeBuff(buff_addr);
+    }
+}
+
+
+/*
+ * This routine writes to the pseudo terminal.  If there is a free
+ * buffer then write with an echo buffer completing asyncronously, else
+ * write syncronously using the buffer reserved for writing.  All errors
+ *  are fatal, except DATAOVERUN and DATALOST,these errors can be ignored.
+
+ CAREFUL! Whatever calls this must NOT pass more than VMS_TERM_BUFFER_SIZE
+ bytes at a time.  This definition has been moved to VMS.H
+
+ */
+
+int tt_write(const char *tt_write_buf, int size)
+{
+  int status;
+  TT_BUF_STRUCT *echoBuff;
+
+  /* if writing stopped, return 0 until Xon */
+  if(write_stopped) return (0);
+
+  memmove(&tt_w_buff->data,tt_write_buf,size);
+
+  echoBuff = getBuff();
+  if (echoBuff != LIB$_QUEWASEMP)
+    {
+      status = PTD$WRITE (tt_chan, &tt_echo_ast, echoBuff,
+                         &tt_w_buff->status, size,
+                         &echoBuff->status, VMS_TERM_BUFFER_SIZE);
+    }
+  else
+    {
+      status = PTD$WRITE (tt_chan, 0, 0, &tt_w_buff->status, size, 0, 0);
+    }
+  if (status & SS$_NORMAL)
+    {
+      if ((tt_w_buff->status != SS$_NORMAL) &&
+         (tt_w_buff->status != SS$_DATAOVERUN) &&
+         (tt_w_buff->status != SS$_DATALOST))
+       {
+         CloseDown(tt_w_buff->status);
+       }
+    }
+  else
+    {
+      CloseDown(status);
+    }
+
+  return(size);
+}
+
+
+/*
+ * This routine is called when a read to the pseudo terminal completes.
+ * Put the newly read buffer onto the read queue.  It will be processed
+ * and freed in the routine tt_read.
+ */
+
+static void tt_read_ast(TT_BUF_STRUCT *buff_addr)
+{
+  int status;
+
+  if (buff_addr->status & SS$_NORMAL)
+    {
+      status = LIB$INSQTI(buff_addr, &read_queue);
+      if ((status != SS$_NORMAL) && (status != LIB$_ONEENTQUE))
+       {
+         CloseDown(status);
+       }
+    }
+  else
+    CloseDown(buff_addr->status);
+
+  tt_start_read();
+  sys$wake(0,0);
+  return;
+}
+
+
+/*
+ * If there is a free buffer on the buffer queue then Start a read from
+ * the pseudo terminal, otherwise set a flag, the reading will be restarted
+ * in the routine freeBuff when a buffer is freed.
+ */
+
+void tt_start_read(void)
+{
+  int status;
+  static int size;
+  TT_BUF_STRUCT *buff_addr;
+
+  buff_addr = getBuff();
+  if (buff_addr != LIB$_QUEWASEMP)
+    {
+      if(!tt_pasting){
+      status = PTD$READ (0, tt_chan, &tt_read_ast, buff_addr,
+                        &buff_addr->status, VMS_TERM_BUFFER_SIZE);
+      if ((status & SS$_NORMAL) != SS$_NORMAL)
+       {
+         CloseDown(status);
+       }
+      }
+      }
+  else
+    {
+      read_stopped = True;
+    }
+  return;
+}
+
+
+/*
+ * Get data from the pseudo terminal.  Return the data from the first item
+ * on the read queue, and put that buffer back onto the free buffer queue.
+ * Return the length or zero if the read queue is empty.
+ *
+ */
+
+int tt_read(char *buffer)
+{
+  TT_BUF_STRUCT *read_buff;
+  int status;
+  int len;
+
+   status = LIB$REMQHI(&read_queue, &read_buff);
+   if(status == LIB$_QUEWASEMP){
+     return(0);
+   }
+   else if (status & SS$_NORMAL)
+     {
+       len = read_buff->length;
+       memmove(buffer,&read_buff->data,len);
+       freeBuff(read_buff);
+       tt_new_output=True; /* DRM something will be written */
+     }
+   else
+     CloseDown(status);
+
+   return(len);
+}
+
+
+/*
+ * if xon then it is safe to start writing again.
+ */
+
+static void send_xon(void)
+{
+  write_stopped = False;
+}
+
+
+/*
+ * If Xoff then stop writing to the pseudo terminal until you get Xon.
+ */
+static void send_xoff(void)
+{
+  write_stopped = True;
+}
+
+
+
+/*
+ * Beep the terminal to let the user know data will be lost because
+ * of too much data.
+ */
+
+static void send_bell(void)
+{
+   Bell(term);
+}
+
+/*
+ * if the pseudo terminal's characteristics change, check to see if the
+ * page size changed.  If it did, resize the widget, otherwise, ignore
+ * it!  This routine just gets the new term dimensions and sets a flag
+ * to indicate the term chars have changed.  The widget gets resized in
+ * the routine in_put in the module CHARPROC.C.  You cant resize the
+ * widget in this routine because this is an AST and X is not reenterent.
+ */
+
+static void char_change(void)
+{
+  int status;
+
+  /*
+   * Dont do anything if in Tek mode
+   */
+
+  if(!(TScreenOf(term)->TekEmu))
+    {
+      status = sys$qiow(0,tt_chan,IO$_SENSEMODE,0,0,0,&tt_mode,8,0,0,0,0);
+      if(!(status & SS$_NORMAL)) CloseDown(status);
+
+      if((TScreenOf(term)->max_row != tt_mode.length) ||
+        (TScreenOf(term)->max_col != tt_mode.page_width))
+       {
+         tt_length = tt_mode.length;
+         tt_width =  tt_mode.page_width;
+
+         tt_changed = True;
+
+       }
+    }
+}
+
+
+/*
+ * Put a free buffer back onto the buffer queue.  If reading was
+ * stopped for lack of free buffers, start reading again.
+ */
+
+static void freeBuff (TT_BUF_STRUCT *buff_addr)
+{
+  int ast_stat;
+  int status;
+
+  ast_stat = SYS$SETAST(0);
+  if (!read_stopped)
+    {
+      LIB$INSQHI(buff_addr, &buffer_queue);
+    }
+  else
+    {
+      status = PTD$READ (0, tt_chan, &tt_read_ast, buff_addr,
+                        &buff_addr->status, VMS_TERM_BUFFER_SIZE);
+      if (status & SS$_NORMAL)
+       {
+         read_stopped = False;
+       }
+      else
+       {
+         CloseDown(status);
+       }
+    }
+  if (ast_stat == SS$_WASSET) ast_stat = SYS$SETAST(1);
+}
+
+
+/*
+ * return a free buffer from the buffer queue.
+ */
+
+TT_BUF_STRUCT *getBuff(void)
+{
+  int status;
+  TT_BUF_STRUCT *buff_addr;
+
+  status = LIB$REMQHI(&buffer_queue, &buff_addr);
+  if (status & SS$_NORMAL)
+    {
+      return(buff_addr);
+    }
+  else
+    {
+      return(status);
+    }
+}
+
+
+/*
+ * Close down and exit.  Kill the detached process (if it still
+ * exists), deassign mailbox channell (if assigned), cancel any
+ * waiting IO to the pseudo terminal and delete it, exit with any
+ * status information.
+ */
+
+static void CloseDown(int exit_status)
+{
+  int status;
+
+  /* if process has not terminated, do so now! */
+  if(pid != 0)
+    {
+      status = sys$forcex(&pid,0,0);
+      if(!(status & SS$_NORMAL)) lib$signal(status);
+    }
+
+  /* if mbx_chan is assigned, deassign it */
+  if(mbx_chan != 0)
+    {
+      sys$dassgn(mbx_chan);
+    }
+
+  /* cancel pseudo terminal IO requests */
+  status = ptd$cancel(tt_chan);
+  if(!(status & SS$_NORMAL)) lib$signal(status);
+
+  /* delete pseudo terminal */
+  status = ptd$delete(tt_chan);
+  if(!(status & SS$_NORMAL)) lib$signal(status);
+
+  if(!(exit_status & SS$_NORMAL)) lib$signal(exit_status);
+
+  exit(1);
+
+}
+
+
+/*
+ * This routine gets called when the detached process terminates (for
+ * whatever reason).  The mailbox buffer has final exit status.  Close
+ * down and exit.
+ */
+
+static void mbx_read_ast(void)
+{
+  int status;
+
+  pid = 0;
+
+  status = mbx_read_iosb.status;
+  if (!(status & SS$_NORMAL)) CloseDown(status);
+
+  status = (unsigned long int) mbx_buf.acc$l_finalsts;
+  if (!(status & SS$_NORMAL)) CloseDown(status);
+
+  CloseDown(1);
+
+}
+
+
+/*
+ * This routine starts a read on the mailbox associated with the detached
+ * process.  The AST routine gets called when the detached process terminates.
+ */
+
+static void mbx_read(void)
+{
+int status;
+static int size;
+
+   size = ACC$K_TERMLEN;
+   status = sys$qio(0,mbx_chan,
+          IO$_READVBLK,
+          &mbx_read_iosb,
+          &mbx_read_ast,
+          0,
+          &mbx_buf,
+          size,0,0,0,0);
+
+   if (!(status & SS$_NORMAL)) CloseDown(status);
+
+   return;
+}
diff --git a/vms.h b/vms.h
new file mode 100644 (file)
index 0000000..8eb2064
--- /dev/null
+++ b/vms.h
@@ -0,0 +1,41 @@
+/* $XFree86: xc/programs/xterm/vms.h,v 1.1 2000/02/08 17:19:45 dawes Exp $ */
+
+/* vms.h
+ */
+#include <ssdef.h>
+#include <iodef.h>
+#include <msgdef.h>
+#include <descrip.h>
+#include <dvidef.h>
+#include <jpidef.h>
+#include <prcdef.h>
+#include <dcdef.h>
+#include <ttdef.h>
+#include <tt2def.h>
+#include <accdef.h>
+#include <prvdef.h>
+
+struct IOSB
+{
+       short int status;
+       short int len;
+       int unused;
+} mbx_read_iosb,iosb;
+
+#define MAXITEMLIST   5
+
+short int      tt_chan;    /* channel to the Pseudo terminal */
+short int      mbx_chan;   /* channel to the mailbox */
+struct accdef  mbx_buf;    /* mailbox buffer */
+short int      mbxunit;    /* mailbox unit number */
+int            pid;            /* PID of created process */
+static $DESCRIPTOR  (image, "SYS$SYSTEM:LOGINOUT.EXE");
+
+static struct      items {
+       short int       buflen;
+       short int       code;
+       int             buffer;
+       int             return_addr;
+} itemlist[MAXITEMLIST];
+
+int tt_write(const char *tt_write_buf,int size);
diff --git a/vttests/16colors.sh b/vttests/16colors.sh
new file mode 100755 (executable)
index 0000000..1b43c8c
--- /dev/null
@@ -0,0 +1,119 @@
+#!/bin/sh
+# $XTermId: 16colors.sh,v 1.13 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Show a simple 16-color test pattern.  It is a little more confusing than
+# 8colors.sh, since everything is abbreviated to fit on an 80-column line.
+# The high (8-15) combinations for foreground or background are marked with
+# a '+' sign.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD "\e[0m"; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD "\e[0m"; exit' 0    1   2   5    15
+fi
+
+echo "\e[0m"
+while true
+do
+    for AT in 0 1 4 7
+    do
+       case $AT in
+       0) attr="   ";;
+       1) attr="BO ";;
+       4) attr="UN ";;
+       7) attr="RV ";;
+       esac
+       for FG in 0 1 2 3 4 5 6 7
+       do
+           case $FG in
+           0) fcolor="BLK ";;
+           1) fcolor="RED ";;
+           2) fcolor="GRN ";;
+           3) fcolor="YEL ";;
+           4) fcolor="BLU ";;
+           5) fcolor="MAG ";;
+           6) fcolor="CYN ";;
+           7) fcolor="WHT ";;
+           esac
+           for HI in 3 9
+           do
+               if test $HI = 3 ; then
+                   color=" $fcolor"
+               else
+                   color="+$fcolor"
+               fi
+               $CMD $OPT "\e[0;${AT}m$attr$SUF"
+               $CMD $OPT "\e[${HI}${FG}m$color$SUF"
+               for BG in 1 2 3 4 5 6 7
+               do
+                   case $BG in
+                   0) bcolor="BLK ";;
+                   1) bcolor="RED ";;
+                   2) bcolor="GRN ";;
+                   3) bcolor="YEL ";;
+                   4) bcolor="BLU ";;
+                   5) bcolor="MAG ";;
+                   6) bcolor="CYN ";;
+                   7) bcolor="WHT ";;
+                   esac
+                   $CMD $OPT "\e[4${BG}m$bcolor$SUF"
+                   $CMD $OPT "\e[10${BG}m+$bcolor$SUF"
+               done
+               echo "\e[0m"
+           done
+       done
+       sleep 1
+    done
+done
diff --git a/vttests/256colors.pl b/vttests/256colors.pl
new file mode 100755 (executable)
index 0000000..57976f7
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+# $XTermId: 256colors.pl,v 1.4 2006/09/29 21:49:03 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999,2006 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# This uses 33 print-lines on an 80-column display.  Printing the numbers in
+# hexadecimal would make it compact enough for 24x80, but less readable.
+
+for ($bg = 0; $bg < 256; $bg++) {
+    # print "\x1b[9;1H\x1b[2J";
+    for ($fg = 0; $fg < 256; $fg++) {
+       print "\x1b[48;5;${bg}m\x1b[38;5;${fg}m";
+       printf "%03.3d/%03.3d ", $fg, $bg;
+    }
+    print "\n";
+    sleep 1;
+}
diff --git a/vttests/256colors2.pl b/vttests/256colors2.pl
new file mode 100755 (executable)
index 0000000..2a880bd
--- /dev/null
@@ -0,0 +1,129 @@
+#!/usr/bin/perl
+# $XTermId: 256colors2.pl,v 1.10 2009/10/10 14:45:26 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2007,2009 by Thomas E. Dickey
+# Copyright 2002 by Steve Wall
+# Copyright 1999 by Todd Larason
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+use strict;
+
+use Getopt::Std;
+
+our ($opt_h, $opt_q, $opt_r);
+&getopts('hqr') || die("Usage: $0 [-q] [-r]");
+die("Usage: $0 [options]\n
+Options:
+  -h  display this message
+  -q  quieter output by merging all palette initialization
+  -r  display the reverse of the usual palette
+") if ( $opt_h);
+
+our ($red, $green, $blue);
+our ($gray, $level, $color);
+
+sub map_cube($) {
+       my $value = $_[0];
+       $value = (5 - $value) if defined($opt_r);
+       return $value;
+}
+
+sub map_gray($) {
+       my $value = $_[0];
+       $value = (23 - $value) if defined($opt_r);
+       return $value;
+}
+
+printf("\x1b]4") if ($opt_q);
+# colors 16-231 are a 6x6x6 color cube
+for ($red = 0; $red < 6; $red++) {
+    for ($green = 0; $green < 6; $green++) {
+       for ($blue = 0; $blue < 6; $blue++) {
+           printf("\x1b]4") unless ($opt_q);
+           printf(";%d;rgb:%2.2x/%2.2x/%2.2x",
+                  16 + (map_cube($red) * 36) + (map_cube($green) * 6) + map_cube($blue),
+                  ($red ? ($red * 40 + 55) : 0),
+                  ($green ? ($green * 40 + 55) : 0),
+                  ($blue ? ($blue * 40 + 55) : 0));
+           printf("\x1b\\") unless ($opt_q);
+       }
+    }
+}
+
+# colors 232-255 are a grayscale ramp, intentionally leaving out
+# black and white
+for ($gray = 0; $gray < 24; $gray++) {
+    $level = (map_gray($gray) * 10) + 8;
+    printf("\x1b]4") unless ($opt_q);
+    printf(";%d;rgb:%2.2x/%2.2x/%2.2x",
+          232 + $gray, $level, $level, $level);
+    printf("\x1b\\") unless ($opt_q);
+}
+printf("\x1b\\") if ($opt_q);
+
+
+# display the colors
+
+# first the system ones:
+print "System colors:\n";
+for ($color = 0; $color < 8; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
+for ($color = 8; $color < 16; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n\n";
+
+# now the color cube
+print "Color cube, 6x6x6:\n";
+for ($green = 0; $green < 6; $green++) {
+    for ($red = 0; $red < 6; $red++) {
+       for ($blue = 0; $blue < 6; $blue++) {
+           $color = 16 + ($red * 36) + ($green * 6) + $blue;
+           print "\x1b[48;5;${color}m  ";
+       }
+       print "\x1b[0m ";
+    }
+    print "\n";
+}
+
+
+# now the grayscale ramp
+print "Grayscale ramp:\n";
+for ($color = 232; $color < 256; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
diff --git a/vttests/88colors.pl b/vttests/88colors.pl
new file mode 100755 (executable)
index 0000000..3db178c
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+# $XTermId: 88colors.pl,v 1.3 1999/09/27 20:12:18 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Made from 256colors.pl
+
+for ($bg = 0; $bg < 88; $bg++) {
+    print "\x1b[9;1H\x1b[48;5;${bg}m\x1b[2J";
+    for ($fg = 0; $fg < 88; $fg++) {
+       print "\x1b[38;5;${fg}m";
+       printf "%03.3d/%03.3d ", $fg, $bg;
+    }
+    sleep 1;
+    print "\n";
+}
diff --git a/vttests/88colors2.pl b/vttests/88colors2.pl
new file mode 100755 (executable)
index 0000000..9c63b8c
--- /dev/null
@@ -0,0 +1,133 @@
+#!/usr/bin/perl
+# $XTermId: 88colors2.pl,v 1.7 2009/10/10 14:57:12 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2007,2009 by Thomas E. Dickey
+# Copyright 1999 by Steve Wall
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+#
+# Adapted from 256colors2.pl
+
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+use strict;
+
+use Getopt::Std;
+
+our ($opt_h, $opt_q, $opt_r);
+&getopts('hqr') || die("Usage: $0 [-q] [-r]");
+die("Usage: $0 [options]\n
+Options:
+  -h  display this message
+  -q  quieter output by merging all palette initialization
+  -r  display the reverse of the usual palette
+") if ( $opt_h);
+
+our (@steps);
+our ($red, $green, $blue);
+our ($gray, $level, $color);
+
+sub map_cube($) {
+       my $value = $_[0];
+       $value = (3 - $value) if defined($opt_r);
+       return $value;
+}
+
+sub map_gray($) {
+       my $value = $_[0];
+       $value = (7 - $value) if defined($opt_r);
+       return $value;
+}
+
+# colors 16-79 are a 4x4x4 color cube
+@steps=(0,139,205,255);
+printf("\x1b]4") if ($opt_q);
+for ($red = 0; $red < 4; $red++) {
+    for ($green = 0; $green < 4; $green++) {
+       for ($blue = 0; $blue < 4; $blue++) {
+           printf("\x1b]4") unless ($opt_q);
+           printf(";%d;rgb:%2.2x/%2.2x/%2.2x",
+                  16 + (map_cube($red) * 16) + (map_cube($green) * 4) + map_cube($blue),
+                  int (@steps[$red]),
+                  int (@steps[$green]),
+                  int (@steps[$blue]));
+           printf("\x1b\\") unless ($opt_q);
+       }
+    }
+}
+
+# colors 80-87 are a grayscale ramp, intentionally leaving out
+# black and white
+for ($gray = 0; $gray < 8; $gray++) {
+    $level = (map_gray($gray) * 23.18181818) + 46.36363636;
+    if( $gray > 0 ) { $level += 23.18181818; }
+    printf("\x1b]4") unless ($opt_q);
+    printf(";%d;rgb:%2.2x/%2.2x/%2.2x",
+          80 + $gray, int($level), int($level), int($level));
+    printf("\x1b\\") unless ($opt_q);
+}
+printf("\x1b\\") if ($opt_q);
+
+
+# display the colors
+
+# first the system ones:
+print "System colors:\n";
+for ($color = 0; $color < 8; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
+for ($color = 8; $color < 16; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n\n";
+
+# now the color cube
+print "Color cube, 4x4x4:\n";
+for ($green = 0; $green < 4; $green++) {
+    for ($red = 0; $red < 4; $red++) {
+       for ($blue = 0; $blue < 4; $blue++) {
+           $color = 16 + ($red * 16) + ($green * 4) + $blue;
+           print "\x1b[48;5;${color}m  ";
+       }
+       print "\x1b[0m ";
+    }
+    print "\n";
+}
+
+
+# now the grayscale ramp
+print "Grayscale ramp:\n";
+for ($color = 80; $color < 88; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
diff --git a/vttests/8colors.sh b/vttests/8colors.sh
new file mode 100755 (executable)
index 0000000..616755f
--- /dev/null
@@ -0,0 +1,107 @@
+#!/bin/sh
+# $XTermId: 8colors.sh,v 1.13 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Show a simple 8-color test pattern
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD $OPT "\e[0m"; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD $OPT "\e[0m"; exit' 0    1   2   5    15
+fi
+
+echo "\e[0m"
+while true
+do
+    for AT in 0 1 4 7
+    do
+       case $AT in
+       0) attr="normal  ";;
+       1) attr="bold    ";;
+       4) attr="under   ";;
+       7) attr="reverse ";;
+       esac
+       for FG in 0 1 2 3 4 5 6 7
+       do
+           case $FG in
+           0) fcolor="black   ";;
+           1) fcolor="red     ";;
+           2) fcolor="green   ";;
+           3) fcolor="yellow  ";;
+           4) fcolor="blue    ";;
+           5) fcolor="magenta ";;
+           6) fcolor="cyan    ";;
+           7) fcolor="white   ";;
+           esac
+           $CMD $OPT "\e[0;${AT}m$attr"
+           $CMD $OPT "\e[3${FG}m$fcolor"
+           for BG in 1 2 3 4 5 6 7
+           do
+               case $BG in
+               0) bcolor="black   ";;
+               1) bcolor="red     ";;
+               2) bcolor="green   ";;
+               3) bcolor="yellow  ";;
+               4) bcolor="blue    ";;
+               5) bcolor="magenta ";;
+               6) bcolor="cyan    ";;
+               7) bcolor="white   ";;
+               esac
+               $CMD $OPT "\e[4${BG}m$bcolor"
+           done
+           echo "\e[0m"
+       done
+       sleep 1
+    done
+done
diff --git a/vttests/acolors.sh b/vttests/acolors.sh
new file mode 100755 (executable)
index 0000000..d0c7c0d
--- /dev/null
@@ -0,0 +1,93 @@
+#!/bin/sh
+# $XTermId: acolors.sh,v 1.6 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Demonstrate the use of the control sequence for changing ANSI colors.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+LIST="00 30 80 d0 ff"
+
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 5
+
+$CMD $OPT "${ESC}]4;4;?\a${SUF}" > /dev/tty
+read original
+stty $old
+original=${original}${SUF}
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD $OPT "$original" >/dev/tty; exit' 0    1   2   5    15
+fi
+
+$CMD "${ESC}[0;1;34mThis message is BLUE"
+$CMD "${ESC}[0;1;31mThis message is RED ${ESC}[0;31m(sometimes)"
+$CMD "${ESC}[0;1;32mThis message is GREEN${ESC}[0m"
+while true
+do
+    for R in $LIST
+    do
+       for G in $LIST
+       do
+           for B in $LIST
+           do
+               # color "9" is bold-red
+               test $R != 00 && test $G = 00 && test $B = 00 && $CMD $OPT "\a" >/dev/tty
+               $CMD $OPT "${ESC}]4;9;rgb:$R/$G/$B\a${SUF}" >/dev/tty
+               sleep 1
+           done
+       done
+    done
+done
diff --git a/vttests/doublechars.sh b/vttests/doublechars.sh
new file mode 100755 (executable)
index 0000000..2facb3d
--- /dev/null
@@ -0,0 +1,116 @@
+#!/bin/sh
+# $XTermId: doublechars.sh,v 1.16 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Illustrate the use of double-size characters by drawing successive lines in
+# the commonly used video attributes.
+#
+# Use the -w option to force the output to wrap.  It will look ugly, because
+# the double-high lines will be split.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+SAVE=yes
+WRAP=no
+if test $# != 0 ; then
+    while test $# != 0
+    do
+       case $1 in
+       -n)     SAVE=no ;;
+       -w)     WRAP=yes ;;
+       esac
+       shift
+    done
+fi
+
+if test $SAVE = yes ; then
+    exec </dev/tty
+    old=`stty -g`
+    stty raw -echo min 0  time 5
+
+    $CMD $OPT "${ESC}[18t${SUF}" > /dev/tty
+    IFS=';' read junk high wide
+
+    stty $old
+
+    wide=`echo $wide|sed -e 's/t.*//'`
+    original=${ESC}[8\;${high}\;${wide}t${SUF}
+
+    if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+    then
+       trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM
+    else
+       trap '$CMD $OPT "$original" >/dev/tty; exit' 0    1   2   5    15
+    fi
+
+fi
+
+if test $WRAP = yes ; then
+       # turn on wrapping and force the screen to 80 columns
+       $CMD $OPT "${ESC}[?7h" >/dev/tty
+       $CMD $OPT "${ESC}[?40l" >/dev/tty
+else
+       # force the screen to 132 columns
+       $CMD $OPT "${ESC}[?40h" >/dev/tty
+       $CMD $OPT "${ESC}[?3h" >/dev/tty
+fi
+
+for SGR in 0 1 4 5 7
+do
+       $CMD $OPT "${ESC}[0;${SGR}m" >/dev/tty
+       for DBL in 5 3 4 6 5
+       do
+               $CMD $OPT "${ESC}#${DBL}" >/dev/tty
+               echo "The quick brown fox jumps over the lazy dog" >/dev/tty
+       done
+       echo
+done
+$CMD $OPT "${ESC}[0m" >/dev/tty
diff --git a/vttests/dynamic.sh b/vttests/dynamic.sh
new file mode 100755 (executable)
index 0000000..e5a2cd6
--- /dev/null
@@ -0,0 +1,89 @@
+#!/bin/sh
+# $XTermId: dynamic.sh,v 1.16 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Demonstrate the use of dynamic colors by setting the background successively
+# to different values.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+LIST="00 30 80 d0 ff"
+
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 5
+
+$CMD $OPT "${ESC}]11;?\a${SUF}" > /dev/tty
+read original
+stty $old
+original=${original}${SUF}
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD $OPT "$original" >/dev/tty; exit' 0    1   2   5    15
+fi
+
+while true
+do
+    for R in $LIST
+    do
+       for G in $LIST
+       do
+           for B in $LIST
+           do
+               $CMD $OPT "${ESC}]11;rgb:$R/$G/$B\a${SUF}" >/dev/tty
+               sleep 1
+           done
+       done
+    done
+done
diff --git a/vttests/dynamic2.sh b/vttests/dynamic2.sh
new file mode 100755 (executable)
index 0000000..7e7f02a
--- /dev/null
@@ -0,0 +1,114 @@
+#!/bin/sh
+# $XTermId: dynamic2.sh,v 1.2 2006/10/17 20:37:21 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2006 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Demonstrate the use of dynamic colors by setting each dynamic color
+# successively to different values.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+LIST="00 30 80 d0 ff"
+FULL="10 11 12 13 14 15 16 17 18"
+
+echo "reading current color settings"
+
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 5
+
+original=
+for N in $FULL
+do
+    $CMD $OPT "${ESC}]$N;?\a${SUF}" > /dev/tty
+    read reply
+    eval original$N='${reply}${SUF}'
+    original=${original}${reply}${SUF}
+done
+stty $old
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD $OPT "$original" >/dev/tty; exit' 0    1   2   5    15
+fi
+
+while true
+do
+    for N in $FULL
+    do
+       case $N in
+       10) echo "coloring text foreground";;
+       11) echo "coloring text background";;
+       12) echo "coloring text cursor";;
+       13) echo "coloring mouse foreground";;
+       14) echo "coloring mouse background";;
+       15) echo "coloring tektronix foreground";;
+       16) echo "coloring tektronix background";;
+       17) echo "coloring highlight background";;
+       18) echo "coloring tektronix cursor";;
+       esac
+       for R in $LIST
+       do
+           for G in $LIST
+           do
+               for B in $LIST
+               do
+                   $CMD $OPT "${ESC}]$N;rgb:$R/$G/$B\a${SUF}" >/dev/tty
+                   sleep 1
+               done
+           done
+       done
+       eval 'restore=$'original$N
+       $CMD $OPT "$restore" >/dev/tty
+       sleep 1
+    done
+done
diff --git a/vttests/fonts.sh b/vttests/fonts.sh
new file mode 100755 (executable)
index 0000000..e970d7e
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+# $XTermId: fonts.sh,v 1.10 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Demonstrate the use of dynamic colors by setting the background successively
+# to different values.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 5
+
+$CMD $OPT "${ESC}]50;?\a${SUF}" > /dev/tty
+read original
+
+stty $old
+original="${original}${SUF}"
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD $OPT "$original" >/dev/tty; exit' 0    1   2   5    15
+fi
+
+F=1
+D=1
+T=6
+while true
+do
+    $CMD $OPT "${ESC}]50;#$F\a${SUF}" >/dev/tty
+    #sleep 1
+    if test .$D = .1 ; then
+       test $F = $T && D=-1
+    else
+       test $F = 1 && D=1
+    fi
+    F=`expr $F + $D`
+done
diff --git a/vttests/paste64.pl b/vttests/paste64.pl
new file mode 100755 (executable)
index 0000000..619a222
--- /dev/null
@@ -0,0 +1,171 @@
+#!/usr/bin/perl -w
+# $XTermId: paste64.pl,v 1.10 2006/03/13 01:28:02 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2006 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Test the paste64 option of xterm.
+
+use strict;
+
+use Term::ReadKey;
+use IO::Handle;
+use MIME::Base64;
+
+our $target = "";
+
+sub to_hex($) {
+       my $value = $_[0];
+       my $result = "";
+       my $n;
+
+       for ( $n = 0; $n < length($value); ++$n) {
+               $result .= sprintf("%02X", ord substr($value,$n,1));
+       }
+       return $result;
+}
+
+sub show_string($) {
+       my $value = $_[0];
+       my $n;
+
+       my $result = "";
+       for ( $n = 0; $n < length($value); $n += 1) {
+               my $c = ord substr($value,$n,1);
+               if ( $c == ord '\\' ) {
+                       $result .= "\\\\";
+               } elsif ( $c == 0x1b ) {
+                       $result .= "\\E";
+               } elsif ( $c == 0x7f ) {
+                       $result .= "^?";
+               } elsif ( $c == 32 ) {
+                       $result .= "\\s";
+               } elsif ( $c < 32 ) {
+                       $result .= sprintf("^%c", $c + 64);
+               } elsif ( $c > 128 ) {
+                       $result .= sprintf("\\%03o", $c);
+               } else {
+                       $result .= chr($c);
+               }
+       }
+
+       printf "%s\r\n", $result;
+}
+
+sub get_reply($) {
+       my $command = $_[0];
+       my $reply = "";
+
+       printf "send: ";
+       show_string($command);
+
+       print STDOUT $command;
+       autoflush STDOUT 1;
+       while (1) {
+               my $test=ReadKey 1;
+               last if not defined $test;
+               #printf "%d:%s\r\n", length($reply), to_hex($test);
+               $reply .= $test;
+       }
+       return $reply;
+}
+
+sub get_paste() {
+       my $reply = get_reply("\x1b]52;" . $target . ";?\x1b\\");
+
+       printf "read: ";
+       show_string($reply);
+
+       my $data = $reply;
+       $data =~ s/^\x1b]52;[[:alnum:]]*;//;
+       $data =~ s/\x1b\\$//;
+       printf "chop: ";
+       show_string($data);
+
+        $data = decode_base64($data);
+       printf "data: ";
+       show_string($data);
+}
+
+sub put_paste() {
+       ReadMode 1;
+
+       printf "data: ";
+       my $data = ReadLine 0;
+       chomp $data;
+       ReadMode 5;
+
+       $data = encode_base64($data);
+       chomp $data;
+       printf "data: ";
+       show_string($data);
+
+       my $send = "\x1b]52;" . $target . ";" . $data . "\x1b\\";
+
+       printf "send: ";
+       show_string($send);
+}
+
+sub set_target() {
+       ReadMode 1;
+
+       printf "target: ";
+       $target = ReadLine 0;
+       $target =~ s/[^[:alnum:]]//g;
+       ReadMode 5;
+       printf "result: %s\r\n", $target;
+}
+
+ReadMode 5, 'STDIN'; # allow single-character inputs
+while (1) {
+       my $cmd;
+
+       printf "\r\nCommand (? for help):";
+       $cmd = ReadKey 0;
+       if ( $cmd eq "?" ) {
+               printf "\r\np=put selection, g=get selection, q=quit, r=reset target, s=set target\r\n";
+       } elsif ($cmd eq "p") {
+               printf " ...put selection\r\n";
+               put_paste();
+       } elsif ($cmd eq "g") {
+               printf " ...get selection\r\n";
+               get_paste();
+       } elsif ($cmd eq "q") {
+               printf " ...quit\r\n";
+               last;
+       } elsif ($cmd eq "r") {
+               printf " ...reset\r\n";
+               $target = "";
+       } elsif ($cmd eq "s") {
+               printf " ...set target\r\n";
+               set_target();
+       }
+}
+ReadMode 0, 'STDIN'; # Reset tty mode before exiting
diff --git a/vttests/query-fonts.pl b/vttests/query-fonts.pl
new file mode 100755 (executable)
index 0000000..2b86c07
--- /dev/null
@@ -0,0 +1,166 @@
+#!/usr/bin/perl -w
+# $XTermId: query-fonts.pl,v 1.5 2010/05/24 09:01:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2010 by Thomas E. Dickey
+#
+#                         All Rights Reserved
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Test the font-query features of xterm.
+
+# TODO:
+# test relative vs absolute font numbering
+# test all font-slots
+# test selection
+# test bold / wide / widebold
+# test actual fontname vs nominal
+# extend "CSI > Ps; Ps T" to query fontname in hex
+
+use strict;
+
+use Getopt::Std;
+use IO::Handle;
+
+our ( $opt_a, $opt_r, $opt_s );
+&getopts('ars') || die(
+    "Usage: $0 [options]\n
+Options:\n
+  -a      test using absolute numbers
+  -r      test using relative numbers
+  -s      use ^G rather than ST
+"
+);
+
+our $ST = $opt_s ? "\007" : "\x1b\\";
+
+sub no_reply($) {
+    open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n");
+    autoflush TTY 1;
+    my $old = `stty -g`;
+    system "stty raw -echo min 0 time 5";
+
+    print TTY @_;
+    close TTY;
+    system "stty $old";
+}
+
+sub get_reply($) {
+    open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n");
+    autoflush TTY 1;
+    my $old = `stty -g`;
+    system "stty raw -echo min 0 time 5";
+
+    print TTY @_;
+    my $reply = <TTY>;
+    close TTY;
+    system "stty $old";
+    if ( defined $reply ) {
+        die("^C received\n") if ( "$reply" eq "\003" );
+    }
+    return $reply;
+}
+
+sub query_font($) {
+    my $param = $_[0];
+    my $reply;
+    my $n;
+    my $st    = $opt_s ? qr/\007/ : qr/\x1b\\/;
+    my $osc   = qr/\x1b]50/;
+    my $match = qr/${osc}.*${st}/;
+
+    $reply = get_reply( "\x1b]50;?" . $param . $ST );
+
+    printf "query{%s}%*s", $param, 3 - length($param), " ";
+
+    if ( defined $reply ) {
+        printf "%2d ", length($reply);
+        if ( $reply =~ /${match}/ ) {
+
+            $reply =~ s/^${osc}//;
+            $reply =~ s/^;//;
+            $reply =~ s/${st}$//;
+        }
+        else {
+            printf "? ";
+        }
+
+        my $result = "";
+        for ( $n = 0 ; $n < length($reply) ; ) {
+            my $c = substr( $reply, $n, 1 );
+            if ( $c =~ /[[:print:]]/ ) {
+                $result .= $c;
+            }
+            else {
+                my $k = ord substr( $reply, $n, 1 );
+                if ( ord $k == 0x1b ) {
+                    $result .= "\\E";
+                }
+                elsif ( $k == 0x7f ) {
+                    $result .= "^?";
+                }
+                elsif ( $k == 32 ) {
+                    $result .= "\\s";
+                }
+                elsif ( $k < 32 ) {
+                    $result .= sprintf( "^%c", $k + 64 );
+                }
+                elsif ( $k > 128 ) {
+                    $result .= sprintf( "\\%03o", $k );
+                }
+                else {
+                    $result .= chr($k);
+                }
+            }
+            $n += 1;
+        }
+
+        printf "{%s}", $result;
+    }
+    printf "\n";
+}
+
+if ($opt_r) {
+    my $n;
+    query_font("-");
+    foreach $n ( 0 .. 5 ) {
+        query_font( sprintf "-%d", $n );
+    }
+    query_font("+");
+    foreach $n ( 0 .. 5 ) {
+        query_font( sprintf "+%d", $n );
+    }
+}
+if ($opt_a) {
+    my $n;
+    foreach $n ( 0 .. 5 ) {
+        query_font( sprintf "%d", $n );
+    }
+}
+if ( not $opt_a and not $opt_r ) {
+    query_font("");
+}
diff --git a/vttests/resize.pl b/vttests/resize.pl
new file mode 100755 (executable)
index 0000000..29d0d9b
--- /dev/null
@@ -0,0 +1,129 @@
+#!/usr/bin/perl
+# $XTermId: resize.pl,v 1.3 2004/03/04 02:21:58 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2004 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# resize.sh rewritten into Perl for comparison.
+# See also Term::ReadKey.
+
+use IO::Handle;
+
+sub write_tty {
+       open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n");
+       autoflush TTY 1;
+       print TTY @_;
+       close TTY;
+}
+
+sub get_reply {
+       open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n");
+       autoflush TTY 1;
+       $old=`stty -g`;
+       system "stty raw -echo min 0 time 5";
+
+       print TTY @_;
+       my $reply=<TTY>;
+       close TTY;
+       system "stty $old";
+       return $reply;
+}
+
+sub csi_field {
+       my $first = @_[0];
+       my $second = @_[1];
+       $first =~ s/^[^0-9]+//;
+       while ( --$second > 0 ) {
+               $first =~ s/^[\d]+//;
+               $first =~ s/^[^\d]+//;
+       }
+       $first =~ s/[^\d]+.*$//;
+       return $first;
+}
+
+$original=get_reply("\x1b[18t");
+if ( $original =~ /\x1b\[8;\d+;\d+t/ ) {
+       $high=csi_field($original,2);
+       $wide=csi_field($original,3);
+       printf "parsed terminal size $high,$wide\n";
+} else {
+       die "Cannot get terminal size via escape sequence\n";
+}
+#
+$maximize=get_reply("\x1b[19t");
+if ( $maximize =~ /\x1b\[9;\d+;\d+t/ ) {
+       $maxhigh=csi_field($maximize,2);
+       $maxwide=csi_field($maximize,3);
+       $maxhigh != 0 or $maxhigh = $high * 2;
+       $maxwide != 0 or $maxwide = $wide * 2;
+       printf "parsed terminal maxsize $maxhigh,$maxwide\n";
+} else {
+       die "Cannot get terminal size via escape sequence\n";
+}
+
+sub catch_zap {
+       $zapped++;
+}
+$SIG{INT} = \&catch_zap;
+$SIG{QUIT} = \&catch_zap;
+$SIG{KILL} = \&catch_zap;
+$SIG{HUP} = \&catch_zap;
+$SIG{TERM} = \&catch_zap;
+
+$w=$wide;
+$h=$high;
+$a=1;
+$zapped=0;
+while ( $zapped == 0 )
+{
+#      sleep 1
+       printf "resizing to $h by $w\n";
+       write_tty("\x1b[8;$h;$w" . "t");
+       if ( $a == 1 ) {
+               if ( $w == $maxwide ) {
+                       $h += $a;
+                       if ( $h = $maxhigh ) {
+                               $a = -1;
+                       }
+               } else {
+                       $w += $a;
+               }
+       } else {
+               if ( $w == $wide ) {
+                       $h += $a;
+                       if ( $h = $high ) {
+                               $a=1;
+                       }
+               } else {
+                       $w += $a;
+               }
+       }
+}
+write_tty($original);
diff --git a/vttests/resize.sh b/vttests/resize.sh
new file mode 100755 (executable)
index 0000000..b870795
--- /dev/null
@@ -0,0 +1,111 @@
+#!/bin/sh
+# $XTermId: resize.sh,v 1.16 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Obtain the current screen size, then resize the terminal to the nominal
+# screen width/height, and restore the size.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 5
+
+$CMD $OPT "${ESC}[18t${SUF}" > /dev/tty
+IFS=';' read junk high wide
+
+$CMD $OPT "${ESC}[19t${SUF}" > /dev/tty
+IFS=';' read junk maxhigh maxwide
+
+stty $old
+
+wide=`echo $wide|sed -e 's/t.*//'`
+maxwide=`echo $maxwide|sed -e 's/t.*//'`
+original=${ESC}[8\;${high}\;${wide}t${SUF}
+
+test $maxwide = 0 && maxwide=`expr $wide \* 2`
+test $maxhigh = 0 && maxhigh=`expr $high \* 2`
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD $OPT "$original" >/dev/tty; exit' 0    1   2   5    15
+fi
+
+w=$wide
+h=$high
+a=1
+while true
+do
+#      sleep 1
+       echo resizing to $h by $w
+       $CMD $OPT "${ESC}[8;${h};${w}t" >/dev/tty
+       if test $a = 1 ; then
+               if test $w = $maxwide ; then
+                       h=`expr $h + $a`
+                       if test $h = $maxhigh ; then
+                               a=-1
+                       fi
+               else
+                       w=`expr $w + $a`
+               fi
+       else
+               if test $w = $wide ; then
+                       h=`expr $h + $a`
+                       if test $h = $high ; then
+                               a=1
+                       fi
+               else
+                       w=`expr $w + $a`
+               fi
+       fi
+done
diff --git a/vttests/tcapquery.pl b/vttests/tcapquery.pl
new file mode 100755 (executable)
index 0000000..068cb22
--- /dev/null
@@ -0,0 +1,324 @@
+#!/usr/bin/perl -w
+# $XTermId: tcapquery.pl,v 1.18 2010/01/04 09:43:46 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2004-2008,2010 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Test the tcap-query option of xterm.
+
+use strict;
+
+use Getopt::Std;
+use IO::Handle;
+
+our ($opt_a, $opt_b, $opt_c, $opt_e, $opt_f, $opt_i, $opt_k, $opt_m, $opt_t, $opt_x, $opt_X);
+&getopts('abcefikmt:x:X') || die("Usage: $0 [options]\n
+Options:\n
+  -a      (same as -c -e -f -k -m)
+  -b      use both terminfo and termcap (default is termcap)
+  -c      cursor-keys
+  -e      editing keypad-keys
+  -f      function-keys
+  -i      use terminfo rather than termcap names
+  -k      numeric keypad-keys
+  -m      miscellaneous (none of -c, -e, -f, -k)
+  -t NAME use given NAME for \$TERM, set that in xterm's tcap keyboard
+  -x KEY  extended cursor/editing key (terminfo only)
+  -X      test all extended cursor- and/or editing-keys (terminfo)
+");
+
+if ( not ( defined($opt_c)
+       or defined($opt_e)
+       or defined($opt_f)
+       or defined($opt_k)
+       or defined($opt_m)
+       or defined($opt_x) ) ) {
+       $opt_a=1;
+}
+
+sub no_reply($) {
+       open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n");
+       autoflush TTY 1;
+       my $old=`stty -g`;
+       system "stty raw -echo min 0 time 5";
+
+       print TTY @_;
+       close TTY;
+       system "stty $old";
+}
+
+sub get_reply($) {
+       open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n");
+       autoflush TTY 1;
+       my $old=`stty -g`;
+       system "stty raw -echo min 0 time 5";
+
+       print TTY @_;
+       my $reply=<TTY>;
+       close TTY;
+       system "stty $old";
+       if ( defined $reply ) {
+               die("^C received\n") if ( "$reply" eq "\003" );
+       }
+       return $reply;
+}
+
+sub hexified($) {
+       my $value = $_[0];
+       my $result = "";
+       my $n;
+
+       for ( $n = 0; $n < length($value); ++$n) {
+               $result .= sprintf("%02X", ord substr($value,$n,1));
+       }
+       return $result;
+}
+
+sub modify_tcap($) {
+       my $name = $_[0];
+       my $param = hexified($name);
+       no_reply("\x1bP+p" . $param . "\x1b\\");
+}
+
+sub query_tcap($$) {
+       my $tcap = $_[0];
+       my $tinfo = $_[1];
+       my $param1 = hexified($tcap);
+       my $param2 = hexified($tinfo);
+       my $reply;
+
+       # uncomment one of the following lines
+       if ( defined($opt_b) ) {
+               $reply=get_reply("\x1bP+q" . $param1 . ";" . $param2 . "\x1b\\");
+       } elsif ( defined($opt_i) ) {
+               $reply=get_reply("\x1bP+q" . $param2 . "\x1b\\");
+       } else {
+               $reply=get_reply("\x1bP+q" . $param1 . "\x1b\\");
+       }
+
+       return unless defined $reply;
+       if ( $reply =~ /\x1bP1\+r[[:xdigit:]]+=[[:xdigit:]]*.*/ ) {
+               my $value = $reply;
+               my $n;
+
+               $value =~ s/^\x1bP1\+r//;
+               $value =~ s/\x1b\\//;
+
+               my $result = "";
+               for ( $n = 0; $n < length($value); ) {
+                       my $c = substr($value,$n,1);
+                       # handle semicolon and equals
+                       if ( $c =~ /[[:punct:]]/ ) {
+                               $n += 1;
+                               $result .= $c;
+                       } else {
+                               # handle hex-data
+                               my $k = hex substr($value,$n,2);
+                               if ( $k == 0x1b ) {
+                                       $result .= "\\E";
+                               } elsif ( $k == 0x7f ) {
+                                       $result .= "^?";
+                               } elsif ( $k == 32 ) {
+                                       $result .= "\\s";
+                               } elsif ( $k < 32 ) {
+                                       $result .= sprintf("^%c", $k + 64);
+                               } elsif ( $k > 128 ) {
+                                       $result .= sprintf("\\%03o", $k);
+                               } else {
+                                       $result .= chr($k);
+                               }
+                               $n += 2;
+                       }
+               }
+
+               printf "%s\n", $result;
+       }
+}
+
+# extended-keys are a feature of ncurses 5.0 and later
+sub query_extended($) {
+       my $name = $_[0];
+       my $n;
+
+       $name = "k" . $name if ( $name !~ /^k/ );
+
+       for ( $n = 2; $n <= 7; ++$n) {
+               my $test = $name;
+               $test = $test . $n if ( $n > 2 );
+               query_tcap( $name, $test );
+       }
+}
+
+query_tcap(    "TN",   "name");
+if ( defined($opt_t) ) {
+       printf "Setting TERM=%s\n", $opt_t;
+       modify_tcap($opt_t);
+}
+
+# See xtermcapKeycode()
+if ( defined($opt_a) || defined($opt_c) ) {
+query_tcap(    "ku",   "kcuu1");
+query_tcap(    "kd",   "kcud1");
+query_tcap(    "kr",   "kcuf1");
+query_tcap(    "kl",   "kcub1");
+
+query_tcap(    "kF",   "kind");
+query_tcap(    "kR",   "kri");
+query_tcap(    "%i",   "kRIT");
+query_tcap(    "#4",   "kLFT");
+}
+
+if ( defined($opt_a) || defined($opt_e) ) {
+query_tcap(    "kD",   "kdch1");
+query_tcap(    "kI",   "kich1");
+
+query_tcap(    "kh",   "khome");
+query_tcap(    "\@7",  "kend");
+query_tcap(    "#2",   "kHOM");
+query_tcap(    "*7",   "kEND");
+
+query_tcap(    "*6",   "kslt");
+query_tcap(    "#6",   "kSLT");
+query_tcap(    "\@0",  "kfnd");
+query_tcap(    "*0",   "kFND");
+
+query_tcap(    "kN",   "knp");
+query_tcap(    "kP",   "kpp");
+
+query_tcap(    "%c",   "kNXT");
+query_tcap(    "%e",   "kPRV");
+}
+
+if ( defined($opt_a) || defined($opt_f) ) {
+query_tcap(    "k1",   "kf1");
+query_tcap(    "k2",   "kf2");
+query_tcap(    "k3",   "kf3");
+query_tcap(    "k4",   "kf4");
+query_tcap(    "k5",   "kf5");
+query_tcap(    "k6",   "kf6");
+query_tcap(    "k7",   "kf7");
+query_tcap(    "k8",   "kf8");
+query_tcap(    "k9",   "kf9");
+query_tcap(    "k;",   "kf10");
+query_tcap(    "F1",   "kf11");
+query_tcap(    "F2",   "kf12");
+query_tcap(    "F3",   "kf13");
+query_tcap(    "F4",   "kf14");
+query_tcap(    "F5",   "kf15");
+query_tcap(    "F6",   "kf16");
+query_tcap(    "F7",   "kf17");
+query_tcap(    "F8",   "kf18");
+query_tcap(    "F9",   "kf19");
+query_tcap(    "FA",   "kf20");
+query_tcap(    "FB",   "kf21");
+query_tcap(    "FC",   "kf22");
+query_tcap(    "FD",   "kf23");
+query_tcap(    "FE",   "kf24");
+query_tcap(    "FF",   "kf25");
+query_tcap(    "FG",   "kf26");
+query_tcap(    "FH",   "kf27");
+query_tcap(    "FI",   "kf28");
+query_tcap(    "FJ",   "kf29");
+query_tcap(    "FK",   "kf30");
+query_tcap(    "FL",   "kf31");
+query_tcap(    "FM",   "kf32");
+query_tcap(    "FN",   "kf33");
+query_tcap(    "FO",   "kf34");
+query_tcap(    "FP",   "kf35");
+query_tcap(    "FQ",   "kf36");
+query_tcap(    "FR",   "kf37");
+query_tcap(    "FS",   "kf38");
+query_tcap(    "FT",   "kf39");
+query_tcap(    "FU",   "kf40");
+query_tcap(    "FV",   "kf41");
+query_tcap(    "FW",   "kf42");
+query_tcap(    "FX",   "kf43");
+query_tcap(    "FY",   "kf44");
+query_tcap(    "FZ",   "kf45");
+query_tcap(    "Fa",   "kf46");
+query_tcap(    "Fb",   "kf47");
+query_tcap(    "Fc",   "kf48");
+query_tcap(    "Fd",   "kf49");
+query_tcap(    "Fe",   "kf50");
+query_tcap(    "Ff",   "kf51");
+query_tcap(    "Fg",   "kf52");
+query_tcap(    "Fh",   "kf53");
+query_tcap(    "Fi",   "kf54");
+query_tcap(    "Fj",   "kf55");
+query_tcap(    "Fk",   "kf56");
+query_tcap(    "Fl",   "kf57");
+query_tcap(    "Fm",   "kf58");
+query_tcap(    "Fn",   "kf59");
+query_tcap(    "Fo",   "kf60");
+query_tcap(    "Fp",   "kf61");
+query_tcap(    "Fq",   "kf62");
+query_tcap(    "Fr",   "kf63");
+}
+
+if ( defined($opt_a) || defined($opt_k) ) {
+query_tcap(    "K1",   "ka1");
+query_tcap(    "K3",   "ka3");
+query_tcap(    "K4",   "kc1");
+query_tcap(    "K5",   "kc3");
+}
+
+if ( defined($opt_a) || defined($opt_m) ) {
+query_tcap(    "kB",   "kcbt");
+query_tcap(    "kC",   "kclr");
+query_tcap(    "&8",   "kund");
+
+query_tcap(    "kb",   "kbs");
+
+query_tcap(    "%1",   "khlp");
+query_tcap(    "#1",   "kHLP");
+
+query_tcap(    "Co",   "colors");
+}
+
+if ( defined ($opt_x) ) {
+       query_extended($opt_x);
+}
+
+if ( defined ($opt_X) ) {
+       if ( defined($opt_c) ) {
+               query_extended("DN");
+               query_extended("UP");
+               query_extended("LFT");
+               query_extended("RIT");
+       }
+       if ( defined($opt_e) ) {
+               query_extended("DC");
+               query_extended("END");
+               query_extended("HOM");
+               query_extended("IC");
+               query_extended("NXT");
+               query_extended("PRV");
+       }
+}
diff --git a/vttests/title.sh b/vttests/title.sh
new file mode 100755 (executable)
index 0000000..83be515
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/sh
+# $XTermId: title.sh,v 1.17 2003/05/19 00:52:30 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 1999-2002,2003 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+# Obtain the current title of the window, set up a simple clock which runs
+# until this script is interrupted, then restore the title.
+
+ESC="\e"
+CMD='echo'
+OPT='-n'
+SUF=''
+TMP=/tmp/xterm$$
+eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null
+( test ! -f $TMP || test -s $TMP ) &&
+for verb in printf print ; do
+    rm -f $TMP
+    eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null
+    if test -f $TMP ; then
+       if test ! -s $TMP ; then
+           CMD="$verb"
+           OPT=
+           SUF='\c'
+           break
+       fi
+    fi
+done
+rm -f $TMP
+
+exec </dev/tty
+old=`stty -g`
+stty raw -echo min 0  time 5
+
+$CMD $OPT "${ESC}[21t${SUF}" > /dev/tty
+read original
+
+stty $old
+
+# We actually get this terminated by an <esc>backslash, but the backslash
+# is lost.  We may lose doublequote characters when restoring the title,
+# depending on the shell.
+original=`echo "$original" |sed -e 's/^...//' -e 's/.$//'`
+original=${ESC}]2\;"${original}\a"${SUF}
+
+if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null
+then
+    trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM
+else
+    trap '$CMD $OPT "$original" >/dev/tty; exit' 0    1   2   5    15
+fi
+
+while true
+do
+       sleep 1
+       $CMD $OPT "${ESC}]2;`date`\a" >/dev/tty
+done
diff --git a/wcwidth.c b/wcwidth.c
new file mode 100644 (file)
index 0000000..77e1015
--- /dev/null
+++ b/wcwidth.c
@@ -0,0 +1,331 @@
+/* $XTermId: wcwidth.c,v 1.22 2009/02/13 19:53:12 tom Exp $ */
+
+/* $XFree86: xc/programs/xterm/wcwidth.c,v 1.9 2006/06/19 00:36:52 dickey Exp $ */
+
+/*
+ * This is an implementation of wcwidth() and wcswidth() (defined in
+ * IEEE Std 1002.1-2001) for Unicode.
+ *
+ * http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html
+ * http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html
+ *
+ * In fixed-width output devices, Latin characters all occupy a single
+ * "cell" position of equal width, whereas ideographic CJK characters
+ * occupy two such cells. Interoperability between terminal-line
+ * applications and (teletype-style) character terminals using the
+ * UTF-8 encoding requires agreement on which character should advance
+ * the cursor by how many cell positions. No established formal
+ * standards exist at present on which Unicode character shall occupy
+ * how many cell positions on character terminals. These routines are
+ * a first attempt of defining such behavior based on simple rules
+ * applied to data provided by the Unicode Consortium.
+ *
+ * For some graphical characters, the Unicode standard explicitly
+ * defines a character-cell width via the definition of the East Asian
+ * FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
+ * In all these cases, there is no ambiguity about which width a
+ * terminal shall use. For characters in the East Asian Ambiguous (A)
+ * class, the width choice depends purely on a preference of backward
+ * compatibility with either historic CJK or Western practice.
+ * Choosing single-width for these characters is easy to justify as
+ * the appropriate long-term solution, as the CJK practice of
+ * displaying these characters as double-width comes from historic
+ * implementation simplicity (8-bit encoded characters were displayed
+ * single-width and 16-bit ones double-width, even for Greek,
+ * Cyrillic, etc.) and not any typographic considerations.
+ *
+ * Much less clear is the choice of width for the Not East Asian
+ * (Neutral) class. Existing practice does not dictate a width for any
+ * of these characters. It would nevertheless make sense
+ * typographically to allocate two character cells to characters such
+ * as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
+ * represented adequately with a single-width glyph. The following
+ * routines at present merely assign a single-cell width to all
+ * neutral characters, in the interest of simplicity. This is not
+ * entirely satisfactory and should be reconsidered before
+ * establishing a formal standard in this area. At the moment, the
+ * decision which Not East Asian (Neutral) characters should be
+ * represented by double-width glyphs cannot yet be answered by
+ * applying a simple rule from the Unicode database content. Setting
+ * up a proper standard for the behavior of UTF-8 character terminals
+ * will require a careful analysis not only of each Unicode character,
+ * but also of each presentation form, something the author of these
+ * routines has avoided to do so far.
+ *
+ * http://www.unicode.org/unicode/reports/tr11/
+ *
+ * Markus Kuhn -- 2007-05-25 (Unicode 5.0)
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * for any purpose and without fee is hereby granted. The author
+ * disclaims all warranties with regard to this software.
+ *
+ * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
+ */
+
+#include <wcwidth.h>
+
+struct interval {
+  unsigned long first;
+  unsigned long last;
+};
+
+/* auxiliary function for binary search in interval table */
+static int bisearch(unsigned long ucs, const struct interval *table, int max) {
+  int min = 0;
+  int mid;
+
+  if (ucs >= table[0].first && ucs <= table[max].last) {
+    while (max >= min) {
+      mid = (min + max) / 2;
+      if (ucs > table[mid].last)
+        min = mid + 1;
+      else if (ucs < table[mid].first)
+        max = mid - 1;
+      else
+        return 1;
+    }
+  }
+
+  return 0;
+}
+
+
+/* The following two functions define the column width of an ISO 10646
+ * character as follows:
+ *
+ *    - The null character (U+0000) has a column width of 0.
+ *
+ *    - Other C0/C1 control characters and DEL will lead to a return
+ *      value of -1.
+ *
+ *    - Non-spacing and enclosing combining characters (general
+ *      category code Mn or Me in the Unicode database) have a
+ *      column width of 0.
+ *
+ *    - SOFT HYPHEN (U+00AD) has a column width of 1.
+ *
+ *    - Other format characters (general category code Cf in the Unicode
+ *      database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
+ *
+ *    - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
+ *      have a column width of 0.
+ *
+ *    - Spacing characters in the East Asian Wide (W) or East Asian
+ *      Full-width (F) category as defined in Unicode Technical
+ *      Report #11 have a column width of 2.
+ *
+ *    - All remaining characters (including all printable
+ *      ISO 8859-1 and WGL4 characters, Unicode control characters,
+ *      etc.) have a column width of 1.
+ *
+ * This implementation assumes that wchar_t characters are encoded
+ * in ISO 10646.
+ */
+
+int mk_wcwidth(wchar_t ucs)
+{
+  unsigned long cmp = (unsigned long) ucs;
+
+  /* sorted list of non-overlapping intervals of non-spacing characters */
+  /* generated by
+   *   uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c
+   */
+  static const struct interval combining[] = {
+    { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 },
+    { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
+    { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 },
+    { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 },
+    { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
+    { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
+    { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 },
+    { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D },
+    { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 },
+    { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD },
+    { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C },
+    { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D },
+    { 0x0A70, 0x0A71 }, { 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC },
+    { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD },
+    { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C },
+    { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D },
+    { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 }, { 0x0BC0, 0x0BC0 },
+    { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 },
+    { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC },
+    { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
+    { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D },
+    { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 },
+    { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E },
+    { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC },
+    { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 },
+    { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E },
+    { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 },
+    { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 },
+    { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 },
+    { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F },
+    { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 },
+    { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD },
+    { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD },
+    { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 },
+    { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B },
+    { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 },
+    { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 },
+    { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF },
+    { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 },
+    { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F },
+    { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B },
+    { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F },
+    { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB },
+    { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F },
+    { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 },
+    { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD },
+    { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F },
+    { 0xE0100, 0xE01EF }
+  };
+
+  /* test for 8-bit control characters */
+  if (cmp == 0)
+    return 0;
+  if (cmp < 32 || (cmp >= 0x7f && cmp < 0xa0))
+    return -1;
+
+  /* binary search in table of non-spacing characters */
+  if (bisearch(cmp, combining,
+               (int) (sizeof(combining) / sizeof(struct interval) - 1)))
+    return 0;
+
+  /* if we arrive here, cmp is not a combining or C0/C1 control character */
+
+  return 1 +
+    (cmp >= 0x1100 &&
+     (cmp <= 0x115f ||                    /* Hangul Jamo init. consonants */
+      cmp == 0x2329 || cmp == 0x232a ||
+      (cmp >= 0x2e80 && cmp <= 0xa4cf &&
+       cmp != 0x303f) ||                  /* CJK ... Yi */
+      (cmp >= 0xac00 && cmp <= 0xd7a3) || /* Hangul Syllables */
+      (cmp >= 0xf900 && cmp <= 0xfaff) || /* CJK Compatibility Ideographs */
+      (cmp >= 0xfe10 && cmp <= 0xfe19) || /* Vertical forms */
+      (cmp >= 0xfe30 && cmp <= 0xfe6f) || /* CJK Compatibility Forms */
+      (cmp >= 0xff00 && cmp <= 0xff60) || /* Fullwidth Forms */
+      (cmp >= 0xffe0 && cmp <= 0xffe6) ||
+      (cmp >= 0x20000 && cmp <= 0x2fffd) ||
+      (cmp >= 0x30000 && cmp <= 0x3fffd)));
+}
+
+
+int mk_wcswidth(const wchar_t *pwcs, size_t n)
+{
+  int w, width = 0;
+
+  for (;*pwcs && n-- > 0; pwcs++)
+    if ((w = mk_wcwidth(*pwcs)) < 0)
+      return -1;
+    else
+      width += w;
+
+  return width;
+}
+
+
+/*
+ * The following functions are the same as mk_wcwidth() and
+ * mk_wcwidth_cjk(), except that spacing characters in the East Asian
+ * Ambiguous (A) category as defined in Unicode Technical Report #11
+ * have a column width of 2. This variant might be useful for users of
+ * CJK legacy encodings who want to migrate to UCS without changing
+ * the traditional terminal character-width behaviour. It is not
+ * otherwise recommended for general use.
+ */
+int mk_wcwidth_cjk(wchar_t ucs)
+{
+  /* sorted list of non-overlapping intervals of East Asian Ambiguous
+   * characters, generated by
+   *
+   * uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf \
+   *   +E000..F8FF \
+   *   +F0000..FFFFD \
+   *   +100000..10FFFD  c
+   *
+   * "WIDTH-A" is a file extracted from EastAsianWidth.txt by selecting
+   * only those with width "A", and omitting:
+   *
+   *   0xAD
+   *   all lines with "COMBINING"
+   *
+   * (uniset does not recognize the range expressions in WIDTH-A).
+   */
+  static const struct interval ambiguous[] = {
+    { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
+    { 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 },
+    { 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 },
+    { 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 },
+    { 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED },
+    { 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA },
+    { 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 },
+    { 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B },
+    { 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 },
+    { 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 },
+    { 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 },
+    { 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE },
+    { 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 },
+    { 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA },
+    { 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 },
+    { 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB },
+    { 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB },
+    { 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0391, 0x03A1 },
+    { 0x03A3, 0x03A9 }, { 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 },
+    { 0x0401, 0x0401 }, { 0x0410, 0x044F }, { 0x0451, 0x0451 },
+    { 0x2010, 0x2010 }, { 0x2013, 0x2016 }, { 0x2018, 0x2019 },
+    { 0x201C, 0x201D }, { 0x2020, 0x2022 }, { 0x2024, 0x2027 },
+    { 0x2030, 0x2030 }, { 0x2032, 0x2033 }, { 0x2035, 0x2035 },
+    { 0x203B, 0x203B }, { 0x203E, 0x203E }, { 0x2074, 0x2074 },
+    { 0x207F, 0x207F }, { 0x2081, 0x2084 }, { 0x20AC, 0x20AC },
+    { 0x2103, 0x2103 }, { 0x2105, 0x2105 }, { 0x2109, 0x2109 },
+    { 0x2113, 0x2113 }, { 0x2116, 0x2116 }, { 0x2121, 0x2122 },
+    { 0x2126, 0x2126 }, { 0x212B, 0x212B }, { 0x2153, 0x2154 },
+    { 0x215B, 0x215E }, { 0x2160, 0x216B }, { 0x2170, 0x2179 },
+    { 0x2190, 0x2199 }, { 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 },
+    { 0x21D4, 0x21D4 }, { 0x21E7, 0x21E7 }, { 0x2200, 0x2200 },
+    { 0x2202, 0x2203 }, { 0x2207, 0x2208 }, { 0x220B, 0x220B },
+    { 0x220F, 0x220F }, { 0x2211, 0x2211 }, { 0x2215, 0x2215 },
+    { 0x221A, 0x221A }, { 0x221D, 0x2220 }, { 0x2223, 0x2223 },
+    { 0x2225, 0x2225 }, { 0x2227, 0x222C }, { 0x222E, 0x222E },
+    { 0x2234, 0x2237 }, { 0x223C, 0x223D }, { 0x2248, 0x2248 },
+    { 0x224C, 0x224C }, { 0x2252, 0x2252 }, { 0x2260, 0x2261 },
+    { 0x2264, 0x2267 }, { 0x226A, 0x226B }, { 0x226E, 0x226F },
+    { 0x2282, 0x2283 }, { 0x2286, 0x2287 }, { 0x2295, 0x2295 },
+    { 0x2299, 0x2299 }, { 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF },
+    { 0x2312, 0x2312 }, { 0x2460, 0x24E9 }, { 0x24EB, 0x254B },
+    { 0x2550, 0x2573 }, { 0x2580, 0x258F }, { 0x2592, 0x2595 },
+    { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 }, { 0x25B2, 0x25B3 },
+    { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD }, { 0x25C0, 0x25C1 },
+    { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB }, { 0x25CE, 0x25D1 },
+    { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF }, { 0x2605, 0x2606 },
+    { 0x2609, 0x2609 }, { 0x260E, 0x260F }, { 0x2614, 0x2615 },
+    { 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 },
+    { 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 },
+    { 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F },
+    { 0x273D, 0x273D }, { 0x2776, 0x277F }, { 0xE000, 0xF8FF },
+    { 0xFFFD, 0xFFFD }, { 0xF0000, 0xFFFFD }, { 0x100000, 0x10FFFD }
+  };
+
+  /* binary search in table of non-spacing characters */
+  if (bisearch((unsigned long) ucs, ambiguous,
+               (int) (sizeof(ambiguous) / sizeof(struct interval) - 1)))
+    return 2;
+
+  return mk_wcwidth(ucs);
+}
+
+
+int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n)
+{
+  int w, width = 0;
+
+  for (;*pwcs && n-- > 0; pwcs++)
+    if ((w = mk_wcwidth_cjk(*pwcs)) < 0)
+      return -1;
+    else
+      width += w;
+
+  return width;
+}
diff --git a/wcwidth.h b/wcwidth.h
new file mode 100644 (file)
index 0000000..b4eb51a
--- /dev/null
+++ b/wcwidth.h
@@ -0,0 +1,14 @@
+/* $XFree86: xc/programs/xterm/wcwidth.h,v 1.5 2005/05/03 00:38:25 dickey Exp $ */
+
+#ifndef        included_wcwidth_h
+#define        included_wcwidth_h 1
+
+#include <stddef.h>
+
+extern int mk_wcswidth(const wchar_t * pwcs, size_t n);
+extern int mk_wcswidth_cjk(const wchar_t * pwcs, size_t n);
+extern int mk_wcwidth(wchar_t ucs);
+extern int mk_wcwidth_cjk(wchar_t ucs);
+extern int wcswidth_cjk(const wchar_t * pwcs, size_t n);
+
+#endif /* included_wcwidth_h */
diff --git a/xcharmouse.h b/xcharmouse.h
new file mode 100644 (file)
index 0000000..63ef2bf
--- /dev/null
@@ -0,0 +1,81 @@
+/* $XTermId: xcharmouse.h,v 1.12 2010/08/19 09:30:03 Ryan.Johnson Exp $ */
+
+/************************************************************
+
+Copyright 1998 by Jason Bacon <acadix@execpc.com>
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of the above listed
+copyright holder(s) not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
+LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifndef included_xcharmouse_h
+#define included_xcharmouse_h
+
+/*
+ * Macros for dpmodes
+ * J. Bacon, acadix@execpc.com, June 1998
+ * Steve Wall, September 1999
+ * Ilya Zakharevich, August 2002
+ */
+
+/* DECSET arguments for turning on mouse reporting modes */
+#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
+
+#if OPT_FOCUS_EVENT
+#define SET_FOCUS_EVENT_MOUSE       1004 /* can be combined with above */
+#endif
+
+/* Extend mouse tracking for terminals wider(taller) than 223 cols(rows) */
+#define SET_EXT_MODE_MOUSE          1005 /* compatible with above */
+
+#define SET_BUTTON1_MOVE_POINT      2001 /* click1 emit Esc seq to move point*/
+#define SET_BUTTON2_MOVE_POINT      2002 /* press2 emit Esc seq to move point*/
+#define SET_DBUTTON3_DELETE         2003 /* Double click-3 deletes */
+#define SET_PASTE_IN_BRACKET        2004 /* Surround paste by escapes */
+#define SET_PASTE_QUOTE             2005 /* Quote each char during paste */
+#define SET_PASTE_LITERAL_NL        2006 /* Paste "\n" as C-j */
+
+#if OPT_DEC_LOCATOR
+
+/* Bit fields for screen->locator_events */
+#define        LOC_BTNS_DN             0x1
+#define        LOC_BTNS_UP             0x2
+
+/* Special values for screen->loc_filter_* */
+#define        LOC_FILTER_POS          -1
+
+#endif /* OPT_DEC_LOCATOR */
+
+/* Values for screen->send_mouse_pos */
+typedef enum {
+    MOUSE_OFF
+    ,X10_MOUSE
+    ,VT200_MOUSE
+    ,VT200_HIGHLIGHT_MOUSE
+    ,BTN_EVENT_MOUSE
+    ,ANY_EVENT_MOUSE
+    ,DEC_LOCATOR
+} XtermMouseModes;
+
+#endif /* included_xcharmouse_h */
diff --git a/xstrings.c b/xstrings.c
new file mode 100644 (file)
index 0000000..142f276
--- /dev/null
@@ -0,0 +1,286 @@
+/* $XTermId: xstrings.c,v 1.37 2010/04/04 22:34:17 tom Exp $ */
+
+/************************************************************
+
+Copyright 2000-2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#include <xterm.h>
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <xstrings.h>
+
+char *
+x_basename(char *name)
+{
+    char *cp;
+
+    cp = strrchr(name, '/');
+#ifdef __UNIXOS2__
+    if (cp == 0)
+       cp = strrchr(name, '\\');
+#endif
+    return (cp ? cp + 1 : name);
+}
+
+/*
+ * Decode a hexadecimal string, returning the decoded string.
+ * On return, 'next' points to the first character not part of the input.
+ * The caller must free the result.
+ */
+char *
+x_decode_hex(const char *source, const char **next)
+{
+    char *result = 0;
+    int pass;
+    size_t j, k;
+
+    for (pass = 0; pass < 2; ++pass) {
+       for (j = k = 0; isxdigit(CharOf(source[j])); ++j) {
+           if ((pass != 0) && (j & 1) != 0) {
+               result[k++] = (char) ((x_hex2int(source[j - 1]) << 4)
+                                     | x_hex2int(source[j]));
+           }
+       }
+       *next = (source + j);
+       if ((j & 1) == 0) {
+           if (pass) {
+               result[k] = '\0';
+           } else {
+               result = malloc(++j);
+               if (result == 0)
+                   break;      /* not enough memory */
+           }
+       } else {
+           break;              /* must have an even number of digits */
+       }
+    }
+    return result;
+}
+
+/*
+ * Encode a string into hexadecimal, returning the encoded string.
+ * The caller must free the result.
+ */
+char *
+x_encode_hex(const char *source)
+{
+    size_t need = (strlen(source) * 2) + 1;
+    char *result = malloc(need);
+
+    if (result != 0) {
+       unsigned j, k;
+       for (j = k = 0; source[j] != '\0'; ++j) {
+           sprintf(result + k, "%02X", CharOf(source[j]));
+           k += 2;
+       }
+    }
+    return result;
+}
+
+char *
+x_getenv(const char *name)
+{
+    return x_strdup(x_nonempty(getenv(name)));
+}
+
+/*
+ * Decode a single hex "nibble", returning the nibble as 0-15, or -1 on error.
+ */ int
+x_hex2int(int c)
+{
+    if (c >= '0' && c <= '9')
+       return c - '0';
+    if (c >= 'a' && c <= 'f')
+       return c - 'a' + 10;
+    if (c >= 'A' && c <= 'F')
+       return c - 'A' + 10;
+    return -1;
+}
+
+/*
+ * Check if the given string is nonnull/nonempty.  If so, return a pointer
+ * to the beginning of its content, otherwise return null.
+ */
+String
+x_nonempty(String s)
+{
+    if (s != 0) {
+       if (*s == '\0') {
+           s = 0;
+       } else {
+           s = x_skip_blanks(s);
+           if (*s == '\0')
+               s = 0;
+       }
+    }
+    return s;
+}
+
+String
+x_skip_blanks(String s)
+{
+    while (isspace(CharOf(*s)))
+       ++s;
+    return s;
+}
+
+String
+x_skip_nonblanks(String s)
+{
+    while (*s != '\0' && !isspace(CharOf(*s)))
+       ++s;
+    return s;
+}
+
+int
+x_strcasecmp(const char *s1, const char *s2)
+{
+    size_t len = strlen(s1);
+
+    if (len != strlen(s2))
+       return 1;
+
+    return x_strncasecmp(s1, s2, (unsigned) len);
+}
+
+int
+x_strncasecmp(const char *s1, const char *s2, unsigned n)
+{
+    while (n-- != 0) {
+       char c1 = x_toupper(*s1);
+       char c2 = x_toupper(*s2);
+       if (c1 != c2)
+           return 1;
+       if (c1 == 0)
+           break;
+       s1++, s2++;
+    }
+
+    return 0;
+}
+
+/*
+ * Allocates a copy of a string
+ */
+char *
+x_strdup(const char *s)
+{
+    char *result = 0;
+
+    if (s != 0) {
+       char *t = CastMallocN(char, strlen(s));
+       if (t != 0) {
+           strcpy(t, s);
+       }
+       result = t;
+    }
+    return result;
+}
+
+/*
+ * Returns a pointer to the first occurrence of s2 in s1,
+ * or NULL if there are none.
+ */
+char *
+x_strindex(char *s1, const char *s2)
+{
+    char *s3;
+    size_t s2len = strlen(s2);
+
+    while ((s3 = strchr(s1, *s2)) != NULL) {
+       if (strncmp(s3, s2, s2len) == 0)
+           return (s3);
+       s1 = ++s3;
+    }
+    return (NULL);
+}
+
+/*
+ * Trims leading/trailing spaces from a copy of the string.
+ */
+char *
+x_strtrim(const char *source)
+{
+    char *result;
+    char *s;
+    char *d;
+
+    if (source != 0 && *source != '\0') {
+       char *t = x_strdup(source);
+       s = t;
+       d = s;
+       while (isspace(CharOf(*s)))
+           ++s;
+       while ((*d++ = *s++) != '\0') {
+           ;
+       }
+       if (*t != '\0') {
+           s = t + strlen(t);
+           while (s != t && isspace(CharOf(s[-1]))) {
+               *--s = '\0';
+           }
+       }
+       result = t;
+    } else {
+       result = x_strdup("");
+    }
+    return result;
+}
+
+/*
+ * Avoid using system locale for upper/lowercase conversion, since there are
+ * a few locales where toupper(tolower(c)) != c.
+ */
+char
+x_toupper(int ch)
+{
+    static char table[256];
+    char result = table[CharOf(ch)];
+
+    if (result == '\0') {
+       unsigned n;
+       const char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+       for (n = 0; n < sizeof(table); ++n) {
+           table[n] = (char) n;
+       }
+       for (n = 0; s[n] != '\0'; ++n) {
+           table[CharOf(s[n])] = s[n % 26];
+       }
+       result = table[CharOf(ch)];
+    }
+
+    return result;
+}
diff --git a/xstrings.h b/xstrings.h
new file mode 100644 (file)
index 0000000..569f710
--- /dev/null
@@ -0,0 +1,55 @@
+/* $XTermId: xstrings.h,v 1.19 2009/12/06 15:50:18 tom Exp $ */
+
+/************************************************************
+
+Copyright 2000-2008,2009 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#ifndef included_xstrings_h
+#define included_xstrings_h 1
+
+#include <X11/Intrinsic.h>
+
+extern String x_nonempty(String /* s */);
+extern String x_skip_blanks(String /* s */);
+extern String x_skip_nonblanks(String /* s */);
+extern char *x_basename(char * /* name */);
+extern char *x_decode_hex(const char * /* source */, const char ** /* next */);
+extern char *x_encode_hex(const char * /* source */);
+extern char *x_getenv(const char * /* name */);
+extern char *x_strdup(const char * /* s */);
+extern char *x_strindex(char * /* s1 */, const char * /* s2 */);
+extern char *x_strtrim(const char * /* s */);
+extern char x_toupper(int /* ch */);
+extern int x_hex2int(int /* ch */);
+extern int x_strcasecmp(const char * /* s1 */, const char * /* s2 */);
+extern int x_strncasecmp(const char * /* s1 */, const char * /* s2 */, unsigned  /* n */);
+
+#endif /* included_xstrings_h */
diff --git a/xterm-268/packaging/16colors.txt b/xterm-268/packaging/16colors.txt
new file mode 100644 (file)
index 0000000..9b09e77
--- /dev/null
@@ -0,0 +1,24 @@
+\e[0;037;040mANSI-Colors v1.0
+\e[0;037;040m(c)1994  by: Pablo Ariel Kohan
+\e[0;037;040m   |3 9 3 9 3 9 3 9 3 9 3 9 3 9 3 9|
+\e[0;037;040m   |0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7|
+\e[0;037;040m---+-------------------------------+---
+\e[0;037;040m040|\e[0;030;040mX \e[0;090;040mX \e[0;031;040mX \e[0;091;040mX \e[0;032;040mX \e[0;092;040mX \e[0;033;040mX \e[0;093;040mX \e[0;034;040mX \e[0;094;040mX \e[0;035;040mX \e[0;095;040mX \e[0;036;040mX \e[0;096;040mX \e[0;037;040mX \e[0;097;040mX\e[0;037;040m|040 
+\e[0;037;040m100|\e[0;030;100mX \e[0;090;100mX \e[0;031;100mX \e[0;091;100mX \e[0;032;100mX \e[0;092;100mX \e[0;033;100mX \e[0;093;100mX \e[0;034;100mX \e[0;094;100mX \e[0;035;100mX \e[0;095;100mX \e[0;036;100mX \e[0;096;100mX \e[0;037;100mX \e[0;097;100mX\e[0;037;040m|100
+\e[0;037;040m041|\e[0;030;041mX \e[0;090;041mX \e[0;031;041mX \e[0;091;041mX \e[0;032;041mX \e[0;092;041mX \e[0;033;041mX \e[0;093;041mX \e[0;034;041mX \e[0;094;041mX \e[0;035;041mX \e[0;095;041mX \e[0;036;041mX \e[0;096;041mX \e[0;037;041mX \e[0;097;041mX\e[0;037;040m|041 
+\e[0;037;040m101|\e[0;030;101mX \e[0;090;101mX \e[0;031;101mX \e[0;091;101mX \e[0;032;101mX \e[0;092;101mX \e[0;033;101mX \e[0;093;101mX \e[0;034;101mX \e[0;094;101mX \e[0;035;101mX \e[0;095;101mX \e[0;036;101mX \e[0;096;101mX \e[0;037;101mX \e[0;097;101mX\e[0;037;040m|101
+\e[0;037;040m042|\e[0;030;042mX \e[0;090;042mX \e[0;031;042mX \e[0;091;042mX \e[0;032;042mX \e[0;092;042mX \e[0;033;042mX \e[0;093;042mX \e[0;034;042mX \e[0;094;042mX \e[0;035;042mX \e[0;095;042mX \e[0;036;042mX \e[0;096;042mX \e[0;037;042mX \e[0;097;042mX\e[0;037;040m|042 
+\e[0;037;040m102|\e[0;030;102mX \e[0;090;102mX \e[0;031;102mX \e[0;091;102mX \e[0;032;102mX \e[0;092;102mX \e[0;033;102mX \e[0;093;102mX \e[0;034;102mX \e[0;094;102mX \e[0;035;102mX \e[0;095;102mX \e[0;036;102mX \e[0;096;102mX \e[0;037;102mX \e[0;097;102mX\e[0;037;040m|102
+\e[0;037;040m043|\e[0;030;043mX \e[0;090;043mX \e[0;031;043mX \e[0;091;043mX \e[0;032;043mX \e[0;092;043mX \e[0;033;043mX \e[0;093;043mX \e[0;034;043mX \e[0;094;043mX \e[0;035;043mX \e[0;095;043mX \e[0;036;043mX \e[0;096;043mX \e[0;037;043mX \e[0;097;043mX\e[0;037;040m|043 
+\e[0;037;040m103|\e[0;030;103mX \e[0;090;103mX \e[0;031;103mX \e[0;091;103mX \e[0;032;103mX \e[0;092;103mX \e[0;033;103mX \e[0;093;103mX \e[0;034;103mX \e[0;094;103mX \e[0;035;103mX \e[0;095;103mX \e[0;036;103mX \e[0;096;103mX \e[0;037;103mX \e[0;097;103mX\e[0;037;040m|103
+\e[0;037;040m044|\e[0;030;044mX \e[0;090;044mX \e[0;031;044mX \e[0;091;044mX \e[0;032;044mX \e[0;092;044mX \e[0;033;044mX \e[0;093;044mX \e[0;034;044mX \e[0;094;044mX \e[0;035;044mX \e[0;095;044mX \e[0;036;044mX \e[0;096;044mX \e[0;037;044mX \e[0;097;044mX\e[0;037;040m|044 
+\e[0;037;040m104|\e[0;030;104mX \e[0;090;104mX \e[0;031;104mX \e[0;091;104mX \e[0;032;104mX \e[0;092;104mX \e[0;033;104mX \e[0;093;104mX \e[0;034;104mX \e[0;094;104mX \e[0;035;104mX \e[0;095;104mX \e[0;036;104mX \e[0;096;104mX \e[0;037;104mX \e[0;097;104mX\e[0;037;040m|104
+\e[0;037;040m045|\e[0;030;045mX \e[0;090;045mX \e[0;031;045mX \e[0;091;045mX \e[0;032;045mX \e[0;092;045mX \e[0;033;045mX \e[0;093;045mX \e[0;034;045mX \e[0;094;045mX \e[0;035;045mX \e[0;095;045mX \e[0;036;045mX \e[0;096;045mX \e[0;037;045mX \e[0;097;045mX\e[0;037;040m|045 
+\e[0;037;040m105|\e[0;030;105mX \e[0;090;105mX \e[0;031;105mX \e[0;091;105mX \e[0;032;105mX \e[0;092;105mX \e[0;033;105mX \e[0;093;105mX \e[0;034;105mX \e[0;094;105mX \e[0;035;105mX \e[0;095;105mX \e[0;036;105mX \e[0;096;105mX \e[0;037;105mX \e[0;097;105mX\e[0;037;040m|105
+\e[0;037;040m046|\e[0;030;046mX \e[0;090;046mX \e[0;031;046mX \e[0;091;046mX \e[0;032;046mX \e[0;092;046mX \e[0;033;046mX \e[0;093;046mX \e[0;034;046mX \e[0;094;046mX \e[0;035;046mX \e[0;095;046mX \e[0;036;046mX \e[0;096;046mX \e[0;037;046mX \e[0;097;046mX\e[0;037;040m|046 
+\e[0;037;040m106|\e[0;030;106mX \e[0;090;106mX \e[0;031;106mX \e[0;091;106mX \e[0;032;106mX \e[0;092;106mX \e[0;033;106mX \e[0;093;106mX \e[0;034;106mX \e[0;094;106mX \e[0;035;106mX \e[0;095;106mX \e[0;036;106mX \e[0;096;106mX \e[0;037;106mX \e[0;097;106mX\e[0;037;040m|106
+\e[0;037;040m047|\e[0;030;047mX \e[0;090;047mX \e[0;031;047mX \e[0;091;047mX \e[0;032;047mX \e[0;092;047mX \e[0;033;047mX \e[0;093;047mX \e[0;034;047mX \e[0;094;047mX \e[0;035;047mX \e[0;095;047mX \e[0;036;047mX \e[0;096;047mX \e[0;037;047mX \e[0;097;047mX\e[0;037;040m|047 
+\e[0;037;040m107|\e[0;030;107mX \e[0;090;107mX \e[0;031;107mX \e[0;091;107mX \e[0;032;107mX \e[0;092;107mX \e[0;033;107mX \e[0;093;107mX \e[0;034;107mX \e[0;094;107mX \e[0;035;107mX \e[0;095;107mX \e[0;036;107mX \e[0;096;107mX \e[0;037;107mX \e[0;097;107mX\e[0;037;040m|107
+\e[0;037;040m---+-------------------------------+---
+\e[0;037;040m   |3 9 3 9 3 9 3 9 3 9 3 9 3 9 3 9|
+\e[0;037;040m   |0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7|
diff --git a/xterm-268/packaging/buildfix.patch b/xterm-268/packaging/buildfix.patch
new file mode 100644 (file)
index 0000000..bffe191
--- /dev/null
@@ -0,0 +1,15 @@
+--- xterm-261/Makefile.in.ori  2010-08-16 12:42:01.000000000 +0800
++++ xterm-261/Makefile.in      2010-08-16 12:42:44.000000000 +0800
+@@ -160,10 +160,10 @@
+ main$o resize$o screen$o : xterm_io.h
+ xterm$x : $(OBJS1)
+-      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(LIBS) $(EXTRA_LOADFLAGS)
++      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(LIBS) $(EXTRA_LOADFLAGS) -ltinfo
+ resize$x : $(OBJS2)
+-      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(LIBS)
++      @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(LIBS) -ltinfo
+ 256colres.h :
+       -rm -f $@
diff --git a/xterm-268/packaging/failsafe.desktop b/xterm-268/packaging/failsafe.desktop
new file mode 100644 (file)
index 0000000..513327a
--- /dev/null
@@ -0,0 +1,4 @@
+[Desktop entry]
+Name=failsafe X session
+Comment=This X session provides a fallback to a single xterm
+Exec=/usr/bin/xterm
diff --git a/xterm-268/packaging/xterm-256-man-page_paths.patch b/xterm-268/packaging/xterm-256-man-page_paths.patch
new file mode 100644 (file)
index 0000000..6bfd46d
--- /dev/null
@@ -0,0 +1,48 @@
+diff -up xterm-256/minstall.sh.man-page_paths xterm-256/minstall.sh
+--- xterm-256/minstall.sh.man-page_paths       2010-03-04 00:44:49.000000000 +0100
++++ xterm-256/minstall.sh      2010-03-09 12:11:26.000000000 +0100
+@@ -109,6 +109,10 @@ WTMP_PATH=$WTMP_PATH/$WTMP_NAME
+ X_MANSECT=`man X 2>&1 | tr '\012' '\020' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
+ test -z "$X_MANSECT" && X_MANSECT=$suffix
++fontpath=/usr/share/X11/fonts
++xorgcfgdir=/etc/X11
++xorgcfgfil=xorg.conf
++X_MANSECT=7
+ sed   -e 's%__vendorversion__%"X Window System"%' \
+       -e s%__apploaddir__%$APPS_DIR% \
+       -e s%__mansuffix__%$MY_MANSECT%g \
+@@ -117,6 +121,9 @@ sed        -e 's%__vendorversion__%"X Window Sy
+       -e s%/etc/utmp%$UTMP_PATH%g \
+       -e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \
+       -e s%/etc/wtmp%$WTMP_PATH%g \
++      -e s%__fontpath__%$fontpath%g \
++      -e s%__xorgcfgdir__%$xorgcfgdir%g \
++      -e s%__xorgcfgfil__%$xorgcfgfil%g \
+       $OLD_FILE >$NEW_FILE
+ echo "$MINSTALL $OLD_FILE $END_FILE"
+diff -up xterm-256/xterm.man.man-page_paths xterm-256/xterm.man
+--- xterm-256/xterm.man.man-page_paths 2010-03-03 23:30:35.000000000 +0100
++++ xterm-256/xterm.man        2010-03-09 12:11:26.000000000 +0100
+@@ -1699,17 +1699,17 @@ Since X11R6, bitmap fonts have been scal
+ The font server claims to provide the bold font that \fIxterm\fP requests,
+ but the result is not always readable.
+ XFree86 provides a feature which can be used to suppress the scaling.
+-In the X server's configuration file (e.g., "/etc/X11/XFree86"), you
++In the X server's configuration file (e.g., __xorgcfgdir__/__xorgcfgfil__), you
+ can add ":unscaled" to the end of the directory specification for the
+ "misc" fonts, which comprise the fixed-pitch fonts that are used by \fIxterm\fP.
+ For example
+ .RS
+-      FontPath        "/usr/lib/X11/fonts/misc/"
++      FontPath        "__fontpath__"
+ .RE
+ .IP
+ would become
+ .RS
+-      FontPath        "/usr/lib/X11/fonts/misc/:unscaled"
++      FontPath        "__fontpath__/misc/:unscaled"
+ .RE
+ .IP
+ Depending on your configuration, the font server may have its own configuration
diff --git a/xterm-268/packaging/xterm-261-resources.patch b/xterm-268/packaging/xterm-261-resources.patch
new file mode 100644 (file)
index 0000000..91b7808
--- /dev/null
@@ -0,0 +1,17 @@
+--- xterm-261/XTerm.ad.ori     2010-08-12 14:48:34.000000000 +0800
++++ xterm-261/XTerm.ad 2010-08-12 14:50:49.000000000 +0800
+@@ -249,3 +249,14 @@
+ !*allowTcapOps: false
+ !*allowTitleOps: false
+ !*allowWindowOps: false
++
++! MeeGo Defaults:
++*allowFontOps: false
++*allowTcapOps: false
++*allowTitleOps: false
++*allowWindowOps: false
++*VT100*eightBitInput: false
++*VT100*metaSendsEscape: true
++*VT100*backarrowKey: false
++*VT100*scrollBar: true
++*VT100*utf8Title: true
diff --git a/xterm-268/packaging/xterm.changes b/xterm-268/packaging/xterm.changes
new file mode 100644 (file)
index 0000000..5bb55d4
--- /dev/null
@@ -0,0 +1,15 @@
+* Fri May 18 22:18:09 UTC 2012 - tracy.graydon@intel.com
+- Make that tar.bz2 
+
+* Fri May 18 22:10:09 UTC 2012 - tracy.graydon@intel.com
+- Change the tarball to .bz2 
+
+* Fri May 18 20:57:48 UTC 2012 - tracy.graydon@intel.com
+- More spec fixing 
+
+* Fri May 18 04:36:40 UTC 2012 - tracy.graydon@intel.com
+- fix packaging 
+
+* Fri May 18 04:25:31 UTC 2012 - tracy.graydon@intel.com
+- obs/gerrit sync 
+
diff --git a/xterm-268/packaging/xterm.desktop b/xterm-268/packaging/xterm.desktop
new file mode 100644 (file)
index 0000000..3e7c0fb
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=xterm Terminal
+GenericName=Terminal
+Comment=Terminal emulator for the X Window System
+Exec=xterm
+Icon=icons-Applications-xterminal
+Type=Application
+Categories=System;Utility;
+NoDisplay=false
+NotShowIn=X-MEEGO-NB;
diff --git a/xterm-268/packaging/xterm.spec b/xterm-268/packaging/xterm.spec
new file mode 100644 (file)
index 0000000..75da4b5
--- /dev/null
@@ -0,0 +1,91 @@
+%define x11_app_defaults_dir %(pkg-config --variable appdefaultdir xt)
+
+Name:       xterm
+Summary:    Terminal emulator for the X Window System
+Version:    268
+Release:    2.5
+Group:      System/X
+License:    MIT
+URL:        http://dickey.his.com/xterm
+Source0:    %{name}-%{version}.tar.bz2
+Source1:    16colors.txt
+Source2:    xterm.desktop
+Source3:    failsafe.desktop
+Patch0:     xterm-261-resources.patch
+Patch1:     xterm-256-man-page_paths.patch
+Patch2:     buildfix.patch
+BuildRequires:  pkgconfig(xft)
+BuildRequires:  pkgconfig(xaw7)
+BuildRequires:  pkgconfig(xext)
+BuildRequires:  pkgconfig(ncurses)
+BuildRequires:  pkgconfig(xkbfile)
+BuildRequires:  imake
+BuildRequires:  desktop-file-utils
+
+
+%description
+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 not use the window system directly.
+
+
+%prep
+%setup -q
+
+# xterm-261-resources.patch
+%patch0 -p1
+# xterm-256-man-page_paths.patch
+%patch1 -p1
+# buildfix.patch
+%patch2 -p1
+
+%build
+
+%configure --disable-static \
+    --with-app-defaults=%{x11_app_defaults_dir} \
+    --enable-256-color \
+    --enable-exec-xterm \
+    --enable-luit \
+    --enable-warnings \
+    --enable-wide-chars \
+    --with-tty-group=tty \
+    --disable-full-tgetent
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+mkdir -p %{buildroot}%{_datadir}/applications/
+install -m 644 %{SOURCE2} %{buildroot}%{_datadir}/applications/
+mkdir -p %{buildroot}%{_datadir}/xsessions/
+install -m 644 %{SOURCE3} %{buildroot}%{_datadir}/xsessions/
+
+cp -fp %{SOURCE1} 16colors.txt
+
+desktop-file-install --delete-original       \
+  --dir %{buildroot}%{_datadir}/applications             \
+   %{buildroot}%{_datadir}/applications/*.desktop
+
+
+%files
+%defattr(-,root,root,-)
+%doc xterm.log.html ctlseqs.txt 16colors.txt README.i18n
+%{_bindir}/xterm
+%{_bindir}/koi8rxterm
+%{_bindir}/resize
+%{_bindir}/uxterm
+%doc %{_mandir}/man1/koi8rxterm.1*
+%doc %{_mandir}/man1/resize.1*
+%doc %{_mandir}/man1/uxterm.1*
+%doc %{_mandir}/man1/xterm.1*
+%{_datadir}/applications/xterm.desktop
+%{_datadir}/xsessions/failsafe.desktop
+%{_datadir}/pixmaps/*
+%{x11_app_defaults_dir}/KOI8RXTerm*
+%{x11_app_defaults_dir}/UXTerm*
+%{x11_app_defaults_dir}/XTerm*
+
+
diff --git a/xterm.dat b/xterm.dat
new file mode 100644 (file)
index 0000000..6ae28ca
--- /dev/null
+++ b/xterm.dat
@@ -0,0 +1,160 @@
+! $XFree86: xc/programs/xterm/xterm.dat,v 1.5 2005/07/07 00:46:14 dickey Exp $
+!
+*title: Xterm
+*iconName: Xterm
+*c132: TRUE
+*scrollBar: on
+*saveLines:    1000
+
+! This is nonsense: if the xterm has no session management capabilities,
+! it is useless, and if it does, it is harmful.
+!XTerm.JoinSession:False
+
+! turn off NumLock support - there is some conflict or problem on VMS
+*numLock: false
+
+*SimpleMenu*BackingStore: NotUseful
+*SimpleMenu*menuLabel.font: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso*-*
+*SimpleMenu*menuLabel.vertSpace:   100
+*SimpleMenu*HorizontalMargins: 16
+*SimpleMenu*Sme.height:    16
+*SimpleMenu*Cursor: left_ptr
+
+*mainMenu.Label:  Main Options
+*mainMenu*securekbd*Label:  Secure Keyboard
+*mainMenu*allowsends*Label:  Allow SendEvents
+*mainMenu*logging*Label:  Log to File
+*mainMenu*print*Label:  Print Window
+*mainMenu*redraw*Label:  Redraw Window
+*mainMenu*8-bit control*Label: 8-Bit Controls
+*mainMenu*backarrow key*Label: Backarrow Key
+*mainMenu*num-lock*Label: Alt/NumLock Modifiers
+*mainMenu*meta-esc*Label: Meta Sends Escape
+*mainMenu*sunFunction-keys*Label: Sun Function-Keys
+*mainMenu*sunKeyboard*Label: VT220 Keyboard
+*mainMenu*hp function-keys*Label: HP Function-Keys
+*mainMenu*suspend*Label:  Send STOP Signal
+*mainMenu*suspend*Sensitive: FALSE
+*mainMenu*continue*Label:  Send CONT Signal
+*mainMenu*continue*Sensitive: FALSE
+*mainMenu*interrupt*Label:  Send INT Signal
+*mainMenu*interrupt*Sensitive: FALSE
+*mainMenu*hangup*Label:  Send HUP Signal
+*mainMenu*hangup*Sensitive: FALSE
+*mainMenu*terminate*Label:  Send TERM Signal
+*mainMenu*terminate*Sensitive:  FALSE
+*mainMenu*kill*Label:  Send KILL Signal
+*mainMenu*kill*Sensitive:  FALSE
+*mainMenu*quit*Label:  Quit
+
+*vtMenu.Label:  VT Options
+*vtMenu*scrollbar*Label:  Enable Scrollbar
+*vtMenu*jumpscroll*Label:  Enable Jump Scroll
+*vtMenu*reversevideo*Label:  Enable Reverse Video
+*vtMenu*autowrap*Label:  Enable Auto Wraparound
+*vtMenu*reversewrap*Label:  Enable Reverse Wraparound
+*vtMenu*autolinefeed*Label:  Enable Auto Linefeed
+*vtMenu*appcursor*Label:  Enable Application Cursor Keys
+*vtMenu*appkeypad*Label:  Enable Application Keypad
+*vtMenu*scrollkey*Label:  Scroll to Bottom on Key Press
+*vtMenu*scrollttyoutput*Label:  Scroll to Bottom on Tty Output
+*vtMenu*allow132*Label: Allow 80/132 Column Switching
+*vtMenu*cursesemul*Label:  Enable Curses Emulation
+*vtMenu*visualbell*Label:  Enable Visual Bell
+*vtMenu*poponbell*Label:  Enable Pop on Bell
+*vtMenu*marginbell*Label:  Enable Margin Bell
+*vtMenu*cursorblink*Label: Enable Blinking Cursor
+*vtMenu*titeInhibit*Label:  Enable Alternate Screen Switching
+*vtMenu*activeicon*Label: Enable Active Icon
+*vtMenu*softreset*Label:  Do Soft Reset
+*vtMenu*hardreset*Label:  Do Full Reset
+*vtMenu*clearsavedlines*Label:  Reset and Clear Saved Lines
+*vtMenu*tekshow*Label:  Show Tek Window
+*vtMenu*tekmode*Label:  Switch to Tek Mode
+*vtMenu*vthide*Label:  Hide VT Window
+*vtMenu*altscreen*Label:  Show Alternate Screen
+
+*fontMenu.Label:  VT Fonts
+*fontMenu*fontdefault*Label:       Default
+*VT100*font:               -bitstream-terminal-medium-r-normal-gs-18-180-75-75-c-110-iso8859-1
+*fontMenu*font1*Label:     Tiny
+*VT100*font1:              -misc-fixed-medium-r-normal--8-60-*-*-c-50-iso8859-1
+*fontMenu*font2*Label:     Small
+*VT100*font2:              -misc-fixed-medium-r-normal--10-70-*-*-c-60-iso8859-1
+*fontMenu*font3*Label:     Medium
+*VT100*font3:              -misc-fixed-medium-r-normal--13-120-*-*-c-70-iso8859-1
+*fontMenu*font4*Label:     Large
+*VT100*font4:              -bitstream-terminal-medium-r-normal-gs-18-180-75-75-c-110-iso8859-1
+*fontMenu*font5*Label:     Huge
+*VT100*font5:              -bitstream-terminal-medium-r-normal-gs-36-280-100-100-c-220-iso8859-1
+*fontMenu*font6*Label:     Large-Narrow
+*VT100*font6:              -bitstream-terminal-medium-r-narrow--18-180-75-75-c-70-iso8859-1
+*fontMenu*fontescape*Label:        Escape Sequence
+*fontMenu*fontsel*Label:           Selection
+!fontescape and fontsel overridden by application
+*fontMenu*font-doublesize*Label: Doublesized Characters
+*fontMenu*font-loadable*Label: VT220 Soft Fonts
+
+*tekMenu.Label:  Tek Options
+*tekMenu*tektextlarge*Label:  Large Characters
+*tekMenu*tektext2*Label:  #2 Size Characters
+*tekMenu*tektext3*Label:  #3 Size Characters
+*tekMenu*tektextsmall*Label:  Small Characters
+*tekMenu*tekpage*Label:  PAGE
+*tekMenu*tekreset*Label:  RESET
+*tekMenu*tekcopy*Label:  COPY
+*tekMenu*vtshow*Label:  Show VT Window
+*tekMenu*vtmode*Label:  Switch to VT Mode
+*tekMenu*tekhide*Label:  Hide Tek Window
+
+*tek4014*fontLarge: -misc-fixed-medium-r-normal--15-140-*-*-c-90-iso8859-1
+*tek4014*font2: -misc-fixed-medium-r-normal--13-120-*-*-c-70-iso8859-1
+*tek4014*font3: -misc-fixed-medium-r-normal--10-100-*-*-c-60-iso8859-1
+*tek4014*fontSmall: -misc-fixed-medium-r-normal--8-80-*-*-c-50-iso8859-1
+
+! Enable Colour by default.
+
+*VT100*colorMode: on
+*VT100*boldColors: on
+*VT100*dynamicColors: on
+
+*VT100*highlightColor: red
+*VT100*cursorColor: white
+!bold text color
+*VT100*colorBDMode: on
+*VT100*colorBD: green
+!blinking text color
+*VT100*colorBLMode: on
+*VT100*colorBL: red
+
+
+! Uncomment this use color for underline attribute
+!*VT100*colorULMode: on
+!*VT100*italicULMode: on
+!*VT100*underLine: off
+
+! Uncomment this to use color for the bold attribute
+*VT100*colorBDMode: on
+
+! Uncomment this to use the bold/underline colors in preference to other colors
+*VT100*colorAttrMode: on
+
+*VT100*color0: black
+*VT100*color1: red3
+*VT100*color2: green3
+*VT100*color3: yellow3
+*VT100*color4: blue3
+*VT100*color5: magenta3
+*VT100*color6: cyan3
+*VT100*color7: gray90
+*VT100*color8: gray30
+*VT100*color9: red
+*VT100*color10: green
+*VT100*color11: yellow
+*VT100*color12: blue
+*VT100*color13: magenta
+*VT100*color14: cyan
+*VT100*color15: white
+*VT100*colorUL: yellow
+*VT100*colorBD: white
+
diff --git a/xterm.desktop b/xterm.desktop
new file mode 100644 (file)
index 0000000..82e1927
--- /dev/null
@@ -0,0 +1,41 @@
+# $XTermId: xterm.desktop,v 1.10 2010/06/15 10:58:13 tom Exp $
+# -----------------------------------------------------------------------------
+# this file is part of xterm
+#
+# Copyright 2006-2007,2010 by Thomas E. Dickey
+# 
+#                         All Rights Reserved
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# 
+# Except as contained in this notice, the name(s) of the above copyright
+# holders shall not be used in advertising or otherwise to promote the
+# sale, use or other dealings in this Software without prior written
+# authorization.
+# -----------------------------------------------------------------------------
+[Desktop Entry]
+Name=XTerm
+Comment=standard terminal emulator for the X window system
+Exec=xterm
+Terminal=false
+Type=Application
+Encoding=UTF-8
+Icon=xterm-color_48x48
+Categories=System;TerminalEmulator;
diff --git a/xterm.h b/xterm.h
new file mode 100644 (file)
index 0000000..84af675
--- /dev/null
+++ b/xterm.h
@@ -0,0 +1,1363 @@
+/* $XTermId: xterm.h,v 1.638 2011/02/09 10:13:20 tom Exp $ */
+
+/************************************************************
+
+Copyright 1999-2010,2011 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+/*
+ * Common/useful definitions for XTERM application.
+ *
+ * This is also where we put the fallback definitions if we do not build using
+ * the configure script.
+ */
+#ifndef included_xterm_h
+#define included_xterm_h
+/* *INDENT-OFF* */
+
+#ifdef HAVE_CONFIG_H
+#include <xtermcfg.h>
+#endif
+
+#ifndef GCC_PRINTFLIKE
+#define GCC_PRINTFLIKE(f,n)    /* nothing */
+#endif
+
+#ifndef GCC_UNUSED
+#define GCC_UNUSED             /* nothing */
+#endif
+
+#ifndef GCC_NORETURN
+#define GCC_NORETURN           /* nothing */
+#endif
+
+#if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
+#define USE_IGNORE_RC
+#define IGNORE_RC(func) ignore_unused = (int) func
+#else
+#define IGNORE_RC(func) (void) func
+#endif /* gcc workarounds */
+
+#include <X11/Xos.h>
+
+#ifndef HAVE_CONFIG_H
+
+#define HAVE_LIB_XAW 1
+
+#ifdef CSRG_BASED
+/* Get definition of BSD */
+#include <sys/param.h>
+#endif
+
+#ifndef DFT_TERMTYPE
+#define DFT_TERMTYPE "xterm"
+#endif
+
+#ifndef X_NOT_POSIX
+#define HAVE_WAITPID 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_UNISTD_H 1
+#endif
+
+#define HAVE_STDLIB_H 1
+
+#if defined(sun)
+/* errno is declared in <errno.h> */
+#else
+#define DECL_ERRNO 1
+#endif
+
+#undef DECL_PTSNAME            /* ptsname() is normally in stdlib.h */
+
+#ifndef NOPUTENV
+#define HAVE_PUTENV 1
+#endif
+
+#if defined(CSRG_BASED) || defined(__GNU__)
+#define USE_POSIX_TERMIOS 1
+#endif
+
+#ifdef __NetBSD__
+#if __NetBSD_Version__ >= 106030000    /* 1.6C */
+#define BSD_UTMPX 1
+#define ut_xtime ut_tv.tv_sec
+#endif
+#endif
+
+#if defined(hpux) && !defined(__hpux)
+#define __hpux 1               /* HPUX 11.0 does not define this */
+#endif
+
+#if !defined(__SCO__) && (defined(SCO) || defined(sco) || defined(SCO325))
+#define __SCO__ 1
+#endif
+
+#ifdef USE_POSIX_TERMIOS
+#define HAVE_TERMIOS_H 1
+#define HAVE_TCGETATTR 1
+#endif
+
+#if defined(__UNIXOS2__) || defined(__SCO__) || defined(__UNIXWARE__)
+#define USE_TERMCAP 1
+#endif
+
+#if defined(UTMP)
+#define HAVE_UTMP 1
+#endif
+
+#if (defined(__MVS__) || defined(SVR4) || defined(__SCO__) || defined(BSD_UTMPX)) && !defined(__CYGWIN__)
+#define UTMPX_FOR_UTMP 1
+#endif
+
+#if !defined(ISC) && !defined(__QNX__)
+#define HAVE_UTMP_UT_HOST 1
+#endif
+
+#if defined(UTMPX_FOR_UTMP) && !(defined(__MVS__) || defined(__hpux))
+#define HAVE_UTMP_UT_SESSION 1
+#endif
+
+#if !(defined(linux) && (!defined(__GLIBC__) || (__GLIBC__ < 2))) && !defined(SVR4)
+#define ut_xstatus ut_exit.e_exit
+#endif
+
+#if defined(SVR4) || defined(__SCO__) || defined(BSD_UTMPX) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)))
+#define HAVE_UTMP_UT_XTIME 1
+#endif
+
+#if defined(linux) || defined(__CYGWIN__)
+#define USE_LASTLOG
+#define HAVE_LASTLOG_H
+#define USE_STRUCT_LASTLOG
+#elif defined(BSD) && (BSD >= 199103)
+#ifdef BSD_UTMPX
+#define USE_LASTLOGX
+#else
+#define USE_LASTLOG
+#define USE_STRUCT_LASTLOG
+#endif
+#endif
+
+#if defined(__OpenBSD__)
+#define DEFDELETE_DEL True
+#define DEF_BACKARO_ERASE True
+#define DEF_INITIAL_ERASE True
+#endif
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#define DEFDELETE_DEL True
+#define OPT_SCO_FUNC_KEYS 1
+#endif
+
+#if defined(__SCO__) || defined(SVR4) || defined(_POSIX_SOURCE) || defined(__QNX__) || defined(__hpux) || (defined(BSD) && (BSD >= 199103)) || defined(__CYGWIN__)
+#define USE_POSIX_WAIT
+#endif
+
+#if defined(AIXV3) || defined(CRAY) || defined(__SCO__) || defined(SVR4) || (defined(SYSV) && defined(i386)) || defined(__MVS__) || defined(__hpux) || defined(__osf__) || defined(linux) || defined(macII) || defined(BSD_UTMPX)
+#define USE_SYSV_UTMP
+#endif
+
+#if defined(__GNU__) || defined(__MVS__) || defined(__osf__)
+#define USE_TTY_GROUP
+#endif
+
+#if defined(__CYGWIN__)
+#define HAVE_NCURSES_TERM_H 1
+#endif
+
+#ifdef __osf__
+#define TTY_GROUP_NAME "terminal"
+#endif
+
+#if defined(__MVS__)
+#undef ut_xstatus
+#define ut_name ut_user
+#define ut_xstatus ut_exit.ut_e_exit
+#define ut_xtime ut_tv.tv_sec
+#endif
+
+#if defined(ut_xstatus)
+#define HAVE_UTMP_UT_XSTATUS 1
+#endif
+
+#if defined(XKB)
+#define HAVE_XKB_BELL_EXT 1
+#endif
+
+#if (defined(SVR4) && !defined(__CYGWIN__)) || defined(linux) || (defined(BSD) && (BSD >= 199103))
+#define HAVE_POSIX_SAVED_IDS
+#endif
+
+#endif /* HAVE_CONFIG_H */
+
+#ifndef HAVE_X11_DECKEYSYM_H
+#define HAVE_X11_DECKEYSYM_H 1
+#endif
+
+#ifndef HAVE_X11_SUNKEYSYM_H
+#define HAVE_X11_SUNKEYSYM_H 1
+#endif
+
+#ifndef HAVE_X11_XF86KEYSYM_H
+#define HAVE_X11_XF86KEYSYM_H 0
+#endif
+
+/***====================================================================***/
+
+/* if compiling with gcc -ansi -pedantic, we must fix POSIX definitions */
+#if defined(SVR4) && defined(sun)
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__ 1
+#endif
+#ifndef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 1
+#endif
+#endif
+
+/***====================================================================***/
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#else
+extern char *calloc();
+extern char *getenv();
+extern char *malloc();
+extern char *realloc();
+extern void exit();
+extern void free();
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#include <errno.h>
+#if defined(DECL_ERRNO) && !defined(errno)
+extern int errno;
+#endif
+
+/*
+ * FIXME:  Toggling logging from xterm hangs under Linux 2.0.29 with libc5 if
+ * we use 'waitpid()', while 'wait()' seems to work properly.
+ */
+#ifdef linux
+#undef HAVE_WAITPID
+#endif
+
+#ifndef OPT_WIDE_CHARS
+#define OPT_WIDE_CHARS 0
+#endif
+
+#if OPT_WIDE_CHARS
+#define HIDDEN_CHAR 0xffff
+#endif
+
+/***====================================================================***/
+
+#include <proto.h>
+#include <ptyx.h>
+
+#if (XtSpecificationRelease >= 6) && !defined(NO_XPOLL_H) && !defined(sun)
+#include <X11/Xpoll.h>
+#define USE_XPOLL_H 1
+#else
+#define Select(n,r,w,e,t) select(n,(fd_set*)r,(fd_set*)w,(fd_set*)e,(struct timeval *)t)
+#define XFD_COPYSET(src,dst) memcpy((dst)->fds_bits, (src)->fds_bits, sizeof(fd_set))
+#if defined(__MVS__) && !defined(TIME_WITH_SYS_TIME)
+#define TIME_WITH_SYS_TIME
+#endif
+#endif
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+/* these may be needed for sig_atomic_t */
+#include <sys/types.h>
+#include <signal.h>
+
+#ifdef USE_SYS_SELECT_H
+
+#if defined(USE_XPOLL_H) && defined(AIXV3) && defined(NFDBITS)
+#undef NFDBITS                 /* conflict between X11/Xpoll.h and sys/select.h */
+#endif
+
+#include <sys/select.h>
+
+#endif /* USE_SYS_SELECT_H */
+
+#include <setjmp.h>
+
+#if defined(__UNIXOS2__) && !defined(XTERM_MAIN)
+#define environ gblenvp                /* circumvent a bug */
+#endif
+
+#if !defined(VMS) && !(defined(linux) && defined(__USE_GNU)) && !defined(__hpux) && !defined(_ALL_SOURCE) && !defined(__osf__)
+extern char **environ;
+#endif
+
+#define XK_Fn(n)       (XK_F1 + (n) - 1)
+
+#define Maybe          2
+
+/***====================================================================***/
+
+#define XtNallowC1Printable    "allowC1Printable"
+#define XtNallowColorOps       "allowColorOps"
+#define XtNallowFontOps                "allowFontOps"
+#define XtNallowScrollLock     "allowScrollLock"
+#define XtNallowSendEvents     "allowSendEvents"
+#define XtNallowTcapOps                "allowTcapOps"
+#define XtNallowTitleOps       "allowTitleOps"
+#define XtNallowWindowOps      "allowWindowOps"
+#define XtNaltIsNotMeta                "altIsNotMeta"
+#define XtNaltSendsEscape      "altSendsEscape"
+#define XtNalwaysBoldMode      "alwaysBoldMode"
+#define XtNalwaysHighlight     "alwaysHighlight"
+#define XtNalwaysUseMods       "alwaysUseMods"
+#define XtNanswerbackString    "answerbackString"
+#define XtNappcursorDefault    "appcursorDefault"
+#define XtNappkeypadDefault    "appkeypadDefault"
+#define XtNautoWrap            "autoWrap"
+#define XtNawaitInput          "awaitInput"
+#define XtNbackarrowKey                "backarrowKey"
+#define XtNbellIsUrgent                "bellIsUrgent"
+#define XtNbellOnReset         "bellOnReset"
+#define XtNbellSuppressTime    "bellSuppressTime"
+#define XtNboldColors          "boldColors"
+#define XtNboldFont            "boldFont"
+#define XtNboldMode            "boldMode"
+#define XtNbrokenLinuxOSC      "brokenLinuxOSC"
+#define XtNbrokenSelections    "brokenSelections"
+#define XtNbrokenStringTerm    "brokenStringTerm"
+#define XtNc132                        "c132"
+#define XtNcacheDoublesize     "cacheDoublesize"
+#define XtNcharClass           "charClass"
+#define XtNcjkWidth            "cjkWidth"
+#define XtNcolorAttrMode       "colorAttrMode"
+#define XtNcolorBDMode         "colorBDMode"
+#define XtNcolorBLMode         "colorBLMode"
+#define XtNcolorMode           "colorMode"
+#define XtNcolorRVMode         "colorRVMode"
+#define XtNcolorULMode         "colorULMode"
+#define XtNcombiningChars      "combiningChars"
+#define XtNctrlFKeys           "ctrlFKeys"
+#define XtNcurses              "curses"
+#define XtNcursorBlink         "cursorBlink"
+#define XtNcursorColor         "cursorColor"
+#define XtNcursorOffTime       "cursorOffTime"
+#define XtNcursorOnTime                "cursorOnTime"
+#define XtNcursorUnderline     "cursorUnderLine"
+#define XtNcutNewline          "cutNewline"
+#define XtNcutToBeginningOfLine        "cutToBeginningOfLine"
+#define XtNdecTerminalID       "decTerminalID"
+#define XtNdefaultString       "defaultString"
+#define XtNdeleteIsDEL         "deleteIsDEL"
+#define XtNdisallowedColorOps  "disallowedColorOps"
+#define XtNdisallowedFontOps   "disallowedFontOps"
+#define XtNdisallowedTcapOps   "disallowedTcapOps"
+#define XtNdisallowedWindowOps "disallowedWindowOps"
+#define XtNdynamicColors       "dynamicColors"
+#define XtNeightBitControl     "eightBitControl"
+#define XtNeightBitInput       "eightBitInput"
+#define XtNeightBitOutput      "eightBitOutput"
+#define XtNeightBitSelectTypes "eightBitSelectTypes"
+#define XtNfaceName            "faceName"
+#define XtNfaceNameDoublesize  "faceNameDoublesize"
+#define XtNfaceSize            "faceSize"
+#define XtNfastScroll          "fastScroll"
+#define XtNfont1               "font1"
+#define XtNfont2               "font2"
+#define XtNfont3               "font3"
+#define XtNfont4               "font4"
+#define XtNfont5               "font5"
+#define XtNfont6               "font6"
+#define XtNfontDoublesize      "fontDoublesize"
+#define XtNfontStyle           "fontStyle"
+#define XtNfontWarnings                "fontWarnings"
+#define XtNforceBoxChars       "forceBoxChars"
+#define XtNforcePackedFont     "forcePackedFont"
+#define XtNformatOtherKeys     "formatOtherKeys"
+#define XtNfreeBoldBox         "freeBoldBox"
+#define XtNhighlightColor      "highlightColor"
+#define XtNhighlightColorMode  "highlightColorMode"
+#define XtNhighlightReverse    "highlightReverse"
+#define XtNhighlightSelection  "highlightSelection"
+#define XtNhighlightTextColor  "highlightTextColor"
+#define XtNhpLowerleftBugCompat        "hpLowerleftBugCompat"
+#define XtNi18nSelections      "i18nSelections"
+#define XtNinitialFont         "initialFont"
+#define XtNinternalBorder      "internalBorder"
+#define XtNitalicULMode                "italicULMode"
+#define XtNjumpScroll          "jumpScroll"
+#define XtNkeepSelection       "keepSelection"
+#define XtNkeyboardDialect     "keyboardDialect"
+#define XtNlimitResize         "limitResize"
+#define XtNlocale              "locale"
+#define XtNlocaleFilter                "localeFilter"
+#define XtNlogFile             "logFile"
+#define XtNlogInhibit          "logInhibit"
+#define XtNlogging             "logging"
+#define XtNloginShell          "loginShell"
+#define XtNmarginBell          "marginBell"
+#define XtNmaximized           "maximized"
+#define XtNmenuBar             "menuBar"
+#define XtNmenuHeight          "menuHeight"
+#define XtNmetaSendsEscape     "metaSendsEscape"
+#define XtNmkSamplePass                "mkSamplePass"
+#define XtNmkSampleSize                "mkSampleSize"
+#define XtNmkWidth             "mkWidth"
+#define XtNmodifyCursorKeys    "modifyCursorKeys"
+#define XtNmodifyFunctionKeys  "modifyFunctionKeys"
+#define XtNmodifyKeypadKeys    "modifyKeypadKeys"
+#define XtNmodifyOtherKeys     "modifyOtherKeys"
+#define XtNmodifyStringKeys    "modifyStringKeys"
+#define XtNmultiClickTime      "multiClickTime"
+#define XtNmultiScroll         "multiScroll"
+#define XtNnMarginBell         "nMarginBell"
+#define XtNnumLock             "numLock"
+#define XtNoldXtermFKeys       "oldXtermFKeys"
+#define XtNpointerColor                "pointerColor"
+#define XtNpointerColorBackground "pointerColorBackground"
+#define XtNpointerMode         "pointerMode"
+#define XtNpointerShape                "pointerShape"
+#define XtNpopOnBell           "popOnBell"
+#define XtNprintAttributes     "printAttributes"
+#define XtNprinterAutoClose    "printerAutoClose"
+#define XtNprinterCommand      "printerCommand"
+#define XtNprinterControlMode  "printerControlMode"
+#define XtNprinterExtent       "printerExtent"
+#define XtNprinterFormFeed     "printerFormFeed"
+#define XtNprinterNewLine      "printerNewLine"
+#define XtNquietGrab           "quietGrab"
+#define XtNrenderFont          "renderFont"
+#define XtNresizeGravity       "resizeGravity"
+#define XtNretryInputMethod     "retryInputMethod"
+#define XtNreverseWrap         "reverseWrap"
+#define XtNrightScrollBar      "rightScrollBar"
+#define XtNsaveLines           "saveLines"
+#define XtNscrollBar           "scrollBar"
+#define XtNscrollBarBorder     "scrollBarBorder"
+#define XtNscrollKey           "scrollKey"
+#define XtNscrollLines         "scrollLines"
+#define XtNscrollPos           "scrollPos"
+#define XtNscrollTtyOutput     "scrollTtyOutput"
+#define XtNselectToClipboard   "selectToClipboard"
+#define XtNshiftFonts          "shiftFonts"
+#define XtNshowBlinkAsBold     "showBlinkAsBold"
+#define XtNshowMissingGlyphs   "showMissingGlyphs"
+#define XtNshowWrapMarks       "showWrapMarks"
+#define XtNsignalInhibit       "signalInhibit"
+#define XtNtekGeometry         "tekGeometry"
+#define XtNtekInhibit          "tekInhibit"
+#define XtNtekSmall            "tekSmall"
+#define XtNtekStartup          "tekStartup"
+#define XtNtiXtraScroll                "tiXtraScroll"
+#define XtNtiteInhibit         "titeInhibit"
+#define XtNtitleModes          "titleModes"
+#define XtNtoolBar             "toolBar"
+#define XtNtrimSelection       "trimSelection"
+#define XtNunderLine           "underLine"
+#define XtNuseClipping         "useClipping"
+#define XtNutf8                        "utf8"
+#define XtNutf8Latin1          "utf8Latin1"
+#define XtNutf8SelectTypes     "utf8SelectTypes"
+#define XtNutf8Title           "utf8Title"
+#define XtNveryBoldColors      "veryBoldColors"
+#define XtNvisualBell          "visualBell"
+#define XtNvisualBellDelay     "visualBellDelay"
+#define XtNvt100Graphics       "vt100Graphics"
+#define XtNwideBoldFont                "wideBoldFont"
+#define XtNwideChars           "wideChars"
+#define XtNwideFont            "wideFont"
+#define XtNximFont             "ximFont"
+#define XtNxmcAttributes       "xmcAttributes"
+#define XtNxmcGlitch           "xmcGlitch"
+#define XtNxmcInline           "xmcInline"
+#define XtNxmcMoveSGR          "xmcMoveSGR"
+
+#define XtCAllowC1Printable    "AllowC1Printable"
+#define XtCAllowColorOps       "AllowColorOps"
+#define XtCAllowFontOps                "AllowFontOps"
+#define XtCAllowScrollLock     "AllowScrollLock"
+#define XtCAllowSendEvents     "AllowSendEvents"
+#define XtCAllowTcapOps                "AllowTcapOps"
+#define XtCAllowTitleOps       "AllowTitleOps"
+#define XtCAllowWindowOps      "AllowWindowOps"
+#define XtCAltIsNotMeta                "AltIsNotMeta"
+#define XtCAltSendsEscape      "AltSendsEscape"
+#define XtCAlwaysBoldMode      "AlwaysBoldMode"
+#define XtCAlwaysHighlight     "AlwaysHighlight"
+#define XtCAlwaysUseMods       "AlwaysUseMods"
+#define XtCAnswerbackString    "AnswerbackString"
+#define XtCAppcursorDefault    "AppcursorDefault"
+#define XtCAppkeypadDefault    "AppkeypadDefault"
+#define XtCAutoWrap            "AutoWrap"
+#define XtCAwaitInput          "AwaitInput"
+#define XtCBackarrowKey                "BackarrowKey"
+#define XtCBellIsUrgent                "BellIsUrgent"
+#define XtCBellOnReset         "BellOnReset"
+#define XtCBellSuppressTime    "BellSuppressTime"
+#define XtCBoldFont            "BoldFont"
+#define XtCBoldMode            "BoldMode"
+#define XtCBrokenLinuxOSC      "BrokenLinuxOSC"
+#define XtCBrokenSelections    "BrokenSelections"
+#define XtCBrokenStringTerm    "BrokenStringTerm"
+#define XtCC132                        "C132"
+#define XtCCacheDoublesize     "CacheDoublesize"
+#define XtCCharClass           "CharClass"
+#define XtCCjkWidth            "CjkWidth"
+#define XtCColorAttrMode       "ColorAttrMode"
+#define XtCColorMode           "ColorMode"
+#define XtCColumn              "Column"
+#define XtCCombiningChars      "CombiningChars"
+#define XtCCtrlFKeys           "CtrlFKeys"
+#define XtCCurses              "Curses"
+#define XtCCursorBlink         "CursorBlink"
+#define XtCCursorOffTime       "CursorOffTime"
+#define XtCCursorOnTime                "CursorOnTime"
+#define XtCCursorUnderline     "CursorUnderLine"
+#define XtCCutNewline          "CutNewline"
+#define XtCCutToBeginningOfLine        "CutToBeginningOfLine"
+#define XtCDecTerminalID       "DecTerminalID"
+#define XtCDefaultString       "DefaultString"
+#define XtCDeleteIsDEL         "DeleteIsDEL"
+#define XtCDisallowedColorOps  "DisallowedColorOps"
+#define XtCDisallowedFontOps   "DisallowedFontOps"
+#define XtCDisallowedTcapOps   "DisallowedTcapOps"
+#define XtCDisallowedWindowOps "DisallowedWindowOps"
+#define XtCDynamicColors       "DynamicColors"
+#define XtCEightBitControl     "EightBitControl"
+#define XtCEightBitInput       "EightBitInput"
+#define XtCEightBitOutput      "EightBitOutput"
+#define XtCEightBitSelectTypes "EightBitSelectTypes"
+#define XtCFaceName            "FaceName"
+#define XtCFaceNameDoublesize  "FaceNameDoublesize"
+#define XtCFaceSize            "FaceSize"
+#define XtCFastScroll          "FastScroll"
+#define XtCFont1               "Font1"
+#define XtCFont2               "Font2"
+#define XtCFont3               "Font3"
+#define XtCFont4               "Font4"
+#define XtCFont5               "Font5"
+#define XtCFont6               "Font6"
+#define XtCFontDoublesize      "FontDoublesize"
+#define XtCFontStyle           "FontStyle"
+#define XtCFontWarnings                "FontWarnings"
+#define XtCForceBoxChars       "ForceBoxChars"
+#define XtCForcePackedFont     "ForcePackedFont"
+#define XtCFormatOtherKeys     "FormatOtherKeys"
+#define XtCFreeBoldBox         "FreeBoldBox"
+#define XtCHighlightColorMode  "HighlightColorMode"
+#define XtCHighlightReverse    "HighlightReverse"
+#define XtCHighlightSelection  "HighlightSelection"
+#define XtCHpLowerleftBugCompat        "HpLowerleftBugCompat"
+#define XtCI18nSelections      "I18nSelections"
+#define XtCInitialFont         "InitialFont"
+#define XtCJumpScroll          "JumpScroll"
+#define XtCKeepSelection       "KeepSelection"
+#define XtCKeyboardDialect     "KeyboardDialect"
+#define XtCLimitResize         "LimitResize"
+#define XtCLocale              "Locale"
+#define XtCLocaleFilter                "LocaleFilter"
+#define XtCLogInhibit          "LogInhibit"
+#define XtCLogfile             "Logfile"
+#define XtCLogging             "Logging"
+#define XtCLoginShell          "LoginShell"
+#define XtCMarginBell          "MarginBell"
+#define XtCMaximized           "Maximized"
+#define XtCMenuBar             "MenuBar"
+#define XtCMenuHeight          "MenuHeight"
+#define XtCMetaSendsEscape     "MetaSendsEscape"
+#define XtCMkSamplePass        "MkSamplePass"
+#define XtCMkSampleSize        "MkSampleSize"
+#define XtCMkWidth             "MkWidth"
+#define XtCModifyCursorKeys    "ModifyCursorKeys"
+#define XtCModifyFunctionKeys  "ModifyFunctionKeys"
+#define XtCModifyKeypadKeys    "ModifyKeypadKeys"
+#define XtCModifyOtherKeys     "ModifyOtherKeys"
+#define XtCModifyStringKeys    "ModifyStringKeys"
+#define XtCMultiClickTime      "MultiClickTime"
+#define XtCMultiScroll         "MultiScroll"
+#define XtCNumLock             "NumLock"
+#define XtCOldXtermFKeys       "OldXtermFKeys"
+#define XtCPointerMode         "PointerMode"
+#define XtCPopOnBell           "PopOnBell"
+#define XtCPrintAttributes     "PrintAttributes"
+#define XtCPrinterAutoClose    "PrinterAutoClose"
+#define XtCPrinterCommand      "PrinterCommand"
+#define XtCPrinterControlMode  "PrinterControlMode"
+#define XtCPrinterExtent       "PrinterExtent"
+#define XtCPrinterFormFeed     "PrinterFormFeed"
+#define XtCPrinterNewLine      "PrinterNewLine"
+#define XtCQuietGrab           "QuietGrab"
+#define XtCRenderFont          "RenderFont"
+#define XtCResizeGravity       "ResizeGravity"
+#define XtCRetryInputMethod     "RetryInputMethod"
+#define XtCReverseWrap         "ReverseWrap"
+#define XtCRightScrollBar      "RightScrollBar"
+#define XtCSaveLines           "SaveLines"
+#define XtCScrollBar           "ScrollBar"
+#define XtCScrollBarBorder     "ScrollBarBorder"
+#define XtCScrollCond          "ScrollCond"
+#define XtCScrollLines         "ScrollLines"
+#define XtCScrollPos           "ScrollPos"
+#define XtCSelectToClipboard   "SelectToClipboard"
+#define XtCShiftFonts          "ShiftFonts"
+#define XtCShowBlinkAsBold     "ShowBlinkAsBold"
+#define XtCShowMissingGlyphs   "ShowMissingGlyphs"
+#define XtCShowWrapMarks       "ShowWrapMarks"
+#define XtCSignalInhibit       "SignalInhibit"
+#define XtCTekInhibit          "TekInhibit"
+#define XtCTekSmall            "TekSmall"
+#define XtCTekStartup          "TekStartup"
+#define XtCTiXtraScroll                "TiXtraScroll"
+#define XtCTiteInhibit         "TiteInhibit"
+#define XtCTitleModes          "TitleModes"
+#define XtCToolBar             "ToolBar"
+#define XtCTrimSelection       "TrimSelection"
+#define XtCUnderLine           "UnderLine"
+#define XtCUseClipping         "UseClipping"
+#define XtCUtf8                        "Utf8"
+#define XtCUtf8Latin1          "Utf8Latin1"
+#define XtCUtf8SelectTypes     "Utf8SelectTypes"
+#define XtCUtf8Title           "Utf8Title"
+#define XtCVT100Graphics       "VT100Graphics"
+#define XtCVeryBoldColors      "VeryBoldColors"
+#define XtCVisualBell          "VisualBell"
+#define XtCVisualBellDelay     "VisualBellDelay"
+#define XtCWideBoldFont                "WideBoldFont"
+#define XtCWideChars           "WideChars"
+#define XtCWideFont            "WideFont"
+#define XtCXimFont             "XimFont"
+#define XtCXmcAttributes       "XmcAttributes"
+#define XtCXmcGlitch           "XmcGlitch"
+#define XtCXmcInline           "XmcInline"
+#define XtCXmcMoveSGR          "XmcMoveSGR"
+
+#if defined(NO_ACTIVE_ICON) && !defined(XtNgeometry)
+#define XtNgeometry            "geometry"
+#define XtCGeometry            "Geometry"
+#endif
+
+#if OPT_COLOR_CLASS
+#define XtCCursorColor         "CursorColor"
+#define XtCPointerColor                "PointerColor"
+#define XtCHighlightColor      "HighlightColor"
+#define XtCHighlightTextColor  "HighlightTextColor"
+#else
+#define XtCCursorColor         XtCForeground
+#define XtCPointerColor                XtCForeground
+#define XtCHighlightColor      XtCForeground
+#define XtCHighlightTextColor  XtCBackground
+#endif
+
+/***====================================================================***/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct XTERM_RESOURCE;
+
+/* Tekproc.c */
+#if OPT_TEK4014
+extern TekWidget getTekWidget(Widget /* w */);
+extern int TekGetFontSize (const char * /* param */);
+extern int TekInit (void);
+extern int TekPtyData(void);
+extern void ChangeTekColors (TekWidget /* tw */, TScreen * /* screen */, ScrnColors * /* pNew */);
+extern void HandleGINInput             PROTO_XT_ACTIONS_ARGS;
+extern void TCursorToggle (TekWidget /* tw */, int /* toggle */);
+extern void TekCopy (TekWidget /* tw */);
+extern void TekEnqMouse (TekWidget /* tw */, int /* c */);
+extern void TekExpose (Widget  /* w */, XEvent * /* event */, Region  /* region */);
+extern void TekGINoff (TekWidget /* tw */);
+extern void TekRefresh (TekWidget /* tw */);
+extern void TekRepaint (TekWidget /* xw */);
+extern void TekReverseVideo (TekWidget /* tw */);
+extern void TekRun (void);
+extern void TekSetFontSize (TekWidget /* tw */, Bool /* fromMenu */, int  /* newitem */);
+extern void TekSimulatePageButton (TekWidget /* tw */, Bool /* reset */);
+#endif
+
+/* button.c */
+#define        MotionOff( s, t ) if (!(screen->hide_pointer)) {                \
+           (s)->event_mask |= ButtonMotionMask;                        \
+           (s)->event_mask &= ~PointerMotionMask;                      \
+           XSelectInput(XtDisplay((t)), XtWindow((t)), (long) (s)->event_mask); }
+
+#define        MotionOn( s, t ) {                                              \
+           (s)->event_mask &= ~ButtonMotionMask;                       \
+           (s)->event_mask |= PointerMotionMask;                       \
+           XSelectInput(XtDisplay((t)), XtWindow((t)), (long) (s)->event_mask); }
+
+extern Bool SendMousePosition (XtermWidget  /* w */, XEvent*  /* event */);
+extern void DiredButton                PROTO_XT_ACTIONS_ARGS;
+extern void DisownSelection (XtermWidget  /* termw */);
+extern void UnhiliteSelection (XtermWidget  /* termw */);
+extern void HandleCopySelection        PROTO_XT_ACTIONS_ARGS;
+extern void HandleInsertSelection      PROTO_XT_ACTIONS_ARGS;
+extern void HandleKeyboardSelectEnd    PROTO_XT_ACTIONS_ARGS;
+extern void HandleKeyboardSelectExtend PROTO_XT_ACTIONS_ARGS;
+extern void HandleKeyboardSelectStart  PROTO_XT_ACTIONS_ARGS;
+extern void HandleKeyboardStartExtend  PROTO_XT_ACTIONS_ARGS;
+extern void HandleSelectEnd            PROTO_XT_ACTIONS_ARGS;
+extern void HandleSelectExtend         PROTO_XT_ACTIONS_ARGS;
+extern void HandleSelectSet            PROTO_XT_ACTIONS_ARGS;
+extern void HandleSelectStart          PROTO_XT_ACTIONS_ARGS;
+extern void HandleStartExtend          PROTO_XT_ACTIONS_ARGS;
+extern void ResizeSelection (TScreen * /* screen */, int  /* rows */, int  /* cols */);
+extern void ScrollSelection (TScreen * /* screen */, int  /* amount */,  Bool /* always */);
+extern void TrackMouse (XtermWidget /* xw */, int /* func */, CELL * /* start */, int /* firstrow */, int /* lastrow */);
+extern void ViButton                   PROTO_XT_ACTIONS_ARGS;
+
+extern int xtermUtf8ToTextList(XtermWidget /* xw */, XTextProperty * /* text_prop */, char *** /* text_list */, int * /* text_list_count */);
+
+#if OPT_DEC_LOCATOR
+extern void GetLocatorPosition (XtermWidget  /* w */);
+extern void InitLocatorFilter (XtermWidget  /* w */);
+#endif /* OPT_DEC_LOCATOR */
+
+#if OPT_FOCUS_EVENT
+extern void SendFocusButton(XtermWidget /* xw */, XFocusChangeEvent * /* event */);
+#else
+#define SendFocusBotton(xw, event) /* nothing */
+#endif
+
+#if OPT_PASTE64
+extern void AppendToSelectionBuffer (TScreen * /* screen */, unsigned  /* c */);
+extern void ClearSelectionBuffer (TScreen * /* screen */);
+extern void CompleteSelection (XtermWidget  /* xw */, String * /* args */, Cardinal  /* len */);
+extern void xtermGetSelection (Widget  /* w */, Time  /* ev_time */, String * /* params */, Cardinal  /* num_params */, Atom * /* targets */);
+#endif
+
+#if OPT_READLINE
+extern void ReadLineButton             PROTO_XT_ACTIONS_ARGS;
+#endif
+
+#if OPT_WIDE_CHARS
+extern Bool iswide(int  /* i */);
+#define WideCells(n) (((IChar)(n) >= first_widechar) ? my_wcwidth((wchar_t) (n)) : 1)
+#define isWide(n)    (((IChar)(n) >= first_widechar) && iswide(n))
+#else
+#define WideCells(n) 1
+#endif
+
+/* cachedCgs.c */
+extern CgsEnum getCgsId(XtermWidget /*xw*/, VTwin * /*cgsWin*/, GC /*gc*/);
+extern GC freeCgs(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*cgsId*/);
+extern GC getCgsGC(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*cgsId*/);
+extern Pixel getCgsBack(XtermWidget /*xw*/, VTwin * /*cgsWin*/, GC /*gc*/);
+extern Pixel getCgsFore(XtermWidget /*xw*/, VTwin * /*cgsWin*/, GC /*gc*/);
+extern XTermFonts * getCgsFont(XtermWidget /*xw*/, VTwin * /*cgsWin*/, GC /*gc*/);
+extern void clrCgsFonts(XtermWidget /*xw*/, VTwin * /*cgsWin*/, XTermFonts * /*font*/);
+extern void copyCgs(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*dstCgsId*/, CgsEnum /*srcCgsId*/);
+extern void redoCgs(XtermWidget /*xw*/, Pixel /*fg*/, Pixel /*bg*/, CgsEnum /*cgsId*/);
+extern void setCgsBack(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*cgsId*/, Pixel /*bg*/);
+extern void setCgsCSet(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*cgsId*/, unsigned /*cset*/);
+extern void setCgsFont(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*cgsId*/, XTermFonts * /*font*/);
+extern void setCgsFore(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*cgsId*/, Pixel /*fg*/);
+extern void swapCgs(XtermWidget /*xw*/, VTwin * /*cgsWin*/, CgsEnum /*dstCgsId*/, CgsEnum /*srcCgsId*/);
+
+#ifdef NO_LEAKS
+extern void noleaks_cachedCgs (XtermWidget /* xw */);
+#endif
+
+/* charproc.c */
+extern Bool CheckBufPtrs (TScreen * /* screen */);
+extern Bool set_cursor_gcs (XtermWidget /* xw */);
+extern int VTInit (XtermWidget /* xw */);
+extern void FindFontSelection (XtermWidget /* xw */, const char * /* atom_name */, Bool  /* justprobe */);
+extern void HideCursor (void);
+extern void RestartBlinking(TScreen * /* screen */);
+extern void ShowCursor (void);
+extern void SwitchBufPtrs (TScreen * /* screen */, int /* toBuf */);
+extern void ToggleAlternate (XtermWidget /* xw */);
+extern void VTReset (XtermWidget /* xw */, int /* full */, int /* saved */);
+extern void VTRun (XtermWidget /* xw */);
+extern void dotext (XtermWidget /* xw */, int  /* charset */, IChar * /* buf */, Cardinal  /* len */);
+extern void releaseCursorGCs(XtermWidget /*xw*/);
+extern void releaseWindowGCs(XtermWidget /*xw*/, VTwin * /*win*/);
+extern void resetCharsets (TScreen * /* screen */);
+extern void set_max_col(TScreen *  /* screen */, int  /* cols */);
+extern void set_max_row(TScreen *  /* screen */, int  /* rows */);
+extern void set_tb_margins (TScreen * /* screen */, int  /* top */, int  /* bottom */);
+extern void unparse_end (XtermWidget /* xw */);
+extern void unparseputc (XtermWidget /* xw */, int  /* c */);
+extern void unparseputc1 (XtermWidget /* xw */, int  /* c */);
+extern void unparseputn (XtermWidget /* xw */, unsigned /* n */);
+extern void unparseputs (XtermWidget /* xw */, const char * /* s */);
+extern void unparseseq (XtermWidget /* xw */, ANSI * /* ap */);
+extern void v_write (int  /* f */, const Char * /* d */, unsigned  /* len */);
+extern void xtermAddInput(Widget  /* w */);
+
+#if OPT_BLINK_CURS
+extern void ToggleCursorBlink(TScreen * /* screen */);
+#endif
+
+#if OPT_ISO_COLORS
+extern void SGR_Background (XtermWidget /* xw */, int  /* color */);
+extern void SGR_Foreground (XtermWidget /* xw */, int  /* color */);
+#endif
+
+#ifdef NO_LEAKS
+extern void noleaks_charproc (void);
+#endif
+
+/* charsets.c */
+extern unsigned xtermCharSetIn (unsigned  /* code */, int  /* charset */);
+extern int xtermCharSetOut (XtermWidget /* xw */, IChar * /* buf */, IChar * /* ptr */, int  /* charset */);
+
+/* cursor.c */
+extern void AdjustSavedCursor (XtermWidget /* xw */, int /* adjust */);
+extern void CarriageReturn (TScreen * /* screen */);
+extern void CursorBack (XtermWidget /* xw */, int   /* n */);
+extern void CursorDown (TScreen * /* screen */, int   /* n */);
+extern void CursorForward (TScreen * /* screen */, int   /* n */);
+extern void CursorNextLine (TScreen * /* screen */, int  /* count */);
+extern void CursorPrevLine (TScreen * /* screen */, int  /* count */);
+extern void CursorRestore (XtermWidget  /* xw */);
+extern void CursorSave (XtermWidget  /* xw */);
+extern void CursorSet (TScreen * /* screen */, int  /* row */, int  /* col */, unsigned  /* flags */);
+extern void CursorUp (TScreen * /* screen */, int   /* n */);
+extern void RevIndex (XtermWidget /* xw */, int  /* amount */);
+extern void xtermIndex (XtermWidget /* xw */, int  /* amount */);
+
+#if OPT_TRACE
+extern int set_cur_col(TScreen * /* screen */, int  /* value */);
+extern int set_cur_row(TScreen * /* screen */, int  /* value */);
+#else
+#define set_cur_col(screen, value) screen->cur_col = value
+#define set_cur_row(screen, value) screen->cur_row = value
+#endif
+
+/* doublechr.c */
+extern void xterm_DECDHL (XtermWidget /* xw */, Bool  /* top */);
+extern void xterm_DECSWL (XtermWidget /* xw */);
+extern void xterm_DECDWL (XtermWidget /* xw */);
+#if OPT_DEC_CHRSET
+extern int xterm_Double_index(XtermWidget /* xw */, unsigned  /* chrset */, unsigned  /* flags */);
+extern GC xterm_DoubleGC(XtermWidget /* xw */, unsigned  /* chrset */, unsigned  /* flags */, GC  /* old_gc */, int * /* inxp */);
+#endif
+
+/* input.c */
+extern unsigned xtermParamToState (XtermWidget /* xw */, unsigned /* param */);
+extern unsigned xtermStateToParam (XtermWidget /* xw */, unsigned /* state */);
+extern Bool xtermDeleteIsDEL (XtermWidget /* xw */);
+extern void Input (XtermWidget /* xw */, XKeyEvent */* event */, Bool /* eightbit */);
+extern void StringInput (XtermWidget /* xw */, const Char * /* string */, size_t  /* nbytes */);
+
+#if OPT_NUM_LOCK
+extern void VTInitModifiers(XtermWidget /* xw */);
+#endif
+
+/* linedata.c */
+extern LineData *getLineData(TScreen * /* screen */, int /* row */);
+extern void copyLineData(LineData * /* dst */, LineData * /* src */);
+extern void initLineData(XtermWidget /* xw */);
+
+extern CellData *newCellData(XtermWidget /* xw */, Cardinal /* count */);
+extern void saveCellData(TScreen * /* screen */, CellData * /* data */, Cardinal /* cell */, LineData * /* ld */, int /* column */);
+extern void restoreCellData(TScreen * /* screen */, CellData * /* data */, Cardinal /* cell */, LineData * /* ld */, int /* column */);
+
+/* main.c */
+#ifndef __UNIXOS2__
+#define ENVP_ARG /**/
+#else
+#define ENVP_ARG , char ** /* envp */
+#endif
+
+extern int main (int  /* argc */, char ** /* argv */ ENVP_ARG);
+extern int GetBytesAvailable (int  /* fd */);
+extern int kill_process_group (int  /* pid */, int  /* sig */);
+extern int nonblocking_wait (void);
+
+#if OPT_PTY_HANDSHAKE
+extern void first_map_occurred (void);
+#else
+#define first_map_occurred() /* nothing */
+#endif
+
+#ifdef SIGNAL_T
+extern SIGNAL_T Exit (int  /* n */);
+#endif
+
+#ifndef SIG_ATOMIC_T
+#define SIG_ATOMIC_T int
+#endif
+
+#if OPT_WIDE_CHARS
+extern unsigned first_widechar;
+extern int (*my_wcwidth)(wchar_t);
+#endif
+
+/* menu.c */
+extern void do_hangup          PROTO_XT_CALLBACK_ARGS;
+extern void repairSizeHints    (void);
+extern void show_8bit_control  (Bool  /* value */);
+
+/* misc.c */
+extern Bool AllocateTermColor(XtermWidget, ScrnColors *, int, const char *, Bool);
+extern Cursor make_colored_cursor (unsigned /* cursorindex */, unsigned long  /* fg */, unsigned long  /* bg */);
+extern OptionHelp * sortedOpts(OptionHelp *, XrmOptionDescRec *, Cardinal);
+extern Window WMFrameWindow(XtermWidget /* termw */);
+extern XrmOptionDescRec * sortedOptDescs(XrmOptionDescRec *, Cardinal);
+extern XtermWidget getXtermWidget(Widget /* w */);
+extern char *udk_lookup (int /* keycode */, int * /* len */);
+extern char *xtermEnvEncoding (void);
+extern char *xtermEnvLocale (void);
+extern char *xtermFindShell(char * /* leaf */, Bool  /* warning */);
+extern char *xtermVersion(void);
+extern const char *SysErrorMsg (int /* n */);
+extern const char *SysReasonMsg (int /* n */);
+extern int ResetAnsiColorRequest(XtermWidget, char *, int);
+extern int XStrCmp (char * /* s1 */, char * /* s2 */);
+extern int creat_as (uid_t  /* uid */, gid_t  /* gid */, Bool  /* append */, char * /* pathname */, int  /* mode */);
+extern int open_userfile (uid_t  /* uid */, gid_t  /* gid */, char * /* path */, Bool  /* append */);
+extern int xerror (Display * /* d */, XErrorEvent * /* ev */);
+extern int xioerror (Display * /* dpy */);
+extern int xtermResetIds(TScreen *  /* screen */);
+extern void Bell (XtermWidget /* xw */, int  /* which */, int  /* percent */);
+extern void ChangeIconName (XtermWidget /* xw */, char * /* name */);
+extern void ChangeTitle (XtermWidget /* xw */, char * /* name */);
+extern void ChangeXprop (char * /* name */);
+extern void Cleanup (int  /* code */);
+extern void HandleBellPropertyChange   PROTO_XT_EV_HANDLER_ARGS;
+extern void HandleEightBitKeyPressed   PROTO_XT_ACTIONS_ARGS;
+extern void HandleEnterWindow          PROTO_XT_EV_HANDLER_ARGS;
+extern void HandleFocusChange          PROTO_XT_EV_HANDLER_ARGS;
+extern void HandleInterpret            PROTO_XT_ACTIONS_ARGS;
+extern void HandleKeyPressed           PROTO_XT_ACTIONS_ARGS;
+extern void HandleLeaveWindow          PROTO_XT_EV_HANDLER_ARGS;
+extern void HandleSpawnTerminal        PROTO_XT_ACTIONS_ARGS;
+extern void HandleStringEvent          PROTO_XT_ACTIONS_ARGS;
+extern void Panic (const char * /* s */, int  /* a */);
+extern void Redraw (void);
+extern void ReverseOldColors (void);
+extern void SysError (int /* i */) GCC_NORETURN;
+extern void VisualBell (void);
+extern void do_dcs (XtermWidget /* xw */, Char * /* buf */, size_t  /* len */);
+extern void do_decrpm (XtermWidget /* xw */, int /* nparam */, int *  /* params */);
+extern void do_osc (XtermWidget /* xw */, Char * /* buf */, size_t  /* len */, int  /* final */);
+extern void do_rpm (XtermWidget /* xw */, int /* nparam */, int *  /* params */);
+extern void do_xevents (void);
+extern void end_tek_mode (void);
+extern void end_vt_mode (void);
+extern void hide_tek_window (void);
+extern void hide_vt_window (void);
+extern void reset_decudk (void);
+extern void set_tek_visibility (Bool  /* on */);
+extern void set_vt_visibility (Bool  /* on */);
+extern void switch_modes (Bool  /* tovt */);
+extern void timestamp_filename(char * /* dst */, const char * /* src */);
+extern void xevents (void);
+extern void xt_error (String  /* message */);
+extern void xtermBell(XtermWidget /* xw */, int /* which */, int /* percent */);
+extern void xtermCopyEnv (char ** /* oldenv */);
+extern void xtermDisplayCursor (XtermWidget /* xw */);
+extern void xtermSetenv (const char * /* var */, const char * /* value */);
+extern void xtermShowPointer (XtermWidget /* xw */, Bool /* enable */);
+
+#if OPT_DABBREV
+extern void HandleDabbrevExpand        PROTO_XT_ACTIONS_ARGS;
+#endif
+
+#if OPT_MAXIMIZE
+extern int QueryMaximize (XtermWidget  /* termw */, unsigned * /* width */, unsigned * /* height */);
+extern void HandleDeIconify            PROTO_XT_ACTIONS_ARGS;
+extern void HandleIconify              PROTO_XT_ACTIONS_ARGS;
+extern void HandleMaximize             PROTO_XT_ACTIONS_ARGS;
+extern void HandleRestoreSize          PROTO_XT_ACTIONS_ARGS;
+extern void RequestMaximize (XtermWidget  /* termw */, int  /* maximize */);
+#endif
+
+#if OPT_SCROLL_LOCK
+extern void GetScrollLock (TScreen * /* screen */);
+extern void HandleScrollLock           PROTO_XT_ACTIONS_ARGS;
+extern void ShowScrollLock (TScreen * /* screen */, Bool /* enable */);
+extern void SetScrollLock (TScreen * /* screen */, Bool /* enable */);
+extern void xtermShowLED (TScreen * /* screen */, Cardinal /* led_number */, Bool /* enable */);
+extern void xtermClearLEDs (TScreen * /* screen */);
+#else
+#define ShowScrollLock(screen, enable) /* nothing */
+#define SetScrollLock(screen, enable) /* nothing */
+#define GetScrollLock(screen) /* nothing */
+#endif
+
+#if OPT_WIDE_CHARS
+extern Bool xtermEnvUTF8(void);
+#else
+#define xtermEnvUTF8() False
+#endif
+
+#ifdef ALLOWLOGGING
+extern void StartLog (XtermWidget /* xw */);
+extern void CloseLog (XtermWidget /* xw */);
+extern void FlushLog (XtermWidget /* xw */);
+#else
+#define FlushLog(xw) /*nothing*/
+#endif
+
+/* print.c */
+extern Bool xtermHasPrinter (XtermWidget /* xw */);
+extern PrinterFlags *getPrinterFlags(XtermWidget /* xw */, String * /* params */, Cardinal * /* param_count */);
+extern int xtermPrinterControl (XtermWidget /* xw */, int /* chr */);
+extern void setPrinterControlMode (XtermWidget /* xw */, int /* mode */);
+extern void xtermAutoPrint (XtermWidget /* xw */, unsigned /* chr */);
+extern void xtermMediaControl (XtermWidget /* xw */, int  /* param */, int  /* private_seq */);
+extern void xtermPrintScreen (XtermWidget /* xw */, Bool  /* use_DECPEX */, PrinterFlags * /* p */);
+extern void xtermPrintEverything (XtermWidget /* xw */, PrinterFlags * /* p */);
+
+/* ptydata.c */
+#ifdef VMS
+#define PtySelect int
+#else
+#define PtySelect fd_set
+#endif
+
+extern Bool decodeUtf8 (PtyData * /* data */);
+extern int readPtyData (XtermWidget /* xw */, PtySelect * /* select_mask */, PtyData * /* data */);
+extern void fillPtyData (XtermWidget /* xw */, PtyData * /* data */, const char * /* value */, int  /* length */);
+extern void initPtyData (PtyData ** /* data */);
+extern void trimPtyData (XtermWidget /* xw */, PtyData * /* data */);
+
+#ifdef NO_LEAKS
+extern void noleaks_ptydata ( void );
+#endif
+
+#if OPT_WIDE_CHARS
+extern Char *convertToUTF8 (Char * /* lp */, unsigned  /* c */);
+extern IChar nextPtyData (TScreen * /* screen */, PtyData * /* data */);
+extern IChar skipPtyData (PtyData * /* data */);
+extern PtyData * fakePtyData(PtyData * /* result */, Char * /* next */, Char * /* last */);
+extern void switchPtyData (TScreen * /* screen */, int  /* f */);
+extern void writePtyData (int  /* f */, IChar * /* d */, unsigned  /* len */);
+
+#define morePtyData(screen,data) \
+       (((data)->last > (data)->next) \
+        ? (((screen)->utf8_inparse && !(data)->utf_size) \
+           ? decodeUtf8(data) \
+           : True) \
+        : False)
+#else
+#define morePtyData(screen, data) ((data)->last > (data)->next)
+#define nextPtyData(screen, data) (*((data)->next++) & \
+                                       (screen->output_eight_bits \
+                                       ? 0xff \
+                                       : 0x7f))
+#define writePtyData(f,d,len) v_write(f,d,len)
+#endif
+
+/* screen.c */
+extern Bool non_blank_line (TScreen */* screen */, int  /* row */, int  /* col */, int  /* len */);
+extern Char * allocScrnData(TScreen * /* screen */, unsigned /* nrow */, unsigned /* ncol */);
+extern ScrnBuf allocScrnBuf (XtermWidget /* xw */, unsigned  /* nrow */, unsigned  /* ncol */, ScrnPtr * /* addr */);
+extern ScrnBuf scrnHeadAddr (TScreen * /* screen */, ScrnBuf /* base */, unsigned /* offset */);
+extern int ScreenResize (XtermWidget /* xw */, int  /* width */, int  /* height */, unsigned * /* flags */);
+extern size_t ScrnPointers (TScreen * /* screen */, size_t  /* len */);
+extern void ClearBufRows (XtermWidget /* xw */, int  /* first */, int  /* last */);
+extern void ClearCells (XtermWidget /* xw */, int /* flags */, unsigned /* len */, int /* row */, int /* col */);
+extern void ScrnAllocBuf (XtermWidget /* xw */);
+extern void ScrnClearCells (XtermWidget /* xw */, int /* row */, int /* col */, unsigned /* len */);
+extern void ScrnDeleteChar (XtermWidget /* xw */, unsigned  /* n */);
+extern void ScrnDeleteLine (XtermWidget /* xw */, ScrnBuf  /* sb */, int  /* n */, int  /* last */, unsigned /* where */);
+extern void ScrnDisownSelection (XtermWidget /* xw */);
+extern void ScrnFillRectangle (XtermWidget /* xw */, XTermRect *,  int ,  unsigned /* flags */, Bool /* keepColors */);
+extern void ScrnInsertChar (XtermWidget /* xw */, unsigned  /* n */);
+extern void ScrnInsertLine (XtermWidget /* xw */, ScrnBuf /* sb */, int  /* last */, int  /* where */, unsigned  /* n */);
+extern void ScrnRefresh (XtermWidget /* xw */, int  /* toprow */, int  /* leftcol */, int  /* nrows */, int  /* ncols */, Bool  /* force */);
+extern void ScrnUpdate (XtermWidget /* xw */, int  /* toprow */, int  /* leftcol */, int  /* nrows */, int  /* ncols */, Bool  /* force */);
+extern void ScrnWriteText (XtermWidget /* xw */, IChar * /* str */, unsigned  /* flags */, unsigned /* cur_fg_bg */, unsigned  /* length */);
+extern void ShowWrapMarks (XtermWidget /* xw */, int /* row */, LineData * /* ld */);
+extern void setupLineData (TScreen * /* screen */, ScrnBuf /* base */, Char * /* data */, unsigned /* nrow */, unsigned /* ncol */);
+extern void xtermParseRect (XtermWidget /* xw */, int, int *, XTermRect *);
+
+#if OPT_TRACE && OPT_TRACE_FLAGS
+extern int  LineTstFlag(LineData /* ld */, int /* flag */);
+extern void LineClrFlag(LineData /* ld */, int /* flag */);
+extern void LineSetFlag(LineData /* ld */, int /* flag */);
+#else
+
+#define LineFlags(ld)         GetLineFlags(ld)
+
+#define LineClrFlag(ld, flag) SetLineFlags(ld, (GetLineFlags(ld) & ~ (flag)))
+#define LineSetFlag(ld, flag) SetLineFlags(ld, (GetLineFlags(ld) | (flag)))
+#define LineTstFlag(ld, flag) ((GetLineFlags(ld) & flag) != 0)
+
+#endif /* OPT_TRACE && OPT_TRACE_FLAGS */
+
+#define LineClrBlinked(ld) LineClrFlag(ld, LINEBLINKED)
+#define LineSetBlinked(ld) LineSetFlag(ld, LINEBLINKED)
+#define LineTstBlinked(ld) LineTstFlag(ld, LINEBLINKED)
+
+#define LineClrWrapped(ld) LineClrFlag(ld, LINEWRAPPED)
+#define LineSetWrapped(ld) LineSetFlag(ld, LINEWRAPPED)
+#define LineTstWrapped(ld) LineTstFlag(ld, LINEWRAPPED)
+
+#define ScrnHaveSelection(screen) \
+                       ((screen)->startH.row != (screen)->endH.row \
+                       || (screen)->startH.col != (screen)->endH.col)
+
+#define ScrnAreLinesInSelection(screen, first, last) \
+       ((last) >= (screen)->startH.row && (first) <= (screen)->endH.row)
+
+#define ScrnIsLineInSelection(screen, line) \
+       ((line) >= (screen)->startH.row && (line) <= (screen)->endH.row)
+
+#define ScrnHaveLineMargins(screen) \
+                       ((screen)->top_marg != 0 \
+                       || ((screen)->bot_marg != screen->max_row))
+
+#define ScrnIsLineInMargins(screen, line) \
+       ((line) >= (screen)->top_marg && (line) <= (screen)->bot_marg)
+
+#if OPT_DEC_RECTOPS
+extern void ScrnCopyRectangle (XtermWidget /* xw */, XTermRect *, int, int *);
+extern void ScrnMarkRectangle (XtermWidget /* xw */, XTermRect *, Bool, int, int *);
+extern void ScrnWipeRectangle (XtermWidget /* xw */, XTermRect *);
+#endif
+
+#if OPT_WIDE_CHARS
+extern void ChangeToWide(XtermWidget /* xw */);
+#endif
+
+/* scrollback.c */
+extern LineData *getScrollback (TScreen * /* screen */, int /* row */);
+extern LineData *addScrollback (TScreen * /* screen */);
+extern void deleteScrollback (TScreen * /* screen */, int /* row */);
+
+/* scrollbar.c */
+extern void DoResizeScreen (XtermWidget /* xw */);
+extern void HandleScrollBack           PROTO_XT_ACTIONS_ARGS;
+extern void HandleScrollForward        PROTO_XT_ACTIONS_ARGS;
+extern void ResizeScrollBar (XtermWidget  /* xw */);
+extern void ScrollBarDrawThumb (Widget  /* scrollWidget */);
+extern void ScrollBarOff (XtermWidget  /* xw */);
+extern void ScrollBarOn (XtermWidget  /* xw */, Bool /* init */);
+extern void ScrollBarReverseVideo (Widget  /* scrollWidget */);
+extern void ToggleScrollBar (XtermWidget  /* xw */);
+extern void WindowScroll (XtermWidget /* xw */, int  /* top */, Bool /* always */);
+
+#ifdef SCROLLBAR_RIGHT
+extern void updateRightScrollbar(XtermWidget  /* xw */);
+#else
+#define updateRightScrollbar(xw) /* nothing */
+#endif
+
+/* tabs.c */
+extern Bool TabToNextStop (XtermWidget /* xw */);
+extern Bool TabToPrevStop (XtermWidget /* xw */);
+extern void TabClear (Tabs  /* tabs */, int  /* col */);
+extern void TabReset (Tabs  /* tabs */);
+extern void TabSet (Tabs  /* tabs */, int  /* col */);
+extern void TabZonk (Tabs  /* tabs */);
+
+/* util.c */
+extern Boolean isDefaultBackground(const char * /* name */);
+extern Boolean isDefaultForeground(const char * /* name */);
+extern GC updatedXtermGC (XtermWidget /* xw */, unsigned  /* flags */, unsigned /* fg_bg */, Bool  /* hilite */);
+extern int AddToRefresh (XtermWidget /* xw */);
+extern int ClearInLine (XtermWidget /* xw */, int /* row */, int /* col */, unsigned /* len */);
+extern int HandleExposure (XtermWidget /* xw */, XEvent * /* event */);
+extern int drawXtermText (XtermWidget /* xw */, unsigned /* flags */, GC /* gc */, int /* x */, int /* y */, int /* chrset */, IChar * /* text */, Cardinal /* len */, int /* on_wide */);
+extern void ChangeColors (XtermWidget  /* xw */, ScrnColors * /* pNew */);
+extern void ClearRight (XtermWidget /* xw */, int /* n */);
+extern void ClearScreen (XtermWidget /* xw */);
+extern void DeleteChar (XtermWidget /* xw */, unsigned /* n */);
+extern void DeleteLine (XtermWidget /* xw */, int /* n */);
+extern void FlushScroll (XtermWidget /* xw */);
+extern void GetColors (XtermWidget  /* xw */, ScrnColors * /* pColors */);
+extern void InsertChar (XtermWidget /* xw */, unsigned /* n */);
+extern void InsertLine (XtermWidget /* xw */, int  /* n */);
+extern void RevScroll (XtermWidget /* xw */, int  /* amount */);
+extern void ReverseVideo (XtermWidget  /* termw */);
+extern void WriteText (XtermWidget /* xw */, IChar * /* str */, Cardinal /* len */);
+extern void decode_keyboard_type (XtermWidget /* xw */, struct XTERM_RESOURCE * /* rp */);
+extern void decode_wcwidth (XtermWidget  /* xw */);
+extern void do_erase_display (XtermWidget /* xw */, int  /* param */, int  /* mode */);
+extern void do_erase_line (XtermWidget /* xw */, int  /* param */, int  /* mode */);
+extern void getXtermSizeHints (XtermWidget /* xw */);
+extern void init_keyboard_type (XtermWidget /* xw */, xtermKeyboardType /* type */, Bool  /* set */);
+extern void recolor_cursor (TScreen * /* screen */, Cursor  /* cursor */, unsigned long  /* fg */, unsigned long  /* bg */);
+extern void resetXtermGC (XtermWidget /* xw */, unsigned  /* flags */, Bool  /* hilite */);
+extern void scrolling_copy_area (XtermWidget /* xw */, int  /* firstline */, int  /* nlines */, int  /* amount */);
+extern void set_keyboard_type (XtermWidget /* xw */, xtermKeyboardType  /* type */, Bool  /* set */);
+extern void toggle_keyboard_type (XtermWidget /* xw */, xtermKeyboardType  /* type */);
+extern void update_keyboard_type (void);
+extern void xtermClear (XtermWidget /* xw */);
+extern void xtermRepaint (XtermWidget /* xw */);
+extern void xtermScroll (XtermWidget /* xw */, int /* amount */);
+extern void xtermSizeHints (XtermWidget  /* xw */, int /* scrollbarWidth */);
+
+#if OPT_ISO_COLORS
+
+extern unsigned extract_fg (XtermWidget /* xw */, unsigned  /* color */, unsigned  /* flags */);
+extern unsigned extract_bg (XtermWidget /* xw */, unsigned  /* color */, unsigned  /* flags */);
+extern CellColor makeColorPair (int  /* fg */, int  /* bg */);
+extern void ClearCurBackground (XtermWidget /* xw */, int  /* top */, int  /* left */, unsigned  /* height */, unsigned  /* width */);
+
+#define xtermColorPair(xw) makeColorPair(xw->sgr_foreground, xw->sgr_background)
+
+#define getXtermForeground(xw, flags, color) \
+       (((flags) & FG_COLOR) && ((int)(color) >= 0 && (color) < MAXCOLORS) \
+                       ? GET_COLOR_RES(xw, TScreenOf(xw)->Acolors[color]) \
+                       : T_COLOR(TScreenOf(xw), TEXT_FG))
+
+#define getXtermBackground(xw, flags, color) \
+       (((flags) & BG_COLOR) && ((int)(color) >= 0 && (color) < MAXCOLORS) \
+                       ? GET_COLOR_RES(xw, TScreenOf(xw)->Acolors[color]) \
+                       : T_COLOR(TScreenOf(xw), TEXT_BG))
+
+#if OPT_COLOR_RES
+#define GET_COLOR_RES(xw, res) xtermGetColorRes(xw, &(res))
+#define SET_COLOR_RES(res,color) (res)->value = color
+#define EQL_COLOR_RES(res,color) (res)->value == color
+#define T_COLOR(v,n) (v)->Tcolors[n].value
+extern Pixel xtermGetColorRes(XtermWidget /* xw */, ColorRes * /* res */);
+#else
+#define GET_COLOR_RES(xw, res) res
+#define SET_COLOR_RES(res,color) *res = color
+#define EQL_COLOR_RES(res,color) *res == color
+#define T_COLOR(v,n) (v)->Tcolors[n]
+#endif
+
+#define ExtractForeground(color) (unsigned) GetCellColorFG(color)
+#define ExtractBackground(color) (unsigned) GetCellColorBG(color)
+
+#define MapToColorMode(fg, screen, flags) \
+       (((screen)->colorBLMode && ((flags) & BLINK)) \
+        ? COLOR_BL \
+        : (((screen)->colorULMode && ((flags) & UNDERLINE)) \
+           ? COLOR_UL \
+           : (((screen)->colorBDMode && ((flags) & BOLD)) \
+              ? COLOR_BD \
+              : fg)))
+
+#define checkVeryBoldAttr(flags, fg, code, attr) \
+       if ((flags & FG_COLOR) != 0 \
+        && (screen->veryBoldColors & attr) == 0 \
+        && (flags & attr) != 0 \
+        && (fg == code)) \
+                UIntClr(flags, attr)
+
+#define checkVeryBoldColors(flags, fg) \
+       checkVeryBoldAttr(flags, fg, COLOR_RV, INVERSE); \
+       checkVeryBoldAttr(flags, fg, COLOR_UL, UNDERLINE); \
+       checkVeryBoldAttr(flags, fg, COLOR_BD, BOLD); \
+       checkVeryBoldAttr(flags, fg, COLOR_BL, BLINK)
+
+#else /* !OPT_ISO_COLORS */
+
+#define MapToColorMode(fg, screen, flags) fg
+
+#define ClearDFtBackground(xw, top, left, height, width) \
+       ClearCurBackground(xw, top, left, height, width)
+
+#define ClearCurBackground(xw, top, left, height, width) \
+       XClearArea (TScreenOf(xw)->display, VWindow(TScreenOf(xw)), \
+               left, top, width, height, False)
+
+#define extract_fg(xw, color, flags) (xw)->cur_foreground
+#define extract_bg(xw, color, flags) (xw)->cur_background
+
+               /* FIXME: Reverse-Video? */
+#define T_COLOR(v,n) (v)->Tcolors[n]
+#define getXtermBackground(xw, flags, color) T_COLOR(TScreenOf(xw), TEXT_BG)
+#define getXtermForeground(xw, flags, color) T_COLOR(TScreenOf(xw), TEXT_FG)
+#define makeColorPair(fg, bg) 0
+#define xtermColorPair(xw) 0
+
+#define checkVeryBoldColors(flags, fg) /* nothing */
+
+#endif /* OPT_ISO_COLORS */
+
+#define XTERM_CELL(row,col)    getXtermCell(screen,     ROW2INX(screen, row), col)
+
+extern unsigned getXtermCell (TScreen * /* screen */, int  /* row */, int  /* col */);
+extern void putXtermCell (TScreen * /* screen */, int  /* row */, int  /* col */, int  /* ch */);
+
+#if OPT_HIGHLIGHT_COLOR
+#define isNotForeground(xw, fg, bg, sel) \
+               (Boolean) ((sel) != T_COLOR(TScreenOf(xw), TEXT_FG) \
+                          && (sel) != (fg) \
+                          && (sel) != (bg) \
+                          && (sel) != (xw)->dft_foreground)
+#define isNotBackground(xw, fg, bg, sel) \
+               (Boolean) ((sel) != T_COLOR(TScreenOf(xw), TEXT_BG) \
+                          && (sel) != (fg) \
+                          && (sel) != (bg) \
+                          && (sel) != (xw)->dft_background)
+#endif
+
+#if OPT_WIDE_CHARS
+extern Boolean isWideControl(unsigned /* ch */);
+extern int DamagedCells(TScreen * /* screen */, unsigned /* n */, int * /* klp */, int * /* krp */, int /* row */, int /* col */);
+extern int DamagedCurCells(TScreen * /* screen */, unsigned /* n */, int * /* klp */, int * /* krp */);
+extern unsigned AsciiEquivs(unsigned /* ch */);
+extern void addXtermCombining (TScreen * /* screen */, int  /* row */, int  /* col */, unsigned  /* ch */);
+extern void allocXtermChars(ScrnPtr * /* buffer */, Cardinal /* length */);
+#endif
+
+#if OPT_XMC_GLITCH
+extern void Mark_XMC (XtermWidget /* xw */, int  /* param */);
+extern void Jump_XMC (XtermWidget /* xw */);
+extern void Resolve_XMC (XtermWidget /* xw */);
+#endif
+
+#if OPT_WIDE_CHARS
+unsigned visual_width(IChar * /* str */, Cardinal  /* len */);
+#else
+#define visual_width(a, b) (b)
+#endif
+
+#define BtoS(b)    (((b) == Maybe) ? "maybe" : ((b) ? "on" : "off"))
+#define NonNull(s) ((s) ? (s) : "<null>")
+
+#define UIntSet(dst,bits) dst = dst | (unsigned) (bits)
+#define UIntClr(dst,bits) dst = dst & (unsigned) ~(bits)
+
+#ifdef __cplusplus
+       }
+#endif
+/* *INDENT-ON* */
+
+#endif /* included_xterm_h */
diff --git a/xterm.log.html b/xterm.log.html
new file mode 100644 (file)
index 0000000..38e2011
--- /dev/null
@@ -0,0 +1,8998 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!--
+ *****************************************************************************
+ * this file is part of xterm                                                *
+ *                                                                           *
+ * Copyright 1997-2010,2011 by Thomas E. Dickey                              *
+ *                                                                           *
+ * All Rights Reserved                                                       *
+ *                                                                           *
+ * Permission is hereby granted, free of charge, to any person obtaining a   *
+ * copy of this software and associated documentation files (the             *
+ * "Software"), to deal in the Software without restriction, including       *
+ * without limitation the rights to use, copy, modify, merge, publish,       *
+ * distribute, sublicense, and/or sell copies of the Software, and to        *
+ * permit persons to whom the Software is furnished to do so, subject to     *
+ * the following conditions:                                                 *
+ *                                                                           *
+ * The above copyright notice and this permission notice shall be included   *
+ * in all copies or substantial portions of the Software.                    *
+ *                                                                           *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS   *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF                *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.    *
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY  *
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,      *
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE         *
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                    *
+ *                                                                           *
+ * Except as contained in this notice, the name(s) of the above copyright    *
+ * holders shall not be used in advertising or otherwise to promote the      *
+ * sale, use or other dealings in this Software without prior written        *
+ * authorization.                                                            *
+ *****************************************************************************
+  $XTermId: xterm.log.html,v 1.1009 2011/02/10 09:36:17 tom Exp $
+  -->
+<HTML>
+<HEAD>
+<TITLE>XTERM - Change Log</TITLE>
+<LINK REV=MADE HREF="mailto:dickey@invisible-island.net">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+</HEAD>
+<BODY>
+<HR>
+Copyright &copy; 1997-2009,2010 by <A
+HREF="mailto:dickey@invisible-island.net">Thomas E. Dickey</A>
+<HR>
+<H1>Contents</H1>
+This file contains a list of the changes that I have made for xterm,
+from the notes that I add when submitting a patch.
+<P>
+You should note that other changes have been made as well, by other people,
+to fix bugs and correct ifdef's for portability.
+Most of these are summarized in the XFree86 CHANGELOG
+(found in the unbundled tree, xc/programs/Xserver/hw/xfree86).
+<a href="http://invisible-island.net/xterm/xterm.log.html">Here</a>
+is the latest version of this file.
+
+<UL>
+<LI><A HREF="#xterm_268">Patch #268 - 2011/02/10</A>
+<LI><A HREF="#xterm_267">Patch #267 - 2010/11/20</A>
+<LI><A HREF="#xterm_266">Patch #266 - 2010/10/24</A>
+<LI><A HREF="#xterm_265">Patch #265 - 2010/10/22</A>
+<LI><A HREF="#xterm_264">Patch #264 - 2010/10/14</A>
+<LI><A HREF="#xterm_263">Patch #263 - 2010/10/13</A>
+<LI><A HREF="#xterm_262">Patch #262 - 2010/8/30</A>
+<LI><A HREF="#xterm_261">Patch #261 - 2010/6/28</A>
+<LI><A HREF="#xterm_260">Patch #260 - 2010/6/20</A>
+<LI><A HREF="#xterm_259">Patch #259 - 2010/6/5</A>
+<LI><A HREF="#xterm_258">Patch #258 - 2010/5/1</A>
+<LI><A HREF="#xterm_257">Patch #257 - 2010/4/22</A>
+<LI><A HREF="#xterm_256">Patch #256 - 2010/3/6</A>
+<LI><A HREF="#xterm_255">Patch #255 - 2010/1/21</A>
+<LI><A HREF="#xterm_254">Patch #254 - 2010/1/6</A>
+<LI><A HREF="#xterm_253">Patch #253 - 2009/12/10</A>
+<LI><A HREF="#xterm_252">Patch #252 - 2009/12/7</A>
+<LI><A HREF="#xterm_251">Patch #251 - 2009/11/11</A>
+<LI><A HREF="#xterm_250">Patch #250 - 2009/10/13</A>
+<LI><A HREF="#xterm_249">Patch #249 - 2009/10/1</A>
+<LI><A HREF="#xterm_248">Patch #248 - 2009/9/11</A>
+<LI><A HREF="#xterm_247">Patch #247 - 2009/8/30</A>
+<LI><A HREF="#xterm_246">Patch #246 - 2009/8/16</A>
+<LI><A HREF="#xterm_245">Patch #245 - 2009/8/12</A>
+<LI><A HREF="#xterm_244">Patch #244 - 2009/8/9</A>
+<LI><A HREF="#xterm_243">Patch #243 - 2009/3/28</A>
+<LI><A HREF="#xterm_242">Patch #242 - 2009/2/15</A>
+<LI><A HREF="#xterm_241">Patch #241 - 2009/1/26</A>
+<LI><A HREF="#xterm_240">Patch #240 - 2009/1/25</A>
+<LI><A HREF="#xterm_239">Patch #239 - 2009/1/8</A>
+<LI><A HREF="#xterm_238">Patch #238 - 2008/12/30</A>
+<LI><A HREF="#xterm_237">Patch #237 - 2008/09/14</A>
+<LI><A HREF="#xterm_236">Patch #236 - 2008/07/27</A>
+<LI><A HREF="#xterm_235">Patch #235 - 2008/04/20</A>
+<LI><A HREF="#xterm_234">Patch #234 - 2008/03/02</A>
+<LI><A HREF="#xterm_233">Patch #233 - 2008/02/24</A>
+<LI><A HREF="#xterm_232">Patch #232 - 2008/01/30</A>
+<LI><A HREF="#xterm_231">Patch #231 - 2008/01/05</A>
+<LI><A HREF="#xterm_230">Patch #230 - 2007/12/31</A>
+<LI><A HREF="#xterm_229">Patch #229 - 2007/8/12</A>
+<LI><A HREF="#xterm_228">Patch #228 - 2007/7/22</A>
+<LI><A HREF="#xterm_227">Patch #227 - 2007/6/27</A>
+<LI><A HREF="#xterm_226">Patch #226 - 2007/6/17</A>
+<LI><A HREF="#xterm_225">Patch #225 - 2007/3/24</A>
+<LI><A HREF="#xterm_224">Patch #224 - 2007/2/11</A>
+<LI><A HREF="#xterm_223">Patch #223 - 2006/11/30</A>
+<LI><A HREF="#xterm_222">Patch #222 - 2006/10/17</A>
+<LI><A HREF="#xterm_221">Patch #221 - 2006/10/1</A>
+<LI><A HREF="#xterm_220">Patch #220 - 2006/9/10</A>
+<LI><A HREF="#xterm_219">Patch #219 - 2006/9/4</A>
+<LI><A HREF="#xterm_218">Patch #218 - 2006/8/27</A>
+<LI><A HREF="#xterm_217">Patch #217 - 2006/8/20</A>
+<LI><A HREF="#xterm_216">Patch #216 - 2006/8/3</A>
+<LI><A HREF="#xterm_215">Patch #215 - 2006/6/19 - XFree86 4.6.99.2</A>
+<LI><A HREF="#xterm_214">Patch #214 - 2006/6/18 - XFree86 4.6.99.2</A>
+<LI><A HREF="#xterm_213">Patch #213 - 2006/4/30 - XFree86 4.5.99.905</A>
+<LI><A HREF="#xterm_212">Patch #212 - 2006/4/9 - XFree86 4.5.99.904</A>
+<LI><A HREF="#xterm_211">Patch #211 - 2006/3/19 - XFree86 4.5.99.902</A>
+<LI><A HREF="#xterm_210">Patch #210 - 2006/3/12 - XFree86 4.5.99.902</A>
+<LI><A HREF="#xterm_209">Patch #209 - 2006/2/12 - XFree86 4.5.99.22</A>
+<LI><A HREF="#xterm_208">Patch #208 - 2006/1/3 - XFree86 4.5.99.19</A>
+<LI><A HREF="#xterm_207">Patch #207 - 2005/11/13 - XFree86 4.5.99.16</A>
+<LI><A HREF="#xterm_206">Patch #206 - 2005/11/3 - XFree86 4.5.99.15</A>
+<LI><A HREF="#xterm_205">Patch #205 - 2005/9/18 - XFree86 4.5.99.12</A>
+<LI><A HREF="#xterm_204">Patch #204 - 2005/8/4 - XFree86 4.5.99.9</A>
+<LI><A HREF="#xterm_203">Patch #203 - 2005/7/6 - XFree86 4.5.99.7</A>
+<LI><A HREF="#xterm_202">Patch #202 - 2005/5/2 - XFree86 4.5.99.3</A>
+<LI><A HREF="#xterm_201">Patch #201 - 2005/4/21 - XFree86 4.5.99.2</A>
+<LI><A HREF="#xterm_200">Patch #200 - 2005/2/6 - XFree86 4.4.99.23</A>
+<LI><A HREF="#xterm_199">Patch #199 - 2005/1/17 - XFree86 4.4.99.22</A>
+<LI><A HREF="#xterm_198">Patch #198 - 2005/1/13 - XFree86 4.4.99.21</A>
+<LI><A HREF="#xterm_197">Patch #197 - 2004/11/30 - XFree86 4.4.99.19</A>
+<LI><A HREF="#xterm_196">Patch #196 - 2004/8/15 - XFree86 4.4.99.12</A>
+<LI><A HREF="#xterm_195">Patch #195 - 2004/8/8 - XFree86 4.4.99.11</A>
+<LI><A HREF="#xterm_194">Patch #194 - 2004/7/27 - XFree86 4.4.99.11</A>
+<LI><A HREF="#xterm_193">Patch #193 - 2004/7/19 - XFree86 4.4.99.10</A>
+<LI><A HREF="#xterm_192">Patch #192 - 2004/7/12 - XFree86 4.4.99.9</A>
+<LI><A HREF="#xterm_191">Patch #191 - 2004/6/6 - XFree86 4.4.99.7</A>
+<LI><A HREF="#xterm_190">Patch #190 - 2004/5/25 - XFree86 4.4.99.6</A>
+<LI><A HREF="#xterm_189">Patch #189 - 2004/5/16 - XFree86 4.4.99.6</A>
+<LI><A HREF="#xterm_188">Patch #188 - 2004/5/12 - XFree86 4.4.99.6</A>
+<LI><A HREF="#xterm_187">Patch #187 - 2004/4/27 - XFree86 4.4.99.4</A>
+<LI><A HREF="#xterm_186">Patch #186 - 2004/4/18 - XFree86 4.4.99.4</A>
+<LI><A HREF="#xterm_185">Patch #185 - 2004/3/3 - XFree86 4.4</A>
+<LI><A HREF="#xterm_184">Patch #184 - 2003/12/31 - XFree86 4.3.99.903</A>
+<LI><A HREF="#xterm_183">Patch #183 - 2003/12/26 - XFree86 4.3.99.903</A>
+<LI><A HREF="#xterm_182">Patch #182 - 2003/12/2 - XFree86 4.3.99.901</A>
+<LI><A HREF="#xterm_181">Patch #181 - 2003/10/26 - XFree86 4.3.99.15</A>
+<LI><A HREF="#xterm_180">Patch #180 - 2003/10/12 - XFree86 4.3.99.15</A>
+<LI><A HREF="#xterm_179">Patch #179 - 2003/5/21 - XFree86 4.3.99.5</A>
+<LI><A HREF="#xterm_178">Patch #178 - 2003/5/18 - XFree86 4.3.99.5</A>
+<LI><A HREF="#xterm_177">Patch #177 - 2003/3/23 - XFree86 4.3.0</A>
+<LI><A HREF="#xterm_176">Patch #176 - 2003/3/22 - XFree86 4.3.0</A>
+<LI><A HREF="#xterm_175">Patch #175 - 2003/3/9 - XFree86 4.3.0</A>
+<LI><A HREF="#xterm_174">Patch #174 - 2003/2/25 - XFree86 4.2.99.903</A>
+<LI><A HREF="#xterm_173">Patch #173 - 2003/2/6 - XFree86 4.2.99.902</A>
+<LI><A HREF="#xterm_172">Patch #172 - 2002/12/27 - XFree86 4.2.99.3</A>
+<LI><A HREF="#xterm_171">Patch #171 - 2002/12/12 - XFree86 4.2.99.3</A>
+<LI><A HREF="#xterm_170">Patch #170 - 2002/10/13 - XFree86 4.2.1</A>
+<LI><A HREF="#xterm_169">Patch #169 - 2002/10/5 - XFree86 4.2.1</A>
+<LI><A HREF="#xterm_168">Patch #168 - 2002/9/29 - XFree86 4.2.1</A>
+<LI><A HREF="#xterm_167">Patch #167 - 2002/8/24 - XFree86 4.2.0</A>
+<LI><A HREF="#xterm_166">Patch #166 - 2002/3/25 - XFree86 4.2.0</A>
+<LI><A HREF="#xterm_165">Patch #165 - 2002/1/5 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_164">Patch #164 - 2001/11/13 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_163">Patch #163 - 2001/11/04 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_162">Patch #162 - 2001/10/23 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_161">Patch #161 - 2001/10/10 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_160">Patch #160 - 2001/10/7 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_159">Patch #159 - 2001/9/19 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_158">Patch #158 - 2001/9/8 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_157">Patch #157 - 2001/6/18 - XFree86 4.1.0</A>
+<LI><A HREF="#xterm_156">Patch #156 - 2001/4/28 - XFree86 4.0.3</A>
+<LI><A HREF="#xterm_155">Patch #155 - 2001/4/20 - XFree86 4.0.3</A>
+<LI><A HREF="#xterm_154">Patch #154 - 2001/4/11 - XFree86 4.0.3</A>
+<LI><A HREF="#xterm_153">Patch #153 - 2001/3/29 - XFree86 4.0.3</A>
+<LI><A HREF="#xterm_152">Patch #152 - 2001/3/13 - XFree86 4.0.2</A>
+<LI><A HREF="#xterm_151">Patch #151 - 2001/3/10 - XFree86 4.0.2</A>
+<LI><A HREF="#xterm_150">Patch #150 - 2000/12/29 - XFree86 4.0.2</A>
+<LI><A HREF="#xterm_149">Patch #149 - 2000/12/6 - XFree86 4.0.1h</A>
+<LI><A HREF="#xterm_148">Patch #148 - 2000/10/31 - XFree86 4.0.1d</A>
+<LI><A HREF="#xterm_147">Patch #147 - 2000/10/26 - XFree86 4.0.1c</A>
+<LI><A HREF="#xterm_146">Patch #146 - 2000/9/12 - XFree86 4.0.1c</A>
+<LI><A HREF="#xterm_145">Patch #145 - 2000/9/11 - XFree86 4.0.1c</A>
+<LI><A HREF="#xterm_144">Patch #144 - 2000/8/23 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_143">Patch #143 - 2000/8/19 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_142">Patch #142 - 2000/8/18 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_141">Patch #141 - 2000/8/14 - XFree86 4.0.1b</A>
+<LI><A HREF="#xterm_140">Patch #140 - 2000/7/23 - XFree86 4.0.1</A>
+<LI><A HREF="#xterm_139">Patch #139 - 2000/6/17 - XFree86 4.0d</A>
+<LI><A HREF="#xterm_138">Patch #138 - 2000/6/15 - XFree86 4.0c</A>
+<LI><A HREF="#xterm_137">Patch #137 - 2000/6/10 - XFree86 4.0b</A>
+<LI><A HREF="#xterm_136">Patch #136 - 2000/6/3 - XFree86 4.0b</A>
+<LI><A HREF="#xterm_135">Patch #135 - 2000/5/29 - XFree86 4.0b</A>
+<LI><A HREF="#xterm_134">Patch #134 - 2000/5/28 - XFree86 4.0b</A>
+<LI><A HREF="#xterm_133">Patch #133 - 2000/5/2 - XFree86 4.0a</A>
+<LI><A HREF="#xterm_132">Patch #132 - 2000/4/11 - XFree86 4.0a</A>
+<LI><A HREF="#xterm_131">Patch #131 - 2000/3/3 - XFree86 3.9.18b</A>
+<LI><A HREF="#xterm_130">Patch #130 - 2000/3/1 - XFree86 3.9.18a</A>
+<LI><A HREF="#xterm_129">Patch #129 - 2000/2/26 - XFree86 3.9.18a</A>
+<LI><A HREF="#xterm_128">Patch #128 - 2000/2/17 - XFree86 3.9.18</A>
+<LI><A HREF="#xterm_127">Patch #127 - 2000/2/12 - XFree86 3.9.17e</A>
+<LI><A HREF="#xterm_126">Patch #126 - 2000/2/8 - XFree86 3.9.17c</A>
+<LI><A HREF="#xterm_125">Patch #125 - 2000/1/31 - XFree86 3.9.17c</A>
+<LI><A HREF="#xterm_124">Patch #124 - 2000/1/27 - XFree86 3.9.17b</A>
+<LI><A HREF="#xterm_123">Patch #123 - 2000/1/22 - XFree86 3.9.17a</A>
+<LI><A HREF="#xterm_122">Patch #122 - 1999/12/28 - XFree86 3.9.16f</A>
+<LI><A HREF="#xterm_121">Patch #121 - 1999/11/14 - XFree86 3.9.16c</A>
+<LI><A HREF="#xterm_120">Patch #120 - 1999/10/28 - XFree86 3.9.16c</A>
+<LI><A HREF="#xterm_119">Patch #119 - 1999/10/16 - XFree86 3.9.16c</A>
+<LI><A HREF="#xterm_118">Patch #118 - 1999/10/5 - XFree86 3.9.16b</A>
+<LI><A HREF="#xterm_117">Patch #117 - 1999/9/29 - XFree86 3.9.16b</A>
+<LI><A HREF="#xterm_116">Patch #116 - 1999/9/25 - XFree86 3.9.16a</A>
+<LI><A HREF="#xterm_115">Patch #115 - 1999/9/18 - XFree86 3.9.16a</A>
+<LI><A HREF="#xterm_114">Patch #114 - 1999/9/15 - XFree86 3.9.16</A>
+<LI><A HREF="#xterm_113">Patch #113 - 1999/8/15 - XFree86 3.9.15b</A>
+<LI><A HREF="#xterm_112">Patch #112 - 1999/7/17 - XFree86 3.9Pw</A>
+<LI><A HREF="#xterm_111">Patch #111 - 1999/7/10 - XFree86 3.9Pw</A>
+<LI><A HREF="#xterm_110">Patch #110 - 1999/6/29 - XFree86 3.9Pu</A>
+<LI><A HREF="#xterm_109">Patch #109 - 1999/6/23 - XFree86 3.9Pt</A>
+<LI><A HREF="#xterm_108">Patch #108 - 1999/6/19 - XFree86 3.9Ps</A>
+<LI><A HREF="#xterm_107">Patch #107 - 1999/6/12 - XFree86 3.9Pq</A>
+<LI><A HREF="#xterm_106">Patch #106 - 1999/6/9 - XFree86 3.9Pq</A>
+<LI><A HREF="#xterm_105">Patch #105 - 1999/6/5 - XFree86 3.9Pp</A>
+<LI><A HREF="#xterm_104">Patch #104 - 1999/5/30 - XFree86 3.9Pn</A>
+<LI><A HREF="#xterm_103">Patch #103 - 1999/5/14 - XFree86 3.9Pm</A>
+<LI><A HREF="#xterm_102">Patch #102 - 1999/5/12 - XFree86 3.9Pm</A>
+<LI><A HREF="#xterm_101">Patch #101 - 1999/5/10 - XFree86 3.9Pm</A>
+<LI><A HREF="#xterm_100">Patch #100 - 1999/5/3 - XFree86 3.9Pl</A>
+<LI><A HREF="#xterm_99">Patch #99 - 1999/5/2 - XFree86 3.9Pk</A>
+<LI><A HREF="#xterm_98">Patch #98 - 1999/4/26 - XFree86 3.9Pk</A>
+<LI><A HREF="#xterm_97">Patch #97 - 1999/4/25 - XFree86 3.9Pk</A>
+<LI><A HREF="#xterm_96">Patch #96 - 1999/4/19 - XFree86 3.9Pj</A>
+<LI><A HREF="#xterm_95">Patch #95 - 1999/4/5 - XFree86 3.9Ph</A>
+<LI><A HREF="#xterm_94">Patch #94 - 1999/3/27 - XFree86 3.9Pf</A>
+<LI><A HREF="#xterm_93">Patch #93 - 1999/3/14 - XFree86 3.9Pd</A>
+<LI><A HREF="#xterm_92">Patch #92 - 1999/2/5 - XFree86 3.9Nz</A>
+<LI><A HREF="#xterm_91">Patch #91 - 1999/1/21 - XFree86 3.9Nw</A>
+<LI><A HREF="#xterm_90">Patch #90 - 1998/12/13 - XFree86 3.9Nq</A>
+<LI><A HREF="#xterm_89">Patch #89 - 1998/11/20 - XFree86 3.9Nm</A>
+<LI><A HREF="#xterm_88">Patch #88 - 1998/10/31 - XFree86 3.9Nk and 3.3.2h</A>
+<LI><A HREF="#xterm_87">Patch #87 - 1998/10/21 - XFree86 3.9Nj and 3.3.2f</A>
+<LI><A HREF="#xterm_86">Patch #86 - 1998/10/14 - XFree86 3.9Nj and 3.3.2e</A>
+<LI><A HREF="#xterm_85">Patch #85 - 1998/10/12 - XFree86 3.9Nj and 3.3.2e</A>
+<LI><A HREF="#xterm_84">Patch #84 - 1998/10/9 - XFree86 3.9Ni and 3.3.2e</A>
+<LI><A HREF="#sync_83">Resync #83 - 1998/10/7 - XFree86 3.3.2e</A>
+<LI><A HREF="#xterm_83">Patch #83 - 1998/8/25 - XFree86 3.9Nb</A>
+<LI><A HREF="#xterm_82">Patch #82 - 1998/7/15 - XFree86 3.9Aj</A>
+<LI><A HREF="#xterm_81">Patch #81 - 1998/7/14 - XFree86 3.9Aj</A>
+<LI><A HREF="#xterm_80">Patch #80 - 1998/6/29 - XFree86 3.9Ai</A>
+<LI><A HREF="#xterm_79">Patch #79 - 1998/6/28 - XFree86 3.9Ai</A>
+<LI><A HREF="#xterm_78">Patch #78 - 1998/6/3 - XFree86 3.9Ah and 3.3.2</A>
+<LI><A HREF="#xterm_77">Patch #77 - 1998/5/26 - XFree86 3.9Ah and 3.3.2</A>
+<LI><A HREF="#xterm_76">Patch #76 - 1998/5/8 - XFree86 3.9Ah and 3.3.2</A>
+<LI><A HREF="#xterm_75">Patch #75 - 1998/5/7 - XFree86 3.9Ah and 3.3.2</A>
+<LI><A HREF="#xterm_74">Patch #74 - 1998/4/27 - XFree86 3.9Ag and 3.3.2</A>
+<LI><A HREF="#xterm_73">Patch #73 - 1998/4/25 - XFree86 3.9Ag and 3.3.2</A>
+<LI><A HREF="#xterm_72">Patch #72 - 1998/4/17 - XFree86 3.9Ag and 3.3.2</A>
+<LI><A HREF="#xterm_71">Patch #71 - 1998/4/12 - XFree86 3.9Ag and 3.3.2</A>
+<LI><A HREF="#xterm_70">Patch #70 - 1998/3/29 - XFree86 3.9Af and 3.3.2</A>
+<LI><A HREF="#xterm_69">Patch #69 - 1998/3/16 - XFree86 3.9Ad and 3.3.2</A>
+<LI><A HREF="#xterm_68">Patch #68 - 1998/3/4 - XFree86 3.9Ad and 3.3.1z</A>
+<LI><A HREF="#xterm_67">Patch #67 - 1998/2/23 - XFree86 3.9Ad and 3.3.1e</A>
+<LI><A HREF="#xterm_66">Patch #66 - 1998/2/16 - XFree86 3.9Ad and 3.3.1d</A>
+<LI><A HREF="#xterm_65">Patch #65 - 1998/2/14 - XFree86 3.9Ad and 3.3.1c</A>
+<LI><A HREF="#xterm_64">Patch #64 - 1998/2/8 - XFree86 3.9Ad</A>
+<LI><A HREF="#xterm_63">Patch #63 - 1998/2/5 - XFree86 3.9Ad</A>
+<LI><A HREF="#xterm_62">Patch #62 - 1998/1/23 - XFree86 3.9Ac</A>
+<LI><A HREF="#xterm_61">Patch #61 - 1998/1/17 - XFree86 3.9Ac</A>
+<LI><A HREF="#xterm_60">Patch #60 - 1998/1/10 - XFree86 3.9Ab</A>
+<LI><A HREF="#xterm_59">Patch #59 - 1998/1/5 - XFree86 3.9Ab</A>
+<LI><A HREF="#xterm_58">Patch #58 - 1998/1/3 - XFree86 3.9Ab</A>
+<LI><A HREF="#xterm_57">Patch #57 - 1997/12/26 - XFree86 3.9Aa</A>
+<LI><A HREF="#xterm_56">Patch #56 - 1997/11/28 - XFree86 3.9x</A>
+<LI><A HREF="#xterm_55">Patch #55 - 1997/11/25 - XFree86 3.9x</A>
+<LI><A HREF="#xterm_54">Patch #54 - 1997/10/17 - XFree86 3.9s</A>
+<LI><A HREF="#xterm_53">Patch #53 - 1997/10/12 - XFree86 3.9r</A>
+<LI><A HREF="#xterm_52">Patch #52 - 1997/9/29 - XFree86 3.9q</A>
+<LI><A HREF="#xterm_51">Patch #51 - 1997/9/15 - XFree86 3.9p</A>
+<LI><A HREF="#xterm_50">Patch #50 - 1997/8/22 - XFree86 3.9m</A>
+<LI><A HREF="#xterm_49">Patch #49 - 1997/8/10 - XFree86 3.9k</A>
+<LI><A HREF="#xterm_48">Patch #48 - 1997/7/26 - XFree86 3.9j</A>
+<LI><A HREF="#xterm_47">Patch #47 - 1997/7/13 - XFree86 3.9i</A>
+<LI><A HREF="#xterm_46">Patch #46 - 1997/7/4 - XFree86 3.9h</A>
+<LI><A HREF="#xterm_45">Patch #45 - 1997/7/2 - XFree86 3.9h</A>
+<LI><A HREF="#xterm_44">Patch #44 - 1997/6/22 - XFree86 3.9g</A>
+<LI><A HREF="#xterm_43">Patch #43 - 1997/6/10 - XFree86 3.9d</A>
+<LI><A HREF="#xterm_42">Patch #42 - 1997/6/8 - XFree86 3.2Xl</A>
+<LI><A HREF="#xterm_41">Patch #41 - 1997/5/28 - XFree86 3.2Xl</A>
+<LI><A HREF="#xterm_40">Patch #40 - 1997/5/26 - XFree86 3.2Xl</A>
+<LI><A HREF="#xterm_39">Patch #39 - 1997/5/24 - XFree86 3.2Xl</A>
+<LI><A HREF="#xterm_38">Patch #38 - 1997/5/22 - XFree86 3.2Xh</A>
+<LI><A HREF="#xterm_37">Patch #37 - 1997/5/7 - XFree86 3.9a</A>
+<LI><A HREF="#xterm_36">Patch #36 - 1997/1/16 - XFree86 3.2r</A>
+<LI><A HREF="#xterm_35">Patch #35 - 1997/1/7 - XFree86 3.2o</A>
+<LI><A HREF="#xterm_34">Patch #34 - 1997/1/5 - XFree86 3.2o</A>
+<LI><A HREF="#xterm_33">Patch #33 - 1996/11/24 - XFree86 3.2</A>
+<LI><A HREF="#xterm_32">Patch #32 - 1996/11/21 - XFree86 3.2</A>
+<LI><A HREF="#xterm_31">Patch #31 - 1996/11/16 - XFree86 3.2</A>
+<LI><A HREF="#xterm_30">Patch #30 - 1996/11/16 - XFree86 3.2</A>
+<LI><A HREF="#xterm_29">Patch #29 - 1996/9/15 - XFree86 3.1.2Gb</A>
+<LI><A HREF="#xterm_28">Patch #28 - 1996/8/31 - XFree86 3.1.2F</A>
+<LI><A HREF="#xterm_27">Patch #27 - 1996/8/21 - XFree86 3.1.2Ek</A>
+<LI><A HREF="#xterm_26">Patch #26 - 1996/8/20 - XFree86 3.1.2Ei</A>
+<LI><A HREF="#xterm_25">Patch #25 - 1996/8/18 - XFree86 3.1.2Ei</A>
+<LI><A HREF="#xterm_24">Patch #24 - 1996/8/11 - XFree86 3.1.2Ee</A>
+<LI><A HREF="#xterm_23">Patch #23 - 1996/7/31 - XFree86 3.1.2Ec</A>
+<LI><A HREF="#xterm_22">Patch #22 - 1996/7/26 - XFree86 3.1.2Ec</A>
+<LI><A HREF="#xterm_21">Patch #21 - 1996/7/24 - XFree86 3.1.2Ec</A>
+<LI><A HREF="#xterm_20">Patch #20 - 1996/7/24 - XFree86 3.1.2Ec</A>
+<LI><A HREF="#xterm_19">Patch #19 - 1996/7/21 - XFree86 3.1.2Ec</A>
+<LI><A HREF="#xterm_18">Patch #18 - 1996/7/18 - XFree86 3.1.2Ec</A>
+<LI><A HREF="#xterm_17">Patch #17 - 1996/7/2 - XFree86 3.1.2Eb</A>
+<LI><A HREF="#xterm_16">Patch #16 - 1996/6/25 - XFree86 3.1.2Ea</A>
+<LI><A HREF="#xterm_15">Patch #15 - 1996/5/29 - XFree86 3.1.2E</A>
+<LI><A HREF="#xterm_14">Patch #14 - 1996/5/12 - XFree86 3.1.2Dj</A>
+<LI><A HREF="#xterm_13">Patch #13 - 1996/4/23 - XFree86 3.1.2Df</A>
+<LI><A HREF="#xterm_12">Patch #12 - 1996/3/16 - XFree86 3.1.2Dc</A>
+<LI><A HREF="#xterm_11">Patch #11 - 1996/3/5 - XFree86 3.1.2Db</A>
+<LI><A HREF="#xterm_10">Patch #10 - 1996/2/14 - XFree86 3.1.2Cd</A>
+<LI><A HREF="#xterm_09">Patch #9 - 1996/2/10 - XFree86 3.1.2Cb</A>
+<LI><A HREF="#xterm_08">Patch #8 - 1996/2/9 - XFree86 3.1.2Cb</A>
+<LI><A HREF="#xterm_07">Patch #7 - 1996/1/28 - XFree86 3.1.2n</A>
+<LI><A HREF="#xterm_06">Patch #6 - 1996/1/8</A>
+<LI><A HREF="#xterm_05">Patch #5 - 1996/1/7</A>
+<LI><A HREF="#xterm_04">Patch #4 - 1996/1/7</A>
+<LI><A HREF="#xterm_03">Patch #3 - 1996/1/7</A>
+<LI><A HREF="#xterm_02">Patch #2 - 1996/1/7</A>
+<LI><A HREF="#xterm_01">Patch #1 - 1996/1/6</A>
+</UL>
+
+<H1><A NAME="xterm_268">Patch #268 - 2011/02/10</A></H1>
+<ul>
+       <li>fix an inconsistency of the "Enable Reverse Video" checkbox in
+           the VT Options menu.
+           This also removes a special case
+           added in <a href="#xterm_217">patch #217</a>
+           which limited the effect of the <code>reverseVideo</code> resource
+           (Debian #603808).
+
+       <li>amend decoding of misformed UTF-8 sequences to avoid absorbing
+           valid characters as documented in Unicode 6.0 section 3.9
+           (report by Keith Winstein).
+
+       <li>do not set urgency hint when window already has focus
+           (patch by Dimitrios Christidis).
+
+       <li>amend extended mouse-coordinate mode from
+           <a href="#xterm_262">patch #262</a> changes to include
+           the <em>Cb</em> button-code, which also may be greater than 127
+           (report by Ailin Nemui).
+
+       <li>ensure that underline-cursor is visible when an application happens
+           to set the background color (report by Christian Weisgerber).
+
+       <li>add feature for
+           <a href="http://www.davidsimmons.com/soft/xtermhacks/xterm-fullscreen.patch">full-screen toggling</a>
+           using either Alt-Enter
+           or a menu selection
+           (integrated patch by Dave Simmons).
+
+       <li>add missing logic to handle reallocation of FIFO index for the
+           "UTF-8" menu entry (report by David Holland, NetBSD #44344).
+           
+       <li>add makefile rules <code>docs-ctlseqs</code>,
+           <code>docs-xterm</code>, etc.
+
+       <li>correct typo in description of DECRPM in control sequences
+           document (report by Ailin Nemui).
+</ul>
+
+<H1><A NAME="xterm_267">Patch #267 - 2010/11/20</A></H1>
+<ul>
+       <li>minor formatting changes to ctlseqs.ms to simplify a script which
+           extracts the feature information.  See the results in
+<a href="http://invisible-island.net/xterm/xterm.faq.html#compare_versions">Comparing versions, by counting controls</a> in the xterm FAQ.
+
+       <li>add <code>docs-clean</code> makefile rule.
+
+       <li>add <code>copy-selection</code> action (request by 
+           Timo Juhani Lindfors, Debian #588785).
+
+       <li>trim leading/trailing blanks from string used for "Selection"
+           font-menu data.
+
+       <li>trim leading/trailing blanks from color resource values.
+
+       <li>configure script improvements:
+       <ul>
+       <li>add workaround for removal of X11 dependency from Xt's package
+           file (report by Robert Hooker).
+
+       <li>add workaround for removal of fontconfig dependency from Xft's
+           package file (report by Jeremy Huddleston).
+
+       <li>add workaround for removal of Xmu dependency from Xaw's package
+           file (report by Jeremy Huddleston).
+
+       <li>improve workaround in <code>CF_X_TOOLKIT</code> macro,
+           checking for other
+           possible packages where Xt's dependencies may be given.
+
+       <li>prefer <code>${name:=value}</code> to <code>${name-value}</code>,
+           since recent bash changes break legacy support for that feature.
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_266">Patch #266 - 2010/10/24</A></H1>
+<ul>
+       <li>add rpm and dpkg scripts, for testing.
+
+       <li>more fixes for Debian #600707 (report by  Cyril Brulebois).
+</ul>
+
+<H1><A NAME="xterm_265">Patch #265 - 2010/10/22</A></H1>
+<ul>
+       <li>fix a regression in fontname logic from 
+           <a href="#xterm_263">patch #263</a> changes
+           (Debian #600707, reported by Vincent Lefevre).
+
+       <li>revert modification of any-event/any-button protocol from
+           <a href="#xterm_263">patch #263</a> changes.
+           It interferes with selection using a
+           shifted mouse button (reports by Neil Bird, Bram Moolenaar).
+</ul>
+
+<H1><A NAME="xterm_264">Patch #264 - 2010/10/14</A></H1>
+<ul>
+       <li>replace a null-pointer check with check for empty string in
+           <code>xtermOpenFont</code>,
+           to eliminate a warning message from
+           <a href="#xterm_263">patch #263</a> changes.
+
+       <li>build-fix for <a href="#xterm_263">patch #263</a> when toolbar
+           is not configured
+           (patch by Chris Clayton)
+           (reports by Robby Workman,
+           David Wood).
+</ul>
+
+<H1><A NAME="xterm_263">Patch #263 - 2010/10/13</A></H1>
+<ul>
+       <li>corrected initialization of "misc" resource values, to ensure that
+           xterm has allocated a copy of strings which may not have been
+           malloc'd by the X library (Debian #600129).
+
+       <li>modify handling of any-event/any-button mouse protocol; it
+           now is active with any combination of key-modifiers.
+
+       <li>add debugging feature <code>showWrapMarks</code>, which marks
+           lines which xterm knows are wrapped, showing where a double-click
+           will select past the end of a line.
+
+       <li>build-fix to address change in include-guards for
+           <code>Xlib.h</code>
+           in ongoing Xorg edits (patch by Jeremy Huddleston).
+
+       <li>improve <code>pointerMode</code> by continuing to watch for motion
+           events after mouse tracking is disabled if the pointer is hidden
+           (Debian #594856).
+
+       <li>further extend initialization for active-icon font to check if
+           the font was not loaded succesfully,
+           to retry with <code>font1</code>,
+           or as even (if TrueType fonts are used) to use a TrueType font.
+           The retries are to help with cases as in
+           <a href="#xterm_241">patch #241</a> where the bitmap fonts are
+           not available.
+
+       <li>fix special case of active-icon used when TrueType font is
+           specified for the xterm window,
+           from <a href="#xterm_261">patch #261</a> change.
+           In that case, the default font's size was used for layout of the
+           active icon's window (Debian #591265).
+</ul>
+
+<H1><A NAME="xterm_262">Patch #262 - 2010/8/30</A></H1>
+<ul>
+       <li>fix a case where changing the cursor color via escape sequences
+           did not immediately update the screen (report by Andreas Wagner).
+
+       <li>implement ANSI and DEC request-mode control sequences.  The
+           latter includes the xterm-specific private modes such as the
+           mouse mode.  The feature is ifdef'd with the rectangle operations
+           since its decoding overlaps that feature.
+
+       <li>correct typo in ctlseqs.ms for response of OSC 21 (patch by
+           Kevin Schoedel).
+
+       <li>improve discussion of mouse tracking in ctlseqs.ms
+
+       <li>increase an array limit used in reporting mouse events (report
+           by Ryan Johnson).
+
+       <li>add extended mouse-coordinates mode, allowing up to 2015x2015
+           windows, using UTF-8 encoding (patch by Ryan Johnson).
+
+       <li>modify manpage hyphens to conform with
+           <a href="http://lintian.debian.org/tags/hyphen-used-as-minus-sign.html">Debian</a>.
+</ul>
+
+<H1><A NAME="xterm_261">Patch #261 - 2010/6/28</A></H1>
+<ul>
+       <li>fix regression in <code>renderFont</code> logic, from
+           <a href="#xterm_260">patch #260</a> changes
+           (report by Joseph Quinsey).
+</ul>
+
+<H1><A NAME="xterm_260">Patch #260 - 2010/6/20</A></H1>
+<ul>
+       <li>modify <code>plink.sh</code> to work around problem linking to
+           recent PCRE libraries.
+
+       <li>extend <code>renderFont</code> resource to allow deferred switch
+           to TrueType fonts without affecting existing resource settings
+           (Debian #585620).
+
+       <li>modify configure macro CF_X_TOOLKIT to work around omission of
+           ICE library from ".pc" file (report by Miroslav Lichvar).
+
+       <li>change configure script default for <code>--enable-broken-st</code>
+           i.e., the <code>brokenStringTerm</code> feature)
+           to normally enable it.
+           If the corresponding resource is enabled,
+           this feature eliminates an apparent freeze of xterm
+           when sending mis-encoded data to the screen (Debian #584801).
+
+       <li>document in manpage some actions which were overlooked:
+           <ul>
+            <li>readline-button
+            <li>scroll-lock
+            <li>set-8-bit-control
+           </ul>
+
+       <li>undo a change to limit-check in <code>ScrnRefresh</code>
+           in <a href="#xterm_257">patch #257</a>,
+           which broke <code>fastScroll</code> feature
+           (Debian #584841).
+
+       <li>modify handling of
+           <code>brokenLinuxOSC</code> and
+           <code>brokenStringTerm</code>
+           to also sound the bell.
+
+       <li>add control/D and control/Q to controls which will cause early
+           exit from control string per <code>brokenStringTerm</code>
+           resource.
+
+       <li>improve documentation of <code>brokenStringTerm</code> resource
+           in manpage.
+</ul>
+
+<H1><A NAME="xterm_259">Patch #259 - 2010/6/5</A></H1>
+<ul>
+       <li>modify configure check for
+           <a href="http://invisible-island.net/luit/">luit</a> to include new
+           aliases for the program
+           (<code>xterm-filter</code> and
+           <code>bluit</code>).
+
+       <li>add workaround in <code>xtermClearLEDs()</code> to account for
+           Xkb's override, making vttest's LED demo reset the scroll
+           lock.
+
+       <li>filter out client-message events when deciding whether to hide
+           cursor, e.g., when using SCIM
+           (patch/report by anonymous user).
+
+       <li>improve description of <code>-bd</code> option in manpage
+           (report by Guy Daniel Clotilde).
+
+       <li>modify configure checks for PCRE and other libraries to use
+           <code>pkg-config</code>, if available.
+
+       <li>amend change from <a href="#xterm_252">patch #252</a>, to take
+           <code>veryColorColors</code> resource into account when checking
+           <code>colorBDMode</code> resource for TrueType fonts
+           (report by anonymous user).
+
+       <li>add <code>vttests/query-fonts.pl</code> script for
+           demonstrating the <code>OSC&nbsp;50</code> font query.
+
+       <li>improve manpage discussion of Scroll Lock feature.
+
+       <li>improve configure macros CF_GCC_VERSION and CF_GCC_WARNINGS.
+
+       <li>fix warnings for "clang --analyze".
+
+       <li>change default for <code>allowScrollLock</code> resource to
+           <code>false</code>, noting that the supposedly unused key has
+           been useful for various rebindings (Debian #580946).
+</ul>
+
+<H1><A NAME="xterm_258">Patch #258 - 2010/5/1</A></H1>
+<ul>
+       <li>add pointer-checks in <code>ScrnRefresh</code> to fix a case in
+           rapid scrolling where an empty record is fetched from the
+           scrollback FIFO.
+</ul>
+
+<H1><A NAME="xterm_257">Patch #257 - 2010/4/22</A></H1>
+<ul>
+       <li>correct ctlseqs.ms description of OSC 17 and OSC 19
+           (patch by Emanuele Giaquinta).
+
+       <li>corrected logic for <code>menuLocale</code> resource;
+           the <code>setlocale</code> function returns the original locale
+           only when querying.
+
+       <li>improve filtering of translations resource, narrowing the scope
+           of the <code>alwaysUseMods</code> to address only the translations
+           that would cause a key to be sent to the host (report by Andrew
+           Gaylard).
+
+       <li>change default value of <code>menuLocale</code> resource to "C",
+           to work around
+           longstanding <a href="http://invisible-island.net/xterm/xterm.faq.html#slow_menus">Xorg bug</a>.
+
+       <li>modify handling of <code>scrollKey</code> feature to ignore
+           XON/XOFF keys.
+
+       <li>implement scroll-lock feature.
+
+       <li>revise memory allocation in UTF8toLatin1() to fix an out-of-bounds
+           index (Mandriva #54531).
+
+       <li>compute value for first wide-character rather than assuming it is
+           256, fixes problem with <code>-cjk_width</code> introduced in
+           patches
+           <a href="#xterm_242">242</a> and
+           <a href="#xterm_249">249</a>
+           (report by Thomas Wolff).
+
+       <li>improve configure script:
+       <ul>
+           <li>corrected check for <code>_XOPEN_SOURCE</code> for OpenSolaris.
+
+           <li>when possible, add rpath option for libraries in unusual places
+
+           <li>add configure option <code>--disable-rpath-hack</code> to
+               control whether the rpath option can be added.
+       </ul>
+
+       <li>modify <code>AllocateTermColor()</code> to separate initialization
+           from control sequences,
+           fixing problem from <a href="#xterm_254">patch #254</a> changes
+           where enabling <code>allowSendEvents</code>
+           resource prevents setting cursor color on command-line
+           (Debian #572928). 
+
+       <li>amend logic from <a href="#xterm_185">patch #185</a> to not
+           reallocate cell-array if processing <code>ESC&nbsp;%&nbsp;G</code>
+           to switch from UTF-8 if already in ISO-8859-1 character set
+           (report by Michael Koehne).
+
+       <li>fix to avoid calling <code>XmuInternStrings()</code> with zero
+           count (report by Johan Bockg&#229;rd).
+
+       <li>fix build when --disable-ansi-color configure option is used.
+
+       <li>fix build when neither OPT_TCAP_QUERY or OPT_TCAP_FKEYS is defined
+           (patch by Matthieu Herrb)
+</ul>
+
+<H1><A NAME="xterm_256">Patch #256 - 2010/3/6</A></H1>
+<ul>
+       <li>add TerminalEmulator to desktop category files.
+
+       <li>modify <code>sinstall.sh</code> to ignore the "." appended to
+           permissions by selinux.
+
+       <li>change app-defaults organization, installing UXTerm-color
+           and KOI8XTerm-color for consistent behavior regarding
+           <code>customization:&nbsp;color</code> (prompted by discussion
+           in Ubuntu #421261).
+
+       <li>fix typo in <code>minstall.sh</code> from
+           <a href="#xterm_255">patch #255</a> changes,
+           and add case for
+           <code>/var/run</code> needed for full path of utmp
+           (report by Julien Cristau).
+
+       <li>minor fix to xterm manpage, remove a comment stating that margin
+           bell can be changed via the VT Options menu.  That was replaced in 
+           <a href="#xterm_225">patch #225</a>
+
+       <li>add a "docs" rule to makefile.
+
+       <li>fix initialization of Atom used for <code>XkbBell</code> feature
+           from <a href="#xterm_243">patch 243</a> changes.
+           Unlike the other calls to <code>XInternAtom()</code>,
+           in this case the flag telling X to create the Atom was unset
+           (patch by Chris Adams).
+</ul>
+
+<H1><A NAME="xterm_255">Patch #255 - 2010/1/21</A></H1>
+<ul>
+       <li>rename <code>install.sh</code> to <code>install-sh</code> in case
+           suffix-rules might interfere.
+
+       <li>extend range for <code>convertToUTF8</code> function to full
+           31-bits, to use with printing, etc.
+
+       <li>improve manpage by checking for actual locations of
+           utmp/wtmp files (Debian #562640).
+
+       <li>modify configure macro CF_XOPEN_SOURCE to remove -D's before
+           adding the same name rather than relying on -U's, to reduce
+           redefinition warnings for some platforms that have conflicting
+           definitions in headers.
+
+       <li>correct logic used to switch to alternate screen using FIFO-lines
+           configuration (Debian #565772).
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_254">Patch #254 - 2010/1/6</A></H1>
+<ul>
+       <li>add a configure-check to eliminate <code>install-ti</code>
+           rule from Makefile when the system has no tic (terminfo compiler)
+           program.  This lets one use the <code>install-full</code>
+           rule more consistently.
+
+       <li>amend change to WriteText() function in 
+           <a href="#xterm_252">patch #252</a> to take into account the
+           <code>colorAttrMode</code> resource
+           (report by Krzysztof Kotlenga).
+
+       <li>document <code>titleModes</code> resource in manpage, added in
+           <a href="#xterm_252">patch #252</a>.
+
+       <li>modify tcap-query table entries for shifted up/down cursor keys
+           to match ncurses convention.
+
+       <li>improve lookup of termcap-query data, allowing for duplicate
+           keycodes versus missing entries.
+
+       <li>add control sequence which can be used to modify the terminal
+           data used for the termcap-keyboard.
+
+       <li>improve portability of tcap-query feature, using terminfo functions
+           in preference to termcap on systems having terminfo.
+
+       <li>improve font-setting/querying control (<code>OSC&nbsp;50</code>):
+           <ul>
+           <li>when TrueType font is selected, the TrueType
+               <code>faceName</code> will be set, rather than the bitmap font.
+           <li>when TrueType font is selected, querying returns the name of
+               the TrueType font.
+           <li>querying a font recognizes the relative-font convention that
+               setting a font could use.
+           </ul>
+
+       <li>add menu-entry for allowColorOps.
+
+       <li>add new resources for fine-tuning menu entries:
+           <code>allowColorOps</code>,
+           <code>disallowedColorOps</code>,
+           <code>disallowedFontOps</code> and
+           <code>disallowedTcapOps</code>.
+
+       <li>correct logic for disabling the "TrueType Fonts" menu item; it was
+           not ensuring that the <code>faceName</code> resource value was
+           non-empty.
+
+       <li>implement VT520-style controls <code>DECSMBV</code> and
+           <code>DECSWBV</code> for setting the margin- and warning-bell
+           volume.
+
+       <li>fix a minor error from <a href="#xterm_243">patch #243</a> which
+           made the zIconBeep feature use a minor-error tone rather than an
+           informational tone.
+
+       <li>add a null-pointer check for the case where <code>renderFont</code>
+           resource is true, but <code>faceName</code> resource is unset,
+           used in logic to strip "xft:" prefix from
+           <a href="#xterm_251">patch #251</a> changes
+           (patch by Michael Riepe).
+
+       <li>add special case to configure CF_XOPEN_SOURCE macro to use extensions
+           on Darwin (patch by Dennis Preiser).
+
+       <li>improve configure checks for regular expressions header and
+           library
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_253">Patch #253 - 2009/12/10</A></H1>
+<ul>
+       <li>add a null-pointer check in <code>getPrinterFlags()</code>
+           per changes in <a href="#xterm_252">patch #252</a>.
+
+       <li>add a null-pointer check, needed in UTF-8 mode for Xft fonts after
+           changes in <a href="#xterm_252">patch #252</a> (patch by Alan
+           Coopersmith).
+
+       <li>correct size when clearing struct for tek4014 (patch by Jochen
+           Voss).
+
+       <li>parenthesize expression in <code>MoreRows</code> macro, fixing
+           a limit check added in <a href="#xterm_251">patch #251</a>
+           (Debian #560039).
+</ul>
+
+<H1><A NAME="xterm_252">Patch #252 - 2009/12/7</A></H1>
+<ul>
+       <li>modify title-querying logic to support retrieval of titles encoded
+           using UTF-8.
+
+       <li>add new "title-modes" control sequence for controlling whether
+           window/icon titles can be set or queried using UTF-8, optionally
+           encoded in a hexadecimal string.
+
+       <li>use <code>mkdir&nbsp;-p</code> rather than <code>mkdirs.sh</code>
+           (prompted by discussion of mawk by Aleksey Cheusov).
+
+       <li>add appropriate copyright/license notices to the bulk of files
+           lacking same, and modify to use identical terms in others which
+           used different wording.  The main exceptions are the files
+           contributed by Markus Kuhn, who appears to prefer public domain
+           distribution, noting that I have modified/improved several of these
+           without changing the terms of distribution (request by Jari Aalto).
+
+       <li>add control sequences for resetting the "dynamic" colors to
+           their default values.
+
+       <li>add control sequences for resetting the "special" colors to
+           their default values.
+
+       <li>add control sequences for setting the "special" colors such as
+           <code>colorBD</code> (bold).
+
+       <li>add overlooked case for setting highlight foreground color with
+           the dynamic-colors control.
+
+       <li>add <code>OSC 104</code>, for resetting ANSI/16/88/256 colors to
+           default.
+
+       <li>reset ANSI/16/88/256 colors to default in soft/hard reset functions.
+
+       <li>strip "xft:" prefix from <code>faceName</code> and
+           <code>faceNameDoublesize</code> resource values,
+
+       <li>add <code>DECSCUSR</code> (discussion with Andy Koppe).
+
+       <li>add check/warning on failure to load font, to see if the name looks
+           like an Xft pattern rather than XLFD.  This can happen if someone
+           happens to modify their X resource settings for programs that read
+           data from xterm's namespace.
+
+       <li>modify handling of <code>print</code> and
+           <code>print-everything</code>
+           actions to allow the various printer flags to be overridden  by
+           supplying parameters.
+
+       <li>add resource <code>printerNewLine</code> (request by Ovidiu
+           Gheorghioiu).
+
+       <li>minor cleanup, finish using <code>TScreenOf()</code> and
+           <code>TekScreenOf()</code> macros introduced in 
+           <a href="#xterm_224">patch #224</a>.
+
+       <li>improve checks in ShowCursor/HideCursor to get the background
+           color, particularly when <code>highlightReverse</code> resource
+           is used (reports by Jan Engelhardt, Christian Weisgerber).
+
+       <li>correct <code>checkVeryBoldAttr</code> to omit comparison of
+           foreground color to special color values used for
+           <code>color&lt;XX&gt;</code> resources (report by Jan Engelhardt).
+
+       <li>make <code>colorBDMode</code> and <code>colorULMode</code>
+           resources work with TrueType configuration (report by Jan
+           Engelhardt).
+</ul>
+
+<H1><A NAME="xterm_251">Patch #251 - 2009/11/11</A></H1>
+<ul>
+       <li>add window-ops controls to push/pop icon and/or window labels on
+           a stack.
+
+       <li>minor fixes to align termcap file with terminfo.
+
+       <li>add resource <code>disallowedWindowOps</code>, to allow fine-tuning
+           of features to suppress with the <code>allowWindowOps</code>
+           resource (prompted by discussion with Bram Moolenaar).
+
+       <li>add makefile rules for resize-manpage to pdf, etc.
+
+       <li>further improve limit-checks in select/paste (Mandriva #54531).
+</ul>
+
+<H1><A NAME="xterm_250">Patch #250 - 2009/10/13</A></H1>
+<ul>
+       <li>add check and error-message for fonts that have no printable
+           values in the ISO-8859-1 range (Debian #542434).
+
+       <li>some compiler-warning cleanup, in particular workaround for
+           defective implementation of gcc's attribute warn_unused_result
+           (report by Bram Moolenaar).
+
+       <li>improve estimate of single-column width for packed TrueType
+           fonts by ignoring extents for codes 127 and 159.
+
+       <li>improve line-drawing for TrueType fonts which happen to have
+           defined glyphs which are <em>not</em> line-drawing in 0..31
+           by assuming they're not, and just checking the existence of
+           the Unicode codepoints.  This makes it more likely that the
+           user can override a misconfigured font using the "Line-Drawing
+           Characters" menu entry.
+
+       <li>limit minimum cell-width for packed font to maximum-advance
+           reported by Xft.  Some fonts are wider than that, even in the
+           Latin-1 range (Debian #550497).
+
+       <li>add list of direct-contributors in "THANKS" file.
+
+       <li>stylistic changes to this file to help scripted extraction of
+           list of contributors.
+
+       <li>correct off-by-one in <code>okPosition</code> fix from
+           <a href="#xterm_249">patch #249</a> limit-checks which
+           prevented double-click selection on the bottom line of the
+           screen (reports by Rajeev V. Pillai, Debian #550368).
+
+       <li>add <code>-q</code> option to
+           <code>vttest/256colors2.pl</code> and
+           <code>vttest/88colors2.pl</code>
+           to demonstrate bulk initialization of color palette.
+
+       <li>improve the workaround from patch #188 by enabling resources for
+           the 88-color model.
+
+       <li>document in xterm manpage the limited availability of resources
+           <code>color16</code> to <code>color255</code> as noted in
+           <a href="#xterm_188">patch #188</a> (Ubuntu #438850).
+</ul>
+
+<H1><A NAME="xterm_249">Patch #249 - 2009/10/1</A></H1>
+<ul>
+       <li>change default for <code>allowWindowOps</code> resource to false.
+           <!-- on the other hand, gnome-terminal, pterm and rxvt-unicode
+               leave most of the related functionality enabled ;-) -->
+
+       <li>add limit-checks for result of visual_width() function,
+           needed from <a href="#xterm_242">patch #242</a> and
+           exposed by #244 changes (Debian #548321).
+
+       <li>improve limit-checks in select/paste.
+
+       <li>fix a remaining bug from 
+           <a href="#xterm_230">patch #230</a>
+           changes for displaying multi-column
+           characters in a proportional font (report by Chris Jones).
+
+       <li>add new resource forcePackedFont and menu entry "Packed Font" to
+           control whether to use the font's minimum (default) or maximum
+           width when those differ.  The workaround which xterm uses to
+           accommodate proportional fonts is not necessary with certain
+           fonts such as unifont which happen to store a mixture of
+           multicolumn glyphs (report by Chris Jones).
+
+       <li>fix an (old) bug which did not restart the timer for blinking text
+           if the only blinking text was temporarily scrolled out of view,
+           e.g., using the scrollbar.
+
+       <li>fix an (old) flaw in the delete-line operation where the text which
+           is scrolled into view while the display is scrolled up was not
+           repainted.
+
+       <li>improve delete-line and insert-line operations, retaining selection
+           when the selection does not intersect the deleted/inserted lines.
+
+       <li>fix an (old) off-by-one error when an application cleared above the
+           cursor position while the display was scrolled up, that would leave
+           an extra line of text uncleared.
+
+       <li>fix a similar problem where the double-size attribute would not be
+           reset when clearing the screen while the display was scrolled up.
+
+       <li>fix an indexing error which would occur if an application cleared
+           a line while the display was scrolled up and was also in UTF-8 mode
+           (Redhat #524503).
+           The error was from <a href="#xterm_228">patch #228</a>
+           but more visible after
+           changes from <a href="#xterm_244">patch #244</a>.
+</ul>
+
+<H1><A NAME="xterm_248">Patch #248 - 2009/9/11</A></H1>
+<ul>
+       <li>fix an overlooked adjustment for selecting double-width characters
+           in the narrow-character configuration.
+
+       <li>eliminate uses of <code>XTERM_CELL</code> and
+           <code>XTERM_CELLC</code> where an appropriate <code>LineData</code>
+           pointer is available.
+
+       <li>correct expression in <code>okScrnRow</code> macro, making
+           selections give the length of lines below the visible screen
+           (report by Stuart Henderson).
+
+       <li>correct logic used to improve performance of missing-glyph check,
+           which did not handle line-drawing characters (Debian #545220).
+</ul>
+
+<H1><A NAME="xterm_247">Patch #247 - 2009/8/30</A></H1>
+<ul>
+       <li>add ifdef's and check for openpty() on DragonFly (patch by
+           Alex Hornung).
+
+       <li>correct calculation for size of line's data block, which was
+           sometimes off-by-one when configured
+           using <code>--enable-16bit-chars</code>
+           (report by H Merijn Brand).
+
+       <li>fix indexing error in print-everything feature from
+           <a href="#xterm_246">patch #246</a> (patch by Ovidiu Gheorghioiu).
+</ul>
+
+<H1><A NAME="xterm_246">Patch #246 - 2009/8/16</A></H1>
+<ul>
+       <li>remove obsolete logic for saving/restoring wrapping flags, which
+           did not work on 64-bit platform.  Wrapping flags (stored in the
+           line-index) are now copied with line-data (Debian #541160).
+
+       <li>modify comments in app-defaults files to avoid problem with
+           C preprocessor used by <code>xrdb</code> (Debian #541603).
+
+       <li>restore special case in <code>makeColorPair</code>,
+           needed for <code>colorBDMode</code> resource (Debian #541089).
+
+       <li>correct <code>SetLineFlags()</code> macro, broken in
+           <a href="#xterm_244">patch #244</a>
+           when recoding to avoid gcc-specific bitfields (Debian #541236).
+
+       <li>modify initialization of screen buffers to ensure that pointers
+           align to int-boundaries.
+           This fixes a problem introduced in
+           <a href="#xterm_244">patch #244</a>
+           where the color- and character-arrays
+           (stored after the video-attributes in each row)
+           might be misaligned (report by Rajeev V Pillai).
+
+       <li>add limit-check in <code>ScrnRefresh</code> for handling
+           saved-lines from the circular buffer which are repainted on a
+           screen whose width has increased.  To improve performance, circular
+           buffer entries are not resized (report by Rajeev V Pillai).
+
+       <li>correct type for <code>CellColor</code> (a late change in
+           <a href="#xterm_244">patch #244</a>
+           to avoid gcc-specifc enums made that unsigned
+           rather than unsigned short, for the 256-color option).
+
+       <li>fix typo in configure option --enable-16bit-chars (report by
+           Rajeev V. Pillai).
+</ul>
+
+<H1><A NAME="xterm_245">Patch #245 - 2009/8/12</A></H1>
+<ul>
+       <li>correct a special case in saving FIFO-lines from
+           <a href="#xterm_244">patch #244</a>.
+           If the screen was shrunk, xterm used the wrong amount for copying
+           to FIFO-lines, and then used this amount to adjust the current
+           row on the screen.  That was both a visible defect (Debian #541109)
+           as well as a potential addressing error (Debian #541132, #541160,
+           and #541236).
+
+       <li>add clarification in xterm manual about the
+           various <code>allow<em>XXX</em>Ops</code> resources, which
+           are disabled when the 
+           <code>allowSendEvents</code> resource is active (patch by
+           Julien Cristau, Debian #531597).
+</ul>
+
+<H1><A NAME="xterm_244">Patch #244 - 2009/8/9</A></H1>
+<ul>
+       <li>refactored storage of saved-lines, providing a configure option
+           to manage them as a FIFO (actually a circular buffer), improving
+           performance.
+           Added configure option <code>--enable-fifo-lines</code> to
+           enable/disable the new feature (it is enabled by default).
+
+       <li>added <code>fastScroll</code> resource, to amuse
+           people who measure terminal emulator performance by
+           <code>cat</code>'ing large files to the screen.
+
+       <li>modify check in <code>readPtyData</code> from return values
+           to provide exit on zero-bytes read from pty for FreeBSD, or
+           eliminate high-CPU in "xterm-hold" processing
+           (discussion with Ulrich Spoerlein, FreeBSD ports/136686).
+           The check was originally modified to combine negative/zero
+           values in XFree86-3.1.2E, 1996/05/06.
+
+       <li>add configure option <code>--enable-16bit-chars</code> to
+           provide wide-characters with 16-bits (rather than the default
+           32-bits).
+
+       <li>add <code>retryInputMethod</code> resource to allow configuring
+           out the retries xterm uses to connect to non-responsive XIM
+           server, to work around defective X configurations as noted in
+           <a href="http://mail-index.netbsd.org/tech-x11/2009/06/07/msg000511.html">NetBSD mailing list</a>.
+
+       <li>make regular-expression selection work for VT100 double-sized
+           characters.
+
+       <li>improve layout when drawing missing characters in a proportional
+           font, e.g., as boxes, to take into account whether they are
+           double-width (report by Guilbert Stabilo on comp.unix.shell).
+
+       <li>add capability for keypad-center (kb2/KA2) to termcap entry for
+           xterm-new, as well as xterm-8bit, xterm-sun and xterm-vt220
+           (FreeBSD conf/136336).
+
+       <li>change default for <code>keepSelection</code> resource to true
+           (prompted by discussion with David Muir Sharnoff).
+
+       <li>remove a limit-check in ptydata.c, allowing Unicode values past
+           64k to be displayed using TrueType fonts (Debian #458432).
+
+       <li>remove a vt52-specific ifdef to allow mapping F1-F4 to PF1-PF4
+           when vt52 support is not compiled (report by Olaf 'Rhialto'
+           Seibert).
+
+       <li>save/restore line-wrapping flags when converting from ISO-8859-1
+           encoding to UTF-8 encoding, as well as when resizing screen.
+
+       <li>remove extra adjustment of position in fix for Debian #418324.
+
+       <li>modify default check for <code>mkWidth</code> resource to check
+           for line-drawing characters, which are categorized as double-width
+           in Solaris 10 (report by Sebastian Kayser).
+
+       <li>add "print-everything" action (patch by Ovidiu Gheorghioiu).
+
+       <li>start refactoring scrollback data using new getLineData() function.
+
+       <li>demote recent change to Debian #252873 fix to experimental,
+           ifdef'd out as <code>EXP_BOGUS_FG</code> (Debian #522141).
+
+       <li>work around groff mapping of ASCII quotes using macros (requested
+           by Reuben Thomas based on Colin Watson advice, fixes Debian #378700).
+
+       <li>correct symbol used for default of <code>allowWindowOps</code>
+           which was <code>DEF_ALLOW_FONT</code>
+           rather than <code>DEF_ALLOW_WINDOW</code>
+           (report by Matthieu Herrb).
+
+       <li>amend fix for tek4014 from <a href="#xterm_243">patch #243</a>
+           to make it only apply to the Tek Options menu.
+</ul>
+
+<H1><A NAME="xterm_243">Patch #243 - 2009/3/28</A></H1>
+<ul>
+       <li>revert change to default for <code>allowTcapOps</code> (request by
+           Bram Moolenaar).
+
+       <li>reallocate result returned by <code>xtermEnvLocale()</code> to
+           avoid reference to freed memory after handling
+           <code>menuLocale</code> resource.
+
+       <li>fix an old (X11R5) bug in tek4014 for switching fontsizes.
+
+       <li>add resource <code>defaultString</code> to make configurable the
+           use of "#" when pastes of UTF-8 text fail due to limitations in
+           the current locale settings.
+
+       <li>make the set of selection target Atom's configurable by two new
+           resources <code>eightBitSelectTypes</code> and
+           <code>utf8SelectTypes</code>, e.g., to use the <code>TEXT</code>
+           Atom in preference to <code>UTF8_STRING</code> (discussion with
+           Stanislav Sedov regarding koi8rxterm and the FreeBSD port).
+
+       <li>modify handling of <code>TARGETS</code> Atom by making it return
+           exactly the set of targets as those which xterm is currently
+           providing.
+
+       <li>set <code>MANPAGER</code> and <code>PAGER</code> explicitly to
+           /bin/cat in <code>minstall.sh</code> to work around /etc/man.conf's
+           with those variables already set
+           (report by &#1052;&#1072;&#1088;&#1100;&#1103;&#1089;&#1080;&#1085;
+           &#1057;&#1077;&#1084;&#1105;&#1085;).
+       <li>improve error-checking of tcap-query parser.
+
+       <li>add check for keyboard <code>tcap</code>), which ensures that
+           terminal descriptions containing the same string for
+           shifted/unshifted keys will be seen by tcap-query as only the
+           unshifted key.  (This would only happen with an incorrect terminal
+           description).
+
+       <li>fix conversion for input event-state to modifier-parameter which
+           made tcap-query feature not work with <code>tcapFunctionKeys</code>
+           (keyboard type <code>tcap</code>).
+
+       <li>add "DEF_ALLOW_<em>XXX</em>" definitions to main.h to allow
+           overriding the default compiled-in values for
+           "allow<em>xxx</em>" resources.
+
+       <li>remove check on bell-percentage added in
+           <a href="#xterm_242">patch #242</a>,
+           which disallowed zero/negative values (Redhat Bugzilla #487829).
+</ul>
+
+<H1><A NAME="xterm_242">Patch #242 - 2009/2/15</A></H1>
+<ul>
+       <li>fix configure check for <code>XkbBell</code> and provide
+           appropriate parameter for it.
+
+       <li>fix a caching problem with double-size fonts versus reverse video
+           that could cause core dump.
+
+       <li>repair double-size fonts from workaround
+           used in <a href="#xterm_240">patch #240</a>.
+
+       <li>add new section to the VT Fonts menu which allows enabling or
+           disabling the font, termcap (tcap-query), title and window
+           operations.
+
+       <li>add <code>fontWarnings</code> resource, to control whether to show
+           warnings on failure to load a font.
+
+       <li>improve warnings for unloadable fonts introduced in
+           <a href="#xterm_240">patch #240</a>
+           by limiting those to the cases where a font would be specified
+           directly by a resource setting rather than a derived fontname.
+
+       <li>further amend fix for Debian #252873
+           from <a href="#xterm_197">patch #197</a> to
+           treat a blank cell which does not have both foreground and background
+           colored as a non-colored cell.
+           This improves a special case where the cursor is on a blank
+           cell which had foreground color scrolled in
+           (report by Miroslav Lichvar).
+           <p>
+           Also add the same logic when hiding cursor, so the outline matches
+           the in-focus cursor.
+
+       <li>modify internals to reduce places PAIRED_CHARS() is used, making
+           WriteText() and ScrnWriteText() accept IChar array, as well as
+           providing a wrapper for drawXtermText().
+
+       <li>change default XIM font from "*" to "fixed" to improve startup
+           time in zh_CN.UTF-8 locale (Mike Fabian, SuSE Bugzilla #464930).
+
+       <li>typo in #240 log (Slava Semushin)
+</ul>
+
+<H1><A NAME="xterm_241">Patch #241 - 2009/1/26</A></H1>
+<ul>
+       <li>improve checks for missing bitmap fonts, fallback to "fixed" as
+           needed to work around broken font-packages (report by Jacek
+           Luczak).
+
+       <li>fix breakage from <a href="#xterm_240">patch #240</a> changes for
+           <code>xtermAddInput()</code> (patches by Jeff Chua, Julien Cristau).
+</ul>
+
+<H1><A NAME="xterm_240">Patch #240 - 2009/1/25</A></H1>
+<ul>
+       <li>use <code>plink.sh</code> for linking xterm (suggested by Larry
+           Doolittle).
+
+       <li>add resource descriptions for input method to xterm manpage.
+
+       <li>update configure script; consistently append to $CFLAGS rather
+           than prepend.
+
+       <li>add <code>install-scripts</code> rule to makefile, to allow
+           koi8rxterm and uxterm scripts to be altered independently of
+           <code>install-bin</code> 
+
+       <li>add <code>-maximized</code> command-line option and corresponding
+           resource (prompted by alt.os.linux newsgroup comment).
+
+       <li>modify translations of scrollbar widget using
+           <code>xtermAddInput()</code>
+           (see <a href="#xterm_181">patch #181</a>) to accept the actions
+           that the vt100 widget accepts, such as shift-insert to perform
+           a paste operation (request by Martin Zwickel).
+
+       <li>change default for <code>allowTcapsOps</code> resource to false,
+           since it causes unexpected behavior for vim users with
+           <code>AltGr</code>.
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_239">Patch #239 - 2009/1/8</A></H1>
+<ul>
+       <li>correct a cast in input.c, which broke translation of numeric
+           keypad codes to pageup, pagedown, etc., on 64-bit platform
+           (Debian #511138, report by Larry Doolittle).
+</ul>
+
+<H1><A NAME="xterm_238">Patch #238 - 2008/12/30</A></H1>
+<ul>
+       <li>update configure macro CF_XOPEN_SOURCE for AIX 6.x and Mint
+           platforms.
+
+       <li>reset the screen wrapping-flag at the end of
+           <code>ClearRight</code> to fix an occasional case where the last
+           character of a scrolled and wrapped line would be cleared (patch by
+           Joe Peterson).
+
+       <li>modify to use POSIX coding for comparing resource settings such
+           as <code>locale</code>, to work with locales such as Turkish
+           (report by M Vefa Bicakci).
+
+       <li>turn on configure <code>paste64</code> feature by default
+           (request by Jean-Philippe Bernardy).
+           It is runtime enabled/disabled with <code>allowWindowOps</code>.
+
+       <li>turn on configure <code>tcap-query</code> feature by default,
+           add resource <code>allowTcapOps</code>
+           to make this runtime enabled/disabled.
+
+       <li>make <code>OSC 3</code> (change X property, from
+           <a href="#xterm_110">patch #110</a>)
+           subject to <code>allowWindowOps</code> resource.
+
+       <li>make VT220 <code>DSR</code> responses inactive in VT100-mode.
+
+       <li>make <code>DECUDK</code> feature inactive in VT100-mode.
+
+       <li>respond to incorrectly formatted <code>DECRQSS</code> with a
+           cancel.
+
+       <li>add <code>allowFontOps</code> 
+           resource to allow the fontsize-switching and font query/set
+           control sequences to be enabled/disabled
+           (prompted by Debian #510030).
+
+       <li>some code cleanup based on gcc 4.x <code>-Wconversion</code>
+           warnings in button.c and charproc.c
+
+       <li>modify <code>tcap-query</code> feature to not return data for
+           shifted cursor-keys when the keyboard type is set to vt220,
+           since returning the same string for shifted/unshifted keys may
+           confuse some applications (GenToo #212546).
+</ul>
+
+<H1><A NAME="xterm_237">Patch #237 - 2008/09/14</A></H1>
+<ul>
+       <li>improve usability of TrueType fonts by making the font-size
+           switching for shifted keypad plus/minus use the
+           <code>faceSize</code> resources to determine the order of fonts
+           (when TrueType fonts are used) rather than the bitmap fonts, since
+           their sizes may not be in the same order (report by H Merijn
+           Brand)
+
+       <li>remove an optimization of <code>ConfigureNotify</code> events
+           from <a href="#xterm_236">patch #236</a>
+           which seems to interfere with passing <code>SIGWINCH</code> to 
+           applications (GenToo #233836).
+
+       <li>modify handling of <code>altSendsEscape</code> to reset the
+           <code>eightBitInput</code> mode, like <code>metaSendsEscape</code> 
+           (patch by Ted Phelps).
+
+       <li>add feature to show the text-cursor as an underline rather than a
+           box, plus command-line options <code>-uc</code> and
+           <code>+uc</code> and resource <code>cursorUnderLine</code> to
+           control the feature (patch by Paul Lampert).
+
+       <li>update config.guess, config.sub
+</ul>
+<H1><A NAME="xterm_236">Patch #236 - 2008/07/27</A></H1>
+<ul>
+       <li>correct memory reallocation when handling a paste of UTF-8 text
+           from <a href="#xterm_225">patch #225</a> changes
+           (report/patch by Max Mikhanosha).
+
+       <li>correct allocation of temporary buffer in
+           <code>xtermFindShell</code> in case the user's <code>$PATH</code>
+           contains no ":" (report/analysis by Victor Stinner,
+           Freedesktop.Org Bugzilla #16790).
+
+       <li>modify CF_XOPEN_SOURCE to add case for DragonFly BSD, to fix
+           new compile problem exposed by fix for fd_mask (patch by
+           Hasso Tepper).
+
+       <li>add configure-check for ncurses <code>use_extended_names</code>,
+           (report by Martin Mokrejs).
+
+       <li>correct computation for toolbar height; layout manager already
+           takes into account <code>borderWidth</code> resource.
+
+       <li>implement VT320-style SCS (select character set) for ISO Latin-1
+           supplemental.
+
+       <li>fixes for vt100-style character sets in UTF-8 mode (Ubuntu #230919).
+
+       <li>fix to make <code>luit</code> work with xterm's <code>-ls</code>
+           option (report/patch by Marius Tolzmann).
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_235">Patch #235 - 2008/04/20</A></H1>
+<ul>
+       <li>add control sequences for some of the recent resource/menu
+           settings:
+           <ul>
+           <li><code>altSendsEscape</code> (private mode 1039)
+           <li><code>keepSelection</code> (private mode 1040)
+           <li><code>selectToClipboard</code> (private mode 1041)
+           <li><code>bellIsUrgent</code> (private mode 1042)
+           <li><code>popOnBell</code> (private mode 1043)
+           </ul>
+
+       <li>add resource <code>formatOtherKeys</code> to provide an alternate
+           escape sequence format for the <code>modifyOtherKeys</code> 
+           resource (request by Paul LeoNerd Evans).
+
+       <li>adjust saved-cursor position if the window is resized while
+           displaying the alternate screen (Novell #196880, Debian #383384).
+
+       <li>improve pointer-checks to fix a bug exposed by resizing during
+           initialization under StumpWM window manager
+           (Fedora Bugzilla #437928).
+
+       <li>modify <code>unselectwindow()</code> to ensure that the mouse
+           pointer is not hidden after xterm loses focus (report by Jeremy
+           Huddleston).
+
+       <li>add special check for fd_mask on Mac OS X (report by Jeremy
+           Huddleston).
+
+       <li>add <code>dylib</code> to autoconf's suffix list used for checking
+           the result from <code>xmkmf</code>, to work with Mac OS X (report
+           by Jeremy Huddleston).
+
+       <li>correct initialization of bold- and wide-, wide-bold fonts which
+           may be set via the <code>utf8Fonts</code> subresource (Debian
+           #347790).
+</ul>
+
+<H1><A NAME="xterm_234">Patch #234 - 2008/03/02</A></H1>
+<ul>
+       <li>modify <code>sinstall.sh</code> to use POSIX locale to 
+           bypass GNU ls changes to date-format.
+
+       <li>improved/refined changes for closing bitmap font (patch by
+           Andrea Odetti).
+
+       <li>improve resize computation for situations where the negotiation
+           fails, by invoking the xterm widget's core-class resize method
+           (Debian #365602, patch by Jim Paris).
+
+       <li>restore initialization of terminal's <code>VMIN</code> and
+           <code>VTIME</code> settings,
+           from <a href="#xterm_232">patch #232</a> changes
+           (patch by Matthieu Herrb).
+</ul>
+
+<H1><A NAME="xterm_233">Patch #233 - 2008/02/24</A></H1>
+<ul>
+       <li>add configure check for <code>ttydefaults.h</code>, include if
+           needed, e.g., for systems where defining
+           <code>_POSIX_C_SOURCE</code>, etc.,
+           prevents it from being included via
+           <code>termios.h</code> (prompted by comments by Robert Delius Royar
+           and Jeremy Huddleston).
+
+       <li>bug-fixes for bugs.opensolaris.org (patches from Alan Coopersmith)
+           <dl>
+           <dt>4029911
+           <dd>fix a typo in manpage
+           <dt>4045962
+           <dd>xterm doesn't properly set ut_syslen
+           <dt>4192572
+           <dd>left-left-right misinterpreted as triple click
+           </dl>
+
+       <li>minor optimization to tab-initialization (patch by
+           Németh Márton).
+
+       <li>fix a case where an incorrect font was freed during initialization
+           from <a href="#xterm_232">patch #232</a> changes (patch by
+           Andrea Odetti).
+
+       <li>improve comparison used in <code>SameFont</code> function for
+           GC-caching (Julien Cristau).
+
+       <li>correct macro name used for default <code>CKILL</code> definition
+           to work with Mac OS X (report by Jeremy Huddleston).
+</ul>
+
+<H1><A NAME="xterm_232">Patch #232 - 2008/01/30</A></H1>
+<ul>
+       <li>corrected logic in a font-cache used for reverse-video (Debian
+           #404079).
+
+       <li>add control sequence to alter <code>pointerMode</code> at runtime.
+
+       <li>add limit-checks for rectangle operation parameters (report by
+           Martin Pirker).
+
+       <li>modify <code>minstall.sh</code> to suppress <code>$MANPAGER</code>
+           and <code>$PAGER</code> environment variables, which may interfere
+           with redirecting output of <code>man</code> to a shell variable
+           (report/patch by Zdenek Sekera).
+
+       <li>do not try to hide mouse pointer in the tek4014 window, fixes
+           broken "-t" option at startup from
+           <a href="#xterm_230">patch #230</a> changes
+           (report by Robert K. Nelson).
+
+       <li>correct datatype used when drawing tek4014 data using xterm
+           compiled for wide-characters, on big-endian machines (reports
+           by Jeremy Huddleston, Harald Hanche-Olsen, Martin Costabel, Merle
+           Reinhart).
+
+       <li>modify to cache the font-names along with the bitmap font data,
+           to improve comparison of fonts.
+
+       <li>modify to allow building with configure options
+           <code>--disable-ansi-color</code> and
+           <code>--disable-leaks</code> (Debian #459817, report/patch by Németh Márton).
+
+       <li>modify to allow building with configure options
+           <code>--enable-wide-chars</code> and
+           <code>--disable-c1-print</code> (Debian #459816, report/patch by Németh Márton).
+
+       <li>add <code>pointerMode</code> resource to control whether and
+           when the pointer cursor is hidden as the user types.
+
+       <li>simplify initialization of ttyMode- and related characters using
+           a table.
+
+       <li>modify initialization-logic for stty values that correspond to
+           ltchars structure and the BSD TIOCSLTC ioctl (susp, dsusp, rprnt
+           flush, werase, lnext).  These were reset to constants for both
+           termios and legacy interfaces immediately after asking the system
+           for the existing values since X11R6.1, rather than using them to
+           provide inherited values.  While the legacy interface has some
+           constraints, e.g., on HPUX, the POSIX or termios interface should
+           not.  Your shell may reset these anyway
+           (prompted by patch by Ed Schouten).
+
+       <li>improve logic for hiding/displaying pointer-cursor (report by
+           Mark Brukhartz).
+
+       <li>add limit-checks to tabs.c, increase maximum column for setting
+           tab-stops from 320 to 1024 (report by Németh Márton).
+
+       <li>correct length, i.e., number of types of selection targets,
+           computed by <code>ConvertSelection()</code> when not handling
+           wide characters for the <code>XA_TARGETS()</code> case.
+           This leaves an extra Atom on the end of the list which is
+           not handled by
+           <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6322854">Java applications</a>.
+           The problem was introduced in <a href="#xterm_151">patch #151</a>
+           (report by David Wood).
+</ul>
+
+<H1><A NAME="xterm_231">Patch #231 - 2008/01/05</A></H1>
+<ul>
+       <li>undo change to <code>getXtermCell()</code> from patch #230
+           using <code>PACK_PAIR</code> macro (Debian #459014, analysis by
+           Caetano Jimenez Carezzato).
+
+       <li>minor documentation fixes (patch by Slava Semushin)
+
+       <li>add makefile actions to install KOI8RXTerm app-defaults file
+           (patch by Julien Cristau).
+</ul>
+
+<H1><A NAME="xterm_230">Patch #230 - 2007/12/31</A></H1>
+<ul>
+       <li>add <code>quietGrab</code> resource, which when true, suppresses
+           cursor repainting when <code>NotifyGrab</code> and
+           <code>NotifyUngrab</code> event types are received during
+           change of focus (request by Nicolas George).
+
+       <li>do not treat Unicode BIDI control characters as combining
+           characters (Debian #457634).
+
+       <li>add <code>koi8rxterm</code>, from Debian.
+
+       <li>add manpage for <code>uxterm</code>, from Debian (Ubuntu #128136,
+           Debian #438645)
+
+       <li>remove ".xpm" suffixes from Icon filenames in desktop files since
+           it confuses some lookups following the
+           <a href="http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html">Icon Theme Specification</a>
+           (report by Slava Semushin)
+
+       <li>correct width-calculation used for adjusting proportional fonts,
+           to work with wide-characters (Debian #441354).
+
+       <li>fixes/improvements for double-size characters:
+           <ul>
+           <li>correct old clipping calculation which used total height of
+               glyphs where ascent was needed.
+
+           <li>if bold font is unavailable, fall back to normal font
+
+           <li>adjust to "work" with Xft (which does not support double-width
+               single-height characters). 
+
+           <li>restore reset of doublesize for a line when it is cleared,
+               broken in <a href="#xterm_228">patch #228</a>.
+           </ul>
+
+       <li>modify logic for <code>forceBoxChars</code> resource when using
+           TrueType fonts to be consistent with bitmap fonts
+
+       <li>modify logic for <code>forceBoxChars</code> resource to make the
+           "Line-Drawing Characters" menu entry use xterm's line-drawing
+           characters even asked to draw wide line-drawing characters which
+           are available in the font.
+
+       <li>modify rectangle-support functions to preserve colors when
+           filling/erasing to match WRQ Reflection behavior
+           (request by Enzo Toscano).
+
+       <li>add getopt-parsing to tcapquery.pl, including feature to test the
+           extended cursor/editing keys.
+
+       <li>make missing double-width glyphs display as double-width
+           (Debian #456236).
+
+       <li>change <code>tcap-fkeys</code> and <code>rectangles</code>
+           configure options to enable them by default.
+
+       <li>hide the mouse pointer while user is typing (request by Rodolfo
+           Borges).
+
+       <li>extend configure options
+           <code>--enable-tcap-query</code> and
+           <code>--enable-tcap-fkeys</code> to
+           send cursor- and editing-keypad keys modified according to the
+           keyboard (or termcap) selection for shift, alt, control, meta.
+
+       <li>modify <code>kdch1</code> in termcap, e.g., <code>xterm-r6</code>
+           to match the terminfo file.
+
+       <li>add <code>-hm</code> option to turn <code>highlightColorMode</code>
+           on or off.
+
+       <li>add <code>highlightColorMode</code> resource to separate the
+           new (since <a href="#xterm_225">patch #225</a>) highlighting with both text- and
+           background-colors (prompted by report/example by Thomas Wolff).
+
+       <li>add <em>Keep Selection</em> menu entry to turn the 
+           <code>keepSelection</code> resource on/off at runtime.
+
+       <li>add <code>keepSelection</code> resource, which when enabled,
+           tells xterm to retain the X selection even after it stops
+           highlighting it (patch by Sergey Vlasov).
+
+       <li>extend the <code>CSI&nbsp;&gt;&nbsp;n</code> sequence to allow
+           disabling all types of modified-keys that the
+           <code>CSI&nbsp;&gt;&nbsp;m</code> sequence affects.
+
+       <li>move include for <code>&lt;xtermcap.h&gt;</code> in
+           <code>resize.c</code> to avoid redefinition of <code>termios</code>
+           structure on OpenSolaris (report by Rahul Gopinathan Nair).
+
+       <li>extend terminfo building blocks for modified editing keys to
+           include all six keys.
+
+       <li>synchronize terminfo with ncurses (report by Stephane Chazelas)
+           <ul>
+           <li>equate <code>xterm-xfree86</code>
+               and <code>xterm-xf86-v44</code>.
+           <li>add ncurses extensions OTbs, AX, for termcap conversions.
+           <li>make old/legacy entries such as
+               <code>xterm-24</code>, <code>xterm-65</code>
+               and aliases <code>xterms</code>, <code>vs100</code>
+               inherit from <code>xterm-old</code>.
+           <li>make <code>xterm-r5</code> and <code>xterm-r6</code> the
+               same, ignoring historical errors in X Consortium's version.
+           </ul>
+
+       <li>fix an ifdef in logic for selecting regular
+           expressions while in a narrow-character locale (Debian #449227).
+</ul>
+
+<H1><A NAME="xterm_229">Patch #229 - 2007/8/12</A></H1>
+<ul>
+       <li>override locale in minstall.sh;
+           change in <a href="#xterm_226">patch #226</a>
+           does not work in UTF-8 locale (report by Zdenek Sekera).
+
+       <li>undo an incorrect fix for a memory leak
+           in <a href="#xterm_209">patch #209</a> (Debian #435858).
+</ul>
+
+<H1><A NAME="xterm_228">Patch #228 - 2007/7/22</A></H1>
+<ul>
+       <li>modify configure script to permit combining
+           <code>--with-utempter</code>
+           and <code>--enable-setuid</code>, e.g., for using xterm with 
+           the utempter library on FreeBSD (report by Andriy Gapon).
+
+       <li>modify "Quit" menu entry to override the <code>-hold</code>
+           command-line option.
+
+       <li>add a check in the startup error-reporting to avoid writing to
+           pipe when it has not been opened.  In that case, report errors
+           directly to the standard error.
+
+       <li>add OPT_READLINE definition to xtermcfg.hin, overlooked in
+           <a href="#xterm_205">patch #205</a>
+           (report by Kalle Olavi Niemitalo).
+
+       <li>modify <code>88colors2.pl</code> and <code>256colors2.pl</code>,
+           adding <code>-r</code>
+           option to reverse the palettes for the extended colors.
+
+       <li>check for partial overwrite or deletion of multi-column characters
+           in several cases, e.g., insert-character, delete-character,
+           etc.,
+           and fill the remainder of the cells used by the multi-column
+           characters affected with blanks.
+
+       <li>correct character-class codes in wide-character mode for characters
+           215, 247 (see also <a href="#xterm_165">patch #165</a>).
+
+       <li>fix missing assignment for UTF-8 parsing in widget initialization
+           (Debian #403360).
+
+       <li>correct index expression used to set line-wrapping flag, making
+           selection from scrollback work consistently (Debian #430121,
+           report by Vincent Lefevre).
+
+       <li>amend changes to handshake in
+           <a href="#xterm_226">patch #226</a>
+           to accommodate Solaris, which relies on the extra setting of
+           the terminal size after I/O initialization.
+           Do this by adding new resource <code>ptySttySize</code>,
+           which is false for Linux and MacOS X, i.e., true for
+           for Solaris and other SVR4 platforms, as well as FreeBSD
+           (reports by David Wood, Renato Botelho).
+
+       <li>check for X events after cursor-left, and carriage return,
+           consistent with indexing operations
+           (comments by Vegard Nossum and Ingo Molnar on a mailing-list).
+
+       <li>initialize the <code>.keyboard</code> structure,
+           needed for some platforms (such as Solaris) after
+           <a href="#xterm_227">patch #227</a> fixes for keysyms
+           (patch by David Wood).
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_227">Patch #227 - 2007/6/27</A></H1>
+<ul>
+       <li>exclude the Intel compiler from the extra gcc warning options
+           added in 
+           <a href="#xterm_226">patch #226</a>.
+
+       <li>modify change for Debian #422521
+           from <a href="#xterm_226">patch #226</a>
+           to work with configurations where the X server does not
+           recognize
+           the <code>XF86Paste</code>
+           or <code>SunPaste</code> keysyms (report by Paolo Pumilia).
+
+       <li>fix incorrect free in fix for "Selection" menu entry in
+           <a href="#xterm_226">patch #226</a>.
+</ul>
+
+<H1><A NAME="xterm_226">Patch #226 - 2007/6/17</A></H1>
+<ul>
+       <li>add configure check to use <code>-Wno-unknown-pragmas</code> for
+           Solaris, and a few other new gcc warning options to address
+           regressions in its warning options.
+
+       <li>add sample desktop and icon files, along with configure options for
+           manipulating them.
+
+       <li>fix an infinite loop when showing a 2-column character in a
+           1-column screen (Debian #426863).
+
+       <li>add <code>XF86Paste</code> and <code>SunPaste</code> to the
+           default translations (Debian #422521, patch by Bernhard R Link).
+
+       <li>update wcwidth.c (partly based on/prompted by mailing list
+           comment).
+
+       <li>update/improve keysym2ucs.c based on Unicode 5.0.1d3 and Xorg
+           7.1 keysymdef.h file.
+
+       <li>improve <code>gen-pc-fkeys.pl</code>, making it show all of the
+           building-block terminfo entries used by xterm.
+
+       <li>correct strings used for modifiers applied to F1-F4 in xterm+pcf1
+           terminfo entry.
+
+       <li>improve session management by adding the ICE connection number
+           to the <code>select</code> call rather than waking up once per
+           second (patch by Miroslav Lichvar).
+           
+       <li>add environment variable <code>$XTERM_LOCALE</code> to help
+           with shell initialization, e.g., to set a specific locale for
+           xterm on systems where a global locale is set in the shell
+           startup scripts.
+
+       <li>add resource settings <code>mkSampleSize</code> and
+           <code>mkSamplePass</code>
+           to modify the <code>mkWidth</code> added
+           in <a href="#xterm_201">patch #201</a>.
+           In <a href="#xterm_202">patch #202</a>,
+           xterm would also check if the system's
+           <code>wcwidth</code> matched its built-in tables
+           "well enough" to be used when <code>mkWidth</code> was false,
+           and if not would use the built-in tables anyway.
+           These resources allow the user to customize the decision
+           (prompted by comments by Emanuele Giaquinta)
+
+       <li>modify logic which resets/updates the screensize on the child
+           process side of the pseudo-terminal to do this only if a
+           successful handshake was received, e.g., as determined by
+           the <code>waitForMap</code> resource (prompted by reports
+           by Emanuele Giaquinta and Bernhard R Link, but see also
+           <a href="#xterm_177">patch #177</a> and
+           <a href="#xterm_159">patch #159</a>.
+
+       <li>improve permissions logic when closing pseudo-terminal
+           (Debian #12261,
+            patch by Nathanael Nerode,
+            analysis by Richard Braakman).
+
+       <li>add resource <code>highlightReverse</code> which controls whether
+           xterm will allow selection highlighting to hide reverse-video
+           or use the older behavior which inverts the foreground and
+           background colors when selected text with reverse-video attribute
+           (report by Adam M Costello, comments by Victor Vaile).
+
+       <li>restore a special case for cursor-color in
+           <code>ReverseVideo()</code>
+           lost in rewrite for <a href="#xterm_224">patch #224</a>
+           (report by Adam Sulmicki).
+
+       <li>correct initialization for menu entry for <code>bellIsUrgent</code> 
+           (patch by Emanuele Giaquinta).
+
+       <li>correct length of underlining for double-width Xft fonts
+           (report by Shidai Liu "Leo").
+
+       <li>correct clipping for double-width Xft fonts
+           (report by Shidai Liu "Leo").
+
+       <li>modify initialization for <code>italicULMode</code> to avoid
+           <code>XftPatternBuild</code> reusing bold attributes
+           (report by Shidai Liu "Leo").
+
+       <li>add a check in case someone tries to call the
+           <code>popup-menu()</code> action on a menu which is not initialized
+           (Debian #426364).
+
+       <li>improve CF_IMAKE_CFLAGS to work with Solaris sed (report by Peter
+           Bray).
+
+       <li>improve guess for X's manpage section in <code>minstall.sh</code>,
+           (prompted by comment by Miroslav Lichvar).
+
+       <li>modify <code>minstall.sh</code> to handle manpage patch with more
+           than one dot (patch by Miroslav Lichvar).
+
+       <li>fix configure message for --disable-setgid option (patch by
+           Miroslav Lichvar).
+
+       <li>add <code>allowTitleOps</code> resource to allow users to prevent
+           the title- and icon-names from changing (request by John Bashinski).
+
+       <li>fix "spawn-new-terminal" action, for the case where no parameter
+           is passed to the action (patch by Daniel Colascione).
+
+       <li>fix error-checking on internal font switching for "Selection"
+           menu entry (Debian #421523).
+
+       <li>amend select/paste change from
+           <a href="#xterm_225">patch #225</a>
+           by limiting it to non-UTF-8/non-KOI8-R encoding (Debian #420974).
+
+       <li>add workaround for groff ".URL" codes which are not present in
+           some commonly-used bitmap fonts (Debian #418324).
+</ul>
+
+<H1><A NAME="xterm_225">Patch #225 - 2007/3/24</A></H1>
+<ul>
+       <li>add <code>useClipping</code> resource to allow clipping to be
+           disabled.
+
+       <li>use <code>XftDrawSetClipRectangles</code>
+           to work around Xft pixel-trash (report by Reuben Thomas).
+
+       <li>add configure option <code>--enable-tcap-fkeys</code>, and
+           resource <code>tcapFunctionKeys</code>, which can be used
+           to tell xterm to use function-key definitions from the termcap
+           (or terminfo) which it uses to set $TERM on startup.
+
+       <li>add resources <code>altIsNotMeta</code> and
+           <code>altSendsEscape</code> to allow one to use Alt-keys like the
+           meta-key even if they are bound to different keycodes (prompted by
+           discussion with Daniel Jacobowitz).
+
+       <li>revert a change from <a href="#xterm_216">patch #216</a>
+           that unnecessarily made the meta modifier override
+           the <code>eightBitInput</code> resource if the alt- and
+           meta-modifiers happened to overlap
+           (report/patch by Daniel Jacobowitz).
+
+       <li>correct associated font for active icon for colored text
+           (broken in <a href="#xterm_224">patch #224</a>).
+
+       <li>correct ifdef's for Darwin (patch by Emanuele Giaquinta).
+
+       <li>add <code>highlightTextColor</code> resource, and options
+           <code>-selfg</code>, <code>-selbg</code> like <code>xwsh</code>
+           (adapted from patch by Victor Vaile).
+
+       <li>revise <code>find_closest_color()</code> function to address
+           concern about borrowing from <code>Tcl/Tk</code>
+           (request by Dan McNichol).
+
+       <li>add "spawn-new-terminal" action, which can be assigned to key
+           translation, allowing one to spawn a new copy of xterm using
+           the current process' working directory (adapted from patch
+           by Daniel Colascione).
+
+       <li>improve select/paste between UTF-8 and Latin1 xterms by adapting
+           the translations from <a href="#xterm_185">patch #185</a>.
+           Extend that to include Unicode fullwidth forms FF00-FF5E.
+           Also modify select/paste of DEC line-drawing characters in
+           Latin1 mode to use ASCII characters.
+
+       <li>add "Enable Bell Urgency" to VT Options menu, removed "Enable
+           Margin Bell".
+
+       <li>add <code>bellIsUrgent</code> resource to control whether the
+           Urgency hint is set/reset.
+
+       <li>modify to set Urgency window manager hint on bell, reset it on
+           Focus-In event (patch by Emanuele Giaquinta).
+
+       <li>add <code>--disable-setgid</code> configure option (request by
+           Miroslav Lichvar).
+
+       <li>fix a possible infinite loop in last change to
+           <code>dabbrev-expand()</code> (patch by Emanuele Giaquinta).
+
+       <li>modify initialization to set the pty erase value if the
+           <code>erase</code> is set in the <code>ttyModes</code> resource. 
+           This overrides the <code>ptyInitialErase</code> setting (request by
+           Llu&#237;s Batlle i Rossell).
+
+       <li>add <code>initialFont</code> resource to xterm widget, like
+           tek-widget (Debian #299669).
+
+       <li>amend change to <code>boldMode</code> from
+           <a href="#xterm_223">patch #223</a> for Debian #347790.
+           As noted in Debian #412599, that made xterm
+           no longer match the documented behavior.
+           Add new resource <code>alwaysBoldMode</code>
+           to allow overriding the comparison
+           between normal/bold fonts when deciding whether to use overstriking
+           to simulate bold fonts.
+
+       <li>restore background color in ClearCurBackground(), omitted in
+           changes for <a href="#xterm_223">patch #223</a> (report by
+           Miroslav Lichvar).
+
+       <li>correct logic for repainting double-width TrueType characters
+           (prompted by test-case for Novell #246573).
+
+       <li>add a check to avoid trying to repeat a multibyte character
+           (report by Sami Farin).
+
+       <li>modify parameter to <code>XftNameParse()</code> to select wide
+           face-name as needed, to make <code>-fd</code> option work (patch by
+           Mike Fabian, Novell #246573).
+
+       <li>correct logic for mouse highlight tracking's abort sequence,
+           broken in a restructuring modification from
+           <a href="#xterm_224">patch #224</a>
+           (report by Thomas Wolff).
+
+       <li>revert the simplification of blinking cursor, since that broke
+           the xor'ing introduced in <a href="#xterm_193">patch #193</a>
+           (report by Thomas Wolff).
+</ul>
+
+<H1><A NAME="xterm_224">Patch #224 - 2007/2/11</A></H1>
+<ul>
+       <li>simplify code for set/reset mode for blinking cursor 
+           (patch by Emanuele Giaquinta).
+
+       <li>modify <code>dabbrev-expand()</code> to restart after the last
+           match (patch by Emanuele Giaquinta).
+
+       <li>add control sequences for enabling/disabling focus in/out event
+           reporting (request by Bram Moolenaar).
+
+       <li>improve startup performance of menus by adding resource setting
+           <code>menuLocale</code> which can be set to override X's
+           lengthy initialization of fontsets - which are seldom used
+           for the <code>Xaw</code> popup menus (adapted from patch by
+           Dave Coffin).
+
+       <li>modify do_precomposition() function and make-compose.sh to handle
+           21-bit codes vs the 16-bit codes those were written for, and
+           fix a few mis-sorted codes
+           (patch by Thomas Wolff).
+
+       <li>handle special case in <code>-cjk_width</code>
+           which unexpectedly caused a character's width to change when
+           a combining character
+           (patch by Thomas Wolff)
+
+       <li>fix build for GNU/KFreeBSD (Debian #40111).
+
+       <li>consolidate GC creation/updating into a single module to reduce GC
+           manipulation (prompted by Debian #389476, though a complete fix
+           would involve optimizing the scrolling behavior).
+
+       <li>fix ifdef of xtermCellWidth(), which broke for a case without
+           TrueType and without wide-character support (report by Martin
+           Pirker).
+
+       <li>undo a comparison in <code>handle_translated_exposure</code> which
+           did not work due to X server optimization.  That caused the
+           inner border to be repainted with unexpected colors when handling
+           a repaint, e.g., after switching to/from another workspace
+           (Debian #401726, Redhat Bugzilla #223027).
+
+       <li>allow <code>-cr</code> option to override cursor color when
+           <code>-ah</code> option is used (Debian #406502).
+
+       <li>add a note in xterm's manpage explaining that the <code>-bw</code>
+           (or <code>-w</code>) option is only used by the window manager,
+           if at all (Debian #405043).
+
+       <li>make <code>Selection</code> of <code>VT&nbsp;Fonts</code> work with
+           <code>selectToClipboard</code> resource.
+
+       <li>correct length calculation for <code>Selection</code> entry of
+           <code>VT&nbsp;Fonts</code> menu, broken since it ignored the
+           actual selection length since X11R4.
+
+       <li>fixes for fontsize changes with <code>-fa</code> option (Redhat
+           Bugzilla #222340).
+</ul>
+
+<H1><A NAME="xterm_223">Patch #223 - 2006/11/30</A></H1>
+<ul>
+       <li>add <code>--enable-rectangles</code> configure option (request by
+           Martin Pirker).
+
+       <li>correct default value for <code>--with-symlink</code> configure
+           option.
+
+       <li>fixes configure script macros that use <code>$X_EXTRA_LIBS</code>.
+
+       <li>modify configure script to provide support for pre-package config
+           versions of Xft aka "FreeType".
+
+       <li>add the Xaw scrollbar translations resource to the xterm manpage,
+           add an example showing how to change the mouse button assignments
+           (Debian #382225).
+
+       <li>amend a change from <a href="#xterm_216">patch #216</a>,
+           which omitted modifiers for control, meta, etc., if they were
+           mixed with any other modifiers.  The intent of the change was
+           to avoid confusion with
+           <code>XK_Mode_switch</code>
+            and <code>XK_ISO_Level3_Shift</code>;
+           the check is now done explicitly (report by Daniel Jacobowitz).
+
+       <li>interpret a negative value for <code>modifyCursorKeys</code>
+           or <code>modifyFunctionKeys</code> resources to disable the
+           respective features (prompted by Novell #220728).
+
+       <li>amend cell-width computation for FreeType from
+           <a href="#xterm_217">patch #217</a>, which did not work
+           for VT100 line-drawing characters (Debian #399638, GenToo #147111).
+
+       <li>amend a change from <a href="#xterm_216">patch #216</a>,
+           which made alt-modifier on a cursor-key send a modifier parameter
+           (Novell #220728).
+
+       <li>correct an off-by-one that made DECCRA not work (report/patch by
+           Martin Pirker).
+
+       <li>revert an optimization in SGR_Foreground() and SGR_Background
+           from <a href="#xterm_209">patch #209</a> (Debian #347722,
+           analysis by Pierre Lombard).
+
+       <li>fix for <code>boldMode</code> (Debian #347790, patch by Tim Pope).
+
+       <li>amend fix for <code>-iconic</code> in
+           <a href="#xterm_208">patch #208</a>,
+           which broke the positioning part of <code>-geom</code> with toolbar
+           configuration.
+
+       <li>fix to prevent indexing error in regular expressions (patch
+           by Dennis Schneider).
+
+       <li>fixes to make the internalBorder area not change color due to
+           reverseVideo and/or related exposure events.  The latter was a very
+           old bug exposed in <a href="#xterm_196">patch #196</a> (report by
+           Neil Hoggarth, also Debian #397624).
+</ul>
+
+<H1><A NAME="xterm_222">Patch #222 - 2006/10/17</A></H1>
+<ul>
+       <li>minor optimization for recoloring cursor via dynamic colors.
+
+       <li>fix a bug caused by restructuring of tek4014 widget (report by Paul
+           Schenkeveld)
+</ul>
+
+<H1><A NAME="xterm_221">Patch #221 - 2006/10/1</A></H1>
+<ul>
+       <li>fix for regular expressions:  the code which converted the column
+           offset within a line did not check properly for the end of a line,
+           and if allowed to match the whole line, would select the beginning
+           of the following line.  If the following line were empty, in turn
+           it would select from the next, etc.  (report by Sean
+           Reifschneider).
+
+       <li>minor optimization of color allocation to avoid repainting the
+           screen if the corresponding color had not been allocated.
+
+       <li>fixes for vttests/256colors.pl (report by Egmont Koblinger).
+
+       <li>add terminfo building block entries for modifiers of the 6-key
+           editing keypad.
+
+       <li>fix for initialization of tek4014 which broke on QNX 6.1
+</ul>
+
+<H1><A NAME="xterm_220">Patch #220 - 2006/9/10</A></H1>
+<ul>
+       <li>make "xterm -t -iconic" work as expected, i.e., start in tek4014
+           mode, but iconified.
+</ul>
+
+<H1><A NAME="xterm_219">Patch #219 - 2006/9/4</A></H1>
+<ul>
+       <li>some internal restructuring to separate data for vt100 and tek4014
+           widgets.
+
+       <li>fix a few cases where form-events would be seen by the vt100
+           widget when built with the toolbar configuration.
+</ul>
+
+<H1><A NAME="xterm_218">Patch #218 - 2006/8/27</A></H1>
+<ul>
+       <li>change behavior when encountering an illegal character in a title
+           string.  Rather than reject the string, translate illegal
+           characters into "?" and use the string (requested by Thomas Wolff).
+
+       <li>improve checks for nonprinting characters in title strings
+           (report by Samuel Thibault).
+
+       <li>correct typo in menu labels, changing <code>print-redirect</code>
+           to <code>print-redir</code>, making it follow the manpage and
+           match the usage for the actions table (report by Samuel Thibault).
+
+       <li>correct a typo that prevents building with some older systems such
+           as Solaris 2.6 (report by Julian Bridle).
+</ul>
+
+<H1><A NAME="xterm_217">Patch #217 - 2006/8/20</A></H1>
+<ul>
+       <li>minor improvements to FreeType font layout and drawing.
+
+       <li>add a check in the ptyInitialErase logic to ensure that the
+           termcap was read (Redhat Bugzilla #201246).
+
+       <li>limit changes for reverse-video from
+           <a href="#xterm_216">patch #216</a> to cases where the
+           reverse-video command-line option is used
+           (report by Zdenek Sekera).
+
+       <li>correct bitmap-derived pointsizes for TrueType fonts; they should
+           be proportional to the square root of the area of the bitmap
+           fonts.
+
+       <li>add resources to specify pointsize of TrueType fonts (request
+           by Reuben Thomas).
+
+       <li>improve install of terminfo by filtering out harmless messages
+           related to extended capabilities.  At the same time, use ncurses
+           tic to compile the extended capabilities if possible
+           (report by Zdenek Sekera).
+
+       <li>update "xterm+pcfkeys" terminfo entry to correspond to
+           <a href="#xterm_216">patch #216</a>.
+</ul>
+
+<H1><A NAME="xterm_216">Patch #216 - 2006/8/3</A></H1>
+<ul>
+       <li>improve handling of <code>ConfigureNotify</code> events by checking
+           if there are further events in the queue which obsolete the current
+           one (adapted from rxvt 2.7.5).  Only the normal normal
+           (non-toolbar) configuration is addressed in this patch.
+
+       <li>several changes to terminfo:
+       <ul>
+           <li>incorporate some minor changes from ncurses to help keep these
+               synchronized:
+           <dl>
+               <dt>2005-02-26
+               <dd>modify sgr/sgr0 in xterm-new to improve tgetent's derived "me".
+               <dt>2006-02-18
+               <dd>remove ncv flag from xterm-16color
+               <dt>2006-06-24
+               <dd>improve xterm-256color by combining the 16-color
+               setaf/setab strings with SGR 48,
+               and cancelling the setf/setb strings.
+           </dl>
+           <li>use extended function-key definitions for xterm-sun, xterm-sco
+               entries.
+
+           <li>add terminfo building-blocks corresponding to the
+               <code>modifyFunctionKeys</code>
+               and <code>modifyCursorKeys</code> resources.
+       </ul>
+
+       <li>ifdef'd Sun function-key feature to make it optional, like HP and
+           SCO.
+
+       <li>extend table for termcap-query feature through F63, and updated
+           tcapquery.pl to match.
+
+       <li>modify logic for function-key input processing to allow function
+           key numbers which are constructed by control- and shift-modifiers
+           to extend beyond X's hardcoded limit of 35.
+
+       <li>add control sequence to set or reset the <code>eightBitInput</code>
+           resource.
+
+       <li>change default resource <code>modifyFunctionKeys</code> to 2
+           to avoid sending SS3 with parameters (report by Kalle Olavi Niemitalo).
+
+       <li>add control sequences for setting and resetting the values of the
+           <code>modifyCursorKeys</code>,
+           <code>modifyFunctionKeys</code> and
+           <code>modifyOtherKeys</code> resources.
+
+       <li>add <code>modifyFunctionKeys</code> resource like
+           <code>modifyCursorKeys</code>.
+           Setting this to zero allows one to use the control- and
+           shift-modifiers to construct function key strings,
+           for terminals using many function keys,
+           e.g., for <code>xterm-sun</code> or <code>xterm-sco</code>.
+
+       <li>modify screen responses and function-key logic to reduce the
+           number of writes made, to make it less likely that an application
+           would read only part of a function-key in a read operation
+           (suggested by John E Urbanczyk).
+
+       <li>add <code>combiningChars</code> resource, which allows the user to
+           specify the maximum number of combining characters that xterm will
+           store for each cell in wide-character mode (prompted by request by
+           Markus Kuhn to increase the limit from 2).
+
+       <li>improve logic in <code>metaSendsEscape</code> in case the Alt-
+           and Meta-keys are mapped to different modifiers.  That allows one
+           to use the Alt-key for shifting in the <code>eightBitInput</code>
+           and use a Meta-key modifier to prefix the result with an
+           <code>&lt;ESC&gt;</code>.
+
+       <li>improve <code>modifyCursorKeys</code> logic to prevent it from
+           modifying codes where <code>eightBitInput</code> or
+           <code>metaSendsEscape</code> are set
+           (request by Dan Nicolaescu).
+
+       <li>improve <code>modifyCursorKeys</code> logic to prevent it from
+           changing the user input when other modifiers such as AltGr are used
+           (report by Thomas Wolff).
+
+       <li>extend <code>modifyCursorKeys</code> to include the numeric keypad
+           when in application mode.
+
+       <li>improve <code>-reverse</code> (<code>-rv</code>) option
+           (patch by Jason Vas Dias, Redhat #189161).
+
+       <li>workaround for color resources on Fedora-5 which made the toolbar
+           colors inconsistent.
+
+       <li>corrected calls used for <code>--disable-setuid</code> option,
+           add debugging traces to help diagnose this area.
+
+       <li>modify configure script to ensure that <code>USE_UTMP_SETGID</code>
+           is defined only if the check for POSIX saved-ids succeeds, or
+           corresponds to one of the BSD systems known to have a workable
+           <code>setegid</code> function.
+
+       <li>extend configure check for POSIX saved-ids to include BSD systems
+
+       <li>modify CF_SYSV configure macro to work with gcc on HPUX 10.20,
+           whose broken
+           <code>&lt;term.h&gt;</code> relies on including
+           <code>&lt;termios.h&gt;</code>.
+
+       <li>change order of setuid/setgid ifdef checks in Imakefile to make
+           it simpler to produce a setgid install, allowing the latter to
+           override the former (prompted by an XFree86 commit).
+
+       <li>adapt a fix for setgid support from subsequent XFree86 changes
+           (patch by Emanuele Giaquinta).
+
+       <li>further improve setgid support (patches by Emanuele Giaquinta).
+</ul>
+
+<H1><A NAME="xterm_215">Patch #215 - 2006/6/19 - XFree86 4.6.99.2</A></H1>
+<ul>
+       <li>improve setgid support by exploiting the saved-ids feature on which
+           it relies (patch by Emanuele Giaquinta).
+
+       <li>make the <code>modifyOtherKeys</code> resource disabled by default
+           since the intermediate setting altered some common bindings
+           (report by Emanuele Giaquinta).
+</ul>
+
+<H1><A NAME="xterm_214">Patch #214 - 2006/6/18 - XFree86 4.6.99.2</A></H1>
+<ul>
+       <li>modify makefile rule for ctlseqs.txt to strip backspace/overstrikes,
+           and add a copy of ctlseqs.txt to the source tarballs (requests by
+           Bram Moolenaar, Emanuele Giaquinta).
+
+       <li>add <code>modifyOtherKeys</code> resource, analogous to the
+           <code>modifyCursorKeys</code> resource.  This applies to keys that
+           normally would transmit nothing when a given modifier is applied
+           (request by Dan Nicolaescu).
+
+       <li>add <code>default</code> to the acceptable values for the
+           <code>keyboardType</code> resource, allowing the <code>-kt</code>
+           command-line option to override app-defaults resource settings of
+           <code>sunKeyboard</code>, etc.
+
+       <li>correct ifdef's for <code>XkbBell()</code> which used the header
+           file but not the corresponding function in
+           <a href="#xterm_175">patch #175</a>
+           (report by Zach Beane).
+
+       <li>add xterm manpage to the <code>--with-symlink</code> logic.
+
+       <li>regenerated configure script to omit some debugging artifacts of
+           the SIGWINCH test.
+
+       <li>fix <code>install-man</code> rule in <code>Makefile.in</code> to
+           avoid including the <code>$(DESTDIR)</code> value in substitutions
+           made on the manpages (patch by Emanuele Giaquinta).
+
+       <li>improved fix for cursor deallocation
+           (Redhat #186935, patch by Jason Vas Dias).
+
+       <li>improve checks for setuid/setgid operation to accommodate limited
+           resource management in some kernels (GenToo #193238).
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_213">Patch #213 - 2006/4/30 - XFree86 4.5.99.905</A></H1>
+<ul>
+       <li>minor optimization to cell layout; will use that to simplify some
+           logic and allow for more than two combining characters in another
+           patch.
+
+       <li>add <code>utf8Latin1</code> resource to make optional the
+           feature from <a href="#xterm_209">patch #209</a> which
+           allowed ISO-8859-1 fonts to be used in cases
+           where a wide font was given.  This would only
+           work for the special case where the user normally used Latin-1
+           and wanted some wide characters (report by Rostislav Krasny).
+
+       <li>add <code>utf8Title</code> resource to manpage (Novell #52655).
+
+       <li>fix typo in table entry for <code>utf8Title</code> resource which
+           made it treated as an integer rather than boolean (patch by Mike
+           Fabian, Novell #52655).
+</ul>
+
+<H1><A NAME="xterm_212">Patch #212 - 2006/4/9 - XFree86 4.5.99.904</A></H1>
+<ul>
+       <li>improve description of <code>forceBoxChars</code> in manpage
+           (discussion with Joe Wells).
+
+       <li>set checkmark for "Select To Clipboard" menu entry on startup,
+           from resource setting.
+
+       <li>update manpage to note that <code>*customization:color</code> is
+           not needed, though it is useful (Redhat #188034).
+
+       <li>add underscore to sample pattern for URL in <code>XTerm.ad</code>
+           (Redhat #188037).
+
+       <li>modify install rule for manpage to use the configured app-defaults
+           directory (Redhat #188031).
+
+       <li>add checks in <code>releaseCursorGCs()</code> to ensure GC's are
+           distinct, needed since memory leak changes for
+           <a href="#xterm_208">patch #208</a>
+           (Redhat #186935, patch by Jason Vas Dias).
+
+       <li>modify <code>Imakefile</code> definitions to allow
+           <code>imake</code> to set <code>InstallXtermSetGID</code>.
+           Add symbol <code>InstGidFlags</code>.
+
+       <li>add configure script check to ensure that SIGWINCH if defined even
+           when headers undefine this as a side-effect of
+           <code>_POSIX_C_SOURCE</code>, etc.
+
+       <li>resync with XFree86 CVS
+       <ul>
+          <li>ifdef-out chmod of terminal device for OS/2 (XFree86 #1663,
+              Frank Giessler).
+          <li>move new <code>Imakefile</code> chunk which defines
+              <code>$(CSGIDFLAGS)</code> before DEFINES,
+              e.g., for IRIX64 (Marc La France).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_211">Patch #211 - 2006/3/19 - XFree86 4.5.99.902</A></H1>
+<ul>
+       <li>modify prefix/suffix transformation in makefile to make
+           <code>uxterm</code> install properly on Cygwin.
+
+       <li>restore the sizeof-comparison for <code>struct lastlog</code>
+           added in <a href="#xterm_208">patch #208</a>,
+           rendered (mostly) obsolete in <a href="#xterm_210">patch #210</a>,
+           since an imake configuration can still turn that code on
+           (prompted by comment by David Dawes).
+
+       <li>remove feature for <code>FreeBSDArchitecture</code> from
+           <code>Imakefile</code> which would install xterm using the
+           <code>utmp</code> group since a standard FreeBSD system has no such
+           group, though it would support this configuration.  FreeBSD
+           packager uses the <code>configure</code> script, which can make the
+           appropriate check (prompted by comment by David Dawes).
+
+       <li>fixes for gcc redefinition warnings when built using imake
+           (reports by David Dawes, Marc La France).
+</ul>
+
+<H1><A NAME="xterm_210">Patch #210 - 2006/3/12 - XFree86 4.5.99.902</A></H1>
+<ul>
+       <li>add configure check for workaround in
+           <a href="#xterm_208">patch #208</a>
+           for Solaris' inconsistent support for struct lastlog to quiet
+           compiler warnings
+           (prompted by David Dawes commit message for XFree86).
+
+       <li>fixes for BASE64 selection manipulation,
+           e.g., ensure that the string
+           terminator is written after cut-buffer data (report by Joe Allen).
+
+       <li>add vttests/paste64.pl script to test experimental option for
+           setting/getting selection data.
+
+       <li>add some error-checking in fontutils.c
+           (prompted by David Dawes commit message for XFree86).
+
+       <li>change xterm manpage to show the actual color resource names
+           <code>XtDefaultForeground</code> and
+           <code>XtDefaultBackground</code> rather than black and white
+           (prompted by discussion with Emanuele Giaquinta).
+
+       <li>add <code>utf8Title</code> resource and menu entry, allowing the
+           user to control whether title strings are interpreted as ISO-8859-1
+           or UTF-8 encoding (Novell #52655, #113206).
+
+       <li>change order of ifdef's for utempter versus platforms in
+           <code>Imakefile</code> to ensure a proper value for
+           <code>InstallXtermSetGID</code>
+           (prompted by Marc La France commit message for XFree86).
+
+       <li>update the cursor GCs when menu entry for reverse video is toggled.
+           (Redhat #183993).
+
+       <li>a memory-leak fix for <code>set_cursor_gcs()</code>
+           in <a href="#xterm_208">patch #208</a> broke the
+           <code>-cm</code> option (Redhat #182382).
+</ul>
+
+<H1><A NAME="xterm_209">Patch #209 - 2006/2/12 - XFree86 4.5.99.22</A></H1>
+<ul>
+       <li>remove <code>setf</code> and <code>setb</code> from
+           <code>xterm-256color</code> terminfo entry to avoid issues with
+           applications that ignore the ANSI strings (report by Emanuele
+           Giaquinta).
+
+       <li>remove obsolete references to "Xorg" to avoid confusion with
+           "X.org" (prompted by David Dawes commit message for XFree86).
+
+       <li>improve initial layout performance for the toolbar configuration
+           by precalculating the height of the toolbar.
+
+       <li>remove menu entry for "Enable Curses Emulation" (to make room for
+           "Select To Clipboard").
+
+       <li>add resource <code>selectToClipboard</code>,
+           action <code>set-select</code> and a menu entry to allow
+           users to switch between PRIMARY and CLIPBOARD for select/paste.
+
+       <li>allow cursor to have the same color as foreground (text), since it
+           is rendered as reverse (Debian #350664).
+
+       <li>amend change for loading <code>utf8Fonts</code> resource from <a
+           href="#xterm_204">patch #204</a> to allow an ISO-8859-1 "normal"
+           font to be combined with an ISO-10646 font if the latter is given
+           via the <code>-fw</code> option or its corresponding resource
+           value (prompted by comment in Novell #49305).
+
+       <li>add <code>TIOCSCTTY</code> <code>ioctl()</code> ifdef'd for
+           <code>__GNU__</code> to set the controlling terminal (Debian
+           #348457).
+
+       <li>add configure option <code>--disable-leaks</code>.
+
+       <li>add a check in <code>Bell</code> to ensure that the VT100 widget
+           is realized, since it may be called by <code>xtermLoadFont</code>
+           given an incorrect font resource (Redhat #180450).
+
+       <li>improve initialization of wide-bold font by not using the derived
+           value when it happens to have few glyphs (report by Mboso Sampson).
+
+       <li>improve dynamic colors by not repainting the screen if only the
+           cursor color changes (request by Bram Moolenaar).
+
+       <li>fix menu initialization for tek4014 window broken in
+           <a href="#xterm_206">patch #206</a>.
+
+       <li>typo in manpage (Debian #351425).
+
+       <li>correct loop logic in <code>dotext</code> to prevent an infinite
+           loop if a wide character was just at the right margin when wrapping
+           was disabled (report by Serge van den Boom).
+
+       <li>initialize the saved-cursor data so a restore-cursor operation
+           without a preceding save-cursor operation will not modify the
+           foreground color.
+
+       <li>add a new selection feature: regular expressions, and new resources
+           which specify what happens on multiple mouse clicks:
+           <code>on2Clicks</code>,
+           <code>on3Clicks</code>,
+           <code>on4Clicks</code> and
+           <code>on5Clicks</code>.
+
+       <li>revert the <code>XTerm.ad</code> change from
+           <a href="#xterm_208">patch #208</a> (Debian #348384).
+
+       <li>fixes for the print-window to make it handle combining
+           characters in UTF-8 mode.
+
+       <li>add check to ensure that double-clicking to extend selection will
+           not extend it into the scrollback area.  This still allows users
+           to scroll back and select text (Debian #347415).
+
+       <li>add configure option <code>--with-tty-group</code> to help work
+           around deficiencies in packager's build environment (Debian
+           #349142).
+
+       <li>fix typo in configure script option
+           <code>--disable-narrowproto</code>
+           (report by David Mart&#237;nez Moreno).
+
+       <li>amend CF_X_FREETYPE changes for <code>pkg-config</code> check to
+           ensure that <code>Xft</code> is known to that tool (report and
+           patch by Emanuele Giaquinta).
+
+       <li>add an ifdef to allow <code>./configure --disable-active-icon</code>
+           to work, broken by new code for testing memory leaks in
+           <a href="#xterm_208">patch #208</a> (report by Brian Lindholm).
+</ul>
+
+<H1><A NAME="xterm_208">Patch #208 - 2006/1/3 - XFree86 4.5.99.19</A></H1>
+<ul>
+       <li>add <code>charClass</code> resource to <code>XTerm.ad</code> and
+           <code>UXTerm.ad</code> which simplifies selecting URLs (prompted
+           by Kirill Ponomarew).
+
+       <li>modify install rule for <code>uxterm</code> to account for the
+           <code>--program-prefix</code>, etc., options by invoking the
+           transformed name of xterm rather than simply "xterm".
+
+       <li>modify configure <code>--with-app-defaults</code> option to allow
+           <code>--without-app-defaults</code>.
+
+       <li>add configure <code>--with-symlink</code> option to make it simpler
+           to install successive versions of <code>xterm</code> renamed using
+           the <code>--program-prefix</code>, etc., options with a symbolic
+           link pointing to the most recent.
+
+       <li>make <code>-iconic</code> option work with toolbar configuration
+           (GenToo #113604).
+
+       <li>suppress <code>lastlog</code> feature for 64-bit Solaris
+           configuration since that platform provides only a 32-bit interface
+           (report by Peter Bray).
+
+       <li>fix memory reallocation for the "UTF-8" menu entry when xterm is
+           started using the <code>+u8</code> option (reported by Jan Willem
+           Stumpel).
+
+       <li>add a configure check for the actual path of <code>luit</code>,
+           to work around broken <code>imake</code> configurations.
+
+       <li>add a configure check for <code>pkg-config</code> (Redhat Bugzilla
+           #173541).
+
+       <li>modify install-rule for <code>uxterm</code> to omit executable
+           suffix, e.g., for Cygwin.
+
+       <li>modify <code>sinstall.sh</code> to work around quirks in Cygwin
+           configuration.
+</ul>
+
+<H1><A NAME="xterm_207">Patch #207 - 2005/11/13 - XFree86 4.5.99.16</A></H1>
+<ul>
+       <li>enable <code>lastlogx</code> support for NetBSD (was added, but
+           not enabled in <a href="#xterm_186">patch #186</a>).
+
+       <li>work around broken <code>lastlog.h</code> in glibc 2.3.5, which
+           includes <code>utmp.h</code>.
+
+       <li>revert part of recent XFree86 Imakefile change, restoring the
+           <code>-I.</code> needed for <code>xmkmf</code> builds of xterm
+           (XFree86 Bugzilla #1633,
+            reports by Alexander Pohoyda,
+            Matthieu Herrb).
+
+       <li>change compiled-in default for <code>printerCommand</code>
+           resource to an empty string.  People who want to use the
+           printer should be able to read the manual (Debian #311490).
+
+       <li>modify <code>Imakefile</code> to work around old problems in
+           <code>imake</code> configuration to allow test-builds using
+           <code>xmkmf</code> on Linux.  (This was not noticed since several
+           releases had broken definitions relating to Xft which were harder
+           to work around).
+
+       <li>link <code>resize</code> for SCO platforms (Kean Johnston).
+</ul>
+
+<H1><A NAME="xterm_206">Patch #206 - 2005/11/3 - XFree86 4.5.99.15</A></H1>
+<ul>
+       <li>add configure <code>--with-app-defaults</code> option to allow
+           app-defaults directory for install-rules to be customized.
+
+       <li>remove default translations for <code>dabbrev-expand()</code>
+           due to conflicts with existing keyboard arrangements.
+
+       <li>remove redundant check for <code>_NET_WM_PID</code>
+           (report by Emanuele Giaquinta).
+
+       <li>set icon border width explicitly to work around fvwm problem
+           with active icon resizing (report by Steve Morris, analysis
+           by Dominik Vogt).
+
+       <li>modify resource files to make the font-resources a little
+           more specific, e.g., changing "*VT100*" to "*VT100.", to
+           make the distinction between VT100.font and VT100.utf8Fonts.font
+           sharper, in case a packager modifies one of those.
+
+       <li>expanded comments in <code>UXTerm.ad</code> regarding the
+           font resources (Debian #319179).
+
+       <li>add <code>--enable-narrowproto</code> configure option to
+           accommodate X.org "modular" build (report by Stephan Hermann,
+           GenToo #17220).
+
+       <li>fix typo in xterm.man description of <code>+wf</code> (patch
+           by Tobias Stoeckmann).
+
+       <li>add <code>scrollBarBorder</code> resource (request by Floyd L
+           Davidson).
+
+       <li>modify <code>xterm-new</code> terminfo entry to use capabilities
+           for shifted scroll forward/reverse as shifted cursor up/down.
+
+       <li>correct updating of checkmark for toolbar entry in popup menu
+           (report by Emanuele Giaquinta).
+
+       <li>fix ifdef's to allow compiling with toolbar and without tek4014
+           (patch by Emanuele Giaquinta).
+
+       <li>use <code>openpty()</code> for Darwin port (patch by Emanuele
+           Giaquinta).
+
+       <li>fix GenToo #90697 a different way, postponing the logic in
+           <code>SetupToolbar</code> until the toolbar is actually needed,
+           i.e., the <code>+tb</code> option is handled as expected.
+
+       <li>revert fix made in <a href="#xterm_203">patch #203</a> for GenToo
+           #90697.  That introduced a problem with the control mouse
+           click-popups, while most of the performance problems can be
+           resolved by restricting the menu fonts (report by Emanuele
+           Giaquinta).
+
+       <li>fix a file-descriptor leak when calling <code>openpty()</code>
+           (OpenBSD system/4561).
+
+       <li>make a special case of resizing work like vt100: a hard reset
+           also resets the 132/80 mode.  The code to support this was
+           present since X11R5, but not used because the corresponding
+           initial state of the <code>-132</code> option was not saved.
+
+       <li>restore window manager hints after <code>XtMakeResizeRequest()</code>
+           calls.  One instance from <a href="#xterm_205">patch #205</a>
+           resulted in the window manager displaying pixels rather than
+           than characters after selecting a different font size (FreeBSD
+           ports/87424).
+
+       <li>remove special case for Darwin in CF_XOPEN_SOURCE
+           (Emanuele Giaquinta).
+
+       <li>modify parsing of control sequence <code>CSI&nbsp;T</code>
+           to allow scroll-down
+           to be sent while mouse tracking is enabled (request by
+           D Hugh Redelmeier).
+
+       <li>correct termcap "me" (mode-end) string so it does not modify the
+           alternate character set (report by Andrey Chernov).
+
+       <li>correct size-comparison in HandleInterpret() broken in changes
+           from <a href="#xterm_201">patch #201</a> to allocate input
+           buffer (Debian #334317).
+
+       <li>amend adjustments for scrollbar layout from
+           <a href="#xterm_204">patch #204</a> to make
+           this apply only to the toolbar configuration.  In the non-toolbar
+           configuration, the resulting scrollbar was shifted by its
+           borderwidth (report by Matthieu Herrb).
+
+       <li>add select-cursor-extend() action.
+
+       <li>fix some broken href's in xterm.log.html, and typo in the
+           INSTALL file (report/patch by David Mart&#237;nez Moreno).
+
+       <li>modify <code>Imakefile</code> to use setgid mode for installing
+           with Linux, OpenBSD and FreeBSD.
+
+       <li>add configure --with-setuid and --with-reference options to
+           allow packagers more flexibility in customizing install
+           permissions.
+
+       <li>generalize and make optional (configure --with-utmp-setgid)
+           the change made for XFree86 Bugzilla #878 in
+           <a href="#xterm_205">patch #205</a>
+           (FreeBSD bug report #ports/86663).
+</ul>
+
+<H1><A NAME="xterm_205">Patch #205 - 2005/9/18 - XFree86 4.5.99.12</A></H1>
+<ul>
+       <li>correct a typo in CF_FUNC_TGETENT introduced in <a
+           href="#xterm_198">patch #198</a> fix for Gentoo #69926.
+
+       <li>implement logic in termcap query to process multiple parameters
+           as documented in ctlseqs.ms
+
+       <li>fix buffer size used for termcap query, which was not long enough
+           for the terminfo "colors" name (patch by Bradd W. Szonye).
+
+       <li>add configure option --enable-readline-mouse, which turns on the
+           experimental OPT_READLINE code (patch by Ilya Zakharevich).
+
+       <li>for FreeBSD, drop setuid privileges after startup
+           (XFree86 Bugzilla #878, report/patch by Alexander Pohoyda)
+
+       <li>add menu entry (alt-esc) and corresponding action (alt-sends-esc)
+           to toggle the <code>eightBitInput</code> resource setting.
+
+       <li>generate configure script with autoconf 2.52 (patched) to use
+           the feature therein which forces the script's locale to POSIX
+           (Gentoo Bugzilla #105369).
+
+       <li>modify computation of rows/columns on resize to avoid extending
+           beyond the given limits, e.g., if resizing in response to a
+           "maximize" in Gnome or KDE which do not use the window manager
+           hints for this case (Debian #289123, Novell #61153).
+
+       <li>modifications to work with z/OS 1.4 (Paul Giordano).
+
+       <li>improve error-reporting when chown/chmod of the pseudo-terminal
+           fails, e.g., if a copy of xterm which was designed to work with
+           old-style pseudo-terminals is not installed setuid or setgid
+           (report by Jeremy C. Reed).
+
+       <li>patches from Emanuele Giaquinta:
+           <ul>
+           <li>ctlseqs.ms says that primary and secondary DA accept a
+               nonzero parameter, which is incorrect.  Also modify code
+               to agree with this.
+
+           <li>correct a comment in 88colres.pl
+
+           <li>ctlseqs.ms says that the DEC Set/Reset control sequences for
+               the backarrow key make it send DEL/BS, respectively, while it's
+               the opposite.
+
+           <li>update the menu entries for the metaSendsEscape, deleteIsDEL
+               and numLock resources when changing them with the corresponding
+               DEC Set/Reset control sequences.
+           </ul>
+
+       <li>fixes for configure script:
+           <ul>
+           <li>add special case for QNX, defining _QNX_SOURCE.
+           <li>check for preprocessors which do not perform -U and -D options
+               in the given order.
+           <li>improve macro to determine gcc version
+           <li>improve check for Intel compiler and related warning options
+           </ul>
+
+       <li>update config.guess, config.sub
+
+       <li>improve fix from <a href="#xterm_198">patch #198</a> for
+           <code>Cleanup()</code> by ensuring it is not called from the
+           SIGCHLD handler (patch by Todd Miller (OpenBSD CVS)).
+
+       <li>eliminate a retry for a better-matching bold font, to work around
+           recent font server changes.
+
+       <li>fixes for Novell #113277:
+           <ul>
+           <li>specify weight for wide font which may be derived from
+               normal fontname.
+           <li>cache the derived wide- and widebolt-fontnames.
+           </ul>
+
+       <li>workaround for GenToo Bugzilla #100728.
+
+       <li>add menubar's border width to layout computation.  Normally this
+           is zero, but patterns such as <code>XTerm*borderWidth:1</code>
+           would give poor layout for the toolbar configuration.
+</ul>
+
+<H1><A NAME="xterm_204">Patch #204 - 2005/8/4 - XFree86 4.5.99.9</A></H1>
+<ul>
+       <li>work around quirk in shell which allowed user to "run" uxterm
+           script when there was no UTF-8 locale installed by entering
+           "sh -x uxterm".  Also popup an xmessage to show the problem
+           for users who run this via a GUI (Debian #318513).
+
+       <li>disallow changes to fonts, toolbar and scrollbar when the vt100
+           window is iconified, to simplify management of the active icon.
+
+       <li>fixes to make <code>-geom</code> option work properly with the
+           toolbar configuration (Gentoo Bugzilla #90717, #91967).
+
+       <li>minor improvements to scrollbar layout: ensure that the scrollbar
+           border is zero if the vt100 border is zero.
+
+       <li>improve initialization due to <code>utf8</code> resource by
+           loading the <code>utf8Fonts</code> resource in the case where
+           <code>locale</code> resource is false.  Also in this case, do
+           not disable switching UTF-8 mode on/off.
+
+       <li>minor optimization of TrueType font-loading, loads italic font
+           only when needed.
+
+       <li>correct variable used to store temporary result from lookup of bold
+           font, when initializing the wide-bold-font data and no immediate
+           match is found by asking for a bold variant of the wide-font.  The
+           result was to use overstriking rather than the actual bold font
+           (Debian #318162, patch by Eugene Konev).
+
+       <li>add checks to ensure vt100 widget is realized when it might be
+           updated via actions handled from a tek4014-only configuration.
+</ul>
+
+<H1><A NAME="xterm_203">Patch #203 - 2005/7/6 - XFree86 4.5.99.7</A></H1>
+<ul>
+       <li>modify initialization of <code>allowSendEvents</code> and
+           <code>allowWindowOps</code> to prevent modification with the
+           editres protocol.
+
+       <li>fix compiler warning for NetBSD by including util.h in main.c
+           (XFree86 Bugzilla #1596).
+
+       <li>fix to build on Darwin 8.x, which no longer provides
+           <code>setpgrp()</code> (patch by Min Sik Kim).
+
+       <li>adapted fixes for Legend (SCO) from diffs attached to
+           Freedesktop.Org Bugzilla #3180.
+
+       <li>fix typo in xterm manpage description of <code>-ls</code> option
+           (Freedesktop.Org Bugzilla #3543).
+
+       <li>add support for interpreting the underline attribute as an italic
+           font in Xft mode (patch by Chuck Blake).
+
+       <li>improve initialization of toolbar so that individual pulldown
+           menus are initialized on demand, as they are in the scenario
+           where they are invoked as popup menus (GenToo Bugzilla #90697).
+
+       <li>fix logic in <code>find_utmp</code>, which did not reset result
+           in <code>getutid()</code>, causing an infinite loop in some
+           conditions (report by Emil Mikulic).
+
+       <li>set the <code>_NET_WM_PID</code> property (GenToo Bugzilla #91008).
+
+       <li>modify ifdef's in ptyx.h and xterm_io.h to build with DragonFly
+           (patch by Jeroen Ruigrok).
+
+       <li>change default values for <code>minBufSize</code> and
+           <code>maxBufSize</code> to 4096 and 32768 respectively so that the
+           initial read request will match the value from before changes to
+           use <code>sched_yield()</code>.
+
+       <li>make paste of UTF-8 faster for Western character sets by checking
+           range of incoming data (patch by Joe Allen).
+
+       <li>add experimental option to allow
+           applications to get or set the selection data as a BASE64 string
+           (adapted from patch by Joe Allen).
+
+       <li>fix an off-by-one error parsing <code>-S/nn</code> option
+           (Debian #311438, report/fix by Peter Chubb).
+
+       <li>fix an initialization bug from
+           <a href="#xterm_201">patch #201</a> that broke logging
+           (report by Rodney Thayer).
+
+       <li>amend change to command-line processing in
+           <a href="#xterm_201">patch #201</a> to avoid
+           conflict with <code>-e</code> option (report by Servatius Brandt).
+
+       <li>suppress configure check for <code>_XOPEN_SOURCE</code> on
+           darwin.
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_202">Patch #202 - 2005/5/2 - XFree86 4.5.99.3</A></H1>
+<ul>
+       <li>add extended shift- and control-modifier cursor keys to
+           "xterm+pcfkeys" terminfo entry to correspond to ncurses 20050430
+           patch.
+
+       <li>fix a rare case where text would be written with the wrong colors
+           because output of scrolled text would reset the colors and the
+           new text would be written with the same colors (report/testcase
+           by Thomas Glanzmann).
+
+       <li>rename <code>$CMD</code> variable in <code>plink.sh</code> because
+           it is a reserved symbol in bash 3.00.16 (report by Ted Taylor).
+
+       <li>add environment variables <code>$XTERM_SHELL</code> and
+           <code>$XTERM_VERSION</code>
+           (request by Zdenek Sekera).
+
+       <li>corrected workaround for background color of menubar, which gave
+           a too-broad expression, coloring the background of the VT100
+           widget unless overridden by another resource setting.
+
+       <li>correct an error in the logic which decides when
+           <code>sched_yield()</code> is run; it would occasionally hang when
+           contending with other pseudo-terminal applications such as screen
+           (report by Kirill Ponomarew).
+
+       <li>modify initialization to decide whether to default to built-in
+           <code>wcwidth()</code> versus system's version based on the
+           starting locale and whether the system's version is poor quality
+           (suggested by Bram Moolenaar).
+
+       <li>update table for <code>mk_width()</code> from UnicodeData 4.1.0
+           using Markus Kuhn's <code>uniset</code> script.
+</ul>
+
+<H1><A NAME="xterm_201">Patch #201 - 2005/4/21 - XFree86 4.5.99.2</A></H1>
+<ul>
+       <li>improve resource files to show how the menubar and popup menus can
+           be colored (prompted by report by Joe Wells).
+
+       <li>modify parsing of OSC (and SOS, etc), strings so their contents
+           are not interpreted as UTF-8.  This allows non-ASCII title strings
+           to be set, provided that the window manager complies (report by
+           Thomas Wolff).
+
+       <li>improved some of the built-in line-drawing glyphs.
+
+       <li>correct color of "box" character drawn for line-drawing glyph 1
+           (report by Nicolas George).
+
+       <li>improve behavior when switching to UTF-8 mode after startup so
+           xterm will check if the current fonts are already wide
+           (ISO10646-1).  If they are not, xterm will use the
+           <code>utf8Fonts</code> subresource to load appropriate fonts
+           (request by Bram Moolenaar).
+
+       <li>modify logic for setting title-string so it applies to the current
+           widget rather than the vt100 widget.
+
+       <li>modify initialization for wide-bold fontname, to search for one
+           if none is given (report by Michael Schroeder).
+
+       <li>add resource <code>mkWidth</code> and command-line option
+           <code>-mk_width</code> to control whether xterm uses the built-in
+           version of wcwidth().
+
+       <li>add resource settings for minimum/maximum input buffer size, and
+           call to <code>sched_yield</code> to improve performance with newer
+           Linux kernels (adapted from patch by Nicolas George).
+
+       <li>correct computation of width for wide characters with the invisible
+           attribute (report by Thomas Wolff).
+
+       <li>modify interaction between <code>+u8</code> and <code>locale</code>
+           resource to allow the command-line option to override the resource
+           (requested by Thomas Wolff).
+
+       <li>add a limit check for scrolling margins in a one-line screen,
+           overlooked in fixes for
+           <a href="#xterm_198">patch #198</a> (Debian #297430).
+
+       <li>correct treatment of <code>iconBorderWidth</code> for resizing
+           an active-icon, and its description in manpage (Debian #296592).
+
+       <li>modify configure script <code>--disable-imake</code> to use the
+           script's definitions anyway if it cannot detect imake (prompted
+           by FreeBSD bug 77408).
+
+       <li>ignore error in the I/O initialization that tries to set the
+           tty to 7-bit input for the case where <code>eightBitInput</code>
+           resource is false (Debian #298551).
+
+       <li>modify command-processing to accept an optional parameter that
+           tells xterm which shell program to use (request by Zdenek Sekera).
+
+       <li>add simpler resource <code>keyboardType</code> which, when set,
+           overrides the individual keyboard-type resources and eliminates
+           the possibility of conflict between them.
+
+       <li>add initialization for <code>scoFunctionKeys</code> resource
+           (report by Rick K).
+
+       <li>correct logic of <code>ReallocateBufOffsets()</code> which did not
+           copy the content of the old screen buffer to the proper location,
+           making a repaint clear after switching to wide-character mode
+           (report by Bram Moolenaar):
+
+       <li>implement the remaining pieces to make xterm allocate cells for
+           wide-characters when the "UTF-8" menu entry is selected.  Also,
+           load the UTF-8 font when that menu entry is selected, or the escape
+           sequence for UTF-8 mode is received (report by Bram Moolenaar):
+
+       <li>add command-line options (<code>-tb</code>, <code>+tb</code>) and
+           resource <code>toolBar</code> to allow menu/toolbar to disabled or
+           enabled at startup (prompted by reports by Joe Wells).
+
+       <li>correct typo in configure script's --enable-dec-locator option
+           (report by Bram Moolenaar).
+</ul>
+
+<H1><A NAME="xterm_200">Patch #200 - 2005/2/6 - XFree86 4.4.99.23</A></H1>
+<ul>
+       <li>increase color pairs value for xterm-256color and xterm-88color to
+           match ncurses, which has an experimental option to support this.
+
+       <li>modify ifdef's to make AIX use termios rather than termio; the
+            struct sizes for the two were not the same.
+
+       <li>improve CF_WITH_IMAKE_CFLAGS configure macro script for
+           OSMAJORVERSION and OSMINORVERSION values, e.g., for Tru64 and AIX.
+
+       <li>modify ifdef to define USE_POSIX_TERMIOS for Darwin (patch by Min
+           Sik Kim).
+
+       <li>modify find_utmp() to initialize the whole utmpx struct (except
+           ut_id), since that is needed for OSF1 4.0D to prevent an infinite
+           loop on exit.
+
+       <li>add configure check before adding -D_POSIX_SOURCE since some
+           platforms predefine it, e.g., cygwin.
+
+       <li>add simplified sed expressions in CF_IMAKE_CFLAGS configure script
+           macro to ensure value for PROJECTROOT is quoted on Solaris, i.e.,
+           when nested <code>\(</code> and <code>\)</code> are not interpreted
+           correctly.
+
+       <li>correct DEC rectangle operations to reset state after completing
+           the operations.
+
+       <li>modify CASE_ST handling in charproc.c to ensure that the parse
+           state is reset even if xterm is not currently processing an OSC or
+           other string (patch by Johnny Billquist forwarded by Matthias
+           Scheler, NetBSD xsrc/29003).
+
+       <li>fix OS/2 build for innotek_libc (patch by David Yeo).
+
+       <li>fix a regression from <a href="#xterm_197">patch #197</a> fix for
+           Debian #277832 which disowned the selection if it was scrolled,
+           e.g., by the user pressing return at the bottom of the screen
+           (Debian #291787).
+
+       <li>move the warning/exit for missing $DISPLAY into the error handler
+           in case <code>-display</code> is given, and the connect fails for
+           some other reason.
+</ul>
+
+<H1><A NAME="xterm_199">Patch #199 - 2005/1/17 - XFree86 4.4.99.22</A></H1>
+<ul>
+       <li>instead of setting <code>$DISPLAY</code>, check for the unset
+           variable and warn/exit on this condition (comments by H Merijn
+           Brand and Bernhard R Link).
+
+       <li>fix a typo in Imakefile from <a href="#xterm_198">patch #198</a>
+           (reports/patches by Stefan Dirsch, Mike Castle).
+</ul>
+
+<H1><A NAME="xterm_198">Patch #198 - 2005/1/13 - XFree86 4.4.99.21</A></H1>
+<ul>
+       <li>set <code>$DISPLAY</code> to ":0" if it is not set.
+
+       <li>add <code>utmpDisplayId</code> resource to allow users to control
+           whether the display identifier (display number and screen number)
+           are retained in the connection information recorded in utmp
+           (discussion with Edoardo Tirtarahardja).
+
+       <li>add <code>bellOnReset</code> resource to allow users to disable
+           bell which sounds on hard reset since <a href="#xterm_183">patch
+           #183</a> changes to DECSCL (discussion with Danek Duvall).
+
+       <li>improve <code>$WINDOWID</code> for configuration with toolbar by
+           making it refer to the top-level shell rather than the parent of
+           the current window.  For that case, the parent is a form widget,
+           which does not have a name, which made the <code>$WINDOWID</code>
+           not very useful as a parameter for <code>xwininfo</code>
+           (suggested by Dave Bodenstab).
+
+       <li>fix a typo in WhichVFont() macro
+           from <a href="#xterm_197">patch #197</a> changes
+           which broke the --disable-active-icon configuration
+           (report by Ralf S. Engelschall).
+
+       <li>improve some limit checks (Gentoo Bugzilla #75604).
+
+       <li>add --disable-setuid option to configure script (Gentoo Bugzilla
+           #76543).
+
+       <li>add --disable-full-tgetent option to configure script, allowing one
+           to ignore a termcap library in favor of ncurses/curses (Gentoo
+           Bugzilla #69926).
+
+       <li>modify configure script to choose useful warning options for Intel
+           version 8.0 compiler.
+
+       <li>update config.guess, config.sub
+
+       <li>make active-icon work properly when TrueType fonts are used
+           (Debian #286068).
+
+       <li>correct change from <a href="#xterm_157">patch #157</a> which uses
+           getlogin() to check for an alias; the storage used for the related
+           getpwuid() call was overwritten by the data used for comparison
+           (patch by Per Hedeland).
+
+       <li>correct case of SCS for character set 0 (line-drawing) to allow it
+           to be selected into GR.
+
+       <li>fix a file-descriptor leak (Redhat Bugzilla #139597).
+
+       <li>modify <code>creat_as()</code> to only fork if xterm is actually
+           running as setuid and/or setgid.  This works around a Cygwin bug
+           which hangs when logging is enabled and makes xterm a little
+           faster for systems using interfaces such as utempter (report by
+           Al Goodman).
+
+       <li>modify <code>Cleanup()</code> to avoid operations such as X calls
+           that might use unsafe functions when it is called by a signal
+           handler (report by Michiel Boland).
+
+       <li>fix bugs in <a href="#xterm_191">patch #191</a> and in SRM changes
+           from <a href="#xterm_197">patch #197</a> that
+           broke DECSET 38:  switch to Tek4014 emulation (report by Dave
+           Bodenstab).
+
+       <li>fix for manpage escapes (Marc La France).
+
+       <li>improve on IRIX-specific change for Imakefile in XFree86 CVS versus
+           resize linking against termcap library to reflect definitions for
+           USE_TERMCAP in resize.c
+</ul>
+
+<H1><A NAME="xterm_197">Patch #197 - 2004/11/30 - XFree86 4.4.99.19</A></H1>
+<ul>
+       <li>modify configure script to remove empty "-DPROJECTROOT=" definition
+           which resulted unusable values for luit's default path.
+
+       <li>update precompose.c based on Unicode 4.0.1
+
+       <li>several minor fixes based on Intel compiler warnings.
+
+       <li>change default translations so a <code>BtnDown</code> which is
+           not recognized is simply ignored rather than emitting a bell.
+           That makes it less obtrusive when the user tries to use a mouse
+           which provides more capabilities than the X mouse driver supports,
+           e.g., one with a horizontal scroll wheel (Debian #265133).
+
+       <li>note in xterm's manpage that <code>translations</code> is not
+           specific to xterm (Debian #278897).
+
+       <li>modify uxterm script to use locale program to verify if the
+           derived locale is installed (Debian #246398).
+
+       <li>correct font handling for active icon when in UTF-8 mode (report
+           by Paolo Liberatore).
+
+       <li>make active-icon and toolbar configurations work together.
+
+       <li>modify the criteria for disowning primary selection.  Previously,
+           this happened anytime the cursor was moved before the end of the
+           selection.  That would ensure that any insert/delete of char or
+           line, as well as scrolling, would disown the selection.  The
+           new criteria change this to checking if the operations would
+           modify the data which is highlighted (Debian #277832).
+
+       <li>reimplement <code>DECALN</code> with functions for vt420 rectangles,
+           fixes selection for this case.
+
+       <li>implement vt420 rectangle operations.
+
+       <li>add parsing, for debug/test of vt220 soft-fonts.
+
+       <li>add menu entry, actions and escape sequence to allow
+           enabling/disabling toolbars at runtime.
+
+       <li>improve rendering for Xft, allow it to draw non-linedrawing
+           characters such as "pi", which were drawn from internal tables
+           with <a href="#xterm_180">patch #180</a>
+           (Freedesktop.org Bugzilla #1260).
+
+       <li>add configure option <code>--enable-mini-luit</code>, ifdef'd the
+           mini-luit feature with <code>OPT_MINI_LUIT</code>.
+
+       <li>add mini-luit feature, which supports Latin9 directly rather than
+           via luit, provided that Unicode fonts are used (Freedesktop.org
+           Bugzilla #1571, request by Stefan Dirsch, patch by Michael
+           Schroeder).
+
+       <li>for Linux, if IUTF8 is defined, e.g., on recent 2.6.x kernels,
+           set the corresponding flag for the slave pty, to enable UTF-8
+           interpretation of backspace in cooked mode (Freedesktop.org
+           Bugzilla #1578, request by Stefan Dirsch).
+
+       <li>modify <code>faceSize</code> resource to use a floating-point
+           internal value (adapted from patch by Sam Stephenson).
+
+       <li>correct handling selection of tabs over cleared space in UTF-8
+           mode.  In this special case, xterm represents the whitespace with
+           a null rather than a space character (Debian #276447).
+
+       <li>amend fix for infinite loop from <a href="#xterm_192">patch
+           #192</a> to check if there is wrapped text to output in a following
+           iteration (Debian #273202).
+
+       <li>fixes ifdef'd with <code>__INTERIX</code> to allow building with
+           Interix (Windows Services for UNIX) 3.5 using the xlibs libraries
+           from freedesktop.org (patch by Min Sik Kim).
+
+       <li>amend solution for Debian #252873, #260471 from <a
+           href="#xterm_194">patch #194</a> by making the cursor not
+           explicitly colored if only the foreground color is set, and the
+           cursor is on a blank space (Debian #275473).
+
+       <li>correct logic for send/receive mode (SRM) with regard to control
+           characters.
+
+       <li>fix masking of invisible text in wide-character mode, which did
+           not work for line-drawing characters.
+
+       <li>incorporate CF_XOPEN_SOURCE into configure script, replacing
+           CF_GNU_SOURCE.
+</ul>
+
+<H1><A NAME="xterm_196">Patch #196 - 2004/8/15 - XFree86 4.4.99.12</A></H1>
+<ul>
+       <li>add a special case to configure script to ignore NetBSD's
+           <code>grantpt()</code> which was recently added (but not part of a
+           release), until someone is able to ensure that xterm can use it
+           (report by Min Sik Kim).
+
+       <li>clear the buffer returned by getutid().  This fixes an infinite
+           loop on some platforms introduced in <a href="#xterm_193">patch
+           #193</a> by Debian #256468 fix (report by David Ellement).
+</ul>
+
+<H1><A NAME="xterm_195">Patch #195 - 2004/8/8 - XFree86 4.4.99.11</A></H1>
+<ul>
+       <li>correct length used for blinking text, make the last column blink
+           (patch by Alexander V Lukyanov).
+
+       <li>start changes to make doublesize characters work with TrueType
+           fonts (see <a href="#xterm_44">patch #44</a>).
+
+       <li>trim leading/trailing blanks from color resources as done for
+           other strings in <a href="#xterm_167">patch #167</a>.
+
+       <li>fixes for <code>showBlinkAsBold</code> resource (report by
+           Christoph Berg).
+</ul>
+
+<H1><A NAME="xterm_194">Patch #194 - 2004/7/27 - XFree86 4.4.99.11</A></H1>
+<ul>
+       <li>change clearing operations so foreground color attribute is not
+           set.  Usually this is benign, but in some cases when the cursor
+           color is not set explicitly, the cursor would show this color
+           (Debian #252873, #260471).
+
+       <li>add extra state (cursor-moved) to guard against deciding that the
+           cursor did not require repainting after an indexing operation
+           that leaves the cursor in the same location on the screen.
+
+       <li>fix a case where a full-screen indexing operation would
+           not restore the cursor-busy state.
+
+       <li>fix a repainting bug introduced in
+           <a href="#xterm_180">patch #180</a>:  when using a font
+           lacking line-drawing characters, a repaint of the screen could
+           skip horizontally an extra amount after filling in the missing
+           character (reports by Nicolas George, Hans de Goede, Redhat
+           Bugzilla #128341).
+
+       <li>rename terminfo fragment "xterm-pc-fkeys" to "xterm+pcfkeys" for
+           consistency with ncurses.
+</ul>
+
+<H1><A NAME="xterm_193">Patch #193 - 2004/7/19 - XFree86 4.4.99.10</A></H1>
+<ul>
+       <li>fix for wide-character selection from OpenBSD CVS
+           (report/patch by Matthieu Herrb).
+
+       <li>modify initialization and cleanup of utmp data to also compare
+           the <code>ut_line</code> member (Debian #256468).
+
+       <li>modify check on focus-change to ignore <code>FocusOut</code> events
+           generated by <code>XGrabKeyboard</code>.  This fixes a case where
+           the text cursor would act as if focus were lost when selecting the
+           "Secure Keyboard" menu option.
+
+       <li>add <code>gen-pc-fkeys.pl</code> script, use that to generate
+           terminfo fragment corresponding to the pc-style function keys.
+
+       <li>fix a case where the checkmark by the "VT220 Keyboard" menu entry
+           was not set on startup.
+
+       <li>separated two methods for making the cursor blink (menu and
+           escape sequence) by using the menu as the primary method and
+           XOR'ing the state of the escape sequence against that.
+
+       <li>modify logic for enabling blinking cursor via escape sequence as
+           well as the related save/restore operations so this is only
+           available if the <code>cursorBlink</code> resource was set on
+           startup.
+</ul>
+
+<H1><A NAME="xterm_192">Patch #192 - 2004/7/12 - XFree86 4.4.99.9</A></H1>
+<ul>
+       <li>change resource settings for color4 and color12, add some discussion
+           in <code>XTerm-col.ad</code> (Debian #241717).
+
+       <li>add a note in xterm manpage discussing the difference between
+           alt- and meta-keys, and the way the latter is used in the
+           <code>eightBitInput</code> resource.
+
+       <li>add a note in xterm manpage regarding possible conflict between
+           resource settings for <code>xterm.vt100.font</code> and
+           <code>xterm.vt100.utf8Fonts.font</code> (Debian #254650).
+
+       <li>add compile-time customization of <code>backarrowKeyIsErase</code>
+           and <code>ptyInitialErase</code> default resource values
+           (adapted from OpenBSD CVS).
+
+       <li>change parameter of <code>FIONREAD</code> <code>ioctl()</code> call
+           from long to int
+           (discussion on tech-x11@netbsd.org regarding LP64 by
+           John Heasley and Matthias Scheler).
+
+       <li>modify configure script options for Athena widgets to work as
+           expected for "--without-Xaw3d", etc., (GenToo Bugzilla #53455).
+
+       <li>add case to uxterm to accommodate locales ending with "@euro",
+           e.g., fr_FR.UTF-8@euro (Debian #255197, report/analysis by
+           Matthieu Lagouge).
+
+       <li>add special case for VT100 graphic's "box" character (discussion
+           with Ben Armstrong).
+
+       <li>add missing initialization for bitmap-font sizes needed to make
+           fonts menu work with TrueType fonts (report by Ben Armstrong).
+
+       <li>save the fontnames for bold fonts that are derived from normal
+           fonts, or from the <code>boldFont</code> resource, so the same
+           value is restored when switching with the VT Fonts menu (Debian
+           #256086).
+
+       <li>fix manpage preprocessing (Marc La France).
+
+       <li>fix typo in manpage's description of character classes (Debian
+           #257073).
+
+       <li>modify terminfo to accommodate luit, which relies on G1 being used
+           via an ISO-2022 escape sequence (Debian #254316, analysis by
+           Juliusz Chroboczek).
+
+       <li>modify Makefile.in rule for ctlseqs.txt to work around groff SGR
+           misfeature.
+
+       <li>modify <code>XTerm.ad</code> to set <code>saveLines</code> default
+           to 1024 (Redhat Bugzilla #127132).
+
+       <li>add a limit-check in <code>dotext()</code> to prevent infinite
+           loop in a corner case of UTF-8 configuration.
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_191">Patch #191 - 2004/6/6 - XFree86 4.4.99.7</A></H1>
+<ul>
+       <li>correct options parsing for <code>-into</code> option so it
+           can be combined with <code>-e</code> (Redhat Bugzilla #124518,
+           report/patch by James Armstrong).
+
+       <li>fix ifdef's for <code>OPT_COLOR_RES2</code>
+           so that the fake resource table introduced in
+           <a href="#xterm_188">patch #188</a>
+           is not compiled if it is empty.
+           This happened to work with gcc (report by Joel Konkle-Parker).
+
+       <li>reorganize ptydata.c to use one input buffer shared between
+           the VTxxx and tek4014 emulators.  In the new scheme, UTF-8
+           decoding is performed on characters as they are needed by the
+           state machine rather than on buffers as they are read.
+
+       <li>work around change in quoting of PROJECTROOT symbol when using
+           configure script, from changes made in
+           <a href="#xterm_187">patch #187</a> for CF_IMAKE_CFLAGS
+           (GenToo Bugzilla #50982).
+</ul>
+
+<H1><A NAME="xterm_190">Patch #190 - 2004/5/25 - XFree86 4.4.99.6</A></H1>
+<ul>
+       <li>correct state for values in the range 128-159 after translating
+           from UTF-8: this should be ignored unless the user overrides it
+           with the <code>allowC1Printable</code> resource (reported by
+           Simon Strandgaard).
+
+       <li>add configure-script check for nl_langinfo(CODESET), use this to
+           replace check of environment variables for UTF-8.
+
+       <li>change Makefile.in rules for 256colres.h and 88colres.h so they
+           are only made if they do not exist.  The maintainer-clean rule
+           will remove these files; they require perl to be made.
+
+       <li>remove check in configure script --enable-toolbar that suppressed
+           this option when building with Xaw7.
+
+       <li>apply fixes to Tektronix widget used for VT100 widget to make
+           toolbar work with Xaw7 (XFree86 4.x).
+</ul>
+
+<H1><A NAME="xterm_189">Patch #189 - 2004/5/16 - XFree86 4.4.99.6</A></H1>
+<ul>
+       <li>do not call xim_real_init() if <code>openIm</code> resource is
+           false (Debian #249025).
+
+       <li>minor improvements to built-in line-drawing.
+
+       <li>fix a few portability issues with dynamic abbreviation support,
+           i.e., did not compile on Tru64.
+
+       <li>modify constraints in form used to layout toolbar, to work with
+           newer Xaw in XFree86 4.x.
+</ul>
+
+<H1><A NAME="xterm_188">Patch #188 - 2004/5/12 - XFree86 4.4.99.6</A></H1>
+<ul>
+       <li>correct table entry for DEL in the ground state, which marked it
+           as a printable character from <a href="#xterm_171">patch #171</a>
+           (report by D Hugh Redelmeier).
+
+       <li>improve fix in <a href="#xterm_186">patch #186</a> for failure in
+           xim_real_init() by adding a sleep.
+
+       <li>fix a typo in os2main.c
+           (XFree86 Bugzilla #1358, report/patch by Frank Giessler).
+
+       <li>make escape sequence reporting dynamic colors consistent with the
+           logic that sets it; choosing the opposite color when reverse
+           video is set (XFree86 Bugzilla #1361, reported by Bradd W Szonye).
+
+       <li>modify initialization of 256- and 88-colors so that colors beyond
+           16 are normally not X resources.  This works around a hard-coded
+           limit in Xt which breaks xterm when 256-colors and luit are both
+           configured (report by Noah Friedman).
+
+       <li>remove <code>ncv</code> from <code>xterm-256color</code> terminfo
+           entry since it is no longer needed (report by Eli Zaretskii).
+
+       <li>add "erase2" and "eol2" keywords to <code>ttyModes</code> resource,
+           for recent/current FreeBSD.
+
+       <li>improve ifdef's for utempter library to omit direct calls to
+           <code>setutent()</code> or <code>getutent()</code> (adapted from
+           patch by Christian Biere).
+
+       <li>add dynamic abbreviation support like Emacs (patch by Tomasz
+           Cholewo).  This is ifdef'd with <code>OPT_DABBREV</code>, and
+           enabled via the configure script <code>--enable-dabbrev</code>
+           option.
+
+       <li>fix problem responding to session management events, e.g., which
+           would make logging out very slow (patch by Eddy De Greef, Debian
+           #233883).
+
+       <li>work around a newer bug in toolbar with XFree86 by forcing menus
+           to be fully initialized at startup.  In older versions of XFree86
+           and X11R6, it was possible to delay initialization of the menu
+           contents until it was popped up.  (The longstanding bug with
+           XFree86 4.x layout for toolbar still exists, though).
+
+       <li>modify <code>xtermAddInput</code> to work around core dump on
+           IRIX64 when initializing scrollbar translations if toolbar is
+           compiled-in.
+
+       <li>fix some minor conflicts in the 2-character entry names in the
+           termcap file.
+</ul>
+
+<H1><A NAME="xterm_187">Patch #187 - 2004/4/27 - XFree86 4.4.99.4</A></H1>
+<ul>
+       <li>change xterm version string to use <code>__vendorversion__</code>
+           where that is available, and "XTerm" otherwise.
+
+       <li>improve description of <code>utf8</code> resource in manpage
+           (Debian #179407).
+
+       <li>modify configure macros CF_IMAKE_CFLAGS and CF_ADD_CFLAGS to
+           handle <code>-D</code> options that define string values, e.g.,
+           for <code>XVENDORNAME</code>.
+
+       <li>modify configure macro CF_IMAKE_CFLAGS to allow (if
+           <code>$PATH</code> is set accordingly) to use the
+           <code>xmkmf</code> script within an X build tree.
+
+       <li>add missing <code>#undef OPT_SESSION_MGT</code> to xtermcfg.hin
+           to make the configure script's --disable-session-mgt option work.
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_186">Patch #186 - 2004/4/18 - XFree86 4.4.99.4</A></H1>
+<ul>
+       <li>change reset on <code>DECSCL</code> to a soft-reset (appears some
+           DEC manuals have errors).
+
+       <li>add a section to ctlseqs.ms elaborating on normal/alternate screens.
+
+       <li>modify initialization of Acolors[] so that any XtDefaultForeground
+           or XtDefaultBackground values are translated as in the Tcolors[],
+           to use the window's foreground/background colors.  This affects
+           the <code>colorBD</code> and similar resources which normally have
+           no explicit color assigned.
+
+       <li>modify initialization of Tektronix window so that control sequences
+           setting its color before the window is popped up will apply to
+           its initial colors.
+
+       <li>add control sequence to set Tektronix window's text-cursor.
+
+       <li>modify initialization of terminal colors, e.g., mouse pointer and
+           text cursor, to treat <code>XtDefaultForeground</code> and
+           <code>XtDefaultBackground</code> values as the actual foreground
+           and background colors of the terminal rather than white and black
+           (Debian #241717).
+
+       <li>remove an incorrect comparison against <code>PTYCHARLEN</code> in
+           parsing the <code>-S</code> option (report by Michael B Taylor).
+
+       <li>minor restructuring of terminfo/termcap files, having noted some
+           packager's customizations which caused the structure to be
+           confused.
+
+       <li>eliminate an isolated use of MIN/MAX in charproc.c
+
+       <li>replace <code>XtExtdefaultfont</code> and
+           <code>XtExtdefaultbackground</code> by their more familiar
+           equivalents
+           <code>XtDefaultFont</code> and
+           <code>XtDefaultBackground</code>.
+
+       <li>replace ifdef's using <code>SCO</code>, <code>sco</code> and
+           <code>SCO325</code> with <code>__SCO__</code>
+           (XFree86 Bugzilla #1301, Kean Johnston).
+           But ensure that it still builds on platforms where this symbol
+           is not defined.
+
+       <li>add <code>scoFunctionKeys</code> resource, to match manpage.
+
+       <li>update manpage discussion of menus and related resources.
+
+       <li>enable utmpx support for NetBSD 1.6C and newer (patch by
+           Matthias Scheler).
+
+       <li>add a note in the manpage discussing xterm's treatment of open
+           file-descriptors (request by Dan Shearer).
+
+       <li>modify <code>Help()</code> to make "xterm -h" write to standard
+           output rather than standard error (patch by Bram Moolenaar).
+
+       <li>check for type of failure in xim_real_init() to avoid looping when
+           the problem is an unsupported input method rather than a failure
+           to connect to the XIM server.  Problem was introduced in
+           <a href="#xterm_175">patch #175</a> (XFree86 Bugzilla #1306).
+
+       <li>modify <code>Imakefile</code> to remove dependency of "install"
+           target on the <code>xterm</code> executable to make installs from
+           tree without attempting to rebuild anything (commit by David Dawes,
+           report/patch from Lee Olsen).
+
+       <li>remove call to <code>ShowCursor</code> from
+           <code>SetCursorBlink()</code> since that is redundant,
+           and can cause display glitches if the cursor is already
+           blinking (XFree86 Bugzilla #1158, patch/report by Andreas Schwab).
+</ul>
+
+<H1><A NAME="xterm_185">Patch #185 - 2004/3/3 - XFree86 4.4</A></H1>
+<ul>
+       <li>fix tcap-query logic for the backspace key (XFree86 Bugzilla #1233,
+           report/patch by Anton Kovalenko).
+
+       <li>add test-scripts resize.pl and tcapquery.pl
+
+       <li>add translation to ASCII of commonly-used characters that groff
+           translates to Unicode, when the font in use does not provide the
+           corresponding glyphs (Debian #219551).
+
+       <li>modify RequestMaximize(), which performs maximize/restore via
+           control sequences, to account for window-frame (patch by
+           Jess Thrysoee).
+
+       <li>improve pattern used in <code>uxterm</code> to check for UTF-8
+           locale, e.g., for HPUX (patch by H Merijn Brand).
+
+       <li>add <code>-fd</code> option and resource
+           <code>faceNameDoublesize</code> to specify double-wide fonts with
+           Xft (adapted from patch by Zarick Lau).
+
+       <li>change a couple of resource classes from "Boolean" to specific
+           values: <code>freeBoldBox</code>, <code>forceBoxChars</code>.
+
+       <li>add resource <code>showMissingGlyphs</code> to outline places on
+           the screen where a font lacks the corresponding glyph.
+
+       <li>add resource <code>showBlinkAsBold</code> to control whether
+           blinking text should be shown as bold or actual blinking text.
+
+       <li>improve logic in ShowCursor() to avoid repainting the cursor when
+           it is already visible, e.g., in response to the DECTCEM escape
+           sequence.  This also addresses XFree86 Bugzilla #1158.
+
+       <li>implement blinking text, using the timer for blinking cursor.
+
+       <li>modify FreeType support to allow resizing the font, in the same
+           ways the window can be resized if fixed fonts are used.  The
+           relative font sizes are derived from the fixed font sizes.
+
+       <li>add menu items and corresponding actions for switching on/off
+           the UTF-8 mode and Xft (TrueType) support.
+
+       <li>add logic to handle switching UTF-8 mode on/off.  It worked if
+           the escape sequences were flushed, but if data was mixed in with
+           the same write, some were not handled properly (report by
+           Nicolas George).
+
+       <li>modify to allow turning UTF-8 mode on/off via escape sequence even
+           if <code>-wc</code> option was not given at startup (patch by Peter
+           Berg Larsen).
+
+       <li>amend fix for XFree86 Bugzilla #981, adjusting for savedlines value
+           (report by Tim Adye).
+
+       <li>fix a typo in computing relative font size (Jess Thrysoee).
+</ul>
+
+<H1><A NAME="xterm_184">Patch #184 - 2003/12/31 - XFree86 4.3.99.903</A></H1>
+<ul>
+       <li>improve configure-script checks for FreeType and related libraries,
+           using <code>xft-config</code> or <code>freetype-config</code>
+           scripts when available.
+
+       <li>fix configure-script check for <code>SYSV</code> definition by
+           ensuring whether <code>sys_errlist[]</code> is declared, and by
+           modifying the test program to include <code>X11/Intrinsic.h</code>
+           to check that <code>wchar_t</code> is declared consistently (report
+           by H Merijn Brand).
+</ul>
+
+<H1><A NAME="xterm_183">Patch #183 - 2003/12/26 - XFree86 4.3.99.903</A></H1>
+<ul>
+       <li>correct logic for configurations that may attempt to open both
+           old/new-style pseudoterminals.  In this case, the old-style are
+           preferred.  Logic was broken in <a href="#xterm_145">patch #145</a>
+           (XFree86 Bugzilla #997, report/patch by Kean Johnston).
+
+       <li>modify handling of <code>eightBitInput</code> resource in UTF-8
+           mode to translate the value into UTF-8.  Otherwise an illegal
+           UTF-8 code is sent to the application (report by Bram Moolenaar).
+
+       <li>modify <code>uxterm</code> script to interpret help and version
+           options so xterm does not always create a window when the user
+           requests this information (Debian #223926).
+
+       <li>add a limit check to ScrnTstWrapped() (XFree86 Bugzilla #981).
+
+       <li>modify DECSCL to perform a hard reset (RIS) as per DEC manuals.
+           Extended DECSCL to accept parameters for vt4XX and vt5xx terminals.
+
+       <li>correct logic for ANSI conformance level escape sequences, which
+           were confused with DEC conformance level escape sequences.
+
+       <li>correct state for vt52 shift-in/shift-out, which was not reset
+           properly after <a href="#xterm_171">patch #171</a>.
+
+       <li>correct handling of graphics characters for vt52 mode, which did
+           not display line-drawing characters after G1 fix from
+           <a href="#xterm_182">patch #182</a>.
+
+       <li>fixes for configure script to work with current Cygwin headers
+           and libraries.
+
+       <li>modify <code>Imakefile</code> to put the current directory at the
+           beginning of the include searchpath (patch by David Dawes).
+</ul>
+
+<H1><A NAME="xterm_182">Patch #182 - 2003/12/2 - XFree86 4.3.99.901</A></H1>
+<ul>
+       <li>correct logic for <code>metaSendsEscape</code> resource to allow
+           for the meta-right key to be tested.  Improve check for meta/alt
+           modifiers by dropping the assumption that a keysym is associated
+           with only one modifier, and by ignoring NoSymbol entries in the
+           xmodmap data (XFree86 Bugzilla #924, patch by David Dawes).
+
+       <li>correct wrapping logic for line-drawing characters written in
+           non-UTF-8 mode of xterm build for wide-characters (XFree86 Bugzilla
+           #918, report/patch by J&#x00fc;rgen Keil).
+
+       <li>improve manpage description of resources, in particular the
+           <code>utf8Fonts</code> class (XFree86 Bugzilla #905).
+
+       <li>add definitions to compile with glibc-based GNU/Hurd, GNU/KFreeBSD
+           and GNU/KNetBSD (XFree86 Bugzilla #893).
+
+       <li>compiler-warning fixes (patch by Christian Biere).
+
+       <li>add README.i18n (Tomohiro Kubota).
+
+       <li>correct initialization of G1 character set mapping, which used
+           line-drawing set as a result of confusion between "DEC Supplemental
+           Graphic" and "DEC Special Graphic" character sets
+           (see <a href="#xterm_34">patch #34</a> regarding DECSTR).
+
+       <li>correct ifdef in main.c for variable utret (patch by
+           Bernhard Rosenkraenzer).
+
+       <li>document in xterm's manpage how to use XFree86 ":unscaled" keyword
+           to suppress scaling of bold fonts.
+
+       <li>when deriving bold fontname from normal fontname, use the normal
+           font's average width to avoid for example selecting 7x13bold
+           from an 8x13 normal font (Debian #107769).
+</ul>
+
+<H1><A NAME="xterm_181">Patch #181 - 2003/10/26 - XFree86 4.3.99.15</A></H1>
+<ul>
+       <li>implement <code>boldMode</code> for wide-character logic in
+           <code>drawXtermText()</code> (report by Michael Schroeder).
+
+       <li>modify <code>UXTerm.ad</code> resource file to include
+           "XTerm-color" rather than "XTerm", in case the latter file contains
+           no color resource definitions, e.g., after <a
+           href="#xterm_180">patch #180</a>.
+
+       <li>add action <code>load-vt-fonts()</code> and configure option
+           <code>--enable-load-vt-fonts</code> which allows users to define
+           additional sets of VT-fonts which can be loaded at runtime.
+
+       <li>add logic to wide-character support which attempts to load fonts
+           specified by <code>utf8Fonts</code> subresources at startup.  The
+           subresources have the same names as the fonts which they replace,
+           e.g., <code>font</code>, <code>font1</code>, etc., so that the
+           ISO-10646-1 fonts can be specified in the <code>XTerm</code>
+           app-defaults file (adapted from patch by Tomohiro Kubota).
+
+       <li>improve Set Font escape string handling by making the relative
+           settings apply to the size of the font, as in shift keypad
+           plus/minus rather than the menu index.
+
+       <li>simplify parameter passing for the <code>set-vt-font</code> action
+           and related code.
+
+       <li>cleanup some include-ordering, moving some recently-added hardcoded
+           stuff into xterm.h where it will not interfere with the configure
+           script.
+
+       <li>modify <code>xtermAddInput()</code> (see note on augmentation in <a
+           href="#xterm_158">patch #158</a>) to use the complete set of
+           default keyboard translations so that one can use shifted pageup,
+           wheel mouse, etc., while the mouse pointer is over the scrollbar.
+           (Debian #178812).
+
+       <li>make save/restore mode controls apply to show/blink cursor states.
+
+       <li>add escape sequence to start/stop blinking cursor, which allows
+           implementing <code>cvvis</code> terminfo capability (request by
+           Nate Bargmann).
+
+       <li>add <code>indp</code> and <code>rin</code> to terminfo entry.
+
+       <li>fix an out-of-bounds array reference in ScrnRefresh() for wide
+           characters (report by Dan Harnett, patch by Todd Miller).
+           This bug dates from <a href="#xterm_141">patch #141</a>.
+</ul>
+
+<H1><A NAME="xterm_180">Patch #180 - 2003/10/12 - XFree86 4.3.99.15</A></H1>
+<ul>
+       <li>several fixes for rendering using Xft via option <code>-fa</code>:
+         <ul>
+         <li>translate Unicode values, i.e,. from UTF-8 output to xterm, for
+             line-drawing to xterm's internal code, etc., since TrueType fonts
+             generally do not have either set of line-drawing glyphs.  xterm
+             can draw these directly (report by Abigail Brady).
+         <li>pass 16-bit values rather than 8-bit values to
+             xtermXftDrawString() to allow for wide-characters.
+         <li>remove spurious check for <code>colorBDMode</code> resource in
+             logic that does bold fonts.
+         <li>implement underlining.
+         </ul>
+
+       <li>patches by Ilya Zakharevich:
+         <ul>
+         <li>improve drawXtermText() by making the recursive calls
+             communicate through arguments, and not through saving/restoring
+             global variables.
+
+         <li>make double-width characters work with <code>-u8</code> option.
+
+         <li>modify lookup of double-sized fonts by checking for a match
+             ignoring x/y resolution if the first check fails.
+         </ul>
+
+       <li>make height of TrueType fonts match ascent+descent (patch by
+           Keith Packard).
+
+       <li>correct configure-script check for imake $CFLAGS, which did not
+           check properly if imake was not available.
+
+       <li>correct install rule in Makefile.in for <code>uxterm</code>, which
+           was attempting to strip the script (newsgroup posting by Fernan
+           Aguero).
+
+       <li>correct AF/AB strings in termcap for xterm-256color and
+           xterm-88color entries (report by Josh Howard).
+
+       <li>update wcwidth.c to incorporate changes from Markus Kuhn's
+           2003-05-20 (Unicode 4.0) version of that file.
+
+       <li>modify <code>scroll-back</code> and <code>scroll-forw</code>
+           actions to accept an adjustment value, e.g.,
+           <pre>
+             <code>scroll-back(1, page-2)</code></pre>
+           to scroll back by 2 lines less than a page (patch by Greg
+           Klanderman).
+
+       <li>use color resource setting from Debian package for xterm VT100 widget,
+           since the choice of blues provides better contrast.
+
+       <li>remove color resources from <code>XTerm.ad</code>, leaving them
+           only in <code>XTerm-col.ad</code> (prompted by Debian package for
+           xterm).
+
+       <li>correct configure script option --enable-pty-handshake (report by
+           Paul Gilmartin).
+
+       <li>add <code>visualBellDelay</code> resource to modify the length of
+           time used for visual bell, for very slow displays or very fast
+           computers (reports by Ingo van Lil and Doug Toppin).
+
+       <li>correct logic for initializing dynamic highlight color (patch by
+           Jess Thrysoee).
+
+       <li>add a check for non-zero size in call to <code>XCopyArea()</code>
+           to accommodate a Solaris bug.
+
+       <li>correct typo in example for character classes in xterm manpage
+          (Debian #198910).
+
+       <li>link xterm with bind_on_load option on Darwin to work around a
+          deadlock in the dynamic loader when a signal is received while
+          the dynamic loader is looking up symbols (patches by Rob Braun,
+          Torrey Lyons).
+
+       <li>modify configure script to avoid using "head -1".
+
+       <li>update config.guess, config.sub
+
+       <li>modify ifdef's to work around inclusion of types FcChar32 and
+          XftCharSpec with FreeType 2.0 (see <a href="#xterm_175">patch #175</a>).
+
+       <li>modify the predictable version of the generated logfile name (see
+          <a href="#xterm_171">patch #171</a>) to append the process-id rather
+          than a random value.
+
+       <li>resync with XFree86 CVS
+       <ul>
+          <li>Enable SCO function keys in xterm
+          <li>Make Delete key send DEL by default on SCO in xterm
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_179">Patch #179 - 2003/5/21 - XFree86 4.3.99.5</A></H1>
+<ul>
+       <li>modify ifdef's for WTMPX_FILE to allow building on cygwin again.
+
+       <li>change the default of pty-handshaking configure option (and related
+           default for imake) to assume this feature is needed.
+
+       <li>add ifdef's so configure option for XawPlus library works (patch
+           by Pavel Roskin).
+
+       <li>add <code>$(MAIN_DEFINES)</code> to the variables checked by the
+           configure script that may contain information set by imake.  This
+           allows xterm to build/run properly using the configure script on
+           IRIX64.
+
+       <li>add configure check for ".exe" suffix on cygwin.
+</ul>
+
+<H1><A NAME="xterm_178">Patch #178 - 2003/5/18 - XFree86 4.3.99.5</A></H1>
+<ul>
+       <li>modify default for configure <code>--enable-pty-handshake</code>
+           option to enable it for Solaris (report by Nelson Beebe).
+
+       <li>modify <code>in_put()</code> function to call
+           <code>PreeditPosition()</code> only when the cursor's position has
+           changed.  This addresses report by Stefan Baums of high CPU usage
+           while xterm with chinput are running in the background (patch by
+           Yong Li).
+
+       <li>improved explanation of <code>-ls</code> conflict with
+           <code>-e</code> option in xterm manpage (adapted from comments by
+           Henning Makholm).
+
+       <li>correct comment in terminfo file regarding modifier used for
+           <code>kDC</code> (Debian #189764, report by Henning Makholm).
+
+       <li>correct/extend some of the keypad description in ctlseqs.ms
+           (report by Henning Makholm).
+
+       <li>correct keypad-mapping table in input.c so <code>XK_KP_Equal</code>
+           works (report by Henning Makholm).
+
+       <li>modified to work with CJK double-width (bi-width/monospace) fonts.
+           They're similar to Roman Czbora and David Starner's gnuunifonts in
+           that Latin letters and numbers have all the same width which is
+           exactly the half of the width of East Asian characters.  (patch by
+           Jungshik Shin &lt;jshin@mailaps.org&gt;).
+
+       <li>add configure option <code>--enable-broken-osc</code> and resource
+           <code>brokenLinuxOSC</code> to accommodate scripts which do not
+           distinguish between running in the Linux console and running in X.
+           Linux console recognizes malformed control strings which start
+           with an <code>OSC</code>, but are fixed-length, with no terminator.
+
+       <li>add configure option <code>--enable-broken-st</code> and resource
+           <code>brokenStringTerm</code> to allow
+           user to revert one part of the parsing table corrections from
+           <a href="#xterm_171">patch #171</a>.  (reports by
+           Matthias Scheler and
+           Kirill Ponomarew indicate that someone's
+           network firmware sends an <code>&lt;escape&gt;X</code>).
+
+       <li>modify configure <code>--disable-imake</code> to provide values
+           for <code>OSMAJORVERSION</code>, <code>OSMINORVERSION</code>,
+           <code>FUNCPROTO</code> and <code>NARROWPROTO</code> (report by
+           Heiko Schlichting).
+
+       <li>correct <code>vttests/16colors.sh</code>, which omitted the
+           <code>$SUF</code> variable in output strings (patch by Paul
+           Gilmartin).
+
+       <li>modify shell scripts in <code>vttests</code> directory to attempt
+           to use named signals in the <code>trap</code> statement, making
+           this portable to OS/390 (report by Paul Gilmartin).  Tested on
+           SunOS 4.1.4, which implements only numbers.
+</ul>
+
+<H1><A NAME="xterm_177">Patch #177 - 2003/3/23 - XFree86 4.3.0</A></H1>
+<ul>
+       <li>fix definition of <code>USE_HANDSHAKE</code>, must be numeric
+           (reported by Jens Schleusener).
+</ul>
+
+<H1><A NAME="xterm_176">Patch #176 - 2003/3/22 - XFree86 4.3.0</A></H1>
+<ul>
+       <li>add configure option <code>--enable-pty-handshake</code> to allow
+           one to compile-in support for the pty handshaking logic, and
+           resource <code>ptyHandshake</code> to enable or disable it
+           (suggested by Ian Collier).
+
+       <li>restore <code>USE_HANDSHAKE</code> ifdef removed in
+           <a href="#xterm_159">patch #159</a>
+           to address Debian #39964.
+
+       <li>move ifdef's for ttysize/winsize into xterm_io.h
+
+       <li>simplify loop on <code>tgetent</code>, check if the successive
+           entries in the lookup table are the same.  That makes xterm do
+           one less lookup if there is no "xterm" entry in the termcap file
+           (report by Derek Martin).
+
+       <li>correct manpage discussion of <code>$TERM</code> and
+           <code>$TERMCAP</code> variables, which omitted the Tektronix
+           emulation and a note of the final "dumb" fallback.
+
+       <li>broaden ifdef for <code>XRegisterIMInstantiateCallback()</code>
+           from <a href="#xterm_175">patch #175</a> (XIM fix) to exclude
+           non-XFree86 (report by Nelson Beebe indicates this breaks for
+           Solaris, IRIX and OSF/1).
+
+       <li>correct resource-size for <code>iconFont</code> (this was added
+           by X11R6.3).
+
+       <li>improve configure check for XKB bell extension, to work around
+           inconsistent implementation of this feature (reports by Nelson
+           Beebe, Kriston Rehberg and David Ellement).
+
+       <li>modify configure-check for <code>tty</code> group to be less
+           strict in batch mode (report by Nelson Beebe).
+
+       <li>modify to allow building with g++, to use its compiler warnings
+           (suggested by Nelson Beebe).
+
+       <li>modify <code>dec2ucs[]</code> table to reflect newer codes
+           available for scanlines 1, 3, 7, 9 (report by Michael Schroeder).
+
+       <li>add configure option for XawPlus library.
+</ul>
+
+<H1><A NAME="xterm_175">Patch #175 - 2003/3/9 - XFree86 4.3.0</A></H1>
+<ul>
+       <li>fix a SIGSEGV which could occur if xterm is connecting to XIM
+           server, and the XIM server is destroyed (patch by Nam SungHyun).
+
+       <li>modify to use built-in line-drawing characters for Xft fonts
+           (patch by Andrew Tipton).
+
+       <li>make menu reflect the state of the <code>tekInhibit</code>
+           resource.
+
+       <li>make <code>signalInhibit</code> resource work, i.e., disable the
+           menu entries that would send signals to, or exit xterm.  This was
+           probably broken in X11R5 when logging was disabled (report by Sven
+           Mascheck).
+
+       <li>changed classes of <code>colorBDMode</code> and similar
+           resources that override colors when a video attribute is
+           set to <code>ColorAttrMode</code>, to make them distinct
+           from <code>ColorMode</code>.  This avoids an unexpected
+           rendering of reverse video, for example (report by Paul Fox).
+
+       <li>changed class of <code>veryBoldColors</code> to
+           <code>VeryBoldColors</code>, since
+           <code>ColorMode</code> is associated with boolean resources.
+
+       <li>add option <code>-k8</code> and resource
+           <code>allowC1Printable</code> to allow users of non-VTxxx
+           character sets such as KOI-8 to treat the C1 control area
+           (character codes 128-159) as printable rather than control
+           characters.
+
+       <li>add a null-pointer check for return-value of <code>ptsname()</code>
+           in HPUX-specific code (report by David Ellement).
+
+       <li>revise the ifdef's used for <code>XKB</code> bell support.  The
+           code was using a nonstandard call <code>XkbStdBell()</code>.
+           Changed to use <code>XkbBell()</code> (based on patch by
+           &lt;derek@signalmarketing.com&gt;).
+
+       <li>add a null-pointer check in <code>xtermLoadFont()</code> in case
+           there is no wide-bold font (Nam SungHyun).
+
+       <li>change <code>Makefile.in</code> to use autoconf's
+           <code>bindir</code>, <code>libdir</code> and <code>mandir</code>
+           variables (report by Nam SungHyun).
+
+       <li>add <code>le</code> to termcap <code>xterm-basic</code> entry.
+           Though missing from older termcaps for xterm, some applications
+           check for it (report by Matthias Buelow).
+
+       <li>modify <code>uxterm</code> script to strip modifiers such as "@euro"
+           from the locale setting before adding ".UTF-8" (Debian #179929).
+
+       <li>modify the remaining places where tek4014 emulation uses
+           <code>XDefineCursor()</code>, to make it work as originally
+           implemented, e.g., when switching back to alpha mode.
+           Added test-screen in vttest to test this feature properly.
+</ul>
+
+<H1><A NAME="xterm_174">Patch #174 - 2003/2/25 - XFree86 4.2.99.903</A></H1>
+<ul>
+       <li>work-around for XFree86 bug which made <code>XDefineCursor()</code>
+           on a shell-window no longer work.  The tek4014 emulation used this.
+           Use the next lower window (report by Karl Rudolf Bauchspiess).
+
+       <li>add a resource setting <code>allowWindowOps</code> to control
+           whether the extended window operations should be allowed, e.g.,
+           resize, iconify, report window attributes.  This is to accommodate
+           people who are not capable of using a pager to view log-files.
+</ul>
+
+<H1><A NAME="xterm_173">Patch #173 - 2003/2/6 - XFree86 4.2.99.902</A></H1>
+<ul>
+       <li>reset mouse mode to normal on a full reset.  This does not apply
+           to mouse hilite tracking mode, of course (see ctlseqs.ms).
+
+       <li>add a time-delay at the point where mouse hilite tracking mode
+           choses to not handle X events, to avoid runaway CPU usage
+           (report by D Hugh Redelmeier).
+
+       <li>check for illegal character in DECUDK string, quit if detected.
+</ul>
+
+<H1><A NAME="xterm_172">Patch #172 - 2002/12/27 - XFree86 4.2.99.3</A></H1>
+<ul>
+       <li>fixes to make repainting of 256-color example work properly
+         (reports by Abigail Brady and Scott A Crosby).
+         <ul>
+          <li>set flag in <code>AllocateAnsiColor()</code> to ensure the color
+            is allocated once only.
+          <li>fix check in <code>ScrnRefresh</code>, which was comparing
+            background colors only if the ANSI foreground colors also were set.
+         </ul>
+
+       <li>merge <code>Error()</code> calls and some <code>exit()</code> calls
+         into <code>SysError()</code>, and change that to add the brief
+         explanation for each error code which is provided in the manpage.
+         Change a few <code>SysError()</code>, calls to avoid using code 1, to
+         avoid confusion with exit status from places that do not use
+         <code>SysError()</code>.
+
+       <li>simplify logic used to open a debug logfile as the standard error.
+
+       <li>modify the <code>-e</code> option so that if it fails, xterm will
+         check if only one argument follows, e.g., it was quoted, and then
+         retry using <code>sh&nbsp;-c</code>.
+
+       <li>modify parsing of DECUDK string parameter to allow a comma between
+         pairs of hexadecimal digits (Ray Neuman &lt;raymond@one.com.au&gt;
+         reports that "real" terminals accept this; perhaps they simply
+         ignore unexpected characters).
+
+       <li>fix a few problems with the <code>$TERMCAP</code> string generated
+         by <code>resize</code>:
+         <ul>
+          <li>for Bourne shell, add an <code>export</code> command.
+            This was missing as far back as X11R5.
+          <li>escape exclamation marks, used in xterm's reset string.
+          <li>translate literal <code>\177\</code> to "^?".
+         </ul>
+
+       <li>improve configure check for <code>tgetent()</code> to work when
+         <code>$TERMCAP</code> has been set to a specific entry.
+
+       <li>modify <code>minstall.sh</code> to use "%" rather than "@",
+         to avoid problems with AFS (report by Zdenek Sekera).
+
+       <li>list fatal error codes from <code>error.h</code> in the manpage,
+         remove unused codes in <code>error.h</code>.
+
+       <li>use more explicit wording for manpage list of color resources,
+         since at least one user confused the generic names such as "black"
+         with the names in rgb.txt (the latter are now used).
+
+       <li>minor fix to description of 1003 mouse mode in ctlseqs.ms
+         (Larry Riedel).
+</ul>
+
+<H1><A NAME="xterm_171">Patch #171 - 2002/12/12 - XFree86 4.2.99.3</A></H1>
+<ul>
+       <li>modify parser tables to improve detection of malformed control
+         sequences, making xterm behave more like a real DEC terminal
+         (patch by Paul Williams).
+
+       <li>update comment in <code>input.c</code> to document
+         <code>Meta</code> as a modifier for escape sequences (patch by D
+         Roland Walker).
+
+       <li>add ifdef'd code for logging option which adds the hostname and a
+         timestamp to the generated logfile name.  The ifdef's are setup
+         with the configure script (patch by Nelson Beebe).
+
+       <li>remove <code>xevents()</code> call from the end of
+         <code>BlinkCursor()</code>, to fix an occasional problem
+         which caused xterm to pause until a key was pressed.
+         The reason for this was that there was no check to ensure that
+         there really were events for <code>xevents()</code> to process.
+         (patch by Semen A Ustimenko &lt;semenu@FreeBSD.org&gt;).
+
+       <li>remove unused mode-params from <code>open()</code> calls that do
+         not create a file.
+
+       <li>modify configure script to put new items first on
+         <code>$CPPFLAGS</code> and <code>$CFLAGS</code> to avoid conflict
+         with environment's <em>-I</em> and <em>-D</em> options.
+
+       <li>update config.guess, config.sub
+
+       <li>resync with XFree86 CVS
+       <ul>
+         <li>fix va_args glitches for xterm/libfontconfig:  0 == (void*)0
+           isn't true for all platforms (Egbert Eich).
+         <li>initialise ProgramName in xterm's main before referencing it
+           (#5473, Peter Valchev).
+          <li>some cleanup of Imakefile ifdef's (Marc La France).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_170">Patch #170 - 2002/10/13 - XFree86 4.2.1</A></H1>
+<ul>
+       <li>correct an off-by-one allocating data for sorted help message.
+
+       <li>modify configure script to check for Xpm library, on which XFree86
+         Xaw library depends.
+
+       <li>update config.guess, config.sub
+</ul>
+
+<H1><A NAME="xterm_169">Patch #169 - 2002/10/5 - XFree86 4.2.1</A></H1>
+<ul>
+       <li>modify wording of some options in help message to make them use
+         <code>-/+</code> consistently with respect to "on/off" or "off/on".
+
+       <li>sort options list which is displayed in help- and syntax-messages
+         at runtime to simplify maintenance.
+
+       <li>remove support for Amoeba and Minix (Juliusz Chroboczek noted it
+         was removed from XFree86 server; there have been no users since
+         1996).
+
+       <li>add configure script option <code>--disable-session-mgt</code>
+         to control whether the session management code should be compiled-in
+         (request by H Merijn Brand).
+
+       <li>ifdef'd the session-management changes with
+         <code>OPT_SESSION_MGT</code>, to accommodate X11R5 which predates
+         the related definitions.
+
+       <li>fix <code>decode_keyvalue()</code>, which did not properly parse
+         multiple settings as needed for the <code>ttyModes</code> resource,
+         since it did not skip over the parsed data.
+
+       <li>fix an option-parsing conflict between <code>-class</code> and
+         <code>-cjk_width</code> (Nam SungHyun)
+
+       <li>add a missing null in <code>XtVaSetValues()</code> call used in
+         <code>Cleanup()</code> (Nam SungHyun)
+</ul>
+
+<H1><A NAME="xterm_168">Patch #168 - 2002/9/29 - XFree86 4.2.1</A></H1>
+<ul>
+       <li>improve data reported for control sequence that requests window
+         position by taking into account the window decorations, e.g.,
+         border and title (patch by Jess Thrysoee &lt;jess@thrysoee.dk&gt;).
+
+       <li>add <code>-cjk_width</code> and corresponding resource
+         <code>cjkWidth</code> (patch by Jungshik Shin
+         &lt;jshin@mailaps.org&gt;).
+
+       <li>add <code>-into</code> option, for embedding xterm in a Tcl/Tk
+         application (patch by George Peter Staplin &lt;georgeps@xmission.com&gt;).
+
+       <li>add simple session management (XSM) client capabilities to xterm.
+         So a session manager such as, e.g., xsm, should be able to respawn or
+         kill xterms without the help of an SM proxy (like smproxy), which is
+         a hack and almost always buggy (patch by David Madore).
+
+       <li>fix conflict between ifdef's for <code>OPT_DEC_LOCATOR</code> and
+         <code>OPT_READLINE</code> in button.c (reported by Ilya Zakharevich).
+
+       <li>fix for inconsistent use of <code>struct utmp</code> versus
+         <code>struct utmpx</code> introduced in <a href="#xterm_167">patch #167</a>
+         (patches by Paul Gilmartin, Marc La France).
+
+       <li>modify logic for <code>metaSendsEscape</code> to allow it to work
+         in a setup where the Meta-key is not recognized as a modifier by
+         the key-translations logic (discussion of eightBitInput with H.J.Lu).
+         Note however that Vincent Lefevre reported this in January).
+
+       <li>use null pointer values consistently, rather than literal "0", for
+         ending variable-length argument lists, e.g., for
+         <code>execlp()</code> (based on patch by Matthieu Herrb).
+
+       <li>correct logic of <code>ChangeAnsiColorRequest()</code>, which would
+         do a screen repaint after replying to a request for information.
+
+       <li>improve scripts in vttests to work with systems whose shells support
+         <code>echo -n</code> and have, as does Debian, an unrelated
+         <code>print</code> utility.
+
+       <li>add vttests/acolors.sh to demonstrate OSC 4, which queries or
+         sets ANSI colors.
+
+       <li>fixes for ctlseqs.ms (Pavel Roskin, Ilya Zakharevich).
+
+       <li>typos in xterm manpage (Jens Schweikhardt)
+
+       <li>remove a redundant GCC_UNUSED from InitPopup() (Nam SungHyun)
+</ul>
+
+<H1><A NAME="xterm_167">Patch #167 - 2002/8/24 - XFree86 4.2.0</A></H1>
+<ul>
+       <li>correct ifdef's for <code>USE_TERMCAP</code> to match cygwin
+         configuration.
+
+       <li>fix several places in ctlseqs.ms which had no boxes around the
+         literal text (report by Ilya Zakharevich).
+
+       <li>extend mouse support for readline,
+           ifdef'd with OPT_READLINE
+           (integrated patch from Ilya Zakharevich).
+
+       <li>modify terminfo description to match default for
+         <code>modifyCursorKeys</code> resource.
+
+       <li>add <code>modifyCursorKeys</code> resource to control how the
+         shift- and similar modifiers are used to make a cursor escape
+         sequence.  The default makes a modified escape sequence always start
+         with CSI and puts the modifier as the second parameter, to avoid
+         confusing applications that would interpret the first parameter as a
+         repeat count.  The original behavior can be obtained by setting the
+         resource to 0 (newsgroup discussion with Stephen J Turnbull,
+         Jeffrey Altman).
+
+       <li>correct missing initializations for <code>appdefaultCursor</code>
+         and <code>appdefaultKeypad</code> resources.
+
+       <li>add configure option <code>--enable-luit</code> and ifdef'd the
+         luit-related code with OPT_LUIT_PROG.
+
+       <li>modify xterm to invoke luit (integrated patch by Tomohiro Kubota)
+
+       <li>update wcwidth.c to match Markus Kuhn's 2002-05-18 version.
+
+       <li>correct limit-checking in <code>ComputeSelect()</code> to handle
+         selections that extend off the visible area; rather
+         than modify the parameters to <code>TrackText()</code>, use
+         <code>ScrollSelection()</code> to update the highlighting limits.
+         (reported by Yegappan Lakshmanan and Nelson Beebe,
+          patch by Alexander V Lukyanov).
+
+       <li>correct manpage description of <code>tiXtraScroll</code> resource
+         (reported by Tony Finch).
+
+       <li>changes from OpenBSD:
+       <ul>
+          <li>Make xterm setgid utmp to be able to update utmp even
+          with root privileges revoked.
+          <li>If not updating utmp, revoke group privileges totally too.
+       </ul>
+
+       <li>changes from NetBSD:
+       <ul>
+        <li>Check that the return value from ttyslot() is greater than 0
+         before writing the utmp file.
+         Fixes w's "w: Stale utmp entry: &lt;user&gt; &lt;tty&gt; &lt;pty&gt;" errors.
+        <li>Use openpty() to deal with new pty naming scheme.
+       </ul>
+
+       <li>add <code>print-redir</code> action and menu entry to allow user to
+         switch terminal in/out of printer controller mode.  It appears from
+         the manual that a real vt220 would not switch back to normal mode, so
+         another mechanism is used (addresses Debian #37517).
+
+       <li>check if <code>printerCommand</code> resource string is empty, use
+         this to allow user to disable printer function.
+
+       <li>trim trailing blanks from resource strings.
+
+       <li>check return value from <code>ptsname()</code>, which may return
+         null for example if someone has changed the permissions of /dev/pts
+         to zero (Debian #121899).
+
+       <li>modify OS/2 version to use <code>__UNIXOS2__</code> definition
+         rather than <code>__EMX__</code>, related cleanup (patch by Holger
+         Veit).
+
+       <li>used modified indent 2.0
+         (patch <a href="ftp://invisible-island.net/gnu-patches/">20020428</a>)
+         to reformat most of the C source files, to simplify maintenance.
+
+       <li>fix a couple of places where there were leading tabs on
+         symbol-definition lines in Imakefile (Marc La France from report by
+         Tony Finch)
+
+       <li>add imake variable (TraceXTerm) to allow building debug version
+         (Egbert Eich).
+</ul>
+
+<H1><A NAME="xterm_166">Patch #166 - 2002/03/25 - XFree86 4.2.0</A></H1>
+<ul>
+       <li>correct a bug in selection: double clicking on a word which
+         was partly scrolled off the screen may select that text (report
+         by Vincent Lefevre &lt;vincent@vinc17.org&gt;).
+
+       <li>implement <code>veryBoldColors</code> resource to control whether
+         the corresponding video attribute such as <code>bold</code> is
+         displayed when using <code>colorBDMode</code>, etc.  (request by Josh
+         Howard &lt;jrh@vicor-nb.com&gt;).
+
+       <li>define escape sequences for function keys F21-F35 (patch by Steve Wall).
+
+       <li>change the colors for the 256-color model, making them less skewed
+         toward black (patch by Steve Wall).
+
+       <li>add <code>vt100Graphics</code> resource
+         (see <a href="#xterm_115">patch #115</a>,
+         based on discussion with Glenn Maynard).
+
+       <li>ifdef'd Xaw/Xaw3d/neXtaw includes separately to avoid potential
+         incompatibilities between these flavors of Athena widgets.
+
+       <li>add configure check for XFree86 4.x Xaw library, whose geometry
+         management is broken, to avoid trying to use it for toolbar
+         configuration.
+
+       <li>updates to configure script from vile and lynx to allow
+         configure.in to be compiled with autoconf 2.5x
+
+       <li>add a check for null pointer return by <code>ptsname()</code>
+         (newsgroup posting from Mike Silva &lt;mikesilva@lucent.com&gt;).
+
+       <li>fill in a few details needed to allow UTF-8 mode to switch on/off
+         after startup.  This requires that <code>wideChars</code> resource be
+         set.  (based on comments in 4 Aug 2001 by Alexey Marinichev
+         &lt;lyosha@lyosha.2y.net&gt;).
+
+       <li>remove duplicate install rules that make directories, e.g., so installing
+         manpage will not create app-defaults directory.
+
+       <li>add comment in in <code>do_osc()</code>, reserving cases 30 and 31
+         for for Konsole (request by Stephan Binner
+         &lt;Stephan.Binner@gmx.de&gt;).
+
+       <li>fixes for ctlseqs.ms and xterm.man
+         (patch by Werner Lemberg &lt;wl@gnu.org&gt;).
+
+       <li>add check for monochrome display, disabling colorMode in that
+         case (fixes Debian #134130).
+
+       <li>resync with XFree86 CVS
+       <ul>
+          <li>Fix some xterm build warnings on *BSD (patch by David Dawes).
+          <li>Only use SA_RESTART in xterm when it's available (patch by Frank Liu).
+          <li>Fix incorrect code in signal handlers in most of the clients,
+            xterm and xdm not done yet (patch by Matthieu Herrb).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_165">Patch #165 - 2002/01/05 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>modify <code>uxterm</code> script to strip encoding part from
+         environment variable before adding ".UTF-8" (based on Debian
+         #125947, but using a more portable solution).
+
+       <li>add an assignment statement in VTInitialize() to make
+         <code>awaitInput</code> resource work.
+
+       <li>use new macros init_Bres(), etc., in VTInitialize() to add trace of
+         the initialization of resources.
+
+       <li>modify checks for $LC_ALL, related environment variables to ensure
+         the resulting strings are nonempty (report by Markus Kuhn).
+
+       <li>add an ifdef in charproc.c for num_ptrs variable in case all
+         configure options are disabled.
+
+       <li>modify definition of getXtermBackground() to avoid negative array
+         index warning on Tru64 (report by Jeremie Petit).
+
+       <li>improve fix from patch #165 (still Debian #117184, report by Matt
+         Zimmerman &lt;mdz@debian.org&gt;)
+
+       <li>correct install rule for uxterm in Makefile.in, to handle the
+         case where building in a different directory than xterm's source
+         (patch by Paul Gilmartin).
+
+       <li>documented ANSI.SYS-style cursor save/restore escape sequences
+         in ctlseqs.ms, which are in xterm since X11R5.
+
+       <li>correct two entries in the default charClass table, which did not
+         follow the manpage comment about the character number corresponding
+         to the class (patch by Marc Bevand &lt;bevand_m@epita.fr&gt;).
+
+       <li>fix a couple of typos in comments in the app-defaults files
+         (David Krause &lt;xfree86@davidkrause.com&gt;).
+
+       <li>resync with XFree86 CVS
+         <ul>
+         <li>update language of copyrights in some files to reflect the fact
+             that they were reassigned from X Consortium to The Open Group in
+             1998.  Note that this xterm source is derived from the 1996
+             version from X Consortium, does not incorporate changes made by X
+             Consortium or The Open Group after that date, hence we do not add
+             The Open Group's 1998 copyright date to related files.
+
+         <li>save/restore <code>errno</code> in signal catcher (patch by Matthieu Herrb).
+
+         <li>modify UXTerm.ad's font5 resource so that xterm can display double
+             width characters using a font distributed with XFree86 (Tomohiro Kubota).
+         </ul>
+</ul>
+
+<H1><A NAME="xterm_164">Patch #164 - 2001/11/13 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>correct a case where <code>ptyInitialErase</code> and
+         <code>backarrowKeyIsErase</code> resources combine to set
+         <code>DECBKM</code> mode, but a <code>reset</code> command would not
+         reset xterm to that state, making the erase character revert to ^H
+         (Debian #117184)
+</ul>
+
+<H1><A NAME="xterm_163">Patch #163 - 2001/11/04 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>correct ifdef's for <code>__QNX__</code> and
+         <code>USE_SYSV_PGRP</code> in main.c call to <code>tcsetpgrp</code>,
+         which broke bash behavior around <a href="#xterm_140">patch #140</a>
+         (report/patch by Frank Liu &lt;fliu@mail.vipstage.com&gt;).
+
+       <li>modify trace.c to fix missing definition of GCC_UNUSED for
+         compilers other than gcc when configured for trace code (report/patch
+         by Paul Gilmartin).
+
+       <li>change format in TraceOptions() to use long rather than int, since
+         the latter could lose precision on 64-bit machines (report/patch by
+         Nelson Beebe).
+
+       <li>modify xterm manual page and minstall.sh to allow imake rules
+         to define location of app-defaults directory (Debian #87611).
+
+       <li>review/update list of conflicting preprocesor symbols to remove
+         from $CPPFLAGS at the end of the configure script.  In particular,
+         this allows one to configure xterm without the utempter library on
+         Redhat 7.1 (report/patch by Adam Sulmicki).
+</ul>
+
+<H1><A NAME="xterm_162">Patch #162 - 2001/10/23 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>correct logic that processes <code>-class</code> option, so that
+         a following <code>-e</code> option is handled (Debian #116297).
+
+       <li>improve options-decoding to allow <code>-version</code> and
+         <code>-help</code> options to be combined (Debian #110226).
+
+       <li>add a 10 millisecond delay in event loop when processing
+         <code>-hold</code> option, to avoid using too much CPU time
+         (Debian #116213).
+
+       <li>prefix final program execution in <code>uxterm</code> with "exec"
+         to avoid a useless shell hanging around (Christian Weisgerber).
+</ul>
+
+<H1><A NAME="xterm_161">Patch #161 - 2001/10/10 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>modify logic that resets keypad application mode to avoid doing
+          this if there is no modifier associated with the Num_Lock keysym
+          (report by John E Davis &lt;davis@space.mit.edu&gt; and Alan W Irwin
+          &lt;irwin@beluga.phys.uvic.ca&gt;).
+
+       <li>add built-in translation for Control/KP_Separator to KP_Subtract,
+          to accommodate users who wish to use xmodmap to reassign the top
+          row of the numeric keypad.
+
+       <li>correct Imakefile install-rule for <code>uxname</code> script
+          (reported by Nam SungHyun &lt;namsh@lge.com&gt;).
+
+       <li>resync with XFree86 CVS &ndash; correct typo in <code>&lt;ncurses/term.h&gt;</code>
+          ifdef.
+</ul>
+
+<H1><A NAME="xterm_160">Patch #160 - 2001/10/7 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>modify logic in main.c
+           (see <a href="#xterm_145">patch #145</a>) to avoid generating the
+           same identifier, for example, for /dev/tty1 and /dev/pts/1, which
+           is used to denote an entry in the utmp file (Debian bug report
+           #84676),  A similar fix was also sent by Jerome Borsboom
+           &lt;borsboom@westbrabant.net&gt; in May, but I overlooked it when
+           reviewing bug reports.
+
+       <li>add configure check for <code>&lt;ncurses/term.h&gt;</code> to get
+           rid of hardcoded <code>__CYGWIN__</code> ifdef in resize.c
+           <p>
+           NOTE: The CYGWIN port should not be linking <code>resize</code>
+           with ncurses.  It appears that the only reason it is, is because
+           both the ncurses and termcap ports on that platform are badly
+           misconfigured (essential pieces have been removed, etc).  Checking
+           for <code>&lt;ncurses/term.h&gt;</code> does not hurt anything,
+           since there are some correct installations that are set up that
+           way.
+
+       <li>add a sample <code>uxterm</code> script, which uses the
+           <code>UXTerm</code> application defaults for UTF-8 environments.
+
+       <li>undo change to xterm application defaults, since this introduced an
+           unnecessary incompatibility.  The intended functionality was
+           already addressed by the <a href="#xterm_141">UXTerm</a>
+           app-defaults file.
+
+       <li>resync with XFree86 CVS
+       <ul>
+       <li>Modified xterm app default to use LFD fontnames instead of old type
+           (Michael Schroeder).
+       <li>Fix xterm when XIM is disabled - caused a segfault
+           (Tomohiro Kubota).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_159">Patch #159 - 2001/9/19 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>remove an ifdef for <code>USE_HANDSHAKE</code> added in patch
+          #158 from the second <code>TIOCSSIZE</code> ioctl call in the
+          initialization code.  Paul Gilmartin reports that for Solaris 2.6
+          (sparc), stty does not show that xterm sets rows and columns unless
+          the second ioctl is executed.
+
+       <li>correct treatment of empty parameter list for some OSC strings
+          (report by Sami Farin &lt;sfarin@ratol.fi&gt;).
+</ul>
+
+<H1><A NAME="xterm_158">Patch #158 - 2001/9/8 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>augment key translations for scrollbar widget to ensure that
+          keystrokes intended for the text area are not lost if the mouse
+          pointer happens to fall on the scrollbar.  This can happen, for
+          instance, if the user's <code>app-defaults</code> or
+          <code>.Xdefaults</code> file contains a translations resource,
+          though it may also happen through unrelated resource settings:
+          probably a bug in libXt (reported by Paul Fox
+          &lt;pgf@foxharp.boston.ma.us&gt; and Dmitry Yu.  Bolkhovityanov
+          &lt;D.Yu.Bolkhovityanov@inp.nsk.su&gt;).
+
+       <li>widen ifdef's in xterm.h to define <code>__EXTENSIONS__</code> on
+          Solaris, for compilers other than gcc.  This was added along
+          <code>_POSIX_C_SOURCE</code> with in <a href="#xterm_151">patch
+          #151</a>, but is not sufficient since Sun's compiler does not define
+          <code>__STDC__</code> by default (report by Matthias Scheler
+          &lt;tron@zhadum.de&gt;).
+
+       <li>modify xterm to obtain the closest matching color if an exact color
+          is not available, e.g., on 8-bit displays (patch by Steve Wall)
+
+       <li>implement "OverTheSpot" preedit type of XIM input
+          (patch by Tomohiro Kubota):
+         <ul>
+         <li>This preedit type is a reasonable compromise between
+           simpleness of implementation and usefulness.  "Root" preedit
+           type is easy to implement but not useful; "OnTheSpot" preedit
+           type is the best in the point of view of user interface but
+           very complex.  And more, "OverTheSpot" is the preedit type
+           which the most XIM servers support.  Thus, to achieve reasonable
+           usability, support of "OverTheSpot" preedit type is needed.
+
+         <li>In "OverTheSpot" preedit type, the preedit (preconversion)
+           string is displayed at the position of the cursor.  On the
+           other hand, it is XIM server's responsibility to display
+           the preedit string.  Thus, it is needed for XIM client (here
+           XTerm) to inform the XIM server of the cursor position.
+           And more, to achieve good visual proportion, preedit string
+           must be written using proper font.  Thus, it is XIM client's
+           responsibility to inform the XIM server of the proper font.
+           The font must be supplied by "fontset".  Fontset is a set of
+           fonts with charsets which are specified by the current locale.
+           Since XTerm uses ISO10646 fonts regardless of the current locale,
+           the fonts for XIM must be prepared separately.  It is difficult
+           to prepare fonts which are similar to XTerm font.  Thus, my
+           patch uses a simple way - the default font is "*" which matches
+           every fonts and X library will automatically choose fonts with
+           proper charsets.  I added "-fx" command option and "ximFont"
+           resource to override this default font setting.
+
+         <li>changed the definition of "OverTheSpot" preedit type
+           from XIMPreeditPosition|XIMStatusArea
+           to XIMPreeditPosition|XIMStatusNothing.
+           This matches the behavior of other programs such as
+           Rxvt, Kterm, Gedit.
+
+         <li>A tiny XIM bugfix is also included.  By calling XSetLocaleModifiers()
+           with parameter of "", it can consier XMODIFIERS environmental
+           variable which is a standard way for users to specify XIM server
+           to be used.
+         </ul>
+
+       <li>adjust configure script to accommodate repackaging of keysym2ucs.c
+         as include-file for xutf8.c (patch by Tomohiro Kubota).
+
+       <li>add the <code>UXTerm</code> app-defaults file to makefile install
+         rules (request by Juliusz Chroboczek).
+
+       <li>correct logic in <code>get_termcap()</code>, which returned false
+         if the <code>tgetent()</code> call indicated that xterm was linked
+         with terminfo.  Although the <code>$TERMCAP</code> variable cannot be
+         adjusted in this case, xterm still needs information from this call
+         to extract data to initialize the erase-mode when the
+         <code>ptyInitialErase</code> resource is false.
+
+       <li>modify <code>ScrollbarReverseVideo()</code> function to cache the
+         original border color, so it can restore that when an application
+         flashes the screen (Bugzilla #38872).
+
+       <li>resync with XFree86 CVS
+       <ul>
+         <li>remove ifdef's for X_NOT_STDC_ENV (patch by David Dawes).
+         <li>add Cygwin to special errno handling case in ptydata.c (Alan Hourihane)
+         <li>set screen size earlier in initialization, to address a race
+           with window manager resizing its clients (Keith Packard).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_157">Patch #157 - 2001/6/18 - XFree86 4.1.0</A></H1>
+<ul>
+       <li>clean up button.c and input.c (patch by Juliusz Chroboczek).  The
+         basic idea is to use a single set of APIs in the XTerm core, and put
+         a set of workarounds in a separate file.  As you will notice, this
+         drastically simplifies parts of the code; in particular, the only
+         remaining ifdefs related to the differences between Xutf8 and legacy
+         systems are related to the selection provider logic.
+
+         This defines two new files, xutf8.h and xutf8.c, provide some
+         half-hearted but fully portable emulation for the three Xutf8*
+         functions that XTerm uses.
+
+         Putting these in a separate file will allow people to experiment with
+         more complex versions without making the core of XTerm more difficult
+         to maintain.
+
+         The functionality of the emulation is as follows.
+         <ul>
+         <li>Xutf8TextListToTextProperty fully handles XStringstyle and
+         XUTF8StringStyle.  It will only generate STRING for XStdICCTextStyle,
+         and wil only generate Latin-1 in XCompoundTextStyle (but label it as
+         COMPOUND_TEXT, as the spec requires).  (I have hesitated to make this
+         function fail for XStdICCTextStyle and XCompoundTextStyle; this might
+         be a smart thing to do, in the hope that the selection requestor will
+         try UTF8_STRING afterwards; opinions?)
+
+         <li>Xutf8TextPropertyToTextList fully handles STRING and UTF8_STRING.
+         It systematically fails for COMPOUND_TEXT.
+
+         <li>Xutf8LookupString will properly handle single-keystroke input for
+         the keysyms covered by Markus' keysym2ucs function.  It will not
+         handle either compose key input or external input methods.
+         </ul>
+
+       <li>add an ifdef for <code>SunXK_F36</code>, used in
+         <code>xtermcapKeycode()</code> (patch by Mark Waggoner
+         &lt;waggoner@ichips.intel.com&gt;).
+
+       <li>modify check for login name to try <code>getlogin()</code> and
+         $LOGNAME, $USER environment variables to detect if the user has
+         logged in under an alias, i.e., an account with the same user id
+         but a different name (Debian bug report #70084).
+
+       <li>add resource <code>tiXtraScroll</code>, which can be used to
+         preserve the screen contents in the scrollback rather than erasing
+         it when starting a fullscreen application such as <code>vi</code>
+         (patch by Ken Martin &lt;fletcher@catsreach.org&gt;).
+
+       <li>two patches by Denis Zaitsev &lt;zzz@cd-club.ru&gt;:
+       <ul>
+         <li>added <code>forceBoxChars</code> resource to control the
+           "line-drawing characters" option.
+
+         <li>added <code>freeBoldBox</code> resource, which, when set true,
+           suppresses check in <code>same_font_size()</code>, so xterm does
+           not attempt to ensure that the bold font is the same size as
+           the normal font.
+       </ul>
+
+       <li>change the color class for ANSI colors and similar ones such as
+         bold-color, etc., to follow the convention that the classname is the
+         instance name with a leading capital (e.g., <code>color0</code> and
+         <code>Color0</code> rather than <code>color0</code> and
+         <code>Foreground</code>).  There was little use for Foreground as a
+         class other than to create occasional confusion and bug reports, most
+         recently by Nelson Beebe who reports that it disables colors in xterm
+         but not on Linux, which is probably due to a difference in resource
+         evaluation order.  A configure script option (--disable-color-class)
+         is provided for anyone who did use the older behavior.
+
+       <li>fix a signal-handling bug.  When running xterm with
+         <code>ksh</code> or similar shell such as bash 2.05, xterm will hang
+         and not respond to keystrokes after the user types
+         <code>suspend</code>.  Additionally the popup menus do not respond,
+         so it is not possible to send SIGCONT to the shell.
+         What is happening is that the shell is sending itself SIGSTOP, and it
+         is being stopped.  Per specification it also means that the operating
+         system is sending SIGCHLD to parent to the bash (XTERM).
+         Now the issue is that xterm assumes it cannot happen and it expects
+         to receive SIGCHLD only upon <em>termination</em> of its children.
+         This causes a deadlock with xterm waiting for the child to
+         die, and the child waiting for SIGCONT.
+         (report/patch by Adam Sulmicki), analysis/testing by Sven Mascheck
+         &lt;sven.mascheck@student.uni-ulm.de&gt;).
+
+       <li>correct some inconsistent checks for <code>XtReleaseGC()</code>
+         calls in <code>xtermLoadFont()</code> (patch by Nam SungHyun
+         &lt;namsh@lge.com&gt;).
+
+       <li>updated wcwidth.c and keysym2ucs.c to versions dated 2001/1/12
+         and 2001/4/18, respectively from
+               http://www.cl.cam.ac.uk/~mgk25/ucs/
+
+       <li>correction to change from <a href="#xterm_90">patch #90</a>,
+         which was intended to
+         reset the saved cursor position for normal/alternate screens
+         on a soft reset, but actually wiped out all of the saved cursor
+         information.  Just reset the saved position for the current screen
+         (report by Michael Schroeder).
+
+       <li>modify ShowCursor() and HideCursor() so that if the cursor points
+         to the second part of a wide character, make the show/hide operate on
+         the first position of the wide character (patch by Sven Verdoolaege).
+
+       <li>scrolling in the alternate screen just before switching back to the
+         main screen can cause extra blank lines to be inserted into the
+         scrollback buffer (patch by Paul Vojta
+         &lt;vojta@math.berkeley.edu&gt;).
+
+       <li>resync with XFree86 4.1.0:
+       <ul>
+         <li>Use TermcapLibrary as -lncurses instead of -ltermcap, fixes
+           problem building xterm/resize on Cygwin/XFree86 (Harold Hunt).
+         <li>Install xterm.termcap and xterm.terminfo when installing xterm
+           (Torrey T. Lyons).
+         <li>Fix some build issues on Cygwin/XFree86 (Suhaib Siddiqi).
+         <li>Define CBAUD, when it's missing in xterm, on LynxOS
+           (Stuart Lissaman).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_156">Patch #156 - 2001/4/28 - XFree86 4.0.3</A></H1>
+<ul>
+       <li>change order of selection-target types to make 8-bit xterm prefer
+         UTF8_STRING to COMPOUND_TEXT (patch by Juliusz Chroboczek).
+
+       <li>document <code>-fa</code>, <code>-fs</code> command-line options
+         and <code>faceName</code>, <code>faceSize</code>
+         resources which are used by the freetype library support.
+
+       <li>if configure script finds freetype libraries, but imake definitions
+         do not have the XRENDERFONT definition, define it anyway.
+
+       <li>modify configure script check for freetype libraries to include
+         <code>&lt;Xlib.h&gt;</code>, since an older version of the related
+         headers relies on this (patch by Adam Sulmicki).
+</ul>
+
+<H1><A NAME="xterm_155">Patch #155 - 2001/4/20 - XFree86 4.0.3</A></H1>
+<ul>
+       <li>correct return type of in_put() from <a href="#xterm_155">patch #153</a>
+         changes, which left it not wide enough for UTF-8 (patch by Bruno Haible).
+</ul>
+
+<H1><A NAME="xterm_154">Patch #154 - 2001/4/11 - XFree86 4.0.3</A></H1>
+<ul>
+       <li>undo check for return value from <code>pututline</code> (used for
+         debugging) since that function does not return a value on Slackware
+         3.6.
+
+       <li>correct length in ScreenWrite, when rendering invisible text
+         (patch by Sven Verdoolaege &lt;skimo@kotnet.org&gt;).
+
+       <li>fixes/improvements for the <code>i18nSelection</code> resource
+         from patch #153, by Bruno Haible:
+
+       <ul>
+         <li>add missing initialization for <code>i18nSelection</code>
+           resource.
+
+         <li>split-out the non-ICCM aspect of the
+           <code>i18nSelection</code> resource as a new resource,
+           <code>brokenSelections</code>.
+       </ul>
+
+       <li>add configure check for <code>&lt;time.h&gt;</code> and
+         <code>&lt;sys/time.h&gt;</code>, to allow for Unixware&nbsp;7,
+         which requires both.  If the configure script is not used, only
+         <code>&lt;time.h&gt;</code> will be included as before (report
+         by Thanh Ma).
+
+       <li>fix redefinition of <code>dup2</code>, <code>getutent</code>,
+         <code>getutid</code>, <code>getutline</code> and <code>sleep</code>
+         functions on Unixware&nbsp;7 (report by Thanh Ma
+         &lt;Thanh.Ma@casi-rusco.com&gt;)
+
+       <li>add a fall-back definition for <code>__hpux</code>, which is
+         apparently not defined in some compilers on HPUX 11.0 (reported
+         by Clint Olsen).
+
+       <li>change VAL_INITIAL_ERASE, which is used as a fallback for the
+         <code>"kb"</code> termcap string to 8, since that matches the
+         xterm terminal description (request by Alexander V Lukyanov).
+
+       <li>correct an off-by-one in <code>ClearInLine</code>, which caused
+         the erase-characters (ECH) control to display incorrectly
+         (patch by Alexander V Lukyanov).
+
+       <li>correct escape sequences shown in terminfo for shifted editing
+         keys.  The modifier code was for the control key rather than
+         the shift key.
+</ul>
+
+<H1><A NAME="xterm_153">Patch #153 - 2001/3/29 - XFree86 4.0.3</A></H1>
+<ul>
+       <li>increase PTYCHARLEN to 8 for os390, add some debugging traces
+         for UTMP functions (patch by Paul Gilmartin).
+
+       <li>correct an misplaced brace in <code>SelectionReceived()</code>
+         (patch by Bruno Haible).
+
+       <li>correct an assignment dropped in <code>SelectionReceived()</code>
+         which made it not compile for wide-characters combined with debug
+         traces.
+
+       <li>correct typo, clarify description of 88- and 256-color controls
+         (report by Bram Moolenaar).
+
+       <li>correct a typo in ctlseqs.ms which caused DEC Locator control
+         sequences using single quote "'" display grave "`" instead (reported
+         by Paul Williams, apparently in patch #114).
+</ul>
+
+<H1><A NAME="xterm_152">Patch #152 - 2001/3/13 - XFree86 4.0.2</A></H1>
+<ul>
+       <li>correct index in inner loop in <code>VTInitI18N()</code> from
+         patch #151 changes, which resulted in infinite loop under some
+         conditions (report/analysis by Paul Gilmartin).
+
+       <li>remove spurious "%|" from terminfo sgr capabilities
+         (report/analysis by Adam M Costello, Debian #89222).
+
+       <li>add shell script to adjust list of dynamic libraries linked by
+         <code>resize</code> when building with the standalone configure
+         script.  Otherwise it uses the same list as for xterm, which is
+         excessive.
+
+       <li>fix a few compiler warnings reported by the 20010305 gcc snapshot.
+</ul>
+
+<H1><A NAME="xterm_151">Patch #151 - 2001/3/10 - XFree86 4.0.2</A></H1>
+<ul>
+       <li>alter the behaviour of selections in XTerm (patch by Juliusz Chroboczek).
+         It is believed to follow the ICCCM + UTF8_STRING to the letter, both
+         in UTF-8 and in eight-bit mode.  From his description:
+         <ul>
+         <li>When compiled against XFree86 4.0.2, the patched XTerm will make
+           the selection available as COMPOUND_TEXT, STRING or UTF8_STRING in
+           both modes.  It will request selections in the following order:
+           <p>
+             UTF-8 mode: UTF8_STRING, TEXT, COMPOUND_TEXT, STRING.<br>
+             eight-bit mode: TEXT, COMPOUND_TEXT, UTF8_STRING, STRING.
+
+         <li>When compiled against an earlier version of XFree86 (or compiled with
+           OPT_UTF8_API=0), it will still obey the ICCCM, but will neither
+           request nor provide UTF8_STRING in eight-bit mode, and neither TEXT
+           nor COMPOUND_TEXT in UTF-8 mode.
+         <li>For compatibility with previous versions of XTerm, a resource
+           <code>i18nSelections</code> is provided, please see the manpage for
+           details.  However, due to an unexpected combination of ICCCM
+           extensions by various bits and pieces of the libraries, interacting
+           with previous versions of XTerm will work in many locales even
+           without this flag.  (Please do not set this resource to true by
+           default, as this would violate the ICCCM.)
+         </ul>
+
+       <li>improved error checking/reporting in VTInitI18N(), ensuring that
+         lack of input method styles is treated distinctly from a mismatch.
+
+       <li>remove an incorrect ifdef from patch #141 which suppressed
+         overstriking to simulate bold font when xterm was compiled to support
+         wide characters (report/analysis by Adam M Costello
+         &lt;amc@cs.berkeley.edu&gt;, Debian #76404, Debian #77575).
+
+       <li>modify <code>RequestResize()</code> function to save/restore window
+         manager hints.  Its call to <code>XtMakeResizeRequest()</code> had
+         the undesirable side-effect of clearing window manager hints, e.g.,
+         when switching to 132-columns via DECCOLM escape sequence.  Window
+         manager hints make it simple to resize xterm in terms of character
+         cells rather than pixels (reports by Christian Weisgerber,
+         Debian #79939).
+         <p>
+         This applies to the normal configuration.  When built with toolbar
+         support, the hints are applied to a different widget level (more
+         work will be needed to make hints work with the toolbar).
+
+       <li>fix a redefinition warning for resize.c on OpenBSD (patch by
+         Christian Weisgerber).
+
+       <li>change resource corresponding to <code>-T</code> option to match
+         Xt library's <code>-title</code>, i.e.,  <code>.title</code>
+         rather than <code>*title</code> so the command-line options are
+         interchangeable as documented (Debian bug report #68843).
+
+       <li>add script used from autoconf'd makefile for installing manpages,
+         since recent XFree86 changing the way section numbers are represented
+         makes the install dependent on extra scripts.
+
+       <li>add configure check for freetype libraries and configure option
+         --disable-freetype to override this feature.
+
+       <li>modify some configure script macros to avoid using changequote(),
+         which has been rendered useless in the latest autoconf alpha 2.49c
+
+       <li>update config.guess, config.sub to 2001-2-13
+
+       <li>remove redundant/contradictory __CYGWIN__ definitions from resize.c
+
+       <li>correct manpage typo introduced by X11R6.5 resync.
+</ul>
+       Changes from XFree86 4.0.2:
+<ul>
+       <li>add definition of <code>_POSIX_C_SOURCE</code> for Solaris to
+         make this compile with <code>gcc -ansi -pedantic</code> (report
+         by &lt;mark@zang.com&gt;.
+</ul>
+
+<H1><A NAME="xterm_150">Patch #150 - 2000/12/29 - XFree86 4.0.2</A></H1>
+<ul>
+       <li>move the binding for shifted keypad plus/minus, which invokes the
+         <code>larger-vt-font()</code> and <code>smaller-vt-font()</code>
+         actions, respectively, into the translations resource (suggested by
+         Marius Gedminas &lt;mgedmin@puni.osf.lt&gt;).
+
+       <li>modify configure script to support the
+         <code>--program-prefix</code>, <code>--program-suffix</code> and
+         <code>--program-transform-name</code> options (request by Alison
+         Winters &lt;alison@mirrabooka.com&gt;).
+
+       <li>fixes for wide/combining characters (Robert Brady):
+       <ul>
+          <li>fix a scrolling / combining characters display anomaly
+
+          <li>fix a problem with double-width characters where if the primary
+              font had no box-drawing characters, the right hand half of
+              double-width characters was erased (reported by Yao Zhang
+              &lt;yzhang@sharemedia.com&gt;).
+
+          <li>fix special case of null byte for key handling in UTF-8 locales.
+       </ul>
+
+       <li>modify logic that compares sizes of normal and bold fonts to be
+         more forgiving of the font server's choice of bold font which must
+         match the normal font's size.  Now <code>same_font_size()</code>
+         compares the height of the fonts rather than individually ascent and
+         descent, and allows the bold font to be one pixel smaller than the
+         normal font (addresses a report by Alan Citterman
+         &lt;alan@mticket.com&gt;, who says that something in patches #146 to
+         #148 made xterm more likely to overstrike bold fonts, and indirectly
+         Debian bug report #76404, which reports the opposite).
+
+       <li>make configure script use $CFLAGS and $CPPFLAGS consistently,
+         including removing a chunk from configure.in which attempted to
+         save/restore $CPPFLAGS while processing value set by the --x-includes
+         option, but lost values set in an intervening AC_CHECK_HEADERS.  This
+         change modifies macros CF_ADD_CFLAGS, CF_ANSI_CC_CHECK and
+         CF_X_TOOLKIT, as well as removing variables IMAKE_CFLAGS and X_CFLAGS
+         from the generated makefile (the AC_CHECK_HEADERS problem was
+         reported by Albert Chin-A-Young &lt;china@thewrittenword.com&lt;).
+
+       <li>correct a comparison in SELECTWORD case of ComputeSelect(), which
+         resulted in a word-selection wrapping past the first column without
+         checking the first column's character class (reported by Christian
+         Lacunza &lt;celacunza@netscape.net&gt;
+
+       <li>correct a logic in UTF-8 mode for selecting double-width characters;
+         a combining character was omitted (patch by Markus Kuhn).
+
+       <li>add feature to pop (raise) window when a bell is received
+         (patch by Gael Roualland &lt;gael.roualland@dial.oleane.com&gt;).
+
+       <li>add __NetBSD__ and __OpenBSD__ to special-case in xterm_io.h
+         for USE_POSIX_TERMIOS definition (patch by Christian Weisgerber).
+
+       <li>move special-case HPUX include for &lt;sys/bsdtty.h&gt; to
+         xterm_io.h to define TIOCSLTC, making HAS_LTCHARS defined for HPUX
+         10.20 (report by Bruno Betro).
+</ul>
+
+<H1><A NAME="xterm_149">Patch #149 - 2000/12/6 - XFree86 4.0.1h</A></H1>
+<ul>
+       <li>restructured includes for <code>termios.h</code>,
+         <code>termio.h</code> and related definitions for main.c, os2main.c,
+         screen.c and resize.c so they will share equivalent definitions in a
+         new header <code>xterm_io.h</code>.  This is intended to solve some
+         problems mainly for HPUX which appear to arise from inconsistent
+         definitions for SIGWINCH- and HAS_LTCHARS-related symbols (reports
+         by Bruno Betro, Jeremie Petit and Clint Olsen).
+
+       <li>improve usability of double-width fonts by allowing normal fonts
+         to be given as double-width (from a patch by Fabrice Bellard
+         &lt;bellard@email.enst.fr&gt;).
+
+       <li>correct a few compiler warnings in TRACE() macros for
+         signed/unsigned variable differences (reported by Clint Olsen).
+
+       <li>make configure script use $CFLAGS and $CPPFLAGS more consistently,
+         i.e., by using CF_ADD_CFLAGS in CF_ANSI_CC macro.
+
+       <li>expanded description of environment variables in manual-page.
+
+       <li>modify OPT_TCAP_QUERY feature to always return the termcap or
+         terminfo capability string in the response, and to read/write the
+         names in hexadecimal form to allow for the special case of termcap's
+         <code>k;</code> name (patch by Bram Moolenaar).
+
+       <li>add OPT_SAME_NAME and OPT_TCAP_QUERY to xtermcfg.hin, so the
+         corresponding configure options work (patch by Bram Moolenaar).
+
+       <li>resync with XFree86 4.0.1g:
+       <ul>
+         <li>Rewrite Xft library for Render extension/core text and font management
+           Change xterm to use new interface (Keith Packard).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_148">Patch #148 - 2000/10/31 - XFree86 4.0.1d</A></H1>
+<ul>
+       <li>document logfile options in man-page.
+
+       <li>correct spelling of <code>-samename</code> option in help message.
+
+       <li>add configure script option <code>--enable-tcap-query</code>
+         (request by Bram Moolenaar).
+
+       <li>add a "Co" or "colors" entry to the OPT_TCAP_QUERY feature
+           (patch by Bram Moolenaar).
+       <li>patch by Kiyokazu Suto &lt;suto@ks-and-ks.ne.jp&gt;:
+       <ul>
+         <li>add support for bold font for double width characters.
+            The font name may be specified with the command line option
+            <code>-fwb</code> or with resource
+            <code>wideBoldFont</code> (class <code>WideBoldFont</code>).
+         <li>correct underlining of double width character string, which
+            was drawn only half width.
+         <li>correct binary search of precomposed character table, which
+            may return wrong result when <code>int</code> is just 32 bits.
+         </ul>
+
+       <li>some changes to align terminfo with ncurses 5.2:
+       <ul>
+         <li>remove xtermm description, retaining xterm-mono since the former
+           conflicts with ncurses.
+         <li>modify initialization and reset strings to avoid putting the
+           save/restore cursor operations bracketing changes to video
+           attributes, since the changes could be lost when the cursor is
+           restored.  This affects xterm-r6 and xterm-8bit (the xterm-xfree86
+           entry uses the soft-reset feature which resets scrolling margins
+           and origin mode without requiring us to save/restore the cursor
+           position).
+         <li>make a few entries explicitly inherit from xterm-xfree86 rather
+           than xterm: xterm-rep, xterm-xmc, xterm-nrc
+       </ul>
+
+       <li>ensure that sign-extension does not affect <code>ctype</code>
+         macros by using <code>CharOf()</code> macro to coerce the parameter
+         to an unsigned char.
+
+       <li>resync with XFree86 4.0.1d:
+       <ul>
+         <li>Add primitive support in xterm for Xft based fonts (Keith Packard).
+           The changes are ifdef'd with <code>-DXRENDERFONT</code>.
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_147">Patch #147 - 2000/10/26 - XFree86 4.0.1c</A></H1>
+<ul>
+       <li>correct implementation of <code>ptyInitialErase</code>:  the
+         value assigned to <code>initial_erase</code> was for the control
+         terminal, which is correct as far as it goes.  But there was no
+         following test for the pseudo-terminal's erase value, which would
+         overwrite the default obtained from the control terminal
+         (reported by Christian Weisgerber &lt;naddy@mips.inka.de&gt;).
+
+       <li>modify check for printable-characters in OSC string to use xterm's
+         ansi_table rather than isprint() macro, to isolate this check from
+         locale settings.  This fixes a problem using 8-bit characters to
+         set the title (reported by Ricardas Cepas &lt;rch@richard.eu.org&gt;).
+
+       <li>modify sample scripts to check for printf before print, since the
+         latter is not as well standardized (e.g., on Linux).
+
+       <li>updated config.sub, config.guess to reflect changes on
+         subversions.gnu.org
+</ul>
+
+<H1><A NAME="xterm_146">Patch #146 - 2000/9/12 - XFree86 4.0.1c</A></H1>
+<ul>
+       <li>correct two instances overlooked from patch #141 which assumed
+         UTF-8 mode without checking, causing a core dump in non-UTF-8 mode
+         (one instance was reported by Tommi Virtanen &lt;tv@debian.org&gt;).
+
+       <li>correct a problem selecting from the scrollback buffer in UTF-8
+         mode by changing remaining getXtermCell() calls to XTERM_CELL() as in
+         the non-UTF-8 cases (report by Markus Kuhn, patch by Robert Brady).
+</ul>
+
+<H1><A NAME="xterm_145">Patch #145 - 2000/9/11 - XFree86 4.0.1c</A></H1>
+<ul>
+       <li>changes for UTF-8 configuration (Robert Brady):
+       <ul>
+         <li>doublewide characters don't lose their accents when the cursor
+           moves onto or from them (a visual bug)
+
+         <li>fix logic in addXtermCombining, which mean that if the low byte
+           of a cell's first combining char was 0, a following combining char
+           would go into combining slot 1, not 2.
+
+         <li>modify logic for cut-buffers so UTF-8 data is first converted
+           to Latin1.
+
+         <li>collapse surrogates, 0xfffe, 0xffff to UCS_REPL.
+
+         <li>modify to allow xterm to to show combining characters
+          attached to doublewidth characters.
+
+         <li>correct bug in linewrap with -u8 option (reported by
+           Andreas Koenig &lt;andreas.koenig@anima.de&gt;).
+       </ul>
+
+       <li>several changes to PTY logic (based on request by Tim Ryan
+         &lt;timryan@nortelnetworks.com&gt;).
+       <ul>
+         <li>modify treatment of <code>-S</code> option to to make it work with
+           Unix98 PTY's.
+
+         <li>restore sense of IsPts flag in <code>get_pty()</code>, which was
+           lost in Unix98 changes.
+
+         <li>use new functions <code>my_pty_id()</code> and
+           <code>my_pty_name()</code> to simplify/fix strings used for utmp,
+           wtmp identifiers.
+
+         <li>simplify <code>get_pty()</code> function, making it have a single
+           return point so its inputs/outputs can be identified.
+       </ul>
+
+       <li>update config.guess and config.sub and scripts to my 20000819 patch,
+          adding cases for OS/2 EMX.
+
+       <li>add special case for os390 compiler options to configure script
+         (patch by Paul Gilmartin)
+
+       <li>fix some unused-variable compiler warnings (reported by
+         Zdenek Sekera).
+
+       <li>split-out some string functions into xstrings.c, to use them
+         more consistently among main.c, os2main.c and resize.c
+
+       <li>align termcap/terminfo files, adding entries to make them match.
+         The termcap entries are necessarily less complete than the terminfo,
+         to fit within 1023 character per entry.
+
+       <li>add terminfo entry for xterm-sco (SCO function keys).
+
+       <li>modify <code>same_font_name()</code> to properly handle wildcard
+         introduced in <code>bold_font_name()</code>, making comparison for
+         different fonts succeed when only the normal font is specified.  This
+         is needed to decide if 1-pixel offset should be used.  (reported
+         in a newsgroup by Bart Oldeman &lt;enbeo@enbeo.resnet.bris.ac.uk&gt;)
+
+       <li>correct preprocessor line for OPT_WIDE_CHARS in drawXtermText()
+         from patch #141 which resulted in overstriking for bold fonts not
+         working.
+
+       <li>correct Imakefile from 4.0.1c resync so UTF-8 modules are in
+         UTF8SRC, UTF8OBJ lists, allowing build without UTF-8 support.
+</ul>
+
+<H1><A NAME="xterm_144">Patch #144 - 2000/8/23 - XFree86 4.0.1b</A></H1>
+<ul>
+       <li>remove a spurious assignment in ScreenWrite() from Robert Brady's
+         patch which set a null at the "end" of the buffer to be written.
+         That made the autowrap feature write a blank in the first column for
+         the non-UTF-8 configuration, rather than the actual character
+         (reported by Alan Citterman &lt;alan@mticket.com&gt;).
+</ul>
+
+<H1><A NAME="xterm_143">Patch #143 - 2000/8/19 - XFree86 4.0.1b</A></H1>
+<ul>
+       <li>add a check to ensure that <code>-class</code> command-line option
+         is not confused with <code>-c</code> (reported by Paul Townsend
+         &lt;aab@aab.cc.purdue.edu&gt;).
+</ul>
+
+<H1><A NAME="xterm_142">Patch #142 - 2000/8/18 - XFree86 4.0.1b</A></H1>
+<ul>
+       <li>correction to precompose scripts, so 0061 + 0300 will now be really
+         be displayed as 00C0 (patch by Robert Brady
+         &lt;robert@susu.org.uk&gt;).
+
+       <li>correct macro ClassSelects() in button.c, used to hide ifdef's for
+         OPT_WIDE_CHARS in patch #141 (reported by Andreas Paul
+         &lt;paula@informatik.tu-muenchen.de&gt;).
+
+       <li>change wcwidth.h to include stddef.h rather than wchar.h, which is
+         not present on OpenBSD and FreeBSD (reported by Christian
+         Weisgerber and Bram Moolenaar).
+
+       <li>newer config.sub and config.guess, from lynx 2.8.4dev.7
+</ul>
+
+<H1><A NAME="xterm_141">Patch #141 - 2000/8/14 - XFree86 4.0.1b</A></H1>
+<ul>
+       <li>changes for doublewidth and combining characters, from
+         http://www.ecs.soton.ac.uk/~rwb197/xterm/
+         (integrated patch by Robert Brady).
+         In this context,
+         doublewidth refers to 16-bit character sets which may have glyphs
+         occupying two cells.
+
+       <li>add command-line option <code>-class</code>, which allows one
+         to override xterm's resource class.  Also add resource file
+         <code>UXTerm.ad</code>, which simplifies using xterm for both
+         8-bit character sets and UTF-8.
+
+       <li>fixes/improvements to OPT_TCAP_QUERY logic (patches by Bram
+         Moolenaar, Steve Wall).
+</ul>
+
+<H1><A NAME="xterm_140">Patch #140 - 2000/7/23 - XFree86 4.0.1</A></H1>
+<ul>
+       <li>modify Makefile.in to circumvent GNU make's built-in suffix rule
+         for ".sh" which confuses install.sh with the "make install" target
+         (report/patch by Paul Gilmartin).
+
+       <li>implement an experimental control sequence which an application may
+         use to query the terminal to determine what sequence of characters it
+         would send for a given function key.  This is ifdef'd with
+         OPT_TCAP_QUERY (request by Bram Moolenaar).
+
+       <li>add /usr/local to search path in CF_X_ATHENA configure macro
+         to build with Xaw3d on OpenBSD (patch by Christian Weisgerber).
+
+       <li>add missing <code>#undef HAVE_TERMIO_C_ISPEED</code> to
+         xtermcfg.hin, omitted in patch #133 fix for IRIX 6.5 baudrate (report
+         by Alain Filbois &lt;Alain.Filbois@loria.fr&gt;).
+
+       <li>correct a few errors in xterm.man:  font in filename example for
+         Tektronix emulation, and description of -nul/+nul command-line
+         options (report by Eric Fischer &lt;enf@pobox.com&gt;).
+
+       <li>update config.guess and config.sub, from tin and lynx.
+</ul>
+
+<H1><A NAME="xterm_139">Patch #139 - 2000/6/17 - XFree86 4.0d</A></H1>
+<ul>
+       <li>back out change to <code>-name</code> command-line option,
+         restoring its original behavior (as noted by David Madore, the
+         correct interpretation of this option is the application instance
+         rather than the application class).
+</ul>
+
+<H1><A NAME="xterm_138">Patch #138 - 2000/6/15 - XFree86 4.0c</A></H1>
+<ul>
+       <li>workaround for fixed fonts which are generated from Unicode fonts:
+         they omit glyphs for some xterm's less-used line-drawing characters,
+         which caused xterm to set a flag telling it to use only its internal
+         line-drawing characters.  Do not set the flag (it can be set from the
+         popup menu), and xterm will generate only the line-drawing glyphs
+         which actually are missing.
+         <br>
+         Otherwise, when used for large fonts, xterm may generate a 2-pixel
+         wide line, which can leave dots on the screen.
+
+       <li>restore first line of 256colres.pl, omitted in 4.0c diffs.
+</ul>
+<H1><A NAME="xterm_137">Patch #137 - 2000/6/10 - XFree86 4.0b</A></H1>
+<ul>
+       <li>make command-line <code>-name</code> option work as documented.
+         Apparently this was lost in X11R5 when coding to use
+         <code>XtAppInitialize</code>.
+
+       <li>limit numeric parameters of control sequences to 65535 to
+         simplify checks for numeric overflow.
+
+       <li>change index into UDK list to unsigned to guard against numeric
+         overflow making the index negative (Taneli Huuskonen
+         &lt;huuskone@cc.helsinki.fi&gt;).
+
+       <li>change <code>sun&nbsp;function-keys</code> resource name to
+         <code>sunFunctionKeys</code> to work around redefinition of the
+         token <code>sun</code> by xrdb on Solaris.  Similarly, renamed
+         resource <code>sun&nbsp;keyboard</code> to <code>sunKeyboard</code>
+         (Steve Wall).
+
+       <li>change similar resource names for HP and SCO to avoid potential
+         conflict with xrdb symbols on other systems, as well as for
+         consistency.
+
+       <li>reorganized the install targets in the autoconf'd Makefile, adding
+         install-app, install-bin, install-dirs and install-man.  The
+         app-defaults class can be overridden by setting the make variable
+         'CLASS', simplifying customization of xterm as a Unicode terminal,
+         e.g., CLASS=UXTerm.
+
+       <li>add limit checks to <code>ClearInLine()</code>,
+         <code>ScrnInsertChar()</code>, <code>ScrnDeleteChar()</code> to
+         correct potential out-of-bounds indexing (prompted by Debian bug
+         report #64713, which reported a problem with ICH escape sequences).
+
+       <li>updates to config.sub and config.guess
+         Kevin Buettner &lt;kev@primenet.com&gt; for elf64_ia64
+         Bernd Kuemmerlen &lt;bkuemmer@mevis.de&gt; and MacOS X.
+
+       <li>for os390, add check for errno set to
+         ENODEV on failure to open /dev/tty when there is no controlling
+         terminal (patch by Paul Gilmartin).
+
+       <li>fixes for building on Digital Unix 4.0 and AIX 4.2
+           (patch from H Merijn Brand &lt;h.m.brand@hccnet.nl&gt;).
+
+       <li>modify DECRQSS reply for DECSCL to additionally report if the
+         terminal is set for 8-bit controls.
+</ul>
+
+<H1><A NAME="xterm_136">Patch #136 - 2000/6/3 - XFree86 4.0b</A></H1>
+<ul>
+       <li>add a resource (<code>limitResize</code>)
+         limiting resizing via the CSI 4 t and CSI 8 t sequences.
+
+       <li>ignore out-of-bounds resize requests, i.e., where sign-extension
+         or truncation of the parameters would occur.
+</ul>
+
+<H1><A NAME="xterm_135">Patch #135 - 2000/5/29 - XFree86 4.0b</A></H1>
+<ul>
+       <li>remove code introduced in #134 which made some backgrounds bold.
+
+       <li>minor correction to format of updated $TERMCAP when adding
+         <code>kb</code> capability for <code>ptyInitialErase</code> logic.
+
+       <li>improved test for SVR4 definition.
+</ul>
+
+<H1><A NAME="xterm_134">Patch #134 - 2000/5/28 - XFree86 4.0b</A></H1>
+<ul>
+       <li>update URL's and mailing addresses, moved to http://dickey.his.com
+         and dickey@herndon4.his.com
+
+       <li>correct missing quotes in CF_TTY_GROUP configure script macro in
+         case the script is run in batch mode.
+
+       <li>modify ownership-check of log file to ignore the group ownership.
+         Otherwise xterm cannot create logfiles in directories with set-gid
+         permissions.
+
+       <li>simplify the logic that reads termcap data.
+
+       <li>add fallback definition for B9600 in case line speed definition
+         for 38400 is missing (report by Jack J Woehr &lt;jwoehr@ibm.net&gt;,
+         for OpenBSD 2.6).
+
+       <li>fix:  Set highlightColor, and select a region containing the text
+         cursor.  If the window loses focus, the cursor becomes hollow, with
+         the region inside the cursor being background/foreground, unlike the
+         rest of the selection, which is foreground/highlight
+         (patch by Ross Paterson &lt;ross@soi.city.ac.uk&gt;).
+
+       <li>add configure script tests to define SVR4, SYSV and USE_POSIX_WAIT,
+         which enables xterm to compile on Solaris 7 and SCO Openserver
+         without imake, though there are still a few features for the latter
+         which require <code>sco</code> to be predefined.
+
+       <li>patches from Steve Wall:
+       <ul>
+       <li>add support for two Sun-specific function keys.  These keys are
+         labeled F11 and F12 on Sun Type 5 keyboards, but return SunXK_F36 and
+         SunXK_F37.  Support will only be compiled in if the header file
+         &lt;X11/Sunkeysym.h&gt; exists and contains the appropriate symbol
+         definitions.  The keycodes for the DEC keycodes were arbitrary unused
+         codes, but the ones for the Sun keycodes are what cmdtool and
+         shelltool actually send.
+
+       <li>add <code>colorRV</code> and <code>colorRVMode</code> resources to
+         allow specifying a color to use for reverse video, similar to the
+         existing UL, BD, and BL modes.
+
+       <li>add <code>alwaysUseMods</code> resource, to override check if
+         <code>alt</code> or <code>meta</code> modifiers are used in
+         <code>translations</code> resource.  Revamped the code to calculate
+         the modifier value, and included Meta if alwaysUseMods is TRUE, using
+         values 9-16.
+       </ul>
+
+       <li>fixes for os390 (Paul Gilmartin):
+       <ul>
+       <li>regularize the definition of CONTROL() and remove an
+         acknowledged "trial and error" table.
+
+       <li>translate "^?" into A2E(0177) which is the EBCDIC "DEL"
+         rather than plain 0177 which is the EBCDIC quotation mark.
+
+       <li>modify <code>xtermMissingChar()</code> so that EBCDIC codes 128-159
+         are not rendered as blanks by X server running on Solaris, which sees
+         those as control characters.
+
+       <li>make debugging traces (configure --enable-trace)
+        work properly with EBCDIC.
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_133">Patch #133 - 2000/5/2 - XFree86 4.0a</A></H1>
+<ul>
+       <li>add substitutions in autoconf'd Makefile for CPPFLAGS, LDFLAGS and
+         AWK (reported by Neil Bird).
+
+       <li>correct uninitialized <code>childstat</code> variable from patch
+         #131 in <code>creat_as()</code> function, which caused logging to not
+         work on Solaris, whose <code>waitpid()</code> function does not
+         initialize its parameter.  Add check for EINTR on return from
+         <code>waitpid()</code> as well (reported by Neil Bird
+         &lt;neil.bird@rdel.co.uk&gt;).
+
+       <li>remove a redundant check for working <code>setuid()</code> function
+         introduced in patch #132. Greg Smith reports that this does not work
+         as intended on os390.
+
+       <li>change line speed from 9600bd to 38400bd, to accommodate people who
+         mistakenly use $TERM set to <em>vt100</em>, to reduce the effect of
+         padding associated with this terminal type.
+
+       <li>add configure script check for IRIX 6.5's redefinition of baud
+         rates associated with <code>struct termio</code>, to correct a
+         situation where the baud rate was initialized to zero (reported by
+         Andrew Isaacson &lt;adi@lcse.umn.edu&gt;).
+
+       <li>remove unused configure script check for VDISABLE.
+</ul>
+
+<H1><A NAME="xterm_132">Patch #132 - 2000/4/11 - XFree86 4.0a</A></H1>
+<ul>
+       <li>undo an incorrect change from patch #113 caused the right scrollbar
+         to be positioned incorrectly when re-enabling it (analysis by
+         D Roland Walker).
+
+       <li>add ctrlFKeys resource, replacing constant for adjusting
+         control-F1 to control-F12 to VT220-style F10-F20.  The resource
+         changes the constant 12 to a default value of 10 (request by
+         Jim Knoble &lt;jmknoble@pobox.com&gt;).
+
+       <li>correct ifdef'ing for conflict between definitions in AIX's
+         &lt;sys/select.h&gt; and &lt;X11/Xpoll.h&gt; (reported by Clint
+         Olsen).
+
+       <li>add checks for return-values of getutid(), initgroups() and
+         setuid() in main.c, as well as modifying ifdef's for __osf__ to
+         include tty-group and WTMP logic (adapted from patch by Paul Szabo
+         &lt;psz@maths.usyd.edu.au&gt;)
+
+       <li>modify resize.c to build and work on os390 (uses EBCDIC)
+         (adapted from patch by Phil Sidler &lt;Phil.Sidler@airborne.com&gt;)
+
+       <li>use Ires(), Bres() and Sres() macros to simplify resource list in
+         charproc.c
+
+       <li>resync with XFree86 4.0a:
+       <ul>
+         <li>correct a typo in os2main.c (Holger Veit, from 4.0a).
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_131">Patch #131 - 2000/3/3 - XFree86 3.9.18b</A></H1>
+<ul>
+       <li>improve logfile security (integrated patch by Branden Robinson)
+         <ul>
+         <li>make the <code>creat_as()</code> function more strict by using
+           O_EXCL rather than O_APPEND.
+         <li>fixes to make DEBUG ifdef's compile/run, including making the
+           debug logfile more unique by appending a timestamp to its name.
+         <li>include &lt;term.h&gt; in resize.c, to fix a missing-prototype
+           warning.
+         </ul>
+
+       <li>modified <code>creat_as()</code> a little more, retaining the
+         ability to append to a logfile If the user specifies the name.
+         Also, check if the opened file (which patch #130 ensures is
+         owned by the effective user) is not writable by other users.
+
+       <li>use <code>creat_as()</code> logic to make tek4014 screen-copy
+         more secure (noted by Branden Robinson).
+
+       <li>ifdef'd some of Branden's changes to build/work on older machines.
+
+       <li>correct missing initialization of the <code>.mode</code> flag in
+         <code>ColorRes</code> struct, from patch #129.  This worked on Linux
+         because <code>malloc()</code> zeroes memory on that platform
+         (reported by Christian Weisgerber).
+
+       <li>modify logic for <code>deleteIsDEL</code> resource so it has
+         internally 3 states:  unspecified, true and false.  If unspecified,
+         the keyboard type determines whether the Delete key transmits
+         <code>&lt;ESC&gt;[3~</code> or <code>\177</code>, and the popup menu
+         entry reflects the internal state.  Otherwise, the popup menu entry
+         overrides the keyboard type (suggested by Dr Werner Fink, to make it
+         simpler to set resources that imitate the legacy X11R6 xterm).
+</ul>
+
+<H1><A NAME="xterm_130">Patch #130 - 2000/3/1 - XFree86 3.9.18a</A></H1>
+<ul>
+       <li>modify <code>scroll-forw()</code> and <code>scroll-back()</code>
+         actions, adding a third parameter which will direct xterm to ignore
+         the action when mouse reporting is enabled.  This is needed for
+         the wheel mouse to be used to report to the application rather than
+         scroll the window.
+
+       <li>add menu entry and action to allow disabling xterm's assumption
+         that the current font contains line-drawing characters if the
+         font cells 1-31 are nonempty.  Some fonts may have other characters
+         (reported by Bruno Betro &lt;bruno@iami.mi.cnr.it&gt;).
+
+       <li>add a check in <code>creat_as()</code> to ensure that the user
+         really owns the logfile that has been opened.
+
+       <li>add logic to implement SCO function-keys.  (This is really
+         incomplete, since I intend to revisit this and make xterm able to
+         emulate scoansi better than just the function-keys).
+
+       <li>add configure script option --enable-sco-fkeys, minor related fixes
+         (patch by Dr Werner Fink).
+
+       <li>fix typos in ctlseqs.ms (reported by Bram Moolenaar)
+
+       <li>fix typo in sinstall.sh default for $TST_PROG (reported by
+         Paul Gilmartin &lt;pg@sweng.stortek.com&gt;)
+</ul>
+
+<H1><A NAME="xterm_129">Patch #129 - 2000/2/26 - XFree86 3.9.18a</A></H1>
+<ul>
+       <li>improve initialization of ANSI colors by delaying allocation until
+         each color is first used.
+
+       <li>remove ifdef that prevented colorBD/colorUL/colorBL resources from
+         working when 256-color configuration was built (reported by
+         Todd Larason).
+
+       <li>fix some minor inconsistencies in terminfo (Debian #58530).
+</ul>
+
+<H1><A NAME="xterm_128">Patch #128 - 2000/2/17 - XFree86 3.9.18</A></H1>
+<ul>
+       <li>correct logic for <code>oldXtermFKeys</code> resource, fixes a core
+         dump when attempting to set it from the command-line (reported by Dr
+         Werner Fink).
+       <li>correct ifdef for meta-sends-escap so configure --disable-num-lock
+         builds.
+</ul>
+
+<H1><A NAME="xterm_127">Patch #127 - 2000/2/12 - XFree86 3.9.17e</A></H1>
+<ul>
+       <li>add resource, popup menu entry and control sequence to allow
+         changing the Delete key to send either DEL or the VT220-style
+         Remove escape sequence.
+
+       <li>remove logic for metaSendsEscape that would allow xterm to send
+         <code>&lt;ESC&gt;[3~</code> before a function key that would begin
+         with <code>&lt;ESC&gt;[3~</code> (request by Christian Weisgerber).
+
+       <li>add missing action and documentation for meta-sends-escape.
+
+       <li>correct a few typos in ctlseqs.ms (incorrect code for Cyan color)
+</ul>
+
+<H1><A NAME="xterm_126">Patch #126 - 2000/2/8 - XFree86 3.9.17c</A></H1>
+<ul>
+       <li>ensure that xterm will automatically activate the UTF-8 mode whenever
+         the name of the locale environment variable suggests that a UTF-8
+         locale is in use (patch by Markus Kuhn).
+         This will help that by simply setting LC_CTYPE an
+         entire system can be switched over to UTF-8, without users having to
+         remember the UTF-8 command line options ("-u8", etc.) of the various
+         applications.  Command line options and X resource entries can still
+         be used to override this default choice.
+
+       <li>add old function-keys control sequences and popup menu entry, for
+         compatibility with legacy X11R6 xterm.
+
+       <li>revert translation of editing keypad "Delete" key to legacy \177.
+
+       <li>simplify the color-resource data expressions with macro COLOR_RES,
+         for later use in restructuring color initialization.
+
+       <li>change encoding of wheel mouse (buttons 4 and 5) to avoid conflict
+         with legacy mouse modifiers (suggested by Bram Moolenaar).
+</ul>
+
+<H1><A NAME="xterm_125">Patch #125 - 2000/1/31 - XFree86 3.9.17c</A></H1>
+<ul>
+       <li>make this work on OpenVMS
+           (integrated patch by David Mathog).
+
+       <li>rename some functions, e.g., <code>Index</code> to
+         <code>xtermIndex</code> so that ports such as VMS which link
+         externals ignoring case will not have library conflicts (reported by
+         David Mathog).
+
+       <li>correct logic of <code>do_reversevideo()</code>, which did not
+         update the corresponding popup menu check mark (reported by David
+         Mathog, this was a detail overlooked in patch #94).
+
+       <li>change TRACE macro so semicolon is not within definition, making
+         <em>indent</em> and similar programs work better.
+
+       <li>add <code>depend</code> rule to Makefile.in
+
+       <li>modify logic of boldColors resource to suppress it if an extended
+         color control has been used, e.g., for 88-color or 256-color mode
+         (patch by Todd Larason).
+
+       <li>revise logic that handles menus and input translation for keyboard
+         type so only one can be selected at a time.
+
+       <li>restore kdch1=\177 for the Sun function-key type, and make the
+         the Delete key send DEL (\177) if the oldXtermFKeys resource is set.
+
+       <li>rephrase logic and ifdef's for POSIX VDISABLE to avoid preprocessor
+         expression that will not compile on NetBSD/x86 1.4.1 (reported by
+         Takaaki Nomura &lt;amadeus@yk.rim.or.jp&gt;).
+
+</ul>
+
+<H1><A NAME="xterm_124">Patch #124 - 2000/1/27 - XFree86 3.9.17b</A></H1>
+<ul>
+       <li>change coding of editing keypad's "Delete" key to
+         &lt;escape&gt;[3~, in the default (Sun/PC) keyboard mode.
+         This makes the terminfo kdch1 capability independent of the
+         coding of the backarrow key, which sends either backspace (8)
+         or DEL (127).  The reason for doing this (compatibility with
+         the <em>screen</em> program) outweighs the choice of DEL (127)
+         which was used in X11R5/X11R6 xterms.  The <em>screen</em>
+         program translates whatever matches kdch1 into &lt;escape&gt;[3~,
+         even if it happens to be the stty erase character.
+
+       <li>add encoding for control/?, to work around xmodmap or key
+         translations which may confuse backspace and delete.  A control/?
+         will send DEL (127), and a control/H will of course send backspace
+         (8).
+
+       <li>add encoding for kcbt to &lt;escape&gt;[Z (fixes Debian #54840).
+
+       <li>minor correction to logic that encodes Sun and DEC function keys
+         to avoid sending an escape sequence if the key symbol is not found
+         in xterm's lookup table.
+
+       <li>simplify ifdef's in main.c for POSIX VDISABLE so the "^-" pattern
+         is more likely to be implemented when <em>imake</em> configures xterm
+         (fixes Debian #55105).
+
+       <li>change manpage to make it clearer what codes are sent by the
+         backarrow key.
+</ul>
+
+<H1><A NAME="xterm_123">Patch #123 - 2000/1/22 - XFree86 3.9.17a</A></H1>
+<ul>
+       <li>add a note reserving OSC 51 for use in Emacs shell (request by
+         Rob Mayoff &lt;mayoff@dqd.com&gt;).
+
+       <li>correct a missing backslash in xterm-vt220 termcap.
+
+       <li>cleanup remaining quoted includes, preferring bracketed form.
+
+       <li>minor configure-script macro updates from tin and vile.
+
+       <li>add configure-script option for using utempter library, adapted
+         from Redhat 6.1 patch for XFree86 3.3.5
+
+       <li>resync with XFree86 3.9.17a:
+       <ul>
+         <li>correction to QNX support (Frank Guangxin Liu)
+         <li>some cosmetic changes that did not correct any reported problems.
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_122">Patch #122 - 1999/12/28 - XFree86 3.9.16f</A></H1>
+<ul>
+       <li>move the suggested wheel-mouse button translations into charproc.c
+         to simplify customization.  Correct some minor logic errors in the
+         support for buttons 4 and 5, used for wheel mice (reported by
+         Bram Moolenaar).
+
+       <li>implement <em>metaSendsEscape</em> resource, with corresponding
+         control sequence and menu entry.  Like <em>eightBitInput</em>, this
+         causes xterm to send ESC prefixing the given key, but applies to
+         all keys and is independent of the 8-bit/7-bit terminal setting.
+         (requests by Alexander V Lukyanov and Marc Feeley).
+
+       <li>correct potential indexing with negative subscript in udk_lookup(),
+         (reported by Ian Collier &lt;Ian.Collier@comlab.ox.ac.uk&gt;).
+
+       <li>modify configure script that sets TERMINFO_DIR to use ${prefix}
+         rather than /usr if the --prefix option was specified (request by
+         Zdenek Sekera &lt;zs@sgi.com&gt;).
+
+       <li>modify checks for repeat-character control sequence to test the
+         character class against xterm's state table, rather than the
+         isprint() macro (patch by Alexander V Lukyanov).
+
+       <li>change several functions to macros to improve speed
+
+       <li>two corrections to simulation of bold font via overstriking:
+       <ul>
+         <li>use clipping to avoid leaving trash at end of the text, and
+         <li>add brackets so wide-character logic does not fall-through
+           into the overstriking logic (reported by
+           Marc Feeley &lt;feeley@IRO.UMontreal.CA&gt;)
+       </ul>
+
+       <li>add several entries to termcap file to make it have the same set
+        of aliases as the terminfo file.
+
+       <li>scale the color values used for xterm-256color terminfo entry to
+        0..1000, as expected by ncurses.
+
+       <li>change xterm-r6 terminfo definitions for F1-F4 to match program.
+
+       <li>Add QNX/Neutrino support (Frank Guangxin Liu
+        &lt;frank@ctcqnx4.ctc.cummins.com&gt;)
+</ul>
+<H1><A NAME="xterm_121">Patch #121 - 1999/11/14 - XFree86 3.9.16c</A></H1>
+<ul>
+       <li>change label on "Sun/PC Keyboard" popup menu entry to "VT220
+         Keyboard", since the checked state corresponds to VT220 rather than
+         Sun/PC.
+
+       <li>add configure test CF_UTMP_UT_XSTATUS to handle the variants of
+         utmp exit status (reports by Dave Ellement, Jeremie Petit, Tomas
+         Vanhala).
+
+       <li>amend treatment of ALT key
+         (see <a href="#xterm_94">patch #94</a>) so that if ALT is used
+         as a modifier in key translations, then no parameter will be sent
+         in escape sequences for Sun/PC function keys (request by Dr Werner Fink).
+
+       <li>modify default for OPT_I18N_SUPPORT to assume that
+         <code>XtSetLanguageProc()</code> is available in X11R5.
+         <p>
+         Caveat: <code>XtSetLanguageProc()</code> was
+         added fairly late in the X11R5 patches, and some vendors shipped
+         buggy versions of this function (request by Tomas Vanhala).
+
+       <li>correct configure macro CF_SYSV_UTMP to test-link with functions
+         consistent with the header, e.g., getutent() for utmp.h and
+         getutxent() for utmpx.h (reported by Greg Smith).
+
+       <li>modify terminfo entry for <code>xterm-xfree86</code> to reflect
+         modifiers for shift and control which (from a patch by Alexander V
+         Lukyanov).
+
+       <li>modify terminfo entry for <code>xterm-sun</code> to match the
+         function-key definitions in ncurses.  The pageup/pagedown and
+         related function keys correspond to the Sun keyboard, which does
+         not necessarily correspond with X's notion of those keys.
+
+       <li>modify treatment of XK_Delete keysym so it transmits parameterized
+         VT220-style <code>&lt;ESC&gt;[3~</code> if modifiers (shift, control
+         alt) are given (request by Alexander V Lukyanov).
+
+       <li>corrected misspelled resource name in command-line option for
+         HP function keys.
+</ul>
+
+<H1><A NAME="xterm_120">Patch #120 - 1999/10/28 - XFree86 3.9.16c</A></H1>
+<ul>
+       <li>refine the change to <code>SGR_Background()</code> in patch #119,
+         by not flushing the pending scrolling operation if the background
+         color is not actually changing.  This combination occurs when using
+         color-ls to display a long listing, since each line ends with an SGR0
+         which affects only the foreground color.  The unnecessary flushing
+         made it noticeably slower (reported by D Roland Walker
+         &lt;walker@pobox.com&gt;).
+
+       <li>remove obsolete documentation about modifiers which can be returned
+         in mouse tracking mode, and modify logic to ignore modifiers other
+         than the existing ones, e.g., NumLock (prompted by discussions with
+         Christian Weisgerber and Brad Pepers &lt;brad@linuxcanada.com&gt;).
+
+       <li>use free bit from obsolete shift-modifier coding of mouse tracking
+         button events to encode buttons 4 and 5, e.g., for a wheel mouse
+         (requests by Brad Pepers and Bram Moolenaar).
+
+       <li>correct a place where the ptyInitialErase logic did not set the
+         backarrowKey state, and modify it further to use tgetstr() rather
+         than parse the termcap data returned from tgetent() so the
+         ptyInitialErase logic will work when xterm is linked with a terminfo
+         library (based on a patch by Dr Werner Fink &lt;werner@suse.de&gt;).
+
+       <li>fix definition of HAVE_UTMP_UT_HOST for ISC configuration
+           (patch by Michael Rohleder).
+
+       <li>improve configure script's utmp tests (based on reports by Greg
+         Smith for os390, and David Ellement for HPUX).
+
+       <li>modify sinstall.sh to use uid=0 rather than 'root' to determine if
+         the installer is privileged.  This is needed on some systems since
+         more than one account may be privileged (report by Greg Smith).
+
+       <li>add an application resource, <code>messages</code> (and a
+         corresponding -/+mesg option) which controls the initial permission
+         on the terminal:  if messages is set to true (the default), behavior
+         is as without the patch; if it is set to false (as per -mesg), the
+         terminal is opened in mode 0600, thus producing the effect of the
+         <code>mesg n</code> command.  This is useful for users who want to
+         redirect all their messages to one particular xterm:  it is more
+         pleasant to do this with xterm resources than with explicit calls to
+         the <code>mesg</code> program  (patch, description by David Madore
+         &lt;david.madore@ens.fr&gt;).
+</ul>
+
+<H1><A NAME="xterm_119">Patch #119 - 1999/10/16 - XFree86 3.9.16c</A></H1>
+<ul>
+       <li>add responses (DA and DSR) for DEC locator mode
+
+       <li>add coding for ANSI color to DA response
+
+       <li>implement UTF-8 translation for Media Copy (print) operations.
+
+       <li>implement vt320 control sequences for Print Composed Main Display
+         and for Print All Pages.  The latter directs xterm to print the
+         current screen as well as the scrollback buffer.
+
+       <li>correct error in _GNU_SOURCE configure test, which left it always
+         defined.
+
+       <li>add more information, i.e., with strerror for some system calls in
+         the main program which may fail due to insufficient permissions
+         (prompted by a problem report for <code>-C</code> by Jeremie Petit
+         &lt;Jeremie.Petit@digital.com&gt;).
+
+       <li>add workaround for conflict between &lt;X11/Xpoll.h&gt; and
+         &lt;sys/select.h&gt; on AIX 4.3 (Richard Griswold
+         &lt;griswold@acm.org&gt;).
+
+       <li>add configure script test to resolve conflict between between
+         &lt;X11/Xpoll.h&gt; and &lt;sys/select.h&gt;
+
+       <li>modify translation of UTF-8 sequences to reject "overly long"
+         variations (patch by Markus Kuhn).
+
+       <li>remove <code>utf8controls</code> resource, since Markus' change
+         removes the corresponding logic.
+
+       <li>correct a case where colors were not rendered properly.  This
+         happened when an application inserted several lines, then changed
+         colors.  If this was done all in one write, then there would be no
+         intervening refresh, and the new color was applied to the pending
+         scrolling operation which was awaiting the next refresh (reported
+         by Stephane Chazelas &lt;Stephane_Chazelas@Raytheon.com&gt;).
+
+</ul>
+
+<H1><A NAME="xterm_118">Patch #118 - 1999/10/5 - XFree86 3.9.16b</A></H1>
+<ul>
+       <li>refine configure test for utmp versus utmpx, to build on HP-UX 10.x
+         (reported by David Ellement).
+
+       <li>move the configure check for <code>const</code> after the check
+         for ANSI C compiler options, since those may be required to make
+         it work properly on HP-UX.
+
+       <li>add configure test for defining <code>_GNU_SOURCE</code>
+
+       <li>correction to <em>-hold</em> option, ensure that if data is already
+         in the output buffer that it will be displayed before closing the
+         PTY.
+
+       <li>move the configure checks for setuid install of xterm into a script
+         to avoid installing it setuid'd to a non-root user (reported by
+         Adam Sulmicki &lt;adam@cfar.umd.edu&gt;).
+
+       <li>correct configure script's check for termcap.h to avoid using
+         ncurses' version of it on systems that have a working
+         <code>tgetent()</code> function.  This is needed to make
+         <code>resize</code> work properly.
+
+       <li>fix some typography in ctlseqs.ms description of DEC locator events
+         (reported by Steve Wall).
+</ul>
+
+<H1><A NAME="xterm_117">Patch #117 - 1999/9/29 - XFree86 3.9.16b</A></H1>
+<ul>
+       <li>change order of tests in configure script for utmp and utmpx
+         to test utmpx first, to compile on Solaris (reported by
+         Leena Heino &lt;liinu@uta.fi&gt;
+         and Patrik Hagglund &lt;patha@ida.liu.se&gt;).
+
+       <li>add a configure test for utmp.ut_xtime, needed for SCO Openserver,
+         and for lastlog, needed for Redhat 6.0, to refine the utmp/utmpx
+         auto-configure.
+
+       <li>remove a spurious comma in an #undef (reported by
+         David Green &lt;greendjf@cvhp152.marconicomms.com&gt; and
+         David Ellement &lt;ellement@sdd.hp.com&gt; both on HP-UX, whose
+         compiler does care about syntax).
+
+       <li>change ifdef's using __CYGWIN32__ to __CYGWIN__ (reported by Suhaib
+         M. Siddiqi &lt;Ssiddiqi@InspirePharm.Com&gt;, who is told that the
+         next Cygnus release will drop that symbol in their next release).
+
+       <li>minor cleanup of ifdef's for makeColorPair (patch by Steve Wall).
+
+       <li>work around problem observed in XFree86 3.3.5
+           (patch by Alexander V Lukyanov, Mozilla #5419).
+           From the problem report:
+       <blockquote>
+       xterm consumes cpu when selecting text with mouse (holding
+       down left mouse button) and when a program working under the
+       xterm outputs something to stdout.
+       <p>
+       Easy way to reproduce:<br>
+               <code>while :; do echo aaa; sleep 1; done</code><br>
+       (while this runs, select text and hold down left mouse button)
+       watch cpu load.<br>
+       release left mouse button - spinning stops.
+       </blockquote>
+</ul>
+
+<H1><A NAME="xterm_116">Patch #116 - 1999/9/25 - XFree86 3.9.16a</A></H1>
+<ul>
+       <li>modify warning if change-ownership of PTY fails; some
+         configurations may not happen to have old-style pty's (reported by
+         Bob Maynard).
+
+       <li>improve check in configure script for group ownership of installed
+         xterm; some platforms use the -g option of ls to toggle group off
+         rather than on (reported by Greg Smith).
+
+       <li>minor improvement to toolbar geometry, to make it not resizable.
+         This still is not satisfactory (but is usable) since the toolbar
+         overlaps the xterm widget if the window is resized to make it
+         smaller.  It appears that some work is needed for the xterm widget's
+         geometry management to make it function properly.
+
+       <li>implement configure script tests for utmp, tty group.
+
+       <li>implement <em>-hold</em> option, allowing users to retain the
+         window after a shell has exited (this is recently an FAQ, but
+         prompted by a comment by Joachim Plaettner-Hochwarth
+         &lt;plaettner@aem.umn.edu&gt; in comp.unix.programmer, that the IRIX
+         winterm provides this option).
+
+       <li>add support for DEC Locator control sequences for xterm
+         (integrated patch by Steve Wall):
+         <pre>
+
+               DECEFR, "Enable Filter Rectangle"
+               DECELR, "Enable Locator Reports"
+               DECSLE, "Select Locator Events"
+               DECRQLP, "Request Locator Position"
+         </pre>
+         This allows the xterm mouse to be used with applications that use the
+         DEC Locator sequences, such as VAX Tpu, or SMG$ based applications.
+
+       <li>improve print action (patch by Matthias Baake).  From his notes,
+         <ul>
+           <li>Bug 1<br>
+             Underlined text is preceded by ESC&nbsp;[0;2m . This should be ESC&nbsp;[0;4m&nbsp;,
+             ESC&nbsp;[2m doesn't seem to have any effect. (print.c/send_SGR)
+
+           <li>Bug 2<br>
+             The check for the last non-empty column (while (last &gt; 0) ... in
+             print.c/printLine) omits the rightmost column of the screen, the loop must
+             start with last = screen-&gt;max_col+1 instead of last = screen-&gt;max_col.
+
+           <li>Bug 3<br>
+             Any attributes of the first character (and of all immediately following
+             characters with the same attributes) are ignored. The variable attr
+             (print.c/printLine) should be initialized with 0, not with *a &amp; SGR_MASK.
+         </ul>
+</ul>
+
+<H1><A NAME="xterm_115">Patch #115 - 1999/9/18 - XFree86 3.9.16a</A></H1>
+<ul>
+       <li>integrated changes by Steve Wall to implement an 88-color model
+         for systems where 256-colors cannot be allocated.
+
+       <li>when 256-color configuration is compiled, colored bold and
+         underlining is not available; ifdef'd to avoid possible odd effects
+         in this case (reported by Steve Wall).
+
+       <li>add resource <em>cacheDoublesize</em>, to limit the caching of font
+         information for double-sized characters.  This addresses a problem
+         reported by Aryeh Koenigsberg for X terminals with limited font
+         memory.
+
+       <li>modify treatment of line-drawing characters in UTF-8 mode so that
+         the Unicode values are used rather than the C0 codes for storing the
+         translated characters (request by Markus Kuhn).
+</ul>
+
+<H1><A NAME="xterm_114">Patch #114 - 1999/9/15 - XFree86 3.9.16</A></H1>
+<ul>
+
+       <li>add configure script checks for Athena headers and libraries under
+         /usr/contrib to work on HPUX (reported by several people:
+               David Nixon &lt;djn@csc.liv.ac.uk&gt;
+               Aryeh Koenigsberg &lt;aryeh.koenigsberg@telrad.co.il&gt;
+               Johannes M&#x00E4;hner &lt;johanm@camline.com&gt;
+               Andrew Gaylard &lt;andrew.gaylard@bsw.co.za&gt;).
+
+       <li>add check to configure script if xterm is installed setgid rather
+         than setuid, since wtmp and utmp may be installed with group-writable
+         permissions other than root (based on Debian bug report #7112 by Bo
+         Branten &lt;bosse@ing.umu.se&gt;).
+
+       <li>rewrote logic that removes data from termcap entry, e.g., for
+         titeInhibit, to make it less likely to remove the wrong data.
+
+       <li>correct logic which checks for missing characters used for line
+         drawing.  The 0 character was tested unnecessarily, leading to
+         some inefficiency when rendering.
+
+       <li>change termcap capability which is used as input or output of
+         ptyInitialErase logic from <em>kD</em> to <em>kb</em>.
+         Christian Weisgerber &lt;naddy@mips.rhein-neckar.de&gt; pointed out
+         in effect that <em>kD</em> (in terminfo <em>kdch1</em>) should
+         correspond to the control sequence for <em>dch1</em>, which deletes
+         from the current position toward the right.
+
+       <li>check for failure to change ownership of the PTY device and warn
+         when xterm is running setuid'd to root.  This was reported to happen
+         on the FreeBSD/NetBSD/OpenBSD systems as a result of the chflags()
+         call.
+
+       <li>add xterm-noapp terminfo entry to illustate a nominally
+         bash-compatible terminal description.
+</ul>
+
+<H1><A NAME="xterm_113">Patch #113 - 1999/8/15 - XFree86 3.9.15b</A></H1>
+Several fixes.  The main one is a first draft of pulldown menus.  It's not
+complete (I have some minor/annoying geometry problems to correct), but is
+usable.  Once it's complete I plan to add a menu to support additional
+selections that won't fit on the current popup menus.  Also, this fits into my
+longterm plan to allow configuring with Motif libraries.
+
+<ul>
+       <li>correct error in input conversion for NRC mode (reported by
+         Stefan Traby &lt;stefan@sime.com&gt;).
+
+       <li>fix initialization of num_lock data in Misc struct (since those
+         fields of the reference widget aren't initialized), and add logic to
+         deal with XVision whose NumLock key does not transmit but does alter
+         keypad state.
+
+       <li>correct a missing return-value in get_pty(), for SCO
+
+       <li>add E2A fix for backspace (patch by Greg Smith), i.e.,<br>
+         #define VAL_INITIAL_ERASE A2E(127)
+
+       <li>correct foreground color within cursor outline when the
+         window is unfocused (reported by Stephane Chazelas).
+
+       <li>corrected position of scrollbar set in ResizeScrollBar(), which
+         left it positioned incorrectly if the right scrollbar were enabled
+         from the popup menu but was not initially enabled.
+
+         <p>
+         I have noticed some additional problems with right-scrollbar on
+         X11R5 which I will correct later.
+
+       <li>integrate changes by Jean-Claude Michot for QNX from XFree86 3.3.4c
+
+       <li>add resources menuBar/MenuBar, menuHeight/MenuHeight for later
+         use in toolbar geometry.
+
+       <li>add configure option --enable-toolbar
+
+       <li>add missing definition to make ziconbeep logic not compile-in when
+         configure script disables it.
+
+       <li>add configure-check for input-method support in X libraries
+</ul>
+
+<H1><A NAME="xterm_112">Patch #112 - 1999/7/17 - XFree86 3.9Pw</A></H1>
+<ul>
+       <li>add null-pointer check to FlushLog(), fixes a core dump when both
+         -l and -lf options are used when xterm is configured with wide-character
+         support.
+
+       <li>remove "ISO" case for SD, which was due to a typographical error in
+         ECMA-48 (reported by Paul Williams &lt;paul@celigne.co.uk&gt; for
+         vttest).
+
+       <li>add "FILES" section to manpage.
+
+       <li>generate header file to initialize default resources for colors
+         16-255.
+
+       <li>fixes for os390 (Greg Smith):
+       <ul>
+         <li>add README.os390
+
+         <li>use the pty_search() function to find an available pty/tty pair.
+
+         <li>move E2A() call out of getXtermCell() to SaveText() function
+             so it will be available in all configurations.
+       </ul>
+
+       <li>patches by Todd Larason:
+       <ul>
+         <li>enable SGR 48 5 in ISO color mode, not just 256 color mode
+
+         <li>change configure's --disable-256-color option to
+           --enable-256-color, to match its effect
+
+         <li>fix OSC 4 xx ?  (report ansi color) to report a string which can
+           actually be used to set the color back
+
+         <li>fix OSC 4 xx yy (change ansi color) to not allow setting colors &gt;
+           15 in 16 color mode
+
+         <li>simplify the COLOR_ settings a bit in ptyx.h, along with setting
+           NUM_ANSI_COLORS needed for #1 and #4 above
+
+         <li>correct string-terminator code passed for reference to OSC
+           responses; when in 7-bit mode, only the final byte of ST was seen.
+
+         <li>Allow multiple color #;name pairs in OSC 4,
+           and document changes to match.
+       </ul>
+</ul>
+
+<H1><A NAME="xterm_111">Patch #111 - 1999/7/10 - XFree86 3.9Pw</A></H1>
+<ul>
+       <li>add control sequences for specifying the RGB value of the ANSI
+         colors, and for configuring with 256 colors (patch by Todd Larason
+         &lt;jtl@molehill.org&gt;).  I made the default configuration to
+         16-colors, because xterm uses the default color map (which has only
+         256 colors).
+
+       <li>correct an error in DCS $ q m reporting for colors 8-15 (Todd
+         Larason).
+
+       <li>add test/demo script for double size characters.  Used this to
+         test/correct display of double size characters that should wrap,
+         underlined double size characters.
+
+       <li>increased cache size for double size fonts to 8, to allow for both
+         normal and bold fonts (discussion with Aryeh Koenigsberg
+         &lt;aryeh.koenigsberg@telrad.co.il&gt;).
+
+       <li>add fixes for port to OS390 aka MVS
+           (integrated patch from Greg Smith &lt;rys@epaibm.rtpnc.epa.gov&gt;).
+           OS390 uses EBCDIC rather than ASCII.
+
+       <li>correct an off-by-one in binary search limits in keysym2ucs.c (Markus
+         Kuhn).
+
+       <li>implement logging for UTF-8 mode.  The output is written in UTF-8 form.
+</ul>
+
+<H1><A NAME="xterm_110">Patch #110 - 1999/6/29 - XFree86 3.9Pu</A></H1>
+<ul>
+       <li>If colorMode is enabled by default, compile-in default resources to
+         match the colors listed in XTerm-col.ad (this should fix a
+         longstanding FAQ).
+
+       <li>added new OSC&nbsp;3&nbsp;;&nbsp;PROPNAME=VALUE&nbsp;ST escape
+         sequence to set an arbitrary X property on the top level xterm X11
+         window.  Omit "=VALUE" to delete the X property (patch by Greg Badros
+         &lt;gjb@cs.washington.edu&gt;).
+
+       <li>change internal flag used for <em>utf8controls</em> resource
+         so we allow 31-bit range of characters (suggested by Thomas Wolff).
+
+       <li>add check for 16-bit characters in OSC strings, change them to '?'
+         (reported by Thomas Wolff).
+
+       <li>modify logic of same_font_name() to avoid trying to interpret both
+         parameters as wildcard patterns.  That does not (cannot) work, and in
+         some instances the font server will return unresolved wildcards for
+         the normal or bold fontnames, making them match inadvertently,
+         triggering the fallback overstrike logic (reported by Tim Adye).
+</ul>
+
+<H1><A NAME="xterm_109">Patch #109 - 1999/6/23 - XFree86 3.9Pt</A></H1>
+<ul>
+       <li>correct range-check from patch #108, which resulted in not being
+         able to select from the scrollback buffer (reported by Tim Adye
+         &lt;T.J.Adye@rl.ac.uk&gt;)
+
+       <li>correct "no available ptys" problem with Cygwin B20.1 (patch by Tim
+         Adye).
+
+       <li>modified install-ti rule in Makefile.in to allow override of the
+         terminfo directory when doing a "make install", i.e., by assigning
+         to TERMINFO_DIR (request by Zdenek Sekera &lt;zs@sgi.com&gt;).
+
+       <li>added install-full rule to Makefile.in
+
+       <li>resync mkdirs.sh and install.sh scripts against current autoconf
+
+       <li>implement $(DESTDIR) in Makefile.in, making it simple to install
+         xterm and associated files into a directory just for packaging a
+         binary release (suggested by CaT &lt;cat@zip.com.au&gt;).
+
+       <li>change IChar type to unsigned, rather than unsigned short, making
+         room for a flag to keep with 16-bit characters to prevent them from
+         being interpreted as C0 or C1 controls (reported by Thomas Wolff).
+
+       <li>correct a typo from patch #107, incorrect array name, in the
+         filterUTF8 function (patch by Bruno Haible &lt;haible@ilog.fr&gt;)
+
+       <li>add <em>utf8controls</em> resource to specify whether xterm should
+         interpret 16-bit characters unpacked from UTF-8 form as control
+         characters if they happen to fall into that range.  This behavior
+         is left unspecified by the Unicode standard (request by Thomas Wolff).
+
+       <li>modify handling of OSC to recover if application sends 16-bit
+         characters with codes above 255.  We cannot display them as is, but
+         translate out-of-range characters to a '?' (reported by Thomas
+         Wolff).
+</ul>
+
+<H1><A NAME="xterm_108">Patch #108 - 1999/6/19 - XFree86 3.9Ps</A></H1>
+<ul>
+       <li>add a range-check to LastTextCol(), to guard against indexing
+         before the beginning of the scrollback buffer.  This appears to
+         happen with certain fonts under X11R5 (reported by Stephane Chazelas
+         &lt;Stephane_Chazelas@Raytheon.com&gt;).
+
+       <li>implement resource <em>boldMode</em>, to allow disabling the
+         simulation of bold fonts when the bold and normal fonts are not
+         different (requested by Will Day &lt;willday@rom.oit.gatech.edu&gt;).
+
+       <li>change the atom "UTF-8" to "UTF8_STRING", and fixes a few bugs in
+         the UTF-8 selection (patch by Juliusz Chroboczek).
+
+       <li>correct logic of binary-search in keysym2ucs.c (patch by Markus
+         Kuhn).
+
+       <li>add special interpretation of keysym codes above 0x1000000 as
+         the corresponding UCS value plus 0x1000000 (patch by Markus Kuhn).
+</ul>
+
+<H1><A NAME="xterm_107">Patch #107 - 1999/6/12 - XFree86 3.9Pq</A></H1>
+<ul>
+       <li>Two changes from Stephen P Wall.
+         From his description:
+       <blockquote>
+       The first change is simple - I added ESC[3J to erase the stored lines
+       above the screen.  That's what the changes to util.c and ctlseqs.ms
+       are.
+       <p>
+       The second change is to get the blinking cursor working.  I took out
+       the cursorBlinkTime resource, and put in cursorBlink (Boolean),
+       cursorOnTime (time cursor is on in msecs) and cursorOffTime, and added
+       a cursorblink item to the vtMenu to enable/disable it.
+       </blockquote>
+
+       <li>improve selection (integrated patch by Juliusz Chroboczek).
+         From his description:
+       <blockquote>
+       With this patch, selection conversion works properly:
+<pre>
+       ISO 8859-1 xterm -&gt; ISO 8859-1 xterm (transferred as STRING);
+       ISO 8859-1 xterm -&gt; UTF-8 xterm (transferred as STRING);
+       UTF-8 xterm -&gt; ISO 8859-1 xterm (transferred as STRING);
+       UTF-8 xterm -&gt; UTF-8 xterm (transferred as UTF-8).
+</pre>
+       It will not work properly if one xterm is in, say, ISO 8859-2.
+       Actually, for this case xterm breaks the ICCCM routinely (sending ISO
+       8859-2 data as STRING), so I wouldn't worry too much about it.  I have
+       not changed the behaviour in eight-bit mode in any way.
+       </blockquote>
+</ul>
+
+<H1><A NAME="xterm_106">Patch #106 - 1999/6/9 - XFree86 3.9Pq</A></H1>
+<ul>
+       <li>remove duplicate fix for OpenBSD in resize.c
+
+       <li>correct logic in ScreenWrite, which did not reset the high bytes
+         of 16-bit characters when overwriting them with a 8-bit character
+         string (reported by Thomas Wolff).
+
+       <li>provide limited support for
+           input of UTF-8 16-bit data by a lookup table
+           (integrated patch by Markus Kuhn).
+
+       <li>correct check in non_blank_line to ensure we're in wide-character
+         mode before looking at the high bytes, for InsertChar.
+</ul>
+<H1><A NAME="xterm_105">Patch #105 - 1999/6/5 - XFree86 3.9Pp</A></H1>
+<ul>
+       <li>implement new resource <em>trimSelection</em>, which allows xterm
+         to trim trailing blanks from selected lines.  This does not affect
+         the highlighting. (reported by several people using <em>mutt</em>,
+         including
+         Hans Morten Kind &lt;edphk@uib.no&gt;,
+         Jeremy &lt;jeremy@exit109.com&gt;
+         and (Michael Fuller &lt;msf@mds.rmit.edu.au&gt;).
+
+       <li>include term.h in resize for OpenBSD (patch by Matthieu Herrb).
+
+       <li>correct logic for UTF-8 in functions that hide and show the cursor;
+         it was displaying a space whenever the low byte of the character at
+         the cursor position was zero (reported by Thomas Wolff
+         &lt;Thomas.Wolff@icn.siemens.de&gt;).
+</ul>
+
+<H1><A NAME="xterm_104">Patch #104 - 1999/5/30 - XFree86 3.9Pn</A></H1>
+This is a resync patch against XFree86 3.9Pn, reflecting changes which were
+submitted by Branden Robinson, who worked with
+Wichert Akkerman &lt;wichert@cs.leidenuniv.nl&gt;
+to set up ifdef's to handle GNU libc 2.1,
+and use getpt() which lets xterm avoid having to know the actual PTY name.
+<p>
+I have also added a few fixes for signed/unsigned mismatches, and corrected
+a problem in the configure script (the UTF-8 code was always configured since
+the Imakefile defines this).
+
+<H1><A NAME="xterm_103">Patch #103 - 1999/5/14 - XFree86 3.9Pm</A></H1>
+<ul>
+       <li>correct selection logic: I omitted an offset that accounts for
+         the distance into the scrollback buffer when rewriting this for
+         patch #101.  Also fixed a similar problem for selecting double
+         size characters from the scrollback buffer (first was reported
+         by D Roland Walker &lt;walker@pobox.com&gt;).
+
+       <li>improved support for Unix98 PTY's, using patch in Debian bug report
+         #35650, by J.H.M. Dassen &lt;jdassen@wi.leidenuniv.nl&gt;. From
+         the patch description:
+       <blockquote>
+       <ul>
+       <li>No longer links xterm against libutil on a glibc2.1 system.
+         libutil is a compatibility library and should only be used when
+         necessary.  Rather than having get_pty() use openpty() from this
+         compatibility library, use the real UNIX98 pty support in get_pty()
+         (open()ing the master pty, through getpt() if available (glibc
+         extension)).  Use openpty() only under glibc2.0.
+       <li>GNU libc2 is not Linux-specific; already it runs on the Hurd.  It
+         provides the UNIX98 pty functions (plus the getpt() extension),
+         regardless of the underlying OS.  Changed two constructs to look for
+         GNU libc2 only, not GNU libc2 on Linux.
+       </ul>
+       </blockquote>
+
+       <li>improve font configuration, by checking if the user's resource
+        settings for normal and bold fonts give the same font sizes
+        (fixes problem reported by Peter Waltenberg &lt;peterw@dascom.com&gt;).
+</ul>
+
+<H1><A NAME="xterm_102">Patch #102 - 1999/5/12 - XFree86 3.9Pm</A></H1>
+<ul>
+       <li>revert change to openpty call in patch #101; this causes xterm to
+         fail on DEC-Alpha OSF/1 4.0B (reported by H Merijn Brand).
+
+       <li>modify print.c to move include of stdio.h after the autoconf'd
+         xtermcfg.h since HP's ANSI C compiler otherwise sees inconsistent
+         prototype for getopt, probably due to problem with const (reported by
+         H Merijn Brand).
+</ul>
+
+<H1><A NAME="xterm_101">Patch #101 - 1999/5/10 - XFree86 3.9Pm</A></H1>
+<ul>
+       <li>moved includes and definitions for 'select' from data.h to xterm.h
+         to fix problem introduced by prototype for getPtyData, part of UTF-8
+         changes (reported by Jens Schleusener &lt;Jens.Schleusener@dlr.de&gt;)
+
+       <li>added "Meta &lt;Btn2Down&gt;:clear-saved-lines()" default
+         translation (patch by H Merijn Brand)
+
+       <li>fixes to configure script and ifdef's in main.c to build on a
+         HP9000/D390 (hppa-2.0w) running HP-UX 11.00 (64 bit) with egcs 1.1.2
+         and HP's ANSI C compiler (patch by H Merijn Brand
+         &lt;PROCURA_BV@CompuServe.com&gt;)
+
+       <li>add more parentheses in ifdef's (patch by Bob Maynard).
+
+       <li>eliminate conflicting definitions for USE_TERMINFO in resize.c
+         (reported by Jeremy Buhler).
+
+       <li>change openpty call to pass NULL rather than ttydev parameter,
+         since that was used only to estimate the length of the
+         corresponding data, and may not really be long enough
+         (reported by Andreas Jaeger)
+
+       <li>update description in xterm manpage for character class table,
+         which said it handles only 7-bit codes.
+
+       <li>correct a typo in ScrnDeleteChar() which made it not clear the
+         high byte of wide-character data.
+
+       <li>add logic to convert selection to UTF-8 form when appropriate.
+         This makes select/paste "work", but further work is needed to
+         make UTF-8 recognized as a locale in Xlib.
+
+       <li>correct right-limit check when selecting double-width characters.
+
+       <li>change default answerback response to an empty string.
+</ul>
+
+<H1><A NAME="xterm_100">Patch #100 - 1999/5/3 - XFree86 3.9Pl</A></H1>
+<ul>
+       <li>Correct a typo in the default resource value for
+         backarrowKeyIsErase:  it was always true (reported by Bram
+         Moolenaar).
+
+       <li>improve configure script's test if the installed xterm is setuid,
+         in case that is a symbolic link.
+
+       <li>correct "install-ti" rule in Makefile.in, by not setting a blank
+         $TERMINFO value.  That is interpreted as "." by ncurses' tic.
+</ul>
+
+<H1><A NAME="xterm_99">Patch #99 - 1999/5/2 - XFree86 3.9Pk</A></H1>
+<ul>
+       <li>correct logic that computes num_ptrs count of the number of indices
+         into the screen buffer.  This is the maximum of the colors and
+         character-set indices; was incorrect in patch #97.
+
+       <li>correct argument type for sigsetjmp, incidental change in patch
+         #96's Unix88 PTY patch (reported by Bram Moolenaar).
+
+       <li>correct description of secondary DA in ctlseqs.ms (reported by Bram
+         Moolenaar).
+
+       <li>decouple the backarrowKey and ptyInitialErase resources by
+         adding a new resource backarrowKeyIsErase, to accommodate people
+         using applications which have hardcoded tests for characters 8 and
+         127 rather than relying on the stty settings.
+
+       <li>modify the UTF-8 decoder so that all possible illegal UTF-8
+         sequences are properly represented by U+FFFD.  This should be very
+         helpful for developers of code that output UTF-8 strings for
+         debugging.  See the file utf-8-test.txt in
+         http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz for a
+         demonstration text that contains numerous illegal UTF-8 values.
+         (patch by Markus Kuhn).
+
+       <li>correct a place in ScrnRefresh where I was filling the high byte of
+         a wide character with a space rather than a null (reported by Markus
+         Kuhn).
+</ul>
+
+<H1><A NAME="xterm_98">Patch #98 - 1999/4/26 - XFree86 3.9Pk</A></H1>
+<ul>
+       <li>correct data manipulation in unparseputc(), broken for
+         little-endian machines by patch #97's UTF-8 changes.  This meant that
+         keyboard input on SunOS did not work, though Linux i386 was fine.
+
+       <li>modify initialization for backarrowKey and logic for initial-erase
+         to prevent the initial-erase from overriding an explicitly set
+         backarrowKey resource (reported by Vikas Agnihotri).
+
+       <li>add a missing null-pointer check in ScrnRefresh, for the
+         wide-characters configuration.
+</ul>
+
+<H1><A NAME="xterm_97">Patch #97 - 1999/4/25 - XFree86 3.9Pk</A></H1>
+<ul>
+       <li>add configure script test for -lutil, needed for openpty call when
+         configuring xterm for Glibc-2.1 and Unix98 PTY's (first reported by
+         Martin Lorentz" &lt;m.lorentz@w12.link-goe.de&gt;).
+
+       <li>completely parenthesize ifdef expressions for Glibc (suggested by
+         Bob Maynard).
+
+       <li>add initial-erase options (-ie, +ie) to help message (reported by
+         Vikas Agnihotri).
+
+       <li>remove duplicate definition of USE_USG_PTYS (reported by Jeremy
+         Buhler).
+
+       <li>change termcap <em>kD</em> and terminfo <em>kdch1</em> to a DEL
+         (\177).
+         I overlooked this when separating the styles of keyboard with
+         the <em>sunKeyboard</em> resources in patch #94, so that it normally
+         matches the value of the stty erase character:
+         <ul>
+         <li>Reported by Jae Gangemi &lt;jgangemi@ccf.rutgers.edu&gt;,
+           this caused emacs to not process the DEL properly, combining it
+           with succeeding characters.
+         <li>This does not appear to be related to a problem which I have
+           found with <em>screen</em>, which translates the stty erase into
+           the termcap <em>kD</em> or terminfo <em>kdch1</em> value
+           (depending on how it is linked)
+           if the $TERMCAP variable is set when <em>screen</em> is invoked.
+         </ul>
+
+       <li>add command-line options for enabling UTF-8 mode: -u8 and +u8.
+         The more obvious -utf8 and +utf8 would conflict with xterm's
+         -ut and +ut (utmp) options.
+
+         The UTF-8 changes were requested by Markus Kuhn
+         &lt;Markus.Kuhn@cl.cam.ac.uk&gt;.  This patch does not complete UTF-8
+         implementation, but makes it usable, i.e., display and refresh work,
+         and I am able to display the test cases which Markus provides.
+         More work is needed to complete this feature:
+         <ul>
+         <li>the control sequences for switching in/out of UTF-8 mode are
+           partly implemented (don't use them).  Similarly, the switching
+           between vt100 and tek4014 emulations when UTF-8 mode is enabled
+           will not work properly.
+           <p>
+           You must use the -u8 command line option
+           to use this feature, as well as compile with the OPT_WIDE_CHARS
+           definition.
+         <li>cut/paste only copies 8-bit characters.
+         <li>logging is disabled in the wide-character configuration
+         <li>printing only writes 8-bit characters.
+         <li>input only does 8-bit characters.  This is the area that I know
+           least about.
+         </ul>
+</ul>
+
+<H1><A NAME="xterm_96">Patch #96 - 1999/4/19 - XFree86 3.9Pj</A></H1>
+<ul>
+       <li>modify Makefile.in to work with configure script's --srcdir option.
+         (patch by Jeremy Buhler &lt;jbuhler@cs.washington.edu&gt;)
+
+       <li>add checks for 'echo -n' equivalent for 8colors.sh and 16colors.sh
+         scripts (reported by Vikas Agnihotri).
+
+       <li>improve logic that looks for bold fonts to allow for wildcards
+         in the specification for normal fonts, and to ensure that if
+         a bold font is specified as normal, that xterm will simulate a
+         bold version of that using a one-pixel offset overstrike
+         (reported by Henrik Harmsen &lt;harmsen@erv.ericsson.se&gt;).
+
+       <li>correct horizontal spacing of double width line-drawing characters
+         that xterm simulates.
+
+       <li>improve support for Unix98 PTY's, using patch in Debian bug report
+         #35650, by Topi Miettinen &lt;Topi.Miettinen@medialab.sonera.fi&gt;.
+         Andreas Jaeger says this also corrects a permissions problem
+         reported by cat@zip.net.au
+
+       <li>modify initial-erase logic to ensure that <code>ttyModes</code>
+         resource overrides it.
+</ul>
+
+<H1><A NAME="xterm_95">Patch #95 - 1999/4/5 - XFree86 3.9Ph</A></H1>
+<ul>
+       <li>modify primary DA response to allow a '1' parameter.
+
+       <li>add printer and national replacement character sets to VT220
+         primary DA response.
+
+       <li>document primary and secondary DA responses in ctlseqs.ms
+
+       <li>use the patch number (e.g., 95) in the secondary DA response,
+         providing user applications a means of determining the version
+         of xterm for feature comparison (request by Bram Moolenaar).
+
+       <li>make xterm respond to secondary DA when the decTerminalID
+         is set for VT100.
+
+       <li>limit user-defined keys (DECUDK) to VT220-style keyboard
+         when sunKeyBoard resource is true.
+
+       <li>modify ifdef's for Linux-2.2.x with Glibc-2.1 to work with
+         Glibc-2.1 and no Unix98 PTY support (patch from Andreas Jaeger
+         &lt;aj@arthur.rhein-neckar.de&gt;)
+
+       <li>add optional feature (resource and command-line options) to make
+         xterm use the PTY's sense of erase character on startup, rather than
+         requiring it to be \177, or set the PTY's erase character to match
+         xterm's configuration.  Note that while $TERMCAP is modified to
+         reflect the actual configuration, the terminfo kdch1 string is not
+         (request by Dirk H Hohndel &lt;hohndel@suse.de&gt;)
+
+       <li>improve scripts in vttests to work with newer shells that do not
+         use 'echo -n'.
+
+       <li>add fonts.sh example script
+
+       <li>correct inequality in handling of "#1" font specification.
+
+       <li>correct call to XGetWMNormalHints() used for computing maximum
+         screen size; the size hints may not have been set.
+
+       <li>begin implementation of support for wide-characters (configure
+         option --enable-wide-chars defines OPT_WIDE_CHARS, invoke xterm with
+         -wc option to activate this feature).  This patch optionally widens
+         internal data structures, invokes the 16-bit text output rather than
+         the 8-bit version and adds some tables.
+
+</ul>
+<H1><A NAME="xterm_94">Patch #94 - 1999/3/27 - XFree86 3.9Pf</A></H1>
+<ul>
+       <li>further fixes for terminfo: ka1, ka3, etc., differ between the
+         default xterm-xfree86 and xterm-vt220 entries.
+
+       <li>change default (with sunKeyboard resource false) behavior of
+         the editing keypad "Delete" to send a 127, like xterm-r6.
+         The VT220-style <code>&lt;ESC&gt;[3~</code> is sent when
+         sunKeyboard is true (reported by Tomas Vanhala).
+
+       <li>add parameters to function keys to indicate if shift, control
+         or alt are set.  The codes are based on a description of
+         a DEC VT510 with a PC keyboard, from Jeffrey Altman
+         &lt;jaltman@watsun.cc.columbia.edu&gt;.
+
+       <li>add control sequence 1035, set-num-lock action and num-lock
+         menu entry to control the use of the NumLock and Alt keys for
+         the Sun/PC and VT220 keyboard extensions.
+
+       <li>implement DECSET/DECRST numeric keypad (DECNKM) mode.
+
+       <li>modify terminfo and termcap to use recommended "X Window" or "X11"
+         names rather than "X Windows" (reported by Tomas Vanhala).
+
+       <li>suppress translation of shifted keypad "+" when sunKeyboard
+         is true.
+
+       <li>workaround unexpected behavior (perhaps bug) in XmbLookupString,
+         which returns trash in the string buffer for numlock and control-key
+         combined with keypad-keys.
+
+       <li>modify ScrollBarReverseVideo() to keep scrollbar border visible
+         when reverse video is toggled.
+
+       <li>correct missing case for parameter 17 (set highlight color) in
+         dynamic colors control sequences.
+
+       <li>extend dynamic colors control sequences to allow users to
+         determine the colors and font which are currently active.
+
+       <li>minor tweak to OSC responses, to use BEL if the application used
+         that to end the request, rather than ST.  This works better with
+         shell scripts, which may not handle an
+         <code>&lt;ESC&gt;backslash</code> very well.
+
+       <li>separate menu settings for reverse video from that done under
+         program control.
+
+       <li>corrected ifdef's for menus, which did not allow tek4014 to
+         be suppressed properly (reported by Clint Olsen).
+
+       <li>changes for Linux-2.2.x with GLibc-2.1 and
+         /dev/ptmx support (integrated patch from Pavel Roskin):
+       <ul>
+         <li>main.c and resize.c were using different rules to determine
+           whether ATT should be defined (actually USE_USG_PTYS is more
+           apt).
+
+         <li>copy definitions from main.c to resize.c to prevent
+           sys/stream.h and sys/ptem.h from inclusion when SYSV is not
+           defined
+
+         <li>define CNUL if not already defined like other variables.
+
+         <li>/dev/tty does exist in Linux, but it doesn't mean, it
+           should be used.  Therefore EACCES is now an acceptable
+           result.
+
+         <li>ifdef'd several calls such as <code>ioctl (ptyfd, I_PUSH,
+           "ptem")</code> to build on Linux (I_PUSH is not defined when
+           sys/stropts.h is not included).
+       </ul>
+
+       <li>initialize second "ltc" variable in main.c (reported by David
+         Dawes).
+
+       <li>provide definition for USE_USG_PTYS in screen.c
+
+       <li>add resource-files to install rule in standalone Makefile.in
+
+       <li>add sample scripts to illustrate titlebar controls, resizing
+         and colors.
+</ul>
+
+<H1><A NAME="xterm_93">Patch #93 - 1999/3/14 - XFree86 3.9Pd</A></H1>
+Here are several fixes and minor enhancements.  The chief ones
+are the fixes for NumLock mode and reverse video, since we had become
+used to working around the problems.
+<ul>
+       <li>remove kfnd/kll/kslt strings from terminfo, because curses
+         applications do not necessarily return khome/kend pairs
+         (reported by Vikas Agnihotri).
+
+       <li>implement NumLock resource which overrides the keyboard tables for the
+         special case of keypad keys.  This is a problem introduced in xterm
+         by X11R6 changes, i.e., an ambiguity which in effect discarded vt100
+         keypad support.
+
+       <li>modify Sun/PC keyboard mode to extend this (emulation of DEC vt100
+         keypad) to the remainder of the numeric keypad.  Now, the default
+         operating mode of xterm uses the keyboard tables as-is (except if
+         the NumLock mode overrides), but provides good vt100 keypad compatibility
+         if the Sun/PC keyboard menu item is checked.
+
+       <li>separate command-line settings for reverse video from that done
+         under program control.  This is a problem which was introduced by
+         X11R6.  Though <em>correct</em>, most users are confused by allowing
+         the reset command to undo the effect of the command-line <kbd>-rv</kbd>
+         option.
+
+       <li>add description of function keys, keypad and cursor keys to ctlseqs.ms
+
+       <li>add terminfo entries for xterm-vt52, xterm-sun and xterm-hp
+
+       <li>correct typo (missing case value) for DECSET 35, enable/disable
+         shifted keypad action and a few compiler warnings (reported by Zdenek
+         Sekera &lt;zs@sgi.com&gt;).
+
+       <li>correct reporting of color values 8-15 in DECRQSS (reported by
+         Vikas Agnihotri).
+
+       <li>modify parsing of ttyModes resource to recognize "^-" as "undef"
+         (requested by Tomas Vanhala).
+
+       <li>integrate/extend changes to add iconify/maximize actions
+         (from Edward S. Arthur &lt;eda@ultranet.com&gt;).
+
+       <li>add control sequences for maximizing/restoring window, and
+         for reporting maximum screen size.
+
+       <li>add 'interpret' action, to support local function-key interpretation.
+         Used properly, this makes most of the specialized actions of xterm
+         redundant.
+
+       <li>add control sequence private modes 1051, 1052 and 1052, for
+         setting the Sun and HP function key modes, and for setting the
+         Sun/PC keyboard mode.
+
+       <li>add configure option --disable-maximize
+
+       <li>add configure option --disable-num-lcok
+
+       <li>extend descriptions of configure script options in INSTALL.
+</ul>
+
+<H1><A NAME="xterm_92">Patch #92 - 1999/2/5 - XFree86 3.9Nz</A></H1>
+<ul>
+       <li>increase buffer size for tgetent (i.e., termcap) to 1500.  This
+         fixes a problem where <em>screen</em> is built using ncurses or
+         GNU termcap and <em>xterm</em> is built using the standard termcap
+         interface.  The former does not limit the termcap size, while the
+         latter is assumed to be no longer than 1023 characters.  The
+         <em>screen</em> program's termcap entry is about 1200 characters
+         long.
+
+       <li>change update_menu_item() to a function, to simplify debugging.
+         This also reduces the executable by 4Kb.
+
+       <li>add control sequences for DECSET 30, 1010, 1011 like rxvt (enable
+         or disable some features that were only settable via resources or
+         command line arguments).
+
+       <li>add control sequence for DECSET 35, which enables/disables the
+         shifted keypad functions.
+
+       <li>add support for switching font sizes, by stepping through the
+         font menu using shifted keypad plus and minus.
+
+       <li>correct missing initialization of tekInhibit and tekSmall resources.
+
+       <li>correct ifdef's in charproc.c for XtNgeometry and XtCGeometry
+         (reported by Bram Moolenaar).
+</ul>
+
+<H1><A NAME="xterm_91">Patch #91 - 1999/1/21 - XFree86 3.9Nw</A></H1>
+<ul>
+       <li>Implement logic to translate input characters which are mapped
+         when in vt220 National Replacement Character mode (requested by
+         Tomas Vanhala).
+
+       <li>Resync configure scripts with my patches to autoconf 2.13
+
+       <li>Change order of -lXmu and -lXext to accommodate cygwin32
+         (reported by Vikas Agnihotri).
+
+       <li>Add "-ti" option to set terminal emulation level from command
+         line rather than via resource.
+
+       <li>Simplify some of the preprocessor logic using #elif.
+</ul>
+
+<H1><A NAME="xterm_90">Patch #90 - 1998/12/13 - XFree86 3.9Nq</A></H1>
+This implements several small fixes and enhancements.  The chief one implements
+fallback support for line drawing characters with fonts that do not include
+those characters.  But I implemented that last.
+
+<ul>
+       <li>If any of the glyphs in positions 0-31 (used by xterm to implement
+         the VT100 alternate character set) are zero-sized (i.e., missing),
+         xterm will reserve a normal space for the glyph when drawing.  I
+         implemented a simple stroke-drawing function to draw the line-drawing
+         characters and a couple of the other (simpler) characters such as
+         diamond.  (This was suggested by Vikas Agnihotri).
+
+       <li>Modify the computation of doublesize characters to work around font
+         servers which shift the scaled characters up/down or do not give the
+         correct width.
+
+       <li>Add popup menu item and corresponding resource settings to disable
+         the font-scaling logic for doublesize characters to work around
+         (older) font servers which simply do not draw the fonts scaled to the
+         size that they said they would.  I see this problem on a SunOS system
+         running X11R5; the X11R6 servers seem well behaved.
+
+       <li>Implement new escape sequence, private mode 1049, which combines
+         the switch to/from alternate screen mode with screen clearing and
+         cursor save/restore.  Unlike the existing escape sequence, this
+         clears the alternate screen when switching to it rather than when
+         switching to the normal screen, thus retaining the alternate screen
+         contents for select/paste operations.
+
+       <p>When I implemented the popup menu entry to toggle between the normal
+         and alternate screens, I considered only pasting from the normal
+         screen to the alternate; this improvement allows either direction.
+
+       <li>Changed the termcap and terminfo for xterm-xfree86 and xterm-8bit
+         to use the new 1049 private mode.
+
+       <li>Modify the logic which switches between normal and alternate
+         screens so that the save/restore cursor operations apply only to the
+         current screen.  That means that applications which use the terminfo
+         smcur/rmcur or termcap ti/te capabilities will restore the cursor to
+         the original position on the normal screen rather than to the most
+         recent place where a save-cursor operation was performed.
+
+       <p>I note that a real VT100 terminal would not behave in this way,
+         but it is a moot point since the VT100 does not implement alternate
+         screen, and therefore the save/restore cursor sequence would not be
+         used in this context.  I reviewed the logic which switches between
+         normal and alternate screens based on some recent newsgroup postings
+         as well as a proposed patch in the Debian group which attempts to
+         do this (the patch has a bug, however, so I did not use it).
+
+       <li>Add popup menu entry for toggling the titeInhibit resource.
+
+       <li>Add new resource answerbackString, which overrides the default
+         "xterm" returned by xterm when responding to an ENQ (control/E)
+         character (request by Rajesh Vaidheeswarran &lt;rv@fore.com&gt;).
+
+       <li>Add new resource keyboardDialect for setting the NRC display
+         character set (request by Tomas Vanhala, who notes that I should
+         add logic to translate the keyboard as well).
+
+       <li>Add new command-line option and corresponding resources for making
+         xterm generate escape sequences compatible with HP terminals.  Like
+         the existing Sun escape sequences, this is available as a popup menu
+         item.  It is enabled by the configure script with the option
+         --enable-hp-fkeys (requested by Toni Mueller &lt;sales@oeko.net&gt;).
+
+       <li>Add configure script option --disable-boxchars to disable the
+         fallback support for line drawing characters.
+
+       <li>Fix ifdef's for configure script --disable-ansi-color, and reviewed
+         all configure options to ensure that all can be enabled/disabled
+         appropriately.
+
+       <li>Update config.guess and config.sub, from Lynx.
+</ul>
+
+<H1><A NAME="xterm_89">Patch #89 - 1998/11/20 - XFree86 3.9Nm</A></H1>
+This patch completes the implementation of double-sized character support
+for the VT100 emulation, and fixes a few minor bugs:
+
+<ul>
+<li>corrected the cursor position in HideCursor, which did not multiply
+the column by two when in doublesize mode.
+This bug, which did not appear in normal use,
+dates back to my original <a href="#xterm_44">changes</a> to partly implement
+double-sized characters.
+I noticed it when cat'ing a typescript from vttest's double-sized character
+test.
+<li>ensure that the current line is repainted when switching between
+single and double width characters.
+<li>reduce the number of bits used for double-sized character coding
+from 3 to 2, to make more room for soft-font codes.
+<li>copy newer ifdef's from the XFree86 3.3.3 release's main.c,
+which address details of glibc and powerpc.
+<li>moved definition of DECL_ERRNO in xterm.h to match XFree86 3.3.3
+<li>modify <em>resize</em> to remove the ifdef on SVr4 that suppressed
+printing the script for $LINES and $COLUMNS.
+Solaris' resize utility does this; suppressing the behavior is unnecessary.
+</ul>
+I tested the double-sized characters using vttest and the xfsft patch.
+These fonts worked reasonably well:
+<pre>
+       -bitstream-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1
+       9x15
+</pre>
+The iso8859 font does not include box characters, of course, but looks good.
+
+<H1><A NAME="xterm_88">Patch #88 - 1998/10/31 - XFree86 3.9Nk and 3.3.2h</A></H1>
+This refines my #85 patch by checking for a case where the font server
+returns a bold font that does not quite correspond to the normal font.
+When I asked for a bold version of the 6x12 font, the font server
+returned a near equivalent where the ascent and descent values did not
+match, causing xterm to leave lines across the display.
+This patch makes xterm reject that type of mismatch, falling back to the
+old font behavior.
+
+<H1><A NAME="xterm_87">Patch #87 - 1998/10/21 - XFree86 3.9Nj and 3.3.2f</A></H1>
+This corrects a problem reported by Stefan Dalibor.  My table entries for the
+<em>printerExtent</em> and <em>printerFormFeed</em> resources used the wrong
+types for sizeof, causing the printer to not work properly on some platforms
+because the <em>printAttributes</em> resource was overwritten (e.g., Digital Unix with DEC Alpha).
+<p>
+I reviewed all of the resource table entries and fixed a potential problem with
+<em>resizeGravity</em>, which was typed as <em>int</em> rather than
+<em>XtGravity</em>.
+
+<H1><A NAME="xterm_86">Patch #86 - 1998/10/14 - XFree86 3.9Nj and 3.3.2e</A></H1>
+A small fix: when switching to/from the continuous mouse reporting mode,
+the event mask was incorrect if xterm was built under X11R5 because the
+original data was saved under an ifdef for active-icon.
+
+<H1><A NAME="xterm_85">Patch #85 - 1998/10/12 - XFree86 3.9Nj and 3.3.2e</A></H1>
+Some cleanup (I noticed the pixel droppings a few months ago after getting a
+new 17" monitor):
+<ul>
+       <li>split-out the functions that load/reload fonts for xterm as new
+         file fontutils.c to extend them to support automatic loading of
+         bold font corresponding to the normal font.  Adapted logic from
+         EMU 1.3 for this purpose.  This fixes most occurrences of pixel
+         droppings from bold characters.
+
+       <li>modified by renaming variables and adding casts to permit compile
+         with g++.
+
+       <li>modify headers so they can all be compiled without order
+         dependencies, and use bracketed rather than quoting includes to allow
+         compile from separate directory.
+
+       <li>renamed xtermm terminfo entry to xterm-mono, to avoid conflict with
+         Solaris entry now in ncurses.
+</ul>
+
+<H1><A NAME="xterm_84">Patch #84 - 1998/10/9 - XFree86 3.9Ni</A> and 3.3.2e</H1>
+Several small fixes and enhancements, including a patch from
+Bjorn Helgaas:
+<ul>
+       <li>correct initialization of TERMCAP environment variable, which
+         was frequently set to garbage on non-Linux systems because
+         "termcap" and "newtc" contained random data from the stack.
+
+       <li>remove the LINEWRAPPED attribute from lines as they are cleared.
+         Previously, the attribute was set but never cleared.
+
+       <li>make word and line selections work even when lines are wrapped
+         by xterm.  Previously, selections were limited to one screen line.
+</ul>
+as well as
+<ul>
+       <li>modify logic for line-wrapping to reset the associated flag if
+         the application deletes a character. This fixes a problem reported
+         by Bjorn Helgaas where word/line selection would still wrap even
+         after deleting characters from the first line.
+       <li>add kll/kH capabilities to xterm-xfree86 entries in termcap and
+         terminfo (request by Michael Schroeder).
+       <li>shorten descriptions in termcap to make resolved entries all
+         shorter than 1023 character limit.
+       <li>use DECSTR control sequence to shorten initialization and reset
+         strings in xterm-xfree86 termcap and terminfo.
+       <li>use rmul/smul and rmir/smir in xterm-r5 terminfo to match termcap.
+       <li>correct typos in initialization and reset strings in xterm-r5
+         termcap and terminfo.
+       <li>disable special translations of key symbols (the backarrow key,
+         the editing keypad and the keypad "+") when a modifier other than
+         shift, control or numlock is used.  This makes xterm handle the meta
+         key as expected by people using emacs (reported by Pete Harlan
+         &lt;harlan@pointofchoice.com&gt; in linux.debian.user newsgroup).
+</ul>
+
+<H1><A NAME="sync_83">Resync #83 - 1998/10/7 - XFree86 3.3.2e</A></H1>
+
+Merge changes through patch #83 with the 3.3.2e version.
+<p>
+This follows a change from XFree86 CVS which adds checks for non-null
+return from malloc (patch by Matthieu Herrb).
+
+<H1><A NAME="xterm_83">Patch #83 - 1998/8/25 - XFree86 3.9Nb</A></H1>
+Several small fixes and enhancements:
+<ul>
+       <li>add configure test to infer if xterm should be installed setuid
+         based on previously installed xterm (reported by Stephen Marley
+         and Stefan Dalibor).
+
+       <li>implement quasi-continuous mouse reporting
+           (integrated patch by Jason Bacon).
+
+       <li>correct control sequences transmitted by function keys F1 to F4
+         when sunFunctionKeys resource is true (it was still using the
+         VT100 control sequences).
+
+       <li>modify handling of backarrow key so that the control modifier
+         toggles the backspace/delete interpretation set by the
+         backarrowKey resource.
+
+       <li>limit the row and column values used to report mouse position.
+</ul>
+
+From resync with XFree86 3.9Nb:
+<ul>
+       <li>add support for the VSTATUS control character (patch by
+         Robert Earl &lt;rearl@teleport.com&gt;).
+</ul>
+
+<H1><A NAME="xterm_82">Patch #82 - 1998/7/15 - XFree86 3.9Aj</A></H1>
+Bug fix for patch #81:
+<ul>
+       <li>remove an #undef for NBBY, which caused compile problem on FreeBSD
+         (reported by David Dawes).
+</ul>
+
+<H1><A NAME="xterm_81">Patch #81 - 1998/7/14 - XFree86 3.9Aj</A></H1>
+More bug fixes:
+<ul>
+       <li>fix conflicting ifdef's for TIOCSLTC when building with Linux on
+         AXP aka DEC Alpha (reported by Robin Cutshaw).
+
+       <li>correction to patch #79, move assignment for *utptr-&gt;ut_user = 0;
+         back into non-SVR4 ifdef in main.c, since this clobbers username on
+         Solaris 2.5.1 (analysis by Will Day
+         &lt;willday@rom.oit.gatech.edu&gt;).
+
+       <li>corrected khome/kend in xterm-8bit terminfo description.
+
+       <li>improve cursor color by making it always the reverse of fg/bg
+         unless the cursorColor resource is set, i.e., to something other than
+         the default foreground (reported by Vikas Agnihotri and Bram
+         Moolenaar).
+
+       <li>minor fixes for compiler warnings, including a syntax error in
+         the AMOEBA ifdef's.
+</ul>
+From resync with XFree86 3.9Aj:
+<ul>
+       <li>correction to patch #73, supply missing #else for fallback definitions
+         of size_t, time_t (Robin Cutshaw &lt;robin@intercore.com&gt;).
+</ul>
+
+<H1><A NAME="xterm_80">Patch #80 - 1998/6/29 - XFree86 3.9Ai</A></H1>
+This fixes a couple of items leftover or introduced by patch 79:
+<ul>
+       <li>take out the logic that suppresses editing-keypad in vt100 mode
+         (those keys are too valuable to give up for a fine point of
+         emulation).
+
+       <li>corrected a couple of places in terminfo where I missed using the
+         vt220-style editing-keypad codes for Find/Select (mapped to Home/End).
+
+       <li>checked termcap file against terminfo, fix several places where it
+         was inconsistent.
+</ul>
+
+<H1><A NAME="xterm_79">Patch #79 - 1998/6/28 - XFree86 3.9Ai</A></H1>
+
+This patch fixes several small bugs:
+<ul>
+       <li>use X_EXTRA_LIBS in standalone Makefile.in (patch by Tomas Vanhala).
+
+       <li>add new resource 'oldXtermFKeys' which provides backward compatibility
+         for F1-F4 control sequences with TOG's xterm.
+
+       <li>determine the server's default foreground/background Pixel values,
+         needed if the -flipPixels X server option is used (reported by
+         David Dawes).
+
+       <li>correct logic for F1-F4 function keys so that they generate VT100
+         compatible escape sequences in VT220 mode, since that is what the
+         numeric keypad is supposed to do (reported by Ron Johnson, Jr.
+         &lt;ronjohn@communique.net&gt;).
+
+       <li>modify logic for editing keypad to work more like VT220: don't
+         pass those codes in VT100-mode unless oldXtermFKeys mode is set.
+
+       <li>correct an interaction with the editing-keypad logic that prevented
+         backarrow key from sending a 127 for the delete key (the 'remove'
+         escape sequence was being sent instead).
+
+       <li>use return-value from getuid() rather than the parameter, to work on
+         systems which do not update the latter (patch by Kevin Buhr
+         &lt;buhr@mozart.stat.wisc.edu&gt;)
+
+       <li>correct scrollbar border color when toggling to/from secure keyboard
+         mode (patch by Jeff Uphoff &lt;juphoff@tarsier.cv.nrao.edu&gt;)
+
+       <li>modifications to terminfo file:
+<ul>
+         <li>rename description to xterm-xfree86, adding an entry 'xterm'
+           which is derived from xterm-xfree86 to simplify customization.
+
+         <li>change string for kdch1 from \177 to \E[3~, to address complaints
+           from Debian developers.  (This applies to the key labeled "Delete",
+           and does not affect the backarrow key).
+
+         <li>add user-strings u6, u7, u8, u9 to entries to make them work with
+           Daniel Weaver's "tack" program.
+
+         <li>modify xterm-24, xterm-bold, xterm-boldso entries to disentangle them from
+           explicit dependency upon xterm-xfree86.
+
+         <li>add generic 'xterm-color' entry.
+
+         <li>minor corrections to xterm-xfree86, xterm-8bit, xterm-r5 and
+           xterm-r6 entries.
+</ul>
+</ul>
+
+<H1><A NAME="xterm_78">Patch #78 - 1998/6/3 - XFree86 3.9Ah and 3.3.2</A></H1>
+
+Again, most of the bulk of this patch is for ANSI conversion.  I used the
+IRIX compiler's -wlint option to find the remaining functions that use
+K&amp;R syntax (since gcc does not do this properly).
+
+Also, I changed the logic in the print code slightly to close unwanted files
+before opening a pipe to the printer.  This may help in some configurations
+where the line printer hangs until xterm closes the pipe.
+
+<H1><A NAME="xterm_77">Patch #77 - 1998/5/26 - XFree86 3.9Ah and 3.3.2</A></H1>
+
+Most of the bulk of this patch is to convert the extended C (K&amp;R functions
+with prototypes) to ANSI.  I verified that on Linux by comparing object
+files, to ensure that I did not, for example, interchange parameters in
+the function declarations.
+<p>
+The rest of the patch fixes several minor bugs, and adds a few features:
+<ul>
+       <li>back-out my use of ncurses "captoinfo -f" option (if/then/else/endif)
+         formatting, since ncurses did not correctly filter embedded newlines
+         in terminfo capability strings until _after_ ncurses 4.1, thus
+         corrupting setf/setb/sgr strings (reported by Darren Hiebert and
+         others).
+
+       <li>document SGR 8, 28 (invisible/visible), add corresponding
+         capabilities to terminfo description.
+<p>
+         I would also add the 'prot protected capability, but the control
+         sequences for that would not be recognized or properly ignored by the
+         older xterm programs.
+
+       <li>modify ChangeGroup to not suppress a null-resource, but treat it as an
+         empty string (recommended by Stefan Dalibor).
+
+       <li>add printerAutoClose resource to control whether printer is closed
+         when going offline.  More than one person reports problems (on
+         Solaris 2.6 and Digital Unix 4.0) getting the printer to proceed
+         unless xterm exits; I think that it is a problem flushing the pipe.
+         Closing it ought to flush it.
+
+       <li>adapt TOG fix-3 to in HandleKeymapChange and VTInitI18N (but adapt
+         XtStackAlloc/XtStackFree for clarity, as well as fixing memory leak).
+
+       <li>change calls on FillCurBackground to ClearCurBackground, in effect
+         using XClearArea rather than XFillRectangle when clearing as a
+         side-effect of scrolling and insertion  (patch by Alexander V
+         Lukyanov)
+
+       <li>correct some places where insert/delete did not _move_ the color
+         attributes, using memmove (patch by Alexander V  Lukyanov
+         &lt;lav@long.yar.ru&gt;)
+
+       <li>add ifdef's for __CYGWIN32__, for port to cygnus version B19.1
+         (patch by Andrew Sumner &lt;andrew_sumner@hotmail.com&gt;).
+
+       <li>remove #define for hpux that turned on USE_SYSV_ENVVARS, since this
+         causes some applications (such as 'less') to get incorrect $LINES and
+         $COLUMNS values (reported by Clint Olsen).
+
+       <li>modify behavior for HP-UX, to set the "reserved" process group
+         controls to _POSIX_VDISABLE so the TIOCSLTC ioctl does not produce an
+         error (patch by Ben Yoshino &lt;ben@wiliki.eng.hawaii.edu&gt;).
+
+       <li>correct length of underlining, reducing it by one pixel to avoid
+         leaving a dot when the application does not clear the whole screen
+         I noticed this only recently myself (and other people as well); it
+         depends on the font chosen.  A 6x10 font shows it, but the other
+         fonts from XTerm.ad do not.  I also see a similar problem with the
+         emulation of bold fonts.
+         (patch by Sergei Laskavy &lt;Laskavy@cs.msu.su&gt;).
+
+       <li>add include for Xos.h to xterm.h, to ensure proper definitions
+         (reported by Holger Veit).
+
+       <li>update config.guess to recognize Unixware 2.1 and 7 (patch by
+         Mike Hopkirk &lt;hops@sco.com&gt;).
+</ul>
+
+<H1><A NAME="xterm_76">Patch #76 - 1998/5/8 - XFree86 3.9Ah and 3.3.2</A></H1>
+
+A fix for the print-window function, and some minor cleanup:
+<ul>
+       <li>modify logic that closes pipe in the print-window function to not use
+         pclose, which does not work on all systems, since I did not open the
+         pipe with popen (reported by Stefan Dalibor).
+
+       <li>correct name of $(EXTRA_LOAD_FLAGS) imake variable (reported
+         by Stefan Dalibor).
+
+       <li>guard logic in ChangeGroup() function against null pointer
+         (reported by Stefan Dalibor).
+
+       <li>ensure that menu entry for toggling sunKeyboard resource is
+         initialized (reported by Branden Robinson &lt;branden@purdue.edu&gt;).
+
+       <li>gcc unused-variable warnings (reported by Bernd Ernesti
+         &lt;bernd@arresum.inka.de&gt;)
+
+       <li>rename global variable 'buffer' to 'VTbuffer'
+</ul>
+
+<H1><A NAME="xterm_75">Patch #75 - 1998/5/7 - XFree86 3.9Ah and 3.3.2</A></H1>
+
+This incorporates fixes from several people, as well as some improvements
+that I made based on feedback from users:
+<ul>
+       <li>add option to standalone configure script, "--with-own-terminfo-dir",
+         which causes xterm to pass a predefined value of $TERMINFO to the
+         application.  Also use this value in install rule "make install-ti",
+         for the standalone configure script.
+
+         (patch &amp; feedback from Tor Lillqvist &lt;tml@hemuli.tte.vtt.fi&gt;)
+
+       <li>change ifdef's for "hpux" to "__hpux" (patch by Tor Lillqvist).  The
+         imake configuration uses the former, but the latter is predefined by
+         HP's compilers.
+
+       <li>define USE_SYSV_ENVVARS for HP-UX, curses does not use $TERMCAP (patch
+         by Tor Lillqvist).
+
+       <li>on HP-UX, use the /dev/ptym/clone device to allocate PTY's.  Works
+         both on HP-UX 9 and 10.  (patch by Tor Lillqvist).
+
+       <li>modify configure script to obtain the $(EXTRA_LOADFLAGS) value from
+         imake, needed for compiling under DEC OSF/1 (reported by
+         Stefan Dalibor)
+
+       <li>modify print-window action so that the printer is closed after
+         printing a window, unless the printer was already opened (i.e.,
+         by an application running in the window).  This makes the printing
+         complete without having to exit xterm, since not all systems treat
+         fflush through a pipe very well (reported by Stefan Dalibor)
+
+       <li>modify printing code so that the ^M's are not printed if the
+         printAttribute resource is set to zero (request by Stefan Dalibor).
+
+       <li>correct typo in xterm.man, for the default value of printAttribute
+         (reported by Stefan Dalibor).
+
+       <li>correct printing code so that the alternate character set is
+         printed, like other attributes, with escape sequences.
+
+       <li>correct termcap description, removing spurious 'm' character from
+         the 'op' capability (reported by Greg Woods &lt;woods@weird.com&gt;).
+
+       <li>correct trace code so that the initial timestamp is set.
+
+       <li>correct/modify utmp data for the Linux glibc 2 configuration,
+         so that the ut_line member is set before using it to update wtmp
+         (patch by Bill Nottingham &lt;wen1@cec.wustl.edu&gt;).
+</ul>
+
+<H1><A NAME="xterm_74">Patch #74 - 1998/4/27 - XFree86 3.9Ag and 3.3.2</A></H1>
+
+This corrects a couple of recent bugs and adds a new resource:
+<ul>
+       <li>modify definition of TRACE_CHILD so that it does not conflict with
+         ifdef's for USE_USG_PTYS in main.c (reported by Vikas Agnihotri
+         &lt;VikasA@att.com&gt; and Stefan Dalibor).
+
+       <li>correct ownership of file (actually pipe) written by the print
+         controls.  When undoing the setuid changes in patch #69, I overlooked
+         this.  Now xterm forks a process which resets setuid and routes the
+         printer data as the real user.
+
+       <li>add a new resource, "printAttributes", which controls whether
+         color attributes (or any attributes) are sent to the printer.
+</ul>
+
+<H1><A NAME="xterm_73">Patch #73 - 1998/4/25 - XFree86 3.9Ag and 3.3.2</A></H1>
+
+This patch does the following:
+<ul>
+       <li>implements a print-window facility for xterm.  Though useful in
+         itself, I added it as part of some debugging which I am doing.
+         (Occasionally during an exposure event xterm fails to restore the
+         proper colors for highlighted text, and printing the screen will
+         show the internal states nicely).
+<p>
+         The print facility now also displays the color information.
+         (I will probably make this a resource).
+
+       <li>modified the xterm-16color terminfo description to use the setaf and
+         setab strings, which is a little more efficient (requested by Stephen
+         Marley).
+
+       <li>reduced some clutter of the ifdef/includes (e.g., stdlib.h, unistd.h,
+         errno) making the configure script test for these.
+<p>
+         I removed the symbols Size_t and Time_t, since they no longer serve
+         a useful purpose.
+
+       <li>added some debugging traces to show the initial screen size,
+         and the success/failure of the ioctl calls pass handle window
+         resizing events to the application (for Clint Olsen).
+<p>
+         I also modified the trace code to produce two files since some
+         of the information is produced by the child process.  So now
+         they are Trace-parent.out and Trace-child.out
+
+       <li>updated configure test for ANSI compiler options to handle a
+         special case for HP-UX 10.x (reported by Clint Olsen).
+</ul>
+
+<H1><A NAME="xterm_72">Patch #72 - 1998/4/17 - XFree86 3.9Ag and 3.3.2</A></H1>
+
+This is a patch from Chris Siebenmann &lt;cks@hawkwind.utcs.toronto.edu&gt;,
+which I have cleaned up a little, and integrated into the configure script.
+<p>
+From his description:
+<blockquote>
+ This set of patches is the latest incarnation of patches originally
+written by Ian! D Allen, then of the University of Waterloo and now of
+who knows where; I have been carrying them forward from xterm to xterm
+ever since about X11R4.  What they do is add an option so that when an
+iconified xterm receives output it prepends '*** ' to its icon title
+and (optionally) beeps the bell; deiconifying the xterm removes the
+'*** '. Over the years I've found this to be incredibly convenient for
+monitoring all sorts of low-activity things.
+</blockquote>
+
+<H1><A NAME="xterm_71">Patch #71 - 1998/4/12 - XFree86 3.9Ag and 3.3.2</A></H1>
+
+This patch is a slightly modified version of one by Richard Braakman, which
+prevents buffer overflow in the input-method and preedit-type parsing in xterm.
+I changed a couple of details to make the code more maintainable, and looked
+for similar things - copying into a fixed-size buffer (found none, though I did
+spot an unused variable).
+
+<H1><A NAME="xterm_70">Patch #70 - 1998/3/29 - XFree86 3.9Af and 3.3.2</A></H1>
+
+This patch corrects some minor bugs in xterm, and fills in some more details
+in the VT220 emulation:
+<UL>
+       <LI>modify Imakefile to use SpecialCObjectRule for menu and data modules,
+         making xterm build properly if logging is enabled
+         (patch by Scott Sewall &lt;scott@iprg.nokia.com&gt;).
+
+       <LI>restore "ich" capability to terminfo entries, since
+         Michael Schroeder points out that "ich1"
+         is the one which is the problem in Solaris vi.
+
+       <LI>correct color of cursor, which would disappear on inverse-video
+         since the initialization did not compare the cursor color against
+         both foreground and background (reported by Olivier Calle).
+
+       <LI>correct abbreviation-test for -version and -help options, making
+         command-line option -vb work (reported by Stefan Dalibor).
+
+       <LI>correct a dependency between ifdef's for OPT_I18N_SUPPORT and
+         OPT_INPUT_METHOD (reported by Stefan Dalibor).
+
+       <LI>split-out character-set translations as new module charsets.c, to
+         implement VT220 national replacement character sets (a mode where
+         some of the characters are displayed as specific European glyphs).
+         This relies on xterm using an ISO 8859-1 font (approach suggested by
+         Kenneth R. Robinette &lt;zkrr01@mailbox.neosoft.com&gt;).
+
+       <LI>correct a missing increment, which made SS2 and SS3 controls
+         repeat the shifted character.
+
+       <LI>add xterm-nrc to terminfo to illustrate the VT220 national
+         replacement character sets.
+
+       <LI>reformat terminfo using new ncurses tic option "-f", which makes
+         if/then/else/endif expressions easier to read.
+</UL>
+
+<H1><A NAME="xterm_69">Patch #69 - 1998/3/16 - XFree86 3.9Ad and 3.3.2</A></H1>
+
+This corrects the problem in xterm with utmp, reported by Olivier Calle
+&lt;olivier@tc.fluke.com&gt;
+as well as some other people after the XFree86 3.3.2 release.
+<P>
+The error was introduced by my patch #53 in XFree86 3.9r (October 1997).
+<P>
+The correction removes the reset of setuid/setgid before the main event loop,
+and solves the problem which I had worked around in a different manner:  for
+some reason, the particular waitpid() call in creat_as() hangs, does not
+return when the child process exits.  I changed the ifdef's to force the Linux
+configuration to use wait() instead.  This call appears to work properly on
+other platforms such as SunOS and Solaris.
+<P>
+I also added tests in the standalone configure script to check for the
+existence of waitpid().
+
+<H1><A NAME="xterm_68">Patch #68 - 1998/3/4 - XFree86 3.9Ad and 3.3.1z</A></H1>
+
+This corrects another problem with the logic for highlightColor resource.
+As reported by David Dawes:
+<blockquote>
+       I've just noticed a problem with with the "inverse" control sequence
+       (ESC[7m) with the 3.3.2 xterm.  What it does is sets the background
+       black, and the text the usual foreground colour rather than simply
+       swapping the foreground/background.
+
+</blockquote>
+This appears to be because when I added logic to check that the highlightColor
+was distinct from foreground and background colors, I did not add a further
+check to see that it was not black (I would make an explicit check for the
+resource not being set, but see nothing definite in the headers that would let
+me reference an explicitly-undefined Pixel value, though there are some
+implications in xpm.h).  But this should work.
+
+<H1><A NAME="xterm_67">Patch #67 - 1998/2/23 - XFree86 3.9Ad and 3.3.1e</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>improve test for highlightColor so that xterm does not attempt to
+         use that unless it is different from the foreground and background
+         colors (reported by Stefan Dalibor
+         &lt;Stefan.Dalibor@informatik.uni-erlangen.de&gt;.
+<P>
+         I could not reproduce this until I noticed that the -rev option
+         exposed it nicely.
+
+       <LI>remove ich and ich1 from xterm and xterm-8bit terminfo descriptions.
+         SVr4 terminfo documents that you must not combine these with
+         smir/rmir, but ncurses allows it, opening a hole.  Solaris 2.6 vi
+         does not work properly if it is using a terminfo description when
+         these are combined, since it was written to accommodate old terminals
+         that required it (reported by Stephen Marley).
+
+       <LI>restore 1-pixel overlap of scrollbar border with left edge of window
+         (reported by Jim Burmeister &lt;jimb@metrolink.com&gt;).
+
+       <LI>add a configure option, --enable-logfile-exec, which allows the
+         user to specify a pipe for logfile.  This defines ALLOWLOGFILEEXEC.
+
+       <LI>makes the ALLOWLOGFILEEXEC code compile &amp; run, if configured.
+
+       <LI>minor documentation nits.
+</UL>
+
+<H1><A NAME="xterm_66">Patch #66 - 1998/2/16 - XFree86 3.9Ad and 3.3.1d</A></H1>
+
+This fixes the problem reported with failure to build the <EM>resize</EM>
+program (BSDI, OSF/1) due to not having &lt;termcap.h&gt;, by changing the
+ifdef to one that would be set only if the file exists (not currently
+specified, except by the standalone configure script).  We do not really need
+to include &lt;termcap.h&gt; to build, but only for a clean compile, since it
+may declare the tgetent() prototype.
+
+I also updated the man-page for <EM>resize</EM>, since I had recently noticed
+that it can be used to resize <EM>xterm</EM> using the "Sun" control sequences
+option.
+
+<H1><A NAME="xterm_65">Patch #65 - 1998/2/14 - XFree86 3.9Ad and 3.3.1c</A></H1>
+
+This is a small patch to xterm's 8-bit terminal description.  I noticed
+while testing ncurses that I had specified the wrong (VT100-style) codes
+for the F1-F4.  Xterm only uses VT220-style function keys in 8-bit mode.
+
+<H1><A NAME="xterm_64">Patch #64 - 1998/2/8 - XFree86 3.9Ad</A></H1>
+
+This fixes the following problems with xterm:
+<UL>
+       <LI>save/restore the ANSI foreground and background colors with the other
+         visible attributes in the save-cursor and restore-cursor operations.
+         This works around a problem with vim, which apparently assumed that
+         switching between the normal and alternate screens resets the colors
+         (reported by Jim Battle &lt;jb@chromatic.com&gt;).
+<P>
+         It would be nice to implement save/restore cursor as a stack (and
+         solve this type of problem completely), but that would lead to
+         incompatibility with applications which assume they are running with a
+         VT100 or VT220.
+
+       <LI>corrects behavior of a restore-cursor operation which does not
+         follow a save-cursor (it is supposed to set the character sets
+         to a known initial state).
+
+       <LI>extends the sunKeyboard resource (and menu toggle) to modify the
+         home, end and delete keys on a Sun or PC editing keypad, making them
+         generate codes compatible with DEC VT220's Find, Select and Remove
+         keys.
+
+       <LI>corrects a length in checking command-line options, which caused the
+         "-help" message to not work when X was not running.
+
+       <LI>add some detail to the man-page (requested by Jason Bacon
+         &lt;acadix@execpc.com&gt;)
+
+       <LI>modify the standalone configure script to ignore the broken nsl and
+         socket libraries on IRIX 6.2 (the ones on 5.2 also are broken, so
+         this change just widens the check for the system version number).
+</UL>
+
+<H1><A NAME="xterm_63">Patch #63 - 1998/2/5 - XFree86 3.9Ad</A></H1>
+
+This is another patch from Bjorn Helgaas &lt;helgaas@rsn.hp.com&gt;, which I've
+reviewed (and learned some).  Following are his notes:
+<P>
+I poked around some more and finally got xterm-62 to build and run
+cleanly on HP-UX 10.20.  Here are the patches.  They look sort of
+ugly, so here's a little explanation:
+<UL>
+        <LI>aclocal.m4: Removed side effects from the AC_CACHE_VAL
+        commands in CF_FUNC_TGETENT.  Previously, LIBS was set inside
+        AC_CACHE_VAL, which worked fine the first time configure was
+        run, but failed if there were cached values.
+
+        <LI>aclocal.m4: Added temporary setting of LIBS before
+        AC_TRY_LINK in CF_FUNC_TGETENT.  Previously, the last value set
+        by the AC_TRY_RUN loop was used, so only -lcurses was checked.
+
+        <LI>configure.in: Added temporary setting of CPPFLAGS before
+        AC_CHECK_HEADERS for X11 files.  Previously &lt;X11/DECkeysym.h&gt;
+        and &lt;X11/Xpoll.h&gt; were found only if they were in the compiler's
+        default include directories, even if `--x-includes=DIR' had been
+        used or AC_PATH_XTRA had found them elsewhere.
+</UL>
+The problem on HP-UX was that we were linking with -lcurses rather than
+-ltermcap due to the second bullet above, and apparently something in
+HP-UX curses is broken.  This seems very strange, because the only thing
+used is tgetent, which should affect any tty/pty configuration, but I
+lost interest in tracking down the exact problem.
+
+<H1><A NAME="xterm_62">Patch #62 - 1998/1/23 - XFree86 3.9Ac</A></H1>
+
+This is a patch mostly by Bjorn Helgaas &lt;helgaas@dhc.net&gt; (I added the
+os2main.c change, and a little of the documentation).  From Bjorn's
+description:
+<UL>
+       <LI>If you use the "-hc &lt;color&gt;" option or set the "highlightColor"
+         resource, text is highlighted by changing only the background color,
+         rather than using reverse video.  I find this easier to read,
+         especially when selecting multi-colored text, and it is similar to
+         the way Netscape shows selections.
+
+       <LI>Most of the code changes are under "#if OPT_HIGHLIGHT_COLOR".  The
+         principal exception is in screen.c, where I added a couple calls to
+         resetXtermGC().  This seems like it could be a bug even without
+         the color highlighting changes (though I don't pretend to understand
+         all the logic).
+</UL>
+
+<H1><A NAME="xterm_61">Patch #61 - 1998/1/17 - XFree86 3.9Ac</A></H1>
+
+This patch modifies the reset behavior of xterm slightly:
+<UL>
+       <LI>change the terminfo entry so that rs1 (one of the strings used by
+         the 'reset' program) does a hard reset rather than switching
+         character sets.  This is more in accord with other terminal
+         descriptions.
+
+       <LI>modifies the treatment of hard reset by the xterm program to
+         reset the saved lines.
+
+       <LI>corrects hard reset by also resetting user-defined keys, i.e., DECUDK.
+</UL>
+
+<H1><A NAME="xterm_60">Patch #60 - 1998/1/10 - XFree86 3.9Ab</A></H1>
+
+This fixes some minor bugs and adds new functionality:
+<UL>
+       <LI>add support for blinking text.
+<UL>
+         <LI>This does not actually cause the
+         text to flash, but text with the blink attribute can be displayed
+         in color, using new resources colorBL and colorBLMode.
+
+         <LI>If colors are not used, the blinking text will be displayed as
+         before (just like bold).  The main purpose of this is to make
+         applications work properly when they assume the emulator supports
+         blinking text.
+
+         <LI>I did this by moving the per-cell LINEWRAPPED flag to a per-line
+         flag, to make room for the new BLINK flag.  There were no per-line
+         flags, so this changes a lot of logic.
+</UL>
+
+       <LI>corrected missing save-cursor logic in the handling of SGR 1048
+         (the new control sequence I added in patch #54, 1997/10/17).
+         Reported by Darren Hiebert.
+
+       <LI>flush the output of the transparent printing after each line
+         Reported by Tomas Vanhala &lt;vanhala@ling.helsinki.fi&gt;.
+
+       <LI>correct the modes that are affected by save/restore cursor by adding
+         WRAPAROUND and PROTECTED.
+
+       <LI>corrected placement of one of the XSync calls that I added in patch
+         #51, 1997/9/15, which had the side-effect of writing on the window
+         border when the xterm was resizing from 132 to 80 columns.
+
+       <LI>work around an incompatibility of the XKB definition used in xterm
+         versus that symbol from IRIX 6.2's imake definitions (by adjusting
+         the standalone configure script).
+</UL>
+
+<H1><A NAME="xterm_59">Patch #59 - 1998/1/5 - XFree86 3.9Ab</A></H1>
+
+My last patch has an off-by-one error in the comparison for argc.  Douglas
+Kosovic &lt;douglask@dstc.edu.au&gt; showed me where (he got a core dump).
+Also, I think this explains Clint Olsen's problem, but the symptoms were more
+subtle (EINVAL for a system call if the -display option is omitted).
+
+<H1><A NAME="xterm_58">Patch #58 - 1998/1/3 - XFree86 3.9Ab</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>implement logic to permit xterm to work with proportional fonts.
+<UL>
+         <LI>Thomas Wolff
+         &lt;Thomas.Wolff@sietec.de&gt;
+         requested this (but it isn't exactly what he's asking
+         for - that's a more involved task).
+
+         <LI>I chose to do this by rendering the characters on a fixed pitch,
+         because it would not be useful for existing applications to display
+         varying numbers of characters on each line.
+
+         <LI>Except that this forces the display to be wider, it works reasonably
+         well.  A couple of special cases (reverse + colorBD, for example)
+         do not display with proper colors, since the inter-character gaps
+         are painted with the background.
+</UL>
+
+       <LI>added a version number to the program (several people have requested
+         this).
+
+       <LI>make the -version and -help options interpreted before the program
+         attempts to open the display.
+
+       <LI>minor reorganization of the man-page (ordered the options, resources
+         and translations alphabetically - and eliminated some duplication).
+
+       <LI>corrected a misspelled filename in Makefile.in, and added a lint
+         rule.
+
+       <LI>updated the configure script to correct behavior when it cannot
+         find imake, as well as to fix the IRIX+gcc build (conflict with
+         /usr/include).
+
+       <LI>regenerated the configure script with a newer patch to autoconf
+         that fixes a problem with environment space vs the configure --help
+         message.
+</UL>
+<H1><A NAME="xterm_57">Patch #57 - 1997/12/26 - XFree86 3.9Aa</A></H1>
+
+This patch is mostly concerned with the standalone configure script; a few
+minor corrections are added:
+<UL>
+       <LI>add configure option --disable-tek4014, to allow xterm to be built
+         without the tek4014 emulation.
+
+       <LI>add configure option --with-terminal-type, to allow xterm to be
+         compiled with default $TERM value other than "xterm" (e.g.,
+         "xterm-16color") -- requested by Stephen Marley &lt;stephen@memex.com&gt;.
+
+       <LI>fix a typo in the configure --help message -- reported by Darren
+         Hiebert &lt;darren@hmi.com&gt;.
+
+       <LI>review diffs between main.c and os2main.c, to make them more alike.
+         (applies some minor bug-fixes to OS/2's version).
+
+       <LI>add missing quotes in memmove/bcopy configure test
+</UL>
+
+
+<H1><A NAME="xterm_56">Patch #56 - 1997/11/28 - XFree86 3.9x</A></H1>
+
+This patch is based on analysis by Arfst Ludwig &lt;arfst@luxor.IN-Berlin.DE&gt;,
+who reported:
+<blockquote>
+       Setting the following resources xterm (all current versions) receives a
+       segmentation fault on &lt;Btn2Up&gt; after scrolling:
+<PRE>
+
+         *XTerm*VT100*translations:    #override \
+             ~Shift~Ctrl&lt;Btn2Up&gt;: insert-selection(PRIMARY, CUT_BUFFER0)\n\
+             Shift~Ctrl&lt;Btn2Up&gt;:  insert-selection(CLIPBOARD, CUT_BUFFER1)\n\
+             ~Shift&lt;BtnUp&gt;:       select-end(PRIMARY, CUT_BUFFER0)\n\
+             Shift&lt;BtnUp&gt;:        select-end(CLIPBOARD, CUT_BUFFER1)
+</PRE>
+       (The above resources intention is to be able to paste the latest
+       selection even if the xterm was cleared.)
+<P>
+       And here is how it works (and a fix!):  The widget given to the action
+       handler as first argument is not guaranteed to be a XtermWidget (it can
+       be the ScrollbarWidget).  Instead of accessing the widget's member
+       directly XtDisplay gives the required pointer in a safe way.
+</blockquote>
+I noticed that this was not the only instance (by reading the code, and testing
+with his example), and extended the solution to check the widget-class to
+ensure that it is indeed xterm's widget class before attempting to use it in
+the context of translations.
+
+<H1><A NAME="xterm_55">Patch #55 - 1997/11/25 - XFree86 3.9x</A></H1>
+
+This fixes the segmentation violation noted by Rogier Wolff about a month
+ago.  He'd set xterm to 400 (rows) by 150 columns, which broke because there
+were limited buffers (200 rows) used for juggling data when adding or deleting
+lines and for switching between alternate and normal screens.  I replaced this
+by an allocated buffer.
+<P>
+The bug is simple to test if you set titeInhibit false.
+
+<H1><A NAME="xterm_54">Patch #54 - 1997/10/17 - XFree86 3.9s</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>correct a minor placement problem with the right scrollbar.
+
+       <LI>implement a new set of control sequences for switching between the
+         normal and alternate VT100 screens.  These work around the older
+         sequences limitation that required modification of the runtime
+         $TERMCAP to cooperate with the titeInhibit resource (that can't work
+         with terminfo).  I do this by moving all of the functionality of the
+         rmcur terminfo capability into the control sequences.
+
+       <LI>implement the alternate-screen menu entry
+</UL>
+
+<H1><A NAME="xterm_53">Patch #53 - 1997/10/12 - XFree86 3.9r</A></H1>
+
+This patch adds a fix and implements a new feature (as well as some minor
+typos):
+<UL>
+       <LI>JCHANDRA@Inf.COM (JCHANDRA) noted that there was still a problem
+         with the wait call with the logging option.  It hung when the logfile
+         was opened as a command-line option.  I fixed this by moving the
+         StartLogging() call down past the place where I'd reset the setuid
+         mode.  So the logfile is opened as the real user, without having
+         to fork.
+
+       <LI>improve Rohleder's changes by
+           renaming the command-line options and reducing the number of ifdef's.
+
+       <LI>implement right-scrollbars for xterm
+         (patch by Michael Rohleder &lt;michael.rohleder@stadt-frankfurt.de&gt;).
+</UL>
+
+<H1><A NAME="xterm_52">Patch #52 - 1997/9/29 - XFree86 3.9q</A></H1>
+
+This patch addresses bugs and requests reported by
+<UL>
+       <LI>Bob Maynard &lt;rmaynard@montana.com&gt;,
+       <LI>Clint Olsen &lt;olsenc@ichips.intel.com&gt;,
+       <LI>JCHANDRA@Inf.COM (JCHANDRA),
+       <LI>Michael Schroeder &lt;Michael.Schroeder@informatik.uni-erlangen.de&gt;,
+       <LI>Pablo Ariel Kohan &lt;pablo@memco.co.il&gt;
+</UL>
+
+Some of the changes are interrelated (it was an unusually busy week).
+<UL>
+
+       <LI>change the default resource value for colorMode to true, matching
+         the Xterm.ad file.
+
+       <LI>correct behavior of 'ech' control, making the default and 0
+         parameters erase one character rather than to the end of line
+         (reported by Michael Schroeder).
+
+       <LI>add resource boldColors, command-line options +pc and -pc and
+         configure-script option to specify behavior of xterm's mapping bold
+         colors 0 through 7 to colors 8 through 15.
+         (request by Pablo Ariel Kohan).
+
+       <LI>add resource colorAttrMode to specify whether colorULMode and
+         colorBDMode can override the ANSI colors
+         (report by Clint Olsen).
+
+       <LI>correct a conflict between colorULMode/colorBDMode versus ANSI
+         colors, where exposure events would occasionally pick up the
+         former (e.g., colorBD) rather than ANSI colors.  Testing the
+         colorAttrMode made this apparent, though it has been in the
+         code since 3.2A (patch #35 in Jan 1997).
+
+       <LI>correct two problems with the optional logging support.  On Linux
+         at least, the waitpid call in creat_as hangs when the logging is
+         toggled from the popup menu.  Also, the mktemp template has the wrong
+         number of X's (since X11R5!).  Fixed the waitpid problem by
+         exploiting the fact that the setuid behavior is reset before the
+         popup menus are available.
+         (reported by Jayachandran C.).
+
+       <LI>add configure script options for building with the Xaw3d and neXtaw
+         libraries.
+
+       <LI>correct CF_IMAKE_CFLAGS standalone configure script macro, so that it
+         will pick up $(ALLDEFINES) rather than $(STD_DEFINES).  This is
+         needed to make scrollbars work on Linux, since that uses narrow
+         prototypes.
+         (reported by Bob Maynard).
+
+       <LI>various minor updates to configure-script macros.
+</UL>
+
+<H1><A NAME="xterm_51">Patch #51 - 1997/9/15 - XFree86 3.9p</A></H1>
+
+Most of this patch is related to the standalone configure script, though
+there are fixes/enhancements as well:
+<UL>
+       <LI>add a new resource sunKeyboard, with associated command-line
+         option and menu-toggle that allows using a normal Sun or PC
+         keyboard to generated the complete DEC-style function keys
+         and keypad.
+
+       <LI>correct a reversed foreground/background test in the control
+         sequence that replies with the current SGR settings.
+
+       <LI>correct, by invoking XSync, a display problem that caused the
+         program to not properly update newly exposed areas when a font
+         change or 80/132 resize request was not completely accepted.
+
+       <LI>restructured autoconf macros (I made a library of all of the
+         macros across the complicated configure scripts I'm working on).
+
+       <LI>use the autoconf config.guess and config.sub scripts to better
+         identify the host-os.
+
+       <LI>improve the configure script that uses 'imake' as a fallback for
+         definitions.
+
+       <LI>correct several instances of unsigned/signed mixed expressions.
+</UL>
+
+I've tested the configure script on Linux, SunOS 4.1.3, Solaris 2.5.1,
+IRIX 5.2 and 6.2, AIX 3.2.5 and CLIX 3.1 (all but the last run properly
+as well).
+
+<H1><A NAME="xterm_50">Patch #50 - 1997/8/22 - XFree86 3.9m</A></H1>
+
+This is a collection of small fixes, and a couple of minor enhancements:
+<UL>
+       <LI>plug a security hole in the implementation of Media Copy (print)
+         by invoking setuid just before the main loop.
+
+       <LI>add an ifdef'd include for &lt;sys/termio.h&gt; for HP-UX, which allows
+         the program to process SIGWINCH events (this is a bug in X11R6.3)
+
+       <LI>add state-table entries for VT52 emulation to enter/exit keypad
+         application mode.
+
+       <LI>disable the popup-menu entry for 8-bit controls when the terminal-id
+         is less than 200 (e.g., VT52 or VT100).
+
+       <LI>ensure that the popup-menu entry for 8-bit controls is updated when
+         the application enables/disables this mode, including the response
+         to a full-reset.
+
+       <LI>implement VT300 DECBKM feature: set interpretation of the backarrow
+         key to either backspace or delete.  The initial setting is via
+         resource; it can also be modified in the main popup menu.
+
+       <LI>implement VTxxx KAM (ISO AM), which allows a keyboard to be locked
+         (i.e., the terminal discards input).
+
+       <LI>implement VTxxx SRM, which is used to control local echoing of
+         input on the terminal.
+
+       <LI>add terminfo and termcap entries for xterm-8bit, a variation of
+         the xterm description that uses 8-bit control characters.
+
+       <LI>add fallback definitions for Imakefile to allow it to work on some
+         X11R5 systems that have no SpecialCObjectRule or ProgramTargetName
+         macros.
+
+       <LI>add .c.o and .c.i rules to standalone Makefile.in
+
+       <LI>correct order of -lXmu and -lXext in standalone configure script.
+
+       <LI>add configure script options to allow selective disabling of
+         active-icon, input-method and i18n code (mainly for users with X11R5
+         or an incomplete X11R6 configuration).
+
+       <LI>change menu-indices from #define's to enum values, thereby making
+         it work better with the ifdef's for logging and active-icon (the
+         X11R6.3 active-icon code is incorrectly ifdef'd; this corrects an
+         error introduced by incorporating that code).
+
+       <LI>correct minor compile errors in the configuration where active-icon
+         is not used.
+
+       <LI>add configure option to suppress echoing of long compiler commands
+
+       <LI>correct spelling of decTerminalID in configure script help message
+
+       <LI>use gcc __attribute__((unused)) to quiet warnings about unused
+         parameters when compiling with -W (to make it simpler to find the
+         real problems).
+</UL>
+
+<H1><A NAME="xterm_49">Patch #49 - 1997/8/10 - XFree86 3.9k</A></H1>
+
+This patch implements the VT100/VT220 Media Copy (i.e., print-screen) control
+sequences.
+
+<H1><A NAME="xterm_48">Patch #48 - 1997/7/26 - XFree86 3.9j</A></H1>
+
+This patch does the following (all but the first affect only the standalone
+configure script):
+<UL>
+       <LI>minor correction to positioning of underlines for small (e.g., 5x8)
+         font size.
+       <P>
+         The existing behavior allowed underlines to be drawn outside the
+         character-cell, so they weren't cleared properly under some
+         circumstances.
+
+       <LI>adds more special-case tokens to the standalone configure script's
+         imake-option filter (e.g., "&amp;&amp;", since a "make -n main.o" on my IRIX
+         system uses that shell construct).
+
+       <LI>adds a '--enable-logging' option for the standalone configure script.
+
+       <LI>adds check and ifdef's for the standalone configure script to allow
+         for building on platforms with X11R6, which lacks Xpoll.h (introduced
+         in X11R6.1).
+</UL>
+
+<H1><A NAME="xterm_47">Patch #47 - 1997/7/13 - XFree86 3.9i</A></H1>
+
+This patch does the following
+<UL>
+       <LI>corrects an indexing error in the doublesize character logic
+         (button.c) that caused core dump (this was reported by J.  Wunsch).
+       <LI>corrects the logic of ShowCursor when it is painting in a doublesize
+         cell (charproc.c).
+       <LI>corrects, according to vttest, the behavior when switching to
+         doublesize characters and back again (doublechr.c).
+       <LI>adds cbt (back_tab) to the terminfo description (this was something
+         that I'd overlooked as applicable to curses optimization last
+         summer).
+       <LI>corrects, for the standalone xmc test, the logic for disabling xmc.
+</UL>
+
+<H1><A NAME="xterm_46">Patch #46 - 1997/7/4 - XFree86 3.9h</A></H1>
+
+This is a patch to provide test-support for some work I'm doing on ncurses.  It
+does not modify the normal configuration of xterm; the code is compiled if the
+standalone configure option "--enable-xmc-glitch" is specified.
+
+<H1><A NAME="xterm_45">Patch #45 - 1997/7/2 - XFree86 3.9h</A></H1>
+
+This fixes the problem reported with xterm's cursor color versus the background
+(the second chunk in this patch) and also removes some duplicate initialization
+of the cursor GC's.  If the cursor color at startup is the same as the
+background, then xterm will use the reverse GC, ignoring the setting of the
+colorMode resource.
+
+<H1><A NAME="xterm_44">Patch #44 - 1997/6/22 - XFree86 3.9g</A></H1>
+
+This implements the first part of the VT100 doublesize characters for xterm,
+as well as fixing a handful of bugs:
+<UL>
+       <LI>the doublesize character support uses the normal font (using scaled
+         fonts will be another patch) with blanks to simulate doublesize
+         characters.  This patch does most of the global changes that'll be
+         required.  I've hidden most of the details in macros and ifdef's so
+         it's easy to configure out (part of the patch is a configure option
+         for that purpose).
+
+       <LI>corrected limits in DeleteChar() function -- it's always ignored the
+         size of the left border and scrollbar.  I noticed this when working
+         on the doublesize characters since the glitch was doubled in size
+         (i.e., it wrapped some garbage around the right margin).
+
+       <LI>corrected 'memmove()' logic, for standalone builds (it referenced a
+         malloc wrapper from my development library).
+
+       <LI>add a check for HideCursor() to prevent repeated screen updates
+         (which can cause a spurious cursor glitch to appear, e.g., during
+         scrolling).  I noticed this with the 3.2A version (but only a few
+         weeks ago, when I started working on this patch).
+</UL>
+
+<H1><A NAME="xterm_43">Patch #43 - 1997/6/10 - XFree86 3.9d</A></H1>
+
+Here's a fix for two problems:
+<UL>
+       <LI>modify handling of tgetent results in xterm and resize programs to
+         make them tolerant of missing termcap file, or unknown terminal name.
+         In this scheme, an explicit "-tn" option will succeed, overriding
+         the fallback list.
+
+       <LI>a nit in the configure script (log extra information to help diagnose
+         which case of the test-compile of tgetent was used).
+</UL>
+
+<H1><A NAME="xterm_42">Patch #42 - 1997/6/8 - XFree86 3.2Xl</A></H1>
+
+Bram Moolenaar reported that the cursor color changed unexpectedly while
+scrolling.  The cause was that it used the same GC's as the logic that draws
+the ANSI colors.  The bug only appears if the cursorColor resource isn't set,
+and has been present since the initial implementation early last year.  (The
+same bug also appears in rxvt ;-).  Here's a fix.
+
+<H1><A NAME="xterm_41">Patch #41 - 1997/5/28 - XFree86 3.2Xl</A></H1>
+
+Some nits found by Darren Hiebert (missing part of install-rule, incorrect
+assignment for --enable-color-mode option).
+
+<H1><A NAME="xterm_40">Patch #40 - 1997/5/26 - XFree86 3.2Xl</A></H1>
+
+Patch for the configure script's logic for obtaining imake predefined
+symbols.
+
+<H1><A NAME="xterm_39">Patch #39 - 1997/5/24 - XFree86 3.2Xl</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>integrate the 16-color change for 'xterm'
+
+       <LI>minor fixes/clarification of tgetent in terminfo vs termcap to
+         'resize'
+</UL>
+
+(both changes also modify the configure script)
+
+<H1><A NAME="xterm_38">Patch #38 - 1997/5/22 - XFree86 3.2Xh</A></H1>
+
+This implements a simple configuration script with autoconf (to which I'll
+add more options later).  It does the following:
+<UL>
+       <LI>configures xterm to build with X11R5 (at least on SunOS 4.1, Solaris
+         2.4, possibly IRIX - sorry network was down today, but I did test
+         an earlier version yesterday).
+
+       <LI>enables/disables the configuration ifdef's for ANSI color and VT52
+         emulation.
+</UL>
+It does not make tests for the things that imake does (that's another project),
+instead it uses a hybrid of the autoconf tests for libraries and adds imake's
+compiler options (which are necessary in some cases to get main.c to compile).
+
+<H1><A NAME="xterm_37">Patch #37 - 1997/5/7 - XFree86 3.9a</A></H1>
+
+This corrects a minor, but annoying error in the vt220 emulation: the DECUDK
+is only supposed to be interpreted for _shifted_ function keys.
+
+<H1><A NAME="xterm_36">Patch #36 - 1997/1/16 - XFree86 3.2r</A></H1>
+
+This corrects something that I overlooked in patch #27 (21-aug-1996), which is
+that when trimming the region to be repainted for the highlightSelection
+resource of xterm, I still have to paint the background past the highlighted
+region.  This only happens when I first do a selection in a window that's
+partly off-screen, then move the window on-screen.
+
+<H1><A NAME="xterm_35">Patch #35 - 1997/1/7 - XFree86 3.2o</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>combines the coding for foreground and background colors into a
+         single byte, reducing the memory required to store saved-lines in
+         color.  (I'll take back that byte in a following patch to use to
+         ensure the character-set, so there's no long-term decrease in memory
+         use).
+
+       <LI>modifies the PF1-PF4 coding in termcap/terminfo.  Because xterm is
+         still by default emulating vt100, the function key codes are
+         vt100-compatible (I overlooked this in patch #31).
+
+         I also reformatted the whole terminfo file into a single-column,
+         for consistency.
+
+       <LI>adds an interim xterm-vt220 description to accommodate the old and new
+         styles of function-keys (though probably it'd be better to drop the
+         old-style altogether).
+</UL>
+
+<H1><A NAME="xterm_34">Patch #34 - 1997/1/5 - XFree86 3.2o</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>implement DECSTR (soft terminal reset).  The biggest diff is due to
+         adding another state table (note that there's only one useful state
+         here, but it's only 256 bytes rather than 1k as it would have been
+         before I reduced the size of state entries).
+
+       <LI>some minor tidying up (e.g., signed/unsigned use bitcpy, MODE_DECCKM,
+         resetColor, resetCharsets).  More is done in patch #35.
+</UL>
+
+I got the description of DECSTR from a vt420 user's manual.  I'll do some
+testing with vttest to ensure that there's nothing else to do than what was
+documented.
+
+<H1><A NAME="xterm_33">Patch #33 - 1996/11/24 - XFree86 3.2</A></H1>
+
+This adds to the reset-fix by Matthieu Herrb &lt;Mathieu.Herrb@mipnet.fr&gt; a
+small change to make xterm able to output 8-bit characters in VT100 mode.
+
+Applications that run on real VT100's don't do that anyway, and this feature
+should be removed sometime after finishing off the VT220 emulation (VT220's can
+do 8-bit characters).  That would be a good time to change the default
+terminal-id to 220.
+
+<H1><A NAME="xterm_32">Patch #32 - 1996/11/21 - XFree86 3.2</A></H1>
+
+This implements the REP (repeat) control for xterm.  That isn't part of the DEC
+VTxxx series, but is defined in ISO 6429.  (Note that the base xterm terminal
+description is <EM>not</EM> changed -- I added a variant, "xterm-rep").
+
+<H1><A NAME="xterm_31">Patch #31 - 1996/11/16 - XFree86 3.2</A></H1>
+
+This implements vt52 emulation in xterm (ifdef'd so it can be removed).
+I've been using it for testing for the past month or so.
+
+<H1><A NAME="xterm_30">Patch #30 - 1996/11/16 - XFree86 3.2</A></H1>
+
+From bug-report by &lt;auroux@clipper.ens.fr&gt; (Denis Auroux), missing reset to
+ground state.  I checked through the rest of <EM>that</EM> table and found another,
+in the unimplemented MC (screen print).
+
+<H1><A NAME="xterm_29">Patch #29 - 1996/9/15 - XFree86 3.1.2Gb</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>corrects the restoration of color for bold/underline color mode
+
+       <LI>adds a resource 'decTerminalID' to control the reporting level of
+         xterm (e.g., VT100, VT220).
+
+       <LI>uses the new resource to implement/correct the DA1, DA2 and
+         DECRPTUI reports.
+
+       <LI>change valid-response code in DECRQSS from 0 to 1 (the manual says 0,
+         but the VT420 terminal I've been testing on says 1).
+</UL>
+
+All of these changes are based on vttest 2.6
+<P>
+(Most of the volume in the patch is to add 2 more state tables for parsing
+the 2nd/3rd device-attribute controls).
+
+<H1><A NAME="xterm_28">Patch #28 - 1996/8/31 - XFree86 3.1.2F</A></H1>
+
+This patch corrects the following reported by Roland Rosenfeld
+&lt;roland@spinnaker.rhein.de&gt;:
+<UL>
+       <LI>handle SGR 22, 24 and 25 in combination with colorUL and colorBD
+         resources.  Also noted &amp; fixed reset of colored underline/bold
+         with SGR 0.
+
+       <LI>a typo in the termcap (missing '['), from 3.1.2Dj (my error)
+</UL>
+
+Roland also complained that he couldn't use box characters with
+<PRE>
+       -adobe-courier-bold-r-normal--12-120-75-75-m-70-iso8859-1
+</PRE>
+but that's a known xterm limitation (the box characters must be part of the
+font, in the first 32 locations).
+
+<H1><A NAME="xterm_27">Patch #27 - 1996/8/21 - XFree86 3.1.2Ek</A></H1>
+
+This patch fixes one of my long-term gripes:  xterm's selection doesn't clearly
+show what's being selected (as per David's request, it's controlled by a
+resource, which defaults to the older behavior).
+
+<H1><A NAME="xterm_26">Patch #26 - 1996/8/20 - XFree86 3.1.2Ei</A></H1>
+
+Here's a patch to fix a problem with xterm's cut/paste and another to modify
+the appearance of the highlighting while selecting.  (The changes are
+independent, so you can see if the change to screen.c is desirable).
+
+<H1><A NAME="xterm_25">Patch #25 - 1996/8/18 - XFree86 3.1.2Ei</A></H1>
+
+Here's a correction for two minor bugs that I picked up in testing, plus
+some lint (from Solaris 2.5) where NULL was used incorrectly:
+<UL>
+       <LI>make the second alternate font the same as the first (that's what
+         vt420 and dtterm do)
+
+       <LI>corrected DECSCL report when DECSCL hasn't been set (i.e., don't
+         return a '60').
+</UL>
+
+<H1><A NAME="xterm_24">Patch #24 - 1996/8/11 - XFree86 3.1.2Ee</A></H1>
+
+This patch does several things.  In effect, xterm can (I think) do a reasonably
+good job of emulating vt220 and vt320 terminals (as well as it was doing
+vt100, at any rate ;-).
+<P>
+It does NOT do:
+<UL>
+       <LI>soft fonts
+
+       <LI>rigel or sixel graphics
+</UL>
+<P>
+Anyway, I:
+<UL>
+
+       <LI>added ECH, CPL, CNL, SU, SD, CBT, CHT controls
+
+       <LI>added popup-menu for switching between DEC and Sun function keys.
+         (corrected alignment err wrt logging entry at that point).
+
+       <LI>make xterm recognize both 8-bit and 7-bit controls (including
+         popup menu for switching modes).
+
+       <LI>add user-definable function keys (aka DECUDK)
+
+       <LI>support concealed text
+
+       <LI>support protected text (both ISO compatible and DEC compatible -
+         that's not the same thing, btw), with SPA, EPA, DECSCA, DECSED,
+         DECSEL controls.
+
+       <LI>implement DECSCL.
+</UL>
+<P>
+I'll be continuing to test this patch for a while, but don't expect to add any
+new functionality (it passes all of the current tests I've built in vttest, but
+I need to make more tests)..
+
+<H1><A NAME="xterm_23">Patch #23 - 1996/7/31 - XFree86 3.1.2Ec</A></H1>
+
+This removes the blinking cursor I added last week (for performance reasons).
+Time-permitting, I'll revisit this after 3.2 is released (there <EM>will</EM> be more
+work after XFree86 3.2, I assume).
+
+<H1><A NAME="xterm_22">Patch #22 - 1996/7/26 - XFree86 3.1.2Ec</A></H1>
+
+I looked more closely at my "double-negative" and realized that I had been
+confused by the default color scheme (black on white) in combination with
+reverse video.  However, I did see that the original_fg and original_bg data
+weren't really used - so I removed that logic.
+<P>
+Also:
+<UL>
+       <LI>during initialization, check if ANSI colors are set with non fg/bg
+         values, disable color mode if not.  This makes xterm tolerant of
+         applications that allocate the whole color map.
+
+       <LI>implemented blinking cursor (default is <EM>off</EM>)
+</UL>
+
+<H1><A NAME="xterm_21">Patch #21 - 1996/7/24 - XFree86 3.1.2Ec</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>fixes some minor typography in the control-sequences documentation
+         (it didn't occur to me til I'd sent the last patch that I could use
+         ghostview for previewing the troff output ;-)
+
+       <LI>adjusts the shell's background color in ReverseVideo so that flicker
+         in resizing is reduced
+
+       <LI>adds an ifdef OPT_ISO_COLORS to allow configuring xterm without
+         the ISO color support (saves a lot of memory)
+
+       <LI>used that ifdef to isolate/modify logic so that if the user doesn't
+         have the colorMode enabled, then ISO color support is disabled (saving
+         memory).
+       <P>
+         (If anyone needs numbers, I had savedLines set to 2000, and found
+         a reduction from ~700k to ~400k of allocated memory, according to
+         Purify).
+</UL>
+
+<H1><A NAME="xterm_20">Patch #20 - 1996/7/24 - XFree86 3.1.2Ec</A></H1>
+
+This documents the changes in control sequences for window operations that
+I added in my previous patch.  I'm testing another patch that allows the
+user to use less memory if colors aren't needed.
+
+<H1><A NAME="xterm_19">Patch #19 - 1996/7/21 - XFree86 3.1.2Ec</A></H1>
+
+This patch does the following:
+<UL>
+       <LI>fixes the core dump that I reported on IRIX 5.2 (in main.c)
+       <P>
+         (it's worth noting that this bug exists in X11R6.1, so I'd like
+         to assume that someone's already submitted a fix to X Consortium...)
+
+       <LI>change the interpretation of zero rows or columns in a resize-window
+         request to use the root window's size (looking more carefully at
+         dtterm, that seems to be what it does).
+
+       <LI>change some memmove calls to memcpy for slightly better performance.
+         also, a couple of memset calls to bzero, since Quantify says bzero runs
+         20% faster, I assume because there's one less argument.
+
+       <LI>interpret character sets 1 and 2 (so that vttest gives a reasonable
+         result) Both rxvt and dtterm do something equivalent.
+
+       <LI>fix a minor memory leak in the logic that retrieves the window or
+         icon names (Purify found this for me while I ran vttest).
+</UL>
+
+<H1><A NAME="xterm_18">Patch #18 - 1996/7/18 - XFree86 3.1.2Ec</A></H1>
+
+This implements the following:
+<UL>
+       <LI>escape sequences that act like the CDE dtterm's window operations
+         (though I have implemented the default width and height -- I've seen
+         a rather buggy dtterm running that seems to treat width=0 or height=0
+         literally -- maybe that's a feature, not a bug?)
+
+       <LI>minor tweak to the screen-repainting when resizing (I still cannot
+         entirely get rid of flicker).
+
+       <LI>still more fixes to terminfo &amp; termcap (I corrected my error for
+         the hpa code and added some other stuff by comparing to ncurses'
+         description and rxvt's).
+
+       <LI>a tweak to the changes by Michael Rohleder for the color translation
+
+       <LI>re-order attribute codes to allow later implementation of protected
+         fields (dtterm supposedly does this; it's probably more useful than
+         blinking or invisible text -- that uses up all of the available bits
+         without changing the attribute scheme radically).
+</UL>
+
+<H1><A NAME="xterm_17">Patch #17 - 1996/7/2 - XFree86 3.1.2Eb</A></H1>
+
+This patch implements for xterm several minor features from ISO 6429 which are
+useful for terminfo applications.  The HPA and VPA control sequences allow
+cursor movement along a row or column, cutting down a little on the characters
+transmitted.  The other codes allow resetting specific graphic rendition
+attributes without modifying the other attributes.
+
+(now if someone just had time to implement blinking cursors...)
+
+<H1><A NAME="xterm_16">Patch #16 - 1996/6/25 - XFree86 3.1.2Ea</A></H1>
+
+Adam Tla/lka &lt;atlka@pg.gda.pl&gt; told me a couple of weeks ago that I'd missed
+some of the background coloring in xterm.  I investigated, and found that while
+I'd picked up on the clear-to-bottom and clear-to-end-of-line operations, I'd
+overlooked the insert/delete lines.  Just so I wouldn't overlook any more of
+these, I updated a copy of vttest to test ISO colors and bce (background color
+erase).  This patch introduces a new function, ClearCurBackground, whose calls
+replace the direct XClearArea calls that I'd overlooked.
+
+(There's also a few compiler warnings fixed, etc ;-)
+
+<H1><A NAME="xterm_15">Patch #15 - 1996/5/29 - XFree86 3.1.2E</A></H1>
+
+This fixes the problem reported by David Dawes, by making the 50msec select
+timeout for the Xaw3d arrow scrollbar a resource.  (I made it a boolean for a
+variety of reasons -- to make it a number, you'd need an additional resource,
+to avoid breaking the logic).
+
+<H1><A NAME="xterm_14">Patch #14 - 1996/5/12 - XFree86 3.1.2Dj</A></H1>
+
+This patch brings the termcap and terminfo descriptions for xterm up to date.
+I made the following changes:
+<UL>
+       <LI>reformatted the terminfo description in a single-column (this is ok
+         for terminfo, and will simplify future patches -- can't do that for
+         termcap, since it would impact buffer requirements on some systems).
+
+       <LI>omitted obsolete features in termcap to save a little space (bs, pt)
+
+       <LI>added color capabilities to termcap (ut, Co, NC, op, AB, AF)
+
+       <LI>corrected some capabilities (vi, ve)
+
+       <LI>added 'st' (set tab)
+
+       <LI>reduced function keys in termcap for 'xterm' to 12 because color
+         capabilities makes that description larger than 1023 characters.
+
+       <LI>created new termcap name 'xtermm' (monochrome) to match the terminfo
+         list, and make that description have 20 function keys.
+
+       <LI>added corresponding color capabilities to terminfo (bce, colors,
+         pairs, op, ncv, setab, setaf)
+
+       <LI>corrected corresponding capabilities in terminfo (civis, cnorm,
+         rmcup, smcup)
+
+       <LI>added capabilities (el1, hts)
+
+       <LI>in both, corrected home/end keys to match the code correction made
+         by Thomas Mueller in 3.1.2Bk
+
+         <P>=&gt; (I'm still considering modifying the code &amp; description to match
+             the rxvt program).
+</UL>
+
+<H1><A NAME="xterm_13">Patch #13 - 1996/4/23 - XFree86 3.1.2Df</A></H1>
+
+This corrects my earlier changes for colors - the inner border of the xterm was
+getting painted with the wrong color, since I'd moved the call to set the
+background into the logic that tracks SGR information.
+
+<H1><A NAME="xterm_12">Patch #12 - 1996/3/16 - XFree86 3.1.2Dc</A></H1>
+
+This corrects a memory leak in xterm that happens whenever one switches fonts.
+
+<H1><A NAME="xterm_11">Patch #11 - 1996/3/5 - XFree86 3.1.2Db</A></H1>
+
+This patch corrects the behavior of the ANSI colors in xterm when reverse
+video is used, as well as some other lesser sins:
+<UL>
+       <LI>button.c
+<UL>
+               <LI>(compiler warnings: shadowing of 'time', redundant cast)
+</UL>
+
+       <LI>charproc.c
+<UL>
+               <LI>renamed screen.colors[] array to screen.Acolors[] to more
+               easily distinguish the non-ANSI colors from the ANSI colors.
+
+               <LI>moved logic of SGR_Save() into VTInitialize, getting rid of
+               local private variables original_fg and original_bg.
+
+               <LI>moved some logic into getXtermForeground and getXtermBackground
+               from SGR_Foreground, SGR_Background, etc.
+
+               <LI>corrected misleading 'row' to 'col' in case for CUF, CUB
+               sequences.
+</UL>
+
+       <LI>ctlseqs.ms
+       <LI>xterm.man
+<UL>
+               <LI>(correct a misconception which I'd added that the color0
+               through color6 resource values apply to non-ANSI colors)
+</UL>
+
+       <LI>ptyx.h
+<UL>
+               <LI>added original_fg, original_bg to TScreen structure.
+</UL>
+
+       <LI>scrollbar.c
+<UL>
+               <LI>(compiler warnings: redundant cast)
+</UL>
+
+       <LI>util.c
+<UL>
+               <LI>new functions getXtermForeground and getXtermBackground replace
+               the macros GET_FG and GET_BG, with the added functionality of
+               checking for the reverse-video status of xterm.
+
+               <LI>in ReverseVideo, swap the SGR foreground and background colors
+               also.
+</UL>
+</UL>
+
+<H1><A NAME="xterm_10">Patch #10 - 1996/2/14 - XFree86 3.1.2Cd</A></H1>
+
+I observed an occasional glitch in the xterm's color behavior; a clear to end
+of line would get a color that had been used in a program that supposedly reset
+colors.  I traced this down to the way xterm was modifying colors of GC's on
+the fly; it didn't restore the original color of the GC, even though it would
+later be used in functions (such as ClearRight) that assumed (my error) that
+the GC would have the current foreground or background color.
+<P>
+I fixed this by resetting the GC's colors with a new function 'resetXtermGC()',
+and direct calls on SGR_Foreground/SGR_Background, as appropriate and using a
+new function 'updatedXtermGC()' to encapsulate the logic that modifies the GC's
+color.  (I also removed some commented-out code that was trying to do this --
+the problem was a little more obscure).
+
+<H1><A NAME="xterm_09">Patch #9 - 1996/2/10 - XFree86 3.1.2Cb</A></H1>
+
+This patch fixes the remaining problems that I had making xterm run with x11r5,
+as well as a couple of other bugs.  It follows my patch from yesterday, that
+added ifdef's for some of the input-method resources.
+<UL>
+       <LI>corrected ifdef's that suppress the input-method code (doesn't
+         exist in my x11r5, and xterm works adequately without it).
+
+       <LI>corrected fallback definition for 'Select()' macro (oops: I'd
+         copied the wrong text...)
+
+       <LI>moved the declarations for the fd_set variables to data.[ch]
+
+       <LI>corrected an ifdef in resize.c (sunos 4.x doesn't have termcap.h)
+
+       <LI>corrected (in main.c) some unused/orphaned variables.
+</UL>
+
+<H1><A NAME="xterm_08">Patch #8 - 1996/2/9 - XFree86 3.1.2Cb</A></H1>
+
+This is mostly a documentation patch for xterm.  It describes the color control
+sequences in more detail, and documents some other features of xterm that
+aren't described elsewhere.
+<P>
+I've also added a couple of ifdef's to fix (part of) the problem that I'm
+working on (making the program work properly on x11r5, where I'm doing memory
+testing -- I have a "good" version from mid-January, but my resync version
+doesn't work properly on x11r5).  I'm not done with <EM>that</EM> yet.
+
+<H1><A NAME="xterm_07">Patch #7 - 1996/1/28 - XFree86 3.1.2n</A></H1>
+
+I did a (clean) build of 3.1.2n on Linux 1.2.13 (ELF).  I've got an S3 card.
+<P>
+This fixes the following in the 3.1.2n xterm:
+<UL>
+       <LI>initialize cur_foreground, cur_background in charproc.c (Purify
+         told me they weren't initialized).
+
+       <LI>add interpretation of codes 39, 49, to reset background and
+         foreground to default value (I'm told that ISO 6429 does this; but I
+         don't have a written reference -- yet -- can anyone help here?).
+         Anyway, rxvt does it, and it'll solve my remaining color management
+         problems.
+
+       <LI>shadowing of 'time' in menu.c
+
+       <LI>'Cardinal' vs 'int' in scrollbar.c
+
+       <LI>several changes to permit compile with X11R5 (the system that I've
+         got Purify on won't be upgraded to X11R6 for a long time).
+</UL>
+<P>
+I built this version (with a minor nit that I'll patch soon) on SunOS 4.1.3 so
+that I can test it some more with Purify.
+<P>
+<EM>btw</EM>:
+the changes made in Xpoll.h won't work on some older systems, because
+       fd_set isn't a defined type (I've got one machine at least that this
+       applies to).
+
+<H1><A NAME="xterm_06">Patch #6 - 1996/1/8</A></H1>
+
+This patch does all of the SGR foreground/background fixes (i.e., clearing the
+screen after an SGR color is set causes that color to be used in the foreground
+and/or background).  If the FG_COLOR and/or BG_COLOR flags aren't set, then the
+xterm foreground and background default to the window's values.  This usage is
+consistent with various types of hardware (especially the IBM PC), and is also
+used in rxvt.
+<UL>
+       <LI>charproc.c:
+<UL>
+               <LI>add/use new macros GET_FG, GET_BG - n/c.
+
+               <LI>add/use new functions SGR_Foreground() and SGR_Background()
+                 to set corresponding colors in GC's, and to retain sense of
+                 "original" colors.
+
+                 <P>
+                 =&gt; This makes redundant some of the corresponding logic
+                    in HideCursor to set the foreground and background,
+                    but I left it in since it <EM>may</EM> be fixing an unrelated
+                    requirement.
+
+               <LI>set GC's in LoadNewFont() according to whether the SGR fg/bg
+                 colors are active.
+
+                 <P>
+                 =&gt; This fixes some glitches in the accompanying resize,
+                    that leaves parts of the window in the original
+                    background color.
+</UL>
+
+       <LI>screen.c:
+<UL>
+               <LI>modified ClearBufRows() to use the SGR fg/bg colors if
+                 they're set.
+
+               <LI>added function ScrnClearLines(), used this to replace
+                 portions of ScrnInsertLine() and ScrnDeleteLine().
+                 The new function uses the SGR fg/bg colors if they're
+                 set.
+
+                 <P>
+                 =&gt; Otherwise, selection after an index or reverse index will
+                    paint the wrong colors.
+
+               <LI>modified ScrnDeleteChar() and ScrnInsertChar()
+                 to use SGR fg/bg colors.
+</UL>
+
+       <LI>util.c:
+<UL>
+               <LI>modified ClearRight() so that if either of the SGR fg/bg
+                 colors is set, we don't bzero the attributes and color
+                 arrays, but instead fill them with the appropriate codes.
+
+               <LI>modified ClearLeft to use SGR fg/bg colors.
+</UL>
+</UL>
+
+<H1><A NAME="xterm_05">Patch #5 - 1996/1/7</A></H1>
+
+This patch modifies the object code, by replacing indexing expressions with
+temporary variables with the full indexing expression.  At first glance, this
+seems inefficient (it did to me ;-), until remembering comments made in the
+compilers newsgroups that trying to "help" the compiler doesn't really work
+that well.  A good optimizing compiler can do a better job than the programmer
+can.  (There's a moral in the use of 'register' variables also, but I won't fix
+those...).
+<P>
+Anyway, the revised code generates a smaller object...
+<UL>
+<LI>charproc.c:
+<UL>
+<LI>recode index expressions in ShowCursor() and HideCursor()
+                 using SCRN_BUF_xxxxS macros - changes object.
+
+<LI>replace constant '4' by MAX_PTRS - n/c.
+</UL>
+
+<LI>ptyx.h:
+<UL>
+<LI>defined the SCRN_BUF_xxxxS macros in terms of BUF_xxxxS
+                 macros, to pick up references to ScrnBuf data directly, and
+                 added MAX_PTRS symbol to pick up those '4' constants strewn
+                 about the code - n/c.
+</UL>
+
+<LI>screen.c:
+<UL>
+<LI>recode index expressions in ScreenWrite() using
+                 SCRN_BUF_xxxxS macros - changes object.
+
+<LI>replace constant '4' by MAX_PTRS - n/c.
+
+<LI>use macros BUF_CHARS, BUF_ATTRS - n/c.
+
+<LI>cast calloc to 'Char *' to fix compiler warning on IRIX - n/c
+</UL>
+
+<LI>scrollbar.c:
+<UL>
+<LI>replace constant '4' by MAX_PTRS - n/c.
+
+<LI>cast calloc to 'Char *' to fix compiler warning on IRIX - n/c
+</UL>
+</UL>
+
+<H1><A NAME="xterm_04">Patch #4 - 1996/1/7</A></H1>
+When setting up for this phase, I saw that you'd corrected the bug that I found
+in ClearLeft.  I decided to make this series of patches anyway, since
+readability never hurt (and there's the potential for finding another bug while
+reviewing this set).
+<UL>
+<LI>button.c:
+<UL>
+<LI>use SCRN_BUF_xxxxS macros - n/c
+</UL>
+<LI>charproc.c:
+<UL>
+<LI>use SCRN_BUF_xxxxS macros - n/c
+</UL>
+<LI>ptyx.h:
+<UL>
+<LI>added four macros: SCRN_BUF_CHARS, SCRN_BUF_ATTRS,
+                 SCRN_BUF_FORES, SCRN_BUF_BACKS to represent the four
+                 arrays that are derived from screen-&gt;buf.
+</UL>
+<LI>screen.c:
+<UL>
+<LI>use SCRN_BUF_xxxxS macros - n/c
+</UL>
+<LI>util.c:
+<UL>
+<LI>use SCRN_BUF_xxxxS macros - n/c
+</UL>
+</UL>
+<H1><A NAME="xterm_03">Patch #3 - 1996/1/7</A></H1>
+
+This is my third (and final cleanup) patch for xterm.  It gets rid of the
+unused stuff, and converts several functions to static (thereby reducing their
+scope).
+<P>
+At this point, the only compile warnings I've got (on Linux) are those about
+the select arguments (int vs fd_set type), and a missing declaration for
+waitpid.  Those both are hard to get right without autoconfigure.
+<P>
+The next patches will address the functional changes...
+<UL>
+<LI>Tekproc.c:
+<UL>
+<LI>changed several functions to 'static' that aren't used
+outside this module -- changes object
+</UL>
+<LI>charproc.c:
+<UL>
+<LI>changed several functions to 'static' that aren't used
+outside this module -- changes object
+<LI>deleted unused function unparsefputs -- changes object.
+</UL>
+<LI>main.c:
+<UL>
+<LI>changed several functions to 'static' that aren't used
+outside this module -- changes object
+<LI>ifdef'd out unused function 'consolepr()' -- changes object
+<LI>removed unused variable 'dummy_tio' -- changes object
+<LI>moved variable 'discipline' to quiet unused-warning -- changes object
+</UL>
+<LI>main.h:
+<UL>
+<LI>deleted unused definition of DEFBORDERWIDTH - n/c
+</UL>
+<LI>misc.c:
+<UL>
+<LI>changed several functions to 'static' that aren't used
+outside this module -- changes object
+<LI>provide dummy return statements for xerror and xioerror to
+quiet compiler warnings -- changes object
+</UL>
+<LI>ptyx.h:
+<UL>
+<LI>change sbuf_address and abuf_address to 'Char *' - n/c
+</UL>
+<LI>resize.c:
+<UL>
+<LI>changed several functions to 'static' that aren't used outside this module
+-- changes object
+</UL>
+<LI>screen.c:
+<UL>
+<LI>remove unnecessary 'Char **' casts - n/c
+</UL>
+<LI>util.c:
+<UL>
+<LI>changed several functions to 'static' that aren't used outside this module
+-- changes object
+</UL>
+</UL>
+<H1><A NAME="xterm_02">Patch #2 - 1996/1/7</A></H1>
+This is my second patch to xterm.  It corrects most of the gcc warnings (except
+for some that are due to X header files ;-).  I compared objects to keep track
+of the changes that don't affect the object code (n/c) versus those that do.
+<P>
+At this point, I'm compiling (fairly) clean with gcc options
+<PRE>
+       -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wnested-externs
+</PRE>
+(I also compiled with -Wshadow, but while that found some things that I wanted
+to find, there's far too many warnings from the X headers to be usable in this
+context).
+<P>
+The changes:
+<UL>
+<LI>Tekproc.c:
+<UL>
+<LI>parenthesized expression to avoid gcc warning -- n/c.
+
+<LI>corrected nested-extern declaration for Bool
+                 waiting_for_initial_map; ourTopLevelShellArgs, and
+                 number_ourTopLevelShellArgs - n/c
+
+</UL>
+<LI>charproc.c:
+<UL>
+<LI>corrected potentially-unintialized variables 'scstype', 'xim',
+                 and 'input_style' -- changes object.
+
+<LI>adjusted logic of VTparse so that gcc won't warn about setjmp
+                 clobbering parsestate -- changes object.
+
+<LI>corrected initialization of 'scstype', which could have been
+                 clobbered by setjmp/longjmp - changes object.
+
+<LI>corrected nested-extern declaration of 'term', 'ProgramName'
+                 - n/c
+</UL>
+
+<LI>cursor.c:
+<UL>
+<LI>corrected nested-extern declaration of 'term' -- n/c
+
+<LI>renamed 'term' parameters to avoid gcc -Wshadow warning - n/c
+</UL>
+
+<LI>input.c:
+<UL>
+<LI>change interface of StringInput to assume size_t (i.e.,
+                 unsigned) nbytes -- changes object.
+
+<LI>change interface of funcvalue, and sunfuncvalue to use
+                 'KeySym' type instead of 'int' - changes object.
+</UL>
+
+<LI>main.c:
+<UL>
+<LI>moved definitions of SIGNAL_T, SIGNAL_RETURN to proto.h - n/c
+
+<LI>corrected missing params of 'do_hangup()' -- changes object
+                 (note: the missing params were not used).
+
+<LI>corrected missing param of 'Error()' -- changes object
+
+<LI>corrected nested-extern 'environ' - n/c
+
+<LI>adjusted assignments to 'tty_got_hung' and 'no_dev_tty' so
+                 that gcc can see they won't be clobbered by the longjmp -
+                 changes object.
+
+<LI>use Size_t type - n/c.
+</UL>
+
+<LI>menu.c:
+<UL>
+<LI>removed redundant prototype for 'do_hangup()' -- n/c.
+
+<LI>renamed 'time' parameters to avoid gcc -Wshadow warning - n/c
+</UL>
+
+<LI>menu.h:
+<UL>
+<LI>renamed 'time' parameters to avoid gcc -Wshadow warning - n/c
+</UL>
+
+<LI>misc.c:
+<UL>
+<LI>corrected definition of 'HandleFocusChange()' -- changes
+                 object
+
+<LI>cast parameters in call to 'TekExpose()' -- n/c
+
+<LI>corrected nested-extern declarations of 'term', 'toplevel',
+                 ProgramName, and 'environ' -- n/c.
+
+<LI>use Size_t type - n/c.
+</UL>
+
+<LI>proto.h:
+<UL>
+<LI>moved definition of SIGNAL_T (and SIGNAL_RETURN) here from
+                 main.c, resize.c to allow use of this symbol in prototypes
+                 (mostly in xterm.h).
+
+<LI>added definition 'Size_t' to use as corrected type for
+                 strncpy, malloc sizes - n/c.
+</UL>
+
+<LI>resize.c:
+<UL>
+<LI>moved SIGNAL_T definition to proto.h -- n/c.
+
+<LI>use Size_t type - n/c.
+</UL>
+
+<LI>screen.c:
+<UL>
+<LI>use Size_t type - n/c.
+</UL>
+
+<LI>tabs.c:
+<UL>
+<LI>corrected nested-extern declaration of 'term' -- n/c
+</UL>
+
+<LI>util.c:
+<UL>
+<LI>corrected/supplied parameters to 'TekExpose()' -- changes
+                 object (note:  'TekExpose()' doesn't use its parameters).
+
+<LI>corrected nested-extern declaration of
+                 'waiting_for_initial_map' -- n/c.
+
+<LI>renamed 'term' parameters to avoid gcc -Wshadow warning - n/c
+</UL>
+
+<LI>xterm.h:
+<UL>
+<LI>prototype 'do_hangup()', 'HandleFocusChange()',
+                 'TekExpose()', 'Error()', 'Exit()' - forces changes in
+                 various places.
+
+<LI>adjusted prototypes that pass 'Boolean' arguments to use
+                 'int' (this is the "correct" ANSI approach to extended
+                 compiles; it's worth mentioning that gcc doesn't meet the
+                 ANSI spec here).  I used gcc -Wconversion to find these, but
+                 there's a lot of unrelated warnings that are due to setting
+                 NARROWPROTO in the config - n/c.
+
+<LI>renamed 'term' parameters to avoid gcc -Wshadow warning - n/c
+</UL>
+</UL>
+<H1><A NAME="xterm_01">Patch #1 - 1996/1/6</A></H1>
+This is my first cleanup patch for xterm.  It addresses all of the gcc warnings
+for -Wall, -Wmissing-prototypes and -Wstrict-prototypes that I can change
+without modifying the object code.  (I'm compiling this with gcc 2.7.0 for an
+aout target, which makes it simple to compare objects.  When I do ELF-only,
+I've got a tool that compares that sort of thing as well).
+<P>
+Briefly, this patch adds (and uses) two header files in the xterm directory:
+<PRE>
+       proto.h
+       xterm.h
+</PRE>
+I expect this to be the biggest patch by far.  However (barring a misplaced
+prototype), it shouldn't break anything, since the intent of the patch is to
+provide missing declarations.
+</BODY>
+</HTML>
diff --git a/xterm.man b/xterm.man
new file mode 100644 (file)
index 0000000..d6360e8
--- /dev/null
+++ b/xterm.man
@@ -0,0 +1,5842 @@
+'\" t
+.\" $XTermId: xterm.man,v 1.476 2011/02/08 21:46:33 tom Exp $
+.\"
+.\" Copyright 1996-2010,2011 by Thomas E. Dickey
+.\"
+.\"                         All Rights Reserved
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining a
+.\" copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name(s) of the above copyright
+.\" holders shall not be used in advertising or otherwise to promote the
+.\" sale, use or other dealings in this Software without prior written
+.\" authorization.
+.\"
+.\"
+.\" Copyright 1989  The Open Group
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation.
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\"
+.\" updated by Thomas E. Dickey for XFree86, July 1996 - February 2006.
+.\"
+.\" Bulleted paragraph
+.de bP
+.IP \(bu 4
+..
+.\" these would be fallbacks for DS/DE,
+.\" but groff changed the meaning of the macros.
+.de NS
+.sp
+.in +4
+.nf
+.ft C                  \" Courier
+..
+.de NE
+.fi
+.ft P
+.sp
+.in -4
+..
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds AQ \(aq
+.el       .ds AQ '
+.ie \n(.g .ds `` \(lq
+.el       .ds `` ``
+.ie \n(.g .ds '' \(rq
+.el       .ds '' ''
+.TH XTERM 1 __vendorversion__
+.SH NAME
+xterm \- terminal emulator for X
+.SH SYNOPSIS
+.B xterm
+[\-\fItoolkitoption\fP ...] [\-\fIoption\fP ...] [\fIshell\fP]
+.SH DESCRIPTION
+The \fIxterm\fP program is a terminal emulator for the X Window System.
+It provides DEC VT102/VT220 (VTxxx) and Tektronix 4014
+compatible terminals for programs that cannot
+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), \fIxterm\fP will use the facilities to notify programs
+running in the window whenever it is resized.
+.
+.PP
+The VTxxx and Tektronix 4014 terminals each have their own window so that you
+can edit text in one and look at graphics in the other at the same time.
+To maintain the correct aspect ratio (height/width), Tektronix graphics will
+be restricted to the largest box with a 4014's aspect ratio that will fit in
+the window.
+This box is located in the upper left area of the window.
+.
+.PP
+Although both windows may be displayed at the same time, one of them is
+considered the \*(``active\*('' window for receiving keyboard input and terminal
+output.
+This is the window that contains the text cursor.
+The active window can be chosen through escape sequences,
+the \*(``VT Options\*('' menu in the VTxxx window, and the \*(``Tek Options\*(''
+menu in the 4014 window.
+.
+.SH EMULATIONS
+The VT102 emulation is fairly complete, but does not support
+autorepeat.
+Double-size characters are displayed properly if your font server supports
+scalable fonts.
+The VT220 emulation does not support soft fonts, it is otherwise complete.
+.IR Termcap (5)
+entries that work with
+.I xterm
+include
+an optional platform-specific entry,
+\*(``xterm,\*(''
+\*(``vt102,\*(''
+\*(``vt100,\*(''
+\*(``ansi\*('' and
+\*(``dumb.\*(''
+.I xterm
+automatically searches the termcap file in this order for these entries and then
+sets the \*(``TERM\*('' and the \*(``TERMCAP\*('' environment variables.
+You may also use \*(``vt220,\*(''  but must set the terminal emulation level
+with the \fBdecTerminalID\fP resource.
+(The \*(``TERMCAP\*('' environment variable is not set if \fIxterm\fP is linked
+against a terminfo library, since the requisite information is not provided
+by the termcap emulation of terminfo libraries).
+.
+.PP
+Many of the special
+.I xterm
+features may be modified under program control
+through a set of escape sequences different from the standard VT102 escape
+sequences.
+(See the
+.I "Xterm Control Sequences"
+document.)
+.
+.PP
+The Tektronix 4014 emulation is also fairly good.
+It supports 12-bit graphics addressing, scaled to the window size.
+Four different font sizes and five different lines types are supported.
+There is no write-through or defocused mode support.
+The Tektronix text and graphics commands are recorded internally by
+.I xterm
+and may be written to a file by sending the COPY escape sequence (or through
+the
+.B Tektronix
+menu; see below).
+The name of the file will be
+\*(``\fBCOPY\fIyyyy\fB\-\fIMM\fB\-\fIdd\fB.\fIhh\fB:\fImm\fB:\fIss\fR\*('', where
+.IR yyyy ,
+.IR MM ,
+.IR dd ,
+.IR hh ,
+.I mm
+and
+.I ss
+are the year, month, day, hour, minute and second when the COPY was performed
+(the file is created in the directory
+.I xterm
+is started in, or the home directory for a login
+.IR xterm ).
+.
+.PP
+Not all of the features described in this manual are necessarily available in
+this version of \fIxterm\fP.
+Some (e.g., the non-VT220 extensions) are available
+only if they were compiled in, though the most commonly-used are in the
+default configuration.
+.
+.SH "OTHER FEATURES"
+.I Xterm
+automatically highlights the text cursor when the
+pointer enters the window (selected) and unhighlights it when the pointer
+leaves the window (unselected).
+If the window is the focus window, then the text cursor is
+highlighted no matter where the pointer is.
+.
+.PP
+In VT102 mode, there are escape sequences to activate and deactivate
+an alternate screen buffer, which is the same size as the display area
+of the window.
+When activated, the current screen is saved and replaced with the alternate
+screen.
+Saving of lines scrolled off the top of the window is disabled until the
+normal screen is restored.
+The
+.IR termcap (5)
+entry for
+.I xterm
+allows the visual editor
+.IR vi (1)
+to switch to the alternate screen for editing and to restore the screen
+on exit.
+A popup menu entry makes it simple to switch between the normal and
+alternate screens for cut and paste.
+.
+.PP
+In either VT102 or Tektronix mode, there are escape sequences to change the
+name of the windows.
+Additionally, in VT102 mode,
+\fIxterm\fP implements the window-manipulation control
+sequences from \fIdtterm\fP, such as resizing the window, setting its location
+on the screen.
+.
+.PP
+.I Xterm
+allows character-based applications to receive mouse events (currently
+button-press and release events, and button-motion events)
+as keyboard control sequences.
+See \fIXterm Control Sequences\fP for details.
+.
+.
+.SH OPTIONS
+The \fIxterm\fP terminal emulator
+accepts the standard X Toolkit command line options as well as
+many application-specific options.
+If the option begins with a
+.RB ` + '
+instead of a
+.RB ` \- ',
+the option is restored to its default value.
+The \fB\-version\fP and \fB\-help\fP options are interpreted even if \fIxterm\fP
+cannot open the display, and are useful for testing and configuration scripts:
+.TP 8
+.B \-version
+This causes \fIxterm\fP to print a version number to the standard output.
+.TP 8
+.B \-help
+This causes \fIxterm\fP to print out a verbose message describing its options,
+one per line.
+The message is written to the standard output.
+\fIXterm\fP generates this message, sorting it and noting whether
+a "\fB\-option\fP"
+or a "\fB+option\fP" turns the feature on or off,
+since some features historically have been one or the other.
+\fIXterm\fP generates a concise help message (multiple options per line)
+when an unknown option is used, e.g.,
+.RS
+       \fBxterm \-z\fP
+.RE
+.IP
+If the logic for a particular option such as logging is not compiled
+into \fIxterm\fP, the help text for that option also is not displayed
+by the \fB\-help\fP option.
+.
+.PP
+One parameter (after all options) may be given.
+That overrides \fIxterm\fP's built-in choice of shell program.
+Normally \fIxterm\fP checks the SHELL variable.
+If that is not set, \fIxterm\fP tries to use the shell program specified
+in the password file.
+If that is not set, \fIxterm\fP uses \fI/bin/sh\fP.
+If the parameter names an executable file, \fIxterm\fP uses that instead.
+The parameter must be an absolute path, or name a file found on the user's
+PATH (and thereby construct an absolute path).
+The \fB\-e\fP option cannot be used with this parameter since
+it uses all parameters following the option.
+.PP
+The other options are used to control the appearance and behavior.
+Not all options are necessarily configured into your copy of \fIxterm\fP:
+.TP 8
+.B \-132
+Normally, the VT102 DECCOLM escape sequence that switches between 80 and
+132 column mode is ignored.
+This option causes the DECCOLM escape sequence to be recognized, and the
+.I xterm
+window will resize appropriately.
+.TP 8
+.B \-ah
+This option indicates that
+.I xterm
+should always highlight the text cursor.
+By default,
+.I xterm
+will display a hollow text cursor whenever the focus is lost or the
+pointer leaves the window.
+.TP 8
+.B +ah
+This option indicates that
+.I xterm
+should do text cursor highlighting based on focus.
+.TP 8
+.B \-ai
+This option disables active icon support if that feature was compiled
+into \fIxterm\fP.
+This is equivalent to setting the \fIvt100\fP resource
+\fBactiveIcon\fP to \*(``false\*(''.
+.TP 8
+.B +ai
+This option enables active icon support if that feature was compiled
+into \fIxterm\fP.
+This is equivalent to setting the \fIvt100\fP resource
+\fBactiveIcon\fP to \*(``true\*(''.
+.TP 8
+.B \-aw
+This option indicates that auto-wraparound should be allowed.
+This
+allows the cursor to automatically wrap to the beginning of the next
+line when it is at the rightmost position of a line and text is
+output.
+.TP 8
+.B +aw
+This option indicates that auto-wraparound should not be allowed.
+.TP 8
+.BI \-b " number"
+This option specifies the size of the inner border (the distance between
+the outer edge of the characters and the window border) in pixels.
+That is the \fIvt100\fP \fIinternalBorder\fP resource.
+The
+default is 2.
+.TP 8
+.B +bc
+turn off text cursor blinking.
+This overrides the \fBcursorBlink\fR resource.
+.TP 8
+.B \-bc
+turn on text cursor blinking.
+This overrides the \fBcursorBlink\fR resource.
+.TP 8
+.BI \-bcf " milliseconds"
+set the amount of time text cursor is off when blinking via the
+\fIcursorOffTime\fP resource.
+.TP 8
+.BI \-bcn " milliseconds"
+set the amount of time text cursor is on when blinking via the
+\fIcursorOffTime\fP resource.
+.TP 8
+.B "\-bdc"
+Set the \fIvt100\fP resource \fBcolorBDMode\fR to \*(``false\*('',
+disabling the display of characters with bold attribute as color
+.TP 8
+.B "+bdc"
+Set the \fIvt100\fP resource \fBcolorBDMode\fR to \*(``true\*('',
+enabling the display of characters with bold attribute as color
+rather than bold
+.TP 8
+.B "\-cb"
+Set the \fIvt100\fP resource \fBcutToBeginningOfLine\fP to \*(``false\*(''.
+.TP 8
+.B "+cb"
+Set the \fIvt100\fP resource \fBcutToBeginningOfLine\fP to \*(``true\*(''.
+.TP 8
+.B "\-cc \fIcharacterclassrange\fP:\fIvalue\fP[,...]"
+This sets classes indicated by the given ranges for using in selecting by
+words.
+See the section specifying character classes.
+and discussion of the \fIcharClass\fP resource.
+.TP 8
+.B "\-cjk_width"
+Set the \fBcjkWidth\fP resource to \*(``true\*(''.
+When turned on, characters with East Asian Ambiguous (A) category in UTR 11
+have a column width of 2.
+Otherwise, they have a column width of 1.
+This may be useful for some legacy CJK text
+terminal-based programs assuming box drawings and others to have a column
+width of 2.
+It also should be turned on when you specify a TrueType
+CJK double-width (bi-width/monospace) font either with \fB\-fa\fP at
+the command line or \fBfaceName\fP resource.
+The default is \*(``false\*(''
+.TP 8
+.B "+cjk_width"
+Reset the \fBcjkWidth\fP resource.
+.TP 8
+.BI \-class " string"
+This option allows you to override \fIxterm\fP's resource class.
+Normally it is \*(``XTerm\*('', but
+can be set to another class such as \*(``UXTerm\*('' to override selected resources.
+.TP 8
+.B "\-cm"
+This option disables recognition of ANSI color-change escape sequences.
+It sets the \fIcolorMode\fP resource to \*(``false\*(''.
+.TP 8
+.B "+cm"
+This option enables recognition of ANSI color-change escape sequences.
+This is the same as the \fIvt100\fP resource \fBcolorMode\fP.
+.TP 8
+.B "\-cn"
+This option indicates that newlines should not be cut in line-mode
+selections.
+It sets the \fIcutNewline\fP resource to \*(``false\*(''.
+.TP 8
+.B +cn
+This option indicates that newlines should be cut in line-mode selections.
+It sets the \fIcutNewline\fP resource to \*(``true\*(''.
+.TP 8
+.BI \-cr " color"
+This option specifies the color to use for text cursor.
+The default is to
+use the same foreground color that is used for text.
+It sets the \fIcursorColor\fP resource according to the parameter.
+.TP 8
+.B \-cu
+This option indicates that \fIxterm\fP should work around a bug in the
+.IR more (1)
+program that causes it
+to incorrectly display lines that are exactly the width of the window and
+are followed by a line beginning with a tab
+(the leading tabs are not displayed).
+This option is so named because it was originally thought to be a bug
+in the
+.IR curses (3x)
+cursor motion package.
+.TP 8
+.B +cu
+This option indicates that \fIxterm\fP should not work around the
+.IR more (1)
+bug mentioned above.
+.TP 8
+.B "\-dc"
+This option disables the escape sequence to change dynamic colors:
+the vt100 foreground and background colors,
+its text cursor color,
+the pointer cursor foreground and background colors,
+the Tektronix emulator foreground and background colors,
+its text cursor color
+and highlight color.
+The option sets the \fIdynamicColors\fP option to \*(``false\*(''.
+.TP 8
+.B "+dc"
+This option enables the escape sequence to change dynamic colors.
+The option sets the \fIdynamicColors\fP option to \*(``true\*(''.
+.TP 8
+.BI \-e " program \fP[ \fIarguments \fP.\|.\|. ]\fI"
+This option specifies the program (and its command line arguments) to be
+run in the \fIxterm\fP window.
+It also sets the window title and icon
+name to be the basename of the program being executed if neither \fI\-T\fP
+nor \fI\-n\fP are given on the command line.
+\fBThis must be the last option on the command line.\fP
+.TP 8
+.BI \-en " encoding"
+This option determines the encoding on which \fIxterm\fP runs.
+It sets the \fBlocale\fR resource.
+Encodings other than UTF-8 are supported by using \fIluit\fR.
+The \fB\-lc\fR option should be used instead of \fB\-en\fR for
+systems with locale support.
+.TP 8
+.BI \-fb " font"
+This option specifies a font to be used when displaying bold text.
+It sets the \fBboldFont\fR resource.
+.IP
+This font must be the same height and width as the normal font, otherwise it is ignored.
+If only one of the normal or bold fonts is specified, it will be used as the
+normal font and the bold font will be produced by overstriking this font.
+.IP
+See also the discussion of \fBboldMode\fP and \fBalwaysBoldMode\fP resources.
+.TP 8
+.BI \-fa " pattern"
+This option sets the pattern for fonts selected from the FreeType
+library if support for that library was compiled into \fIxterm\fP.
+This corresponds to the \fBfaceName\fP resource.
+When a CJK
+double-width font is specified, you also need to turn
+on the \fBcjkWidth\fP resource.
+.IP
+See also the \fBrenderFont\fP resource,
+which combines with this to determine whether FreeType fonts are
+initially active.
+.TP 8
+.BI \-fbb
+This option indicates that \fIxterm\fP should compare normal and bold fonts bounding
+boxes to ensure they are compatible.
+It sets the \fBfreeBoldBox\fP resource to \*(``false\*(''.
+.TP 8
+.BI +fbb
+This option indicates that \fIxterm\fP should not compare normal and bold fonts bounding
+boxes to ensure they are compatible.
+It sets the \fBfreeBoldBox\fP resource to \*(``true\*(''.
+.TP 8
+.BI \-fbx
+This option indicates that \fIxterm\fP should not assume that the
+normal and bold fonts have VT100 line-drawing characters.
+If any are missing, \fIxterm\fP will draw the characters directly.
+It sets the \fBforceBoxChars\fP resource to \*(``false\*(''.
+.TP 8
+.BI +fbx
+This option indicates that \fIxterm\fP should assume that the
+normal and bold fonts have VT100 line-drawing characters.
+It sets the \fBforceBoxChars\fP resource to \*(``true\*(''.
+.TP 8
+.BI \-fd " pattern"
+This option sets the pattern for double-width fonts selected from the FreeType
+library if support for that library was compiled into \fIxterm\fP.
+This corresponds to the \fBfaceNameDoublesize\fP resource.
+.TP 8
+.BI \-fi " font"
+This option sets the font for active icons if that feature was compiled
+into \fIxterm\fP.
+.IP
+See also the discussion of the \fBiconFont\fP resource.
+.TP 8
+.BI \-fs " size"
+This option sets the pointsize for fonts selected from the FreeType
+library if support for that library was compiled into \fIxterm\fP.
+This corresponds to the \fBfaceSize\fP resource.
+.TP 8
+.B \-fw \fIfont\fP
+This option specifies the font to be used for displaying wide text.
+By default,
+it will attempt to use a font twice as wide as the font that will be used to
+draw normal text.
+If no double-width font is found, it will improvise, by stretching
+the normal font.
+This corresponds to the \fBwideFont\fP resource.
+.TP 8
+.B \-fwb \fIfont\fP
+This option specifies the font to be used for displaying bold wide text.
+By default,
+it will attempt to use a font twice as wide as the font that will be used to
+draw bold text.
+If no double-width font is found, it will improvise, by stretching
+the bold font.
+This corresponds to the \fBwideBoldFont\fP resource.
+.TP 8
+.B \-fx \fIfont\fP
+This option specifies the font to be used for displaying the preedit string
+in the "OverTheSpot" input method.
+.IP
+See also the discussion of the \fBximFont\fP resource.
+.TP 8
+.BI \-hc " color"
+(see \fB\-selbg\fP).
+.TP 8
+.BI \-hf
+This option indicates that HP Function Key escape codes should be generated
+for function keys.
+It sets the \fBhpFunctionKeys\fP resource to \*(``true\*(''.
+.TP 8
+.BI +hf
+This option indicates that HP Function Key escape codes should not be generated
+for function keys.
+It sets the \fBhpFunctionKeys\fP resource to \*(``false\*(''.
+.TP 8
+.BI \-hm
+Tells \fIxterm\fP to use
+\fBhighlightTextColor\fP and \fBhighlightColor\fP
+to override the reversed foreground/background colors in a selection.
+It sets the \fBhighlightColorMode\fP resource to \*(``true\*(''.
+.TP 8
+.BI +hm
+Tells \fIxterm\fP not to use
+\fBhighlightTextColor\fP and \fBhighlightColor\fP
+to override the reversed foreground/background colors in a selection.
+It sets the \fBhighlightColorMode\fP resource to \*(``false\*(''.
+.TP 8
+.BI \-hold
+Turn on the \fBhold\fP resource, i.e.,
+\fIxterm\fP will not immediately destroy its window when the shell command completes.
+It will wait until you use the window manager to destroy/kill the window, or
+if you use the menu entries that send a signal, e.g., HUP or KILL.
+.TP 8
+.BI +hold
+Turn off the \fBhold\fP resource, i.e.,
+\fIxterm\fP will immediately destroy its window when the shell command completes.
+.TP 8
+.B \-ie
+Turn on the \fBptyInitialErase\fP resource, i.e.,
+use the pseudo-terminal's sense of the stty erase value.
+.TP 8
+.B +ie
+Turn off the \fBptyInitialErase\fP resource, i.e.,
+set the stty erase value using the \fBkb\fP string from the termcap entry as
+a reference, if available.
+.TP 8
+.B \-im
+Turn on the \fBuseInsertMode\fP resource,
+which forces use of insert mode by adding appropriate entries to the TERMCAP
+environment variable.
+.TP 8
+.B +im
+Turn off the \fBuseInsertMode\fP resource.
+.TP 8
+.BI \-into " windowId"
+Given an X window identifier (a decimal integer),
+\fIxterm\fP will reparent its top-level shell widget to that window.
+This is used to embed \fIxterm\fP within other applications.
+.TP 8
+.B \-j
+This option indicates that \fIxterm\fP should do jump scrolling.
+It corresponds to the \fBjumpScroll\fP resource.
+Normally,
+text is scrolled one line at a time; this option allows \fIxterm\fP to move
+multiple lines at a time so that it does not fall as far behind.
+Its use is
+strongly recommended since it makes \fIxterm\fP much faster when scanning
+through large amounts of text.
+The VT100 escape sequences for enabling and
+disabling smooth scroll as well as the \*(``VT Options\*(''
+menu can be used to turn this
+feature on or off.
+.TP 8
+.B +j
+This option indicates that \fIxterm\fP should not do jump scrolling.
+.TP 8
+.B \-k8
+This option sets the \fBallowC1Printable\fP resource.
+When \fBallowC1Printable\fP is set, \fIxterm\fP overrides the mapping
+of C1 control characters (code 128-159) to treat them as printable.
+.TP 8
+.B +k8
+This option resets the \fBallowC1Printable\fP resource.
+.TP 8
+.BI \-kt " keyboardtype"
+This option sets the \fBkeyboardType\fP resource.
+Possible values include:
+\*(``unknown\*('',
+\*(``default\*('',
+\*(``hp\*('',
+\*(``sco\*('',
+\*(``sun\*('',
+\*(``tcap\*('' and
+\*(``vt220\*(''.
+.IP
+The value \*(``unknown\*('',
+causes the corresponding resource to be ignored.
+.IP
+The value \*(``default\*('',
+suppresses the associated resources
+.BR hpFunctionKeys ,
+.BR scoFunctionKeys ,
+.BR sunFunctionKeys,
+.BR tcapFunctionKeys
+and
+.BR sunKeyboard ,
+using the Sun/PC keyboard layout.
+.TP 8
+.B \-l
+Turn logging on.
+Normally logging is not supported, due to security concerns.
+Some versions of \fIxterm\fP may have logging enabled.
+The logfile is written to the directory from which \fIxterm\fP is
+invoked.
+The filename is generated, of the form
+.sp
+       XtermLog.\fIXXXXXX\fR
+.sp
+or
+.sp
+       Xterm.log.\fIhostname.yyyy.mm.dd.hh.mm.ss.XXXXXX\fR
+.sp
+depending on how \fIxterm\fP was built.
+.TP 8
+.B +l
+Turn logging off.
+.TP 8
+.B \-lc
+Turn on support of various encodings according to the users'
+locale setting, i.e., LC_ALL, LC_CTYPE, or LANG environment variables.
+This is achieved by turning on UTF-8 mode and by invoking \fIluit\fR for
+conversion between locale encodings and UTF-8.
+(\fIluit\fR is not invoked in UTF-8 locales.)
+This corresponds to the \fBlocale\fR resource.
+.IP
+The actual list of encodings which are supported is determined by \fIluit\fR.
+Consult the \fIluit\fR manual page for further details.
+.IP
+See also the discussion of the \fB\-u8\fP option which supports UTF-8 locales.
+.TP 8
+.B +lc
+Turn off support of automatic selection of locale encodings.
+Conventional 8bit mode or, in UTF-8 locales or with \fB\-u8\fP option,
+UTF-8 mode will be used.
+.TP 8
+.BI \-lcc " path"
+File name for the encoding converter from/to locale encodings
+and UTF-8 which is used with \fB\-lc\fP option or \fBlocale\fR resource.
+This corresponds to the \fBlocaleFilter\fR resource.
+.TP 8
+.B \-leftbar
+Force scrollbar to the left side of VT100 screen.
+This is the default, unless you have set the rightScrollBar resource.
+.TP 8
+.BI \-lf " filename"
+Specify the log-filename.
+See the \fB\-l\fP option.
+.TP 8
+.B \-ls
+This option indicates that the shell that is started in the \fIxterm\fP window
+will be a login shell (i.e., the first character of argv[0] will be a dash,
+indicating to the shell that it should read the user's .login or .profile).
+.IP
+The \fB\-ls\fP flag and the \fBloginShell\fP resource
+are ignored if \fB\-e\fP is also given,
+because \fIxterm\fP does not know how to make the shell
+start the given command after whatever it does when it is a login
+shell \- the user's shell of choice need not be a Bourne shell after all.
+Also, \fIxterm\ \-e\fP is supposed to provide a consistent
+functionality for other applications that need to start text-mode
+programs in a window, and if \fBloginShell\fP were not ignored, the
+result of ~/.profile might interfere with that.
+.IP
+If you do want the effect of \fB\-ls\fP and \fB\-e\fP simultaneously, you
+may get away with something like
+.RS 15
+xterm \-e /bin/bash \-l \-c "my command here"
+.RE
+.IP
+Finally, \fB\-ls\fP is not completely ignored,
+because \fIxterm\ \-ls\ \-e\fP does write a \fI/etc/wtmp\fP entry
+(if configured to do so),
+whereas \fIxterm\ \-e\fP does not.
+.TP 8
+.B \-maximized
+This option indicates that \fIxterm\fP should ask the window manager to
+maximize its layout on startup.
+This corresponds to the \fBmaximized\fP resource.
+.IP
+Maximizing is not the reverse of iconifying;
+it is possible to do both with certain window managers.
+.TP 8
+.B +maximized
+This option indicates that \fIxterm\fP should ask the window manager to
+maximize its layout on startup.
+.TP 8
+.B +ls
+This option indicates that the shell that is started should not be a login
+shell (i.e., it will be a normal \*(``subshell\*('').
+.TP 8
+.B \-mb
+This option indicates that \fIxterm\fP should ring a margin bell when
+the user types near the right end of a line.
+.TP 8
+.B +mb
+This option indicates that margin bell should not be rung.
+.TP 8
+.BI \-mc " milliseconds"
+This option specifies the maximum time between multi-click selections.
+.TP 8
+.B \-mesg
+Turn off the \fBmessages\fP resource, i.e.,
+disallow write access to the terminal.
+.TP 8
+.B +mesg
+Turn on the \fBmessages\fP resource, i.e.,
+allow write access to the terminal.
+.TP 8
+.B "\-mk_width"
+Set the \fBmkWidth\fP resource to \*(``true\*(''.
+This makes \fIxterm\fP use a built-in version of the wide-character width
+calculation.
+The default is \*(``false\*(''
+.TP 8
+.B "+mk_width"
+Reset the \fBmkWidth\fP resource.
+.TP 8
+.BI \-ms " color"
+This option specifies the color to be used for the pointer cursor.
+The default
+is to use the foreground color.
+This sets the \fIpointerColor\fP resource.
+.TP 8
+.BI \-nb " number"
+This option specifies the number of characters from the right end of a line
+at which the margin bell, if enabled, will ring.
+The default is 10.
+.TP 8
+.B "\-nul"
+This option disables the display of underlining.
+.TP 8
+.B "+nul"
+This option enables the display of underlining.
+.TP 8
+.B \-pc
+This option enables the PC-style use of bold colors (see boldColors
+resource).
+.TP 8
+.B +pc
+This option disables the PC-style use of bold colors.
+.TP 8
+.B \-pob
+This option indicates that the window should be raised whenever a
+Control-G is received.
+.TP 8
+.B +pob
+This option indicates that the window should not be raised whenever a
+Control-G is received.
+.TP 8
+.B \-rightbar
+Force scrollbar to the right side of VT100 screen.
+.TP 8
+.B "\-rvc"
+This option disables the display of characters with reverse attribute as color.
+.TP 8
+.B "+rvc"
+This option enables the display of characters with reverse attribute as color.
+.TP 8
+.B \-rw
+This option indicates that reverse-wraparound should be allowed.
+This allows
+the cursor to back up from the leftmost column of one line to the rightmost
+column of the previous line.
+This is very useful for editing long shell
+command lines and is encouraged.
+This option can be turned on and off from
+the \*(``VT Options\*('' menu.
+.TP 8
+.B +rw
+This option indicates that reverse-wraparound should not be allowed.
+.TP 8
+.B \-s
+This option indicates that \fIxterm\fP may scroll asynchronously, meaning that
+the screen does not have to be kept completely up to date while scrolling.
+This allows \fIxterm\fP to run faster when network latencies are very high
+and is typically useful when running across a very large internet or many
+gateways.
+.TP 8
+.B +s
+This option indicates that \fIxterm\fP should scroll synchronously.
+.TP 8
+.B \-samename
+Does not send title and icon name change requests when the request
+would have no effect: the name is not changed.
+This has the advantage
+of preventing flicker and the disadvantage of requiring an extra
+round trip to the server to find out the previous value.
+In practice
+this should never be a problem.
+.TP 8
+.B +samename
+Always send title and icon name change requests.
+.TP 8
+.B \-sb
+This option indicates that some number of lines that are scrolled off the top
+of the window should be saved and that a scrollbar should be displayed so that
+those lines can be viewed.
+This option may be turned on and off from the
+\*(``VT Options\*('' menu.
+.TP 8
+.B +sb
+This option indicates that a scrollbar should not be displayed.
+.TP 8
+.BI \-selbg " color"
+This option specifies the color to use for the background of selected text.
+If not specified, reverse video is used.
+See the discussion of the \fBhighlightColor\fP resource.
+.TP 8
+.BI \-selfg " color"
+This option specifies the color to use for selected text.
+If not specified, reverse video is used.
+See the discussion of the \fBhighlightTextColor\fP resource.
+.TP 8
+.B \-sf
+This option indicates that Sun Function Key escape codes should be generated
+for function keys.
+.TP 8
+.B +sf
+This option indicates that the standard escape codes should be generated for
+function keys.
+.TP 8
+.B \-si
+This option indicates that output to a window should not automatically
+reposition the screen to the bottom of the scrolling region.
+This option can be turned on and off from the \*(``VT Options\*('' menu.
+.TP 8
+.B +si
+This option indicates that output to a window should cause it to
+scroll to the bottom.
+.TP 8
+.B \-sk
+This option indicates that pressing a key while
+using the scrollbar to review previous lines of text should
+cause the window to be repositioned automatically in the normal position at the
+bottom of the scroll region.
+.TP 8
+.B +sk
+This option indicates that pressing a key while using the scrollbar
+should not cause the window to be repositioned.
+.TP 8
+.BI \-sl " number"
+This option specifies the number of lines to save that have been scrolled
+off the top of the screen.
+This corresponds to the \fBsaveLines\fP resource.
+The default is 64.
+.TP 8
+.B \-sm
+This option, corresponding to the \fBsessionMgt\fR resource,
+indicates that \fIxterm\fR should
+set up session manager callbacks.
+.TP 8
+.B +sm
+This option indicates that \fIxterm\fR should
+not set up session manager callbacks.
+.TP 8
+.B \-sp
+This option indicates that Sun/PC keyboard should be assumed,
+providing mapping for keypad \*(``+' to \*(``,', and
+CTRL-F1 to F13, CTRL-F2 to F14, etc.
+.TP 8
+.B +sp
+This option indicates that the standard escape codes should be generated for
+keypad and function keys.
+.TP 8
+.B \-t
+This option indicates that \fIxterm\fP should start in Tektronix mode, rather
+than in VT102 mode.
+Switching between the two windows is done using the
+\*(``Options\*('' menus.
+.IR Termcap (5)
+entries that work with
+.I xterm
+\*(``tek4014,\*(''
+\*(``tek4015,\*(''
+\*(``tek4012,\*(''
+\*(``tek4013,\*(''
+\*(``tek4010,\*('' and
+\*(``dumb.\*(''
+.I xterm
+automatically searches the termcap file in this order for these entries and then
+sets the \*(``TERM\*('' and the \*(``TERMCAP\*('' environment variables.
+.TP 8
+.B +t
+This option indicates that \fIxterm\fP should start in VT102 mode.
+.TP 8
+.B \-tb
+This option, corresponding to the \fBtoolBar\fR resource,
+indicates that \fIxterm\fR should display a toolbar (or menubar)
+at the top of its window.
+The buttons in the toolbar correspond to
+the popup menus, e.g., control/left/mouse for "Main Options".
+.TP 8
+.B +tb
+This option indicates that \fIxterm\fR should
+not set up a toolbar.
+.TP 8
+.BI \-ti " term_id"
+Specify the name used by \fIxterm\fP to select the
+correct response to terminal ID queries.
+It also specifies the emulation level,
+used to determine the type of response to a DA control sequence.
+Valid values include vt52, vt100, vt101, vt102, and vt220 (the "vt" is optional).
+The default is vt100.
+The term_id argument specifies the terminal ID to use.
+(This is the same as the \fBdecTerminalID\fP resource).
+.TP 8
+.BI \-tm " string"
+This option specifies a series of terminal setting keywords followed by the
+characters that should be bound to those functions, similar to the \fIstty\fP
+program.
+The keywords and their values are described in detail in the \fBttyModes\fP
+resource.
+.TP 8
+.BI \-tn " name"
+This option specifies the name of the terminal type to be set in the TERM
+environment variable.
+It corresponds to the \fBtermName\fP resource.
+This terminal type must exist in the terminal
+database
+(termcap or terminfo, depending on how \fIxterm\fP is built)
+and should have \fIli#\fP and \fIco#\fP entries.
+If the terminal type is not found, \fIxterm\fP uses the built-in list
+\*(``xterm\*('', \*(``vt102\*('', etc.
+.TP 8
+.B \-u8
+This option sets the \fButf8\fP resource.
+When \fButf8\fP is set, \fIxterm\fP interprets incoming data as UTF-8.
+This sets the \fBwideChars\fP resource as a side-effect,
+but the UTF-8 mode set by this option prevents it from being turned off.
+If you must turn it on and off, use the \fBwideChars\fP resource.
+.IP
+This option and the \fButf8\fR resource are overridden by
+the \fB\-lc\fP and \fB\-en\fP options and \fBlocale\fR resource.
+That is, if \fIxterm\fP has been compiled to support \fIluit\fR,
+and the \fBlocale\fP resource is not \*(``false\*(''
+this option is ignored.
+We recommend using
+the \fB\-lc\fR option or the \*(``\fBlocale:\ true\fR\*('' resource
+in UTF-8 locales when your operating system supports locale,
+or \fB\-en\ UTF-8\fP option or the \*(``\fBlocale:\ UTF-8\fR\*('' resource
+when your operating system does not support locale.
+.TP 8
+.B +u8
+This option resets the \fButf8\fP resource.
+.TP 8
+.B "\-uc"
+This option makes the cursor underlined instead of a box.
+.TP 8
+.B "+uc"
+This option makes the cursor a box instead of underlined.
+.TP 8
+.B "\-ulc"
+This option disables the display of characters with underline attribute as
+color rather than with underlining.
+.TP 8
+.B "+ulc"
+This option enables the display of characters with underline attribute as
+color rather than with underlining.
+.TP 8
+.B "\-ulit"
+This option, corresponding to the \fBitalicULMode\fP resource,
+disables the display of characters with underline attribute as
+italics rather than with underlining.
+.TP 8
+.B "+ulit"
+This option, corresponding to the \fBitalicULMode\fP resource,
+enables the display of characters with underline attribute as
+italics rather than with underlining.
+.TP 8
+.B \-ut
+This option indicates that \fIxterm\fP should not write a record into the
+the system \fIutmp\fP log file.
+.TP 8
+.B +ut
+This option indicates that \fIxterm\fP should write a record into
+the system \fIutmp\fP log file.
+.TP 8
+.B \-vb
+This option indicates that a visual bell is preferred over an audible one.
+Instead of ringing the terminal bell whenever a Control-G is received, the
+window will be flashed.
+.TP 8
+.B +vb
+This option indicates that a visual bell should not be used.
+.TP 8
+.B \-wc
+This option sets the \fBwideChars\fP resource.
+When \fBwideChars\fP is set, \fIxterm\fP maintains internal structures for 16-bit
+characters.
+If you do not set this resource to \*(``true\*('',
+\fIxterm\fP will ignore the escape sequence which turns UTF-8 mode on and off.
+The default is \*(``false\*(''.
+.TP 8
+.B +wc
+This option resets the \fBwideChars\fP resource.
+.TP 8
+.B \-wf
+This option indicates that \fIxterm\fP should wait for the window to be mapped
+the first time before starting the subprocess so that the initial terminal
+size settings and environment variables are correct.
+It is the application's
+responsibility to catch subsequent terminal size changes.
+.TP 8
+.B +wf
+This option indicates that \fIxterm\fP should not wait before starting the
+subprocess.
+.TP 8
+.B \-ziconbeep \fIpercent\fP
+Same as \fBzIconBeep\fP resource.
+If percent is non-zero, xterms that produce output while iconified
+will cause an XBell sound at the given volume
+and have "***" prepended to their icon titles.
+Most window managers will detect this change immediately, showing you
+which window has the output.
+(A similar feature was in x10 \fIxterm\fP.)
+.TP 8
+.B \-C
+This option indicates that this window should receive console output.
+This
+is not supported on all systems.
+To obtain console output, you must be the
+owner of the console device, and you must have read and write permission
+for it.
+If you are running X under \fIxdm\fP on the console screen you may
+need to have the session startup and reset programs explicitly change the
+ownership of the console device in order to get this option to work.
+.TP 8
+.B \-S\fIccn\fP
+This option allows \fIxterm\fP to be used as an input and
+output channel for an existing program and is sometimes used in specialized
+applications.
+The option value specifies the last few letters of the name of a pseudo-terminal
+to use in slave mode, plus the number of the inherited file descriptor.
+If the option contains a \*(``/\*('' character, that delimits the characters
+used for the pseudo-terminal name from the file descriptor.
+Otherwise, exactly two characters are used from the option for
+the pseudo-terminal name, the remainder is the file descriptor.
+Examples
+(the first two are equivalent
+since the descriptor follows the last \*(``/\*(''):
+.sp
+.nf
+.RS 15
+-S/dev/pts/123/45
+-S123/45
+-Sab34
+.RE
+.fi
+.IP
+Note that \fIxterm\fP does not close any file descriptor
+which it did not open for its own use.
+It is possible (though probably not portable) to have an application
+which passes an open file descriptor down to \fIxterm\fP past the
+initialization or the \fB\-S\fP option to a process running in the \fIxterm\fP.
+.PP
+The following command line arguments are provided for compatibility with
+older versions.
+They may not be supported in the next release as the X
+Toolkit provides standard options that accomplish the same task.
+.TP 8
+.B "%\fIgeom\fP"
+This option specifies the preferred size and position of the Tektronix window.
+It is shorthand for specifying the \*(``\fI*tekGeometry\fP\*('' resource.
+.TP 8
+.B \ #\fIgeom\fP
+This option specifies the preferred position of the icon window.
+It is shorthand for specifying the \*(``\fI*iconGeometry\fP\*('' resource.
+.TP 8
+.BI \-T " string"
+This option specifies the title for \fIxterm\fP's windows.
+It is equivalent to \fB\-title\fP.
+.TP 8
+.BI \-n " string"
+This option specifies the icon name for \fIxterm\fP's windows.
+It is shorthand for specifying the \*(``\fI*iconName\fP\*('' resource.
+Note that this is not the same as the toolkit option \fB\-name\fP (see below).
+The default icon name is the application name.
+.TP 8
+.B \-r
+This option indicates that reverse video should be simulated by swapping
+the foreground and background colors.
+It is equivalent to
+\fB\-rv\fP.
+.TP 8
+.BI \-w " number"
+This option specifies the width in pixels of the border surrounding the window.
+It is equivalent to \fB\-borderwidth\fP or \fB\-bw\fP.
+.
+.PP
+The following standard X Toolkit command line arguments are commonly used
+with \fIxterm\fP:
+.TP 8
+.B \-bd \fIcolor\fP
+This option specifies the color to use for the border of the window.
+The corresponding resource name is \fIborderColor\fP.
+\fIxterm\fP uses the X Toolkit default, which is \*(``XtDefaultForeground\*(''.
+.TP 8
+.B \-bg \fIcolor\fP
+This option specifies the color to use for the background of the window.
+The corresponding resource name is \fIbackground\fP.
+The default is \*(``XtDefaultBackground.\*(''
+.TP 8
+.B \-bw \fInumber\fP
+This option specifies the width in pixels of the border surrounding the window.
+.IP
+This appears to be a legacy of older X releases.
+It sets the \fBborderWidth\fP resource of the shell widget,
+and may provide advice to your window manager to set the thickness of the
+window frame.
+Most window managers do not use this information.
+See the \fB\-b\fP option, which controls the inner border of the \fIxterm\fP
+window.
+.TP 8
+.B \-display \fIdisplay\fP
+This option specifies the X server to contact; see \fIX(__miscmansuffix__)\fP.
+.TP 8
+.B \-fg \fIcolor\fP
+This option specifies the color to use for displaying text.
+The corresponding resource name is \fIforeground\fP.
+The default is
+\*(``XtDefaultForeground.\*(''
+.TP 8
+.B \-fn \fIfont\fP
+This option specifies the font to be used for displaying normal text.
+The corresponding resource name is \fIfont\fP.
+The resource value default is \fIfixed\fP.
+.TP 8
+.B \-font \fIfont\fP
+This is the same as \fB\-fn\fP.
+.TP 8
+.B \-geometry \fIgeometry\fP
+This option specifies the preferred size and position of the VT102 window;
+see \fIX(__miscmansuffix__)\fP.
+.TP 8
+.B \-iconic
+This option indicates that \fIxterm\fP should ask the window manager to
+start it as an icon rather than as the normal window.
+The corresponding resource name is \fIiconic\fP.
+.TP 8
+.B \-name \fIname\fP
+This option specifies the application name under which resources are to be
+obtained, rather than the default executable file name.
+\fIName\fP should not contain \*(``.\*('' or \*(``*\*('' characters.
+.TP 8
+.B \-rv
+This option indicates that reverse video should be simulated by swapping
+the foreground and background colors.
+The corresponding resource name is \fIreverseVideo\fP.
+.TP 8
+.B +rv
+Disable the simulation of reverse video by swapping foreground and background
+colors.
+.TP 8
+.B \-title \fIstring\fP
+This option specifies the window title string, which may be displayed by
+window managers if the user so chooses.
+The default title is the command
+line specified after the \fB\-e\fP option, if any, otherwise the application
+name.
+.TP 8
+.B \-xrm \fIresourcestring\fP
+This option specifies a resource string to be used.
+This is especially
+useful for setting resources that do not have separate command line options.
+.
+.
+.SH RESOURCES
+The program understands all of the core X Toolkit resource names and classes.
+Application specific resources (e.g., "\fBXTerm.\fP\fINAME\fP") follow:
+.TP 8
+.B "backarrowKeyIsErase (\fPclass\fB BackarrowKeyIsErase)"
+Tie the VTxxx \fBbackarrowKey\fP and \fBptyInitialErase\fP resources
+together by setting the DECBKM state according to whether the initial value of
+stty erase is a backspace (8) or delete (127) character.
+The default is \*(``false\*('', which disables this feature.
+.TP 8
+.B "hold (\fPclass\fB Hold)"
+If true,
+\fIxterm\fP will not immediately destroy its window when the shell command completes.
+It will wait until you use the window manager to destroy/kill the window, or
+if you use the menu entries that send a signal, e.g., HUP or KILL.
+You may scroll back, select text, etc., to perform most graphical operations.
+Resizing the display will lose data, however, since this involves interaction
+with the shell which is no longer running.
+.TP 8
+.B "hpFunctionKeys (\fPclass\fB HpFunctionKeys)"
+Specifies whether or not HP Function Key escape codes should be generated for
+function keys instead of standard escape sequences.
+.IP
+See also the \fBkeyboardType\fP resource.
+.TP 8
+.B "iconGeometry (\fPclass\fB IconGeometry)"
+Specifies the preferred size and position of the application when iconified.
+It is not necessarily obeyed by all window managers.
+.TP 8
+.B "iconName (\fPclass\fB IconName)"
+Specifies the icon name.
+The default is the application name.
+.TP 8
+.B "keyboardType (\fPclass\fB KeyboardType)"
+Enables one (or none) of the various keyboard-type resources:
+\fBhpFunctionKeys\fP,
+\fBscoFunctionKeys\fP,
+\fBsunFunctionKeys\fP,
+\fBtcapFunctionKeys\fP and
+\fBsunKeyboard\fP.
+The resource's value should be one of the corresponding strings
+\*(``hp\*('',
+\*(``sco\*('',
+\*(``sun\*('',
+\*(``tcap\*('' or
+\*(``vt220\*(''.
+The individual resources are provided for legacy support;
+this resource is simpler to use.
+.TP 8
+.B "maxBufSize (\fPclass\fB MaxBufSize)"
+Specify the maximum size of the input buffer.
+The default is 32768.
+You cannot set this to a value less than the \fBminBufSize\fR resource.
+It will be increased as needed to make that value evenly divide this one.
+.IP
+On some systems you may want to increase one or both of the
+\fBmaxBufSize\fP and
+\fBminBufSize\fP resource values to achieve better performance
+if the operating system prefers larger buffer sizes.
+.TP 8
+.B "maximized (\fPclass\fB Maximized)"
+Specifies whether or not \fIxterm\fP should ask the window manager to
+maximize its layout on startup.
+The default is
+\*(``false.\*(''
+.TP 8
+.B "messages (\fPclass\fB Messages)"
+Specifies whether write access to the terminal is allowed initially.
+See
+.BR mesg (1).
+The default is \*(``true\*(''.
+.TP 9
+.B "menuLocale (\fPclass\fB MenuLocale)"
+Specify the locale used for character-set computations when loading
+the popup menus.
+Use this to improve initialization performance of the Athena popup menus,
+which may load unnecessary (and very large) fonts, e.g.,
+in a locale having UTF-8 encoding.
+The default is the "C" (POSIX).
+.IP
+To use the current locale
+(only useful if you have localized the resource settings for the menu entries),
+set the resource to an empty string.
+.TP 8
+.B "minBufSize (\fPclass\fB MinBufSize)"
+Specify the minimum size of the input buffer, i.e., the amount of data
+that \fIxterm\fR requests on each read.
+The default is 4096.
+You cannot set this to a value less than 64.
+.TP 8
+.B "ptyHandshake (\fPclass\fB PtyHandshake)
+If \*(``true\*('', \fIxterm\fP will perform handshaking during initialization
+to ensure that the parent and child processes update the \fIutmp\fP
+and \fIstty\fP state.
+.IP
+See also \fBwaitForMap\fP which waits for the pseudo-terminal's notion
+of the screen size,
+and \fBptySttySize\fP which resets the screen size after other terminal
+initialization is complete.
+The default is \*(``true\*(''.
+.TP 8
+.B "ptyInitialErase (\fPclass\fB PtyInitialErase)"
+If \*(``true\*('', \fIxterm\fP will use the pseudo-terminal's sense of the stty erase
+value.
+If \*(``false\*('', \fIxterm\fP will set the stty erase value to match its own
+configuration, using the \fBkb\fP string from the termcap entry as
+a reference, if available.
+In either case, the result is applied to the TERMCAP variable
+which \fIxterm\fP sets.
+.IP
+See also the \fBttyModes\fP resource, which may modify this.
+The default is \*(``false\*(''.
+.TP 8
+.B "ptySttySize (\fPclass\fB PtySttySize)
+If \*(``true\*('', \fIxterm\fP will reset the screen size after
+terminal initialization is complete.
+This is needed for some systems whose pseudo-terminals cannot
+propagate terminal characteristics.
+Where it is not needed, it can interfere with other methods for
+setting the intial screen size, e.g., via window manager interaction.
+.IP
+See also \fBwaitForMap\fP which waits for a handshake-message
+giving the pseudo-terminal's notion of the screen size.
+The default is \*(``false\*('' on Linux and OS X systems,
+\*(``true\*('' otherwise.
+.TP 8
+.B "sameName (\fPclass\fB SameName)"
+If the value of this resource is \*(``true\*('', \fIxterm\fP does not send
+title and icon name change requests when the request
+would have no effect: the name is not changed.
+This has the advantage
+of preventing flicker and the disadvantage of requiring an extra
+round trip to the server to find out the previous value.
+In practice
+this should never be a problem.
+The default is \*(``true\*(''.
+.TP 8
+.B "scoFunctionKeys (\fPclass\fB ScoFunctionKeys)"
+Specifies whether or not SCP Function Key escape codes should be generated for
+function keys instead of standard escape sequences.
+.IP
+See also the \fBkeyboardType\fP resource.
+.TP 8
+.B "sessionMgt (\fPclass\fB SessionMgt)"
+If the value of this resource is \*(``true\*('',
+\fIxterm\fP sets up session manager callbacks
+for \fBXtNdieCallback\fR and \fBXtNsaveCallback\fR.
+The default is \*(``true\*(''.
+.TP 8
+.B "sunFunctionKeys (\fPclass\fB SunFunctionKeys)"
+Specifies whether or not Sun Function Key escape codes should be generated for
+function keys instead of standard escape sequences.
+.IP
+See also the \fBkeyboardType\fP resource.
+.TP 8
+.B "sunKeyboard (\fPclass\fB SunKeyboard)"
+Specifies whether or not Sun/PC keyboard layout should be assumed rather
+than DEC VT220.
+This causes the keypad \*(``+' to be mapped to \*(``,'.
+and
+CTRL F1-F12 to F11-F20, depending on the setting of the \fBctrlFKeys\fP
+resource.
+so \fIxterm\fP emulates a DEC VT220 more accurately.
+Otherwise (the default, with \fBsunKeyboard\fP set to \*(``false\*(''),
+\fIxterm\fP uses PC-style bindings for the function keys and keypad.
+.IP
+PC-style bindings
+use the Shift, Alt, Control and Meta keys as modifiers for function-keys
+and keypad
+(see the document \fIXterm Control Sequences\fP for details).
+The PC-style bindings are analogous to PCTerm, but not the same thing.
+Normally these bindings do not conflict with the use of the Meta key
+as described for the \fBeightBitInput\fP resource.
+If they do, note that the PC-style bindings are evaluated first.
+.IP
+See also the \fBkeyboardType\fP resource.
+.TP 8
+.B "tcapFunctionKeys (\fPclass\fB TcapFunctionKeys)"
+Specifies whether or not function key escape codes read from the
+termcap/terminfo entry should be generated for
+function keys instead of standard escape sequences.
+.IP
+See also the \fBkeyboardType\fP resource.
+.TP 8
+.B "termName (\fPclass\fB TermName)"
+Specifies the terminal type name to be set in the TERM environment variable.
+.TP 8
+.B "title (\fPclass\fB Title)"
+Specifies a string that may be used by the window manager when displaying
+this application.
+.TP 8
+.B "toolBar (\fPclass\fB ToolBar)"
+Specifies whether or not the toolbar should be displayed.
+The default is
+\*(``true.\*(''
+.TP 8
+.B "ttyModes (\fPclass\fB TtyModes)"
+Specifies a string containing terminal setting keywords and the characters
+to which they may be bound.
+Allowable keywords include:
+brk,
+dsusp,
+eof,
+eol,
+eol2,
+erase,
+erase2,
+flush,
+intr,
+kill,
+lnext,
+quit,
+rprnt,
+start,
+status,
+stop,
+susp,
+swtch and
+weras.
+Control characters may be specified as ^char (e.g., ^c or ^u)
+and \fB^?\fP may be used to indicate delete (127).
+Use \fB^\-\fP to denote \fIundef\fP.
+Use \fB\\034\fP to represent \fB^\\\fP, since a literal backslash in
+an X resource escapes the next character.
+.IP
+This is very useful for overriding
+the default terminal settings without having to do an \fIstty\fP every time
+an \fIxterm\fP is started.
+Note, however, that the stty program on a given host may use different
+keywords; \fIxterm\fR's table is built-in.
+.IP
+If the \fBttyModes\fP resource specifies a value for \fBerase\fP,
+that overrides the \fBptyInitialErase\fP resource setting,
+i.e., \fIxterm\fP initializes the terminal to match that value.
+.TP 8
+.B "useInsertMode (\fPclass\fB UseInsertMode)"
+Force use of insert mode by adding appropriate entries to the TERMCAP
+environment variable.
+This is useful if the system termcap is broken.
+The default is \*(``false.\*(''
+.TP 8
+.B "utmpDisplayId (\fPclass\fB UtmpDisplayId)"
+Specifies whether or not \fIxterm\fP should try to record the display
+identifier (display number and screen number) as well as the hostname in
+the system \fIutmp\fP log file.
+The default is \*(``true.\*(''
+.TP 8
+.B "utmpInhibit (\fPclass\fB UtmpInhibit)"
+Specifies whether or not \fIxterm\fP should try to record the user's terminal
+in
+the system \fIutmp\fP log file.
+If true, \fIxterm\fP will not try.
+The default is \*(``false.\*(''
+.TP 8
+.B "waitForMap (\fPclass\fB WaitForMap)"
+Specifies whether or not \fIxterm\fP should wait for the initial window map
+before starting the subprocess.
+This is part of the
+.B ptyHandshake
+logic.
+When \fIxterm\fP is directed to wait in this fashion,
+it passes the terminal size from the display end of the pseudo-terminal
+to the terminal I/O connection, e.g., according to the window manager.
+Otherwise, it uses the size as given in resource values or command-line
+option \fB\-geom\fP.
+The default is \*(``false.\*(''
+.TP 8
+.B "zIconBeep (\fPclass\fB ZIconBeep)"
+Same as \-ziconbeep command line argument.
+If the value of this resource is non-zero, xterms that produce output
+while iconified will cause an XBell sound at the given volume
+and have "***" prepended to their icon titles.
+Most window managers will detect this change immediately, showing you
+which window has the output.
+(A similar feature was in x10 \fIxterm\fR.)
+The default is \*(``false.\*(''
+.\"
+.SS VT100 Widget Resources
+.PP
+The following resources are specified as part
+of the \fIvt100\fP widget (class \fIVT100\fP).
+They are specified by patterns such as "\fBXTerm.vt100.\fP\fINAME\fP".
+.PP
+If your \fIxterm\fP is configured to support the "toolbar", then those
+patterns need an extra level for the form-widget which holds the
+toolbar and vt100 widget.  A wildcard between the top-level
+"XTerm" and the "vt100" widget makes the resource settings work for
+either, e.g., "\fBXTerm*vt100.\fP\fINAME\fP".
+.TP 8
+.B "activeIcon (\fPclass\fB ActiveIcon)"
+Specifies whether or not active icon windows are to be used when the
+\fIxterm\fP window is iconified, if this feature is compiled into \fIxterm\fR.
+The active icon is a miniature representation of the content of the
+window and will update as the content changes.
+Not all window managers
+necessarily support application icon windows.
+Some window managers
+will allow you to enter keystrokes into the active icon window.
+The default is \*(``false.\*(''
+.TP 8
+.B "allowC1Printable (\fPclass\fB AllowC1Printable)"
+If true, overrides the mapping of C1 controls
+(codes 128-159) to make them be treated
+as if they were printable characters.
+Although this corresponds to no particular standard,
+some users insist it is a VT100.
+The default is \*(``false.\*(''
+.TP
+.B "allowColorOps (\fPclass\fB AllowColorOps)"
+Specifies whether control sequences that set/query the dynamic colors should be allowed.
+ANSI colors are unaffected by this resource setting.
+The default is \*(``true.\*(''
+.TP
+.B "allowFontOps (\fPclass\fB AllowFontOps)"
+Specifies whether control sequences that set/query the font should be allowed.
+The default is \*(``true.\*(''
+.TP 8
+.B "allowScrollLock (\fPclass\fB AllowScrollLock)"
+Specifies whether control sequences that set/query
+the Scroll Lock key should be allowed,
+as well as whether the Scroll Lock key responds to user's keypress.
+The default is \*(``false.\*(''
+.IP
+When this feature is enabled, \fIxterm\fP will sense the state of the
+Scroll Lock key each time it acquires focus.
+Pressing the Scroll Lock key toggles \fIxterm\fP's internal state,
+as well as toggling the associated LED.
+While the Scroll Lock is active, \fIxterm\fP attempts to keep a viewport on the
+same set of lines.
+If the current viewport is scrolled past the limit set by the
+\fBsaveLines\fP resource, then Scroll Lock has no further effect.
+.IP
+The reason for setting the default to \*(``false.\*('' is to avoid
+user surprise.  This key is generally unused in keyboard configurations,
+and has not acquired a standard meaning even when it is used in that manner.
+Consequently, users have assigned it for ad hoc purposes.
+.TP 8
+.B "allowSendEvents (\fPclass\fB AllowSendEvents)"
+Specifies whether or not synthetic key and button events (generated using
+the X protocol SendEvent request) should be interpreted or discarded.
+The default is \*(``false\*('' meaning they are discarded.
+Note that allowing such events would create a very large security hole, therefore
+enabling this resource forcefully disables the \fBallow\fP\fIXXX\fP\fBOps\fR resources.
+The default is \*(``false.\*(''
+.TP
+.B "allowTcapOps (\fPclass\fB AllowTcapOps)"
+Specifies whether control sequences that query the terminal's
+notion of its function-key strings, as termcap or terminfo capabilities
+should be allowed.
+The default is \*(``false.\*(''
+.IP
+A few programs, e.g,. \fIvim\fP, use this feature to get an accurate
+description of the terminal's capabilities,
+independent of the termcap/terminfo setting:
+.RS
+.TP 3
+-
+\fIxterm\fP can tell the querying program how many colors it supports.
+This is a constant, depending on how it is compiled, typically 16.
+It does not change if you alter resource settings,
+e.g., the \fBboldColors\fP resource.
+.TP 3
+-
+\fIxterm\fP can tell the querying program what strings are sent by modified
+(shift-, control-, alt-) function- and keypad-keys.
+Reporting control- and alt-modifiers is a feature that relies on the
+\fIncurses\fP extended naming.
+.RE
+.TP
+.B "allowTitleOps (\fPclass\fB AllowTitleOps)"
+Specifies whether control sequences that modify the window title or icon name
+should be allowed.
+The default is \*(``true.\*(''
+.TP
+.B "allowWindowOps (\fPclass\fB AllowWindowOps)"
+Specifies whether extended window control sequences
+(as used in \fIdtterm\fP)
+should be allowed.
+These include several control sequences which manipulate the window size or
+position, as well as reporting these values and the title or icon name.
+Each of these can be abused in a script;
+curiously enough most terminal emulators that implement these
+restrict only a small part of the repertoire.
+For fine-tuning, see \fBdisallowedWindowOps\fP.
+The default is \*(``false.\*(''
+.TP 8
+.B "altIsNotMeta (\fPclass\fB AltIsNotMeta\fP)"
+If \*(``true\*('', treat the Alt-key as if it were the Meta-key.
+Your keyboard may happen to be configured so they are the same.
+But if they are not, this allows you to use the same prefix- and shifting
+operations with the Alt-key as with the Meta-key.
+See \fBaltSendsEscape\fP and \fBmetaSendsEscape\fP.
+The default is \*(``false.\*(''
+.TP 8
+.B "altSendsEscape (\fPclass\fB AltSendsEscape\fP)"
+This is an additional keyboard operation that may be processed
+after the logic for \fBmetaSendsEscape\fP.
+It is only available if the \fBaltIsNotMeta\fP resource is set.
+.IP
+If \*(``true\*('', Alt characters
+(a character combined with the modifier associated with left/right Alt-keys)
+are converted into a two-character
+sequence with the character itself preceded by ESC.
+This applies as well to function key control sequences, unless \fIxterm\fP
+sees that \fBAlt\fP is used in your key translations.
+If \*(``false\*('', Alt characters input from the keyboard cause a shift to
+8-bit characters (just like \fBmetaSendsEscape\fP).
+By combining the Alt- and Meta-modifiers, you can create corresponding
+combinations of ESC-prefix and 8-bit characters.
+The default is \*(``false.\*(''
+.TP 8
+.B "alwaysBoldMode (\fPclass\fB AlwaysBoldMode)"
+Specifies whether \fIxterm\fP should check if the normal and bold
+fonts are distinct before deciding whether to use overstriking to
+simulate bold fonts.
+If this resource is true,
+\fIxterm\fP does not make the check for
+distinct fonts when deciding how to handle the \fBboldMode\fP resource.
+The default is \*(``false.\*(''
+.TS
+l l l l
+_ _ _ _
+l l l l.
+\fIboldMode\fR \fIalwaysBoldMode\fR    \fIComparison\fR        \fIAction\fP
+false  false   ignored use font
+false  true    ignored use font
+true   false   same    overstrike
+true   false   different       use font
+true   true    ignored overstrike
+.TE
+.TP 8
+.B "alwaysHighlight (\fPclass\fB AlwaysHighlight)"
+Specifies whether or not \fIxterm\fP should always display a highlighted
+text cursor.
+By default (if this resource is false),
+a hollow text cursor is displayed whenever the
+pointer moves out of the window or the window loses the input focus.
+The default is \*(``false.\*(''
+.TP 8
+.B "alwaysUseMods (\fPclass\fB AlwaysUseMods)"
+Override the \fBnumLock\fP resource, telling \fIxterm\fR to use the Alt and Meta
+modifiers to construct parameters for function key sequences even if
+those modifiers appear in the translations resource.
+Normally \fIxterm\fP checks if Alt or Meta is used in a translation that
+would conflict with function key modifiers, and will ignore these modifiers
+in that special case.
+The default is \*(``false.\*(''
+.TP 8
+.B "answerbackString (\fPclass\fB AnswerbackString)"
+Specifies the string that \fIxterm\fR sends in response to an ENQ (control/E)
+character from the host.
+The default is a blank string, i.e., \*(``\*(''.
+A hardware VT100 implements this feature as a setup option.
+.TP 8
+.B "appcursorDefault (\fPclass\fB AppcursorDefault)"
+If \*(``true,\*('' the cursor keys are initially in application mode.
+This is the same as the VT102 private DECCKM mode,
+The default is \*(``false.\*(''
+.TP 8
+.B "appkeypadDefault (\fPclass\fB AppkeypadDefault)"
+If \*(``true,\*('' the keypad keys are initially in application mode.
+The default is \*(``false.\*(''
+.TP 8
+.B "autoWrap (\fPclass\fB AutoWrap)"
+Specifies whether or not auto-wraparound should be enabled.
+This is the same as the VT102 DECAWM.
+The
+default is \*(``true.\*(''
+.TP 8
+.B "awaitInput (\fPclass\fB AwaitInput)"
+Specifies whether or not the \fIxterm\fR uses a 50 millisecond timeout to
+await input (i.e., to support the Xaw3d arrow scrollbar).
+The default is \*(``false.\*(''
+.TP 8
+.B "backarrowKey (\fPclass\fB BackarrowKey)"
+Specifies whether the backarrow key transmits
+a backspace (8)
+or delete (127) character.
+This corresponds to the DECBKM control sequence.
+The default (backspace) is \*(``true.\*(''
+Pressing the control key toggles this behavior.
+.TP 8
+.B "background (\fPclass\fB Background)"
+Specifies the color to use for the background of the window.
+The default is
+\*(``XtDefaultBackground.\*(''
+.TP 8
+.B "bellIsUrgent (\fPclass\fB BellIsUrgent)"
+Specifies whether to set the Urgency hint for the window manager
+when making a bell sound.
+The default is \*(``false.\*(''
+.TP 8
+.B "bellOnReset (\fPclass\fB BellOnReset)"
+Specifies whether to sound a bell when doing a hard reset.
+The default is \*(``true.\*(''
+.TP 8
+.B "bellSuppressTime (\fPclass\fB BellSuppressTime)"
+Number of milliseconds after a bell command is sent during which additional
+bells will be suppressed.
+Default is 200.
+If set non-zero,
+additional bells
+will also be suppressed until the server reports that processing of
+the first bell has been completed; this feature is most useful with
+the visible bell.
+.TP 8
+.B "boldColors (\fPclass\fB ColorMode)"
+Specifies whether to combine bold attribute with colors like the IBM PC,
+i.e., map colors 0 through 7 to colors 8 through 15.
+These normally are the brighter versions of the first 8 colors, hence bold.
+The default is \*(``true.\*(''
+.TP 8
+.B "boldFont (\fPclass\fB BoldFont)"
+Specifies the name of the bold font to use instead of overstriking.
+There is no default for this resource.
+.IP
+This font must be the same height and width as the normal font, otherwise it is ignored.
+If only one of the normal or bold fonts is specified, it will be used as the
+normal font and the bold font will be produced by overstriking this font.
+.IP
+See also the discussion of \fBboldMode\fP and \fBalwaysBoldMode\fP resources.
+.TP 8
+.B "boldMode (\fPclass\fB BoldMode)"
+This specifies whether or not text with the bold attribute should be
+overstruck to simulate bold fonts if the resolved bold font is the
+same as the normal font.
+It may be desirable to disable bold fonts when color is being
+used for the bold attribute.
+.IP
+Note that \fIxterm\fP has one bold font which you may set explicitly.
+\fIXterm\fP attempts to derive a bold font for the other font selections
+(\fBfont1\fP through \fBfont6\fP).
+If it cannot find a bold font, it will use the normal font.
+In each case (whether the explicit resource or the derived font),
+if the normal and bold fonts are distinct, this resource has no effect.
+The default is \*(``true.\*(''
+.IP
+See the \fBalwaysBoldMode\fP resource which can modify the behavior
+of this resource.
+.IP
+Although \fIxterm\fP attempts to derive a bold font for other font selections,
+the font server may not cooperate.
+Since X11R6, bitmap fonts have been scaled.
+The font server claims to provide the bold font that \fIxterm\fP requests,
+but the result is not always readable.
+XFree86 provides a feature which can be used to suppress the scaling.
+In the X server's configuration file (e.g., "/etc/X11/XFree86"), you
+can add ":unscaled" to the end of the directory specification for the
+"misc" fonts, which comprise the fixed-pitch fonts that are used by \fIxterm\fP.
+For example
+.RS
+       FontPath        "/usr/lib/X11/fonts/misc/"
+.RE
+.IP
+would become
+.RS
+       FontPath        "/usr/lib/X11/fonts/misc/:unscaled"
+.RE
+.IP
+Depending on your configuration, the font server may have its own configuration
+file.
+The same ":unscaled" can be added to its configuration file at the
+end of the directory specification for "misc".
+.IP
+The bitmap scaling feature is also used by \fIxterm\fP to implement
+VT102 double-width and double-height characters.
+.TP 8
+.B "brokenLinuxOSC (\fPclass\fB BrokenLinuxOSC)"
+If true, \fIxterm\fP applies a workaround to ignore malformed control
+sequences that a Linux script might send.
+Compare the palette control sequences documented in \fIconsole_codes\fR
+with ECMA-48.
+The default is \*(``true.\*(''
+.TP 8
+.B "brokenSelections (\fPclass\fB BrokenSelections)"
+If true, \fIxterm\fP in 8-bit mode will interpret
+.B STRING
+selections as carrying text in the current locale's encoding.
+Normally
+.B STRING
+selections carry ISO-8859-1 encoded text.
+Setting this resource to
+\*(``true\*('' violates the ICCCM; it may, however, be useful for interacting
+with some broken X clients.
+The default is \*(``false.\*(''
+.TP 8
+.B "brokenStringTerm (\fPclass\fB BrokenStringTerm)"
+provides a work-around for some ISDN routers which start an application
+control string without completing it.
+Set this to \*(``true\*('' if \fIxterm\fP appears to freeze when connecting.
+The default is \*(``false.\*(''
+.IP
+\fIXterm\fP's state parser recognizes
+several types of control strings which can contain text, e.g.,
+.sp
+.RS
+\fBAPC\fP (Application Program Command),
+.br
+\fBDCS\fP (Device Control String),
+.br
+\fBOSC\fP (Operating System Command),
+.br
+\fBPM\fP (Privacy Message), and
+.br
+\fBSOS\fP (Start of String),
+.RE
+.IP
+Each should end with a string-terminator (a special character which
+cannot appear in these strings).
+Ordinary control characters found within the string are not ignored;
+they are processed without interfering with the process of accumulating
+the control string's content.
+\fIXterm\fP recognizes these controls in all modes,
+although some of the functions may be suppressed after parsing the control.
+.IP
+When enabled, this feature allows the user to exit from an unterminated
+control string when any of these ordinary control characters are found:
+.sp
+.RS
+control/D (used as an end of file in many shells),
+.br
+control/H (backspace),
+.br
+control/I (tab-feed),
+.br
+control/J (line feed aka newline),
+.br
+control/K (vertical tab),
+.br
+control/L (form feed),
+.br
+control/M (carriage return),
+.br
+control/N (shift-out),
+.br
+control/O (shift-in),
+.br
+control/Q (XOFF),
+.br
+control/X (cancel)
+.RE
+.TP 8
+.B "c132 (\fPclass\fB C132)"
+Specifies whether or not the VT102 DECCOLM escape sequence,
+used to switch between 80 and 132 columns, should be honored.
+The default is \*(``false.\*(''
+.TP 8
+.B "cacheDoublesize (\fPclass\fB CacheDoublesize)"
+Tells whether to cache double-sized fonts by \fIxterm\fR.
+Set this to zero to disable double-sized fonts altogether.
+.TP 8
+.B "charClass (\fPclass\fB CharClass)"
+Specifies comma-separated lists of character class bindings of the form
+[\fIlow\fP-]\fIhigh\fP:\fIvalue\fP.
+These are used in determining which
+sets of characters should be treated the same when doing cut and paste.
+See the \fBCHARACTER CLASSES\fP section.
+.TP 8
+.B "cjkWidth (\fPclass\fB CjkWidth)"
+Specifies whether \fIxterm\fP should follow
+the traditional East Asian width convention.
+When turned on, characters with East Asian Ambiguous (A) category in UTR
+11 have a column width of 2.
+You may have to set this option to \*(``true\*(''
+if you have some old East Asian terminal based programs that assume that
+line-drawing characters have a column width of 2.
+If this resource is false, the \fBmkWidth\fP resource controls the
+choice between the system's \fBwcwidth\fP and \fIxterm\fP's built-in tables.
+The default is \*(``false.\*(''
+.TP 8
+.B "color0 (\fPclass\fB Color0)"
+.TP 8
+.B "color1 (\fPclass\fB Color1)"
+.TP 8
+.B "color2 (\fPclass\fB Color2)"
+.TP 8
+.B "color3 (\fPclass\fB Color3)"
+.TP 8
+.B "color4 (\fPclass\fB Color4)"
+.TP 8
+.B "color5 (\fPclass\fB Color5)"
+.TP 8
+.B "color6 (\fPclass\fB Color6)"
+.TP 8
+.B "color7 (\fPclass\fB Color7)"
+These specify the colors for the ISO-6429 extension.
+The defaults are,
+respectively,
+black,
+red3,
+green3,
+yellow3,
+a customizable dark blue,
+magenta3,
+cyan3,
+and
+gray90.
+The default shades of color are chosen to allow the colors 8-15
+to be used as brighter versions.
+.TP 8
+.B "color8 (\fPclass\fB Color8)"
+.TP 8
+.B "color9 (\fPclass\fB Color9)"
+.TP 8
+.B "color10 (\fPclass\fB Color10)"
+.TP 8
+.B "color11 (\fPclass\fB Color11)"
+.TP 8
+.B "color12 (\fPclass\fB Color12)"
+.TP 8
+.B "color13 (\fPclass\fB Color13)"
+.TP 8
+.B "color14 (\fPclass\fB Color14)"
+.TP 8
+.B "color15 (\fPclass\fB Color15)"
+These specify the colors for the ISO-6429 extension if the bold attribute
+is also enabled.
+The default resource values are respectively,
+gray30,
+red,
+green,
+yellow,
+a customizable light blue,
+magenta,
+cyan,
+and
+white.
+.TP 8
+.B "color16 (\fPclass\fB Color16)"
+.TP 8
+through
+.TP 8
+.B "color255 (\fPclass\fB Color255)"
+These specify the colors for the 256-color extension.
+The default resource values
+are for colors 16 through 231 to make a 6x6x6 color cube, and colors
+232 through 255 to make a grayscale ramp.
+.IP
+Resources past \fBcolor15\fP are available as a compile-time option.
+Due to a hardcoded limit in the X libraries on the total number of
+resources (to 400), the resources for 256-colors
+are omitted when wide-character support and \fIluit\fP are enabled.
+Besides inconsistent behavior if only part of the resources were allowed,
+determining the exact cutoff is difficult, and the X libraries tend
+to crash if the number of resources exceeds the limit.
+The color palette is still initialized to the same default values,
+and can be modified via control sequences.
+.IP
+On the other hand, the resource limit does permit including the entire
+range for 88-colors.
+.TP 8
+.B "colorAttrMode (\fPclass\fB ColorAttrMode)"
+Specifies whether \fBcolorBD\fP, \fBcolorBL\fP, \fBcolorRV\fP, and
+\fBcolorUL\fP should override ANSI colors.
+If not, these are displayed only when no ANSI colors
+have been set for the corresponding position.
+The default is \*(``false.\*(''
+.TP 8
+.B "colorBD (\fPclass\fB ColorBD)"
+This specifies the color to use to display bold characters if
+the \*(``colorBDMode\*('' resource is enabled.
+The default is \*(``XtDefaultForeground.\*(''
+.TP 8
+.B "colorBDMode (\fPclass\fB ColorAttrMode)"
+Specifies whether characters with the bold attribute should be displayed in
+color or as bold characters.
+Note that setting \fBcolorMode\fR off disables
+all colors, including bold.
+The default is \*(``false.\*(''
+.TP 8
+.B "colorBL (\fPclass\fB ColorBL)"
+This specifies the color to use to display blink characters if
+the \*(``colorBLMode\*('' resource is enabled.
+The default is \*(``XtDefaultForeground.\*(''
+.TP 8
+.B "colorBLMode (\fPclass\fB ColorAttrMode)"
+Specifies whether characters with the blink attribute should be displayed in
+color.
+Note that setting \fBcolorMode\fR off disables all colors, including this.
+The default is \*(``false.\*(''
+.TP 8
+.B "colorMode (\fPclass\fB ColorMode)"
+Specifies whether or not recognition of ANSI (ISO-6429)
+color change escape sequences should be enabled.
+The default is \*(``true.\*(''
+.TP 8
+.B "colorRV (\fPclass\fB ColorRV)"
+This specifies the color to use to display reverse characters if
+the \*(``colorRVMode\*('' resource is enabled.
+The default is \*(``XtDefaultForeground.\*(''
+.TP 8
+.B "colorRVMode (\fPclass\fB ColorAttrMode)"
+Specifies whether characters with the reverse attribute should be displayed in
+color.
+Note that setting \fBcolorMode\fR off disables all colors, including this.
+The default is \*(``false.\*(''
+.TP 8
+.B "colorUL (\fPclass\fB ColorUL)"
+This specifies the color to use to display underlined characters if
+the \*(``colorULMode\*('' resource is enabled.
+The default is \*(``XtDefaultForeground.\*(''
+.TP 8
+.B "colorULMode (\fPclass\fB ColorAttrMode)"
+Specifies whether characters with the underline attribute should be displayed
+in color or as underlined characters.
+Note that setting \fBcolorMode\fR off
+disables all colors, including underlining.
+The default is \*(``false.\*(''
+.TP 8
+.B "combiningChars (\fPclass\fB CombiningChars)"
+Specifies the number of wide-characters which can be stored in a cell
+to overstrike (combine) with the base character of the cell.
+This can be set to values in the range 0 to 4.
+The default is \*(``2\*(''.
+.TP 8
+.B "ctrlFKeys (\fPclass\fB CtrlFKeys)"
+In VT220 keyboard mode (see \fBsunKeyboard\fP resource),
+specifies the amount by which to shift F1-F12 given a control modifier (CTRL).
+This allows you to generate key symbols for F10-F20 on a Sun/PC keyboard.
+The default is \*(``10\*('', which means that CTRL F1 generates the key
+symbol for F11.
+.TP 8
+.B "curses (\fPclass\fB Curses)"
+Specifies whether or not the last column bug in
+.IR more (1)
+should be worked around.
+See the \fB\-cu\fP option for details.
+The default is \*(``false.\*(''
+.TP 8
+.B "cursorBlink (\fPclass\fB CursorBlink)"
+Specifies whether to make the cursor blink.
+The default is \*(``false.\*(''
+.TP 8
+.B "cursorColor (\fPclass\fB CursorColor)"
+Specifies the color to use for the text cursor.
+The default is \*(``XtDefaultForeground.\*(''
+By default,
+\fIxterm\fP attempts to keep this color from being the same as the background
+color, since it draws the cursor by filling the background of a text cell.
+The same restriction applies to control sequences which may change this color.
+.IP
+Setting this resource overrides
+most of \fIxterm\fP's adjustments to cursor color.
+It will still use reverse-video to disallow some cases, such as a black
+cursor on a black background.
+.TP 8
+.B "cursorOffTime (\fPclass\fB CursorOffTime)"
+Specifies the duration of the "off" part of the cursor blink cycle-time
+in milliseconds.
+The same timer is used for text blinking.
+The default is 300.
+.TP 8
+.B "cursorOnTime (\fPclass\fB CursorOnTime)"
+Specifies the duration of the "on" part of the cursor blink cycle-time,
+in milliseconds.
+The same timer is used for text blinking.
+The default is 600.
+.TP 8
+.B "cutNewline (\fPclass\fB CutNewline)"
+If \*(``false\*('', triple clicking to select a line does not include the Newline
+at the end of the line.
+If \*(``true\*('', the Newline is selected.
+The default is \*(``true.\*(''
+.TP 8
+.B "cursorUnderLine (\fPclass\fB CursorUnderLine)"
+Specifies whether to make the cursor underlined or a box.
+The default is \*(``false.\*(''
+.TP 8
+.B "cutToBeginningOfLine (\fPclass\fB CutToBeginningOfLine)"
+If \*(``false\*('', triple clicking to select a line selects only from the
+current word forward.
+If \*(``true\*('', the entire line is selected.
+The default is \*(``true.\*(''
+.TP 8
+.B "decTerminalID (\fPclass\fB DecTerminalID)"
+Specifies the emulation level (100=VT100, 220=VT220, etc.), used to determine
+the type of response to a DA control sequence.
+Leading non-digit characters are ignored, e.g., "vt100" and "100" are the same.
+The default is 100.
+.TP 8
+.B "defaultString (\fPclass\fB DefaultString)"
+Specify the character (or string) which \fIxterm\fP will substitute when
+pasted text includes a character which cannot be represented in the
+current encoding.
+For instance, pasting UTF-8 text into a display of ISO-8859-1 characters
+will only be able to display codes 0-255, while UTF-8 text can include
+Unicode values above 255.
+The default is \*(``#\*('' (a single pound sign).
+.IP
+If the undisplayable text would be double-width,
+\fIxterm\fP will add a space after the \*(``#\*('' character, to give roughly
+the same layout on the screen as the original text.
+.TP 8
+.B "deleteIsDEL (\fPclass\fB DeleteIsDEL)"
+Specifies whether the Delete key on the editing keypad should send DEL (127)
+or the VT220-style Remove escape sequence.
+The default is \*(``false,\*('' for the latter.
+.TP 8
+.B "disallowedColorOps (\fPclass\fB DisallowedColorOps)"
+Specify which features will be disabled if \fBallowColorOps\fP is false.
+This is a comma-separated list of names.
+The default value is
+.RS
+SetColor,GetColor,GetAnsiColor
+.RE
+.IP
+The names are listed below.  \fIxterm\fP ignores capitalization, but
+they are shown in mixed-case for clarity.
+.RS
+.TP 5
+SetColor
+Set a specific dynamic color.
+.TP 5
+GetColor
+Report the current setting of a given dynamic color.
+.TP 5
+GetAnsiColor
+Report the current setting of a given ANSI color (actually any of the colors
+set via ANSI-style controls).
+.RE
+.TP 8
+.B "disallowedFontOps (\fPclass\fB DisallowedFontOps)"
+Specify which features will be disabled if \fBallowFontOps\fP is false.
+This is a comma-separated list of names.
+The default value is
+.RS
+SetFont,GetFont
+.RE
+.IP
+The names are listed below.  \fIxterm\fP ignores capitalization, but
+they are shown in mixed-case for clarity.
+.RS
+.TP 5
+SetFont
+Set the specified font.
+.TP 5
+GetFont
+Report the specified font.
+.RE
+.TP 8
+.B "disallowedTcapOps (\fPclass\fB DisallowedTcapOps)"
+Specify which features will be disabled if \fBallowTcapOps\fP is false.
+This is a comma-separated list of names.
+The default value is
+.RS
+SetTcap,GetTcap
+.RE
+.IP
+The names are listed below.  \fIxterm\fP ignores capitalization, but
+they are shown in mixed-case for clarity.
+.RS
+.TP 5
+SetTcap
+(not implemented)
+.TP 5
+GetTcap
+Report specified function- and other special keys.
+.RE
+.TP 8
+.B "disallowedWindowOps (\fPclass\fB DisallowedWindowOps)"
+Specify which features will be disabled if \fBallowWindowOps\fP is false.
+This is a comma-separated list of names, or (for the controls adapted
+from \fIdtterm\fP the operation number).
+The default value is
+.RS
+20,21,SetXprop,SetSelection
+.RE
+.IP
+The names are listed below.  \fIxterm\fP ignores capitalization, but
+they are shown in mixed-case for clarity.  Where a number can be used
+as an alternative, it is given in parentheses after the name.
+.RS
+.TP 5
+GetIconTitle (20)
+Report xterm window's icon label as a string.
+.TP 5
+GetScreenSizeChars (19)
+Report the size of the screen in characters as numbers.
+.TP 5
+GetSelection
+Report selection data as a base64 string.
+.TP 5
+GetWinPosition (13)
+Report xterm window position as numbers.
+.TP 5
+GetWinSizeChars (18)
+Report the size of the text area in characters as numbers.
+.TP 5
+GetWinSizePixels (14)
+Report xterm window in pixels as numbers.
+.TP 5
+GetWinState (11)
+Report xterm window state as a number.
+.TP 5
+GetWinTitle (21)
+Report xterm window's title as a string.
+.TP 5
+LowerWin (6)
+Lower the xterm window to the bottom of the stacking order.
+.TP 5
+MaximizeWin (9)
+Maximize window (i.e., resize to screen size).
+.TP 5
+MinimizeWin (2)
+Iconify window.
+.TP 5
+PopTitle (23)
+Pop title from internal stack.
+.TP 5
+PushTitle (22)
+Push title to internal stack.
+.TP 5
+RaiseWin (5)
+Raise the xterm window to the front of the stacking order.
+.TP 5
+RefreshWin (7)
+Refresh the xterm window.
+.TP 5
+RestoreWin (1)
+De-iconify window.
+.TP 5
+SetSelection
+Set selection data.
+.TP 5
+SetWinLines
+Resize to a given number of lines, at least 24.
+.TP 5
+SetWinPosition (3)
+Move window to given coordinates.
+.TP 5
+SetWinSizeChars (8)
+Resize the text area to given size in characters.
+.TP 5
+SetWinSizePixels (4)
+Resize the xterm window to given size in pixels.
+.TP 5
+SetXprop
+Set X property on top-level window.
+.RE
+.TP 8
+.B "dynamicColors (\fPclass\fB DynamicColors)"
+Specifies whether or not escape sequences to change colors assigned to
+different attributes are recognized.
+.TP 8
+.B "eightBitControl (\fPclass\fB EightBitControl\fP)"
+Specifies whether or not control sequences sent by the
+terminal should be eight-bit characters or escape sequences.
+The default is \*(``false.\*(''
+.TP 8
+.B "eightBitInput (\fPclass\fB EightBitInput\fP)"
+If \*(``true\*('', Meta characters
+(a single-byte character combined with the \fIMeta\fP modifier key)
+input from the keyboard are presented as a
+single character with the eighth bit turned on.
+The terminal is put into 8-bit mode.
+If \*(``false\*('', Meta characters are converted into a two-character
+sequence with the character itself preceded by ESC.
+On startup, \fIxterm\fP tries to put the terminal into 7-bit mode.
+The \fBmetaSendsEscape\fP and \fBaltSendsEscape\fP resources may override this.
+The default is \*(``true.\*(''
+.IP
+Generally keyboards do not have a key labeled "Meta",
+but "Alt" keys are common, and they are conventionally used for "Meta".
+If they were synonymous, it would have been reasonable to name this
+resource "altSendsEscape", reversing its sense.
+For more background on this, see the \fBmeta\fP function in curses.
+.IP
+Note that the \fIAlt\fP key is not necessarily the same as the
+\fIMeta\fP modifier.
+\fIxmodmap\fP lists your key modifiers.
+X defines modifiers for shift, (caps) lock and control,
+as well as 5 additional modifiers which are generally used to configure
+key modifiers.
+\fIxterm\fP inspects the same information to find the modifier associated
+with either \fIMeta\fP key (left or right),
+and uses that key as the \fIMeta\fP modifier.
+It also looks for the NumLock key,
+to recognize the modifier which is associated with that.
+.IP
+If your \fIxmodmap\fP configuration
+uses the same keycodes for Alt- and Meta-keys,
+\fIxterm\fP will only see the Alt-key definitions, since those are tested
+before Meta-keys.
+NumLock is tested first.
+It is important to keep these keys distinct;
+otherwise some of \fIxterm\fP's functionality is not available.
+.TP 8
+.B "eightBitOutput (\fPclass\fB EightBitOutput\fP)"
+Specifies whether or not eight-bit characters sent from the host should be
+accepted as is or stripped when printed.
+The default is \*(``true,\*(''
+which means that they are accepted as is.
+.TP 8
+.B "eightBitSelectTypes (\fPclass\fB EightBitSelectTypes\fP)"
+Override \fIxterm\fP's default selection target list (see SELECT/PASTE) for
+selections in normal (ISO-8859-1) mode.
+The default is an empty string, which does not override anything.
+.TP 8
+.B "faceName (\fPclass\fB FaceName)"
+Specify the pattern for fonts selected from the FreeType
+library if support for that library was compiled into \fIxterm\fR.
+There is no default value.
+.IP
+If not specified,
+or if there is no match for both normal and bold fonts,
+\fIxterm\fR uses the \fBfont\fP and related resources.
+.TP 8
+.B "faceNameDoublesize (\fPclass\fB FaceNameDoublesize)"
+Specify an double-width font for cases where an application requires
+this, e.g., in CJK applications.
+There is no default value.
+.IP
+If the application uses double-wide characters and this resource is not given,
+\fIxterm\fP will use a scaled version of the font given by \fBfaceName\fP.
+.TP 8
+.B "faceSize (\fPclass\fB FaceSize)"
+Specify the pointsize for fonts selected from the FreeType
+library if support for that library was compiled into \fIxterm\fR.
+The default is \*(``14.\*(''
+On the \fBVT\ Fonts\fP menu, this corresponds to the \fIDefault\fP entry.
+.IP
+Although the default is \*(``14.\*('',
+this may not be the same as the pointsize for the default bitmap font,
+i.e., that assigned with the \fB\-fn\fP option,
+or the \fBfont\fP resource.
+For example, the "fixed" font usually has a pointsize of \*(``8.\*(''.
+If you set \fBfaceSize\fP to match the size of the bitmap font,
+then switching between bitmap and TrueType fonts via the font menu
+will give comparable sizes for the window.
+.IP
+You can specify the pointsize for TrueType fonts selected with the other
+size-related menu entries such as Medium, Huge, etc., by using one of
+the following resource values.
+If you do not specify a value,
+they default to \*(``0.0\*('',
+which causes \fIxterm\fP to use the ratio of font sizes
+from the corresponding bitmap
+font resources to obtain a TrueType pointsize.
+.IP
+If all of the \fBfaceSize\fP resources are set, then \fIxterm\fP
+will use this information to determine the next smaller/larger
+TrueType font for the
+\fIlarger-vt-font()\fP and
+\fIsmaller-vt-font()\fP actions.
+If any are not set, \fIxterm\fP will use only the areas of the bitmap fonts.
+.TP 8
+.B "faceSize1 (\fPclass\fB FaceSize1)"
+Specifies the pointsize of the first alternative font.
+.TP 8
+.B "faceSize2 (\fPclass\fB FaceSize2)"
+Specifies the pointsize of the second alternative font.
+.TP 8
+.B "faceSize3 (\fPclass\fB FaceSize3)"
+Specifies the pointsize of the third alternative font.
+.TP 8
+.B "faceSize4 (\fPclass\fB FaceSize4)"
+Specifies the pointsize of the fourth alternative font.
+.TP 8
+.B "faceSize5 (\fPclass\fB FaceSize5)"
+Specifies the pointsize of the fifth alternative font.
+.TP 8
+.B "faceSize6 (\fPclass\fB FaceSize6)"
+Specifies the pointsize of the sixth alternative font.
+.TP 8
+.B "font (\fPclass\fB Font)"
+Specifies the name of the normal font.
+The default is \*(``fixed.\*(''
+.IP
+See the discussion of the \fBlocale\fP resource,
+which describes how this font may be overridden.
+.IP
+NOTE: some resource files use patterns such as
+.RS
+*font: fixed
+.RE
+.IP
+which are overly broad, affecting both
+.RS
+xterm.vt100.font
+.RE
+.IP
+and
+.RS
+xterm.vt100.utf8fonts.font
+.RE
+.IP
+which is probably not what you intended.
+.TP 8
+.B "fastScroll (\fPclass\fB FastScroll)"
+Modifies the effect of jump scroll (\fBjumpScroll\fP)
+by suppressing screen refreshes
+for the special case when output to the screen has completely shifted
+the contents off-screen.
+For instance, \fIcat\fP'ing a large file to the screen does this.
+.TP 8
+.B "font1 (\fPclass\fB Font1)"
+Specifies the name of the first alternative font.
+.TP 8
+.B "font2 (\fPclass\fB Font2)"
+Specifies the name of the second alternative font.
+.TP 8
+.B "font3 (\fPclass\fB Font3)"
+Specifies the name of the third alternative font.
+.TP 8
+.B "font4 (\fPclass\fB Font4)"
+Specifies the name of the fourth alternative font.
+.TP 8
+.B "font5 (\fPclass\fB Font5)"
+Specifies the name of the fifth alternative font.
+.TP 8
+.B "font6 (\fPclass\fB Font6)"
+Specifies the name of the sixth alternative font.
+.TP 8
+.B "fontDoublesize (\fPclass\fB FontDoublesize)"
+Specifies whether \fIxterm\fP should attempt to use font scaling to draw
+double-sized characters.
+Some older font servers cannot do this properly, will return misleading
+font metrics.
+The default is \*(``true\*(''.
+If disabled, \fIxterm\fP will simulate double-sized characters by drawing
+normal characters with spaces between them.
+.TP 8
+.B "fontWarnings (\fPclass\fB FontWarnings)"
+Specify whether \fIxterm\fP should report an error if it fails to load a font:
+.RS
+.TP 5
+0
+Never report an error (though the X libraries may).
+.TP 5
+1
+Report an error if the font name was given as a resource setting.
+.TP 5
+2
+Always report an error on failure to load a font.
+.RE
+.TP 8
+.B "forceBoxChars (\fPclass\fB ForceBoxChars)"
+Specifies whether \fIxterm\fP should assume the normal and bold fonts
+have VT100 line-drawing characters:
+.RS
+.TP 5
+-
+The fixed-pitch ISO-8859-*-encoded fonts used by \fIxterm\fP
+normally have the VT100 line-drawing glyphs in cells 1-31.
+Other fixed-pitch fonts may be more attractive, but lack these glyphs.
+.TP
+-
+When using an ISO-10646-1 font and the \fBwideChars\fP resource is true,
+\fIxterm\fP uses the Unicode glyphs which match the VT100 line-drawing glyphs.
+.RE
+.IP
+If \*(``false\*('', \fIxterm\fP checks for missing glyphs in the font
+and makes line-drawing characters directly as needed.
+If \*(``true\*('', \fIxterm\fP assumes the font does not contain the
+line-drawing characters, and draws them directly.
+The default is \*(``false.\*(''
+.TP 8
+.B "forcePackedFont (\fPclass\fB ForcePackedFont)"
+Specifies whether \fIxterm\fP should use the maximum or minimum glyph
+width when displaying using a bitmap font.
+Use the maximum width to help with proportional fonts.
+The default is \*(``true,\*('' denoting the minimum width.
+.TP 8
+.B "foreground (\fPclass\fB Foreground)"
+Specifies the color to use for displaying text in the window.
+Setting the
+class name instead of the instance name is an easy way to have everything
+that would normally appear in the text color change color.
+The default
+is \*(``XtDefaultForeground.\*(''
+.TP 8
+.B "formatOtherKeys (\fPclass\fB FormatOtherKeys)"
+Overrides the format of the escape sequence used to report modified keys
+with the \fImodifyOtherKeys\fP resource.
+.RS
+.TP 3
+0
+send modified keys as parameters for function-key 27 (default).
+.TP 3
+1
+send modified keys as parameters for CSI\ u.
+.RE
+.TP 8
+.B "freeBoldBox (\fPclass\fB FreeBoldBox)"
+Specifies whether \fIxterm\fP should assume the bounding boxes for
+normal and bold fonts are compatible.
+If \*(``false\*('', \fIxterm\fP compares them and will reject choices of
+bold fonts that do not match the size of the normal font.
+The default is \*(``false\*('', which means that the comparison is performed.
+.TP 8
+.B "geometry (\fPclass\fB Geometry)"
+Specifies the preferred size and position of the VT102 window.
+There is no default for this resource.
+.TP 8
+.B "highlightColor (\fPclass\fB HighlightColor)"
+Specifies the color to use for the background of selected (highlighted) text.
+If not specified (i.e., matching the default foreground), reverse video is used.
+The default is \*(``XtDefaultForeground.\*(''
+.TP 8
+.B "highlightColorMode (\fPclass\fB HighlightColorMode)"
+Specifies whether \fIxterm\fP should use
+\fBhighlightTextColor\fP and \fBhighlightColor\fP
+to override the reversed foreground/background colors in a selection.
+The default is unspecified:
+at startup, \fIxterm\fP checks if those resources are set to something
+other than the default foreground and background colors.
+Setting this resource disables the check.
+.IP
+The following table shows the interaction of the highlighting
+resources, abbreviated as shown to fit in this page:
+.RS
+.TP 3
+HCM
+highlightColorMode
+.TP 3
+HR
+highlightReverse
+.TP 3
+HBG
+highlightColor
+.TP 3
+HFG
+highlightTextColor
+.RE
+.IP
+.TS
+l l l l l
+_ _ _ _ _
+l l l l l.
+\fIHCM\fR      \fIHR\fR        \fIHBG\fR       \fIHFG\fR       \fIHighlight\fP
+false  false   default default bg/fg
+false  false   default set     bg/fg
+false  false   set     default fg/HBG
+false  false   set     set     fg/HBG
+=
+false  true    default default bg/fg
+false  true    default set     bg/fg
+false  true    set     default fg/HBG
+false  true    set     set     fg/HBG
+=
+true   false   default default bg/fg
+true   false   default set     HFG/fg
+true   false   set     default bg/HBG
+true   false   set     set     HFG/HBG
+=
+true   true    default default fg/fg (useless)
+true   true    default set     HFG/fg
+true   true    set     default fg/HBG
+true   true    set     set     HFG/HBG
+=
+default        false   default default bg/fg
+default        false   default set     bg/fg
+default        false   set     default fg/HBG
+default        false   set     set     HFG/HBG
+=
+default        true    default default bg/fg
+default        true    default set     bg/fg
+default        true    set     default fg/HBG
+default        true    set     set     HFG/HBG
+=
+.TE
+.TP 8
+.B "highlightReverse (\fPclass\fB HighlightReverse)"
+Specifies whether \fIxterm\fP should reverse the selection foreground
+and background colors when selecting text with reverse-video attribute.
+This applies only to
+the \fBhighlightColor\fP and \fBhighlightTextColor\fP resources,
+e.g., to match the color scheme of \fIxwsh\fP.
+If \*(``true\*('', \fIxterm\fP reverses the colors,
+If \*(``false\*('', \fIxterm\fP does not reverse colors,
+The default is \*(``true.\*(''
+.TP 8
+.B "highlightSelection (\fPclass\fB HighlightSelection)"
+If \*(``false\*('', selecting with the mouse highlights all positions on the screen
+between the beginning of the selection and the current position.
+If \*(``true\*('', \fIxterm\fP highlights only the positions that contain text that
+can be selected.
+The default is \*(``false.\*(''
+.IP
+Depending on the way your applications write to the screen, there may
+be trailing blanks on a line.
+\fIXterm\fP stores data as it is shown on the screen.
+Erasing the display changes the internal state of each cell
+so it is not considered a blank for the purpose of selection.
+Blanks written since the last erase are selectable.
+If you do not wish to have trailing blanks in a selection,
+use the \fBtrimSelection\fP resource.
+.TP 8
+.B "highlightTextColor (\fPclass\fB HighlightTextColor)"
+Specifies the color to use for the foreground of selected (highlighted) text.
+If not specified (i.e., matching the default background), reverse video is used.
+The default is \*(``XtDefaultBackground.\*(''
+.TP 8
+.B "hpLowerleftBugCompat (\fPclass\fB HpLowerleftBugCompat)"
+Specifies whether to work around a bug in HP's \fIxdb\fP,
+which ignores termcap and always sends
+ESC F to move to the lower left corner.
+\*(``true\*('' causes \fIxterm\fP to interpret ESC F as a request to move to the
+lower left corner of the screen.
+The default is \*(``false.\*(''
+.TP 8
+.B "i18nSelections (\fPclass\fB I18nSelections)"
+If false, \fIxterm\fP will not request the targets
+.B COMPOUND_TEXT
+or
+.BR TEXT .
+The default is \*(``true.\*('' It may be set to false in order to work around
+ICCCM violations by other X clients.
+.TP 8
+.B "iconBorderColor (\fPclass\fB BorderColor)"
+Specifies the border color for the active icon window if this feature
+is compiled into \fIxterm\fR.
+Not all window managers will make the icon
+border visible.
+.TP 8
+.B "iconBorderWidth (\fPclass\fB BorderWidth)"
+Specifies the border width for the active icon window if this feature
+is compiled into \fIxterm\fR.
+The default is 2.
+Not all window managers will make the border visible.
+.TP 8
+.B "iconFont (\fPclass\fB IconFont)"
+Specifies the font for the miniature active icon window, if this feature
+is compiled into \fIxterm\fR.
+The default is "nil2".
+.TP 8
+.B "initialFont (\fPclass\fB InitialFont)"
+Specifies which of the VT100 fonts to use initially.
+Values are the same as for the \fIset-vt-font\fP action.
+The default is \*(``d\*('', i.e., "default".
+.TP 8
+.B "inputMethod (\fPclass\fB XtCInputMethod)"
+Tells \fIxterm\fP which type of input method to use.
+There is no default method.
+.TP 8
+.B "internalBorder (\fPclass\fB BorderWidth)"
+Specifies the number of pixels between the characters and the window border.
+The default is 2.
+.TP 8
+.B "italicULMode (\fPclass\fB ColorAttrMode)"
+Specifies whether characters with the underline attribute should be displayed
+in an italic font or as underlined characters.
+It is implemented only for TrueType fonts.
+.TP 8
+.B "jumpScroll (\fPclass\fB JumpScroll)"
+Specifies whether or not jump scroll should be used.
+This corresponds to the VT102 DECSCLM private mode.
+The default is \*(``true.\*(''
+See \fBfastScroll\fP for a variation.
+.TP 8
+.B "keepSelection (\fPclass\fB KeepSelection)"
+Specifies whether \fIxterm\fR will keep the selection even after the
+selected area was touched by some output to the terminal.
+The default is \*(``true\*(''.
+.TP 8
+.B "keyboardDialect (\fPclass\fB KeyboardDialect)"
+Specifies the initial keyboard dialect, as well as the default value when
+the terminal is reset.
+The value given is the same as the final character in the control sequences
+which change character sets.
+The default is \*(``B\*('', which corresponds to US ASCII.
+.TP 8
+.B "\fIname\fP\fBKeymap\fP (class\fB \fIName\fP\fBKeymap\fP)"
+See the discussion of the \fBkeymap()\fP action.
+.TP 8
+.B "limitResize (\fPclass\fB LimitResize)"
+Limits resizing of the screen via control sequence to a given multiple of
+the display dimensions.
+The default is \*(``1\*(''.
+.TP 8
+.B "locale (\fPclass\fB Locale)"
+Specifies how to use \fIluit\fR, an encoding converter between UTF-8
+and locale encodings.
+The resource value (ignoring case) may be:
+.RS
+.TP 4
+.I true
+\fIxterm\fR will use the
+encoding specified by the users' LC_CTYPE locale (i.e., LC_ALL,
+LC_CTYPE, or LANG variables) as far as possible.
+This is realized
+by always enabling UTF-8 mode and invoking \fIluit\fR in non-UTF-8
+locales.
+.TP
+.I medium
+\fIxterm\fR will follow users'
+LC_CTYPE locale only for UTF-8, east Asian, and Thai locales,
+where the encodings were not supported by conventional 8bit mode
+with changing fonts.
+For other locales, \fIxterm\fR will use conventional 8bit mode.
+.TP
+.I checkfont
+If mini-luit is compiled-in, \fIxterm\fR will check if a Unicode font has
+been specified.
+If so, it checks if the character encoding for the
+current locale is POSIX, Latin-1 or Latin-9, uses the appropriate
+mapping to support those with the Unicode font.
+For other encodings, \fIxterm\fR assumes that UTF-8 encoding is required.
+.TP
+.I false
+\fIxterm\fR will use conventional 8bit mode
+or UTF-8 mode according to \fButf8\fR resource or \fB\-u8\fP option.
+.RE
+.IP
+Any other value, e.g., \*(``UTF-8\*('' or \*(``ISO8859-2\*('',
+is assumed to be an encoding name;
+\fIluit\fR will be invoked to support the encoding.
+The actual list of supported encodings depends on \fIluit\fR.
+The default is \*(``medium\*(''.
+.IP
+Regardless of your locale and encoding,
+you need an ISO-10646-1 font to display the result.
+Your configuration may not include this font,
+or locale-support by \fIxterm\fP may not be needed.
+At startup, \fIxterm\fP uses a mechanism equivalent to
+the \fBload-vt-fonts(utf8Fonts,\ Utf8Fonts)\fP action
+to load font name subresources of the VT100 widget.
+That is,
+resource patterns such as "\fB*vt100.utf8Fonts.font\fP" will be loaded,
+and (if this resource is enabled), override the normal fonts.
+If no subresources are found,
+the normal fonts such as "\fB*vt100.font\fP", etc., are used.
+The resource files distributed with \fIxterm\fP use ISO-10646-1 fonts,
+but do not rely on them unless you are using the locale mechanism.
+.TP 8
+.B "localeFilter (\fPclass\fB LocaleFilter)"
+Specifies the file name for the encoding converter from/to locale
+encodings and UTF-8 which is used with the \fB\-lc\fR option or \fBlocale\fR resource.
+The help message shown by \*(``xterm \-help\*('' lists the default value,
+which depends on your system configuration.
+.IP
+If the encoding converter requires command-line parameters,
+you should put those within a shell script to execute the converter,
+and set this resource to point to the shell script.
+.TP 8
+.B "loginShell (\fPclass\fB LoginShell)"
+Specifies whether or not the shell to be run in the window should be started
+as a login shell.
+The default is \*(``false.\*(''
+.TP 8
+.B "marginBell (\fPclass\fB MarginBell)"
+Specifies whether or not the bell should be rung when the user types near the
+right margin.
+The default is \*(``false.\*(''
+.TP 8
+.B "metaSendsEscape (\fPclass\fB MetaSendsEscape\fP)"
+If \*(``true\*('', Meta characters
+(a character combined with the \fIMeta\fP modifier key)
+are converted into a two-character
+sequence with the character itself preceded by ESC.
+This applies as well to function key control sequences, unless \fIxterm\fP
+sees that \fBMeta\fP is used in your key translations.
+If \*(``false\*('', Meta characters input from the keyboard are handled according
+to the \fBeightBitInput\fP resource.
+The default is \*(``false.\*(''
+.TP 8
+.B "mkSamplePass (\fPclass\fB MkSamplePass)"
+If \fBmkSampleSize\fP is nonzero,
+and \fBmkWidth\fP (and \fBcjkWidth\fP) are false,
+on startup \fIxterm\fP compares its built-in tables to the system's
+wide character width data to decide if it will use the system's data.
+It tests the first \fBmkSampleSize\fP character values,
+and allows up to \fBmkSamplePass\fP mismatches before the test fails.
+The default (for the allowed number of mismatches) is 256.
+.TP 8
+.B "mkSampleSize (\fPclass\fB MkSampleSize)"
+With \fBmkSamplePass\fP, this specifies a startup test used for
+initializing wide character width calculations.
+The default (number of characters to check) is 1024.
+.TP 8
+.B "mkWidth (\fPclass\fB MkWidth)"
+Specifies whether \fIxterm\fP should use a built-in version of the wide
+character width calculation.
+See also the \fBcjkWidth\fP resource which can override this.
+The default is \*(``false.\*(''
+.IP
+Here is a summary of the resources which control the choice of
+wide character width calculation:
+.TS
+l l l
+_ _ _
+l l l.
+\fIcjkWidth\fR \fImkWidth\fR   \fIAction\fP
+false  false   use system tables subject to \fBmkSamplePass\fP
+false  true    use built-in tables
+true   false   use built-in CJK tables
+true   true    use built-in CJK tables
+.TE
+.TP 8
+.B "modifyCursorKeys (\fPclass\fB ModifyCursorKeys\fP)"
+Tells how to handle the special case where
+Control-, Shift-, Alt- or Meta-modifiers are used to add a parameter to
+the escape sequence returned by a cursor-key.
+The default is \*(``2\*('':
+.IP
+Set it to \-1 to disable it.
+.br
+Set it to 0 to use the old/obsolete behavior.
+.br
+Set it to 1 to prefix modified sequences with CSI.
+.br
+Set it to 2 to force the modifier to be the second parameter if it would
+otherwise be the first.
+.br
+Set it to 3 to mark the sequence with a \*(``>\*('' to hint that it is private.
+.TP 8
+.B "modifyFunctionKeys (\fPclass\fB ModifyFunctionKeys\fP)"
+Tells how to handle the special case where
+Control-, Shift-, Alt- or Meta-modifiers are used to add a parameter to
+the escape sequence returned by a (numbered) function-key.
+The default is \*(``2\*(''.
+The resource values are similar to \fBmodifyCursorKeys\fP:
+.IP
+Set it to \-1 to permit the user to use shift- and control-modifiers
+to construct function-key strings using the normal encoding scheme.
+.br
+Set it to 0 to use the old/obsolete behavior.
+.br
+Set it to 1 to prefix modified sequences with CSI.
+.br
+Set it to 2 to force the modifier to be the second parameter if it would
+otherwise be the first.
+.br
+Set it to 3 to mark the sequence with a \*(``>\*('' to hint that it is private.
+.IP
+If \fBmodifyFunctionKeys\fP is zero,
+\fIxterm\fP uses Control- and Shift-modifiers to allow the user to
+construct numbered function-keys beyond the set provided by the
+keyboard:
+.RS
+.TP 5
+Control
+adds the value given by the \fBctrlFKeys\fP resource.
+.TP 5
+Shift
+adds twice the value given by the \fBctrlFKeys\fP resource.
+.TP 5
+Control/Shift
+adds three times the value given by the \fBctrlFKeys\fP resource.
+.RE
+.IP
+As a special case,
+legacy (when \fBoldFunctionKeys\fP is true)
+or vt220 (when \fBsunKeyboard\fP is true) keyboards interpret only the
+Control-modifier when constructing numbered function-keys.
+This is done to provide compatible keyboards for DEC VT220 and related
+terminals that implement user-defined keys (UDK).
+.TP 8
+.B "modifyOtherKeys (\fPclass\fB ModifyOtherKeys\fP)"
+Like \fBmodifyCursorKeys\fP, tells \fIxterm\fP to construct an
+escape sequence for other keys (such as "2") when modified by
+Control-, Alt- or Meta-modifiers.
+This feature does not apply to function keys and well-defined
+keys such as ESC or the control keys.
+The default is \*(``0\*('':
+.RS
+.TP 5
+0
+disables this feature.
+.TP 5
+1
+enables this feature for keys except for those with
+well-known behavior, e.g., Tab, Backarrow and some special
+control character cases, e.g., Control-Space to make a NUL.
+.TP 5
+2
+enables this feature for keys including the exceptions listed.
+.RE
+.TP 8
+.B "multiClickTime (\fPclass\fB MultiClickTime)"
+Specifies the maximum time in milliseconds between multi-click select
+events.
+The default is 250 milliseconds.
+.TP 8
+.B "multiScroll (\fPclass\fB MultiScroll)"
+Specifies whether or not scrolling should be done asynchronously.
+The default is \*(``false.\*(''
+.TP 8
+.B "nMarginBell (\fPclass\fB Column)"
+Specifies the number of characters from the right margin at which the margin
+bell should be rung, when enabled by the \fBmarginBell\fP resource.
+The default is 10.
+.TP 8
+.B "numLock (\fPclass\fB NumLock)"
+If \*(``true\*('', \fIxterm\fR checks if NumLock is used as a modifier (see \fIxmodmap\fP(__mansuffix__)).
+If so, this modifier is used to simplify the logic when implementing special
+NumLock for the \fBsunKeyboard\fP resource.
+Also (when \fBsunKeyboard\fP is false), similar logic is used to find the
+modifier associated with the left and right Alt keys.
+The default is \*(``true.\*(''
+.TP 8
+.B "oldXtermFKeys (\fPclass\fB OldXtermFKeys)"
+If \*(``true\*('', \fIxterm\fR will use old-style control sequences for function keys F1 to F4,
+for compatibility with X Consortium \fIxterm\fR.
+Otherwise, it uses the VT100-style
+codes for PF1 to PF4.
+The default is \*(``false.\*(''
+.TP 8
+.B "on2Clicks (\fPclass\fB On2Clicks)"
+.TP
+.B "on3Clicks (\fPclass\fB On3Clicks)"
+.TP
+.B "on4Clicks (\fPclass\fB On4Clicks)"
+.TP
+.B "on5Clicks (\fPclass\fB On5Clicks)"
+Specify selection behavior in response to multiple mouse clicks.
+A single mouse click is always interpreted as described in
+the \fBSELECTION\fP section (see \fBPOINTER USAGE\fP).
+Multiple mouse clicks (using the button which activates the \fBselect-start\fP
+action) are interpreted according to the resource values of
+\fBon2Clicks\fP, etc.
+The resource value can be one of these:
+.RS
+.TP 3
+word
+Select a \*(``word\*('' as determined by the \fBcharClass\fP resource.
+See the \fBCHARACTER CLASSES\fP section.
+.TP
+line
+Select a line (counting wrapping).
+.TP
+group
+Select a group of adjacent lines (counting wrapping).
+The selection stops on a blank line,
+and does not extend outside the current page.
+.TP
+page
+Select all visible lines, i.e., the page.
+.TP
+all
+Select all lines, i.e., including the saved lines.
+.TP
+regex
+Select a \*(``word\*('' as determined by the regular expression which
+follows in the resource value.
+.TP
+none
+No selection action is associated with this resource.
+\fIxterm\fP interprets it as the end of the list.
+For example, you may use it to disable triple (and higher) clicking
+by setting \fBon3Clicks\fP to \*(``none\*(''.
+.RE
+.IP
+The default values for \fBon2Clicks\fP and \fBon3Clicks\fP are
+\*(``word\*('' and \*(``line\*('', respectively.
+There is no default value for \fBon4Clicks\fP or \fBon5Clicks\fP,
+making those inactive.
+On startup, \fIxterm\fP determines the maximum number of clicks
+by the \fBon\fP\fIX\fP\fBClicks\fP resource values which are set.
+.TP 8
+.B "openIm (\fPclass\fB XtCOpenIm)"
+Tells \fIxterm\fP whether to open the input method at startup.
+The default is \*(``true\*(''.
+.TP 8
+.B "pointerColor (\fPclass\fB PointerColor)"
+Specifies the foreground color of the pointer.
+The default is
+\*(``XtDefaultForeground.\*(''
+.TP 8
+.B "pointerColorBackground (\fPclass\fB PointerColorBackground)"
+Specifies the background color of the pointer.
+The default is
+\*(``XtDefaultBackground.\*(''
+.TP 8
+.B "pointerMode (\fPclass\fB PointerMode)"
+Specifies when the pointer may be hidden as the user types.
+It will be redisplayed if the user moves the mouse,
+or clicks one of its buttons.
+.RS
+.TP 3
+0
+never
+.TP 3
+1
+the application running in \fIxterm\fP has not activated mouse mode.
+This is the default.
+.TP 3
+2
+always.
+.RE
+.TP 8
+.B "pointerShape (\fPclass\fB Cursor)"
+Specifies the name of the shape of the pointer.
+The default is \*(``xterm.\*(''
+.TP 8
+.B "popOnBell (\fPclass\fB PopOnBell)"
+Specifies whether the window would be raised when Control-G is received.
+The default is \*(``false.\*(''
+.IP
+If the window is iconified, this has no effect.
+However, the \fBzIconBeep\fP resource provides you with the ability to
+see which iconified windows have sounded a bell.
+.TP 8
+.B "preeditType (\fPclass\fB XtCPreeditType)"
+Tells \fIxterm\fP which types of preedit (preconversion) string to display.
+The default is \*(``OverTheSpot,Root\*(''.
+.TP 8
+.B "printAttributes (\fPclass\fB PrintAttributes)"
+Specifies whether to print graphic attributes along with the text.
+A real DEC VTxxx terminal will print the underline, highlighting codes
+but your printer may not handle these.
+A \*(``0\*('' disables the attributes.
+A \*(``1\*('' prints the normal set of attributes (bold, underline, inverse and blink)
+as VT100-style control sequences.
+A \*(``2\*('' prints ANSI color attributes as well.
+The default is \*(``1.\*(''
+.TP 8
+.B "printerAutoClose (\fPclass\fB PrinterAutoClose)"
+If \*(``true\*('', \fIxterm\fR will close the printer (a pipe) when the application switches
+the printer offline with a Media Copy command.
+The default is \*(``false.\*(''
+.TP 8
+.B "printerCommand (\fPclass\fB PrinterCommand)"
+Specifies a shell command to which
+.I xterm
+will open a pipe when the first
+MC (Media Copy) command is initiated.
+The default is a blank string.
+If the resource value is given as a blank string, the printer is disabled.
+.TP 8
+.B "printerControlMode (\fPclass\fB PrinterControlMode)"
+Specifies the printer control mode.
+A \*(``1\*('' selects autoprint mode, which causes
+.I xterm
+to print a line from the screen when you move the cursor off that
+line with a line feed, form feed or vertical tab character, or an
+autowrap occurs.
+Autoprint mode is overridden by printer controller mode (a \*(``2\*(''),
+which causes all of the output to be directed to the printer.
+The default is \*(``0.\*(''
+.TP 8
+.B "printerExtent (\fPclass\fB PrinterExtent)"
+Controls whether a print page function will print the entire page (true), or
+only the the portion within the scrolling margins (false).
+The default is \*(``false.\*(''
+.TP 8
+.B "printerFormFeed (\fPclass\fB PrinterFormFeed)"
+Controls whether a form feed is sent to the printer at the end of a print
+page function.
+The default is \*(``false.\*(''
+.TP 8
+.B "printerNewLine (\fPclass\fB PrinterNewLine)"
+Controls whether a newline is sent to the printer at the end of a print
+page function.
+The default is \*(``true.\*(''
+.TP 8
+.B "quietGrab (\fPclass\fB QuietGrab)"
+Controls whether the cursor is repainted
+when \fINotifyGrab\fP and \fINotifyUngrab\fP
+event types are received during change of focus.
+The default is \*(``false.\*(''
+.TP 8
+.B "renderFont (\fPclass\fB RenderFont)"
+If \fIxterm\fR is built with the Xft library,
+this controls whether the \fBfaceName\fR resource is used.
+The default is \*(``default.\*(''
+.IP
+The resource values are strings, evaluated as booleans after startup.
+.RS
+.TP 5
+false
+.br
+disable the feature and use the normal (bitmap) font.
+.TP 5
+true
+.br
+startup using the TrueType font specified by the \fBfaceName\fP and
+\fBfaceSize\fP resource settings.
+If there is no value for \fBfaceName\fP, disable the feature and use
+the normal (bitmap) font.
+.IP
+After startup, you can still switch to/from the bitmap font using the
+\*(``TrueType Fonts\*('' menu entry.
+.TP 5
+default
+.br
+startup using the normal (bitmap) font,
+but enable the \*(``TrueType Fonts\*(''
+menu entry to allow runtime switching to/from TrueType fonts.
+.IP
+If there is no \fBfaceName\fP resource set,
+then runtime switching to TrueType fonts is disabled.
+\fIXterm\fP has a separate  compiled-in value for \fBfaceName\fP
+for the special case where \fBrenderFont\fP is \*(``default\*(''.
+That is normally \*(``mono\*(''.
+.RE
+.TP 8
+.B "resizeGravity (\fPclass\fB ResizeGravity)"
+Affects the behavior when the window is resized to be taller or
+shorter.
+\fBNorthWest\fP
+specifies that the top line of text on the screen stay fixed.
+If the window
+is made shorter, lines are dropped from the bottom; if the window is
+made taller, blank lines are added at the bottom.
+This is compatible
+with the behavior in R4.
+\fBSouthWest\fP (the default) specifies that
+the bottom line of text on the screen stay fixed.
+If the window is
+made taller, additional saved lines will be scrolled down onto the
+screen; if the window is made shorter, lines will be scrolled off the
+top of the screen, and the top saved lines will be dropped.
+.TP 8
+.B "retryInputMethod (\fPclass\fB XtCRetryInputMethod)"
+Tells \fIxterm\fP how many times to retry,
+in case the input-method server is not responding.
+This is a different issue than unsupported preedit type, etc.
+You may encounter retries if your X configuration (and its libraries)
+are missing pieces.
+Setting this resource to zero ``0'' will cancel the retrying.
+The default is ``3''.
+.TP 8
+.B "reverseVideo (\fPclass\fB ReverseVideo)"
+Specifies whether or not reverse video should be simulated.
+The default is
+\*(``false.\*(''
+.IP
+There are several aspects to reverse video in \fIxterm\fP:
+.RS
+.bP
+The command-line \fB\-rv\fP option tells the X libraries to reverse
+the foreground and background colors.
+\fIXterm\fP's command-line options set resource values.
+In particular, the X Toolkit sets the \fBreverseVideo\fP resource
+when the \fB\-rv\fP option is used.
+.bP
+If the user has also used command-line options \fB\-fg\fP or \fB\-bg\fP 
+to set the foreground and background colors,
+\fIxterm\fP does not see these options directly.
+Instead,
+it examines the resource values to reconstruct the command-line options,
+and determine which of the colors is the user's intended foreground, etc.
+Their actual values are irrelevant to the reverse video function;
+some users prefer the X defaults (black text on a white background),
+others prefer white text on a black background.
+.bP
+After startup,
+the user can toggle the "Enable Reverse Video" menu entry.
+This exchanges the current foreground and background colors
+of the VT100 widget,
+and repaints the screen.
+Because of the X resource hierarchy,
+the \fBreverseVideo\fP resource applies to more than the VT100 widget.
+.RE
+.IP
+Programs running in an \fIxterm\fP can also use control sequences
+to enable the VT100 reverse video mode.
+These are independent of the \fIreverseVideo\fP resource and the menu entry.
+\fIXterm\fP exchanges the current foreground and background colors
+when drawing text affected by these control sequences.
+.IP
+Other control sequences can alter the foreground and background colors
+which are used:
+.RS
+.bP
+Programs can also use the ANSI color control sequences to set the
+foreground and background colors.
+.bP
+Extensions to the ANSI color controls (such as 16-, 88- or 256-colors)
+are treated similarly to the ANSI control.
+.bP
+Using other control sequences (the "\fIdynamic colors\fR" feature),
+a program can change the foreground and background colors.
+.RE
+.TP 8
+.B "reverseWrap (\fPclass\fB ReverseWrap)"
+Specifies whether or not reverse-wraparound should be enabled.
+This corresponds to \fIxterm\fP's private mode 45.
+The default is
+\*(``false.\*(''
+.TP 8
+.B "rightScrollBar (\fPclass\fB RightScrollBar)"
+Specifies whether or not the scrollbar should be displayed on the right
+rather than the left.
+The default is \*(``false.\*(''
+.TP 8
+.B "saveLines (\fPclass\fB SaveLines)"
+Specifies the number of lines to save beyond the top of the screen when a
+scrollbar is turned on.
+The default is 64.
+.TP 8
+.B "scrollBar (\fPclass\fB ScrollBar)"
+Specifies whether or not the scrollbar should be displayed.
+The default is
+\*(``false.\*(''
+.TP 8
+.B "scrollBarBorder (\fPclass\fB ScrollBarBorder)"
+Specifies the width of the scrollbar border.
+Note that this is drawn to overlap the border of the \fIxterm\fP window.
+Modifying the scrollbar's border affects only the line between the VT100
+widget and the scrollbar.
+The default value is 1.
+.TP 8
+.B "scrollKey (\fPclass\fB ScrollCond)"
+Specifies whether or not pressing a key should automatically cause the
+scrollbar to go to the bottom of the scrolling region.
+This corresponds to \fIxterm\fP's private mode 1011.
+The default is
+\*(``false.\*(''
+.TP 8
+.B "scrollLines (\fPclass\fB ScrollLines)"
+Specifies the number of lines that the \fIscroll-back\fP and
+\fIscroll-forw\fP actions should use as a default.
+The default value is 1.
+.TP 8
+.B "scrollTtyOutput (\fPclass\fB ScrollCond)"
+Specifies whether or not output to the terminal should automatically cause
+the scrollbar to go to the bottom of the scrolling region.
+The default is \*(``true.\*(''
+.TP
+.B "selectToClipboard (\fPclass\fB SelectToClipboard)"
+Tells \fIxterm\fP whether to use the PRIMARY or CLIPBOARD for
+SELECT tokens in the selection mechanism.
+The \fBset-select\fP action can change this at runtime,
+allowing the user to work with programs that handle only one of these
+mechanisms.
+The default is \*(``false\*('', which tells it to use PRIMARY.
+.TP 8
+.B "shiftFonts (\fPclass\fB ShiftFonts)"
+Specifies whether to enable the actions
+\fBlarger-vt-font()\fP and
+\fBsmaller-vt-font()\fP, which are normally bound to
+the shifted KP_Add and KP_Subtract.
+The default is \*(``true.\*(''
+.TP 8
+.B "showBlinkAsBold (\fPclass\fB ShowBlinkAsBold)"
+Tells \fIxterm\fP whether to display text with blink-attribute the same
+as bold.
+If \fIxterm\fP has not been configured to support blinking text,
+the default is \*(``true.\*('', which corresponds to older versions of \fIxterm\fP,
+otherwise the default is \*(``false.\*(''
+.TP 8
+.B "showMissingGlyphs (\fPclass\fB ShowMissingGlyphs)"
+Tells \fIxterm\fP whether to display a box outlining places where
+a character has been used that the font does not represent.
+The default is \*(``false.\*(''
+.TP 8
+.B "showWrapMarks (\fPclass\fB ShowWrapMarks)"
+For debugging \fIxterm\fP and applications that may manipulate the
+wrapped-line flag by writing text at the right margin,
+show a mark on the right inner-border of the window.
+The mark shows which lines have the flag set.
+.TP 8
+.B "signalInhibit (\fPclass\fB SignalInhibit)"
+Specifies whether or not the entries in the \*(``Main Options\*('' menu for sending
+signals to \fIxterm\fP should be disallowed.
+The default is \*(``false.\*(''
+.TP 8
+.B "tekGeometry (\fPclass\fB Geometry)"
+Specifies the preferred size and position of the Tektronix window.
+There is no default for this resource.
+.TP 8
+.B "tekInhibit (\fPclass\fB TekInhibit)"
+Specifies whether or not
+the escape sequence to enter
+Tektronix mode should be ignored.
+The default is
+\*(``false.\*(''
+.TP 8
+.B "tekSmall (\fPclass\fB TekSmall)"
+Specifies whether or not the Tektronix mode window should start in its smallest
+size if no explicit geometry is given.
+This is useful when running \fIxterm\fP
+on displays with small screens.
+The default is \*(``false.\*(''
+.TP 8
+.B "tekStartup (\fPclass\fB TekStartup)"
+Specifies whether or not \fIxterm\fP should start up in Tektronix mode.
+The default is \*(``false.\*(''
+.TP 8
+.B "tiXtraScroll (\fPclass\fB TiXtraScroll)"
+Specifies whether \fIxterm\fP should scroll to a new page when processing
+the \fIti\fP termcap entry, i.e., the private modes 47, 1047 or 1049.
+This is only in effect if \fBtiteInhibit\fP is \*(``true\*('',
+because the intent of this option is to provide a picture of the full-screen
+application's display on the scrollback without wiping out the text that
+would be shown before the application was initialized.
+The default for this resource is \*(``false.\*(''
+.TP 8
+.B "titeInhibit (\fPclass\fB TiteInhibit)"
+Specifies whether or not \fIxterm\fP should remove \fIti\fP and \fIte\fP
+termcap entries (used to switch between alternate screens on startup of many
+screen-oriented programs) from the TERMCAP string.
+If set,
+\fIxterm\fP also ignores the escape sequence to switch to the
+alternate screen.
+\fIXterm\fP supports terminfo in a different way, supporting composite control
+sequences (also known as private modes) 1047, 1048 and 1049 which have the same
+effect as the original 47 control sequence.
+The default for this resource is \*(``false.\*(''
+.TP 8
+.B "titleModes (\fPclass\fB TitleModes)"
+Tells \fIxterm\fP whether to accept or return
+window- and icon-labels in ISO-8859-1
+(the default) or UTF-8.
+Either can be encoded in hexadecimal.
+The default for this resource is \*(``0.\*(''
+.IP
+Each bit (bit "0" is 1, bit "1" is 2, etc) corresponds to one of the
+parameters set by the title modes control sequence:
+.RS
+.TP 5
+0
+Set window/icon labels using hexadecimal
+.TP 5
+1
+Query window/icon labels using hexadecimal
+.TP 5
+2
+Set window/icon labels using UTF-8 (overrides \fButf8Titles\fP resource).
+.TP 5
+3
+Query window/icon labels using UTF-8
+.RE
+.TP 8
+.B "translations (\fPclass\fB Translations)"
+Specifies the key and button bindings for menus, selections, \*(``programmed
+strings,\*('' etc.
+The \fBtranslations\fP resource,
+which provides much of \fIxterm\fP's configurability,
+is a feature of the X Toolkit Intrinsics library (Xt).
+See the \fBACTIONS\fP section.
+.TP 8
+.B "trimSelection (\fPclass\fB TrimSelection)"
+If you set \fBhighlightSelection\fP,
+you can see the text which is selected, including any trailing spaces.
+Clearing the screen (or a line) resets it to a state containing no spaces.
+Some lines may contain trailing spaces when an application writes them to
+the screen.
+However, you may not wish to paste lines with trailing spaces.
+If this resource is true, \fIxterm\fP will trim trailing spaces from
+text which is selected.
+It does not affect spaces which result in a wrapped line, nor will it
+trim the trailing newline from your selection.
+The default is \*(``false.\*(''
+.TP 8
+.B "underLine (\fPclass\fB UnderLine)"
+This specifies whether or not text with the underline attribute should be
+underlined.
+It may be desirable to disable underlining when color is being
+used for the underline attribute.
+The default is \*(``true.\*(''
+.TP 8
+.B "useClipping (\fPclass\fB UseClipping)"
+Tell \fIxterm\fP whether to use clipping to keep
+from producing dots outside the text drawing area.
+Originally used to work around for overstriking effects,
+this is also needed to work with some incorrectly-sized fonts.
+The default is \*(``true.\*(''
+.TP 8
+.B "utf8 (\fPclass\fB Utf8)"
+This specifies whether \fIxterm\fP will run in UTF-8 mode.
+If you set this resource, \fIxterm\fP also sets the \fBwideChars\fP resource as a side-effect.
+The resource is an integer, expected to range from 0 to 3:
+.RS
+.TP 3
+0
+UTF-8 mode is initially off.
+The command-line option \fB+u8\fP sets the resource to this value.
+Escape sequences for turning UTF-8 mode on/off are allowed.
+.TP
+1
+UTF-8 mode is initially on.
+Escape sequences for turning UTF-8 mode on/off are allowed.
+.TP
+2
+The command-line option \fB\-u8\fP sets the resource to this value.
+Escape sequences for turning UTF-8 mode on/off are ignored.
+.TP
+3
+This is the default value of the resource.
+It is changed during initialization depending on
+whether the \fBlocale\fP resource was set, to 0 or 2.
+See the \fBlocale\fR resource for additional discussion of non-UTF-8 locales.
+.RE
+.IP
+If you want to set the value of \fButf8\fP, it should be in this range.
+Other nonzero values are treated the same as \*(``1\*('',
+i.e., UTF-8 mode is initially on, and
+escape sequences for turning UTF-8 mode on/off are allowed.
+.TP 8
+.B "utf8Fonts (\fPclass\fB Utf8Fonts)"
+See the discussion of the \fBlocale\fP resource.
+.TP 8
+.B "utf8Latin1 (\fPclass\fB Utf8Latin1)"
+If true,
+allow an ISO-8859-1 \fInormal\fP
+font to be combined with an ISO-10646 font if the latter is given
+via the \fB\-fw\fP option or its corresponding resource value.
+The default is \*(``false.\*(''
+.TP 8
+.B "utf8SelectTypes (\fPclass\fB Utf8SelectTypes)"
+Override \fIxterm\fP's default selection target list (see SELECT/PASTE) for
+selections in wide-character (UTF-8) mode.
+The default is an empty string, which does not override anything.
+.TP 8
+.B "utf8Title (\fPclass\fB Utf8Title)"
+Applications can set \fIxterm\fP's title by writing a control sequence.
+Normally this control sequence follows the VT220 convention,
+which encodes the string in ISO-8859-1 and
+allows for an 8-bit string terminator.
+If \fIxterm\fP is started in a UTF-8 locale,
+it translates the ISO-8859-1 string to UTF-8 to work with the X libraries
+which assume the string is UTF-8.
+.IP
+However, some users may wish to write a title string encoded in UTF-8.
+The window manager is responsible for drawing window titles.
+Some window managers (not all) support UTF-8 encoding of window titles.
+Set this resource to \*(``true\*('' to allow UTF-8 encoded title strings.
+That cancels the translation to UTF-8,
+allowing UTF-8 strings to be displayed as is.
+.IP
+This feature is available as a menu entry, since it is related to
+the particular applications you are running within \fIxterm\fP.
+You can also use a control sequence (see the discussion of "Title Modes"
+in the control sequences document), to set an equivalent flag.
+The \fBtitleModes\fP resource sets the same value,
+which overrides this resource.
+.IP
+The default is \*(``false.\*(''
+.TP 8
+.B "veryBoldColors (\fPclass\fB VeryBoldColors)"
+Specifies whether to combine video attributes with colors specified by
+\fBcolorBD\fR, \fBcolorBL\fR, \fBcolorRV\fR and \fBcolorUL\fR.
+The resource value is the sum of values for each attribute:
+.RS 10
+.nf
+1 for reverse,
+2 for underline,
+4 for bold and
+8 for blink.
+.fi
+.RE
+.IP
+The default is \*(``0.\*(''
+.TP 8
+.B "visualBell (\fPclass\fB VisualBell)"
+Specifies whether or not a visible bell (i.e., flashing) should be used instead
+of an audible bell when Control-G is received.
+The default is \*(``false.\*(''
+.TP 8
+.B "visualBellDelay (\fPclass\fB VisualBellDelay)"
+Number of milliseconds to delay when displaying a visual bell.
+Default is 100.
+If set to zero, no visual bell is displayed.
+This is useful for very slow displays, e.g., an LCD display on a laptop.
+.TP 8
+.B "vt100Graphics (\fPclass\fB VT100Graphics)"
+This specifies whether \fIxterm\fP will interpret VT100 graphic character
+escape sequences while in UTF-8 mode.
+The default is \*(``true\*('', to provide support for various legacy applications.
+.TP 8
+.B "wideBoldFont (\fPclass\fB WideBoldFont)"
+This option specifies the font to be used for displaying bold wide text.
+By default,
+it will attempt to use a font twice as wide as the font that will be used to
+draw bold text.
+If no double-width font is found, it will improvise, by stretching
+the bold font.
+.TP 8
+.B "wideChars (\fPclass\fB WideChars)"
+Specifies if \fIxterm\fP should respond to control sequences that
+process 16-bit characters.
+The default is \*(``false.\*(''
+.TP 8
+.B "wideFont (\fPclass\fB WideFont)"
+This option specifies the font to be used for displaying wide text.
+By default,
+it will attempt to use a font twice as wide as the font that will be used to
+draw normal text.
+If no double-width font is found, it will improvise, by stretching
+the normal font.
+.TP 8
+.B "ximFont (\fPclass\fB XimFont)"
+This option specifies the font to be used for displaying the preedit string
+in the "OverTheSpot" input method.
+.IP
+In "OverTheSpot" preedit type, the preedit (preconversion)
+string is displayed at the position of the cursor.
+It is the XIM server's responsibility to display the preedit string.
+The XIM client must inform the XIM server of the cursor position.
+For best results, the preedit string must be displayed with a proper font.
+Therefore, \fIxterm\fP informs the XIM server of the proper font.
+The font is be supplied by a "fontset", whose default value is "*".
+This matches every font, the X library automatically chooses fonts with
+proper charsets.
+The \fBximFont\fP resource is provided to override this default font setting.
+.\"
+.SS Tek4014 Widget Resources
+.PP
+The following resources are specified
+as part of the \fItek4014\fP widget (class \fITek4014\fP).
+These are specified by patterns such as "\fBXTerm.tek4014.\fP\fINAME\fP":
+.TP 8
+.B "font2 (\fPclass\fB Font)"
+Specifies font number 2 to use in the Tektronix window.
+.TP 8
+.B "font3 (\fPclass\fB Font)"
+Specifies font number 3 to use in the Tektronix window.
+.TP 8
+.B "fontLarge (\fPclass\fB Font)"
+Specifies the large font to use in the Tektronix window.
+.TP 8
+.B "fontSmall (\fPclass\fB Font)"
+Specifies the small font to use in the Tektronix window.
+.TP 8
+.B "ginTerminator (\fPclass\fB GinTerminator)"
+Specifies what character(s) should follow a GIN report or status report.
+The possibilities are \*(``none,\*('' which sends no terminating characters,
+\*(``CRonly,\*('' which sends CR, and \*(``CR&EOT,\*('' which sends both CR and EOT.
+The default is \*(``none.\*(''
+.TP 8
+.B "height (\fPclass\fB Height)"
+Specifies the height of the Tektronix window in pixels.
+.TP 8
+.B "initialFont (\fPclass\fB InitialFont)"
+Specifies which of the four Tektronix fonts to use initially.
+Values are the same as for the \fIset-tek-text\fP action.
+The default is \*(``large.\*(''
+.TP 8
+.B "width (\fPclass\fB Width)"
+Specifies the width of the Tektronix window in pixels.
+.\"
+.SS Menu Resources
+.PP
+The resources that may be specified for the various menus are described in
+the documentation for the Athena \fBSimpleMenu\fP widget.
+The name and classes
+of the entries in each of the menus are listed below.
+Resources named "\fBline\fR\fIN\fR" where \fIN\fR is a number
+are separators with class \fBSmeLine\fR.
+.
+.PP
+The \fImainMenu\fP has the following entries:
+.TP 8
+.B "toolbar (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-toolbar(toggle)\fP action.
+.TP 8
+.B "securekbd (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsecure()\fP action.
+.TP 8
+.B "allowsends (\fPclass\fB SmeBSB)"
+This entry invokes the \fBallow-send-events(toggle)\fP action.
+.TP 8
+.B "redraw (\fPclass\fB SmeBSB)"
+This entry invokes the \fBredraw()\fP action.
+.TP 8
+.B "logging (\fPclass\fB SmeBSB)"
+This entry invokes the \fBlogging(toggle)\fP action.
+.TP 8
+.B "print (\fPclass\fB SmeBSB)"
+This entry invokes the \fBprint()\fP action.
+.TP 8
+.B "print-redir (\fPclass\fB SmeBSB)"
+This entry invokes the \fBprint-redir()\fP action.
+.TP 8
+.B "8-bit-control (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-8-bit-control(toggle)\fP action.
+.TP 8
+.B "backarrow\ key (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-backarrow(toggle)\fP action.
+.TP 8
+.B "num-lock (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-num-lock(toggle)\fP action.
+.TP 8
+.B "alt-esc (\fPclass\fB SmeBSB)"
+This entry invokes the \fBalt-sends-escape(toggle)\fP action.
+.TP 8
+.B "meta-esc (\fPclass\fB SmeBSB)"
+This entry invokes the \fBmeta-sends-escape(toggle)\fP action.
+.TP 8
+.B "delete-is-del (\fPclass\fB SmeBSB)"
+This entry invokes the \fBdelete-is-del(toggle)\fP action.
+.TP 8
+.B "oldFunctionKeys (\fPclass\fB SmeBSB)"
+This entry invokes the \fBold-function-keys(toggle)\fP action.
+.TP 8
+.B "hpFunctionKeys (\fPclass\fB SmeBSB)"
+This entry invokes the \fBhp-function-keys(toggle)\fP action.
+.TP 8
+.B "scoFunctionKeys (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsco-function-keys(toggle)\fP action.
+.TP 8
+.B "sunFunctionKeys (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsun-function-keys(toggle)\fP action.
+.TP 8
+.B "sunKeyboard (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsunKeyboard(toggle)\fP action.
+.TP 8
+.B "suspend (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsend-signal(tstp)\fP action on systems that
+support job control.
+.TP 8
+.B "continue (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsend-signal(cont)\fP action on systems that
+support job control.
+.TP 8
+.B "interrupt (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsend-signal(int)\fP action.
+.TP 8
+.B "hangup (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsend-signal(hup)\fP action.
+.TP 8
+.B "terminate (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsend-signal(term)\fP action.
+.TP 8
+.B "kill (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsend-signal(kill)\fP action.
+.TP 8
+.B "quit (\fPclass\fB SmeBSB)"
+This entry invokes the \fBquit()\fP action.
+.
+.PP
+The \fIvtMenu\fP has the following entries:
+.TP 8
+.B "scrollbar (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-scrollbar(toggle)\fP action.
+.TP 8
+.B "jumpscroll (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-jumpscroll(toggle)\fP action.
+.TP 8
+.B "reversevideo (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-reverse-video(toggle)\fP action.
+.TP 8
+.B "autowrap (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-autowrap(toggle)\fP action.
+.TP 8
+.B "reversewrap (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-reversewrap(toggle)\fP action.
+.TP 8
+.B "autolinefeed (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-autolinefeed(toggle)\fP action.
+.TP 8
+.B "appcursor (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-appcursor(toggle)\fP action.
+.TP 8
+.B "appkeypad (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-appkeypad(toggle)\fP action.
+.TP 8
+.B "scrollkey (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-scroll-on-key(toggle)\fP action.
+.TP 8
+.B "scrollttyoutput (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-scroll-on-tty-output(toggle)\fP action.
+.TP 8
+.B "allow132 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-allow132(toggle)\fP action.
+.TP 8
+.B "cursesemul (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-cursesemul(toggle)\fP action.
+.TP 8
+.B "visualbell (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-visualbell(toggle)\fP action.
+.TP 8
+.B "bellIsUrgent (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-bellIsUrgent(toggle)\fP action.
+.TP 8
+.B "poponbell (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-poponbell(toggle)\fP action.
+.TP 8
+.B "cursorblink (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-cursorblink(toggle)\fP action.
+.TP 8
+.B "titeInhibit (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-titeInhibit(toggle)\fP action.
+.TP 8
+.B "activeicon (\fPclass\fB SmeBSB)"
+This entry toggles active icons on and off if this feature was
+compiled into \fIxterm\fP.
+It is enabled only if \fIxterm\fP
+was started with the command line option +ai or the \fBactiveIcon\fP
+resource is set to \*(``true.\*(''
+.TP 8
+.B "softreset (\fPclass\fB SmeBSB)"
+This entry invokes the \fBsoft-reset()\fP action.
+.TP 8
+.B "hardreset (\fPclass\fB SmeBSB)"
+This entry invokes the \fBhard-reset()\fP action.
+.TP 8
+.B "clearsavedlines (\fPclass\fB SmeBSB)"
+This entry invokes the \fBclear-saved-lines()\fP action.
+.TP 8
+.B "tekshow (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-visibility(tek,toggle)\fP action.
+.TP 8
+.B "tekmode (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-terminal-type(tek)\fP action.
+.TP 8
+.B "vthide (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-visibility(vt,off)\fP action.
+.TP 8
+.B "altscreen (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-altscreen(toggle)\fP action.
+.
+.PP
+The \fIfontMenu\fP has the following entries:
+.TP 8
+.B "fontdefault (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(d)\fP action.
+.TP 8
+.B "font1 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(1)\fP action.
+.TP 8
+.B "font2 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(2)\fP action.
+.TP 8
+.B "font3 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(3)\fP action.
+.TP 8
+.B "font4 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(4)\fP action.
+.TP 8
+.B "font5 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(5)\fP action.
+.TP 8
+.B "font6 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(6)\fP action.
+.TP 8
+.B "fontescape (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(e)\fP action.
+.TP 8
+.B "fontsel (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-vt-font(s)\fP action.
+.TP 8
+.B "font-linedrawing (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-font-linedrawing(s)\fP action.
+.TP 8
+.B "font-packed (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-font-packed(s)\fP action.
+.TP 8
+.B "font-doublesize (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-font-doublesize(s)\fP action.
+.TP 8
+.B "render-font (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-render-font(s)\fP action.
+.TP 8
+.B "utf8-mode (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-utf8-mode(s)\fP action.
+.TP 8
+.B "utf8-title (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-utf8-title(s)\fP action.
+.
+.PP
+The \fItekMenu\fP has the following entries:
+.TP 8
+.B "tektextlarge (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-tek-text(large)\fP action.
+.TP 8
+.B "tektext2 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-tek-text(2)\fP action.
+.TP 8
+.B "tektext3 (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-tek-text(3)\fP action.
+.TP 8
+.B "tektextsmall (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-tek-text(small)\fP action.
+.TP 8
+.B "tekpage (\fPclass\fB SmeBSB)"
+This entry invokes the \fBtek-page()\fP action.
+.TP 8
+.B "tekreset (\fPclass\fB SmeBSB)"
+This entry invokes the \fBtek-reset()\fP action.
+.TP 8
+.B "tekcopy (\fPclass\fB SmeBSB)"
+This entry invokes the \fBtek-copy()\fP action.
+.TP 8
+.B "vtshow (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-visibility(vt,toggle)\fP action.
+.TP 8
+.B "vtmode (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-terminal-type(vt)\fP action.
+.TP 8
+.B "tekhide (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-visibility(tek,toggle)\fP action.
+.\"
+.SS Scrollbar Resources
+.PP
+The following resources are useful when specified for the Athena Scrollbar
+widget:
+.TP 8
+.B "thickness (\fPclass\fB Thickness)"
+Specifies the width in pixels of the scrollbar.
+.TP 8
+.B "background (\fPclass\fB Background)"
+Specifies the color to use for the background of the scrollbar.
+.TP 8
+.B "foreground (\fPclass\fB Foreground)"
+Specifies the color to use for the foreground of the scrollbar.
+The \*(``thumb\*(''
+of the scrollbar is a simple checkerboard pattern alternating pixels for
+foreground and background color.
+.
+.
+.SH "POINTER USAGE"
+.
+.PP
+Once the VT102 window is created,
+.I xterm
+allows you to select text and copy it within the same or other windows.
+.
+.SS "SELECTION"
+.PP
+The selection functions are invoked when the pointer buttons are used with no
+modifiers, and when they are used with the \*(``shift\*('' key.
+The assignment of the functions described below to keys and buttons may
+be changed through the resource database; see \fBACTIONS\fP below.
+.
+.PP
+Pointer button one (usually left) is used to save text into the cut buffer.
+Move the cursor to beginning of the text,
+and then hold the button down while moving the cursor to the end of the region
+and releasing the button.
+The selected text is highlighted and is saved in the global cut buffer
+and made the PRIMARY selection when the button is released.
+Normally (but see the discussion of \fBon2Clicks\fP, etc):
+.RS
+.TP 3
+-
+Double-clicking selects by words.
+.TP
+-
+Triple-clicking
+selects by lines.
+.TP
+-
+Quadruple-clicking goes back to characters, etc.
+.RE
+.PP
+Multiple-click is determined by the time from button up to
+button down, so you can change the selection unit in the middle of a selection.
+Logical words and lines selected by double- or triple-clicking may wrap
+across more than one screen line if lines were wrapped by \fIxterm\fP
+itself rather than by the application running in the window.
+If the key/button bindings specify that an X selection is to be made,
+\fIxterm\fP will leave the selected text highlighted for as long as it
+is the selection owner.
+.
+.PP
+Pointer button two (usually middle) \*(``types\*('' (pastes) the text from
+the PRIMARY selection, if any, otherwise from
+the cut buffer,
+inserting it as keyboard input.
+.
+.PP
+Pointer button three (usually right) extends the current selection.
+(Without loss of generality,
+you can swap \*(``right\*('' and \*(``left\*('' everywhere in the rest of this
+paragraph.)  If pressed while closer to
+the right edge of the selection than the left, it extends/contracts the
+right edge of the selection.
+If you contract the selection past
+the left edge of the selection,
+.I xterm
+assumes you really meant the left edge, restores the original selection, then
+extends/contracts the left edge of the selection.
+Extension starts in the
+selection unit mode
+that the last selection or extension was performed in; you can multiple-click
+to cycle through them.
+.
+.PP
+By cutting and pasting pieces of text without trailing new lines,
+you can take text from several places in different windows and form a command
+to the shell, for example, or take output from a program and insert it into
+your favorite editor.
+Since cut buffers are globally shared among different applications,
+you may regard each as a \*(``file\*('' whose contents you know.
+The terminal emulator and other text programs should be treating it as if it
+were a text file, i.e., the text is delimited by new lines.
+.
+.SS "SCROLLING"
+.PP
+The scroll region displays the position and amount of text currently showing
+in the window (highlighted) relative to the amount of text actually saved.
+As more text is saved (up to the maximum), the size of the highlighted area
+decreases.
+.
+.PP
+Clicking button one with the pointer in the scroll region moves the
+adjacent line to the top of the display window.
+.
+.PP
+Clicking button three moves the top line of the display window down to the
+pointer position.
+.
+.PP
+Clicking button two moves the display to a position in the saved text
+that corresponds to the pointer's position in the scrollbar.
+.
+.SS "TEKTRONIX POINTER"
+.PP
+Unlike the VT102 window, the Tektronix window does not allow the copying of
+text.
+It does allow Tektronix GIN mode, and in this mode
+the cursor will change from an arrow to a cross.
+Pressing any key will send that key and the current coordinate of the
+cross cursor.
+Pressing button one, two, or three will return the letters \*(``l\*('', \*(``m\*('', and
+\*(``r\*('', respectively.
+If the \*(``shift\*('' key is pressed when a pointer button is pressed, the corresponding
+upper case letter is sent.
+To distinguish a pointer button from a key, the high bit of the character is
+set (but this is bit is normally stripped unless the terminal mode is RAW;
+see
+.IR tty (4)
+for details).
+.
+.
+.SH SELECT/PASTE
+X clients provide select and paste support by responding to requests conveyed
+by the server.
+.SS PRIMARY
+When configured to use the primary selection,
+(the default) \fIxterm\fP can
+provide the selection data in ways which help to retain character
+encoding information as it is pasted.
+.PP
+A user "selects" text on xterm, which highlights the selected text.
+A subsequent "paste" to another client forwards a request to the client owning
+the selection.
+If \fIxterm\fP owns the primary selection, it makes the data
+available in the form of one or more "selection targets".
+If it does not own the primary selection,
+e.g., if it has released it or another client has
+asserted ownership, it relies on cut-buffers to pass the data.
+But cut-buffers handle only ISO-8859-1 data
+(officially \- some clients ignore the rules).
+.
+.SS CLIPBOARD
+When configured to use the clipboard (see resource \fBselectToClipboard\fP),
+the problem with persistence of ownership is bypassed.
+Otherwise, there is no difference regarding the data which can be
+passed via selection.
+.
+.SS SELECTION TARGETS
+The different types of data which are passed depend on what the receiving
+client asks for.
+These are termed \fIselection targets\fP.
+.PP
+When asking for the selection data,
+\fIxterm\fP tries the following types in this order:
+.RS
+.TP 5
+UTF8_STRING
+This is an XFree86 extension, which denotes that the data is encoded in UTF-8.
+When \fIxterm\fP is built with wide-character support,
+it both accepts and provides this type.
+.TP 5
+TEXT
+the text is in the encoding which corresponds to your current locale.
+.TP 5
+.\" see xc/doc/specs/CTEXT/ctext.tbl.ms
+.\" (it says the data is stored as a type of ISO 2022)
+COMPOUND_TEXT
+this is a format for multiple character set data, such as multi-lingual text.
+It can store UTF-8 data as a special case.
+.TP 5
+STRING
+This is Latin 1 (ISO-8859-1) data.
+.RE
+.PP
+The middle two (TEXT and COMPOUND_TEXT) are added if \fIxterm\fP
+is configured with the \fBi18nSelections\fP resource set to \*(``true\*(''.
+.PP
+UTF8_STRING is preferred (therefore first in the list)
+since \fIxterm\fP stores text as Unicode data when
+running in wide-character mode, and no translation is needed.
+On the other hand, TEXT and COMPOUND_TEXT may require translation.
+If the translation is incomplete, they will insert X's \*(``defaultString\*(''
+whose value cannot be set, and may simply be empty.
+\fIXterm\fP's \fBdefaultString\fP resource specifies the string to
+use for incomplete translations of the UTF8_STRING.
+.PP
+You can alter the types which \fIxterm\fP tries using the
+\fBeightBitSelectTypes\fP or \fButf8SelectTypes\fP resources.
+For instance, you might have some specific locale setting
+which does not use UTF-8 encoding.
+The resource value is a comma-separated list of the selection targets,
+which consist of the names shown.  You can use the special name I18N
+to denote the optional inclusion of TEXT and COMPOUND_TEXT.
+The names are matched ignoring case, and can be abbreviated.
+The default list can be expressed in several ways, e.g.,
+.sp
+.RS
+.nf
+UTF8_STRING,I18N,STRING
+utf8,i18n,string
+u,i,s
+.fi
+.RE
+.
+.SH MENUS
+.
+.PP
+.I Xterm
+has four menus, named
+.IR mainMenu ,
+.IR vtMenu ,
+.IR fontMenu ,
+and
+.IR tekMenu .
+Each menu pops up under the correct combinations of key and button presses.
+Each menu is divided into sections, separated by a horizontal line.
+Some menu entries correspond to modes that can be altered.
+A check mark appears next to a mode that is currently active.
+Selecting one of these modes toggles its state.
+Other menu entries are commands;
+selecting one of these performs the indicated function.
+.PP
+All of the menu entries correspond to X actions.
+In the list below, the menu label is shown followed by the action's
+name in parenthesis.
+.
+.\" ************************************************************************
+.SS "Main Options"
+.PP
+The \fIxterm\fP \fImainMenu\fP pops up
+when the \*(``control\*('' key and pointer button one are pressed in a window.
+This menu contains items that apply to both the VT102 and Tektronix windows.
+There are several sections:
+.TP
+Commands for managing X events:
+.RS
+.TP
+Toolbar
+Clicking on the "Toolbar" menu entry hides the toolbar if it is visible,
+and shows it if it is not.
+.TP
+Secure Keyboard (securekbd)
+The
+.B Secure Keyboard
+mode is helpful when typing in passwords or other sensitive data in an
+unsecure environment;
+see \fBSECURITY\fP below (but read the limitations carefully).
+.TP
+Allow SendEvents (allowsends)
+Specifies whether or not synthetic key and button events generated using
+the X protocol SendEvent request should be interpreted or discarded.
+This corresponds to the \fBallowSendEvents\fP resource.
+.TP
+Redraw Window (redraw)
+Forces the X display to repaint;
+useful in some environments.
+.RE
+.TP
+Commands for capturing output:
+.RS
+.TP
+Log to File (logging)
+Captures text sent to the screen in a logfile,
+as in the \fB\-l\fP logging option.
+.TP
+Print Window (print)
+Sends the text of the current window to the program given in the
+\fBprinterCommand\fP resource.
+.TP
+Redirect to Printer (print-redir)
+This sets the \fBprinterControlMode\fR to 0 or 2.
+You can use this to turn the printer on as if an application had sent
+the appropriate control sequence.
+It is also useful for switching the printer
+off if an application turns it on without resetting the print control mode.
+.RE
+.TP
+Modes for setting keyboard style:
+.RS
+.TP
+8-Bit Controls (8-bit-control)
+Enabled for VT220 emulation, this controls whether \fIxterm\fP will send
+8-bit control sequences rather than using 7-bit (ASCII) controls,
+e.g., sending a byte in the range 128-159 rather than the escape character
+followed by a second byte.
+\fIXterm\fP always interprets both 8-bit and 7-bit control sequences
+(see the document \fIXterm Control Sequences\fP).
+This corresponds to the \fBeightBitControl\fP resource.
+.TP
+Backarrow Key (BS/DEL) (backarrow\ key)
+Modifies the behavior of the backarrow key, making it transmit
+either a backspace (8)
+or delete (127) character.
+This corresponds to the \fBbackarrowKey\fP resource.
+.TP
+Alt/NumLock Modifiers (num-lock)
+Controls the treatment of Alt- and NumLock-key modifiers.
+This corresponds to the \fBnumLock\fP resource.
+.TP
+Meta Sends Escape (meta-esc)
+Controls whether \fIMeta\fP keys are converted into a two-character
+sequence with the character itself preceded by ESC.
+This corresponds to the \fBmetaSendsEscape\fP resource.
+.TP
+Delete is DEL (delete-is-del)
+Controls whether the Delete key on the editing keypad should send DEL (127)
+or the VT220-style Remove escape sequence.
+This corresponds to the \fBdeleteIsDEL\fP resource.
+.TP
+Old Function-Keys (oldFunctionKeys)
+.TP
+HP Function-Keys (hpFunctionKeys)
+.TP
+SCO Function-Keys (scoFunctionKeys)
+.TP
+Sun Function-Keys (sunFunctionKeys)
+.TP
+VT220 Keyboard (sunKeyboard)
+These act as a radio-button, selecting one style for the keyboard layout.
+It corresponds to more than one resource setting:
+.BR "sunKeyboard" ","
+.BR "sunFunctionKeys" ","
+.BR "scoFunctionKeys" " and"
+.BR "hpFunctionKeys "."
+.RE
+.TP
+Commands for process signalling:
+.RS
+.TP
+Send STOP Signal (suspend)
+.TP
+Send CONT Signal (continue)
+.TP
+Send INT Signal (interrupt)
+.TP
+Send HUP Signal (hangup)
+.TP
+Send TERM Signal (terminate)
+.TP
+Send KILL Signal (kill)
+These send the SIGTSTP, SIGCONT, SIGINT, SIGHUP, SIGTERM and SIGKILL
+signals respectively, to the process group of the process running under
+.I xterm
+(usually the shell).
+The
+.B SIGCONT
+function is especially useful if the user has accidentally typed CTRL-Z,
+suspending the process.
+.TP
+Quit (quit)
+Stop processing X events except to support the \fB-hold\fP option,
+and then send a SIGHUP signal to the
+the process group of the process running under
+.I xterm
+(usually the shell).
+.RE
+.PP
+.
+.\" ************************************************************************
+.SS "VT Options"
+.PP
+The
+.I vtMenu
+sets various modes in the VT102 emulation, and is popped up when the
+\*(``control\*('' key and pointer button two are pressed in the VT102 window.
+.TP
+VT102/VT220 Modes:
+.RS
+.
+.TP
+Enable Scrollbar (scrollbar)
+Enable (or disable) the scrollbar.
+This corresponds to the
+.B \-sb
+option and the
+.B scrollBar
+resource.
+.
+.TP
+Enable Jump Scroll (jumpscroll)
+Enable (or disable) jump scrolling.
+This corresponds to the
+.B \-j
+option and the
+.B jumpScroll
+resource.
+.
+.TP
+Enable Reverse Video (reversevideo)
+Enable (or disable) reverse-video.
+This corresponds to the
+.B \-rv
+option and the
+.B reverseVideo
+resource.
+.
+.TP
+Enable Auto Wraparound (autowrap)
+Enable (or disable) auto-wraparound.
+This corresponds to the
+.B \-aw
+option and the
+.B autoWrap
+resource.
+.
+.TP
+Enable Reverse Wraparound (reversewrap)
+Enable (or disable) reverse wraparound.
+This corresponds to the
+.B \-rw
+option and the
+.B reverseWrap
+resource.
+.
+.TP
+Enable Auto Linefeed (autolinefeed)
+Enable (or disable) auto-linefeed.
+This is the VT102 NEL function,
+which causes the emulator to emit a linefeed after each carriage return.
+There is no corresponding command-line option or resource setting.
+.
+.TP
+Enable Application Cursor Keys (appcursor)
+Enable (or disable) application cursor keys.
+This corresponds to the
+.B appcursorDefault
+resource.
+There is no corresponding command-line option.
+.
+.TP
+Enable Application Keypad (appkeypad)
+Enable (or disable) application keypad keys.
+This corresponds to the
+.B appkeypadDefault
+resource.
+There is no corresponding command-line option.
+.
+.TP
+Scroll to Bottom on Key Press (scrollkey)
+Enable (or disable) scrolling to the bottom of the scrolling region on a keypress.
+This corresponds to the
+.B \-sk
+option and the
+.B scrollKey
+resource.
+.IP
+As a special case, the XON / XOFF keys (control/S and control/Q) are ignored.
+.
+.TP
+Scroll to Bottom on Tty Output (scrollttyoutput)
+Enable (or disable) scrolling to the bottom of the scrolling region on output to the terminal.
+This corresponds to the
+.B \-si
+option and the
+.B scrollTtyOutput
+resource.
+.
+.TP
+Allow 80/132 Column Switching (allow132)
+Enable (or disable) switching between 80 and 132 columns.
+This corresponds to the
+.B \-132
+option and the
+.B c132
+resource.
+.
+.TP
+Keep Selection (keepSelection)
+Tell \fIxterm\fP whether to disown the selection when it stops highlighting it,
+e.g., when an application modifies the display so that it no longer matches
+the text which has been highlighted.
+As long as \fIxterm\fP continues to own the selection,
+it can provide the corresponding text to other clients via cut/paste.
+This corresponds to the
+.B keepSelection
+resource.
+There is no corresponding command-line option.
+.
+.TP
+Select to Clipboard (selectToClipboard)
+Tell \fIxterm\fP whether to use the PRIMARY or CLIPBOARD
+for SELECT tokens in the \fBtranslations\fP resource which
+maps keyboard and mouse actions to select/paste actions.
+This corresponds to the
+.B selectToClipboard
+resource.
+There is no corresponding command-line option.
+.
+.TP
+Enable Visual Bell (visualbell)
+Enable (or disable) visible bell (i.e., flashing) instead of an audible bell.
+This corresponds to the
+.B \-vb
+option and the
+.B visualBell
+resource.
+.
+.TP
+Enable Bell Urgency (bellIsUrgent)
+Enable (or disable) Urgency window manager hint when Control-G is received.
+This corresponds to the
+.B bellIsUrgent
+resource.
+.
+.TP
+Enable Pop on Bell (poponbell)
+Enable (or disable) raising of the window when Control-G is received.
+This corresponds to the
+.B \-pop
+option and the
+.B popOnBell
+resource.
+.
+.TP
+Enable Blinking Cursor (cursorblink)
+Enable (or disable) the blinking-cursor feature.
+This corresponds to the
+.B \-bc
+option and the
+.B cursorBlink
+resource.
+There is also an escape sequence
+(see the document \fIXterm Control Sequences\fP).
+The menu entry and the escape sequence states are XOR'd:
+if both are enabled, the cursor will not blink,
+if only one is enabled, the cursor will blink.
+.
+.TP
+Enable Alternate Screen Switching (titeInhibit)
+Enable (or disable) switching between the normal and alternate screens.
+This corresponds to the
+.B titeInhibit
+resource.
+There is no corresponding command-line option.
+.
+.TP
+Enable Active Icon (activeicon)
+Enable (or disable) the active-icon feature.
+This corresponds to the
+.B \-ai
+option and the
+.B activeIcon
+resource.
+.RE
+.
+.TP
+VT102/VT220 Commands:
+.RS
+.TP
+Do Soft Reset (softreset)
+Reset scroll regions.
+This can be convenient when some program has left the scroll regions
+set incorrectly (often a problem when using VMS or TOPS-20).
+This corresponds to the VT220 DECSTR control sequence.
+.
+.TP
+Do Full Reset (hardreset)
+The full reset entry will clear the screen, reset tabs to every
+eight columns, and reset the terminal modes (such as wrap and smooth scroll)
+to their initial states just after
+.I xterm
+has finished processing the command line options.
+This corresponds to the VT102 RIS control sequence,
+with a few obvious differences.
+For example, your session is not disconnected as a real VT102 would do.
+.
+.TP
+Reset and Clear Saved Lines (clearsavedlines)
+Perform a full reset,
+and also clear the saved lines.
+.RE
+.
+.TP
+Commands for setting the current screen:
+.RS
+.
+.TP
+Show Tek Window (tekshow)
+When enabled,
+pops the Tektronix 4014 window up (makes it visible).
+When disabled,
+hides the Tektronix 4014 window.
+.
+.TP
+Switch to Tek Mode (tekmode)
+When enabled,
+pops the Tektronix 4014 window up if it is not already visible,
+and switches the input stream to that window.
+When disabled,
+hides the Tektronix 4014 window and
+switches input back to the VTxxx window.
+.
+.TP
+Hide VT Window (vthide)
+When enabled,
+hides the VTxxx window,
+shows the Tektronix 4014 window if
+it was not already visible
+and switches the input stream to that window.
+When disabled,
+shows the VTxxx window,
+and switches the input stream to that window.
+.
+.TP
+Show Alternate Screen (altscreen)
+When enabled,
+shows the alternate screen.
+When disabled,
+shows the normal screen.
+Note that the normal screen may have saved lines;
+the alternate screen does not.
+.RE
+.PP
+.
+.SS "VT Fonts"
+.PP
+The \fIfontMenu\fP pops up when
+when the \*(``control\*('' key and pointer button three are pressed in a window.
+It sets the font used in the VT102 window,
+or modifies the way the font is specified or displayed.
+There are several sections.
+.PP
+The first section allows you to select the font from a set of alternatives:
+.RS
+.TP
+Default (fontdefault)
+Set the font to the default, i.e., that given by the
+.B *VT100.font
+resource.
+.TP
+Unreadable (font1)
+Set the font to that given by the
+.B *VT100.font1
+resource.
+.TP
+Tiny (font2)
+Set the font to that given by the
+.B *VT100.font2
+resource.
+.TP
+Small (font3)
+Set the font to that given by the
+.B *VT100.font3
+resource.
+.TP
+Medium (font4)
+Set the font to that given by the
+.B *VT100.font4
+resource.
+.TP
+Large (font5)
+Set the font to that given by the
+.B *VT100.font5
+resource.
+.TP
+Huge (font6)
+Set the font to that given by the
+.B *VT100.font6
+resource.
+.TP
+Escape Sequence
+This allows you to set the font last specified by the Set
+Font escape sequence (see the document \fIXterm Control Sequences\fP).
+.TP
+Selection (fontsel)
+This allows you to set the font specified
+the current selection as a font name (if the PRIMARY selection is owned).
+.RE
+.PP
+The second section allows you to modify the way it is displayed:
+.RS
+.TP
+Line-Drawing Characters (font-linedrawing)
+When set, tells \fIxterm\fP to draw its own line-drawing characters.
+Otherwise it relies on the font containing these.
+Compare to the \fBforceBoxChars\fP resource.
+.TP
+Packed Font (font-packed)
+When set, tells \fIxterm\fP to use the minimum glyph-width from a font
+when displaying characters.
+Use the maximum width (unchecked) to help display proportional fonts.
+Compare to the \fBforcePackedFont\fP resource.
+.TP
+Doublesized Characters (font-doublesize)
+When set, \fIxterm\fP may ask the font server to produce scaled versions
+of the normal font, for VT102 double-size characters.
+.RE
+.PP
+The third section allows you to modify the way it is specified:
+.RS
+.TP
+TrueType Fonts (render-font)
+If the
+.B "renderFont
+and corresponding resources were set,
+this is a further control whether \fIxterm\fP will actually use the
+Xft library calls to obtain a font.
+.TP
+UTF-8 (utf8-mode)
+This controls whether \fIxterm\fP uses UTF-8 encoding of input/output.
+It is useful for temporarily switching \fIxterm\fP to display
+text from an application which does not follow the locale settings.
+.RE
+.PP
+The fourth section allows you to enable or disable special operations
+which can be controlled by writing escape sequences to the terminal.
+These are disabled if the SendEvents feature is enabled:
+.RS
+.TP
+Allow Color Ops (allow-font-ops)
+This corresponds to the \fBallowColorOps\fP resource.
+Enable or disable control sequences that set/query the colors.
+.TP
+Allow Font Ops (allow-font-ops)
+This corresponds to the \fBallowFontOps\fP resource.
+Enable or disable control sequences that set/query the font.
+.TP
+Allow Tcap Ops (allow-tcap-ops)
+Enable or disable control sequences that query the terminal's
+notion of its function-key strings, as termcap or terminfo capabilities.
+This corresponds to the \fBallowTcapOps\fP resource.
+.TP
+Allow Title Ops (allow-title-ops)
+Enable or disable control sequences that modify the window title or icon name.
+This corresponds to the \fBallowTitleOps\fP resource.
+.TP
+Allow Window Ops (allow-window-ops)
+Enable or disable extended window control sequences (as used in dtterm).
+This corresponds to the \fBallowWindowOps\fP resource.
+.RE
+.
+.SS "TEK Options"
+.PP
+The
+.I tekMenu
+sets various modes in the Tektronix emulation, and is popped up when the
+\*(``control\*('' key and pointer button two are pressed in the Tektronix window.
+The current font size is checked in the modes section of the menu.
+.RS
+.TP
+Large Characters (tektextlarge)
+.TP
+\&#2 Size Characters (tektext2)
+.TP
+\&#3 Size Characters (tektext3)
+.TP
+Small Characters (tektextsmall)
+.RE
+.PP
+Commands:
+.RS
+.TP
+PAGE (tekpage)
+Clear the Tektronix window.
+.TP
+RESET (tekreset)
+.TP
+COPY (tekcopy)
+.RE
+.PP
+Windows:
+.RS
+.TP
+Show VT Window (vtshow)
+.TP
+Switch to VT Mode (vtmode)
+.TP
+Hide Tek Window (tekhide)
+.RE
+.
+.
+.SH SECURITY
+.
+.PP
+X environments differ in their security consciousness.
+Most servers,
+run under \fIxdm\fP,
+are capable of using a \*(``magic cookie\*('' authorization
+scheme that can provide a reasonable level of security for many people.
+If your server is only using a host-based mechanism to control access to
+the server (see \fIxhost(__mansuffix__)\fP), then if you enable access for a host and
+other users are also permitted to run clients on that same host,
+it is possible that someone can run an application which uses the
+basic services of the X protocol to snoop on your activities,
+potentially capturing a transcript of everything you type at the keyboard.
+Any process which has access to your X display can manipulate it
+in ways that you might not anticipate,
+even redirecting your keyboard to itself
+and sending events to your application's windows.
+This is true even with the \*(``magic cookie\*('' authorization scheme.
+While the \fBallowSendEvents\fP provides some protection against
+rogue applications tampering with your programs,
+guarding against a snooper is harder.
+.
+.PP
+The possibility of an application spying on your keystrokes
+is of particular concern when you want to type in a password
+or other sensitive data.
+The best solution to this problem is to use a better
+authorization mechanism than is provided by X.
+Given all of these caveats,
+a simple mechanism exists for protecting keyboard input in \fIxterm\fP.
+.
+.PP
+The \fIxterm\fP menu (see \fBMENUS\fP above) contains a \fBSecure Keyboard\fP
+entry which, when enabled,
+attempts to ensure that all keyboard input is directed
+\fIonly\fP to \fIxterm\fP (using the GrabKeyboard protocol request).
+When an application prompts you for a password
+(or other sensitive data), you can enable \fBSecure Keyboard\fP using the
+menu, type in the data, and then disable \fBSecure Keyboard\fP using
+the menu again.
+This ensures that you know which window is accepting your keystrokes.
+It cannot ensure that there are no processes which have access to your
+X display that might be observing the keystrokes as well.
+.
+.PP
+Only one X client at a time can grab the keyboard,
+so when you attempt to enable \fBSecure Keyboard\fP it may fail.
+In this case, the bell will sound.
+If the \fBSecure Keyboard\fP succeeds,
+the foreground and background colors will be exchanged (as if you
+selected the \fBReverse Video\fP entry in the \fBModes\fP menu);
+they will be exchanged again when you exit secure mode.
+If the colors
+do \fInot\fP switch, then
+you should be \fIvery\fP suspicious that you are being spoofed.
+If the application you are running displays a prompt before asking for
+the password, it is safest to enter secure mode \fIbefore\fP the
+prompt gets displayed, and to make sure that the prompt gets displayed
+correctly (in the new colors), to minimize the probability of
+spoofing.
+You can also bring up the menu again and make sure that a check
+mark appears next to the entry.
+.
+.PP
+\fBSecure Keyboard\fP mode will be disabled automatically if your \fIxterm\fP
+window becomes iconified (or otherwise unmapped), or if you start up
+a reparenting window manager (that places a title bar or other decoration
+around the window) while in \fBSecure Keyboard\fP mode.
+(This is a
+feature of the X protocol not easily overcome.)  When this happens,
+the foreground and background colors will be switched back and the bell
+will sound in warning.
+.
+.
+.SH "CHARACTER CLASSES"
+Clicking the left pointer button twice in rapid succession
+(double-clicking) causes all characters of the same class
+(e.g., letters, white space, punctuation) to be selected as a \*(``word\*(''.
+Since different people have different preferences for what should
+be selected (for example, should filenames be selected as a whole or only
+the separate subnames), the default mapping can be overridden through the use
+of the \fBcharClass\fP (class \fICharClass\fP) resource.
+.
+.PP
+This resource is a
+series of comma-separated
+of \fIrange\fP:\fIvalue\fP pairs.
+The
+\fIrange\fP is either a single number or \fIlow\fP-\fIhigh\fP in the range of 0
+to 65535, corresponding to the code for the character or characters to be
+set.
+The \fIvalue\fP is arbitrary, although the default table uses the
+character number of the first character occurring in the set.
+When not in
+UTF-8 mode, only the first 256 bytes of this table will be used.
+.
+.PP
+The default table starts as follows \-
+.NS
+static int charClass[256] = {
+/\(** NUL  SOH  STX  ETX  EOT  ENQ  ACK  BEL */
+    32,   1,   1,   1,   1,   1,   1,   1,
+/\(**  BS   HT   NL   VT   NP   CR   SO   SI */
+     1,  32,   1,   1,   1,   1,   1,   1,
+/\(** DLE  DC1  DC2  DC3  DC4  NAK  SYN  ETB */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/\(** CAN   EM  SUB  ESC   FS   GS   RS   US */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/\(**  SP    !    "    #    $    %    &    \*(AQ */
+.\"   " <- for emacs autocolor to work well :-)
+    32,  33,  34,  35,  36,  37,  38,  39,
+/\(**   (    )    *    +    ,    \-    .    / */
+    40,  41,  42,  43,  44,  45,  46,  47,
+/\(**   0    1    2    3    4    5    6    7 */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**   8    9    :    ;    <    =    >    ? */
+    48,  48,  58,  59,  60,  61,  62,  63,
+/\(**   @    A    B    C    D    E    F    G */
+    64,  48,  48,  48,  48,  48,  48,  48,
+/\(**   H    I    J    K    L    M    N    O */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**   P    Q    R    S    T    U    V    W */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**   X    Y    Z    [    \\    ]    ^    _ */
+    48,  48,  48,  91,  92,  93,  94,  48,
+/\(**   `    a    b    c    d    e    f    g */
+    96,  48,  48,  48,  48,  48,  48,  48,
+/\(**   h    i    j    k    l    m    n    o */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**   p    q    r    s    t    u    v    w */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**   x    y    z    {    |    }    ~  DEL */
+    48,  48,  48, 123, 124, 125, 126,   1,
+/\(** x80  x81  x82  x83  IND  NEL  SSA  ESA */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/\(** HTS  HTJ  VTS  PLD  PLU   RI  SS2  SS3 */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/\(** DCS  PU1  PU2  STS  CCH   MW  SPA  EPA */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/\(** x98  x99  x9A  CSI   ST  OSC   PM  APC */
+     1,   1,   1,   1,   1,   1,   1,   1,
+/\(**   \-    i   c/    L   ox   Y\-    |   So */
+   160, 161, 162, 163, 164, 165, 166, 167,
+/\(**  ..   c0   ip   <<    _        R0    \- */
+   168, 169, 170, 171, 172, 173, 174, 175,
+/\(**   o   +\-    2    3    \*(AQ    u   q|    . */
+   176, 177, 178, 179, 180, 181, 182, 183,
+/\(**   ,    1    2   >>  1/4  1/2  3/4    ? */
+   184, 185, 186, 187, 188, 189, 190, 191,
+/\(**  A`   A\*(AQ   A^   A~   A:   Ao   AE   C, */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**  E`   E\*(AQ   E^   E:   I`   I\*(AQ   I^   I: */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**  D\-   N~   O`   O\*(AQ   O^   O~   O:    X */
+    48,  48,  48,  48,  48,  48,  48, 215,
+/\(**  O/   U`   U\*(AQ   U^   U:   Y\*(AQ    P    B */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**  a`   a\*(AQ   a^   a~   a:   ao   ae   c, */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**  e`   e\*(AQ   e^   e:    i`  i\*(AQ   i^   i: */
+    48,  48,  48,  48,  48,  48,  48,  48,
+/\(**   d   n~   o`   o\*(AQ   o^   o~   o:   \-: */
+    48,  48,  48,  48,  48,  48,  48, 247,
+/\(**  o/   u`   u\*(AQ   u^   u:   y\*(AQ    P   y: */
+    48,  48,  48,  48,  48,  48,  48,  48};
+.NE
+For example, the string \*(``33:48,37:48,45\-47:48,38:48\*('' indicates that the
+exclamation mark, percent sign, dash, period, slash, and ampersand characters
+should be treated the same way as characters and numbers.
+This is useful
+for cutting and pasting electronic mailing addresses and filenames.
+.
+.
+.SH ACTIONS
+It is possible to rebind keys (or sequences of keys) to arbitrary strings
+for input, by changing the \fBtranslations\fP resources
+for the vt100 or tek4014 widgets.
+Changing the \fBtranslations\fP resource
+for events other than key and button events is not expected,
+and will cause unpredictable behavior.
+The following
+actions are provided for use within the \fIvt100\fP or \fItek4014\fP
+\fBtranslations\fP resources:
+.TP 8
+.B "allow-color-ops(\fIon/off/toggle\fP)"
+This action set or toggles the \fBallowColorOps\fP resource and is also
+invoked by the \fBallow-color-ops\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "allow-font-ops(\fIon/off/toggle\fP)"
+This action set or toggles the \fBallowFontOps\fP resource and is also
+invoked by the \fBallow-font-ops\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "allow-send-events(\fIon/off/toggle\fP)"
+This action set or toggles the \fBallowSendEvents\fP resource and is also
+invoked by the \fBallowsends\fP entry in \fImainMenu\fP.
+.TP 8
+.B "allow-tcap-ops(\fIon/off/toggle\fP)"
+This action set or toggles the \fBallowTcapOps\fP resource and is also
+invoked by the \fBallow-tcap-ops\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "allow-title-ops(\fIon/off/toggle\fP)"
+This action set or toggles the \fBallowTitleOps\fP resource and is also
+invoked by the \fBallow-title-ops\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "allow-window-ops(\fIon/off/toggle\fP)"
+This action set or toggles the \fBallowWindowOps\fP resource and is also
+invoked by the \fBallow-window-ops\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "alt-sends-escape()"
+This action toggles the state of the \fBeightBitInput\fP resource.
+.TP 8
+.B "bell([\fIpercent\fP])"
+This action rings the keyboard bell at the specified percentage
+above or below the base volume.
+.TP 8
+.B "clear-saved-lines()"
+This action does \fBhard-reset()\fP (see below) and also clears the history
+of lines saved off the top of the screen.
+It is also invoked from the \fBclearsavedlines\fP entry in \fIvtMenu\fP.
+The effect is identical to a hardware reset (RIS) control sequence.
+.TP 8
+.B "copy-selection(\fIdestname\fP [, ...])"
+This action puts the currently selected text into all of the selections or
+cutbuffers specified by \fIdestname\fP.
+Unlike \fBselect-end\fP, it does not send a mouse position or otherwise
+modify the internal selection state.
+.TP 8
+.B "create-menu(\fIm/v/f/t\fP)"
+This action creates one of the menus used by \fIxterm\fP,
+if it has not been previously created.
+The parameter values are the menu names:
+\fImainMenu\fP, \fIvtMenu\fP, \fIfontMenu\fP, \fItekMenu\fP, respectively.
+.TP 8
+.B "dabbrev-expand()"
+Expands the word before cursor by searching in the preceding text on the
+screen and in the scrollback buffer for words starting with that
+abbreviation.
+Repeating \fBdabbrev-expand()\fP several times in sequence searches for an
+alternative expansion by looking farther back.
+Lack of more matches is signaled by a \fBbeep()\fP.
+Attempts to expand an empty word
+(i.e., when cursor is preceded by a space) yield successively all previous
+words.
+Consecutive identical expansions are ignored.
+The word here is defined as a sequence of non-whitespace characters.
+This feature partially emulates the behavior
+of \*(``dynamic abbreviation\*('' expansion in Emacs (bound there to M\-/).
+Here is a resource setting for \fIxterm\fP which will do the same thing:
+.NS
+*VT100*translations:    #override \\n\\\&
+       Meta <KeyPress> /:dabbrev-expand()
+.NE
+.TP 8
+.B "deiconify()"
+Changes the window state back to normal, if it was iconified.
+.TP 8
+.B "delete-is-del()"
+This action toggles the state of the \fBdeleteIsDEL\fP resource.
+.TP 8
+.B "dired-button()"
+Handles a button event (other than press and release)
+by echoing the event's position
+(i.e., character line and column) in the following format:
+.sp
+.in +8
+^X ESC G <line+\*(`` \*(''> <col+\*(`` \*(''>
+.in -8
+.TP 8
+.B "fullscreen()"
+Asks the window manager to change the window to full-screen.
+.TP 8
+.B "iconify()"
+Iconifies the window.
+.TP 8
+.B "hard-reset()"
+This action resets the scrolling region, tabs, window size, and cursor keys
+and clears the screen.
+It is also invoked from the \fBhardreset\fP
+entry in \fIvtMenu\fP.
+.TP 8
+.B "ignore()"
+This action ignores the event but checks for special pointer position
+escape sequences.
+.TP 8
+.B "insert()"
+This action inserts the character or string associated with
+the key that was pressed.
+.TP 8
+.B "insert-eight-bit()"
+This action inserts an eight-bit (Meta) version of the character or string
+associated with the key that was pressed.
+This only applies to single-byte values.
+The exact action depends on the value of
+the \fBmetaSendsEscape\fP and
+the \fBeightBitInput\fP resources.
+The \fBmetaSendsEscape\fP resource is tested first.
+.IP
+The term "eight-bit" is misleading:
+\fIxterm\fP checks if the key's value is less than 128.
+If so, \fIxterm\fP adds 128 to the value, setting its eighth bit.
+Otherwise \fIxterm\fP sends an ESC byte before the key.
+In other applications' documentation, that is referred to as a "meta key".
+.TP 8
+.B "insert-selection(\fIsourcename\fP [, ...])"
+This action inserts the string found in the selection or cutbuffer indicated
+by \fIsourcename\fP.
+Sources are checked in the order given (case is
+significant) until one is found.
+Commonly-used selections include:
+\fIPRIMARY\fP, \fISECONDARY\fP, and \fICLIPBOARD\fP.
+Cut buffers are
+typically named \fICUT_BUFFER0\fP through \fICUT_BUFFER7\fP.
+.TP 8
+.B "insert-seven-bit()"
+This action is a synonym for \fBinsert()\fP
+The term "seven-bit" is misleading:
+it only implies that \fIxterm\fP does not try to add 128 to the key's value
+as in \fBinsert-eight-bit()\fP.
+.TP 8
+.B "interpret(\fIcontrol-sequence\fP)"
+Interpret the given control sequence locally, i.e., without passing it to
+the host.
+This works by inserting the control sequence at the front
+of the input buffer.
+Use "\\" to escape octal digits in the string.
+Xt does not allow you to put a null character (i.e., "\\000") in the string.
+.TP 8
+.B "keymap(\fIname\fP)"
+This action dynamically defines a new translation table whose resource
+name is \fIname\fP with the suffix \fIKeymap\fP (case is significant).
+The name \fINone\fP restores the original translation table.
+.TP 8
+.B "larger-vt-font()"
+Set the font to the next larger one, based on the font dimensions.
+See also \fBset-vt-font()\fP.
+.TP 8
+.B "load-vt-fonts(\fIname\fP[,\fIclass\fP])"
+Load fontnames from the given subresource name and class.
+That is, load the "*VT100.\fIname\fP.font", resource as "*VT100.font" etc.
+If no name is given, the original set of fontnames is restored.
+.IP
+Unlike \fBset-vt-font()\fR, this does not affect the escape- and select-fonts,
+since those are not based on resource values.
+It does affect the fonts loosely organized under the \*(``Default\*('' menu
+entry, including \fBfont\fP, \fBboldFont\fP, \fBwideFont\fP and \fBwideBoldFont\fP.
+.TP 8
+.B "maximize()"
+Resizes the window to fill the screen.
+.TP 8
+.B "meta-sends-escape()"
+This action toggles the state of the \fBmetaSendsEscape\fP resource.
+.TP 8
+.B "popup-menu(\fImenuname\fP)"
+This action displays the specified popup menu.
+Valid names (case is
+significant) include:  \fImainMenu\fP, \fIvtMenu\fP, \fIfontMenu\fP,
+and \fItekMenu\fP.
+.TP 8
+.B "print(\fIprinter-flags\fP)"
+This action prints the window and is also invoked by the
+\fIprint\fP entry in \fImainMenu\fP.
+.IP
+The action accepts optional parameters, which temporarily override
+resource settings.
+The parameter values are matched ignoring case:
+.RS
+.TP 5
+noFormFeed
+no form feed will be sent at the end of the last line printed
+(i.e., \fBprinterFormFeed\fP is ``false'').
+.TP 5
+FormFeed
+a form feed will be sent at the end of the last line printed
+(i.e., \fBprinterFormFeed\fP is ``true'').
+.TP 5
+noNewLine
+no newline will be sent at the end of the last line printed,
+and wrapped lines will be combined into long lines
+(i.e., \fBprinterNewLine\fP is ``false'').
+.TP 5
+NewLine
+a newline will be sent at the end of the last line printed,
+and each line will be limited (by adding a newline) to the screen width
+(i.e., \fBprinterNewLine\fP is ``true'').
+.TP 5
+noAttrs
+the page is printed without attributes
+(i.e., \fBprintAttributes\fP is ``0'').
+.TP 5
+monoAttrs
+the page is printed with monochrome (vt220) attributes
+(i.e., \fBprintAttributes\fP is ``1'').
+.TP 5
+colorAttrs
+the page is printed with ANSI color attributes
+(i.e., \fBprintAttributes\fP is ``2'').
+.RE
+.TP 8
+.B "print-everything(\fIprinter-flags\fP)"
+This action sends the entire text history, in addition to the text
+currently visible, to the program given in the \fBprinterCommand\fP resource.
+It allows the same optional parameters as the \fBprint\fP action.
+With a suitable printer command, the action can be used to load the text
+history in an editor.
+.TP 8
+.B "print-redir()"
+This action toggles the \fBprinterControlMode\fR between 0 and 2.
+The corresponding popup menu entry is useful for switching the printer
+off if you happen to change your mind after deciding to print random
+binary files on the terminal.
+.TP 8
+.B "quit()"
+This action sends a SIGHUP to the subprogram and exits.
+It is also invoked
+by the \fBquit\fP entry in \fImainMenu\fP.
+.TP 8
+.B "readline-button()"
+Supports the optional readline feature by echoing repeated cursor forward
+or backward control sequences on button release event,
+to request that the host application update its notion of the cursor's
+position to match the button event.
+.TP 8
+.B "redraw()"
+This action redraws the window and is also invoked by the
+\fIredraw\fP entry in \fImainMenu\fP.
+.TP 8
+.B "restore()"
+Restores the window to the size before it was last maximized.
+.TP 8
+.B "scroll-back(\fIcount\fP [,\fIunits\fP [,\fImouse\fP] ])"
+This action scrolls the text window backward so that text that had previously
+scrolled off the top of the screen is now visible.
+.IP
+The \fIcount\fP argument
+indicates the number of \fIunits\fP (which may be \fIpage\fP, \fIhalfpage\fP,
+\fIpixel\fP, or \fIline\fP) by which to scroll.
+.IP
+An adjustment can be specified for these values by appending a "+" or "\-"
+sign followed by a number,
+e.g., \fIpage\-2\fP to specify 2 lines less than a page.
+.IP
+If the third parameter \fImouse\fP is given, the action is ignored when
+mouse reporting is enabled.
+.TP 8
+.B "scroll-forw(\fIcount\fP [,\fIunits\fP [,\fImouse\fP] ])"
+This action is similar to \fBscroll-back\fP except that it scrolls
+in the other direction.
+.TP 8
+.B "secure()"
+This action toggles the \fISecure Keyboard\fP mode described in the
+section named \fBSECURITY\fP, and is invoked from the \fBsecurekbd\fP
+entry in \fImainMenu\fP.
+.TP 8
+.B "scroll-lock(\fIon/off/toggle\fP)"
+This action toggles internal state which tells
+\fIxterm\fP whether Scroll Lock is active,
+subject to the \fBallowScrollLock\fP resource.
+.TP 8
+.B "select-cursor-end(\fIdestname\fP [, ...])"
+This action is similar to \fBselect-end\fP except that it should be used
+with \fBselect-cursor-start\fP.
+.TP 8
+.B "select-cursor-extend()"
+This action is similar to \fBselect-extend\fP except that it should be used
+with \fBselect-cursor-start\fP.
+.TP 8
+.B "select-cursor-start()"
+This action is similar to \fBselect-start\fP except that it begins the
+selection at the current text cursor position.
+.TP 8
+.B "select-end(\fIdestname\fP [, ...])"
+This action puts the currently selected text into all of the selections or
+cutbuffers specified by \fIdestname\fP.
+It also sends a mouse position and updates the internal selection state
+to reflect the end of the selection process.
+.TP 8
+.B "select-extend()"
+This action tracks the pointer and extends the selection.
+It should only be bound to Motion events.
+.TP 8
+.B "select-set()"
+This action stores text that corresponds to the current selection,
+without affecting the selection mode.
+.TP 8
+.B "select-start()"
+This action begins text selection at the current pointer location.
+See
+the section on \fBPOINTER USAGE\fP for information on making selections.
+.TP 8
+.B "send-signal(\fIsigname\fP)"
+This action sends the signal named by \fIsigname\fP
+to the \fIxterm\fP subprocess (the shell or program specified with
+the \fI\-e\fP command line option) and is also invoked by the
+.BR suspend ,
+.BR continue ,
+.BR interrupt ,
+.BR hangup ,
+.BR terminate ,
+and
+.BR kill
+entries in \fImainMenu\fP.
+Allowable signal names are (case is
+not significant):
+\fItstp\fP (if supported by the operating system), \fIsuspend\fP (same
+as \fItstp\fP), \fIcont\fP
+(if supported by the operating system), \fIint\fP, \fIhup\fP, \fIterm\fP,
+\fIquit\fP,
+\fIalrm\fP, \fIalarm\fP (same as \fIalrm\fP) and \fIkill\fP.
+.TP 8
+.B "set-8-bit-control(\fIon/off/toggle\fP)"
+This action toggles the \fBeightBitControl\fP resource and is also invoked from the
+\fB8-bit-control\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-allow132(\fIon/off/toggle\fP)"
+This action toggles the \fBc132\fP resource and is also invoked from the
+\fBallow132\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-altscreen(\fIon/off/toggle\fP)"
+This action toggles between the alternate and current screens.
+.TP 8
+.B "set-appcursor(\fIon/off/toggle\fP)"
+This action toggles the handling Application Cursor Key mode
+and is also invoked by the \fBappcursor\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-appkeypad(\fIon/off/toggle\fP)"
+This action toggles the handling of Application Keypad mode and is also
+invoked by the \fBappkeypad\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-autolinefeed(\fIon/off/toggle\fP)"
+This action toggles automatic insertion of linefeeds and is also invoked by
+the \fBautolinefeed\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-autowrap(\fIon/off/toggle\fP)"
+This action toggles automatic wrapping of long lines and is also invoked by
+the \fBautowrap\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-backarrow(\fIon/off/toggle\fP)"
+This action toggles the \fBbackarrowKey\fP resource and is also invoked from the
+\fBbackarrow key\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-bellIsUrgent(\fIon/off/toggle\fP)"
+This action toggles the \fBbellIsUrgent\fP resource and is also invoked
+by the \fBbellIsUrgent\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-cursorblink(\fIon/off/toggle\fP)"
+This action toggles the \fBcursorBlink\fP resource and is also invoked from the
+\fBcursorblink\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-cursesemul(\fIon/off/toggle\fP)"
+This action toggles the \fBcurses\fP resource and is also invoked from the
+\fBcursesemul\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-font-doublesize(\fIon/off/toggle\fP)"
+This action toggles the \fBfontDoublesize\fP resource and is also invoked by
+the \fBfont-doublesize\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "set-hp-function-keys(\fIon/off/toggle\fP)"
+This action toggles the \fBhpFunctionKeys\fP resource and is also invoked by
+the \fBhpFunctionKeys\fP entry in \fImainMenu\fP.
+.TP 8
+.B "set-jumpscroll(\fIon/off/toggle\fP)"
+This action toggles the \fBjumpscroll\fP resource and is also invoked by the
+\fBjumpscroll\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-font-linedrawing(\fIon/off/toggle\fP)"
+This action toggles the \fIxterm\fR's state regarding whether the current font
+has line-drawing characters and whether it should draw them directly.
+It is also invoked by the \fBfont-linedrawing\fP entry in \fIfontMenu\fP.
+.\" .\" not implemented
+.\" .TP 8
+.\" .B "set-font-loading(\fIon/off/toggle\fP)"
+.\" This action toggles the TBD resource
+.\" which controls the ability to load VT220 soft fonts.
+.\" It is also invoked by the \fBfont-loadable\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "set-font-packed(\fIon/off/toggle\fP)"
+This action toggles the \fIforcePackedFont\fR's resource
+which controls use of the font's minimum or maximum glyph width.
+It is also invoked by the \fBfont-packed\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "set-keep-selection(\fIon/off/toggle\fP)"
+This action toggles the \fBkeepSelection\fP resource and is also invoked by
+the \fBkeepSelection\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-logging()"
+This action toggles the state of the logging option.
+.TP 8
+.B "set-old-function-keys(\fIon/off/toggle\fP)"
+This action toggles the state of legacy function keys and is also invoked by
+the \fBoldFunctionKeys\fP entry in \fImainMenu\fP.
+.TP 8
+.B "set-marginbell(\fIon/off/toggle\fP)"
+This action toggles the \fBmarginBell\fP resource.
+.TP 8
+.B "set-num-lock()"
+This action toggles the state of the \fBnumLock\fP resource.
+.TP 8
+.B "set-pop-on-bell(\fIon/off/toggle\fP)"
+This action toggles the \fBpopOnBell\fP resource and is also invoked
+by the \fBpoponbell\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-render-font(\fIon/off/toggle\fP)"
+This action toggles the \fBrenderFont\fP resource and is also invoked by
+the \fBrender-font\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "set-reverse-video(\fIon/off/toggle\fP)"
+This action toggles the \fBreverseVideo\fP resource and is also invoked by
+the \fBreversevideo\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-reversewrap(\fIon/off/toggle\fP)"
+This action toggles the \fBreverseWrap\fP resource and is also invoked by
+the \fBreversewrap\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-scroll-on-key(\fIon/off/toggle\fP)"
+This action toggles the \fBscrollKey\fP resource and is also invoked from
+the \fBscrollkey\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-scroll-on-tty-output(\fIon/off/toggle\fP)"
+This action toggles the \fBscrollTtyOutput\fP resource and is also invoked
+from the \fBscrollttyoutput\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-scrollbar(\fIon/off/toggle\fP)"
+This action toggles the \fBscrollbar\fP resource and is also invoked by
+the \fBscrollbar\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-select(\fIon/off/toggle\fP)"
+This action toggles the \fBselectToClipboard\fP resource and is also invoked by
+the \fBselectToClipboard\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-sco-function-keys(\fIon/off/toggle\fP)"
+This action toggles the \fBscoFunctionKeys\fP resource and is also invoked by
+the \fBscoFunctionKeys\fP entry in \fImainMenu\fP.
+.TP 8
+.B "set-sun-function-keys(\fIon/off/toggle\fP)"
+This action toggles the \fBsunFunctionKeys\fP resource and is also invoked by
+the \fBsunFunctionKeys\fP entry in \fImainMenu\fP.
+.TP 8
+.B "set-sun-keyboard(\fIon/off/toggle\fP)"
+This action toggles the \fBsunKeyboard\fP resource and is also invoked by
+the \fBsunKeyboard\fP entry in \fImainMenu\fP.
+.TP 8
+.B "set-tek-text(\fIlarge/2/3/small\fP)"
+This action sets font used in the Tektronix window to the value of the
+resources \fBtektextlarge\fP, \fBtektext2\fP, \fBtektext3\fP, and
+\fBtektextsmall\fP according to the argument.
+It is also invoked by the entries
+of the same names as the resources in \fItekMenu\fP.
+.TP 8
+.B "set-terminal-type(\fItype\fP)"
+This action directs output to either the \fIvt\fP or \fItek\fP windows,
+according to the \fItype\fP string.
+It is also invoked by the
+\fBtekmode\fP entry in \fIvtMenu\fP and the \fBvtmode\fP entry in
+\fItekMenu\fP.
+.TP 8
+.B "set-titeInhibit(\fIon/off/toggle\fP)"
+This action toggles the \fBtiteInhibit\fP resource,
+which controls switching between the alternate and current screens.
+.TP 8
+.B "set-toolbar(\fIon/off/toggle\fP)"
+This action toggles the toolbar feature and is also invoked by
+the \fBtoolbar\fP entry in \fImainMenu\fP.
+.TP 8
+.B "set-utf8-mode(\fIon/off/toggle\fP)"
+This action toggles the \fButf8\fP resource and is also invoked by
+the \fButf8-mode\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "set-utf8-title(\fIon/off/toggle\fP)"
+This action toggles the \fButf8Title\fP resource and is also invoked by
+the \fButf8-title\fP entry in \fIfontMenu\fP.
+.TP 8
+.B "set-visibility(\fIvt/tek\fP,\fIon/off/toggle\fP)"
+This action controls whether or not the \fIvt\fP or \fItek\fP windows are
+visible.
+It is also invoked from the \fBtekshow\fP and \fBvthide\fP entries
+in \fIvtMenu\fP and the \fBvtshow\fP and \fBtekhide\fP entries in
+\fItekMenu\fP.
+.TP 8
+.B "set-visual-bell(\fIon/off/toggle\fP)"
+This action toggles the \fBvisualBell\fP resource and is also invoked
+by the \fBvisualbell\fP entry in \fIvtMenu\fP.
+.TP 8
+.B "set-vt-font(\fId/1/2/3/4/5/6/e/s\fP [,\fInormalfont\fP [, \fIboldfont\fP]])"
+This action sets the font or fonts currently being used in the VT102 window.
+The first argument is a single character that specifies the font to be
+used:
+.RS 8
+.HP
+\fId\fP or \fID\fP indicate the default font (the font initially
+used when
+\fIxterm\fP was started),
+.HP
+\fI1\fP through \fI6\fP indicate the fonts
+specified by the \fIfont1\fP through \fIfont6\fP resources,
+.HP
+\fIe\fP or \fIE\fP
+indicate the normal and bold fonts that have been set through escape codes
+(or specified as the second and third action arguments, respectively), and
+.HP
+\fIs\fP or \fIS\fP indicate the font selection (as made by programs such as
+\fIxfontsel(__mansuffix__)\fP) indicated by the second action argument.
+.RE
+.IP
+If \fIxterm\fR is configured to support wide characters, an
+additional two optional parameters are recognized for the \fIe\fP argument:
+wide font and wide bold font.
+.TP 8
+.B "smaller-vt-font()"
+Set the font to the next smaller one, based on the font dimensions.
+See also \fBset-vt-font()\fP.
+.TP 8
+.B "soft-reset()"
+This action resets the scrolling region and is also invoked from the
+\fBsoftreset\fP entry in \fIvtMenu\fP.
+The effect is identical to a soft reset (DECSTR) control sequence.
+.TP 8
+.B "spawn-new-terminal(params)"
+Spawn a new \fIxterm\fP process.
+This is available on systems which have a modern version of the
+process filesystem, e.g., "/proc", which \fIxterm\fP can read.
+.IP
+Use the "cwd" process entry, e.g., /proc/12345/cwd to obtain the
+working directory of the process which is running in the current \fIxterm\fP.
+.IP
+On systems which have the "exe" process entry, e.g., /proc/12345/exe,
+use this to obtain the actual executable.
+Otherwise, use the $PATH variable to find \fIxterm\fP.
+.IP
+If parameters are given in the action,
+pass them to the new \fIxterm\fP process.
+.TP 8
+.B "start-extend()"
+This action is similar to \fBselect-start\fP except that the
+selection is extended to the current pointer location.
+.TP 8
+.B "start-cursor-extend()"
+This action is similar to \fBselect-extend\fP except that the
+selection is extended to the current text cursor position.
+.TP 8
+.B "string(\fIstring\fP)"
+This action inserts the specified text string as if it had been typed.
+Quotation is necessary if the string contains whitespace or
+non-alphanumeric characters.
+If the string argument begins with the
+characters \*(``0x\*('', it is interpreted
+as a hex character constant.
+.TP 8
+.B "tek-copy()"
+This action copies the escape codes used to generate the current window
+contents to a file in the current directory beginning with the name COPY.
+It is also invoked from the \fItekcopy\fP entry in \fItekMenu\fP.
+.TP 8
+.B "tek-page()"
+This action clears the Tektronix window and is also invoked by the
+\fBtekpage\fP entry in \fItekMenu\fP.
+.TP 8
+.B "tek-reset()"
+This action resets the Tektronix window and is also invoked by the
+\fItekreset\fP entry in \fItekMenu\fP.
+.TP 8
+.B "vi-button()"
+Handles a button event (other than press and release)
+by echoing a control sequence computed from the event's line number
+in the screen relative to the current line:
+.sp
+.in +8
+ESC ^P
+.in -8
+or
+.in +8
+ESC ^N
+.in -8
+.sp
+according to whether the event is before, or after the current line,
+respectively.
+The ^N (or ^P) is repeated once for each line that the event differs
+from the current line.
+The control sequence is omitted altogether if the button event is on the
+current line.
+.TP 8
+.B "visual-bell()"
+This action flashes the window quickly.
+.
+.PP
+The Tektronix window also has the following action:
+.TP 8
+.B "gin-press(\fIl/L/m/M/r/R\fP)"
+This action sends the indicated graphics input code.
+.
+.PP
+The default bindings in the VT102 window use the SELECT token,
+which is set by the \fBselectToClipboard\fP resource:
+.NS
+.ta 2.5i
+          Shift <KeyPress> Prior:scroll-back(1,halfpage) \\n\\\&
+           Shift <KeyPress> Next:scroll-forw(1,halfpage) \\n\\\&
+         Shift <KeyPress> Select:select-cursor-start() \\\&
+                                 select-cursor-end(SELECT, CUT_BUFFER0) \\n\\\&
+         Shift <KeyPress> Insert:insert-selection(SELECT, CUT_BUFFER0) \\n\\\&
+                 Alt <Key>Return:fullscreen()\n\
+        <KeyRelease> Scroll_Lock:scroll-lock() \\n\\\&
+    Shift~Ctrl <KeyPress> KP_Add:larger-vt-font() \\n\\\&
+    Shift Ctrl <KeyPress> KP_Add:smaller-vt-font() \\n\\\&
+    Shift <KeyPress> KP_Subtract:smaller-vt-font() \\n\\\&
+                ~Meta <KeyPress>:insert-seven-bit() \\n\\\&
+                 Meta <KeyPress>:insert-eight-bit() \\n\\\&
+                !Ctrl <Btn1Down>:popup-menu(mainMenu) \\n\\\&
+           !Lock Ctrl <Btn1Down>:popup-menu(mainMenu) \\n\\\&
+ !Lock Ctrl @Num_Lock <Btn1Down>:popup-menu(mainMenu) \\n\\\&
+     ! @Num_Lock Ctrl <Btn1Down>:popup-menu(mainMenu) \\n\\\&
+                ~Meta <Btn1Down>:select-start() \\n\\\&
+              ~Meta <Btn1Motion>:select-extend() \\n\\\&
+                !Ctrl <Btn2Down>:popup-menu(vtMenu) \\n\\\&
+           !Lock Ctrl <Btn2Down>:popup-menu(vtMenu) \\n\\\&
+ !Lock Ctrl @Num_Lock <Btn2Down>:popup-menu(vtMenu) \\n\\\&
+     ! @Num_Lock Ctrl <Btn2Down>:popup-menu(vtMenu) \\n\\\&
+          ~Ctrl ~Meta <Btn2Down>:ignore() \\n\\\&
+                 Meta <Btn2Down>:clear-saved-lines() \\n\\\&
+            ~Ctrl ~Meta <Btn2Up>:insert-selection(SELECT, CUT_BUFFER0) \\n\\\&
+                !Ctrl <Btn3Down>:popup-menu(fontMenu) \\n\\\&
+           !Lock Ctrl <Btn3Down>:popup-menu(fontMenu) \\n\\\&
+ !Lock Ctrl @Num_Lock <Btn3Down>:popup-menu(fontMenu) \\n\\\&
+     ! @Num_Lock Ctrl <Btn3Down>:popup-menu(fontMenu) \\n\\\&
+          ~Ctrl ~Meta <Btn3Down>:start-extend() \\n\\\&
+              ~Meta <Btn3Motion>:select-extend() \\n\\\&
+                 Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \\n\\\&
+            Lock Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \\n\\\&
+  Lock @Num_Lock Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \\n\\\&
+       @Num_Lock Ctrl <Btn4Down>:scroll-back(1,halfpage,m) \\n\\\&
+                      <Btn4Down>:scroll-back(5,line,m)     \\n\\\&
+                 Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \\n\\\&
+            Lock Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \\n\\\&
+  Lock @Num_Lock Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \\n\\\&
+       @Num_Lock Ctrl <Btn5Down>:scroll-forw(1,halfpage,m) \\n\\\&
+                      <Btn5Down>:scroll-forw(5,line,m)     \\n\\\&
+                         <BtnUp>:select-end(SELECT, CUT_BUFFER0) \\n\\\&
+                       <BtnDown>:ignore()
+.NE
+.PP
+The default bindings for the scrollbar widget
+are separate from the VT100 widget:
+.NS
+.ta 2.5i
+                      <Btn5Down>: StartScroll(Forward) \\n\\\&
+                      <Btn1Down>: StartScroll(Forward) \\n\\\&
+                      <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \\n\\\&
+                      <Btn3Down>: StartScroll(Backward) \\n\\\&
+                      <Btn4Down>: StartScroll(Backward) \\n\\\&
+                      <Btn2Motion>: MoveThumb() NotifyThumb() \\n\\\&
+                      <BtnUp>:    NotifyScroll(Proportional) EndScroll()
+.NE
+.PP
+The default bindings in the Tektronix window are:
+.NS
+.ta 2.5i
+                 ~Meta<KeyPress>: insert-seven-bit() \\n\\\&
+                  Meta<KeyPress>: insert-eight-bit() \\n\\\&
+                !Ctrl <Btn1Down>: popup-menu(mainMenu) \\n\\\&
+           !Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \\n\\\&
+ !Lock Ctrl @Num_Lock <Btn1Down>: popup-menu(mainMenu) \\n\\\&
+      !Ctrl @Num_Lock <Btn1Down>: popup-menu(mainMenu) \\n\\\&
+                !Ctrl <Btn2Down>: popup-menu(tekMenu) \\n\\\&
+           !Lock Ctrl <Btn2Down>: popup-menu(tekMenu) \\n\\\&
+ !Lock Ctrl @Num_Lock <Btn2Down>: popup-menu(tekMenu) \\n\\\&
+      !Ctrl @Num_Lock <Btn2Down>: popup-menu(tekMenu) \\n\\\&
+           Shift ~Meta<Btn1Down>: gin-press(L) \\n\\\&
+                 ~Meta<Btn1Down>: gin-press(l) \\n\\\&
+           Shift ~Meta<Btn2Down>: gin-press(M) \\n\\\&
+                 ~Meta<Btn2Down>: gin-press(m) \\n\\\&
+           Shift ~Meta<Btn3Down>: gin-press(R) \\n\\\&
+                 ~Meta<Btn3Down>: gin-press(r)
+.NE
+.PP
+Here is an example which uses shifted select/paste to copy to the clipboard,
+and unshifted select/paste for the primary selection.
+In each case, a (different) cut buffer is
+also a target or source of the select/paste operation.
+It is important to remember however,
+that cut buffers store data in ISO-8859-1 encoding,
+while selections can store data in a variety of formats and encodings.
+While \fIxterm\fP owns the selection, it highlights it.
+When it loses the selection, it removes the corresponding highlight.
+But you can still paste from the corresponding cut buffer.
+.NS
+.ta .5i 1.5i
+*VT100*translations:    #override \\n\\\&
+    ~Shift~Ctrl<Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0) \\n\\\&
+    Shift~Ctrl<Btn2Up>:  insert-selection(CLIPBOARD, CUT_BUFFER1) \\n\\\&
+    ~Shift<BtnUp>:       select-end(PRIMARY, CUT_BUFFER0) \\n\\\&
+    Shift<BtnUp>:        select-end(CLIPBOARD, CUT_BUFFER1)
+.NE
+.PP
+Below is a sample how of the \fBkeymap()\fP action is used to add special
+keys for entering commonly-typed works:
+.NS
+.ta .5i 1.5i
+*VT100.Translations: #override <Key>F13: keymap(dbx)
+*VT100.dbxKeymap.translations: \\\&
+       <Key>F14:       keymap(None) \\n\\\&
+       <Key>F17:       string("next") string(0x0d) \\n\\\&
+       <Key>F18:       string("step") string(0x0d) \\n\\\&
+       <Key>F19:       string("continue") string(0x0d) \\n\\\&
+       <Key>F20:       string("print ") insert-selection(PRIMARY, CUT_BUFFER0)
+.NE
+.PP
+Some people prefer using the left pointer button
+for dragging the scrollbar thumb.
+That can be setup by altering the translations resource, e.g.,
+.NS
+.ta .5i 1.5i
+*VT100.scrollbar.translations: #override \\n\\\&
+       <Btn5Down>:     StartScroll(Forward) \\n\\\&
+       <Btn1Down>:     StartScroll(Continuous) MoveThumb() NotifyThumb() \\n\\\&
+       <Btn4Down>:     StartScroll(Backward) \\n\\\&
+       <Btn1Motion>:   MoveThumb() NotifyThumb() \\n\\\&
+       <BtnUp>:        NotifyScroll(Proportional) EndScroll()
+.NE
+.SH "CONTROL SEQUENCES AND KEYBOARD"
+The \fIXterm Control Sequences\fP document lists the control sequences which
+an application can send \fIxterm\fP to make it perform various operations.
+Most of these operations are standardized, from either the DEC or Tektronix
+terminals, or from more widely used standards such as ISO-6429.
+.
+.
+.SH ENVIRONMENT
+.I Xterm
+sets several environment variables:
+.TP 5
+DISPLAY
+is the display name,
+pointing to the X server (see \fBDISPLAY NAMES\fP in X(__miscmansuffix__)).
+.TP 5
+TERM
+is set according to the termcap (or terminfo) entry which it is using as
+a reference.
+.TP 5
+WINDOWID
+is set to the X window id number of the \fIxterm\fP window.
+.TP 5
+XTERM_LOCALE
+shows the locale which was used by \fIxterm\fP on startup.
+Some shell initialization scripts may set a different locale.
+.TP 5
+XTERM_SHELL
+is set to the pathname of the program which is invoked.
+Usually that is a shell program, e.g., \fI/bin/sh\fP.
+Since it is not necessarily a shell program however,
+it is distinct from \*(``SHELL\*(''.
+.TP 5
+XTERM_VERSION
+is set to the string displayed by the \fB\-version\fP option.
+That is normally an identifier for the X Window libraries used to
+build \fIxterm\fP, followed by
+\fIxterm\fP's patch number in parenthesis.
+The patch number is also part of the response to a Secondary Device Attributes
+(DA) control sequence (see \fIXterm Control Sequences\fP).
+.
+.PP
+Depending on your system configuration, \fIxterm\fP may also set the
+following:
+.TP 5
+COLUMNS
+the width of the \fIxterm\fP in characters (cf: "stty columns").
+.TP 5
+HOME
+when \fIxterm\fP is configured to update utmp.
+.TP 5
+LINES
+the height of the \fIxterm\fP in characters (cf: "stty rows").
+.TP 5
+LOGNAME
+when \fIxterm\fP is configured to update utmp.
+.TP 5
+SHELL
+when \fIxterm\fP is configured to update utmp.
+It is also set if you provide the shell name as the optional parameter.
+.TP 5
+TERMCAP
+the contents of the termcap entry corresponding to $TERM,
+with lines and columns values substituted
+for the actual size window you have created.
+.TP 5
+TERMINFO
+may be defined to a nonstandard location in the configure script.
+.\"
+.
+.
+.SH FILES
+The actual pathnames given may differ on your system.
+.TP 5
+\fI/etc/utmp\fP
+the system logfile, which records user logins.
+.TP 5
+\fI/etc/wtmp\fP
+the system logfile, which records user logins and logouts.
+.TP 5
+.I __apploaddir__/XTerm
+the \fIxterm\fP default application resources.
+.TP 5
+.I __apploaddir__/XTerm\-color
+the \fIxterm\fP color application resources.
+If your display supports color, use this
+.in +10
+*customization: \-color
+.in -10
+in your .Xdefaults file to
+automatically use this resource file rather than
+.IR __apploaddir__/XTerm .
+If you do not do this,
+\fIxterm\fP uses its compiled-in default resource settings for colors.
+.
+.
+.SH ERROR MESSAGES
+Most of the fatal error messages from \fIxterm\fP use the following format:
+.RS
+xterm: Error \fIXXX\fP, errno \fIYYY\fP: \fIZZZ\fP
+.RE
+The \fIXXX\fP codes (which are used by \fIxterm\fP as its exit-code)
+are listed below, with a brief explanation.
+.TP 5
+1
+is used for miscellaneous errors, usually accompanied by a specific message,
+.TP
+11
+ERROR_FIONBIO
+.br
+main: ioctl() failed on FIONBIO
+.TP
+12
+ERROR_F_GETFL
+.br
+main: ioctl() failed on F_GETFL
+.TP
+13
+ERROR_F_SETFL
+.br
+main: ioctl() failed on F_SETFL
+.TP
+14
+ERROR_OPDEVTTY
+.br
+spawn: open() failed on /dev/tty
+.TP
+15
+ERROR_TIOCGETP
+.br
+spawn: ioctl() failed on TIOCGETP
+.TP
+17
+ERROR_PTSNAME
+.br
+spawn: ptsname() failed
+.TP
+18
+ERROR_OPPTSNAME
+.br
+spawn: open() failed on ptsname
+.TP
+19
+ERROR_PTEM
+.br
+spawn: ioctl() failed on I_PUSH/"ptem"
+.TP
+20
+ERROR_CONSEM
+.br
+spawn: ioctl() failed on I_PUSH/"consem"
+.TP
+21
+ERROR_LDTERM
+.br
+spawn: ioctl() failed on I_PUSH/"ldterm"
+.TP
+22
+ERROR_TTCOMPAT
+.br
+spawn: ioctl() failed on I_PUSH/"ttcompat"
+.TP
+23
+ERROR_TIOCSETP
+.br
+spawn: ioctl() failed on TIOCSETP
+.TP
+24
+ERROR_TIOCSETC
+.br
+spawn: ioctl() failed on TIOCSETC
+.TP
+25
+ERROR_TIOCSETD
+.br
+spawn: ioctl() failed on TIOCSETD
+.TP
+26
+ERROR_TIOCSLTC
+.br
+spawn: ioctl() failed on TIOCSLTC
+.TP
+27
+ERROR_TIOCLSET
+.br
+spawn: ioctl() failed on TIOCLSET
+.TP
+28
+ERROR_INIGROUPS
+.br
+spawn: initgroups() failed
+.TP
+29
+ERROR_FORK
+.br
+spawn: fork() failed
+.TP
+30
+ERROR_EXEC
+.br
+spawn: exec() failed
+.TP
+32
+ERROR_PTYS
+.br
+get_pty: not enough ptys
+.TP
+34
+ERROR_PTY_EXEC
+.br
+waiting for initial map
+.TP
+35
+ERROR_SETUID
+.br
+spawn: setuid() failed
+.TP
+36
+ERROR_INIT
+.br
+spawn: can't initialize window
+.TP
+46
+ERROR_TIOCKSET
+.br
+spawn: ioctl() failed on TIOCKSET
+.TP
+47
+ERROR_TIOCKSETC
+.br
+spawn: ioctl() failed on TIOCKSETC
+.TP
+49
+ERROR_LUMALLOC
+.br
+luit: command-line malloc failed
+.TP
+50
+ERROR_SELECT
+.br
+in_put: select() failed
+.TP
+54
+ERROR_VINIT
+.br
+VTInit: can't initialize window
+.TP
+57
+ERROR_KMMALLOC1
+.br
+HandleKeymapChange: malloc failed
+.TP
+60
+ERROR_TSELECT
+.br
+Tinput: select() failed
+.TP
+64
+ERROR_TINIT
+.br
+TekInit: can't initialize window
+.TP
+71
+ERROR_BMALLOC2
+.br
+SaltTextAway: malloc() failed
+.TP
+80
+ERROR_LOGEXEC
+.br
+StartLog: exec() failed
+.TP
+83
+ERROR_XERROR
+.br
+xerror: XError event
+.TP
+84
+ERROR_XIOERROR
+.br
+xioerror: X I/O error
+.TP
+90
+ERROR_SCALLOC
+.br
+Alloc: calloc() failed on base
+.TP
+91
+ERROR_SCALLOC2
+.br
+Alloc: calloc() failed on rows
+.TP
+102
+ERROR_SAVE_PTR
+.br
+ScrnPointers: malloc/realloc() failed
+.TP
+121
+ERROR_MMALLOC
+.br
+my_memmove: malloc/realloc failed
+.
+.
+.SH BUGS
+.
+.PP
+Large pastes do not work on some systems.
+This is not a bug in
+\fIxterm\fP; it is a bug in the pseudo terminal driver of those
+systems.
+\fIxterm\fP feeds large pastes to the pty only as fast as the pty
+will accept data, but some pty drivers do not return enough information
+to know if the write has succeeded.
+.
+.PP
+Many of the options are not resettable after
+.I xterm
+starts.
+.
+.PP
+This program still needs to be rewritten.
+It should be split into very
+modular sections, with the various emulators being completely separate
+widgets that do not know about each other.
+Ideally, you'd like to be able to
+pick and choose emulator widgets and stick them into a single control widget.
+.
+.PP
+There needs to be a dialog box to allow entry of the Tek COPY file name.
+.
+.
+.SH "SEE ALSO"
+resize(__mansuffix__), luit(__mansuffix__), X(__miscmansuffix__), pty(4), tty(4)
+.br
+\fIXterm Control Sequences\fP
+(this is the file ctlseqs.ms).
+.sp
+http://invisible-island.net/xterm/xterm.html
+.br
+http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+.
+.
+.SH AUTHORS
+Far too many people, including:
+.sp
+Loretta Guarino Reid (DEC-UEG-WSL),
+Joel McCormack (DEC-UEG-WSL), Terry Weissman (DEC-UEG-WSL),
+Edward Moy (Berkeley), Ralph R. Swick (MIT-Athena),
+Mark Vandevoorde (MIT-Athena), Bob McNamara (DEC-MAD),
+Jim Gettys (MIT-Athena), Bob Scheifler (MIT X Consortium), Doug Mink (SAO),
+Steve Pitschke (Stellar), Ron Newman (MIT-Athena), Jim Fulton (MIT X
+Consortium), Dave Serisky (HP), Jonathan Kamens (MIT-Athena),
+Jason Bacon,
+Stephen P. Wall,
+David Wexelblat, and
+Thomas Dickey (invisible-island.net).
diff --git a/xterm_axp.opt b/xterm_axp.opt
new file mode 100644 (file)
index 0000000..53dab4e
--- /dev/null
@@ -0,0 +1,28 @@
+BUTTON.OBJ
+CHARPROC.OBJ
+CHARSETS.OBJ
+CURSOR.OBJ
+DATA.OBJ
+DOUBLECHR.OBJ
+FONTUTILS.OBJ
+INPUT.OBJ
+KEYSYM2UCS.OBJ
+MAIN.OBJ
+MENU.OBJ
+MISC.OBJ
+PRINT.OBJ
+PTYDATA.OBJ
+SCREEN.OBJ
+SCROLLBAR.OBJ
+TABS.OBJ
+TEKPROC.OBJ
+TEKPRSTBL.OBJ
+TRACE.OBJ
+TTYSVR.OBJ
+UTIL.OBJ
+VMS.OBJ
+VTPRSTBL.OBJ
+XAW3DLIB.OLB/LIB
+XMULIB.OLB/LIB
+SYS$SHARE:DECW$XTLIBSHRR5.EXE/SHARE
+SYS$SHARE:DECW$XLIBSHR.EXE/SHARE
diff --git a/xterm_io.h b/xterm_io.h
new file mode 100644 (file)
index 0000000..76c7106
--- /dev/null
@@ -0,0 +1,309 @@
+/* $XTermId: xterm_io.h,v 1.50 2010/05/23 16:04:32 tom Exp $ */
+
+/*
+ * Copyright 2000-2006,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+
+#ifndef        included_xterm_io_h
+#define        included_xterm_io_h
+
+#include <xterm.h>
+
+/*
+ * System-specific definitions (keep these chunks one-per-system!).
+ *
+ * FIXME:  some, such as those defining USE_TERMIOS should be moved to xterm.h
+ * as they are integrated with the configure script.
+ */
+#ifdef CSRG_BASED
+#define USE_TERMIOS
+#endif
+
+#ifdef __CYGWIN__
+#define ATT
+#define SVR4
+#define SYSV
+#define USE_SYSV_TERMIO
+#endif
+
+#ifdef __UNIXOS2__
+#define USE_SYSV_TERMIO
+#endif
+
+#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__)
+#ifndef USE_POSIX_TERMIOS
+#define USE_POSIX_TERMIOS
+#endif
+#endif
+
+#if defined(AIXV4)
+#define USE_POSIX_TERMIOS
+#ifndef SYSV
+#define SYSV
+#endif
+#endif
+
+#ifdef linux
+#define USE_TERMIOS
+#endif
+
+#ifdef __SCO__
+#define USE_TERMIOS
+#ifndef _SVID3
+#define _SVID3
+#endif
+#endif
+
+#ifdef Lynx
+#define USE_SYSV_TERMIO
+#endif
+
+#ifdef macII
+#undef SYSV                    /* pretend to be bsd (sgtty.h) */
+#endif /* macII */
+
+#if defined(__GLIBC__) && !defined(linux)
+#define USE_POSIX_TERMIOS      /* GNU/Hurd, GNU/KFreeBSD and GNU/KNetBSD */
+#endif
+
+#ifdef __MVS__
+#define SVR4
+#define USE_POSIX_TERMIOS
+#endif
+
+#ifdef __QNX__
+#define USE_POSIX_TERMIOS
+#endif
+
+#if defined(__osf__)
+#define USE_POSIX_TERMIOS
+#undef SYSV
+#endif
+
+/*
+ * Indirect system dependencies
+ */
+#if defined(SVR4) && !defined(__sgi)
+#define USE_TERMIOS
+#endif
+
+#ifdef SYSV
+#define USE_SYSV_TERMIO
+#endif
+
+#if defined(USE_POSIX_TERMIOS) && !defined(USE_TERMIOS)
+#define USE_TERMIOS
+#endif
+
+/*
+ * Low-level ioctl, where it is needed or non-conflicting with termio/etc.
+ */
+#ifdef __QNX__
+#include <ioctl.h>
+#else
+#include <sys/ioctl.h>
+#endif
+
+/*
+ * Terminal I/O includes (termio, termios, sgtty headers).
+ */
+#if defined(USE_POSIX_TERMIOS)
+#include <termios.h>
+#elif defined(USE_TERMIOS)
+#include <termios.h>
+/* this hacked termios support only works on SYSV */
+#define USE_ANY_SYSV_TERMIO
+#define termio termios
+#ifndef __CYGWIN__
+#undef  TCGETA
+#define TCGETA TCGETS
+#undef  TCSETA
+#define TCSETA TCSETS
+#undef  TCSETAW
+#define TCSETAW TCSETSW
+#endif
+#elif defined(USE_SYSV_TERMIO)
+# define USE_ANY_SYSV_TERMIO
+# ifdef Lynx
+#  include <termio.h>
+# else
+#  include <sys/termio.h>
+# endif
+#elif defined(SYSV) || defined(ISC)
+# include <sys/termio.h>
+#elif !defined(VMS)
+# include <sgtty.h>
+#endif /* USE_POSIX_TERMIOS */
+
+/*
+ * Stream includes, which declare struct winsize or ttysize.
+ */
+#ifdef SYSV
+#ifdef USE_USG_PTYS
+#include <sys/stream.h>                        /* get typedef used in ptem.h */
+#if !defined(SVR4) || defined(__SCO__)
+#include <sys/ptem.h>                  /* get struct winsize */
+#endif
+#endif /* USE_USG_PTYS */
+#elif defined(sun) && !defined(SVR4)
+#include <sys/ttycom.h>
+#ifdef TIOCSWINSZ
+#undef TIOCSSIZE
+#endif
+#endif /* SYSV */
+
+/*
+ * Special cases (structures and definitions that have to be adjusted).
+ */
+#if defined(__CYGWIN__) && !defined(TIOCSPGRP)
+#include <termios.h>
+#define TIOCSPGRP (_IOW('t', 118, pid_t))
+#endif
+
+#ifdef __UNIXOS2__
+
+#define XFREE86_PTY    0x76
+
+#define XTY_TIOCSETA   0x48
+#define XTY_TIOCSETAW  0x49
+#define XTY_TIOCSETAF  0x4a
+#define XTY_TIOCCONS   0x4d
+#define XTY_TIOCSWINSZ 0x53
+#define XTY_ENADUP     0x5a
+#define XTY_TRACE      0x5b
+#define XTY_TIOCGETA   0x65
+#define XTY_TIOCGWINSZ 0x66
+#define PTMS_GETPTY    0x64
+#define PTMS_BUFSZ     14
+
+#ifndef NCCS
+#define NCCS 11
+#endif
+
+#define TIOCCONS       108
+#define TIOCSWINSZ     113
+#define TIOCGWINSZ     117
+
+struct pt_termios
+{
+        unsigned short  c_iflag;
+        unsigned short  c_oflag;
+        unsigned short  c_cflag;
+        unsigned short  c_lflag;
+        unsigned char   c_cc[NCCS];
+        long            _reserved_[4];
+};
+
+struct winsize {
+       unsigned short  ws_row;         /* rows, in characters */
+       unsigned short  ws_col;         /* columns, in characters */
+       unsigned short  ws_xpixel;      /* horizontal size, pixels */
+       unsigned short  ws_ypixel;      /* vertical size, pixels */
+};
+#define TTYSIZE_STRUCT struct winsize
+#define USE_STRUCT_WINSIZE 1
+
+#ifdef XTERM_MAIN
+extern int ptioctl(int fd, int func, void* data);
+#define ioctl ptioctl
+#endif
+
+#endif /* __UNIXOS2__ */
+
+#ifdef __hpux
+#include <sys/bsdtty.h>                /* defines TIOCSLTC */
+#endif
+
+#ifdef ISC
+#define TIOCGPGRP TCGETPGRP
+#define TIOCSPGRP TCSETPGRP
+#endif
+
+#ifdef Lynx
+#include <resource.h>
+#elif !(defined(SYSV) || defined(linux) || defined(VMS) || (defined(__QNX__)&&!defined(__QNXNTO__)))
+#include <sys/resource.h>
+#endif
+
+#ifdef macII
+#undef FIOCLEX
+#undef FIONCLEX
+#endif /* macII */
+
+#ifdef __QNX__
+#undef TIOCSLTC                        /* <sgtty.h> conflicts with <termios.h> */
+#undef TIOCLSET
+#endif
+
+#if defined(__sgi) && (OSMAJORVERSION >= 5)
+#undef TIOCLSET                                /* defined, but not useable */
+#endif
+
+#if defined(__GNU__) || defined(__MVS__) || defined(__osf__)
+#undef TIOCLSET
+#undef TIOCSLTC
+#endif
+
+#if defined (__sgi) || (defined(__linux__) && defined(__sparc__)) || defined(__UNIXWARE__)
+#undef TIOCLSET /* XXX why is this undef-ed again? */
+#endif
+
+#if defined(sun) || defined(__UNIXWARE__)
+#include <sys/filio.h>
+#endif
+
+#if defined(TIOCSLTC) && ! (defined(linux) || defined(__MVS__) || defined(Lynx) || defined(SVR4))
+#define HAS_LTCHARS
+#endif
+
+#if !defined(TTYSIZE_STRUCT)
+#if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4))
+#define USE_STRUCT_TTYSIZE 1
+#define TTYSIZE_STRUCT struct ttysize
+#elif defined(TIOCSWINSZ)
+#define USE_STRUCT_WINSIZE 1
+#define TTYSIZE_STRUCT struct winsize
+#endif /* sun vs TIOCSWINSZ */
+#endif /* TTYSIZE_STRUCT */
+
+#if defined(USE_STRUCT_TTYSIZE)
+#define TTYSIZE_STRUCT struct ttysize
+#define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSSIZE, &data);
+#define TTYSIZE_COLS(data) data.ts_cols
+#define TTYSIZE_ROWS(data) data.ts_lines
+#elif defined(USE_STRUCT_WINSIZE)
+#define TTYSIZE_STRUCT struct winsize
+#define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSWINSZ, (char *) &data)
+#define TTYSIZE_COLS(data) data.ws_col
+#define TTYSIZE_ROWS(data) data.ws_row
+#endif
+
+typedef unsigned short ttySize_t;
+
+#endif /* included_xterm_io_h */
diff --git a/xtermcap.c b/xtermcap.c
new file mode 100644 (file)
index 0000000..571ba8a
--- /dev/null
@@ -0,0 +1,632 @@
+/* $XTermId: xtermcap.c,v 1.44 2010/06/13 17:46:27 tom Exp $ */
+
+/*
+ * Copyright 2007-2009,2010 by Thomas E. Dickey
+ *
+ *                         All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ */
+
+#include <xtermcap.h>
+#include <data.h>
+
+#include <X11/keysym.h>
+#include <ctype.h>
+
+#ifdef VMS
+#include <X11/keysymdef.h>
+#endif
+
+#include <xstrings.h>
+
+#if USE_TERMINFO && defined(NCURSES_VERSION) && defined(HAVE_USE_EXTENDED_NAMES)
+#define USE_EXTENDED_NAMES 1
+#else
+#define USE_EXTENDED_NAMES 0
+#endif
+
+#if USE_TERMINFO
+#define TcapInit(buffer, name) (setupterm(name, fileno(stdout), &ignored) == OK)
+#else
+#define TcapInit(buffer, name) (tgetent(buffer, name) == 1)
+#endif
+
+#define NO_STRING (char *)(-1)
+
+#if OPT_TCAP_QUERY || OPT_TCAP_FKEYS
+
+#define SHIFT (MOD_NONE + MOD_SHIFT)
+
+typedef struct {
+    const char *tc;
+    const char *ti;
+    int code;
+    unsigned param;            /* see xtermStateToParam() */
+} TCAPINFO;
+/* *INDENT-OFF* */
+#define DATA(tc,ti,x,y) { tc, ti, x, y }
+static TCAPINFO table[] = {
+       /*      tcap    terminfo        code            state */
+       DATA(   "%1",   "khlp",         XK_Help,        0       ),
+       DATA(   "#1",   "kHLP",         XK_Help,        SHIFT   ),
+       DATA(   "@0",   "kfnd",         XK_Find,        0       ),
+       DATA(   "*0",   "kFND",         XK_Find,        SHIFT   ),
+       DATA(   "*6",   "kslt",         XK_Select,      0       ),
+       DATA(   "#6",   "kSLT",         XK_Select,      SHIFT   ),
+
+       DATA(   "kh",   "khome",        XK_Home,        0       ),
+       DATA(   "#2",   "kHOM",         XK_Home,        SHIFT   ),
+       DATA(   "@7",   "kend",         XK_End,         0       ),
+       DATA(   "*7",   "kEND",         XK_End,         SHIFT   ),
+
+       DATA(   "kl",   "kcub1",        XK_Left,        0       ),
+       DATA(   "kr",   "kcuf1",        XK_Right,       0       ),
+       DATA(   "ku",   "kcuu1",        XK_Up,          0       ),
+       DATA(   "kd",   "kcud1",        XK_Down,        0       ),
+
+       DATA(   "#4",   "kLFT",         XK_Left,        SHIFT   ),
+       DATA(   "%i",   "kRIT",         XK_Right,       SHIFT   ),
+       DATA(   "kF",   "kind",         XK_Up,          SHIFT   ),
+       DATA(   "kR",   "kri",          XK_Down,        SHIFT   ),
+
+       DATA(   "k1",   "kf1",          XK_Fn(1),       0       ),
+       DATA(   "k2",   "kf2",          XK_Fn(2),       0       ),
+       DATA(   "k3",   "kf3",          XK_Fn(3),       0       ),
+       DATA(   "k4",   "kf4",          XK_Fn(4),       0       ),
+       DATA(   "k5",   "kf5",          XK_Fn(5),       0       ),
+       DATA(   "k6",   "kf6",          XK_Fn(6),       0       ),
+       DATA(   "k7",   "kf7",          XK_Fn(7),       0       ),
+       DATA(   "k8",   "kf8",          XK_Fn(8),       0       ),
+       DATA(   "k9",   "kf9",          XK_Fn(9),       0       ),
+       DATA(   "k;",   "kf10",         XK_Fn(10),      0       ),
+
+       DATA(   "F1",   "kf11",         XK_Fn(11),      0       ),
+       DATA(   "F2",   "kf12",         XK_Fn(12),      0       ),
+       DATA(   "F3",   "kf13",         XK_Fn(13),      0       ),
+       DATA(   "F4",   "kf14",         XK_Fn(14),      0       ),
+       DATA(   "F5",   "kf15",         XK_Fn(15),      0       ),
+       DATA(   "F6",   "kf16",         XK_Fn(16),      0       ),
+       DATA(   "F7",   "kf17",         XK_Fn(17),      0       ),
+       DATA(   "F8",   "kf18",         XK_Fn(18),      0       ),
+       DATA(   "F9",   "kf19",         XK_Fn(19),      0       ),
+       DATA(   "FA",   "kf20",         XK_Fn(20),      0       ),
+       DATA(   "FB",   "kf21",         XK_Fn(21),      0       ),
+       DATA(   "FC",   "kf22",         XK_Fn(22),      0       ),
+       DATA(   "FD",   "kf23",         XK_Fn(23),      0       ),
+       DATA(   "FE",   "kf24",         XK_Fn(24),      0       ),
+       DATA(   "FF",   "kf25",         XK_Fn(25),      0       ),
+       DATA(   "FG",   "kf26",         XK_Fn(26),      0       ),
+       DATA(   "FH",   "kf27",         XK_Fn(27),      0       ),
+       DATA(   "FI",   "kf28",         XK_Fn(28),      0       ),
+       DATA(   "FJ",   "kf29",         XK_Fn(29),      0       ),
+       DATA(   "FK",   "kf30",         XK_Fn(30),      0       ),
+       DATA(   "FL",   "kf31",         XK_Fn(31),      0       ),
+       DATA(   "FM",   "kf32",         XK_Fn(32),      0       ),
+       DATA(   "FN",   "kf33",         XK_Fn(33),      0       ),
+       DATA(   "FO",   "kf34",         XK_Fn(34),      0       ),
+       DATA(   "FP",   "kf35",         XK_Fn(35),      0       ),
+
+       DATA(   "FQ",   "kf36",         -36,            0       ),
+       DATA(   "FR",   "kf37",         -37,            0       ),
+       DATA(   "FS",   "kf38",         -38,            0       ),
+       DATA(   "FT",   "kf39",         -39,            0       ),
+       DATA(   "FU",   "kf40",         -40,            0       ),
+       DATA(   "FV",   "kf41",         -41,            0       ),
+       DATA(   "FW",   "kf42",         -42,            0       ),
+       DATA(   "FX",   "kf43",         -43,            0       ),
+       DATA(   "FY",   "kf44",         -44,            0       ),
+       DATA(   "FZ",   "kf45",         -45,            0       ),
+       DATA(   "Fa",   "kf46",         -46,            0       ),
+       DATA(   "Fb",   "kf47",         -47,            0       ),
+       DATA(   "Fc",   "kf48",         -48,            0       ),
+       DATA(   "Fd",   "kf49",         -49,            0       ),
+       DATA(   "Fe",   "kf50",         -50,            0       ),
+       DATA(   "Ff",   "kf51",         -51,            0       ),
+       DATA(   "Fg",   "kf52",         -52,            0       ),
+       DATA(   "Fh",   "kf53",         -53,            0       ),
+       DATA(   "Fi",   "kf54",         -54,            0       ),
+       DATA(   "Fj",   "kf55",         -55,            0       ),
+       DATA(   "Fk",   "kf56",         -56,            0       ),
+       DATA(   "Fl",   "kf57",         -57,            0       ),
+       DATA(   "Fm",   "kf58",         -58,            0       ),
+       DATA(   "Fn",   "kf59",         -59,            0       ),
+       DATA(   "Fo",   "kf60",         -60,            0       ),
+       DATA(   "Fp",   "kf61",         -61,            0       ),
+       DATA(   "Fq",   "kf62",         -62,            0       ),
+       DATA(   "Fr",   "kf63",         -63,            0       ),
+
+       DATA(   "K1",   "ka1",          XK_KP_Home,     0       ),
+       DATA(   "K4",   "kc1",          XK_KP_End,      0       ),
+       DATA(   "K3",   "ka3",          XK_KP_Prior,    0       ),
+       DATA(   "K5",   "kc3",          XK_KP_Next,     0       ),
+
+#ifdef XK_ISO_Left_Tab
+       DATA(   "kB",   "kcbt",         XK_ISO_Left_Tab, 0      ),
+#endif
+       DATA(   "kC",   "kclr",         XK_Clear,       0       ),
+       DATA(   "kD",   "kdch1",        XK_Delete,      0       ),
+       DATA(   "kI",   "kich1",        XK_Insert,      0       ),
+
+       DATA(   "kN",   "knp",          XK_Next,        0       ),
+       DATA(   "kP",   "kpp",          XK_Prior,       0       ),
+       DATA(   "%c",   "kNXT",         XK_Next,        SHIFT   ),
+       DATA(   "%e",   "kPRV",         XK_Prior,       SHIFT   ),
+
+       DATA(   "&8",   "kund",         XK_Undo,        0       ),
+       DATA(   "kb",   "kbs",          XK_BackSpace,   0       ),
+# if OPT_TCAP_QUERY && OPT_ISO_COLORS
+       /* XK_COLORS is a fake code. */
+       DATA(   "Co",   "colors",       XK_COLORS,      0       ),
+# endif
+       DATA(   "TN",   "name",         XK_TCAPNAME,    0       ),
+#if USE_EXTENDED_NAMES
+#define DEXT(name, parm, code) DATA("", name, code, parm)
+#define D1ST(name, parm, code) DEXT("k" #name, parm, code)
+#define DMOD(name, parm, code) DEXT("k" #name #parm, parm, code)
+
+#define DGRP(name, code) \
+       D1ST(name, 2, code), \
+       DMOD(name, 3, code), \
+       DMOD(name, 4, code), \
+       DMOD(name, 5, code), \
+       DMOD(name, 6, code), \
+       DMOD(name, 7, code), \
+       DMOD(name, 8, code)
+
+       /* the terminfo codes here are ncurses extensions */
+       /* ignore the termcap names, which are empty */
+       DATA(   "",     "kUP",          XK_Up,          SHIFT   ),
+       DATA(   "",     "kDN",          XK_Up,          SHIFT   ),
+
+       DGRP(DN,   XK_Down),
+       DGRP(LFT,  XK_Left),
+       DGRP(RIT,  XK_Right),
+       DGRP(UP,   XK_Up),
+       DGRP(DC,   XK_Delete),
+       DGRP(END,  XK_End),
+       DGRP(HOM,  XK_Home),
+       DGRP(IC,   XK_Insert),
+       DGRP(NXT,  XK_Next),
+       DGRP(PRV,  XK_Prior),
+#endif
+};
+#undef DATA
+/* *INDENT-ON* */
+
+#if OPT_TCAP_FKEYS
+static void
+loadTermcapStrings(TScreen * screen)
+{
+    if (screen->tcap_fkeys == 0) {
+       char name[80];
+       Cardinal want = XtNumber(table);
+       Cardinal have;
+       char *fkey;
+#ifdef USE_TERMCAP
+       char *area = screen->tcap_area;
+#endif
+
+       TRACE(("loadTermcapStrings\n"));
+       if ((screen->tcap_fkeys = TypeCallocN(char *, want)) != 0) {
+           for (have = 0; have < want; ++have) {
+#ifndef USE_TERMCAP
+               fkey = tigetstr(strcpy(name, table[have].ti));
+#else
+               fkey = tgetstr(strcpy(name, table[have].tc), &area);
+#endif
+               if (fkey != 0 && fkey != NO_STRING) {
+                   screen->tcap_fkeys[have] = x_strdup(fkey);
+               } else {
+                   screen->tcap_fkeys[have] = NO_STRING;
+               }
+           }
+       }
+    }
+}
+#endif
+
+#if OPT_TCAP_QUERY
+static Boolean
+keyIsDistinct(XtermWidget xw, int which)
+{
+    Boolean result = True;
+
+    switch (xw->keyboard.type) {
+    case keyboardIsTermcap:
+#if OPT_TCAP_FKEYS
+       if (table[which].param == SHIFT) {
+           TScreen *screen = TScreenOf(xw);
+           Cardinal k;
+           char *fkey;
+
+           loadTermcapStrings(screen);
+           if (screen->tcap_fkeys[which] != NO_STRING) {
+               for (k = 0; k < XtNumber(table); k++) {
+                   if (table[k].code == table[which].code
+                       && table[k].param == 0) {
+                       if ((fkey = screen->tcap_fkeys[k]) != NO_STRING
+                           && !strcmp(fkey, screen->tcap_fkeys[which])) {
+                           TRACE(("shifted/unshifted keys do not differ\n"));
+                           result = False;
+                       }
+                       break;
+                   }
+               }
+           } else {
+               /* there is no data for the shifted key */
+               result = -1;
+           }
+       }
+#endif
+       break;
+       /*
+        * The vt220-keyboard will not return distinct key sequences for
+        * shifted cursor-keys.  Just pretend they do not exist, since some
+        * programs may be confused if we return the same data for
+        * shifted/unshifted keys.
+        */
+    case keyboardIsVT220:
+       if (table[which].param == SHIFT) {
+           TRACE(("shifted/unshifted keys do not differ\n"));
+           result = False;
+       }
+       break;
+    case keyboardIsLegacy:
+    case keyboardIsDefault:
+    case keyboardIsHP:
+    case keyboardIsSCO:
+    case keyboardIsSun:
+       break;
+    }
+
+    return result;
+}
+
+static int
+lookupTcapByName(const char *name)
+{
+    int result = -2;
+    Cardinal j;
+
+    if (!IsEmpty(name)) {
+       for (j = 0; j < XtNumber(table); j++) {
+           if (!strcmp(table[j].ti, name) || !strcmp(table[j].tc, name)) {
+               result = (int) j;
+               break;
+           }
+       }
+    }
+
+    if (result >= 0) {
+       TRACE(("lookupTcapByName(%s) tc=%s, ti=%s code %#x, param %#x\n",
+              name,
+              table[result].tc,
+              table[result].ti,
+              table[result].code,
+              table[result].param));
+    } else {
+       TRACE(("lookupTcapByName(%s) FAIL\n", name));
+    }
+    return result;
+}
+
+/*
+ * Parse the termcap/terminfo name from the string, returning a positive number
+ * (the keysym) if found, otherwise -1.  Update the string pointer.
+ * Returns the (shift, control) state in *state.
+ *
+ * This does not attempt to construct control/shift modifiers to construct
+ * function-key values.  Instead, it sets the *fkey flag to pass to Input()
+ * and bypass the lookup of keysym altogether.
+ */
+int
+xtermcapKeycode(XtermWidget xw, const char **params, unsigned *state, Bool * fkey)
+{
+    TCAPINFO *data;
+    int which;
+    int code = -1;
+    char *name;
+    const char *p;
+
+    TRACE(("xtermcapKeycode(%s)\n", *params));
+
+    /* Convert hex encoded name to ascii */
+    name = x_decode_hex(*params, &p);
+    *params = p;
+
+    *state = 0;
+    *fkey = False;
+
+    if (!IsEmpty(name) && (*p == 0 || *p == ';')) {
+       if ((which = lookupTcapByName(name)) >= 0) {
+           if (keyIsDistinct(xw, which)) {
+               data = table + which;
+               code = data->code;
+               *state = xtermParamToState(xw, data->param);
+               if (IsFunctionKey(code)) {
+                   *fkey = True;
+               } else if (code < 0) {
+                   *fkey = True;
+                   code = XK_Fn((-code));
+               }
+#if OPT_SUN_FUNC_KEYS
+               if (*fkey && xw->keyboard.type == keyboardIsSun) {
+                   int num = code - XK_Fn(0);
+
+                   /* match function-key case in sunfuncvalue() */
+                   if (num > 20) {
+                       if (num <= 30 || num > 47) {
+                           code = -1;
+                       } else {
+                           code -= 10;
+                           switch (num) {
+                           case 37:    /* khome */
+                           case 39:    /* kpp */
+                           case 41:    /* kb2 */
+                           case 43:    /* kend */
+                           case 45:    /* knp */
+                               code = -1;
+                               break;
+                           }
+                       }
+                   }
+               }
+#endif
+           } else {
+               TRACE(("... name ok, data not ok\n"));
+               code = -1;
+           }
+       } else {
+           TRACE(("... name not ok\n"));
+           code = -2;
+       }
+    } else {
+       TRACE(("... name not ok\n"));
+       code = -2;
+    }
+
+    TRACE(("... xtermcapKeycode(%s, %u, %d) -> %#06x\n",
+          name, *state, *fkey, code));
+    free(name);
+    return code;
+}
+#endif /* OPT_TCAP_QUERY */
+
+#if OPT_TCAP_FKEYS
+static int
+nextTcapByCode(int code, unsigned param, int last)
+{
+    int result = -1;
+    int n;
+
+    TRACE(("lookupTcapByCode %#x:%#x\n", code, param));
+    for (n = last + 1; n < (int) XtNumber(table); n++) {
+       if (table[n].code == code &&
+           table[n].param == param) {
+           TRACE(("->lookupTcapByCode %d:%s\n", n, table[n].ti));
+           result = n;
+           break;
+       }
+    }
+    return result;
+}
+
+static int
+firstTcapByCode(int code, unsigned param)
+{
+    return nextTcapByCode(code, param, -1);
+}
+
+int
+xtermcapString(XtermWidget xw, int keycode, unsigned mask)
+{
+    int result = 0;
+    unsigned param = xtermStateToParam(xw, mask);
+    int which;
+
+    if ((which = firstTcapByCode(keycode, param)) >= 0) {
+       TScreen *screen = TScreenOf(xw);
+       char *fkey;
+
+       loadTermcapStrings(screen);
+       if (screen->tcap_fkeys != 0) {
+           do {
+               if ((fkey = screen->tcap_fkeys[which]) != NO_STRING) {
+                   StringInput(xw, (Char *) fkey, strlen(fkey));
+                   result = 1;
+                   break;
+               }
+           } while ((which = nextTcapByCode(keycode, param, which)) >= 0);
+       }
+    }
+
+    TRACE(("xtermcapString(keycode=%#x, mask=%#x) ->%d\n",
+          keycode, mask, result));
+
+    return result;
+}
+#endif /* OPT_TCAP_FKEYS */
+
+#endif /* OPT_TCAP_QUERY || OPT_TCAP_FKEYS */
+
+/*
+ * If we're linked to terminfo, tgetent() will return an empty buffer.  We
+ * cannot use that to adjust the $TERMCAP variable.
+ */
+Bool
+get_termcap(XtermWidget xw, char *name)
+{
+#if USE_TERMINFO
+    int ignored = 0;
+#endif
+    char *buffer = get_tcap_buffer(xw);
+
+    *buffer = 0;               /* initialize, in case we're using terminfo's tgetent */
+
+#if USE_EXTENDED_NAMES
+    use_extended_names(TRUE);
+#endif
+    if (!IsEmpty(name)) {
+       if (TcapInit(buffer, name)) {
+           TRACE(("get_termcap(%s) succeeded (%s)\n", name,
+                  (*buffer
+                   ? "ok:termcap, we can update $TERMCAP"
+                   : "assuming this is terminfo")));
+           return True;
+       } else {
+           *buffer = 0;        /* just in case */
+       }
+    }
+    return False;
+}
+
+/*
+ * Retrieve the termcap-buffer.
+ */
+char *
+get_tcap_buffer(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+    char *buffer;
+
+#if OPT_TEK4014
+    if (TEK4014_ACTIVE(xw)) {
+       buffer = TekScreenOf(tekWidget)->tcapbuf;
+    } else
+#endif
+    {
+       buffer = screen->tcapbuf;
+    }
+    return buffer;
+}
+
+/*
+ * Retrieve the erase-key, for initialization in main program.
+ */
+char *
+get_tcap_erase(XtermWidget xw GCC_UNUSED)
+{
+#ifdef USE_TERMCAP
+    char *area = TScreenOf(xw)->tcap_area;
+#endif
+    char *fkey;
+
+#ifndef USE_TERMCAP
+    fkey = tigetstr("kbs");
+#else
+    fkey = tgetstr("kb", &area);
+#endif
+
+    if (fkey == NO_STRING)
+       fkey = 0;
+    if (fkey != 0)
+       fkey = x_strdup(fkey);
+    return fkey;
+}
+
+/*
+ * A legal termcap (or terminfo) name consists solely of graphic characters,
+ * excluding the punctuation used to delimit fields of the source description.
+ */
+static Bool
+isLegalTcapName(const char *name)
+{
+    Bool result = False;
+
+    if (*name != '\0') {
+       result = True;
+       while (*name != '\0') {
+           if (isgraph(CharOf(*name))) {
+               if (strchr("\\|,:'\"", *name) != 0) {
+                   result = False;
+                   break;
+               }
+           } else {
+               result = False;
+               break;
+           }
+           ++name;
+       }
+    }
+
+    return result;
+}
+
+void
+set_termcap(XtermWidget xw, const char *name)
+{
+    Boolean success = False;
+#if USE_TERMINFO
+    int ignored = 0;
+#else
+    TScreen *screen = TScreenOf(xw);
+    char buffer[sizeof(screen->tcapbuf)];
+#endif
+
+    TRACE(("set_termcap(%s)\n", NonNull(name)));
+    if (IsEmpty(name)) {
+       Bell(xw, XkbBI_MinorError, 0);
+    } else {
+       const char *temp;
+       char *value;
+
+       if ((value = x_decode_hex(name, &temp)) != 0) {
+           if (*temp == '\0' && isLegalTcapName(value)) {
+               if (TcapInit(buffer, value)) {
+#if !USE_TERMINFO
+                   memcpy(screen->tcapbuf, buffer, sizeof(buffer));
+#endif
+                   free_termcap(xw);
+                   success = True;
+               }
+           }
+           free(value);
+       }
+    }
+    if (!success)
+       Bell(xw, XkbBI_MinorError, 0);
+}
+
+void
+free_termcap(XtermWidget xw)
+{
+    TScreen *screen = TScreenOf(xw);
+
+    if (screen->tcap_fkeys != 0) {
+       Cardinal want = XtNumber(table);
+       Cardinal have;
+       char *fkey;
+
+       for (have = 0; have < want; ++have) {
+           fkey = screen->tcap_fkeys[have];
+           if (fkey != 0 && fkey != NO_STRING) {
+               free(fkey);
+           }
+       }
+       free(screen->tcap_fkeys);
+       screen->tcap_fkeys = 0;
+    }
+}
diff --git a/xtermcap.h b/xtermcap.h
new file mode 100644 (file)
index 0000000..c50ad76
--- /dev/null
@@ -0,0 +1,116 @@
+/* $XTermId: xtermcap.h,v 1.16 2010/01/06 21:20:40 tom Exp $ */
+
+/************************************************************
+
+Copyright 2007-2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+/*
+ * Common/useful definitions for XTERM termcap interface.
+ */
+#ifndef included_xtermcap_h
+#define included_xtermcap_h
+
+#include <xterm.h>
+
+#include <ptyx.h>
+
+#ifndef HAVE_TIGETSTR
+#undef USE_TERMINFO
+#endif
+
+#ifndef USE_TERMINFO
+#define USE_TERMINFO 0
+#endif
+
+#if !USE_TERMINFO
+#undef HAVE_TIGETSTR
+#ifndef USE_TERMCAP
+#define USE_TERMCAP 1
+#endif
+#endif
+
+#undef ERR                     /* workaround for glibc 2.1.3 */
+
+#include <curses.h>
+
+#ifndef NCURSES_VERSION
+#ifdef HAVE_TERMCAP_H
+#include <termcap.h>
+#endif
+#endif
+
+#ifdef HAVE_NCURSES_TERM_H
+#include <ncurses/term.h>
+#elif defined(HAVE_TERM_H)
+#include <term.h>              /* tgetent() */
+#endif
+
+/*
+ * Get rid of conflicting symbols from term.h
+ */
+#undef bell
+
+/***====================================================================***/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define        MOD_NONE        1
+#define        MOD_SHIFT       1
+#define        MOD_ALT         2
+#define        MOD_CTRL        4
+#define        MOD_META        8
+
+#define MODIFIER_NAME(parm, name) \
+       (((parm > MOD_NONE) && ((parm - MOD_NONE) & name)) ? " "#name : "")
+
+/* xtermcap.c */
+extern Bool get_termcap(XtermWidget /* xw */, char * /* name */);
+extern void set_termcap(XtermWidget /* xw */, const char * /* name */);
+extern void free_termcap(XtermWidget /* xw */);
+
+extern char *get_tcap_buffer(XtermWidget /* xw */);
+extern char *get_tcap_erase(XtermWidget /* xw */);
+
+#if OPT_TCAP_FKEYS
+extern int xtermcapString(XtermWidget /* xw */, int /* keycode */, unsigned /* mask */);
+#endif
+
+#if OPT_TCAP_QUERY
+extern int xtermcapKeycode(XtermWidget /* xw */, const char ** /* params */, unsigned * /* state */, Bool * /* fkey */);
+#endif
+
+#ifdef __cplusplus
+       }
+#endif
+
+#endif /* included_xtermcap_h */
diff --git a/xtermcfg.hin b/xtermcfg.hin
new file mode 100644 (file)
index 0000000..8311384
--- /dev/null
@@ -0,0 +1,218 @@
+/* $XTermId: xtermcfg.hin,v 1.182 2010/11/11 01:14:49 tom Exp $ */
+
+/************************************************************
+
+Copyright 1997-2009,2010 by Thomas E. Dickey
+
+                        All Rights Reserved
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright
+holders shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization.
+
+********************************************************/
+
+#ifndef included_xtermcfg_h
+#define included_xtermcfg_h 1
+
+/* This is a template for <xtermcfg.h> */
+
+#undef ALLOWLOGFILEEXEC                /* CF_ARG_ENABLE(enable-logfile-exec) */
+#undef ALLOWLOGGING            /* CF_ARG_ENABLE(enable-logging) */
+#undef CC_HAS_PROTOS           /* CF_ANSI_CC */
+#undef CSRG_BASED              /* CF_TYPE_FD_MASK */
+#undef DECL_ERRNO              /* CF_ERRNO */
+#undef DFT_COLORMODE           /* AC_ARG_WITH(default-color-mode) */
+#undef DFT_DECID               /* AC_ARG_WITH(default-terminal-id) */
+#undef DFT_TERMTYPE            /* AC_ARG_WITH(default-term-type) */
+#undef DISABLE_SETGID          /* CF_ARG_DISABLE(setgid) */
+#undef DISABLE_SETUID          /* CF_ARG_DISABLE(setuid) */
+#undef HAVE_GETHOSTNAME                /* AC_CHECK_FUNCS(gethostname) */
+#undef HAVE_GETLOGIN           /* AC_CHECK_FUNCS(getlogin) */
+#undef HAVE_LANGINFO_CODESET   /* AM_LANGINFO_CODESET */
+#undef HAVE_LASTLOG_H          /* CF_LASTLOG */
+#undef HAVE_LIB_NEXTAW         /* CF_X_ATHENA(--with-neXtaw) */
+#undef HAVE_LIB_PCRE           /* CF_WITH_PCRE */
+#undef HAVE_LIB_XAW            /* CF_X_ATHENA */
+#undef HAVE_LIB_XAW3D          /* CF_X_ATHENA(--with-Xaw3d) */
+#undef HAVE_LIB_XAWPLUS                /* CF_X_ATHENA(--with-XawPlus) */
+#undef HAVE_NCURSES_TERM_H     /* AC_CHECK_HEADERS(ncurses/term.h) */
+#undef HAVE_PATHS_H            /* CF_LASTLOG */
+#undef HAVE_PCREPOSIX_H                /* CF_WITH_PCRE */
+#undef HAVE_POSIX_SAVED_IDS    /* CF_POSIX_SAVED_IDS */
+#undef HAVE_PUTENV             /* AC_CHECK_FUNCS(putenv) */
+#undef HAVE_SCHED_YIELD                /* AC_CHECK_FUNCS(sched_yield) */
+#undef HAVE_STDLIB_H           /* AC_CHECK_HEADERS(stdlib.h) */
+#undef HAVE_STRERROR           /* AC_CHECK_FUNCS(strerror) */
+#undef HAVE_STRFTIME           /* AC_CHECK_FUNCS(strftime) */
+#undef HAVE_SYS_TIME_H         /* AC_HEADER_TIME */
+#undef HAVE_SYS_TTYDEFAULTS_H  /* AC_CHECK_HEADERS(sys/ttydefaults.h) */
+#undef HAVE_SYS_WAIT_H         /* AC_HEADER_SYS_WAIT */
+#undef HAVE_TCGETATTR          /* AC_CHECK_FUNCS(tcgetattr) */
+#undef HAVE_TERMCAP_H          /* AC_CHECK_HEADERS(termcap.h) */
+#undef HAVE_TERMIOS_H          /* AC_CHECK_HEADERS(termios.h) */
+#undef HAVE_TERMIO_C_ISPEED    /* CF_TERMIO_C_ISPEED */
+#undef HAVE_TERM_H             /* AC_CHECK_HEADERS(term.h) */
+#undef HAVE_TIGETSTR           /* AC_CHECK_FUNCS(tigetstr) */
+#undef HAVE_UNISTD_H           /* AC_CHECK_HEADERS(unistd.h) */
+#undef HAVE_USE_EXTENDED_NAMES /* AC_CHECK_FUNCS(use_extended_names) */
+#undef HAVE_UTMP               /* CF_UTMP */
+#undef HAVE_UTMP_UT_HOST       /* CF_UTMP_UT_HOST */
+#undef HAVE_UTMP_UT_SESSION    /* CF_UTMP_UT_SESSION */
+#undef HAVE_UTMP_UT_SYSLEN     /* CF_UTMP_UT_SYSLEN */
+#undef HAVE_UTMP_UT_XSTATUS    /* CF_UTMP_UT_XSTATUS */
+#undef HAVE_UTMP_UT_XTIME      /* CF_UTMP_UT_XTIME */
+#undef HAVE_WAITPID            /* AC_CHECK_FUNCS(waitpid) */
+#undef HAVE_WCHAR_H            /* AC_CHECK_HEADERS(wchar.h) */
+#undef HAVE_WCSWIDTH           /* AC_CHECK_FUNCS(wcswidth) */
+#undef HAVE_WCWIDTH            /* AC_CHECK_FUNCS(wcwidth) */
+#undef HAVE_X11_DECKEYSYM_H    /* AC_CHECK_HEADERS(X11/DECkeysym.h) */
+#undef HAVE_X11_EXTENSIONS_XKB_H /* AC_CHECK_HEADERS(X11/extensions/XKB.h) */
+#undef HAVE_X11_SUNKEYSYM_H    /* AC_CHECK_HEADERS(X11/Sunkeysym.h) */
+#undef HAVE_X11_XF86KEYSYM_H   /* AC_CHECK_HEADERS(X11/XF86keysym.h) */
+#undef HAVE_X11_XKBLIB_H       /* AC_CHECK_HEADERS(X11/XKBlib.h) */
+#undef HAVE_X11_XPOLL_H                /* AC_CHECK_HEADERS(X11/Xpoll.h) */
+#undef HAVE_XFTDRAWSETCLIP     /* CF_X_FREETYPE */
+#undef HAVE_XFTDRAWSETCLIPRECTANGLES /* CF_X_FREETYPE */
+#undef HAVE_XKBQUERYEXTENSION  /* AC_CHECK_FUNCS(XkbQueryExtension) */
+#undef HAVE_XKB_BELL_EXT       /* CF_XKB_BELL_EXT */
+#undef LUIT_PATH               /* CF_ARG_ENABLE(luit) */
+#undef NO_ACTIVE_ICON          /* CF_ARG_DISABLE(active-icon) */
+#undef NO_LEAKS                        /* CF_ARG_DISABLE(leaks) */
+#undef OPT_256_COLORS          /* CF_ARG_ENABLE(256-color) */
+#undef OPT_88_COLORS           /* CF_ARG_ENABLE(88-color) */
+#undef OPT_AIX_COLORS          /* CF_ARG_DISABLE(16-color) */
+#undef OPT_BLINK_CURS          /* CF_ARG_DISABLE(blink-cursor) */
+#undef OPT_BLINK_TEXT          /* CF_ARG_DISABLE(blink-text) */
+#undef OPT_BOX_CHARS           /* CF_ARG_DISABLE(boxchars) */
+#undef OPT_BROKEN_OSC          /* CF_ARG_ENABLE(broken-osc) */
+#undef OPT_BROKEN_ST           /* CF_ARG_DISABLE(broken-st) */
+#undef OPT_C1_PRINT            /* CF_ARG_DISABLE(c1-print) */
+#undef OPT_COLOR_CLASS         /* CF_ARG_DISABLE(color-class) */
+#undef OPT_DABBREV             /* CF_ARG_ENABLE(dabbrev) */
+#undef OPT_DEC_CHRSET          /* CF_ARG_DISABLE(doublechars) */
+#undef OPT_DEC_LOCATOR         /* CF_ARG_ENABLE(dec-locator) */
+#undef OPT_DEC_RECTOPS         /* CF_ARG_ENABLE(rectangles) */
+#undef OPT_EXEC_XTERM          /* CF_ARG_ENABLE(exec-xterm) */
+#undef OPT_FIFO_LINES          /* CF_ARG_ENABLE(fifo-lines) */
+#undef OPT_HIGHLIGHT_COLOR     /* CF_ARG_DISABLE(highlighting) */
+#undef OPT_HP_FUNC_KEYS                /* CF_ARG_ENABLE(hp-fkeys) */
+#undef OPT_I18N_SUPPORT                /* CF_ARG_DISABLE(i18n) */
+#undef OPT_INITIAL_ERASE       /* CF_ARG_DISABLE(initial-erase) */
+#undef OPT_INPUT_METHOD                /* CF_ARG_DISABLE(input-method) */
+#undef OPT_ISO_COLORS          /* CF_ARG_DISABLE(ansi-color) */
+#undef OPT_LOAD_VTFONTS                /* CF_ARG_ENABLE(load-vt-fonts) */
+#undef OPT_LUIT_PROG           /* CF_ARG_ENABLE(luit) */
+#undef OPT_MAXIMIZE            /* CF_ARG_DISABLE(maximize) */
+#undef OPT_MINI_LUIT           /* CF_ARG_ENABLE(mini-luit) */
+#undef OPT_NUM_LOCK            /* CF_ARG_DISABLE(num-lock) */
+#undef OPT_PASTE64             /* CF_ARG_ENABLE(past64) */
+#undef OPT_PC_COLORS           /* CF_ARG_DISABLE(pc-color) */
+#undef OPT_PTY_HANDSHAKE       /* CF_ARG_ENABLE(pty-handshake) */
+#undef OPT_READLINE            /* CF_ARG_ENABLE(readline-mouse) */
+#undef OPT_SAME_NAME           /* CF_ARG_DISABLE(samename) */
+#undef OPT_SCO_FUNC_KEYS       /* CF_ARG_ENABLE(sco-fkeys) */
+#undef OPT_SELECT_REGEX                /* CF_ARG_DISABLE(regex) */
+#undef OPT_SESSION_MGT         /* CF_ARG_DISABLE(session-mgt) */
+#undef OPT_SUN_FUNC_KEYS       /* CF_ARG_ENABLE(sun-fkeys) */
+#undef OPT_TCAP_FKEYS          /* CF_ARG_ENABLE(tcap-fkeys) */
+#undef OPT_TCAP_QUERY          /* CF_ARG_ENABLE(tcap-query) */
+#undef OPT_TEK4014             /* CF_ARG_DISABLE(tek4014) */
+#undef OPT_TOOLBAR             /* CF_ARG_ENABLE(toolbar) */
+#undef OPT_VT52_MODE           /* CF_ARG_DISABLE(vt52) */
+#undef OPT_WIDER_ICHAR         /* CF_ARG_ENABLE(16bit-chars) */
+#undef OPT_WIDE_CHARS          /* CF_ARG_OPTION(wide-chars) */
+#undef OPT_XMC_GLITCH          /* CF_ARG_ENABLE(xmc-glitch) */
+#undef OPT_ZICONBEEP           /* CF_ARG_DISABLE(ziconbeep) */
+#undef OWN_TERMINFO_DIR                /* AC_ARG_WITH(own-terminfo) */
+#undef PROCFS_ROOT             /* CF_ARG_ENABLE(exec-xterm) */
+#undef SCROLLBAR_RIGHT         /* CF_ARG_ENABLE(rightbar) */
+#undef SIG_ATOMIC_T            /* CF_SIG_ATOMIC_T */
+#undef SVR4                    /* CF_SVR4, imake */
+#undef SYSV                    /* CF_SYSV, imake */
+#undef TIME_WITH_SYS_TIME      /* AC_HEADER_TIME */
+#undef TTY_GROUP_NAME          /* CF_TTY_GROUP */
+#undef USE_LASTLOG             /* CF_LASTLOG */
+#undef USE_MY_MEMMOVE          /* CF_FUNC_MEMMOVE */
+#undef USE_OK_BCOPY            /* CF_FUNC_MEMMOVE */
+#undef USE_POSIX_WAIT          /* CF_POSIX_WAIT */
+#undef USE_STRUCT_LASTLOG      /* CF_STRUCT_LASTLOG */
+#undef USE_SYSV_UTMP           /* CF_UTMP */
+#undef USE_SYS_SELECT_H                /* CF_TYPE_FD_SET */
+#undef USE_TERMCAP             /* CF_FUNC_TGETENT */
+#undef USE_TERMINFO            /* CF_FUNC_TGETENT */
+#undef USE_TTY_GROUP           /* CF_TTY_GROUP */
+#undef USE_UTEMPTER            /* CF_UTEMPTER */
+#undef USE_UTMP_SETGID         /* AC_ARG_WITH(utmp-setgid) */
+#undef UTMPX_FOR_UTMP          /* CF_UTMP */
+#undef XRENDERFONT             /* CF_X_FREETYPE */
+#undef const                   /* AC_CONST */
+#undef gid_t                   /* AC_TYPE_UID_T */
+#undef mode_t                  /* AC_TYPE_MODE_T */
+#undef off_t                   /* AC_TYPE_OFF_T */
+#undef pid_t                   /* AC_TYPE_PID_T */
+#undef size_t                  /* AC_TYPE_SIZE_T */
+#undef time_t                  /* AC_CHECK_TYPE(time_t, long) */
+#undef uid_t                   /* AC_TYPE_UID_T */
+#undef ut_name                 /* CF_UTMP */
+#undef ut_xstatus              /* CF_UTMP_UT_XSTATUS */
+#undef ut_xtime                        /* CF_UTMP_UT_XTIME */
+
+/*
+ * Ifdef'd to make it simple to override.
+ */
+#ifndef OPT_TRACE
+#undef OPT_TRACE               /* CF_ARG_ENABLE(trace) */
+#undef OPT_TRACE_FLAGS         /* ...no option */
+#endif
+
+/*
+ * g++ support for __attribute__() is haphazard.
+ */
+#ifndef __cplusplus
+#undef GCC_PRINTF
+#undef GCC_PRINTFLIKE
+#undef GCC_UNUSED
+#endif
+
+#ifdef USE_OK_BCOPY
+#define memmove(d,s,n) bcopy(s,d,n)
+#endif
+
+#ifdef USE_MY_MEMMOVE
+#define memmove(d,s,n) my_memmove(d,s,n)
+extern void * my_memmove(void * s1, void * s2, size_t n);
+#endif
+
+#ifndef HAVE_STRERROR
+#define strerror(n) my_strerror(n)
+extern char *my_strerror(int n);
+#endif
+
+#ifndef HAVE_X11_XPOLL_H
+#define NO_XPOLL_H     /* X11R6.1 & up use Xpoll.h for select() definitions */
+#endif
+
+/* vile:cmode
+ */
+#endif /* included_xtermcfg_h */
diff --git a/xutf8.c b/xutf8.c
new file mode 100644 (file)
index 0000000..8dabf15
--- /dev/null
+++ b/xutf8.c
@@ -0,0 +1,378 @@
+/* $XTermId: xutf8.c,v 1.9 2009/11/05 23:30:05 tom Exp $ */
+
+/*
+Copyright (c) 2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#include <xterm.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xmu/Xmu.h>
+
+#include <xutf8.h>
+
+#ifndef X_HAVE_UTF8_STRING
+
+#undef XA_UTF8_STRING
+#define KEYSYM2UCS_INCLUDED
+
+#include "keysym2ucs.c"
+
+Atom
+_xa_utf8_string(Display * dpy)
+{
+    static AtomPtr p = NULL;
+
+    if (p == NULL)
+       p = XmuMakeAtom("UTF8_STRING");
+
+    return XmuInternAtom(dpy, p);
+}
+#define XA_UTF8_STRING(dpy) _xa_utf8_string(dpy)
+
+static int
+utf8countBytes(int c)
+{
+    if (c < 0)
+       return 0;
+
+    if (c <= 0x7F) {
+       return 1;
+    } else if (c <= 0x7FF) {
+       return 2;
+    } else if (c <= 0xFFFF) {
+       return 3;
+    } else
+       return 4;
+}
+
+static void
+utf8insert(char *dest, int c, int *len_return)
+{
+    if (c < 0)
+       return;
+
+    if (c <= 0x7F) {
+       dest[0] = c;
+       *len_return = 1;
+    } else if (c <= 0x7FF) {
+       dest[0] = 0xC0 | ((c >> 6) & 0x1F);
+       dest[1] = 0x80 | (c & 0x3F);
+       *len_return = 2;
+    } else if (c <= 0xFFFF) {
+       dest[0] = 0xE0 | ((c >> 12) & 0x0F);
+       dest[1] = 0x80 | ((c >> 6) & 0x3F);
+       dest[2] = 0x80 | (c & 0x3F);
+       *len_return = 3;
+    } else {
+       dest[0] = 0xF0 | ((c >> 18) & 0x07);
+       dest[1] = 0x80 | ((c >> 12) & 0x3f);
+       dest[2] = 0x80 | ((c >> 6) & 0x3f);
+       dest[3] = 0x80 | (c & 0x3f);
+       *len_return = 4;
+    }
+}
+
+static int
+l1countUtf8Bytes(char *s, int len)
+{
+    int l = 0;
+    while (len > 0) {
+       if ((*s & 0x80) == 0)
+           l++;
+       else
+           l += 2;
+       s++;
+       len--;
+    }
+    return l;
+}
+
+static void
+l1utf8copy(char *d, char *s, int len)
+{
+    int l;
+    while (len > 0) {
+       utf8insert(d, (*s) & 0xFF, &l);
+       d += l;
+       s++;
+       len--;
+    }
+}
+
+static void
+utf8l1strcpy(char *d, char *s)
+{
+#define SKIP do { s++; } while(((*s & 0x80) != 0) && (*s & 0xC0) != 0xC0)
+    while (*s) {
+       if ((*s & 0x80) == 0)
+           *d++ = *s++;
+       else if ((*s & 0x7C) == 0x40) {
+           if ((s[1] & 0x80) == 0) {
+               s++;            /* incorrect UTF-8 */
+               continue;
+           } else if ((*s & 0x7C) == 0x40) {
+               *d++ = ((*s & 0x03) << 6) | (s[1] & 0x3F);
+               s += 2;
+           } else {
+               *d++ = '?';
+               SKIP;
+           }
+       } else {
+           *d++ = '?';
+           SKIP;
+       }
+    }
+    *d = 0;
+#undef SKIP
+}
+
+/* Keep this in sync with utf8l1strcpy! */
+static int
+utf8l1strlen(char *s)
+{
+#define SKIP do { s++; } while(((*s & 0x80) != 0) && (*s & 0xC0) != 0xC0)
+    int len = 0;
+    while (*s) {
+       if ((*s & 0x80) == 0) {
+           s++;
+           len++;
+       } else if ((*s & 0x7C) == 0x40) {
+           if ((s[1] & 0x80) == 0) {
+               s++;
+               continue;
+           } else if ((*s & 0x7C) == 0x40) {
+               len++;
+               s += 2;
+           } else {
+               len++;
+               SKIP;
+           }
+       } else {
+           len++;
+           SKIP;
+       }
+    }
+#undef SKIP
+    return len;
+}
+
+int
+Xutf8TextPropertyToTextList(Display * dpy,
+                           const XTextProperty * tp,
+                           char ***list_return,
+                           int *count_return)
+{
+    int utf8;
+    char **list;
+    int nelements;
+    char *cp;
+    char *start;
+    size_t i;
+    int j;
+    size_t datalen = tp->nitems;
+    size_t len;
+
+    if (tp->format != 8)
+       return XConverterNotFound;
+
+    if (tp->encoding == XA_STRING)
+       utf8 = 0;
+    else if (tp->encoding == XA_UTF8_STRING(dpy))
+       utf8 = 1;
+    else
+       return XConverterNotFound;
+
+    if (datalen == 0) {
+       *list_return = NULL;
+       *count_return = 0;
+       return 0;
+    }
+
+    nelements = 1;
+    for (cp = (char *) tp->value, i = datalen; i != 0; cp++, i--) {
+       if (*cp == '\0')
+           nelements++;
+    }
+
+    list = TypeMallocN(char *, (unsigned) nelements);
+    if (!list)
+       return XNoMemory;
+
+    if (utf8)
+       len = datalen;
+    else
+       len = l1countUtf8Bytes((char *) tp->value, datalen);
+
+    start = CastMallocN(char, len);
+    if (!start) {
+       free(list);
+       return XNoMemory;
+    }
+
+    if (utf8)
+       memcpy(start, (char *) tp->value, datalen);
+    else
+       l1utf8copy(start, (char *) tp->value, datalen);
+    start[len] = '\0';
+
+    for (cp = start, i = len + 1, j = 0; i != 0; cp++, i--) {
+       if (*cp == '\0') {
+           list[j] = start;
+           start = (cp + 1);
+           j++;
+       }
+    }
+
+    list[j] = NULL;
+    *list_return = list;
+    *count_return = nelements;
+    return 0;
+}
+
+int
+Xutf8TextListToTextProperty(Display * dpy,
+                           char **list,
+                           int count,
+                           XICCEncodingStyle style,
+                           XTextProperty * text_prop)
+{
+    XTextProperty proto;
+    unsigned int nbytes;
+    int i;
+
+    if (style != XStringStyle &&
+       style != XCompoundTextStyle &&
+       style != XStdICCTextStyle &&
+       style != XUTF8StringStyle)
+       return XConverterNotFound;
+
+    if (style == XUTF8StringStyle) {
+       for (i = 0, nbytes = 0; i < count; i++) {
+           nbytes += (unsigned) ((list[i] ? strlen(list[i]) : 0) + 1);
+       }
+    } else {
+       for (i = 0, nbytes = 0; i < count; i++) {
+           nbytes += (unsigned) ((list[i] ? utf8l1strlen(list[i]) : 0) + 1);
+       }
+    }
+
+    if (style == XCompoundTextStyle)
+       proto.encoding = XA_COMPOUND_TEXT(dpy);
+    else if (style == XUTF8StringStyle)
+       proto.encoding = XA_UTF8_STRING(dpy);
+    else
+       proto.encoding = XA_STRING;
+    proto.format = 8;
+    if (nbytes)
+       proto.nitems = nbytes - 1;
+    else
+       proto.nitems = 0;
+    proto.value = NULL;
+
+    if (nbytes > 0) {
+       char *buf = TypeMallocN(char, nbytes);
+       if (!buf)
+           return XNoMemory;
+
+       proto.value = (unsigned char *) buf;
+       for (i = 0; i < count; i++) {
+           char *arg = list[i];
+
+           if (arg) {
+               if (style == XUTF8StringStyle) {
+                   strcpy(buf, arg);
+               } else {
+                   utf8l1strcpy(buf, arg);
+               }
+               buf += (strlen(buf) + 1);
+           } else {
+               *buf++ = '\0';
+           }
+       }
+    } else {
+       proto.value = CastMalloc(unsigned char);        /* easier for client */
+       if (!proto.value)
+           return XNoMemory;
+
+       proto.value[0] = '\0';
+    }
+
+    *text_prop = proto;
+    return 0;
+}
+
+int
+Xutf8LookupString(XIC ic GCC_UNUSED,
+                 XKeyEvent * ev,
+                 char *buffer,
+                 int nbytes,
+                 KeySym * keysym_return,
+                 Status * status_return)
+{
+    int rc;
+    KeySym keysym;
+    int codepoint;
+    int len;
+
+    rc = XLookupString(ev, buffer, nbytes, &keysym, NULL);
+
+    if (rc > 0) {
+       codepoint = buffer[0] & 0xFF;
+    } else {
+       codepoint = keysym2ucs(keysym);
+    }
+
+    if (codepoint < 0) {
+       if (keysym == None) {
+           *status_return = XLookupNone;
+       } else {
+           *status_return = XLookupKeySym;
+           *keysym_return = keysym;
+       }
+       return 0;
+    }
+
+    if (nbytes < utf8countBytes(codepoint)) {
+       *status_return = XBufferOverflow;
+       return utf8countBytes(codepoint);
+    }
+
+    utf8insert(buffer, codepoint, &len);
+
+    if (keysym != None) {
+       *keysym_return = keysym;
+       *status_return = XLookupBoth;
+    } else {
+       *status_return = XLookupChars;
+    }
+    return len;
+}
+#else /* X_HAVE_UTF8_STRING */
+/* Silence the compiler */
+void
+xutf8_dummy(void)
+{
+    return;
+}
+#endif
diff --git a/xutf8.h b/xutf8.h
new file mode 100644 (file)
index 0000000..45fdd90
--- /dev/null
+++ b/xutf8.h
@@ -0,0 +1,61 @@
+/*
+ * $XTermId: xutf8.h,v 1.4 2010/10/10 14:10:12 Jeremy.Huddleston Exp $
+ */
+/*
+Copyright (c) 2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#include <X11/Xlib.h>
+
+#ifndef X_HAVE_UTF8_STRING
+
+#undef XA_UTF8_STRING
+Atom _xa_utf8_string(Display*);
+#define XA_UTF8_STRING(dpy) _xa_utf8_string(dpy)
+
+#undef XUTF8StringStyle
+#define XUTF8StringStyle 4
+
+int Xutf8TextPropertyToTextList(
+    Display *,
+    const XTextProperty *,
+    char ***,
+    int *
+);
+int
+Xutf8TextListToTextProperty(
+    Display *,
+    char **,
+    int,
+    XICCEncodingStyle,
+    XTextProperty *
+);
+int Xutf8LookupString(
+    XIC,
+    XKeyPressedEvent *,
+    char *,
+    int,
+    KeySym *,
+    Status *
+);
+#else
+void xutf8_dummy(void);
+#endif