From f4092abdf94af6a99aff944d6264bc1284e8bdd4 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 10 Oct 2011 17:43:39 +0200 Subject: Imported nx-X11-3.1.0-1.tar.gz Summary: Imported nx-X11-3.1.0-1.tar.gz Keywords: Imported nx-X11-3.1.0-1.tar.gz into Git repository --- nx-X11/programs/xterm/256colres.h | 250 + nx-X11/programs/xterm/256colres.pl | 57 + nx-X11/programs/xterm/88colres.h | 82 + nx-X11/programs/xterm/88colres.pl | 60 + nx-X11/programs/xterm/AAA_README_VMS.txt | 48 + nx-X11/programs/xterm/INSTALL | 487 + nx-X11/programs/xterm/Imakefile | 325 + nx-X11/programs/xterm/Imakefile.NX.original | 325 + nx-X11/programs/xterm/Imakefile.X.original | 289 + nx-X11/programs/xterm/MANIFEST | 126 + nx-X11/programs/xterm/Makefile.in | 243 + nx-X11/programs/xterm/README | 15 + nx-X11/programs/xterm/README.i18n | 199 + nx-X11/programs/xterm/README.os390 | 74 + nx-X11/programs/xterm/TekPrsTbl.c | 2622 +++++ nx-X11/programs/xterm/Tekparse.def | 42 + nx-X11/programs/xterm/Tekparse.h | 99 + nx-X11/programs/xterm/Tekproc.c | 1782 ++++ nx-X11/programs/xterm/Tests | 42 + nx-X11/programs/xterm/UXTerm.ad | 38 + nx-X11/programs/xterm/VTPrsTbl.c | 7216 +++++++++++++ nx-X11/programs/xterm/VTparse.def | 142 + nx-X11/programs/xterm/VTparse.h | 248 + nx-X11/programs/xterm/XTerm-col.ad | 130 + nx-X11/programs/xterm/XTerm.ad | 185 + nx-X11/programs/xterm/aclocal.m4 | 2359 +++++ nx-X11/programs/xterm/button.c | 3284 ++++++ nx-X11/programs/xterm/charclass.c | 142 + nx-X11/programs/xterm/charclass.h | 13 + nx-X11/programs/xterm/charproc.c | 7300 +++++++++++++ nx-X11/programs/xterm/charproc.c.NX.original | 7300 +++++++++++++ nx-X11/programs/xterm/charproc.c.X.original | 7276 +++++++++++++ nx-X11/programs/xterm/charsets.c | 461 + nx-X11/programs/xterm/config.guess | 1499 +++ nx-X11/programs/xterm/config.sub | 1577 +++ nx-X11/programs/xterm/configure | 11548 +++++++++++++++++++++ nx-X11/programs/xterm/configure.in | 779 ++ nx-X11/programs/xterm/ctlseqs.ms | 1876 ++++ nx-X11/programs/xterm/cursor.c | 345 + nx-X11/programs/xterm/data.c | 127 + nx-X11/programs/xterm/data.h | 207 + nx-X11/programs/xterm/doublechr.c | 267 + nx-X11/programs/xterm/error.h | 90 + nx-X11/programs/xterm/fontutils.c | 2371 +++++ nx-X11/programs/xterm/fontutils.h | 89 + nx-X11/programs/xterm/gen-pc-fkeys.pl | 98 + nx-X11/programs/xterm/input.c | 1259 +++ nx-X11/programs/xterm/install.sh | 294 + nx-X11/programs/xterm/keysym2ucs.c | 857 ++ nx-X11/programs/xterm/keysym2ucs.h | 9 + nx-X11/programs/xterm/link_axp.com | 107 + nx-X11/programs/xterm/main.c | 4943 +++++++++ nx-X11/programs/xterm/main.c.NX.original | 4943 +++++++++ nx-X11/programs/xterm/main.c.X.original | 4912 +++++++++ nx-X11/programs/xterm/main.h | 89 + nx-X11/programs/xterm/make.com | 90 + nx-X11/programs/xterm/menu.c | 2959 ++++++ nx-X11/programs/xterm/menu.h | 441 + nx-X11/programs/xterm/minstall.sh | 29 + nx-X11/programs/xterm/misc.c | 3260 ++++++ nx-X11/programs/xterm/mkdirs.sh | 38 + nx-X11/programs/xterm/os2main.c | 2155 ++++ nx-X11/programs/xterm/plink.sh | 27 + nx-X11/programs/xterm/precompose.c | 1041 ++ nx-X11/programs/xterm/precompose.h | 11 + nx-X11/programs/xterm/print.c | 608 ++ nx-X11/programs/xterm/proto.h | 29 + nx-X11/programs/xterm/ptydata.c | 420 + nx-X11/programs/xterm/ptyx.h | 2016 ++++ nx-X11/programs/xterm/resize.c | 600 ++ nx-X11/programs/xterm/resize.man | 84 + nx-X11/programs/xterm/screen.c | 1853 ++++ nx-X11/programs/xterm/scrollbar.c | 682 ++ nx-X11/programs/xterm/sinstall.sh | 156 + nx-X11/programs/xterm/tabs.c | 182 + nx-X11/programs/xterm/tektests/aitest.tek | 1 + nx-X11/programs/xterm/tektests/dmerc.tek | 1 + nx-X11/programs/xterm/tektests/fotest.tek | Bin 0 -> 16231 bytes nx-X11/programs/xterm/tektests/imtest.tek | 1 + nx-X11/programs/xterm/tektests/imtesth.tek | 1 + nx-X11/programs/xterm/tektests/ocpred.tek | 3 + nx-X11/programs/xterm/tektests/usmap.tek | Bin 0 -> 6939 bytes nx-X11/programs/xterm/termcap | 209 + nx-X11/programs/xterm/terminfo | 1012 ++ nx-X11/programs/xterm/testxmc.c | 226 + nx-X11/programs/xterm/trace.c | 490 + nx-X11/programs/xterm/trace.h | 79 + nx-X11/programs/xterm/unicode/README | 24 + nx-X11/programs/xterm/unicode/convmap.pl | 177 + nx-X11/programs/xterm/unicode/keysym.map | 1062 ++ nx-X11/programs/xterm/unicode/make-precompose.sh | 8 + nx-X11/programs/xterm/unicode/precompose.c.head | 16 + nx-X11/programs/xterm/unicode/precompose.c.tail | 23 + nx-X11/programs/xterm/util.c | 2951 ++++++ nx-X11/programs/xterm/uxterm | 82 + nx-X11/programs/xterm/version.h | 14 + nx-X11/programs/xterm/vms.c | 725 ++ nx-X11/programs/xterm/vms.h | 39 + nx-X11/programs/xterm/vttests/16colors.sh | 90 + nx-X11/programs/xterm/vttests/256colors.pl | 12 + nx-X11/programs/xterm/vttests/256colors2.pl | 63 + nx-X11/programs/xterm/vttests/88colors.pl | 13 + nx-X11/programs/xterm/vttests/88colors2.pl | 66 + nx-X11/programs/xterm/vttests/8colors.sh | 78 + nx-X11/programs/xterm/vttests/acolors.sh | 64 + nx-X11/programs/xterm/vttests/doublechars.sh | 87 + nx-X11/programs/xterm/vttests/dynamic.sh | 60 + nx-X11/programs/xterm/vttests/fonts.sh | 59 + nx-X11/programs/xterm/vttests/resize.pl | 100 + nx-X11/programs/xterm/vttests/resize.sh | 82 + nx-X11/programs/xterm/vttests/tcapquery.pl | 162 + nx-X11/programs/xterm/vttests/title.sh | 55 + nx-X11/programs/xterm/wcwidth.c | 306 + nx-X11/programs/xterm/wcwidth.h | 14 + nx-X11/programs/xterm/xcharmouse.h | 76 + nx-X11/programs/xterm/xstrings.c | 146 + nx-X11/programs/xterm/xstrings.h | 44 + nx-X11/programs/xterm/xterm.dat | 160 + nx-X11/programs/xterm/xterm.h | 1101 ++ nx-X11/programs/xterm/xterm.log.html | 6641 ++++++++++++ nx-X11/programs/xterm/xterm.man | 4418 ++++++++ nx-X11/programs/xterm/xterm_axp.opt | 28 + nx-X11/programs/xterm/xterm_io.h | 309 + nx-X11/programs/xterm/xtermcfg.hin | 176 + nx-X11/programs/xterm/xutf8.c | 378 + nx-X11/programs/xterm/xutf8.h | 61 + 126 files changed, 120221 insertions(+) create mode 100644 nx-X11/programs/xterm/256colres.h create mode 100644 nx-X11/programs/xterm/256colres.pl create mode 100644 nx-X11/programs/xterm/88colres.h create mode 100644 nx-X11/programs/xterm/88colres.pl create mode 100644 nx-X11/programs/xterm/AAA_README_VMS.txt create mode 100644 nx-X11/programs/xterm/INSTALL create mode 100644 nx-X11/programs/xterm/Imakefile create mode 100644 nx-X11/programs/xterm/Imakefile.NX.original create mode 100644 nx-X11/programs/xterm/Imakefile.X.original create mode 100644 nx-X11/programs/xterm/MANIFEST create mode 100644 nx-X11/programs/xterm/Makefile.in create mode 100644 nx-X11/programs/xterm/README create mode 100644 nx-X11/programs/xterm/README.i18n create mode 100644 nx-X11/programs/xterm/README.os390 create mode 100644 nx-X11/programs/xterm/TekPrsTbl.c create mode 100644 nx-X11/programs/xterm/Tekparse.def create mode 100644 nx-X11/programs/xterm/Tekparse.h create mode 100644 nx-X11/programs/xterm/Tekproc.c create mode 100644 nx-X11/programs/xterm/Tests create mode 100644 nx-X11/programs/xterm/UXTerm.ad create mode 100644 nx-X11/programs/xterm/VTPrsTbl.c create mode 100644 nx-X11/programs/xterm/VTparse.def create mode 100644 nx-X11/programs/xterm/VTparse.h create mode 100644 nx-X11/programs/xterm/XTerm-col.ad create mode 100644 nx-X11/programs/xterm/XTerm.ad create mode 100644 nx-X11/programs/xterm/aclocal.m4 create mode 100644 nx-X11/programs/xterm/button.c create mode 100644 nx-X11/programs/xterm/charclass.c create mode 100644 nx-X11/programs/xterm/charclass.h create mode 100644 nx-X11/programs/xterm/charproc.c create mode 100644 nx-X11/programs/xterm/charproc.c.NX.original create mode 100644 nx-X11/programs/xterm/charproc.c.X.original create mode 100644 nx-X11/programs/xterm/charsets.c create mode 100644 nx-X11/programs/xterm/config.guess create mode 100644 nx-X11/programs/xterm/config.sub create mode 100644 nx-X11/programs/xterm/configure create mode 100644 nx-X11/programs/xterm/configure.in create mode 100644 nx-X11/programs/xterm/ctlseqs.ms create mode 100644 nx-X11/programs/xterm/cursor.c create mode 100644 nx-X11/programs/xterm/data.c create mode 100644 nx-X11/programs/xterm/data.h create mode 100644 nx-X11/programs/xterm/doublechr.c create mode 100644 nx-X11/programs/xterm/error.h create mode 100644 nx-X11/programs/xterm/fontutils.c create mode 100644 nx-X11/programs/xterm/fontutils.h create mode 100755 nx-X11/programs/xterm/gen-pc-fkeys.pl create mode 100644 nx-X11/programs/xterm/input.c create mode 100644 nx-X11/programs/xterm/install.sh create mode 100644 nx-X11/programs/xterm/keysym2ucs.c create mode 100644 nx-X11/programs/xterm/keysym2ucs.h create mode 100644 nx-X11/programs/xterm/link_axp.com create mode 100644 nx-X11/programs/xterm/main.c create mode 100644 nx-X11/programs/xterm/main.c.NX.original create mode 100644 nx-X11/programs/xterm/main.c.X.original create mode 100644 nx-X11/programs/xterm/main.h create mode 100644 nx-X11/programs/xterm/make.com create mode 100644 nx-X11/programs/xterm/menu.c create mode 100644 nx-X11/programs/xterm/menu.h create mode 100644 nx-X11/programs/xterm/minstall.sh create mode 100644 nx-X11/programs/xterm/misc.c create mode 100644 nx-X11/programs/xterm/mkdirs.sh create mode 100644 nx-X11/programs/xterm/os2main.c create mode 100644 nx-X11/programs/xterm/plink.sh create mode 100644 nx-X11/programs/xterm/precompose.c create mode 100644 nx-X11/programs/xterm/precompose.h create mode 100644 nx-X11/programs/xterm/print.c create mode 100644 nx-X11/programs/xterm/proto.h create mode 100644 nx-X11/programs/xterm/ptydata.c create mode 100644 nx-X11/programs/xterm/ptyx.h create mode 100644 nx-X11/programs/xterm/resize.c create mode 100644 nx-X11/programs/xterm/resize.man create mode 100644 nx-X11/programs/xterm/screen.c create mode 100644 nx-X11/programs/xterm/scrollbar.c create mode 100644 nx-X11/programs/xterm/sinstall.sh create mode 100644 nx-X11/programs/xterm/tabs.c create mode 100644 nx-X11/programs/xterm/tektests/aitest.tek create mode 100644 nx-X11/programs/xterm/tektests/dmerc.tek create mode 100644 nx-X11/programs/xterm/tektests/fotest.tek create mode 100644 nx-X11/programs/xterm/tektests/imtest.tek create mode 100644 nx-X11/programs/xterm/tektests/imtesth.tek create mode 100644 nx-X11/programs/xterm/tektests/ocpred.tek create mode 100644 nx-X11/programs/xterm/tektests/usmap.tek create mode 100644 nx-X11/programs/xterm/termcap create mode 100644 nx-X11/programs/xterm/terminfo create mode 100644 nx-X11/programs/xterm/testxmc.c create mode 100644 nx-X11/programs/xterm/trace.c create mode 100644 nx-X11/programs/xterm/trace.h create mode 100644 nx-X11/programs/xterm/unicode/README create mode 100644 nx-X11/programs/xterm/unicode/convmap.pl create mode 100644 nx-X11/programs/xterm/unicode/keysym.map create mode 100644 nx-X11/programs/xterm/unicode/make-precompose.sh create mode 100644 nx-X11/programs/xterm/unicode/precompose.c.head create mode 100644 nx-X11/programs/xterm/unicode/precompose.c.tail create mode 100644 nx-X11/programs/xterm/util.c create mode 100644 nx-X11/programs/xterm/uxterm create mode 100644 nx-X11/programs/xterm/version.h create mode 100644 nx-X11/programs/xterm/vms.c create mode 100644 nx-X11/programs/xterm/vms.h create mode 100644 nx-X11/programs/xterm/vttests/16colors.sh create mode 100644 nx-X11/programs/xterm/vttests/256colors.pl create mode 100644 nx-X11/programs/xterm/vttests/256colors2.pl create mode 100644 nx-X11/programs/xterm/vttests/88colors.pl create mode 100644 nx-X11/programs/xterm/vttests/88colors2.pl create mode 100644 nx-X11/programs/xterm/vttests/8colors.sh create mode 100644 nx-X11/programs/xterm/vttests/acolors.sh create mode 100644 nx-X11/programs/xterm/vttests/doublechars.sh create mode 100644 nx-X11/programs/xterm/vttests/dynamic.sh create mode 100644 nx-X11/programs/xterm/vttests/fonts.sh create mode 100755 nx-X11/programs/xterm/vttests/resize.pl create mode 100644 nx-X11/programs/xterm/vttests/resize.sh create mode 100755 nx-X11/programs/xterm/vttests/tcapquery.pl create mode 100644 nx-X11/programs/xterm/vttests/title.sh create mode 100644 nx-X11/programs/xterm/wcwidth.c create mode 100644 nx-X11/programs/xterm/wcwidth.h create mode 100644 nx-X11/programs/xterm/xcharmouse.h create mode 100644 nx-X11/programs/xterm/xstrings.c create mode 100644 nx-X11/programs/xterm/xstrings.h create mode 100644 nx-X11/programs/xterm/xterm.dat create mode 100644 nx-X11/programs/xterm/xterm.h create mode 100644 nx-X11/programs/xterm/xterm.log.html create mode 100644 nx-X11/programs/xterm/xterm.man create mode 100644 nx-X11/programs/xterm/xterm_axp.opt create mode 100644 nx-X11/programs/xterm/xterm_io.h create mode 100644 nx-X11/programs/xterm/xtermcfg.hin create mode 100644 nx-X11/programs/xterm/xutf8.c create mode 100644 nx-X11/programs/xterm/xutf8.h (limited to 'nx-X11/programs/xterm') diff --git a/nx-X11/programs/xterm/256colres.h b/nx-X11/programs/xterm/256colres.h new file mode 100644 index 000000000..a84acd588 --- /dev/null +++ b/nx-X11/programs/xterm/256colres.h @@ -0,0 +1,250 @@ +/* + * This header file was generated by ./256colres.pl + */ +/* $XFree86: xc/programs/xterm/256colres.h,v 1.5 2002/10/05 17:57:11 dickey 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/nx-X11/programs/xterm/256colres.pl b/nx-X11/programs/xterm/256colres.pl new file mode 100644 index 000000000..a6b995e48 --- /dev/null +++ b/nx-X11/programs/xterm/256colres.pl @@ -0,0 +1,57 @@ +#! /usr/bin/perl +# Author: Thomas E. Dickey +# $XFree86: xc/programs/xterm/256colres.pl,v 1.8 2002/10/05 17:57:11 dickey Exp $ + +# 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 + +print < 0 ) { $level += 23.18181818; } + $code = 80 + $gray; + printf($line1, $code); + printf($line2, $code); + printf($line3, + int($level), int($level), int($level)); +} + +print < 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/nx-X11/programs/xterm/INSTALL b/nx-X11/programs/xterm/INSTALL new file mode 100644 index 000000000..844ad8362 --- /dev/null +++ b/nx-X11/programs/xterm/INSTALL @@ -0,0 +1,487 @@ +-- $XTermId: INSTALL,v 1.94 2005/11/03 13:17:26 tom Exp $ +-- $XFree86: xc/programs/xterm/INSTALL,v 3.40 2005/11/03 13:17:26 dickey Exp $ +-- Thomas E. Dickey + +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-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-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-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-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-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-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-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-setuid disable setuid/setgid + + Do not install xterm using setuid or setgid permissions. Drop setuid + and setgid permissions on startup. This is done if you have linked + xterm with the utempter library, but may also be useful for systems + where the pseudoterminal and utmp interfaces are wrapped so that xterm + does not require these permissions. + + --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-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-broken-st allow broken string-terminators], + + 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. + + --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-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 Xorg "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 Xorg hackers. + + For instance + + configure --disable-imake --disable-narrowproto + + --enable-paste64 enable support for bracketed paste mode + + 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). + + --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-tcap-query enable termcap query/report + + Compile-in code to support experimental 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. + + --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-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-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 back-color erase capability. + + --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-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 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. diff --git a/nx-X11/programs/xterm/Imakefile b/nx-X11/programs/xterm/Imakefile new file mode 100644 index 000000000..ded0b5e4c --- /dev/null +++ b/nx-X11/programs/xterm/Imakefile @@ -0,0 +1,325 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NX-X11, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of NoMachine S.r.l. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +XCOMM $XTermId: Imakefile,v 1.87 2005/11/13 23:10:35 tom Exp $ +XCOMM +XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:55:07 cpqbld 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.61 2005/11/13 23:10:35 dickey Exp $ +XCOMM + +#if NXLibraries + +/* + * This will make applications that use the Xt + * toolkit deal with the NX modified select(). + */ + +NX_DEFINES = -DNX_TRANS_SOCKET \ + -DNX_TRANS_EXIT + +# -DNX_TRANS_TEST \ +# -DNX_TRANS_DEBUG + +#endif + +/* 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 + +#if defined(UseUtempter) +#undef InstallXtermSetUID /* imake sets this */ +#define InstallXtermSetUID NO +#define InstallXtermSetGID NO + UTMPLIB = -lutempter +#endif + +/* + * setgid mode works for systems that do not require setuid to open pty. + */ +#if defined(OpenBSDArchitecture) || \ + (defined(LinuxArchitecture) && \ + (LinuxCLibMajorVersion == 6)) || \ + defined(FreeBSDArchitecture) +#undef InstallXtermSetGID +#define InstallXtermSetGID YES +#endif + +/* + * Fixes to allow compile with X11R5 + */ +#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 + +/* + * 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 + * + */ +#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) \ + -DOSMAJORVERSION=$(OSMAJORVERSION) \ + -DOSMINORVERSION=$(OSMINORVERSION) + MISC_DEFINES = /* -DALLOWLOGGING -DALLOWLOGFILEEXEC */ + XKB_DEFINES = XkbClientDefines + PATH_DEFINES = -DPROJECTROOT=$(PROJECTROOT) +#if NXLibraries + DEFINES = $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) $(PATH_DEFINES) $(PUTENVDEF) $(IMAKEDEFINES) $(TRACEDEF) $(NX_DEFINES) +#else + DEFINES = $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) $(PATH_DEFINES) $(PUTENVDEF) $(IMAKEDEFINES) $(TRACEDEF) +#endif + 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 charproc.c charsets.c cursor.c \ + data.c doublechr.c fontutils.c input.c \ + menu.c misc.c print.c ptydata.c \ + screen.c scrollbar.c tabs.c util.c xstrings.c \ + TekPrsTbl.c Tekproc.c VTPrsTbl.c \ + $(MAINSRC) $(EXTRASRC) $(UTF8SRC) $(TRACESRC) + OBJS1 = button.o charproc.o charsets.o cursor.o \ + data.o doublechr.o fontutils.o input.o \ + menu.o misc.o print.o ptydata.o \ + screen.o scrollbar.o tabs.o util.o xstrings.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 +INSTUIDFLAGS = -m 4711 +SetUIDProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(PTYLIB)) +#else +NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(UTMPLIB) $(PTYLIB)) +#endif + +#if InstallXtermSetGID +CSGIDFLAGS = -DUSE_UTMP_SETGID +INSTUIDFLAGS = -m 2755 -g utmp +#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) $(INSTUIDFLAGS) ProgramTargetName(xterm.inst) $(DESTDIR)$(BINDIR)/ProgramTargetName(xterm) + RemoveFile(ProgramTargetName(xterm.inst)) +#else +#if InstallXtermSetUID +InstallProgramWithFlags(xterm,$(BINDIR),$(INSTUIDFLAGS)) +#else +InstallProgramWithFlags(xterm,$(BINDIR),NullParameter) +#endif +#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/nx-X11/programs/xterm/Imakefile.NX.original b/nx-X11/programs/xterm/Imakefile.NX.original new file mode 100644 index 000000000..ded0b5e4c --- /dev/null +++ b/nx-X11/programs/xterm/Imakefile.NX.original @@ -0,0 +1,325 @@ +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NX-X11, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of NoMachine S.r.l. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +XCOMM $XTermId: Imakefile,v 1.87 2005/11/13 23:10:35 tom Exp $ +XCOMM +XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:55:07 cpqbld 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.61 2005/11/13 23:10:35 dickey Exp $ +XCOMM + +#if NXLibraries + +/* + * This will make applications that use the Xt + * toolkit deal with the NX modified select(). + */ + +NX_DEFINES = -DNX_TRANS_SOCKET \ + -DNX_TRANS_EXIT + +# -DNX_TRANS_TEST \ +# -DNX_TRANS_DEBUG + +#endif + +/* 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 + +#if defined(UseUtempter) +#undef InstallXtermSetUID /* imake sets this */ +#define InstallXtermSetUID NO +#define InstallXtermSetGID NO + UTMPLIB = -lutempter +#endif + +/* + * setgid mode works for systems that do not require setuid to open pty. + */ +#if defined(OpenBSDArchitecture) || \ + (defined(LinuxArchitecture) && \ + (LinuxCLibMajorVersion == 6)) || \ + defined(FreeBSDArchitecture) +#undef InstallXtermSetGID +#define InstallXtermSetGID YES +#endif + +/* + * Fixes to allow compile with X11R5 + */ +#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 + +/* + * 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 + * + */ +#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) \ + -DOSMAJORVERSION=$(OSMAJORVERSION) \ + -DOSMINORVERSION=$(OSMINORVERSION) + MISC_DEFINES = /* -DALLOWLOGGING -DALLOWLOGFILEEXEC */ + XKB_DEFINES = XkbClientDefines + PATH_DEFINES = -DPROJECTROOT=$(PROJECTROOT) +#if NXLibraries + DEFINES = $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) $(PATH_DEFINES) $(PUTENVDEF) $(IMAKEDEFINES) $(TRACEDEF) $(NX_DEFINES) +#else + DEFINES = $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) $(PATH_DEFINES) $(PUTENVDEF) $(IMAKEDEFINES) $(TRACEDEF) +#endif + 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 charproc.c charsets.c cursor.c \ + data.c doublechr.c fontutils.c input.c \ + menu.c misc.c print.c ptydata.c \ + screen.c scrollbar.c tabs.c util.c xstrings.c \ + TekPrsTbl.c Tekproc.c VTPrsTbl.c \ + $(MAINSRC) $(EXTRASRC) $(UTF8SRC) $(TRACESRC) + OBJS1 = button.o charproc.o charsets.o cursor.o \ + data.o doublechr.o fontutils.o input.o \ + menu.o misc.o print.o ptydata.o \ + screen.o scrollbar.o tabs.o util.o xstrings.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 +INSTUIDFLAGS = -m 4711 +SetUIDProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(PTYLIB)) +#else +NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(UTMPLIB) $(PTYLIB)) +#endif + +#if InstallXtermSetGID +CSGIDFLAGS = -DUSE_UTMP_SETGID +INSTUIDFLAGS = -m 2755 -g utmp +#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) $(INSTUIDFLAGS) ProgramTargetName(xterm.inst) $(DESTDIR)$(BINDIR)/ProgramTargetName(xterm) + RemoveFile(ProgramTargetName(xterm.inst)) +#else +#if InstallXtermSetUID +InstallProgramWithFlags(xterm,$(BINDIR),$(INSTUIDFLAGS)) +#else +InstallProgramWithFlags(xterm,$(BINDIR),NullParameter) +#endif +#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/nx-X11/programs/xterm/Imakefile.X.original b/nx-X11/programs/xterm/Imakefile.X.original new file mode 100644 index 000000000..50bbfee2d --- /dev/null +++ b/nx-X11/programs/xterm/Imakefile.X.original @@ -0,0 +1,289 @@ +XCOMM $XTermId: Imakefile,v 1.87 2005/11/13 23:10:35 tom Exp $ +XCOMM +XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:55:07 cpqbld 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.61 2005/11/13 23:10:35 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 + +#if defined(UseUtempter) +#undef InstallXtermSetUID /* imake sets this */ +#define InstallXtermSetUID NO +#define InstallXtermSetGID NO + UTMPLIB = -lutempter +#endif + +/* + * setgid mode works for systems that do not require setuid to open pty. + */ +#if defined(OpenBSDArchitecture) || \ + (defined(LinuxArchitecture) && \ + (LinuxCLibMajorVersion == 6)) || \ + defined(FreeBSDArchitecture) +#undef InstallXtermSetGID +#define InstallXtermSetGID YES +#endif + +/* + * Fixes to allow compile with X11R5 + */ +#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 + +/* + * 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 + * + */ +#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) \ + -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 charproc.c charsets.c cursor.c \ + data.c doublechr.c fontutils.c input.c \ + menu.c misc.c print.c ptydata.c \ + screen.c scrollbar.c tabs.c util.c xstrings.c \ + TekPrsTbl.c Tekproc.c VTPrsTbl.c \ + $(MAINSRC) $(EXTRASRC) $(UTF8SRC) $(TRACESRC) + OBJS1 = button.o charproc.o charsets.o cursor.o \ + data.o doublechr.o fontutils.o input.o \ + menu.o misc.o print.o ptydata.o \ + screen.o scrollbar.o tabs.o util.o xstrings.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 +INSTUIDFLAGS = -m 4711 +SetUIDProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(PTYLIB)) +#else +NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),$(XRFLIBS) XkbClientLibs XawClientLibs,$(TERMCAPLIB) $(UTMPLIB) $(PTYLIB)) +#endif + +#if InstallXtermSetGID +CSGIDFLAGS = -DUSE_UTMP_SETGID +INSTUIDFLAGS = -m 2755 -g utmp +#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) $(INSTUIDFLAGS) ProgramTargetName(xterm.inst) $(DESTDIR)$(BINDIR)/ProgramTargetName(xterm) + RemoveFile(ProgramTargetName(xterm.inst)) +#else +#if InstallXtermSetUID +InstallProgramWithFlags(xterm,$(BINDIR),$(INSTUIDFLAGS)) +#else +InstallProgramWithFlags(xterm,$(BINDIR),NullParameter) +#endif +#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/nx-X11/programs/xterm/MANIFEST b/nx-X11/programs/xterm/MANIFEST new file mode 100644 index 000000000..a23a710be --- /dev/null +++ b/nx-X11/programs/xterm/MANIFEST @@ -0,0 +1,126 @@ +MANIFEST for xterm, version xterm-207 +-------------------------------------------------------------------------------- +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 +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' +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 +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 +configure Configuration script for UNIX +ctlseqs.ms documentation: Xterm Control Sequences +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 configure script: fallback install script +keysym2ucs.c lookup-table for UTF-8 to keysyms +keysym2ucs.h interface of keysym2ucs.c +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' +mkdirs.sh configure script: make directories for install process +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' +screen.c VT100 screen update functions +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 +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.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 +xtermcfg.hin configure script: template for xtermcfg.h +xutf8.c JC's cleanup of UTF8 +xutf8.h JC's cleanup of UTF8 +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/fonts.sh script to demonstrate font-switching sequences +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/nx-X11/programs/xterm/Makefile.in b/nx-X11/programs/xterm/Makefile.in new file mode 100644 index 000000000..99fffe1d9 --- /dev/null +++ b/nx-X11/programs/xterm/Makefile.in @@ -0,0 +1,243 @@ +## $XTermId: Makefile.in,v 1.118 2005/11/03 13:17:27 tom Exp $ +## +## $XFree86: xc/programs/xterm/Makefile.in,v 3.51 2005/11/03 13:17:27 dickey Exp $ ## +## +## Copyright 2002-2003,2004 by Thomas E. Dickey +## +## 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. + +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) + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_DATA = @INSTALL_DATA@ +transform = @program_transform_name@ + +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ + +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@ + +#### End of system configuration section. #### + +RM = rm -f +LINT = @LINT@ + +DESTDIR = +BINDIR = $(DESTDIR)$(bindir) +LIBDIR = $(DESTDIR)$(libdir) +MANDIR = $(DESTDIR)$(mandir) +APPSDIR = $(DESTDIR)$(appsdir) + +INSTALL_DIRS = $(BINDIR) $(APPSDIR) $(MANDIR) + +CLASS = XTerm +EXTRAHDR = @EXTRAHDRS@ +EXTRASRC = @EXTRASRCS@ +EXTRAOBJ = @EXTRAOBJS@ + + SRCS1 = button.c charproc.c charsets.c cursor.c \ + data.c doublechr.c fontutils.c input.c \ + $(MAINSRC) menu.c misc.c print.c ptydata.c \ + screen.c scrollbar.c tabs.c util.c xstrings.c \ + VTPrsTbl.c $(EXTRASRC) + OBJS1 = button$o charproc$o charsets$o cursor$o \ + data$o doublechr$o fontutils$o input$o \ + main$o menu$o misc$o print$o ptydata$o \ + screen$o scrollbar$o tabs$o util$o xstrings$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 $(EXTRAHDR) + PROGRAMS = xterm$x resize$x + +all : $(PROGRAMS) + +.SUFFIXES : .i .def .hin + +.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++}' >$@ + +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@$(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(X_LIBS) $(X_EXTRA_LIBS) $(LIBS) $(EXTRA_LOADFLAGS) + +resize$x : $(OBJS2) + @ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(X_LIBS) $(X_EXTRA_LIBS) $(LIBS) + +256colres.h : + -rm -f $@ + perl $(srcdir)/256colres.pl > $@ + +88colres.h : + -rm -f $@ + perl $(srcdir)/88colres.pl > $@ + +charproc$o : main.h @CHARPROC_DEPS@ + +TRANSFORM = sed 's/$x$$//'|sed '$(transform)'|sed 's/$$/$x/' +actual_xterm = `echo xterm| sed '$(transform)'` +actual_resize = `echo resize| sed '$(transform)'` +binary_xterm = `echo xterm$x| $(TRANSFORM)` +binary_resize = `echo resize$x| $(TRANSFORM)` +binary_uxterm = `echo uxterm| $(TRANSFORM)` + +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_SCRIPT) -m 755 $(srcdir)/uxterm $(BINDIR)/$(binary_uxterm) + +install \ +install-man \ +install-full :: $(MANDIR) + $(SHELL) $(srcdir)/minstall.sh "$(INSTALL_DATA)" $(srcdir)/xterm.man $(MANDIR)/$(actual_xterm).$(manext) + $(SHELL) $(srcdir)/minstall.sh "$(INSTALL_DATA)" $(srcdir)/resize.man $(MANDIR)/$(actual_resize).$(manext) + +install \ +install-app \ +install-full :: $(APPSDIR) + @echo installing $(APPSDIR)/$(CLASS) + @sed -e s/XTerm/$(CLASS)/ $(srcdir)/XTerm.ad >XTerm.tmp + @$(INSTALL_DATA) XTerm.tmp $(APPSDIR)/$(CLASS) + @echo installing $(APPSDIR)/$(CLASS)-color + @sed -e s/XTerm/$(CLASS)/ $(srcdir)/XTerm-col.ad >XTerm.tmp + @$(INSTALL_DATA) XTerm.tmp $(APPSDIR)/$(CLASS)-color + @echo installing $(APPSDIR)/UXTerm + @sed -e s/XTerm/$(CLASS)/ $(srcdir)/UXTerm.ad >XTerm.tmp + @$(INSTALL_DATA) XTerm.tmp $(APPSDIR)/UXTerm + @rm -f XTerm.tmp + +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@ + +install-full \ +install-ti :: $(TERMINFO_DIR) + $(SET_TERMINFO) tic $(srcdir)/terminfo + @echo 'Completed installation of terminfo description.' + +install-full \ +install-tc :: + @test -f /etc/termcap && echo 'You must install the termcap entry manually by editing /etc/termcap' + +installdirs : $(INSTALL_DIRS) + +uninstall : + -$(RM) $(BINDIR)/$(binary_xterm) + -$(RM) $(BINDIR)/$(binary_resize) + -$(RM) $(BINDIR)/$(binary_uxterm) + -$(RM) $(MANDIR)/$(actual_xterm).$(manext) + -$(RM) $(MANDIR)/$(actual_resize).$(manext) + -$(RM) $(APPSDIR)/$(CLASS) + -$(RM) $(APPSDIR)/$(CLASS)-color + -$(RM) $(APPSDIR)/UXTerm + +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 + +realclean : distclean + -$(RM) tags TAGS ctlseqs.ps ctlseqs.txt + +maintainer-clean : realclean + -$(RM) 256colres.h 88colres.h + +ctlseqs.txt : ctlseqs.ms + GROFF_NO_SGR=stupid $(SHELL) -c "tbl ctlseqs.ms | nroff -Tascii -ms" >$@ + +ctlseqs.ps : ctlseqs.ms + tbl ctlseqs.ms | groff -ms >$@ + +lint : + $(LINT) $(CPPFLAGS) $(SRCS1) + $(LINT) $(CPPFLAGS) $(SRCS2) + +tags : + ctags $(SRCS) $(HDRS) + +TAGS : + etags $(SRCS) $(HDRS) + +$(TERMINFO_DIR) $(INSTALL_DIRS) : + $(SHELL) ${srcdir}/mkdirs.sh $@ + +ALWAYS : + +depend : $(TABLES) + makedepend -- $(CPPFLAGS) -- $(SRCS) + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/nx-X11/programs/xterm/README b/nx-X11/programs/xterm/README new file mode 100644 index 000000000..f098b04b0 --- /dev/null +++ b/nx-X11/programs/xterm/README @@ -0,0 +1,15 @@ + 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/nx-X11/programs/xterm/README.i18n b/nx-X11/programs/xterm/README.i18n new file mode 100644 index 000000000..511ee60f6 --- /dev/null +++ b/nx-X11/programs/xterm/README.i18n @@ -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/nx-X11/programs/xterm/README.os390 b/nx-X11/programs/xterm/README.os390 new file mode 100644 index 000000000..2fe50b604 --- /dev/null +++ b/nx-X11/programs/xterm/README.os390 @@ -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/nx-X11/programs/xterm/TekPrsTbl.c b/nx-X11/programs/xterm/TekPrsTbl.c new file mode 100644 index 000000000..290a0a332 --- /dev/null +++ b/nx-X11/programs/xterm/TekPrsTbl.c @@ -0,0 +1,2622 @@ +/* + * $Xorg: TekPrsTbl.c,v 1.3 2000/08/17 19:55:07 cpqbld 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.3 2001/01/17 23:46:33 dawes Exp $ */ + +#include + +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/nx-X11/programs/xterm/Tekparse.def b/nx-X11/programs/xterm/Tekparse.def new file mode 100644 index 000000000..50b1be183 --- /dev/null +++ b/nx-X11/programs/xterm/Tekparse.def @@ -0,0 +1,42 @@ +# +# $Xorg: Tekparse.def,v 1.3 2000/08/17 19:55:07 cpqbld Exp $ +# +# 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/nx-X11/programs/xterm/Tekparse.h b/nx-X11/programs/xterm/Tekparse.h new file mode 100644 index 000000000..c7c315ec7 --- /dev/null +++ b/nx-X11/programs/xterm/Tekparse.h @@ -0,0 +1,99 @@ +/* + * $Xorg: Tekparse.h,v 1.3 2000/08/17 19:55:07 cpqbld 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.4 2001/01/17 23:46:34 dawes 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/nx-X11/programs/xterm/Tekproc.c b/nx-X11/programs/xterm/Tekproc.c new file mode 100644 index 000000000..0a6b79bd1 --- /dev/null +++ b/nx-X11/programs/xterm/Tekproc.c @@ -0,0 +1,1782 @@ +/* $XTermId: Tekproc.c,v 1.131 2005/11/03 13:17:27 tom Exp $ */ + +/* + * $Xorg: Tekproc.c,v 1.5 2001/02/09 02:06:02 xorgcvs Exp $ + * + * Warning, there be crufty dragons here. + */ +/* $XFree86: xc/programs/xterm/Tekproc.c,v 3.55 2005/11/03 13:17:27 dickey Exp $ */ + +/* + +Copyright 2001-2004,2005 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 + +#include +#include +#include +#include + +#if OPT_TOOLBAR + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif /* OPT_TOOLBAR */ + +#include +#include +#include + +#include +#include +#include +#include + +#define DefaultGCID XGContextFromGC(DefaultGC(screen->display, DefaultScreen(screen->display))) + +/* 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[screen->page.fontsize].nlines - 1)\ + * TekChar[screen->page.fontsize].vsize) +#define TEKMINHEIGHT 452 +#define TEKMINWIDTH 600 +#define TEKTOPPAD 34 +#define TEKWIDTH 4096 +#define WEST 02 + +#define TekMove(x,y) screen->cur_X = x; screen->cur_Y = y +#define input() Tinput() +#define unput(c) *Tpushback++ = 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: insert-seven-bit() \n\ + Meta: insert-eight-bit() \n\ + !Ctrl : popup-menu(mainMenu) \n\ + !Lock Ctrl : popup-menu(mainMenu) \n\ +!Lock Ctrl @Num_Lock : popup-menu(mainMenu) \n\ + !Ctrl @Num_Lock : popup-menu(mainMenu) \n\ + !Ctrl : popup-menu(tekMenu) \n\ + !Lock Ctrl : popup-menu(tekMenu) \n\ +!Lock Ctrl @Num_Lock : popup-menu(tekMenu) \n\ + !Ctrl @Num_Lock : popup-menu(tekMenu) \n\ + Shift ~Meta: gin-press(L) \n\ + ~Meta: gin-press(l) \n\ + Shift ~Meta: gin-press(M) \n\ + ~Meta: gin-press(m) \n\ + Shift ~Meta: gin-press(R) \n\ + ~Meta: 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("initialFont", "InitialFont", 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(void); +static int getpoint(void); +static void TCursorBack(void); +static void TCursorDown(void); +static void TCursorForward(void); +static void TCursorUp(void); +static void TekBackground(TScreen * screen); +static void TekConfigure(Widget w); +static void TekDraw(int x, int y); +static void TekEnq(unsigned status, int x, int y); +static void TekFlush(void); +static void TekInitialize(Widget request, + Widget wnew, + ArgList args, + Cardinal *num_args); +static void TekPage(void); +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 */ + } +}; +#define tekWidgetClass ((WidgetClass)&tekClassRec) + +static Bool Tfailed = False; + +int +TekInit(void) +{ + Widget form_top, menu_top; + + if (!Tfailed + && tekWidget == 0) { + + TRACE(("TekInit\n")); + /* this causes the Initialize method to be called */ + tekshellwidget = + XtCreatePopupShell("tektronix", topLevelShellWidgetClass, + toplevel, ourTopLevelShellArgs, + number_ourTopLevelShellArgs); + + SetupMenus(tekshellwidget, &form_top, &menu_top); + + /* 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, +#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(void) +{ + TScreen *screen = &term->screen; + 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 (screen->TekGIN) { + TekGINoff(); + TekEnqMouse(0); + } else { + c = 064; /* has hard copy unit */ + if (screen->margin == MARGIN2) + c |= 02; + TekEnq(c, screen->cur_X, screen->cur_Y); + } + TekRecord->ptr[-1] = NAK; /* remove from recording */ + Tparsestate = curstate; + break; + + case CASE_VT_MODE: + TRACE(("case: special return to vt102 mode\n")); + Tparsestate = curstate; + TekRecord->ptr[-1] = NAK; /* remove from recording */ + FlushLog(screen); + return; + + case CASE_SPT_STATE: + TRACE(("case: Enter Special Point Plot mode\n")); + if (screen->TekGIN) + TekGINoff(); + Tparsestate = curstate = Tspttable; + break; + + case CASE_GIN: + TRACE(("case: Do Tek GIN mode\n")); + screen->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(screen->display, TWindow(screen), + GINcursor); + } + Tparsestate = Tbyptable; /* Bypass mode */ + break; + + case CASE_BEL: + TRACE(("case: BEL\n")); + if (screen->TekGIN) + TekGINoff(); + if (!TekRefresh) + Bell(XkbBI_TerminalBell, 0); + Tparsestate = curstate; /* clear bypass condition */ + break; + + case CASE_BS: + TRACE(("case: BS\n")); + if (screen->TekGIN) + TekGINoff(); + Tparsestate = curstate; /* clear bypass condition */ + TCursorBack(); + break; + + case CASE_PT_STATE: + TRACE(("case: Enter Tek Point Plot mode\n")); + if (screen->TekGIN) + TekGINoff(); + Tparsestate = curstate = Tpttable; + break; + + case CASE_PLT_STATE: + TRACE(("case: Enter Tek Plot mode\n")); + if (screen->TekGIN) + TekGINoff(); + Tparsestate = curstate = Tplttable; + if ((c = input()) == BEL) + screen->pen = PENDOWN; + else { + unput(c); + screen->pen = PENUP; + } + break; + + case CASE_TAB: + TRACE(("case: HT\n")); + if (screen->TekGIN) + TekGINoff(); + Tparsestate = curstate; /* clear bypass condition */ + TCursorForward(); + break; + + case CASE_IPL_STATE: + TRACE(("case: Enter Tek Incremental Plot mode\n")); + if (screen->TekGIN) + TekGINoff(); + Tparsestate = curstate = Tipltable; + break; + + case CASE_ALP_STATE: + TRACE(("case: Enter Tek Alpha mode from any other mode\n")); + if (screen->TekGIN) + TekGINoff(); + /* if in one of graphics states, move alpha cursor */ + if (nplot > 0) /* flush line VTbuffer */ + TekFlush(); + Tparsestate = curstate = Talptable; + break; + + case CASE_UP: + TRACE(("case: cursor up\n")); + if (screen->TekGIN) + TekGINoff(); + Tparsestate = curstate; /* clear bypass condition */ + TCursorUp(); + break; + + case CASE_COPY: + TRACE(("case: make copy\n")); + if (screen->TekGIN) + TekGINoff(); + TekCopy(); + TekRecord->ptr[-1] = NAK; /* remove from recording */ + Tparsestate = curstate; /* clear bypass condition */ + break; + + case CASE_PAGE: + TRACE(("case: Page Function\n")); + if (screen->TekGIN) + TekGINoff(); + TekPage(); /* 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((int) (c & 03)); + Tparsestate = curstate; + break; + + case CASE_BEAM_VEC: + TRACE(("case: beam and vector selector\n")); + /* only line types */ + if ((c &= LINEMASK) != screen->cur.linetype) { + if (nplot > 0) + TekFlush(); + if (c <= TEKNUMLINES) + screen->cur.linetype = c; + } + Tparsestate = curstate; + break; + + case CASE_CURSTATE: + Tparsestate = curstate; + break; + + case CASE_PENUP: + TRACE(("case: Ipl: penup\n")); + screen->pen = PENUP; + break; + + case CASE_PENDOWN: + TRACE(("case: Ipl: pendown\n")); + screen->pen = PENDOWN; + break; + + case CASE_IPL_POINT: + TRACE(("case: Ipl: point\n")); + x = screen->cur_X; + y = screen->cur_Y; + if (c & NORTH) + y++; + else if (c & SOUTH) + y--; + if (c & EAST) + x++; + else if (c & WEST) + x--; + if (screen->pen == PENDOWN) + TekDraw(x, y); + else + TekMove(x, y); + break; + + case CASE_PLT_VEC: + TRACE(("case: Plt: vector\n")); + unput(c); + if (getpoint()) { + if (screen->pen == PENDOWN) { + TekDraw(screen->cur.x, screen->cur.y); + } else { + TekMove(screen->cur.x, screen->cur.y); + } + screen->pen = PENDOWN; + } + break; + + case CASE_PT_POINT: + TRACE(("case: Pt: point\n")); + unput(c); + if (getpoint()) { + TekMove(screen->cur.x, screen->cur.y); + TekDraw(screen->cur.x, screen->cur.y); + } + break; + + case CASE_SPT_POINT: + TRACE(("case: Spt: point\n")); + /* ignore intensity character in c */ + if (getpoint()) { + TekMove(screen->cur.x, screen->cur.y); + TekDraw(screen->cur.x, screen->cur.y); + } + break; + + case CASE_CR: + TRACE(("case: CR\n")); + if (screen->TekGIN) + TekGINoff(); + if (nplot > 0) /* flush line VTbuffer */ + TekFlush(); + screen->cur_X = screen->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 (screen->TekGIN) + TekGINoff(); + TCursorDown(); + if (!TekRefresh) + do_xevents(); + break; + + case CASE_SP: + TRACE(("case: SP\n")); + TCursorForward(); + break; + + case CASE_PRINT: + TRACE(("case: printable character\n")); + ch = c; + c = screen->cur.fontsize; + x = (int) (screen->cur_X * TekScale(screen)) + + screen->border; + y = (int) ((TEKHEIGHT + TEKTOPPAD - screen->cur_Y) * TekScale(screen)) + + screen->border; + +#if OPT_WIDE_CHARS + if (screen->wide_chars + && (ch > 255)) { + XChar2b sbuf; + sbuf.byte2 = CharOf(ch); + sbuf.byte1 = CharOf(ch >> 8); + XDrawImageString16(screen->display, + TWindow(screen), + screen->TnormalGC, + x, + y, + &sbuf, + 1); + } else +#endif + XDrawString(screen->display, + TWindow(screen), + screen->TnormalGC, + x, + y, + (char *) &ch, + 1); + TCursorForward(); + 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")); + { + Char buf2[512]; + IChar c2; + unsigned len = 0; + while ((c2 = input()) != BEL) { + if (!isprint(c2 & 0x7f) + || len + 2 >= (int) sizeof(buf2)) + break; + buf2[len++] = c2; + } + buf2[len] = 0; + if (c2 == BEL) + do_osc(buf2, len, BEL); + } + Tparsestate = curstate; + break; + } + } +} + +static int rcnt; +static char *rptr; +static PtySelect Tselect_mask; + +static IChar +Tinput(void) +{ + TScreen *screen = &term->screen; + TekLink *tek; + + if (Tpushback > Tpushb) + return (*--Tpushback); + if (TekRefresh) { + if (rcnt-- > 0) + return (*rptr++); + if ((tek = TekRefresh->next) != 0) { + TekRefresh = tek; + rptr = tek->data; + rcnt = tek->count - 1; + TekSetFontSize(tek->fontsize); + return (*rptr++); + } + TekRefresh = (TekLink *) 0; + longjmp(Tekjump, 1); + } + again: + if (VTbuffer->next >= VTbuffer->last) { + int update = VTbuffer->update; + + if (nplot > 0) /* flush line */ + TekFlush(); +#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(screen, &Tselect_mask, VTbuffer)) { + break; + } + if (Ttoggled && curstate == Talptable) { + TCursorToggle(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(screen->display); +#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(screen->display), &Tselect_mask)) { + xevents(); + if (VTbuffer->update != update) + goto again; + } +#endif /* VMS */ + } + if (!Ttoggled && curstate == Talptable) { + TCursorToggle(TOGGLE); + Ttoggled = True; + } + } + tek = TekRecord; + if (tek->count >= TEK_LINK_BLOCK_SIZE + || tek->fontsize != screen->cur.fontsize) { + if ((TekRecord = tek->next = CastMalloc(TekLink)) == 0) + Panic("Tinput: malloc error (%d)\n", errno); + tek = tek->next; + tek->next = (TekLink *) 0; + tek->fontsize = screen->cur.fontsize; + tek->count = 0; + tek->ptr = tek->data; + } + tek->count++; + + (void) morePtyData(screen, VTbuffer); + return (*tek->ptr++ = nextPtyData(screen, VTbuffer)); +} + +/* this should become the Tek Widget's Resize proc */ +static void +TekConfigure(Widget w) +{ + TScreen *screen = &term->screen; + int border = 2 * screen->border; + double d; + + if (TWindow(screen)) + XClearWindow(screen->display, TWindow(screen)); + TWidth(screen) = w->core.width - border; + THeight(screen) = w->core.height - border; + TekScale(screen) = (double) TWidth(screen) / TEKWIDTH; + if ((d = (double) THeight(screen) / (TEKHEIGHT + TEKTOPPAD + TEKBOTTOMPAD)) + < TekScale(screen)) + TekScale(screen) = d; + TFullWidth(screen) = w->core.width; + TFullHeight(screen) = w->core.height; +} + +/*ARGSUSED*/ +void +TekExpose(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + Region region GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + TRACE(("TekExpose\n")); + +#ifdef lint + region = region; +#endif + if (!Ttoggled) + TCursorToggle(CLEAR); + Ttoggled = True; + Tpushback = Tpushb; + screen->cur_X = 0; + screen->cur_Y = TEKHOME; + TekSetFontSize(screen->page.fontsize); + screen->cur = screen->page; + screen->margin = MARGIN1; + if (screen->TekGIN) { + screen->TekGIN = NULL; + TekGINoff(); + } + TekRefresh = &Tek0; + rptr = TekRefresh->data; + rcnt = TekRefresh->count; + Tparsestate = curstate = Talptable; + TRACE(("TekExpose resets data to replay %d bytes\n", rcnt)); + if (waiting_for_initial_map) + first_map_occurred(); + if (!screen->waitrefresh) + dorefresh(); +} + +void +dorefresh(void) +{ + TScreen *screen = &term->screen; + 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(screen->display, TWindow(screen), wait_cursor); + XFlush(screen->display); + if (!setjmp(Tekjump)) + Tekparse(); + XDefineCursor(screen->display, TWindow(screen), + (screen->TekGIN && GINcursor) ? GINcursor : screen->arrow); +} + +static void +TekPage(void) +{ + TScreen *screen = &term->screen; + TekLink *tek; + + XClearWindow(screen->display, TWindow(screen)); + screen->cur_X = 0; + screen->cur_Y = TEKHOME; + screen->margin = MARGIN1; + screen->page = screen->cur; + if (screen->TekGIN) + TekGINoff(); + tek = TekRecord = &Tek0; + tek->fontsize = screen->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; + TekRefresh = (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(void) +{ + int c, x, y, e, lo_y = 0; + TScreen *screen = &term->screen; + + x = screen->cur.x; + y = screen->cur.y; + for (;;) { + if ((c = 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; + screen->cur.x = x; + screen->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(void) +{ + TScreen *screen = &term->screen; + struct Tek_Char *t; + int x, l; + + x = (screen->cur_X -= + (t = &TekChar[screen->cur.fontsize])->hsize + ); + + if (((screen->margin == MARGIN1) && (x < 0)) + || ((screen->margin == MARGIN2) && (x < TEKWIDTH / 2))) { + if ((l = (screen->cur_Y + (t->vsize - 1)) / t->vsize + 1) >= + t->nlines) { + screen->margin = !screen->margin; + l = 0; + } + screen->cur_Y = l * t->vsize; + screen->cur_X = (t->charsperline - 1) * t->hsize; + } +} + +static void +TCursorForward(void) +{ + TScreen *screen = &term->screen; + struct Tek_Char *t; + int l; + + if ((screen->cur_X += + (t = &TekChar[screen->cur.fontsize])->hsize + ) > TEKWIDTH + ) { + if ((l = screen->cur_Y / t->vsize - 1) < 0) { + screen->margin = !screen->margin; + l = t->nlines - 1; + } + screen->cur_Y = l * t->vsize; + screen->cur_X = screen->margin == MARGIN1 ? 0 : TEKWIDTH / 2; + } +} + +static void +TCursorUp(void) +{ + TScreen *screen = &term->screen; + struct Tek_Char *t; + int l; + + t = &TekChar[screen->cur.fontsize]; + + if ((l = (screen->cur_Y + (t->vsize - 1)) / t->vsize + 1) >= t->nlines) { + l = 0; + if ((screen->margin = !screen->margin) != MARGIN1) { + if (screen->cur_X < TEKWIDTH / 2) + screen->cur_X += TEKWIDTH / 2; + } else if (screen->cur_X >= TEKWIDTH / 2) + screen->cur_X -= TEKWIDTH / 2; + } + screen->cur_Y = l * t->vsize; +} + +static void +TCursorDown(void) +{ + TScreen *screen = &term->screen; + struct Tek_Char *t; + int l; + + t = &TekChar[screen->cur.fontsize]; + + if ((l = screen->cur_Y / t->vsize - 1) < 0) { + l = t->nlines - 1; + if ((screen->margin = !screen->margin) != MARGIN1) { + if (screen->cur_X < TEKWIDTH / 2) + screen->cur_X += TEKWIDTH / 2; + } else if (screen->cur_X >= TEKWIDTH / 2) + screen->cur_X -= TEKWIDTH / 2; + } + screen->cur_Y = l * t->vsize; +} + +static void +AddToDraw(int x1, int y1, int x2, int y2) +{ + TScreen *screen = &term->screen; + XSegment *lp; + + TRACE(("AddToDraw (%d,%d) (%d,%d)\n", x1, y1, x2, y2)); + if (nplot >= MAX_PTS) { + TekFlush(); + } + lp = line_pt++; + lp->x1 = x1 = (int) (x1 * TekScale(screen) + screen->border); + lp->y1 = y1 = (int) ((TEKHEIGHT + TEKTOPPAD - y1) * TekScale(screen) + + screen->border); + lp->x2 = x2 = (int) (x2 * TekScale(screen) + screen->border); + lp->y2 = y2 = (int) ((TEKHEIGHT + TEKTOPPAD - y2) * TekScale(screen) + + screen->border); + nplot++; + TRACE(("...AddToDraw %d points\n", nplot)); +} + +static void +TekDraw(int x, int y) +{ + TScreen *screen = &term->screen; + + if (nplot == 0 || T_lastx != screen->cur_X || T_lasty != screen->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 && screen->cur.linetype != SOLIDLINE) + TekFlush(); + } + AddToDraw(screen->cur_X, screen->cur_Y, x, y); + T_lastx = screen->cur_X = x; + T_lasty = screen->cur_Y = y; +} + +static void +TekFlush(void) +{ + TScreen *screen = &term->screen; + + TRACE(("TekFlush\n")); + XDrawSegments(screen->display, TWindow(screen), + ((screen->cur.linetype == SOLIDLINE) ? screen->TnormalGC : + screen->linepat[screen->cur.linetype - 1]), + Tline, nplot); + nplot = 0; + line_pt = Tline; +} + +void +TekGINoff(void) +{ + TScreen *screen = &term->screen; + + TRACE(("TekGINoff\n")); + XDefineCursor(screen->display, TWindow(screen), screen->arrow); + if (GINcursor) + XFreeCursor(screen->display, GINcursor); + if (screen->TekGIN) { + *screen->TekGIN = CAN; /* modify recording */ + screen->TekGIN = NULL; + } +} + +void +TekEnqMouse(int c) /* character pressed */ +{ + TScreen *screen = &term->screen; + int mousex, mousey, rootx, rooty; + unsigned int mask; /* XQueryPointer */ + Window root, subw; + + TRACE(("TekEnqMouse\n")); + XQueryPointer( + screen->display, TWindow(screen), + &root, &subw, + &rootx, &rooty, + &mousex, &mousey, + &mask); + if ((mousex = (int) ((mousex - screen->border) / TekScale(screen))) < 0) + mousex = 0; + else if (mousex >= TEKWIDTH) + mousex = TEKWIDTH - 1; + if ((mousey = (int) (TEKHEIGHT + TEKTOPPAD - (mousey - screen->border) / + TekScale(screen))) < 0) + mousey = 0; + else if (mousey >= TEKHEIGHT) + mousey = TEKHEIGHT - 1; + TekEnq((unsigned) c, mousex, mousey); +} + +static void +TekEnq(unsigned status, + int x, + int y) +{ + TScreen *screen = &term->screen; + Char cplot[7]; + int len = 5; + int adj = (status != 0) ? 0 : 1; + + TRACE(("TekEnq\n")); + cplot[0] = status; + /* Translate x and y to Tektronix code */ + cplot[1] = 040 | ((x >> SHIFTHI) & FIVEBITS); + cplot[2] = 040 | ((x >> SHIFTLO) & FIVEBITS); + cplot[3] = 040 | ((y >> SHIFTHI) & FIVEBITS); + cplot[4] = 040 | ((y >> SHIFTLO) & FIVEBITS); + + if (screen->gin_terminator != GIN_TERM_NONE) + cplot[len++] = '\r'; + if (screen->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) +{ + TScreen *screen = &term->screen; + + TRACE(("TekRun ...\n")); + + if (!TWindow(screen) && !TekInit()) { + if (VWindow(screen)) { + screen->TekEmu = False; + return; + } + Exit(ERROR_TINIT); + } + if (!screen->Tshow) { + set_tek_visibility(True); + } + update_vttekmode(); + update_vtshow(); + update_tekshow(); + set_tekhide_sensitivity(); + + Tpushback = Tpushb; + Ttoggled = True; + if (!setjmp(Tekend)) + Tekparse(); + if (!Ttoggled) { + TCursorToggle(TOGGLE); + Ttoggled = True; + } + screen->TekEmu = False; +} + +#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 request GCC_UNUSED, + Widget wnew GCC_UNUSED, + ArgList args GCC_UNUSED, + Cardinal *num_args GCC_UNUSED) +{ + Widget tekparent = SHELL_OF(wnew); + + 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((Widget) wnew, PropertyChangeMask, False, + HandleBellPropertyChange, (Opaque) 0); +} + +static void +TekRealize(Widget gw GCC_UNUSED, /* same as tekWidget */ + XtValueMask * valuemaskp, + XSetWindowAttributes * values) +{ + TScreen *screen = &term->screen; + int i; + TekLink *tek; + double d; + int border = 2 * screen->border; + int pr; + XGCValues gcv; + int winX, winY, width, height; + XSizeHints sizehints; + char Tdefault[32]; + unsigned TEKgcFontMask; + + TRACE(("TekRealize\n")); + +#ifndef NO_ACTIVE_ICON + term->screen.whichTwin = &term->screen.fullTwin; +#endif /* NO_ACTIVE_ICON */ + + BorderPixel(tekWidget) = BorderPixel(term); + + for (i = 0; i < TEKNUMFONTS; i++) { + if (!tekWidget->tek.Tfont[i]) { + tekWidget->tek.Tfont[i] = XQueryFont(screen->display, DefaultGCID); + } + TRACE(("Tfont[%d] %dx%d\n", + i, + tekWidget->tek.Tfont[i]->ascent + + tekWidget->tek.Tfont[i]->descent, + tekWidget->tek.Tfont[i]->max_bounds.width)); + tekWidget->tek.tobaseline[i] = tekWidget->tek.Tfont[i]->ascent; + } + + if (!TekPtyData()) + return; + + if (term->misc.T_geometry == NULL) { + int defwidth, defheight; + + if (term->misc.tekSmall) { + defwidth = TEKMINWIDTH; + defheight = TEKMINHEIGHT; + } else { + defwidth = TEKDEFWIDTH; + defheight = TEKDEFHEIGHT; + } + sprintf(Tdefault, "=%dx%d", defwidth + border, defheight + border); + term->misc.T_geometry = Tdefault; + } + + winX = 1; + winY = 1; + width = TEKDEFWIDTH + border; + height = TEKDEFHEIGHT + border; + + TRACE(("parsing T_geometry %s\n", NonNull(term->misc.T_geometry))); + pr = XParseGeometry(term->misc.T_geometry, + &winX, + &winY, + (unsigned int *) &width, + (unsigned int *) &height); + TRACE(("... position %d,%d size %dx%d\n", winY, winX, height, width)); + if ((pr & XValue) && (pr & XNegative)) + winX += DisplayWidth(screen->display, DefaultScreen(screen->display)) + - width - (BorderWidth(SHELL_OF(term)) * 2); + if ((pr & YValue) && (pr & YNegative)) + winY += DisplayHeight(screen->display, DefaultScreen(screen->display)) + - height - (BorderWidth(SHELL_OF(term)) * 2); + + /* set up size hints */ + sizehints.min_width = TEKMINWIDTH + border; + sizehints.min_height = TEKMINHEIGHT + border; + sizehints.width_inc = 1; + sizehints.height_inc = 1; + sizehints.flags = PMinSize | PResizeInc; + sizehints.x = winX; + sizehints.y = winY; + if ((XValue & pr) || (YValue & pr)) { + sizehints.flags |= USSize | USPosition; + sizehints.flags |= PWinGravity; + switch (pr & (XNegative | YNegative)) { + case 0: + sizehints.win_gravity = NorthWestGravity; + break; + case XNegative: + sizehints.win_gravity = NorthEastGravity; + break; + case YNegative: + sizehints.win_gravity = SouthWestGravity; + break; + default: + sizehints.win_gravity = SouthEastGravity; + break; + } + } else { + /* set a default size, but do *not* set position */ + sizehints.flags |= PSize; + } + sizehints.width = width; + sizehints.height = height; + if ((WidthValue & pr) || (HeightValue & pr)) + sizehints.flags |= USSize; + else + sizehints.flags |= PSize; + + TRACE(("make resize request %dx%d\n", height, width)); + (void) XtMakeResizeRequest((Widget) tekWidget, + width, height, + &tekWidget->core.width, &tekWidget->core.height); + TRACE(("...made resize request %dx%d\n", tekWidget->core.height, tekWidget->core.width)); + + /* 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 (sizehints.flags & USPosition) + XMoveWindow(XtDisplay(tekWidget), TShellWindow, sizehints.x, sizehints.y); + + XSetWMNormalHints(XtDisplay(tekWidget), TShellWindow, &sizehints); + XFlush(XtDisplay(tekWidget)); /* get it out to window manager */ + + values->win_gravity = NorthWestGravity; + values->background_pixel = T_COLOR(screen, TEK_BG); + + XtWindow(tekWidget) = TWindow(screen) = + XCreateWindow(screen->display, + XtWindow(SHELL_OF(tekWidget)), + tekWidget->core.x, tekWidget->core.y, + tekWidget->core.width, tekWidget->core.height, BorderWidth(tekWidget), + (int) tekWidget->core.depth, + InputOutput, CopyFromParent, + ((*valuemaskp) | CWBackPixel | CWWinGravity), + values); + + TFullWidth(screen) = width; + TFullHeight(screen) = height; + TWidth(screen) = width - border; + THeight(screen) = height - border; + TekScale(screen) = (double) TWidth(screen) / TEKWIDTH; + if ((d = (double) THeight(screen) / (TEKHEIGHT + TEKTOPPAD + + TEKBOTTOMPAD)) < TekScale(screen)) + TekScale(screen) = d; + + screen->cur.fontsize = TEK_FONT_LARGE; + if (tekWidget->tek.initial_font) { + char *s = tekWidget->tek.initial_font; + + if (XmuCompareISOLatin1(s, "large") == 0) + screen->cur.fontsize = TEK_FONT_LARGE; + else if (XmuCompareISOLatin1(s, "2") == 0 || + XmuCompareISOLatin1(s, "two") == 0) + screen->cur.fontsize = TEK_FONT_2; + else if (XmuCompareISOLatin1(s, "3") == 0 || + XmuCompareISOLatin1(s, "three") == 0) + screen->cur.fontsize = TEK_FONT_3; + else if (XmuCompareISOLatin1(s, "small") == 0) + screen->cur.fontsize = TEK_FONT_SMALL; + } +#define TestGIN(s) XmuCompareISOLatin1(tekWidget->tek.gin_terminator_str, s) + + if (TestGIN(GIN_TERM_NONE_STR) == 0) + screen->gin_terminator = GIN_TERM_NONE; + else if (TestGIN(GIN_TERM_CR_STR) == 0) + screen->gin_terminator = GIN_TERM_CR; + else if (TestGIN(GIN_TERM_EOT_STR) == 0) + screen->gin_terminator = GIN_TERM_EOT; + else + fprintf(stderr, "%s: illegal GIN terminator setting \"%s\"\n", + xterm_name, tekWidget->tek.gin_terminator_str); + + gcv.graphics_exposures = True; /* default */ + gcv.font = tekWidget->tek.Tfont[screen->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 = (gcv.font == DefaultGCID) ? 0 : GCFont; + screen->TnormalGC = XCreateGC(screen->display, TWindow(screen), + (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; + screen->TcursorGC = XCreateGC(screen->display, TWindow(screen), + (GCFunction | GCPlaneMask), &gcv); + + gcv.foreground = T_COLOR(screen, TEK_FG); + gcv.line_style = LineOnOffDash; + gcv.line_width = 0; + for (i = 0; i < TEKNUMLINES; i++) { + screen->linepat[i] = XCreateGC(screen->display, TWindow(screen), + (GCForeground | GCLineStyle), &gcv); + XSetDashes(screen->display, screen->linepat[i], 0, + (char *) dashes[i], dash_length[i]); + } + + TekBackground(screen); + + screen->margin = MARGIN1; /* Margin 1 */ + screen->TekGIN = False; /* GIN off */ + + XDefineCursor(screen->display, TWindow(screen), screen->pointer_cursor); + + { /* 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(tekWidget), args, 2); + tek_icon_name = XtMalloc(strlen(icon_name) + 7); + strcpy(tek_icon_name, icon_name); + strcat(tek_icon_name, "(Tek)"); + tek_title = XtMalloc(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(tekWidget), args, 2); + XtFree(tek_icon_name); + XtFree(tek_title); + } + + tek = TekRecord = &Tek0; + tek->next = (TekLink *) 0; + tek->fontsize = screen->cur.fontsize; + tek->count = 0; + tek->ptr = tek->data; + Tpushback = Tpushb; + screen->cur_X = 0; + screen->cur_Y = TEKHOME; + line_pt = Tline; + Ttoggled = True; + screen->page = screen->cur; + return; +} + +void +TekSetFontSize(int newitem) +{ + TScreen *screen = &term->screen; + int oldsize = screen->cur.fontsize; + int newsize = MI2FS(newitem); + Font fid; + + TRACE(("TekSetFontSize(%d)\n", newitem)); + + if (!tekWidget || oldsize == newsize) + return; + if (!Ttoggled) + TCursorToggle(TOGGLE); + set_tekfont_menu_item(oldsize, False); + + fid = tekWidget->tek.Tfont[newsize]->fid; + if (fid == DefaultGCID) + /* we didn't succeed in opening a real font + for this size. Instead, use server default. */ + XCopyGC(screen->display, + DefaultGC(screen->display, DefaultScreen(screen->display)), + GCFont, screen->TnormalGC); + else + XSetFont(screen->display, screen->TnormalGC, fid); + + screen->cur.fontsize = newsize; + set_tekfont_menu_item(newsize, True); + if (!Ttoggled) + TCursorToggle(TOGGLE); +} + +void +ChangeTekColors(TScreen * screen, ScrnColors * pNew) +{ + 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 (tekWidget) { + XSetForeground(screen->display, screen->TnormalGC, + T_COLOR(screen, TEK_FG)); + XSetBackground(screen->display, screen->TnormalGC, + T_COLOR(screen, TEK_BG)); + if (BorderPixel(tekWidget) == T_COLOR(screen, TEK_BG)) { + BorderPixel(tekWidget) = T_COLOR(screen, TEK_FG); + BorderPixel(XtParent(tekWidget)) = T_COLOR(screen, TEK_FG); + if (XtWindow(XtParent(tekWidget))) + XSetWindowBorder(screen->display, + XtWindow(XtParent(tekWidget)), + BorderPixel(tekWidget)); + } + + for (i = 0; i < TEKNUMLINES; i++) { + XSetForeground(screen->display, screen->linepat[i], + T_COLOR(screen, TEK_FG)); + } + + gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^ + T_COLOR(screen, TEK_CURSOR)); + XChangeGC(screen->display, screen->TcursorGC, GCPlaneMask, &gcv); + TekBackground(screen); + } + return; +} + +void +TekReverseVideo(TScreen * screen) +{ + int i; + XGCValues gcv; + + EXCHANGE(T_COLOR(screen, TEK_FG), T_COLOR(screen, TEK_BG), i); + + T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG); + + if (tekWidget) { + XSetForeground(screen->display, screen->TnormalGC, T_COLOR(screen, TEK_FG)); + XSetBackground(screen->display, screen->TnormalGC, T_COLOR(screen, TEK_BG)); + + if (BorderPixel(tekWidget) == T_COLOR(screen, TEK_BG)) { + BorderPixel(tekWidget) = T_COLOR(screen, TEK_FG); + BorderPixel(XtParent(tekWidget)) = T_COLOR(screen, TEK_FG); + if (XtWindow(XtParent(tekWidget))) + XSetWindowBorder(screen->display, + XtWindow(XtParent(tekWidget)), + BorderPixel(tekWidget)); + } + + for (i = 0; i < TEKNUMLINES; i++) { + XSetForeground(screen->display, screen->linepat[i], + T_COLOR(screen, TEK_FG)); + } + + gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^ + T_COLOR(screen, TEK_CURSOR)); + XChangeGC(screen->display, screen->TcursorGC, GCPlaneMask, &gcv); + TekBackground(screen); + } +} + +static void +TekBackground(TScreen * screen) +{ + if (TWindow(screen)) + XSetWindowBackground(screen->display, TWindow(screen), + T_COLOR(screen, TEK_BG)); +} + +/* + * Toggles cursor on or off at cursor position in screen. + */ +void +TCursorToggle(int toggle) /* TOGGLE or CLEAR */ +{ + TScreen *screen = &term->screen; + int c, x, y; + unsigned int cellwidth, cellheight; + + if (!screen->Tshow) + return; + + c = screen->cur.fontsize; + cellwidth = (unsigned) tekWidget->tek.Tfont[c]->max_bounds.width; + cellheight = (unsigned) (tekWidget->tek.Tfont[c]->ascent + + tekWidget->tek.Tfont[c]->descent); + + x = (int) ((screen->cur_X * TekScale(screen)) + screen->border); + y = (int) (((TEKHEIGHT + TEKTOPPAD - screen->cur_Y) * TekScale(screen)) + + screen->border - tekWidget->tek.tobaseline[c]); + + if (toggle == TOGGLE) { + if (screen->select || screen->always_highlight) + XFillRectangle(screen->display, TWindow(screen), + screen->TcursorGC, x, y, + cellwidth, cellheight); + else { /* fix to use different GC! */ + XDrawRectangle(screen->display, TWindow(screen), + screen->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(screen->display, TWindow(screen), x, y, + cellwidth, cellheight, False); + } +} + +void +TekSimulatePageButton(Bool reset) +{ + TScreen *screen = &term->screen; + + if (!tekWidget) + return; + if (reset) { + bzero((char *) &screen->cur, sizeof screen->cur); + } + TekRefresh = (TekLink *) 0; + TekPage(); + screen->cur_X = 0; + screen->cur_Y = TEKHOME; +} + +/* write copy of screen to a file */ + +void +TekCopy(void) +{ + TScreen *screen = &term->screen; + + 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(XkbBI_MinorError, 0); + return; + } +#ifndef VMS + if (access(".", W_OK) < 0) { /* can't write in directory */ + Bell(XkbBI_MinorError, 0); + return; + } +#endif + + if ((tekcopyfd = open_userfile(screen->uid, screen->gid, buf, False)) >= 0) { + sprintf(initbuf, "%c%c%c%c", + ESC, (char) (screen->page.fontsize + '8'), + ESC, (char) (screen->page.linetype + '`')); + write(tekcopyfd, initbuf, 4); + Tp = &Tek0; + do { + write(tekcopyfd, Tp->data, Tp->count); + Tp = Tp->next; + } while (Tp); + close(tekcopyfd); + } +} diff --git a/nx-X11/programs/xterm/Tests b/nx-X11/programs/xterm/Tests new file mode 100644 index 000000000..0c6c88925 --- /dev/null +++ b/nx-X11/programs/xterm/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/nx-X11/programs/xterm/UXTerm.ad b/nx-X11/programs/xterm/UXTerm.ad new file mode 100644 index 000000000..b2180bfc5 --- /dev/null +++ b/nx-X11/programs/xterm/UXTerm.ad @@ -0,0 +1,38 @@ +! $XFree86: xc/programs/xterm/UXTerm.ad,v 1.4 2005/11/03 13:17:27 dickey Exp $ + +! Use +! xterm -class UXTerm +! to set resources for UTF-8 mode with corresponding fonts. +! See the uxterm script for an example. + +#include "XTerm-color" + +*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 diff --git a/nx-X11/programs/xterm/VTPrsTbl.c b/nx-X11/programs/xterm/VTPrsTbl.c new file mode 100644 index 000000000..043190e95 --- /dev/null +++ b/nx-X11/programs/xterm/VTPrsTbl.c @@ -0,0 +1,7216 @@ +/* $XTermId: VTPrsTbl.c,v 1.44 2005/11/13 23:10:35 tom Exp $ */ + +/* + * $Xorg: VTPrsTbl.c,v 1.3 2000/08/17 19:55:07 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/VTPrsTbl.c,v 3.29 2005/11/13 23:10:35 dickey Exp $ */ +/* + * + * Copyright 1999-2004,2005 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 + +#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 + +/* + * 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_IGNORE, +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_GROUND_STATE, +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_IGNORE, +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_GROUND_STATE, +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_IGNORE, +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_GROUND_STATE, +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_IGNORE, +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_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_GROUND_STATE, +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_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_GROUND_STATE, +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_GROUND_STATE, +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_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_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_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_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, +}; + +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_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_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_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_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_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 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_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_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_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_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, +}; + +/* + * 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/nx-X11/programs/xterm/VTparse.def b/nx-X11/programs/xterm/VTparse.def new file mode 100644 index 000000000..56c65ee4a --- /dev/null +++ b/nx-X11/programs/xterm/VTparse.def @@ -0,0 +1,142 @@ +# $XTermId: VTparse.def,v 1.25 2005/07/07 00:46:13 tom Exp $ +# +# $Xorg: VTparse.def,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ +# +# 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. +# +# $XFree86: xc/programs/xterm/VTparse.def,v 3.16 2005/07/07 00:46:13 dickey Exp $ +# + +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 diff --git a/nx-X11/programs/xterm/VTparse.h b/nx-X11/programs/xterm/VTparse.h new file mode 100644 index 000000000..8143e2a44 --- /dev/null +++ b/nx-X11/programs/xterm/VTparse.h @@ -0,0 +1,248 @@ +/* $XTermId: VTparse.h,v 1.38 2005/11/13 23:10:35 tom Exp $ */ + +/* + * $Xorg: VTparse.h,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/VTparse.h,v 3.22 2005/11/13 23:10:35 dickey Exp $ */ +/* + * Copyright 2002-2004,2005 by Thomas E. Dickey + * + * 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. + * + * 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 + +#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_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 scstable[]; +extern Const PARSE_T sos_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 + +#endif /* included_VTparse_h */ diff --git a/nx-X11/programs/xterm/XTerm-col.ad b/nx-X11/programs/xterm/XTerm-col.ad new file mode 100644 index 000000000..d8148ca82 --- /dev/null +++ b/nx-X11/programs/xterm/XTerm-col.ad @@ -0,0 +1,130 @@ +! $XTermId: XTerm-col.ad,v 1.19 2005/09/18 23:48:12 tom Exp $ +! $XFree86: xc/programs/xterm/XTerm-col.ad,v 3.7 2005/09/18 23:48:12 dickey Exp $ + +#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's 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.*.foreground: gray15 +*.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/nx-X11/programs/xterm/XTerm.ad b/nx-X11/programs/xterm/XTerm.ad new file mode 100644 index 000000000..bb492fc9a --- /dev/null +++ b/nx-X11/programs/xterm/XTerm.ad @@ -0,0 +1,185 @@ +! $Xorg: XTerm.ad,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ +! +! +! +! +! $XTermId: XTerm.ad,v 1.69 2005/11/03 13:17:27 tom Exp $ +! $XFree86: xc/programs/xterm/XTerm.ad,v 3.32 2005/11/03 13:17:27 dickey Exp $ + +*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*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*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*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 +*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*render-font*Label: TrueType Fonts +*fontMenu*utf8-mode*Label: UTF-8 + +*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 diff --git a/nx-X11/programs/xterm/aclocal.m4 b/nx-X11/programs/xterm/aclocal.m4 new file mode 100644 index 000000000..b5fb07053 --- /dev/null +++ b/nx-X11/programs/xterm/aclocal.m4 @@ -0,0 +1,2359 @@ +dnl $XTermId: aclocal.m4,v 1.206 2005/11/03 13:17:27 tom Exp $ +dnl +dnl $XFree86: xc/programs/xterm/aclocal.m4,v 3.60 2005/11/03 13:17:27 dickey Exp $ +dnl +dnl --------------------------------------------------------------------------- +dnl +dnl Copyright 1997-2004,2005 by Thomas E. Dickey +dnl +dnl All Rights Reserved +dnl +dnl Permission to use, copy, modify, and distribute this software and its +dnl documentation for any purpose and without fee is hereby granted, +dnl provided that the above copyright notice appear in all copies and that +dnl both that copyright notice and this permission notice appear in +dnl supporting documentation, and that the name of the above listed +dnl copyright holder(s) not be used in advertising or publicity pertaining +dnl to distribution of the software without specific, written prior +dnl permission. +dnl +dnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD +dnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +dnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE +dnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +dnl +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 ], + [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 and nl_langinfo(CODESET).]) + fi +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30 +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 + 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="$cf_new_cppflags $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_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34 +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: 3 updated: 1997/10/18 14:42:41 +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: 10 updated: 2004/05/23 13:03:31 +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_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 ],[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: 9 updated: 2001/12/30 18:03:23 +dnl -------------- +dnl Check for data that is usually declared in or , 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 +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 +#endif +#include +#include +#include ], + [long x = (long) $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,int) +])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: 10 updated: 2003/04/17 22:27:11 +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='# compiling' + SHOW_CC='# compiling' + 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_ENABLE_NARROWPROTO version: 1 updated: 2005/11/02 15:04:41 +dnl --------------------- +dnl If this is not set properly, Xaw's scrollbars will not work. +dnl The so-called "modular" configuration for Xorg 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=$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 +AC_DEFUN([CF_ERRNO], +[ +CF_CHECK_ERRNO(errno) +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_FUNC_MEMMOVE version: 5 updated: 2000/08/12 23:18:52 +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); + exit (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: 10 updated: 2005/09/18 15:26:47 +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" && LIBS="$LIBS -l$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"); + exit($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 && LIBS="$LIBS $cf_cv_lib_tgetent" + AC_DEFINE(USE_TERMCAP) + AC_TRY_COMPILE([ +#include ],[ +#ifdef NCURSES_VERSION +make an error +#endif],[AC_DEFINE(HAVE_TERMCAP_H)]) +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 + LIBS="$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: 10 updated: 2005/05/28 13:16:28 +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 < conftest.$ac_ext <&AC_FD_CC + case $cf_attribute in + scanf|printf) + cat >conftest.h <conftest.h <>confdefs.h + fi + done +else + fgrep define conftest.i >>confdefs.h +fi +rm -rf conftest* +fi +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42 +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| 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: 20 updated: 2005/08/06 18:37:29 +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 <],[ +#ifndef _XOPEN_SOURCE +make an error +#endif], + [cf_cv_gnu_source=no], + [cf_save="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" + AC_TRY_COMPILE([#include ],[ +#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: 27 updated: 2005/04/05 18:26:15 +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/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\\'"0-9 ]][[^ ]]*\([[ ]][[ ]]*[[^- ]][[^ ]]*\)*\)/\1='\\"\2\\"'/g +s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\\'"0-9 ]][[^ ]]*\)[[ ]]/\1='\\"\2\\"' /g +s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\\'"0-9 ]][[^ ]]*\)$/\1='\\"\2\\"'/g +s/^IMAKE[[ ]]*/IMAKE_CFLAGS="/ +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_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_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 +#include +#include +#include +#include +#include +],[ +{ + 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: 3 updated: 2005/08/06 18:37:29 +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 +#ifdef HAVE_LASTLOG_H +#include +#else +#ifdef HAVE_PATHS_H +#include +#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_MSG_LOG version: 3 updated: 1997/09/07 14:05:52 +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 "(line __oline__) testing $* ..." 1>&AC_FD_CC +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_PATH_PROG version: 6 updated: 2004/01/26 20:58:41 +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],[ +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" +case $host_os in #(vi +os2*) #(vi + IFS="${IFS};" + ;; +*) + IFS="${IFS}:" + ;; +esac + +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: 9 updated: 2002/09/17 23:03:38 +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],[ +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%$ac_default_prefix%` + ;; + esac + ;; #(vi +.NONE/*) + $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%` + ;; +*) + ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2) + ;; +esac +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10 +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 ],[ +#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 ],[ +#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 ],[ +#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" + if test "$cf_cv_cc_u_d_options" = yes ; then + cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \ + sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'` + CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source" + fi + CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source" +fi + +])dnl +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 +#include +#include +#ifdef HAVE_SYS_WAIT_H +#include +#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_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_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18 +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], +[ +# remove $3 symbol from $2 +$1=`echo "$2" | \ + sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \ + -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'` +])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 +#include +#include + +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 +AC_DEFUN([CF_SIZE_T], +[ +AC_MSG_CHECKING(for size_t in or ) +AC_CACHE_VAL(cf_cv_type_size_t,[ + AC_TRY_COMPILE([ +#include +#ifdef STDC_HEADERS +#include +#include +#endif +#include ], + [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_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 +#include +],[ +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: 10 updated: 2005/09/18 15:42:35 +dnl ------- +dnl Check if this is a SYSV platform, e.g., as used in , and whether +dnl defining it will be helpful. The following features are used to check: +dnl +dnl a) bona-fide SVSY 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( \ +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 /* look for wchar_t */ +#endif +#ifdef HAVE_X11_INTRINSIC_H +#include /* Intrinsic.h has other traps... */ +#endif +#include +#include /* eliminate most BSD hacks */ +#include /* declare sys_errlist on older systems */ +#include /* eliminate most of the remaining ones */ +],[ +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; +#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 +#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 +#include ],[ +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_TTY_GROUP version: 5 updated: 2003/03/19 23:52:35 +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_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/(.*$//'` +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 + read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest /dev/null 1>/dev/null ) then + cf_cv_tty_group_name="tty" + fi + ;; +esac +fi +]) + +AC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_cv_tty_group_name") + +# 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 $cf_cv_tty_group_name group,cf_cv_tty_group,[ +cf_tty_name=`tty` +if test "$cf_tty_name" != "not a tty" +then +AC_TRY_RUN([ +#include +#include +#include +#include +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) { + exit(0); + } + exit(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 +]) +test $cf_cv_tty_group = yes && AC_DEFINE(USE_TTY_GROUP) +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_TYPE_FD_SET version: 3 updated: 1999/10/16 13:49:00 +dnl -------------- +dnl Check for the declaration of fd_set. Some platforms declare it in +dnl , and some in , which requires . +dnl Finally, if we are using this for an X application, Xpoll.h may include +dnl , so we don't want to do it twice. +AC_DEFUN([CF_TYPE_FD_SET], +[ +AC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set, + [echo "trying sys/types alone" 1>&AC_FD_CC +AC_TRY_COMPILE([ +#include ], + [fd_set x], + [cf_cv_type_fd_set=sys/types.h], + [echo "trying X11/Xpoll.h" 1>&AC_FD_CC +AC_TRY_COMPILE([ +#ifdef HAVE_X11_XPOLL_H +#include +#endif], + [fd_set x], + [cf_cv_type_fd_set=X11/Xpoll.h], + [echo "trying sys/select.h" 1>&AC_FD_CC +AC_TRY_COMPILE([ +#include +#include ], + [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: 2 updated: 2000/01/22 22:50:59 +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" +LIBS="-lutempter $LIBS" +AC_TRY_LINK([ +#include +],[ + 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) + LIBS="-lutempter $LIBS" +fi +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_UTMP version: 8 updated: 2002/10/27 23:21:42 +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 +#include <${cf_header}.h> +#define getutent getutxent +#ifdef USE_LASTLOG +#include /* 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_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 + read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest +#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: 3 updated: 2002/10/27 23:21:42 +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 utmp.ut_name is declared,cf_cv_have_utmp_ut_name,[ + cf_cv_have_utmp_ut_name=no +cf_utmp_includes=" +#include +#include <${cf_cv_have_utmp}.h> +#define getutent getutxent +#ifdef USE_LASTLOG +#include /* 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: 4 updated: 2002/10/27 23:21:42 +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 utmp.ut_session is declared, cf_cv_have_utmp_ut_session,[ + AC_TRY_COMPILE([ +#include +#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_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 +#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: 6 updated: 2002/10/27 23:21:42 +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 utmp.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[ + AC_TRY_COMPILE([ +#include +#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 +#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: 2 updated: 1997/09/05 10:45:14 +dnl ---------- +dnl Use AC_VERBOSE w/o the warnings +AC_DEFUN([CF_VERBOSE], +[test -n "$verbose" && echo " $1" 1>&AC_FD_MSG +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_WITH_IMAKE_CFLAGS version: 8 updated: 2005/11/02 15:04:41 +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: 6 updated: 1998/10/11 00:40:17 +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 +CF_PATH_SYNTAX(withval) +eval $3="$withval" +AC_SUBST($3)dnl +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_XKB_BELL_EXT version: 2 updated: 2003/05/18 17:28:57 +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 /* has the prototype */ +#include /* has the XkbBI_xxx definitions */ +],[ +int x = XkbBI_Info + |XkbBI_MinorError + |XkbBI_MajorError + |XkbBI_TerminalBell + |XkbBI_MarginBell; +],[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: 23 updated: 2005/10/15 16:39:05 +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 +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],[ + +AC_REQUIRE([CF_PROG_CC_U_D]) + +cf_XOPEN_SOURCE=ifelse($1,,500,$1) +cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2) + +case $host_os in #(vi +aix[[45]]*) #(vi + CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE" + ;; +freebsd*) #(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 + CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + ;; +hpux*) #(vi + CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE" + ;; +irix[[56]].*) #(vi + CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE" + ;; +linux*|gnu*) #(vi + CF_GNU_SOURCE + ;; +mirbsd*) #(vi + # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks + ;; +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 + CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE" + ;; +nto-qnx*) #(vi + CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE" + ;; +sco*) #(vi + # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer + ;; +solaris*) #(vi + CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__" + ;; +*) + AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[ + AC_TRY_COMPILE([#include ],[ +#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 ],[ +#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) + test "$cf_cv_cc_u_d_options" = yes && \ + CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE" + CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source" + fi + CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) + ;; +esac +]) +dnl --------------------------------------------------------------------------- +dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41 +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], +[AC_REQUIRE([CF_X_TOOLKIT]) +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 + +AC_CHECK_LIB(Xext,XextCreateExtension, + [LIBS="-lXext $LIBS"]) + +cf_x_athena_lib="" + +CF_X_ATHENA_CPPFLAGS($cf_x_athena) +CF_X_ATHENA_LIBS($cf_x_athena) +])dnl +dnl --------------------------------------------------------------------------- +dnl CF_X_ATHENA_CPPFLAGS version: 2 updated: 2002/10/09 20:00:37 +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_include="" + +for cf_path in default \ + /usr/contrib/X11R6 \ + /usr/contrib/X11R5 \ + /usr/lib/X11R5 \ + /usr/local +do + if test -z "$cf_x_athena_include" ; then + cf_save="$CPPFLAGS" + cf_test=X11/$cf_x_athena_root/SimpleMenu.h + if test $cf_path != default ; then + CPPFLAGS="-I$cf_path/include $cf_save" + AC_MSG_CHECKING(for $cf_test in $cf_path) + else + AC_MSG_CHECKING(for $cf_test) + fi + AC_TRY_COMPILE([ +#include +#include <$cf_test>],[], + [cf_result=yes], + [cf_result=no]) + AC_MSG_RESULT($cf_result) + if test "$cf_result" = yes ; then + cf_x_athena_include=$cf_path + break + else + CPPFLAGS="$cf_save" + fi + fi +done + +if test -z "$cf_x_athena_include" ; then + AC_MSG_WARN( +[Unable to successfully find Athena header files with test program]) +elif test "$cf_x_athena_include" != default ; then + CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include" +fi +]) +dnl --------------------------------------------------------------------------- +dnl CF_X_ATHENA_LIBS version: 3 updated: 2003/02/16 15:24:54 +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 + LIBS="-L$cf_path/lib $cf_lib $LIBS" + AC_MSG_CHECKING(for $cf_lib in $cf_path) + else + LIBS="$cf_lib $LIBS" + AC_MSG_CHECKING(for $cf_test in $cf_lib) + fi + cf_SAVE="$LIBS" + LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS" + 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" + LIBS="$cf_SAVE" + break + else + LIBS="$cf_save" + fi + fi + done +done + +if test -z "$cf_x_athena_lib" ; then + AC_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_FREETYPE version: 11 updated: 2004/04/25 16:43:59 +dnl ------------- +dnl Check for X FreeType headers and libraries (XFree86 4.x). +dnl +dnl If either or both of these configure-script options are not given, rely on +dnl the output of xft-config or the older freetype-config to provide the +dnl cflags/libs options. +dnl --with-freetype-cflags +dnl --with-freetype-libs +AC_DEFUN([CF_X_FREETYPE], +[ +cf_extra_freetype_libs= +AC_PATH_PROG(FREETYPE_CONFIG, xft-config, none) +if test "$FREETYPE_CONFIG" = none; then + cf_extra_freetype_libs="-lXft" + AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none) +fi + +if test "$FREETYPE_CONFIG" != none ; then + +AC_ARG_WITH(freetype-cflags, + [ --with-freetype-cflags -D/-I options for compiling with FreeType], +[cf_cv_x_freetype_incs="$withval" + CF_VERBOSE(freetype-cflags $cf_cv_x_freetype_incs) +],[ +AC_CACHE_CHECK(for X FreeType headers,cf_cv_x_freetype_incs,[ + cf_cv_x_freetype_incs="`$FREETYPE_CONFIG --cflags 2>/dev/null`" +])]) + +AC_ARG_WITH(freetype-libs, + [ --with-freetype-libs -L/-l options to link FreeType], +[cf_cv_x_freetype_libs="$withval" + CF_VERBOSE(freetype-libs $cf_cv_x_freetype_libs) +],[ +AC_CACHE_CHECK(for X FreeType libraries,cf_cv_x_freetype_libs,[ + +cf_save_LIBS="$LIBS" +cf_save_INCS="$CPPFLAGS" + +cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG --libs 2>/dev/null`" + +LIBS="$cf_cv_x_freetype_libs $LIBS" +CPPFLAGS="$cf_cv_x_freetype_incs $CPPFLAGS" + +AC_TRY_LINK([ +#include +#include +#include ],[ + XftPattern *pat = XftNameParse ("name"); + ],[],[cf_cv_x_freetype_libs=]) + LIBS="$cf_save_LIBS" + CPPFLAGS="$cf_save_INCS" +])]) + +if test -n "$cf_cv_x_freetype_libs" ; then + LIBS="$cf_cv_x_freetype_libs $LIBS" + CF_ADD_CFLAGS($cf_cv_x_freetype_incs) + AC_DEFINE(XRENDERFONT) +else + CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//` +fi +else + CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//` +fi + +# FIXME: revisit this if needed +AC_SUBST(XRENDERFONT) +AC_SUBST(HAVE_TYPE_FCCHAR32) +AC_SUBST(HAVE_TYPE_XFTCHARSPEC) +]) +dnl --------------------------------------------------------------------------- +dnl CF_X_TOOLKIT version: 10 updated: 2004/04/25 15:37:17 +dnl ------------ +dnl Check for X Toolkit libraries +dnl +AC_DEFUN([CF_X_TOOLKIT], +[ +AC_REQUIRE([AC_PATH_XTRA]) +AC_REQUIRE([CF_CHECK_CACHE]) + +# SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -` + +cf_have_X_LIBS=no + +LDFLAGS="$X_LIBS $LDFLAGS" +CF_CHECK_CFLAGS($X_CFLAGS) + +AC_CHECK_FUNC(XOpenDisplay,,[ +AC_CHECK_LIB(X11,XOpenDisplay, + [LIBS="-lX11 $LIBS"],, + [$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_PRE_LIBS $LIBS $X_EXTRA_LIBS])]) + +if test $cf_have_X_LIBS = no ; then + AC_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/nx-X11/programs/xterm/button.c b/nx-X11/programs/xterm/button.c new file mode 100644 index 000000000..d8d0b32b3 --- /dev/null +++ b/nx-X11/programs/xterm/button.c @@ -0,0 +1,3284 @@ +/* $XTermId: button.c,v 1.197 2005/11/03 13:17:27 tom Exp $ */ + +/* $Xorg: button.c,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ */ +/* + * Copyright 1999-2004,2005 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. + */ +/* $XFree86: xc/programs/xterm/button.c,v 3.82 2005/11/03 13:17:27 dickey Exp $ */ + +/* +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 + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#if OPT_WIDE_CHARS +#include +#else +#define CharacterClass(value) \ + charClass[value & ((sizeof(charClass)/sizeof(charClass[0]))-1)] +#endif + +#define XTERM_CELL(row,col) getXtermCell(screen, row + screen->topline, col) +#define XTERM_CELL_C1(row,col) getXtermCellComb1(screen, row + screen->topline, col) +#define XTERM_CELL_C2(row,col) getXtermCellComb2(screen, row + screen->topline, col) + + /* + * 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 KeyModifiers (event->xbutton.state & OurModifiers) + +#define KeyState(x) (((x) & (ShiftMask|ControlMask)) + (((x) & Mod1Mask) ? 2 : 0)) + /* adds together the bits: + shift key -> 1 + meta key -> 2 + control key -> 4 */ + +#define Coordinate(r,c) ((r) * MaxCols(&(term->screen)) + (c)) + +#if OPT_DEC_LOCATOR +static ANSI reply; +#endif + +/* Selection/extension variables */ + +/* Raw char position where the selection started */ +static int rawRow, rawCol; + +/* Selected area before CHAR, WORD, LINE selectUnit processing */ +static int startRRow, startRCol, endRRow, endRCol = 0; + +/* Selected area after CHAR, WORD, LINE selectUnit processing */ +static int startSRow, startSCol, endSRow, endSCol = 0; + +/* Valid rows for selection clipping */ +static int firstValidRow, lastValidRow; + +/* Start, end of extension */ +static int startERow, startECol, endERow, endECol; + +/* Saved values of raw selection for extend to restore to */ +static int saveStartRRow, saveStartRCol, saveEndRRow, saveEndRCol; + +/* Saved value of WORD selection for LINE processing to restore to */ +static int saveStartWRow, saveStartWCol; + +/* Multi-click handling */ +static int numberOfClicks = 0; +static Time lastButtonUpTime = 0; + +#if OPT_READLINE +static Time lastButtonDownTime = 0; +static int ExtendingSelection = 0; +static Time lastButton3UpTime = 0; +static Time lastButton3DoubleDownTime = 0; +static int lastButton3row, lastButton3col; /* At the release time */ +#endif /* OPT_READLINE */ + +typedef int SelectUnit; + +#define SELECTCHAR 0 +#define SELECTWORD 1 +#define SELECTLINE 2 +#define NSELECTUNITS 3 +static SelectUnit selectUnit; + +/* Send emacs escape code when done selecting or extending? */ +static int replyToEmacs; + +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(int startRow, int startCol, int endRow, int + endCol, Bool extend); +static void EditorButton(XButtonEvent * event); +static void EndExtend(Widget w, XEvent * event, String * params, Cardinal + num_params, Bool use_cursor_loc); +static void ExtendExtend(int row, int col); +static void PointToRowCol(int y, int x, int *r, int *c); +static void ReHiliteText(int frow, int fcol, int trow, int tcol); +static void SaltTextAway(int crow, int ccol, int row, int col, String * + params, Cardinal num_params); +static void SelectSet(Widget w, XEvent * event, String * params, Cardinal num_params); +static void SelectionReceived PROTO_XT_SEL_CB_ARGS; +static void StartSelect(int startrow, int startcol); +static void TrackDown(XButtonEvent * event); +static void _OwnSelection(XtermWidget termw, String * selections, Cardinal count); +static void do_select_end(Widget w, XEvent * event, String * params, + Cardinal *num_params, Bool use_cursor_loc); + +Bool +SendMousePosition(Widget w, XEvent * event) +{ + TScreen *screen; + + if (!IsXtermWidget(w)) + return False; + + screen = &((XtermWidget) w)->screen; + + /* If send_mouse_pos mode isn't on, we shouldn't be here */ + if (screen->send_mouse_pos == MOUSE_OFF) + return False; + +#if OPT_DEC_LOCATOR + if (screen->send_mouse_pos == DEC_LOCATOR) { + return (SendLocatorPosition(w, event)); + } +#endif /* OPT_DEC_LOCATOR */ + + /* Make sure the event is an appropriate type */ + if ((screen->send_mouse_pos != BTN_EVENT_MOUSE) + && (screen->send_mouse_pos != ANY_EVENT_MOUSE) + && event->type != ButtonPress + && event->type != ButtonRelease) + return False; + + switch (screen->send_mouse_pos) { + case X10_MOUSE: /* X10 compatibility sequences */ + + if (KeyModifiers == 0) { + if (event->type == ButtonPress) + EditorButton((XButtonEvent *) event); + return True; + } + return False; + + case VT200_HIGHLIGHT_MOUSE: /* DEC vt200 hilite tracking */ + if (event->type == ButtonPress && + KeyModifiers == 0 && + event->xbutton.button == Button1) { + TrackDown((XButtonEvent *) event); + return True; + } + if (KeyModifiers == 0 || KeyModifiers == ControlMask) { + EditorButton((XButtonEvent *) event); + return True; + } + return False; + + case VT200_MOUSE: /* DEC vt200 compatible */ + + /* xterm extension for motion reporting. June 1998 */ + /* EditorButton() will distinguish between the modes */ + case BTN_EVENT_MOUSE: + case ANY_EVENT_MOUSE: + if (KeyModifiers == 0 || KeyModifiers == ControlMask) { + EditorButton((XButtonEvent *) event); + return True; + } + return False; + + default: + return False; + } +} + +#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)++; \ + } + +Bool +SendLocatorPosition(Widget w, XEvent * event) +{ + TScreen *screen = &((XtermWidget) w)->screen; + int row, col; + Bool oor; + int button; + int state; + + /* Make sure the event is an appropriate type */ + if ((event->type != ButtonPress && + event->type != ButtonRelease && + !screen->loc_filter) || + (KeyModifiers != 0 && KeyModifiers != 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(w, event); + return (True); + } + + /* get button # */ + button = event->xbutton.button - 1; + + LocatorCoords(row, col, event->xbutton.x, event->xbutton.y, oor); + + /* + * DECterm mouse: + * + * ESCAPE '[' event ; mask ; row ; column '&' 'w' + */ + reply.a_type = CSI; + + if (oor) { + reply.a_nparam = 1; + reply.a_param[0] = 0; /* Event - 0 = locator unavailable */ + reply.a_inters = '&'; + reply.a_final = 'w'; + unparseseq(&reply, screen->respond); + + if (screen->locator_reset) { + MotionOff(screen, term); + 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] = 2 + (button << 1); + break; + case ButtonRelease: + reply.a_param[0] = 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->xbutton.state + & (Button1Mask | Button2Mask | Button3Mask | Button4Mask)) >> 8; + state ^= 1 << button; /* update mask to "after" state */ + state = (state & ~(4 | 1)) | ((state & 1) ? 4 : 0) | ((state & 4) ? 1 : 0); /* swap Button1 & Button3 */ + + reply.a_param[1] = state; + reply.a_param[2] = row; + reply.a_param[3] = col; + reply.a_inters = '&'; + reply.a_final = 'w'; + + unparseseq(&reply, screen->respond); + + if (screen->locator_reset) { + MotionOff(screen, term); + 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, term); + } + + 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) = ((mask) & (Button1Mask | Button2Mask | Button3Mask | Button4Mask)) >> 8; \ + /* swap Button1 & Button3 */ \ + (state) = ((state) & ~(4|1)) | (((state)&1)?4:0) | (((state)&4)?1:0); \ +} + +void +GetLocatorPosition(XtermWidget w) +{ + TScreen *screen = &w->screen; + 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, term); + } + + reply.a_type = 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(&reply, screen->respond); + + if (screen->locator_reset) { + MotionOff(screen, term); + 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] = state; + reply.a_param[2] = row; + reply.a_param[3] = col; + reply.a_inters = '&'; + reply.a_final = 'w'; + unparseseq(&reply, screen->respond); + + if (screen->locator_reset) { + MotionOff(screen, term); + screen->send_mouse_pos = MOUSE_OFF; + } +} + +void +InitLocatorFilter(XtermWidget w) +{ + TScreen *screen = &w->screen; + 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. + */ + reply.a_type = CSI; + reply.a_nparam = 1; + reply.a_param[0] = 0; /* Event - 0 = locator unavailable */ + reply.a_inters = '&'; + reply.a_final = 'w'; + unparseseq(&reply, screen->respond); + + if (screen->locator_reset) { + MotionOff(screen, term); + 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, term); + } + 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); + + reply.a_type = CSI; + reply.a_nparam = 4; + reply.a_param[0] = 10; /* Event - 10 = locator outside filter */ + reply.a_param[1] = state; + reply.a_param[2] = row; + reply.a_param[3] = col; + reply.a_inters = '&'; + reply.a_final = 'w'; + unparseseq(&reply, screen->respond); + + if (screen->locator_reset) { + MotionOff(screen, term); + 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, term); +} + +void +CheckLocatorPosition(Widget w, XEvent * event) +{ + TScreen *screen = &((XtermWidget) w)->screen; + int row, col; + Bool oor; + int state; + + LocatorCoords(row, col, event->xbutton.x, event->xbutton.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, term); + + reply.a_type = CSI; + if (oor) { + reply.a_nparam = 1; + reply.a_param[0] = 0; /* Event - 0 = locator unavailable */ + } else { + ButtonState(state, event->xbutton.state); + + reply.a_nparam = 4; + reply.a_param[0] = 10; /* Event - 10 = locator outside filter */ + reply.a_param[1] = state; + reply.a_param[2] = row; + reply.a_param[3] = col; + } + + reply.a_inters = '&'; + reply.a_final = 'w'; + unparseseq(&reply, screen->respond); + + if (screen->locator_reset) { + MotionOff(screen, term); + screen->send_mouse_pos = MOUSE_OFF; + } + } +} +#endif /* OPT_DEC_LOCATOR */ + +#if OPT_READLINE +static int +isClick1_clean(XEvent * event) +{ + TScreen *screen = &term->screen; + int delta; + + if (!(event->type == ButtonPress || event->type == ButtonRelease) + /* Disable on Shift-Click-1, including the application-mouse modes */ + || (KeyModifiers & 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 = term->screen.multiClickTime + 1; + else if (event->xbutton.time > lastButtonDownTime) /* most of the time */ + delta = event->xbutton.time - lastButtonDownTime; + else /* time has rolled over since lastButtonUpTime */ + delta = (((Time) ~ 0) - lastButtonDownTime) + event->xbutton.time; + return delta <= term->screen.multiClickTime; +} + +static int +isDoubleClick3(XEvent * event) +{ + int delta; + + if (event->type != ButtonRelease + || (KeyModifiers & ShiftMask) + || event->xbutton.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 = term->screen.multiClickTime + 1; + else if (event->xbutton.time > lastButton3DoubleDownTime) /* most of the time */ + delta = event->xbutton.time - lastButton3DoubleDownTime; + else /* time has rolled over since lastButton3DoubleDownTime */ + delta = (((Time) ~ 0) - lastButton3DoubleDownTime) + event->xbutton.time; + if (delta <= term->screen.multiClickTime) { + /* Double click */ + int row, col; + + /* Cannot check ExtendingSelection, since mouse-3 always sets it */ + PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); + if (row == lastButton3row && col == lastButton3col) { + lastButton3DoubleDownTime = 0; /* Disable the third click */ + return 1; + } + } + /* Not a double click, memorize for future check. */ + lastButton3UpTime = event->xbutton.time; + PointToRowCol(event->xbutton.y, event->xbutton.x, + &lastButton3row, &lastButton3col); + return 0; +} + +static int +CheckSecondPress3(XEvent * event) +{ + int delta, row, col; + + if (event->type != ButtonPress + || (KeyModifiers & 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 = term->screen.multiClickTime + 1; + else if (event->xbutton.time > lastButton3UpTime) /* most of the time */ + delta = event->xbutton.time - lastButton3UpTime; + else /* time has rolled over since lastButton3UpTime */ + delta = (((Time) ~ 0) - lastButton3UpTime) + event->xbutton.time; + if (delta <= term->screen.multiClickTime) { + PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); + if (row == lastButton3row && col == lastButton3col) { + /* A candidate for a double-click */ + lastButton3DoubleDownTime = event->xbutton.time; + PointToRowCol(event->xbutton.y, event->xbutton.x, + &lastButton3row, &lastButton3col); + return 1; + } + lastButton3UpTime = 0; /* Disable the info about the previous click */ + } + /* Either too long, or moved, disable. */ + lastButton3DoubleDownTime = 0; + return 0; +} + +static int +rowOnCurrentLine(int line, int *deltap) /* must be XButtonEvent */ +{ + TScreen *screen = &term->screen; + int l1, l2; + + *deltap = 0; + if (line == screen->cur_row) + return 1; + + if (line < screen->cur_row) + l1 = line, l2 = screen->cur_row; + else + l2 = line, l1 = screen->cur_row; + l1--; + while (++l1 < l2) + if (!ScrnTstWrapped(screen, l1)) + return 0; + /* Everything is on one "wrapped line" now */ + *deltap = line - screen->cur_row; + return 1; +} + +static int +eventRow(XEvent * event) /* must be XButtonEvent */ +{ + TScreen *screen = &term->screen; + + return (event->xbutton.y - screen->border) / FontHeight(screen); +} + +static int +eventColBetween(XEvent * event) /* must be XButtonEvent */ +{ + TScreen *screen = &term->screen; + + /* 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(int col, int ldelta) +{ + TScreen *screen = &term->screen; + 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++] = CSI; + } else { + line[count++] = ESC; + line[count++] = '['; /* XXX maybe sometimes O is better? */ + } + line[count++] = (col > 0 ? 'C' : 'D'); + if (col < 0) + col = -col; + while (col--) + v_write(screen->respond, line, 3); + return 1; +} + +static int +ReadLineDelete(int r1, int c1, int r2, int c2) +{ + TScreen *screen = &term->screen; + int del; + + del = c2 - c1 + (r2 - r1) * MaxCols(screen); + if (del <= 0) /* Just in case... */ + return 0; + while (del--) + v_write(screen->respond, (Char *) "\177", 1); + return 1; +} +#endif /* OPT_READLINE */ + +/* ^XM-G */ +void +DiredButton(Widget w GCC_UNUSED, + XEvent * event, /* must be XButtonEvent */ + String * params GCC_UNUSED, /* selections */ + Cardinal *num_params GCC_UNUSED) +{ + TScreen *screen = &term->screen; + Char Line[6]; + unsigned line, col; + + if (event->type == ButtonPress || event->type == ButtonRelease) { + line = (event->xbutton.y - screen->border) / FontHeight(screen); + col = (event->xbutton.x - OriginX(screen)) / FontWidth(screen); + Line[0] = CONTROL('X'); + Line[1] = ESC; + Line[2] = 'G'; + Line[3] = ' ' + col; + Line[4] = ' ' + line; + v_write(screen->respond, Line, 5); + } +} + +#if OPT_READLINE +void +ReadLineButton(Widget w GCC_UNUSED, + XEvent * event, /* must be XButtonEvent */ + String * params GCC_UNUSED, /* selections */ + Cardinal *num_params GCC_UNUSED) +{ + TScreen *screen = &term->screen; + Char Line[6]; + int line, col, ldelta = 0; + + if (!(event->type == ButtonPress || event->type == ButtonRelease) + || (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 = event->xbutton.time - lastButtonDownTime; + else /* time has rolled over since lastButtonUpTime */ + delta = (((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 (line != screen->cur_row) { + int l1, l2; + + if (line < screen->cur_row) + l1 = line, l2 = screen->cur_row; + else + l2 = line, l1 = screen->cur_row; + l1--; + while (++l1 < l2) + if (!ScrnTstWrapped(screen, l1)) + goto finish; + /* Everything is on one "wrapped line" now */ + ldelta = line - screen->cur_row; + } + /* 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] = ESC; + /* XXX: sometimes it is better to send '['? */ + Line[1] = 'O'; + Line[2] = (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(w, event, params, num_params, False); +} +#endif /* OPT_READLINE */ + +/* repeats n or p */ +void +ViButton(Widget w GCC_UNUSED, + XEvent * event, /* must be XButtonEvent */ + String * params GCC_UNUSED, /* selections */ + Cardinal *num_params GCC_UNUSED) +{ + TScreen *screen = &term->screen; + int pty = screen->respond; + Char Line[6]; + int line; + + if (event->type == ButtonPress || event->type == ButtonRelease) { + + line = screen->cur_row - + ((event->xbutton.y - screen->border) / FontHeight(screen)); + if (line != 0) { + Line[0] = 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) +{ + TScreen *screen; + int row, col; + + if (!IsXtermWidget(w)) + return; + + screen = &((XtermWidget) w)->screen; + screen->selection_time = event->xmotion.time; + switch (eventMode) { + /* If not in one of the DEC mouse-reporting modes */ + case LEFTEXTENSION: + case RIGHTEXTENSION: + PointToRowCol(event->xmotion.y, event->xmotion.x, + &row, &col); + ExtendExtend(row, col); + 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(w, event); + } + break; + } +} + +void +HandleKeyboardSelectExtend(Widget w, + XEvent * event GCC_UNUSED, /* must be XButtonEvent */ + String * params GCC_UNUSED, + Cardinal *num_params GCC_UNUSED) +{ + TScreen *screen; + + if (!IsXtermWidget(w)) + return; + + screen = &((XtermWidget) w)->screen; + ExtendExtend(screen->cursor_row, screen->cursor_col); +} + +static void +do_select_end(Widget w, + XEvent * event, /* must be XButtonEvent */ + String * params, /* selections */ + Cardinal *num_params, + Bool use_cursor_loc) +{ +#if OPT_READLINE + int ldelta1, ldelta2; + TScreen *screen = &term->screen; +#endif + + if (!IsXtermWidget(w)) { + return; + } + + ((XtermWidget) w)->screen.selection_time = event->xbutton.time; + switch (eventMode) { + case NORMAL: + (void) SendMousePosition(w, event); + break; + case LEFTEXTENSION: + case RIGHTEXTENSION: + EndExtend(w, event, params, *num_params, use_cursor_loc); +#if OPT_READLINE + if (isClick1_clean(event) + && SCREEN_FLAG(screen, click1_moves) + && rowOnCurrentLine(eventRow(event), &ldelta1)) { + ReadLineMovePoint(eventColBetween(event), ldelta1); + } + if (isDoubleClick3(event) + && SCREEN_FLAG(screen, dclick3_deletes) + && rowOnCurrentLine(startSRow, &ldelta1) + && rowOnCurrentLine(endSRow, &ldelta2)) { + ReadLineMovePoint(endSCol, ldelta2); + ReadLineDelete(startSRow, startSCol, endSRow, endSCol); + } +#endif /* OPT_READLINE */ + break; + } +} + +void +HandleSelectEnd(Widget w, + XEvent * event, /* must be XButtonEvent */ + String * params, /* selections */ + Cardinal *num_params) +{ + do_select_end(w, event, params, num_params, False); +} + +void +HandleKeyboardSelectEnd(Widget w, + XEvent * event, /* must be XButtonEvent */ + String * params, /* selections */ + Cardinal *num_params) +{ + do_select_end(w, event, params, num_params, True); +} + +struct _SelectionList { + String *params; + Cardinal count; + Atom *targets; + Time time; +}; + +/* convert a UTF-8 string to Latin-1, replacing non Latin-1 characters + * by `#'. */ + +#if OPT_WIDE_CHARS +static Char * +UTF8toLatin1(Char * s, unsigned len, unsigned long *result) +{ + static Char *buffer; + static size_t used; + + Char *p = s; + Char *q; + + if (used == 0) { + buffer = (Char *) XtMalloc(used = len); + } else if (len > used) { + buffer = (Char *) XtRealloc((char *) buffer, used = len); + } + q = buffer; + + /* We're assuming that the xterm widget never contains Unicode + control characters. */ + + while (p < s + len) { + if ((*p & 0x80) == 0) { + *q++ = *p++; + } else if ((*p & 0x7C) == 0x40 && p < s + len - 1) { + *q++ = ((*p & 0x03) << 6) | (p[1] & 0x3F); + p += 2; + } else if ((*p & 0x60) == 0x40) { + *q++ = '#'; + p += 2; + } else if ((*p & 0x50) == 0x40) { + *q++ = '#'; + p += 3; + } else { /* this cannot happen */ + *q++ = '#'; + p++; + } + } + *result = q - buffer; + return buffer; +} +#endif /* OPT_WIDE_CHARS */ + +static Atom * +_SelectionTargets(Widget w) +{ + static Atom *eightBitSelectionTargets = NULL; + TScreen *screen; + int n; + + if (!IsXtermWidget(w)) + return NULL; + + screen = &((XtermWidget) w)->screen; + +#if OPT_WIDE_CHARS + if (screen->wide_chars) { + static Atom *utf8SelectionTargets = NULL; + + if (utf8SelectionTargets == NULL) { + utf8SelectionTargets = (Atom *) XtMalloc(5 * sizeof(Atom)); + if (utf8SelectionTargets == NULL) { + TRACE(("Couldn't allocate utf8SelectionTargets\n")); + return NULL; + } + n = 0; + utf8SelectionTargets[n++] = XA_UTF8_STRING(XtDisplay(w)); +#ifdef X_HAVE_UTF8_STRING + if (screen->i18nSelections) { + utf8SelectionTargets[n++] = XA_TEXT(XtDisplay(w)); + utf8SelectionTargets[n++] = XA_COMPOUND_TEXT(XtDisplay(w)); + } +#endif + utf8SelectionTargets[n++] = XA_STRING; + utf8SelectionTargets[n] = None; + } + return utf8SelectionTargets; + } +#endif + + /* not screen->wide_chars */ + if (eightBitSelectionTargets == NULL) { + eightBitSelectionTargets = (Atom *) XtMalloc(5 * sizeof(Atom)); + if (eightBitSelectionTargets == NULL) { + TRACE(("Couldn't allocate eightBitSelectionTargets\n")); + return NULL; + } + n = 0; +#ifdef X_HAVE_UTF8_STRING + eightBitSelectionTargets[n++] = XA_UTF8_STRING(XtDisplay(w)); +#endif + if (screen->i18nSelections) { + eightBitSelectionTargets[n++] = XA_TEXT(XtDisplay(w)); + eightBitSelectionTargets[n++] = XA_COMPOUND_TEXT(XtDisplay(w)); + } + eightBitSelectionTargets[n++] = XA_STRING; + eightBitSelectionTargets[n] = None; + } + return eightBitSelectionTargets; +} + +/* + * 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(unsigned code) +{ + int cutbuffer; + switch (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; +} + +#define ResetPaste64() term->screen.base64_paste = 0 + +#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; + + if (!IsXtermWidget(w)) + return; + +#if OPT_TRACE + TRACE(("xtermGetSelection\n")); + if (num_params > 0) { + Cardinal n; + for (n = 0; n < num_params; ++n) { + TRACE(("param[%d]:%s\n", n, params[n])); + } + } +#endif + + XmuInternStrings(XtDisplay(w), params, (Cardinal) 1, &selection); + cutbuffer = CutBuffer(selection); + TRACE(("Cutbuffer: %d, target: %lu\n", cutbuffer, + targets ? (unsigned long) targets[0] : 0)); + 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 + ResetPaste64(); +#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 = XtNew(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]", 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 = base64_code[screen->base64_accu << 4]; + tty_vwrite(screen->respond, &x, 1); + break; + case 4: + x = base64_code[screen->base64_accu << 2]; + tty_vwrite(screen->respond, &x, 1); + break; + } + if (screen->base64_pad & 3) + tty_vwrite(screen->respond, + (Char *) "===", + 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++] = base64_code[*p >> 2]; + screen->base64_accu = (*p & 0x3); + screen->base64_count = 2; + ++p; + break; + case 2: + buf[x++] = base64_code[(screen->base64_accu << 4) + (*p >> 4)]; + screen->base64_accu = (*p & 0xF); + screen->base64_count = 4; + ++p; + break; + case 4: + buf[x++] = base64_code[(screen->base64_accu << 2) + (*p >> 6)]; + buf[x++] = 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, (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, int 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, Char * in) +{ + Char line[16]; + unsigned count = 0; + unsigned length = strlen((char *) in); + + if (screen->control_eight_bits) { + line[count++] = CSI; + } else { + line[count++] = 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 GCC_UNUSED) +{ + 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 + + if (!IsXtermWidget(w)) + return; + screen = &((XtermWidget) w)->screen; + 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; + +#if OPT_WIDE_CHARS + if (screen->wide_chars) { + if (*type == XA_UTF8_STRING(XtDisplay(w)) || + *type == XA_STRING || + *type == XA_COMPOUND_TEXT(XtDisplay(w))) { + 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. */ + + /* There's no need to special-case UTF8_STRING. If Xlib + doesn't know about it, we didn't request it. If a broken + selection holder sends it anyhow, the conversion function + will fail. */ + + if (*type == XA_UTF8_STRING(XtDisplay(w)) || + *type == XA_STRING || + *type == XA_COMPOUND_TEXT(XtDisplay(w))) { + Status rc; + GettingSelection(dpy, *type, line, *length); + 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) { + ; + } else +#endif +#if OPT_READLINE + if (SCREEN_FLAG(screen, paste_brackets)) { + _WriteKey(screen, (Char *) "200"); + } +#endif + for (i = 0; i < text_list_count; i++) { + int len = strlen(text_list[i]); + _WriteSelectionData(screen, (Char *) text_list[i], len); + } +#if OPT_PASTE64 + if (screen->base64_paste) { + ResetPaste64(); + } else +#endif +#if OPT_READLINE + if (SCREEN_FLAG(screen, paste_brackets)) { + _WriteKey(screen, (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; + xtermGetSelection(w, list->time, + list->params, list->count, list->targets); + XtFree((char *) client_data); +#if OPT_PASTE64 + } else { + ResetPaste64(); +#endif + } + return; +} + +void +HandleInsertSelection(Widget w, + XEvent * event, /* assumed to be XButtonEvent* */ + String * params, /* selections in precedence order */ + Cardinal *num_params) +{ +#if OPT_READLINE + int ldelta; + TScreen *screen = &((XtermWidget) w)->screen; +#endif + + if (SendMousePosition(w, event)) + return; + +#if OPT_READLINE + if ((event->type == ButtonPress || event->type == ButtonRelease) + /* Disable on Shift-mouse, including the application-mouse modes */ + && !(KeyModifiers & ShiftMask) + && (screen->send_mouse_pos == MOUSE_OFF) + && SCREEN_FLAG(screen, paste_moves) + && rowOnCurrentLine(eventRow(event), &ldelta)) + ReadLineMovePoint(eventColBetween(event), ldelta); +#endif /* OPT_READLINE */ + + xtermGetSelection(w, event->xbutton.time, params, *num_params, NULL); +} + +static SelectUnit +EvalSelectUnit(Time buttonDownTime, SelectUnit defaultUnit) +{ + int delta; + + if (lastButtonUpTime == (Time) 0) /* first time and once in a blue moon */ + delta = term->screen.multiClickTime + 1; + else if (buttonDownTime > lastButtonUpTime) /* most of the time */ + delta = buttonDownTime - lastButtonUpTime; + else /* time has rolled over since lastButtonUpTime */ + delta = (((Time) ~ 0) - lastButtonUpTime) + buttonDownTime; + + if (delta > term->screen.multiClickTime) { + numberOfClicks = 1; + return defaultUnit; + } else { + ++numberOfClicks; + return ((selectUnit + 1) % NSELECTUNITS); + } +} + +static void +do_select_start(Widget w, + XEvent * event, /* must be XButtonEvent* */ + int startrow, + int startcol) +{ + if (SendMousePosition(w, event)) + return; + selectUnit = EvalSelectUnit(event->xbutton.time, SELECTCHAR); + replyToEmacs = False; + +#if OPT_READLINE + lastButtonDownTime = event->xbutton.time; +#endif + + StartSelect(startrow, startcol); +} + +/* ARGSUSED */ +void +HandleSelectStart(Widget w, + XEvent * event, /* must be XButtonEvent* */ + String * params GCC_UNUSED, + Cardinal *num_params GCC_UNUSED) +{ + TScreen *screen; + int startrow, startcol; + + if (!IsXtermWidget(w)) + return; + + screen = &((XtermWidget) w)->screen; + firstValidRow = 0; + lastValidRow = screen->max_row; + PointToRowCol(event->xbutton.y, event->xbutton.x, &startrow, &startcol); + +#if OPT_READLINE + ExtendingSelection = 0; +#endif + + do_select_start(w, event, startrow, startcol); +} + +/* ARGSUSED */ +void +HandleKeyboardSelectStart(Widget w, + XEvent * event, /* must be XButtonEvent* */ + String * params GCC_UNUSED, + Cardinal *num_params GCC_UNUSED) +{ + TScreen *screen; + + if (!IsXtermWidget(w)) + return; + + screen = &((XtermWidget) w)->screen; + do_select_start(w, event, screen->cursor_row, screen->cursor_col); +} + +static void +TrackDown(XButtonEvent * event) +{ + int startrow, startcol; + + selectUnit = EvalSelectUnit(event->time, SELECTCHAR); + if (numberOfClicks > 1) { + PointToRowCol(event->y, event->x, &startrow, &startcol); + replyToEmacs = True; + StartSelect(startrow, startcol); + } else { + waitingForTrackInfo = True; + EditorButton((XButtonEvent *) event); + } +} + +#define boundsCheck(x) if (x < 0) \ + x = 0; \ + else if (x >= screen->max_row) \ + x = screen->max_row + +void +TrackMouse(int func, int startrow, int startcol, int firstrow, int lastrow) +{ + TScreen *screen = &term->screen; + + if (!waitingForTrackInfo) { /* Timed out, so ignore */ + return; + } + waitingForTrackInfo = False; + if (func == 0) + return; + boundsCheck(startrow); + boundsCheck(firstrow); + boundsCheck(lastrow); + firstValidRow = firstrow; + lastValidRow = lastrow; + replyToEmacs = True; + StartSelect(startrow, startcol); +} + +static void +StartSelect(int startrow, int startcol) +{ + TScreen *screen = &term->screen; + + TRACE(("StartSelect row=%d, col=%d\n", startrow, startcol)); + if (screen->cursor_state) + HideCursor(); + if (numberOfClicks == 1) { + /* set start of selection */ + rawRow = startrow; + rawCol = startcol; + + } + /* else use old values in rawRow, Col */ + saveStartRRow = startERow = rawRow; + saveStartRCol = startECol = rawCol; + saveEndRRow = endERow = rawRow; + saveEndRCol = endECol = rawCol; + if (Coordinate(startrow, startcol) < Coordinate(rawRow, rawCol)) { + eventMode = LEFTEXTENSION; + startERow = startrow; + startECol = startcol; + } else { + eventMode = RIGHTEXTENSION; + endERow = startrow; + endECol = startcol; + } + ComputeSelect(startERow, startECol, endERow, endECol, False); +} + +static void +EndExtend(Widget w, + XEvent * event, /* must be XButtonEvent */ + String * params, /* selections */ + Cardinal num_params, + Bool use_cursor_loc) +{ + int row, col; + unsigned count; + TScreen *screen = &term->screen; + Char line[9]; + + if (use_cursor_loc) { + row = screen->cursor_row; + col = screen->cursor_col; + } else { + PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); + } + ExtendExtend(row, col); + lastButtonUpTime = event->xbutton.time; + if (startSRow != endSRow || startSCol != endSCol) { + if (replyToEmacs) { + count = 0; + if (screen->control_eight_bits) { + line[count++] = CSI; + } else { + line[count++] = ESC; + line[count++] = '['; + } + if (rawRow == startSRow && rawCol == startSCol + && row == endSRow && col == endSCol) { + /* Use short-form emacs select */ + line[count++] = 't'; + line[count++] = ' ' + endSCol + 1; + line[count++] = ' ' + endSRow + 1; + } else { + /* long-form, specify everything */ + line[count++] = 'T'; + line[count++] = ' ' + startSCol + 1; + line[count++] = ' ' + startSRow + 1; + line[count++] = ' ' + endSCol + 1; + line[count++] = ' ' + endSRow + 1; + line[count++] = ' ' + col + 1; + line[count++] = ' ' + row + 1; + } + v_write(screen->respond, line, count); + TrackText(0, 0, 0, 0); + } + } + SelectSet(w, event, params, num_params); + eventMode = NORMAL; +} + +void +HandleSelectSet(Widget w, + XEvent * event, + String * params, + Cardinal *num_params) +{ + SelectSet(w, event, params, *num_params); +} + +/* ARGSUSED */ +static void +SelectSet(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + String * params, + Cardinal num_params) +{ + TRACE(("SelectSet\n")); + /* Only do select stuff if non-null select */ + if (startSRow != endSRow || startSCol != endSCol) { + SaltTextAway(startSRow, startSCol, endSRow, endSCol, + params, num_params); + } else { + DisownSelection(term); + } +} + +#define Abs(x) ((x) < 0 ? -(x) : (x)) + +/* ARGSUSED */ +static void +do_start_extend(Widget w, + XEvent * event, /* must be XButtonEvent* */ + String * params GCC_UNUSED, + Cardinal *num_params GCC_UNUSED, + Bool use_cursor_loc) +{ + TScreen *screen; + int row, col, coord; + + if (!IsXtermWidget(w)) + return; + + screen = &((XtermWidget) w)->screen; + if (SendMousePosition(w, event)) + return; + firstValidRow = 0; + lastValidRow = screen->max_row; +#if OPT_READLINE + if ((KeyModifiers & ShiftMask) + || event->xbutton.button != Button3 + || !(SCREEN_FLAG(screen, dclick3_deletes))) +#endif + selectUnit = EvalSelectUnit(event->xbutton.time, selectUnit); + replyToEmacs = False; + +#if OPT_READLINE + CheckSecondPress3(event); +#endif + + if (numberOfClicks == 1 + || (SCREEN_FLAG(screen, dclick3_deletes) /* Dclick special */ + &&!(KeyModifiers & ShiftMask))) { + /* Save existing selection so we can reestablish it if the guy + extends past the other end of the selection */ + saveStartRRow = startERow = startRRow; + saveStartRCol = startECol = startRCol; + saveEndRRow = endERow = endRRow; + saveEndRCol = endECol = endRCol; + } else { + /* He just needed the selection mode changed, use old values. */ + startERow = startRRow = saveStartRRow; + startECol = startRCol = saveStartRCol; + endERow = endRRow = saveEndRRow; + endECol = endRCol = saveEndRCol; + + } + if (use_cursor_loc) { + row = screen->cursor_row; + col = screen->cursor_col; + } else { + PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); + } + coord = Coordinate(row, col); + + if (Abs(coord - Coordinate(startSRow, startSCol)) + < Abs(coord - Coordinate(endSRow, endSCol)) + || coord < Coordinate(startSRow, startSCol)) { + /* point is close to left side of selection */ + eventMode = LEFTEXTENSION; + startERow = row; + startECol = col; + } else { + /* point is close to left side of selection */ + eventMode = RIGHTEXTENSION; + endERow = row; + endECol = col; + } + ComputeSelect(startERow, startECol, endERow, endECol, True); + +#if OPT_READLINE + if (startSRow != endSRow || startSCol != endSCol) + ExtendingSelection = 1; +#endif +} + +static void +ExtendExtend(int row, int col) +{ + int coord = Coordinate(row, col); + + TRACE(("ExtendExtend row=%d, col=%d\n", row, col)); + if (eventMode == LEFTEXTENSION + && (coord + (selectUnit != SELECTCHAR)) > Coordinate(endSRow, endSCol)) { + /* Whoops, he's changed his mind. Do RIGHTEXTENSION */ + eventMode = RIGHTEXTENSION; + startERow = saveStartRRow; + startECol = saveStartRCol; + } else if (eventMode == RIGHTEXTENSION + && coord < Coordinate(startSRow, startSCol)) { + /* Whoops, he's changed his mind. Do LEFTEXTENSION */ + eventMode = LEFTEXTENSION; + endERow = saveEndRRow; + endECol = saveEndRCol; + } + if (eventMode == LEFTEXTENSION) { + startERow = row; + startECol = col; + } else { + endERow = row; + endECol = col; + } + ComputeSelect(startERow, startECol, endERow, endECol, False); + +#if OPT_READLINE + if (startSRow != endSRow || startSCol != endSCol) + ExtendingSelection = 1; +#endif +} + +void +HandleStartExtend(Widget w, + XEvent * event, /* must be XButtonEvent* */ + String * params, /* unused */ + Cardinal *num_params) /* unused */ +{ + do_start_extend(w, event, params, num_params, False); +} + +void +HandleKeyboardStartExtend(Widget w, + XEvent * event, /* must be XButtonEvent* */ + String * params, /* unused */ + Cardinal *num_params) /* unused */ +{ + do_start_extend(w, event, params, num_params, True); +} + +void +ScrollSelection(TScreen * screen, int amount, Bool always) +{ + int minrow = -screen->savedlines - screen->topline; + int maxrow = screen->max_row - screen->topline; + int maxcol = screen->max_col; + +#define scroll_update_one(row, col) \ + row += amount; \ + if (row < minrow) { \ + row = minrow; \ + col = 0; \ + } \ + if (row > maxrow) { \ + row = maxrow; \ + col = maxcol; \ + } + + scroll_update_one(startRRow, startRCol); + scroll_update_one(endRRow, endRCol); + scroll_update_one(startSRow, startSCol); + scroll_update_one(endSRow, endSCol); + + scroll_update_one(rawRow, rawCol); + + /* + * 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 = screen->startHRow + screen->topline; + if (always + || !ScrnHaveLineMargins(screen) + || ScrnIsLineInMargins(screen, adjust)) { + scroll_update_one(screen->startHRow, screen->startHCol); + } + adjust = screen->endHRow + screen->topline; + if (always + || !ScrnHaveLineMargins(screen) + || ScrnIsLineInMargins(screen, adjust)) { + scroll_update_one(screen->endHRow, screen->endHCol); + } + } + + screen->startHCoord = Coordinate(screen->startHRow, screen->startHCol); + screen->endHCoord = Coordinate(screen->endHRow, screen->endHCol); +} + +/*ARGSUSED*/ +void +ResizeSelection(TScreen * screen GCC_UNUSED, int rows, int cols) +{ + rows--; /* decr to get 0-max */ + cols--; + + if (startRRow > rows) + startRRow = rows; + if (startSRow > rows) + startSRow = rows; + if (endRRow > rows) + endRRow = rows; + if (endSRow > rows) + endSRow = rows; + if (rawRow > rows) + rawRow = rows; + + if (startRCol > cols) + startRCol = cols; + if (startSCol > cols) + startSCol = cols; + if (endRCol > cols) + endRCol = cols; + if (endSCol > cols) + endSCol = cols; + if (rawCol > cols) + rawCol = cols; +} + +#if OPT_WIDE_CHARS +Bool +iswide(int i) +{ + return (i == HIDDEN_CHAR) || (my_wcwidth(i) == 2); +} + +#define isWideCell(row, col) iswide((int)XTERM_CELL(row, col)) +#endif + +static void +PointToRowCol(int y, + int x, + int *r, + int *c) +/* 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. */ +{ + TScreen *screen = &term->screen; + int row, col; + + row = (y - screen->border) / FontHeight(screen); + if (row < firstValidRow) + row = firstValidRow; + else if (row > lastValidRow) + row = lastValidRow; + col = (x - OriginX(screen)) / FontWidth(screen); + if (col < 0) + col = 0; + else if (col > MaxCols(screen)) { + 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 (col > 0 + && isWideCell(row, col - 1) + && (XTERM_CELL(row, col) == HIDDEN_CHAR)) { + col -= 1; + } +#endif + *r = row; + *c = col; +} + +static int +LastTextCol(int row) +{ + TScreen *screen = &term->screen; + int i; + Char *ch; + + if ((row += screen->topline) + screen->savedlines >= 0) { + for (i = screen->max_col, + ch = SCRN_BUF_ATTRS(screen, row) + i; + i >= 0 && !(*ch & CHARDRAWN); + ch--, i--) ; +#if OPT_DEC_CHRSET + if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, row)[0])) { + i *= 2; + } +#endif + } else { + i = -1; + } + 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 + +#if OPT_WIDE_CHARS +static int +class_of(TScreen * screen, int row, int col) +{ + int value; +#if OPT_DEC_CHRSET + if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, row + screen->topline)[0])) { + col /= 2; + } +#endif + value = XTERM_CELL(row, col); + if_OPT_WIDE_CHARS(screen, { + return CharacterClass(value); + }); + return CharacterClass(value); +} +#define ClassSelects(screen, row, col, cclass) \ + (class_of(screen, row, col) == cclass \ + || XTERM_CELL(row, col) == HIDDEN_CHAR) +#else +#define class_of(screen,row,col) charClass[XTERM_CELL(row, col)] +#define ClassSelects(screen, row, col, cclass) \ + (class_of(screen,row, col) == cclass) +#endif + +/* + * sets startSRow startSCol endSRow endSCol + * ensuring that they have legal values + */ +static void +ComputeSelect(int startRow, + int startCol, + int endRow, + int endCol, + Bool extend) +{ + TScreen *screen = &term->screen; + int length; + int cclass; + + TRACE(("ComputeSelect(startRow=%d, startCol=%d, endRow=%d, endCol=%d, %sextend)\n", + startRow, startCol, endRow, endCol, extend ? "" : "no")); + +#if OPT_WIDE_CHARS + if (startCol > 1 + && isWideCell(startRow, startCol - 1) + && XTERM_CELL(startRow, startCol - 0) == HIDDEN_CHAR) { + fprintf(stderr, "Adjusting start. Changing downwards from %i.\n", startCol); + startCol -= 1; + if (endCol == (startCol + 1)) + endCol--; + } + + if (endCol > 1 + && isWideCell(endRow, endCol - 1) + && XTERM_CELL(endRow, endCol) == HIDDEN_CHAR) { + endCol += 1; + } +#endif + + if (Coordinate(startRow, startCol) <= Coordinate(endRow, endCol)) { + startSRow = startRRow = startRow; + startSCol = startRCol = startCol; + endSRow = endRRow = endRow; + endSCol = endRCol = endCol; + } else { /* Swap them */ + startSRow = startRRow = endRow; + startSCol = startRCol = endCol; + endSRow = endRRow = startRow; + endSCol = endRCol = startCol; + } + + switch (selectUnit) { + case SELECTCHAR: + if (startSCol > (LastTextCol(startSRow) + 1)) { + startSCol = 0; + startSRow++; + } + if (endSCol > (LastTextCol(endSRow) + 1)) { + endSCol = 0; + endSRow++; + } + break; + case SELECTWORD: + if (startSCol > (LastTextCol(startSRow) + 1)) { + startSCol = 0; + startSRow++; + } else { + cclass = class_of(screen, startSRow, startSCol); + do { + --startSCol; + if (startSCol < 0 + && ScrnTstWrapped(screen, startSRow - 1)) { + --startSRow; + startSCol = LastTextCol(startSRow); + } + } while (startSCol >= 0 + && ClassSelects(screen, startSRow, startSCol, cclass)); + ++startSCol; + } + +#if OPT_WIDE_CHARS + if (startSCol && XTERM_CELL(startSRow, startSCol) == HIDDEN_CHAR) + startSCol++; +#endif + + if (endSCol > (LastTextCol(endSRow) + 1)) { + endSCol = 0; + endSRow++; + } else { + length = LastTextCol(endSRow); + cclass = class_of(screen, endSRow, endSCol); + do { + ++endSCol; + if (endSCol > length + && ScrnTstWrapped(screen, endSRow)) { + endSCol = 0; + ++endSRow; + length = LastTextCol(endSRow); + } + } while (endSCol <= length + && ClassSelects(screen, endSRow, endSCol, cclass)); + /* Word select selects if pointing to any char + in "word", especially in that it includes + the last character in a word. So no --endSCol + and do special eol handling */ + if (endSCol > length + 1) { + endSCol = 0; + ++endSRow; + } + } + +#if OPT_WIDE_CHARS + if (endSCol && XTERM_CELL(endSRow, endSCol) == HIDDEN_CHAR) + endSCol++; +#endif + + saveStartWRow = startSRow; + saveStartWCol = startSCol; + break; + case SELECTLINE: + while (ScrnTstWrapped(screen, endSRow)) { + ++endSRow; + } + if (term->screen.cutToBeginningOfLine + || startSRow < saveStartWRow) { + startSCol = 0; + while (ScrnTstWrapped(screen, startSRow - 1)) { + --startSRow; + } + } else if (!extend) { + if ((startRow < saveStartWRow) + || (startRow == saveStartWRow + && startCol < saveStartWCol)) { + startSCol = 0; + while (ScrnTstWrapped(screen, startSRow - 1)) { + --startSRow; + } + } else { + startSRow = saveStartWRow; + startSCol = saveStartWCol; + } + } + if (term->screen.cutNewline) { + endSCol = 0; + ++endSRow; + } else { + endSCol = LastTextCol(endSRow) + 1; + } + break; + } + + /* check boundaries */ + ScrollSelection(screen, 0, False); + + TrackText(startSRow, startSCol, endSRow, endSCol); + return; +} + +void +TrackText(int frow, + int fcol, + int trow, + int tcol) + /* Guaranteed (frow, fcol) <= (trow, tcol) */ +{ + int from, to; + TScreen *screen = &term->screen; + int old_startrow, old_startcol, old_endrow, old_endcol; + + TRACE(("TrackText(frow=%d, fcol=%d, trow=%d, tcol=%d)\n", + frow, fcol, trow, tcol)); + + old_startrow = screen->startHRow; + old_startcol = screen->startHCol; + old_endrow = screen->endHRow; + old_endcol = screen->endHCol; + if (frow == old_startrow && fcol == old_startcol && + trow == old_endrow && tcol == old_endcol) + return; + screen->startHRow = frow; + screen->startHCol = fcol; + screen->endHRow = trow; + screen->endHCol = tcol; + from = Coordinate(frow, fcol); + to = Coordinate(trow, tcol); + if (to <= screen->startHCoord || from > screen->endHCoord) { + /* No overlap whatsoever between old and new hilite */ + ReHiliteText(old_startrow, old_startcol, old_endrow, old_endcol); + ReHiliteText(frow, fcol, trow, tcol); + } else { + if (from < screen->startHCoord) { + /* Extend left end */ + ReHiliteText(frow, fcol, old_startrow, old_startcol); + } else if (from > screen->startHCoord) { + /* Shorten left end */ + ReHiliteText(old_startrow, old_startcol, frow, fcol); + } + if (to > screen->endHCoord) { + /* Extend right end */ + ReHiliteText(old_endrow, old_endcol, trow, tcol); + } else if (to < screen->endHCoord) { + /* Shorten right end */ + ReHiliteText(trow, tcol, old_endrow, old_endcol); + } + } + screen->startHCoord = from; + screen->endHCoord = to; +} + +static void +ReHiliteText(int frow, + int fcol, + int trow, + int tcol) + /* Guaranteed that (frow, fcol) <= (trow, tcol) */ +{ + TScreen *screen = &term->screen; + int i; + + TRACE(("ReHiliteText from %d.%d to %d.%d\n", frow, fcol, trow, tcol)); + + if (frow < 0) + frow = fcol = 0; + else if (frow > screen->max_row) + return; /* nothing to do, since trow >= frow */ + + if (trow < 0) + return; /* nothing to do, since frow <= trow */ + else if (trow > screen->max_row) { + trow = screen->max_row; + tcol = MaxCols(screen); + } + if (frow == trow && fcol == tcol) + return; + + if (frow != trow) { /* do multiple rows */ + if ((i = screen->max_col - fcol + 1) > 0) { /* first row */ + ScrnRefresh(screen, frow, fcol, 1, i, True); + } + if ((i = trow - frow - 1) > 0) { /* middle rows */ + ScrnRefresh(screen, frow + 1, 0, i, MaxCols(screen), True); + } + if (tcol > 0 && trow <= screen->max_row) { /* last row */ + ScrnRefresh(screen, trow, 0, 1, tcol, True); + } + } else { /* do single row */ + ScrnRefresh(screen, frow, fcol, 1, tcol - fcol, True); + } +} + +static void +SaltTextAway(int crow, int ccol, int row, int col, + String * params, /* selections */ + Cardinal num_params) + /* Guaranteed that (crow, ccol) <= (row, col), and that both points are valid + (may have row = screen->max_row+1, col = 0) */ +{ + TScreen *screen = &term->screen; + int i, j = 0; + int eol; + Char *line; + Char *lp; + + if (crow == row && ccol > col) { + int tmp = ccol; + ccol = col; + col = tmp; + } + + --col; + /* first we need to know how long the string is before we can save it */ + + if (row == crow) { + j = Length(screen, crow, ccol, col); + } else { /* two cases, cut is on same line, cut spans multiple lines */ + j += Length(screen, crow, ccol, screen->max_col) + 1; + for (i = crow + 1; i < row; i++) + j += Length(screen, i, 0, screen->max_col) + 1; + if (col >= 0) + j += Length(screen, row, 0, 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((unsigned) 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 (row == crow) { + lp = SaveText(screen, row, ccol, col, lp, &eol); + } else { + lp = SaveText(screen, crow, ccol, screen->max_col, lp, &eol); + if (eol) + *lp++ = '\n'; /* put in newline at end of line */ + for (i = crow + 1; i < row; i++) { + lp = SaveText(screen, i, 0, screen->max_col, lp, &eol); + if (eol) + *lp++ = '\n'; + } + if (col >= 0) + lp = SaveText(screen, row, 0, col, lp, &eol); + } + *lp = '\0'; /* make sure we have end marked */ + + TRACE(("Salted TEXT:%d:%.*s\n", lp - line, lp - line, line)); + screen->selection_length = (lp - line); + _OwnSelection(term, params, num_params); +} + +#if OPT_PASTE64 +void +ClearSelectionBuffer() +{ + TScreen *screen = &term->screen; + screen->selection_length = 0; + screen->base64_count = 0; +} + +static void +AppendStrToSelectionBuffer(Char * text, int len) +{ + TScreen *screen = &term->screen; + if (len != 0) { + int j = 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((unsigned) 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, + (unsigned) k); + if (screen->selection_data == 0) + SysError(ERROR_BMALLOC2); + } + screen->selection_size = k; + } + 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) +{ + int 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 = (screen->base64_accu << 6) + six; + screen->base64_count = 0; + AppendStrToSelectionBuffer(&ch, 1); + break; + + case 4: + ch = (screen->base64_accu << 4) + (six >> 2); + screen->base64_accu = (six & 0x3); + screen->base64_count = 2; + AppendStrToSelectionBuffer(&ch, 1); + break; + + case 6: + ch = (screen->base64_accu << 2) + (six >> 4); + screen->base64_accu = (six & 0xF); + screen->base64_count = 4; + AppendStrToSelectionBuffer(&ch, 1); + break; + } +} + +void +CompleteSelection(char **args, Cardinal len) +{ + term->screen.base64_count = 0; + term->screen.base64_accu = 0; + _OwnSelection(term, 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) +{ + Display *d = XtDisplay(w); + TScreen *screen; + XTextProperty textprop; + + if (!IsXtermWidget(w)) + return False; + + screen = &((XtermWidget) w)->screen; + + if (conversion_function(d, (char **) &screen->selection_data, 1, + conversion_style, + &textprop) < Success) + return False; + *value = (XtPointer) textprop.value; + *length = textprop.nitems; + *type = textprop.encoding; + *format = textprop.format; + return True; +} + +static Boolean +ConvertSelection(Widget w, + Atom * selection, + Atom * target, + Atom * type, + XtPointer *value, + unsigned long *length, + int *format) +{ + Display *d = XtDisplay(w); + TScreen *screen; + Bool result = False; + + if (!IsXtermWidget(w)) + return False; + + screen = &((XtermWidget) w)->screen; + + if (screen->selection_data == NULL) + return False; /* can this happen? */ + + if (*target == XA_TARGETS(d)) { + 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)) { + std_targets = (Atom *) (std_return); + *length = std_length + 6; + targetP = (Atom *) XtMalloc(sizeof(Atom) * (*length)); + *value = (XtPointer) targetP; + *targetP++ = XA_STRING; + *targetP++ = XA_TEXT(d); +#ifdef X_HAVE_UTF8_STRING + *targetP++ = XA_COMPOUND_TEXT(d); + *targetP++ = XA_UTF8_STRING(d); +#else + *targetP = XA_COMPOUND_TEXT(d); + if_OPT_WIDE_CHARS(screen, { + *targetP = XA_UTF8_STRING(d); + }); + targetP++; +#endif + *targetP++ = XA_LENGTH(d); + *targetP++ = XA_LIST_LENGTH(d); + memcpy(targetP, std_targets, sizeof(Atom) * std_length); + XtFree((char *) std_targets); + *type = XA_ATOM; + *format = 32; + result = True; + } + } +#if OPT_WIDE_CHARS + else if (screen->wide_chars && *target == XA_STRING) { + result = + _ConvertSelectionHelper(w, + type, value, length, format, + Xutf8TextListToTextProperty, + XStringStyle); + } else if (screen->wide_chars && *target == XA_UTF8_STRING(d)) { + result = + _ConvertSelectionHelper(w, + type, value, length, format, + Xutf8TextListToTextProperty, + XUTF8StringStyle); + } else if (screen->wide_chars && *target == XA_TEXT(d)) { + result = + _ConvertSelectionHelper(w, + type, value, length, format, + Xutf8TextListToTextProperty, + XStdICCTextStyle); + } else if (screen->wide_chars && *target == XA_COMPOUND_TEXT(d)) { + result = + _ConvertSelectionHelper(w, + type, value, length, format, + Xutf8TextListToTextProperty, + XCompoundTextStyle); + } +#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; + } else if (*target == XA_TEXT(d)) { /* not wide_chars */ + result = + _ConvertSelectionHelper(w, + type, value, length, format, + XmbTextListToTextProperty, + XStdICCTextStyle); + } else if (*target == XA_COMPOUND_TEXT(d)) { /* not wide_chars */ + result = + _ConvertSelectionHelper(w, + type, value, length, format, + XmbTextListToTextProperty, + XCompoundTextStyle); + } +#ifdef X_HAVE_UTF8_STRING + else if (*target == XA_UTF8_STRING(d)) { /* not wide_chars */ + result = + _ConvertSelectionHelper(w, + type, value, length, format, + XmbTextListToTextProperty, + XUTF8StringStyle); + } +#endif + else if (*target == XA_LIST_LENGTH(d)) { + *value = XtMalloc(4); + if (sizeof(long) == 4) + *(long *) *value = 1; + else { + long temp = 1; + memcpy((char *) *value, ((char *) &temp) + sizeof(long) - 4, 4); + } + *type = XA_INTEGER; + *length = 1; + *format = 32; + result = True; + } else if (*target == XA_LENGTH(d)) { + /* This value is wrong if we have UTF-8 text */ + *value = XtMalloc(4); + if (sizeof(long) == 4) { + *(long *) *value = screen->selection_length; + } else { + long temp = screen->selection_length; + memcpy((char *) *value, ((char *) &temp) + sizeof(long) - 4, 4); + } + *type = XA_INTEGER; + *length = 1; + *format = 32; + result = True; + } else if (XmuConvertStandardSelection(w, + screen->selection_time, selection, + target, type, (XPointer *) value, + length, format)) { + result = True; + } + + /* else */ + return result; +} + +static void +LoseSelection(Widget w, Atom * selection) +{ + TScreen *screen; + Atom *atomP; + Cardinal i; + + if (!IsXtermWidget(w)) + return; + + screen = &((XtermWidget) w)->screen; + 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(0, 0, 0, 0); +} + +/* 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 termw, + String * selections, + Cardinal count) +{ + Atom *atoms = termw->screen.selection_atoms; + Cardinal i; + Bool have_selection = False; + + if (termw->screen.selection_length < 0) + return; + + if (count > termw->screen.sel_atoms_size) { + XtFree((char *) atoms); + atoms = (Atom *) XtMalloc(count * sizeof(Atom)); + termw->screen.selection_atoms = atoms; + termw->screen.sel_atoms_size = count; + } + XmuInternStrings(XtDisplay((Widget) termw), selections, count, atoms); + for (i = 0; i < count; i++) { + int cutbuffer = CutBuffer(atoms[i]); + if (cutbuffer >= 0) { + if (termw->screen.selection_length > + 4 * XMaxRequestSize(XtDisplay((Widget) termw)) - 32) { + fprintf(stderr, + "%s: selection too big (%d bytes), not storing in CUT_BUFFER%d\n", + xterm_name, termw->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 = termw->screen.selection_length; + Char *data = termw->screen.selection_data; + if_OPT_WIDE_CHARS((&(termw->screen)), { + data = UTF8toLatin1(data, length, &length); + }); + TRACE(("XStoreBuffer(%d)\n", cutbuffer)); + XStoreBuffer(XtDisplay((Widget) termw), + (char *) data, + (int) length, + cutbuffer); + } + } else if (!replyToEmacs) { + have_selection |= + XtOwnSelection((Widget) termw, atoms[i], + termw->screen.selection_time, + ConvertSelection, LoseSelection, SelectionDone); + } + } + if (!replyToEmacs) + termw->screen.selection_count = count; + if (!have_selection) + TrackText(0, 0, 0, 0); +} + +static void +ResetSelectionState(TScreen * screen) +{ + screen->selection_count = 0; + screen->startHRow = screen->startHCol = 0; + screen->endHRow = screen->endHCol = 0; +} + +void +DisownSelection(XtermWidget termw) +{ + TScreen *screen = &(termw->screen); + 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->startHRow, + screen->startHCol, + screen->endHRow, + screen->endHCol)); + + for (i = 0; i < count; i++) { + int cutbuffer = CutBuffer(atoms[i]); + if (cutbuffer < 0) { + XtDisownSelection((Widget) termw, 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 */ + int start_row = screen->startHRow; + int start_col = screen->startHCol; + int end_row = screen->endHRow; + int end_col = screen->endHCol; + + ResetSelectionState(screen); + ReHiliteText(start_row, start_col, end_row, end_col); + } else { + ResetSelectionState(screen); + } +} + +/* returns number of chars in line from scol to ecol out */ +/* ARGSUSED */ +static int +Length(TScreen * screen GCC_UNUSED, + int row, + int scol, + int ecol) +{ + int lastcol = LastTextCol(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) +{ + int i = 0; + unsigned c; + Char *result = lp; +#if OPT_WIDE_CHARS + int previous = 0; + unsigned c_1 = 0, c_2 = 0; +#endif + + i = Length(screen, row, scol, ecol); + ecol = scol + i; +#if OPT_DEC_CHRSET + if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, row + screen->topline)[0])) { + scol = (scol + 0) / 2; + ecol = (ecol + 1) / 2; + } +#endif + *eol = !ScrnTstWrapped(screen, row); + for (i = scol; i < ecol; i++) { + c = E2A(XTERM_CELL(row, i)); +#if OPT_WIDE_CHARS + if (screen->utf8_mode != uFalse) { + c_1 = E2A(XTERM_CELL_C1(row, i)); + c_2 = E2A(XTERM_CELL_C2(row, i)); + } + + /* We want to strip out every occurrence of HIDDEN_CHAR AFTER a + * wide character. + */ + if (c == HIDDEN_CHAR && iswide(previous)) { + previous = c; + /* Combining characters attached to double-width characters + are in memory attached to the HIDDEN_CHAR */ + if (c_1) { + lp = convertToUTF8(lp, c_1); + if (c_2) + lp = convertToUTF8(lp, c_2); + } + continue; + } + previous = c; + if (screen->utf8_mode != uFalse) { + lp = convertToUTF8(lp, (c != 0) ? c : ' '); + if (c_1) { + lp = convertToUTF8(lp, c_1); + if (c_2) + lp = convertToUTF8(lp, c_2); + } + } else +#endif + { + if (c == 0) { + c = E2A(' '); + } else if (c < E2A(' ')) { + if (c == XPOUND) + c = 0x23; /* char on screen is pound sterling */ + else + c += 0x5f; /* char is from DEC drawing set */ + } else if (c == 0x7f) { + c = 0x5f; + } + *lp++ = 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 = 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; +} + +#define MOUSE_LIMIT (255 - 32) + +static void +EditorButton(XButtonEvent * event) +{ + TScreen *screen = &term->screen; + int pty = screen->respond; + Char line[6]; + int row, col; + int button; + unsigned count = 0; + + /* If button event, get button # adjusted for DEC compatibility */ + button = 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; + else if (row > MOUSE_LIMIT) + row = MOUSE_LIMIT; + + if (col < 0) + col = 0; + else if (col > screen->max_col) + col = screen->max_col; + else if (col > MOUSE_LIMIT) + col = MOUSE_LIMIT; + + /* Build key sequence starting with \E[M */ + if (screen->control_eight_bits) { + line[count++] = CSI; + } else { + line[count++] = ESC; + line[count++] = '['; + } + line[count++] = 'M'; + + /* Add event code to key sequence */ + if (screen->send_mouse_pos == X10_MOUSE) { + line[count++] = ' ' + button; + } else { + /* Button-Motion events */ + switch (event->type) { + case ButtonPress: + line[count++] = BtnCode(event, screen->mouse_button = button); + 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; + line[count++] = BtnCode(event, screen->mouse_button = button); + 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)) + return; + line[count++] = BtnCode(event, screen->mouse_button); + break; + default: + return; + } + } + + screen->mouse_row = row; + screen->mouse_col = col; + + /* Add pointer position to key sequence */ + line[count++] = ' ' + col + 1; + line[count++] = ' ' + row + 1; + + TRACE(("mouse at %d,%d button+mask = %#x\n", row, col, + (screen->control_eight_bits) ? line[2] : line[3])); + + /* Transmit key sequence to process running under xterm */ + v_write(pty, line, count); +} + +/*ARGSUSED*/ +#if OPT_TEK4014 +void +HandleGINInput(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + String * param_list, + Cardinal *nparamsp) +{ + if (term->screen.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(XkbBI_MinorError, 0); /* let them know they goofed */ + c = 'l'; /* provide a default */ + } + TekEnqMouse(c | 0x80); + TekGINoff(); + } else { + Bell(XkbBI_MinorError, 0); + } +} +#endif /* OPT_TEK4014 */ + +/* ARGSUSED */ +void +HandleSecure(Widget w GCC_UNUSED, + XEvent * event, /* unused */ + String * params GCC_UNUSED, /* [0] = volume */ + Cardinal *param_count GCC_UNUSED) /* 0 or 1 */ +{ + 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; + DoSecureKeyboard(ev_time); +} diff --git a/nx-X11/programs/xterm/charclass.c b/nx-X11/programs/xterm/charclass.c new file mode 100644 index 000000000..96220607c --- /dev/null +++ b/nx-X11/programs/xterm/charclass.c @@ -0,0 +1,142 @@ +/* $XTermId: charclass.c,v 1.10 2005/01/14 01:50:02 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 -1 (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. + */ +/* $XFree86: xc/programs/xterm/charclass.c,v 1.5 2005/01/14 01:50:02 dickey Exp $ */ + +#include +#include + +#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, 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; +} + +void +init_classtab(void) +{ + const int size = 50; + + classtab = TypeMallocN(struct classentry, size); + if (!classtab) + abort(); + classtab[0].cclass = size; + classtab[0].first = 1; + classtab[0].last = 0; + + /* old xterm default classes */ + SetCharacterClassRange(0, 0, 32); + SetCharacterClassRange(1, 31, 1); + SetCharacterClassRange('\t', '\t', 32); + SetCharacterClassRange('0', '9', 48); + SetCharacterClassRange('A', 'Z', 48); + SetCharacterClassRange('_', '_', 48); + SetCharacterClassRange('a', 'z', 48); + SetCharacterClassRange(127, 159, 1); + SetCharacterClassRange(160, 191, -1); + SetCharacterClassRange(192, 255, 48); + SetCharacterClassRange(215, 215, 216); + SetCharacterClassRange(247, 247, 248); + + /* added Unicode classes */ + SetCharacterClassRange(0x0100, 0xffdf, 48); /* mostly characters */ + SetCharacterClassRange(0x037e, 0x037e, -1); /* Greek question mark */ + SetCharacterClassRange(0x0387, 0x0387, -1); /* Greek ano teleia */ + SetCharacterClassRange(0x055a, 0x055f, -1); /* Armenian punctuation */ + SetCharacterClassRange(0x0589, 0x0589, -1); /* Armenian full stop */ + SetCharacterClassRange(0x0700, 0x070d, -1); /* Syriac punctuation */ + SetCharacterClassRange(0x104a, 0x104f, -1); /* Myanmar punctuation */ + SetCharacterClassRange(0x10fb, 0x10fb, -1); /* Georgian punctuation */ + SetCharacterClassRange(0x1361, 0x1368, -1); /* Ethiopic punctuation */ + SetCharacterClassRange(0x166d, 0x166e, -1); /* Canadian Syl. punctuation */ + SetCharacterClassRange(0x17d4, 0x17dc, -1); /* Khmer punctuation */ + SetCharacterClassRange(0x1800, 0x180a, -1); /* Mongolian punctuation */ + SetCharacterClassRange(0x2000, 0x200a, 32); /* spaces */ + SetCharacterClassRange(0x200b, 0x27ff, -1); /* punctuation and symbols */ + SetCharacterClassRange(0x2070, 0x207f, 0x2070); /* superscript */ + SetCharacterClassRange(0x2080, 0x208f, 0x2080); /* subscript */ + SetCharacterClassRange(0x3000, 0x3000, 32); /* ideographic space */ + SetCharacterClassRange(0x3001, 0x3020, -1); /* 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, -1); /* punctuation forms */ + SetCharacterClassRange(0xff00, 0xff0f, -1); /* half/fullwidth ASCII */ + SetCharacterClassRange(0xff1a, 0xff20, -1); /* half/fullwidth ASCII */ + SetCharacterClassRange(0xff3b, 0xff40, -1); /* half/fullwidth ASCII */ + SetCharacterClassRange(0xff5b, 0xff64, -1); /* half/fullwidth ASCII */ + + return; +} + +int +CharacterClass(int c) +{ + int i, cclass = -1; + + 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; +} + +#endif /* OPT_WIDE_CHARS */ diff --git a/nx-X11/programs/xterm/charclass.h b/nx-X11/programs/xterm/charclass.h new file mode 100644 index 000000000..c93f8ff47 --- /dev/null +++ b/nx-X11/programs/xterm/charclass.h @@ -0,0 +1,13 @@ +/* $XFree86: xc/programs/xterm/charclass.h,v 1.1 2000/08/26 04:33:53 dawes 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); + +#endif diff --git a/nx-X11/programs/xterm/charproc.c b/nx-X11/programs/xterm/charproc.c new file mode 100644 index 000000000..4ec8a33df --- /dev/null +++ b/nx-X11/programs/xterm/charproc.c @@ -0,0 +1,7300 @@ +/* $XTermId: charproc.c,v 1.627 2005/11/13 23:10:35 tom Exp $ */ + +/* + * $Xorg: charproc.c,v 1.6 2001/02/09 02:06:02 xorgcvs Exp $ + */ + +/* $XFree86: xc/programs/xterm/charproc.c,v 3.177 2005/11/13 23:10:35 dickey Exp $ */ + +/* + +Copyright 1999-2004,2005 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. + */ + +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NX-X11, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of NoMachine S.r.l. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* charproc.c */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OPT_INPUT_METHOD + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif + +#if OPT_WIDE_CHARS +#include +#include +#ifdef HAVE_LANGINFO_CODESET +#include +#endif +#endif + +#if OPT_INPUT_METHOD +#include +#endif + +#include +#include + +#if defined(HAVE_SCHED_YIELD) +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if OPT_ZICONBEEP || OPT_TOOLBAR +#define HANDLE_STRUCT_NOTIFY 1 +#else +#define HANDLE_STRUCT_NOTIFY 0 +#endif + +static IChar doinput(void); +static int set_character_class(char *s); +static void FromAlternate(TScreen * screen); +static void RequestResize(XtermWidget termw, int rows, int cols, int text); +static void SwitchBufs(TScreen * screen); +static void ToAlternate(TScreen * screen); +static void VTallocbuf(void); +static void WriteText(TScreen * screen, + PAIRED_CHARS(Char * str, Char * str2), + Cardinal len); +static void ansi_modes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)); +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 termw, void (*func) (unsigned *p, unsigned mask)); +static void restoremodes(XtermWidget termw); +static void savemodes(XtermWidget termw); +static void unparseputn(unsigned int n, int fd); +static void window_ops(XtermWidget termw); + +#define DoStartBlinking(s) ((s)->cursor_blink ^ (s)->cursor_blink_esc) + +#if OPT_BLINK_CURS || OPT_BLINK_TEXT +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 char *_Font_Selected_ = "yes"; /* string is arbitrary */ + +static char defaultTranslations[] = +"\ + Shift Prior:scroll-back(1,halfpage) \n\ + Shift Next:scroll-forw(1,halfpage) \n\ + Shift Select:select-cursor-start() select-cursor-end(PRIMARY, CUT_BUFFER0) \n\ + Shift Insert:insert-selection(PRIMARY, CUT_BUFFER0) \n\ +" +#if OPT_SHIFT_FONTS +"\ + Shift~Ctrl KP_Add:larger-vt-font() \n\ + Shift Ctrl KP_Add:smaller-vt-font() \n\ + Shift KP_Subtract:smaller-vt-font() \n\ +" +#endif +"\ + ~Meta :insert-seven-bit() \n\ + Meta :insert-eight-bit() \n\ + !Ctrl :popup-menu(mainMenu) \n\ + !Lock Ctrl :popup-menu(mainMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(mainMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(mainMenu) \n\ + ~Meta :select-start() \n\ + ~Meta :select-extend() \n\ + !Ctrl :popup-menu(vtMenu) \n\ + !Lock Ctrl :popup-menu(vtMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(vtMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(vtMenu) \n\ + ~Ctrl ~Meta :ignore() \n\ + Meta :clear-saved-lines() \n\ + ~Ctrl ~Meta :insert-selection(PRIMARY, CUT_BUFFER0) \n\ + !Ctrl :popup-menu(fontMenu) \n\ + !Lock Ctrl :popup-menu(fontMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(fontMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(fontMenu) \n\ + ~Ctrl ~Meta :start-extend() \n\ + ~Meta :select-extend() \n\ + Ctrl :scroll-back(1,halfpage,m) \n\ + Lock Ctrl :scroll-back(1,halfpage,m) \n\ + Lock @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\ + @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\ + :scroll-back(5,line,m) \n\ + Ctrl :scroll-forw(1,halfpage,m) \n\ + Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + Lock @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + :scroll-forw(5,line,m) \n\ + :select-end(PRIMARY, CUT_BUFFER0) \n\ + :ignore() \ +"; /* PROCURA added "Meta :clear-saved-lines()" */ +/* *INDENT-OFF* */ +static XtActionsRec actionsList[] = { + { "allow-send-events", HandleAllowSends }, + { "bell", HandleBell }, + { "clear-saved-lines", HandleClearSavedLines }, + { "create-menu", HandleCreateMenu }, + { "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-redir", HandlePrintControlMode }, + { "quit", HandleQuit }, + { "redraw", HandleRedraw }, + { "delete-is-del", HandleDeleteIsDEL }, + { "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-cursesemul", HandleCursesEmul }, + { "set-jumpscroll", HandleJumpscroll }, + { "set-old-function-keys", HandleOldFunctionKeys }, + { "set-marginbell", HandleMarginBell }, + { "set-reverse-video", HandleReverseVideo }, + { "set-reversewrap", HandleReverseWrap }, + { "set-scroll-on-key", HandleScrollKey }, + { "set-scroll-on-tty-output", HandleScrollTtyOutput }, + { "set-scrollbar", HandleScrollbar }, + { "set-sun-function-keys", HandleSunFunctionKeys }, + { "set-sun-keyboard", HandleSunKeyboard }, + { "set-titeInhibit", HandleTiteInhibit }, + { "set-visual-bell", HandleSetVisualBell }, + { "set-pop-on-bell", HandleSetPopOnBell }, + { "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_BLINK_CURS + { "set-cursorblink", HandleCursorBlink }, +#endif +#if OPT_BOX_CHARS + { "set-font-linedrawing", HandleFontBoxChars }, +#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_HP_FUNC_KEYS + { "set-hp-function-keys", HandleHpFunctionKeys }, +#endif +#if OPT_LOAD_VTFONTS + { "load-vt-fonts", HandleLoadVTFonts }, +#endif +#if OPT_MAXIMIZE + { "deiconify", HandleDeIconify }, + { "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_SHIFT_FONTS + { "larger-vt-font", HandleLargerFont }, + { "smaller-vt-font", HandleSmallerFont }, +#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 }, +#endif +}; +/* *INDENT-ON* */ + +static XtResource resources[] = +{ + Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False), + Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, True), + 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(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(XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, screen.hp_ll_bc, False), + Bres(XtNi18nSelections, XtCI18nSelections, screen.i18nSelections, True), + Bres(XtNjumpScroll, XtCJumpScroll, screen.jumpscroll, 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(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(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(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(XtNprinterControlMode, XtCPrinterControlMode, + screen.printer_controlmode, 0), + 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(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(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), + Fres("iconFont", "IconFont", screen.fnt_icon, XtDefaultFont), + Cres("iconBorderColor", XtCBorderColor, misc.icon_border_pixel, XtDefaultBackground), +#endif /* NO_ACTIVE_ICON */ + +#if OPT_BLINK_CURS + Bres(XtNcursorBlink, XtCCursorBlink, screen.cursor_blink, False), +#endif + +#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(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_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), +#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"), +#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 */ + +#if OPT_MOD_FKEYS + Ires(XtNmodifyCursorKeys, XtCModifyCursorKeys, + keyboard.modify_cursor_keys, 2), +#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, screen.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 + Ires(XtNutf8, XtCUtf8, screen.utf8_mode, uDefault), + Bres(XtNwideChars, XtCWideChars, screen.wide_chars, False), + Bres(XtNmkWidth, XtCMkWidth, misc.mk_width, False), + Bres(XtNcjkWidth, XtCCjkWidth, misc.cjk_width, False), + Bres(XtNvt100Graphics, XtCVT100Graphics, screen.vt100_graphics, True), + Sres(XtNwideBoldFont, XtCWideBoldFont, misc.default_font.f_wb, DEFWIDEBOLDFONT), + Sres(XtNwideFont, XtCWideFont, misc.default_font.f_w, DEFWIDEFONT), +#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_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 + Dres(XtNfaceSize, XtCFaceSize, misc.face_size, DEFFACESIZE), + Sres(XtNfaceName, XtCFaceName, misc.face_name, DEFFACENAME), + Sres(XtNfaceNameDoublesize, XtCFaceNameDoublesize, misc.face_wide_name, DEFFACENAME), + Bres(XtNrenderFont, XtCRenderFont, misc.render_font, True), +#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(void); +#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 */ + resources, /* resources */ + XtNumber(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) +{ +#if OPT_TOOLBAR + /* *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_SHIFT_FONTS + { "larger-vt-font", HandleLargerFont }, + { "smaller-vt-font", HandleSmallerFont }, +#endif + }; + /* *INDENT-ON* */ + + XtAppAddActions(app_con, input_actions, XtNumber(input_actions)); +#endif + XtAugmentTranslations(w, XtParseTranslationTable(defaultTranslations)); +} + +#if OPT_ISO_COLORS +/* + * 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(int color) +{ + TScreen *screen = &term->screen; + Pixel fg; + + if (color >= 0) { + term->flags |= FG_COLOR; + } else { + term->flags &= ~FG_COLOR; + } + fg = getXtermForeground(term->flags, color); + term->cur_foreground = color; + + XSetForeground(screen->display, NormalGC(screen), fg); + XSetBackground(screen->display, ReverseGC(screen), fg); + + if (NormalGC(screen) != NormalBoldGC(screen)) { + XSetForeground(screen->display, NormalBoldGC(screen), fg); + XSetBackground(screen->display, ReverseBoldGC(screen), fg); + } +} + +void +SGR_Background(int color) +{ + TScreen *screen = &term->screen; + 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 != term->cur_background)) + FlushScroll(screen); + + if (color >= 0) { + term->flags |= BG_COLOR; + } else { + term->flags &= ~BG_COLOR; + } + bg = getXtermBackground(term->flags, color); + term->cur_background = color; + + XSetBackground(screen->display, NormalGC(screen), bg); + XSetForeground(screen->display, ReverseGC(screen), bg); + + if (NormalGC(screen) != NormalBoldGC(screen)) { + XSetBackground(screen->display, NormalBoldGC(screen), bg); + XSetForeground(screen->display, ReverseBoldGC(screen), bg); + } +} + +/* Invoked after updating bold/underline flags, computes the extended color + * index to use for foreground. (See also 'extract_fg()'). + */ +static void +setExtendedFG(void) +{ + int fg = term->sgr_foreground; + + if (term->screen.colorAttrMode + || (fg < 0)) { + if (term->screen.colorULMode && (term->flags & UNDERLINE)) + fg = COLOR_UL; + if (term->screen.colorBDMode && (term->flags & BOLD)) + fg = COLOR_BD; + if (term->screen.colorBLMode && (term->flags & BLINK)) + fg = COLOR_BL; + } + + /* 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 (term->screen.boldColors + && (!term->sgr_extended) + && (fg >= 0) + && (fg < 8) + && (term->flags & BOLD)) + fg |= 8; +#endif + + SGR_Foreground(fg); +} + +/* Invoked after updating inverse flag, computes the extended color + * index to use for background. (See also 'extract_bg()'). + */ +static void +setExtendedBG(void) +{ + int bg = term->sgr_background; + + if (term->screen.colorAttrMode + || (bg < 0)) { + if (term->screen.colorRVMode && (term->flags & INVERSE)) + bg = COLOR_RV; + } + + SGR_Background(bg); +} + +static void +reset_SGR_Foreground(void) +{ + term->sgr_foreground = -1; + term->sgr_extended = 0; + setExtendedFG(); +} + +static void +reset_SGR_Background(void) +{ + term->sgr_background = -1; + setExtendedBG(); +} + +static void +reset_SGR_Colors(void) +{ + reset_SGR_Foreground(); + reset_SGR_Background(); +} +#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_TRACE +#define WHICH_TABLE(name) if (table == name) result = #name +static char * +which_table(Const PARSE_T * table) +{ + char *result = "?"; + /* *INDENT-OFF* */ + WHICH_TABLE (ansi_table); + else WHICH_TABLE (csi_table); + else WHICH_TABLE (csi2_table); + else WHICH_TABLE (csi_ex_table); + else WHICH_TABLE (csi_quo_table); +#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); +#endif + else WHICH_TABLE (dec_table); + else WHICH_TABLE (dec2_table); + else WHICH_TABLE (dec3_table); + else WHICH_TABLE (cigtable); + else WHICH_TABLE (eigtable); + else WHICH_TABLE (esc_table); + else WHICH_TABLE (esc_sp_table); + else WHICH_TABLE (scrtable); + else WHICH_TABLE (scstable); + else WHICH_TABLE (sos_table); +#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; \ + unsigned 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(screen, \ + screen->gsets[(int) (screen->curss)], \ + print_area, 1); \ + screen->curss = 0; \ + single++; \ + } \ + if (print_used > single) { \ + dotext(screen, \ + screen->gsets[(int) (screen->curgl)], \ + print_area + single, \ + print_used - single); \ + } \ + print_used = 0; \ + } \ + +struct ParseState { +#if OPT_VT52_MODE + Bool vt52_cup; +#endif + Const PARSE_T *groundtable; + Const PARSE_T *parsestate; + int scstype; + 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 +}; + +static struct ParseState myState; + +static Boolean +doparsing(unsigned c, struct ParseState *sp) +{ + /* Buffer for processing printable text */ + static IChar *print_area; + static size_t print_size, print_used; + + /* Buffer for processing strings (e.g., OSC ... ST) */ + static Char *string_area; + static size_t string_size, string_used; + + TScreen *screen = &term->screen; + int row; + int col; + int top; + int bot; + int count; + int laststate; + int thischar = -1; + XTermRect myRect; + + do { +#if OPT_WIDE_CHARS + + /* + * 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) { + int prev, precomposed; + + WriteNow(); + + prev = getXtermCell(screen, + screen->last_written_row, + screen->last_written_col); + precomposed = do_precomposition(prev, (int) c); + + if (precomposed != -1) { + 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(screen, + 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 = xtermPrinterControl((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++] = (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, term->flags); + sp->parsestate = vt52_table; + param[0] = 0; + param[1] = 0; + continue; + } +#endif + + /* + * The parsing tables all have 256 entries. If we're supporting + * wide characters, we handle them by treating them the same as + * printing characters. + */ + laststate = sp->nextstate; +#if OPT_WIDE_CHARS + if (c > 255) { + 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 (string_used) { + switch (string_area[0]) { + case 'P': + if (string_used <= 7) + break; + /* FALLTHRU */ + case 'R': + sp->parsestate = sp->groundtable; + sp->nextstate = sp->parsestate[E2A(c)]; + 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 5: /* FALLTHRU */ + case 8: /* FALLTHRU */ + case 9: /* FALLTHRU */ + case 10: /* FALLTHRU */ + case 11: /* FALLTHRU */ + case 12: /* FALLTHRU */ + case 13: /* FALLTHRU */ + case 14: /* FALLTHRU */ + case 15: /* FALLTHRU */ + case 24: + sp->parsestate = sp->groundtable; + sp->nextstate = sp->parsestate[E2A(c)]; + 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. + */ + if (iswide((int) c) != 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, print_area, print_used, print_size); + if (new_string == 0) { + fprintf(stderr, + "Cannot allocate %u bytes for printable text\n", + 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 + print_area = new_string; + print_size = new_length; + print_area[print_used++] = sp->lastchar = thischar = c; +#if OPT_WIDE_CHARS + sp->last_was_wide = iswide((int) c); +#endif + if (morePtyData(screen, VTbuffer)) { + continue; + } + } + + if (sp->nextstate == CASE_PRINT + || (laststate == CASE_PRINT && 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, string_area, string_used, string_size); + if (new_string == 0) { + fprintf(stderr, + "Cannot allocate %u bytes for string mode %d\n", + 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 + string_area = new_string; + string_size = new_length; + string_area[string_used++] = c; + } else if (sp->parsestate != esc_table) { + /* if we were accumulating, we're not any more */ + sp->string_mode = 0; + 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")); + sp->parsestate = sp->groundtable; + 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(screen->answer_back[count], screen->respond); + break; + + case CASE_BELL: + TRACE(("CASE_BELL - bell\n")); + if (sp->string_mode == OSC) { + if (string_used) + string_area[--string_used] = '\0'; + do_osc(string_area, string_used, (int) c); + sp->parsestate = sp->groundtable; + } else { + /* bell */ + Bell(XkbBI_TerminalBell, 0); + } + break; + + case CASE_BS: + TRACE(("CASE_BS - backspace\n")); + CursorBack(screen, 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((int) c); + xtermIndex(screen, 1); + if (term->flags & LINEFEED) + CarriageReturn(screen); + do_xevents(); + break; + + case CASE_CBT: + /* cursor backward tabulation */ + if ((count = param[0]) == DEFAULT) + count = 1; + while ((count-- > 0) + && (TabToPrevStop(screen))) ; + sp->parsestate = sp->groundtable; + break; + + case CASE_CHT: + /* cursor forward tabulation */ + if ((count = param[0]) == DEFAULT) + count = 1; + while ((count-- > 0) + && (TabToNextStop(screen))) ; + sp->parsestate = sp->groundtable; + break; + + case CASE_TAB: + /* tab */ + TabToNextStop(screen); + break; + + case CASE_SI: + screen->curgl = 0; + if_OPT_VT52_MODE(screen, { + sp->parsestate = sp->groundtable; + }); + break; + + case CASE_SO: + screen->curgl = 1; + if_OPT_VT52_MODE(screen, { + sp->parsestate = sp->groundtable; + }); + break; + + case CASE_DECDHL: + xterm_DECDHL(c == '3'); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSWL: + xterm_DECSWL(); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECDWL: + xterm_DECDWL(); + sp->parsestate = sp->groundtable; + break; + + case CASE_SCR_STATE: + /* enter scr state */ + sp->parsestate = scrtable; + break; + + case CASE_SCS0_STATE: + /* enter scs state 0 */ + sp->scstype = 0; + sp->parsestate = scstable; + break; + + case CASE_SCS1_STATE: + /* enter scs state 1 */ + sp->scstype = 1; + sp->parsestate = scstable; + break; + + case CASE_SCS2_STATE: + /* enter scs state 2 */ + sp->scstype = 2; + sp->parsestate = scstable; + break; + + case CASE_SCS3_STATE: + /* enter scs state 3 */ + sp->scstype = 3; + sp->parsestate = scstable; + break; + + case CASE_ESC_IGNORE: + /* unknown escape sequence */ + sp->parsestate = eigtable; + break; + + case CASE_ESC_DIGIT: + /* digit in csi or dec mode */ + if ((row = param[nparam - 1]) == DEFAULT) + row = 0; + param[nparam - 1] = 10 * row + (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(screen, (unsigned) row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUU: + TRACE(("CASE_CUU - cursor up\n")); + if ((row = param[0]) < 1) + row = 1; + CursorUp(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUD: + TRACE(("CASE_CUD - cursor down\n")); + if ((row = param[0]) < 1) + row = 1; + CursorDown(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUF: + TRACE(("CASE_CUF - cursor forward\n")); + if ((col = param[0]) < 1) + col = 1; + CursorForward(screen, col); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUB: + TRACE(("CASE_CUB - cursor backward\n")); + if ((col = param[0]) < 1) + col = 1; + CursorBack(screen, col); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUP: + TRACE(("CASE_CUP - cursor position\n")); + if_OPT_XMC_GLITCH(screen, { + Jump_XMC(screen); + }); + if ((row = param[0]) < 1) + row = 1; + if (nparam < 2 || (col = param[1]) < 1) + col = 1; + CursorSet(screen, row - 1, col - 1, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_VPA: + TRACE(("CASE_VPA - vertical position\n")); + if ((row = param[0]) < 1) + row = 1; + CursorSet(screen, row - 1, screen->cur_col, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_HPA: + TRACE(("CASE_HPA - horizontal position\n")); + if ((col = param[0]) < 1) + col = 1; + CursorSet(screen, screen->cur_row, col - 1, term->flags); + sp->parsestate = sp->groundtable; + 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, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_ED: + TRACE(("CASE_ED - erase display\n")); + do_erase_display(screen, param[0], OFF_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_EL: + TRACE(("CASE_EL - erase line\n")); + do_erase_line(screen, param[0], OFF_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_ECH: + TRACE(("CASE_ECH - erase char\n")); + /* ECH */ + ClearRight(screen, param[0] < 1 ? 1 : param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_IL: + TRACE(("CASE_IL - insert line\n")); + if ((row = param[0]) < 1) + row = 1; + InsertLine(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_DL: + TRACE(("CASE_DL - delete line\n")); + if ((row = param[0]) < 1) + row = 1; + DeleteLine(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_DCH: + TRACE(("CASE_DCH - delete char\n")); + if ((row = param[0]) < 1) + row = 1; + DeleteChar(screen, (unsigned) row); + sp->parsestate = sp->groundtable; + 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) { + TRACE(("CASE_TRACK_MOUSE\n")); + /* Track mouse as long as in window and between + * specified rows + */ + TrackMouse(param[0], + param[2] - 1, param[1] - 1, + param[3] - 1, param[4] - 2); + } else { + TRACE(("CASE_SD - scroll down\n")); + /* SD */ + if ((count = param[0]) < 1) + count = 1; + RevScroll(screen, count); + do_xevents(); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECID: + TRACE(("CASE_DECID\n")); + if_OPT_VT52_MODE(screen, { + unparseputc(ESC, screen->respond); + unparseputc('/', screen->respond); + unparseputc('Z', screen->respond); + sp->parsestate = sp->groundtable; + 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 = 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++] = 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 (term->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 = count; + reply.a_inters = 0; + reply.a_final = 'c'; + unparseseq(&reply, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DA2: + TRACE(("CASE_DA2\n")); + if (param[0] <= 0) { /* less than means DEFAULT */ + count = 0; + reply.a_type = 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 = count; + reply.a_inters = 0; + reply.a_final = 'c'; + unparseseq(&reply, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRPTUI: + TRACE(("CASE_DECRPTUI\n")); + if ((screen->terminal_id >= 400) + && (param[0] <= 0)) { /* less than means DEFAULT */ + unparseputc1(DCS, screen->respond); + unparseputc('!', screen->respond); + unparseputc('|', screen->respond); + unparseputc('0', screen->respond); + unparseputc1(ST, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_TBC: + TRACE(("CASE_TBC - tab clear\n")); + if ((row = param[0]) <= 0) /* less than means default */ + TabClear(term->tabs, screen->cur_col); + else if (row == 3) + TabZonk(term->tabs); + sp->parsestate = sp->groundtable; + break; + + case CASE_SET: + TRACE(("CASE_SET - set mode\n")); + ansi_modes(term, bitset); + sp->parsestate = sp->groundtable; + break; + + case CASE_RST: + TRACE(("CASE_RST - reset mode\n")); + ansi_modes(term, bitclr); + sp->parsestate = sp->groundtable; + break; + + case CASE_SGR: + for (row = 0; row < nparam; ++row) { + if_OPT_XMC_GLITCH(screen, { + Mark_XMC(screen, param[row]); + }); + TRACE(("CASE_SGR %d\n", param[row])); + switch (param[row]) { + case DEFAULT: + case 0: + term->flags &= + ~(INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE); + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + break; + case 1: /* Bold */ + term->flags |= BOLD; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 5: /* Blink */ + term->flags |= BLINK; + StartBlinking(screen); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 4: /* Underscore */ + term->flags |= UNDERLINE; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 7: + term->flags |= INVERSE; + if_OPT_ISO_COLORS(screen, { + setExtendedBG(); + }); + break; + case 8: + term->flags |= INVISIBLE; + break; + case 22: /* reset 'bold' */ + term->flags &= ~BOLD; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 24: + term->flags &= ~UNDERLINE; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 25: /* reset 'blink' */ + term->flags &= ~BLINK; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 27: + term->flags &= ~INVERSE; + if_OPT_ISO_COLORS(screen, { + setExtendedBG(); + }); + break; + case 28: + term->flags &= ~INVISIBLE; + break; + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + if_OPT_ISO_COLORS(screen, { + term->sgr_foreground = (param[row] - 30); + term->sgr_extended = 0; + setExtendedFG(); + }); + 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) { + term->sgr_foreground = param[row]; + term->sgr_extended = 1; + setExtendedFG(); + } + break; + default: + row += 7; + break; + } + } + }); + break; + case 39: + if_OPT_ISO_COLORS(screen, { + reset_SGR_Foreground(); + }); + break; + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + if_OPT_ISO_COLORS(screen, { + term->sgr_background = (param[row] - 40); + setExtendedBG(); + }); + 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) { + term->sgr_background = param[row]; + setExtendedBG(); + } + break; + default: + row += 7; + break; + } + } + }); + break; + case 49: + if_OPT_ISO_COLORS(screen, { + reset_SGR_Background(); + }); + break; + case 90: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 97: + if_OPT_AIX_COLORS(screen, { + term->sgr_foreground = (param[row] - 90 + 8); + term->sgr_extended = 0; + setExtendedFG(); + }); + break; + case 100: +#if !OPT_AIX_COLORS + if_OPT_ISO_COLORS(screen, { + reset_SGR_Foreground(); + reset_SGR_Background(); + }); + break; +#endif + case 101: + case 102: + case 103: + case 104: + case 105: + case 106: + case 107: + if_OPT_AIX_COLORS(screen, { + term->sgr_background = (param[row] - 100 + 8); + setExtendedBG(); + }); + break; + } + } + sp->parsestate = sp->groundtable; + 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 = CSI; + reply.a_pintro = 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++] = screen->cur_row + 1; + reply.a_param[count++] = screen->cur_col + 1; + reply.a_final = 'R'; + break; + case 15: + /* printer status */ + reply.a_param[count++] = 13; /* implement printer */ + break; + case 25: + /* UDK status */ + reply.a_param[count++] = 20; /* UDK always unlocked */ + break; + case 26: + /* keyboard status */ + 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 OPT_DEC_LOCATOR + reply.a_param[count++] = 50; /* locator ready */ +#else + reply.a_param[count++] = 53; /* no locator */ +#endif + break; + } + + if ((reply.a_nparam = count) != 0) + unparseseq(&reply, screen->respond); + + sp->parsestate = sp->groundtable; + sp->private_function = False; + break; + + case CASE_MC: + TRACE(("CASE_MC - media control\n")); + xtermMediaControl(param[0], False); + sp->parsestate = sp->groundtable; + break; + + case CASE_DEC_MC: + TRACE(("CASE_DEC_MC - DEC media control\n")); + xtermMediaControl(param[0], True); + sp->parsestate = sp->groundtable; + 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(screen); + 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); + sp->parsestate = sp->groundtable; + 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(screen); + set_tb_margins(screen, top - 1, bot - 1); + CursorSet(screen, 0, 0, term->flags); + } + sp->parsestate = sp->groundtable; + 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 = CSI; + reply.a_pintro = 0; + reply.a_nparam = 7; + reply.a_param[0] = 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(&reply, screen->respond); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSET: + /* DECSET */ +#if OPT_VT52_MODE + if (screen->vtXX_level != 0) +#endif + dpmodes(term, bitset); + sp->parsestate = sp->groundtable; +#if OPT_TEK4014 + if (screen->TekEmu) + return False; +#endif + break; + + case CASE_DECRST: + /* DECRST */ + dpmodes(term, bitclr); +#if OPT_VT52_MODE + if (screen->vtXX_level == 0) + sp->groundtable = vt52_table; + else if (screen->terminal_id >= 100) + sp->groundtable = ansi_table; +#endif + sp->parsestate = sp->groundtable; + 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, term->flags); + xtermParseRect(screen, 0, 0, &myRect); + ScrnFillRectangle(screen, &myRect, 'E', 0); + sp->parsestate = sp->groundtable; + break; + + case CASE_GSETS: + TRACE(("CASE_GSETS(%d) = '%c'\n", sp->scstype, c)); + if (screen->vtXX_level != 0) + screen->gsets[sp->scstype] = c; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSC: + TRACE(("CASE_DECSC - save cursor\n")); + CursorSave(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRC: + TRACE(("CASE_DECRC - restore cursor\n")); + CursorRestore(term); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECKPAM: + TRACE(("CASE_DECKPAM\n")); + term->keyboard.flags |= MODE_DECKPAM; + update_appkeypad(); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECKPNM: + TRACE(("CASE_DECKPNM\n")); + term->keyboard.flags &= ~MODE_DECKPAM; + update_appkeypad(); + sp->parsestate = sp->groundtable; + break; + + case CASE_CSI_QUOTE_STATE: + sp->parsestate = csi_quo_table; + break; + +#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); + sp->parsestate = sp->groundtable; + break; + + case CASE_ANSI_LEVEL_2: + TRACE(("CASE_ANSI_LEVEL_2\n")); + set_ansi_conformance(screen, 2); + sp->parsestate = sp->groundtable; + break; + + case CASE_ANSI_LEVEL_3: + TRACE(("CASE_ANSI_LEVEL_3\n")); + set_ansi_conformance(screen, 3); + sp->parsestate = sp->groundtable; + 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(False, False); + screen->vtXX_level = param[0] - 60; + if (param[0] > 61) { + if (param[1] == 1) + show_8bit_control(False); + else if (param[1] == 0 || param[1] == 2) + show_8bit_control(True); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSCA: + TRACE(("CASE_DECSCA\n")); + screen->protected_mode = DEC_PROTECT; + if (param[0] <= 0 || param[0] == 2) + term->flags &= ~PROTECTED; + else if (param[0] == 1) + term->flags |= PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSED: + TRACE(("CASE_DECSED\n")); + do_erase_display(screen, param[0], DEC_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSEL: + TRACE(("CASE_DECSEL\n")); + do_erase_line(screen, param[0], DEC_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_ST: + TRACE(("CASE_ST: End of String (%d bytes)\n", string_used)); + sp->parsestate = sp->groundtable; + if (!string_used) + break; + string_area[--string_used] = '\0'; + switch (sp->string_mode) { + case APC: + /* ignored */ + break; + case DCS: + do_dcs(string_area, string_used); + break; + case OSC: + do_osc(string_area, string_used, ST); + break; + case PM: + /* ignored */ + break; + case SOS: + /* ignored */ + break; + } + break; + + case CASE_SOS: + TRACE(("CASE_SOS: Start of String\n")); + sp->string_mode = SOS; + sp->parsestate = sos_table; + break; + + case CASE_PM: + TRACE(("CASE_PM: Privacy Message\n")); + sp->string_mode = PM; + sp->parsestate = sos_table; + break; + + case CASE_DCS: + TRACE(("CASE_DCS: Device Control String\n")); + sp->string_mode = DCS; + sp->parsestate = sos_table; + break; + + case CASE_APC: + TRACE(("CASE_APC: Application Program Command\n")); + sp->string_mode = APC; + sp->parsestate = sos_table; + break; + + case CASE_SPA: + TRACE(("CASE_SPA - start protected area\n")); + screen->protected_mode = ISO_PROTECT; + term->flags |= PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_EPA: + TRACE(("CASE_EPA - end protected area\n")); + term->flags &= ~PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_SU: + TRACE(("CASE_SU - scroll up\n")); + if ((count = param[0]) < 1) + count = 1; + xtermScroll(screen, count); + sp->parsestate = sp->groundtable; + break; + + case CASE_IND: + TRACE(("CASE_IND - index\n")); + xtermIndex(screen, 1); + do_xevents(); + sp->parsestate = sp->groundtable; + break; + + case CASE_CPL: + TRACE(("CASE_CPL - cursor prev line\n")); + CursorPrevLine(screen, param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_CNL: + TRACE(("CASE_NPL - cursor next line\n")); + CursorNextLine(screen, param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_NEL: + TRACE(("CASE_NEL\n")); + xtermIndex(screen, 1); + CarriageReturn(screen); + do_xevents(); + sp->parsestate = sp->groundtable; + break; + + case CASE_HTS: + TRACE(("CASE_HTS - horizontal tab set\n")); + TabSet(term->tabs, screen->cur_col); + sp->parsestate = sp->groundtable; + break; + + case CASE_RI: + TRACE(("CASE_RI - reverse index\n")); + RevIndex(screen, 1); + sp->parsestate = sp->groundtable; + break; + + case CASE_SS2: + TRACE(("CASE_SS2\n")); + screen->curss = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_SS3: + TRACE(("CASE_SS3\n")); + screen->curss = 3; + sp->parsestate = sp->groundtable; + 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, term); + 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(term); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECELR: + MotionOff(screen, term); + 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; + 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; + } + sp->parsestate = sp->groundtable; + 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, term); + screen->loc_filter = False; + screen->locator_events = 0; + break; + case 1: + screen->locator_events |= LOC_BTNS_DN; + break; + case 2: + screen->locator_events &= ~LOC_BTNS_DN; + break; + case 3: + screen->locator_events |= LOC_BTNS_UP; + break; + case 4: + screen->locator_events &= ~LOC_BTNS_UP; + break; + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRQLP: + TRACE(("DECRQLP - Request Locator Position\n")); + if (param[0] < 2) { + /* Issue DECLRP Locator Position Report */ + GetLocatorPosition(term); + } + sp->parsestate = sp->groundtable; + break; +#endif /* OPT_DEC_LOCATOR */ + +#if OPT_DEC_RECTOPS + case CASE_CSI_DOLLAR_STATE: + /* csi dollar ($) */ + if (screen->vtXX_level >= 4) + sp->parsestate = csi_dollar_table; + else + sp->parsestate = eigtable; + break; + + case CASE_CSI_STAR_STATE: + /* csi dollar (*) */ + if (screen->vtXX_level >= 4) + sp->parsestate = csi_star_table; + else + sp->parsestate = eigtable; + break; + + case CASE_DECCRA: + TRACE(("CASE_DECCRA - Copy rectangular area\n")); + xtermParseRect(screen, nparam, param, &myRect); + ScrnCopyRectangle(screen, &myRect, nparam - 5, param + 5); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECERA: + TRACE(("CASE_DECERA - Erase rectangular area\n")); + xtermParseRect(screen, nparam, param, &myRect); + ScrnFillRectangle(screen, &myRect, ' ', 0); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECFRA: + TRACE(("CASE_DECFRA - Fill rectangular area\n")); + if (nparam > 0 + && ((param[0] >= 32 && param[0] <= 126) + || (param[0] >= 160 && param[0] <= 255))) { + xtermParseRect(screen, nparam - 1, param + 1, &myRect); + ScrnFillRectangle(screen, &myRect, param[0], term->flags); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSERA: + TRACE(("CASE_DECSERA - Selective erase rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnWipeRectangle(screen, &myRect); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSACE: + TRACE(("CASE_DECSACE - Select attribute change extent\n")); + screen->cur_decsace = param[0]; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECCARA: + TRACE(("CASE_DECCARA - Change attributes in rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnMarkRectangle(screen, &myRect, False, nparam - 4, param + 4); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRARA: + TRACE(("CASE_DECRARA - Reverse attributes in rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnMarkRectangle(screen, &myRect, True, nparam - 4, param + 4); + sp->parsestate = sp->groundtable; + break; +#else + case CASE_CSI_DOLLAR_STATE: + /* csi dollar ($) */ + sp->parsestate = eigtable; + break; + + case CASE_CSI_STAR_STATE: + /* csi dollar (*) */ + sp->parsestate = eigtable; + break; +#endif /* OPT_DEC_RECTOPS */ + + case CASE_S7C1T: + TRACE(("CASE_S7C1T\n")); + show_8bit_control(False); + sp->parsestate = sp->groundtable; + break; + + case CASE_S8C1T: + TRACE(("CASE_S8C1T\n")); +#if OPT_VT52_MODE + if (screen->vtXX_level <= 1) + break; +#endif + show_8bit_control(True); + sp->parsestate = sp->groundtable; + break; + + case CASE_OSC: + TRACE(("CASE_OSC: Operating System Command\n")); + sp->parsestate = sos_table; + sp->string_mode = OSC; + break; + + case CASE_RIS: + TRACE(("CASE_RIS\n")); + VTReset(True, True); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSTR: + TRACE(("CASE_DECSTR\n")); + VTReset(False, False); + sp->parsestate = sp->groundtable; + break; + + case CASE_REP: + TRACE(("CASE_REP\n")); + if (sp->lastchar >= 0 && + sp->groundtable[E2A(sp->lastchar)] == CASE_PRINT) { + IChar repeated[2]; + count = (param[0] < 1) ? 1 : param[0]; + repeated[0] = sp->lastchar; + while (count-- > 0) { + dotext(screen, + screen->gsets[(int) (screen->curgl)], + repeated, 1); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_LS2: + TRACE(("CASE_LS2\n")); + screen->curgl = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS3: + TRACE(("CASE_LS3\n")); + screen->curgl = 3; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS3R: + TRACE(("CASE_LS3R\n")); + screen->curgr = 3; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS2R: + TRACE(("CASE_LS2R\n")); + screen->curgr = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS1R: + TRACE(("CASE_LS1R\n")); + screen->curgr = 1; + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_SAVE: + savemodes(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_RESTORE: + restoremodes(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_WINOPS: + TRACE(("CASE_XTERM_WINOPS\n")); + if (screen->allowWindowOps) + window_ops(term); + sp->parsestate = sp->groundtable; + 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) { + WriteNow(); + ChangeToWide(screen); + } + if (screen->wide_chars + && screen->utf8_mode != uAlways) { + 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")); + } + sp->parsestate = sp->groundtable; + break; +#endif + + case CASE_CSI_IGNORE: + sp->parsestate = cigtable; + break; + } + if (sp->parsestate == sp->groundtable) + sp->lastchar = thischar; + } while (0); + +#if OPT_WIDE_CHARS + screen->utf8_inparse = (screen->utf8_mode != uFalse + && sp->parsestate != sos_table); +#endif + + return True; +} + +static void +VTparse(void) +{ + TScreen *screen; + + /* We longjmp back to this point in VTReset() */ + (void) setjmp(vtjmpbuf); + screen = &term->screen; + memset(&myState, 0, sizeof(myState)); +#if OPT_VT52_MODE + myState.groundtable = screen->vtXX_level ? ansi_table : vt52_table; +#else + myState.groundtable = ansi_table; +#endif + myState.parsestate = myState.groundtable; + myState.lastchar = -1; /* not a legal IChar */ + myState.nextstate = -1; /* not a legal state */ + + for (;;) { + if (!doparsing(doinput(), &myState)) + return; + } +} + +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. */ + +int +v_write(int f, Char * data, unsigned len) +{ + int riten; + unsigned c = len; + + if (v_bufstr == NULL && len > 0) { + v_buffer = (Char *) XtMalloc(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, (char *) data); + fprintf(stderr, "\n"); + } +#endif + +#ifdef VMS + if ((1 << f) != pty_mask) + return (tt_write((char *) data, len)); +#else /* VMS */ + if (!FD_ISSET(f, &pty_mask)) + return (write(f, (char *) data, len)); +#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 + term->screen.dabbrev_working = 0; /* 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, (unsigned) (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. */ + int size = v_bufptr - v_buffer; /* save across realloc */ + 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 */ + c = 0; + } + } + } + if (v_bufend >= v_bufptr + len) { + /* new stuff will fit */ + memmove(v_bufptr, data, 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 = 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 = v_bufstr - v_buffer; + int size = 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 */ + } + } + return (c); +} + +#ifdef VMS +#define ptymask() (v_bufptr > v_bufstr ? pty_mask : 0) + +static void +in_put(void) +{ + static PtySelect select_mask; + static PtySelect write_mask; + int update = VTbuffer->update; + int size; + + int status; + Dimension replyWidth, replyHeight; + XtGeometryResult stat; + + TScreen *screen = &term->screen; + 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 = XtMakeResizeRequest((Widget) term, + ((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) { + term->core.width = replyWidth; + term->core.height = replyHeight; + + ScreenResize(&term->screen, replyWidth, replyHeight, + &term->flags); + } + repairSizeHints(); + } + + if (eventMode == NORMAL + && readPtyData(screen, &select_mask, VTbuffer)) { + if (screen->scrollWidget + && screen->scrollttyoutput + && screen->topline < 0) + /* Scroll to bottom */ + WindowScroll(screen, 0); + break; + } + if (screen->scroll_amt) + FlushScroll(screen); + 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 (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(void) +{ + static PtySelect select_mask; + static PtySelect write_mask; + + TScreen *screen = &term->screen; + 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 (eventMode == NORMAL + && (size = readPtyData(screen, &select_mask, VTbuffer)) != 0) { + if (screen->scrollWidget + && screen->scrollttyoutput + && screen->topline < 0) + WindowScroll(screen, 0); /* Scroll to bottom */ + /* stop speed reading at some point to look for X stuff */ + TRACE(("VTbuffer uses %d/%d\n", + 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(screen); + 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 (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) { + /* + * When session management is enabled, we should not block since + * session related events can arrive any time. + */ + select_timeout.tv_sec = 1; + select_timeout.tv_usec = 0; + time_select = 1; +#endif + } + if (need_cleanup) + Cleanup(0); + +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) + fprintf(stderr, "xterm::in_put: Select called with [%d][%p][%p][%p][%p].\n", + max_plus1, (void *) &select_mask, (void *) &write_mask, (void *) 0, + (void *) (time_select ? &select_timeout : 0)); +#endif + + 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 = &term->screen; + + while (!morePtyData(screen, VTbuffer)) + in_put(); + return nextPtyData(screen, VTbuffer); +} + +#if OPT_INPUT_METHOD +/* + * For OverTheSpot, client has to inform the position for XIM preedit. + */ +static void +PreeditPosition(TScreen * screen) +{ + XPoint spot; + XVaNestedList list; + + if (!screen->xic) + return; + spot.x = CurCursorX(screen, screen->cur_row, screen->cur_col); + spot.y = 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 + +/* + * process a string of characters according to the character set indicated + * by charset. worry about end of line conditions (wraparound if selected). + */ +void +dotext(TScreen * screen, + int charset, + IChar * buf, /* start of characters to process */ + Cardinal len) /* end */ +{ +#if OPT_WIDE_CHARS + Cardinal chars_chomped = 1; +#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 && charset == '0')) +#endif + + if (!xtermCharSetOut(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; + int need_wrap = 0; + chars_chomped = 0; + + if (screen->do_wrap && (term->flags & WRAPAROUND)) { + /* mark that we had to wrap this line */ + ScrnSetWrapped(screen, screen->cur_row); + xtermAutoPrint('\n'); + xtermIndex(screen, 1); + set_cur_col(screen, 0); + screen->do_wrap = 0; + width_available = MaxCols(screen) - screen->cur_col; + } + + while (width_here <= width_available && chars_chomped < (len - offset)) { + if (!screen->utf8_mode + || (screen->vt100_graphics && charset == '0')) + width_here++; + else + width_here += my_wcwidth((int) buf[chars_chomped + offset]); + chars_chomped++; + } + + if (width_here > width_available) { + chars_chomped--; + if (!screen->utf8_mode + || (screen->vt100_graphics && charset == '0')) + width_here--; + else + width_here -= my_wcwidth((int) buf[chars_chomped + offset]); + need_wrap = 1; + } else if (width_here == width_available) { + need_wrap = 1; + } else if (chars_chomped != (len - offset)) { + need_wrap = 1; + } + + /* + * 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) { + static unsigned limit; + static Char *hibyte, *lobyte; + Bool both = False; + unsigned j, k; + + if (chars_chomped >= limit) { + limit = (chars_chomped + 1) * 2; + lobyte = (Char *) XtRealloc((char *) lobyte, limit); + hibyte = (Char *) XtRealloc((char *) hibyte, limit); + } + for (j = offset; j < offset + chars_chomped; j++) { + k = j - offset; + lobyte[k] = buf[j]; + if (buf[j] > 255) { + hibyte[k] = (buf[j] >> 8); + both = True; + } else { + hibyte[k] = 0; + } + } + + WriteText(screen, PAIRED_CHARS(lobyte, + (both ? hibyte : 0)), + chars_chomped); + } + screen->do_wrap = need_wrap; + } +#else + + for (offset = 0; offset < len; offset += this_col) { + last_col = CurMaxCol(screen, screen->cur_row); + this_col = last_col - screen->cur_col + 1; + if (this_col <= 1) { + if (screen->do_wrap && (term->flags & WRAPAROUND)) { + /* mark that we had to wrap this line */ + ScrnSetWrapped(screen, screen->cur_row); + xtermAutoPrint('\n'); + xtermIndex(screen, 1); + set_cur_col(screen, 0); + screen->do_wrap = 0; + this_col = last_col + 1; + } else + this_col = 1; + } + if (offset + this_col > len) { + this_col = len - offset; + } + next_col = screen->cur_col + this_col; + + WriteText(screen, PAIRED_CHARS(buf + offset, + buf2 ? buf2 + offset : 0), + this_col); + + /* + * the call to WriteText updates screen->cur_col. + * If screen->cur_col != next_col, we must have + * hit the right margin, so set the do_wrap flag. + */ + screen->do_wrap = (screen->cur_col < (int) next_col); + } + +#endif +} + +#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! + */ +static int mapstate = -1; +#endif /* HANDLE_STRUCT_NOTIFY */ + +#if OPT_WIDE_CHARS +unsigned +visual_width(PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +{ + /* returns the visual width of a string (doublewide characters count + as 2, normalwide characters count as 1) */ + int my_len = 0; + while (len) { + int ch = *str; + if (str2) + ch |= *str2 << 8; + if (str) + str++; + if (str2) + str2++; + if (iswide(ch)) + my_len += 2; + else + my_len++; + len--; + } + return my_len; +} +#endif + +/* + * write a string str of length len onto the screen at + * the current cursor position. update cursor position. + */ +static void +WriteText(TScreen * screen, PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +{ + ScrnPtr PAIRED_CHARS(temp_str = 0, temp_str2 = 0); + unsigned test; + unsigned flags = term->flags; + unsigned fg_bg = makeColorPair(term->cur_foreground, term->cur_background); + unsigned cells = visual_width(PAIRED_CHARS(str, str2), len); + GC currentGC; + + TRACE(("WriteText (%2d,%2d) (%d) %3d:%s\n", + screen->cur_row, + screen->cur_col, + curXtermChrSet(screen->cur_row), + len, visibleChars(PAIRED_CHARS(str, str2), len))); + + if (ScrnHaveSelection(screen) + && ScrnIsLineInSelection(screen, screen->cur_row - screen->topline)) { + ScrnDisownSelection(screen); + } + + if (screen->cur_row - screen->topline <= screen->max_row) { + if (screen->cursor_state) + HideCursor(); + + if (flags & INSERT) { + InsertChar(screen, cells); + } + if (!AddToRefresh(screen)) { + + if (screen->scroll_amt) + FlushScroll(screen); + + if (flags & INVISIBLE) { + if (cells > len) { + str = temp_str = TypeMallocN(Char, cells); + if (str == 0) + return; + } + if_OPT_WIDE_CHARS(screen, { + if (cells > len) { + str2 = temp_str2 = TypeMallocN(Char, cells); + } + }); + len = cells; + + memset(str, ' ', len); + if_OPT_WIDE_CHARS(screen, { + if (str2 != 0) + memset(str2, 0, len); + }); + } + + TRACE(("WriteText calling drawXtermText (%d,%d)\n", + screen->cur_col, + screen->cur_row)); + + test = flags; + checkVeryBoldColors(test, term->cur_foreground); + + /* make sure that the correct GC is current */ + currentGC = updatedXtermGC(screen, flags, fg_bg, False); + + drawXtermText(screen, test & DRAWX_MASK, currentGC, + CurCursorX(screen, screen->cur_row, screen->cur_col), + CursorY(screen, screen->cur_row), + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(str, str2), len, 0); + + resetXtermGC(screen, flags, False); + } + } + + ScreenWrite(screen, PAIRED_CHARS(str, str2), flags, fg_bg, len); + CursorForward(screen, (int) cells); +#if OPT_ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + */ + if (zIconBeep && mapstate == IsUnmapped && !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) { + zIconBeep_flagged = True; + Changename(icon_name); + } + if (zIconBeep > 0) { +#if defined(HAVE_XKBBELL) + XkbBell(XtDisplay(toplevel), VShellWindow, zIconBeep, XkbBI_Info); +#else + XBell(XtDisplay(toplevel), zIconBeep); +#endif + } + } + mapstate = -1; +#endif /* OPT_ZICONBEEP */ + if (temp_str != 0) + free(temp_str); + if_OPT_WIDE_CHARS(screen, { + if (temp_str2 != 0) + free(temp_str2); + }); + return; +} + +#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} + }; + + switch (event->type) { + case MapNotify: + TRACE(("HandleStructNotify(MapNotify)\n")); +#if OPT_ZICONBEEP + if (zIconBeep_flagged) { + 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) { + zIconBeep_flagged = True; + return; + } + strcpy(buf, icon_name + 4); + Changename(buf); + free(buf); + } + } +#endif /* OPT_ZICONBEEP */ + mapstate = !IsUnmapped; + break; + case UnmapNotify: + TRACE(("HandleStructNotify(UnmapNotify)\n")); + mapstate = IsUnmapped; + break; + case ConfigureNotify: + TRACE(("HandleStructNotify(ConfigureNotify)\n")); +#if OPT_TOOLBAR + /* the notify is for the top-level widget, but we care about vt100 */ + if (term->screen.Vshow) { + TScreen *screen = &term->screen; + struct _vtwin *Vwin = WhichVWin(&(term->screen)); + 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. + */ + XtMakeResizeRequest((Widget) term, + screen->fullVwin.fullwidth, + info->menu_height + - save.menu_height + + screen->fullVwin.fullheight, + NULL, NULL); + repairSizeHints(); + } + } + } +#endif /* OPT_TOOLBAR */ + break; + default: + TRACE(("HandleStructNotify(event %d)\n", event->type)); + break; + } +} +#endif /* HANDLE_STRUCT_NOTIFY */ + +#if OPT_BLINK_CURS +static void +SetCursorBlink(TScreen * screen, int enable) +{ + screen->cursor_blink = enable; + if (DoStartBlinking(screen)) { + StartBlinking(screen); + } else { +#if !OPT_BLINK_TEXT + StopBlinking(screen); +#endif + } + update_cursorblink(); +} + +void +ToggleCursorBlink(TScreen * screen) +{ + SetCursorBlink(screen, !(screen->cursor_blink)); +} +#endif + +/* + * process ANSI modes set, reset + */ +static void +ansi_modes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)) +{ + int i; + + for (i = 0; i < nparam; ++i) { + switch (param[i]) { + case 2: /* KAM (if set, keyboard locked */ + (*func) (&termw->keyboard.flags, MODE_KAM); + break; + + case 4: /* IRM */ + (*func) (&termw->flags, INSERT); + break; + + case 12: /* SRM (if set, local echo */ + (*func) (&termw->keyboard.flags, MODE_SRM); + break; + + case 20: /* LNM */ + (*func) (&termw->flags, LINEFEED); + update_autolinefeed(); + break; + } + } +} + +#define set_mousemode(mode) \ + screen->send_mouse_pos = (func == bitset) ? mode : MOUSE_OFF +#define set_mouseflag(f) \ + ((func == bitset) \ + ? SCREEN_FLAG_set(screen, f) \ + : SCREEN_FLAG_unset(screen, f)) + +/* + * process DEC private modes set, reset + */ +static void +dpmodes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)) +{ + TScreen *screen = &termw->screen; + int i, j; + + for (i = 0; i < nparam; ++i) { + TRACE(("%s %d\n", (func == bitset) ? "DECSET" : "DECRST", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + (*func) (&termw->keyboard.flags, MODE_DECCKM); + update_appcursor(); + break; + case 2: /* DECANM - ANSI/VT52 mode */ + if (func == bitset) { /* ANSI (VT100) */ + /* + * Setting DECANM should have no effect, since this function + * cannot be reached from vt52 mode. + */ + ; + } +#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(screen); + CursorSet(screen, 0, 0, termw->flags); + if ((j = func == bitset ? 132 : 80) != + ((termw->flags & IN132COLUMNS) ? 132 : 80) || + j != MaxCols(screen)) + RequestResize(termw, -1, j, True); + (*func) (&termw->flags, IN132COLUMNS); + } + break; + case 4: /* DECSCLM (slow scroll) */ + if (func == bitset) { + screen->jumpscroll = 0; + if (screen->scroll_amt) + FlushScroll(screen); + } else + screen->jumpscroll = 1; + (*func) (&termw->flags, SMOOTHSCROLL); + update_jumpscroll(); + break; + case 5: /* DECSCNM */ + j = termw->flags; + (*func) (&termw->flags, REVERSE_VIDEO); + if ((termw->flags ^ j) & REVERSE_VIDEO) + ReverseVideo(termw); + /* update_reversevideo done in RevVid */ + break; + + case 6: /* DECOM */ + (*func) (&termw->flags, ORIGIN); + CursorSet(screen, 0, 0, termw->flags); + break; + + case 7: /* DECAWM */ + (*func) (&termw->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, termw); + set_mousemode(X10_MOUSE); + break; +#if OPT_TOOLBAR + case 10: /* rxvt */ + ShowToolbar(func == bitset); + break; +#endif +#if OPT_BLINK_CURS + case 12: /* att610: Start/stop blinking cursor */ + if (screen->cursor_blink_res) { + screen->cursor_blink_esc = (func == bitset) ? ON : OFF; + SetCursorBlink(screen, screen->cursor_blink); + } + break; +#endif + case 18: /* DECPFF: print form feed */ + screen->printer_formfeed = (func == bitset) ? ON : OFF; + break; + case 19: /* DECPEX: print extent */ + screen->printer_extent = (func == bitset) ? ON : OFF; + break; + case 25: /* DECTCEM: Show/hide cursor (VT200) */ + screen->cursor_set = (func == bitset) ? ON : OFF; + break; + case 30: /* rxvt */ + if (screen->fullVwin.sb_info.width != ((func == bitset) ? ON : OFF)) + ToggleScrollBar(termw); + break; +#if OPT_SHIFT_FONTS + case 35: /* rxvt */ + term->misc.shift_fonts = (func == bitset) ? ON : OFF; + break; +#endif + case 38: /* DECTEK */ +#if OPT_TEK4014 + if (func == bitset && !(screen->inhibit & I_TEK)) { + FlushLog(screen); + screen->TekEmu = True; + } +#endif + break; + case 40: /* 132 column mode */ + screen->c132 = (func == bitset); + update_allow132(); + break; + case 41: /* curses hack */ + screen->curses = (func == bitset); + update_cursesemul(); + break; + case 42: /* DECNRCM national charset (VT220) */ + (*func) (&termw->flags, NATIONAL); + break; + case 44: /* margin bell */ + screen->marginbell = (func == bitset); + if (!screen->marginbell) + screen->bellarmed = -1; + update_marginbell(); + break; + case 45: /* reverse wraparound */ + (*func) (&termw->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 (func == bitset) + StartLog(screen); + else + CloseLog(screen); +#else + Bell(XkbBI_Info, 0); + Bell(XkbBI_Info, 0); +#endif /* ALLOWLOGFILEONOFF */ + break; +#endif + case 1049: /* alternate buffer & cursor */ + if (!termw->misc.titeInhibit) { + if (func == bitset) { + CursorSave(termw); + ToAlternate(screen); + ClearScreen(screen); + } else { + FromAlternate(screen); + CursorRestore(termw); + } + } else if (termw->misc.tiXtraScroll) { + if (func == bitset) { + xtermScroll(screen, screen->max_row); + } + } + break; + case 1047: + case 47: /* alternate buffer */ + if (!termw->misc.titeInhibit) { + if (func == bitset) { + ToAlternate(screen); + } else { + if (screen->alternate + && (param[i] == 1047)) + ClearScreen(screen); + FromAlternate(screen); + } + } else if (termw->misc.tiXtraScroll) { + if (func == bitset) { + xtermScroll(screen, screen->max_row); + } + } + break; + case 66: /* DECNKM */ + (*func) (&termw->keyboard.flags, MODE_DECKPAM); + update_appkeypad(); + break; + case 67: /* DECBKM */ + /* back-arrow mapped to backspace or delete(D) */ + (*func) (&termw->keyboard.flags, MODE_DECBKM); + TRACE(("DECSET DECBKM %s\n", + BtoS(termw->keyboard.flags & MODE_DECBKM))); + update_decbkm(); + break; + case SET_VT200_MOUSE: /* xterm bogus sequence */ + MotionOff(screen, termw); + set_mousemode(VT200_MOUSE); + break; + case SET_VT200_HIGHLIGHT_MOUSE: /* xterm sequence w/hilite tracking */ + MotionOff(screen, termw); + set_mousemode(VT200_HIGHLIGHT_MOUSE); + break; + case SET_BTN_EVENT_MOUSE: + MotionOff(screen, termw); + 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, term); + } else { + MotionOn(screen, term); + } + break; + case 1010: /* rxvt */ + screen->scrollttyoutput = (func == bitset) ? ON : OFF; + update_scrollttyoutput(); + break; + case 1011: /* rxvt */ + screen->scrollkey = (func == bitset) ? ON : OFF; + update_scrollkey(); + break; +#if OPT_NUM_LOCK + case 1035: + term->misc.real_NumLock = (func == bitset) ? ON : OFF; + update_num_lock(); + break; + case 1036: + screen->meta_sends_esc = (func == bitset) ? ON : OFF; + update_meta_esc(); + break; +#endif + case 1037: + screen->delete_is_del = (func == bitset) ? ON : OFF; + update_delete_del(); + break; + case 1048: + if (!termw->misc.titeInhibit) { + if (func == bitset) + CursorSave(termw); + else + CursorRestore(termw); + } + break; + case 1051: + set_keyboard_type(keyboardIsSun, func == bitset); + break; +#if OPT_HP_FUNC_KEYS + case 1052: + set_keyboard_type(keyboardIsHP, func == bitset); + break; +#endif +#if OPT_SCO_FUNC_KEYS + case 1053: + set_keyboard_type(keyboardIsSCO, func == bitset); + break; +#endif + case 1060: + set_keyboard_type(keyboardIsLegacy, func == bitset); + break; +#if OPT_SUNPC_KBD + case 1061: + set_keyboard_type(keyboardIsVT220, func == bitset); + 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 termw) +{ + TScreen *screen = &termw->screen; + int i; + + for (i = 0; i < nparam; i++) { + TRACE(("savemodes %d\n", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + DoSM(DP_DECCKM, termw->keyboard.flags & MODE_DECCKM); + break; + case 3: /* DECCOLM */ + if (screen->c132) + DoSM(DP_DECCOLM, termw->flags & IN132COLUMNS); + break; + case 4: /* DECSCLM (slow scroll) */ + DoSM(DP_DECSCLM, termw->flags & SMOOTHSCROLL); + break; + case 5: /* DECSCNM */ + DoSM(DP_DECSCNM, termw->flags & REVERSE_VIDEO); + break; + case 6: /* DECOM */ + DoSM(DP_DECOM, termw->flags & ORIGIN); + break; + + case 7: /* DECAWM */ + DoSM(DP_DECAWM, termw->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 44: /* margin bell */ + DoSM(DP_X_MARGIN, screen->marginbell); + break; + case 45: /* reverse wraparound */ + DoSM(DP_X_REVWRAP, termw->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->alternate); + 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; + case 1048: + if (!termw->misc.titeInhibit) { + CursorSave(termw); + } + 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 termw) +{ + TScreen *screen = &termw->screen; + int i, j; + + for (i = 0; i < nparam; i++) { + TRACE(("restoremodes %d\n", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + bitcpy(&termw->keyboard.flags, + screen->save_modes[DP_DECCKM], MODE_DECCKM); + update_appcursor(); + break; + case 3: /* DECCOLM */ + if (screen->c132) { + ClearScreen(screen); + CursorSet(screen, 0, 0, termw->flags); + if ((j = (screen->save_modes[DP_DECCOLM] & IN132COLUMNS) + ? 132 : 80) != ((termw->flags & IN132COLUMNS) + ? 132 : 80) || j != MaxCols(screen)) + RequestResize(termw, -1, j, True); + bitcpy(&termw->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(screen); + } else + screen->jumpscroll = 1; + bitcpy(&termw->flags, screen->save_modes[DP_DECSCLM], SMOOTHSCROLL); + update_jumpscroll(); + break; + case 5: /* DECSCNM */ + if ((screen->save_modes[DP_DECSCNM] ^ termw->flags) & REVERSE_VIDEO) { + bitcpy(&termw->flags, screen->save_modes[DP_DECSCNM], REVERSE_VIDEO); + ReverseVideo(termw); + /* update_reversevideo done in RevVid */ + } + break; + case 6: /* DECOM */ + bitcpy(&termw->flags, screen->save_modes[DP_DECOM], ORIGIN); + CursorSet(screen, 0, 0, termw->flags); + break; + + case 7: /* DECAWM */ + bitcpy(&termw->flags, screen->save_modes[DP_DECAWM], WRAPAROUND); + update_autowrap(); + break; + case 8: /* DECARM */ + /* ignore autorepeat */ + break; + case SET_X10_MOUSE: /* MIT bogus sequence */ + DoRM(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(&termw->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(screen); + else + CloseLog(screen); +#endif /* ALLOWLOGFILEONOFF */ + /* update_logging done by StartLog and CloseLog */ + break; +#endif + case 1047: /* alternate buffer */ + /* FALLTHRU */ + case 47: /* alternate buffer */ + if (!termw->misc.titeInhibit) { + if (screen->save_modes[DP_X_ALTSCRN]) + ToAlternate(screen); + else + FromAlternate(screen); + /* update_altscreen done by ToAlt and FromAlt */ + } else if (termw->misc.tiXtraScroll) { + if (screen->save_modes[DP_X_ALTSCRN]) { + xtermScroll(screen, 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: + DoRM(DP_X_MOUSE, screen->send_mouse_pos); + break; + case 1048: + if (!termw->misc.titeInhibit) { + CursorRestore(termw); + } + 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 */ + } + } +} + +/* + * Report window label (icon or title) in dtterm protocol + * ESC ] code label ESC backslash + */ +static void +report_win_label(TScreen * screen, + int code, + XTextProperty * text, + Status ok) +{ + char **list; + int length = 0; + + reply.a_type = ESC; + unparseputc(ESC, screen->respond); + unparseputc(']', screen->respond); + unparseputc(code, screen->respond); + + if (ok) { + if (XTextPropertyToStringList(text, &list, &length)) { + int n, c; + for (n = 0; n < length; n++) { + char *s = list[n]; + while ((c = *s++) != '\0') + unparseputc(c, screen->respond); + } + XFreeStringList(list); + } + if (text->value != 0) + XFree(text->value); + } + + unparseputc(ESC, screen->respond); + unparseputc('\\', screen->respond); +} + +/* + * Window operations (from CDE dtterm description, as well as extensions). + * See also "allowWindowOps" resource. + */ +static void +window_ops(XtermWidget termw) +{ + TScreen *screen = &termw->screen; + XWindowChanges values; + XWindowAttributes win_attrs; + XTextProperty text; + unsigned value_mask; + unsigned root_width; + unsigned root_height; + + TRACE(("window_ops %d\n", param[0])); + switch (param[0]) { + case 1: /* Restore (de-iconify) window */ + XMapWindow(screen->display, + VShellWindow); + break; + + case 2: /* Minimize (iconify) window */ + XIconifyWindow(screen->display, + VShellWindow, + DefaultScreen(screen->display)); + break; + + case 3: /* Move the window to the given position */ + values.x = param[1]; + values.y = param[2]; + value_mask = (CWX | CWY); + XReconfigureWMWindow(screen->display, + VShellWindow, + DefaultScreen(screen->display), + value_mask, + &values); + break; + + case 4: /* Resize the window to given size in pixels */ + RequestResize(termw, param[1], param[2], False); + break; + + case 5: /* Raise the window to the front of the stack */ + XRaiseWindow(screen->display, VShellWindow); + break; + + case 6: /* Lower the window to the bottom of the stack */ + XLowerWindow(screen->display, VShellWindow); + break; + + case 7: /* Refresh the window */ + Redraw(); + break; + + case 8: /* Resize the text-area, in characters */ + RequestResize(termw, param[1], param[2], True); + break; + +#if OPT_MAXIMIZE + case 9: /* Maximize or restore */ + RequestMaximize(termw, param[1]); + break; +#endif + + case 11: /* Report the window's state */ + XGetWindowAttributes(screen->display, + VWindow(screen), + &win_attrs); + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 1; + reply.a_param[0] = (win_attrs.map_state == IsViewable) ? 1 : 2; + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 13: /* Report the window's position */ + XGetWindowAttributes(screen->display, + WMFrameWindow(termw), + &win_attrs); + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 3; + reply.a_param[1] = win_attrs.x; + reply.a_param[2] = win_attrs.y; + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 14: /* Report the window's size in pixels */ + XGetWindowAttributes(screen->display, + VWindow(screen), + &win_attrs); + reply.a_type = 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] = Height(screen); + reply.a_param[2] = Width(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 18: /* Report the text's size in characters */ + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 8; + reply.a_param[1] = MaxRows(screen); + reply.a_param[2] = MaxCols(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + +#if OPT_MAXIMIZE + case 19: /* Report the screen's size, in characters */ + if (!QueryMaximize(term, &root_height, &root_width)) { + root_height = 0; + root_width = 0; + } + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 9; + reply.a_param[1] = root_height / FontHeight(screen); + reply.a_param[2] = root_width / FontWidth(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; +#endif + + case 20: /* Report the icon's label */ + report_win_label(screen, 'L', &text, + XGetWMIconName(screen->display, VShellWindow, &text)); + break; + + case 21: /* Report the window's title */ + report_win_label(screen, 'l', &text, + XGetWMName(screen->display, VShellWindow, &text)); + break; + + default: /* DECSLPP (24, 25, 36, 48, 72, 144) */ + if (param[0] >= 24) + RequestResize(termw, 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(int c, int fd) +{ + if (c >= 0x80 && c <= 0x9F) { + if (!term->screen.control_eight_bits) { + unparseputc(A2E(ESC), fd); + c = A2E(c - 0x40); + } + } + unparseputc(c, fd); +} + +void +unparseseq(ANSI * ap, int fd) +{ + int c; + int i; + int inters; + + unparseputc1(c = ap->a_type, fd); + if (c == ESC + || c == DCS + || c == CSI + || c == OSC + || c == PM + || c == APC + || c == SS3) { + if (ap->a_pintro != 0) + unparseputc(ap->a_pintro, fd); + for (i = 0; i < ap->a_nparam; ++i) { + if (i != 0) + unparseputc(';', fd); + unparseputn((unsigned int) ap->a_param[i], fd); + } + if ((inters = ap->a_inters) != 0) { + for (i = 3; i >= 0; --i) { + c = CharOf(inters >> (8 * i)); + if (c != 0) + unparseputc(c, fd); + } + } + unparseputc((char) ap->a_final, fd); + } +} + +static void +unparseputn(unsigned int n, int fd) +{ + unsigned int q; + + q = n / 10; + if (q != 0) + unparseputn(q, fd); + unparseputc((char) ('0' + (n % 10)), fd); +} + +void +unparseputc(int c, int fd) +{ + IChar buf[2]; + unsigned i = 1; + +#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 (term->screen.tc_query >= 0) { + char tmp[3]; + sprintf(tmp, "%02X", c & 0xFF); + buf[0] = tmp[0]; + buf[1] = tmp[1]; + i = 2; + } else +#endif + if ((buf[0] = c) == '\r' && (term->flags & LINEFEED)) { + buf[1] = '\n'; + i++; + } +#ifdef VMS + tt_write(&buf, i); +#else /* VMS */ + writePtyData(fd, buf, i); +#endif /* VMS */ + + /* If send/receive mode is reset, we echo characters locally */ + if ((term->keyboard.flags & MODE_SRM) == 0) { + (void) doparsing((unsigned) c, &myState); + } +} + +void +unparseputs(char *s, int fd) +{ + while (*s) + unparseputc(*s++, fd); +} + +void +ToggleAlternate(TScreen * screen) +{ + if (screen->alternate) + FromAlternate(screen); + else + ToAlternate(screen); +} + +static void +ToAlternate(TScreen * screen) +{ + if (screen->alternate) + return; + TRACE(("ToAlternate\n")); + if (!screen->altbuf) + screen->altbuf = Allocate(MaxRows(screen), MaxCols(screen), + &screen->abuf_address); + SwitchBufs(screen); + screen->alternate = True; + update_altscreen(); +} + +static void +FromAlternate(TScreen * screen) +{ + if (!screen->alternate) + return; + TRACE(("FromAlternate\n")); + if (screen->scroll_amt) + FlushScroll(screen); + screen->alternate = False; + SwitchBufs(screen); + update_altscreen(); +} + +static void +SwitchBufs(TScreen * screen) +{ + int rows, top; + + if (screen->cursor_state) + HideCursor(); + + rows = MaxRows(screen); + SwitchBufPtrs(screen); + + if ((top = -screen->topline) < rows) { + if (screen->scroll_amt) + FlushScroll(screen); + if (top == 0) + XClearWindow(screen->display, VWindow(screen)); + else + XClearArea(screen->display, + VWindow(screen), + (int) OriginX(screen), + (int) top * FontHeight(screen) + screen->border, + (unsigned) Width(screen), + (unsigned) (rows - top) * FontHeight(screen), + False); + } + ScrnUpdate(screen, 0, 0, rows, MaxCols(screen), False); +} + +/* swap buffer line pointers between alt and regular screens */ +void +SwitchBufPtrs(TScreen * screen) +{ + size_t len = ScrnPointers(screen, (unsigned) MaxRows(screen)); + + memcpy((char *) screen->save_ptr, (char *) screen->visbuf, len); + memcpy((char *) screen->visbuf, (char *) screen->altbuf, len); + memcpy((char *) screen->altbuf, (char *) screen->save_ptr, len); +} + +void +VTRun(void) +{ + TScreen *screen = &term->screen; + + TRACE(("VTRun ...\n")); + + if (!screen->Vshow) { + set_vt_visibility(True); + } + update_vttekmode(); + update_vtshow(); + update_tekshow(); + set_vthide_sensitivity(); + + if (screen->allbuf == NULL) + VTallocbuf(); + + 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(screen, VTbuffer, (char *) Tpushback, Tpushb - Tpushback); + Tpushb = Tpushback; + } +#endif + if (!setjmp(VTend)) + VTparse(); + StopBlinking(screen); + HideCursor(); + screen->cursor_set = OFF; +} + +/*ARGSUSED*/ +static void +VTExpose(Widget w GCC_UNUSED, + XEvent * event, + Region region GCC_UNUSED) +{ + TScreen *screen = &term->screen; + +#ifdef DEBUG + if (debug) + fputs("Expose\n", stderr); +#endif /* DEBUG */ + if (event->type == Expose) + HandleExposure(screen, event); +} + +static void +VTGraphicsOrNoExpose(XEvent * event) +{ + TScreen *screen = &term->screen; + if (screen->incopy <= 0) { + screen->incopy = 1; + if (screen->scrolls > 0) + screen->scrolls--; + } + if (event->type == GraphicsExpose) + if (HandleExposure(screen, 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)) { + ScreenResize(&term->screen, term->core.width, term->core.height, &term->flags); + } +} + +#define okDimension(src,dst) ((src <= 32767) && ((dst = src) == src)) + +static void +RequestResize(XtermWidget termw, int rows, int cols, int text) +{ +#ifndef nothack + XSizeHints sizehints; + long supp; +#endif + TScreen *screen = &termw->screen; + 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 ((askedWidth = cols) < cols + || (askedHeight = rows) < rows) + return; + + if (askedHeight == 0 + || askedWidth == 0 + || term->misc.limit_resize > 0) { + XGetWindowAttributes(XtDisplay(termw), + RootWindowOfScreen(XtScreen(termw)), &attrs); + } + + if (text) { + if ((value = rows) != 0) { + if (rows < 0) + value = MaxRows(screen); + value *= FontHeight(screen); + value += (2 * screen->border); + if (!okDimension(value, askedHeight)) + return; + } + + if ((value = cols) != 0) { + if (cols < 0) + value = MaxCols(screen); + value *= FontWidth(screen); + value += (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 = attrs.height; + if (cols == 0) + askedWidth = attrs.width; + + if (term->misc.limit_resize > 0) { + Dimension high = term->misc.limit_resize * attrs.height; + Dimension wide = term->misc.limit_resize * attrs.width; + if (high < attrs.height) + high = attrs.height; + if (askedHeight > high) + askedHeight = high; + if (wide < attrs.width) + wide = attrs.width; + if (askedWidth > wide) + askedWidth = wide; + } +#ifndef nothack + if (!XGetWMNormalHints(screen->display, VShellWindow, + &sizehints, &supp)) + bzero(&sizehints, sizeof(sizehints)); +#endif + + status = XtMakeResizeRequest((Widget) termw, + askedWidth, askedHeight, + &replyWidth, &replyHeight); + TRACE(("charproc.c XtMakeResizeRequest %dx%d -> %dx%d (status %d)\n", + askedHeight, askedWidth, + replyHeight, replyWidth, + status)); + + if (status == XtGeometryYes || + status == XtGeometryDone) { + ScreenResize(&termw->screen, + replyWidth, + replyHeight, + &termw->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 (sizehints.flags + && replyHeight + && replyWidth) { + sizehints.height = replyHeight; + sizehints.width = replyWidth; + + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_HINTS(&sizehints); + XSetWMNormalHints(screen->display, VShellWindow, &sizehints); + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_WM_HINTS(termw); + } +#endif + + XSync(screen->display, False); /* synchronize */ + if (XtAppPending(app_con)) + xevents(); +} + +static String xterm_trans = +"WM_PROTOCOLS: DeleteWindow()\n\ + : KeyboardMapping()\n"; + +int +VTInit(void) +{ + TScreen *screen = &term->screen; + Widget vtparent = SHELL_OF(term); + + 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) (term)); + + if (screen->allbuf == NULL) + VTallocbuf(); + return (1); +} + +static void +VTallocbuf(void) +{ + TScreen *screen = &term->screen; + int nrows = MaxRows(screen); + + /* allocate screen buffer now, if necessary. */ + if (screen->scrollWidget) + nrows += screen->savelines; + screen->allbuf = Allocate(nrows, MaxCols(screen), + &screen->sbuf_address); + if (screen->scrollWidget) + screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; + else + screen->visbuf = screen->allbuf; + return; +} + +static void +VTClassInit(void) +{ + XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity, + (XtConvertArgList) NULL, (Cardinal) 0); +} + +/* + * 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_Dres(name) \ + TRACE(("init " #name " = %f\n", \ + wnew->name = request->name)) +#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 : "")) +#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_Dres(name) wnew->name = request->name +#define init_Ires(name) wnew->name = request->name +#define init_Sres(name) wnew->name = x_strtrim(request->name) +#define init_Tres(offset) fill_Tres(wnew, request, offset) +#endif + +#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; + + target->screen.Tcolors[offset] = source->screen.Tcolors[offset]; + target->screen.Tcolors[offset].mode = False; + + if ((name = x_strtrim(target->screen.Tcolors[offset].resource)) != 0) + target->screen.Tcolors[offset].resource = name; + + if (name == 0) { + target->screen.Tcolors[offset].value = target->dft_foreground; + } else if (!x_strcasecmp(name, XtDefaultForeground)) { + target->screen.Tcolors[offset].value = + ((offset == TEXT_FG || offset == TEXT_BG) + ? target->dft_foreground + : target->screen.Tcolors[TEXT_FG].value); + } else if (!x_strcasecmp(name, XtDefaultBackground)) { + target->screen.Tcolors[offset].value = + ((offset == TEXT_FG || offset == TEXT_BG) + ? target->dft_background + : target->screen.Tcolors[TEXT_BG].value); + } else { + if (AllocateTermColor(target, &temp, offset, name)) { + target->screen.Tcolors[offset].value = temp.colors[offset]; + } + } + return target->screen.Tcolors[offset].value; +} +#else +#define fill_Tres(target, source, offset) \ + target->screen.Tcolors[offset] = source->screen.Tcolors[offset] +#endif + +#if OPT_WIDE_CHARS +static void +VTInitialize_locale(XtermWidget request) +{ + Bool is_utf8 = xtermEnvUTF8(); + + TRACE(("VTInitialize_locale\n")); + TRACE(("... request screen.utf8_mode = %d\n", request->screen.utf8_mode)); + + if (request->screen.utf8_mode < 0) + request->screen.utf8_mode = uFalse; + + if (request->screen.utf8_mode > 3) + request->screen.utf8_mode = uDefault; + + request->screen.latin9_mode = 0; + request->screen.unicode_font = 0; +#if OPT_LUIT_PROG + request->misc.callfilter = 0; + request->misc.use_encoding = 0; + + TRACE(("... setup for luit:\n")); + TRACE(("... request misc.locale_str = \"%s\"\n", request->misc.locale_str)); + + if (request->screen.utf8_mode == uFalse) { + TRACE(("... command-line +u8 overrides\n")); + } else +#if OPT_MINI_LUIT + if (x_strcasecmp(request->misc.locale_str, "CHECKFONT") == 0) { + int fl = (request->misc.default_font.f_n + ? strlen(request->misc.default_font.f_n) + : 0); + if (fl > 11 + && x_strcasecmp(request->misc.default_font.f_n + fl - 11, + "-ISO10646-1") == 0) { + request->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 (request->screen.utf8_mode == uDefault) + request->screen.utf8_mode = uFalse; + } else if (!strcmp(xtermEnvEncoding(), "ISO-8859-15")) { + if (request->screen.utf8_mode == uDefault) + request->screen.utf8_mode = uFalse; + request->screen.latin9_mode = 1; + } else { + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; + } +#else + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; +#endif + } else { + /* other encoding, use False */ + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } + } + } else +#endif /* OPT_MINI_LUIT */ + if (x_strcasecmp(request->misc.locale_str, "TRUE") == 0 || + x_strcasecmp(request->misc.locale_str, "ON") == 0 || + x_strcasecmp(request->misc.locale_str, "YES") == 0 || + x_strcasecmp(request->misc.locale_str, "AUTO") == 0 || + strcmp(request->misc.locale_str, "1") == 0) { + /* when true ... fully obeying LC_CTYPE locale */ + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; + } else if (x_strcasecmp(request->misc.locale_str, "FALSE") == 0 || + x_strcasecmp(request->misc.locale_str, "OFF") == 0 || + x_strcasecmp(request->misc.locale_str, "NO") == 0 || + strcmp(request->misc.locale_str, "0") == 0) { + /* when false ... original value of utf8_mode is effective */ + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } + } else if (x_strcasecmp(request->misc.locale_str, "MEDIUM") == 0 || + x_strcasecmp(request->misc.locale_str, "SEMIAUTO") == 0) { + /* when medium ... obeying locale only for UTF-8 and Asian */ + if (is_utf8) { + request->screen.utf8_mode = uAlways; + } else if ( +#ifdef MB_CUR_MAX + MB_CUR_MAX > 1 || +#else + !strncmp(xtermEnvLocale(), "ja", 2) || + !strncmp(xtermEnvLocale(), "ko", 2) || + !strncmp(xtermEnvLocale(), "zh", 2) || +#endif + !strncmp(xtermEnvLocale(), "th", 2) || + !strncmp(xtermEnvLocale(), "vi", 2)) { + request->misc.callfilter = 1; + request->screen.utf8_mode = uAlways; + } else { + request->screen.utf8_mode = uFalse; + } + } else if (x_strcasecmp(request->misc.locale_str, "UTF-8") == 0 || + x_strcasecmp(request->misc.locale_str, "UTF8") == 0) { + /* when UTF-8 ... UTF-8 mode */ + request->screen.utf8_mode = uAlways; + } else { + /* other words are regarded as encoding name passed to luit */ + request->misc.callfilter = 1; + request->screen.utf8_mode = uAlways; + request->misc.use_encoding = 1; + } + TRACE(("... updated misc.callfilter = %s\n", BtoS(request->misc.callfilter))); + TRACE(("... updated misc.use_encoding = %s\n", BtoS(request->misc.use_encoding))); +#else + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } +#endif /* OPT_LUIT_PROG */ + + request->screen.utf8_inparse = (request->screen.utf8_mode != uFalse); + + TRACE(("... updated screen.utf8_mode = %d\n", request->screen.utf8_mode)); + TRACE(("...VTInitialize_locale done\n")); +} +#endif + +/* ARGSUSED */ +static void +VTInitialize(Widget wrequest, + Widget new_arg, + ArgList args GCC_UNUSED, + Cardinal *num_args GCC_UNUSED) +{ + XtermWidget request = (XtermWidget) wrequest; + XtermWidget wnew = (XtermWidget) new_arg; + Widget my_parent = SHELL_OF(wnew); + int i; + char *s; + +#if OPT_ISO_COLORS + Bool color_ok; +#endif + +#if OPT_COLOR_RES2 && (MAXCOLORS > MIN_ANSI_COLORS) + 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\n")); + + /* 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. + */ + bzero((char *) &wnew->screen, sizeof(wnew->screen)); + + /* 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. + */ + wnew->screen.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(wnew->screen.display); + wnew->dft_background = MyBlackPixel(wnew->screen.display); + } else { + wnew->dft_foreground = MyBlackPixel(wnew->screen.display); + wnew->dft_background = MyWhitePixel(wnew->screen.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(&(wnew->screen), TEXT_FG))); + TRACE((" Screen background %#lx\n", T_COLOR(&(wnew->screen), TEXT_BG))); + + wnew->screen.mouse_button = -1; + wnew->screen.mouse_row = -1; + wnew->screen.mouse_col = -1; + +#if OPT_BOX_CHARS + init_Bres(screen.force_box_chars); + 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); + wnew->screen.cursor_blink_res = wnew->screen.cursor_blink; +#endif +#if OPT_BLINK_TEXT + init_Ires(screen.blink_as_bold); +#endif + init_Ires(screen.border); + init_Bres(screen.jumpscroll); + init_Bres(screen.old_fkeys); + init_Bres(screen.delete_is_del); + wnew->keyboard.type = wnew->screen.old_fkeys + ? keyboardIsLegacy + : keyboardIsDefault; +#ifdef ALLOWLOGGING + init_Sres(screen.logfile); +#endif + 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_Sres(screen.term_id); + for (s = request->screen.term_id; *s; s++) { + if (!isalpha(CharOf(*s))) + break; + } + wnew->screen.terminal_id = atoi(s); + if (wnew->screen.terminal_id < MIN_DECID) + wnew->screen.terminal_id = MIN_DECID; + if (wnew->screen.terminal_id > MAX_DECID) + wnew->screen.terminal_id = MAX_DECID; + TRACE(("term_id '%s' -> terminal_id %d\n", + wnew->screen.term_id, + wnew->screen.terminal_id)); + + wnew->screen.vtXX_level = (wnew->screen.terminal_id / 100); + 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_left = 0; + wnew->misc.alt_right = 0; + wnew->misc.meta_trans = False; + wnew->misc.meta_left = 0; + wnew->misc.meta_right = 0; +#endif +#if OPT_SHIFT_FONTS + init_Bres(misc.shift_fonts); +#endif +#if OPT_SUNPC_KBD + init_Ires(misc.ctrl_fkeys); +#endif +#if OPT_TEK4014 + init_Bres(misc.tekInhibit); + init_Bres(misc.tekSmall); + init_Bres(screen.TekEmu); +#endif +#if OPT_TCAP_QUERY + wnew->screen.tc_query = -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.cutNewline); + init_Bres(screen.cutToBeginningOfLine); + init_Bres(screen.highlight_selection); + init_Bres(screen.trim_selection); + init_Bres(screen.i18nSelections); + init_Bres(screen.brokenSelections); + init_Bres(screen.always_highlight); + wnew->screen.pointer_cursor = request->screen.pointer_cursor; + + 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_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.meta_sends_esc); + + init_Bres(screen.allowSendEvent0); + init_Bres(screen.allowWindowOp0); + + /* make a copy so that editres cannot change the resource after startup */ + wnew->screen.allowSendEvents = wnew->screen.allowSendEvent0; + wnew->screen.allowWindowOps = wnew->screen.allowWindowOp0; + +#ifndef NO_ACTIVE_ICON + wnew->screen.fnt_icon = request->screen.fnt_icon; + 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.titeInhibit); + init_Bres(misc.tiXtraScroll); + init_Bres(misc.dynamicColors); + for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) { + init_Sres(screen.MenuFontName(i)); + } + /* set default in realize proc */ + wnew->screen.MenuFontName(fontMenu_fontdefault) = NULL; + wnew->screen.MenuFontName(fontMenu_fontescape) = NULL; + wnew->screen.MenuFontName(fontMenu_fontsel) = NULL; + wnew->screen.menu_font_number = fontMenu_fontdefault; + +#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_DEC_CHRSET + init_Bres(screen.font_doublesize); + init_Ires(screen.cache_doublesize); + if (wnew->screen.cache_doublesize > NUM_CHRSET) + wnew->screen.cache_doublesize = NUM_CHRSET; + if (wnew->screen.cache_doublesize == 0) + wnew->screen.font_doublesize = False; + TRACE(("Doublesize%s enabled, up to %d fonts\n", + wnew->screen.font_doublesize ? "" : " not", + wnew->screen.cache_doublesize)); +#endif + +#if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS + wnew->num_ptrs = (OFF_ATTRS + 1); /* OFF_FLAGS, OFF_CHARS, OFF_ATTRS */ +#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); + + for (i = 0, color_ok = False; i < MAXCOLORS; i++) { + +#if OPT_COLOR_RES2 && (MAXCOLORS > MIN_ANSI_COLORS) + /* + * 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) { + wnew->screen.Acolors[i].resource + = ((char *) fake_resources[i - MIN_ANSI_COLORS].default_addr); + if (wnew->screen.Acolors[i].resource == 0) + wnew->screen.Acolors[i].resource = XtDefaultForeground; + } else +#endif /* OPT_COLOR_RES2 */ + wnew->screen.Acolors[i] = request->screen.Acolors[i]; + +#if OPT_COLOR_RES + TRACE(("Acolors[%d] = %s\n", i, wnew->screen.Acolors[i].resource)); + wnew->screen.Acolors[i].mode = False; + if (!x_strcasecmp(wnew->screen.Acolors[i].resource, XtDefaultForeground)) { + wnew->screen.Acolors[i].value = T_COLOR(&(wnew->screen), TEXT_FG); + wnew->screen.Acolors[i].mode = True; + } else if (!x_strcasecmp(wnew->screen.Acolors[i].resource, XtDefaultBackground)) { + wnew->screen.Acolors[i].value = T_COLOR(&(wnew->screen), TEXT_BG); + wnew->screen.Acolors[i].mode = True; + } else { + color_ok = True; + } +#else + TRACE(("Acolors[%d] = %#lx\n", i, request->screen.Acolors[i])); + if (wnew->screen.Acolors[i] != wnew->dft_foreground && + wnew->screen.Acolors[i] != T_COLOR(&(wnew->screen), TEXT_FG) && + wnew->screen.Acolors[i] != T_COLOR(&(wnew->screen), 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 = wnew->screen.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) { + wnew->screen.colorMode = False; + TRACE(("All colors are foreground or background: disable colorMode\n")); + } +#if OPT_EXT_COLORS + wnew->num_ptrs = (OFF_BGRND + 1); +#else + wnew->num_ptrs = (OFF_COLOR + 1); +#endif + wnew->sgr_foreground = -1; + wnew->sgr_background = -1; + wnew->sgr_extended = 0; +#endif /* OPT_ISO_COLORS */ + + init_Tres(MOUSE_FG); + init_Tres(MOUSE_BG); + init_Tres(TEXT_CURSOR); +#if OPT_HIGHLIGHT_COLOR + init_Tres(HIGHLIGHT_BG); +#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. + */ + T_COLOR(&(wnew->screen), TEK_BG) = T_COLOR(&(wnew->screen), TEXT_BG); + T_COLOR(&(wnew->screen), TEK_FG) = T_COLOR(&(wnew->screen), TEXT_FG); + T_COLOR(&(wnew->screen), TEK_CURSOR) = T_COLOR(&(wnew->screen), TEXT_CURSOR); +#endif + +#if OPT_DEC_CHRSET + wnew->num_ptrs = (OFF_CSETS + 1); +#endif + +#if OPT_WIDE_CHARS + VTInitialize_locale(request); + +#if OPT_LUIT_PROG + init_Bres(misc.callfilter); + init_Bres(misc.use_encoding); + init_Sres(misc.locale_str); + init_Sres(misc.localefilter); +#endif + +#if OPT_RENDERFONT + init_Dres(misc.face_size); + init_Sres(misc.face_name); + init_Sres(misc.face_wide_name); + init_Bres(misc.render_font); + /* minor tweak to make debug traces consistent: */ + if (wnew->misc.render_font) { + if (wnew->misc.face_name == 0) { + wnew->misc.render_font = False; + TRACE(("reset render_font since there is no face_name\n")); + } + } +#endif + + init_Bres(screen.vt100_graphics); + init_Ires(screen.utf8_mode); + init_Bres(screen.wide_chars); + init_Bres(misc.mk_width); + init_Bres(misc.cjk_width); + if (request->screen.utf8_mode) { + TRACE(("setting wide_chars on\n")); + wnew->screen.wide_chars = True; + } else { + TRACE(("setting utf8_mode to 0\n")); + wnew->screen.utf8_mode = uFalse; + } + TRACE(("initialized UTF-8 mode to %d\n", wnew->screen.utf8_mode)); + +#if OPT_MINI_LUIT + if (request->screen.latin9_mode) { + wnew->screen.latin9_mode = True; + } + if (request->screen.unicode_font) { + wnew->screen.unicode_font = True; + } + TRACE(("initialized Latin9 mode to %d\n", wnew->screen.latin9_mode)); + TRACE(("initialized unicode_font to %d\n", wnew->screen.unicode_font)); +#endif + + if (wnew->screen.wide_chars != False) + wnew->num_ptrs = (OFF_COM2H + 1); + + decode_wcwidth((wnew->misc.cjk_width ? 2 : 0) + + (wnew->misc.mk_width ? 1 : 0) + + 1); +#endif /* OPT_WIDE_CHARS */ + + init_Bres(screen.bold_mode); + init_Bres(screen.underline); + + wnew->cur_foreground = 0; + wnew->cur_background = 0; + + wnew->keyboard.flags = MODE_SRM; + if (wnew->screen.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. + */ + 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 (zIconBeep) +#endif + XtAddEventHandler(my_parent, StructureNotifyMask, False, + HandleStructNotify, (Opaque) 0); +#endif /* HANDLE_STRUCT_NOTIFY */ + + wnew->screen.bellInProgress = False; + + set_character_class(wnew->screen.charClass); + + /* create it, but don't realize it */ + ScrollBarOn(wnew, True, False); + + /* make sure that the resize gravity acceptable */ + if (wnew->misc.resizeGravity != NorthWestGravity && + wnew->misc.resizeGravity != SouthWestGravity) { + Cardinal nparams = 1; + + XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError", + "unsupported resizeGravity resource value (%d)", + (String *) & (wnew->misc.resizeGravity), &nparams); + wnew->misc.resizeGravity = SouthWestGravity; + } +#ifndef NO_ACTIVE_ICON + wnew->screen.whichVwin = &wnew->screen.fullVwin; +#if OPT_TEK4014 + wnew->screen.whichTwin = &wnew->screen.fullTwin; +#endif +#endif /* NO_ACTIVE_ICON */ + + if (wnew->screen.savelines < 0) + wnew->screen.savelines = 0; + + init_Bres(screen.awaitInput); + + wnew->flags = 0; + if (!wnew->screen.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 (wnew->screen.c132) + wnew->flags |= IN132COLUMNS; + + wnew->initflags = wnew->flags; + + init_Ires(keyboard.modify_cursor_keys); + + 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; + + return; +} + +static void +VTDestroy(Widget w) +{ + XtFree((char *) (((XtermWidget) w)->screen.selection_data)); +} + +/*ARGSUSED*/ +static void +VTRealize(Widget w, + XtValueMask * valuemask, + XSetWindowAttributes * values) +{ + XtermWidget xw = (XtermWidget) w; + TScreen *screen = &xw->screen; + + unsigned width, height; + int xpos, ypos, pr; + XSizeHints sizehints; + Atom pid_atom; + + TRACE(("VTRealize\n")); + + TabReset(xw->tabs); + + screen->MenuFontName(fontMenu_fontdefault) = xw->misc.default_font.f_n; + screen->fnt_norm = NULL; + screen->fnt_bold = NULL; +#if OPT_WIDE_CHARS + screen->fnt_dwd = NULL; + screen->fnt_dwdb = NULL; +#endif + if (!xtermLoadFont(xw, + &(xw->misc.default_font), + False, 0)) { + if (XmuCompareISOLatin1(xw->misc.default_font.f_n, "fixed") != 0) { + fprintf(stderr, + "%s: unable to open font \"%s\", trying \"fixed\"....\n", + xterm_name, xw->misc.default_font.f_n); + (void) xtermLoadFont(xw, + xtermFontName("fixed"), + False, 0); + screen->MenuFontName(fontMenu_fontdefault) = "fixed"; + } + } + + /* really screwed if we couldn't open default font */ + if (!screen->fnt_norm) { + fprintf(stderr, "%s: unable to locate a suitable font\n", + xterm_name); + Exit(1); + } +#if OPT_WIDE_CHARS + if (xw->screen.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->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)) + - width - (BorderWidth(XtParent(xw)) * 2); + } + if ((pr & YValue) && (YNegative & pr)) { + ypos += DisplayHeight(screen->display, DefaultScreen(screen->display)) + - height - (BorderWidth(XtParent(xw)) * 2); + } + + /* set up size hints for window manager; min 1 char by 1 char */ + bzero(&sizehints, sizeof(sizehints)); + xtermSizeHints(xw, &sizehints, (xw->misc.scrollbar + ? (screen->scrollWidget->core.width + + BorderWidth(screen->scrollWidget)) + : 0)); + + sizehints.x = xpos; + sizehints.y = ypos; + if ((XValue & pr) || (YValue & pr)) { + sizehints.flags |= USSize | USPosition; + sizehints.flags |= PWinGravity; + switch (pr & (XNegative | YNegative)) { + case 0: + sizehints.win_gravity = NorthWestGravity; + break; + case XNegative: + sizehints.win_gravity = NorthEastGravity; + break; + case YNegative: + sizehints.win_gravity = SouthWestGravity; + break; + default: + sizehints.win_gravity = SouthEastGravity; + break; + } + } else { + /* set a default size, but do *not* set position */ + sizehints.flags |= PSize; + } + sizehints.height = sizehints.base_height + + sizehints.height_inc * MaxRows(screen); + sizehints.width = sizehints.base_width + + sizehints.width_inc * MaxCols(screen); + + if ((WidthValue & pr) || (HeightValue & pr)) + sizehints.flags |= USSize; + else + sizehints.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. + */ + TRACE(("make resize request %dx%d\n", height, width)); + (void) XtMakeResizeRequest((Widget) xw, + (Dimension) width, (Dimension) height, + &xw->core.width, &xw->core.height); + TRACE(("...made resize request %dx%d\n", xw->core.height, xw->core.width)); + + /* 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 (sizehints.flags & USPosition) + XMoveWindow(XtDisplay(xw), XtWindow(SHELL_OF(xw)), + sizehints.x, sizehints.y); + + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_HINTS(&sizehints); + XSetWMNormalHints(XtDisplay(xw), XtWindow(SHELL_OF(xw)), &sizehints); + 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, + 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 = ((xw->misc.resizeGravity == NorthWestGravity) + ? NorthWestGravity + : ForgetGravity); + xw->screen.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 + if (xw->misc.active_icon && screen->fnt_icon) { + int iconX = 0, iconY = 0; + Widget shell = SHELL_OF(xw); + unsigned long mask; + XGCValues xgcv; + + TRACE(("Initializing active-icon\n")); + XtVaGetValues(shell, XtNiconX, &iconX, XtNiconY, &iconY, (XtPointer) 0); + xtermComputeFontInfo(xw, &(screen->iconVwin), screen->fnt_icon, 0); + + /* 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); + + mask = (GCFont | GCForeground | GCBackground | + GCGraphicsExposures | GCFunction); + + xgcv.font = screen->fnt_icon->fid; + xgcv.foreground = T_COLOR(screen, TEXT_FG); + xgcv.background = T_COLOR(screen, TEXT_BG); + xgcv.graphics_exposures = True; /* default */ + xgcv.function = GXcopy; + + screen->iconVwin.normalGC = + screen->iconVwin.normalboldGC = + XtGetGC(shell, mask, &xgcv); + + xgcv.foreground = T_COLOR(screen, TEXT_BG); + xgcv.background = T_COLOR(screen, TEXT_FG); + + screen->iconVwin.reverseGC = + screen->iconVwin.reverseboldGC = + XtGetGC(shell, mask, &xgcv); +#if OPT_TOOLBAR + /* + * Toolbar is initialized before we get here. Enable the menu item + * and set it properly. + */ + set_sensitivity(mw, + 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(); +#else + xw->screen.xic = NULL; +#endif +#if OPT_NUM_LOCK + VTInitModifiers(); +#endif + + set_cursor_gcs(screen); + + /* Reset variables used by ANSI emulation. */ + + resetCharsets(screen); + + XDefineCursor(screen->display, VShellWindow, 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 = screen->allbuf = NULL; + + screen->do_wrap = 0; + screen->scrolls = screen->incopy = 0; + xtermSetCursorBox(screen); + + screen->savedlines = 0; + + if (xw->misc.scrollbar) { + screen->fullVwin.sb_info.width = 0; + ScrollBarOn(xw, False, True); + } + CursorSave(xw); + 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(); +} + +static void +xim_destroy_cb(XIM im GCC_UNUSED, + XPointer client_data GCC_UNUSED, + XPointer call_data GCC_UNUSED) +{ + term->screen.xic = NULL; + + XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL, + xim_instantiate_cb, NULL); +} +#endif /* X11R6+ */ + +static void +xim_real_init(void) +{ + unsigned i, j; + char *p, *s, *t, *ns, *end, buf[32]; + XIMStyles *xim_styles; + XIMStyle input_style = 0; + Bool found; + static struct { + char *name; + unsigned long code; + } known_style[] = { + { + "OverTheSpot", (XIMPreeditPosition | XIMStatusNothing) + }, + { + "OffTheSpot", (XIMPreeditArea | XIMStatusArea) + }, + { + "Root", (XIMPreeditNothing | XIMStatusNothing) + }, + }; + + term->screen.xic = NULL; + + if (term->misc.cannot_im) { + return; + } + + if (!term->misc.input_method || !*term->misc.input_method) { + if ((p = XSetLocaleModifiers("")) != NULL && *p) + term->screen.xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); + } else { + s = term->misc.input_method; + i = 5 + strlen(s); + t = (char *) MyStackAlloc(i, buf); + if (t == NULL) + SysError(ERROR_VINIT); + + 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, (unsigned) (end - s)); + + if ((p = XSetLocaleModifiers(t)) != 0 && *p + && (term->screen.xim = XOpenIM(XtDisplay(term), + NULL, + NULL, + NULL)) != 0) + break; + + } + s = ns + 1; + } + MyStackFree(t, buf); + } + + if (term->screen.xim == NULL + && (p = XSetLocaleModifiers("@im=none")) != NULL + && *p) { + term->screen.xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); + } + + if (!term->screen.xim) { + fprintf(stderr, "Failed to open input method\n"); + return; + } + TRACE(("VTInitI18N opened input method\n")); + + if (XGetIMValues(term->screen.xim, XNQueryInputStyle, &xim_styles, NULL) + || !xim_styles + || !xim_styles->count_styles) { + fprintf(stderr, "input method doesn't support any style\n"); + XCloseIM(term->screen.xim); + term->misc.cannot_im = True; + return; + } + + found = False; + for (s = term->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", 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, (unsigned) (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", + term->misc.preedit_type); + XCloseIM(term->screen.xim); + term->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"); + XCloseIM(term->screen.xim); + term->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; + + term->screen.fs = XCreateFontSet(XtDisplay(term), + term->misc.f_x, + &missing_charset_list, + &missing_charset_count, + &def_string); + if (term->screen.fs == NULL) { + fprintf(stderr, "Preparation of font set " + "\"%s\" for XIM failed.\n", term->misc.f_x); + term->screen.fs = XCreateFontSet(XtDisplay(term), + DEFXIMFONT, + &missing_charset_list, + &missing_charset_count, + &def_string); + } + if (term->screen.fs == NULL) { + fprintf(stderr, "Preparation of default font set " + "\"%s\" for XIM failed.\n", DEFXIMFONT); + XCloseIM(term->screen.xim); + term->misc.cannot_im = True; + return; + } + (void) XExtentsOfFontSet(term->screen.fs); + j = XFontsOfFontSet(term->screen.fs, &fonts, &font_name_list); + for (i = 0, term->screen.fs_ascent = 0; i < j; i++) { + if (term->screen.fs_ascent < (*fonts)->ascent) + term->screen.fs_ascent = (*fonts)->ascent; + } + p_list = XVaCreateNestedList(0, + XNSpotLocation, &spot, + XNFontSet, term->screen.fs, + NULL); + term->screen.xic = XCreateIC(term->screen.xim, + XNInputStyle, input_style, + XNClientWindow, XtWindow(term), + XNFocusWindow, XtWindow(term), + XNPreeditAttributes, p_list, + NULL); + } else { + term->screen.xic = XCreateIC(term->screen.xim, XNInputStyle, input_style, + XNClientWindow, XtWindow(term), + XNFocusWindow, XtWindow(term), + NULL); + } + + if (!term->screen.xic) { + fprintf(stderr, "Failed to create input context\n"); + XCloseIM(term->screen.xim); + } +#if defined(USE_XIM_INSTANTIATE_CB) + else { + XIMCallback destroy_cb; + + destroy_cb.callback = xim_destroy_cb; + destroy_cb.client_data = NULL; + if (XSetIMValues(term->screen.xim, XNDestroyCallback, &destroy_cb, NULL)) + fprintf(stderr, "Could not set destroy callback to IM\n"); + } +#endif + + return; +} + +static void +VTInitI18N(void) +{ + if (term->misc.open_im) { + xim_real_init(); + +#if defined(USE_XIM_INSTANTIATE_CB) + if (term->screen.xic == NULL && !term->misc.cannot_im) { + sleep(3); + XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL, + xim_instantiate_cb, NULL); + } +#endif + } +} +#endif /* OPT_I18N_SUPPORT && OPT_INPUT_METHOD */ + +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; + Bool refresh_needed = False; + Bool fonts_redone = False; + + if ((T_COLOR(&(curvt->screen), TEXT_BG) != + T_COLOR(&(newvt->screen), TEXT_BG)) || + (T_COLOR(&(curvt->screen), TEXT_FG) != + T_COLOR(&(newvt->screen), TEXT_FG)) || + (curvt->screen.MenuFontName(curvt->screen.menu_font_number) != + newvt->screen.MenuFontName(newvt->screen.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) + newvt->screen.MenuFontName(fontMenu_fontdefault) = newvt->misc.default_font.f_n; + if (xtermLoadFont(newvt, + xtermFontName(newvt->screen.MenuFontName(curvt->screen.menu_font_number)), + True, newvt->screen.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) + newvt->screen.MenuFontName(fontMenu_fontdefault) = curvt->misc.default_font.f_n; + } + if (!fonts_redone + && (T_COLOR(&(curvt->screen), TEXT_CURSOR) != + T_COLOR(&(newvt->screen), TEXT_CURSOR))) { + set_cursor_gcs(&newvt->screen); + refresh_needed = True; + } + if (curvt->misc.re_verse != newvt->misc.re_verse) { + newvt->flags ^= REVERSE_VIDEO; + ReverseVideo(newvt); + newvt->misc.re_verse = !newvt->misc.re_verse; /* ReverseVideo toggles */ + refresh_needed = True; + } + if ((T_COLOR(&(curvt->screen), MOUSE_FG) != + T_COLOR(&(newvt->screen), MOUSE_FG)) || + (T_COLOR(&(curvt->screen), MOUSE_BG) != + T_COLOR(&(newvt->screen), MOUSE_BG))) { + recolor_cursor(newvt->screen.pointer_cursor, + T_COLOR(&(newvt->screen), MOUSE_FG), + T_COLOR(&(newvt->screen), MOUSE_BG)); + refresh_needed = True; + } + if (curvt->misc.scrollbar != newvt->misc.scrollbar) { + ToggleScrollBar(newvt); + } + + return refresh_needed; +} + +#define setGC(value) set_at = __LINE__, currentGC = value + +#define OutsideSelection(screen,row,col) \ + ((row) > (screen)->endHRow || \ + ((row) == (screen)->endHRow && \ + (col) >= (screen)->endHCol) || \ + (row) < (screen)->startHRow || \ + ((row) == (screen)->startHRow && \ + (col) < (screen)->startHCol)) + +/* + * Shows cursor at new cursor position in screen. + */ +void +ShowCursor(void) +{ + TScreen *screen = &term->screen; + int x, y; + Char clo; + unsigned flags; + unsigned fg_bg = 0; + GC currentGC; + int set_at; + Bool in_selection; + Bool reversed; + Pixel fg_pix; + Pixel bg_pix; + Pixel tmp; +#if OPT_HIGHLIGHT_COLOR + Pixel hi_pix = T_COLOR(screen, HIGHLIGHT_BG); +#endif +#if OPT_WIDE_CHARS + Char chi = 0; + Char c1h = 0; + Char c1l = 0; + Char c2h = 0; + Char c2l = 0; + int base; +#endif + int cursor_col; + + if (screen->cursor_state == BLINKED_OFF) + return; + + if (eventMode != NORMAL) + return; + + if (screen->cur_row - screen->topline > screen->max_row) + return; + + screen->cursor_row = screen->cur_row; + cursor_col = screen->cursor_col = screen->cur_col; + screen->cursor_moved = False; + +#ifndef NO_ACTIVE_ICON + if (IsIcon(screen)) { + screen->cursor_state = ON; + return; + } +#endif /* NO_ACTIVE_ICON */ + +#if OPT_WIDE_CHARS + base = +#endif + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + + if_OPT_WIDE_CHARS(screen, { + int my_col; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + if (clo == HIDDEN_LO && chi == HIDDEN_HI && cursor_col > 0) { + /* if cursor points to non-initial part of wide character, + * back it up + */ + --cursor_col; + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + } + my_col = cursor_col; + base = (chi << 8) | clo; + if (iswide(base)) + my_col += 1; + c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col]; + c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col]; + c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col]; + c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col]; + }); + + flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[cursor_col]; + + if (clo == 0 +#if OPT_WIDE_CHARS + && chi == 0 +#endif + ) { + clo = ' '; + } + + /* + * 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 OPT_ISO_COLORS + if ((flags & TERM_COLOR_FLAGS(term)) == BG_COLOR +#if OPT_WIDE_CHARS + && chi == 0 +#endif + && clo == ' ') { + flags &= ~TERM_COLOR_FLAGS(term); + } +#endif + + /* + * Compare the current cell to the last set of colors used for the + * cursor and update the GC's if needed. + */ + if_OPT_EXT_COLORS(screen, { + fg_bg = (SCRN_BUF_FGRND(screen, screen->cursor_row)[cursor_col] << 8) + | (SCRN_BUF_BGRND(screen, screen->cursor_row)[cursor_col]); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fg_bg = SCRN_BUF_COLOR(screen, screen->cursor_row)[cursor_col]; + }); + fg_pix = getXtermForeground(flags, extract_fg(fg_bg, flags)); + bg_pix = getXtermBackground(flags, extract_bg(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. + */ + if (screen->select || screen->always_highlight) { + if (reversed) { /* text is reverse video */ + if (screen->cursorGC) { + setGC(screen->cursorGC); + } else { + if (flags & BOLDATTR(screen)) { + setGC(NormalBoldGC(screen)); + } else { + setGC(NormalGC(screen)); + } + } +#if OPT_HIGHLIGHT_COLOR + if (hi_pix != T_COLOR(screen, TEXT_FG) + && hi_pix != fg_pix + && hi_pix != bg_pix + && hi_pix != term->dft_foreground) { + bg_pix = fg_pix; + fg_pix = hi_pix; + } +#endif + EXCHANGE(fg_pix, bg_pix, tmp); + } else { /* normal video */ + if (screen->reversecursorGC) { + setGC(screen->reversecursorGC); + } else { + if (flags & BOLDATTR(screen)) { + setGC(ReverseBoldGC(screen)); + } else { + setGC(ReverseGC(screen)); + } + } + } + if (T_COLOR(screen, TEXT_CURSOR) == term->dft_foreground) { + XSetBackground(screen->display, currentGC, fg_pix); + } + XSetForeground(screen->display, currentGC, bg_pix); + } else { /* not selected */ + if (reversed) { /* text is reverse video */ +#if OPT_HIGHLIGHT_COLOR + if (hi_pix != T_COLOR(screen, TEXT_FG) + && hi_pix != fg_pix + && hi_pix != bg_pix + && hi_pix != term->dft_foreground) { + bg_pix = fg_pix; + fg_pix = hi_pix; + } +#endif + setGC(ReverseGC(screen)); + XSetForeground(screen->display, currentGC, bg_pix); + XSetBackground(screen->display, currentGC, fg_pix); + } else { /* normal video */ + setGC(NormalGC(screen)); + XSetForeground(screen->display, currentGC, fg_pix); + XSetBackground(screen->display, currentGC, 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)\n", + screen->cur_row, screen->cur_col)); + + drawXtermText(screen, flags & DRAWX_MASK, currentGC, + x = CurCursorX(screen, screen->cur_row, cursor_col), + y = CursorY(screen, screen->cur_row), + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&clo, &chi), 1, 0); + +#if OPT_WIDE_CHARS + if (c1l || c1h) { + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c1l, &c1h), 1, iswide(base)); + + if (c2l || c2h) + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c2l, &c2h), 1, iswide(base)); + } +#endif + + if (!screen->select && !screen->always_highlight) { + screen->box->x = x; + screen->box->y = y; + XDrawLines(screen->display, VWindow(screen), + screen->cursoroutlineGC ? screen->cursoroutlineGC + : currentGC, + screen->box, NBOX, CoordModePrevious); + } + } + screen->cursor_state = ON; +} + +/* + * hide cursor at previous cursor position in screen. + */ +void +HideCursor(void) +{ + TScreen *screen = &term->screen; + GC currentGC; + unsigned flags; + unsigned fg_bg = 0; + int x, y; + Char clo; + Bool in_selection; +#if OPT_WIDE_CHARS + Char chi = 0; + Char c1h = 0; + Char c1l = 0; + Char c2h = 0; + Char c2l = 0; + int base; +#endif + int cursor_col; + + if (screen->cursor_state == OFF) /* FIXME */ + return; + if (screen->cursor_row - screen->topline > screen->max_row) + return; + + cursor_col = screen->cursor_col; + +#ifndef NO_ACTIVE_ICON + if (IsIcon(screen)) { + screen->cursor_state = OFF; + return; + } +#endif /* NO_ACTIVE_ICON */ + +#if OPT_WIDE_CHARS + base = +#endif + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[cursor_col]; + + if_OPT_WIDE_CHARS(screen, { + int my_col; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + if (clo == HIDDEN_LO && chi == HIDDEN_HI) { + /* if cursor points to non-initial part of wide character, + * back it up + */ + --cursor_col; + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + } + my_col = cursor_col; + base = (chi << 8) | clo; + if (iswide(base)) + my_col += 1; + c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col]; + c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col]; + c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col]; + c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col]; + }); + + if_OPT_EXT_COLORS(screen, { + fg_bg = (SCRN_BUF_FGRND(screen, screen->cursor_row)[cursor_col] << 8) + | (SCRN_BUF_BGRND(screen, screen->cursor_row)[cursor_col]); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fg_bg = SCRN_BUF_COLOR(screen, screen->cursor_row)[cursor_col]; + }); + + if (OutsideSelection(screen, screen->cursor_row, screen->cursor_col)) + in_selection = False; + else + in_selection = True; + + currentGC = updatedXtermGC(screen, flags, fg_bg, in_selection); + + if (clo == 0 +#if OPT_WIDE_CHARS + && chi == 0 +#endif + ) { + clo = ' '; + } + + TRACE(("HideCursor calling drawXtermText cur(%d,%d)\n", + screen->cursor_row, screen->cursor_col)); + drawXtermText(screen, flags & DRAWX_MASK, currentGC, + x = CurCursorX(screen, screen->cursor_row, cursor_col), + y = CursorY(screen, screen->cursor_row), + curXtermChrSet(screen->cursor_row), + PAIRED_CHARS(&clo, &chi), 1, 0); + +#if OPT_WIDE_CHARS + if (c1l || c1h) { + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c1l, &c1h), 1, iswide(base)); + + if (c2l || c2h) + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c2l, &c2h), 1, iswide(base)); + } +#endif + screen->cursor_state = OFF; + resetXtermGC(screen, flags, in_selection); +} + +#if OPT_BLINK_CURS || OPT_BLINK_TEXT +static void +StartBlinking(TScreen * screen) +{ + if (screen->blink_timer == 0) { + unsigned long interval = (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 +ScrnHasBlinking(TScreen * screen, int row) +{ + Char *attrs = SCRN_BUF_ATTRS(screen, row); + int col; + Bool result = False; + + for (col = 0; col < MaxCols(screen); ++col) { + if (attrs[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 line 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--) { + if (ScrnTstBlinked(screen, row)) { + if (ScrnHasBlinking(screen, row)) { + resume = True; + if (row > last_row) + last_row = row; + if (row < first_row) + first_row = row; + } else { + ScrnClrBlinked(screen, row); + } + } + } + /* + * FIXME: this could be a little more efficient, e.g,. by limiting the + * columns which are updated. + */ + if (first_row <= last_row) { + ScrnRefresh(screen, + 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 */ + +/* + * 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(Bool full, Bool saved) +{ + TScreen *screen = &term->screen; + + if (!XtIsRealized((Widget) term)) { + Bell(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(&term->flags, ORIGIN); + + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + + /* Reset character-sets to initial state */ + resetCharsets(screen); + + /* Reset DECSCA */ + bitclr(&term->flags, PROTECTED); + screen->protected_mode = OFF_PROTECT; + + if (full) { /* RIS */ + if (screen->bellOnReset) + Bell(XkbBI_TerminalBell, 0); + + /* reset the mouse mode */ + screen->send_mouse_pos = MOUSE_OFF; + waitingForTrackInfo = False; + eventMode = NORMAL; + + TabReset(term->tabs); + term->keyboard.flags = MODE_SRM; +#if OPT_INITIAL_ERASE + if (term->keyboard.reset_DECBKM == 1) + term->keyboard.flags |= MODE_DECBKM; + else if (term->keyboard.reset_DECBKM == 2) +#endif + if (term->screen.backarrow_key) + term->keyboard.flags |= MODE_DECBKM; + TRACE(("full reset DECBKM %s\n", + BtoS(term->keyboard.flags & MODE_DECBKM))); + update_appcursor(); + update_appkeypad(); + update_decbkm(); + show_8bit_control(False); + reset_decudk(); + + FromAlternate(screen); + ClearScreen(screen); + screen->cursor_state = OFF; + if (term->flags & REVERSE_VIDEO) + ReverseVideo(term); + + term->flags = term->initflags; + update_reversevideo(); + update_autowrap(); + update_reversewrap(); + update_autolinefeed(); + + screen->jumpscroll = !(term->flags & SMOOTHSCROLL); + update_jumpscroll(); + + if (screen->c132 && (term->flags & IN132COLUMNS)) { + Dimension reqWidth = (80 * FontWidth(screen) + + 2 * screen->border + ScrollbarWidth(screen)); + Dimension reqHeight = (FontHeight(screen) + * MaxRows(screen) + 2 * screen->border); + Dimension replyWidth; + Dimension replyHeight; + + TRACE(("Making resize-request to restore 80-columns %dx%d\n", + reqHeight, reqWidth)); + XtMakeResizeRequest((Widget) term, + reqWidth, + reqHeight, + &replyWidth, &replyHeight); + TRACE(("...result %dx%d\n", replyHeight, replyWidth)); + repairSizeHints(); + XSync(screen->display, False); /* synchronize */ + if (XtAppPending(app_con)) + xevents(); + } + + CursorSet(screen, 0, 0, term->flags); + CursorSave(term); + } else { /* DECSTR */ + /* + * There's a tiny difference, to accommodate usage of xterm. + * We reset autowrap to the resource values rather than turning + * it off. + */ + term->keyboard.flags &= ~(MODE_DECCKM | MODE_KAM | MODE_DECKPAM); + bitcpy(&term->flags, term->initflags, WRAPAROUND | REVERSEWRAP); + bitclr(&term->flags, INSERT | INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE); + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + update_appcursor(); + update_autowrap(); + update_reversewrap(); + + CursorSave(term); + screen->sc[screen->alternate != False].row = + screen->sc[screen->alternate != False].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 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 = strlen(s), acc = 0, numbers = digits = 0; + i < len; i++) { + Char c = 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); + + (void) sprintf(pmapName, "%sKeymap", params[0]); + (void) strcpy(pmapClass, pmapName); + if (islower(CharOf(pmapClass[0]))) + pmapClass[0] = toupper(CharOf(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(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) +{ + /* do nothing, but check for funny escape sequences */ + (void) SendMousePosition(w, event); +} + +/* ARGSUSED */ +static void +DoSetSelectedFont(Widget w GCC_UNUSED, + XtPointer client_data GCC_UNUSED, + Atom * selection GCC_UNUSED, + Atom * type, + XtPointer value, + unsigned long *length GCC_UNUSED, + int *format) +{ + char *val = (char *) value; + int len; + if (*type != XA_STRING || *format != 8) { + Bell(XkbBI_MinorError, 0); + return; + } + len = strlen(val); + if (len > 0) { + if (val[len - 1] == '\n') + val[len - 1] = '\0'; + /* 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(val, '\n')) + return; + if (!xtermLoadFont(term, + xtermFontName(val), + True, + fontMenu_fontsel)) + Bell(XkbBI_MinorError, 0); + } +} + +void +FindFontSelection(char *atom_name, Bool justprobe) +{ + static AtomPtr *atoms; + static int atomCount = 0; + AtomPtr *pAtom; + int a; + Atom target; + + if (!atom_name) + atom_name = "PRIMARY"; + + for (pAtom = atoms, a = atomCount; a; a--, pAtom++) { + if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) + break; + } + if (!a) { + atoms = (AtomPtr *) XtRealloc((char *) atoms, + sizeof(AtomPtr) * (atomCount + 1)); + *(pAtom = &atoms[atomCount++]) = XmuMakeAtom(atom_name); + } + + target = XmuInternAtom(XtDisplay(term), *pAtom); + if (justprobe) { + term->screen.MenuFontName(fontMenu_fontsel) = + XGetSelectionOwner(XtDisplay(term), target) ? _Font_Selected_ : 0; + } else { + XtGetSelectionValue((Widget) term, target, XA_STRING, + DoSetSelectedFont, NULL, + XtLastTimestampProcessed(XtDisplay(term))); + } + return; +} + +void +set_cursor_gcs(TScreen * screen) +{ + XGCValues xgcv; + XtGCMask mask; + Pixel cc = T_COLOR(screen, TEXT_CURSOR); + Pixel fg = T_COLOR(screen, TEXT_FG); + Pixel bg = T_COLOR(screen, TEXT_BG); + GC new_cursorGC = NULL; + GC new_cursorFillGC = NULL; + GC new_reversecursorGC = NULL; + GC new_cursoroutlineGC = NULL; + + /* + * Let's see, there are three things that have "color": + * + * background + * text + * cursorblock + * + * And, there are four situation 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. + */ + +#if OPT_ISO_COLORS + /* + * If we're using ANSI colors, the functions manipulating the SGR code will + * use the same GC's. To avoid having the cursor change color, we use the + * Xlib calls rather than the Xt calls. + * + * Use the colorMode value to determine which we'll do (the VWindow may + * not be set before the widget's realized, so it's tested separately). + */ + if (screen->colorMode) { + if (VWindow(screen) != 0 && (cc != bg) && (cc != fg)) { + /* we might have a colored foreground/background later */ + xgcv.font = screen->fnt_norm->fid; + mask = (GCForeground | GCBackground | GCFont); + xgcv.foreground = fg; + xgcv.background = cc; + new_cursorGC = XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + + xgcv.foreground = cc; + xgcv.background = fg; + new_cursorFillGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + + if (screen->always_highlight) { + new_reversecursorGC = (GC) 0; + new_cursoroutlineGC = (GC) 0; + } else { + xgcv.foreground = bg; + xgcv.background = cc; + new_reversecursorGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + xgcv.foreground = cc; + xgcv.background = bg; + new_cursoroutlineGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + } + } + } else +#endif + if (cc != fg && cc != bg) { + /* we have a colored cursor */ + xgcv.font = screen->fnt_norm->fid; + mask = (GCForeground | GCBackground | GCFont); + + xgcv.foreground = fg; + xgcv.background = cc; + new_cursorGC = XtGetGC((Widget) term, mask, &xgcv); + + xgcv.foreground = cc; + xgcv.background = fg; + new_cursorFillGC = XtGetGC((Widget) term, mask, &xgcv); + + if (screen->always_highlight) { + new_reversecursorGC = (GC) 0; + new_cursoroutlineGC = (GC) 0; + } else { + xgcv.foreground = bg; + xgcv.background = cc; + new_reversecursorGC = XtGetGC((Widget) term, mask, &xgcv); + xgcv.foreground = cc; + xgcv.background = bg; + new_cursoroutlineGC = XtGetGC((Widget) term, mask, &xgcv); + } + } +#if OPT_ISO_COLORS + if (screen->colorMode) { + if (screen->cursorGC) + XFreeGC(screen->display, screen->cursorGC); + if (screen->fillCursorGC) + XFreeGC(screen->display, screen->fillCursorGC); + if (screen->reversecursorGC) + XFreeGC(screen->display, screen->reversecursorGC); + if (screen->cursoroutlineGC) + XFreeGC(screen->display, screen->cursoroutlineGC); + } else +#endif + { + if (screen->cursorGC) + XtReleaseGC((Widget) term, screen->cursorGC); + if (screen->fillCursorGC) + XtReleaseGC((Widget) term, screen->fillCursorGC); + if (screen->reversecursorGC) + XtReleaseGC((Widget) term, screen->reversecursorGC); + if (screen->cursoroutlineGC) + XtReleaseGC((Widget) term, screen->cursoroutlineGC); + } + + screen->cursorGC = new_cursorGC; + screen->fillCursorGC = new_cursorFillGC; + screen->reversecursorGC = new_reversecursorGC; + screen->cursoroutlineGC = new_cursoroutlineGC; +} diff --git a/nx-X11/programs/xterm/charproc.c.NX.original b/nx-X11/programs/xterm/charproc.c.NX.original new file mode 100644 index 000000000..4ec8a33df --- /dev/null +++ b/nx-X11/programs/xterm/charproc.c.NX.original @@ -0,0 +1,7300 @@ +/* $XTermId: charproc.c,v 1.627 2005/11/13 23:10:35 tom Exp $ */ + +/* + * $Xorg: charproc.c,v 1.6 2001/02/09 02:06:02 xorgcvs Exp $ + */ + +/* $XFree86: xc/programs/xterm/charproc.c,v 3.177 2005/11/13 23:10:35 dickey Exp $ */ + +/* + +Copyright 1999-2004,2005 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. + */ + +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NX-X11, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of NoMachine S.r.l. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* charproc.c */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OPT_INPUT_METHOD + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif + +#if OPT_WIDE_CHARS +#include +#include +#ifdef HAVE_LANGINFO_CODESET +#include +#endif +#endif + +#if OPT_INPUT_METHOD +#include +#endif + +#include +#include + +#if defined(HAVE_SCHED_YIELD) +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if OPT_ZICONBEEP || OPT_TOOLBAR +#define HANDLE_STRUCT_NOTIFY 1 +#else +#define HANDLE_STRUCT_NOTIFY 0 +#endif + +static IChar doinput(void); +static int set_character_class(char *s); +static void FromAlternate(TScreen * screen); +static void RequestResize(XtermWidget termw, int rows, int cols, int text); +static void SwitchBufs(TScreen * screen); +static void ToAlternate(TScreen * screen); +static void VTallocbuf(void); +static void WriteText(TScreen * screen, + PAIRED_CHARS(Char * str, Char * str2), + Cardinal len); +static void ansi_modes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)); +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 termw, void (*func) (unsigned *p, unsigned mask)); +static void restoremodes(XtermWidget termw); +static void savemodes(XtermWidget termw); +static void unparseputn(unsigned int n, int fd); +static void window_ops(XtermWidget termw); + +#define DoStartBlinking(s) ((s)->cursor_blink ^ (s)->cursor_blink_esc) + +#if OPT_BLINK_CURS || OPT_BLINK_TEXT +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 char *_Font_Selected_ = "yes"; /* string is arbitrary */ + +static char defaultTranslations[] = +"\ + Shift Prior:scroll-back(1,halfpage) \n\ + Shift Next:scroll-forw(1,halfpage) \n\ + Shift Select:select-cursor-start() select-cursor-end(PRIMARY, CUT_BUFFER0) \n\ + Shift Insert:insert-selection(PRIMARY, CUT_BUFFER0) \n\ +" +#if OPT_SHIFT_FONTS +"\ + Shift~Ctrl KP_Add:larger-vt-font() \n\ + Shift Ctrl KP_Add:smaller-vt-font() \n\ + Shift KP_Subtract:smaller-vt-font() \n\ +" +#endif +"\ + ~Meta :insert-seven-bit() \n\ + Meta :insert-eight-bit() \n\ + !Ctrl :popup-menu(mainMenu) \n\ + !Lock Ctrl :popup-menu(mainMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(mainMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(mainMenu) \n\ + ~Meta :select-start() \n\ + ~Meta :select-extend() \n\ + !Ctrl :popup-menu(vtMenu) \n\ + !Lock Ctrl :popup-menu(vtMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(vtMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(vtMenu) \n\ + ~Ctrl ~Meta :ignore() \n\ + Meta :clear-saved-lines() \n\ + ~Ctrl ~Meta :insert-selection(PRIMARY, CUT_BUFFER0) \n\ + !Ctrl :popup-menu(fontMenu) \n\ + !Lock Ctrl :popup-menu(fontMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(fontMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(fontMenu) \n\ + ~Ctrl ~Meta :start-extend() \n\ + ~Meta :select-extend() \n\ + Ctrl :scroll-back(1,halfpage,m) \n\ + Lock Ctrl :scroll-back(1,halfpage,m) \n\ + Lock @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\ + @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\ + :scroll-back(5,line,m) \n\ + Ctrl :scroll-forw(1,halfpage,m) \n\ + Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + Lock @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + :scroll-forw(5,line,m) \n\ + :select-end(PRIMARY, CUT_BUFFER0) \n\ + :ignore() \ +"; /* PROCURA added "Meta :clear-saved-lines()" */ +/* *INDENT-OFF* */ +static XtActionsRec actionsList[] = { + { "allow-send-events", HandleAllowSends }, + { "bell", HandleBell }, + { "clear-saved-lines", HandleClearSavedLines }, + { "create-menu", HandleCreateMenu }, + { "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-redir", HandlePrintControlMode }, + { "quit", HandleQuit }, + { "redraw", HandleRedraw }, + { "delete-is-del", HandleDeleteIsDEL }, + { "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-cursesemul", HandleCursesEmul }, + { "set-jumpscroll", HandleJumpscroll }, + { "set-old-function-keys", HandleOldFunctionKeys }, + { "set-marginbell", HandleMarginBell }, + { "set-reverse-video", HandleReverseVideo }, + { "set-reversewrap", HandleReverseWrap }, + { "set-scroll-on-key", HandleScrollKey }, + { "set-scroll-on-tty-output", HandleScrollTtyOutput }, + { "set-scrollbar", HandleScrollbar }, + { "set-sun-function-keys", HandleSunFunctionKeys }, + { "set-sun-keyboard", HandleSunKeyboard }, + { "set-titeInhibit", HandleTiteInhibit }, + { "set-visual-bell", HandleSetVisualBell }, + { "set-pop-on-bell", HandleSetPopOnBell }, + { "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_BLINK_CURS + { "set-cursorblink", HandleCursorBlink }, +#endif +#if OPT_BOX_CHARS + { "set-font-linedrawing", HandleFontBoxChars }, +#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_HP_FUNC_KEYS + { "set-hp-function-keys", HandleHpFunctionKeys }, +#endif +#if OPT_LOAD_VTFONTS + { "load-vt-fonts", HandleLoadVTFonts }, +#endif +#if OPT_MAXIMIZE + { "deiconify", HandleDeIconify }, + { "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_SHIFT_FONTS + { "larger-vt-font", HandleLargerFont }, + { "smaller-vt-font", HandleSmallerFont }, +#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 }, +#endif +}; +/* *INDENT-ON* */ + +static XtResource resources[] = +{ + Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False), + Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, True), + 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(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(XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, screen.hp_ll_bc, False), + Bres(XtNi18nSelections, XtCI18nSelections, screen.i18nSelections, True), + Bres(XtNjumpScroll, XtCJumpScroll, screen.jumpscroll, 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(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(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(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(XtNprinterControlMode, XtCPrinterControlMode, + screen.printer_controlmode, 0), + 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(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(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), + Fres("iconFont", "IconFont", screen.fnt_icon, XtDefaultFont), + Cres("iconBorderColor", XtCBorderColor, misc.icon_border_pixel, XtDefaultBackground), +#endif /* NO_ACTIVE_ICON */ + +#if OPT_BLINK_CURS + Bres(XtNcursorBlink, XtCCursorBlink, screen.cursor_blink, False), +#endif + +#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(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_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), +#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"), +#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 */ + +#if OPT_MOD_FKEYS + Ires(XtNmodifyCursorKeys, XtCModifyCursorKeys, + keyboard.modify_cursor_keys, 2), +#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, screen.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 + Ires(XtNutf8, XtCUtf8, screen.utf8_mode, uDefault), + Bres(XtNwideChars, XtCWideChars, screen.wide_chars, False), + Bres(XtNmkWidth, XtCMkWidth, misc.mk_width, False), + Bres(XtNcjkWidth, XtCCjkWidth, misc.cjk_width, False), + Bres(XtNvt100Graphics, XtCVT100Graphics, screen.vt100_graphics, True), + Sres(XtNwideBoldFont, XtCWideBoldFont, misc.default_font.f_wb, DEFWIDEBOLDFONT), + Sres(XtNwideFont, XtCWideFont, misc.default_font.f_w, DEFWIDEFONT), +#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_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 + Dres(XtNfaceSize, XtCFaceSize, misc.face_size, DEFFACESIZE), + Sres(XtNfaceName, XtCFaceName, misc.face_name, DEFFACENAME), + Sres(XtNfaceNameDoublesize, XtCFaceNameDoublesize, misc.face_wide_name, DEFFACENAME), + Bres(XtNrenderFont, XtCRenderFont, misc.render_font, True), +#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(void); +#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 */ + resources, /* resources */ + XtNumber(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) +{ +#if OPT_TOOLBAR + /* *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_SHIFT_FONTS + { "larger-vt-font", HandleLargerFont }, + { "smaller-vt-font", HandleSmallerFont }, +#endif + }; + /* *INDENT-ON* */ + + XtAppAddActions(app_con, input_actions, XtNumber(input_actions)); +#endif + XtAugmentTranslations(w, XtParseTranslationTable(defaultTranslations)); +} + +#if OPT_ISO_COLORS +/* + * 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(int color) +{ + TScreen *screen = &term->screen; + Pixel fg; + + if (color >= 0) { + term->flags |= FG_COLOR; + } else { + term->flags &= ~FG_COLOR; + } + fg = getXtermForeground(term->flags, color); + term->cur_foreground = color; + + XSetForeground(screen->display, NormalGC(screen), fg); + XSetBackground(screen->display, ReverseGC(screen), fg); + + if (NormalGC(screen) != NormalBoldGC(screen)) { + XSetForeground(screen->display, NormalBoldGC(screen), fg); + XSetBackground(screen->display, ReverseBoldGC(screen), fg); + } +} + +void +SGR_Background(int color) +{ + TScreen *screen = &term->screen; + 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 != term->cur_background)) + FlushScroll(screen); + + if (color >= 0) { + term->flags |= BG_COLOR; + } else { + term->flags &= ~BG_COLOR; + } + bg = getXtermBackground(term->flags, color); + term->cur_background = color; + + XSetBackground(screen->display, NormalGC(screen), bg); + XSetForeground(screen->display, ReverseGC(screen), bg); + + if (NormalGC(screen) != NormalBoldGC(screen)) { + XSetBackground(screen->display, NormalBoldGC(screen), bg); + XSetForeground(screen->display, ReverseBoldGC(screen), bg); + } +} + +/* Invoked after updating bold/underline flags, computes the extended color + * index to use for foreground. (See also 'extract_fg()'). + */ +static void +setExtendedFG(void) +{ + int fg = term->sgr_foreground; + + if (term->screen.colorAttrMode + || (fg < 0)) { + if (term->screen.colorULMode && (term->flags & UNDERLINE)) + fg = COLOR_UL; + if (term->screen.colorBDMode && (term->flags & BOLD)) + fg = COLOR_BD; + if (term->screen.colorBLMode && (term->flags & BLINK)) + fg = COLOR_BL; + } + + /* 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 (term->screen.boldColors + && (!term->sgr_extended) + && (fg >= 0) + && (fg < 8) + && (term->flags & BOLD)) + fg |= 8; +#endif + + SGR_Foreground(fg); +} + +/* Invoked after updating inverse flag, computes the extended color + * index to use for background. (See also 'extract_bg()'). + */ +static void +setExtendedBG(void) +{ + int bg = term->sgr_background; + + if (term->screen.colorAttrMode + || (bg < 0)) { + if (term->screen.colorRVMode && (term->flags & INVERSE)) + bg = COLOR_RV; + } + + SGR_Background(bg); +} + +static void +reset_SGR_Foreground(void) +{ + term->sgr_foreground = -1; + term->sgr_extended = 0; + setExtendedFG(); +} + +static void +reset_SGR_Background(void) +{ + term->sgr_background = -1; + setExtendedBG(); +} + +static void +reset_SGR_Colors(void) +{ + reset_SGR_Foreground(); + reset_SGR_Background(); +} +#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_TRACE +#define WHICH_TABLE(name) if (table == name) result = #name +static char * +which_table(Const PARSE_T * table) +{ + char *result = "?"; + /* *INDENT-OFF* */ + WHICH_TABLE (ansi_table); + else WHICH_TABLE (csi_table); + else WHICH_TABLE (csi2_table); + else WHICH_TABLE (csi_ex_table); + else WHICH_TABLE (csi_quo_table); +#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); +#endif + else WHICH_TABLE (dec_table); + else WHICH_TABLE (dec2_table); + else WHICH_TABLE (dec3_table); + else WHICH_TABLE (cigtable); + else WHICH_TABLE (eigtable); + else WHICH_TABLE (esc_table); + else WHICH_TABLE (esc_sp_table); + else WHICH_TABLE (scrtable); + else WHICH_TABLE (scstable); + else WHICH_TABLE (sos_table); +#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; \ + unsigned 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(screen, \ + screen->gsets[(int) (screen->curss)], \ + print_area, 1); \ + screen->curss = 0; \ + single++; \ + } \ + if (print_used > single) { \ + dotext(screen, \ + screen->gsets[(int) (screen->curgl)], \ + print_area + single, \ + print_used - single); \ + } \ + print_used = 0; \ + } \ + +struct ParseState { +#if OPT_VT52_MODE + Bool vt52_cup; +#endif + Const PARSE_T *groundtable; + Const PARSE_T *parsestate; + int scstype; + 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 +}; + +static struct ParseState myState; + +static Boolean +doparsing(unsigned c, struct ParseState *sp) +{ + /* Buffer for processing printable text */ + static IChar *print_area; + static size_t print_size, print_used; + + /* Buffer for processing strings (e.g., OSC ... ST) */ + static Char *string_area; + static size_t string_size, string_used; + + TScreen *screen = &term->screen; + int row; + int col; + int top; + int bot; + int count; + int laststate; + int thischar = -1; + XTermRect myRect; + + do { +#if OPT_WIDE_CHARS + + /* + * 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) { + int prev, precomposed; + + WriteNow(); + + prev = getXtermCell(screen, + screen->last_written_row, + screen->last_written_col); + precomposed = do_precomposition(prev, (int) c); + + if (precomposed != -1) { + 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(screen, + 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 = xtermPrinterControl((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++] = (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, term->flags); + sp->parsestate = vt52_table; + param[0] = 0; + param[1] = 0; + continue; + } +#endif + + /* + * The parsing tables all have 256 entries. If we're supporting + * wide characters, we handle them by treating them the same as + * printing characters. + */ + laststate = sp->nextstate; +#if OPT_WIDE_CHARS + if (c > 255) { + 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 (string_used) { + switch (string_area[0]) { + case 'P': + if (string_used <= 7) + break; + /* FALLTHRU */ + case 'R': + sp->parsestate = sp->groundtable; + sp->nextstate = sp->parsestate[E2A(c)]; + 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 5: /* FALLTHRU */ + case 8: /* FALLTHRU */ + case 9: /* FALLTHRU */ + case 10: /* FALLTHRU */ + case 11: /* FALLTHRU */ + case 12: /* FALLTHRU */ + case 13: /* FALLTHRU */ + case 14: /* FALLTHRU */ + case 15: /* FALLTHRU */ + case 24: + sp->parsestate = sp->groundtable; + sp->nextstate = sp->parsestate[E2A(c)]; + 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. + */ + if (iswide((int) c) != 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, print_area, print_used, print_size); + if (new_string == 0) { + fprintf(stderr, + "Cannot allocate %u bytes for printable text\n", + 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 + print_area = new_string; + print_size = new_length; + print_area[print_used++] = sp->lastchar = thischar = c; +#if OPT_WIDE_CHARS + sp->last_was_wide = iswide((int) c); +#endif + if (morePtyData(screen, VTbuffer)) { + continue; + } + } + + if (sp->nextstate == CASE_PRINT + || (laststate == CASE_PRINT && 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, string_area, string_used, string_size); + if (new_string == 0) { + fprintf(stderr, + "Cannot allocate %u bytes for string mode %d\n", + 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 + string_area = new_string; + string_size = new_length; + string_area[string_used++] = c; + } else if (sp->parsestate != esc_table) { + /* if we were accumulating, we're not any more */ + sp->string_mode = 0; + 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")); + sp->parsestate = sp->groundtable; + 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(screen->answer_back[count], screen->respond); + break; + + case CASE_BELL: + TRACE(("CASE_BELL - bell\n")); + if (sp->string_mode == OSC) { + if (string_used) + string_area[--string_used] = '\0'; + do_osc(string_area, string_used, (int) c); + sp->parsestate = sp->groundtable; + } else { + /* bell */ + Bell(XkbBI_TerminalBell, 0); + } + break; + + case CASE_BS: + TRACE(("CASE_BS - backspace\n")); + CursorBack(screen, 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((int) c); + xtermIndex(screen, 1); + if (term->flags & LINEFEED) + CarriageReturn(screen); + do_xevents(); + break; + + case CASE_CBT: + /* cursor backward tabulation */ + if ((count = param[0]) == DEFAULT) + count = 1; + while ((count-- > 0) + && (TabToPrevStop(screen))) ; + sp->parsestate = sp->groundtable; + break; + + case CASE_CHT: + /* cursor forward tabulation */ + if ((count = param[0]) == DEFAULT) + count = 1; + while ((count-- > 0) + && (TabToNextStop(screen))) ; + sp->parsestate = sp->groundtable; + break; + + case CASE_TAB: + /* tab */ + TabToNextStop(screen); + break; + + case CASE_SI: + screen->curgl = 0; + if_OPT_VT52_MODE(screen, { + sp->parsestate = sp->groundtable; + }); + break; + + case CASE_SO: + screen->curgl = 1; + if_OPT_VT52_MODE(screen, { + sp->parsestate = sp->groundtable; + }); + break; + + case CASE_DECDHL: + xterm_DECDHL(c == '3'); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSWL: + xterm_DECSWL(); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECDWL: + xterm_DECDWL(); + sp->parsestate = sp->groundtable; + break; + + case CASE_SCR_STATE: + /* enter scr state */ + sp->parsestate = scrtable; + break; + + case CASE_SCS0_STATE: + /* enter scs state 0 */ + sp->scstype = 0; + sp->parsestate = scstable; + break; + + case CASE_SCS1_STATE: + /* enter scs state 1 */ + sp->scstype = 1; + sp->parsestate = scstable; + break; + + case CASE_SCS2_STATE: + /* enter scs state 2 */ + sp->scstype = 2; + sp->parsestate = scstable; + break; + + case CASE_SCS3_STATE: + /* enter scs state 3 */ + sp->scstype = 3; + sp->parsestate = scstable; + break; + + case CASE_ESC_IGNORE: + /* unknown escape sequence */ + sp->parsestate = eigtable; + break; + + case CASE_ESC_DIGIT: + /* digit in csi or dec mode */ + if ((row = param[nparam - 1]) == DEFAULT) + row = 0; + param[nparam - 1] = 10 * row + (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(screen, (unsigned) row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUU: + TRACE(("CASE_CUU - cursor up\n")); + if ((row = param[0]) < 1) + row = 1; + CursorUp(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUD: + TRACE(("CASE_CUD - cursor down\n")); + if ((row = param[0]) < 1) + row = 1; + CursorDown(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUF: + TRACE(("CASE_CUF - cursor forward\n")); + if ((col = param[0]) < 1) + col = 1; + CursorForward(screen, col); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUB: + TRACE(("CASE_CUB - cursor backward\n")); + if ((col = param[0]) < 1) + col = 1; + CursorBack(screen, col); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUP: + TRACE(("CASE_CUP - cursor position\n")); + if_OPT_XMC_GLITCH(screen, { + Jump_XMC(screen); + }); + if ((row = param[0]) < 1) + row = 1; + if (nparam < 2 || (col = param[1]) < 1) + col = 1; + CursorSet(screen, row - 1, col - 1, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_VPA: + TRACE(("CASE_VPA - vertical position\n")); + if ((row = param[0]) < 1) + row = 1; + CursorSet(screen, row - 1, screen->cur_col, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_HPA: + TRACE(("CASE_HPA - horizontal position\n")); + if ((col = param[0]) < 1) + col = 1; + CursorSet(screen, screen->cur_row, col - 1, term->flags); + sp->parsestate = sp->groundtable; + 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, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_ED: + TRACE(("CASE_ED - erase display\n")); + do_erase_display(screen, param[0], OFF_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_EL: + TRACE(("CASE_EL - erase line\n")); + do_erase_line(screen, param[0], OFF_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_ECH: + TRACE(("CASE_ECH - erase char\n")); + /* ECH */ + ClearRight(screen, param[0] < 1 ? 1 : param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_IL: + TRACE(("CASE_IL - insert line\n")); + if ((row = param[0]) < 1) + row = 1; + InsertLine(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_DL: + TRACE(("CASE_DL - delete line\n")); + if ((row = param[0]) < 1) + row = 1; + DeleteLine(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_DCH: + TRACE(("CASE_DCH - delete char\n")); + if ((row = param[0]) < 1) + row = 1; + DeleteChar(screen, (unsigned) row); + sp->parsestate = sp->groundtable; + 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) { + TRACE(("CASE_TRACK_MOUSE\n")); + /* Track mouse as long as in window and between + * specified rows + */ + TrackMouse(param[0], + param[2] - 1, param[1] - 1, + param[3] - 1, param[4] - 2); + } else { + TRACE(("CASE_SD - scroll down\n")); + /* SD */ + if ((count = param[0]) < 1) + count = 1; + RevScroll(screen, count); + do_xevents(); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECID: + TRACE(("CASE_DECID\n")); + if_OPT_VT52_MODE(screen, { + unparseputc(ESC, screen->respond); + unparseputc('/', screen->respond); + unparseputc('Z', screen->respond); + sp->parsestate = sp->groundtable; + 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 = 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++] = 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 (term->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 = count; + reply.a_inters = 0; + reply.a_final = 'c'; + unparseseq(&reply, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DA2: + TRACE(("CASE_DA2\n")); + if (param[0] <= 0) { /* less than means DEFAULT */ + count = 0; + reply.a_type = 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 = count; + reply.a_inters = 0; + reply.a_final = 'c'; + unparseseq(&reply, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRPTUI: + TRACE(("CASE_DECRPTUI\n")); + if ((screen->terminal_id >= 400) + && (param[0] <= 0)) { /* less than means DEFAULT */ + unparseputc1(DCS, screen->respond); + unparseputc('!', screen->respond); + unparseputc('|', screen->respond); + unparseputc('0', screen->respond); + unparseputc1(ST, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_TBC: + TRACE(("CASE_TBC - tab clear\n")); + if ((row = param[0]) <= 0) /* less than means default */ + TabClear(term->tabs, screen->cur_col); + else if (row == 3) + TabZonk(term->tabs); + sp->parsestate = sp->groundtable; + break; + + case CASE_SET: + TRACE(("CASE_SET - set mode\n")); + ansi_modes(term, bitset); + sp->parsestate = sp->groundtable; + break; + + case CASE_RST: + TRACE(("CASE_RST - reset mode\n")); + ansi_modes(term, bitclr); + sp->parsestate = sp->groundtable; + break; + + case CASE_SGR: + for (row = 0; row < nparam; ++row) { + if_OPT_XMC_GLITCH(screen, { + Mark_XMC(screen, param[row]); + }); + TRACE(("CASE_SGR %d\n", param[row])); + switch (param[row]) { + case DEFAULT: + case 0: + term->flags &= + ~(INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE); + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + break; + case 1: /* Bold */ + term->flags |= BOLD; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 5: /* Blink */ + term->flags |= BLINK; + StartBlinking(screen); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 4: /* Underscore */ + term->flags |= UNDERLINE; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 7: + term->flags |= INVERSE; + if_OPT_ISO_COLORS(screen, { + setExtendedBG(); + }); + break; + case 8: + term->flags |= INVISIBLE; + break; + case 22: /* reset 'bold' */ + term->flags &= ~BOLD; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 24: + term->flags &= ~UNDERLINE; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 25: /* reset 'blink' */ + term->flags &= ~BLINK; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 27: + term->flags &= ~INVERSE; + if_OPT_ISO_COLORS(screen, { + setExtendedBG(); + }); + break; + case 28: + term->flags &= ~INVISIBLE; + break; + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + if_OPT_ISO_COLORS(screen, { + term->sgr_foreground = (param[row] - 30); + term->sgr_extended = 0; + setExtendedFG(); + }); + 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) { + term->sgr_foreground = param[row]; + term->sgr_extended = 1; + setExtendedFG(); + } + break; + default: + row += 7; + break; + } + } + }); + break; + case 39: + if_OPT_ISO_COLORS(screen, { + reset_SGR_Foreground(); + }); + break; + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + if_OPT_ISO_COLORS(screen, { + term->sgr_background = (param[row] - 40); + setExtendedBG(); + }); + 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) { + term->sgr_background = param[row]; + setExtendedBG(); + } + break; + default: + row += 7; + break; + } + } + }); + break; + case 49: + if_OPT_ISO_COLORS(screen, { + reset_SGR_Background(); + }); + break; + case 90: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 97: + if_OPT_AIX_COLORS(screen, { + term->sgr_foreground = (param[row] - 90 + 8); + term->sgr_extended = 0; + setExtendedFG(); + }); + break; + case 100: +#if !OPT_AIX_COLORS + if_OPT_ISO_COLORS(screen, { + reset_SGR_Foreground(); + reset_SGR_Background(); + }); + break; +#endif + case 101: + case 102: + case 103: + case 104: + case 105: + case 106: + case 107: + if_OPT_AIX_COLORS(screen, { + term->sgr_background = (param[row] - 100 + 8); + setExtendedBG(); + }); + break; + } + } + sp->parsestate = sp->groundtable; + 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 = CSI; + reply.a_pintro = 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++] = screen->cur_row + 1; + reply.a_param[count++] = screen->cur_col + 1; + reply.a_final = 'R'; + break; + case 15: + /* printer status */ + reply.a_param[count++] = 13; /* implement printer */ + break; + case 25: + /* UDK status */ + reply.a_param[count++] = 20; /* UDK always unlocked */ + break; + case 26: + /* keyboard status */ + 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 OPT_DEC_LOCATOR + reply.a_param[count++] = 50; /* locator ready */ +#else + reply.a_param[count++] = 53; /* no locator */ +#endif + break; + } + + if ((reply.a_nparam = count) != 0) + unparseseq(&reply, screen->respond); + + sp->parsestate = sp->groundtable; + sp->private_function = False; + break; + + case CASE_MC: + TRACE(("CASE_MC - media control\n")); + xtermMediaControl(param[0], False); + sp->parsestate = sp->groundtable; + break; + + case CASE_DEC_MC: + TRACE(("CASE_DEC_MC - DEC media control\n")); + xtermMediaControl(param[0], True); + sp->parsestate = sp->groundtable; + 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(screen); + 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); + sp->parsestate = sp->groundtable; + 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(screen); + set_tb_margins(screen, top - 1, bot - 1); + CursorSet(screen, 0, 0, term->flags); + } + sp->parsestate = sp->groundtable; + 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 = CSI; + reply.a_pintro = 0; + reply.a_nparam = 7; + reply.a_param[0] = 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(&reply, screen->respond); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSET: + /* DECSET */ +#if OPT_VT52_MODE + if (screen->vtXX_level != 0) +#endif + dpmodes(term, bitset); + sp->parsestate = sp->groundtable; +#if OPT_TEK4014 + if (screen->TekEmu) + return False; +#endif + break; + + case CASE_DECRST: + /* DECRST */ + dpmodes(term, bitclr); +#if OPT_VT52_MODE + if (screen->vtXX_level == 0) + sp->groundtable = vt52_table; + else if (screen->terminal_id >= 100) + sp->groundtable = ansi_table; +#endif + sp->parsestate = sp->groundtable; + 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, term->flags); + xtermParseRect(screen, 0, 0, &myRect); + ScrnFillRectangle(screen, &myRect, 'E', 0); + sp->parsestate = sp->groundtable; + break; + + case CASE_GSETS: + TRACE(("CASE_GSETS(%d) = '%c'\n", sp->scstype, c)); + if (screen->vtXX_level != 0) + screen->gsets[sp->scstype] = c; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSC: + TRACE(("CASE_DECSC - save cursor\n")); + CursorSave(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRC: + TRACE(("CASE_DECRC - restore cursor\n")); + CursorRestore(term); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECKPAM: + TRACE(("CASE_DECKPAM\n")); + term->keyboard.flags |= MODE_DECKPAM; + update_appkeypad(); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECKPNM: + TRACE(("CASE_DECKPNM\n")); + term->keyboard.flags &= ~MODE_DECKPAM; + update_appkeypad(); + sp->parsestate = sp->groundtable; + break; + + case CASE_CSI_QUOTE_STATE: + sp->parsestate = csi_quo_table; + break; + +#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); + sp->parsestate = sp->groundtable; + break; + + case CASE_ANSI_LEVEL_2: + TRACE(("CASE_ANSI_LEVEL_2\n")); + set_ansi_conformance(screen, 2); + sp->parsestate = sp->groundtable; + break; + + case CASE_ANSI_LEVEL_3: + TRACE(("CASE_ANSI_LEVEL_3\n")); + set_ansi_conformance(screen, 3); + sp->parsestate = sp->groundtable; + 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(False, False); + screen->vtXX_level = param[0] - 60; + if (param[0] > 61) { + if (param[1] == 1) + show_8bit_control(False); + else if (param[1] == 0 || param[1] == 2) + show_8bit_control(True); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSCA: + TRACE(("CASE_DECSCA\n")); + screen->protected_mode = DEC_PROTECT; + if (param[0] <= 0 || param[0] == 2) + term->flags &= ~PROTECTED; + else if (param[0] == 1) + term->flags |= PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSED: + TRACE(("CASE_DECSED\n")); + do_erase_display(screen, param[0], DEC_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSEL: + TRACE(("CASE_DECSEL\n")); + do_erase_line(screen, param[0], DEC_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_ST: + TRACE(("CASE_ST: End of String (%d bytes)\n", string_used)); + sp->parsestate = sp->groundtable; + if (!string_used) + break; + string_area[--string_used] = '\0'; + switch (sp->string_mode) { + case APC: + /* ignored */ + break; + case DCS: + do_dcs(string_area, string_used); + break; + case OSC: + do_osc(string_area, string_used, ST); + break; + case PM: + /* ignored */ + break; + case SOS: + /* ignored */ + break; + } + break; + + case CASE_SOS: + TRACE(("CASE_SOS: Start of String\n")); + sp->string_mode = SOS; + sp->parsestate = sos_table; + break; + + case CASE_PM: + TRACE(("CASE_PM: Privacy Message\n")); + sp->string_mode = PM; + sp->parsestate = sos_table; + break; + + case CASE_DCS: + TRACE(("CASE_DCS: Device Control String\n")); + sp->string_mode = DCS; + sp->parsestate = sos_table; + break; + + case CASE_APC: + TRACE(("CASE_APC: Application Program Command\n")); + sp->string_mode = APC; + sp->parsestate = sos_table; + break; + + case CASE_SPA: + TRACE(("CASE_SPA - start protected area\n")); + screen->protected_mode = ISO_PROTECT; + term->flags |= PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_EPA: + TRACE(("CASE_EPA - end protected area\n")); + term->flags &= ~PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_SU: + TRACE(("CASE_SU - scroll up\n")); + if ((count = param[0]) < 1) + count = 1; + xtermScroll(screen, count); + sp->parsestate = sp->groundtable; + break; + + case CASE_IND: + TRACE(("CASE_IND - index\n")); + xtermIndex(screen, 1); + do_xevents(); + sp->parsestate = sp->groundtable; + break; + + case CASE_CPL: + TRACE(("CASE_CPL - cursor prev line\n")); + CursorPrevLine(screen, param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_CNL: + TRACE(("CASE_NPL - cursor next line\n")); + CursorNextLine(screen, param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_NEL: + TRACE(("CASE_NEL\n")); + xtermIndex(screen, 1); + CarriageReturn(screen); + do_xevents(); + sp->parsestate = sp->groundtable; + break; + + case CASE_HTS: + TRACE(("CASE_HTS - horizontal tab set\n")); + TabSet(term->tabs, screen->cur_col); + sp->parsestate = sp->groundtable; + break; + + case CASE_RI: + TRACE(("CASE_RI - reverse index\n")); + RevIndex(screen, 1); + sp->parsestate = sp->groundtable; + break; + + case CASE_SS2: + TRACE(("CASE_SS2\n")); + screen->curss = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_SS3: + TRACE(("CASE_SS3\n")); + screen->curss = 3; + sp->parsestate = sp->groundtable; + 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, term); + 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(term); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECELR: + MotionOff(screen, term); + 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; + 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; + } + sp->parsestate = sp->groundtable; + 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, term); + screen->loc_filter = False; + screen->locator_events = 0; + break; + case 1: + screen->locator_events |= LOC_BTNS_DN; + break; + case 2: + screen->locator_events &= ~LOC_BTNS_DN; + break; + case 3: + screen->locator_events |= LOC_BTNS_UP; + break; + case 4: + screen->locator_events &= ~LOC_BTNS_UP; + break; + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRQLP: + TRACE(("DECRQLP - Request Locator Position\n")); + if (param[0] < 2) { + /* Issue DECLRP Locator Position Report */ + GetLocatorPosition(term); + } + sp->parsestate = sp->groundtable; + break; +#endif /* OPT_DEC_LOCATOR */ + +#if OPT_DEC_RECTOPS + case CASE_CSI_DOLLAR_STATE: + /* csi dollar ($) */ + if (screen->vtXX_level >= 4) + sp->parsestate = csi_dollar_table; + else + sp->parsestate = eigtable; + break; + + case CASE_CSI_STAR_STATE: + /* csi dollar (*) */ + if (screen->vtXX_level >= 4) + sp->parsestate = csi_star_table; + else + sp->parsestate = eigtable; + break; + + case CASE_DECCRA: + TRACE(("CASE_DECCRA - Copy rectangular area\n")); + xtermParseRect(screen, nparam, param, &myRect); + ScrnCopyRectangle(screen, &myRect, nparam - 5, param + 5); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECERA: + TRACE(("CASE_DECERA - Erase rectangular area\n")); + xtermParseRect(screen, nparam, param, &myRect); + ScrnFillRectangle(screen, &myRect, ' ', 0); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECFRA: + TRACE(("CASE_DECFRA - Fill rectangular area\n")); + if (nparam > 0 + && ((param[0] >= 32 && param[0] <= 126) + || (param[0] >= 160 && param[0] <= 255))) { + xtermParseRect(screen, nparam - 1, param + 1, &myRect); + ScrnFillRectangle(screen, &myRect, param[0], term->flags); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSERA: + TRACE(("CASE_DECSERA - Selective erase rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnWipeRectangle(screen, &myRect); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSACE: + TRACE(("CASE_DECSACE - Select attribute change extent\n")); + screen->cur_decsace = param[0]; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECCARA: + TRACE(("CASE_DECCARA - Change attributes in rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnMarkRectangle(screen, &myRect, False, nparam - 4, param + 4); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRARA: + TRACE(("CASE_DECRARA - Reverse attributes in rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnMarkRectangle(screen, &myRect, True, nparam - 4, param + 4); + sp->parsestate = sp->groundtable; + break; +#else + case CASE_CSI_DOLLAR_STATE: + /* csi dollar ($) */ + sp->parsestate = eigtable; + break; + + case CASE_CSI_STAR_STATE: + /* csi dollar (*) */ + sp->parsestate = eigtable; + break; +#endif /* OPT_DEC_RECTOPS */ + + case CASE_S7C1T: + TRACE(("CASE_S7C1T\n")); + show_8bit_control(False); + sp->parsestate = sp->groundtable; + break; + + case CASE_S8C1T: + TRACE(("CASE_S8C1T\n")); +#if OPT_VT52_MODE + if (screen->vtXX_level <= 1) + break; +#endif + show_8bit_control(True); + sp->parsestate = sp->groundtable; + break; + + case CASE_OSC: + TRACE(("CASE_OSC: Operating System Command\n")); + sp->parsestate = sos_table; + sp->string_mode = OSC; + break; + + case CASE_RIS: + TRACE(("CASE_RIS\n")); + VTReset(True, True); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSTR: + TRACE(("CASE_DECSTR\n")); + VTReset(False, False); + sp->parsestate = sp->groundtable; + break; + + case CASE_REP: + TRACE(("CASE_REP\n")); + if (sp->lastchar >= 0 && + sp->groundtable[E2A(sp->lastchar)] == CASE_PRINT) { + IChar repeated[2]; + count = (param[0] < 1) ? 1 : param[0]; + repeated[0] = sp->lastchar; + while (count-- > 0) { + dotext(screen, + screen->gsets[(int) (screen->curgl)], + repeated, 1); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_LS2: + TRACE(("CASE_LS2\n")); + screen->curgl = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS3: + TRACE(("CASE_LS3\n")); + screen->curgl = 3; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS3R: + TRACE(("CASE_LS3R\n")); + screen->curgr = 3; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS2R: + TRACE(("CASE_LS2R\n")); + screen->curgr = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS1R: + TRACE(("CASE_LS1R\n")); + screen->curgr = 1; + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_SAVE: + savemodes(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_RESTORE: + restoremodes(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_WINOPS: + TRACE(("CASE_XTERM_WINOPS\n")); + if (screen->allowWindowOps) + window_ops(term); + sp->parsestate = sp->groundtable; + 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) { + WriteNow(); + ChangeToWide(screen); + } + if (screen->wide_chars + && screen->utf8_mode != uAlways) { + 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")); + } + sp->parsestate = sp->groundtable; + break; +#endif + + case CASE_CSI_IGNORE: + sp->parsestate = cigtable; + break; + } + if (sp->parsestate == sp->groundtable) + sp->lastchar = thischar; + } while (0); + +#if OPT_WIDE_CHARS + screen->utf8_inparse = (screen->utf8_mode != uFalse + && sp->parsestate != sos_table); +#endif + + return True; +} + +static void +VTparse(void) +{ + TScreen *screen; + + /* We longjmp back to this point in VTReset() */ + (void) setjmp(vtjmpbuf); + screen = &term->screen; + memset(&myState, 0, sizeof(myState)); +#if OPT_VT52_MODE + myState.groundtable = screen->vtXX_level ? ansi_table : vt52_table; +#else + myState.groundtable = ansi_table; +#endif + myState.parsestate = myState.groundtable; + myState.lastchar = -1; /* not a legal IChar */ + myState.nextstate = -1; /* not a legal state */ + + for (;;) { + if (!doparsing(doinput(), &myState)) + return; + } +} + +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. */ + +int +v_write(int f, Char * data, unsigned len) +{ + int riten; + unsigned c = len; + + if (v_bufstr == NULL && len > 0) { + v_buffer = (Char *) XtMalloc(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, (char *) data); + fprintf(stderr, "\n"); + } +#endif + +#ifdef VMS + if ((1 << f) != pty_mask) + return (tt_write((char *) data, len)); +#else /* VMS */ + if (!FD_ISSET(f, &pty_mask)) + return (write(f, (char *) data, len)); +#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 + term->screen.dabbrev_working = 0; /* 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, (unsigned) (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. */ + int size = v_bufptr - v_buffer; /* save across realloc */ + 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 */ + c = 0; + } + } + } + if (v_bufend >= v_bufptr + len) { + /* new stuff will fit */ + memmove(v_bufptr, data, 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 = 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 = v_bufstr - v_buffer; + int size = 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 */ + } + } + return (c); +} + +#ifdef VMS +#define ptymask() (v_bufptr > v_bufstr ? pty_mask : 0) + +static void +in_put(void) +{ + static PtySelect select_mask; + static PtySelect write_mask; + int update = VTbuffer->update; + int size; + + int status; + Dimension replyWidth, replyHeight; + XtGeometryResult stat; + + TScreen *screen = &term->screen; + 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 = XtMakeResizeRequest((Widget) term, + ((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) { + term->core.width = replyWidth; + term->core.height = replyHeight; + + ScreenResize(&term->screen, replyWidth, replyHeight, + &term->flags); + } + repairSizeHints(); + } + + if (eventMode == NORMAL + && readPtyData(screen, &select_mask, VTbuffer)) { + if (screen->scrollWidget + && screen->scrollttyoutput + && screen->topline < 0) + /* Scroll to bottom */ + WindowScroll(screen, 0); + break; + } + if (screen->scroll_amt) + FlushScroll(screen); + 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 (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(void) +{ + static PtySelect select_mask; + static PtySelect write_mask; + + TScreen *screen = &term->screen; + 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 (eventMode == NORMAL + && (size = readPtyData(screen, &select_mask, VTbuffer)) != 0) { + if (screen->scrollWidget + && screen->scrollttyoutput + && screen->topline < 0) + WindowScroll(screen, 0); /* Scroll to bottom */ + /* stop speed reading at some point to look for X stuff */ + TRACE(("VTbuffer uses %d/%d\n", + 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(screen); + 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 (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) { + /* + * When session management is enabled, we should not block since + * session related events can arrive any time. + */ + select_timeout.tv_sec = 1; + select_timeout.tv_usec = 0; + time_select = 1; +#endif + } + if (need_cleanup) + Cleanup(0); + +#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) + fprintf(stderr, "xterm::in_put: Select called with [%d][%p][%p][%p][%p].\n", + max_plus1, (void *) &select_mask, (void *) &write_mask, (void *) 0, + (void *) (time_select ? &select_timeout : 0)); +#endif + + 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 = &term->screen; + + while (!morePtyData(screen, VTbuffer)) + in_put(); + return nextPtyData(screen, VTbuffer); +} + +#if OPT_INPUT_METHOD +/* + * For OverTheSpot, client has to inform the position for XIM preedit. + */ +static void +PreeditPosition(TScreen * screen) +{ + XPoint spot; + XVaNestedList list; + + if (!screen->xic) + return; + spot.x = CurCursorX(screen, screen->cur_row, screen->cur_col); + spot.y = 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 + +/* + * process a string of characters according to the character set indicated + * by charset. worry about end of line conditions (wraparound if selected). + */ +void +dotext(TScreen * screen, + int charset, + IChar * buf, /* start of characters to process */ + Cardinal len) /* end */ +{ +#if OPT_WIDE_CHARS + Cardinal chars_chomped = 1; +#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 && charset == '0')) +#endif + + if (!xtermCharSetOut(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; + int need_wrap = 0; + chars_chomped = 0; + + if (screen->do_wrap && (term->flags & WRAPAROUND)) { + /* mark that we had to wrap this line */ + ScrnSetWrapped(screen, screen->cur_row); + xtermAutoPrint('\n'); + xtermIndex(screen, 1); + set_cur_col(screen, 0); + screen->do_wrap = 0; + width_available = MaxCols(screen) - screen->cur_col; + } + + while (width_here <= width_available && chars_chomped < (len - offset)) { + if (!screen->utf8_mode + || (screen->vt100_graphics && charset == '0')) + width_here++; + else + width_here += my_wcwidth((int) buf[chars_chomped + offset]); + chars_chomped++; + } + + if (width_here > width_available) { + chars_chomped--; + if (!screen->utf8_mode + || (screen->vt100_graphics && charset == '0')) + width_here--; + else + width_here -= my_wcwidth((int) buf[chars_chomped + offset]); + need_wrap = 1; + } else if (width_here == width_available) { + need_wrap = 1; + } else if (chars_chomped != (len - offset)) { + need_wrap = 1; + } + + /* + * 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) { + static unsigned limit; + static Char *hibyte, *lobyte; + Bool both = False; + unsigned j, k; + + if (chars_chomped >= limit) { + limit = (chars_chomped + 1) * 2; + lobyte = (Char *) XtRealloc((char *) lobyte, limit); + hibyte = (Char *) XtRealloc((char *) hibyte, limit); + } + for (j = offset; j < offset + chars_chomped; j++) { + k = j - offset; + lobyte[k] = buf[j]; + if (buf[j] > 255) { + hibyte[k] = (buf[j] >> 8); + both = True; + } else { + hibyte[k] = 0; + } + } + + WriteText(screen, PAIRED_CHARS(lobyte, + (both ? hibyte : 0)), + chars_chomped); + } + screen->do_wrap = need_wrap; + } +#else + + for (offset = 0; offset < len; offset += this_col) { + last_col = CurMaxCol(screen, screen->cur_row); + this_col = last_col - screen->cur_col + 1; + if (this_col <= 1) { + if (screen->do_wrap && (term->flags & WRAPAROUND)) { + /* mark that we had to wrap this line */ + ScrnSetWrapped(screen, screen->cur_row); + xtermAutoPrint('\n'); + xtermIndex(screen, 1); + set_cur_col(screen, 0); + screen->do_wrap = 0; + this_col = last_col + 1; + } else + this_col = 1; + } + if (offset + this_col > len) { + this_col = len - offset; + } + next_col = screen->cur_col + this_col; + + WriteText(screen, PAIRED_CHARS(buf + offset, + buf2 ? buf2 + offset : 0), + this_col); + + /* + * the call to WriteText updates screen->cur_col. + * If screen->cur_col != next_col, we must have + * hit the right margin, so set the do_wrap flag. + */ + screen->do_wrap = (screen->cur_col < (int) next_col); + } + +#endif +} + +#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! + */ +static int mapstate = -1; +#endif /* HANDLE_STRUCT_NOTIFY */ + +#if OPT_WIDE_CHARS +unsigned +visual_width(PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +{ + /* returns the visual width of a string (doublewide characters count + as 2, normalwide characters count as 1) */ + int my_len = 0; + while (len) { + int ch = *str; + if (str2) + ch |= *str2 << 8; + if (str) + str++; + if (str2) + str2++; + if (iswide(ch)) + my_len += 2; + else + my_len++; + len--; + } + return my_len; +} +#endif + +/* + * write a string str of length len onto the screen at + * the current cursor position. update cursor position. + */ +static void +WriteText(TScreen * screen, PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +{ + ScrnPtr PAIRED_CHARS(temp_str = 0, temp_str2 = 0); + unsigned test; + unsigned flags = term->flags; + unsigned fg_bg = makeColorPair(term->cur_foreground, term->cur_background); + unsigned cells = visual_width(PAIRED_CHARS(str, str2), len); + GC currentGC; + + TRACE(("WriteText (%2d,%2d) (%d) %3d:%s\n", + screen->cur_row, + screen->cur_col, + curXtermChrSet(screen->cur_row), + len, visibleChars(PAIRED_CHARS(str, str2), len))); + + if (ScrnHaveSelection(screen) + && ScrnIsLineInSelection(screen, screen->cur_row - screen->topline)) { + ScrnDisownSelection(screen); + } + + if (screen->cur_row - screen->topline <= screen->max_row) { + if (screen->cursor_state) + HideCursor(); + + if (flags & INSERT) { + InsertChar(screen, cells); + } + if (!AddToRefresh(screen)) { + + if (screen->scroll_amt) + FlushScroll(screen); + + if (flags & INVISIBLE) { + if (cells > len) { + str = temp_str = TypeMallocN(Char, cells); + if (str == 0) + return; + } + if_OPT_WIDE_CHARS(screen, { + if (cells > len) { + str2 = temp_str2 = TypeMallocN(Char, cells); + } + }); + len = cells; + + memset(str, ' ', len); + if_OPT_WIDE_CHARS(screen, { + if (str2 != 0) + memset(str2, 0, len); + }); + } + + TRACE(("WriteText calling drawXtermText (%d,%d)\n", + screen->cur_col, + screen->cur_row)); + + test = flags; + checkVeryBoldColors(test, term->cur_foreground); + + /* make sure that the correct GC is current */ + currentGC = updatedXtermGC(screen, flags, fg_bg, False); + + drawXtermText(screen, test & DRAWX_MASK, currentGC, + CurCursorX(screen, screen->cur_row, screen->cur_col), + CursorY(screen, screen->cur_row), + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(str, str2), len, 0); + + resetXtermGC(screen, flags, False); + } + } + + ScreenWrite(screen, PAIRED_CHARS(str, str2), flags, fg_bg, len); + CursorForward(screen, (int) cells); +#if OPT_ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + */ + if (zIconBeep && mapstate == IsUnmapped && !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) { + zIconBeep_flagged = True; + Changename(icon_name); + } + if (zIconBeep > 0) { +#if defined(HAVE_XKBBELL) + XkbBell(XtDisplay(toplevel), VShellWindow, zIconBeep, XkbBI_Info); +#else + XBell(XtDisplay(toplevel), zIconBeep); +#endif + } + } + mapstate = -1; +#endif /* OPT_ZICONBEEP */ + if (temp_str != 0) + free(temp_str); + if_OPT_WIDE_CHARS(screen, { + if (temp_str2 != 0) + free(temp_str2); + }); + return; +} + +#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} + }; + + switch (event->type) { + case MapNotify: + TRACE(("HandleStructNotify(MapNotify)\n")); +#if OPT_ZICONBEEP + if (zIconBeep_flagged) { + 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) { + zIconBeep_flagged = True; + return; + } + strcpy(buf, icon_name + 4); + Changename(buf); + free(buf); + } + } +#endif /* OPT_ZICONBEEP */ + mapstate = !IsUnmapped; + break; + case UnmapNotify: + TRACE(("HandleStructNotify(UnmapNotify)\n")); + mapstate = IsUnmapped; + break; + case ConfigureNotify: + TRACE(("HandleStructNotify(ConfigureNotify)\n")); +#if OPT_TOOLBAR + /* the notify is for the top-level widget, but we care about vt100 */ + if (term->screen.Vshow) { + TScreen *screen = &term->screen; + struct _vtwin *Vwin = WhichVWin(&(term->screen)); + 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. + */ + XtMakeResizeRequest((Widget) term, + screen->fullVwin.fullwidth, + info->menu_height + - save.menu_height + + screen->fullVwin.fullheight, + NULL, NULL); + repairSizeHints(); + } + } + } +#endif /* OPT_TOOLBAR */ + break; + default: + TRACE(("HandleStructNotify(event %d)\n", event->type)); + break; + } +} +#endif /* HANDLE_STRUCT_NOTIFY */ + +#if OPT_BLINK_CURS +static void +SetCursorBlink(TScreen * screen, int enable) +{ + screen->cursor_blink = enable; + if (DoStartBlinking(screen)) { + StartBlinking(screen); + } else { +#if !OPT_BLINK_TEXT + StopBlinking(screen); +#endif + } + update_cursorblink(); +} + +void +ToggleCursorBlink(TScreen * screen) +{ + SetCursorBlink(screen, !(screen->cursor_blink)); +} +#endif + +/* + * process ANSI modes set, reset + */ +static void +ansi_modes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)) +{ + int i; + + for (i = 0; i < nparam; ++i) { + switch (param[i]) { + case 2: /* KAM (if set, keyboard locked */ + (*func) (&termw->keyboard.flags, MODE_KAM); + break; + + case 4: /* IRM */ + (*func) (&termw->flags, INSERT); + break; + + case 12: /* SRM (if set, local echo */ + (*func) (&termw->keyboard.flags, MODE_SRM); + break; + + case 20: /* LNM */ + (*func) (&termw->flags, LINEFEED); + update_autolinefeed(); + break; + } + } +} + +#define set_mousemode(mode) \ + screen->send_mouse_pos = (func == bitset) ? mode : MOUSE_OFF +#define set_mouseflag(f) \ + ((func == bitset) \ + ? SCREEN_FLAG_set(screen, f) \ + : SCREEN_FLAG_unset(screen, f)) + +/* + * process DEC private modes set, reset + */ +static void +dpmodes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)) +{ + TScreen *screen = &termw->screen; + int i, j; + + for (i = 0; i < nparam; ++i) { + TRACE(("%s %d\n", (func == bitset) ? "DECSET" : "DECRST", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + (*func) (&termw->keyboard.flags, MODE_DECCKM); + update_appcursor(); + break; + case 2: /* DECANM - ANSI/VT52 mode */ + if (func == bitset) { /* ANSI (VT100) */ + /* + * Setting DECANM should have no effect, since this function + * cannot be reached from vt52 mode. + */ + ; + } +#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(screen); + CursorSet(screen, 0, 0, termw->flags); + if ((j = func == bitset ? 132 : 80) != + ((termw->flags & IN132COLUMNS) ? 132 : 80) || + j != MaxCols(screen)) + RequestResize(termw, -1, j, True); + (*func) (&termw->flags, IN132COLUMNS); + } + break; + case 4: /* DECSCLM (slow scroll) */ + if (func == bitset) { + screen->jumpscroll = 0; + if (screen->scroll_amt) + FlushScroll(screen); + } else + screen->jumpscroll = 1; + (*func) (&termw->flags, SMOOTHSCROLL); + update_jumpscroll(); + break; + case 5: /* DECSCNM */ + j = termw->flags; + (*func) (&termw->flags, REVERSE_VIDEO); + if ((termw->flags ^ j) & REVERSE_VIDEO) + ReverseVideo(termw); + /* update_reversevideo done in RevVid */ + break; + + case 6: /* DECOM */ + (*func) (&termw->flags, ORIGIN); + CursorSet(screen, 0, 0, termw->flags); + break; + + case 7: /* DECAWM */ + (*func) (&termw->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, termw); + set_mousemode(X10_MOUSE); + break; +#if OPT_TOOLBAR + case 10: /* rxvt */ + ShowToolbar(func == bitset); + break; +#endif +#if OPT_BLINK_CURS + case 12: /* att610: Start/stop blinking cursor */ + if (screen->cursor_blink_res) { + screen->cursor_blink_esc = (func == bitset) ? ON : OFF; + SetCursorBlink(screen, screen->cursor_blink); + } + break; +#endif + case 18: /* DECPFF: print form feed */ + screen->printer_formfeed = (func == bitset) ? ON : OFF; + break; + case 19: /* DECPEX: print extent */ + screen->printer_extent = (func == bitset) ? ON : OFF; + break; + case 25: /* DECTCEM: Show/hide cursor (VT200) */ + screen->cursor_set = (func == bitset) ? ON : OFF; + break; + case 30: /* rxvt */ + if (screen->fullVwin.sb_info.width != ((func == bitset) ? ON : OFF)) + ToggleScrollBar(termw); + break; +#if OPT_SHIFT_FONTS + case 35: /* rxvt */ + term->misc.shift_fonts = (func == bitset) ? ON : OFF; + break; +#endif + case 38: /* DECTEK */ +#if OPT_TEK4014 + if (func == bitset && !(screen->inhibit & I_TEK)) { + FlushLog(screen); + screen->TekEmu = True; + } +#endif + break; + case 40: /* 132 column mode */ + screen->c132 = (func == bitset); + update_allow132(); + break; + case 41: /* curses hack */ + screen->curses = (func == bitset); + update_cursesemul(); + break; + case 42: /* DECNRCM national charset (VT220) */ + (*func) (&termw->flags, NATIONAL); + break; + case 44: /* margin bell */ + screen->marginbell = (func == bitset); + if (!screen->marginbell) + screen->bellarmed = -1; + update_marginbell(); + break; + case 45: /* reverse wraparound */ + (*func) (&termw->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 (func == bitset) + StartLog(screen); + else + CloseLog(screen); +#else + Bell(XkbBI_Info, 0); + Bell(XkbBI_Info, 0); +#endif /* ALLOWLOGFILEONOFF */ + break; +#endif + case 1049: /* alternate buffer & cursor */ + if (!termw->misc.titeInhibit) { + if (func == bitset) { + CursorSave(termw); + ToAlternate(screen); + ClearScreen(screen); + } else { + FromAlternate(screen); + CursorRestore(termw); + } + } else if (termw->misc.tiXtraScroll) { + if (func == bitset) { + xtermScroll(screen, screen->max_row); + } + } + break; + case 1047: + case 47: /* alternate buffer */ + if (!termw->misc.titeInhibit) { + if (func == bitset) { + ToAlternate(screen); + } else { + if (screen->alternate + && (param[i] == 1047)) + ClearScreen(screen); + FromAlternate(screen); + } + } else if (termw->misc.tiXtraScroll) { + if (func == bitset) { + xtermScroll(screen, screen->max_row); + } + } + break; + case 66: /* DECNKM */ + (*func) (&termw->keyboard.flags, MODE_DECKPAM); + update_appkeypad(); + break; + case 67: /* DECBKM */ + /* back-arrow mapped to backspace or delete(D) */ + (*func) (&termw->keyboard.flags, MODE_DECBKM); + TRACE(("DECSET DECBKM %s\n", + BtoS(termw->keyboard.flags & MODE_DECBKM))); + update_decbkm(); + break; + case SET_VT200_MOUSE: /* xterm bogus sequence */ + MotionOff(screen, termw); + set_mousemode(VT200_MOUSE); + break; + case SET_VT200_HIGHLIGHT_MOUSE: /* xterm sequence w/hilite tracking */ + MotionOff(screen, termw); + set_mousemode(VT200_HIGHLIGHT_MOUSE); + break; + case SET_BTN_EVENT_MOUSE: + MotionOff(screen, termw); + 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, term); + } else { + MotionOn(screen, term); + } + break; + case 1010: /* rxvt */ + screen->scrollttyoutput = (func == bitset) ? ON : OFF; + update_scrollttyoutput(); + break; + case 1011: /* rxvt */ + screen->scrollkey = (func == bitset) ? ON : OFF; + update_scrollkey(); + break; +#if OPT_NUM_LOCK + case 1035: + term->misc.real_NumLock = (func == bitset) ? ON : OFF; + update_num_lock(); + break; + case 1036: + screen->meta_sends_esc = (func == bitset) ? ON : OFF; + update_meta_esc(); + break; +#endif + case 1037: + screen->delete_is_del = (func == bitset) ? ON : OFF; + update_delete_del(); + break; + case 1048: + if (!termw->misc.titeInhibit) { + if (func == bitset) + CursorSave(termw); + else + CursorRestore(termw); + } + break; + case 1051: + set_keyboard_type(keyboardIsSun, func == bitset); + break; +#if OPT_HP_FUNC_KEYS + case 1052: + set_keyboard_type(keyboardIsHP, func == bitset); + break; +#endif +#if OPT_SCO_FUNC_KEYS + case 1053: + set_keyboard_type(keyboardIsSCO, func == bitset); + break; +#endif + case 1060: + set_keyboard_type(keyboardIsLegacy, func == bitset); + break; +#if OPT_SUNPC_KBD + case 1061: + set_keyboard_type(keyboardIsVT220, func == bitset); + 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 termw) +{ + TScreen *screen = &termw->screen; + int i; + + for (i = 0; i < nparam; i++) { + TRACE(("savemodes %d\n", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + DoSM(DP_DECCKM, termw->keyboard.flags & MODE_DECCKM); + break; + case 3: /* DECCOLM */ + if (screen->c132) + DoSM(DP_DECCOLM, termw->flags & IN132COLUMNS); + break; + case 4: /* DECSCLM (slow scroll) */ + DoSM(DP_DECSCLM, termw->flags & SMOOTHSCROLL); + break; + case 5: /* DECSCNM */ + DoSM(DP_DECSCNM, termw->flags & REVERSE_VIDEO); + break; + case 6: /* DECOM */ + DoSM(DP_DECOM, termw->flags & ORIGIN); + break; + + case 7: /* DECAWM */ + DoSM(DP_DECAWM, termw->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 44: /* margin bell */ + DoSM(DP_X_MARGIN, screen->marginbell); + break; + case 45: /* reverse wraparound */ + DoSM(DP_X_REVWRAP, termw->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->alternate); + 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; + case 1048: + if (!termw->misc.titeInhibit) { + CursorSave(termw); + } + 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 termw) +{ + TScreen *screen = &termw->screen; + int i, j; + + for (i = 0; i < nparam; i++) { + TRACE(("restoremodes %d\n", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + bitcpy(&termw->keyboard.flags, + screen->save_modes[DP_DECCKM], MODE_DECCKM); + update_appcursor(); + break; + case 3: /* DECCOLM */ + if (screen->c132) { + ClearScreen(screen); + CursorSet(screen, 0, 0, termw->flags); + if ((j = (screen->save_modes[DP_DECCOLM] & IN132COLUMNS) + ? 132 : 80) != ((termw->flags & IN132COLUMNS) + ? 132 : 80) || j != MaxCols(screen)) + RequestResize(termw, -1, j, True); + bitcpy(&termw->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(screen); + } else + screen->jumpscroll = 1; + bitcpy(&termw->flags, screen->save_modes[DP_DECSCLM], SMOOTHSCROLL); + update_jumpscroll(); + break; + case 5: /* DECSCNM */ + if ((screen->save_modes[DP_DECSCNM] ^ termw->flags) & REVERSE_VIDEO) { + bitcpy(&termw->flags, screen->save_modes[DP_DECSCNM], REVERSE_VIDEO); + ReverseVideo(termw); + /* update_reversevideo done in RevVid */ + } + break; + case 6: /* DECOM */ + bitcpy(&termw->flags, screen->save_modes[DP_DECOM], ORIGIN); + CursorSet(screen, 0, 0, termw->flags); + break; + + case 7: /* DECAWM */ + bitcpy(&termw->flags, screen->save_modes[DP_DECAWM], WRAPAROUND); + update_autowrap(); + break; + case 8: /* DECARM */ + /* ignore autorepeat */ + break; + case SET_X10_MOUSE: /* MIT bogus sequence */ + DoRM(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(&termw->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(screen); + else + CloseLog(screen); +#endif /* ALLOWLOGFILEONOFF */ + /* update_logging done by StartLog and CloseLog */ + break; +#endif + case 1047: /* alternate buffer */ + /* FALLTHRU */ + case 47: /* alternate buffer */ + if (!termw->misc.titeInhibit) { + if (screen->save_modes[DP_X_ALTSCRN]) + ToAlternate(screen); + else + FromAlternate(screen); + /* update_altscreen done by ToAlt and FromAlt */ + } else if (termw->misc.tiXtraScroll) { + if (screen->save_modes[DP_X_ALTSCRN]) { + xtermScroll(screen, 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: + DoRM(DP_X_MOUSE, screen->send_mouse_pos); + break; + case 1048: + if (!termw->misc.titeInhibit) { + CursorRestore(termw); + } + 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 */ + } + } +} + +/* + * Report window label (icon or title) in dtterm protocol + * ESC ] code label ESC backslash + */ +static void +report_win_label(TScreen * screen, + int code, + XTextProperty * text, + Status ok) +{ + char **list; + int length = 0; + + reply.a_type = ESC; + unparseputc(ESC, screen->respond); + unparseputc(']', screen->respond); + unparseputc(code, screen->respond); + + if (ok) { + if (XTextPropertyToStringList(text, &list, &length)) { + int n, c; + for (n = 0; n < length; n++) { + char *s = list[n]; + while ((c = *s++) != '\0') + unparseputc(c, screen->respond); + } + XFreeStringList(list); + } + if (text->value != 0) + XFree(text->value); + } + + unparseputc(ESC, screen->respond); + unparseputc('\\', screen->respond); +} + +/* + * Window operations (from CDE dtterm description, as well as extensions). + * See also "allowWindowOps" resource. + */ +static void +window_ops(XtermWidget termw) +{ + TScreen *screen = &termw->screen; + XWindowChanges values; + XWindowAttributes win_attrs; + XTextProperty text; + unsigned value_mask; + unsigned root_width; + unsigned root_height; + + TRACE(("window_ops %d\n", param[0])); + switch (param[0]) { + case 1: /* Restore (de-iconify) window */ + XMapWindow(screen->display, + VShellWindow); + break; + + case 2: /* Minimize (iconify) window */ + XIconifyWindow(screen->display, + VShellWindow, + DefaultScreen(screen->display)); + break; + + case 3: /* Move the window to the given position */ + values.x = param[1]; + values.y = param[2]; + value_mask = (CWX | CWY); + XReconfigureWMWindow(screen->display, + VShellWindow, + DefaultScreen(screen->display), + value_mask, + &values); + break; + + case 4: /* Resize the window to given size in pixels */ + RequestResize(termw, param[1], param[2], False); + break; + + case 5: /* Raise the window to the front of the stack */ + XRaiseWindow(screen->display, VShellWindow); + break; + + case 6: /* Lower the window to the bottom of the stack */ + XLowerWindow(screen->display, VShellWindow); + break; + + case 7: /* Refresh the window */ + Redraw(); + break; + + case 8: /* Resize the text-area, in characters */ + RequestResize(termw, param[1], param[2], True); + break; + +#if OPT_MAXIMIZE + case 9: /* Maximize or restore */ + RequestMaximize(termw, param[1]); + break; +#endif + + case 11: /* Report the window's state */ + XGetWindowAttributes(screen->display, + VWindow(screen), + &win_attrs); + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 1; + reply.a_param[0] = (win_attrs.map_state == IsViewable) ? 1 : 2; + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 13: /* Report the window's position */ + XGetWindowAttributes(screen->display, + WMFrameWindow(termw), + &win_attrs); + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 3; + reply.a_param[1] = win_attrs.x; + reply.a_param[2] = win_attrs.y; + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 14: /* Report the window's size in pixels */ + XGetWindowAttributes(screen->display, + VWindow(screen), + &win_attrs); + reply.a_type = 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] = Height(screen); + reply.a_param[2] = Width(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 18: /* Report the text's size in characters */ + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 8; + reply.a_param[1] = MaxRows(screen); + reply.a_param[2] = MaxCols(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + +#if OPT_MAXIMIZE + case 19: /* Report the screen's size, in characters */ + if (!QueryMaximize(term, &root_height, &root_width)) { + root_height = 0; + root_width = 0; + } + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 9; + reply.a_param[1] = root_height / FontHeight(screen); + reply.a_param[2] = root_width / FontWidth(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; +#endif + + case 20: /* Report the icon's label */ + report_win_label(screen, 'L', &text, + XGetWMIconName(screen->display, VShellWindow, &text)); + break; + + case 21: /* Report the window's title */ + report_win_label(screen, 'l', &text, + XGetWMName(screen->display, VShellWindow, &text)); + break; + + default: /* DECSLPP (24, 25, 36, 48, 72, 144) */ + if (param[0] >= 24) + RequestResize(termw, 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(int c, int fd) +{ + if (c >= 0x80 && c <= 0x9F) { + if (!term->screen.control_eight_bits) { + unparseputc(A2E(ESC), fd); + c = A2E(c - 0x40); + } + } + unparseputc(c, fd); +} + +void +unparseseq(ANSI * ap, int fd) +{ + int c; + int i; + int inters; + + unparseputc1(c = ap->a_type, fd); + if (c == ESC + || c == DCS + || c == CSI + || c == OSC + || c == PM + || c == APC + || c == SS3) { + if (ap->a_pintro != 0) + unparseputc(ap->a_pintro, fd); + for (i = 0; i < ap->a_nparam; ++i) { + if (i != 0) + unparseputc(';', fd); + unparseputn((unsigned int) ap->a_param[i], fd); + } + if ((inters = ap->a_inters) != 0) { + for (i = 3; i >= 0; --i) { + c = CharOf(inters >> (8 * i)); + if (c != 0) + unparseputc(c, fd); + } + } + unparseputc((char) ap->a_final, fd); + } +} + +static void +unparseputn(unsigned int n, int fd) +{ + unsigned int q; + + q = n / 10; + if (q != 0) + unparseputn(q, fd); + unparseputc((char) ('0' + (n % 10)), fd); +} + +void +unparseputc(int c, int fd) +{ + IChar buf[2]; + unsigned i = 1; + +#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 (term->screen.tc_query >= 0) { + char tmp[3]; + sprintf(tmp, "%02X", c & 0xFF); + buf[0] = tmp[0]; + buf[1] = tmp[1]; + i = 2; + } else +#endif + if ((buf[0] = c) == '\r' && (term->flags & LINEFEED)) { + buf[1] = '\n'; + i++; + } +#ifdef VMS + tt_write(&buf, i); +#else /* VMS */ + writePtyData(fd, buf, i); +#endif /* VMS */ + + /* If send/receive mode is reset, we echo characters locally */ + if ((term->keyboard.flags & MODE_SRM) == 0) { + (void) doparsing((unsigned) c, &myState); + } +} + +void +unparseputs(char *s, int fd) +{ + while (*s) + unparseputc(*s++, fd); +} + +void +ToggleAlternate(TScreen * screen) +{ + if (screen->alternate) + FromAlternate(screen); + else + ToAlternate(screen); +} + +static void +ToAlternate(TScreen * screen) +{ + if (screen->alternate) + return; + TRACE(("ToAlternate\n")); + if (!screen->altbuf) + screen->altbuf = Allocate(MaxRows(screen), MaxCols(screen), + &screen->abuf_address); + SwitchBufs(screen); + screen->alternate = True; + update_altscreen(); +} + +static void +FromAlternate(TScreen * screen) +{ + if (!screen->alternate) + return; + TRACE(("FromAlternate\n")); + if (screen->scroll_amt) + FlushScroll(screen); + screen->alternate = False; + SwitchBufs(screen); + update_altscreen(); +} + +static void +SwitchBufs(TScreen * screen) +{ + int rows, top; + + if (screen->cursor_state) + HideCursor(); + + rows = MaxRows(screen); + SwitchBufPtrs(screen); + + if ((top = -screen->topline) < rows) { + if (screen->scroll_amt) + FlushScroll(screen); + if (top == 0) + XClearWindow(screen->display, VWindow(screen)); + else + XClearArea(screen->display, + VWindow(screen), + (int) OriginX(screen), + (int) top * FontHeight(screen) + screen->border, + (unsigned) Width(screen), + (unsigned) (rows - top) * FontHeight(screen), + False); + } + ScrnUpdate(screen, 0, 0, rows, MaxCols(screen), False); +} + +/* swap buffer line pointers between alt and regular screens */ +void +SwitchBufPtrs(TScreen * screen) +{ + size_t len = ScrnPointers(screen, (unsigned) MaxRows(screen)); + + memcpy((char *) screen->save_ptr, (char *) screen->visbuf, len); + memcpy((char *) screen->visbuf, (char *) screen->altbuf, len); + memcpy((char *) screen->altbuf, (char *) screen->save_ptr, len); +} + +void +VTRun(void) +{ + TScreen *screen = &term->screen; + + TRACE(("VTRun ...\n")); + + if (!screen->Vshow) { + set_vt_visibility(True); + } + update_vttekmode(); + update_vtshow(); + update_tekshow(); + set_vthide_sensitivity(); + + if (screen->allbuf == NULL) + VTallocbuf(); + + 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(screen, VTbuffer, (char *) Tpushback, Tpushb - Tpushback); + Tpushb = Tpushback; + } +#endif + if (!setjmp(VTend)) + VTparse(); + StopBlinking(screen); + HideCursor(); + screen->cursor_set = OFF; +} + +/*ARGSUSED*/ +static void +VTExpose(Widget w GCC_UNUSED, + XEvent * event, + Region region GCC_UNUSED) +{ + TScreen *screen = &term->screen; + +#ifdef DEBUG + if (debug) + fputs("Expose\n", stderr); +#endif /* DEBUG */ + if (event->type == Expose) + HandleExposure(screen, event); +} + +static void +VTGraphicsOrNoExpose(XEvent * event) +{ + TScreen *screen = &term->screen; + if (screen->incopy <= 0) { + screen->incopy = 1; + if (screen->scrolls > 0) + screen->scrolls--; + } + if (event->type == GraphicsExpose) + if (HandleExposure(screen, 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)) { + ScreenResize(&term->screen, term->core.width, term->core.height, &term->flags); + } +} + +#define okDimension(src,dst) ((src <= 32767) && ((dst = src) == src)) + +static void +RequestResize(XtermWidget termw, int rows, int cols, int text) +{ +#ifndef nothack + XSizeHints sizehints; + long supp; +#endif + TScreen *screen = &termw->screen; + 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 ((askedWidth = cols) < cols + || (askedHeight = rows) < rows) + return; + + if (askedHeight == 0 + || askedWidth == 0 + || term->misc.limit_resize > 0) { + XGetWindowAttributes(XtDisplay(termw), + RootWindowOfScreen(XtScreen(termw)), &attrs); + } + + if (text) { + if ((value = rows) != 0) { + if (rows < 0) + value = MaxRows(screen); + value *= FontHeight(screen); + value += (2 * screen->border); + if (!okDimension(value, askedHeight)) + return; + } + + if ((value = cols) != 0) { + if (cols < 0) + value = MaxCols(screen); + value *= FontWidth(screen); + value += (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 = attrs.height; + if (cols == 0) + askedWidth = attrs.width; + + if (term->misc.limit_resize > 0) { + Dimension high = term->misc.limit_resize * attrs.height; + Dimension wide = term->misc.limit_resize * attrs.width; + if (high < attrs.height) + high = attrs.height; + if (askedHeight > high) + askedHeight = high; + if (wide < attrs.width) + wide = attrs.width; + if (askedWidth > wide) + askedWidth = wide; + } +#ifndef nothack + if (!XGetWMNormalHints(screen->display, VShellWindow, + &sizehints, &supp)) + bzero(&sizehints, sizeof(sizehints)); +#endif + + status = XtMakeResizeRequest((Widget) termw, + askedWidth, askedHeight, + &replyWidth, &replyHeight); + TRACE(("charproc.c XtMakeResizeRequest %dx%d -> %dx%d (status %d)\n", + askedHeight, askedWidth, + replyHeight, replyWidth, + status)); + + if (status == XtGeometryYes || + status == XtGeometryDone) { + ScreenResize(&termw->screen, + replyWidth, + replyHeight, + &termw->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 (sizehints.flags + && replyHeight + && replyWidth) { + sizehints.height = replyHeight; + sizehints.width = replyWidth; + + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_HINTS(&sizehints); + XSetWMNormalHints(screen->display, VShellWindow, &sizehints); + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_WM_HINTS(termw); + } +#endif + + XSync(screen->display, False); /* synchronize */ + if (XtAppPending(app_con)) + xevents(); +} + +static String xterm_trans = +"WM_PROTOCOLS: DeleteWindow()\n\ + : KeyboardMapping()\n"; + +int +VTInit(void) +{ + TScreen *screen = &term->screen; + Widget vtparent = SHELL_OF(term); + + 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) (term)); + + if (screen->allbuf == NULL) + VTallocbuf(); + return (1); +} + +static void +VTallocbuf(void) +{ + TScreen *screen = &term->screen; + int nrows = MaxRows(screen); + + /* allocate screen buffer now, if necessary. */ + if (screen->scrollWidget) + nrows += screen->savelines; + screen->allbuf = Allocate(nrows, MaxCols(screen), + &screen->sbuf_address); + if (screen->scrollWidget) + screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; + else + screen->visbuf = screen->allbuf; + return; +} + +static void +VTClassInit(void) +{ + XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity, + (XtConvertArgList) NULL, (Cardinal) 0); +} + +/* + * 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_Dres(name) \ + TRACE(("init " #name " = %f\n", \ + wnew->name = request->name)) +#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 : "")) +#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_Dres(name) wnew->name = request->name +#define init_Ires(name) wnew->name = request->name +#define init_Sres(name) wnew->name = x_strtrim(request->name) +#define init_Tres(offset) fill_Tres(wnew, request, offset) +#endif + +#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; + + target->screen.Tcolors[offset] = source->screen.Tcolors[offset]; + target->screen.Tcolors[offset].mode = False; + + if ((name = x_strtrim(target->screen.Tcolors[offset].resource)) != 0) + target->screen.Tcolors[offset].resource = name; + + if (name == 0) { + target->screen.Tcolors[offset].value = target->dft_foreground; + } else if (!x_strcasecmp(name, XtDefaultForeground)) { + target->screen.Tcolors[offset].value = + ((offset == TEXT_FG || offset == TEXT_BG) + ? target->dft_foreground + : target->screen.Tcolors[TEXT_FG].value); + } else if (!x_strcasecmp(name, XtDefaultBackground)) { + target->screen.Tcolors[offset].value = + ((offset == TEXT_FG || offset == TEXT_BG) + ? target->dft_background + : target->screen.Tcolors[TEXT_BG].value); + } else { + if (AllocateTermColor(target, &temp, offset, name)) { + target->screen.Tcolors[offset].value = temp.colors[offset]; + } + } + return target->screen.Tcolors[offset].value; +} +#else +#define fill_Tres(target, source, offset) \ + target->screen.Tcolors[offset] = source->screen.Tcolors[offset] +#endif + +#if OPT_WIDE_CHARS +static void +VTInitialize_locale(XtermWidget request) +{ + Bool is_utf8 = xtermEnvUTF8(); + + TRACE(("VTInitialize_locale\n")); + TRACE(("... request screen.utf8_mode = %d\n", request->screen.utf8_mode)); + + if (request->screen.utf8_mode < 0) + request->screen.utf8_mode = uFalse; + + if (request->screen.utf8_mode > 3) + request->screen.utf8_mode = uDefault; + + request->screen.latin9_mode = 0; + request->screen.unicode_font = 0; +#if OPT_LUIT_PROG + request->misc.callfilter = 0; + request->misc.use_encoding = 0; + + TRACE(("... setup for luit:\n")); + TRACE(("... request misc.locale_str = \"%s\"\n", request->misc.locale_str)); + + if (request->screen.utf8_mode == uFalse) { + TRACE(("... command-line +u8 overrides\n")); + } else +#if OPT_MINI_LUIT + if (x_strcasecmp(request->misc.locale_str, "CHECKFONT") == 0) { + int fl = (request->misc.default_font.f_n + ? strlen(request->misc.default_font.f_n) + : 0); + if (fl > 11 + && x_strcasecmp(request->misc.default_font.f_n + fl - 11, + "-ISO10646-1") == 0) { + request->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 (request->screen.utf8_mode == uDefault) + request->screen.utf8_mode = uFalse; + } else if (!strcmp(xtermEnvEncoding(), "ISO-8859-15")) { + if (request->screen.utf8_mode == uDefault) + request->screen.utf8_mode = uFalse; + request->screen.latin9_mode = 1; + } else { + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; + } +#else + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; +#endif + } else { + /* other encoding, use False */ + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } + } + } else +#endif /* OPT_MINI_LUIT */ + if (x_strcasecmp(request->misc.locale_str, "TRUE") == 0 || + x_strcasecmp(request->misc.locale_str, "ON") == 0 || + x_strcasecmp(request->misc.locale_str, "YES") == 0 || + x_strcasecmp(request->misc.locale_str, "AUTO") == 0 || + strcmp(request->misc.locale_str, "1") == 0) { + /* when true ... fully obeying LC_CTYPE locale */ + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; + } else if (x_strcasecmp(request->misc.locale_str, "FALSE") == 0 || + x_strcasecmp(request->misc.locale_str, "OFF") == 0 || + x_strcasecmp(request->misc.locale_str, "NO") == 0 || + strcmp(request->misc.locale_str, "0") == 0) { + /* when false ... original value of utf8_mode is effective */ + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } + } else if (x_strcasecmp(request->misc.locale_str, "MEDIUM") == 0 || + x_strcasecmp(request->misc.locale_str, "SEMIAUTO") == 0) { + /* when medium ... obeying locale only for UTF-8 and Asian */ + if (is_utf8) { + request->screen.utf8_mode = uAlways; + } else if ( +#ifdef MB_CUR_MAX + MB_CUR_MAX > 1 || +#else + !strncmp(xtermEnvLocale(), "ja", 2) || + !strncmp(xtermEnvLocale(), "ko", 2) || + !strncmp(xtermEnvLocale(), "zh", 2) || +#endif + !strncmp(xtermEnvLocale(), "th", 2) || + !strncmp(xtermEnvLocale(), "vi", 2)) { + request->misc.callfilter = 1; + request->screen.utf8_mode = uAlways; + } else { + request->screen.utf8_mode = uFalse; + } + } else if (x_strcasecmp(request->misc.locale_str, "UTF-8") == 0 || + x_strcasecmp(request->misc.locale_str, "UTF8") == 0) { + /* when UTF-8 ... UTF-8 mode */ + request->screen.utf8_mode = uAlways; + } else { + /* other words are regarded as encoding name passed to luit */ + request->misc.callfilter = 1; + request->screen.utf8_mode = uAlways; + request->misc.use_encoding = 1; + } + TRACE(("... updated misc.callfilter = %s\n", BtoS(request->misc.callfilter))); + TRACE(("... updated misc.use_encoding = %s\n", BtoS(request->misc.use_encoding))); +#else + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } +#endif /* OPT_LUIT_PROG */ + + request->screen.utf8_inparse = (request->screen.utf8_mode != uFalse); + + TRACE(("... updated screen.utf8_mode = %d\n", request->screen.utf8_mode)); + TRACE(("...VTInitialize_locale done\n")); +} +#endif + +/* ARGSUSED */ +static void +VTInitialize(Widget wrequest, + Widget new_arg, + ArgList args GCC_UNUSED, + Cardinal *num_args GCC_UNUSED) +{ + XtermWidget request = (XtermWidget) wrequest; + XtermWidget wnew = (XtermWidget) new_arg; + Widget my_parent = SHELL_OF(wnew); + int i; + char *s; + +#if OPT_ISO_COLORS + Bool color_ok; +#endif + +#if OPT_COLOR_RES2 && (MAXCOLORS > MIN_ANSI_COLORS) + 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\n")); + + /* 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. + */ + bzero((char *) &wnew->screen, sizeof(wnew->screen)); + + /* 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. + */ + wnew->screen.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(wnew->screen.display); + wnew->dft_background = MyBlackPixel(wnew->screen.display); + } else { + wnew->dft_foreground = MyBlackPixel(wnew->screen.display); + wnew->dft_background = MyWhitePixel(wnew->screen.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(&(wnew->screen), TEXT_FG))); + TRACE((" Screen background %#lx\n", T_COLOR(&(wnew->screen), TEXT_BG))); + + wnew->screen.mouse_button = -1; + wnew->screen.mouse_row = -1; + wnew->screen.mouse_col = -1; + +#if OPT_BOX_CHARS + init_Bres(screen.force_box_chars); + 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); + wnew->screen.cursor_blink_res = wnew->screen.cursor_blink; +#endif +#if OPT_BLINK_TEXT + init_Ires(screen.blink_as_bold); +#endif + init_Ires(screen.border); + init_Bres(screen.jumpscroll); + init_Bres(screen.old_fkeys); + init_Bres(screen.delete_is_del); + wnew->keyboard.type = wnew->screen.old_fkeys + ? keyboardIsLegacy + : keyboardIsDefault; +#ifdef ALLOWLOGGING + init_Sres(screen.logfile); +#endif + 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_Sres(screen.term_id); + for (s = request->screen.term_id; *s; s++) { + if (!isalpha(CharOf(*s))) + break; + } + wnew->screen.terminal_id = atoi(s); + if (wnew->screen.terminal_id < MIN_DECID) + wnew->screen.terminal_id = MIN_DECID; + if (wnew->screen.terminal_id > MAX_DECID) + wnew->screen.terminal_id = MAX_DECID; + TRACE(("term_id '%s' -> terminal_id %d\n", + wnew->screen.term_id, + wnew->screen.terminal_id)); + + wnew->screen.vtXX_level = (wnew->screen.terminal_id / 100); + 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_left = 0; + wnew->misc.alt_right = 0; + wnew->misc.meta_trans = False; + wnew->misc.meta_left = 0; + wnew->misc.meta_right = 0; +#endif +#if OPT_SHIFT_FONTS + init_Bres(misc.shift_fonts); +#endif +#if OPT_SUNPC_KBD + init_Ires(misc.ctrl_fkeys); +#endif +#if OPT_TEK4014 + init_Bres(misc.tekInhibit); + init_Bres(misc.tekSmall); + init_Bres(screen.TekEmu); +#endif +#if OPT_TCAP_QUERY + wnew->screen.tc_query = -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.cutNewline); + init_Bres(screen.cutToBeginningOfLine); + init_Bres(screen.highlight_selection); + init_Bres(screen.trim_selection); + init_Bres(screen.i18nSelections); + init_Bres(screen.brokenSelections); + init_Bres(screen.always_highlight); + wnew->screen.pointer_cursor = request->screen.pointer_cursor; + + 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_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.meta_sends_esc); + + init_Bres(screen.allowSendEvent0); + init_Bres(screen.allowWindowOp0); + + /* make a copy so that editres cannot change the resource after startup */ + wnew->screen.allowSendEvents = wnew->screen.allowSendEvent0; + wnew->screen.allowWindowOps = wnew->screen.allowWindowOp0; + +#ifndef NO_ACTIVE_ICON + wnew->screen.fnt_icon = request->screen.fnt_icon; + 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.titeInhibit); + init_Bres(misc.tiXtraScroll); + init_Bres(misc.dynamicColors); + for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) { + init_Sres(screen.MenuFontName(i)); + } + /* set default in realize proc */ + wnew->screen.MenuFontName(fontMenu_fontdefault) = NULL; + wnew->screen.MenuFontName(fontMenu_fontescape) = NULL; + wnew->screen.MenuFontName(fontMenu_fontsel) = NULL; + wnew->screen.menu_font_number = fontMenu_fontdefault; + +#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_DEC_CHRSET + init_Bres(screen.font_doublesize); + init_Ires(screen.cache_doublesize); + if (wnew->screen.cache_doublesize > NUM_CHRSET) + wnew->screen.cache_doublesize = NUM_CHRSET; + if (wnew->screen.cache_doublesize == 0) + wnew->screen.font_doublesize = False; + TRACE(("Doublesize%s enabled, up to %d fonts\n", + wnew->screen.font_doublesize ? "" : " not", + wnew->screen.cache_doublesize)); +#endif + +#if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS + wnew->num_ptrs = (OFF_ATTRS + 1); /* OFF_FLAGS, OFF_CHARS, OFF_ATTRS */ +#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); + + for (i = 0, color_ok = False; i < MAXCOLORS; i++) { + +#if OPT_COLOR_RES2 && (MAXCOLORS > MIN_ANSI_COLORS) + /* + * 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) { + wnew->screen.Acolors[i].resource + = ((char *) fake_resources[i - MIN_ANSI_COLORS].default_addr); + if (wnew->screen.Acolors[i].resource == 0) + wnew->screen.Acolors[i].resource = XtDefaultForeground; + } else +#endif /* OPT_COLOR_RES2 */ + wnew->screen.Acolors[i] = request->screen.Acolors[i]; + +#if OPT_COLOR_RES + TRACE(("Acolors[%d] = %s\n", i, wnew->screen.Acolors[i].resource)); + wnew->screen.Acolors[i].mode = False; + if (!x_strcasecmp(wnew->screen.Acolors[i].resource, XtDefaultForeground)) { + wnew->screen.Acolors[i].value = T_COLOR(&(wnew->screen), TEXT_FG); + wnew->screen.Acolors[i].mode = True; + } else if (!x_strcasecmp(wnew->screen.Acolors[i].resource, XtDefaultBackground)) { + wnew->screen.Acolors[i].value = T_COLOR(&(wnew->screen), TEXT_BG); + wnew->screen.Acolors[i].mode = True; + } else { + color_ok = True; + } +#else + TRACE(("Acolors[%d] = %#lx\n", i, request->screen.Acolors[i])); + if (wnew->screen.Acolors[i] != wnew->dft_foreground && + wnew->screen.Acolors[i] != T_COLOR(&(wnew->screen), TEXT_FG) && + wnew->screen.Acolors[i] != T_COLOR(&(wnew->screen), 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 = wnew->screen.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) { + wnew->screen.colorMode = False; + TRACE(("All colors are foreground or background: disable colorMode\n")); + } +#if OPT_EXT_COLORS + wnew->num_ptrs = (OFF_BGRND + 1); +#else + wnew->num_ptrs = (OFF_COLOR + 1); +#endif + wnew->sgr_foreground = -1; + wnew->sgr_background = -1; + wnew->sgr_extended = 0; +#endif /* OPT_ISO_COLORS */ + + init_Tres(MOUSE_FG); + init_Tres(MOUSE_BG); + init_Tres(TEXT_CURSOR); +#if OPT_HIGHLIGHT_COLOR + init_Tres(HIGHLIGHT_BG); +#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. + */ + T_COLOR(&(wnew->screen), TEK_BG) = T_COLOR(&(wnew->screen), TEXT_BG); + T_COLOR(&(wnew->screen), TEK_FG) = T_COLOR(&(wnew->screen), TEXT_FG); + T_COLOR(&(wnew->screen), TEK_CURSOR) = T_COLOR(&(wnew->screen), TEXT_CURSOR); +#endif + +#if OPT_DEC_CHRSET + wnew->num_ptrs = (OFF_CSETS + 1); +#endif + +#if OPT_WIDE_CHARS + VTInitialize_locale(request); + +#if OPT_LUIT_PROG + init_Bres(misc.callfilter); + init_Bres(misc.use_encoding); + init_Sres(misc.locale_str); + init_Sres(misc.localefilter); +#endif + +#if OPT_RENDERFONT + init_Dres(misc.face_size); + init_Sres(misc.face_name); + init_Sres(misc.face_wide_name); + init_Bres(misc.render_font); + /* minor tweak to make debug traces consistent: */ + if (wnew->misc.render_font) { + if (wnew->misc.face_name == 0) { + wnew->misc.render_font = False; + TRACE(("reset render_font since there is no face_name\n")); + } + } +#endif + + init_Bres(screen.vt100_graphics); + init_Ires(screen.utf8_mode); + init_Bres(screen.wide_chars); + init_Bres(misc.mk_width); + init_Bres(misc.cjk_width); + if (request->screen.utf8_mode) { + TRACE(("setting wide_chars on\n")); + wnew->screen.wide_chars = True; + } else { + TRACE(("setting utf8_mode to 0\n")); + wnew->screen.utf8_mode = uFalse; + } + TRACE(("initialized UTF-8 mode to %d\n", wnew->screen.utf8_mode)); + +#if OPT_MINI_LUIT + if (request->screen.latin9_mode) { + wnew->screen.latin9_mode = True; + } + if (request->screen.unicode_font) { + wnew->screen.unicode_font = True; + } + TRACE(("initialized Latin9 mode to %d\n", wnew->screen.latin9_mode)); + TRACE(("initialized unicode_font to %d\n", wnew->screen.unicode_font)); +#endif + + if (wnew->screen.wide_chars != False) + wnew->num_ptrs = (OFF_COM2H + 1); + + decode_wcwidth((wnew->misc.cjk_width ? 2 : 0) + + (wnew->misc.mk_width ? 1 : 0) + + 1); +#endif /* OPT_WIDE_CHARS */ + + init_Bres(screen.bold_mode); + init_Bres(screen.underline); + + wnew->cur_foreground = 0; + wnew->cur_background = 0; + + wnew->keyboard.flags = MODE_SRM; + if (wnew->screen.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. + */ + 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 (zIconBeep) +#endif + XtAddEventHandler(my_parent, StructureNotifyMask, False, + HandleStructNotify, (Opaque) 0); +#endif /* HANDLE_STRUCT_NOTIFY */ + + wnew->screen.bellInProgress = False; + + set_character_class(wnew->screen.charClass); + + /* create it, but don't realize it */ + ScrollBarOn(wnew, True, False); + + /* make sure that the resize gravity acceptable */ + if (wnew->misc.resizeGravity != NorthWestGravity && + wnew->misc.resizeGravity != SouthWestGravity) { + Cardinal nparams = 1; + + XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError", + "unsupported resizeGravity resource value (%d)", + (String *) & (wnew->misc.resizeGravity), &nparams); + wnew->misc.resizeGravity = SouthWestGravity; + } +#ifndef NO_ACTIVE_ICON + wnew->screen.whichVwin = &wnew->screen.fullVwin; +#if OPT_TEK4014 + wnew->screen.whichTwin = &wnew->screen.fullTwin; +#endif +#endif /* NO_ACTIVE_ICON */ + + if (wnew->screen.savelines < 0) + wnew->screen.savelines = 0; + + init_Bres(screen.awaitInput); + + wnew->flags = 0; + if (!wnew->screen.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 (wnew->screen.c132) + wnew->flags |= IN132COLUMNS; + + wnew->initflags = wnew->flags; + + init_Ires(keyboard.modify_cursor_keys); + + 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; + + return; +} + +static void +VTDestroy(Widget w) +{ + XtFree((char *) (((XtermWidget) w)->screen.selection_data)); +} + +/*ARGSUSED*/ +static void +VTRealize(Widget w, + XtValueMask * valuemask, + XSetWindowAttributes * values) +{ + XtermWidget xw = (XtermWidget) w; + TScreen *screen = &xw->screen; + + unsigned width, height; + int xpos, ypos, pr; + XSizeHints sizehints; + Atom pid_atom; + + TRACE(("VTRealize\n")); + + TabReset(xw->tabs); + + screen->MenuFontName(fontMenu_fontdefault) = xw->misc.default_font.f_n; + screen->fnt_norm = NULL; + screen->fnt_bold = NULL; +#if OPT_WIDE_CHARS + screen->fnt_dwd = NULL; + screen->fnt_dwdb = NULL; +#endif + if (!xtermLoadFont(xw, + &(xw->misc.default_font), + False, 0)) { + if (XmuCompareISOLatin1(xw->misc.default_font.f_n, "fixed") != 0) { + fprintf(stderr, + "%s: unable to open font \"%s\", trying \"fixed\"....\n", + xterm_name, xw->misc.default_font.f_n); + (void) xtermLoadFont(xw, + xtermFontName("fixed"), + False, 0); + screen->MenuFontName(fontMenu_fontdefault) = "fixed"; + } + } + + /* really screwed if we couldn't open default font */ + if (!screen->fnt_norm) { + fprintf(stderr, "%s: unable to locate a suitable font\n", + xterm_name); + Exit(1); + } +#if OPT_WIDE_CHARS + if (xw->screen.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->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)) + - width - (BorderWidth(XtParent(xw)) * 2); + } + if ((pr & YValue) && (YNegative & pr)) { + ypos += DisplayHeight(screen->display, DefaultScreen(screen->display)) + - height - (BorderWidth(XtParent(xw)) * 2); + } + + /* set up size hints for window manager; min 1 char by 1 char */ + bzero(&sizehints, sizeof(sizehints)); + xtermSizeHints(xw, &sizehints, (xw->misc.scrollbar + ? (screen->scrollWidget->core.width + + BorderWidth(screen->scrollWidget)) + : 0)); + + sizehints.x = xpos; + sizehints.y = ypos; + if ((XValue & pr) || (YValue & pr)) { + sizehints.flags |= USSize | USPosition; + sizehints.flags |= PWinGravity; + switch (pr & (XNegative | YNegative)) { + case 0: + sizehints.win_gravity = NorthWestGravity; + break; + case XNegative: + sizehints.win_gravity = NorthEastGravity; + break; + case YNegative: + sizehints.win_gravity = SouthWestGravity; + break; + default: + sizehints.win_gravity = SouthEastGravity; + break; + } + } else { + /* set a default size, but do *not* set position */ + sizehints.flags |= PSize; + } + sizehints.height = sizehints.base_height + + sizehints.height_inc * MaxRows(screen); + sizehints.width = sizehints.base_width + + sizehints.width_inc * MaxCols(screen); + + if ((WidthValue & pr) || (HeightValue & pr)) + sizehints.flags |= USSize; + else + sizehints.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. + */ + TRACE(("make resize request %dx%d\n", height, width)); + (void) XtMakeResizeRequest((Widget) xw, + (Dimension) width, (Dimension) height, + &xw->core.width, &xw->core.height); + TRACE(("...made resize request %dx%d\n", xw->core.height, xw->core.width)); + + /* 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 (sizehints.flags & USPosition) + XMoveWindow(XtDisplay(xw), XtWindow(SHELL_OF(xw)), + sizehints.x, sizehints.y); + + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_HINTS(&sizehints); + XSetWMNormalHints(XtDisplay(xw), XtWindow(SHELL_OF(xw)), &sizehints); + 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, + 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 = ((xw->misc.resizeGravity == NorthWestGravity) + ? NorthWestGravity + : ForgetGravity); + xw->screen.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 + if (xw->misc.active_icon && screen->fnt_icon) { + int iconX = 0, iconY = 0; + Widget shell = SHELL_OF(xw); + unsigned long mask; + XGCValues xgcv; + + TRACE(("Initializing active-icon\n")); + XtVaGetValues(shell, XtNiconX, &iconX, XtNiconY, &iconY, (XtPointer) 0); + xtermComputeFontInfo(xw, &(screen->iconVwin), screen->fnt_icon, 0); + + /* 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); + + mask = (GCFont | GCForeground | GCBackground | + GCGraphicsExposures | GCFunction); + + xgcv.font = screen->fnt_icon->fid; + xgcv.foreground = T_COLOR(screen, TEXT_FG); + xgcv.background = T_COLOR(screen, TEXT_BG); + xgcv.graphics_exposures = True; /* default */ + xgcv.function = GXcopy; + + screen->iconVwin.normalGC = + screen->iconVwin.normalboldGC = + XtGetGC(shell, mask, &xgcv); + + xgcv.foreground = T_COLOR(screen, TEXT_BG); + xgcv.background = T_COLOR(screen, TEXT_FG); + + screen->iconVwin.reverseGC = + screen->iconVwin.reverseboldGC = + XtGetGC(shell, mask, &xgcv); +#if OPT_TOOLBAR + /* + * Toolbar is initialized before we get here. Enable the menu item + * and set it properly. + */ + set_sensitivity(mw, + 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(); +#else + xw->screen.xic = NULL; +#endif +#if OPT_NUM_LOCK + VTInitModifiers(); +#endif + + set_cursor_gcs(screen); + + /* Reset variables used by ANSI emulation. */ + + resetCharsets(screen); + + XDefineCursor(screen->display, VShellWindow, 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 = screen->allbuf = NULL; + + screen->do_wrap = 0; + screen->scrolls = screen->incopy = 0; + xtermSetCursorBox(screen); + + screen->savedlines = 0; + + if (xw->misc.scrollbar) { + screen->fullVwin.sb_info.width = 0; + ScrollBarOn(xw, False, True); + } + CursorSave(xw); + 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(); +} + +static void +xim_destroy_cb(XIM im GCC_UNUSED, + XPointer client_data GCC_UNUSED, + XPointer call_data GCC_UNUSED) +{ + term->screen.xic = NULL; + + XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL, + xim_instantiate_cb, NULL); +} +#endif /* X11R6+ */ + +static void +xim_real_init(void) +{ + unsigned i, j; + char *p, *s, *t, *ns, *end, buf[32]; + XIMStyles *xim_styles; + XIMStyle input_style = 0; + Bool found; + static struct { + char *name; + unsigned long code; + } known_style[] = { + { + "OverTheSpot", (XIMPreeditPosition | XIMStatusNothing) + }, + { + "OffTheSpot", (XIMPreeditArea | XIMStatusArea) + }, + { + "Root", (XIMPreeditNothing | XIMStatusNothing) + }, + }; + + term->screen.xic = NULL; + + if (term->misc.cannot_im) { + return; + } + + if (!term->misc.input_method || !*term->misc.input_method) { + if ((p = XSetLocaleModifiers("")) != NULL && *p) + term->screen.xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); + } else { + s = term->misc.input_method; + i = 5 + strlen(s); + t = (char *) MyStackAlloc(i, buf); + if (t == NULL) + SysError(ERROR_VINIT); + + 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, (unsigned) (end - s)); + + if ((p = XSetLocaleModifiers(t)) != 0 && *p + && (term->screen.xim = XOpenIM(XtDisplay(term), + NULL, + NULL, + NULL)) != 0) + break; + + } + s = ns + 1; + } + MyStackFree(t, buf); + } + + if (term->screen.xim == NULL + && (p = XSetLocaleModifiers("@im=none")) != NULL + && *p) { + term->screen.xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); + } + + if (!term->screen.xim) { + fprintf(stderr, "Failed to open input method\n"); + return; + } + TRACE(("VTInitI18N opened input method\n")); + + if (XGetIMValues(term->screen.xim, XNQueryInputStyle, &xim_styles, NULL) + || !xim_styles + || !xim_styles->count_styles) { + fprintf(stderr, "input method doesn't support any style\n"); + XCloseIM(term->screen.xim); + term->misc.cannot_im = True; + return; + } + + found = False; + for (s = term->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", 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, (unsigned) (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", + term->misc.preedit_type); + XCloseIM(term->screen.xim); + term->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"); + XCloseIM(term->screen.xim); + term->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; + + term->screen.fs = XCreateFontSet(XtDisplay(term), + term->misc.f_x, + &missing_charset_list, + &missing_charset_count, + &def_string); + if (term->screen.fs == NULL) { + fprintf(stderr, "Preparation of font set " + "\"%s\" for XIM failed.\n", term->misc.f_x); + term->screen.fs = XCreateFontSet(XtDisplay(term), + DEFXIMFONT, + &missing_charset_list, + &missing_charset_count, + &def_string); + } + if (term->screen.fs == NULL) { + fprintf(stderr, "Preparation of default font set " + "\"%s\" for XIM failed.\n", DEFXIMFONT); + XCloseIM(term->screen.xim); + term->misc.cannot_im = True; + return; + } + (void) XExtentsOfFontSet(term->screen.fs); + j = XFontsOfFontSet(term->screen.fs, &fonts, &font_name_list); + for (i = 0, term->screen.fs_ascent = 0; i < j; i++) { + if (term->screen.fs_ascent < (*fonts)->ascent) + term->screen.fs_ascent = (*fonts)->ascent; + } + p_list = XVaCreateNestedList(0, + XNSpotLocation, &spot, + XNFontSet, term->screen.fs, + NULL); + term->screen.xic = XCreateIC(term->screen.xim, + XNInputStyle, input_style, + XNClientWindow, XtWindow(term), + XNFocusWindow, XtWindow(term), + XNPreeditAttributes, p_list, + NULL); + } else { + term->screen.xic = XCreateIC(term->screen.xim, XNInputStyle, input_style, + XNClientWindow, XtWindow(term), + XNFocusWindow, XtWindow(term), + NULL); + } + + if (!term->screen.xic) { + fprintf(stderr, "Failed to create input context\n"); + XCloseIM(term->screen.xim); + } +#if defined(USE_XIM_INSTANTIATE_CB) + else { + XIMCallback destroy_cb; + + destroy_cb.callback = xim_destroy_cb; + destroy_cb.client_data = NULL; + if (XSetIMValues(term->screen.xim, XNDestroyCallback, &destroy_cb, NULL)) + fprintf(stderr, "Could not set destroy callback to IM\n"); + } +#endif + + return; +} + +static void +VTInitI18N(void) +{ + if (term->misc.open_im) { + xim_real_init(); + +#if defined(USE_XIM_INSTANTIATE_CB) + if (term->screen.xic == NULL && !term->misc.cannot_im) { + sleep(3); + XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL, + xim_instantiate_cb, NULL); + } +#endif + } +} +#endif /* OPT_I18N_SUPPORT && OPT_INPUT_METHOD */ + +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; + Bool refresh_needed = False; + Bool fonts_redone = False; + + if ((T_COLOR(&(curvt->screen), TEXT_BG) != + T_COLOR(&(newvt->screen), TEXT_BG)) || + (T_COLOR(&(curvt->screen), TEXT_FG) != + T_COLOR(&(newvt->screen), TEXT_FG)) || + (curvt->screen.MenuFontName(curvt->screen.menu_font_number) != + newvt->screen.MenuFontName(newvt->screen.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) + newvt->screen.MenuFontName(fontMenu_fontdefault) = newvt->misc.default_font.f_n; + if (xtermLoadFont(newvt, + xtermFontName(newvt->screen.MenuFontName(curvt->screen.menu_font_number)), + True, newvt->screen.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) + newvt->screen.MenuFontName(fontMenu_fontdefault) = curvt->misc.default_font.f_n; + } + if (!fonts_redone + && (T_COLOR(&(curvt->screen), TEXT_CURSOR) != + T_COLOR(&(newvt->screen), TEXT_CURSOR))) { + set_cursor_gcs(&newvt->screen); + refresh_needed = True; + } + if (curvt->misc.re_verse != newvt->misc.re_verse) { + newvt->flags ^= REVERSE_VIDEO; + ReverseVideo(newvt); + newvt->misc.re_verse = !newvt->misc.re_verse; /* ReverseVideo toggles */ + refresh_needed = True; + } + if ((T_COLOR(&(curvt->screen), MOUSE_FG) != + T_COLOR(&(newvt->screen), MOUSE_FG)) || + (T_COLOR(&(curvt->screen), MOUSE_BG) != + T_COLOR(&(newvt->screen), MOUSE_BG))) { + recolor_cursor(newvt->screen.pointer_cursor, + T_COLOR(&(newvt->screen), MOUSE_FG), + T_COLOR(&(newvt->screen), MOUSE_BG)); + refresh_needed = True; + } + if (curvt->misc.scrollbar != newvt->misc.scrollbar) { + ToggleScrollBar(newvt); + } + + return refresh_needed; +} + +#define setGC(value) set_at = __LINE__, currentGC = value + +#define OutsideSelection(screen,row,col) \ + ((row) > (screen)->endHRow || \ + ((row) == (screen)->endHRow && \ + (col) >= (screen)->endHCol) || \ + (row) < (screen)->startHRow || \ + ((row) == (screen)->startHRow && \ + (col) < (screen)->startHCol)) + +/* + * Shows cursor at new cursor position in screen. + */ +void +ShowCursor(void) +{ + TScreen *screen = &term->screen; + int x, y; + Char clo; + unsigned flags; + unsigned fg_bg = 0; + GC currentGC; + int set_at; + Bool in_selection; + Bool reversed; + Pixel fg_pix; + Pixel bg_pix; + Pixel tmp; +#if OPT_HIGHLIGHT_COLOR + Pixel hi_pix = T_COLOR(screen, HIGHLIGHT_BG); +#endif +#if OPT_WIDE_CHARS + Char chi = 0; + Char c1h = 0; + Char c1l = 0; + Char c2h = 0; + Char c2l = 0; + int base; +#endif + int cursor_col; + + if (screen->cursor_state == BLINKED_OFF) + return; + + if (eventMode != NORMAL) + return; + + if (screen->cur_row - screen->topline > screen->max_row) + return; + + screen->cursor_row = screen->cur_row; + cursor_col = screen->cursor_col = screen->cur_col; + screen->cursor_moved = False; + +#ifndef NO_ACTIVE_ICON + if (IsIcon(screen)) { + screen->cursor_state = ON; + return; + } +#endif /* NO_ACTIVE_ICON */ + +#if OPT_WIDE_CHARS + base = +#endif + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + + if_OPT_WIDE_CHARS(screen, { + int my_col; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + if (clo == HIDDEN_LO && chi == HIDDEN_HI && cursor_col > 0) { + /* if cursor points to non-initial part of wide character, + * back it up + */ + --cursor_col; + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + } + my_col = cursor_col; + base = (chi << 8) | clo; + if (iswide(base)) + my_col += 1; + c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col]; + c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col]; + c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col]; + c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col]; + }); + + flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[cursor_col]; + + if (clo == 0 +#if OPT_WIDE_CHARS + && chi == 0 +#endif + ) { + clo = ' '; + } + + /* + * 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 OPT_ISO_COLORS + if ((flags & TERM_COLOR_FLAGS(term)) == BG_COLOR +#if OPT_WIDE_CHARS + && chi == 0 +#endif + && clo == ' ') { + flags &= ~TERM_COLOR_FLAGS(term); + } +#endif + + /* + * Compare the current cell to the last set of colors used for the + * cursor and update the GC's if needed. + */ + if_OPT_EXT_COLORS(screen, { + fg_bg = (SCRN_BUF_FGRND(screen, screen->cursor_row)[cursor_col] << 8) + | (SCRN_BUF_BGRND(screen, screen->cursor_row)[cursor_col]); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fg_bg = SCRN_BUF_COLOR(screen, screen->cursor_row)[cursor_col]; + }); + fg_pix = getXtermForeground(flags, extract_fg(fg_bg, flags)); + bg_pix = getXtermBackground(flags, extract_bg(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. + */ + if (screen->select || screen->always_highlight) { + if (reversed) { /* text is reverse video */ + if (screen->cursorGC) { + setGC(screen->cursorGC); + } else { + if (flags & BOLDATTR(screen)) { + setGC(NormalBoldGC(screen)); + } else { + setGC(NormalGC(screen)); + } + } +#if OPT_HIGHLIGHT_COLOR + if (hi_pix != T_COLOR(screen, TEXT_FG) + && hi_pix != fg_pix + && hi_pix != bg_pix + && hi_pix != term->dft_foreground) { + bg_pix = fg_pix; + fg_pix = hi_pix; + } +#endif + EXCHANGE(fg_pix, bg_pix, tmp); + } else { /* normal video */ + if (screen->reversecursorGC) { + setGC(screen->reversecursorGC); + } else { + if (flags & BOLDATTR(screen)) { + setGC(ReverseBoldGC(screen)); + } else { + setGC(ReverseGC(screen)); + } + } + } + if (T_COLOR(screen, TEXT_CURSOR) == term->dft_foreground) { + XSetBackground(screen->display, currentGC, fg_pix); + } + XSetForeground(screen->display, currentGC, bg_pix); + } else { /* not selected */ + if (reversed) { /* text is reverse video */ +#if OPT_HIGHLIGHT_COLOR + if (hi_pix != T_COLOR(screen, TEXT_FG) + && hi_pix != fg_pix + && hi_pix != bg_pix + && hi_pix != term->dft_foreground) { + bg_pix = fg_pix; + fg_pix = hi_pix; + } +#endif + setGC(ReverseGC(screen)); + XSetForeground(screen->display, currentGC, bg_pix); + XSetBackground(screen->display, currentGC, fg_pix); + } else { /* normal video */ + setGC(NormalGC(screen)); + XSetForeground(screen->display, currentGC, fg_pix); + XSetBackground(screen->display, currentGC, 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)\n", + screen->cur_row, screen->cur_col)); + + drawXtermText(screen, flags & DRAWX_MASK, currentGC, + x = CurCursorX(screen, screen->cur_row, cursor_col), + y = CursorY(screen, screen->cur_row), + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&clo, &chi), 1, 0); + +#if OPT_WIDE_CHARS + if (c1l || c1h) { + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c1l, &c1h), 1, iswide(base)); + + if (c2l || c2h) + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c2l, &c2h), 1, iswide(base)); + } +#endif + + if (!screen->select && !screen->always_highlight) { + screen->box->x = x; + screen->box->y = y; + XDrawLines(screen->display, VWindow(screen), + screen->cursoroutlineGC ? screen->cursoroutlineGC + : currentGC, + screen->box, NBOX, CoordModePrevious); + } + } + screen->cursor_state = ON; +} + +/* + * hide cursor at previous cursor position in screen. + */ +void +HideCursor(void) +{ + TScreen *screen = &term->screen; + GC currentGC; + unsigned flags; + unsigned fg_bg = 0; + int x, y; + Char clo; + Bool in_selection; +#if OPT_WIDE_CHARS + Char chi = 0; + Char c1h = 0; + Char c1l = 0; + Char c2h = 0; + Char c2l = 0; + int base; +#endif + int cursor_col; + + if (screen->cursor_state == OFF) /* FIXME */ + return; + if (screen->cursor_row - screen->topline > screen->max_row) + return; + + cursor_col = screen->cursor_col; + +#ifndef NO_ACTIVE_ICON + if (IsIcon(screen)) { + screen->cursor_state = OFF; + return; + } +#endif /* NO_ACTIVE_ICON */ + +#if OPT_WIDE_CHARS + base = +#endif + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[cursor_col]; + + if_OPT_WIDE_CHARS(screen, { + int my_col; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + if (clo == HIDDEN_LO && chi == HIDDEN_HI) { + /* if cursor points to non-initial part of wide character, + * back it up + */ + --cursor_col; + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + } + my_col = cursor_col; + base = (chi << 8) | clo; + if (iswide(base)) + my_col += 1; + c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col]; + c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col]; + c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col]; + c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col]; + }); + + if_OPT_EXT_COLORS(screen, { + fg_bg = (SCRN_BUF_FGRND(screen, screen->cursor_row)[cursor_col] << 8) + | (SCRN_BUF_BGRND(screen, screen->cursor_row)[cursor_col]); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fg_bg = SCRN_BUF_COLOR(screen, screen->cursor_row)[cursor_col]; + }); + + if (OutsideSelection(screen, screen->cursor_row, screen->cursor_col)) + in_selection = False; + else + in_selection = True; + + currentGC = updatedXtermGC(screen, flags, fg_bg, in_selection); + + if (clo == 0 +#if OPT_WIDE_CHARS + && chi == 0 +#endif + ) { + clo = ' '; + } + + TRACE(("HideCursor calling drawXtermText cur(%d,%d)\n", + screen->cursor_row, screen->cursor_col)); + drawXtermText(screen, flags & DRAWX_MASK, currentGC, + x = CurCursorX(screen, screen->cursor_row, cursor_col), + y = CursorY(screen, screen->cursor_row), + curXtermChrSet(screen->cursor_row), + PAIRED_CHARS(&clo, &chi), 1, 0); + +#if OPT_WIDE_CHARS + if (c1l || c1h) { + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c1l, &c1h), 1, iswide(base)); + + if (c2l || c2h) + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c2l, &c2h), 1, iswide(base)); + } +#endif + screen->cursor_state = OFF; + resetXtermGC(screen, flags, in_selection); +} + +#if OPT_BLINK_CURS || OPT_BLINK_TEXT +static void +StartBlinking(TScreen * screen) +{ + if (screen->blink_timer == 0) { + unsigned long interval = (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 +ScrnHasBlinking(TScreen * screen, int row) +{ + Char *attrs = SCRN_BUF_ATTRS(screen, row); + int col; + Bool result = False; + + for (col = 0; col < MaxCols(screen); ++col) { + if (attrs[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 line 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--) { + if (ScrnTstBlinked(screen, row)) { + if (ScrnHasBlinking(screen, row)) { + resume = True; + if (row > last_row) + last_row = row; + if (row < first_row) + first_row = row; + } else { + ScrnClrBlinked(screen, row); + } + } + } + /* + * FIXME: this could be a little more efficient, e.g,. by limiting the + * columns which are updated. + */ + if (first_row <= last_row) { + ScrnRefresh(screen, + 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 */ + +/* + * 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(Bool full, Bool saved) +{ + TScreen *screen = &term->screen; + + if (!XtIsRealized((Widget) term)) { + Bell(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(&term->flags, ORIGIN); + + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + + /* Reset character-sets to initial state */ + resetCharsets(screen); + + /* Reset DECSCA */ + bitclr(&term->flags, PROTECTED); + screen->protected_mode = OFF_PROTECT; + + if (full) { /* RIS */ + if (screen->bellOnReset) + Bell(XkbBI_TerminalBell, 0); + + /* reset the mouse mode */ + screen->send_mouse_pos = MOUSE_OFF; + waitingForTrackInfo = False; + eventMode = NORMAL; + + TabReset(term->tabs); + term->keyboard.flags = MODE_SRM; +#if OPT_INITIAL_ERASE + if (term->keyboard.reset_DECBKM == 1) + term->keyboard.flags |= MODE_DECBKM; + else if (term->keyboard.reset_DECBKM == 2) +#endif + if (term->screen.backarrow_key) + term->keyboard.flags |= MODE_DECBKM; + TRACE(("full reset DECBKM %s\n", + BtoS(term->keyboard.flags & MODE_DECBKM))); + update_appcursor(); + update_appkeypad(); + update_decbkm(); + show_8bit_control(False); + reset_decudk(); + + FromAlternate(screen); + ClearScreen(screen); + screen->cursor_state = OFF; + if (term->flags & REVERSE_VIDEO) + ReverseVideo(term); + + term->flags = term->initflags; + update_reversevideo(); + update_autowrap(); + update_reversewrap(); + update_autolinefeed(); + + screen->jumpscroll = !(term->flags & SMOOTHSCROLL); + update_jumpscroll(); + + if (screen->c132 && (term->flags & IN132COLUMNS)) { + Dimension reqWidth = (80 * FontWidth(screen) + + 2 * screen->border + ScrollbarWidth(screen)); + Dimension reqHeight = (FontHeight(screen) + * MaxRows(screen) + 2 * screen->border); + Dimension replyWidth; + Dimension replyHeight; + + TRACE(("Making resize-request to restore 80-columns %dx%d\n", + reqHeight, reqWidth)); + XtMakeResizeRequest((Widget) term, + reqWidth, + reqHeight, + &replyWidth, &replyHeight); + TRACE(("...result %dx%d\n", replyHeight, replyWidth)); + repairSizeHints(); + XSync(screen->display, False); /* synchronize */ + if (XtAppPending(app_con)) + xevents(); + } + + CursorSet(screen, 0, 0, term->flags); + CursorSave(term); + } else { /* DECSTR */ + /* + * There's a tiny difference, to accommodate usage of xterm. + * We reset autowrap to the resource values rather than turning + * it off. + */ + term->keyboard.flags &= ~(MODE_DECCKM | MODE_KAM | MODE_DECKPAM); + bitcpy(&term->flags, term->initflags, WRAPAROUND | REVERSEWRAP); + bitclr(&term->flags, INSERT | INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE); + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + update_appcursor(); + update_autowrap(); + update_reversewrap(); + + CursorSave(term); + screen->sc[screen->alternate != False].row = + screen->sc[screen->alternate != False].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 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 = strlen(s), acc = 0, numbers = digits = 0; + i < len; i++) { + Char c = 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); + + (void) sprintf(pmapName, "%sKeymap", params[0]); + (void) strcpy(pmapClass, pmapName); + if (islower(CharOf(pmapClass[0]))) + pmapClass[0] = toupper(CharOf(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(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) +{ + /* do nothing, but check for funny escape sequences */ + (void) SendMousePosition(w, event); +} + +/* ARGSUSED */ +static void +DoSetSelectedFont(Widget w GCC_UNUSED, + XtPointer client_data GCC_UNUSED, + Atom * selection GCC_UNUSED, + Atom * type, + XtPointer value, + unsigned long *length GCC_UNUSED, + int *format) +{ + char *val = (char *) value; + int len; + if (*type != XA_STRING || *format != 8) { + Bell(XkbBI_MinorError, 0); + return; + } + len = strlen(val); + if (len > 0) { + if (val[len - 1] == '\n') + val[len - 1] = '\0'; + /* 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(val, '\n')) + return; + if (!xtermLoadFont(term, + xtermFontName(val), + True, + fontMenu_fontsel)) + Bell(XkbBI_MinorError, 0); + } +} + +void +FindFontSelection(char *atom_name, Bool justprobe) +{ + static AtomPtr *atoms; + static int atomCount = 0; + AtomPtr *pAtom; + int a; + Atom target; + + if (!atom_name) + atom_name = "PRIMARY"; + + for (pAtom = atoms, a = atomCount; a; a--, pAtom++) { + if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) + break; + } + if (!a) { + atoms = (AtomPtr *) XtRealloc((char *) atoms, + sizeof(AtomPtr) * (atomCount + 1)); + *(pAtom = &atoms[atomCount++]) = XmuMakeAtom(atom_name); + } + + target = XmuInternAtom(XtDisplay(term), *pAtom); + if (justprobe) { + term->screen.MenuFontName(fontMenu_fontsel) = + XGetSelectionOwner(XtDisplay(term), target) ? _Font_Selected_ : 0; + } else { + XtGetSelectionValue((Widget) term, target, XA_STRING, + DoSetSelectedFont, NULL, + XtLastTimestampProcessed(XtDisplay(term))); + } + return; +} + +void +set_cursor_gcs(TScreen * screen) +{ + XGCValues xgcv; + XtGCMask mask; + Pixel cc = T_COLOR(screen, TEXT_CURSOR); + Pixel fg = T_COLOR(screen, TEXT_FG); + Pixel bg = T_COLOR(screen, TEXT_BG); + GC new_cursorGC = NULL; + GC new_cursorFillGC = NULL; + GC new_reversecursorGC = NULL; + GC new_cursoroutlineGC = NULL; + + /* + * Let's see, there are three things that have "color": + * + * background + * text + * cursorblock + * + * And, there are four situation 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. + */ + +#if OPT_ISO_COLORS + /* + * If we're using ANSI colors, the functions manipulating the SGR code will + * use the same GC's. To avoid having the cursor change color, we use the + * Xlib calls rather than the Xt calls. + * + * Use the colorMode value to determine which we'll do (the VWindow may + * not be set before the widget's realized, so it's tested separately). + */ + if (screen->colorMode) { + if (VWindow(screen) != 0 && (cc != bg) && (cc != fg)) { + /* we might have a colored foreground/background later */ + xgcv.font = screen->fnt_norm->fid; + mask = (GCForeground | GCBackground | GCFont); + xgcv.foreground = fg; + xgcv.background = cc; + new_cursorGC = XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + + xgcv.foreground = cc; + xgcv.background = fg; + new_cursorFillGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + + if (screen->always_highlight) { + new_reversecursorGC = (GC) 0; + new_cursoroutlineGC = (GC) 0; + } else { + xgcv.foreground = bg; + xgcv.background = cc; + new_reversecursorGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + xgcv.foreground = cc; + xgcv.background = bg; + new_cursoroutlineGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + } + } + } else +#endif + if (cc != fg && cc != bg) { + /* we have a colored cursor */ + xgcv.font = screen->fnt_norm->fid; + mask = (GCForeground | GCBackground | GCFont); + + xgcv.foreground = fg; + xgcv.background = cc; + new_cursorGC = XtGetGC((Widget) term, mask, &xgcv); + + xgcv.foreground = cc; + xgcv.background = fg; + new_cursorFillGC = XtGetGC((Widget) term, mask, &xgcv); + + if (screen->always_highlight) { + new_reversecursorGC = (GC) 0; + new_cursoroutlineGC = (GC) 0; + } else { + xgcv.foreground = bg; + xgcv.background = cc; + new_reversecursorGC = XtGetGC((Widget) term, mask, &xgcv); + xgcv.foreground = cc; + xgcv.background = bg; + new_cursoroutlineGC = XtGetGC((Widget) term, mask, &xgcv); + } + } +#if OPT_ISO_COLORS + if (screen->colorMode) { + if (screen->cursorGC) + XFreeGC(screen->display, screen->cursorGC); + if (screen->fillCursorGC) + XFreeGC(screen->display, screen->fillCursorGC); + if (screen->reversecursorGC) + XFreeGC(screen->display, screen->reversecursorGC); + if (screen->cursoroutlineGC) + XFreeGC(screen->display, screen->cursoroutlineGC); + } else +#endif + { + if (screen->cursorGC) + XtReleaseGC((Widget) term, screen->cursorGC); + if (screen->fillCursorGC) + XtReleaseGC((Widget) term, screen->fillCursorGC); + if (screen->reversecursorGC) + XtReleaseGC((Widget) term, screen->reversecursorGC); + if (screen->cursoroutlineGC) + XtReleaseGC((Widget) term, screen->cursoroutlineGC); + } + + screen->cursorGC = new_cursorGC; + screen->fillCursorGC = new_cursorFillGC; + screen->reversecursorGC = new_reversecursorGC; + screen->cursoroutlineGC = new_cursoroutlineGC; +} diff --git a/nx-X11/programs/xterm/charproc.c.X.original b/nx-X11/programs/xterm/charproc.c.X.original new file mode 100644 index 000000000..2c72b5bdc --- /dev/null +++ b/nx-X11/programs/xterm/charproc.c.X.original @@ -0,0 +1,7276 @@ +/* $XTermId: charproc.c,v 1.627 2005/11/13 23:10:35 tom Exp $ */ + +/* + * $Xorg: charproc.c,v 1.6 2001/02/09 02:06:02 xorgcvs Exp $ + */ + +/* $XFree86: xc/programs/xterm/charproc.c,v 3.177 2005/11/13 23:10:35 dickey Exp $ */ + +/* + +Copyright 1999-2004,2005 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 +#include + +#include +#include +#include +#include +#include +#include + +#if OPT_INPUT_METHOD + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif + +#if OPT_WIDE_CHARS +#include +#include +#ifdef HAVE_LANGINFO_CODESET +#include +#endif +#endif + +#if OPT_INPUT_METHOD +#include +#endif + +#include +#include + +#if defined(HAVE_SCHED_YIELD) +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if OPT_ZICONBEEP || OPT_TOOLBAR +#define HANDLE_STRUCT_NOTIFY 1 +#else +#define HANDLE_STRUCT_NOTIFY 0 +#endif + +static IChar doinput(void); +static int set_character_class(char *s); +static void FromAlternate(TScreen * screen); +static void RequestResize(XtermWidget termw, int rows, int cols, int text); +static void SwitchBufs(TScreen * screen); +static void ToAlternate(TScreen * screen); +static void VTallocbuf(void); +static void WriteText(TScreen * screen, + PAIRED_CHARS(Char * str, Char * str2), + Cardinal len); +static void ansi_modes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)); +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 termw, void (*func) (unsigned *p, unsigned mask)); +static void restoremodes(XtermWidget termw); +static void savemodes(XtermWidget termw); +static void unparseputn(unsigned int n, int fd); +static void window_ops(XtermWidget termw); + +#define DoStartBlinking(s) ((s)->cursor_blink ^ (s)->cursor_blink_esc) + +#if OPT_BLINK_CURS || OPT_BLINK_TEXT +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 char *_Font_Selected_ = "yes"; /* string is arbitrary */ + +static char defaultTranslations[] = +"\ + Shift Prior:scroll-back(1,halfpage) \n\ + Shift Next:scroll-forw(1,halfpage) \n\ + Shift Select:select-cursor-start() select-cursor-end(PRIMARY, CUT_BUFFER0) \n\ + Shift Insert:insert-selection(PRIMARY, CUT_BUFFER0) \n\ +" +#if OPT_SHIFT_FONTS +"\ + Shift~Ctrl KP_Add:larger-vt-font() \n\ + Shift Ctrl KP_Add:smaller-vt-font() \n\ + Shift KP_Subtract:smaller-vt-font() \n\ +" +#endif +"\ + ~Meta :insert-seven-bit() \n\ + Meta :insert-eight-bit() \n\ + !Ctrl :popup-menu(mainMenu) \n\ + !Lock Ctrl :popup-menu(mainMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(mainMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(mainMenu) \n\ + ~Meta :select-start() \n\ + ~Meta :select-extend() \n\ + !Ctrl :popup-menu(vtMenu) \n\ + !Lock Ctrl :popup-menu(vtMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(vtMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(vtMenu) \n\ + ~Ctrl ~Meta :ignore() \n\ + Meta :clear-saved-lines() \n\ + ~Ctrl ~Meta :insert-selection(PRIMARY, CUT_BUFFER0) \n\ + !Ctrl :popup-menu(fontMenu) \n\ + !Lock Ctrl :popup-menu(fontMenu) \n\ + !Lock Ctrl @Num_Lock :popup-menu(fontMenu) \n\ + ! @Num_Lock Ctrl :popup-menu(fontMenu) \n\ + ~Ctrl ~Meta :start-extend() \n\ + ~Meta :select-extend() \n\ + Ctrl :scroll-back(1,halfpage,m) \n\ + Lock Ctrl :scroll-back(1,halfpage,m) \n\ + Lock @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\ + @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\ + :scroll-back(5,line,m) \n\ + Ctrl :scroll-forw(1,halfpage,m) \n\ + Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + Lock @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\ + :scroll-forw(5,line,m) \n\ + :select-end(PRIMARY, CUT_BUFFER0) \n\ + :ignore() \ +"; /* PROCURA added "Meta :clear-saved-lines()" */ +/* *INDENT-OFF* */ +static XtActionsRec actionsList[] = { + { "allow-send-events", HandleAllowSends }, + { "bell", HandleBell }, + { "clear-saved-lines", HandleClearSavedLines }, + { "create-menu", HandleCreateMenu }, + { "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-redir", HandlePrintControlMode }, + { "quit", HandleQuit }, + { "redraw", HandleRedraw }, + { "delete-is-del", HandleDeleteIsDEL }, + { "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-cursesemul", HandleCursesEmul }, + { "set-jumpscroll", HandleJumpscroll }, + { "set-old-function-keys", HandleOldFunctionKeys }, + { "set-marginbell", HandleMarginBell }, + { "set-reverse-video", HandleReverseVideo }, + { "set-reversewrap", HandleReverseWrap }, + { "set-scroll-on-key", HandleScrollKey }, + { "set-scroll-on-tty-output", HandleScrollTtyOutput }, + { "set-scrollbar", HandleScrollbar }, + { "set-sun-function-keys", HandleSunFunctionKeys }, + { "set-sun-keyboard", HandleSunKeyboard }, + { "set-titeInhibit", HandleTiteInhibit }, + { "set-visual-bell", HandleSetVisualBell }, + { "set-pop-on-bell", HandleSetPopOnBell }, + { "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_BLINK_CURS + { "set-cursorblink", HandleCursorBlink }, +#endif +#if OPT_BOX_CHARS + { "set-font-linedrawing", HandleFontBoxChars }, +#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_HP_FUNC_KEYS + { "set-hp-function-keys", HandleHpFunctionKeys }, +#endif +#if OPT_LOAD_VTFONTS + { "load-vt-fonts", HandleLoadVTFonts }, +#endif +#if OPT_MAXIMIZE + { "deiconify", HandleDeIconify }, + { "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_SHIFT_FONTS + { "larger-vt-font", HandleLargerFont }, + { "smaller-vt-font", HandleSmallerFont }, +#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 }, +#endif +}; +/* *INDENT-ON* */ + +static XtResource resources[] = +{ + Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False), + Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, True), + 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(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(XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, screen.hp_ll_bc, False), + Bres(XtNi18nSelections, XtCI18nSelections, screen.i18nSelections, True), + Bres(XtNjumpScroll, XtCJumpScroll, screen.jumpscroll, 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(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(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(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(XtNprinterControlMode, XtCPrinterControlMode, + screen.printer_controlmode, 0), + 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(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(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), + Fres("iconFont", "IconFont", screen.fnt_icon, XtDefaultFont), + Cres("iconBorderColor", XtCBorderColor, misc.icon_border_pixel, XtDefaultBackground), +#endif /* NO_ACTIVE_ICON */ + +#if OPT_BLINK_CURS + Bres(XtNcursorBlink, XtCCursorBlink, screen.cursor_blink, False), +#endif + +#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(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_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), +#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"), +#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 */ + +#if OPT_MOD_FKEYS + Ires(XtNmodifyCursorKeys, XtCModifyCursorKeys, + keyboard.modify_cursor_keys, 2), +#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, screen.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 + Ires(XtNutf8, XtCUtf8, screen.utf8_mode, uDefault), + Bres(XtNwideChars, XtCWideChars, screen.wide_chars, False), + Bres(XtNmkWidth, XtCMkWidth, misc.mk_width, False), + Bres(XtNcjkWidth, XtCCjkWidth, misc.cjk_width, False), + Bres(XtNvt100Graphics, XtCVT100Graphics, screen.vt100_graphics, True), + Sres(XtNwideBoldFont, XtCWideBoldFont, misc.default_font.f_wb, DEFWIDEBOLDFONT), + Sres(XtNwideFont, XtCWideFont, misc.default_font.f_w, DEFWIDEFONT), +#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_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 + Dres(XtNfaceSize, XtCFaceSize, misc.face_size, DEFFACESIZE), + Sres(XtNfaceName, XtCFaceName, misc.face_name, DEFFACENAME), + Sres(XtNfaceNameDoublesize, XtCFaceNameDoublesize, misc.face_wide_name, DEFFACENAME), + Bres(XtNrenderFont, XtCRenderFont, misc.render_font, True), +#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(void); +#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 */ + resources, /* resources */ + XtNumber(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) +{ +#if OPT_TOOLBAR + /* *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_SHIFT_FONTS + { "larger-vt-font", HandleLargerFont }, + { "smaller-vt-font", HandleSmallerFont }, +#endif + }; + /* *INDENT-ON* */ + + XtAppAddActions(app_con, input_actions, XtNumber(input_actions)); +#endif + XtAugmentTranslations(w, XtParseTranslationTable(defaultTranslations)); +} + +#if OPT_ISO_COLORS +/* + * 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(int color) +{ + TScreen *screen = &term->screen; + Pixel fg; + + if (color >= 0) { + term->flags |= FG_COLOR; + } else { + term->flags &= ~FG_COLOR; + } + fg = getXtermForeground(term->flags, color); + term->cur_foreground = color; + + XSetForeground(screen->display, NormalGC(screen), fg); + XSetBackground(screen->display, ReverseGC(screen), fg); + + if (NormalGC(screen) != NormalBoldGC(screen)) { + XSetForeground(screen->display, NormalBoldGC(screen), fg); + XSetBackground(screen->display, ReverseBoldGC(screen), fg); + } +} + +void +SGR_Background(int color) +{ + TScreen *screen = &term->screen; + 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 != term->cur_background)) + FlushScroll(screen); + + if (color >= 0) { + term->flags |= BG_COLOR; + } else { + term->flags &= ~BG_COLOR; + } + bg = getXtermBackground(term->flags, color); + term->cur_background = color; + + XSetBackground(screen->display, NormalGC(screen), bg); + XSetForeground(screen->display, ReverseGC(screen), bg); + + if (NormalGC(screen) != NormalBoldGC(screen)) { + XSetBackground(screen->display, NormalBoldGC(screen), bg); + XSetForeground(screen->display, ReverseBoldGC(screen), bg); + } +} + +/* Invoked after updating bold/underline flags, computes the extended color + * index to use for foreground. (See also 'extract_fg()'). + */ +static void +setExtendedFG(void) +{ + int fg = term->sgr_foreground; + + if (term->screen.colorAttrMode + || (fg < 0)) { + if (term->screen.colorULMode && (term->flags & UNDERLINE)) + fg = COLOR_UL; + if (term->screen.colorBDMode && (term->flags & BOLD)) + fg = COLOR_BD; + if (term->screen.colorBLMode && (term->flags & BLINK)) + fg = COLOR_BL; + } + + /* 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 (term->screen.boldColors + && (!term->sgr_extended) + && (fg >= 0) + && (fg < 8) + && (term->flags & BOLD)) + fg |= 8; +#endif + + SGR_Foreground(fg); +} + +/* Invoked after updating inverse flag, computes the extended color + * index to use for background. (See also 'extract_bg()'). + */ +static void +setExtendedBG(void) +{ + int bg = term->sgr_background; + + if (term->screen.colorAttrMode + || (bg < 0)) { + if (term->screen.colorRVMode && (term->flags & INVERSE)) + bg = COLOR_RV; + } + + SGR_Background(bg); +} + +static void +reset_SGR_Foreground(void) +{ + term->sgr_foreground = -1; + term->sgr_extended = 0; + setExtendedFG(); +} + +static void +reset_SGR_Background(void) +{ + term->sgr_background = -1; + setExtendedBG(); +} + +static void +reset_SGR_Colors(void) +{ + reset_SGR_Foreground(); + reset_SGR_Background(); +} +#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_TRACE +#define WHICH_TABLE(name) if (table == name) result = #name +static char * +which_table(Const PARSE_T * table) +{ + char *result = "?"; + /* *INDENT-OFF* */ + WHICH_TABLE (ansi_table); + else WHICH_TABLE (csi_table); + else WHICH_TABLE (csi2_table); + else WHICH_TABLE (csi_ex_table); + else WHICH_TABLE (csi_quo_table); +#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); +#endif + else WHICH_TABLE (dec_table); + else WHICH_TABLE (dec2_table); + else WHICH_TABLE (dec3_table); + else WHICH_TABLE (cigtable); + else WHICH_TABLE (eigtable); + else WHICH_TABLE (esc_table); + else WHICH_TABLE (esc_sp_table); + else WHICH_TABLE (scrtable); + else WHICH_TABLE (scstable); + else WHICH_TABLE (sos_table); +#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; \ + unsigned 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(screen, \ + screen->gsets[(int) (screen->curss)], \ + print_area, 1); \ + screen->curss = 0; \ + single++; \ + } \ + if (print_used > single) { \ + dotext(screen, \ + screen->gsets[(int) (screen->curgl)], \ + print_area + single, \ + print_used - single); \ + } \ + print_used = 0; \ + } \ + +struct ParseState { +#if OPT_VT52_MODE + Bool vt52_cup; +#endif + Const PARSE_T *groundtable; + Const PARSE_T *parsestate; + int scstype; + 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 +}; + +static struct ParseState myState; + +static Boolean +doparsing(unsigned c, struct ParseState *sp) +{ + /* Buffer for processing printable text */ + static IChar *print_area; + static size_t print_size, print_used; + + /* Buffer for processing strings (e.g., OSC ... ST) */ + static Char *string_area; + static size_t string_size, string_used; + + TScreen *screen = &term->screen; + int row; + int col; + int top; + int bot; + int count; + int laststate; + int thischar = -1; + XTermRect myRect; + + do { +#if OPT_WIDE_CHARS + + /* + * 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) { + int prev, precomposed; + + WriteNow(); + + prev = getXtermCell(screen, + screen->last_written_row, + screen->last_written_col); + precomposed = do_precomposition(prev, (int) c); + + if (precomposed != -1) { + 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(screen, + 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 = xtermPrinterControl((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++] = (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, term->flags); + sp->parsestate = vt52_table; + param[0] = 0; + param[1] = 0; + continue; + } +#endif + + /* + * The parsing tables all have 256 entries. If we're supporting + * wide characters, we handle them by treating them the same as + * printing characters. + */ + laststate = sp->nextstate; +#if OPT_WIDE_CHARS + if (c > 255) { + 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 (string_used) { + switch (string_area[0]) { + case 'P': + if (string_used <= 7) + break; + /* FALLTHRU */ + case 'R': + sp->parsestate = sp->groundtable; + sp->nextstate = sp->parsestate[E2A(c)]; + 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 5: /* FALLTHRU */ + case 8: /* FALLTHRU */ + case 9: /* FALLTHRU */ + case 10: /* FALLTHRU */ + case 11: /* FALLTHRU */ + case 12: /* FALLTHRU */ + case 13: /* FALLTHRU */ + case 14: /* FALLTHRU */ + case 15: /* FALLTHRU */ + case 24: + sp->parsestate = sp->groundtable; + sp->nextstate = sp->parsestate[E2A(c)]; + 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. + */ + if (iswide((int) c) != 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, print_area, print_used, print_size); + if (new_string == 0) { + fprintf(stderr, + "Cannot allocate %u bytes for printable text\n", + 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 + print_area = new_string; + print_size = new_length; + print_area[print_used++] = sp->lastchar = thischar = c; +#if OPT_WIDE_CHARS + sp->last_was_wide = iswide((int) c); +#endif + if (morePtyData(screen, VTbuffer)) { + continue; + } + } + + if (sp->nextstate == CASE_PRINT + || (laststate == CASE_PRINT && 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, string_area, string_used, string_size); + if (new_string == 0) { + fprintf(stderr, + "Cannot allocate %u bytes for string mode %d\n", + 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 + string_area = new_string; + string_size = new_length; + string_area[string_used++] = c; + } else if (sp->parsestate != esc_table) { + /* if we were accumulating, we're not any more */ + sp->string_mode = 0; + 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")); + sp->parsestate = sp->groundtable; + 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(screen->answer_back[count], screen->respond); + break; + + case CASE_BELL: + TRACE(("CASE_BELL - bell\n")); + if (sp->string_mode == OSC) { + if (string_used) + string_area[--string_used] = '\0'; + do_osc(string_area, string_used, (int) c); + sp->parsestate = sp->groundtable; + } else { + /* bell */ + Bell(XkbBI_TerminalBell, 0); + } + break; + + case CASE_BS: + TRACE(("CASE_BS - backspace\n")); + CursorBack(screen, 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((int) c); + xtermIndex(screen, 1); + if (term->flags & LINEFEED) + CarriageReturn(screen); + do_xevents(); + break; + + case CASE_CBT: + /* cursor backward tabulation */ + if ((count = param[0]) == DEFAULT) + count = 1; + while ((count-- > 0) + && (TabToPrevStop(screen))) ; + sp->parsestate = sp->groundtable; + break; + + case CASE_CHT: + /* cursor forward tabulation */ + if ((count = param[0]) == DEFAULT) + count = 1; + while ((count-- > 0) + && (TabToNextStop(screen))) ; + sp->parsestate = sp->groundtable; + break; + + case CASE_TAB: + /* tab */ + TabToNextStop(screen); + break; + + case CASE_SI: + screen->curgl = 0; + if_OPT_VT52_MODE(screen, { + sp->parsestate = sp->groundtable; + }); + break; + + case CASE_SO: + screen->curgl = 1; + if_OPT_VT52_MODE(screen, { + sp->parsestate = sp->groundtable; + }); + break; + + case CASE_DECDHL: + xterm_DECDHL(c == '3'); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSWL: + xterm_DECSWL(); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECDWL: + xterm_DECDWL(); + sp->parsestate = sp->groundtable; + break; + + case CASE_SCR_STATE: + /* enter scr state */ + sp->parsestate = scrtable; + break; + + case CASE_SCS0_STATE: + /* enter scs state 0 */ + sp->scstype = 0; + sp->parsestate = scstable; + break; + + case CASE_SCS1_STATE: + /* enter scs state 1 */ + sp->scstype = 1; + sp->parsestate = scstable; + break; + + case CASE_SCS2_STATE: + /* enter scs state 2 */ + sp->scstype = 2; + sp->parsestate = scstable; + break; + + case CASE_SCS3_STATE: + /* enter scs state 3 */ + sp->scstype = 3; + sp->parsestate = scstable; + break; + + case CASE_ESC_IGNORE: + /* unknown escape sequence */ + sp->parsestate = eigtable; + break; + + case CASE_ESC_DIGIT: + /* digit in csi or dec mode */ + if ((row = param[nparam - 1]) == DEFAULT) + row = 0; + param[nparam - 1] = 10 * row + (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(screen, (unsigned) row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUU: + TRACE(("CASE_CUU - cursor up\n")); + if ((row = param[0]) < 1) + row = 1; + CursorUp(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUD: + TRACE(("CASE_CUD - cursor down\n")); + if ((row = param[0]) < 1) + row = 1; + CursorDown(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUF: + TRACE(("CASE_CUF - cursor forward\n")); + if ((col = param[0]) < 1) + col = 1; + CursorForward(screen, col); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUB: + TRACE(("CASE_CUB - cursor backward\n")); + if ((col = param[0]) < 1) + col = 1; + CursorBack(screen, col); + sp->parsestate = sp->groundtable; + break; + + case CASE_CUP: + TRACE(("CASE_CUP - cursor position\n")); + if_OPT_XMC_GLITCH(screen, { + Jump_XMC(screen); + }); + if ((row = param[0]) < 1) + row = 1; + if (nparam < 2 || (col = param[1]) < 1) + col = 1; + CursorSet(screen, row - 1, col - 1, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_VPA: + TRACE(("CASE_VPA - vertical position\n")); + if ((row = param[0]) < 1) + row = 1; + CursorSet(screen, row - 1, screen->cur_col, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_HPA: + TRACE(("CASE_HPA - horizontal position\n")); + if ((col = param[0]) < 1) + col = 1; + CursorSet(screen, screen->cur_row, col - 1, term->flags); + sp->parsestate = sp->groundtable; + 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, term->flags); + sp->parsestate = sp->groundtable; + break; + + case CASE_ED: + TRACE(("CASE_ED - erase display\n")); + do_erase_display(screen, param[0], OFF_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_EL: + TRACE(("CASE_EL - erase line\n")); + do_erase_line(screen, param[0], OFF_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_ECH: + TRACE(("CASE_ECH - erase char\n")); + /* ECH */ + ClearRight(screen, param[0] < 1 ? 1 : param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_IL: + TRACE(("CASE_IL - insert line\n")); + if ((row = param[0]) < 1) + row = 1; + InsertLine(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_DL: + TRACE(("CASE_DL - delete line\n")); + if ((row = param[0]) < 1) + row = 1; + DeleteLine(screen, row); + sp->parsestate = sp->groundtable; + break; + + case CASE_DCH: + TRACE(("CASE_DCH - delete char\n")); + if ((row = param[0]) < 1) + row = 1; + DeleteChar(screen, (unsigned) row); + sp->parsestate = sp->groundtable; + 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) { + TRACE(("CASE_TRACK_MOUSE\n")); + /* Track mouse as long as in window and between + * specified rows + */ + TrackMouse(param[0], + param[2] - 1, param[1] - 1, + param[3] - 1, param[4] - 2); + } else { + TRACE(("CASE_SD - scroll down\n")); + /* SD */ + if ((count = param[0]) < 1) + count = 1; + RevScroll(screen, count); + do_xevents(); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECID: + TRACE(("CASE_DECID\n")); + if_OPT_VT52_MODE(screen, { + unparseputc(ESC, screen->respond); + unparseputc('/', screen->respond); + unparseputc('Z', screen->respond); + sp->parsestate = sp->groundtable; + 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 = 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++] = 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 (term->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 = count; + reply.a_inters = 0; + reply.a_final = 'c'; + unparseseq(&reply, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DA2: + TRACE(("CASE_DA2\n")); + if (param[0] <= 0) { /* less than means DEFAULT */ + count = 0; + reply.a_type = 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 = count; + reply.a_inters = 0; + reply.a_final = 'c'; + unparseseq(&reply, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRPTUI: + TRACE(("CASE_DECRPTUI\n")); + if ((screen->terminal_id >= 400) + && (param[0] <= 0)) { /* less than means DEFAULT */ + unparseputc1(DCS, screen->respond); + unparseputc('!', screen->respond); + unparseputc('|', screen->respond); + unparseputc('0', screen->respond); + unparseputc1(ST, screen->respond); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_TBC: + TRACE(("CASE_TBC - tab clear\n")); + if ((row = param[0]) <= 0) /* less than means default */ + TabClear(term->tabs, screen->cur_col); + else if (row == 3) + TabZonk(term->tabs); + sp->parsestate = sp->groundtable; + break; + + case CASE_SET: + TRACE(("CASE_SET - set mode\n")); + ansi_modes(term, bitset); + sp->parsestate = sp->groundtable; + break; + + case CASE_RST: + TRACE(("CASE_RST - reset mode\n")); + ansi_modes(term, bitclr); + sp->parsestate = sp->groundtable; + break; + + case CASE_SGR: + for (row = 0; row < nparam; ++row) { + if_OPT_XMC_GLITCH(screen, { + Mark_XMC(screen, param[row]); + }); + TRACE(("CASE_SGR %d\n", param[row])); + switch (param[row]) { + case DEFAULT: + case 0: + term->flags &= + ~(INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE); + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + break; + case 1: /* Bold */ + term->flags |= BOLD; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 5: /* Blink */ + term->flags |= BLINK; + StartBlinking(screen); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 4: /* Underscore */ + term->flags |= UNDERLINE; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 7: + term->flags |= INVERSE; + if_OPT_ISO_COLORS(screen, { + setExtendedBG(); + }); + break; + case 8: + term->flags |= INVISIBLE; + break; + case 22: /* reset 'bold' */ + term->flags &= ~BOLD; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 24: + term->flags &= ~UNDERLINE; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 25: /* reset 'blink' */ + term->flags &= ~BLINK; + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + break; + case 27: + term->flags &= ~INVERSE; + if_OPT_ISO_COLORS(screen, { + setExtendedBG(); + }); + break; + case 28: + term->flags &= ~INVISIBLE; + break; + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + if_OPT_ISO_COLORS(screen, { + term->sgr_foreground = (param[row] - 30); + term->sgr_extended = 0; + setExtendedFG(); + }); + 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) { + term->sgr_foreground = param[row]; + term->sgr_extended = 1; + setExtendedFG(); + } + break; + default: + row += 7; + break; + } + } + }); + break; + case 39: + if_OPT_ISO_COLORS(screen, { + reset_SGR_Foreground(); + }); + break; + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + if_OPT_ISO_COLORS(screen, { + term->sgr_background = (param[row] - 40); + setExtendedBG(); + }); + 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) { + term->sgr_background = param[row]; + setExtendedBG(); + } + break; + default: + row += 7; + break; + } + } + }); + break; + case 49: + if_OPT_ISO_COLORS(screen, { + reset_SGR_Background(); + }); + break; + case 90: + case 91: + case 92: + case 93: + case 94: + case 95: + case 96: + case 97: + if_OPT_AIX_COLORS(screen, { + term->sgr_foreground = (param[row] - 90 + 8); + term->sgr_extended = 0; + setExtendedFG(); + }); + break; + case 100: +#if !OPT_AIX_COLORS + if_OPT_ISO_COLORS(screen, { + reset_SGR_Foreground(); + reset_SGR_Background(); + }); + break; +#endif + case 101: + case 102: + case 103: + case 104: + case 105: + case 106: + case 107: + if_OPT_AIX_COLORS(screen, { + term->sgr_background = (param[row] - 100 + 8); + setExtendedBG(); + }); + break; + } + } + sp->parsestate = sp->groundtable; + 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 = CSI; + reply.a_pintro = 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++] = screen->cur_row + 1; + reply.a_param[count++] = screen->cur_col + 1; + reply.a_final = 'R'; + break; + case 15: + /* printer status */ + reply.a_param[count++] = 13; /* implement printer */ + break; + case 25: + /* UDK status */ + reply.a_param[count++] = 20; /* UDK always unlocked */ + break; + case 26: + /* keyboard status */ + 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 OPT_DEC_LOCATOR + reply.a_param[count++] = 50; /* locator ready */ +#else + reply.a_param[count++] = 53; /* no locator */ +#endif + break; + } + + if ((reply.a_nparam = count) != 0) + unparseseq(&reply, screen->respond); + + sp->parsestate = sp->groundtable; + sp->private_function = False; + break; + + case CASE_MC: + TRACE(("CASE_MC - media control\n")); + xtermMediaControl(param[0], False); + sp->parsestate = sp->groundtable; + break; + + case CASE_DEC_MC: + TRACE(("CASE_DEC_MC - DEC media control\n")); + xtermMediaControl(param[0], True); + sp->parsestate = sp->groundtable; + 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(screen); + 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); + sp->parsestate = sp->groundtable; + 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(screen); + set_tb_margins(screen, top - 1, bot - 1); + CursorSet(screen, 0, 0, term->flags); + } + sp->parsestate = sp->groundtable; + 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 = CSI; + reply.a_pintro = 0; + reply.a_nparam = 7; + reply.a_param[0] = 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(&reply, screen->respond); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSET: + /* DECSET */ +#if OPT_VT52_MODE + if (screen->vtXX_level != 0) +#endif + dpmodes(term, bitset); + sp->parsestate = sp->groundtable; +#if OPT_TEK4014 + if (screen->TekEmu) + return False; +#endif + break; + + case CASE_DECRST: + /* DECRST */ + dpmodes(term, bitclr); +#if OPT_VT52_MODE + if (screen->vtXX_level == 0) + sp->groundtable = vt52_table; + else if (screen->terminal_id >= 100) + sp->groundtable = ansi_table; +#endif + sp->parsestate = sp->groundtable; + 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, term->flags); + xtermParseRect(screen, 0, 0, &myRect); + ScrnFillRectangle(screen, &myRect, 'E', 0); + sp->parsestate = sp->groundtable; + break; + + case CASE_GSETS: + TRACE(("CASE_GSETS(%d) = '%c'\n", sp->scstype, c)); + if (screen->vtXX_level != 0) + screen->gsets[sp->scstype] = c; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSC: + TRACE(("CASE_DECSC - save cursor\n")); + CursorSave(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRC: + TRACE(("CASE_DECRC - restore cursor\n")); + CursorRestore(term); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(); + }); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECKPAM: + TRACE(("CASE_DECKPAM\n")); + term->keyboard.flags |= MODE_DECKPAM; + update_appkeypad(); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECKPNM: + TRACE(("CASE_DECKPNM\n")); + term->keyboard.flags &= ~MODE_DECKPAM; + update_appkeypad(); + sp->parsestate = sp->groundtable; + break; + + case CASE_CSI_QUOTE_STATE: + sp->parsestate = csi_quo_table; + break; + +#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); + sp->parsestate = sp->groundtable; + break; + + case CASE_ANSI_LEVEL_2: + TRACE(("CASE_ANSI_LEVEL_2\n")); + set_ansi_conformance(screen, 2); + sp->parsestate = sp->groundtable; + break; + + case CASE_ANSI_LEVEL_3: + TRACE(("CASE_ANSI_LEVEL_3\n")); + set_ansi_conformance(screen, 3); + sp->parsestate = sp->groundtable; + 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(False, False); + screen->vtXX_level = param[0] - 60; + if (param[0] > 61) { + if (param[1] == 1) + show_8bit_control(False); + else if (param[1] == 0 || param[1] == 2) + show_8bit_control(True); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSCA: + TRACE(("CASE_DECSCA\n")); + screen->protected_mode = DEC_PROTECT; + if (param[0] <= 0 || param[0] == 2) + term->flags &= ~PROTECTED; + else if (param[0] == 1) + term->flags |= PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSED: + TRACE(("CASE_DECSED\n")); + do_erase_display(screen, param[0], DEC_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSEL: + TRACE(("CASE_DECSEL\n")); + do_erase_line(screen, param[0], DEC_PROTECT); + sp->parsestate = sp->groundtable; + break; + + case CASE_ST: + TRACE(("CASE_ST: End of String (%d bytes)\n", string_used)); + sp->parsestate = sp->groundtable; + if (!string_used) + break; + string_area[--string_used] = '\0'; + switch (sp->string_mode) { + case APC: + /* ignored */ + break; + case DCS: + do_dcs(string_area, string_used); + break; + case OSC: + do_osc(string_area, string_used, ST); + break; + case PM: + /* ignored */ + break; + case SOS: + /* ignored */ + break; + } + break; + + case CASE_SOS: + TRACE(("CASE_SOS: Start of String\n")); + sp->string_mode = SOS; + sp->parsestate = sos_table; + break; + + case CASE_PM: + TRACE(("CASE_PM: Privacy Message\n")); + sp->string_mode = PM; + sp->parsestate = sos_table; + break; + + case CASE_DCS: + TRACE(("CASE_DCS: Device Control String\n")); + sp->string_mode = DCS; + sp->parsestate = sos_table; + break; + + case CASE_APC: + TRACE(("CASE_APC: Application Program Command\n")); + sp->string_mode = APC; + sp->parsestate = sos_table; + break; + + case CASE_SPA: + TRACE(("CASE_SPA - start protected area\n")); + screen->protected_mode = ISO_PROTECT; + term->flags |= PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_EPA: + TRACE(("CASE_EPA - end protected area\n")); + term->flags &= ~PROTECTED; + sp->parsestate = sp->groundtable; + break; + + case CASE_SU: + TRACE(("CASE_SU - scroll up\n")); + if ((count = param[0]) < 1) + count = 1; + xtermScroll(screen, count); + sp->parsestate = sp->groundtable; + break; + + case CASE_IND: + TRACE(("CASE_IND - index\n")); + xtermIndex(screen, 1); + do_xevents(); + sp->parsestate = sp->groundtable; + break; + + case CASE_CPL: + TRACE(("CASE_CPL - cursor prev line\n")); + CursorPrevLine(screen, param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_CNL: + TRACE(("CASE_NPL - cursor next line\n")); + CursorNextLine(screen, param[0]); + sp->parsestate = sp->groundtable; + break; + + case CASE_NEL: + TRACE(("CASE_NEL\n")); + xtermIndex(screen, 1); + CarriageReturn(screen); + do_xevents(); + sp->parsestate = sp->groundtable; + break; + + case CASE_HTS: + TRACE(("CASE_HTS - horizontal tab set\n")); + TabSet(term->tabs, screen->cur_col); + sp->parsestate = sp->groundtable; + break; + + case CASE_RI: + TRACE(("CASE_RI - reverse index\n")); + RevIndex(screen, 1); + sp->parsestate = sp->groundtable; + break; + + case CASE_SS2: + TRACE(("CASE_SS2\n")); + screen->curss = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_SS3: + TRACE(("CASE_SS3\n")); + screen->curss = 3; + sp->parsestate = sp->groundtable; + 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, term); + 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(term); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECELR: + MotionOff(screen, term); + 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; + 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; + } + sp->parsestate = sp->groundtable; + 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, term); + screen->loc_filter = False; + screen->locator_events = 0; + break; + case 1: + screen->locator_events |= LOC_BTNS_DN; + break; + case 2: + screen->locator_events &= ~LOC_BTNS_DN; + break; + case 3: + screen->locator_events |= LOC_BTNS_UP; + break; + case 4: + screen->locator_events &= ~LOC_BTNS_UP; + break; + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRQLP: + TRACE(("DECRQLP - Request Locator Position\n")); + if (param[0] < 2) { + /* Issue DECLRP Locator Position Report */ + GetLocatorPosition(term); + } + sp->parsestate = sp->groundtable; + break; +#endif /* OPT_DEC_LOCATOR */ + +#if OPT_DEC_RECTOPS + case CASE_CSI_DOLLAR_STATE: + /* csi dollar ($) */ + if (screen->vtXX_level >= 4) + sp->parsestate = csi_dollar_table; + else + sp->parsestate = eigtable; + break; + + case CASE_CSI_STAR_STATE: + /* csi dollar (*) */ + if (screen->vtXX_level >= 4) + sp->parsestate = csi_star_table; + else + sp->parsestate = eigtable; + break; + + case CASE_DECCRA: + TRACE(("CASE_DECCRA - Copy rectangular area\n")); + xtermParseRect(screen, nparam, param, &myRect); + ScrnCopyRectangle(screen, &myRect, nparam - 5, param + 5); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECERA: + TRACE(("CASE_DECERA - Erase rectangular area\n")); + xtermParseRect(screen, nparam, param, &myRect); + ScrnFillRectangle(screen, &myRect, ' ', 0); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECFRA: + TRACE(("CASE_DECFRA - Fill rectangular area\n")); + if (nparam > 0 + && ((param[0] >= 32 && param[0] <= 126) + || (param[0] >= 160 && param[0] <= 255))) { + xtermParseRect(screen, nparam - 1, param + 1, &myRect); + ScrnFillRectangle(screen, &myRect, param[0], term->flags); + } + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSERA: + TRACE(("CASE_DECSERA - Selective erase rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnWipeRectangle(screen, &myRect); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSACE: + TRACE(("CASE_DECSACE - Select attribute change extent\n")); + screen->cur_decsace = param[0]; + sp->parsestate = sp->groundtable; + break; + + case CASE_DECCARA: + TRACE(("CASE_DECCARA - Change attributes in rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnMarkRectangle(screen, &myRect, False, nparam - 4, param + 4); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECRARA: + TRACE(("CASE_DECRARA - Reverse attributes in rectangular area\n")); + xtermParseRect(screen, nparam > 4 ? 4 : nparam, param, &myRect); + ScrnMarkRectangle(screen, &myRect, True, nparam - 4, param + 4); + sp->parsestate = sp->groundtable; + break; +#else + case CASE_CSI_DOLLAR_STATE: + /* csi dollar ($) */ + sp->parsestate = eigtable; + break; + + case CASE_CSI_STAR_STATE: + /* csi dollar (*) */ + sp->parsestate = eigtable; + break; +#endif /* OPT_DEC_RECTOPS */ + + case CASE_S7C1T: + TRACE(("CASE_S7C1T\n")); + show_8bit_control(False); + sp->parsestate = sp->groundtable; + break; + + case CASE_S8C1T: + TRACE(("CASE_S8C1T\n")); +#if OPT_VT52_MODE + if (screen->vtXX_level <= 1) + break; +#endif + show_8bit_control(True); + sp->parsestate = sp->groundtable; + break; + + case CASE_OSC: + TRACE(("CASE_OSC: Operating System Command\n")); + sp->parsestate = sos_table; + sp->string_mode = OSC; + break; + + case CASE_RIS: + TRACE(("CASE_RIS\n")); + VTReset(True, True); + sp->parsestate = sp->groundtable; + break; + + case CASE_DECSTR: + TRACE(("CASE_DECSTR\n")); + VTReset(False, False); + sp->parsestate = sp->groundtable; + break; + + case CASE_REP: + TRACE(("CASE_REP\n")); + if (sp->lastchar >= 0 && + sp->groundtable[E2A(sp->lastchar)] == CASE_PRINT) { + IChar repeated[2]; + count = (param[0] < 1) ? 1 : param[0]; + repeated[0] = sp->lastchar; + while (count-- > 0) { + dotext(screen, + screen->gsets[(int) (screen->curgl)], + repeated, 1); + } + } + sp->parsestate = sp->groundtable; + break; + + case CASE_LS2: + TRACE(("CASE_LS2\n")); + screen->curgl = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS3: + TRACE(("CASE_LS3\n")); + screen->curgl = 3; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS3R: + TRACE(("CASE_LS3R\n")); + screen->curgr = 3; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS2R: + TRACE(("CASE_LS2R\n")); + screen->curgr = 2; + sp->parsestate = sp->groundtable; + break; + + case CASE_LS1R: + TRACE(("CASE_LS1R\n")); + screen->curgr = 1; + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_SAVE: + savemodes(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_RESTORE: + restoremodes(term); + sp->parsestate = sp->groundtable; + break; + + case CASE_XTERM_WINOPS: + TRACE(("CASE_XTERM_WINOPS\n")); + if (screen->allowWindowOps) + window_ops(term); + sp->parsestate = sp->groundtable; + 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) { + WriteNow(); + ChangeToWide(screen); + } + if (screen->wide_chars + && screen->utf8_mode != uAlways) { + 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")); + } + sp->parsestate = sp->groundtable; + break; +#endif + + case CASE_CSI_IGNORE: + sp->parsestate = cigtable; + break; + } + if (sp->parsestate == sp->groundtable) + sp->lastchar = thischar; + } while (0); + +#if OPT_WIDE_CHARS + screen->utf8_inparse = (screen->utf8_mode != uFalse + && sp->parsestate != sos_table); +#endif + + return True; +} + +static void +VTparse(void) +{ + TScreen *screen; + + /* We longjmp back to this point in VTReset() */ + (void) setjmp(vtjmpbuf); + screen = &term->screen; + memset(&myState, 0, sizeof(myState)); +#if OPT_VT52_MODE + myState.groundtable = screen->vtXX_level ? ansi_table : vt52_table; +#else + myState.groundtable = ansi_table; +#endif + myState.parsestate = myState.groundtable; + myState.lastchar = -1; /* not a legal IChar */ + myState.nextstate = -1; /* not a legal state */ + + for (;;) { + if (!doparsing(doinput(), &myState)) + return; + } +} + +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. */ + +int +v_write(int f, Char * data, unsigned len) +{ + int riten; + unsigned c = len; + + if (v_bufstr == NULL && len > 0) { + v_buffer = (Char *) XtMalloc(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, (char *) data); + fprintf(stderr, "\n"); + } +#endif + +#ifdef VMS + if ((1 << f) != pty_mask) + return (tt_write((char *) data, len)); +#else /* VMS */ + if (!FD_ISSET(f, &pty_mask)) + return (write(f, (char *) data, len)); +#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 + term->screen.dabbrev_working = 0; /* 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, (unsigned) (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. */ + int size = v_bufptr - v_buffer; /* save across realloc */ + 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 */ + c = 0; + } + } + } + if (v_bufend >= v_bufptr + len) { + /* new stuff will fit */ + memmove(v_bufptr, data, 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 = 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 = v_bufstr - v_buffer; + int size = 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 */ + } + } + return (c); +} + +#ifdef VMS +#define ptymask() (v_bufptr > v_bufstr ? pty_mask : 0) + +static void +in_put(void) +{ + static PtySelect select_mask; + static PtySelect write_mask; + int update = VTbuffer->update; + int size; + + int status; + Dimension replyWidth, replyHeight; + XtGeometryResult stat; + + TScreen *screen = &term->screen; + 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 = XtMakeResizeRequest((Widget) term, + ((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) { + term->core.width = replyWidth; + term->core.height = replyHeight; + + ScreenResize(&term->screen, replyWidth, replyHeight, + &term->flags); + } + repairSizeHints(); + } + + if (eventMode == NORMAL + && readPtyData(screen, &select_mask, VTbuffer)) { + if (screen->scrollWidget + && screen->scrollttyoutput + && screen->topline < 0) + /* Scroll to bottom */ + WindowScroll(screen, 0); + break; + } + if (screen->scroll_amt) + FlushScroll(screen); + 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 (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(void) +{ + static PtySelect select_mask; + static PtySelect write_mask; + + TScreen *screen = &term->screen; + 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 (eventMode == NORMAL + && (size = readPtyData(screen, &select_mask, VTbuffer)) != 0) { + if (screen->scrollWidget + && screen->scrollttyoutput + && screen->topline < 0) + WindowScroll(screen, 0); /* Scroll to bottom */ + /* stop speed reading at some point to look for X stuff */ + TRACE(("VTbuffer uses %d/%d\n", + 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(screen); + 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 (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) { + /* + * When session management is enabled, we should not block since + * session related events can arrive any time. + */ + select_timeout.tv_sec = 1; + select_timeout.tv_usec = 0; + time_select = 1; +#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 = &term->screen; + + while (!morePtyData(screen, VTbuffer)) + in_put(); + return nextPtyData(screen, VTbuffer); +} + +#if OPT_INPUT_METHOD +/* + * For OverTheSpot, client has to inform the position for XIM preedit. + */ +static void +PreeditPosition(TScreen * screen) +{ + XPoint spot; + XVaNestedList list; + + if (!screen->xic) + return; + spot.x = CurCursorX(screen, screen->cur_row, screen->cur_col); + spot.y = 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 + +/* + * process a string of characters according to the character set indicated + * by charset. worry about end of line conditions (wraparound if selected). + */ +void +dotext(TScreen * screen, + int charset, + IChar * buf, /* start of characters to process */ + Cardinal len) /* end */ +{ +#if OPT_WIDE_CHARS + Cardinal chars_chomped = 1; +#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 && charset == '0')) +#endif + + if (!xtermCharSetOut(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; + int need_wrap = 0; + chars_chomped = 0; + + if (screen->do_wrap && (term->flags & WRAPAROUND)) { + /* mark that we had to wrap this line */ + ScrnSetWrapped(screen, screen->cur_row); + xtermAutoPrint('\n'); + xtermIndex(screen, 1); + set_cur_col(screen, 0); + screen->do_wrap = 0; + width_available = MaxCols(screen) - screen->cur_col; + } + + while (width_here <= width_available && chars_chomped < (len - offset)) { + if (!screen->utf8_mode + || (screen->vt100_graphics && charset == '0')) + width_here++; + else + width_here += my_wcwidth((int) buf[chars_chomped + offset]); + chars_chomped++; + } + + if (width_here > width_available) { + chars_chomped--; + if (!screen->utf8_mode + || (screen->vt100_graphics && charset == '0')) + width_here--; + else + width_here -= my_wcwidth((int) buf[chars_chomped + offset]); + need_wrap = 1; + } else if (width_here == width_available) { + need_wrap = 1; + } else if (chars_chomped != (len - offset)) { + need_wrap = 1; + } + + /* + * 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) { + static unsigned limit; + static Char *hibyte, *lobyte; + Bool both = False; + unsigned j, k; + + if (chars_chomped >= limit) { + limit = (chars_chomped + 1) * 2; + lobyte = (Char *) XtRealloc((char *) lobyte, limit); + hibyte = (Char *) XtRealloc((char *) hibyte, limit); + } + for (j = offset; j < offset + chars_chomped; j++) { + k = j - offset; + lobyte[k] = buf[j]; + if (buf[j] > 255) { + hibyte[k] = (buf[j] >> 8); + both = True; + } else { + hibyte[k] = 0; + } + } + + WriteText(screen, PAIRED_CHARS(lobyte, + (both ? hibyte : 0)), + chars_chomped); + } + screen->do_wrap = need_wrap; + } +#else + + for (offset = 0; offset < len; offset += this_col) { + last_col = CurMaxCol(screen, screen->cur_row); + this_col = last_col - screen->cur_col + 1; + if (this_col <= 1) { + if (screen->do_wrap && (term->flags & WRAPAROUND)) { + /* mark that we had to wrap this line */ + ScrnSetWrapped(screen, screen->cur_row); + xtermAutoPrint('\n'); + xtermIndex(screen, 1); + set_cur_col(screen, 0); + screen->do_wrap = 0; + this_col = last_col + 1; + } else + this_col = 1; + } + if (offset + this_col > len) { + this_col = len - offset; + } + next_col = screen->cur_col + this_col; + + WriteText(screen, PAIRED_CHARS(buf + offset, + buf2 ? buf2 + offset : 0), + this_col); + + /* + * the call to WriteText updates screen->cur_col. + * If screen->cur_col != next_col, we must have + * hit the right margin, so set the do_wrap flag. + */ + screen->do_wrap = (screen->cur_col < (int) next_col); + } + +#endif +} + +#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! + */ +static int mapstate = -1; +#endif /* HANDLE_STRUCT_NOTIFY */ + +#if OPT_WIDE_CHARS +unsigned +visual_width(PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +{ + /* returns the visual width of a string (doublewide characters count + as 2, normalwide characters count as 1) */ + int my_len = 0; + while (len) { + int ch = *str; + if (str2) + ch |= *str2 << 8; + if (str) + str++; + if (str2) + str2++; + if (iswide(ch)) + my_len += 2; + else + my_len++; + len--; + } + return my_len; +} +#endif + +/* + * write a string str of length len onto the screen at + * the current cursor position. update cursor position. + */ +static void +WriteText(TScreen * screen, PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +{ + ScrnPtr PAIRED_CHARS(temp_str = 0, temp_str2 = 0); + unsigned test; + unsigned flags = term->flags; + unsigned fg_bg = makeColorPair(term->cur_foreground, term->cur_background); + unsigned cells = visual_width(PAIRED_CHARS(str, str2), len); + GC currentGC; + + TRACE(("WriteText (%2d,%2d) (%d) %3d:%s\n", + screen->cur_row, + screen->cur_col, + curXtermChrSet(screen->cur_row), + len, visibleChars(PAIRED_CHARS(str, str2), len))); + + if (ScrnHaveSelection(screen) + && ScrnIsLineInSelection(screen, screen->cur_row - screen->topline)) { + ScrnDisownSelection(screen); + } + + if (screen->cur_row - screen->topline <= screen->max_row) { + if (screen->cursor_state) + HideCursor(); + + if (flags & INSERT) { + InsertChar(screen, cells); + } + if (!AddToRefresh(screen)) { + + if (screen->scroll_amt) + FlushScroll(screen); + + if (flags & INVISIBLE) { + if (cells > len) { + str = temp_str = TypeMallocN(Char, cells); + if (str == 0) + return; + } + if_OPT_WIDE_CHARS(screen, { + if (cells > len) { + str2 = temp_str2 = TypeMallocN(Char, cells); + } + }); + len = cells; + + memset(str, ' ', len); + if_OPT_WIDE_CHARS(screen, { + if (str2 != 0) + memset(str2, 0, len); + }); + } + + TRACE(("WriteText calling drawXtermText (%d,%d)\n", + screen->cur_col, + screen->cur_row)); + + test = flags; + checkVeryBoldColors(test, term->cur_foreground); + + /* make sure that the correct GC is current */ + currentGC = updatedXtermGC(screen, flags, fg_bg, False); + + drawXtermText(screen, test & DRAWX_MASK, currentGC, + CurCursorX(screen, screen->cur_row, screen->cur_col), + CursorY(screen, screen->cur_row), + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(str, str2), len, 0); + + resetXtermGC(screen, flags, False); + } + } + + ScreenWrite(screen, PAIRED_CHARS(str, str2), flags, fg_bg, len); + CursorForward(screen, (int) cells); +#if OPT_ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + */ + if (zIconBeep && mapstate == IsUnmapped && !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) { + zIconBeep_flagged = True; + Changename(icon_name); + } + if (zIconBeep > 0) { +#if defined(HAVE_XKBBELL) + XkbBell(XtDisplay(toplevel), VShellWindow, zIconBeep, XkbBI_Info); +#else + XBell(XtDisplay(toplevel), zIconBeep); +#endif + } + } + mapstate = -1; +#endif /* OPT_ZICONBEEP */ + if (temp_str != 0) + free(temp_str); + if_OPT_WIDE_CHARS(screen, { + if (temp_str2 != 0) + free(temp_str2); + }); + return; +} + +#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} + }; + + switch (event->type) { + case MapNotify: + TRACE(("HandleStructNotify(MapNotify)\n")); +#if OPT_ZICONBEEP + if (zIconBeep_flagged) { + 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) { + zIconBeep_flagged = True; + return; + } + strcpy(buf, icon_name + 4); + Changename(buf); + free(buf); + } + } +#endif /* OPT_ZICONBEEP */ + mapstate = !IsUnmapped; + break; + case UnmapNotify: + TRACE(("HandleStructNotify(UnmapNotify)\n")); + mapstate = IsUnmapped; + break; + case ConfigureNotify: + TRACE(("HandleStructNotify(ConfigureNotify)\n")); +#if OPT_TOOLBAR + /* the notify is for the top-level widget, but we care about vt100 */ + if (term->screen.Vshow) { + TScreen *screen = &term->screen; + struct _vtwin *Vwin = WhichVWin(&(term->screen)); + 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. + */ + XtMakeResizeRequest((Widget) term, + screen->fullVwin.fullwidth, + info->menu_height + - save.menu_height + + screen->fullVwin.fullheight, + NULL, NULL); + repairSizeHints(); + } + } + } +#endif /* OPT_TOOLBAR */ + break; + default: + TRACE(("HandleStructNotify(event %d)\n", event->type)); + break; + } +} +#endif /* HANDLE_STRUCT_NOTIFY */ + +#if OPT_BLINK_CURS +static void +SetCursorBlink(TScreen * screen, int enable) +{ + screen->cursor_blink = enable; + if (DoStartBlinking(screen)) { + StartBlinking(screen); + } else { +#if !OPT_BLINK_TEXT + StopBlinking(screen); +#endif + } + update_cursorblink(); +} + +void +ToggleCursorBlink(TScreen * screen) +{ + SetCursorBlink(screen, !(screen->cursor_blink)); +} +#endif + +/* + * process ANSI modes set, reset + */ +static void +ansi_modes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)) +{ + int i; + + for (i = 0; i < nparam; ++i) { + switch (param[i]) { + case 2: /* KAM (if set, keyboard locked */ + (*func) (&termw->keyboard.flags, MODE_KAM); + break; + + case 4: /* IRM */ + (*func) (&termw->flags, INSERT); + break; + + case 12: /* SRM (if set, local echo */ + (*func) (&termw->keyboard.flags, MODE_SRM); + break; + + case 20: /* LNM */ + (*func) (&termw->flags, LINEFEED); + update_autolinefeed(); + break; + } + } +} + +#define set_mousemode(mode) \ + screen->send_mouse_pos = (func == bitset) ? mode : MOUSE_OFF +#define set_mouseflag(f) \ + ((func == bitset) \ + ? SCREEN_FLAG_set(screen, f) \ + : SCREEN_FLAG_unset(screen, f)) + +/* + * process DEC private modes set, reset + */ +static void +dpmodes(XtermWidget termw, + void (*func) (unsigned *p, unsigned mask)) +{ + TScreen *screen = &termw->screen; + int i, j; + + for (i = 0; i < nparam; ++i) { + TRACE(("%s %d\n", (func == bitset) ? "DECSET" : "DECRST", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + (*func) (&termw->keyboard.flags, MODE_DECCKM); + update_appcursor(); + break; + case 2: /* DECANM - ANSI/VT52 mode */ + if (func == bitset) { /* ANSI (VT100) */ + /* + * Setting DECANM should have no effect, since this function + * cannot be reached from vt52 mode. + */ + ; + } +#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(screen); + CursorSet(screen, 0, 0, termw->flags); + if ((j = func == bitset ? 132 : 80) != + ((termw->flags & IN132COLUMNS) ? 132 : 80) || + j != MaxCols(screen)) + RequestResize(termw, -1, j, True); + (*func) (&termw->flags, IN132COLUMNS); + } + break; + case 4: /* DECSCLM (slow scroll) */ + if (func == bitset) { + screen->jumpscroll = 0; + if (screen->scroll_amt) + FlushScroll(screen); + } else + screen->jumpscroll = 1; + (*func) (&termw->flags, SMOOTHSCROLL); + update_jumpscroll(); + break; + case 5: /* DECSCNM */ + j = termw->flags; + (*func) (&termw->flags, REVERSE_VIDEO); + if ((termw->flags ^ j) & REVERSE_VIDEO) + ReverseVideo(termw); + /* update_reversevideo done in RevVid */ + break; + + case 6: /* DECOM */ + (*func) (&termw->flags, ORIGIN); + CursorSet(screen, 0, 0, termw->flags); + break; + + case 7: /* DECAWM */ + (*func) (&termw->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, termw); + set_mousemode(X10_MOUSE); + break; +#if OPT_TOOLBAR + case 10: /* rxvt */ + ShowToolbar(func == bitset); + break; +#endif +#if OPT_BLINK_CURS + case 12: /* att610: Start/stop blinking cursor */ + if (screen->cursor_blink_res) { + screen->cursor_blink_esc = (func == bitset) ? ON : OFF; + SetCursorBlink(screen, screen->cursor_blink); + } + break; +#endif + case 18: /* DECPFF: print form feed */ + screen->printer_formfeed = (func == bitset) ? ON : OFF; + break; + case 19: /* DECPEX: print extent */ + screen->printer_extent = (func == bitset) ? ON : OFF; + break; + case 25: /* DECTCEM: Show/hide cursor (VT200) */ + screen->cursor_set = (func == bitset) ? ON : OFF; + break; + case 30: /* rxvt */ + if (screen->fullVwin.sb_info.width != ((func == bitset) ? ON : OFF)) + ToggleScrollBar(termw); + break; +#if OPT_SHIFT_FONTS + case 35: /* rxvt */ + term->misc.shift_fonts = (func == bitset) ? ON : OFF; + break; +#endif + case 38: /* DECTEK */ +#if OPT_TEK4014 + if (func == bitset && !(screen->inhibit & I_TEK)) { + FlushLog(screen); + screen->TekEmu = True; + } +#endif + break; + case 40: /* 132 column mode */ + screen->c132 = (func == bitset); + update_allow132(); + break; + case 41: /* curses hack */ + screen->curses = (func == bitset); + update_cursesemul(); + break; + case 42: /* DECNRCM national charset (VT220) */ + (*func) (&termw->flags, NATIONAL); + break; + case 44: /* margin bell */ + screen->marginbell = (func == bitset); + if (!screen->marginbell) + screen->bellarmed = -1; + update_marginbell(); + break; + case 45: /* reverse wraparound */ + (*func) (&termw->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 (func == bitset) + StartLog(screen); + else + CloseLog(screen); +#else + Bell(XkbBI_Info, 0); + Bell(XkbBI_Info, 0); +#endif /* ALLOWLOGFILEONOFF */ + break; +#endif + case 1049: /* alternate buffer & cursor */ + if (!termw->misc.titeInhibit) { + if (func == bitset) { + CursorSave(termw); + ToAlternate(screen); + ClearScreen(screen); + } else { + FromAlternate(screen); + CursorRestore(termw); + } + } else if (termw->misc.tiXtraScroll) { + if (func == bitset) { + xtermScroll(screen, screen->max_row); + } + } + break; + case 1047: + case 47: /* alternate buffer */ + if (!termw->misc.titeInhibit) { + if (func == bitset) { + ToAlternate(screen); + } else { + if (screen->alternate + && (param[i] == 1047)) + ClearScreen(screen); + FromAlternate(screen); + } + } else if (termw->misc.tiXtraScroll) { + if (func == bitset) { + xtermScroll(screen, screen->max_row); + } + } + break; + case 66: /* DECNKM */ + (*func) (&termw->keyboard.flags, MODE_DECKPAM); + update_appkeypad(); + break; + case 67: /* DECBKM */ + /* back-arrow mapped to backspace or delete(D) */ + (*func) (&termw->keyboard.flags, MODE_DECBKM); + TRACE(("DECSET DECBKM %s\n", + BtoS(termw->keyboard.flags & MODE_DECBKM))); + update_decbkm(); + break; + case SET_VT200_MOUSE: /* xterm bogus sequence */ + MotionOff(screen, termw); + set_mousemode(VT200_MOUSE); + break; + case SET_VT200_HIGHLIGHT_MOUSE: /* xterm sequence w/hilite tracking */ + MotionOff(screen, termw); + set_mousemode(VT200_HIGHLIGHT_MOUSE); + break; + case SET_BTN_EVENT_MOUSE: + MotionOff(screen, termw); + 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, term); + } else { + MotionOn(screen, term); + } + break; + case 1010: /* rxvt */ + screen->scrollttyoutput = (func == bitset) ? ON : OFF; + update_scrollttyoutput(); + break; + case 1011: /* rxvt */ + screen->scrollkey = (func == bitset) ? ON : OFF; + update_scrollkey(); + break; +#if OPT_NUM_LOCK + case 1035: + term->misc.real_NumLock = (func == bitset) ? ON : OFF; + update_num_lock(); + break; + case 1036: + screen->meta_sends_esc = (func == bitset) ? ON : OFF; + update_meta_esc(); + break; +#endif + case 1037: + screen->delete_is_del = (func == bitset) ? ON : OFF; + update_delete_del(); + break; + case 1048: + if (!termw->misc.titeInhibit) { + if (func == bitset) + CursorSave(termw); + else + CursorRestore(termw); + } + break; + case 1051: + set_keyboard_type(keyboardIsSun, func == bitset); + break; +#if OPT_HP_FUNC_KEYS + case 1052: + set_keyboard_type(keyboardIsHP, func == bitset); + break; +#endif +#if OPT_SCO_FUNC_KEYS + case 1053: + set_keyboard_type(keyboardIsSCO, func == bitset); + break; +#endif + case 1060: + set_keyboard_type(keyboardIsLegacy, func == bitset); + break; +#if OPT_SUNPC_KBD + case 1061: + set_keyboard_type(keyboardIsVT220, func == bitset); + 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 termw) +{ + TScreen *screen = &termw->screen; + int i; + + for (i = 0; i < nparam; i++) { + TRACE(("savemodes %d\n", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + DoSM(DP_DECCKM, termw->keyboard.flags & MODE_DECCKM); + break; + case 3: /* DECCOLM */ + if (screen->c132) + DoSM(DP_DECCOLM, termw->flags & IN132COLUMNS); + break; + case 4: /* DECSCLM (slow scroll) */ + DoSM(DP_DECSCLM, termw->flags & SMOOTHSCROLL); + break; + case 5: /* DECSCNM */ + DoSM(DP_DECSCNM, termw->flags & REVERSE_VIDEO); + break; + case 6: /* DECOM */ + DoSM(DP_DECOM, termw->flags & ORIGIN); + break; + + case 7: /* DECAWM */ + DoSM(DP_DECAWM, termw->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 44: /* margin bell */ + DoSM(DP_X_MARGIN, screen->marginbell); + break; + case 45: /* reverse wraparound */ + DoSM(DP_X_REVWRAP, termw->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->alternate); + 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; + case 1048: + if (!termw->misc.titeInhibit) { + CursorSave(termw); + } + 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 termw) +{ + TScreen *screen = &termw->screen; + int i, j; + + for (i = 0; i < nparam; i++) { + TRACE(("restoremodes %d\n", param[i])); + switch (param[i]) { + case 1: /* DECCKM */ + bitcpy(&termw->keyboard.flags, + screen->save_modes[DP_DECCKM], MODE_DECCKM); + update_appcursor(); + break; + case 3: /* DECCOLM */ + if (screen->c132) { + ClearScreen(screen); + CursorSet(screen, 0, 0, termw->flags); + if ((j = (screen->save_modes[DP_DECCOLM] & IN132COLUMNS) + ? 132 : 80) != ((termw->flags & IN132COLUMNS) + ? 132 : 80) || j != MaxCols(screen)) + RequestResize(termw, -1, j, True); + bitcpy(&termw->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(screen); + } else + screen->jumpscroll = 1; + bitcpy(&termw->flags, screen->save_modes[DP_DECSCLM], SMOOTHSCROLL); + update_jumpscroll(); + break; + case 5: /* DECSCNM */ + if ((screen->save_modes[DP_DECSCNM] ^ termw->flags) & REVERSE_VIDEO) { + bitcpy(&termw->flags, screen->save_modes[DP_DECSCNM], REVERSE_VIDEO); + ReverseVideo(termw); + /* update_reversevideo done in RevVid */ + } + break; + case 6: /* DECOM */ + bitcpy(&termw->flags, screen->save_modes[DP_DECOM], ORIGIN); + CursorSet(screen, 0, 0, termw->flags); + break; + + case 7: /* DECAWM */ + bitcpy(&termw->flags, screen->save_modes[DP_DECAWM], WRAPAROUND); + update_autowrap(); + break; + case 8: /* DECARM */ + /* ignore autorepeat */ + break; + case SET_X10_MOUSE: /* MIT bogus sequence */ + DoRM(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(&termw->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(screen); + else + CloseLog(screen); +#endif /* ALLOWLOGFILEONOFF */ + /* update_logging done by StartLog and CloseLog */ + break; +#endif + case 1047: /* alternate buffer */ + /* FALLTHRU */ + case 47: /* alternate buffer */ + if (!termw->misc.titeInhibit) { + if (screen->save_modes[DP_X_ALTSCRN]) + ToAlternate(screen); + else + FromAlternate(screen); + /* update_altscreen done by ToAlt and FromAlt */ + } else if (termw->misc.tiXtraScroll) { + if (screen->save_modes[DP_X_ALTSCRN]) { + xtermScroll(screen, 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: + DoRM(DP_X_MOUSE, screen->send_mouse_pos); + break; + case 1048: + if (!termw->misc.titeInhibit) { + CursorRestore(termw); + } + 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 */ + } + } +} + +/* + * Report window label (icon or title) in dtterm protocol + * ESC ] code label ESC backslash + */ +static void +report_win_label(TScreen * screen, + int code, + XTextProperty * text, + Status ok) +{ + char **list; + int length = 0; + + reply.a_type = ESC; + unparseputc(ESC, screen->respond); + unparseputc(']', screen->respond); + unparseputc(code, screen->respond); + + if (ok) { + if (XTextPropertyToStringList(text, &list, &length)) { + int n, c; + for (n = 0; n < length; n++) { + char *s = list[n]; + while ((c = *s++) != '\0') + unparseputc(c, screen->respond); + } + XFreeStringList(list); + } + if (text->value != 0) + XFree(text->value); + } + + unparseputc(ESC, screen->respond); + unparseputc('\\', screen->respond); +} + +/* + * Window operations (from CDE dtterm description, as well as extensions). + * See also "allowWindowOps" resource. + */ +static void +window_ops(XtermWidget termw) +{ + TScreen *screen = &termw->screen; + XWindowChanges values; + XWindowAttributes win_attrs; + XTextProperty text; + unsigned value_mask; + unsigned root_width; + unsigned root_height; + + TRACE(("window_ops %d\n", param[0])); + switch (param[0]) { + case 1: /* Restore (de-iconify) window */ + XMapWindow(screen->display, + VShellWindow); + break; + + case 2: /* Minimize (iconify) window */ + XIconifyWindow(screen->display, + VShellWindow, + DefaultScreen(screen->display)); + break; + + case 3: /* Move the window to the given position */ + values.x = param[1]; + values.y = param[2]; + value_mask = (CWX | CWY); + XReconfigureWMWindow(screen->display, + VShellWindow, + DefaultScreen(screen->display), + value_mask, + &values); + break; + + case 4: /* Resize the window to given size in pixels */ + RequestResize(termw, param[1], param[2], False); + break; + + case 5: /* Raise the window to the front of the stack */ + XRaiseWindow(screen->display, VShellWindow); + break; + + case 6: /* Lower the window to the bottom of the stack */ + XLowerWindow(screen->display, VShellWindow); + break; + + case 7: /* Refresh the window */ + Redraw(); + break; + + case 8: /* Resize the text-area, in characters */ + RequestResize(termw, param[1], param[2], True); + break; + +#if OPT_MAXIMIZE + case 9: /* Maximize or restore */ + RequestMaximize(termw, param[1]); + break; +#endif + + case 11: /* Report the window's state */ + XGetWindowAttributes(screen->display, + VWindow(screen), + &win_attrs); + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 1; + reply.a_param[0] = (win_attrs.map_state == IsViewable) ? 1 : 2; + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 13: /* Report the window's position */ + XGetWindowAttributes(screen->display, + WMFrameWindow(termw), + &win_attrs); + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 3; + reply.a_param[1] = win_attrs.x; + reply.a_param[2] = win_attrs.y; + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 14: /* Report the window's size in pixels */ + XGetWindowAttributes(screen->display, + VWindow(screen), + &win_attrs); + reply.a_type = 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] = Height(screen); + reply.a_param[2] = Width(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + + case 18: /* Report the text's size in characters */ + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 8; + reply.a_param[1] = MaxRows(screen); + reply.a_param[2] = MaxCols(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; + +#if OPT_MAXIMIZE + case 19: /* Report the screen's size, in characters */ + if (!QueryMaximize(term, &root_height, &root_width)) { + root_height = 0; + root_width = 0; + } + reply.a_type = CSI; + reply.a_pintro = 0; + reply.a_nparam = 3; + reply.a_param[0] = 9; + reply.a_param[1] = root_height / FontHeight(screen); + reply.a_param[2] = root_width / FontWidth(screen); + reply.a_inters = 0; + reply.a_final = 't'; + unparseseq(&reply, screen->respond); + break; +#endif + + case 20: /* Report the icon's label */ + report_win_label(screen, 'L', &text, + XGetWMIconName(screen->display, VShellWindow, &text)); + break; + + case 21: /* Report the window's title */ + report_win_label(screen, 'l', &text, + XGetWMName(screen->display, VShellWindow, &text)); + break; + + default: /* DECSLPP (24, 25, 36, 48, 72, 144) */ + if (param[0] >= 24) + RequestResize(termw, 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(int c, int fd) +{ + if (c >= 0x80 && c <= 0x9F) { + if (!term->screen.control_eight_bits) { + unparseputc(A2E(ESC), fd); + c = A2E(c - 0x40); + } + } + unparseputc(c, fd); +} + +void +unparseseq(ANSI * ap, int fd) +{ + int c; + int i; + int inters; + + unparseputc1(c = ap->a_type, fd); + if (c == ESC + || c == DCS + || c == CSI + || c == OSC + || c == PM + || c == APC + || c == SS3) { + if (ap->a_pintro != 0) + unparseputc(ap->a_pintro, fd); + for (i = 0; i < ap->a_nparam; ++i) { + if (i != 0) + unparseputc(';', fd); + unparseputn((unsigned int) ap->a_param[i], fd); + } + if ((inters = ap->a_inters) != 0) { + for (i = 3; i >= 0; --i) { + c = CharOf(inters >> (8 * i)); + if (c != 0) + unparseputc(c, fd); + } + } + unparseputc((char) ap->a_final, fd); + } +} + +static void +unparseputn(unsigned int n, int fd) +{ + unsigned int q; + + q = n / 10; + if (q != 0) + unparseputn(q, fd); + unparseputc((char) ('0' + (n % 10)), fd); +} + +void +unparseputc(int c, int fd) +{ + IChar buf[2]; + unsigned i = 1; + +#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 (term->screen.tc_query >= 0) { + char tmp[3]; + sprintf(tmp, "%02X", c & 0xFF); + buf[0] = tmp[0]; + buf[1] = tmp[1]; + i = 2; + } else +#endif + if ((buf[0] = c) == '\r' && (term->flags & LINEFEED)) { + buf[1] = '\n'; + i++; + } +#ifdef VMS + tt_write(&buf, i); +#else /* VMS */ + writePtyData(fd, buf, i); +#endif /* VMS */ + + /* If send/receive mode is reset, we echo characters locally */ + if ((term->keyboard.flags & MODE_SRM) == 0) { + (void) doparsing((unsigned) c, &myState); + } +} + +void +unparseputs(char *s, int fd) +{ + while (*s) + unparseputc(*s++, fd); +} + +void +ToggleAlternate(TScreen * screen) +{ + if (screen->alternate) + FromAlternate(screen); + else + ToAlternate(screen); +} + +static void +ToAlternate(TScreen * screen) +{ + if (screen->alternate) + return; + TRACE(("ToAlternate\n")); + if (!screen->altbuf) + screen->altbuf = Allocate(MaxRows(screen), MaxCols(screen), + &screen->abuf_address); + SwitchBufs(screen); + screen->alternate = True; + update_altscreen(); +} + +static void +FromAlternate(TScreen * screen) +{ + if (!screen->alternate) + return; + TRACE(("FromAlternate\n")); + if (screen->scroll_amt) + FlushScroll(screen); + screen->alternate = False; + SwitchBufs(screen); + update_altscreen(); +} + +static void +SwitchBufs(TScreen * screen) +{ + int rows, top; + + if (screen->cursor_state) + HideCursor(); + + rows = MaxRows(screen); + SwitchBufPtrs(screen); + + if ((top = -screen->topline) < rows) { + if (screen->scroll_amt) + FlushScroll(screen); + if (top == 0) + XClearWindow(screen->display, VWindow(screen)); + else + XClearArea(screen->display, + VWindow(screen), + (int) OriginX(screen), + (int) top * FontHeight(screen) + screen->border, + (unsigned) Width(screen), + (unsigned) (rows - top) * FontHeight(screen), + False); + } + ScrnUpdate(screen, 0, 0, rows, MaxCols(screen), False); +} + +/* swap buffer line pointers between alt and regular screens */ +void +SwitchBufPtrs(TScreen * screen) +{ + size_t len = ScrnPointers(screen, (unsigned) MaxRows(screen)); + + memcpy((char *) screen->save_ptr, (char *) screen->visbuf, len); + memcpy((char *) screen->visbuf, (char *) screen->altbuf, len); + memcpy((char *) screen->altbuf, (char *) screen->save_ptr, len); +} + +void +VTRun(void) +{ + TScreen *screen = &term->screen; + + TRACE(("VTRun ...\n")); + + if (!screen->Vshow) { + set_vt_visibility(True); + } + update_vttekmode(); + update_vtshow(); + update_tekshow(); + set_vthide_sensitivity(); + + if (screen->allbuf == NULL) + VTallocbuf(); + + 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(screen, VTbuffer, (char *) Tpushback, Tpushb - Tpushback); + Tpushb = Tpushback; + } +#endif + if (!setjmp(VTend)) + VTparse(); + StopBlinking(screen); + HideCursor(); + screen->cursor_set = OFF; +} + +/*ARGSUSED*/ +static void +VTExpose(Widget w GCC_UNUSED, + XEvent * event, + Region region GCC_UNUSED) +{ + TScreen *screen = &term->screen; + +#ifdef DEBUG + if (debug) + fputs("Expose\n", stderr); +#endif /* DEBUG */ + if (event->type == Expose) + HandleExposure(screen, event); +} + +static void +VTGraphicsOrNoExpose(XEvent * event) +{ + TScreen *screen = &term->screen; + if (screen->incopy <= 0) { + screen->incopy = 1; + if (screen->scrolls > 0) + screen->scrolls--; + } + if (event->type == GraphicsExpose) + if (HandleExposure(screen, 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)) { + ScreenResize(&term->screen, term->core.width, term->core.height, &term->flags); + } +} + +#define okDimension(src,dst) ((src <= 32767) && ((dst = src) == src)) + +static void +RequestResize(XtermWidget termw, int rows, int cols, int text) +{ +#ifndef nothack + XSizeHints sizehints; + long supp; +#endif + TScreen *screen = &termw->screen; + 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 ((askedWidth = cols) < cols + || (askedHeight = rows) < rows) + return; + + if (askedHeight == 0 + || askedWidth == 0 + || term->misc.limit_resize > 0) { + XGetWindowAttributes(XtDisplay(termw), + RootWindowOfScreen(XtScreen(termw)), &attrs); + } + + if (text) { + if ((value = rows) != 0) { + if (rows < 0) + value = MaxRows(screen); + value *= FontHeight(screen); + value += (2 * screen->border); + if (!okDimension(value, askedHeight)) + return; + } + + if ((value = cols) != 0) { + if (cols < 0) + value = MaxCols(screen); + value *= FontWidth(screen); + value += (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 = attrs.height; + if (cols == 0) + askedWidth = attrs.width; + + if (term->misc.limit_resize > 0) { + Dimension high = term->misc.limit_resize * attrs.height; + Dimension wide = term->misc.limit_resize * attrs.width; + if (high < attrs.height) + high = attrs.height; + if (askedHeight > high) + askedHeight = high; + if (wide < attrs.width) + wide = attrs.width; + if (askedWidth > wide) + askedWidth = wide; + } +#ifndef nothack + if (!XGetWMNormalHints(screen->display, VShellWindow, + &sizehints, &supp)) + bzero(&sizehints, sizeof(sizehints)); +#endif + + status = XtMakeResizeRequest((Widget) termw, + askedWidth, askedHeight, + &replyWidth, &replyHeight); + TRACE(("charproc.c XtMakeResizeRequest %dx%d -> %dx%d (status %d)\n", + askedHeight, askedWidth, + replyHeight, replyWidth, + status)); + + if (status == XtGeometryYes || + status == XtGeometryDone) { + ScreenResize(&termw->screen, + replyWidth, + replyHeight, + &termw->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 (sizehints.flags + && replyHeight + && replyWidth) { + sizehints.height = replyHeight; + sizehints.width = replyWidth; + + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_HINTS(&sizehints); + XSetWMNormalHints(screen->display, VShellWindow, &sizehints); + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_WM_HINTS(termw); + } +#endif + + XSync(screen->display, False); /* synchronize */ + if (XtAppPending(app_con)) + xevents(); +} + +static String xterm_trans = +"WM_PROTOCOLS: DeleteWindow()\n\ + : KeyboardMapping()\n"; + +int +VTInit(void) +{ + TScreen *screen = &term->screen; + Widget vtparent = SHELL_OF(term); + + 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) (term)); + + if (screen->allbuf == NULL) + VTallocbuf(); + return (1); +} + +static void +VTallocbuf(void) +{ + TScreen *screen = &term->screen; + int nrows = MaxRows(screen); + + /* allocate screen buffer now, if necessary. */ + if (screen->scrollWidget) + nrows += screen->savelines; + screen->allbuf = Allocate(nrows, MaxCols(screen), + &screen->sbuf_address); + if (screen->scrollWidget) + screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; + else + screen->visbuf = screen->allbuf; + return; +} + +static void +VTClassInit(void) +{ + XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity, + (XtConvertArgList) NULL, (Cardinal) 0); +} + +/* + * 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_Dres(name) \ + TRACE(("init " #name " = %f\n", \ + wnew->name = request->name)) +#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 : "")) +#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_Dres(name) wnew->name = request->name +#define init_Ires(name) wnew->name = request->name +#define init_Sres(name) wnew->name = x_strtrim(request->name) +#define init_Tres(offset) fill_Tres(wnew, request, offset) +#endif + +#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; + + target->screen.Tcolors[offset] = source->screen.Tcolors[offset]; + target->screen.Tcolors[offset].mode = False; + + if ((name = x_strtrim(target->screen.Tcolors[offset].resource)) != 0) + target->screen.Tcolors[offset].resource = name; + + if (name == 0) { + target->screen.Tcolors[offset].value = target->dft_foreground; + } else if (!x_strcasecmp(name, XtDefaultForeground)) { + target->screen.Tcolors[offset].value = + ((offset == TEXT_FG || offset == TEXT_BG) + ? target->dft_foreground + : target->screen.Tcolors[TEXT_FG].value); + } else if (!x_strcasecmp(name, XtDefaultBackground)) { + target->screen.Tcolors[offset].value = + ((offset == TEXT_FG || offset == TEXT_BG) + ? target->dft_background + : target->screen.Tcolors[TEXT_BG].value); + } else { + if (AllocateTermColor(target, &temp, offset, name)) { + target->screen.Tcolors[offset].value = temp.colors[offset]; + } + } + return target->screen.Tcolors[offset].value; +} +#else +#define fill_Tres(target, source, offset) \ + target->screen.Tcolors[offset] = source->screen.Tcolors[offset] +#endif + +#if OPT_WIDE_CHARS +static void +VTInitialize_locale(XtermWidget request) +{ + Bool is_utf8 = xtermEnvUTF8(); + + TRACE(("VTInitialize_locale\n")); + TRACE(("... request screen.utf8_mode = %d\n", request->screen.utf8_mode)); + + if (request->screen.utf8_mode < 0) + request->screen.utf8_mode = uFalse; + + if (request->screen.utf8_mode > 3) + request->screen.utf8_mode = uDefault; + + request->screen.latin9_mode = 0; + request->screen.unicode_font = 0; +#if OPT_LUIT_PROG + request->misc.callfilter = 0; + request->misc.use_encoding = 0; + + TRACE(("... setup for luit:\n")); + TRACE(("... request misc.locale_str = \"%s\"\n", request->misc.locale_str)); + + if (request->screen.utf8_mode == uFalse) { + TRACE(("... command-line +u8 overrides\n")); + } else +#if OPT_MINI_LUIT + if (x_strcasecmp(request->misc.locale_str, "CHECKFONT") == 0) { + int fl = (request->misc.default_font.f_n + ? strlen(request->misc.default_font.f_n) + : 0); + if (fl > 11 + && x_strcasecmp(request->misc.default_font.f_n + fl - 11, + "-ISO10646-1") == 0) { + request->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 (request->screen.utf8_mode == uDefault) + request->screen.utf8_mode = uFalse; + } else if (!strcmp(xtermEnvEncoding(), "ISO-8859-15")) { + if (request->screen.utf8_mode == uDefault) + request->screen.utf8_mode = uFalse; + request->screen.latin9_mode = 1; + } else { + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; + } +#else + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; +#endif + } else { + /* other encoding, use False */ + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } + } + } else +#endif /* OPT_MINI_LUIT */ + if (x_strcasecmp(request->misc.locale_str, "TRUE") == 0 || + x_strcasecmp(request->misc.locale_str, "ON") == 0 || + x_strcasecmp(request->misc.locale_str, "YES") == 0 || + x_strcasecmp(request->misc.locale_str, "AUTO") == 0 || + strcmp(request->misc.locale_str, "1") == 0) { + /* when true ... fully obeying LC_CTYPE locale */ + request->misc.callfilter = is_utf8 ? 0 : 1; + request->screen.utf8_mode = uAlways; + } else if (x_strcasecmp(request->misc.locale_str, "FALSE") == 0 || + x_strcasecmp(request->misc.locale_str, "OFF") == 0 || + x_strcasecmp(request->misc.locale_str, "NO") == 0 || + strcmp(request->misc.locale_str, "0") == 0) { + /* when false ... original value of utf8_mode is effective */ + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } + } else if (x_strcasecmp(request->misc.locale_str, "MEDIUM") == 0 || + x_strcasecmp(request->misc.locale_str, "SEMIAUTO") == 0) { + /* when medium ... obeying locale only for UTF-8 and Asian */ + if (is_utf8) { + request->screen.utf8_mode = uAlways; + } else if ( +#ifdef MB_CUR_MAX + MB_CUR_MAX > 1 || +#else + !strncmp(xtermEnvLocale(), "ja", 2) || + !strncmp(xtermEnvLocale(), "ko", 2) || + !strncmp(xtermEnvLocale(), "zh", 2) || +#endif + !strncmp(xtermEnvLocale(), "th", 2) || + !strncmp(xtermEnvLocale(), "vi", 2)) { + request->misc.callfilter = 1; + request->screen.utf8_mode = uAlways; + } else { + request->screen.utf8_mode = uFalse; + } + } else if (x_strcasecmp(request->misc.locale_str, "UTF-8") == 0 || + x_strcasecmp(request->misc.locale_str, "UTF8") == 0) { + /* when UTF-8 ... UTF-8 mode */ + request->screen.utf8_mode = uAlways; + } else { + /* other words are regarded as encoding name passed to luit */ + request->misc.callfilter = 1; + request->screen.utf8_mode = uAlways; + request->misc.use_encoding = 1; + } + TRACE(("... updated misc.callfilter = %s\n", BtoS(request->misc.callfilter))); + TRACE(("... updated misc.use_encoding = %s\n", BtoS(request->misc.use_encoding))); +#else + if (request->screen.utf8_mode == uDefault) { + request->screen.utf8_mode = is_utf8 ? uAlways : uFalse; + } +#endif /* OPT_LUIT_PROG */ + + request->screen.utf8_inparse = (request->screen.utf8_mode != uFalse); + + TRACE(("... updated screen.utf8_mode = %d\n", request->screen.utf8_mode)); + TRACE(("...VTInitialize_locale done\n")); +} +#endif + +/* ARGSUSED */ +static void +VTInitialize(Widget wrequest, + Widget new_arg, + ArgList args GCC_UNUSED, + Cardinal *num_args GCC_UNUSED) +{ + XtermWidget request = (XtermWidget) wrequest; + XtermWidget wnew = (XtermWidget) new_arg; + Widget my_parent = SHELL_OF(wnew); + int i; + char *s; + +#if OPT_ISO_COLORS + Bool color_ok; +#endif + +#if OPT_COLOR_RES2 && (MAXCOLORS > MIN_ANSI_COLORS) + 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\n")); + + /* 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. + */ + bzero((char *) &wnew->screen, sizeof(wnew->screen)); + + /* 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. + */ + wnew->screen.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(wnew->screen.display); + wnew->dft_background = MyBlackPixel(wnew->screen.display); + } else { + wnew->dft_foreground = MyBlackPixel(wnew->screen.display); + wnew->dft_background = MyWhitePixel(wnew->screen.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(&(wnew->screen), TEXT_FG))); + TRACE((" Screen background %#lx\n", T_COLOR(&(wnew->screen), TEXT_BG))); + + wnew->screen.mouse_button = -1; + wnew->screen.mouse_row = -1; + wnew->screen.mouse_col = -1; + +#if OPT_BOX_CHARS + init_Bres(screen.force_box_chars); + 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); + wnew->screen.cursor_blink_res = wnew->screen.cursor_blink; +#endif +#if OPT_BLINK_TEXT + init_Ires(screen.blink_as_bold); +#endif + init_Ires(screen.border); + init_Bres(screen.jumpscroll); + init_Bres(screen.old_fkeys); + init_Bres(screen.delete_is_del); + wnew->keyboard.type = wnew->screen.old_fkeys + ? keyboardIsLegacy + : keyboardIsDefault; +#ifdef ALLOWLOGGING + init_Sres(screen.logfile); +#endif + 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_Sres(screen.term_id); + for (s = request->screen.term_id; *s; s++) { + if (!isalpha(CharOf(*s))) + break; + } + wnew->screen.terminal_id = atoi(s); + if (wnew->screen.terminal_id < MIN_DECID) + wnew->screen.terminal_id = MIN_DECID; + if (wnew->screen.terminal_id > MAX_DECID) + wnew->screen.terminal_id = MAX_DECID; + TRACE(("term_id '%s' -> terminal_id %d\n", + wnew->screen.term_id, + wnew->screen.terminal_id)); + + wnew->screen.vtXX_level = (wnew->screen.terminal_id / 100); + 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_left = 0; + wnew->misc.alt_right = 0; + wnew->misc.meta_trans = False; + wnew->misc.meta_left = 0; + wnew->misc.meta_right = 0; +#endif +#if OPT_SHIFT_FONTS + init_Bres(misc.shift_fonts); +#endif +#if OPT_SUNPC_KBD + init_Ires(misc.ctrl_fkeys); +#endif +#if OPT_TEK4014 + init_Bres(misc.tekInhibit); + init_Bres(misc.tekSmall); + init_Bres(screen.TekEmu); +#endif +#if OPT_TCAP_QUERY + wnew->screen.tc_query = -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.cutNewline); + init_Bres(screen.cutToBeginningOfLine); + init_Bres(screen.highlight_selection); + init_Bres(screen.trim_selection); + init_Bres(screen.i18nSelections); + init_Bres(screen.brokenSelections); + init_Bres(screen.always_highlight); + wnew->screen.pointer_cursor = request->screen.pointer_cursor; + + 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_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.meta_sends_esc); + + init_Bres(screen.allowSendEvent0); + init_Bres(screen.allowWindowOp0); + + /* make a copy so that editres cannot change the resource after startup */ + wnew->screen.allowSendEvents = wnew->screen.allowSendEvent0; + wnew->screen.allowWindowOps = wnew->screen.allowWindowOp0; + +#ifndef NO_ACTIVE_ICON + wnew->screen.fnt_icon = request->screen.fnt_icon; + 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.titeInhibit); + init_Bres(misc.tiXtraScroll); + init_Bres(misc.dynamicColors); + for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) { + init_Sres(screen.MenuFontName(i)); + } + /* set default in realize proc */ + wnew->screen.MenuFontName(fontMenu_fontdefault) = NULL; + wnew->screen.MenuFontName(fontMenu_fontescape) = NULL; + wnew->screen.MenuFontName(fontMenu_fontsel) = NULL; + wnew->screen.menu_font_number = fontMenu_fontdefault; + +#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_DEC_CHRSET + init_Bres(screen.font_doublesize); + init_Ires(screen.cache_doublesize); + if (wnew->screen.cache_doublesize > NUM_CHRSET) + wnew->screen.cache_doublesize = NUM_CHRSET; + if (wnew->screen.cache_doublesize == 0) + wnew->screen.font_doublesize = False; + TRACE(("Doublesize%s enabled, up to %d fonts\n", + wnew->screen.font_doublesize ? "" : " not", + wnew->screen.cache_doublesize)); +#endif + +#if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS + wnew->num_ptrs = (OFF_ATTRS + 1); /* OFF_FLAGS, OFF_CHARS, OFF_ATTRS */ +#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); + + for (i = 0, color_ok = False; i < MAXCOLORS; i++) { + +#if OPT_COLOR_RES2 && (MAXCOLORS > MIN_ANSI_COLORS) + /* + * 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) { + wnew->screen.Acolors[i].resource + = ((char *) fake_resources[i - MIN_ANSI_COLORS].default_addr); + if (wnew->screen.Acolors[i].resource == 0) + wnew->screen.Acolors[i].resource = XtDefaultForeground; + } else +#endif /* OPT_COLOR_RES2 */ + wnew->screen.Acolors[i] = request->screen.Acolors[i]; + +#if OPT_COLOR_RES + TRACE(("Acolors[%d] = %s\n", i, wnew->screen.Acolors[i].resource)); + wnew->screen.Acolors[i].mode = False; + if (!x_strcasecmp(wnew->screen.Acolors[i].resource, XtDefaultForeground)) { + wnew->screen.Acolors[i].value = T_COLOR(&(wnew->screen), TEXT_FG); + wnew->screen.Acolors[i].mode = True; + } else if (!x_strcasecmp(wnew->screen.Acolors[i].resource, XtDefaultBackground)) { + wnew->screen.Acolors[i].value = T_COLOR(&(wnew->screen), TEXT_BG); + wnew->screen.Acolors[i].mode = True; + } else { + color_ok = True; + } +#else + TRACE(("Acolors[%d] = %#lx\n", i, request->screen.Acolors[i])); + if (wnew->screen.Acolors[i] != wnew->dft_foreground && + wnew->screen.Acolors[i] != T_COLOR(&(wnew->screen), TEXT_FG) && + wnew->screen.Acolors[i] != T_COLOR(&(wnew->screen), 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 = wnew->screen.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) { + wnew->screen.colorMode = False; + TRACE(("All colors are foreground or background: disable colorMode\n")); + } +#if OPT_EXT_COLORS + wnew->num_ptrs = (OFF_BGRND + 1); +#else + wnew->num_ptrs = (OFF_COLOR + 1); +#endif + wnew->sgr_foreground = -1; + wnew->sgr_background = -1; + wnew->sgr_extended = 0; +#endif /* OPT_ISO_COLORS */ + + init_Tres(MOUSE_FG); + init_Tres(MOUSE_BG); + init_Tres(TEXT_CURSOR); +#if OPT_HIGHLIGHT_COLOR + init_Tres(HIGHLIGHT_BG); +#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. + */ + T_COLOR(&(wnew->screen), TEK_BG) = T_COLOR(&(wnew->screen), TEXT_BG); + T_COLOR(&(wnew->screen), TEK_FG) = T_COLOR(&(wnew->screen), TEXT_FG); + T_COLOR(&(wnew->screen), TEK_CURSOR) = T_COLOR(&(wnew->screen), TEXT_CURSOR); +#endif + +#if OPT_DEC_CHRSET + wnew->num_ptrs = (OFF_CSETS + 1); +#endif + +#if OPT_WIDE_CHARS + VTInitialize_locale(request); + +#if OPT_LUIT_PROG + init_Bres(misc.callfilter); + init_Bres(misc.use_encoding); + init_Sres(misc.locale_str); + init_Sres(misc.localefilter); +#endif + +#if OPT_RENDERFONT + init_Dres(misc.face_size); + init_Sres(misc.face_name); + init_Sres(misc.face_wide_name); + init_Bres(misc.render_font); + /* minor tweak to make debug traces consistent: */ + if (wnew->misc.render_font) { + if (wnew->misc.face_name == 0) { + wnew->misc.render_font = False; + TRACE(("reset render_font since there is no face_name\n")); + } + } +#endif + + init_Bres(screen.vt100_graphics); + init_Ires(screen.utf8_mode); + init_Bres(screen.wide_chars); + init_Bres(misc.mk_width); + init_Bres(misc.cjk_width); + if (request->screen.utf8_mode) { + TRACE(("setting wide_chars on\n")); + wnew->screen.wide_chars = True; + } else { + TRACE(("setting utf8_mode to 0\n")); + wnew->screen.utf8_mode = uFalse; + } + TRACE(("initialized UTF-8 mode to %d\n", wnew->screen.utf8_mode)); + +#if OPT_MINI_LUIT + if (request->screen.latin9_mode) { + wnew->screen.latin9_mode = True; + } + if (request->screen.unicode_font) { + wnew->screen.unicode_font = True; + } + TRACE(("initialized Latin9 mode to %d\n", wnew->screen.latin9_mode)); + TRACE(("initialized unicode_font to %d\n", wnew->screen.unicode_font)); +#endif + + if (wnew->screen.wide_chars != False) + wnew->num_ptrs = (OFF_COM2H + 1); + + decode_wcwidth((wnew->misc.cjk_width ? 2 : 0) + + (wnew->misc.mk_width ? 1 : 0) + + 1); +#endif /* OPT_WIDE_CHARS */ + + init_Bres(screen.bold_mode); + init_Bres(screen.underline); + + wnew->cur_foreground = 0; + wnew->cur_background = 0; + + wnew->keyboard.flags = MODE_SRM; + if (wnew->screen.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. + */ + 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 (zIconBeep) +#endif + XtAddEventHandler(my_parent, StructureNotifyMask, False, + HandleStructNotify, (Opaque) 0); +#endif /* HANDLE_STRUCT_NOTIFY */ + + wnew->screen.bellInProgress = False; + + set_character_class(wnew->screen.charClass); + + /* create it, but don't realize it */ + ScrollBarOn(wnew, True, False); + + /* make sure that the resize gravity acceptable */ + if (wnew->misc.resizeGravity != NorthWestGravity && + wnew->misc.resizeGravity != SouthWestGravity) { + Cardinal nparams = 1; + + XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError", + "unsupported resizeGravity resource value (%d)", + (String *) & (wnew->misc.resizeGravity), &nparams); + wnew->misc.resizeGravity = SouthWestGravity; + } +#ifndef NO_ACTIVE_ICON + wnew->screen.whichVwin = &wnew->screen.fullVwin; +#if OPT_TEK4014 + wnew->screen.whichTwin = &wnew->screen.fullTwin; +#endif +#endif /* NO_ACTIVE_ICON */ + + if (wnew->screen.savelines < 0) + wnew->screen.savelines = 0; + + init_Bres(screen.awaitInput); + + wnew->flags = 0; + if (!wnew->screen.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 (wnew->screen.c132) + wnew->flags |= IN132COLUMNS; + + wnew->initflags = wnew->flags; + + init_Ires(keyboard.modify_cursor_keys); + + 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; + + return; +} + +static void +VTDestroy(Widget w) +{ + XtFree((char *) (((XtermWidget) w)->screen.selection_data)); +} + +/*ARGSUSED*/ +static void +VTRealize(Widget w, + XtValueMask * valuemask, + XSetWindowAttributes * values) +{ + XtermWidget xw = (XtermWidget) w; + TScreen *screen = &xw->screen; + + unsigned width, height; + int xpos, ypos, pr; + XSizeHints sizehints; + Atom pid_atom; + + TRACE(("VTRealize\n")); + + TabReset(xw->tabs); + + screen->MenuFontName(fontMenu_fontdefault) = xw->misc.default_font.f_n; + screen->fnt_norm = NULL; + screen->fnt_bold = NULL; +#if OPT_WIDE_CHARS + screen->fnt_dwd = NULL; + screen->fnt_dwdb = NULL; +#endif + if (!xtermLoadFont(xw, + &(xw->misc.default_font), + False, 0)) { + if (XmuCompareISOLatin1(xw->misc.default_font.f_n, "fixed") != 0) { + fprintf(stderr, + "%s: unable to open font \"%s\", trying \"fixed\"....\n", + xterm_name, xw->misc.default_font.f_n); + (void) xtermLoadFont(xw, + xtermFontName("fixed"), + False, 0); + screen->MenuFontName(fontMenu_fontdefault) = "fixed"; + } + } + + /* really screwed if we couldn't open default font */ + if (!screen->fnt_norm) { + fprintf(stderr, "%s: unable to locate a suitable font\n", + xterm_name); + Exit(1); + } +#if OPT_WIDE_CHARS + if (xw->screen.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->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)) + - width - (BorderWidth(XtParent(xw)) * 2); + } + if ((pr & YValue) && (YNegative & pr)) { + ypos += DisplayHeight(screen->display, DefaultScreen(screen->display)) + - height - (BorderWidth(XtParent(xw)) * 2); + } + + /* set up size hints for window manager; min 1 char by 1 char */ + bzero(&sizehints, sizeof(sizehints)); + xtermSizeHints(xw, &sizehints, (xw->misc.scrollbar + ? (screen->scrollWidget->core.width + + BorderWidth(screen->scrollWidget)) + : 0)); + + sizehints.x = xpos; + sizehints.y = ypos; + if ((XValue & pr) || (YValue & pr)) { + sizehints.flags |= USSize | USPosition; + sizehints.flags |= PWinGravity; + switch (pr & (XNegative | YNegative)) { + case 0: + sizehints.win_gravity = NorthWestGravity; + break; + case XNegative: + sizehints.win_gravity = NorthEastGravity; + break; + case YNegative: + sizehints.win_gravity = SouthWestGravity; + break; + default: + sizehints.win_gravity = SouthEastGravity; + break; + } + } else { + /* set a default size, but do *not* set position */ + sizehints.flags |= PSize; + } + sizehints.height = sizehints.base_height + + sizehints.height_inc * MaxRows(screen); + sizehints.width = sizehints.base_width + + sizehints.width_inc * MaxCols(screen); + + if ((WidthValue & pr) || (HeightValue & pr)) + sizehints.flags |= USSize; + else + sizehints.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. + */ + TRACE(("make resize request %dx%d\n", height, width)); + (void) XtMakeResizeRequest((Widget) xw, + (Dimension) width, (Dimension) height, + &xw->core.width, &xw->core.height); + TRACE(("...made resize request %dx%d\n", xw->core.height, xw->core.width)); + + /* 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 (sizehints.flags & USPosition) + XMoveWindow(XtDisplay(xw), XtWindow(SHELL_OF(xw)), + sizehints.x, sizehints.y); + + TRACE(("%s@%d -- ", __FILE__, __LINE__)); + TRACE_HINTS(&sizehints); + XSetWMNormalHints(XtDisplay(xw), XtWindow(SHELL_OF(xw)), &sizehints); + 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, + 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 = ((xw->misc.resizeGravity == NorthWestGravity) + ? NorthWestGravity + : ForgetGravity); + xw->screen.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 + if (xw->misc.active_icon && screen->fnt_icon) { + int iconX = 0, iconY = 0; + Widget shell = SHELL_OF(xw); + unsigned long mask; + XGCValues xgcv; + + TRACE(("Initializing active-icon\n")); + XtVaGetValues(shell, XtNiconX, &iconX, XtNiconY, &iconY, (XtPointer) 0); + xtermComputeFontInfo(xw, &(screen->iconVwin), screen->fnt_icon, 0); + + /* 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); + + mask = (GCFont | GCForeground | GCBackground | + GCGraphicsExposures | GCFunction); + + xgcv.font = screen->fnt_icon->fid; + xgcv.foreground = T_COLOR(screen, TEXT_FG); + xgcv.background = T_COLOR(screen, TEXT_BG); + xgcv.graphics_exposures = True; /* default */ + xgcv.function = GXcopy; + + screen->iconVwin.normalGC = + screen->iconVwin.normalboldGC = + XtGetGC(shell, mask, &xgcv); + + xgcv.foreground = T_COLOR(screen, TEXT_BG); + xgcv.background = T_COLOR(screen, TEXT_FG); + + screen->iconVwin.reverseGC = + screen->iconVwin.reverseboldGC = + XtGetGC(shell, mask, &xgcv); +#if OPT_TOOLBAR + /* + * Toolbar is initialized before we get here. Enable the menu item + * and set it properly. + */ + set_sensitivity(mw, + 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(); +#else + xw->screen.xic = NULL; +#endif +#if OPT_NUM_LOCK + VTInitModifiers(); +#endif + + set_cursor_gcs(screen); + + /* Reset variables used by ANSI emulation. */ + + resetCharsets(screen); + + XDefineCursor(screen->display, VShellWindow, 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 = screen->allbuf = NULL; + + screen->do_wrap = 0; + screen->scrolls = screen->incopy = 0; + xtermSetCursorBox(screen); + + screen->savedlines = 0; + + if (xw->misc.scrollbar) { + screen->fullVwin.sb_info.width = 0; + ScrollBarOn(xw, False, True); + } + CursorSave(xw); + 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(); +} + +static void +xim_destroy_cb(XIM im GCC_UNUSED, + XPointer client_data GCC_UNUSED, + XPointer call_data GCC_UNUSED) +{ + term->screen.xic = NULL; + + XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL, + xim_instantiate_cb, NULL); +} +#endif /* X11R6+ */ + +static void +xim_real_init(void) +{ + unsigned i, j; + char *p, *s, *t, *ns, *end, buf[32]; + XIMStyles *xim_styles; + XIMStyle input_style = 0; + Bool found; + static struct { + char *name; + unsigned long code; + } known_style[] = { + { + "OverTheSpot", (XIMPreeditPosition | XIMStatusNothing) + }, + { + "OffTheSpot", (XIMPreeditArea | XIMStatusArea) + }, + { + "Root", (XIMPreeditNothing | XIMStatusNothing) + }, + }; + + term->screen.xic = NULL; + + if (term->misc.cannot_im) { + return; + } + + if (!term->misc.input_method || !*term->misc.input_method) { + if ((p = XSetLocaleModifiers("")) != NULL && *p) + term->screen.xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); + } else { + s = term->misc.input_method; + i = 5 + strlen(s); + t = (char *) MyStackAlloc(i, buf); + if (t == NULL) + SysError(ERROR_VINIT); + + 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, (unsigned) (end - s)); + + if ((p = XSetLocaleModifiers(t)) != 0 && *p + && (term->screen.xim = XOpenIM(XtDisplay(term), + NULL, + NULL, + NULL)) != 0) + break; + + } + s = ns + 1; + } + MyStackFree(t, buf); + } + + if (term->screen.xim == NULL + && (p = XSetLocaleModifiers("@im=none")) != NULL + && *p) { + term->screen.xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL); + } + + if (!term->screen.xim) { + fprintf(stderr, "Failed to open input method\n"); + return; + } + TRACE(("VTInitI18N opened input method\n")); + + if (XGetIMValues(term->screen.xim, XNQueryInputStyle, &xim_styles, NULL) + || !xim_styles + || !xim_styles->count_styles) { + fprintf(stderr, "input method doesn't support any style\n"); + XCloseIM(term->screen.xim); + term->misc.cannot_im = True; + return; + } + + found = False; + for (s = term->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", 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, (unsigned) (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", + term->misc.preedit_type); + XCloseIM(term->screen.xim); + term->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"); + XCloseIM(term->screen.xim); + term->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; + + term->screen.fs = XCreateFontSet(XtDisplay(term), + term->misc.f_x, + &missing_charset_list, + &missing_charset_count, + &def_string); + if (term->screen.fs == NULL) { + fprintf(stderr, "Preparation of font set " + "\"%s\" for XIM failed.\n", term->misc.f_x); + term->screen.fs = XCreateFontSet(XtDisplay(term), + DEFXIMFONT, + &missing_charset_list, + &missing_charset_count, + &def_string); + } + if (term->screen.fs == NULL) { + fprintf(stderr, "Preparation of default font set " + "\"%s\" for XIM failed.\n", DEFXIMFONT); + XCloseIM(term->screen.xim); + term->misc.cannot_im = True; + return; + } + (void) XExtentsOfFontSet(term->screen.fs); + j = XFontsOfFontSet(term->screen.fs, &fonts, &font_name_list); + for (i = 0, term->screen.fs_ascent = 0; i < j; i++) { + if (term->screen.fs_ascent < (*fonts)->ascent) + term->screen.fs_ascent = (*fonts)->ascent; + } + p_list = XVaCreateNestedList(0, + XNSpotLocation, &spot, + XNFontSet, term->screen.fs, + NULL); + term->screen.xic = XCreateIC(term->screen.xim, + XNInputStyle, input_style, + XNClientWindow, XtWindow(term), + XNFocusWindow, XtWindow(term), + XNPreeditAttributes, p_list, + NULL); + } else { + term->screen.xic = XCreateIC(term->screen.xim, XNInputStyle, input_style, + XNClientWindow, XtWindow(term), + XNFocusWindow, XtWindow(term), + NULL); + } + + if (!term->screen.xic) { + fprintf(stderr, "Failed to create input context\n"); + XCloseIM(term->screen.xim); + } +#if defined(USE_XIM_INSTANTIATE_CB) + else { + XIMCallback destroy_cb; + + destroy_cb.callback = xim_destroy_cb; + destroy_cb.client_data = NULL; + if (XSetIMValues(term->screen.xim, XNDestroyCallback, &destroy_cb, NULL)) + fprintf(stderr, "Could not set destroy callback to IM\n"); + } +#endif + + return; +} + +static void +VTInitI18N(void) +{ + if (term->misc.open_im) { + xim_real_init(); + +#if defined(USE_XIM_INSTANTIATE_CB) + if (term->screen.xic == NULL && !term->misc.cannot_im) { + sleep(3); + XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL, + xim_instantiate_cb, NULL); + } +#endif + } +} +#endif /* OPT_I18N_SUPPORT && OPT_INPUT_METHOD */ + +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; + Bool refresh_needed = False; + Bool fonts_redone = False; + + if ((T_COLOR(&(curvt->screen), TEXT_BG) != + T_COLOR(&(newvt->screen), TEXT_BG)) || + (T_COLOR(&(curvt->screen), TEXT_FG) != + T_COLOR(&(newvt->screen), TEXT_FG)) || + (curvt->screen.MenuFontName(curvt->screen.menu_font_number) != + newvt->screen.MenuFontName(newvt->screen.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) + newvt->screen.MenuFontName(fontMenu_fontdefault) = newvt->misc.default_font.f_n; + if (xtermLoadFont(newvt, + xtermFontName(newvt->screen.MenuFontName(curvt->screen.menu_font_number)), + True, newvt->screen.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) + newvt->screen.MenuFontName(fontMenu_fontdefault) = curvt->misc.default_font.f_n; + } + if (!fonts_redone + && (T_COLOR(&(curvt->screen), TEXT_CURSOR) != + T_COLOR(&(newvt->screen), TEXT_CURSOR))) { + set_cursor_gcs(&newvt->screen); + refresh_needed = True; + } + if (curvt->misc.re_verse != newvt->misc.re_verse) { + newvt->flags ^= REVERSE_VIDEO; + ReverseVideo(newvt); + newvt->misc.re_verse = !newvt->misc.re_verse; /* ReverseVideo toggles */ + refresh_needed = True; + } + if ((T_COLOR(&(curvt->screen), MOUSE_FG) != + T_COLOR(&(newvt->screen), MOUSE_FG)) || + (T_COLOR(&(curvt->screen), MOUSE_BG) != + T_COLOR(&(newvt->screen), MOUSE_BG))) { + recolor_cursor(newvt->screen.pointer_cursor, + T_COLOR(&(newvt->screen), MOUSE_FG), + T_COLOR(&(newvt->screen), MOUSE_BG)); + refresh_needed = True; + } + if (curvt->misc.scrollbar != newvt->misc.scrollbar) { + ToggleScrollBar(newvt); + } + + return refresh_needed; +} + +#define setGC(value) set_at = __LINE__, currentGC = value + +#define OutsideSelection(screen,row,col) \ + ((row) > (screen)->endHRow || \ + ((row) == (screen)->endHRow && \ + (col) >= (screen)->endHCol) || \ + (row) < (screen)->startHRow || \ + ((row) == (screen)->startHRow && \ + (col) < (screen)->startHCol)) + +/* + * Shows cursor at new cursor position in screen. + */ +void +ShowCursor(void) +{ + TScreen *screen = &term->screen; + int x, y; + Char clo; + unsigned flags; + unsigned fg_bg = 0; + GC currentGC; + int set_at; + Bool in_selection; + Bool reversed; + Pixel fg_pix; + Pixel bg_pix; + Pixel tmp; +#if OPT_HIGHLIGHT_COLOR + Pixel hi_pix = T_COLOR(screen, HIGHLIGHT_BG); +#endif +#if OPT_WIDE_CHARS + Char chi = 0; + Char c1h = 0; + Char c1l = 0; + Char c2h = 0; + Char c2l = 0; + int base; +#endif + int cursor_col; + + if (screen->cursor_state == BLINKED_OFF) + return; + + if (eventMode != NORMAL) + return; + + if (screen->cur_row - screen->topline > screen->max_row) + return; + + screen->cursor_row = screen->cur_row; + cursor_col = screen->cursor_col = screen->cur_col; + screen->cursor_moved = False; + +#ifndef NO_ACTIVE_ICON + if (IsIcon(screen)) { + screen->cursor_state = ON; + return; + } +#endif /* NO_ACTIVE_ICON */ + +#if OPT_WIDE_CHARS + base = +#endif + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + + if_OPT_WIDE_CHARS(screen, { + int my_col; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + if (clo == HIDDEN_LO && chi == HIDDEN_HI && cursor_col > 0) { + /* if cursor points to non-initial part of wide character, + * back it up + */ + --cursor_col; + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + } + my_col = cursor_col; + base = (chi << 8) | clo; + if (iswide(base)) + my_col += 1; + c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col]; + c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col]; + c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col]; + c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col]; + }); + + flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[cursor_col]; + + if (clo == 0 +#if OPT_WIDE_CHARS + && chi == 0 +#endif + ) { + clo = ' '; + } + + /* + * 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 OPT_ISO_COLORS + if ((flags & TERM_COLOR_FLAGS(term)) == BG_COLOR +#if OPT_WIDE_CHARS + && chi == 0 +#endif + && clo == ' ') { + flags &= ~TERM_COLOR_FLAGS(term); + } +#endif + + /* + * Compare the current cell to the last set of colors used for the + * cursor and update the GC's if needed. + */ + if_OPT_EXT_COLORS(screen, { + fg_bg = (SCRN_BUF_FGRND(screen, screen->cursor_row)[cursor_col] << 8) + | (SCRN_BUF_BGRND(screen, screen->cursor_row)[cursor_col]); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fg_bg = SCRN_BUF_COLOR(screen, screen->cursor_row)[cursor_col]; + }); + fg_pix = getXtermForeground(flags, extract_fg(fg_bg, flags)); + bg_pix = getXtermBackground(flags, extract_bg(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. + */ + if (screen->select || screen->always_highlight) { + if (reversed) { /* text is reverse video */ + if (screen->cursorGC) { + setGC(screen->cursorGC); + } else { + if (flags & BOLDATTR(screen)) { + setGC(NormalBoldGC(screen)); + } else { + setGC(NormalGC(screen)); + } + } +#if OPT_HIGHLIGHT_COLOR + if (hi_pix != T_COLOR(screen, TEXT_FG) + && hi_pix != fg_pix + && hi_pix != bg_pix + && hi_pix != term->dft_foreground) { + bg_pix = fg_pix; + fg_pix = hi_pix; + } +#endif + EXCHANGE(fg_pix, bg_pix, tmp); + } else { /* normal video */ + if (screen->reversecursorGC) { + setGC(screen->reversecursorGC); + } else { + if (flags & BOLDATTR(screen)) { + setGC(ReverseBoldGC(screen)); + } else { + setGC(ReverseGC(screen)); + } + } + } + if (T_COLOR(screen, TEXT_CURSOR) == term->dft_foreground) { + XSetBackground(screen->display, currentGC, fg_pix); + } + XSetForeground(screen->display, currentGC, bg_pix); + } else { /* not selected */ + if (reversed) { /* text is reverse video */ +#if OPT_HIGHLIGHT_COLOR + if (hi_pix != T_COLOR(screen, TEXT_FG) + && hi_pix != fg_pix + && hi_pix != bg_pix + && hi_pix != term->dft_foreground) { + bg_pix = fg_pix; + fg_pix = hi_pix; + } +#endif + setGC(ReverseGC(screen)); + XSetForeground(screen->display, currentGC, bg_pix); + XSetBackground(screen->display, currentGC, fg_pix); + } else { /* normal video */ + setGC(NormalGC(screen)); + XSetForeground(screen->display, currentGC, fg_pix); + XSetBackground(screen->display, currentGC, 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)\n", + screen->cur_row, screen->cur_col)); + + drawXtermText(screen, flags & DRAWX_MASK, currentGC, + x = CurCursorX(screen, screen->cur_row, cursor_col), + y = CursorY(screen, screen->cur_row), + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&clo, &chi), 1, 0); + +#if OPT_WIDE_CHARS + if (c1l || c1h) { + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c1l, &c1h), 1, iswide(base)); + + if (c2l || c2h) + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c2l, &c2h), 1, iswide(base)); + } +#endif + + if (!screen->select && !screen->always_highlight) { + screen->box->x = x; + screen->box->y = y; + XDrawLines(screen->display, VWindow(screen), + screen->cursoroutlineGC ? screen->cursoroutlineGC + : currentGC, + screen->box, NBOX, CoordModePrevious); + } + } + screen->cursor_state = ON; +} + +/* + * hide cursor at previous cursor position in screen. + */ +void +HideCursor(void) +{ + TScreen *screen = &term->screen; + GC currentGC; + unsigned flags; + unsigned fg_bg = 0; + int x, y; + Char clo; + Bool in_selection; +#if OPT_WIDE_CHARS + Char chi = 0; + Char c1h = 0; + Char c1l = 0; + Char c2h = 0; + Char c2l = 0; + int base; +#endif + int cursor_col; + + if (screen->cursor_state == OFF) /* FIXME */ + return; + if (screen->cursor_row - screen->topline > screen->max_row) + return; + + cursor_col = screen->cursor_col; + +#ifndef NO_ACTIVE_ICON + if (IsIcon(screen)) { + screen->cursor_state = OFF; + return; + } +#endif /* NO_ACTIVE_ICON */ + +#if OPT_WIDE_CHARS + base = +#endif + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + flags = SCRN_BUF_ATTRS(screen, screen->cursor_row)[cursor_col]; + + if_OPT_WIDE_CHARS(screen, { + int my_col; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + if (clo == HIDDEN_LO && chi == HIDDEN_HI) { + /* if cursor points to non-initial part of wide character, + * back it up + */ + --cursor_col; + clo = SCRN_BUF_CHARS(screen, screen->cursor_row)[cursor_col]; + chi = SCRN_BUF_WIDEC(screen, screen->cursor_row)[cursor_col]; + } + my_col = cursor_col; + base = (chi << 8) | clo; + if (iswide(base)) + my_col += 1; + c1l = SCRN_BUF_COM1L(screen, screen->cursor_row)[my_col]; + c1h = SCRN_BUF_COM1H(screen, screen->cursor_row)[my_col]; + c2l = SCRN_BUF_COM2L(screen, screen->cursor_row)[my_col]; + c2h = SCRN_BUF_COM2H(screen, screen->cursor_row)[my_col]; + }); + + if_OPT_EXT_COLORS(screen, { + fg_bg = (SCRN_BUF_FGRND(screen, screen->cursor_row)[cursor_col] << 8) + | (SCRN_BUF_BGRND(screen, screen->cursor_row)[cursor_col]); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fg_bg = SCRN_BUF_COLOR(screen, screen->cursor_row)[cursor_col]; + }); + + if (OutsideSelection(screen, screen->cursor_row, screen->cursor_col)) + in_selection = False; + else + in_selection = True; + + currentGC = updatedXtermGC(screen, flags, fg_bg, in_selection); + + if (clo == 0 +#if OPT_WIDE_CHARS + && chi == 0 +#endif + ) { + clo = ' '; + } + + TRACE(("HideCursor calling drawXtermText cur(%d,%d)\n", + screen->cursor_row, screen->cursor_col)); + drawXtermText(screen, flags & DRAWX_MASK, currentGC, + x = CurCursorX(screen, screen->cursor_row, cursor_col), + y = CursorY(screen, screen->cursor_row), + curXtermChrSet(screen->cursor_row), + PAIRED_CHARS(&clo, &chi), 1, 0); + +#if OPT_WIDE_CHARS + if (c1l || c1h) { + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c1l, &c1h), 1, iswide(base)); + + if (c2l || c2h) + drawXtermText(screen, (flags & DRAWX_MASK) | NOBACKGROUND, + currentGC, x, y, + curXtermChrSet(screen->cur_row), + PAIRED_CHARS(&c2l, &c2h), 1, iswide(base)); + } +#endif + screen->cursor_state = OFF; + resetXtermGC(screen, flags, in_selection); +} + +#if OPT_BLINK_CURS || OPT_BLINK_TEXT +static void +StartBlinking(TScreen * screen) +{ + if (screen->blink_timer == 0) { + unsigned long interval = (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 +ScrnHasBlinking(TScreen * screen, int row) +{ + Char *attrs = SCRN_BUF_ATTRS(screen, row); + int col; + Bool result = False; + + for (col = 0; col < MaxCols(screen); ++col) { + if (attrs[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 line 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--) { + if (ScrnTstBlinked(screen, row)) { + if (ScrnHasBlinking(screen, row)) { + resume = True; + if (row > last_row) + last_row = row; + if (row < first_row) + first_row = row; + } else { + ScrnClrBlinked(screen, row); + } + } + } + /* + * FIXME: this could be a little more efficient, e.g,. by limiting the + * columns which are updated. + */ + if (first_row <= last_row) { + ScrnRefresh(screen, + 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 */ + +/* + * 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(Bool full, Bool saved) +{ + TScreen *screen = &term->screen; + + if (!XtIsRealized((Widget) term)) { + Bell(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(&term->flags, ORIGIN); + + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + + /* Reset character-sets to initial state */ + resetCharsets(screen); + + /* Reset DECSCA */ + bitclr(&term->flags, PROTECTED); + screen->protected_mode = OFF_PROTECT; + + if (full) { /* RIS */ + if (screen->bellOnReset) + Bell(XkbBI_TerminalBell, 0); + + /* reset the mouse mode */ + screen->send_mouse_pos = MOUSE_OFF; + waitingForTrackInfo = False; + eventMode = NORMAL; + + TabReset(term->tabs); + term->keyboard.flags = MODE_SRM; +#if OPT_INITIAL_ERASE + if (term->keyboard.reset_DECBKM == 1) + term->keyboard.flags |= MODE_DECBKM; + else if (term->keyboard.reset_DECBKM == 2) +#endif + if (term->screen.backarrow_key) + term->keyboard.flags |= MODE_DECBKM; + TRACE(("full reset DECBKM %s\n", + BtoS(term->keyboard.flags & MODE_DECBKM))); + update_appcursor(); + update_appkeypad(); + update_decbkm(); + show_8bit_control(False); + reset_decudk(); + + FromAlternate(screen); + ClearScreen(screen); + screen->cursor_state = OFF; + if (term->flags & REVERSE_VIDEO) + ReverseVideo(term); + + term->flags = term->initflags; + update_reversevideo(); + update_autowrap(); + update_reversewrap(); + update_autolinefeed(); + + screen->jumpscroll = !(term->flags & SMOOTHSCROLL); + update_jumpscroll(); + + if (screen->c132 && (term->flags & IN132COLUMNS)) { + Dimension reqWidth = (80 * FontWidth(screen) + + 2 * screen->border + ScrollbarWidth(screen)); + Dimension reqHeight = (FontHeight(screen) + * MaxRows(screen) + 2 * screen->border); + Dimension replyWidth; + Dimension replyHeight; + + TRACE(("Making resize-request to restore 80-columns %dx%d\n", + reqHeight, reqWidth)); + XtMakeResizeRequest((Widget) term, + reqWidth, + reqHeight, + &replyWidth, &replyHeight); + TRACE(("...result %dx%d\n", replyHeight, replyWidth)); + repairSizeHints(); + XSync(screen->display, False); /* synchronize */ + if (XtAppPending(app_con)) + xevents(); + } + + CursorSet(screen, 0, 0, term->flags); + CursorSave(term); + } else { /* DECSTR */ + /* + * There's a tiny difference, to accommodate usage of xterm. + * We reset autowrap to the resource values rather than turning + * it off. + */ + term->keyboard.flags &= ~(MODE_DECCKM | MODE_KAM | MODE_DECKPAM); + bitcpy(&term->flags, term->initflags, WRAPAROUND | REVERSEWRAP); + bitclr(&term->flags, INSERT | INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE); + if_OPT_ISO_COLORS(screen, { + reset_SGR_Colors(); + }); + update_appcursor(); + update_autowrap(); + update_reversewrap(); + + CursorSave(term); + screen->sc[screen->alternate != False].row = + screen->sc[screen->alternate != False].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 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 = strlen(s), acc = 0, numbers = digits = 0; + i < len; i++) { + Char c = 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); + + (void) sprintf(pmapName, "%sKeymap", params[0]); + (void) strcpy(pmapClass, pmapName); + if (islower(CharOf(pmapClass[0]))) + pmapClass[0] = toupper(CharOf(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(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) +{ + /* do nothing, but check for funny escape sequences */ + (void) SendMousePosition(w, event); +} + +/* ARGSUSED */ +static void +DoSetSelectedFont(Widget w GCC_UNUSED, + XtPointer client_data GCC_UNUSED, + Atom * selection GCC_UNUSED, + Atom * type, + XtPointer value, + unsigned long *length GCC_UNUSED, + int *format) +{ + char *val = (char *) value; + int len; + if (*type != XA_STRING || *format != 8) { + Bell(XkbBI_MinorError, 0); + return; + } + len = strlen(val); + if (len > 0) { + if (val[len - 1] == '\n') + val[len - 1] = '\0'; + /* 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(val, '\n')) + return; + if (!xtermLoadFont(term, + xtermFontName(val), + True, + fontMenu_fontsel)) + Bell(XkbBI_MinorError, 0); + } +} + +void +FindFontSelection(char *atom_name, Bool justprobe) +{ + static AtomPtr *atoms; + static int atomCount = 0; + AtomPtr *pAtom; + int a; + Atom target; + + if (!atom_name) + atom_name = "PRIMARY"; + + for (pAtom = atoms, a = atomCount; a; a--, pAtom++) { + if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) + break; + } + if (!a) { + atoms = (AtomPtr *) XtRealloc((char *) atoms, + sizeof(AtomPtr) * (atomCount + 1)); + *(pAtom = &atoms[atomCount++]) = XmuMakeAtom(atom_name); + } + + target = XmuInternAtom(XtDisplay(term), *pAtom); + if (justprobe) { + term->screen.MenuFontName(fontMenu_fontsel) = + XGetSelectionOwner(XtDisplay(term), target) ? _Font_Selected_ : 0; + } else { + XtGetSelectionValue((Widget) term, target, XA_STRING, + DoSetSelectedFont, NULL, + XtLastTimestampProcessed(XtDisplay(term))); + } + return; +} + +void +set_cursor_gcs(TScreen * screen) +{ + XGCValues xgcv; + XtGCMask mask; + Pixel cc = T_COLOR(screen, TEXT_CURSOR); + Pixel fg = T_COLOR(screen, TEXT_FG); + Pixel bg = T_COLOR(screen, TEXT_BG); + GC new_cursorGC = NULL; + GC new_cursorFillGC = NULL; + GC new_reversecursorGC = NULL; + GC new_cursoroutlineGC = NULL; + + /* + * Let's see, there are three things that have "color": + * + * background + * text + * cursorblock + * + * And, there are four situation 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. + */ + +#if OPT_ISO_COLORS + /* + * If we're using ANSI colors, the functions manipulating the SGR code will + * use the same GC's. To avoid having the cursor change color, we use the + * Xlib calls rather than the Xt calls. + * + * Use the colorMode value to determine which we'll do (the VWindow may + * not be set before the widget's realized, so it's tested separately). + */ + if (screen->colorMode) { + if (VWindow(screen) != 0 && (cc != bg) && (cc != fg)) { + /* we might have a colored foreground/background later */ + xgcv.font = screen->fnt_norm->fid; + mask = (GCForeground | GCBackground | GCFont); + xgcv.foreground = fg; + xgcv.background = cc; + new_cursorGC = XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + + xgcv.foreground = cc; + xgcv.background = fg; + new_cursorFillGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + + if (screen->always_highlight) { + new_reversecursorGC = (GC) 0; + new_cursoroutlineGC = (GC) 0; + } else { + xgcv.foreground = bg; + xgcv.background = cc; + new_reversecursorGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + xgcv.foreground = cc; + xgcv.background = bg; + new_cursoroutlineGC = + XCreateGC(screen->display, VWindow(screen), mask, &xgcv); + } + } + } else +#endif + if (cc != fg && cc != bg) { + /* we have a colored cursor */ + xgcv.font = screen->fnt_norm->fid; + mask = (GCForeground | GCBackground | GCFont); + + xgcv.foreground = fg; + xgcv.background = cc; + new_cursorGC = XtGetGC((Widget) term, mask, &xgcv); + + xgcv.foreground = cc; + xgcv.background = fg; + new_cursorFillGC = XtGetGC((Widget) term, mask, &xgcv); + + if (screen->always_highlight) { + new_reversecursorGC = (GC) 0; + new_cursoroutlineGC = (GC) 0; + } else { + xgcv.foreground = bg; + xgcv.background = cc; + new_reversecursorGC = XtGetGC((Widget) term, mask, &xgcv); + xgcv.foreground = cc; + xgcv.background = bg; + new_cursoroutlineGC = XtGetGC((Widget) term, mask, &xgcv); + } + } +#if OPT_ISO_COLORS + if (screen->colorMode) { + if (screen->cursorGC) + XFreeGC(screen->display, screen->cursorGC); + if (screen->fillCursorGC) + XFreeGC(screen->display, screen->fillCursorGC); + if (screen->reversecursorGC) + XFreeGC(screen->display, screen->reversecursorGC); + if (screen->cursoroutlineGC) + XFreeGC(screen->display, screen->cursoroutlineGC); + } else +#endif + { + if (screen->cursorGC) + XtReleaseGC((Widget) term, screen->cursorGC); + if (screen->fillCursorGC) + XtReleaseGC((Widget) term, screen->fillCursorGC); + if (screen->reversecursorGC) + XtReleaseGC((Widget) term, screen->reversecursorGC); + if (screen->cursoroutlineGC) + XtReleaseGC((Widget) term, screen->cursoroutlineGC); + } + + screen->cursorGC = new_cursorGC; + screen->fillCursorGC = new_cursorFillGC; + screen->reversecursorGC = new_reversecursorGC; + screen->cursoroutlineGC = new_cursoroutlineGC; +} diff --git a/nx-X11/programs/xterm/charsets.c b/nx-X11/programs/xterm/charsets.c new file mode 100644 index 000000000..528175aeb --- /dev/null +++ b/nx-X11/programs/xterm/charsets.c @@ -0,0 +1,461 @@ +/* $XTermId: charsets.c,v 1.32 2005/01/14 01:50:02 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/charsets.c,v 1.12 2005/01/14 01:50:02 dickey Exp $ + */ + +/************************************************************ + +Copyright 1998-2003,2005 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 +#include +#include + +#include + +/* + * 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) +{ + 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) { + case XK_sterling: code = 0x23; break; + case XK_threequarters: code = 0x40; break; + case XK_ydiaeresis: code = 0x5b; break; + case XK_onehalf: code = 0x5c; break; + /* N/A case XK_bar: code = 0x5d; break; */ + case XK_diaeresis: code = 0x7b; break; + /* N/A case XK_f: code = 0x7c; break; */ + case XK_onequarter: code = 0x7d; break; + case XK_acute: code = 0x7e; break; + } + break; + + case 'C': + case '5': /* Finnish */ + switch (code) { + case XK_Adiaeresis: code = 0x5b; break; + case XK_Odiaeresis: code = 0x5c; break; + case XK_Aring: code = 0x5d; break; + case XK_Udiaeresis: code = 0x5e; break; + case XK_eacute: code = 0x60; break; + case XK_adiaeresis: code = 0x7b; break; + case XK_odiaeresis: code = 0x7c; break; + case XK_aring: code = 0x7d; break; + case XK_udiaeresis: code = 0x7e; break; + } + break; + + case 'R': /* French */ + switch (code) { + case XK_sterling: code = 0x23; break; + case XK_agrave: code = 0x40; break; + case XK_degree: code = 0x5b; break; + case XK_ccedilla: code = 0x5c; break; + case XK_section: code = 0x5d; break; + case XK_eacute: code = 0x7b; break; + case XK_ugrave: code = 0x7c; break; + case XK_egrave: code = 0x7d; break; + case XK_diaeresis: code = 0x7e; break; + } + break; + + case 'Q': /* French Canadian */ + switch (code) { + case XK_agrave: code = 0x40; break; + case XK_acircumflex: code = 0x5b; break; + case XK_ccedilla: code = 0x5c; break; + case XK_ecircumflex: code = 0x5d; break; + case XK_icircumflex: code = 0x5e; break; + case XK_ocircumflex: code = 0x60; break; + case XK_eacute: code = 0x7b; break; + case XK_ugrave: code = 0x7c; break; + case XK_egrave: code = 0x7d; break; + case XK_ucircumflex: code = 0x7e; break; + } + break; + + case 'K': /* German */ + switch (code) { + case XK_section: code = 0x40; break; + case XK_Adiaeresis: code = 0x5b; break; + case XK_Odiaeresis: code = 0x5c; break; + case XK_Udiaeresis: code = 0x5d; break; + case XK_adiaeresis: code = 0x7b; break; + case XK_odiaeresis: code = 0x7c; break; + case XK_udiaeresis: code = 0x7d; break; + case XK_ssharp: code = 0x7e; break; + } + break; + + case 'Y': /* Italian */ + switch (code) { + case XK_sterling: code = 0x23; break; + case XK_section: code = 0x40; break; + case XK_degree: code = 0x5b; break; + case XK_ccedilla: code = 0x5c; break; + case XK_eacute: code = 0x5d; break; + case XK_ugrave: code = 0x60; break; + case XK_agrave: code = 0x7b; break; + case XK_ograve: code = 0x7c; break; + case XK_egrave: code = 0x7d; break; + case XK_igrave: code = 0x7e; break; + } + break; + + case 'E': + case '6': /* Norwegian/Danish */ + switch (code) { + case XK_Adiaeresis: code = 0x40; break; + case XK_AE: code = 0x5b; break; + case XK_Ooblique: code = 0x5c; break; + case XK_Aring: code = 0x5d; break; + case XK_Udiaeresis: code = 0x5e; break; + case XK_adiaeresis: code = 0x60; break; + case XK_ae: code = 0x7b; break; + case XK_oslash: code = 0x7c; break; + case XK_aring: code = 0x7d; break; + case XK_udiaeresis: code = 0x7e; break; + } + break; + + case 'Z': /* Spanish */ + switch (code) { + case XK_sterling: code = 0x23; break; + case XK_section: code = 0x40; break; + case XK_exclamdown: code = 0x5b; break; + case XK_Ntilde: code = 0x5c; break; + case XK_questiondown: code = 0x5d; break; + case XK_degree: code = 0x7b; break; + case XK_ntilde: code = 0x7c; break; + case XK_ccedilla: code = 0x7d; break; + } + break; + + case 'H': + case '7': /* Swedish */ + switch (code) { + case XK_Eacute: code = 0x40; break; + case XK_Adiaeresis: code = 0x5b; break; + case XK_Odiaeresis: code = 0x5c; break; + case XK_Aring: code = 0x5d; break; + case XK_Udiaeresis: code = 0x5e; break; + case XK_eacute: code = 0x60; break; + case XK_adiaeresis: code = 0x7b; break; + case XK_odiaeresis: code = 0x7c; break; + case XK_aring: code = 0x7d; break; + case XK_udiaeresis: code = 0x7e; break; + } + break; + + case '=': /* Swiss */ + switch (code) { + case XK_ugrave: code = 0x23; break; + case XK_agrave: code = 0x40; break; + case XK_eacute: code = 0x5b; break; + case XK_ccedilla: code = 0x5c; break; + case XK_ecircumflex: code = 0x5d; break; + case XK_icircumflex: code = 0x5e; break; + case XK_egrave: code = 0x5f; break; + case XK_ocircumflex: code = 0x60; break; + case XK_adiaeresis: code = 0x7b; break; + case XK_odiaeresis: code = 0x7c; break; + case XK_udiaeresis: code = 0x7d; break; + case XK_ucircumflex: code = 0x7e; break; + } + break; + + default: /* any character sets we don't recognize*/ + break; + } + code &= 0x7f; /* NRC in any case is 7-bit */ + } + return code; +} + +/* + * 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(IChar *buf, IChar *ptr, int leftset) +{ + IChar *s; + register TScreen *screen = &term->screen; + int count = 0; + int rightset = screen->gsets[(int)(screen->curgr)]; + + TRACE(("CHARSET GL=%c(G%d) GR=%c(G%d) SS%d:%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++; + switch (cs) { + case 'A': /* United Kingdom set (or Latin 1) */ + if ((term->flags & NATIONAL) + || (screen->vtXX_level <= 1)) { + if (chr == 0x23) + chr = XPOUND; /* UK pound sign*/ + } 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 = dec2ucs((unsigned)(seven - 0x5f)); + else +#endif + chr = seven - 0x5f; + } else { + chr = seven; + } + break; + + case '4': /* Dutch */ + switch (chr = seven) { + case 0x23: chr = XK_sterling; break; + case 0x40: chr = XK_threequarters; break; + case 0x5b: chr = XK_ydiaeresis; break; + case 0x5c: chr = XK_onehalf; break; + case 0x5d: chr = XK_bar; break; + case 0x7b: chr = XK_diaeresis; break; + case 0x7c: chr = XK_f; break; + case 0x7d: chr = XK_onequarter; break; + case 0x7e: chr = XK_acute; break; + } + break; + + case 'C': + case '5': /* Finnish */ + switch (chr = seven) { + case 0x5b: chr = XK_Adiaeresis; break; + case 0x5c: chr = XK_Odiaeresis; break; + case 0x5d: chr = XK_Aring; break; + case 0x5e: chr = XK_Udiaeresis; break; + case 0x60: chr = XK_eacute; break; + case 0x7b: chr = XK_adiaeresis; break; + case 0x7c: chr = XK_odiaeresis; break; + case 0x7d: chr = XK_aring; break; + case 0x7e: chr = XK_udiaeresis; break; + } + break; + + case 'R': /* French */ + switch (chr = seven) { + case 0x23: chr = XK_sterling; break; + case 0x40: chr = XK_agrave; break; + case 0x5b: chr = XK_degree; break; + case 0x5c: chr = XK_ccedilla; break; + case 0x5d: chr = XK_section; break; + case 0x7b: chr = XK_eacute; break; + case 0x7c: chr = XK_ugrave; break; + case 0x7d: chr = XK_egrave; break; + case 0x7e: chr = XK_diaeresis; break; + } + break; + + case 'Q': /* French Canadian */ + switch (chr = seven) { + case 0x40: chr = XK_agrave; break; + case 0x5b: chr = XK_acircumflex; break; + case 0x5c: chr = XK_ccedilla; break; + case 0x5d: chr = XK_ecircumflex; break; + case 0x5e: chr = XK_icircumflex; break; + case 0x60: chr = XK_ocircumflex; break; + case 0x7b: chr = XK_eacute; break; + case 0x7c: chr = XK_ugrave; break; + case 0x7d: chr = XK_egrave; break; + case 0x7e: chr = XK_ucircumflex; break; + } + break; + + case 'K': /* German */ + switch (chr = seven) { + case 0x40: chr = XK_section; break; + case 0x5b: chr = XK_Adiaeresis; break; + case 0x5c: chr = XK_Odiaeresis; break; + case 0x5d: chr = XK_Udiaeresis; break; + case 0x7b: chr = XK_adiaeresis; break; + case 0x7c: chr = XK_odiaeresis; break; + case 0x7d: chr = XK_udiaeresis; break; + case 0x7e: chr = XK_ssharp; break; + } + break; + + case 'Y': /* Italian */ + switch (chr = seven) { + case 0x23: chr = XK_sterling; break; + case 0x40: chr = XK_section; break; + case 0x5b: chr = XK_degree; break; + case 0x5c: chr = XK_ccedilla; break; + case 0x5d: chr = XK_eacute; break; + case 0x60: chr = XK_ugrave; break; + case 0x7b: chr = XK_agrave; break; + case 0x7c: chr = XK_ograve; break; + case 0x7d: chr = XK_egrave; break; + case 0x7e: chr = XK_igrave; break; + } + break; + + case 'E': + case '6': /* Norwegian/Danish */ + switch (chr = seven) { + case 0x40: chr = XK_Adiaeresis; break; + case 0x5b: chr = XK_AE; break; + case 0x5c: chr = XK_Ooblique; break; + case 0x5d: chr = XK_Aring; break; + case 0x5e: chr = XK_Udiaeresis; break; + case 0x60: chr = XK_adiaeresis; break; + case 0x7b: chr = XK_ae; break; + case 0x7c: chr = XK_oslash; break; + case 0x7d: chr = XK_aring; break; + case 0x7e: chr = XK_udiaeresis; break; + } + break; + + case 'Z': /* Spanish */ + switch (chr = seven) { + case 0x23: chr = XK_sterling; break; + case 0x40: chr = XK_section; break; + case 0x5b: chr = XK_exclamdown; break; + case 0x5c: chr = XK_Ntilde; break; + case 0x5d: chr = XK_questiondown; break; + case 0x7b: chr = XK_degree; break; + case 0x7c: chr = XK_ntilde; break; + case 0x7d: chr = XK_ccedilla; break; + } + break; + + case 'H': + case '7': /* Swedish */ + switch (chr = seven) { + case 0x40: chr = XK_Eacute; break; + case 0x5b: chr = XK_Adiaeresis; break; + case 0x5c: chr = XK_Odiaeresis; break; + case 0x5d: chr = XK_Aring; break; + case 0x5e: chr = XK_Udiaeresis; break; + case 0x60: chr = XK_eacute; break; + case 0x7b: chr = XK_adiaeresis; break; + case 0x7c: chr = XK_odiaeresis; break; + case 0x7d: chr = XK_aring; break; + case 0x7e: chr = XK_udiaeresis; break; + } + break; + + case '=': /* Swiss */ + switch (chr = seven) { + case 0x23: chr = XK_ugrave; break; + case 0x40: chr = XK_agrave; break; + case 0x5b: chr = XK_eacute; break; + case 0x5c: chr = XK_ccedilla; break; + case 0x5d: chr = XK_ecircumflex; break; + case 0x5e: chr = XK_icircumflex; break; + case 0x5f: chr = XK_egrave; break; + case 0x60: chr = XK_ocircumflex; break; + case 0x7b: chr = XK_adiaeresis; break; + case 0x7c: chr = XK_odiaeresis; break; + case 0x7d: chr = XK_udiaeresis; break; + case 0x7e: chr = XK_ucircumflex; break; + } + 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 == 0x7f) + chr = ' '; + *s = A2E(chr); + } + return count; +} diff --git a/nx-X11/programs/xterm/config.guess b/nx-X11/programs/xterm/config.guess new file mode 100644 index 000000000..6d71f752f --- /dev/null +++ b/nx-X11/programs/xterm/config.guess @@ -0,0 +1,1499 @@ +#! /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 Free Software Foundation, Inc. + +timestamp='2005-05-27' + +# 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 to . Submit a context +# diff and a properly formatted 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. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +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 ." + +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 +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 -q "$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 ;' + +# 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 ;; + *) 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 __ELF__ >/dev/null + 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 ;; + amd64:OpenBSD:*:*) + echo x86_64-unknown-openbsd${UNAME_RELEASE} + exit ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit ;; + cats:OpenBSD:*:*) + echo arm-unknown-openbsd${UNAME_RELEASE} + exit ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit ;; + luna88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit ;; + sgi:OpenBSD:*:*) + echo mips64-unknown-openbsd${UNAME_RELEASE} + exit ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-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 ;; + 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:SunOS:5.*:*) + echo i386-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 /* 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 + + 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:*:[45]) + 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 + #include + + 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 + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || 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 __LP64__ >/dev/null + 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 + 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:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*: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 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-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*:*:*) + 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 ;; + arm*: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 ;; + 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:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #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; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #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; } + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + 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 ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + 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 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-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 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; 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.0*:*) + 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' /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 i386. + echo i386-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; } ;; + 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.0*:*) + 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 + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # 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 ;; + 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 ;; + 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 + *86) UNAME_PROCESSOR=i686 ;; + 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 ;; +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 < +# include +#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 + 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 +# 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 < 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/nx-X11/programs/xterm/config.sub b/nx-X11/programs/xterm/config.sub new file mode 100644 index 000000000..8b2c57a6e --- /dev/null +++ b/nx-X11/programs/xterm/config.sub @@ -0,0 +1,1577 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + +timestamp='2005-06-02' + +# 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 . Submit a context +# diff and a properly formatted 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. + +# 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 ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +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-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-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) + os= + basic_machine=$1 + ;; + -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 + ;; + -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/'` + ;; + -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 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ms1 \ + | msp430 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m32c) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # 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-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | ms1-* \ + | msp430-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + m32c-*) + ;; + # 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 + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + 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 + ;; + cr16c) + basic_machine=cr16c-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 + ;; + 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 + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + 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 + ;; + 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 + ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + 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 + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + 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 + ;; + 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 + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + 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 + ;; + 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 + ;; + 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 + ;; + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b) + 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. + -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* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -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* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -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*) + # 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* \ + | -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 + ;; + -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 + *-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 + ;; + 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 + ;; + *-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 + ;; + -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/nx-X11/programs/xterm/configure b/nx-X11/programs/xterm/configure new file mode 100644 index 000000000..7cdc6da4f --- /dev/null +++ b/nx-X11/programs/xterm/configure @@ -0,0 +1,11548 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by Autoconf 2.52.20030208. +# +# 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 +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#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 < if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + 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 </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 <\?\"\']*) + 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:945: 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:956: 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:964: 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:980: 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:984: 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:990: 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:992: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:994: 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:1013: 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:1015: 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 + +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:1035: PATH=\".;.\"; conftest.sh") >&5 + (PATH=".;."; conftest.sh) 2>&5 + ac_status=$? + echo "$as_me:1038: \$? = $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:1066: 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:1076: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:1080: 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:1089: 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:1093: 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:1098: 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:1106: 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:1115: 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:1120: 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 <&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:1145: 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:1149: 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:1151: 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 +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:1175: 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:1190: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1198: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1201: 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:1210: 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:1225: 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:1233: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1236: 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:1249: 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:1264: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1272: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1275: 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:1284: 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:1299: 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:1307: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1310: 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:1323: 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:1343: 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:1365: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1368: 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:1379: 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:1394: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:1402: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:1405: 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:1418: 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:1433: 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:1441: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:1444: 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:1456: 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:1461:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:1464: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:1467: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:1469: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:1472: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:1474: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:1477: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line 1481 "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:1497: 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:1500: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:1503: \$? = $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 | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + 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:1526: 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:1532: 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:1537: 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:1543: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1546: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:1553: 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:1561: 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:1568: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:1570: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:1573: checking for executable suffix" >&5 +echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 +if { (eval echo "$as_me:1575: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:1578: \$? = $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 | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:1594: 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:1600: 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:1606: 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 1612 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:1624: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1627: \$? = $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 | *.pdb ) ;; + *) 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:1639: 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:1646: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:1650: 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 1656 "configure" +#include "confdefs.h" + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1671: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1674: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1677: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1680: \$? = $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:1692: 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:1698: 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 1704 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1716: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1719: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1722: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1725: \$? = $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:1735: 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:1762: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1765: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1768: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1771: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + '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 1783 "configure" +#include "confdefs.h" +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1796: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1799: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1802: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1805: \$? = $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 1815 "configure" +#include "confdefs.h" +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:1827: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:1830: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:1833: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:1836: \$? = $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 -f 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_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 +echo "$as_me:1868: 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 1889 "configure" +#include "confdefs.h" +#include + Syntax error +_ACEOF +if { (eval echo "$as_me:1894: \"$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:1900: \$? = $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 1923 "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:1927: \"$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:1933: \$? = $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:1970: 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 1980 "configure" +#include "confdefs.h" +#include + Syntax error +_ACEOF +if { (eval echo "$as_me:1985: \"$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:1991: \$? = $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 2014 "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:2018: \"$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:2024: \$? = $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:2052: 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 + +if test $ac_cv_c_compiler_gnu = yes; then + echo "$as_me:2064: 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 2071 "configure" +#include "confdefs.h" +#include +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 -f conftest* + + if test $ac_cv_prog_gcc_traditional = no; then + cat >conftest.$ac_ext <<_ACEOF +#line 2086 "configure" +#include "confdefs.h" +#include +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 -f conftest* + + fi +fi +echo "$as_me:2099: 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:2110: 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:2125: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:2133: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:2136: 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:2155: 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:2204: 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' + +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:2232: 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:2247: found $ac_dir/$ac_word" >&5 +break +done + +fi +fi +LINT=$ac_cv_prog_LINT +if test -n "$LINT"; then + echo "$as_me:2255: result: $LINT" >&5 +echo "${ECHO_T}$LINT" >&6 +else + echo "$as_me:2258: 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:2267: checking for AIX" >&5 +echo $ECHO_N "checking for AIX... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line 2270 "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:2279: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +cat >>confdefs.h <<\EOF +#define _ALL_SOURCE 1 +EOF + +else + echo "$as_me:2286: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +rm -f conftest* + +echo "$as_me:2291: 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:2296: 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:2310: result: no" >&5 +echo "${ECHO_T}no" >&6 + ISC= +fi + +### checks for compiler characteristics + +echo "$as_me:2317: 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 + 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="$cf_new_cppflags $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 2411 "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:2432: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2435: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2438: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2441: \$? = $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:2454: 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 + 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="$cf_new_cppflags $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:2536: 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 2544 "configure" +#include "confdefs.h" +#include +#include +#include +#include +/* 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:2593: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2596: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2599: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2602: \$? = $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:2619: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:2622: 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:2627: 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 2633 "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:2691: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2694: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2697: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2700: \$? = $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:2710: 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 <&5 +echo $ECHO_N "checking if $CC -U and -D options work together... $ECHO_C" >&6 +if test "${cf_cv_cc_u_d_options+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cf_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS" + cat >conftest.$ac_ext <<_ACEOF +#line 2746 "configure" +#include "confdefs.h" + +int +main () +{ + +#ifndef U_D_OPTIONS +make an undefined-error +#endif +#ifdef D_U_OPTIONS +make a defined-error +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2765: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2768: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2771: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2774: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + cf_cv_cc_u_d_options=yes +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 + + cf_cv_cc_u_d_options=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + CPPFLAGS="$cf_save_CPPFLAGS" + +fi +echo "$as_me:2788: result: $cf_cv_cc_u_d_options" >&5 +echo "${ECHO_T}$cf_cv_cc_u_d_options" >&6 + +cf_XOPEN_SOURCE=500 +cf_POSIX_C_SOURCE=199506L + +case $host_os in #(vi +aix[45]*) #(vi + CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE" + ;; +freebsd*) #(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 + CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" + ;; +hpux*) #(vi + CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE" + ;; +irix[56].*) #(vi + CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE" + ;; +linux*|gnu*) #(vi + +echo "$as_me:2814: 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 2821 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifndef _XOPEN_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2836: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2839: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2842: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2845: \$? = $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 2854 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifdef _XOPEN_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2869: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2872: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2875: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2878: \$? = $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:2893: 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 + ;; +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 + CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE" + ;; +nto-qnx*) #(vi + CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE" + ;; +sco*) #(vi + # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer + ;; +solaris*) #(vi + CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__" + ;; +*) + echo "$as_me:2920: 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 2927 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifndef _XOPEN_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2942: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2945: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2948: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2951: \$? = $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 2960 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifdef _XOPEN_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:2975: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:2978: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:2981: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:2984: \$? = $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:2999: result: $cf_cv_xopen_source" >&5 +echo "${ECHO_T}$cf_cv_xopen_source" >&6 + if test "$cf_cv_xopen_source" != no ; then + +# remove _XOPEN_SOURCE symbol from $CFLAGS +CFLAGS=`echo "$CFLAGS" | \ + sed -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?$//g'` + +# remove _XOPEN_SOURCE symbol from $CPPFLAGS +CPPFLAGS=`echo "$CPPFLAGS" | \ + sed -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]_XOPEN_SOURCE\(=[^ ]*\)\?$//g'` + + test "$cf_cv_cc_u_d_options" = yes && \ + CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE" + CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source" + fi + +cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE + +cf_save_CFLAGS="$CFLAGS" +cf_save_CPPFLAGS="$CPPFLAGS" + +# remove _POSIX_C_SOURCE symbol from $cf_save_CFLAGS +cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \ + sed -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?[ ]/ /g' \ + -e 's/-[UD]_POSIX_C_SOURCE\(=[^ ]*\)\?$//g'` + +# remove _POSIX_C_SOURCE symbol from $cf_save_CPPFLAGS +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:3033: 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 "(line 3039) testing if the symbol is already defined go no further ..." 1>&5 + + cat >conftest.$ac_ext <<_ACEOF +#line 3042 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifndef _POSIX_C_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3057: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3060: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3063: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3066: \$? = $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 3087 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifdef _POSIX_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3102: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3105: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3108: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3111: \$? = $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 "(line 3122) testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5 + + CFLAGS="$cf_trim_CFLAGS" + CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" + +echo "(line 3127) testing if the second compile does not leave our definition intact error ..." 1>&5 + + cat >conftest.$ac_ext <<_ACEOF +#line 3130 "configure" +#include "confdefs.h" +#include +int +main () +{ + +#ifndef _POSIX_C_SOURCE +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3145: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3148: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3151: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3154: \$? = $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:3170: 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" + if test "$cf_cv_cc_u_d_options" = yes ; then + cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \ + sed -e 's/-D/-U/g' -e 's/=[^ ]*//g'` + CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source" + fi + CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source" +fi + + ;; +esac + +### checks for header files + +for ac_header in \ +ncurses/term.h \ +stdlib.h \ +termios.h \ +unistd.h \ +wchar.h \ + +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:3198: 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 3204 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:3208: \"$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:3214: \$? = $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:3233: 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 <&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 3249 "configure" +#include "confdefs.h" +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3265: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3268: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3271: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3274: \$? = $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:3284: 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:3294: 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 3300 "configure" +#include "confdefs.h" +#include +int +main () +{ +char* cs = nl_langinfo(CODESET); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:3312: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3315: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3318: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3321: \$? = $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:3332: 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:3344: 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 3356 "configure" +#include "confdefs.h" + +#include +#include +#include + +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:3379: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3382: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3385: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3388: \$? = $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:3402: 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 < or " >&5 +echo $ECHO_N "checking for size_t in or ... $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 3415 "configure" +#include "confdefs.h" + +#include +#ifdef STDC_HEADERS +#include +#include +#endif +#include +int +main () +{ +size_t x + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3433: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3436: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3439: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3442: \$? = $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:3454: 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:3460: 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 3466 "configure" +#include "confdefs.h" +#include +#include +#include +#include + +_ACEOF +if { (eval echo "$as_me:3474: \"$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:3480: \$? = $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 3502 "configure" +#include "confdefs.h" +#include + +_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 -f 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 3520 "configure" +#include "confdefs.h" +#include + +_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 -f 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 3541 "configure" +#include "confdefs.h" +#include +#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)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:3567: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3570: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:3572: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3575: \$? = $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:3588: 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:3604: 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 3610 "configure" +#include "confdefs.h" +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:3616: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3619: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3622: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3625: \$? = $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:3635: 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 <&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 3651 "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:3666: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3669: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3672: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3675: \$? = $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:3685: 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 <&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 3703 "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:3718: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3721: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3724: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3727: \$? = $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:3737: 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 <&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 3755 "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:3770: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:3773: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:3776: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3779: \$? = $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:3789: 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 <&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 3807 "configure" +#include "confdefs.h" +#include + +_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 -f conftest* + +fi +echo "$as_me:3821: 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 + +### 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:3852: 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 3858 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* 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:3889: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3892: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3895: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3898: \$? = $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:3908: 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 <&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 3924 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char memmove (); below. */ +#include +/* 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:3955: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:3958: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:3961: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:3964: \$? = $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:3974: 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:3980: 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 3986 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char bcopy (); below. */ +#include +/* 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:4017: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4020: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4023: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4026: \$? = $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:4036: 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:4040: 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 4050 "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); + exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz")); +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:4064: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4067: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:4069: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4072: \$? = $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:4085: 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:4109: 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 4115 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:4119: \"$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:4125: \$? = $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:4144: 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 <&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 4161 "configure" +#include "confdefs.h" + +#include +#ifdef HAVE_LASTLOG_H +#include +#else +#ifdef HAVE_PATHS_H +#include +#endif +#endif +int +main () +{ +char *path = _PATH_LASTLOG + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4181: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4184: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4187: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4190: \$? = $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:4205: 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:4211: 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 +#include <${cf_header}.h> +#define getutent getutxent +#ifdef USE_LASTLOG +#include /* may conflict with utmpx.h on Linux */ +#endif +" + cat >conftest.$ac_ext <<_ACEOF +#line 4228 "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:4242: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4245: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4248: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4251: \$? = $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 4260 "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:4274: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4277: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4280: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4283: \$? = $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:4298: 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:4311: checking if utmp.ut_host is declared" >&5 +echo $ECHO_N "checking if 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 4318 "configure" +#include "confdefs.h" + +#include +#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:4332: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4335: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4338: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4341: \$? = $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:4353: 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:4362: checking if utmp.ut_name is declared" >&5 +echo $ECHO_N "checking if 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 +#include <${cf_cv_have_utmp}.h> +#define getutent getutxent +#ifdef USE_LASTLOG +#include /* may conflict with utmpx.h on Linux */ +#endif +" +for cf_header in ut_name ut_user ; do + cat >conftest.$ac_ext <<_ACEOF +#line 4379 "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:4393: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4396: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4399: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4402: \$? = $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:4414: 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:4419: 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:4433: 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 4446 "configure" +#include "confdefs.h" + +#include +#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:4460: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4463: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4466: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4469: \$? = $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:4482: 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 <&5 +echo $ECHO_N "checking if 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 4504 "configure" +#include "confdefs.h" + +#include +#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:4518: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4521: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4524: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4527: \$? = $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 4534 "configure" +#include "confdefs.h" + +#include +#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:4548: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4551: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4554: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4557: \$? = $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:4571: 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:4588: checking if utmp.ut_session is declared" >&5 +echo $ECHO_N "checking if 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 4595 "configure" +#include "confdefs.h" + +#include +#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:4609: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4612: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4615: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4618: \$? = $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:4629: 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:4639: 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 4647 "configure" +#include "confdefs.h" + +#include +#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:4666: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4669: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4672: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4675: \$? = $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:4686: 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 + +# 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:4702: 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:4719: 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:4728: 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="$LIBS -l$cf_termlib" + 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 4750 "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"); + exit($cf_TERMTST); } +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:4765: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4768: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:4770: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4773: \$? = $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:4794: 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="$LIBS $cf_cv_lib_tgetent" + cat >>confdefs.h <<\EOF +#define USE_TERMCAP 1 +EOF + + cat >conftest.$ac_ext <<_ACEOF +#line 4808 "configure" +#include "confdefs.h" + +#include +int +main () +{ + +#ifdef NCURSES_VERSION +make an error +#endif + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:4824: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:4827: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:4830: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4833: \$? = $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 + # 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:4850: 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 4860 "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:4872: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:4875: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:4878: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:4881: \$? = $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:4895: 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="$LIBS $cf_cv_lib_part_tgetent" + +for ac_header in termcap.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:4904: 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 4910 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:4914: \"$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:4920: \$? = $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:4939: 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 <>confdefs.h <<\EOF +#define USE_TERMINFO 1 +EOF + + fi +fi + +echo "$as_me:4958: 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; +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%$ac_default_prefix%` + ;; + esac + ;; #(vi +.NONE/*) + withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%` + ;; +*) + { { echo "$as_me:4987: error: expected a pathname, not \"$withval\"" >&5 +echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;} + { (exit 1); exit 1; }; } + ;; +esac + +eval appsdir="$withval" + +echo "$as_me:4995: result: $appsdir" >&5 +echo "${ECHO_T}$appsdir" >&6 + +# inherit SINSTALL_OPTS from environment to allow packager to customize it. + +echo "$as_me:5000: 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:5010: result: $with_reference" >&5 +echo "${ECHO_T}$with_reference" >&6 + +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:5018: 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:5035: 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:5046: result: $XTERM_PATH" >&5 +echo "${ECHO_T}$XTERM_PATH" >&6 +else + echo "$as_me:5049: 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" +case $host_os in #(vi +os2*) #(vi + IFS="${IFS};" + ;; +*) + IFS="${IFS}:" + ;; +esac + +for cf_temp in $ac_cv_path_XTERM_PATH +do + if test -z "$cf_path_prog" ; then + if test "$with_full_paths" = yes ; then + +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%$ac_default_prefix%` + ;; + esac + ;; #(vi +.NONE/*) + cf_temp=`echo $cf_temp | sed -e s%NONE%$ac_default_prefix%` + ;; +*) + 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 "(line 5111) testing defining path for ${cf_path_prog} ..." 1>&5 + + cat >>confdefs.h <>confdefs.h <&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:5140: result: $disable_setuid" >&5 +echo "${ECHO_T}$disable_setuid" >&6 + +echo "$as_me:5143: 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:5153: 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:5165: 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:5175: 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:5182: 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 + read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest &5 +echo "${ECHO_T}$cf_cv_utmp_group" >&6 +else + { { echo "$as_me:5227: 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 + 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:5242: 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:5252: result: $use_utempter" >&5 +echo "${ECHO_T}$use_utempter" >&6 + +if test "$use_utempter" = yes ; then + +echo "$as_me:5257: 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 5266 "configure" +#include "confdefs.h" + +#include + +int +main () +{ + + addToUtmp("/dev/tty", 0, 1); + removeFromUtmp(); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:5283: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:5286: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:5289: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5292: \$? = $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:5306: 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 && disable_setuid=yes +fi + +### checks for external data + +echo "$as_me:5321: 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 5328 "configure" +#include "confdefs.h" + +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#include +#include +int +main () +{ +long x = (long) errno + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:5346: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:5349: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:5352: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5355: \$? = $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:5366: 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 <&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 5388 "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:5403: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:5406: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:5409: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5412: \$? = $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:5423: 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 <&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/(.*$//'` +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 + read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest /dev/null 1>/dev/null ) then + cf_cv_tty_group_name="tty" + fi + ;; +esac +fi + +fi +echo "$as_me:5488: result: $cf_cv_tty_group_name" >&5 +echo "${ECHO_T}$cf_cv_tty_group_name" >&6 + +cat >>confdefs.h <&5 +echo $ECHO_N "checking if we may use $cf_cv_tty_group_name 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 5512 "configure" +#include "confdefs.h" + +#include +#include +#include +#include +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) { + exit(0); + } + exit(1); +} + +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:5538: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:5541: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:5543: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5546: \$? = $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:5564: result: $cf_cv_tty_group" >&5 +echo "${ECHO_T}$cf_cv_tty_group" >&6 +test $cf_cv_tty_group = yes && cat >>confdefs.h <<\EOF +#define USE_TTY_GROUP 1 +EOF + +### checks for system services and user specified options + +echo "$as_me:5572: 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 5578 "configure" +#include "confdefs.h" +#include +#include +#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:5600: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:5603: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:5606: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5609: \$? = $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:5619: 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:5629: 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 5636 "configure" +#include "confdefs.h" + +#include +#include +#include +#ifdef HAVE_SYS_WAIT_H +#include +#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:5659: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:5662: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:5665: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5668: \$? = $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:5679: 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:5685: 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 5692 "configure" +#include "confdefs.h" + +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#include +#include +int +main () +{ +long x = (long) sys_nerr + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:5710: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:5713: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:5716: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5719: \$? = $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:5730: 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 <&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 5752 "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:5767: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:5770: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:5773: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5776: \$? = $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:5787: 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 <&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 5807 "configure" +#include "confdefs.h" + +#ifdef HAVE_STDLIB_H +#include +#endif +#include +#include +#include +int +main () +{ +long x = (long) sys_errlist + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:5825: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:5828: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:5831: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5834: \$? = $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:5845: 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 <&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 5867 "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:5882: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:5885: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:5888: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:5891: \$? = $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:5902: 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 <&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 5927 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:5931: \"$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:5937: \$? = $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:5956: 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 <&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 5973 "configure" +#include "confdefs.h" + +#undef SYSV +#define SYSV 1 /* get Xos.h to declare sys_errlist[] */ +#ifdef HAVE_STDLIB_H +#include /* look for wchar_t */ +#endif +#ifdef HAVE_X11_INTRINSIC_H +#include /* Intrinsic.h has other traps... */ +#endif +#include +#include /* eliminate most BSD hacks */ +#include /* declare sys_errlist on older systems */ +#include /* eliminate most of the remaining ones */ + +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; +#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:6011: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:6014: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:6017: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6020: \$? = $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:6031: 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:6037: 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 6045 "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:6064: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6067: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6070: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6073: \$? = $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:6084: 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:6088: 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 6095 "configure" +#include "confdefs.h" + +#include +#include + +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:6121: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:6124: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:6127: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6130: \$? = $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:6141: 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:6150: 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; 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 6247 "configure" +#include "confdefs.h" +#include +_ACEOF +if { (eval echo "$as_me:6251: \"$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:6257: \$? = $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 6290 "configure" +#include "confdefs.h" +#include +int +main () +{ +XtMalloc (0) + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:6302: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6305: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6308: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6311: \$? = $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; 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:6349: 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:6359: 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:6383: 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 6387 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:6399: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6402: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6405: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6408: \$? = $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:6418: 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 6424 "configure" +#include "confdefs.h" + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:6436: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6439: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6442: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6445: \$? = $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:6455: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + X_LIBS="$X_LIBS -R $x_libraries" + else + echo "$as_me:6459: 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 6479 "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:6498: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6501: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6504: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6507: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +echo "$as_me:6513: 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 6521 "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:6540: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6543: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6546: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6549: \$? = $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:6560: 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:6567: 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 6575 "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:6594: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6597: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6600: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6603: \$? = $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:6614: 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:6633: 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 6639 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char gethostbyname (); below. */ +#include +/* 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:6670: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6673: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6676: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6679: \$? = $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:6689: 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:6693: 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 6701 "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:6720: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6723: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6726: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6729: \$? = $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:6740: 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:6747: 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 6755 "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:6774: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6777: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6780: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6783: \$? = $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:6794: 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:6810: 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 6816 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char connect (); below. */ +#include +/* 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:6847: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6850: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6853: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6856: \$? = $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:6866: 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:6870: 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 6878 "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:6897: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6900: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6903: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6906: \$? = $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:6917: 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:6926: 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 6932 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char remove (); below. */ +#include +/* 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:6963: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:6966: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:6969: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:6972: \$? = $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:6982: 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:6986: 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 6994 "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:7013: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7016: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7019: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7022: \$? = $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:7033: 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:7042: 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 7048 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shmat (); below. */ +#include +/* 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:7079: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7082: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7085: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7088: \$? = $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:7098: 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:7102: 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 7110 "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:7129: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7132: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7135: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7138: \$? = $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:7149: 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:7167: 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 7175 "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:7194: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7197: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7200: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7203: \$? = $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:7214: 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 + +# SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -` + +cf_have_X_LIBS=no + +LDFLAGS="$X_LIBS $LDFLAGS" + +test -n "$verbose" && echo " checking additions to CFLAGS" 1>&6 + +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 + 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 + + 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 + + CPPFLAGS="$cf_new_cppflags $CPPFLAGS" +fi + +if test -n "$cf_new_extra_cppflags" ; then + test -n "$verbose" && echo " add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6 + + EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" +fi + +if test "$cf_check_cflags" != "$CFLAGS" ; then +cat >conftest.$ac_ext <<_ACEOF +#line 7308 "configure" +#include "confdefs.h" +#include +int +main () +{ +printf("Hello world"); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:7320: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7323: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7326: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7329: \$? = $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 + + if test "$cf_check_cppflags" != "$CPPFLAGS" ; then + test -n "$verbose" && echo " but keeping change to \$CPPFLAGS" 1>&6 + + fi + CFLAGS="$cf_check_flags" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi + +echo "$as_me:7346: 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 7352 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char XOpenDisplay (); below. */ +#include +/* 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:7383: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7386: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7389: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7392: \$? = $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:7402: 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:7408: 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 7416 "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:7435: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7438: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7441: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7444: \$? = $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:7455: 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:7463: 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 7469 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char XtAppInitialize (); below. */ +#include +/* 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:7500: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7503: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7506: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7509: \$? = $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:7519: 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:7525: 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 7533 "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:7552: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7555: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7558: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7561: \$? = $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:7572: 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" +fi + +fi + +if test $cf_have_X_LIBS = no ; then + { echo "$as_me:7586: 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/Xpoll.h \ + +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:7601: 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 7607 "configure" +#include "confdefs.h" +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:7611: \"$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:7617: \$? = $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:7636: 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 <&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:7659: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:7662: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +echo "$as_me:7666: 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:7677: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:7680: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +echo "$as_me:7684: 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:7695: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:7698: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +echo "$as_me:7702: 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 7710 "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:7729: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7732: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7735: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7738: \$? = $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:7749: 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 + +cf_x_athena_lib="" + +cf_x_athena_root=$cf_x_athena +cf_x_athena_include="" + +for cf_path in default \ + /usr/contrib/X11R6 \ + /usr/contrib/X11R5 \ + /usr/lib/X11R5 \ + /usr/local +do + if test -z "$cf_x_athena_include" ; then + cf_save="$CPPFLAGS" + cf_test=X11/$cf_x_athena_root/SimpleMenu.h + if test $cf_path != default ; then + CPPFLAGS="-I$cf_path/include $cf_save" + echo "$as_me:7771: 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:7774: checking for $cf_test" >&5 +echo $ECHO_N "checking for $cf_test... $ECHO_C" >&6 + fi + cat >conftest.$ac_ext <<_ACEOF +#line 7778 "configure" +#include "confdefs.h" + +#include +#include <$cf_test> +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:7792: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:7795: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:7798: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7801: \$? = $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:7810: result: $cf_result" >&5 +echo "${ECHO_T}$cf_result" >&6 + if test "$cf_result" = yes ; then + cf_x_athena_include=$cf_path + break + else + CPPFLAGS="$cf_save" + fi + fi +done + +if test -z "$cf_x_athena_include" ; then + { echo "$as_me:7822: 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_include" != default ; then + CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include" +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:7847: 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:7851: checking for $cf_test in $cf_lib" >&5 +echo $ECHO_N "checking for $cf_test in $cf_lib... $ECHO_C" >&6 + fi + cf_SAVE="$LIBS" + LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line 7857 "configure" +#include "confdefs.h" + +int +main () +{ +$cf_test() + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:7869: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:7872: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:7875: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7878: \$? = $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:7887: result: $cf_result" >&5 +echo "${ECHO_T}$cf_result" >&6 + if test "$cf_result" = yes ; then + cf_x_athena_lib="$cf_lib" + LIBS="$cf_SAVE" + break + else + LIBS="$cf_save" + fi + fi + done +done + +if test -z "$cf_x_athena_lib" ; then + { { echo "$as_me:7901: 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 <&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 "trying sys/types alone" 1>&5 +cat >conftest.$ac_ext <<_ACEOF +#line 7919 "configure" +#include "confdefs.h" + +#include +int +main () +{ +fd_set x + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:7932: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:7935: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:7938: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7941: \$? = $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 "trying X11/Xpoll.h" 1>&5 +cat >conftest.$ac_ext <<_ACEOF +#line 7949 "configure" +#include "confdefs.h" + +#ifdef HAVE_X11_XPOLL_H +#include +#endif +int +main () +{ +fd_set x + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:7964: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:7967: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:7970: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:7973: \$? = $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 "trying sys/select.h" 1>&5 +cat >conftest.$ac_ext <<_ACEOF +#line 7981 "configure" +#include "confdefs.h" + +#include +#include +int +main () +{ +fd_set x + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:7995: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:7998: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:8001: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:8004: \$? = $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:8018: 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:8027: 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 8034 "configure" +#include "confdefs.h" + +#include +#include +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:8052: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:8055: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:8058: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:8061: \$? = $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:8073: 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*) # 2004/8/15 - revisit this if/when grantpt is known to work. + +echo "$as_me:8086: 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 8094 "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:8113: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:8116: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:8119: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:8122: \$? = $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:8133: 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 <&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 8156 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* 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:8187: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:8190: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:8193: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:8196: \$? = $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:8206: 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 <&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 8223 "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:8242: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:8245: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:8248: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:8251: \$? = $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:8262: 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 <&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 8286 "configure" +#include "confdefs.h" + +#include /* has the prototype */ +#include /* has the XkbBI_xxx definitions */ + +int +main () +{ + +int x = XkbBI_Info + |XkbBI_MinorError + |XkbBI_MajorError + |XkbBI_TerminalBell + |XkbBI_MarginBell; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:8307: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:8310: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:8313: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:8316: \$? = $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:8327: 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:8337: 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 8343 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. */ +#include +/* 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:8374: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:8377: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:8380: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:8383: \$? = $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:8393: 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 <&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=$default_narrowproto + fi +else + enableval=$cf_default_narrowproto + enable_narrowproto=$default_narrowproto + +fi; +echo "$as_me:8435: result: $enable_narrowproto" >&5 +echo "${ECHO_T}$enable_narrowproto" >&6 + +echo "$as_me:8438: 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:8455: 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:8464: 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:8481: found $ac_dir/$ac_word" >&5 + break +fi +done + + ;; +esac +fi +IMAKE=$ac_cv_path_IMAKE + +if test -n "$IMAKE"; then + echo "$as_me:8492: result: $IMAKE" >&5 +echo "${ECHO_T}$IMAKE" >&6 +else + echo "$as_me:8495: 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/\(-D[a-zA-Z0-9_][a-zA-Z0-9_]*\)=\([^\\'"0-9 ][^ ]*\([ ][ ]*[^- ][^ ]*\)*\)/\1='\\"\2\\"'/g +s/\(-D[a-zA-Z0-9_][a-zA-Z0-9_]*\)=\([^\\'"0-9 ][^ ]*\)[ ]/\1='\\"\2\\"' /g +s/\(-D[a-zA-Z0-9_][a-zA-Z0-9_]*\)=\([^\\'"0-9 ][^ ]*\)$/\1='\\"\2\\"'/g +s/^IMAKE[ ]*/IMAKE_CFLAGS="/ +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 + + 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:8568: 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 + + else + { echo "$as_me:8577: 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 + + 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 + +test -n "$verbose" && echo " IMAKE_LOADFLAGS $IMAKE_LOADFLAGS" 1>&6 + +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 + 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="$cf_new_cppflags $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 + + # 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 + 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="$cf_new_cppflags $CPPFLAGS" +fi + +if test -n "$cf_new_extra_cppflags" ; then + + EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS" +fi + +fi + +echo "$as_me:8833: 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:8843: 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 <&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:8863: result: $default_TERM" >&5 +echo "${ECHO_T}$default_TERM" >&6 +cat >>confdefs.h <&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:8879: result: $TERMINFO_DIR" >&5 +echo "${ECHO_T}$TERMINFO_DIR" >&6 +if test "$TERMINFO_DIR" = yes ; then + { echo "$as_me:8882: 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 <&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 + +############################################################################### + +echo "$as_me:8909: 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:8926: 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:8935: 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:8952: 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:8960: 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:8977: 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:8983: 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:9000: 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:9010: 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:9027: 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:9041: 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:9058: 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:9064: 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:9088: 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:9102: 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=yes + else + enable_broken_st=no + fi +else + enableval=no + enable_broken_st=no + +fi; +echo "$as_me:9119: 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:9125: 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:9142: 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:9150: 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:9167: 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:9173: 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:9190: 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:9196: 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:9213: 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:9221: 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:9238: 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:9244: 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:9261: 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:9267: 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:9284: 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:9290: 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:9307: result: $enable_freetype" >&5 +echo "${ECHO_T}$enable_freetype" >&6 +if test "$enable_freetype" = yes ; then + +cf_extra_freetype_libs= +# 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:9314: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_FREETYPE_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $FREETYPE_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_FREETYPE_CONFIG="$FREETYPE_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_CONFIG="$ac_dir/$ac_word" + echo "$as_me:9331: found $ac_dir/$ac_word" >&5 + break +fi +done + + test -z "$ac_cv_path_FREETYPE_CONFIG" && ac_cv_path_FREETYPE_CONFIG="none" + ;; +esac +fi +FREETYPE_CONFIG=$ac_cv_path_FREETYPE_CONFIG + +if test -n "$FREETYPE_CONFIG"; then + echo "$as_me:9343: result: $FREETYPE_CONFIG" >&5 +echo "${ECHO_T}$FREETYPE_CONFIG" >&6 +else + echo "$as_me:9346: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test "$FREETYPE_CONFIG" = none; then + 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:9354: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_FREETYPE_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $FREETYPE_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_FREETYPE_CONFIG="$FREETYPE_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_CONFIG="$ac_dir/$ac_word" + echo "$as_me:9371: found $ac_dir/$ac_word" >&5 + break +fi +done + + test -z "$ac_cv_path_FREETYPE_CONFIG" && ac_cv_path_FREETYPE_CONFIG="none" + ;; +esac +fi +FREETYPE_CONFIG=$ac_cv_path_FREETYPE_CONFIG + +if test -n "$FREETYPE_CONFIG"; then + echo "$as_me:9383: result: $FREETYPE_CONFIG" >&5 +echo "${ECHO_T}$FREETYPE_CONFIG" >&6 +else + echo "$as_me:9386: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi + +if test "$FREETYPE_CONFIG" != none ; then + +# 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="$withval" + test -n "$verbose" && echo " freetype-cflags $cf_cv_x_freetype_incs" 1>&6 + +else + +echo "$as_me:9402: checking for X FreeType headers" >&5 +echo $ECHO_N "checking for X FreeType headers... $ECHO_C" >&6 +if test "${cf_cv_x_freetype_incs+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cf_cv_x_freetype_incs="`$FREETYPE_CONFIG --cflags 2>/dev/null`" + +fi +echo "$as_me:9411: result: $cf_cv_x_freetype_incs" >&5 +echo "${ECHO_T}$cf_cv_x_freetype_incs" >&6 +fi; + +# 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="$withval" + test -n "$verbose" && echo " freetype-libs $cf_cv_x_freetype_libs" 1>&6 + +else + +echo "$as_me:9423: checking for X FreeType libraries" >&5 +echo $ECHO_N "checking for X FreeType libraries... $ECHO_C" >&6 +if test "${cf_cv_x_freetype_libs+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +cf_save_LIBS="$LIBS" +cf_save_INCS="$CPPFLAGS" + +cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG --libs 2>/dev/null`" + +LIBS="$cf_cv_x_freetype_libs $LIBS" +CPPFLAGS="$cf_cv_x_freetype_incs $CPPFLAGS" + +cat >conftest.$ac_ext <<_ACEOF +#line 9438 "configure" +#include "confdefs.h" + +#include +#include +#include +int +main () +{ + + XftPattern *pat = XftNameParse ("name"); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:9455: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:9458: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:9461: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:9464: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +cf_cv_x_freetype_libs= +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + LIBS="$cf_save_LIBS" + CPPFLAGS="$cf_save_INCS" + +fi +echo "$as_me:9477: result: $cf_cv_x_freetype_libs" >&5 +echo "${ECHO_T}$cf_cv_x_freetype_libs" >&6 +fi; + +if test -n "$cf_cv_x_freetype_libs" ; 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 + 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="$cf_new_cppflags $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 + +else + CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//` +fi +else + CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//` +fi + +# FIXME: revisit this if needed + +else + CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//` +fi + +echo "$as_me:9569: 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:9586: 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:9595: 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:9612: 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:9621: 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:9638: 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:9647: 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:9664: 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:9673: 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:9690: result: $enable_ximp" >&5 +echo "${ECHO_T}$enable_ximp" >&6 + +echo "$as_me:9693: 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 9700 "configure" +#include "confdefs.h" + +#include +#include +#include +#include +#include +#include + +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:9732: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:9735: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:9738: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:9741: \$? = $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:9751: 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:9762: 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:9779: 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:9788: 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:9805: 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:9812: 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:9829: 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:9839: 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:9856: 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:9862: 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:9879: 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:9885: 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" != yes && enableval=no + if test "$enableval" != "no" ; then + enable_paste64=yes + else + enable_paste64=no + fi +else + enableval=no + enable_paste64=no + +fi; +echo "$as_me:9902: 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:9916: 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:9933: 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:9947: 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:9964: 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:9973: 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:9990: 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:9999: 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:10016: 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:10022: 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:10039: 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:10045: 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" != yes && enableval=no + if test "$enableval" != "no" ; then + enable_tcap_query=yes + else + enable_tcap_query=no + fi +else + enableval=no + enable_tcap_query=no + +fi; +echo "$as_me:10062: 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:10068: 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:10085: 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:10098: 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:10115: 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:10124: 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:10141: 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:10147: 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:10164: 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:10173: 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:10190: 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 + +fi + +echo "$as_me:10199: 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:10216: result: $enable_wchar" >&5 +echo "${ECHO_T}$enable_wchar" >&6 +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:10228: 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:10245: 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:10254: 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:10271: 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:10280: 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:10297: 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:10305: 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:10322: 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:10333: 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='# compiling' + SHOW_CC='# compiling' + ECHO_CC='' + + fi +else + enableval=yes + + ECHO_LT='' + ECHO_LD='' + RULE_CC='# compiling' + SHOW_CC='# compiling' + ECHO_CC='' + +fi; +echo "$as_me:10367: result: $enableval" >&5 +echo "${ECHO_T}$enableval" >&6 + +echo "$as_me:10370: 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:10387: 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 + +if test -n "$GCC" ; then +echo "$as_me:10399: 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:10416: result: $with_warnings" >&5 +echo "${ECHO_T}$with_warnings" >&6 +if test "$with_warnings" = yes +then + +if test "$GCC" = yes +then +cat > conftest.i <&5 +echo "$as_me: checking for $CC __attribute__ directives..." >&6;} +cat > conftest.$ac_ext <&5 + case $cf_attribute in + scanf|printf) + cat >conftest.h <conftest.h <&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:10483: \$? = $ac_status" >&5 + (exit $ac_status); }; then + test -n "$verbose" && echo "$as_me:10485: result: ... $cf_attribute" >&5 +echo "${ECHO_T}... $cf_attribute" >&6 + cat conftest.h >>confdefs.h + 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:10498: checking version of $CC" >&5 +echo $ECHO_N "checking version of $CC... $ECHO_C" >&6 + GCC_VERSION="`${CC} --version| 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:10502: 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:10511: 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 10516 "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:10533: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:10536: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:10539: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:10542: \$? = $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:10553: result: $INTEL_COMPILER" >&5 +echo "${ECHO_T}$INTEL_COMPILER" >&6 + ;; + esac +fi + +cat > conftest.$ac_ext <&5 +echo "$as_me: checking for $CC warning options..." >&6;} + cf_save_CFLAGS="$CFLAGS" + EXTRA_CFLAGS="-Wall" + for cf_opt in \ + wd1419 \ + wd1682 \ + wd1683 \ + wd1684 \ + wd193 \ + wd279 \ + wd593 \ + wd810 \ + wd869 \ + wd981 + do + CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" + if { (eval echo "$as_me:10595: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:10598: \$? = $ac_status" >&5 + (exit $ac_status); }; then + test -n "$verbose" && echo "$as_me:10600: 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:10609: checking for $CC warning options..." >&5 +echo "$as_me: checking for $CC warning options..." >&6;} + cf_save_CFLAGS="$CFLAGS" + EXTRA_CFLAGS="-W -Wall" + cf_warn_CONST="" + test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings" + for cf_opt in \ + Wbad-function-cast \ + Wcast-align \ + Wcast-qual \ + Winline \ + Wmissing-declarations \ + Wmissing-prototypes \ + Wnested-externs \ + Wpointer-arith \ + Wshadow \ + Wstrict-prototypes \ + Wundef $cf_warn_CONST + do + CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" + if { (eval echo "$as_me:10629: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:10632: \$? = $ac_status" >&5 + (exit $ac_status); }; then + test -n "$verbose" && echo "$as_me:10634: 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 + 3.3*) + test -n "$verbose" && echo " feature is broken in gcc $GCC_VERSION" 1>&6 + + continue;; + esac + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" + fi + done + CFLAGS="$cf_save_CFLAGS" +fi +rm -f conftest* + +fi +fi + +if test $disable_setuid = yes ; then + MAY_SETUID="#" + NOT_SETUID= + cat >>confdefs.h <<\EOF +#define DISABLE_SETUID 1 +EOF + +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 + +### 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:10768: 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 ." +EOF + +cat >>$CONFIG_STATUS <>$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 <>$CONFIG_STATUS <<\EOF + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:10941: 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:10960: 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.20030208, 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:10997: 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 <\$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,@LINT@,$LINT,;t t +s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t +s,@PROG_EXT@,$PROG_EXT,;t t +s,@appsdir@,$appsdir,;t t +s,@XTERM_PATH@,$XTERM_PATH,;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,@IMAKE@,$IMAKE,;t t +s,@IMAKE_CFLAGS@,$IMAKE_CFLAGS,;t t +s,@IMAKE_LOADFLAGS@,$IMAKE_LOADFLAGS,;t t +s,@TERMINFO_DIR@,$TERMINFO_DIR,;t t +s,@SET_TERMINFO@,$SET_TERMINFO,;t t +s,@FREETYPE_CONFIG@,$FREETYPE_CONFIG,;t t +s,@XRENDERFONT@,$XRENDERFONT,;t t +s,@HAVE_TYPE_FCCHAR32@,$HAVE_TYPE_FCCHAR32,;t t +s,@HAVE_TYPE_XFTCHARSPEC@,$HAVE_TYPE_XFTCHARSPEC,;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 +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:11243: 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:11261: 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:11274: 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 <>$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:11340: 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:11351: 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:11364: 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 <>$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 <>$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:11482: $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/nx-X11/programs/xterm/configure.in b/nx-X11/programs/xterm/configure.in new file mode 100644 index 000000000..6ec395318 --- /dev/null +++ b/nx-X11/programs/xterm/configure.in @@ -0,0 +1,779 @@ +dnl $XTermId: configure.in,v 1.197 2005/11/03 13:17:27 tom Exp $ +dnl +dnl $XFree86: xc/programs/xterm/configure.in,v 3.72 2005/11/03 13:17:27 dickey Exp $ +dnl +dnl --------------------------------------------------------------------------- +dnl +dnl Copyright 1997-2004,2005 by Thomas E. Dickey +dnl +dnl All Rights Reserved +dnl +dnl Permission to use, copy, modify, and distribute this software and its +dnl documentation for any purpose and without fee is hereby granted, +dnl provided that the above copyright notice appear in all copies and that +dnl both that copyright notice and this permission notice appear in +dnl supporting documentation, and that the name of the above listed +dnl copyright holder(s) not be used in advertising or publicity pertaining +dnl to distribution of the software without specific, written prior +dnl permission. +dnl +dnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD +dnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +dnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE +dnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +dnl +dnl --------------------------------------------------------------------------- +dnl Process this file with autoconf to produce a configure script. +dnl +AC_PREREQ(2.13.20020210) +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_GCC_TRADITIONAL +AC_PROG_AWK +AC_PROG_INSTALL +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_CONST +CF_PROG_EXT +CF_XOPEN_SOURCE + +### checks for header files +AC_CHECK_HEADERS( \ +ncurses/term.h \ +stdlib.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 + +### 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_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) + +# 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) + +CF_PATH_PROG(XTERM_PATH,$with_reference) + +AC_MSG_CHECKING(if you want to disable setuid) +CF_ARG_DISABLE(setuid, + [ --disable-setuid disable setuid in xterm, do not install setuid], + [disable_setuid=yes], + [disable_setuid=no], + no) +AC_MSG_RESULT($disable_setuid) + +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 + 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 && disable_setuid=yes +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/Xpoll.h \ + ) + +CF_X_ATHENA +CF_TYPE_FD_SET +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*) # 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 + +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_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 +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, + [ --enable-broken-st allow broken string-terminators], + [enable_broken_st=yes], + [enable_broken_st=no]) +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 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_FREETYPE +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 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_ENABLE(paste64, + [ --enable-paste64 enable get/set base64 selection data], + [enable_paste64=yes], + [enable_paste64=no]) +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 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-query/report) +CF_ARG_ENABLE(tcap-query, + [ --enable-tcap-query compile-in termcap-query support], + [enable_tcap_query=yes], + [enable_tcap_query=no]) +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) +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) +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 -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 + +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 + +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 +fi +fi + +AC_SUBST(EXTRA_CFLAGS) +AC_SUBST(CHARPROC_DEPS) +AC_SUBST(EXTRAHDRS) +AC_SUBST(EXTRASRCS) +AC_SUBST(EXTRAOBJS) + +if test $disable_setuid = yes ; then + MAY_SETUID="#" + NOT_SETUID= + AC_DEFINE(DISABLE_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 + +### output Makefile and xtermcfg.h +AC_OUTPUT(Makefile) diff --git a/nx-X11/programs/xterm/ctlseqs.ms b/nx-X11/programs/xterm/ctlseqs.ms new file mode 100644 index 000000000..bbf8960ee --- /dev/null +++ b/nx-X11/programs/xterm/ctlseqs.ms @@ -0,0 +1,1876 @@ +.\"#! troff -ms $1 -*- Nroff -*- +.\" "Xterm Control Sequences" document +.\" $XTermId: ctlseqs.ms,v 1.158 2005/09/18 23:48:10 tom Exp $ +.\" +.\" +.\" $Xorg: ctlseqs.ms,v 1.3 2000/08/17 19:42:51 cpqbld Exp $ +.\" +.\" +.\" +.\" $XFree86: xc/doc/specs/xterm/ctlseqs.ms,v 3.57 2005/09/18 23:48:10 dickey Exp $ +.\" +.\" +.\" Copyright 1996-2004,2005 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 +.\" +.\" Run this file through troff and use the -ms macro package. +.\" +.if n .pl 9999v \" no page breaks in nroff +.ND +.de St +.sp +.nr PD 0 +.nr PI 1.5i +.nr VS 16 +.. +.de Ed +.nr PD .3v +.nr VS 12 +.. +.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 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-2005) +.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 +.ds RH 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): affects next character only +.IP \\*(Es\\*O +Single Shift Select of G3 Character Set (\*(S3 is 0x8f): 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 +.ds RH 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 features not supported is auto-repeat, +since the only way X provides for this will affect all windows. +There are additional control sequences to provide +\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 +.\" +.LP +.B +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) same as LF +. +.IP \\*(Lf +Line Feed or New Line (NL) (Ctrl-J) +. +.IP \\*(So +Shift Out (Ctrl-N) \(-> Switch to Alternate Character Set: invokes the +G1 character set. +. +.IP \\*(Sp +Space. +. +.IP \\*(Ta +Horizontal Tab (HT) (Ctrl-I) +. +.IP \\*(Vt +Vertical Tab (Ctrl-K) same as LF +. +.IP \\*(Si +Shift In (Ctrl-O) \(-> Switch to Standard Character Set: invokes the +G0 character set (the default). +.Ed +.\" +.\" +.\" +.St +.LP +.B +Controls beginning with ESC (other than those where ESC is part of a 7-bit equivalent to 8-bit C1 controls), ordered by the final 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, ISO 8859-1 (ISO 2022) +. +.IP \\*(Es\\*%\\*G +Select UTF-8 character set (ISO 2022) +. +.IP \\*(Es\\*(((\\*(Cc +Designate G0 Character Set (ISO 2022) +.IP \\*(Es\\*)\\*(Cc +Designate G1 Character Set (ISO 2022) +. +.IP \\*(Es\\**\\*(Cc +Designate G2 Character Set (ISO 2022) +. +.IP \\*(Es\\*+\\*(Cc +Designate G3 Character Set (ISO 2022) +.br +Final character \*(Cc for designating character sets +(\*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 +. +.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 (if +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 +.LP +.B +Application Program-Control functions +.IP \\*(AP\\*(Pt\\*s\\*(ST +\fIxterm\fP implements no \*(AP functions; \*(Pt is ignored. +\*(Pt need not be printable characters. +.Ed +. +.St +.LP +.B +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\\*+\\*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 +\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 +.LP +.B +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\\*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: + \(-> \*1 132-columns + \(-> \*2 Printer + \(-> \*6 Selective erase + \(-> \*8 User-defined keys + \(-> \*9 National replacement character sets + \(-> \*1\*5 Technical characters + \(-> \*2\*2 ANSI color, e.g., VT525 + \(-> \*2\*9 ANSI text locator (i.e., DEC Locator mode) +. +.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 + \(-> \*0 (``VT100'') + \(-> \*1 (``VT220'') +.br +and \*(Pv is the firmware version (for \fIxterm\fP, this is 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 +(normally disabled by a compile-time option) + \*(Ps = \*4\*7 \(-> Use Alternate Screen Buffer (unless +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\*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\*5 \(-> Enable special modifiers for Alt and NumLock keys. + \*(Ps = \*1\*0\*3\*6 \(-> Send ESC when Meta modifies a key +(enables the \fBmetaSendsEscape\fP resource). + \*(Ps = \*1\*0\*3\*7 \(-> Send DEL from the editing-keypad Delete key + \*(Ps = \*1\*0\*4\*7 \(-> Use Alternate Screen Buffer (unless +disabled by the \fBtiteInhibit\fP resource) + \*(Ps = \*1\*0\*4\*8 \(-> Save cursor as in DECSC (unless +disabled by the \fBtiteInhibit\fP resource) + \*(Ps = \*1\*0\*4\*9 \(-> Save cursor as in DECSC +and use Alternate Screen Buffer, clearing it first (unless +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\*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 Sun/PC keyboard emulation of VT220 keyboard. + \*(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 +(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\*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\*5 \(-> Disable special modifiers for Alt and NumLock keys. + \*(Ps = \*1\*0\*3\*6 \(-> Don't send ESC when Meta modifies a key +(disables the \fBmetaSendsEscape\fP resource). + \*(Ps = \*1\*0\*3\*7 \(-> Send VT220 Remove from the editing-keypad Delete key + \*(Ps = \*1\*0\*4\*7 \(-> Use Normal Screen Buffer, clearing screen +first if in the Alternate Screen (unless +disabled by the \fBtiteInhibit\fP resource) + \*(Ps = \*1\*0\*4\*8 \(-> Restore cursor as in DECRC (unless +disabled by the \fBtiteInhibit\fP resource) + \*(Ps = \*1\*0\*4\*9 \(-> Use Normal Screen Buffer and restore cursor +as in DECRC (unless +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\*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 Sun/PC keyboard emulation of VT220 keyboard. + \*(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\\*s\\*n +Device Status Report (DSR) + \*(Ps = \*5 \(-> Status Report \*(Cs\*0\*n (``OK'') + \*(Ps = \*6 \(-> Report Cursor Position (CPR) [row;column] as +.br +\*(Cs\*(Ir\*s\*;\*(Ic\*s\*R +. +.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\\*!\\*p +Soft terminal reset (DECSTR) +. +.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\\*(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). + \*(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 ; \fIx ; y\fP \(-> Move window to [x, y]. + \*(Ps = \*4 ; \fIheight ; width\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 ; \fIheight ; width\fP \(-> 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 \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 as +\*(Cs\*3\*;\*(Ix\*;\*(Iy\*t + \*(Ps = \*1\*4 \(-> Report \fIxterm\fP window in pixels as +\*(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 as +\*(Cs\*s\*8\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t + \*(Ps = \*1\*9 \(-> Report the size of the screen in characters as +\*(Cs\*s\*9\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t + \*(Ps = \*2\*0 \(-> Report \fIxterm\fP window's icon label as +\*(Os\*s\*L\*s\fIlabel\fP\*s\*(ST + \*(Ps = \*2\*1 \(-> Report \fIxterm\fP window's title as +\*(Os\*s\*l\*s\fItitle\fP\*s\*(ST + \*(Ps >= \*2\*4 \(-> Resize to \*(Ps lines (DECSLPP) +. +.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Ps\\*$\\*t +Reverse Attributes in Rectangular Area (DECRARA). + \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle. + \*(Ps denotes the attributes to reverse. 1, 4, 5, 7 +. +.IP \\*(Cs\\*u +Save cursor (ANSI.SYS) +. +.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Pp\\*;\\*(Pt\\*;\\*(Pl\\*;\\*(Pp\\*$\\*v +Copy Rectangular Area (DECCRA) + \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle. + \*(Pp denotes the source page. + \*(Pt\*;\*(Pl denotes the target location. + \*(Pp denotes the target page. +. +.IP \\*(Cs\\*(Pt\\*s\\*;\\*(Pl\\*s\\*;\\*(Pb\\*s\\*;\\*(Pr\\*s\\*(qu\\*w +Enable Filter Rectangle (DECEFR) +.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. + \*1 \(-> no parity + \*1 \(-> eight bits + \*1 \*2 \*8 \(-> transmit 38.4k baud + \*1 \*2 \*8 \(-> receive 38.4k baud + \*1 \(-> clock multiplier + \*0 \(-> STP flags +. +.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). + \*(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). + \*(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) + (default) also cancels any filter rectangle + \*(Ps = \*1 \(-> report button down transitions + \*(Ps = \*2 \(-> do not report button down transitions + \*(Ps = \*3 \(-> report button up transitions + \*(Ps = \*4 \(-> do not report button up transitions +. +.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*$\\*{ +Selective Erase Rectangular Area (DECSERA). + \*(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 +.LP +.B +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, +i.e., 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 +The 8 colors which may be set 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. +One or more parameters is expected for \*(Pt. +Each successive parameter changes the next color in the list. +The value of \*(Ps tells the starting point in the list. +The colors are specified by name or RGB specification as per \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 color to \*(Pt + \*(Ps = \*1\*8 \(-> Change Tektronix cursor color to \*(Pt +.sp + \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt (normally disabled by a +compile-time option) +.sp + \*(Ps = \*5\*0 \(-> Set Font to \*(Pt +If \*(Pt begins with a "#", index in the font menu, relative (if the +next character is a plus or minus sign) or absolute. A number is +expected but not required after the sign (the default is the current +entry for relative, zero for absolute indexing). +.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 \*0 \*1 \*2 \*3 \*4 \*5 \*6 \*7. +It is used to construct a list of selection parameters for +clipboard, +primary, +or cut buffers 0 through 8 respectively, +in the order given. +If the parameter is empty, \fIxterm\fP uses \*p\*0, +to specify the primary 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 +. +.St +.LP +.B +Privacy Message +.IP \\*(PM\\*(Pt\\*s\\*(ST +\fIxterm\fP implements no \*(PM functions; \*(Pt is ignored. +\*(Pt need not be printable characters. +.Ed +. +.SH +PC-Style Function Keys +.ds RH 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. +.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 +They also provide 12 function keys, as well as a few other special-purpose keys. +.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 +.LP +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). +.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~ + +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: +.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: +.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. +.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: +.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 +.ds RH 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 ~, +followed by the pasted text, followed by ESC [ 201 ~. +.SH +Mouse Tracking +.ds RH 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. + +There are six mutually exclusive modes. +One is DEC Locator mode, enabled by the +DECELR \*(Cs\*(Ps\*s\*;\*(Ps\*s\*s\*'\*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 +DECSET \*(Cs\*?\*(Pm\*s\*h +or +DECRST \*(Cs\*?\*(Pm\*s\*l +control sequence. + +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 +.DE +.LP +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. + +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. + +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). +\*(Cb is button\-1. +\*(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, \fIxterm\fP sends +\*(Cs\*M\*(Cb\*(Cx\*(Cy. +The low two bits of \*(Cb encode button information: +0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. +The next three bits encode the modifiers which were down when the button was +pressed and are added together: 4=Shift, 8=Meta, 16=Control. +Note however that the shift and control bits are normally unavailable +because \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). +\*(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 button events +can be received. +\fBWarning:\fP use of this mode requires a cooperating program or it will +hang \fIxterm.\fP +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: if the start and end coordinates are valid text +locations: \*(Cs\*t\*(Cx\*(Cy. If either coordinate is past +the end of the line: +\*(Cs\*T\*(Cx\*(Cy\*(Cx\*(Cy\*(Cx\*(Cy. +The parameters are \fIstartx, starty, endx, endy, mousex,\fP and \fImousey.\fP +\fIstartx, starty, endx, \fPand\fI endy\fP give the starting and +ending character positions of the region. \fImousex\fP and \fImousey\fP +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 +\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. On button-motion events, \fIxterm\fP adds 32 to the event code +(the third character, \*(Cb). +The other bits of the event code specify button and modifier keys as in normal mode. +For example, motion into cell x,y with button 1 +down is reported as \*(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) ). + +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. +. +.br +.ds RH Tektronix 4014 Mode +.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 (ignored by \fIxterm\fP) (ESC Ctrl-N) +.IP \\*(Es\\*(Si +End 4015 APL mode (ignored by \fIxterm\fP) (ESC Ctrl-O) +.IP \\*(Es\\*(Eb +COPY (Save Tektronix Codes to file COPYyyyy-mm-dd.hh:mm:ss) (ESC 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 (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 +. +. +.br +.ds RH VT52 Mode +.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/nx-X11/programs/xterm/cursor.c b/nx-X11/programs/xterm/cursor.c new file mode 100644 index 000000000..d77645acd --- /dev/null +++ b/nx-X11/programs/xterm/cursor.c @@ -0,0 +1,345 @@ +/* $XTermId: cursor.c,v 1.36 2005/08/05 01:25:39 tom Exp $ */ + +/* + * $Xorg: cursor.c,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/cursor.c,v 3.18 2005/08/05 01:25:39 dickey Exp $ */ + +/* + * Copyright 2002-2004,2005 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 +#include + +#include + +/* + * 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 = 0; + + 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(TScreen * screen, int n) +{ + int i, j, k, rev; + + if ((rev = (term->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); + } else + set_cur_col(screen, 0); + } + screen->do_wrap = 0; +} + +/* + * moves the cursor forward n, no wraparound + */ +void +CursorForward(TScreen * screen, int n) +{ + int next = screen->cur_col + n; + int max = CurMaxCol(screen, screen->cur_row); + + if (next > max) + next = max; + + set_cur_col(screen, next); + screen->do_wrap = 0; +} + +/* + * 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 = 0; +} + +/* + * 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 = 0; +} + +/* + * Moves cursor down amount lines, scrolls if necessary. + * Won't leave scrolling region. No carriage return. + */ +void +xtermIndex(TScreen * screen, int amount) +{ + 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(screen, amount - j); +} + +/* + * Moves cursor up amount lines, reverse scrolls if necessary. + * Won't leave scrolling region. No carriage return. + */ +void +RevIndex(TScreen * screen, int amount) +{ + /* + * 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(screen, 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 = 0; +} + +/* + * Save Cursor and Attributes + */ +void +CursorSave(XtermWidget tw) +{ + TScreen *screen = &tw->screen; + SavedCursor *sc = &screen->sc[screen->alternate != False]; + + sc->saved = True; + sc->row = screen->cur_row; + sc->col = screen->cur_col; + sc->flags = tw->flags; + sc->curgl = screen->curgl; + sc->curgr = screen->curgr; +#if OPT_ISO_COLORS + sc->cur_foreground = tw->cur_foreground; + sc->cur_background = tw->cur_background; + sc->sgr_foreground = tw->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 tw) +{ + TScreen *screen = &tw->screen; + SavedCursor *sc = &screen->sc[screen->alternate != False]; + + /* 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); + } + + tw->flags &= ~DECSC_FLAGS; + tw->flags |= sc->flags & DECSC_FLAGS; + CursorSet(screen, + ((tw->flags & ORIGIN) + ? sc->row - screen->top_marg + : sc->row), + sc->col, tw->flags); + +#if OPT_ISO_COLORS + tw->sgr_foreground = sc->sgr_foreground; + SGR_Foreground(tw->flags & FG_COLOR ? sc->cur_foreground : -1); + SGR_Background(tw->flags & BG_COLOR ? sc->cur_background : -1); +#endif +} + +/* + * 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) +{ + 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) +{ + assert(screen != 0); + assert(value >= 0); + assert(value <= screen->max_col); + screen->cur_col = value; + return value; +} +#endif /* OPT_TRACE */ diff --git a/nx-X11/programs/xterm/data.c b/nx-X11/programs/xterm/data.c new file mode 100644 index 000000000..6fbf85cd5 --- /dev/null +++ b/nx-X11/programs/xterm/data.c @@ -0,0 +1,127 @@ +/* $XTermId: data.c,v 1.77 2005/09/18 23:48:12 tom Exp $ */ + +/* + * $Xorg: data.c,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/data.c,v 3.32 2005/09/18 23:48:12 dickey Exp $ */ + +/* + * Copyright 2002-2004,2005 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 + +Widget toplevel; /* top-most widget in xterm */ + +#if OPT_TEK4014 +Char *Tpushb; +Char *Tpushback; +TekLink *TekRefresh; +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; + +Bool waiting_for_initial_map; + +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; + +#if OPT_ZICONBEEP +int zIconBeep; /* non-zero means beep; see charproc.c for details -IAN! */ +Boolean zIconBeep_flagged; /* True if the icon name has been changed */ +#endif /* OPT_ZICONBEEP */ + +#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 + +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; + +Boolean waitingForTrackInfo = False; +EventMode eventMode = NORMAL; diff --git a/nx-X11/programs/xterm/data.h b/nx-X11/programs/xterm/data.h new file mode 100644 index 000000000..04e36786e --- /dev/null +++ b/nx-X11/programs/xterm/data.h @@ -0,0 +1,207 @@ +/* $XTermId: data.h,v 1.92 2005/09/18 23:48:12 tom Exp $ */ + +/* + * $Xorg: data.h,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/data.h,v 3.37 2005/09/18 23:48:12 dickey Exp $ */ + +/* + * Copyright 2002-2004,2005 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 + +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 *TekRefresh; +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; + +#if OPT_ZICONBEEP +extern int zIconBeep; +extern Boolean zIconBeep_flagged; +#endif + +#if OPT_SAME_NAME +extern Boolean sameName; +#endif + +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 Boolean waitingForTrackInfo; + +extern EventMode eventMode; + +extern XtermWidget term; + +extern SIG_ATOMIC_T need_cleanup; + +#if defined(HAVE_XKB_BELL_EXT) +#include /* has the prototype */ +#include /* 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 Bool waiting_for_initial_map; +extern Atom wm_delete_window; + +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 keyboardType; + Boolean sunFunctionKeys; /* %%% should be widget resource? */ +#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_INITIAL_ERASE + Boolean ptyInitialErase; /* if true, use pty's sense of erase char */ + Boolean backarrow_is_erase; /* override backspace/delete */ +#endif + Boolean wait_for_map; + Boolean useInsertMode; +#if OPT_ZICONBEEP + int zIconBeep; /* beep level when output while iconified */ +#endif +#if OPT_PTY_HANDSHAKE + Boolean ptyHandshake; /* use pty-handshaking */ +#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 +} XTERM_RESOURCE; + +extern XTERM_RESOURCE resource; + +#endif /* included_data_h */ diff --git a/nx-X11/programs/xterm/doublechr.c b/nx-X11/programs/xterm/doublechr.c new file mode 100644 index 000000000..b768b2ed7 --- /dev/null +++ b/nx-X11/programs/xterm/doublechr.c @@ -0,0 +1,267 @@ +/* $XTermId: doublechr.c,v 1.43 2005/08/05 01:25:39 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/doublechr.c,v 3.17 2005/08/05 01:25:39 dickey Exp $ + */ + +/************************************************************ + +Copyright 1997-2004,2005 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 +#include +#include + +#include + +/* + * 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. + */ +#define curChrSet SCRN_BUF_CSETS(screen, screen->cur_row)[0] + +#if OPT_DEC_CHRSET +static void +repaint_line(unsigned newChrSet) +{ + register TScreen *screen = &term->screen; + int curcol = screen->cur_col; + int currow = screen->cur_row; + unsigned len = MaxCols(screen); + int width = len; + unsigned oldChrSet = SCRN_BUF_CSETS(screen, currow)[0]; + + assert(width > 0); + + /* + * Ignore repetition. + */ + if (oldChrSet == newChrSet) + return; + + TRACE(("repaint_line(%2d,%2d) (%d)\n", currow, screen->cur_col, 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. + */ + if (CSET_DOUBLE(oldChrSet) != CSET_DOUBLE(newChrSet)) { + ClearCurBackground(screen, + CursorY(screen, currow), + CurCursorX(screen, currow, 0), + (unsigned) FontHeight(screen), + len * CurFontWidth(screen, currow)); + } + + /* FIXME: do VT220 softchars allow double-sizes? */ + memset(SCRN_BUF_CSETS(screen, currow), (Char) newChrSet, len); + + set_cur_col(screen, 0); + ScrnUpdate(screen, 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(Bool top) +{ +#if OPT_DEC_CHRSET + repaint_line((unsigned) (top ? CSET_DHL_TOP : CSET_DHL_BOT)); +#endif +} + +/* + * Set the line to single-width characters (the normal state). + */ +void +xterm_DECSWL(void) +{ +#if OPT_DEC_CHRSET + repaint_line(CSET_SWL); +#endif +} + +/* + * Set the line to double-width characters + */ +void +xterm_DECDWL(void) +{ +#if OPT_DEC_CHRSET + repaint_line(CSET_DWL); +#endif +} + +#if OPT_DEC_CHRSET +static void +discard_font(TScreen * screen, XTermFonts * data) +{ + TRACE(("discard_font chrset=%d %s\n", data->chrset, + (data->fn != 0) ? data->fn : "")); + + data->chrset = 0; + data->flags = 0; + if (data->gc != 0) { + XFreeGC(screen->display, data->gc); + data->gc = 0; + } + if (data->fn != 0) { + free(data->fn); + data->fn = 0; + } + if (data->fs != 0) { + XFreeFont(screen->display, data->fs); + data->fs = 0; + } +} + +int +xterm_Double_index(unsigned chrset, unsigned flags) +{ + int n; + TScreen *screen = &term->screen; + 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; + } + return n; + } + } + + /* Not, found, push back existing fonts and create a new entry */ + if (screen->fonts_used >= screen->cache_doublesize) { + TRACE(("...xterm_Double_index: discard oldest\n")); + discard_font(screen, &(data[screen->fonts_used - 1])); + } else { + screen->fonts_used += 1; + } + for (n = screen->fonts_used; n > 0; n--) + data[n] = data[n - 1]; + + TRACE(("...xterm_Double_index -> (NEW:%d)\n", screen->fonts_used)); + + data[0].chrset = chrset; + data[0].flags = flags; + data[0].fn = 0; + data[0].fs = 0; + data[0].gc = 0; + return 0; +} + +/* + * Lookup/cache a GC for the double-size character display. We save up to + * NUM_CHRSET values. + */ +GC +xterm_DoubleGC(unsigned chrset, unsigned flags, GC old_gc) +{ + XGCValues gcv; + register TScreen *screen = &term->screen; + unsigned long mask = (GCForeground | GCBackground | GCFont); + int n; + char *name; + XTermFonts *data; + + if ((name = xtermSpecialFont(screen, flags, chrset)) == 0) + return 0; + + n = xterm_Double_index(chrset, flags); + data = &(screen->double_fonts[n]); + if (data->fn != 0) { + if (!strcmp(data->fn, name)) { + if (data->fs != 0) { + XCopyGC(screen->display, old_gc, (unsigned long) (~GCFont), data->gc); + return data->gc; + } + } + discard_font(screen, data); + data->chrset = chrset; + data->flags = flags & BOLD; + } + data->fn = name; + + TRACE(("xterm_DoubleGC %s %d: %s\n", flags & BOLD ? "BOLD" : "NORM", n, name)); + + if ((data->fs = XLoadQueryFont(screen->display, name)) == 0) { + /* Retry with * in resolutions */ + char *nname = xtermSpecialFont(screen, flags | NORESOLUTION, chrset); + + if (!nname) + return 0; + if ((data->fs = XLoadQueryFont(screen->display, nname)) == 0) { + XtFree(nname); + return 0; + } + XtFree(name); + data->fn = nname; + } + + TRACE(("-> OK\n")); + + gcv.graphics_exposures = TRUE; /* default */ + gcv.font = data->fs->fid; + gcv.foreground = T_COLOR(screen, TEXT_FG); + gcv.background = T_COLOR(screen, TEXT_BG); + + data->gc = XCreateGC(screen->display, VWindow(screen), mask, &gcv); + XCopyGC(screen->display, old_gc, (unsigned long) (~GCFont), data->gc); + return data->gc; +} +#endif diff --git a/nx-X11/programs/xterm/error.h b/nx-X11/programs/xterm/error.h new file mode 100644 index 000000000..11e777f63 --- /dev/null +++ b/nx-X11/programs/xterm/error.h @@ -0,0 +1,90 @@ +/* + * $Xorg: error.h,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ + */ + + +/* $XFree86: xc/programs/xterm/error.h,v 1.8 2002/12/27 21:05:22 dickey 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_SPREALLOC 48 /* spawn: realloc of ttydev failed */ +#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_SREALLOC 92 /* ScreenResize: realloc() failed on alt base */ +#define ERROR_RESIZE 96 /* ScreenResize: malloc() or realloc() failed */ +#define ERROR_SAVE_PTR 102 /* ScrnPointers: malloc/realloc() failed */ + +/* scrollbar.c */ +#define ERROR_SBRALLOC 110 /* ScrollBarOn: realloc() failed on base */ +#define ERROR_SBRALLOC2 111 /* ScrollBarOn: realloc() failed on rows */ + +/* util.c */ +#define ERROR_MMALLOC 121 /* my_memmove: malloc/realloc failed */ diff --git a/nx-X11/programs/xterm/fontutils.c b/nx-X11/programs/xterm/fontutils.c new file mode 100644 index 000000000..fb4c6373c --- /dev/null +++ b/nx-X11/programs/xterm/fontutils.c @@ -0,0 +1,2371 @@ +/* $XTermId: fontutils.c,v 1.184 2005/11/03 13:17:27 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/fontutils.c,v 1.55 2005/11/03 13:17:27 dickey Exp $ + */ + +/************************************************************ + +Copyright 1998-2004,2005 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 +#include + +#include +#include +#include +#include +#include + +#include +#include + +/* 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(TScreen *, int); +#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; +} + +/* + * 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; + char *str; + + /* + * first get the full font name + */ + for (name = 0, i = 0, fp = fs->properties; + i < fs->n_properties; + i++, fp++) + if (fp->name == fontatom) + name = XGetAtomName(dpy, fp->card32); + + 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 (strlen(name) < MAX_FONTNAME - 1) { + strcpy(result, name); + } else { + TRACE(("fontname too large: %s\n", name)); + return 0; + } + } + + /* + * 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, unsigned next) +{ + unsigned last = (*result != 0) ? strlen(*result) : 0; + unsigned have = (*result != 0) ? ALLOCHUNK(last) : 0; + unsigned 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, 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, + char *use_weight, + int use_average_width, + 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; + char *weight; + int pixel_size; + int res_x; + int res_y; + + props = get_font_name_props(screen->display, screen->fnt_norm, (char *) 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(char *pattern, char *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 = char2lower(*pattern++); + int m = char2lower(*match++); + if (p != m) + return False; + } + } + return (*pattern == *match); /* both should be NUL */ +} + +/* + * 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, char *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) +{ + 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 xw->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 /* 'l' */ +#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 int +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 0; /* 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 0; + + 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(char *normal) +{ + static VTFontNames data; + memset(&data, 0, sizeof(data)); + data.f_n = normal; + return &data; +} + +static void +cache_menu_font_name(TScreen * screen, int fontnum, int which, const char *name) +{ + if (name != 0) { + char *last = 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); + } + } +} + +int +xtermLoadFont(XtermWidget xw, + const VTFontNames * fonts, + Bool doresize, + int fontnum) +{ + TScreen *screen = &(xw->screen); + + VTFontNames myfonts; + /* FIXME: use XFreeFontInfo */ + FontNameProperties *fp; + XFontStruct *nfs = NULL; + XFontStruct *bfs = NULL; +#if OPT_WIDE_CHARS + XFontStruct *wfs = NULL; + XFontStruct *wbfs = NULL; +#endif + XGCValues xgcv; + unsigned long mask; + GC new_normalGC = NULL; + GC new_normalboldGC = NULL; + GC new_reverseGC = NULL; + GC new_reverseboldGC = NULL; + Pixel new_normal; + Pixel new_revers; + char *tmpname = NULL; + char normal[MAX_FONTNAME]; + Bool proportional = False; + + memset(&myfonts, 0, sizeof(myfonts)); + if (fonts != 0) + myfonts = *fonts; + if (myfonts.f_n == 0) + return 0; + + if (fontnum == fontMenu_fontescape + && myfonts.f_n != screen->MenuFontName(fontnum)) { + if ((tmpname = x_strdup(myfonts.f_n)) == 0) + return 0; + } + + TRACE(("xtermLoadFont #%d normal %s\n", fontnum, NonNull(myfonts.f_n))); + TRACE(("xtermLoadFont #%d bold %s\n", fontnum, NonNull(myfonts.f_b))); +#if OPT_WIDE_CHARS + TRACE(("xtermLoadFont #%d wide %s\n", fontnum, NonNull(myfonts.f_w))); + TRACE(("xtermLoadFont #%d w/bold %s\n", fontnum, NonNull(myfonts.f_wb))); +#endif + + if (!(nfs = XLoadQueryFont(screen->display, myfonts.f_n))) + goto bad; + if (EmptyFont(nfs)) + goto bad; /* can't use a 0-sized font */ + + strcpy(normal, myfonts.f_n); + if (myfonts.f_b == 0) { + fp = get_font_name_props(screen->display, nfs, normal); + if (fp != 0) { + myfonts.f_b = bold_font_name(fp, fp->average_width); + if ((bfs = XLoadQueryFont(screen->display, myfonts.f_b)) == 0) { + myfonts.f_b = bold_font_name(fp, -1); + bfs = XLoadQueryFont(screen->display, myfonts.f_b); + } + TRACE(("...derived bold %s\n", myfonts.f_b)); + } + if (fp == 0 || bfs == 0) { + bfs = nfs; + TRACE(("...cannot load a matching bold font\n")); + } else if (same_font_size(xw, nfs, bfs) + && got_bold_font(screen->display, bfs, myfonts.f_b)) { + TRACE(("...got a matching bold font\n")); + cache_menu_font_name(screen, fontnum, fBold, myfonts.f_b); + } else { + XFreeFont(screen->display, bfs); + bfs = nfs; + TRACE(("...did not get a matching bold font\n")); + } + } else if ((bfs = XLoadQueryFont(screen->display, myfonts.f_b)) == 0) { + bfs = nfs; + TRACE(("...cannot load bold font %s\n", 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, { + char bold[MAX_FONTNAME]; + + if (myfonts.f_w != 0) { + cache_menu_font_name(screen, fontnum, fWide, myfonts.f_w); + } else if (!is_double_width_font(nfs)) { + fp = get_font_name_props(screen->display, nfs, normal); + if (fp != 0) { + myfonts.f_w = wide_font_name(fp); + TRACE(("...derived wide %s\n", myfonts.f_w)); + cache_menu_font_name(screen, fontnum, fWide, myfonts.f_w); + } + } + + if (myfonts.f_w) { + wfs = XLoadQueryFont(screen->display, myfonts.f_w); + } else { + wfs = nfs; + } + + if (myfonts.f_wb != 0) { + cache_menu_font_name(screen, fontnum, fWBold, myfonts.f_wb); + } else if (!is_double_width_font(bfs)) { + fp = get_font_name_props(screen->display, bfs, bold); + if (fp != 0) { + myfonts.f_wb = widebold_font_name(fp); + TRACE(("...derived wide/bold %s\n", myfonts.f_wb)); + cache_menu_font_name(screen, fontnum, fWBold, myfonts.f_wb); + } + } + + if (myfonts.f_wb) { + wbfs = XLoadQueryFont(screen->display, myfonts.f_wb); + } else if (is_double_width_font(bfs)) { + wbfs = bfs; + } else { + wbfs = wfs; + TRACE(("...cannot load wide bold font %s\n", myfonts.f_wb)); + } + + if (EmptyFont(wbfs)) + 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(bfs)) + goto bad; /* can't use a 0-sized font */ + + if (!same_font_size(xw, nfs, bfs) + && (is_fixed_font(nfs) && is_fixed_font(bfs))) { + TRACE(("...ignoring mismatched normal/bold fonts\n")); + XFreeFont(screen->display, bfs); + bfs = nfs; + } + + if_OPT_WIDE_CHARS(screen, { + if (wfs != 0 + && wbfs != 0 + && !same_font_size(xw, wfs, wbfs) + && (is_fixed_font(wfs) && is_fixed_font(wbfs))) { + TRACE(("...ignoring mismatched normal/bold wide fonts\n")); + XFreeFont(screen->display, wbfs); + wbfs = wfs; + } + }); + + /* + * Normal/bold fonts should be the same width. Also, the min/max + * values should be the same. + */ + if (!is_fixed_font(nfs) + || !is_fixed_font(bfs) + || nfs->max_bounds.width != bfs->max_bounds.width) { + TRACE(("Proportional font! normal %d/%d, bold %d/%d\n", + nfs->min_bounds.width, + nfs->max_bounds.width, + bfs->min_bounds.width, + bfs->max_bounds.width)); + proportional = True; + } + + if_OPT_WIDE_CHARS(screen, { + if (wfs != 0 + && wbfs != 0 + && (!is_fixed_font(wfs) + || !is_fixed_font(wbfs) + || wfs->max_bounds.width != wbfs->max_bounds.width)) { + TRACE(("Proportional font! wide %d/%d, wide bold %d/%d\n", + wfs->min_bounds.width, + wfs->max_bounds.width, + wbfs->min_bounds.width, + wbfs->max_bounds.width)); + proportional = True; + } + }); + + /* TODO : enforce that the width of the wide font is 2* the width + of the narrow font */ + + mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures | + GCFunction); + + new_normal = getXtermForeground(xw->flags, xw->cur_foreground); + new_revers = getXtermBackground(xw->flags, xw->cur_background); + + xgcv.font = nfs->fid; + xgcv.foreground = new_normal; + xgcv.background = new_revers; + xgcv.graphics_exposures = True; /* default */ + xgcv.function = GXcopy; + + new_normalGC = XtGetGC((Widget) xw, mask, &xgcv); + if (!new_normalGC) + goto bad; + + if (nfs == bfs) { /* there is no bold font */ + new_normalboldGC = new_normalGC; + } else { + xgcv.font = bfs->fid; + new_normalboldGC = XtGetGC((Widget) xw, mask, &xgcv); + if (!new_normalboldGC) + goto bad; + } + + xgcv.font = nfs->fid; + xgcv.foreground = new_revers; + xgcv.background = new_normal; + new_reverseGC = XtGetGC((Widget) xw, mask, &xgcv); + if (!new_reverseGC) + goto bad; + + if (nfs == bfs) { /* there is no bold font */ + new_reverseboldGC = new_reverseGC; + } else { + xgcv.font = bfs->fid; + new_reverseboldGC = XtGetGC((Widget) xw, mask, &xgcv); + if (!new_reverseboldGC) + goto bad; + } + + if (NormalGC(screen) != NormalBoldGC(screen)) + XtReleaseGC((Widget) xw, NormalBoldGC(screen)); + XtReleaseGC((Widget) xw, NormalGC(screen)); + + if (ReverseGC(screen) != ReverseBoldGC(screen)) + XtReleaseGC((Widget) xw, ReverseBoldGC(screen)); + XtReleaseGC((Widget) xw, ReverseGC(screen)); + + NormalGC(screen) = new_normalGC; + NormalBoldGC(screen) = new_normalboldGC; + ReverseGC(screen) = new_reverseGC; + ReverseBoldGC(screen) = new_reverseboldGC; + + /* + * 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. + */ + if (screen->fnt_bold != 0 + && screen->fnt_bold != screen->fnt_norm) + XFreeFont(screen->display, screen->fnt_bold); + if (screen->fnt_norm != 0) + XFreeFont(screen->display, screen->fnt_norm); + + screen->fnt_norm = nfs; + screen->fnt_bold = bfs; +#if OPT_WIDE_CHARS + screen->fnt_dwd = wfs; + if (wbfs == NULL) + wbfs = wfs; + screen->fnt_dwdb = wbfs; +#endif + screen->fnt_prop = proportional; + 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 (xtermMissingChar(xw, n, nfs)) { + TRACE(("missing normal char #%d\n", n)); + screen->fnt_boxes = False; + break; + } + if (xtermMissingChar(xw, n, bfs)) { + 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 + + screen->enbolden = screen->bold_mode + && ((nfs == bfs) || 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(screen->MenuFontName(fontnum)); + screen->MenuFontName(fontnum) = tmpname; + if (fontnum == fontMenu_fontescape) { + set_sensitivity(xw->screen.fontMenu, + fontMenuEntries[fontMenu_fontescape].widget, + True); + } +#if OPT_SHIFT_FONTS + screen->menu_font_sizes[fontnum] = FontSize(nfs); +#endif + } + set_cursor_gcs(screen); + xtermUpdateFontInfo(xw, doresize); + return 1; + + bad: + if (tmpname) + free(tmpname); + if (new_normalGC) + XtReleaseGC((Widget) xw, new_normalGC); + if (new_normalboldGC && new_normalGC != new_normalboldGC) + XtReleaseGC((Widget) xw, new_normalboldGC); + if (new_reverseGC) + XtReleaseGC((Widget) xw, new_reverseGC); + if (new_reverseboldGC && new_reverseGC != new_reverseboldGC) + XtReleaseGC((Widget) xw, new_reverseboldGC); + if (nfs) + XFreeFont(screen->display, nfs); + if (bfs && nfs != bfs) + XFreeFont(screen->display, bfs); +#if OPT_WIDE_CHARS + if (wfs) + XFreeFont(screen->display, wfs); + if (wbfs && wbfs != wfs) + XFreeFont(screen->display, wbfs); +#endif + 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; + char *menu_font_names[fontMenu_lastBuiltin + 1][fMAX]; +} SubResourceRec; + +#define MERGE_SUBFONT(src,dst,name) \ + if (dst.name == 0) { \ + 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_fontdefault; n <= fontMenu_lastBuiltin; ++n) { \ + for (m = 0; m < fMAX; ++m) { \ + dst.menu_font_names[n][m] = 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 w, char *myName, char *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; + + if (!initialized) { + + initialized = True; + TRACE(("xtermLoadVTFonts saving original\n")); + original.default_font = w->misc.default_font; + COPY_MENU_FONTS(w->screen, original); + } + + if (myName == 0 || *myName == 0) { + TRACE(("xtermLoadVTFonts restoring original\n")); + w->misc.default_font = original.default_font; + COPY_MENU_FONTS(original, w->screen); + for (n = 0; n < XtNumber(original.menu_font_names); ++n) + w->screen.MenuFontName(n) = original.MenuFontName(n); + } else { + TRACE(("xtermLoadVTFonts(%s, %s)\n", myName, myClass)); + + memset(&subresourceRec, 0, sizeof(subresourceRec)); + XtGetSubresources((Widget) w, (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(w->misc, subresourceRec, default_font.f_n); + MERGE_SUBFONT(w->misc, subresourceRec, default_font.f_b); +#if OPT_WIDE_CHARS + MERGE_SUBFONT(w->misc, subresourceRec, default_font.f_w); + MERGE_SUBFONT(w->misc, subresourceRec, default_font.f_wb); +#endif + for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; ++n) + MERGE_SUBFONT(w->screen, subresourceRec, MenuFontName(n)); + + /* + * Finally, copy the subresource data to the widget. + */ + w->misc.default_font = subresourceRec.default_font; + COPY_MENU_FONTS(subresourceRec, w->screen); + w->screen.MenuFontName(fontMenu_fontdefault) = w->misc.default_font.f_n; + } else { + TRACE(("...no resources found\n")); + status = False; + } + } + return status; +} + +#if OPT_WIDE_CHARS +static Bool +isWideFont(XFontStruct * fp, char *tag, Bool nullOk) +{ + Bool result = False; + + (void) tag; + if (fp != 0) { + unsigned count = 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; + } + TRACE(("isWideFont(%s) found %d cells\n", tag, count)); + result = (count > 256) ? True : False; + } else { + result = nullOk; + } + return result; +} + +static Bool +currentFontsAreWide(XtermWidget w, Bool nullOk) +{ + Bool result = True; + TScreen *screen = &(w->screen); + + result = (isWideFont(screen->fnt_norm, "normal", nullOk) + && isWideFont(screen->fnt_bold, "bold", nullOk) + && isWideFont(screen->fnt_dwd, "wide", nullOk) + && isWideFont(screen->fnt_dwdb, "wide-bold", nullOk)); + + TRACE(("currentFontsAreWide returns %d\n", result)); + 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 currentFontsAreWide(). + * + * 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 w, Bool nullOk) +{ + Bool result = currentFontsAreWide(w, nullOk); + + /* FIXME: add a test for wide-font */ + if (!result) { + result = xtermLoadVTFonts(w, "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 w) +{ + Bool result; + result = xtermLoadVTFonts(w, NULL, NULL); + TRACE(("xtermLoadDefaultFonts:%d\n", result)); + return result; +} +#endif /* OPT_LOAD_VTFONTS || OPT_WIDE_CHARS */ + +#if OPT_LOAD_VTFONTS +void +HandleLoadVTFonts(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *param_count GCC_UNUSED) +{ + static char empty[] = ""; /* appease strict compilers */ + + char buf[80]; + char *myName = (*param_count > 0) ? params[0] : empty; + char *convert = (*param_count > 1) ? params[1] : myName; + char *myClass = (char *) MyStackAlloc(strlen(convert), buf); + int n; + + TRACE(("HandleLoadVTFonts(%d)\n", *param_count)); + strcpy(myClass, convert); + if (*param_count == 1 + && islower(CharOf(myClass[0]))) + myClass[0] = toupper(CharOf(myClass[0])); + + if (xtermLoadVTFonts(term, 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 = term->screen.menu_font_number; + if (font_number > fontMenu_lastBuiltin) + font_number = fontMenu_lastBuiltin; + for (n = 0; n < NMENUFONTS; ++n) + term->screen.menu_font_sizes[n] = 0; + SetVTFont(term, font_number, True, + ((font_number == fontMenu_fontdefault) + ? &(term->misc.default_font) + : NULL)); + } + + MyStackFree(myClass, 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; + + vp = &VTbox[1]; + (vp++)->x = FontWidth(screen) - 1; + (vp++)->y = FontHeight(screen) - 1; + (vp++)->x = -(FontWidth(screen) - 1); + vp->y = -(FontHeight(screen) - 1); + screen->box = VTbox; +} + +#define CACHE_XFT(dst,src) if (src != 0) {\ + dst[fontnum] = src;\ + TRACE(("%s[%d] = %d (%d,%d) by %d\n",\ + #dst,\ + fontnum,\ + src->height,\ + src->ascent,\ + src->descent,\ + src->max_advance_width));\ + } + +#if OPT_RENDERFONT +static XftFont * +xtermOpenXft(Display * dpy, XftPattern * pat, const char *tag GCC_UNUSED) +{ + XftPattern *match; + XftResult status; + XftFont *result = 0; + + if (pat != 0) { + match = XftFontMatch(dpy, DefaultScreen(dpy), pat, &status); + result = XftFontOpenPattern(dpy, match); + if ((result == 0) && match) { + TRACE(("...did not match %s font\n", tag)); + XftPatternDestroy(match); + } else { + TRACE(("...matched %s font\n", tag)); + } + } + return result; +} +#endif + +/* + * Compute useful values for the font/window sizes + */ +void +xtermComputeFontInfo(XtermWidget xw, + struct _vtwin *win, + XFontStruct * font, + int sbwidth) +{ + TScreen *screen = &(xw->screen); + + int i, j, width, height; + +#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 (xw->misc.render_font && !IsIconWin(screen, win)) { + Display *dpy = screen->display; + int fontnum = screen->menu_font_number; + XftFont *norm = screen->renderFontNorm[fontnum]; + XftFont *bold = screen->renderFontBold[fontnum]; + XftFont *ital = screen->renderFontItal[fontnum]; +#if OPT_RENDERWIDE + XftFont *wnorm = screen->renderWideNorm[fontnum]; + XftFont *wbold = screen->renderWideBold[fontnum]; + XftFont *wital = screen->renderWideItal[fontnum]; +#endif + + if (norm == 0 && xw->misc.face_name) { + XftPattern *pat; + double face_size = xw->misc.face_size; + + TRACE(("xtermComputeFontInfo norm(face %s, size %f)\n", + xw->misc.face_name, + xw->misc.face_size)); + +#if OPT_SHIFT_FONTS + /* + * If the user is switching font-sizes, make it follow 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(screen, fontnum); + if (fontnum != fontMenu_fontdefault) { + int num = screen->menu_font_sizes[fontnum]; + int den = screen->menu_font_sizes[0]; + face_size = (1.0 * face_size * num) / den; + TRACE(("scaled using %d/%d -> %f\n", num, den, face_size)); + } +#endif + + pat = XftNameParse(xw->misc.face_name); + XftPatternBuild(pat, + XFT_FAMILY, XftTypeString, "mono", + XFT_SIZE, XftTypeDouble, face_size, + XFT_SPACING, XftTypeInteger, XFT_MONO, + (void *) 0); + norm = xtermOpenXft(dpy, pat, "normal"); + + if (norm != 0) { + XftPatternBuild(pat, + XFT_WEIGHT, XftTypeInteger, XFT_WEIGHT_BOLD, + XFT_CHAR_WIDTH, XftTypeInteger, norm->max_advance_width, + (void *) 0); + bold = xtermOpenXft(dpy, pat, "bold"); + +#if OPT_ISO_COLORS + if (screen->italicULMode) { + XftPatternBuild(pat, + XFT_SLANT, XftTypeInteger, XFT_SLANT_ITALIC, + XFT_CHAR_WIDTH, XftTypeInteger, norm->max_advance_width, + (void *) 0); + ital = xtermOpenXft(dpy, pat, "italic"); + } +#endif /* OPT_ISO_COLORS */ + + /* + * 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 " : "")); + } + } + + if (pat) + 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) { + char *face_name = (xw->misc.face_wide_name + ? xw->misc.face_wide_name + : xw->misc.face_name); + int char_width = norm->max_advance_width * 2; + + TRACE(("xtermComputeFontInfo wide(face %s, char_width %d)\n", + face_name, + char_width)); + + pat = XftNameParse(xw->misc.face_name); + XftPatternBuild(pat, + XFT_FAMILY, XftTypeString, face_name, + XFT_SIZE, XftTypeDouble, face_size, + XFT_SPACING, XftTypeInteger, XFT_MONO, + XFT_CHAR_WIDTH, XftTypeInteger, char_width, + (void *) 0); + wnorm = xtermOpenXft(dpy, pat, "wide"); + + if (wnorm != 0) { + XftPatternBuild(pat, + XFT_FAMILY, XftTypeString, face_name, + XFT_SIZE, XftTypeDouble, face_size, + XFT_SPACING, XftTypeInteger, XFT_MONO, + XFT_CHAR_WIDTH, XftTypeInteger, char_width, + XFT_WEIGHT, XftTypeInteger, XFT_WEIGHT_BOLD, + (void *) 0); + wbold = xtermOpenXft(dpy, pat, "wide-bold"); + + if (screen->italicULMode) { + XftPatternBuild(pat, + XFT_FAMILY, XftTypeString, face_name, + XFT_SIZE, XftTypeDouble, face_size, + XFT_SPACING, XftTypeInteger, XFT_MONO, + XFT_CHAR_WIDTH, XftTypeInteger, char_width, + XFT_SLANT, XftTypeInteger, XFT_SLANT_ITALIC, + (void *) 0); + wital = xtermOpenXft(dpy, pat, "wide-italic"); + } + } + + if (pat) + XftPatternDestroy(pat); + + CACHE_XFT(screen->renderWideNorm, wnorm); + CACHE_XFT(screen->renderWideBold, wbold); + CACHE_XFT(screen->renderWideItal, wital); + } +#endif + } + if (norm == 0) { + xw->misc.render_font = False; + update_font_renderfont(); + } else { + win->f_width = norm->max_advance_width; + win->f_height = norm->height; + win->f_ascent = norm->ascent; + win->f_descent = norm->descent; + if (win->f_height < win->f_ascent + win->f_descent) + win->f_height = win->f_ascent + win->f_descent; + if (is_double_width_font_xft(screen->display, norm)) + win->f_width >>= 1; + } + } + if (!xw->misc.render_font || IsIconWin(screen, win)) +#endif + { + if (is_double_width_font(font)) { + 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 = width; + win->fullheight = 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)); +} + +/* save this information as a side-effect for double-sized characters */ +void +xtermSaveFontInfo(TScreen * screen, XFontStruct * font) +{ + screen->fnt_wide = (font->max_bounds.width); + screen->fnt_high = (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 = &(xw->screen); + + int scrollbar_width; + struct _vtwin *win = &(screen->fullVwin); + + scrollbar_width = (xw->misc.scrollbar + ? (screen->scrollWidget->core.width + + screen->scrollWidget->core.border_width) + : 0); + xtermComputeFontInfo(xw, win, screen->fnt_norm, scrollbar_width); + xtermSaveFontInfo(screen, screen->fnt_norm); + + if (doresize) { + if (VWindow(screen)) { + XClearWindow(screen->display, VWindow(screen)); + } + TRACE(("xtermUpdateFontInfo {{\n")); + DoResizeScreen(xw); /* set to the new natural size */ + if (screen->scrollWidget) + ResizeScrollBar(xw); + Redraw(); + TRACE(("... }} xtermUpdateFontInfo\n")); +#ifdef SCROLLBAR_RIGHT + updateRightScrollbar(term); +#endif + } + xtermSetCursorBox(screen); +} + +#if OPT_BOX_CHARS + +/* + * Returns true if the given character is missing from the specified font. + */ +Bool +xtermMissingChar(XtermWidget xw, unsigned ch, XFontStruct * font) +{ + if (font != 0 + && font->per_char != 0 + && !font->all_chars_exist) { + static XCharStruct dft, *tmp = &dft, *pc = 0; + + if (font->max_byte1 == 0) { +#if OPT_WIDE_CHARS + if (ch > 255) { + TRACE(("xtermMissingChar %#04x (row)\n", ch)); + return True; + } +#endif + CI_GET_CHAR_INFO_1D(font, E2A(ch), tmp, pc); + } +#if OPT_WIDE_CHARS + else { + CI_GET_CHAR_INFO_2D(font, (ch >> 8), (ch & 0xff), tmp, pc); + } +#else + + if (!pc) + return False; /* Urgh! */ +#endif + + if (CI_NONEXISTCHAR(pc)) { + TRACE(("xtermMissingChar %#04x (!exists)\n", ch)); + return True; + } + } + if (ch < 32 + && xw->screen.force_box_chars) { + TRACE(("xtermMissingChar %#04x (forced off)\n", ch)); + return True; + } + return False; +} + +/* + * 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 * (font_width-1)) / (BOX_WIDE-1) +#define SCALE_Y(n) n = (n * (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) +{ + TScreen *screen = &(xw->screen); + /* *INDENT-OFF* */ + static const short glyph_ht[] = { + SEG( 0, 0, 0, 5*MID_HIGH/6), /* H */ + SEG(6*BOX_WIDE/10, 0, 6*BOX_WIDE/10,5*MID_HIGH/6), + SEG( 0, 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( 0, 0, 6*BOX_WIDE/10, 0), /* F */ + SEG( 0, 5*MID_HIGH/12,6*CHR_WIDE/12,5*MID_HIGH/12), + SEG( 0, 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( 0, 0, 0, 5*MID_HIGH/6), /* L */ + SEG( 0, 5*MID_HIGH/6, 6*BOX_WIDE/10,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_nl[] = { + SEG( 0, 5*MID_HIGH/6, 0, 0), /* N */ + SEG( 0, 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( 0, 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 */ + }; + + XGCValues values; + unsigned long mask; + GC gc2; + const short *p; + unsigned font_width = ((flags & DOUBLEWFONT) ? 2 : 1) * screen->fnt_wide; + unsigned font_height = ((flags & DOUBLEHFONT) ? 2 : 1) * screen->fnt_high; + +#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 + && !xtermMissingChar(xw, n, (flags & BOLD) + ? screen->fnt_bold + : screen->fnt_norm)) { + 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 (!XGetGCValues(screen->display, gc, GCBackground, &values)) + return; + + mask = GCForeground; + if (ch == 2) { + values.tile = + XmuCreateStippledPixmap(XtScreen((Widget) xw), + getXtermForeground(xw->flags, xw->cur_foreground), + getXtermBackground(xw->flags, xw->cur_background), + xw->core.depth); + if (values.stipple != XtUnspecifiedPixmap) { + mask |= GCBackground | GCTile | GCFillStyle; + values.fill_style = FillTiled; + } else { + ch = (unsigned) (~0); /* make this not match anything */ + } + } else { + values.foreground = values.background; + } + gc2 = XCreateGC(screen->display, + VWindow(screen), + mask, + &values); + + if (!(flags & NOBACKGROUND)) { + XFillRectangle(screen->display, VWindow(screen), gc2, x, y, + font_width, + font_height); + } + + XCopyGC(screen->display, gc, (1 << GCLastBit) - 1, gc2); + 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 = 3 * BOX_WIDE / 4; + points[1].y = MID_HIGH; + + points[2].x = points[0].x; + points[2].y = 3 * BOX_HIGH / 4; + + points[3].x = BOX_WIDE / 4; + 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 == 2) { /* box */ + XmuReleaseStippledPixmap(XtScreen((Widget) xw), values.tile); + } else if (ch == 7) { /* degrees */ + unsigned width = (BOX_WIDE / 3); + int x_coord = MID_WIDE - (width / 2); + int y_coord = MID_HIGH - 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 - (width / 3); + int y_coord = MID_HIGH - (width / 3); + + SCALE_X(x_coord); + SCALE_Y(y_coord); + SCALE_X(width); + + XFillArc(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); + } + + XFreeGC(screen->display, gc2); +} + +#if OPT_RENDERFONT && OPT_WIDE_CHARS + +/* + * 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) +{ + unsigned check = XftCharIndex(xw->screen.display, font, wc); + Bool result = False; + + if (check == 0) { + TRACE(("missingXft %d (%d)\n", wc, ucs2dec(wc))); + result = True; + } + return result; +} + +/* + * Check if the character corresponds to one of xterm's internal codes for + * line-drawing characters. That is only a subset of the 1-31 codes used for + * graphic characters. We want to know specifically about the line-drawing + * characters because the fonts used by Xft do not always give useful glyphs + * for line-drawing, and there is no reliable way to detect this. + */ +Bool +xtermIsLineDrawing(unsigned wc) +{ + Bool result; + switch (wc) { + case 0x0B: /* lower_right_corner */ + case 0x0C: /* upper_right_corner */ + case 0x0D: /* upper_left_corner */ + case 0x0E: /* lower_left_corner */ + case 0x0F: /* cross */ + case 0x10: /* scan_line_1 */ + case 0x11: /* scan_line_3 */ + case 0x12: /* scan_line_7 */ + case 0x13: /* scan_line_9 */ + case 0x14: /* horizontal_line */ + case 0x15: /* left_tee */ + case 0x16: /* right_tee */ + case 0x17: /* bottom_tee */ + case 0x18: /* top_tee */ + case 0x19: /* vertical_line */ + result = True; + TRACE(("xtermIsLineDrawing %d\n", wc)); + break; + default: + result = False; + break; + } + 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 (ch < 32) { + 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 XFontStruct * +xtermFindFont(TScreen * screen, int fontnum) +{ + XFontStruct *nfs = 0; + char *name; + + if ((name = screen->MenuFontName(fontnum)) != 0 + && (nfs = XLoadQueryFont(screen->display, name)) != 0) { + if (EmptyFont(nfs)) { + XFreeFont(screen->display, nfs); + nfs = 0; + } + } + return nfs; +} + +static void +lookupOneFontSize(TScreen * screen, int fontnum) +{ + if (screen->menu_font_sizes[fontnum] == 0) { + XFontStruct *fs = xtermFindFont(screen, fontnum); + screen->menu_font_sizes[fontnum] = -1; + if (fs != 0) { + screen->menu_font_sizes[fontnum] = FontSize(fs); + TRACE(("menu_font_sizes[%d] = %ld\n", fontnum, + screen->menu_font_sizes[fontnum])); + XFreeFont(screen->display, fs); + } + } +} + +/* + * Cache the font-sizes so subsequent larger/smaller font actions will go fast. + */ +static void +lookupFontSizes(TScreen * screen) +{ + int n; + + for (n = 0; n < NMENUFONTS; n++) { + lookupOneFontSize(screen, n); + } +} + +/* + * Find the index of a larger/smaller font (according to the sign of 'relative' + * and its magnitude), starting from the 'old' index. + */ +int +lookupRelativeFontSize(TScreen * screen, int old, int relative) +{ + int n, m = -1; + + if (!IsIcon(screen)) { + lookupFontSizes(screen); + 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; + } + } + } + if (m >= 0) { + if (relative > 1) + m = lookupRelativeFontSize(screen, m, relative - 1); + else if (relative < -1) + m = lookupRelativeFontSize(screen, 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) +{ + if (term->misc.shift_fonts) { + TScreen *screen = &term->screen; + int m; + + m = lookupRelativeFontSize(screen, screen->menu_font_number, 1); + if (m >= 0) { + SetVTFont(term, m, True, NULL); + } else { + Bell(XkbBI_MinorError, 0); + } + } +} + +/* ARGSUSED */ +void +HandleSmallerFont(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *param_count GCC_UNUSED) +{ + if (term->misc.shift_fonts) { + TScreen *screen = &term->screen; + int m; + + m = lookupRelativeFontSize(screen, screen->menu_font_number, -1); + if (m >= 0) { + SetVTFont(term, m, True, NULL); + } else { + Bell(XkbBI_MinorError, 0); + } + } +} +#endif + +/* ARGSUSED */ +void +HandleSetFont(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + int fontnum; + VTFontNames fonts; + + memset(&fonts, 0, sizeof(fonts)); + + if (*param_count == 0) { + fontnum = fontMenu_fontdefault; + } else { + Cardinal maxparams = 1; /* total number of params allowed */ + + switch (params[0][0]) { + case 'd': + case 'D': + case '0': + fontnum = fontMenu_fontdefault; + 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; +#if OPT_WIDE_CHARS + maxparams = 5; +#else + maxparams = 3; +#endif + break; + case 's': + case 'S': + fontnum = fontMenu_fontsel; + maxparams = 2; + break; + default: + Bell(XkbBI_MinorError, 0); + return; + } + if (*param_count > maxparams) { /* see if extra args given */ + Bell(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(term, fontnum, True, &fonts); +} + +void +SetVTFont(XtermWidget xw, + int which, + Bool doresize, + const VTFontNames * fonts) +{ + TScreen *screen = &xw->screen; + + TRACE(("SetVTFont(which=%d, f_n=%s, f_b=%s)\n", which, + (fonts && fonts->f_n) ? fonts->f_n : "", + (fonts && fonts->f_b) ? fonts->f_b : "")); + + if (IsIcon(screen)) { + Bell(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(myfonts.f_n, False); + return; + } else { + if (myfonts.f_n == 0) { + myfonts.f_n = screen->MenuFontName(which); + TRACE(("set myfonts.f_n from menu_font_names[%d][fNorm] %s\n", + which, NonNull(myfonts.f_n))); + } + if (myfonts.f_b == 0) { + myfonts.f_b = screen->menu_font_names[which][fBold]; + TRACE(("set myfonts.f_b from menu_font_names[%d][fBold] %s\n", + which, NonNull(myfonts.f_b))); + } +#if OPT_WIDE_CHARS + if (myfonts.f_w == 0) { + myfonts.f_w = screen->menu_font_names[which][fWide]; + TRACE(("set myfonts.f_w from menu_font_names[%d][fWide] %s\n", + which, NonNull(myfonts.f_w))); + } + if (myfonts.f_wb == 0) { + myfonts.f_wb = screen->menu_font_names[which][fWBold]; + TRACE(("set myfonts.f_wb from menu_font_names[%d][fWBold] %s\n", + which, NonNull(myfonts.f_wb))); + } +#endif + if (xtermLoadFont(xw, + &myfonts, + doresize, which)) { + return; + } + } + } + + Bell(XkbBI_MinorError, 0); + return; +} diff --git a/nx-X11/programs/xterm/fontutils.h b/nx-X11/programs/xterm/fontutils.h new file mode 100644 index 000000000..536e707b0 --- /dev/null +++ b/nx-X11/programs/xterm/fontutils.h @@ -0,0 +1,89 @@ +/* + * $XFree86: xc/programs/xterm/fontutils.h,v 1.16 2005/08/05 01:25:39 dickey Exp $ + */ + +/************************************************************ + +Copyright 1998-2004,2005 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 + +extern Bool xtermLoadDefaultFonts (XtermWidget w); +extern const VTFontNames * xtermFontName(char *normal); +extern int lookupRelativeFontSize(TScreen * screen, int old, int relative); +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 xtermComputeFontInfo (XtermWidget xw, struct _vtwin *win, XFontStruct *font, int sbwidth); +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 +extern Bool xtermMissingChar(XtermWidget xw, unsigned ch, XFontStruct *font); +extern void xtermDrawBoxChar(XtermWidget xw, unsigned ch, unsigned flags, GC gc, int x, int y); +#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 && OPT_WIDE_CHARS +extern Bool xtermIsLineDrawing(unsigned /* wc */); +extern Bool xtermXftMissing(XtermWidget /* xw */, XftFont * /* font */, unsigned /* wc */); +#endif + +#if OPT_SHIFT_FONTS +extern void HandleSmallerFont PROTO_XT_ACTIONS_ARGS; +extern void HandleLargerFont PROTO_XT_ACTIONS_ARGS; +#endif + +#if OPT_WIDE_CHARS +extern unsigned ucs2dec(unsigned); +extern unsigned dec2ucs(unsigned); +#endif + +#endif /* included_fontutils_h */ diff --git a/nx-X11/programs/xterm/gen-pc-fkeys.pl b/nx-X11/programs/xterm/gen-pc-fkeys.pl new file mode 100755 index 000000000..c7ba80268 --- /dev/null +++ b/nx-X11/programs/xterm/gen-pc-fkeys.pl @@ -0,0 +1,98 @@ +#! /usr/bin/perl -w +# Author: Thomas E. Dickey +# $XTermId: gen-pc-fkeys.pl,v 1.5 2005/04/03 16:58:29 tom Exp $ +# $XFree86: xc/programs/xterm/gen-pc-fkeys.pl,v 1.2 2005/03/29 04:00:32 tsi Exp $ +# +# Construct a list of function-key definitions corresponding to xterm's +# Sun/PC keyboard. This uses infocmp to obtain the strings to modify (and +# verify). +use strict; + +my(@old_keys); +my($min_fkeys,$max_fkeys,$max_modifier,$modify_opt,$terminfo); + +$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) +$modify_opt=2; # xterm's modifyCursorKeys resource +$terminfo="xterm-new"; # the terminfo entry to use + +my($cur_modifier, $cur_fkey); + +# apply the given modifier to the terminfo string, return the result +sub modify_it { + my $code = $_[0]; + my $text = $_[1]; + if ($code != 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; + } + $text = $piece . $code . $final; + } + return $text; +} + +# compute the next modifier value +sub next_modifier { + my $code = $_[0]; + my $mask = $code - 1; + if ($mask == 0) { + $mask = 1; + } elsif ($mask == 1) { + $mask = 4; + } elsif ($mask == 2) { + $mask = 3; # FIXME + } elsif ($mask == 4) { + $mask = 5; + } elsif ($mask == 5) { + $mask = 2; + } + # printf ("# next_modifier(%d) = %d\n", $code, $mask + 1); + return $mask + 1; +} + +# Read the terminfo entry's list of function keys $old_keys[]. +# We could handle $old_keys[0], but choose to start numbering from 1. +sub readterm() { + my($key,$n,$str); + my(@list) = `infocmp -1 $terminfo`; + for $n (0..$#list) { + chop $list[$n]; + $list[$n] =~ s/^[[:space:]]//; + if ( $list[$n] =~ /^kf[[:digit:]]+=/ ) { + $key = $list[$n]; + $key =~ s/^kf//; + $key =~ s/=.*//; + $str = $list[$n]; + $str =~ s/^kf[[:digit:]]+=//; + $str =~ s/,[[:space:]]*$//; + # printf "$n:%s(%d)(%s)\n", $list[$n], $key, $str; + $old_keys[$key] = $str; + } + } + # printf ("last index:%d\n", $#old_keys); +} + +readterm(); + +# 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. +printf "xterm+pcfkeys|fragment for PC-style keys, \n"; +for ($cur_fkey = 1, $cur_modifier = 1; $cur_fkey < $max_fkeys; ++$cur_fkey) { + my $index = (($cur_fkey - 1) % $min_fkeys); + if ($index == 0 && $cur_fkey != 1) { + $cur_modifier = next_modifier($cur_modifier); + } + my $input = $old_keys[$index + 1]; + my $result = modify_it($cur_modifier,$input); + printf "\tkf%d=%s, \n", $cur_fkey, $result; + if (defined $old_keys[$cur_fkey]) { + if ($old_keys[$cur_fkey] ne $result) { + printf "# diff %s\n", $old_keys[$cur_fkey]; + } + } +} diff --git a/nx-X11/programs/xterm/input.c b/nx-X11/programs/xterm/input.c new file mode 100644 index 000000000..2e93686a9 --- /dev/null +++ b/nx-X11/programs/xterm/input.c @@ -0,0 +1,1259 @@ +/* $XTermId: input.c,v 1.174 2005/09/18 23:48:12 tom Exp $ */ + +/* + * $Xorg: input.c,v 1.3 2000/08/17 19:55:08 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/input.c,v 3.73 2005/09/18 23:48:12 dickey Exp $ */ + +/* + * Copyright 1999-2004,2005 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 + +#include + +#ifdef VMS +#include +#endif + +#if HAVE_X11_DECKEYSYM_H +#include +#endif + +#if HAVE_X11_SUNKEYSYM_H +#include +#endif + +#include +#include + +#include + +#include +#include + +#define MAP(from, to) case from: return(to) + +#define KEYSYM_FMT "0x%04lX" /* simplify matching */ + +/* 0123456789 abc def0123456789abcdef0123456789abcdef0123456789abcd */ +static char *kypd_num = " XXXXXXXX\tXXX\rXXXxxxxXXXXXXXXXXXXXXXXXXXXX*+,-./0123456789XXX="; + +/* 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcd */ +static char *kypd_apl = " ABCDEFGHIJKLMNOPQRSTUVWXYZ??????abcdefghijklmnopqrstuvwxyzXXX"; + +static char *curfinal = "HDACB FE"; + +static int decfuncvalue(KeySym keycode); +static int sunfuncvalue(KeySym keycode); +#if OPT_HP_FUNC_KEYS +static int hpfuncvalue(KeySym keycode); +#endif +#if OPT_SCO_FUNC_KEYS +static int scofuncvalue(KeySym keycode); +#endif + +#if OPT_TRACE +static char * +ModifierName(unsigned modifier) +{ + 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; +} +#endif + +static void +AdjustAfterInput(TScreen * screen) +{ + if (screen->scrollkey && screen->topline != 0) + WindowScroll(screen, 0); + 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(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; + } +} + +/* returns true if the key is on the editing keypad */ +static Bool +IsEditFunctionKey(KeySym keysym) +{ + switch (keysym) { + case XK_Prior: + case XK_Next: + case XK_Insert: + case XK_Find: + case XK_Select: +#ifdef DXK_Remove + case DXK_Remove: +#endif +#ifdef XK_KP_Delete + case XK_KP_Delete: + case XK_KP_Insert: +#endif +#ifdef XK_ISO_Left_Tab + case XK_ISO_Left_Tab: +#endif + return True; + default: + return False; + } +} + +#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 + +/* + * Modifiers other than shift, control and numlock should be reserved for the + * user. We use the first two explicitly to support VT220 keyboard, and the + * third is used implicitly in keyboard configuration to make the keypad work. + */ +#define isModified(event) \ + (event->state & \ + (Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask )) + +#define VT52_KEYPAD \ + if_OPT_VT52_MODE(screen,{ \ + reply.a_type = ESC; \ + reply.a_pintro = '?'; \ + }) + +#define VT52_CURSOR_KEYS \ + if_OPT_VT52_MODE(screen,{ \ + reply.a_type = ESC; \ + }) + +#define APPEND_PARM(number) \ + reply.a_param[(int) reply.a_nparam] = number, \ + reply.a_nparam += 1 + +#if OPT_MOD_FKEYS +#define MODIFIER_PARM \ + if (modify_parm > 1) 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(void) +{ + TScreen *screen = &term->screen; + Bool result = True; + + if (term->keyboard.type == keyboardIsDefault + || term->keyboard.type == keyboardIsVT220) + result = (screen->delete_is_del == True); + + if (term->keyboard.type == keyboardIsLegacy) + result = (screen->delete_is_del != False); + + TRACE(("xtermDeleteIsDEL(%d/%d) = %d\n", + term->keyboard.type, + screen->delete_is_del, + result)); + + return result; +} + +void +Input(TKeyboard * keyboard, + TScreen * screen, + XKeyEvent * event, + Bool eightbit) +{ + +#define STRBUFSIZE 500 + + char strbuf[STRBUFSIZE]; + Char *string; + int key = False; + int pty = screen->respond; + int nbytes; + KeySym keysym = 0; + ANSI reply; + int dec_code; + short modify_parm = 0; + int keypad_mode = ((keyboard->flags & MODE_DECKPAM) != 0); + + /* Ignore characters typed at the keyboard */ + if (keyboard->flags & MODE_KAM) + return; + +#if OPT_TCAP_QUERY + if (screen->tc_query >= 0) { + keysym = screen->tc_query; + if (keysym != XK_BackSpace) { + nbytes = 0; + strbuf[0] = 0; + } else { + nbytes = 1; + strbuf[0] = 8; + } + } else +#endif +#if OPT_I18N_SUPPORT + if (screen->xic) { + Status status_return; +#if OPT_WIDE_CHARS + if (screen->utf8_mode) + nbytes = Xutf8LookupString(screen->xic, event, + strbuf, sizeof(strbuf), + &keysym, &status_return); + else +#endif + nbytes = XmbLookupString(screen->xic, event, + strbuf, sizeof(strbuf), + &keysym, &status_return); + } else +#endif + { + static XComposeStatus compose_status = + {NULL, 0}; + nbytes = XLookupString(event, strbuf, sizeof(strbuf), + &keysym, &compose_status); + } + + string = (Char *) & strbuf[0]; + reply.a_pintro = 0; + reply.a_final = 0; + reply.a_nparam = 0; + reply.a_inters = 0; + + TRACE(("Input keysym " + KEYSYM_FMT + ", %d:'%.*s'%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + keysym, + nbytes, + nbytes > 0 ? nbytes : 1, + nbytes > 0 ? strbuf : "", + ModifierName(event->state & ShiftMask), + ModifierName(event->state & LockMask), + ModifierName(event->state & ControlMask), + ModifierName(event->state & Mod1Mask), + ModifierName(event->state & Mod2Mask), + ModifierName(event->state & Mod3Mask), + ModifierName(event->state & Mod4Mask), + ModifierName(event->state & Mod5Mask), + eightbit ? " 8bit" : " 7bit", + IsKeypadKey(keysym) ? " KeypadKey" : "", + IsCursorKey(keysym) ? " CursorKey" : "", + IsPFKey(keysym) ? " PFKey" : "", + IsFunctionKey(keysym) ? " FKey" : "", + IsMiscFunctionKey(keysym) ? " MiscFKey" : "", + IsEditFunctionKey(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 + && (event->state & ShiftMask) == 0) { + if (keysym == XK_KP_Add) { + keysym = XK_KP_Separator; + TRACE(("...Input keypad(+), change keysym to " + KEYSYM_FMT + "\n", + keysym)); + } + if ((event->state & ControlMask) != 0 + && keysym == XK_KP_Separator) { + keysym = XK_KP_Subtract; + TRACE(("...Input control/keypad(,), change keysym to " + KEYSYM_FMT + "\n", + 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 (nbytes == 1 + && IsKeypadKey(keysym) + && term->misc.real_NumLock + && (term->misc.num_lock & event->state) != 0) { + keypad_mode = 0; + TRACE(("...Input num_lock, force keypad_mode off\n")); + } +#endif + +#if OPT_MOD_FKEYS + /* + * If we are in the normal (possibly Sun/PC) keyboard state, allow + * modifiers to add a parameter to the function-key control sequences. + */ + if (event->state != 0 + && !(IsKeypadKey(keysym) && keypad_mode) +#if OPT_SUNPC_KBD + && keyboard->type != keyboardIsVT220 +#endif +#if OPT_VT52_MODE + && screen->vtXX_level != 0 +#endif + ) { +/* +* 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) +*/ +#define UNMOD 1 +#define SHIFT 1 +#define ALT 2 +#define CTRL 4 +#define META 8 + modify_parm = UNMOD; + if (event->state & ShiftMask) { + modify_parm += SHIFT; + } + if (event->state & ControlMask) { + modify_parm += CTRL; + } +#if OPT_NUM_LOCK + if ((term->misc.alwaysUseMods + || term->misc.real_NumLock) + && ((event->state & term->misc.alt_left) != 0 + || (event->state & term->misc.alt_right)) != 0) { + modify_parm += ALT; + } + if (term->misc.alwaysUseMods + && ((event->state & term->misc.meta_left) != 0 + || (event->state & term->misc.meta_right)) != 0) { + modify_parm += META; + } +#endif + TRACE(("...ModifierParm %d\n", modify_parm)); + } +#endif /* OPT_MOD_FKEYS */ + + /* VT300 & up: backarrow toggle */ + if ((nbytes == 1) + && (((keyboard->flags & MODE_DECBKM) == 0) + ^ ((event->state & ControlMask) != 0)) + && (keysym == XK_BackSpace)) { + strbuf[0] = '\177'; + TRACE(("...Input backarrow changed to %d\n", *strbuf)); + } +#if OPT_SUNPC_KBD + /* make an DEC editing-keypad from a Sun or PC editing-keypad */ + if (keyboard->type == keyboardIsVT220 + && (keysym != XK_Delete || !xtermDeleteIsDEL())) + keysym = TranslateFromSUNPC(keysym); + else +#endif + { +#ifdef XK_KP_Home + if (keysym >= XK_KP_Home && keysym <= XK_KP_Begin) { + TRACE(("...Input keypad before was " KEYSYM_FMT "\n", keysym)); + keysym += XK_Home - XK_KP_Home; + TRACE(("...Input keypad changed to " KEYSYM_FMT "\n", keysym)); + } +#endif + } + +#if OPT_HP_FUNC_KEYS + if (keyboard->type == keyboardIsHP + && (reply.a_final = hpfuncvalue(keysym)) != 0) { + reply.a_type = ESC; + MODIFIER_PARM; + unparseseq(&reply, pty); + } else +#endif +#if OPT_SCO_FUNC_KEYS + if (keyboard->type == keyboardIsSCO + && (reply.a_final = scofuncvalue(keysym)) != 0) { + reply.a_type = CSI; + MODIFIER_PARM; + unparseseq(&reply, pty); + } else +#endif + if (IsPFKey(keysym)) { + reply.a_type = SS3; + reply.a_final = keysym - XK_KP_F1 + 'P'; + VT52_CURSOR_KEYS; + MODIFIER_PARM; + unparseseq(&reply, pty); + key = True; +#if 0 /* OPT_SUNPC_KBD should suppress - but only for vt220 compatibility */ + } else if (keyboard->type == keyboardIsVT220 + && screen->vtXX_level <= 1 + && IsEditFunctionKey(keysym)) { + key = False; /* ignore editing-keypad in vt100 mode */ +#endif + } else if (IsCursorKey(keysym) && + keysym != XK_Prior && keysym != XK_Next) { + if (keyboard->flags & MODE_DECCKM) { + reply.a_type = SS3; + } else { + reply.a_type = CSI; + } +#if OPT_MOD_FKEYS + if (modify_parm > 1) { + if (keyboard->modify_cursor_keys) + reply.a_type = CSI; /* SS3 should not have params */ + if (keyboard->modify_cursor_keys > 1) + APPEND_PARM(1); /* force modifier to 2nd param */ + if (keyboard->modify_cursor_keys > 2) + reply.a_pintro = '>'; /* mark this as "private" */ + } +#endif + reply.a_final = curfinal[keysym - XK_Home]; + VT52_CURSOR_KEYS; + MODIFIER_PARM; + unparseseq(&reply, pty); + key = True; + } else if (IsFunctionKey(keysym) + || IsMiscFunctionKey(keysym) + || IsEditFunctionKey(keysym) +#ifdef SunXK_F36 + || keysym == SunXK_F36 + || keysym == SunXK_F37 +#endif + || (keysym == XK_Delete + && ((modify_parm > 1) + || !xtermDeleteIsDEL()))) { +#if OPT_SUNPC_KBD + if (keyboard->type == keyboardIsVT220) { + if ((event->state & ControlMask) + && (keysym >= XK_F1 && keysym <= XK_F12)) + keysym += term->misc.ctrl_fkeys; + } +#endif + + dec_code = decfuncvalue(keysym); + if ((event->state & ShiftMask) +#if OPT_SUNPC_KBD + && keyboard->type == keyboardIsVT220 +#endif + && ((string = (Char *) udk_lookup(dec_code, &nbytes)) != 0)) { + while (nbytes-- > 0) + unparseputc(*string++, pty); + } +#if OPT_VT52_MODE + /* + * Interpret F1-F4 as PF1-PF4 for VT52, VT100 + */ + else if (keyboard->type != keyboardIsSun + && keyboard->type != keyboardIsLegacy + && (dec_code >= 11 && dec_code <= 14)) { + reply.a_type = SS3; + VT52_CURSOR_KEYS; + reply.a_final = A2E(dec_code - 11 + E2A('P')); + MODIFIER_PARM; + unparseseq(&reply, pty); + } +#endif + else { + reply.a_type = CSI; + reply.a_nparam = 1; + reply.a_final = 0; + MODIFIER_PARM; + if (keyboard->type == keyboardIsSun) { + reply.a_param[0] = sunfuncvalue(keysym); + reply.a_final = 'z'; +#ifdef XK_ISO_Left_Tab + } else if (keysym == XK_ISO_Left_Tab) { + reply.a_nparam = 0; + reply.a_final = 'Z'; +#endif + } else { + reply.a_param[0] = dec_code; + reply.a_final = '~'; + } + if (reply.a_final != 0 + && (reply.a_nparam == 0 || reply.a_param[0] >= 0)) + unparseseq(&reply, pty); + } + key = True; + } else if (IsKeypadKey(keysym)) { + if (keypad_mode) { + reply.a_type = SS3; + reply.a_final = kypd_apl[keysym - XK_KP_Space]; + VT52_KEYPAD; + MODIFIER_PARM; + unparseseq(&reply, pty); + } else { + unparseputc(kypd_num[keysym - XK_KP_Space], pty); + } + key = True; + } else if (nbytes > 0) { +#if OPT_TEK4014 + if (screen->TekGIN) { + TekEnqMouse(*string++); + TekGINoff(); + nbytes--; + } +#endif + if (nbytes == 1) { +#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 (screen->meta_sends_esc + && ((event->state & term->misc.meta_left) != 0 + || (event->state & term->misc.meta_right) != 0)) { + TRACE(("...input-char is modified by META\n")); + eightbit = False; + unparseputc(ESC, pty); /* escape */ + } +#endif + if (eightbit && screen->input_eight_bits) { + IChar ch = CharOf(*string); + if (ch < 128) { + *string |= 0x80; + TRACE(("...input shift from %d to %d (%#x to %#x)\n", + ch, CharOf(*string), + ch, CharOf(*string))); +#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(*string); + nbytes = 2; + string[0] = 0xc0 | ((ch >> 6) & 0x3); + string[1] = 0x80 | (ch & 0x3f); + TRACE(("...encoded %#x in UTF-8 as %#x,%#x\n", + ch, string[0], string[1])); + } +#endif + } + eightbit = False; + } + /* VT220 & up: National Replacement Characters */ + if ((term->flags & NATIONAL) != 0) { + int cmp = xtermCharSetIn(CharOf(*string), + screen->keyboard_dialect[0]); + TRACE(("...input NRC %d, %s %d\n", + CharOf(*string), + (CharOf(*string) == cmp) + ? "unchanged" + : "changed to", + CharOf(cmp))); + *string = cmp; + } else if (eightbit) { + unparseputc(ESC, pty); /* escape */ + } else if (*string == '?' + && (event->state & ControlMask) != 0) { + *string = 127; + } + } + while (nbytes-- > 0) + unparseputc(*string++, pty); + key = True; + } + if (key && !TEK4014_ACTIVE(screen)) + AdjustAfterInput(screen); +#ifdef ENABLE_PRINT + if (keysym == XK_F2) + TekPrint(); +#endif + return; +} + +void +StringInput(TScreen * screen, Char * string, size_t nbytes) +{ + int pty = screen->respond; + + TRACE(("InputString (%s,%d)\n", + visibleChars(PAIRED_CHARS(string, 0), nbytes), + nbytes)); +#if OPT_TEK4014 + if (nbytes && screen->TekGIN) { + TekEnqMouse(*string++); + TekGINoff(); + nbytes--; + } +#endif + while (nbytes-- != 0) + unparseputc(*string++, pty); + if (!TEK4014_ACTIVE(screen)) + AdjustAfterInput(screen); +} + +/* These definitions are DEC-style (e.g., vt320) */ +static int +decfuncvalue(KeySym keycode) +{ + switch (keycode) { + MAP(XK_F1, 11); + MAP(XK_F2, 12); + MAP(XK_F3, 13); + MAP(XK_F4, 14); + MAP(XK_F5, 15); + MAP(XK_F6, 17); + MAP(XK_F7, 18); + MAP(XK_F8, 19); + MAP(XK_F9, 20); + MAP(XK_F10, 21); + MAP(XK_F11, 23); + MAP(XK_F12, 24); + MAP(XK_F13, 25); + MAP(XK_F14, 26); + MAP(XK_F15, 28); + MAP(XK_Help, 28); + MAP(XK_F16, 29); + MAP(XK_Menu, 29); + MAP(XK_F17, 31); + MAP(XK_F18, 32); + MAP(XK_F19, 33); + MAP(XK_F20, 34); +#if defined(XK_F21) + MAP(XK_F21, 42); + MAP(XK_F22, 43); + MAP(XK_F23, 44); + MAP(XK_F24, 45); + MAP(XK_F25, 46); + MAP(XK_F26, 47); + MAP(XK_F27, 48); + MAP(XK_F28, 49); + MAP(XK_F29, 50); + MAP(XK_F30, 51); + MAP(XK_F31, 52); + MAP(XK_F32, 53); + MAP(XK_F33, 54); + MAP(XK_F34, 55); + MAP(XK_F35, 56); +#endif +#ifdef SunXK_F36 + MAP(SunXK_F36, 57); + MAP(SunXK_F37, 58); +#endif + 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 + default: + return (-1); + } +} + +#if OPT_HP_FUNC_KEYS +static int +hpfuncvalue(KeySym keycode) +{ + switch (keycode) { + 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'); + MAP(XK_F1, 'p'); + MAP(XK_F2, 'q'); + MAP(XK_F3, 'r'); + MAP(XK_F4, 's'); + MAP(XK_F5, 't'); + MAP(XK_F6, 'u'); + MAP(XK_F7, 'v'); + MAP(XK_F8, 'w'); +#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: + return 0; + } +} +#endif + +#if OPT_SCO_FUNC_KEYS +static int +scofuncvalue(KeySym keycode) +{ + switch (keycode) { + MAP(XK_Up, 'A'); + MAP(XK_Down, 'B'); + MAP(XK_Right, 'C'); + MAP(XK_Left, 'D'); + MAP(XK_End, 'F'); + MAP(XK_Insert, 'L'); + MAP(XK_Next, 'G'); + MAP(XK_Prior, 'I'); + MAP(XK_Home, 'H'); + MAP(XK_F1, 'M'); + MAP(XK_F2, 'N'); + MAP(XK_F3, 'O'); + MAP(XK_F4, 'P'); + MAP(XK_F5, 'Q'); + MAP(XK_F6, 'R'); + MAP(XK_F7, 'S'); + MAP(XK_F8, 'T'); + MAP(XK_F9, 'U'); + MAP(XK_F10, 'V'); + MAP(XK_F11, 'W'); + MAP(XK_F12, 'X'); + MAP(XK_F13, 'Y'); + MAP(XK_F15, 'a'); + MAP(XK_F16, 'b'); + MAP(XK_F17, 'c'); + MAP(XK_F18, 'd'); + MAP(XK_F19, 'e'); + MAP(XK_F20, 'f'); +#if defined(XK_F21) + MAP(XK_F21, 'g'); + MAP(XK_F22, 'h'); + MAP(XK_F23, 'i'); + MAP(XK_F24, 'j'); + MAP(XK_F25, 'k'); + MAP(XK_F26, 'l'); + MAP(XK_F27, 'm'); + MAP(XK_F28, 'n'); + MAP(XK_F29, 'o'); + MAP(XK_F30, 'p'); + MAP(XK_F31, 'q'); + MAP(XK_F32, 'r'); + MAP(XK_F33, 's'); + MAP(XK_F34, 't'); + MAP(XK_F35, 'u'); +#endif +#ifdef XK_KP_Insert + MAP(XK_KP_Insert, 'L'); +#endif + default: + return 0; + } +} +#endif + +static int +sunfuncvalue(KeySym keycode) +{ + switch (keycode) { + MAP(XK_F1, 224); + MAP(XK_F2, 225); + MAP(XK_F3, 226); + MAP(XK_F4, 227); + MAP(XK_F5, 228); + MAP(XK_F6, 229); + MAP(XK_F7, 230); + MAP(XK_F8, 231); + MAP(XK_F9, 232); + MAP(XK_F10, 233); + MAP(XK_F11, 192); + MAP(XK_F12, 193); + MAP(XK_F13, 194); + MAP(XK_F14, 195); /* kund */ + MAP(XK_F15, 196); + MAP(XK_Help, 196); /* khlp */ + MAP(XK_F16, 197); /* kcpy */ + MAP(XK_Menu, 197); + MAP(XK_F17, 198); + MAP(XK_F18, 199); + MAP(XK_F19, 200); /* kfnd */ + MAP(XK_F20, 201); + + MAP(XK_R1, 208); /* kf31 */ + MAP(XK_R2, 209); /* kf32 */ + MAP(XK_R3, 210); /* kf33 */ + MAP(XK_R4, 211); /* kf34 */ + MAP(XK_R5, 212); /* kf35 */ + MAP(XK_R6, 213); /* kf36 */ + MAP(XK_R7, 214); /* kf37 */ + MAP(XK_R8, 215); /* kf38 */ + MAP(XK_R9, 216); /* kf39=kpp */ + MAP(XK_R10, 217); /* kf40 */ + MAP(XK_R11, 218); /* kf41=kb2 */ + MAP(XK_R12, 219); /* kf42 */ + MAP(XK_R13, 220); /* kf43=kend */ + MAP(XK_R14, 221); /* kf44 */ + MAP(XK_R15, 222); /* kf45 */ +#ifdef SunXK_F36 + MAP(SunXK_F36, 234); + MAP(SunXK_F37, 235); +#endif + + 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, 5); + MAP(XK_Next, 6); + default: + return (-1); + } +} + +#if OPT_NUM_LOCK +/* + * Note 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, const char *keyword) +{ + static String data; + static XtResource key_resources[] = + { + {XtNtranslations, XtCTranslations, XtRString, + sizeof(data), 0, XtRString, (XtPointer) NULL} + }; + Bool result = False; + + XtGetSubresources(w, + (XtPointer) &data, + "vt100", + "VT100", + key_resources, + XtNumber(key_resources), + NULL, + (Cardinal) 0); + + if (data != 0) { + char *p = data; + int state = 0; + int now = ' ', prv; + TRACE(("TranslationsUseKeyword(%p):%s\n", w, p)); + while (*p != 0) { + prv = now; + now = char2lower(*p++); + if (now == ':' + || now == '!') { + state = -1; + } else if (now == '\n') { + state = 0; + } else if (state >= 0) { + if (isgraph(now) + && now == keyword[state]) { + if ((state != 0 + || !isalnum(prv)) + && ((keyword[++state] == 0) + && !isalnum(CharOf(*p)))) { + result = True; + break; + } + } else { + state = 0; + } + } + } + } + TRACE(("TranslationsUseKeyword(%p, %s) = %d\n", w, keyword, result)); + return result; +} + +#define SaveMask(name) term->misc.name |= mask;\ + TRACE(("%s mask %#lx is%s modifier\n", \ + #name, \ + term->misc.name, \ + ModifierName(term->misc.name))); +/* + * 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(void) +{ + int i, j, k; + Display *dpy = XtDisplay(term); + XModifierKeymap *keymap = XGetModifierMapping(dpy); + unsigned long mask; + int min_keycode, max_keycode, keysyms_per_keycode = 0; + + if (keymap != 0) { + KeySym *theMap; + + TRACE(("VTInitModifiers\n")); + + XDisplayKeycodes(dpy, &min_keycode, &max_keycode); + theMap = XGetKeyboardMapping(dpy, + min_keycode, + (max_keycode - min_keycode + 1), + &keysyms_per_keycode); + + if (theMap != 0) { + 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) { + KeySym keysym; + int l = 0; + do { + keysym = XKeycodeToKeysym(dpy, code, l); + l++; + } while (!keysym && l < keysyms_per_keycode); + if (keysym == XK_Num_Lock) { + SaveMask(num_lock); + } else if (keysym == XK_Alt_L) { + SaveMask(alt_left); + } else if (keysym == XK_Alt_R) { + SaveMask(alt_right); + } else if (keysym == XK_Meta_L) { + SaveMask(meta_left); + } else if (keysym == XK_Meta_R) { + SaveMask(meta_right); + } + } + k++; + } + } + XFree(theMap); + } + + /* Don't disable any mods if "alwaysUseMods" is true. */ + if (!term->misc.alwaysUseMods) { + /* + * If the Alt modifier is used in translations, we would rather not + * use it to modify function-keys when NumLock is active. + */ + if ((term->misc.alt_left != 0 + || term->misc.alt_right != 0) + && (TranslationsUseKeyword(toplevel, "alt") + || TranslationsUseKeyword((Widget) term, "alt"))) { + TRACE(("ALT is used as a modifier in translations (ignore mask)\n")); + term->misc.alt_left = 0; + term->misc.alt_right = 0; + } + + /* + * If the Meta modifier is used in translations, we would rather not + * use it to modify function-keys. + */ + if ((term->misc.meta_left != 0 + || term->misc.meta_right != 0) + && (TranslationsUseKeyword(toplevel, "meta") + || TranslationsUseKeyword((Widget) term, "meta"))) { + TRACE(("META is used as a modifier in translations\n")); + term->misc.meta_trans = True; + } + } + + XFreeModifiermap(keymap); + } +} +#endif /* OPT_NUM_LOCK */ + +#if OPT_TCAP_QUERY +static int +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; +} + +/* + * 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. + */ +int +xtermcapKeycode(char **params, unsigned *state) +{ + /* *INDENT-OFF* */ +#define DATA(tc,ti,x,y) { tc, ti, x, y } + static struct { + char *tc; + char *ti; + int code; + unsigned state; + } table[] = { + /* tcap terminfo keycode masks */ + DATA( "#2", "kHOM", XK_Home, ShiftMask ), + DATA( "#4", "kLFT", XK_Left, ShiftMask ), + DATA( "%1", "khlp", XK_Help, 0 ), + DATA( "%i", "kRIT", XK_Right, ShiftMask ), + DATA( "*6", "kslt", XK_Select, 0 ), + DATA( "*7", "kEND", XK_End, ShiftMask ), + DATA( "@0", "kfnd", XK_Find, 0 ), + DATA( "@7", "kend", XK_End, 0 ), + DATA( "F1", "kf11", XK_F11, 0 ), + DATA( "F2", "kf12", XK_F12, 0 ), + DATA( "F3", "kf13", XK_F13, 0 ), + DATA( "F4", "kf14", XK_F14, 0 ), + DATA( "F5", "kf15", XK_F15, 0 ), + DATA( "F6", "kf16", XK_F16, 0 ), + DATA( "F7", "kf17", XK_F17, 0 ), + DATA( "F8", "kf18", XK_F18, 0 ), + DATA( "F9", "kf19", XK_F19, 0 ), + DATA( "FA", "kf20", XK_F20, 0 ), + DATA( "FB", "kf21", XK_F21, 0 ), + DATA( "FC", "kf22", XK_F22, 0 ), + DATA( "FD", "kf23", XK_F23, 0 ), + DATA( "FE", "kf24", XK_F24, 0 ), + DATA( "FF", "kf25", XK_F25, 0 ), + DATA( "FG", "kf26", XK_F26, 0 ), + DATA( "FH", "kf27", XK_F27, 0 ), + DATA( "FI", "kf28", XK_F28, 0 ), + DATA( "FJ", "kf29", XK_F29, 0 ), + DATA( "FK", "kf30", XK_F30, 0 ), + DATA( "FL", "kf31", XK_F31, 0 ), + DATA( "FM", "kf32", XK_F32, 0 ), + DATA( "FN", "kf33", XK_F33, 0 ), + DATA( "FO", "kf34", XK_F34, 0 ), + DATA( "FP", "kf35", XK_F35, 0 ), +#ifdef SunXK_F36 + DATA( "FQ", "kf36", SunXK_F36, 0 ), + DATA( "FR", "kf37", SunXK_F37, 0 ), +#endif + DATA( "K1", "ka1", XK_KP_Home, 0 ), + DATA( "K4", "kc1", XK_KP_End, 0 ), + DATA( "k1", "kf1", XK_F1, 0 ), + DATA( "k2", "kf2", XK_F2, 0 ), + DATA( "k3", "kf3", XK_F3, 0 ), + DATA( "k4", "kf4", XK_F4, 0 ), + DATA( "k5", "kf5", XK_F5, 0 ), + DATA( "k6", "kf6", XK_F6, 0 ), + DATA( "k7", "kf7", XK_F7, 0 ), + DATA( "k8", "kf8", XK_F8, 0 ), + DATA( "k9", "kf9", XK_F9, 0 ), + DATA( "k;", "kf10", XK_F10, 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( "kb", "kbs", XK_BackSpace, 0 ), + DATA( "kd", "kcud1", XK_Down, 0 ), + DATA( "kh", "khome", XK_Home, 0 ), + DATA( "kl", "kcub1", XK_Left, 0 ), + DATA( "kr", "kcuf1", XK_Right, 0 ), + DATA( "ku", "kcuu1", XK_Up, 0 ), +# if OPT_ISO_COLORS + /* XK_COLORS is a fake code. */ + DATA( "Co", "colors", XK_COLORS, 0 ), +# endif + }; + /* *INDENT-ON* */ + + Cardinal n; + unsigned len = 0; + int code = -1; +#define MAX_TNAME_LEN 6 + char name[MAX_TNAME_LEN + 1]; + char *p; + + TRACE(("xtermcapKeycode(%s)\n", *params)); + + /* Convert hex encoded name to ascii */ + for (p = *params; hex2int(p[0]) >= 0 && hex2int(p[1]) >= 0; p += 2) { + if (len >= MAX_TNAME_LEN) + break; + name[len++] = (hex2int(p[0]) << 4) + hex2int(p[1]); + } + name[len] = 0; + *params = p; + + if (*p == 0 || *p == ';') { + for (n = 0; n < XtNumber(table); n++) { + if (!strcmp(table[n].ti, name) || !strcmp(table[n].tc, name)) { + code = table[n].code; + *state = table[n].state; + break; + } + } + } + + TRACE(("... xtermcapKeycode(%s, %u) -> %#06x\n", name, *state, code)); + return code; +} +#endif diff --git a/nx-X11/programs/xterm/install.sh b/nx-X11/programs/xterm/install.sh new file mode 100644 index 000000000..462fa9c3d --- /dev/null +++ b/nx-X11/programs/xterm/install.sh @@ -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/nx-X11/programs/xterm/keysym2ucs.c b/nx-X11/programs/xterm/keysym2ucs.c new file mode 100644 index 000000000..b96d9624b --- /dev/null +++ b/nx-X11/programs/xterm/keysym2ucs.c @@ -0,0 +1,857 @@ +/* $XFree86: xc/programs/xterm/keysym2ucs.c,v 1.5 2001/06/18 19:09:26 dickey 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 , University of Cambridge, April 2001 + * + * Special thanks to Richard Verhoeven 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 */ + { 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 */ + { 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 ⎷ ??? */ + { 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 ⎡ ??? */ + { 0x08a8, 0x23a3 }, /* botleftsqbracket ⎣ ??? */ + { 0x08a9, 0x23a4 }, /* toprightsqbracket ⎤ ??? */ + { 0x08aa, 0x23a6 }, /* botrightsqbracket ⎦ ??? */ + { 0x08ab, 0x239b }, /* topleftparens ⎛ ??? */ + { 0x08ac, 0x239d }, /* botleftparens ⎝ ??? */ + { 0x08ad, 0x239e }, /* toprightparens ⎞ ??? */ + { 0x08ae, 0x23a0 }, /* botrightparens ⎠ ??? */ + { 0x08af, 0x23a8 }, /* leftmiddlecurlybrace ⎨ ??? */ + { 0x08b0, 0x23ac }, /* rightmiddlecurlybrace ⎬ ??? */ +/* 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 blank ? ??? */ + { 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 (Unicode 3.2 draft) */ + { 0x09f0, 0x23bb }, /* horizlinescan3 ⎻ HORIZONTAL SCAN LINE-3 (Unicode 3.2 draft) */ + { 0x09f1, 0x2500 }, /* horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */ + { 0x09f2, 0x23bc }, /* horizlinescan7 ⎼ HORIZONTAL SCAN LINE-7 (Unicode 3.2 draft) */ + { 0x09f3, 0x23bd }, /* horizlinescan9 ⎽ HORIZONTAL SCAN LINE-9 (Unicode 3.2 draft) */ + { 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 signifblank ? ??? */ + { 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 decimalpoint ? ??? */ + { 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 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 */ + { 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/nx-X11/programs/xterm/keysym2ucs.h b/nx-X11/programs/xterm/keysym2ucs.h new file mode 100644 index 000000000..1f23ac662 --- /dev/null +++ b/nx-X11/programs/xterm/keysym2ucs.h @@ -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 + +long keysym2ucs(KeySym keysym); diff --git a/nx-X11/programs/xterm/link_axp.com b/nx-X11/programs/xterm/link_axp.com new file mode 100644 index 000000000..1f493a933 --- /dev/null +++ b/nx-X11/programs/xterm/link_axp.com @@ -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/nx-X11/programs/xterm/main.c b/nx-X11/programs/xterm/main.c new file mode 100644 index 000000000..35ce9d928 --- /dev/null +++ b/nx-X11/programs/xterm/main.c @@ -0,0 +1,4943 @@ +/* $XTermId: main.c,v 1.477 2005/11/13 23:10:36 tom Exp $ */ + +#if !defined(lint) && 0 +static char *rid = "$Xorg: main.c,v 1.7 2001/02/09 02:06:02 xorgcvs Exp $"; +#endif /* lint */ + +/* + * 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-2004,2005 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. + +******************************************************************/ + +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NX-X11, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of NoMachine S.r.l. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* $XFree86: xc/programs/xterm/main.c,v 3.199 2005/11/13 23:10:36 dickey Exp $ */ + +#ifdef NX_TRANS_EXIT + +/* + * Redefine the libc exit() function to be + * sure we get rid of proxy and detect any + * abnormal termination. + */ + +extern void NXTransExit(int code) __attribute__((noreturn)); + +#define exit(code) NXTransExit(code) + +#endif /* #ifdef NX_TRANS_EXIT */ + +/* main.c */ + +#define RES_OFFSET(field) XtOffsetOf(XTERM_RESOURCE, field) + +#include + +#include +#include + +#if OPT_TOOLBAR + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif /* OPT_TOOLBAR */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OPT_WIDE_CHARS +#include +#endif + +#ifdef __osf__ +#define USE_SYSV_SIGNALS +#define WTMP +#include /* openpty() */ +#endif + +#ifdef __sgi +#include /* 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 +#endif +#endif +#endif + +#ifdef __MVS__ +#define USE_SYSV_PGRP +#define USE_SYSV_SIGNALS +#endif + +#ifdef __CYGWIN__ +#define LASTLOG +#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 +#endif + +#ifndef TTY_GROUP_NAME +#define TTY_GROUP_NAME "tty" +#endif + +#include + +#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 /* for I_PUSH */ +#include /* 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 +#undef USE_SYSV_ENVVARS +#undef FIOCLEX +#undef FIONCLEX +#define setpgrp2 setpgrp +#include +#include +#endif + +#ifdef __hpux +#define HAS_BSD_GROUPS +#include +#endif /* __hpux */ + +#ifdef __osf__ +#define HAS_BSD_GROUPS +#undef USE_SYSV_PGRP +#define setpgrp setpgid +#endif + +#ifdef __sgi +#define HAS_BSD_GROUPS +#include +#endif /* __sgi */ + +#ifdef sun +#include +#endif + +#else /* } !SYSV { */ /* BSD systems */ + +#ifdef __QNX__ + +#ifndef __QNXNTO__ +#define ttyslot() 1 +#else +#define USE_SYSV_PGRP +extern __inline__ +ttyslot() +{ + 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 +#endif +#endif /* USE_POSIX_TERMIOS */ +#ifdef Lynx +#include +#else +#include +#endif +#ifndef __INTERIX +#define HAS_BSD_GROUPS +#endif +#endif /* !VMS */ +#endif /* !linux */ + +#endif /* __QNX__ */ + +#endif /* } !SYSV */ + +#if defined(SVR4) && !defined(__CYGWIN__) +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +#ifdef linux +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +/* Xpoll.h and 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 /* for NOFILE */ +#endif + +#if defined(BSD) && (BSD >= 199103) +#define WTMP +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +#include + +#ifdef __hpux +#include +#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 +#endif + +#if defined(UTMPX_FOR_UTMP) + +#include + +#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 + +#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 /* caution: glibc 2.3.5 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 +#endif /* PUCC_PTYD */ + +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) +#include /* openpty() */ +#endif + +#ifdef __FreeBSD__ +#include /* 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 + +#if defined(__SCO__) || (defined(ISC) && !defined(_POSIX_SOURCE)) +#undef SIGTSTP /* defined, but not the BSD way */ +#endif + +#ifdef SIGTSTP +#include +#endif + +#if defined(__SCO__) || defined(__UNIXWARE__) +#undef ECHOKE +#undef ECHOCTL +#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 + +#ifdef SYSV +extern char *ptsname(int); +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + extern int tgetent(char *ptr, char *name); + extern char *tgetstr(char *name, char **ptr); + +#ifdef __cplusplus +} +#endif +#ifndef VMS +static SIGNAL_T reapchild(int n); +static int spawn(void); +static void remove_termcap_entry(char *buf, char *str); +#ifdef USE_PTY_SEARCH +static int pty_search(int *pty); +#endif +#endif /* ! VMS */ + +static int get_pty(int *pty, char *from); +static void get_terminal(void); +static void resize(TScreen * s, char *oldtc, char *newtc); +static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode); + +static Bool added_utmp_entry = False; + +#if defined(USE_UTMP_SETGID) +static int utmpGid = -1; +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 spawn() 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 */ +#ifndef CBRK +#define CBRK 0 +#endif +#ifndef CDSUSP +#define CDSUSP CONTROL('Y') +#endif +#ifndef CEOF +#define CEOF CONTROL('D') +#endif +#ifndef CEOL +#define CEOL 0 +#endif +#ifndef CFLUSH +#define CFLUSH CONTROL('O') +#endif +#ifndef CINTR +#define CINTR 0177 +#endif +#ifndef CKILL +#define CKILL '@' +#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 + +#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) +#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) +#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 int override_tty_modes = 0; +/* *INDENT-OFF* */ +static struct _xttymodes { + char *name; + size_t len; + int set; + Char 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 */ +}; +/* *INDENT-ON* */ + +#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value + +static int parse_tty_modes(char *s, struct _xttymodes *modelist); + +#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 */ + +#ifndef USE_UTEMPTER +#ifdef USE_LASTLOG +static char etc_lastlog[] = LASTLOG_FILENAME; +#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 /* 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)); \ + } + +/* 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("keyboardType", "KeyboardType", keyboardType, "unknown"), + Bres("sunFunctionKeys", "SunFunctionKeys", sunFunctionKeys, False), +#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_INITIAL_ERASE + Bres("ptyInitialErase", "PtyInitialErase", ptyInitialErase, DEF_INITIAL_ERASE), + Bres("backarrowKeyIsErase", "BackarrowKeyIsErase", backarrow_is_erase, DEF_BACKARO_ERASE), +#endif + Bres("waitForMap", "WaitForMap", wait_for_map, False), + Bres("useInsertMode", "UseInsertMode", useInsertMode, False), +#if OPT_ZICONBEEP + Ires("zIconBeep", "ZIconBeep", zIconBeep, 0), +#endif +#if OPT_PTY_HANDSHAKE + Bres("ptyHandshake", "PtyHandshake", ptyHandshake, True), +#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 +}; + +static char *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, (caddr_t) NULL}, +{"-132", "*c132", XrmoptionNoArg, (caddr_t) "on"}, +{"+132", "*c132", XrmoptionNoArg, (caddr_t) "off"}, +{"-ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "on"}, +{"+ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "off"}, +{"-aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "off"}, +#ifndef NO_ACTIVE_ICON +{"-ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "off"}, +{"+ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "on"}, +#endif /* NO_ACTIVE_ICON */ +{"-b", "*internalBorder",XrmoptionSepArg, (caddr_t) NULL}, +{"-bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "on"}, +{"+bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "off"}, +{"-bcf", "*cursorOffTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bcn", "*cursorOnTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-cc", "*charClass", XrmoptionSepArg, (caddr_t) NULL}, +{"-cm", "*colorMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+cm", "*colorMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "off"}, +{"+cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "on"}, +{"-cr", "*cursorColor", XrmoptionSepArg, (caddr_t) NULL}, +{"-cu", "*curses", XrmoptionNoArg, (caddr_t) "on"}, +{"+cu", "*curses", XrmoptionNoArg, (caddr_t) "off"}, +{"-dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "off"}, +{"+dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "on"}, +{"-fb", "*boldFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"on"}, +{"-fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"on"}, +#ifndef NO_ACTIVE_ICON +{"-fi", "*iconFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif /* NO_ACTIVE_ICON */ +#if OPT_RENDERFONT +{"-fa", "*faceName", XrmoptionSepArg, (caddr_t) NULL}, +{"-fd", "*faceNameDoublesize", XrmoptionSepArg, (caddr_t) NULL}, +{"-fs", "*faceSize", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_WIDE_CHARS +{"-fw", "*wideFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fwb", "*wideBoldFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_INPUT_METHOD +{"-fx", "*ximFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HIGHLIGHT_COLOR +{"-hc", "*highlightColor", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HP_FUNC_KEYS +{"-hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "on"}, +{"+hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-hold", "*hold", XrmoptionNoArg, (caddr_t) "on"}, +{"+hold", "*hold", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_INITIAL_ERASE +{"-ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "on"}, +{"+ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_C1_PRINT +{"-k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "on"}, +{"+k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +{"+kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +/* parse logging options anyway for compatibility */ +{"-l", "*logging", XrmoptionNoArg, (caddr_t) "on"}, +{"+l", "*logging", XrmoptionNoArg, (caddr_t) "off"}, +{"-lf", "*logFile", XrmoptionSepArg, (caddr_t) NULL}, +{"-ls", "*loginShell", XrmoptionNoArg, (caddr_t) "on"}, +{"+ls", "*loginShell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mb", "*marginBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+mb", "*marginBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mc", "*multiClickTime", XrmoptionSepArg, (caddr_t) NULL}, +{"-mesg", "*messages", XrmoptionNoArg, (caddr_t) "off"}, +{"+mesg", "*messages", XrmoptionNoArg, (caddr_t) "on"}, +{"-ms", "*pointerColor",XrmoptionSepArg, (caddr_t) NULL}, +{"-nb", "*nMarginBell", XrmoptionSepArg, (caddr_t) NULL}, +{"-nul", "*underLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+nul", "*underLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-pc", "*boldColors", XrmoptionNoArg, (caddr_t) "on"}, +{"+pc", "*boldColors", XrmoptionNoArg, (caddr_t) "off"}, +{"-rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "off"}, +{"-s", "*multiScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+s", "*multiScroll", XrmoptionNoArg, (caddr_t) "off"}, +{"-sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "on"}, +{"+sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "off"}, +#ifdef SCROLLBAR_RIGHT +{"-leftbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "off"}, +{"-rightbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "on"}, +#endif +{"-rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "on"}, +{"+sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "off"}, +{"-si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "off"}, +{"+si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "on"}, +{"-sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "on"}, +{"+sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "off"}, +{"-sl", "*saveLines", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_SUNPC_KBD +{"-sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "on"}, +{"+sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TEK4014 +{"-t", "*tekStartup", XrmoptionNoArg, (caddr_t) "on"}, +{"+t", "*tekStartup", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-ti", "*decTerminalID",XrmoptionSepArg, (caddr_t) NULL}, +{"-tm", "*ttyModes", XrmoptionSepArg, (caddr_t) NULL}, +{"-tn", "*termName", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_WIDE_CHARS +{"-u8", "*utf8", XrmoptionNoArg, (caddr_t) "2"}, +{"+u8", "*utf8", XrmoptionNoArg, (caddr_t) "0"}, +#endif +#if OPT_LUIT_PROG +{"-lc", "*locale", XrmoptionNoArg, (caddr_t) "on"}, +{"+lc", "*locale", XrmoptionNoArg, (caddr_t) "off"}, +{"-lcc", "*localeFilter",XrmoptionSepArg, (caddr_t) NULL}, +{"-en", "*locale", XrmoptionSepArg, (caddr_t) NULL}, +#endif +{"-ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "on"}, +{"+ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "off"}, +{"-im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "on"}, +{"+im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "off"}, +{"-vb", "*visualBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_WIDE_CHARS +{"-wc", "*wideChars", XrmoptionNoArg, (caddr_t) "on"}, +{"+wc", "*wideChars", XrmoptionNoArg, (caddr_t) "off"}, +{"-mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "off"}, +{"-cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"}, +{"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_ZICONBEEP +{"-ziconbeep", "*zIconBeep", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_SAME_NAME +{"-samename", "*sameName", XrmoptionNoArg, (caddr_t) "on"}, +{"+samename", "*sameName", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_SESSION_MGT +{"-sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "on"}, +{"+sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TOOLBAR +{"-tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "on"}, +{"+tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "off"}, +#endif +/* options that we process ourselves */ +{"-help", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-version", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-class", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +{"-e", NULL, XrmoptionSkipLine, (caddr_t) NULL}, +{"-into", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +/* bogus old compatibility stuff for which there are + standard XtOpenApplication options now */ +{"%", "*tekGeometry", XrmoptionStickyArg, (caddr_t) NULL}, +{"#", ".iconGeometry",XrmoptionStickyArg, (caddr_t) NULL}, +{"-T", ".title", XrmoptionSepArg, (caddr_t) NULL}, +{"-n", "*iconName", XrmoptionSepArg, (caddr_t) NULL}, +{"-r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-w", ".borderWidth", XrmoptionSepArg, (caddr_t) 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 +{ "-hc color", "selection background 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 +{ "-/+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 +{ NULL, NULL }}; +/* *INDENT-ON* */ + +static 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(127); + 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; +} + +/* + * If we're linked to terminfo, tgetent() will return an empty buffer. We + * cannot use that to adjust the $TERMCAP variable. + */ +static Bool +get_termcap(char *name, char *buffer, char *resized) +{ + TScreen *screen = &term->screen; + + *buffer = 0; /* initialize, in case we're using terminfo's tgetent */ + + if (name != 0) { + if (tgetent(buffer, name) == 1) { + TRACE(("get_termcap(%s) succeeded (%s)\n", name, + (*buffer + ? "ok:termcap, we can update $TERMCAP" + : "assuming this is terminfo"))); + if (*buffer) { + if (!TEK4014_ACTIVE(screen)) { + resize(screen, buffer, resized); + } + } + return True; + } else { + *buffer = 0; /* just in case */ + } + } + return False; +} + +static int +abbrev(char *tst, 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 + strlen(ProgramName); + for (opt = list; opt->opt; opt++) { + int len = 3 + 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)); + 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; +} +#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 (term->screen.Tshow) + hide_vt_window(); + else + do_hangup(w, (XtPointer) 0, (XtPointer) 0); + } else if (term->screen.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 = 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 = 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 */ + +int +main(int argc, char *argv[]ENVP_ARG) +{ + Widget form_top, menu_top; + TScreen *screen; + int mode; + char *my_class = DEFCLASS; + Window winToEmbedInto = None; + +#ifdef DISABLE_SETUID + if (seteuid(getuid()) == -1) + exit(2); + if (setuid(getuid()) == -1) + exit(2); +#endif + + ProgramName = argv[0]; + + /* 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); + if (seteuid(getuid()) == -1) { + fprintf(stderr, + "%s: unable to change back euid\n", ProgramName); + exit(1); + } + if (setuid(getuid()) == -1) { + fprintf(stderr, + "%s: unable to change back uid\n", ProgramName); + exit(1); + } +#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; + 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 { + 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). + */ + 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 +#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 /* } */ + + d_tio.c_cc[VINTR] = CINTR; + d_tio.c_cc[VQUIT] = CQUIT; + d_tio.c_cc[VERASE] = CERASE; + d_tio.c_cc[VKILL] = CKILL; + d_tio.c_cc[VEOF] = CEOF; + d_tio.c_cc[VEOL] = CNUL; + d_tio.c_cc[VEOL2] = CNUL; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = CNUL; +#endif + +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ + d_tio.c_cc[VSUSP] = CSUSP; +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CDSUSP; +#endif + d_tio.c_cc[VREPRINT] = CRPRNT; + d_tio.c_cc[VDISCARD] = CFLUSH; + d_tio.c_cc[VWERASE] = CWERASE; + d_tio.c_cc[VLNEXT] = CLNEXT; + d_tio.c_cc[VMIN] = 1; + d_tio.c_cc[VTIME] = 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 + d_tio.c_cc[VINTR] = CONTROL('C'); /* '^C' */ + d_tio.c_cc[VERASE] = 0x7f; /* 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; /* '^@' */ + d_tio.c_cc[VMIN] = 1; + d_tio.c_cc[VTIME] = 0; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = CSWTCH; /* usually '^Z' */ +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = CLNEXT; +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = CWERASE; +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = CRPRNT; +#endif +#ifdef VRPRNT + d_tio.c_cc[VRPRNT] = CRPRNT; +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = CFLUSH; +#endif +#ifdef VFLUSHO + d_tio.c_cc[VFLUSHO] = CFLUSH; +#endif +#ifdef VSTOP + d_tio.c_cc[VSTOP] = CSTOP; +#endif +#ifdef VSTART + d_tio.c_cc[VSTART] = CSTART; +#endif +#ifdef VSUSP + d_tio.c_cc[VSUSP] = CSUSP; +#endif +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CDSUSP; +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = CSTATUS; +#endif + /* now, try to inherit tty settings */ + { + int i; + + for (i = 0; i <= 2; i++) { + TERMIO_STRUCT deftio; + if (ttyGetAttr(i, &deftio) == 0) { + d_tio.c_cc[VINTR] = deftio.c_cc[VINTR]; + d_tio.c_cc[VQUIT] = deftio.c_cc[VQUIT]; + d_tio.c_cc[VERASE] = deftio.c_cc[VERASE]; + d_tio.c_cc[VKILL] = deftio.c_cc[VKILL]; + d_tio.c_cc[VEOF] = deftio.c_cc[VEOF]; + d_tio.c_cc[VEOL] = deftio.c_cc[VEOL]; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = deftio.c_cc[VSWTCH]; +#endif +#ifdef VEOL2 + d_tio.c_cc[VEOL2] = deftio.c_cc[VEOL2]; +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = deftio.c_cc[VLNEXT]; +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = deftio.c_cc[VWERASE]; +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = deftio.c_cc[VREPRINT]; +#endif +#ifdef VRPRNT + d_tio.c_cc[VRPRNT] = deftio.c_cc[VRPRNT]; +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = deftio.c_cc[VDISCARD]; +#endif +#ifdef VFLUSHO + d_tio.c_cc[VFLUSHO] = deftio.c_cc[VFLUSHO]; +#endif +#ifdef VSTOP + d_tio.c_cc[VSTOP] = deftio.c_cc[VSTOP]; +#endif +#ifdef VSTART + d_tio.c_cc[VSTART] = deftio.c_cc[VSTART]; +#endif +#ifdef VSUSP + d_tio.c_cc[VSUSP] = deftio.c_cc[VSUSP]; +#endif +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = deftio.c_cc[VDSUSP]; +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = deftio.c_cc[VSTATUS]; +#endif + break; + } + } + } +#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 */ +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ + d_tio.c_cc[VSUSP] = CSUSP; +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CharOf('\000'); +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = CharOf('\377'); +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = CharOf('\377'); +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = CharOf('\377'); +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = CharOf('\377'); +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = CharOf('\377'); +#endif +#endif /* } USE_TERMIOS */ +#ifdef TIOCLSET /* { */ + d_lmode = 0; +#endif /* } TIOCLSET */ +#endif /* } macII, ATT, CRAY */ +#endif /* } TERMIO_STRUCT */ + + /* Init the Toolkit. */ + { +#ifdef HAS_SAVED_IDS_AND_SETEUID + uid_t euid = geteuid(); + gid_t egid = getegid(); + uid_t ruid = getuid(); + gid_t rgid = getgid(); + + if (setegid(rgid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) /* could happen if _BPX_SHAREAS=REUSE */ +#endif + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) rgid, strerror(errno)); + } + + if (seteuid(ruid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) ruid, strerror(errno)); + } +#endif + + XtSetErrorHandler(xt_error); +#if OPT_SESSION_MGT + toplevel = XtOpenApplication(&app_con, my_class, + optionDescList, + XtNumber(optionDescList), + &argc, argv, fallback_resources, + sessionShellWidgetClass, + NULL, 0); +#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(); + +#ifdef HAS_SAVED_IDS_AND_SETEUID + if (seteuid(euid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) euid, strerror(errno)); + } + + if (setegid(egid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) egid, strerror(errno)); + } +#endif + +#if defined(USE_UTMP_SETGID) + if (resource.utmpInhibit) { + /* Can totally revoke group privs */ + setegid(getgid()); + setgid(getgid()); + } +#endif + } + + waiting_for_initial_map = resource.wait_for_map; + + /* + * 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 = 1; + } + } +#if OPT_ZICONBEEP + zIconBeep = resource.zIconBeep; + zIconBeep_flagged = False; + if (zIconBeep > 100 || zIconBeep < -100) { + 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 */ +#if OPT_SAME_NAME + sameName = resource.sameName; +#endif + 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 == getuid()) && + !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); + + 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, +#endif + (XtPointer) 0); + decode_keyboard_type(&resource); + + screen = &term->screen; + 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) + screen->TekEmu = False; + + if (screen->TekEmu && !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[4]; + 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(getuid(), getgid(), False, dbglogfile, 0666)) { + 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 */ + + /* open a terminal for client */ + get_terminal(); + + spawn(); + +#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(screen)))); + 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 +#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(screen); + } +#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); + } + + for (;;) { +#if OPT_TEK4014 + if (screen->TekEmu) + TekRun(); + else +#endif + VTRun(); + } +} + +#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS)) || 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), + getuid(), 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 spawn(). That's the reason + for the "if (IsPts)" statement in spawn(); 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 */ + + 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(getuid(), getgid(), 0600U); + seteuid(getuid()); + +#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 */ + +/* + * sets up X and initializes the terminal structure except for term.buf.fildes. + */ +static void +get_terminal(void) +{ + TScreen *screen = &term->screen; + + screen->arrow = make_colored_cursor(XC_left_ptr, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); +} + +/* + * 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) +{ + siglongjmp(env, 1); + SIGNAL_RETURN; +} + +/* + * declared outside OPT_PTY_HANDSHAKE so HsSysError() callers can use + */ +static int cp_pipe[2]; /* this pipe is used for child to parent transfer */ + +#if OPT_PTY_HANDSHAKE +static int pc_pipe[2]; /* 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; + +/* 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 pf, int error) +{ + handshake_t handshake; + + handshake.status = PTY_FATALERROR; + handshake.error = errno; + handshake.fatal_error = error; + strcpy(handshake.buffer, ttydev); + write(pf, (char *) &handshake, sizeof(handshake)); + exit(error); +} + +void +first_map_occurred(void) +{ + handshake_t handshake; + TScreen *screen = &term->screen; + + handshake.status = PTY_EXEC; + handshake.rows = screen->max_row; + handshake.cols = screen->max_col; + write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); + close(cp_pipe[0]); + close(pc_pipe[1]); + waiting_for_initial_map = False; +} +#else +/* + * temporary hack to get xterm working on att ptys + */ +static void +HsSysError(int pf GCC_UNUSED, int error) +{ + fprintf(stderr, "%s: fatal pty error %d (errno=%d) on tty %s\n", + xterm_name, error, errno, ttydev); + exit(error); +} + +void +first_map_occurred(void) +{ + return; +} +#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(("set_owner(%s, uid=%d, gid=%d, mode=%#o\n", device, uid, gid, mode)); + + if (chown(device, uid, gid) < 0) { + why = errno; + if (why != ENOENT + && getuid() == 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 %03o currently %03o: %s\n", + device, (unsigned) mode, (sb.st_mode & 0777U), + strerror(why)); + TRACE(("...stat uid=%d, gid=%d, mode=%#o\n", + sb.st_uid, sb.st_gid, 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 + +/* + * 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 +spawn(void) +{ + TScreen *screen = &term->screen; +#if OPT_PTY_HANDSHAKE + handshake_t handshake; + int done; +#endif +#if OPT_INITIAL_ERASE + int initial_erase = VAL_INITIAL_ERASE; +#endif + int rc = 0; + int ttyfd = -1; + +#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 termcap[TERMCAP_SIZE]; + char newtc[TERMCAP_SIZE]; + char *ptr, *shname, *shname_minus; + int i, no_dev_tty = False; + char **envnew; /* new environment */ + int envsize; /* elements in 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 lastlog; +#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 = getuid(); + screen->gid = getgid(); + + termcap[0] = '\0'; + newtc[0] = '\0'; + +#ifdef SIGTTOU + /* so that TIOCSWINSZ || TIOCSIZE doesn't block */ + signal(SIGTTOU, SIG_IGN); +#endif + + if (am_slave >= 0) { + screen->respond = am_slave; + set_pty_id(ttydev, passedPty); +#ifdef USE_PTY_DEVICE + set_pty_id(ptydev, passedPty); +#endif + setgid(screen->gid); + setuid(screen->uid); + } 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; + } +#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. + */ + no_dev_tty = False; + 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) { + no_dev_tty = True; +#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, <c) == -1) + ltc = d_ltc; +#endif /* HAS_LTCHARS */ +#ifdef TIOCLSET + if (ioctl(ttyfd, TIOCLGET, &lmode) == -1) + lmode = d_lmode; +#endif /* TIOCLSET */ +#ifdef TERMIO_STRUCT + if ((rc = ttyGetAttr(ttyfd, &tio)) == -1) + tio = d_tio; +#else /* !TERMIO_STRUCT */ + if ((rc = ioctl(ttyfd, TIOCGETP, (char *) &sg)) == -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; + if ((rc = ttyGetAttr(screen->respond, &my_tio)) == 0) + initial_erase = my_tio.c_cc[VERASE]; +#else /* !TERMIO_STRUCT */ + struct sgttyb my_sg; + if ((rc = ioctl(screen->respond, TIOCGETP, (char *) &my_sg)) == 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(XtParent(CURRENT_EMU(screen)), False); + + wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", + False); + + if (!TEK4014_ACTIVE(screen)) + VTInit(); /* 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(XtParent(CURRENT_EMU(screen)), + mit_console, CurrentTime, + ConvertConsoleSelection, NULL, NULL); + } +#endif +#if OPT_TEK4014 + if (screen->TekEmu) { + envnew = tekterm; + ptr = newtc; + } else +#endif + { + envnew = vtterm; + ptr = termcap; + } + + /* + * 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. + */ + if (!get_termcap(TermName = resource.term_name, ptr, newtc)) { + char *last = NULL; + TermName = *envnew; + while (*envnew != NULL) { + if ((last == NULL || strcmp(last, *envnew)) + && get_termcap(*envnew, ptr, newtc)) { + TermName = *envnew; + break; + } + last = *envnew; + envnew++; + } + } + + /* + * 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 ")); + if (!resource.ptyInitialErase) { + char temp[1024], *p = temp; + char *s = tgetstr(TERMCAP_ERASE, &p); + TRACE(("...extracting initial_erase value from termcap\n")); + if (s != 0) { + initial_erase = decode_keyvalue(&s, True); + } + } + 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 == 127) { + term->keyboard.flags &= ~MODE_DECBKM; + } else { + term->keyboard.flags |= MODE_DECBKM; + term->keyboard.reset_DECBKM = 1; + } + TRACE(("...sets DECBKM %s\n", + (term->keyboard.flags & MODE_DECBKM) ? "on" : "off")); + } else { + term->keyboard.reset_DECBKM = 2; + } +#endif /* OPT_INITIAL_ERASE */ + +#ifdef TTYSIZE_STRUCT + /* tell tty how big window is */ +#if OPT_TEK4014 + if (TEK4014_ACTIVE(screen)) { + TTYSIZE_ROWS(ts) = 38; + TTYSIZE_COLS(ts) = 81; +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = TFullWidth(screen); + ts.ws_ypixel = TFullHeight(screen); +#endif + } else +#endif + { + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = FullHeight(screen); +#endif + } + 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) { + /* + * now in child process + */ + TRACE_CHILD +#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 + +#ifdef USE_USG_PTYS +#ifdef USE_ISPTS_FLAG + if (IsPts) { /* SYSV386 supports both, which did we open? */ +#endif + int ptyfd = 0; + char *pty_name = 0; + + setpgrp(); + grantpt(screen->respond); + unlockpt(screen->respond); + if ((pty_name = ptsname(screen->respond)) == 0) { + SysError(ERROR_PTSNAME); + } + if ((ptyfd = open(pty_name, O_RDWR)) < 0) { + SysError(ERROR_OPPTSNAME); + } +#ifdef I_PUSH + if (ioctl(ptyfd, I_PUSH, "ptem") < 0) { + SysError(ERROR_PTEM); + } +#if !defined(SVR4) && !(defined(SYSV) && defined(i386)) + if (!getenv("CONSEM") && ioctl(ptyfd, I_PUSH, "consem") < 0) { + SysError(ERROR_CONSEM); + } +#endif /* !SVR4 */ + if (ioctl(ptyfd, I_PUSH, "ldterm") < 0) { + SysError(ERROR_LDTERM); + } +#ifdef SVR4 /* from Sony */ + 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(screen)) { + TTYSIZE_ROWS(ts) = 24; + TTYSIZE_COLS(ts) = 80; +#ifdef USE_STRUCT_WINSIZE + ts.ws_xpixel = TFullWidth(screen); + ts.ws_ypixel = TFullHeight(screen); +#endif + } else +#endif /* OPT_TEK4014 */ + { + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#ifdef USE_STRUCT_WINSIZE + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = 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) { + (void) close(cp_pipe[1]); + cp_pipe[1] = i; + } + } + if (pc_pipe[0] <= 2) { + if ((i = fcntl(pc_pipe[0], F_DUPFD, 3)) >= 0) { + (void) 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__ + 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) + (void) setsid(); +#else + (void) 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__ */ + } + + while (1) { +#if defined(TIOCNOTTY) && (!defined(__GLIBC__) || (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))) + if (!no_dev_tty + && (ttyfd = open("/dev/tty", O_RDWR)) >= 0) { + ioctl(ttyfd, TIOCNOTTY, (char *) NULL); + close_fd(ttyfd); + } +#endif /* TIOCNOTTY && !glibc >= 2.1 */ +#ifdef CSRG_BASED + (void) revoke(ttydev); +#endif + if ((ttyfd = open(ttydev, O_RDWR)) >= 0) { +#if defined(CRAY) && defined(TCSETCTTY) + /* make /dev/tty work */ + ioctl(ttyfd, TCSETCTTY, 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); + write(cp_pipe[1], (char *) &handshake, + sizeof(handshake)); + + /* get reply from parent */ + i = 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 = CastMallocN(char, strlen(handshake.buffer)); + if (ttydev == NULL) { + SysError(ERROR_SPREALLOC); + } + strcpy(ttydev, handshake.buffer); + } + + /* use the same tty name that everyone else will use + * (from ttyname) + */ + if ((ptr = ttyname(ttyfd)) != 0) { + /* it may be bigger */ + ttydev = TypeRealloc(char, strlen(ptr) + 1, ttydev); + if (ttydev == NULL) { + SysError(ERROR_SPREALLOC); + } + (void) strcpy(ttydev, 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 */ + 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 + 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 + 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 +#ifndef __MVS__ + /* reset EOL to default value */ + tio.c_cc[VEOL] = CEOL; /* '^@' */ + /* certain shells (ksh & csh) change EOF as well */ + tio.c_cc[VEOF] = CEOF; /* '^D' */ +#else + if (tio.c_cc[VEOL] == 0) + tio.c_cc[VEOL] = CEOL; /* '^@' */ + if (tio.c_cc[VEOF] == 0) + tio.c_cc[VEOF] = CEOF; /* '^D' */ +#endif +#ifdef VLNEXT + tio.c_cc[VLNEXT] = CLNEXT; +#endif +#ifdef VWERASE + tio.c_cc[VWERASE] = CWERASE; +#endif +#ifdef VREPRINT + tio.c_cc[VREPRINT] = CRPRNT; +#endif +#ifdef VRPRNT + tio.c_cc[VRPRNT] = CRPRNT; +#endif +#ifdef VDISCARD + tio.c_cc[VDISCARD] = CFLUSH; +#endif +#ifdef VFLUSHO + tio.c_cc[VFLUSHO] = CFLUSH; +#endif +#ifdef VSTOP + tio.c_cc[VSTOP] = CSTOP; +#endif +#ifdef VSTART + tio.c_cc[VSTART] = CSTART; +#endif +#ifdef VSUSP + tio.c_cc[VSUSP] = CSUSP; +#endif +#ifdef VDSUSP + tio.c_cc[VDSUSP] = CDSUSP; +#endif + if (override_tty_modes) { + /* sysv-specific */ + TMODE(XTTYMODE_intr, tio.c_cc[VINTR]); + TMODE(XTTYMODE_quit, tio.c_cc[VQUIT]); + TMODE(XTTYMODE_erase, tio.c_cc[VERASE]); + TMODE(XTTYMODE_kill, tio.c_cc[VKILL]); + TMODE(XTTYMODE_eof, tio.c_cc[VEOF]); + TMODE(XTTYMODE_eol, tio.c_cc[VEOL]); +#ifdef VSWTCH + TMODE(XTTYMODE_swtch, tio.c_cc[VSWTCH]); +#endif +#ifdef VSUSP + TMODE(XTTYMODE_susp, tio.c_cc[VSUSP]); +#endif +#ifdef VDSUSP + TMODE(XTTYMODE_dsusp, tio.c_cc[VDSUSP]); +#endif +#ifdef VREPRINT + TMODE(XTTYMODE_rprnt, tio.c_cc[VREPRINT]); +#endif +#ifdef VRPRNT + TMODE(XTTYMODE_rprnt, tio.c_cc[VRPRNT]); +#endif +#ifdef VDISCARD + TMODE(XTTYMODE_flush, tio.c_cc[VDISCARD]); +#endif +#ifdef VFLUSHO + TMODE(XTTYMODE_flush, tio.c_cc[VFLUSHO]); +#endif +#ifdef VWERASE + TMODE(XTTYMODE_weras, tio.c_cc[VWERASE]); +#endif +#ifdef VLNEXT + TMODE(XTTYMODE_lnext, tio.c_cc[VLNEXT]); +#endif +#ifdef VSTART + TMODE(XTTYMODE_start, tio.c_cc[VSTART]); +#endif +#ifdef VSTOP + TMODE(XTTYMODE_stop, tio.c_cc[VSTOP]); +#endif +#ifdef VSTATUS + TMODE(XTTYMODE_status, tio.c_cc[VSTATUS]); +#endif +#ifdef VERASE2 + TMODE(XTTYMODE_erase2, tio.c_cc[VERASE2]); +#endif +#ifdef VEOL2 + TMODE(XTTYMODE_eol2, tio.c_cc[VEOL2]); +#endif +#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, <c) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETC); +#endif /* HAS_LTCHARS */ +#ifdef TIOCLSET + if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCLSET); +#endif /* TIOCLSET */ + if (ttySetAttr(ttyfd, &tio) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETP); + + /* ignore errors here - some platforms don't work */ + 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(cp_pipe[1], ERROR_TIOCSETP); + if (ioctl(ttyfd, TIOCSETC, (char *) &tc) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETC); + if (ioctl(ttyfd, TIOCSETD, (char *) &discipline) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETD); + if (ioctl(ttyfd, TIOCSLTC, (char *) <c) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSLTC); + if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCLSET); +#ifdef sony + if (ioctl(ttyfd, TIOCKSET, (char *) &jmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCKSET); + if (ioctl(ttyfd, TIOCKSETC, (char *) &jtc) == -1) + HsSysError(cp_pipe[1], 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", + xterm_name, 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", + xterm_name, strerror(errno)); + (void) 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 make the parent process set the + * terminal's erase mode, and if we had no ttyModes 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, + (!resource.ptyInitialErase + && !override_tty_modes + && !ttymodelist[XTTYMODE_erase].set) + ? "YES" : "NO", + resource.ptyInitialErase, + override_tty_modes, + ttymodelist[XTTYMODE_erase].set)); + if (!resource.ptyInitialErase + && !override_tty_modes + && !ttymodelist[XTTYMODE_erase].set) { +#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; + 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 + + /* copy the environment before Setenv'ing */ + for (i = 0; environ[i] != NULL; i++) ; + /* compute number of xtermSetenv() calls below */ + envsize = 1; /* (NULL terminating entry) */ + envsize += 5; /* TERM, WINDOWID, DISPLAY, _SHELL, _VERSION */ +#ifdef HAVE_UTMP + envsize += 1; /* LOGNAME */ +#endif /* HAVE_UTMP */ +#ifdef USE_SYSV_ENVVARS + envsize += 2; /* COLUMNS, LINES */ +#ifdef HAVE_UTMP + envsize += 2; /* HOME, SHELL */ +#endif /* HAVE_UTMP */ +#ifdef OWN_TERMINFO_DIR + envsize += 1; /* TERMINFO */ +#endif +#else /* USE_SYSV_ENVVARS */ + envsize += 1; /* TERMCAP */ +#endif /* USE_SYSV_ENVVARS */ + envnew = TypeCallocN(char *, (unsigned) i + envsize); + memmove((char *) envnew, (char *) environ, i * sizeof(char *)); + environ = envnew; + xtermSetenv("TERM=", TermName); + if (!TermName) + *newtc = 0; + + sprintf(buf, "%lu", + ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU(screen))))); + xtermSetenv("WINDOWID=", buf); + + /* put the display into the environment of the shell */ + xtermSetenv("DISPLAY=", XDisplayString(screen->display)); + + xtermSetenv("XTERM_VERSION=", xtermVersion()); + + 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); + + (void) close(0); + + if (open("/dev/tty", O_RDWR)) { + SysError(ERROR_OPDEVTTY); + } + (void) close(1); + (void) close(2); + dup(0); + dup(0); +#else + /* dup the tty */ + for (i = 0; i <= 2; i++) + if (i != ttyfd) { + (void) close(i); + (void) 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 = getenv("LOGNAME")) != NULL + || (login_name = 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_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 */ + if (!(utret = find_utmp(&utmp))) { + (void) call_setutent(); + init_utmp(USER_PROCESS, &utmp); + if (!(utret = find_utmp(&utmp))) { + (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", + 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 + (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 (term->misc.login_shell) + updwtmpx(WTMPX_FILE, &utmp); +#elif defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)) + if (term->misc.login_shell) + call_updwtmp(etc_wtmp, &utmp); +#else + if (term->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) { + bzero((char *) &utmp, 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 + /* cast needed on Ultrix 4.4 */ + time((time_t *) & utmp.ut_time); + lseek(i, (long) (tslot * sizeof(utmp)), 0); + write(i, (char *) &utmp, sizeof(utmp)); + close(i); + added_utmp_entry = True; +#if defined(WTMP) + if (term->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 (term->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 (term->misc.login_shell) { + bzero((char *) &lastlog, sizeof(lastlog)); + (void) strncpy(lastlog.ll_line, + my_pty_name(ttydev), + sizeof(lastlog.ll_line)); + X_GETTIMEOFDAY(&lastlog.ll_tv); + SetUtmpHost(lastlog.ll_host, screen); + updlastlogx(_PATH_LASTLOGX, screen->uid, &lastlog); + } +#endif + +#ifdef USE_LASTLOG + if (term->misc.login_shell && + (i = open(etc_lastlog, O_WRONLY)) >= 0) { + bzero((char *) &lastlog, sizeof(struct lastlog)); + (void) strncpy(lastlog.ll_line, + my_pty_name(ttydev), + sizeof(lastlog.ll_line)); + SetUtmpHost(lastlog.ll_host, screen); + time(&lastlog.ll_time); + lseek(i, (long) (screen->uid * sizeof(struct lastlog)), 0); + write(i, (char *) &lastlog, sizeof(struct lastlog)); + close(i); + } +#endif /* USE_LASTLOG */ + +#if defined(USE_UTMP_SETGID) + /* Switch to real gid after writing utmp entry */ + utmpGid = getegid(); + if (getgid() != getegid()) { + utmpGid = getegid(); + setegid(getgid()); + TRACE(("switch to real gid %d after writing utmp\n", getgid())); + } +#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); + (void) write(cp_pipe[1], (char *) &handshake, sizeof(handshake)); + } +#endif /* OPT_PTY_HANDSHAKE */ +#endif /* USE_UTEMPTER */ +#endif /* HAVE_UTMP */ + + (void) setgid(screen->gid); +#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); + } +#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); + (void) write(cp_pipe[1], (char *) &handshake, sizeof(handshake)); + + if (waiting_for_initial_map) { + i = 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) { + set_max_row(screen, handshake.rows); + set_max_col(screen, handshake.cols); +#ifdef TTYSIZE_STRUCT + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = 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 (!getenv("HOME")) + xtermSetenv("HOME=", pw->pw_dir); + if (!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 (!TEK4014_ACTIVE(screen) && *newtc) { + strcpy(termcap, newtc); + resize(screen, termcap, newtc); + } + if (term->misc.titeInhibit && !term->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 = 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 */ + + /* need to reset after all the ioctl bashing we did above */ +#if OPT_PTY_HANDSHAKE + if (resource.ptyHandshake) { +#ifdef TTYSIZE_STRUCT + i = SET_TTYSIZE(0, ts); + TRACE(("spawn 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 = getenv("SHELL")) == NULL || *ptr == 0) && + ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) || + *(ptr = pw->pw_shell) == 0)) { + ptr = "/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) { + 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", + xterm_name, *command_to_exec_with_luit, strerror(errno)); + fprintf(stderr, "%s: cannot support your locale.\n", + xterm_name); + } +#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", + xterm_name, *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 (term->misc.login_shell && pw && added_utmp_entry) + execl(bin_login, "login", "-p", "-f", login_name, (void *) 0); +#endif + execlp(ptr, + (term->misc.login_shell ? shname_minus : shname), + (void *) 0); + + /* Exec failed. */ + fprintf(stderr, "%s: Could not exec %s: %s\n", xterm_name, + ptr, strerror(errno)); + (void) 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; + } + + 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. + */ + (void) 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", + xterm_name, strerror(errno)); + handshake.status = PTY_NOMORE; + write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); + exit(ERROR_PTYS); + } + handshake.status = PTY_NEW; + (void) strcpy(handshake.buffer, ttydev); + write(pc_pipe[1], (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; + default: + fprintf(stderr, "%s: unexpected handshake status %d\n", + xterm_name, + (int) handshake.status); + } + } + /* close our sides of the pipes */ + if (!waiting_for_initial_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 spawn */ + +SIGNAL_T +Exit(int n) +{ + TScreen *screen = &term->screen; + +#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) + if (utmpGid != -1) { + /* Switch back to group utmp */ + setegid(utmpGid); + TRACE(("switched back to group %d (check: %d)\n", + utmpGid, (int) getgid())); + } +#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 (term->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 (term->misc.login_shell) + call_updwtmp(etc_wtmp, utptr); +#else + /* set wtmp entry if wtmp file exists */ + if (term->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(); + } +#else /* not USE_SYSV_UTMP */ + int wfd; + struct utmp utmp; + + if (!resource.utmpInhibit && added_utmp_entry && + (am_slave < 0 && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)) { + bzero((char *) &utmp, sizeof(utmp)); + lseek(wfd, (long) (tslot * sizeof(utmp)), 0); + write(wfd, (char *) &utmp, sizeof(utmp)); + close(wfd); +#ifdef WTMP + if (term->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)); + time(&utmp.ut_time); + write(wfd, (char *) &utmp, sizeof(utmp)); + close(wfd); + } +#endif /* WTMP */ + } +#endif /* USE_SYSV_UTMP */ +#endif /* HAVE_UTMP */ + close(screen->respond); /* close explicitly to avoid race with slave side */ +#ifdef ALLOWLOGGING + if (screen->logging) + CloseLog(screen); +#endif + + if (am_slave < 0) { + /* 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 + } +#if OPT_TRACE || defined(NO_LEAKS) + if (n == 0) { + TRACE(("Freeing memory leaks\n")); + if (term != 0) { + Display *dpy = term->screen.display; + + if (term->screen.sbuf_address) { + free(term->screen.sbuf_address); + TRACE(("freed screen.sbuf_address\n")); + } + if (term->screen.allbuf) { + free(term->screen.allbuf); + TRACE(("freed screen.allbuf\n")); + } + if (term->screen.xim) { + XCloseIM(term->screen.xim); + TRACE(("freed screen.xim\n")); + } + if (toplevel) { + XtDestroyWidget(toplevel); + TRACE(("destroyed top-level widget\n")); + } + XtCloseDisplay(dpy); + TRACE(("closed display\n")); + } + TRACE((0)); + } +#endif + + exit(n); + SIGNAL_RETURN; +} + +/* ARGSUSED */ +static void +resize(TScreen * screen, char *oldtc, char *newtc) +{ +#ifndef USE_SYSV_ENVVARS + char *ptr1, *ptr2; + size_t i; + int li_first = 0; + char *temp; + + 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 = ptr1 - oldtc); + temp = newtc + i; + sprintf(temp, "%d", (li_first + ? MaxRows(screen) + : MaxCols(screen))); + temp += strlen(temp); + ptr1 = strchr(ptr1, ':'); + strncpy(temp, ptr1, i = ptr2 - ptr1); + temp += i; + sprintf(temp, "%d", (li_first + ? MaxCols(screen) + : MaxRows(screen))); + ptr2 = strchr(ptr2, ':'); + strcat(temp, ptr2); + TRACE((" ==> %s\n", newtc)); +#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 == term->screen.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, 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")); + 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)); + } + } +} + +#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 timeout = + {0, 0}; + + FD_ZERO(&set); + FD_SET(fd, &set); + if (Select(fd + 1, &set, NULL, NULL, &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 +#include +#include +#include +#include + +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/nx-X11/programs/xterm/main.c.NX.original b/nx-X11/programs/xterm/main.c.NX.original new file mode 100644 index 000000000..35ce9d928 --- /dev/null +++ b/nx-X11/programs/xterm/main.c.NX.original @@ -0,0 +1,4943 @@ +/* $XTermId: main.c,v 1.477 2005/11/13 23:10:36 tom Exp $ */ + +#if !defined(lint) && 0 +static char *rid = "$Xorg: main.c,v 1.7 2001/02/09 02:06:02 xorgcvs Exp $"; +#endif /* lint */ + +/* + * 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-2004,2005 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. + +******************************************************************/ + +/**************************************************************************/ +/* */ +/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/. */ +/* */ +/* NX-X11, NX protocol compression and NX extensions to this software */ +/* are copyright of NoMachine. Redistribution and use of the present */ +/* software is allowed according to terms specified in the file LICENSE */ +/* which comes in the source distribution. */ +/* */ +/* Check http://www.nomachine.com/licensing.html for applicability. */ +/* */ +/* NX and NoMachine are trademarks of NoMachine S.r.l. */ +/* */ +/* All rights reserved. */ +/* */ +/**************************************************************************/ + +/* $XFree86: xc/programs/xterm/main.c,v 3.199 2005/11/13 23:10:36 dickey Exp $ */ + +#ifdef NX_TRANS_EXIT + +/* + * Redefine the libc exit() function to be + * sure we get rid of proxy and detect any + * abnormal termination. + */ + +extern void NXTransExit(int code) __attribute__((noreturn)); + +#define exit(code) NXTransExit(code) + +#endif /* #ifdef NX_TRANS_EXIT */ + +/* main.c */ + +#define RES_OFFSET(field) XtOffsetOf(XTERM_RESOURCE, field) + +#include + +#include +#include + +#if OPT_TOOLBAR + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif /* OPT_TOOLBAR */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OPT_WIDE_CHARS +#include +#endif + +#ifdef __osf__ +#define USE_SYSV_SIGNALS +#define WTMP +#include /* openpty() */ +#endif + +#ifdef __sgi +#include /* 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 +#endif +#endif +#endif + +#ifdef __MVS__ +#define USE_SYSV_PGRP +#define USE_SYSV_SIGNALS +#endif + +#ifdef __CYGWIN__ +#define LASTLOG +#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 +#endif + +#ifndef TTY_GROUP_NAME +#define TTY_GROUP_NAME "tty" +#endif + +#include + +#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 /* for I_PUSH */ +#include /* 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 +#undef USE_SYSV_ENVVARS +#undef FIOCLEX +#undef FIONCLEX +#define setpgrp2 setpgrp +#include +#include +#endif + +#ifdef __hpux +#define HAS_BSD_GROUPS +#include +#endif /* __hpux */ + +#ifdef __osf__ +#define HAS_BSD_GROUPS +#undef USE_SYSV_PGRP +#define setpgrp setpgid +#endif + +#ifdef __sgi +#define HAS_BSD_GROUPS +#include +#endif /* __sgi */ + +#ifdef sun +#include +#endif + +#else /* } !SYSV { */ /* BSD systems */ + +#ifdef __QNX__ + +#ifndef __QNXNTO__ +#define ttyslot() 1 +#else +#define USE_SYSV_PGRP +extern __inline__ +ttyslot() +{ + 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 +#endif +#endif /* USE_POSIX_TERMIOS */ +#ifdef Lynx +#include +#else +#include +#endif +#ifndef __INTERIX +#define HAS_BSD_GROUPS +#endif +#endif /* !VMS */ +#endif /* !linux */ + +#endif /* __QNX__ */ + +#endif /* } !SYSV */ + +#if defined(SVR4) && !defined(__CYGWIN__) +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +#ifdef linux +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +/* Xpoll.h and 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 /* for NOFILE */ +#endif + +#if defined(BSD) && (BSD >= 199103) +#define WTMP +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +#include + +#ifdef __hpux +#include +#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 +#endif + +#if defined(UTMPX_FOR_UTMP) + +#include + +#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 + +#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 /* caution: glibc 2.3.5 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 +#endif /* PUCC_PTYD */ + +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) +#include /* openpty() */ +#endif + +#ifdef __FreeBSD__ +#include /* 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 + +#if defined(__SCO__) || (defined(ISC) && !defined(_POSIX_SOURCE)) +#undef SIGTSTP /* defined, but not the BSD way */ +#endif + +#ifdef SIGTSTP +#include +#endif + +#if defined(__SCO__) || defined(__UNIXWARE__) +#undef ECHOKE +#undef ECHOCTL +#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 + +#ifdef SYSV +extern char *ptsname(int); +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + extern int tgetent(char *ptr, char *name); + extern char *tgetstr(char *name, char **ptr); + +#ifdef __cplusplus +} +#endif +#ifndef VMS +static SIGNAL_T reapchild(int n); +static int spawn(void); +static void remove_termcap_entry(char *buf, char *str); +#ifdef USE_PTY_SEARCH +static int pty_search(int *pty); +#endif +#endif /* ! VMS */ + +static int get_pty(int *pty, char *from); +static void get_terminal(void); +static void resize(TScreen * s, char *oldtc, char *newtc); +static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode); + +static Bool added_utmp_entry = False; + +#if defined(USE_UTMP_SETGID) +static int utmpGid = -1; +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 spawn() 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 */ +#ifndef CBRK +#define CBRK 0 +#endif +#ifndef CDSUSP +#define CDSUSP CONTROL('Y') +#endif +#ifndef CEOF +#define CEOF CONTROL('D') +#endif +#ifndef CEOL +#define CEOL 0 +#endif +#ifndef CFLUSH +#define CFLUSH CONTROL('O') +#endif +#ifndef CINTR +#define CINTR 0177 +#endif +#ifndef CKILL +#define CKILL '@' +#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 + +#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) +#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) +#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 int override_tty_modes = 0; +/* *INDENT-OFF* */ +static struct _xttymodes { + char *name; + size_t len; + int set; + Char 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 */ +}; +/* *INDENT-ON* */ + +#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value + +static int parse_tty_modes(char *s, struct _xttymodes *modelist); + +#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 */ + +#ifndef USE_UTEMPTER +#ifdef USE_LASTLOG +static char etc_lastlog[] = LASTLOG_FILENAME; +#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 /* 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)); \ + } + +/* 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("keyboardType", "KeyboardType", keyboardType, "unknown"), + Bres("sunFunctionKeys", "SunFunctionKeys", sunFunctionKeys, False), +#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_INITIAL_ERASE + Bres("ptyInitialErase", "PtyInitialErase", ptyInitialErase, DEF_INITIAL_ERASE), + Bres("backarrowKeyIsErase", "BackarrowKeyIsErase", backarrow_is_erase, DEF_BACKARO_ERASE), +#endif + Bres("waitForMap", "WaitForMap", wait_for_map, False), + Bres("useInsertMode", "UseInsertMode", useInsertMode, False), +#if OPT_ZICONBEEP + Ires("zIconBeep", "ZIconBeep", zIconBeep, 0), +#endif +#if OPT_PTY_HANDSHAKE + Bres("ptyHandshake", "PtyHandshake", ptyHandshake, True), +#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 +}; + +static char *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, (caddr_t) NULL}, +{"-132", "*c132", XrmoptionNoArg, (caddr_t) "on"}, +{"+132", "*c132", XrmoptionNoArg, (caddr_t) "off"}, +{"-ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "on"}, +{"+ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "off"}, +{"-aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "off"}, +#ifndef NO_ACTIVE_ICON +{"-ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "off"}, +{"+ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "on"}, +#endif /* NO_ACTIVE_ICON */ +{"-b", "*internalBorder",XrmoptionSepArg, (caddr_t) NULL}, +{"-bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "on"}, +{"+bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "off"}, +{"-bcf", "*cursorOffTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bcn", "*cursorOnTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-cc", "*charClass", XrmoptionSepArg, (caddr_t) NULL}, +{"-cm", "*colorMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+cm", "*colorMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "off"}, +{"+cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "on"}, +{"-cr", "*cursorColor", XrmoptionSepArg, (caddr_t) NULL}, +{"-cu", "*curses", XrmoptionNoArg, (caddr_t) "on"}, +{"+cu", "*curses", XrmoptionNoArg, (caddr_t) "off"}, +{"-dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "off"}, +{"+dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "on"}, +{"-fb", "*boldFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"on"}, +{"-fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"on"}, +#ifndef NO_ACTIVE_ICON +{"-fi", "*iconFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif /* NO_ACTIVE_ICON */ +#if OPT_RENDERFONT +{"-fa", "*faceName", XrmoptionSepArg, (caddr_t) NULL}, +{"-fd", "*faceNameDoublesize", XrmoptionSepArg, (caddr_t) NULL}, +{"-fs", "*faceSize", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_WIDE_CHARS +{"-fw", "*wideFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fwb", "*wideBoldFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_INPUT_METHOD +{"-fx", "*ximFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HIGHLIGHT_COLOR +{"-hc", "*highlightColor", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HP_FUNC_KEYS +{"-hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "on"}, +{"+hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-hold", "*hold", XrmoptionNoArg, (caddr_t) "on"}, +{"+hold", "*hold", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_INITIAL_ERASE +{"-ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "on"}, +{"+ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_C1_PRINT +{"-k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "on"}, +{"+k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +{"+kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +/* parse logging options anyway for compatibility */ +{"-l", "*logging", XrmoptionNoArg, (caddr_t) "on"}, +{"+l", "*logging", XrmoptionNoArg, (caddr_t) "off"}, +{"-lf", "*logFile", XrmoptionSepArg, (caddr_t) NULL}, +{"-ls", "*loginShell", XrmoptionNoArg, (caddr_t) "on"}, +{"+ls", "*loginShell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mb", "*marginBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+mb", "*marginBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mc", "*multiClickTime", XrmoptionSepArg, (caddr_t) NULL}, +{"-mesg", "*messages", XrmoptionNoArg, (caddr_t) "off"}, +{"+mesg", "*messages", XrmoptionNoArg, (caddr_t) "on"}, +{"-ms", "*pointerColor",XrmoptionSepArg, (caddr_t) NULL}, +{"-nb", "*nMarginBell", XrmoptionSepArg, (caddr_t) NULL}, +{"-nul", "*underLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+nul", "*underLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-pc", "*boldColors", XrmoptionNoArg, (caddr_t) "on"}, +{"+pc", "*boldColors", XrmoptionNoArg, (caddr_t) "off"}, +{"-rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "off"}, +{"-s", "*multiScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+s", "*multiScroll", XrmoptionNoArg, (caddr_t) "off"}, +{"-sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "on"}, +{"+sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "off"}, +#ifdef SCROLLBAR_RIGHT +{"-leftbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "off"}, +{"-rightbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "on"}, +#endif +{"-rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "on"}, +{"+sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "off"}, +{"-si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "off"}, +{"+si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "on"}, +{"-sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "on"}, +{"+sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "off"}, +{"-sl", "*saveLines", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_SUNPC_KBD +{"-sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "on"}, +{"+sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TEK4014 +{"-t", "*tekStartup", XrmoptionNoArg, (caddr_t) "on"}, +{"+t", "*tekStartup", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-ti", "*decTerminalID",XrmoptionSepArg, (caddr_t) NULL}, +{"-tm", "*ttyModes", XrmoptionSepArg, (caddr_t) NULL}, +{"-tn", "*termName", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_WIDE_CHARS +{"-u8", "*utf8", XrmoptionNoArg, (caddr_t) "2"}, +{"+u8", "*utf8", XrmoptionNoArg, (caddr_t) "0"}, +#endif +#if OPT_LUIT_PROG +{"-lc", "*locale", XrmoptionNoArg, (caddr_t) "on"}, +{"+lc", "*locale", XrmoptionNoArg, (caddr_t) "off"}, +{"-lcc", "*localeFilter",XrmoptionSepArg, (caddr_t) NULL}, +{"-en", "*locale", XrmoptionSepArg, (caddr_t) NULL}, +#endif +{"-ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "on"}, +{"+ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "off"}, +{"-im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "on"}, +{"+im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "off"}, +{"-vb", "*visualBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_WIDE_CHARS +{"-wc", "*wideChars", XrmoptionNoArg, (caddr_t) "on"}, +{"+wc", "*wideChars", XrmoptionNoArg, (caddr_t) "off"}, +{"-mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "off"}, +{"-cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"}, +{"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_ZICONBEEP +{"-ziconbeep", "*zIconBeep", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_SAME_NAME +{"-samename", "*sameName", XrmoptionNoArg, (caddr_t) "on"}, +{"+samename", "*sameName", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_SESSION_MGT +{"-sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "on"}, +{"+sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TOOLBAR +{"-tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "on"}, +{"+tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "off"}, +#endif +/* options that we process ourselves */ +{"-help", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-version", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-class", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +{"-e", NULL, XrmoptionSkipLine, (caddr_t) NULL}, +{"-into", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +/* bogus old compatibility stuff for which there are + standard XtOpenApplication options now */ +{"%", "*tekGeometry", XrmoptionStickyArg, (caddr_t) NULL}, +{"#", ".iconGeometry",XrmoptionStickyArg, (caddr_t) NULL}, +{"-T", ".title", XrmoptionSepArg, (caddr_t) NULL}, +{"-n", "*iconName", XrmoptionSepArg, (caddr_t) NULL}, +{"-r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-w", ".borderWidth", XrmoptionSepArg, (caddr_t) 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 +{ "-hc color", "selection background 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 +{ "-/+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 +{ NULL, NULL }}; +/* *INDENT-ON* */ + +static 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(127); + 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; +} + +/* + * If we're linked to terminfo, tgetent() will return an empty buffer. We + * cannot use that to adjust the $TERMCAP variable. + */ +static Bool +get_termcap(char *name, char *buffer, char *resized) +{ + TScreen *screen = &term->screen; + + *buffer = 0; /* initialize, in case we're using terminfo's tgetent */ + + if (name != 0) { + if (tgetent(buffer, name) == 1) { + TRACE(("get_termcap(%s) succeeded (%s)\n", name, + (*buffer + ? "ok:termcap, we can update $TERMCAP" + : "assuming this is terminfo"))); + if (*buffer) { + if (!TEK4014_ACTIVE(screen)) { + resize(screen, buffer, resized); + } + } + return True; + } else { + *buffer = 0; /* just in case */ + } + } + return False; +} + +static int +abbrev(char *tst, 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 + strlen(ProgramName); + for (opt = list; opt->opt; opt++) { + int len = 3 + 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)); + 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; +} +#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 (term->screen.Tshow) + hide_vt_window(); + else + do_hangup(w, (XtPointer) 0, (XtPointer) 0); + } else if (term->screen.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 = 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 = 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 */ + +int +main(int argc, char *argv[]ENVP_ARG) +{ + Widget form_top, menu_top; + TScreen *screen; + int mode; + char *my_class = DEFCLASS; + Window winToEmbedInto = None; + +#ifdef DISABLE_SETUID + if (seteuid(getuid()) == -1) + exit(2); + if (setuid(getuid()) == -1) + exit(2); +#endif + + ProgramName = argv[0]; + + /* 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); + if (seteuid(getuid()) == -1) { + fprintf(stderr, + "%s: unable to change back euid\n", ProgramName); + exit(1); + } + if (setuid(getuid()) == -1) { + fprintf(stderr, + "%s: unable to change back uid\n", ProgramName); + exit(1); + } +#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; + 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 { + 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). + */ + 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 +#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 /* } */ + + d_tio.c_cc[VINTR] = CINTR; + d_tio.c_cc[VQUIT] = CQUIT; + d_tio.c_cc[VERASE] = CERASE; + d_tio.c_cc[VKILL] = CKILL; + d_tio.c_cc[VEOF] = CEOF; + d_tio.c_cc[VEOL] = CNUL; + d_tio.c_cc[VEOL2] = CNUL; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = CNUL; +#endif + +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ + d_tio.c_cc[VSUSP] = CSUSP; +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CDSUSP; +#endif + d_tio.c_cc[VREPRINT] = CRPRNT; + d_tio.c_cc[VDISCARD] = CFLUSH; + d_tio.c_cc[VWERASE] = CWERASE; + d_tio.c_cc[VLNEXT] = CLNEXT; + d_tio.c_cc[VMIN] = 1; + d_tio.c_cc[VTIME] = 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 + d_tio.c_cc[VINTR] = CONTROL('C'); /* '^C' */ + d_tio.c_cc[VERASE] = 0x7f; /* 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; /* '^@' */ + d_tio.c_cc[VMIN] = 1; + d_tio.c_cc[VTIME] = 0; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = CSWTCH; /* usually '^Z' */ +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = CLNEXT; +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = CWERASE; +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = CRPRNT; +#endif +#ifdef VRPRNT + d_tio.c_cc[VRPRNT] = CRPRNT; +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = CFLUSH; +#endif +#ifdef VFLUSHO + d_tio.c_cc[VFLUSHO] = CFLUSH; +#endif +#ifdef VSTOP + d_tio.c_cc[VSTOP] = CSTOP; +#endif +#ifdef VSTART + d_tio.c_cc[VSTART] = CSTART; +#endif +#ifdef VSUSP + d_tio.c_cc[VSUSP] = CSUSP; +#endif +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CDSUSP; +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = CSTATUS; +#endif + /* now, try to inherit tty settings */ + { + int i; + + for (i = 0; i <= 2; i++) { + TERMIO_STRUCT deftio; + if (ttyGetAttr(i, &deftio) == 0) { + d_tio.c_cc[VINTR] = deftio.c_cc[VINTR]; + d_tio.c_cc[VQUIT] = deftio.c_cc[VQUIT]; + d_tio.c_cc[VERASE] = deftio.c_cc[VERASE]; + d_tio.c_cc[VKILL] = deftio.c_cc[VKILL]; + d_tio.c_cc[VEOF] = deftio.c_cc[VEOF]; + d_tio.c_cc[VEOL] = deftio.c_cc[VEOL]; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = deftio.c_cc[VSWTCH]; +#endif +#ifdef VEOL2 + d_tio.c_cc[VEOL2] = deftio.c_cc[VEOL2]; +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = deftio.c_cc[VLNEXT]; +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = deftio.c_cc[VWERASE]; +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = deftio.c_cc[VREPRINT]; +#endif +#ifdef VRPRNT + d_tio.c_cc[VRPRNT] = deftio.c_cc[VRPRNT]; +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = deftio.c_cc[VDISCARD]; +#endif +#ifdef VFLUSHO + d_tio.c_cc[VFLUSHO] = deftio.c_cc[VFLUSHO]; +#endif +#ifdef VSTOP + d_tio.c_cc[VSTOP] = deftio.c_cc[VSTOP]; +#endif +#ifdef VSTART + d_tio.c_cc[VSTART] = deftio.c_cc[VSTART]; +#endif +#ifdef VSUSP + d_tio.c_cc[VSUSP] = deftio.c_cc[VSUSP]; +#endif +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = deftio.c_cc[VDSUSP]; +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = deftio.c_cc[VSTATUS]; +#endif + break; + } + } + } +#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 */ +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ + d_tio.c_cc[VSUSP] = CSUSP; +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CharOf('\000'); +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = CharOf('\377'); +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = CharOf('\377'); +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = CharOf('\377'); +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = CharOf('\377'); +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = CharOf('\377'); +#endif +#endif /* } USE_TERMIOS */ +#ifdef TIOCLSET /* { */ + d_lmode = 0; +#endif /* } TIOCLSET */ +#endif /* } macII, ATT, CRAY */ +#endif /* } TERMIO_STRUCT */ + + /* Init the Toolkit. */ + { +#ifdef HAS_SAVED_IDS_AND_SETEUID + uid_t euid = geteuid(); + gid_t egid = getegid(); + uid_t ruid = getuid(); + gid_t rgid = getgid(); + + if (setegid(rgid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) /* could happen if _BPX_SHAREAS=REUSE */ +#endif + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) rgid, strerror(errno)); + } + + if (seteuid(ruid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) ruid, strerror(errno)); + } +#endif + + XtSetErrorHandler(xt_error); +#if OPT_SESSION_MGT + toplevel = XtOpenApplication(&app_con, my_class, + optionDescList, + XtNumber(optionDescList), + &argc, argv, fallback_resources, + sessionShellWidgetClass, + NULL, 0); +#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(); + +#ifdef HAS_SAVED_IDS_AND_SETEUID + if (seteuid(euid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) euid, strerror(errno)); + } + + if (setegid(egid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) egid, strerror(errno)); + } +#endif + +#if defined(USE_UTMP_SETGID) + if (resource.utmpInhibit) { + /* Can totally revoke group privs */ + setegid(getgid()); + setgid(getgid()); + } +#endif + } + + waiting_for_initial_map = resource.wait_for_map; + + /* + * 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 = 1; + } + } +#if OPT_ZICONBEEP + zIconBeep = resource.zIconBeep; + zIconBeep_flagged = False; + if (zIconBeep > 100 || zIconBeep < -100) { + 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 */ +#if OPT_SAME_NAME + sameName = resource.sameName; +#endif + 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 == getuid()) && + !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); + + 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, +#endif + (XtPointer) 0); + decode_keyboard_type(&resource); + + screen = &term->screen; + 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) + screen->TekEmu = False; + + if (screen->TekEmu && !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[4]; + 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(getuid(), getgid(), False, dbglogfile, 0666)) { + 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 */ + + /* open a terminal for client */ + get_terminal(); + + spawn(); + +#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(screen)))); + 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 +#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(screen); + } +#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); + } + + for (;;) { +#if OPT_TEK4014 + if (screen->TekEmu) + TekRun(); + else +#endif + VTRun(); + } +} + +#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS)) || 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), + getuid(), 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 spawn(). That's the reason + for the "if (IsPts)" statement in spawn(); 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 */ + + 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(getuid(), getgid(), 0600U); + seteuid(getuid()); + +#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 */ + +/* + * sets up X and initializes the terminal structure except for term.buf.fildes. + */ +static void +get_terminal(void) +{ + TScreen *screen = &term->screen; + + screen->arrow = make_colored_cursor(XC_left_ptr, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); +} + +/* + * 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) +{ + siglongjmp(env, 1); + SIGNAL_RETURN; +} + +/* + * declared outside OPT_PTY_HANDSHAKE so HsSysError() callers can use + */ +static int cp_pipe[2]; /* this pipe is used for child to parent transfer */ + +#if OPT_PTY_HANDSHAKE +static int pc_pipe[2]; /* 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; + +/* 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 pf, int error) +{ + handshake_t handshake; + + handshake.status = PTY_FATALERROR; + handshake.error = errno; + handshake.fatal_error = error; + strcpy(handshake.buffer, ttydev); + write(pf, (char *) &handshake, sizeof(handshake)); + exit(error); +} + +void +first_map_occurred(void) +{ + handshake_t handshake; + TScreen *screen = &term->screen; + + handshake.status = PTY_EXEC; + handshake.rows = screen->max_row; + handshake.cols = screen->max_col; + write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); + close(cp_pipe[0]); + close(pc_pipe[1]); + waiting_for_initial_map = False; +} +#else +/* + * temporary hack to get xterm working on att ptys + */ +static void +HsSysError(int pf GCC_UNUSED, int error) +{ + fprintf(stderr, "%s: fatal pty error %d (errno=%d) on tty %s\n", + xterm_name, error, errno, ttydev); + exit(error); +} + +void +first_map_occurred(void) +{ + return; +} +#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(("set_owner(%s, uid=%d, gid=%d, mode=%#o\n", device, uid, gid, mode)); + + if (chown(device, uid, gid) < 0) { + why = errno; + if (why != ENOENT + && getuid() == 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 %03o currently %03o: %s\n", + device, (unsigned) mode, (sb.st_mode & 0777U), + strerror(why)); + TRACE(("...stat uid=%d, gid=%d, mode=%#o\n", + sb.st_uid, sb.st_gid, 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 + +/* + * 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 +spawn(void) +{ + TScreen *screen = &term->screen; +#if OPT_PTY_HANDSHAKE + handshake_t handshake; + int done; +#endif +#if OPT_INITIAL_ERASE + int initial_erase = VAL_INITIAL_ERASE; +#endif + int rc = 0; + int ttyfd = -1; + +#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 termcap[TERMCAP_SIZE]; + char newtc[TERMCAP_SIZE]; + char *ptr, *shname, *shname_minus; + int i, no_dev_tty = False; + char **envnew; /* new environment */ + int envsize; /* elements in 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 lastlog; +#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 = getuid(); + screen->gid = getgid(); + + termcap[0] = '\0'; + newtc[0] = '\0'; + +#ifdef SIGTTOU + /* so that TIOCSWINSZ || TIOCSIZE doesn't block */ + signal(SIGTTOU, SIG_IGN); +#endif + + if (am_slave >= 0) { + screen->respond = am_slave; + set_pty_id(ttydev, passedPty); +#ifdef USE_PTY_DEVICE + set_pty_id(ptydev, passedPty); +#endif + setgid(screen->gid); + setuid(screen->uid); + } 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; + } +#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. + */ + no_dev_tty = False; + 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) { + no_dev_tty = True; +#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, <c) == -1) + ltc = d_ltc; +#endif /* HAS_LTCHARS */ +#ifdef TIOCLSET + if (ioctl(ttyfd, TIOCLGET, &lmode) == -1) + lmode = d_lmode; +#endif /* TIOCLSET */ +#ifdef TERMIO_STRUCT + if ((rc = ttyGetAttr(ttyfd, &tio)) == -1) + tio = d_tio; +#else /* !TERMIO_STRUCT */ + if ((rc = ioctl(ttyfd, TIOCGETP, (char *) &sg)) == -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; + if ((rc = ttyGetAttr(screen->respond, &my_tio)) == 0) + initial_erase = my_tio.c_cc[VERASE]; +#else /* !TERMIO_STRUCT */ + struct sgttyb my_sg; + if ((rc = ioctl(screen->respond, TIOCGETP, (char *) &my_sg)) == 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(XtParent(CURRENT_EMU(screen)), False); + + wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", + False); + + if (!TEK4014_ACTIVE(screen)) + VTInit(); /* 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(XtParent(CURRENT_EMU(screen)), + mit_console, CurrentTime, + ConvertConsoleSelection, NULL, NULL); + } +#endif +#if OPT_TEK4014 + if (screen->TekEmu) { + envnew = tekterm; + ptr = newtc; + } else +#endif + { + envnew = vtterm; + ptr = termcap; + } + + /* + * 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. + */ + if (!get_termcap(TermName = resource.term_name, ptr, newtc)) { + char *last = NULL; + TermName = *envnew; + while (*envnew != NULL) { + if ((last == NULL || strcmp(last, *envnew)) + && get_termcap(*envnew, ptr, newtc)) { + TermName = *envnew; + break; + } + last = *envnew; + envnew++; + } + } + + /* + * 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 ")); + if (!resource.ptyInitialErase) { + char temp[1024], *p = temp; + char *s = tgetstr(TERMCAP_ERASE, &p); + TRACE(("...extracting initial_erase value from termcap\n")); + if (s != 0) { + initial_erase = decode_keyvalue(&s, True); + } + } + 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 == 127) { + term->keyboard.flags &= ~MODE_DECBKM; + } else { + term->keyboard.flags |= MODE_DECBKM; + term->keyboard.reset_DECBKM = 1; + } + TRACE(("...sets DECBKM %s\n", + (term->keyboard.flags & MODE_DECBKM) ? "on" : "off")); + } else { + term->keyboard.reset_DECBKM = 2; + } +#endif /* OPT_INITIAL_ERASE */ + +#ifdef TTYSIZE_STRUCT + /* tell tty how big window is */ +#if OPT_TEK4014 + if (TEK4014_ACTIVE(screen)) { + TTYSIZE_ROWS(ts) = 38; + TTYSIZE_COLS(ts) = 81; +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = TFullWidth(screen); + ts.ws_ypixel = TFullHeight(screen); +#endif + } else +#endif + { + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = FullHeight(screen); +#endif + } + 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) { + /* + * now in child process + */ + TRACE_CHILD +#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 + +#ifdef USE_USG_PTYS +#ifdef USE_ISPTS_FLAG + if (IsPts) { /* SYSV386 supports both, which did we open? */ +#endif + int ptyfd = 0; + char *pty_name = 0; + + setpgrp(); + grantpt(screen->respond); + unlockpt(screen->respond); + if ((pty_name = ptsname(screen->respond)) == 0) { + SysError(ERROR_PTSNAME); + } + if ((ptyfd = open(pty_name, O_RDWR)) < 0) { + SysError(ERROR_OPPTSNAME); + } +#ifdef I_PUSH + if (ioctl(ptyfd, I_PUSH, "ptem") < 0) { + SysError(ERROR_PTEM); + } +#if !defined(SVR4) && !(defined(SYSV) && defined(i386)) + if (!getenv("CONSEM") && ioctl(ptyfd, I_PUSH, "consem") < 0) { + SysError(ERROR_CONSEM); + } +#endif /* !SVR4 */ + if (ioctl(ptyfd, I_PUSH, "ldterm") < 0) { + SysError(ERROR_LDTERM); + } +#ifdef SVR4 /* from Sony */ + 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(screen)) { + TTYSIZE_ROWS(ts) = 24; + TTYSIZE_COLS(ts) = 80; +#ifdef USE_STRUCT_WINSIZE + ts.ws_xpixel = TFullWidth(screen); + ts.ws_ypixel = TFullHeight(screen); +#endif + } else +#endif /* OPT_TEK4014 */ + { + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#ifdef USE_STRUCT_WINSIZE + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = 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) { + (void) close(cp_pipe[1]); + cp_pipe[1] = i; + } + } + if (pc_pipe[0] <= 2) { + if ((i = fcntl(pc_pipe[0], F_DUPFD, 3)) >= 0) { + (void) 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__ + 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) + (void) setsid(); +#else + (void) 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__ */ + } + + while (1) { +#if defined(TIOCNOTTY) && (!defined(__GLIBC__) || (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))) + if (!no_dev_tty + && (ttyfd = open("/dev/tty", O_RDWR)) >= 0) { + ioctl(ttyfd, TIOCNOTTY, (char *) NULL); + close_fd(ttyfd); + } +#endif /* TIOCNOTTY && !glibc >= 2.1 */ +#ifdef CSRG_BASED + (void) revoke(ttydev); +#endif + if ((ttyfd = open(ttydev, O_RDWR)) >= 0) { +#if defined(CRAY) && defined(TCSETCTTY) + /* make /dev/tty work */ + ioctl(ttyfd, TCSETCTTY, 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); + write(cp_pipe[1], (char *) &handshake, + sizeof(handshake)); + + /* get reply from parent */ + i = 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 = CastMallocN(char, strlen(handshake.buffer)); + if (ttydev == NULL) { + SysError(ERROR_SPREALLOC); + } + strcpy(ttydev, handshake.buffer); + } + + /* use the same tty name that everyone else will use + * (from ttyname) + */ + if ((ptr = ttyname(ttyfd)) != 0) { + /* it may be bigger */ + ttydev = TypeRealloc(char, strlen(ptr) + 1, ttydev); + if (ttydev == NULL) { + SysError(ERROR_SPREALLOC); + } + (void) strcpy(ttydev, 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 */ + 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 + 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 + 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 +#ifndef __MVS__ + /* reset EOL to default value */ + tio.c_cc[VEOL] = CEOL; /* '^@' */ + /* certain shells (ksh & csh) change EOF as well */ + tio.c_cc[VEOF] = CEOF; /* '^D' */ +#else + if (tio.c_cc[VEOL] == 0) + tio.c_cc[VEOL] = CEOL; /* '^@' */ + if (tio.c_cc[VEOF] == 0) + tio.c_cc[VEOF] = CEOF; /* '^D' */ +#endif +#ifdef VLNEXT + tio.c_cc[VLNEXT] = CLNEXT; +#endif +#ifdef VWERASE + tio.c_cc[VWERASE] = CWERASE; +#endif +#ifdef VREPRINT + tio.c_cc[VREPRINT] = CRPRNT; +#endif +#ifdef VRPRNT + tio.c_cc[VRPRNT] = CRPRNT; +#endif +#ifdef VDISCARD + tio.c_cc[VDISCARD] = CFLUSH; +#endif +#ifdef VFLUSHO + tio.c_cc[VFLUSHO] = CFLUSH; +#endif +#ifdef VSTOP + tio.c_cc[VSTOP] = CSTOP; +#endif +#ifdef VSTART + tio.c_cc[VSTART] = CSTART; +#endif +#ifdef VSUSP + tio.c_cc[VSUSP] = CSUSP; +#endif +#ifdef VDSUSP + tio.c_cc[VDSUSP] = CDSUSP; +#endif + if (override_tty_modes) { + /* sysv-specific */ + TMODE(XTTYMODE_intr, tio.c_cc[VINTR]); + TMODE(XTTYMODE_quit, tio.c_cc[VQUIT]); + TMODE(XTTYMODE_erase, tio.c_cc[VERASE]); + TMODE(XTTYMODE_kill, tio.c_cc[VKILL]); + TMODE(XTTYMODE_eof, tio.c_cc[VEOF]); + TMODE(XTTYMODE_eol, tio.c_cc[VEOL]); +#ifdef VSWTCH + TMODE(XTTYMODE_swtch, tio.c_cc[VSWTCH]); +#endif +#ifdef VSUSP + TMODE(XTTYMODE_susp, tio.c_cc[VSUSP]); +#endif +#ifdef VDSUSP + TMODE(XTTYMODE_dsusp, tio.c_cc[VDSUSP]); +#endif +#ifdef VREPRINT + TMODE(XTTYMODE_rprnt, tio.c_cc[VREPRINT]); +#endif +#ifdef VRPRNT + TMODE(XTTYMODE_rprnt, tio.c_cc[VRPRNT]); +#endif +#ifdef VDISCARD + TMODE(XTTYMODE_flush, tio.c_cc[VDISCARD]); +#endif +#ifdef VFLUSHO + TMODE(XTTYMODE_flush, tio.c_cc[VFLUSHO]); +#endif +#ifdef VWERASE + TMODE(XTTYMODE_weras, tio.c_cc[VWERASE]); +#endif +#ifdef VLNEXT + TMODE(XTTYMODE_lnext, tio.c_cc[VLNEXT]); +#endif +#ifdef VSTART + TMODE(XTTYMODE_start, tio.c_cc[VSTART]); +#endif +#ifdef VSTOP + TMODE(XTTYMODE_stop, tio.c_cc[VSTOP]); +#endif +#ifdef VSTATUS + TMODE(XTTYMODE_status, tio.c_cc[VSTATUS]); +#endif +#ifdef VERASE2 + TMODE(XTTYMODE_erase2, tio.c_cc[VERASE2]); +#endif +#ifdef VEOL2 + TMODE(XTTYMODE_eol2, tio.c_cc[VEOL2]); +#endif +#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, <c) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETC); +#endif /* HAS_LTCHARS */ +#ifdef TIOCLSET + if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCLSET); +#endif /* TIOCLSET */ + if (ttySetAttr(ttyfd, &tio) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETP); + + /* ignore errors here - some platforms don't work */ + 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(cp_pipe[1], ERROR_TIOCSETP); + if (ioctl(ttyfd, TIOCSETC, (char *) &tc) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETC); + if (ioctl(ttyfd, TIOCSETD, (char *) &discipline) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETD); + if (ioctl(ttyfd, TIOCSLTC, (char *) <c) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSLTC); + if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCLSET); +#ifdef sony + if (ioctl(ttyfd, TIOCKSET, (char *) &jmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCKSET); + if (ioctl(ttyfd, TIOCKSETC, (char *) &jtc) == -1) + HsSysError(cp_pipe[1], 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", + xterm_name, 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", + xterm_name, strerror(errno)); + (void) 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 make the parent process set the + * terminal's erase mode, and if we had no ttyModes 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, + (!resource.ptyInitialErase + && !override_tty_modes + && !ttymodelist[XTTYMODE_erase].set) + ? "YES" : "NO", + resource.ptyInitialErase, + override_tty_modes, + ttymodelist[XTTYMODE_erase].set)); + if (!resource.ptyInitialErase + && !override_tty_modes + && !ttymodelist[XTTYMODE_erase].set) { +#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; + 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 + + /* copy the environment before Setenv'ing */ + for (i = 0; environ[i] != NULL; i++) ; + /* compute number of xtermSetenv() calls below */ + envsize = 1; /* (NULL terminating entry) */ + envsize += 5; /* TERM, WINDOWID, DISPLAY, _SHELL, _VERSION */ +#ifdef HAVE_UTMP + envsize += 1; /* LOGNAME */ +#endif /* HAVE_UTMP */ +#ifdef USE_SYSV_ENVVARS + envsize += 2; /* COLUMNS, LINES */ +#ifdef HAVE_UTMP + envsize += 2; /* HOME, SHELL */ +#endif /* HAVE_UTMP */ +#ifdef OWN_TERMINFO_DIR + envsize += 1; /* TERMINFO */ +#endif +#else /* USE_SYSV_ENVVARS */ + envsize += 1; /* TERMCAP */ +#endif /* USE_SYSV_ENVVARS */ + envnew = TypeCallocN(char *, (unsigned) i + envsize); + memmove((char *) envnew, (char *) environ, i * sizeof(char *)); + environ = envnew; + xtermSetenv("TERM=", TermName); + if (!TermName) + *newtc = 0; + + sprintf(buf, "%lu", + ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU(screen))))); + xtermSetenv("WINDOWID=", buf); + + /* put the display into the environment of the shell */ + xtermSetenv("DISPLAY=", XDisplayString(screen->display)); + + xtermSetenv("XTERM_VERSION=", xtermVersion()); + + 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); + + (void) close(0); + + if (open("/dev/tty", O_RDWR)) { + SysError(ERROR_OPDEVTTY); + } + (void) close(1); + (void) close(2); + dup(0); + dup(0); +#else + /* dup the tty */ + for (i = 0; i <= 2; i++) + if (i != ttyfd) { + (void) close(i); + (void) 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 = getenv("LOGNAME")) != NULL + || (login_name = 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_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 */ + if (!(utret = find_utmp(&utmp))) { + (void) call_setutent(); + init_utmp(USER_PROCESS, &utmp); + if (!(utret = find_utmp(&utmp))) { + (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", + 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 + (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 (term->misc.login_shell) + updwtmpx(WTMPX_FILE, &utmp); +#elif defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)) + if (term->misc.login_shell) + call_updwtmp(etc_wtmp, &utmp); +#else + if (term->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) { + bzero((char *) &utmp, 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 + /* cast needed on Ultrix 4.4 */ + time((time_t *) & utmp.ut_time); + lseek(i, (long) (tslot * sizeof(utmp)), 0); + write(i, (char *) &utmp, sizeof(utmp)); + close(i); + added_utmp_entry = True; +#if defined(WTMP) + if (term->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 (term->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 (term->misc.login_shell) { + bzero((char *) &lastlog, sizeof(lastlog)); + (void) strncpy(lastlog.ll_line, + my_pty_name(ttydev), + sizeof(lastlog.ll_line)); + X_GETTIMEOFDAY(&lastlog.ll_tv); + SetUtmpHost(lastlog.ll_host, screen); + updlastlogx(_PATH_LASTLOGX, screen->uid, &lastlog); + } +#endif + +#ifdef USE_LASTLOG + if (term->misc.login_shell && + (i = open(etc_lastlog, O_WRONLY)) >= 0) { + bzero((char *) &lastlog, sizeof(struct lastlog)); + (void) strncpy(lastlog.ll_line, + my_pty_name(ttydev), + sizeof(lastlog.ll_line)); + SetUtmpHost(lastlog.ll_host, screen); + time(&lastlog.ll_time); + lseek(i, (long) (screen->uid * sizeof(struct lastlog)), 0); + write(i, (char *) &lastlog, sizeof(struct lastlog)); + close(i); + } +#endif /* USE_LASTLOG */ + +#if defined(USE_UTMP_SETGID) + /* Switch to real gid after writing utmp entry */ + utmpGid = getegid(); + if (getgid() != getegid()) { + utmpGid = getegid(); + setegid(getgid()); + TRACE(("switch to real gid %d after writing utmp\n", getgid())); + } +#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); + (void) write(cp_pipe[1], (char *) &handshake, sizeof(handshake)); + } +#endif /* OPT_PTY_HANDSHAKE */ +#endif /* USE_UTEMPTER */ +#endif /* HAVE_UTMP */ + + (void) setgid(screen->gid); +#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); + } +#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); + (void) write(cp_pipe[1], (char *) &handshake, sizeof(handshake)); + + if (waiting_for_initial_map) { + i = 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) { + set_max_row(screen, handshake.rows); + set_max_col(screen, handshake.cols); +#ifdef TTYSIZE_STRUCT + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = 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 (!getenv("HOME")) + xtermSetenv("HOME=", pw->pw_dir); + if (!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 (!TEK4014_ACTIVE(screen) && *newtc) { + strcpy(termcap, newtc); + resize(screen, termcap, newtc); + } + if (term->misc.titeInhibit && !term->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 = 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 */ + + /* need to reset after all the ioctl bashing we did above */ +#if OPT_PTY_HANDSHAKE + if (resource.ptyHandshake) { +#ifdef TTYSIZE_STRUCT + i = SET_TTYSIZE(0, ts); + TRACE(("spawn 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 = getenv("SHELL")) == NULL || *ptr == 0) && + ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) || + *(ptr = pw->pw_shell) == 0)) { + ptr = "/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) { + 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", + xterm_name, *command_to_exec_with_luit, strerror(errno)); + fprintf(stderr, "%s: cannot support your locale.\n", + xterm_name); + } +#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", + xterm_name, *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 (term->misc.login_shell && pw && added_utmp_entry) + execl(bin_login, "login", "-p", "-f", login_name, (void *) 0); +#endif + execlp(ptr, + (term->misc.login_shell ? shname_minus : shname), + (void *) 0); + + /* Exec failed. */ + fprintf(stderr, "%s: Could not exec %s: %s\n", xterm_name, + ptr, strerror(errno)); + (void) 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; + } + + 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. + */ + (void) 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", + xterm_name, strerror(errno)); + handshake.status = PTY_NOMORE; + write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); + exit(ERROR_PTYS); + } + handshake.status = PTY_NEW; + (void) strcpy(handshake.buffer, ttydev); + write(pc_pipe[1], (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; + default: + fprintf(stderr, "%s: unexpected handshake status %d\n", + xterm_name, + (int) handshake.status); + } + } + /* close our sides of the pipes */ + if (!waiting_for_initial_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 spawn */ + +SIGNAL_T +Exit(int n) +{ + TScreen *screen = &term->screen; + +#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) + if (utmpGid != -1) { + /* Switch back to group utmp */ + setegid(utmpGid); + TRACE(("switched back to group %d (check: %d)\n", + utmpGid, (int) getgid())); + } +#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 (term->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 (term->misc.login_shell) + call_updwtmp(etc_wtmp, utptr); +#else + /* set wtmp entry if wtmp file exists */ + if (term->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(); + } +#else /* not USE_SYSV_UTMP */ + int wfd; + struct utmp utmp; + + if (!resource.utmpInhibit && added_utmp_entry && + (am_slave < 0 && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)) { + bzero((char *) &utmp, sizeof(utmp)); + lseek(wfd, (long) (tslot * sizeof(utmp)), 0); + write(wfd, (char *) &utmp, sizeof(utmp)); + close(wfd); +#ifdef WTMP + if (term->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)); + time(&utmp.ut_time); + write(wfd, (char *) &utmp, sizeof(utmp)); + close(wfd); + } +#endif /* WTMP */ + } +#endif /* USE_SYSV_UTMP */ +#endif /* HAVE_UTMP */ + close(screen->respond); /* close explicitly to avoid race with slave side */ +#ifdef ALLOWLOGGING + if (screen->logging) + CloseLog(screen); +#endif + + if (am_slave < 0) { + /* 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 + } +#if OPT_TRACE || defined(NO_LEAKS) + if (n == 0) { + TRACE(("Freeing memory leaks\n")); + if (term != 0) { + Display *dpy = term->screen.display; + + if (term->screen.sbuf_address) { + free(term->screen.sbuf_address); + TRACE(("freed screen.sbuf_address\n")); + } + if (term->screen.allbuf) { + free(term->screen.allbuf); + TRACE(("freed screen.allbuf\n")); + } + if (term->screen.xim) { + XCloseIM(term->screen.xim); + TRACE(("freed screen.xim\n")); + } + if (toplevel) { + XtDestroyWidget(toplevel); + TRACE(("destroyed top-level widget\n")); + } + XtCloseDisplay(dpy); + TRACE(("closed display\n")); + } + TRACE((0)); + } +#endif + + exit(n); + SIGNAL_RETURN; +} + +/* ARGSUSED */ +static void +resize(TScreen * screen, char *oldtc, char *newtc) +{ +#ifndef USE_SYSV_ENVVARS + char *ptr1, *ptr2; + size_t i; + int li_first = 0; + char *temp; + + 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 = ptr1 - oldtc); + temp = newtc + i; + sprintf(temp, "%d", (li_first + ? MaxRows(screen) + : MaxCols(screen))); + temp += strlen(temp); + ptr1 = strchr(ptr1, ':'); + strncpy(temp, ptr1, i = ptr2 - ptr1); + temp += i; + sprintf(temp, "%d", (li_first + ? MaxCols(screen) + : MaxRows(screen))); + ptr2 = strchr(ptr2, ':'); + strcat(temp, ptr2); + TRACE((" ==> %s\n", newtc)); +#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 == term->screen.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, 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")); + 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)); + } + } +} + +#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 timeout = + {0, 0}; + + FD_ZERO(&set); + FD_SET(fd, &set); + if (Select(fd + 1, &set, NULL, NULL, &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 +#include +#include +#include +#include + +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/nx-X11/programs/xterm/main.c.X.original b/nx-X11/programs/xterm/main.c.X.original new file mode 100644 index 000000000..b84826cb4 --- /dev/null +++ b/nx-X11/programs/xterm/main.c.X.original @@ -0,0 +1,4912 @@ +/* $XTermId: main.c,v 1.477 2005/11/13 23:10:36 tom Exp $ */ + +#if !defined(lint) && 0 +static char *rid = "$Xorg: main.c,v 1.7 2001/02/09 02:06:02 xorgcvs Exp $"; +#endif /* lint */ + +/* + * 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-2004,2005 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. + +******************************************************************/ + +/* $XFree86: xc/programs/xterm/main.c,v 3.199 2005/11/13 23:10:36 dickey Exp $ */ + +/* main.c */ + +#define RES_OFFSET(field) XtOffsetOf(XTERM_RESOURCE, field) + +#include + +#include +#include + +#if OPT_TOOLBAR + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif /* OPT_TOOLBAR */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OPT_WIDE_CHARS +#include +#endif + +#ifdef __osf__ +#define USE_SYSV_SIGNALS +#define WTMP +#include /* openpty() */ +#endif + +#ifdef __sgi +#include /* 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 +#endif +#endif +#endif + +#ifdef __MVS__ +#define USE_SYSV_PGRP +#define USE_SYSV_SIGNALS +#endif + +#ifdef __CYGWIN__ +#define LASTLOG +#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 +#endif + +#ifndef TTY_GROUP_NAME +#define TTY_GROUP_NAME "tty" +#endif + +#include + +#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 /* for I_PUSH */ +#include /* 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 +#undef USE_SYSV_ENVVARS +#undef FIOCLEX +#undef FIONCLEX +#define setpgrp2 setpgrp +#include +#include +#endif + +#ifdef __hpux +#define HAS_BSD_GROUPS +#include +#endif /* __hpux */ + +#ifdef __osf__ +#define HAS_BSD_GROUPS +#undef USE_SYSV_PGRP +#define setpgrp setpgid +#endif + +#ifdef __sgi +#define HAS_BSD_GROUPS +#include +#endif /* __sgi */ + +#ifdef sun +#include +#endif + +#else /* } !SYSV { */ /* BSD systems */ + +#ifdef __QNX__ + +#ifndef __QNXNTO__ +#define ttyslot() 1 +#else +#define USE_SYSV_PGRP +extern __inline__ +ttyslot() +{ + 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 +#endif +#endif /* USE_POSIX_TERMIOS */ +#ifdef Lynx +#include +#else +#include +#endif +#ifndef __INTERIX +#define HAS_BSD_GROUPS +#endif +#endif /* !VMS */ +#endif /* !linux */ + +#endif /* __QNX__ */ + +#endif /* } !SYSV */ + +#if defined(SVR4) && !defined(__CYGWIN__) +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +#ifdef linux +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +/* Xpoll.h and 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 /* for NOFILE */ +#endif + +#if defined(BSD) && (BSD >= 199103) +#define WTMP +#define HAS_SAVED_IDS_AND_SETEUID +#endif + +#include + +#ifdef __hpux +#include +#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 +#endif + +#if defined(UTMPX_FOR_UTMP) + +#include + +#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 + +#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 /* caution: glibc 2.3.5 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 +#endif /* PUCC_PTYD */ + +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) +#include /* openpty() */ +#endif + +#ifdef __FreeBSD__ +#include /* 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 + +#if defined(__SCO__) || (defined(ISC) && !defined(_POSIX_SOURCE)) +#undef SIGTSTP /* defined, but not the BSD way */ +#endif + +#ifdef SIGTSTP +#include +#endif + +#if defined(__SCO__) || defined(__UNIXWARE__) +#undef ECHOKE +#undef ECHOCTL +#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 + +#ifdef SYSV +extern char *ptsname(int); +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + extern int tgetent(char *ptr, char *name); + extern char *tgetstr(char *name, char **ptr); + +#ifdef __cplusplus +} +#endif +#ifndef VMS +static SIGNAL_T reapchild(int n); +static int spawn(void); +static void remove_termcap_entry(char *buf, char *str); +#ifdef USE_PTY_SEARCH +static int pty_search(int *pty); +#endif +#endif /* ! VMS */ + +static int get_pty(int *pty, char *from); +static void get_terminal(void); +static void resize(TScreen * s, char *oldtc, char *newtc); +static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode); + +static Bool added_utmp_entry = False; + +#if defined(USE_UTMP_SETGID) +static int utmpGid = -1; +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 spawn() 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 */ +#ifndef CBRK +#define CBRK 0 +#endif +#ifndef CDSUSP +#define CDSUSP CONTROL('Y') +#endif +#ifndef CEOF +#define CEOF CONTROL('D') +#endif +#ifndef CEOL +#define CEOL 0 +#endif +#ifndef CFLUSH +#define CFLUSH CONTROL('O') +#endif +#ifndef CINTR +#define CINTR 0177 +#endif +#ifndef CKILL +#define CKILL '@' +#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 + +#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) +#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) +#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 int override_tty_modes = 0; +/* *INDENT-OFF* */ +static struct _xttymodes { + char *name; + size_t len; + int set; + Char 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 */ +}; +/* *INDENT-ON* */ + +#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value + +static int parse_tty_modes(char *s, struct _xttymodes *modelist); + +#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 */ + +#ifndef USE_UTEMPTER +#ifdef USE_LASTLOG +static char etc_lastlog[] = LASTLOG_FILENAME; +#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 /* 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)); \ + } + +/* 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("keyboardType", "KeyboardType", keyboardType, "unknown"), + Bres("sunFunctionKeys", "SunFunctionKeys", sunFunctionKeys, False), +#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_INITIAL_ERASE + Bres("ptyInitialErase", "PtyInitialErase", ptyInitialErase, DEF_INITIAL_ERASE), + Bres("backarrowKeyIsErase", "BackarrowKeyIsErase", backarrow_is_erase, DEF_BACKARO_ERASE), +#endif + Bres("waitForMap", "WaitForMap", wait_for_map, False), + Bres("useInsertMode", "UseInsertMode", useInsertMode, False), +#if OPT_ZICONBEEP + Ires("zIconBeep", "ZIconBeep", zIconBeep, 0), +#endif +#if OPT_PTY_HANDSHAKE + Bres("ptyHandshake", "PtyHandshake", ptyHandshake, True), +#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 +}; + +static char *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, (caddr_t) NULL}, +{"-132", "*c132", XrmoptionNoArg, (caddr_t) "on"}, +{"+132", "*c132", XrmoptionNoArg, (caddr_t) "off"}, +{"-ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "on"}, +{"+ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "off"}, +{"-aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "off"}, +#ifndef NO_ACTIVE_ICON +{"-ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "off"}, +{"+ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "on"}, +#endif /* NO_ACTIVE_ICON */ +{"-b", "*internalBorder",XrmoptionSepArg, (caddr_t) NULL}, +{"-bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "on"}, +{"+bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "off"}, +{"-bcf", "*cursorOffTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bcn", "*cursorOnTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-cc", "*charClass", XrmoptionSepArg, (caddr_t) NULL}, +{"-cm", "*colorMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+cm", "*colorMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "off"}, +{"+cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "on"}, +{"-cr", "*cursorColor", XrmoptionSepArg, (caddr_t) NULL}, +{"-cu", "*curses", XrmoptionNoArg, (caddr_t) "on"}, +{"+cu", "*curses", XrmoptionNoArg, (caddr_t) "off"}, +{"-dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "off"}, +{"+dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "on"}, +{"-fb", "*boldFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"on"}, +{"-fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"on"}, +#ifndef NO_ACTIVE_ICON +{"-fi", "*iconFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif /* NO_ACTIVE_ICON */ +#if OPT_RENDERFONT +{"-fa", "*faceName", XrmoptionSepArg, (caddr_t) NULL}, +{"-fd", "*faceNameDoublesize", XrmoptionSepArg, (caddr_t) NULL}, +{"-fs", "*faceSize", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_WIDE_CHARS +{"-fw", "*wideFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fwb", "*wideBoldFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_INPUT_METHOD +{"-fx", "*ximFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HIGHLIGHT_COLOR +{"-hc", "*highlightColor", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HP_FUNC_KEYS +{"-hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "on"}, +{"+hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-hold", "*hold", XrmoptionNoArg, (caddr_t) "on"}, +{"+hold", "*hold", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_INITIAL_ERASE +{"-ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "on"}, +{"+ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_C1_PRINT +{"-k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "on"}, +{"+k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +{"+kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +/* parse logging options anyway for compatibility */ +{"-l", "*logging", XrmoptionNoArg, (caddr_t) "on"}, +{"+l", "*logging", XrmoptionNoArg, (caddr_t) "off"}, +{"-lf", "*logFile", XrmoptionSepArg, (caddr_t) NULL}, +{"-ls", "*loginShell", XrmoptionNoArg, (caddr_t) "on"}, +{"+ls", "*loginShell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mb", "*marginBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+mb", "*marginBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mc", "*multiClickTime", XrmoptionSepArg, (caddr_t) NULL}, +{"-mesg", "*messages", XrmoptionNoArg, (caddr_t) "off"}, +{"+mesg", "*messages", XrmoptionNoArg, (caddr_t) "on"}, +{"-ms", "*pointerColor",XrmoptionSepArg, (caddr_t) NULL}, +{"-nb", "*nMarginBell", XrmoptionSepArg, (caddr_t) NULL}, +{"-nul", "*underLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+nul", "*underLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-pc", "*boldColors", XrmoptionNoArg, (caddr_t) "on"}, +{"+pc", "*boldColors", XrmoptionNoArg, (caddr_t) "off"}, +{"-rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "off"}, +{"-s", "*multiScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+s", "*multiScroll", XrmoptionNoArg, (caddr_t) "off"}, +{"-sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "on"}, +{"+sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "off"}, +#ifdef SCROLLBAR_RIGHT +{"-leftbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "off"}, +{"-rightbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "on"}, +#endif +{"-rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "on"}, +{"+sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "off"}, +{"-si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "off"}, +{"+si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "on"}, +{"-sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "on"}, +{"+sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "off"}, +{"-sl", "*saveLines", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_SUNPC_KBD +{"-sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "on"}, +{"+sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TEK4014 +{"-t", "*tekStartup", XrmoptionNoArg, (caddr_t) "on"}, +{"+t", "*tekStartup", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-ti", "*decTerminalID",XrmoptionSepArg, (caddr_t) NULL}, +{"-tm", "*ttyModes", XrmoptionSepArg, (caddr_t) NULL}, +{"-tn", "*termName", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_WIDE_CHARS +{"-u8", "*utf8", XrmoptionNoArg, (caddr_t) "2"}, +{"+u8", "*utf8", XrmoptionNoArg, (caddr_t) "0"}, +#endif +#if OPT_LUIT_PROG +{"-lc", "*locale", XrmoptionNoArg, (caddr_t) "on"}, +{"+lc", "*locale", XrmoptionNoArg, (caddr_t) "off"}, +{"-lcc", "*localeFilter",XrmoptionSepArg, (caddr_t) NULL}, +{"-en", "*locale", XrmoptionSepArg, (caddr_t) NULL}, +#endif +{"-ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "on"}, +{"+ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "off"}, +{"-im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "on"}, +{"+im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "off"}, +{"-vb", "*visualBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_WIDE_CHARS +{"-wc", "*wideChars", XrmoptionNoArg, (caddr_t) "on"}, +{"+wc", "*wideChars", XrmoptionNoArg, (caddr_t) "off"}, +{"-mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "off"}, +{"-cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"}, +{"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_ZICONBEEP +{"-ziconbeep", "*zIconBeep", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_SAME_NAME +{"-samename", "*sameName", XrmoptionNoArg, (caddr_t) "on"}, +{"+samename", "*sameName", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_SESSION_MGT +{"-sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "on"}, +{"+sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TOOLBAR +{"-tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "on"}, +{"+tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "off"}, +#endif +/* options that we process ourselves */ +{"-help", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-version", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-class", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +{"-e", NULL, XrmoptionSkipLine, (caddr_t) NULL}, +{"-into", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +/* bogus old compatibility stuff for which there are + standard XtOpenApplication options now */ +{"%", "*tekGeometry", XrmoptionStickyArg, (caddr_t) NULL}, +{"#", ".iconGeometry",XrmoptionStickyArg, (caddr_t) NULL}, +{"-T", ".title", XrmoptionSepArg, (caddr_t) NULL}, +{"-n", "*iconName", XrmoptionSepArg, (caddr_t) NULL}, +{"-r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-w", ".borderWidth", XrmoptionSepArg, (caddr_t) 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 +{ "-hc color", "selection background 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 +{ "-/+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 +{ NULL, NULL }}; +/* *INDENT-ON* */ + +static 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(127); + 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; +} + +/* + * If we're linked to terminfo, tgetent() will return an empty buffer. We + * cannot use that to adjust the $TERMCAP variable. + */ +static Bool +get_termcap(char *name, char *buffer, char *resized) +{ + TScreen *screen = &term->screen; + + *buffer = 0; /* initialize, in case we're using terminfo's tgetent */ + + if (name != 0) { + if (tgetent(buffer, name) == 1) { + TRACE(("get_termcap(%s) succeeded (%s)\n", name, + (*buffer + ? "ok:termcap, we can update $TERMCAP" + : "assuming this is terminfo"))); + if (*buffer) { + if (!TEK4014_ACTIVE(screen)) { + resize(screen, buffer, resized); + } + } + return True; + } else { + *buffer = 0; /* just in case */ + } + } + return False; +} + +static int +abbrev(char *tst, 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 + strlen(ProgramName); + for (opt = list; opt->opt; opt++) { + int len = 3 + 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)); + 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; +} +#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 (term->screen.Tshow) + hide_vt_window(); + else + do_hangup(w, (XtPointer) 0, (XtPointer) 0); + } else if (term->screen.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 = 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 = 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 */ + +int +main(int argc, char *argv[]ENVP_ARG) +{ + Widget form_top, menu_top; + TScreen *screen; + int mode; + char *my_class = DEFCLASS; + Window winToEmbedInto = None; + +#ifdef DISABLE_SETUID + if (seteuid(getuid()) == -1) + exit(2); + if (setuid(getuid()) == -1) + exit(2); +#endif + + ProgramName = argv[0]; + + /* 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); + if (seteuid(getuid()) == -1) { + fprintf(stderr, + "%s: unable to change back euid\n", ProgramName); + exit(1); + } + if (setuid(getuid()) == -1) { + fprintf(stderr, + "%s: unable to change back uid\n", ProgramName); + exit(1); + } +#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; + 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 { + 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). + */ + 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 +#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 /* } */ + + d_tio.c_cc[VINTR] = CINTR; + d_tio.c_cc[VQUIT] = CQUIT; + d_tio.c_cc[VERASE] = CERASE; + d_tio.c_cc[VKILL] = CKILL; + d_tio.c_cc[VEOF] = CEOF; + d_tio.c_cc[VEOL] = CNUL; + d_tio.c_cc[VEOL2] = CNUL; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = CNUL; +#endif + +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ + d_tio.c_cc[VSUSP] = CSUSP; +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CDSUSP; +#endif + d_tio.c_cc[VREPRINT] = CRPRNT; + d_tio.c_cc[VDISCARD] = CFLUSH; + d_tio.c_cc[VWERASE] = CWERASE; + d_tio.c_cc[VLNEXT] = CLNEXT; + d_tio.c_cc[VMIN] = 1; + d_tio.c_cc[VTIME] = 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 + d_tio.c_cc[VINTR] = CONTROL('C'); /* '^C' */ + d_tio.c_cc[VERASE] = 0x7f; /* 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; /* '^@' */ + d_tio.c_cc[VMIN] = 1; + d_tio.c_cc[VTIME] = 0; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = CSWTCH; /* usually '^Z' */ +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = CLNEXT; +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = CWERASE; +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = CRPRNT; +#endif +#ifdef VRPRNT + d_tio.c_cc[VRPRNT] = CRPRNT; +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = CFLUSH; +#endif +#ifdef VFLUSHO + d_tio.c_cc[VFLUSHO] = CFLUSH; +#endif +#ifdef VSTOP + d_tio.c_cc[VSTOP] = CSTOP; +#endif +#ifdef VSTART + d_tio.c_cc[VSTART] = CSTART; +#endif +#ifdef VSUSP + d_tio.c_cc[VSUSP] = CSUSP; +#endif +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CDSUSP; +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = CSTATUS; +#endif + /* now, try to inherit tty settings */ + { + int i; + + for (i = 0; i <= 2; i++) { + TERMIO_STRUCT deftio; + if (ttyGetAttr(i, &deftio) == 0) { + d_tio.c_cc[VINTR] = deftio.c_cc[VINTR]; + d_tio.c_cc[VQUIT] = deftio.c_cc[VQUIT]; + d_tio.c_cc[VERASE] = deftio.c_cc[VERASE]; + d_tio.c_cc[VKILL] = deftio.c_cc[VKILL]; + d_tio.c_cc[VEOF] = deftio.c_cc[VEOF]; + d_tio.c_cc[VEOL] = deftio.c_cc[VEOL]; +#ifdef VSWTCH + d_tio.c_cc[VSWTCH] = deftio.c_cc[VSWTCH]; +#endif +#ifdef VEOL2 + d_tio.c_cc[VEOL2] = deftio.c_cc[VEOL2]; +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = deftio.c_cc[VLNEXT]; +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = deftio.c_cc[VWERASE]; +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = deftio.c_cc[VREPRINT]; +#endif +#ifdef VRPRNT + d_tio.c_cc[VRPRNT] = deftio.c_cc[VRPRNT]; +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = deftio.c_cc[VDISCARD]; +#endif +#ifdef VFLUSHO + d_tio.c_cc[VFLUSHO] = deftio.c_cc[VFLUSHO]; +#endif +#ifdef VSTOP + d_tio.c_cc[VSTOP] = deftio.c_cc[VSTOP]; +#endif +#ifdef VSTART + d_tio.c_cc[VSTART] = deftio.c_cc[VSTART]; +#endif +#ifdef VSUSP + d_tio.c_cc[VSUSP] = deftio.c_cc[VSUSP]; +#endif +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = deftio.c_cc[VDSUSP]; +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = deftio.c_cc[VSTATUS]; +#endif + break; + } + } + } +#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 */ +#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */ + d_tio.c_cc[VSUSP] = CSUSP; +#ifdef VDSUSP + d_tio.c_cc[VDSUSP] = CharOf('\000'); +#endif +#ifdef VSTATUS + d_tio.c_cc[VSTATUS] = CharOf('\377'); +#endif +#ifdef VREPRINT + d_tio.c_cc[VREPRINT] = CharOf('\377'); +#endif +#ifdef VDISCARD + d_tio.c_cc[VDISCARD] = CharOf('\377'); +#endif +#ifdef VWERASE + d_tio.c_cc[VWERASE] = CharOf('\377'); +#endif +#ifdef VLNEXT + d_tio.c_cc[VLNEXT] = CharOf('\377'); +#endif +#endif /* } USE_TERMIOS */ +#ifdef TIOCLSET /* { */ + d_lmode = 0; +#endif /* } TIOCLSET */ +#endif /* } macII, ATT, CRAY */ +#endif /* } TERMIO_STRUCT */ + + /* Init the Toolkit. */ + { +#ifdef HAS_SAVED_IDS_AND_SETEUID + uid_t euid = geteuid(); + gid_t egid = getegid(); + uid_t ruid = getuid(); + gid_t rgid = getgid(); + + if (setegid(rgid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) /* could happen if _BPX_SHAREAS=REUSE */ +#endif + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) rgid, strerror(errno)); + } + + if (seteuid(ruid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) ruid, strerror(errno)); + } +#endif + + XtSetErrorHandler(xt_error); +#if OPT_SESSION_MGT + toplevel = XtOpenApplication(&app_con, my_class, + optionDescList, + XtNumber(optionDescList), + &argc, argv, fallback_resources, + sessionShellWidgetClass, + NULL, 0); +#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(); + +#ifdef HAS_SAVED_IDS_AND_SETEUID + if (seteuid(euid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) euid, strerror(errno)); + } + + if (setegid(egid) == -1) { +#ifdef __MVS__ + if (!(errno == EMVSERR)) +#endif + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) egid, strerror(errno)); + } +#endif + +#if defined(USE_UTMP_SETGID) + if (resource.utmpInhibit) { + /* Can totally revoke group privs */ + setegid(getgid()); + setgid(getgid()); + } +#endif + } + + waiting_for_initial_map = resource.wait_for_map; + + /* + * 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 = 1; + } + } +#if OPT_ZICONBEEP + zIconBeep = resource.zIconBeep; + zIconBeep_flagged = False; + if (zIconBeep > 100 || zIconBeep < -100) { + 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 */ +#if OPT_SAME_NAME + sameName = resource.sameName; +#endif + 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 == getuid()) && + !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); + + 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, +#endif + (XtPointer) 0); + decode_keyboard_type(&resource); + + screen = &term->screen; + 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) + screen->TekEmu = False; + + if (screen->TekEmu && !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[4]; + 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(getuid(), getgid(), False, dbglogfile, 0666)) { + 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 */ + + /* open a terminal for client */ + get_terminal(); + + spawn(); + +#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(screen)))); + 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 +#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(screen); + } +#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); + } + + for (;;) { +#if OPT_TEK4014 + if (screen->TekEmu) + TekRun(); + else +#endif + VTRun(); + } +} + +#if defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS)) || 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), + getuid(), 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 spawn(). That's the reason + for the "if (IsPts)" statement in spawn(); 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 */ + + 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(getuid(), getgid(), 0600U); + seteuid(getuid()); + +#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 */ + +/* + * sets up X and initializes the terminal structure except for term.buf.fildes. + */ +static void +get_terminal(void) +{ + TScreen *screen = &term->screen; + + screen->arrow = make_colored_cursor(XC_left_ptr, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); +} + +/* + * 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) +{ + siglongjmp(env, 1); + SIGNAL_RETURN; +} + +/* + * declared outside OPT_PTY_HANDSHAKE so HsSysError() callers can use + */ +static int cp_pipe[2]; /* this pipe is used for child to parent transfer */ + +#if OPT_PTY_HANDSHAKE +static int pc_pipe[2]; /* 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; + +/* 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 pf, int error) +{ + handshake_t handshake; + + handshake.status = PTY_FATALERROR; + handshake.error = errno; + handshake.fatal_error = error; + strcpy(handshake.buffer, ttydev); + write(pf, (char *) &handshake, sizeof(handshake)); + exit(error); +} + +void +first_map_occurred(void) +{ + handshake_t handshake; + TScreen *screen = &term->screen; + + handshake.status = PTY_EXEC; + handshake.rows = screen->max_row; + handshake.cols = screen->max_col; + write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); + close(cp_pipe[0]); + close(pc_pipe[1]); + waiting_for_initial_map = False; +} +#else +/* + * temporary hack to get xterm working on att ptys + */ +static void +HsSysError(int pf GCC_UNUSED, int error) +{ + fprintf(stderr, "%s: fatal pty error %d (errno=%d) on tty %s\n", + xterm_name, error, errno, ttydev); + exit(error); +} + +void +first_map_occurred(void) +{ + return; +} +#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(("set_owner(%s, uid=%d, gid=%d, mode=%#o\n", device, uid, gid, mode)); + + if (chown(device, uid, gid) < 0) { + why = errno; + if (why != ENOENT + && getuid() == 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 %03o currently %03o: %s\n", + device, (unsigned) mode, (sb.st_mode & 0777U), + strerror(why)); + TRACE(("...stat uid=%d, gid=%d, mode=%#o\n", + sb.st_uid, sb.st_gid, 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 + +/* + * 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 +spawn(void) +{ + TScreen *screen = &term->screen; +#if OPT_PTY_HANDSHAKE + handshake_t handshake; + int done; +#endif +#if OPT_INITIAL_ERASE + int initial_erase = VAL_INITIAL_ERASE; +#endif + int rc = 0; + int ttyfd = -1; + +#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 termcap[TERMCAP_SIZE]; + char newtc[TERMCAP_SIZE]; + char *ptr, *shname, *shname_minus; + int i, no_dev_tty = False; + char **envnew; /* new environment */ + int envsize; /* elements in 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 lastlog; +#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 = getuid(); + screen->gid = getgid(); + + termcap[0] = '\0'; + newtc[0] = '\0'; + +#ifdef SIGTTOU + /* so that TIOCSWINSZ || TIOCSIZE doesn't block */ + signal(SIGTTOU, SIG_IGN); +#endif + + if (am_slave >= 0) { + screen->respond = am_slave; + set_pty_id(ttydev, passedPty); +#ifdef USE_PTY_DEVICE + set_pty_id(ptydev, passedPty); +#endif + setgid(screen->gid); + setuid(screen->uid); + } 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; + } +#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. + */ + no_dev_tty = False; + 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) { + no_dev_tty = True; +#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, <c) == -1) + ltc = d_ltc; +#endif /* HAS_LTCHARS */ +#ifdef TIOCLSET + if (ioctl(ttyfd, TIOCLGET, &lmode) == -1) + lmode = d_lmode; +#endif /* TIOCLSET */ +#ifdef TERMIO_STRUCT + if ((rc = ttyGetAttr(ttyfd, &tio)) == -1) + tio = d_tio; +#else /* !TERMIO_STRUCT */ + if ((rc = ioctl(ttyfd, TIOCGETP, (char *) &sg)) == -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; + if ((rc = ttyGetAttr(screen->respond, &my_tio)) == 0) + initial_erase = my_tio.c_cc[VERASE]; +#else /* !TERMIO_STRUCT */ + struct sgttyb my_sg; + if ((rc = ioctl(screen->respond, TIOCGETP, (char *) &my_sg)) == 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(XtParent(CURRENT_EMU(screen)), False); + + wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", + False); + + if (!TEK4014_ACTIVE(screen)) + VTInit(); /* 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(XtParent(CURRENT_EMU(screen)), + mit_console, CurrentTime, + ConvertConsoleSelection, NULL, NULL); + } +#endif +#if OPT_TEK4014 + if (screen->TekEmu) { + envnew = tekterm; + ptr = newtc; + } else +#endif + { + envnew = vtterm; + ptr = termcap; + } + + /* + * 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. + */ + if (!get_termcap(TermName = resource.term_name, ptr, newtc)) { + char *last = NULL; + TermName = *envnew; + while (*envnew != NULL) { + if ((last == NULL || strcmp(last, *envnew)) + && get_termcap(*envnew, ptr, newtc)) { + TermName = *envnew; + break; + } + last = *envnew; + envnew++; + } + } + + /* + * 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 ")); + if (!resource.ptyInitialErase) { + char temp[1024], *p = temp; + char *s = tgetstr(TERMCAP_ERASE, &p); + TRACE(("...extracting initial_erase value from termcap\n")); + if (s != 0) { + initial_erase = decode_keyvalue(&s, True); + } + } + 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 == 127) { + term->keyboard.flags &= ~MODE_DECBKM; + } else { + term->keyboard.flags |= MODE_DECBKM; + term->keyboard.reset_DECBKM = 1; + } + TRACE(("...sets DECBKM %s\n", + (term->keyboard.flags & MODE_DECBKM) ? "on" : "off")); + } else { + term->keyboard.reset_DECBKM = 2; + } +#endif /* OPT_INITIAL_ERASE */ + +#ifdef TTYSIZE_STRUCT + /* tell tty how big window is */ +#if OPT_TEK4014 + if (TEK4014_ACTIVE(screen)) { + TTYSIZE_ROWS(ts) = 38; + TTYSIZE_COLS(ts) = 81; +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = TFullWidth(screen); + ts.ws_ypixel = TFullHeight(screen); +#endif + } else +#endif + { + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = FullHeight(screen); +#endif + } + 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) { + /* + * now in child process + */ + TRACE_CHILD +#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 + +#ifdef USE_USG_PTYS +#ifdef USE_ISPTS_FLAG + if (IsPts) { /* SYSV386 supports both, which did we open? */ +#endif + int ptyfd = 0; + char *pty_name = 0; + + setpgrp(); + grantpt(screen->respond); + unlockpt(screen->respond); + if ((pty_name = ptsname(screen->respond)) == 0) { + SysError(ERROR_PTSNAME); + } + if ((ptyfd = open(pty_name, O_RDWR)) < 0) { + SysError(ERROR_OPPTSNAME); + } +#ifdef I_PUSH + if (ioctl(ptyfd, I_PUSH, "ptem") < 0) { + SysError(ERROR_PTEM); + } +#if !defined(SVR4) && !(defined(SYSV) && defined(i386)) + if (!getenv("CONSEM") && ioctl(ptyfd, I_PUSH, "consem") < 0) { + SysError(ERROR_CONSEM); + } +#endif /* !SVR4 */ + if (ioctl(ptyfd, I_PUSH, "ldterm") < 0) { + SysError(ERROR_LDTERM); + } +#ifdef SVR4 /* from Sony */ + 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(screen)) { + TTYSIZE_ROWS(ts) = 24; + TTYSIZE_COLS(ts) = 80; +#ifdef USE_STRUCT_WINSIZE + ts.ws_xpixel = TFullWidth(screen); + ts.ws_ypixel = TFullHeight(screen); +#endif + } else +#endif /* OPT_TEK4014 */ + { + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#ifdef USE_STRUCT_WINSIZE + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = 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) { + (void) close(cp_pipe[1]); + cp_pipe[1] = i; + } + } + if (pc_pipe[0] <= 2) { + if ((i = fcntl(pc_pipe[0], F_DUPFD, 3)) >= 0) { + (void) 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__ + 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) + (void) setsid(); +#else + (void) 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__ */ + } + + while (1) { +#if defined(TIOCNOTTY) && (!defined(__GLIBC__) || (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))) + if (!no_dev_tty + && (ttyfd = open("/dev/tty", O_RDWR)) >= 0) { + ioctl(ttyfd, TIOCNOTTY, (char *) NULL); + close_fd(ttyfd); + } +#endif /* TIOCNOTTY && !glibc >= 2.1 */ +#ifdef CSRG_BASED + (void) revoke(ttydev); +#endif + if ((ttyfd = open(ttydev, O_RDWR)) >= 0) { +#if defined(CRAY) && defined(TCSETCTTY) + /* make /dev/tty work */ + ioctl(ttyfd, TCSETCTTY, 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); + write(cp_pipe[1], (char *) &handshake, + sizeof(handshake)); + + /* get reply from parent */ + i = 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 = CastMallocN(char, strlen(handshake.buffer)); + if (ttydev == NULL) { + SysError(ERROR_SPREALLOC); + } + strcpy(ttydev, handshake.buffer); + } + + /* use the same tty name that everyone else will use + * (from ttyname) + */ + if ((ptr = ttyname(ttyfd)) != 0) { + /* it may be bigger */ + ttydev = TypeRealloc(char, strlen(ptr) + 1, ttydev); + if (ttydev == NULL) { + SysError(ERROR_SPREALLOC); + } + (void) strcpy(ttydev, 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 */ + 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 + 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 + 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 +#ifndef __MVS__ + /* reset EOL to default value */ + tio.c_cc[VEOL] = CEOL; /* '^@' */ + /* certain shells (ksh & csh) change EOF as well */ + tio.c_cc[VEOF] = CEOF; /* '^D' */ +#else + if (tio.c_cc[VEOL] == 0) + tio.c_cc[VEOL] = CEOL; /* '^@' */ + if (tio.c_cc[VEOF] == 0) + tio.c_cc[VEOF] = CEOF; /* '^D' */ +#endif +#ifdef VLNEXT + tio.c_cc[VLNEXT] = CLNEXT; +#endif +#ifdef VWERASE + tio.c_cc[VWERASE] = CWERASE; +#endif +#ifdef VREPRINT + tio.c_cc[VREPRINT] = CRPRNT; +#endif +#ifdef VRPRNT + tio.c_cc[VRPRNT] = CRPRNT; +#endif +#ifdef VDISCARD + tio.c_cc[VDISCARD] = CFLUSH; +#endif +#ifdef VFLUSHO + tio.c_cc[VFLUSHO] = CFLUSH; +#endif +#ifdef VSTOP + tio.c_cc[VSTOP] = CSTOP; +#endif +#ifdef VSTART + tio.c_cc[VSTART] = CSTART; +#endif +#ifdef VSUSP + tio.c_cc[VSUSP] = CSUSP; +#endif +#ifdef VDSUSP + tio.c_cc[VDSUSP] = CDSUSP; +#endif + if (override_tty_modes) { + /* sysv-specific */ + TMODE(XTTYMODE_intr, tio.c_cc[VINTR]); + TMODE(XTTYMODE_quit, tio.c_cc[VQUIT]); + TMODE(XTTYMODE_erase, tio.c_cc[VERASE]); + TMODE(XTTYMODE_kill, tio.c_cc[VKILL]); + TMODE(XTTYMODE_eof, tio.c_cc[VEOF]); + TMODE(XTTYMODE_eol, tio.c_cc[VEOL]); +#ifdef VSWTCH + TMODE(XTTYMODE_swtch, tio.c_cc[VSWTCH]); +#endif +#ifdef VSUSP + TMODE(XTTYMODE_susp, tio.c_cc[VSUSP]); +#endif +#ifdef VDSUSP + TMODE(XTTYMODE_dsusp, tio.c_cc[VDSUSP]); +#endif +#ifdef VREPRINT + TMODE(XTTYMODE_rprnt, tio.c_cc[VREPRINT]); +#endif +#ifdef VRPRNT + TMODE(XTTYMODE_rprnt, tio.c_cc[VRPRNT]); +#endif +#ifdef VDISCARD + TMODE(XTTYMODE_flush, tio.c_cc[VDISCARD]); +#endif +#ifdef VFLUSHO + TMODE(XTTYMODE_flush, tio.c_cc[VFLUSHO]); +#endif +#ifdef VWERASE + TMODE(XTTYMODE_weras, tio.c_cc[VWERASE]); +#endif +#ifdef VLNEXT + TMODE(XTTYMODE_lnext, tio.c_cc[VLNEXT]); +#endif +#ifdef VSTART + TMODE(XTTYMODE_start, tio.c_cc[VSTART]); +#endif +#ifdef VSTOP + TMODE(XTTYMODE_stop, tio.c_cc[VSTOP]); +#endif +#ifdef VSTATUS + TMODE(XTTYMODE_status, tio.c_cc[VSTATUS]); +#endif +#ifdef VERASE2 + TMODE(XTTYMODE_erase2, tio.c_cc[VERASE2]); +#endif +#ifdef VEOL2 + TMODE(XTTYMODE_eol2, tio.c_cc[VEOL2]); +#endif +#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, <c) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETC); +#endif /* HAS_LTCHARS */ +#ifdef TIOCLSET + if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCLSET); +#endif /* TIOCLSET */ + if (ttySetAttr(ttyfd, &tio) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETP); + + /* ignore errors here - some platforms don't work */ + 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(cp_pipe[1], ERROR_TIOCSETP); + if (ioctl(ttyfd, TIOCSETC, (char *) &tc) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETC); + if (ioctl(ttyfd, TIOCSETD, (char *) &discipline) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSETD); + if (ioctl(ttyfd, TIOCSLTC, (char *) <c) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCSLTC); + if (ioctl(ttyfd, TIOCLSET, (char *) &lmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCLSET); +#ifdef sony + if (ioctl(ttyfd, TIOCKSET, (char *) &jmode) == -1) + HsSysError(cp_pipe[1], ERROR_TIOCKSET); + if (ioctl(ttyfd, TIOCKSETC, (char *) &jtc) == -1) + HsSysError(cp_pipe[1], 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", + xterm_name, 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", + xterm_name, strerror(errno)); + (void) 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 make the parent process set the + * terminal's erase mode, and if we had no ttyModes 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, + (!resource.ptyInitialErase + && !override_tty_modes + && !ttymodelist[XTTYMODE_erase].set) + ? "YES" : "NO", + resource.ptyInitialErase, + override_tty_modes, + ttymodelist[XTTYMODE_erase].set)); + if (!resource.ptyInitialErase + && !override_tty_modes + && !ttymodelist[XTTYMODE_erase].set) { +#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; + 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 + + /* copy the environment before Setenv'ing */ + for (i = 0; environ[i] != NULL; i++) ; + /* compute number of xtermSetenv() calls below */ + envsize = 1; /* (NULL terminating entry) */ + envsize += 5; /* TERM, WINDOWID, DISPLAY, _SHELL, _VERSION */ +#ifdef HAVE_UTMP + envsize += 1; /* LOGNAME */ +#endif /* HAVE_UTMP */ +#ifdef USE_SYSV_ENVVARS + envsize += 2; /* COLUMNS, LINES */ +#ifdef HAVE_UTMP + envsize += 2; /* HOME, SHELL */ +#endif /* HAVE_UTMP */ +#ifdef OWN_TERMINFO_DIR + envsize += 1; /* TERMINFO */ +#endif +#else /* USE_SYSV_ENVVARS */ + envsize += 1; /* TERMCAP */ +#endif /* USE_SYSV_ENVVARS */ + envnew = TypeCallocN(char *, (unsigned) i + envsize); + memmove((char *) envnew, (char *) environ, i * sizeof(char *)); + environ = envnew; + xtermSetenv("TERM=", TermName); + if (!TermName) + *newtc = 0; + + sprintf(buf, "%lu", + ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU(screen))))); + xtermSetenv("WINDOWID=", buf); + + /* put the display into the environment of the shell */ + xtermSetenv("DISPLAY=", XDisplayString(screen->display)); + + xtermSetenv("XTERM_VERSION=", xtermVersion()); + + 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); + + (void) close(0); + + if (open("/dev/tty", O_RDWR)) { + SysError(ERROR_OPDEVTTY); + } + (void) close(1); + (void) close(2); + dup(0); + dup(0); +#else + /* dup the tty */ + for (i = 0; i <= 2; i++) + if (i != ttyfd) { + (void) close(i); + (void) 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 = getenv("LOGNAME")) != NULL + || (login_name = 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_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 */ + if (!(utret = find_utmp(&utmp))) { + (void) call_setutent(); + init_utmp(USER_PROCESS, &utmp); + if (!(utret = find_utmp(&utmp))) { + (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", + 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 + (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 (term->misc.login_shell) + updwtmpx(WTMPX_FILE, &utmp); +#elif defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && !(defined(__powerpc__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)) + if (term->misc.login_shell) + call_updwtmp(etc_wtmp, &utmp); +#else + if (term->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) { + bzero((char *) &utmp, 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 + /* cast needed on Ultrix 4.4 */ + time((time_t *) & utmp.ut_time); + lseek(i, (long) (tslot * sizeof(utmp)), 0); + write(i, (char *) &utmp, sizeof(utmp)); + close(i); + added_utmp_entry = True; +#if defined(WTMP) + if (term->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 (term->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 (term->misc.login_shell) { + bzero((char *) &lastlog, sizeof(lastlog)); + (void) strncpy(lastlog.ll_line, + my_pty_name(ttydev), + sizeof(lastlog.ll_line)); + X_GETTIMEOFDAY(&lastlog.ll_tv); + SetUtmpHost(lastlog.ll_host, screen); + updlastlogx(_PATH_LASTLOGX, screen->uid, &lastlog); + } +#endif + +#ifdef USE_LASTLOG + if (term->misc.login_shell && + (i = open(etc_lastlog, O_WRONLY)) >= 0) { + bzero((char *) &lastlog, sizeof(struct lastlog)); + (void) strncpy(lastlog.ll_line, + my_pty_name(ttydev), + sizeof(lastlog.ll_line)); + SetUtmpHost(lastlog.ll_host, screen); + time(&lastlog.ll_time); + lseek(i, (long) (screen->uid * sizeof(struct lastlog)), 0); + write(i, (char *) &lastlog, sizeof(struct lastlog)); + close(i); + } +#endif /* USE_LASTLOG */ + +#if defined(USE_UTMP_SETGID) + /* Switch to real gid after writing utmp entry */ + utmpGid = getegid(); + if (getgid() != getegid()) { + utmpGid = getegid(); + setegid(getgid()); + TRACE(("switch to real gid %d after writing utmp\n", getgid())); + } +#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); + (void) write(cp_pipe[1], (char *) &handshake, sizeof(handshake)); + } +#endif /* OPT_PTY_HANDSHAKE */ +#endif /* USE_UTEMPTER */ +#endif /* HAVE_UTMP */ + + (void) setgid(screen->gid); +#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); + } +#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); + (void) write(cp_pipe[1], (char *) &handshake, sizeof(handshake)); + + if (waiting_for_initial_map) { + i = 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) { + set_max_row(screen, handshake.rows); + set_max_col(screen, handshake.cols); +#ifdef TTYSIZE_STRUCT + TTYSIZE_ROWS(ts) = MaxRows(screen); + TTYSIZE_COLS(ts) = MaxCols(screen); +#if defined(USE_STRUCT_WINSIZE) + ts.ws_xpixel = FullWidth(screen); + ts.ws_ypixel = 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 (!getenv("HOME")) + xtermSetenv("HOME=", pw->pw_dir); + if (!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 (!TEK4014_ACTIVE(screen) && *newtc) { + strcpy(termcap, newtc); + resize(screen, termcap, newtc); + } + if (term->misc.titeInhibit && !term->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 = 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 */ + + /* need to reset after all the ioctl bashing we did above */ +#if OPT_PTY_HANDSHAKE + if (resource.ptyHandshake) { +#ifdef TTYSIZE_STRUCT + i = SET_TTYSIZE(0, ts); + TRACE(("spawn 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 = getenv("SHELL")) == NULL || *ptr == 0) && + ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) || + *(ptr = pw->pw_shell) == 0)) { + ptr = "/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) { + 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", + xterm_name, *command_to_exec_with_luit, strerror(errno)); + fprintf(stderr, "%s: cannot support your locale.\n", + xterm_name); + } +#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", + xterm_name, *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 (term->misc.login_shell && pw && added_utmp_entry) + execl(bin_login, "login", "-p", "-f", login_name, (void *) 0); +#endif + execlp(ptr, + (term->misc.login_shell ? shname_minus : shname), + (void *) 0); + + /* Exec failed. */ + fprintf(stderr, "%s: Could not exec %s: %s\n", xterm_name, + ptr, strerror(errno)); + (void) 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; + } + + 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. + */ + (void) 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", + xterm_name, strerror(errno)); + handshake.status = PTY_NOMORE; + write(pc_pipe[1], (char *) &handshake, sizeof(handshake)); + exit(ERROR_PTYS); + } + handshake.status = PTY_NEW; + (void) strcpy(handshake.buffer, ttydev); + write(pc_pipe[1], (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; + default: + fprintf(stderr, "%s: unexpected handshake status %d\n", + xterm_name, + (int) handshake.status); + } + } + /* close our sides of the pipes */ + if (!waiting_for_initial_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 spawn */ + +SIGNAL_T +Exit(int n) +{ + TScreen *screen = &term->screen; + +#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) + if (utmpGid != -1) { + /* Switch back to group utmp */ + setegid(utmpGid); + TRACE(("switched back to group %d (check: %d)\n", + utmpGid, (int) getgid())); + } +#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 (term->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 (term->misc.login_shell) + call_updwtmp(etc_wtmp, utptr); +#else + /* set wtmp entry if wtmp file exists */ + if (term->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(); + } +#else /* not USE_SYSV_UTMP */ + int wfd; + struct utmp utmp; + + if (!resource.utmpInhibit && added_utmp_entry && + (am_slave < 0 && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)) { + bzero((char *) &utmp, sizeof(utmp)); + lseek(wfd, (long) (tslot * sizeof(utmp)), 0); + write(wfd, (char *) &utmp, sizeof(utmp)); + close(wfd); +#ifdef WTMP + if (term->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)); + time(&utmp.ut_time); + write(wfd, (char *) &utmp, sizeof(utmp)); + close(wfd); + } +#endif /* WTMP */ + } +#endif /* USE_SYSV_UTMP */ +#endif /* HAVE_UTMP */ + close(screen->respond); /* close explicitly to avoid race with slave side */ +#ifdef ALLOWLOGGING + if (screen->logging) + CloseLog(screen); +#endif + + if (am_slave < 0) { + /* 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 + } +#if OPT_TRACE || defined(NO_LEAKS) + if (n == 0) { + TRACE(("Freeing memory leaks\n")); + if (term != 0) { + Display *dpy = term->screen.display; + + if (term->screen.sbuf_address) { + free(term->screen.sbuf_address); + TRACE(("freed screen.sbuf_address\n")); + } + if (term->screen.allbuf) { + free(term->screen.allbuf); + TRACE(("freed screen.allbuf\n")); + } + if (term->screen.xim) { + XCloseIM(term->screen.xim); + TRACE(("freed screen.xim\n")); + } + if (toplevel) { + XtDestroyWidget(toplevel); + TRACE(("destroyed top-level widget\n")); + } + XtCloseDisplay(dpy); + TRACE(("closed display\n")); + } + TRACE((0)); + } +#endif + + exit(n); + SIGNAL_RETURN; +} + +/* ARGSUSED */ +static void +resize(TScreen * screen, char *oldtc, char *newtc) +{ +#ifndef USE_SYSV_ENVVARS + char *ptr1, *ptr2; + size_t i; + int li_first = 0; + char *temp; + + 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 = ptr1 - oldtc); + temp = newtc + i; + sprintf(temp, "%d", (li_first + ? MaxRows(screen) + : MaxCols(screen))); + temp += strlen(temp); + ptr1 = strchr(ptr1, ':'); + strncpy(temp, ptr1, i = ptr2 - ptr1); + temp += i; + sprintf(temp, "%d", (li_first + ? MaxCols(screen) + : MaxRows(screen))); + ptr2 = strchr(ptr2, ':'); + strcat(temp, ptr2); + TRACE((" ==> %s\n", newtc)); +#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 == term->screen.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, 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")); + 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)); + } + } +} + +#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 timeout = + {0, 0}; + + FD_ZERO(&set); + FD_SET(fd, &set); + if (Select(fd + 1, &set, NULL, NULL, &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 +#include +#include +#include +#include + +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/nx-X11/programs/xterm/main.h b/nx-X11/programs/xterm/main.h new file mode 100644 index 000000000..5a8116665 --- /dev/null +++ b/nx-X11/programs/xterm/main.h @@ -0,0 +1,89 @@ +/* $XTermId: main.h,v 1.27 2004/12/01 01:27:47 tom Exp $ */ + +/* + * $Xorg: main.h,v 1.3 2000/08/17 19:55:09 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/main.h,v 3.12 2004/12/01 01:27:47 dickey 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. + */ +#ifndef included_main_h +#define included_main_h + +#include + +#define DEFCLASS "XTerm" +#define DEFFONT "fixed" +#define DEFWIDEFONT NULL /* grab one which is 2x as wide */ +#define DEFWIDEBOLDFONT NULL +#define DEFXIMFONT "*" +#define DEFBOLDFONT NULL /* no bold font uses overstriking */ +#define DEFBORDER 2 +#define DEFFACENAME NULL +#define DEFFACESIZE "14.0" + +#if OPT_BLINK_TEXT +#define DEFBLINKASBOLD FALSE +#else +#define DEFBLINKASBOLD TRUE +#endif + +#ifndef DEFDELETE_DEL +#define DEFDELETE_DEL 2 +#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 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 + +#define DEFLOCALEFILTER1(x) DEFLOCALEFILTER2(x) +#define DEFLOCALEFILTER DEFLOCALEFILTER1(PROJECTROOT) "/bin/luit" + +#endif /* included_main_h */ diff --git a/nx-X11/programs/xterm/make.com b/nx-X11/programs/xterm/make.com new file mode 100644 index 000000000..d2b662bd0 --- /dev/null +++ b/nx-X11/programs/xterm/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/nx-X11/programs/xterm/menu.c b/nx-X11/programs/xterm/menu.c new file mode 100644 index 000000000..4f451d660 --- /dev/null +++ b/nx-X11/programs/xterm/menu.c @@ -0,0 +1,2959 @@ +/* $XTermId: menu.c,v 1.191 2005/11/13 23:10:36 tom Exp $ */ + +/* $Xorg: menu.c,v 1.4 2001/02/09 02:06:03 xorgcvs Exp $ */ +/* + +Copyright 1999-2004,2005 by Thomas E. Dickey + + 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. + +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. + +*/ +/* $XFree86: xc/programs/xterm/menu.c,v 3.64 2005/11/13 23:10:36 dickey Exp $ */ + +#include +#include +#include +#include + +#include + +#define app_con Xaw_app_con /* quiet a warning from SimpleMenu.h */ + +#if defined(HAVE_LIB_XAW) + +#include +#include +#include +#include + +#if OPT_TOOLBAR +#include +#include +#endif + +#elif defined(HAVE_LIB_XAW3D) + +#include +#include +#include +#include + +#if OPT_TOOLBAR +#include +#include +#endif + +#elif defined(HAVE_LIB_NEXTAW) + +#include +#include +#include +#include + +#if OPT_TOOLBAR +#include +#include +#endif + +#elif defined(HAVE_LIB_XAWPLUS) + +#include +#include +#include +#include + +#if OPT_TOOLBAR +#include +#include +#endif + +#endif + +#undef app_con + +#include +#include +/* *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_clearsavedlines PROTO_XT_CALLBACK_ARGS; +static void do_continue PROTO_XT_CALLBACK_ARGS; +static void do_cursesemul 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_marginbell PROTO_XT_CALLBACK_ARGS; +static void do_old_fkeys 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_softreset PROTO_XT_CALLBACK_ARGS; +static void do_sun_fkeys 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_poponbell 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_BLINK_CURS +static void do_cursorblink PROTO_XT_CALLBACK_ARGS; +#endif + +#if OPT_BOX_CHARS +static void do_font_boxchars 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_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_SUNPC_KBD +static void do_sun_kbd 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; +#endif + +/* + * The order of entries MUST match the values given in menu.h + */ +MenuEntry mainMenuEntries[] = { +#if OPT_TOOLBAR + { "toolbar", do_toolbar, 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-redirect", 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_HP_FUNC_KEYS + { "hpFunctionKeys", do_hp_fkeys, NULL }, +#endif +#if OPT_SCO_FUNC_KEYS + { "scoFunctionKeys",do_sco_fkeys, NULL }, +#endif + { "sunFunctionKeys",do_sun_fkeys, NULL }, +#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 }, + { "cursesemul", do_cursesemul, NULL }, + { "visualbell", do_visualbell, NULL }, + { "poponbell", do_poponbell, NULL }, + { "marginbell", do_marginbell, 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 }, +#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 }, +#endif +#endif /* toggles for other font extensions */ + + }; + +#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 + +/* + * 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}; + + Widget m; + TScreen *screen = &xtw->screen; + MenuHeader *data = &menu_names[num]; + MenuList *list = select_menu(w, num); + struct _MenuEntry *entries = data->entry_list; + int nentries = data->entry_len; + + 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 + m = list->w; + if (m == 0) { + return m; + } +#else + m = XtCreatePopupShell(data->internal_name, + simpleMenuWidgetClass, + toplevel, + NULL, 0); + list->w = m; +#endif + 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), m, + &arg, (Cardinal) 1); + } + + /* do not realize at this point */ + return m; +} + +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); +} + +/* + * public interfaces + */ + +/* ARGSUSED */ +static Bool +domenu(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + String * params, /* mainMenu, vtMenu, or tekMenu */ + Cardinal *param_count) /* 0 or 1 */ +{ + TScreen *screen = &term->screen; + MenuIndex me; + Bool created = False; + Widget mw; + + if (*param_count != 1) { + Bell(XkbBI_MinorError, 0); + return False; + } + + if ((me = indexOfMenu(params[0])) == noMenu) { + Bell(XkbBI_MinorError, 0); + return False; + } + + if ((mw = obtain_menu(w, me)) == 0 + || sizeof_menu(w, me) == 0) { + mw = create_menu(w, term, 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_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 (!xtermHasPrinter()) { + set_sensitivity(mw, + mainMenuEntries[mainMenu_print].widget, + False); + set_sensitivity(mw, + mainMenuEntries[mainMenu_print_redir].widget, + False); + } + if (screen->terminal_id < 200) { + set_sensitivity(mw, + mainMenuEntries[mainMenu_8bit_ctrl].widget, + False); + } +#if !defined(SIGTSTP) + set_sensitivity(mw, + mainMenuEntries[mainMenu_suspend].widget, False); +#endif +#if !defined(SIGCONT) + set_sensitivity(mw, + mainMenuEntries[mainMenu_continue].widget, False); +#endif +#ifdef ALLOWLOGGING + if (screen->inhibit & I_LOG) { + set_sensitivity(mw, + mainMenuEntries[mainMenu_logging].widget, False); + } +#endif + if (screen->inhibit & I_SIGNAL) { + int n; + for (n = (int) mainMenu_suspend; n <= (int) mainMenu_quit; ++n) { + set_sensitivity(mw, 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_visualbell(); + update_poponbell(); + update_marginbell(); + update_cursorblink(); + update_altscreen(); + update_titeInhibit(); +#ifndef NO_ACTIVE_ICON + if (!screen->fnt_icon || !screen->iconVwin.window) { + set_sensitivity(mw, + 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) { + set_sensitivity(mw, vtMenuEntries[n].widget, False); + } + } +#endif + } + break; + + case fontMenu: + if (created) { + set_menu_font(True); + set_sensitivity(mw, + fontMenuEntries[fontMenu_fontescape].widget, + (screen->menu_font_names[fontMenu_fontescape] + ? True : False)); +#if OPT_BOX_CHARS + update_font_boxchars(); + set_sensitivity(mw, + fontMenuEntries[fontMenu_font_boxchars].widget, + True); +#endif +#if OPT_DEC_SOFTFONT /* FIXME: not implemented */ + update_font_loadable(); + set_sensitivity(mw, + fontMenuEntries[fontMenu_font_loadable].widget, + False); +#endif +#if OPT_DEC_CHRSET + update_font_doublesize(); + if (term->screen.cache_doublesize == 0) + set_sensitivity(mw, + fontMenuEntries[fontMenu_font_doublesize].widget, + False); +#endif +#if OPT_RENDERFONT + update_font_renderfont(); + if (term->misc.face_name == 0) { + set_sensitivity(mw, + fontMenuEntries[fontMenu_render_font].widget, + False); + } +#endif +#if OPT_WIDE_CHARS + update_font_utf8_mode(); +#endif + } + FindFontSelection(NULL, True); + set_sensitivity(mw, + fontMenuEntries[fontMenu_fontsel].widget, + (screen->menu_font_names[fontMenu_fontsel] + ? True : False)); + break; + +#if OPT_TEK4014 + case tekMenu: + if (created) { + set_tekfont_menu_item(screen->cur.fontsize, True); + update_vtshow(); + } + break; +#endif + default: + break; + } + + return True; +} + +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 = &term->screen; + + if (hold_screen > 1) + hold_screen = 0; + if (screen->pid > 1) + kill_process_group(screen->pid, sig); +#endif +} + +/* + * action routines + */ + +/* ARGSUSED */ +void +DoSecureKeyboard(Time tp GCC_UNUSED) +{ + do_securekbd(vt_shell[mainMenu].w, (XtPointer) 0, (XtPointer) 0); +} + +static void +do_securekbd(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + Time now = CurrentTime; /* XXX - wrong */ + + if (screen->grabbedKbd) { + XUngrabKeyboard(screen->display, now); + ReverseVideo(term); + screen->grabbedKbd = False; + } else { + if (XGrabKeyboard(screen->display, XtWindow(CURRENT_EMU(screen)), + True, GrabModeAsync, GrabModeAsync, now) + != GrabSuccess) { + Bell(XkbBI_MinorError, 100); + } else { + ReverseVideo(term); + screen->grabbedKbd = True; + } + } + update_securekbd(); +} + +static void +do_allowsends(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + screen->allowSendEvents = !screen->allowSendEvents; + update_allowsends(); +} + +static void +do_visualbell(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + screen->visualbell = !screen->visualbell; + update_visualbell(); +} + +static void +do_poponbell(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + screen->poponbell = !screen->poponbell; + update_poponbell(); +} + +#ifdef ALLOWLOGGING +static void +do_logging(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + if (screen->logging) { + CloseLog(screen); + } else { + StartLog(screen); + } + /* 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(True); +} + +static void +do_print_redir(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + setPrinterControlMode(term->screen.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 (term->screen.control_eight_bits != value) { + term->screen.control_eight_bits = value; + update_8bit_control(); + } +} + +static void +do_8bit_control(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + show_8bit_control(!term->screen.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) +{ + term->misc.real_NumLock = !term->misc.real_NumLock; + update_num_lock(); +} + +static void +do_alt_esc(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + term->screen.input_eight_bits = !term->screen.input_eight_bits; + update_alt_esc(); +} + +static void +do_meta_esc(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + term->screen.meta_sends_esc = !term->screen.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->screen.delete_is_del = False; + else + term->screen.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(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(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(keyboardIsSCO); +} +#endif + +static void +do_sun_fkeys(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + toggle_keyboard_type(keyboardIsSun); +} + +#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(keyboardIsVT220); +} +#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(0); +} + +/* + * 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 = &term->screen; + + term->flags ^= SMOOTHSCROLL; + if (term->flags & SMOOTHSCROLL) { + screen->jumpscroll = False; + if (screen->scroll_amt) + FlushScroll(screen); + } 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 = &term->screen; + + screen->scrollkey = !screen->scrollkey; + update_scrollkey(); +} + +static void +do_scrollttyoutput(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + screen->scrollttyoutput = !screen->scrollttyoutput; + update_scrollttyoutput(); +} + +static void +do_allow132(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + screen->c132 = !screen->c132; + update_allow132(); +} + +static void +do_cursesemul(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + screen->curses = !screen->curses; + update_cursesemul(); +} + +static void +do_marginbell(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + if (!(screen->marginbell = !screen->marginbell)) + screen->bellarmed = -1; + update_marginbell(); +} + +#if OPT_TEK4014 +static void +handle_tekshow(Widget gw GCC_UNUSED, Bool allowswitch) +{ + TScreen *screen = &term->screen; + + if (!screen->Tshow) { /* 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(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 = &term->screen; + ToggleCursorBlink(screen); +} +#endif + +/* ARGSUSED */ +static void +do_altscreen(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + ToggleAlternate(screen); +} + +/* ARGSUSED */ +static void +do_titeInhibit(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + term->misc.titeInhibit = !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 = &term->screen; + + if (screen->iconVwin.window) { + Widget shell = XtParent(term); + term->misc.active_icon = !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(False, False); +} + +static void +do_hardreset(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + VTReset(True, False); +} + +static void +do_clearsavedlines(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + VTReset(True, True); +} + +#if OPT_TEK4014 +static void +do_tekmode(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + switch_modes(screen->TekEmu); /* 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) +{ + char *entryname = (char *) closure; + int i; + + for (i = 0; i < NMENUFONTS; i++) { + if (strcmp(entryname, fontMenuEntries[i].name) == 0) { + SetVTFont(term, i, True, NULL); + return; + } + } + Bell(XkbBI_MinorError, 0); +} + +#if OPT_DEC_CHRSET +static void +do_font_doublesize(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + if (term->screen.cache_doublesize != 0) + term->screen.font_doublesize = !term->screen.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) +{ + term->screen.force_box_chars = !term->screen.force_box_chars; + update_font_boxchars(); + Redraw(); +} +#endif + +#if OPT_DEC_SOFTFONT +static void +do_font_loadable(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + term->misc.font_loadable = !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) +{ + TScreen *screen = &term->screen; + int fontnum = screen->menu_font_number; + String name = term->screen.MenuFontName(fontnum); + + term->misc.render_font = !term->misc.render_font; + update_font_renderfont(); + xtermLoadFont(term, xtermFontName(name), True, fontnum); + ScrnRefresh(screen, 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 = &term->screen; + + /* + * 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(screen); + } + } + 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. + */ +} +#endif + +/* + * tek menu + */ + +#if OPT_TEK4014 +static void +do_tektextlarge(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TekSetFontSize(tekMenu_tektextlarge); +} + +static void +do_tektext2(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TekSetFontSize(tekMenu_tektext2); +} + +static void +do_tektext3(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TekSetFontSize(tekMenu_tektext3); +} + +static void +do_tektextsmall(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + + TekSetFontSize(tekMenu_tektextsmall); +} + +static void +do_tekpage(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TekSimulatePageButton(False); +} + +static void +do_tekreset(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TekSimulatePageButton(True); +} + +static void +do_tekcopy(Widget gw GCC_UNUSED, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + TekCopy(); +} + +static void +handle_vtshow(Widget gw GCC_UNUSED, Bool allowswitch) +{ + TScreen *screen = &term->screen; + + if (!screen->Vshow) { /* not showing, turn on */ + set_vt_visibility(True); + } else if (screen->Tshow || allowswitch) { /* is showing, turn off */ + set_vt_visibility(False); + if (!screen->TekEmu && TekRefresh) + dorefresh(); + end_vt_mode(); /* WARNING: this does a longjmp... */ + } else + Bell(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) +{ + TScreen *screen = &term->screen; + + switch_modes(screen->TekEmu); /* 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) +{ + 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(XkbBI_MinorError, 0); + break; + + case -1: + (*proc) (w, closure, data); + break; + + case 0: + if (var) + (*proc) (w, closure, data); + else + Bell(XkbBI_MinorError, 0); + break; + + case 1: + if (!var) + (*proc) (w, closure, data); + else + Bell(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_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, term->screen.allowSendEvents, + params, *param_count, w); +} + +void +HandleSetVisualBell(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_visualbell, term->screen.visualbell, + params, *param_count, w); +} + +void +HandleSetPopOnBell(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_poponbell, term->screen.poponbell, + params, *param_count, w); +} + +#ifdef ALLOWLOGGING +void +HandleLogging(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_logging, term->screen.logging, + params, *param_count, w); +} +#endif + +/* ARGSUSED */ +void +HandlePrintScreen(Widget w, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *param_count GCC_UNUSED) +{ + do_print(w, (XtPointer) 0, (XtPointer) 0); +} + +/* 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 { + 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(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, term->screen.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); +} + +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); +} + +#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, !term->screen.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, term->screen.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, term->screen.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) +{ + if (IsIcon(&(term->screen))) { + Bell(XkbBI_MinorError, 0); + } else { + handle_vt_toggle(do_scrollbar, term->screen.fullVwin.sb_info.width, + params, *param_count, w); + } +} + +void +HandleJumpscroll(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_jumpscroll, term->screen.jumpscroll, + 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(do_scrollkey, term->screen.scrollkey, + params, *param_count, w); +} + +void +HandleScrollTtyOutput(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_scrollttyoutput, term->screen.scrollttyoutput, + params, *param_count, w); +} + +void +HandleAllow132(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_allow132, term->screen.c132, + params, *param_count, w); +} + +void +HandleCursesEmul(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_cursesemul, term->screen.curses, + params, *param_count, w); +} + +void +HandleMarginBell(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_marginbell, term->screen.marginbell, + params, *param_count, w); +} + +#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, term->screen.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, term->screen.alternate, + 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(do_font_doublesize, term->screen.font_doublesize, + params, *param_count, w); +} +#endif + +#if OPT_BOX_CHARS +void +HandleFontBoxChars(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_font_boxchars, term->screen.force_box_chars, + 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) +{ + handle_vt_toggle(do_font_renderfont, term->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, term->screen.utf8_mode, + params, *param_count, w); +} +#endif + +#if OPT_TEK4014 +void +HandleSetTerminalType(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + if (*param_count == 1) { + switch (params[0][0]) { + case 'v': + case 'V': + if (term->screen.TekEmu) + do_vtmode(w, (XtPointer) 0, (XtPointer) 0); + break; + case 't': + case 'T': + if (!term->screen.TekEmu) + do_tekmode(w, (XtPointer) 0, (XtPointer) 0); + break; + default: + Bell(XkbBI_MinorError, 0); + } + } else { + Bell(XkbBI_MinorError, 0); + } +} + +void +HandleVisibility(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + if (*param_count == 2) { + switch (params[0][0]) { + case 'v': + case 'V': + handle_tek_toggle(do_vtonoff, (int) term->screen.Vshow, + params + 1, (*param_count) - 1, w); + break; + case 't': + case 'T': + handle_tek_toggle(do_tekonoff, (int) term->screen.Tshow, + params + 1, (*param_count) - 1, w); + break; + default: + Bell(XkbBI_MinorError, 0); + } + } else { + Bell(XkbBI_MinorError, 0); + } +} + +/* ARGSUSED */ +void +HandleSetTekText(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + void (*proc) PROTO_XT_CALLBACK_ARGS = 0; + + switch (*param_count) { + case 0: + proc = do_tektextlarge; + break; + case 1: + switch (params[0][0]) { + case 'l': + case 'L': + proc = do_tektextlarge; + break; + case '2': + proc = do_tektext2; + break; + case '3': + proc = do_tektext3; + break; + case 's': + case 'S': + proc = do_tektextsmall; + break; + } + break; + } + if (proc) + (*proc) (w, (XtPointer) 0, (XtPointer) 0); + else + Bell(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 */ + +void +UpdateMenuItem(Widget mi, XtArgVal val) +{ + static Arg menuArgs = + {XtNleftBitmap, (XtArgVal) 0}; + + if (mi) { + menuArgs.value = (XtArgVal) ((val) + ? term->screen.menu_item_bitmap + : None); + XtSetValues(mi, &menuArgs, (Cardinal) 1); + } +} + +void +SetItemSensitivity(Widget mi, XtArgVal val) +{ + static Arg menuArgs = + {XtNsensitive, (XtArgVal) 0}; + + if (mi) { + menuArgs.value = (XtArgVal) (val); + XtSetValues(mi, &menuArgs, (Cardinal) 1); + } +} + +#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 void +SetupShell(Widget *menus, MenuList * shell, int n, int m) +{ + char temp[80]; + char *external_name = 0; + + 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); +} + +#endif + +void +SetupMenus(Widget shell, Widget *forms, Widget *menus) +{ +#if OPT_TOOLBAR + Cardinal n; + Arg args[10]; +#endif + + TRACE(("SetupMenus(%s)\n", shell == toplevel ? "vt100" : "tek4014")); + + 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); + + if (shell == toplevel) { /* vt100 */ + for (n = mainMenu; n <= fontMenu; n++) { + SetupShell(menus, vt_shell, n, n - 1); + } + } +#if OPT_TEK4014 + else { /* tek4014 */ + SetupShell(menus, tek_shell, mainMenu, -1); + SetupShell(menus, tek_shell, tekMenu, mainMenu); + } +#endif + +#else + *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) +{ + TScreen *screen = &term->screen; + + XSizeHints sizehints; + + if (XtIsRealized((Widget) term)) { + bzero(&sizehints, sizeof(sizehints)); + xtermSizeHints(term, &sizehints, ScrollbarWidth(screen)); + + XSetWMNormalHints(screen->display, XtWindow(SHELL_OF(term)), &sizehints); + } +} + +#if OPT_TOOLBAR +static int called_SetupToolbar[2] = +{False, False}; + +static void +SetupToolbar(int which) +{ + int n; + + TRACE(("SetupToolbar(%s)\n", which ? "vt100" : "tek4014")); + + if (which) { /* vt100 */ + for (n = mainMenu; n <= fontMenu; n++) { + InitPopup(vt_shell[n].w, menu_names[n].internal_name, 0); + } + } +#if OPT_TEK4014 + else { /* tek4014 */ + InitPopup(tek_shell[mainMenu].w, menu_names[mainMenu].internal_name, 0); + InitPopup(tek_shell[tekMenu].w, menu_names[tekMenu].internal_name, 0); + } +#endif + called_SetupToolbar[which] = True; + ShowToolbar(resource.toolBar); +} + +static TbInfo * +toolbar_info(Widget w) +{ + TRACE(("...getting toolbar_info\n")); +#if OPT_TEK4014 + if (w != (Widget) term) + return &(tekWidget->tek.tb_info); +#endif + return &(WhichVWin(&(term->screen))->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) +{ + TRACE(("ShowToolbar(%d)\n", enable)); + + if (IsIcon(&(term->screen))) { + Bell(XkbBI_MinorError, 0); + } else { + if (enable) { + int which = !TEK4014_ACTIVE(&(term->screen)); + if (!called_SetupToolbar[which]) + SetupToolbar(which); + show_toolbar((Widget) term); +#if OPT_TEK4014 + show_toolbar((Widget) tekWidget); +#endif + } else { + hide_toolbar((Widget) term); +#if OPT_TEK4014 + hide_toolbar((Widget) tekWidget); +#endif + } + resource.toolBar = enable; + update_toolbar(); + } +} + +void +HandleToolbar(Widget w, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *param_count GCC_UNUSED) +{ + if (IsIcon(&(term->screen))) { + Bell(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) +{ + /* + * 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(&(term->screen))) { + Bell(XkbBI_MinorError, 0); + } else { + ShowToolbar(resource.toolBar = !resource.toolBar); + } +} + +void +update_toolbar(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_toolbar].widget, + resource.toolBar); +} +#endif /* OPT_TOOLBAR */ + +void +update_securekbd(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_securekbd].widget, + term->screen.grabbedKbd); +} + +void +update_allowsends(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_allowsends].widget, + term->screen.allowSendEvents); +} + +#ifdef ALLOWLOGGING +void +update_logging(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_logging].widget, + term->screen.logging); +} +#endif + +void +update_print_redir(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_print_redir].widget, + term->screen.printer_controlmode); +} + +void +update_8bit_control(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_8bit_ctrl].widget, + term->screen.control_eight_bits); +} + +void +update_decbkm(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_backarrow].widget, + (term->keyboard.flags & MODE_DECBKM) != 0); +} + +#if OPT_NUM_LOCK +void +update_num_lock(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_num_lock].widget, + term->misc.real_NumLock); +} + +void +update_alt_esc(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_alt_esc].widget, + !term->screen.input_eight_bits); +} + +void +update_meta_esc(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_meta_esc].widget, + term->screen.meta_sends_esc); +} +#endif + +void +update_sun_fkeys(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_sun_fkeys].widget, + term->keyboard.type == keyboardIsSun); +} + +void +update_old_fkeys(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_old_fkeys].widget, + term->keyboard.type == keyboardIsLegacy); +} + +void +update_delete_del(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_delete_del].widget, + xtermDeleteIsDEL()); +} + +#if OPT_SUNPC_KBD +void +update_sun_kbd(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_sun_kbd].widget, + term->keyboard.type == keyboardIsVT220); +} +#endif + +#if OPT_HP_FUNC_KEYS +void +update_hp_fkeys(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_hp_fkeys].widget, + term->keyboard.type == keyboardIsHP); +} +#endif + +#if OPT_SCO_FUNC_KEYS +void +update_sco_fkeys(void) +{ + update_menu_item(term->screen.mainMenu, + mainMenuEntries[mainMenu_sco_fkeys].widget, + term->keyboard.type == keyboardIsSCO); +} +#endif + +void +update_scrollbar(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_scrollbar].widget, + ScrollbarWidth(&term->screen)); +} + +void +update_jumpscroll(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_jumpscroll].widget, + term->screen.jumpscroll); +} + +void +update_reversevideo(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_reversevideo].widget, + (term->misc.re_verse)); +} + +void +update_autowrap(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_autowrap].widget, + (term->flags & WRAPAROUND) != 0); +} + +void +update_reversewrap(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_reversewrap].widget, + (term->flags & REVERSEWRAP) != 0); +} + +void +update_autolinefeed(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_autolinefeed].widget, + (term->flags & LINEFEED) != 0); +} + +void +update_appcursor(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_appcursor].widget, + (term->keyboard.flags & MODE_DECCKM) != 0); +} + +void +update_appkeypad(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_appkeypad].widget, + (term->keyboard.flags & MODE_DECKPAM) != 0); +} + +void +update_scrollkey(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_scrollkey].widget, + term->screen.scrollkey); +} + +void +update_scrollttyoutput(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_scrollttyoutput].widget, + term->screen.scrollttyoutput); +} + +void +update_allow132(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_allow132].widget, + term->screen.c132); +} + +void +update_cursesemul(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_cursesemul].widget, + term->screen.curses); +} + +void +update_visualbell(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_visualbell].widget, + term->screen.visualbell); +} + +void +update_poponbell(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_poponbell].widget, + term->screen.poponbell); +} + +void +update_marginbell(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_marginbell].widget, + term->screen.marginbell); +} + +#if OPT_BLINK_CURS +void +update_cursorblink(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_cursorblink].widget, + term->screen.cursor_blink); +} +#endif + +void +update_altscreen(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_altscreen].widget, + term->screen.alternate); +} + +void +update_titeInhibit(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_titeInhibit].widget, + !(term->misc.titeInhibit)); +} + +#ifndef NO_ACTIVE_ICON +void +update_activeicon(void) +{ + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_activeicon].widget, + term->misc.active_icon); +} +#endif /* NO_ACTIVE_ICON */ + +#if OPT_DEC_CHRSET +void +update_font_doublesize(void) +{ + update_menu_item(term->screen.fontMenu, + fontMenuEntries[fontMenu_font_doublesize].widget, + term->screen.font_doublesize); +} +#endif + +#if OPT_BOX_CHARS +void +update_font_boxchars(void) +{ + update_menu_item(term->screen.fontMenu, + fontMenuEntries[fontMenu_font_boxchars].widget, + term->screen.force_box_chars); +} +#endif + +#if OPT_DEC_SOFTFONT +void +update_font_loadable(void) +{ + update_menu_item(term->screen.fontMenu, + fontMenuEntries[fontMenu_font_loadable].widget, + term->misc.font_loadable); +} +#endif + +#if OPT_RENDERFONT +void +update_font_renderfont(void) +{ + update_menu_item(term->screen.fontMenu, + fontMenuEntries[fontMenu_render_font].widget, + term->misc.render_font); +} +#endif + +#if OPT_WIDE_CHARS +void +update_font_utf8_mode(void) +{ + Widget iw = fontMenuEntries[fontMenu_wide_chars].widget; + Bool active = (term->screen.utf8_mode != uAlways); + Bool enable = (term->screen.utf8_mode != uFalse); + + TRACE(("update_font_utf8_mode active %d, enable %d\n", active, enable)); + set_sensitivity(term->screen.fontMenu, iw, active); + update_menu_item(term->screen.fontMenu, iw, enable); +} +#endif + +#if OPT_TEK4014 +void +update_tekshow(void) +{ + if (!(term->screen.inhibit & I_TEK)) { + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_tekshow].widget, + term->screen.Tshow); + } +} + +void +update_vttekmode(void) +{ + if (!(term->screen.inhibit & I_TEK)) { + update_menu_item(term->screen.vtMenu, + vtMenuEntries[vtMenu_tekmode].widget, + term->screen.TekEmu); + update_menu_item(term->screen.tekMenu, + tekMenuEntries[tekMenu_vtmode].widget, + !term->screen.TekEmu); + } +} + +void +update_vtshow(void) +{ + if (!(term->screen.inhibit & I_TEK)) { + update_menu_item(term->screen.tekMenu, + tekMenuEntries[tekMenu_vtshow].widget, + term->screen.Vshow); + } +} + +void +set_vthide_sensitivity(void) +{ + if (!(term->screen.inhibit & I_TEK)) { + set_sensitivity(term->screen.vtMenu, + vtMenuEntries[vtMenu_vthide].widget, + term->screen.Tshow); + } +} + +void +set_tekhide_sensitivity(void) +{ + if (!(term->screen.inhibit & I_TEK)) { + set_sensitivity(term->screen.tekMenu, + tekMenuEntries[tekMenu_tekhide].widget, + term->screen.Vshow); + } +} + +void +set_tekfont_menu_item(int n, int val) +{ + if (!(term->screen.inhibit & I_TEK)) { + update_menu_item(term->screen.tekMenu, + tekMenuEntries[FS2MI(n)].widget, + (val)); + } +} +#endif /* OPT_TEK4014 */ + +void +set_menu_font(int val) +{ + update_menu_item(term->screen.fontMenu, + fontMenuEntries[term->screen.menu_font_number].widget, + (val)); +} diff --git a/nx-X11/programs/xterm/menu.h b/nx-X11/programs/xterm/menu.h new file mode 100644 index 000000000..e64c5d3dc --- /dev/null +++ b/nx-X11/programs/xterm/menu.h @@ -0,0 +1,441 @@ +/* $XTermId: menu.h,v 1.96 2005/11/03 13:17:28 tom Exp $ */ + +/* $Xorg: menu.h,v 1.4 2001/02/09 02:06:03 xorgcvs Exp $ */ +/* + +Copyright 1999-2004,2005 by Thomas E. Dickey + + 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. + + +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. + +*/ +/* $XFree86: xc/programs/xterm/menu.h,v 3.38 2005/11/03 13:17:28 dickey Exp $ */ + +#ifndef included_menu_h +#define included_menu_h + +#include + +typedef struct _MenuEntry { + 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 HandleAllowSends 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 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 HandleHardReset PROTO_XT_ACTIONS_ARGS; +extern void HandleHpFunctionKeys PROTO_XT_ACTIONS_ARGS; +extern void HandleJumpscroll 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 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 HandleSendSignal PROTO_XT_ACTIONS_ARGS; +extern void HandleSetPopOnBell 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 HandleVisibility PROTO_XT_ACTIONS_ARGS; + +extern void DoSecureKeyboard (Time tp); +extern void SetupMenus (Widget shell, Widget *forms, Widget *menus); + +#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 + 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_HP_FUNC_KEYS + mainMenu_hp_fkeys, +#endif +#if OPT_SCO_FUNC_KEYS + mainMenu_sco_fkeys, +#endif + mainMenu_sun_fkeys, +#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_cursesemul, + vtMenu_visualbell, + vtMenu_poponbell, + vtMenu_marginbell, +#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_fontdefault, + 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, +#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, +#endif +#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 + + +/* + * macros for updating menus + */ + +#define update_menu_item(w,mi,val) UpdateMenuItem(mi,val) +extern void UpdateMenuItem(Widget mi, XtArgVal val); + +#define set_sensitivity(w,mi,val) SetItemSensitivity(mi,val) +extern void SetItemSensitivity(Widget mi, XtArgVal 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 + +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_sun_fkeys(void); +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 + +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_scrollttyoutput(void); +extern void update_allow132(void); +extern void update_cursesemul(void); +extern void update_visualbell(void); +extern void update_poponbell(void); +extern void update_marginbell(void); + +#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); +#else +#define update_font_boxchars() /* 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); +#else +#define update_font_utf8_mode() /* 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); + +#endif /*included_menu_h*/ diff --git a/nx-X11/programs/xterm/minstall.sh b/nx-X11/programs/xterm/minstall.sh new file mode 100644 index 000000000..1271ad3c0 --- /dev/null +++ b/nx-X11/programs/xterm/minstall.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/minstall.sh,v 1.4 2002/12/27 21:05:22 dickey Exp $ +# +# Install manpages, substituting a reasonable section value since XFree86 4.x +# doesn't use constants... +# +# Parameters: +# $1 = program to invoke as "install" +# $2 = manpage to install +# $3 = final installed-path +# + +MINSTALL="$1" +OLD_FILE="$2" +END_FILE="$3" + +suffix=`echo "$END_FILE" | sed -e 's%^[^.]*.%%'` +NEW_FILE=temp$$ + +sed -e 's%__vendorversion__%"X Window System"%' \ + -e s%__apploaddir__%/usr/lib/X11/app-defaults% \ + -e s%__mansuffix__%$suffix%g \ + -e s%__miscmansuffix__%$suffix%g \ + $OLD_FILE >$NEW_FILE + +echo "$MINSTALL $OLD_FILE $END_FILE" +eval "$MINSTALL $NEW_FILE $END_FILE" + +rm -f $NEW_FILE diff --git a/nx-X11/programs/xterm/misc.c b/nx-X11/programs/xterm/misc.c new file mode 100644 index 000000000..447e4c058 --- /dev/null +++ b/nx-X11/programs/xterm/misc.c @@ -0,0 +1,3260 @@ +/* $XTermId: misc.c,v 1.280 2005/11/03 13:17:28 tom Exp $ */ + +/* + * $Xorg: misc.c,v 1.3 2000/08/17 19:55:09 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/misc.c,v 3.101 2005/11/03 13:17:28 dickey Exp $ */ + +/* + * + * Copyright 1999-2004,2005 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 +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#if HAVE_X11_SUNKEYSYM_H +#include +#endif + +#ifdef HAVE_LANGINFO_CODESET +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include + +#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(term)) || \ + (tekWidget && \ + event.xcrossing.window == XtWindow(XtParent(tekWidget))))) +#else +#define OUR_EVENT(event,Type) \ + (event.type == Type && \ + (event.xcrossing.window == XtWindow(XtParent(term)))) +#endif + +static Bool ChangeColorsRequest(XtermWidget pTerm, int start, char + *names, int final); +static void DoSpecialEnterNotify(XEnterWindowEvent * ev); +static void DoSpecialLeaveNotify(XEnterWindowEvent * ev); +static void selectwindow(TScreen * screen, int flag); +static void unselectwindow(TScreen * screen, int flag); +static void Sleep(int msec); + +void +do_xevents(void) +{ + TScreen *screen = &term->screen; + + if (XtAppPending(app_con) + || +#if defined(VMS) || defined(__VMS) + screen->display->qlen > 0 +#else + GetBytesAvailable(ConnectionNumber(screen->display)) > 0 +#endif + ) + xevents(); +} + +void +xevents(void) +{ + XEvent event; + XtInputMask input_mask; + TScreen *screen = &term->screen; + + if (need_cleanup) + Cleanup(0); + + if (screen->scroll_amt) + FlushScroll(screen); + /* + * 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)) & XtIMTimer) + XtAppProcessEvent(app_con, XtIMTimer); +#if OPT_SESSION_MGT + /* + * Session management events are alternative input events. Deal with + * them in the same way. + */ + while ((input_mask = XtAppPending(app_con)) & XtIMAlternateInput) + XtAppProcessEvent(app_con, XtIMAlternateInput); +#endif + + /* + * 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 (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(&event.xcrossing); + else if (OUR_EVENT(event, LeaveNotify)) + DoSpecialLeaveNotify(&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(term)) { + SendMousePosition((Widget) term, &event); + continue; + } + + 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 ((input_mask = XtAppPending(app_con)) & XtIMXEvent); +} + +Cursor +make_colored_cursor(unsigned cursorindex, /* index into font */ + unsigned long fg, /* pixel value */ + unsigned long bg) /* pixel value */ +{ + TScreen *screen = &term->screen; + Cursor c; + Display *dpy = screen->display; + + c = XCreateFontCursor(dpy, cursorindex); + if (c == (Cursor) 0) + return (c); + + recolor_cursor(c, fg, bg); + return (c); +} + +/* ARGSUSED */ +void +HandleKeyPressed(Widget w GCC_UNUSED, + XEvent * event, + String * params GCC_UNUSED, + Cardinal *nparams GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + TRACE(("Handle 7bit-key\n")); +#ifdef ACTIVEWINDOWINPUTONLY + if (w == CURRENT_EMU(screen)) +#endif + Input(&term->keyboard, screen, &event->xkey, False); +} + +/* ARGSUSED */ +void +HandleEightBitKeyPressed(Widget w GCC_UNUSED, + XEvent * event, + String * params GCC_UNUSED, + Cardinal *nparams GCC_UNUSED) +{ + TScreen *screen = &term->screen; + + TRACE(("Handle 8bit-key\n")); +#ifdef ACTIVEWINDOWINPUTONLY + if (w == CURRENT_EMU(screen)) +#endif + Input(&term->keyboard, screen, &event->xkey, True); +} + +/* ARGSUSED */ +void +HandleStringEvent(Widget w GCC_UNUSED, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *nparams) +{ + TScreen *screen = &term->screen; + +#ifdef ACTIVEWINDOWINPUTONLY + if (w != CURRENT_EMU(screen)) + return; +#endif + + if (*nparams != 1) + return; + + if ((*params)[0] == '0' && (*params)[1] == 'x' && (*params)[2] != '\0') { + Char c, *p; + Char hexval[2]; + hexval[0] = hexval[1] = 0; + for (p = (Char *) (*params + 2); (c = *p); p++) { + hexval[0] *= 16; + if (isupper(c)) + c = tolower(c); + if (c >= '0' && c <= '9') + hexval[0] += c - '0'; + else if (c >= 'a' && c <= 'f') + hexval[0] += c - 'a' + 10; + else + break; + } + if (c == '\0') + StringInput(screen, hexval, 1); + } else { + StringInput(screen, (Char *) * params, strlen(*params)); + } +} + +/* + * 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) { + char *value = params[0]; + int need = strlen(value); + int used = VTbuffer->next - VTbuffer->buffer; + int have = VTbuffer->last - VTbuffer->buffer; + + if (have - used + need < BUF_SIZE) { + + fillPtyData(&term->screen, VTbuffer, value, (int) strlen(value)); + + TRACE(("Interpret %s\n", value)); + VTbuffer->update++; + } + } +} + +static void +DoSpecialEnterNotify(XEnterWindowEvent * ev) +{ + TScreen *screen = &term->screen; + + TRACE(("DoSpecialEnterNotify(%d)\n", screen->select)); +#ifdef ACTIVEWINDOWINPUTONLY + if (ev->window == XtWindow(XtParent(CURRENT_EMU(screen)))) +#endif + if (((ev->detail) != NotifyInferior) && + ev->focus && + !(screen->select & FOCUS)) + selectwindow(screen, INWINDOW); +} + +/*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")); +} + +static void +DoSpecialLeaveNotify(XEnterWindowEvent * ev) +{ + TScreen *screen = &term->screen; + + TRACE(("DoSpecialLeaveNotify(%d)\n", screen->select)); +#ifdef ACTIVEWINDOWINPUTONLY + if (ev->window == XtWindow(XtParent(CURRENT_EMU(screen)))) +#endif + if (((ev->detail) != NotifyInferior) && + ev->focus && + !(screen->select & FOCUS)) + unselectwindow(screen, INWINDOW); +} + +/*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")); +} + +/*ARGSUSED*/ +void +HandleFocusChange(Widget w GCC_UNUSED, + XtPointer eventdata GCC_UNUSED, + XEvent * ev, + Boolean * cont GCC_UNUSED) +{ + XFocusChangeEvent *event = (XFocusChangeEvent *) ev; + TScreen *screen = &term->screen; + + TRACE(("HandleFocusChange type=%d, mode=%d, detail=%d\n", + event->type, + event->mode, + event->detail)); + + if (event->type == FocusIn) { + /* + * 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)); + } else { + /* + * XGrabKeyboard() will generate FocusOut/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(XkbBI_Info, 100); + ReverseVideo(term); + screen->grabbedKbd = False; + update_securekbd(); + } + } +} + +static void +selectwindow(TScreen * screen, int flag) +{ + TRACE(("selectwindow(%d) flag=%d\n", screen->select, flag)); + +#if OPT_TEK4014 + if (screen->TekEmu) { + if (!Ttoggled) + TCursorToggle(TOGGLE); + screen->select |= flag; + if (!Ttoggled) + TCursorToggle(TOGGLE); + return; + } else +#endif + { + if (screen->xic) + XSetICFocus(screen->xic); + + if (screen->cursor_state && CursorMoved(screen)) + HideCursor(); + screen->select |= flag; + if (screen->cursor_state) + ShowCursor(); + return; + } +} + +static void +unselectwindow(TScreen * screen, int flag) +{ + TRACE(("unselectwindow(%d) flag=%d\n", screen->select, flag)); + + if (screen->always_highlight) + return; + +#if OPT_TEK4014 + if (screen->TekEmu) { + if (!Ttoggled) + TCursorToggle(TOGGLE); + screen->select &= ~flag; + if (!Ttoggled) + TCursorToggle(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 long lastBellTime; /* in milliseconds */ + +void +Bell(int which GCC_UNUSED, int percent) +{ + TScreen *screen = &term->screen; + struct timeval curtime; + long now_msecs; + + TRACE(("BELL %d\n", percent)); + + /* 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 { +#if defined(HAVE_XKBBELL) + XkbBell(screen->display, VShellWindow, percent, which); +#else + XBell(screen->display, percent); +#endif + } + + if (screen->poponbell) + XRaiseWindow(screen->display, VShellWindow); + + 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(screen); + 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 = &term->screen; + + 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 (screen->TekEmu) { + flashWindow(screen, TWindow(screen), visualGC, + TFullWidth(screen), + TFullHeight(screen)); + } 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 = &term->screen; + + if (ev->xproperty.atom == XA_NOTICE) { + screen->bellInProgress = False; + } +} + +Window +WMFrameWindow(XtermWidget termw) +{ + Window win_root, win_current, *children; + Window win_parent = 0; + unsigned int nchildren; + + win_current = XtWindow(termw); + + /* find the parent which is child of root */ + do { + if (win_parent) + win_current = win_parent; + XQueryTree((&termw->screen)->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(int *xp, int *yp, TScreen * screen) +{ + Char *linep; + + while (*yp >= 0) { + linep = BUF_CHARS(screen->allbuf, *yp); + if (--*xp >= 0) + return linep[*xp]; + if (--*yp < 0) /* go to previous line */ + break; + *xp = MaxCols(screen); + if (!((long) BUF_FLAGS(screen->allbuf, *yp) & LINEWRAPPED)) + return ' '; /* treat lines as separate */ + } + return -1; +} + +static char * +dabbrev_prev_word(int *xp, int *yp, TScreen * screen) +{ + static char ab[MAXWLEN]; + char *abword; + int c; + + abword = ab + MAXWLEN - 1; + *abword = '\0'; /* end of string marker */ + + while ((c = dabbrev_prev_char(xp, yp, screen)) >= 0 && + IS_WORD_CONSTITUENT(c)) + if (abword > ab) /* store only |MAXWLEN| last chars */ + *(--abword) = c; + if (c < 0) { + if (abword < ab + MAXWLEN - 1) + return abword; + else + return 0; + } + + while ((c = dabbrev_prev_char(xp, yp, screen)) >= 0 && + !IS_WORD_CONSTITUENT(c)) ; /* skip preceding spaces */ + (*xp)++; /* can be | > screen->max_col| */ + return abword; +} + +static int +dabbrev_expand(TScreen * screen) +{ + int pty = screen->respond; /* file descriptor of pty */ + + static int x, y; + static char *dabbrev_hint = 0, *lastexpansion = 0; + + char *expansion; + Char *copybuffer; + size_t hint_len; + unsigned i; + unsigned del_cnt; + unsigned buf_cnt; + + if (!screen->dabbrev_working) { /* initialize */ + x = screen->cur_col; + y = screen->cur_row + screen->savelines; + + free(dabbrev_hint); /* free(NULL) is OK */ + dabbrev_hint = dabbrev_prev_word(&x, &y, screen); + if (!dabbrev_hint) + return 0; /* no preceding word? */ + free(lastexpansion); + if (!(lastexpansion = strdup(dabbrev_hint))) /* make own copy */ + return 0; + if (!(dabbrev_hint = strdup(dabbrev_hint))) { + free(lastexpansion); + return 0; + } + screen->dabbrev_working = 1; /* we are in the middle of dabbrev process */ + } + + hint_len = strlen(dabbrev_hint); + while ((expansion = dabbrev_prev_word(&x, &y, screen))) { + 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) /* no expansion found */ + return 0; + + del_cnt = strlen(lastexpansion) - hint_len; + buf_cnt = del_cnt + strlen(expansion) - hint_len; + if (!(copybuffer = TypeMallocN(Char, buf_cnt))) + return 0; + for (i = 0; i < del_cnt; i++) { /* delete previous expansion */ + copybuffer[i] = screen->dabbrev_erase_char; + } + memmove(copybuffer + del_cnt, + expansion + hint_len, + strlen(expansion) - hint_len); + v_write(pty, copybuffer, buf_cnt); + screen->dabbrev_working = 1; /* v_write() just set it to 1 */ + free(copybuffer); + + free(lastexpansion); + lastexpansion = strdup(expansion); + if (!lastexpansion) + return 0; + return 1; +} + +/*ARGSUSED*/ +void +HandleDabbrevExpand(Widget gw, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *nparams GCC_UNUSED) +{ + XtermWidget w = (XtermWidget) gw; + TScreen *screen = &w->screen; + if (!dabbrev_expand(screen)) + Bell(XkbBI_TerminalBell, 0); +} +#endif /* OPT_DABBREV */ + +#if OPT_MAXIMIZE +/*ARGSUSED*/ +void +HandleDeIconify(Widget gw, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *nparams GCC_UNUSED) +{ + if (IsXtermWidget(gw)) { + TScreen *screen = &((XtermWidget) gw)->screen; + XMapWindow(screen->display, VShellWindow); + } +} + +/*ARGSUSED*/ +void +HandleIconify(Widget gw, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *nparams GCC_UNUSED) +{ + if (IsXtermWidget(gw)) { + TScreen *screen = &((XtermWidget) gw)->screen; + XIconifyWindow(screen->display, + VShellWindow, + DefaultScreen(screen->display)); + } +} + +int +QueryMaximize(XtermWidget termw, unsigned *width, unsigned *height) +{ + TScreen *screen = &termw->screen; + 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(termw)), + &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, + &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 = hints.max_width; + if ((unsigned) hints.max_height < *height) + *height = hints.max_height; + } + return 1; + } + return 0; +} + +void +RequestMaximize(XtermWidget termw, int maximize) +{ + TScreen *screen = &termw->screen; + XWindowAttributes wm_attrs, vshell_attrs; + unsigned root_width, root_height; + + if (maximize) { + + if (QueryMaximize(termw, &root_width, &root_height)) { + + if (XGetWindowAttributes(screen->display, + WMFrameWindow(termw), + &wm_attrs)) { + + if (XGetWindowAttributes(screen->display, + VShellWindow, + &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 = vshell_attrs.width; + screen->restore_height = 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 -= ((wm_attrs.width - vshell_attrs.width) + + (wm_attrs.border_width * 2)); + root_height -= ((wm_attrs.height - vshell_attrs.height) + + (wm_attrs.border_width * 2)); + + XMoveResizeWindow(screen->display, VShellWindow, + 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, + screen->restore_x, + screen->restore_y, + screen->restore_width, + screen->restore_height); + } + } +} + +/*ARGSUSED*/ +void +HandleMaximize(Widget gw, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *nparams GCC_UNUSED) +{ + if (IsXtermWidget(gw)) { + RequestMaximize((XtermWidget) gw, 1); + } +} + +/*ARGSUSED*/ +void +HandleRestoreSize(Widget gw, + XEvent * event GCC_UNUSED, + String * params GCC_UNUSED, + Cardinal *nparams GCC_UNUSED) +{ + if (IsXtermWidget(gw)) { + RequestMaximize((XtermWidget) gw, 0); + } +} +#endif /* OPT_MAXIMIZE */ + +void +Redraw(void) +{ + TScreen *screen = &term->screen; + XExposeEvent event; + + 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 (TWindow(screen) && screen->Tshow) { + event.window = TWindow(screen); + 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; + + time(&tstamp); + 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))) + || ((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, 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", + uid, geteuid(), + gid, 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) + _exit(ERROR_SETUID); + if (setuid(uid) == -1) + _exit(ERROR_SETUID); + fd = open(pathname, + O_WRONLY | O_CREAT | (append ? O_APPEND : O_EXCL), + mode); + if (fd >= 0) { + close(fd); + _exit(0); + } else + _exit(1); + /* 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 == term->screen.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 */ + +#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) +{ + TScreen *screen = &term->screen; + +#ifdef SYSV + (void) signal(SIGPIPE, SIG_IGN); +#endif /* SYSV */ + if (screen->logging) + CloseLog(screen); +} +#endif /* ALLOWLOGFILEEXEC */ + +void +StartLog(TScreen * screen) +{ + static char *log_default; +#ifdef ALLOWLOGFILEEXEC + char *cp; +#endif /* ALLOWLOGFILEEXEC */ + + 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; + + (void) time(&now); + 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, 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 = getenv("SHELL")) == NULL || *cp == 0) + && ((pw = getpwuid(screen->uid)) == NULL + || *(cp = pw->pw_shell) == 0)) + || (shell = CastMallocN(char, strlen(cp))) == 0) { + shell = "/bin/sh"; + } else { + strcpy(shell, cp); + } + + signal(SIGHUP, SIG_DFL); + signal(SIGCHLD, SIG_DFL); + + /* (this is redundant) */ + if (setgid(screen->gid) == -1) + exit(ERROR_SETUID); + if (setuid(screen->uid) == -1) + 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(XkbBI_Info, 0); + Bell(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(TScreen * screen) +{ + if (!screen->logging || (screen->inhibit & I_LOG)) + return; + FlushLog(screen); + close(screen->logfd); + screen->logging = False; + update_logging(); +} + +void +FlushLog(TScreen * screen) +{ + 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 = cp - screen->logstart) > 0) { + write(screen->logfd, (char *) screen->logstart, (unsigned) i); + } + screen->logstart = VTbuffer->next; + } +} + +#endif /* ALLOWLOGGING */ + +/***====================================================================***/ + +#if OPT_ISO_COLORS +static void +ReportAnsiColorRequest(XtermWidget pTerm, int colornum, int final) +{ + XColor color; + Colormap cmap = pTerm->core.colormap; + char buffer[80]; + + TRACE(("ReportAnsiColorRequest %d\n", colornum)); + color.pixel = GET_COLOR_RES(pTerm->screen.Acolors[colornum]); + XQueryColor(term->screen.display, cmap, &color); + sprintf(buffer, "4;%d;rgb:%04x/%04x/%04x", + colornum, + color.red, + color.green, + color.blue); + unparseputc1(OSC, pTerm->screen.respond); + unparseputs(buffer, pTerm->screen.respond); + unparseputc1(final, pTerm->screen.respond); +} + +/* +* 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. +* Return False if not able to find or allocate a color. +*/ +static int +find_closest_color(Display * display, Colormap cmap, XColor * def) +{ + double tmp, distance, closestDistance; + int closest, numFound; + XColor *colortable; + XVisualInfo myTemplate, *visInfoPtr; + char *found; + unsigned i; + unsigned cmap_size; + unsigned attempts; + + myTemplate.visualid = XVisualIDFromVisual(DefaultVisual(display, + XDefaultScreen(display))); + visInfoPtr = XGetVisualInfo(display, (long) VisualIDMask, + &myTemplate, &numFound); + if (numFound < 1) { + /* FindClosestColor couldn't lookup visual */ + return False; + } + + cmap_size = visInfoPtr->colormap_size; + XFree((char *) visInfoPtr); + colortable = TypeMallocN(XColor, cmap_size); + if (!colortable) { + return False; /* out of memory */ + } + found = TypeCallocN(char, cmap_size); + if (!found) { + free(colortable); + return False; /* out of memory */ + } + + for (i = 0; i < cmap_size; i++) { + colortable[i].pixel = (unsigned long) i; + } + XQueryColors(display, cmap, colortable, (int) cmap_size); + + /* + * Find the color that best approximates the desired one, then + * try to allocate that color. If that fails, it must mean that + * the color was read-write (so we can't use it, since its owner + * might change it) or else it was already freed. Try again, + * over and over again, until something succeeds. + */ + for (attempts = 0; attempts < cmap_size; attempts++) { + closestDistance = 1e30; + closest = 0; + for (i = 0; i < cmap_size; i++) { + if (!found[closest]) { + /* + * Use Euclidean distance in RGB space, weighted by Y (of YIQ) + * as the objective function; this accounts for differences + * in the color sensitivity of the eye. + */ + tmp = .30 * (((int) def->red) - (int) colortable[i].red); + distance = tmp * tmp; + tmp = .61 * (((int) def->green) - (int) colortable[i].green); + distance += tmp * tmp; + tmp = .11 * (((int) def->blue) - (int) colortable[i].blue); + distance += tmp * tmp; + if (distance < closestDistance) { + closest = i; + closestDistance = distance; + } + } + } + if (XAllocColor(display, cmap, &colortable[closest]) != 0) { + *def = colortable[closest]; + break; + } + found[closest] = True; /* Don't look at this entry again */ + } + + free(colortable); + free(found); + if (attempts < cmap_size) { + return True; /* Got a closest matching color */ + } else { + return False; /* Couldn't allocate a near match */ + } +} + +static Bool +AllocateAnsiColor(XtermWidget pTerm, + ColorRes * res, + char *spec) +{ + XColor def; + TScreen *screen = &pTerm->screen; + Colormap cmap = pTerm->core.colormap; + + if (XParseColor(screen->display, cmap, spec, &def) + && (XAllocColor(screen->display, cmap, &def) + || find_closest_color(screen->display, cmap, &def))) { + SET_COLOR_RES(res, def.pixel); + TRACE(("AllocateAnsiColor[%d] %s (pixel %#lx)\n", + (res - screen->Acolors), spec, def.pixel)); +#if OPT_COLOR_RES + res->mode = True; +#endif + return (True); + } + TRACE(("AllocateAnsiColor %s (failed)\n", spec)); + return (False); +} + +#if OPT_COLOR_RES +Pixel +xtermGetColorRes(ColorRes * res) +{ + Pixel result = 0; + + if (res->mode) { + result = res->value; + } else { + TRACE(("xtermGetColorRes for Acolors[%d]\n", + res - term->screen.Acolors)); + + if (res >= term->screen.Acolors) { + assert(res - term->screen.Acolors < MAXCOLORS); + + if (!AllocateAnsiColor(term, res, res->resource)) { + res->value = term->screen.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 Bool +ChangeAnsiColorRequest(XtermWidget pTerm, + char *buf, + int final) +{ + char *name; + int color; + int r = False; + + 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 >= NUM_ANSI_COLORS) + break; + buf = strchr(name, ';'); + if (buf) { + *buf = '\0'; + buf++; + } + if (!strcmp(name, "?")) + ReportAnsiColorRequest(pTerm, color, final); + else { + TRACE(("ChangeAnsiColor for Acolors[%d]\n", color)); + if (!AllocateAnsiColor(pTerm, &(pTerm->screen.Acolors[color]), name)) + break; + /* FIXME: free old color somehow? We aren't for the other color + * change style (dynamic colors). + */ + r = True; + } + } + if (r) + ChangeAnsiColors(pTerm); + return (r); +} +#else +#define find_closest_color(display, cmap, def) 0 +#endif /* OPT_ISO_COLORS */ + +#if OPT_PASTE64 +static void +ManipulateSelectionData(TScreen * screen, char *buf, int final) +{ +#define PDATA(a,b) { a, #b } + static struct { + char given; + char *result; + } table[] = { + 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), + }; + + char *base = buf; + Cardinal j, n = 0; + char **select_args = 0; + + TRACE(("Manipulate selection data\n")); + + while (*buf != ';' && *buf != '\0') { + ++buf; + } + + if (*buf == ';') { + *buf++ = '\0'; + + if (*base == '\0') + base = "p0"; + 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) { + select_args[n++] = table[j].result; + TRACE(("atom[%d] %s\n", n, table[j].result)); + break; + } + } + ++base; + } + + if (!strcmp(buf, "?")) { + TRACE(("Getting selection\n")); + unparseputc1(OSC, screen->respond); + unparseputs("52", screen->respond); + unparseputc(';', screen->respond); + + unparseputs(base, screen->respond); + unparseputc(';', screen->respond); + + screen->base64_paste = 1; /* Tells xtermGetSelection data is base64 encoded */ + xtermGetSelection((Widget) term, 0, select_args, n, NULL); + unparseputc1(final, screen->respond); + } else { + TRACE(("Setting selection with %s\n", buf)); + ClearSelectionBuffer(); + while (*buf != '\0') + AppendToSelectionBuffer(screen, CharOf(*buf++)); + CompleteSelection(select_args, n); + } + free(select_args); + } +} +#endif /* OPT_PASTE64 */ + +/***====================================================================***/ + +void +do_osc(Char * oscbuf, unsigned len GCC_UNUSED, int final) +{ + TScreen *screen = &(term->screen); + int mode; + Char *cp; + int state = 0; + char *buf = 0; + + TRACE(("do_osc %s\n", oscbuf)); + + /* + * Lines should be of the form number ; string , however + * older xterms can accept 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 + * , which is the 7-bit equivalent to . + */ + mode = 0; + for (cp = oscbuf; *cp != '\0'; cp++) { + switch (state) { + case 0: + if (isdigit(*cp)) { + mode = 10 * mode + (*cp - '0'); + if (mode > 65535) + return; + break; + } + /* FALLTHRU */ + case 1: + if (*cp != ';') + return; + state = 2; + break; + case 2: + buf = (char *) cp; + state = 3; + /* FALLTHRU */ + default: + if (ansi_table[CharOf(*cp)] != CASE_PRINT) + return; + } + } + if (buf == 0) + return; + + switch (mode) { + case 0: /* new icon name and title */ + Changename(buf); + Changetitle(buf); + break; + + case 1: /* new icon name only */ + Changename(buf); + break; + + case 2: /* new title only */ + Changetitle(buf); + break; + + case 3: /* change X property */ + ChangeXprop(buf); + break; +#if OPT_ISO_COLORS + case 4: + ChangeAnsiColorRequest(term, buf, final); + break; +#endif + case 10 + TEXT_FG: + case 10 + TEXT_BG: + case 10 + TEXT_CURSOR: + case 10 + MOUSE_FG: + case 10 + MOUSE_BG: +#if OPT_HIGHLIGHT_COLOR + case 10 + HIGHLIGHT_BG: +#endif +#if OPT_TEK4014 + case 10 + TEK_FG: + case 10 + TEK_BG: + case 10 + TEK_CURSOR: +#endif + if (term->misc.dynamicColors) + ChangeColorsRequest(term, mode - 10, buf, final); + break; + + case 30: + case 31: + /* reserved for Konsole (Stephan Binner ) */ + 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 (buf != 0 + && strcmp(buf, "?") + && (cp = CastMallocN(char, strlen(buf)) != NULL)) { + strcpy(cp, buf); + if (screen->logfile) + free(screen->logfile); + screen->logfile = cp; + break; + } +#endif + Bell(XkbBI_Info, 0); + Bell(XkbBI_Info, 0); + break; +#endif /* ALLOWLOGGING */ + + case 50: + if (buf != 0 && !strcmp(buf, "?")) { + int num = screen->menu_font_number; + + unparseputc1(OSC, screen->respond); + unparseputs("50", screen->respond); + + if ((buf = screen->MenuFontName(num)) != 0) { + unparseputc(';', screen->respond); + unparseputs(buf, screen->respond); + } + unparseputc1(final, screen->respond); + } else if (buf != 0) { + VTFontNames fonts; + + memset(&fonts, 0, sizeof(fonts)); + + /* + * If the font specification is a "#", followed by an + * optional sign and optional number, lookup the + * corresponding menu font entry. + */ + if (*buf == '#') { + int num = screen->menu_font_number; + int rel = 0; + + if (*++buf == '+') { + rel = 1; + buf++; + } else if (*buf == '-') { + rel = -1; + buf++; + } + + if (isdigit(CharOf(*buf))) { + int val = atoi(buf); + if (rel > 0) + rel = val; + else if (rel < 0) + rel = -val; + else + num = val; + } else if (rel == 0) { + num = 0; + } + + if (rel != 0) + num = lookupRelativeFontSize(screen, + screen->menu_font_number, rel); + + if (num < 0 + || num > fontMenu_lastBuiltin + || (buf = screen->MenuFontName(num)) == 0) { + Bell(XkbBI_MinorError, 0); + break; + } + } + fonts.f_n = buf; + SetVTFont(term, fontMenu_fontescape, True, &fonts); + } + break; + case 51: + /* reserved for Emacs shell (Rob Mayoff ) */ + break; + +#if OPT_PASTE64 + case 52: + if (screen->allowWindowOps && (buf != 0)) + ManipulateSelectionData(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. + */ + } +} + +#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(char **cp) +{ + int c; + + for (;;) { + if ((c = **cp) != '\0') + *cp = *cp + 1; + if (c == ';' || c == '\0') + return -1; + 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; + } +} + +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(char *cp) +{ + while (*cp) { + 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) + (*cp++ - '0'); + if (*cp == '/') { + cp++; + while ((hi = udk_value(&cp)) >= 0 + && (lo = udk_value(&cp)) >= 0) { + str[len++] = (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, 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 >= 0x20 && ch <= 0x2f) { + if (len < 2) + DscsName[len++] = ch; + } else if (ch >= 0x30 && ch <= 0x7e) { + DscsName[len++] = 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 -= 0x3f; + for (n = 0; n < 6; ++n) { + bits[row + n][col] = (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, char **string) +{ + char *cp = *string; + short nparam = 0; + + memset(params, 0, sizeof(*params)); + while (*cp != '\0') { + Char ch = CharOf(*cp++); + + if (isdigit(ch)) { + if (nparam < NPARAM) { + params->a_param[nparam] *= 10; + params->a_param[nparam] += (ch - '0'); + } + } else if (ch == ';') { + if (++nparam < NPARAM) + params->a_nparam = nparam; + } else if (ch < 32) { + ; + } else { + /* should be 0x30 to 0x7e */ + params->a_final = ch; + break; + } + } + *string = cp; +} + +void +do_dcs(Char * dcsbuf, size_t dcslen) +{ + TScreen *screen = &term->screen; + char reply[BUFSIZ]; + char *cp = (char *) dcsbuf; + Bool okay; + ANSI params; + + TRACE(("do_dcs(%s:%d)\n", (char *) dcsbuf, 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) + && (term->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 (term->flags & BOLD) + strcat(reply, ";1"); + if (term->flags & UNDERLINE) + strcat(reply, ";4"); + if (term->flags & BLINK) + strcat(reply, ";5"); + if (term->flags & INVERSE) + strcat(reply, ";7"); + if (term->flags & INVISIBLE) + strcat(reply, ";8"); + if_OPT_EXT_COLORS(screen, { + if (term->flags & FG_COLOR) { + if (term->cur_foreground >= 16) + sprintf(reply + strlen(reply), + ";38;5;%d", term->cur_foreground); + else + sprintf(reply + strlen(reply), + ";%d%d", + term->cur_foreground >= 8 ? 9 : 3, + term->cur_foreground >= 8 ? + term->cur_foreground - 8 : + term->cur_foreground); + } + if (term->flags & BG_COLOR) { + if (term->cur_background >= 16) + sprintf(reply + strlen(reply), + ";48;5;%d", term->cur_foreground); + else + sprintf(reply + strlen(reply), + ";%d%d", + term->cur_background >= 8 ? 10 : 4, + term->cur_background >= 8 ? + term->cur_background - 8 : + term->cur_background); + } + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + if (term->flags & FG_COLOR) + sprintf(reply + strlen(reply), + ";%d%d", + term->cur_foreground >= 8 ? 9 : 3, + term->cur_foreground >= 8 ? + term->cur_foreground - 8 : + term->cur_foreground); + if (term->flags & BG_COLOR) + sprintf(reply + strlen(reply), + ";%d%d", + term->cur_background >= 8 ? 10 : 4, + term->cur_background >= 8 ? + term->cur_background - 8 : + term->cur_background); + }); + strcat(reply, "m"); + } else + okay = False; + + unparseputc1(DCS, screen->respond); + unparseputc(okay ? '1' : '0', screen->respond); + unparseputc('$', screen->respond); + unparseputc('r', screen->respond); + if (okay) + cp = reply; + unparseputs(cp, screen->respond); + unparseputc1(ST, screen->respond); + } else { + unparseputc(CAN, screen->respond); + } + break; +#if OPT_TCAP_QUERY + case '+': + cp++; + if (*cp == 'q') { + unsigned state; + int code; + char *tmp; + char *parsed = ++cp; + + unparseputc1(DCS, screen->respond); + + code = xtermcapKeycode(&parsed, &state); + unparseputc(code >= 0 ? '1' : '0', screen->respond); + + unparseputc('+', screen->respond); + unparseputc('r', screen->respond); + + while (*cp != 0) { + if (cp == parsed) + break; /* no data found, error */ + + for (tmp = cp; tmp != parsed; ++tmp) + unparseputc(*tmp, screen->respond); + + if (code >= 0) { + unparseputc('=', screen->respond); + screen->tc_query = code; + /* XK_COLORS is a fake code for the "Co" entry (maximum + * number of colors) */ + if (code == XK_COLORS) { +# if OPT_256_COLORS + unparseputc('2', screen->respond); + unparseputc('5', screen->respond); + unparseputc('6', screen->respond); +# elif OPT_88_COLORS + unparseputc('8', screen->respond); + unparseputc('8', screen->respond); +# else + unparseputc('1', screen->respond); + unparseputc('6', screen->respond); +# endif + } else { + XKeyEvent event; + event.state = state; + Input(&(term->keyboard), screen, &event, False); + } + screen->tc_query = -1; + } else { + break; /* no match found, error */ + } + + cp = parsed; + if (*parsed == ';') { + unparseputc(*parsed++, screen->respond); + cp = parsed; + code = xtermcapKeycode(&parsed, &state); + } + } + unparseputc1(ST, screen->respond); + } + break; +#endif + default: + parse_ansi_params(¶ms, &cp); + switch (params.a_final) { + case '|': /* DECUDK */ + if (params.a_param[0] == 0) + reset_decudk(); + parse_decudk(cp); + break; + case '{': /* DECDLD */ + parse_decdld(¶ms, cp); + break; + } + break; + } +} + +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(String attribute, char *value) +{ + Arg args[1]; + const char *name = (value != 0) ? (char *) value : ""; + TScreen *screen = &term->screen; + Widget w = CURRENT_EMU(screen); + Widget top = SHELL_OF(w); + + TRACE(("ChangeGroup(attribute=%s, value=%s)\n", attribute, name)); + +#if OPT_WIDE_CHARS + /* + * Title strings are limited to ISO-8859-1, which is consistent with the + * printable data in sos_table. However, if we're running in UTF-8 mode, + * 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()) { + int n; + unsigned limit = strlen(name); + + if (limit < 1024) { + for (n = 0; name[n] != '\0'; ++n) { + if (CharOf(name[n]) > 127) { + static Char *converted; + if (converted != 0) + free(converted); + if ((converted = TypeMallocN(Char, 1 + (5 * limit))) != 0) { + Char *temp = converted; + while (*name != 0) { + temp = convertToUTF8(temp, CharOf(*name)); + ++name; + } + *temp = 0; + name = (const char *) converted; + } + break; + } + } + } + } +#endif + +#if OPT_SAME_NAME + /* If the attribute isn't going to change, then don't bother... */ + + if (sameName) { + char *buf; + XtSetArg(args[0], attribute, &buf); + XtGetValues(top, args, 1); + if (strcmp(name, buf) == 0) + return; + } +#endif /* OPT_SAME_NAME */ + + XtSetArg(args[0], attribute, name); + XtSetValues(top, args, 1); +} + +void +Changename(char *name) +{ + if (name == 0) + name = ""; +#if OPT_ZICONBEEP /* If warning should be given then give it */ + if (zIconBeep && zIconBeep_flagged) { + char *newname = CastMallocN(char, strlen(name) + 4); + if (!newname) { + fprintf(stderr, "malloc failed in Changename\n"); + return; + } + strcpy(newname, "*** "); + strcat(newname, name); + ChangeGroup(XtNiconName, newname); + free(newname); + } else +#endif /* OPT_ZICONBEEP */ + ChangeGroup(XtNiconName, name); +} + +void +Changetitle(char *name) +{ + ChangeGroup(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); + } +} + +/***====================================================================***/ + +static ScrnColors *pOldColors = NULL; + +static Bool +GetOldColors(XtermWidget pTerm) +{ + int i; + if (pOldColors == NULL) { + pOldColors = (ScrnColors *) XtMalloc(sizeof(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(pTerm, 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 + default: + break; + } + return n; +} + +static void +ReportColorRequest(XtermWidget pTerm, int ndx, int final) +{ + XColor color; + Colormap cmap = pTerm->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 = (term->misc.re_verse) ? oppositeColor(ndx) : ndx; + + GetOldColors(pTerm); + color.pixel = pOldColors->colors[ndx]; + XQueryColor(term->screen.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(OSC, pTerm->screen.respond); + unparseputs(buffer, pTerm->screen.respond); + unparseputc1(final, pTerm->screen.respond); +} + +static Bool +UpdateOldColors(XtermWidget pTerm 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); +} + +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]) { + tmpName = XtMalloc(strlen(pOld->names[TEXT_BG]) + 1); + if (tmpName) { + strcpy(tmpName, pOld->names[TEXT_BG]); + 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 pTerm, + ScrnColors * pNew, + int ndx, + const char *name) +{ + XColor def; + TScreen *screen = &pTerm->screen; + Colormap cmap = pTerm->core.colormap; + char *newName; + + if (XParseColor(screen->display, cmap, name, &def) + && (XAllocColor(screen->display, cmap, &def) + || find_closest_color(screen->display, cmap, &def)) + && (newName = XtMalloc(strlen(name) + 1)) != 0) { + SET_COLOR_VALUE(pNew, ndx, def.pixel); + strcpy(newName, name); + SET_COLOR_NAME(pNew, ndx, newName); + TRACE(("AllocateTermColor #%d: %s (pixel %#lx)\n", ndx, newName, def.pixel)); + return (True); + } + TRACE(("AllocateTermColor #%d: %s (failed)\n", ndx, name)); + return (False); +} + +static Bool +ChangeColorsRequest(XtermWidget pTerm, + int start, + char *names, + int final) +{ + char *thisName; + ScrnColors newColors; + int i, ndx; + + TRACE(("ChangeColorsRequest start=%d, names='%s'\n", start, names)); + + if ((pOldColors == NULL) + && (!GetOldColors(pTerm))) { + return (False); + } + newColors.which = 0; + for (i = 0; i < NCOLORS; i++) { + newColors.names[i] = NULL; + } + for (i = start; i < NCOLORS; i++) { + if (term->misc.re_verse) + ndx = oppositeColor(i); + else + ndx = i; + if ((names == NULL) || (names[0] == '\0')) { + newColors.names[ndx] = NULL; + } else { + if (names[0] == ';') + thisName = NULL; + else + thisName = names; + names = strchr(names, ';'); + if (names != NULL) { + *names = '\0'; + names++; + } + if (thisName != 0 && !strcmp(thisName, "?")) + ReportColorRequest(pTerm, ndx, final); + else if (!pOldColors->names[ndx] + || (thisName + && strcmp(thisName, pOldColors->names[ndx]))) { + AllocateTermColor(pTerm, &newColors, ndx, thisName); + } + } + } + + if (newColors.which == 0) + return (True); + + ChangeColors(pTerm, &newColors); + UpdateOldColors(pTerm, &newColors); + return (True); +} + +/***====================================================================***/ + +#ifndef DEBUG +/* ARGSUSED */ +#endif +void +Panic(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 */ +} + +char * +SysErrorMsg(int n) +{ + static char unknown[] = "unknown error"; + char *s = strerror(n); + return s ? s : unknown; +} + +void +SysError(int i) +{ + static const char *table[] = + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ,"main: ioctl() failed on FIONBIO" /* 11 */ + ,"main: ioctl() failed on F_GETFL" /* 12 */ + ,"main: ioctl() failed on F_SETFL" /* 13 */ + ,"spawn: open() failed on /dev/tty" /* 14 */ + ,"spawn: ioctl() failed on TIOCGETP" /* 15 */ + ,0 + ,"spawn: ptsname() failed" /* 17 */ + ,"spawn: open() failed on ptsname" /* 18 */ + ,"spawn: ioctl() failed on I_PUSH/\"ptem\"" /* 19 */ + ,"spawn: ioctl() failed on I_PUSH/\"consem\"" /* 20 */ + ,"spawn: ioctl() failed on I_PUSH/\"ldterm\"" /* 21 */ + ,"spawn: ioctl() failed on I_PUSH/\"ttcompat\"" /* 22 */ + ,"spawn: ioctl() failed on TIOCSETP" /* 23 */ + ,"spawn: ioctl() failed on TIOCSETC" /* 24 */ + ,"spawn: ioctl() failed on TIOCSETD" /* 25 */ + ,"spawn: ioctl() failed on TIOCSLTC" /* 26 */ + ,"spawn: ioctl() failed on TIOCLSET" /* 27 */ + ,"spawn: initgroups() failed" /* 28 */ + ,"spawn: fork() failed" /* 29 */ + ,"spawn: exec() failed" /* 30 */ + ,0 + ,"get_pty: not enough ptys" /* 32 */ + ,0 + ,"waiting for initial map" /* 34 */ + ,"spawn: setuid() failed" /* 35 */ + ,"spawn: can't initialize window" /* 36 */ + ,0, 0, 0, 0, 0, 0, 0, 0, 0 + ,"spawn: ioctl() failed on TIOCKSET" /* 46 */ + ,"spawn: ioctl() failed on TIOCKSETC" /* 47 */ + ,"spawn: realloc of ttydev failed" /* 48 */ + ,"luit: command-line malloc failed" /* 49 */ + ,"in_put: select() failed" /* 50 */ + ,0, 0, 0 + ,"VTInit: can't initialize window" /* 54 */ + ,0, 0 + ,"HandleKeymapChange: malloc failed" /* 57 */ + ,0, 0 + ,"Tinput: select() failed" /* 60 */ + ,0, 0, 0 + ,"TekInit: can't initialize window" /* 64 */ + ,0, 0, 0, 0, 0, 0 + ,"SaltTextAway: malloc() failed" /* 71 */ + ,0, 0, 0, 0, 0, 0, 0, 0 + ,"StartLog: exec() failed" /* 80 */ + ,0, 0 + ,"xerror: XError event" /* 83 */ + ,"xioerror: X I/O error" /* 84 */ + ,0, 0, 0, 0, 0 + ,"Alloc: calloc() failed on base" /* 90 */ + ,"Alloc: calloc() failed on rows" /* 91 */ + ,"ScreenResize: realloc() failed on alt base" /* 92 */ + ,0, 0, 0 + ,"ScreenResize: malloc() or realloc() failed" /* 96 */ + ,0, 0, 0, 0, 0 + ,"ScrnPointers: malloc/realloc() failed" /* 102 */ + ,0, 0, 0, 0, 0, 0, 0 + ,"ScrollBarOn: realloc() failed on base" /* 110 */ + ,"ScrollBarOn: realloc() failed on rows" /* 111 */ + ,0, 0, 0, 0, 0, 0, 0, 0, 0 + ,"my_memmove: malloc/realloc failed" /* 121 */ + }; + int oerrno; + + oerrno = errno; + fprintf(stderr, "%s: Error %d, errno %d: ", xterm_name, i, oerrno); + fprintf(stderr, "%s\n", SysErrorMsg(oerrno)); + if ((Cardinal) i < XtNumber(table) && table[i] != 0) { + fprintf(stderr, "Reason: %s\n", table[i]); + } + Cleanup(i); +} + +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); +} + +/* + * cleanup by sending SIGHUP to client processes + */ +void +Cleanup(int code) +{ + static Bool cleaning; + TScreen *screen = &term->screen; + + /* + * 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, + (XtPointer *) 0); + } +#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 = getenv("PATH")) != 0) { + if ((tmp = TypeMallocN(char, strlen(leaf) + strlen(s) + 1)) != 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 */ + +/* + * 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(char *var, char *value) +{ + if (value != 0) { + int envindex = 0; + size_t len = strlen(var); + + TRACE(("xtermSetenv(var=%s, value=%s)\n", var, value)); + + while (environ[envindex] != NULL) { + if (strncmp(environ[envindex], var, len) == 0) { + /* found it */ + environ[envindex] = CastMallocN(char, len + strlen(value)); + strcpy(environ[envindex], var); + strcat(environ[envindex], value); + return; + } + envindex++; + } + + TRACE(("...expanding env to %d\n", envindex + 1)); + + environ[envindex] = CastMallocN(char, len + strlen(value)); + (void) strcpy(environ[envindex], var); + strcat(environ[envindex], value); + environ[++envindex] = NULL; + } +} + +/*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) +{ + char *ptr; + + (void) fprintf(stderr, "%s Xt error: %s\n", ProgramName, message); + + /* + * Check for the obvious - Xt does a poor job of reporting this. + */ + if ((ptr = getenv("DISPLAY")) == 0 || *x_strtrim(ptr) == '\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) +{ + TScreen *screen = &term->screen; + + TRACE(("set_vt_visibility(%d)\n", on)); + if (on) { + if (!screen->Vshow && term) { + VTInit(); + XtMapWidget(XtParent(term)); +#if OPT_TOOLBAR + /* we need both of these during initialization */ + XtMapWidget(SHELL_OF(term)); + ShowToolbar(resource.toolBar); +#endif + screen->Vshow = True; + } + } +#if OPT_TEK4014 + else { + if (screen->Vshow && term) { + withdraw_window(XtDisplay(term), + VShellWindow, + XScreenNumberOfScreen(XtScreen(term))); + 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) +{ + TScreen *screen = &term->screen; + + TRACE(("set_tek_visibility(%d)\n", on)); + if (on) { + if (!screen->Tshow && (tekWidget || TekInit())) { + 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 + ("WM_PROTOCOLS: DeleteWindow()")); + (void) XSetWMProtocols(XtDisplay(tekParent), + XtWindow(tekParent), + &wm_delete_window, 1); + screen->Tshow = True; + } + } else { + if (screen->Tshow && tekWidget) { + withdraw_window(XtDisplay(tekWidget), + TShellWindow, + XScreenNumberOfScreen(XtScreen(tekWidget))); + screen->Tshow = False; + } + } + set_tekhide_sensitivity(); + set_vthide_sensitivity(); + update_vtshow(); + update_tekshow(); + update_vttekmode(); + return; +} + +void +end_tek_mode(void) +{ + TScreen *screen = &term->screen; + + if (screen->TekEmu) { + FlushLog(screen); + longjmp(Tekend, 1); + } + return; +} + +void +end_vt_mode(void) +{ + TScreen *screen = &term->screen; + + if (!screen->TekEmu) { + FlushLog(screen); + screen->TekEmu = True; + longjmp(VTend, 1); + } + return; +} + +void +switch_modes(Bool tovt) /* if true, then become vt mode */ +{ + if (tovt) { + if (TekRefresh) + dorefresh(); + end_tek_mode(); /* WARNING: this does a longjmp... */ + } else { + end_vt_mode(); /* WARNING: this does a longjmp... */ + } +} + +void +hide_vt_window(void) +{ + TScreen *screen = &term->screen; + + set_vt_visibility(False); + if (!screen->TekEmu) + switch_modes(False); /* switch to tek mode */ +} + +void +hide_tek_window(void) +{ + TScreen *screen = &term->screen; + + set_tek_visibility(False); + TekRefresh = (TekLink *) 0; + if (screen->TekEmu) + 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; + + if (res_array == 0) { + Cardinal j; + + /* make a sorted index to 'resources' */ + res_array = TypeCallocN(XrmOptionDescRec, res_count); + for (j = 0; j < res_count; j++) + res_array[j] = descs[j]; + qsort(res_array, 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; + + if (opt_array == 0) { + Cardinal opt_count, j; +#if OPT_TRACE + Cardinal k; + XrmOptionDescRec *res_array = sortedOptDescs(descs, numDescs); + int code; + 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 *name = opt_array[j].opt + 3; + for (k = 0; k < numDescs; ++k) { + 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; + } + if (x_strindex(opt_array[j].desc, "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 locale that xterm was started in. + */ +char * +xtermEnvLocale(void) +{ + static char *result; + + if (result == 0) { + if ((result = getenv("LC_ALL")) == 0 || *result == '\0') + if ((result = getenv("LC_CTYPE")) == 0 || *result == '\0') + if ((result = getenv("LANG")) == 0 || *result == '\0') + 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 (*locale == 0 || !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 *result; + if (result == 0) { + char *vendor = __vendorversion__; + 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 ", 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; +} diff --git a/nx-X11/programs/xterm/mkdirs.sh b/nx-X11/programs/xterm/mkdirs.sh new file mode 100644 index 000000000..ffe7494c4 --- /dev/null +++ b/nx-X11/programs/xterm/mkdirs.sh @@ -0,0 +1,38 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Last modified: 1994-03-25 +# Public domain +# + +errstatus=0 +umask 022 + +for file in ${1+"$@"} ; do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d in ${1+"$@"} ; do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + case "$pathcomp" in + [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]: ) + ;; # DOSISH systems + * ) mkdir "$pathcomp" || errstatus=$? ;; + esac + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/nx-X11/programs/xterm/os2main.c b/nx-X11/programs/xterm/os2main.c new file mode 100644 index 000000000..8ef6147a1 --- /dev/null +++ b/nx-X11/programs/xterm/os2main.c @@ -0,0 +1,2155 @@ +/* $XTermId: os2main.c,v 1.213 2005/11/03 13:17:28 tom Exp $ */ + +/* removed all foreign stuff to get the code more clear (hv) + * and did some rewrite for the obscure OS/2 environment + */ + +#ifndef lint +static char *rid = "$XConsortium: main.c,v 1.227.1.2 95/06/29 18:13:15 kaleb Exp $"; +#endif /* lint */ +/* $XFree86: xc/programs/xterm/os2main.c,v 3.81 2005/11/03 13:17:28 dickey Exp $ */ + +/*********************************************************** + +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 +#define XTERM_MAIN + +#define RES_OFFSET(field) XtOffsetOf(XTERM_RESOURCE, field) + +#include + +#include +#ifdef I18N +#include +#endif + +#if OPT_TOOLBAR + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#endif /* OPT_TOOLBAR */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OPT_WIDE_CHARS +#include +#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 +#include /* for NOFILE */ +#include +#include + +static SIGNAL_T reapchild(int n); +static int spawn(void); +static void get_terminal(void); +static void resize(TScreen * s, char *oldtc, char *newtc); +static void set_owner(char *device, uid_t uid, gid_t gid, mode_t mode); + +static Bool added_utmp_entry = False; + +/* +** 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 spawn() 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 + +/* + * 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 int override_tty_modes = 0; +/* *INDENT-OFF* */ +static struct _xttymodes { + char *name; + size_t len; + int set; + Char 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 /* 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("keyboardType", "KeyboardType", keyboardType, "unknown"), + Bres("sunFunctionKeys", "SunFunctionKeys", sunFunctionKeys, False), +#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_INITIAL_ERASE + Bres("ptyInitialErase", "PtyInitialErase", ptyInitialErase, DEF_INITIAL_ERASE), + Bres("backarrowKeyIsErase", "BackarrowKeyIsErase", backarrow_is_erase, DEF_BACKARO_ERASE), +#endif + Bres("waitForMap", "WaitForMap", wait_for_map, False), + Bres("useInsertMode", "UseInsertMode", useInsertMode, False), +#if OPT_ZICONBEEP + Ires("zIconBeep", "ZIconBeep", zIconBeep, 0), +#endif +#if OPT_PTY_HANDSHAKE + Bres("ptyHandshake", "PtyHandshake", ptyHandshake, True), +#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 +}; + +static char *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, (caddr_t) NULL}, +{"-132", "*c132", XrmoptionNoArg, (caddr_t) "on"}, +{"+132", "*c132", XrmoptionNoArg, (caddr_t) "off"}, +{"-ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "on"}, +{"+ah", "*alwaysHighlight", XrmoptionNoArg, (caddr_t) "off"}, +{"-aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+aw", "*autoWrap", XrmoptionNoArg, (caddr_t) "off"}, +#ifndef NO_ACTIVE_ICON +{"-ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "off"}, +{"+ai", "*activeIcon", XrmoptionNoArg, (caddr_t) "on"}, +#endif /* NO_ACTIVE_ICON */ +{"-b", "*internalBorder",XrmoptionSepArg, (caddr_t) NULL}, +{"-bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "on"}, +{"+bc", "*cursorBlink", XrmoptionNoArg, (caddr_t) "off"}, +{"-bcf", "*cursorOffTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bcn", "*cursorOnTime",XrmoptionSepArg, (caddr_t) NULL}, +{"-bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+bdc", "*colorBDMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-cc", "*charClass", XrmoptionSepArg, (caddr_t) NULL}, +{"-cm", "*colorMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+cm", "*colorMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "off"}, +{"+cn", "*cutNewline", XrmoptionNoArg, (caddr_t) "on"}, +{"-cr", "*cursorColor", XrmoptionSepArg, (caddr_t) NULL}, +{"-cu", "*curses", XrmoptionNoArg, (caddr_t) "on"}, +{"+cu", "*curses", XrmoptionNoArg, (caddr_t) "off"}, +{"-dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "off"}, +{"+dc", "*dynamicColors",XrmoptionNoArg, (caddr_t) "on"}, +{"-fb", "*boldFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbb", "*freeBoldBox", XrmoptionNoArg, (caddr_t)"on"}, +{"-fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"off"}, +{"+fbx", "*forceBoxChars", XrmoptionNoArg, (caddr_t)"on"}, +#ifndef NO_ACTIVE_ICON +{"-fi", "*iconFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif /* NO_ACTIVE_ICON */ +#if OPT_RENDERFONT +{"-fa", "*faceName", XrmoptionSepArg, (caddr_t) NULL}, +{"-fd", "*faceNameDoublesize", XrmoptionSepArg, (caddr_t) NULL}, +{"-fs", "*faceSize", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_WIDE_CHARS +{"-fw", "*wideFont", XrmoptionSepArg, (caddr_t) NULL}, +{"-fwb", "*wideBoldFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_INPUT_METHOD +{"-fx", "*ximFont", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HIGHLIGHT_COLOR +{"-hc", "*highlightColor", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_HP_FUNC_KEYS +{"-hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "on"}, +{"+hf", "*hpFunctionKeys",XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-hold", "*hold", XrmoptionNoArg, (caddr_t) "on"}, +{"+hold", "*hold", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_INITIAL_ERASE +{"-ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "on"}, +{"+ie", "*ptyInitialErase", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_C1_PRINT +{"-k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "on"}, +{"+k8", "*allowC1Printable", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +{"+kt", "*keyboardType", XrmoptionSepArg, (caddr_t) NULL}, +/* parse logging options anyway for compatibility */ +{"-l", "*logging", XrmoptionNoArg, (caddr_t) "on"}, +{"+l", "*logging", XrmoptionNoArg, (caddr_t) "off"}, +{"-lf", "*logFile", XrmoptionSepArg, (caddr_t) NULL}, +{"-ls", "*loginShell", XrmoptionNoArg, (caddr_t) "on"}, +{"+ls", "*loginShell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mb", "*marginBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+mb", "*marginBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-mc", "*multiClickTime", XrmoptionSepArg, (caddr_t) NULL}, +{"-mesg", "*messages", XrmoptionNoArg, (caddr_t) "off"}, +{"+mesg", "*messages", XrmoptionNoArg, (caddr_t) "on"}, +{"-ms", "*pointerColor",XrmoptionSepArg, (caddr_t) NULL}, +{"-nb", "*nMarginBell", XrmoptionSepArg, (caddr_t) NULL}, +{"-nul", "*underLine", XrmoptionNoArg, (caddr_t) "off"}, +{"+nul", "*underLine", XrmoptionNoArg, (caddr_t) "on"}, +{"-pc", "*boldColors", XrmoptionNoArg, (caddr_t) "on"}, +{"+pc", "*boldColors", XrmoptionNoArg, (caddr_t) "off"}, +{"-rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "on"}, +{"+rw", "*reverseWrap", XrmoptionNoArg, (caddr_t) "off"}, +{"-s", "*multiScroll", XrmoptionNoArg, (caddr_t) "on"}, +{"+s", "*multiScroll", XrmoptionNoArg, (caddr_t) "off"}, +{"-sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "on"}, +{"+sb", "*scrollBar", XrmoptionNoArg, (caddr_t) "off"}, +#ifdef SCROLLBAR_RIGHT +{"-leftbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "off"}, +{"-rightbar", "*rightScrollBar", XrmoptionNoArg, (caddr_t) "on"}, +#endif +{"-rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+rvc", "*colorRVMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "on"}, +{"+sf", "*sunFunctionKeys", XrmoptionNoArg, (caddr_t) "off"}, +{"-si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "off"}, +{"+si", "*scrollTtyOutput", XrmoptionNoArg, (caddr_t) "on"}, +{"-sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "on"}, +{"+sk", "*scrollKey", XrmoptionNoArg, (caddr_t) "off"}, +{"-sl", "*saveLines", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_SUNPC_KBD +{"-sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "on"}, +{"+sp", "*sunKeyboard", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TEK4014 +{"-t", "*tekStartup", XrmoptionNoArg, (caddr_t) "on"}, +{"+t", "*tekStartup", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-ti", "*decTerminalID",XrmoptionSepArg, (caddr_t) NULL}, +{"-tm", "*ttyModes", XrmoptionSepArg, (caddr_t) NULL}, +{"-tn", "*termName", XrmoptionSepArg, (caddr_t) NULL}, +#if OPT_WIDE_CHARS +{"-u8", "*utf8", XrmoptionNoArg, (caddr_t) "2"}, +{"+u8", "*utf8", XrmoptionNoArg, (caddr_t) "0"}, +#endif +#if OPT_LUIT_PROG +{"-lc", "*locale", XrmoptionNoArg, (caddr_t) "on"}, +{"+lc", "*locale", XrmoptionNoArg, (caddr_t) "off"}, +{"-lcc", "*localeFilter",XrmoptionSepArg, (caddr_t) NULL}, +{"-en", "*locale", XrmoptionSepArg, (caddr_t) NULL}, +#endif +{"-ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulc", "*colorULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "off"}, +{"+ulit", "*italicULMode", XrmoptionNoArg, (caddr_t) "on"}, +{"-ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "on"}, +{"+ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "off"}, +{"-im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "on"}, +{"+im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "off"}, +{"-vb", "*visualBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"}, +{"-pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "on"}, +{"+pob", "*popOnBell", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_WIDE_CHARS +{"-wc", "*wideChars", XrmoptionNoArg, (caddr_t) "on"}, +{"+wc", "*wideChars", XrmoptionNoArg, (caddr_t) "off"}, +{"-mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+mk_width", "*mkWidth", XrmoptionNoArg, (caddr_t) "off"}, +{"-cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "on"}, +{"+cjk_width", "*cjkWidth", XrmoptionNoArg, (caddr_t) "off"}, +#endif +{"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"}, +{"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"}, +#if OPT_ZICONBEEP +{"-ziconbeep", "*zIconBeep", XrmoptionSepArg, (caddr_t) NULL}, +#endif +#if OPT_SAME_NAME +{"-samename", "*sameName", XrmoptionNoArg, (caddr_t) "on"}, +{"+samename", "*sameName", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_SESSION_MGT +{"-sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "on"}, +{"+sm", "*sessionMgt", XrmoptionNoArg, (caddr_t) "off"}, +#endif +#if OPT_TOOLBAR +{"-tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "on"}, +{"+tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "off"}, +#endif +/* options that we process ourselves */ +{"-help", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-version", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, +{"-class", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +{"-e", NULL, XrmoptionSkipLine, (caddr_t) NULL}, +{"-into", NULL, XrmoptionSkipArg, (caddr_t) NULL}, +/* bogus old compatibility stuff for which there are + standard XtOpenApplication options now */ +{"%", "*tekGeometry", XrmoptionStickyArg, (caddr_t) NULL}, +{"#", ".iconGeometry",XrmoptionStickyArg, (caddr_t) NULL}, +{"-T", ".title", XrmoptionSepArg, (caddr_t) NULL}, +{"-n", "*iconName", XrmoptionSepArg, (caddr_t) NULL}, +{"-r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+r", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "on"}, +{"+rv", "*reverseVideo",XrmoptionNoArg, (caddr_t) "off"}, +{"-w", ".borderWidth", XrmoptionSepArg, (caddr_t) 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 +{ "-hc color", "selection background 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 +{ "-/+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 +{ NULL, NULL }}; +/* *INDENT-ON* */ + +/*debug FILE *confd;*/ +/*static void opencons() +{ + if ((confd=fopen("/dev/console$","w")) < 0) { + fputs("!!! Cannot open console device.\n", + stderr); + exit(1); + } +} + +static void closecons(void) +{ + fclose(confd); +} +*/ +static 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(127); + 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; +} + +/* + * If we're linked to terminfo, tgetent() will return an empty buffer. We + * cannot use that to adjust the $TERMCAP variable. + */ +static Bool +get_termcap(char *name, char *buffer, char *resized) +{ + TScreen *screen = &term->screen; + + *buffer = 0; /* initialize, in case we're using terminfo's tgetent */ + + if (name != 0) { + if (tgetent(buffer, name) == 1) { + TRACE(("get_termcap(%s) succeeded (%s)\n", name, + (*buffer + ? "ok:termcap, we can update $TERMCAP" + : "assuming this is terminfo"))); + if (*buffer) { + if (!TEK4014_ACTIVE(screen)) { + resize(screen, buffer, resized); + } + } + return True; + } else { + *buffer = 0; /* just in case */ + } + } + return False; +} + +static int +abbrev(char *tst, 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 + strlen(ProgramName); + for (opt = list; opt->opt; opt++) { + int len = 3 + 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)); + 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; +} +#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 (term->screen.Tshow) + hide_vt_window(); + else + do_hangup(w, (XtPointer) 0, (XtPointer) 0); + } else if (term->screen.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; + TScreen *screen; + int mode; + char *my_class = DEFCLASS; + Window winToEmbedInto = None; + + /* Do these first, since we may not be able to open the display */ + ProgramName = argv[0]; + 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 { + 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 + +/*debug 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] = 0x7f; /* 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); +#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(); + + waiting_for_initial_map = resource.wait_for_map; + + /* + * 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 = 1; + } + } +#if OPT_ZICONBEEP + zIconBeep = resource.zIconBeep; + zIconBeep_flagged = False; + if (zIconBeep > 100 || zIconBeep < -100) { + 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 */ +#if OPT_SAME_NAME + sameName = resource.sameName; +#endif + 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 == getuid()) && + !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); + + 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, +#endif + (XtPointer) 0); + + decode_keyboard_type(&resource); + + screen = &term->screen; + + 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) + screen->TekEmu = False; + + if (screen->TekEmu && !TekInit()) + exit(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[4]; + 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. */ + int i = -1; + if (debug) { + creat_as(getuid(), getgid(), True, "xterm.debug.log", 0666); + i = open("xterm.debug.log", 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 */ + + /* open a terminal for client */ + get_terminal(); + + spawn(); + + /* 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(screen)))); + 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(screen); + } +#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); + } + + for (;;) { +#if OPT_TEK4014 + if (screen->TekEmu) + TekRun(); + else +#endif + VTRun(); + } + 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); +} + +/* + * sets up X and initializes the terminal structure except for term.buf.fildes. + */ +static void +get_terminal(void) +{ + TScreen *screen = &term->screen; + + screen->arrow = make_colored_cursor(XC_left_ptr, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); +} + +/* + * 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; +} + +struct { + int rows; + int cols; +} handshake = { + + -1, -1 +}; + +void +first_map_occurred(void) +{ + TScreen *screen = &term->screen; + handshake.rows = screen->max_row; + handshake.cols = screen->max_col; + waiting_for_initial_map = False; +} + +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 + && getuid() == 0) { + fprintf(stderr, "Cannot chown %s to %ld,%ld: %s\n", + device, (long) uid, (long) gid, 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, mode, strerror(why)); + } else { + fprintf(stderr, + "Cannot chmod %s to %03o currently %03o: %s\n", + device, mode, (sb.st_mode & S_IFMT), 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 +spawn(void) +/* + * 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 = &term->screen; + int Xsocket = ConnectionNumber(screen->display); + + int ttyfd = -1; + struct termio tio; + int status; + + char termcap[TERMCAP_SIZE], newtc[TERMCAP_SIZE]; + char *TermName = NULL; + char *ptr, *shname, buf[64]; + int i, no_dev_tty = False, envsize; + char *dev_tty_name = (char *) 0; + TTYSIZE_STRUCT ts; + int pgrp = getpid(); + char numbuf[12], **envnew; + + screen->uid = getuid(); + screen->gid = getgid(); + + 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]; + + setgid(screen->gid); + setuid(screen->uid); + } 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(XtParent(CURRENT_EMU(screen)), False); + + wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", + False); + + if (!TEK4014_ACTIVE(screen)) + VTInit(); /* 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(XtParent(CURRENT_EMU(screen)), + mit_console, CurrentTime, + ConvertConsoleSelection, NULL, NULL); + } +#if OPT_TEK4014 + if (screen->TekEmu) { + envnew = tekterm; + ptr = newtc; + } else +#endif + { + envnew = vtterm; + ptr = termcap; + } + + /* + * 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. + */ + if (!get_termcap(TermName = resource.term_name, ptr, newtc)) { + char *last = NULL; + TermName = *envnew; + while (*envnew != NULL) { + if ((last == NULL || strcmp(last, *envnew)) + && get_termcap(*envnew, ptr, newtc)) { + TermName = *envnew; + break; + } + last = *envnew; + envnew++; + } + } + + /* tell tty how big window is */ +#if OPT_TEK4014 + if (TEK4014_ACTIVE(screen)) { + TTYSIZE_ROWS(ts) = 38; + TTYSIZE_COLS(ts) = 81; + ts.ws_xpixel = TFullWidth(screen); + ts.ws_ypixel = TFullHeight(screen); + } 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; + +/*debug fclose(confd); +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) { + /* it may be bigger */ + ttydev = TypeRealloc(char, strlen(ptr) + 1, ttydev); + if (ttydev == NULL) { + SysError(ERROR_SPREALLOC); + } + (void) strcpy(ttydev, 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 + */ + { + struct termio 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\n", xterm_name); + } + } + + 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); + + /* copy the environment before Setenv'ing */ + for (i = 0; gblenvp[i] != NULL; i++) ; + + /* compute number of xtermSetenv() calls below */ + envsize = 1; /* (NULL terminating entry) */ + envsize += 5; /* TERM, WINDOWID, DISPLAY, _SHELL, _VERSION */ + envsize += 2; /* COLUMNS, LINES */ + + envnew = TypeCallocN(char *, (unsigned) i + envsize); + memmove((char *) envnew, (char *) gblenvp, i * sizeof(char *)); + gblenvp = envnew; + xtermSetenv("TERM=", TermName); + if (!TermName) + *newtc = 0; + + sprintf(buf, "%lu", + ((unsigned long) XtWindow(SHELL_OF(CURRENT_EMU(screen))))); + xtermSetenv("WINDOWID=", buf); + + /* put the display into the environment of the shell */ + xtermSetenv("DISPLAY=", XDisplayString(screen->display)); + + xtermSetenv("XTERM_VERSION=", xtermVersion()); + + 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); + (void) dup(ttyfd); + } + + /* and close the tty */ + if (ttyfd > 2) + close_fd(ttyfd); + + setpgrp(0, pgrp); + setgid(screen->gid); + setuid(screen->uid); + + if (handshake.rows > 0 && handshake.cols > 0) { + 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); + + /* reconstruct dead environ variable */ + environ = gblenvp; + + /* 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", + xterm_name, *command_to_exec_with_luit, strerror(errno)); + fprintf(stderr, "%s: cannot support your locale.\n", + xterm_name); + } +#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", + xterm_name, *command_to_exec); + } + + /* use a layered mechanism to find a shell */ + ptr = getenv("X11SHELL"); + if (!ptr) + ptr = getenv("SHELL"); + if (!ptr) + ptr = 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", + xterm_name, *command_to_exec); + } else { + execlpe(ptr, shname, 0, gblenvp); + + /* Exec failed. */ + fprintf(stderr, "%s: Could not exec %s!\n", + xterm_name, 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 spawn */ + +SIGNAL_T +Exit(int n) +{ + TScreen *screen = &term->screen; + int pty = term->screen.respond; /* file descriptor of pty */ + close(pty); /* close explicitly to avoid race with slave side */ +#ifdef ALLOWLOGGING + if (screen->logging) + CloseLog(screen); +#endif + if (am_slave < 0) { + /* restore ownership of tty and pty */ + set_owner(ttydev, 0, 0, 0666U); + set_owner(ptydev, 0, 0, 0666U); + } + exit(n); + SIGNAL_RETURN; +} + +/* ARGSUSED */ +static void +resize(TScreen * screen, char *oldtc, char *newtc) +{ +} + +/* + * 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 == term->screen.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) { + while (*s && isascii(CharOf(*s)) && isspace(CharOf(*s))) + s++; + if (!*s) + return count; + + for (mp = modelist; mp->name; mp++) { + if (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; + struct termio *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 = (struct termio *) 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 = (struct termio *) 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/nx-X11/programs/xterm/plink.sh b/nx-X11/programs/xterm/plink.sh new file mode 100644 index 000000000..244f1b517 --- /dev/null +++ b/nx-X11/programs/xterm/plink.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# $XTermId: plink.sh,v 1.4 2005/05/03 00:38:24 tom Exp $ +# $XFree86: xc/programs/xterm/plink.sh,v 3.2 2005/05/03 00:38:24 dickey Exp $ +# +# Reduce the number of dynamic libraries used to link an executable. +LINKIT= +while test $# != 0 +do + OPT="$1" + shift + case $OPT in + -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/nx-X11/programs/xterm/precompose.c b/nx-X11/programs/xterm/precompose.c new file mode 100644 index 000000000..afe4c3f3f --- /dev/null +++ b/nx-X11/programs/xterm/precompose.c @@ -0,0 +1,1041 @@ +/* + * Canonical Compositions + * + * DO NOT EDIT BY HAND! This is generated by the script + * unicode/make-precompose.sh + */ +/* $XTermId: precompose.c,v 1.7 2004/12/01 01:27:47 tom Exp $ */ +/* $XFree86: xc/programs/xterm/precompose.c,v 1.3 2004/12/01 01:27:47 dickey Exp $ */ + +#include + +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}, +{ 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}, +{ 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}, +}; + +int do_precomposition(int base, int comb) { + int min = 0; + int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1; + int mid; + unsigned int sought = ((unsigned)base << 16) | (unsigned)comb, that; + + /* binary search */ + while (max >= min) { + mid = (min + max) / 2; + that = ((unsigned)precompositions[mid].base << 16) | ((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/nx-X11/programs/xterm/precompose.h b/nx-X11/programs/xterm/precompose.h new file mode 100644 index 000000000..661bbb1ac --- /dev/null +++ b/nx-X11/programs/xterm/precompose.h @@ -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/nx-X11/programs/xterm/print.c b/nx-X11/programs/xterm/print.c new file mode 100644 index 000000000..c081f8ff9 --- /dev/null +++ b/nx-X11/programs/xterm/print.c @@ -0,0 +1,608 @@ +/* $XTermId: print.c,v 1.63 2005/08/05 01:25:40 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/print.c,v 1.22 2005/08/05 01:25:40 dickey Exp $ + */ + +/************************************************************ + +Copyright 1997-2004,2005 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 +#include +#include +#include + +#include + +#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(int chr); +static void printLine(int row, int chr); +static void send_CharSet(int row); +static void send_SGR(unsigned attr, unsigned fg, unsigned bg); +static void stringToPrinter(char *str); + +static FILE *Printer; +static pid_t Printer_pid; +static int initialized; + +static void +closePrinter(void) +{ + if (xtermHasPrinter() != 0) { +#ifdef VMS + TScreen *screen = &term->screen; + + 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(void) +{ + TScreen *screen = &term->screen; + + TRACE(("printCursorLine\n")); + printLine(screen->cur_row, '\n'); +} + +#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(int row, int chr) +{ + TScreen *screen = &term->screen; + Char *c = SCRN_BUF_CHARS(screen, row); + Char *a = SCRN_BUF_ATTRS(screen, row); + Char attr = 0; + unsigned ch; + int last = MaxCols(screen); + int col; +#if OPT_ISO_COLORS && OPT_PRINT_COLORS +#if OPT_EXT_COLORS + Char *fbf = 0; + Char *fbb = 0; +#define ColorOf(col) (unsigned)((fbf[col] << 8) | fbb[col]) +#else + Char *fb = 0; +#define ColorOf(col) (fb[col]) +#endif +#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; + + TRACE(("printLine(row=%d, top=%d:%d, chr=%d):%s\n", + row, screen->topline, screen->max_row, chr, + visibleChars(PAIRED_CHARS(c, + screen->utf8_mode + ? SCRN_BUF_WIDEC(screen, row) + : 0), (unsigned) last))); + + if_OPT_EXT_COLORS(screen, { + fbf = SCRN_BUF_FGRND(screen, row); + fbb = SCRN_BUF_BGRND(screen, row); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fb = SCRN_BUF_COLOR(screen, row); + }); + while (last > 0) { + if ((a[last - 1] & CHARDRAWN) == 0) + last--; + else + break; + } + if (last) { + if (screen->print_attributes) { + send_CharSet(row); + send_SGR(0, NO_COLOR, NO_COLOR); + } + for (col = 0; col < last; col++) { + ch = c[col]; + if_OPT_WIDE_CHARS(screen, { + ch = getXtermCell(screen, row, col); + }); +#if OPT_PRINT_COLORS + if (screen->colorMode) { + if (screen->print_attributes > 1) { + fg = (a[col] & FG_COLOR) + ? extract_fg(ColorOf(col), a[col]) + : NO_COLOR; + bg = (a[col] & BG_COLOR) + ? extract_bg(ColorOf(col), a[col]) + : NO_COLOR; + } + } +#endif + if ((((a[col] & SGR_MASK) != attr) +#if OPT_PRINT_COLORS + || (last_fg != fg) || (last_bg != bg) +#endif + ) + && ch) { + attr = (a[col] & SGR_MASK); + last_fg = fg; + last_bg = bg; + if (screen->print_attributes) + send_SGR(attr, fg, bg); + } + + if (ch == 0) + ch = ' '; + +#if OPT_WIDE_CHARS + if (screen->utf8_mode) + cs = CSET_IN; + else +#endif + cs = (ch >= ' ' && ch != 0x7f) ? CSET_IN : CSET_OUT; + if (last_cs != cs) { + if (screen->print_attributes) { + charToPrinter((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((int) ((cs == CSET_OUT) + ? (ch == 0x7f ? 0x5f : (ch + 0x5f)) + : ch)); + } + if (screen->print_attributes) { + send_SGR(0, NO_COLOR, NO_COLOR); + if (cs != CSET_IN) + charToPrinter(SHIFT_IN); + } + } + if (screen->print_attributes) + charToPrinter('\r'); + charToPrinter(chr); +} + +void +xtermPrintScreen(Bool use_DECPEX) +{ + if (XtIsRealized((Widget) term)) { + TScreen *screen = &term->screen; + Bool extent = (use_DECPEX && screen->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(top++, '\n'); + if (screen->printer_formfeed) + charToPrinter('\f'); + + if (!was_open || screen->printer_autoclose) { + closePrinter(); + } + } else { + Bell(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. + */ +static void +xtermPrintEverything(void) +{ + TScreen *screen = &term->screen; + int top = 0; + int bot = screen->max_row; + int was_open = initialized; + + if (!screen->altbuf) + top = -screen->savedlines; + + TRACE(("xtermPrintEverything, rows %d..%d\n", top, bot)); + while (top <= bot) + printLine(top++, '\n'); + if (screen->printer_formfeed) + charToPrinter('\f'); + + if (!was_open || screen->printer_autoclose) { + closePrinter(); + } +} + +static void +send_CharSet(int row) +{ +#if OPT_DEC_CHRSET + TScreen *screen = &term->screen; + char *msg = 0; + + switch (SCRN_BUF_CSETS(screen, row)[0]) { + 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(msg); +#endif /* OPT_DEC_CHRSET */ +} + +static void +send_SGR(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 (term->screen.boldColors + && fg > 8 + && (attr & BOLD) != 0) + fg -= 8; +#endif + sprintf(msg + strlen(msg), ";%u", (fg < 8) ? (30 + fg) : (82 + fg)); + } +#endif + strcat(msg, "m"); + stringToPrinter(msg); +} + +/* + * This implementation only knows how to write to a pipe. + */ +static void +charToPrinter(int chr) +{ + TScreen *screen = &term->screen; + + if (!initialized && xtermHasPrinter()) { +#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(((char *) 0)); + 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 (setgid(screen->gid) == -1) + exit(2); + if (setuid(screen->uid) == -1) + exit(2); + + 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(), Printer_pid)); + } +#endif + initialized++; + } + if (Printer != 0) { +#if OPT_WIDE_CHARS + if (chr > 127) { + Char temp[10]; + *convertToUTF8(temp, (unsigned) chr) = 0; + fputs((char *) temp, Printer); + } else +#endif + fputc(chr, Printer); + if (isForm(chr)) + fflush(Printer); + } +} + +static void +stringToPrinter(char *str) +{ + while (*str) + charToPrinter(*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(int param, int private_seq) +{ + TRACE(("MediaCopy param=%d, private=%d\n", param, private_seq)); + + if (private_seq) { + switch (param) { + case 1: + printCursorLine(); + break; + case 4: + setPrinterControlMode(0); + break; + case 5: + setPrinterControlMode(1); + break; + case 10: /* VT320 */ + xtermPrintScreen(False); + break; + case 11: /* VT320 */ + xtermPrintEverything(); + break; + } + } else { + switch (param) { + case -1: + case 0: + xtermPrintScreen(True); + break; + case 4: + setPrinterControlMode(0); + break; + case 5: + setPrinterControlMode(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(int chr) +{ + TScreen *screen = &term->screen; + + if (screen->printer_controlmode == 1) { + TRACE(("AutoPrint %d\n", chr)); + printLine(screen->cursor_row, chr); + 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(int chr) +{ + TScreen *screen = &term->screen; + /* *INDENT-OFF* */ + static struct { + Char seq[5]; + int active; + } tbl[] = { + { { CSI, '5', 'i' }, 2 }, + { { CSI, '4', 'i' }, 0 }, + { { ESC, LB, '5', 'i' }, 2 }, + { { 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 CSI: + case ESC: + case '[': + case '4': + case '5': + case 'i': + bfr[length++] = 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(tbl[n].active); + if (screen->printer_autoclose + && screen->printer_controlmode == 0) + closePrinter(); + 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(bfr[n]); + bfr[0] = chr; + length = 1; + return 0; + } +} + +/* + * If there is no printer command, we will ignore printer controls. + */ +Bool +xtermHasPrinter(void) +{ + TScreen *screen = &term->screen; + + return (strlen(screen->printer_command) != 0); +} + +#define showPrinterControlMode(mode) \ + (((mode) == 0) \ + ? "normal" \ + : ((mode) == 1 \ + ? "autoprint" \ + : "printer controller")) + +void +setPrinterControlMode(int mode) +{ + if (xtermHasPrinter() + && term->screen.printer_controlmode != mode) { + TRACE(("%s %s mode\n", + (mode + ? "set" + : "reset"), + (mode + ? showPrinterControlMode(mode) + : showPrinterControlMode(term->screen.printer_controlmode)))); + term->screen.printer_controlmode = mode; + update_print_redir(); + } +} diff --git a/nx-X11/programs/xterm/proto.h b/nx-X11/programs/xterm/proto.h new file mode 100644 index 000000000..262c308dc --- /dev/null +++ b/nx-X11/programs/xterm/proto.h @@ -0,0 +1,29 @@ +/* $XFree86: xc/programs/xterm/proto.h,v 3.4 2003/10/27 01:07:57 dickey Exp $ */ + +#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/nx-X11/programs/xterm/ptydata.c b/nx-X11/programs/xterm/ptydata.c new file mode 100644 index 000000000..7d3dae3e1 --- /dev/null +++ b/nx-X11/programs/xterm/ptydata.c @@ -0,0 +1,420 @@ +/* $XTermId: ptydata.c,v 1.65 2005/04/22 00:21:54 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/ptydata.c,v 1.23 2005/04/22 00:21:54 dickey Exp $ + */ + +/************************************************************ + +Copyright 1999-2004,2005 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 + +#if OPT_WIDE_CHARS +#include +#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. + */ +static Bool +decodeUtf8(PtyData * data) +{ + int i; + int length = data->last - data->next; + int utf_count = 0; + IChar 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 + 1); + } else { + data->utf_data = 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; + } + /* characters outside UCS-2 become UCS_REPL */ + if (utf_char > 0x03ff) { + /* value would be >0xffff */ + utf_char = UCS_REPL; + } else { + utf_char <<= 6; + utf_char |= (c & 0x3f); + } + if ((utf_char >= 0xd800 && + utf_char <= 0xdfff) || + (utf_char == 0xfffe) || + (utf_char == 0xffff)) { + utf_char = UCS_REPL; + } + utf_count--; + if (utf_count == 0) { + data->utf_data = 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(TScreen * screen, PtySelect * select_mask, PtyData * data) +{ + int size = 0; + +#ifdef VMS + if (*select_mask & pty_mask) { + trimPtyData(screen, 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)) { + trimPtyData(screen, data); + + size = read(screen->respond, (char *) data->last, FRG_SIZE); + if (size <= 0) { + /* + * 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 (defined(i386) && defined(SVR4) && defined(sun)) || defined(__CYGWIN__) + if (errno == EIO || errno == 0) +#else + if (errno == EIO) +#endif + Cleanup(0); + else if (!E_TEST(errno)) + Panic("input: read returned unexpected error (%d)\n", errno); + size = 0; + } else if (size == 0) { +#if defined(__UNIXOS2__) + Cleanup(0); +#else + Panic("input: read returned zero\n", 0); +#endif + } + } +#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 + term->screen.logstart = VTbuffer->next; +#endif + } + + return (size); +} + +/* + * Check if there is more data in the input buffer which can be returned by + * nextPtyData(). If there is insufficient data to return a completed UTF-8 + * value, return false anyway. + */ +#if OPT_WIDE_CHARS +Bool +morePtyData(TScreen * screen GCC_UNUSED, PtyData * data) +{ + Bool result = (data->last > data->next); + if (result && screen->utf8_inparse) { + if (!data->utf_size) + result = decodeUtf8(data); + } + TRACE2(("morePtyData returns %d\n", result)); + return result; +} +#endif + +/* + * 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 = data->utf_data; + data->next += data->utf_size; + data->utf_size = 0; + } else { + result = *((data)->next++); + if (!screen->output_eight_bits) + result &= 0x7f; + } + TRACE2(("nextPtyData returns %#x\n", result)); + 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 = (flag != 0); + + TRACE(("turning UTF-8 mode %s\n", BtoS(flag))); + update_font_utf8_mode(); + } +} +#endif + +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 = (PtyData *) XtMalloc(sizeof(*data) + BUF_SIZE + FRG_SIZE); + + memset(data, 0, sizeof(*data)); + data->next = data->buffer; + data->last = data->buffer; + *result = data; +} + +/* + * Remove used data by shifting the buffer down, to make room for more data, + * e.g., a continuation-read. + */ +void +trimPtyData(TScreen * screen GCC_UNUSED, PtyData * data) +{ + int i; + + FlushLog(screen); + + if (data->next != data->buffer) { + int n = (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(TScreen * screen, PtyData * data, char *value, int length) +{ + int size; + int n; + + /* remove the used portion of the buffer */ + trimPtyData(screen, data); + + VTbuffer->last += length; + size = 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) +{ + if (c < 0x80) { /* 0******* */ + *lp++ = (c); + } else if (c < 0x800) { /* 110***** 10****** */ + *lp++ = (0xc0 | (c >> 6)); + *lp++ = (0x80 | (c & 0x3f)); + } else { /* 1110**** 10****** 10****** */ + *lp++ = (0xe0 | (c >> 12)); + *lp++ = (0x80 | ((c >> 6) & 0x3f)); + *lp++ = (0x80 | (c & 0x3f)); + } + /* + * UTF-8 is defined for words of up to 31 bits, but we need only 16 + * bits here, since that's all that X11R6 supports. + */ + return lp; +} + +/* + * Write data back to the PTY + */ +void +writePtyData(int f, IChar * d, unsigned len) +{ + static Char *dbuf; + static unsigned dlen; + unsigned n = (len << 1); + + if (dlen <= len) { + dlen = n; + dbuf = (Char *) XtRealloc((char *) dbuf, dlen); + } + + for (n = 0; n < len; n++) + dbuf[n] = d[n]; + v_write(f, dbuf, n); +} +#endif diff --git a/nx-X11/programs/xterm/ptyx.h b/nx-X11/programs/xterm/ptyx.h new file mode 100644 index 000000000..b08f8b41d --- /dev/null +++ b/nx-X11/programs/xterm/ptyx.h @@ -0,0 +1,2016 @@ +/* $XTermId: ptyx.h,v 1.390 2005/11/03 13:17:28 tom Exp $ */ + +/* + * $Xorg: ptyx.h,v 1.3 2000/08/17 19:55:09 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/ptyx.h,v 3.127 2005/11/03 13:17:28 dickey Exp $ */ + +/* + * Copyright 1999-2004,2005 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 +#endif + +/* ptyx.h */ +/* @(#)ptyx.h X10/6.6 11/10/86 */ + +#include +#include /* for XtNdieCallback, etc. */ +#include /* for standard resource names */ +#include /* For Max() and Min(). */ +#include +#include +#include +#ifdef XRENDERFONT +#include +#endif + +/* adapted from IntrinsicI.h */ +#define MyStackAlloc(size, stack_cache_array) \ + ((size) <= sizeof(stack_cache_array) \ + ? (XtPointer)(stack_cache_array) \ + : (XtPointer)malloc((unsigned)(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((n), sizeof(type)) +#define TypeCalloc(type) TypeCalloc(type,1) + +#define TypeMallocN(type,n) (type *)malloc(sizeof(type) * (n)) +#define TypeMalloc(type) TypeMallocN(type,0) + +#define TypeRealloc(type,n,p) (type *)realloc(p, (n) * sizeof(type)) + +/* use these to allocate partly-structured data */ +#define CastMallocN(type,n) (type *)malloc(sizeof(type) + (n)) +#define CastMalloc(type) CastMallocN(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 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(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +#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 +#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, 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; + +#define CharOf(n) ((unsigned char)(n)) + +/* + * ANSI emulation, special character codes + */ +#define INQ 0x05 +#define BEL 0x07 +#define FF 0x0C /* C0, C1 control names */ +#define LS1 0x0E +#define LS0 0x0F +#define NAK 0x15 +#define CAN 0x18 +#define SUB 0x1A +#define ESC 0x1B +#define XPOUND 0x1E /* internal mapping for '#' */ +#define US 0x1F +#define DEL 0x7F +#define RI 0x8D +#define SS2 0x8E +#define SS3 0x8F +#define DCS 0x90 +#define SPA 0x96 +#define EPA 0x97 +#define SOS 0x98 +#define OLDID 0x9A /* ESC Z */ +#define CSI 0x9B +#define ST 0x9C +#define OSC 0x9D +#define PM 0x9E +#define APC 0x9F +#define RDEL 0xFF + +#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 { + char *opt; + char *desc; +} OptionHelp; + +typedef struct { + unsigned char a_type; /* CSI, etc., see unparseq() */ + unsigned char a_pintro; /* private-mode char, if any */ + unsigned char a_inters; /* special (before final-char) */ + unsigned char a_final; /* final-char */ + short a_nparam; /* # of parameters */ + short 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_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 */ +#undef OPT_COLOR_RES2 +#endif + +#ifndef OPT_COLOR_RES2 +#define OPT_COLOR_RES2 OPT_COLOR_RES /* true to avoid using extra resources */ +#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_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_SCO_FUNC_KEYS +#define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */ +#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_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_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_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_COLOR_RES2 && !(OPT_256_COLORS || OPT_88_COLORS) +/* You must have 88/256 colors to need fake-resource logic */ +#undef OPT_COLOR_RES2 +#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 + , fBold +#if OPT_WIDE_CHARS + , fWide + , fWBold +#endif + , fMAX +} VTFontEnum; + +/* indices for the normal terminal colors in screen.Tcolors[] */ +typedef enum { + TEXT_FG = 0 /* text foreground */ + , TEXT_BG = 1 /* text background */ + , TEXT_CURSOR = 2 /* text cursor */ + , MOUSE_FG = 3 /* mouse foreground */ + , MOUSE_BG = 4 /* mouse background */ +#if OPT_TEK4014 + , TEK_FG = 5 /* tektronix foreground */ + , TEK_BG = 6 /* tektronix background */ +#endif +#if OPT_HIGHLIGHT_COLOR + , HIGHLIGHT_BG = 7 /* highlight background */ +#endif +#if OPT_TEK4014 + , TEK_CURSOR = 8 /* tektronix cursor */ +#endif + , NCOLORS /* total number of colors */ +} TermColors; + +#define COLOR_DEFINED(s,w) ((s)->which & (1<<(w))) +#define COLOR_VALUE(s,w) ((s)->colors[w]) +#define SET_COLOR_VALUE(s,w,v) (((s)->colors[w] = (v)), ((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 |= (1<<(w)))) + +#define UNDEFINE_COLOR(s,w) ((s)->which &= (~((w)<<1))) + +/***====================================================================***/ + +#if OPT_ISO_COLORS +#define if_OPT_ISO_COLORS(screen, code) if(screen->colorMode) code +#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 +# define XK_COLORS 0x0003 +#endif + +#else /* !OPT_ISO_COLORS */ + +#define if_OPT_ISO_COLORS(screen, code) /* nothing */ +#define TERM_COLOR_FLAGS(xw) 0 + +#define ReverseOrHilite(screen,flags,hilite) \ + (( (flags & INVERSE) && !hilite) || \ + (!(flags & INVERSE) && hilite)) + +#endif /* OPT_ISO_COLORS */ + +#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 +# define if_OPT_EXT_COLORS(screen, code) if(screen->colorMode) code +# define if_OPT_ISO_TRADITIONAL_COLORS(screen, code) /* nothing */ +#elif OPT_ISO_COLORS +# define if_OPT_EXT_COLORS(screen, code) /* nothing */ +# define if_OPT_ISO_TRADITIONAL_COLORS(screen, code) if(screen->colorMode) code +#else +# define if_OPT_EXT_COLORS(screen, code) /* nothing */ +# define if_OPT_ISO_TRADITIONAL_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 + +/***====================================================================***/ + +#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) ((code) > CSET_DWL) + /* for doublesize characters, the first cell in a row holds the info */ +#define SCRN_ROW_CSET(screen,row) (SCRN_BUF_CSETS((screen), row)[0]) +#define CurMaxCol(screen, row) \ + (CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \ + ? (screen->max_col / 2) \ + : (screen->max_col)) +#define CurCursorX(screen, row, col) \ + (CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \ + ? CursorX(screen, 2*(col)) \ + : CursorX(screen, (col))) +#define CurFontWidth(screen, row) \ + (CSET_DOUBLE(SCRN_ROW_CSET(screen, row)) \ + ? 2*FontWidth(screen) \ + : FontWidth(screen)) +#else +#define if_OPT_DEC_CHRSET(code) /*nothing*/ +#define CurMaxCol(screen, row) screen->max_col +#define CurCursorX(screen, row, col) CursorX(screen, col) +#define CurFontWidth(screen, row) FontWidth(screen) +#endif + +#if OPT_LUIT_PROG && !OPT_WIDE_CHARS +#error Luit requires the wide-chars configuration +#endif + + /* the number of pointers per row in 'ScrnBuf' */ +#if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS +#define MAX_PTRS term->num_ptrs +#else +#define MAX_PTRS (OFF_ATTRS+1) +#endif + +#define BUF_HEAD 1 + /* the number that point to Char data */ +#define BUF_PTRS (MAX_PTRS - BUF_HEAD) + +/***====================================================================***/ + +#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(screen) ((screen)->TekEmu) +#define CURRENT_EMU_VAL(screen,tek,vt) (TEK4014_ACTIVE(screen) ? tek : vt) +#define CURRENT_EMU(screen) CURRENT_EMU_VAL(screen, (Widget)tekWidget, (Widget)term) +#else +#define TEK4014_ACTIVE(screen) 0 +#define CURRENT_EMU_VAL(screen,tek,vt) (vt) +#define CURRENT_EMU(screen) ((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) +#else +#define if_OPT_XMC_GLITCH(screen, code) /* nothing */ +#endif + +/***====================================================================***/ + +#if OPT_WIDE_CHARS +#define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code +#define PAIRED_CHARS(a,b) a,b +typedef unsigned IChar; /* for 8 or 16-bit characters, plus flag */ +#else +#define if_OPT_WIDE_CHARS(screen, code) /* nothing */ +#define PAIRED_CHARS(a,b) a +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 */ +#endif + Char buffer[1]; +} PtyData; + +/***====================================================================***/ + +/* The order of ifdef's matches the logic for num_ptrs in VTInitialize */ +typedef enum { + OFF_FLAGS = 0 /* BUF_HEAD */ + , OFF_CHARS = 1 /* first (or only) byte of cell's character */ + , OFF_ATTRS = 2 /* video attributes */ +#if OPT_ISO_COLORS +#if OPT_256_COLORS || OPT_88_COLORS + , OFF_FGRND /* foreground color number */ + , OFF_BGRND /* background color number */ +#else + , OFF_COLOR /* foreground+background color numbers */ +#endif +#endif +#if OPT_DEC_CHRSET + , OFF_CSETS /* DEC character-set */ +#endif +#if OPT_WIDE_CHARS + , OFF_WIDEC /* second byte of first wide-character */ + , OFF_COM1L /* first combining character */ + , OFF_COM1H + , OFF_COM2L /* second combining character */ + , OFF_COM2H +#endif +} BufOffsets; + + /* ScrnBuf-level macros */ +#define BUF_FLAGS(buf, row) (buf[MAX_PTRS * (row) + OFF_FLAGS]) +#define BUF_CHARS(buf, row) (buf[MAX_PTRS * (row) + OFF_CHARS]) +#define BUF_ATTRS(buf, row) (buf[MAX_PTRS * (row) + OFF_ATTRS]) +#define BUF_COLOR(buf, row) (buf[MAX_PTRS * (row) + OFF_COLOR]) +#define BUF_FGRND(buf, row) (buf[MAX_PTRS * (row) + OFF_FGRND]) +#define BUF_BGRND(buf, row) (buf[MAX_PTRS * (row) + OFF_BGRND]) +#define BUF_CSETS(buf, row) (buf[MAX_PTRS * (row) + OFF_CSETS]) +#define BUF_WIDEC(buf, row) (buf[MAX_PTRS * (row) + OFF_WIDEC]) +#define BUF_COM1L(buf, row) (buf[MAX_PTRS * (row) + OFF_COM1L]) +#define BUF_COM1H(buf, row) (buf[MAX_PTRS * (row) + OFF_COM1H]) +#define BUF_COM2L(buf, row) (buf[MAX_PTRS * (row) + OFF_COM2L]) +#define BUF_COM2H(buf, row) (buf[MAX_PTRS * (row) + OFF_COM2H]) + + /* TScreen-level macros */ +#define SCRN_BUF_FLAGS(screen, row) BUF_FLAGS(screen->visbuf, row) +#define SCRN_BUF_CHARS(screen, row) BUF_CHARS(screen->visbuf, row) +#define SCRN_BUF_ATTRS(screen, row) BUF_ATTRS(screen->visbuf, row) +#define SCRN_BUF_COLOR(screen, row) BUF_COLOR(screen->visbuf, row) +#define SCRN_BUF_FGRND(screen, row) BUF_FGRND(screen->visbuf, row) +#define SCRN_BUF_BGRND(screen, row) BUF_BGRND(screen->visbuf, row) +#define SCRN_BUF_CSETS(screen, row) BUF_CSETS(screen->visbuf, row) +#define SCRN_BUF_WIDEC(screen, row) BUF_WIDEC(screen->visbuf, row) +#define SCRN_BUF_COM1L(screen, row) BUF_COM1L(screen->visbuf, row) +#define SCRN_BUF_COM2L(screen, row) BUF_COM2L(screen->visbuf, row) +#define SCRN_BUF_COM1H(screen, row) BUF_COM1H(screen->visbuf, row) +#define SCRN_BUF_COM2H(screen, row) BUF_COM2H(screen->visbuf, row) + +typedef struct { + unsigned chrset; + unsigned flags; + XFontStruct * fs; + GC gc; + char * fn; +} XTermFonts; + +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_REVWRAP, + DP_X_X10MSE, +#if OPT_BLINK_CURS + DP_CRS_BLINK, +#endif +#if OPT_TOOLBAR + DP_TOOLBAR, +#endif + DP_LAST +} SaveModes; + +#define DoSM(code,value) screen->save_modes[code] = value +#define DoRM(code,value) value = screen->save_modes[code] + + /* index into vt_shell[] or tek_shell[] */ +typedef enum { + noMenu = -1, + mainMenu, + vtMenu, + fontMenu, + tekMenu +} MenuIndex; + +#define NUM_POPUP_MENUS 4 + +#if OPT_COLOR_RES +typedef struct { + String resource; + Pixel value; + int mode; +} ColorRes; +#else +#define ColorRes Pixel +#endif + +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 { + 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 + +struct _vtwin { + 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; + GC normalGC; /* normal painting */ + GC reverseGC; /* reverse painting */ + GC normalboldGC; /* normal painting, bold font */ + GC reverseboldGC; /* reverse painting, bold font */ +#if OPT_TOOLBAR + Boolean active; /* true if toolbars are used */ + TbInfo tb_info; /* toolbar information */ +#endif +}; + +struct _tekwin { + 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 */ +}; + +typedef struct { +/* These parameters apply to both windows */ + Display *display; /* X display for screen */ + int respond; /* socket for responses + (position report, etc.) */ +#if OPT_TCAP_QUERY + int tc_query; +#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 */ + GC cursorGC; /* normal cursor painting */ + GC fillCursorGC; /* special cursor painting */ + GC reversecursorGC;/* reverse cursor painting */ + GC cursoroutlineGC;/* for painting lines around */ + ColorRes Tcolors[NCOLORS]; /* terminal colors */ +#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 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; +#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 + Boolean c1_printable; /* true if we treat C1 as print */ +#endif + int border; /* inner border */ + int scrollBarBorder; /* scrollBar border */ + Cursor arrow; /* arrow cursor */ + unsigned long event_mask; + unsigned short send_mouse_pos; /* user wants mouse transition */ + /* and position information */ +#if OPT_PASTE64 + int base64_paste; /* set to send paste in base64 */ + /* _qWriteSelectionData expects these to be initialized to zero. + * base64_flush() is the last step of the conversion, it clears these + * variables. + */ + int base64_accu; + int base64_count; + int 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 short 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 allowSendEvents;/* SendEvent mode */ + Boolean allowWindowOps; /* WindowOps mode */ + Boolean allowSendEvent0;/* initial SendEvent mode */ + Boolean allowWindowOp0; /* initial WindowOps mode */ + Boolean awaitInput; /* select-timeout mode */ + Boolean grabbedKbd; /* keyboard is grabbed */ +#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 */ + struct _vtwin fullVwin; +#ifndef NO_ACTIVE_ICON + struct _vtwin iconVwin; + struct _vtwin * whichVwin; +#endif /* NO_ACTIVE_ICON */ + + Cursor pointer_cursor; /* pointer 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 */ + int printer_controlmode; /* 0=off, 1=auto, 2=controller */ + int print_attributes; /* 0=off, 1=normal, 2=color */ + + Boolean fnt_prop; /* true if proportional fonts */ + Boolean fnt_boxes; /* true if font has box-chars */ +#if OPT_BOX_CHARS + Boolean force_box_chars;/* true if we assume that */ + Boolean force_all_chars;/* true to outline missing chars*/ +#endif + Dimension fnt_wide; + Dimension fnt_high; + XFontStruct *fnt_norm; /* normal font of terminal */ + XFontStruct *fnt_bold; /* bold font of terminal */ + Boolean free_bold_box; /* same_font_size's austerity */ +#if OPT_WIDE_CHARS + XFontStruct *fnt_dwd; /* wide font of terminal */ + XFontStruct *fnt_dwdb; /* wide bold font of terminal */ +#endif +#ifndef NO_ACTIVE_ICON + XFontStruct *fnt_icon; /* 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... */ +#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 + int cursor_GC; /* see ShowCursor() */ + int cursor_set; /* requested state */ + int cursor_col; /* previous cursor column */ + int cursor_row; /* previous cursor row */ + Boolean cursor_moved; /* scrolling makes cursor move */ + 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 */ + int topline; /* line number of top, <= 0 */ + int savedlines; /* number of lines that've been saved */ + int savelines; /* number of lines off top to save */ + int scrolllines; /* number of lines to button scroll */ + Boolean scrollttyoutput; /* scroll to bottom on tty output */ + Boolean scrollkey; /* scroll to bottom on key */ + + ScrnBuf visbuf; /* ptr to visible screen buf (main) */ + ScrnBuf allbuf; /* screen buffer (may include + lines scrolled off top) */ + Char *sbuf_address; /* main screen memory address */ + ScrnBuf altbuf; /* alternate screen buffer */ + Char *abuf_address; /* alternate screen memory address */ + Char **save_ptr; /* workspace for save-pointers */ + size_t save_len; /* ...and its length */ + Boolean alternate; /* true if using alternate buf */ + unsigned short 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 */ + Boolean multiscroll; /* true if multi-scroll */ + int scrolls; /* outstanding scroll count, + used only with multiscroll */ + SavedCursor sc[2]; /* data for restore cursor */ + unsigned char save_modes[DP_LAST]; /* save dec/xterm private modes */ + + /* 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 scroll_amt; /* amount to scroll */ + int refresh_amt; /* amount to refresh */ + int protected_mode; /* 0=off, 1=DEC, 2=ISO */ + Boolean old_fkeys; /* true for compatible fkeys */ + Boolean delete_is_del; /* true for compatible Delete key */ + Boolean jumpscroll; /* whether we should jumpscroll */ + Boolean always_highlight; /* whether to highlight cursor */ + Boolean underline; /* whether to underline text */ + Boolean bold_mode; /* whether to use bold font */ + +#if OPT_MAXIMIZE + Boolean restore_data; + int restore_x; + int restore_y; + unsigned restore_width; + unsigned restore_height; +#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 + +#if OPT_TEK4014 +/* Tektronix window parameters */ + GC TnormalGC; /* normal painting */ + GC TcursorGC; /* normal cursor painting */ + + Boolean Tshow; /* Tek window showing */ + Boolean waitrefresh; /* postpone refresh */ + struct _tekwin fullTwin; +#ifndef NO_ACTIVE_ICON + struct _tekwin iconTwin; + struct _tekwin *whichTwin; +#endif /* NO_ACTIVE_ICON */ + + GC linepat[TEKNUMLINES]; /* line patterns */ + Boolean TekEmu; /* true if Tektronix emulation */ + 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 */ +#endif /* OPT_TEK4014 */ + + int multiClickTime; /* time between multiclick selects */ + int visualBellDelay; /* msecs to delay for visibleBell */ + int bellSuppressTime; /* msecs after Bell before another allowed */ + Boolean bellInProgress; /* still ringing/flashing prev bell? */ + 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 trim_selection; /* controls trimming of selection */ + Boolean i18nSelections; + Boolean brokenSelections; + Char *selection_data; /* the current selection */ + int selection_size; /* size of allocated buffer */ + int selection_length; /* number of significant bytes */ + Time selection_time; /* latest event timestamp */ + int startHRow, startHCol, /* highlighted text */ + endHRow, endHCol, + startHCoord, endHCoord; + Atom* selection_atoms; /* which selections we own */ + Cardinal sel_atoms_size; /* how many atoms allocated */ + Cardinal selection_count; /* how many atoms in use */ + 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 meta_sends_esc; /* Meta-key sends ESC prefix */ + Pixmap menu_item_bitmap; /* mask for checking items */ + 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_RENDERFONT + XftFont * renderFontNorm[NMENUFONTS]; + XftFont * renderFontBold[NMENUFONTS]; + XftFont * renderFontItal[NMENUFONTS]; + XftFont * renderWideNorm[NMENUFONTS]; + XftFont * renderWideBold[NMENUFONTS]; + XftFont * renderWideItal[NMENUFONTS]; + 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 + int dabbrev_working; /* nonzero during dabbrev process */ + unsigned char dabbrev_erase_char; /* used for deleting inserted completion */ +#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; + +#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 &= ~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 { + keyboardIsLegacy, /* bogus vt220 codes for F1-F4, etc. */ + keyboardIsDefault, + keyboardIsHP, + keyboardIsSCO, + keyboardIsSun, + keyboardIsVT220 +} xtermKeyboardType; + +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 + +#define NAME_SUN_KT " sun" + +#if OPT_SUNPC_KBD +#define NAME_VT220_KT " vt220" +#else +#define NAME_VT220_KT /*nothing*/ +#endif + +#define KEYBOARD_TYPES NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT + +#if OPT_TRACE +extern const char * visibleKeyboardType(xtermKeyboardType); +#endif + +typedef struct +{ + xtermKeyboardType type; + unsigned flags; +#if OPT_INITIAL_ERASE + int reset_DECBKM; /* reset should set DECBKM */ +#endif + int modify_cursor_keys; /* how to handle modifiers */ +} TKeyboard; + +typedef struct { + char *f_n; /* the normal font */ + char *f_b; /* the bold font */ +#if OPT_WIDE_CHARS + char *f_w; /* the normal wide font */ + char *f_wb; /* the bold wide font */ +#endif +} VTFontNames; + +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() */ +#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 +#if OPT_INPUT_METHOD + char *f_x; /* font for XIM */ +#endif + 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 */ +#endif + Boolean scrollbar; +#ifdef SCROLLBAR_RIGHT + Boolean useRight; +#endif + Boolean titeInhibit; + Boolean tiXtraScroll; + Boolean appcursorDefault; + Boolean appkeypadDefault; +#if OPT_INPUT_METHOD + char* input_method; + char* preedit_type; + Boolean open_im; + Boolean cannot_im; /* true if we cannot use input-method */ +#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 long num_lock; /* modifier for Num_Lock */ + unsigned long alt_left; /* modifier for Alt_L */ + unsigned long alt_right; /* modifier for Alt_R */ + Boolean meta_trans; /* true if Meta is used in translations */ + unsigned long meta_left; /* modifier for Meta_L */ + unsigned long meta_right; /* modifier for Meta_R */ +#endif +#if OPT_RENDERFONT + char *face_name; + char *face_wide_name; + float face_size; + 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; +#endif + +/* define masks for keyboard.flags */ +#define MODE_KAM 0x01 /* keyboard action mode */ +#define MODE_DECKPAM 0x02 /* keypad application mode */ +#define MODE_DECCKM 0x04 /* cursor keys */ +#define MODE_SRM 0x08 /* send-receive mode */ +#define MODE_DECBKM 0x10 /* backarrow */ + + +#define N_MARGINBELL 10 + +#define TAB_BITS_SHIFT 5 /* 2**5 == 32 */ +#define TAB_BITS_WIDTH (1 << TAB_BITS_SHIFT) +#define TAB_ARRAY_SIZE 10 /* number of ints to provide MAX_TABS bits */ +#define MAX_TABS (TAB_BITS_WIDTH * TAB_ARRAY_SIZE) + +typedef unsigned Tabs [TAB_ARRAY_SIZE]; + +typedef struct _XtermWidgetRec { + CorePart core; + 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 +#if OPT_ISO_COLORS || OPT_DEC_CHRSET || OPT_WIDE_CHARS + int num_ptrs; /* number of pointers per row in 'ScrnBuf' */ +#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; +} 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. + */ + +/* global flags and character flags (visible character attributes) */ +#define INVERSE 0x01 /* invert the characters to be output */ +#define UNDERLINE 0x02 /* true if underlining */ +#define BOLD 0x04 +#define BLINK 0x08 +/* global flags (also character attributes) */ +#define BG_COLOR 0x10 /* true if background set */ +#define FG_COLOR 0x20 /* true if foreground set */ + +/* character flags (internal attributes) */ +#define PROTECTED 0x40 /* a character is drawn that cannot be erased */ +#define CHARDRAWN 0x80 /* a character has been drawn here on the + screen. Used to distinguish blanks from + empty parts of the screen when selecting */ + +#if OPT_BLINK_TEXT +#define BOLDATTR(screen) (BOLD | ((screen)->blink_as_bold ? BLINK : 0)) +#else +#define BOLDATTR(screen) (BOLD | BLINK) +#endif + +/* The following attributes make sense in the argument of drawXtermText() */ +#define NOBACKGROUND 0x100 /* Used for overstrike */ +#define NOTRANSLATION 0x200 /* No scan for chars missing in font */ +#define NATIVEENCODING 0x400 /* strings are in the font encoding */ +#define DOUBLEWFONT 0x800 /* The actual X-font is double-width */ +#define DOUBLEHFONT 0x1000 /* The actual X-font is double-height */ +#define CHARBYCHAR 0x2000 /* Draw chars one-by-one */ + +/* The toplevel-call to drawXtermText() should have text-attributes guarded: */ +#define DRAWX_MASK 0xff /* text flags should be bitand'ed */ + +/* The following attribute makes sense in the argument of xtermSpecialFont etc */ +#define NORESOLUTION 0x800000 /* find the font without resolution */ + + /* mask: user-visible attributes */ +#define ATTRIBUTES (INVERSE|UNDERLINE|BOLD|BLINK|BG_COLOR|FG_COLOR|INVISIBLE|PROTECTED) + + /* mask for video-attributes only */ +#define SGR_MASK (BOLD|BLINK|UNDERLINE|INVERSE) + +#define WRAPAROUND 0x400 /* true if auto wraparound mode */ +#define REVERSEWRAP 0x800 /* true if reverse wraparound mode */ +#define REVERSE_VIDEO 0x1000 /* true if screen white on black */ +#define LINEFEED 0x2000 /* true if in auto linefeed mode */ +#define ORIGIN 0x4000 /* true if in origin mode */ +#define INSERT 0x8000 /* true if in insert mode */ +#define SMOOTHSCROLL 0x10000 /* true if in smooth scroll mode */ +#define IN132COLUMNS 0x20000 /* true if in 132 column mode */ +#define INVISIBLE 0x40000 /* true if writing invisible text */ +#define NATIONAL 0x100000 /* true if writing national charset */ + +/* + * Per-line flags + */ +#define LINEWRAPPED 0x01 /* 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. + */ +/* + * 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 + +#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)->cursor_col != (screen)->cur_col || \ + (screen)->cursor_row != (screen)->cur_row)) + +#define CursorX(screen,col) ((col) * FontWidth(screen) + OriginX(screen)) +#define CursorY(screen,row) ((((row) - screen->topline) * 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 \ + : (screen)->name) +#define FontAscent(screen) (IsIcon(screen) ? (screen)->fnt_icon->ascent \ + : WhichVWin(screen)->f_ascent) +#define FontDescent(screen) (IsIcon(screen) ? (screen)->fnt_icon->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 */ + +/* + * Macro to check if we are iconified; do not use render for that case. + */ +#define UsingRenderFont(xw) ((xw)->misc.render_font && !IsIcon(&((xw)->screen))) + +/* + * These definitions do not depend on whether xterm supports active-icon. + */ +#define VWindow(screen) WhichVWin(screen)->window +#define VShellWindow XtWindow(SHELL_OF(term)) +#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, fnt_norm) +#define BoldFont(screen) WhichVFont(screen, fnt_bold) + +#define ScrollbarWidth(screen) WhichVWin(screen)->sb_info.width +#define NormalGC(screen) WhichVWin(screen)->normalGC +#define ReverseGC(screen) WhichVWin(screen)->reverseGC +#define NormalBoldGC(screen) WhichVWin(screen)->normalboldGC +#define ReverseBoldGC(screen) WhichVWin(screen)->reverseboldGC + +#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) + +#if OPT_TOOLBAR +#define ToolbarHeight(w) ((resource.toolBar) \ + ? (term->VT100_TB_INFO(menu_height) \ + + term->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 +#include +#undef NDEBUG /* turn on assert's */ +#else +#ifndef NDEBUG +#define NDEBUG /* not debugging, don't do assert's */ +#endif +#endif + +#ifndef TRACE +#define TRACE(p) /*nothing*/ +#endif + +#ifndef TRACE_ARGV +#define TRACE_ARGV(tag,argv) /*nothing*/ +#endif + +#ifndef TRACE_CHILD +#define TRACE_CHILD /*nothing*/ +#endif + +#ifndef TRACE_HINTS +#define TRACE_HINTS(hints) /*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 + +#endif /* included_ptyx_h */ diff --git a/nx-X11/programs/xterm/resize.c b/nx-X11/programs/xterm/resize.c new file mode 100644 index 000000000..67cdd6e57 --- /dev/null +++ b/nx-X11/programs/xterm/resize.c @@ -0,0 +1,600 @@ +/* $XTermId: resize.c,v 1.97 2005/11/13 23:10:36 tom Exp $ */ + +/* + * $Xorg: resize.c,v 1.3 2000/08/17 19:55:09 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/resize.c,v 3.60 2005/11/13 23:10:36 dickey Exp $ */ + +/* + * Copyright 2003-2004,2005 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 +#include +#include +#include +#include + +#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 +#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 +#include + +#ifdef X_NOT_POSIX +#if !defined(SYSV) && !defined(i386) +extern struct passwd *getpwuid(); /* does ANYBODY need this? */ +#endif /* SYSV && i386 */ +#endif /* X_NOT_POSIX */ + +#ifndef bzero +#define bzero(s, n) memset(s, 0, n) +#endif + +#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 { + 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 char *emuname[EMULATIONS] = +{ + "VT100", + "Sun", +}; +static char *myname; +static int shell_type = SHELL_UNKNOWN; +static 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 char *getwsize[EMULATIONS] = +{ /* size in pixels */ + 0, + ESCAPE("[14t"), +}; +#endif /* USE_STRUCT_{TTYSIZE|WINSIZE} */ +static char *restore[EMULATIONS] = +{ + ESCAPE("8"), + 0, +}; +static char *setname = ""; +static 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 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 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, char *str); + +#undef US /* may conflict with curses.h */ + +#ifdef USE_TERMCAP +#ifdef HAVE_TERMCAP_H +#include +#if defined(NCURSES_VERSION) + /* The tgetent emulation function in SVr4-style curses implementations + * (e.g., ncurses) ignores the buffer, so TERMCAP can't be set from it. + * Instead, just use terminfo. + */ +#undef USE_TERMCAP +#include +#endif +#else +#undef ERR /* workaround for glibc 2.1.3 */ +#include +#ifdef NCURSES_VERSION +#ifdef HAVE_NCURSES_TERM_H +#include +#else +#include /* tgetent() */ +#endif /*CYGWIN */ +#endif +#endif /* HAVE_TERMCAP_H */ +#endif + +#define TERMCAP_SIZE 1500 /* 1023 is standard; 'screen' exceeds */ + +#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) +{ + register char *ptr, *env; + register 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 = getenv("SHELL")) == NULL || *ptr == 0) && + (((pw = getpwuid(getuid())) == NULL) || + *(ptr = pw->pw_shell) == 0)) + /* this is the same default that xterm uses */ + ptr = "/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 = "/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 = getenv("TERM")) || !*env) { + env = DFT_TERMTYPE; + if (SHELL_BOURNE == shell_type) + setname = "TERM=xterm;\nexport TERM;\n"; + else + setname = "setenv TERM xterm;\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 (!(env = getenv("TERM")) || !*env) { + env = DFT_TERMTYPE; + if (SHELL_BOURNE == shell_type) + setname = "TERM=xterm;\nexport TERM;\n"; + else + setname = "setenv TERM xterm;\n"; + } +#endif /* USE_TERMINFO */ + +#ifdef USE_ANY_SYSV_TERMIO + ioctl(tty, TCGETA, &tioorig); + tio = tioorig; + tio.c_iflag &= ~(ICRNL | IUCLC); + 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; + tio.c_iflag &= ~ICRNL; + 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; + 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) { + sprintf(buf, setsize[emu], argv[0], argv[1]); + write(tty, buf, strlen(buf)); + } + 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]) + 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 */ + 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) = rows; + TTYSIZE_COLS(ts) = 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 = cols * (ts.ws_xpixel / TTYSIZE_COLS(ts)); + if (TTYSIZE_ROWS(ts) != 0) + ts.ws_ypixel = rows * (ts.ws_ypixel / TTYSIZE_ROWS(ts)); + TTYSIZE_ROWS(ts) = rows; + TTYSIZE_COLS(ts) = 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, (unsigned) 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, (unsigned) 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(register char *str) +{ + while (*str) { + if (!isdigit(CharOf(*str))) + return (0); + str++; + } + return (1); +} + +static void +readstring(register FILE *fp, register char *buf, char *str) +{ + register 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 + bzero((char *) &it, 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 */ + *buf++ = c = ESCAPE("")[0]; + *buf++ = '['; + } else { + *buf++ = c; + } + if (c != *str) { + fprintf(stderr, "%s: unknown character, exiting.\r\n", myname); + onintr(0); + } + last = str[strlen(str) - 1]; + while ((*buf++ = getc(fp)) != last) ; +#if defined(USG) || defined(__UNIXOS2__) + alarm(0); +#else + bzero((char *) &it, 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/nx-X11/programs/xterm/resize.man b/nx-X11/programs/xterm/resize.man new file mode 100644 index 000000000..a1bdc0f45 --- /dev/null +++ b/nx-X11/programs/xterm/resize.man @@ -0,0 +1,84 @@ +.\" $Xorg: resize.man,v 1.3 2000/08/17 19:55:09 cpqbld Exp $ +.\" +.\" updated by Thomas E. Dickey for XFree86, 1998-2002. +.\" +.\" $XFree86: xc/programs/xterm/resize.man,v 1.10 2002/08/17 19:52:27 dickey Exp $ +.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 'set noglob; eval \fC`\fPresize\fC`\fP' +.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 the 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(1) +.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/nx-X11/programs/xterm/screen.c b/nx-X11/programs/xterm/screen.c new file mode 100644 index 000000000..09712218f --- /dev/null +++ b/nx-X11/programs/xterm/screen.c @@ -0,0 +1,1853 @@ +/* $XTermId: screen.c,v 1.184 2005/11/03 13:17:28 tom Exp $ */ + +/* + * $Xorg: screen.c,v 1.3 2000/08/17 19:55:09 cpqbld Exp $ + */ + +/* + * Copyright 1999-2004,2005 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. + */ + +/* $XFree86: xc/programs/xterm/screen.c,v 3.73 2005/11/03 13:17:28 dickey Exp $ */ + +/* screen.c */ + +#include +#include +#include +#include +#include +#include + +#if OPT_WIDE_CHARS +#include +#include +#endif + +#include +#include + +#define getMinRow(screen) ((term->flags & ORIGIN) ? (screen)->top_marg : 0) +#define getMaxRow(screen) ((term->flags & ORIGIN) ? (screen)->bot_marg : (screen)->max_row) +#define getMinCol(screen) 0 +#define getMaxCol(screen) ((screen)->max_col) + +/* + * 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, together + * with the intention of being able to change the total number of pointers per + * row according to whether the user wants color or not. + */ +ScrnBuf +Allocate(int nrow, int ncol, Char ** addr) +{ + ScrnBuf base; + Char *tmp; + int i, j, k; + size_t entries = MAX_PTRS * nrow; + size_t length = BUF_PTRS * nrow * ncol; + + if ((base = TypeCallocN(ScrnPtr, entries)) == 0) + SysError(ERROR_SCALLOC); + + if ((tmp = TypeCallocN(Char, length)) == 0) + SysError(ERROR_SCALLOC2); + + *addr = tmp; + for (i = k = 0; i < nrow; i++) { + base[k] = 0; /* per-line flags */ + k += BUF_HEAD; + for (j = BUF_HEAD; j < MAX_PTRS; j++) { + base[k++] = tmp; + tmp += ncol; + } + } + + return (base); +} + +/* + * 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(ScrnBuf * sbuf, + Char ** sbufaddr, + int nrow, + int ncol, + int oldrow, + int oldcol) +{ + ScrnBuf base; + Char *tmp; + int i, j, k, minrows; + size_t mincols; + Char *oldbuf; + int move_down = 0, move_up = 0; + size_t entries = MAX_PTRS * nrow; + size_t length = BUF_PTRS * nrow * ncol; + + if (sbuf == NULL || *sbuf == NULL) { + return 0; + } + + oldbuf = *sbufaddr; + + /* + * Special case if oldcol == ncol - straight forward realloc and + * update of the additional lines in sbuf + * + * FIXME: this is a good idea, but doesn't seem to be implemented. + * -gildea + */ + + /* + * 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. + */ + if (nrow < oldrow + && term->misc.resizeGravity == SouthWestGravity) { + /* Remove lines off the top of the buffer if necessary. */ + move_up = (oldrow - nrow) + - (term->screen.max_row - term->screen.cur_row); + if (move_up < 0) + move_up = 0; + /* Overlapping memmove here! */ + memmove(*sbuf, *sbuf + (move_up * MAX_PTRS), + MAX_PTRS * (oldrow - move_up) * sizeof((*sbuf)[0])); + } + *sbuf = TypeRealloc(ScrnPtr, entries, *sbuf); + if (*sbuf == 0) + SysError(ERROR_RESIZE); + base = *sbuf; + + /* + * create the new buffer space and copy old buffer contents there + * line by line. + */ + if ((tmp = TypeCallocN(Char, length)) == 0) + SysError(ERROR_SREALLOC); + *sbufaddr = tmp; + minrows = (oldrow < nrow) ? oldrow : nrow; + mincols = (oldcol < ncol) ? oldcol : ncol; + if (nrow > oldrow + && term->misc.resizeGravity == SouthWestGravity) { + /* move data down to bottom of expanded screen */ + move_down = Min(nrow - oldrow, term->screen.savedlines); + tmp += (ncol * move_down * BUF_PTRS); + } + + for (i = k = 0; i < minrows; i++) { + k += BUF_HEAD; + for (j = BUF_HEAD; j < MAX_PTRS; j++) { + memcpy(tmp, base[k++], mincols); + tmp += ncol; + } + } + + /* + * update the pointers in sbuf + */ + for (i = k = 0, tmp = *sbufaddr; i < nrow; i++) { + for (j = 0; j < BUF_HEAD; j++) + base[k++] = 0; + for (j = BUF_HEAD; j < MAX_PTRS; j++) { + base[k++] = tmp; + tmp += ncol; + } + } + + /* Now free the old buffer */ + free(oldbuf); + + return move_down ? move_down : -move_up; /* convert to rows */ +} + +#if OPT_WIDE_CHARS +#if 0 +static void +dump_screen(const char *tag, + ScrnBuf sbuf, + Char * sbufaddr, + unsigned nrow, + unsigned ncol) +{ + unsigned y, x; + + TRACE(("DUMP %s, ptrs %d\n", tag, term->num_ptrs)); + TRACE((" sbuf %p\n", sbuf)); + TRACE((" sbufaddr %p\n", sbufaddr)); + TRACE((" nrow %d\n", nrow)); + TRACE((" ncol %d\n", ncol)); + + for (y = 0; y < nrow; ++y) { + ScrnPtr ptr = BUF_CHARS(sbuf, y); + TRACE(("%3d:%p:", y, ptr)); + for (x = 0; x < ncol; ++x) { + Char c = ptr[x]; + if (c == 0) + c = '~'; + TRACE(("%c", c)); + } + TRACE(("\n")); + } +} +#else +#define dump_screen(tag, sbuf, sbufaddr, nrow, ncol) /* nothing */ +#endif + +/* + * This function reallocates memory if changing the number of Buf offsets. + * The code is based on Reallocate(). + */ +static void +ReallocateBufOffsets(ScrnBuf * sbuf, + Char ** sbufaddr, + unsigned nrow, + unsigned ncol, + size_t new_max_offsets) +{ + unsigned i; + int j, k; + ScrnBuf base; + Char *oldbuf, *tmp; + size_t entries, length; + /* + * As there are 2 buffers (allbuf, altbuf), we cannot change num_ptrs in + * this function. However MAX_PTRS and BUF_PTRS depend on num_ptrs so + * change it now and restore the value when done. + */ + int old_max_ptrs = MAX_PTRS; + + assert(nrow != 0); + assert(ncol != 0); + assert(new_max_offsets != 0); + + dump_screen("before", *sbuf, *sbufaddr, nrow, ncol); + + term->num_ptrs = new_max_offsets; + + entries = MAX_PTRS * nrow; + length = BUF_PTRS * nrow * ncol; + oldbuf = *sbufaddr; + + *sbuf = TypeRealloc(ScrnPtr, entries, *sbuf); + if (*sbuf == 0) + SysError(ERROR_RESIZE); + base = *sbuf; + + if ((tmp = TypeCallocN(Char, length)) == 0) + SysError(ERROR_SREALLOC); + *sbufaddr = tmp; + + for (i = k = 0; i < nrow; i++) { + k += BUF_HEAD; + for (j = BUF_HEAD; j < old_max_ptrs; j++) { + memcpy(tmp, base[k++], ncol); + tmp += ncol; + } + tmp += ncol * (new_max_offsets - old_max_ptrs); + } + + /* + * update the pointers in sbuf + */ + for (i = k = 0, tmp = *sbufaddr; i < nrow; i++) { + for (j = 0; j < BUF_HEAD; j++) + base[k++] = 0; + for (j = BUF_HEAD; j < MAX_PTRS; j++) { + base[k++] = tmp; + tmp += ncol; + } + } + + /* Now free the old buffer and restore num_ptrs */ + free(oldbuf); + dump_screen("after", *sbuf, *sbufaddr, nrow, ncol); + + term->num_ptrs = old_max_ptrs; +} + +/* + * This function dynamically adds support for wide-characters. + */ +void +ChangeToWide(TScreen * screen) +{ + unsigned new_bufoffset = (OFF_COM2H + 1); + int savelines = screen->scrollWidget ? screen->savelines : 0; + + if (screen->wide_chars) + return; + + TRACE(("ChangeToWide\n")); + if (xtermLoadWideFonts(term, True)) { + if (savelines < 0) + savelines = 0; + ReallocateBufOffsets(&screen->allbuf, &screen->sbuf_address, + (unsigned) (MaxRows(screen) + savelines), + (unsigned) MaxCols(screen), + new_bufoffset); + if (screen->altbuf) + ReallocateBufOffsets(&screen->altbuf, &screen->abuf_address, + (unsigned) MaxRows(screen), + (unsigned) MaxCols(screen), + new_bufoffset); + screen->wide_chars = True; + term->num_ptrs = new_bufoffset; + screen->visbuf = &screen->allbuf[MAX_PTRS * savelines]; + update_font_utf8_mode(); + SetVTFont(term, screen->menu_font_number, TRUE, NULL); + } + TRACE(("...ChangeToWide\n")); +} +#endif + +/* + * Disown the selection and repaint the area that is highlighted so it is no + * longer highlighted. + */ +void +ScrnDisownSelection(TScreen * screen) +{ + if (ScrnHaveSelection(screen)) { + DisownSelection(term); + } +} + +/* + * Writes str into buf at screen's current row and column. Characters are set + * to match flags. + */ +void +ScreenWrite(TScreen * screen, + PAIRED_CHARS(Char * str, Char * str2), + unsigned flags, + unsigned cur_fg_bg, + unsigned length) +{ +#if OPT_ISO_COLORS +#if OPT_EXT_COLORS + Char *fbf = 0; + Char *fbb = 0; +#else + Char *fb = 0; +#endif +#endif +#if OPT_DEC_CHRSET + Char *cb = 0; +#endif + Char *attrs; + int avail = MaxCols(screen) - screen->cur_col; + Char *chars; + int wrappedbit; +#if OPT_WIDE_CHARS + Char starcol1, starcol2; + Char *comb1l = 0, *comb1h = 0, *comb2l = 0, *comb2h = 0; +#endif + unsigned real_width = visual_width(PAIRED_CHARS(str, str2), length); + + if (avail <= 0) + return; + if (length > (unsigned) avail) + length = avail; + if (length == 0 || real_width == 0) + return; + + chars = SCRN_BUF_CHARS(screen, screen->cur_row) + screen->cur_col; + attrs = SCRN_BUF_ATTRS(screen, screen->cur_row) + screen->cur_col; + + if_OPT_WIDE_CHARS(screen, { + comb1l = SCRN_BUF_COM1L(screen, screen->cur_row) + screen->cur_col; + comb1h = SCRN_BUF_COM1H(screen, screen->cur_row) + screen->cur_col; + comb2l = SCRN_BUF_COM2L(screen, screen->cur_row) + screen->cur_col; + comb2h = SCRN_BUF_COM2H(screen, screen->cur_row) + screen->cur_col; + }); + + if_OPT_EXT_COLORS(screen, { + fbf = SCRN_BUF_FGRND(screen, screen->cur_row) + screen->cur_col; + fbb = SCRN_BUF_BGRND(screen, screen->cur_row) + screen->cur_col; + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fb = SCRN_BUF_COLOR(screen, screen->cur_row) + screen->cur_col; + }); + if_OPT_DEC_CHRSET({ + cb = SCRN_BUF_CSETS(screen, screen->cur_row) + screen->cur_col; + }); + + wrappedbit = ScrnTstWrapped(screen, screen->cur_row); + +#if OPT_WIDE_CHARS + starcol1 = *chars; + starcol2 = chars[length - 1]; +#endif + + /* write blanks if we're writing invisible text */ + if (flags & INVISIBLE) { + memset(chars, ' ', length); + } else { + memcpy(chars, str, length); /* This can stand for the present. If it + is wrong, we will scribble over it */ + } + +#if OPT_BLINK_TEXT + if ((flags & BLINK) && !(screen->blink_as_bold)) { + ScrnSetBlinked(screen, screen->cur_row); + } +#endif + +#define ERROR_1 0x20 +#define ERROR_2 0x00 + if_OPT_WIDE_CHARS(screen, { + + Char *char2; + + if (real_width != length) { + Char *char1 = chars; + char2 = SCRN_BUF_WIDEC(screen, screen->cur_row); + char2 += screen->cur_col; + if (screen->cur_col && starcol1 == HIDDEN_LO && *char2 == HIDDEN_HI + && iswide(char1[-1] | (char2[-1] << 8))) { + char1[-1] = ERROR_1; + char2[-1] = ERROR_2; + } + /* if we are overwriting the right hand half of a + wide character, make the other half vanish */ + while (length) { + int ch = *str; + if (str2) + ch |= *str2 << 8; + + *char1 = *str; + char1++; + str++; + + if (str2) { + *char2 = *str2; + str2++; + } else + *char2 = 0; + char2++; + length--; + + if (iswide(ch)) { + *char1 = HIDDEN_LO; + *char2 = HIDDEN_HI; + char1++; + char2++; + } + } + + if (*char1 == HIDDEN_LO + && *char2 == HIDDEN_HI + && char1[-1] == HIDDEN_LO + && char2[-1] == HIDDEN_HI) { + *char1 = ERROR_1; + *char2 = ERROR_2; + } + /* if we are overwriting the left hand half of a + wide character, make the other half vanish */ + } + + else { + + if ((char2 = SCRN_BUF_WIDEC(screen, screen->cur_row)) != 0) { + char2 += screen->cur_col; + if (screen->cur_col && starcol1 == HIDDEN_LO && *char2 == HIDDEN_HI + && iswide(chars[-1] | (char2[-1] << 8))) { + chars[-1] = ERROR_1; + char2[-1] = ERROR_2; + } + /* if we are overwriting the right hand half of a + wide character, make the other half vanish */ + if (chars[length] == HIDDEN_LO && char2[length] == HIDDEN_HI && + iswide(starcol2 | (char2[length - 1] << 8))) { + chars[length] = ERROR_1; + char2[length] = ERROR_2; + } + /* if we are overwriting the left hand half of a + wide character, make the other half vanish */ + if ((flags & INVISIBLE) || (str2 == 0)) + memset(char2, 0, length); + else + memcpy(char2, str2, length); + } + } + }); + + flags &= ATTRIBUTES; + flags |= CHARDRAWN; + memset(attrs, (Char) flags, real_width); + + if_OPT_WIDE_CHARS(screen, { + memset(comb1l, 0, real_width); + memset(comb2l, 0, real_width); + memset(comb1h, 0, real_width); + memset(comb2h, 0, real_width); + }); + if_OPT_EXT_COLORS(screen, { + memset(fbf, (Char) (cur_fg_bg >> 8), real_width); + memset(fbb, (Char) (cur_fg_bg & 0xff), real_width); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + memset(fb, cur_fg_bg, real_width); + }); + if_OPT_DEC_CHRSET({ + memset(cb, curXtermChrSet(screen->cur_row), real_width); + }); + + if (wrappedbit) + ScrnSetWrapped(screen, screen->cur_row); + else + ScrnClrWrapped(screen, screen->cur_row); + + if_OPT_WIDE_CHARS(screen, { + screen->last_written_col = screen->cur_col + real_width - 1; + screen->last_written_row = screen->cur_row; + }); + + if_OPT_XMC_GLITCH(screen, { + Resolve_XMC(screen); + }); +} + +/* + * Saves pointers to the n lines beginning at sb + where, and clears the lines + */ +static void +ScrnClearLines(TScreen * screen, ScrnBuf sb, int where, unsigned n, unsigned size) +{ + int i, j; + size_t len = ScrnPointers(screen, n); + int last = (n * MAX_PTRS); + + TRACE(("ScrnClearLines(where %d, n %d, size %d)\n", where, n, size)); + + assert(n != 0); + assert(size != 0); + + /* save n lines at where */ + memcpy((char *) screen->save_ptr, + (char *) &sb[MAX_PTRS * where], + len); + + /* clear contents of old rows */ + if (TERM_COLOR_FLAGS(term)) { + int flags = TERM_COLOR_FLAGS(term); + for (i = 0; i < last; i += MAX_PTRS) { + for (j = 0; j < MAX_PTRS; j++) { + if (j < BUF_HEAD) + screen->save_ptr[i + j] = 0; + else if (j == OFF_ATTRS) + memset(screen->save_ptr[i + j], flags, size); +#if OPT_ISO_COLORS +#if OPT_EXT_COLORS + else if (j == OFF_FGRND) + memset(screen->save_ptr[i + j], term->sgr_foreground, size); + else if (j == OFF_BGRND) + memset(screen->save_ptr[i + j], term->cur_background, size); +#else + else if (j == OFF_COLOR) + memset(screen->save_ptr[i + j], xtermColorPair(), size); +#endif +#endif + else + bzero(screen->save_ptr[i + j], size); + } + } + } else { + for (i = 0; i < last; i += MAX_PTRS) { + for (j = 0; j < BUF_HEAD; j++) + screen->save_ptr[i + j] = 0; + for (j = BUF_HEAD; j < MAX_PTRS; j++) + bzero(screen->save_ptr[i + j], size); + } + } +} + +size_t +ScrnPointers(TScreen * screen, size_t len) +{ + len *= MAX_PTRS; + + if (len > screen->save_len) { + if (screen->save_len) + screen->save_ptr = TypeRealloc(ScrnPtr, len, screen->save_ptr); + else + screen->save_ptr = TypeMallocN(ScrnPtr, len); + screen->save_len = len; + if (screen->save_ptr == 0) + SysError(ERROR_SAVE_PTR); + } + return len * sizeof(ScrnPtr); +} + +/* + * Inserts n blank lines at sb + where, treating last as a bottom margin. + * size is the size of each entry in sb. + */ +void +ScrnInsertLine(TScreen * screen, ScrnBuf sb, int last, int where, + unsigned n, unsigned size) +{ + size_t len = ScrnPointers(screen, n); + + assert(where >= 0); + assert(last >= (int) n); + assert(last >= where); + + assert(n != 0); + assert(size != 0); + assert(MAX_PTRS > 0); + + /* save n lines at bottom */ + ScrnClearLines(screen, sb, (last -= n - 1), n, size); + + /* + * WARNING, overlapping copy operation. Move down lines (pointers). + * + * +----|---------|--------+ + * + * is copied in the array to: + * + * +--------|---------|----+ + */ + assert(last >= where); + memmove((char *) &sb[MAX_PTRS * (where + n)], + (char *) &sb[MAX_PTRS * where], + MAX_PTRS * sizeof(char *) * (last - where)); + + /* reuse storage for new lines at where */ + memcpy((char *) &sb[MAX_PTRS * where], + (char *) screen->save_ptr, + len); +} + +/* + * Deletes n lines at sb + where, treating last as a bottom margin. + * size is the size of each entry in sb. + */ +void +ScrnDeleteLine(TScreen * screen, ScrnBuf sb, int last, int where, + unsigned n, unsigned size) +{ + assert(where >= 0); + assert(last >= where + (int) n - 1); + + assert(n != 0); + assert(size != 0); + assert(MAX_PTRS > 0); + + ScrnClearLines(screen, sb, where, n, size); + + /* move up lines */ + memmove((char *) &sb[MAX_PTRS * where], + (char *) &sb[MAX_PTRS * (where + n)], + MAX_PTRS * sizeof(char *) * ((last -= n - 1) - where)); + + /* reuse storage for new bottom lines */ + memcpy((char *) &sb[MAX_PTRS * last], + (char *) screen->save_ptr, + MAX_PTRS * sizeof(char *) * n); +} + +/* + * Inserts n blanks in screen at current row, col. Size is the size of each + * row. + */ +void +ScrnInsertChar(TScreen * screen, unsigned n) +{ + ScrnBuf sb = screen->visbuf; + unsigned last = MaxCols(screen); + int row = screen->cur_row; + unsigned col = screen->cur_col; + unsigned i; + Char *ptr = BUF_CHARS(sb, row); + Char *attrs = BUF_ATTRS(sb, row); + int wrappedbit = ScrnTstWrapped(screen, row); + int flags = CHARDRAWN | TERM_COLOR_FLAGS(term); + size_t nbytes; + + if (last <= (col + n)) { + if (last <= col) + return; + n = last - col; + } + nbytes = (last - (col + n)); + + assert(screen->cur_col >= 0); + assert(screen->cur_row >= 0); + assert(n > 0); + assert(last > n); + + ScrnClrWrapped(screen, row); /* make sure the bit isn't moved */ + for (i = last - 1; i >= col + n; i--) { + unsigned j = i - n; + assert(i >= n); + ptr[i] = ptr[j]; + attrs[i] = attrs[j]; + } + + for (i = col; i < col + n; i++) + ptr[i] = ' '; + for (i = col; i < col + n; i++) + attrs[i] = flags; + if_OPT_EXT_COLORS(screen, { + ptr = BUF_FGRND(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, term->sgr_foreground, n); + ptr = BUF_BGRND(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, term->cur_background, n); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + ptr = BUF_COLOR(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, xtermColorPair(), n); + }); + if_OPT_DEC_CHRSET({ + ptr = BUF_CSETS(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, curXtermChrSet(row), n); + }); + if_OPT_WIDE_CHARS(screen, { + ptr = BUF_WIDEC(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, 0, n); + + ptr = BUF_COM1L(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, 0, n); + + ptr = BUF_COM1H(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, 0, n); + + ptr = BUF_COM2L(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, 0, n); + + ptr = BUF_COM2H(sb, row); + memmove(ptr + col + n, ptr + col, nbytes); + memset(ptr + col, 0, n); + }); + + if (wrappedbit) + ScrnSetWrapped(screen, row); + else + ScrnClrWrapped(screen, row); +} + +/* + * Deletes n characters at current row, col. + */ +void +ScrnDeleteChar(TScreen * screen, unsigned n) +{ + ScrnBuf sb = screen->visbuf; + unsigned last = MaxCols(screen); + unsigned row = screen->cur_row; + unsigned col = screen->cur_col; + Char *ptr = BUF_CHARS(sb, row); + Char *attrs = BUF_ATTRS(sb, row); + size_t nbytes; + + if (last <= (col + n)) { + if (last <= col) + return; + n = last - col; + } + nbytes = (last - (col + n)); + + assert(screen->cur_col >= 0); + assert(screen->cur_row >= 0); + assert(n > 0); + assert(last > n); + + memmove(ptr + col, ptr + col + n, nbytes); + memmove(attrs + col, attrs + col + n, nbytes); + bzero(ptr + last - n, n); + memset(attrs + last - n, (Char) (TERM_COLOR_FLAGS(term)), n); + + if_OPT_EXT_COLORS(screen, { + ptr = BUF_FGRND(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, term->sgr_foreground, n); + ptr = BUF_BGRND(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, term->cur_background, n); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + ptr = BUF_COLOR(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, xtermColorPair(), n); + }); + if_OPT_DEC_CHRSET({ + ptr = BUF_CSETS(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, curXtermChrSet(row), n); + }); + if_OPT_WIDE_CHARS(screen, { + ptr = BUF_WIDEC(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, 0, n); + + ptr = BUF_COM1L(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, 0, n); + + ptr = BUF_COM1H(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, 0, n); + + ptr = BUF_COM2L(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, 0, n); + + ptr = BUF_COM2H(sb, row); + memmove(ptr + col, ptr + col + n, nbytes); + memset(ptr + last - n, 0, n); + }); + ScrnClrWrapped(screen, row); +} + +/* + * 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(TScreen * screen, + int toprow, + int leftcol, + int nrows, + int ncols, + Bool force) /* ... leading/trailing spaces */ +{ + int y = toprow * FontHeight(screen) + screen->border; + int row; + int topline = screen->topline; + int maxrow = toprow + nrows - 1; + int scrollamt = screen->scroll_amt; + int max = screen->max_row; + int gc_changes = 0; +#ifdef __CYGWIN__ + static char first_time = 1; +#endif + static int recurse = 0; + + TRACE(("ScrnRefresh (%d,%d) - (%d,%d)%s\n", + toprow, leftcol, + nrows, ncols, + force ? " force" : "")); + + if (screen->cursor_col >= leftcol + && screen->cursor_col <= (leftcol + ncols - 1) + && screen->cursor_row >= toprow + topline + && screen->cursor_row <= maxrow + topline) + screen->cursor_state = OFF; + + for (row = toprow; row <= maxrow; y += FontHeight(screen), row++) { +#if OPT_ISO_COLORS +#if OPT_EXT_COLORS + Char *fbf = 0; + Char *fbb = 0; +#define ColorOf(col) (unsigned) ((fbf[col] << 8) | fbb[col]) +#else + Char *fb = 0; +#define ColorOf(col) (unsigned) (fb[col]) +#endif +#endif +#if OPT_DEC_CHRSET + Char *cb = 0; +#endif +#if OPT_WIDE_CHARS + int wideness = 0; + Char *widec = 0; +#define WIDEC_PTR(cell) widec ? &widec[cell] : 0 +#define BLANK_CEL(cell) ((chars[cell] == ' ') && (widec == 0 || widec[cell] == 0)) +#else +#define BLANK_CEL(cell) (chars[cell] == ' ') +#endif + Char cs = 0; + Char *chars; + Char *attrs; + int col = leftcol; + int maxcol = leftcol + ncols - 1; + int hi_col = maxcol; + int lastind; + unsigned flags; + unsigned test; + unsigned fg_bg = 0, fg = 0, bg = 0; + int x; + GC gc; + Bool hilite; + + if (row < screen->top_marg || row > screen->bot_marg) + lastind = row; + else + lastind = row - scrollamt; + + TRACE(("ScrnRefresh row=%d lastind=%d/%d\n", row, lastind, max)); + if (lastind < 0 || lastind > max) + continue; + + chars = SCRN_BUF_CHARS(screen, lastind + topline); + attrs = SCRN_BUF_ATTRS(screen, lastind + topline); + + if_OPT_DEC_CHRSET({ + cb = SCRN_BUF_CSETS(screen, lastind + topline); + }); + + if_OPT_WIDE_CHARS(screen, { + widec = SCRN_BUF_WIDEC(screen, lastind + topline); + }); + + 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] | (widec[leftcol] << 8)) == HIDDEN_CHAR && + iswide(chars[leftcol - 1] | (widec[leftcol - 1] << 8))) { + leftcol--; + ncols++; + col = leftcol; + } + } else { + fprintf(stderr, "This should not happen. Why is it so?\n"); + } + }); + + if (row < screen->startHRow || row > screen->endHRow || + (row == screen->startHRow && maxcol < screen->startHCol) || + (row == screen->endHRow && col >= screen->endHCol)) { +#if OPT_DEC_CHRSET + /* + * Temporarily change dimensions to double-sized characters so + * we can reuse the recursion on this function. + */ + if (CSET_DOUBLE(*cb)) { + 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(*cb)) { + col *= 2; + maxcol *= 2; + } +#endif + hilite = False; + } else { + /* row intersects selection; split into pieces of single type */ + if (row == screen->startHRow && col < screen->startHCol) { + recurse++; + ScrnRefresh(screen, row, col, 1, screen->startHCol - col, + force); + col = screen->startHCol; + } + if (row == screen->endHRow && maxcol >= screen->endHCol) { + recurse++; + ScrnRefresh(screen, row, screen->endHCol, 1, + maxcol - screen->endHCol + 1, force); + maxcol = screen->endHCol - 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(*cb)) { + col /= 2; + maxcol /= 2; + } + cs = cb[col]; + }); + + flags = attrs[col]; +#if OPT_WIDE_CHARS + if (widec) + wideness = iswide(chars[col] | (widec[col] << 8)); + else + wideness = 0; +#endif + if_OPT_EXT_COLORS(screen, { + fbf = SCRN_BUF_FGRND(screen, lastind + topline); + fbb = SCRN_BUF_BGRND(screen, lastind + topline); + fg_bg = ColorOf(col); + /* this combines them, then splits them again. but + extract_fg does more, so seems reasonable */ + fg = extract_fg(fg_bg, flags); + bg = extract_bg(fg_bg, flags); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fb = SCRN_BUF_COLOR(screen, lastind + topline); + fg_bg = ColorOf(col); + fg = extract_fg(fg_bg, flags); + bg = extract_bg(fg_bg, flags); + }); + + gc = updatedXtermGC(screen, flags, fg_bg, hilite); + gc_changes |= (flags & (FG_COLOR | BG_COLOR)); + + x = CurCursorX(screen, row + topline, col); + lastind = col; + + for (; col <= maxcol; col++) { + if ((attrs[col] != flags) + || (hilite && (col > hi_col)) +#if OPT_ISO_COLORS + || ((flags & FG_COLOR) + && (extract_fg(ColorOf(col), attrs[col]) != fg)) + || ((flags & BG_COLOR) + && (extract_bg(ColorOf(col), attrs[col]) != bg)) +#endif +#if OPT_WIDE_CHARS + || (widec + && ((iswide(chars[col] | (widec[col] << 8))) != wideness) + && !((chars[col] | (widec[col] << 8)) == HIDDEN_CHAR)) +#endif +#if OPT_DEC_CHRSET + || (cb[col] != cs) +#endif + ) { + assert(col >= lastind); + TRACE(("ScrnRefresh looping drawXtermText %d..%d:%s\n", + lastind, col, + visibleChars(PAIRED_CHARS(&chars[lastind], + WIDEC_PTR(lastind)), + (unsigned) (col - lastind)))); + + test = flags; + checkVeryBoldColors(test, fg); + + x = drawXtermText(screen, test & DRAWX_MASK, gc, x, y, + cs, + PAIRED_CHARS(&chars[lastind], WIDEC_PTR(lastind)), + (unsigned) (col - lastind), 0); + + if_OPT_WIDE_CHARS(screen, { + int i; + Char *comb1l = BUF_COM1L(screen->visbuf, row + topline); + Char *comb2l = BUF_COM2L(screen->visbuf, row + topline); + Char *comb1h = BUF_COM1H(screen->visbuf, row + topline); + Char *comb2h = BUF_COM2H(screen->visbuf, row + topline); + for (i = lastind; i < col; i++) { + int my_x = CurCursorX(screen, row + topline, i); + int base = chars[i] | (widec[i] << 8); + int comb1 = comb1l[i] | (comb1h[i] << 8); + int comb2 = comb2l[i] | (comb2h[i] << 8); + + if (iswide(base)) + my_x = CurCursorX(screen, row + topline, i - 1); + + if (comb1 != 0) { + drawXtermText(screen, (test & DRAWX_MASK) + | NOBACKGROUND, gc, my_x, y, cs, + PAIRED_CHARS(comb1l + i, comb1h + i), + 1, iswide(base)); + } + + if (comb2 != 0) { + drawXtermText(screen, (test & DRAWX_MASK) + | NOBACKGROUND, gc, my_x, y, cs, + PAIRED_CHARS(comb2l + i, comb2h + i), + 1, iswide(base)); + } + } + }); + + resetXtermGC(screen, flags, hilite); + + lastind = col; + + if (hilite && (col > hi_col)) + hilite = False; + + flags = attrs[col]; + if_OPT_EXT_COLORS(screen, { + fg_bg = ColorOf(col); + fg = extract_fg(fg_bg, flags); + bg = extract_bg(fg_bg, flags); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + fg_bg = ColorOf(col); + fg = extract_fg(fg_bg, flags); + bg = extract_bg(fg_bg, flags); + }); + if_OPT_DEC_CHRSET({ + cs = cb[col]; + }); +#if OPT_WIDE_CHARS + if (widec) + wideness = iswide(chars[col] | (widec[col] << 8)); +#endif + + gc = updatedXtermGC(screen, flags, fg_bg, hilite); + gc_changes |= (flags & (FG_COLOR | BG_COLOR)); + } + + if (chars[col] == 0) { +#if OPT_WIDE_CHARS + if (widec == 0 || widec[col] == 0) +#endif + chars[col] = ' '; + } + } + + assert(col >= lastind); + TRACE(("ScrnRefresh calling drawXtermText %d..%d:%s\n", + lastind, col, + visibleChars(PAIRED_CHARS(&chars[lastind], WIDEC_PTR(lastind)), + (unsigned) (col - lastind)))); + + test = flags; + checkVeryBoldColors(test, fg); + + drawXtermText(screen, test & DRAWX_MASK, gc, x, y, + cs, + PAIRED_CHARS(&chars[lastind], WIDEC_PTR(lastind)), + (unsigned) (col - lastind), 0); + + if_OPT_WIDE_CHARS(screen, { + int i; + Char *comb1l = BUF_COM1L(screen->visbuf, row + topline); + Char *comb2l = BUF_COM2L(screen->visbuf, row + topline); + Char *comb1h = BUF_COM1H(screen->visbuf, row + topline); + Char *comb2h = BUF_COM2H(screen->visbuf, row + topline); + for (i = lastind; i < col; i++) { + int my_x = CurCursorX(screen, row + topline, i); + int base = chars[i] | (widec[i] << 8); + int comb1 = comb1l[i] | (comb1h[i] << 8); + int comb2 = comb2l[i] | (comb2h[i] << 8); + + if (iswide(base)) + my_x = CurCursorX(screen, row + topline, i - 1); + + if (comb1 != 0) { + drawXtermText(screen, (test & DRAWX_MASK) | + NOBACKGROUND, gc, my_x, y, cs, + PAIRED_CHARS(comb1l + i, comb1h + i), + 1, iswide(base)); + } + + if (comb2 != 0) { + drawXtermText(screen, (test & DRAWX_MASK) | + NOBACKGROUND, gc, my_x, y, cs, + PAIRED_CHARS(comb2l + i, comb2h + i), + 1, iswide(base)); + } + } + }); + + resetXtermGC(screen, 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(term->cur_foreground); + if (gc_changes & BG_COLOR) + SGR_Background(term->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 = term->core.width; + ts.ws_ypixel = term->core.height; + SET_TTYSIZE(screen->respond, ts); + } +#endif + recurse--; +} + +/* + * 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(TScreen * screen, + int toprow, + int leftcol, + int nrows, + int ncols, + Bool force) /* ... leading/trailing spaces */ +{ + if (ScrnHaveSelection(screen) + && (toprow <= screen->endHRow) + && (toprow + nrows - 1 >= screen->startHRow)) { + ScrnDisownSelection(screen); + } + ScrnRefresh(screen, 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(TScreen * screen, + int first, + int last) +{ + ScrnBuf buf = screen->visbuf; + unsigned len = MaxCols(screen); + int row; + int flags = TERM_COLOR_FLAGS(term); + + TRACE(("ClearBufRows %d..%d\n", first, last)); + for (row = first; row <= last; row++) { + ScrnClrWrapped(screen, row); + bzero(BUF_CHARS(buf, row), len); + memset(BUF_ATTRS(buf, row), flags, len); + if_OPT_EXT_COLORS(screen, { + memset(BUF_FGRND(buf, row), term->sgr_foreground, len); + memset(BUF_BGRND(buf, row), term->cur_background, len); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + memset(BUF_COLOR(buf, row), xtermColorPair(), len); + }); + if_OPT_DEC_CHRSET({ + memset(BUF_CSETS(buf, row), 0, len); + }); + if_OPT_WIDE_CHARS(screen, { + memset(BUF_WIDEC(buf, row), 0, len); + memset(BUF_COM1L(buf, row), 0, len); + memset(BUF_COM1H(buf, row), 0, len); + memset(BUF_COM2L(buf, row), 0, len); + memset(BUF_COM2H(buf, row), 0, len); + }); + } +} + +/* + 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(TScreen * screen, + int width, + int height, + unsigned *flags) +{ + int code, rows, cols; + int border = 2 * screen->border; + int move_down_by; +#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); + + /* clear the right and bottom internal border because of NorthWest + gravity might have left junk on the right and bottom edges */ + if (width >= FullWidth(screen)) { + XClearArea(screen->display, tw, + FullWidth(screen), 0, /* right edge */ + 0, (unsigned) height, /* from top to bottom */ + False); + } + if (height >= 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 savelines = (screen->scrollWidget + ? screen->savelines + : 0); + int delta_rows = rows - MaxRows(screen); + + TRACE(("...ScreenResize chars %dx%d\n", rows, cols)); + + if (screen->cursor_state) + HideCursor(); + if (screen->alternate + && term->misc.resizeGravity == SouthWestGravity) + /* swap buffer pointers back to make all this hair work */ + SwitchBufPtrs(screen); + if (screen->altbuf) + (void) Reallocate(&screen->altbuf, + &screen->abuf_address, + rows, + cols, + MaxRows(screen), + MaxCols(screen)); + move_down_by = Reallocate(&screen->allbuf, + &screen->sbuf_address, + rows + savelines, cols, + MaxRows(screen) + savelines, + MaxCols(screen)); + screen->visbuf = &screen->allbuf[MAX_PTRS * savelines]; + + set_max_row(screen, screen->max_row + delta_rows); + set_max_col(screen, cols - 1); + + if (term->misc.resizeGravity == SouthWestGravity) { + 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->cursor_row += move_down_by; + ScrollSelection(screen, move_down_by, True); + + if (screen->alternate) + SwitchBufPtrs(screen); /* put the pointers back */ + } + + /* adjust scrolling region */ + set_tb_margins(screen, 0, screen->max_row); + *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 = height; + screen->fullVwin.fullwidth = width; + + if (screen->scrollWidget) + ResizeScrollBar(term); + + 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 = + screen->iconVwin.width + 2 * term->misc.icon_border_width; + changes.height = screen->iconVwin.fullheight = + screen->iconVwin.height + 2 * term->misc.icon_border_width; + changes.border_width = term->misc.icon_border_width; + + TRACE(("resizing icon window %dx%d\n", changes.height, changes.width)); + XConfigureWindow(XtDisplay(term), screen->iconVwin.window, + CWWidth | CWHeight | CWBorderWidth, &changes); + } +#endif /* NO_ACTIVE_ICON */ + +#ifdef TTYSIZE_STRUCT + /* Set tty's idea of window size */ + TTYSIZE_ROWS(ts) = rows; + TTYSIZE_COLS(ts) = cols; +#ifdef USE_STRUCT_WINSIZE + ts.ws_xpixel = width; + ts.ws_ypixel = 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(ScrnBuf sb, + int row, + int col, + int len) +{ + int i; + Char *ptr = BUF_CHARS(sb, row); + + for (i = col; i < len; i++) { + if (ptr[i]) + return True; + } + + if_OPT_WIDE_CHARS((&(term->screen)), { + if ((ptr = BUF_WIDEC(sb, row)) != 0) { + for (i = col; i < len; i++) { + if (ptr[i]) + return True; + } + } + }); + + return False; +} + +/* + * Copy the rectangle boundaries into a struct, providing default values as + * needed. + */ +void +xtermParseRect(TScreen * screen, int nparams, int *params, XTermRect * target) +{ + memset(target, 0, sizeof(*target)); + target->top = (nparams > 0) ? params[0] : getMinRow(screen) + 1; + target->left = (nparams > 1) ? params[1] : getMinCol(screen) + 1; + target->bottom = (nparams > 2) ? params[2] : getMaxRow(screen) + 1; + target->right = (nparams > 3) ? params[3] : getMaxCol(screen) + 1; + TRACE(("parsed rectangle %d,%d %d,%d\n", + target->top, + target->left, + target->bottom, + target->right)); +} + +static Bool +validRect(TScreen * screen, XTermRect * target) +{ + TRACE(("comparing against screensize %dx%d\n", + getMaxRow(screen) + 1, + getMaxCol(screen) + 1)); + return (target != 0 + && target->top > getMinRow(screen) + && target->left > getMinCol(screen) + && target->top <= target->bottom + && target->left <= target->right + && target->top <= getMaxRow(screen) + 1 + && target->right <= getMaxCol(screen) + 1); +} + +/* + * Fills a rectangle with the given character and video-attributes. + */ +void +ScrnFillRectangle(TScreen * screen, XTermRect * target, int value, unsigned flags) +{ + TRACE(("filling rectangle with '%c'\n", value)); + if (validRect(screen, target)) { + unsigned left = target->left - 1; + unsigned size = target->right - left; + Char attrs = flags; + int row; + + attrs &= ATTRIBUTES; + attrs |= CHARDRAWN; + for (row = target->bottom - 1; row >= (target->top - 1); row--) { + TRACE(("filling %d [%d..%d]\n", row, left + 1, left + size)); + memset(SCRN_BUF_ATTRS(screen, row) + left, attrs, size); + memset(SCRN_BUF_CHARS(screen, row) + left, (Char) value, size); + if_OPT_WIDE_CHARS(screen, { + bzero(SCRN_BUF_WIDEC(screen, row) + left, size); + }); + } + ScrnUpdate(screen, + 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(TScreen * screen, XTermRect * source, int nparam, int *params) +{ + TRACE(("copying rectangle\n")); + + if (validRect(screen, source)) { + XTermRect target; + xtermParseRect(screen, + ((nparam > 3) ? 2 : (nparam - 1)), + params + 1, + &target); + if (validRect(screen, &target)) { + unsigned high = (source->bottom - source->top) + 1; + unsigned wide = (source->right - source->left) + 1; + unsigned size = (high * wide); + int row, col, n; + + Char *attrs = TypeMallocN(Char, size); + Char *chars = TypeMallocN(Char, size); + +#if OPT_WIDE_CHARS + Char *widec = TypeMallocN(Char, size); + if (widec == 0) + return; +#endif + if (attrs == 0 + || chars == 0) + return; + + TRACE(("OK - make copy %dx%d\n", high, wide)); + target.bottom = target.top + (high - 1); + target.right = target.left + (wide - 1); + + for (row = source->top - 1; row < source->bottom; ++row) { + for (col = source->left - 1; col < source->right; ++col) { + n = ((1 + row - source->top) * wide) + (1 + col - source->left); + attrs[n] = SCRN_BUF_ATTRS(screen, row)[col] | CHARDRAWN; + chars[n] = SCRN_BUF_CHARS(screen, row)[col]; + if_OPT_WIDE_CHARS(screen, { + widec[n] = SCRN_BUF_WIDEC(screen, row)[col]; + }) + } + } + for (row = target.top - 1; row < target.bottom; ++row) { + for (col = target.left - 1; col < target.right; ++col) { + if (row >= getMinRow(screen) + && row <= getMaxRow(screen) + && col >= getMinCol(screen) + && col <= getMaxCol(screen)) { + n = ((1 + row - target.top) * wide) + (1 + col - target.left); + SCRN_BUF_ATTRS(screen, row)[col] = attrs[n]; + SCRN_BUF_CHARS(screen, row)[col] = chars[n]; + if_OPT_WIDE_CHARS(screen, { + SCRN_BUF_WIDEC(screen, row)[col] = widec[n]; + }) + } + } + } + free(attrs); + free(chars); +#if OPT_WIDE_CHARS + free(widec); +#endif + + ScrnUpdate(screen, + (target.top - 1), + (target.left - 1), + (target.bottom - target.top) + 1, + ((target.right - target.left) + 1), + False); + } + } +} + +/* + * Modifies the video-attributes only - so selection is unaffected. + */ +void +ScrnMarkRectangle(TScreen * screen, + XTermRect * target, + Bool reverse, + int nparam, + int *params) +{ + Bool exact = (screen->cur_decsace == 2); + + TRACE(("%s %s\n", + reverse ? "reversing" : "marking", + (exact + ? "rectangle" + : "region"))); + + if (validRect(screen, target)) { + 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)); + + TRACE(("marking %d [%d..%d]\n", row, left + 1, right + 1)); + for (col = left; col <= right; ++col) { + unsigned flags = SCRN_BUF_ATTRS(screen, row)[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; + } + } else { + switch (params[n]) { + case 0: + 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 22: + flags &= ~BOLD; + break; + case 24: + flags &= ~UNDERLINE; + break; + case 25: + flags &= ~BLINK; + break; + case 27: + flags &= ~INVERSE; + break; + } + } + } +#if OPT_TRACE + if (row == top && col == left) + TRACE(("first mask-change is %#x\n", + SCRN_BUF_ATTRS(screen, row)[col] ^ flags)); +#endif + SCRN_BUF_ATTRS(screen, row)[col] = flags; + } + } + ScrnRefresh(screen, + (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 are untouched. + */ +void +ScrnWipeRectangle(TScreen * screen, + XTermRect * target) +{ + TRACE(("wiping rectangle\n")); + + if (validRect(screen, target)) { + 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 + 1, right + 1)); + for (col = left; col <= right; ++col) { + if (!((screen->protected_mode == DEC_PROTECT) + && (SCRN_BUF_ATTRS(screen, row)[col] & PROTECTED))) { + SCRN_BUF_ATTRS(screen, row)[col] |= CHARDRAWN; + SCRN_BUF_CHARS(screen, row)[col] = ' '; + if_OPT_WIDE_CHARS(screen, { + SCRN_BUF_WIDEC(screen, row)[col] = '\0'; + }) + } + } + } + ScrnUpdate(screen, + (target->top - 1), + (target->left - 1), + (target->bottom - target->top) + 1, + ((target->right - target->left) + 1), + False); + } +} +#endif /* OPT_DEC_RECTOPS */ diff --git a/nx-X11/programs/xterm/scrollbar.c b/nx-X11/programs/xterm/scrollbar.c new file mode 100644 index 000000000..6dccf6e56 --- /dev/null +++ b/nx-X11/programs/xterm/scrollbar.c @@ -0,0 +1,682 @@ +/* $XTermId: scrollbar.c,v 1.116 2005/11/03 13:17:28 tom Exp $ */ + +/* + * $Xorg: scrollbar.c,v 1.4 2000/08/17 19:55:09 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/scrollbar.c,v 3.45 2005/11/03 13:17:28 dickey Exp $ */ + +/* + * Copyright 2000-2004,2005 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 + +#include + +#if defined(HAVE_LIB_XAW) +#include +#elif defined(HAVE_LIB_XAW3D) +#include +#elif defined(HAVE_LIB_NEXTAW) +#include +#elif defined(HAVE_LIB_XAWPLUS) +#include +#endif + +#include +#include +#include +#include + +/* + * 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) ((xw)->screen.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 = &xw->screen; + + int border = 2 * xw->screen.border; + int min_wide = border + xw->screen.fullVwin.sb_info.width; + int min_high = border; +#if 1 /* ndef nothack */ + XSizeHints sizehints; + long supp; +#endif + XtGeometryResult geomreqresult; + Dimension reqWidth, reqHeight, repWidth, repHeight; +#ifndef NO_ACTIVE_ICON + struct _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); + if (!XGetWMNormalHints(screen->display, XtWindow(SHELL_OF(xw)), + &sizehints, &supp)) + bzero(&sizehints, sizeof(sizehints)); + + xtermSizeHints(xw, &sizehints, ScrollbarWidth(screen)); + + /* These are obsolete, but old clients may use them */ + sizehints.width = MaxCols(screen) * FontWidth(screen) + sizehints.min_width; + sizehints.height = MaxRows(screen) * FontHeight(screen) + sizehints.min_height; +#endif + + XSetWMNormalHints(screen->display, XtWindow(SHELL_OF(xw)), &sizehints); + + reqWidth = MaxCols(screen) * FontWidth(screen) + min_wide; + reqHeight = MaxRows(screen) * FontHeight(screen) + min_high; + + TRACE(("...requesting screensize chars %dx%d, pixels %dx%d\n", + MaxRows(screen), + MaxCols(screen), + reqHeight, reqWidth)); + + geomreqresult = XtMakeResizeRequest((Widget) xw, reqWidth, reqHeight, + &repWidth, &repHeight); + TRACE(("scrollbar.c XtMakeResizeRequest %dx%d -> %dx%d (status %d)\n", + reqHeight, reqWidth, + repHeight, repWidth, + geomreqresult)); + + if (geomreqresult == XtGeometryAlmost) { + TRACE(("...almost, retry screensize %dx%d\n", repHeight, repWidth)); + geomreqresult = XtMakeResizeRequest((Widget) xw, repWidth, + repHeight, NULL, NULL); + } +#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 (sizehints.flags + && repHeight + && repWidth) { + sizehints.height = repHeight; + sizehints.width = repWidth; + TRACE_HINTS(&sizehints); + XSetWMNormalHints(screen->display, VShellWindow, &sizehints); + } +#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) +{ + SbInfo *sb = &(term->screen.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) +{ + TScreen *screen = &term->screen; + int thumbTop, thumbHeight, totalHeight; + + thumbTop = screen->topline + screen->savedlines; + thumbHeight = MaxRows(screen); + totalHeight = thumbHeight + screen->savedlines; + + XawScrollbarSetThumb(scrollWidget, + ((float) thumbTop) / totalHeight, + ((float) thumbHeight) / totalHeight); +} + +void +ResizeScrollBar(XtermWidget xw) +{ + TScreen *screen = &(xw->screen); + + int height = screen->fullVwin.height + screen->border * 2; + int width = screen->scrollWidget->core.width; + int ypos = -ScrollBarBorder(xw); +#ifdef SCROLLBAR_RIGHT + int xpos = ((term->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, + xpos, + ypos, + width, + height, + BorderWidth(screen->scrollWidget)); + ScrollBarDrawThumb(screen->scrollWidget); +} + +void +WindowScroll(TScreen * screen, int top) +{ + int i, lines; + int scrolltop, scrollheight, refreshtop; + + if (top < -screen->savedlines) + top = -screen->savedlines; + else if (top > 0) + top = 0; + if ((i = screen->topline - top) == 0) { + ScrollBarDrawThumb(screen->scrollWidget); + return; + } + + 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(screen, 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(screen, refreshtop, 0, lines, MaxCols(screen), False); + + 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 = &xw->screen; + + 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, int init, int doalloc) +{ + TScreen *screen = &xw->screen; + int i, j, k; + + if (screen->fullVwin.sb_info.width || IsIcon(screen)) + return; + + TRACE(("ScrollBarOn\n")); + 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(XkbBI_MinorError, 0); + } + } + } else if (!screen->scrollWidget || !XtIsRealized((Widget) term)) { + Bell(XkbBI_MinorError, 0); + Bell(XkbBI_MinorError, 0); + } else { + + if (doalloc && screen->allbuf) { + /* FIXME: this is not integrated well with Allocate */ + if ((screen->allbuf = + TypeRealloc(ScrnPtr, + MAX_PTRS * (screen->max_row + 2 + screen->savelines), + screen->visbuf)) == NULL) { + SysError(ERROR_SBRALLOC); + } + screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; + memmove((char *) screen->visbuf, (char *) screen->allbuf, + MAX_PTRS * (screen->max_row + 2) * sizeof(char *)); + for (i = k = 0; i < screen->savelines; i++) { + k += BUF_HEAD; + for (j = BUF_HEAD; j < MAX_PTRS; j++) { + if ((screen->allbuf[k++] = + TypeCallocN(Char, (unsigned) MaxCols(screen)) + ) == NULL) + SysError(ERROR_SBRALLOC2); + } + } + } + + 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(term); +#endif + + XtMapWidget(screen->scrollWidget); + update_scrollbar(); + if (screen->visbuf) { + XClearWindow(screen->display, XtWindow(term)); + Redraw(); + } + } +} + +void +ScrollBarOff(TScreen * screen) +{ + if (!screen->fullVwin.sb_info.width || IsIcon(screen)) + return; + + TRACE(("ScrollBarOff\n")); + if (XtIsRealized((Widget) term)) { + XtUnmapWidget(screen->scrollWidget); + screen->fullVwin.sb_info.width = 0; + DoResizeScreen(term); + update_scrollbar(); + if (screen->visbuf) { + XClearWindow(screen->display, XtWindow(term)); + Redraw(); + } + } else { + Bell(XkbBI_MinorError, 0); + } +} + +/* + * Toggle the visibility of the scrollbars. + */ +void +ToggleScrollBar(XtermWidget w) +{ + TScreen *screen = &w->screen; + + if (IsIcon(screen)) { + Bell(XkbBI_MinorError, 0); + } else { + TRACE(("ToggleScrollBar{{\n")); + if (screen->fullVwin.sb_info.width) { + ScrollBarOff(screen); + } else { + ScrollBarOn(w, FALSE, FALSE); + } + update_scrollbar(); + TRACE(("...ToggleScrollBar}}\n")); + } +} + +/*ARGSUSED*/ +static void +ScrollTextTo( + Widget scrollbarWidget GCC_UNUSED, + XtPointer client_data GCC_UNUSED, + XtPointer call_data) +{ + float *topPercent = (float *) call_data; + TScreen *screen = &term->screen; + int thumbTop; /* relative to first saved line */ + int newTopLine; + + /* + * screen->savedlines : Number of offscreen text lines, + * MaxRows(screen) : Number of onscreen text lines, + * screen->topline : -Number of lines above the last screen->max_row+1 lines + */ + + thumbTop = (int) (*topPercent * (screen->savedlines + MaxRows(screen))); + newTopLine = thumbTop - screen->savedlines; + WindowScroll(screen, newTopLine); +} + +/*ARGSUSED*/ +static void +ScrollTextUpDownBy( + Widget scrollbarWidget GCC_UNUSED, + XtPointer client_data GCC_UNUSED, + XtPointer call_data) +{ + long pixels = (long) call_data; + + TScreen *screen = &term->screen; + int rowOnScreen, newTopLine; + + rowOnScreen = pixels / FontHeight(screen); + if (rowOnScreen == 0) { + if (pixels < 0) + rowOnScreen = -1; + else if (pixels > 0) + rowOnScreen = 1; + } + newTopLine = screen->topline + rowOnScreen; + WindowScroll(screen, newTopLine); +} + +/* + * assume that b is lower case and allow plural + */ +static int +specialcmplowerwiths(char *a, char *b, int *modifier) +{ + char ca, cb; + + *modifier = 0; + if (!a || !b) + return 0; + + while (1) { + ca = char2lower(*a); + cb = *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); + return 1; + + case '\0': + return 1; + + default: + return 0; + } +} + +static long +params_to_pixels(TScreen * screen, String * params, Cardinal n) +{ + int mult = 1; + char *s; + int modifier; + + switch (n > 2 ? 2 : n) { + case 2: + s = params[1]; + if (specialcmplowerwiths(s, "page", &modifier)) { + mult = (MaxRows(screen) + modifier) * FontHeight(screen); + } else if (specialcmplowerwiths(s, "halfpage", &modifier)) { + mult = ((MaxRows(screen) + modifier) * FontHeight(screen)) / 2; + } else if (specialcmplowerwiths(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 gw, String * params, Cardinal nparams) +{ + if (gw != 0) { + if (IsXtermWidget(gw)) { + TScreen *screen = &((XtermWidget) gw)->screen; + if (nparams > 2 + && screen->send_mouse_pos != MOUSE_OFF) + return 0; + return params_to_pixels(screen, params, nparams); + } else { + /* + * This may have been the scrollbar widget. Try its parent, which + * would be the VT100 widget. + */ + return AmountToScroll(XtParent(gw), params, nparams); + } + } + return 0; +} + +/*ARGSUSED*/ +void +HandleScrollForward( + Widget gw, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *nparams) +{ + long amount; + + if ((amount = AmountToScroll(gw, params, *nparams)) != 0) { + ScrollTextUpDownBy(gw, (XtPointer) 0, (XtPointer) amount); + } +} + +/*ARGSUSED*/ +void +HandleScrollBack( + Widget gw, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *nparams) +{ + long amount; + + if ((amount = -AmountToScroll(gw, params, *nparams)) != 0) { + ScrollTextUpDownBy(gw, (XtPointer) 0, (XtPointer) amount); + } +} diff --git a/nx-X11/programs/xterm/sinstall.sh b/nx-X11/programs/xterm/sinstall.sh new file mode 100644 index 000000000..85bca69e3 --- /dev/null +++ b/nx-X11/programs/xterm/sinstall.sh @@ -0,0 +1,156 @@ +#!/bin/sh +# $XTermId: sinstall.sh,v 1.13 2005/11/03 13:17:28 tom Exp $ +# $XFree86: xc/programs/xterm/sinstall.sh,v 1.4 2005/11/03 13:17:28 dickey Exp $ +# +# 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 + +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 >$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 >$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 + PROG_SUID=4000 + PROG_SGID=2000 + ;; + .???s*) #(vi + PROG_SUID=4000 + PROG_GRP= + ;; + .??????s*) + 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/--[sxt]/1/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/nx-X11/programs/xterm/tabs.c b/nx-X11/programs/xterm/tabs.c new file mode 100644 index 000000000..cfe91a0c3 --- /dev/null +++ b/nx-X11/programs/xterm/tabs.c @@ -0,0 +1,182 @@ +/* + * $XFree86: xc/programs/xterm/tabs.c,v 3.12 2005/04/22 00:21:54 dickey Exp $ + */ + +/* $Xorg: tabs.c,v 1.3 2000/08/17 19:55:09 cpqbld Exp $ */ + +/* + * Copyright 2000-2002,2005 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 +#include + +/* + * This file presumes 32bits/word. This is somewhat of a crock, and should + * be fixed sometime. + */ +#define TAB_INDEX(n) ((n) >> 5) +#define TAB_MASK(n) (1 << ((n) & (TAB_BITS_WIDTH-1))) + +#define SET_TAB(tabs,n) tabs[TAB_INDEX(n)] |= TAB_MASK(n) +#define CLR_TAB(tabs,n) tabs[TAB_INDEX(n)] &= ~TAB_MASK(n) +#define TST_TAB(tabs,n) tabs[TAB_INDEX(n)] & TAB_MASK(n) + +/* + * places tabstops at only every 8 columns + */ +void +TabReset(Tabs tabs) +{ + int i; + + for (i = 0; i < TAB_ARRAY_SIZE; ++i) + tabs[i] = 0; + + for (i = 0; i < MAX_TABS; i += 8) + TabSet(tabs, i); +} + +/* + * places a tabstop at col + */ +void +TabSet(Tabs tabs, int col) +{ + SET_TAB(tabs, col); +} + +/* + * clears a tabstop at col + */ +void +TabClear(Tabs tabs, int col) +{ + 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(TScreen * screen, Tabs tabs, int col) +{ + if (screen->curses && screen->do_wrap && (term->flags & WRAPAROUND)) { + xtermIndex(screen, 1); + set_cur_col(screen, 0); + col = screen->do_wrap = 0; + } + 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 (TST_TAB(tabs, col)) + return (col); + + return (0); +} + +/* + * Tab to the next stop, returning true if the cursor moved + */ +Bool +TabToNextStop(TScreen * screen) +{ + int saved_column = screen->cur_col; + int next = TabNext(screen, term->tabs, screen->cur_col); + int max = CurMaxCol(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(TScreen * screen) +{ + int saved_column = screen->cur_col; + + set_cur_col(screen, TabPrev(term->tabs, screen->cur_col)); + + return (screen->cur_col < saved_column); +} + +/* + * clears all tabs + */ +void +TabZonk(Tabs tabs) +{ + int i; + + for (i = 0; i < TAB_ARRAY_SIZE; ++i) + tabs[i] = 0; +} diff --git a/nx-X11/programs/xterm/tektests/aitest.tek b/nx-X11/programs/xterm/tektests/aitest.tek new file mode 100644 index 000000000..254c4ec5c --- /dev/null +++ b/nx-X11/programs/xterm/tektests/aitest.tek @@ -0,0 +1 @@ + 1,`g ],`g?C3`t0@$`z0@,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`/L3ga/M3gc/O3je/Q3ng/S3ni/U3nk/W3bn/Y3cp/[3cr/]3`t0@,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@,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@,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`0T3ea0R3ec0P3je0N3ng0L3ni0J3nk0H3bn0F3ap0D3ar0B3`t0@,ag*O,aj*O,am*O,bp*O,bs*O,gv*O,dy*P,e|*P,f*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@,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*R*m|*S*oy*S*nv*T*ms*U*lp*V*om*V*nj*W*mg*X*ae*Y*ab*Z)a*[)a|*\)ay*])ev*^)fs*_)gp+@)hm+B)ij+C)ng+D)od+E)ab+G(c+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/S$o}/W$o{/[$`z0@,cg5P,cd5P,ca5P+b~5P+b{5P+mw5P+lt5P+oq5O+nn5O+lk5O+oh5N+me5N+ob5M*m5M*o|5L*my5L*nv5K*os5J*lp5J*mm5I*nj5H*og5G*ce5F*cb5E)c5D)c|5C)cy5B)gv5A)fs5@)ep4_)hm4^)kj4\)ng4[)md4Z)cb4X(a4W(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$i0L$m}0H$m{0D$`z0@,cg5P,cj5P,cm5P,bp5P,bs5P,ev5P,dy5P,g|5O,f5O-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@,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(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-]3ka.B3dc.H3ae.M3cg.R3lh.X3jj.]3dl/C3om/H3jo/N3aq/T3hr/Z3`t0@,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(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,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@,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)c7T)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%g3H%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@,bg8E,ej8E,em8E,hp8E,ls8E,nv8D,az8D,g}8C-f`8C-kc8B-if8B-ni8A-cm8@-`p8@-es7_-ev7^-iy7]-i|7\-m7[.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}2G2i2B3ia1]3dc1X3ce1R3ag1M3lh1H3jj1B3dl0]3mm0W3jo0Q3cq0K3hr0F3`t0@,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'E0kb'H0ie'L0jh'O0hk'S0jn'V0eq'Z0dt'^0cw(A0oy(E0o|(I0k(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@,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'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+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@,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'j8I'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[%j4U%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@,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]/j8Z0ib8W0ke8S0jh8P0hk8M0jn8I0gq8E0dt8B0aw7^0my7Z0m|7V0i7R1eb7N1`e7J1ng7E1ej7A1cm6\1io6X1fr6S1ot6N1dw6J1ly6E1d|6@1h~5[2`a5V2gc5P2ne5K2`h5F2fj5@2dl4[2jn4U2op4O2lr4J2mt4D2mv3^2mx3X2mz3R2h|3L2k~3E3f`2_3ab2Y3oc2R3ee2L3cg2E3hh1_3aj1X3jk1Q3nl1J3cn1C3ko0\3np0U3nq0N3as0G3`t0@,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%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@,ag#@,ec#@+n#@+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$O(c|$R(ix$V(gu$Y(ar$](ln%A(kk%D(gh%H(ge%L(`b%Q'a%U'n{%Y'lx%^'nu&B'lr&G'oo&K'cm&P'cj&U'gg&Z'kd&_'ha'E&a'J&g|'O&iy'U&cw'Z&ft(@&mq(F&eo(L&`m(R&ij(X&eh(^&ne)D&kc)J&ia)Q%g)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.H$h~.P$k}.W$o|._$c|/G$g{/O$hz/X$`z0@,cg<_,gc<_+n<_+a|<_+dx<_+jt<^+cq<]+dm<]+ii<\+af<[+eb_+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(`=R(i{=N(nw=J(bt=F(ip=B(`m<^(ji_-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=_/jc=\/ig=Y/gk=U/`o=R/ir=N/fv=J/bz=F/i}=B0`a<^0jdY180*ji=Q7bd=Q7bg=B200*hi;[7`d;[7`g;L220*ji:D7bd:D7bg9U240*hi8N7`d8N7`g7_260*ki6W7cd6W7cg6H280*ii5A7ad5A7ag4R300*ki3J7cd3J7cg2[320*ii1T7ad1T7ag1E340*hi/^7`d/^7`g/O 0*ki.G7cd.G7cg-X20*ii,Q7ad,Q7ag,B40*ki*Z7cd*Z7cg*K60*ii)D7ad)D7ag(U80*hi'N7`d'N7`g&_100*ji%W7bd%W7bg%H120*hi$A7`d$A7`g#R140*ji"J7bd"J7bg![160*hi T7`d T7`g E1800d.BP0f|4@0fh1PP+200f|4@1ga4@1kf4@1kk4@1lp4A1cv4@1g{4@2j`4@2me4@2dk4@2kp3_2av3_2k{3^3da3^3bg3]3nl3\3or3[3ox3Z3n~3Y4ae3X4hk3W4ar3U4ox3S4k3Q5jf3O5mm3M5cu3J5o|3G6jd3D6kl3@6cu2\6i}2X6i})K6cu)F6kl)B6hd(_5o|([5`u(Y5mm(V5hf(T4h(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(],ey)@,mr)C,jl)F,cf)I+f)M+jx)Q+lq)V+oj)Z+lc*@*o|*E*`v*L*co*R*co1P*bv1W*o|1]+nc2C+oj2H+oq2M+hx2R+d2V,cf2Y,il2],mr3@,ey3C,h3F-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@/gt7US0js>O/j;_S-100js>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_.hf>^.hl>].dr>\.ax>[.m}>Z/ec>Y/mh>X/en>W/ms>V/dy>U/h~>T0lc>S0ci>Q0gn>P0js>O+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,^0oe,^0jh,]0ln,R0lp,I0ln,E0mr,D0ot+\0dr+X0er+S0or+X0dv+Z0gv+T0ft+P0az+U0i{+U0h+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+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)G1gq)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)O4n`)L4n`)N4gb)M4gc)M4ae)M4oe)M4gh)K4ig)M4ol)M4gh)M4me)O4dc)P4hg)R4ak)S4ko)T4ko)X4dp)Z4gp)T4br)Y4cr)Z4bt)[4bs)]4bs)]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+F6ib+F6oc+G6od+C6nc+A6`f+C6bf*_6kb*\6kb*X6cf*\6fg*_6eh+B6nk*Y6dn*Z6lp*V6br*W6jt*W6ou*T6dx*V7ea*O7`d*P7lc*M7gc*L7cc*L7kb*L7gb*L7na*L7fa*L7ba*L7i`*L7e`*L6m*L6e*L6`*L6h~*L6d~*L6l}*L6g}*K6nz*H6m~*B6e*B6i*B7b`*B7j`*B7ba*B7ja*B7bb*B7jb*B7bc*B7gc*B7oc*B7bd)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'\7bd!_7lb!_7mb"B7mb"B7ac"B7ac"B7ec"B7ec"B7jc"B7nc"B7nc"B7bd"B7cd"C7oc"C7nc"C7jc"C7fc"C7fc"C7bc"C7mb"C7mb"C7ib"C7eb"C7eb"C7ab"C7la"C7da"C6k"B6h}"C6`|"E6a|"F6e}"G6n~"I6j}"I6`}"K6e~"L6a}"L6e{"M6d{"N6b}"M6`"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"Z7l`"\7j`"\7ad"^7cd#A7nc#A7jc#A7jc#A7ec#A7ec#A7ac#A7lb#A7lb#A7hb#A7hb#A7ja#A7ha#C6e#@6a#B6o#C7l`#D7da#F7ic#H7kc#I7oc#I7oc#I7`d#J7cd#V7jc#Y7bd#[7ob#_7`d$C7kb$C7da$C7lb$B7c`$A6j$D6c}$G6i{$I6b{$J6j|$J6e}$I6n~$I6e}$J6d}$L6b{$L6mz$N6n{$N6f$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$Y6jb$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$X5h$X6ba$W6ia$X6jb$W6fg$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$W6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6kn$W6ml$W6al$X6fm$Y6on$X6`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$S6ds$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$R6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6kt$O6aw$Q6nw$P6ex$Q6bz$O6mu$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$O6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6ky"\6dz#A6b{#@6nz"_6`|"_6dx"_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"_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!]6`h!]6mg!^6fi!_6hh"A6oj!_6mj!^6`h!]6od!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!Y6`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!T6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P5e~!O6a`!O6c`!P6k`!P6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6d`!N5e!M5g!M6c`!N5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5a~!G5i}!H5a~!I5f~!H5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5k|!F5i|!E5b}!D5g}!F5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5g!C5k|!A5k|!C5f!D5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5fz [5k{ ]5h| ]5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5`{ Z5hz Z5j{ [5m{ [5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5e{ X5dz Y5m{ Y5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5fz?E5oy?F5my?G5oz?E5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5n{?@5k{>]5mz>_5j{?@5c|?@7ad!V7bd!V7nc!V7oc!V7lc!W7lc!W7ic!W7jc!W7jc!W7gc!W7gc!W7dc!X7ec!X7ac!X7bc!X7cc!X7cc!X7lb!Y7mb!Y7mb!Y7`d![6jy$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$N5lz+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+G5`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*P2ct(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(V2bg)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)H2cj*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*G2gk)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)R1hn)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&U2g&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&E3gi&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%D5d%A6lc$_6jb$]6af$\6fg$]6gg$Z6eh$Z6bm$]6nj$Y5bn%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%N4fq&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&L4d})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})P4cw)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)E5cg(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(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(I5gu'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'V6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6`a'K5k'K6i`'L5d~'M5e'N5j}'N5e}'M5a{'M5gz'O5jy'P5mw'P5`v'R5ot'Q5lt'S5mu'S5ow'R5nw'Q5kx'Q5mz'P5h}'P5e{'O5d}'O5f~'O6d`'O6ma'M6cb'J7m`&]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&P6`~&N6e}&R6i~&R6o&T6f&U6n&X7f`&X7g`&[6m&\7m`&]2ik"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"V2mo"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"T2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2jq"R2hq"T2lq"T2br"R2mq"R2`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"O2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2lt"K2ht"L2ct"K2gt"J/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-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>Z,h{>Z,hz>[,f|>]-`a?@-fa>_-ac?@-mb?A-`d?B-nd?A-de?C-eg?D-ah?D-bi?D,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,kwI+fi>I*f>I+fd>I+dd?H+di?H*d?H+dd?H+dd?H+gd5U,cc5U,cc5Z,cc5P,cc5U-ka5U-ka5Z-ka5P-ka5U.g`5U.g`5Z.g`5P.g`5U.o~5U.o~5Z.o~5P.o~5U/k}5U/k}5Z/k}5P/k}5U0c|5U0c|5Z0c|5P0c|5U1oz5U1oz5Z1oz5P1oz5U2gy5U2gy5Z2gy5P2gy5U3cx5U3cx5Z3cx5P3cx5U4kv5U4kv5Z4kv5P4kv5U4kv5U+gd5U+ed4W*e4W+ei4W+ed4W+fd3X*f3X+fi3X+fd3X+dd2Z*d2Z+di2Z+dd2Z+ed1[*e1[+ei1[+ed1[+gd0\*g0\+gi0\+gd0\+dd/^*d/^+di/^+dd/^+fd._*f._+fi._+fd._+gd.@*g.@+gi.@+gd.@+ed-B*e-B+ei-B+ed-B+fd,C*f,C+fi,C+fd,C+fd,C+gd5U*oe5U*oe5P*oe5Z*oe5U)cg5U)cg5P)cg5Z)cg5U(kh5U(kh5P(kh5Z(kh5U'oi5U'oi5P'oi5Z'oi5U&gk5U&gk5P&gk5Z&gk5U%kl5U%kl5P%kl5Z%kl5U$cn5U$cn5P$cn5Z$cn5U#go5U#go5P#go5Z#go5U"op5U"op5P"op5Z"op5U!cr5U!cr5P!cr5Z!cr5U!cr5U4kv5U4k{5PN+fd,C*hl,FE!cr5U cy5PS+dd?H*hl>YW%`o @,cc5U,nb5T,nb5S,mb5R,ib5Q,db5P,`b5O,oa5M,ka5L,fa5K,o`5J,k`5I,``5I+h5H+`5G+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*n4W*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@*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*l6T+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+c6D+k6C,c`6B,k`6A,o`6@,da6@,ka5^,oa5],bb5\,fb5[,ib5Z,mb5Y,lb5X,lb5W,cc5U$`l?@$`l?J$`l?E%`u?E%`u?@%`u?J%`j9Y 0.1"$`t9Y 2148 km#`v9YStar position#``9Yin sky plane"`j9YFrom 2:40: 0!`t9YEach 0: 1: 0+fd,C+fi,RSUN->.ke7[.di7[.na7\.ke7[-k{8@SAA.ke7[.`b7L.me7K-g~7L.`b7L-h~6\.eb6[-oz6\-h~6\-lz6L-i~6K-cw6L-lz6L-dw5\-a{5[-ks5\-dw5\-ms5L-jw5K-`p5M-ms5L-ap4\-ns4[-dl4]-ap4\-il4L-fp4K-lh4M-il4L-ai3\-nl3[-de3]-ai3\-fe3L-ci3K-ia3M-fe3L-na2\-ke2[,a~2]-na2\,b~2L-oa2K,ez2M,b~2L,kz1\,d~1\,nv1],kz1\,cw1L,lz1L,fs1M,cw1L,ds0],aw0\,ko0],ds0],lo0M,is0L,cl0M,lo0M,dl/],ap/\,kh/],dl/],ih/M,fl/L,ld/N,ih/M,ae.],nh.\,da.^,ae.],fa.M,ce.L+i}.N,fa.M+n}-],ka-\+az-^+n}-]+gz-M+`~-M+jv-N+gz-M+kv,]+dz,]+nr,^+kv,]+`s,N+mv,M+go,N+`s,N7lv @May 4 1986 Occultation of nepklem 1026 by Triton (N1)7h` @Observed from SAAO Sutherland 74" Long= -20 48 44.3 Lat= -32 22 43.46dj @13.11-magnitude star at RA= 18h 24m 16.1231s Dec=-22d 13' 22.807" + 5`t @ (1950) RA= 18h 22m 5.3070s Dec=-22d 14' 27.910" + 4l} @Closest at 2:45:30 U.T. 4hg @ Radial= 4158.7 km = 0.19"3dq @ Planet= 1600.0 km = 0.07"2`{ @ ET - UT = 56.1709 sec DE-1182ld @ P.A.= 12.7 deg.1hn @ Phase = 1.5 deg = 100.0%0dx @ Alt= 75 d, Az= -36 d0`b @ Sun alt=-30 d, Az= 90 d/lk @ Sun:127.8 d, Moon: 11.9 d.hu @ V =0.0007 "/s = 14.22 km/s-d @ D = 29.619079 A.U.-`i @Doug Mink 16: 4 Nov 11 1985-`i @ diff --git a/nx-X11/programs/xterm/tektests/usmap.tek b/nx-X11/programs/xterm/tektests/usmap.tek new file mode 100644 index 000000000..0e6234463 Binary files /dev/null and b/nx-X11/programs/xterm/tektests/usmap.tek differ diff --git a/nx-X11/programs/xterm/termcap b/nx-X11/programs/xterm/termcap new file mode 100644 index 000000000..1320f45f1 --- /dev/null +++ b/nx-X11/programs/xterm/termcap @@ -0,0 +1,209 @@ +# $XTermId: termcap,v 1.68 2005/11/03 13:17:28 tom Exp $ +# +# $Xorg: termcap,v 1.3 2000/08/17 19:55:10 cpqbld Exp $ +# +# This file is formatted using ncurses' "tic -CNx". +# +# 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 +# 'xtermm' 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 +# +# $XFree86: xc/programs/xterm/termcap,v 3.36 2005/11/03 13:17:28 dickey Exp $ +# +xf|xterm-new|modern xterm:\ + :*6=\EOF:@7=\EOF:F1=\E[23~:F2=\E[24~: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[?25h:vi=\E[?25l: + +# 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~:Km=\E[M:kH=\E[4~:kh=\E[1~:\ + :tc=xterm-basic: + +v1|xterm-24|xterms|vs100|24x80 xterm:\ + :li#24:tc=xterm: +v2|xterm-65|65x80 xterm:\ + :li#65:tc=xterm: +vb|xterm-bold|xterm with bold for underline:\ + :so=\E[7m:us=\E[1m:tc=xterm: +vB|xterm-boldso|xterm with bold for standout:\ + :se=\E[m:so=\E[1m:tc=xterm: +vm|xterm-mono|monochrome xterm:\ + :ut@:\ + :Co@:NC@:kn#20:pa@:\ + :AB@:AF@:Sb@:Sf@:op@:st@:tc=xterm: +# +# 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. Note that AF/AB really should be Sf/Sb, but there are +# applications which expect the former. The terminfo contains both strings. +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@:\ + :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?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: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: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=\177: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=\177: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/nx-X11/programs/xterm/terminfo b/nx-X11/programs/xterm/terminfo new file mode 100644 index 000000000..f0b5f4d3a --- /dev/null +++ b/nx-X11/programs/xterm/terminfo @@ -0,0 +1,1012 @@ +# $XTermId: terminfo,v 1.111 2005/11/03 13:17:28 tom Exp $ +# +# $Xorg: terminfo,v 1.3 2000/08/17 19:55:10 cpqbld Exp $ +# +# meml locks memory above the cursor; memu unlocks (ala HP terminals) +# +# XFree86 updates/notes/new entries (including xterm-8bit, xterm-16color) +# - Thomas E. Dickey +# +# $XFree86: xc/programs/xterm/terminfo,v 3.57 2005/11/03 13:17:28 dickey Exp $ +# +# 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, + 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, + kcbt=\E[Z, + kcub1=\EOD, + kcud1=\EOB, + kcuf1=\EOC, + kcuu1=\EOA, + kend=\EOF, + kent=\EOM, + khome=\EOH, + kich1=\E[2~, + kind=\E[1;2B, + kmous=\E[M, + knp=\E[6~, + kpp=\E[5~, + kri=\E[1;2A, + rin=\E[%p1%dT, + use=xterm+pcfkeys, + use=xterm-basic, +# Encode modifiers using parameters (see ctlseqs.msg). +# Note that this is unrelated to PCTERM. +# +# Some names are extensions allowed by ncurses: +# kDN, kDN5, kDN6, kLFT5, kLFT6, kRIT5, kRIT6, kUP, kUP5, kUP6 +xterm+pcfkeys|fragment for PC-style keys, + 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~, + kDN=\E[1;2B, + kDN5=\E[1;5B, + kDN6=\E[1;6B, + kLFT5=\E[1;5D, + kLFT6=\E[1;6D, + kRIT5=\E[1;5C, + kRIT6=\E[1;6C, + kUP=\E[1;2A, + kUP5=\E[1;5A, + kUP6=\E[1;6A, +# +# This chunk is used for building the VT220/Sun/PC keyboard variants. +xterm-basic|modern xterm terminal emulator - common, + am, + bce, + km, + mc5i, + mir, + msgr, + xenl, + 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, + kdch1=\E[3~, + 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>, + 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\E(0%e\E(B%;, + sgr0=\E[m\E(B, + smacs=\E(0, + 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, +# +# 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, + kcub1=\EOD, + kcud1=\EOB, + kcuf1=\EOC, + kcuu1=\EOA, + 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~, + kmous=\E[M, + knp=\E[6~, + kpp=\E[5~, + 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, +# +# kf30-kf45 are keysyms XK_R1 through XK_R15 on the Sun keyboard. +xterm-sun|xterm with sun function keys, + kb2=\E[218z, + kcpy=\E[197z, + kcub1=\EOD, + kcud1=\EOB, + kcuf1=\EOC, + kcuu1=\EOA, + kdch1=\177, + 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, + 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, + kmous=\E[M, + 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, +xterm-sco|xterm with SCO function keys, + kcub1=\E[D, + kcud1=\E[B, + kcuf1=\E[C, + kcuu1=\E[A, + kend=\E[F, + kf1=\E[M, + kf10=\E[V, + kf11=\E[W, + kf12=\E[X, + kf13=\E[Y, + 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, + kf4=\E[P, + kf5=\E[Q, + kf6=\E[R, + kf7=\E[S, + kf8=\E[T, + kf9=\E[U, + khome=\E[H, + kich1=\E[L, + knp=\E[G, + kpp=\E[I, + use=xterm-basic, +# +# Other variants: +xterm-24|xterms|vs100|xterm terminal emulator (X Window System), + lines#24, + use=xterm, +xterm-65|xterm with tall window 65x80 (X Window System), + lines#65, + use=xterm, +xterm-bold|xterm with bold instead of underline (X Window System), + smso=\E[7m, + smul=\E[1m, + use=xterm, +xterm-boldso|xterm with bold for standout (X Window System), + rmso=\E[m, + smso=\E[1m, + use=xterm, +xterm-mono|monochrome xterm, + bce@, + colors@, + ncv@, + pairs@, + op@, + setab@, + setaf@, + setb@, + setf@, + sgr@, + use=xterm, +# +# 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, + kcub1=\E[D, + kcud1=\E[B, + kcuf1=\E[C, + kcuu1=\E[A, + rmcup@, + rmkx=\E>, + smcup@, + smkx=\E=, + use=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 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, + ncv#32, + 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[48;5;%p1%dm, + setaf=\E[38;5;%p1%dm, + setb=\E[48;5;%p1%dm, + setf=\E[38;5;%p1%dm, + 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), + am, + bce, + km, + mc5i, + mir, + msgr, + npc, + xenl, + 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=\233m\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, +# +# 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, + am, + km, + mir, + msgr, + xenl, + cols#80, + it#8, + lines#24, + acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, + blink@, + 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, + 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=\177, + kend=\E[4~, + 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~, + khome=\E[1~, + kich1=\E[2~, + kmous=\E[M, + knp=\E[6~, + kpp=\E[5~, + 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, +# +# 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, + am, + km, + msgr, + xenl, + cols#80, + it#8, + lines#24, + bel=^G, + blink@, + 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=\177, + 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. +xterm-xfree86|xterm terminal emulator (XFree86), + use=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. +xterm|X11 terminal emulator, + use=xterm-new, +# use=xterm-r6, diff --git a/nx-X11/programs/xterm/testxmc.c b/nx-X11/programs/xterm/testxmc.c new file mode 100644 index 000000000..60c1f14b4 --- /dev/null +++ b/nx-X11/programs/xterm/testxmc.c @@ -0,0 +1,226 @@ +/* $XTermId: testxmc.c,v 1.30 2005/08/05 01:25:40 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/testxmc.c,v 3.13 2005/08/05 01:25:40 dickey Exp $ + */ + +/************************************************************ + +Copyright 1997-2004,2005 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 +#include + +#define MARK_ON(a) (my_attrs & a) != 0 && (term->flags & (whichone = a)) == 0 +#define MARK_OFF(a) (my_attrs & a) != 0 && (term->flags & (whichone = a)) != 0 + +void +Mark_XMC(TScreen * screen, int param) +{ + static IChar *glitch; + Bool found = False; + Char my_attrs = (screen->xmc_attributes & XMC_FLAGS); + Char 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((term->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 = term->flags; + term->flags ^= whichone; + TRACE(("XMC Writing glitch (%d/%d) after SGR %d\n", my_attrs, + whichone, param)); + dotext(screen, '?', glitch, screen->xmc_glitch); + term->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(TScreen * screen) +{ + if (!screen->move_sgr_ok + && screen->cur_col <= CurMaxCol(screen, screen->cur_row)) { + Mark_XMC(screen, -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(TScreen * screen) +{ + Bool changed = False; + Char start; + Char my_attrs = (screen->xmc_attributes & XMC_FLAGS); + int row = screen->cur_row; + int col = screen->cur_col; + + /* Find the preceding cell. + */ + if (getXtermCell(screen, row, col) != XMC_GLITCH) { + if (col != 0) { + col--; + } else if (!screen->xmc_inline && row != 0) { + row--; + col = CurMaxCol(screen, row); + } + } + start = (SCRN_BUF_ATTRS(screen, row)[col] & my_attrs); + + /* Now propagate the starting state until we reach a cell which holds + * a glitch. + */ + for (;;) { + if (col < CurMaxCol(screen, row)) { + col++; + } else if (!screen->xmc_inline && row < screen->max_row) { + row++; + col = 0; + } else + break; + if (getXtermCell(screen, row, col) == XMC_GLITCH) + break; + if ((SCRN_BUF_ATTRS(screen, row)[col] & my_attrs) != start) { + SCRN_BUF_ATTRS(screen, row)[col] = start | + (SCRN_BUF_ATTRS(screen, row)[col] & ~my_attrs); + changed = True; + } + } + + TRACE(("XMC %s (%s:%d/%d) from %d,%d to %d,%d\n", + changed ? "Ripple" : "Nochange", + BtoS(term->flags & my_attrs), + my_attrs, start, + screen->cur_row, screen->cur_col, + row, col)); + + if (changed) { + ScrnUpdate(screen, screen->cur_row, 0, row + 1 - screen->cur_row, + MaxCols(screen), True); + } +} diff --git a/nx-X11/programs/xterm/trace.c b/nx-X11/programs/xterm/trace.c new file mode 100644 index 000000000..abaaf634f --- /dev/null +++ b/nx-X11/programs/xterm/trace.c @@ -0,0 +1,490 @@ +/* $XTermId: trace.c,v 1.63 2005/09/18 23:48:13 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/trace.c,v 3.23 2005/09/18 23:48:13 dickey Exp $ + */ + +/************************************************************ + +Copyright 1997-2004,2005 by Thomas E. Dickey + + 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. + +********************************************************/ + +/* + * debugging support via TRACE macro. + */ + +#include /* for definition of GCC_UNUSED */ +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_X11_TRANSLATEI_H +#include +#else +#ifdef __cplusplus +extern "C" { +#endif + + extern String _XtPrintXlations(Widget w, + XtTranslations xlations, + Widget accelWidget, + _XtBoolean includeRHS); +#ifdef __cplusplus +} +#endif +#endif +char *trace_who = "parent"; + +void +Trace(char *fmt,...) +{ + static FILE *fp; + static char *trace_out; + va_list ap; + + if (fp != 0 + && trace_who != trace_out) { + fclose(fp); + fp = 0; + } + trace_out = trace_who; + + if (!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 ((fp = fopen(name, "r")) == 0) { + break; + } + fclose(fp); + } +#else + sprintf(name, "Trace-%s.out", trace_who); +#endif + fp = fopen(name, "w"); + if (fp != 0) { + time_t now = time((time_t *) 0); + fprintf(fp, "%s\n", xtermVersion()); +#ifdef HAVE_UNISTD_H + fprintf(fp, "process %d real (%u/%u) effective (%u/%u) -- %s", + getpid(), + (unsigned) getuid(), (unsigned) getgid(), + (unsigned) geteuid(), (unsigned) getegid(), + ctime(&now)); +#else + fprintf(fp, "process %d -- %s", + getpid(), + ctime(&now)); +#endif + } + } + if (!fp) + abort(); + + va_start(ap, fmt); + if (fmt != 0) { + vfprintf(fp, fmt, ap); + (void) fflush(fp); + } else { + (void) fclose(fp); + (void) fflush(stdout); + (void) fflush(stderr); + } + va_end(ap); +} + +char * +visibleChars(PAIRED_CHARS(Char * buf, Char * buf2), unsigned len) +{ + static char *result; + static unsigned used; + unsigned limit = ((len + 1) * 8) + 1; + char *dst; + + if (limit > used) { + used = limit; + result = XtRealloc(result, used); + } + dst = result; + while (len--) { + unsigned value = *buf++; +#if OPT_WIDE_CHARS + if (buf2 != 0) { + value |= (*buf2 << 8); + buf2++; + } + if (value > 255) + sprintf(dst, "\\u+%04X", value); + else +#endif + if (E2A(value) < 32 || (E2A(value) >= 127 && E2A(value) < 160)) + sprintf(dst, "\\%03o", value); + else + sprintf(dst, "%c", CharOf(value)); + dst += strlen(dst); + } + return result; +} + +char * +visibleIChar(IChar * buf, unsigned len) +{ + static char *result; + static unsigned used; + unsigned limit = ((len + 1) * 6) + 1; + char *dst; + + if (limit > used) { + used = limit; + result = XtRealloc(result, used); + } + dst = result; + while (len--) { + unsigned value = *buf++; +#if OPT_WIDE_CHARS + if (value > 255) + sprintf(dst, "\\u+%04X", value); + else +#endif + if (E2A(value) < 32 || (E2A(value) >= 127 && E2A(value) < 160)) + sprintf(dst, "\\%03o", value); + else + sprintf(dst, "%c", CharOf(value)); + dst += strlen(dst); + } + 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(keyboardIsVT220); + } + return result; +} + +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)); + 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; + long supp = 0; + + bzero(&sizehints, sizeof(sizehints)); + if (!XGetWMNormalHints(xw->screen.display, XtWindow(SHELL_OF(xw)), + &sizehints, &supp)) + bzero(&sizehints, sizeof(sizehints)); + TraceSizeHints(&sizehints); +} + +/* + * Some calls to XGetAtom() will fail, and we don't want to stop. So we use + * our own error-handler. + */ +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", result != 0 ? result : "(null)")); + if (result) + XFree(result); + } else { + TRACE(("none (widget is null)\n")); + } + XSetErrorHandler(save); +} + +#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); + XRES_B(sunFunctionKeys); +#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_INITIAL_ERASE + XRES_B(ptyInitialErase); + XRES_B(backarrow_is_erase); +#endif + XRES_B(wait_for_map); + XRES_B(useInsertMode); +#if OPT_ZICONBEEP + XRES_I(zIconBeep); +#endif +#if OPT_PTY_HANDSHAKE + XRES_B(ptyHandshake); +#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, char *src, int first) +{ + char *s; + + if (!strncmp(src, "-/+", 3)) { + dst[0] = 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(char *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; + default: + break; + } + } +} diff --git a/nx-X11/programs/xterm/trace.h b/nx-X11/programs/xterm/trace.h new file mode 100644 index 000000000..9ddfb4650 --- /dev/null +++ b/nx-X11/programs/xterm/trace.h @@ -0,0 +1,79 @@ +/* $XTermId: trace.h,v 1.35 2005/09/18 23:48:13 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/trace.h,v 3.17 2005/09/18 23:48:13 dickey Exp $ + */ + +/************************************************************ + +Copyright 1997-2004,2005 by Thomas E. Dickey + + 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. + +********************************************************/ + +/* + * Common/useful definitions for XTERM application + */ +#ifndef included_trace_h +#define included_trace_h + +#include + +#if OPT_TRACE + +extern void Trace ( char *, ... ) +#ifdef GCC_PRINTF + __attribute__ ((format(printf,1,2))) +#endif + ; +#define TRACE(p) Trace p + +#if OPT_TRACE > 1 +#define TRACE2(p) Trace p +#endif + +extern char * visibleChars (PAIRED_CHARS(Char *buf, Char *buf2), unsigned len); +extern char * visibleIChar (IChar *, unsigned); + +extern void TraceArgv(const char *tag, char **argv); +#define TRACE_ARGV(tag,argv) TraceArgv(tag,argv) + +extern char *trace_who; +#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; + +extern void TraceSizeHints(XSizeHints *); +#define TRACE_HINTS(hints) TraceSizeHints(hints) + +extern void TraceOptions(OptionHelp *options, XrmOptionDescRec *resources, Cardinal count); +#define TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens) + +extern void TraceTranslations(const char *, Widget); +#define TRACE_TRANS(name,w) TraceTranslations(name,w) + +extern void TraceWMSizeHints(XtermWidget); +#define TRACE_WM_HINTS(w) TraceWMSizeHints(w) + +extern void TraceXtermResources(void); +#define TRACE_XRES() TraceXtermResources() + +#endif + +#endif /* included_trace_h */ diff --git a/nx-X11/programs/xterm/unicode/README b/nx-X11/programs/xterm/unicode/README new file mode 100644 index 000000000..a6b4fb1db --- /dev/null +++ b/nx-X11/programs/xterm/unicode/README @@ -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/nx-X11/programs/xterm/unicode/convmap.pl b/nx-X11/programs/xterm/unicode/convmap.pl new file mode 100644 index 000000000..aa85b6fb7 --- /dev/null +++ b/nx-X11/programs/xterm/unicode/convmap.pl @@ -0,0 +1,177 @@ +#!/usr/bin/perl +# Generate keysym2ucs.c file +# +# $XFree86: xc/programs/xterm/unicode/convmap.pl,v 1.5 2000/01/24 22:22:05 dawes Exp $ + +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); + } +} + +$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 () { + if (/^([0-9,A-F]{4});([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*)$/) { + $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, ") { + if (/^0x([0-9a-f]{4})\s+U([0-9a-f]{4})\s*(\#.*)?$/){ + $keysym = hex($1); + $ucs = hex($2); + $keysym_to_ucs{$keysym} = $ucs; + } elsif (/^\s*\#/ || /^\s*$/) { + } else { + die("Syntax error in 'list' in line\n$_\n"); + } +} +close(LIST); + +# read entries in keysymdef.h +open(LIST, ") { + if (/^\#define\s+XK_([A-Za-z_0-9]+)\s+0x([0-9a-fA-F]+)\s*(\/.*)?$/) { + next if /\/\* deprecated \*\//; + $keysymname = $1; + $keysym = hex($2); + $keysym_to_keysymname{$keysym} = $keysymname; + } +} +close(LIST); + +print < 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 0x1000abcd. + * + * 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 , University of Cambridge, June 1999 + * + * Special thanks to Richard Verhoeven for preparing + * an initial draft of the mapping table. + * + * This software is in the public domain. Share and enjoy! + */ + +#include + +struct codepair { + unsigned short keysym; + unsigned short ucs; +} keysymtab[] = { +EOT + +for $keysym (sort {$a <=> $b} keys(%keysym_to_keysymname)) { + $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 <= 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/nx-X11/programs/xterm/unicode/keysym.map b/nx-X11/programs/xterm/unicode/keysym.map new file mode 100644 index 000000000..6e587bdc0 --- /dev/null +++ b/nx-X11/programs/xterm/unicode/keysym.map @@ -0,0 +1,1062 @@ +# 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 responsable for any damage that +# occured 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, +# Markus Kuhn, University of Cambridge, +# +# 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 +0x0027 U0027 # quoteright /* deprecated */ +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 +0x0060 U0060 # quoteleft /* deprecated */ +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 +0x00d0 U00d0 # Eth /* deprecated */ +0x00d1 U00d1 # Ntilde +0x00d2 U00d2 # Ograve +0x00d3 U00d3 # Oacute +0x00d4 U00d4 # Ocircumflex +0x00d5 U00d5 # Otilde +0x00d6 U00d6 # Odiaeresis +0x00d7 U00d7 # multiply +0x00d8 U00d8 # Ooblique +0x00d9 U00d9 # Ugrave +0x00da U00da # Uacute +0x00db U00db # Ucircumflex +0x00dc U00dc # Udiaeresis +0x00dd U00dd # Yacute +0x00de U00de # THORN +0x00de U00de # Thorn /* deprecated */ +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 +0x13bc U0152 # OE +0x13bd U0153 # oe +0x13be U0178 # Ydiaeresis +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 +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 +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_IOTAdiaeresis +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 U0000 # leftradical +0x08a2 U0000 # topleftradical +0x08a3 U0000 # horizconnector +0x08a4 U2320 # topintegral +0x08a5 U2321 # botintegral +0x08a6 U2502 # vertconnector +0x08a7 U0000 # topleftsqbracket +0x08a8 U0000 # botleftsqbracket +0x08a9 U0000 # toprightsqbracket +0x08aa U0000 # botrightsqbracket +0x08ab U0000 # topleftparens +0x08ac U0000 # botleftparens +0x08ad U0000 # toprightparens +0x08ae U0000 # botrightparens +0x08af U0000 # leftmiddlecurlybrace +0x08b0 U0000 # 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 U2245 # approximate +0x08c9 U0000 # 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 U0000 # horizlinescan1 +0x09f0 U0000 # horizlinescan3 +0x09f1 U2500 # horizlinescan5 +0x09f2 U0000 # horizlinescan7 +0x09f3 U0000 # horizlinescan9 +0x09f4 U251c # leftt +0x09f5 U2524 # rightt +0x09f6 U2534 # bott +0x09f7 U252c # topt +0x09f8 U2502 # vertbar +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 */ +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 U0000 # signifblank +0x0aae U2026 # ellipsis +0x0aaf U0000 # 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 +0x0abd U002e # decimalpoint +0x0abe U232a # rightanglebracket +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 U25a1 # 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 U25a0 # 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 U22a4 # downtack +0x0bc3 U2229 # upshoe +0x0bc4 U230a # downstile +0x0bc6 U005f # underbar +0x0bca U2218 # jot +0x0bcc U2395 # quad +0x0bce U22a5 # uptack +0x0bcf U25cb # circle +0x0bd3 U2308 # upstile +0x0bd6 U222a # downshoe +0x0bd8 U2283 # rightshoe +0x0bda U2282 # leftshoe +0x0bdc U22a3 # lefttack +0x0bfc U22a2 # righttack +0x0cdf U2017 # hebrew_doublelowline +0x0ce0 U05d0 # hebrew_aleph +0x0ce1 U05d1 # hebrew_bet +0x0ce1 U05d1 # hebrew_beth /* deprecated */ +0x0ce2 U05d2 # hebrew_gimel +0x0ce2 U05d2 # hebrew_gimmel /* deprecated */ +0x0ce3 U05d3 # hebrew_dalet +0x0ce3 U05d3 # hebrew_daleth /* deprecated */ +0x0ce4 U05d4 # hebrew_he +0x0ce5 U05d5 # hebrew_waw +0x0ce6 U05d6 # hebrew_zain +0x0ce6 U05d6 # hebrew_zayin /* deprecated */ +0x0ce7 U05d7 # hebrew_chet +0x0ce7 U05d7 # hebrew_het /* deprecated */ +0x0ce8 U05d8 # hebrew_tet +0x0ce8 U05d8 # hebrew_teth /* deprecated */ +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 +0x0cf1 U05e1 # hebrew_samekh /* deprecated */ +0x0cf2 U05e2 # hebrew_ayin +0x0cf3 U05e3 # hebrew_finalpe +0x0cf4 U05e4 # hebrew_pe +0x0cf5 U05e5 # hebrew_finalzade +0x0cf5 U05e5 # hebrew_finalzadi /* deprecated */ +0x0cf6 U05e6 # hebrew_zade +0x0cf6 U05e6 # hebrew_zadi /* deprecated */ +0x0cf7 U05e7 # hebrew_kuf /* deprecated */ +0x0cf7 U05e7 # hebrew_qoph +0x0cf8 U05e8 # hebrew_resh +0x0cf9 U05e9 # hebrew_shin +0x0cfa U05ea # hebrew_taf /* deprecated */ +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 U0000 # Hangul_KkogjiDalrinIeung +0x0ef4 U3184 # Hangul_SunkyeongeumPhieuf +0x0ef5 U3186 # Hangul_YeorinHieuh +0x0ef6 U318d # Hangul_AraeA +0x0ef7 U318e # Hangul_AraeAE +0x0ef8 U11eb # Hangul_J_PanSios +0x0ef9 U0000 # Hangul_J_KkogjiDalrinIeung +0x0efa U11f9 # Hangul_J_YeorinHieuh +0x0eff U20a9 # Korean_Won +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 diff --git a/nx-X11/programs/xterm/unicode/make-precompose.sh b/nx-X11/programs/xterm/unicode/make-precompose.sh new file mode 100644 index 000000000..747866c4d --- /dev/null +++ b/nx-X11/programs/xterm/unicode/make-precompose.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# $XTermId: make-precompose.sh,v 1.5 2005/04/03 16:58:30 tom 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' +cut UnicodeData.txt -d ";" -f 1,6 | \ + grep ";[0-9,A-F]" | grep " " | \ + sed -e "s/ /, 0x/;s/^/{ 0x/;s/;/, 0x/;s/$/},/" | (sort -k 3 || sort +2) +cat precompose.c.tail diff --git a/nx-X11/programs/xterm/unicode/precompose.c.head b/nx-X11/programs/xterm/unicode/precompose.c.head new file mode 100644 index 000000000..c51f752d7 --- /dev/null +++ b/nx-X11/programs/xterm/unicode/precompose.c.head @@ -0,0 +1,16 @@ +/* + * Canonical Compositions + * + * DO NOT EDIT BY HAND! This is generated by the script + * unicode/make-precompose.sh + */ +/* @XTermId@ */ +/* @XFree86@ */ + +#include + +static struct { + int replacement; + int base; + int comb; +} precompositions[] = { diff --git a/nx-X11/programs/xterm/unicode/precompose.c.tail b/nx-X11/programs/xterm/unicode/precompose.c.tail new file mode 100644 index 000000000..0ceca9b6c --- /dev/null +++ b/nx-X11/programs/xterm/unicode/precompose.c.tail @@ -0,0 +1,23 @@ +}; + +int do_precomposition(int base, int comb) { + int min = 0; + int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1; + int mid; + unsigned int sought = ((unsigned)base << 16) | (unsigned)comb, that; + + /* binary search */ + while (max >= min) { + mid = (min + max) / 2; + that = ((unsigned)precompositions[mid].base << 16) | ((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/nx-X11/programs/xterm/util.c b/nx-X11/programs/xterm/util.c new file mode 100644 index 000000000..84feac48f --- /dev/null +++ b/nx-X11/programs/xterm/util.c @@ -0,0 +1,2951 @@ +/* $XTermId: util.c,v 1.255 2005/09/18 23:48:13 tom Exp $ */ + +/* + * $Xorg: util.c,v 1.3 2000/08/17 19:55:10 cpqbld Exp $ + */ + +/* $XFree86: xc/programs/xterm/util.c,v 3.93 2005/09/18 23:48:13 dickey Exp $ */ + +/* + * Copyright 1999-2004,2005 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 + +#include +#include +#include +#include +#include + +#if OPT_WIDE_CHARS +#if defined(HAVE_WCHAR_H) && defined(HAVE_WCWIDTH) +#include +#endif +#include +#endif + +#include +#include +#include + +static int ClearInLine(TScreen * screen, int row, int col, unsigned len); +static int handle_translated_exposure(TScreen * screen, + int rect_x, + int rect_y, + int rect_width, + int rect_height); +static void ClearLeft(TScreen * screen); +static void CopyWait(TScreen * screen); +static void horizontal_copy_area(TScreen * screen, + int firstchar, + int nchars, + int amount); +static void vertical_copy_area(TScreen * screen, + int firstline, + int nlines, + int amount); + +#if OPT_WIDE_CHARS +int (*my_wcwidth) (wchar_t); +#endif + +/* + * These routines are used for the jump scroll feature + */ +void +FlushScroll(TScreen * screen) +{ + int i; + int shift = -screen->topline; + 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->alternate + && 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(screen, 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(screen, + (int) refreshtop * FontHeight(screen) + screen->border, + (int) OriginX(screen), + (unsigned) refreshheight * FontHeight(screen), + (unsigned) Width(screen)); + ScrnRefresh(screen, refreshtop, 0, refreshheight, + MaxCols(screen), False); + } + return; +} + +int +AddToRefresh(TScreen * screen) +{ + int amount = screen->refresh_amt; + int row = screen->cur_row; + + if (amount == 0) { + return (0); + } else if (amount > 0) { + int bottom; + + if (row == (bottom = screen->bot_marg) - amount) { + screen->refresh_amt++; + return (1); + } + return (row >= bottom - amount + 1 && row <= bottom); + } else { + int top; + + amount = -amount; + if (row == (top = screen->top_marg) + amount) { + screen->refresh_amt--; + return (1); + } + return (row <= top + amount - 1 && row >= top); + } +} + +/* + * 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(TScreen * screen, int amount, Boolean all_lines) +{ + 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->alternate ? "alternate" : "normal", + amount, + all_lines ? "all" : "visible")); + TRACE2((" before highlite %d.%d .. %d.%d\n", + screen->startHRow, + screen->startHCol, + screen->endHRow, + screen->endHCol)); + TRACE2((" margins %d..%d\n", screen->top_marg, screen->bot_marg)); + TRACE2((" limits %d..%d\n", lo_row, hi_row)); + + if (screen->startHRow >= lo_row + && screen->startHRow - amount < lo_row) { + /* truncate the selection because its start would move out of region */ + if (lo_row + amount <= screen->endHRow) { + TRACE2(("truncate selection by changing start %d.%d to %d.%d\n", + screen->startHRow, + screen->startHCol, + lo_row + amount, + 0)); + screen->startHRow = lo_row + amount; + screen->startHCol = 0; + } else { + TRACE2(("deselect because %d.%d .. %d.%d shifted %d is outside margins %d..%d\n", + screen->startHRow, + screen->startHCol, + screen->endHRow, + screen->endHCol, + -amount, + lo_row, + hi_row)); + ScrnDisownSelection(screen); + } + } else if (screen->startHRow <= hi_row && screen->endHRow > hi_row) { + ScrnDisownSelection(screen); + } else if (screen->startHRow < lo_row && screen->endHRow > lo_row) { + ScrnDisownSelection(screen); + } + + TRACE2((" after highlite %d.%d .. %d.%d\n", + screen->startHRow, + screen->startHCol, + screen->endHRow, + screen->endHCol)); +} + +/* + * This is the same as adjustHiliteOnFwdScroll(), but reversed. In this case, + * only the visible lines are affected. + */ +static void +adjustHiliteOnBakScroll(TScreen * screen, int amount) +{ + int lo_row = screen->top_marg; + int hi_row = screen->bot_marg; + + TRACE2(("adjustSelection BAK %s by %d (%s)\n", + screen->alternate ? "alternate" : "normal", + amount, + "visible")); + TRACE2((" before highlite %d.%d .. %d.%d\n", + screen->startHRow, + screen->startHCol, + screen->endHRow, + screen->endHCol)); + TRACE2((" margins %d..%d\n", screen->top_marg, screen->bot_marg)); + + if (screen->endHRow >= hi_row + && screen->endHRow + amount > hi_row) { + /* truncate the selection because its start would move out of region */ + if (hi_row - amount >= screen->startHRow) { + TRACE2(("truncate selection by changing start %d.%d to %d.%d\n", + screen->startHRow, + screen->startHCol, + hi_row - amount, + 0)); + screen->endHRow = hi_row - amount; + screen->endHCol = 0; + } else { + TRACE2(("deselect because %d.%d .. %d.%d shifted %d is outside margins %d..%d\n", + screen->startHRow, + screen->startHCol, + screen->endHRow, + screen->endHCol, + amount, + lo_row, + hi_row)); + ScrnDisownSelection(screen); + } + } else if (screen->endHRow >= lo_row && screen->startHRow < lo_row) { + ScrnDisownSelection(screen); + } else if (screen->endHRow > hi_row && screen->startHRow > hi_row) { + ScrnDisownSelection(screen); + } + + TRACE2((" after highlite %d.%d .. %d.%d\n", + screen->startHRow, + screen->startHCol, + screen->endHRow, + screen->endHCol)); +} + +/* + * 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(TScreen * screen, int amount) +{ + 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 = (screen->scrollWidget + && !screen->alternate + && 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 (ScrnHaveSelection(screen)) + adjustHiliteOnFwdScroll(screen, amount, scroll_all_lines); + + if (screen->jumpscroll) { + if (screen->scroll_amt > 0) { + if (screen->refresh_amt + amount > i) + FlushScroll(screen); + screen->scroll_amt += amount; + screen->refresh_amt += amount; + } else { + if (screen->scroll_amt < 0) + FlushScroll(screen); + screen->scroll_amt = amount; + screen->refresh_amt = amount; + } + refreshheight = 0; + } else { + ScrollSelection(screen, -(amount), False); + if (amount == i) { + ClearScreen(screen); + screen->cursor_busy -= 1; + return; + } + + shift = -screen->topline; + 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(screen); + screen->scrolls++; + } + + scrolling_copy_area(screen, scrolltop + amount, scrollheight, amount); + + if (refreshheight > 0) { + ClearCurBackground(screen, + (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(screen, + screen->allbuf, + screen->bot_marg + screen->savelines, + 0, + (unsigned) amount, + (unsigned) MaxCols(screen)); + } else { + ScrnDeleteLine(screen, + screen->visbuf, + screen->bot_marg, + screen->top_marg, + (unsigned) amount, + (unsigned) MaxCols(screen)); + } + } + + if (refreshheight > 0) { + ScrnRefresh(screen, 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(TScreen * screen, int amount) +{ + 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(screen, amount); + + if (screen->jumpscroll) { + if (screen->scroll_amt < 0) { + if (-screen->refresh_amt + amount > i) + FlushScroll(screen); + screen->scroll_amt -= amount; + screen->refresh_amt -= amount; + } else { + if (screen->scroll_amt > 0) + FlushScroll(screen); + screen->scroll_amt = -amount; + screen->refresh_amt = -amount; + } + } else { + shift = -screen->topline; + 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(screen); + screen->scrolls++; + } + + scrolling_copy_area(screen, scrolltop - amount, scrollheight, -amount); + + if (refreshheight > 0) { + ClearCurBackground(screen, + (int) refreshtop * FontHeight(screen) + screen->border, + (int) OriginX(screen), + (unsigned) refreshheight * FontHeight(screen), + (unsigned) Width(screen)); + } + } + if (amount > 0) { + ScrnInsertLine(screen, + screen->visbuf, + screen->bot_marg, + screen->top_marg, + (unsigned) amount, + (unsigned) MaxCols(screen)); + } + screen->cursor_busy -= 1; + 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(TScreen * screen, int n) +{ + int i; + int shift; + int bot; + int refreshtop; + int refreshheight; + int scrolltop; + int scrollheight; + + if (!ScrnIsLineInMargins(screen, screen->cur_row - screen->topline)) + return; + + TRACE(("InsertLine count=%d\n", n)); + + if (screen->cursor_state) + HideCursor(); + + if (ScrnHaveSelection(screen) + && ScrnAreLinesInSelection(screen, screen->top_marg, screen->bot_marg)) { + ScrnDisownSelection(screen); + } + + screen->do_wrap = 0; + 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(screen); + screen->scroll_amt -= n; + screen->refresh_amt -= n; + } else if (screen->scroll_amt) + FlushScroll(screen); + } + if (!screen->scroll_amt) { + shift = -screen->topline; + 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(screen, scrolltop - n, scrollheight, -n); + if (refreshheight > 0) { + ClearCurBackground(screen, + (int) refreshtop * FontHeight(screen) + screen->border, + (int) OriginX(screen), + (unsigned) refreshheight * FontHeight(screen), + (unsigned) Width(screen)); + } + } + if (n > 0) { + ScrnInsertLine(screen, + screen->visbuf, + screen->bot_marg, + screen->cur_row, + (unsigned) n, + (unsigned) MaxCols(screen)); + } +} + +/* + * 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(TScreen * screen, int n) +{ + int i; + int shift; + int bot; + int refreshtop; + int refreshheight; + int scrolltop; + int scrollheight; + + if (!ScrnIsLineInMargins(screen, screen->cur_row - screen->topline)) + return; + + TRACE(("DeleteLine count=%d\n", n)); + + if (screen->cursor_state) + HideCursor(); + + if (ScrnHaveSelection(screen) + && ScrnAreLinesInSelection(screen, screen->top_marg, screen->bot_marg)) { + ScrnDisownSelection(screen); + } + + screen->do_wrap = 0; + if (n > (i = screen->bot_marg - screen->cur_row + 1)) + n = i; + if (screen->jumpscroll) { + if (screen->scroll_amt >= 0 && screen->cur_row == screen->top_marg) { + if (screen->refresh_amt + n > MaxRows(screen)) + FlushScroll(screen); + screen->scroll_amt += n; + screen->refresh_amt += n; + } else if (screen->scroll_amt) + FlushScroll(screen); + } + if (!screen->scroll_amt) { + + shift = -screen->topline; + 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 (screen->scrollWidget && !screen->alternate && screen->cur_row == 0) { + 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(screen, scrolltop + n, scrollheight, n); + if (refreshheight > 0) { + ClearCurBackground(screen, + (int) refreshtop * FontHeight(screen) + screen->border, + (int) OriginX(screen), + (unsigned) refreshheight * FontHeight(screen), + (unsigned) Width(screen)); + } + } + /* adjust screen->buf */ + if (n > 0) { + if (screen->scrollWidget + && !screen->alternate + && screen->cur_row == 0) + ScrnDeleteLine(screen, + screen->allbuf, + screen->bot_marg + screen->savelines, + 0, + (unsigned) n, + (unsigned) MaxCols(screen)); + else + ScrnDeleteLine(screen, + screen->visbuf, + screen->bot_marg, + screen->cur_row, + (unsigned) n, + (unsigned) MaxCols(screen)); + } +} + +/* + * Insert n blanks at the cursor's position, no wraparound + */ +void +InsertChar(TScreen * screen, unsigned n) +{ + unsigned limit; + int row = screen->cur_row - screen->topline; + + if (screen->cursor_state) + HideCursor(); + + TRACE(("InsertChar count=%d\n", n)); + + if (ScrnHaveSelection(screen) + && ScrnIsLineInSelection(screen, row)) { + ScrnDisownSelection(screen); + } + screen->do_wrap = 0; + + assert(screen->cur_col <= screen->max_col); + limit = MaxCols(screen) - screen->cur_col; + + if (n > limit) + n = limit; + + assert(n != 0); + if (row <= screen->max_row) { + if (!AddToRefresh(screen)) { + int col = MaxCols(screen) - n; + if (screen->scroll_amt) + FlushScroll(screen); + +#if OPT_DEC_CHRSET + if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, screen->cur_row)[0])) { + col = MaxCols(screen) / 2 - n; + } +#endif + /* + * prevent InsertChar from shifting the end of a line over + * if it is being appended to + */ + if (non_blank_line(screen->visbuf, screen->cur_row, + screen->cur_col, MaxCols(screen))) + horizontal_copy_area(screen, screen->cur_col, + col - screen->cur_col, + (int) n); + + ClearCurBackground(screen, + CursorY(screen, screen->cur_row), + CurCursorX(screen, screen->cur_row, screen->cur_col), + (unsigned) FontHeight(screen), + n * CurFontWidth(screen, screen->cur_row)); + } + } + /* adjust screen->buf */ + ScrnInsertChar(screen, n); +} + +/* + * Deletes n chars at the cursor's position, no wraparound. + */ +void +DeleteChar(TScreen * screen, unsigned n) +{ + unsigned limit; + int row = screen->cur_row - screen->topline; + + if (screen->cursor_state) + HideCursor(); + + TRACE(("DeleteChar count=%d\n", n)); + + if (ScrnHaveSelection(screen) + && ScrnIsLineInSelection(screen, row)) { + ScrnDisownSelection(screen); + } + screen->do_wrap = 0; + + assert(screen->cur_col <= screen->max_col); + limit = MaxCols(screen) - screen->cur_col; + + if (n > limit) + n = limit; + + assert(n != 0); + if (row <= screen->max_row) { + if (!AddToRefresh(screen)) { + int col = MaxCols(screen) - n; + if (screen->scroll_amt) + FlushScroll(screen); + +#if OPT_DEC_CHRSET + if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, screen->cur_row)[0])) { + col = MaxCols(screen) / 2 - n; + } +#endif + horizontal_copy_area(screen, + (int) (screen->cur_col + n), + col - screen->cur_col, + -((int) n)); + + ClearCurBackground(screen, + CursorY(screen, screen->cur_row), + CurCursorX(screen, screen->cur_row, col), + (unsigned) FontHeight(screen), + n * CurFontWidth(screen, screen->cur_row)); + } + } + if (n > 0) { + /* adjust screen->buf */ + ScrnDeleteChar(screen, (unsigned) n); + } +} + +/* + * Clear from cursor position to beginning of display, inclusive. + */ +static void +ClearAbove(TScreen * screen) +{ + if (screen->protected_mode != OFF_PROTECT) { + int row; + unsigned len = MaxCols(screen); + + assert(screen->max_col >= 0); + for (row = 0; row <= screen->max_row; row++) + ClearInLine(screen, row, 0, len); + } else { + int top, height; + + if (screen->cursor_state) + HideCursor(); + if ((top = -screen->topline) <= screen->max_row) { + if (screen->scroll_amt) + FlushScroll(screen); + if ((height = screen->cur_row + top) > screen->max_row) + height = screen->max_row; + if ((height -= top) > 0) { + ClearCurBackground(screen, + top * FontHeight(screen) + screen->border, + OriginX(screen), + (unsigned) (height * FontHeight(screen)), + (unsigned) (Width(screen))); + } + } + ClearBufRows(screen, 0, screen->cur_row - 1); + } + + if (screen->cur_row - screen->topline <= screen->max_row) + ClearLeft(screen); +} + +/* + * Clear from cursor position to end of display, inclusive. + */ +static void +ClearBelow(TScreen * screen) +{ + ClearRight(screen, -1); + + if (screen->protected_mode != OFF_PROTECT) { + int row; + unsigned len = MaxCols(screen); + + assert(screen->max_col >= 0); + for (row = screen->cur_row + 1; row <= screen->max_row; row++) + ClearInLine(screen, row, 0, len); + } else { + int top; + + if ((top = screen->cur_row - screen->topline) <= screen->max_row) { + if (screen->scroll_amt) + FlushScroll(screen); + if (++top <= screen->max_row) { + ClearCurBackground(screen, + top * FontHeight(screen) + screen->border, + OriginX(screen), + (unsigned) ((screen->max_row - top + 1) + * FontHeight(screen)), + (unsigned) (Width(screen))); + } + } + ClearBufRows(screen, 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 +ClearInLine(TScreen * screen, int row, int col, unsigned len) +{ + int rc = 1; + int flags = TERM_COLOR_FLAGS(term); + + TRACE(("ClearInLine(row=%d, col=%d, len=%d) vs %d..%d\n", + row, col, len, + screen->startHRow, + screen->startHCol)); + + if (ScrnHaveSelection(screen) + && ScrnIsLineInSelection(screen, row)) { + ScrnDisownSelection(screen); + } + + /* + * 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; + } else { + len = 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 = SCRN_BUF_ATTRS(screen, row) + 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(screen, 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 += n; + len -= n; + } + } while (!done); + + screen->protected_mode = saved_mode; + if (len <= 0) + return 0; + } + /* fall through to the final non-protected segment */ + + if (screen->cursor_state) + HideCursor(); + screen->do_wrap = 0; + + if (row - screen->topline <= screen->max_row) { + if (!AddToRefresh(screen)) { + if (screen->scroll_amt) + FlushScroll(screen); + ClearCurBackground(screen, + CursorY(screen, row), + CurCursorX(screen, row, col), + (unsigned) FontHeight(screen), + len * CurFontWidth(screen, row)); + } + } + + memset(SCRN_BUF_CHARS(screen, row) + col, ' ', len); + memset(SCRN_BUF_ATTRS(screen, row) + col, flags, len); + + if_OPT_EXT_COLORS(screen, { + memset(SCRN_BUF_FGRND(screen, row) + col, term->sgr_foreground, len); + memset(SCRN_BUF_BGRND(screen, row) + col, term->cur_background, len); + }); + if_OPT_ISO_TRADITIONAL_COLORS(screen, { + memset(SCRN_BUF_COLOR(screen, row) + col, xtermColorPair(), len); + }); + if_OPT_DEC_CHRSET({ + memset(SCRN_BUF_CSETS(screen, row) + col, + curXtermChrSet(screen->cur_row), len); + }); + if_OPT_WIDE_CHARS(screen, { + memset(SCRN_BUF_WIDEC(screen, row) + col, 0, len); + memset(SCRN_BUF_COM1L(screen, row) + col, 0, len); + memset(SCRN_BUF_COM1H(screen, row) + col, 0, len); + memset(SCRN_BUF_COM2L(screen, row) + col, 0, len); + memset(SCRN_BUF_COM2H(screen, row) + col, 0, len); + }); + + return rc; +} + +/* + * Clear the next n characters on the cursor's line, including the cursor's + * position. + */ +void +ClearRight(TScreen * screen, int n) +{ + unsigned len = (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 = n; + + (void) ClearInLine(screen, screen->cur_row, screen->cur_col, len); + + /* with the right part cleared, we can't be wrapping */ + ScrnClrWrapped(screen, screen->cur_row); +} + +/* + * Clear first part of cursor's line, inclusive. + */ +static void +ClearLeft(TScreen * screen) +{ + unsigned len = screen->cur_col + 1; + assert(screen->cur_col >= 0); + + (void) ClearInLine(screen, screen->cur_row, 0, len); +} + +/* + * Erase the cursor's line. + */ +static void +ClearLine(TScreen * screen) +{ + unsigned len = MaxCols(screen); + + assert(screen->max_col >= 0); + (void) ClearInLine(screen, screen->cur_row, 0, len); +} + +void +ClearScreen(TScreen * screen) +{ + int top; + + if (screen->cursor_state) + HideCursor(); + + ScrnDisownSelection(screen); + screen->do_wrap = 0; + if ((top = -screen->topline) <= screen->max_row) { + if (screen->scroll_amt) + FlushScroll(screen); + ClearCurBackground(screen, + top * FontHeight(screen) + screen->border, + OriginX(screen), + (unsigned) ((screen->max_row - top + 1) + * FontHeight(screen)), + (unsigned) Width(screen)); + } + ClearBufRows(screen, 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(TScreen * screen, int param, int mode) +{ + 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(screen, -1); + break; + case 1: + ClearLeft(screen); + break; + case 2: + ClearLine(screen); + 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(TScreen * screen, int param, int mode) +{ + 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(screen, 2, mode); + saved_mode = screen->protected_mode; + } else + ClearBelow(screen); + break; + + case 1: + if (screen->cur_row == screen->max_row + && screen->cur_col == screen->max_col) { + screen->protected_mode = saved_mode; + do_erase_display(screen, 2, mode); + saved_mode = screen->protected_mode; + } else + ClearAbove(screen); + 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 = MaxCols(screen); + + assert(screen->max_col >= 0); + for (row = 0; row <= screen->max_row; row++) + rc &= ClearInLine(screen, row, 0, len); + if (rc != 0) + saved_mode = OFF_PROTECT; + } else { + ClearScreen(screen); + } + break; + + case 3: + /* xterm addition - erase saved lines. */ + screen->savedlines = 0; + ScrollBarDrawThumb(screen->scrollWidget); + break; + } + screen->protected_mode = saved_mode; +} + +static void +CopyWait(TScreen * screen) +{ + XEvent reply; + XEvent *rep = &reply; + + while (1) { + XWindowEvent(screen->display, VWindow(screen), + ExposureMask, &reply); + switch (reply.type) { + case Expose: + HandleExposure(screen, &reply); + break; + case NoExpose: + case GraphicsExpose: + if (screen->incopy <= 0) { + screen->incopy = 1; + if (screen->scrolls > 0) + screen->scrolls--; + } + if (reply.type == GraphicsExpose) + HandleExposure(screen, &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(TScreen * screen, + int src_x, + int src_y, + unsigned width, + unsigned height, + int dest_x, + int dest_y) +{ + if (width != 0 && height != 0) { + /* wait for previous CopyArea to complete unless + multiscroll is enabled and active */ + if (screen->incopy && screen->scrolls == 0) + CopyWait(screen); + 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(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(TScreen * screen, + int firstchar, /* char pos on screen to start copying at */ + int nchars, + int amount) /* number of characters to move right */ +{ + int src_x = CurCursorX(screen, screen->cur_row, firstchar); + int src_y = CursorY(screen, screen->cur_row); + + copy_area(screen, src_x, src_y, + (unsigned) nchars * CurFontWidth(screen, screen->cur_row), + (unsigned) FontHeight(screen), + src_x + amount * CurFontWidth(screen, screen->cur_row), src_y); +} + +/* + * use when inserting or deleting lines from the screen + */ +static void +vertical_copy_area(TScreen * screen, + int firstline, /* line on screen to start copying at */ + int nlines, + int amount) /* number of lines to move up (neg=down) */ +{ + if (nlines > 0) { + int src_x = OriginX(screen); + int src_y = firstline * FontHeight(screen) + screen->border; + + copy_area(screen, src_x, src_y, + (unsigned) Width(screen), + (unsigned) (nlines * FontHeight(screen)), + src_x, src_y - amount * FontHeight(screen)); + } +} + +/* + * use when scrolling the entire screen + */ +void +scrolling_copy_area(TScreen * screen, + 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(screen, firstline, nlines, amount); + } +} + +/* + * Handler for Expose events on the VT widget. + * Returns 1 iff the area where the cursor was got refreshed. + */ +int +HandleExposure(TScreen * screen, XEvent * event) +{ + 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(screen, 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 + screen->copy_width, + (unsigned) (reply->x + reply->width)); + int both_y2 = Min(screen->copy_src_y + screen->copy_height, + (unsigned) (reply->y + 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 + (screen, 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(screen, reply->x, reply->y, + reply->width, reply->height); + + return value; + } +} + +/* + * 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(TScreen * screen, + int rect_x, + int rect_y, + int rect_width, + int rect_height) +{ + int toprow, leftcol, nrows, ncols; + int x0, x1; + int y0, y1; + + 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); + + toprow = y0 / FontHeight(screen); + if (toprow < 0) + toprow = 0; + + leftcol = x0 / CurFontWidth(screen, screen->cur_row); + 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(screen, toprow, leftcol, nrows, ncols, False); + if (waiting_for_initial_map) { + first_map_occurred(); + } + if (screen->cur_row >= toprow && + screen->cur_row < toprow + nrows && + screen->cur_col >= leftcol && + screen->cur_col < leftcol + ncols) + return (1); + + } + return (0); +} + +/***====================================================================***/ + +void +GetColors(XtermWidget tw, ScrnColors * pColors) +{ + TScreen *screen = &tw->screen; + int n; + + pColors->which = 0; + for (n = 0; n < NCOLORS; ++n) { + SET_COLOR_VALUE(pColors, n, T_COLOR(screen, n)); + } +} + +void +ChangeColors(XtermWidget tw, ScrnColors * pNew) +{ + TScreen *screen = &tw->screen; +#if OPT_TEK4014 + Window tek = TWindow(screen); +#endif + + 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))); + } else if ((T_COLOR(screen, TEXT_CURSOR) == T_COLOR(screen, TEXT_FG)) && + (COLOR_DEFINED(pNew, TEXT_FG))) { + T_COLOR(screen, TEXT_CURSOR) = COLOR_VALUE(pNew, TEXT_FG); + TRACE(("... TEXT_CURSOR: %#lx\n", T_COLOR(screen, TEXT_CURSOR))); + } + + 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))); + XSetForeground(screen->display, NormalGC(screen), fg); + XSetBackground(screen->display, ReverseGC(screen), fg); + XSetForeground(screen->display, NormalBoldGC(screen), fg); + XSetBackground(screen->display, ReverseBoldGC(screen), fg); + } + + 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))); + XSetBackground(screen->display, NormalGC(screen), bg); + XSetForeground(screen->display, ReverseGC(screen), bg); + XSetBackground(screen->display, NormalBoldGC(screen), bg); + XSetForeground(screen->display, ReverseBoldGC(screen), bg); + XSetWindowBackground(screen->display, VWindow(screen), + T_COLOR(screen, TEXT_BG)); + } +#if OPT_HIGHLIGHT_COLOR + if (COLOR_DEFINED(pNew, HIGHLIGHT_BG)) { + T_COLOR(screen, HIGHLIGHT_BG) = COLOR_VALUE(pNew, HIGHLIGHT_BG); + TRACE(("... HIGHLIGHT_BG: %#lx\n", T_COLOR(screen, HIGHLIGHT_BG))); + } +#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))); + } + + recolor_cursor(screen->pointer_cursor, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); + recolor_cursor(screen->arrow, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); + XDefineCursor(screen->display, VWindow(screen), + screen->pointer_cursor); + +#if OPT_TEK4014 + if (tek) + XDefineCursor(screen->display, tek, screen->arrow); +#endif + } +#if OPT_TEK4014 + if (COLOR_DEFINED(pNew, TEK_FG) || + COLOR_DEFINED(pNew, TEK_BG) || + COLOR_DEFINED(pNew, TEK_CURSOR)) { + ChangeTekColors(screen, pNew); + } +#endif + set_cursor_gcs(screen); + XClearWindow(screen->display, VWindow(screen)); + ScrnRefresh(screen, 0, 0, MaxRows(screen), + MaxCols(screen), False); +#if OPT_TEK4014 + if (screen->Tshow) { + XClearWindow(screen->display, tek); + TekExpose((Widget) NULL, (XEvent *) NULL, (Region) NULL); + } +#endif +} + +void +ChangeAnsiColors(XtermWidget tw) +{ + TScreen *screen = &tw->screen; + + XClearWindow(screen->display, VWindow(screen)); + ScrnRefresh(screen, 0, 0, + MaxRows(screen), + MaxCols(screen), False); +} + +/***====================================================================***/ + +void +ReverseVideo(XtermWidget termw) +{ + TScreen *screen = &termw->screen; + GC tmpGC; + Pixel tmp; +#if OPT_TEK4014 + Window tek = TWindow(screen); +#endif + + /* + * 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. + */ + if_OPT_ISO_COLORS(screen, { + ColorRes tmp2; + EXCHANGE(screen->Acolors[0], screen->Acolors[7], tmp2); + EXCHANGE(screen->Acolors[8], screen->Acolors[15], tmp2); + }); + + tmp = T_COLOR(screen, TEXT_BG); + if (T_COLOR(screen, TEXT_CURSOR) == T_COLOR(screen, TEXT_FG)) + T_COLOR(screen, TEXT_CURSOR) = tmp; + T_COLOR(screen, TEXT_BG) = T_COLOR(screen, TEXT_FG); + T_COLOR(screen, TEXT_FG) = tmp; + + EXCHANGE(T_COLOR(screen, MOUSE_FG), T_COLOR(screen, MOUSE_BG), tmp); + EXCHANGE(NormalGC(screen), ReverseGC(screen), tmpGC); + EXCHANGE(NormalBoldGC(screen), ReverseBoldGC(screen), tmpGC); +#ifndef NO_ACTIVE_ICON + tmpGC = screen->iconVwin.normalGC; + screen->iconVwin.normalGC = screen->iconVwin.reverseGC; + screen->iconVwin.reverseGC = tmpGC; + + tmpGC = screen->iconVwin.normalboldGC; + screen->iconVwin.normalboldGC = screen->iconVwin.reverseboldGC; + screen->iconVwin.reverseboldGC = tmpGC; +#endif /* NO_ACTIVE_ICON */ + + recolor_cursor(screen->pointer_cursor, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); + recolor_cursor(screen->arrow, + T_COLOR(screen, MOUSE_FG), + T_COLOR(screen, MOUSE_BG)); + + termw->misc.re_verse = !termw->misc.re_verse; + + if (XtIsRealized((Widget) termw)) { + XDefineCursor(screen->display, VWindow(screen), screen->pointer_cursor); + } +#if OPT_TEK4014 + if (tek) + XDefineCursor(screen->display, tek, screen->arrow); +#endif + + if (screen->scrollWidget) + ScrollBarReverseVideo(screen->scrollWidget); + + if (XtIsRealized((Widget) termw)) { + XSetWindowBackground(screen->display, VWindow(screen), + T_COLOR(screen, TEXT_BG)); + + /* the shell-window's background will be used in the first repainting + * on resizing + */ + XSetWindowBackground(screen->display, VShellWindow, + T_COLOR(screen, TEXT_BG)); + } +#if OPT_TEK4014 + TekReverseVideo(screen); +#endif + if (XtIsRealized((Widget) termw)) { + XClearWindow(screen->display, VWindow(screen)); + ScrnRefresh(screen, 0, 0, MaxRows(screen), + MaxCols(screen), False); + } +#if OPT_TEK4014 + if (screen->Tshow) { + XClearWindow(screen->display, tek); + TekExpose((Widget) NULL, (XEvent *) NULL, (Region) NULL); + } +#endif + ReverseOldColors(); + update_reversevideo(); +} + +void +recolor_cursor(Cursor cursor, /* X cursor ID to set */ + unsigned long fg, /* pixel indexes to look up */ + unsigned long bg) /* pixel indexes to look up */ +{ + TScreen *screen = &term->screen; + 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 * +getColor(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(term->screen.display, term->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; +} + +/* + * 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 void +xtermXftDrawString(TScreen * screen, + unsigned flags GCC_UNUSED, + XftColor * color, + XftFont * font, + int x, + int y, + PAIRED_CHARS(Char * text, Char * text2), + int len, + int fwidth, + int *deltax) +{ +#if OPT_RENDERWIDE + XftFont *wfont; + int n; + int ncells = 0; /* # of 'half-width' charcells */ + static XftCharSpec *sbuf; + static int slen = 0; + XftFont *lastFont = 0; + XftFont *currFont = 0; + int start = 0; + int charWidth; + FcChar32 wc; + int fontnum = screen->menu_font_number; + + if (len == 0 || !(*text || *text2)) { + return; + } +#if OPT_ISO_COLORS + if ((flags & UNDERLINE) + && screen->italicULMode + && screen->renderWideItal[fontnum]) { + wfont = screen->renderWideItal[fontnum]; + } else +#endif + if ((flags & BOLDATTR(screen)) + && screen->renderWideBold[fontnum]) { + wfont = screen->renderWideBold[fontnum]; + } else { + wfont = screen->renderWideNorm[fontnum]; + } + + if ((int) slen < len) { + slen = (len + 1) * 2; + sbuf = (XftCharSpec *) XtRealloc((char *) sbuf, + slen * sizeof(XftCharSpec)); + } + + for (n = 0; n < len; n++) { + if (text2) + wc = *text++ | (*text2++ << 8); + else + wc = *text++; + sbuf[n].ucs4 = wc; + sbuf[n].x = x + fwidth * ncells; + sbuf[n].y = y; + charWidth = my_wcwidth((int) wc); + currFont = (charWidth == 2 && wfont != 0) ? wfont : font; + ncells += charWidth; + if (lastFont != currFont) { + if (lastFont != 0) { + XftDrawCharSpec(screen->renderDraw, + color, + lastFont, + sbuf + start, + n - start); + } + start = n; + lastFont = currFont; + } + } + XftDrawCharSpec(screen->renderDraw, + color, + lastFont, + sbuf + start, + n - start); + + if (deltax) + *deltax = ncells * fwidth; +#else + + XftDrawString8(screen->renderDraw, + color, + font, + x, y, (unsigned char *) text, len); + if (deltax) + *deltax = len * fwidth; +#endif +} +#endif /* OPT_RENDERFONT */ + +#define DrawX(col) x + (col * (font_width)) +#define DrawSegment(first,last) (void)drawXtermText(screen, flags|NOTRANSLATION, gc, DrawX(first), y, chrset, PAIRED_CHARS(text+first, text2+first), (unsigned)(last - first), on_wide) + +#if OPT_WIDE_CHARS +/* + * 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(TScreen * screen, + unsigned ch, + unsigned flags, + GC gc, + int x, + int y, + int chrset, + int on_wide) +{ + int fixed = False; + + if (screen->wide_chars && screen->utf8_mode && ch > 256) { + switch (ch) { + case 0x2010: /* groff "-" */ + case 0x2011: + case 0x2012: + case 0x2013: + case 0x2014: + case 0x2015: + case 0x2212: /* groff "\-" */ + ch = '-'; + fixed = True; + break; + case 0x2018: /* groff "`" */ + ch = '`'; + fixed = True; + break; + case 0x2019: /* groff ' */ + ch = '\''; + fixed = True; + break; + case 0x201C: /* groff lq */ + case 0x201D: /* groff rq */ + ch = '"'; + fixed = True; + break; + } + if (fixed) { + Char text[2]; + Char text2[2]; + + text[0] = ch; + text2[0] = 0; + drawXtermText(screen, + flags, + gc, + x, + y, + chrset, + PAIRED_CHARS(text, text2), + 1, + on_wide); + } + } + return fixed; +} +#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 (pwidth > 2) { \ + XRectangle clip; \ + int clip_x = x; \ + int clip_y = y - FontHeight(screen) + FontDescent(screen); \ + clip.x = 0; \ + clip.y = 0; \ + clip.height = FontHeight(screen); \ + clip.width = pwidth * plength; \ + XSetClipRectangles(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 */ + +/* + * Draws text with the specified combination of bold/underline. The return + * value is the updated x position. + */ +int +drawXtermText(TScreen * screen, + unsigned flags, + GC gc, + int x, + int y, + int chrset, + PAIRED_CHARS(Char * text, Char * text2), + Cardinal len, + int on_wide) +{ + int real_length = len; + int underline_len; + /* 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 + /* + * It's simpler to pass in a null pointer for text2 in places where + * we only use codes through 255. Fix text2 here so we can increment + * it, etc. + */ + if (text2 == 0) { + static Char *dbuf; + static unsigned dlen; + if (dlen <= len) { + dlen = (len + 1) * 2; + dbuf = (Char *) XtRealloc((char *) dbuf, dlen); + memset(dbuf, 0, dlen); + } + text2 = dbuf; + } +#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. + */ + GC gc2 = ((!IsIcon(screen) && screen->font_doublesize) + ? xterm_DoubleGC((unsigned) chrset, flags, gc) + : 0); + + TRACE(("DRAWTEXT%c[%4d,%4d] (%d) %d:%.*s\n", + screen->cursor_state == OFF ? ' ' : '*', + y, x, chrset, len, (int) len, text)); + + if (gc2 != 0) { /* draw actual double-sized characters */ + /* Update the last-used cache of double-sized fonts */ + int inx = xterm_Double_index((unsigned) chrset, flags); + XFontStruct *fs = screen->double_fonts[inx].fs; + XRectangle rect, *rp = ▭ + int nr = 1; + int adjust; + + font_width *= 2; + flags |= DOUBLEWFONT; + + rect.x = 0; + rect.y = 0; + rect.width = len * font_width; + rect.height = FontHeight(screen); + + switch (chrset) { + case CSET_DHL_TOP: + rect.y = -(rect.height / 2); + y -= rect.y; + flags |= DOUBLEHFONT; + break; + case CSET_DHL_BOT: + rect.y = (rect.height / 2); + y -= rect.y; + flags |= DOUBLEHFONT; + break; + default: + nr = 0; + break; + } + + /* + * Though it is the right "size", a given bold font may + * be shifted up by a pixel or two. Shift it back into + * the clipping rectangle. + */ + if (nr != 0) { + adjust = fs->ascent + + fs->descent + - (2 * FontHeight(screen)); + rect.y -= adjust; + y += adjust; + } + + if (nr) + XSetClipRectangles(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(screen, flags, gc2, + x, y, 0, + PAIRED_CHARS(text++, text2++), + 1, on_wide); + x += FontWidth(screen); + } + } else { + x = drawXtermText(screen, flags, gc2, + x, y, 0, + PAIRED_CHARS(text, text2), + len, on_wide); + x += len * FontWidth(screen); + } + + TRACE(("drawtext [%4d,%4d]\n", y, x)); + } else { /* simulate double-sized characters */ +#if OPT_WIDE_CHARS + Char *wide = 0; +#endif + unsigned need = 2 * len; + Char *temp = TypeMallocN(Char, need); + unsigned n = 0; + if_OPT_WIDE_CHARS(screen, { + wide = TypeMallocN(Char, need); + }); + while (len--) { + if_OPT_WIDE_CHARS(screen, { + wide[n] = *text2++; + wide[n + 1] = 0; + }); + temp[n++] = *text++; + temp[n++] = ' '; + } + x = drawXtermText(screen, + flags, + gc, + x, y, + 0, + PAIRED_CHARS(temp, wide), + n, + on_wide); + free(temp); + if_OPT_WIDE_CHARS(screen, { + free(wide); + }); + } + return x; + } +#endif +#if OPT_RENDERFONT + if (UsingRenderFont(term)) { + Display *dpy = screen->display; + XftFont *font; + XGCValues values; + int fontnum = screen->menu_font_number; + + 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->italicULMode + && screen->renderFontItal[fontnum]) { + font = screen->renderFontItal[fontnum]; + did_ul = True; + } else +#endif + if ((flags & BOLDATTR(screen)) + && screen->renderFontBold[fontnum]) { + font = screen->renderFontBold[fontnum]; + } else { + font = screen->renderFontNorm[fontnum]; + } + XGetGCValues(dpy, gc, GCForeground | GCBackground, &values); + if (!(flags & NOBACKGROUND)) + XftDrawRect(screen->renderDraw, + getColor(values.background), + x, y, + len * FontWidth(screen), + (unsigned) FontHeight(screen)); + + y += font->ascent; +#if OPT_BOX_CHARS + if (!screen->force_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++) { + unsigned ch = text[last]; + int deltax = 0; + + /* + * If we're reading UTF-8 from the client, we may have a + * line-drawing character. Translate it back to our box-code + * if it is really a line-drawing character (since the + * fonts used by Xft generally do not have correct glyphs), + * or if Xft can tell us that the glyph is really missing. + */ + if_OPT_WIDE_CHARS(screen, { + unsigned full = (ch | (text2[last] << 8)); + unsigned part = ucs2dec(full); + if (xtermIsDecGraphic(part) && + (xtermIsLineDrawing(part) + || xtermXftMissing(term, font, full))) + ch = part; + else + ch = full; + }); + /* + * If we have one of our box-codes, draw it directly. + */ + if (xtermIsDecGraphic(ch)) { + /* line drawing character time */ + if (last > first) { + xtermXftDrawString(screen, flags, + getColor(values.foreground), + font, curX, y, + PAIRED_CHARS(text + first, + text2 + first), + last - first, + FontWidth(screen), + &deltax); + curX += deltax; + } + old_wide = screen->fnt_wide; + old_high = screen->fnt_high; + screen->fnt_wide = FontWidth(screen); + screen->fnt_high = FontHeight(screen); + xtermDrawBoxChar(term, ch, flags, gc, + curX, y - FontAscent(screen)); + curX += FontWidth(screen); + screen->fnt_wide = old_wide; + screen->fnt_high = old_high; + first = last + 1; + } + } + if (last > first) { + xtermXftDrawString(screen, flags, + getColor(values.foreground), + font, curX, y, + PAIRED_CHARS(text + first, text2 + first), + last - first, + FontWidth(screen), + NULL); + } + } else +#endif /* OPT_BOX_CHARS */ + { + xtermXftDrawString(screen, flags, + getColor(values.foreground), + font, x, y, PAIRED_CHARS(text, text2), + (int) len, FontWidth(screen), NULL); + } + + if ((flags & UNDERLINE) && screen->underline && !did_ul) { + if (FontDescent(screen) > 1) + y++; + XDrawLine(screen->display, VWindow(screen), gc, + x, y, + x + (int) len * FontWidth(screen) - 1, + y); + } + return x + 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; + GC fillGC = gc; /* might be cursorGC */ + XFontStruct *fs = ((flags & BOLDATTR(screen)) + ? BoldFont(screen) + : NormalFont(screen)); + +#define GC_PAIRS(a,b) \ + if (gc == a) fillGC = b; \ + if (gc == b) fillGC = a + + /* + * Fill the area where we'll write the characters, otherwise + * we'll get gaps between them. 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. + */ + if (gc == screen->cursorGC + || gc == screen->reversecursorGC) + fillGC = screen->fillCursorGC; + GC_PAIRS(NormalGC(screen), ReverseGC(screen)); + GC_PAIRS(NormalBoldGC(screen), ReverseBoldGC(screen)); + + if (!(flags & NOBACKGROUND)) + XFillRectangle(screen->display, VWindow(screen), fillGC, + x, y, + len * FontWidth(screen), + (unsigned) FontHeight(screen)); + + while (len--) { + width = XTextWidth(fs, (char *) text, 1); + adj = (FontWidth(screen) - width) / 2; + (void) drawXtermText(screen, flags | NOBACKGROUND | CHARBYCHAR, + gc, x + adj, y, chrset, + PAIRED_CHARS(text++, text2++), 1, on_wide); + x += FontWidth(screen); + } + 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(). */ + XFontStruct *font = ((flags & BOLD) + ? BoldFont(screen) + : NormalFont(screen)); + int last, first = 0; + for (last = 0; last < (int) len; last++) { + unsigned ch = text[last]; + Bool isMissing; +#if OPT_WIDE_CHARS + if (text2 != 0) + ch |= (text2[last] << 8); + isMissing = (ch != HIDDEN_CHAR) + && (xtermMissingChar(term, ch, + ((on_wide || iswide((int) ch)) + && screen->fnt_dwd) + ? screen->fnt_dwd + : font)); +#else + isMissing = xtermMissingChar(term, ch, font); +#endif + if (isMissing) { + if (last > first) + DrawSegment(first, last); +#if OPT_WIDE_CHARS + if (!ucs_workaround(screen, ch, flags, gc, DrawX(last), y, + chrset, on_wide)) +#endif + xtermDrawBoxChar(term, ch, flags, gc, DrawX(last), y); + first = last + 1; + } + } + if (last <= first) { + return x + real_length * FontWidth(screen); + } + text += first; +#if OPT_WIDE_CHARS + text2 += first; +#endif + len = last - first; + flags |= NOTRANSLATION; + if (DrawX(first) != x) { + return drawXtermText(screen, + flags, + gc, + DrawX(first), + y, + chrset, + PAIRED_CHARS(text, text2), + 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). The only translation we do + * in this branch is the removal of HIDDEN_CHAR (for the wide-char case). + */ + TRACE(("drawtext%c[%4d,%4d] (%d) %d:%s\n", + screen->cursor_state == OFF ? ' ' : '*', + y, x, chrset, len, + visibleChars(PAIRED_CHARS(text, text2), len))); + y += FontAscent(screen); + +#if OPT_WIDE_CHARS + if (screen->wide_chars || screen->unicode_font) { + int ascent_adjust = 0; + static XChar2b *sbuf; + static Cardinal slen; + int n; + unsigned ch = text[0] | (text2[0] << 8); + int wideness = (!IsIcon(screen) + && ((on_wide || iswide((int) ch) != 0) + && (screen->fnt_dwd != NULL))); + unsigned char *endtext = text + len; + if (slen < len) { + slen = (len + 1) * 2; + sbuf = (XChar2b *) XtRealloc((char *) sbuf, slen * sizeof(*sbuf)); + } + for (n = 0; n < (int) len; n++) { + sbuf[n].byte2 = *text; + sbuf[n].byte1 = *text2; +#if OPT_MINI_LUIT +#define UCS2SBUF(n,value) sbuf[n].byte2 = (value & 0xff);\ + sbuf[n].byte1 = (value >> 8) +#define Map2Sbuf(n,from,to) (*text == from) { UCS2SBUF(n,to); } + if (screen->latin9_mode && !screen->utf8_mode && *text2 == 0) { + + /* see http://www.cs.tut.fi/~jkorpela/latin9.html */ + /* *INDENT-OFF* */ + if Map2Sbuf(n, 0xa4, 0x20ac) + else if Map2Sbuf(n, 0xa6, 0x0160) + else if Map2Sbuf(n, 0xa8, 0x0161) + else if Map2Sbuf(n, 0xb4, 0x017d) + else if Map2Sbuf(n, 0xb8, 0x017e) + else if Map2Sbuf(n, 0xbc, 0x0152) + else if Map2Sbuf(n, 0xbd, 0x0153) + else if Map2Sbuf(n, 0xbe, 0x0178) + /* *INDENT-ON* */ + + } + if (screen->unicode_font + && *text2 == 0 + && (*text == 0x7f || *text < 0x20)) { + int ni = dec2ucs(*text == 0x7f ? 0 : *text); + UCS2SBUF(n, ni); + } +#endif /* OPT_MINI_LUIT */ + text++; + text2++; + if (wideness) { + /* filter out those pesky fake characters. */ + while (text < endtext + && *text == HIDDEN_HI + && *text2 == HIDDEN_LO) { + text++; + text2++; + len--; + } + } + } + /* This is probably wrong. But it works. */ + underline_len = len; + + /* Set the drawing font */ + if (flags & (DOUBLEHFONT | DOUBLEWFONT)) { + ; /* Do nothing: font is already set */ + } else if (wideness + && (screen->fnt_dwd->fid || screen->fnt_dwdb->fid)) { + underline_len = real_length = len * 2; + if ((flags & BOLDATTR(screen)) != 0 + && screen->fnt_dwdb->fid) { + XSetFont(screen->display, gc, screen->fnt_dwdb->fid); + ascent_adjust = (screen->fnt_dwdb->ascent + - NormalFont(screen)->ascent); + } else { + XSetFont(screen->display, gc, screen->fnt_dwd->fid); + ascent_adjust = (screen->fnt_dwd->ascent + - NormalFont(screen)->ascent); + } + /* fix ascent */ + } else if ((flags & BOLDATTR(screen)) != 0 + && BoldFont(screen)->fid) { + XSetFont(screen->display, gc, BoldFont(screen)->fid); + } else { + XSetFont(screen->display, gc, NormalFont(screen)->fid); + } + + if (flags & NOBACKGROUND) + XDrawString16(screen->display, + VWindow(screen), gc, + x, y + ascent_adjust, + sbuf, n); + else + XDrawImageString16(screen->display, + VWindow(screen), gc, + x, y + ascent_adjust, + sbuf, n); + + if ((flags & BOLDATTR(screen)) && screen->enbolden) { + beginClipping(screen, gc, font_width, len); + XDrawString16(screen->display, VWindow(screen), gc, + x + 1, y + ascent_adjust, sbuf, n); + endClipping(screen, gc); + } + + } else +#endif /* OPT_WIDE_CHARS */ + { + int length = len; /* X should have used unsigned */ + + if (flags & NOBACKGROUND) + XDrawString(screen->display, VWindow(screen), gc, + x, y, (char *) text, length); + else + XDrawImageString(screen->display, VWindow(screen), gc, + x, y, (char *) text, length); + underline_len = length; + if ((flags & BOLDATTR(screen)) && screen->enbolden) { + beginClipping(screen, gc, font_width, length); + XDrawString(screen->display, VWindow(screen), gc, + x + 1, y, (char *) text, 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 + underline_len * font_width - 1, y); + } + + return x + real_length * FontWidth(screen); +} + +/* set up size hints for window manager; min 1 char by 1 char */ +void +xtermSizeHints(XtermWidget xw, XSizeHints * sizehints, int scrollbarWidth) +{ + TScreen *screen = &xw->screen; + + TRACE(("xtermSizeHints\n")); + TRACE((" border %d\n", xw->core.border_width)); + TRACE((" scrollbar %d\n", scrollbarWidth)); + + sizehints->base_width = 2 * screen->border + scrollbarWidth; + sizehints->base_height = 2 * screen->border; + +#if OPT_TOOLBAR + TRACE((" toolbar %d\n", ToolbarHeight(xw))); + + sizehints->base_height += ToolbarHeight(xw); + sizehints->base_height += xw->core.border_width * 2; + sizehints->base_width += xw->core.border_width * 2; +#endif + + sizehints->width_inc = FontWidth(screen); + sizehints->height_inc = FontHeight(screen); + sizehints->min_width = sizehints->base_width + sizehints->width_inc; + sizehints->min_height = sizehints->base_height + sizehints->height_inc; + + sizehints->width = MaxCols(screen) * FontWidth(screen) + sizehints->min_width; + sizehints->height = MaxRows(screen) * FontHeight(screen) + sizehints->min_height; + + sizehints->flags |= (PSize | PBaseSize | PMinSize | PResizeInc); + + TRACE_HINTS(sizehints); +} + +/* + * 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(TScreen * screen, unsigned flags, unsigned fg_bg, Bool hilite) +{ + int my_fg = extract_fg(fg_bg, flags); + int my_bg = extract_bg(fg_bg, flags); + Pixel fg_pix = getXtermForeground(flags, my_fg); + Pixel bg_pix = getXtermBackground(flags, my_bg); + Pixel xx_pix; +#if OPT_HIGHLIGHT_COLOR + Pixel hi_pix = T_COLOR(screen, HIGHLIGHT_BG); +#endif + GC gc; + + checkVeryBoldColors(flags, my_fg); + + if (ReverseOrHilite(screen, flags, hilite)) { + if (flags & BOLDATTR(screen)) + gc = ReverseBoldGC(screen); + else + gc = ReverseGC(screen); + +#if OPT_HIGHLIGHT_COLOR + if (hi_pix != T_COLOR(screen, TEXT_FG) + && hi_pix != fg_pix + && hi_pix != bg_pix + && hi_pix != term->dft_foreground) { + bg_pix = fg_pix; + fg_pix = hi_pix; + } +#endif + xx_pix = bg_pix; + bg_pix = fg_pix; + fg_pix = xx_pix; + } else { + if (flags & BOLDATTR(screen)) + gc = NormalBoldGC(screen); + else + gc = NormalGC(screen); + + } + +#if OPT_BLINK_TEXT + if ((screen->blink_state == ON) && (!screen->blink_as_bold) && (flags & BLINK)) { + fg_pix = bg_pix; + } +#endif + + XSetForeground(screen->display, gc, fg_pix); + XSetBackground(screen->display, gc, bg_pix); + return gc; +} + +/* + * 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(TScreen * screen, unsigned flags, Bool hilite) +{ + Pixel fg_pix = getXtermForeground(flags, term->cur_foreground); + Pixel bg_pix = getXtermBackground(flags, term->cur_background); + GC gc; + + checkVeryBoldColors(flags, term->cur_foreground); + + if (ReverseOrHilite(screen, flags, hilite)) { + if (flags & BOLDATTR(screen)) + gc = ReverseBoldGC(screen); + else + gc = ReverseGC(screen); + + XSetForeground(screen->display, gc, bg_pix); + XSetBackground(screen->display, gc, fg_pix); + + } else { + if (flags & BOLDATTR(screen)) + gc = NormalBoldGC(screen); + else + gc = NormalGC(screen); + + XSetForeground(screen->display, gc, fg_pix); + XSetBackground(screen->display, gc, bg_pix); + } +} + +#if OPT_ISO_COLORS +/* + * Extract the foreground-color index from a one-byte color pair. If we've got + * BOLD or UNDERLINE color-mode active, those will be used. + */ +unsigned +extract_fg(unsigned color, unsigned flags) +{ + unsigned fg = ExtractForeground(color); + + if (term->screen.colorAttrMode + || (fg == ExtractBackground(color))) { + if (term->screen.colorULMode && (flags & UNDERLINE)) + fg = COLOR_UL; + if (term->screen.colorBDMode && (flags & BOLD)) + fg = COLOR_BD; + if (term->screen.colorBLMode && (flags & BLINK)) + fg = COLOR_BL; + } + return fg; +} + +/* + * Extract the background-color index from a one-byte color pair. + * If we've got INVERSE color-mode active, that will be used. + */ +unsigned +extract_bg(unsigned color, unsigned flags) +{ + unsigned bg = ExtractBackground(color); + + if (term->screen.colorAttrMode + || (bg == ExtractForeground(color))) { + if (term->screen.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. + */ +unsigned +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; +#if OPT_EXT_COLORS + return (my_fg << 8) | my_bg; +#else + return (my_fg << 4) | my_bg; +#endif +} + +/* + * Using the "current" SGR background, clear a rectangle. + */ +void +ClearCurBackground(TScreen * screen, + int top, + int left, + unsigned height, + unsigned width) +{ + XSetWindowBackground(screen->display, + VWindow(screen), + getXtermBackground(term->flags, term->cur_background)); + + XClearArea(screen->display, VWindow(screen), + left, top, width, height, False); + + XSetWindowBackground(screen->display, + VWindow(screen), + getXtermBackground(term->flags, MAXCOLORS)); +} +#endif /* OPT_ISO_COLORS */ + +/* + * Returns a single 8/16-bit number for the given cell + */ +unsigned +getXtermCell(TScreen * screen, int row, int col) +{ + unsigned ch = SCRN_BUF_CHARS(screen, row)[col]; + if_OPT_WIDE_CHARS(screen, { + ch |= (SCRN_BUF_WIDEC(screen, row)[col] << 8); + }); + return ch; +} + +/* + * Sets a single 8/16-bit number for the given cell + */ +void +putXtermCell(TScreen * screen, int row, int col, int ch) +{ + SCRN_BUF_CHARS(screen, row)[col] = ch; + if_OPT_WIDE_CHARS(screen, { + SCRN_BUF_WIDEC(screen, row)[col] = (ch >> 8); + SCRN_BUF_COM1L(screen, row)[col] = 0; + SCRN_BUF_COM1H(screen, row)[col] = 0; + SCRN_BUF_COM2L(screen, row)[col] = 0; + SCRN_BUF_COM2H(screen, row)[col] = 0; + }); +} + +#if OPT_WIDE_CHARS +unsigned +getXtermCellComb1(TScreen * screen, int row, int col) +{ + unsigned ch = SCRN_BUF_COM1L(screen, row)[col]; + ch |= (SCRN_BUF_COM1H(screen, row)[col] << 8); + return ch; +} + +unsigned +getXtermCellComb2(TScreen * screen, int row, int col) +{ + unsigned ch = SCRN_BUF_COM2L(screen, row)[col]; + ch |= (SCRN_BUF_COM2H(screen, row)[col] << 8); + return ch; +} + +/* + * Add a combining character for the given cell + */ +void +addXtermCombining(TScreen * screen, int row, int col, unsigned ch) +{ + if (!SCRN_BUF_COM1L(screen, row)[col] + && !SCRN_BUF_COM1H(screen, row)[col]) { + SCRN_BUF_COM1L(screen, row)[col] = ch & 0xff; + SCRN_BUF_COM1H(screen, row)[col] = ch >> 8; + } else if (!SCRN_BUF_COM2H(screen, row)[col]) { + SCRN_BUF_COM2L(screen, row)[col] = ch & 0xff; + SCRN_BUF_COM2H(screen, row)[col] = ch >> 8; + } +} +#endif + +#ifdef HAVE_CONFIG_H +#ifdef USE_MY_MEMMOVE +char * +my_memmove(char *s1, char *s2, size_t n) +{ + if (n != 0) { + if ((s1 + n > s2) && (s2 + n > s1)) { + 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] = s2[j]; + s2 = bfr; + } + while (n-- != 0) + s1[n] = s2[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 + +int +char2lower(int ch) +{ + if (isascii(ch) && isupper(ch)) { /* lowercasify */ +#ifdef _tolower + ch = _tolower(ch); +#else + ch = tolower(ch); +#endif + } + return ch; +} + +void +update_keyboard_type(void) +{ + update_delete_del(); + update_old_fkeys(); + update_hp_fkeys(); + update_sco_fkeys(); + update_sun_fkeys(); + update_sun_kbd(); +} + +void +set_keyboard_type(xtermKeyboardType type, Bool set) +{ + xtermKeyboardType save = term->keyboard.type; + + TRACE(("set_keyboard_type(%s, %s) currently %s\n", + visibleKeyboardType(type), + BtoS(set), + visibleKeyboardType(term->keyboard.type))); + if (set) { + term->keyboard.type = type; + } else { + term->keyboard.type = keyboardIsDefault; + } + + if (save != term->keyboard.type) { + update_keyboard_type(); + } +} + +void +toggle_keyboard_type(xtermKeyboardType type) +{ + xtermKeyboardType save = term->keyboard.type; + + TRACE(("toggle_keyboard_type(%s) currently %s\n", + visibleKeyboardType(type), + visibleKeyboardType(term->keyboard.type))); + if (term->keyboard.type == type) { + term->keyboard.type = keyboardIsDefault; + } else { + term->keyboard.type = type; + } + + if (save != term->keyboard.type) { + update_keyboard_type(); + } +} + +void +init_keyboard_type(xtermKeyboardType type, Bool set) +{ + static Bool wasSet = False; + + TRACE(("init_keyboard_type(%s, %s) currently %s\n", + visibleKeyboardType(type), + BtoS(set), + visibleKeyboardType(term->keyboard.type))); + if (set) { + if (wasSet) { + fprintf(stderr, "Conflicting keyboard type option (%u/%u)\n", + term->keyboard.type, type); + } + term->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(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 + DATA(NAME_SUN_KT, keyboardIsSun, sunFunctionKeys), +#if OPT_SUNPC_KBD + DATA(NAME_VT220_KT, keyboardIsVT220, sunKeyboard), +#endif + }; + Cardinal n; + + if (x_strcasecmp(rp->keyboardType, "unknown")) { + Bool found = False; + for (n = 0; n < XtNumber(table); ++n) { + if (!x_strcasecmp(rp->keyboardType, table[n].name + 1)) { + FLAG(n) = True; + found = True; + init_keyboard_type(table[n].type, FLAG(n)); + } else { + FLAG(n) = False; + } + } + if (!found) { + fprintf(stderr, + "KeyboardType resource \"%s\" not found\n", + rp->keyboardType); + } + } else { + for (n = 0; n < XtNumber(table); ++n) + init_keyboard_type(table[n].type, FLAG(n)); + } +#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(void) +{ + wchar_t n; + int oops = 0; + int last = 1024; + + for (n = 0; n < last; ++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\n", oops, last)); + return (oops < (last / 4)); +} +#endif /* HAVE_WCWIDTH */ + +void +decode_wcwidth(int mode) +{ + switch (mode) { + default: +#if defined(HAVE_WCHAR_H) && defined(HAVE_WCWIDTH) + if (xtermEnvUTF8() && systemWcwidthOk()) { + my_wcwidth = wcwidth; + TRACE(("using system wcwidth() function\n")); + break; + } + /* FALLTHRU */ + case 2: +#endif + 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; + } +} +#endif diff --git a/nx-X11/programs/xterm/uxterm b/nx-X11/programs/xterm/uxterm new file mode 100644 index 000000000..6e8f72032 --- /dev/null +++ b/nx-X11/programs/xterm/uxterm @@ -0,0 +1,82 @@ +#!/bin/sh +# $XTermId: uxterm,v 1.20 2005/08/05 01:25:40 tom Exp $ +# $XFree86: xc/programs/xterm/uxterm,v 1.11 2005/08/05 01:25:40 dickey Exp $ +# wrapper script to setup xterm with UTF-8 locale + +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*) + $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 "uxterm tried to use locale $value by setting \$$name" >&2 + xmessage -file - < from VMS.C + * Forced device type to be VT102 since that is + * what we are emulating. + */ + +#include +#include + +#include +#include + +#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); +int tt_write(char *tt_write_buf,int size); +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 = &term->screen; + 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(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(); +} + +/* + * 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(!(term->screen.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((term->screen.max_row != tt_mode.length) || + (term->screen.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/nx-X11/programs/xterm/vms.h b/nx-X11/programs/xterm/vms.h new file mode 100644 index 000000000..86f338eb9 --- /dev/null +++ b/nx-X11/programs/xterm/vms.h @@ -0,0 +1,39 @@ +/* $XFree86: xc/programs/xterm/vms.h,v 1.1 2000/02/08 17:19:45 dawes Exp $ */ + +/* vms.h + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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]; diff --git a/nx-X11/programs/xterm/vttests/16colors.sh b/nx-X11/programs/xterm/vttests/16colors.sh new file mode 100644 index 000000000..f47337577 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/16colors.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/16colors.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# 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="" +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 ""; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD ""; exit' 0 1 2 5 15 +fi + +echo "" +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 "[0;${AT}m$attr$SUF" + $CMD $OPT "[${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 "[4${BG}m$bcolor$SUF" + $CMD $OPT "[10${BG}m+$bcolor$SUF" + done + echo "" + done + done + sleep 1 + done +done diff --git a/nx-X11/programs/xterm/vttests/256colors.pl b/nx-X11/programs/xterm/vttests/256colors.pl new file mode 100644 index 000000000..b053b94fc --- /dev/null +++ b/nx-X11/programs/xterm/vttests/256colors.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl +# $XFree86: xc/programs/xterm/vttests/256colors.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $ + +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; + } + sleep 1; + print "\n"; +} diff --git a/nx-X11/programs/xterm/vttests/256colors2.pl b/nx-X11/programs/xterm/vttests/256colors2.pl new file mode 100644 index 000000000..c97c2be9d --- /dev/null +++ b/nx-X11/programs/xterm/vttests/256colors2.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl +# Author: Todd Larason +# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $ + +# use the resources for colors 0-15 - usually more-or-less a +# reproduction of the standard ANSI colors, but possibly more +# pleasing shades + +# 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;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 16 + ($red * 36) + ($green * 6) + $blue, + ($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 +for ($gray = 0; $gray < 24; $gray++) { + $level = ($gray * 10) + 8; + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 232 + $gray, $level, $level, $level); +} + + +# 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/nx-X11/programs/xterm/vttests/88colors.pl b/nx-X11/programs/xterm/vttests/88colors.pl new file mode 100644 index 000000000..a645fc3d4 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/88colors.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl +# $XFree86: xc/programs/xterm/vttests/88colors.pl,v 1.1 1999/09/25 14:38:51 dawes Exp $ +# 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/nx-X11/programs/xterm/vttests/88colors2.pl b/nx-X11/programs/xterm/vttests/88colors2.pl new file mode 100644 index 000000000..0e4c8f529 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/88colors2.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl +# Author: Steve Wall +# $XFree86: xc/programs/xterm/vttests/88colors2.pl,v 1.1 1999/09/25 14:38:51 dawes Exp $ +# Made 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 + +# colors 16-79 are a 4x4x4 color cube +@steps=(0,139,205,255); +for ($red = 0; $red < 4; $red++) { + for ($green = 0; $green < 4; $green++) { + for ($blue = 0; $blue < 4; $blue++) { + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 16 + ($red * 16) + ($green * 4) + $blue, + 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; } + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 80 + $gray, int($level), int($level), int($level)); +} + + +# 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/nx-X11/programs/xterm/vttests/8colors.sh b/nx-X11/programs/xterm/vttests/8colors.sh new file mode 100644 index 000000000..10865f730 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/8colors.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/8colors.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Show a simple 8-color test pattern + +ESC="" +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 ""; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT ""; exit' 0 1 2 5 15 +fi + +echo "" +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 "[0;${AT}m$attr" + $CMD $OPT "[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 "[4${BG}m$bcolor" + done + echo "" + done + sleep 1 + done +done diff --git a/nx-X11/programs/xterm/vttests/acolors.sh b/nx-X11/programs/xterm/vttests/acolors.sh new file mode 100644 index 000000000..ea19a38f4 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/acolors.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/acolors.sh,v 1.2 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Demonstrate the use of the control sequence for changing ANSI colors. + +ESC="" +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 +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 "" >/dev/tty + $CMD $OPT "${ESC}]4;9;rgb:$R/$G/$B${SUF}" >/dev/tty + sleep 1 + done + done + done +done diff --git a/nx-X11/programs/xterm/vttests/doublechars.sh b/nx-X11/programs/xterm/vttests/doublechars.sh new file mode 100644 index 000000000..dd032ae46 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/doublechars.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/doublechars.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/7/7) +# 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="" +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 + 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/nx-X11/programs/xterm/vttests/dynamic.sh b/nx-X11/programs/xterm/vttests/dynamic.sh new file mode 100644 index 000000000..e68ebbc6c --- /dev/null +++ b/nx-X11/programs/xterm/vttests/dynamic.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/dynamic.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Demonstrate the use of dynamic colors by setting the background successively +# to different values. + +ESC="" +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 +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${SUF}" >/dev/tty + sleep 1 + done + done + done +done diff --git a/nx-X11/programs/xterm/vttests/fonts.sh b/nx-X11/programs/xterm/vttests/fonts.sh new file mode 100644 index 000000000..5dd9e29f0 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/fonts.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/fonts.sh,v 1.4 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Demonstrate the use of dynamic colors by setting the background successively +# to different values. + +ESC="" +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 +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${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/nx-X11/programs/xterm/vttests/resize.pl b/nx-X11/programs/xterm/vttests/resize.pl new file mode 100755 index 000000000..21a18beea --- /dev/null +++ b/nx-X11/programs/xterm/vttests/resize.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl +# $XFree86: xc/programs/xterm/vttests/resize.pl,v 1.1 2004/03/04 02:21:58 dickey Exp $ +# +# -- Thomas Dickey (2004/3/3) +# resize.sh rewritten into Perl for comparison. +# See also Term::ReadKey. + +use IO::Handle; + +sub write_tty { + open 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/nx-X11/programs/xterm/vttests/resize.sh b/nx-X11/programs/xterm/vttests/resize.sh new file mode 100644 index 000000000..004574949 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/resize.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/resize.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Obtain the current screen size, then resize the terminal to the nominal +# screen width/height, and restore the size. + +ESC="" +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 +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/nx-X11/programs/xterm/vttests/tcapquery.pl b/nx-X11/programs/xterm/vttests/tcapquery.pl new file mode 100755 index 000000000..0cd5d9f64 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/tcapquery.pl @@ -0,0 +1,162 @@ +#!/usr/bin/perl +# $XFree86: xc/programs/xterm/vttests/tcapquery.pl,v 1.2 2005/09/18 23:48:14 dickey Exp $ +# +# -- Thomas Dickey (2004/3/3) +# Test the tcap-query option of xterm. + +use strict; + +use IO::Handle; + +sub write_tty { + open 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; +} + +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 query_tcap { + my $tcap = @_[0]; + my $tinfo = @_[1]; + my $param1 = hexified($tcap); + my $param2 = hexified($tinfo); + + # uncomment one of the following lines + my $reply=get_reply("\x1bP+q" . $param1 . ";" . $param2 . "\x1b\\"); + #my $reply=get_reply("\x1bP+q" . $param2 . "\x1b\\"); + + 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 "$result\n"; + } +} + +# See xtermcapKeycode() +query_tcap( "#2", "kHOM"); +query_tcap( "#4", "kLFT"); +query_tcap( "%1", "khlp"); +query_tcap( "%i", "kRIT"); +query_tcap( "*6", "kslt"); +query_tcap( "*7", "kEND"); +query_tcap( "@0", "kfnd"); +query_tcap( "@7", "kend"); +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( "K1", "ka1"); +query_tcap( "K4", "kc1"); +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( "kB", "kcbt"); +query_tcap( "kC", "kclr"); +query_tcap( "kD", "kdch1"); +query_tcap( "kI", "kich1"); +query_tcap( "kN", "knp"); +query_tcap( "kP", "kpp"); +query_tcap( "kb", "kbs"); +query_tcap( "kd", "kcud1"); +query_tcap( "kh", "khome"); +query_tcap( "kl", "kcub1"); +query_tcap( "kr", "kcuf1"); +query_tcap( "ku", "kcuu1"); +query_tcap( "Co", "colors"); diff --git a/nx-X11/programs/xterm/vttests/title.sh b/nx-X11/programs/xterm/vttests/title.sh new file mode 100644 index 000000000..af3807783 --- /dev/null +++ b/nx-X11/programs/xterm/vttests/title.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/title.sh,v 1.6 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Obtain the current title of the window, set up a simple clock which runs +# until this script is interrupted, then restore the title. + +ESC="" +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 +read original + +stty $old + +# We actually get this terminated by an 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}"${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`" >/dev/tty +done diff --git a/nx-X11/programs/xterm/wcwidth.c b/nx-X11/programs/xterm/wcwidth.c new file mode 100644 index 000000000..d74c7a870 --- /dev/null +++ b/nx-X11/programs/xterm/wcwidth.c @@ -0,0 +1,306 @@ +/* $XFree86: xc/programs/xterm/wcwidth.c,v 1.7 2005/05/03 00:38:25 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 -- 2003-05-20 (Unicode 4.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 + +struct interval { + int first; + int last; +}; + +/* auxiliary function for binary search in interval table */ +static int bisearch(wchar_t ucs, const struct interval *table, int max) { + int min = 0; + int mid; + + if (ucs < table[0].first || ucs > table[max].last) + return 0; + 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) +{ + /* 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, 0x05B9 }, { 0x05BB, 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 }, { 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 }, + { 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 }, + { 0x1DC0, 0x1DC3 }, { 0x200B, 0x200F }, { 0x202A, 0x202E }, + { 0x2060, 0x2063 }, { 0x206A, 0x206F }, { 0x20D0, 0x20EB }, + { 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 (ucs == 0) + return 0; + if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) + return -1; + + /* binary search in table of non-spacing characters */ + if (bisearch(ucs, combining, + sizeof(combining) / sizeof(struct interval) - 1)) + return 0; + + /* if we arrive here, ucs is not a combining or C0/C1 control character */ + + return 1 + + (ucs >= 0x1100 && + (ucs <= 0x115f || /* Hangul Jamo init. consonants */ + ucs == 0x2329 || ucs == 0x232a || + (ucs >= 0x2e80 && ucs <= 0xa4cf && + ucs != 0x303f) || /* CJK ... Yi */ + (ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */ + (ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */ + (ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */ + (ucs >= 0xff00 && ucs <= 0xff60) || /* Fullwidth Forms */ + (ucs >= 0xffe0 && ucs <= 0xffe6) || + (ucs >= 0x20000 && ucs <= 0x2fffd) || + (ucs >= 0x30000 && ucs <= 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 c" */ + 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(ucs, ambiguous, + 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/nx-X11/programs/xterm/wcwidth.h b/nx-X11/programs/xterm/wcwidth.h new file mode 100644 index 000000000..b4eb51af4 --- /dev/null +++ b/nx-X11/programs/xterm/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 + +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/nx-X11/programs/xterm/xcharmouse.h b/nx-X11/programs/xterm/xcharmouse.h new file mode 100644 index 000000000..c1f257e96 --- /dev/null +++ b/nx-X11/programs/xterm/xcharmouse.h @@ -0,0 +1,76 @@ +/* + * $XFree86: xc/programs/xterm/xcharmouse.h,v 1.3 2002/08/24 18:54:39 dickey Exp $ + */ + +/************************************************************ + +Copyright 1998 by Jason Bacon + + 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 + +#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 */ +enum { + MOUSE_OFF + ,X10_MOUSE + ,VT200_MOUSE + ,VT200_HIGHLIGHT_MOUSE + ,BTN_EVENT_MOUSE + ,ANY_EVENT_MOUSE + ,DEC_LOCATOR +}; + +#endif /* included_xcharmouse_h */ diff --git a/nx-X11/programs/xterm/xstrings.c b/nx-X11/programs/xterm/xstrings.c new file mode 100644 index 000000000..1bc2d522e --- /dev/null +++ b/nx-X11/programs/xterm/xstrings.c @@ -0,0 +1,146 @@ +/* $XTermId: xstrings.c,v 1.22 2005/01/14 01:50:03 tom Exp $ */ + +/* $XFree86: xc/programs/xterm/xstrings.c,v 1.9 2005/01/14 01:50:03 dickey Exp $ */ + +/************************************************************ + +Copyright 2000-2004,2005 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 + +#include +#include +#include + +#include + +char * +x_basename(char *name) +{ + char *cp; + + cp = strrchr(name, '/'); +#ifdef __UNIXOS2__ + if (cp == 0) + cp = strrchr(name, '\\'); +#endif + return (cp ? cp + 1 : name); +} + +int +x_strcasecmp(const char *s1, const char *s2) +{ + unsigned len = strlen(s1); + + if (len != strlen(s2)) + return 1; + + while (len-- != 0) { + int c1 = toupper(CharOf(*s1)); + int c2 = toupper(CharOf(*s2)); + if (c1 != c2) + return 1; + 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, 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 the string, returns a copy of it if it + * is modified. + */ +char * +x_strtrim(char *s) +{ + char *base = s; + char *d; + + if (s != 0 && *s != '\0') { + char *t = x_strdup(base); + 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'; + } + } + if (!strcmp(t, base)) { + free(t); + } else { + base = t; + } + } + return base; +} diff --git a/nx-X11/programs/xterm/xstrings.h b/nx-X11/programs/xterm/xstrings.h new file mode 100644 index 000000000..fb7886e25 --- /dev/null +++ b/nx-X11/programs/xterm/xstrings.h @@ -0,0 +1,44 @@ +/* $XFree86: xc/programs/xterm/xstrings.h,v 1.4 2002/08/17 19:52:27 dickey Exp $ */ + +/************************************************************ + +Copyright 2000-2001,2002 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 + +extern char *x_basename(char *name); +extern char *x_strdup(const char *s); +extern char *x_strindex(char *s1, char *s2); +extern char *x_strtrim(char *s); +extern int x_strcasecmp(const char *s1, const char *s2); + +#endif /* included_xstrings_h */ diff --git a/nx-X11/programs/xterm/xterm.dat b/nx-X11/programs/xterm/xterm.dat new file mode 100644 index 000000000..6ae28ca42 --- /dev/null +++ b/nx-X11/programs/xterm/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/nx-X11/programs/xterm/xterm.h b/nx-X11/programs/xterm/xterm.h new file mode 100644 index 000000000..1e4ff56ab --- /dev/null +++ b/nx-X11/programs/xterm/xterm.h @@ -0,0 +1,1101 @@ +/* $XTermId: xterm.h,v 1.357 2005/11/03 13:17:28 tom Exp $ */ + +/* $XFree86: xc/programs/xterm/xterm.h,v 3.109 2005/11/03 13:17:28 dickey Exp $ */ + +/************************************************************ + +Copyright 1999-2004,2005 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 + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifndef GCC_UNUSED +#define GCC_UNUSED /* nothing */ +#endif + +#ifndef GCC_NORETURN +#define GCC_NORETURN /* nothing */ +#endif + +#include + +#ifndef HAVE_CONFIG_H + +#define HAVE_LIB_XAW 1 + +#ifdef CSRG_BASED +/* Get definition of BSD */ +#include +#endif + +#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 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 +#define DECL_ERRNO 1 + +#ifndef NOPUTENV +#define HAVE_PUTENV 1 +#endif + +#if defined(CSRG_BASED) || defined(__GNU__) +#define USE_POSIX_TERMIOS 1 +#endif + +#ifdef __NetBSD__ +#include +#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 +#elif defined(BSD) && (BSD >= 199103) +#ifdef BSD_UTMPX +#define USE_LASTLOGX +#else +#define USE_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_XKBBELL 1 +#endif + +#endif /* HAVE_CONFIG_H */ + +/***====================================================================***/ + +/* 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 +#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 +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +#include +#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_HI 0xff +#define HIDDEN_LO 0xff +#define HIDDEN_CHAR 0xffff +#endif + +/***====================================================================***/ + +#include +#include + +#if (XtSpecificationRelease >= 6) && !defined(NO_XPOLL_H) && !defined(sun) +#include +#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 +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +/* these may be needed for sig_atomic_t */ +#include +#include + +#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 + +#endif /* USE_SYS_SELECT_H */ + +#include + +#if defined(__UNIXOS2__) && !defined(XTERM_MAIN) +#define environ gblenvp /* circumvent a bug */ +#endif + +#if !defined(VMS) && !(defined(linux) && defined(__USE_GNU)) +extern char **environ; +#endif + +/***====================================================================***/ + +#define XtNallowC1Printable "allowC1Printable" +#define XtNallowSendEvents "allowSendEvents" +#define XtNallowWindowOps "allowWindowOps" +#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 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 XtNctrlFKeys "ctrlFKeys" +#define XtNcurses "curses" +#define XtNcursorBlink "cursorBlink" +#define XtNcursorColor "cursorColor" +#define XtNcursorOffTime "cursorOffTime" +#define XtNcursorOnTime "cursorOnTime" +#define XtNcutNewline "cutNewline" +#define XtNcutToBeginningOfLine "cutToBeginningOfLine" +#define XtNdecTerminalID "decTerminalID" +#define XtNdeleteIsDEL "deleteIsDEL" +#define XtNdynamicColors "dynamicColors" +#define XtNeightBitControl "eightBitControl" +#define XtNeightBitInput "eightBitInput" +#define XtNeightBitOutput "eightBitOutput" +#define XtNfaceName "faceName" +#define XtNfaceNameDoublesize "faceNameDoublesize" +#define XtNfaceSize "faceSize" +#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 XtNforceBoxChars "forceBoxChars" +#define XtNfreeBoldBox "freeBoldBox" +#define XtNhighlightColor "highlightColor" +#define XtNhighlightSelection "highlightSelection" +#define XtNhpLowerleftBugCompat "hpLowerleftBugCompat" +#define XtNi18nSelections "i18nSelections" +#define XtNinternalBorder "internalBorder" +#define XtNitalicULMode "italicULMode" +#define XtNjumpScroll "jumpScroll" +#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 XtNmenuBar "menuBar" +#define XtNmenuHeight "menuHeight" +#define XtNmetaSendsEscape "metaSendsEscape" +#define XtNmkWidth "mkWidth" +#define XtNmodifyCursorKeys "modifyCursorKeys" +#define XtNmultiClickTime "multiClickTime" +#define XtNmultiScroll "multiScroll" +#define XtNnMarginBell "nMarginBell" +#define XtNnumLock "numLock" +#define XtNoldXtermFKeys "oldXtermFKeys" +#define XtNpointerColor "pointerColor" +#define XtNpointerColorBackground "pointerColorBackground" +#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 XtNrenderFont "renderFont" +#define XtNresizeGravity "resizeGravity" +#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 XtNshiftFonts "shiftFonts" +#define XtNshowBlinkAsBold "showBlinkAsBold" +#define XtNshowMissingGlyphs "showMissingGlyphs" +#define XtNsignalInhibit "signalInhibit" +#define XtNtekGeometry "tekGeometry" +#define XtNtekInhibit "tekInhibit" +#define XtNtekSmall "tekSmall" +#define XtNtekStartup "tekStartup" +#define XtNtiXtraScroll "tiXtraScroll" +#define XtNtiteInhibit "titeInhibit" +#define XtNtoolBar "toolBar" +#define XtNtrimSelection "trimSelection" +#define XtNunderLine "underLine" +#define XtNutf8 "utf8" +#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 XtCAllowSendEvents "AllowSendEvents" +#define XtCAllowWindowOps "AllowWindowOps" +#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 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 XtCCtrlFKeys "CtrlFKeys" +#define XtCCurses "Curses" +#define XtCCursorBlink "CursorBlink" +#define XtCCursorOffTime "CursorOffTime" +#define XtCCursorOnTime "CursorOnTime" +#define XtCCutNewline "CutNewline" +#define XtCCutToBeginningOfLine "CutToBeginningOfLine" +#define XtCDecTerminalID "DecTerminalID" +#define XtCDeleteIsDEL "DeleteIsDEL" +#define XtCDynamicColors "DynamicColors" +#define XtCEightBitControl "EightBitControl" +#define XtCEightBitInput "EightBitInput" +#define XtCEightBitOutput "EightBitOutput" +#define XtCFaceName "FaceName" +#define XtCFaceNameDoublesize "FaceNameDoublesize" +#define XtCFaceSize "FaceSize" +#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 XtCForceBoxChars "ForceBoxChars" +#define XtCFreeBoldBox "FreeBoldBox" +#define XtCHighlightSelection "HighlightSelection" +#define XtCHpLowerleftBugCompat "HpLowerleftBugCompat" +#define XtCI18nSelections "I18nSelections" +#define XtCJumpScroll "JumpScroll" +#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 XtCMenuBar "MenuBar" +#define XtCMenuHeight "MenuHeight" +#define XtCMetaSendsEscape "MetaSendsEscape" +#define XtCMkWidth "MkWidth" +#define XtCModifyCursorKeys "ModifyCursorKeys" +#define XtCMultiClickTime "MultiClickTime" +#define XtCMultiScroll "MultiScroll" +#define XtCNumLock "NumLock" +#define XtCOldXtermFKeys "OldXtermFKeys" +#define XtCPopOnBell "PopOnBell" +#define XtCPrintAttributes "PrintAttributes" +#define XtCPrinterAutoClose "PrinterAutoClose" +#define XtCPrinterCommand "PrinterCommand" +#define XtCPrinterControlMode "PrinterControlMode" +#define XtCPrinterExtent "PrinterExtent" +#define XtCPrinterFormFeed "PrinterFormFeed" +#define XtCRenderFont "RenderFont" +#define XtCResizeGravity "ResizeGravity" +#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 XtCShiftFonts "ShiftFonts" +#define XtCShowBlinkAsBold "ShowBlinkAsBold" +#define XtCShowMissingGlyphs "ShowMissingGlyphs" +#define XtCSignalInhibit "SignalInhibit" +#define XtCTekInhibit "TekInhibit" +#define XtCTekSmall "TekSmall" +#define XtCTekStartup "TekStartup" +#define XtCTiXtraScroll "TiXtraScroll" +#define XtCTiteInhibit "TiteInhibit" +#define XtCToolBar "ToolBar" +#define XtCTrimSelection "TrimSelection" +#define XtCUnderLine "UnderLine" +#define XtCUtf8 "Utf8" +#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" +#else +#define XtCCursorColor XtCForeground +#define XtCPointerColor XtCForeground +#define XtCHighlightColor XtCForeground +#endif + +/***====================================================================***/ + +#ifdef __cplusplus +extern "C" { +#endif + +struct XTERM_RESOURCE; + +/* Tekproc.c */ +extern int TekInit (void); +extern int TekPtyData(void); +extern void ChangeTekColors (TScreen *screen, ScrnColors *pNew); +extern void TCursorToggle (int toggle); +extern void TekCopy (void); +extern void TekEnqMouse (int c); +extern void TekExpose (Widget w, XEvent *event, Region region); +extern void TekGINoff (void); +extern void TekReverseVideo (TScreen *screen); +extern void TekRun (void); +extern void TekSetFontSize (int newitem); +extern void TekSimulatePageButton (Bool reset); +extern void dorefresh (void); + +/* button.c */ +#define MotionOff( s, t ) { \ + (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 (Widget w, XEvent* event); +extern void DiredButton PROTO_XT_ACTIONS_ARGS; +extern void DisownSelection (XtermWidget termw); +extern void HandleGINInput 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 HandleSecure 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 ReadLineButton PROTO_XT_ACTIONS_ARGS; +extern void ResizeSelection (TScreen *screen, int rows, int cols); +extern void ScrollSelection (TScreen* screen, int amount, Bool); +extern void TrackMouse (int func, int startrow, int startcol, int firstrow, int lastrow); +extern void TrackText (int frow, int fcol, int trow, int tcol); +extern void ViButton PROTO_XT_ACTIONS_ARGS; + +#if OPT_DEC_LOCATOR +extern Bool SendLocatorPosition (Widget w, XEvent* event); +extern void CheckLocatorPosition (Widget w, XEvent *event); +extern void GetLocatorPosition (XtermWidget w); +extern void InitLocatorFilter (XtermWidget w); +#endif /* OPT_DEC_LOCATOR */ + +#if OPT_PASTE64 +extern void AppendToSelectionBuffer (TScreen *screen, unsigned c); +extern void ClearSelectionBuffer (void); +extern void CompleteSelection (char **args, Cardinal len); +extern void xtermGetSelection (Widget w, Time ev_time, String *params, Cardinal num_params, Atom *targets); +#endif + +#if OPT_WIDE_CHARS +extern Bool iswide(int i); +#endif + +/* charproc.c */ +extern int VTInit (void); +extern int v_write (int f, Char *d, unsigned len); +extern void FindFontSelection (char *atom_name, Bool justprobe); +extern void HideCursor (void); +extern void ShowCursor (void); +extern void SwitchBufPtrs (TScreen *screen); +extern void ToggleAlternate (TScreen *screen); +extern void VTReset (int full, int saved); +extern void VTRun (void); +extern void dotext (TScreen *screen, int charset, IChar *buf, Cardinal len); +extern void resetCharsets (TScreen *screen); +extern void set_cursor_gcs (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 unparseputc (int c, int fd); +extern void unparseputc1 (int c, int fd); +extern void unparseputs (char *s, int fd); +extern void unparseseq (ANSI *ap, int fd); +extern void xtermAddInput(Widget w); + +#if OPT_BLINK_CURS +extern void ToggleCursorBlink(TScreen *screen); +#endif + +#if OPT_ISO_COLORS +extern void SGR_Background (int color); +extern void SGR_Foreground (int color); +#endif + +/* charsets.c */ +extern unsigned xtermCharSetIn (unsigned code, int charset); +extern int xtermCharSetOut (IChar *buf, IChar *ptr, int charset); + +/* cursor.c */ +extern void CarriageReturn (TScreen *screen); +extern void CursorBack (TScreen *screen, 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 tw); +extern void CursorSave (XtermWidget tw); +extern void CursorSet (TScreen *screen, int row, int col, unsigned flags); +extern void CursorUp (TScreen *screen, int n); +extern void RevIndex (TScreen *screen, int amount); +extern void xtermIndex (TScreen *screen, 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 (Bool top); +extern void xterm_DECSWL (void); +extern void xterm_DECDWL (void); +#if OPT_DEC_CHRSET +extern int xterm_Double_index(unsigned chrset, unsigned flags); +extern GC xterm_DoubleGC(unsigned chrset, unsigned flags, GC old_gc); +#endif + +/* input.c */ +extern Bool xtermDeleteIsDEL (void); +extern void Input (TKeyboard *keyboard, TScreen *screen, XKeyEvent *event, Bool eightbit); +extern void StringInput (TScreen *screen, Char *string, size_t nbytes); + +#if OPT_NUM_LOCK +extern void VTInitModifiers(void); +#endif + +#if OPT_TCAP_QUERY +extern int xtermcapKeycode(char **params, unsigned *state); +#endif + +/* 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); +extern void first_map_occurred (void); + +#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 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 *); +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 char *SysErrorMsg (int n); +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 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 void Bell (int which, int percent); +extern void ChangeXprop (char *name); +extern void Changename (char *name); +extern void Changetitle (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 HandleStringEvent PROTO_XT_ACTIONS_ARGS; +extern void Panic (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 (Char *buf, size_t len); +extern void do_osc (Char *buf, unsigned len, int final); +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 xtermSetenv (char *var, char *value); + +#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_WIDE_CHARS +extern Bool xtermEnvUTF8(void); +#else +#define xtermEnvUTF8() False +#endif + +#ifdef ALLOWLOGGING +extern void StartLog (TScreen *screen); +extern void CloseLog (TScreen *screen); +extern void FlushLog (TScreen *screen); +#else +#define FlushLog(screen) /*nothing*/ +#endif + +/* print.c */ +extern Bool xtermHasPrinter (void); +extern int xtermPrinterControl (int chr); +extern void setPrinterControlMode (int mode); +extern void xtermAutoPrint (int chr); +extern void xtermMediaControl (int param, int private_seq); +extern void xtermPrintScreen (Bool use_DECPEX); + +/* ptydata.c */ +#ifdef VMS +#define PtySelect int +#else +#define PtySelect fd_set +#endif + +extern int readPtyData (TScreen *screen, PtySelect *select_mask, PtyData *data); +extern void fillPtyData (TScreen *screen, PtyData *data, char *value, int length); +extern void initPtyData (PtyData **data); +extern void trimPtyData (TScreen *screen, PtyData *data); + +#if OPT_WIDE_CHARS +extern Bool morePtyData (TScreen *screen, PtyData *data); +extern Char *convertToUTF8 (Char *lp, unsigned c); +extern IChar nextPtyData (TScreen *screen, PtyData *data); +extern void switchPtyData (TScreen *screen, int f); +extern void writePtyData (int f, IChar *d, unsigned len); +#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 (ScrnBuf sb, int row, int col, int len); +extern ScrnBuf Allocate (int nrow, int ncol, Char **addr); +extern int ScreenResize (TScreen *screen, int width, int height, unsigned *flags); +extern size_t ScrnPointers (TScreen *screen, size_t len); +extern void ClearBufRows (TScreen *screen, int first, int last); +extern void ScreenWrite (TScreen *screen, PAIRED_CHARS(Char *str, Char *str2), unsigned flags, unsigned cur_fg_bg, unsigned length); +extern void ScrnDeleteChar (TScreen *screen, unsigned n); +extern void ScrnDeleteLine (TScreen *screen, ScrnBuf sb, int n, int last, unsigned size, unsigned where); +extern void ScrnFillRectangle (TScreen *, XTermRect *, int, unsigned); +extern void ScrnInsertChar (TScreen *screen, unsigned n); +extern void ScrnInsertLine (TScreen *screen, ScrnBuf sb, int last, int where, unsigned n, unsigned size); +extern void ScrnRefresh (TScreen *screen, int toprow, int leftcol, int nrows, int ncols, Bool force); +extern void ScrnUpdate (TScreen *screen, int toprow, int leftcol, int nrows, int ncols, Bool force); +extern void ScrnDisownSelection (TScreen *screen); +extern void xtermParseRect (TScreen *, int, int *, XTermRect *); + +#define ScrnClrFlag(screen, row, flag) \ + SCRN_BUF_FLAGS(screen, row + screen->topline) = \ + (Char *)((long)SCRN_BUF_FLAGS(screen, row + screen->topline) & ~ (flag)) + +#define ScrnSetFlag(screen, row, flag) \ + SCRN_BUF_FLAGS(screen, row + screen->topline) = \ + (Char *)(((long)SCRN_BUF_FLAGS(screen, row + screen->topline) | (flag))) + +#define ScrnTstFlag(screen, row, flag) \ + ((row + screen->savelines + screen->topline) >= 0 && ((long)SCRN_BUF_FLAGS(screen, row + screen->topline) & (flag)) != 0) + +#define ScrnClrBlinked(screen, row) ScrnClrFlag(screen, row, BLINK) +#define ScrnSetBlinked(screen, row) ScrnSetFlag(screen, row, BLINK) +#define ScrnTstBlinked(screen, row) ScrnTstFlag(screen, row, BLINK) + +#define ScrnClrWrapped(screen, row) ScrnClrFlag(screen, row, LINEWRAPPED) +#define ScrnSetWrapped(screen, row) ScrnSetFlag(screen, row, LINEWRAPPED) +#define ScrnTstWrapped(screen, row) ScrnTstFlag(screen, row, LINEWRAPPED) + +#define ScrnHaveSelection(screen) \ + ((screen)->startHRow != (screen)->endHRow \ + || (screen)->startHCol != (screen)->endHCol) + +#define ScrnAreLinesInSelection(screen, first, last) \ + ((last) >= (screen)->startHRow && (first) <= (screen)->endHRow) + +#define ScrnIsLineInSelection(screen, line) \ + ((line) >= (screen)->startHRow && (line) <= (screen)->endHRow) + +#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 (TScreen *, XTermRect *, int, int *); +extern void ScrnMarkRectangle (TScreen *, XTermRect *, Bool, int, int *); +extern void ScrnWipeRectangle (TScreen *, XTermRect *); +#endif + +#if OPT_WIDE_CHARS +extern void ChangeToWide(TScreen * screen); +#endif + +/* 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 (TScreen *screen); +extern void ScrollBarOn (XtermWidget xw, int init, int doalloc); +extern void ScrollBarReverseVideo (Widget scrollWidget); +extern void ToggleScrollBar (XtermWidget w); +extern void WindowScroll (TScreen *screen, int top); + +#ifdef SCROLLBAR_RIGHT +extern void updateRightScrollbar(XtermWidget xw); +#else +#define updateRightScrollbar(xw) /* nothing */ +#endif + +/* tabs.c */ +extern Bool TabToNextStop (TScreen *screen); +extern Bool TabToPrevStop (TScreen *screen); +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 GC updatedXtermGC (TScreen *screen, unsigned flags, unsigned fg_bg, Bool hilite); +extern int AddToRefresh (TScreen *screen); +extern int HandleExposure (TScreen *screen, XEvent *event); +extern int char2lower (int ch); +extern int drawXtermText (TScreen *screen, unsigned flags, GC gc, int x, int y, int chrset, PAIRED_CHARS(Char *text, Char *text2), Cardinal len, int on_wide); +extern void ChangeAnsiColors (XtermWidget tw); +extern void ChangeColors (XtermWidget tw, ScrnColors *pNew); +extern void ClearRight (TScreen *screen, int n); +extern void ClearScreen (TScreen *screen); +extern void DeleteChar (TScreen *screen, unsigned n); +extern void DeleteLine (TScreen *screen, int n); +extern void FlushScroll (TScreen *screen); +extern void GetColors (XtermWidget tw, ScrnColors *pColors); +extern void InsertChar (TScreen *screen, unsigned n); +extern void InsertLine (TScreen *screen, int n); +extern void RevScroll (TScreen *screen, int amount); +extern void ReverseVideo (XtermWidget termw); +extern void decode_keyboard_type (struct XTERM_RESOURCE *rp); +extern void decode_wcwidth (int mode); +extern void do_erase_display (TScreen *screen, int param, int mode); +extern void do_erase_line (TScreen *screen, int param, int mode); +extern void init_keyboard_type (xtermKeyboardType, Bool set); +extern void recolor_cursor (Cursor cursor, unsigned long fg, unsigned long bg); +extern void resetXtermGC (TScreen *screen, unsigned flags, Bool hilite); +extern void scrolling_copy_area (TScreen *screen, int firstline, int nlines, int amount); +extern void set_keyboard_type (xtermKeyboardType type, Bool set); +extern void toggle_keyboard_type (xtermKeyboardType type); +extern void update_keyboard_type (void); +extern void xtermScroll (TScreen *screen, int amount); +extern void xtermSizeHints (XtermWidget xw, XSizeHints *sizehints, int scrollbarWidth); + +#if OPT_ISO_COLORS + +extern unsigned extract_fg (unsigned color, unsigned flags); +extern unsigned extract_bg (unsigned color, unsigned flags); +extern unsigned makeColorPair (int fg, int bg); +extern void ClearCurBackground (TScreen *screen, int top, int left, unsigned height, unsigned width); + +#define xtermColorPair() makeColorPair(term->sgr_foreground, term->sgr_background) + +#define getXtermForeground(flags, color) \ + (((flags) & FG_COLOR) && ((int)(color) >= 0 && (color) < MAXCOLORS) \ + ? GET_COLOR_RES(term->screen.Acolors[color]) \ + : T_COLOR(&(term->screen), TEXT_FG)) + +#define getXtermBackground(flags, color) \ + (((flags) & BG_COLOR) && ((int)(color) >= 0 && (color) < MAXCOLORS) \ + ? GET_COLOR_RES(term->screen.Acolors[color]) \ + : T_COLOR(&(term->screen), TEXT_BG)) + +#if OPT_COLOR_RES +#define GET_COLOR_RES(res) xtermGetColorRes(&(res)) +#define SET_COLOR_RES(res,color) (res)->value = color +#define T_COLOR(v,n) (v)->Tcolors[n].value +extern Pixel xtermGetColorRes(ColorRes *res); +#else +#define GET_COLOR_RES(res) res +#define SET_COLOR_RES(res,color) *res = color +#define T_COLOR(v,n) (v)->Tcolors[n] +#endif + +#if OPT_EXT_COLORS +#define ExtractForeground(color) ((color >> 8) & 0xff) +#define ExtractBackground(color) (color & 0xff) +#else +#define ExtractForeground(color) ((color >> 4) & 0xf) +#define ExtractBackground(color) (color & 0xf) +#endif + +#define checkVeryBoldAttr(flags, fg, code, attr) \ + if ((flags & FG_COLOR) != 0 \ + && (screen->veryBoldColors & attr) == 0 \ + && (flags & attr) != 0 \ + && (fg == code)) \ + 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 ClearCurBackground(screen, top, left, height, width) \ + XClearArea (screen->display, VWindow(screen), \ + left, top, width, height, FALSE) + +#define extract_fg(color, flags) term->cur_foreground +#define extract_bg(color, flags) term->cur_background + + /* FIXME: Reverse-Video? */ +#define T_COLOR(v,n) (v)->Tcolors[n] +#define getXtermBackground(flags, color) T_COLOR(&(term->screen), TEXT_BG) +#define getXtermForeground(flags, color) T_COLOR(&(term->screen), TEXT_FG) +#define makeColorPair(fg, bg) 0 +#define xtermColorPair() 0 + +#define checkVeryBoldColors(flags, fg) /* nothing */ + +#endif /* OPT_ISO_COLORS */ + +#if OPT_DEC_CHRSET +#define curXtermChrSet(row) \ + ((CSET_DOUBLE(SCRN_ROW_CSET((&term->screen), row))) \ + ? SCRN_ROW_CSET((&term->screen), row) \ + : (term->screen).cur_chrset) +#else +#define curXtermChrSet(row) 0 +#endif + +extern unsigned getXtermCell (TScreen *screen, int row, int col); +extern void putXtermCell (TScreen *screen, int row, int col, int ch); + +#if OPT_WIDE_CHARS +extern unsigned getXtermCellComb1 (TScreen *screen, int row, int col); +extern unsigned getXtermCellComb2 (TScreen *screen, int row, int col); +extern void addXtermCombining (TScreen *screen, int row, int col, unsigned ch); +#endif + +#if OPT_XMC_GLITCH +extern void Mark_XMC (TScreen *screen, int param); +extern void Jump_XMC (TScreen *screen); +extern void Resolve_XMC (TScreen *screen); +#endif + +#if OPT_WIDE_CHARS +unsigned visual_width(PAIRED_CHARS(Char *str, Char *str2), Cardinal len); +#else +#define visual_width(a, b) (b) +#endif + +#define BtoS(b) ((b) ? "on" : "off") +#define NonNull(s) ((s) ? (s) : "") + +#ifdef __cplusplus + } +#endif + +#endif /* included_xterm_h */ diff --git a/nx-X11/programs/xterm/xterm.log.html b/nx-X11/programs/xterm/xterm.log.html new file mode 100644 index 000000000..d9628696d --- /dev/null +++ b/nx-X11/programs/xterm/xterm.log.html @@ -0,0 +1,6641 @@ + + + + +XTERM - Change Log + + + + +
+Copyright 1997-2004,2005 by Thomas E. Dickey +
+

Contents

+This file contains a list of the changes that I have made for xterm, +from the notes that I add when submitting a patch. +

+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). +Here +is the latest version of this file. + +

+ +

Patch #207 - 2005/11/13 - XFree86 4.5.99.16

+
    +
  • enable lastlogx support for NetBSD (was added, but + not enabled in patch #186). + +
  • work around broken lastlog.h in glibc 2.3.5, which + includes utmp.h. + +
  • revert part of recent XFree86 Imakefile change, restoring the + -I. needed for xmkmf builds of xterm + (XFree86 Bugzilla #1633, reports by Alexander Pohoyda and Matthieu + Herrb). + +
  • change compiled-in default for printerCommand + resource to an empty string. People who want to use the + printer should be able to read the manual (Debian #311490). + +
  • modify Imakefile to work around old problems in + imake configuration to allow test-builds using + xmkmf on Linux. (This was not noticed since several + releases had broken definitions relating to Xft which were harder + to work around). + +
  • link resize for SCO platforms (Kean Johnston). +
+ +

Patch #206 - 2005/11/3 - XFree86 4.5.99.15

+
    +
  • add configure --with-app-defaults option to allow + app-defaults directory for install-rules to be customized. + +
  • remove default translations for dabbrev-expand() + due to conflicts with existing keyboard arrangements. + +
  • remove redundant check for _NET_WM_PID + (report by Emanuele Giaquinta). + +
  • set icon border width explicitly to work around fvwm problem + with active icon resizing (report by Steve Morris, analysis + by Dominik Vogt). + +
  • 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. + +
  • expanded comments in UXTerm.ad regarding the + font resources (Debian #319179). + +
  • add --enable-narrowproto configure option to + accommodate Xorg "modular" build (report by Stephan Hermann, + GenToo #17220). + +
  • fix typo in xterm.man description of +wf (patch + by Tobias Stoeckmann). + +
  • add scrollBarBorder resource (request by Floyd L + Davidson). + +
  • modify xterm-new terminfo entry to use capabilities + for shifted scroll forward/reverse as shifted cursor up/down. + +
  • correct updating of checkmark for toolbar entry in popup menu + (report by Emanuele Giaquinta). + +
  • fix ifdef's to allow compiling with toolbar and without tek4014 + (patch by Emanuele Giaquinta). + +
  • use openpty() for Darwin port (patch by Emanuele + Giaquinta). + +
  • fix GenToo #90697 a different way, postponing the logic in + SetupToolbar until the toolbar is actually needed, + i.e., the +tb option is handled as expected. + +
  • revert fix made in patch #203 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). + +
  • fix a file-descriptor leak when calling openpty() + (OpenBSD system/4561). + +
  • 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 -132 option was not saved. + +
  • restore window manager hints after XtMakeResizeRequest() + calls. One instance from patch #205 + resulted in the window manager displaying pixels rather than + than characters after selecting a different font size (FreeBSD + ports/87424). + +
  • remove special case for Darwin in CF_XOPEN_SOURCE + (Emanuele Giaquinta). + +
  • modify parsing of control sequence CSI T + to allow scroll-down + to be sent while mouse tracking is enabled (request by + D Hugh Redelmeier). + +
  • correct termcap "me" (mode-end) string so it does not modify the + alternate character set (report by Andrey Chernov). + +
  • correct size-comparison in HandleInterpret() broken in changes + from patch #201 to allocate input + buffer (Debian #334317). + +
  • amend adjustments for scrollbar layout from + patch #204 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). + +
  • add select-cursor-extend() action. + +
  • fix some broken href's in xterm.log.html, and typo in the + INSTALL file (report/patch by David Martínez Moreno). + +
  • modify Imakefile to use setgid mode for installing + with Linux, OpenBSD and FreeBSD. + +
  • add configure --with-setuid and --with-reference options to + allow packagers more flexibility in customizing install + permissions. + +
  • generalize and make optional (configure --with-utmp-setgid) + the change made for XFree86 Bugzilla #878 in + patch #205 + (FreeBSD bug report #ports/86663). +
+ +

Patch #205 - 2005/9/18 - XFree86 4.5.99.12

+
    +
  • correct a typo in CF_FUNC_TGETENT introduced in patch #198 fix for Gentoo #69926. + +
  • implement logic in termcap query to process multiple parameters + as documented in ctlseqs.ms + +
  • fix buffer size used for termcap query, which was not long enough + for the terminfo "colors" name (patch by Bradd W. Szonye). + +
  • add configure option --enable-readline-mouse, which turns on the + experimental OPT_READLINE code (patch by Ilya Zakharevich). + +
  • for FreeBSD, drop setuid privileges after startup + (XFree86 Bugzilla #878, report/patch by Alexander Pohoyda) + +
  • add menu entry (alt-esc) and corresponding action (alt-sends-esc) + to toggle the eightBitInput resource setting. + +
  • generate configure script with autoconf 2.52 (patched) to use + the feature therein which forces the script's locale to POSIX + (Gentoo Bugzilla #105369). + +
  • 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). + +
  • modifications to work with z/OS 1.4 (Paul Giordano). + +
  • 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). + +
  • patches from Emanuele Giaquinta: +
      +
    • ctlseqs.ms says that primary and secondary DA accept a + nonzero parameter, which is incorrect. Also modify code + to agree with this. + +
    • correct a comment in 88colres.pl + +
    • 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. + +
    • update the menu entries for the metaSendsEscape, deleteIsDEL + and numLock resources when changing them with the corresponding + DEC Set/Reset control sequences. +
    + +
  • fixes for configure script: +
      +
    • add special case for QNX, defining _QNX_SOURCE. +
    • check for preprocessors which do not perform -U and -D options + in the given order. +
    • improve macro to determine gcc version +
    • improve check for Intel compiler and related warning options +
    + +
  • update config.guess, config.sub + +
  • improve fix from patch #198 for + Cleanup() by ensuring it is not called from the + SIGCHLD handler (patch from OpenBSD by Todd Miller). + +
  • eliminate a retry for a better-matching bold font, to work around + recent font server changes. + +
  • fixes for Novell #113277: +
      +
    • specify weight for wide font which may be derived from + normal fontname. +
    • cache the derived wide- and widebolt-fontnames. +
    + +
  • workaround for GenToo Bugzilla #100728. + +
  • add menubar's border width to layout computation. Normally this + is zero, but patterns such as XTerm*borderWidth:1 + would give poor layout for the toolbar configuration. +
+ +

Patch #204 - 2005/8/4 - XFree86 4.5.99.9

+
    +
  • 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). + +
  • disallow changes to fonts, toolbar and scrollbar when the vt100 + window is iconified, to simplify management of the active icon. + +
  • fixes to make -geom option work properly with the + toolbar configuration (Gentoo Bugzilla #90717, #91967). + +
  • minor improvements to scrollbar layout: ensure that the scrollbar + border is zero if the vt100 border is zero. + +
  • improve initialization due to utf8 resource by + loading the utf8Fonts resource in the case where + locale resource is false. Also in this case, do + not disable switching UTF-8 mode on/off. + +
  • minor optimization of TrueType font-loading, loads italic font + only when needed. + +
  • 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). + +
  • add checks to ensure vt100 widget is realized when it might be + updated via actions handled from a tek4014-only configuration. +
+ +

Patch #203 - 2005/7/6 - XFree86 4.5.99.7

+
    +
  • modify initialization of allowSendEvents and + allowWindowOps to prevent modification with the + editres protocol. + +
  • fix compiler warning for NetBSD by including util.h in main.c + (XFree86 Bugzilla #1596). + +
  • fix to build on Darwin 8.x, which no longer provides + setpgrp() (patch by Min Sik Kim). + +
  • adapted fixes for Legend (SCO) from diffs attached to + Freedesktop.Org Bugzilla #3180. + +
  • fix typo in xterm manpage description of -ls option + (Freedesktop.Org Bugzilla #3543). + +
  • add support for interpreting the underline attribute as an italic + font in Xft mode (patch by Chuck Blake). + +
  • 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). + +
  • fix logic in find_utmp, which did not reset result + in getutid(), causing an infinite loop in some + conditions (report by Emil Mikulic). + +
  • set the _NET_WM_PID property (GenToo Bugzilla #91008). + +
  • modify ifdef's in ptyx.h and xterm_io.h to build with DragonFly + (patch by Jeroen Ruigrok). + +
  • change default values for minBufSize and + maxBufSize to 4096 and 32768 respectively so that the + initial read request will match the value from before changes to + use sched_yield(). + +
  • make paste of UTF-8 faster for Western character sets by checking + range of incoming data (patch by Joe Allen). + +
  • adapted patch by Joe Allen to add experimental option to allow + applications to get or set the selection data. + +
  • fix an off-by-one error parsing -S/nn option + (Debian #311438, report/fix by Peter Chubb). + +
  • fix an initialization bug from + patch #201 that broke logging + (report by Rodney Thayer). + +
  • amend change to command-line processing in + patch #201 to avoid + conflict with -e option (report by Servatius Brandt). + +
  • suppress configure check for _XOPEN_SOURCE on + darwin. + +
  • update config.guess, config.sub +
+ +

Patch #202 - 2005/5/2 - XFree86 4.5.99.3

+
    +
  • add extended shift- and control-modifier cursor keys to + "xterm+pcfkeys" terminfo entry to correspond to ncurses 20050430 + patch. + +
  • 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). + +
  • rename $CMD variable in plink.sh because + it is a reserved symbol in bash 3.00.16 (report by Ted Taylor). + +
  • add environment variables $XTERM_SHELL and $XTERM_VERSION + (request by Zdenek Sekera). + +
  • 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. + +
  • correct an error in the logic which decides when + sched_yield() is run; it would occasionally hang when + contending with other pseudo-terminal applications such as screen + (report by Kirill Ponomarew). + +
  • modify initialization to decide whether to default to built-in + wcwidth() versus system's version based on the + starting locale and whether the system's version is poor quality + (suggested by Bram Moolenaar). + +
  • update table for mk_width() from UnicodeData 4.1.0 + using Markus Kuhn's uniset script. +
+ +

Patch #201 - 2005/4/21 - XFree86 4.5.99.2

+
    +
  • improve resource files to show how the menubar and popup menus can + be colored (prompted by report by Joe Wells). + +
  • 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). + +
  • improved some of the built-in line-drawing glyphs. + +
  • correct color of "box" character drawn for line-drawing glyph 1 + (report by Nicolas George). + +
  • 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 + utf8Fonts subresource to load appropriate fonts + (request by Bram Moolenaar). + +
  • modify logic for setting title-string so it applies to the current + widget rather than the vt100 widget. + +
  • modify initialization for wide-bold fontname, to search for one + if none is given (report by Michael Schroeder). + +
  • add resource mkWidth and command-line option + -mk_width to control whether xterm uses the built-in + version of wcwidth(). + +
  • add resource settings for minimum/maximum input buffer size, and + call to sched_yield to improve performance with newer + Linux kernels (adapted from patch by Nicolas George). + +
  • correct computation of width for wide characters with the invisible + attribute (report by Thomas Wolff). + +
  • modify interaction between +u8 and locale + resource to allow the command-line option to override the resource + (requested by Thomas Wolff). + +
  • add a limit check for scrolling margins in a one-line screen, + overlooked in fixes for + patch #198 (Debian #297430). + +
  • correct treatment of iconBorderWidth for resizing + an active-icon, and its description in manpage (Debian #296592). + +
  • modify configure script --disable-imake to use the + script's definitions anyway if it cannot detect imake (prompted + by FreeBSD bug 77408). + +
  • ignore error in the I/O initialization that tries to set the + tty to 7-bit input for the case where eightBitInput + resource is false (Debian #298551). + +
  • modify command-processing to accept an optional parameter that + tells xterm which shell program to use (request by Zdenek Sekera). + +
  • add simpler resource keyboardType which, when set, + overrides the individual keyboard-type resources and eliminates + the possibility of conflict between them. + +
  • add initialization for scoFunctionKeys resource + (report by Rick K). + +
  • correct logic of ReallocateBufOffsets() 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): + +
  • 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): + +
  • add command-line options (-tb, +tb) and + resource toolBar to allow menu/toolbar to disabled or + enabled at startup (prompted by reports by Joe Wells). + +
  • correct typo in configure script's --enable-dec-locator option + (report by Bram Moolenaar). +
+ +

Patch #200 - 2005/2/6 - XFree86 4.4.99.23

+
    +
  • increase color pairs value for xterm-256color and xterm-88color to + match ncurses, which has an experimental option to support this. + +
  • modify ifdef's to make AIX use termios rather than termio; the + struct sizes for the two were not the same. + +
  • improve CF_WITH_IMAKE_CFLAGS configure macro script for + OSMAJORVERSION and OSMINORVERSION values, e.g., for Tru64 and AIX. + +
  • modify ifdef to define USE_POSIX_TERMIOS for Darwin (patch by Min + Sik Kim). + +
  • 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. + +
  • add configure check before adding -D_POSIX_SOURCE since some + platforms predefine it, e.g., cygwin. + +
  • add simplified sed expressions in CF_IMAKE_CFLAGS configure script + macro to ensure value for PROJECTROOT is quoted on Solaris, i.e., + when nested \( and \) are not interpreted + correctly. + +
  • correct DEC rectangle operations to reset state after completing + the operations. + +
  • 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). + +
  • fix OS/2 build for innotek_libc (patch by David Yeo). + +
  • fix a regression from patch #197 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). + +
  • move the warning/exit for missing $DISPLAY into the error handler + in case -display is given, and the connect fails for + some other reason. +
+ +

Patch #199 - 2005/1/17 - XFree86 4.4.99.22

+
    +
  • instead of setting $DISPLAY, check for the unset + variable and warn/exit on this condition (comments by H Merijn + Brand and Bernhard R Link). + +
  • fix a typo in Imakefile from patch #198 + (reports/patches by Stefan Dirsch, and Mike Castle). +
+ +

Patch #198 - 2005/1/13 - XFree86 4.4.99.21

+
    +
  • set $DISPLAY to ":0" if it is not set. + +
  • add utmpDisplayId 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). + +
  • add bellOnReset resource to allow users to disable + bell which sounds on hard reset since patch + #183 changes to DECSCL (discussion with Danek Duvall). + +
  • improve $WINDOWID 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 $WINDOWID + not very useful as a parameter for xwininfo + (suggested by Dave Bodenstab). + +
  • fix a typo in WhichVFont() macro + from patch #197 changes + which broke the --disable-active-icon configuration + (report by Ralf S. Engelschall). + +
  • improve some limit checks (Gentoo Bugzilla #75604). + +
  • add --disable-setuid option to configure script (Gentoo Bugzilla + #76543). + +
  • add --disable-full-tgetent option to configure script, allowing one + to ignore a termcap library in favor of ncurses/curses (Gentoo + Bugzilla #69926). + +
  • modify configure script to choose useful warning options for Intel + version 8.0 compiler. + +
  • update config.guess, config.sub + +
  • make active-icon work properly when TrueType fonts are used + (Debian #286068). + +
  • correct change from patch #157 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). + +
  • correct case of SCS for character set 0 (line-drawing) to allow it + to be selected into GR. + +
  • fix a file-descriptor leak (Redhat Bugzilla #139597). + +
  • modify creat_as() 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). + +
  • modify Cleanup() to avoid operations such as X calls + that might use unsafe functions when it is called by a signal + handler (report by Michiel Boland). + +
  • fix bugs in patch #191 and in SRM changes + from patch #197 that + broke DECSET 38: switch to Tek4014 emulation (report by Dave + Bodenstab). + +
  • fix for manpage escapes (Marc La France). + +
  • 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 +
+ +

Patch #197 - 2004/11/30 - XFree86 4.4.99.19

+
    +
  • modify configure script to remove empty "-DPROJECTROOT=" definition + which resulted unusable values for luit's default path. + +
  • update precompose.c based on Unicode 4.0.1 + +
  • several minor fixes based on Intel compiler warnings. + +
  • change default translations so a BtnDown 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). + +
  • note in xterm's manpage that translations is not + specific to xterm (Debian #278897). + +
  • modify uxterm script to use locale program to verify if the + derived locale is installed (Debian #246398). + +
  • correct font handling for active icon when in UTF-8 mode (report + by Paolo Liberatore). + +
  • make active-icon and toolbar configurations work together. + +
  • 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). + +
  • reimplement DECALN with functions for vt420 rectangles, + fixes selection for this case. + +
  • implement vt420 rectangle operations. + +
  • add parsing, for debug/test of vt220 soft-fonts. + +
  • add menu entry, actions and escape sequence to allow + enabling/disabling toolbars at runtime. + +
  • improve rendering for Xft, allow it to draw non-linedrawing + characters such as "pi", which were drawn from internal tables + with patch #180 + (Freedesktop.org Bugzilla #1260). + +
  • add configure option --enable-mini-luit, ifdef'd the + mini-luit feature with OPT_MINI_LUIT. + +
  • 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). + +
  • 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). + +
  • modify faceSize resource to use a floating-point + internal value (adapted from patch by Sam Stephenson). + +
  • 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). + +
  • amend fix for infinite loop from patch + #192 to check if there is wrapped text to output in a following + iteration (Debian #273202). + +
  • fixes ifdef'd with __INTERIX to allow building with + Interix (Windows Services for UNIX) 3.5 using the xlibs libraries + from freedesktop.org (patch by Min Sik Kim). + +
  • amend solution for Debian #252873, #260471 from patch #194 by making the cursor not + explicitly colored if only the foreground color is set, and the + cursor is on a blank space (Debian #275473). + +
  • correct logic for send/receive mode (SRM) with regard to control + characters. + +
  • fix masking of invisible text in wide-character mode, which did + not work for line-drawing characters. + +
  • incorporate CF_XOPEN_SOURCE into configure script, replacing + CF_GNU_SOURCE. +
+ +

Patch #196 - 2004/8/15 - XFree86 4.4.99.12

+
    +
  • add a special case to configure script to ignore NetBSD's + grantpt() 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). + +
  • clear the buffer returned by getutid(). This fixes an infinite + loop on some platforms introduced in patch + #193 by Debian #256468 fix (report by David Ellement). +
+ +

Patch #195 - 2004/8/8 - XFree86 4.4.99.11

+
    +
  • correct length used for blinking text, make the last column blink + (patch by Alexander V Lukyanov). + +
  • start changes to make doublesize characters work with TrueType + fonts (see patch #44). + +
  • trim leading/trailing blanks from color resources as done for + other strings in patch #167. + +
  • fixes for showBlinkAsBold resource (report by + Christoph Berg). +
+ +

Patch #194 - 2004/7/27 - XFree86 4.4.99.11

+
    +
  • 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). + +
  • 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. + +
  • fix a case where a full-screen indexing operation would + not restore the cursor-busy state. + +
  • fix a repainting bug introduced in + patch #180: 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). + +
  • rename terminfo fragment "xterm-pc-fkeys" to "xterm+pcfkeys" for + consistency with ncurses. +
+ +

Patch #193 - 2004/7/19 - XFree86 4.4.99.10

+
    +
  • fix for wide-character selection from OpenBSD CVS + (report/patch by Matthieu Herrb). + +
  • modify initialization and cleanup of utmp data to also compare + the ut_line member (Debian #256468). + +
  • modify check on focus-change to ignore FocusOut events + generated by XGrabKeyboard. This fixes a case where + the text cursor would act as if focus were lost when selecting the + "Secure Keyboard" menu option. + +
  • add gen-pc-fkeys.pl script, use that to generate + terminfo fragment corresponding to the pc-style function keys. + +
  • fix a case where the checkmark by the "VT220 Keyboard" menu entry + was not set on startup. + +
  • 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. + +
  • modify logic for enabling blinking cursor via escape sequence as + well as the related save/restore operations so this is only + available if the cursorBlink resource was set on + startup. +
+ +

Patch #192 - 2004/7/12 - XFree86 4.4.99.9

+
    +
  • change resource settings for color4 and color12, add some discussion + in XTerm-col.ad (Debian #241717). + +
  • add a note in xterm manpage discussing the difference between + alt- and meta-keys, and the way the latter is used in the + eightBitInput resource. + +
  • add a note in xterm manpage regarding possible conflict between + resource settings for xterm.vt100.font and + xterm.vt100.utf8Fonts.font (Debian #254650). + +
  • add compile-time customization of backarrowKeyIsErase + and ptyInitialErase default resource values + (adapted from OpenBSD CVS). + +
  • change parameter of FIONREAD ioctl() call + from long to int + (discussion on tech-x11@netbsd.org regarding LP64 by + John Heasley and Matthias Scheler). + +
  • modify configure script options for Athena widgets to work as + expected for "--without-Xaw3d", etc., (GenToo Bugzilla #53455). + +
  • add case to uxterm to accommodate locales ending with "@euro", + e.g., fr_FR.UTF-8@euro (Debian #255197, report/analysis by + Matthieu Lagouge). + +
  • add special case for VT100 graphic's "box" character (discussion + with Ben Armstrong). + +
  • add missing initialization for bitmap-font sizes needed to make + fonts menu work with TrueType fonts (report by Ben Armstrong). + +
  • save the fontnames for bold fonts that are derived from normal + fonts, or from the boldFont resource, so the same + value is restored when switching with the VT Fonts menu (Debian + #256086). + +
  • fix manpage preprocessing (Marc La France). + +
  • fix typo in manpage's description of character classes (Debian + #257073). + +
  • modify terminfo to accommodate luit, which relies on G1 being used + via an ISO-2022 escape sequence (Debian #254316, analysis by + Juliusz Chroboczek). + +
  • modify Makefile.in rule for ctlseqs.txt to work around groff SGR + misfeature. + +
  • modify XTerm.ad to set saveLines default + to 1024 (Redhat Bugzilla #127132). + +
  • add a limit-check in dotext() to prevent infinite + loop in a corner case of UTF-8 configuration. + +
  • update config.guess, config.sub +
+ +

Patch #191 - 2004/6/6 - XFree86 4.4.99.7

+
    +
  • correct options parsing for -into option so it + can be combined with -e (Redhat Bugzilla #124518, + report/patch by James Armstrong). + +
  • fix ifdef's for OPT_COLOR_RES2 + so that the fake resource table introduced in + patch #188 + is not compiled if it is empty. + This happened to work with gcc (report by Joel Konkle-Parker). + +
  • 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. + +
  • work around change in quoting of PROJECTROOT symbol when using + configure script, from changes made in + patch #187 for CF_IMAKE_CFLAGS + (GenToo Bugzilla #50982). +
+ +

Patch #190 - 2004/5/25 - XFree86 4.4.99.6

+
    +
  • 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 allowC1Printable resource (reported by + Simon Strandgaard). + +
  • add configure-script check for nl_langinfo(CODESET), use this to + replace check of environment variables for UTF-8. + +
  • 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. + +
  • remove check in configure script --enable-toolbar that suppressed + this option when building with Xaw7. + +
  • apply fixes to Tektronix widget used for VT100 widget to make + toolbar work with Xaw7 (XFree86 4.x). +
+ +

Patch #189 - 2004/5/16 - XFree86 4.4.99.6

+
    +
  • do not call xim_real_init() if openIm resource is + false (Debian #249025). + +
  • minor improvements to built-in line-drawing. + +
  • fix a few portability issues with dynamic abbreviation support, + i.e., did not compile on Tru64. + +
  • modify constraints in form used to layout toolbar, to work with + newer Xaw in XFree86 4.x. +
+ +

Patch #188 - 2004/5/12 - XFree86 4.4.99.6

+
    +
  • correct table entry for DEL in the ground state, which marked it + as a printable character from patch #171 + (report by D Hugh Redelmeier). + +
  • improve fix in patch #186 for failure in + xim_real_init() by adding a sleep. + +
  • fix a typo in os2main.c + (XFree86 Bugzilla #1358, report/patch by Frank Giessler). + +
  • 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). + +
  • 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). + +
  • remove ncv from xterm-256color terminfo + entry since it is no longer needed (report by Eli Zaretskii). + +
  • add "erase2" and "eol2" keywords to ttyModes resource, + for recent/current FreeBSD. + +
  • improve ifdef's for utempter library to omit direct calls to + setutent() or getutent() (adapted from + patch by Christian Biere). + +
  • add dynamic abbreviation support like Emacs (patch by Tomasz + Cholewo). This is ifdef'd with OPT_DABBREV, and + enabled via the configure script --enable-dabbrev + option. + +
  • fix problem responding to session management events, e.g., which + would make logging out very slow (patch by Eddy De Greef, Debian + #233883). + +
  • 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). + +
  • modify xtermAddInput to work around core dump on + IRIX64 when initializing scrollbar translations if toolbar is + compiled-in. + +
  • fix some minor conflicts in the 2-character entry names in the + termcap file. +
+ +

Patch #187 - 2004/4/27 - XFree86 4.4.99.4

+
    +
  • change xterm version string to use __vendorversion__ + where that is available, and "XTerm" otherwise. + +
  • improve description of utf8 resource in manpage + (Debian #179407). + +
  • modify configure macros CF_IMAKE_CFLAGS and CF_ADD_CFLAGS to + handle -D options that define string values, e.g., + for XVENDORNAME. + +
  • modify configure macro CF_IMAKE_CFLAGS to allow (if + $PATH is set accordingly) to use the + xmkmf script within an X build tree. + +
  • add missing #undef OPT_SESSION_MGT to xtermcfg.hin + to make the configure script's --disable-session-mgt option work. + +
  • update config.guess, config.sub +
+ +

Patch #186 - 2004/4/18 - XFree86 4.4.99.4

+
    +
  • change reset on DECSCL to a soft-reset (appears some + DEC manuals have errors). + +
  • add a section to ctlseqs.ms elaborating on normal/alternate screens. + +
  • 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 colorBD and similar resources which normally have + no explicit color assigned. + +
  • modify initialization of Tektronix window so that control sequences + setting its color before the window is popped up will apply to + its initial colors. + +
  • add control sequence to set Tektronix window's text-cursor. + +
  • modify initialization of terminal colors, e.g., mouse pointer and + text cursor, to treat XtDefaultForeground and + XtDefaultBackground values as the actual foreground + and background colors of the terminal rather than white and black + (Debian #241717). + +
  • remove an incorrect comparison against PTYCHARLEN in + parsing the -S option (report by Michael B Taylor). + +
  • minor restructuring of terminfo/termcap files, having noted some + packager's customizations which caused the structure to be + confused. + +
  • eliminate an isolated use of MIN/MAX in charproc.c + +
  • replace XtExtdefaultfont and + XtExtdefaultbackground by their more familiar + equivalents + XtDefaultFont and + XtDefaultBackground. + +
  • replace ifdef's using SCO, sco and + SCO325 with __SCO__ + (XFree86 Bugzilla #1301, Kean Johnston). + But ensure that it still builds on platforms where this symbol + is not defined. + +
  • add scoFunctionKeys resource, to match manpage. + +
  • update manpage discussion of menus and related resources. + +
  • enable utmpx support for NetBSD 1.6C and newer (patch by + Matthias Scheler). + +
  • add a note in the manpage discussing xterm's treatment of open + file-descriptors (request by Dan Shearer). + +
  • modify Help() to make "xterm -h" write to standard + output rather than standard error (patch by Bram Moolenaar). + +
  • 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 + patch #175 (XFree86 Bugzilla #1306). + +
  • modify Imakefile to remove dependency of "install" + target on the xterm executable to make installs from + tree without attempting to rebuild anything (David Dawes, based on + a patch and report from Lee Olsen). + +
  • remove call to ShowCursor from + SetCursorBlink() since that is redundant, + and can cause display glitches if the cursor is already + blinking (XFree86 Bugzilla #1158, patch/report by Andreas Schwab). +
+ +

Patch #185 - 2004/3/3 - XFree86 4.4

+
    +
  • fix tcap-query logic for the backspace key (XFree86 Bugzilla #1233, + report/patch by Anton Kovalenko). + +
  • add test-scripts resize.pl and tcapquery.pl + +
  • 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). + +
  • modify RequestMaximize(), which performs maximize/restore via + control sequences, to account for window-frame (patch by + Jess Thrysoee). + +
  • improve pattern used in uxterm to check for UTF-8 + locale, e.g., for HPUX (patch by H Merijn Brand). + +
  • add -fd option and resource + faceNameDoublesize to specify double-wide fonts with + Xft (adapted from patch by Zarick Lau). + +
  • change a couple of resource classes from "Boolean" to specific + values: freeBoldBox, forceBoxChars. + +
  • add resource showMissingGlyphs to outline places on + the screen where a font lacks the corresponding glyph. + +
  • add resource showBlinkAsBold to control whether + blinking text should be shown as bold or actual blinking text. + +
  • 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. + +
  • implement blinking text, using the timer for blinking cursor. + +
  • 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. + +
  • add menu items and corresponding actions for switching on/off + the UTF-8 mode and Xft (TrueType) support. + +
  • 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). + +
  • modify to allow turning UTF-8 mode on/off via escape sequence even + if -wc option was not given at startup (patch by Peter + Berg Larsen). + +
  • amend fix for XFree86 Bugzilla #981, adjusting for savedlines value + (report by Tim Adye). + +
  • fix a typo in computing relative font size (Jess Thrysoee). +
+ +

Patch #184 - 2003/12/31 - XFree86 4.3.99.903

+
    +
  • improve configure-script checks for FreeType and related libraries, + using xft-config or freetype-config + scripts when available. + +
  • fix configure-script check for SYSV definition by + ensuring whether sys_errlist[] is declared, and by + modifying the test program to include X11/Intrinsic.h + to check that wchar_t is declared consistently (report + by H Merijn Brand). +
+ +

Patch #183 - 2003/12/26 - XFree86 4.3.99.903

+
    +
  • 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 patch #145 + (XFree86 Bugzilla #997, report/patch by Kean Johnston). + +
  • modify handling of eightBitInput 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). + +
  • modify uxterm script to interpret help and version + options so xterm does not always create a window when the user + requests this information (Debian #223926). + +
  • add a limit check to ScrnTstWrapped() (XFree86 Bugzilla #981). + +
  • modify DECSCL to perform a hard reset (RIS) as per DEC manuals. + Extended DECSCL to accept parameters for vt4XX and vt5xx terminals. + +
  • correct logic for ANSI conformance level escape sequences, which + were confused with DEC conformance level escape sequences. + +
  • correct state for vt52 shift-in/shift-out, which was not reset + properly after patch #171. + +
  • correct handling of graphics characters for vt52 mode, which did + not display line-drawing characters after G1 fix from + patch #182. + +
  • fixes for configure script to work with current Cygwin headers + and libraries. + +
  • modify Imakefile to put the current directory at the + beginning of the include searchpath (David Dawes). +
+ +

Patch #182 - 2003/12/2 - XFree86 4.3.99.901

+
    +
  • correct logic for metaSendsEscape 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). + +
  • 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ürgen Keil). + +
  • improve manpage description of resources, in particular the + utf8Fonts class (XFree86 Bugzilla #905). + +
  • add definitions to compile with glibc-based GNU/Hurd, GNU/KFreeBSD + and GNU/KNetBSD (XFree86 Bugzilla #893). + +
  • compiler-warning fixes (patch by Christian Biere). + +
  • add README.i18n (Tomohiro KUBOTA). + +
  • 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 patch #34 regarding DECSTR). + +
  • correct ifdef in main.c for variable utret (patch by + Bernhard Rosenkraenzer). + +
  • document in xterm's manpage how to use XFree86 ":unscaled" keyword + to suppress scaling of bold fonts. + +
  • 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). +
+ +

Patch #181 - 2003/10/26 - XFree86 4.3.99.15

+
    +
  • implement boldMode for wide-character logic in + drawXtermText() (report by Michael Schroeder). + +
  • modify UXTerm.ad resource file to include + "XTerm-color" rather than "XTerm", in case the latter file contains + no color resource definitions, e.g., after patch #180. + +
  • add action load-vt-fonts() and configure option + --enable-load-vt-fonts which allows users to define + additional sets of VT-fonts which can be loaded at runtime. + +
  • add logic to wide-character support which attempts to load fonts + specified by utf8Fonts subresources at startup. The + subresources have the same names as the fonts which they replace, + e.g., font, font1, etc., so that the + ISO-10646-1 fonts can be specified in the XTerm + app-defaults file (this is an adaptation of a patch by Tomohiro + KUBOTA). + +
  • 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. + +
  • simplify parameter passing for the set-vt-font action + and related code. + +
  • cleanup some include-ordering, moving some recently-added hardcoded + stuff into xterm.h where it will not interfere with the configure + script. + +
  • modify xtermAddInput() (see note on augmentation in patch #158) 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). + +
  • make save/restore mode controls apply to show/blink cursor states. + +
  • add escape sequence to start/stop blinking cursor, which allows + implementing cvvis terminfo capability (request by + Nate Bargmann). + +
  • add indp and rin to terminfo entry. + +
  • fix an out-of-bounds array reference in ScrnRefresh() for wide + characters (report by Dan Harnett, patch by Todd Miller, bug dates + from patch #141). +
+ +

Patch #180 - 2003/10/12 - XFree86 4.3.99.15

+
    +
  • several fixes for rendering using Xft (option -fa): +
      +
    • translate Unicode values (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). +
    • pass 16-bit values rather than 8-bit values to + xtermXftDrawString() to allow for wide-characters. +
    • remove spurious check for colorBDMode resource in + logic that does bold fonts. +
    • implement underlining. +
    + +
  • patches by Ilya Zakharevich: +
      +
    • improve drawXtermText() by making the recursive calls + communicate through arguments, and not through saving/restoring + global variables. + +
    • make double-width characters work with -u8 option. + +
    • modify lookup of double-sized fonts by checking for a match + ignoring x/y resolution if the first check fails. +
    + +
  • make height of TrueType fonts match ascent+descent (patch by + Keith Packard). + +
  • correct configure-script check for imake $CFLAGS, which did not + check properly if imake was not available. + +
  • correct install rule in Makefile.in for uxterm, which + was attempting to strip the script (newsgroup posting by Fernan + Aguero). + +
  • correct AF/AB strings in termcap for xterm-256color and + xterm-88color entries (report by Josh Howard). + +
  • update wcwidth.c to incorporate changes from Markus Kuhn's + 2003-05-20 (Unicode 4.0) version of that file. + +
  • modify scroll-back and scroll-forw + actions to accept an adjustment value, e.g., +
    +	      scroll-back(1, page-2)
    + to scroll back by 2 lines less than a page (patch by Greg + Klanderman). + +
  • use color resource setting from Debian package for xterm VT100 widget, + since the choice of blues provides better contrast. + +
  • remove color resources from XTerm.ad, leaving them + only in XTerm-col.ad (prompted by Debian package for + xterm). + +
  • correct configure script option --enable-pty-handshake (report by + Paul Gilmartin). + +
  • add visualBellDelay 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). + +
  • correct logic for initializing dynamic highlight color (patch by + Jess Thrysoee). + +
  • add a check for non-zero size in call to XCopyArea() + to accommodate a Solaris bug. + +
  • correct typo in example for character classes in xterm manpage + (Debian #198910). + +
  • 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). + +
  • modify configure script to avoid using "head -1". + +
  • update config.guess, config.sub + +
  • modify ifdef's to work around inclusion of types FcChar32 and + XftCharSpec with FreeType 2.0 (see patch #175). + +
  • modify the predictable version of the generated logfile name (see + patch #171) to append the process-id rather + than a random value. + +
  • resync with XFree86 CVS: +
      +
    • Enable SCO function keys in xterm +
    • Make Delete key send DEL by default on SCO in xterm +
    +
+ +

Patch #179 - 2003/5/21 - XFree86 4.3.99.5

+
    +
  • modify ifdef's for WTMPX_FILE to allow building on cygwin again. + +
  • change the default of pty-handshaking configure option (and related + default for imake) to assume this feature is needed. + +
  • add ifdef's so configure option for XawPlus library works (patch + by Pavel Roskin). + +
  • add $(MAIN_DEFINES) 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. + +
  • add configure check for ".exe" suffix on cygwin. +
+ +

Patch #178 - 2003/5/18 - XFree86 4.3.99.5

+
    +
  • modify default for configure --enable-pty-handshake + option to enable it for Solaris (report by Nelson Beebe). + +
  • modify in_put() function to call + PreeditPosition() 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). + +
  • improved explanation of -ls conflict with + -e option in xterm manpage (adapted from comments by + Henning Makholm). + +
  • correct comment in terminfo file regarding modifier used for + kDC (Debian #189764, report by Henning Makholm). + +
  • correct/extend some of the keypad description in ctlseqs.ms + (report by Henning Makholm). + +
  • correct keypad-mapping table in input.c so XK_KP_Equal + works (report by Henning Makholm). + +
  • 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 <jshin@mailaps.org>). + +
  • add configure option --enable-broken-osc and resource + brokenLinuxOSC 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 OSC, but are fixed-length, with no terminator. + +
  • add configure option --enable-broken-st and resource + brokenStringTerm to allow + user to revert one part of the parsing table corrections from + patch #171. (reports by + Matthias Scheler and + Kirill Ponomarew indicate that someone's + network firmware sends an <escape>X). + +
  • modify configure --disable-imake to provide values + for OSMAJORVERSION, OSMINORVERSION, + FUNCPROTO and NARROWPROTO (report by + Heiko Schlichting). + +
  • correct vttests/16colors.sh, which omitted the + $SUF variable in output strings (patch by Paul + Gilmartin). + +
  • modify shell scripts in vttests directory to attempt + to use named signals in the trap statement, making + this portable to OS/390 (report by Paul Gilmartin). Tested on + SunOS 4.1.4, which implements only numbers. +
+ +

Patch #177 - 2003/3/23 - XFree86 4.3.0

+
    +
  • fix definition of USE_HANDSHAKE, must be numeric + (reported by Jens Schleusener). +
+ +

Patch #176 - 2003/3/22 - XFree86 4.3.0

+
    +
  • add configure option --enable-pty-handshake to allow + one to compile-in support for the pty handshaking logic, and + resource ptyHandshake to enable or disable it + (suggested by Ian Collier). + +
  • restore USE_HANDSHAKE ifdef removed in + patch #159 + to address Debian #39964. + +
  • move ifdef's for ttysize/winsize into xterm_io.h + +
  • simplify loop on tgetent, 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). + +
  • correct manpage discussion of $TERM and + $TERMCAP variables, which omitted the Tektronix + emulation and a note of the final "dumb" fallback. + +
  • broaden ifdef for XRegisterIMInstantiateCallback() + from patch #175 (XIM fix) to exclude + non-XFree86 (report by Nelson Beebe indicates this breaks for + Solaris, IRIX and OSF/1). + +
  • correct resource-size for iconFont (this was added + by X11R6.3). + +
  • improve configure check for XKB bell extension, to work around + inconsistent implementation of this feature (reports by Nelson + Beebe, Kriston Rehberg and David Ellement). + +
  • modify configure-check for tty group to be less + strict in batch mode (report by Nelson Beebe). + +
  • modify to allow building with g++, to use its compiler warnings + (suggested by Nelson Beebe). + +
  • modify dec2ucs[] table to reflect newer codes + available for scanlines 1, 3, 7, 9 (report by Michael Schroeder). + +
  • add configure option for XawPlus library. +
+ +

Patch #175 - 2003/3/9 - XFree86 4.3.0

+
    +
  • fix a SIGSEGV which could occur if xterm is connecting to XIM + server, and the XIM server is destroyed (patch by Nam SungHyun). + +
  • modify to use built-in line-drawing characters for Xft fonts + (patch by Andrew Tipton). + +
  • make menu reflect the state of the tekInhibit + resource. + +
  • make signalInhibit 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). + +
  • changed classes of colorBDMode and similar + resources that override colors when a video attribute is + set to ColorAttrMode, to make them distinct + from ColorMode. This avoids an unexpected + rendering of reverse video, for example (report by Paul Fox). + +
  • changed class of veryBoldColors to + VeryBoldColors, since + ColorMode is associated with boolean resources. + +
  • add option -k8 and resource + allowC1Printable 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. + +
  • add a null-pointer check for return-value of ptsname() + in HPUX-specific code (report by David Ellement). + +
  • revise the ifdef's used for XKB bell support. The + code was using a nonstandard call XkbStdBell(). + Changed to use XkbBell() (based on patch by + <derek@signalmarketing.com>). + +
  • add a null-pointer check in xtermLoadFont() in case + there is no wide-bold font (Nam SungHyun). + +
  • change Makefile.in to use autoconf's + bindir, libdir and mandir + variables (report by Nam SungHyun). + +
  • add le to termcap xterm-basic entry. + Though missing from older termcaps for xterm, some applications + check for it (report by Matthias Buelow). + +
  • modify uxterm script to strip modifiers such as "@euro" + from the locale setting before adding ".UTF-8" (Debian #179929). + +
  • modify the remaining places where tek4014 emulation uses + XDefineCursor(), 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. +
+ +

Patch #174 - 2003/2/25 - XFree86 4.2.99.903

+
    +
  • work-around for XFree86 bug which made XDefineCursor() + on a shell-window no longer work. The tek4014 emulation used this. + Use the next lower window (report by Karl Rudolf Bauchspiess). + +
  • add a resource setting allowWindowOps 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. +
+ +

Patch #173 - 2003/2/6 - XFree86 4.2.99.902

+
    +
  • reset mouse mode to normal on a full reset. This does not apply + to mouse hilite tracking mode, of course (see ctlseqs.ms). + +
  • 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). + +
  • check for illegal character in DECUDK string, quit if detected. +
+ +

Patch #172 - 2002/12/27 - XFree86 4.2.99.3

+
    +
  • fixes to make repainting of 256-color example work properly + (reports by Abigail Brady and Scott A Crosby). +
      +
    • set flag in AllocateAnsiColor() to ensure the color + is allocated once only. +
    • fix check in ScrnRefresh, which was comparing + background colors only if the ANSI foreground colors also were set. +
    + +
  • merge Error() calls and some exit() calls + into SysError(), and change that to add the brief + explanation for each error code which is provided in the manpage. + Change a few SysError(), calls to avoid using code 1, to + avoid confusion with exit status from places that do not use + SysError(). + +
  • simplify logic used to open a debug logfile as the standard error. + +
  • modify the -e option so that if it fails, xterm will + check if only one argument follows, e.g., it was quoted, and then + retry using sh -c. + +
  • modify parsing of DECUDK string parameter to allow a comma between + pairs of hexadecimal digits (Ray Neuman <raymond@one.com.au> + reports that "real" terminals accept this; perhaps they simply + ignore unexpected characters). + +
  • fix a few problems with the $TERMCAP string generated + by resize: +
      +
    • for Bourne shell, add an export command. + This was missing as far back as X11R5. +
    • escape exclamation marks, used in xterm's reset string. +
    • translate literal \177\ to "^?". +
    + +
  • improve configure check for tgetent() to work when + $TERMCAP has been set to a specific entry. + +
  • modify minstall.sh to use "%" rather than "@", + to avoid problems with AFS (report by Zdenek Sekera). + +
  • list fatal error codes from error.h in the manpage, + remove unused codes in error.h. + +
  • 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). + +
  • minor fix to description of 1003 mouse mode in ctlseqs.ms + (Larry Riedel). +
+ +

Patch #171 - 2002/12/12 - XFree86 4.2.99.3

+
    +
  • modify parser tables to improve detection of malformed control + sequences, making xterm behave more like a real DEC terminal + (patch by Paul Williams). + +
  • update comment in input.c to document + Meta as a modifier for escape sequences (patch by D + Roland Walker). + +
  • 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). + +
  • remove xevents() call from the end of + BlinkCursor(), 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 xevents() to process. + (patch by Semen A Ustimenko <semenu@FreeBSD.org>). + +
  • remove unused mode-params from open() calls that do + not create a file. + +
  • modify configure script to put new items first on + $CPPFLAGS and $CFLAGS to avoid conflict + with environment's -I and -D options. + +
  • update config.guess, config.sub + +
  • resync with XFree86 CVS: +
      +
    • fix va_args glitches for xterm/libfontconfig: 0 == (void*)0 + isn't true for all platforms (Egbert Eich). +
    • initialise ProgramName in xterm's main before referencing it + (#5473, Peter Valchev). +
    • some cleanup of Imakefile ifdef's (Marc La France). +
    +
+ +

Patch #170 - 2002/10/13 - XFree86 4.2.1

+
    +
  • correct an off-by-one allocating data for sorted help message. + +
  • modify configure script to check for Xpm library, on which XFree86 + Xaw library depends. + +
  • update config.guess, config.sub +
+ +

Patch #169 - 2002/10/5 - XFree86 4.2.1

+
    +
  • modify wording of some options in help message to make them use + -/+ consistently with respect to "on/off" or "off/on". + +
  • sort options list which is displayed in help- and syntax-messages + at runtime to simplify maintenance. + +
  • remove support for Amoeba and Minix (Juliusz Chroboczek noted it + was removed from XFree86 server; there have been no users since + 1996). + +
  • add configure script option --disable-session-mgt + to control whether the session management code should be compiled-in + (request by H Merijn Brand). + +
  • ifdef'd the session-management changes with + OPT_SESSION_MGT, to accommodate X11R5 which predates + the related definitions. + +
  • fix decode_keyvalue(), which did not properly parse + multiple settings as needed for the ttyModes resource, + since it did not skip over the parsed data. + +
  • fix an option-parsing conflict between -class and + -cjk_width (Nam SungHyun) + +
  • add a missing null in XtVaSetValues() call used in + Cleanup() (Nam SungHyun) +
+ +

Patch #168 - 2002/9/29 - XFree86 4.2.1

+
    +
  • 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 <jess@thrysoee.dk>). + +
  • add -cjk_width and corresponding resource + cjkWidth (patch by Jungshik Shin + <jshin@mailaps.org>). + +
  • add -into option, for embedding xterm in a Tcl/Tk + application (patch by George Peter Staplin <georgeps@xmission.com>). + +
  • 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). + +
  • fix conflict between ifdef's for OPT_DEC_LOCATOR and + OPT_READLINE in button.c (reported by Ilya Zakharevich). + +
  • fix for inconsistent use of struct utmp versus + struct utmpx introduced in patch #167 + (patches by Paul Gilmartin, Marc La France). + +
  • modify logic for metaSendsEscape to allow it to work + in a setup where the Meta-key is not recognized as a modifier by + the key-translations logic (from a discussion of eightBitInput + with H.J.Lu, however Vincent Lefevre reported this in January). + +
  • use null pointer values consistently, rather than literal "0", for + ending variable-length argument lists, e.g., for + execlp() (based on patch by Matthieu Herrb). + +
  • correct logic of ChangeAnsiColorRequest(), which would + do a screen repaint after replying to a request for information. + +
  • improve scripts in vttests to work with systems whose shells support + echo -n and have, as does Debian, an unrelated + print utility. + +
  • add vttests/acolors.sh to demonstrate OSC 4, which queries or + sets ANSI colors. + +
  • fixes for ctlseqs.ms (Pavel Roskin, Ilya Zakharevich). + +
  • typos in xterm manpage (Jens Schweikhardt) + +
  • remove a redundant GCC_UNUSED from InitPopup() (Nam SungHyun) +
+ +

Patch #167 - 2002/8/24 - XFree86 4.2.0

+
    +
  • correct ifdef's for USE_TERMCAP to match cygwin + configuration. + +
  • fix several places in ctlseqs.ms which had no boxes around the + literal text (report by Ilya Zakharevich). + +
  • integrated patch from Ilya Zakharevich to extend mouse support for + readline (ifdef'd with OPT_READLINE). + +
  • modify terminfo description to match default for + modifyCursorKeys resource. + +
  • add modifyCursorKeys 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 (from newsgroup discussion with Stephen J Turnbull + and Jeffrey Altman). + +
  • correct missing initializations for appdefaultCursor + and appdefaultKeypad resources. + +
  • add configure option --enable-luit and ifdef'd the + luit-related code with OPT_LUIT_PROG. + +
  • integrate patch by Tomohiro KUBOTA from + http://www.xfree86.org/pipermail/i18n/2002-July/003378.html which + modifies xterm to invoke luit. + +
  • update wcwidth.c to match Markus Kuhn's 2002-05-18 version. + +
  • correct limit-checking in ComputeSelect() to handle + selections that extend off the visible area; rather + than modify the parameters to TrackText(), use + ScrollSelection() to update the highlighting limits. + (reported by Yegappan Lakshmanan and Nelson Beebe, + patch by Alexander V Lukyanov). + +
  • correct manpage description of tiXtraScroll resource + (reported by Tony Finch). + +
  • changes from OpenBSD: +
      +
    • Make xterm setgid utmp to be able to update utmp even + with root privileges revoked. +
    • If not updating utmp, revoke group privileges totally too. +
    + +
  • changes from NetBSD: +
      +
    • Check that the return value from ttyslot() is greater than 0 + before writing the utmp file. + Fixes w's "w: Stale utmp entry: <user> <tty> <pty>" errors. +
    • Use openpty() to deal with new pty naming scheme. +
    + +
  • add print-redir 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). + +
  • check if printerCommand resource string is empty, use + this to allow user to disable printer function. + +
  • trim trailing blanks from resource strings. + +
  • check return value from ptsname(), which may return + null for example if someone has changed the permissions of /dev/pts + to zero (Debian #121899). + +
  • modify OS/2 version to use __UNIXOS2__ definition + rather than __EMX__, related cleanup (patch by Holger + Veit). + +
  • used modified indent 2.0 + (patch 20020428) + to reformat most of the C source files, to simplify maintenance. + +
  • fix a couple of places where there were leading tabs on + symbol-definition lines in Imakefile (Marc La France from report by + Tony Finch) + +
  • add imake variable (TraceXTerm) to allow building debug version + (Egbert Eich). +
+ +

Patch #166 - 2002/03/25 - XFree86 4.2.0

+
    +
  • 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 <vincent@vinc17.org>). + +
  • implement veryBoldColors resource to control whether + the corresponding video attribute such as bold is + displayed when using colorBDMode, etc. (request by Josh + Howard <jrh@vicor-nb.com>). + +
  • define escape sequences for function keys F21-F35 (patch by Steve Wall). + +
  • change the colors for the 256-color model, making them less skewed + toward black (patch by Steve Wall). + +
  • add vt100Graphics resource + (see patch #115, + based on discussion with Glenn Maynard). + +
  • ifdef'd Xaw/Xaw3d/neXtaw includes separately to avoid potential + incompatibilities between these flavors of Athena widgets. + +
  • add configure check for XFree86 4.x Xaw library, whose geometry + management is broken, to avoid trying to use it for toolbar + configuration. + +
  • updates to configure script from vile and lynx to allow + configure.in to be compiled with autoconf 2.5x + +
  • add a check for null pointer return by ptsname() + (newsgroup posting from Mike Silva <mikesilva@lucent.com>). + +
  • fill in a few details needed to allow UTF-8 mode to switch on/off + after startup. This requires that wideChars resource be + set. (based on comments in 4 Aug 2001 by Alexey Marinichev + <lyosha@lyosha.2y.net>). + +
  • remove duplicate install rules that make directories, e.g., so installing + manpage will not create app-defaults directory. + +
  • add comment in in do_osc(), reserving cases 30 and 31 + for for Konsole (request by Stephan Binner + <Stephan.Binner@gmx.de>). + +
  • fixes for ctlseqs.ms and xterm.man + (patch by Werner LEMBERG <wl@gnu.org>). + +
  • add check for monochrome display, disabling colorMode in that + case (fixes Debian #134130). + +
  • resync with XFree86 CVS: +
      +
    • Fix some xterm build warnings on *BSD (David Dawes). +
    • Only use SA_RESTART in xterm when it's available (Frank Liu). +
    • Fix incorrect code in signal handlers in most of the clients, + xterm and xdm not done yet (Matthieu Herrb). +
    +
+ +

Patch #165 - 2002/01/05 - XFree86 4.1.0

+
    +
  • modify uxterm script to strip encoding part from + environment variable before adding ".UTF-8" (based on Debian + #125947, but using a more portable solution). + +
  • add an assignment statement in VTInitialize() to make + awaitInput resource work. + +
  • use new macros init_Bres(), etc., in VTInitialize() to add trace of + the initialization of resources. + +
  • modify checks for $LC_ALL, related environment variables to ensure + the resulting strings are nonempty (report by Markus Kuhn). + +
  • add an ifdef in charproc.c for num_ptrs variable in case all + configure options are disabled. + +
  • modify definition of getXtermBackground() to avoid negative array + index warning on Tru64 (report by Jeremie Petit). + +
  • improve fix from patch #165 (still Debian #117184, report by Matt + Zimmerman <mdz@debian.org>) + +
  • 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). + +
  • documented ANSI.SYS-style cursor save/restore escape sequences + in ctlseqs.ms, which are in xterm since X11R5. + +
  • 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 <bevand_m@epita.fr>). + +
  • fix a couple of typos in comments in the app-defaults files + (David Krause <xfree86@davidkrause.com>). + +
  • resync with XFree86 CVS: +
      +
    • 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. + +
    • save/restore errno in signal catcher (Matthieu Herrb). + +
    • modify UXTerm.ad's font5 resource so that xterm can display double + width characters using a font distributed with XFree86 (Tomohiro KUBOTA). +
    +
+ +

Patch #163 - 2001/11/13 - XFree86 4.1.0

+
    +
  • correct a case where ptyInitialErase and + backarrowKeyIsErase resources combine to set + DECBKM mode, but a reset command would not + reset xterm to that state, making the erase character revert to ^H + (Debian #117184) +
+ +

Patch #163 - 2001/11/04 - XFree86 4.1.0

+
    +
  • correct ifdef's for __QNX__ and + USE_SYSV_PGRP in main.c call to tcsetpgrp, + which broke bash behavior around patch #140 + (report/patch by Frank Liu <fliu@mail.vipstage.com>). + +
  • 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). + +
  • 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). + +
  • modify xterm manual page and minstall.sh to allow imake rules + to define location of app-defaults directory (Debian #87611). + +
  • 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). +
+ +

Patch #162 - 2001/10/23 - XFree86 4.1.0

+
    +
  • correct logic that processes -class option, so that + a following -e option is handled (Debian #116297). + +
  • improve options-decoding to allow -version and + -help options to be combined (Debian #110226). + +
  • add a 10 millisecond delay in event loop when processing + -hold option, to avoid using too much CPU time + (Debian #116213). + +
  • prefix final program execution in uxterm with "exec" + to avoid a useless shell hanging around (Christian Weisgerber). +
+ +

Patch #161 - 2001/10/10 - XFree86 4.1.0

+
    +
  • 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 <davis@space.mit.edu> and Alan W Irwin + <irwin@beluga.phys.uvic.ca>). + +
  • 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. + +
  • correct Imakefile install-rule for uxname script + (reported by Nam SungHyun <namsh@lge.com>). + +
  • resync with XFree86 CVS: correct typo in <ncurses/term.h> + ifdef. +
+ +

Patch #160 - 2001/10/7 - XFree86 4.1.0

+
    +
  • modify logic in main.c + (see patch #145) 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 + <borsboom@westbrabant.net> in May, but I overlooked it when + reviewing bug reports. + +
  • add configure check for <ncurses/term.h> to get + rid of hardcoded __CYGWIN__ ifdef in resize.c +

    + NOTE: The CYGWIN port should not be linking resize + 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 <ncurses/term.h> does not hurt anything, + since there are some correct installations that are set up that + way. + +

  • add a sample uxterm script, which uses the + UXTerm application defaults for UTF-8 environments. + +
  • undo change to xterm application defaults, since this introduced an + unnecessary incompatibility. The intended functionality was + already addressed by the UXTerm + app-defaults file. + +
  • resync with XFree86 CVS: +
      +
    • Modified xterm app default to use LFD fontnames instead of old type + (Michael Schroeder). +
    • Fix xterm when XIM is disabled - caused a segfault + (Tomohiro Kubota). +
    +
+ +

Patch #159 - 2001/9/19 - XFree86 4.1.0

+
    +
  • remove an ifdef for USE_HANDSHAKE added in patch + #158 from the second TIOCSSIZE 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. + +
  • correct treatment of empty parameter list for some OSC strings + (report by Sami Farin <sfarin@ratol.fi>). +
+ +

Patch #158 - 2001/9/8 - XFree86 4.1.0

+
    +
  • 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 app-defaults or + .Xdefaults file contains a translations resource, + though it may also happen through unrelated resource settings: + probably a bug in libXt (reported by Paul Fox + <pgf@foxharp.boston.ma.us> and Dmitry Yu. Bolkhovityanov + <D.Yu.Bolkhovityanov@inp.nsk.su>). + +
  • widen ifdef's in xterm.h to define __EXTENSIONS__ on + Solaris, for compilers other than gcc. This was added along + _POSIX_C_SOURCE with in patch + #151, but is not sufficient since Sun's compiler does not define + __STDC__ by default (report by Matthias Scheler + <tron@zhadum.de>). + +
  • 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) + +
  • patch by Tomohiro KUBOTA <tkubota@riken.go.jp> to implement + "OverTheSpot" preedit type of XIM input: +
      +
    • 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. + +
    • 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. + +
    • 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. + +
    • 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. +
    + +
  • adjust configure script to accommodate repackaging of keysym2ucs.c + as include-file for xutf8.c (patch by Tomohiro KUBOTA + <kubota@debian.org>). + +
  • add the UXTerm app-defaults file to makefile install + rules (request by Juliusz Chroboczek). + +
  • correct logic in get_termcap(), which returned false + if the tgetent() call indicated that xterm was linked + with terminfo. Although the $TERMCAP variable cannot be + adjusted in this case, xterm still needs information from this call + to extract data to initialize the erase-mode when the + ptyInitialErase resource is false. + +
  • modify ScrollbarReverseVideo() function to cache the + original border color, so it can restore that when an application + flashes the screen (Bugzilla #38872). + +
  • resync with XFree86 CVS: +
      +
    • remove ifdef's for X_NOT_STDC_ENV (David Dawes). +
    • add Cygwin to special errno handling case in ptydata.c (Alan Hourihane) +
    • set screen size earlier in initialization, to address a race + with window manager resizing its clients (Keith Packard). +
    +
+ +

Patch #157 - 2001/6/18 - XFree86 4.1.0

+
    +
  • patch by Juliusz Chroboczek to clean up button.c and input.c. 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. +
      +
    • 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?) + +
    • Xutf8TextPropertyToTextList fully handles STRING and UTF8_STRING. + It systematically fails for COMPOUND_TEXT. + +
    • 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. +
    + +
  • add an ifdef for SunXK_F36, used in + xtermcapKeycode() (patch by Mark Waggoner + <waggoner@ichips.intel.com>). + +
  • modify check for login name to try getlogin() 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). + +
  • add resource tiXtraScroll, which can be used to + preserve the screen contents in the scrollback rather than erasing + it when starting a fullscreen application such as vi + (patch by Ken Martin <fletcher@catsreach.org>). + +
  • two patches by Denis Zaitsev <zzz@cd-club.ru>: +
      +
    • added forceBoxChars resource to control the + "line-drawing characters" option. + +
    • added freeBoldBox resource, which, when set true, + suppresses check in same_font_size(), so xterm does + not attempt to ensure that the bold font is the same size as + the normal font. +
    + +
  • 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., color0 and + Color0 rather than color0 and + Foreground). 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. + +
  • fix a signal-handling bug. When running xterm with + ksh or similar shell such as bash 2.05, xterm will hang + and not respond to keystrokes after the user types + suspend. 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 termination 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 + <sven.mascheck@student.uni-ulm.de>). + +
  • correct some inconsistent checks for XtReleaseGC() + calls in xtermLoadFont() (patch by Nam SungHyun + <namsh@lge.com>). + +
  • 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/ + +
  • correction to change from patch #90, + 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). + +
  • 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). + +
  • 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 + <vojta@math.berkeley.edu>). + +
  • resync with XFree86 4.1.0: +
      +
    • Use TermcapLibrary as -lncurses instead of -ltermcap, fixes + problem building xterm/resize on Cygwin/XFree86 (Harold Hunt). +
    • Install xterm.termcap and xterm.terminfo when installing xterm + (Torrey T. Lyons). +
    • Fix some build issues on Cygwin/XFree86 (Suhaib Siddiqi). +
    • Define CBAUD, when it's missing in xterm, on LynxOS + (Stuart Lissaman). +
    +
+ +

Patch #156 - 2001/4/28 - XFree86 4.0.3

+
    +
  • change order of selection-target types to make 8-bit xterm prefer + UTF8_STRING to COMPOUND_TEXT (patch by Juliusz Chroboczek). + +
  • document -fa, -fs command-line options + and faceName, faceSize + resources which are used by the freetype library support. + +
  • if configure script finds freetype libraries, but imake definitions + do not have the XRENDERFONT definition, define it anyway. + +
  • modify configure script check for freetype libraries to include + <Xlib.h>, since an older version of the related + headers relies on this (patch by Adam Sulmicki). +
+ +

Patch #155 - 2001/4/20 - XFree86 4.0.3

+
    +
  • correct return type of in_put() from patch #153 + changes, which left it not wide enough for UTF-8 (patch by Bruno Haible). +
+ +

Patch #154 - 2001/4/11 - XFree86 4.0.3

+
    +
  • undo check for return value from pututline (used for + debugging) since that function does not return a value on Slackware + 3.6. + +
  • correct length in ScreenWrite, when rendering invisible text + (patch by Sven Verdoolaege <skimo@kotnet.org>). + +
  • fixes/improvements for the i18nSelection resource + from patch #153, by Bruno Haible: + +
      +
    • add missing initialization for i18nSelection + resource. + +
    • split-out the non-ICCM aspect of the + i18nSelection resource as a new resource, + brokenSelections. +
    + +
  • add configure check for <time.h> and + <sys/time.h>, to allow for Unixware 7, + which requires both. If the configure script is not used, only + <time.h> will be included as before (report + by Thanh Ma). + +
  • fix redefinition of dup2, getutent, + getutid, getutline and sleep + functions on Unixware 7 (report by Thanh Ma + <Thanh.Ma@casi-rusco.com>) + +
  • add a fall-back definition for __hpux, which is + apparently not defined in some compilers on HPUX 11.0 (reported + by Clint Olsen). + +
  • change VAL_INITIAL_ERASE, which is used as a fallback for the + "kb" termcap string to 8, since that matches the + xterm terminal description (request by Alexander V Lukyanov). + +
  • correct an off-by-one in ClearInLine, which caused + the erase-characters (ECH) control to display incorrectly + (patch by Alexander V Lukyanov). + +
  • correct escape sequences shown in terminfo for shifted editing + keys. The modifier code was for the control key rather than + the shift key. +
+ +

Patch #153 - 2001/3/29 - XFree86 4.0.3

+
    +
  • increase PTYCHARLEN to 8 for os390, add some debugging traces + for UTMP functions (patch by Paul Gilmartin). + +
  • correct an misplaced brace in SelectionReceived() + (patch by Bruno Haible). + +
  • correct an assignment dropped in SelectionReceived() + which made it not compile for wide-characters combined with debug + traces. + +
  • correct typo, clarify description of 88- and 256-color controls + (report by Bram Moolenaar). + +
  • 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). +
+ +

Patch #152 - 2001/3/13 - XFree86 4.0.2

+
    +
  • correct index in inner loop in VTInitI18N() from + patch #151 changes, which resulted in infinite loop under some + conditions (report/analysis by Paul Gilmartin). + +
  • remove spurious "%|" from terminfo sgr capabilities + (report/analysis by Adam M Costello, Debian bug #89222). + +
  • add shell script to adjust list of dynamic libraries linked by + resize when building with the standalone configure + script. Otherwise it uses the same list as for xterm, which is + excessive. + +
  • fix a few compiler warnings reported by the 20010305 gcc snapshot. +
+ +

Patch #151 - 2001/3/10 - XFree86 4.0.2

+
    +
  • patch from Juliusz Chroboczek <jch@pps.jussieu.fr> which + alters the behaviour of selections in XTerm. + It is believed to follow the ICCCM + UTF8_STRING to the letter, both + in UTF-8 and in eight-bit mode. From his description: +
      +
    • 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: +

      + UTF-8 mode: UTF8_STRING, TEXT, COMPOUND_TEXT, STRING.
      + eight-bit mode: TEXT, COMPOUND_TEXT, UTF8_STRING, STRING. + +

    • 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. +
    • For compatibility with previous versions of XTerm, a resource + i18nSelections 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.) +
    + +
  • improved error checking/reporting in VTInitI18N(), ensuring that + lack of input method styles is treated distinctly from a mismatch. + +
  • 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 + <amc@cs.berkeley.edu>, fixes Debian bugs #76404, #77575). + +
  • modify RequestResize() function to save/restore window + manager hints. Its call to XtMakeResizeRequest() 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 (reported by Christian Weisgerber as well + as Debian bug #79939). +

    + 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). + +

  • fix a redefinition warning for resize.c on OpenBSD (patch by + Christian Weisgerber). + +
  • change resource corresponding to -T option to match + Xt library's -title, i.e., .title + rather than *title so the command-line options are + interchangeable as documented (Debian bug report #68843). + +
  • 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. + +
  • add configure check for freetype libraries and configure option + --disable-freetype to override this feature. + +
  • modify some configure script macros to avoid using changequote(), + which has been rendered useless in the latest autoconf alpha 2.49c + +
  • update config.guess, config.sub to 2001-2-13 + +
  • remove redundant/contradictory __CYGWIN__ definitions from resize.c + +
  • correct manpage typo introduced by X11R6.5 resync. +
+ Changes from XFree86 4.0.2: +
    +
  • add definition of _POSIX_C_SOURCE for Solaris to + make this compile with gcc -ansi -pedantic (report + by <mark@zang.com>. +
+ +

Patch #150 - 2000/12/29 - XFree86 4.0.2

+
    +
  • move the binding for shifted keypad plus/minus, which invokes the + larger-vt-font() and smaller-vt-font() + actions, respectively, into the translations resource (suggested by + Marius Gedminas <mgedmin@puni.osf.lt>). + +
  • modify configure script to support the + --program-prefix, --program-suffix and + --program-transform-name options (request by Alison + Winters <alison@mirrabooka.com>). + +
  • patch from Robert Brady +
      +
    • fix a scrolling / combining characters display anomaly + +
    • 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 + <yzhang@sharemedia.com>). + +
    • fix special case of null byte for key handling in UTF-8 locales. +
    + +
  • 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 same_font_size() + 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 + <alan@mticket.com>, 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). + +
  • 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 <china@thewrittenword.com<). + +
  • 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 <celacunza@netscape.net> + +
  • correct a logic in UTF-8 mode for selecting double-width characters; + a combining character was omitted (patch by Markus Kuhn). + +
  • add feature to pop (raise) window when a bell is received + (patch by Gael Roualland <gael.roualland@dial.oleane.com>). + +
  • add __NetBSD__ and __OpenBSD__ to special-case in xterm_io.h + for USE_POSIX_TERMIOS definition (patch by Christian Weisgerber). + +
  • move special-case HPUX include for <sys/bsdtty.h> to + xterm_io.h to define TIOCSLTC, making HAS_LTCHARS defined for HPUX + 10.20 (report by Bruno Betro). +
+ +

Patch #149 - 2000/12/6 - XFree86 4.0.1h

+
    +
  • restructured includes for termios.h, + termio.h and related definitions for main.c, os2main.c, + screen.c and resize.c so they will share equivalent definitions in a + new header xterm_io.h. 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). + +
  • improve usability of double-width fonts by allowing normal fonts + to be given as double-width (from a patch by Fabrice Bellard + <bellard@email.enst.fr>). + +
  • correct a few compiler warnings in TRACE() macros for + signed/unsigned variable differences (reported by Clint Olsen). + +
  • make configure script use $CFLAGS and $CPPFLAGS more consistently, + i.e., by using CF_ADD_CFLAGS in CF_ANSI_CC macro. + +
  • expanded description of environment variables in manual-page. + +
  • 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 + k; name (patch by Bram Moolenaar). + +
  • add OPT_SAME_NAME and OPT_TCAP_QUERY to xtermcfg.hin, so the + corresponding configure options work (patch by Bram Moolenaar). + +
  • resync with XFree86 4.0.1g: +
      +
    • Rewrite Xft library for Render extension/core text and font management + Change xterm to use new interface (Keith Packard). +
    +
+ +

Patch #148 - 2000/10/31 - XFree86 4.0.1d

+
    +
  • document logfile options in man-page. + +
  • correct spelling of -samename option in help message. + +
  • add configure script option --enable-tcap-query + (request by Bram Moolenaar). + +
  • patch by Bram Moolenaar to add a + "Co" or "colors" entry to the OPT_TCAP_QUERY feature. +
  • patch by Kiyokazu SUTO <suto@ks-and-ks.ne.jp>: +
      +
    • add support for bold font for double width characters. + The font name may be specified with the command line option + -fwb or with resource + wideBoldFont (class WideBoldFont). +
    • correct underlining of double width character string, which + was drawn only half width. +
    • correct binary search of precomposed character table, which + may return wrong result when int is just 32 bits. +
    + +
  • some changes to align terminfo with ncurses 5.2: +
      +
    • remove xtermm description, retaining xterm-mono since the former + conflicts with ncurses. +
    • 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). +
    • make a few entries explicitly inherit from xterm-xfree86 rather + than xterm: xterm-rep, xterm-xmc, xterm-nrc +
    + +
  • ensure that sign-extension does not affect ctype + macros by using CharOf() macro to coerce the parameter + to an unsigned char. + +
  • resync with XFree86 4.0.1d: +
      +
    • Add primitive support in xterm for Xft based fonts (Keith Packard). + The changes are ifdef'd with -DXRENDERFONT. +
    +
+ +

Patch #147 - 2000/10/26 - XFree86 4.0.1c

+
    +
  • correct implementation of ptyInitialErase: the + value assigned to initial_erase 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 <naddy@mips.inka.de>). + +
  • 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 <rch@richard.eu.org>). + +
  • modify sample scripts to check for printf before print, since the + latter is not as well standardized (e.g., on Linux). + +
  • updated config.sub, config.guess to reflect changes on + subversions.gnu.org +
+ +

Patch #146 - 2000/9/12 - XFree86 4.0.1c

+
    +
  • 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 <tv@debian.org>). + +
  • 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). +
+ +

Patch #145 - 2000/9/11 - XFree86 4.0.1c

+
    +
  • several changes from Robert Brady for UTF-8 configuration: +
      +
    • doublewide characters don't lose their accents when the cursor + moves onto or from them (a visual bug) + +
    • 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. + +
    • modify logic for cut-buffers so UTF-8 data is first converted + to Latin1. + +
    • collapse surrogates, 0xfffe, 0xffff to UCS_REPL. + +
    • modify to allow xterm to to show combining characters + attached to doublewidth characters. + +
    • correct bug in linewrap with -u8 option (reported by + Andreas Koenig <andreas.koenig@anima.de>). +
    + +
  • several changes to PTY logic (based on request by Tim Ryan + <timryan@nortelnetworks.com>). +
      +
    • modify treatment of -S option to to make it work with + Unix98 PTY's. + +
    • restore sense of IsPts flag in get_pty(), which was + lost in Unix98 changes. + +
    • use new functions my_pty_id() and + my_pty_name() to simplify/fix strings used for utmp, + wtmp identifiers. + +
    • simplify get_pty() function, making it have a single + return point so its inputs/outputs can be identified. +
    + +
  • update config.guess and config.sub and scripts to my 20000819 patch, + adding cases for OS/2 EMX. + +
  • add special case for os390 compiler options to configure script + (patch by Paul Gilmartin) + +
  • fix some unused-variable compiler warnings (reported by + Zdenek Sekera). + +
  • split-out some string functions into xstrings.c, to use them + more consistently among main.c, os2main.c and resize.c + +
  • 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. + +
  • add terminfo entry for xterm-sco (SCO function keys). + +
  • modify same_font_name() to properly handle wildcard + introduced in bold_font_name(), 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 <enbeo@enbeo.resnet.bris.ac.uk>) + +
  • correct preprocessor line for OPT_WIDE_CHARS in drawXtermText() + from patch #141 which resulted in overstriking for bold fonts not + working. + +
  • correct Imakefile from 4.0.1c resync so UTF-8 modules are in + UTF8SRC, UTF8OBJ lists, allowing build without UTF-8 support. +
+ +

Patch #144 - 2000/8/23 - XFree86 4.0.1b

+
    +
  • 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 <alan@mticket.com>). +
+ +

Patch #143 - 2000/8/19 - XFree86 4.0.1b

+
    +
  • add a check to ensure that -class command-line option + is not confused with -c (reported by Paul Townsend + <aab@aab.cc.purdue.edu>). +
+ +

Patch #142 - 2000/8/18 - XFree86 4.0.1b

+
    +
  • correction to precompose scripts, so 0061 + 0300 will now be really + be displayed as 00C0 (patch by Robert Brady + <robert@susu.org.uk>). + +
  • correct macro ClassSelects() in button.c, used to hide ifdef's for + OPT_WIDE_CHARS in patch #141 (reported by Andreas Paul + <paula@informatik.tu-muenchen.de>). + +
  • 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). + +
  • newer config.sub and config.guess, from lynx 2.8.4dev.7 +
+ +

Patch #141 - 2000/8/14 - XFree86 4.0.1b

+
    +
  • Most of this patch is an integration of Robert Brady's patch #11 + for doublewidth and combining characters, from + http://www.ecs.soton.ac.uk/~rwb197/xterm/. In this context, + doublewidth refers to 16-bit character sets which may have glyphs + occupying two cells. + +
  • add command-line option -class, which allows one + to override xterm's resource class. Also add resource file + UXTerm.ad, which simplifies using xterm for both + 8-bit character sets and UTF-8. + +
  • fixes/improvements to OPT_TCAP_QUERY logic (patches by Bram + Moolenaar, Steve Wall). +
+ +

Patch #140 - 2000/7/23 - XFree86 4.0.1

+
    +
  • 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). + +
  • 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). + +
  • add /usr/local to search path in CF_X_ATHENA configure macro + to build with Xaw3d on OpenBSD (patch by Christian Weisgerber). + +
  • add missing #undef HAVE_TERMIO_C_ISPEED to + xtermcfg.hin, omitted in patch #133 fix for IRIX 6.5 baudrate (report + by Alain Filbois <Alain.Filbois@loria.fr>). + +
  • 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 <enf@pobox.com>). + +
  • update config.guess and config.sub (from tin and lynx) +
+ +

Patch #139 - 2000/6/17 - XFree86 4.0d

+
    +
  • back out change to -name 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). +
+ +

Patch #138 - 2000/6/15 - XFree86 4.0c

+
    +
  • 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. +
    + Otherwise, when used for large fonts, xterm may generate a 2-pixel + wide line, which can leave dots on the screen. + +
  • restore first line of 256colres.pl, omitted in 4.0c diffs. +
+

Patch #137 - 2000/6/10 - XFree86 4.0b

+
    +
  • make command-line -name option work as documented. + Apparently this was lost in X11R5 when coding to use + XtAppInitialize. + +
  • limit numeric parameters of control sequences to 65535 to + simplify checks for numeric overflow. + +
  • change index into UDK list to unsigned to guard against numeric + overflow making the index negative (Taneli Huuskonen + <huuskone@cc.helsinki.fi>). + +
  • change sun function-keys resource name to + sunFunctionKeys to work around redefinition of the + token sun by xrdb on Solaris. Similarly, renamed + resource sun keyboard to sunKeyboard + (Steve Wall). + +
  • change similar resource names for HP and SCO to avoid potential + conflict with xrdb symbols on other systems, as well as for + consistency. + +
  • 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. + +
  • add limit checks to ClearInLine(), + ScrnInsertChar(), ScrnDeleteChar() to + correct potential out-of-bounds indexing (prompted by Debian bug + report #64713, which reported a problem with ICH escape sequences). + +
  • updates to config.sub and config.guess + Kevin Buettner <kev@primenet.com> for elf64_ia64 + Bernd Kuemmerlen <bkuemmer@mevis.de> and MacOS X. + +
  • patch from Paul Gilmartin for os390 to check for errno set to + ENODEV on failure to open /dev/tty when there is no controlling + terminal. + +
  • patch from H Merijn Brand <h.m.brand@hccnet.nl> for + building on Digital Unix 4.0 and AIX 4.2. + +
  • modify DECRQSS reply for DECSCL to additionally report if the + terminal is set for 8-bit controls. +
+ +

Patch #136 - 2000/6/3 - XFree86 4.0b

+
    +
  • add a resource (limitResize) + limiting resizing via the CSI 4 t and CSI 8 t sequences. + +
  • ignore out-of-bounds resize requests, i.e., where sign-extension + or truncation of the parameters would occur. +
+ +

Patch #135 - 2000/5/29 - XFree86 4.0b

+
    +
  • remove code introduced in #134 which made some backgrounds bold. + +
  • minor correction to format of updated $TERMCAP when adding + kb capability for ptyInitialErase logic. + +
  • improved test for SVR4 definition. +
+ +

Patch #134 - 2000/5/28 - XFree86 4.0b

+
    +
  • update URL's and mailing addresses, moved to http://dickey.his.com + and dickey@herndon4.his.com + +
  • correct missing quotes in CF_TTY_GROUP configure script macro in + case the script is run in batch mode. + +
  • modify ownership-check of log file to ignore the group ownership. + Otherwise xterm cannot create logfiles in directories with set-gid + permissions. + +
  • simplify the logic that reads termcap data. + +
  • add fallback definition for B9600 in case line speed definition + for 38400 is missing (report by Jack J Woehr <jwoehr@ibm.net>, + for OpenBSD 2.6). + +
  • 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 <ross@soi.city.ac.uk>). + +
  • 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 sco to be predefined. + +
  • patches from Steve Wall: +
      +
    • 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 + <X11/Sunkeysym.h> 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. + +
    • add colorRV and colorRVMode resources to + allow specifying a color to use for reverse video, similar to the + existing UL, BD, and BL modes. + +
    • add alwaysUseMods resource, to override check if + alt or meta modifiers are used in + translations resource. Revamped the code to calculate + the modifier value, and included Meta if alwaysUseMods is TRUE, using + values 9-16. +
    + +
  • patches from Paul Gilmartin for os390: +
      +
    • regularize the definition of CONTROL() and remove an + acknowledged "trial and error" table. + +
    • translate "^?" into A2E(0177) which is the EBCDIC "DEL" + rather than plain 0177 which is the EBCDIC quotation mark. + +
    • modify xtermMissingChar() so that EBCDIC codes 128-159 + are not rendered as blanks by X server running on Solaris, which sees + those as control characters. + +
    • make debugging traces (configure --enable-trace) + work properly with EBCDIC. +
    +
+ +

Patch #133 - 2000/5/2 - XFree86 4.0a

+
    +
  • add substitutions in autoconf'd Makefile for CPPFLAGS, LDFLAGS and + AWK (reported by Neil Bird). + +
  • correct uninitialized childstat variable from patch + #131 in creat_as() function, which caused logging to not + work on Solaris, whose waitpid() function does not + initialize its parameter. Add check for EINTR on return from + waitpid() as well (reported by Neil Bird + <neil.bird@rdel.co.uk>). + +
  • remove a redundant check for working setuid() function + introduced in patch #132 (Greg Smith reports that this does not work + as intended on os390). + +
  • change line speed from 9600bd to 38400bd, to accommodate people who + mistakenly use $TERM set to vt100, to reduce the effect of + padding associated with this terminal type. + +
  • add configure script check for IRIX 6.5's redefinition of baud + rates associated with struct termio, to correct a + situation where the baud rate was initialized to zero (reported by + Andrew Isaacson <adi@lcse.umn.edu>). + +
  • remove unused configure script check for VDISABLE. +
+ +

Patch #132 - 2000/4/11 - XFree86 4.0a

+
    +
  • undo an incorrect change from patch #113 caused the right scrollbar + to be positioned incorrectly when re-enabling it (analysis by + D Roland Walker). + +
  • 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 <jmknoble@pobox.com>). + +
  • correct ifdef'ing for conflict between definitions in AIX's + <sys/select.h> and <X11/XPoll.h> (reported by Clint + Olsen). + +
  • 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 + <psz@maths.usyd.edu.au>) + +
  • modify resize.c to build and work on os390 (uses EBCDIC) + (adapted from patch by Phil Sidler <Phil.Sidler@airborne.com>) + +
  • use Ires(), Bres() and Sres() macros to simplify resource list in + charproc.c + +
  • resync with XFree86 4.0a: +
      +
    • correct a typo in os2main.c (Holger Veit, from 4.0a). +
    +
+ +

Patch #131 - 2000/3/3 - XFree86 3.9.18b

+
    +
  • integrate patch by Branden Robinson for improving logfile + security: +
      +
    • make the creat_as() function more strict by using + O_EXCL rather than O_APPEND. +
    • fixes to make DEBUG ifdef's compile/run, including making the + debug logfile more unique by appending a timestamp to its name. +
    • include <term.h> in resize.c, to fix a missing-prototype + warning. +
    + +
  • modified creat_as() 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. + +
  • use creat_as() logic to make tek4014 screen-copy + more secure (noted by Branden Robinson). + +
  • ifdef'd some of Branden's changes to build/work on older machines. + +
  • correct missing initialization of the .mode flag in + ColorRes struct, from patch #129. This worked on Linux + because malloc() zeroes memory on that platform + (reported by Christian Weisgerber). + +
  • modify logic for deleteIsDEL resource so it has + internally 3 states: unspecified, true and false. If unspecified, + the keyboard type determines whether the Delete key transmits + <esc>[3~ or \177, 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). +
+ +

Patch #130 - 2000/3/1 - XFree86 3.9.18a

+
    +
  • modify scroll-forw() and scroll-back() + 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. + +
  • 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 <bruno@iami.mi.cnr.it>). + +
  • add a check in creat_as() to ensure that the user + really owns the logfile that has been opened. + +
  • 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). + +
  • add configure script option --enable-sco-fkeys, minor related fixes + (patch by Dr Werner Fink). + +
  • fix typos in ctlseqs.ms (reported by Bram Moolenaar) + +
  • fix typo in sinstall.sh default for $TST_PROG (reported by + Paul Gilmartin <pg@sweng.stortek.com>) +
+ +

Patch #129 - 2000/2/26 - XFree86 3.9.18a

+
    +
  • improve initialization of ANSI colors by delaying allocation until + each color is first used. + +
  • remove ifdef that prevented colorBD/colorUL/colorBL resources from + working when 256-color configuration was built (reported by + Todd Larason). + +
  • fix some minor inconsistencies in terminfo (Debian #58530). +
+ +

Patch #128 - 2000/2/17 - XFree86 3.9.18

+
    +
  • correct logic for oldXtermFKeys resource, fixes a core + dump when attempting to set it from the command-line (reported by Dr + Werner Fink). +
  • correct ifdef for meta-sends-escap so configure --disable-num-lock + builds. +
+ +

Patch #127 - 2000/2/12 - XFree86 3.9.17e

+
    +
  • 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. + +
  • remove logic for metaSendsEscape that would allow xterm to send + <esc>[3~ before a function key that would begin + with <esc>[3~ (request by Christian Weisgerber). + +
  • add missing action and documentation for meta-sends-escape. + +
  • correct a few typos in ctlseqs.ms (incorrect code for Cyan color) +
+ +

Patch #126 - 2000/2/8 - XFree86 3.9.17c

+
    +
  • patch by Markus Kuhn: + 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. 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. + +
  • add old function-keys control sequences and popup menu entry, for + compatibility with legacy X11R6 xterm. + +
  • revert translation of editing keypad "Delete" key to legacy \177. + +
  • simplify the color-resource data expressions with macro COLOR_RES, + for later use in restructuring color initialization. + +
  • change encoding of wheel mouse (buttons 4 and 5) to avoid conflict + with legacy mouse modifiers (suggested by Bram Moolenaar). +
+ +

Patch #125 - 2000/1/31 - XFree86 3.9.17c

+
    +
  • integrate patch by David Mathog + <mathog@seqaxp.bio.caltech.edu> to make this work on OpenVMS + +
  • rename some functions, e.g., Index to + xtermIndex so that ports such as VMS which link + externals ignoring case will not have library conflicts (reported by + David Mathog). + +
  • correct logic of do_reversevideo(), which did not + update the corresponding popup menu check mark (reported by David + Mathog, this was a detail overlooked in patch #94). + +
  • change TRACE macro so semicolon is not within definition, making + indent and similar programs work better. + +
  • add depend rule to Makefile.in + +
  • 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). + +
  • revise logic that handles menus and input translation for keyboard + type so only one can be selected at a time. + +
  • restore kdch1=\177 for the Sun function-key type, and make the + the Delete key send DEL (\177) if the oldXtermFKeys resource is set. + +
  • 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 <amadeus@yk.rim.or.jp>). + +
+ +

Patch #124 - 2000/1/27 - XFree86 3.9.17b

+
    +
  • change coding of editing keypad's "Delete" key to + <escape>[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 screen program) outweighs the choice of DEL (127) + which was used in X11R5/X11R6 xterms. The screen + program translates whatever matches kdch1 into <escape>[3~, + even if it happens to be the stty erase character. + +
  • 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). + +
  • add encoding for kcbt to <escape>[Z (fixes Debian #54840). + +
  • 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. + +
  • simplify ifdef's in main.c for POSIX VDISABLE so the "^-" pattern + is more likely to be implemented when imake configures xterm + (fixes Debian #55105). + +
  • change manpage to make it clearer what codes are sent by the + backarrow key. +
+ +

Patch #123 - 2000/1/22 - XFree86 3.9.17a

+
    +
  • add a note reserving OSC 51 for use in Emacs shell (request by + Rob Mayoff <mayoff@dqd.com>). + +
  • correct a missing backslash in xterm-vt220 termcap. + +
  • cleanup remaining quoted includes, preferring bracketed form. + +
  • minor configure-script macro updates from tin and vile. + +
  • add configure-script option for using utempter library, adapted + from Redhat 6.1 patch for XFree86 3.3.5 + +
  • resync with XFree86 3.9.17a: +
      +
    • correction to QNX support (Frank Guangxin Liu) +
    • some cosmetic changes that did not correct any reported problems. +
    +
+ +

Patch #122 - 1999/12/28 - XFree86 3.9.16f

+
    +
  • 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). + +
  • implement metaSendsEscape resource, with corresponding + control sequence and menu entry. Like eightBitInput, 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). + +
  • correct potential indexing with negative subscript in udk_lookup(), + (reported by Ian Collier <Ian.Collier@comlab.ox.ac.uk>). + +
  • modify configure script that sets TERMINFO_DIR to use ${prefix} + rather than /usr if the --prefix option was specified (request by + Zdenek Sekera <zs@sgi.com>). + +
  • 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). + +
  • change several functions to macros to improve speed + +
  • two corrections to simulation of bold font via overstriking: +
      +
    • use clipping to avoid leaving trash at end of the text, and +
    • add brackets so wide-character logic does not fall-through + into the overstriking logic (reported by + Marc Feeley <feeley@IRO.UMontreal.CA>) +
    + +
  • add several entries to termcap file to make it have the same set + of aliases as the terminfo file. + +
  • scale the color values used for xterm-256color terminfo entry to + 0..1000, as expected by ncurses. + +
  • change xterm-r6 terminfo definitions for F1-F4 to match program. + +
  • Add QNX/Neutrino support (Frank Guangxin Liu + <frank@ctcqnx4.ctc.cummins.com>) +
+

Patch #121 - 1999/11/14 - XFree86 3.9.16c

+
    +
  • change label on "Sun/PC Keyboard" popup menu entry to "VT220 + Keyboard", since the checked state corresponds to VT220 rather than + Sun/PC. + +
  • add configure test CF_UTMP_UT_XSTATUS to handle the variants of + utmp exit status (reports by Dave Ellement, Jeremie Petit, Tomas + Vanhala). + +
  • amend treatment of ALT key + (see patch #94) 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). + +
  • modify default for OPT_I18N_SUPPORT to assume that + XtSetLanguageProc() is available in X11R5. +

    + Caveat: XtSetLanguageProc() was + added fairly late in the X11R5 patches, and some vendors shipped + buggy versions of this function (request by Tomas Vanhala). + +

  • 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). + +
  • modify terminfo entry for xterm-xfree86 to reflect + modifiers for shift and control which (from a patch by Alexander V + Lukyanov). + +
  • modify terminfo entry for xterm-sun 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. + +
  • modify treatment of XK_Delete keysym so it transmits parameterized + VT220-style <esc>[3~ if modifiers (shift, control + alt) are given (request by Alexander V Lukyanov). + +
  • corrected misspelled resource name in command-line option for + HP function keys. +
+ +

Patch #120 - 1999/10/28 - XFree86 3.9.16c

+
    +
  • refine the change to SGR_Background() 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 + <walker@pobox.com>). + +
  • 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 <brad@linuxcanada.com>). + +
  • 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). + +
  • 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 <werner@suse.de>). + +
  • fix definition of HAVE_UTMP_UT_HOST for ISC configuration (patch by + <michael.rohleder@stadt-frankfurt.de>) + +
  • improve configure script's utmp tests (based on reports by Greg + Smith for os390, and David Ellement for HPUX). + +
  • 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). + +
  • add an application resource, messages (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 + mesg n 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 mesg program (patch, description by David Madore + <david.madore@ens.fr>). +
+ +

Patch #119 - 1999/10/16 - XFree86 3.9.16c

+
    +
  • add responses (DA and DSR) for DEC locator mode + +
  • add coding for ANSI color to DA response + +
  • implement UTF-8 translation for Media Copy (print) operations. + +
  • 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. + +
  • correct error in _GNU_SOURCE configure test, which left it always + defined. + +
  • 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 -C by Jeremie Petit + <Jeremie.Petit@digital.com>). + +
  • add workaround for conflict between <X11/XPoll.h> and + <sys/select.h> on AIX 4.3 (Richard Griswold + <griswold@acm.org>). + +
  • add configure script test to resolve conflict between between + <X11/XPoll.h> and <sys/select.h> + +
  • modify translation of UTF-8 sequences to reject "overly long" + variations (patch by Markus Kuhn). + +
  • remove utf8controls resource, since Markus' change + removes the corresponding logic. + +
  • 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 <Stephane_Chazelas@Raytheon.com>). + +
+ +

Patch #118 - 1999/10/5 - XFree86 3.9.16b

+
    +
  • refine configure test for utmp versus utmpx, to build on HP-UX 10.x + (reported by David Ellement). + +
  • move the configure check for const after the check + for ANSI C compiler options, since those may be required to make + it work properly on HP-UX. + +
  • add configure test for defining _GNU_SOURCE + +
  • correction to -hold option, ensure that if data is already + in the output buffer that it will be displayed before closing the + PTY. + +
  • 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 <adam@cfar.umd.edu>). + +
  • correct configure script's check for termcap.h to avoid using + ncurses' version of it on systems that have a working + tgetent() function. This is needed to make + resize work properly. + +
  • fix some typography in ctlseqs.ms description of DEC locator events + (reported by Steve Wall). +
+ +

Patch #117 - 1999/9/29 - XFree86 3.9.16b

+
    +
  • change order of tests in configure script for utmp and utmpx + to test utmpx first, to compile on Solaris (reported by + Leena Heino <liinu@uta.fi> + and Patrik Hagglund <patha@ida.liu.se>). + +
  • 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. + +
  • remove a spurious comma in an #undef (reported by + David Green <greendjf@cvhp152.marconicomms.com> and + David Ellement <ellement@sdd.hp.com> both on HP-UX, whose + compiler does care about syntax). + +
  • change ifdef's using __CYGWIN32__ to __CYGWIN__ (reported by Suhaib + M. Siddiqi <Ssiddiqi@InspirePharm.Com>, who is told that the + next Cygnus release will drop that symbol in their next release). + +
  • minor cleanup of ifdef's for makeColorPair (patch by Steve Wall). + +
  • patch by Alexander V Lukyanov to work around problem observed + in XFree86 3.3.5, reported as bug #5419 to Mozilla. From the + problem report: +
    + 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. +

    + Easy way to reproduce:
    + while :; do echo aaa; sleep 1; done
    + (while this runs, select text and hold down left mouse button) + watch cpu load.
    + release left mouse button - spinning stops. +

    +
+ +

Patch #116 - 1999/9/25 - XFree86 3.9.16a

+
    +
  • modify warning if change-ownership of PTY fails; some + configurations may not happen to have old-style pty's (reported by + Bob Maynard). + +
  • 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). + +
  • 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. + +
  • implement configure script tests for utmp, tty group. + +
  • implement -hold 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 + <plaettner@aem.umn.edu> in comp.unix.programmer, that the IRIX + winterm provides this option). + +
  • integrated change by Steve Wall to + 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. + +
  • patch from Matthias Baake <Matthias.Baake@gmx.de>, for print + action. From his notes: +
      +
    • Bug 1: + Underlined text is preceded by ESC [0;2m . This should be ESC [0;4m , ESC + [2m doesn't seem to have any effect. (print.c/send_SGR) + +
    • Bug 2: + The check for the last non-empty column (while (last > 0) ... in + print.c/printLine) omits the rightmost column of the screen, the loop must + start with last = screen->max_col+1 instead of last = screen->max_col. + +
    • Bug 3: + 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 & SGR_MASK. +
    +
+ +

Patch #115 - 1999/9/18 - XFree86 3.9.16a

+
    +
  • integrated changes by Steve Wall to implement an 88-color model + for systems where 256-colors cannot be allocated. + +
  • 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). + +
  • add resource cacheDoublesize, 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. + +
  • 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). +
+ +

Patch #114 - 1999/9/15 - XFree86 3.9.16

+
    + +
  • add configure script checks for Athena headers and libraries under + /usr/contrib to work on HPUX (reported by several people: + David Nixon <djn@csc.liv.ac.uk> + Aryeh Koenigsberg <aryeh.koenigsberg@telrad.co.il> + Johannes Mähner <johanm@camline.com> + Andrew Gaylard <andrew.gaylard@bsw.co.za>). + +
  • 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 <bosse@ing.umu.se>). + +
  • rewrote logic that removes data from termcap entry, e.g., for + titeInhibit, to make it less likely to remove the wrong data. + +
  • correct logic which checks for missing characters used for line + drawing. The 0 character was tested unnecessarily, leading to + some inefficiency when rendering. + +
  • change termcap capability which is used as input or output of + ptyInitialErase logic from kD to kb. + Christian Weisgerber <naddy@mips.rhein-neckar.de> pointed out + in effect that kD (in terminfo kdch1) should + correspond to the control sequence for dch1, which deletes + from the current position toward the right. + +
  • 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. + +
  • add xterm-noapp terminfo entry to illustate a nominally + bash-compatible terminal description. +
+ +

Patch #113 - 1999/8/15 - XFree86 3.9.15b

+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. + +
    +
  • correct error in input conversion for NRC mode (reported by + Stefan Traby <stefan@sime.com>). + +
  • 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. + +
  • correct a missing return-value in get_pty(), for SCO + +
  • add E2A fix for backspace (Greg Smith), i.e.,
    + #define VAL_INITIAL_ERASE A2E(127) + +
  • correct foreground color within cursor outline when the + window is unfocused (reported by Stephane Chazelas). + +
  • 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. + +

    + I have noticed some additional problems with right-scrollbar on + X11R5 which I will correct later. + +

  • integrate changes by Jean-Claude Michot for QNX from XFree86 3.3.4c + +
  • add resources menuBar/MenuBar, menuHeight/MenuHeight for later + use in toolbar geometry. + +
  • add configure option --enable-toolbar + +
  • add missing definition to make ziconbeep logic not compile-in when + configure script disables it. + +
  • add configure-check for input-method support in X libraries +
+ +

Patch #112 - 1999/7/17 - XFree86 3.9Pw

+
    +
  • 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. + +
  • remove "ISO" case for SD, which was due to a typographical error in + ECMA-48 (reported by Paul Williams <paul@celigne.co.uk> for + vttest). + +
  • add "FILES" section to manpage. + +
  • generate header file to initialize default resources for colors + 16-255. + +
  • patches by Greg Smith for os390: +
      +
    • add README.os390 + +
    • use the pty_search() function to find an available pty/tty pair. + +
    • move E2A() call out of getXtermCell() to SaveText() function + so it will be available in all configurations. +
    + +
  • patches by Todd Larason: +
      +
    • enable SGR 48 5 in ISO color mode, not just 256 color mode + +
    • change configure's --disable-256-color option to + --enable-256-color, to match its effect + +
    • fix OSC 4 xx ? (report ansi color) to report a string which can + actually be used to set the color back + +
    • fix OSC 4 xx yy (change ansi color) to not allow setting colors > + 15 in 16 color mode + +
    • simplify the COLOR_ settings a bit in ptyx.h, along with setting + NUM_ANSI_COLORS needed for #1 and #4 above + +
    • correct string-terminator code passed for reference to OSC + responses; when in 7-bit mode, only the final byte of ST was seen. + +
    • Allow multiple color #;name pairs in OSC 4, + and document changes to match. +
    +
+ +

Patch #111 - 1999/7/10 - XFree86 3.9Pw

+
    +
  • add control sequences for specifying the RGB value of the ANSI + colors, and for configuring with 256 colors (patch by Todd Larason + <jtl@molehill.org>). I made the default configuration to + 16-colors, because xterm uses the default color map (which has only + 256 colors). + +
  • correct an error in DCS $ q m reporting for colors 8-15 (Todd + Larason). + +
  • 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. + +
  • increased cache size for double size fonts to 8, to allow for both + normal and bold fonts (from discussion with Aryeh Koenigsberg + <aryeh.koenigsberg@telrad.co.il>). + +
  • integrated patch from Greg Smith <rys@epaibm.rtpnc.epa.gov> + for port to OS390 (aka MVS). OS390 uses EBCDIC rather than ASCII. + +
  • correct an off-by-one in binary search limits in keysym2ucs.c (Markus + Kuhn). + +
  • implement logging for UTF-8 mode. The output is written in UTF-8 form. +
+ +

Patch #110 - 1999/6/29 - XFree86 3.9Pu

+
    +
  • 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). + +
  • added new OSC 3 ; PROPNAME=VALUE 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 + <gjb@cs.washington.edu>). + +
  • change internal flag used for utf8controls resource + so we allow 31-bit range of characters (suggested by Thomas Wolff). + +
  • add check for 16-bit characters in OSC strings, change them to '?' + (reported by Thomas Wolff). + +
  • 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). +
+ +

Patch #109 - 1999/6/23 - XFree86 3.9Pt

+
    +
  • correct range-check from patch #108, which resulted in not being + able to select from the scrollback buffer (reported by Tim Adye + <T.J.Adye@rl.ac.uk>) + +
  • correct "no available ptys" problem with Cygwin B20.1 (patch by Tim + Adye). + +
  • 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 <zs@sgi.com>). + +
  • added install-full rule to Makefile.in + +
  • resync mkdirs.sh and install.sh scripts against current autoconf + +
  • 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 <cat@zip.com.au>). + +
  • 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). + +
  • correct a typo from patch #107, incorrect array name, in the + filterUTF8 function (patch by Bruno Haible <haible@ilog.fr>) + +
  • add utf8controls 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). + +
  • 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). +
+ +

Patch #108 - 1999/6/19 - XFree86 3.9Ps

+
    +
  • 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 + <Stephane_Chazelas@Raytheon.com>). + +
  • implement resource boldMode, to allow disabling the + simulation of bold fonts when the bold and normal fonts are not + different (requested by Will Day <willday@rom.oit.gatech.edu>). + +
  • change the atom "UTF-8" to "UTF8_STRING", and fixes a few bugs in + the UTF-8 selection (patch by Juliusz Chroboczek). + +
  • correct logic of binary-search in keysym2ucs.c (patch by Markus + Kuhn). + +
  • add special interpretation of keysym codes above 0x1000000 as + the corresponding UCS value plus 0x1000000 (patch by Markus Kuhn). +
+ +

Patch #107 - 1999/6/12 - XFree86 3.9Pq

+
    +
  • Two changes from Stephen P Wall. + From his description: +
    + 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. +

    + 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. +

    + +
  • Integrated a patch from Juliusz Chroboczek <jec@dcs.ed.ac.uk>. + From his description: +
    + With this patch, selection conversion works properly: +
    +	ISO 8859-1 xterm -> ISO 8859-1 xterm (transferred as STRING);
    +	ISO 8859-1 xterm -> UTF-8 xterm (transferred as STRING);
    +	UTF-8 xterm -> ISO 8859-1 xterm (transferred as STRING);
    +	UTF-8 xterm -> UTF-8 xterm (transferred as UTF-8).
    +
    + 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. +
    +
+ +

Patch #106 - 1999/6/9 - XFree86 3.9Pq

+
    +
  • remove duplicate fix for OpenBSD in resize.c + +
  • 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). + +
  • integrate patch by Markus Kuhn to provide limited support for + input of UTF-8 16-bit data by a lookup table. + +
  • correct check in non_blank_line to ensure we're in wide-character + mode before looking at the high bytes, for InsertChar. +
+

Patch #105 - 1999/6/5 - XFree86 3.9Pp

+
    +
  • implement new resource trimSelection, which allows xterm + to trim trailing blanks from selected lines. This does not affect + the highlighting. (reported by several people using mutt, + including + Hans Morten Kind <edphk@uib.no>, + Jeremy <jeremy@exit109.com> + and (Michael Fuller <msf@mds.rmit.edu.au>). + +
  • add patch by Matthieu Herrb to include term.h in resize for OpenBSD. + +
  • 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 + <Thomas.Wolff@icn.siemens.de>). +
+ +

Patch #104 - 1999/5/30 - XFree86 3.9Pn

+This is a resync patch against XFree86 3.9Pn, reflecting changes which were +submitted by Branden Robinson, who worked with +Wichert Akkerman <wichert@cs.leidenuniv.nl> +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. +

+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). + +

Patch #103 - 1999/5/14 - XFree86 3.9Pm

+
    +
  • 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 <walker@pobox.com>). + +
  • improved support for Unix98 PTY's, using patch in Debian bug report + #35650, by J.H.M. Dassen <jdassen@wi.leidenuniv.nl>. From + the patch description: +
    +
      +
    • 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. +
    • 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. +
    +
    + +
  • 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 <peterw@dascom.com>). +
+ +

Patch #102 - 1999/5/12 - XFree86 3.9Pm

+
    +
  • 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). + +
  • 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). +
+ +

Patch #101 - 1999/5/10 - XFree86 3.9Pm

+
    +
  • 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 <Jens.Schleusener@dlr.de>) + +
  • added "Meta <Btn2Down>:clear-saved-lines()" default + translation (patch by H Merijn Brand) + +
  • 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 + <PROCURA_BV@CompuServe.com>) + +
  • add more parentheses in ifdef's (patch by Bob Maynard). + +
  • eliminate conflicting definitions for USE_TERMINFO in resize.c + (reported by Jeremy Buhler). + +
  • 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) + +
  • update description in xterm manpage for character class table, + which said it handles only 7-bit codes. + +
  • correct a typo in ScrnDeleteChar() which made it not clear the + high byte of wide-character data. + +
  • 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. + +
  • correct right-limit check when selecting double-width characters. + +
  • change default answerback response to an empty string. +
+ +

Patch #100 - 1999/5/3 - XFree86 3.9Pl

+
    +
  • Correct a typo in the default resource value for + backarrowKeyIsErase: it was always true (reported by Bram + Moolenaar). + +
  • improve configure script's test if the installed xterm is setuid, + in case that is a symbolic link. + +
  • correct "install-ti" rule in Makefile.in, by not setting a blank + $TERMINFO value. That is interpreted as "." by ncurses' tic. +
+ +

Patch #99 - 1999/5/2 - XFree86 3.9Pk

+
    +
  • 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. + +
  • correct argument type for sigsetjmp, incidental change in patch + #96's Unix88 PTY patch (reported by Bram Moolenaar). + +
  • correct description of secondary DA in ctlseqs.ms (reported by Bram + Moolenaar). + +
  • 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. + +
  • 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). + +
  • 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). +
+ +

Patch #98 - 1999/4/26 - XFree86 3.9Pk

+
    +
  • 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. + +
  • 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). + +
  • add a missing null-pointer check in ScrnRefresh, for the + wide-characters configuration. +
+ +

Patch #97 - 1999/4/25 - XFree86 3.9Pk

+
    +
  • 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" <m.lorentz@w12.link-goe.de>). + +
  • completely parenthesize ifdef expressions for Glibc (suggested by + Bob Maynard). + +
  • add initial-erase options (-ie, +ie) to help message (reported by + Vikas Agnihotri). + +
  • remove duplicate definition of USE_USG_PTYS (reported by Jeremy + Buhler). + +
  • change termcap kD and terminfo kdch1 to a DEL + (\177). + I overlooked this when separating the styles of keyboard with + the sunKeyboard resources in patch #94, so that it normally + matches the value of the stty erase character: +
      +
    • Reported by Jae Gangemi <jgangemi@ccf.rutgers.edu>, + this caused emacs to not process the DEL properly, combining it + with succeeding characters. +
    • This does not appear to be related to a problem which I have + found with screen, which translates the stty erase into + the termcap kD or terminfo kdch1 value + (depending on how it is linked) + if the $TERMCAP variable is set when screen is invoked. +
    + +
  • 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 + <Markus.Kuhn@cl.cam.ac.uk>. 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: +
      +
    • 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. +

      + You must use the -u8 command line option + to use this feature, as well as compile with the OPT_WIDE_CHARS + definition. +

    • cut/paste only copies 8-bit characters. +
    • logging is disabled in the wide-character configuration +
    • printing only writes 8-bit characters. +
    • input only does 8-bit characters. This is the area that I know + least about. +
    +
+ +

Patch #96 - 1999/4/19 - XFree86 3.9Pj

+
    +
  • modify Makefile.in to work with configure script's --srcdir option. + (patch by Jeremy Buhler <jbuhler@cs.washington.edu>) + +
  • add checks for 'echo -n' equivalent for 8colors.sh and 16colors.sh + scripts (reported by Vikas Agnihotri). + +
  • 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 <harmsen@erv.ericsson.se>). + +
  • correct horizontal spacing of double width line-drawing characters + that xterm simulates. + +
  • improve support for Unix98 PTY's, using patch in Debian bug report + #35650, by Topi Miettinen <Topi.Miettinen@medialab.sonera.fi>. + Andreas Jaeger says this also corrects a permissions problem + reported by cat@zip.net.au + +
  • modify initial-erase logic to ensure that ttyModes + resource overrides it. +
+ +

Patch #95 - 1999/4/5 - XFree86 3.9Ph

+
    +
  • modify primary DA response to allow a '1' parameter. + +
  • add printer and national replacement character sets to VT220 + primary DA response. + +
  • document primary and secondary DA responses in ctlseqs.ms + +
  • 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). + +
  • make xterm respond to secondary DA when the decTerminalID + is set for VT100. + +
  • limit user-defined keys (DECUDK) to VT220-style keyboard + when sunKeyBoard resource is true. + +
  • 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 From Andreas Jaeger + <aj@arthur.rhein-neckar.de>) + +
  • 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 <hohndel@suse.de>) + +
  • improve scripts in vttests to work with newer shells that do not + use 'echo -n'. + +
  • add fonts.sh example script + +
  • correct inequality in handling of "#1" font specification. + +
  • correct call to XGetWMNormalHints() used for computing maximum + screen size; the size hints may not have been set. + +
  • 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. + +
+

Patch #94 - 1999/3/27 - XFree86 3.9Pf

+
    +
  • further fixes for terminfo: ka1, ka3, etc., differ between the + default xterm-xfree86 and xterm-vt220 entries. + +
  • change default (with sunKeyboard resource false) behavior of + the editing keypad "Delete" to send a 127, like xterm-r6. + The VT220-style <esc>[3~ is sent when + sunKeyboard is true (reported by Tomas Vanhala). + +
  • 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 + <jaltman@watsun.cc.columbia.edu>. + +
  • 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. + +
  • implement DECSET/DECRST numeric keypad (DECNKM) mode. + +
  • modify terminfo and termcap to use recommended "X Window" or "X11" + names rather than "X Windows" (reported by Tomas Vanhala). + +
  • suppress translation of shifted keypad "+" when sunKeyboard + is true. + +
  • workaround unexpected behavior (perhaps bug) in XmbLookupString, + which returns trash in the string buffer for numlock and control-key + combined with keypad-keys. + +
  • modify ScrollBarReverseVideo() to keep scrollbar border visible + when reverse video is toggled. + +
  • correct missing case for parameter 17 (set highlight color) in + dynamic colors control sequences. + +
  • extend dynamic colors control sequences to allow users to + determine the colors and font which are currently active. + +
  • 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 + <esc>backslash very well. + +
  • separate menu settings for reverse video from that done under + program control. + +
  • corrected ifdef's for menus, which did not allow tek4014 to + be suppressed properly (reported by Clint Olsen). + +
  • integrated patch from Pavel Roskin + <pavel_roskin@geocities.com> + for Linux-2.2.x with GLibc-2.1 and + /dev/ptmx support: +
      +
    • main.c and resize.c were using different rules to determine + whether ATT should be defined (actually USE_USG_PTYS is more + apt). + +
    • copy definitions from main.c to resize.c to prevent + sys/stream.h and sys/ptem.h from inclusion when SYSV is not + defined + +
    • define CNUL if not already defined like other variables. + +
    • /dev/tty does exist in Linux, but it doesn't mean, it + should be used. Therefore EACCES is now an acceptable + result. + +
    • ifdef'd several calls such as ioctl (ptyfd, I_PUSH, + "ptem") to build on Linux (I_PUSH is not defined when + sys/stropts.h is not included). +
    + +
  • initialize second "ltc" variable in main.c (reported by David + Dawes). + +
  • provide definition for USE_USG_PTYS in screen.c + +
  • add resource-files to install rule in standalone Makefile.in + +
  • add sample scripts to illustrate titlebar controls, resizing + and colors. +
+ +

Patch #93 - 1999/3/14 - XFree86 3.9Pd

+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. +
    +
  • remove kfnd/kll/kslt strings from terminfo, because curses + applications do not necessarily return khome/kend pairs + (reported by Vikas Agnihotri). + +
  • 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. + +
  • 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. + +
  • separate command-line settings for reverse video from that done + under program control. This is a problem which was introduced by + X11R6. Though correct, most users are confused by allowing + the reset command to undo the effect of the command-line -rv + option. + +
  • add description of function keys, keypad and cursor keys to ctlseqs.ms + +
  • add terminfo entries for xterm-vt52, xterm-sun and xterm-hp + +
  • correct typo (missing case value) for DECSET 35, enable/disable + shifted keypad action and a few compiler warnings (reported by Zdenek + Sekera <zs@sgi.com>). + +
  • correct reporting of color values 8-15 in DECRQSS (reported by + Vikas Agnihotri). + +
  • modify parsing of ttyModes resource to recognize "^-" as "undef" + (requested by Tomas Vanhala). + +
  • integrate/extend changes to add iconify/maximize actions + (from Edward S. Arthur <eda@ultranet.com>). + +
  • add control sequences for maximizing/restoring window, and + for reporting maximum screen size. + +
  • add 'interpret' action, to support local function-key interpretation. + Used properly, this makes most of the specialized actions of xterm + redundant. + +
  • 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. + +
  • add configure option --disable-maximize + +
  • add configure option --disable-num-lcok + +
  • extend descriptions of configure script options in INSTALL. +
+ +

Patch #92 - 1999/2/5 - XFree86 3.9Nz

+
    +
  • increase buffer size for tgetent (i.e., termcap) to 1500. This + fixes a problem where screen is built using ncurses or + GNU termcap and xterm 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 + screen program's termcap entry is about 1200 characters + long. + +
  • change update_menu_item() to a function, to simplify debugging. + This also reduces the executable by 4Kb. + +
  • 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). + +
  • add control sequence for DECSET 35, which enables/disables the + shifted keypad functions. + +
  • add support for switching font sizes, by stepping through the + font menu using shifted keypad plus and minus. + +
  • correct missing initialization of tekInhibit and tekSmall resources. + +
  • correct ifdef's in charproc.c for XtNgeometry and XtCGeometry + (reported by Bram Moolenaar). +
+ +

Patch #91 - 1999/1/21 - XFree86 3.9Nw

+
    +
  • Implement logic to translate input characters which are mapped + when in vt220 National Replacement Character mode (requested by + Tomas Vanhala). + +
  • Resync configure scripts with my patches to autoconf 2.13 + +
  • Change order of -lXmu and -lXext to accommodate cygwin32 + (reported by Vikas Agnihotri). + +
  • Add "-ti" option to set terminal emulation level from command + line rather than via resource. + +
  • Simplify some of the preprocessor logic using #elif. +
+ +

Patch #90 - 1998/12/13 - XFree86 3.9Nq

+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. + +
    +
  • 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). + +
  • 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. + +
  • 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. + +
  • 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. + +

    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. + +

  • Changed the termcap and terminfo for xterm-xfree86 and xterm-8bit + to use the new 1049 private mode. + +
  • 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. + +

    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). + +

  • Add popup menu entry for toggling the titeInhibit resource. + +
  • Add new resource answerbackString, which overrides the default + "xterm" returned by xterm when responding to an ENQ (control/E) + character (request by Rajesh Vaidheeswarran <rv@fore.com>). + +
  • 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). + +
  • 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 <sales@oeko.net>). + +
  • Add configure script option --disable-boxchars to disable the + fallback support for line drawing characters. + +
  • Fix ifdef's for configure script --disable-ansi-color, and reviewed + all configure options to ensure that all can be enabled/disabled + appropriately. + +
  • Update config.guess and config.sub, from Lynx. +
+ +

Patch #89 - 1998/11/20 - XFree86 3.9Nm

+This patch completes the implementation of double-sized character support +for the VT100 emulation, and fixes a few minor bugs: + +
    +
  • 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 changes to partly implement +double-sized characters. +I noticed it when cat'ing a typescript from vttest's double-sized character +test. +
  • ensure that the current line is repainted when switching between +single and double width characters. +
  • reduce the number of bits used for double-sized character coding +from 3 to 2, to make more room for soft-font codes. +
  • copy newer ifdef's from the XFree86 3.3.3 release's main.c, +which address details of glibc and powerpc. +
  • moved definition of DECL_ERRNO in xterm.h to match XFree86 3.3.3 +
  • modify resize 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. +
+I tested the double-sized characters using vttest and the xfsft patch. +These fonts worked reasonably well: +
+	-bitstream-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1
+	9x15
+
+The iso8859 font does not include box characters, of course, but looks good. + +

Patch #88 - 1998/10/31 - XFree86 3.9Nk and 3.3.2h

+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. + +

Patch #87 - 1998/10/21 - XFree86 3.9Nj and 3.3.2f

+This corrects a problem reported by Stefan Dalibor. My table entries for the +printerExtent and printerFormFeed resources used the wrong +types for sizeof, causing the printer to not work properly on some platforms +because the printAttributes resource was overwritten (e.g., Digital Unix with DEC Alpha). +

+I reviewed all of the resource table entries and fixed a potential problem with +resizeGravity, which was typed as int rather than +XtGravity. + +

Patch #86 - 1998/10/14 - XFree86 3.9Nj and 3.3.2e

+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. + +

Patch #85 - 1998/10/12 - XFree86 3.9Nj and 3.3.2e

+Some cleanup (I noticed the pixel droppings a few months ago after getting a +new 17" monitor): +
    +
  • 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. + +
  • modified by renaming variables and adding casts to permit compile + with g++. + +
  • modify headers so they can all be compiled without order + dependencies, and use bracketed rather than quoting includes to allow + compile from separate directory. + +
  • renamed xtermm terminfo entry to xterm-mono, to avoid conflict with + Solaris entry now in ncurses. +
+ +

Patch #84 - 1998/10/9 - XFree86 3.9Ni and 3.3.2e

+Several small fixes and enhancements, including a patch from +Bjorn Helgaas: +
    +
  • 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. + +
  • remove the LINEWRAPPED attribute from lines as they are cleared. + Previously, the attribute was set but never cleared. + +
  • make word and line selections work even when lines are wrapped + by xterm. Previously, selections were limited to one screen line. +
+as well as +
    +
  • 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. +
  • add kll/kH capabilities to xterm-xfree86 entries in termcap and + terminfo (request by Michael Schroeder). +
  • shorten descriptions in termcap to make resolved entries all + shorter than 1023 character limit. +
  • use DECSTR control sequence to shorten initialization and reset + strings in xterm-xfree86 termcap and terminfo. +
  • use rmul/smul and rmir/smir in xterm-r5 terminfo to match termcap. +
  • correct typos in initialization and reset strings in xterm-r5 + termcap and terminfo. +
  • 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 + <harlan@pointofchoice.com> in linux.debian.user newsgroup). +
+ +

Resync #83 - 1998/10/7 - XFree86 3.3.2e

+ +Merge changes through patch #83 with the 3.3.2e version. This follows a +patch by Matthieu Herrb <matthieu@laas.fr> to add checks for non-null +return from malloc. + +

Patch #83 - 1998/8/25 - XFree86 3.9Nb

+Several small fixes and enhancements: +
    +
  • add configure test to infer if xterm should be installed setuid + based on previously installed xterm (reported by Stephen Marley + and Stefan Dalibor). + +
  • integrate/extend patch by Jason Bacon to implement quasi-continuous + mouse reporting. + +
  • correct control sequences transmitted by function keys F1 to F4 + when sunFunctionKeys resource is true (it was still using the + VT100 control sequences). + +
  • modify handling of backarrow key so that the control modifier + toggles the backspace/delete interpretation set by the + backarrowKey resource. + +
  • limit the row and column values used to report mouse position. +
+ +From resync with XFree86 3.9Nb: +
    +
  • add support for the VSTATUS control character (patch by + Robert Earl <rearl@teleport.com>). +
+ +

Patch #82 - 1998/7/15 - XFree86 3.9Aj

+Bug fix for patch #81: +
    +
  • remove an #undef for NBBY, which caused compile problem on FreeBSD + (reported by David Dawes). +
+ +

Patch #81 - 1998/7/14 - XFree86 3.9Aj

+More bug fixes: +
    +
  • fix conflicting ifdef's for TIOCSLTC when building with Linux on + AXP aka DEC Alpha (reported by Robin Cutshaw). + +
  • correction to patch #79, move assignment for *utptr->ut_user = 0; + back into non-SVR4 ifdef in main.c, since this clobbers username on + Solaris 2.5.1 (analysis by Will Day + <willday@rom.oit.gatech.edu>). + +
  • corrected khome/kend in xterm-8bit terminfo description. + +
  • 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). + +
  • minor fixes for compiler warnings, including a syntax error in + the AMOEBA ifdef's. +
+From resync with XFree86 3.9Aj: +
    +
  • correction to patch #73, supply missing #else for fallback definitions + of size_t, time_t (Robin Cutshaw <robin@intercore.com>). +
+ +

Patch #80 - 1998/6/29 - XFree86 3.9Ai

+This fixes a couple of items leftover or introduced by patch 79: +
    +
  • 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). + +
  • corrected a couple of places in terminfo where I missed using the + vt220-style editing-keypad codes for Find/Select (mapped to Home/End). + +
  • checked termcap file against terminfo, fix several places where it + was inconsistent. +
+ +

Patch #79 - 1998/6/28 - XFree86 3.9Ai

+ +This patch fixes several small bugs: +
    +
  • use X_EXTRA_LIBS in standalone Makefile.in (patch by Tomas Vanhala). + +
  • add new resource 'oldXtermFKeys' which provides backward compatibility + for F1-F4 control sequences with TOG's xterm. + +
  • determine the server's default foreground/background Pixel values, + needed if the -flipPixels X server option is used (reported by + David Dawes). + +
  • 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. + <ronjohn@communique.net>). + +
  • modify logic for editing keypad to work more like VT220: don't + pass those codes in VT100-mode unless oldXtermFKeys mode is set. + +
  • 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). + +
  • use return-value from getuid() rather than the parameter, to work on + systems which do not update the latter (patch by Kevin Buhr + <buhr@mozart.stat.wisc.edu>) + +
  • correct scrollbar border color when toggling to/from secure keyboard + mode (patch by Jeff Uphoff <juphoff@tarsier.cv.nrao.edu>) + +
  • modifications to terminfo file: +
      +
    • rename description to xterm-xfree86, adding an entry 'xterm' + which is derived from xterm-xfree86 to simplify customization. + +
    • 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). + +
    • add user-strings u6, u7, u8, u9 to entries to make them work with + Daniel Weaver's "tack" program. + +
    • modify xterm-24, xterm-bold, xterm-boldso entries to disentangle them from + explicit dependency upon xterm-xfree86. + +
    • add generic 'xterm-color' entry. + +
    • minor corrections to xterm-xfree86, xterm-8bit, xterm-r5 and + xterm-r6 entries. +
    +
+ +

Patch #78 - 1998/6/3 - XFree86 3.9Ah and 3.3.2

+ +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&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. + +

Patch #77 - 1998/5/26 - XFree86 3.9Ah and 3.3.2

+ +Most of the bulk of this patch is to convert the extended C (K&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. +

+The rest of the patch fixes several minor bugs, and adds a few features: +

    +
  • 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). + +
  • document SGR 8, 28 (invisible/visible), add corresponding + capabilities to terminfo description. +

    + 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. + +

  • modify ChangeGroup to not suppress a null-resource, but treat it as an + empty string (recommended by Stefan Dalibor). + +
  • 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. + +
  • adapt TOG fix-3 to in HandleKeymapChange and VTInitI18N (but adapt + XtStackAlloc/XtStackFree for clarity, as well as fixing memory leak). + +
  • 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) + +
  • correct some places where insert/delete did not _move_ the color + attributes, using memmove (patch by Alexander V Lukyanov + <lav@long.yar.ru>) + +
  • add ifdef's for __CYGWIN32__, for port to cygnus version B19.1 + (patch by Andrew Sumner <andrew_sumner@hotmail.com>). + +
  • 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). + +
  • 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 <ben@wiliki.eng.hawaii.edu>). + +
  • correct length of underlining, reducing it by one pixel to avoid + leaving a dot when the application does not clear the whole screen + (patch by (Sergei Laskavy <Laskavy@cs.msu.su>). +

    + 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. + +

  • add include for Xos.h to xterm.h, to ensure proper definitions + (reported by Holger Veit). + +
  • update config.guess to recognize Unixware 2.1 and 7 (patch by + Mike Hopkirk <hops@sco.com>). +
+ +

Patch #76 - 1998/5/8 - XFree86 3.9Ah and 3.3.2

+ +A fix for the print-window function, and some minor cleanup: +
    +
  • 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). + +
  • correct name of $(EXTRA_LOAD_FLAGS) imake variable (reported + by Stefan Dalibor). + +
  • guard logic in ChangeGroup() function against null pointer + (reported by Stefan Dalibor). + +
  • ensure that menu entry for toggling sunKeyboard resource is + initialized (reported by Branden Robinson <branden@purdue.edu>). + +
  • gcc unused-variable warnings (reported by Bernd Ernesti + <bernd@arresum.inka.de>) + +
  • rename global variable 'buffer' to 'VTbuffer' +
+ +

Patch #75 - 1998/5/7 - XFree86 3.9Ah and 3.3.2

+ +This incorporates fixes from several people, as well as some improvements +that I made based on feedback from users: +
    +
  • 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 & feedback from Tor Lillqvist <tml@hemuli.tte.vtt.fi>) + +
  • 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. + +
  • define USE_SYSV_ENVVARS for HP-UX, curses does not use $TERMCAP (patch + by Tor Lillqvist). + +
  • 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). + +
  • modify configure script to obtain the $(EXTRA_LOADFLAGS) value from + imake, needed for compiling under DEC OSF/1 (reported by + Stefan Dalibor) + +
  • 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) + +
  • modify printing code so that the ^M's are not printed if the + printAttribute resource is set to zero (request by Stefan Dalibor). + +
  • correct typo in xterm.man, for the default value of printAttribute + (reported by Stefan Dalibor). + +
  • correct printing code so that the alternate character set is + printed, like other attributes, with escape sequences. + +
  • correct termcap description, removing spurious 'm' character from + the 'op' capability (reported by Greg Woods <woods@weird.com>). + +
  • correct trace code so that the initial timestamp is set. + +
  • 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 <wen1@cec.wustl.edu>). +
+ +

Patch #74 - 1998/4/27 - XFree86 3.9Ag and 3.3.2

+ +This corrects a couple of recent bugs and adds a new resource: +
    +
  • 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 + <VikasA@att.com> and Stefan Dalibor). + +
  • 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. + +
  • add a new resource, "printAttributes", which controls whether + color attributes (or any attributes) are sent to the printer. +
+ +

Patch #73 - 1998/4/25 - XFree86 3.9Ag and 3.3.2

+ +This patch does the following: +
    +
  • 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). +

    + The print facility now also displays the color information. + (I will probably make this a resource). + +

  • modified the xterm-16color terminfo description to use the setaf and + setab strings, which is a little more efficient (requested by Stephen + Marley). + +
  • reduced some clutter of the ifdef/includes (e.g., stdlib.h, unistd.h, + errno) making the configure script test for these. +

    + I removed the symbols Size_t and Time_t, since they no longer serve + a useful purpose. + +

  • 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). +

    + 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 + +

  • updated configure test for ANSI compiler options to handle a + special case for HP-UX 10.x (reported by Clint Olsen). +
+ +

Patch #72 - 1998/4/17 - XFree86 3.9Ag and 3.3.2

+ +This is a patch from Chris Siebenmann <cks@hawkwind.utcs.toronto.edu>, +which I have cleaned up a little, and integrated into the configure script. +

+From his description: +

+ 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. +
+ +

Patch #71 - 1998/4/12 - XFree86 3.9Ag and 3.3.2

+ +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). + +

Patch #70 - 1998/3/29 - XFree86 3.9Af and 3.3.2

+ +This patch corrects some minor bugs in xterm, and fills in some more details +in the VT220 emulation: +
    +
  • modify Imakefile to use SpecialCObjectRule for menu and data modules, + making xterm build properly if logging is enabled + (patch by Scott Sewall <scott@iprg.nokia.com>). + +
  • restore "ich" capability to terminfo entries, since + Michael Schroeder points out that "ich1" + is the one which is the problem in Solaris vi. + +
  • 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). + +
  • correct abbreviation-test for -version and -help options, making + command-line option -vb work (reported by Stefan Dalibor). + +
  • correct a dependency between ifdef's for OPT_I18N_SUPPORT and + OPT_INPUT_METHOD (reported by Stefan Dalibor). + +
  • 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 <zkrr01@mailbox.neosoft.com>). + +
  • correct a missing increment, which made SS2 and SS3 controls + repeat the shifted character. + +
  • add xterm-nrc to terminfo to illustrate the VT220 national + replacement character sets. + +
  • reformat terminfo using new ncurses tic option "-f", which makes + if/then/else/endif expressions easier to read. +
+ +

Patch #69 - 1998/3/16 - XFree86 3.9Ad and 3.3.2

+ +This corrects the problem in xterm with utmp, reported by Olivier Calle +<olivier@tc.fluke.com> +as well as some other people after the XFree86 3.3.2 release. +

+The error was introduced by my patch #53 in XFree86 3.9r (October 1997). +

+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. +

+I also added tests in the standalone configure script to check for the +existence of waitpid(). + +

Patch #68 - 1998/3/4 - XFree86 3.9Ad and 3.3.1z

+ +This corrects another problem with the logic for highlightColor resource. +As reported by David Dawes: +
+ 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. + +
+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. + +

Patch #67 - 1998/2/23 - XFree86 3.9Ad and 3.3.1e

+ +This patch does the following: +
    +
  • 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 + <Stefan.Dalibor@informatik.uni-erlangen.de>. +

    + I could not reproduce this until I noticed that the -rev option + exposed it nicely. + +

  • 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). + +
  • restore 1-pixel overlap of scrollbar border with left edge of window + (reported by Jim Burmeister <jimb@metrolink.com>). + +
  • add a configure option, --enable-logfile-exec, which allows the + user to specify a pipe for logfile. This defines ALLOWLOGFILEEXEC. + +
  • makes the ALLOWLOGFILEEXEC code compile & run, if configured. + +
  • minor documentation nits. +
+ +

Patch #66 - 1998/2/16 - XFree86 3.9Ad and 3.3.1d

+ +This fixes the problem reported with failure to build the resize +program (BSDI, OSF/1) due to not having <termcap.h>, 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 <termcap.h> to build, but only for a clean compile, since it +may declare the tgetent() prototype. + +I also updated the man-page for resize, since I had recently noticed +that it can be used to resize xterm using the "Sun" control sequences +option. + +

Patch #65 - 1998/2/14 - XFree86 3.9Ad and 3.3.1c

+ +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. + +

Patch #64 - 1998/2/8 - XFree86 3.9Ad

+ +This fixes the following problems with xterm: +
    +
  • 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 <jb@chromatic.com>). +

    + 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. + +

  • 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). + +
  • 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. + +
  • corrects a length in checking command-line options, which caused the + "-help" message to not work when X was not running. + +
  • adds some detail to the man-page (requested by Jason Bacon + <acadix@execpc.com>) + +
  • 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). +
+ +

Patch #63 - 1998/2/5 - XFree86 3.9Ad

+ +This is another patch from Bjorn Helgaas <helgaas@rsn.hp.com>, which I've +reviewed (and learned some). Following are his notes: +

+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: +

    +
  • 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. + +
  • 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. + +
  • configure.in: Added temporary setting of CPPFLAGS before + AC_CHECK_HEADERS for X11 files. Previously <X11/DECkeysym.h> + and <X11/Xpoll.h> 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. +
+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. + +

Patch #62 - 1998/1/23 - XFree86 3.9Ac

+ +This is a patch mostly by Bjorn Helgaas <helgaas@dhc.net> (I added the +os2main.c change, and a little of the documentation). From Bjorn's +description: +
    +
  • If you use the "-hc <color>" 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. + +
  • 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). +
+ +

Patch #61 - 1998/1/17 - XFree86 3.9Ac

+ +This patch modifies the reset behavior of xterm slightly: +
    +
  • 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. + +
  • modifies the treatment of hard reset by the xterm program to + reset the saved lines. + +
  • corrects hard reset by also resetting user-defined keys (DECUDK). +
+ +

Patch #60 - 1998/1/10 - XFree86 3.9Ab

+ +This fixes some minor bugs and adds new functionality: +
    +
  • add support for blinking text. +
      +
    • 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. + +
    • 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. + +
    • 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. +
    + +
  • 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. + +
  • flush the output of the transparent printing after each line + Reported by Tomas Vanhala <vanhala@ling.helsinki.fi>. + +
  • correct the modes that are affected by save/restore cursor by adding + WRAPAROUND and PROTECTED. + +
  • 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. + +
  • 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). +
+ +

Patch #59 - 1998/1/5 - XFree86 3.9Ab

+ +My last patch has an off-by-one error in the comparison for argc. Douglas +Kosovic <douglask@dstc.edu.au> 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). + +

Patch #58 - 1998/1/3 - XFree86 3.9Ab

+ +This patch does the following: +
    +
  • implement logic to permit xterm to work with proportional fonts. +
      +
    • Thomas Wolff + <Thomas.Wolff@sietec.de> + requested this (but it isn't exactly what he's asking + for - that's a more involved task). + +
    • 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. + +
    • 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. +
    + +
  • added a version number to the program (several people have requested + this). + +
  • make the -version and -help options interpreted before the program + attempts to open the display. + +
  • minor reorganization of the man-page (ordered the options, resources + and translations alphabetically - and eliminated some duplication). + +
  • corrected a misspelled filename in Makefile.in, and added a lint + rule. + +
  • 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). + +
  • regenerated the configure script with a newer patch to autoconf + that fixes a problem with environment space vs the configure --help + message. +
+

Patch #57 - 1997/12/26 - XFree86 3.9Aa

+ +This patch is mostly concerned with the standalone configure script; a few +minor corrections are added: +
    +
  • add configure option --disable-tek4014, to allow xterm to be built + without the tek4014 emulation. + +
  • 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 <stephen@memex.com>. + +
  • fix a typo in the configure --help message -- reported by Darren + Hiebert <darren@hmi.com>. + +
  • review diffs between main.c and os2main.c, to make them more alike. + (applies some minor bug-fixes to OS/2's version). + +
  • add missing quotes in memmove/bcopy configure test +
+ + +

Patch #56 - 1997/11/28 - XFree86 3.9x

+ +This patch is based on analysis by Arfst Ludwig <arfst@luxor.IN-Berlin.DE>, +who reported: +
+ Setting the following resources xterm (all current versions) receives a + segmentation fault on <Btn2Up> after scrolling: +
+
+	  *XTerm*VT100*translations:    #override \
+	      ~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)
+
+ (The above resources intention is to be able to paste the latest + selection even if the xterm was cleared.) +

+ 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. +

+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. + +

Patch #55 - 1997/11/25 - XFree86 3.9x

+ +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. +

+The bug is simple to test if you set titeInhibit false. + +

Patch #54 - 1997/10/17 - XFree86 3.9s

+ +This patch does the following: +
    +
  • correct a minor placement problem with the right scrollbar. + +
  • 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. + +
  • implement the alternate-screen menu entry +
+ +

Patch #53 - 1997/10/12 - XFree86 3.9r

+ +This patch adds a fix and implements a new feature (as well as some minor +typos): +
    +
  • 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. + +
  • Michael Rohleder <michael.rohleder@stadt-frankfurt.de> sent + me a patch which implements right-scrollbars for xterm. I used that + as a starting point, renamed the command-line options and reduced + the number of ifdef's. +
+ +

Patch #52 - 1997/9/29 - XFree86 3.9q

+ +This patch addresses bugs and requests reported by +
    +
  • Bob Maynard <rmaynard@montana.com>, +
  • Clint Olsen <olsenc@ichips.intel.com>, +
  • JCHANDRA@Inf.COM (JCHANDRA), +
  • Michael Schroeder <Michael.Schroeder@informatik.uni-erlangen.de>, +
  • Pablo Ariel Kohan <pablo@memco.co.il> +
+ +Some of the changes are interrelated (it was an unusually busy week). +
    + +
  • change the default resource value for colorMode to true, matching + the Xterm.ad file. + +
  • 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). + +
  • 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). + +
  • add resource colorAttrMode to specify whether colorULMode and + colorBDMode can override the ANSI colors + (from a problem report by Clint Olsen). + +
  • 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). + +
  • 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.). + +
  • add configure script options for building with the Xaw3d and neXtaw + libraries. + +
  • 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). + +
  • various minor updates to configure-script macros. +
+ +

Patch #51 - 1997/9/15 - XFree86 3.9p

+ +Most of this patch is related to the standalone configure script, though +there are fixes/enhancements as well: +
    +
  • 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. + +
  • correct a reversed foreground/background test in the control + sequence that replies with the current SGR settings. + +
  • 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. + +
  • restructured autoconf macros (I made a library of all of the + macros across the complicated configure scripts I'm working on). + +
  • use the autoconf config.guess and config.sub scripts to better + identify the host-os. + +
  • improve the configure script that uses 'imake' as a fallback for + definitions. + +
  • correct several instances of unsigned/signed mixed expressions. +
+ +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). + +

Patch #50 - 1997/8/22 - XFree86 3.9m

+ +This is a collection of small fixes, and a couple of minor enhancements: +
    +
  • plug a security hole in the implementation of Media Copy (print) + by invoking setuid just before the main loop. + +
  • add an ifdef'd include for <sys/termio.h> for HP-UX, which allows + the program to process SIGWINCH events (this is a bug in X11R6.3) + +
  • add state-table entries for VT52 emulation to enter/exit keypad + application mode. + +
  • disable the popup-menu entry for 8-bit controls when the terminal-id + is less than 200 (e.g., VT52 or VT100). + +
  • 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. + +
  • 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. + +
  • implement VTxxx KAM (ISO AM), which allows a keyboard to be locked + (i.e., the terminal discards input). + +
  • implement VTxxx SRM, which is used to control local echoing of + input on the terminal. + +
  • add terminfo and termcap entries for xterm-8bit, a variation of + the xterm description that uses 8-bit control characters. + +
  • add fallback definitions for Imakefile to allow it to work on some + X11R5 systems that have no SpecialCObjectRule or ProgramTargetName + macros. + +
  • add .c.o and .c.i rules to standalone Makefile.in + +
  • correct order of -lXmu and -lXext in standalone configure script. + +
  • 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). + +
  • 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). + +
  • correct minor compile errors in the configuration where active-icon + is not used. + +
  • add configure option to suppress echoing of long compiler commands + +
  • correct spelling of decTerminalID in configure script help message + +
  • use gcc __attribute__((unused)) to quiet warnings about unused + parameters when compiling with -W (to make it simpler to find the + real problems). +
+ +

Patch #49 - 1997/8/10 - XFree86 3.9k

+ +This patch implements the VT100/VT220 Media Copy (i.e., print-screen) control +sequences. + +

Patch #48 - 1997/7/26 - XFree86 3.9j

+ +This patch does the following (all but the first affect only the standalone +configure script): +
    +
  • minor correction to positioning of underlines for small (e.g., 5x8) + font size. +

    + The existing behavior allowed underlines to be drawn outside the + character-cell, so they weren't cleared properly under some + circumstances. + +

  • adds more special-case tokens to the standalone configure script's + imake-option filter (e.g., "&&", since a "make -n main.o" on my IRIX + system uses that shell construct). + +
  • adds a '--enable-logging' option for the standalone configure script. + +
  • 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). +
+ +

Patch #47 - 1997/7/13 - XFree86 3.9i

+ +This patch does the following +
    +
  • corrects an indexing error in the doublesize character logic + (button.c) that caused core dump (this was reported by J. Wunsch). +
  • corrects the logic of ShowCursor when it is painting in a doublesize + cell (charproc.c). +
  • corrects, according to vttest, the behavior when switching to + doublesize characters and back again (doublechr.c). +
  • adds cbt (back_tab) to the terminfo description (this was something + that I'd overlooked as applicable to curses optimization last + summer). +
  • corrects, for the standalone xmc test, the logic for disabling xmc. +
+ +

Patch #46 - 1997/7/4 - XFree86 3.9h

+ +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. + +

Patch #45 - 1997/7/2 - XFree86 3.9h

+ +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. + +

Patch #44 - 1997/6/22 - XFree86 3.9g

+ +This implements the first part of the VT100 doublesize characters for xterm, +as well as fixing a handful of bugs: +
    +
  • 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). + +
  • 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). + +
  • corrected 'memmove()' logic, for standalone builds (it referenced a + malloc wrapper from my development library). + +
  • 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). +
+ +

Patch #43 - 1997/6/10 - XFree86 3.9d

+ +Here's a fix for two problems: +
    +
  • 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. + +
  • a nit in the configure script (log extra information to help diagnose + which case of the test-compile of tgetent was used). +
+ +

Patch #42 - 1997/6/8 - XFree86 3.2Xl

+ +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. + +

Patch #41 - 1997/5/28 - XFree86 3.2Xl

+ +Some nits found by Darren Hiebert (missing part of install-rule, incorrect +assignment for --enable-color-mode option). + +

Patch #40 - 1997/5/26 - XFree86 3.2Xl

+ +Patch for the configure script's logic for obtaining imake predefined +symbols. + +

Patch #39 - 1997/5/24 - XFree86 3.2Xl

+ +This patch does the following: +
    +
  • integrate the 16-color change for 'xterm' + +
  • minor fixes/clarification of tgetent in terminfo vs termcap to + 'resize' +
+ +(both changes also modify the configure script) + +

Patch #38 - 1997/5/22 - XFree86 3.2Xh

+ +This implements a simple configuration script with autoconf (to which I'll +add more options later). It does the following: +
    +
  • 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). + +
  • enables/disables the configuration ifdef's for ANSI color and VT52 + emulation. +
+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). + +

Patch #37 - 1997/5/7 - XFree86 3.9a

+ +This corrects a minor, but annoying error in the vt220 emulation: the DECUDK +is only supposed to be interpreted for _shifted_ function keys. + +

Patch #36 - 1997/1/16 - XFree86 3.2r

+ +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. + +

Patch #35 - 1997/1/7 - XFree86 3.2o

+ +This patch does the following: +
    +
  • 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). + +
  • 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. + +
  • 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). +
+ +

Patch #34 - 1997/1/5 - XFree86 3.2o

+ +This patch does the following: +
    +
  • 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). + +
  • some minor tidying up (e.g., signed/unsigned use bitcpy, MODE_DECCKM, + resetColor, resetCharsets). More is done in patch #35. +
+ +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. + +

Patch #33 - 1996/11/24 - XFree86 3.2

+ +This adds to the reset-fix by Matthieu Herrb <Mathieu.Herrb@mipnet.fr> 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. + +

Patch #32 - 1996/11/21 - XFree86 3.2

+ +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 not changed -- I added a variant, "xterm-rep"). + +

Patch #31 - 1996/11/16 - XFree86 3.2

+ +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. + +

Patch #30 - 1996/11/16 - XFree86 3.2

+ +From bug-report by <auroux@clipper.ens.fr> (Denis Auroux), missing reset to +ground state. I checked through the rest of that table and found another, +in the unimplemented MC (screen print). + +

Patch #29 - 1996/9/15 - XFree86 3.1.2Gb

+ +This patch does the following: +
    +
  • corrects the restoration of color for bold/underline color mode + +
  • adds a resource 'decTerminalID' to control the reporting level of + xterm (e.g., VT100, VT220). + +
  • uses the new resource to implement/correct the DA1, DA2 and + DECRPTUI reports. + +
  • 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). +
+ +All of these changes are based on vttest 2.6 +

+(Most of the volume in the patch is to add 2 more state tables for parsing +the 2nd/3rd device-attribute controls). + +

Patch #28 - 1996/8/31 - XFree86 3.1.2F

+ +This patch corrects the following reported by Roland Rosenfeld +<roland@spinnaker.rhein.de>: +
    +
  • handle SGR 22, 24 and 25 in combination with colorUL and colorBD + resources. Also noted & fixed reset of colored underline/bold + with SGR 0. + +
  • a typo in the termcap (missing '['), from 3.1.2Dj (my error) +
+ +Roland also complained that he couldn't use box characters with +
+	-adobe-courier-bold-r-normal--12-120-75-75-m-70-iso8859-1
+
+but that's a known xterm limitation (the box characters must be part of the +font, in the first 32 locations). + +

Patch #27 - 1996/8/21 - XFree86 3.1.2Ek

+ +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). + +

Patch #26 - 1996/8/20 - XFree86 3.1.2Ei

+ +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). + +

Patch #25 - 1996/8/18 - XFree86 3.1.2Ei

+ +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: +
    +
  • make the second alternate font the same as the first (that's what + vt420 and dtterm do) + +
  • corrected DECSCL report when DECSCL hasn't been set (i.e., don't + return a '60'). +
+ +

Patch #24 - 1996/8/11 - XFree86 3.1.2Ee

+ +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 ;-). +

+It does NOT do: +

    +
  • soft fonts + +
  • rigel or sixel graphics +
+

+Anyway, I: +

    + +
  • added ECH, CPL, CNL, SU, SD, CBT, CHT controls + +
  • added popup-menu for switching between DEC and Sun function keys. + (corrected alignment err wrt logging entry at that point). + +
  • make xterm recognize both 8-bit and 7-bit controls (including + popup menu for switching modes). + +
  • add user-definable function keys (aka DECUDK) + +
  • support concealed text + +
  • support protected text (both ISO compatible and DEC compatible - + that's not the same thing, btw), with SPA, EPA, DECSCA, DECSED, + DECSEL controls. + +
  • implement DECSCL. +
+

+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).. + +

Patch #23 - 1996/7/31 - XFree86 3.1.2Ec

+ +This removes the blinking cursor I added last week (for performance reasons). +Time-permitting, I'll revisit this after 3.2 is released (there will be more +work after XFree86 3.2, I assume). + +

Patch #22 - 1996/7/26 - XFree86 3.1.2Ec

+ +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. +

+Also: +

    +
  • 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. + +
  • implemented blinking cursor (default is off) +
+ +

Patch #21 - 1996/7/24 - XFree86 3.1.2Ec

+ +This patch does the following: +
    +
  • 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 ;-) + +
  • adjusts the shell's background color in ReverseVideo so that flicker + in resizing is reduced + +
  • adds an ifdef OPT_ISO_COLORS to allow configuring xterm without + the ISO color support (saves a lot of memory) + +
  • 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). +

    + (If anyone needs numbers, I had savedLines set to 2000, and found + a reduction from ~700k to ~400k of allocated memory, according to + Purify). +

+ +

Patch #20 - 1996/7/24 - XFree86 3.1.2Ec

+ +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. + +

Patch #19 - 1996/7/21 - XFree86 3.1.2Ec

+ +This patch does the following: +
    +
  • fixes the core dump that I reported on IRIX 5.2 (in main.c) +

    + (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...) + +

  • 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). + +
  • change some memmove calls to memcpy for slightly better performance. + (also, a couple of memset calls to bzero - Quantify says bzero runs + 20% faster, I assume because there's one less argument). + +
  • interpret character sets 1 and 2 (so that vttest gives a reasonable + result) Both rxvt and dtterm do something equivalent. + +
  • fix a minor memory leak in the logic that retrieves the window or + icon names (Purify found this for me while I ran vttest). +
+ +

Patch #18 - 1996/7/18 - XFree86 3.1.2Ec

+ +This implements the following: +
    +
  • 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?) + +
  • minor tweak to the screen-repainting when resizing (I still cannot + entirely get rid of flicker). + +
  • still more fixes to terminfo & termcap (I corrected my error for + the hpa code and added some other stuff by comparing to ncurses' + description and rxvt's). + +
  • a tweak to the patch by Michael Rohleder for the color translation + +
  • 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). +
+ +

Patch #17 - 1996/7/2 - XFree86 3.1.2Eb

+ +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...) + +

Patch #16 - 1996/6/25 - XFree86 3.1.2Ea

+ +Adam Tla/lka <atlka@pg.gda.pl> 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 ;-) + +

Patch #15 - 1996/5/29 - XFree86 3.1.2E

+ +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). + +

Patch #14 - 1996/5/12 - XFree86 3.1.2Dj

+ +This patch brings the termcap and terminfo descriptions for xterm up to date. +I made the following changes: +
    +
  • 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). + +
  • omitted obsolete features in termcap to save a little space (bs, pt) + +
  • added color capabilities to termcap (ut, Co, NC, op, AB, AF) + +
  • corrected some capabilities (vi, ve) + +
  • added 'st' (set tab) + +
  • reduced function keys in termcap for 'xterm' to 12 because color + capabilities makes that description larger than 1023 characters. + +
  • created new termcap name 'xtermm' (monochrome) to match the terminfo + list, and make that description have 20 function keys. + +
  • added corresponding color capabilities to terminfo (bce, colors, + pairs, op, ncv, setab, setaf) + +
  • corrected corresponding capabilities in terminfo (civis, cnorm, + rmcup, smcup) + +
  • added capabilities (el1, hts) + +
  • in both, corrected home/end keys to match the code correction made + by Thomas Mueller in 3.1.2Bk + +

    => (I'm still considering modifying the code & description to match + the rxvt program). +

+ +

Patch #13 - 1996/4/23 - XFree86 3.1.2Df

+ +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. + +

Patch #12 - 1996/3/16 - XFree86 3.1.2Dc

+ +This corrects a memory leak in xterm that happens whenever one switches fonts. + +

Patch #11 - 1996/3/5 - XFree86 3.1.2Db

+ +This patch corrects the behavior of the ANSI colors in xterm when reverse +video is used, as well as some other lesser sins: +
    +
  • button.c +
      +
    • (compiler warnings: shadowing of 'time', redundant cast) +
    + +
  • charproc.c +
      +
    • renamed screen.colors[] array to screen.Acolors[] to more + easily distinguish the non-ANSI colors from the ANSI colors. + +
    • moved logic of SGR_Save() into VTInitialize, getting rid of + local private variables original_fg and original_bg. + +
    • moved some logic into getXtermForeground and getXtermBackground + from SGR_Foreground, SGR_Background, etc. + +
    • corrected misleading 'row' to 'col' in case for CUF, CUB + sequences. +
    + +
  • ctlseqs.ms +
  • xterm.man +
      +
    • (correct a misconception which I'd added that the color0 + through color6 resource values apply to non-ANSI colors) +
    + +
  • ptyx.h +
      +
    • added original_fg, original_bg to TScreen structure. +
    + +
  • scrollbar.c +
      +
    • (compiler warnings: redundant cast) +
    + +
  • util.c +
      +
    • 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. + +
    • in ReverseVideo, swap the SGR foreground and background colors + also. +
    +
+ +

Patch #10 - 1996/2/14 - XFree86 3.1.2Cd

+ +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. +

+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). + +

Patch #9 - 1996/2/10 - XFree86 3.1.2Cb

+ +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. +
    +
  • corrected ifdef's that suppress the input-method code (doesn't + exist in my x11r5, and xterm works adequately without it). + +
  • corrected fallback definition for 'Select()' macro (oops: I'd + copied the wrong text...) + +
  • moved the declarations for the fd_set variables to data.[ch] + +
  • corrected an ifdef in resize.c (sunos 4.x doesn't have termcap.h) + +
  • corrected (in main.c) some unused/orphaned variables. +
+ +

Patch #8 - 1996/2/9 - XFree86 3.1.2Cb

+ +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. +

+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 that yet. + +

Patch #7 - 1996/1/28 - XFree86 3.1.2n

+ +I did a (clean) build of 3.1.2n on Linux 1.2.13 (ELF). I've got an S3 card. +

+This fixes the following in the 3.1.2n xterm: +

    +
  • initialize cur_foreground, cur_background in charproc.c (Purify + told me they weren't initialized). + +
  • 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. + +
  • shadowing of 'time' in menu.c + +
  • 'Cardinal' vs 'int' in scrollbar.c + +
  • 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). +
+

+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. +

+btw: +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). + +

Patch #6 - 1996/1/8

+ +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. +
    +
  • charproc.c: +
      +
    • add/use new macros GET_FG, GET_BG - n/c. + +
    • add/use new functions SGR_Foreground() and SGR_Background() + to set corresponding colors in GC's, and to retain sense of + "original" colors. + +

      + => This makes redundant some of the corresponding logic + in HideCursor to set the foreground and background, + but I left it in since it may be fixing an unrelated + requirement. + +

    • set GC's in LoadNewFont() according to whether the SGR fg/bg + colors are active. + +

      + => This fixes some glitches in the accompanying resize, + that leaves parts of the window in the original + background color. +

    + +
  • screen.c: +
      +
    • modified ClearBufRows() to use the SGR fg/bg colors if + they're set. + +
    • 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. + +

      + => Otherwise, selection after an index or reverse index will + paint the wrong colors. + +

    • modified ScrnDeleteChar() and ScrnInsertChar() + to use SGR fg/bg colors. +
    + +
  • util.c: +
      +
    • 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. + +
    • modified ClearLeft to use SGR fg/bg colors. +
    +
+ +

Patch #5 - 1996/1/7

+ +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...). +

+Anyway, the revised code generates a smaller object... +

    +
  • charproc.c: +
      +
    • recode index expressions in ShowCursor() and HideCursor() + using SCRN_BUF_xxxxS macros - changes object. + +
    • replace constant '4' by MAX_PTRS - n/c. +
    + +
  • ptyx.h: +
      +
    • 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. +
    + +
  • screen.c: +
      +
    • recode index expressions in ScreenWrite() using + SCRN_BUF_xxxxS macros - changes object. + +
    • replace constant '4' by MAX_PTRS - n/c. + +
    • use macros BUF_CHARS, BUF_ATTRS - n/c. + +
    • cast calloc to 'Char *' to fix compiler warning on IRIX - n/c +
    + +
  • scrollbar.c: +
      +
    • replace constant '4' by MAX_PTRS - n/c. + +
    • cast calloc to 'Char *' to fix compiler warning on IRIX - n/c +
    +
+ +

Patch #4 - 1996/1/7

+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). +
    +
  • button.c: +
      +
    • use SCRN_BUF_xxxxS macros - n/c +
    +
  • charproc.c: +
      +
    • use SCRN_BUF_xxxxS macros - n/c +
    +
  • ptyx.h: +
      +
    • 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->buf. +
    +
  • screen.c: +
      +
    • use SCRN_BUF_xxxxS macros - n/c +
    +
  • util.c: +
      +
    • use SCRN_BUF_xxxxS macros - n/c +
    +
+

Patch #3 - 1996/1/7

+ +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). +

+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. +

+The next patches will address the functional changes... +

    +
  • Tekproc.c: +
      +
    • changed several functions to 'static' that aren't used +outside this module -- changes object +
    +
  • charproc.c: +
      +
    • changed several functions to 'static' that aren't used +outside this module -- changes object +
    • deleted unused function unparsefputs -- changes object. +
    +
  • main.c: +
      +
    • changed several functions to 'static' that aren't used +outside this module -- changes object +
    • ifdef'd out unused function 'consolepr()' -- changes object +
    • removed unused variable 'dummy_tio' -- changes object +
    • moved variable 'discipline' to quiet unused-warning -- changes object +
    +
  • main.h: +
      +
    • deleted unused definition of DEFBORDERWIDTH - n/c +
    +
  • misc.c: +
      +
    • changed several functions to 'static' that aren't used +outside this module -- changes object +
    • provide dummy return statements for xerror and xioerror to +quiet compiler warnings -- changes object +
    +
  • ptyx.h: +
      +
    • change sbuf_address and abuf_address to 'Char *' - n/c +
    +
  • resize.c: +
      +
    • changed several functions to 'static' that aren't used outside this module +-- changes object +
    +
  • screen.c: +
      +
    • remove unnecessary 'Char **' casts - n/c +
    +
  • util.c: +
      +
    • changed several functions to 'static' that aren't used outside this module +-- changes object +
    +
+

Patch #2 - 1996/1/7

+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. +

+At this point, I'm compiling (fairly) clean with gcc options +

+	-Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wnested-externs
+
+(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). +

+The changes: +

    +
  • Tekproc.c: +
      +
    • parenthesized expression to avoid gcc warning -- n/c. + +
    • corrected nested-extern declaration for Bool + waiting_for_initial_map; ourTopLevelShellArgs, and + number_ourTopLevelShellArgs - n/c + +
    +
  • charproc.c: +
      +
    • corrected potentially-unintialized variables 'scstype', 'xim', + and 'input_style' -- changes object. + +
    • adjusted logic of VTparse so that gcc won't warn about setjmp + clobbering parsestate -- changes object. + +
    • corrected initialization of 'scstype', which could have been + clobbered by setjmp/longjmp - changes object. + +
    • corrected nested-extern declaration of 'term', 'ProgramName' + - n/c +
    + +
  • cursor.c: +
      +
    • corrected nested-extern declaration of 'term' -- n/c + +
    • renamed 'term' parameters to avoid gcc -Wshadow warning - n/c +
    + +
  • input.c: +
      +
    • change interface of StringInput to assume size_t (i.e., + unsigned) nbytes -- changes object. + +
    • change interface of funcvalue, and sunfuncvalue to use + 'KeySym' type instead of 'int' - changes object. +
    + +
  • main.c: +
      +
    • moved definitions of SIGNAL_T, SIGNAL_RETURN to proto.h - n/c + +
    • corrected missing params of 'do_hangup()' -- changes object + (note: the missing params were not used). + +
    • corrected missing param of 'Error()' -- changes object + +
    • corrected nested-extern 'environ' - n/c + +
    • 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. + +
    • use Size_t type - n/c. +
    + +
  • menu.c: +
      +
    • removed redundant prototype for 'do_hangup()' -- n/c. + +
    • renamed 'time' parameters to avoid gcc -Wshadow warning - n/c +
    + +
  • menu.h: +
      +
    • renamed 'time' parameters to avoid gcc -Wshadow warning - n/c +
    + +
  • misc.c: +
      +
    • corrected definition of 'HandleFocusChange()' -- changes + object + +
    • cast parameters in call to 'TekExpose()' -- n/c + +
    • corrected nested-extern declarations of 'term', 'toplevel', + ProgramName, and 'environ' -- n/c. + +
    • use Size_t type - n/c. +
    + +
  • proto.h: +
      +
    • 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). + +
    • added definition 'Size_t' to use as corrected type for + strncpy, malloc sizes - n/c. +
    + +
  • resize.c: +
      +
    • moved SIGNAL_T definition to proto.h -- n/c. + +
    • use Size_t type - n/c. +
    + +
  • screen.c: +
      +
    • use Size_t type - n/c. +
    + +
  • tabs.c: +
      +
    • corrected nested-extern declaration of 'term' -- n/c +
    + +
  • util.c: +
      +
    • corrected/supplied parameters to 'TekExpose()' -- changes + object (note: 'TekExpose()' doesn't use its parameters). + +
    • corrected nested-extern declaration of + 'waiting_for_initial_map' -- n/c. + +
    • renamed 'term' parameters to avoid gcc -Wshadow warning - n/c +
    + +
  • xterm.h: +
      +
    • prototype 'do_hangup()', 'HandleFocusChange()', + 'TekExpose()', 'Error()', 'Exit()' - forces changes in + various places. + +
    • 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. + +
    • renamed 'term' parameters to avoid gcc -Wshadow warning - n/c +
    +
+

Patch #1 - 1996/1/6

+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). +

+Briefly, this patch adds (and uses) two header files in the xterm directory: +

+	proto.h
+	xterm.h
+
+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. + + diff --git a/nx-X11/programs/xterm/xterm.man b/nx-X11/programs/xterm/xterm.man new file mode 100644 index 000000000..36fa64df0 --- /dev/null +++ b/nx-X11/programs/xterm/xterm.man @@ -0,0 +1,4418 @@ +.\" $XTermId: xterm.man,v 1.320 2005/11/13 23:10:36 tom Exp $ +.\" $Xorg: xterm.man,v 1.4 2001/02/09 02:06:03 xorgcvs Exp $ +.\" +.\" +.\" Copyright 1996-2004,2005 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. +.\" +.\" $XFree86: xc/programs/xterm/xterm.man,v 3.118 2005/11/13 23:10:36 dickey Exp $ +.\" +.\" updated by Thomas E. Dickey for XFree86, July 1996 - July 2004. +. +.de DS +.sp +.in +4 +.nf +.ft C \" Courier +.. +.de DE +.fi +.ft P +.sp +.in -4 +.. +.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'' and ``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 all of the standard X Toolkit command line options as well as +the following. +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. +The message is written to the standard error. +. +.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 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 has to 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. +This font must be the same height and width as the normal font. +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. +The default is to do overstriking of the normal font. +See also the discussion of \fBboldFont\fP and \fBboldMode\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. +.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. +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 doublewidth 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 doublewidth 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. +See also the discussion of the \fBximFont\fP resource. +.TP 8 +.BI -hc " color" +This option specifies the color to use for the background of +selected or otherwise highlighted text. +If not specified, +reverse video is used. +See the discussion of the \fBhighlightColor\fP resource. +.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 -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: ``hp'', ``sco'', ``sun'' and ``vt220''. +The default value ``unknown'', +causes the corresponding resource to be ignored. +.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. +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 +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. +This option can be turned on +and off from the ``VT Options'' menu. +.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 +.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'' and ``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 "-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 -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 zIconBeep 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: +.nf +.RS 15 +-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 default is ``black.'' +.TP 8 +.B -bg \fIcolor\fP +This option specifies the color to use for the background of the window. +The default is ``white.'' +.TP 8 +.B -bw \fInumber\fP +This option specifies the width in pixels of the border surrounding the 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 default is +``black.'' +.TP 8 +.B -fn \fIfont\fP +This option specifies the font to be used for displaying normal text. +The +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. +.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. +.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. +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 and +\fBsunKeyboard\fP. +The resource's value should be one of the corresponding strings +hp, sco, sun 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 "messages (\fPclass\fB Messages)" +Specifies whether write access to the terminal is allowed initially. +See +.BR mesg (1). +The default is ``true''. +.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 \fButmp\fP +and \fBstty\fP state. +Platforms with newer pseudo-terminal interfaces do not require this feature; +normally it is not configured. +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. +The default is ``false''. +.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. +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. +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. +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. +.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. +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.'' +. +.PP +The following resources are specified as part +of the \fIvt100\fP widget (class \fIVT100\fP): +These are specified by patterns such as "\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 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 creates a very large security hole. +The default is ``false.'' +.TP +.B "allowWindowOps (\fPclass\fB AllowWindowOps)" +Specifies whether extended window control sequences (as used in dtterm) +for should be allowed. +The default is ``true.'' +.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. +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 +``white.'' +.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. +.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. +Note that \fIxterm\fP has one bold font which you may set explicitly. +It attempts to match a bold font for the other font selections +(\fBfont1\fP through \fBfont6\fP). +If the normal and bold fonts are distinct, this resource has no effect. +The default is ``true.'' +.IP +Although \fIxterm\fP attempts to match 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". +.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.'' +.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)" +Specifies the maximum number of double-sized fonts which are cached by +\fIxterm\fR. +The default (8) may be too large for some X terminals with limited memory. +Set this to zero to disable doublesize 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 CHARACTER CLASSES 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. +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. +.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 "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 ``black.'' +.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 "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 "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 "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 \fIkeys\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 resource 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 "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. +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. +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.'' +.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 "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 +doublesize characters. +Some older font servers cannot do this properly, will return misleading +font metrics. +The default is ``true''. +If disabled, \fIxterm\fP will simulate doublesize characters by drawing +normal characters with spaces between them. +.TP 8 +.B "forceBoxChars (\fPclass\fB ForceBoxChars)" +Specifies whether \fIxterm\fP should assume the normal and bold fonts +have VT100 line-drawing characters. +The fixed-pitch 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. +If ``false'', \fIxterm\fP will check for missing glyphs in cells 1-31 +and make line-drawing characters directly. +If ``true'', \fIxterm\fP uses whatever is in cells 1-31 without checking. +The default is ``false.'' +.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 ``black.'' +.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 or otherwise +highlighted text. +If not specified, reverse video is used. +The default is ``XtDefaultForeground.'' +.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 "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 never 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 "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. +.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.'' +.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. +.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 "mkWidth (\fPclass\fB MkWidth)" +Specifies whether \fIxterm\fP should use a built-in version of the wide +character width calculation. +The default is ``false.'' +.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. +Set it to 0 to use the old/obsolete behavior. +Set it to 1 to prefix modified sequences with CSI. +Set it to 2 to force the modifier to be the second parameter. +Set it to 3 to mark the sequence with a '>' to hint that it is private. +The default is ``2''. +.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. +.TP 8 +.B "numLock (\fPclass\fB NumLock)" +If ``true'', \fIxterm\fR checks if NumLock is used as a modifier (see \fIxmodmap\fP(1)). +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 "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 "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 whould be raised when Control-G is +received. +The default is ``false.'' +.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 "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 ``true.'' +.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 "reverseVideo (\fPclass\fB ReverseVideo)" +Specifies whether or not reverse video should be simulated. +The default is +``false.'' +.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 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 "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 "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 "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 +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 "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 doublewidth 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 doublewidth 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. +. +.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. +. +.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 "poponbell (\fPclass\fB SmeBSB)" +This entry invokes the \fBset-poponbell(toggle)\fP action. +.TP 8 +.B "marginbell (\fPclass\fB SmeBSB)" +This entry invokes the \fBset-marginbell(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-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. +. +.PP +The \fItekMenu\fP has the following entries: +.TP 8 +.B "tektextlarge (\fPclass\fB SmeBSB)" +This entry invokes the \fBset-tek-text(l)\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(s)\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. +. +.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. +. +.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. +Double-clicking selects by words. +Triple-clicking +selects by lines. +Quadruple-clicking goes back to characters, etc. +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. +. +.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. +. +.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 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. +. +.\" ************************************************************************ +.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 +. +.\" ************************************************************************ +.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. +. +.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 +Enable Curses Emulation (cursesemul) +Enable (or disable) a workaround for the so-called "curses bug". +This corresponds to the +.B -cu +option and the +.B curses +resource. +. +.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 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 Margin Bell (marginbell) +Enable (or disable) a bell when the user types near the right margin. +This corresponds to the +.B -mb +option and the +.B marginBell +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 +. +.PP +The \fIfontMenu\fP sets the font used in the VT102 window, +or modifies the way the font is specified or displayed. +There are three 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. +.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 +.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 +\ Size Characters (tektext2) +.TP +\ 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(1)\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 mouse button twice in rapid succession will cause all +characters of the same class (e.g., letters, white space, punctuation) to be +selected. +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 - +.DS +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 ! " # $ % & ' */ +.\" " <- 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 ' 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}; +.DE +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-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 "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 "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: +.DS +*VT100*translations: #override \\n\\\& + Meta /:dabbrev-expand() +.DE +.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 +.in -8 +.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: \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()" +This action prints the window and is also invoked by the +\fIprint\fP entry in \fImainMenu\fP. +.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 "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 "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-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. +.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-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-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. +.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 and is also invoked from +the \fBmarginbell\fP entry in \fIvtMenu\fP. +.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-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 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 +.\" should toggle "toolBar" resource (see note). +.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-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(1)\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 "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 are: +.DS +.ta 2.5i + Shift Prior:scroll-back(1,halfpage) \\n\\\& + Shift Next:scroll-forw(1,halfpage) \\n\\\& + Shift Select:select-cursor-start() \\\& + select-cursor-end(PRIMARY, CUT_BUFFER0) \\n\\\& + Shift Insert:insert-selection(PRIMARY, CUT_BUFFER0) \\n\\\& + Shift~Ctrl KP_Add:larger-vt-font() \\n\\\& + Shift Ctrl KP_Add:smaller-vt-font() \\n\\\& + Shift KP_Subtract:smaller-vt-font() \\n\\\& + ~Meta :insert-seven-bit() \\n\\\& + Meta :insert-eight-bit() \\n\\\& + !Ctrl :popup-menu(mainMenu) \\n\\\& + !Lock Ctrl :popup-menu(mainMenu) \\n\\\& + !Lock Ctrl @Num_Lock :popup-menu(mainMenu) \\n\\\& + ! @Num_Lock Ctrl :popup-menu(mainMenu) \\n\\\& + ~Meta :select-start() \\n\\\& + ~Meta :select-extend() \\n\\\& + !Ctrl :popup-menu(vtMenu) \\n\\\& + !Lock Ctrl :popup-menu(vtMenu) \\n\\\& + !Lock Ctrl @Num_Lock :popup-menu(vtMenu) \\n\\\& + ! @Num_Lock Ctrl :popup-menu(vtMenu) \\n\\\& + ~Ctrl ~Meta :ignore() \\n\\\& + Meta :clear-saved-lines() \\n\\\& + ~Ctrl ~Meta :insert-selection(PRIMARY, CUT_BUFFER0) \\n\\\& + !Ctrl :popup-menu(fontMenu) \\n\\\& + !Lock Ctrl :popup-menu(fontMenu) \\n\\\& + !Lock Ctrl @Num_Lock :popup-menu(fontMenu) \\n\\\& + ! @Num_Lock Ctrl :popup-menu(fontMenu) \\n\\\& + ~Ctrl ~Meta :start-extend() \\n\\\& + ~Meta :select-extend() \\n\\\& + Ctrl :scroll-back(1,halfpage,m) \\n\\\& + Lock Ctrl :scroll-back(1,halfpage,m) \\n\\\& + Lock @Num_Lock Ctrl :scroll-back(1,halfpage,m) \\n\\\& + @Num_Lock Ctrl :scroll-back(1,halfpage,m) \\n\\\& + :scroll-back(5,line,m) \\n\\\& + Ctrl :scroll-forw(1,halfpage,m) \\n\\\& + Lock Ctrl :scroll-forw(1,halfpage,m) \\n\\\& + Lock @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \\n\\\& + @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \\n\\\& + :scroll-forw(5,line,m) \\n\\\& + :select-end(PRIMARY, CUT_BUFFER0) \\n\\\& + :ignore() +.DE +.PP +The default bindings in the Tektronix window are: +.DS +.ta 2.5i + ~Meta: insert-seven-bit() \\n\\\& + Meta: insert-eight-bit() \\n\\\& + !Ctrl : popup-menu(mainMenu) \\n\\\& + !Lock Ctrl : popup-menu(mainMenu) \\n\\\& +!Lock Ctrl @Num_Lock : popup-menu(mainMenu) \\n\\\& + !Ctrl @Num_Lock : popup-menu(mainMenu) \\n\\\& + !Ctrl : popup-menu(tekMenu) \\n\\\& + !Lock Ctrl : popup-menu(tekMenu) \\n\\\& +!Lock Ctrl @Num_Lock : popup-menu(tekMenu) \\n\\\& + !Ctrl @Num_Lock : popup-menu(tekMenu) \\n\\\& + Shift ~Meta: gin-press(L) \\n\\\& + ~Meta: gin-press(l) \\n\\\& + Shift ~Meta: gin-press(M) \\n\\\& + ~Meta: gin-press(m) \\n\\\& + Shift ~Meta: gin-press(R) \\n\\\& + ~Meta: gin-press(r) +.DE +.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. +.DS +.ta .5i 1.5i +*VT100*translations: #override \\n\\\& + ~Shift~Ctrl: insert-selection(PRIMARY, CUT_BUFFER0) \\n\\\& + Shift~Ctrl: insert-selection(CLIPBOARD, CUT_BUFFER1) \\n\\\& + ~Shift: select-end(PRIMARY, CUT_BUFFER0) \\n\\\& + Shift: select-end(CLIPBOARD, CUT_BUFFER1) +.DE +.PP +Below is a sample how of the \fBkeymap()\fP action is used to add special +keys for entering commonly-typed works: +.DS +.ta .5i 1.5i +*VT100.Translations: #override F13: keymap(dbx) +*VT100.dbxKeymap.translations: \\\& + F14: keymap(None) \\n\\\& + F17: string("next") string(0x0d) \\n\\\& + F18: string("step") string(0x0d) \\n\\\& + F19: string("continue") string(0x0d) \\n\\\& + F20: string("print ") insert-selection(PRIMARY, CUT_BUFFER0) +.DE +.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_SHELL +is set to the pathname of the program which is invoked. +Usually that is a shell program, e.g., \fB/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 turn on color in \fIxterm\fP and similar applications. +. +. +.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 +48 +ERROR_SPREALLOC +.br +spawn: realloc of ttydev failed +.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 +92 +ERROR_SREALLOC +.br +ScreenResize: realloc() failed on alt base +.TP +96 +ERROR_RESIZE +.br +ScreenResize: malloc() or realloc() failed +.TP +102 +ERROR_SAVE_PTR +.br +ScrnPointers: malloc/realloc() failed +.TP +110 +ERROR_SBRALLOC +.br +ScrollBarOn: realloc() failed on base +.TP +111 +ERROR_SBRALLOC2 +.br +ScrollBarOn: realloc() failed on rows +.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(1), luit(1), 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 +. +. +.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 (XFree86 Project). diff --git a/nx-X11/programs/xterm/xterm_axp.opt b/nx-X11/programs/xterm/xterm_axp.opt new file mode 100644 index 000000000..53dab4eb3 --- /dev/null +++ b/nx-X11/programs/xterm/xterm_axp.opt @@ -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/nx-X11/programs/xterm/xterm_io.h b/nx-X11/programs/xterm/xterm_io.h new file mode 100644 index 000000000..337f72800 --- /dev/null +++ b/nx-X11/programs/xterm/xterm_io.h @@ -0,0 +1,309 @@ +/* + * $XFree86: xc/programs/xterm/xterm_io.h,v 1.19 2005/11/13 23:10:37 dickey Exp $ + */ + +/* + * Copyright 2000-2004,2005 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 + +/* + * 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 +#else +#include +#endif + +/* + * Terminal I/O includes (termio, termios, sgtty headers). + */ +#if defined(USE_POSIX_TERMIOS) +#include +#elif defined(USE_TERMIOS) +#include +/* 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 +# else +# include +# endif +#elif defined(SYSV) || defined(ISC) +# include +#elif !defined(VMS) +# include +#endif /* USE_POSIX_TERMIOS */ + +/* + * Stream includes, which declare struct winsize or ttysize. + */ +#ifdef SYSV +#ifdef USE_USG_PTYS +#include /* get typedef used in ptem.h */ +#if !defined(SVR4) || defined(__SCO__) +#include /* get struct winsize */ +#endif +#endif /* USE_USG_PTYS */ +#elif defined(sun) && !defined(SVR4) +#include +#ifdef TIOCSWINSZ +#undef TIOCSSIZE +#endif +#endif /* SYSV */ + +/* + * Special cases (structures and definitions that have to be adjusted). + */ +#if defined(__CYGWIN__) && !defined(TIOCSPGRP) +#include +#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 /* defines TIOCSLTC */ +#endif + +#ifdef ISC +#define TIOCGPGRP TCGETPGRP +#define TIOCSPGRP TCSETPGRP +#endif + +#ifdef Lynx +#include +#elif !(defined(SYSV) || defined(linux) || defined(VMS) || (defined(__QNX__)&&!defined(__QNXNTO__))) +#include +#endif + +#ifdef macII +#undef FIOCLEX +#undef FIONCLEX +#endif /* macII */ + +#ifdef __QNX__ +#undef TIOCSLTC /* conflicts with */ +#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 +#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 + +#endif /* included_xterm_io_h */ diff --git a/nx-X11/programs/xterm/xtermcfg.hin b/nx-X11/programs/xterm/xtermcfg.hin new file mode 100644 index 000000000..b87f9ec13 --- /dev/null +++ b/nx-X11/programs/xterm/xtermcfg.hin @@ -0,0 +1,176 @@ +/* $XTermId: xtermcfg.hin,v 1.143 2005/11/03 13:17:28 tom Exp $ */ + +/* + * $XFree86: xc/programs/xterm/xtermcfg.hin,v 3.57 2005/11/03 13:17:28 dickey Exp $ + */ + +/************************************************************ + +Copyright 1997-2004,2005 by Thomas E. Dickey + + 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_xtermcfg_h +#define included_xtermcfg_h 1 + +/* This is a template for */ + +#undef ALLOWLOGFILEEXEC /* CF_ARG_ENABLE(enable-logfile-exec) */ +#undef ALLOWLOGGING /* CF_ARG_ENABLE(enable-logging) */ +#undef CC_HAS_PROTOS /* CF_ANSI_CC */ +#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_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_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_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_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_UNISTD_H /* AC_CHECK_HEADERS(unistd.h) */ +#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_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_SUNKEYSYM_H /* AC_CHECK_HEADERS(X11/Sunkeysym.h) */ +#undef HAVE_X11_XPOLL_H /* AC_CHECK_HEADERS(X11/Xpoll.h) */ +#undef HAVE_XKB_BELL_EXT /* CF_XKB_BELL_EXT */ +#undef NO_ACTIVE_ICON /* CF_ARG_DISABLE(active-icon) */ +#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_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_SAME_NAME /* CF_ARG_DISABLE(samename) */ +#undef OPT_SCO_FUNC_KEYS /* CF_ARG_ENABLE(sco-fkeys) */ +#undef OPT_SESSION_MGT /* CF_ARG_DISABLE(session-mgt) */ +#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_TRACE /* CF_ARG_ENABLE(trace) */ +#undef OPT_VT52_MODE /* CF_ARG_DISABLE(vt52) */ +#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 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_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_UTMP_SETGID /* AC_ARG_WITH(utmp-setgid) */ +#undef USE_UTEMPTER /* CF_UTEMPTER */ +#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 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 */ + +/* + * g++ support for __attribute__() is haphazard. + */ +#ifndef __cplusplus +#undef GCC_PRINTF +#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 char * my_memmove(char * s1, char * 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 + +#endif /* included_xtermcfg_h */ diff --git a/nx-X11/programs/xterm/xutf8.c b/nx-X11/programs/xterm/xutf8.c new file mode 100644 index 000000000..446ec9606 --- /dev/null +++ b/nx-X11/programs/xterm/xutf8.c @@ -0,0 +1,378 @@ +/* $XTermId: xutf8.c,v 1.8 2005/01/14 01:50:03 tom Exp $ */ + +/* $XFree86: xc/programs/xterm/xutf8.c,v 1.4 2005/01/14 01:50:03 dickey 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 + +#include +#include +#include +#include + +#include + +#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; + int i, j; + int datalen = (int) tp->nitems; + int 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 *, 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/nx-X11/programs/xterm/xutf8.h b/nx-X11/programs/xterm/xutf8.h new file mode 100644 index 000000000..f0cc561a2 --- /dev/null +++ b/nx-X11/programs/xterm/xutf8.h @@ -0,0 +1,61 @@ +/* $XFree86: xc/programs/xterm/xutf8.h,v 1.1 2001/06/18 19:09:28 dickey 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. +*/ + +#ifndef _XLIB_H_ +#error Please include before "xutf8.h" +#endif + +#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 -- cgit v1.2.3