aboutsummaryrefslogtreecommitdiff
path: root/vendor/x11iraf/xgterm
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /vendor/x11iraf/xgterm
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'vendor/x11iraf/xgterm')
-rw-r--r--vendor/x11iraf/xgterm/.gdb_history93
-rw-r--r--vendor/x11iraf/xgterm/.pure0
-rw-r--r--vendor/x11iraf/xgterm/Imakefile154
-rw-r--r--vendor/x11iraf/xgterm/NOTES959
-rw-r--r--vendor/x11iraf/xgterm/README15
-rw-r--r--vendor/x11iraf/xgterm/TODO93
-rw-r--r--vendor/x11iraf/xgterm/Tests42
-rw-r--r--vendor/x11iraf/xgterm/VTPrsTbl.c2956
-rw-r--r--vendor/x11iraf/xgterm/VTparse.def80
-rw-r--r--vendor/x11iraf/xgterm/VTparse.h110
-rw-r--r--vendor/x11iraf/xgterm/XGterm.ad112
-rw-r--r--vendor/x11iraf/xgterm/XGterm.ad.R585
-rw-r--r--vendor/x11iraf/xgterm/_3d44
-rw-r--r--vendor/x11iraf/xgterm/button.c1480
-rw-r--r--vendor/x11iraf/xgterm/charproc.c3877
-rw-r--r--vendor/x11iraf/xgterm/ctlseqs.ms587
-rw-r--r--vendor/x11iraf/xgterm/ctlseqs.ps9696
-rw-r--r--vendor/x11iraf/xgterm/cursor.c244
-rw-r--r--vendor/x11iraf/xgterm/data.c106
-rw-r--r--vendor/x11iraf/xgterm/data.h69
-rw-r--r--vendor/x11iraf/xgterm/error.h111
-rw-r--r--vendor/x11iraf/xgterm/gtermio.c2671
-rw-r--r--vendor/x11iraf/xgterm/gtermio.esc122
-rw-r--r--vendor/x11iraf/xgterm/gtermio.h8
-rw-r--r--vendor/x11iraf/xgterm/input.c295
-rw-r--r--vendor/x11iraf/xgterm/login.cl108
-rw-r--r--vendor/x11iraf/xgterm/main.c5300
-rw-r--r--vendor/x11iraf/xgterm/main.h31
-rw-r--r--vendor/x11iraf/xgterm/menu.c1313
-rw-r--r--vendor/x11iraf/xgterm/menu.h311
-rw-r--r--vendor/x11iraf/xgterm/misc.c1530
-rw-r--r--vendor/x11iraf/xgterm/mkp1
-rw-r--r--vendor/x11iraf/xgterm/ptyx.h557
-rw-r--r--vendor/x11iraf/xgterm/ptyx_new.h1836
-rw-r--r--vendor/x11iraf/xgterm/resize.c584
-rw-r--r--vendor/x11iraf/xgterm/resize.man72
-rw-r--r--vendor/x11iraf/xgterm/screen.c771
-rw-r--r--vendor/x11iraf/xgterm/scrollbar.c531
-rw-r--r--vendor/x11iraf/xgterm/tabs.c106
-rw-r--r--vendor/x11iraf/xgterm/termcap27
-rw-r--r--vendor/x11iraf/xgterm/terminfo17
-rw-r--r--vendor/x11iraf/xgterm/util.c1111
-rw-r--r--vendor/x11iraf/xgterm/xgterm.man981
-rw-r--r--vendor/x11iraf/xgterm/xgterm.ps1298
-rw-r--r--vendor/x11iraf/xgterm/xterm.man1649
-rwxr-xr-xvendor/x11iraf/xgterm/z5
-rw-r--r--vendor/x11iraf/xgterm/zz.c14
47 files changed, 42162 insertions, 0 deletions
diff --git a/vendor/x11iraf/xgterm/.gdb_history b/vendor/x11iraf/xgterm/.gdb_history
new file mode 100644
index 00000000..89d38562
--- /dev/null
+++ b/vendor/x11iraf/xgterm/.gdb_history
@@ -0,0 +1,93 @@
+run
+quit
+run
+where
+quit
+b get_pty
+run
+c
+quit
+b pty_search
+b get_pty
+b init_ttyio
+run
+where
+quit
+b get_pty
+b init_ttyio
+run -display denali:0.0
+p pty
+s
+quit
+b Panic
+run
+s
+s
+s
+s
+p fd
+quit
+b main
+run
+s
+p ptydev
+s
+p xgterm_name
+s
+quit
+b get_pty
+b main
+b get_pty
+run
+quit
+b main
+run
+s
+p toplevel
+p *toplevel
+s
+p app_con
+p *app_con
+s
+p app_con
+p *app_con
+s
+where
+s
+quit
+run
+where
+quit
+b consolepr
+run
+helop
+help
+help running
+set follow-fork-mode
+set follow-fork-mode child
+run
+logo
+quit
+b strerror
+run
+where
+quit
+b get_pty
+run
+quit
+b strerror
+run
+where
+quit
+run
+cd
+p w
+where
+up
+p w
+p w->gterm.cmapName
+where
+down
+p w
+p w->gterm.cmapName
+quit
diff --git a/vendor/x11iraf/xgterm/.pure b/vendor/x11iraf/xgterm/.pure
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/vendor/x11iraf/xgterm/.pure
diff --git a/vendor/x11iraf/xgterm/Imakefile b/vendor/x11iraf/xgterm/Imakefile
new file mode 100644
index 00000000..ec3309e3
--- /dev/null
+++ b/vendor/x11iraf/xgterm/Imakefile
@@ -0,0 +1,154 @@
+XCOMM $XConsortium: Imakefile,v 1.56 92/03/11 17:35:22 gildea Exp $
+XCOMM
+XCOMM Attention xgterm porters
+XCOMM
+XCOMM
+XCOMM Xgterm 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
+
+X11IRAFDIR = ../
+#include <../X11IRAF.tmpl>
+
+/*
+ * add -DWTMP and -DLASTLOG if you want them; make sure that bcopy can
+ * handle overlapping copies before using it.
+ */
+#ifdef SetTtyGroup /* turn on in config/machine.cf */
+ TTYGROUPDEF = -DUSE_TTY_GROUP
+ TTYGROUPDEF =
+#endif
+#ifdef UsePUCCPtyd /* turn on in config/site.def */
+ PUCCPTYDDEF = -DPUCC_PTYD /* does not need to be setuid */
+ PTYLIB = -lpucc
+#endif
+
+/* Hack to build on NOAO HP systems where the Xmu and Xaw libs had to be added
+ * specially to the system they don't come with the default X11 development
+ * system. This also avoids the binary requiring the shared lib version on
+ * systems which may not have it.
+ */
+#if defined(HPArchitecture) && OSMajorVersion >= 10
+ XMULIB = /usr/lib/X11R6/libXmu.a
+ XAWLIB = /usr/lib/X11R6/libXaw.a
+#endif
+
+
+ OSMAJORVERSION = OSMajorVersion
+ OSMINORVERSION = OSMinorVersion
+
+ CDEBUGFLAGS = -g
+ XAWLIB = LibXaw3d
+ DEPXAWLIB = DepLibXaw3d
+ X11IRAFDIR = ../
+
+ MAIN_DEFINES = -DUTMP $(TTYGROUPDEF) $(PUCCPTYDDEF) \
+ -DOSMAJORVERSION=$(OSMAJORVERSION) \
+ -DOSMINORVERSION=$(OSMINORVERSION)
+ MISC_DEFINES = /* -DALLOWLOGFILEEXEC */
+ EXTRA_DEFINES = -DALLOWLOGGING
+ LOCAL_LDFLAGS = -L../lib
+ EXTRA_INCLUDES = -I../include
+ DEPENDFLAGS = -I../include -I../include/ObmW
+
+ SRCS1 = button.c charproc.c cursor.c data.c gtermio.c input.c \
+ main.c menu.c misc.c screen.c scrollbar.c tabs.c \
+ util.c VTPrsTbl.c
+ OBJS1 = main.o input.o charproc.o cursor.o util.o tabs.o \
+ screen.o scrollbar.o button.o misc.o \
+ VTPrsTbl.o data.o menu.o gtermio.o
+ SRCS2 = resize.c
+ OBJS2 = resize.o
+ SRCS = $(SRCS1) $(SRCS2)
+ OBJS = $(OBJS1) $(OBJS2)
+ DEPOBM = DepLibObm DepLibXpm DepLibXaw3d
+
+ PROGRAMS = resize xgterm
+ DEPLIBS1 = XawClientDepLibs $(DEPOBM)
+ DEPLIBS2 =
+ PROGRAMS = xgterm resize
+
+#ifndef TermcapLibrary
+#if SystemV && !defined(MacIIArchitecture)
+#if defined(CrayArchitecture) || defined(RsArchitecture)
+#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
+ OBMLIBS = -lobm -lXpm
+ MATHLIB = -lm
+
+AllTarget($(PROGRAMS))
+
+SpecialObjectRule(main.o,NullParameter,$(MAIN_DEFINES))
+SpecialObjectRule(misc.o,NullParameter,$(MISC_DEFINES))
+SpecialObjectRule(charproc.o,NullParameter,$(MISC_DEFINES))
+
+main.o: ../version.h
+
+#if InstallXgtermSetUID
+SetUIDProgramTarget(xgterm,$(OBJS1),$(DEPLIBS1),$(OBMLIBS) XawClientLibs,$(TERMCAPLIB) $(PTYLIB) $(MATHLIB))
+#else
+NormalProgramTarget(xgterm,$(OBJS1),$(DEPLIBS1),$(OBMLIBS) XawClientLibs,$(TERMCAPLIB) $(PTYLIB) $(MATHLIB))
+#endif
+
+
+#if InstallBinaries
+#if InstallXgtermSetUID && defined(SunArchitecture) && HasSharedLibraries
+#if AlternateUsrLibDir
+#if OSMajorVersion > 4 || (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:: xgterm
+ MakeDir(X11irafBinDir)
+ $(CP) xgterm X11irafBinDir
+ chmod 4755 X11irafBinDir/xgterm
+#else
+#if InstallXgtermSetUID
+install:: xgterm
+ MakeDir(X11irafBinDir)
+ $(CP) xgterm X11irafBinDir
+ chmod 4755 X11irafBinDir/xgterm
+#else
+install:: xgterm
+ MakeDir(X11irafBinDir)
+ $(CP) xgterm X11irafBinDir
+#endif
+#endif
+
+NormalProgramTarget(resize,$(OBJS2),$(DEPLIBS2),NullParameter,$(TERMCAPLIB))
+install:: resize
+ MakeDir(X11irafBinDir)
+ $(CP) resize X11irafBinDir
+#endif
+
+#if InstallAppdefs
+install:: XGterm.ad
+ MakeDir(X11irafAppDir)
+ cp XGterm.ad X11irafAppDir/XGterm
+#endif
+
+#if InstallManuals
+install::
+ MakeDir(X11irafManDir)
+ $(CP) xgterm.man X11irafManDir/xgterm.1
+ $(CP) resize.man X11irafManDir/resize.1
+#endif
+
+DependTarget()
diff --git a/vendor/x11iraf/xgterm/NOTES b/vendor/x11iraf/xgterm/NOTES
new file mode 100644
index 00000000..f14fa19d
--- /dev/null
+++ b/vendor/x11iraf/xgterm/NOTES
@@ -0,0 +1,959 @@
+xgterm.NOTES -- Some random design notes made while writing this code. Not
+intended to be useful to anyone reading this code.
+
+
+To do:
+ Object manager
+ add bitmap support
+ add event handling support
+ Gterm widget
+ add cell array
+ pixrect operations?
+ minor odds and ends
+ Gtermio
+ modify to use object manager
+ add messaging capability
+ GIO
+ add messaging capability
+ modify cell array support as needed
+
+
+Pixmaps
+ cache by name
+ new entry replaces old
+ entries are never freed unless overwritten
+ for lookup, check cache first then look for file (normal resource
+ translation)
+
+ typical bitmap:
+
+ #define opendot_width 16
+ #define opendot_height 16
+ #define opendot_x_hot 7
+ #define opendot_y_hot 7
+ static char opendot_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,
+ 0x60,0x03,0x20,0x02,0x60,0x03,0xc0,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
+ types of bitmaps - bitmap, pixmap, cursor
+
+ createBitmap name width height data
+ createPixmap name width height depth fg_color bg_color data
+ createCursor name source mask fg_color bg_color x_hot y_hot
+
+
+Event handling
+
+ addEventHandler <procname> <event-mask> [<event-mask>...]
+ userEventHandler {widget event-type time wx wy rx ry other}
+ where "other" is a event-specific list of fields
+
+Event structs
+
+ event masks, event names are numerous
+ most events have these fields:
+ type, time, x_win, y_win, x_root, y_root other
+ other fields:
+ key: state (key or button mask), keycode
+ button: state (key or button mask), button code
+ motion: state (key or button mask), is_hint
+ crossing: mode (normal, grab, ungrab)
+ focus: mode (normal, grab, ungrab)
+ visibility: state
+ error: error_code, request_code, minor_code
+
+ keycode|button|mode|state
+
+Event masks
+
+ Button1MotionMask
+ Button2MotionMask
+ Button3MotionMask
+ Button4MotionMask
+ Button5MotionMask
+ ButtonMotionMask
+ ButtonPressMask
+ ButtonReleaseMask
+ ColormapChangeMask
+ EnterWindowMask
+ ExposureMask
+ FocusChangeMask
+ KeyPressMask
+ KeyReleaseMask
+ KeymapStateMask
+ LeaveWindowMask
+ NoEventMask
+ OwnerGrabButtonMask
+ PointerMotionHintMask
+ PointerMotionMask
+ PropertyChangeMask
+ ResizeRedirectMask
+ StructureNotifyMask
+ SubstructureNotifyMask
+ SubstructureRedirectMask
+ VisibilityChangeMask
+
+Event names
+
+ ButtonPress
+ ButtonRelease
+ CirculateNotify
+ CirculateRequest
+ ClientMessage
+ ColormapNotify
+ ConfigureNotify
+ ConfigureRequest
+ CreateNotify
+ DestroyNotify
+ EnterNotify
+ Expose
+ FocusIn
+ FocusOut
+ GraphicsExpose
+ GravityNotify
+ KeyPress
+ KeyRelease
+ KeymapNotify
+ LeaveNotify
+ MapNotify
+ MapRequest
+ MappingNotify
+ MotionNotify
+ NoExpose
+ PropertyNotify
+ ReparentNotify
+ ResizeRequest
+ SelectionClear
+ SelectionNotify
+ SelectionRequest
+ UnmapNotify
+ VisibilityNotify
+
+
+GTERM CELL ARRAY
+
+ Colormap
+ use pseudocolor visual if possible
+ a fixed number of well defined sharable, read-only cells
+ a variable number of private read-write cells
+ the private cells are allocated at runtime when the
+ application allocates a colormap
+ the graphcap entry specifies the maximum number of private
+ colormap cells that can be allocated
+ a private colormap is used if the requested cells cannot
+ be allocated
+ there is only one colormap per gterm widget (if there are
+ multiple cell arrays they share the same colormap)
+
+ Cell arrays (obsolete term?)
+ A cell array is mapping of an MxN array of 8 bit pixel values
+ to a region of the screen.
+ The pixel values in a cell array range from 0 to NC, and are
+ contiguous in that range. NC is the number of colors in
+ the gterm colormap. The first few values starting at 0
+ are statically allocated and cell array pixels will
+ normally start at the first dynamically allocated value.
+ The cell array mapping defines the transformation used to paint
+ a region of the Gterm window from the cell array pixels.
+ Scaling and axis flipping are possible.
+ Cell arrays are defined and written to in separate steps. A
+ given write operation may modify only part of the MxN pixels
+ of the cell array.
+
+ New operations
+ write colormap Writes N cells of the gterm colormap starting
+ at a given pixel value.
+
+ define cell array Define transformation for cell array N.
+ Several cell arrays may be active.
+
+ write cell array Write to a subregion of a cell array (operates
+ in cell array pixels, not screen pixels).
+
+ Arbitrary regions of the colormap or a cell array may be
+ modified, allowing for very interactive operations.
+
+ Binary pixel values must be encoded for transmission between the
+ client and server. The simplest encoding adds 040 to the value
+ of each pixel (byte), resulting in a printable byte stream.
+ Control codes may be used for compression schemes.
+
+ Alternative scheme
+ Store cell array in off screen buffer. This is the same as
+ above except that in the above scheme the pixels are not
+ saved.
+ Modifying any pixel data, or editing the mapping causes the
+ affected region of the screen to be rewritten.
+ The advantage of this approach is that operations such as zoom
+ and pan can be implemented merely by modifying the mapping.
+ Given multiple cell arrays, one can also do blink, split
+ screen, etc.
+ Perhaps mappings should be separate from cell arrays. The
+ same array may be mapped to more than one region of the
+ screen, or a mapping may map portions of more than one
+ array.
+ Fundamental items are pixel array, mapping, colormap
+
+ Pixmap operations
+ Create host or display pixmap
+ Destroy pixmap (or all such pixmaps)
+ Copy data to/from pixmap and screen
+ Read a file into a pixmap or series of pixmaps
+ Append pixmap to a file
+
+ Should be combined with Obm capabilities for creating and
+ referencing pixmaps.
+
+ Pixmap operations can be used for a number of purposes,
+ including movie making.
+
+Imaging Procedures
+
+ Images (rasters) are implemented internally in Gterm using either
+ ximages or off screen pixmaps. Which format is used is decided at
+ raster create time and is controlled by a Gterm resource. This is
+ transparent to the client application. Currently only 8 bit rasters
+ are supported.
+
+ GtRasterInit (gt)
+ GtAssignRaster (gt, raster, drawable)
+ GtCreateRaster (gt, raster, type, width, height)
+ GtDestroyRaster (gt, raster)
+ exists = GtQueryRaster (gt, raster, &width, &height)
+ n = GtNRasters (gt)
+
+ GtWritePixels (gt, raster, pixels, x1, y1, nx, ny)
+ GtReadPixels (gt, raster, pixels, x1, y1, nx, ny)
+ pixmap = GtCreatePixmap (gt, src, x, y, width, height)
+ GtCopyPixmap (gt, pixmap, dst, x, y, width, height)
+
+ GtWriteColormap (gt, first, nelem, r, g, b)
+ GtReadColormap (gt, first, nelem, r, g, b)
+
+ GtInitMappings (gt)
+ GtCopyRaster (gt, rop, src,sx,sy,snx,sny, dst,dx,dy,dnx,dny)
+ GtSetMapping (gt, mapping, src,sx,sy,snx,sny, dst,dx,dy,dnx,dny)
+ GtGetMapping (gt, mapping, src,sx,sy,snx,sny, dst,dx,dy,dnx,dny)
+ GtEnableMapping (gt, mapping, enable)
+ GtRefreshMapping (gt, mapping)
+
+ For the widget class we can also have commands to operate upon
+ pixmaps created by or written into a gterm widget.
+
+ createPixmap name src [x y width height]
+ copyPixmap name dst [x y width height]
+ destroyPixmap name
+
+ There should also be commands to delete pixmaps, write pixmaps to
+ files, and read pixmaps from files.
+
+ The imaging routines operate in window or pixmap pixels. If a
+ window is resized, any mappings referencing the window are modified
+ to reflect the change in size. A query-size function is required
+ to pass the window size in pixels back to the client. A set-size
+ (resize window) procedure is also desirable to allow the client to
+ attempt to set the window to the optimum size for an image.
+
+ The client uses a special library of procedures for imaging. These
+ use GIO escapes to communicate with the stdgraph kernel. The
+ stdgraph kernel uses special ESC codes to communicate with the
+ server.
+
+ Applications which do only simple imaging will use GIO calls to
+ put a cell array and assign colors, using NDC coordinates for the
+ cell array mapping. More demanding applications that must operate
+ in pixel space, operate directly on image buffers, etc., will use
+ the GIO escapes directly. The stdgraph kernel will keep track of
+ the window size and perform NDC to pixel space conversions for the
+ put cell array call.
+
+
+Implementation
+
+ Code structure
+
+ client
+ gio
+ gim
+ gki_escape
+ | (--IPC--)
+ stdgraph kernel
+ serial encoding
+ | (--IPC--)
+ gtermio
+ obm
+ gterm widget
+
+
+ Simple graphics applications use the high level GIO routines for
+ imaging. These include put/get cell array and put/get colors, with
+ gset being used to select colors for drawing.
+
+ A small library of routines are used in client programs that have
+ more demanding imaging requirements. These are implemented using
+ GIO escapes and operate in pixel space, providing direct access to
+ the gterm imaging functions.
+
+ The GIO escapes are processed by the stdgraph kernel. This uses ASCII
+ escape sequences defined in graphcap to communicate with the server.
+ The GIO escape codes are defined in lib$gescape.h.
+
+ The gtermio code in Xgterm processes these escape sequences and
+ converts them into calls to the imaging routines in the gterm widget.
+
+ The object manager also provides routines for calling the gterm
+ imaging routines from within UI code.
+
+ The actual Xlib based imaging code is in the gterm widget.
+
+
+Complications
+
+ Cursor mode - wants to buffer all GKI instructions, including the
+ GIM escapes, some of which are voluminous. If any interactive image
+ editing, redrawing, etc. is done without initializing things, this
+ could be a lot of data. Would like cursor mode to work in the sense
+ that one can redraw the screen, zoom and pan.
+
+ Cursor readback - for a cursor read within a mapped region of the
+ screen, the logical thing is to return raster coordinates rather
+ than Tek window coordinates. The server should make the mapping
+ transparent, so that the client gets raster coordinates regardless
+ of the image offset, scale, any axis flip, and so on.
+
+ Cursor mode strategy - all GIM escapes issued by the client are
+ executed, but only setmapping instructions are buffered. During a
+ cursor mode redraw the setmapping instructions are edited to reflect
+ the cursor mode zoom/pan (this should be done by a GIM routine), and
+ retransimitted to the server at the time that they are encountered
+ in the display list. In most cases this will result in the image
+ data being redrawn at the appropriate time, e.g. after a frame draw
+ and area clear, and before any overlaid graphics is drawn.
+
+ This requires that the server not initialize the imaging system on
+ every frame clear (probably the imaging subsystem should be
+ initialized when the cursor mode frame buffer is cleared, rather
+ than when the server screen is cleared). The space required to
+ buffer setmapping instructions is mimimal. A disadvantage is that
+ :.write/read will not save or redisplay image data. The major
+ advantage is that this provides full cursor mode zoom/pan capability
+ and is time and space efficient.
+
+ To encapsulate manipulation of the GIM escapes in the cursor mode
+ code, a GIM (stdgraph kernel) routine should be called when a GIM
+ escape is executed to edit the instruction, if any, left behind in
+ the cursor mode buffer. This routine will have access to the
+ cursor mode frame buffer and will edit it as necessary, e.g.
+ deleting the instruction, replacing it, or editing earlier GIM
+ escapes in the same frame buffer.
+
+ Cursor readback strategy - to solve this problem it appears to be
+ necessary to have the server pass back the "cursor number" in a
+ cursor read. When a cursor read occurs there is no way the client
+ can predict which cursor will be read; the server selects the cursor
+ depending upon the pointer location. The cursor number is the Tek
+ cursor, a raster cursor, or a region of a window. The WCS number
+ in the cursor value struct passed back to the client indicates
+ which cursor was read.
+
+
+Timings
+
+ Time to copy 631296 byte text file through a tty/pty
+
+ lepus 8-9sec 70 Kb/sec
+ tucana 2sec 300 Kb/sec
+
+
+Cursor Handling
+
+ The general scheme is that when the cursor is read, the server
+ determines which raster the cursor is in and returns pixel
+ coordinates relative to this raster, regardless of how the raster is
+ mapped to the screen. The return cursor value includes the raster
+ number, pixel X and Y coordinates, and the keystroke (keycode) which
+ terminated the cursor read.
+
+ Since the Tek cursor value struct does not provide adequate
+ resolution or any provision for the raster number, a custom cursor
+ return value is required. gtermio will continue to support a Tek
+ cursor, using a special escape to initiate a custom cursor read.
+
+ gki_retcursor needs to be modified to provide more coordinate
+ resolution and to allow the "cursor" (raster) number to be returned.
+
+ In cursor mode, WCS selection will use the CN/raster number instead
+ of screen position to determine the WCS to be used. A WCS maps a
+ range of world coordinates (e.g. image pixel coordinates) to a
+ viewport in NDC space.
+
+
+Current cursor mechanism
+
+ ESC SUB - initiate standard Tek cursor read
+ user types key to terminate graphics input mode
+
+ server returns cursor value encoded as
+ key
+ hix; lox
+ hiy; loy
+ trailer1; trailer2
+ x, y are encoded in Tek screen coordinates, 0-1023,0-779
+
+ gki_getcursor (fd, x, y, key, cursor)
+ stg_getcursor (cursor number)
+ call stg_readcursor to read cursor
+ returns GKI cursor value struct
+ cursor number, x, y, key
+
+ stg_readcursor (cursor, x, y, key)
+ stg_rdcursor (tty, cursor, x, y, key, output_rc)
+ set raw mode
+ getc until pattern is matched
+ clear raw mode
+ stg_encode to decode cursor value
+ return x, y, key
+
+ rcursor (fd, curval, maxch)
+ grc_cursor (rc, stream, x, y, key, ppos) (screen)
+ gtr_readcursor (stream, x, y, key) (screen)
+ gki_getcursor (fd, mx, my, key, 0) (GKI)
+ grc_scrtowcs (stream, x, y, xc, yc, wcs) (WCS)
+ grc_scrtondc (sx, sy, mx, my) (NDC)
+ wcs = grc_selectwcs (tr, mx, my)
+ grc_settran (w, ct)
+ grc_ndctowcs (ct, mx, my, wx, wy) (WCS)
+ format and return cursor value as a string (WCS)
+
+ screen coordinates - workstation screen/window
+ NDC coordinates - normalized screen coordinates (no zoom)
+ WCS coordinates - world coordinates in active WCS
+
+ WCS - max 16 per screen
+ wx1,wx2,wy1,wy2 range of world coordinates
+ sx1,sx2,sy1,sy2 viewport, NDC coordinates
+ xtran, ytran type of transformation in each axis
+ clip flag to clip at viewport boundary
+
+ WSTRAN - cursor mode ndc-to-screen
+ vx1,vx2,vy1,vy2 range of NDC coordinates
+ mx1,mx1,my1,my2 range of GKI coordinates
+
+
+Cursor mechanism with rasters
+
+ The key concept underlying this scheme is that GKI (NDC) coordinates
+ refer to the "raster" the cursor is in, rather than to the screen,
+ hence are independent of the raster-to-screen mapping. One
+ logically draws into a raster, and any mappings defined on the
+ raster take care of rendering the graphics on the screen. A cursor
+ read returns both screen coordinates, used for cursor mode zoom/pan,
+ and image raster GKI/NDC coordinates. A special case is raster 0,
+ the screen (actually the drawing window), which is what GKI/NDC
+ coordinates always referred to in the past. When drawing into
+ raster 0 one is drawing directly to the screen. When drawing into a
+ raster, one is still drawing to the screen, but via any mapping or
+ mappings defined on the raster.
+
+ Each raster has zero or more WCS associated with it. The WCS
+ associated with the raster defines a mapping between some world
+ coordinate system, e.g., image pixel coordinates, and NDC or
+ normalized raster coordinates. To get from world coordinates to
+ pixels on the screen, one converts from world coordinates to NDC
+ coordinates via the WCS, then from NDC coordinates to raster pixels,
+ then from raster pixels to screen pixels via the mapping. To be
+ more precise, the full transformation is as follows:
+
+ GIO in the client:
+ world -> NDC
+ NDC -> GKI (clipped at viewport)
+
+ Cursor mode in the CL:
+ GKI to "screen" (zoomed/clipped-GKI) coordinates
+ zoomed-GKI to Tek coordinates for serial protocol
+
+ Gtermio code in the server:
+ Tek coordinates to raster pixel coordinates for current
+ drawing raster
+
+ Gterm widget code:
+ raster pixel coordinates to screen pixel coordinates
+ via a mapping defined on the raster
+ repeat for each mapping defined on the raster
+
+ Graphics drawing for raster overlays requires that the server treat
+ the input Tek encoded coordinates (1024x780) as normalized for the
+ current raster. If the raster number is zero the normal drawing
+ operation (into the display window) takes place. If the raster
+ number is nonzero any mappings defined on the referenced raster
+ define where the graphics is drawn on the screen. If a mapping is
+ disabled no drawing takes place. Graphics are automatically clipped
+ at the boundary of the destination rect defined by a mapping.
+
+ In a cursor read operation, the server determines which raster if
+ any is mapped to the region of the screen the cursor is in. Both
+ screen (raster 0) and raster coordinates are returned using a
+ special cursor value struct. The cursor value return by RCURSOR
+ (hence =gcur and clgcur) returns the world coordinates defined by
+ the selected WCS for the current raster. If no WCS is defined NDC
+ coordinates are returned. If multiple WCS are defined for a raster
+ cursor mode selects the "nearest" viewport as it has always done
+ for screen coordinates.
+
+ About the only alternative to the above scheme is to have the server
+ return raster pixel coordinates. The problem with this is that this
+ is inconsistent with the GIO graphics model, and the WCS cannot be
+ used to return world coordinates, or to draw graphics overlays.
+
+ A complication with this scheme is that normally WCS 1 is used for
+ the screen (raster 0). Sometimes more than one WCS is used. Hence
+ to make a strict association between WCS number and raster number
+ would require that raster numbers be allocated accordingly in the
+ client. Also it is not clear what happens if there is more than one
+ WCS defined for a raster. To get around this problem a way is
+ needed to define which raster a WCS refers to. This can be done
+ without a (significant) protocol change by encoding the frame number
+ in the existing, little used WCS_CLIP field of the existing WCS
+ structure.
+
+
+Colormap Sharing
+
+ A gterm resource selects type of colormap: default, private, shared
+ default means default screen colormap, shared by all apps
+ private means colormap is used only by this gterm instance
+ shared means non-default colormap shared by multiple gterms
+
+ In the case of the default colormap, read-only or read-write cells
+ are allocated out of the screen default colormap. This guarantees
+ that the colors of non-gterm windows will not be affected when gterm
+ colors are allocated, but it may not be possible to allocate all
+ requested colors, or having allocated these colors to a gterm
+ widget it may not be possible to run other applications. Use of
+ the default colormap is appropriate for applications that do not
+ use many colors.
+
+ A private colormap is allocated and used by only a single gterm.
+ This guarantees that the expected number of colors will be available,
+ and prevents one gterm from changing another's colors. The main
+ disadvantage is that the window will go black (or whatever) when
+ the pointer is not in the window.
+
+ A shared colormap is a non-default (custom) colormap shared by
+ multiple gterms. Allocation of colors is guaranteed, but when one
+ gterm modifies the colormap all gterms using the shared colormap
+ are affected. They are however still visible and if they contain
+ similar data the display may still appear reasonable. There can
+ be multiple shared colormaps, each with a different name.
+
+ It is possible to use a trick to minimize colormap flashing when
+ private or shared colormaps are used. This works so long as the
+ default colormap has only a limited number of colors allocated,
+ and the gterm client needs only a limited number of colors (e.g.
+ 200 or so out of 256). The trick is to allocate as many colors as
+ possible from the default colormap, assigning the same pixels for
+ colors in the custom colormap. The default colormap is then copied
+ to the private (or shared) colormap, and the new colors are stored
+ in both colormaps. The newly allocated colors are then freed in
+ the default colormap. The custom colormap will then inherit most
+ of the color assignments of the default colormap, and in turn the
+ default colormap may still have the initial color assignments from
+ the custom colormap.
+
+ Differences will appear as both colormaps change thereafter, but in
+ practice many color assignments are fairly static so colormap
+ flashing should be minimized. The default colormap can be updated
+ periodically by repeating the allocate, store, copy, and free
+ sequence, e.g., when the custom colormap is modified.
+
+ Custom gterm colormap allocation strategy: in the normal case reserve
+ 216 colors for private use. The remaining cells are copied from the
+ default colormap to minimize colormap flashing. If the gterm client
+ requests more than 216 colors the full colormap is allocated.
+
+ 0 - 37 copied from default colormap
+ 38 - 253 reserved for gterm client
+ 254 - 255 copied from default colormap
+
+ The point where the gterm colormap starts (e.g. 38) should be defined
+ by a resource as there is no guarantee which end of the default
+ colormap static colors will be allocated at.
+
+ if (use default colormap) {
+ allocate read-write cells
+ store colors
+ } else {
+ if (don't have colormap yet) {
+ map colormap name to atom
+ if (named gterm colormap not found) {
+ # Create gterm colormap.
+ open connection to display
+ create colormap, allocate all colors
+ call XSetRGBColormaps to set colormap property
+ call XSetCloseDownMode to make colormap permanent
+ close display
+ } else {
+ call XGetRGBColormaps to get colormap property
+ get colormap id
+ }
+ set colormap id for gterm window
+ call XSetWMColormapWindows to notify WM of custom colormap
+ }
+ store new colors in custom colormap
+ if (match colormaps) {
+ copy global cells from default colormap
+ attempt to allocate cells in default colormap
+ attempt to store new colors in default colormap
+ free cells allocated above
+ }
+ }
+
+ If the gterm widget has a private colormap different than that of
+ its top level window, XSetWMColormapWindows must be called for gterm
+ window focus in/out events to indicate to the WM that the colormap
+ for the gterm window is to be loaded.
+
+
+Windowing the Display
+
+ Given a range of display pixel values and a normalized colormap,
+ apply a threshold/gain transformation to window the display (i.e.,
+ write new screen colormap). This needs to be done in the UI to
+ provide acceptable interactive response.
+
+ GtWindowDisplay (gw, offset, slope)
+
+ offset (0.5 +/- X) center of windowed region
+ slope (+/- X) slope of transfer function
+
+ The transfer function is applied to the normalized colormap
+ and the output colormap is written to the screen.
+
+ To window over a greater dynamic range one must regenerate the
+ display pixel values from the raster or image (this can be done by
+ the client). For example, the client application can display a
+ histogram and the user can mark the region to be written to the the
+ gterm raster pixels.
+
+ The marker facilities described in the next section can be used to
+ implement real-time display of the grayscale transfer function if
+ desired. The message facility could also be used to transfer the
+ image histogram and information about the histogram region loaded
+ into a raster, for use with the transfer function to generate a
+ full display of the grayscale mapping from disk image to screen.
+
+
+Graphics Markers
+
+ A "marker" is a graphics object, defined on a raster, which can be
+ created or destroyed, which can draw itself, or which can modify
+ (move or resize) itself in response to pointer events. Markers have
+ attributes such as the marker type (text, line, circle, polygon,
+ etc.), color, line width, center, width, height, visibility, and
+ sensitivity. Markers can accept callbacks which are executed when
+ the object is interactively moved or resized.
+
+ Markers can be used to annotate a window, as if one were drawing
+ into a window. The chief difference between a marker and a simple
+ drawing operation (such as a polyline) is that markers are not just
+ lines on the screen, but actual objects capable of responding to
+ requests or taking independent action.
+
+ Generic functions
+
+ create
+ destroy
+ copy
+ set attribute
+ get attribute
+ raise, lower
+
+ Generic attributes
+
+ type
+ visibility
+ autoRedraw
+ sensitivity
+ foreground, background text markers
+ linecolor, linewidth
+ knotcolor, knotsize
+ fillcolor, fillstyle polygon markers
+ width, height
+ x, y
+
+ Marker types
+
+ text font, string
+ line vertices
+ box
+ rectangle
+ circle
+ ellipse
+ polyline vertices
+ polygon vertices
+
+ Procedures
+
+ gm = GmGreate (gt, type, interactive)
+ gm = GmCopy (gm)
+ GmDestroy (gm)
+ GmAddCallback (gm, func, client_data)
+ gm = GmSelect (gt, x, y, &what)
+
+ GmMarkpos (gm)
+ GmRedraw (gm, func, erase)
+ GmRaise (gm, ref_gm|NULL)
+ GmLower (gm, ref_gm|NULL)
+ GmNotify (gm, events)
+
+ GmAdd (gm, x, y)
+ GmDelete (gm, x, y)
+ GmMove (gm, x, y)
+ GmResize (gm, x, y)
+ GmRotate (gm, x, y)
+
+ GmSetAttribute (gm, attribute, value, type)
+ GmGetAttribute (gm, attribute, value, type)
+ GmSetVertices (gm, points, first, npts)
+ npts = GmGetVertices (gm, points, first, maxpts)
+
+ raster = GtSelectRaster (gt, st, sx, sy, rt, &rx, &ry, &mp)
+ GtMapVector (gt, mp, dir, st, sv, dt, dv, npts, clip)
+
+ Markers operate in screen coordinates (raster 0). The SelectRaster
+ and MapVector routines may be used to convert to and from raster
+ coordinates if desired.
+
+ Actions
+ create (type)
+ destroy marker
+ set (attr, value)
+ raise marker
+ lower marker
+ notify callback
+
+ markpos marker
+ markposAdd marker point button1-down
+ redraw marker button1-up
+ add point
+ delete point
+ deleteDestroy point or marker delete or backspace
+ move marker
+ resize marker
+ moveResize point or marker button1-motion
+ rotate marker shift-button1
+
+ Marker specific functions (internal)
+
+ bool = select (gm, x, y, &what)
+ classinit (gm)
+ markpos (gm, &rect)
+ redraw (gm, function)
+
+ add (gm, x, y)
+ delete (gm, x, y)
+ move (gm, x, y)
+ resize (gm, x, y)
+ rotate (gm, x, y)
+
+ The marker specific functions are the methods for each marker
+ class. The functions add, delete, move etc. merely edit the marker
+ descriptor. A separate call to redraw is required to redraw the
+ modified marker.
+
+ Actions such as deleteDestroy and moveResize will select one of the
+ listed actions based upon the pointer coordinates. For example with
+ moveResize, if the pointer is in the center of a marker the entire
+ marker is moved, and if the pointer is near a point the point is
+ moved or the marker resized depending upon the type of marker.
+
+ The default translations for these actions are shown at the right.
+ These translations are in effect only when the pointer is over a
+ marker that is sensitive and visible. The cursor will change to
+ indicate that the marker is active; the cursor type will indicate
+ whether the entire marker, a single point, or add-point will be
+ selected if button1 is pressed at that location. In addition, the
+ default translation for button1-down for the window is create
+ rectangle. Hence a rectangle object can be created and dragged out
+ with the left button at any time just using the default
+ translations. This can be used prior to executing a command to
+ indicate the region to be operated upon.
+
+ Actions such as move, resize, rotate, etc. do not redraw the object
+ (unless autoRedraw is set). Instead, these actions do a GXor redraw
+ of the marker at the old location, edit the marker according to its
+ type, and then do another GXor redraw at the new location. When
+ tracking the cursor this produces a rubber-band effect. When
+ tracking completes (e.g., button1-up) the screen is refreshed at the
+ markpos position, erasing the old marker, any affected markers are
+ redrawn at the markpos position, and the edited marker is redrawn at
+ the new location.
+
+ A Marker is created with GmCreate. If the interactive flag is set
+ a mode is entered where the mouse is used to set the initial
+ position and size of the object. The cursor changes to indicate
+ that the widget is waiting for input. The user moves the mouse to
+ the position on the screen where the object will go, clicks the left
+ pointer, and then does a drag to set the initial size and
+ orientation of the object. When the button is released the create
+ object operation is complete, unless the marker type is polygon in
+ which case multiple click-and-drag operations are required to
+ interactively define the polygon.
+
+ If the create is not interactive, the GmCreate returns immediately,
+ and SetAttribute calls are used to set the object attributes and
+ then display the object.
+
+ Once a marker has been created the sensitivity attribute controls
+ whether the object can be interactively moved or resized with the
+ mouse. If the marker is sensitive, when the pointer is placed
+ within the marker or near a vertex or edge the cursor will change to
+ indicate that the marker, vertex, or edge can be dragged to move or
+ resize the marker. Alternatively, the delete or backspace key can
+ be used to destroy the marker. This will not actually destroy the
+ marker, but will notify the client (via a callback) that the user
+ has requested that the marker be destroyed.
+
+ When the mouse is near a sensitive marker a special translation
+ table defines the key or pointer bindings associated with the drag,
+ delete, etc. marker actions. Typical bindings would be left pointer
+ for create and drag, middle pointer to terminate a sequence such as
+ when drawing a polygon or to abort a create object, shift left
+ pointer to add a point to an existing polygon, and delete or
+ backspace to delete an object, or in add-point mode, the last vertex
+ in a polygon.
+
+ All the gterm widget need do is, when there is one or more sensitive
+ marker in a window, track the cursor and load the marker translation
+ table when the pointer is over a marker which is sensitive. The
+ rest will be done by the marker actions.
+
+ Markers can be used in UI code to provide a more general method of
+ position input than a cursor read, which can only specify a single
+ point. For example to input a rectangular region, one would do the
+ following:
+
+ UI selects marker type rectangle
+ UI creates a rectangle marker in interactive mode
+ cursor changes to indicate create-object mode
+ user positions mouse and clicks left button
+ holding button down, user drags out the rectangle
+ button up terminates GmCreate
+ UI calls GetVertices and passes polygon back to client
+ UI destroys marker
+
+ If desired, the client application can draw the polygon again
+ using normal graphics drawing commands (i.e., not as a marker).
+
+ To mark a region on a raster in UI code:
+
+ UI creates rectangle object in noninteractive mode
+ visibility and autoredraw are initially false
+ UI calls SetAttribute to set rectangle position, size, etc.
+ UI sets visibility attribute to cause marker to be drawn
+
+ If the region is to be active, e.g. something should happen if the
+ user moves or resizes the region, then the sensitivity should be
+ set to true and a callback can be posted to take some action if the
+ region is changed. For example, this could be used to graphically
+ pan the image or adjust the colormap.
+
+ Markers are only drawn to the screen, never to the screen pixmap.
+ Hence they can be erased by copying from the screen pixmap. If the
+ screen needs to be refreshed the markers are redrawn from the object
+ list maintained internally by the gterm widget.
+
+
+Display of Pixel Dependent Information
+
+ A common feature of image display UIs is the ability to display
+ information about the pixel under the cursor, either in sample mode
+ or continuously as the cursor is moved. For maximum flexibility
+ one must rely upon the client application to return information about
+ a pixel, since usually only the client has full access to the data,
+ and the significance of a pixel can be highly application specific.
+ An example of this is the display of the cursor position and pixel
+ intensity in user coordinates.
+
+ To implement this feature we need the following capabilities.
+
+ o The UI posts a callback procedure which is called whenever
+ the cursor moves, i.e., which receives pointer-moved events.
+
+ o The UI obtains information about the pixel under the pointer
+ from the client.
+
+ o The UI displays this information in a text object, either
+ overlaid on the image or in a separate text display area.
+
+ The WS already provides the ability to post a callback to receive
+ pointer-moved events. What we need is an efficient way to obtain
+ information about the pixel under the cursor. Due to the overhead
+ of the client-server architecture, it is undesirable to query the
+ client every time we need information about a pixel. Hence, we must
+ get information for a block of pixels in single query and cache this
+ information in the server, sending another query only when the
+ pointer moves to a different region of the screen.
+
+ This can be done by sending a request to the client to send a block
+ of information (text) for all the points in a grid in pixel space.
+ The client responds by generating the text as a message to a UI
+ parameter. The UI then needs a way to select text from the UI
+ parameter, and generate another query if the desired data is not
+ cached.
+
+ The cached text consists of a sequence of lines of the form
+
+ raster-x raster-y client-text
+
+ The server will need to cache several such blocks of data, each with
+ a header identifying the raster number and the region of the raster
+ covered by the cached data. The object code in the server will
+ provide convenience routines for managing and searching this data.
+
+
+Text Display Facilities
+
+ Real-time display of pixel information requires some way of
+ displaying the text passed back by the client via the method
+ described in the last section. Text display can be done either
+ using a text widget ouside the gterm window, or using a text marker
+ if the text is to be overlaid on the image. An advantage of using a
+ marker for the text overlay is that since the marker is active, the
+ user can use the mouse to reposition the text on the screen.
+
+
+Translations
+
+ The Widget specifies the default translations. The Widget
+ translations resource specifies replacement, augment, or override
+ translations. Additional augment or override translations may
+ be specified in a function call (e.g. to cause the widget to invoke
+ an application specified menu via a translation).
+
+ On a marker focusout, the widget must restore the gterm window
+ translations.
+
+ At initialize time:
+
+ if (translations resource defined) {
+ if (augment or override translations) {
+ defTranslations = compiled Gterm translations
+ compile auxiliary translations
+ set augment or override flag
+ } else
+ defTranslations = compiled translations resource
+ } else
+ defTranslations = compiled translations resource
+
+ At focusout time:
+
+ SetValues defTranslations
+ for (each auxiliary translation table)
+ augment or override widget translations
+
+ Additional auxiliary widget translations can be specified with
+ GtAugmentTranslations or GtOverrideTranslations.
+
+oo
diff --git a/vendor/x11iraf/xgterm/README b/vendor/x11iraf/xgterm/README
new file mode 100644
index 00000000..6e312da2
--- /dev/null
+++ b/vendor/x11iraf/xgterm/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 xgterm: the man page, xgterm.man, which describes
+how to use it, and ctlseqs.ms, which describes the control sequences it
+understands.
diff --git a/vendor/x11iraf/xgterm/TODO b/vendor/x11iraf/xgterm/TODO
new file mode 100644
index 00000000..ebf3c939
--- /dev/null
+++ b/vendor/x11iraf/xgterm/TODO
@@ -0,0 +1,93 @@
+ XGTERM - TODO
+
+
+
+Imaging Support (July 1993)
+
+ Gterm widget
+ debug polygon marker code
+ debug fill area support
+ implement missing read-raster primitive
+ add resource to set cursor type
+
+ Object manager
+ add gterm widget support (subclass)
+ bindings for standard actions
+ support for pixel tagging
+ callbacks for image events? (e.g. raster actions)
+ add support for timers and background work functions
+ debug or trace mode for Tcl interpreter
+ improved error handling and recovery
+ flesh out support for standard widgets (menu, text, etc.)
+ evaluate other widgets (Xc, FWF, layout)
+
+ Xgterm
+ hack event handling to support timers
+ add missing arguments, resources
+
+ IRAF
+ file include capability for .gui file
+ interactive background mode (bkg GUIs)
+ stdimage which uses stdgraph kernel
+
+
+Imaging Support (April 1993)
+
+ subraster updates do not always overlap on screen [DONE]
+ check out frame buffer editing (partial instructions) [DONE]
+ custom cursor bitmap for crosshair cursor [DONE]
+ colormap - initialize table for static entries [DONE]
+
+ add colormap number to GIM read/write colormap (0=screen) [DONE]
+ implement polygon clipping code in gio/cursor [DONE]
+ what to do about raster mapping after window resize [DONE]
+ add NDC-GIM coordinate conversions primitives to GIM ? [DONE]
+ add support for alternate GKI|GIM coordinates to GIM [DONE]
+
+ general problem of cursor input and rasters/mappings [DONE]
+ return cursor coordinate in GKI units scaled to raster? [DONE]
+
+ resolve problem of multiple gterms with color tables [DONE]
+ private colormap
+ share with other gterms (e.g. using properties)
+ reload colormap on focus-in event?
+ allocate private colormap if 256 cells requested?
+ add tcl callable windowing function (midpoint, slope) [DONE]
+ window display pixels by diddling colormap
+ regenerate display pixels from ximage (or from client)
+ add tcl callable region drawing facilities [DONE]
+ draw, erase, shape; how is interaction handled
+ add support for getting x/y/z from client and getting x/y/z
+ string given raster pixel coordinate
+ add tcl support for text display in the gterm window. can be [DONE]
+ combined with above for coord display
+
+ implement GIM functions in interpreter (callbacks?)
+ implement missing read-raster primitive
+ add tcl access to gterm widget drawing functions?
+ add resource to set ginmode, busy cursor types
+ check out menu stuff
+
+ add get/put cell array (NDC coords) to GIO
+ add get/put colormap to GIO
+
+ add gtermio resource to set ginmode terminators
+ add gtermio resource to set emulation type
+
+ what about stdgraph/stdimage? one possibility is for standard
+ xgterm GUI to provide separate graph, image windows automatically
+ selectable by graphics stream
+
+ start up interactive bkg jobs in own xgterm
+
+
+Client Applications (May 1993)
+
+ Clean up Xgterm client (setup menus etc.)
+ write Ximtool client
+ Demo clients, further testing of object manager and widget stuff
+ imbrowse
+ movie program
+ simple image display task using GIO
+
+
diff --git a/vendor/x11iraf/xgterm/Tests b/vendor/x11iraf/xgterm/Tests
new file mode 100644
index 00000000..f270e203
--- /dev/null
+++ b/vendor/x11iraf/xgterm/Tests
@@ -0,0 +1,42 @@
+Tests for xgterm:
+
+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 xgterm window. The program must immediately
+update its screen image for the new size.
+
+If compiled with -DUTMP, starting a new xgterm should create a new utmp
+entry. ("who" will show this info.) Exiting xgterm should remove the
+entry. Killing the xgterm 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 "xgterm -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 xgterm running only Tek widget: "xgterm -t"
+
+
+Please add to this list if you find xgterm failing in some way.
diff --git a/vendor/x11iraf/xgterm/VTPrsTbl.c b/vendor/x11iraf/xgterm/VTPrsTbl.c
new file mode 100644
index 00000000..1392de99
--- /dev/null
+++ b/vendor/x11iraf/xgterm/VTPrsTbl.c
@@ -0,0 +1,2956 @@
+/*
+ * $XConsortium: VTPrsTbl.c,v 1.9 92/09/15 15:28:28 gildea 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.
+ */
+
+#include "VTparse.h"
+
+#if __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+/*
+ * Stupid Apollo C preprocessor can't handle long lines. So... To keep
+ * it happy, we put each onto a separate line.... Sigh...
+ */
+
+Const int groundtable[] =
+{
+/* 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_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_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+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_GROUND_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_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 csitable[] = /* ESC [ */
+{
+/* 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_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_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+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_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_IGNORE,
+CASE_ESC_SEMI,
+/* < = > ? */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_DEC_STATE,
+/* @ A B C */
+CASE_ICH,
+CASE_CUU,
+CASE_CUD,
+CASE_CUF,
+/* D E F G */
+CASE_CUB,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* H I J K */
+CASE_CUP,
+CASE_GROUND_STATE,
+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_GROUND_STATE,
+/* T U V W */
+CASE_TRACK_MOUSE,
+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_DA1,
+/* d e f g */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_CUP,
+CASE_TBC,
+/* h i j k */
+CASE_SET,
+CASE_GROUND_STATE,
+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_GROUND_STATE,
+/* t u v w */
+CASE_SUNREQTPARM,
+CASE_GROUND_STATE,
+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_GROUND_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
+
+Const int dectable[] = /* ESC [ ? */
+{
+/* 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_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_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+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_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_IGNORE,
+CASE_ESC_SEMI,
+/* < = > ? */
+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_DECSET,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* l m n o */
+CASE_DECRST,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* p q r s */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_XGTERM_RESTORE,
+CASE_XGTERM_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_GROUND_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
+
+Const int eigtable[] = /* CASE_ESC_IGNORE */
+{
+/* 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_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_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+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_GROUND_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
+
+Const int esctable[] = /* ESC */
+{
+/* 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_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_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+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_SCR_STATE,
+/* $ % & ' */
+CASE_ESC_IGNORE,
+CASE_ESC_IGNORE,
+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_IGNORE_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* T U V W */
+CASE_XGTERM_TITLE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* X Y Z [ */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_DECID,
+CASE_CSI_STATE,
+/* \ ] ^ _ */
+CASE_GROUND_STATE,
+CASE_OSC,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* ` 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_GROUND_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
+
+Const int iestable[] = /* CASE_IGNORE_ESC */
+{
+/* NUL SOH STX ETX */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* EOT ENQ ACK BEL */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* BS HT NL VT */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* NP CR SO SI */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* DLE DC1 DC2 DC3 */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* DC4 NAK SYN ETB */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* CAN EM SUB ESC */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* FS GS RS US */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* SP ! " # */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* $ % & ' */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* ( ) * + */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* , - . / */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* 0 1 2 3 */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* 4 5 6 7 */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* 8 9 : ; */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* < = > ? */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* @ A B C */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* D E F G */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* H I J K */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* L M N O */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* P Q R S */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* T U V W */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* X Y Z [ */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* \ ] ^ _ */
+CASE_GROUND_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* ` a b c */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* d e f g */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* h i j k */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* l m n o */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* p q r s */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* t u v w */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* x y z { */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+/* | } ~ DEL */
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_STATE,
+CASE_IGNORE_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
+
+Const int igntable[] = /* CASE_IGNORE_STATE */
+{
+/* NUL SOH STX ETX */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/* EOT ENQ ACK BEL */
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+/* 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_IGNORE_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_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
+
+Const int scrtable[] = /* ESC # */
+{
+/* 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_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_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+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_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_GROUND_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
+
+Const int scstable[] = /* ESC ( 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_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_IGNORE,
+CASE_IGNORE,
+CASE_IGNORE,
+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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* 8 9 : ; */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* < = > ? */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* @ A B C */
+CASE_GROUND_STATE,
+CASE_GSETS,
+CASE_GSETS,
+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_GROUND_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_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* currency yen brokenbar section */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* diaeresis copyright ordfeminine guillemotleft */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* notsign hyphen registered macron */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* degree plusminus twosuperior threesuperior */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+/* acute mu paragraph periodcentered */
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_GROUND_STATE,
+CASE_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_GROUND_STATE,
+};
diff --git a/vendor/x11iraf/xgterm/VTparse.def b/vendor/x11iraf/xgterm/VTparse.def
new file mode 100644
index 00000000..fa083f9f
--- /dev/null
+++ b/vendor/x11iraf/xgterm/VTparse.def
@@ -0,0 +1,80 @@
+#
+# $XConsortium: VTparse.def,v 1.4 92/09/15 15:28:31 gildea 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.
+#
+
+CASE_GROUND_STATE
+CASE_IGNORE_STATE
+CASE_IGNORE_ESC
+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_SUNREQTPARM
+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_XGTERM_SAVE
+CASE_XGTERM_RESTORE
+CASE_XGTERM_TITLE
+CASE_DECID
+CASE_HP_MEM_LOCK
+CASE_HP_MEM_UNLOCK
+CASE_HP_BUGGY_LL
diff --git a/vendor/x11iraf/xgterm/VTparse.h b/vendor/x11iraf/xgterm/VTparse.h
new file mode 100644
index 00000000..c7c7fa06
--- /dev/null
+++ b/vendor/x11iraf/xgterm/VTparse.h
@@ -0,0 +1,110 @@
+/*
+ * $XConsortium: VTparse.h,v 1.6 92/09/15 15:28:31 gildea 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.
+ */
+
+/*
+ * 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++}'
+ *
+ * You 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_STATE 1
+#define CASE_IGNORE_ESC 2
+#define CASE_IGNORE 3
+#define CASE_BELL 4
+#define CASE_BS 5
+#define CASE_CR 6
+#define CASE_ESC 7
+#define CASE_VMOT 8
+#define CASE_TAB 9
+#define CASE_SI 10
+#define CASE_SO 11
+#define CASE_SCR_STATE 12
+#define CASE_SCS0_STATE 13
+#define CASE_SCS1_STATE 14
+#define CASE_SCS2_STATE 15
+#define CASE_SCS3_STATE 16
+#define CASE_ESC_IGNORE 17
+#define CASE_ESC_DIGIT 18
+#define CASE_ESC_SEMI 19
+#define CASE_DEC_STATE 20
+#define CASE_ICH 21
+#define CASE_CUU 22
+#define CASE_CUD 23
+#define CASE_CUF 24
+#define CASE_CUB 25
+#define CASE_CUP 26
+#define CASE_ED 27
+#define CASE_EL 28
+#define CASE_IL 29
+#define CASE_DL 30
+#define CASE_DCH 31
+#define CASE_DA1 32
+#define CASE_TRACK_MOUSE 33
+#define CASE_TBC 34
+#define CASE_SET 35
+#define CASE_RST 36
+#define CASE_SGR 37
+#define CASE_CPR 38
+#define CASE_DECSTBM 39
+#define CASE_SUNREQTPARM 40
+#define CASE_DECREQTPARM 41
+#define CASE_DECSET 42
+#define CASE_DECRST 43
+#define CASE_DECALN 44
+#define CASE_GSETS 45
+#define CASE_DECSC 46
+#define CASE_DECRC 47
+#define CASE_DECKPAM 48
+#define CASE_DECKPNM 49
+#define CASE_IND 50
+#define CASE_NEL 51
+#define CASE_HTS 52
+#define CASE_RI 53
+#define CASE_SS2 54
+#define CASE_SS3 55
+#define CASE_CSI_STATE 56
+#define CASE_OSC 57
+#define CASE_RIS 58
+#define CASE_LS2 59
+#define CASE_LS3 60
+#define CASE_LS3R 61
+#define CASE_LS2R 62
+#define CASE_LS1R 63
+#define CASE_PRINT 64
+#define CASE_XGTERM_SAVE 65
+#define CASE_XGTERM_RESTORE 66
+#define CASE_XGTERM_TITLE 67
+#define CASE_DECID 68
+#define CASE_HP_MEM_LOCK 69
+#define CASE_HP_MEM_UNLOCK 70
+#define CASE_HP_BUGGY_LL 71
diff --git a/vendor/x11iraf/xgterm/XGterm.ad b/vendor/x11iraf/xgterm/XGterm.ad
new file mode 100644
index 00000000..644f5a68
--- /dev/null
+++ b/vendor/x11iraf/xgterm/XGterm.ad
@@ -0,0 +1,112 @@
+*SimpleMenu*BackingStore: NotUseful
+*SimpleMenu*font: -adobe-helvetica-bold-r-normal--*-100-*-*-*-*-iso8859-*
+*SimpleMenu*menuLabel.vertSpace: 100
+*SimpleMenu*HorizontalMargins: 16
+*SimpleMenu*vertSpace: 10
+*SimpleMenu*Cursor: left_ptr
+
+! Comment out if not color display.
+*SimpleMenu*menuLabel.foreground: White
+*SimpleMenu.borderColor: black
+!.xgterm.SimpleMenu.background: #7c8498
+!.gterm-iraf.tekMenu.background: #7c8498
+.xgterm.SimpleMenu.background: #8992a8
+.gterm-iraf.tekMenu.background: #8992a8
+*SimpleMenu*foreground: Black
+
+! The following is for Xaw3d.
+*beNiceToColormap: False
+
+*mainMenu.Label: Main Options
+*mainMenu*securekbd*Label: Secure Keyboard
+*mainMenu*allowsends*Label: Allow SendEvents
+*mainMenu*logging*Label: Log to File
+*mainMenu*redraw*Label: Redraw Window
+*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
+
+*fontMenu.Label: VT Fonts
+*fontMenu*fontdefault*Label: Default
+*fontMenu*font1*Label: Unreadable
+*VT100*font1: 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
+
+*vtMenu.Label: Control Options
+*vtMenu*scrollbar*Label: Enable Scrollbar
+*vtMenu*jumpscroll*Label: Enable Jump Scroll
+*vtMenu*reversevideo*Label: Enable Reverse Video
+*vtMenu*colortext*Label: Enable Color Text
+*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*marginbell*Label: Enable Margin Bell
+*vtMenu*altscreen*Label: Show Alternate Screen
+*vtMenu*softreset*Label: Do Soft Reset
+*vtMenu*hardreset*Label: Do Full Reset
+*vtMenu*clearsavedlines*Label: Reset and Clear Saved Lines
+*vtMenu*gioenable*Label: Enable Graphics Capabilities
+*vtMenu*tekshow*Label: Show Graphics Window
+*vtMenu*tekmode*Label: Switch to Graphics Mode
+*vtMenu*tekreset*Label: Reset Graphics Window
+*vtMenu*vthide*Label: Hide VT Window
+
+*tekMenu.Label: Graphics Options
+*tekMenu*tekpage*Label: Clear window
+*tekMenu*tekhide*Label: Hide Window
+*tekMenu*vtshow*Label: Show VT Window
+*tekMenu*tekreset*Label: Destroy Window
+
+! The following key bindings are for Sun sparcstation keyboards (copy/paste).
+*VT100.Translations: #override \
+ <Key>L6:select-set(CLIPBOARD)\n\
+ <Key>L8:insert-selection(CLIPBOARD)
+
+! The following define the ISO 6429 color standard
+*VT100*color0: black
+*VT100*color1: red
+*VT100*color2: green
+*VT100*color3: yellow
+*VT100*color4: blue
+*VT100*color5: magenta
+*VT100*color6: cyan
+*VT100*color7: gray55
+*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*colorBD: white
+*VT100*colorUL: yellow
+
+! The following define resources to produce a 3-D scrollbar with arrows.
+*VT100*Scrollbar*background: #c0c0c0
+*VT100*Scrollbar*width: 15
+*VT100*Scrollbar*height: 15
+*VT100*Scrollbar*shadowWidth: 2
diff --git a/vendor/x11iraf/xgterm/XGterm.ad.R5 b/vendor/x11iraf/xgterm/XGterm.ad.R5
new file mode 100644
index 00000000..e87d6b0a
--- /dev/null
+++ b/vendor/x11iraf/xgterm/XGterm.ad.R5
@@ -0,0 +1,85 @@
+*SimpleMenu*BackingStore: NotUseful
+*SimpleMenu*font: -adobe-helvetica-bold-r-normal--*-100-*-*-*-*-iso8859-*
+*SimpleMenu*menuLabel.vertSpace: 100
+*SimpleMenu*HorizontalMargins: 16
+*SimpleMenu*vertSpace: 10
+*SimpleMenu*Cursor: left_ptr
+
+! Comment out if not color display.
+*SimpleMenu*menuLabel.foreground: White
+*SimpleMenu.borderColor: black
+!.xgterm.SimpleMenu.background: #7c8498
+!.gterm-iraf.tekMenu.background: #7c8498
+.xgterm.SimpleMenu.background: #8992a8
+.gterm-iraf.tekMenu.background: #8992a8
+*SimpleMenu*foreground: Black
+
+! The following is for Xaw3d.
+*beNiceToColormap: False
+
+*mainMenu.Label: Main Options
+*mainMenu*securekbd*Label: Secure Keyboard
+*mainMenu*allowsends*Label: Allow SendEvents
+*mainMenu*logging*Label: Log to File
+*mainMenu*redraw*Label: Redraw Window
+*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
+
+*fontMenu.Label: VT Fonts
+*fontMenu*fontdefault*Label: Default
+*fontMenu*font1*Label: Unreadable
+*VT100*font1: 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
+
+*vtMenu.Label: Control 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*marginbell*Label: Enable Margin Bell
+*vtMenu*altscreen*Label: Show Alternate Screen
+*vtMenu*softreset*Label: Do Soft Reset
+*vtMenu*hardreset*Label: Do Full Reset
+*vtMenu*clearsavedlines*Label: Reset and Clear Saved Lines
+*vtMenu*gioenable*Label: Enable Graphics Capabilities
+*vtMenu*tekshow*Label: Show Graphics Window
+*vtMenu*tekmode*Label: Switch to Graphics Mode
+*vtMenu*tekreset*Label: Reset Graphics Window
+*vtMenu*vthide*Label: Hide VT Window
+
+*tekMenu.Label: Graphics Options
+*tekMenu*tekpage*Label: Clear window
+*tekMenu*tekhide*Label: Hide Window
+*tekMenu*vtshow*Label: Show VT Window
+*tekMenu*tekreset*Label: Destroy Window
+
+! The following key bindings are for Sun sparcstation keyboards (copy/paste).
+*VT100.Translations: #override \
+ <Key>L6:select-set(CLIPBOARD)\n\
+ <Key>L8:insert-selection(CLIPBOARD)
diff --git a/vendor/x11iraf/xgterm/_3d b/vendor/x11iraf/xgterm/_3d
new file mode 100644
index 00000000..750e7d4e
--- /dev/null
+++ b/vendor/x11iraf/xgterm/_3d
@@ -0,0 +1,44 @@
+
+XGterm*Form.background: #c0c0c0
+XGterm*TransientShell*Dialog.background: #c0c0c0
+XGterm*Command.background: #c0c0c0
+XGterm*Menubutton.background: #c0c0c0
+XGterm*ScrollbarBackground: #c0c0c0
+!XGterm*Scrollbar*background: #c0c0c0
+XGterm*Scrollbar*background: #c0c0c0
+!XGterm*Scrollbar*foreground: #cccccc
+XGterm*Scrollbar*width: 15
+XGterm*Scrollbar*height: 15
+XGterm*Scrollbar*shadowWidth: 2
+XGterm*Scrollbar*cursorName: top_left_arrow
+XGterm*Scrollbar*pushThumb: true
+XGterm*shapeStyle: Rectangle
+XGterm*beNiceToColormap: False
+XGterm*shadowWidth: 2
+XGterm*SmeBSB*shadowWidth: 2
+XGterm*highlightThickness: 0
+XGterm*topShadowContrast: 20
+XGterm*bottomShadowContrast: 55
+
+!*VT100*background: black
+!*VT100*foreground: wheat
+*VT100*color0: black
+*VT100*color1: red4
+*VT100*color2: green4
+*VT100*color3: yellow4
+*VT100*color4: blue4
+*VT100*color5: magenta4
+*VT100*color6: cyan4
+*VT100*color7: gray55
+*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*colorBD: white
+*VT100*colorUL: yellow
+
+XGterm*dynamicColors: false
diff --git a/vendor/x11iraf/xgterm/button.c b/vendor/x11iraf/xgterm/button.c
new file mode 100644
index 00000000..18a15673
--- /dev/null
+++ b/vendor/x11iraf/xgterm/button.c
@@ -0,0 +1,1480 @@
+/* $XConsortium: button.c,v 1.69 94/04/02 12:41:50 gildea 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.
+ */
+
+/*
+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 "ptyx.h" /* Xlib headers included here. */
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/StdSel.h>
+
+#include "data.h"
+#include "error.h"
+#include "menu.h"
+
+extern char *malloc();
+
+extern void DoSecureKeyboard();
+
+#define KeyState(x) (((x) & (ShiftMask|ControlMask)) + (((x) & Mod1Mask) ? 2 : 0))
+ /* adds together the bits:
+ shift key -> 1
+ meta key -> 2
+ control key -> 4 */
+
+#define TEXTMODES 4
+#define NBUTS 3
+#define DIRS 2
+#define UP 1
+#define DOWN 0
+#define SHIFTS 8 /* three keys, so eight combinations */
+#define Coordinate(r,c) ((r) * (term->screen.max_col+1) + (c))
+
+extern char *xgterm_name;
+
+static void PointToRowCol();
+static void SelectionReceived();
+static void TrackDown();
+static void ComputeSelect();
+static void EditorButton();
+static void ExtendExtend();
+static void ReHiliteText();
+static void SelectSet();
+static void StartSelect();
+static int Length();
+static char *SaveText();
+
+extern XgtermWidget term;
+
+/* 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;
+
+/* Multi-click handling */
+static int numberOfClicks = 0;
+static long int lastButtonUpTime = 0;
+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;
+
+
+Boolean SendMousePosition(w, event)
+Widget w;
+XEvent* event;
+{
+ register TScreen *screen = &((XgtermWidget)w)->screen;
+
+ if (screen->send_mouse_pos == 0) return False;
+
+ if (event->type != ButtonPress && event->type != ButtonRelease)
+ return False;
+
+#define KeyModifiers \
+ (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \
+ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask ))
+
+#define ButtonModifiers \
+ (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \
+ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask ))
+
+ switch (screen->send_mouse_pos) {
+ case 1: /* X10 compatibility sequences */
+
+ if (KeyModifiers == 0) {
+ if (event->type == ButtonPress)
+ EditorButton(event);
+ return True;
+ }
+ return False;
+
+ case 2: /* DEC vt200 compatible */
+
+ if (KeyModifiers == 0 || KeyModifiers == ControlMask) {
+ EditorButton(event);
+ return True;
+ }
+ return False;
+
+ case 3: /* DEC vt200 hilite tracking */
+ if ( event->type == ButtonPress &&
+ KeyModifiers == 0 &&
+ event->xbutton.button == Button1 ) {
+ TrackDown(event);
+ return True;
+ }
+ if (KeyModifiers == 0 || KeyModifiers == ControlMask) {
+ EditorButton(event);
+ return True;
+ }
+ /* fall through */
+
+ default:
+ return False;
+ }
+#undef KeyModifiers
+}
+
+
+void
+DiredButton(w, event, params, num_params)
+Widget w;
+XEvent *event; /* must be XButtonEvent */
+String *params; /* selections */
+Cardinal *num_params;
+{ /* ^XM-G<line+' '><col+' '> */
+ register TScreen *screen = &term->screen;
+ int pty = screen->respond;
+ char Line[ 6 ];
+ register unsigned line, col;
+
+ if (event->type != ButtonPress && event->type != ButtonRelease)
+ return;
+ strcpy( Line, "\030\033G " );
+
+ line = ( event->xbutton.y - screen->border ) / FontHeight( screen );
+ if (term->misc.sb_right)
+ col = (event->xbutton.x - screen->border) / FontWidth(screen);
+ else
+ col = (event->xbutton.x - screen->border - screen->scrollbar) /
+ FontWidth(screen);
+ Line[3] = ' ' + col;
+ Line[4] = ' ' + line;
+ v_write(pty, Line, 5 );
+}
+
+void
+ViButton(w, event, params, num_params)
+Widget w;
+XEvent *event; /* must be XButtonEvent */
+String *params; /* selections */
+Cardinal *num_params;
+{ /* ^XM-G<line+' '><col+' '> */
+ register TScreen *screen = &term->screen;
+ int pty = screen->respond;
+ char Line[ 6 ];
+ register int line, col;
+
+ if (event->type != ButtonPress && event->type != ButtonRelease)
+ return;
+
+ line = screen->cur_row -
+ (( event->xbutton.y - screen->border ) / FontHeight( screen));
+/* fprintf( stderr, "xtdb line=%d\n", line ); */
+ if ( ! line ) return;
+ Line[ 1 ] = 0;
+ Line[ 0 ] = 27;
+ v_write(pty, Line, 1 );
+
+ Line[ 0 ] = 'p' & 0x1f;
+
+ if ( line < 0 )
+ { line = -line;
+ Line[ 0 ] = 'n' & 0x1f;
+ }
+ while ( --line >= 0 ) v_write(pty, Line, 1 );
+}
+
+/*ARGSUSED*/
+void HandleSelectExtend(w, event, params, num_params)
+Widget w;
+XEvent *event; /* must be XMotionEvent */
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ register TScreen *screen = &((XgtermWidget)w)->screen;
+ int row, col;
+
+ screen->selection_time = event->xmotion.time;
+ switch (eventMode) {
+ case LEFTEXTENSION :
+ case RIGHTEXTENSION :
+ PointToRowCol (event->xmotion.y, event->xmotion.x,
+ &row, &col);
+ ExtendExtend (row, col);
+ break;
+ case NORMAL :
+ /* will get here if send_mouse_pos != 0 */
+ break;
+ }
+}
+
+static void EndExtend();
+
+static void do_select_end (w, event, params, num_params, use_cursor_loc)
+Widget w;
+XEvent *event; /* must be XButtonEvent */
+String *params; /* selections */
+Cardinal *num_params;
+Bool use_cursor_loc;
+{
+ ((XgtermWidget)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);
+ break;
+ }
+}
+
+
+void HandleSelectEnd(w, event, params, num_params)
+Widget w;
+XEvent *event; /* must be XButtonEvent */
+String *params; /* selections */
+Cardinal *num_params;
+{
+ do_select_end (w, event, params, num_params, False);
+}
+
+
+void HandleKeyboardSelectEnd(w, event, params, num_params)
+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;
+ Time time;
+};
+
+
+static void _GetSelection(w, time, params, num_params)
+Widget w;
+Time time;
+String *params; /* selections in precedence order */
+Cardinal num_params;
+{
+ Atom selection;
+ int cutbuffer;
+
+ XmuInternStrings(XtDisplay(w), params, (Cardinal)1, &selection);
+ switch (selection) {
+ 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;
+ }
+ if (cutbuffer >= 0) {
+ register TScreen *screen = &((XgtermWidget)w)->screen;
+ int inbytes;
+ unsigned long nbytes;
+ int fmt8 = 8;
+ Atom type = XA_STRING;
+ char *line = XFetchBuffer(screen->display, &inbytes, cutbuffer);
+ nbytes = (unsigned long) inbytes;
+ if (nbytes > 0)
+ SelectionReceived(w, NULL, &selection, &type, (XtPointer)line,
+ &nbytes, &fmt8);
+ else if (num_params > 1)
+ _GetSelection(w, time, params+1, num_params-1);
+ } else {
+ struct _SelectionList* list;
+ if (--num_params) {
+ list = XtNew(struct _SelectionList);
+ list->params = params + 1;
+ list->count = num_params; /* decremented above */
+ list->time = time;
+ } else list = NULL;
+ XtGetSelectionValue(w, selection, XA_STRING, SelectionReceived,
+ (XtPointer)list, time);
+ }
+}
+
+/* SelectionReceived: stuff received selection text into pty */
+
+/* ARGSUSED */
+static void SelectionReceived(w, client_data, selection, type,
+ value, length, format)
+Widget w;
+XtPointer client_data;
+Atom *selection, *type;
+XtPointer value;
+unsigned long *length;
+int *format;
+{
+ int pty = ((XgtermWidget)w)->screen.respond; /* file descriptor of pty */
+ register char *lag, *cp, *end;
+ char *line = (char*)value;
+
+ if (*type == 0 /*XT_CONVERT_FAIL*/ || *length == 0 || value == NULL) {
+ /* could not get this selection, so see if there are more to try */
+ struct _SelectionList* list = (struct _SelectionList*)client_data;
+ if (list != NULL) {
+ _GetSelection(w, list->time, list->params, list->count);
+ XtFree(client_data);
+ }
+ return;
+ }
+
+ /* 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. */
+
+ end = &line[*length];
+ lag = line;
+ for (cp = line; cp != end; cp++)
+ {
+ if (*cp != '\n') continue;
+ *cp = '\r';
+ v_write(pty, lag, cp - lag + 1);
+ lag = cp + 1;
+ }
+ if (lag != end)
+ v_write(pty, lag, end - lag);
+
+ XtFree(client_data);
+ XtFree(value);
+}
+
+
+void
+HandleInsertSelection(w, event, params, num_params)
+Widget w;
+XEvent *event; /* assumed to be XButtonEvent* */
+String *params; /* selections in precedence order */
+Cardinal *num_params;
+{
+ if (SendMousePosition(w, event)) return;
+ _GetSelection(w, event->xbutton.time, params, *num_params);
+}
+
+
+static void
+SetSelectUnit(buttonDownTime, defaultUnit)
+ Time buttonDownTime;
+ SelectUnit defaultUnit;
+{
+/* Do arithmetic as integers, but compare as unsigned solves clock wraparound */
+ if ((long unsigned)((long int)buttonDownTime - lastButtonUpTime)
+ > term->screen.multiClickTime) {
+ numberOfClicks = 1;
+ selectUnit = defaultUnit;
+ } else {
+ ++numberOfClicks;
+ selectUnit = ((selectUnit + 1) % NSELECTUNITS);
+ }
+}
+
+static void do_select_start (w, event, startrow, startcol)
+Widget w;
+XEvent *event; /* must be XButtonEvent* */
+int startrow, startcol;
+{
+ if (SendMousePosition(w, event)) return;
+ SetSelectUnit(event->xbutton.time, SELECTCHAR);
+ replyToEmacs = FALSE;
+ StartSelect(startrow, startcol);
+}
+
+/* ARGSUSED */
+void
+HandleSelectStart(w, event, params, num_params)
+Widget w;
+XEvent *event; /* must be XButtonEvent* */
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ register TScreen *screen = &((XgtermWidget)w)->screen;
+ int startrow, startcol;
+
+ firstValidRow = 0;
+ lastValidRow = screen->max_row;
+ PointToRowCol(event->xbutton.y, event->xbutton.x, &startrow, &startcol);
+ do_select_start (w, event, startrow, startcol);
+}
+
+
+/* ARGSUSED */
+void
+HandleKeyboardSelectStart(w, event, params, num_params)
+Widget w;
+XEvent *event; /* must be XButtonEvent* */
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ register TScreen *screen = &((XgtermWidget)w)->screen;
+
+ do_select_start (w, event, screen->cursor_row, screen->cursor_col);
+}
+
+
+static void
+TrackDown(event)
+ register XButtonEvent *event;
+{
+ int startrow, startcol;
+
+ SetSelectUnit(event->time, SELECTCHAR);
+ if (numberOfClicks > 1 ) {
+ PointToRowCol(event->y, event->x, &startrow, &startcol);
+ replyToEmacs = TRUE;
+ StartSelect(startrow, startcol);
+ } else {
+ waitingForTrackInfo = 1;
+ EditorButton(event);
+ }
+}
+
+
+#define boundsCheck(x) if (x < 0) \
+ x = 0; \
+ else if (x >= screen->max_row) \
+ x = screen->max_row;
+
+void
+TrackMouse(func, startrow, startcol, firstrow, lastrow)
+ int func, startrow, startcol, firstrow, lastrow;
+{
+ TScreen *screen = &term->screen;
+
+ if (!waitingForTrackInfo) { /* Timed out, so ignore */
+ return;
+ }
+ waitingForTrackInfo = 0;
+ if (func == 0) return;
+ boundsCheck (startrow)
+ boundsCheck (firstrow)
+ boundsCheck (lastrow)
+ firstValidRow = firstrow;
+ lastValidRow = lastrow;
+ replyToEmacs = TRUE;
+ StartSelect(startrow, startcol);
+}
+
+static void
+StartSelect(startrow, startcol)
+ int startrow, startcol;
+{
+ TScreen *screen = &term->screen;
+
+ 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(w, event, params, num_params, use_cursor_loc)
+ Widget w;
+ XEvent *event; /* must be XButtonEvent */
+ String *params; /* selections */
+ Cardinal num_params;
+ Bool use_cursor_loc;
+{
+ int row, col;
+ 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) {
+ if (rawRow == startSRow && rawCol == startSCol
+ && row == endSRow && col == endSCol) {
+ /* Use short-form emacs select */
+ strcpy(line, "\033[t");
+ line[3] = ' ' + endSCol + 1;
+ line[4] = ' ' + endSRow + 1;
+ v_write(screen->respond, line, 5);
+ } else {
+ /* long-form, specify everything */
+ strcpy(line, "\033[T");
+ line[3] = ' ' + startSCol + 1;
+ line[4] = ' ' + startSRow + 1;
+ line[5] = ' ' + endSCol + 1;
+ line[6] = ' ' + endSRow + 1;
+ line[7] = ' ' + col + 1;
+ line[8] = ' ' + row + 1;
+ v_write(screen->respond, line, 9);
+ }
+ TrackText(0, 0, 0, 0);
+ }
+ }
+ SelectSet(w, event, params, num_params);
+ eventMode = NORMAL;
+}
+
+void
+HandleSelectSet(w, event, params, num_params)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *num_params;
+{
+ SelectSet (w, event, params, *num_params);
+}
+
+static void SaltTextAway();
+
+/* ARGSUSED */
+static void
+SelectSet (w, event, params, num_params)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal num_params;
+{
+ /* 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 (w, event, params, num_params, use_cursor_loc)
+Widget w;
+XEvent *event; /* must be XButtonEvent* */
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+Bool use_cursor_loc;
+{
+ TScreen *screen = &((XgtermWidget)w)->screen;
+ int row, col, coord;
+
+ if (SendMousePosition(w, event)) return;
+ firstValidRow = 0;
+ lastValidRow = screen->max_row;
+ SetSelectUnit(event->xbutton.time, selectUnit);
+ replyToEmacs = FALSE;
+
+ if (numberOfClicks == 1) {
+ /* 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);
+}
+
+static void
+ExtendExtend (row, col)
+ int row, col;
+{
+ int coord = Coordinate(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);
+}
+
+
+void HandleStartExtend(w, event, params, num_params)
+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(w, event, params, num_params)
+Widget w;
+XEvent *event; /* must be XButtonEvent* */
+String *params; /* unused */
+Cardinal *num_params; /* unused */
+{
+ do_start_extend (w, event, params, num_params, True);
+}
+
+
+ScrollSelection(screen, amount)
+register TScreen* screen;
+register int amount;
+{
+ register int minrow = -screen->savedlines - screen->topline;
+ register int maxrow = screen->max_row - screen->topline;
+ register 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);
+
+ scroll_update_one(screen->startHRow, screen->startHCol);
+ scroll_update_one(screen->endHRow, screen->endHCol);
+
+ screen->startHCoord = Coordinate (screen->startHRow, screen->startHCol);
+ screen->endHCoord = Coordinate (screen->endHRow, screen->endHCol);
+}
+
+
+/*ARGSUSED*/
+ResizeSelection (screen, rows, cols)
+ TScreen *screen;
+ int rows, 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;
+}
+
+static void
+PointToRowCol(y, x, r, c)
+ register int y, x;
+ int *r, *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. */
+{
+ register TScreen *screen = &term->screen;
+ register row, col;
+
+ row = (y - screen->border) / FontHeight(screen);
+ if(row < firstValidRow)
+ row = firstValidRow;
+ else if(row > lastValidRow)
+ row = lastValidRow;
+ if (term->misc.sb_right)
+ col = (x - screen->border) / FontWidth(screen);
+ else
+ col = (x - screen->border - screen->scrollbar) / FontWidth(screen);
+ if(col < 0)
+ col = 0;
+ else if(col > screen->max_col+1) {
+ col = screen->max_col+1;
+ }
+ *r = row;
+ *c = col;
+}
+
+static int
+LastTextCol(row)
+ register int row;
+{
+ register TScreen *screen = &term->screen;
+ register int i;
+ register Char *ch;
+
+ for ( i = screen->max_col,
+ ch = screen->buf[4 * (row + screen->topline) + 1] + i ;
+ i >= 0 && !(*ch & CHARDRAWN) ;
+ ch--, i--)
+ ;
+ return(i);
+}
+
+/*
+** 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]
+** - execeptions
+*/
+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, 216,
+/* 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, 248,
+/* o/ u` u' u^ u: y' P y: */
+ 48, 48, 48, 48, 48, 48, 48, 48};
+
+int SetCharacterClassRange (low, high, value)
+ register int low, high; /* in range of [0..255] */
+ register int value; /* arbitrary */
+{
+
+ if (low < 0 || high > 255 || high < low) return (-1);
+
+ for (; low <= high; low++) charClass[low] = value;
+
+ return (0);
+}
+
+/*
+ * sets startSRow startSCol endSRow endSCol
+ * ensuring that they have legal values
+ */
+
+static void
+ComputeSelect(startRow, startCol, endRow, endCol, extend)
+ int startRow, startCol, endRow, endCol;
+ Bool extend;
+{
+ register TScreen *screen = &term->screen;
+ register Char *ptr;
+ register int length;
+ register int class;
+ int osc = startSCol;
+
+ 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 {
+ ptr = screen->buf[4*(startSRow+screen->topline)]
+ + startSCol;
+ class = charClass[*ptr];
+ do {
+ --startSCol;
+ --ptr;
+ } while (startSCol >= 0
+ && charClass[*ptr] == class);
+ ++startSCol;
+ }
+ if (endSCol > (LastTextCol(endSRow) + 1)) {
+ endSCol = 0;
+ endSRow++;
+ } else {
+ length = LastTextCol(endSRow);
+ ptr = screen->buf[4*(endSRow+screen->topline)]
+ + endSCol;
+ class = charClass[*ptr];
+ do {
+ ++endSCol;
+ ++ptr;
+ } while (endSCol <= length
+ && charClass[*ptr] == class);
+ /* 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;
+ }
+ }
+ break;
+ case SELECTLINE :
+ if (term->screen.cutToBeginningOfLine) {
+ startSCol = 0;
+ } else if (!extend) {
+ startSCol = osc;
+ }
+ if (term->screen.cutNewline) {
+ endSCol = 0;
+ ++endSRow;
+ } else {
+ endSCol = LastTextCol(endSRow) + 1;
+ }
+ break;
+ }
+
+ TrackText(startSRow, startSCol, endSRow, endSCol);
+ return;
+}
+
+
+TrackText(frow, fcol, trow, tcol)
+ register int frow, fcol, trow, tcol;
+ /* Guaranteed (frow, fcol) <= (trow, tcol) */
+{
+ register int from, to;
+ register TScreen *screen = &term->screen;
+ int old_startrow, old_startcol, old_endrow, old_endcol;
+
+ 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(frow, fcol, trow, tcol)
+ register int frow, fcol, trow, tcol;
+ /* Guaranteed that (frow, fcol) <= (trow, tcol) */
+{
+ register TScreen *screen = &term->screen;
+ register int i;
+
+ 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 = screen->max_col+1;
+ }
+ 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, screen->max_col+1, 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 _OwnSelection();
+
+static void
+SaltTextAway(crow, ccol, row, col, params, num_params)
+ /*register*/ int crow, ccol, row, 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) */
+{
+ register TScreen *screen = &term->screen;
+ register int i, j = 0;
+ int eol;
+ char *line, *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);
+ }
+
+ /* now get some memory to save it in */
+
+ if (screen->selection_size <= j) {
+ if((line = malloc((unsigned) j + 1)) == (char *)NULL)
+ SysError(ERROR_BMALLOC2);
+ XtFree(screen->selection);
+ screen->selection = line;
+ screen->selection_size = j + 1;
+ } else line = screen->selection;
+ if (!line || 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 */
+
+ screen->selection_length = (lp - line);
+ _OwnSelection(term, params, num_params);
+}
+
+static Boolean ConvertSelection(w, selection, target,
+ type, value, length, format)
+Widget w;
+Atom *selection, *target, *type;
+XtPointer *value;
+unsigned long *length;
+int *format;
+{
+ Display* d = XtDisplay(w);
+ XgtermWidget xgterm = (XgtermWidget)w;
+
+ if (xgterm->screen.selection == NULL) return False; /* can this happen? */
+
+ if (*target == XA_TARGETS(d)) {
+ Atom* targetP;
+ Atom* std_targets;
+ unsigned long std_length;
+ XmuConvertStandardSelection(
+ w, xgterm->screen.selection_time, selection,
+ target, type, (caddr_t*)&std_targets, &std_length, format
+ );
+ *length = std_length + 5;
+ *value = (XtPointer)XtMalloc(sizeof(Atom)*(*length));
+ targetP = *(Atom**)value;
+ *targetP++ = XA_STRING;
+ *targetP++ = XA_TEXT(d);
+ *targetP++ = XA_COMPOUND_TEXT(d);
+ *targetP++ = XA_LENGTH(d);
+ *targetP++ = XA_LIST_LENGTH(d);
+ memmove( (char*)targetP, (char*)std_targets, sizeof(Atom)*std_length);
+ XtFree((char*)std_targets);
+ *type = XA_ATOM;
+ *format = 32;
+ return True;
+ }
+
+ if (*target == XA_STRING ||
+ *target == XA_TEXT(d) ||
+ *target == XA_COMPOUND_TEXT(d)) {
+ if (*target == XA_COMPOUND_TEXT(d))
+ *type = *target;
+ else
+ *type = XA_STRING;
+ *value = xgterm->screen.selection;
+ *length = xgterm->screen.selection_length;
+ *format = 8;
+ return True;
+ }
+ if (*target == XA_LIST_LENGTH(d)) {
+ *value = XtMalloc(4);
+ if (sizeof(long) == 4)
+ *(long*)*value = 1;
+ else {
+ long temp = 1;
+ memmove( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
+ }
+ *type = XA_INTEGER;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (*target == XA_LENGTH(d)) {
+ *value = XtMalloc(4);
+ if (sizeof(long) == 4)
+ *(long*)*value = xgterm->screen.selection_length;
+ else {
+ long temp = xgterm->screen.selection_length;
+ memmove( (char*)*value, ((char*)&temp)+sizeof(long)-4, 4);
+ }
+ *type = XA_INTEGER;
+ *length = 1;
+ *format = 32;
+ return True;
+ }
+ if (XmuConvertStandardSelection(w, xgterm->screen.selection_time, selection,
+ target, type,
+ (caddr_t *)value, length, format))
+ return True;
+
+ /* else */
+ return False;
+
+}
+
+
+static void LoseSelection(w, selection)
+ Widget w;
+ Atom *selection;
+{
+ register TScreen* screen = &((XgtermWidget)w)->screen;
+ register Atom* atomP;
+ int i;
+ for (i = 0, atomP = screen->selection_atoms;
+ i < screen->selection_count; i++, atomP++)
+ {
+ if (*selection == *atomP) *atomP = (Atom)0;
+ switch (*atomP) {
+ case XA_CUT_BUFFER0:
+ case XA_CUT_BUFFER1:
+ case XA_CUT_BUFFER2:
+ case XA_CUT_BUFFER3:
+ case XA_CUT_BUFFER4:
+ case XA_CUT_BUFFER5:
+ case XA_CUT_BUFFER6:
+ case XA_CUT_BUFFER7: *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(w, selection, target)
+Widget w;
+Atom *selection, *target;
+{
+ /* empty proc so Intrinsics know we want to keep storage */
+}
+
+
+static void _OwnSelection(termw, selections, count)
+ register XgtermWidget termw;
+ String *selections;
+ Cardinal count;
+{
+ Atom* atoms = termw->screen.selection_atoms;
+ int i;
+ Boolean 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;
+ switch (atoms[i]) {
+ 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;
+ }
+ 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",
+ xgterm_name, termw->screen.selection_length, cutbuffer);
+ else
+ XStoreBuffer( XtDisplay((Widget)termw), termw->screen.selection,
+ termw->screen.selection_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);
+}
+
+/* void */
+DisownSelection(termw)
+ register XgtermWidget termw;
+{
+ Atom* atoms = termw->screen.selection_atoms;
+ Cardinal count = termw->screen.selection_count;
+ int i;
+
+ for (i = 0; i < count; i++) {
+ int cutbuffer;
+ switch (atoms[i]) {
+ 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;
+ }
+ if (cutbuffer < 0)
+ XtDisownSelection( (Widget)termw, atoms[i],
+ termw->screen.selection_time );
+ }
+ termw->screen.selection_count = 0;
+ termw->screen.startHRow = termw->screen.startHCol = 0;
+ termw->screen.endHRow = termw->screen.endHCol = 0;
+}
+
+
+/* returns number of chars in line from scol to ecol out */
+/* ARGSUSED */
+static int
+Length(screen, row, scol, ecol)
+ register int row, scol, ecol;
+ register TScreen *screen;
+{
+ register int lastcol = LastTextCol(row);
+
+ if (ecol > lastcol)
+ ecol = lastcol;
+ return (ecol - scol + 1);
+}
+
+/* copies text into line, preallocated */
+static char *
+SaveText(screen, row, scol, ecol, lp, eol)
+ int row;
+ int scol, ecol;
+ TScreen *screen;
+ register char *lp; /* pointer to where to put the text */
+ int *eol;
+{
+ register int i = 0;
+ register Char *ch = screen->buf[4 * (row + screen->topline)];
+ Char attr;
+ register int c;
+
+ *eol = 0;
+ i = Length(screen, row, scol, ecol);
+ ecol = scol + i;
+ if (*eol == 0) {
+ if(ScrnGetAttributes(screen, row + screen->topline, 0, &attr, 1) == 1) {
+ *eol = (attr & LINEWRAPPED) ? 0 : 1;
+ } else {
+ /* If we can't get the attributes, assume no wrap */
+ /* CANTHAPPEN */
+ (void)fprintf(stderr, "%s: no attributes for %d, %d\n",
+ xgterm_name, row, ecol - 1);
+ *eol = 1;
+ }
+ }
+ for (i = scol; i < ecol; i++) {
+ c = ch[i];
+ if (c == 0)
+ c = ' ';
+ else if(c < ' ') {
+ if(c == '\036')
+ c = '#'; /* char on screen is pound sterling */
+ else
+ c += 0x5f; /* char is from DEC drawing set */
+ } else if(c == 0x7f)
+ c = 0x5f;
+ *lp++ = c;
+ }
+ return(lp);
+}
+
+static void
+EditorButton(event)
+ register XButtonEvent *event;
+{
+ register TScreen *screen = &term->screen;
+ int pty = screen->respond;
+ char line[6];
+ register unsigned row, col;
+ int button;
+
+ button = event->button - 1;
+
+ row = (event->y - screen->border)
+ / FontHeight(screen);
+ if (term->misc.sb_right)
+ col = (event->x - screen->border) / FontWidth(screen);
+ else
+ col = (event->x - screen->border - screen->scrollbar) / FontWidth(screen);
+ (void) strcpy(line, "\033[M");
+ if (screen->send_mouse_pos == 1) {
+ line[3] = ' ' + button;
+ } else {
+ line[3] = ' ' + (KeyState(event->state) << 2) +
+ ((event->type == ButtonPress)? button:3);
+ }
+ line[4] = ' ' + col + 1;
+ line[5] = ' ' + row + 1;
+ v_write(pty, line, 6);
+}
+
+
+/* ARGSUSED */
+void HandleSecure(w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* [0] = volume */
+ Cardinal *param_count; /* 0 or 1 */
+{
+ Time time = CurrentTime;
+
+ if ((event->xany.type == KeyPress) ||
+ (event->xany.type == KeyRelease))
+ time = event->xkey.time;
+ else if ((event->xany.type == ButtonPress) ||
+ (event->xany.type == ButtonRelease))
+ time = event->xbutton.time;
+ DoSecureKeyboard (time);
+}
diff --git a/vendor/x11iraf/xgterm/charproc.c b/vendor/x11iraf/xgterm/charproc.c
new file mode 100644
index 00000000..51a44c9d
--- /dev/null
+++ b/vendor/x11iraf/xgterm/charproc.c
@@ -0,0 +1,3877 @@
+/*
+ * $XConsortium: charproc.c,v 1.180 94/04/17 20:23:25 hersh Exp $
+ */
+/*
+
+Copyright (c) 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 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 "ptyx.h"
+#include "VTparse.h"
+#include "data.h"
+#include "error.h"
+#include "menu.h"
+#include "main.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Atoms.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xmu/Converters.h>
+#ifdef I18N
+#include <X11/Xaw/XawImP.h>
+#endif
+#include <stdio.h>
+#include <errno.h>
+#include <setjmp.h>
+#include <ctype.h>
+
+
+/*
+ * 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
+
+extern jmp_buf VTend;
+
+extern XtAppContext app_con;
+extern Widget toplevel;
+extern void exit();
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+extern char *malloc();
+extern char *realloc();
+#endif
+
+
+static void VTallocbuf();
+static int finput();
+static void dotext();
+static void WriteText();
+static int in_put();
+static void do_read(), do_write();
+static void ToAlternate();
+static void FromAlternate();
+static void update_font_info();
+
+static void bitset(), bitclr();
+
+#define DEFAULT -1
+#define TEXT_BUF_SIZE 1024
+#define TRACKTIMESEC 4L
+#define TRACKTIMEUSEC 0L
+#define BELLSUPPRESSMSEC 200
+
+#define XtNalwaysHighlight "alwaysHighlight"
+#define XtNappcursorDefault "appcursorDefault"
+#define XtNappkeypadDefault "appkeypadDefault"
+#define XtNbellSuppressTime "bellSuppressTime"
+#define XtNboldFont "boldFont"
+#define XtNc132 "c132"
+#define XtNcharClass "charClass"
+#define XtNcurses "curses"
+#define XtNhpLowerleftBugCompat "hpLowerleftBugCompat"
+#define XtNcursorColor "cursorColor"
+#define XtNcutNewline "cutNewline"
+#define XtNcutToBeginningOfLine "cutToBeginningOfLine"
+#define XtNeightBitInput "eightBitInput"
+#define XtNeightBitOutput "eightBitOutput"
+#define XtNgeometry "geometry"
+#define XtNtekGeometry "tekGeometry"
+#define XtNinternalBorder "internalBorder"
+#define XtNjumpScroll "jumpScroll"
+#ifdef ALLOWLOGGING
+#define XtNlogFile "logFile"
+#define XtNlogging "logging"
+#define XtNlogInhibit "logInhibit"
+#endif
+#define XtNloginShell "loginShell"
+#define XtNmarginBell "marginBell"
+#define XtNpointerColor "pointerColor"
+#define XtNpointerColorBackground "pointerColorBackground"
+#define XtNpointerShape "pointerShape"
+#define XtNmultiClickTime "multiClickTime"
+#define XtNmultiScroll "multiScroll"
+#define XtNnMarginBell "nMarginBell"
+#define XtNresizeGravity "resizeGravity"
+#define XtNreverseWrap "reverseWrap"
+#define XtNautoWrap "autoWrap"
+#define XtNsaveLines "saveLines"
+#define XtNscrollBar "scrollBar"
+#define XtNscrollTtyOutput "scrollTtyOutput"
+#define XtNscrollKey "scrollKey"
+#define XtNscrollLines "scrollLines"
+#define XtNscrollPos "scrollPos"
+#define XtNsignalInhibit "signalInhibit"
+#define XtNtekInhibit "tekInhibit"
+#define XtNtekStartup "tekStartup"
+#define XtNtiteInhibit "titeInhibit"
+#define XtNunderLine "underLine"
+#define XtNvisualBell "visualBell"
+#define XtNallowSendEvents "allowSendEvents"
+#define XtNcolor0 "color0"
+#define XtNcolor1 "color1"
+#define XtNcolor2 "color2"
+#define XtNcolor3 "color3"
+#define XtNcolor4 "color4"
+#define XtNcolor5 "color5"
+#define XtNcolor6 "color6"
+#define XtNcolor7 "color7"
+#define XtNcolor8 "color8"
+#define XtNcolor9 "color9"
+#define XtNcolor10 "color10"
+#define XtNcolor11 "color11"
+#define XtNcolor12 "color12"
+#define XtNcolor13 "color13"
+#define XtNcolor14 "color14"
+#define XtNcolor15 "color15"
+#define XtNcolorBD "colorBD"
+#define XtNcolorUL "colorUL"
+#define XtNdynamicColors "dynamicColors"
+#define XtNscrollBarRight "scrollBarRight"
+
+#define XtCAlwaysHighlight "AlwaysHighlight"
+#define XtCAppcursorDefault "AppcursorDefault"
+#define XtCAppkeypadDefault "AppkeypadDefault"
+#define XtCBellSuppressTime "BellSuppressTime"
+#define XtCBoldFont "BoldFont"
+#define XtCC132 "C132"
+#define XtCCharClass "CharClass"
+#define XtCCurses "Curses"
+#define XtCHpLowerleftBugCompat "HpLowerleftBugCompat"
+#define XtCCutNewline "CutNewline"
+#define XtCCutToBeginningOfLine "CutToBeginningOfLine"
+#define XtCEightBitInput "EightBitInput"
+#define XtCEightBitOutput "EightBitOutput"
+#define XtCGeometry "Geometry"
+#define XtCJumpScroll "JumpScroll"
+#ifdef ALLOWLOGGING
+#define XtCLogfile "Logfile"
+#define XtCLogging "Logging"
+#define XtCLogInhibit "LogInhibit"
+#endif
+#define XtCLoginShell "LoginShell"
+#define XtCMarginBell "MarginBell"
+#define XtCMultiClickTime "MultiClickTime"
+#define XtCMultiScroll "MultiScroll"
+#define XtCColumn "Column"
+#define XtCResizeGravity "ResizeGravity"
+#define XtCReverseWrap "ReverseWrap"
+#define XtCAutoWrap "AutoWrap"
+#define XtCSaveLines "SaveLines"
+#define XtCScrollBar "ScrollBar"
+#define XtCScrollLines "ScrollLines"
+#define XtCScrollPos "ScrollPos"
+#define XtCScrollCond "ScrollCond"
+#define XtCSignalInhibit "SignalInhibit"
+#define XtCTekInhibit "TekInhibit"
+#define XtCTekStartup "TekStartup"
+#define XtCTiteInhibit "TiteInhibit"
+#define XtCUnderLine "UnderLine"
+#define XtCVisualBell "VisualBell"
+#define XtCAllowSendEvents "AllowSendEvents"
+#define XtCDynamicColors "DynamicColors"
+#define XtCScrollBarRight "ScrollBarRight"
+
+#define doinput() (bcnt-- > 0 ? *bptr++ : in_put())
+
+static int nparam;
+static ANSI reply;
+static int param[NPARAM];
+
+static unsigned long ctotal;
+static unsigned long ntotal;
+static jmp_buf vtjmpbuf;
+
+extern int groundtable[];
+extern int csitable[];
+extern int dectable[];
+extern int eigtable[];
+extern int esctable[];
+extern int iestable[];
+extern int igntable[];
+extern int scrtable[];
+extern int scstable[];
+
+
+/* event handlers */
+extern void HandleKeyPressed(), HandleEightBitKeyPressed();
+extern void HandleStringEvent();
+extern void HandleEnterWindow();
+extern void HandleLeaveWindow();
+extern void HandleBellPropertyChange();
+extern void HandleFocusChange();
+static void HandleKeymapChange();
+extern void HandleInsertSelection();
+extern void HandleSelectStart(), HandleKeyboardSelectStart();
+extern void HandleSelectExtend(), HandleSelectSet();
+extern void HandleSelectEnd(), HandleKeyboardSelectEnd();
+extern void HandleStartExtend(), HandleKeyboardStartExtend();
+static void HandleBell();
+static void HandleVisualBell();
+static void HandleIgnore();
+extern void HandleSecure();
+extern void HandleScrollForward();
+extern void HandleScrollBack();
+extern void HandleCreateMenu(), HandlePopupMenu();
+extern void HandleSetFont();
+extern void SetVTFont();
+
+extern void ViButton(), DiredButton();
+extern Boolean SendMousePosition();
+extern void ScrnSetAttributes();
+
+/*
+ * NOTE: VTInitialize zeros out the entire ".screen" component of the
+ * XgtermWidget, so make sure to add an assignment statement in VTInitialize()
+ * for each new ".screen" field added to this resource list.
+ */
+
+/* Defaults */
+static Boolean defaultFALSE = FALSE;
+static Boolean defaultTRUE = TRUE;
+static int defaultBorderWidth = DEFBORDERWIDTH;
+static int defaultIntBorder = DEFBORDER;
+static int defaultSaveLines = SAVELINES;
+static int defaultScrollLines = SCROLLLINES;
+static int defaultNMarginBell = N_MARGINBELL;
+static int defaultMultiClickTime = MULTICLICKTIME;
+static int defaultBellSuppressTime = BELLSUPPRESSMSEC;
+static char * _Font_Selected_ = "yes"; /* string is arbitrary */
+
+/*
+ * Warning, the following must be kept under 1024 bytes or else some
+ * compilers (particularly AT&T 6386 SVR3.2) will barf). Workaround is to
+ * declare a static buffer and copy in at run time (the the Athena text widget
+ * does). Yuck.
+ */
+static char defaultTranslations[] =
+"\
+ Shift <KeyPress> Prior:scroll-back(1,halfpage) \n\
+ Shift <KeyPress> Next:scroll-forw(1,halfpage) \n\
+Shift <KeyPress> Select:select-cursor-start() select-cursor-end(PRIMARY, CUT_BUFFER0) \n\
+Shift <KeyPress> Insert:insert-selection(PRIMARY, CUT_BUFFER0) \n\
+ ~Meta <KeyPress>:insert-seven-bit() \n\
+ Meta <KeyPress>:insert-eight-bit() \n\
+ !Ctrl <Btn1Down>:popup-menu(mainMenu) \n\
+ !Lock Ctrl <Btn1Down>:popup-menu(mainMenu) \n\
+ ~Meta <Btn1Down>:select-start() \n\
+ ~Meta <Btn1Motion>:select-extend() \n\
+ !Ctrl <Btn2Down>:popup-menu(fontMenu) \n\
+ !Lock Ctrl <Btn2Down>:popup-menu(fontMenu) \n\
+ ~Ctrl ~Meta <Btn2Down>:ignore() \n\
+ ~Ctrl ~Meta <Btn2Up>:insert-selection(PRIMARY, CUT_BUFFER0) \n\
+ !Ctrl <Btn3Down>:popup-menu(vtMenu) \n\
+ !Lock Ctrl <Btn3Down>:popup-menu(vtMenu) \n\
+ ~Ctrl ~Meta <Btn3Down>:start-extend() \n\
+ ~Meta <Btn3Motion>:select-extend() \n\
+ <BtnUp>:select-end(PRIMARY, CUT_BUFFER0) \n\
+ <BtnDown>:bell(0) \
+";
+
+static XtActionsRec actionsList[] = {
+ { "bell", HandleBell },
+ { "create-menu", HandleCreateMenu },
+ { "ignore", HandleIgnore },
+ { "insert", HandleKeyPressed }, /* alias for insert-seven-bit */
+ { "insert-seven-bit", HandleKeyPressed },
+ { "insert-eight-bit", HandleEightBitKeyPressed },
+ { "insert-selection", HandleInsertSelection },
+ { "keymap", HandleKeymapChange },
+ { "popup-menu", HandlePopupMenu },
+ { "secure", HandleSecure },
+ { "select-start", HandleSelectStart },
+ { "select-extend", HandleSelectExtend },
+ { "select-end", HandleSelectEnd },
+ { "select-set", HandleSelectSet },
+ { "select-cursor-start", HandleKeyboardSelectStart },
+ { "select-cursor-end", HandleKeyboardSelectEnd },
+ { "set-vt-font", HandleSetFont },
+ { "start-extend", HandleStartExtend },
+ { "start-cursor-extend", HandleKeyboardStartExtend },
+ { "string", HandleStringEvent },
+ { "scroll-forw", HandleScrollForward },
+ { "scroll-back", HandleScrollBack },
+ /* 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 },
+ { "clear-saved-lines", HandleClearSavedLines },
+ { "set-terminal-type", HandleSetTerminalType },
+ { "set-visibility", HandleVisibility },
+ { "tek-page", HandleTekPage },
+ { "tek-reset", HandleTekReset },
+ { "tek-copy", HandleTekCopy },
+ { "visual-bell", HandleVisualBell },
+ { "dired-button", DiredButton },
+ { "vi-button", ViButton },
+};
+
+static XtResource resources[] = {
+{XtNfont, XtCFont, XtRString, sizeof(char *),
+ XtOffsetOf(XgtermWidgetRec, misc.f_n), XtRString,
+ DEFFONT},
+{XtNboldFont, XtCBoldFont, XtRString, sizeof(char *),
+ XtOffsetOf(XgtermWidgetRec, misc.f_b), XtRString,
+ DEFBOLDFONT},
+{XtNc132, XtCC132, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.c132),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNcharClass, XtCCharClass, XtRString, sizeof(char *),
+ XtOffsetOf(XgtermWidgetRec, screen.charClass),
+ XtRString, (XtPointer) NULL},
+{XtNcurses, XtCCurses, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.curses),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.hp_ll_bc),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNcutNewline, XtCCutNewline, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.cutNewline),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+{XtNcutToBeginningOfLine, XtCCutToBeginningOfLine, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.cutToBeginningOfLine),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+{XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, core.background_pixel),
+ XtRString, "XtDefaultBackground"},
+{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.foreground),
+ XtRString, "XtDefaultForeground"},
+{XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.cursorcolor),
+ XtRString, "XtDefaultForeground"},
+{XtNeightBitInput, XtCEightBitInput, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.input_eight_bits),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+{XtNeightBitOutput, XtCEightBitOutput, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.output_eight_bits),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+{XtNgeometry,XtCGeometry, XtRString, sizeof(char *),
+ XtOffsetOf(XgtermWidgetRec, misc.geo_metry),
+ XtRString, (XtPointer) NULL},
+{XtNalwaysHighlight,XtCAlwaysHighlight,XtRBoolean,
+ sizeof(Boolean),XtOffsetOf(XgtermWidgetRec, screen.always_highlight),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNappcursorDefault,XtCAppcursorDefault,XtRBoolean,
+ sizeof(Boolean),XtOffsetOf(XgtermWidgetRec, misc.appcursorDefault),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNappkeypadDefault,XtCAppkeypadDefault,XtRBoolean,
+ sizeof(Boolean),XtOffsetOf(XgtermWidgetRec, misc.appkeypadDefault),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNbellSuppressTime, XtCBellSuppressTime, XtRInt, sizeof(int),
+ XtOffsetOf(XgtermWidgetRec, screen.bellSuppressTime),
+ XtRInt, (XtPointer) &defaultBellSuppressTime},
+{XtNtekGeometry,XtCGeometry, XtRString, sizeof(char *),
+ XtOffsetOf(XgtermWidgetRec, misc.T_geometry),
+ XtRString, (XtPointer) NULL},
+{XtNalwaysHighlight,XtCAlwaysHighlight,XtRBoolean,
+ sizeof(Boolean),XtOffset(XgtermWidget, screen.always_highlight),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNinternalBorder,XtCBorderWidth,XtRInt, sizeof(int),
+ XtOffsetOf(XgtermWidgetRec, screen.border),
+ XtRInt, (XtPointer) &defaultIntBorder},
+{XtNjumpScroll, XtCJumpScroll, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.jumpscroll),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+#ifdef ALLOWLOGGING
+{XtNlogFile, XtCLogfile, XtRString, sizeof(char *),
+ XtOffsetOf(XgtermWidgetRec, screen.logfile),
+ XtRString, (XtPointer) NULL},
+{XtNlogging, XtCLogging, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.log_on),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNlogInhibit, XtCLogInhibit, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.logInhibit),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+#endif
+{XtNloginShell, XtCLoginShell, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.login_shell),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNmarginBell, XtCMarginBell, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.marginbell),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNpointerColor, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.mousecolor),
+ XtRString, "XtDefaultForeground"},
+{XtNpointerColorBackground, XtCBackground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.mousecolorback),
+ XtRString, "XtDefaultBackground"},
+{XtNpointerShape,XtCCursor, XtRCursor, sizeof(Cursor),
+ XtOffsetOf(XgtermWidgetRec, screen.pointer_cursor),
+ XtRString, (XtPointer) "xterm"},
+{XtNmultiClickTime,XtCMultiClickTime, XtRInt, sizeof(int),
+ XtOffsetOf(XgtermWidgetRec, screen.multiClickTime),
+ XtRInt, (XtPointer) &defaultMultiClickTime},
+{XtNmultiScroll,XtCMultiScroll, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.multiscroll),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNnMarginBell,XtCColumn, XtRInt, sizeof(int),
+ XtOffsetOf(XgtermWidgetRec, screen.nmarginbell),
+ XtRInt, (XtPointer) &defaultNMarginBell},
+{XtNreverseVideo,XtCReverseVideo,XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.re_verse),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNresizeGravity, XtCResizeGravity, XtRGravity, sizeof(XtGravity),
+ XtOffsetOf(XgtermWidgetRec, misc.resizeGravity),
+ XtRImmediate, (XtPointer) SouthWestGravity},
+{XtNreverseWrap,XtCReverseWrap, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.reverseWrap),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNautoWrap,XtCAutoWrap, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.autoWrap),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+{XtNsaveLines, XtCSaveLines, XtRInt, sizeof(int),
+ XtOffsetOf(XgtermWidgetRec, screen.savelines),
+ XtRInt, (XtPointer) &defaultSaveLines},
+{XtNscrollBar, XtCScrollBar, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.scrollbar),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNscrollTtyOutput,XtCScrollCond, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.scrollttyoutput),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+{XtNscrollKey, XtCScrollCond, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.scrollkey),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNscrollLines, XtCScrollLines, XtRInt, sizeof(int),
+ XtOffsetOf(XgtermWidgetRec, screen.scrolllines),
+ XtRInt, (XtPointer) &defaultScrollLines},
+{XtNsignalInhibit,XtCSignalInhibit,XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.signalInhibit),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNtekInhibit, XtCTekInhibit, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.tekInhibit),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNtekStartup, XtCTekStartup, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.TekEmu),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNtiteInhibit, XtCTiteInhibit, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.titeInhibit),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNunderLine, XtCUnderLine, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.underline),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.visualbell),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNallowSendEvents, XtCAllowSendEvents, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, screen.allowSendEvents),
+ XtRBoolean, (XtPointer) &defaultTRUE},
+{"font1", "Font1", XtRString, sizeof(String),
+ XtOffsetOf(XgtermWidgetRec, screen.menu_font_names[fontMenu_font1]),
+ XtRString, (XtPointer) NULL},
+{"font2", "Font2", XtRString, sizeof(String),
+ XtOffsetOf(XgtermWidgetRec, screen.menu_font_names[fontMenu_font2]),
+ XtRString, (XtPointer) NULL},
+{"font3", "Font3", XtRString, sizeof(String),
+ XtOffsetOf(XgtermWidgetRec, screen.menu_font_names[fontMenu_font3]),
+ XtRString, (XtPointer) NULL},
+{"font4", "Font4", XtRString, sizeof(String),
+ XtOffsetOf(XgtermWidgetRec, screen.menu_font_names[fontMenu_font4]),
+ XtRString, (XtPointer) NULL},
+{"font5", "Font5", XtRString, sizeof(String),
+ XtOffsetOf(XgtermWidgetRec, screen.menu_font_names[fontMenu_font5]),
+ XtRString, (XtPointer) NULL},
+{"font6", "Font6", XtRString, sizeof(String),
+ XtOffsetOf(XgtermWidgetRec, screen.menu_font_names[fontMenu_font6]),
+ XtRString, (XtPointer) NULL},
+#ifdef I18N
+ {XtNinputMethod, XtCInputMethod, XtRString, sizeof(char*),
+ XtOffsetOf(XgtermWidgetRec, misc.input_method),
+ XtRString, (XtPointer)NULL},
+ {XtNpreeditType, XtCPreeditType, XtRString, sizeof(char*),
+ XtOffsetOf(XgtermWidgetRec, misc.preedit_type),
+ XtRString, (XtPointer)"Root"},
+ {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.open_im),
+ XtRImmediate, (XtPointer)TRUE},
+#endif
+{XtNcolor0, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_0]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor1, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_1]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor2, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_2]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor3, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_3]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor4, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_4]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor5, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_5]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor6, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_6]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor7, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_7]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor8, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_8]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor9, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_9]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor10, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_10]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor11, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_11]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor12, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_12]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor13, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_13]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor14, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_14]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolor15, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_15]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolorBD, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_BD]),
+ XtRString, "XtDefaultForeground"},
+{XtNcolorUL, XtCForeground, XtRPixel, sizeof(Pixel),
+ XtOffsetOf(XgtermWidgetRec, screen.colors[COLOR_UL]),
+ XtRString, "XtDefaultForeground"},
+{XtNdynamicColors, XtCDynamicColors, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.dynamicColors),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+{XtNscrollBarRight, XtCScrollBarRight, XtRBoolean, sizeof(Boolean),
+ XtOffsetOf(XgtermWidgetRec, misc.sb_right),
+ XtRBoolean, (XtPointer) &defaultFALSE},
+};
+
+static void VTClassInit();
+static void VTInitialize();
+static void VTRealize();
+static void VTExpose();
+static void VTResize();
+static void VTDestroy();
+static Boolean VTSetValues();
+#ifdef I18N
+static void VTInitI18N();
+#endif
+
+static WidgetClassRec xgtermClassRec = {
+ {
+/* core_class fields */
+ /* superclass */ (WidgetClass) &widgetClassRec,
+ /* class_name */ "VT100",
+ /* widget_size */ sizeof(XgtermWidgetRec),
+ /* class_initialize */ VTClassInit,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ VTInitialize,
+ /* initialize_hook */ NULL,
+ /* realize */ VTRealize,
+ /* actions */ actionsList,
+ /* num_actions */ XtNumber(actionsList),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ FALSE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ FALSE,
+ /* destroy */ VTDestroy,
+ /* resize */ VTResize,
+ /* expose */ VTExpose,
+ /* set_values */ VTSetValues,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ NULL,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_offsets */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator*/ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ }
+};
+
+WidgetClass xgtermWidgetClass = (WidgetClass)&xgtermClassRec;
+
+static void VTparse()
+{
+ register TScreen *screen = &term->screen;
+ register int *parsestate = groundtable;
+ register unsigned int c;
+ register unsigned char *cp;
+ register int row, col, top, bot, scstype;
+ extern int TrackMouse();
+
+ if(setjmp(vtjmpbuf))
+ parsestate = groundtable;
+ for( ; ; ) {
+ switch (parsestate[c = doinput()]) {
+ case CASE_PRINT:
+ /* printable characters */
+ top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt;
+ cp = bptr;
+ *--bptr = c;
+ while(top > 0 && isprint(*cp & 0x7f)) {
+ top--;
+ bcnt--;
+ cp++;
+ }
+ if(screen->curss) {
+ dotext(screen, term->flags,
+ screen->gsets[screen->curss], bptr, bptr + 1,
+ term->cur_foreground,
+ term->cur_background );
+ screen->curss = 0;
+ bptr++;
+ }
+ if(bptr < cp)
+ dotext(screen, term->flags,
+ screen->gsets[screen->curgl], bptr, cp,
+ term->cur_foreground,
+ term->cur_background );
+ bptr = cp;
+ break;
+
+ case CASE_GROUND_STATE:
+ /* exit ignore mode */
+ parsestate = groundtable;
+ break;
+
+ case CASE_IGNORE_STATE:
+ /* Ies: ignore anything else */
+ parsestate = igntable;
+ break;
+
+ case CASE_IGNORE_ESC:
+ /* Ign: escape */
+ parsestate = iestable;
+ break;
+
+ case CASE_IGNORE:
+ /* Ignore character */
+ break;
+
+ case CASE_BELL:
+ /* bell */
+ Bell();
+ break;
+
+ case CASE_BS:
+ /* backspace */
+ CursorBack(screen, 1);
+ break;
+
+ case CASE_CR:
+ /* carriage return */
+ CarriageReturn(screen);
+ parsestate = groundtable;
+ break;
+
+ case CASE_ESC:
+ /* escape */
+ parsestate = esctable;
+ break;
+
+ case CASE_VMOT:
+ /*
+ * form feed, line feed, vertical tab
+ */
+ Index(screen, 1);
+ if (term->flags & LINEFEED)
+ CarriageReturn(screen);
+ if (XtAppPending(app_con) ||
+ GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
+ xevents();
+ parsestate = groundtable;
+ break;
+
+ case CASE_TAB:
+ /* tab */
+ screen->cur_col = TabNext(term->tabs, screen->cur_col);
+ if (screen->cur_col > screen->max_col)
+ screen->cur_col = screen->max_col;
+ break;
+
+ case CASE_SI:
+ screen->curgl = 0;
+ break;
+
+ case CASE_SO:
+ screen->curgl = 1;
+ break;
+
+ case CASE_SCR_STATE:
+ /* enter scr state */
+ parsestate = scrtable;
+ break;
+
+ case CASE_SCS0_STATE:
+ /* enter scs state 0 */
+ scstype = 0;
+ parsestate = scstable;
+ break;
+
+ case CASE_SCS1_STATE:
+ /* enter scs state 1 */
+ scstype = 1;
+ parsestate = scstable;
+ break;
+
+ case CASE_SCS2_STATE:
+ /* enter scs state 2 */
+ scstype = 2;
+ parsestate = scstable;
+ break;
+
+ case CASE_SCS3_STATE:
+ /* enter scs state 3 */
+ scstype = 3;
+ parsestate = scstable;
+ break;
+
+ case CASE_ESC_IGNORE:
+ /* unknown escape sequence */
+ 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');
+ break;
+
+ case CASE_ESC_SEMI:
+ /* semicolon in csi or dec mode */
+ param[nparam++] = DEFAULT;
+ break;
+
+ case CASE_DEC_STATE:
+ /* enter dec mode */
+ parsestate = dectable;
+ break;
+
+ case CASE_ICH:
+ /* ICH */
+ if((row = param[0]) < 1)
+ row = 1;
+ InsertChar(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_CUU:
+ /* CUU */
+ if((row = param[0]) < 1)
+ row = 1;
+ CursorUp(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_CUD:
+ /* CUD */
+ if((row = param[0]) < 1)
+ row = 1;
+ CursorDown(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_CUF:
+ /* CUF */
+ if((row = param[0]) < 1)
+ row = 1;
+ CursorForward(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_CUB:
+ /* CUB */
+ if((row = param[0]) < 1)
+ row = 1;
+ CursorBack(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_CUP:
+ /* CUP | HVP */
+ if((row = param[0]) < 1)
+ row = 1;
+ if(nparam < 2 || (col = param[1]) < 1)
+ col = 1;
+ CursorSet(screen, row-1, col-1, term->flags);
+ parsestate = groundtable;
+ break;
+
+ case CASE_HP_BUGGY_LL:
+ /* 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);
+ parsestate = groundtable;
+ break;
+
+ case CASE_ED:
+ /* ED */
+ switch (param[0]) {
+ case DEFAULT:
+ case 0:
+ ClearBelow(screen);
+ break;
+
+ case 1:
+ ClearAbove(screen);
+ break;
+
+ case 2:
+ ClearScreen(screen);
+ CursorSet(screen, 0, 0, term->flags);
+ break;
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_EL:
+ /* EL */
+ switch (param[0]) {
+ case DEFAULT:
+ case 0:
+ ClearRight(screen);
+ break;
+ case 1:
+ ClearLeft(screen);
+ break;
+ case 2:
+ ClearLine(screen);
+ break;
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_IL:
+ /* IL */
+ if((row = param[0]) < 1)
+ row = 1;
+ InsertLine(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_DL:
+ /* DL */
+ if((row = param[0]) < 1)
+ row = 1;
+ DeleteLine(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_DCH:
+ /* DCH */
+ if((row = param[0]) < 1)
+ row = 1;
+ DeleteChar(screen, row);
+ parsestate = groundtable;
+ break;
+
+ case CASE_TRACK_MOUSE:
+ /* 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);
+ break;
+
+ case CASE_DECID:
+ param[0] = -1; /* Default ID parameter */
+ /* Fall through into ... */
+ case CASE_DA1:
+ /* DA1 */
+ if (param[0] <= 0) { /* less than means DEFAULT */
+ reply.a_type = CSI;
+ reply.a_pintro = '?';
+ reply.a_nparam = 2;
+ reply.a_param[0] = 1; /* VT102 */
+ reply.a_param[1] = 2; /* VT102 */
+ reply.a_inters = 0;
+ reply.a_final = 'c';
+ unparseseq(&reply, screen->respond);
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_TBC:
+ /* TBC */
+ if ((row = param[0]) <= 0) /* less than means default */
+ TabClear(term->tabs, screen->cur_col);
+ else if (row == 3)
+ TabZonk(term->tabs);
+ parsestate = groundtable;
+ break;
+
+ case CASE_SET:
+ /* SET */
+ ansi_modes(term, bitset);
+ parsestate = groundtable;
+ break;
+
+ case CASE_RST:
+ /* RST */
+ ansi_modes(term, bitclr);
+ parsestate = groundtable;
+ break;
+
+ case CASE_SGR:
+ /* SGR */
+ for (row=0; row<nparam; ++row) {
+ switch (param[row]) {
+ case DEFAULT:
+ case 0:
+ term->flags &=
+ ~(INVERSE|BOLD|UNDERLINE|FG_COLOR|BG_COLOR);
+ break;
+ case 1:
+ case 5: /* Blink, really. */
+ term->flags |= BOLD;
+ if (term->misc.dynamicColors) {
+ if (!(term->flags & FG_COLOR) ||
+ (term->cur_foreground==COLOR_UL)) {
+ term->flags |= FG_COLOR;
+ term->cur_foreground = COLOR_BD;
+ } else { /* Set highlight bit */
+ if (term->cur_foreground < 8)
+ term->cur_foreground |= 8;
+ }
+ }
+ break;
+ case 4: /* Underscore */
+ term->flags |= UNDERLINE;
+ if (term->misc.dynamicColors) {
+/**/ if (!(term->flags & FG_COLOR)) {
+ term->flags |= FG_COLOR;
+ term->cur_foreground = COLOR_UL;
+ }
+ }
+ break;
+ case 7:
+ term->flags |= INVERSE;
+ break;
+ case 30:
+ case 31:
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ term->flags |= FG_COLOR;
+ term->cur_foreground = param[row] - 30;
+ /* Set highlight bit if bold on */
+ if (term->flags & BOLD)
+ term->cur_foreground |= 8;
+ break;
+ case 40:
+ case 41:
+ case 42:
+ case 43:
+ case 44:
+ case 45:
+ case 46:
+ case 47:
+ term->flags |= BG_COLOR;
+ term->cur_background = param[row] - 40;
+ break;
+ }
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_CPR:
+ /* CPR */
+ if ((row = param[0]) == 5) {
+ reply.a_type = CSI;
+ reply.a_pintro = 0;
+ reply.a_nparam = 1;
+ reply.a_param[0] = 0;
+ reply.a_inters = 0;
+ reply.a_final = 'n';
+ unparseseq(&reply, screen->respond);
+ } else if (row == 6) {
+ reply.a_type = CSI;
+ reply.a_pintro = 0;
+ reply.a_nparam = 2;
+ reply.a_param[0] = screen->cur_row+1;
+ reply.a_param[1] = screen->cur_col+1;
+ reply.a_inters = 0;
+ reply.a_final = 'R';
+ unparseseq(&reply, screen->respond);
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_HP_MEM_LOCK:
+ case CASE_HP_MEM_UNLOCK:
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ if (parsestate[c] == CASE_HP_MEM_LOCK)
+ screen->top_marg = screen->cur_row;
+ else
+ screen->top_marg = 0;
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECSTBM:
+ /* DECSTBM - set scrolling region */
+ if((top = param[0]) < 1)
+ top = 1;
+ if(nparam < 2 || (bot = param[1]) == DEFAULT
+ || bot > screen->max_row + 1
+ || bot == 0)
+ bot = screen->max_row+1;
+ if (bot > top) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ screen->top_marg = top-1;
+ screen->bot_marg = bot-1;
+ CursorSet(screen, 0, 0, term->flags);
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_SUNREQTPARM:
+ /* Escape commands or query functions used by the
+ * SunView shelltool (ttysw widget). Most of these
+ * are currently stubbed out.
+ */
+ if ((row = param[0]) == DEFAULT)
+ row = 18;
+ switch (row) {
+ case 1:
+ /* open */
+ break;
+ case 2:
+ /* close */
+ break;
+ case 3:
+ /* move */
+ break;
+ case 4:
+ /* resize */
+ break;
+ case 5:
+ /* front */
+ break;
+ case 6:
+ /* back */
+ break;
+ case 7:
+ /* refresh */
+ break;
+ case 11:
+ /* report if open or iconic by sending
+ * \E[1t or \E[2t.
+ */
+ break;
+ case 13:
+ /* report position by sending \E[3;TOP;LEFTt
+ */
+ break;
+ case 14:
+ /* report size in pixels by sending \E[4;HT;WIDTHt.
+ */
+ break;
+ case 18:
+ /* report size in characters by sending
+ * \E[8;ROWS;COLSt.
+ */
+ reply.a_type = ESC;
+ reply.a_pintro = '[';
+ reply.a_nparam = 3;
+ reply.a_param[0] = 8;
+ reply.a_param[1] = screen->max_row + 1;
+ reply.a_param[2] = screen->max_col + 1;
+ reply.a_inters = 0;
+ reply.a_final = 't';
+ unparseseq(&reply, screen->respond);
+ break;
+ case 20:
+ /* report icon label by sending \E]Llabel\E\.
+ */
+ break;
+ case 21:
+ /* report tool header by sending \E]llabel\E\.
+ */
+ break;
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECREQTPARM:
+ /* DECREQTPARM */
+ 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] = 112; /* transmit 9600 baud */
+ reply.a_param[4] = 112; /* receive 9600 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);
+ }
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECSET:
+ /* DECSET */
+ dpmodes(term, bitset);
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECRST:
+ /* DECRST */
+ dpmodes(term, bitclr);
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECALN:
+ /* DECALN */
+ if(screen->cursor_state)
+ HideCursor();
+ for(row = screen->max_row ; row >= 0 ; row--) {
+ memset(screen->buf[4 * row + 1], 0,
+ col = screen->max_col + 1);
+ for(cp = (unsigned char *)screen->buf[4 * row] ; col > 0 ; col--)
+ *cp++ = (unsigned char) 'E';
+ }
+ ScrnRefresh(screen, 0, 0, screen->max_row + 1,
+ screen->max_col + 1, False);
+ parsestate = groundtable;
+ break;
+
+ case CASE_GSETS:
+ screen->gsets[scstype] = c;
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECSC:
+ /* DECSC */
+ CursorSave(term, &screen->sc);
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECRC:
+ /* DECRC */
+ CursorRestore(term, &screen->sc);
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECKPAM:
+ /* DECKPAM */
+ term->keyboard.flags |= KYPD_APL;
+ update_appkeypad();
+ parsestate = groundtable;
+ break;
+
+ case CASE_DECKPNM:
+ /* DECKPNM */
+ term->keyboard.flags &= ~KYPD_APL;
+ update_appkeypad();
+ parsestate = groundtable;
+ break;
+
+ case CASE_IND:
+ /* IND */
+ Index(screen, 1);
+ if (XtAppPending(app_con) ||
+ GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
+ xevents();
+ parsestate = groundtable;
+ break;
+
+ case CASE_NEL:
+ /* NEL */
+ Index(screen, 1);
+ CarriageReturn(screen);
+
+ if (XtAppPending(app_con) ||
+ GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
+ xevents();
+ parsestate = groundtable;
+ break;
+
+ case CASE_HTS:
+ /* HTS */
+ TabSet(term->tabs, screen->cur_col);
+ parsestate = groundtable;
+ break;
+
+ case CASE_RI:
+ /* RI */
+ RevIndex(screen, 1);
+ parsestate = groundtable;
+ break;
+
+ case CASE_SS2:
+ /* SS2 */
+ screen->curss = 2;
+ parsestate = groundtable;
+ break;
+
+ case CASE_SS3:
+ /* SS3 */
+ screen->curss = 3;
+ parsestate = groundtable;
+ break;
+
+ case CASE_CSI_STATE:
+ /* enter csi state */
+ nparam = 1;
+ param[0] = DEFAULT;
+ parsestate = csitable;
+ break;
+
+ case CASE_OSC:
+ /* Operating System Command: ESC ] */
+ do_osc(finput);
+ parsestate = groundtable;
+ break;
+
+ case CASE_RIS:
+ /* RIS */
+ VTReset(TRUE);
+ parsestate = groundtable;
+ break;
+
+ case CASE_LS2:
+ /* LS2 */
+ screen->curgl = 2;
+ parsestate = groundtable;
+ break;
+
+ case CASE_LS3:
+ /* LS3 */
+ screen->curgl = 3;
+ parsestate = groundtable;
+ break;
+
+ case CASE_LS3R:
+ /* LS3R */
+ screen->curgr = 3;
+ parsestate = groundtable;
+ break;
+
+ case CASE_LS2R:
+ /* LS2R */
+ screen->curgr = 2;
+ parsestate = groundtable;
+ break;
+
+ case CASE_LS1R:
+ /* LS1R */
+ screen->curgr = 1;
+ parsestate = groundtable;
+ break;
+
+ case CASE_XGTERM_SAVE:
+ savemodes(term);
+ parsestate = groundtable;
+ break;
+
+ case CASE_XGTERM_RESTORE:
+ restoremodes(term);
+ parsestate = groundtable;
+ break;
+
+ default:
+ printf ("VTParse: unknown state....\n");
+ }
+ }
+}
+
+static finput()
+{
+ return(doinput());
+}
+
+
+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 */
+
+/**/
+static XtIntervalId input_handler = (XtIntervalId) NULL;
+static XtIntervalId output_handler = (XtIntervalId) NULL;
+static int pty_read_bytes = 0;
+#define ptymask() (v_bufptr > v_bufstr ? pty_mask : 0)
+
+/* 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. */
+
+v_write(f, d, len)
+ int f;
+ char *d;
+ int len;
+{
+ int riten;
+ int c = len;
+
+ if (v_bufstr == NULL && len > 0) {
+ v_buffer = 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, d);
+ fprintf(stderr, "\n");
+ }
+#endif
+
+ if ((1 << f) != pty_mask)
+ return(write(f, d, len));
+
+ /*
+ * 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 (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, 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 = realloc(v_buffer, size + len);
+ 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",
+ xgterm_name);
+ v_buffer = v_bufstr; /* restore clobbered pointer */
+ c = 0;
+ }
+ }
+ }
+ if (v_bufend >= v_bufptr + len) {
+ /* new stuff will fit */
+ memmove( v_bufptr, d, 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) {
+ riten = write(f, v_bufstr, v_bufptr - v_bufstr <= MAX_PTY_WRITE ?
+ v_bufptr - v_bufstr : MAX_PTY_WRITE);
+ if (riten < 0) {
+#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;
+ int allocsize = size ? size : 1;
+
+ v_buffer = realloc(v_buffer, allocsize);
+ 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 */
+ }
+ }
+
+ /* If there is still data left to write post an event handler to
+ * write the rest of the buffer. Otherwise remove any old handler.
+ */
+ if (v_bufptr > v_bufstr) {
+ if (!output_handler)
+ output_handler = XtAppAddInput (app_con, f,
+ (XtPointer)XtInputWriteMask, do_write, (XtPointer)NULL);
+ } else if (output_handler) {
+ XtRemoveInput (output_handler);
+ output_handler = (XtIntervalId) NULL;
+ }
+
+ return(c);
+}
+
+
+/* in_put -- Process input from all sources (terminal pty i/o, X events, and
+ * timers). This is called after the input pty data buffer has been processed
+ * and we are ready for more input, and it returns when new input data has
+ * been received from the client.
+ */
+static int
+in_put()
+{
+ register TScreen *screen = &term->screen;
+ register XtInputMask mask;
+
+ /* Enable pty input. */
+ if (!input_handler)
+ init_ttyio (screen->respond);
+
+ /* Process events until we get some input data to return to our caller.
+ */
+ do {
+ /* Pty input events are processed first - this is necessary for the
+ * jump scroll feature to work properly.
+ */
+ if (bcnt <= 0 && pty_read_bytes < 4096) {
+ mask = (XtIMAlternateInput | XtIMTimer);
+ while (bcnt <= 0 && (XtAppPending(app_con) & mask))
+ XtAppProcessEvent (app_con, mask);
+ if (bcnt > 0)
+ goto done;
+ }
+
+ /* Update the screen. */
+ if (screen->scroll_amt)
+ FlushScroll (screen);
+ if (screen->cursor_set && (screen->cursor_col != screen->cur_col
+ || screen->cursor_row != screen->cur_row)) {
+ if (screen->cursor_state)
+ HideCursor();
+ ShowCursor();
+ } else if (screen->cursor_set != screen->cursor_state) {
+ if (screen->cursor_set)
+ ShowCursor();
+ else
+ HideCursor();
+ }
+ while (!gt_flush())
+ ;
+ XFlush (XtDisplay(term));
+
+ /* Process any queued up X events. */
+ while (XtAppPending(app_con) & (XtIMXEvent|XtIMTimer))
+ XtAppProcessEvent (app_con, XtIMXEvent|XtIMTimer);
+
+ /* Wait for and process the next input event. */
+ XtAppProcessEvent (app_con, XtIMAll);
+ pty_read_bytes = 0;
+
+ } while (bcnt <= 0);
+
+done:
+ /* Disable pty input except when in this routine. */
+ XtRemoveInput (input_handler);
+ input_handler = (XtIntervalId) NULL;
+
+ /* Return the next input char. */
+ bcnt--;
+ return (*bptr++);
+}
+
+
+/* do_read -- Called to read input data from the client pty. We merely read
+ * the data into the global input data buffer and return. The data is
+ * processed out of the buffer elsewhere.
+ */
+static void
+do_read (w, fd, id)
+ XtPointer w;
+ int *fd;
+ XtInputId *id;
+{
+ register TScreen *screen = &term->screen;
+
+ /* Don't read any more data until the input buffer is empty. */
+ if (bcnt > 0)
+ return;
+
+#ifdef ALLOWLOGGING
+ if (screen->logging)
+ FlushLog(screen);
+#endif
+
+ bcnt = read (*fd, (char *)(bptr = buffer), BUF_SIZE);
+ if (bcnt > 0 && screen->logging)
+ write (screen->logfd, buffer, bcnt);
+
+ if (bcnt < 0) {
+ if (errno == EIO)
+ Cleanup (0);
+ else if (!E_TEST(errno))
+ Panic ("input: read returned unexpected error (%d)\n", errno);
+ } else if (bcnt == 0) {
+ Panic ("input: read returned zero\n", 0);
+
+ } else {
+ /* read from pty was successful */
+
+ /* Let gtermio remove any graphics text. */
+ bcnt = gt_input (bptr, bcnt);
+ gt_flush();
+
+ if (bcnt <= 0) {
+ bcnt = 0;
+ return;
+ }
+
+ if (!screen->output_eight_bits) {
+ register int bc = bcnt;
+ register Char *b = bptr;
+
+ for (; bc > 0; bc--, b++) {
+ *b &= (Char) 0x7f;
+ }
+ }
+
+ if (screen->scrollWidget && screen->scrollttyoutput &&
+ screen->topline < 0)
+ WindowScroll(screen, 0); /* Scroll to bottom */
+
+ pty_read_bytes += bcnt;
+ }
+}
+
+
+/* do_write -- Called to write buffered client output when there is data
+ * queued and the output file is ready for writing.
+ */
+static void
+do_write (w, fd, id)
+ XtPointer w;
+ int *fd;
+ XtInputId *id;
+{
+ v_write (*fd, 0, 0);
+}
+
+/* init_ttyio -- Initialize tty i/o. Called by the main when the terminal
+ * file descriptor has been obtained.
+ */
+init_ttyio (pty)
+ int pty;
+{
+ if (pty < 0) {
+ Panic ("init_ttyio: invalid pty=%d\n", pty);
+
+ } else if (!input_handler) {
+ input_handler = XtAppAddInput (app_con, pty,
+ (XtPointer)XtInputReadMask, do_read, (XtPointer)NULL);
+ }
+}
+
+
+/*
+ * process a string of characters according to the character set indicated
+ * by charset. worry about end of line conditions (wraparound if selected).
+ */
+static void
+dotext(screen, flags, charset, buf, ptr, fg, bg)
+ register TScreen *screen;
+ unsigned flags, fg, bg;
+ char charset;
+ char *buf; /* start of characters to process */
+ char *ptr; /* end */
+{
+ register char *s;
+ register int len;
+ register int n;
+ register int next_col;
+
+ switch (charset) {
+ case 'A': /* United Kingdom set */
+ for (s=buf; s<ptr; ++s)
+ if (*s == '#')
+ *s = '\036'; /* UK pound sign*/
+ break;
+
+ case 'B': /* ASCII set */
+ break;
+
+ case '0': /* special graphics (line drawing) */
+ for (s=buf; s<ptr; ++s)
+ if (*s>=0x5f && *s<=0x7e)
+ *s = *s == 0x5f ? 0x7f : *s - 0x5f;
+ break;
+
+ default: /* any character sets we don't recognize*/
+ return;
+ }
+
+ len = ptr - buf;
+ ptr = buf;
+ while (len > 0) {
+ n = screen->max_col - screen->cur_col +1;
+ if (n <= 1) {
+ if (screen->do_wrap && (flags&WRAPAROUND)) {
+ /* mark that we had to wrap this line */
+ ScrnSetAttributes(screen, screen->cur_row, 0,
+ LINEWRAPPED, LINEWRAPPED, 1);
+ Index(screen, 1);
+ screen->cur_col = 0;
+ screen->do_wrap = 0;
+ n = screen->max_col+1;
+ } else
+ n = 1;
+ }
+ if (len < n)
+ n = len;
+ next_col = screen->cur_col + n;
+ WriteText(screen, ptr, n, flags, fg, bg);
+ /*
+ * 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 < next_col);
+ len -= n;
+ ptr += n;
+ }
+}
+
+/*
+ * write a string str of length len onto the screen at
+ * the current cursor position. update cursor position.
+ */
+static void
+WriteText(screen, str, len, flags, fg, bg)
+ register TScreen *screen;
+ register char *str;
+ register int len;
+ unsigned flags, fg, bg;
+{
+ register int cx, cy;
+ register unsigned fgs = flags;
+ register Pixel fg_pix, bg_pix;
+ GC currentGC;
+
+ fg_pix = (fgs & FG_COLOR) ? screen->colors[fg] :
+ screen->foreground;
+ bg_pix = (fgs & BG_COLOR) ? screen->colors[bg] :
+ term->core.background_pixel;
+
+ if(screen->cur_row - screen->topline <= screen->max_row) {
+ /*
+ if(screen->cur_row == screen->cursor_row && screen->cur_col <=
+ screen->cursor_col && screen->cursor_col <= screen->cur_col + len - 1)
+ screen->cursor_state = OFF;
+ */
+ if(screen->cursor_state)
+ HideCursor();
+
+ /*
+ * make sure that the correct GC is current
+ */
+
+ if (fgs & INVERSE) {
+ if (fgs & BOLD) currentGC = screen->reverseboldGC;
+ else currentGC = screen->reverseGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, currentGC, bg_pix);
+ XSetBackground(screen->display, currentGC, fg_pix);
+ }
+
+ } else { /* not bold */
+ if (fgs & BOLD) currentGC = screen->normalboldGC;
+ else currentGC = screen->normalGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, currentGC, fg_pix);
+ XSetBackground(screen->display, currentGC, bg_pix);
+ }
+ }
+
+ if (fgs & INSERT)
+ InsertChar(screen, len);
+ if (!(AddToRefresh(screen))) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ cx = CursorX(screen, screen->cur_col);
+ cy = CursorY(screen, screen->cur_row)+screen->fnt_norm->ascent;
+ XDrawImageString(screen->display, TextWindow(screen), currentGC,
+ cx, cy, str, len);
+
+ if((fgs & BOLD) && screen->enbolden)
+ if (currentGC == screen->normalGC || screen->reverseGC)
+ XDrawString(screen->display, TextWindow(screen),
+ currentGC,cx + 1, cy, str, len);
+
+ if((fgs & UNDERLINE) && screen->underline)
+ XDrawLine(screen->display, TextWindow(screen), currentGC,
+ cx, cy+1,
+ cx + len * FontWidth(screen), cy+1);
+ /*
+ * the following statements compile data to compute the average
+ * number of characters written on each call to XText. The data
+ * may be examined via the use of a "hidden" escape sequence.
+ */
+ ctotal += len;
+ ++ntotal;
+ }
+ }
+ ScreenWrite(screen, str, flags, fg, bg, len);
+ CursorForward(screen, len);
+}
+
+/*
+ * process ANSI modes set, reset
+ */
+ansi_modes(termw, func)
+ XgtermWidget termw;
+ int (*func)();
+{
+ register int i;
+
+ for (i=0; i<nparam; ++i) {
+ switch (param[i]) {
+ case 4: /* IRM */
+ (*func)(&termw->flags, INSERT);
+ break;
+
+ case 20: /* LNM */
+ (*func)(&termw->flags, LINEFEED);
+ update_autolinefeed();
+ break;
+ }
+ }
+}
+
+/*
+ * process DEC private modes set, reset
+ */
+dpmodes(termw, func)
+ XgtermWidget termw;
+ void (*func)();
+{
+ register TScreen *screen = &termw->screen;
+ register int i, j;
+
+ for (i=0; i<nparam; ++i) {
+ switch (param[i]) {
+ case 1: /* DECCKM */
+ (*func)(&termw->keyboard.flags, CURSOR_APL);
+ update_appcursor();
+ break;
+ case 2: /* ANSI/VT52 mode */
+ if (func == bitset) {
+ screen->gsets[0] =
+ screen->gsets[1] =
+ screen->gsets[2] =
+ screen->gsets[3] = 'B';
+ screen->curgl = 0;
+ screen->curgr = 2;
+ }
+ 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 != screen->max_col + 1) {
+ Dimension replyWidth, replyHeight;
+ XtGeometryResult status;
+
+ if (term->misc.sb_right) {
+ status = XtMakeResizeRequest (
+ (Widget) termw,
+ (Dimension)FontWidth(screen) * j
+ + 2*screen->border,
+ (Dimension) FontHeight(screen)
+ * (screen->max_row + 1)
+ + 2 * screen->border,
+ &replyWidth, &replyHeight);
+ } else {
+ status = XtMakeResizeRequest (
+ (Widget) termw,
+ (Dimension)FontWidth(screen) * j
+ + 2*screen->border +
+ screen->scrollbar,
+ (Dimension) FontHeight(screen)
+ * (screen->max_row + 1)
+ + 2 * screen->border,
+ &replyWidth, &replyHeight);
+ }
+
+ if (status == XtGeometryYes ||
+ status == XtGeometryDone) {
+ ScreenResize (&termw->screen,
+ replyWidth,
+ replyHeight,
+ &termw->flags);
+ }
+ }
+ (*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 */
+ break;
+ case 9: /* MIT bogus sequence */
+ if(func == bitset)
+ screen->send_mouse_pos = 1;
+ else
+ screen->send_mouse_pos = 0;
+ break;
+ case 38: /* DECTEK */
+ if(func == bitset && !(screen->inhibit & I_TEK)) {
+#ifdef ALLOWLOGGING
+ if(screen->logging) {
+ FlushLog(screen);
+ screen->logstart = Tbuffer;
+ }
+#endif
+ /* Enable gtermio as if a GS had been seen,
+ * but in xterm emulation mode (no trailers).
+ * Call gt_input to pass any buffered input
+ * following the DECTEK on to gtermio.
+ */
+ switch_modes (0);
+ gt_set_ginmode_trailers (NULL);
+ while (!gt_flush())
+ ;
+ }
+ 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 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();
+ Bell();
+#endif /* ALLOWLOGFILEONOFF */
+ break;
+#endif
+ case 47: /* alternate buffer */
+ if (!termw->misc.titeInhibit) {
+ if(func == bitset)
+ ToAlternate(screen);
+ else
+ FromAlternate(screen);
+ }
+ break;
+ case 1000: /* xgterm bogus sequence */
+ if(func == bitset)
+ screen->send_mouse_pos = 2;
+ else
+ screen->send_mouse_pos = 0;
+ break;
+ case 1001: /* xgterm sequence w/hilite tracking */
+ if(func == bitset)
+ screen->send_mouse_pos = 3;
+ else
+ screen->send_mouse_pos = 0;
+ break;
+ }
+ }
+}
+
+/*
+ * process xgterm private modes save
+ */
+savemodes(termw)
+ XgtermWidget termw;
+{
+ register TScreen *screen = &termw->screen;
+ register int i;
+
+ for (i = 0; i < nparam; i++) {
+ switch (param[i]) {
+ case 1: /* DECCKM */
+ screen->save_modes[0] = termw->keyboard.flags &
+ CURSOR_APL;
+ break;
+ case 3: /* DECCOLM */
+ if(screen->c132)
+ screen->save_modes[1] = termw->flags & IN132COLUMNS;
+ break;
+ case 4: /* DECSCLM (slow scroll) */
+ screen->save_modes[2] = termw->flags & SMOOTHSCROLL;
+ break;
+ case 5: /* DECSCNM */
+ screen->save_modes[3] = termw->flags & REVERSE_VIDEO;
+ break;
+ case 6: /* DECOM */
+ screen->save_modes[4] = termw->flags & ORIGIN;
+ break;
+
+ case 7: /* DECAWM */
+ screen->save_modes[5] = termw->flags & WRAPAROUND;
+ break;
+ case 8: /* DECARM */
+ /* ignore autorepeat */
+ break;
+ case 9: /* mouse bogus sequence */
+ screen->save_modes[7] = screen->send_mouse_pos;
+ break;
+ case 40: /* 132 column mode */
+ screen->save_modes[8] = screen->c132;
+ break;
+ case 41: /* curses hack */
+ screen->save_modes[9] = screen->curses;
+ break;
+ case 44: /* margin bell */
+ screen->save_modes[12] = screen->marginbell;
+ break;
+ case 45: /* reverse wraparound */
+ screen->save_modes[13] = termw->flags & REVERSEWRAP;
+ break;
+#ifdef ALLOWLOGGING
+ case 46: /* logging */
+ screen->save_modes[14] = screen->logging;
+ break;
+#endif
+ case 47: /* alternate buffer */
+ screen->save_modes[15] = screen->alternate;
+ break;
+ case 1000: /* mouse bogus sequence */
+ case 1001:
+ screen->save_modes[7] = screen->send_mouse_pos;
+ break;
+ }
+ }
+}
+
+/*
+ * process xgterm private modes restore
+ */
+restoremodes(termw)
+ XgtermWidget termw;
+{
+ register TScreen *screen = &termw->screen;
+ register int i, j;
+
+ for (i = 0; i < nparam; i++) {
+ switch (param[i]) {
+ case 1: /* DECCKM */
+ termw->keyboard.flags &= ~CURSOR_APL;
+ termw->keyboard.flags |= screen->save_modes[0] &
+ CURSOR_APL;
+ update_appcursor();
+ break;
+ case 3: /* DECCOLM */
+ if(screen->c132) {
+ ClearScreen(screen);
+ CursorSet(screen, 0, 0, termw->flags);
+ if((j = (screen->save_modes[1] & IN132COLUMNS)
+ ? 132 : 80) != ((termw->flags & IN132COLUMNS)
+ ? 132 : 80) || j != screen->max_col + 1) {
+ Dimension replyWidth, replyHeight;
+ XtGeometryResult status;
+ status = XtMakeResizeRequest (
+ (Widget) termw,
+ (Dimension) FontWidth(screen) * j
+ + 2*screen->border
+ + screen->scrollbar,
+ (Dimension) FontHeight(screen)
+ * (screen->max_row + 1)
+ + 2*screen->border,
+ &replyWidth, &replyHeight);
+
+ if (status == XtGeometryYes ||
+ status == XtGeometryDone) {
+ ScreenResize (&termw->screen,
+ replyWidth,
+ replyHeight,
+ &termw->flags);
+ }
+ }
+ termw->flags &= ~IN132COLUMNS;
+ termw->flags |= screen->save_modes[1] &
+ IN132COLUMNS;
+ }
+ break;
+ case 4: /* DECSCLM (slow scroll) */
+ if (screen->save_modes[2] & SMOOTHSCROLL) {
+ screen->jumpscroll = 0;
+ if (screen->scroll_amt)
+ FlushScroll(screen);
+ } else
+ screen->jumpscroll = 1;
+ termw->flags &= ~SMOOTHSCROLL;
+ termw->flags |= screen->save_modes[2] & SMOOTHSCROLL;
+ update_jumpscroll();
+ break;
+ case 5: /* DECSCNM */
+ if((screen->save_modes[3] ^ termw->flags) & REVERSE_VIDEO) {
+ termw->flags &= ~REVERSE_VIDEO;
+ termw->flags |= screen->save_modes[3] & REVERSE_VIDEO;
+ ReverseVideo(termw);
+ /* update_reversevideo done in RevVid */
+ }
+ break;
+ case 6: /* DECOM */
+ termw->flags &= ~ORIGIN;
+ termw->flags |= screen->save_modes[4] & ORIGIN;
+ CursorSet(screen, 0, 0, termw->flags);
+ break;
+
+ case 7: /* DECAWM */
+ termw->flags &= ~WRAPAROUND;
+ termw->flags |= screen->save_modes[5] & WRAPAROUND;
+ update_autowrap();
+ break;
+ case 8: /* DECARM */
+ /* ignore autorepeat */
+ break;
+ case 9: /* MIT bogus sequence */
+ screen->send_mouse_pos = screen->save_modes[7];
+ break;
+ case 40: /* 132 column mode */
+ screen->c132 = screen->save_modes[8];
+ update_allow132();
+ break;
+ case 41: /* curses hack */
+ screen->curses = screen->save_modes[9];
+ update_cursesemul();
+ break;
+ case 44: /* margin bell */
+ if(!(screen->marginbell = screen->save_modes[12]))
+ screen->bellarmed = -1;
+ update_marginbell();
+ break;
+ case 45: /* reverse wraparound */
+ termw->flags &= ~REVERSEWRAP;
+ termw->flags |= screen->save_modes[13] & REVERSEWRAP;
+ update_reversewrap();
+ break;
+#ifdef ALLOWLOGGING
+ case 46: /* logging */
+#ifdef ALLOWLOGFILEONOFF
+ if(screen->save_modes[14])
+ StartLog(screen);
+ else
+ CloseLog(screen);
+#endif /* ALLOWLOGFILEONOFF */
+ /* update_logging done by StartLog and CloseLog */
+ break;
+#endif
+ case 47: /* alternate buffer */
+ if (!termw->misc.titeInhibit) {
+ if(screen->save_modes[15])
+ ToAlternate(screen);
+ else
+ FromAlternate(screen);
+ /* update_altscreen done by ToAlt and FromAlt */
+ }
+ break;
+ case 1000: /* mouse bogus sequence */
+ case 1001:
+ screen->send_mouse_pos = screen->save_modes[7];
+ break;
+ }
+ }
+}
+
+/*
+ * set a bit in a word given a pointer to the word and a mask.
+ */
+static void bitset(p, mask)
+ unsigned *p;
+ int mask;
+{
+ *p |= mask;
+}
+
+/*
+ * clear a bit in a word given a pointer to the word and a mask.
+ */
+static void bitclr(p, mask)
+ unsigned *p;
+ int mask;
+{
+ *p &= ~mask;
+}
+
+unparseseq(ap, fd)
+ register ANSI *ap;
+ int fd;
+{
+ register int c;
+ register int i;
+ register int inters;
+
+ c = ap->a_type;
+ if (c>=0x80 && c<=0x9F) {
+ unparseputc(ESC, fd);
+ c -= 0x40;
+ }
+ unparseputc(c, fd);
+ c = ap->a_type;
+ if (c==ESC || c==DCS || c==CSI || c==OSC || c==PM || c==APC) {
+ if (ap->a_pintro != 0)
+ unparseputc((char) 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);
+ }
+ inters = ap->a_inters;
+ for (i=3; i>=0; --i) {
+ c = (inters >> (8*i)) & 0xff;
+ if (c != 0)
+ unparseputc(c, fd);
+ }
+ unparseputc((char) ap->a_final, fd);
+ }
+}
+
+unparseputn(n, fd)
+unsigned int n;
+int fd;
+{
+ unsigned int q;
+
+ q = n/10;
+ if (q != 0)
+ unparseputn(q, fd);
+ unparseputc((char) ('0' + (n%10)), fd);
+}
+
+unparseputc(c, fd)
+char c;
+int fd;
+{
+ char buf[2];
+ register i = 1;
+ extern XgtermWidget term;
+
+ if((buf[0] = c) == '\r' && (term->flags & LINEFEED)) {
+ buf[1] = '\n';
+ i++;
+ }
+ v_write(fd, buf, i);
+}
+
+unparsefputs (s, fd)
+ register char *s;
+ int fd;
+{
+ if (s) {
+ while (*s) unparseputc (*s++, fd);
+ }
+}
+
+static void SwitchBufs();
+
+static void
+ToAlternate(screen)
+register TScreen *screen;
+{
+ extern ScrnBuf Allocate();
+
+ if(screen->alternate)
+ return;
+ if(!screen->altbuf)
+ screen->altbuf = Allocate(screen->max_row + 1, screen->max_col
+ + 1, &screen->abuf_address);
+ SwitchBufs(screen);
+ screen->alternate = TRUE;
+ update_altscreen();
+}
+
+static void
+FromAlternate(screen)
+register TScreen *screen;
+{
+ if(!screen->alternate)
+ return;
+ screen->alternate = FALSE;
+ SwitchBufs(screen);
+ update_altscreen();
+}
+
+static void
+SwitchBufs(screen)
+ register TScreen *screen;
+{
+ register int rows, top;
+
+ if(screen->cursor_state)
+ HideCursor();
+ rows = screen->max_row + 1;
+ SwitchBufPtrs(screen);
+ TrackText(0, 0, 0, 0); /* remove any highlighting */
+ if((top = -screen->topline) <= screen->max_row) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ if(top == 0)
+ XClearWindow(screen->display, TextWindow(screen));
+ else
+ if (term->misc.sb_right) {
+ XClearArea(
+ screen->display,
+ TextWindow(screen),
+ (int) screen->border,
+ (int) top * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) (screen->max_row - top + 1)
+ * FontHeight(screen),
+ FALSE);
+ } else {
+ XClearArea(
+ screen->display,
+ TextWindow(screen),
+ (int) screen->border + screen->scrollbar,
+ (int) top * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) (screen->max_row - top + 1)
+ * FontHeight(screen),
+ FALSE);
+ }
+ }
+ ScrnRefresh(screen, 0, 0, rows, screen->max_col + 1, False);
+}
+
+/* swap buffer line pointers between alt and regular screens */
+
+SwitchBufPtrs(screen)
+ register TScreen *screen;
+{
+ register int rows = screen->max_row + 1;
+ char *save [4 * MAX_ROWS];
+
+ memmove( (char *)save, (char *)screen->buf, 4 * sizeof(char *) * rows);
+ memmove( (char *)screen->buf, (char *)screen->altbuf,
+ 4 * sizeof(char *) * rows);
+ memmove( (char *)screen->altbuf, (char *)save, 4 * sizeof(char *) * rows);
+}
+
+VTRun()
+{
+ register TScreen *screen = &term->screen;
+ register int i;
+
+ XtRealizeWidget (term->core.parent);
+ if (!screen->TekEmu)
+ set_vt_visibility (TRUE);
+/*
+ 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;
+
+ bcnt = 0;
+ bptr = buffer;
+ while(Tpushb > Tpushback) {
+ *bptr++ = *--Tpushb;
+ bcnt++;
+ }
+ bcnt += (i = Tbcnt);
+ for( ; i > 0 ; i--)
+ *bptr++ = *Tbptr++;
+ bptr = buffer;
+ if(!setjmp(VTend))
+ VTparse();
+ HideCursor();
+ screen->cursor_set = OFF;
+}
+
+/*ARGSUSED*/
+static void VTExpose(w, event, region)
+ Widget w;
+ XEvent *event;
+ Region region;
+{
+ register TScreen *screen = &term->screen;
+
+#ifdef DEBUG
+ if(debug)
+ fputs("Expose\n", stderr);
+#endif /* DEBUG */
+ if (event->type == Expose)
+ HandleExposure (screen, event);
+}
+
+static void VTGraphicsOrNoExpose (event)
+ XEvent *event;
+{
+ register 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 (w, closure, event, cont)
+Widget w; /* unused */
+XtPointer closure; /* unused */
+XEvent *event;
+Boolean *cont; /* unused */
+{
+ switch (event->type) {
+ case GraphicsExpose:
+ case NoExpose:
+ VTGraphicsOrNoExpose (event);
+ break;
+ }
+}
+
+
+
+
+static void VTResize(w)
+ Widget w;
+{
+ if (XtIsRealized(w))
+ ScreenResize (&term->screen, term->core.width, term->core.height,
+ &term->flags);
+}
+
+
+extern Atom wm_delete_window; /* for ICCCM delete window */
+
+static String xgterm_trans =
+ "<ClientMessage>WM_PROTOCOLS: DeleteWindow()\n\
+ <MappingNotify>: KeyboardMapping()\n";
+
+int VTInit ()
+{
+ register TScreen *screen = &term->screen;
+ Widget vtparent = term->core.parent;
+
+ XtRealizeWidget (vtparent);
+ XtOverrideTranslations(vtparent, XtParseTranslationTable(xgterm_trans));
+ (void) XSetWMProtocols (XtDisplay(vtparent), XtWindow(vtparent),
+ &wm_delete_window, 1);
+
+ if (screen->allbuf == NULL) VTallocbuf ();
+ return (1);
+}
+
+static void VTallocbuf ()
+{
+ register TScreen *screen = &term->screen;
+ int nrows = screen->max_row + 1;
+ extern ScrnBuf Allocate();
+
+ /* allocate screen buffer now, if necessary. */
+ if (screen->scrollWidget)
+ nrows += screen->savelines;
+ screen->allbuf = Allocate (nrows, screen->max_col + 1,
+ &screen->sbuf_address);
+ if (screen->scrollWidget)
+ screen->buf = &screen->allbuf[4 * screen->savelines];
+ else
+ screen->buf = screen->allbuf;
+ return;
+}
+
+static void VTClassInit ()
+{
+ XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity,
+ (XtConvertArgList) NULL, (Cardinal) 0);
+}
+
+
+/* ARGSUSED */
+static void VTInitialize (wrequest, wnew, args, num_args)
+ Widget wrequest, wnew;
+ ArgList args;
+ Cardinal *num_args;
+{
+ XgtermWidget request = (XgtermWidget) wrequest;
+ XgtermWidget new = (XgtermWidget) wnew;
+ int i;
+
+ /* Zero out the entire "screen" component of "new" widget,
+ then do field-by-field assigment of "screen" fields
+ that are named in the resource list. */
+
+ memset ((char *) &new->screen, 0, sizeof(new->screen));
+ new->screen.c132 = request->screen.c132;
+ new->screen.curses = request->screen.curses;
+ new->screen.hp_ll_bc = request->screen.hp_ll_bc;
+ new->screen.foreground = request->screen.foreground;
+ new->screen.cursorcolor = request->screen.cursorcolor;
+ new->screen.border = request->screen.border;
+ new->screen.jumpscroll = request->screen.jumpscroll;
+#ifdef ALLOWLOGGING
+ new->screen.logfile = request->screen.logfile;
+#endif
+ new->screen.marginbell = request->screen.marginbell;
+ new->screen.mousecolor = request->screen.mousecolor;
+ new->screen.mousecolorback = request->screen.mousecolorback;
+ new->screen.multiscroll = request->screen.multiscroll;
+ new->screen.nmarginbell = request->screen.nmarginbell;
+ new->screen.savelines = request->screen.savelines;
+ new->screen.scrolllines = request->screen.scrolllines;
+ new->screen.scrollttyoutput = request->screen.scrollttyoutput;
+ new->screen.scrollkey = request->screen.scrollkey;
+ new->screen.underline = request->screen.underline;
+ new->screen.visualbell = request->screen.visualbell;
+ new->screen.TekEmu = request->screen.TekEmu;
+ new->misc.re_verse = request->misc.re_verse;
+ new->screen.multiClickTime = request->screen.multiClickTime;
+ new->screen.bellSuppressTime = request->screen.bellSuppressTime;
+ new->screen.charClass = request->screen.charClass;
+ new->screen.cutNewline = request->screen.cutNewline;
+ new->screen.cutToBeginningOfLine = request->screen.cutToBeginningOfLine;
+ new->screen.always_highlight = request->screen.always_highlight;
+ new->screen.pointer_cursor = request->screen.pointer_cursor;
+ new->screen.input_eight_bits = request->screen.input_eight_bits;
+ new->screen.output_eight_bits = request->screen.output_eight_bits;
+ new->screen.allowSendEvents = request->screen.allowSendEvents;
+ new->misc.titeInhibit = request->misc.titeInhibit;
+ for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) {
+ new->screen.menu_font_names[i] = request->screen.menu_font_names[i];
+ }
+ /* set default in realize proc */
+ new->screen.menu_font_names[fontMenu_fontdefault] = NULL;
+ new->screen.menu_font_names[fontMenu_fontescape] = NULL;
+ new->screen.menu_font_names[fontMenu_fontsel] = NULL;
+ new->screen.menu_font_number = fontMenu_fontdefault;
+
+ for (i = 0; i < MAXCOLORS; i++) {
+ new->screen.colors[i] = request->screen.colors[i];
+ }
+
+ /*
+ * The definition of -rv now is that it changes the definition of
+ * XtDefaultForeground and XtDefaultBackground. So, we no longer
+ * need to do anything special.
+ */
+ new->keyboard.flags = 0;
+ new->screen.display = new->core.screen->display;
+ new->core.height = new->core.width = 1;
+ /* 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 xgtermWidget's Realize proc,
+ but the shell's Realize proc is called first, and must see
+ a valid size. */
+
+ /* look for focus related events on the shell, because we need
+ * to care about the shell's border being part of our focus.
+ */
+ XtAddEventHandler(XtParent(new), FocusChangeMask, FALSE,
+ HandleFocusChange, (Opaque)NULL);
+ XtAddEventHandler((Widget)new, 0L, TRUE,
+ VTNonMaskableEvent, (Opaque)NULL);
+ XtAddEventHandler((Widget)new, PropertyChangeMask, FALSE,
+ HandleBellPropertyChange, (Opaque)NULL);
+
+ /* These apply to vt100 window events. */
+ XtAddEventHandler (wnew, EnterWindowMask, FALSE, HandleEnterWindow,
+ (Opaque)NULL);
+ XtAddEventHandler (wnew, LeaveWindowMask, FALSE, HandleLeaveWindow,
+ (Opaque)NULL);
+
+ new->screen.bellInProgress = FALSE;
+ set_character_class (new->screen.charClass);
+
+ /* create it, but don't realize it */
+ ScrollBarOn (new, TRUE, FALSE);
+
+ /* make sure that the resize gravity acceptable */
+ if ( new->misc.resizeGravity != NorthWestGravity &&
+ new->misc.resizeGravity != SouthWestGravity) {
+ Cardinal nparams = 1;
+
+ XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XGtermError",
+ "unsupported resizeGravity resource value (%d)",
+ (String *) &(new->misc.resizeGravity), &nparams);
+ new->misc.resizeGravity = SouthWestGravity;
+ }
+
+ return;
+}
+
+
+static void VTDestroy (w)
+Widget w;
+{
+ XtFree(((XgtermWidget)w)->screen.selection);
+}
+
+/*ARGSUSED*/
+static void VTRealize (w, valuemask, values)
+ Widget w;
+ XtValueMask *valuemask;
+ XSetWindowAttributes *values;
+{
+ unsigned int width, height;
+ register TScreen *screen = &term->screen;
+ int xpos, ypos, pr;
+ XSizeHints sizehints;
+ int scrollbar_width;
+
+ TabReset (term->tabs);
+
+ screen->menu_font_names[fontMenu_fontdefault] = term->misc.f_n;
+ screen->fnt_norm = screen->fnt_bold = NULL;
+ if (!LoadNewFont(screen, term->misc.f_n, term->misc.f_b, False, 0)) {
+ if (XmuCompareISOLatin1(term->misc.f_n, "fixed") != 0) {
+ fprintf (stderr,
+ "%s: unable to open font \"%s\", trying \"fixed\"....\n",
+ xgterm_name, term->misc.f_n);
+ (void) LoadNewFont (screen, "fixed", NULL, False, 0);
+ screen->menu_font_names[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",
+ xgterm_name);
+ Exit (1);
+ }
+
+ /* making cursor */
+ if (!screen->pointer_cursor)
+ screen->pointer_cursor = make_colored_cursor(XC_xterm,
+ screen->mousecolor,
+ screen->mousecolorback);
+ else
+ recolor_cursor (screen->pointer_cursor,
+ screen->mousecolor, screen->mousecolorback);
+
+ scrollbar_width = (term->misc.scrollbar || term->misc.sb_right ?
+ screen->scrollWidget->core.width /* +
+ screen->scrollWidget->core.border_width */ : 0);
+
+ /* set defaults */
+ xpos = 1; ypos = 1; width = 80; height = 24;
+ pr = XParseGeometry (term->misc.geo_metry, &xpos, &ypos,
+ &width, &height);
+ screen->max_col = (width - 1); /* units in character cells */
+ screen->max_row = (height - 1); /* units in character cells */
+ update_font_info (&term->screen, False);
+
+ width = screen->fullVwin.fullwidth;
+ height = screen->fullVwin.fullheight;
+
+ if ((pr & XValue) && (XNegative&pr))
+ xpos += DisplayWidth(screen->display, DefaultScreen(screen->display))
+ - width - (term->core.parent->core.border_width * 2);
+ if ((pr & YValue) && (YNegative&pr))
+ ypos += DisplayHeight(screen->display,DefaultScreen(screen->display))
+ - height - (term->core.parent->core.border_width * 2);
+
+ /* set up size hints for window manager; min 1 char by 1 char */
+ sizehints.base_width = 2 * screen->border + scrollbar_width;
+ sizehints.base_height = 2 * screen->border;
+ 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.flags = (PBaseSize|PMinSize|PResizeInc);
+ 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.width = width;
+ sizehints.height = height;
+ if ((WidthValue&pr) || (HeightValue&pr))
+ sizehints.flags |= USSize;
+ else sizehints.flags |= PSize;
+
+ (void) XtMakeResizeRequest((Widget) term,
+ (Dimension)width, (Dimension)height,
+ &term->core.width, &term->core.height);
+
+ /* XXX This is bogus. We are parsing geometries too late. This
+ * is information that the shell widget ought to have before we get
+ * realized, so that it can do the right thing.
+ */
+ if (sizehints.flags & USPosition)
+ XMoveWindow (XtDisplay(term), term->core.parent->core.window,
+ sizehints.x, sizehints.y);
+
+ XSetWMNormalHints (XtDisplay(term), term->core.parent->core.window,
+ &sizehints);
+ XFlush (XtDisplay(term)); /* get it out to window manager */
+
+ /* use ForgetGravity instead of SouthWestGravity because translating
+ the Expose events for ConfigureNotifys is too hard */
+ values->bit_gravity = term->misc.resizeGravity == NorthWestGravity ?
+ NorthWestGravity : ForgetGravity;
+ term->screen.fullVwin.window = term->core.window =
+ XCreateWindow(XtDisplay(term), XtWindow(term->core.parent),
+ term->core.x, term->core.y,
+ term->core.width, term->core.height, term->core.border_width,
+ (int) term->core.depth,
+ InputOutput, CopyFromParent,
+ *valuemask|CWBitGravity, values);
+
+/*
+#ifdef I18N
+ VTInitI18N();
+#endif
+*/
+
+ set_cursor_gcs (screen);
+
+ /* Reset variables used by ANSI emulation. */
+
+ screen->gsets[0] = 'B'; /* ASCII_G */
+ screen->gsets[1] = 'B';
+ screen->gsets[2] = 'B'; /* DEC supplemental. */
+ screen->gsets[3] = 'B';
+ screen->curgl = 0; /* G0 => GL. */
+ screen->curgr = 2; /* G2 => GR. */
+ screen->curss = 0; /* No single shift. */
+
+ XDefineCursor(screen->display, VShellWindow, screen->pointer_cursor);
+
+ screen->cur_col = screen->cur_row = 0;
+ screen->max_col = Width(screen)/screen->fullVwin.f_width - 1;
+ screen->top_marg = 0;
+ screen->bot_marg = screen->max_row = Height(screen) /
+ screen->fullVwin.f_height - 1;
+
+ screen->sc.row = screen->sc.col = screen->sc.flags = 0;
+
+ /* 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. */
+ screen->buf = screen->allbuf = NULL;
+
+ screen->do_wrap = 0;
+ screen->scrolls = screen->incopy = 0;
+ set_vt_box (screen);
+
+ screen->savedlines = 0;
+
+ if (term->misc.scrollbar || term->misc.sb_right ) {
+ screen->scrollbar = 0;
+ ScrollBarOn (term, FALSE, TRUE);
+ }
+ CursorSave (term, &screen->sc);
+ return;
+}
+
+#ifdef I18N
+
+static void VTInitI18N()
+{
+ int i,
+ ic_cnt = 0;
+ char *p,
+ *s,
+ *ns,
+ *end,
+ tmp[1024],
+ buf[32];
+ XIM xim;
+ XIMStyles *xim_styles;
+ XIMStyle input_style;
+ Boolean found;
+
+ term->screen.xic = NULL;
+
+ if (!term->misc.open_im) return;
+
+ if (term->misc.input_method) {
+ strcpy(tmp, term->misc.input_method);
+ for(s=tmp; *s;) {
+ while (*s && isspace(*s)) s++;
+ if (!*s) break;
+ if (!(ns = end = index(s, ',')))
+ end = s + strlen(s);
+ while (isspace(*end)) end--;
+ *end = '\0';
+
+ strcpy(buf, "@im=");
+ strcat(buf, s);
+ if ((p = XSetLocaleModifiers(buf)) != NULL && *p
+ && (xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL)) != NULL)
+ break;
+
+ s = ns + 1;
+ }
+ } else {
+ if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
+ xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL);
+ }
+
+ if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL && *p)
+ xim = XOpenIM(XtDisplay(term), NULL, NULL, NULL);
+
+ if (!xim) {
+ fprintf(stderr, "Failed to open input method");
+ return;
+ }
+
+ if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)
+ || !xim_styles) {
+ fprintf(stderr, "input method doesn't support any style\n");
+ XCloseIM(xim);
+ return;
+ }
+
+ found = False;
+ strcpy(tmp, term->misc.preedit_type);
+ for(s = tmp; s && !found;) {
+ while (*s && isspace(*s)) s++;
+ if (!*s) break;
+ if (ns = end = index(s, ','))
+ ns++;
+ else
+ end = s + strlen(s);
+ while (isspace(*end)) end--;
+ *end = '\0';
+
+ if (!strcmp(s, "OverTheSpot")) {
+ input_style = (XIMPreeditPosition | XIMStatusArea);
+ } else if (!strcmp(s, "OffTheSpot")) {
+ input_style = (XIMPreeditArea | XIMStatusArea);
+ } else if (!strcmp(s, "Root")) {
+ input_style = (XIMPreeditNothing | XIMStatusNothing);
+ }
+ for (i = 0; (unsigned short)i < xim_styles->count_styles; i++)
+ if (input_style == xim_styles->supported_styles[i]) {
+ found = True;
+ break;
+ }
+
+ s = ns;
+ }
+ XFree(xim_styles);
+
+ if (!found) {
+ fprintf(stderr, "input method doesn't support my preedit type\n");
+ XCloseIM(xim);
+ return;
+ }
+
+ /*
+ * This program only understands the Root preedit_style yet
+ * Then misc.preedit_type should default to:
+ * "OverTheSpot,OffTheSpot,Root"
+ *
+ * /MaF
+ */
+ if (input_style != (XIMPreeditNothing | XIMStatusNothing)) {
+ fprintf(stderr,"This program only supports the 'Root' preedit type\n");
+ XCloseIM(xim);
+ return;
+ }
+
+ term->screen.xic = XCreateIC(xim, XNInputStyle, input_style,
+ XNClientWindow, term->core.window,
+ XNFocusWindow, term->core.window,
+ NULL);
+
+ if (!term->screen.xic) {
+ fprintf(stderr,"Failed to create input context\n");
+ XCloseIM(xim);
+ }
+
+ return;
+}
+
+#endif
+
+
+static Boolean VTSetValues (cur, request, new, args, num_args)
+ Widget cur, request, new;
+ ArgList args;
+ Cardinal *num_args;
+{
+ XgtermWidget curvt = (XgtermWidget) cur;
+ XgtermWidget newvt = (XgtermWidget) new;
+ Boolean refresh_needed = FALSE;
+ Boolean fonts_redone = FALSE;
+
+ if(curvt->core.background_pixel != newvt->core.background_pixel
+ || curvt->screen.foreground != newvt->screen.foreground
+ || curvt->screen.menu_font_names[curvt->screen.menu_font_number]
+ != newvt->screen.menu_font_names[newvt->screen.menu_font_number]
+ || curvt->misc.f_n != newvt->misc.f_n) {
+ if(curvt->misc.f_n != newvt->misc.f_n)
+ newvt->screen.menu_font_names[fontMenu_fontdefault] = newvt->misc.f_n;
+ if (LoadNewFont(&newvt->screen,
+ newvt->screen.menu_font_names[curvt->screen.menu_font_number],
+ newvt->screen.menu_font_names[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.f_n != newvt->misc.f_n)
+ newvt->screen.menu_font_names[fontMenu_fontdefault] = curvt->misc.f_n;
+ }
+ if(!fonts_redone
+ && curvt->screen.cursorcolor != newvt->screen.cursorcolor) {
+ 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(curvt->screen.mousecolor != newvt->screen.mousecolor
+ || curvt->screen.mousecolorback != newvt->screen.mousecolorback) {
+ recolor_cursor (newvt->screen.pointer_cursor,
+ newvt->screen.mousecolor,
+ newvt->screen.mousecolorback);
+ refresh_needed = TRUE;
+ }
+ if ((curvt->misc.scrollbar != newvt->misc.scrollbar) &&
+ (curvt->misc.sb_right != newvt->misc.sb_right)) {
+ if (newvt->misc.scrollbar || newvt->misc.sb_right) {
+ ScrollBarOn (newvt, FALSE, FALSE);
+ } else {
+ ScrollBarOff (&newvt->screen);
+ }
+ update_scrollbar();
+ }
+
+ return refresh_needed;
+}
+
+/*
+ * Shows cursor at new cursor position in screen.
+ */
+ShowCursor()
+{
+ register TScreen *screen = &term->screen;
+ register int x, y, flags;
+ Char c;
+ GC currentGC;
+ Boolean in_selection;
+
+ if (eventMode != NORMAL) return;
+
+ if (screen->cur_row - screen->topline > screen->max_row)
+ return;
+ c = screen->buf[y = 4 * (screen->cursor_row = screen->cur_row)]
+ [x = screen->cursor_col = screen->cur_col];
+ flags = screen->buf[y + 1][x];
+ if (c == 0)
+ c = ' ';
+
+ if (screen->cur_row > screen->endHRow ||
+ (screen->cur_row == screen->endHRow &&
+ screen->cur_col >= screen->endHCol) ||
+ screen->cur_row < screen->startHRow ||
+ (screen->cur_row == screen->startHRow &&
+ screen->cur_col < screen->startHCol))
+ in_selection = False;
+ else
+ in_selection = True;
+
+ if(screen->select || screen->always_highlight) {
+ if (( (flags & INVERSE) && !in_selection) ||
+ (!(flags & INVERSE) && in_selection)){
+ /* text is reverse video */
+ if (screen->cursorGC) {
+ currentGC = screen->cursorGC;
+ } else {
+ if (flags & BOLD) {
+ currentGC = screen->normalboldGC;
+ } else {
+ currentGC = screen->normalGC;
+ }
+ }
+ } else { /* normal video */
+ if (screen->reversecursorGC) {
+ currentGC = screen->reversecursorGC;
+ } else {
+ if (flags & BOLD) {
+ currentGC = screen->reverseboldGC;
+ } else {
+ currentGC = screen->reverseGC;
+ }
+ }
+ }
+#if 0
+ /*RFB*/
+ if ( flags & BG_COLOR )
+ XSetForeground( screen->display, currentGC,
+ screen->colors[ term->cur_background ]);
+ if ( flags & FG_COLOR )
+ XSetBackground( screen->display, currentGC,
+ screen->colors[ term->cur_foreground ]);
+ /**********************************************************/
+ /* */
+ /* we test "flags and background" before calling */
+ /* XSetForeground; */
+ /* */
+ /* it looks funny, but we're in reverse video and the */
+ /* color we're setting it to is the current background */
+ /* color! */
+ /* */
+ /**********************************************************/
+ /*RFB*/
+#endif
+ } else { /* not selected */
+ if (( (flags & INVERSE) && !in_selection) ||
+ (!(flags & INVERSE) && in_selection)) {
+ /* text is reverse video */
+ currentGC = screen->reverseGC;
+ } else { /* normal video */
+ currentGC = screen->normalGC;
+ }
+#if 0
+ /*RFB*/
+ if ( flags & FG_COLOR )
+ XSetForeground( screen->display, currentGC,
+ screen->colors[ term->cur_foreground ]);
+ if ( flags & BG_COLOR )
+ XSetBackground( screen->display, currentGC,
+ screen->colors[ term->cur_background ]);
+ /*RFB*/
+#endif
+ }
+
+ x = CursorX (screen, screen->cur_col);
+ y = CursorY(screen, screen->cur_row) +
+ screen->fnt_norm->ascent;
+ XDrawImageString(screen->display, TextWindow(screen), currentGC,
+ x, y, (char *) &c, 1);
+
+ if((flags & BOLD) && screen->enbolden) /* no bold font */
+ XDrawString(screen->display, TextWindow(screen), currentGC,
+ x + 1, y, (char *) &c, 1);
+ if((flags & UNDERLINE) && screen->underline)
+ XDrawLine(screen->display, TextWindow(screen), currentGC,
+ x, y+1, x + FontWidth(screen), y+1);
+ if (!screen->select && !screen->always_highlight) {
+ screen->box->x = x;
+ screen->box->y = y - screen->fnt_norm->ascent;
+ XDrawLines (screen->display, TextWindow(screen),
+ screen->cursoroutlineGC ? screen->cursoroutlineGC
+ : currentGC,
+ screen->box, NBOX, CoordModePrevious);
+ }
+ screen->cursor_state = ON;
+}
+
+/*
+ * hide cursor at previous cursor position in screen.
+ */
+HideCursor()
+{
+ register TScreen *screen = &term->screen;
+ GC currentGC;
+ register int x, y, flags, fg, bg;
+ register Pixel fg_pix, bg_pix;
+ char c;
+ Boolean in_selection;
+
+ if(screen->cursor_row - screen->topline > screen->max_row)
+ return;
+ c = screen->buf[y = 4 * screen->cursor_row][x = screen->cursor_col];
+ flags = screen->buf[y + 1][x];
+ fg = screen->buf[y + 2][x];
+ bg = screen->buf[y + 3][x];
+
+ fg_pix = (flags&FG_COLOR) ? screen->colors[fg] :
+ screen->foreground;
+ bg_pix = (flags&BG_COLOR) ? screen->colors[bg] :
+ term->core.background_pixel;
+
+ if (screen->cursor_row > screen->endHRow ||
+ (screen->cursor_row == screen->endHRow &&
+ screen->cursor_col >= screen->endHCol) ||
+ screen->cursor_row < screen->startHRow ||
+ (screen->cursor_row == screen->startHRow &&
+ screen->cursor_col < screen->startHCol))
+ in_selection = False;
+ else
+ in_selection = True;
+
+ if (( (flags & INVERSE) && !in_selection) ||
+ (!(flags & INVERSE) && in_selection)) {
+ if(flags & BOLD)
+ currentGC = screen->reverseboldGC;
+ else
+ currentGC = screen->reverseGC;
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, currentGC, bg_pix);
+ XSetBackground(screen->display, currentGC, fg_pix);
+ }
+ } else {
+ if(flags & BOLD)
+ currentGC = screen->normalboldGC;
+ else
+ currentGC = screen->normalGC;
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, currentGC, fg_pix);
+ XSetBackground(screen->display, currentGC, bg_pix);
+ }
+ }
+
+ if (c == 0)
+ c = ' ';
+ x = CursorX (screen, screen->cursor_col);
+ y = (((screen->cursor_row - screen->topline) * FontHeight(screen))) +
+ screen->border;
+ y = y+screen->fnt_norm->ascent;
+ XDrawImageString(screen->display, TextWindow(screen), currentGC,
+ x, y, &c, 1);
+ if((flags & BOLD) && screen->enbolden)
+ XDrawString(screen->display, TextWindow(screen), currentGC,
+ x + 1, y, &c, 1);
+ if((flags & UNDERLINE) && screen->underline)
+ XDrawLine(screen->display, TextWindow(screen), currentGC,
+ x, y+1, x + FontWidth(screen), y+1);
+ screen->cursor_state = OFF;
+}
+
+VTReset(full)
+ Boolean full;
+{
+ register TScreen *screen = &term->screen;
+
+ /* reset scrolling region */
+ screen->top_marg = 0;
+ screen->bot_marg = screen->max_row;
+ term->flags &= ~ORIGIN;
+ if(full) {
+ TabReset (term->tabs);
+ term->keyboard.flags = 0;
+ update_appcursor();
+ update_appkeypad();
+ screen->gsets[0] = 'B';
+ screen->gsets[1] = 'B';
+ screen->gsets[2] = 'B';
+ screen->gsets[3] = 'B';
+ screen->curgl = 0;
+ screen->curgr = 2;
+ screen->curss = 0;
+ 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 junk;
+
+ if (term->misc.sb_right) {
+ XtMakeResizeRequest(
+ (Widget) term,
+ (Dimension) 80*FontWidth(screen)
+ + 2 * screen->border,
+ (Dimension) FontHeight(screen)
+ * (screen->max_row + 1) + 2 * screen->border,
+ &junk, &junk);
+ } else {
+ XtMakeResizeRequest(
+ (Widget) term,
+ (Dimension) 80*FontWidth(screen)
+ + 2 * screen->border + screen->scrollbar,
+ (Dimension) FontHeight(screen)
+ * (screen->max_row + 1) + 2 * screen->border,
+ &junk, &junk);
+ }
+ XSync(screen->display, FALSE); /* synchronize */
+ if(XtAppPending(app_con))
+ xevents();
+ }
+ CursorSet(screen, 0, 0, term->flags);
+ }
+ 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.
+ */
+
+int set_character_class (s)
+ register char *s;
+{
+ register 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";
+ extern char *ProgramName;
+
+ 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(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ 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];
+
+ if (*param_count != 1) return;
+
+ if (original == NULL) original = w->core.tm.translations;
+
+ if (strcmp(params[0], "None") == 0) {
+ XtOverrideTranslations(w, original);
+ return;
+ }
+ (void) sprintf( mapName, "%sKeymap", params[0] );
+ (void) strcpy( mapClass, mapName );
+ if (islower(mapClass[0])) mapClass[0] = toupper(mapClass[0]);
+ XtGetSubresources( w, (XtPointer)&keymap, mapName, mapClass,
+ key_resources, (Cardinal)1, NULL, (Cardinal)0 );
+ if (keymap != NULL)
+ XtOverrideTranslations(w, keymap);
+}
+
+
+/* ARGSUSED */
+static void HandleBell(w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* [0] = volume */
+ Cardinal *param_count; /* 0 or 1 */
+{
+ int percent = (*param_count) ? atoi(params[0]) : 0;
+
+ XBell( XtDisplay(w), percent );
+}
+
+
+/* ARGSUSED */
+static void HandleVisualBell(w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* unused */
+ Cardinal *param_count; /* unused */
+{
+ VisualBell();
+}
+
+
+/* ARGSUSED */
+static void HandleIgnore(w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* unused */
+ Cardinal *param_count; /* unused */
+{
+ /* do nothing, but check for funny escape sequences */
+ (void) SendMousePosition(w, event);
+}
+
+
+/* ARGSUSED */
+static void
+DoSetSelectedFont(w, client_data, selection, type, value, length, format)
+ Widget w;
+ XtPointer client_data;
+ Atom *selection, *type;
+ XtPointer value;
+ unsigned long *length;
+ int *format;
+{
+ char *val = (char *)value;
+ int len;
+ if (*type != XA_STRING || *format != 8) {
+ Bell();
+ 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 (!LoadNewFont (&term->screen, val, NULL, True, fontMenu_fontsel))
+ Bell();
+ }
+}
+
+void FindFontSelection (atom_name, justprobe)
+ 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.menu_font_names[fontMenu_fontsel] =
+ XGetSelectionOwner(XtDisplay(term), target) ? _Font_Selected_ : NULL;
+ } else {
+ XtGetSelectionValue((Widget)term, target, XA_STRING,
+ DoSetSelectedFont, NULL,
+ XtLastTimestampProcessed(XtDisplay(term)));
+ }
+ return;
+}
+
+
+/* ARGSUSED */
+void HandleSetFont(w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* unused */
+ Cardinal *param_count; /* unused */
+{
+ int fontnum;
+ char *name1 = NULL, *name2 = NULL;
+
+ if (*param_count == 0) {
+ fontnum = fontMenu_fontdefault;
+ } else {
+ int 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; maxparams = 3; break;
+ case 's': case 'S':
+ fontnum = fontMenu_fontsel; maxparams = 2; break;
+ default:
+ Bell();
+ return;
+ }
+ if (*param_count > maxparams) { /* see if extra args given */
+ Bell();
+ return;
+ }
+ switch (*param_count) { /* assign 'em */
+ case 3:
+ name2 = params[2];
+ /* fall through */
+ case 2:
+ name1 = params[1];
+ break;
+ }
+ }
+
+ SetVTFont (fontnum, True, name1, name2);
+}
+
+
+void SetVTFont (i, doresize, name1, name2)
+ int i;
+ Bool doresize;
+ char *name1, *name2;
+{
+ TScreen *screen = &term->screen;
+
+ if (i < 0 || i >= NMENUFONTS) {
+ Bell();
+ return;
+ }
+ if (i == fontMenu_fontsel) { /* go get the selection */
+ FindFontSelection (name1, False); /* name1 = atom, name2 is ignored */
+ return;
+ }
+ if (!name1) name1 = screen->menu_font_names[i];
+ if (!LoadNewFont(screen, name1, name2, doresize, i)) {
+ Bell();
+ }
+ return;
+}
+
+
+int LoadNewFont (screen, nfontname, bfontname, doresize, fontnum)
+ TScreen *screen;
+ char *nfontname, *bfontname;
+ Bool doresize;
+ int fontnum;
+{
+ XFontStruct *nfs = NULL, *bfs = NULL;
+ XGCValues xgcv;
+ unsigned long mask;
+ GC new_normalGC = NULL, new_normalboldGC = NULL;
+ GC new_reverseGC = NULL, new_reverseboldGC = NULL;
+ char *tmpname = NULL;
+
+ if (!nfontname) return 0;
+
+ if (fontnum == fontMenu_fontescape &&
+ nfontname != screen->menu_font_names[fontnum]) {
+ tmpname = (char *) malloc (strlen(nfontname) + 1);
+ if (!tmpname) return 0;
+ strcpy (tmpname, nfontname);
+ }
+
+ if (!(nfs = XLoadQueryFont (screen->display, nfontname))) goto bad;
+ if (nfs->ascent + nfs->descent == 0 || nfs->max_bounds.width == 0)
+ goto bad; /* can't use a 0-sized font */
+
+ if (!(bfontname &&
+ (bfs = XLoadQueryFont (screen->display, bfontname))))
+ bfs = nfs;
+ else
+ if (bfs->ascent + bfs->descent == 0 || bfs->max_bounds.width == 0)
+ goto bad; /* can't use a 0-sized font */
+
+ mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures |
+ GCFunction);
+
+ xgcv.font = nfs->fid;
+ xgcv.foreground = screen->foreground;
+ xgcv.background = term->core.background_pixel;
+ xgcv.graphics_exposures = TRUE; /* default */
+ xgcv.function = GXcopy;
+
+ new_normalGC = XtGetGC((Widget)term, 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)term, mask, &xgcv);
+ if (!new_normalboldGC) goto bad;
+ }
+
+ xgcv.font = nfs->fid;
+ xgcv.foreground = term->core.background_pixel;
+ xgcv.background = screen->foreground;
+ new_reverseGC = XtGetGC((Widget)term, 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)term, mask, &xgcv);
+ if (!new_reverseboldGC) goto bad;
+ }
+
+ if (screen->normalGC != screen->normalboldGC)
+ XtReleaseGC ((Widget) term, screen->normalboldGC);
+ XtReleaseGC ((Widget) term, screen->normalGC);
+ if (screen->reverseGC != screen->reverseboldGC)
+ XtReleaseGC ((Widget) term, screen->reverseboldGC);
+ XtReleaseGC ((Widget) term, screen->reverseGC);
+ screen->normalGC = new_normalGC;
+ screen->normalboldGC = new_normalboldGC;
+ screen->reverseGC = new_reverseGC;
+ screen->reverseboldGC = new_reverseboldGC;
+ screen->fnt_norm = nfs;
+ screen->fnt_bold = bfs;
+ screen->enbolden = (nfs == bfs);
+ set_menu_font (False);
+ screen->menu_font_number = fontnum;
+ set_menu_font (True);
+ if (tmpname) { /* if setting escape or sel */
+ if (screen->menu_font_names[fontnum])
+ free (screen->menu_font_names[fontnum]);
+ screen->menu_font_names[fontnum] = tmpname;
+ if (fontnum == fontMenu_fontescape) {
+ set_sensitivity (term->screen.fontMenu,
+ fontMenuEntries[fontMenu_fontescape].widget,
+ TRUE);
+ }
+ }
+ set_cursor_gcs (screen);
+ update_font_info (screen, doresize);
+ return 1;
+
+ bad:
+ if (tmpname) free (tmpname);
+ if (new_normalGC)
+ XtReleaseGC ((Widget) term, screen->normalGC);
+ if (new_normalGC && new_normalGC != new_normalboldGC)
+ XtReleaseGC ((Widget) term, new_normalboldGC);
+ if (new_reverseGC)
+ XtReleaseGC ((Widget) term, new_reverseGC);
+ if (new_reverseGC && new_reverseGC != new_reverseboldGC)
+ XtReleaseGC ((Widget) term, new_reverseboldGC);
+ if (nfs) XFreeFont (screen->display, nfs);
+ if (bfs && nfs != bfs) XFreeFont (screen->display, bfs);
+ return 0;
+}
+
+static void
+update_font_info (screen, doresize)
+ TScreen *screen;
+ Bool doresize;
+{
+ int i, j, width, height, scrollbar_width;
+
+ screen->fullVwin.f_width = screen->fnt_norm->max_bounds.width;
+ screen->fullVwin.f_height = (screen->fnt_norm->ascent +
+ screen->fnt_norm->descent);
+ scrollbar_width = (term->misc.scrollbar || term->misc.sb_right ?
+ screen->scrollWidget->core.width +
+ screen->scrollWidget->core.border_width : 0);
+ i = 2 * screen->border + scrollbar_width;
+ j = 2 * screen->border;
+ width = (screen->max_col + 1) * screen->fullVwin.f_width + i;
+ height = (screen->max_row + 1) * screen->fullVwin.f_height + j;
+ screen->fullVwin.fullwidth = width;
+ screen->fullVwin.fullheight = height;
+ screen->fullVwin.width = width - i;
+ screen->fullVwin.height = height - j;
+
+ if (doresize) {
+ if (VWindow(screen)) {
+ XClearWindow (screen->display, VWindow(screen));
+ }
+ DoResizeScreen (term); /* set to the new natural size */
+ if (screen->scrollWidget) {
+ if (term->misc.sb_right)
+ ResizeScrollBar (screen->scrollWidget,
+ screen->fullVwin.fullwidth -
+ screen->scrollWidget->core.width -
+ screen->scrollWidget->core.border_width, 0,
+ (Height(screen) + screen->border * 2)-1);
+ else
+ ResizeScrollBar (screen->scrollWidget, -1, -1,
+ Height(screen) + screen->border * 2);
+ }
+ Redraw ();
+ }
+ set_vt_box (screen);
+}
+
+set_vt_box (screen)
+ TScreen *screen;
+{
+ 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;
+}
+
+
+set_cursor_gcs (screen)
+ TScreen *screen;
+{
+ XGCValues xgcv;
+ unsigned long mask;
+ unsigned long cc = screen->cursorcolor;
+ unsigned long fg = screen->foreground;
+ unsigned long bg = term->core.background_pixel;
+ GC new_cursorGC = NULL, 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.
+ */
+
+ xgcv.font = screen->fnt_norm->fid;
+ mask = (GCForeground | GCBackground | GCFont);
+ if (cc != fg && cc != bg) {
+ /* we have a colored cursor */
+ xgcv.foreground = fg;
+ xgcv.background = cc;
+ new_cursorGC = 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);
+ }
+ } else {
+ new_cursorGC = (GC) 0;
+ new_reversecursorGC = (GC) 0;
+ new_cursoroutlineGC = (GC) 0;
+ }
+ if (screen->cursorGC) XtReleaseGC ((Widget)term, screen->cursorGC);
+ if (screen->reversecursorGC)
+ XtReleaseGC ((Widget)term, screen->reversecursorGC);
+ if (screen->cursoroutlineGC)
+ XtReleaseGC ((Widget)term, screen->cursoroutlineGC);
+ screen->cursorGC = new_cursorGC;
+ screen->reversecursorGC = new_reversecursorGC;
+ screen->cursoroutlineGC = new_cursoroutlineGC;
+}
diff --git a/vendor/x11iraf/xgterm/ctlseqs.ms b/vendor/x11iraf/xgterm/ctlseqs.ms
new file mode 100644
index 00000000..d5b7d740
--- /dev/null
+++ b/vendor/x11iraf/xgterm/ctlseqs.ms
@@ -0,0 +1,587 @@
+.\"#! troff -ms $1 -*- Nroff -*-
+.\" "Xterm Control Sequences" document
+.\" $XConsortium: ctlseqs.ms,v 1.8 91/07/21 15:30:31 gildea Exp $
+.\"
+.\" Copyright 1991 by the Massachusetts Institute of Technology
+.\"
+.\" Permission to use, copy, modify, and distribute this documentation
+.\" for any purpose and without fee is hereby granted, provided
+.\" that the above copyright notice appears in all copies,
+.\" and that the name of M.I.T. not be used in advertising
+.\" or publicity pertaining to distribution of the software without specific,
+.\" written prior permission. M.I.T. makes no representations about the
+.\" suitability of the software described here for any purpose, nor
+.\" about the accuracy of this documentation. It is provided "as is"
+.\" without express or implied warranty.
+.\"
+.\" The X Window System is a Trademark of MIT.
+.\"
+.\" 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.
+.\"
+.\" Run this file through troff and use the -ms macro package.
+.ND
+.de St
+.sp
+.nr PD 0
+.nr PI 1.5i
+.nr VS 16
+..
+.de Ed
+.nr PD .3v
+.nr VS 12
+..
+.rm CH
+.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
+.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
+.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'\|
+..
+.[] Et \v'-1p'\*X\v'1p'
+.[] En \v'-1p'\*N\v'1p'
+.[] Be \v'-1p'\*L\v'1p'
+.[] Bs \v'-1p'\s\nsBS\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'
+.[] 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'
+.[] ! !
+.[] # #
+.[] (( (
+.[] ) )
+.[] * *
+.[] + +
+.[] 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
+.[] H H
+.[] J J
+.[] K K
+.[] L L
+.[] M M
+.[] N N
+.[] O O
+.[] P P
+.[] R R
+.[] S S
+.[] T T
+.[] Z Z
+.[] [[ [
+.[] bS \\e
+.[] ] ]
+.[] ^ ^
+.[] _ _
+.[] ` \`
+.[] 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
+.[] s s
+.[] t t
+.[] x x
+.[] | |
+.[] } }
+.[] 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 Ps \fIP\v'.3m'\h'-.2m'\s-2s\s0\v'-.3m'\fP
+.ds Pm \fIP\v'.3m'\h'-.2m'\s-2m\s0\v'-.3m'\fP
+.ds Pt \fIP\v'.3m'\h'-.2m'\s-2t\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
+.nr LL 6.5i
+.TL
+Xterm Control Sequences
+.AU
+Edward Moy
+.AI
+University of California, Berkeley
+.sp
+Revised by
+.AU
+Stephen Gildea
+.AI
+MIT X Consortium
+
+.am NP
+.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).
+.IP \*(Pt
+A text parameter composed of printable characters.
+.SH
+VT100 Mode
+.ds RH VT100 Mode
+.LP
+Most of these control sequences are standard VT102 control sequences,
+but there are some sequences here from later DEC VT terminals, too.
+Major VT102 features not supported are smooth scrolling, double size
+characters, blinking characters, and VT52 mode.
+There are additional control sequences to provide
+\fIxterm-\fPdependent functions, like 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
+character sets are specified by ISO 2022; see that document for a
+discussion of character sets.
+.St
+.IP \\*(Be
+Bell (Ctrl-G)
+.IP \\*(Bs
+Backspace (Ctrl-H)
+.IP \\*(Ta
+Horizontal Tab (HT) (Ctrl-I)
+.IP \\*(Lf
+Line Feed or New Line (NL) (Ctrl-J)
+.IP \\*(Vt
+Vertical Tab (Ctrl-K) same as LF
+.IP \\*(Ff
+Form Feed or New Page (NP) (Ctrl-L) same as LF
+.IP \\*(Cr
+Carriage Return (Ctrl-M)
+.IP \\*(So
+Shift Out (Ctrl-N) \(-> Switch to Alternate Character Set: invokes the
+G1 character set.
+.IP \\*(Si
+Shift In (Ctrl-O) \(-> Switch to Standard Character Set: invokes the
+G0 character set (the default).
+.IP \\*(Es\\*#\\*8
+DEC Screen Alignment Test (DECALN)
+.IP \\*(Es\\*(((\\*(Cc
+Designate G0 Character Set (ISO 2022)
+ \*(Cc = \*0 \(-> DEC Special Character and Line Drawing Set
+ \*(Cc = \*A \(-> United Kingdom (UK)
+ \*(Cc = \*(cB \(-> United States (USASCII)
+.IP \\*(Es\\*)\\*(Cc
+Designate G1 Character Set (ISO 2022)
+ \*(Cc = \*0 \(-> DEC Special Character and Line Drawing Set
+ \*(Cc = \*A \(-> United Kingdom (UK)
+ \*(Cc = \*(cB \(-> United States (USASCII)
+.IP \\*(Es\\**\\*(Cc
+Designate G2 Character Set (ISO 2022)
+ \*(Cc = \*0 \(-> DEC Special Character and Line Drawing Set
+ \*(Cc = \*A \(-> United Kingdom (UK)
+ \*(Cc = \*(cB \(-> United States (USASCII)
+.IP \\*(Es\\*+\\*(Cc
+Designate G3 Character Set (ISO 2022)
+ \*(Cc = \*0 \(-> DEC Special Character and Line Drawing Set
+ \*(Cc = \*A \(-> United Kingdom (UK)
+ \*(Cc = \*(cB \(-> United States (USASCII)
+.IP \\*(Es\\*7
+Save Cursor (DECSC)
+.IP \\*(Es\\*8
+Restore Cursor (DECRC)
+.IP \\*(Es\\*=
+Application Keypad (DECPAM)
+.IP \\*(Es\\*>
+Normal Keypad (DECPNM)
+.IP \\*(Es\\*D
+Index (IND)
+.IP \\*(Es\\*E
+Next Line (NEL)
+.IP \\*(Es\\*H
+Tab Set (HTS)
+.IP \\*(Es\\*M
+Reverse Index (RI)
+.IP \\*(Es\\*N
+Single Shift Select of G2 Character Set (SS2): affects next character only
+.IP \\*(Es\\*O
+Single Shift Select of G3 Character Set (SS3): affects next character only
+.IP \\*(Es\\*P\\*(Pt\|\\*(Es\\*(bS
+Device Control String (DCS)
+ \fIxterm\fP implements no DCS functions; \*(Pt is ignored.
+\*(Pt need not be printable characters.
+.IP \\*(Es\\*Z
+Return Terminal ID (DECID). Obsolete form of \*(Es\*([[\*c (DA).
+.IP \\*(Es\\*([[\\*(Ps\|\\*@
+Insert \*(Ps (Blank) Character(s) (default = 1) (ICH)
+.IP \\*(Es\\*([[\\*(Ps\|\\*A
+Cursor Up \*(Ps Times (default = 1) (CUU)
+.IP \\*(Es\\*([[\\*(Ps\|\\*(cB
+Cursor Down \*(Ps Times (default = 1) (CUD)
+.IP \\*(Es\\*([[\\*(Ps\|\\*C
+Cursor Forward \*(Ps Times (default = 1) (CUF)
+.IP \\*(Es\\*([[\\*(Ps\|\\*D
+Cursor Backward \*(Ps Times (default = 1) (CUB)
+.IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*H
+Cursor Position [row;column] (default = [1,1]) (CUP)
+.IP \\*(Es\\*([[\\*(Ps\|\\*J
+Erase in Display (ED)
+ \*(Ps = \*0 \(-> Clear Below (default)
+ \*(Ps = \*1 \(-> Clear Above
+ \*(Ps = \*2 \(-> Clear All
+.IP \\*(Es\\*([[\\*(Ps\|\\*K
+Erase in Line (EL)
+ \*(Ps = \*0 \(-> Clear to Right (default)
+ \*(Ps = \*1 \(-> Clear to Left
+ \*(Ps = \*2 \(-> Clear All
+.IP \\*(Es\\*([[\\*(Ps\|\\*L
+Insert \*(Ps Line(s) (default = 1) (IL)
+.IP \\*(Es\\*([[\\*(Ps\|\\*M
+Delete \*(Ps Line(s) (default = 1) (DL)
+.IP \\*(Es\\*([[\\*(Ps\|\\*P
+Delete \*(Ps Character(s) (default = 1) (DCH)
+.IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*;\\*(Ps\|\\*;\\*(Ps\|\\*;\\*(Ps\|\\*T
+Initiate hilite mouse tracking.
+Parameters are [func;startx;starty;firstrow;lastrow].
+See the section \fBMouse Tracking\fP.
+.IP \\*(Es\\*([[\\*(Ps\|\\*c
+Send Device Attributes (DA)
+ \*(Ps = \*0 or omitted \(-> request attributes from terminal
+ \(-> \*(Es\*([[\*?\*1\*;\*2\*c (``I am a VT100 with Advanced
+Video Option.'')
+.IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*f
+Horizontal and Vertical Position [row;column] (default = [1,1]) (HVP)
+.IP \\*(Es\\*([[\\*(Ps\|\\*g
+Tab Clear (TBC)
+ \*(Ps = \*0 \(-> Clear Current Column (default)
+ \*(Ps = \*3 \(-> Clear All
+.IP \\*(Es\\*([[\\*(Pm\|\\*h
+Set Mode (SM)
+ \*(Ps = \*4 \(-> Insert Mode (IRM)
+ \*(Ps = \*2\*0 \(-> Automatic Newline (LNM)
+.IP \\*(Es\\*([[\\*(Pm\|\\*l
+Reset Mode (RM)
+ \*(Ps = \*4 \(-> Replace Mode (IRM)
+ \*(Ps = \*2\*0 \(-> Normal Linefeed (LNM)
+.IP \\*(Es\\*([[\\*(Pm\|\\*m
+Character Attributes (SGR)
+ \*(Ps = \*0 \(-> Normal (default)
+ \*(Ps = \*1 \(-> Bold
+ \*(Ps = \*4 \(-> Underscore
+ \*(Ps = \*5 \(-> Blink (appears as Bold)
+ \*(Ps = \*7 \(-> Inverse
+.IP \\*(Es\\*([[\\*(Ps\|\\*n
+Device Status Report (DSR)
+ \*(Ps = \*5 \(-> Status Report \*(Es\*([[\*0\*n (``OK'')
+ \*(Ps = \*6 \(-> Report Cursor Position (CPR) [row;column] as
+\*(Es\*([[\*(Ir\|\*;\*(Ic\|\*R
+.IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*r
+Set Scrolling Region [top;bottom] (default = full size of window) (DECSTBM)
+.IP \\*(Es\\*([[\\*(Ps\|\\*x
+Request Terminal Parameters (DECREQTPARM)
+.IP \\*(Es\\*([[\\*?\\*(Pm\|\\*h
+DEC Private Mode Set (DECSET)
+ \*(Ps = \*1 \(-> Application Cursor Keys (DECCKM)
+ \*(Ps = \*2 \(-> Designate USASCII for character sets G0-G3.
+(In the VT102, this selects VT52 mode (DECANM), which \fIxterm\fP
+doesn't support.)
+ \*(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 = \*3\*8 \(-> Enter Tektronix Mode (DECTEK)
+ \*(Ps = \*4\*0 \(-> Allow 80 \z\(<-\(-> 132 Mode
+ \*(Ps = \*4\*1 \(-> \fIcurses\fP(5) fix
+ \*(Ps = \*4\*4 \(-> Turn On Margin Bell
+ \*(Ps = \*4\*5 \(-> Reverse-wraparound Mode
+ \*(Ps = \*4\*6 \(-> Start Logging
+ \*(Ps = \*4\*7 \(-> Use Alternate Screen Buffer (unless
+disabled by the \fBtiteInhibit\fP resource)
+ \*(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.
+See the section \fBMouse Tracking\fP.
+.IP \\*(Es\\*([[\\*?\\*(Pm\|\\*l
+DEC Private Mode Reset (DECRST)
+ \*(Ps = \*1 \(-> Normal Cursor Keys (DECCKM)
+ \*(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 = \*4\*0 \(-> Disallow 80 \z\(<-\(-> 132 Mode
+ \*(Ps = \*4\*1 \(-> No \fIcurses\fP(5) fix
+ \*(Ps = \*4\*4 \(-> Turn Off Margin Bell
+ \*(Ps = \*4\*5 \(-> No Reverse-wraparound Mode
+ \*(Ps = \*4\*6 \(-> Stop Logging
+ \*(Ps = \*4\*7 \(-> Use Normal Screen Buffer
+ \*(Ps = \*1\*0\*0\*0 \(-> Don't Send Mouse X & Y on button press and
+release
+ \*(Ps = \*1\*0\*0\*1 \(-> Don't Use Hilite Mouse Tracking
+.IP \\*(Es\\*([[\\*?\\*(Pm\|\\*r
+Restore DEC Private Mode Values. The value of \*(Ps previously saved is
+restored. \*(Ps values are the same as for DECSET.
+.IP \\*(Es\\*([[\\*?\\*(Pm\|\\*s
+Save DEC Private Mode Values. \*(Ps values are the same as for DECSET.
+.IP \\*(Es\\*]\\*(Ps\|\\*;\\*(Pt\|\\*(Be
+Set Text Parameters
+ \*(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)
+ \*(Ps = \*5\*0 \(-> Set Font to \*(Pt
+.IP \\*(Es\\*^\\*(Pt\|\\*(Es\\*(bS
+Privacy Message (PM)
+ \fIxterm\fP implements no PM functions; \*(Pt is ignored.
+\*(Pt need not be printable characters.
+.IP \\*(Es\\*_\\*(Pt\|\\*(Es\\*(bS
+Application Program Command (APC)
+ \fIxterm\fP implements no APC functions; \*(Pt is ignored.
+\*(Pt need not be printable characters.
+.IP \\*(Es\\*c
+Full Reset (RIS)
+.IP \\*(Es\\*n
+Select the G2 Character Set (LS2)
+.IP \\*(Es\\*o
+Select the G3 Character Set (LS3)
+.IP \\*(Es\\*|
+Invoke the G3 Character Set as GR (LS3R). Has no visible effect in \fIxterm\fP.
+.IP \\*(Es\\*}
+Invoke the G2 Character Set as GR (LS2R). Has no visible effect in \fIxterm\fP.
+.IP \\*(Es\\*(c~
+Invoke the G1 Character Set as GR (LS1R). Has no visible effect in \fIxterm\fP.
+.Ed
+.SH
+Mouse Tracking
+.LP
+The VT widget can be set to send the mouse position and other
+information on button presses. These modes are typically used by
+editors and other full-screen applications that want to make use of
+the mouse.
+.LP
+There are three mutually exclusive modes, each enabled (or disabled)
+by a different parameter in the DECSET (or DECRST) escape sequence.
+Parameters for all mouse tracking escape sequences generated by
+\fIxterm\fP encode numeric parameters in a single character as
+\fIvalue\fP+040. For example, \*! is 1. The screen
+coodinate system is 1-based.
+.LP
+X10 compatibility mode sends an escape sequence 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
+\*(Es\*([[\*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.
+.LP
+Normal tracking mode sends an escape sequence on both button press and
+release. Modifier information is also sent.
+It is enabled by specifying parameter 1000 to DECSET.
+On button press or release, \fIxterm\fP sends
+\*(Es\*([[\*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 upper bits encode what modifiers were down when the button was
+pressed and are added together. 4=Shift, 8=Meta, 16=Control.
+\*(Cx and \*(Cy are the x and y coordinates of the mouse event. The
+upper left corner is (1,1).
+.LP
+Mouse hilite 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.
+Warning: 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
+\*(Es\*([[\*(Ps\|\*;\*(Ps\|\*;\*(Ps\|\*;\*(Ps\|\*;\*(Ps\|\*T.
+The parameters are \fIfunc, startx, starty, firstrow,\fP and \fIlastrow.\fP
+\fIfunc\fP is non-zero to initiate hilite 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: \*(Es\*([[\*t\*(Cx\*(Cy. If either coordinate is past
+the end of the line:
+\*(Es\*([[\*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.
+.SH
+Tektronix 4014 Mode
+.ds RH Tektronix 4014 Mode
+.LP
+Most of these sequences are standard Tektronix 4014 control sequences.
+The major features missing are
+the write-thru 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\\*(Lf
+PAGE (Clear Screen)
+.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 COPYyy-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 \\*(Es\\*]\\*(Ps\|\\*;\\*(Pt\|\\*(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
+.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\\*s
+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
diff --git a/vendor/x11iraf/xgterm/ctlseqs.ps b/vendor/x11iraf/xgterm/ctlseqs.ps
new file mode 100644
index 00000000..b7167a48
--- /dev/null
+++ b/vendor/x11iraf/xgterm/ctlseqs.ps
@@ -0,0 +1,9696 @@
+%!PS-Adobe-1.0
+%%Creator: devps (Pipeline Associates, Inc.)
+%%CreationDate: Mon Feb 23 13:49:22 1998
+%%Pages: (atend)
+%%DocumentFonts: (atend)
+
+/X{exch}def
+/r{rmoveto}def
+/m{moveto}def
+/l{lineto}def
+/rl{rlineto}def
+/lc{yc X xc X l st}def
+/mc{yc X xc X m}def
+/el{gs /a X def a div 1 X scale cp np a xc 2 div 0 360 arc st gr}def
+/ar{cp 7 2 roll np xc 5 1 roll atan 3 1 roll atan X arc st}def
+/sp{yc X xc X 6 2 roll yc X xc X 6 2 roll yc X xc X 6 2 roll ct}def
+/st{stroke}def
+/gs{gsave}def
+/gr{grestore}def
+/cp{currentpoint}def
+/np{newpath}def
+/ct{curveto}def
+/m0{0 0 moveto}def
+/BP{/devps-save save def m0}def
+/EP{
+clear devps-save restore
+showpage}def
+/res 10.000000 def
+/V{res neg div 792 add
+currentpoint pop X
+m}def
+/H{res div
+currentpoint X pop
+moveto}def
+/h{res div 0 r}def
+/v{res neg div 0 X r}def
+/xc{res div}def
+/yc{res neg div 792 add}def
+/S{X H show}def
+/psize 10 def
+/height 1 def
+/slant 0 def
+/FF{findfont X dup 12 div setlinewidth /psize X def
+ [psize 0 psize height mul slant sin slant cos div mul psize height mul 0 0]
+ makefont setfont}def
+/shade{gs
+ /dy X def
+ /dx X def
+ np m
+ setgray
+ 0 dy rl
+ dx 0 rl
+ 0 dy neg rl
+ dx neg 0 rl
+ closepath
+ fill
+gr}def
+1 setlinecap
+/R{/Times-Roman FF}def
+/B{/Times-Bold FF}def
+/I{/Times-Italic FF}def
+/Y{/Symbol FF}def
+%% Troff special characters not on Symbol font
+%% Copyright (C) 1986 by Pipeline Associates, Inc.
+%% Version 1.1
+/altRTD 20 dict def
+altRTD begin
+/s{setcachedevice}def
+/C{1000 1000 scale}def
+/m{moveto}def
+/c{curveto}def
+/S{stroke}def
+/l{lineto}def
+/a{arcto}def
+/p{pop}def
+/sl{setlinewidth}def
+end
+/F_Troff 17 dict def F_Troff begin
+systemdict /currentpacking known
+{/SavePacking currentpacking def true setpacking}if
+/PaintType 0 def
+/FontType 3 def
+/StrokeWidth 0 def
+/UniqueID 8277003 def
+/FontMatrix [.001000 0 0 .001000 0 0] def
+/FontBBox [-12 -105 942 855 ] def
+/Encoding 256 array def
+/CD 256 1 add dict def
+/FontInfo 3 dict def FontInfo begin
+/UnderlinePosition -133 def /UnderlineThickness 20 def end
+/FontName (Troff) def
+0 1 256 1 sub{Encoding exch /.notdef put}for
+CD /.notdef{500 0 setcharwidth{}}put
+Encoding (1) 0 get /br put
+%% bold vertical rule used by tbl
+CD /br{
+C
+0 0 -.5 -.5 1 1 s
+np
+.05 sl
+0 -.1 m
+0 .9 l
+{S}
+}put
+Encoding (2) 0 get /ul put
+%% underline used by tbl
+CD /ul{
+C
+.5 0 -.5 -.5 1 1 s
+np
+.05 sl
+0 -.1 m
+.5 -.1 l
+{S}
+}put
+Encoding (3) 0 get /ru put
+%% baseline rule
+CD /ru{
+C
+.5 0 -.5 -.5 1 1 s
+np
+.05 sl
+m0
+.5 0 l
+{S}
+}put
+Encoding (4) 0 get /vr put
+%% vertical rule
+CD /vr{
+C
+0 0 -.5 -.5 1 1 s
+np
+.05 sl
+m0
+0 1 l
+{S}
+}put
+Encoding (5) 0 get /sq put
+%% square
+CD /sq{
+C
+.5 0 -.5 -.5 1 1 s
+np
+.05 sl
+0 .25 m
+0 .5 rl
+.5 0 rl
+0 -.5 rl
+-.5 0 rl
+closepath
+{S}
+}put
+Encoding (6) 0 get /bx put
+%% solid box
+CD /bx{
+C
+.5 0 -.5 -.5 1 1 s
+np
+0 .25 m
+0 .5 rl
+.5 0 rl
+0 -.5 rl
+-.5 0 rl
+closepath
+{fill}
+}put
+Encoding (7) 0 get /rn put
+%% radical extender
+CD /rn{
+C
+.5 0 -.5 -.5 1 1 s
+np
+.03 sl
+-.03 .9 m
+.5 0 rl
+{S}
+}put
+Encoding (8) 0 get /GR put
+%% gray mask
+CD /GR{
+C
+.5 0 setcharwidth
+.5 setgray
+np
+0 -.1 m
+0 1 rl
+.5 0 rl
+0 -1 rl
+-.5 0 rl
+closepath
+{fill}
+}put
+Encoding 97 /a put
+CD /a{1000 0 0 66 942 421 s 430 415
+m 578 406 678 349 662 319 c 655 306 614 287 583
+296 c 570 300 466 340 438 332 c 365 309 335 213
+270 209 c 0 310 m 108 310 l 108 114 l 0
+114 l 0 310 l 42 161 m 42 134 l 66 134 l 66
+161 l 42 161 l 47 155 m 47 140 l 62 140 l 62
+155 l 47 155 l 110 133 m 226 113 300 66 410
+80 c 497 91 550 69 634 76 c 645 76 663 92 669
+107 c 677 125 673 141 668 160 c 725 334 m 758
+332 734 253 701 250 c 501 325 m 475 316 476 309
+473 302 c 465 282 482 263 499 257 c 552 236 615
+253 689 253 c 701 253 713 236 713 218 c 712 194
+702 168 678 161 c 671 159 663 160 655 160 c 591
+158 516 156 479 168 c 461 173 453 191 453 210 c 453
+224 456 235 466 244 c 476 253 490 252 503 255 c 459
+84 m 447 96 435 106 435 123 c 435 136 440 145 447
+155 c 453 163 462 168 469 173 c 110 293 m 173
+318 300 421 435 415 c 609 407 852 416 885 411 c 898
+409 924 411 930 380 c 942 316 828 339 742 334 c 731
+334 730 335 725 335 c 701 336 685 336 660 336 c{S}}put
+Encoding 98 /b put
+CD /b{1000 0 -12 66 930 421 s 500
+415 m 352 406 252 349 268 319 c 275 306 316 287
+347 296 c 360 300 464 340 492 332 c 565 309 595
+213 660 209 c 930 310 m 822 310 l 822 114 l 930
+114 l 930 310 l 888 161 m 888 134 l 864 134
+l 864 161 l 888 161 l 883 155 m 883 140 l 868
+140 l 868 155 l 883 155 l 820 133 m 704 113
+630 66 520 80 c 433 91 380 69 296 76 c 285 76
+267 92 261 107 c 253 125 257 141 262 160 c 205
+334 m 172 332 196 253 229 250 c 429 325 m 455
+316 454 309 457 302 c 465 282 448 263 431 257 c 378
+236 315 253 241 253 c 229 253 217 236 217 218 c 218
+194 228 168 252 161 c 259 159 267 160 275 160 c 339
+158 414 156 451 168 c 469 173 477 191 477 210 c 477
+224 474 235 464 244 c 454 253 440 252 427 255 c 471
+84 m 483 96 495 106 495 123 c 495 136 490 145 483
+155 c 477 163 468 168 461 173 c 820 293 m 757
+318 630 421 495 415 c 321 407 78 416 45 411 c 32
+409 6 411 0 380 c -12 316 102 339 188 334 c 199
+334 200 335 205 335 c 229 336 245 336 270 336 c{S}}put
+Encoding 99 /c put
+CD /c{1000 0 184 0 827 627 s 185 315
+m 186 488 332 627 505 625 c 682 623 827 467 815
+290 c 804 124 666 0 500 0 c 327 0 184 142 185
+315 c{S}}put
+Encoding 100 /d put
+CD /d{590 0 134 158 477 500 s 300
+160 m 208 162 134 238 135 330 c 136 423 212 500
+305 500 c 397 500 473 427 475 335 c 477 239 396
+158 300 160 c{fill}}put
+Encoding 101 /e put % Bell Symbol
+CD /e{1010 0 -100 -210 1010 1010 s 100 sl 0 setlinecap
+420 300 450 0 360 arc
+420 650 m 420 575 l S
+newpath 120 125 m 720 125 l 75 sl S
+420 125 m 420 25 l S
+220 400 m 220 175 120 175 100 a p p p p
+220 400 m 220 550 420 550 80 a p p p p
+620 400 m 620 175 720 175 100 a p p p p
+620 400 m 620 550 420 550 80 a p p p p
+295 550 m 545 550 l{S}}put
+/BuildChar{altRTD /BuildChar get exec}def end
+altRTD begin /BuildChar{altRTD begin
+/char exch def /fontdict exch def save
+/charname fontdict /Encoding get char get def
+fontdict /StrokeWidth get sl
+fontdict /CD get dup charname known
+{charname}{/.notdef}ifelse get newpath exec
+fontdict /PaintType get 0 eq{exec}{p S}ifelse
+restore end}def end
+systemdict /currentpacking known{F_Troff /SavePacking get setpacking}if
+/Troff F_Troff definefont pop
+/Y1{/Troff FF}def
+%%EndProlog
+%%Page: 1 1
+BP
+/slant 0 def
+/height 1.000000 def
+10 R
+10 R
+1200 V
+12 B
+2574(Xterm)S
+2942(Control)S
+3378(Sequences)S
+1440 V
+10 I
+2978(Edward)S
+3325(Moy)S
+1620 V
+10 R
+2547(University)S
+2999(of)S
+3112(California,)S
+3572(Berkeley)S
+1860 V
+3014(Revised)S
+3366(by)S
+2100 V
+10 I
+2931(Stephen)S
+3277(Gildea)S
+2280 V
+10 R
+2846(MIT)S
+3059(X)S
+3161(Consortium)S
+3000 V
+11 B
+900(De\256nitions)S
+3156 V
+11 Y1
+900(1)S
+3146 V
+900(1)S
+3156 V
+11 I
+957(c)S
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3146 V
+1062(1)S
+900(7)S
+952(77)S
+3156 V
+11 R
+1150(The)S
+1353(literal)S
+1642(character)S
+11 I
+2073(c)S
+11 R
+2121(.)S
+3312 V
+11 I
+900(C)S
+11 R
+1150(A)S
+1262(single)S
+1558(\(required\))S
+2027(character.)S
+3468 V
+11 I
+900(P)S
+3501 V
+9 I
+945(s)S
+3468 V
+11 R
+1150(A)S
+1262(single)S
+1558(\(usually)S
+1945(optional\))S
+2375(numeric)S
+2767(parameter,)S
+3264(composed)S
+3742(of)S
+3866(one)S
+4057(of)S
+4181(more)S
+4439(digits.)S
+3624 V
+11 I
+900(P)S
+3657 V
+9 I
+945(m)S
+3624 V
+11 R
+1150(A)S
+1272(multiple)S
+1684(numeric)S
+2087(parameter)S
+2567(composed)S
+3056(of)S
+3191(any)S
+3393(number)S
+3772(of)S
+3907(single)S
+4214(numeric)S
+4617(parameters,)S
+5168(separated)S
+3744 V
+1150(by)S
+11 Y1
+1293(1)S
+3734 V
+1293(1)S
+3744 V
+11 R
+1358(;)S
+11 Y1
+1455(1)S
+1293(2)S
+1345(22)S
+3734 V
+1455(1)S
+1293(7)S
+1345(77)S
+3744 V
+11 R
+1506(character\(s\).)S
+3900 V
+11 I
+900(P)S
+3933 V
+9 I
+945(t)S
+3900 V
+11 R
+1150(A)S
+1262(text)S
+1460(parameter)S
+1929(composed)S
+2407(of)S
+2531(printable)S
+2954(characters.)S
+4140 V
+11 B
+900(VT100)S
+1251(Mode)S
+4296 V
+11 R
+900(Most)S
+1171(of)S
+1306(these)S
+1575(control)S
+1930(sequences)S
+2417(are)S
+2593(standard)S
+3008(VT102)S
+3363(control)S
+3718(sequences,)S
+4234(but)S
+4420(there)S
+4683(are)S
+4860(some)S
+5137(sequences)S
+4416 V
+900(here)S
+1122(from)S
+1370(later)S
+1598(DEC)S
+1852(VT)S
+2032(terminals,)S
+2503(too.)S
+2739(Major)S
+3041(VT102)S
+3386(features)S
+3765(not)S
+3940(supported)S
+4407(are)S
+4573(smooth)S
+4932(scrolling,)S
+5379(dou-)S
+4536 V
+900(ble)S
+1069(size)S
+1275(characters,)S
+1780(blinking)S
+2184(characters,)S
+2689(and)S
+2883(VT52)S
+3175(mode.)S
+3516(There)S
+3806(are)S
+3974(additional)S
+4450(control)S
+4797(sequences)S
+5276(to)S
+5398(pro-)S
+4656 V
+900(vide)S
+11 I
+1132(xterm-)S
+11 R
+1417(dependent)S
+1910(functions,)S
+2390(like)S
+2598(the)S
+2775(scrollbar)S
+3201(or)S
+3335(window)S
+3732(size.)S
+4006(Where)S
+4338(the)S
+4514(function)S
+4922(is)S
+5038(speci\256ed)S
+5470(by)S
+4776 V
+900(DEC)S
+1157(or)S
+1285(ISO)S
+1499(6429,)S
+1784(the)S
+1955(code)S
+2198(assigned)S
+2613(to)S
+2736(it)S
+2835(is)S
+2946(given)S
+3227(in)S
+3350(parentheses.)S
+3958(The)S
+4166(escape)S
+4494(codes)S
+4781(to)S
+4905(designate)S
+5357(char-)S
+4896 V
+900(acter)S
+1144(sets)S
+1342(are)S
+1507(speci\256ed)S
+1930(by)S
+2073(ISO)S
+2283(2022;)S
+2567(see)S
+2739(that)S
+2937(document)S
+3403(for)S
+3563(a)S
+3644(discussion)S
+4136(of)S
+4260(character)S
+4691(sets.)S
+5176 V
+11 Y1
+900(1)S
+5166 V
+900(1)S
+6 R
+924(BEL)S
+5176 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5166 V
+1062(1)S
+900(7)S
+952(77)S
+5176 V
+11 R
+1980(Bell)S
+2197(\(Ctrl-G\))S
+5336 V
+11 Y1
+900(1)S
+5326 V
+900(1)S
+6 R
+944(BS)S
+5336 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5326 V
+1062(1)S
+900(7)S
+952(77)S
+5336 V
+11 R
+1980(Backspace)S
+2480(\(Ctrl-H\))S
+5496 V
+11 Y1
+900(1)S
+5486 V
+900(1)S
+6 R
+921(TAB)S
+5496 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5486 V
+1062(1)S
+900(7)S
+952(77)S
+5496 V
+11 R
+1980(Horizontal)S
+2482(Tab)S
+2685(\(HT\))S
+2936(\(Ctrl-I\))S
+5656 V
+11 Y1
+900(1)S
+5646 V
+900(1)S
+6 R
+945(LF)S
+5656 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5646 V
+1062(1)S
+900(7)S
+952(77)S
+5656 V
+11 R
+1980(Line)S
+2214(Feed)S
+2460(or)S
+2584(New)S
+2823(Line)S
+3057(\(NL\))S
+3308(\(Ctrl-J\))S
+5816 V
+11 Y1
+900(1)S
+5806 V
+900(1)S
+6 R
+941(VT)S
+5816 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5806 V
+1062(1)S
+900(7)S
+952(77)S
+5816 V
+11 R
+1980(Vertical)S
+2365(Tab)S
+2568(\(Ctrl-K\))S
+2960(same)S
+3218(as)S
+3342(LF)S
+5976 V
+11 Y1
+900(1)S
+5966 V
+900(1)S
+6 R
+947(FF)S
+5976 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5966 V
+1062(1)S
+900(7)S
+952(77)S
+5976 V
+11 R
+1980(Form)S
+2252(Feed)S
+2498(or)S
+2622(New)S
+2861(Page)S
+3107(\(NP\))S
+3353(\(Ctrl-L\))S
+3733(same)S
+3991(as)S
+4115(LF)S
+6136 V
+11 Y1
+900(1)S
+6126 V
+900(1)S
+6 R
+941(CR)S
+6136 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6126 V
+1062(1)S
+900(7)S
+952(77)S
+6136 V
+11 R
+1980(Carriage)S
+2389(Return)S
+2721(\(Ctrl-M\))S
+6296 V
+11 Y1
+900(1)S
+6286 V
+900(1)S
+6 R
+942(SO)S
+6296 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6286 V
+1062(1)S
+900(7)S
+952(77)S
+6296 V
+11 R
+1980(Shift)S
+2230(Out)S
+2430(\(Ctrl-N\))S
+11 Y
+2824(\256)S
+11 R
+2968(Switch)S
+3310(to)S
+3432(Alternate)S
+3875(Character)S
+4335(Set:)S
+4543(invokes)S
+4921(the)S
+5091(G1)S
+5261(charac-)S
+6456 V
+1980(ter)S
+2128(set.)S
+6616 V
+11 Y1
+900(1)S
+6606 V
+900(1)S
+6 R
+954(SI)S
+6616 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6606 V
+1062(1)S
+900(7)S
+952(77)S
+6616 V
+11 R
+1980(Shift)S
+2231(In)S
+2358(\(Ctrl-O\))S
+11 Y
+2753(\256)S
+11 R
+2898(Switch)S
+3241(to)S
+3364(Standard)S
+3791(Character)S
+4252(Set:)S
+4461(invokes)S
+4840(the)S
+5011(G0)S
+5182(character)S
+6776 V
+1980(set)S
+2135(\(the)S
+2338(default\).)S
+7920 V
+EP
+%%Page: 2 2
+BP
+/slant 0 def
+/height 1.000000 def
+11 R
+11 R
+520 V
+900(Xterm Control Sequences)S
+4980(VT100 Mode)S
+880 V
+11 Y1
+900(1)S
+870 V
+900(1)S
+6 R
+925(ESC)S
+880 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+870 V
+1062(1)S
+900(7)S
+952(77)S
+880 V
+1080(1)S
+870 V
+1080(1)S
+880 V
+11 R
+1133(#)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+870 V
+1242(1)S
+1080(7)S
+1132(77)S
+880 V
+1260(1)S
+870 V
+1260(1)S
+880 V
+11 R
+1313(8)S
+11 Y1
+1422(1)S
+1260(2)S
+1312(22)S
+870 V
+1422(1)S
+1260(7)S
+1312(77)S
+880 V
+11 R
+1980(DEC)S
+2233(Screen)S
+2563(Alignment)S
+3067(Test)S
+3289(\(DECALN\))S
+1040 V
+11 Y1
+900(1)S
+1030 V
+900(1)S
+6 R
+925(ESC)S
+1040 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1030 V
+1062(1)S
+900(7)S
+952(77)S
+1040 V
+1080(1)S
+1030 V
+1080(1)S
+1040 V
+11 R
+1143(\()S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1030 V
+1242(1)S
+1080(7)S
+1132(77)S
+1040 V
+11 I
+1260(C)S
+11 R
+1980(Designate)S
+2451(G0)S
+2618(Character)S
+3075(Set)S
+3249(\(ISO)S
+3495(2022\))S
+1200 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+1190 V
+2248(1)S
+1200 V
+11 R
+2301(0)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+1190 V
+2410(1)S
+2248(7)S
+2300(77)S
+1200 V
+11 Y
+2461(\256)S
+11 R
+2603(DEC)S
+2856(Special)S
+3212(Character)S
+3669(and)S
+3860(Line)S
+4094(Drawing)S
+4510(Set)S
+1360 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+1350 V
+2248(1)S
+1360 V
+11 R
+2289(A)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+1350 V
+2410(1)S
+2248(7)S
+2300(77)S
+1360 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(Kingdom)S
+3384(\(UK\))S
+1520 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+1510 V
+2248(1)S
+1520 V
+11 R
+2292(B)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+1510 V
+2410(1)S
+2248(7)S
+2300(77)S
+1520 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(States)S
+3231(\(USASCII\))S
+1680 V
+11 Y1
+900(1)S
+1670 V
+900(1)S
+6 R
+925(ESC)S
+1680 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1670 V
+1062(1)S
+900(7)S
+952(77)S
+1680 V
+1080(1)S
+1670 V
+1080(1)S
+1680 V
+11 R
+1143(\))S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1670 V
+1242(1)S
+1080(7)S
+1132(77)S
+1680 V
+11 I
+1260(C)S
+11 R
+1980(Designate)S
+2451(G1)S
+2618(Character)S
+3075(Set)S
+3249(\(ISO)S
+3495(2022\))S
+1840 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+1830 V
+2248(1)S
+1840 V
+11 R
+2301(0)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+1830 V
+2410(1)S
+2248(7)S
+2300(77)S
+1840 V
+11 Y
+2461(\256)S
+11 R
+2603(DEC)S
+2856(Special)S
+3212(Character)S
+3669(and)S
+3860(Line)S
+4094(Drawing)S
+4510(Set)S
+2000 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+1990 V
+2248(1)S
+2000 V
+11 R
+2289(A)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+1990 V
+2410(1)S
+2248(7)S
+2300(77)S
+2000 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(Kingdom)S
+3384(\(UK\))S
+2160 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+2150 V
+2248(1)S
+2160 V
+11 R
+2292(B)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+2150 V
+2410(1)S
+2248(7)S
+2300(77)S
+2160 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(States)S
+3231(\(USASCII\))S
+2320 V
+11 Y1
+900(1)S
+2310 V
+900(1)S
+6 R
+925(ESC)S
+2320 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2310 V
+1062(1)S
+900(7)S
+952(77)S
+2320 V
+1080(1)S
+2310 V
+1080(1)S
+2320 V
+11 R
+1133(*)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2310 V
+1242(1)S
+1080(7)S
+1132(77)S
+2320 V
+11 I
+1260(C)S
+11 R
+1980(Designate)S
+2451(G2)S
+2618(Character)S
+3075(Set)S
+3249(\(ISO)S
+3495(2022\))S
+2480 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+2470 V
+2248(1)S
+2480 V
+11 R
+2301(0)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+2470 V
+2410(1)S
+2248(7)S
+2300(77)S
+2480 V
+11 Y
+2461(\256)S
+11 R
+2603(DEC)S
+2856(Special)S
+3212(Character)S
+3669(and)S
+3860(Line)S
+4094(Drawing)S
+4510(Set)S
+2640 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+2630 V
+2248(1)S
+2640 V
+11 R
+2289(A)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+2630 V
+2410(1)S
+2248(7)S
+2300(77)S
+2640 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(Kingdom)S
+3384(\(UK\))S
+2800 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+2790 V
+2248(1)S
+2800 V
+11 R
+2292(B)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+2790 V
+2410(1)S
+2248(7)S
+2300(77)S
+2800 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(States)S
+3231(\(USASCII\))S
+2960 V
+11 Y1
+900(1)S
+2950 V
+900(1)S
+6 R
+925(ESC)S
+2960 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2950 V
+1062(1)S
+900(7)S
+952(77)S
+2960 V
+1080(1)S
+2950 V
+1080(1)S
+2960 V
+11 R
+1130(+)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2950 V
+1242(1)S
+1080(7)S
+1132(77)S
+2960 V
+11 I
+1260(C)S
+11 R
+1980(Designate)S
+2451(G3)S
+2618(Character)S
+3075(Set)S
+3249(\(ISO)S
+3495(2022\))S
+3120 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+3110 V
+2248(1)S
+3120 V
+11 R
+2301(0)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+3110 V
+2410(1)S
+2248(7)S
+2300(77)S
+3120 V
+11 Y
+2461(\256)S
+11 R
+2603(DEC)S
+2856(Special)S
+3212(Character)S
+3669(and)S
+3860(Line)S
+4094(Drawing)S
+4510(Set)S
+3280 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+3270 V
+2248(1)S
+3280 V
+11 R
+2289(A)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+3270 V
+2410(1)S
+2248(7)S
+2300(77)S
+3280 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(Kingdom)S
+3384(\(UK\))S
+3440 V
+11 I
+2046(C)S
+11 R
+2153(=)S
+11 Y1
+2248(1)S
+3430 V
+2248(1)S
+3440 V
+11 R
+2292(B)S
+11 Y1
+2410(1)S
+2248(2)S
+2300(22)S
+3430 V
+2410(1)S
+2248(7)S
+2300(77)S
+3440 V
+11 Y
+2461(\256)S
+11 R
+2603(United)S
+2935(States)S
+3231(\(USASCII\))S
+3600 V
+11 Y1
+900(1)S
+3590 V
+900(1)S
+6 R
+925(ESC)S
+3600 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3590 V
+1062(1)S
+900(7)S
+952(77)S
+3600 V
+1080(1)S
+3590 V
+1080(1)S
+3600 V
+11 R
+1133(7)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3590 V
+1242(1)S
+1080(7)S
+1132(77)S
+3600 V
+11 R
+1980(Save)S
+2226(Cursor)S
+2558(\(DECSC\))S
+3760 V
+11 Y1
+900(1)S
+3750 V
+900(1)S
+6 R
+925(ESC)S
+3760 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3750 V
+1062(1)S
+900(7)S
+952(77)S
+3760 V
+1080(1)S
+3750 V
+1080(1)S
+3760 V
+11 R
+1133(8)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3750 V
+1242(1)S
+1080(7)S
+1132(77)S
+3760 V
+11 R
+1980(Restore)S
+2348(Cursor)S
+2680(\(DECRC\))S
+3920 V
+11 Y1
+900(1)S
+3910 V
+900(1)S
+6 R
+925(ESC)S
+3920 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3910 V
+1062(1)S
+900(7)S
+952(77)S
+3920 V
+1080(1)S
+3910 V
+1080(1)S
+3920 V
+11 R
+1130(=)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3910 V
+1242(1)S
+1080(7)S
+1132(77)S
+3920 V
+11 R
+1980(Application)S
+2532(Keypad)S
+2905(\(DECPAM\))S
+4080 V
+11 Y1
+900(1)S
+4070 V
+900(1)S
+6 R
+925(ESC)S
+4080 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4070 V
+1062(1)S
+900(7)S
+952(77)S
+4080 V
+1080(1)S
+4070 V
+1080(1)S
+4080 V
+11 R
+1130(>)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4070 V
+1242(1)S
+1080(7)S
+1132(77)S
+4080 V
+11 R
+1980(Normal)S
+2348(Keypad)S
+2721(\(DECPNM\))S
+4240 V
+11 Y1
+900(1)S
+4230 V
+900(1)S
+6 R
+925(ESC)S
+4240 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4230 V
+1062(1)S
+900(7)S
+952(77)S
+4240 V
+1080(1)S
+4230 V
+1080(1)S
+4240 V
+11 R
+1121(D)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4230 V
+1242(1)S
+1080(7)S
+1132(77)S
+4240 V
+11 R
+1980(Index)S
+2262(\(IND\))S
+4400 V
+11 Y1
+900(1)S
+4390 V
+900(1)S
+6 R
+925(ESC)S
+4400 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4390 V
+1062(1)S
+900(7)S
+952(77)S
+4400 V
+1080(1)S
+4390 V
+1080(1)S
+4400 V
+11 R
+1127(E)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4390 V
+1242(1)S
+1080(7)S
+1132(77)S
+4400 V
+11 R
+1980(Next)S
+2226(Line)S
+2460(\(NEL\))S
+4560 V
+11 Y1
+900(1)S
+4550 V
+900(1)S
+6 R
+925(ESC)S
+4560 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4550 V
+1062(1)S
+900(7)S
+952(77)S
+4560 V
+1080(1)S
+4550 V
+1080(1)S
+4560 V
+11 R
+1121(H)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4550 V
+1242(1)S
+1080(7)S
+1132(77)S
+4560 V
+11 R
+1980(Tab)S
+2183(Set)S
+2357(\(HTS\))S
+4720 V
+11 Y1
+900(1)S
+4710 V
+900(1)S
+6 R
+925(ESC)S
+4720 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4710 V
+1062(1)S
+900(7)S
+952(77)S
+4720 V
+1080(1)S
+4710 V
+1080(1)S
+4720 V
+11 R
+1112(M)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4710 V
+1242(1)S
+1080(7)S
+1132(77)S
+4720 V
+11 R
+1980(Reverse)S
+2365(Index)S
+2647(\(RI\))S
+4880 V
+11 Y1
+900(1)S
+4870 V
+900(1)S
+6 R
+925(ESC)S
+4880 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4870 V
+1062(1)S
+900(7)S
+952(77)S
+4880 V
+1080(1)S
+4870 V
+1080(1)S
+4880 V
+11 R
+1121(N)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4870 V
+1242(1)S
+1080(7)S
+1132(77)S
+4880 V
+11 R
+1980(Single)S
+2295(Shift)S
+2543(Select)S
+2844(of)S
+2968(G2)S
+3135(Character)S
+3592(Set)S
+3766(\(SS2\):)S
+4081(a)S
+4129 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+4196(ects)S
+4399(next)S
+4621(character)S
+5052(only)S
+5040 V
+11 Y1
+900(1)S
+5030 V
+900(1)S
+6 R
+925(ESC)S
+5040 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5030 V
+1062(1)S
+900(7)S
+952(77)S
+5040 V
+1080(1)S
+5030 V
+1080(1)S
+5040 V
+11 R
+1121(O)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5030 V
+1242(1)S
+1080(7)S
+1132(77)S
+5040 V
+11 R
+1980(Single)S
+2295(Shift)S
+2543(Select)S
+2844(of)S
+2968(G3)S
+3135(Character)S
+3592(Set)S
+3766(\(SS3\):)S
+4081(a)S
+4129 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+4196(ects)S
+4399(next)S
+4621(character)S
+5052(only)S
+5200 V
+11 Y1
+900(1)S
+5190 V
+900(1)S
+6 R
+925(ESC)S
+5200 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5190 V
+1062(1)S
+900(7)S
+952(77)S
+5200 V
+1080(1)S
+5190 V
+1080(1)S
+5200 V
+11 R
+1130(P)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5190 V
+1242(1)S
+1080(7)S
+1132(77)S
+5200 V
+11 I
+1260(P)S
+5233 V
+9 I
+1305(t)S
+5200 V
+11 Y1
+1348(1)S
+5190 V
+1348(1)S
+6 R
+1373(ESC)S
+5200 V
+11 Y1
+1510(1)S
+1348(2)S
+1400(22)S
+5190 V
+1510(1)S
+1348(7)S
+1400(77)S
+5200 V
+1528(1)S
+5190 V
+1528(1)S
+5200 V
+11 R
+1593(\\)S
+11 Y1
+1690(1)S
+1528(2)S
+1580(22)S
+5190 V
+1690(1)S
+1528(7)S
+1580(77)S
+5200 V
+11 R
+1980(Device)S
+2322(Control)S
+2692(String)S
+2995(\(DCS\))S
+5360 V
+11 I
+2046(xterm)S
+11 R
+2341(implements)S
+2901(no)S
+3057(DCS)S
+3318(functions;)S
+11 I
+3804(P)S
+5393 V
+9 I
+3849(t)S
+5360 V
+11 R
+3920(is)S
+4040(ignored.)S
+11 I
+4482(P)S
+5393 V
+9 I
+4527(t)S
+5360 V
+11 R
+4599(need)S
+4852(not)S
+5040(be)S
+5190(printable)S
+5520 V
+1980(characters.)S
+5680 V
+11 Y1
+900(1)S
+5670 V
+900(1)S
+6 R
+925(ESC)S
+5680 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5670 V
+1062(1)S
+900(7)S
+952(77)S
+5680 V
+1080(1)S
+5670 V
+1080(1)S
+5680 V
+11 R
+1127(Z)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5670 V
+1242(1)S
+1080(7)S
+1132(77)S
+5680 V
+11 R
+1980(Return)S
+2312(Terminal)S
+2747(ID)S
+2895(\(DECID\).)S
+3396(Obsolete)S
+3819(form)S
+4065(of)S
+11 Y1
+4189(1)S
+5670 V
+4189(1)S
+6 R
+4214(ESC)S
+5680 V
+11 Y1
+4351(1)S
+4189(2)S
+4241(22)S
+5670 V
+4351(1)S
+4189(7)S
+4241(77)S
+5680 V
+4369(1)S
+5670 V
+4369(1)S
+5680 V
+11 R
+4432([)S
+11 Y1
+4531(1)S
+4369(2)S
+4421(22)S
+5670 V
+4531(1)S
+4369(7)S
+4421(77)S
+5680 V
+4549(1)S
+5670 V
+4549(1)S
+5680 V
+11 R
+4606(c)S
+11 Y1
+4711(1)S
+4549(2)S
+4601(22)S
+5670 V
+4711(1)S
+4549(7)S
+4601(77)S
+5680 V
+11 R
+4762(\(DA\).)S
+5840 V
+11 Y1
+900(1)S
+5830 V
+900(1)S
+6 R
+925(ESC)S
+5840 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5830 V
+1062(1)S
+900(7)S
+952(77)S
+5840 V
+1080(1)S
+5830 V
+1080(1)S
+5840 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5830 V
+1242(1)S
+1080(7)S
+1132(77)S
+5840 V
+11 I
+1260(P)S
+5873 V
+9 I
+1305(s)S
+5840 V
+11 Y1
+1358(1)S
+5830 V
+1358(1)S
+5840 V
+11 R
+1388(@)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+5830 V
+1520(1)S
+1358(7)S
+1410(77)S
+5840 V
+11 R
+1980(Insert)S
+11 I
+2262(P)S
+5873 V
+9 I
+2307(s)S
+5840 V
+11 R
+2375(\(Blank\))S
+2743(Character\(s\))S
+3315(\(default)S
+3688(=)S
+3783(1\))S
+3907(\(ICH\))S
+6000 V
+11 Y1
+900(1)S
+5990 V
+900(1)S
+6 R
+925(ESC)S
+6000 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5990 V
+1062(1)S
+900(7)S
+952(77)S
+6000 V
+1080(1)S
+5990 V
+1080(1)S
+6000 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5990 V
+1242(1)S
+1080(7)S
+1132(77)S
+6000 V
+11 I
+1260(P)S
+6033 V
+9 I
+1305(s)S
+6000 V
+11 Y1
+1358(1)S
+5990 V
+1358(1)S
+6000 V
+11 R
+1399(A)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+5990 V
+1520(1)S
+1358(7)S
+1410(77)S
+6000 V
+11 R
+1980(Cursor)S
+2312(Up)S
+11 I
+2479(P)S
+6033 V
+9 I
+2524(s)S
+6000 V
+11 R
+2592(Times)S
+2900(\(default)S
+3273(=)S
+3368(1\))S
+3492(\(CUU\))S
+6160 V
+11 Y1
+900(1)S
+6150 V
+900(1)S
+6 R
+925(ESC)S
+6160 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6150 V
+1062(1)S
+900(7)S
+952(77)S
+6160 V
+1080(1)S
+6150 V
+1080(1)S
+6160 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6150 V
+1242(1)S
+1080(7)S
+1132(77)S
+6160 V
+11 I
+1260(P)S
+6193 V
+9 I
+1305(s)S
+6160 V
+11 Y1
+1358(1)S
+6150 V
+1358(1)S
+6160 V
+11 R
+1402(B)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+6150 V
+1520(1)S
+1358(7)S
+1410(77)S
+6160 V
+11 R
+1980(Cursor)S
+2312(Down)S
+11 I
+2613(P)S
+6193 V
+9 I
+2658(s)S
+6160 V
+11 R
+2726(Times)S
+3034(\(default)S
+3407(=)S
+3502(1\))S
+3626(\(CUD\))S
+6320 V
+11 Y1
+900(1)S
+6310 V
+900(1)S
+6 R
+925(ESC)S
+6320 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6310 V
+1062(1)S
+900(7)S
+952(77)S
+6320 V
+1080(1)S
+6310 V
+1080(1)S
+6320 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6310 V
+1242(1)S
+1080(7)S
+1132(77)S
+6320 V
+11 I
+1260(P)S
+6353 V
+9 I
+1305(s)S
+6320 V
+11 Y1
+1358(1)S
+6310 V
+1358(1)S
+6320 V
+11 R
+1402(C)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+6310 V
+1520(1)S
+1358(7)S
+1410(77)S
+6320 V
+11 R
+1980(Cursor)S
+2312(Forward)S
+11 I
+2716(P)S
+6353 V
+9 I
+2761(s)S
+6320 V
+11 R
+2829(Times)S
+3137(\(default)S
+3510(=)S
+3605(1\))S
+3729(\(CUF\))S
+6480 V
+11 Y1
+900(1)S
+6470 V
+900(1)S
+6 R
+925(ESC)S
+6480 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6470 V
+1062(1)S
+900(7)S
+952(77)S
+6480 V
+1080(1)S
+6470 V
+1080(1)S
+6480 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6470 V
+1242(1)S
+1080(7)S
+1132(77)S
+6480 V
+11 I
+1260(P)S
+6513 V
+9 I
+1305(s)S
+6480 V
+11 Y1
+1358(1)S
+6470 V
+1358(1)S
+6480 V
+11 R
+1399(D)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+6470 V
+1520(1)S
+1358(7)S
+1410(77)S
+6480 V
+11 R
+1980(Cursor)S
+2312(Backward)S
+11 I
+2788(P)S
+6513 V
+9 I
+2833(s)S
+6480 V
+11 R
+2901(Times)S
+3209(\(default)S
+3582(=)S
+3677(1\))S
+3801(\(CUB\))S
+6640 V
+11 Y1
+900(1)S
+6630 V
+900(1)S
+6 R
+925(ESC)S
+6640 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6630 V
+1062(1)S
+900(7)S
+952(77)S
+6640 V
+1080(1)S
+6630 V
+1080(1)S
+6640 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6630 V
+1242(1)S
+1080(7)S
+1132(77)S
+6640 V
+11 I
+1260(P)S
+6673 V
+9 I
+1305(s)S
+6640 V
+11 Y1
+1358(1)S
+6630 V
+1358(1)S
+6640 V
+11 R
+1423(;)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+6630 V
+1520(1)S
+1358(7)S
+1410(77)S
+6640 V
+11 I
+1538(P)S
+6673 V
+9 I
+1583(s)S
+6640 V
+11 Y1
+1636(1)S
+6630 V
+1636(1)S
+6640 V
+11 R
+1677(H)S
+11 Y1
+1798(1)S
+1636(2)S
+1688(22)S
+6630 V
+1798(1)S
+1636(7)S
+1688(77)S
+6640 V
+11 R
+1980(Cursor)S
+2312(Position)S
+2708([row;column])S
+3344(\(default)S
+3717(=)S
+3812([1,1]\))S
+4091(\(CUP\))S
+6800 V
+11 Y1
+900(1)S
+6790 V
+900(1)S
+6 R
+925(ESC)S
+6800 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6790 V
+1062(1)S
+900(7)S
+952(77)S
+6800 V
+1080(1)S
+6790 V
+1080(1)S
+6800 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6790 V
+1242(1)S
+1080(7)S
+1132(77)S
+6800 V
+11 I
+1260(P)S
+6833 V
+9 I
+1305(s)S
+6800 V
+11 Y1
+1358(1)S
+6790 V
+1358(1)S
+6800 V
+11 R
+1417(J)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+6790 V
+1520(1)S
+1358(7)S
+1410(77)S
+6800 V
+11 R
+1980(Erase)S
+2255(in)S
+2374(Display)S
+2749(\(ED\))S
+6960 V
+11 I
+2046(P)S
+6993 V
+9 I
+2091(s)S
+6960 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+6950 V
+2254(1)S
+6960 V
+11 R
+2307(0)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+6950 V
+2416(1)S
+2254(7)S
+2306(77)S
+6960 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(Below)S
+3199(\(default\))S
+7120 V
+11 I
+2046(P)S
+7153 V
+9 I
+2091(s)S
+7120 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+7110 V
+2254(1)S
+7120 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+7110 V
+2416(1)S
+2254(7)S
+2306(77)S
+7120 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(Above)S
+7280 V
+11 I
+2046(P)S
+7313 V
+9 I
+2091(s)S
+7280 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+7270 V
+2254(1)S
+7280 V
+11 R
+2307(2)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+7270 V
+2416(1)S
+2254(7)S
+2306(77)S
+7280 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(All)S
+7720 V
+3212(2)S
+7920 V
+EP
+%%Page: 3 3
+BP
+/slant 0 def
+/height 1.000000 def
+11 R
+11 R
+520 V
+900(Xterm Control Sequences)S
+4980(VT100 Mode)S
+880 V
+11 Y1
+900(1)S
+870 V
+900(1)S
+6 R
+925(ESC)S
+880 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+870 V
+1062(1)S
+900(7)S
+952(77)S
+880 V
+1080(1)S
+870 V
+1080(1)S
+880 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+870 V
+1242(1)S
+1080(7)S
+1132(77)S
+880 V
+11 I
+1260(P)S
+913 V
+9 I
+1305(s)S
+880 V
+11 Y1
+1358(1)S
+870 V
+1358(1)S
+880 V
+11 R
+1399(K)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+870 V
+1520(1)S
+1358(7)S
+1410(77)S
+880 V
+11 R
+1980(Erase)S
+2255(in)S
+2374(Line)S
+2608(\(EL\))S
+1040 V
+11 I
+2046(P)S
+1073 V
+9 I
+2091(s)S
+1040 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1030 V
+2254(1)S
+1040 V
+11 R
+2307(0)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1030 V
+2416(1)S
+2254(7)S
+2306(77)S
+1040 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(to)S
+2998(Right)S
+3277(\(default\))S
+1200 V
+11 I
+2046(P)S
+1233 V
+9 I
+2091(s)S
+1200 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1190 V
+2254(1)S
+1200 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1190 V
+2416(1)S
+2254(7)S
+2306(77)S
+1200 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(to)S
+2998(Left)S
+1360 V
+11 I
+2046(P)S
+1393 V
+9 I
+2091(s)S
+1360 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1350 V
+2254(1)S
+1360 V
+11 R
+2307(2)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1350 V
+2416(1)S
+2254(7)S
+2306(77)S
+1360 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(All)S
+1520 V
+11 Y1
+900(1)S
+1510 V
+900(1)S
+6 R
+925(ESC)S
+1520 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1510 V
+1062(1)S
+900(7)S
+952(77)S
+1520 V
+1080(1)S
+1510 V
+1080(1)S
+1520 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1510 V
+1242(1)S
+1080(7)S
+1132(77)S
+1520 V
+11 I
+1260(P)S
+1553 V
+9 I
+1305(s)S
+1520 V
+11 Y1
+1358(1)S
+1510 V
+1358(1)S
+1520 V
+11 R
+1405(L)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+1510 V
+1520(1)S
+1358(7)S
+1410(77)S
+1520 V
+11 R
+1980(Insert)S
+11 I
+2262(P)S
+1553 V
+9 I
+2307(s)S
+1520 V
+11 R
+2375(Line\(s\))S
+2724(\(default)S
+3097(=)S
+3192(1\))S
+3316(\(IL\))S
+1680 V
+11 Y1
+900(1)S
+1670 V
+900(1)S
+6 R
+925(ESC)S
+1680 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1670 V
+1062(1)S
+900(7)S
+952(77)S
+1680 V
+1080(1)S
+1670 V
+1080(1)S
+1680 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1670 V
+1242(1)S
+1080(7)S
+1132(77)S
+1680 V
+11 I
+1260(P)S
+1713 V
+9 I
+1305(s)S
+1680 V
+11 Y1
+1358(1)S
+1670 V
+1358(1)S
+1680 V
+11 R
+1390(M)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+1670 V
+1520(1)S
+1358(7)S
+1410(77)S
+1680 V
+11 R
+1980(Delete)S
+11 I
+2298(P)S
+1713 V
+9 I
+2343(s)S
+1680 V
+11 R
+2411(Line\(s\))S
+2760(\(default)S
+3133(=)S
+3228(1\))S
+3352(\(DL\))S
+1840 V
+11 Y1
+900(1)S
+1830 V
+900(1)S
+6 R
+925(ESC)S
+1840 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1830 V
+1062(1)S
+900(7)S
+952(77)S
+1840 V
+1080(1)S
+1830 V
+1080(1)S
+1840 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1830 V
+1242(1)S
+1080(7)S
+1132(77)S
+1840 V
+11 I
+1260(P)S
+1873 V
+9 I
+1305(s)S
+1840 V
+11 Y1
+1358(1)S
+1830 V
+1358(1)S
+1840 V
+11 R
+1408(P)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+1830 V
+1520(1)S
+1358(7)S
+1410(77)S
+1840 V
+11 R
+1980(Delete)S
+11 I
+2298(P)S
+1873 V
+9 I
+2343(s)S
+1840 V
+11 R
+2411(Character\(s\))S
+2983(\(default)S
+3356(=)S
+3451(1\))S
+3575(\(DCH\))S
+2000 V
+11 Y1
+900(1)S
+1990 V
+900(1)S
+6 R
+925(ESC)S
+2000 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1990 V
+1062(1)S
+900(7)S
+952(77)S
+2000 V
+1080(1)S
+1990 V
+1080(1)S
+2000 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1990 V
+1242(1)S
+1080(7)S
+1132(77)S
+2000 V
+11 I
+1260(P)S
+2033 V
+9 I
+1305(s)S
+2000 V
+11 Y1
+1358(1)S
+1990 V
+1358(1)S
+2000 V
+11 R
+1423(;)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+1990 V
+1520(1)S
+1358(7)S
+1410(77)S
+2000 V
+11 I
+1538(P)S
+2033 V
+9 I
+1583(s)S
+2000 V
+11 Y1
+1636(1)S
+1990 V
+1636(1)S
+2000 V
+11 R
+1701(;)S
+11 Y1
+1798(1)S
+1636(2)S
+1688(22)S
+1990 V
+1798(1)S
+1636(7)S
+1688(77)S
+2000 V
+11 I
+1816(P)S
+2033 V
+9 I
+1861(s)S
+2000 V
+11 Y1
+1914(1)S
+1990 V
+1914(1)S
+2000 V
+11 R
+1979(;)S
+11 Y1
+2076(1)S
+1914(2)S
+1966(22)S
+1990 V
+2076(1)S
+1914(7)S
+1966(77)S
+2000 V
+11 I
+2094(P)S
+2033 V
+9 I
+2139(s)S
+2000 V
+11 Y1
+2192(1)S
+1990 V
+2192(1)S
+2000 V
+11 R
+2257(;)S
+11 Y1
+2354(1)S
+2192(2)S
+2244(22)S
+1990 V
+2354(1)S
+2192(7)S
+2244(77)S
+2000 V
+11 I
+2372(P)S
+2033 V
+9 I
+2417(s)S
+2000 V
+11 Y1
+2470(1)S
+1990 V
+2470(1)S
+2000 V
+11 R
+2517(T)S
+11 Y1
+2632(1)S
+2470(2)S
+2522(22)S
+1990 V
+2632(1)S
+2470(7)S
+2522(77)S
+2000 V
+11 R
+2650(Initiate)S
+3174(hilite)S
+3614(mouse)S
+4114(tracking.)S
+4748(Parameters)S
+5448(are)S
+2160 V
+1980([func;startx;starty;\256rstrow;lastrow].)S
+3617(See)S
+3808(the)S
+3975(section)S
+11 B
+4319(Mouse)S
+4663(Tracking)S
+11 R
+5098(.)S
+2320 V
+11 Y1
+900(1)S
+2310 V
+900(1)S
+6 R
+925(ESC)S
+2320 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2310 V
+1062(1)S
+900(7)S
+952(77)S
+2320 V
+1080(1)S
+2310 V
+1080(1)S
+2320 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2310 V
+1242(1)S
+1080(7)S
+1132(77)S
+2320 V
+11 I
+1260(P)S
+2353 V
+9 I
+1305(s)S
+2320 V
+11 Y1
+1358(1)S
+2310 V
+1358(1)S
+2320 V
+11 R
+1415(c)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+2310 V
+1520(1)S
+1358(7)S
+1410(77)S
+2320 V
+11 R
+1980(Send)S
+2233(Device)S
+2575(Attributes)S
+3048(\(DA\))S
+2480 V
+11 I
+2046(P)S
+2513 V
+9 I
+2091(s)S
+2480 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+2470 V
+2254(1)S
+2480 V
+11 R
+2307(0)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+2470 V
+2416(1)S
+2254(7)S
+2306(77)S
+2480 V
+11 R
+2467(or)S
+2591(omitted)S
+11 Y
+2961(\256)S
+11 R
+3103(request)S
+3452(attributes)S
+3894(from)S
+4140(terminal)S
+2640 V
+11 Y
+2046(\256)S
+11 Y1
+2232(1)S
+2630 V
+2232(1)S
+6 R
+2257(ESC)S
+2640 V
+11 Y1
+2394(1)S
+2232(2)S
+2284(22)S
+2630 V
+2394(1)S
+2232(7)S
+2284(77)S
+2640 V
+2412(1)S
+2630 V
+2412(1)S
+2640 V
+11 R
+2475([)S
+11 Y1
+2574(1)S
+2412(2)S
+2464(22)S
+2630 V
+2574(1)S
+2412(7)S
+2464(77)S
+2640 V
+2592(1)S
+2630 V
+2592(1)S
+2640 V
+11 R
+2649(?)S
+11 Y1
+2754(1)S
+2592(2)S
+2644(22)S
+2630 V
+2754(1)S
+2592(7)S
+2644(77)S
+2640 V
+2772(1)S
+2630 V
+2772(1)S
+2640 V
+11 R
+2825(1)S
+11 Y1
+2934(1)S
+2772(2)S
+2824(22)S
+2630 V
+2934(1)S
+2772(7)S
+2824(77)S
+2640 V
+2952(1)S
+2630 V
+2952(1)S
+2640 V
+11 R
+3017(;)S
+11 Y1
+3114(1)S
+2952(2)S
+3004(22)S
+2630 V
+3114(1)S
+2952(7)S
+3004(77)S
+2640 V
+3132(1)S
+2630 V
+3132(1)S
+2640 V
+11 R
+3185(2)S
+11 Y1
+3294(1)S
+3132(2)S
+3184(22)S
+2630 V
+3294(1)S
+3132(7)S
+3184(77)S
+2640 V
+3312(1)S
+2630 V
+3312(1)S
+2640 V
+11 R
+3369(c)S
+11 Y1
+3474(1)S
+3312(2)S
+3364(22)S
+2630 V
+3474(1)S
+3312(7)S
+3364(77)S
+2640 V
+11 R
+3569(\(``I)S
+3790(am)S
+4002(a)S
+4128(VT100)S
+4517(with)S
+4791(Advanced)S
+5312(Video)S
+2800 V
+1980(Option.''\))S
+2960 V
+11 Y1
+900(1)S
+2950 V
+900(1)S
+6 R
+925(ESC)S
+2960 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2950 V
+1062(1)S
+900(7)S
+952(77)S
+2960 V
+1080(1)S
+2950 V
+1080(1)S
+2960 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2950 V
+1242(1)S
+1080(7)S
+1132(77)S
+2960 V
+11 I
+1260(P)S
+2993 V
+9 I
+1305(s)S
+2960 V
+11 Y1
+1358(1)S
+2950 V
+1358(1)S
+2960 V
+11 R
+1423(;)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+2950 V
+1520(1)S
+1358(7)S
+1410(77)S
+2960 V
+11 I
+1538(P)S
+2993 V
+9 I
+1583(s)S
+2960 V
+11 Y1
+1636(1)S
+2950 V
+1636(1)S
+2960 V
+11 R
+1699(f)S
+11 Y1
+1798(1)S
+1636(2)S
+1688(22)S
+2950 V
+1798(1)S
+1636(7)S
+1688(77)S
+2960 V
+11 R
+1980(Horizontal)S
+2482(and)S
+2673(Vertical)S
+3058(Position)S
+3454([row;column])S
+4090(\(default)S
+4463(=)S
+4558([1,1]\))S
+4837(\(HVP\))S
+3120 V
+11 Y1
+900(1)S
+3110 V
+900(1)S
+6 R
+925(ESC)S
+3120 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3110 V
+1062(1)S
+900(7)S
+952(77)S
+3120 V
+1080(1)S
+3110 V
+1080(1)S
+3120 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3110 V
+1242(1)S
+1080(7)S
+1132(77)S
+3120 V
+11 I
+1260(P)S
+3153 V
+9 I
+1305(s)S
+3120 V
+11 Y1
+1358(1)S
+3110 V
+1358(1)S
+3120 V
+11 R
+1411(g)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+3110 V
+1520(1)S
+1358(7)S
+1410(77)S
+3120 V
+11 R
+1980(Tab)S
+2183(Clear)S
+2453(\(TBC\))S
+3280 V
+11 I
+2046(P)S
+3313 V
+9 I
+2091(s)S
+3280 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+3270 V
+2254(1)S
+3280 V
+11 R
+2307(0)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+3270 V
+2416(1)S
+2254(7)S
+2306(77)S
+3280 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(Current)S
+3247(Column)S
+3636(\(default\))S
+3440 V
+11 I
+2046(P)S
+3473 V
+9 I
+2091(s)S
+3440 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+3430 V
+2254(1)S
+3440 V
+11 R
+2307(3)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+3430 V
+2416(1)S
+2254(7)S
+2306(77)S
+3440 V
+11 Y
+2467(\256)S
+11 R
+2609(Clear)S
+2879(All)S
+3600 V
+11 Y1
+900(1)S
+3590 V
+900(1)S
+6 R
+925(ESC)S
+3600 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3590 V
+1062(1)S
+900(7)S
+952(77)S
+3600 V
+1080(1)S
+3590 V
+1080(1)S
+3600 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3590 V
+1242(1)S
+1080(7)S
+1132(77)S
+3600 V
+11 I
+1260(P)S
+3633 V
+9 I
+1305(m)S
+3600 V
+11 Y1
+1388(1)S
+3590 V
+1388(1)S
+3600 V
+11 R
+1441(h)S
+11 Y1
+1550(1)S
+1388(2)S
+1440(22)S
+3590 V
+1550(1)S
+1388(7)S
+1440(77)S
+3600 V
+11 R
+1980(Set)S
+2154(Mode)S
+2443(\(SM\))S
+3760 V
+11 I
+2046(P)S
+3793 V
+9 I
+2091(s)S
+3760 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+3750 V
+2254(1)S
+3760 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+3750 V
+2416(1)S
+2254(7)S
+2306(77)S
+3760 V
+11 Y
+2467(\256)S
+11 R
+2609(Insert)S
+2891(Mode)S
+3180(\(IRM\))S
+3920 V
+11 I
+2046(P)S
+3953 V
+9 I
+2091(s)S
+3920 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+3910 V
+2254(1)S
+3920 V
+11 R
+2307(2)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+3910 V
+2416(1)S
+2254(7)S
+2306(77)S
+3920 V
+2434(1)S
+3910 V
+2434(1)S
+3920 V
+11 R
+2487(0)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+3910 V
+2596(1)S
+2434(7)S
+2486(77)S
+3920 V
+11 Y
+2647(\256)S
+11 R
+2789(Automatic)S
+3286(Newline)S
+3690(\(LNM\))S
+4080 V
+11 Y1
+900(1)S
+4070 V
+900(1)S
+6 R
+925(ESC)S
+4080 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4070 V
+1062(1)S
+900(7)S
+952(77)S
+4080 V
+1080(1)S
+4070 V
+1080(1)S
+4080 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4070 V
+1242(1)S
+1080(7)S
+1132(77)S
+4080 V
+11 I
+1260(P)S
+4113 V
+9 I
+1305(m)S
+4080 V
+11 Y1
+1388(1)S
+4070 V
+1388(1)S
+4080 V
+11 R
+1453(l)S
+11 Y1
+1550(1)S
+1388(2)S
+1440(22)S
+4070 V
+1550(1)S
+1388(7)S
+1440(77)S
+4080 V
+11 R
+1980(Reset)S
+2257(Mode)S
+2546(\(RM\))S
+4240 V
+11 I
+2046(P)S
+4273 V
+9 I
+2091(s)S
+4240 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4230 V
+2254(1)S
+4240 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4230 V
+2416(1)S
+2254(7)S
+2306(77)S
+4240 V
+11 Y
+2467(\256)S
+11 R
+2609(Replace)S
+2994(Mode)S
+3283(\(IRM\))S
+4400 V
+11 I
+2046(P)S
+4433 V
+9 I
+2091(s)S
+4400 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4390 V
+2254(1)S
+4400 V
+11 R
+2307(2)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4390 V
+2416(1)S
+2254(7)S
+2306(77)S
+4400 V
+2434(1)S
+4390 V
+2434(1)S
+4400 V
+11 R
+2487(0)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+4390 V
+2596(1)S
+2434(7)S
+2486(77)S
+4400 V
+11 Y
+2647(\256)S
+11 R
+2789(Normal)S
+3157(Linefeed)S
+3578(\(LNM\))S
+4560 V
+11 Y1
+900(1)S
+4550 V
+900(1)S
+6 R
+925(ESC)S
+4560 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4550 V
+1062(1)S
+900(7)S
+952(77)S
+4560 V
+1080(1)S
+4550 V
+1080(1)S
+4560 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4550 V
+1242(1)S
+1080(7)S
+1132(77)S
+4560 V
+11 I
+1260(P)S
+4593 V
+9 I
+1305(m)S
+4560 V
+11 Y1
+1388(1)S
+4550 V
+1388(1)S
+4560 V
+11 R
+1426(m)S
+11 Y1
+1550(1)S
+1388(2)S
+1440(22)S
+4550 V
+1550(1)S
+1388(7)S
+1440(77)S
+4560 V
+11 R
+1980(Character)S
+2437(Attributes)S
+2910(\(SGR\))S
+4720 V
+11 I
+2046(P)S
+4753 V
+9 I
+2091(s)S
+4720 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4710 V
+2254(1)S
+4720 V
+11 R
+2307(0)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4710 V
+2416(1)S
+2254(7)S
+2306(77)S
+4720 V
+11 Y
+2467(\256)S
+11 R
+2609(Normal)S
+2977(\(default\))S
+4880 V
+11 I
+2046(P)S
+4913 V
+9 I
+2091(s)S
+4880 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4870 V
+2254(1)S
+4880 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4870 V
+2416(1)S
+2254(7)S
+2306(77)S
+4880 V
+11 Y
+2467(\256)S
+11 R
+2609(Bold)S
+5040 V
+11 I
+2046(P)S
+5073 V
+9 I
+2091(s)S
+5040 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5030 V
+2254(1)S
+5040 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5030 V
+2416(1)S
+2254(7)S
+2306(77)S
+5040 V
+11 Y
+2467(\256)S
+11 R
+2609(Underscore)S
+5200 V
+11 I
+2046(P)S
+5233 V
+9 I
+2091(s)S
+5200 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5190 V
+2254(1)S
+5200 V
+11 R
+2307(5)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5190 V
+2416(1)S
+2254(7)S
+2306(77)S
+5200 V
+11 Y
+2467(\256)S
+11 R
+2609(Blink)S
+2888(\(appears)S
+3290(as)S
+3414(Bold\))S
+5360 V
+11 I
+2046(P)S
+5393 V
+9 I
+2091(s)S
+5360 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5350 V
+2254(1)S
+5360 V
+11 R
+2307(7)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5350 V
+2416(1)S
+2254(7)S
+2306(77)S
+5360 V
+11 Y
+2467(\256)S
+11 R
+2609(Inverse)S
+5520 V
+11 Y1
+900(1)S
+5510 V
+900(1)S
+6 R
+925(ESC)S
+5520 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5510 V
+1062(1)S
+900(7)S
+952(77)S
+5520 V
+1080(1)S
+5510 V
+1080(1)S
+5520 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5510 V
+1242(1)S
+1080(7)S
+1132(77)S
+5520 V
+11 I
+1260(P)S
+5553 V
+9 I
+1305(s)S
+5520 V
+11 Y1
+1358(1)S
+5510 V
+1358(1)S
+5520 V
+11 R
+1411(n)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+5510 V
+1520(1)S
+1358(7)S
+1410(77)S
+5520 V
+11 R
+1980(Device)S
+2322(Status)S
+2625(Report)S
+2957(\(DSR\))S
+5680 V
+11 I
+2046(P)S
+5713 V
+9 I
+2091(s)S
+5680 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5670 V
+2254(1)S
+5680 V
+11 R
+2307(5)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5670 V
+2416(1)S
+2254(7)S
+2306(77)S
+5680 V
+11 Y
+2467(\256)S
+11 R
+2609(Status)S
+2912(Report)S
+11 Y1
+3244(1)S
+5670 V
+3244(1)S
+6 R
+3269(ESC)S
+5680 V
+11 Y1
+3406(1)S
+3244(2)S
+3296(22)S
+5670 V
+3406(1)S
+3244(7)S
+3296(77)S
+5680 V
+3424(1)S
+5670 V
+3424(1)S
+5680 V
+11 R
+3487([)S
+11 Y1
+3586(1)S
+3424(2)S
+3476(22)S
+5670 V
+3586(1)S
+3424(7)S
+3476(77)S
+5680 V
+3604(1)S
+5670 V
+3604(1)S
+5680 V
+11 R
+3657(0)S
+11 Y1
+3766(1)S
+3604(2)S
+3656(22)S
+5670 V
+3766(1)S
+3604(7)S
+3656(77)S
+5680 V
+3784(1)S
+5670 V
+3784(1)S
+5680 V
+11 R
+3837(n)S
+11 Y1
+3946(1)S
+3784(2)S
+3836(22)S
+5670 V
+3946(1)S
+3784(7)S
+3836(77)S
+5680 V
+11 R
+3997(\(``OK''\))S
+5840 V
+11 I
+2046(P)S
+5873 V
+9 I
+2091(s)S
+5840 V
+11 R
+2255(=)S
+11 Y1
+2446(1)S
+5830 V
+2446(1)S
+5840 V
+11 R
+2499(6)S
+11 Y1
+2608(1)S
+2446(2)S
+2498(22)S
+5830 V
+2608(1)S
+2446(7)S
+2498(77)S
+5840 V
+11 Y
+2755(\256)S
+11 R
+2993(Report)S
+3422(Cursor)S
+3851(Position)S
+4344(\(CPR\))S
+4756([row;column])S
+5489(as)S
+6000 V
+11 Y1
+1980(1)S
+5990 V
+1980(1)S
+6 R
+2005(ESC)S
+6000 V
+11 Y1
+2142(1)S
+1980(2)S
+2032(22)S
+5990 V
+2142(1)S
+1980(7)S
+2032(77)S
+6000 V
+2160(1)S
+5990 V
+2160(1)S
+6000 V
+11 R
+2223([)S
+11 Y1
+2322(1)S
+2160(2)S
+2212(22)S
+5990 V
+2322(1)S
+2160(7)S
+2212(77)S
+6000 V
+11 I
+2340(r)S
+11 Y1
+2401(1)S
+5990 V
+2401(1)S
+6000 V
+11 R
+2466(;)S
+11 Y1
+2563(1)S
+2401(2)S
+2453(22)S
+5990 V
+2563(1)S
+2401(7)S
+2453(77)S
+6000 V
+11 I
+2581(c)S
+11 Y1
+2647(1)S
+5990 V
+2647(1)S
+6000 V
+11 R
+2691(R)S
+11 Y1
+2809(1)S
+2647(2)S
+2699(22)S
+5990 V
+2809(1)S
+2647(7)S
+2699(77)S
+6160 V
+900(1)S
+6150 V
+900(1)S
+6 R
+925(ESC)S
+6160 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6150 V
+1062(1)S
+900(7)S
+952(77)S
+6160 V
+1080(1)S
+6150 V
+1080(1)S
+6160 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6150 V
+1242(1)S
+1080(7)S
+1132(77)S
+6160 V
+11 I
+1260(P)S
+6193 V
+9 I
+1305(s)S
+6160 V
+11 Y1
+1358(1)S
+6150 V
+1358(1)S
+6160 V
+11 R
+1423(;)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+6150 V
+1520(1)S
+1358(7)S
+1410(77)S
+6160 V
+11 I
+1538(P)S
+6193 V
+9 I
+1583(s)S
+6160 V
+11 Y1
+1636(1)S
+6150 V
+1636(1)S
+6160 V
+11 R
+1699(r)S
+11 Y1
+1798(1)S
+1636(2)S
+1688(22)S
+6150 V
+1798(1)S
+1636(7)S
+1688(77)S
+6160 V
+11 R
+1980(Set)S
+2154(Scrolling)S
+2591(Region)S
+2942([top;bottom])S
+3532(\(default)S
+3905(=)S
+4000(full)S
+4186(size)S
+4389(of)S
+4513(window\))S
+4936(\(DECSTBM\))S
+6320 V
+11 Y1
+900(1)S
+6310 V
+900(1)S
+6 R
+925(ESC)S
+6320 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6310 V
+1062(1)S
+900(7)S
+952(77)S
+6320 V
+1080(1)S
+6310 V
+1080(1)S
+6320 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6310 V
+1242(1)S
+1080(7)S
+1132(77)S
+6320 V
+11 I
+1260(P)S
+6353 V
+9 I
+1305(s)S
+6320 V
+11 Y1
+1358(1)S
+6310 V
+1358(1)S
+6320 V
+11 R
+1411(x)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+6310 V
+1520(1)S
+1358(7)S
+1410(77)S
+6320 V
+11 R
+1980(Request)S
+2367(Terminal)S
+2802(Parameters)S
+3321(\(DECREQTPARM\))S
+6480 V
+11 Y1
+900(1)S
+6470 V
+900(1)S
+6 R
+925(ESC)S
+6480 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6470 V
+1062(1)S
+900(7)S
+952(77)S
+6480 V
+1080(1)S
+6470 V
+1080(1)S
+6480 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6470 V
+1242(1)S
+1080(7)S
+1132(77)S
+6480 V
+1260(1)S
+6470 V
+1260(1)S
+6480 V
+11 R
+1317(?)S
+11 Y1
+1422(1)S
+1260(2)S
+1312(22)S
+6470 V
+1422(1)S
+1260(7)S
+1312(77)S
+6480 V
+11 I
+1440(P)S
+6513 V
+9 I
+1485(m)S
+6480 V
+11 Y1
+1568(1)S
+6470 V
+1568(1)S
+6480 V
+11 R
+1621(h)S
+11 Y1
+1730(1)S
+1568(2)S
+1620(22)S
+6470 V
+1730(1)S
+1568(7)S
+1620(77)S
+6480 V
+11 R
+1980(DEC)S
+2233(Private)S
+2577(Mode)S
+2866(Set)S
+3040(\(DECSET\))S
+6640 V
+11 I
+2046(P)S
+6673 V
+9 I
+2091(s)S
+6640 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+6630 V
+2254(1)S
+6640 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+6630 V
+2416(1)S
+2254(7)S
+2306(77)S
+6640 V
+11 Y
+2467(\256)S
+11 R
+2609(Application)S
+3161(Cursor)S
+3493(Keys)S
+3751(\(DECCKM\))S
+6800 V
+11 I
+2046(P)S
+6833 V
+9 I
+2091(s)S
+6800 V
+11 R
+2174(=)S
+11 Y1
+2284(1)S
+6790 V
+2284(1)S
+6800 V
+11 R
+2337(2)S
+11 Y1
+2446(1)S
+2284(2)S
+2336(22)S
+6790 V
+2446(1)S
+2284(7)S
+2336(77)S
+6800 V
+11 Y
+2512(\256)S
+11 R
+2669(Designate)S
+3155(USASCII)S
+3631(for)S
+3807(character)S
+4254(sets)S
+4468(G0-G3.)S
+4882(\(In)S
+5058(the)S
+5241(VT102,)S
+6960 V
+1980(this)S
+2173(selects)S
+2498(VT52)S
+2787(mode)S
+3064(\(DECANM\),)S
+3673(which)S
+11 I
+3974(xterm)S
+11 R
+4256(doesn't)S
+4612(support.\))S
+7120 V
+11 I
+2046(P)S
+7153 V
+9 I
+2091(s)S
+7120 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+7110 V
+2254(1)S
+7120 V
+11 R
+2307(3)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+7110 V
+2416(1)S
+2254(7)S
+2306(77)S
+7120 V
+11 Y
+2467(\256)S
+11 R
+2609(132)S
+2807(Column)S
+3196(Mode)S
+3485(\(DECCOLM\))S
+7280 V
+11 I
+2046(P)S
+7313 V
+9 I
+2091(s)S
+7280 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+7270 V
+2254(1)S
+7280 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+7270 V
+2416(1)S
+2254(7)S
+2306(77)S
+7280 V
+11 Y
+2467(\256)S
+11 R
+2609(Smooth)S
+2986(\(Slow\))S
+3318(Scroll)S
+3614(\(DECSCLM\))S
+7720 V
+3212(3)S
+7920 V
+EP
+%%Page: 4 4
+BP
+/slant 0 def
+/height 1.000000 def
+11 R
+11 R
+520 V
+900(Xterm Control Sequences)S
+4980(VT100 Mode)S
+880 V
+11 I
+2046(P)S
+913 V
+9 I
+2091(s)S
+880 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+870 V
+2254(1)S
+880 V
+11 R
+2307(5)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+870 V
+2416(1)S
+2254(7)S
+2306(77)S
+880 V
+11 Y
+2467(\256)S
+11 R
+2609(Reverse)S
+2994(Video)S
+3295(\(DECSCNM\))S
+1040 V
+11 I
+2046(P)S
+1073 V
+9 I
+2091(s)S
+1040 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1030 V
+2254(1)S
+1040 V
+11 R
+2307(6)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1030 V
+2416(1)S
+2254(7)S
+2306(77)S
+1040 V
+11 Y
+2467(\256)S
+11 R
+2609(Origin)S
+2929(Mode)S
+3218(\(DECOM\))S
+1200 V
+11 I
+2046(P)S
+1233 V
+9 I
+2091(s)S
+1200 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1190 V
+2254(1)S
+1200 V
+11 R
+2307(7)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1190 V
+2416(1)S
+2254(7)S
+2306(77)S
+1200 V
+11 Y
+2467(\256)S
+11 R
+2609(Wraparound)S
+3188(Mode)S
+3477(\(DECAWM\))S
+1360 V
+11 I
+2046(P)S
+1393 V
+9 I
+2091(s)S
+1360 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1350 V
+2254(1)S
+1360 V
+11 R
+2307(8)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1350 V
+2416(1)S
+2254(7)S
+2306(77)S
+1360 V
+11 Y
+2467(\256)S
+11 R
+2609(Auto-repeat)S
+3164(Keys)S
+3422(\(DECARM\))S
+1520 V
+11 I
+2046(P)S
+1553 V
+9 I
+2091(s)S
+1520 V
+11 R
+2175(=)S
+11 Y1
+2286(1)S
+1510 V
+2286(1)S
+1520 V
+11 R
+2339(9)S
+11 Y1
+2448(1)S
+2286(2)S
+2338(22)S
+1510 V
+2448(1)S
+2286(7)S
+2338(77)S
+1520 V
+11 Y
+2516(\256)S
+11 R
+2675(Send)S
+2945(Mouse)S
+3294(X)S
+3423(&)S
+3559(Y)S
+3688(on)S
+3848(button)S
+4180(press.)S
+4516(See)S
+4724(the)S
+4908(section)S
+11 B
+5269(Mouse)S
+1680 V
+1980(Tracking)S
+11 R
+2415(.)S
+1840 V
+11 I
+2046(P)S
+1873 V
+9 I
+2091(s)S
+1840 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1830 V
+2254(1)S
+1840 V
+11 R
+2307(3)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1830 V
+2416(1)S
+2254(7)S
+2306(77)S
+1840 V
+2434(1)S
+1830 V
+2434(1)S
+1840 V
+11 R
+2487(8)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+1830 V
+2596(1)S
+2434(7)S
+2486(77)S
+1840 V
+11 Y
+2647(\256)S
+11 R
+2789(Enter)S
+3059(Tektronix)S
+3525(Mode)S
+3814(\(DECTEK\))S
+2000 V
+11 I
+2046(P)S
+2033 V
+9 I
+2091(s)S
+2000 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1990 V
+2254(1)S
+2000 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1990 V
+2416(1)S
+2254(7)S
+2306(77)S
+2000 V
+2434(1)S
+1990 V
+2434(1)S
+2000 V
+11 R
+2487(0)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+1990 V
+2596(1)S
+2434(7)S
+2486(77)S
+2000 V
+11 Y
+2647(\256)S
+11 R
+2789(Allow)S
+3097(80)S
+11 Y
+3240(\254)S
+3240(\256)S
+11 R
+3382(132)S
+3580(Mode)S
+2160 V
+11 I
+2046(P)S
+2193 V
+9 I
+2091(s)S
+2160 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+2150 V
+2254(1)S
+2160 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+2150 V
+2416(1)S
+2254(7)S
+2306(77)S
+2160 V
+2434(1)S
+2150 V
+2434(1)S
+2160 V
+11 R
+2487(1)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+2150 V
+2596(1)S
+2434(7)S
+2486(77)S
+2160 V
+11 Y
+2647(\256)S
+11 I
+2789(curses)S
+11 R
+3069(\(5\))S
+3229(\256x)S
+2320 V
+11 I
+2046(P)S
+2353 V
+9 I
+2091(s)S
+2320 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+2310 V
+2254(1)S
+2320 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+2310 V
+2416(1)S
+2254(7)S
+2306(77)S
+2320 V
+2434(1)S
+2310 V
+2434(1)S
+2320 V
+11 R
+2487(4)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+2310 V
+2596(1)S
+2434(7)S
+2486(77)S
+2320 V
+11 Y
+2647(\256)S
+11 R
+2789(Turn)S
+3035(On)S
+3202(Margin)S
+3558(Bell)S
+2480 V
+11 I
+2046(P)S
+2513 V
+9 I
+2091(s)S
+2480 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+2470 V
+2254(1)S
+2480 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+2470 V
+2416(1)S
+2254(7)S
+2306(77)S
+2480 V
+2434(1)S
+2470 V
+2434(1)S
+2480 V
+11 R
+2487(5)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+2470 V
+2596(1)S
+2434(7)S
+2486(77)S
+2480 V
+11 Y
+2647(\256)S
+11 R
+2789(Reverse-wraparound)S
+3732(Mode)S
+2640 V
+11 I
+2046(P)S
+2673 V
+9 I
+2091(s)S
+2640 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+2630 V
+2254(1)S
+2640 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+2630 V
+2416(1)S
+2254(7)S
+2306(77)S
+2640 V
+2434(1)S
+2630 V
+2434(1)S
+2640 V
+11 R
+2487(6)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+2630 V
+2596(1)S
+2434(7)S
+2486(77)S
+2640 V
+11 Y
+2647(\256)S
+11 R
+2789(Start)S
+3030(Logging)S
+2800 V
+11 I
+2046(P)S
+2833 V
+9 I
+2091(s)S
+2800 V
+11 R
+2164(=)S
+11 Y1
+2264(1)S
+2790 V
+2264(1)S
+2800 V
+11 R
+2317(4)S
+11 Y1
+2426(1)S
+2264(2)S
+2316(22)S
+2790 V
+2426(1)S
+2264(7)S
+2316(77)S
+2800 V
+2444(1)S
+2790 V
+2444(1)S
+2800 V
+11 R
+2497(7)S
+11 Y1
+2606(1)S
+2444(2)S
+2496(22)S
+2790 V
+2606(1)S
+2444(7)S
+2496(77)S
+2800 V
+11 Y
+2662(\256)S
+11 R
+2809(Use)S
+3017(Alternate)S
+3463(Screen)S
+3799(Bu)S
+3928 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+3995(er)S
+4118(\(unless)S
+4468(disabled)S
+4873(by)S
+5022(the)S
+11 B
+5195(titeInhi-)S
+2960 V
+1980(bit)S
+11 R
+2142(resource\))S
+3120 V
+11 I
+2046(P)S
+3153 V
+9 I
+2091(s)S
+3120 V
+11 R
+2162(=)S
+11 Y1
+2260(1)S
+3110 V
+2260(1)S
+3120 V
+11 R
+2313(1)S
+11 Y1
+2422(1)S
+2260(2)S
+2312(22)S
+3110 V
+2422(1)S
+2260(7)S
+2312(77)S
+3120 V
+2440(1)S
+3110 V
+2440(1)S
+3120 V
+11 R
+2493(0)S
+11 Y1
+2602(1)S
+2440(2)S
+2492(22)S
+3110 V
+2602(1)S
+2440(7)S
+2492(77)S
+3120 V
+2620(1)S
+3110 V
+2620(1)S
+3120 V
+11 R
+2673(0)S
+11 Y1
+2782(1)S
+2620(2)S
+2672(22)S
+3110 V
+2782(1)S
+2620(7)S
+2672(77)S
+3120 V
+2800(1)S
+3110 V
+2800(1)S
+3120 V
+11 R
+2853(0)S
+11 Y1
+2962(1)S
+2800(2)S
+2852(22)S
+3110 V
+2962(1)S
+2800(7)S
+2852(77)S
+3120 V
+11 Y
+3016(\256)S
+11 R
+3161(Send)S
+3417(Mouse)S
+3752(X)S
+3867(&)S
+3989(Y)S
+4104(on)S
+4250(button)S
+4568(press)S
+4829(and)S
+5023(release.)S
+5422(See)S
+3280 V
+1980(the)S
+2147(section)S
+11 B
+2491(Mouse)S
+2835(Tracking)S
+11 R
+3270(.)S
+3440 V
+11 I
+2046(P)S
+3473 V
+9 I
+2091(s)S
+3440 V
+11 R
+2169(=)S
+11 Y1
+2274(1)S
+3430 V
+2274(1)S
+3440 V
+11 R
+2327(1)S
+11 Y1
+2436(1)S
+2274(2)S
+2326(22)S
+3430 V
+2436(1)S
+2274(7)S
+2326(77)S
+3440 V
+2454(1)S
+3430 V
+2454(1)S
+3440 V
+11 R
+2507(0)S
+11 Y1
+2616(1)S
+2454(2)S
+2506(22)S
+3430 V
+2616(1)S
+2454(7)S
+2506(77)S
+3440 V
+2634(1)S
+3430 V
+2634(1)S
+3440 V
+11 R
+2687(0)S
+11 Y1
+2796(1)S
+2634(2)S
+2686(22)S
+3430 V
+2796(1)S
+2634(7)S
+2686(77)S
+3440 V
+2814(1)S
+3430 V
+2814(1)S
+3440 V
+11 R
+2867(1)S
+11 Y1
+2976(1)S
+2814(2)S
+2866(22)S
+3430 V
+2976(1)S
+2814(7)S
+2866(77)S
+3440 V
+11 Y
+3037(\256)S
+11 R
+3189(Use)S
+3402(Hilite)S
+3696(Mouse)S
+4038(Tracking.)S
+4537(See)S
+4738(the)S
+4915(section)S
+11 B
+5269(Mouse)S
+3600 V
+1980(Tracking)S
+11 R
+2415(.)S
+3760 V
+11 Y1
+900(1)S
+3750 V
+900(1)S
+6 R
+925(ESC)S
+3760 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3750 V
+1062(1)S
+900(7)S
+952(77)S
+3760 V
+1080(1)S
+3750 V
+1080(1)S
+3760 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3750 V
+1242(1)S
+1080(7)S
+1132(77)S
+3760 V
+1260(1)S
+3750 V
+1260(1)S
+3760 V
+11 R
+1317(?)S
+11 Y1
+1422(1)S
+1260(2)S
+1312(22)S
+3750 V
+1422(1)S
+1260(7)S
+1312(77)S
+3760 V
+11 I
+1440(P)S
+3793 V
+9 I
+1485(m)S
+3760 V
+11 Y1
+1568(1)S
+3750 V
+1568(1)S
+3760 V
+11 R
+1633(l)S
+11 Y1
+1730(1)S
+1568(2)S
+1620(22)S
+3750 V
+1730(1)S
+1568(7)S
+1620(77)S
+3760 V
+11 R
+1980(DEC)S
+2233(Private)S
+2577(Mode)S
+2866(Reset)S
+3143(\(DECRST\))S
+3920 V
+11 I
+2046(P)S
+3953 V
+9 I
+2091(s)S
+3920 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+3910 V
+2254(1)S
+3920 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+3910 V
+2416(1)S
+2254(7)S
+2306(77)S
+3920 V
+11 Y
+2467(\256)S
+11 R
+2609(Normal)S
+2977(Cursor)S
+3309(Keys)S
+3567(\(DECCKM\))S
+4080 V
+11 I
+2046(P)S
+4113 V
+9 I
+2091(s)S
+4080 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4070 V
+2254(1)S
+4080 V
+11 R
+2307(3)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4070 V
+2416(1)S
+2254(7)S
+2306(77)S
+4080 V
+11 Y
+2467(\256)S
+11 R
+2609(80)S
+2752(Column)S
+3141(Mode)S
+3430(\(DECCOLM\))S
+4240 V
+11 I
+2046(P)S
+4273 V
+9 I
+2091(s)S
+4240 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4230 V
+2254(1)S
+4240 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4230 V
+2416(1)S
+2254(7)S
+2306(77)S
+4240 V
+11 Y
+2467(\256)S
+11 R
+2609(Jump)S
+2881(\(Fast\))S
+3170(Scroll)S
+3466(\(DECSCLM\))S
+4400 V
+11 I
+2046(P)S
+4433 V
+9 I
+2091(s)S
+4400 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4390 V
+2254(1)S
+4400 V
+11 R
+2307(5)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4390 V
+2416(1)S
+2254(7)S
+2306(77)S
+4400 V
+11 Y
+2467(\256)S
+11 R
+2609(Normal)S
+2977(Video)S
+3278(\(DECSCNM\))S
+4560 V
+11 I
+2046(P)S
+4593 V
+9 I
+2091(s)S
+4560 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4550 V
+2254(1)S
+4560 V
+11 R
+2307(6)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4550 V
+2416(1)S
+2254(7)S
+2306(77)S
+4560 V
+11 Y
+2467(\256)S
+11 R
+2609(Normal)S
+2977(Cursor)S
+3309(Mode)S
+3598(\(DECOM\))S
+4720 V
+11 I
+2046(P)S
+4753 V
+9 I
+2091(s)S
+4720 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4710 V
+2254(1)S
+4720 V
+11 R
+2307(7)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4710 V
+2416(1)S
+2254(7)S
+2306(77)S
+4720 V
+11 Y
+2467(\256)S
+11 R
+2609(No)S
+2776(Wraparound)S
+3355(Mode)S
+3644(\(DECAWM\))S
+4880 V
+11 I
+2046(P)S
+4913 V
+9 I
+2091(s)S
+4880 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+4870 V
+2254(1)S
+4880 V
+11 R
+2307(8)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+4870 V
+2416(1)S
+2254(7)S
+2306(77)S
+4880 V
+11 Y
+2467(\256)S
+11 R
+2609(No)S
+2776(Auto-repeat)S
+3331(Keys)S
+3589(\(DECARM\))S
+5040 V
+11 I
+2046(P)S
+5073 V
+9 I
+2091(s)S
+5040 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5030 V
+2254(1)S
+5040 V
+11 R
+2307(9)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5030 V
+2416(1)S
+2254(7)S
+2306(77)S
+5040 V
+11 Y
+2467(\256)S
+11 R
+2609(Don't)S
+2898(Send)S
+3151(Mouse)S
+3483(X)S
+3595(&)S
+3714(Y)S
+3826(on)S
+3969(button)S
+4284(press)S
+5200 V
+11 I
+2046(P)S
+5233 V
+9 I
+2091(s)S
+5200 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5190 V
+2254(1)S
+5200 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5190 V
+2416(1)S
+2254(7)S
+2306(77)S
+5200 V
+2434(1)S
+5190 V
+2434(1)S
+5200 V
+11 R
+2487(0)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+5190 V
+2596(1)S
+2434(7)S
+2486(77)S
+5200 V
+11 Y
+2647(\256)S
+11 R
+2789(Disallow)S
+3219(80)S
+11 Y
+3362(\254)S
+3362(\256)S
+11 R
+3504(132)S
+3702(Mode)S
+5360 V
+11 I
+2046(P)S
+5393 V
+9 I
+2091(s)S
+5360 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5350 V
+2254(1)S
+5360 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5350 V
+2416(1)S
+2254(7)S
+2306(77)S
+5360 V
+2434(1)S
+5350 V
+2434(1)S
+5360 V
+11 R
+2487(1)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+5350 V
+2596(1)S
+2434(7)S
+2486(77)S
+5360 V
+11 Y
+2647(\256)S
+11 R
+2789(No)S
+11 I
+2956(curses)S
+11 R
+3236(\(5\))S
+3396(\256x)S
+5520 V
+11 I
+2046(P)S
+5553 V
+9 I
+2091(s)S
+5520 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5510 V
+2254(1)S
+5520 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5510 V
+2416(1)S
+2254(7)S
+2306(77)S
+5520 V
+2434(1)S
+5510 V
+2434(1)S
+5520 V
+11 R
+2487(4)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+5510 V
+2596(1)S
+2434(7)S
+2486(77)S
+5520 V
+11 Y
+2647(\256)S
+11 R
+2789(Turn)S
+3035(O)S
+3114 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+3214(Margin)S
+3570(Bell)S
+5680 V
+11 I
+2046(P)S
+5713 V
+9 I
+2091(s)S
+5680 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5670 V
+2254(1)S
+5680 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5670 V
+2416(1)S
+2254(7)S
+2306(77)S
+5680 V
+2434(1)S
+5670 V
+2434(1)S
+5680 V
+11 R
+2487(5)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+5670 V
+2596(1)S
+2434(7)S
+2486(77)S
+5680 V
+11 Y
+2647(\256)S
+11 R
+2789(No)S
+2956(Reverse-wraparound)S
+3899(Mode)S
+5840 V
+11 I
+2046(P)S
+5873 V
+9 I
+2091(s)S
+5840 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5830 V
+2254(1)S
+5840 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5830 V
+2416(1)S
+2254(7)S
+2306(77)S
+5840 V
+2434(1)S
+5830 V
+2434(1)S
+5840 V
+11 R
+2487(6)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+5830 V
+2596(1)S
+2434(7)S
+2486(77)S
+5840 V
+11 Y
+2647(\256)S
+11 R
+2789(Stop)S
+3025(Logging)S
+6000 V
+11 I
+2046(P)S
+6033 V
+9 I
+2091(s)S
+6000 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5990 V
+2254(1)S
+6000 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5990 V
+2416(1)S
+2254(7)S
+2306(77)S
+6000 V
+2434(1)S
+5990 V
+2434(1)S
+6000 V
+11 R
+2487(7)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+5990 V
+2596(1)S
+2434(7)S
+2486(77)S
+6000 V
+11 Y
+2647(\256)S
+11 R
+2789(Use)S
+2992(Normal)S
+3360(Screen)S
+3690(Bu)S
+3819 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+3886(er)S
+6160 V
+11 I
+2046(P)S
+6193 V
+9 I
+2091(s)S
+6160 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+6150 V
+2254(1)S
+6160 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+6150 V
+2416(1)S
+2254(7)S
+2306(77)S
+6160 V
+2434(1)S
+6150 V
+2434(1)S
+6160 V
+11 R
+2487(0)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+6150 V
+2596(1)S
+2434(7)S
+2486(77)S
+6160 V
+2614(1)S
+6150 V
+2614(1)S
+6160 V
+11 R
+2667(0)S
+11 Y1
+2776(1)S
+2614(2)S
+2666(22)S
+6150 V
+2776(1)S
+2614(7)S
+2666(77)S
+6160 V
+2794(1)S
+6150 V
+2794(1)S
+6160 V
+11 R
+2847(0)S
+11 Y1
+2956(1)S
+2794(2)S
+2846(22)S
+6150 V
+2956(1)S
+2794(7)S
+2846(77)S
+6160 V
+11 Y
+3007(\256)S
+11 R
+3149(Don't)S
+3438(Send)S
+3691(Mouse)S
+4023(X)S
+4135(&)S
+4254(Y)S
+4366(on)S
+4509(button)S
+4824(press)S
+5082(and)S
+5273(release)S
+6320 V
+11 I
+2046(P)S
+6353 V
+9 I
+2091(s)S
+6320 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+6310 V
+2254(1)S
+6320 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+6310 V
+2416(1)S
+2254(7)S
+2306(77)S
+6320 V
+2434(1)S
+6310 V
+2434(1)S
+6320 V
+11 R
+2487(0)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+6310 V
+2596(1)S
+2434(7)S
+2486(77)S
+6320 V
+2614(1)S
+6310 V
+2614(1)S
+6320 V
+11 R
+2667(0)S
+11 Y1
+2776(1)S
+2614(2)S
+2666(22)S
+6310 V
+2776(1)S
+2614(7)S
+2666(77)S
+6320 V
+2794(1)S
+6310 V
+2794(1)S
+6320 V
+11 R
+2847(1)S
+11 Y1
+2956(1)S
+2794(2)S
+2846(22)S
+6310 V
+2956(1)S
+2794(7)S
+2846(77)S
+6320 V
+11 Y
+3007(\256)S
+11 R
+3149(Don't)S
+3438(Use)S
+3641(Hilite)S
+3925(Mouse)S
+4257(Tracking)S
+6480 V
+11 Y1
+900(1)S
+6470 V
+900(1)S
+6 R
+925(ESC)S
+6480 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6470 V
+1062(1)S
+900(7)S
+952(77)S
+6480 V
+1080(1)S
+6470 V
+1080(1)S
+6480 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6470 V
+1242(1)S
+1080(7)S
+1132(77)S
+6480 V
+1260(1)S
+6470 V
+1260(1)S
+6480 V
+11 R
+1317(?)S
+11 Y1
+1422(1)S
+1260(2)S
+1312(22)S
+6470 V
+1422(1)S
+1260(7)S
+1312(77)S
+6480 V
+11 I
+1440(P)S
+6513 V
+9 I
+1485(m)S
+6480 V
+11 Y1
+1568(1)S
+6470 V
+1568(1)S
+6480 V
+11 R
+1631(r)S
+11 Y1
+1730(1)S
+1568(2)S
+1620(22)S
+6470 V
+1730(1)S
+1568(7)S
+1620(77)S
+6480 V
+11 R
+1980(Restore)S
+2383(DEC)S
+2671(Private)S
+3050(Mode)S
+3374(Values.)S
+3807(The)S
+4045(value)S
+4350(of)S
+11 I
+4509(P)S
+6513 V
+9 I
+4554(s)S
+6480 V
+11 R
+4657(previously)S
+5189(saved)S
+5506(is)S
+6640 V
+1980(restored.)S
+11 I
+2426(P)S
+6673 V
+9 I
+2471(s)S
+6640 V
+11 R
+2539(values)S
+2852(are)S
+3017(the)S
+3184(same)S
+3442(as)S
+3566(for)S
+3726(DECSET.)S
+6800 V
+11 Y1
+900(1)S
+6790 V
+900(1)S
+6 R
+925(ESC)S
+6800 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6790 V
+1062(1)S
+900(7)S
+952(77)S
+6800 V
+1080(1)S
+6790 V
+1080(1)S
+6800 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6790 V
+1242(1)S
+1080(7)S
+1132(77)S
+6800 V
+1260(1)S
+6790 V
+1260(1)S
+6800 V
+11 R
+1317(?)S
+11 Y1
+1422(1)S
+1260(2)S
+1312(22)S
+6790 V
+1422(1)S
+1260(7)S
+1312(77)S
+6800 V
+11 I
+1440(P)S
+6833 V
+9 I
+1485(m)S
+6800 V
+11 Y1
+1568(1)S
+6790 V
+1568(1)S
+6800 V
+11 R
+1627(s)S
+11 Y1
+1730(1)S
+1568(2)S
+1620(22)S
+6790 V
+1730(1)S
+1568(7)S
+1620(77)S
+6800 V
+11 R
+1980(Save)S
+2226(DEC)S
+2479(Private)S
+2823(Mode)S
+3112(Values.)S
+11 I
+3510(P)S
+6833 V
+9 I
+3555(s)S
+6800 V
+11 R
+3623(values)S
+3936(are)S
+4101(the)S
+4268(same)S
+4526(as)S
+4650(for)S
+4810(DECSET.)S
+7720 V
+3212(4)S
+7920 V
+EP
+%%Page: 5 5
+BP
+/slant 0 def
+/height 1.000000 def
+11 R
+11 R
+520 V
+900(Xterm Control Sequences)S
+4980(VT100 Mode)S
+880 V
+11 Y1
+900(1)S
+870 V
+900(1)S
+6 R
+925(ESC)S
+880 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+870 V
+1062(1)S
+900(7)S
+952(77)S
+880 V
+1080(1)S
+870 V
+1080(1)S
+880 V
+11 R
+1143(])S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+870 V
+1242(1)S
+1080(7)S
+1132(77)S
+880 V
+11 I
+1260(P)S
+913 V
+9 I
+1305(s)S
+880 V
+11 Y1
+1358(1)S
+870 V
+1358(1)S
+880 V
+11 R
+1423(;)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+870 V
+1520(1)S
+1358(7)S
+1410(77)S
+880 V
+11 I
+1538(P)S
+913 V
+9 I
+1583(t)S
+880 V
+11 Y1
+1626(1)S
+870 V
+1626(1)S
+6 R
+1650(BEL)S
+880 V
+11 Y1
+1788(1)S
+1626(2)S
+1678(22)S
+870 V
+1788(1)S
+1626(7)S
+1678(77)S
+880 V
+11 R
+1980(Set)S
+2154(Text)S
+2388(Parameters)S
+1040 V
+11 I
+2046(P)S
+1073 V
+9 I
+2091(s)S
+1040 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1030 V
+2254(1)S
+1040 V
+11 R
+2307(0)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1030 V
+2416(1)S
+2254(7)S
+2306(77)S
+1040 V
+11 Y
+2467(\256)S
+11 R
+2609(Change)S
+2977(Icon)S
+3204(Name)S
+3498(and)S
+3689(Window)S
+4100(Title)S
+4341(to)S
+11 I
+4460(P)S
+1073 V
+9 I
+4505(t)S
+1200 V
+11 I
+2046(P)S
+1233 V
+9 I
+2091(s)S
+1200 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1190 V
+2254(1)S
+1200 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1190 V
+2416(1)S
+2254(7)S
+2306(77)S
+1200 V
+11 Y
+2467(\256)S
+11 R
+2609(Change)S
+2977(Icon)S
+3204(Name)S
+3498(to)S
+11 I
+3617(P)S
+1233 V
+9 I
+3662(t)S
+1360 V
+11 I
+2046(P)S
+1393 V
+9 I
+2091(s)S
+1360 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1350 V
+2254(1)S
+1360 V
+11 R
+2307(2)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1350 V
+2416(1)S
+2254(7)S
+2306(77)S
+1360 V
+11 Y
+2467(\256)S
+11 R
+2609(Change)S
+2977(Window)S
+3388(Title)S
+3629(to)S
+11 I
+3748(P)S
+1393 V
+9 I
+3793(t)S
+1520 V
+11 I
+2046(P)S
+1553 V
+9 I
+2091(s)S
+1520 V
+11 R
+2167(=)S
+11 Y1
+2270(1)S
+1510 V
+2270(1)S
+1520 V
+11 R
+2323(4)S
+11 Y1
+2432(1)S
+2270(2)S
+2322(22)S
+1510 V
+2432(1)S
+2270(7)S
+2322(77)S
+1520 V
+2450(1)S
+1510 V
+2450(1)S
+1520 V
+11 R
+2503(6)S
+11 Y1
+2612(1)S
+2450(2)S
+2502(22)S
+1510 V
+2612(1)S
+2450(7)S
+2502(77)S
+1520 V
+11 Y
+2671(\256)S
+11 R
+2821(Change)S
+3197(Log)S
+3415(File)S
+3629(to)S
+11 I
+3757(P)S
+1553 V
+9 I
+3802(t)S
+1520 V
+11 R
+3869(\(normally)S
+4344(disabled)S
+4752(by)S
+4904(a)S
+4994(compile-time)S
+1680 V
+1980(option\))S
+1840 V
+11 I
+2046(P)S
+1873 V
+9 I
+2091(s)S
+1840 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+1830 V
+2254(1)S
+1840 V
+11 R
+2307(5)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+1830 V
+2416(1)S
+2254(7)S
+2306(77)S
+1840 V
+2434(1)S
+1830 V
+2434(1)S
+1840 V
+11 R
+2487(0)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+1830 V
+2596(1)S
+2434(7)S
+2486(77)S
+1840 V
+11 Y
+2647(\256)S
+11 R
+2789(Set)S
+2963(Font)S
+3199(to)S
+11 I
+3318(P)S
+1873 V
+9 I
+3363(t)S
+2000 V
+11 Y1
+900(1)S
+1990 V
+900(1)S
+6 R
+925(ESC)S
+2000 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1990 V
+1062(1)S
+900(7)S
+952(77)S
+2000 V
+1080(1)S
+1990 V
+1080(1)S
+2000 V
+11 R
+1135(^)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1990 V
+1242(1)S
+1080(7)S
+1132(77)S
+2000 V
+11 I
+1260(P)S
+2033 V
+9 I
+1305(t)S
+2000 V
+11 Y1
+1348(1)S
+1990 V
+1348(1)S
+6 R
+1373(ESC)S
+2000 V
+11 Y1
+1510(1)S
+1348(2)S
+1400(22)S
+1990 V
+1510(1)S
+1348(7)S
+1400(77)S
+2000 V
+1528(1)S
+1990 V
+1528(1)S
+2000 V
+11 R
+1593(\\)S
+11 Y1
+1690(1)S
+1528(2)S
+1580(22)S
+1990 V
+1690(1)S
+1528(7)S
+1580(77)S
+2000 V
+11 R
+1980(Privacy)S
+2348(Message)S
+2764(\(PM\))S
+2160 V
+11 I
+2046(xterm)S
+11 R
+2345(implements)S
+2910(no)S
+3071(PM)S
+3282(functions;)S
+11 I
+3773(P)S
+2193 V
+9 I
+3818(t)S
+2160 V
+11 R
+3894(is)S
+4019(ignored.)S
+11 I
+4466(P)S
+2193 V
+9 I
+4511(t)S
+2160 V
+11 R
+4587(need)S
+4844(not)S
+5036(be)S
+5190(printable)S
+2320 V
+1980(characters.)S
+2480 V
+11 Y1
+900(1)S
+2470 V
+900(1)S
+6 R
+925(ESC)S
+2480 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2470 V
+1062(1)S
+900(7)S
+952(77)S
+2480 V
+1080(1)S
+2470 V
+1080(1)S
+2480 V
+11 R
+1133(_)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2470 V
+1242(1)S
+1080(7)S
+1132(77)S
+2480 V
+11 I
+1260(P)S
+2513 V
+9 I
+1305(t)S
+2480 V
+11 Y1
+1348(1)S
+2470 V
+1348(1)S
+6 R
+1373(ESC)S
+2480 V
+11 Y1
+1510(1)S
+1348(2)S
+1400(22)S
+2470 V
+1510(1)S
+1348(7)S
+1400(77)S
+2480 V
+1528(1)S
+2470 V
+1528(1)S
+2480 V
+11 R
+1593(\\)S
+11 Y1
+1690(1)S
+1528(2)S
+1580(22)S
+2470 V
+1690(1)S
+1528(7)S
+1580(77)S
+2480 V
+11 R
+1980(Application)S
+2532(Program)S
+2943(Command)S
+3435(\(APC\))S
+2640 V
+11 I
+2046(xterm)S
+11 R
+2341(implements)S
+2901(no)S
+3057(APC)S
+3318(functions;)S
+11 I
+3804(P)S
+2673 V
+9 I
+3849(t)S
+2640 V
+11 R
+3920(is)S
+4040(ignored.)S
+11 I
+4482(P)S
+2673 V
+9 I
+4527(t)S
+2640 V
+11 R
+4599(need)S
+4852(not)S
+5040(be)S
+5190(printable)S
+2800 V
+1980(characters.)S
+2960 V
+11 Y1
+900(1)S
+2950 V
+900(1)S
+6 R
+925(ESC)S
+2960 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2950 V
+1062(1)S
+900(7)S
+952(77)S
+2960 V
+1080(1)S
+2950 V
+1080(1)S
+2960 V
+11 R
+1137(c)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2950 V
+1242(1)S
+1080(7)S
+1132(77)S
+2960 V
+11 R
+1980(Full)S
+2192(Reset)S
+2469(\(RIS\))S
+3120 V
+11 Y1
+900(1)S
+3110 V
+900(1)S
+6 R
+925(ESC)S
+3120 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3110 V
+1062(1)S
+900(7)S
+952(77)S
+3120 V
+1080(1)S
+3110 V
+1080(1)S
+3120 V
+11 R
+1133(n)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3110 V
+1242(1)S
+1080(7)S
+1132(77)S
+3120 V
+11 R
+1980(Select)S
+2281(the)S
+2448(G2)S
+2615(Character)S
+3072(Set)S
+3246(\(LS2\))S
+3280 V
+11 Y1
+900(1)S
+3270 V
+900(1)S
+6 R
+925(ESC)S
+3280 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3270 V
+1062(1)S
+900(7)S
+952(77)S
+3280 V
+1080(1)S
+3270 V
+1080(1)S
+3280 V
+11 R
+1133(o)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3270 V
+1242(1)S
+1080(7)S
+1132(77)S
+3280 V
+11 R
+1980(Select)S
+2281(the)S
+2448(G3)S
+2615(Character)S
+3072(Set)S
+3246(\(LS3\))S
+3440 V
+11 Y1
+900(1)S
+3430 V
+900(1)S
+6 R
+925(ESC)S
+3440 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3430 V
+1062(1)S
+900(7)S
+952(77)S
+3440 V
+1080(1)S
+3430 V
+1080(1)S
+3440 V
+11 R
+1150(|)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3430 V
+1242(1)S
+1080(7)S
+1132(77)S
+3440 V
+11 R
+1980(Invoke)S
+2317(the)S
+2484(G3)S
+2651(Character)S
+3108(Set)S
+3282(as)S
+3406(GR)S
+3592(\(LS3R\).)S
+4016(Has)S
+4219(no)S
+4362(visible)S
+4689(e)S
+4737 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+4804(ect)S
+4964(in)S
+11 I
+5083(xterm)S
+11 R
+5332(.)S
+3600 V
+11 Y1
+900(1)S
+3590 V
+900(1)S
+6 R
+925(ESC)S
+3600 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3590 V
+1062(1)S
+900(7)S
+952(77)S
+3600 V
+1080(1)S
+3590 V
+1080(1)S
+3600 V
+11 R
+1134(})S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3590 V
+1242(1)S
+1080(7)S
+1132(77)S
+3600 V
+11 R
+1980(Invoke)S
+2317(the)S
+2484(G2)S
+2651(Character)S
+3108(Set)S
+3282(as)S
+3406(GR)S
+3592(\(LS2R\).)S
+4016(Has)S
+4219(no)S
+4362(visible)S
+4689(e)S
+4737 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+4804(ect)S
+4964(in)S
+11 I
+5083(xterm)S
+11 R
+5332(.)S
+3760 V
+11 Y1
+900(1)S
+3750 V
+900(1)S
+6 R
+925(ESC)S
+3760 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3750 V
+1062(1)S
+900(7)S
+952(77)S
+3760 V
+1080(1)S
+3750 V
+1080(1)S
+3760 V
+11 R
+1131(~)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3750 V
+1242(1)S
+1080(7)S
+1132(77)S
+3760 V
+11 R
+1980(Invoke)S
+2317(the)S
+2484(G1)S
+2651(Character)S
+3108(Set)S
+3282(as)S
+3406(GR)S
+3592(\(LS1R\).)S
+4016(Has)S
+4219(no)S
+4362(visible)S
+4689(e)S
+4737 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+4804(ect)S
+4964(in)S
+11 I
+5083(xterm)S
+11 R
+5332(.)S
+4000 V
+11 B
+900(Mouse)S
+1244(Tracking)S
+4168 V
+11 R
+900(The)S
+1110(VT)S
+1296(widget)S
+1635(can)S
+1826(be)S
+1970(set)S
+2133(to)S
+2260(send)S
+2502(the)S
+2677(mouse)S
+3005(position)S
+3402(and)S
+3601(other)S
+3867(information)S
+4427(on)S
+4578(button)S
+4901(presses.)S
+5319(These)S
+4288 V
+900(modes)S
+1238(are)S
+1421(typically)S
+1857(used)S
+2109(by)S
+2270(editors)S
+2620(and)S
+2829(other)S
+3105(full-screen)S
+3623(applications)S
+4205(that)S
+4421(want)S
+4685(to)S
+4822(make)S
+5109(use)S
+5305(of)S
+5446(the)S
+4408 V
+900(mouse.)S
+4576 V
+900(There)S
+1200(are)S
+1378(three)S
+1642(mutually)S
+2081(exclusive)S
+2542(modes,)S
+2904(each)S
+3150(enabled)S
+3537(\(or)S
+3711(disabled\))S
+4160(by)S
+4317(a)S
+4412(di)S
+4498 H
+ (f)show 11 -.5 mul h (f)show
+11 R
+4565(erent)S
+4830(parameter)S
+5313(in)S
+5446(the)S
+4696 V
+900(DECSET)S
+1350(\(or)S
+1511(DECRST\))S
+2004(escape)S
+2328(sequence.)S
+2823(Parameters)S
+3342(for)S
+3502(all)S
+3645(mouse)S
+3965(tracking)S
+4357(escape)S
+4680(sequences)S
+5156(generated)S
+4816 V
+900(by)S
+11 I
+1051(xterm)S
+11 R
+1342(encode)S
+1693(numeric)S
+2094(parameters)S
+2615(in)S
+2743(a)S
+2833(single)S
+3138(character)S
+3578(as)S
+11 I
+3711(value)S
+11 R
+3948(+040.)S
+4278(For)S
+4473(example,)S
+11 Y1
+4914(1)S
+4806 V
+4914(1)S
+4816 V
+11 R
+4977(!)S
+11 Y1
+5076(1)S
+4914(2)S
+4966(22)S
+4806 V
+5076(1)S
+4914(7)S
+4966(77)S
+4816 V
+11 R
+5136(is)S
+5252(1.)S
+5410(The)S
+4936 V
+900(screen)S
+1211(coodinate)S
+1670(system)S
+2009(is)S
+2116(1-based.)S
+5104 V
+900(X10)S
+1124(compatibility)S
+1747(mode)S
+2026(sends)S
+2305(an)S
+2444(escape)S
+2770(sequence)S
+3206(on)S
+3352(button)S
+3670(press)S
+3931(encoding)S
+4369(the)S
+4539(location)S
+4929(and)S
+5123(the)S
+5293(mouse)S
+5224 V
+900(button)S
+1232(pressed.)S
+1671(It)S
+1788(is)S
+1912(enabled)S
+2302(by)S
+2462(specifying)S
+2969(parameter)S
+3455(9)S
+3560(to)S
+3696(DECSET.)S
+4222(On)S
+4405(button)S
+4736(press,)S
+11 I
+5038(xterm)S
+11 R
+5336(sends)S
+5344 V
+11 Y1
+900(1)S
+5334 V
+900(1)S
+6 R
+925(ESC)S
+5344 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5334 V
+1062(1)S
+900(7)S
+952(77)S
+5344 V
+1080(1)S
+5334 V
+1080(1)S
+5344 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5334 V
+1242(1)S
+1080(7)S
+1132(77)S
+5344 V
+1260(1)S
+5334 V
+1260(1)S
+5344 V
+11 R
+1292(M)S
+11 Y1
+1422(1)S
+1260(2)S
+1312(22)S
+5334 V
+1422(1)S
+1260(7)S
+1312(77)S
+5344 V
+11 I
+1440(C)S
+5377 V
+9 I
+1492(b)S
+5344 V
+11 I
+1537(C)S
+5377 V
+9 I
+1589(x)S
+5344 V
+11 I
+1629(C)S
+5377 V
+9 I
+1681(y)S
+5344 V
+11 R
+1762(\(6)S
+1895(characters\).)S
+11 I
+2475(C)S
+5377 V
+9 I
+2527(b)S
+5344 V
+11 R
+2614(is)S
+2730(button\2611.)S
+11 I
+3225(C)S
+5377 V
+9 I
+3277(x)S
+5344 V
+11 R
+3359(and)S
+11 I
+3559(C)S
+5377 V
+9 I
+3611(y)S
+5344 V
+11 R
+3693(are)S
+3867(the)S
+4043(x)S
+4140(and)S
+4340(y)S
+4437(coordinates)S
+4984(of)S
+5117(the)S
+5293(mouse)S
+5464 V
+900(when)S
+1170(the)S
+1337(button)S
+1652(was)S
+1855(pressed.)S
+5632 V
+900(Normal)S
+1268(tracking)S
+1660(mode)S
+1937(sends)S
+2214(an)S
+2350(escape)S
+2673(sequence)S
+3106(on)S
+3249(both)S
+3478(button)S
+3794(press)S
+4053(and)S
+4245(release.)S
+4642(Modi\256er)S
+5061(information)S
+5752 V
+900(is)S
+1011(also)S
+1224(sent.)S
+1498(It)S
+1601(is)S
+1711(enabled)S
+2087(by)S
+2233(specifying)S
+2726(parameter)S
+3198(1000)S
+3454(to)S
+3576(DECSET.)S
+4089(On)S
+4259(button)S
+4577(press)S
+4838(or)S
+4965(release,)S
+11 I
+5331(xterm)S
+5872 V
+11 R
+900(sends)S
+11 Y1
+1184(1)S
+5862 V
+1184(1)S
+6 R
+1209(ESC)S
+5872 V
+11 Y1
+1346(1)S
+1184(2)S
+1236(22)S
+5862 V
+1346(1)S
+1184(7)S
+1236(77)S
+5872 V
+1364(1)S
+5862 V
+1364(1)S
+5872 V
+11 R
+1427([)S
+11 Y1
+1526(1)S
+1364(2)S
+1416(22)S
+5862 V
+1526(1)S
+1364(7)S
+1416(77)S
+5872 V
+1544(1)S
+5862 V
+1544(1)S
+5872 V
+11 R
+1576(M)S
+11 Y1
+1706(1)S
+1544(2)S
+1596(22)S
+5862 V
+1706(1)S
+1544(7)S
+1596(77)S
+5872 V
+11 I
+1724(C)S
+5905 V
+9 I
+1776(b)S
+5872 V
+11 I
+1821(C)S
+5905 V
+9 I
+1873(x)S
+5872 V
+11 I
+1913(C)S
+5905 V
+9 I
+1965(y)S
+5872 V
+11 R
+2005(.)S
+2106(The)S
+2316(low)S
+2521(two)S
+2726(bits)S
+2926(of)S
+11 I
+3057(C)S
+5905 V
+9 I
+3109(b)S
+5872 V
+11 R
+3194(encode)S
+3543(button)S
+3865(information:)S
+4455(0=MB1)S
+4839(pressed,)S
+5236(1=MB2)S
+5992 V
+900(pressed,)S
+1294(2=MB3)S
+1675(pressed,)S
+2068(3=release.)S
+2585(The)S
+2792(upper)S
+3078(bits)S
+3275(encode)S
+3621(what)S
+3871(modi\256ers)S
+4324(were)S
+4572(down)S
+4853(when)S
+5127(the)S
+5298(button)S
+6112 V
+900(was)S
+1112(pressed)S
+1482(and)S
+1682(are)S
+1856(added)S
+2159(together.)S
+2621(4=Shift,)S
+3023(8=Meta,)S
+3435(16=Control.)S
+11 I
+4047(C)S
+6145 V
+9 I
+4099(x)S
+6112 V
+11 R
+4181(and)S
+11 I
+4381(C)S
+6145 V
+9 I
+4433(y)S
+6112 V
+11 R
+4515(are)S
+4690(the)S
+4867(x)S
+4965(and)S
+5166(y)S
+5264(coordi-)S
+6232 V
+900(nates)S
+1158(of)S
+1282(the)S
+1449(mouse)S
+1769(event.)S
+2100(The)S
+2303(upper)S
+2585(left)S
+2764(corner)S
+3075(is)S
+3182(\(1,1\).)S
+6400 V
+900(Mouse)S
+1239(hilite)S
+1506(tracking)S
+1905(noti\256es)S
+2270(a)S
+2358(program)S
+2769(of)S
+2900(a)S
+2988(button)S
+3310(press,)S
+3603(receives)S
+4000(a)S
+4088(range)S
+4371(of)S
+4503(lines)S
+4752(from)S
+5006(the)S
+5181(program,)S
+6520 V
+900(highlights)S
+1387(the)S
+1566(region)S
+1891(covered)S
+2281(by)S
+2436(the)S
+2615(mouse)S
+2947(within)S
+3274(that)S
+3484(range)S
+3771(until)S
+4019(button)S
+4346(release,)S
+4721(and)S
+4924(then)S
+5158(sends)S
+5446(the)S
+6640 V
+900(program)S
+1305(the)S
+1473(release)S
+1809(coordinates.)S
+2409(It)S
+2510(is)S
+2618(enabled)S
+2992(by)S
+3136(specifying)S
+3627(parameter)S
+4097(1001)S
+4352(to)S
+4473(DECSET.)S
+4985(Warning:)S
+5434(use)S
+6760 V
+900(of)S
+1029(this)S
+1227(mode)S
+1509(requires)S
+1899(a)S
+1985(cooperating)S
+2540(program)S
+2949(or)S
+3078(it)S
+3178(will)S
+3387(hang)S
+11 I
+3637(xterm.)S
+11 R
+3984(On)S
+4155(button)S
+4474(press,)S
+4764(the)S
+4935(same)S
+5197(informa-)S
+6880 V
+900(tion)S
+1107(as)S
+1233(for)S
+1395(normal)S
+1741(tracking)S
+2135(is)S
+2245(generated;)S
+11 I
+2736(xterm)S
+11 R
+3021(then)S
+3246(waits)S
+3514(for)S
+3677(the)S
+3847(program)S
+4254(to)S
+4376(send)S
+4613(mouse)S
+4936(tracking)S
+5331(infor-)S
+7000 V
+900(mation.)S
+11 I
+1339(All)S
+1540(X)S
+1679(events)S
+2023(are)S
+2240(ignored)S
+2653(until)S
+2927(the)S
+3132(proper)S
+3502(escape)S
+3870(sequence)S
+4341(is)S
+4486(received)S
+4926(from)S
+5205(the)S
+5410(pty:)S
+7120 V
+11 Y1
+900(1)S
+7110 V
+900(1)S
+6 R
+925(ESC)S
+7120 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+7110 V
+1062(1)S
+900(7)S
+952(77)S
+7120 V
+1080(1)S
+7110 V
+1080(1)S
+7120 V
+11 R
+1143([)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+7110 V
+1242(1)S
+1080(7)S
+1132(77)S
+7120 V
+11 I
+1260(P)S
+7153 V
+9 I
+1305(s)S
+7120 V
+11 Y1
+1358(1)S
+7110 V
+1358(1)S
+7120 V
+11 R
+1423(;)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+7110 V
+1520(1)S
+1358(7)S
+1410(77)S
+7120 V
+11 I
+1538(P)S
+7153 V
+9 I
+1583(s)S
+7120 V
+11 Y1
+1636(1)S
+7110 V
+1636(1)S
+7120 V
+11 R
+1701(;)S
+11 Y1
+1798(1)S
+1636(2)S
+1688(22)S
+7110 V
+1798(1)S
+1636(7)S
+1688(77)S
+7120 V
+11 I
+1816(P)S
+7153 V
+9 I
+1861(s)S
+7120 V
+11 Y1
+1914(1)S
+7110 V
+1914(1)S
+7120 V
+11 R
+1979(;)S
+11 Y1
+2076(1)S
+1914(2)S
+1966(22)S
+7110 V
+2076(1)S
+1914(7)S
+1966(77)S
+7120 V
+11 I
+2094(P)S
+7153 V
+9 I
+2139(s)S
+7120 V
+11 Y1
+2192(1)S
+7110 V
+2192(1)S
+7120 V
+11 R
+2257(;)S
+11 Y1
+2354(1)S
+2192(2)S
+2244(22)S
+7110 V
+2354(1)S
+2192(7)S
+2244(77)S
+7120 V
+11 I
+2372(P)S
+7153 V
+9 I
+2417(s)S
+7120 V
+11 Y1
+2470(1)S
+7110 V
+2470(1)S
+7120 V
+11 R
+2517(T)S
+11 Y1
+2632(1)S
+2470(2)S
+2522(22)S
+7110 V
+2632(1)S
+2470(7)S
+2522(77)S
+7120 V
+11 R
+2650(.)S
+2758(The)S
+2975(parameters)S
+3501(are)S
+11 I
+3680(func,)S
+3944(startx,)S
+4270(starty,)S
+4596(\256rstrow,)S
+11 R
+5015(and)S
+11 I
+5220(lastrow.)S
+7240 V
+900(func)S
+11 R
+1129(is)S
+1243(non-zero)S
+1671(to)S
+1797(initiate)S
+2143(hilite)S
+2410(tracking)S
+2809(and)S
+3007(zero)S
+3234(to)S
+3360(abort.)S
+11 I
+3686(startx)S
+11 R
+3977(and)S
+11 I
+4174(starty)S
+11 R
+4464(give)S
+4692(the)S
+4865(starting)S
+5234(x)S
+5328(and)S
+5525(y)S
+7680 V
+3212(5)S
+7920 V
+EP
+%%Page: 6 6
+BP
+/slant 0 def
+/height 1.000000 def
+11 R
+11 R
+480 V
+900(Xterm Control Sequences)S
+4980(VT100 Mode)S
+840 V
+900(location)S
+1291(for)S
+1455(the)S
+1626(highlighted)S
+2165(region.)S
+2543(The)S
+2750(ending)S
+3086(location)S
+3477(tracks)S
+3776(the)S
+3948(mouse,)S
+4301(but)S
+4480(will)S
+4690(never)S
+4970(be)S
+5111(above)S
+5410(row)S
+960 V
+11 I
+900(\256rstrow)S
+11 R
+1285(and)S
+1484(will)S
+1697(always)S
+2042(be)S
+2186(above)S
+2488(row)S
+11 I
+2699(lastrow.)S
+11 R
+3133(\(The)S
+3380(top)S
+3562(of)S
+3694(the)S
+3869(screen)S
+4188(is)S
+4303(row)S
+4514(1.\))S
+4707(When)S
+5009(the)S
+5184(button)S
+5506(is)S
+1080 V
+900(released,)S
+11 I
+1327(xterm)S
+11 R
+1618(reports)S
+1964(the)S
+2140(ending)S
+2481(position)S
+2879(one)S
+3079(of)S
+3212(two)S
+3419(ways:)S
+3717(if)S
+3826(the)S
+4003(start)S
+4235(and)S
+4436(end)S
+4637(coordinates)S
+5185(are)S
+5360(valid)S
+1200 V
+900(text)S
+1099(locations:)S
+11 Y1
+1561(1)S
+1190 V
+1561(1)S
+6 R
+1586(ESC)S
+1200 V
+11 Y1
+1723(1)S
+1561(2)S
+1613(22)S
+1190 V
+1723(1)S
+1561(7)S
+1613(77)S
+1200 V
+1741(1)S
+1190 V
+1741(1)S
+1200 V
+11 R
+1804([)S
+11 Y1
+1903(1)S
+1741(2)S
+1793(22)S
+1190 V
+1903(1)S
+1741(7)S
+1793(77)S
+1200 V
+1921(1)S
+1190 V
+1921(1)S
+1200 V
+11 R
+1986(t)S
+11 Y1
+2083(1)S
+1921(2)S
+1973(22)S
+1190 V
+2083(1)S
+1921(7)S
+1973(77)S
+1200 V
+11 I
+2101(C)S
+1233 V
+9 I
+2153(x)S
+1200 V
+11 I
+2193(C)S
+1233 V
+9 I
+2245(y)S
+1200 V
+11 R
+2285(.)S
+2380(If)S
+2486(either)S
+2769(coordinate)S
+3265(is)S
+3372(past)S
+3582(the)S
+3749(end)S
+3940(of)S
+4064(the)S
+4231(line:)S
+11 Y1
+4460(1)S
+1190 V
+4460(1)S
+6 R
+4485(ESC)S
+1200 V
+11 Y1
+4622(1)S
+4460(2)S
+4512(22)S
+1190 V
+4622(1)S
+4460(7)S
+4512(77)S
+1200 V
+4640(1)S
+1190 V
+4640(1)S
+1200 V
+11 R
+4703([)S
+11 Y1
+4802(1)S
+4640(2)S
+4692(22)S
+1190 V
+4802(1)S
+4640(7)S
+4692(77)S
+1200 V
+4820(1)S
+1190 V
+4820(1)S
+1200 V
+11 R
+4867(T)S
+11 Y1
+4982(1)S
+4820(2)S
+4872(22)S
+1190 V
+4982(1)S
+4820(7)S
+4872(77)S
+1200 V
+11 I
+5000(C)S
+1233 V
+9 I
+5052(x)S
+1200 V
+11 I
+5092(C)S
+1233 V
+9 I
+5144(y)S
+1200 V
+11 I
+5184(C)S
+1233 V
+9 I
+5236(x)S
+1200 V
+11 I
+5276(C)S
+1233 V
+9 I
+5328(y)S
+1200 V
+11 I
+5368(C)S
+1233 V
+9 I
+5420(x)S
+1200 V
+11 I
+5460(C)S
+1233 V
+9 I
+5512(y)S
+1200 V
+11 R
+5552(.)S
+1320 V
+900(The)S
+1111(parameters)S
+1631(are)S
+11 I
+1804(startx,)S
+2124(starty,)S
+2444(endx,)S
+2720(endy,)S
+2996(mousex,)S
+11 R
+3394(and)S
+11 I
+3594(mousey.)S
+4025(startx,)S
+4346(starty,)S
+4667(endx,)S
+11 R
+4943(and)S
+11 I
+5143(endy)S
+11 R
+5391(give)S
+1440 V
+900(the)S
+1079(starting)S
+1454(and)S
+1657(ending)S
+2001(character)S
+2444(positions)S
+2888(of)S
+3024(the)S
+3203(region.)S
+11 I
+3556(mousex)S
+11 R
+3928(and)S
+11 I
+4130(mousey)S
+11 R
+4502(give)S
+4735(the)S
+4913(location)S
+5311(of)S
+5446(the)S
+1560 V
+900(mouse)S
+1220(at)S
+1332(button)S
+1647(up,)S
+1818(which)S
+2119(may)S
+2341(not)S
+2515(be)S
+2651(over)S
+2878(a)S
+2959(character.)S
+1800 V
+11 B
+900(Tektronix)S
+1404(4014)S
+1657(Mode)S
+1968 V
+11 R
+900(Most)S
+1161(of)S
+1286(these)S
+1545(sequences)S
+2022(are)S
+2188(standard)S
+2593(Tektronix)S
+3060(4014)S
+3314(control)S
+3659(sequences.)S
+4197(The)S
+4401(major)S
+4691(features)S
+5070(missing)S
+5448(are)S
+2088 V
+900(the)S
+1074(write-thru)S
+1552(and)S
+1749(defocused)S
+2231(modes.)S
+2618(This)S
+2853(document)S
+3325(does)S
+3565(not)S
+3745(describe)S
+4148(the)S
+4321(commands)S
+4836(used)S
+5076(in)S
+5201(the)S
+5374(vari-)S
+2208 V
+900(ous)S
+1086(Tektronix)S
+1552(plotting)S
+1929(modes)S
+2249(but)S
+2423(does)S
+2657(describe)S
+3054(the)S
+3221(commands)S
+3730(to)S
+3849(switch)S
+4169(modes.)S
+2488 V
+11 Y1
+900(1)S
+2478 V
+900(1)S
+6 R
+924(BEL)S
+2488 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2478 V
+1062(1)S
+900(7)S
+952(77)S
+2488 V
+11 R
+1980(Bell)S
+2197(\(Ctrl-G\))S
+2648 V
+11 Y1
+900(1)S
+2638 V
+900(1)S
+6 R
+944(BS)S
+2648 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2638 V
+1062(1)S
+900(7)S
+952(77)S
+2648 V
+11 R
+1980(Backspace)S
+2480(\(Ctrl-H\))S
+2808 V
+11 Y1
+900(1)S
+2798 V
+900(1)S
+6 R
+921(TAB)S
+2808 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2798 V
+1062(1)S
+900(7)S
+952(77)S
+2808 V
+11 R
+1980(Horizontal)S
+2482(Tab)S
+2685(\(Ctrl-I\))S
+2968 V
+11 Y1
+900(1)S
+2958 V
+900(1)S
+6 R
+945(LF)S
+2968 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2958 V
+1062(1)S
+900(7)S
+952(77)S
+2968 V
+11 R
+1980(Line)S
+2214(Feed)S
+2460(or)S
+2584(New)S
+2823(Line)S
+3057(\(Ctrl-J\))S
+3128 V
+11 Y1
+900(1)S
+3118 V
+900(1)S
+6 R
+941(VT)S
+3128 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3118 V
+1062(1)S
+900(7)S
+952(77)S
+3128 V
+11 R
+1980(Cursor)S
+2312(up)S
+2455(\(Ctrl-K\))S
+3288 V
+11 Y1
+900(1)S
+3278 V
+900(1)S
+6 R
+947(FF)S
+3288 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3278 V
+1062(1)S
+900(7)S
+952(77)S
+3288 V
+11 R
+1980(Form)S
+2252(Feed)S
+2498(or)S
+2622(New)S
+2861(Page)S
+3107(\(Ctrl-L\))S
+3448 V
+11 Y1
+900(1)S
+3438 V
+900(1)S
+6 R
+941(CR)S
+3448 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3438 V
+1062(1)S
+900(7)S
+952(77)S
+3448 V
+11 R
+1980(Carriage)S
+2389(Return)S
+2721(\(Ctrl-M\))S
+3608 V
+11 Y1
+900(1)S
+3598 V
+900(1)S
+6 R
+925(ESC)S
+3608 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3598 V
+1062(1)S
+900(7)S
+952(77)S
+3608 V
+1080(1)S
+3598 V
+1080(1)S
+6 R
+1102(ETX)S
+3608 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3598 V
+1242(1)S
+1080(7)S
+1132(77)S
+3608 V
+11 R
+1980(Switch)S
+2319(to)S
+2438(VT100)S
+2782(Mode)S
+3071(\(ESC)S
+3343(Ctrl-C\))S
+3768 V
+11 Y1
+900(1)S
+3758 V
+900(1)S
+6 R
+925(ESC)S
+3768 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3758 V
+1062(1)S
+900(7)S
+952(77)S
+3768 V
+1080(1)S
+3758 V
+1080(1)S
+6 R
+1099(ENQ)S
+3768 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3758 V
+1242(1)S
+1080(7)S
+1132(77)S
+3768 V
+11 R
+1980(Return)S
+2312(Terminal)S
+2747(Status)S
+3050(\(ESC)S
+3322(Ctrl-E\))S
+3928 V
+11 Y1
+900(1)S
+3918 V
+900(1)S
+6 R
+925(ESC)S
+3928 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3918 V
+1062(1)S
+900(7)S
+952(77)S
+3928 V
+1080(1)S
+3918 V
+1080(1)S
+6 R
+1125(LF)S
+3928 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+3918 V
+1242(1)S
+1080(7)S
+1132(77)S
+3928 V
+11 R
+1980(PAGE)S
+2300(\(Clear)S
+2606(Screen\))S
+4088 V
+11 Y1
+900(1)S
+4078 V
+900(1)S
+6 R
+925(ESC)S
+4088 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4078 V
+1062(1)S
+900(7)S
+952(77)S
+4088 V
+1080(1)S
+4078 V
+1080(1)S
+6 R
+1122(SO)S
+4088 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4078 V
+1242(1)S
+1080(7)S
+1132(77)S
+4088 V
+11 R
+1980(Begin)S
+2276(4015)S
+2529(APL)S
+2770(mode)S
+3047(\(ignored)S
+3451(by)S
+11 I
+3594(xterm)S
+11 R
+3843(\))S
+3912(\(ESC)S
+4184(Ctrl-N\))S
+4248 V
+11 Y1
+900(1)S
+4238 V
+900(1)S
+6 R
+925(ESC)S
+4248 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4238 V
+1062(1)S
+900(7)S
+952(77)S
+4248 V
+1080(1)S
+4238 V
+1080(1)S
+6 R
+1134(SI)S
+4248 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4238 V
+1242(1)S
+1080(7)S
+1132(77)S
+4248 V
+11 R
+1980(End)S
+2190(4015)S
+2443(APL)S
+2684(mode)S
+2961(\(ignored)S
+3365(by)S
+11 I
+3508(xterm)S
+11 R
+3757(\))S
+3826(\(ESC)S
+4098(Ctrl-O\))S
+4408 V
+11 Y1
+900(1)S
+4398 V
+900(1)S
+6 R
+925(ESC)S
+4408 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4398 V
+1062(1)S
+900(7)S
+952(77)S
+4408 V
+1080(1)S
+4398 V
+1080(1)S
+6 R
+1104(ETB)S
+4408 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4398 V
+1242(1)S
+1080(7)S
+1132(77)S
+4408 V
+11 R
+1980(COPY)S
+2307(\(Save)S
+2589(Tektronix)S
+3055(Codes)S
+3363(to)S
+3482(\256le)S
+3656(COPYyy-mm-dd.hh:mm:ss\))S
+4941(\(ESC)S
+5213(Ctrl-W\))S
+4568 V
+11 Y1
+900(1)S
+4558 V
+900(1)S
+6 R
+925(ESC)S
+4568 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4558 V
+1062(1)S
+900(7)S
+952(77)S
+4568 V
+1080(1)S
+4558 V
+1080(1)S
+6 R
+1098(CAN)S
+4568 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4558 V
+1242(1)S
+1080(7)S
+1132(77)S
+4568 V
+11 R
+1980(Bypass)S
+2331(Condition)S
+2806(\(ESC)S
+3078(Ctrl-X\))S
+4728 V
+11 Y1
+900(1)S
+4718 V
+900(1)S
+6 R
+925(ESC)S
+4728 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4718 V
+1062(1)S
+900(7)S
+952(77)S
+4728 V
+1080(1)S
+4718 V
+1080(1)S
+6 R
+1102(SUB)S
+4728 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4718 V
+1242(1)S
+1080(7)S
+1132(77)S
+4728 V
+11 R
+1980(GIN)S
+2207(mode)S
+2484(\(ESC)S
+2756(Ctrl-Z\))S
+4888 V
+11 Y1
+900(1)S
+4878 V
+900(1)S
+6 R
+925(ESC)S
+4888 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+4878 V
+1062(1)S
+900(7)S
+952(77)S
+4888 V
+1080(1)S
+4878 V
+1080(1)S
+6 R
+1127(FS)S
+4888 V
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+4878 V
+1242(1)S
+1080(7)S
+1132(77)S
+4888 V
+11 R
+1980(Special)S
+2336(Point)S
+2603(Plot)S
+2815(Mode)S
+3104(\(ESC)S
+3376(Ctrl-\\\))S
+5048 V
+11 Y1
+900(1)S
+5038 V
+900(1)S
+6 R
+925(ESC)S
+5048 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5038 V
+1062(1)S
+900(7)S
+952(77)S
+5048 V
+1080(1)S
+5038 V
+1080(1)S
+5048 V
+11 R
+1133(8)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5038 V
+1242(1)S
+1080(7)S
+1132(77)S
+5048 V
+11 R
+1980(Select)S
+2281(Large)S
+2568(Character)S
+3025(Set)S
+5208 V
+11 Y1
+900(1)S
+5198 V
+900(1)S
+6 R
+925(ESC)S
+5208 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5198 V
+1062(1)S
+900(7)S
+952(77)S
+5208 V
+1080(1)S
+5198 V
+1080(1)S
+5208 V
+11 R
+1133(9)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5198 V
+1242(1)S
+1080(7)S
+1132(77)S
+5208 V
+11 R
+1980(Select)S
+2281(#2)S
+2424(Character)S
+2881(Set)S
+5368 V
+11 Y1
+900(1)S
+5358 V
+900(1)S
+6 R
+925(ESC)S
+5368 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5358 V
+1062(1)S
+900(7)S
+952(77)S
+5368 V
+1080(1)S
+5358 V
+1080(1)S
+5368 V
+11 R
+1145(:)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5358 V
+1242(1)S
+1080(7)S
+1132(77)S
+5368 V
+11 R
+1980(Select)S
+2281(#3)S
+2424(Character)S
+2881(Set)S
+5528 V
+11 Y1
+900(1)S
+5518 V
+900(1)S
+6 R
+925(ESC)S
+5528 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5518 V
+1062(1)S
+900(7)S
+952(77)S
+5528 V
+1080(1)S
+5518 V
+1080(1)S
+5528 V
+11 R
+1145(;)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5518 V
+1242(1)S
+1080(7)S
+1132(77)S
+5528 V
+11 R
+1980(Select)S
+2281(Small)S
+2572(Character)S
+3029(Set)S
+5688 V
+11 Y1
+900(1)S
+5678 V
+900(1)S
+6 R
+925(ESC)S
+5688 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+5678 V
+1062(1)S
+900(7)S
+952(77)S
+5688 V
+1080(1)S
+5678 V
+1080(1)S
+5688 V
+11 R
+1143(])S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+5678 V
+1242(1)S
+1080(7)S
+1132(77)S
+5688 V
+11 I
+1260(P)S
+5721 V
+9 I
+1305(s)S
+5688 V
+11 Y1
+1358(1)S
+5678 V
+1358(1)S
+5688 V
+11 R
+1423(;)S
+11 Y1
+1520(1)S
+1358(2)S
+1410(22)S
+5678 V
+1520(1)S
+1358(7)S
+1410(77)S
+5688 V
+11 I
+1538(P)S
+5721 V
+9 I
+1583(t)S
+5688 V
+11 Y1
+1626(1)S
+5678 V
+1626(1)S
+6 R
+1650(BEL)S
+5688 V
+11 Y1
+1788(1)S
+1626(2)S
+1678(22)S
+5678 V
+1788(1)S
+1626(7)S
+1678(77)S
+5688 V
+11 R
+1980(Set)S
+2154(Text)S
+2388(Parameters)S
+2907(of)S
+3031(VT)S
+3210(window)S
+5848 V
+11 I
+2046(P)S
+5881 V
+9 I
+2091(s)S
+5848 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5838 V
+2254(1)S
+5848 V
+11 R
+2307(0)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5838 V
+2416(1)S
+2254(7)S
+2306(77)S
+5848 V
+11 Y
+2467(\256)S
+11 R
+2609(Change)S
+2977(Icon)S
+3204(Name)S
+3498(and)S
+3689(Window)S
+4100(Title)S
+4341(to)S
+11 I
+4460(P)S
+5881 V
+9 I
+4505(t)S
+6008 V
+11 I
+2046(P)S
+6041 V
+9 I
+2091(s)S
+6008 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+5998 V
+2254(1)S
+6008 V
+11 R
+2307(1)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+5998 V
+2416(1)S
+2254(7)S
+2306(77)S
+6008 V
+11 Y
+2467(\256)S
+11 R
+2609(Change)S
+2977(Icon)S
+3204(Name)S
+3498(to)S
+11 I
+3617(P)S
+6041 V
+9 I
+3662(t)S
+6168 V
+11 I
+2046(P)S
+6201 V
+9 I
+2091(s)S
+6168 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+6158 V
+2254(1)S
+6168 V
+11 R
+2307(2)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+6158 V
+2416(1)S
+2254(7)S
+2306(77)S
+6168 V
+11 Y
+2467(\256)S
+11 R
+2609(Change)S
+2977(Window)S
+3388(Title)S
+3629(to)S
+11 I
+3748(P)S
+6201 V
+9 I
+3793(t)S
+6328 V
+11 I
+2046(P)S
+6361 V
+9 I
+2091(s)S
+6328 V
+11 R
+2159(=)S
+11 Y1
+2254(1)S
+6318 V
+2254(1)S
+6328 V
+11 R
+2307(4)S
+11 Y1
+2416(1)S
+2254(2)S
+2306(22)S
+6318 V
+2416(1)S
+2254(7)S
+2306(77)S
+6328 V
+2434(1)S
+6318 V
+2434(1)S
+6328 V
+11 R
+2487(6)S
+11 Y1
+2596(1)S
+2434(2)S
+2486(22)S
+6318 V
+2596(1)S
+2434(7)S
+2486(77)S
+6328 V
+11 Y
+2647(\256)S
+11 R
+2789(Change)S
+3157(Log)S
+3367(File)S
+3572(to)S
+11 I
+3691(P)S
+6361 V
+9 I
+3736(t)S
+6488 V
+11 Y1
+900(1)S
+6478 V
+900(1)S
+6 R
+925(ESC)S
+6488 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6478 V
+1062(1)S
+900(7)S
+952(77)S
+6488 V
+1080(1)S
+6478 V
+1080(1)S
+6488 V
+11 R
+1143(\301)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6478 V
+1242(1)S
+1080(7)S
+1132(77)S
+6488 V
+11 R
+1980(Normal)S
+2348(Z)S
+2448(Axis)S
+2689(and)S
+2880(Normal)S
+3248(\(solid\))S
+3568(Vectors)S
+6648 V
+11 Y1
+900(1)S
+6638 V
+900(1)S
+6 R
+925(ESC)S
+6648 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6638 V
+1062(1)S
+900(7)S
+952(77)S
+6648 V
+1080(1)S
+6638 V
+1080(1)S
+6648 V
+11 R
+1137(a)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6638 V
+1242(1)S
+1080(7)S
+1132(77)S
+6648 V
+11 R
+1980(Normal)S
+2348(Z)S
+2448(Axis)S
+2689(and)S
+2880(Dotted)S
+3212(Line)S
+3446(Vectors)S
+6808 V
+11 Y1
+900(1)S
+6798 V
+900(1)S
+6 R
+925(ESC)S
+6808 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+6798 V
+1062(1)S
+900(7)S
+952(77)S
+6808 V
+1080(1)S
+6798 V
+1080(1)S
+6808 V
+11 R
+1133(b)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+6798 V
+1242(1)S
+1080(7)S
+1132(77)S
+6808 V
+11 R
+1980(Normal)S
+2348(Z)S
+2448(Axis)S
+2689(and)S
+2880(Dot-Dashed)S
+3442(Vectors)S
+7720 V
+3212(6)S
+7920 V
+EP
+%%Page: 7 7
+BP
+/slant 0 def
+/height 1.000000 def
+11 R
+11 R
+520 V
+900(Xterm Control Sequences)S
+4605(Tektronix 4014 Mode)S
+880 V
+11 Y1
+900(1)S
+870 V
+900(1)S
+6 R
+925(ESC)S
+880 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+870 V
+1062(1)S
+900(7)S
+952(77)S
+880 V
+1080(1)S
+870 V
+1080(1)S
+880 V
+11 R
+1137(c)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+870 V
+1242(1)S
+1080(7)S
+1132(77)S
+880 V
+11 R
+1980(Normal)S
+2348(Z)S
+2448(Axis)S
+2689(and)S
+2880(Short-Dashed)S
+3516(Vectors)S
+1040 V
+11 Y1
+900(1)S
+1030 V
+900(1)S
+6 R
+925(ESC)S
+1040 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1030 V
+1062(1)S
+900(7)S
+952(77)S
+1040 V
+1080(1)S
+1030 V
+1080(1)S
+1040 V
+11 R
+1133(d)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1030 V
+1242(1)S
+1080(7)S
+1132(77)S
+1040 V
+11 R
+1980(Normal)S
+2348(Z)S
+2448(Axis)S
+2689(and)S
+2880(Long-Dashed)S
+3509(Vectors)S
+1200 V
+11 Y1
+900(1)S
+1190 V
+900(1)S
+6 R
+925(ESC)S
+1200 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1190 V
+1062(1)S
+900(7)S
+952(77)S
+1200 V
+1080(1)S
+1190 V
+1080(1)S
+1200 V
+11 R
+1133(h)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1190 V
+1242(1)S
+1080(7)S
+1132(77)S
+1200 V
+11 R
+1980(Defocused)S
+2480(Z)S
+2580(Axis)S
+2821(and)S
+3012(Normal)S
+3380(\(solid\))S
+3700(Vectors)S
+1360 V
+11 Y1
+900(1)S
+1350 V
+900(1)S
+6 R
+925(ESC)S
+1360 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1350 V
+1062(1)S
+900(7)S
+952(77)S
+1360 V
+1080(1)S
+1350 V
+1080(1)S
+1360 V
+11 R
+1145(i)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1350 V
+1242(1)S
+1080(7)S
+1132(77)S
+1360 V
+11 R
+1980(Defocused)S
+2480(Z)S
+2580(Axis)S
+2821(and)S
+3012(Dotted)S
+3344(Line)S
+3578(Vectors)S
+1520 V
+11 Y1
+900(1)S
+1510 V
+900(1)S
+6 R
+925(ESC)S
+1520 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1510 V
+1062(1)S
+900(7)S
+952(77)S
+1520 V
+1080(1)S
+1510 V
+1080(1)S
+1520 V
+11 R
+1145(j)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1510 V
+1242(1)S
+1080(7)S
+1132(77)S
+1520 V
+11 R
+1980(Defocused)S
+2480(Z)S
+2580(Axis)S
+2821(and)S
+3012(Dot-Dashed)S
+3574(Vectors)S
+1680 V
+11 Y1
+900(1)S
+1670 V
+900(1)S
+6 R
+925(ESC)S
+1680 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1670 V
+1062(1)S
+900(7)S
+952(77)S
+1680 V
+1080(1)S
+1670 V
+1080(1)S
+1680 V
+11 R
+1133(k)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1670 V
+1242(1)S
+1080(7)S
+1132(77)S
+1680 V
+11 R
+1980(Defocused)S
+2480(Z)S
+2580(Axis)S
+2821(and)S
+3012(Short-Dashed)S
+3648(Vectors)S
+1840 V
+11 Y1
+900(1)S
+1830 V
+900(1)S
+6 R
+925(ESC)S
+1840 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1830 V
+1062(1)S
+900(7)S
+952(77)S
+1840 V
+1080(1)S
+1830 V
+1080(1)S
+1840 V
+11 R
+1145(l)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1830 V
+1242(1)S
+1080(7)S
+1132(77)S
+1840 V
+11 R
+1980(Defocused)S
+2480(Z)S
+2580(Axis)S
+2821(and)S
+3012(Long-Dashed)S
+3641(Vectors)S
+2000 V
+11 Y1
+900(1)S
+1990 V
+900(1)S
+6 R
+925(ESC)S
+2000 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+1990 V
+1062(1)S
+900(7)S
+952(77)S
+2000 V
+1080(1)S
+1990 V
+1080(1)S
+2000 V
+11 R
+1133(p)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+1990 V
+1242(1)S
+1080(7)S
+1132(77)S
+2000 V
+11 R
+1980(Write-Thru)S
+2511(Mode)S
+2800(and)S
+2991(Normal)S
+3359(\(solid\))S
+3679(Vectors)S
+2160 V
+11 Y1
+900(1)S
+2150 V
+900(1)S
+6 R
+925(ESC)S
+2160 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2150 V
+1062(1)S
+900(7)S
+952(77)S
+2160 V
+1080(1)S
+2150 V
+1080(1)S
+2160 V
+11 R
+1133(q)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2150 V
+1242(1)S
+1080(7)S
+1132(77)S
+2160 V
+11 R
+1980(Write-Thru)S
+2511(Mode)S
+2800(and)S
+2991(Dotted)S
+3323(Line)S
+3557(Vectors)S
+2320 V
+11 Y1
+900(1)S
+2310 V
+900(1)S
+6 R
+925(ESC)S
+2320 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2310 V
+1062(1)S
+900(7)S
+952(77)S
+2320 V
+1080(1)S
+2310 V
+1080(1)S
+2320 V
+11 R
+1143(r)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2310 V
+1242(1)S
+1080(7)S
+1132(77)S
+2320 V
+11 R
+1980(Write-Thru)S
+2511(Mode)S
+2800(and)S
+2991(Dot-Dashed)S
+3553(Vectors)S
+2480 V
+11 Y1
+900(1)S
+2470 V
+900(1)S
+6 R
+925(ESC)S
+2480 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2470 V
+1062(1)S
+900(7)S
+952(77)S
+2480 V
+1080(1)S
+2470 V
+1080(1)S
+2480 V
+11 R
+1139(s)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2470 V
+1242(1)S
+1080(7)S
+1132(77)S
+2480 V
+11 R
+1980(Write-Thru)S
+2511(Mode)S
+2800(and)S
+2991(Short-Dashed)S
+3627(Vectors)S
+2640 V
+11 Y1
+900(1)S
+2630 V
+900(1)S
+6 R
+925(ESC)S
+2640 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2630 V
+1062(1)S
+900(7)S
+952(77)S
+2640 V
+1080(1)S
+2630 V
+1080(1)S
+2640 V
+11 R
+1145(t)S
+11 Y1
+1242(1)S
+1080(2)S
+1132(22)S
+2630 V
+1242(1)S
+1080(7)S
+1132(77)S
+2640 V
+11 R
+1980(Write-Thru)S
+2511(Mode)S
+2800(and)S
+2991(Long-Dashed)S
+3620(Vectors)S
+2800 V
+11 Y1
+900(1)S
+2790 V
+900(1)S
+6 R
+947(FS)S
+2800 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2790 V
+1062(1)S
+900(7)S
+952(77)S
+2800 V
+11 R
+1980(Point)S
+2247(Plot)S
+2459(Mode)S
+2748(\(Ctrl-\\\))S
+2960 V
+11 Y1
+900(1)S
+2950 V
+900(1)S
+6 R
+942(GS)S
+2960 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+2950 V
+1062(1)S
+900(7)S
+952(77)S
+2960 V
+11 R
+1980(Graph)S
+2286(Mode)S
+2575(\(Ctrl-]\))S
+3120 V
+11 Y1
+900(1)S
+3110 V
+900(1)S
+6 R
+944(RS)S
+3120 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3110 V
+1062(1)S
+900(7)S
+952(77)S
+3120 V
+11 R
+1980(Incremental)S
+2535(Plot)S
+2747(Mode)S
+3036(\(Ctrl-^\))S
+3280 V
+11 Y1
+900(1)S
+3270 V
+900(1)S
+6 R
+942(US)S
+3280 V
+11 Y1
+1062(1)S
+900(2)S
+952(22)S
+3270 V
+1062(1)S
+900(7)S
+952(77)S
+3280 V
+11 R
+1980(Alpha)S
+2281(Mode)S
+2570(\(Ctrl-_\))S
+7720 V
+3212(7)S
+7920 V
+EP
+%%Trailer
+%%DocumentFonts: Times-Roman Times-Bold Times-Italic Symbol Troff
+%%Pages: 7
+ \ No newline at end of file
diff --git a/vendor/x11iraf/xgterm/cursor.c b/vendor/x11iraf/xgterm/cursor.c
new file mode 100644
index 00000000..5fc00957
--- /dev/null
+++ b/vendor/x11iraf/xgterm/cursor.c
@@ -0,0 +1,244 @@
+/*
+ * $XConsortium: cursor.c,v 1.14 93/09/20 17:42:23 hersh 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.
+ */
+
+/* cursor.c */
+
+#include "ptyx.h" /* also gets Xlib.h */
+
+static void _CheckSelection(screen)
+register TScreen *screen;
+{
+ extern XgtermWidget term; /* %%% gross */
+
+ if (screen->cur_row > screen->endHRow ||
+ (screen->cur_row == screen->endHRow &&
+ screen->cur_col >= screen->endHCol)) {}
+ else
+ DisownSelection(term);
+}
+
+
+
+/*
+ * 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.
+ */
+CursorSet(screen, row, col, flags)
+register TScreen *screen;
+register int row, col;
+unsigned flags;
+{
+ register int maxr;
+
+ col = (col < 0 ? 0 : col);
+ screen->cur_col = (col <= screen->max_col ? col : screen->max_col);
+ maxr = screen->max_row;
+ if (flags & ORIGIN) {
+ row += screen->top_marg;
+ maxr = screen->bot_marg;
+ }
+ row = (row < 0 ? 0 : row);
+ screen->cur_row = (row <= maxr ? row : maxr);
+ screen->do_wrap = 0;
+ _CheckSelection(screen);
+}
+
+/*
+ * moves the cursor left n, no wrap around
+ */
+CursorBack(screen, n)
+register TScreen *screen;
+int n;
+{
+ register int i, j, k, rev;
+ extern XgtermWidget term;
+
+ if((rev = (term->flags & (REVERSEWRAP | WRAPAROUND)) ==
+ (REVERSEWRAP | WRAPAROUND)) && screen->do_wrap)
+ n--;
+ if ((screen->cur_col -= n) < 0) {
+ if(rev) {
+ if((i = (j = screen->max_col + 1) * screen->cur_row +
+ screen->cur_col) < 0) {
+ k = j * (screen->max_row + 1);
+ i += ((-i) / k + 1) * k;
+ }
+ screen->cur_row = i / j;
+ screen->cur_col = i % j;
+ } else
+ screen->cur_col = 0;
+ }
+ screen->do_wrap = 0;
+ _CheckSelection(screen);
+}
+
+/*
+ * moves the cursor forward n, no wraparound
+ */
+CursorForward(screen, n)
+register TScreen *screen;
+int n;
+{
+ screen->cur_col += n;
+ if (screen->cur_col > screen->max_col)
+ screen->cur_col = screen->max_col;
+ screen->do_wrap = 0;
+ _CheckSelection(screen);
+}
+
+/*
+ * moves the cursor down n, no scrolling.
+ * Won't pass bottom margin or bottom of screen.
+ */
+CursorDown(screen, n)
+register TScreen *screen;
+int n;
+{
+ register int max;
+
+ max = (screen->cur_row > screen->bot_marg ?
+ screen->max_row : screen->bot_marg);
+
+ screen->cur_row += n;
+ if (screen->cur_row > max)
+ screen->cur_row = max;
+ screen->do_wrap = 0;
+ _CheckSelection(screen);
+}
+
+/*
+ * moves the cursor up n, no linestarving.
+ * Won't pass top margin or top of screen.
+ */
+CursorUp(screen, n)
+register TScreen *screen;
+int n;
+{
+ register int min;
+
+ min = (screen->cur_row < screen->top_marg ?
+ 0 : screen->top_marg);
+
+ screen->cur_row -= n;
+ if (screen->cur_row < min)
+ screen->cur_row = min;
+ screen->do_wrap = 0;
+ _CheckSelection(screen);
+}
+
+/*
+ * Moves cursor down amount lines, scrolls if necessary.
+ * Won't leave scrolling region. No carriage return.
+ */
+Index(screen, amount)
+register TScreen *screen;
+register int amount;
+{
+ register 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);
+ Scroll(screen, amount - j);
+}
+
+/*
+ * Moves cursor up amount lines, reverse scrolls if necessary.
+ * Won't leave scrolling region. No carriage return.
+ */
+RevIndex(screen, amount)
+register TScreen *screen;
+register 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
+ */
+CarriageReturn(screen)
+register TScreen *screen;
+{
+ screen->cur_col = 0;
+ screen->do_wrap = 0;
+ _CheckSelection(screen);
+}
+
+/*
+ * Save Cursor and Attributes
+ */
+CursorSave(term, sc)
+register XgtermWidget term;
+register SavedCursor *sc;
+{
+ register TScreen *screen = &term->screen;
+
+ sc->row = screen->cur_row;
+ sc->col = screen->cur_col;
+ sc->flags = term->flags;
+ sc->curgl = screen->curgl;
+ sc->curgr = screen->curgr;
+ memmove( sc->gsets, screen->gsets, sizeof(screen->gsets));
+}
+
+/*
+ * Restore Cursor and Attributes
+ */
+CursorRestore(term, sc)
+register XgtermWidget term;
+register SavedCursor *sc;
+{
+ register TScreen *screen = &term->screen;
+
+ memmove( screen->gsets, sc->gsets, sizeof(screen->gsets));
+ screen->curgl = sc->curgl;
+ screen->curgr = sc->curgr;
+ term->flags &= ~(BOLD|INVERSE|UNDERLINE|ORIGIN);
+ term->flags |= sc->flags & (BOLD|INVERSE|UNDERLINE|ORIGIN);
+ CursorSet (screen, (term->flags & ORIGIN) ? sc->row - screen->top_marg
+ : sc->row, sc->col, term->flags);
+}
diff --git a/vendor/x11iraf/xgterm/data.c b/vendor/x11iraf/xgterm/data.c
new file mode 100644
index 00000000..abcc4cfa
--- /dev/null
+++ b/vendor/x11iraf/xgterm/data.c
@@ -0,0 +1,106 @@
+/*
+ * $XConsortium: data.c,v 1.11 93/02/25 17:21:27 gildea 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.
+ */
+
+#include "ptyx.h" /* gets Xt stuff, too */
+#include "data.h"
+#include <setjmp.h>
+
+XPoint T_boxlarge[NBOX] = {
+ {0, 0},
+ {8, 0},
+ {0, 14},
+ {-8, 0},
+ {0, -14},
+};
+XPoint T_box2[NBOX] = {
+ {0, 0},
+ {7, 0},
+ {0, 12},
+ {-7, 0},
+ {0, -12},
+};
+XPoint T_box3[NBOX] = {
+ {0, 0},
+ {5, 0},
+ {0, 12},
+ {-5, 0},
+ {0, -12},
+};
+XPoint T_boxsmall[NBOX] = {
+ {0, 0},
+ {5, 0},
+ {0, 9},
+ {-5, 0},
+ {0, -9},
+};
+int Tbcnt = 0;
+Char *Tbuffer;
+Char *Tbptr;
+Char *Tpushb;
+Char *Tpushback;
+int Ttoggled = 0;
+int bcnt = 0;
+Char buffer[BUF_SIZE];
+Char *bptr = buffer;
+jmp_buf VTend;
+XPoint VTbox[NBOX] = {
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+ {0, 0},
+};
+
+#ifdef DEBUG
+int debug = 0; /* true causes error messages to be displayed */
+#endif /* DEBUG */
+XgtermWidget term; /* master data structure for client */
+char *xgterm_name; /* argv[0] */
+int am_slave = -1; /* set to 1 if running as a slave process */
+int max_plus1;
+int pty_mask;
+int Select_mask;
+int X_mask;
+char *ptydev;
+char *ttydev;
+#ifdef ALLOWLOGGING
+char log_def_name[] = "XgtermLog.XXXXX";
+#endif
+int T_lastx = -1;
+int T_lasty = -1;
+
+/* Display connection used by GUI. */
+Display *gtermio_display;
+Widget gtermio_toplevel;
+char gtermio_appname[SZ_APPNAME+1];
+
+int waitingForTrackInfo = 0;
+EventMode eventMode = NORMAL;
+
+GC visualBellGC;
+
+int VTgcFontMask = GCFont;
diff --git a/vendor/x11iraf/xgterm/data.h b/vendor/x11iraf/xgterm/data.h
new file mode 100644
index 00000000..b1932c96
--- /dev/null
+++ b/vendor/x11iraf/xgterm/data.h
@@ -0,0 +1,69 @@
+/*
+ * $XConsortium: data.h,v 1.9 91/02/05 19:44:30 gildea 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.
+ */
+
+extern XPoint T_box2[];
+extern XPoint T_box3[];
+extern XPoint T_boxlarge[];
+extern XPoint T_boxsmall[];
+extern XPoint VTbox[];
+extern Char *Tbptr;
+extern Char *Tbuffer;
+extern Char *Tpushb;
+extern Char *Tpushback;
+extern Char *bptr;
+#ifdef ALLOWLOGGING
+extern char log_def_name[];
+#endif
+extern char *ptydev;
+extern char *ttydev;
+extern char *xgterm_name;
+extern Char buffer[];
+extern int Select_mask;
+extern int T_lastx;
+extern int T_lasty;
+extern int Tbcnt;
+extern int Ttoggled;
+extern int X_mask;
+extern int am_slave;
+extern int bcnt;
+#ifdef DEBUG
+extern int debug;
+#endif /* DEBUG */
+extern int errno;
+extern int max_plus1;
+extern int pty_mask;
+extern int switchfb[];
+
+extern int waitingForTrackInfo;
+extern EventMode eventMode;
+extern GC visualBellGC;
+extern int VTgcFontMask;
+extern XgtermWidget term;
+
+#define SZ_APPNAME 16
+extern Display *gtermio_display;
+extern Widget gtermio_toplevel;
+extern char gtermio_appname[];
diff --git a/vendor/x11iraf/xgterm/error.h b/vendor/x11iraf/xgterm/error.h
new file mode 100644
index 00000000..1d50d05a
--- /dev/null
+++ b/vendor/x11iraf/xgterm/error.h
@@ -0,0 +1,111 @@
+/*
+ * $XConsortium: error.h,v 1.8 91/07/17 17:43:54 rws 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_KMALLOC 10 /* main: malloc() failed for keyboardtype */
+#define ERROR_FIONBIO 11 /* main: ioctl() failed on FIONBIO */
+
+
+#define ERROR_OPDEVTTY 14 /* spawn: open() failed on /dev/tty */
+#define ERROR_TIOCGETP 15 /* spawn: ioctl() failed on TIOCGETP */
+#define ERROR_TIOCGETC 16 /* spawn: ioctl() failed on TIOCGETC */
+#define ERROR_TIOCGETD 17 /* spawn: ioctl() failed on TIOCGETD */
+#define ERROR_TIOCGLTC 18 /* spawn: ioctl() failed on TIOCGLTC */
+#define ERROR_TIOCLGET 19 /* spawn: ioctl() failed on TIOCLGET */
+#define ERROR_TIOCCONS 20 /* spawn: ioctl() failed on TIOCCONS */
+#define ERROR_OPDEVTTY2 21 /* spawn: second open() failed on /dev/tty */
+#define ERROR_NOTTY 22 /* spawn: ioctl() failed on TIOCNOTTY */
+#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_FORK 29 /* spawn: fork() failed */
+#define ERROR_EXEC 30 /* spawn: exec() failed */
+#define ERROR_OPDEVTTY3 31 /* spawn: third open() failed on /dev/tty */
+#define ERROR_PTYS 32 /* get_pty: not enough ptys */
+#define ERROR_NOX 33 /* get_terminal: can't connect to server */
+#define ERROR_PTY_EXEC 34 /* waiting for initial map */
+
+#define ERROR_INIT 36 /* spawn: can't initialize window */
+#define ERROR_NOCO 37 /* resize: no `co' in termcap */
+#define ERROR_NOLI 38 /* resize: no `li' in termcap */
+#define ERROR_BORDER 39 /* get_terminal: can't make border tile */
+#define ERROR_BACK 40 /* get_terminal: can't make background tile */
+#define ERROR_NOX3 43 /* get_terminal: bad pty from display server */
+#define ERROR_TIOCKGET 44 /* spawn: ioctl() failed on TIOCKGET */
+#define ERROR_TIOCKGETC 45 /* spawn: ioctl() failed on TIOCKGETC */
+#define ERROR_TIOCKSET 46 /* spawn: ioctl() failed on TIOCKSET */
+#define ERROR_TIOCKSETC 47 /* spawn: ioctl() failed on TIOCKSETC */
+/* charproc.c */
+#define ERROR_SELECT 50 /* in_put: select() failed */
+#define ERROR_VINIT 54 /* VTInit: can't initialize window */
+#define ERROR_CNMALLOC1 55 /* Changename: malloc failed */
+#define ERROR_CNMALLOC2 56 /* Changename: malloc failed */
+/* Tekproc.c */
+#define ERROR_TSELECT 60 /* Tinput: select() failed */
+#define ERROR_TINIT 64 /* TekInit: can't initialize window */
+#define ERROR_TBACK 65 /* TekBackground: can't make background */
+/* button.c */
+#define ERROR_BMALLOC2 71 /* SaltTextAway: malloc() failed */
+
+/* misc.c */
+#ifdef ALLOWLOGGING
+#ifdef ALLOWLOGFILEEXEC
+#define ERROR_LOGEXEC 80 /* StartLog: exec() failed */
+#endif
+#endif
+#define ERROR_XERROR 83 /* xerror: XError event */
+#define ERROR_XIOERROR 84 /* xioerror: X I/O error */
+#define ERROR_WINNAME 85 /* get_terminal: malloc failed */
+/* 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_SREALLOC2 93 /* ScreenResize: realloc() failed on alt rows */
+#define ERROR_SREALLOC3 94 /* ScreenResize: realloc() failed on rows */
+#define ERROR_SREALLOC4 95 /* ScreenResize: realloc() failed on rows */
+#define ERROR_RESIZE 96 /* ScreenResize: malloc() or realloc() failed */
+#define ERROR_RESIZE2 97 /* ScreenResize: malloc() or realloc() failed */
+#define ERROR_RESIZROW 98 /* ScreenResize: realloc() failed on alt char */
+#define ERROR_RESIZROW2 99 /* ScreenResize: realloc() failed on alt attr */
+#define ERROR_RESIZROW3 100 /* ScreenResize: realloc() failed on attr */
+#define ERROR_RESIZROW4 101 /* ScreenResize: realloc() failed on attr */
+/* scrollbar.c */
+#define ERROR_SBRALLOC 110 /* ScrollBarOn: realloc() failed on base */
+#define ERROR_SBRALLOC2 111 /* ScrollBarOn: realloc() failed on rows */
+/* util.c */
+#define ERROR_UBACK 120 /* ReverseVideo: can't make background */
+
+#define ERROR_PTSNAME 217 /* spawn: ptsname() failed */
+#define ERROR_OPPTSNAME 218 /* spawn: open() failed on ptsname */
+#define ERROR_INIGROUPS 228 /* spawn: initgroups() failed */
+#define ERROR_SETUID 235 /* spawn: setuid() failed */
+
diff --git a/vendor/x11iraf/xgterm/gtermio.c b/vendor/x11iraf/xgterm/gtermio.c
new file mode 100644
index 00000000..0d1b825d
--- /dev/null
+++ b/vendor/x11iraf/xgterm/gtermio.c
@@ -0,0 +1,2671 @@
+/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+ */
+
+#include <sys/ioctl.h>
+#include <ctype.h>
+#include <stdio.h>
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/Xaw/Cardinals.h>
+#include <X11/Shell.h>
+#include <ObmW/Gterm.h>
+#include <Obm.h>
+
+#include "gtermio.h"
+
+/*
+ * GTERMIO -- XGterm protocol manager for IRAF Gterm graphics emulation.
+ * This protocol is an extension of the Tektronix 4012 graphics protocol.
+ * The basic extensions are patterned after the Retrographics VT640 graphics
+ * terminal, using GS and CAN to switch between vt100 and graphics modes.
+ * Additional extensions are defined to support advanced features such as
+ * color, area fills, graphics erasure, setting the cursor location under
+ * program control, interactive dialog via the "status line", and so on.
+ *
+ * This is the low level code which filters graphics output out of the ASCII
+ * pseudoterminal output stream and decodes the graphics instructions therein,
+ * converting these into function calls to the Gterm graphics widget. The low
+ * level pty input code (i/o manager) in XGterm spends most of its time
+ * waiting for input on a pty. When a block of data is physically read from
+ * the pty, it is passed to the gio_ptyinput procedure herein. This routine
+ * filters out any graphics data in the input stream, handling text/graphics
+ * mode switches, returning any nongraphics input data to be passed on to the
+ * vt100 text widget. The input graphics data is then processed by the
+ * protocol manager which decodes the input and makes calls to the drawing
+ * functions in the gterm graphics widget.
+ */
+
+/* Size limiting definitions. */
+#define TEK_XRES 1024 /* tek4012 logical X resolution */
+#define TEK_YRES 780 /* tek4012 logical Y resolution */
+#define TEK_ROWS 35 /* tek4012 screen size, rows */
+#define TEK_COLS 80 /* tek4012 screen size, columns */
+#define SZ_GBUF 16384 /* max buffered graphics data */
+#define GB_MINSPACE 2048 /* high water mark */
+#define GB_BIGSPACE 12288 /* low water mark */
+#define MAX_PLPTS 4096 /* max points in a polyline */
+#define MAX_COLORS 256 /* max colormap cells */
+#define SZ_TXBUF 1024 /* max chars in a polytext */
+#define SZ_STRBUF 128 /* string input buffer */
+#define SZ_MSGBUF 16384 /* object message fragments */
+#define SZ_ESCAPE 64 /* client escape sequence */
+#define INC_MSGBUF 16384 /* increment if overflow */
+#define MAX_TEXTCHARS 132 /* max chars in text line */
+#define SL_XOFFSET 0 /* x offset to status line */
+#define SL_YOFFSET 5 /* y offset to status line */
+#define MAX_QUOTA 512 /* limit for one proc. loop */
+#define MAXNDC 32767 /* max NDC coordinate value */
+#define MAX_GTERM 128 /* max gterm widgets */
+
+/* Magic numbers. */
+#define SET_BITS 0 /* draw vectors|points */
+#define CLEAR_BITS 1 /* erase vectors|points */
+#define TOGGLE_BITS 2 /* toggle data bits */
+#define COMMAND_MODE 0 /* initial state */
+#define ALPHA_MODE 1 /* tek-alpha character drawing */
+#define TEXT_MODE 2 /* output to status line */
+#define VECTOR_MODE 3 /* draw vectors or points */
+#define MESSAGE_MODE 4 /* accumulate object messages */
+#define WIMAGE_MODE 5 /* draw pixels in image */
+#define WCMAP_MODE 6 /* write to colormap */
+#define WIOMAP_MODE 7 /* write to iomap */
+#define CURSOR_MODE 8 /* read crosshair cursor posn */
+#define BREAK_LINE (-2) /* special automargin code */
+#define ERR (-1) /* error return code */
+
+/* ASCII codes. */
+#define ETX '\003'
+#define ENQ '\005'
+#define BEL '\007'
+#define CR '\015'
+#define CAN '\030'
+#define EM '\031'
+#define SUB '\032'
+#define ESC '\033'
+#define FS '\034'
+#define GS '\035'
+#define RS '\036'
+#define US '\037'
+
+/* The following are the xterm equivalents of GS, CAN. Gtermio recognizes
+ * either as graphics start and end sequences.
+ */
+#define XGS "[?38h" /* xterm GS escape sequence */
+#define LEN_XGS 5 /* length excluding ESC */
+#define XGE "\003" /* graphics terminator (ETX) */
+#define LEN_XGE 1 /* length excluding ESC */
+
+static XtAppContext app_con;
+static ObmContext obm; /* object manager */
+static Widget gw; /* graphics widget */
+
+static int gio_graphicsenabled = 0; /* switch text/graphics output */
+static int gio_enabled = 1; /* enable graphics window */
+static Widget gterms[MAX_GTERM];
+static int actions_registered = 0;
+
+/* Pseudoterminal i/o.
+ */
+static int pty_fd; /* fd of pseudoterminal */
+static int pty_stop = 0; /* set when XOFF is set on pty */
+
+/* The graphics data buffer, a circular buffer. Note that while buffer
+ * data is unsigned char, g_getc below returns a signed integer value.
+ */
+static unsigned char g_buf[SZ_GBUF]; /* circular buffer */
+static unsigned char *g_top= &g_buf[SZ_GBUF]; /* end of buffer + 1 */
+static unsigned char *g_ip = g_buf; /* input pointer */
+static unsigned char *g_op = g_buf; /* output pointer */
+
+#define g_getc(c) (g_ip == g_op ? \
+ ((c)=0, -1) : ((c) = *g_ip++, g_ip >= g_top ? *(char *)(g_ip=g_buf):0))
+#define g_putc(c)\
+ (*g_op++ = (c), ((g_op >= g_top) ? g_op = g_buf : g_op))
+#define g_ungetc(c)\
+ (g_ip = ((g_ip==g_buf) ? g_top-1 : g_ip-1))
+#define g_spaceleft\
+ (g_ip <= g_op ? (g_top - g_op + g_ip - g_buf) : (g_ip - g_op))
+#define g_havedata (g_ip != g_op)
+#define g_mark(ip) ((ip)=g_ip)
+#define g_reset(ip) (g_ip=(ip))
+#define g_equal(ip) ((ip)==g_ip)
+
+/* Message buffer.
+ */
+static char *msgbuf = NULL;
+static int len_msgbuf = 0;
+static int msg_op = 0;
+
+/* Polyline (polymarker) output-point buffer.
+ */
+static char pl_text[MAX_PLPTS]; /* encoded [x,y] coord data */
+static XPoint pl_p[MAX_PLPTS]; /* polyline storage */
+static int pl_npts = 0; /* npoints in polyline */
+static int pl_op = 0; /* which char in coord pair */
+static int pl_pointmode = 0; /* point or line mode */
+static int pl_areamode = 0; /* fill area mode */
+
+static int ohiy=0, oloy=0; /* encoded current position */
+static int ohix=0, olox=0;
+
+/* Graphics text variables.
+ */
+static char tx_buf[SZ_TXBUF+1]; /* polytext text buffer */
+static int tx_len = 0; /* nchars in buffer */
+static int tx_maxlines; /* nlines of text on a screen */
+static int tx_maxcols; /* ncols of text on a screen */
+static int tx_charheight; /* height of a char in pixels */
+static int tx_charwidth; /* width of a char in pixels */
+static int tx_charbase; /* topline to baseline distance */
+static int tx_leftmargin; /* where columns start */
+static int sl_x, sl_y; /* current pos. in status line */
+static int sl_charwidth; /* status line char width */
+static int sl_charheight; /* status line char height */
+static int sl_charbase; /* topline to baseline distance */
+
+/* Miscellaneous variables.
+ */
+static int cur_x, cur_y; /* current x,y position */
+static int tek_xres, tek_yres; /* resolution of input data */
+static int win_xres, win_yres; /* resolution of draw window */
+static int trailer1 = '\r'; /* trailer code, cursor value */
+static int trailer2 = -1; /* second trailer code (opt) */
+static char s_reset[SZ_ESCAPE]; /* sent to client on reset */
+static char s_resize[SZ_ESCAPE]; /* sent to client on resize */
+static int gio_mode=COMMAND_MODE; /* graphics drawing mode */
+static int gio_datalevel=SET_BITS; /* set, clear, or toggle bits */
+static int workstation_open = 0; /* have issued open workstation */
+static int wait_cursor = 0; /* waiting for cursor input */
+static int wincursor = 0; /* return window cursor */
+static int gio_delay = 0; /* wait for widget to ready */
+static int gio_pending = 0; /* workproc already posted */
+
+/* Imaging variables. */
+static int wi_encoding, wi_raster, wi_x1, wi_y1, wi_nx, wi_ny, wi_bp;
+static int wc_map, wc_first, wc_ncolors;
+
+/* Macros to convert between tektronix and window coordinates. */
+#define X_TEK2WIN(x) ( ((x) * win_xres + tek_xres/2) / tek_xres)
+#define Y_TEK2WIN(y) (win_yres-1 - (((y) * win_yres + tek_yres/2) / tek_yres))
+#define X_WIN2TEK(x) ((( (x)) * tek_xres + win_xres/2) / win_xres)
+#define Y_WIN2TEK(y) (((win_yres-1 - (y)) * tek_yres + win_yres/2) / win_yres)
+
+#define min(a,b) ((a)<(b)?(a):(b))
+#define max(a,b) ((a)>(b)?(a):(b))
+
+/* OBM request queue. */
+struct request {
+ int key;
+ int sx, sy;
+ int raster;
+ int rx, ry;
+ int nchars;
+ char *strval;
+ struct request *next;
+};
+
+typedef struct request Request;
+typedef Request *RequestPtr;
+static RequestPtr request_head = NULL;
+static RequestPtr request_tail = NULL;
+
+static int gio_reset(), gio_clear(), gio_setginmodeterm(), gio_output();
+static int gio_retcursor(), gio_queue_output(), gio_queue_request();
+static int gio_hardreset(), gio_activate(), gio_enable(), gio_tekmode();
+static int gio_processdata(), gio_ptyinput(), gio_escape(), gio_status();
+static int gio_activate_cb(), gio_connect_cb();
+static int gio_deactivate_cb();
+static void gio_keyinput(), gio_resize();
+static void pl_decodepts(), gio_retenq();
+
+/* Externally callable routines. */
+static struct GT_function gio_functions[] = {
+ "reset", gio_hardreset, NULL,
+ "clear", gio_clear, NULL,
+ "input", gio_ptyinput, NULL,
+ "output", gio_processdata, NULL,
+ "activate", gio_activate, NULL,
+ "status", gio_status, NULL,
+ "enable", gio_enable, NULL,
+ "tekmode", gio_tekmode, NULL,
+ "setGinmodeTrailers", gio_setginmodeterm, NULL,
+};
+
+
+/* Translation to hook Tek menu to gterm widget. */
+extern void HandlePopupMenu();
+extern void DeleteWindow();
+extern char *gtermio_getResource();
+static Atom wm_delete_window = 0; /* for ICCCM delete window */
+
+static char *gio_shellTrans =
+ "<ClientMessage>WM_PROTOCOLS: DeleteWindow()\n";
+static char *gio_tekMenu =
+ "!Ctrl <Btn3Down>: popup-xtmenu(tekMenu)\n";
+static XtActionsRec actionsList[] = {
+ { "popup-xtmenu", HandlePopupMenu },
+ { "DeleteWindow", DeleteWindow },
+};
+
+
+/*
+ * GTERMIO external procedures.
+ * ----------------------------
+ */
+
+/* GIO_SETUP -- Called by the high level Gterm window management code during
+ * process startup to establish communications between the caller and gtermio.
+ */
+void
+gio_setup (app_context, argc, argv, fd)
+XtAppContext app_context; /* applications context of caller */
+int argc; /* argument count */
+char *argv[]; /* argument vector */
+int fd; /* fd of pty for terminal i/o */
+{
+ app_con = app_context;
+ pty_fd = fd;
+
+ /* Register client callable functions. */
+ gtermio_register (gio_functions, XtNumber(gio_functions));
+
+ /* Open the object manager. */
+ obm = ObmOpen (app_context, argc, argv);
+ ObmAddCallback (obm, OBMCB_connect|OBMCB_preserve,
+ gio_connect_cb, NULL);
+ ObmAddCallback (obm, OBMCB_activate|OBMCB_preserve,
+ gio_activate_cb, NULL);
+ ObmAddCallback (obm, OBMCB_deactivate|OBMCB_preserve,
+ gio_deactivate_cb, NULL);
+ ObmAddCallback (obm, OBMCB_clientOutput|OBMCB_preserve,
+ gio_queue_output, NULL);
+ ObmAddCallback (obm, OBMCB_setGterm|OBMCB_preserve,
+ gio_reset, NULL);
+
+ /* Register xgterm global actions. */
+ if (!actions_registered) {
+ XtAppAddActions (app_context, actionsList, XtNumber(actionsList));
+ actions_registered++;
+ }
+
+ gio_hardreset (0);
+}
+
+
+/* GIO_POSTCONNECTCALLBACK -- Called by the client to post a procedure to
+ * be called when the display connection is opened or close.
+ */
+void
+gio_postconnectcallback (connect, client_data)
+void (*connect)();
+int client_data;
+{
+ if (obm) {
+ ObmAddCallback (obm, OBMCB_connect|OBMCB_preserve,
+ connect, client_data);
+ }
+}
+
+
+/* GIO_ENABLE -- Enable or disable the graphics window. If graphics is
+ * disabled, all i/o is directed to the text window.
+ */
+static
+gio_enable (dummy, onoff)
+int dummy;
+int onoff;
+{
+ switch (onoff) {
+ case 0:
+ gio_enabled = 0;
+ gio_graphicsenabled = 0;
+ break;
+ case 1:
+ gio_enabled = 1;
+ break;
+ }
+
+ return (gio_enabled);
+}
+
+
+/* GIO_ACTIVATE -- Callback procedure called by the client application to
+ * forcibly activate or deactivate the graphics UI.
+ */
+static
+gio_activate (dummy, state)
+int dummy;
+int state;
+{
+ register RequestPtr rp;
+
+ /* Cancel any buffered command output. */
+ wait_cursor = 0;
+ while (rp = request_head) {
+ request_head = rp->next;
+ free ((char *)rp);
+ }
+ request_head = request_tail = NULL;
+
+ switch (state) {
+ case 0:
+ /* Deactivate. If the application is currently waiting for
+ * cursor input send it EOF to indicate that the graphics window
+ * is deactivating and that the application should revert to
+ * terminal mode.
+ */
+ if (wait_cursor) {
+ gio_retcursor ('\004', 0,0, 0,0,0, 0); /* ctrl/d */
+ if (gw)
+ GtSetCursorType (gw, GtIdleCursor);
+ }
+
+ ObmDeactivate (obm, 1);
+ gtermio_close_workstation();
+ gio_graphicsenabled = 0;
+ break;
+
+ case 1:
+ ObmActivate (obm);
+ gtermio_open_workstation();
+ break;
+ }
+
+ return (ObmActivated (obm));
+}
+
+
+/* GIO_STATUS -- Query the status of the Object Manager, i.e., whether or
+ * not a GUI has been loaded.
+ */
+static
+gio_status (dummy, app_name, app_class)
+int dummy;
+char *app_name; /* can be NULL */
+char *app_class; /* can be NULL */
+{
+ return (ObmStatus (obm, app_name, app_class));
+}
+
+
+/* GIO_ACTIVATE_CB -- Activate callback, called by the gterm widget when the
+ * user interface is activated.
+ */
+static
+gio_activate_cb (dummy, w, state)
+int dummy;
+Widget w;
+int state;
+{
+ register RequestPtr rp;
+
+ if (!state)
+ return;
+
+ /* Cancel any buffered command output. */
+ wait_cursor = 0;
+ while (rp = request_head) {
+ request_head = rp->next;
+ free ((char *)rp);
+ }
+ request_head = request_tail = NULL;
+
+ if (state)
+ gtermio_open_workstation();
+ else
+ gtermio_close_workstation();
+
+ /* Arrange to intercept WM events on toplevel window. */
+ wm_delete_window = XInternAtom (XtDisplay(w),
+ "WM_DELETE_WINDOW", False);
+ XSetWMProtocols (XtDisplay(w), XtWindow(w), &wm_delete_window, 1);
+}
+
+
+/* GIO_DEACTIVATE_CB -- Deactivate callback, called by the gterm widget when
+ * the user interface is deactivated. In reality we're just a dummy routine
+ * to intercept a window close action in a GUI to keep from shutting down
+ * completely.
+ */
+static
+gio_deactivate_cb (dummy, w, state)
+int dummy;
+Widget w;
+int state;
+{
+}
+
+
+/* GIO_CONNECT_CB -- Connect callback, called by the gterm widget when a new
+ * application GUI is initialized or when the display connection is closed.
+ */
+static
+gio_connect_cb (dummy, display, toplevel, state)
+int dummy;
+Display *display;
+Widget toplevel;
+int state;
+{
+ if (state) {
+ extern Widget term;
+ extern char *mktemp();
+ XrmDatabase db1, db2;
+ char *fname, buf[256];
+
+ /* Merge XGterm resources into GUI. There ought to be a way
+ * to do this without writing a temporary file, but there
+ * appears to be no alternative at present.
+ */
+ strcpy (buf, "/tmp/XGdbXXXXXX");
+ if (fname = mktemp (buf)) {
+ /* Merge XGterm resources. */
+ db1 = XrmGetDatabase (XtDisplay(term));
+ XrmPutFileDatabase (db1, fname);
+ db1 = XrmGetFileDatabase (fname);
+ db2 = XrmGetDatabase (XtDisplay(toplevel));
+ XrmMergeDatabases (db1, &db2);
+ unlink (fname);
+
+ /* Pass on the default Tek geometry. */
+ XtVaSetValues (toplevel, XtNgeometry,
+ gtermio_getResource ("geometry"), NULL);
+ }
+
+ XtAugmentTranslations (toplevel,
+ XtParseTranslationTable (gio_shellTrans));
+ } else
+ memset (gterms, 0, sizeof(gterms));
+}
+
+
+/* GIO_TEKMODE -- Direct input to the graphics window or the text window.
+ * Normally this is done by the client via the datastream but this routine
+ * can be called to manually switch the input to a window.
+ */
+static
+gio_tekmode (dummy, onoff)
+int dummy;
+int onoff;
+{
+ switch (onoff) {
+ case 0:
+ gio_graphicsenabled = 0;
+ break;
+ case 1:
+ if (gio_enabled)
+ gio_graphicsenabled = 1;
+ break;
+ }
+
+ return (gio_graphicsenabled);
+}
+
+
+/* GIO_CLEAR -- Clear the graphics window.
+ */
+static
+gio_clear (dummy)
+int dummy;
+{
+ if (gw) {
+ GtClearScreen (gw);
+ GtSetRaster (gw, 0);
+ }
+
+ sl_x = 0;
+ sl_y = sl_charbase;
+ cur_x = tx_leftmargin;
+ cur_y = tx_charbase;
+}
+
+/* debug routine. */
+gio_eventmask (w)
+Widget w;
+{
+ printf ("mask = 0x%x\n", XtBuildEventMask(w));
+}
+
+
+/* GIO_HARDRESET -- Reset everything, including cancelling any cursor read
+ * that may be in progress.
+ */
+static
+gio_hardreset (dummy)
+int dummy;
+{
+ register RequestPtr rp;
+
+ /* If a cusor read is currently in progress send the application EOF
+ * to indicate that it should exit graphics mode.
+ */
+ if (wait_cursor) {
+ gio_retcursor ('\004', 0,0, 0,0,0, 0); /* ctrl/d */
+ if (gw)
+ GtSetCursorType (gw, GtIdleCursor);
+ }
+
+ /* Send a reset message to the client, if the client posted a reset
+ * escape sequence.
+ */
+ if (s_reset[0])
+ v_write (pty_fd, s_reset, strlen(s_reset));
+
+ /* The client must reinitialize the client escapes after a reset. */
+ s_reset[0] = '\0';
+ s_resize[0] = '\0';
+
+ /* Initialize the object manager (destroys any current user
+ * interface).
+ */
+ ObmInitialize (obm);
+ gtermio_close_workstation();
+ if (msgbuf)
+ free (msgbuf);
+ msgbuf = (char *) malloc (len_msgbuf = SZ_MSGBUF);
+ msg_op = 0;
+
+ memset (gterms, 0, sizeof(gterms));
+ actions_registered = 0;
+
+ /* Initialize the input buffer. */
+ g_ip = g_op = g_buf;
+ g_top = &g_buf[SZ_GBUF];
+
+ /* Initialize the graphics state. */
+ gio_mode = COMMAND_MODE;
+ gio_graphicsenabled = 0;
+ workstation_open = 0;
+ gio_delay = 0;
+ pty_stop = 0;
+
+ /* Cancel any buffered command output. */
+ wait_cursor = 0;
+ while (rp = request_head) {
+ request_head = rp->next;
+ free ((char *)rp);
+ }
+ request_head = request_tail = NULL;
+ return (0);
+}
+
+
+/* GIO_RESET -- Reset the state of the gtermio code. Should be called
+ * whenever any important data structures change, e.g., if the graphics
+ * window is resized.
+ */
+static
+gio_reset (notused, w, args)
+int notused;
+register Widget w;
+char *args;
+{
+ register int i;
+ int new_widget;
+
+ /* Make this the active graphics widget. */
+ if ((gw = w) == NULL)
+ return (0);
+
+ GtReset (w);
+ GtActivate (w);
+
+ /* Having a callback post a callback can result in an infinite
+ * loop, so only post the callbacks once per widget.
+ */
+ new_widget = 1;
+ for (i=0; i < MAX_GTERM; i++)
+ if (gterms[i] == w) {
+ new_widget = 0;
+ break;
+ }
+
+ if (new_widget) {
+ /* Tell widget how to talk to gtermio. */
+ GtPostResetProc (w, gio_reset, (XtPointer)NULL);
+ GtPostInputProc (w, gio_keyinput, (XtPointer)NULL);
+ GtPostResizeProc (w, gio_resize, (XtPointer)NULL);
+ GtOverrideTranslations (w, gio_tekMenu);
+ GtTimerInhibit (w, False);
+
+ for (i=0; i < MAX_GTERM; i++)
+ if (!gterms[i]) {
+ gterms[i] = w;
+ break;
+ }
+ }
+
+ GtEraseAlphaCursor (w);
+ GtSetTextRes (w, TEK_ROWS, TEK_COLS);
+ GtGetPhysRes (w, 0, &win_xres, &win_yres);
+ GtSetLogRes (w, win_xres, win_yres);
+ tek_xres = TEK_XRES;
+ tek_yres = TEK_YRES;
+
+ GtGetAlphaTextSize (w, NULL,
+ &tx_charwidth, &tx_charheight, &tx_charbase);
+ tx_maxlines = win_yres / tx_charheight;
+ tx_maxcols = win_xres / tx_charwidth;
+ tx_leftmargin = 0;
+ tx_len = 0;
+
+ GtGetDialogTextSize (w, " ",
+ &sl_charwidth, &sl_charheight, &sl_charbase);
+ sl_x = 0;
+ sl_y = sl_charbase;
+
+ pl_npts = 0;
+ pl_op = 0;
+ pl_pointmode = 0;
+ pl_areamode = 0;
+ ohiy = 0; oloy = 0;
+ ohix = 0; olox = 0;
+
+ cur_x = tx_leftmargin;
+ cur_y = tx_charbase;
+
+ return (0);
+}
+
+
+/* GIO_SETGINMODETERM -- Set the GIN mode (cursor read) trailer codes,
+ * expressed as octal constants in the input string argument.
+ */
+static
+gio_setginmodeterm (dummy, str)
+int dummy;
+char *str;
+{
+ register char *ip;
+ register int n;
+
+ trailer1 = trailer2 = -1;
+
+ for (ip=str; isspace(*ip); ip++)
+ ;
+ if (isdigit(*ip)) {
+ for (n=0; isdigit(*ip); ip++)
+ n = n * 8 + *ip - '0';
+ trailer1 = n;
+ }
+
+ while (*ip && isspace(*ip))
+ ip++;
+ if (isdigit(*ip)) {
+ for (n=0; isdigit(*ip); ip++)
+ n = n * 8 + *ip - '0';
+ trailer2 = n;
+ }
+
+ return (0);
+}
+
+
+/*
+ * Internal procedures.
+ * --------------------
+ */
+
+
+/* GIO_RESIZE -- Callback procedure called by the gterm widget when the
+ * drawing window is resized.
+ */
+static void
+gio_resize (notused, w)
+XtPointer notused;
+Widget w;
+{
+ /* Ignore the resize callback if the widget being resized is not the
+ * active widget.
+ */
+ if (w != gw)
+ return;
+
+ /* Always update the window size variables. */
+ if (gw) {
+ GtGetPhysRes (gw, GtGetRaster(gw), &win_xres, &win_yres);
+ GtSetLogRes (gw, win_xres, win_yres);
+
+ GtGetAlphaTextSize (gw, NULL,
+ &tx_charwidth, &tx_charheight, &tx_charbase);
+ tx_maxlines = win_yres / tx_charheight;
+ tx_maxcols = win_xres / tx_charwidth;
+ tx_leftmargin = 0;
+ tx_len = 0;
+
+ GtGetDialogTextSize (gw, " ",
+ &sl_charwidth, &sl_charheight, &sl_charbase);
+ sl_x = 0;
+ sl_y = sl_charbase;
+ }
+
+ /* Do not do a full reset and redraw if the resize request occurs
+ * while we are processing a buffer full of data. This happens when
+ * the window is first mapped, while processing the first block of
+ * drawing instructions.
+ */
+ if (!g_havedata) {
+ if (gw)
+ gio_reset (NULL, gw, NULL);
+
+ /* If the client posted a resize escape sequence, send this
+ * value to the client as a cursor read to signal the resize
+ * event. The window size is returned in the RX,RY fields.
+ */
+ if (s_resize[0]) {
+ int key = s_resize[0];
+ char *strval = s_resize + 1;
+ gio_queue_request (0,0,0, win_xres, win_yres, key, strval);
+ }
+
+ if (wait_cursor && gw)
+ GtSetCursorType (gw, GtBusyCursor);
+ }
+}
+
+
+/* GIO_QUEUE_OUTPUT -- Queue an OBM client request to be sent to the client
+ * in response to the next client cursor read request. This is a callback
+ * procedure called by OBM to queue a request (command) to be sent to the
+ * client process. If the client already has a request for input (cursor
+ * read) pending, the request will be passed on immediately.
+ */
+static int
+gio_queue_output (fd, tcl, objname, key, strval)
+int fd; /* pty */
+XtPointer tcl; /* not used */
+char *objname; /* client object name (not used) */
+int key; /* cursor keystroke or NULL */
+char *strval; /* cursor strval or literal command */
+{
+ int mapping, raster;
+ int sx, sy, rx, ry;
+
+ /* Get the coordinates of the last event processed by the gterm
+ * widget. This is meaningless for many OBM client requests but
+ * will be valid for, e.g., GUI translation events within the
+ * gterm widget.
+ */
+ if (gw)
+ GtGetCursorPos (gw, &sx, &sy);
+ else
+ sx = sy = 0;
+
+ /* Convert screen (window) coordinates to raster coordinates. */
+ if (gw && wincursor) {
+ raster = GtSelectRaster (gw, 0, GtPixel, sx, sy,
+ GtNDC, &rx, &ry, &mapping);
+ ry = MAXNDC - ry;
+ } else
+ raster = rx = ry = 0;
+
+ return (gio_queue_request (sx, sy, raster, rx, ry, key, strval));
+}
+
+
+/* GIO_QUEUE_REQUEST -- Queue a request.
+ */
+static int
+gio_queue_request (sx, sy, raster, rx, ry, key, strval)
+int sx, sy;
+int raster, rx, ry;
+int key;
+char *strval;
+{
+ register RequestPtr rp;
+ int buflen, nchars;
+ char *buf;
+
+ nchars = strlen (strval);
+ buflen = sizeof(Request) + nchars + 1;
+ if ((buf = (char *) malloc (buflen)) == NULL)
+ return (-1);
+
+ rp = (RequestPtr) buf;
+ rp->key = key;
+ rp->sx = sx;
+ rp->sy = sy;
+ rp->raster = raster;
+ rp->rx = rx;
+ rp->ry = ry;
+ rp->nchars = nchars;
+ rp->strval = buf + sizeof(Request);
+ strcpy (rp->strval, strval);
+ rp->next = NULL;
+
+ /* Link request at tail of request list. */
+ if (!request_head)
+ request_head = request_tail = rp;
+ else {
+ request_tail->next = rp;
+ request_tail = rp;
+ }
+
+ /* If a client cursor read is currently pending return the next
+ * available request.
+ */
+ if (wait_cursor)
+ gio_output();
+}
+
+
+/* GIO_OUTPUT -- Return the next available OBM request from the request
+ * queue to the client, in response to a ready for input (cursor read) from
+ * the client. The data sent to the client consists of a cursor value
+ * struct and/or a data string. If both are sent the cursor value struct
+ * contains a field giving the length of the data string which follows.
+ */
+static int
+gio_output()
+{
+ register RequestPtr rp;
+
+ if (!(rp = request_head))
+ return (-1);
+
+ /* Return a cursor read as if "key" had been typed. */
+ if (rp->key) {
+ gio_retcursor (rp->key, rp->sx, rp->sy,
+ rp->raster, rp->rx, rp->ry, rp->nchars);
+ }
+
+ /* Return the string value, if any. */
+ if (rp->nchars > 0) {
+ v_write (pty_fd, rp->strval, rp->nchars);
+ if (!rp->key)
+ v_write (pty_fd, "\r", 1);
+ }
+
+ /* Remove the request from the head of the queue. */
+ if (!(request_head = rp->next))
+ request_tail = NULL;
+ free ((char *)rp);
+
+ return (0);
+}
+
+
+/* GIO_PTYINPUT -- Process pty input packets. Output directed to the
+ * terminal (/dev/tty) by the applications program appears as read-pending
+ * events on the pty seen by the XGterm program. We let the XGterm pty input
+ * code monitor the pty and respond to read-pending events. The low level
+ * read code reads the data and then calls us to process the data packet. We
+ * extract any graphics output from the packet and append it to the gio
+ * buffer. If data is added to the gio buffer a gio-data-pending event is
+ * queued so that the graphics drawing code will be called to process the new
+ * data. The remaining data, or a null length packet if the packet contained
+ * only graphics data, is returned to the caller, completing the read.
+ * Sometime later the graphics drawing code will be called to process the data.
+ */
+static int
+gio_ptyinput (notused, ttybuf, nchars)
+int notused;
+char *ttybuf; /* raw data on input, tty data on output */
+int nchars; /* nchars of raw data */
+{
+ register char *itop = ttybuf + nchars;
+ register char *op, *ip = ttybuf, ch;
+
+ if (!gio_enabled || nchars <= 0)
+ return (nchars);
+
+ /* If in text mode, make a quick scan for the graphics start sequence
+ * and return the entire data packet if graphics mode is not entered.
+ * Graphics start is indicated either by GS or by the xterm graphics
+ * start sequence XGS.
+ */
+ if (!gio_graphicsenabled) {
+ while (ip < itop && *ip != GS &&
+ !(*ip == ESC && strncmp (ip+1, XGS, LEN_XGS) == 0))
+ ip++;
+ if (ip >= itop)
+ return (nchars);
+ else
+ op = ip;
+ } else
+ op = ttybuf;
+
+ /* If the gio buffer has reached the high-water mark, call the
+ * output processing routine to dispose of some of the data.
+ */
+ if (g_spaceleft < max(GB_MINSPACE,nchars)) {
+ while (g_spaceleft < max(GB_BIGSPACE,nchars))
+ if (gio_processdata())
+ break;
+ }
+
+ /* Process rest of data in graphics mode. IP is pointing at the
+ * first char of graphics data, ITOP at the top of the buffer,
+ * and OP at the next tty output char. Filter out any NULs in
+ * the process of copying the data.
+ */
+ while (ip < itop)
+ if (gio_graphicsenabled) {
+ while (ip < itop) {
+ if ((ch = *ip++) == CAN) {
+gend: g_putc (ch);
+ gio_graphicsenabled = 0;
+ break;
+ } else if (ch == ESC && strncmp(ip,XGE,LEN_XGE) == 0) {
+ /* Treat xterm graphics terminator the same as CAN. */
+ ip += LEN_XGE;
+ trailer1 = '\r';
+ ch = CAN;
+ goto gend;
+ } else if (ch)
+ g_putc (ch);
+ }
+ } else {
+ while (ip < itop) {
+ ch = *ip++;
+ if (ch == GS) {
+gstart: g_putc (GS);
+ gio_graphicsenabled = 1;
+ break;
+ } else if (ch == ESC && strncmp(ip,XGS,LEN_XGS) == 0) {
+ ip += LEN_XGS;
+ trailer1 = -1;
+ goto gstart;
+ } else if (ch)
+ *op++ = ch;
+ }
+ }
+
+ return (op - ttybuf);
+}
+
+
+/* GIO_PROCESSDATA -- Called to process graphics instructions and data from
+ * the gio buffer. This is the routine which actually draws lines and text
+ * in the graphics window. May be called repeatedly to process any amount of
+ * data at a time. If there is a great amount of data to be processed the
+ * routine should return occasionally to allow the other XGterm event handlers
+ * to run (operation is not fully asynchronous).
+ *
+ * Graphics data is processed as a stream with no record boundaries, so that
+ * operation is not dependent on how data is buffered through the system.
+ * The graphics engine is a state machine which is by definition always in a
+ * legal state; garbage input causes garbage output, just like a real terminal.
+ * The states are as follows:
+ *
+ * COMMAND_MODE This is the initial state. Characters are accumulated
+ * until a known state is recognized. Receipt of ESC
+ * always causes command mode to be entered, since
+ * additional characters are needed to define the next
+ * instruction.
+ *
+ * ALPHA_MODE Characters are drawn in the graphics window at the
+ * "current" position (normally set beforehand with a
+ * GS/US vector move), using the alpha mode font.
+ * Receipt of any control code causes alpha mode to be
+ * exited.
+ *
+ * TEXT_MODE Text mode is a special mode used to write transient
+ * text in the status line, using the text mode font.
+ * Lines of text are accumulated and displayed on the
+ * status line in reverse video; successive lines of text
+ * overwrite one another. The status line is cleared
+ * when text mode is entered, even if no text is drawn.
+ * Text mode is terminated by receipt of GS or CAN.
+ *
+ * VECTOR_MODE Vector mode refers to both polyline and polypoint
+ * vector sequences. The vertices of the points are
+ * accumulated in a buffer and displayed when the buffer
+ * fills or when vector mode is terminated. Vector
+ * mode is terminated by receipt of any control code;
+ * the tektronix coordinate encoding maps all possible
+ * coordinates into the printable ascii codes.
+ *
+ * MESSAGE_MODE In message mode input text is accumulated in a buffer
+ * and eventually passed to the object manager, which
+ * delivers the message to the referenced object.
+ * Messages are used to download the user interface to
+ * be executed by the object manager, and during
+ * execution messages are used to set the values of
+ * user interface parameters to allow the UI to track
+ * the state of the client application.
+ *
+ * WIMAGE_MODE Pixels are accumulated and written to a gterm widget
+ * image raster.
+ *
+ * WCMAP_MODE Color triplets are accumulated and written to the
+ * gterm widget colormap.
+ *
+ * WIOMAP_MODE Colormap indices are accumulated and written to the
+ * gterm widget iomap.
+ *
+ * CURSOR_MODE The crosshair cursor is turned on, signifying to the
+ * user that the system is waiting on a cursor read.
+ * Output processing ceases until the user types a key
+ * or presses a mouse button to trigger the cursor read.
+ * The cursor value is then encoded and transmitted back
+ * to the pty, and output processing resumes.
+ *
+ * Clearing the screen causes the mode to be reset to command mode, and all
+ * other drawing parameters to be set to their default values, e.g., data level
+ * on, solid line type, and so on.
+ */
+static int
+gio_processdata()
+{
+ register int quota, ch;
+ unsigned char *save_ip, *ip_start;
+ int textwidth;
+
+ /* If gio_delay is set wait for the Gterm widget to become ready
+ * before processing any further graphics input data.
+ */
+ if (gio_delay) {
+ gio_delay = gw ? !GtReady (gw) : 0;
+ if (gio_delay)
+ return (1);
+ }
+
+ if (!g_havedata)
+ return (1);
+
+ if (gw)
+ GtSetCursorType (gw, GtIdleCursor);
+ g_mark (ip_start);
+
+ /* Process data.
+ */
+ for (quota=MAX_QUOTA; --quota >= 0 && g_getc(ch) >= 0; ) {
+ if (ch == 0 || gio_enabled < 0)
+ continue;
+again:
+ switch (gio_mode) {
+ case COMMAND_MODE:
+ switch (ch) {
+ case GS:
+ case FS:
+ case RS:
+ gio_mode = VECTOR_MODE;
+ pl_pointmode = (ch == FS);
+ pl_areamode = (ch == RS);
+ pl_npts = 0;
+ pl_op = 0;
+
+ /* Only execute an open workstation if we have not already
+ * done so and if the next command is something other than
+ * close workstation, i.e., no-op sequences GS-CAN are
+ * filtered out, since they would only cause a pointless
+ * switch to the graphics frame and back without drawing.
+ * The open workstation sequence is GS,US.
+ */
+ if (ch == GS && !workstation_open) {
+ if (g_getc(ch) < 0) {
+ g_ungetc (GS);
+ gio_mode = COMMAND_MODE;
+ goto exit;
+ } else if (ch != CAN) {
+ gtermio_open_workstation();
+ if (ch != EM) {
+ /* Create default UI if none has been
+ * downloaded already by client. Note
+ * that this causes a gio_reset.
+ */
+ gio_activate (NULL, 1);
+ }
+ if (gw)
+ GtActivate (gw);
+ workstation_open = 1;
+ g_ungetc (ch);
+ goto exit;
+ }
+ }
+ break;
+
+ case US:
+ case CR:
+ gio_mode = ALPHA_MODE;
+ tx_len = 0;
+ if (ch == CR)
+ goto again;
+ break;
+
+ case EM:
+ gio_mode = MESSAGE_MODE;
+ msg_op = 0;
+ break;
+
+ case CAN:
+ if (workstation_open) {
+ gtermio_close_workstation();
+ if (gw) {
+ GtSetCursorType (gw, GtIdleCursor);
+ GtDeactivate (gw);
+ }
+ workstation_open = 0;
+ }
+ gio_mode = COMMAND_MODE;
+ goto exit;
+
+ case ESC:
+ g_ungetc (ch);
+ g_mark (save_ip);
+ if (gw)
+ GtEraseAlphaCursor (gw);
+ if ((gio_mode = gio_escape()) == -1) {
+ gio_mode = COMMAND_MODE;
+ g_reset (save_ip);
+ goto exit;
+ } else if (gio_mode == CURSOR_MODE)
+ goto again;
+ break;
+
+ case BEL:
+ if (gw)
+ GtBell (gw);
+ break;
+
+ default:
+ ; /* ignore unknown control chars */
+ }
+ break;
+
+ case MESSAGE_MODE:
+ if (isprint (ch) || isspace(ch)) {
+ if (msg_op >= len_msgbuf) {
+ len_msgbuf += INC_MSGBUF;
+ msgbuf = (char *) realloc (msgbuf, len_msgbuf);
+ }
+ /* Map CRLF and LFLF into LF. */
+ if ((ch == '\n' || ch == '\r') && msg_op > 0 &&
+ msgbuf[msg_op-1] == '\r')
+ --msg_op;
+ msgbuf[msg_op++] = ch;
+
+ } else {
+ msgbuf[msg_op] = '\0';
+ if (msg_op) {
+ char *object, *message;
+ char *ip;
+
+ for (object=ip=msgbuf; *ip && !isspace(*ip); ip++)
+ ;
+ *ip = '\0';
+ message = ip + 1;
+
+ ObmDeliverMsg (obm, object, message);
+ msg_op = 0;
+ }
+ gio_mode = COMMAND_MODE;
+ goto again;
+ }
+ break;
+
+ case WIMAGE_MODE:
+ /* Accumulate pixels and write to a gterm widget image
+ * raster.
+ */
+ if (ch >= 040) {
+ if (msg_op >= len_msgbuf) {
+ len_msgbuf += INC_MSGBUF;
+ msgbuf = (char *) realloc (msgbuf, len_msgbuf);
+ }
+ msgbuf[msg_op++] = ch - 040;
+ } else {
+ if (gw && wi_nx*wi_ny <= len_msgbuf)
+ GtWritePixels (gw, wi_raster, msgbuf, wi_bp,
+ wi_x1, wi_y1, wi_nx, wi_ny);
+
+ msg_op = 0;
+ gio_mode = COMMAND_MODE;
+ goto again;
+ }
+ break;
+
+ case WCMAP_MODE:
+ /* Accumulate colormap triplets and write to the gterm widget
+ * colormap.
+ */
+ if (ch >= 040) {
+ if (msg_op >= len_msgbuf) {
+ len_msgbuf += INC_MSGBUF;
+ msgbuf = (char *) realloc (msgbuf, len_msgbuf);
+ }
+ msgbuf[msg_op++] = ch;
+ } else {
+ register int i, j, v;
+ register char *ip = msgbuf;
+ unsigned short r[MAX_COLORS], g[MAX_COLORS], b[MAX_COLORS];
+ int b1, b2;
+
+ msgbuf[msg_op++] = 0;
+ for (i=0; i < wc_ncolors; i++) {
+ for (j=0; j < 3; j++) {
+ b1 = *ip++; b2 = *ip++;
+ if (b1 < 040 || b2 < 040) {
+ wc_ncolors = i;
+ break;
+ } else {
+ v = ((b1 - 040) << 4) | (b2 - 040);
+ if (j == 0)
+ r[i] = (v << 8);
+ else if (j == 1)
+ g[i] = (v << 8);
+ else
+ b[i] = (v << 8);
+ }
+ }
+ }
+
+ if (gw && wc_ncolors)
+ GtWriteColormap (gw, wc_map,
+ wc_first, wc_ncolors, r, g, b);
+
+ msg_op = 0;
+ gio_mode = COMMAND_MODE;
+ goto again;
+ }
+ break;
+
+ case WIOMAP_MODE:
+ /* Accumulate colormap indices and write to the gterm widget
+ * iomap.
+ */
+ if (ch >= 040) {
+ if (msg_op >= len_msgbuf) {
+ len_msgbuf += INC_MSGBUF;
+ msgbuf = (char *) realloc (msgbuf, len_msgbuf);
+ }
+ msgbuf[msg_op++] = ch;
+ } else {
+ register int b1, b2, i;
+ register char *ip = msgbuf;
+ unsigned short iomap[MAX_COLORS];
+
+ msgbuf[msg_op++] = 0;
+ for (i=0; i < wc_ncolors; i++) {
+ b1 = *ip++; b2 = *ip++;
+ if (b1 < 040 || b2 < 040) {
+ wc_ncolors = i;
+ break;
+ } else
+ iomap[i] = ((b1 - 040) << 4) | (b2 - 040);
+ }
+
+ if (gw && wc_ncolors)
+ GtWriteIomap (gw, iomap, wc_first, wc_ncolors);
+
+ msg_op = 0;
+ gio_mode = COMMAND_MODE;
+ goto again;
+ }
+ break;
+
+ case ALPHA_MODE:
+ /* Tek alpha mode is used to write text to random positions on
+ * the screen, or to write lines of text to the gio window in
+ * "storage scope" mode, where the left and right columns are
+ * alternately written into with an inclusive-or rop. Alpha
+ * text is graphics output, part of the graphics being drawn.
+ */
+ if (ch >= 040) {
+ tx_buf[tx_len++] = ch;
+ } else if (ch == '\t') {
+ tx_buf[tx_len++] = 040;
+ if (tx_leftmargin == 0 && tx_charwidth)
+ while ((tx_len + (cur_x / tx_charwidth)) % 8 != 0)
+ tx_buf[tx_len++] = 040;
+ } else if (ch == '\010' || ch == '\177') {
+ if (tx_len > 0)
+ tx_len--;
+ else if (cur_x > tx_leftmargin)
+ cur_x -= tx_charwidth;
+ } else {
+flush_alpha: if (tx_len > 0) {
+ tx_buf[tx_len] = '\0';
+ if (gw) {
+ GtEraseAlphaCursor (gw);
+ GtDrawAlphaText (gw, cur_x, cur_y, tx_buf);
+ }
+ }
+
+ if (gw) {
+ GtGetAlphaTextSize (gw, tx_buf,
+ &textwidth, &tx_charheight, &tx_charbase);
+ cur_x += textwidth;
+ } else
+ cur_x += tx_len * tx_charwidth;
+ tx_len = 0;
+
+ if (ch == '\n' || ch == BREAK_LINE) {
+ cur_y += tx_charheight;
+ if (cur_y > win_yres) {
+ if (tx_leftmargin == 0)
+ tx_leftmargin = win_xres / 2;
+ else
+ tx_leftmargin = 0;
+ cur_y = tx_charbase;
+ if (cur_x < tx_leftmargin)
+ cur_x = tx_leftmargin;
+ }
+ if (ch == BREAK_LINE)
+ cur_x = tx_leftmargin;
+ } else if (ch == '\r') {
+ cur_x = tx_leftmargin;
+ } else if (ch != 0) {
+ gio_mode = COMMAND_MODE;
+ goto again;
+ }
+ }
+
+ /* Break long lines at the right margin. */
+ if (tx_len && cur_x + (tx_len * tx_charwidth) >= win_xres) {
+ ch = BREAK_LINE;
+ goto flush_alpha;
+ }
+
+ break;
+
+ case TEXT_MODE:
+ /* Status or dialog text. In a graphics application this is
+ * written to the dialog area of the gterm widget. GUIs can
+ * intercept this text (which is the stdout or stderr of a
+ * task when in graphics mode), e.g. to display it in a
+ * message area. This is done by defining a UI parameter
+ * "textout" and registering a callback to process the output
+ * text. If the GUI does not define such a parameter no error
+ * message is printed. Only multicharacter messages are
+ * passed on in this way. In graphics applications where the
+ * user is typing into the status line and single characters
+ * are being echoed to the status line, this prevents the
+ * echoed characters from being delivered as messages (it also
+ * prevents any actual single-character messages from being
+ * delivered).
+ */
+ if (ch >= 040)
+ tx_buf[tx_len++] = ch;
+ else if (ch == '\t')
+ tx_buf[tx_len++] = 040;
+ else if (ch == '\010' || ch == '\177') {
+ if (tx_len > 0) {
+ char delstr[2];
+ delstr[0] = tx_buf[--tx_len];
+ delstr[1] = '\0';
+ GtGetDialogTextSize (gw, delstr,
+ &textwidth, &sl_charheight, &sl_charbase);
+ sl_x -= textwidth;
+ if (gw) {
+ GtEraseAlphaCursor (gw);
+ GtDrawDialogText (gw, sl_x, sl_y, " ");
+ }
+ }
+ } else {
+ if (tx_len > 0) {
+ tx_buf[tx_len] = '\0';
+ if (tx_len > 1) {
+
+ if (ch == '\n') {
+ tx_buf[tx_len] = ch;
+ tx_buf[tx_len+1] = '\0';
+ }
+ tx_buf[tx_len] = '\0';
+ if (tx_len) {
+ char txtbuf[2048];
+ sprintf (txtbuf, "setValue {%s}\0", tx_buf);
+ ObmDeliverMsg (obm, "textout", txtbuf);
+ }
+ }
+/* if (gw && tx_len == 1) {*/
+ if (gw) {
+ GtEraseAlphaCursor (gw);
+ GtDrawDialogText (gw, sl_x, sl_y, tx_buf);
+ }
+ }
+
+ if (gw) {
+ GtGetDialogTextSize (gw, tx_buf,
+ &textwidth, &sl_charheight, &sl_charbase);
+ sl_x += tx_len * sl_charwidth;
+ } else
+ sl_x += tx_len * sl_charwidth;
+
+ if (sl_x > win_xres - sl_charwidth)
+ sl_x = win_xres - sl_charwidth;
+ tx_len = 0;
+
+ if (ch == '\r' || ch == '\n') {
+ if (gw)
+ GtEndDialog (gw);
+ sl_x = 0;
+ } else if (ch != 0) {
+ gio_mode = COMMAND_MODE;
+ goto again;
+ }
+ }
+
+ /* Truncate long lines. */
+ if (sl_charwidth)
+ if (sl_x / sl_charwidth + tx_len >= MAX_TEXTCHARS)
+ if (tx_len > 0)
+ --tx_len;
+ else
+ sl_x -= sl_charwidth;
+ break;
+
+ case VECTOR_MODE:
+ /* Following receipt of GS, accumulate encoded coordinate data
+ * until the buffer fills or a control code is received, then
+ * decode the encoded data to reconstruct the original data
+ * vector, and draw the vector.
+ */
+ if (ch >= 040)
+ pl_text[pl_op++] = ch;
+ if (ch < 040 || pl_op >= MAX_PLPTS)
+ pl_decodepts();
+
+ if (ch < 040 || pl_npts >= MAX_PLPTS) {
+ if (pl_pointmode && pl_npts >= 1) {
+ if (gw)
+ GtDrawPolymarker (gw, pl_p, pl_npts);
+ } else if (pl_areamode && pl_npts >= 1) {
+ if (gw)
+ GtDrawPolygon (gw, pl_p, pl_npts);
+ } else if (pl_npts >= 2) {
+ if (gw)
+ GtDrawPolyline (gw, pl_p, pl_npts);
+ }
+
+ if (pl_npts > 0) {
+ cur_x = pl_p[pl_npts-1].x;
+ cur_y = pl_p[pl_npts-1].y;
+ pl_npts = 0;
+ }
+
+ if (ch < 040) {
+ gio_mode = COMMAND_MODE;
+ pl_op = 0;
+ goto again;
+ }
+ }
+
+ break;
+
+ case CURSOR_MODE:
+ /* Initiate a cursor read, i.e., inform the GUI that the
+ * client is ready for the next input command. If a request
+ * has already been queued for output to the client we send
+ * it back immediately with gio_output. Otherwise cursor
+ * mode is entered for the active graphics widget and the
+ * wait_cursor flag is set to indicate that the client is
+ * ready for input.
+ */
+ if (wait_cursor++) {
+ /* This shouldn't ever happen. */
+ g_ungetc (ch);
+ gio_mode = COMMAND_MODE;
+ if (gw)
+ GtSetCursorType (gw, GtBusyCursor);
+ } else {
+ /* Return the next request from the output queue, or
+ * enter cursor input mode if no requests are queued.
+ */
+ if (gio_output() == 0) {
+ wait_cursor = 0;
+ gio_mode = COMMAND_MODE;
+ } else {
+ ObmActivate (obm);
+ if (gw)
+ GtSetCursorType (gw, GtGinmodeCursor);
+ }
+ }
+ break;
+ }
+ }
+
+exit:
+ /* Flush any buffered text before exiting, as applications will assume
+ * that text appears on the screen as soon as chars are written to the
+ * terminal (any buffering must be hidden).
+ */
+ if (tx_len > 0) {
+ ch = 0;
+ goto again;
+ }
+
+ if (gw)
+ GtFlush (gw);
+
+ if (g_havedata && !g_equal(ip_start) && ch != ESC && !wait_cursor)
+ return (0); /* call again */
+ else {
+ if (!wait_cursor) {
+ /* Update the alpha cursor to indicate we are ready
+ * for more input.
+ */
+ if (gw)
+ GtWriteAlphaCursor (gw, cur_x, cur_y);
+ }
+ gio_pending = 0;
+ return (1); /* all done */
+ }
+}
+
+
+/* PL_DECODEPTS -- Convert a sequence of textronix encoded polyline vertices
+ * into a simple array of [x,y] coordinate pairs. Each coordinate pair is
+ * encoded as a sequence of from 1 to 4 bytes, with bytes being optionally
+ * eliminated which do not change from one coordinate pair to the next. The
+ * possible coordinate pair encodings are as follows:
+ *
+ * HIY LOY HIX LOX
+ * 01xxxxx 11xxxxx 01xxxxx 10xxxxx
+ * 040 140 040 100
+ *
+ * HIY LOX
+ * HIY LOY LOX
+ * HIY LOY HIX LOX
+ * LOY HIX LOX
+ * LOY LOX
+ * LOX
+ *
+ * In words, bytes which do not change need not be sent, except for the low-x
+ * byte (LOX). If the high-x byte changes, then the low-x byte must also be
+ * sent. The current position, stored as the 4 byte encoding, is cleared to
+ * zero when the screen is cleared.
+ */
+static void
+pl_decodepts()
+{
+ register char *ip, *itop;
+ int hiy, loy, hix, lox, type, data, nb;
+ char *ip_save;
+
+ for (ip_save=ip=pl_text, itop = &pl_text[pl_op]; ip < itop; ) {
+ hiy = ohiy; loy = oloy;
+ hix = ohix; lox = olox;
+
+ for (nb=0; nb < 99 && ip < itop; nb++) {
+ type = (*ip & 0140);
+ data = (*ip++ & 037);
+
+ switch (type) {
+ case 040: /* HIY, HIX */
+ if (nb == 0)
+ hiy = data;
+ else
+ hix = data;
+ break;
+ case 0140: /* LOY */
+ loy = data;
+ break;
+
+ case 0100:
+ /* Receipt of LOX marks the end of the variable length
+ * sequence of bytes required to form the next [x,y].
+ */
+ lox = data;
+ pl_p[pl_npts].x = X_TEK2WIN ((hix << 5) + lox);
+ pl_p[pl_npts].y = Y_TEK2WIN ((hiy << 5) + loy);
+ if (gw && GtGetRaster(gw))
+ pl_p[pl_npts].y = (win_yres-1) - pl_p[pl_npts].y;
+
+ /* Update current position. */
+ ohiy = hiy; oloy = loy;
+ ohix = hix; olox = lox;
+
+ ip_save = ip;
+ pl_npts++;
+ nb = 99; /* EXIT */
+ break;
+ }
+ }
+ }
+
+ /* If there is any data left over (too few bytes to form a coordinate
+ * pair) move these to the start of the buffer.
+ */
+ for (pl_op=0, ip=ip_save; ip < itop; )
+ pl_text[pl_op++] = *ip++;
+}
+
+
+/* GIO_KEYINPUT -- Called by the Gterm widget when keyboard input occurs.
+ * If cursor mode is in effect keyboard input terminates the cursor read,
+ * causing a cursor value sequence to be output, otherwise character input is
+ * merely passed on.
+ */
+static void
+gio_keyinput (notused, w, event)
+XtPointer notused;
+Widget w;
+XEvent *event;
+{
+ XKeyEvent *xkey = &event->xkey;
+ char strbuf[SZ_STRBUF];
+ int mapping, raster, sx, sy, rx, ry;
+ int nbytes;
+
+ sx = xkey->x;
+ sy = xkey->y;
+
+ nbytes = XLookupString (xkey, strbuf, SZ_STRBUF, NULL, NULL);
+ if (nbytes > 0) {
+ if (wait_cursor) {
+ /* Return raster number and raster coordinates of raster
+ * cursor is in, in addition to the usual screen coordinates.
+ */
+ if (wincursor) {
+ raster = GtSelectRaster (w, 0, GtPixel, sx, sy,
+ GtNDC, &rx, &ry, &mapping);
+ ry = MAXNDC - ry;
+ } else
+ raster = rx = ry = 0;
+
+ gio_retcursor (strbuf[0], sx, sy, raster, rx, ry, 0);
+ if (w)
+ GtSetCursorType (w, GtBusyCursor);
+ } else
+ v_write (pty_fd, strbuf, nbytes);
+ }
+}
+
+
+/* GIO_RETCURSOR -- Encode and return a cursor value to the pty (and thence
+ * to the program which initiated the cursor read). Clear the cursor read
+ * pending flag so that output processing can resume, and restart the output
+ * processing routine.
+ */
+static int
+gio_retcursor (key, sx, sy, raster, rx, ry, datalen)
+int key; /* key (or whatever) typed to trigger read */
+int sx, sy; /* screen coords of event */
+int raster; /* raster number */
+int rx, ry; /* raster coords of event */
+int datalen; /* nchars of data following cursor value */
+{
+ register int n=0, mc_x, mc_y;
+ char curval[20];
+
+ /* Ignore cursor events unless requested via program control.
+ */
+ if (!wait_cursor)
+ return (-1);
+
+ curval[n++] = key;
+
+ mc_x = (sx > 0) ? X_WIN2TEK(sx) : 0;
+ curval[n++] = ((mc_x >> 5) & 037) | 040;
+ curval[n++] = ((mc_x ) & 037) | 040;
+
+ mc_y = (sy > 0) ? Y_WIN2TEK(sy) : 0;
+ curval[n++] = ((mc_y >> 5) & 037) | 040;
+ curval[n++] = ((mc_y ) & 037) | 040;
+
+ /* The following optional fields are not part of a standard Tek
+ * cursor return value sequence.
+ */
+ if (wincursor) {
+ curval[n++] = ((datalen >> 5) & 037) | 040;
+ curval[n++] = ((datalen ) & 037) | 040;
+
+ curval[n++] = ((raster >> 5) & 037) | 040;
+ curval[n++] = ((raster ) & 037) | 040;
+
+ mc_x = (rx > 0) ? rx : 0;
+ curval[n++] = ((mc_x >> 10) & 037) | 040;
+ curval[n++] = ((mc_x >> 5) & 037) | 040;
+ curval[n++] = ((mc_x ) & 037) | 040;
+
+ mc_y = (ry > 0) ? ry : 0;
+ curval[n++] = ((mc_y >> 10) & 037) | 040;
+ curval[n++] = ((mc_y >> 5) & 037) | 040;
+ curval[n++] = ((mc_y ) & 037) | 040;
+ }
+
+ if (trailer1 >= 0)
+ curval[n++] = trailer1;
+ if (trailer2 >= 0)
+ curval[n++] = trailer2;
+
+ v_write (pty_fd, curval, n);
+
+ wait_cursor = 0;
+ gio_mode = COMMAND_MODE;
+
+ if (!gio_delay)
+ gio_processdata();
+}
+
+
+/* GIO_RETENQ -- Respond to the ESC ENQ request.
+ */
+static void
+gio_retenq()
+{
+ register int mc_x, mc_y;
+ char curval[7];
+ int len;
+
+ /* Graphics status word. */
+ curval[0] = (061 | ((gio_mode == ALPHA_MODE) << 2)
+ | ((tx_leftmargin != 0) << 1));
+
+ /* Alpha cursor position. */
+ mc_x = X_WIN2TEK (cur_x);
+ mc_y = Y_WIN2TEK (cur_y);
+
+ curval[1] = ((mc_x >> 5) & 037) | 040;
+ curval[2] = ((mc_x ) & 037) | 040;
+ curval[3] = ((mc_y >> 5) & 037) | 040;
+ curval[4] = ((mc_y ) & 037) | 040;
+ curval[5] = trailer1;
+ curval[6] = trailer2;
+
+ len = 5;
+ if (trailer1 >= 0) len++;
+ if (trailer2 >= 0) len++;
+ v_write (pty_fd, curval, len);
+}
+
+
+/* Definitions and data structures for a fast table driven fixed pattern
+ * escape sequence recognizer. Given character I of the sequence there will
+ * be N candidate sequences that have matched the first I-1 chars. Examine
+ * each to produce the next list of candidate sequences. Continue until either
+ * a sequence is matched or there are no more candidates. Variable length
+ * sequences such as "ESC[Pl;PcH" are handled as a special case: the general
+ * form of these is ESC '[' <digits> [';' <digits>...] LET.
+ */
+#define MAX_CANDIDATES 64 /* max candidate escseq */
+#define MAX_FIELDS 6 /* max fields in an escseq */
+
+struct _esc {
+ char e_tag; /* integer code for escseq */
+ char e_seq[MAX_FIELDS+1]; /* the sequence itself */
+};
+
+static struct _esc *e_cand1[MAX_CANDIDATES]; /* 1st candidates array */
+static struct _esc *e_cand2[MAX_CANDIDATES]; /* 2nd candidates array */
+static struct _esc **e_pcand, **e_acand; /* candidates arrays */
+static int e_npcand, e_nacand; /* number of candidates */
+static int e_charno; /* char being examined */
+static int scanok; /* clr if decode fails */
+static int startscan(), getint(), getstr(), endscan();
+
+static struct _esc e_table[] = {
+#include "gtermio.esc" /* Gterm escape sequence table */
+ { 0, 0,0,0,0,0,0,0 }
+};
+
+
+/* GIO_ESCAPE -- Recognize and process graphics escape sequences, i.e.,
+ * all multicharacter command codes beginning with ESC. The simple single
+ * character command codes are handled directly by the data processing code.
+ * The escapes have no well defined pattern to them, hence we must simply
+ * consume characters until a legal escape sequence is recognized or the
+ * sequence is found to not match any known sequence. It is possible that
+ * all of the characters forming a sequence will not yet have been deposited
+ * in the input buffer, in which case we return -1, indicating to our caller
+ * that we should be called back later to rescan the same input, when more
+ * data becomes available. Otherwise, we take whatever action is implied
+ * for the escape sequence and return the new mode to the interpreter code.
+ * If an unrecognized escape sequence is encountered it is discarded and we
+ * return in alpha mode so that subsequent input appears as garbage on the
+ * screen.
+ */
+static int
+gio_escape()
+{
+ register struct _esc *esc;
+ register int ch, i, j;
+ struct _esc **e_temp;
+ int tag;
+
+ /* Discard the ESC and get the first char. */
+ g_getc (ch);
+ if (g_getc (ch) < 0)
+ return (-1);
+
+ /* Build the initial list of candidates. This is the most expensive
+ * step, since all sequences must be examined.
+ */
+ for (esc=e_table, e_pcand=e_cand1, e_npcand=0; esc->e_tag; esc++)
+ if (ch == esc->e_seq[0]) {
+ if (esc->e_seq[1] == 0) {
+ tag = esc->e_tag;
+ goto action;
+ }
+ e_pcand[e_npcand++] = esc;
+ }
+
+ /* If there were no candidates, we are done. */
+ if (e_npcand == 0) {
+ g_ungetc (ch);
+ return (ALPHA_MODE);
+ }
+
+ /* Examine successive characters from the input, building a new,
+ * shorter candidate list on each iteration. This should converge
+ * very rapidly one way or the other.
+ */
+ for (j=1, e_acand=e_cand2; j < MAX_FIELDS && e_npcand > 0; j++) {
+ if (g_getc(ch) < 0)
+ return (-1);
+
+ /* Examine the next character of each sequence in the list of
+ * candidate sequences. If we have a complete match, we are
+ * done, else if we have a single character match add the seq
+ * to the new candidates list.
+ */
+ e_nacand = 0;
+ for (i=0; i < e_npcand; i++) {
+ esc = e_pcand[i];
+ if (ch == esc->e_seq[j]) {
+ if (esc->e_seq[j+1] == 0) {
+ tag = esc->e_tag;
+ goto action;
+ }
+ e_acand[e_nacand++] = esc;
+ }
+ }
+
+ e_temp = e_pcand; e_pcand = e_acand; e_acand = e_temp;
+ e_npcand = e_nacand;
+ }
+
+ /* If the escape sequence was recognized the above code should have
+ * vectored off to the action marker below. If we fall through the
+ * loop it can only mean that we have an unrecognized escape sequence,
+ * so discard it and return in command mode.
+ */
+ g_ungetc (ch);
+ return (ALPHA_MODE);
+
+action:
+ /* Process the escape sequence. */
+ switch (tag) {
+ case ESC_SETTEXTMODE:
+ sl_x = 0;
+ tx_len = 0;
+ if (gw)
+ GtStartDialog (gw);
+ return (TEXT_MODE);
+
+ case ESC_ENQUIRE:
+ gio_retenq();
+ break;
+ case ESC_READCURSOR:
+ wincursor = 0;
+ return (CURSOR_MODE);
+ case ESC_WINCURSOR:
+ wincursor = 1;
+ return (CURSOR_MODE);
+ case ESC_SETCURSOR:
+ if (gw)
+ GtSetCursorPos (gw, cur_x, cur_y);
+ break;
+
+ case ESC_CLEARSCREEN:
+ if (gw) {
+ GtClearScreen (gw);
+ GtSetRaster (gw, 0);
+ }
+ tx_leftmargin = 0;
+ cur_x = tx_leftmargin;
+ cur_y = tx_charbase;
+ ohiy = 0; oloy = 0;
+ ohix = 0; olox = 0;
+ gio_datalevel = SET_BITS;
+ pl_pointmode = 0;
+ pl_areamode = 0;
+ return (ALPHA_MODE);
+
+ case ESC_SETCHARSIZE0:
+ case ESC_SETCHARSIZE1:
+ case ESC_SETCHARSIZE2:
+ case ESC_SETCHARSIZE3:
+ /* Ignore these for now. */
+ break;
+
+ case ESC_SETDATALEVEL0:
+ if (gw)
+ GtSetDataLevel (gw, GtSet);
+ break;
+ case ESC_SETDATALEVEL1:
+ if (gw)
+ GtSetDataLevel (gw, GtClear);
+ break;
+ case ESC_SETDATALEVEL2:
+ if (gw)
+ GtSetDataLevel (gw, GtInvert);
+ break;
+
+ case ESC_SETLINESTYLE0:
+ if (gw)
+ GtSetLineStyle (gw, GtSolid);
+ break;
+ case ESC_SETLINESTYLE1:
+ if (gw)
+ GtSetLineStyle (gw, GtDashed);
+ break;
+ case ESC_SETLINESTYLE2:
+ if (gw)
+ GtSetLineStyle (gw, GtDotted);
+ break;
+ case ESC_SETLINESTYLE3:
+ if (gw)
+ GtSetLineStyle (gw, GtDashDot);
+ break;
+ case ESC_SETLINESTYLE4:
+ if (gw)
+ GtSetLineStyle (gw, GtDash3Dot);
+ break;
+
+ case ESC_SETLINEWIDTH0:
+ if (gw)
+ GtSetLineWidth (gw, 1);
+ break;
+ case ESC_SETLINEWIDTH1:
+ if (gw)
+ GtSetLineWidth (gw, 2);
+ break;
+ case ESC_SETLINEWIDTH2:
+ if (gw)
+ GtSetLineWidth (gw, 3);
+ break;
+
+ case ESC_SETCOLOR0:
+ if (gw)
+ GtSetColorIndex (gw, 0);
+ break;
+ case ESC_SETCOLOR1:
+ if (gw)
+ GtSetColorIndex (gw, 1);
+ break;
+ case ESC_SETCOLOR2:
+ if (gw)
+ GtSetColorIndex (gw, 2);
+ break;
+ case ESC_SETCOLOR3:
+ if (gw)
+ GtSetColorIndex (gw, 3);
+ break;
+ case ESC_SETCOLOR4:
+ if (gw)
+ GtSetColorIndex (gw, 4);
+ break;
+ case ESC_SETCOLOR5:
+ if (gw)
+ GtSetColorIndex (gw, 5);
+ break;
+ case ESC_SETCOLOR6:
+ if (gw)
+ GtSetColorIndex (gw, 6);
+ break;
+ case ESC_SETCOLOR7:
+ if (gw)
+ GtSetColorIndex (gw, 7);
+ break;
+ case ESC_SETCOLOR8:
+ if (gw)
+ GtSetColorIndex (gw, 8);
+ break;
+ case ESC_SETCOLOR9: /* see also SETCOLORN */
+ if (gw)
+ GtSetColorIndex (gw, 9);
+ break;
+
+ /* Imaging escape sequences. These are encoded as follows:
+ *
+ * ESC r <code> [ P ; P ; ... ] <data>
+ *
+ * By the time we get here the input is positioned to just before the
+ * first '[' as only the fixed pattern part of the escape will have
+ * been recognized.
+ *
+ * Imaging instructions consist of a fixed pattern escape sequence
+ * identifying the instruction, followed by a fixed number of ASCII
+ * encoded parameters, followed in some cases by a variable-sized data
+ * field.
+ *
+ * Pixels are encoded as ascii codes by adding 040 to the value of each
+ * pixel. The range of possible pixel values is about 200. The EC
+ * field in the read/write pixels instruction specifies the encoding
+ * type; this field is ignored at present and should be zero.
+ *
+ * The query raster instruction returns the raster size as a flag 0/1
+ * indicating whether the given raster exists, followed by pair of
+ * decimal encoded ascii numbers giving the raster size. Raster 0 is
+ * the gterm window hence this function may be used to query the window
+ * size. The create raster instruction may be used to request that the
+ * window size be changed; the server may or may not permit such a
+ * resize request to succeed.
+ *
+ * Colors are RGB color intensity triplets. Intensities are 8 bit
+ * values (0-255) encoded as two bytes, 4 bits plus 040 in each byte.
+ *
+ * Return values are encoded the same as input data, with a two byte
+ * trailer following the data (usually CR).
+ */
+
+ case ESC_SETRESET:
+ { /* parameters: reset-str */
+ if (startscan() || getstr(s_reset) || endscan())
+ return (-1);
+ }
+ break;
+
+ case ESC_SETRESIZE:
+ { /* parameters: resize-str */
+ if (startscan() || getstr(s_resize) || endscan())
+ return (-1);
+ }
+ break;
+
+ case ESC_RASTERINIT:
+ if (gw)
+ GtRasterInit (gw);
+ break;
+
+ case ESC_CREATERASTER:
+ { /* parameters: RN RT NX NY BP */
+ int raster, type, width, height, depth;
+ if (startscan())
+ return (-1);
+ if (getint(&raster) || getint(&type) ||
+ getint(&width) || getint(&height) || getint(&depth))
+ return (-1);
+ if (endscan())
+ return (-1);
+ if (gw && scanok)
+ GtCreateRaster (gw, raster, type, width, height, depth);
+ }
+ break;
+
+ case ESC_DESTROYRASTER:
+ { /* parameters: RN */
+ int raster;
+ if (startscan() || getint(&raster) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtDestroyRaster (gw, raster);
+ }
+ break;
+
+ case ESC_QUERYRASTER:
+ { /* parameters: RN */
+ int status, raster, type, width, height, depth;
+ char obuf[80];
+
+ if (startscan() || getint(&raster) || endscan())
+ return (-1);
+ if (gw) {
+ if (!GtReady (gw)) {
+ gio_delay = 1;
+ return (-1);
+ }
+ status = GtQueryRaster (gw, raster,
+ &type, &width, &height, &depth);
+ }
+
+ sprintf (obuf, "\033[5;%d;%d;%d;%d;%d]",
+ status, type, width, height, depth);
+ v_write (pty_fd, obuf, strlen(obuf));
+ }
+ break;
+
+ case ESC_SETRASTER:
+ { /* parameters: RN */
+ int raster;
+ if (startscan() || getint(&raster) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtSetRaster (gw, raster);
+ }
+ break;
+
+ case ESC_WRITEPIXELS:
+ { /* parameters: RN EC X1 Y1 NX NY BP (NX*NY pixels follow) */
+ if (startscan())
+ return (-1);
+ if (getint(&wi_raster) || getint(&wi_encoding) ||
+ getint(&wi_x1) || getint(&wi_y1) ||
+ getint(&wi_nx) || getint(&wi_ny) || getint(&wi_bp))
+ return (-1);
+ if (endscan())
+ return (-1);
+ msg_op = 0;
+ return (scanok ? WIMAGE_MODE : COMMAND_MODE);
+ }
+ break;
+
+ case ESC_READPIXELS:
+ { /* parameters: RN EC X1 Y1 NX NY BP (return NX*NY pixels) */
+ int raster, encoding, x1, y1, nx, ny, nbits, npix=0;
+ register unsigned char *data, *op;
+ unsigned char obuf[128];
+ register int i;
+
+ if (startscan())
+ return (-1);
+ if (getint(&raster) || getint(&encoding) || getint(&x1) ||
+ getint(&y1) || getint(&nx) || getint(&ny) ||
+ getint(&nbits))
+ return (-1);
+ if (endscan())
+ return (-1);
+
+ if (scanok) {
+ npix = nx * ny;
+ if ((data = (unsigned char *) malloc (npix)) == NULL)
+ return (-1);
+ if (gw && scanok) {
+ if (GtReadPixels (gw, raster, data,
+ nbits, x1, y1, nx, ny) == ERR)
+ npix = 0;
+ }
+ }
+
+ /* Return the pixels bracked by ESC and the trailers. This is
+ * done even if no data is returned, e.g. due to a parameter
+ * error or read error.
+ */
+ op = obuf;
+ *op++ = '\033';
+ for (i=0, op=obuf; i < npix; i++) {
+/* *op++ = data[i] + 040;*/
+ *op++ = ((data[i] >> 4) & 017) + 040;
+ *op++ = ((data[i] ) & 017) + 040;
+ if (op - obuf > 100) {
+ v_write (pty_fd, obuf, op-obuf);
+ op = obuf;
+ }
+ }
+ if (trailer1 >= 0) *op++ = trailer1;
+ if (trailer2 >= 0) *op++ = trailer2;
+ v_write (pty_fd, obuf, op-obuf);
+
+ if (scanok)
+ free (data);
+ }
+ break;
+
+ case ESC_REFRESHPIXELS:
+ { /* parameters: RN CT X1 Y1 NX NY */
+ int x1, y1, nx, ny;
+ int raster, ct;
+
+ if (startscan())
+ return (-1);
+ if (getint(&raster) || getint(&ct) ||
+ getint(&x1) || getint(&y1) ||
+ getint(&nx) || getint(&ny))
+ return (-1);
+ if (endscan())
+ return (-1);
+
+ if (gw && scanok)
+ GtRefreshPixels (gw, raster, ct, x1,y1,nx,ny);
+ }
+ break;
+
+ case ESC_SETPIXELS:
+ { /* parameters: RN CT X1 Y1 NX NY CO OP */
+ int raster, ct, co, op;
+ int x1, y1, nx, ny;
+
+ if (startscan())
+ return (-1);
+ if (getint(&raster) || getint(&ct) ||
+ getint(&x1) || getint(&y1) ||
+ getint(&nx) || getint(&ny) ||
+ getint(&co) || getint(&op))
+ return (-1);
+ if (endscan())
+ return (-1);
+
+ if (gw && scanok)
+ GtSetPixels (gw, raster, ct, x1,y1,nx,ny, co,op);
+ }
+ break;
+
+ case ESC_WRITECMAP:
+ { /* parameters: MP FC NC (NC color triplets follow) */
+
+ if (startscan() || getint(&wc_map) || getint(&wc_first) ||
+ getint(&wc_ncolors) || endscan())
+ return (-1);
+
+ msg_op = 0;
+ if (wc_ncolors > MAX_COLORS)
+ wc_ncolors = MAX_COLORS;
+ return (scanok ? WCMAP_MODE : COMMAND_MODE);
+ }
+ break;
+
+ case ESC_READCMAP:
+ { /* parameters: MP FC NC (return NC color triplets) */
+ int map, first, ncolors, buflen;
+ unsigned short *buf, *r, *g, *b, v[3];
+ unsigned char obuf[128];
+ register unsigned char *op;
+ register int i, j;
+
+ if (startscan() || getint(&map) || getint(&first) ||
+ getint(&ncolors) || endscan())
+ return (-1);
+
+ /* Get the colormap data into a buffer. */
+ if (scanok) {
+ buflen = ncolors * 3 * sizeof (unsigned short);
+ if ((buf = (unsigned short *) malloc (buflen)) == NULL)
+ return (-1);
+ b = (g = (r = buf) + ncolors) + ncolors;
+ if (gw) {
+ ncolors = GtReadColormap (gw, map,first,ncolors,r,g,b);
+ if (ncolors == ERR)
+ ncolors = 0;
+ } else
+ ncolors = 0;
+ } else
+ ncolors = 0;
+
+ /* Return the encoded colors bracked by ESC and the trailers.
+ * This is done even if no data is returned, e.g. due to a
+ * parameter error or read error.
+ */
+ op = obuf;
+ *op++ = '\033';
+ for (i=0, op=obuf; i < ncolors; i++) {
+ v[0] = (r[i] >> 8); v[1] = (g[i] >> 8); v[2] = (b[i] >> 8);
+ for (j=0; j < 3; j++) {
+ *op++ = ((v[j] >> 4) & 017) + 040;
+ *op++ = ((v[j] ) & 017) + 040;
+ }
+
+ if (op - obuf > 100) {
+ v_write (pty_fd, obuf, op-obuf);
+ op = obuf;
+ }
+ }
+ if (trailer1 >= 0) *op++ = trailer1;
+ if (trailer2 >= 0) *op++ = trailer2;
+ v_write (pty_fd, obuf, op-obuf);
+
+ if (scanok)
+ free (buf);
+ }
+ break;
+
+ case ESC_LOADCMAP:
+ { /* parameters: MP OF DX DY */
+ int colormap, gki_offset, dx, dy;
+ float offset, slope;
+
+ if (startscan() || getint(&colormap) || getint(&gki_offset) ||
+ getint(&dx) || getint(&dy) || endscan())
+ return (-1);
+
+ offset = (float)gki_offset / (float)((MAXNDC + 1) / 4);
+ slope = dx ? (float)dy / (float)dx : MAXNDC;
+
+ if (gw && scanok)
+ GtLoadColormap (gw, colormap, offset, slope);
+ }
+ break;
+
+ case ESC_FREECMAP:
+ { /* parameters: MP */
+ int colormap;
+ if (startscan() || getint(&colormap) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtFreeColormap (gw, colormap);
+ }
+ break;
+
+ case ESC_WRITEIOMAP:
+ { /* parameters: FC NC (NC color triplets follow) */
+
+ if (startscan() || getint(&wc_first) ||
+ getint(&wc_ncolors) || endscan())
+ return (-1);
+
+ msg_op = 0;
+ if (wc_ncolors > MAX_COLORS)
+ wc_ncolors = MAX_COLORS;
+ return (scanok ? WIOMAP_MODE : COMMAND_MODE);
+ }
+ break;
+
+ case ESC_READIOMAP:
+ { /* parameters: FC NC (return NC color triplets) */
+ int first, ncolors, buflen;
+ unsigned short *iomap, v;
+ unsigned char obuf[128];
+ register unsigned char *op;
+ register int i;
+
+ if (startscan() || getint(&first) ||
+ getint(&ncolors) || endscan())
+ return (-1);
+
+ /* Get the iomap data into a buffer. */
+ if (scanok) {
+ buflen = ncolors * sizeof (unsigned short);
+ if ((iomap = (unsigned short *) malloc (buflen)) == NULL)
+ return (-1);
+ if (gw) {
+ GtReadIomap (gw, iomap, first, ncolors);
+ } else
+ ncolors = 0;
+ } else
+ ncolors = 0;
+
+ /* Return the encoded array bracked by ESC and the trailers.
+ * This is done even if no data is returned, e.g. due to a
+ * parameter error or read error.
+ */
+ op = obuf;
+ *op++ = '\033';
+ for (i=0, op=obuf; i < ncolors; i++) {
+ v = iomap[i];
+ *op++ = ((v >> 4) & 017) + 040;
+ *op++ = ((v ) & 017) + 040;
+
+ if (op - obuf > 100) {
+ v_write (pty_fd, obuf, op-obuf);
+ op = obuf;
+ }
+ }
+ if (trailer1 >= 0) *op++ = trailer1;
+ if (trailer2 >= 0) *op++ = trailer2;
+ v_write (pty_fd, obuf, op-obuf);
+
+ if (scanok)
+ free (iomap);
+ }
+ break;
+
+ case ESC_SETCOLORN:
+ { /* parameters: CN */
+ int color;
+ if (startscan() || getint(&color) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtSetColorIndex (gw, color);
+ }
+ break;
+
+ case ESC_SETLINEWIDTHN:
+ { /* parameters: LW */
+ int width;
+ if (startscan() || getint(&width) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtSetLineWidth (gw, width);
+ }
+ break;
+
+ case ESC_INITMAPPINGS:
+ if (gw)
+ GtInitMappings (gw);
+ break;
+
+ case ESC_COPYRASTER:
+ { /* parameters: OP SR ST SX SY SW SH DR DT DX DY DW DH */
+ int src, dst, rop;
+ int st, sx, sy, sw, sh;
+ int dt, dx, dy, dw, dh;
+
+ if (startscan())
+ return (-1);
+ if (getint(&rop) || getint(&src) || getint(&st))
+ return (-1);
+ if (getint(&sx) || getint(&sy) || getint(&sw) || getint(&sh))
+ return (-1);
+ if (getint(&dst) || getint(&dt))
+ return (-1);
+ if (getint(&dx) || getint(&dy) || getint(&dw) || getint(&dh))
+ return (-1);
+ if (endscan())
+ return (-1);
+
+ if (gw && scanok)
+ GtCopyRaster (gw, rop,
+ src, st, sx, sy, sw, sh,
+ dst, dt, dx, dy, dw, dh);
+ }
+ break;
+
+ case ESC_SETMAPPING:
+ { /* parameters: MP OP SR ST SX SY SW SH DR DT DX DY DW DH */
+ int mapping, rop, src, st, sx, sy, sw, sh;
+ int dst, dt, dx, dy, dw, dh;
+
+ if (startscan())
+ return (-1);
+ if (getint(&mapping) || getint(&rop))
+ return (-1);
+ if (getint(&src) || getint(&st))
+ return (-1);
+ if (getint(&sx) || getint(&sy) || getint(&sw) || getint(&sh))
+ return (-1);
+ if (getint(&dst) || getint(&dt))
+ return (-1);
+ if (getint(&dx) || getint(&dy) || getint(&dw) || getint(&dh))
+ return (-1);
+ if (endscan())
+ return (-1);
+
+ if (gw && scanok)
+ GtSetMapping (gw, mapping, rop,
+ src, st, sx, sy, sw, sh,
+ dst, dt, dx, dy, dw, dh);
+ }
+ break;
+
+ case ESC_GETMAPPING:
+ { /* parameters: MP (return mapping) */
+ int mapping, rop, enable;
+ int src, st, sx, sy, sw, sh;
+ int dst, dt, dx, dy, dw, dh;
+ char obuf[128];
+
+ if (startscan() || getint(&mapping) || endscan())
+ return (-1);
+
+ enable = src=st=sx=sy=sw=sh = dst=dt=dx=dy=dw=dh = 0;
+ if (gw && scanok) {
+ enable = GtGetMapping (gw, mapping, &rop,
+ &src, &st, &sx, &sy, &sw, &sh,
+ &dst, &dt, &dx, &dy, &dw, &dh);
+ }
+
+ sprintf (obuf,
+ "\033[6;%d;%d %d;%d;%d;%d;%d;%d %d;%d;%d;%d;%d;%d]",
+ enable + 1, rop,
+ src, st, sx, sy, sw, sh,
+ dst, dt, dx, dy, dw, dh);
+ v_write (pty_fd, obuf, strlen(obuf));
+ }
+ break;
+
+ case ESC_ENABLEMAPPING:
+ { /* parameters: MP FL */
+ int mapping, flags;
+ if (startscan() || getint(&mapping) ||
+ getint(&flags) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtEnableMapping (gw, mapping, flags);
+ }
+ break;
+
+ case ESC_DISABLEMAPPING:
+ { /* parameters: MP FL */
+ int mapping, flags;
+ if (startscan() || getint(&mapping) ||
+ getint(&flags) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtDisableMapping (gw, mapping, flags);
+ }
+ break;
+
+ case ESC_REFRESHMAPPING:
+ { /* parameters: MP */
+ int mapping;
+ if (startscan() || getint(&mapping) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtRefreshMapping (gw, mapping);
+ }
+ break;
+
+ case ESC_FREEMAPPING:
+ { /* parameters: MP */
+ int mapping;
+ if (startscan() || getint(&mapping) || endscan())
+ return (-1);
+ if (gw && scanok)
+ GtFreeMapping (gw, mapping);
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ return (COMMAND_MODE);
+}
+
+
+/* STARTSCAN -- Reset the scanok flag at the start of a scan.
+ */
+static int
+startscan()
+{
+ register int ch;
+
+ /* Skip forward to the '[' preceeding the first argument. */
+ while (g_getc (ch) >= 0)
+ if (ch == '[') {
+ scanok = 1;
+ return (0);
+ }
+
+ scanok = 0;
+ return (1);
+}
+
+
+/* GETINT -- Get the next integer token from the input stream. A nonzero
+ * value is returned if the input is exhausted. The scanok flag is cleared
+ * if a decode error occurs.
+ */
+static int
+getint (value)
+int *value;
+{
+ register int ch;
+ register int v;
+ int neg = 0;
+
+ if (scanok) {
+ /* Skip to the next integer token. */
+ for (;;) {
+ if (g_getc (ch) < 0)
+ return (1);
+ if (isdigit(ch) || ch == '-')
+ break;
+ else if (ch == '[' || ch == ' ' || ch == ';')
+ ;
+ else if (ch < 040) {
+ g_ungetc (ch);
+ scanok = 0;
+ return (1);
+ }
+ }
+
+ /* Accumulate the integer value. */
+ if (ch == '-') {
+ neg++;
+ g_getc (ch);
+ } else
+ neg = 0;
+ if (isdigit (ch)) {
+ for (v = ch - '0'; ; ) {
+ if (g_getc (ch) < 0)
+ return (1);
+ if (isdigit(ch))
+ v = v * 10 + ch - '0';
+ else {
+ *value = neg ? -v : v;
+ g_ungetc (ch);
+ break;
+ }
+ }
+ }
+ }
+
+ return (0);
+}
+
+
+/* GETSTR -- Get the next string token from the input stream. A nonzero
+ * value is returned if the input is exhausted. The scanok flag is cleared
+ * if a decode error occurs.
+ */
+static int
+getstr (value)
+char *value;
+{
+ register int ch;
+ register char *op = value;
+
+ if (scanok) {
+ /* Skip to the next string token. */
+ for (;;) {
+ if (g_getc (ch) < 0)
+ return (1);
+ if (ch && ch != '[' && ch != ' ' && ch != ';')
+ break;
+ }
+
+ /* Accumulate the string value. */
+ for (*op++ = ch; ; ) {
+ if (g_getc (ch) < 0)
+ return (1);
+ if (!isspace(ch) && ch != ';' && ch != ']')
+ *op++ = ch;
+ else {
+ *op = '\0';
+ g_ungetc (ch);
+ break;
+ }
+ }
+ }
+
+ return (0);
+}
+
+
+/* ENDSCAN -- Scan forward to the ']' input argument list delimiter.
+ */
+static int
+endscan()
+{
+ register int ch;
+
+ /* Skip to the ']' delimiter. */
+ for (;;) {
+ if (g_getc (ch) < 0)
+ return (1);
+ if (isdigit(ch) || ch == ' ' | ch == ';')
+ ;
+ else if (ch == ']')
+ break;
+ else if (ch < 040) {
+ g_ungetc (ch);
+ scanok = 0;
+ break;
+ }
+ }
+
+ return (0);
+}
diff --git a/vendor/x11iraf/xgterm/gtermio.esc b/vendor/x11iraf/xgterm/gtermio.esc
new file mode 100644
index 00000000..b33b41c1
--- /dev/null
+++ b/vendor/x11iraf/xgterm/gtermio.esc
@@ -0,0 +1,122 @@
+/*
+ * GTERMIO.ESC -- Macros and data defining the escape sequences recognized
+ * by the graphics terminal. Ambiguous cases are resolved in favor of the
+ * entry which occurs first in the table.
+ */
+#define ESC_SETTEXTMODE 1
+#define ESC_ENQUIRE 2
+#define ESC_READCURSOR 3
+#define ESC_WINCURSOR 4
+#define ESC_CLEARSCREEN 5
+#define ESC_SETCURSOR 6
+#define ESC_SETCHARSIZE0 7
+#define ESC_SETCHARSIZE1 8
+#define ESC_SETCHARSIZE2 9
+#define ESC_SETCHARSIZE3 10
+#define ESC_SETDATALEVEL0 11
+#define ESC_SETDATALEVEL1 12
+#define ESC_SETDATALEVEL2 13
+#define ESC_SETLINESTYLE0 14
+#define ESC_SETLINESTYLE1 15
+#define ESC_SETLINESTYLE2 16
+#define ESC_SETLINESTYLE3 17
+#define ESC_SETLINESTYLE4 18
+#define ESC_SETLINEWIDTH0 19
+#define ESC_SETLINEWIDTH1 20
+#define ESC_SETLINEWIDTH2 21
+#define ESC_SETLINEWIDTHN 22
+#define ESC_SETCOLOR0 23
+#define ESC_SETCOLOR1 24
+#define ESC_SETCOLOR2 25
+#define ESC_SETCOLOR3 26
+#define ESC_SETCOLOR4 27
+#define ESC_SETCOLOR5 28
+#define ESC_SETCOLOR6 29
+#define ESC_SETCOLOR7 30
+#define ESC_SETCOLOR8 31
+#define ESC_SETCOLOR9 32
+#define ESC_SETCOLORN 33
+#define ESC_SETRESET 34
+#define ESC_SETRESIZE 35
+#define ESC_RASTERINIT 36
+#define ESC_CREATERASTER 37
+#define ESC_DESTROYRASTER 38
+#define ESC_QUERYRASTER 39
+#define ESC_SETRASTER 40
+#define ESC_WRITEPIXELS 41
+#define ESC_READPIXELS 42
+#define ESC_REFRESHPIXELS 43
+#define ESC_SETPIXELS 44
+#define ESC_COPYRASTER 45
+#define ESC_WRITECMAP 46
+#define ESC_READCMAP 47
+#define ESC_LOADCMAP 48
+#define ESC_FREECMAP 49
+#define ESC_WRITEIOMAP 50
+#define ESC_READIOMAP 51
+#define ESC_INITMAPPINGS 52
+#define ESC_SETMAPPING 53
+#define ESC_GETMAPPING 54
+#define ESC_ENABLEMAPPING 55
+#define ESC_DISABLEMAPPING 56
+#define ESC_REFRESHMAPPING 57
+#define ESC_FREEMAPPING 58
+
+ESC_SETTEXTMODE, 015, 000, 000, 000, 000, 000, 0,
+ESC_ENQUIRE, ENQ, 000, 000, 000, 000, 000, 0,
+ESC_READCURSOR, SUB, 000, 000, 000, 000, 000, 0,
+ESC_WINCURSOR, '/', SUB, 000, 000, 000, 000, 0,
+ESC_CLEARSCREEN, 014, 000, 000, 000, 000, 000, 0,
+ESC_SETCURSOR, '/', 'f', 000, 000, 000, 000, 0,
+ESC_SETCHARSIZE0, '0', 000, 000, 000, 000, 000, 0,
+ESC_SETCHARSIZE1, '1', 000, 000, 000, 000, 000, 0,
+ESC_SETCHARSIZE2, '2', 000, 000, 000, 000, 000, 0,
+ESC_SETCHARSIZE3, '3', 000, 000, 000, 000, 000, 0,
+ESC_SETDATALEVEL0, '/', '0', 'd', 000, 000, 000, 0,
+ESC_SETDATALEVEL1, '/', '1', 'd', 000, 000, 000, 0,
+ESC_SETDATALEVEL2, '/', '2', 'd', 000, 000, 000, 0,
+ESC_SETLINESTYLE0, '`', 000, 000, 000, 000, 000, 0,
+ESC_SETLINESTYLE1, 'a', 000, 000, 000, 000, 000, 0,
+ESC_SETLINESTYLE2, 'b', 000, 000, 000, 000, 000, 0,
+ESC_SETLINESTYLE3, 'c', 000, 000, 000, 000, 000, 0,
+ESC_SETLINESTYLE4, 'd', 000, 000, 000, 000, 000, 0,
+ESC_SETLINEWIDTH0, '/', '0', 'w', 000, 000, 000, 0,
+ESC_SETLINEWIDTH1, '/', '1', 'w', 000, 000, 000, 0,
+ESC_SETLINEWIDTH2, '/', '2', 'w', 000, 000, 000, 0,
+ESC_SETLINEWIDTHN, '/', 'n', 'w', 000, 000, 000, 0,
+ESC_SETCOLOR0, '/', '0', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR1, '/', '1', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR2, '/', '2', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR3, '/', '3', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR4, '/', '4', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR5, '/', '5', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR6, '/', '6', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR7, '/', '7', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR8, '/', '8', 'c', 000, 000, 000, 0,
+ESC_SETCOLOR9, '/', '9', 'c', 000, 000, 000, 0,
+ESC_SETCOLORN, '/', 'n', 'c', 000, 000, 000, 0,
+ESC_SETRESET, 's', 'r', 'e', 000, 000, 000, 0,
+ESC_SETRESIZE, 's', 's', 'z', 000, 000, 000, 0,
+ESC_RASTERINIT, 'r', 'i', 'r', 000, 000, 000, 0,
+ESC_CREATERASTER, 'r', 'c', 'r', 000, 000, 000, 0,
+ESC_DESTROYRASTER, 'r', 'd', 'e', 000, 000, 000, 0,
+ESC_QUERYRASTER, 'r', 'q', 'r', 000, 000, 000, 0,
+ESC_SETRASTER, 'r', 's', 'r', 000, 000, 000, 0,
+ESC_WRITEPIXELS, 'r', 'w', 'r', 000, 000, 000, 0,
+ESC_READPIXELS, 'r', 'r', 'd', 000, 000, 000, 0,
+ESC_REFRESHPIXELS, 'r', 'r', 'p', 000, 000, 000, 0,
+ESC_SETPIXELS, 'r', 's', 'p', 000, 000, 000, 0,
+ESC_COPYRASTER, 'r', 'c', 'o', 000, 000, 000, 0,
+ESC_WRITECMAP, 'r', 'w', 'c', 000, 000, 000, 0,
+ESC_READCMAP, 'r', 'r', 'c', 000, 000, 000, 0,
+ESC_LOADCMAP, 'r', 'l', 'c', 000, 000, 000, 0,
+ESC_FREECMAP, 'r', 'f', 'c', 000, 000, 000, 0,
+ESC_WRITEIOMAP, 'r', 'w', 'o', 000, 000, 000, 0,
+ESC_READIOMAP, 'r', 'r', 'o', 000, 000, 000, 0,
+ESC_INITMAPPINGS, 'r', 'i', 'm', 000, 000, 000, 0,
+ESC_SETMAPPING, 'r', 's', 'm', 000, 000, 000, 0,
+ESC_GETMAPPING, 'r', 'g', 'm', 000, 000, 000, 0,
+ESC_ENABLEMAPPING, 'r', 'e', 'm', 000, 000, 000, 0,
+ESC_DISABLEMAPPING, 'r', 'd', 'm', 000, 000, 000, 0,
+ESC_REFRESHMAPPING, 'r', 'r', 'm', 000, 000, 000, 0,
+ESC_FREEMAPPING, 'r', 'f', 'm', 000, 000, 000, 0,
diff --git a/vendor/x11iraf/xgterm/gtermio.h b/vendor/x11iraf/xgterm/gtermio.h
new file mode 100644
index 00000000..1eafe170
--- /dev/null
+++ b/vendor/x11iraf/xgterm/gtermio.h
@@ -0,0 +1,8 @@
+/*
+ * GTERMIO.H -- Public definitions for the gterm i/o protocol module.
+ */
+struct GT_function {
+ char *name; /* callback name */
+ int (*func)(); /* callback function */
+ XtPointer data; /* callback data */
+};
diff --git a/vendor/x11iraf/xgterm/input.c b/vendor/x11iraf/xgterm/input.c
new file mode 100644
index 00000000..ef806738
--- /dev/null
+++ b/vendor/x11iraf/xgterm/input.c
@@ -0,0 +1,295 @@
+/*
+ * $XConsortium: input.c,v 1.18 94/05/14 15:53:34 gildea 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.
+ */
+
+/* input.c */
+
+#include "ptyx.h" /* gets Xt headers, too */
+#include <X11/keysym.h>
+#include <X11/DECkeysym.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+/* The following are from X11R6 and allow some R6 code to be used below. */
+#ifndef XK_KP_Home
+#define XK_KP_Home 0xFF95
+#define XK_KP_Left 0xFF96
+#define XK_KP_Up 0xFF97
+#define XK_KP_Right 0xFF98
+#define XK_KP_Down 0xFF99
+#define XK_KP_Prior 0xFF9A
+#define XK_KP_Page_Up 0xFF9A
+#define XK_KP_Next 0xFF9B
+#define XK_KP_Page_Down 0xFF9B
+#define XK_KP_End 0xFF9C
+#define XK_KP_Begin 0xFF9D
+#define XK_KP_Insert 0xFF9E
+#define XK_KP_Delete 0xFF9F
+#endif
+
+static XComposeStatus compose_status = {NULL, 0};
+static char *kypd_num =
+ " XXXXXXXX\tXXX\rXXXxxxxXXXXXXXXXXXXXXXXXXXXX*+,-./0123456789XXX=";
+static char *kypd_apl =
+ " ABCDEFGHIJKLMNOPQRSTUVWXYZ??????abcdefghijklmnopqrstuvwxyzXXX";
+static char *cur = "DACB";
+
+static int funcvalue(), sunfuncvalue();
+extern Boolean sunFunctionKeys;
+
+static void
+AdjustAfterInput (screen)
+register 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();
+ 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;
+ }
+}
+
+Input (keyboard, screen, event, eightbit)
+ register TKeyboard *keyboard;
+ register TScreen *screen;
+ register XKeyEvent *event;
+ Bool eightbit;
+{
+
+#ifdef I18N
+#define STRBUFSIZE 500
+#else
+#define STRBUFSIZE 100
+#endif
+
+ char strbuf[STRBUFSIZE];
+ register char *string;
+ register int key = FALSE;
+ int pty = screen->respond;
+ int nbytes;
+ KeySym keysym = 0;
+ ANSI reply;
+#ifdef I18N
+ Status status_return;
+#endif
+
+#ifdef I18N
+ if (screen->xic)
+ nbytes = XmbLookupString (screen->xic, event, strbuf, STRBUFSIZE,
+ &keysym, &status_return);
+ else
+ nbytes = XLookupString (event, strbuf, STRBUFSIZE,
+ &keysym, &compose_status);
+#else
+ nbytes = XLookupString (event, strbuf, STRBUFSIZE,
+ &keysym, &compose_status);
+#endif
+
+ string = &strbuf[0];
+ reply.a_pintro = 0;
+ reply.a_final = 0;
+ reply.a_nparam = 0;
+ reply.a_inters = 0;
+
+ if (keysym >= XK_KP_Home && keysym <= XK_KP_Begin) {
+ keysym += XK_Home - XK_KP_Home;
+ }
+
+ if (IsPFKey(keysym)) {
+ reply.a_type = SS3;
+ unparseseq(&reply, pty);
+ unparseputc((char)(keysym-XK_KP_F1+'P'), pty);
+ key = TRUE;
+ } else if (IsCursorKey(keysym) &&
+ keysym != XK_Prior && keysym != XK_Next) {
+ if (keyboard->flags & CURSOR_APL) {
+ reply.a_type = SS3;
+ unparseseq(&reply, pty);
+ unparseputc(cur[keysym-XK_Left], pty);
+ } else {
+ reply.a_type = CSI;
+ reply.a_final = cur[keysym-XK_Left];
+ unparseseq(&reply, pty);
+ }
+ key = TRUE;
+ } else if (IsFunctionKey(keysym) || IsMiscFunctionKey(keysym) ||
+ keysym == XK_Prior || keysym == XK_Next ||
+ keysym == DXK_Remove || keysym == XK_KP_Delete ||
+ keysym == XK_KP_Insert) {
+ reply.a_type = CSI;
+ reply.a_nparam = 1;
+ if (sunFunctionKeys) {
+ reply.a_param[0] = sunfuncvalue (keysym);
+ reply.a_final = 'z';
+ } else {
+ reply.a_param[0] = funcvalue (keysym);
+ reply.a_final = '~';
+ }
+ if (reply.a_param[0] > 0)
+ unparseseq(&reply, pty);
+ key = TRUE;
+ } else if (IsKeypadKey(keysym)) {
+ if (keyboard->flags & KYPD_APL) {
+ reply.a_type = SS3;
+ unparseseq(&reply, pty);
+ unparseputc(kypd_apl[keysym-XK_KP_Space], pty);
+ } else
+ unparseputc(kypd_num[keysym-XK_KP_Space], pty);
+ key = TRUE;
+ } else if (nbytes > 0) {
+ if ((nbytes == 1) && eightbit) {
+ if (screen->input_eight_bits)
+ *string |= 0x80; /* turn on eighth bit */
+ else
+ unparseputc (033, pty); /* escape */
+ }
+ while (nbytes-- > 0)
+ unparseputc(*string++, pty);
+ key = TRUE;
+ }
+ if (key)
+ AdjustAfterInput(screen);
+ return;
+}
+
+StringInput (screen, string, nbytes)
+ register TScreen *screen;
+ register char *string;
+ int nbytes;
+{
+ int pty = screen->respond;
+
+ while (nbytes-- > 0)
+ unparseputc(*string++, pty);
+ AdjustAfterInput(screen);
+}
+
+static int funcvalue (keycode)
+ int keycode;
+{
+ switch (keycode) {
+ case XK_F1: return(11);
+ case XK_F2: return(12);
+ case XK_F3: return(13);
+ case XK_F4: return(14);
+ case XK_F5: return(15);
+ case XK_F6: return(17);
+ case XK_F7: return(18);
+ case XK_F8: return(19);
+ case XK_F9: return(20);
+ case XK_F10: return(21);
+ case XK_F11: return(23);
+ case XK_F12: return(24);
+ case XK_F13: return(25);
+ case XK_F14: return(26);
+ case XK_F15: return(28);
+ case XK_Help: return(28);
+ case XK_F16: return(29);
+ case XK_Menu: return(29);
+ case XK_F17: return(31);
+ case XK_F18: return(32);
+ case XK_F19: return(33);
+ case XK_F20: return(34);
+
+ case XK_Find : return(1);
+ case XK_Insert: return(2);
+ case XK_KP_Insert: return(2);
+ case XK_Delete: return(3);
+ case XK_KP_Delete: return(3);
+ case DXK_Remove: return(3);
+ case XK_Select: return(4);
+ case XK_Prior: return(5);
+ case XK_Next: return(6);
+ default: return(-1);
+ }
+}
+
+
+static int sunfuncvalue (keycode)
+ int keycode;
+ {
+ switch (keycode) {
+ case XK_F1: return(224);
+ case XK_F2: return(225);
+ case XK_F3: return(226);
+ case XK_F4: return(227);
+ case XK_F5: return(228);
+ case XK_F6: return(229);
+ case XK_F7: return(230);
+ case XK_F8: return(231);
+ case XK_F9: return(232);
+ case XK_F10: return(233);
+ case XK_F11: return(192);
+ case XK_F12: return(193);
+ case XK_F13: return(194);
+ case XK_F14: return(195);
+ case XK_F15: return(196);
+ case XK_Help: return(196);
+ case XK_F16: return(197);
+ case XK_Menu: return(197);
+ case XK_F17: return(198);
+ case XK_F18: return(199);
+ case XK_F19: return(200);
+ case XK_F20: return(201);
+
+ case XK_R1: return(208);
+ case XK_R2: return(209);
+ case XK_R3: return(210);
+ case XK_R4: return(211);
+ case XK_R5: return(212);
+ case XK_R6: return(213);
+ case XK_R7: return(214);
+ case XK_R8: return(215);
+ case XK_R9: return(216);
+ case XK_R10: return(217);
+ case XK_R11: return(218);
+ case XK_R12: return(219);
+ case XK_R13: return(220);
+ case XK_R14: return(221);
+ case XK_R15: return(222);
+
+ case XK_Find : return(1);
+ case XK_Insert: return(2);
+ case XK_KP_Insert: return(2);
+ case XK_Delete: return(3);
+ case XK_KP_Delete: return(3);
+ case DXK_Remove: return(3);
+ case XK_Select: return(4);
+ case XK_Prior: return(5);
+ case XK_Next: return(6);
+ default: return(-1);
+ }
+}
diff --git a/vendor/x11iraf/xgterm/login.cl b/vendor/x11iraf/xgterm/login.cl
new file mode 100644
index 00000000..44856c5a
--- /dev/null
+++ b/vendor/x11iraf/xgterm/login.cl
@@ -0,0 +1,108 @@
+# LOGIN.CL -- User login file for the IRAF command language.
+
+# Identify login.cl version (checked in images.cl).
+if (defpar ("logver"))
+ logver = "IRAF V2.14.1 September 2008"
+
+set home = "/home/fitz/x11iraf-2.0/xgterm/"
+set imdir = "/iraf/imdirs/fitz/"
+set uparm = "home$uparm/"
+set userid = "fitz"
+
+# Set the terminal type. We assume the user has defined this correctly
+# when issuing the MKIRAF and no longer key off the unix TERM to set a
+# default.
+if (access (".hushiraf") == no)
+ print "setting terminal type to xgterm..."
+stty xgterm
+
+
+# Uncomment and edit to change the defaults.
+#set editor = vi
+#set printer = lp
+#set pspage = "letter"
+#set stdimage = imt800
+#set stdimcur = stdimage
+#set stdplot = lw
+#set clobber = no
+#set filewait = yes
+#set cmbuflen = 512000
+#set min_lenuserarea = 64000
+#set imtype = "imh"
+set imextn = "oif:imh fxf:fits,fit fxb:fxb plf:pl qpf:qp stf:hhh,??h"
+
+
+# XIMTOOL/DISPLAY stuff. Set node to the name of your workstation to
+# enable remote image display. The trailing "!" is required.
+#set node = "my_workstation!"
+
+# CL parameters you mighth want to change.
+#ehinit = "nostandout eol noverify"
+#epinit = "standout showall"
+showtype = yes
+
+
+# Load the default CL package. Doing so here allows us to override package
+# paths and load personalized packages from our loginuser.cl.
+clpackage
+
+
+# Default USER package; extend or modify as you wish. Note that this can
+# be used to call FORTRAN programs from IRAF.
+
+package user
+
+task $adb $bc $cal $cat $comm $cp $csh $date $dbx $df $diff = "$foreign"
+task $du $find $finger $ftp $grep $lpq $lprm $ls $mail $make = "$foreign"
+task $man $mon $mv $nm $od $ps $rcp $rlogin $rsh $ruptime = "$foreign"
+task $rwho $sh $spell $sps $strings $su $telnet $tip $top = "$foreign"
+task $vi $emacs $w $wc $less $rusers $sync $pwd $gdb = "$foreign"
+
+task $xc $mkpkg $generic $rtar $wtar $buglog = "$foreign"
+#task $fc = "$xc -h $* -limfort -lsys -lvops -los"
+task $fc = ("$" // envget("iraf") // "unix/hlib/fc.csh" //
+ " -h $* -limfort -lsys -lvops -los")
+task $nbugs = ("$(setenv EDITOR 'buglog -e';" //
+ "less -Cqm +G " // envget ("iraf") // "local/bugs.*)")
+task $cls = "$clear;ls"
+task $clw = "$clear;w"
+task $pg = ("$(less -Cqm $*)")
+
+if (access ("home$loginuser.cl"))
+ cl < "home$loginuser.cl"
+;
+
+keep
+
+
+prcache directory
+cache directory page type help
+
+# Print the message of the day.
+if (access (".hushiraf"))
+ menus = no
+else {
+ clear; type hlib$motd
+}
+
+# Delete any old MTIO lock (magtape position) files.
+if (deftask ("mtclean"))
+ mtclean
+else
+ delete uparm$mt?.lok,uparm$*.wcs verify-
+
+# List any packages you want loaded at login time, ONE PER LINE.
+images # general image operators
+plot # graphics tasks
+dataio # data conversions, import export
+lists # list processing
+
+# The if(deftask...) is needed for V2.9 compatibility.
+if (deftask ("proto"))
+ proto # prototype or ad hoc tasks
+
+tv # image display
+utilities # miscellaneous utilities
+noao # optical astronomy packages
+
+keep
diff --git a/vendor/x11iraf/xgterm/main.c b/vendor/x11iraf/xgterm/main.c
new file mode 100644
index 00000000..01937cc7
--- /dev/null
+++ b/vendor/x11iraf/xgterm/main.c
@@ -0,0 +1,5300 @@
+#ifndef lint
+static char *rid="$XConsortium: main.c,v 1.222 94/04/17 20:23:28 gildea 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 (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.
+
+******************************************************************/
+
+
+/* main.c */
+
+#include "ptyx.h"
+#include "data.h"
+#include "error.h"
+#include "menu.h"
+#include <ObmW/Gterm.h>
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#ifdef I18N
+#include <X11/Xlocale.h>
+#endif
+
+#define TERMCAP_SIZE 1500
+
+
+/* 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
+ */
+#define B38400 /* everyone should define this */
+#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
+
+
+#include <X11/Xos.h>
+#include <X11/cursorfont.h>
+#include <X11/Xaw/SimpleMenu.h>
+#include <pwd.h>
+#include <ctype.h>
+
+#ifdef USE_TTY_GROUP
+#include <grp.h>
+#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
+
+#ifdef __DARWIN__
+#define NEW_GET_PTY
+#define NEW_SPAWN
+#define USE_HANDSHAKE
+#define USE_USG_PTYS
+#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value
+#define USE_STRUCT_WINSIZE 1
+#define TTYSIZE_STRUCT 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
+
+/*
+#ifdef linux
+*/
+#if defined(linux)
+#define USE_ANY_SYSV_TERMIO
+#define USE_SYSV_TERMIO
+#define USE_SYSV_PGRP
+#define USE_SYSV_UTMP
+#define USE_SYSV_SIGNALS
+
+#define FEDORA
+#define NEW_GET_PTY
+#define NEW_SPAWN
+#define USE_USG_PTYS
+/*
+#define USE_STRUCT_WINSIZE
+*/
+#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value
+
+#define USE_STRUCT_WINSIZE 1
+#define TTYSIZE_STRUCT 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
+
+/*
+#ifndef SYSV
+#define SYSV
+#endif
+*/
+#endif /* linux */
+
+
+#ifdef att
+#define ATT
+#endif
+
+#ifdef linux
+#define USE_SYSV_UTMP
+#define USE_SYSV_PGRP
+#define USE_TERMIOS
+#define USE_HANDSHAKE
+#define HAS_UTMP_UT_HOST
+/*
+#define HAS_BSD_GROUPS
+*/
+#undef TIOCCONS
+#define CONSLOG "/proc/kmsg"
+#endif
+
+#ifdef SVR4
+#ifndef SYSV
+#define SYSV /* SVR4 is (approx) superset of SVR3 */
+#endif
+#define ATT
+#define USE_SYSV_UTMP
+#define USE_TERMIOS
+#define HAS_UTMP_UT_HOST
+#endif
+
+#if defined(sgi) && OSMAJORVERSION >= 5
+#ifndef SVR4
+#define SVR4 /* close enough for xterm */
+#endif
+#define USE_SYSV_UTMP
+#define USE_TERMIOS
+#define HAS_UTMP_UT_HOST
+#endif
+
+#ifdef SYSV386
+#define USE_SYSV_UTMP
+#define ATT
+#define USE_HANDSHAKE
+static Bool IsPts = False;
+#endif
+
+#ifdef ATT
+#define USE_USG_PTYS
+#else
+#define USE_HANDSHAKE
+#endif
+
+#if defined(SYSV) && !defined(SVR4) && !defined(AUX) && !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
+
+/* Some local additions to get things to build. (DCT) */
+#ifdef AUX
+#include <utmp.h>
+struct utmp *getutid();
+extern char *ttyname();
+void *memmove(a,b,n) void *a; const void *b; size_t n; { bcopy(b,a,n); }
+#endif
+#if defined(sun) && OSMAJORVERSION < 5
+#undef memmove
+void *memmove(a,b,n) void *a, *b; int n; { bcopy(b,a,n); }
+#endif
+
+#if defined(sony) && defined(bsd43) && !defined(KANJI)
+#define KANJI
+#endif
+
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+
+
+#ifdef USE_TERMIOS
+#include <termios.h>
+/* this hacked termios support only works on SYSV */
+#define USE_SYSV_TERMIO
+#define termio termios
+#undef TCGETA
+#define TCGETA TCGETS
+#undef TCSETA
+#define TCSETA TCSETS
+#else /* USE_TERMIOS */
+#ifdef SYSV
+#include <sys/termio.h>
+#ifdef SCO /* broken TIOCSWINSZ ioctl so disable it */
+#undef TIOCSWINSZ
+#endif
+#endif /* SYSV */
+#endif /* USE_TERMIOS else */
+
+#if defined(SVR4) || defined(__linux__)
+#undef TIOCSLTC /* defined, but not useable */
+#endif
+#define USE_TERMCAP_ENVVARS /* every one uses this except SYSV maybe */
+
+#if defined(sgi) && OSMAJORVERSION >= 5
+#undef TIOCLSET /* defined, but not useable */
+#endif
+
+#ifdef SYSV /* { */
+#ifdef USE_USG_PTYS /* AT&T SYSV has no ptyio.h */
+#include <sys/stream.h> /* get typedef used in ptem.h */
+#include <sys/stropts.h> /* for I_PUSH */
+#ifndef SVR4
+#include <sys/ptem.h> /* get struct winsize */
+#endif
+#include <poll.h> /* for POLLIN */
+#endif /* USE_USG_PTYS */
+#ifdef FEDORA
+#define USE_USG_PTYS
+#endif
+#define USE_SYSV_TERMIO
+#define USE_SYSV_SIGNALS
+#define USE_SYSV_PGRP
+
+#if !defined(TIOCSWINSZ)
+#define USE_SYSV_ENVVARS /* COLUMNS/LINES vs. TERMCAP */
+#endif
+
+#ifndef SCO
+#undef USE_TERMCAP_ENVVARS /* SCO wants both TERMCAP and TERMINFO env */
+#endif
+/*
+ * now get system-specific includes
+ */
+#ifdef CRAY
+#define USE_SYSV_UTMP
+#define HAS_UTMP_UT_HOST
+#define HAS_BSD_GROUPS
+#endif
+#ifdef _IBMR2
+#define HAS_UTMP_UT_HOST
+#define HAS_BSD_GROUPS
+#define USE_SYSV_UTMP
+#endif
+#ifdef macII
+#define USE_SYSV_UTMP
+#define HAS_UTMP_UT_HOST
+#define HAS_BSD_GROUPS
+#include <sys/ttychars.h>
+#undef USE_SYSV_ENVVARS
+#undef FIOCLEX
+#undef FIONCLEX
+#define setpgrp2 setpgrp
+#include <sgtty.h>
+#include <sys/resource.h>
+#endif
+#if defined(hpux) || defined (__hpux)
+#define HAS_BSD_GROUPS
+#define USE_SYSV_UTMP
+#define HAS_UTMP_UT_HOST
+#include <sys/ptyio.h>
+#endif /* __hpux */
+#ifdef sgi
+#include <sys/sysmacros.h>
+#endif /* sgi */
+#ifdef sun
+#include <sys/strredir.h>
+#endif
+#ifdef AIXV3
+#define USE_SYSV_UTMP
+#define HAS_UTMP_UT_HOST
+#endif
+#else /* } !SYSV { */ /* BSD systems */
+#ifndef linux
+#include <sgtty.h>
+#include <sys/resource.h>
+#define HAS_UTMP_UT_HOST
+#define HAS_BSD_GROUPS
+#ifdef __osf__
+#define USE_SYSV_UTMP
+#define setpgrp setpgid
+#endif
+#endif /* !linux */
+#endif /* } !SYSV */
+
+#ifdef _POSIX_SOURCE
+#define USE_POSIXSYSV_WAIT
+#endif
+#ifdef SVR4
+#define USE_POSIX_WAIT
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <setjmp.h>
+
+#ifdef X_NOT_STDC_ENV
+extern int errno;
+#define Time_t long
+extern Time_t time ();
+#else
+#include <time.h>
+#define Time_t time_t
+#endif
+
+#if defined(hpux) || defined(__hpux)
+#include <sys/utsname.h>
+#endif /* __hpux */
+
+#if defined(apollo) && OSMAJORVERSION == 10 && OSMINORVERSION < 4
+#define ttyslot() 1
+#endif /* apollo */
+
+#ifdef SVR4
+#include <utmpx.h>
+#define setutent setutxent
+#define getutent getutxent
+#define getutid getutxid
+#define endutent endutxent
+#define pututline pututxline
+#else
+#include <utmp.h>
+#if defined(_CRAY) && OSMAJORVERSION < 8
+extern struct utmp *getutid __((struct utmp *_Id));
+#endif
+#endif
+
+#ifdef LASTLOG
+#include <lastlog.h>
+#endif
+#include <sys/param.h> /* for NOFILE */
+
+#ifdef PUCC_PTYD
+#include <local/openpty.h>
+int Ptyfd;
+#endif /* PUCC_PTYD */
+
+#ifdef sequent
+#define USE_GET_PSEUDOTTY
+#endif
+
+#ifndef UTMP_FILENAME
+#ifdef UTMP_FILE
+#define UTMP_FILENAME UTMP_FILE
+#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
+
+#ifndef WTMP_FILENAME
+#ifdef WTMP_FILE
+#define WTMP_FILENAME WTMP_FILE
+#else
+#if defined(_PATH_WTMP) /* R6 update */
+#define WTMP_FILENAME _PATH_WTMP
+#else
+#if defined(SYSV)
+#define WTMP_FILENAME "/etc/wtmp"
+#else
+#define WTMP_FILENAME "/usr/adm/wtmp"
+#endif
+#endif
+#endif
+#endif
+
+#include <signal.h>
+
+#if defined(SCO) || defined(ISC)
+#undef SIGTSTP /* defined, but not the BSD way */
+#endif
+
+#ifdef SIGTSTP
+#include <sys/wait.h>
+#if defined(hpux) || defined(__hpux)
+#include <sys/bsdtty.h>
+#endif
+#endif
+
+#ifdef SIGNALRETURNSINT
+#define SIGNAL_T int
+#define SIGNAL_RETURN return 0
+#else
+#define SIGNAL_T void
+#define SIGNAL_RETURN return
+#endif
+
+SIGNAL_T Exit();
+
+#ifndef X_NOT_POSIX
+#include <unistd.h>
+#else
+extern long lseek();
+#if defined(USG) || defined(SCO324)
+extern unsigned sleep();
+#else
+extern void sleep();
+#endif
+#endif
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+extern char *malloc();
+extern char *calloc();
+extern char *realloc();
+extern char *getenv();
+extern void exit();
+#endif
+#ifdef X_NOT_POSIX
+extern char *ttyname();
+#endif
+
+#ifdef SYSV
+extern char *ptsname();
+#endif
+
+extern char *strindex ();
+extern void HandlePopupMenu();
+extern void gtermio_connect();
+
+int switchfb[] = {0, 2, 1, 3};
+
+static SIGNAL_T reapchild ();
+
+static Bool added_utmp_entry = False;
+
+static char **command_to_exec;
+
+#ifdef USE_SYSV_TERMIO
+/* 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;
+#ifdef TIOCSLTC
+static struct ltchars d_ltc;
+#endif /* TIOCSLTC */
+#ifdef TIOCLSET
+static unsigned int d_lmode;
+#endif /* TIOCLSET */
+#else /* not USE_SYSV_TERMIO */
+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 /* USE_SYSV_TERMIO */
+
+static int parse_tty_modes ();
+/*
+ * 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.
+ */
+#define TTYMODE(name) { name, sizeof(name)-1, 0, 0 }
+
+static int override_tty_modes = 0;
+struct _xttymodes {
+ char *name;
+ int len;
+ int set;
+ char value;
+} ttymodelist[] = {
+{ "intr", 4, 0, '\0' }, /* tchars.t_intrc ; VINTR */
+#define XTTYMODE_intr 0
+{ "quit", 4, 0, '\0' }, /* tchars.t_quitc ; VQUIT */
+#define XTTYMODE_quit 1
+{ "erase", 5, 0, '\0' }, /* sgttyb.sg_erase ; VERASE */
+#define XTTYMODE_erase 2
+{ "kill", 4, 0, '\0' }, /* sgttyb.sg_kill ; VKILL */
+#define XTTYMODE_kill 3
+{ "eof", 3, 0, '\0' }, /* tchars.t_eofc ; VEOF */
+#define XTTYMODE_eof 4
+{ "eol", 3, 0, '\0' }, /* VEOL */
+#define XTTYMODE_eol 5
+{ "swtch", 5, 0, '\0' }, /* VSWTCH */
+#define XTTYMODE_swtch 6
+{ "start", 5, 0, '\0' }, /* tchars.t_startc */
+#define XTTYMODE_start 7
+{ "stop", 4, 0, '\0' }, /* tchars.t_stopc */
+#define XTTYMODE_stop 8
+{ "brk", 3, 0, '\0' }, /* tchars.t_brkc */
+#define XTTYMODE_brk 9
+{ "susp", 4, 0, '\0' }, /* ltchars.t_suspc ; VSUSP */
+#define XTTYMODE_susp 10
+{ "dsusp", 5, 0, '\0' }, /* ltchars.t_dsuspc ; VDSUSP */
+#define XTTYMODE_dsusp 11
+{ "rprnt", 5, 0, '\0' }, /* ltchars.t_rprntc ; VREPRINT */
+#define XTTYMODE_rprnt 12
+{ "flush", 5, 0, '\0' }, /* ltchars.t_flushc ; VDISCARD */
+#define XTTYMODE_flush 13
+{ "weras", 5, 0, '\0' }, /* ltchars.t_werasc ; VWERASE */
+#define XTTYMODE_weras 14
+{ "lnext", 5, 0, '\0' }, /* 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 */
+};
+
+#ifdef USE_SYSV_UTMP
+#if defined(X_NOT_STDC_ENV) || defined(AIXV3)
+extern struct utmp *getutent();
+extern struct utmp *getutid();
+extern struct utmp *getutline();
+extern void setutent();
+extern void endutent();
+#ifdef AIXV3
+extern struct utmp* pututline();
+extern int utmpname();
+#else
+extern void pututline();
+extern void utmpname();
+#endif
+#endif /* !SVR4 */
+
+/*#ifndef SYSV386 /* could remove paragraph unconditionally? */
+#ifdef X_NOT_STDC_ENV /* could remove paragraph unconditionally? */
+extern struct passwd *getpwent();
+extern struct passwd *getpwuid();
+extern struct passwd *getpwnam();
+extern void setpwent();
+extern void endpwent();
+#endif
+
+extern struct passwd *fgetpwent();
+#else /* not USE_SYSV_UTMP */
+static char etc_utmp[] = UTMP_FILENAME;
+#ifdef LASTLOG
+static char etc_lastlog[] = LASTLOG_FILENAME;
+#endif
+#endif /* USE_SYSV_UTMP */
+
+#ifdef WTMP
+static char etc_wtmp[] = WTMP_FILENAME;
+#endif
+
+/*
+ * Some people with 4.3bsd /bin/login seem to like to use login -p -f user
+ * to implement xgterm -ls. They can turn on USE_LOGIN_DASH_P and turn off
+ * WTMP and LASTLOG.
+ */
+#ifdef USE_LOGIN_DASH_P
+#ifndef LOGIN_FILENAME
+#define LOGIN_FILENAME "/bin/login"
+#endif
+static char bin_login[] = LOGIN_FILENAME;
+#endif
+
+static int inhibit;
+static char passedPty[2]; /* name if pty if slave */
+
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+static int Console;
+#include <X11/Xmu/SysUtil.h> /* XmuGetHostname */
+#define MIT_CONSOLE_LEN 12
+#define MIT_CONSOLE "MIT_CONSOLE_"
+static char mit_console_name[255 + MIT_CONSOLE_LEN + 1] = MIT_CONSOLE;
+static Atom mit_console;
+#endif /* TIOCCONS */
+
+#ifndef USE_SYSV_UTMP
+static int tslot;
+#endif /* USE_SYSV_UTMP */
+static jmp_buf env;
+
+char *ProgramName;
+Boolean sunFunctionKeys;
+
+static struct _resource {
+ char *xgterm_name;
+ char *icon_geometry;
+ char *title;
+ char *icon_name;
+ char *term_name;
+ char *tty_modes;
+ Boolean utmpInhibit;
+ Boolean sunFunctionKeys; /* %%% should be widget resource? */
+ Boolean wait_for_map;
+ Boolean useInsertMode;
+} resource;
+
+/* used by VT (charproc.c) */
+
+#define offset(field) XtOffsetOf(struct _resource, field)
+
+static XtResource application_resources[] = {
+ {"name", "Name", XtRString, sizeof(char *),
+ offset(xgterm_name), XtRString, "xgterm"},
+ {"iconGeometry", "IconGeometry", XtRString, sizeof(char *),
+ offset(icon_geometry), XtRString, (caddr_t) NULL},
+ {XtNtitle, XtCTitle, XtRString, sizeof(char *),
+ offset(title), XtRString, (caddr_t) NULL},
+ {XtNiconName, XtCIconName, XtRString, sizeof(char *),
+ offset(icon_name), XtRString, (caddr_t) NULL},
+ {"termName", "TermName", XtRString, sizeof(char *),
+ offset(term_name), XtRString, (caddr_t) NULL},
+ {"ttyModes", "TtyModes", XtRString, sizeof(char *),
+ offset(tty_modes), XtRString, (caddr_t) NULL},
+ {"utmpInhibit", "UtmpInhibit", XtRBoolean, sizeof (Boolean),
+ offset(utmpInhibit), XtRString, "false"},
+ {"sunFunctionKeys", "SunFunctionKeys", XtRBoolean, sizeof (Boolean),
+ offset(sunFunctionKeys), XtRString, "false"},
+ {"waitForMap", "WaitForMap", XtRBoolean, sizeof (Boolean),
+ offset(wait_for_map), XtRString, "false"},
+ {"useInsertMode", "UseInsertMode", XtRBoolean, sizeof (Boolean),
+ offset(useInsertMode), XtRString, "false"},
+};
+#undef offset
+
+static char *fallback_resources[] = {
+ "XGterm*SimpleMenu*menuLabel.vertSpace: 100",
+ "XGterm*SimpleMenu*HorizontalMargins: 16",
+ "XGterm*SimpleMenu*Sme.height: 16",
+ "XGterm*SimpleMenu*Cursor: left_ptr",
+ "XGterm*mainMenu.Label: Main Options (no app-defaults)",
+ "XGterm*vtMenu.Label: VT Options (no app-defaults)",
+ "XGterm*fontMenu.Label: VT Fonts (no app-defaults)",
+ NULL
+};
+
+/* Command line options table. Only resources are entered here...there is a
+ pass over the remaining options after XrmParseCommand is let loose. */
+
+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"},
+{"-b", "*internalBorder", XrmoptionSepArg, (caddr_t) NULL},
+{"-cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "off"},
+{"+cb", "*cutToBeginningOfLine", XrmoptionNoArg, (caddr_t) "on"},
+{"-cc", "*charClass", XrmoptionSepArg, (caddr_t) NULL},
+{"-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) "on"},
+{"+dc", "*dynamicColors", XrmoptionNoArg, (caddr_t) "off"},
+{"-e", NULL, XrmoptionSkipLine, (caddr_t) NULL},
+{"-fb", "*boldFont", XrmoptionSepArg, (caddr_t) NULL},
+{"-im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "on"},
+{"+im", "*useInsertMode", XrmoptionNoArg, (caddr_t) "off"},
+{"-j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "on"},
+{"+j", "*jumpScroll", XrmoptionNoArg, (caddr_t) "off"},
+/* 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},
+{"-ms", "*pointerColor", XrmoptionSepArg, (caddr_t) NULL},
+{"-nb", "*nMarginBell", XrmoptionSepArg, (caddr_t) NULL},
+{"-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"},
+{"-sbr", "*scrollBarRight", XrmoptionNoArg, (caddr_t) "on"},
+{"+sbr", "*scrollBarRight", XrmoptionNoArg, (caddr_t) "off"},
+{"-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},
+{"-t", "*tekStartup", XrmoptionNoArg, (caddr_t) "on"},
+{"+t", "*tekStartup", XrmoptionNoArg, (caddr_t) "off"},
+{"-tm", "*ttyModes", XrmoptionSepArg, (caddr_t) NULL},
+{"-tn", "*termName", XrmoptionSepArg, (caddr_t) NULL},
+{"-ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "on"},
+{"+ut", "*utmpInhibit", XrmoptionNoArg, (caddr_t) "off"},
+{"-vb", "*visualBell", XrmoptionNoArg, (caddr_t) "on"},
+{"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"},
+{"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"},
+{"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"},
+/* bogus old compatibility stuff for which there are
+ standard XtAppInitialize options now */
+{"-G", "*tekGeometry", XrmoptionSepArg, (caddr_t) NULL},
+{"%", "*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 struct _options {
+ char *opt;
+ char *desc;
+} options[] = {
+{ "-help", "print out this message" },
+{ "-display displayname", "X server to contact" },
+{ "-geometry geom", "size (in characters) and position" },
+{ "-G geom", "geometry of toplevel graphics window" },
+{ "-/+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" },
+{ "-iconic", "start iconic" },
+{ "-name string", "client instance, icon, and title strings" },
+{ "-title string", "title string" },
+{ "-xrm resourcestring", "additional resource specifications" },
+{ "-/+132", "turn on/off column switch inhibiting" },
+{ "-/+ah", "turn on/off always highlight" },
+{ "-b number", "internal border in pixels" },
+{ "-/+cb", "turn on/off cut-to-beginning-of-line inhibit" },
+{ "-cc classrange", "specify additional character classes" },
+{ "-/+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" },
+{ "-/+sbr", "turn off/on rightside scrollbar option" },
+{ "-fb fontname", "bold text font" },
+{ "-/+im", "use insert mode for TERMCAP" },
+{ "-/+j", "turn on/off jump scroll" },
+#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" },
+{ "-ms color", "pointer color" },
+{ "-nb number", "margin bell in characters from right end" },
+{ "-/+aw", "turn on/off auto wraparound" },
+{ "-/+rw", "turn on/off reverse wraparound" },
+{ "-/+s", "turn on/off multiscroll" },
+{ "-/+sb", "turn on/off scrollbar" },
+{ "-/+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" },
+{ "-tm string", "terminal mode keywords and characters" },
+{ "-tn name", "TERM environment variable name" },
+#ifdef UTMP
+{ "-/+ut", "turn on/off utmp inhibit" },
+#else
+{ "-/+ut", "turn on/off utmp inhibit (not supported)" },
+#endif
+{ "-/+vb", "turn on/off visual bell" },
+{ "-/+wf", "turn on/off wait for map before command exec" },
+{ "-e command args ...", "command to execute" },
+{ "%geom", "Tek window geometry" },
+{ "#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
+{ "-Sxxd", "slave mode on \"ttyxx\", file descriptor \"d\"" },
+{ NULL, NULL }};
+
+static char *message[] = {
+"Fonts must be fixed width and, if both normal and bold are specified, must",
+"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 be 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};
+
+
+/* The X11IRAF version. */
+char *xgterm_version[] = {
+# include "../version.h"
+ NULL
+};
+
+
+/*
+ * If we're linked to terminfo, tgetent() will return an empty buffer. We
+ * cannot use that to adjust the $TERMCAP variable.
+ */
+static Boolean
+get_termcap(char *name, char *buffer, char *resized)
+{
+ register TScreen *screen = &term->screen;
+
+ *buffer = 0; /* initialize, in case we're using terminfo's tgetent */
+
+ if (name != 0) {
+ if (tgetent(buffer, name) == 1) {
+ if (*buffer) {
+ if (!screen->TekEmu) {
+ resize(screen, buffer, resized);
+ }
+ }
+ return True;
+ } else {
+ *buffer = 0; /* just in case */
+ }
+ }
+ return False;
+}
+
+
+static void Syntax (badOption)
+ char *badOption;
+{
+ struct _options *opt;
+ 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 = options; 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 Help ()
+{
+ struct _options *opt;
+ char **cpp;
+
+ fprintf (stderr, "usage:\n %s [-options ...] [-e command args]\n\n",
+ ProgramName);
+ fprintf (stderr, "where options include:\n");
+ for (opt = options; opt->opt; opt++) {
+ fprintf (stderr, " %-28s %s\n", opt->opt, opt->desc);
+ }
+
+ putc ('\n', stderr);
+ for (cpp = message; *cpp; cpp++) {
+ fputs (*cpp, stderr);
+ putc ('\n', stderr);
+ }
+ putc ('\n', stderr);
+
+ exit (0);
+}
+
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+/* ARGSUSED */
+static Boolean
+ConvertConsoleSelection(w, selection, target, type, value, length, format)
+ Widget w;
+ Atom *selection, *target, *type;
+ XtPointer *value;
+ unsigned long *length;
+ int *format;
+{
+ /* we don't save console output, so can't offer it */
+ return False;
+}
+#endif /* TIOCCONS */
+
+
+extern WidgetClass xgtermWidgetClass;
+
+Arg ourTopLevelShellArgs[] = {
+ { XtNallowShellResize, (XtArgVal) TRUE },
+ { XtNinput, (XtArgVal) TRUE },
+};
+int number_ourTopLevelShellArgs = 2;
+
+XtAppContext app_con;
+Widget toplevel;
+Bool waiting_for_initial_map;
+
+extern void do_hangup();
+extern void xt_error();
+
+/*
+ * DeleteWindow(): Action proc to implement ICCCM delete_window.
+ */
+/* ARGSUSED */
+void
+DeleteWindow(w, event, params, num_params)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *num_params;
+{
+ if (w == toplevel)
+ if (term->screen.Tshow)
+ hide_vt_window();
+ else
+ do_hangup(w);
+ else
+ if (term->screen.Vshow)
+ hide_tek_window();
+ else
+ do_hangup(w);
+}
+
+/* ARGSUSED */
+void
+KeyboardMapping(w, event, params, num_params)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *num_params;
+{
+ switch (event->type) {
+ case MappingNotify:
+ XRefreshKeyboardMapping(&event->xmapping);
+ break;
+ }
+}
+
+XtActionsRec actionProcs[] = {
+ "DeleteWindow", DeleteWindow,
+ "KeyboardMapping", KeyboardMapping,
+};
+
+Atom wm_delete_window;
+
+
+main (argc, argv)
+int argc;
+char **argv;
+{
+ register TScreen *screen;
+ register int pty;
+ int Xsocket, mode;
+ char *base_name();
+ int xerror(), xioerror();
+
+#ifdef I18N
+ setlocale(LC_ALL, NULL);
+#endif
+
+ ProgramName = argv[0];
+
+ ttydev = (char *) malloc (strlen (TTYDEV) + 1);
+ ptydev = (char *) malloc (strlen (PTYDEV) + 1);
+ if (!ttydev || !ptydev) {
+ fprintf (stderr,
+ "%s: unable to allocate memory for ttydev or ptydev\n",
+ ProgramName);
+ exit (1);
+ }
+ strcpy (ttydev, TTYDEV);
+ strcpy (ptydev, PTYDEV);
+
+#ifdef USE_SYSV_TERMIO
+ /* 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).
+ */
+#if defined(macII) || defined(ATT) || defined(CRAY)
+ d_tio.c_iflag = ICRNL|IXON;
+ d_tio.c_oflag = OPOST|ONLCR|TAB3;
+ d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;
+ d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
+
+#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;
+ d_tio.c_cc[VSWTCH] = CNUL;
+
+#ifdef USE_TERMIOS
+ d_tio.c_cc[VSUSP] = CSUSP;
+#ifdef VDSUSP /* R6 update */
+ d_tio.c_cc[VDSUSP] = CDSUSP;
+#endif
+ d_tio.c_cc[VREPRINT] = CNUL;
+ d_tio.c_cc[VDISCARD] = CNUL;
+ d_tio.c_cc[VWERASE] = CNUL;
+ d_tio.c_cc[VLNEXT] = CNUL;
+#endif
+#ifdef TIOCSLTC
+ d_ltc.t_suspc = CSUSP; /* t_suspc */
+ d_ltc.t_dsuspc = CDSUSP; /* t_dsuspc */
+ d_ltc.t_rprntc = 0; /* reserved...*/
+ d_ltc.t_flushc = 0;
+ d_ltc.t_werasc = 0;
+ d_ltc.t_lnextc = 0;
+#endif /* TIOCSLTC */
+#ifdef TIOCLSET
+ d_lmode = 0;
+#endif /* TIOCLSET */
+#else /* else !macII */
+ d_tio.c_iflag = ICRNL|IXON;
+ d_tio.c_oflag = OPOST|ONLCR|TAB3;
+#ifdef BAUD_0
+ d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL;
+#else /* !BAUD_0 */
+ d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;
+#endif /* !BAUD_0 */
+ d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
+#ifndef sgi
+ d_tio.c_line = 0;
+#endif
+#ifdef linux
+ d_tio.c_cc[VINTR] = 'C' & 0x3f;
+ d_tio.c_cc[VQUIT] = '\\' & 0x3f;
+ d_tio.c_cc[VERASE] = 0x7f;
+ d_tio.c_cc[VKILL] = 'U' & 0x3f;
+ d_tio.c_cc[VEOF] = 'D' & 0x3f;
+ d_tio.c_cc[VEOL] = '@' & 0x3f;
+#else
+ d_tio.c_cc[VINTR] = 0x7f; /* DEL */
+ d_tio.c_cc[VQUIT] = '\\' & 0x3f; /* '^\' */
+ d_tio.c_cc[VERASE] = '#'; /* '#' */
+ d_tio.c_cc[VKILL] = '@'; /* '@' */
+ d_tio.c_cc[VEOF] = 'D' & 0x3f; /* '^D' */
+ d_tio.c_cc[VEOL] = '@' & 0x3f; /* '^@' */
+#endif
+#ifdef VSWTCH
+ d_tio.c_cc[VSWTCH] = '@' & 0x3f; /* '^@' */
+#endif /* VSWTCH */
+ /* now, try to inherit tty settings */
+ {
+ int i;
+
+ for (i = 0; i <= 2; i++) {
+ struct termio deftio;
+ if (ioctl (i, TCGETA, &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 /* VSWTCH */
+ break;
+ }
+ }
+ }
+#ifdef TIOCSLTC
+ d_ltc.t_suspc = '\000'; /* t_suspc */
+ d_ltc.t_dsuspc = '\000'; /* t_dsuspc */
+ d_ltc.t_rprntc = '\377'; /* reserved...*/
+ d_ltc.t_flushc = '\377';
+ d_ltc.t_werasc = '\377';
+ d_ltc.t_lnextc = '\377';
+#endif /* TIOCSLTC */
+#ifdef USE_TERMIOS
+#ifdef linux
+ d_tio.c_cc[VSUSP] = 'Z' & 0x3f;
+#else
+ d_tio.c_cc[VSUSP] = '\000';
+#endif
+#ifdef VDSUSP
+ d_tio.c_cc[VDSUSP] = '\000';
+#endif
+ d_tio.c_cc[VREPRINT] = '\377';
+ d_tio.c_cc[VDISCARD] = '\377';
+ d_tio.c_cc[VWERASE] = '\377';
+ d_tio.c_cc[VLNEXT] = '\377';
+#endif
+#ifdef TIOCLSET
+ d_lmode = 0;
+#endif /* TIOCLSET */
+#endif /* macII */
+#endif /* USE_SYSV_TERMIO */
+
+ /* Init the Toolkit. */
+ {
+#ifdef HAS_POSIX_SAVED_IDS
+ uid_t euid = geteuid();
+ gid_t egid = getegid();
+ uid_t ruid = getuid();
+ gid_t rgid = getgid();
+
+ if (setegid(ruid) == -1)
+ (void) fprintf(stderr, "setegid(%d): %s\n",
+ rgid, strerror(errno));
+
+ if (seteuid(ruid) == -1)
+ (void) fprintf(stderr, "seteuid(%d): %s\n",
+ ruid, strerror(errno));
+#endif
+
+ XtSetErrorHandler(xt_error);
+ toplevel = XtAppInitialize (&app_con, "XGterm",
+ optionDescList, XtNumber(optionDescList),
+ &argc, argv, fallback_resources, NULL, 0);
+
+ XtGetApplicationResources(toplevel, (XtPointer) &resource,
+ application_resources,
+ XtNumber(application_resources), NULL, 0);
+
+#ifdef HAS_POSIX_SAVED_IDS
+ if (seteuid(euid) == -1)
+ (void) fprintf(stderr, "seteuid(%d): %s\n",
+ euid, strerror(errno));
+
+ if (setegid(egid) == -1)
+ (void) fprintf(stderr, "setegid(%d): %s\n",
+ egid, strerror(errno));
+#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;
+ }
+ }
+
+ xgterm_name = resource.xgterm_name;
+ sunFunctionKeys = resource.sunFunctionKeys;
+ if (strcmp(xgterm_name, "-") == 0) xgterm_name = "xgterm";
+ 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);
+
+
+ /* Parse the rest of the command line */
+ for (argc--, argv++ ; argc > 0 ; argc--, argv++) {
+ if(**argv != '-') Syntax (*argv);
+
+ switch(argv[0][1]) {
+ case 'h':
+ Help ();
+ /* NOTREACHED */
+ case 'C':
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+ {
+ 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;
+ }
+#endif /* TIOCCONS */
+ 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 'e':
+ if (argc <= 1) Syntax (*argv);
+ command_to_exec = ++argv;
+ argc = 0;
+ break;
+ case 'v':
+ if (strcmp (*argv, "-version") == 0) {
+ printf ("Version: %s\n", xgterm_version[0]);
+ exit (1);
+ }
+ break;
+ default:
+ Syntax (*argv);
+ }
+ break;
+ }
+
+ XawSimpleMenuAddGlobalActions (app_con);
+ XtRegisterGrabAction (HandlePopupMenu, True,
+ (ButtonPressMask|ButtonReleaseMask),
+ GrabModeAsync, GrabModeAsync);
+
+ /* Create the vt100 terminal emulator widget. */
+ term = (XgtermWidget) XtCreateManagedWidget ("vt100",
+ xgtermWidgetClass, toplevel, NULL, 0);
+ screen = &term->screen;
+
+ if (screen->savelines < 0) screen->savelines = 0;
+
+ term->flags = 0;
+ if (!screen->jumpscroll) {
+ term->flags |= SMOOTHSCROLL;
+ update_jumpscroll();
+ }
+ if (term->misc.reverseWrap) {
+ term->flags |= REVERSEWRAP;
+ update_reversewrap();
+ }
+ if (term->misc.autoWrap) {
+ term->flags |= WRAPAROUND;
+ update_autowrap();
+ }
+ if (term->misc.re_verse) {
+ term->flags |= REVERSE_VIDEO;
+ update_reversevideo();
+ }
+
+ inhibit = 0;
+#ifdef ALLOWLOGGING
+ if (term->misc.logInhibit) inhibit |= I_LOG;
+#endif
+ if (term->misc.signalInhibit) inhibit |= I_SIGNAL;
+ if (term->misc.tekInhibit) inhibit |= I_TEK;
+
+ term->initflags = term->flags;
+
+ if (term->misc.appcursorDefault) {
+ term->keyboard.flags |= CURSOR_APL;
+ update_appcursor();
+ }
+
+ if (term->misc.appkeypadDefault) {
+ term->keyboard.flags |= KYPD_APL;
+ update_appkeypad();
+ }
+
+/*
+ * Set title and icon name if not specified
+ */
+
+ if (command_to_exec) {
+ Arg args[2];
+
+ if (!resource.title) {
+ if (command_to_exec) {
+ resource.title = base_name (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);
+
+ XtSetValues (toplevel, args, 2);
+ }
+
+#ifdef DEBUG
+ {
+ /* Set up stderr properly. Opening this log file cannot be
+ done securely by a privileged xgterm process (although we try),
+ so the debug feature is disabled by default. */
+ int i = -1;
+ if(debug) {
+ creat_as (getuid(), getgid(), "xgterm.debug.log", 0666);
+ i = open ("xgterm.debug.log", O_WRONLY | O_TRUNC, 0666);
+ }
+ if(i >= 0) {
+#if defined(USE_SYSV_TERMIO) && !defined(SVR4) && !defined(linux)
+ /* SYSV has another pointer which should be part of the
+ ** FILE structure but is actually a seperate array.
+ */
+ unsigned char *old_bufend;
+
+ old_bufend = (unsigned char *) _bufend(stderr);
+#if defined(hpux) || defined(__hpux)
+ stderr->__fileH = (i >> 8);
+ stderr->__fileL = i;
+#else
+ stderr->_file = i;
+#endif
+ _bufend(stderr) = old_bufend;
+#else /* USE_SYSV_TERMIO */
+#ifdef linux
+ setfileno(stderr, i);
+#else
+ stderr->_file = i;
+#endif
+#endif /* USE_SYSV_TERMIO */
+
+ /* 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 */
+#ifdef USE_POSIX_SIGNALS
+ (void) posix_signal(SIGCHLD, reapchild);
+#else
+ (void) signal(SIGCHLD, reapchild);
+#endif
+
+
+ /* Realize procs have now been executed */
+
+ Xsocket = ConnectionNumber(screen->display);
+ pty = screen->respond;
+ init_ttyio (pty);
+
+ /* Connect gtermio to the pty. */
+ if (!term->misc.tekInhibit) {
+ gio_setup (app_con, argc, argv, pty);
+ gio_postconnectcallback (gtermio_connect, NULL);
+ }
+
+ /* Start up graphics window? */
+ if (inhibit & I_TEK)
+ screen->TekEmu = FALSE;
+ if (screen->TekEmu)
+ hide_vt_window();
+
+ /* Write window id so master end can read and use */
+ if (am_slave >= 0) {
+ char buf[80];
+
+ buf[0] = '\0';
+ sprintf (buf, "%lx\n", XtWindow (XtParent (term)));
+ write (pty, buf, strlen (buf));
+ }
+
+#ifdef ALLOWLOGGING
+ if (term->misc.log_on) {
+ StartLog(screen);
+ }
+#endif
+ screen->inhibit = inhibit;
+
+#ifdef AIXV3
+ /* 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.
+ */
+
+ {
+ struct termio tio;
+
+ if(ioctl(pty, TCGETA, &tio) == -1)
+ SysError(ERROR_TIOCGETP);
+
+ tio.c_cflag &= ~(CLOCAL);
+
+ if (ioctl (pty, TCSETA, &tio) == -1)
+ SysError(ERROR_TIOCSETP);
+ }
+#endif
+#ifdef USE_SYSV_TERMIO
+ if (0 > (mode = fcntl(pty, F_GETFL, 0)))
+ Error();
+#ifdef O_NDELAY
+ mode |= O_NDELAY;
+#else
+ mode |= O_NONBLOCK;
+#endif /* O_NDELAY */
+ if (fcntl(pty, F_SETFL, mode))
+ Error();
+#else /* USE_SYSV_TERMIO */
+ mode = 1;
+ if (ioctl (pty, FIONBIO, (char *)&mode) == -1) SysError (ERROR_FIONBIO);
+#endif /* USE_SYSV_TERMIO */
+
+ pty_mask = 1 << pty;
+ X_mask = 1 << Xsocket;
+ Select_mask = pty_mask | X_mask;
+ max_plus1 = (pty < Xsocket) ? (1 + Xsocket) : (1 + pty);
+
+#ifdef DEBUG
+ if (debug) printf ("debugging on\n");
+#endif /* DEBUG */
+ XSetErrorHandler(xerror);
+ XSetIOErrorHandler(xioerror);
+ for( ; ; )
+ VTRun();
+}
+
+char *base_name(name)
+char *name;
+{
+ register char *cp;
+
+ cp = strrchr(name, '/');
+ return(cp ? cp + 1 : name);
+}
+
+
+
+
+#ifdef NEW_GET_PTY
+
+
+#ifdef __DARWIN__
+#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)
+{
+ int result = 1;
+
+
+#if defined(USE_OPENPTY)
+ result = openpty(pty, &opened_tty, ttydev, NULL, NULL);
+
+#elif defined(__OpenBSD__)
+ static int m_tty = -1;
+ static int m_pty = -1;
+ struct group *ttygrp;
+
+
+ if (pty == NULL) {
+ result = openpty(&m_pty, &m_tty, ttydev, NULL, NULL);
+
+ seteuid(0);
+ if ((ttygrp = getgrnam(TTY_GROUP_NAME)) != 0) {
+ set_owner(ttydev, getuid(), ttygrp->gr_gid, 0600);
+ } else {
+ set_owner(ttydev, getuid(), getgid(), 0600);
+ }
+ seteuid(getuid());
+ } else if (m_pty != -1) {
+ *pty = m_pty;
+ result = 0;
+ } else {
+ result = -1;
+ }
+#elif defined(PUCC_PTYD)
+
+ result = ((*pty = openrpty(ttydev, ptydev,
+ (resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN),
+ getuid(), from)) < 0);
+
+/*
+#elif defined(__osf__) || (defined(__GLIBC__) && !defined(USE_USG_PTYS)) || defined(__NetBSD__)
+
+ int tty;
+ result = openpty(pty, &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__) || defined(FEDORA)
+#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
+
+ return result;
+}
+#else
+
+
+
+/* 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.
+ */
+
+get_pty (pty)
+ int *pty;
+{
+#if defined(SYSV) && defined(SYSV386)
+ /*
+ 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.
+ */
+ if (pty_search(pty) == 0)
+ return 0;
+#endif /* SYSV && SYSV386 */
+
+/* Need to move this block of code up a bit on IRIX 6.5 systems to avoid
+ * a segvio when running out of ptys.
+ */
+#if defined(sgi) && OSMAJORVERSION >= 6 && OSMINORVERSION >= 5
+ {
+ char *tty_name;
+
+ tty_name = _getpty (pty, O_RDWR, 0622, 0);
+ if (tty_name == 0)
+ return 1;
+ strcpy (ttydev, tty_name);
+ return 0;
+ }
+#endif
+#ifdef ATT
+ if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {
+ return 1;
+ }
+#if defined(SVR4) || defined(SYSV386)
+ strcpy(ttydev, ptsname(*pty));
+#if defined (SYSV) && defined(SYSV386)
+ IsPts = True;
+#endif
+#endif
+ return 0;
+#else /* ATT else */
+#ifdef AIXV3
+ if ((*pty = open ("/dev/ptc", O_RDWR)) < 0) {
+ return 1;
+ }
+ strcpy(ttydev, ttyname(*pty));
+ return 0;
+#endif
+
+/* Original code for systems below IRIX 6.5 */
+#if defined(sgi) && OSMAJORVERSION >= 4 && (OSMAJORVERSION <= 6 && OSMINORVERSION < 5)
+ {
+ char *tty_name;
+
+ tty_name = _getpty (pty, O_RDWR, 0622, 0);
+ if (tty_name == 0)
+ return 1;
+ strcpy (ttydev, tty_name);
+ return 0;
+ }
+#endif
+#ifdef __convex__
+ {
+ char *pty_name, *getpty();
+
+ while ((pty_name = getpty()) != NULL) {
+ if ((*pty = open (pty_name, O_RDWR)) >= 0) {
+ strcpy(ptydev, pty_name);
+ strcpy(ttydev, pty_name);
+ ttydev[5] = 't';
+ return 0;
+ }
+ }
+ return 1;
+ }
+#endif /* __convex__ */
+#ifdef USE_GET_PSEUDOTTY
+ return ((*pty = getpseudotty (&ttydev, &ptydev)) >= 0 ? 0 : 1);
+#else
+#if (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) {
+ return(1);
+ }
+ sprintf (ttydev, "/dev/ttyq%d", minor(fstat_buf.st_rdev));
+#ifndef sgi
+ sprintf (ptydev, "/dev/ptyq%d", minor(fstat_buf.st_rdev));
+ if ((*tty = open (ttydev, O_RDWR)) < 0) {
+ close (*pty);
+ return(1);
+ }
+#endif /* !sgi */
+ /* got one! */
+ return(0);
+#else /* sgi or umips */
+
+ return pty_search(pty);
+
+#endif /* sgi or umips else */
+#endif /* USE_GET_PSEUDOTTY else */
+#endif /* ATT else */
+}
+#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.
+ */
+int pty_search(pty)
+ int *pty;
+{
+ static int devindex, letter = 0;
+
+#ifdef CRAY
+ for (; devindex < 256; devindex++) {
+ sprintf (ttydev, "/dev/ttyp%03d", devindex);
+ sprintf (ptydev, "/dev/pty/%03d", devindex);
+
+ if ((*pty = open (ptydev, O_RDWR)) >= 0) {
+ /* We need to set things up for our next entry
+ * into this function!
+ */
+ (void) devindex++;
+ return 0;
+ }
+ }
+#else /* CRAY */
+ 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];
+ /* for next time around loop or next entry to this function */
+ devindex++;
+ 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;
+ (void) letter++;
+ }
+#endif /* CRAY else */
+ /*
+ * We were unable to allocate a pty master! Return an error
+ * condition and let our caller terminate cleanly.
+ */
+ return 1;
+}
+
+get_terminal ()
+/*
+ * sets up X and initializes the terminal structure except for term.buf.fildes.
+ */
+{
+ register TScreen *screen = &term->screen;
+
+ screen->arrow = make_colored_cursor (XC_left_ptr,
+ screen->mousecolor,
+ screen->mousecolorback);
+}
+
+/*
+ * 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.
+ */
+
+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
+};
+
+/* 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
+ "xgterm", /* technically correct name */
+ "xterm", /* more likely to be found */
+ "vt102",
+ "vt100",
+ "ansi",
+ "dumb",
+ 0
+};
+
+/* ARGSUSED */
+SIGNAL_T hungtty(i)
+ int i;
+{
+ longjmp(env, 1);
+ SIGNAL_RETURN;
+}
+
+#ifdef USE_HANDSHAKE
+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.
+ */
+
+void
+HsSysError(pf, error)
+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);
+}
+
+static int pc_pipe[2]; /* this pipe is used for parent to child transfer */
+static int cp_pipe[2]; /* this pipe is used for child to parent transfer */
+
+void first_map_occurred ()
+{
+ handshake_t handshake;
+ register 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 xgterm working on att ptys
+ */
+void first_map_occurred ()
+{
+ return;
+}
+#define HsSysError(a,b)
+#endif /* USE_HANDSHAKE else !USE_HANDSHAKE */
+
+
+#ifdef NEW_SPAWN
+
+extern char **environ;
+
+char *
+x_basename(char *name)
+{
+ char *cp;
+
+ cp = strrchr(name, '/');
+#ifdef __UNIXOS2__
+ if (cp == 0)
+ cp = strrchr(name, '\\');
+#endif
+ return (cp ? cp + 1 : name);
+}
+
+
+static void
+set_owner(char *device, int uid, int gid, int mode)
+{
+ if (chown(device, uid, gid) < 0) {
+ if (errno != ENOENT
+ && getuid() == 0) {
+ fprintf(stderr, "Cannot chown %s to %d,%d: %s\n",
+ device, uid, gid, strerror(errno));
+ }
+ }
+ chmod(device, mode);
+}
+
+
+/*
+ * 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(register char *var, register char *value)
+{
+ register int envindex = 0;
+ register size_t len = strlen(var);
+
+ while (environ[envindex] != NULL) {
+ if (strncmp(environ[envindex], var, len) == 0) {
+ /* found it */
+ environ[envindex] = (char *) malloc((unsigned) len
+ + strlen(value) + 1);
+ strcpy(environ[envindex], var);
+ strcat(environ[envindex], value);
+ return;
+ }
+ envindex++;
+ }
+
+ environ[envindex] = (char *) malloc((unsigned) len + strlen(value) + 1);
+ (void) strcpy(environ[envindex], var);
+ strcat(environ[envindex], value);
+ environ[++envindex] = NULL;
+}
+
+
+/*
+ * 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);
+ Boolean 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;
+ }
+ }
+ 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);
+ }
+ 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);
+ }
+}
+
+
+
+
+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
+ */
+{
+ register 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 tty = -1;
+#ifdef USE_ANY_SYSV_TERMIO
+ struct termio tio;
+#ifdef TIOCLSET
+ unsigned lmode;
+#endif /* TIOCLSET */
+#ifdef HAS_LTCHARS
+ struct ltchars ltc;
+#endif /* HAS_LTCHARS */
+#elif defined(USE_POSIX_TERMIOS)
+ struct termios tio;
+#else /* !USE_ANY_SYSV_TERMIO && !USE_POSIX_TERMIOS */
+ 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 /* USE_ANY_SYSV_TERMIO */
+
+ 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 */
+ char *x_basename();
+
+ /* 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)) {
+ tty = open("/dev/tty", O_RDWR);
+ alarm(0);
+ tty_got_hung = False;
+ } else {
+ tty_got_hung = True;
+ tty = -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 (tty < 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 */
+#if defined(USE_ANY_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)
+ tio = d_tio;
+#else /* not USE_ANY_SYSV_TERMIO and not USE_POSIX_TERMIOS */
+ sg = d_sg;
+ tc = d_tc;
+ discipline = d_disipline;
+#ifdef sony
+ jmode = d_jmode;
+ jtc = d_jtc;
+#endif /* sony */
+#endif /* USE_ANY_SYSV_TERMIO or USE_POSIX_TERMIOS */
+ } 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(tty, TIOCGLTC, &ltc) == -1)
+ ltc = d_ltc;
+#endif /* HAS_LTCHARS */
+#ifdef TIOCLSET
+ if (ioctl(tty, TIOCLGET, &lmode) == -1)
+ lmode = d_lmode;
+#endif /* TIOCLSET */
+#ifdef USE_ANY_SYSV_TERMIO
+ if ((rc = ioctl(tty, TCGETA, &tio)) == -1)
+ tio = d_tio;
+#elif defined(USE_POSIX_TERMIOS)
+ if ((rc = tcgetattr(tty, &tio)) == -1)
+ tio = d_tio;
+#else /* !USE_ANY_SYSV_TERMIO && !USE_POSIX_TERMIOS */
+ if ((rc = ioctl(tty, TIOCGETP, (char *) &sg)) == -1)
+ sg = d_sg;
+ if (ioctl(tty, TIOCGETC, (char *) &tc) == -1)
+ tc = d_tc;
+ if (ioctl(tty, TIOCGETD, (char *) &discipline) == -1)
+ discipline = d_disipline;
+#ifdef sony
+ if (ioctl(tty, TIOCKGET, (char *) &jmode) == -1)
+ jmode = d_jmode;
+ if (ioctl(tty, TIOCKGETC, (char *) &jtc) == -1)
+ jtc = d_jtc;
+#endif /* sony */
+#endif /* USE_ANY_SYSV_TERMIO */
+
+ /*
+ * 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 USE_ANY_SYSV_TERMIO
+ initial_erase = tio.c_cc[VERASE];
+#elif defined(USE_POSIX_TERMIOS)
+ initial_erase = tio.c_cc[VERASE];
+#else /* !USE_ANY_SYSV_TERMIO && !USE_POSIX_TERMIOS */
+ initial_erase = sg.sg_erase;
+#endif /* USE_ANY_SYSV_TERMIO */
+ }
+#endif
+
+ close(tty);
+ /* tty is no longer an open fd! */
+ tty = -1;
+ }
+
+#ifdef NEW_GET_PTY
+ if (get_pty(&screen->respond, XDisplayString(screen->display))) {
+ SysError(ERROR_PTYS);
+ }
+#else
+ if (get_pty(&screen->respond))) {
+ SysError(ERROR_PTYS);
+ }
+#endif
+#if OPT_INITIAL_ERASE
+ if (resource.ptyInitialErase) {
+#ifdef USE_ANY_SYSV_TERMIO
+ struct termio my_tio;
+ if ((rc = ioctl(screen->respond, TCGETA, &my_tio)) == 0)
+ initial_erase = my_tio.c_cc[VERASE];
+#elif defined(USE_POSIX_TERMIOS)
+ struct termios my_tio;
+ if ((rc = tcgetattr(screen->respond, &my_tio)) == 0)
+ initial_erase = my_tio.c_cc[VERASE];
+#else /* !USE_ANY_SYSV_TERMIO && !USE_POSIX_TERMIOS */
+ struct sgttyb my_sg;
+ if ((rc = ioctl(screen->respond, TIOCGETP, (char *) &my_sg)) == 0)
+ initial_erase = my_sg.sg_erase;
+#endif /* USE_ANY_SYSV_TERMIO */
+ }
+#endif /* OPT_INITIAL_ERASE */
+ }
+
+ /* avoid double MapWindow requests
+ */
+ XtSetMappedWhenManaged( XtParent(term), False );
+
+ wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
+ False);
+
+ 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(term),
+ mit_console, CurrentTime,
+ ConvertConsoleSelection, NULL, NULL);
+
+ }
+#endif
+
+ if (screen->TekEmu) {
+ envnew = tekterm;
+ ptr = newtc;
+ } else {
+ 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
+ if (!resource.ptyInitialErase) {
+ char temp[1024], *p = temp;
+ char *s = tgetstr(TERMCAP_ERASE, &p);
+ if (s != 0) {
+ initial_erase = decode_keyvalue(&s, True);
+ }
+ }
+
+ 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;
+ }
+ } else {
+ term->keyboard.reset_DECBKM = 2;
+ }
+#endif /* OPT_INITIAL_ERASE */
+
+#ifdef TTYSIZE_STRUCT
+ /* tell tty how big window is */
+
+/*
+ if (screen->TekEmu) {
+ 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
+*/
+
+ {
+ TTYSIZE_ROWS(ts) = screen->max_row + 1;
+ TTYSIZE_COLS(ts) = screen->max_col + 1;
+#if defined(USE_STRUCT_WINSIZE)
+ ts.ws_xpixel = FullWidth(screen);
+ ts.ws_ypixel = FullHeight(screen);
+#endif
+ }
+ i = SET_TTYSIZE(screen->respond, ts);
+#endif /* TTYSIZE_STRUCT */
+
+ added_utmp_entry = False;
+#if defined(USE_UTEMPTER)
+#undef UTMP
+ if (!resource.utmpInhibit) {
+ struct UTMP_STR dummy;
+ char host[sizeof(dummy.ut_host) + 1], *endptr;
+
+ (void) strncpy(host, DisplayString(screen->display), sizeof host);
+ host[sizeof(host) - 1] = '\0';
+ endptr = strrchr(host, ':');
+ if (endptr) {
+ *endptr = '\0';
+ }
+ addToUtmp(ttydev, 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
+ if ((screen->pid = fork()) == -1)
+ SysError(ERROR_FORK);
+
+ if (screen->pid == 0) {
+ /*
+ * now in child process
+ */
+#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__) || defined(__SCO__) || defined(__QNX__)
+ int pgrp = setsid(); /* variable may not be used... */
+#else
+ int pgrp = getpid();
+#endif
+
+#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;
+
+#ifdef __DARWIN__
+ ;
+#else
+ setpgrp();
+#endif
+ 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 */
+ tty = ptyfd;
+ close(screen->respond);
+
+#ifdef TTYSIZE_STRUCT
+ /* tell tty how big window is */
+
+ if (screen->TekEmu) {
+ TTYSIZE_ROWS(ts) = 24;
+ TTYSIZE_COLS(ts) = 80;
+/*
+#ifdef USE_STRUCT_WINSIZE
+ ts.ws_xpixel = TFullWidth(screen);
+ ts.ws_ypixel = TFullHeight(screen);
+#endif
+*/
+ } else
+
+ {
+ TTYSIZE_ROWS(ts) = screen->max_row + 1;
+ TTYSIZE_COLS(ts) = screen->max_col + 1;
+/*
+#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));
+ close(screen->respond);
+
+ /* 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
+ while (1) {
+#if defined(TIOCNOTTY) && (!defined(__GLIBC__) || (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))
+ if (!no_dev_tty
+ && (tty = open("/dev/tty", O_RDWR)) >= 0) {
+ ioctl(tty, TIOCNOTTY, (char *) NULL);
+ close(tty);
+ }
+#endif /* TIOCNOTTY && !glibc >= 2.1 */
+#ifdef CSRG_BASED
+ (void) revoke(ttydev);
+#endif
+ if ((tty = open(ttydev, O_RDWR)) >= 0) {
+#if defined(CRAY) && defined(TCSETCTTY)
+ /* make /dev/tty work */
+ ioctl(tty, 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(tty, 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 = (char *) malloc((unsigned)
+ (strlen(handshake.buffer) + 1));
+ 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(tty)) != 0) {
+ /* it may be bigger */
+ ttydev = (char *) realloc(ttydev,
+ (unsigned) (strlen(ptr) + 1));
+ 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
+
+#ifdef USE_TTY_GROUP
+ {
+ struct group *ttygrp;
+ if ((ttygrp = getgrnam("tty")) != 0) {
+ /* change ownership of tty to real uid, "tty" gid */
+ set_owner(ttydev, screen->uid, ttygrp->gr_gid, 0620);
+ } else {
+ /* change ownership of tty to real group and user id */
+ set_owner(ttydev, screen->uid, screen->gid, 0622);
+ }
+ endgrent();
+ }
+#else /* else !USE_TTY_GROUP */
+ /* change ownership of tty to real group and user id */
+ set_owner(ttydev, screen->uid, screen->gid, 0622);
+#endif /* USE_TTY_GROUP */
+
+ /*
+ * set up the tty modes
+ */
+ {
+#if defined(USE_ANY_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)
+#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 (ioctl(tty, TCGETA, &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;
+ /* 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 */
+ tio.c_cflag &= ~CSIZE;
+ if (screen->input_eight_bits)
+ tio.c_cflag |= CS8;
+ else
+ tio.c_cflag |= CS7;
+ /* 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(tty, TIOCSLTC, &ltc) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETC);
+#endif /* HAS_LTCHARS */
+#ifdef TIOCLSET
+ if (ioctl(tty, TIOCLSET, (char *) &lmode) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCLSET);
+#endif /* TIOCLSET */
+#ifndef USE_POSIX_TERMIOS
+ if (ioctl(tty, TCSETA, &tio) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETP);
+#else /* USE_POSIX_TERMIOS */
+ if (tcsetattr(tty, TCSANOW, &tio) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETP);
+#endif /* USE_POSIX_TERMIOS */
+#else /* USE_ANY_SYSV_TERMIO or USE_POSIX_TERMIOS */
+ 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(tty, TIOCSETP, (char *) &sg) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETP);
+ if (ioctl(tty, TIOCSETC, (char *) &tc) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETC);
+ if (ioctl(tty, TIOCSETD, (char *) &discipline) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETD);
+ if (ioctl(tty, TIOCSLTC, (char *) &ltc) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSLTC);
+ if (ioctl(tty, TIOCLSET, (char *) &lmode) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCLSET);
+#ifdef sony
+ if (ioctl(tty, TIOCKSET, (char *) &jmode) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCKSET);
+ if (ioctl(tty, TIOCKSETC, (char *) &jtc) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCKSETC);
+#endif /* sony */
+#endif /* !USE_ANY_SYSV_TERMIO */
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+ if (Console) {
+#ifdef TIOCCONS
+ int on = 1;
+ if (ioctl(tty, TIOCCONS, (char *) &on) == -1)
+ fprintf(stderr, "%s: cannot open console: %s\n",
+ "xgterm", strerror(errno));
+#endif
+#ifdef SRIOCSREDIR
+ int fd = open("/dev/console", O_RDWR);
+ if (fd == -1 || ioctl(fd, SRIOCSREDIR, tty) == -1)
+ fprintf(stderr, "%s: cannot open console: %s\n",
+ "xgterm", 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
+ if (!resource.ptyInitialErase
+ && !override_tty_modes
+ && !ttymodelist[XTTYMODE_erase].set) {
+#ifdef USE_ANY_SYSV_TERMIO
+ if (ioctl(tty, TCGETA, &tio) == -1)
+ tio = d_tio;
+ tio.c_cc[VERASE] = initial_erase;
+ rc = ioctl(tty, TCSETA, &tio);
+#elif defined(USE_POSIX_TERMIOS)
+ if (tcgetattr(tty, &tio) == -1)
+ tio = d_tio;
+ tio.c_cc[VERASE] = initial_erase;
+ rc = tcsetattr(tty, TCSANOW, &tio);
+#else /* !USE_ANY_SYSV_TERMIO && !USE_POSIX_TERMIOS */
+ if (ioctl(tty, TIOCGETP, (char *) &sg) == -1)
+ sg = d_sg;
+ sg.sg_erase = initial_erase;
+ rc = ioctl(tty, TIOCSETP, (char *) &sg);
+#endif /* USE_ANY_SYSV_TERMIO */
+ }
+#endif
+
+ /* copy the environment before Setenving */
+ for (i = 0; environ[i] != NULL; i++) ;
+ /* compute number of xtermSetenv() calls below */
+ envsize = 1; /* (NULL terminating entry) */
+ envsize += 3; /* TERM, WINDOWID, DISPLAY */
+#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 = (char **) calloc((unsigned) i + envsize, sizeof(char *));
+ memmove((char *) envnew, (char *) environ, i * sizeof(char *));
+ environ = envnew;
+ xtermSetenv("TERM=", TermName);
+ if (!TermName)
+ *newtc = 0;
+
+ sprintf(buf, "%lu",
+ ((unsigned long) XtWindow(XtParent(term))));
+ xtermSetenv("WINDOWID=", buf);
+
+ /* put the display into the environment of the shell */
+ xtermSetenv("DISPLAY=", XDisplayString(screen->display));
+
+ signal(SIGTERM, SIG_DFL);
+
+ /* this is the time to go and set up stdin, out, and err
+ */
+ {
+#if defined(CRAY) && (OSMAJORVERSION >= 6)
+ (void) close(tty);
+ (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 != tty) {
+ (void) close(i);
+ (void) dup(tty);
+ }
+#ifndef ATT
+ /* and close the tty */
+ if (tty > 2)
+ (void) close(tty);
+#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
+ {
+ struct termio t;
+ if (ioctl(0, TCGETA, &t) >= 0) {
+ /* this gets lost somewhere on our way... */
+ t.c_oflag |= OPOST;
+ ioctl(0, TCSETA, &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
+ && pw->pw_uid != pw2->pw_uid) {
+ login_name = NULL;
+ }
+ }
+#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) setutent();
+ /* set up entry to search for */
+ bzero((char *) &utmp, sizeof(utmp));
+ (void) strncpy(utmp.ut_id, my_utmp_id(ttydev), sizeof(utmp.ut_id));
+
+ utmp.ut_type = DEAD_PROCESS;
+
+ /* position to entry in utmp file */
+ /* Test return value: beware of entries left behind: PSz 9 Mar 00 */
+ if (!(utret = getutid(&utmp))) {
+ (void) setutent();
+ utmp.ut_type = USER_PROCESS;
+ if (!(utret = getutid(&utmp))) {
+ (void) setutent();
+ }
+ }
+
+ /* 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
+ (void) strncpy(buf, DisplayString(screen->display), sizeof(buf));
+#ifndef linux
+ {
+ char *disfin = strrchr(buf, ':');
+ if (disfin)
+ *disfin = '\0';
+ }
+#endif
+ (void) strncpy(utmp.ut_host, buf, sizeof(utmp.ut_host));
+#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;
+ pututline(&utmp);
+ }
+#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)
+ 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) 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
+ (void) strncpy(utmp.ut_host,
+ XDisplayString(screen->display),
+ sizeof(utmp.ut_host));
+#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);
+ (void) strncpy(lastlog.ll_host,
+ XDisplayString(screen->display),
+ sizeof(lastlog.ll_host));
+ 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));
+ (void) strncpy(lastlog.ll_host,
+ XDisplayString(screen->display),
+ sizeof(lastlog.ll_host));
+ 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 */
+
+#ifdef __OpenBSD__
+ /* Switch to real gid after writing utmp entry */
+ utmpGid = getegid();
+ if (getgid() != getegid()) {
+ utmpGid = getegid();
+ setegid(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) {
+ screen->max_row = handshake.rows;
+ screen->max_col = handshake.cols;
+#ifdef TTYSIZE_STRUCT
+ TTYSIZE_ROWS(ts) = screen->max_row + 1;
+ TTYSIZE_COLS(ts) = screen->max_col + 1;
+#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", screen->max_col + 1);
+ xtermSetenv("COLUMNS=", numbuf);
+ sprintf(numbuf, "%d", screen->max_row + 1);
+ 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 (!screen->TekEmu && *newtc) {
+ strcpy(termcap, newtc);
+ resize(screen, termcap, newtc);
+ }
+/*
+ if (term->misc.titeInhibit && !term->misc.tiXtraScroll) {
+*/
+ if (term->misc.titeInhibit) {
+ 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,
+ initial_erase & 0377);
+#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);
+#endif /* TTYSIZE_STRUCT */
+ }
+#endif /* OPT_PTY_HANDSHAKE */
+ signal(SIGHUP, SIG_DFL);
+
+#ifdef HAVE_UTMP
+ if (((ptr = getenv("SHELL")) == NULL || *ptr == 0) &&
+ ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) ||
+ *(ptr = pw->pw_shell) == 0))
+#else /* HAVE_UTMP */
+ if (((ptr = getenv("SHELL")) == NULL || *ptr == 0) &&
+ ((pw = getpwuid(screen->uid)) == NULL ||
+ *(ptr = pw->pw_shell) == 0))
+#endif /* HAVE_UTMP */
+ ptr = "/bin/sh";
+ shname = x_basename(ptr);
+
+#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) {
+ 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",
+ "xgterm", *command_to_exec_with_luit, strerror(errno));
+ fprintf(stderr, "%s: cannot support your locale.\n",
+ "xgterm");
+ }
+#endif
+ if (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",
+ "xgterm", *command_to_exec, strerror(errno));
+ }
+#ifdef USE_SYSV_SIGHUP
+ /* fix pts sh hanging around
+ signal(SIGHUP, SIG_DFL);
+ */
+#endif
+
+ shname_minus = (char *) malloc(strlen(shname) + 2);
+ (void) strcpy(shname_minus, "-");
+ (void) strcat(shname_minus, shname);
+#if !defined(USE_ANY_SYSV_TERMIO) && !defined(USE_POSIX_TERMIOS)
+ ldisc = XStrCmp("csh", shname + strlen(shname) - 3) == 0 ?
+ NTTYDISC : 0;
+ ioctl(0, TIOCSETD, (char *) &ldisc);
+#endif /* !USE_ANY_SYSV_TERMIO && !USE_POSIX_TERMIOS */
+
+#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", "xgterm",
+ 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);
+#ifdef NEW_GET_PTY
+ if (get_pty(&screen->respond, XDisplayString(screen->display))) {
+#else
+ if (get_pty(&screen->respond)) {
+#endif
+ /* no more ptys! */
+ fprintf(stderr,
+ "%s: child process can find no available ptys: %s\n",
+ "xgterm", 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",
+ "xgterm", 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? (Fedora)
+ signal(SIGHUP, SIG_DFL);
+ */
+ signal(SIGHUP, SIG_IGN);
+#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 */
+
+#else
+
+
+spawn ()
+/*
+ * 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
+ */
+{
+ extern char *SysErrorMsg();
+ register TScreen *screen = &term->screen;
+ int Xsocket = ConnectionNumber(screen->display);
+#ifdef USE_HANDSHAKE
+ handshake_t handshake;
+#else
+ int fds[2];
+#endif
+ int tty = -1;
+ int discipline;
+ int done;
+#ifdef USE_SYSV_TERMIO
+ struct termio tio;
+ struct termio dummy_tio;
+#ifdef TIOCLSET
+ unsigned lmode;
+#endif /* TIOCLSET */
+#ifdef TIOCSLTC
+ struct ltchars ltc;
+#endif /* TIOCSLTC */
+ int one = 1;
+ int zero = 0;
+ int status;
+#else /* else not USE_SYSV_TERMIO */
+ unsigned lmode;
+ struct tchars tc;
+ struct ltchars ltc;
+ struct sgttyb sg;
+#ifdef sony
+ int jmode;
+ struct jtchars jtc;
+#endif /* sony */
+#endif /* USE_SYSV_TERMIO */
+
+ char termcap [1024];
+ char newtc [1024];
+ char *ptr, *shname, *shname_minus;
+ int i, no_dev_tty = FALSE;
+#ifdef USE_SYSV_TERMIO
+ char *dev_tty_name = (char *) 0;
+ int fd; /* for /etc/wtmp */
+#endif /* USE_SYSV_TERMIO */
+ char **envnew; /* new environment */
+ int envsize; /* elements in new environment */
+ char buf[64];
+ char *TermName = NULL;
+ int ldisc = 0;
+#if defined(sun) && !defined(SVR4)
+#ifdef TIOCSSIZE
+ struct ttysize ts;
+#endif /* TIOCSSIZE */
+#else /* not sun */
+#ifdef TIOCSWINSZ
+ struct winsize ws;
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+ struct passwd *pw = NULL;
+#ifdef UTMP
+#ifdef SVR4
+ struct utmpx utmp;
+#else
+ struct utmp utmp;
+#endif
+#ifdef LASTLOG
+ struct lastlog lastlog;
+#endif /* LASTLOG */
+#endif /* UTMP */
+
+ screen->uid = getuid();
+ screen->gid = getgid();
+
+#ifdef linux
+ memset(termcap, 0, sizeof(termcap));
+ memset(newtc, 0, sizeof(newtc));
+#endif
+
+#ifdef SIGTTOU
+ /* so that TIOCSWINSZ || TIOCSIZE doesn't block */
+ signal(SIGTTOU,SIG_IGN);
+#endif
+
+ if (am_slave) {
+ 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 = False;
+
+ /*
+ * 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)) {
+ tty = open ("/dev/tty", O_RDWR, 0);
+ alarm(0);
+ } else {
+ tty_got_hung = True;
+ tty = -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.
+ */
+ if (tty < 0) {
+ if (tty_got_hung || errno == ENXIO || errno == EIO ||
+ errno == ENOTTY) {
+ no_dev_tty = TRUE;
+#ifdef TIOCSLTC
+ ltc = d_ltc;
+#endif /* TIOCSLTC */
+#ifdef TIOCLSET
+ lmode = d_lmode;
+#endif /* TIOCLSET */
+#ifdef USE_SYSV_TERMIO
+ tio = d_tio;
+#else /* not USE_SYSV_TERMIO */
+ sg = d_sg;
+ tc = d_tc;
+ discipline = d_disipline;
+#ifdef sony
+ jmode = d_jmode;
+ jtc = d_jtc;
+#endif /* sony */
+#endif /* USE_SYSV_TERMIO */
+ } 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 TIOCSLTC
+ if(ioctl(tty, TIOCGLTC, &ltc) == -1)
+ ltc = d_ltc;
+#endif /* TIOCSLTC */
+#ifdef TIOCLSET
+ if(ioctl(tty, TIOCLGET, &lmode) == -1)
+ lmode = d_lmode;
+#endif /* TIOCLSET */
+#ifdef USE_SYSV_TERMIO
+ if(ioctl(tty, TCGETA, &tio) == -1)
+ tio = d_tio;
+
+#else /* not USE_SYSV_TERMIO */
+ if(ioctl(tty, TIOCGETP, (char *)&sg) == -1)
+ sg = d_sg;
+ if(ioctl(tty, TIOCGETC, (char *)&tc) == -1)
+ tc = d_tc;
+ if(ioctl(tty, TIOCGETD, (char *)&discipline) == -1)
+ discipline = d_disipline;
+#ifdef sony
+ if(ioctl(tty, TIOCKGET, (char *)&jmode) == -1)
+ jmode = d_jmode;
+ if(ioctl(tty, TIOCKGETC, (char *)&jtc) == -1)
+ jtc = d_jtc;
+#endif /* sony */
+#endif /* USE_SYSV_TERMIO */
+ close (tty);
+ /* tty is no longer an open fd! */
+ tty = -1;
+ }
+
+#ifdef PUCC_PTYD
+ if(-1 == (screen->respond = openrpty(ttydev, ptydev,
+ (resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN),
+ getuid(), XDisplayString(screen->display)))) {
+#else /* not PUCC_PTYD */
+#ifdef NEW_GET_PTY
+ if (get_pty(&screen->respond,XDisplayString(screen->display))) {
+#else
+ if (get_pty(&screen->respond)) {
+#endif
+#endif /* PUCC_PTYD */
+ /* no ptys! */
+ (void) fprintf(stderr, "%s: no available ptys\n",
+ xgterm_name);
+ exit (ERROR_PTYS);
+#ifdef PUCC_PTYD
+ }
+#else
+ } /* keep braces balanced for emacs */
+#endif
+#ifdef PUCC_PTYD
+ else {
+ /*
+ * set the fd of the master in a global var so
+ * we can undo all this on exit
+ *
+ */
+ Ptyfd = screen->respond;
+ }
+#endif /* PUCC_PTYD */
+ }
+
+ /* avoid double MapWindow requests */
+ XtSetMappedWhenManaged( XtParent(term), False );
+ wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
+ False);
+ 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(term),
+ mit_console, CurrentTime,
+ ConvertConsoleSelection, NULL, NULL);
+ }
+#endif
+ if(screen->TekEmu) {
+ envnew = tekterm;
+ ptr = newtc;
+ } else {
+ envnew = vtterm;
+ ptr = termcap;
+ }
+ TermName = NULL;
+ if (resource.term_name) {
+ if (tgetent (ptr, resource.term_name) == 1) {
+ TermName = resource.term_name;
+ if (!screen->TekEmu)
+ resize (screen, TermName, termcap, newtc);
+ } else {
+ fprintf (stderr, "%s: invalid termcap entry \"%s\".\n",
+ ProgramName, resource.term_name);
+ }
+ }
+ if (!TermName) {
+ while (*envnew != NULL) {
+ if(tgetent(ptr, *envnew) == 1) {
+ TermName = *envnew;
+ if(!screen->TekEmu)
+ resize(screen, TermName, termcap, newtc);
+ break;
+ }
+ envnew++;
+ }
+ if (TermName == NULL) {
+ fprintf (stderr, "%s: unable to find usable termcap entry.\n",
+ ProgramName);
+ Exit (1);
+ }
+ }
+
+#if defined(sun) && !defined(SVR4)
+#ifdef TIOCSSIZE
+ /* tell tty how big window is */
+ if(screen->TekEmu) {
+ ts.ts_lines = 35;
+ ts.ts_cols = 80;
+ } else {
+ ts.ts_lines = screen->max_row + 1;
+ ts.ts_cols = screen->max_col + 1;
+ }
+#endif /* TIOCSSIZE */
+#else /* not sun */
+#ifdef TIOCSWINSZ
+ /* tell tty how big window is */
+ if(screen->TekEmu) {
+ /* We can only guess at the size at this point. */
+ ws.ws_row = 35;
+ ws.ws_col = 80;
+ ws.ws_xpixel = 640;
+ ws.ws_ypixel = 480;
+ } else {
+ ws.ws_row = screen->max_row + 1;
+ ws.ws_col = screen->max_col + 1;
+ ws.ws_xpixel = FullWidth(screen);
+ ws.ws_ypixel = FullHeight(screen);
+ }
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+
+ if (!am_slave) {
+#ifdef USE_HANDSHAKE
+ if (pipe(pc_pipe) || pipe(cp_pipe))
+ SysError (ERROR_FORK);
+#endif
+ if ((screen->pid = fork ()) == -1)
+ SysError (ERROR_FORK);
+
+ if (screen->pid == 0) {
+ /*
+ * now in child process
+ */
+ extern char **environ;
+#if defined(_POSIX_SOURCE) || defined(SVR4) || defined(__convex__)
+ int pgrp = setsid();
+#else
+ int pgrp = getpid();
+#endif
+#ifdef USE_SYSV_TERMIO
+ char numbuf[12];
+#endif /* USE_SYSV_TERMIO */
+#if defined(UTMP) && defined(USE_SYSV_UTMP)
+ char *ptyname;
+#endif
+
+#ifdef USE_USG_PTYS
+#if defined(SYSV) && defined(SYSV386)
+ if (IsPts) { /* SYSV386 supports both, which did we open? */
+#endif /* SYSV && SYSV386 */
+ int ptyfd;
+
+ setpgrp();
+ grantpt (screen->respond);
+ unlockpt (screen->respond);
+ if ((ptyfd = open (ptsname(screen->respond), O_RDWR)) < 0) {
+ SysError (1);
+ }
+#ifdef I_PUSH
+ if (ioctl (ptyfd, I_PUSH, "ptem") < 0) {
+ SysError (2);
+ }
+#if !defined(SVR4) && !defined(SYSV386)
+ if (!getenv("CONSEM") && ioctl (ptyfd, I_PUSH, "consem") < 0) {
+ SysError (3);
+ }
+#endif /* !SVR4 */
+ if (ioctl (ptyfd, I_PUSH, "ldterm") < 0) {
+ SysError (4);
+ }
+#ifdef SVR4 /* from Sony */
+#if !defined(sgi) && !defined(ibm)
+ if (ioctl (ptyfd, I_PUSH, "ttcompat") < 0) {
+ SysError (5);
+ }
+#endif /* !defined(sgi) */
+#endif /* SVR4 */
+#endif /* I_PUSH */
+ tty = ptyfd;
+ close (screen->respond);
+#ifdef TIOCSWINSZ
+ /* tell tty how big window is */
+ if(screen->TekEmu) {
+ ws.ws_row = 35;
+ ws.ws_col = 80;
+ ws.ws_xpixel = 640;
+ ws.ws_ypixel = 480;
+ } else {
+ ws.ws_row = screen->max_row + 1;
+ ws.ws_col = screen->max_col + 1;
+ ws.ws_xpixel = FullWidth(screen);
+ ws.ws_ypixel = FullHeight(screen);
+ }
+#endif
+#if defined(SYSV) && defined(SYSV386)
+ } else { /* else pty, not pts */
+#endif /* SYSV && SYSV386 */
+#endif /* USE_USG_PTYS */
+
+#ifdef USE_HANDSHAKE /* warning, goes for a long ways */
+ /* 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 (Xsocket);
+ close (screen->respond);
+
+ /* 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 */
+ while (1) {
+
+#ifdef TIOCNOTTY
+ if (!no_dev_tty && (tty = open ("/dev/tty", O_RDWR)) >= 0) {
+ ioctl (tty, TIOCNOTTY, (char *) NULL);
+ close (tty);
+ }
+#endif /* TIOCNOTTY */
+ if ((tty = open(ttydev, O_RDWR, 0)) >= 0) {
+#if defined(CRAY) && defined(TCSETCTTY)
+ /* make /dev/tty work */
+ ioctl(tty, TCSETCTTY, 0);
+#endif
+#ifdef USE_SYSV_PGRP
+ /* We need to make sure that we are acutally
+ * 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)) >= 0) {
+ /* success! */
+ close(i);
+ break;
+ }
+#else /* USE_SYSV_PGRP */
+ break;
+#endif /* USE_SYSV_PGRP */
+ }
+
+#ifdef TIOCSCTTY
+ ioctl(tty, 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 = malloc((unsigned)
+ (strlen(handshake.buffer) + 1));
+ strcpy(ttydev, handshake.buffer);
+ }
+
+ /* use the same tty name that everyone else will use
+ ** (from ttyname)
+ */
+ if (ptr = ttyname(tty))
+ {
+ /* it may be bigger */
+ ttydev = realloc (ttydev, (unsigned) (strlen(ptr) + 1));
+ (void) strcpy(ttydev, ptr);
+ }
+#if defined(SYSV) && defined(SYSV386)
+ } /* end of IsPts else clause */
+#endif /* SYSV && SYSV386 */
+
+#endif /* USE_HANDSHAKE -- from near fork */
+
+#ifdef USE_TTY_GROUP
+ {
+#include <grp.h> /* R6 update */
+ struct group *ttygrp;
+ if (ttygrp = getgrnam("tty")) {
+ /* change ownership of tty to real uid, "tty" gid */
+ chown (ttydev, screen->uid, ttygrp->gr_gid);
+ chmod (ttydev, 0620);
+ }
+ else {
+ /* change ownership of tty to real group and user id */
+ chown (ttydev, screen->uid, screen->gid);
+ chmod (ttydev, 0622);
+ }
+ endgrent();
+ }
+#else /* else !USE_TTY_GROUP */
+ /* change ownership of tty to real group and user id */
+ chown (ttydev, screen->uid, screen->gid);
+
+ /* change protection of tty */
+ chmod (ttydev, 0622);
+#endif /* USE_TTY_GROUP */
+
+ /*
+ * set up the tty modes
+ */
+ {
+/*
+#ifdef USE_SYSV_TERMIO
+*/
+#if defined(USE_ANY_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS)
+#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 (ioctl (tty, TCGETA, &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;
+ /* ouput: cr->cr, nl is not return, no delays, ln->cr/nl */
+ tio.c_oflag &=
+ ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
+ tio.c_oflag |= ONLCR;
+#ifdef OPOST
+ tio.c_oflag |= OPOST;
+#endif /* OPOST */
+#ifdef BAUD_0
+ /* baud rate is 0 (don't care) */
+ tio.c_cflag &= ~(CBAUD);
+#else /* !BAUD_0 */
+ /* baud rate is 9600 (nice default) */
+ tio.c_cflag &= ~(CBAUD);
+ tio.c_cflag |= B9600;
+#endif /* !BAUD_0 */
+ /* enable signals, canonical processing (erase, kill, etc),
+ ** echo
+ */
+ tio.c_lflag |= ISIG|ICANON|ECHO;
+ /* reset EOL to defalult value */
+ tio.c_cc[VEOL] = '@' & 0x3f; /* '^@' */
+ /* certain shells (ksh & csh) change EOF as well */
+ tio.c_cc[VEOF] = 'D' & 0x3f; /* '^D' */
+
+#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value;
+ 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, d_tio.c_cc[VSWTCH]);
+#endif
+#ifdef TIOCSLTC
+ /* 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
+ }
+#undef TMODE
+
+ if (ioctl (tty, TCSETA, &tio) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETP);
+#ifdef TIOCSLTC
+#ifndef hpux
+ if (ioctl (tty, TIOCSLTC, &ltc) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCSETC);
+#endif
+#endif /* TIOCSLTC */
+#ifdef TIOCLSET
+ if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1)
+ HsSysError(cp_pipe[1], ERROR_TIOCLSET);
+#endif /* TIOCLSET */
+#else /* USE_SYSV_TERMIO */
+ 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 = B9600;
+ sg.sg_ospeed = B9600;
+ /* reset t_brkc to default value */
+ tc.t_brkc = -1;
+#ifdef sony
+ if (screen->input_eight_bits)
+ lmode |= LPASS8;
+ else
+ lmode &= ~(LPASS8);
+ jmode &= ~KM_KANJI;
+#endif /* sony */
+
+#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value;
+ 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);
+ }
+#undef TMODE
+
+ if (ioctl (tty, TIOCSETP, (char *)&sg) == -1)
+ HsSysError (cp_pipe[1], ERROR_TIOCSETP);
+#ifndef hpux
+ if (ioctl (tty, TIOCSETC, (char *)&tc) == -1)
+ HsSysError (cp_pipe[1], ERROR_TIOCSETC);
+#endif
+ if (ioctl (tty, TIOCSETD, (char *)&discipline) == -1)
+ HsSysError (cp_pipe[1], ERROR_TIOCSETD);
+ if (ioctl (tty, TIOCSLTC, (char *)&ltc) == -1)
+ HsSysError (cp_pipe[1], ERROR_TIOCSLTC);
+ if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1)
+ HsSysError (cp_pipe[1], ERROR_TIOCLSET);
+#ifdef sony
+ if (ioctl (tty, TIOCKSET, (char *)&jmode) == -1)
+ HsSysError (cp_pipe[1], ERROR_TIOCKSET);
+ if (ioctl (tty, TIOCKSETC, (char *)&jtc) == -1)
+ HsSysError (cp_pipe[1], ERROR_TIOCKSETC);
+#endif /* sony */
+#endif /* !USE_SYSV_TERMIO */
+#if defined(TIOCCONS) || defined(SRIOCSREDIR)
+ if (Console) {
+#ifdef TIOCCONS
+ int on = 1;
+ if (ioctl (tty, TIOCCONS, (char *)&on) == -1)
+ fprintf(stderr, "%s: cannot open console\n",
+ xgterm_name);
+#endif
+#ifdef SRIOCSREDIR
+ int fd = open("/dev/console",O_RDWR);
+ if (fd == -1 || ioctl (fd, SRIOCSREDIR, tty) == -1)
+ fprintf(stderr, "%s: cannot open console\n",
+ xgterm_name);
+ (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);
+
+ /* copy the environment before Setenving */
+ for (i = 0 ; environ [i] != NULL ; i++)
+ ;
+ /* compute number of Setenv() calls below */
+ envsize = 1; /* (NULL terminating entry) */
+ envsize += 3; /* TERM, WINDOWID, DISPLAY */
+#ifdef UTMP
+ envsize += 1; /* LOGNAME */
+#endif /* UTMP */
+#ifdef USE_SYSV_ENVVARS
+#ifndef TIOCSWINSZ /* window size not stored in driver? */
+ envsize += 2; /* COLUMNS, LINES */
+#endif /* TIOCSWINSZ */
+#ifdef UTMP
+ envsize += 2; /* HOME, SHELL */
+#endif /* UTMP */
+#else /* USE_SYSV_ENVVARS */
+ envsize += 1; /* TERMCAP */
+#endif /* USE_SYSV_ENVVARS */
+ envnew = (char **) calloc ((unsigned) i + envsize, sizeof(char *));
+ memmove( (char *)envnew, (char *)environ, i * sizeof(char *));
+ environ = envnew;
+ Setenv ("TERM=", TermName);
+ if(!TermName)
+ *newtc = 0;
+
+ sprintf (buf, "%lu",
+ ((unsigned long) XtWindow (XtParent(term))));
+ Setenv ("WINDOWID=", buf);
+ /* put the display into the environment of the shell*/
+ Setenv ("DISPLAY=", XDisplayString (screen->display));
+
+ signal(SIGTERM, SIG_DFL);
+
+ /* this is the time to go and set up stdin, out, and err
+ */
+ {
+#if defined(CRAY) && (OSMAJORVERSION >= 6)
+ (void) close(tty);
+ (void) close(0);
+
+ if (open ("/dev/tty", O_RDWR)) {
+ fprintf(stderr, "cannot open /dev/tty\n");
+ exit(1);
+ }
+ (void) close(1);
+ (void) close(2);
+ dup(0);
+ dup(0);
+#else
+ /* dup the tty */
+ for (i = 0; i <= 2; i++)
+ if (i != tty) {
+ (void) close(i);
+ (void) dup(tty);
+ }
+
+#ifndef ATT
+ /* and close the tty */
+ if (tty > 2)
+ (void) close(tty);
+#endif
+#endif /* CRAY */
+ }
+
+#ifndef USE_SYSV_PGRP
+#ifdef TIOCSCTTY
+ setsid();
+ ioctl(0, TIOCSCTTY, 0);
+#endif
+ ioctl(0, TIOCSPGRP, (char *)&pgrp);
+ setpgrp(0,0);
+ close(open(ttydev, O_WRONLY, 0));
+ setpgrp (0, pgrp);
+#endif /* !USE_SYSV_PGRP */
+
+#ifdef UTMP
+ pw = getpwuid(screen->uid);
+ if (pw && pw->pw_name)
+ Setenv ("LOGNAME=", pw->pw_name); /* for POSIX */
+#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.
+ */
+#ifdef CRAY
+#define PTYCHARLEN 4
+#else
+#define PTYCHARLEN 2
+#endif
+
+ (void) setutent ();
+ /* set up entry to search for */
+ ptyname = ttydev;
+ (void) strncpy(utmp.ut_id,ptyname + strlen(ptyname)-PTYCHARLEN,
+ sizeof (utmp.ut_id));
+ utmp.ut_type = DEAD_PROCESS;
+
+ /* position to entry in utmp file */
+ (void) getutid(&utmp);
+
+ /* set up the new entry */
+ utmp.ut_type = USER_PROCESS;
+#ifndef linux
+ utmp.ut_exit.e_exit = 2;
+#endif
+ (void) strncpy(utmp.ut_user,
+ (pw && pw->pw_name) ? pw->pw_name : "????",
+ sizeof(utmp.ut_user));
+
+ (void)strncpy(utmp.ut_id, ptyname + strlen(ptyname)-PTYCHARLEN,
+ sizeof(utmp.ut_id));
+ (void) strncpy (utmp.ut_line,
+ ptyname + strlen("/dev/"), sizeof (utmp.ut_line));
+
+#ifdef HAS_UTMP_UT_HOST
+ (void) strncpy(buf, DisplayString(screen->display),
+ sizeof(buf));
+#ifndef linux /* R6 update */
+ {
+ char *disfin = strrchr(buf, ':');
+ if (disfin)
+ *disfin = '\0';
+ }
+#endif /* R6 update */
+ (void) strncpy(utmp.ut_host, buf, sizeof(utmp.ut_host));
+#endif
+ (void) strncpy(utmp.ut_name, pw->pw_name,
+ sizeof(utmp.ut_name));
+
+ utmp.ut_pid = getpid();
+#ifdef SVR4
+ utmp.ut_session = getsid(0);
+ 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)
+ (void) pututline(&utmp);
+#ifdef WTMP
+#ifdef SVR4
+ if (term->misc.login_shell)
+ updwtmpx(WTMPX_FILE, &utmp);
+#else
+ if (term->misc.login_shell &&
+ (i = open(etc_wtmp, O_WRONLY|O_APPEND)) >= 0) {
+ write(i, (char *)&utmp, sizeof(struct utmp));
+ close(i);
+ }
+#endif
+#endif
+ /* close the file */
+ (void) 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 (pw && !resource.utmpInhibit &&
+ (i = open(etc_utmp, O_WRONLY)) >= 0) {
+ memset((char *)&utmp, 0, sizeof(struct utmp));
+ (void) strncpy(utmp.ut_line,
+ ttydev + strlen("/dev/"),
+ sizeof(utmp.ut_line));
+ (void) strncpy(utmp.ut_name, pw->pw_name,
+ sizeof(utmp.ut_name));
+#ifdef HAS_UTMP_UT_HOST
+ (void) strncpy(utmp.ut_host,
+ XDisplayString (screen->display),
+ sizeof(utmp.ut_host));
+#endif
+ time(&utmp.ut_time);
+ lseek(i, (long)(tslot * sizeof(struct utmp)), 0);
+ write(i, (char *)&utmp, sizeof(struct utmp));
+ close(i);
+ added_utmp_entry = True;
+#ifdef WTMP
+ if (term->misc.login_shell &&
+ (i = open(etc_wtmp, O_WRONLY|O_APPEND)) >= 0) {
+ int status;
+ status = write(i, (char *)&utmp,
+ sizeof(struct utmp));
+ status = close(i);
+ }
+#endif /* WTMP */
+#ifdef MNX_LASTLOG
+ if (term->misc.login_shell &&
+ (i = open(_U_LASTLOG, O_WRONLY)) >= 0) {
+ lseek(i, (long)(screen->uid *
+ sizeof (struct utmp)), 0);
+ write(i, (char *)&utmp,
+ sizeof (struct utmp));
+ close(i);
+ }
+#endif /* MNX_LASTLOG */
+#ifdef LASTLOG
+ if (term->misc.login_shell &&
+ (i = open(etc_lastlog, O_WRONLY)) >= 0) {
+ memset((char *)&lastlog, 0,
+ sizeof (struct lastlog));
+ (void) strncpy(lastlog.ll_line, ttydev +
+ sizeof("/dev"),
+ sizeof (lastlog.ll_line));
+ (void) strncpy(lastlog.ll_host,
+ XDisplayString (screen->display),
+ sizeof (lastlog.ll_host));
+ time(&lastlog.ll_time);
+ lseek(i, (long)(screen->uid *
+ sizeof (struct lastlog)), 0);
+ write(i, (char *)&lastlog,
+ sizeof (struct lastlog));
+ close(i);
+ }
+#endif /* LASTLOG */
+ } else
+ tslot = -tslot;
+ }
+
+ /* Let's pass our ttyslot to our parent so that it can
+ * clean up after us.
+ */
+#ifdef USE_HANDSHAKE
+ handshake.tty_slot = tslot;
+#endif /* USE_HANDSHAKE */
+#endif /* USE_SYSV_UTMP */
+
+#ifdef USE_HANDSHAKE
+ /* Let our parent know that we set up our utmp entry
+ * so that it can clean up after us.
+ */
+ handshake.status = UTMP_ADDED;
+ handshake.error = 0;
+ strcpy(handshake.buffer, ttydev);
+ (void)write(cp_pipe[1], (char *)&handshake, sizeof(handshake));
+#endif /* USE_HANDSHAKE */
+#endif/* UTMP */
+
+ (void) setgid (screen->gid);
+#ifdef HAS_BSD_GROUPS
+ if (geteuid() == 0 && pw)
+ initgroups (pw->pw_name, pw->pw_gid);
+#endif
+ (void) setuid (screen->uid);
+
+#ifdef USE_HANDSHAKE
+ /* 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) {
+ screen->max_row = handshake.rows;
+ screen->max_col = handshake.cols;
+#if defined(sun) && !defined(SVR4)
+#ifdef TIOCSSIZE
+ ts.ts_lines = screen->max_row + 1;
+ ts.ts_cols = screen->max_col + 1;
+#endif /* TIOCSSIZE */
+#else /* !sun */
+#ifdef TIOCSWINSZ
+ ws.ws_row = screen->max_row + 1;
+ ws.ws_col = screen->max_col + 1;
+ ws.ws_xpixel = FullWidth(screen);
+ ws.ws_ypixel = FullHeight(screen);
+#endif /* TIOCSWINSZ */
+#endif /* sun else !sun */
+ }
+ }
+#endif /* USE_HANDSHAKE */
+
+#ifdef USE_SYSV_ENVVARS
+ sprintf (numbuf, "%d", screen->max_col + 1);
+ Setenv("COLUMNS=", numbuf);
+ sprintf (numbuf, "%d", screen->max_row + 1);
+ Setenv("LINES=", numbuf);
+#ifdef UTMP
+ if (pw) { /* SVR4 doesn't provide these */
+ if (!getenv("HOME"))
+ Setenv("HOME=", pw->pw_dir);
+ if (!getenv("SHELL"))
+ Setenv("SHELL=", pw->pw_shell);
+ }
+#endif /* UTMP */
+#else /* USE_SYSV_ENVVAR */
+ if(!screen->TekEmu) {
+ strcpy (termcap, newtc);
+ resize (screen, TermName, termcap, newtc);
+ }
+ if (term->misc.titeInhibit) {
+ 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");
+ strcat (newtc, ":im=\\E[4h:ei=\\E[4l:mi:");
+ }
+ Setenv ("TERMCAP=", newtc);
+#endif /* USE_SYSV_ENVVAR */
+
+
+ /* need to reset after all the ioctl bashing we did above */
+#if defined(sun) && !defined(SVR4)
+#ifdef TIOCSSIZE
+ ioctl (0, TIOCSSIZE, &ts);
+#endif /* TIOCSSIZE */
+#else /* not sun */
+#ifdef TIOCSWINSZ
+ ioctl (0, TIOCSWINSZ, (char *)&ws);
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+
+ signal(SIGHUP, SIG_DFL);
+ if (command_to_exec) {
+ execvp(*command_to_exec, command_to_exec);
+ /* print error message on screen */
+ fprintf(stderr, "%s: Can't execvp %s\n", xgterm_name,
+ *command_to_exec);
+ }
+
+#ifdef USE_SYSV_SIGHUP
+ /* fix pts sh hanging around */
+ signal (SIGHUP, SIG_DFL);
+#endif
+#ifdef _IBMR2
+ /* The AIX 3.1 "rsh" command turns off INTR in sigmask. We
+ must turn it back on. No you cannot solve this by calling
+ signal(SIGINT,SIG_DFL). Tried.
+ -- Dan Greening dgreen@ibm.com */
+ {
+ extern int sigprocmask();
+ int mask;
+ sigset_t set, oset;
+
+ sigemptyset(&set);
+ sigprocmask(SIG_SETMASK,&set,&oset);
+ }
+#endif /* _IBMR2 */
+
+#ifdef UTMP
+ if(((ptr = getenv("SHELL")) == NULL || *ptr == 0) &&
+ ((pw == NULL && (pw = getpwuid(screen->uid)) == NULL) ||
+ *(ptr = pw->pw_shell) == 0))
+#else /* UTMP */
+ if(((ptr = getenv("SHELL")) == NULL || *ptr == 0) &&
+ ((pw = getpwuid(screen->uid)) == NULL ||
+ *(ptr = pw->pw_shell) == 0))
+#endif /* UTMP */
+ ptr = "/bin/sh";
+ if(shname = strrchr(ptr, '/'))
+ shname++;
+ else
+ shname = ptr;
+ shname_minus = malloc(strlen(shname) + 2);
+ (void) strcpy(shname_minus, "-");
+ (void) strcat(shname_minus, shname);
+#ifndef USE_SYSV_TERMIO
+ ldisc = XStrCmp("csh", shname + strlen(shname) - 3) == 0 ?
+ NTTYDISC : 0;
+ ioctl(0, TIOCSETD, (char *)&ldisc);
+#endif /* !USE_SYSV_TERMIO */
+
+#ifdef USE_LOGIN_DASH_P
+ if (term->misc.login_shell && pw && added_utmp_entry)
+ execl (bin_login, "login", "-p", "-f", pw->pw_name, 0);
+#endif
+ execlp (ptr, (term->misc.login_shell ? shname_minus : shname),
+ 0);
+
+ /* Exec failed. */
+ fprintf (stderr, "%s: Could not exec %s!\n", xgterm_name, ptr);
+ (void) sleep(5);
+ exit(ERROR_EXEC);
+ } /* end if in child after fork */
+
+#ifdef USE_HANDSHAKE
+ /* 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);
+#ifdef NEW_GET_PTY
+ if (get_pty(&screen->respond, XDisplayString(screen->display))) {
+#else
+ if (get_pty(&screen->respond)) {
+#endif
+ /* no more ptys! */
+ (void) fprintf(stderr,
+ "%s: child process can find no available ptys\n",
+ xgterm_name);
+ 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);
+
+ 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 = malloc((unsigned) strlen(handshake.buffer) + 1);
+ strcpy(ttydev, handshake.buffer);
+ break;
+ default:
+ fprintf(stderr, "%s: unexpected handshake status %d\n",
+ xgterm_name, handshake.status);
+ }
+ }
+ /* close our sides of the pipes */
+ if (!waiting_for_initial_map) {
+ close (cp_pipe[0]);
+ close (pc_pipe[1]);
+ }
+#endif /* USE_HANDSHAKE */
+ } /* end if no slave */
+
+ /*
+ * still in parent (xgterm 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 xgterm. This is a problem because hitting the
+ * INTR or QUIT characters on the keyboard will cause xgterm 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);
+#else /* else is bsd or has job control */
+#ifdef SYSV
+ /* 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 /* SYSV */
+#endif /* USE_SYSV_SIGNALS and not SIGTSTP */
+
+ return 0;
+} /* end spawn */
+#endif
+
+
+
+SIGNAL_T
+Exit(n)
+ int n;
+{
+ register TScreen *screen = &term->screen;
+ int pty = term->screen.respond; /* file descriptor of pty */
+#ifdef UTMP
+#ifdef USE_SYSV_UTMP
+#ifdef SVR4
+ struct utmpx utmp;
+ struct utmpx *utptr;
+#else
+ struct utmp utmp;
+ struct utmp *utptr;
+#endif
+ char *ptyname;
+#if defined(WTMP) && !defined(SVR4)
+ int fd; /* for /etc/wtmp */
+ int i;
+#endif
+
+#ifdef PUCC_PTYD
+ closepty(ttydev, ptydev, (resource.utmpInhibit ? OPTY_NOP : OPTY_LOGIN), Ptyfd);
+#endif /* PUCC_PTYD */
+
+ /* cleanup the utmp entry we forged earlier */
+ if (!resource.utmpInhibit
+#ifdef USE_HANDSHAKE /* without handshake, no way to know */
+ && added_utmp_entry
+#endif /* USE_HANDSHAKE */
+ ) {
+ ptyname = ttydev;
+ utmp.ut_type = USER_PROCESS;
+ (void) strncpy(utmp.ut_id, ptyname + strlen(ptyname) - PTYCHARLEN,
+ sizeof(utmp.ut_id));
+ (void) setutent();
+ utptr = getutid(&utmp);
+ /* write it out only if it exists, and the pid's match */
+ if (utptr && (utptr->ut_pid == screen->pid)) {
+ utptr->ut_type = DEAD_PROCESS;
+#ifdef SVR4
+ utmp.ut_session = getsid(0);
+ utmp.ut_xtime = time ((Time_t *) 0);
+ utmp.ut_tv.tv_usec = 0;
+#else
+ utptr->ut_time = time((Time_t *) 0);
+#endif
+ (void) pututline(utptr);
+#ifdef WTMP
+#ifdef SVR4
+ updwtmpx(WTMPX_FILE, &utmp);
+#else
+ /* set wtmp entry if wtmp file exists */
+ if ((fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+ i = write(fd, utptr, sizeof(utmp));
+ i = close(fd);
+ }
+#endif
+#endif
+
+ }
+ (void) endutent();
+ }
+#else /* not USE_SYSV_UTMP */
+ register int wfd;
+ register int i;
+ struct utmp utmp;
+
+ if (!resource.utmpInhibit && added_utmp_entry &&
+ (!am_slave && tslot > 0 && (wfd = open(etc_utmp, O_WRONLY)) >= 0)){
+ memset((char *)&utmp, 0, sizeof(struct utmp));
+ lseek(wfd, (long)(tslot * sizeof(struct utmp)), 0);
+ write(wfd, (char *)&utmp, sizeof(struct utmp));
+ close(wfd);
+#ifdef WTMP
+ if (term->misc.login_shell &&
+ (wfd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
+ (void) strncpy(utmp.ut_line, ttydev +
+ sizeof("/dev"), sizeof (utmp.ut_line));
+ time(&utmp.ut_time);
+ i = write(wfd, (char *)&utmp, sizeof(struct utmp));
+ i = close(wfd);
+ }
+#endif /* WTMP */
+ }
+#endif /* USE_SYSV_UTMP */
+#endif /* UTMP */
+ close(pty); /* close explicitly to avoid race with slave side */
+#ifdef ALLOWLOGGING
+ if(screen->logging)
+ CloseLog(screen);
+#endif
+
+ if (!am_slave) {
+ /* restore ownership of tty and pty */
+ chown (ttydev, 0, 0);
+#ifndef sgi
+ chown (ptydev, 0, 0);
+#endif /* !sgi */
+
+ /* restore modes of tty and pty */
+ chmod (ttydev, 0666);
+#ifndef sgi
+ chmod (ptydev, 0666);
+#endif /* !sgi */
+ }
+ exit(n);
+ SIGNAL_RETURN;
+}
+
+/* ARGSUSED */
+resize(screen, TermName, oldtc, newtc)
+TScreen *screen;
+char *TermName;
+register char *oldtc, *newtc;
+{
+#ifndef USE_SYSV_ENVVARS
+ register char *ptr1, *ptr2;
+ register int i;
+ register int li_first = 0;
+ register char *temp;
+
+ if ((ptr1 = strindex (oldtc, "co#")) == NULL){
+ strcat (oldtc, "co#80:");
+ ptr1 = strindex (oldtc, "co#");
+ }
+ if ((ptr2 = strindex (oldtc, "li#")) == NULL){
+ strcat (oldtc, "li#24:");
+ ptr2 = strindex (oldtc, "li#");
+ }
+ if(ptr1 > ptr2) {
+ li_first++;
+ temp = ptr1;
+ ptr1 = ptr2;
+ ptr2 = temp;
+ }
+ ptr1 += 3;
+ ptr2 += 3;
+ strncpy (newtc, oldtc, i = ptr1 - oldtc);
+ newtc += i;
+ sprintf (newtc, "%d", li_first ? screen->max_row + 1 :
+ screen->max_col + 1);
+ newtc += strlen(newtc);
+ ptr1 = strchr(ptr1, ':');
+ strncpy (newtc, ptr1, i = ptr2 - ptr1);
+ newtc += i;
+ sprintf (newtc, "%d", li_first ? screen->max_col + 1 :
+ screen->max_row + 1);
+ ptr2 = strchr(ptr2, ':');
+ strcat (newtc, ptr2);
+#endif /* USE_SYSV_ENVVARS */
+}
+
+/*
+ * 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()
+{
+#ifdef USE_POSIX_WAIT
+ pid_t pid;
+
+ pid = waitpid(-1, NULL, WNOHANG);
+#else /* USE_POSIX_WAIT */
+#if 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)) */
+ /* union wait status; */ int status;
+ register int pid;
+
+ pid = wait3 (&status, WNOHANG, (struct rusage *)NULL);
+#endif /* defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP) */
+#endif /* USE_POSIX_WAIT else */
+
+ return pid;
+}
+
+/* ARGSUSED */
+static SIGNAL_T reapchild (n)
+ int n;
+{
+ 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
+ Cleanup (0);
+ }
+ } while ( (pid=nonblocking_wait()) > 0);
+
+ SIGNAL_RETURN;
+}
+
+/* VARARGS1 */
+consolepr(fmt,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9)
+char *fmt;
+{
+ extern char *SysErrorMsg();
+ int oerrno;
+ int f;
+ char buf[ BUFSIZ ];
+
+ oerrno = errno;
+ strcpy(buf, "new-xgterm: ");
+ sprintf(buf+strlen(buf), fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
+ strcat(buf, ": ");
+ strcat(buf, SysErrorMsg (oerrno));
+ strcat(buf, "\n");
+ f = open("/dev/console",O_WRONLY);
+ write(f, buf, strlen(buf));
+ close(f);
+#ifdef TIOCNOTTY
+ if ((f = open("/dev/tty", 2)) >= 0) {
+ ioctl(f, TIOCNOTTY, (char *)NULL);
+ close(f);
+ }
+#endif /* TIOCNOTTY */
+}
+
+
+remove_termcap_entry (buf, str)
+ char *buf;
+ char *str;
+{
+ register char *strinbuf;
+
+ strinbuf = strindex (buf, str);
+ if (strinbuf) {
+ register char *colonPtr = strchr(strinbuf+1, ':');
+ if (colonPtr) {
+ while (*colonPtr) {
+ *strinbuf++ = *colonPtr++; /* copy down */
+ }
+ *strinbuf = '\0';
+ } else {
+ strinbuf[1] = '\0';
+ }
+ }
+ return 0;
+}
+
+/*
+ * 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 (s, modelist)
+ char *s;
+ struct _xttymodes *modelist;
+{
+ struct _xttymodes *mp;
+ int c;
+ int count = 0;
+
+ while (1) {
+ while (*s && isascii(*s) && isspace(*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(*s) && isspace(*s)) s++;
+ if (!*s) return -1;
+
+ if (*s == '^') {
+ s++;
+ c = ((*s == '?') ? 0177 : *s & 31); /* keep control bits */
+ } else {
+ c = *s;
+ }
+ mp->value = c;
+ mp->set = 1;
+ count++;
+ s++;
+ }
+}
+
+
+int GetBytesAvailable (fd)
+ int fd;
+{
+#ifdef FIONREAD
+ static long arg;
+ ioctl (fd, FIONREAD, (char *) &arg);
+ return (int) arg;
+#else
+#ifdef FIORDCK
+ return (ioctl (fd, FIORDCHK, NULL));
+#else
+ struct pollfd pollfds[1];
+
+ pollfds[0].fd = fd;
+ pollfds[0].events = POLLIN;
+ return poll (pollfds, 1, 0);
+#endif
+#endif
+}
+
+/* Utility function to try to hide system differences from
+ everybody who used to call killpg() */
+
+int
+kill_process_group(pid, sig)
+ int pid;
+ int sig;
+{
+#ifndef X_NOT_POSIX
+ return kill (-pid, sig);
+#else
+#if defined(SVR4) || defined(SYSV)
+ return kill (-pid, sig);
+#else
+ return killpg (pid, sig);
+#endif
+#endif
+}
diff --git a/vendor/x11iraf/xgterm/main.h b/vendor/x11iraf/xgterm/main.h
new file mode 100644
index 00000000..59d30407
--- /dev/null
+++ b/vendor/x11iraf/xgterm/main.h
@@ -0,0 +1,31 @@
+/*
+ * $XConsortium: main.h,v 1.5 91/02/06 16:00:15 gildea 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.
+ */
+
+#define DEFFONT "fixed"
+#define DEFBOLDFONT NULL /* no bold font uses overstriking */
+#define DEFBORDER 2
+#define DEFBORDERWIDTH 2
diff --git a/vendor/x11iraf/xgterm/menu.c b/vendor/x11iraf/xgterm/menu.c
new file mode 100644
index 00000000..63c7e619
--- /dev/null
+++ b/vendor/x11iraf/xgterm/menu.c
@@ -0,0 +1,1313 @@
+/* $XConsortium: menu.c,v 1.63 94/04/17 20:23:30 gildea Exp $ */
+/*
+
+Copyright (c) 1989 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.
+
+*/
+
+#include "ptyx.h"
+#include "data.h"
+#include "menu.h"
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+#include <X11/Xmu/CharSet.h>
+#include <X11/Xaw/SimpleMenu.h>
+#include <X11/Xaw/SmeBSB.h>
+#include <X11/Xaw/SmeLine.h>
+#include <stdio.h>
+#include <signal.h>
+
+extern void FindFontSelection();
+
+Arg menuArgs[2] = {{ XtNleftBitmap, (XtArgVal) 0 },
+ { XtNsensitive, (XtArgVal) 0 }};
+
+void do_hangup();
+
+static void do_securekbd(), do_allowsends(), do_visualbell(),
+#ifdef ALLOWLOGGING
+ do_logging(),
+#endif
+ do_redraw(), do_suspend(), do_continue(), do_interrupt(),
+ do_terminate(), do_kill(), do_quit(), do_scrollbar(), do_jumpscroll(),
+ do_reversevideo(), do_autowrap(), do_reversewrap(), do_autolinefeed(),
+ do_appcursor(), do_appkeypad(), do_scrollkey(), do_scrollttyoutput(),
+ do_allow132(), do_cursesemul(), do_marginbell(), do_altscreen(),
+ do_softreset(), do_hardreset(), do_clearsavedlines(),
+ do_vthide(), do_vtshow(), do_vtmode(), do_vtfont(),
+ do_gioenable(), do_tekshow(), do_tekmode(), do_tekpage(),
+ do_tekreset(), do_tekcopy(), do_tekhide(), do_colortext();
+
+
+/*
+ * The order entries MUST match the values given in menu.h
+ */
+MenuEntry mainMenuEntries[] = {
+ { "securekbd", do_securekbd, NULL }, /* 0 */
+ { "allowsends", do_allowsends, NULL }, /* 1 */
+#ifdef ALLOWLOGGING
+ { "logging", do_logging, NULL }, /* 2 */
+#endif
+ { "redraw", do_redraw, NULL }, /* 3 */
+ { "line1", NULL, NULL }, /* 4 */
+ { "suspend", do_suspend, NULL }, /* 5 */
+ { "continue", do_continue, NULL }, /* 6 */
+ { "interrupt", do_interrupt, NULL }, /* 7 */
+ { "hangup", do_hangup, NULL }, /* 8 */
+ { "terminate", do_terminate, NULL }, /* 9 */
+ { "kill", do_kill, NULL }, /* 10 */
+ { "line2", NULL, NULL }, /* 11 */
+ { "quit", do_quit, NULL }}; /* 12 */
+
+MenuEntry vtMenuEntries[] = {
+ { "scrollbar", do_scrollbar, NULL }, /* 0 */
+ { "jumpscroll", do_jumpscroll, NULL }, /* 1 */
+ { "reversevideo", do_reversevideo, NULL }, /* 2 */
+ { "colortext", do_colortext, NULL }, /* 3 */
+ { "line1", NULL, NULL }, /* 4 */
+ { "gioenable", do_gioenable, NULL }, /* 5 */
+ { "tekshow", do_tekshow, NULL }, /* 6 */
+ { "tekmode", do_tekmode, NULL }, /* 7 */
+ { "tekreset", do_tekreset, NULL }, /* 8 */
+ { "vthide", do_vthide, NULL }, /* 9 */
+ { "line2", NULL, NULL }, /* 10 */
+ { "autowrap", do_autowrap, NULL }, /* 11 */
+ { "reversewrap", do_reversewrap, NULL }, /* 12 */
+ { "autolinefeed", do_autolinefeed, NULL }, /* 13 */
+ { "appcursor", do_appcursor, NULL }, /* 14 */
+ { "appkeypad", do_appkeypad, NULL }, /* 15 */
+ { "scrollkey", do_scrollkey, NULL }, /* 16 */
+ { "scrollttyoutput",do_scrollttyoutput, NULL }, /* 17 */
+ { "allow132", do_allow132, NULL }, /* 18 */
+ { "cursesemul", do_cursesemul, NULL }, /* 19 */
+ { "visualbell", do_visualbell, NULL }, /* 20 */
+ { "marginbell", do_marginbell, NULL }, /* 21 */
+ { "altscreen", do_altscreen, NULL }, /* 22 */
+ { "line3", NULL, NULL }, /* 23 */
+ { "softreset", do_softreset, NULL }, /* 24 */
+ { "hardreset", do_hardreset, NULL }, /* 25 */
+ { "clearsavedlines",do_clearsavedlines, NULL }}; /* 26 */
+
+MenuEntry fontMenuEntries[] = {
+ { "fontdefault", do_vtfont, NULL }, /* 0 */
+ { "font1", do_vtfont, NULL }, /* 1 */
+ { "font2", do_vtfont, NULL }, /* 2 */
+ { "font3", do_vtfont, NULL }, /* 3 */
+ { "font4", do_vtfont, NULL }, /* 4 */
+ { "font5", do_vtfont, NULL }, /* 5 */
+ { "font6", do_vtfont, NULL }, /* 6 */
+ { "fontescape", do_vtfont, NULL }, /* 7 */
+ { "fontsel", do_vtfont, NULL }}; /* 8 */
+ /* this should match NMENUFONTS in ptyx.h */
+
+MenuEntry tekMenuEntries[] = {
+ { "tekpage", do_tekpage, NULL }, /* 0 */
+ { "tekhide", do_tekhide, NULL }, /* 1 */
+ { "vtshow", do_vtshow, NULL }, /* 2 */
+ { "tekreset", do_tekreset, NULL }}; /* 3 */
+
+static Widget create_menu();
+extern Widget toplevel;
+
+/*
+ * 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
+};
+
+
+/*
+ * public interfaces
+ */
+
+/* ARGSUSED */
+static Bool domenu (w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* mainMenu, vtMenu, or tekMenu */
+ Cardinal *param_count; /* 0 or 1 */
+{
+ TScreen *screen = &term->screen;
+ Widget ww;
+
+ if (*param_count != 1) {
+ XBell (XtDisplay(w), 0);
+ return False;
+ }
+
+ switch (params[0][0]) {
+ case 'm':
+ if (!screen->mainMenu) {
+ screen->mainMenu = create_menu (term, toplevel, "mainMenu",
+ mainMenuEntries,
+ XtNumber(mainMenuEntries));
+ update_securekbd();
+ update_allowsends();
+#ifdef ALLOWLOGGING
+ update_logging();
+#endif
+#ifndef SIGTSTP
+ set_sensitivity (screen->mainMenu,
+ mainMenuEntries[mainMenu_suspend].widget, FALSE);
+#endif
+#ifndef SIGCONT
+ set_sensitivity (screen->mainMenu,
+ mainMenuEntries[mainMenu_continue].widget, FALSE);
+#endif
+ }
+ break;
+
+ case 'v':
+ if (!screen->vtMenu) {
+ screen->vtMenu = create_menu (term, toplevel, "vtMenu",
+ vtMenuEntries,
+ XtNumber(vtMenuEntries));
+ /* and turn off the alternate screen entry */
+ set_altscreen_sensitivity (FALSE);
+ update_scrollbar();
+ update_jumpscroll();
+ update_reversevideo();
+ update_colortext();
+ update_autowrap();
+ update_reversewrap();
+ update_autolinefeed();
+ update_appcursor();
+ update_appkeypad();
+ update_scrollkey();
+ update_scrollttyoutput();
+ update_allow132();
+ update_cursesemul();
+ update_visualbell();
+ update_marginbell();
+ update_gioenable();
+ update_vttekmode();
+ update_tekshow();
+ update_tekreset();
+ update_vtshow();
+ set_vthide_sensitivity();
+ set_tekhide_sensitivity();
+ set_tekreset_sensitivity();
+ }
+
+ /* Update tekshow entry to reflect current graphics application. */
+ if (ww = vtMenuEntries[vtMenu_tekshow].widget) {
+ char *ip, *op, *start;
+ char label[128];
+
+ XtVaGetValues (ww, XtNlabel, &ip, NULL);
+ for (op=label, start=NULL; *op = *ip; op++, ip++)
+ if (*op == '(')
+ start = isspace(*(op-1)) ? op - 1 : op;
+ if (!start)
+ start = label + strlen(label);
+
+ op = start;
+ if (gt_status()) {
+ *op++ = ' ';
+ *op++ = '(';
+ for (ip=gtermio_appname; *ip; )
+ *op++ = *ip++;
+ *op++ = ')';
+ }
+ *op = '\0';
+
+ XtVaSetValues (ww, XtNlabel, label, NULL);
+ }
+ break;
+
+ case 'f':
+ if (!screen->fontMenu) {
+ screen->fontMenu = create_menu (term, toplevel, "fontMenu",
+ fontMenuEntries,
+ NMENUFONTS);
+ set_menu_font (True);
+ set_sensitivity (screen->fontMenu,
+ fontMenuEntries[fontMenu_fontescape].widget,
+ (screen->menu_font_names[fontMenu_fontescape]
+ ? TRUE : FALSE));
+ }
+ FindFontSelection (NULL, True);
+ set_sensitivity (screen->fontMenu,
+ fontMenuEntries[fontMenu_fontsel].widget,
+ (screen->menu_font_names[fontMenu_fontsel]
+ ? TRUE : FALSE));
+ break;
+
+ case 't':
+ if (!screen->tekMenu) {
+ screen->tekMenu = create_menu (w, gtermio_toplevel, "tekMenu",
+ tekMenuEntries,
+ XtNumber(tekMenuEntries));
+ set_vthide_sensitivity();
+ set_tekhide_sensitivity();
+ set_tekreset_sensitivity();
+ update_vttekmode();
+ update_tekshow();
+ update_tekreset();
+ update_vtshow();
+ }
+ break;
+
+ default:
+ XBell (XtDisplay(w), 0);
+ return False;
+ }
+
+ return True;
+}
+
+void HandleCreateMenu (w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* mainMenu, vtMenu, or tekMenu */
+ Cardinal *param_count; /* 0 or 1 */
+{
+ (void) domenu (w, event, params, param_count);
+}
+
+void HandlePopupMenu (w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params; /* mainMenu, vtMenu, or tekMenu */
+ Cardinal *param_count; /* 0 or 1 */
+{
+ if (domenu (w, event, params, param_count)) {
+ XtCallActionProc (w, "XawPositionSimpleMenu", event, params, 1);
+ XtCallActionProc (w, "MenuPopup", event, params, 1);
+ }
+}
+
+
+/*
+ * private interfaces - keep out!
+ */
+
+/*
+ * create_menu - create a popup shell and stuff the menu into it.
+ */
+
+static Widget create_menu (w, toplevelw, name, entries, nentries)
+ Widget w;
+ Widget toplevelw;
+ char *name;
+ struct _MenuEntry *entries;
+ int nentries;
+{
+ TScreen *screen = &term->screen;
+ static XtCallbackRec cb[2] = { { NULL, NULL }, { NULL, NULL }};
+ static Arg arg = { XtNcallback, (XtArgVal) cb };
+ Arg args[10];
+ int nargs;
+ Widget m;
+
+ if (XtDisplay(w) == gtermio_display) {
+ if (screen->tek_menu_item_bitmap == None) {
+ screen->tek_menu_item_bitmap =
+ XCreateBitmapFromData (XtDisplay(w),
+ RootWindowOfScreen(XtScreen(w)),
+ (char *)check_bits, check_width, check_height);
+ }
+ } else {
+ if (screen->menu_item_bitmap == None) {
+ screen->menu_item_bitmap =
+ XCreateBitmapFromData (XtDisplay(w),
+ RootWindowOfScreen(XtScreen(w)),
+ (char *)check_bits, check_width, check_height);
+ }
+ }
+
+ m = XtCreatePopupShell (name, simpleMenuWidgetClass, toplevelw, NULL, 0);
+
+ /* The following produces a double line to separate the menu title from
+ * it's items. It's not in the R6 xterm code but I left it here because
+ * it's a nice effect.
+ */
+ nargs = 0;
+ XtSetArg (args[nargs], XtNheight, 2);
+ nargs++;
+ XtCreateManagedWidget ("tline1", smeLineObjectClass, m, args, nargs);
+ XtCreateManagedWidget ("tline2", smeLineObjectClass, m, args, nargs);
+
+ 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;
+}
+
+init_menu (menu)
+ char *menu;
+{
+ register TScreen *screen = &term->screen;
+ register int i;
+
+ switch (menu[0]) {
+ case 'f':
+ screen->fontMenu = NULL;
+ for (i=0; i < XtNumber(fontMenuEntries); i++)
+ fontMenuEntries[i].widget = NULL;
+ break;
+ case 'm':
+ screen->mainMenu = NULL;
+ for (i=0; i < XtNumber(mainMenuEntries); i++)
+ mainMenuEntries[i].widget = NULL;
+ break;
+ case 'v':
+ screen->vtMenu = NULL;
+ for (i=0; i < XtNumber(vtMenuEntries); i++)
+ vtMenuEntries[i].widget = NULL;
+ break;
+ case 't':
+ screen->tekMenu = NULL;
+ for (i=0; i < XtNumber(tekMenuEntries); i++)
+ tekMenuEntries[i].widget = NULL;
+ break;
+ }
+}
+
+/* ARGSUSED */
+static void handle_send_signal (gw, sig)
+ Widget gw;
+ int sig;
+{
+ register TScreen *screen = &term->screen;
+
+ if (screen->pid > 1) kill_process_group (screen->pid, sig);
+}
+
+
+/*
+ * action routines
+ */
+
+/* ARGSUSED */
+void DoSecureKeyboard (time)
+ Time time;
+{
+ do_securekbd (term->screen.mainMenu, NULL, NULL);
+}
+
+static void do_securekbd (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+ Time time = CurrentTime; /* XXX - wrong */
+
+ if (screen->grabbedKbd) {
+ XUngrabKeyboard (screen->display, time);
+ ReverseVideo (term);
+ screen->grabbedKbd = FALSE;
+ } else {
+ if (XGrabKeyboard (screen->display, term->core.window,
+ True, GrabModeAsync, GrabModeAsync, time)
+ != GrabSuccess) {
+ XBell (screen->display, 100);
+ } else {
+ ReverseVideo (term);
+ screen->grabbedKbd = TRUE;
+ }
+ }
+ update_securekbd();
+}
+
+
+static void do_allowsends (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ /*
+ screen->allowSendEvents = !screen->allowSendEvents;
+ update_allowsends ();
+ */
+}
+
+static void do_visualbell (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ screen->visualbell = !screen->visualbell;
+ update_visualbell();
+}
+
+#ifdef ALLOWLOGGING
+static void do_logging (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ if (screen->logging) {
+ CloseLog (screen);
+ } else {
+ StartLog (screen);
+ }
+ /* update_logging done by CloseLog and StartLog */
+}
+#endif
+
+static void do_redraw (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ Redraw ();
+}
+
+
+/*
+ * 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 (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+#ifdef SIGTSTP
+ handle_send_signal (gw, SIGTSTP);
+#endif
+}
+
+/* ARGSUSED */
+static void do_continue (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+#ifdef SIGCONT
+ handle_send_signal (gw, SIGCONT);
+#endif
+}
+
+/* ARGSUSED */
+static void do_interrupt (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_send_signal (gw, SIGINT);
+}
+
+/* ARGSUSED */
+void do_hangup (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_send_signal (gw, SIGHUP);
+}
+
+/* ARGSUSED */
+static void do_terminate (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_send_signal (gw, SIGTERM);
+}
+
+/* ARGSUSED */
+static void do_kill (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_send_signal (gw, SIGKILL);
+}
+
+static void do_quit (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ Cleanup (0);
+}
+
+
+
+/*
+ * vt menu callbacks
+ */
+
+static void do_scrollbar (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ if (screen->scrollbar) {
+ ScrollBarOff (screen);
+ } else {
+ ScrollBarOn (term, FALSE, FALSE);
+ }
+ update_scrollbar();
+}
+
+
+static void do_jumpscroll (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register 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 (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ term->flags ^= REVERSE_VIDEO;
+ ReverseVideo (term);
+ /* update_reversevideo done in ReverseVideo */
+}
+
+
+static void do_colortext (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ term->misc.dynamicColors = !term->misc.dynamicColors;
+ update_colortext ();
+ Redraw ();
+}
+
+
+static void do_autowrap (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ term->flags ^= WRAPAROUND;
+ update_autowrap();
+}
+
+
+static void do_reversewrap (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ term->flags ^= REVERSEWRAP;
+ update_reversewrap();
+}
+
+
+static void do_autolinefeed (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ term->flags ^= LINEFEED;
+ update_autolinefeed();
+}
+
+
+static void do_appcursor (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ term->keyboard.flags ^= CURSOR_APL;
+ update_appcursor();
+}
+
+
+static void do_appkeypad (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ term->keyboard.flags ^= KYPD_APL;
+ update_appkeypad();
+}
+
+
+static void do_scrollkey (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ screen->scrollkey = !screen->scrollkey;
+ update_scrollkey();
+}
+
+
+static void do_scrollttyoutput (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ screen->scrollttyoutput = !screen->scrollttyoutput;
+ update_scrollttyoutput();
+}
+
+
+static void do_allow132 (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ screen->c132 = !screen->c132;
+ update_allow132();
+}
+
+
+static void do_cursesemul (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ screen->curses = !screen->curses;
+ update_cursesemul();
+}
+
+
+static void do_marginbell (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ if (!(screen->marginbell = !screen->marginbell)) screen->bellarmed = -1;
+ update_marginbell();
+}
+
+
+static void do_altscreen (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ /* do nothing for now; eventually, will want to flip screen */
+}
+
+
+static void do_softreset (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ VTReset (FALSE);
+}
+
+
+static void do_hardreset (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ gt_reset();
+ VTReset (TRUE); /* does a longjmp */
+}
+
+
+static void do_clearsavedlines (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ screen->savedlines = 0;
+ ScrollBarDrawThumb(screen->scrollWidget);
+ VTReset (TRUE); /* does a longjmp */
+}
+
+/* ARGSUSED */
+static void do_gioenable (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ gt_enable (!gt_enable(2));
+ update_gioenable();
+}
+
+/* ARGSUSED */
+static void do_tekmode (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ switch_modes (gt_tekmode(2)); /* switch to tek mode */
+}
+
+static void handle_tekshow (gw, allowswitch)
+ Widget gw;
+ Bool allowswitch;
+{
+ register TScreen *screen = &term->screen;
+
+ if (!gt_activated()) { /* not showing, turn on */
+ set_tek_visibility (TRUE);
+ } else if (screen->Vshow || allowswitch) { /* is showing, turn off */
+ set_tek_visibility (FALSE);
+ } else
+ Bell();
+}
+
+/* ARGSUSED */
+static void do_tekshow (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_tekshow (gw, True);
+}
+
+/* ARGSUSED */
+static void do_tekonoff (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_tekshow (gw, False);
+}
+
+
+/* ARGSUSED */
+static void do_vthide (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ hide_vt_window();
+}
+
+
+/*
+ * vtfont menu
+ */
+
+static void do_vtfont (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ char *entryname = (char *) closure;
+ int i;
+
+ for (i = 0; i < NMENUFONTS; i++) {
+ if (strcmp (entryname, fontMenuEntries[i].name) == 0) {
+ SetVTFont (i, True, NULL, NULL);
+ return;
+ }
+ }
+ Bell();
+}
+
+
+/*
+ * tek menu
+ */
+
+
+static void do_tekpage (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ gt_clear();
+}
+
+
+static void do_tekreset (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ gt_reset();
+ set_vthide_sensitivity();
+ set_tekhide_sensitivity();
+ set_tekreset_sensitivity();
+ update_vttekmode();
+ update_tekshow();
+ update_tekreset();
+ update_vtshow();
+}
+
+
+static void do_tekcopy (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ /* TekCopy (); */
+}
+
+
+static void handle_vtshow (gw, allowswitch)
+ Widget gw;
+ Bool allowswitch;
+{
+ register TScreen *screen = &term->screen;
+
+ if (!screen->Vshow) { /* not showing, turn on */
+ set_vt_visibility (TRUE);
+ } else if (gt_activated() || allowswitch) { /* is showing, turn off */
+ set_vt_visibility (FALSE);
+ end_vt_mode ();
+ } else
+ Bell();
+}
+
+static void do_vtshow (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_vtshow (gw, True);
+}
+
+static void do_vtonoff (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ handle_vtshow (gw, False);
+}
+
+static void do_vtmode (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ register TScreen *screen = &term->screen;
+
+ switch_modes (gt_activated()); /* switch to vt, or from */
+}
+
+
+/* ARGSUSED */
+static void do_tekhide (gw, closure, data)
+ Widget gw;
+ caddr_t closure, data;
+{
+ gt_deactivate();
+ set_vthide_sensitivity();
+ set_tekhide_sensitivity();
+ set_tekreset_sensitivity();
+ update_vttekmode();
+ update_tekshow();
+ update_tekreset();
+ update_vtshow();
+}
+
+
+
+/*
+ * public handler routines
+ */
+
+static void handle_toggle (proc, var, params, nparams, w, closure, data)
+ void (*proc)();
+ int var;
+ String *params;
+ Cardinal nparams;
+ Widget w;
+ caddr_t closure, 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();
+ break;
+
+ case -1:
+ (*proc) (w, closure, data);
+ break;
+
+ case 0:
+ if (var) (*proc) (w, closure, data);
+ else Bell();
+ break;
+
+ case 1:
+ if (!var) (*proc) (w, closure, data);
+ else Bell();
+ break;
+ }
+ return;
+}
+
+void HandleAllowSends(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ /* Currently since we use Xt event processing we cannot easily disable
+ * sendevents as is done in xevent().
+ *
+ handle_toggle (do_allowsends, (int) term->screen.allowSendEvents,
+ params, *param_count, w, NULL, NULL);
+ */
+}
+
+void HandleSetVisualBell(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_visualbell, (int) term->screen.visualbell,
+ params, *param_count, w, NULL, NULL);
+}
+
+#ifdef ALLOWLOGGING
+void HandleLogging(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_logging, (int) term->screen.logging,
+ params, *param_count, w, NULL, NULL);
+}
+#endif
+
+/* ARGSUSED */
+void HandleRedraw(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_redraw(w, NULL, NULL);
+}
+
+/* ARGSUSED */
+void HandleSendSignal(w, event, params, param_count)
+ Widget w;
+ XEvent *event; /* unused */
+ String *params;
+ Cardinal *param_count;
+{
+ 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 },
+ };
+
+ 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();
+}
+
+/* ARGSUSED */
+void HandleQuit(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_quit(w, NULL, NULL);
+}
+
+void HandleScrollbar(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_scrollbar, (int) term->screen.scrollbar,
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleJumpscroll(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_jumpscroll, (int) term->screen.jumpscroll,
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleReverseVideo(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_reversevideo, (int) (term->flags & REVERSE_VIDEO),
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleAutoWrap(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_autowrap, (int) (term->flags & WRAPAROUND),
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleReverseWrap(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_reversewrap, (int) (term->flags & REVERSEWRAP),
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleAutoLineFeed(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_autolinefeed, (int) (term->flags & LINEFEED),
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleAppCursor(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_appcursor, (int) (term->keyboard.flags & CURSOR_APL),
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleAppKeypad(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_appkeypad, (int) (term->keyboard.flags & KYPD_APL),
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleScrollKey(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_scrollkey, (int) term->screen.scrollkey,
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleScrollTtyOutput(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_scrollttyoutput, (int) term->screen.scrollttyoutput,
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleAllow132(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_allow132, (int) term->screen.c132,
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleCursesEmul(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_cursesemul, (int) term->screen.curses,
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleMarginBell(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ handle_toggle (do_marginbell, (int) term->screen.marginbell,
+ params, *param_count, w, NULL, NULL);
+}
+
+void HandleAltScreen(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ /* eventually want to see if sensitive or not */
+ handle_toggle (do_altscreen, (int) term->screen.alternate,
+ params, *param_count, w, NULL, NULL);
+}
+
+/* ARGSUSED */
+void HandleSoftReset(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_softreset(w, NULL, NULL);
+}
+
+/* ARGSUSED */
+void HandleHardReset(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_hardreset(w, NULL, NULL);
+}
+
+/* ARGSUSED */
+void HandleClearSavedLines(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_clearsavedlines(w, NULL, NULL);
+}
+
+void HandleSetTerminalType(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ if (*param_count == 1) {
+ switch (params[0][0]) {
+ case 'v': case 'V':
+ if (gt_activated()) do_vtmode (w, NULL, NULL);
+ break;
+ case 't': case 'T':
+ if (!gt_activated()) do_tekmode (w, NULL, NULL);
+ break;
+ default:
+ Bell();
+ }
+ } else {
+ Bell();
+ }
+}
+
+void HandleVisibility(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ if (*param_count == 2) {
+ switch (params[0][0]) {
+ case 'v': case 'V':
+ handle_toggle (do_vtonoff, (int) term->screen.Vshow,
+ params+1, (*param_count) - 1, w, NULL, NULL);
+ break;
+ case 't': case 'T':
+ handle_toggle (do_tekonoff, (int) gt_activated(),
+ params+1, (*param_count) - 1, w, NULL, NULL);
+ break;
+ default:
+ Bell();
+ }
+ } else {
+ Bell();
+ }
+}
+
+/* ARGSUSED */
+void HandleTekPage(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_tekpage(w, NULL, NULL);
+}
+
+/* ARGSUSED */
+void HandleTekReset(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_tekreset(w, NULL, NULL);
+}
+
+/* ARGSUSED */
+void HandleTekCopy(w, event, params, param_count)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *param_count;
+{
+ do_tekcopy(w, NULL, NULL);
+}
diff --git a/vendor/x11iraf/xgterm/menu.h b/vendor/x11iraf/xgterm/menu.h
new file mode 100644
index 00000000..4b7d01e3
--- /dev/null
+++ b/vendor/x11iraf/xgterm/menu.h
@@ -0,0 +1,311 @@
+/* $XConsortium: menu.h,v 1.24 93/02/25 17:21:31 gildea Exp $ */
+
+/* Copyright 1989 Massachusetts Institute of Technology */
+
+/*
+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, and that the name of M.I.T. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission. M.I.T. makes no representations about the
+suitability of this software for any purpose. It is provided "as is"
+without express or implied warranty.
+*/
+
+typedef struct _MenuEntry {
+ char *name;
+ void (*function)();
+ Widget widget;
+} MenuEntry;
+
+extern MenuEntry mainMenuEntries[], vtMenuEntries[], tekMenuEntries[];
+extern MenuEntry fontMenuEntries[];
+extern Arg menuArgs[];
+
+extern void HandleAllowSends();
+extern void HandleSetVisualBell();
+#ifdef ALLOWLOGGING
+extern void HandleLogging();
+#endif
+extern void HandleRedraw();
+extern void HandleSendSignal();
+extern void HandleQuit();
+extern void HandleScrollbar();
+extern void HandleJumpscroll();
+extern void HandleReverseVideo();
+extern void HandleColorText();
+extern void HandleAutoWrap();
+extern void HandleReverseWrap();
+extern void HandleAutoLineFeed();
+extern void HandleAppCursor();
+extern void HandleAppKeypad();
+extern void HandleScrollKey();
+extern void HandleScrollTtyOutput();
+extern void HandleAllow132();
+extern void HandleCursesEmul();
+extern void HandleMarginBell();
+extern void HandleAltScreen();
+extern void HandleSoftReset();
+extern void HandleHardReset();
+extern void HandleClearSavedLines();
+extern void HandleSetTerminalType();
+extern void HandleVisibility();
+extern void HandleTekPage();
+extern void HandleTekReset();
+extern void HandleTekCopy();
+extern void DoSecureKeyboard();
+
+/*
+ * The following definitions MUST match the order of entries given in
+ * the mainMenuEntries, vtMenuEntries, and tekMenuEntries arrays in menu.c.
+ */
+
+/*
+ * items in primary menu
+ */
+#define mainMenu_securekbd 0
+#define mainMenu_allowsends 1
+#ifdef ALLOWLOGGING
+#define mainMenu_logging 2
+#endif
+#define mainMenu_redraw 3
+#define mainMenu_line1 4
+#define mainMenu_suspend 5
+#define mainMenu_continue 6
+#define mainMenu_interrupt 7
+#define mainMenu_hangup 8
+#define mainMenu_terminate 9
+#define mainMenu_kill 10
+#define mainMenu_line2 11
+#define mainMenu_quit 12
+
+/*
+ * items in vt100 mode menu
+ */
+#define vtMenu_scrollbar 0
+#define vtMenu_jumpscroll 1
+#define vtMenu_reversevideo 2
+#define vtMenu_colortext 3
+#define vtMenu_line1 4
+#define vtMenu_gioenable 5
+#define vtMenu_tekshow 6
+#define vtMenu_tekmode 7
+#define vtMenu_tekreset 8
+#define vtMenu_vthide 9
+#define vtMenu_line2 10
+#define vtMenu_autowrap 11
+#define vtMenu_reversewrap 12
+#define vtMenu_autolinefeed 13
+#define vtMenu_appcursor 14
+#define vtMenu_appkeypad 15
+#define vtMenu_scrollkey 16
+#define vtMenu_scrollttyoutput 17
+#define vtMenu_allow132 18
+#define vtMenu_cursesemul 19
+#define vtMenu_visualbell 20
+#define vtMenu_marginbell 21
+#define vtMenu_altscreen 22
+#define vtMenu_line3 23
+#define vtMenu_softreset 24
+#define vtMenu_hardreset 25
+#define vtMenu_clearsavedlines 26
+
+/*
+ * items in vt100 font menu
+ */
+#define fontMenu_fontdefault 0
+#define fontMenu_font1 1
+#define fontMenu_font2 2
+#define fontMenu_font3 3
+#define fontMenu_font4 4
+#define fontMenu_font5 5
+#define fontMenu_font6 6
+#define fontMenu_lastBuiltin fontMenu_font6
+#define fontMenu_fontescape 7
+#define fontMenu_fontsel 8
+/* number of non-line items should match NMENUFONTS in ptyx.h */
+
+
+
+/*
+ * items in tek4014 mode menu
+ */
+#define tekMenu_tekpage 0
+#define tekMenu_tekhide 1
+#define tekMenu_vtshow 2
+#define tekMenu_tekreset 3
+
+
+/*
+ * macros for updating menus
+ */
+
+#define update_menu_item(w,mi,val) { if (mi) { \
+ menuArgs[0].value = (XtArgVal) ( \
+ (val) ? \
+ ((XtDisplay(w) == gtermio_display) ? \
+ term->screen.tek_menu_item_bitmap \
+ : term->screen.menu_item_bitmap) \
+ : None \
+ ); \
+ XtSetValues (mi, menuArgs, (Cardinal) 1); }}
+
+
+#define set_sensitivity(w,mi,val) { if (mi) { \
+ menuArgs[1].value = (XtArgVal) (val); \
+ XtSetValues (mi, menuArgs+1, (Cardinal) 1); }}
+
+
+
+/*
+ * there should be one of each of the following for each checkable item
+ */
+
+
+#define update_securekbd() \
+ update_menu_item (term->screen.mainMenu, \
+ mainMenuEntries[mainMenu_securekbd].widget, \
+ term->screen.grabbedKbd)
+
+#define update_allowsends() \
+ update_menu_item (term->screen.mainMenu, \
+ mainMenuEntries[mainMenu_allowsends].widget, \
+ term->screen.allowSendEvents)
+
+#ifdef ALLOWLOGGING
+#define update_logging() \
+ update_menu_item (term->screen.mainMenu, \
+ mainMenuEntries[mainMenu_logging].widget, \
+ term->screen.logging)
+#endif
+
+#define update_scrollbar() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_scrollbar].widget, \
+ term->screen.scrollbar)
+
+#define update_jumpscroll() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_jumpscroll].widget, \
+ term->screen.jumpscroll)
+
+#define update_reversevideo() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_reversevideo].widget, \
+ (term->flags & REVERSE_VIDEO))
+
+#define update_colortext() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_colortext].widget, \
+ term->misc.dynamicColors)
+
+#define update_autowrap() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_autowrap].widget, \
+ (term->flags & WRAPAROUND))
+
+#define update_reversewrap() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_reversewrap].widget, \
+ (term->flags & REVERSEWRAP))
+
+#define update_autolinefeed() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_autolinefeed].widget, \
+ (term->flags & LINEFEED))
+
+#define update_appcursor() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_appcursor].widget, \
+ (term->keyboard.flags & CURSOR_APL))
+
+#define update_appkeypad() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_appkeypad].widget, \
+ (term->keyboard.flags & KYPD_APL))
+
+#define update_scrollkey() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_scrollkey].widget, \
+ term->screen.scrollkey)
+
+#define update_scrollttyoutput() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_scrollttyoutput].widget, \
+ term->screen.scrollttyoutput)
+
+#define update_allow132() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_allow132].widget, \
+ term->screen.c132)
+
+#define update_cursesemul() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_cursesemul].widget, \
+ term->screen.curses)
+
+#define update_visualbell() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_visualbell].widget, \
+ term->screen.visualbell)
+
+#define update_marginbell() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_marginbell].widget, \
+ term->screen.marginbell)
+
+#define update_gioenable() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_gioenable].widget, \
+ gt_enable(2))
+
+#define update_tekshow() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_tekshow].widget, \
+ gt_activated())
+
+#define update_tekreset() \
+ set_sensitivity (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_tekreset].widget, \
+ gt_status())
+
+#define update_vttekmode() { \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_tekmode].widget, \
+ gt_tekmode(2)); }
+
+#define update_vtshow() \
+ update_menu_item (term->screen.tekMenu, \
+ tekMenuEntries[tekMenu_vtshow].widget, \
+ term->screen.Vshow)
+
+#define set_vthide_sensitivity() \
+ set_sensitivity (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_vthide].widget, \
+ gt_activated())
+
+#define set_tekhide_sensitivity() \
+ set_sensitivity (term->screen.tekMenu, \
+ tekMenuEntries[tekMenu_tekhide].widget, \
+ term->screen.Vshow)
+
+#define set_tekreset_sensitivity() \
+ set_sensitivity (term->screen.tekMenu, \
+ tekMenuEntries[tekMenu_tekreset].widget, \
+ term->screen.Vshow)
+
+#define update_altscreen() \
+ update_menu_item (term->screen.vtMenu, \
+ vtMenuEntries[vtMenu_altscreen].widget, \
+ term->screen.alternate)
+
+#define set_altscreen_sensitivity(val) \
+ set_sensitivity (term->screen.vtMenu,\
+ vtMenuEntries[vtMenu_altscreen].widget, (val))
+
+#define set_menu_font(val) \
+ update_menu_item (term->screen.fontMenu, \
+ fontMenuEntries[term->screen.menu_font_number].widget, \
+ (val))
diff --git a/vendor/x11iraf/xgterm/misc.c b/vendor/x11iraf/xgterm/misc.c
new file mode 100644
index 00000000..66d752ac
--- /dev/null
+++ b/vendor/x11iraf/xgterm/misc.c
@@ -0,0 +1,1530 @@
+/*
+ * $XConsortium: misc.c,v 1.102 94/03/28 18:27:08 gildea 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.
+ */
+
+#include "ptyx.h" /* X headers included here. */
+
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <ctype.h>
+#include <pwd.h>
+#include <errno.h>
+
+#include <X11/Xatom.h>
+#include <X11/cursorfont.h>
+
+#include <X11/Shell.h>
+#include <X11/Xmu/Error.h>
+#include <X11/Xmu/SysUtil.h>
+#include <X11/Xmu/WinUtil.h>
+
+#include "data.h"
+#include "error.h"
+#include "menu.h"
+#include "gtermio.h"
+
+extern jmp_buf VTend;
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+extern char *malloc();
+extern char *getenv();
+#endif
+
+static void DoSpecialEnterNotify();
+static void DoSpecialLeaveNotify();
+
+extern XtAppContext app_con;
+
+xevents()
+{
+ XEvent event;
+ XtInputMask input_mask;
+ register TScreen *screen = &term->screen;
+
+ 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 there's no XEvents, don't wait around...
+ */
+ if ((input_mask & XtIMXEvent) != XtIMXEvent)
+ return;
+ do {
+ if (waitingForTrackInfo)
+ 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 (event.type == EnterNotify &&
+ (event.xcrossing.window == XtWindow(XtParent(term))))
+ DoSpecialEnterNotify (&event.xcrossing);
+ else if (event.type == LeaveNotify &&
+ (event.xcrossing.window == XtWindow(XtParent(term))))
+ DoSpecialLeaveNotify (&event.xcrossing);
+
+ 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 (cursorindex, fg, bg)
+ int cursorindex; /* index into font */
+ unsigned long fg, bg; /* pixel value */
+{
+ register TScreen *screen = &term->screen;
+ Cursor c;
+ register Display *dpy = screen->display;
+
+ c = XCreateFontCursor (dpy, cursorindex);
+ if (c == (Cursor) 0) return (c);
+
+ recolor_cursor (c, fg, bg);
+ return (c);
+}
+
+/* ARGSUSED */
+void HandleKeyPressed(w, event, params, nparams)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *nparams;
+{
+ register TScreen *screen = &term->screen;
+
+#ifdef ACTIVEWINDOWINPUTONLY
+ if (w == (Widget)term)
+#endif
+ Input (&term->keyboard, screen, &event->xkey, False);
+}
+/* ARGSUSED */
+void HandleEightBitKeyPressed(w, event, params, nparams)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *nparams;
+{
+ register TScreen *screen = &term->screen;
+
+#ifdef ACTIVEWINDOWINPUTONLY
+ if (w == (Widget)term)
+#endif
+ Input (&term->keyboard, screen, &event->xkey, True);
+}
+
+/* ARGSUSED */
+void HandleStringEvent(w, event, params, nparams)
+ Widget w;
+ XEvent *event;
+ String *params;
+ Cardinal *nparams;
+{
+ register TScreen *screen = &term->screen;
+
+#ifdef ACTIVEWINDOWINPUTONLY
+ if (w != (Widget)term)
+ return;
+#endif
+
+ if (*nparams != 1) return;
+
+ if ((*params)[0] == '0' && (*params)[1] == 'x' && (*params)[2] != '\0') {
+ char c, *p, hexval[2];
+ hexval[0] = hexval[1] = 0;
+ for (p = *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, *params, strlen(*params));
+ }
+}
+
+static void DoSpecialEnterNotify (ev)
+ register XEnterWindowEvent *ev;
+{
+ register TScreen *screen = &term->screen;
+
+#ifdef ACTIVEWINDOWINPUTONLY
+ if (ev->window == (Widget)term)
+#endif
+ if (((ev->detail) != NotifyInferior) &&
+ ev->focus &&
+ !(screen->select & FOCUS))
+ selectwindow(screen, INWINDOW);
+}
+
+/*ARGSUSED*/
+void HandleEnterWindow(w, eventdata, event)
+Widget w;
+register XEnterWindowEvent *event;
+caddr_t eventdata;
+{
+ /* This code is necessary as xevent does not see all events anymore. */
+ XEvent *ev = (XEvent *) event;
+ if (ev->type == EnterNotify &&
+ (ev->xcrossing.window == XtWindow(XtParent(term))))
+ DoSpecialEnterNotify (&ev->xcrossing);
+}
+
+
+static void DoSpecialLeaveNotify (ev)
+ register XEnterWindowEvent *ev;
+{
+ register TScreen *screen = &term->screen;
+
+#ifdef ACTIVEWINDOWINPUTONLY
+ if (ev->window == (Widget)term)
+#endif
+ if (((ev->detail) != NotifyInferior) &&
+ ev->focus &&
+ !(screen->select & FOCUS))
+ unselectwindow(screen, INWINDOW);
+}
+
+
+/*ARGSUSED*/
+void HandleLeaveWindow(w, eventdata, event)
+Widget w;
+register XEnterWindowEvent *event;
+caddr_t eventdata;
+{
+ /* This code is necessary as xevent does not see all events anymore. */
+ XEvent *ev = (XEvent *) event;
+ if (ev->type == LeaveNotify &&
+ (ev->xcrossing.window == XtWindow(XtParent(term))))
+ DoSpecialLeaveNotify (&ev->xcrossing);
+}
+
+
+/*ARGSUSED*/
+void HandleFocusChange(w, eventdata, event)
+Widget w;
+register XFocusChangeEvent *event;
+caddr_t eventdata;
+{
+ register TScreen *screen = &term->screen;
+
+ if(event->type == FocusIn)
+ selectwindow(screen,
+ (event->detail == NotifyPointer) ? INWINDOW :
+ FOCUS);
+ else {
+ unselectwindow(screen,
+ (event->detail == NotifyPointer) ? INWINDOW :
+ FOCUS);
+ if (screen->grabbedKbd && (event->mode == NotifyUngrab)) {
+ XBell(screen->display, 100);
+ ReverseVideo(term);
+ screen->grabbedKbd = FALSE;
+ update_securekbd();
+ }
+ }
+}
+
+
+
+selectwindow(screen, flag)
+register TScreen *screen;
+register int flag;
+{
+#ifdef I18N
+ if (screen->xic)
+ XSetICFocus(screen->xic);
+#endif
+ if(screen->cursor_state &&
+ (screen->cursor_col != screen->cur_col ||
+ screen->cursor_row != screen->cur_row))
+ HideCursor();
+ screen->select |= flag;
+ if(screen->cursor_state)
+ ShowCursor();
+ return;
+}
+
+unselectwindow(screen, flag)
+register TScreen *screen;
+register int flag;
+{
+ if (screen->always_highlight) return;
+
+#ifdef I18N
+ if (screen->xic)
+ XUnsetICFocus(screen->xic);
+#endif
+ screen->select &= ~flag;
+ if(screen->cursor_state &&
+ (screen->cursor_col != screen->cur_col ||
+ screen->cursor_row != screen->cur_row))
+ HideCursor();
+ if(screen->cursor_state)
+ ShowCursor();
+}
+
+static long lastBellTime; /* in milliseconds */
+
+Bell()
+{
+ extern XgtermWidget term;
+ register TScreen *screen = &term->screen;
+ struct timeval curtime;
+ long now_msecs;
+
+ /* has enough time gone by that we are allowed to ring
+ the bell again? */
+ if(screen->bellSuppressTime) {
+ if(screen->bellInProgress) {
+ if (XtAppPending(app_con) ||
+ GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
+ xevents();
+ if(screen->bellInProgress) { /* even after new events? */
+ return;
+ }
+ }
+#ifdef X_GETTIMEOFDAY
+ X_GETTIMEOFDAY(&curtime);
+#else
+ gettimeofday(&curtime, NULL);
+#endif
+ 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
+ XBell(screen->display, 0);
+
+ 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 = (Widget) term;
+ XChangeProperty(XtDisplay(w), XtWindow(w),
+ XA_NOTICE, XA_NOTICE, 8, PropModeAppend, NULL, 0);
+ screen->bellInProgress = TRUE;
+ }
+}
+
+
+VisualBell()
+{
+ extern XgtermWidget term;
+ register TScreen *screen = &term->screen;
+ register Pixel xorPixel = screen->foreground ^ term->core.background_pixel;
+ XGCValues gcval;
+ GC visualGC;
+
+ gcval.function = GXxor;
+ gcval.foreground = xorPixel;
+ visualGC = XtGetGC((Widget)term, GCFunction+GCForeground, &gcval);
+ XFillRectangle(
+ screen->display,
+ VWindow(screen),
+ visualGC,
+ 0, 0,
+ (unsigned) FullWidth(screen),
+ (unsigned) FullHeight(screen));
+ XFlush(screen->display);
+ XFillRectangle(
+ screen->display,
+ VWindow(screen),
+ visualGC,
+ 0, 0,
+ (unsigned) FullWidth(screen),
+ (unsigned) FullHeight(screen));
+}
+
+/* ARGSUSED */
+void HandleBellPropertyChange(w, data, ev, more)
+ Widget w;
+ XtPointer data;
+ XEvent *ev;
+ Boolean *more;
+{
+ register TScreen *screen = &term->screen;
+
+ if (ev->xproperty.atom == XA_NOTICE) {
+ screen->bellInProgress = FALSE;
+ }
+}
+
+Redraw()
+{
+ extern XgtermWidget term;
+ register 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 (screen->scrollbar)
+ (*screen->scrollWidget->core.widget_class->core_class.expose) (
+ screen->scrollWidget, (XEvent *)&event, NULL);
+ }
+}
+
+#if defined(ALLOWLOGGING) || defined(DEBUG)
+
+#ifndef X_NOT_POSIX
+#define HAS_WAITPID
+#endif
+
+/*
+ * 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.
+ */
+void
+creat_as(uid, gid, pathname, mode)
+ int uid;
+ int gid;
+ char *pathname;
+ int mode;
+{
+ int fd;
+ int waited;
+ int pid;
+#ifndef HAS_WAITPID
+ int (*chldfunc)();
+
+ chldfunc = signal(SIGCHLD, SIG_DFL);
+#endif
+ pid = fork();
+ switch (pid)
+ {
+ case 0: /* child */
+ setgid(gid);
+ setuid(uid);
+ fd = open(pathname, O_WRONLY|O_CREAT|O_APPEND, mode);
+ if (fd >= 0) {
+ close(fd);
+ _exit(0);
+ } else
+ _exit(1);
+ case -1: /* error */
+ return;
+ default: /* parent */
+#ifdef HAS_WAITPID
+ waitpid(pid, NULL, 0);
+#else
+ waited = wait(NULL);
+ 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
+ }
+}
+#endif
+
+#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.
+ */
+
+StartLog(screen)
+register TScreen *screen;
+{
+ register char *cp;
+ register int i;
+ static char *log_default;
+#ifdef ALLOWLOGFILEEXEC
+ void logpipe();
+#ifdef SYSV
+ /* SYSV has another pointer which should be part of the
+ ** FILE structure but is actually a separate array.
+ */
+ unsigned char *old_bufend;
+#endif /* SYSV */
+#endif /* ALLOWLOGFILEEXEC */
+
+ if(screen->logging || (screen->inhibit & I_LOG))
+ return;
+ if(screen->logfile == NULL || *screen->logfile == 0) {
+ if(screen->logfile)
+ free(screen->logfile);
+ if(log_default == NULL)
+ log_default = log_def_name;
+ mkstemp(log_default);
+ if((screen->logfile = malloc((unsigned)strlen(log_default) + 1)) == NULL)
+ return;
+ strcpy(screen->logfile, log_default);
+ }
+ 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 p[2];
+ static char *shell;
+
+ if(pipe(p) < 0 || (i = fork()) < 0)
+ return;
+ if(i == 0) { /* child */
+ close(p[1]);
+ dup2(p[0], 0);
+ close(p[0]);
+ dup2(fileno(stderr), 1);
+ dup2(fileno(stderr), 2);
+#ifdef SYSV
+ old_bufend = _bufend(stderr);
+#endif /* SYSV */
+ close(fileno(stderr));
+ stderr->_file = 2;
+#ifdef SYSV
+ _bufend(stderr) = old_bufend;
+#endif /* SYSV */
+ close(ConnectionNumber(screen->display));
+ close(screen->respond);
+ if(!shell) {
+ register struct passwd *pw;
+ struct passwd *getpwuid();
+
+ if(((cp = getenv("SHELL")) == NULL || *cp == 0)
+ && ((pw = getpwuid(screen->uid)) == NULL ||
+ *(cp = pw->pw_shell) == 0) ||
+ (shell = malloc((unsigned) strlen(cp) + 1)) == NULL)
+ shell = "/bin/sh";
+ else
+ strcpy(shell, cp);
+ }
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGCHLD, SIG_DFL);
+ setgid(screen->gid);
+ setuid(screen->uid);
+ execl(shell, shell, "-c", &screen->logfile[1], 0);
+ fprintf(stderr, "%s: Can't exec `%s'\n", xgterm_name,
+ &screen->logfile[1]);
+ exit(ERROR_LOGEXEC);
+ }
+ close(p[0]);
+ screen->logfd = p[1];
+ signal(SIGPIPE, logpipe);
+#else
+ Bell();
+ Bell();
+ return;
+#endif
+ } else {
+ if(access(screen->logfile, F_OK) != 0) {
+ if (errno == ENOENT)
+ creat_as(screen->uid, screen->gid,
+ screen->logfile, 0644);
+ else
+ return;
+ }
+
+ if(access(screen->logfile, F_OK) != 0
+ || access(screen->logfile, W_OK) != 0)
+ return;
+ if((screen->logfd = open(screen->logfile, O_WRONLY | O_APPEND,
+ 0644)) < 0)
+ return;
+ }
+ screen->logstart = bptr;
+ screen->logging = TRUE;
+ update_logging();
+}
+
+CloseLog(screen)
+register TScreen *screen;
+{
+ if(!screen->logging || (screen->inhibit & I_LOG))
+ return;
+ FlushLog(screen);
+ close(screen->logfd);
+ screen->logging = FALSE;
+ update_logging();
+}
+
+FlushLog(screen)
+register TScreen *screen;
+{
+ register Char *cp;
+ register int i;
+
+/*
+ * With xgterm pty input is read only in one place, hence logging is done
+ * immediately upon input.
+ *
+ * cp = bptr;
+ * if((i = cp - screen->logstart) > 0)
+ * write(screen->logfd, (char *)screen->logstart, i);
+ */
+ screen->logstart = buffer;
+}
+
+#ifdef ALLOWLOGFILEEXEC
+void logpipe()
+{
+ register TScreen *screen = &term->screen;
+
+#ifdef SYSV
+ (void) signal(SIGPIPE, SIG_IGN);
+#endif /* SYSV */
+ if(screen->logging)
+ CloseLog(screen);
+}
+#endif /* ALLOWLOGFILEEXEC */
+#endif /* ALLOWLOGGING */
+
+
+do_osc(func)
+int (*func)();
+{
+ register int mode, c;
+ register char *cp;
+ char buf[512];
+ char *bufend = &buf[(sizeof buf) - 1]; /* leave room for null */
+ Bool okay = True;
+
+ /*
+ * lines should be of the form <ESC> ] number ; string <BEL>
+ *
+ * where number is one of 0, 1, 2, or 46
+ */
+ mode = 0;
+ while(isdigit(c = (*func)()))
+ mode = 10 * mode + (c - '0');
+ if (c != ';') okay = False;
+ cp = buf;
+ while(isprint((c = (*func)()) & 0x7f) && cp < bufend)
+ *cp++ = c;
+ if (c != 7) okay = False;
+ *cp = 0;
+ if (okay) 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 10: case 11: case 12:
+ case 13: case 14: case 15:
+ case 16:
+ {
+ extern Boolean ChangeColorsRequest();
+ if (term->misc.dynamicColors)
+ ChangeColorsRequest(term,mode-10,buf);
+ }
+ 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 xgterm.
+ */
+ if((cp = malloc((unsigned)strlen(buf) + 1)) == NULL)
+ break;
+ strcpy(cp, buf);
+ if(term->screen.logfile)
+ free(term->screen.logfile);
+ term->screen.logfile = cp;
+#else
+ Bell();
+ Bell();
+#endif
+ break;
+#endif /* ALLOWLOGGING */
+
+ case 50:
+ SetVTFont (fontMenu_fontescape, True, buf, NULL);
+ break;
+
+ /*
+ * One could write code to send back the display and host names,
+ * but that could potentially open a fairly nasty security hole.
+ */
+ }
+}
+
+static ChangeGroup(attribute, value)
+ String attribute;
+ XtArgVal value;
+{
+ extern Widget toplevel;
+ Arg args[1];
+
+ XtSetArg( args[0], attribute, value );
+ XtSetValues( toplevel, args, 1 );
+}
+
+Changename(name)
+register char *name;
+{
+ ChangeGroup( XtNiconName, (XtArgVal)name );
+}
+
+Changetitle(name)
+register char *name;
+{
+ ChangeGroup( XtNtitle, (XtArgVal)name );
+}
+
+/***====================================================================***/
+
+ScrnColors *pOldColors= NULL;
+
+Boolean
+GetOldColors(pTerm)
+XgtermWidget 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);
+}
+
+Boolean
+UpdateOldColors(pTerm,pNew)
+XgtermWidget pTerm;
+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()
+{
+register 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;
+ }
+ }
+ }
+
+ /* swap text FG and BG */
+ tmpPix= pOld->colors[TEXT_FG];
+ tmpName= pOld->names[TEXT_FG];
+ pOld->colors[TEXT_FG]= pOld->colors[TEXT_BG];
+ pOld->names[TEXT_FG]= pOld->names[TEXT_BG];
+ pOld->colors[TEXT_BG]= tmpPix;
+ pOld->names[TEXT_BG]= tmpName;
+
+ /* swap mouse FG and BG */
+ tmpPix= pOld->colors[MOUSE_FG];
+ tmpName= pOld->names[MOUSE_FG];
+ pOld->colors[MOUSE_FG]= pOld->colors[MOUSE_BG];
+ pOld->names[MOUSE_FG]= pOld->names[MOUSE_BG];
+ pOld->colors[MOUSE_BG]= tmpPix;
+ pOld->names[MOUSE_BG]= tmpName;
+
+ /* swap Tek FG and BG */
+ tmpPix= pOld->colors[TEK_FG];
+ tmpName= pOld->names[TEK_FG];
+ pOld->colors[TEK_FG]= pOld->colors[TEK_BG];
+ pOld->names[TEK_FG]= pOld->names[TEK_BG];
+ pOld->colors[TEK_BG]= tmpPix;
+ pOld->names[TEK_BG]= tmpName;
+ }
+ return;
+}
+
+Boolean
+AllocateColor(pTerm,pNew,ndx,name)
+XgtermWidget pTerm;
+ScrnColors *pNew;
+int ndx;
+char *name;
+{
+XColor def;
+register TScreen *screen= &pTerm->screen;
+Colormap cmap= pTerm->core.colormap;
+char *newName;
+
+ if ((XParseColor(screen->display,cmap,name,&def))&&
+ (XAllocColor(screen->display,cmap,&def))) {
+ SET_COLOR_VALUE(pNew,ndx,def.pixel);
+ newName= XtMalloc(strlen(name)+1);
+ if (newName) {
+ strcpy(newName,name);
+ SET_COLOR_NAME(pNew,ndx,newName);
+ }
+ return(TRUE);
+ }
+ return(FALSE);
+}
+
+Boolean
+ChangeColorsRequest(pTerm,start,names)
+XgtermWidget pTerm;
+int start;
+register char *names;
+{
+char *thisName;
+ScrnColors newColors;
+int i,ndx;
+
+ 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= OPPOSITE_COLOR(i);
+ else ndx= i;
+ if ((names==NULL)||(names[0]=='\0')) {
+ newColors.names[ndx]= NULL;
+ }
+ else {
+ if (names[0]==';')
+ thisName= NULL;
+ else thisName= names;
+ names= index(names,';');
+ if (names!=NULL) {
+ *names= '\0';
+ names++;
+ }
+ if ((!pOldColors->names[ndx])||
+ (thisName&&(strcmp(thisName,pOldColors->names[ndx])))) {
+ AllocateColor(pTerm,&newColors,ndx,thisName);
+ }
+ }
+ }
+
+ if (newColors.which==0)
+ return(TRUE);
+
+ ChangeColors(pTerm,&newColors);
+ UpdateOldColors(pTerm,&newColors);
+ return(TRUE);
+}
+
+/***====================================================================***/
+
+
+
+#ifndef DEBUG
+/* ARGSUSED */
+#endif
+Panic(s, a)
+char *s;
+int a;
+{
+#ifdef DEBUG
+ if(debug) {
+ fprintf(stderr, "%s: PANIC! ", xgterm_name);
+ fprintf(stderr, s, a);
+ fputs("\r\n", stderr);
+ fflush(stderr);
+ }
+#endif /* DEBUG */
+}
+
+char *SysErrorMsg (n)
+ int n;
+{
+#if __STDC__
+ return strerror(n);
+#else
+
+ return((n >= 0) ? (char *)strerror(n) : "unknown error");
+#endif /* __STDC__ */
+}
+
+
+SysError (i)
+int i;
+{
+ int oerrno;
+
+ oerrno = errno;
+ /* perror(3) write(2)s to file descriptor 2 */
+ fprintf (stderr, "%s: Error %d, errno %d: ", xgterm_name, i, oerrno);
+ fprintf (stderr, "%s\n", SysErrorMsg (oerrno));
+ Cleanup(i);
+}
+
+Error (i)
+int i;
+{
+ fprintf (stderr, "%s: Error %d\n", xgterm_name, i);
+ Cleanup(i);
+}
+
+
+/*
+ * cleanup by sending SIGHUP to client processes
+ */
+Cleanup (code)
+int code;
+{
+ extern XgtermWidget term;
+ register TScreen *screen;
+
+ screen = &term->screen;
+ if (screen->pid > 1) {
+ (void) kill_process_group (screen->pid, SIGHUP);
+ }
+ Exit (code);
+}
+
+/*
+ * 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().
+ */
+Setenv (var, value)
+register char *var, *value;
+{
+ extern char **environ;
+ register int envindex = 0;
+ register int len = strlen(var);
+
+ while (environ [envindex] != NULL) {
+ if (strncmp (environ [envindex], var, len) == 0) {
+ /* found it */
+ environ[envindex] = (char *)malloc ((unsigned)len + strlen (value) + 1);
+ strcpy (environ [envindex], var);
+ strcat (environ [envindex], value);
+ return;
+ }
+ envindex ++;
+ }
+
+#ifdef DEBUG
+ if (debug) fputs ("expanding env\n", stderr);
+#endif /* DEBUG */
+
+ environ [envindex] = (char *) malloc ((unsigned)len + strlen (value) + 1);
+ (void) strcpy (environ [envindex], var);
+ strcat (environ [envindex], value);
+ environ [++envindex] = NULL;
+}
+
+/*
+ * returns a pointer to the first occurrence of s2 in s1,
+ * or NULL if there are none.
+ */
+char *strindex (s1, s2)
+register char *s1, *s2;
+{
+ register char *s3;
+ int s2len = strlen (s2);
+
+ while ((s3=strchr(s1, *s2)) != NULL) {
+ if (strncmp(s3, s2, s2len) == 0)
+ return (s3);
+ s1 = ++s3;
+ }
+ return (NULL);
+}
+
+
+/* xerror -- Handle an XLIB server error. A standard X error message is
+ * printed and then the program either dumps core, exits, or ignores the error,
+ * depending upon the value of the environment variable XGXERROR, if defined.
+ */
+/*ARGSUSED*/
+xerror (display, event)
+Display *display;
+register XErrorEvent *event;
+{
+ static char *envvar = "XGXERROR";
+ static char *env_maxerrs = "XGMAXERROR";
+ static int nerrs = 0, maxerrs = -1;
+ extern char *getenv();
+ char fname[128];
+ char *action = NULL, *err = NULL;
+ int pid;
+
+ /* Get the max number of allowable errors before we exit, defaults
+ * to 50. This is handy either for debugging to trap errors right
+ * away, or to increase the max value to run longer.
+ */
+ if (maxerrs < 0)
+ maxerrs = ((err = getenv (env_maxerrs)) ? atoi(err) : 50);
+
+ /* If we define XGXERROR to be 'ignore' don't print out the standard
+ * error message, and don't count it.
+ */
+
+ action = getenv (envvar);
+ if (!action || (action && strcmp (action, "ignore") != 0)) {
+
+ /* The default action is to ignore BadCursor messages but we
+ * define a 'catchall' action to let us bypass this. Otherwise,
+ * print the standard X error message and count it towards the
+ * final shutdown.
+ */
+
+ if (event->error_code == BadCursor ||
+ (action && strcmp (action, "catchall") != 0)) {
+ return (0);
+ } else {
+ fprintf (stderr,
+ "%s: warning, error event received:\n", xgterm_name);
+ (void) XmuPrintDefaultErrorMessage (display, event, stderr);
+
+ if (nerrs++ > maxerrs)
+ Exit (ERROR_XERROR);
+ }
+ }
+
+ if (action) {
+ if (strcmp (action, "dumpcore") == 0) {
+ if ((pid = fork()) >= 0) {
+ if (pid) {
+ fprintf (stderr, "dumping core... ");
+ fflush (stderr);
+ sprintf (fname, "core.%d", pid);
+ wait(NULL); rename ("core", fname);
+ fprintf (stderr, "core file core.%d written\n", pid);
+ fflush (stderr);
+ } else
+ kill (getpid(), 6);
+ } else
+ fprintf (stderr, "fork failed, no core dump produced\n");
+ } else if (strcmp (action, "exit") == 0) {
+ fprintf (stderr, "program terminated\n");
+ Exit (ERROR_XERROR);
+ } else if (strcmp (action, "ignore") != 0)
+ fprintf (stderr, "%s: unknown action %s\n", envvar, action);
+ }
+
+ return (0);
+}
+
+/*ARGSUSED*/
+xioerror(dpy)
+Display *dpy;
+{
+ (void) fprintf (stderr,
+ "%s: fatal IO error %d (%s) or KillClient on X server \"%s\"\r\n",
+ xgterm_name, errno, SysErrorMsg (errno),
+ DisplayString (dpy));
+
+ Exit(ERROR_XIOERROR);
+}
+
+void xt_error(message)
+ String message;
+{
+ extern char *ProgramName;
+
+ (void) fprintf (stderr, "%s Xt error: %s\n", ProgramName, message);
+ exit(1);
+}
+
+XStrCmp(s1, s2)
+char *s1, *s2;
+{
+ if (s1 && s2) return(strcmp(s1, s2));
+ if (s1 && *s1) return(1);
+ if (s2 && *s2) return(-1);
+ return(0);
+}
+
+static void withdraw_window (dpy, w, scr)
+ Display *dpy;
+ Window w;
+ int scr;
+{
+ (void) XmuUpdateMapHints (dpy, w, NULL);
+ XWithdrawWindow (dpy, w, scr);
+ return;
+}
+
+void set_vt_visibility (on)
+ Boolean on;
+{
+ register TScreen *screen = &term->screen;
+
+ if (on) {
+ if (!screen->Vshow && term) {
+ VTInit ();
+ XtMapWidget (term->core.parent);
+ screen->Vshow = TRUE;
+ }
+ } else {
+ if (screen->Vshow && term) {
+ withdraw_window (XtDisplay (term),
+ XtWindow(XtParent(term)),
+ XScreenNumberOfScreen(XtScreen(term)));
+ screen->Vshow = FALSE;
+ }
+ }
+ set_vthide_sensitivity();
+ set_tekhide_sensitivity();
+ set_tekreset_sensitivity();
+ update_vttekmode();
+ update_tekshow();
+ update_tekreset();
+ update_vtshow();
+}
+
+extern Atom wm_delete_window; /* for ICCCM delete window */
+
+void set_tek_visibility (on)
+Boolean on;
+{
+ register TScreen *screen = &term->screen;
+ if (on) {
+ if (!gt_activated())
+ gt_activate();
+ } else {
+ if (gt_activated())
+ gt_deactivate();
+ }
+ set_vthide_sensitivity();
+ set_tekhide_sensitivity();
+ set_tekreset_sensitivity();
+ update_vttekmode();
+ update_tekshow();
+ update_tekreset();
+ update_vtshow();
+}
+
+void end_tek_mode ()
+{
+ register TScreen *screen = &term->screen;
+
+ if (gt_tekmode (2)) {
+#ifdef ALLOWLOGGING
+ if (screen->logging) {
+ FlushLog (screen);
+ screen->logstart = buffer;
+ }
+#endif
+ gt_tekmode (0);
+ update_vttekmode();
+ }
+}
+
+void end_vt_mode ()
+{
+ register TScreen *screen = &term->screen;
+
+ if (!gt_tekmode (2)) {
+#ifdef ALLOWLOGGING
+ if(screen->logging) {
+ FlushLog(screen);
+ screen->logstart = Tbuffer;
+ }
+#endif
+ gt_tekmode (1);
+ update_vttekmode();
+ }
+ return;
+}
+
+void switch_modes (tovt)
+ Bool tovt; /* if true, then become vt mode */
+{
+ if (tovt)
+ gt_tekmode (0);
+ else {
+ gt_activate();
+ gt_tekmode (1);
+ }
+
+ set_vthide_sensitivity();
+ set_tekhide_sensitivity();
+ set_tekreset_sensitivity();
+ update_vttekmode();
+ update_tekshow();
+ update_tekreset();
+ update_vtshow();
+}
+
+void hide_vt_window ()
+{
+ register TScreen *screen = &term->screen;
+
+ set_vt_visibility (FALSE);
+ switch_modes (False);
+}
+
+void hide_tek_window ()
+{
+ register TScreen *screen = &term->screen;
+
+ set_tek_visibility (FALSE);
+ switch_modes (True);
+}
+
+
+/*
+ * The GTERMIO routines are called by the gtermio code during initialization
+ * to provide hooks into the xgterm code.
+ */
+
+/* The following is called when a gtermio UI display connection is opened
+ * or closed. The gtermio UI code uses a separate display connection and
+ * passes in the display and toplevel widget for this connection.
+ */
+void
+gtermio_connect (notused, display, toplevel, state)
+int notused;
+Display *display; /* UI display */
+Widget toplevel; /* toplevel widget */
+int state; /* 1=open, 0=close */
+{
+ TScreen *screen = &term->screen;
+
+ if (state) {
+ gtermio_display = display;
+ gtermio_toplevel = toplevel;
+ } else {
+ gtermio_display = NULL;
+ gtermio_toplevel = NULL;
+ screen->tek_menu_item_bitmap = (Pixmap) NULL;
+ init_menu ("tekMenu");
+ }
+}
+
+
+/* The following are called by the gtermio code when switching between
+ * vt100 and graphics mode.
+ */
+static void
+set_workstation_state (state)
+{
+ register TScreen *screen = &term->screen;
+
+ screen->Tshow = state;
+ set_tekhide_sensitivity();
+ set_vthide_sensitivity();
+ set_tekreset_sensitivity();
+ update_vtshow();
+ update_tekshow();
+ update_tekreset();
+ update_vttekmode();
+}
+
+gtermio_open_workstation() { set_workstation_state(1); }
+gtermio_close_workstation() { set_workstation_state(0); }
+
+
+/* GTERMIO protocol module functions.
+ */
+int (*gtermio_reset)(); XtPointer gtermio_reset_data;
+int (*gtermio_clear)(); XtPointer gtermio_clear_data;
+int (*gtermio_input)(); XtPointer gtermio_input_data;
+int (*gtermio_output)(); XtPointer gtermio_output_data;
+int (*gtermio_activate)(); XtPointer gtermio_activate_data;
+int (*gtermio_status)(); XtPointer gtermio_status_data;
+int (*gtermio_enable)(); XtPointer gtermio_enable_data;
+int (*gtermio_tekmode)(); XtPointer gtermio_tekmode_data;
+int (*gtermio_SGMT)(); XtPointer gtermio_SGMT_data;
+
+/* gtermio_register -- This routine is called by the GTERMIO protocol
+ * module code during startup to register the protocol module's public
+ * functions, called by the xgterm code during execution to process
+ * graphics data, activate or deactivate the graphics window, and so on.
+ */
+gtermio_register (functions, nfunc)
+struct GT_function *functions;
+int nfunc;
+{
+ register struct GT_function *fp;
+ register int i;
+
+ for (i=0; i < nfunc; i++) {
+ fp = &functions[i];
+ if (strcmp (fp->name, "reset") == 0) {
+ gtermio_reset = fp->func;
+ gtermio_reset_data = fp->data;
+ } else if (strcmp (fp->name, "clear") == 0) {
+ gtermio_clear = fp->func;
+ gtermio_clear_data = fp->data;
+ } else if (strcmp (fp->name, "input") == 0) {
+ gtermio_input = fp->func;
+ gtermio_input_data = fp->data;
+ } else if (strcmp (fp->name, "output") == 0) {
+ gtermio_output = fp->func;
+ gtermio_output_data = fp->data;
+ } else if (strcmp (fp->name, "activate") == 0) {
+ gtermio_activate = fp->func;
+ gtermio_activate_data = fp->data;
+ } else if (strcmp (fp->name, "status") == 0) {
+ gtermio_status = fp->func;
+ gtermio_status_data = fp->data;
+ } else if (strcmp (fp->name, "enable") == 0) {
+ gtermio_enable = fp->func;
+ gtermio_enable_data = fp->data;
+ } else if (strcmp (fp->name, "tekmode") == 0) {
+ gtermio_tekmode = fp->func;
+ gtermio_tekmode_data = fp->data;
+ } else if (strcmp (fp->name, "setGinmodeTrailers") == 0) {
+ gtermio_SGMT = fp->func;
+ gtermio_SGMT_data = fp->data;
+ }
+ }
+}
+
+/* gtermio_getResource -- Called by the gtermio code to get resource values
+ * from Xgterm.
+ */
+char *
+gtermio_getResource (name)
+char *name;
+{
+ if (strcmp (name, "geometry") == 0)
+ return (term->misc.T_geometry);
+ else
+ return (NULL);
+}
+
+/* gt_reset -- Reset the graphics window.
+ */
+gt_reset()
+{
+ if (gtermio_reset)
+ (*gtermio_reset)(gtermio_reset_data);
+}
+
+/* gt_clear -- Clear the graphics window.
+ */
+gt_clear()
+{
+ if (gtermio_clear)
+ (*gtermio_clear)(gtermio_clear_data);
+}
+
+/* gt_input -- Filter any graphics data out of the input data stream. The
+ * number of bytes of data left after the graphics data is removed is
+ * returned as the function value.
+ */
+gt_input (bptr, bcnt)
+char *bptr;
+int bcnt;
+{
+ if (gtermio_input)
+ return ((*gtermio_input)(gtermio_input_data, bptr, bcnt));
+ else
+ return (bcnt);
+}
+
+/* gt_flush -- Process the gterm output buffer once. Any buffered input
+ * graphics data is processed and output to the screen.
+ */
+gt_flush()
+{
+ if (gtermio_output)
+ return ((*gtermio_output) (gtermio_output_data));
+ else
+ return (1);
+}
+
+/* gt_activate -- Activate the graphics window.
+ */
+gt_activate()
+{
+ if (gtermio_activate)
+ (*gtermio_activate)(gtermio_activate_data, 1);
+}
+
+/* gt_deactivate -- Deactivate the graphics window.
+ */
+gt_deactivate()
+{
+ if (gtermio_activate)
+ (*gtermio_activate)(gtermio_activate_data, 0);
+}
+
+/* gt_activated -- Test whether the graphics window is activated.
+ */
+gt_activated()
+{
+ if (gtermio_activate)
+ return ((*gtermio_activate)(gtermio_activate_data, 2));
+ else
+ return (0);
+}
+
+/* gt_status -- Test whether the graphics window is instantiated or reset.
+ */
+gt_status()
+{
+ if (gtermio_status) {
+ char name[256];
+ int status;
+
+ if (status = (*gtermio_status)(gtermio_status_data, name, NULL)) {
+ strncpy (gtermio_appname, name, SZ_APPNAME);
+ gtermio_appname[SZ_APPNAME] = '\0';
+ } else
+ gtermio_appname[0] = '\0';
+ return (status);
+
+ } else {
+ gtermio_appname[0] = '\0';
+ return (0);
+ }
+}
+
+/* gt_enable -- Enable the graphics window. If the graphics window is
+ * disabled graphics/text mode switches will be ignored and all output will
+ * be directed to the text window.
+ */
+gt_enable (state)
+int state;
+{
+ if (gtermio_enable)
+ return ((*gtermio_enable)(gtermio_enable_data, state));
+ else
+ return (0);
+}
+
+/* gt_tekmode -- Activate the graphics window.
+ */
+gt_tekmode (state)
+int state;
+{
+ register TScreen *screen = &term->screen;
+ int tekEmu;
+
+ if (gtermio_tekmode) {
+ tekEmu = ((*gtermio_tekmode)(gtermio_tekmode_data, state));
+ screen->TekEmu = tekEmu;
+ } else
+ return (0);
+}
+
+/* g_set_ginmode_trailers -- Set the trailer codes used to deliminate a
+ * cursor read value in the gtermio code.
+ */
+gt_set_ginmode_trailers (trailers)
+char *trailers;
+{
+ if (gtermio_SGMT)
+ (*gtermio_SGMT)(gtermio_SGMT_data, trailers);
+}
diff --git a/vendor/x11iraf/xgterm/mkp b/vendor/x11iraf/xgterm/mkp
new file mode 100644
index 00000000..7634c769
--- /dev/null
+++ b/vendor/x11iraf/xgterm/mkp
@@ -0,0 +1 @@
+gcc -m32 -c -g -I../include -I/usr/X11R6/include -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -DFUNCPROTO=15 -DNARROWPROTO -DALLOWLOGGING -DXVENDORNAME='"The X.Org Foundation"' -DXVENDORNAMESHORT='"X.Org"' -DUTMP -DUSE_TTY_GROUP -DOSMAJORVERSION=2 -DOSMINORVERSION=6 -E -C main.c >& main.p
diff --git a/vendor/x11iraf/xgterm/ptyx.h b/vendor/x11iraf/xgterm/ptyx.h
new file mode 100644
index 00000000..ef69a12e
--- /dev/null
+++ b/vendor/x11iraf/xgterm/ptyx.h
@@ -0,0 +1,557 @@
+/*
+ * $XConsortium: ptyx.h,v 1.62 93/02/25 17:21:26 gildea 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.
+ */
+
+/* ptyx.h */
+/* @(#)ptyx.h X10/6.6 11/10/86 */
+
+#include <X11/IntrinsicP.h>
+#include <X11/Xmu/Misc.h> /* For Max() and Min(). */
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+
+
+/* Extra Xlib definitions */
+#define AllButtonsUp(detail, ignore) (\
+ ((ignore) == Button1) ? \
+ (((detail)&(Button2Mask|Button3Mask)) == 0) \
+ : \
+ (((ignore) == Button2) ? \
+ (((detail)&(Button1Mask|Button3Mask)) == 0) \
+ : \
+ (((detail)&(Button1Mask|Button2Mask)) == 0)) \
+ )
+
+#define MAX_COLS 200
+#define MAX_ROWS 128
+
+/*
+** System V definitions
+*/
+
+#ifdef SYSV
+#ifdef X_NOT_POSIX
+#ifndef CRAY
+#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \
+ (close(fd2), fcntl(fd1, F_DUPFD, fd2)))
+#endif
+#endif
+#endif /* SYSV */
+
+/*
+** allow for mobility of the pty master/slave directories
+*/
+#ifndef PTYDEV
+#if defined(hpux) || defined(__hpux)
+#define PTYDEV "/dev/ptym/ptyxx"
+#else /* !__hpux */
+#define PTYDEV "/dev/ptyxx"
+#endif /* !__hpux */
+#endif /* !PTYDEV */
+
+#ifndef TTYDEV
+#if defined(hpux) || defined(__hpux)
+#define TTYDEV "/dev/pty/ttyxx"
+#else /* !__hpux */
+#define TTYDEV "/dev/ttyxx"
+#endif /* !__hpux */
+#endif /* !TTYDEV */
+
+#ifndef PTYCHAR1
+#if defined(hpux) || defined(__hpux)
+#define PTYCHAR1 "zyxwvutsrqp"
+#else /* !__hpux */
+#define PTYCHAR1 "pqrstuvwxyzPQRSTUVWXYZ"
+#endif /* !__hpux */
+#endif /* !PTYCHAR1 */
+
+#ifndef PTYCHAR2
+#if defined(hpux) || defined(__hpux)
+#define PTYCHAR2 "fedcba9876543210"
+#else /* !__hpux */
+#define PTYCHAR2 "0123456789abcdef"
+#endif /* !__hpux */
+#endif /* !PTYCHAR2 */
+
+#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
+
+
+/* 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.
+ */
+
+typedef unsigned char Char; /* to support 8 bit chars */
+typedef Char **ScrnBuf;
+
+/*
+ * ANSI emulation.
+ */
+#define INQ 0x05
+#define FF 0x0C /* C0, C1 control names */
+#define LS1 0x0E
+#define LS0 0x0F
+#define CAN 0x18
+#define SUB 0x1A
+#define ESC 0x1B
+#define US 0x1F
+#define DEL 0x7F
+#define HTS ('H'+0x40)
+#define SS2 0x8E
+#define SS3 0x8F
+#define DCS 0x90
+#define OLDID 0x9A /* ESC Z */
+#define CSI 0x9B
+#define ST 0x9C
+#define OSC 0x9D
+#define PM 0x9E
+#define APC 0x9F
+#define RDEL 0xFF
+
+#define NMENUFONTS 9 /* entries in fontMenu */
+
+#define NBOX 5 /* Number of Points in box */
+#define NPARAM 10 /* Max. parameters */
+
+#define MINHILITE 32
+
+typedef struct {
+ unsigned char a_type;
+ unsigned char a_pintro;
+ unsigned char a_final;
+ unsigned char a_inters;
+ char a_nparam; /* # of parameters */
+ char a_dflt[NPARAM]; /* Default value flags */
+ short a_param[NPARAM]; /* Parameters */
+ char a_nastyf; /* Error flag */
+} ANSI;
+
+typedef struct {
+ int row;
+ int col;
+ unsigned flags; /* Vt100 saves graphics rendition. Ugh! */
+ char curgl;
+ char curgr;
+ char gsets[4];
+} SavedCursor;
+
+#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;
+ int 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 256 /* default # lines to save */
+#define SCROLLLINES 1 /* default # lines to scroll */
+
+/***====================================================================***/
+
+#define TEXT_FG 0
+#define TEXT_BG 1
+#define TEXT_CURSOR 2
+#define MOUSE_FG 3
+#define MOUSE_BG 4
+#define TEK_FG 5
+#define TEK_BG 6
+#define NCOLORS 7
+
+#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)))
+#define OPPOSITE_COLOR(n) (((n)==TEXT_FG?TEXT_BG:\
+ ((n)==TEXT_BG?TEXT_FG:\
+ ((n)==MOUSE_FG?MOUSE_BG:\
+ ((n)==MOUSE_BG?MOUSE_FG:\
+ ((n)==TEK_FG?TEK_BG:\
+ ((n)==TEXT_BG?TEK_FG:(n))))))))
+
+typedef struct {
+ unsigned which;
+ Pixel colors[NCOLORS];
+ char *names[NCOLORS];
+} ScrnColors;
+
+/***====================================================================***/
+
+#define MAXCOLORS 18
+#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 COLOR_BD 16
+#define COLOR_UL 17
+
+
+typedef struct {
+ Display *display; /* X display for screen */
+ int respond; /* socket for responses
+ (position report, etc.) */
+ long pid; /* pid of process on far side */
+ int uid; /* user id of actual person */
+ int gid; /* group id of actual person */
+ GC normalGC; /* normal painting */
+ GC reverseGC; /* reverse painting */
+ GC normalboldGC; /* normal painting, bold font */
+ GC reverseboldGC; /* reverse painting, bold font */
+ GC cursorGC; /* normal cursor painting */
+ GC reversecursorGC;/* reverse cursor painting */
+ GC cursoroutlineGC;/* for painting lines around */
+ Pixel foreground; /* foreground color */
+ Pixel cursorcolor; /* Cursor color */
+ Pixel mousecolor; /* Mouse color */
+ Pixel mousecolorback; /* Mouse color background */
+ Pixel colors[MAXCOLORS]; /* ANSI color emulation */
+ int border; /* inner border */
+ Cursor arrow; /* arrow cursor */
+ unsigned short send_mouse_pos; /* user wants mouse transition */
+ /* and position information */
+ int select; /* xgterm selected */
+ Boolean visualbell; /* visual bell mode */
+ Boolean allowSendEvents;/* SendEvent mode */
+ Boolean grabbedKbd; /* keyboard is grabbed */
+#ifdef ALLOWLOGGING
+ int logging; /* logging mode */
+ int logfd; /* file descriptor of log */
+ char *logfile; /* log file name */
+ unsigned char *logstart; /* current start of log buffer */
+#endif
+ int inhibit; /* flags for inhibiting changes */
+
+ /* VT window parameters */
+ struct {
+ Window window; /* X window id */
+ int width; /* width of columns */
+ int height; /* height of rows */
+ int fullwidth; /* full width of window */
+ int fullheight; /* full height of window */
+ int f_width; /* width of fonts in pixels */
+ int f_height; /* height of fonts in pixels */
+ } fullVwin;
+ Cursor pointer_cursor; /* pointer cursor in window */
+
+ /* Gterm window control */
+ Boolean Vshow; /* VT window showing */
+ Boolean Tshow; /* Tek window showing */
+ Boolean TekEmu; /* true if Tek emulation */
+
+ /* Terminal fonts must be of the same size and of fixed width */
+ XFontStruct *fnt_norm; /* normal font of terminal */
+ XFontStruct *fnt_bold; /* bold font of terminal */
+ int enbolden; /* overstrike for bold font */
+ XPoint *box; /* draw unselected cursor */
+
+ int cursor_state; /* ON or OFF */
+ int cursor_set; /* requested state */
+ int cursor_col; /* previous cursor column */
+ int cursor_row; /* previous cursor row */
+ 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 scrollbar; /* if > 0, width of scrollbar, and
+ scrollbar is showing */
+ 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 buf; /* 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 */
+ 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; /* cludge-ups for more and vi */
+ 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; /* data for restore cursor */
+ int save_modes[19]; /* save dec private modes */
+
+ /* Improved VT100 emulation stuff. */
+ char gsets[4]; /* G0 through G3. */
+ char curgl; /* Current GL setting. */
+ char curgr; /* Current GR setting. */
+ char curss; /* Current single shift. */
+ int scroll_amt; /* amount to scroll */
+ int refresh_amt; /* amount to refresh */
+ Boolean jumpscroll; /* whether we should jumpscroll */
+ Boolean always_highlight; /* whether to highlight cursor */
+ Boolean underline; /* whether to underline text */
+
+ int multiClickTime; /* time between multiclick selects */
+ 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? */
+ char *selection; /* the current selection */
+ int selection_size; /* size of allocated buffer */
+ int selection_length; /* number of significant bytes */
+ int 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 */
+ Pixmap menu_item_bitmap;
+ Pixmap tek_menu_item_bitmap;
+ Widget mainMenu, vtMenu, tekMenu, fontMenu;
+ char* menu_font_names[NMENUFONTS];
+ int menu_font_number;
+#ifdef I18N
+ XIC xic;
+#endif
+} TScreen;
+
+/* 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 struct
+{
+ unsigned flags;
+} TKeyboard;
+
+typedef struct _Misc {
+ char *geo_metry;
+ char *T_geometry;
+ char *f_n;
+ char *f_b;
+#ifdef ALLOWLOGGING
+ Boolean log_on;
+#endif
+ Boolean login_shell;
+ Boolean re_verse;
+ int resizeGravity;
+ Boolean reverseWrap;
+ Boolean autoWrap;
+ Boolean logInhibit;
+ Boolean signalInhibit;
+ Boolean tekInhibit;
+ Boolean scrollbar;
+ Boolean titeInhibit;
+ Boolean appcursorDefault;
+ Boolean appkeypadDefault;
+#ifdef I18N
+ char *input_method;
+ char *preedit_type;
+ Boolean open_im;
+ Boolean shared_ic;
+#endif
+ Boolean dynamicColors; /* use colors */
+ Boolean sb_right; /* scrollbar on right */
+} Misc;
+
+typedef struct {int foo;} XgtermClassPart;
+
+typedef struct _XgtermClassRec {
+ CoreClassPart core_class;
+ XgtermClassPart xgterm_class;
+} XgtermClassRec;
+
+/* define masks for flags */
+#define CAPS_LOCK 0x01
+#define KYPD_APL 0x02
+#define CURSOR_APL 0x04
+
+#define N_MARGINBELL 10
+#define MAX_TABS 320
+#define TAB_ARRAY_SIZE 10 /* number of ints to provide MAX_TABS bits */
+
+typedef unsigned Tabs [TAB_ARRAY_SIZE];
+
+typedef struct _XgtermWidgetRec {
+ CorePart core;
+ TKeyboard keyboard; /* terminal keyboard */
+ TScreen screen; /* terminal screen */
+ unsigned flags; /* mode flags */
+ unsigned cur_foreground; /* current foreground color */
+ unsigned cur_background; /* current background color */
+ unsigned initflags; /* initial mode flags */
+ Tabs tabs; /* tabstops of the terminal */
+ Misc misc; /* miscellaneous parameters */
+} XgtermWidgetRec, *XgtermWidget;
+
+#define BUF_SIZE 4096
+
+/*
+ * terminal flags
+ * There are actually two namespaces mixed together here.
+ * One is the set of flags that can go in screen->buf attributes
+ * and which must fit in a char.
+ * The other is the global setting stored in
+ * term->flags and screen->save_modes. This need only fit in an unsigned.
+ */
+
+#define ATTRIBUTES 0x67 /* mask: user-visible attributes */
+/* 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
+/* character flags (internal attributes) */
+#define LINEWRAPPED 0x08 /* used on the first character in a
+ * line to indicate that it wraps onto
+ * the next line so we can tell the
+ * difference between lines that have
+ * wrapped around and lines that have
+ * ended naturally with a CR at column
+ * max_col.
+ */
+#define CHARDRAWN 0x10 /* a character has been drawn here on the
+ screen. Used to distinguish blanks from
+ empty parts of the screen when selecting */
+/* global flags */
+#define BG_COLOR 0x20 /* true if background set */
+#define FG_COLOR 0x40 /* true if foreground set */
+
+/* global flags */
+#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 VWindow(screen) (screen->fullVwin.window)
+#define VShellWindow term->core.parent->core.window
+#define TextWindow(screen) (screen->fullVwin.window)
+#define Width(screen) (screen->fullVwin.width)
+#define Height(screen) (screen->fullVwin.height)
+#define FullWidth(screen) (screen->fullVwin.fullwidth)
+#define FullHeight(screen) (screen->fullVwin.fullheight)
+#define FontWidth(screen) (screen->fullVwin.f_width)
+#define FontHeight(screen) (screen->fullVwin.f_height)
+
+#define CursorX(screen,col) (term->misc.sb_right ? \
+ (col) * FontWidth(screen) + screen->border : \
+ (col) * FontWidth(screen) + screen->border \
+ + screen->scrollbar)
+#define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \
+ + screen->border)
+
+#define WINDOWEVENTS (TWINDOWEVENTS | PointerMotionMask)
+
+/* flags for cursors */
+#define OFF 0
+#define ON 1
+#define CLEAR 0
+#define TOGGLE 1
+
+/* flags for inhibit */
+#ifdef ALLOWLOGGING
+#define I_LOG 0x01
+#endif
+#define I_SIGNAL 0x02
+#define I_TEK 0x04
+
+extern Cursor make_colored_cursor();
+extern int GetBytesAvailable();
+extern void first_map_occurred();
+extern int kill_process_group();
diff --git a/vendor/x11iraf/xgterm/ptyx_new.h b/vendor/x11iraf/xgterm/ptyx_new.h
new file mode 100644
index 00000000..f4909646
--- /dev/null
+++ b/vendor/x11iraf/xgterm/ptyx_new.h
@@ -0,0 +1,1836 @@
+/* $XTermId: ptyx.h,v 1.321 2004/06/06 22:15:25 tom Exp $ */
+
+/*
+ * $Xorg: ptyx.h,v 1.3 2000/08/17 19:55:09 cpqbld Exp $
+ */
+
+/* $XFree86: xc/programs/xterm/ptyx.h,v 3.116 2004/06/06 22:15:25 dickey Exp $ */
+
+/*
+ * Copyright 1999-2003,2004 by Thomas E. Dickey
+ *
+ * All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization.
+ *
+ *
+ * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of Digital Equipment
+ * Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ *
+ *
+ * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef included_ptyx_h
+#define included_ptyx_h 1
+
+#ifdef HAVE_CONFIG_H
+#include <xtermcfg.h>
+#endif
+
+/* ptyx.h */
+/* @(#)ptyx.h X10/6.6 11/10/86 */
+
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h> /* for XtNdieCallback, etc. */
+#include <X11/StringDefs.h> /* for standard resource names */
+#include <X11/Xmu/Misc.h> /* For Max() and Min(). */
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+#include <X11/Xmu/Converters.h>
+#ifdef XRENDERFONT
+#include <X11/Xft/Xft.h>
+#endif
+
+/* adapted from IntrinsicI.h */
+#define MyStackAlloc(size, stack_cache_array) \
+ ((size) <= sizeof(stack_cache_array) \
+ ? (XtPointer)(stack_cache_array) \
+ : (XtPointer)malloc((unsigned)(size)))
+
+#define MyStackFree(pointer, stack_cache_array) \
+ if ((pointer) != ((char *)(stack_cache_array))) free(pointer)
+
+/*
+** System V definitions
+*/
+
+#ifdef att
+#define ATT
+#endif
+
+#ifdef SVR4
+#undef SYSV /* predefined on Solaris 2.4 */
+#define SYSV /* SVR4 is (approx) superset of SVR3 */
+#define ATT
+#endif
+
+#ifdef SYSV
+#ifdef X_NOT_POSIX
+#if !defined(CRAY) && !defined(SVR4)
+#define dup2(fd1,fd2) ((fd1 == fd2) ? fd1 : \
+ (close(fd2), fcntl(fd1, F_DUPFD, fd2)))
+#endif
+#endif
+#endif /* SYSV */
+
+/*
+ * Newer versions of <X11/Xft/Xft.h> have a version number. We use certain
+ * features from that.
+ */
+#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
+#define HAVE_TYPE_FCCHAR32 1 /* compatible: XftChar16 */
+#define HAVE_TYPE_XFTCHARSPEC 1 /* new type XftCharSpec */
+#endif
+
+/*
+** Definitions to simplify ifdef's for pty's.
+*/
+#define USE_PTY_DEVICE 1
+#define USE_PTY_SEARCH 1
+
+#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__NetBSD__)
+#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 */
+#ifdef __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.
+ */
+
+typedef unsigned char Char; /* to support 8 bit chars */
+typedef Char **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;
+ unsigned char a_pintro;
+ unsigned char a_final;
+ unsigned char a_inters;
+ char 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_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_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_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_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 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 (term->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 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 Sres(name, class, offset, dftvalue) \
+ {RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
+ RES_OFFSET(offset), XtRString, (XtPointer) dftvalue}
+
+/***====================================================================***/
+
+#define BUF_SIZE 4096
+#define FRG_SIZE 128
+
+typedef struct {
+ Char buffer[BUF_SIZE + FRG_SIZE];
+ Char * next;
+ Char * last;
+ int update; /* HandleInterpret */
+#if OPT_WIDE_CHARS
+ IChar utf_data; /* resulting character */
+ int utf_size; /* ...number of bytes decoded */
+#endif
+} PtyData;
+
+/***====================================================================***/
+
+#if OPT_TRACE
+#include <trace.h>
+#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 TRACE2
+#define TRACE2(p) /*nothing*/
+#endif
+
+/***====================================================================***/
+
+/* The order of ifdef's matches the logic for num_ptrs in VTInitialize */
+typedef enum {
+ OFF_FLAGS = 0 /* BUF_HEAD */
+ , OFF_CHARS = 1
+ , OFF_ATTRS = 2
+#if OPT_ISO_COLORS
+#if OPT_256_COLORS || OPT_88_COLORS
+ , OFF_FGRND
+ , OFF_BGRND
+#else
+ , OFF_COLOR
+#endif
+#endif
+#if OPT_DEC_CHRSET
+ , OFF_CSETS
+#endif
+#if OPT_WIDE_CHARS
+ , OFF_WIDEC
+ , OFF_COM1L
+ , OFF_COM1H
+ , OFF_COM2L
+ , 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;
+
+ /* 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
+ 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;
+
+struct _vtwin {
+ Window window; /* X window id */
+ int width; /* width of columns */
+ int height; /* height of rows */
+ int fullwidth; /* full width of window */
+ int 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
+ Widget menu_bar; /* toolbar, if initialized */
+ Dimension menu_height; /* ...and its height */
+#endif
+};
+
+struct _tekwin {
+ Window window; /* X window id */
+ int width; /* width of columns */
+ int height; /* height of rows */
+ int fullwidth; /* full width of window */
+ int 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
+ long pid; /* pid of process on far side */
+ int uid; /* user id of actual person */
+ int 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 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_WIDE_CHARS
+ Boolean wide_chars; /* true when 16-bit chars */
+ Boolean vt100_graphics; /* true to allow vt100-graphics */
+ int utf8_mode; /* use UTF-8 decode/encode: 0-2 */
+ int utf_count; /* state of utf_char */
+ IChar utf_char; /* in-progress character */
+#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 */
+ Cursor arrow; /* arrow cursor */
+ unsigned long event_mask;
+ unsigned short send_mouse_pos; /* user wants mouse transition */
+ /* and position information */
+#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 visualbell; /* visual bell mode */
+ Boolean poponbell; /* pop on bell mode */
+ Boolean allowSendEvents;/* SendEvent mode */
+ Boolean allowWindowOps; /* 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 */
+#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 */
+ 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 */
+ int 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
+ int 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];
+ long menu_font_sizes[NMENUFONTS];
+ int menu_font_number;
+ XIC xic;
+#if OPT_RENDERFONT
+ XftFont * renderFontNorm[NMENUFONTS];
+ XftFont * renderFontBold[NMENUFONTS];
+ XftFont * renderWideNorm[NMENUFONTS];
+ XftFont * renderWideBold[NMENUFONTS];
+ XftDraw * renderDraw;
+#endif
+#if OPT_INPUT_METHOD
+ XFontSet fs; /* fontset for XIM preedit */
+ int fs_ascent; /* ascent of fs */
+#endif
+#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
+ Widget menu_bar; /* toolbar, if initialized */
+ Dimension menu_height; /* ...and its height */
+#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 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 when CJK width convention is turned on */
+#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 */
+ int 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;
+ int 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.
+ * 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_CURS
+#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)
+
+#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 CursorX(screen,col) ((col) * FontWidth(screen) + OriginX(screen))
+#define CursorY(screen,row) ((((row) - screen->topline) * FontHeight(screen)) \
+ + screen->border)
+
+#ifndef NO_ACTIVE_ICON
+#define IsIcon(screen) ((screen)->whichVwin == &(screen)->iconVwin)
+#define VWindow(screen) ((screen)->whichVwin->window)
+#define VShellWindow XtWindow(SHELL_OF(term))
+#define TWindow(screen) ((screen)->whichTwin->window)
+#define TShellWindow XtWindow(SHELL_OF(tekWidget))
+#define Width(screen) ((screen)->whichVwin->width)
+#define Height(screen) ((screen)->whichVwin->height)
+#define FullWidth(screen) ((screen)->whichVwin->fullwidth)
+#define FullHeight(screen) ((screen)->whichVwin->fullheight)
+#define FontWidth(screen) ((screen)->whichVwin->f_width)
+#define FontHeight(screen) ((screen)->whichVwin->f_height)
+#define FontAscent(screen) (IsIcon(screen) ? (screen)->fnt_icon->ascent \
+ : (screen)->whichVwin->f_ascent)
+#define FontDescent(screen) (IsIcon(screen) ? (screen)->fnt_icon->descent \
+ : (screen)->whichVwin->f_descent)
+#define ScrollbarWidth(screen) ((screen)->whichVwin->sb_info.width)
+#define NormalGC(screen) ((screen)->whichVwin->normalGC)
+#define ReverseGC(screen) ((screen)->whichVwin->reverseGC)
+#define NormalBoldGC(screen) ((screen)->whichVwin->normalboldGC)
+#define ReverseBoldGC(screen) ((screen)->whichVwin->reverseboldGC)
+#define TWidth(screen) ((screen)->whichTwin->width)
+#define THeight(screen) ((screen)->whichTwin->height)
+#define TFullWidth(screen) ((screen)->whichTwin->fullwidth)
+#define TFullHeight(screen) ((screen)->whichTwin->fullheight)
+#define TekScale(screen) ((screen)->whichTwin->tekscale)
+
+#else /* NO_ACTIVE_ICON */
+
+#define IsIcon(screen) (False)
+#define VWindow(screen) ((screen)->fullVwin.window)
+#define VShellWindow XtWindow(SHELL_OF(term))
+#define TWindow(screen) ((screen)->fullTwin.window)
+#define TShellWindow XtWindow(SHELL_OF(tekWidget))
+#define Width(screen) ((screen)->fullVwin.width)
+#define Height(screen) ((screen)->fullVwin.height)
+#define FullWidth(screen) ((screen)->fullVwin.fullwidth)
+#define FullHeight(screen) ((screen)->fullVwin.fullheight)
+#define FontWidth(screen) ((screen)->fullVwin.f_width)
+#define FontHeight(screen) ((screen)->fullVwin.f_height)
+#define FontAscent(screen) ((screen)->fullVwin.f_ascent)
+#define FontDescent(screen) ((screen)->fullVwin.f_descent)
+#define ScrollbarWidth(screen) ((screen)->fullVwin.sb_info.width)
+#define NormalGC(screen) ((screen)->fullVwin.normalGC)
+#define ReverseGC(screen) ((screen)->fullVwin.reverseGC)
+#define NormalBoldGC(screen) ((screen)->fullVwin.normalboldGC)
+#define ReverseBoldGC(screen) ((screen)->fullVwin.reverseboldGC)
+#define TWidth(screen) ((screen)->fullTwin.width)
+#define THeight(screen) ((screen)->fullTwin.height)
+#define TFullWidth(screen) ((screen)->fullTwin.fullwidth)
+#define TFullHeight(screen) ((screen)->fullTwin.fullheight)
+#define TekScale(screen) ((screen)->fullTwin.tekscale)
+
+#endif /* NO_ACTIVE_ICON */
+
+#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 */
+ short fontsize; /* character size, 0-3 */
+ 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
+
+#endif /* included_ptyx_h */
diff --git a/vendor/x11iraf/xgterm/resize.c b/vendor/x11iraf/xgterm/resize.c
new file mode 100644
index 00000000..f13f9fdd
--- /dev/null
+++ b/vendor/x11iraf/xgterm/resize.c
@@ -0,0 +1,584 @@
+/*
+ * $XConsortium: resize.c,v 1.29 93/09/20 17:42:18 hersh 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.
+ */
+
+
+/* resize.c */
+
+#include <X11/Xos.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#if defined(att) || (defined(SYSV) && defined(i386))
+#define ATT
+#endif
+
+#ifdef SVR4
+#ifndef SYSV
+#define SYSV
+#endif
+#define ATT
+#endif
+
+#ifdef ATT
+#define USE_USG_PTYS
+#endif
+
+#ifdef APOLLO_SR9
+#define CANT_OPEN_DEV_TTY
+#endif
+
+#ifdef _IBMR2
+#define CANT_OPEN_DEV_TTY
+#endif
+
+#ifdef macII
+#define USE_SYSV_TERMIO
+#undef SYSV /* pretend to be bsd */
+#endif /* macII */
+
+#ifdef SCO
+#define USE_TERMCAP
+#define USE_TERMINFO
+#endif
+
+#if defined(SYSV) || defined(linux)
+#define USE_SYSV_TERMIO
+#define USE_SYSV_UTMP
+#else /* else not SYSV */
+#define USE_TERMCAP
+#endif /* SYSV */
+
+
+/*
+ * 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
+
+#ifdef MINIX
+#define USE_TERMIOS
+#endif
+
+#include <sys/ioctl.h>
+#ifdef USE_SYSV_TERMIO
+#ifdef linux
+#include <termio.h>
+#define USG
+#else
+#include <sys/termio.h>
+#endif
+#else /* else not USE_SYSV_TERMIO */
+#if defined(USE_POSIX_TERMIOS) || defined(MINIX)
+#include <termios.h>
+#else
+#include <sgtty.h>
+#endif
+#endif /* USE_SYSV_TERMIO */
+
+#ifdef USE_USG_PTYS
+#include <sys/stream.h>
+#include <sys/stropts.h>
+#ifndef SVR4
+#include <sys/ptem.h>
+#endif
+#endif
+
+#include <signal.h>
+#include <pwd.h>
+
+#ifdef SIGNALRETURNSINT
+#define SIGNAL_T int
+#else
+#define SIGNAL_T void
+#endif
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+char *getenv();
+#endif
+
+#ifdef USE_SYSV_TERMIO
+#ifdef X_NOT_POSIX
+#if !defined(SYSV) && !defined(i386)
+extern struct passwd *getpwuid(); /* does ANYBODY need this? */
+#endif /* SYSV && i386 */
+#endif /* X_NOT_POSIX */
+#endif /* USE_SYSV_TERMIO */
+
+#ifdef USE_TERMIOS
+#define USE_SYSV_TERMIO
+#define termio termios
+#define TCGETA TCGETS
+#define TCSETAW TCSETSW
+#ifndef IUCLC
+#define IUCLC 0
+#endif
+#endif
+
+#define EMULATIONS 2
+#define SUN 1
+#define TIMEOUT 10
+#define VT100 0
+
+#define SHELL_UNKNOWN 0
+#define SHELL_C 1
+#define SHELL_BOURNE 2
+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 xgterm's) */
+};
+
+char *emuname[EMULATIONS] = {
+ "VT100",
+ "Sun",
+};
+char *myname;
+int shell_type = SHELL_UNKNOWN;
+char *getsize[EMULATIONS] = {
+ "\0337\033[r\033[999;999H\033[6n",
+ "\033[18t",
+};
+#if !defined(sun) || defined(SVR4)
+#ifdef TIOCSWINSZ
+char *getwsize[EMULATIONS] = { /* size in pixels */
+ 0,
+ "\033[14t",
+};
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+char *restore[EMULATIONS] = {
+ "\0338",
+ 0,
+};
+char *setname = "";
+char *setsize[EMULATIONS] = {
+ 0,
+ "\033[8;%s;%st",
+};
+#ifdef USE_SYSV_TERMIO
+struct termio tioorig;
+#else /* not USE_SYSV_TERMIO */
+struct sgttyb sgorig;
+#endif /* USE_SYSV_TERMIO */
+char *size[EMULATIONS] = {
+ "\033[%d;%dR",
+ "\033[8;%d;%dt",
+};
+char sunname[] = "sunsize";
+int tty;
+FILE *ttyfp;
+#if !defined(sun) || defined(SVR4)
+#ifdef TIOCSWINSZ
+char *wsize[EMULATIONS] = {
+ 0,
+ "\033[4;%hd;%hdt",
+};
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+
+char *strindex ();
+
+SIGNAL_T onintr();
+
+/*
+ resets termcap string to reflect current screen size
+ */
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ register char *ptr, *env;
+ register int emu = VT100;
+ char *shell;
+ struct passwd *pw;
+ int i;
+ int rows, cols;
+#ifdef USE_SYSV_TERMIO
+ struct termio tio;
+#else /* not USE_SYSV_TERMIO */
+ struct sgttyb sg;
+#endif /* USE_SYSV_TERMIO */
+#ifdef USE_TERMCAP
+ char termcap [1024];
+ char newtc [1024];
+#endif /* USE_TERMCAP */
+ char buf[BUFSIZ];
+#if defined(sun) && !defined(SVR4)
+#ifdef TIOCSSIZE
+ struct ttysize ts;
+#endif /* TIOCSSIZE */
+#else /* sun */
+#ifdef TIOCSWINSZ
+ struct winsize ws;
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+ char *name_of_tty;
+#ifdef CANT_OPEN_DEV_TTY
+ extern char *ttyname();
+#endif
+
+ ptr = strrchr(myname = argv[0], '/');
+ if(ptr)
+ myname = ptr + 1;
+ 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 xgterm uses.
+ */
+ if (((ptr = getenv("SHELL")) == NULL || *ptr == 0) &&
+ (((pw = getpwuid(getuid())) == NULL) ||
+ *(ptr = pw->pw_shell) == 0))
+ /* this is the same default that xgterm uses */
+ ptr = "/bin/sh";
+
+ shell = strrchr(ptr, '/');
+ if(shell)
+ shell++;
+ else
+ shell = 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 = "xgterm";
+ if(SHELL_BOURNE == shell_type)
+ setname = "TERM=xterm;\nexport TERM;\n";
+ else
+ setname = "setenv TERM xterm;\n";
+ }
+ if(tgetent (termcap, env) <= 0) {
+ fprintf(stderr, "%s: Can't get entry \"%s\"\n",
+ myname, env);
+ exit(1);
+ }
+#endif /* USE_TERMCAP */
+#ifdef USE_TERMINFO
+ if(!(env = getenv("TERM")) || !*env) {
+ env = "xterm";
+ if(SHELL_BOURNE == shell_type)
+ setname = "TERM=xterm;\nexport TERM;\n";
+ else setname = "setenv TERM xterm;\n";
+ }
+#endif /* USE_TERMINFO */
+
+#ifdef USE_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;
+#else /* else not USE_SYSV_TERMIO */
+ ioctl (tty, TIOCGETP, &sgorig);
+ sg = sgorig;
+ sg.sg_flags |= RAW;
+ sg.sg_flags &= ~ECHO;
+#endif /* USE_SYSV_TERMIO */
+ signal(SIGINT, onintr);
+ signal(SIGQUIT, onintr);
+ signal(SIGTERM, onintr);
+#ifdef USE_SYSV_TERMIO
+ ioctl (tty, TCSETAW, &tio);
+#else /* not USE_SYSV_TERMIO */
+ ioctl (tty, TIOCSETP, &sg);
+#endif /* USE_SYSV_TERMIO */
+
+ 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(sun) && !defined(SVR4)
+#ifdef TIOCGSIZE
+ /* finally, set the tty's window size */
+ if (ioctl (tty, TIOCGSIZE, &ts) != -1) {
+ ts.ts_lines = rows;
+ ts.ts_cols = cols;
+ ioctl (tty, TIOCSSIZE, &ts);
+ }
+#endif /* TIOCGSIZE */
+#else /* sun */
+#ifdef TIOCGWINSZ
+ /* 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], &ws.ws_xpixel, &ws.ws_ypixel) != 2) {
+ fprintf(stderr, "%s: Can't get window size\r\n", myname);
+ onintr(0);
+ }
+ ws.ws_row = rows;
+ ws.ws_col = cols;
+ ioctl (tty, TIOCSWINSZ, &ws);
+ } else if (ioctl (tty, TIOCGWINSZ, &ws) != -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"
+ struct winsize values, and multiplying by these ratios...*/
+ if (ws.ws_col != 0)
+ ws.ws_xpixel = cols * (ws.ws_xpixel / ws.ws_col);
+ if (ws.ws_row != 0)
+ ws.ws_ypixel = rows * (ws.ws_ypixel / ws.ws_row);
+ ws.ws_row = rows;
+ ws.ws_col = cols;
+ ioctl (tty, TIOCSWINSZ, &ws);
+ }
+#endif /* TIOCGWINSZ */
+#endif /* sun */
+
+#ifdef USE_SYSV_TERMIO
+ ioctl (tty, TCSETAW, &tioorig);
+#else /* not USE_SYSV_TERMIO */
+ ioctl (tty, TIOCSETP, &sgorig);
+#endif /* USE_SYSV_TERMIO */
+ signal(SIGINT, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+
+#ifdef USE_TERMCAP
+ /* update termcap string */
+ /* first do columns */
+ if ((ptr = strindex (termcap, "co#")) == NULL) {
+ fprintf(stderr, "%s: No `co#'\n", myname);
+ exit (1);
+ }
+
+ i = ptr - termcap + 3;
+ strncpy (newtc, termcap, i);
+ sprintf (newtc + i, "%d", cols);
+ ptr = strchr(ptr, ':');
+ strcat (newtc, ptr);
+
+ /* now do lines */
+ if ((ptr = strindex (newtc, "li#")) == NULL) {
+ fprintf(stderr, "%s: No `li#'\n", myname);
+ exit (1);
+ }
+
+ i = ptr - newtc + 3;
+ strncpy (termcap, newtc, i);
+ sprintf (termcap + i, "%d", rows);
+ ptr = strchr(ptr, ':');
+ strcat (termcap, ptr);
+#endif /* USE_TERMCAP */
+
+ if(SHELL_BOURNE == shell_type) {
+
+#ifdef USE_TERMCAP
+ printf ("%sTERMCAP='%s';\n",
+ setname, termcap);
+#endif /* USE_TERMCAP */
+#ifdef USE_TERMINFO
+#ifndef SVR4
+ printf ("%sCOLUMNS=%d;\nLINES=%d;\nexport COLUMNS LINES;\n",
+ setname, cols, rows);
+#endif /* !SVR4 */
+#endif /* USE_TERMINFO */
+
+ } else { /* not Bourne shell */
+
+#ifdef USE_TERMCAP
+ printf ("set noglob;\n%ssetenv TERMCAP '%s';\nunset noglob;\n",
+ setname, termcap);
+#endif /* USE_TERMCAP */
+#ifdef USE_TERMINFO
+#ifndef SVR4
+ printf ("set noglob;\n%ssetenv COLUMNS '%d';\nsetenv LINES '%d';\nunset noglob;\n",
+ setname, cols, rows);
+#endif /* !SVR4 */
+#endif /* USE_TERMINFO */
+ }
+ exit(0);
+}
+
+char *strindex (s1, s2)
+/*
+ returns a pointer to the first occurrence of s2 in s1, or NULL if there are
+ none.
+ */
+register char *s1, *s2;
+{
+ register char *s3;
+ int s2len = strlen (s2);
+
+ while ((s3 = strchr(s1, *s2)) != NULL)
+ {
+ if (strncmp (s3, s2, s2len) == 0) return (s3);
+ s1 = ++s3;
+ }
+ return (NULL);
+}
+
+checkdigits(str)
+register char *str;
+{
+ while(*str) {
+ if(!isdigit(*str))
+ return(0);
+ str++;
+ }
+ return(1);
+}
+
+readstring(fp, buf, str)
+ register FILE *fp;
+ register char *buf;
+ char *str;
+{
+ register int last, c;
+ SIGNAL_T timeout();
+#if !defined(USG) && !defined(MINIX) && !defined(SCO)
+ struct itimerval it;
+#endif
+
+ signal(SIGALRM, timeout);
+#if defined(USG) || defined(MINIX) || defined(SCO)
+ alarm (TIMEOUT);
+#else
+ memset((char *)&it, 0, sizeof(struct itimerval));
+ it.it_value.tv_sec = TIMEOUT;
+ setitimer(ITIMER_REAL, &it, (struct itimerval *)NULL);
+#endif
+ if ((c = getc(fp)) == 0233) { /* meta-escape, CSI */
+ *buf++ = c = '\033';
+ *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(MINIX) || defined(SCO)
+ alarm (0);
+#else
+ memset((char *)&it, 0, sizeof(struct itimerval));
+ setitimer(ITIMER_REAL, &it, (struct itimerval *)NULL);
+#endif
+ *buf = 0;
+}
+
+Usage()
+{
+ fprintf(stderr, strcmp(myname, sunname) == 0 ?
+ "Usage: %s [rows cols]\n" :
+ "Usage: %s [-u] [-c] [-s [rows cols]]\n", myname);
+ exit(1);
+}
+
+SIGNAL_T
+timeout(sig)
+ int sig;
+{
+ fprintf(stderr, "%s: Time out occurred\r\n", myname);
+ onintr(sig);
+}
+
+/* ARGSUSED */
+SIGNAL_T
+onintr(sig)
+ int sig;
+{
+#ifdef USE_SYSV_TERMIO
+ ioctl (tty, TCSETAW, &tioorig);
+#else /* not USE_SYSV_TERMIO */
+ ioctl (tty, TIOCSETP, &sgorig);
+#endif /* USE_SYSV_TERMIO */
+ exit(1);
+}
diff --git a/vendor/x11iraf/xgterm/resize.man b/vendor/x11iraf/xgterm/resize.man
new file mode 100644
index 00000000..e0c83a64
--- /dev/null
+++ b/vendor/x11iraf/xgterm/resize.man
@@ -0,0 +1,72 @@
+.TH RESIZE 1 "Release 5" "X Version 11"
+.SH NAME
+resize \- utility to set TERMCAP and terminal settings to current window size
+.SH SYNOPSIS
+.B resize
+[-u] [\-s [row col]]
+.SH DESCRIPTION
+.I Resize
+prints a shell command for setting the TERM and TERMCAP environment variables
+to indicate the current size of \fIxgterm\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 resize`'
+.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
+ $ . /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 that Sun console escape sequences will be used
+instead of the special \fIxgterm\fP escape code. If \fIrows\fP and
+\fIcolumns\fP are given, \fIresize\fP will ask the \fIxgterm\fP to resize
+itself. However, the window manager may choose to disallow the change.
+.SH FILES
+/etc/termcap for the base termcap entry to modify.
+.br
+~/.cshrc user's alias for the command.
+.SH "SEE ALSO"
+csh(1), tset(1), xgterm(1)
+.SH AUTHORS
+Mark Vandevoorde (MIT-Athena), Edward Moy (Berkeley)
+.br
+Copyright (c) 1984, 1985 by Massachusetts Institute of Technology.
+.br
+See
+.IR X (1)
+for a complete copyright notice.
+.SH BUGS
+The \fI-u\fP or \fI-c\fP must appear to the left of \fI-s\fP if both are
+specified.
+.PP
+There should be some global notion of display size; termcap and
+terminfo need to be rethought in the context of window systems.
+(Fixed in 4.3BSD, and Ultrix-32 1.2)
diff --git a/vendor/x11iraf/xgterm/screen.c b/vendor/x11iraf/xgterm/screen.c
new file mode 100644
index 00000000..0928daa9
--- /dev/null
+++ b/vendor/x11iraf/xgterm/screen.c
@@ -0,0 +1,771 @@
+/*
+ * $XConsortium: screen.c,v 1.33 94/04/02 17:34:36 gildea 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.
+ */
+
+/* screen.c */
+
+#include "ptyx.h"
+#include "error.h"
+#include "data.h"
+
+#include <stdio.h>
+#include <signal.h>
+#ifdef SVR4
+#include <termios.h>
+#else
+#include <sys/ioctl.h>
+#endif
+
+#ifdef att
+#include <sys/termio.h>
+#include <sys/stream.h> /* get typedef used in ptem.h */
+#include <sys/ptem.h>
+#endif
+
+#ifdef MINIX
+#include <termios.h>
+#endif
+
+
+ScrnBuf Allocate (nrow, ncol, addr)
+/*
+ allocates memory for a 2-dimensional array of chars and returns a pointer
+ thereto
+ each line is formed from a pair of char arrays. The first (even) one is
+ the actual character array and the second (odd) one is the attributes.
+> each line is formed from four char arrays. The first one is the actual
+> character array, the second one is the attributes, the third is the
+> foreground color, and the fourth is the background color.
+ */
+register int nrow, ncol;
+Char **addr;
+{
+ register ScrnBuf base;
+ register Char *tmp;
+ register int i;
+
+ if ((base = (ScrnBuf) calloc ((unsigned)(nrow *= 4), sizeof (char *))) == 0)
+ SysError (ERROR_SCALLOC);
+
+ if ((tmp = (Char *)calloc((unsigned) (nrow * ncol), sizeof(char))) == 0)
+ SysError (ERROR_SCALLOC2);
+
+ *addr = tmp;
+ for (i = 0; i < nrow; i++, tmp += ncol)
+ base[i] = tmp;
+
+ 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
+Reallocate(sbuf, sbufaddr, nrow, ncol, oldrow, oldcol)
+ ScrnBuf *sbuf;
+ Char **sbufaddr;
+ int nrow, ncol, oldrow, oldcol;
+{
+ register ScrnBuf base;
+ register Char *tmp;
+ register int i, minrows, mincols;
+ Char *oldbuf;
+ int move_down = 0, move_up = 0;
+
+ if (sbuf == NULL || *sbuf == NULL)
+ return 0;
+
+ oldrow *= 4;
+ oldbuf = *sbufaddr;
+
+ /*
+ * Special case if oldcol == ncol - straight forward realloc and
+ * update of the additional lines in sbuf
+ */
+
+ /* 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.
+ */
+ nrow *= 4;
+ if (nrow < oldrow && term->misc.resizeGravity == SouthWestGravity) {
+ /* Remove lines off the top of the buffer if necessary. */
+ move_up = oldrow-nrow
+ - 4*(term->screen.max_row - term->screen.cur_row);
+ if (move_up < 0)
+ move_up = 0;
+ /* Overlapping memmove here! */
+ memmove( *sbuf, *sbuf+move_up,
+ (oldrow-move_up)*sizeof((*sbuf)[0]) );
+ }
+ *sbuf = (ScrnBuf) realloc((char *) (*sbuf),
+ (unsigned) (nrow * sizeof(char *)));
+ if (*sbuf == 0)
+ SysError(ERROR_RESIZE);
+ base = *sbuf;
+
+ /*
+ * create the new buffer space and copy old buffer contents there
+ * line by line.
+ */
+ if ((tmp = (Char *)calloc((unsigned) (nrow * ncol), sizeof(char))) == 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, 4*term->screen.savedlines);
+ tmp += ncol*move_down;
+ }
+ for (i = 0; i < minrows; i++, tmp += ncol) {
+ memmove( tmp, base[i], mincols);
+ }
+ /*
+ * update the pointers in sbuf
+ */
+ for (i = 0, tmp = *sbufaddr; i < nrow; i++, tmp += ncol)
+ base[i] = tmp;
+
+ /* Now free the old buffer */
+ free(oldbuf);
+
+ return move_down ? move_down/4 : -move_up/4; /* convert to rows */
+}
+
+ScreenWrite (screen, str, flags, cur_fg, cur_bg, length)
+/*
+ Writes str into buf at row row and column col. Characters are set to match
+ flags.
+ */
+TScreen *screen;
+char *str;
+register unsigned flags;
+register unsigned cur_fg, cur_bg;
+register int length; /* length of string */
+{
+ register Char *attrs, *attrs0, *fgs, *bgs;
+ register int avail = screen->max_col - screen->cur_col + 1;
+ register Char *col;
+ register int wrappedbit;
+
+ if (length > avail)
+ length = avail;
+ if (length <= 0)
+ return;
+
+ col = screen->buf[avail = 4 * screen->cur_row] + screen->cur_col;
+ attrs = attrs0 = screen->buf[avail + 1] + screen->cur_col;
+ fgs = screen->buf[avail + 2] + screen->cur_col;
+ bgs = screen->buf[avail + 3] + screen->cur_col;
+
+ wrappedbit = *attrs0&LINEWRAPPED;
+ flags &= ATTRIBUTES;
+ flags |= CHARDRAWN;
+ memmove( col, str, length);
+ while(length-- > 0)
+ {
+ *attrs++ = flags;
+ *fgs++ = cur_fg;
+ *bgs++ = cur_bg;
+ }
+ if (wrappedbit)
+ *attrs0 |= LINEWRAPPED;
+}
+
+ScrnInsertLine (sb, last, where, n, size)
+/*
+ Inserts n blank lines at sb + where, treating last as a bottom margin.
+ Size is the size of each entry in sb.
+ Requires: 0 <= where < where + n <= last
+ n <= MAX_ROWS
+ */
+register ScrnBuf sb;
+int last;
+register int where, n, size;
+{
+ register int i;
+ char *save [4 * MAX_ROWS];
+
+
+ /* save n lines at bottom */
+ memmove( (char *) save, (char *) &sb [4 * (last -= n - 1)],
+ 4 * sizeof (char *) * n);
+
+ /* clear contents of old rows */
+ for (i = 4 * n - 1; i >= 0; i--)
+ bzero ((char *) save [i], size);
+
+ /*
+ * WARNING, overlapping copy operation. Move down lines (pointers).
+ *
+ * +----|---------|--------+
+ *
+ * is copied in the array to:
+ *
+ * +--------|---------|----+
+ */
+ memmove( (char *) &sb [4 * (where + n)], (char *) &sb [4 * where],
+ 4 * sizeof (char *) * (last - where));
+
+ /* reuse storage for new lines at where */
+ memmove( (char *) &sb[4 * where], (char *)save, 4 * sizeof(char *) * n);
+}
+
+
+ScrnDeleteLine (sb, last, where, n, size)
+/*
+ Deletes n lines at sb + where, treating last as a bottom margin.
+ Size is the size of each entry in sb.
+ Requires 0 <= where < where + n < = last
+ n <= MAX_ROWS
+ */
+register ScrnBuf sb;
+register int n, last, size;
+int where;
+{
+ register int i;
+ char *save [4 * MAX_ROWS];
+
+ /* save n lines at where */
+ memmove( (char *)save, (char *) &sb[4 * where], 4 * sizeof(char *) * n);
+
+ /* clear contents of old rows */
+ for (i = 4 * n - 1 ; i >= 0 ; i--)
+ bzero ((char *) save [i], size);
+
+ /* move up lines */
+ memmove( (char *) &sb[4 * where], (char *) &sb[4 * (where + n)],
+ 4 * sizeof (char *) * ((last -= n - 1) - where));
+
+ /* reuse storage for new bottom lines */
+ memmove( (char *) &sb[4 * last], (char *)save,
+ 4 * sizeof(char *) * n);
+}
+
+
+ScrnInsertChar (sb, row, col, n, size)
+ /*
+ Inserts n blanks in sb at row, col. Size is the size of each row.
+ */
+ ScrnBuf sb;
+ int row, size;
+ register int col, n;
+{
+ register int i, j;
+ register Char *ptr = sb [4 * row];
+ register Char *attrs = sb [4 * row + 1];
+ int wrappedbit = attrs[0]&LINEWRAPPED;
+
+ attrs[0] &= ~LINEWRAPPED; /* make sure the bit isn't moved */
+ for (i = size - 1; i >= col + n; i--) {
+ ptr[i] = ptr[j = i - n];
+ attrs[i] = attrs[j];
+ }
+
+ for (i=col; i<col+n; i++)
+ ptr[i] = ' ';
+ for (i=col; i<col+n; i++)
+ attrs[i] = CHARDRAWN;
+
+ if (wrappedbit)
+ attrs[0] |= LINEWRAPPED;
+}
+
+
+ScrnDeleteChar (sb, row, col, n, size)
+ /*
+ Deletes n characters in sb at row, col. Size is the size of each row.
+ */
+ ScrnBuf sb;
+ register int row, size;
+ register int n, col;
+{
+ register Char *ptr = sb[4 * row];
+ register Char *attrs = sb[4 * row + 1];
+ register nbytes = (size - n - col);
+ int wrappedbit = attrs[0]&LINEWRAPPED;
+
+ memmove( ptr + col, ptr + col + n, nbytes);
+ memmove( attrs + col, attrs + col + n, nbytes);
+ bzero (ptr + size - n, n);
+ bzero (attrs + size - n, n);
+ if (wrappedbit)
+ attrs[0] |= LINEWRAPPED;
+}
+
+
+ScrnRefresh (screen, toprow, leftcol, nrows, ncols, force)
+/*
+ Repaints the area enclosed by the parameters.
+ Requires: (toprow, leftcol), (toprow + nrows, leftcol + ncols) are
+ coordinates of characters in screen;
+ nrows and ncols positive.
+ */
+register TScreen *screen;
+int toprow, leftcol, nrows, ncols;
+Boolean force; /* ... leading/trailing spaces */
+{
+ int y = toprow * FontHeight(screen) + screen->border +
+ screen->fnt_norm->ascent;
+ register int row;
+ register int topline = screen->topline;
+ int maxrow = toprow + nrows - 1;
+ int scrollamt = screen->scroll_amt;
+ int max = screen->max_row;
+
+ 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++) {
+ register Char *chars;
+ register Char *attrs;
+ register Char *fgs, *bgs;
+ register int col = leftcol;
+ int maxcol = leftcol + ncols - 1;
+ int lastind;
+ int flags;
+ int fg, bg;
+ int x, n;
+ GC gc;
+ Pixel fg_pix, bg_pix;
+ Boolean hilite;
+
+ if (row < screen->top_marg || row > screen->bot_marg)
+ lastind = row;
+ else
+ lastind = row - scrollamt;
+
+ if (lastind < 0 || lastind > max)
+ continue;
+
+ chars = screen->buf [4 * (lastind + topline)];
+ attrs = screen->buf [4 * (lastind + topline) + 1];
+ fgs = screen->buf [4 * (lastind + topline) + 2];
+ bgs = screen->buf [4 * (lastind + topline) + 3];
+
+ if (row < screen->startHRow || row > screen->endHRow ||
+ (row == screen->startHRow && maxcol < screen->startHCol) ||
+ (row == screen->endHRow && col >= screen->endHCol))
+ {
+ /* row does not intersect selection; don't hilite */
+ if (!force) {
+ while (col <= maxcol && (attrs[col] & ~BOLD) == 0 &&
+ (chars[col] & ~040) == 0)
+ col++;
+
+ while (col <= maxcol && (attrs[maxcol] & ~BOLD) == 0 &&
+ (chars[maxcol] & ~040) == 0)
+ maxcol--;
+ }
+ hilite = False;
+ }
+ else {
+ /* row intersects selection; split into pieces of single type */
+ if (row == screen->startHRow && col < screen->startHCol) {
+ ScrnRefresh(screen, row, col, 1, screen->startHCol - col,
+ force);
+ col = screen->startHCol;
+ }
+ if (row == screen->endHRow && maxcol >= screen->endHCol) {
+ ScrnRefresh(screen, row, screen->endHCol, 1,
+ maxcol - screen->endHCol + 1, force);
+ maxcol = screen->endHCol - 1;
+ }
+ /* remaining piece should be hilited */
+ hilite = True;
+ }
+
+ if (col > maxcol) continue;
+
+ flags = attrs[col];
+ fg = fgs[col];
+ bg = bgs[col];
+
+ fg_pix = (flags & FG_COLOR) ? screen->colors[fg] :
+ screen->foreground;
+ bg_pix = (flags & BG_COLOR) ? screen->colors[bg] :
+ term->core.background_pixel;
+
+ if ( (!hilite && (flags & INVERSE) != 0) ||
+ (hilite && (flags & INVERSE) == 0) ) {
+ if (flags & BOLD) gc = screen->reverseboldGC;
+ else gc = screen->reverseGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, gc, bg_pix);
+ XSetBackground(screen->display, gc, fg_pix);
+ }
+
+ } else {
+ if (flags & BOLD) gc = screen->normalboldGC;
+ else gc = screen->normalGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, gc, fg_pix);
+ XSetBackground(screen->display, gc, bg_pix);
+ }
+ }
+
+ x = CursorX(screen, col);
+ lastind = col;
+
+ for (; col <= maxcol; col++) {
+ if (attrs[col] != flags ||
+ (term->misc.dynamicColors &&
+ ((flags & FG_COLOR && fgs[col] != fg) ||
+ (flags & BG_COLOR && bgs[col] != bg)))) {
+
+ XDrawImageString(screen->display, TextWindow(screen),
+ gc, x, y, (char *) &chars[lastind], n = col - lastind);
+ if((flags & BOLD) && screen->enbolden)
+ XDrawString(screen->display, TextWindow(screen),
+ gc, x + 1, y, (char *) &chars[lastind], n);
+ if((flags & UNDERLINE) && screen->underline)
+ XDrawLine(screen->display, TextWindow(screen),
+ gc, x, y+1, x+n*FontWidth(screen), y+1);
+
+ x += (col - lastind) * FontWidth(screen);
+
+ lastind = col;
+
+ flags = attrs[col];
+ fg = fgs[col];
+ bg = bgs[col];
+
+ fg_pix = (flags & FG_COLOR) ? screen->colors[fg]
+ : screen->foreground;
+ bg_pix = (flags & BG_COLOR) ? screen->colors[bg]
+ : term->core.background_pixel;
+
+ if ( (!hilite && (flags & INVERSE) != 0) ||
+ (hilite && (flags & INVERSE) == 0) ) {
+ if (flags & BOLD) gc = screen->reverseboldGC;
+ else gc = screen->reverseGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, gc, bg_pix);
+ XSetBackground(screen->display, gc, fg_pix);
+ }
+ } else {
+ if (flags & BOLD) gc = screen->normalboldGC;
+ else gc = screen->normalGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, gc, fg_pix);
+ XSetBackground(screen->display, gc, bg_pix);
+ }
+ }
+ }
+
+ if(chars[col] == 0)
+ chars[col] = ' ';
+ }
+
+
+ if ( (!hilite && (flags & INVERSE) != 0) ||
+ (hilite && (flags & INVERSE) == 0) ) {
+ if (flags & BOLD) gc = screen->reverseboldGC;
+ else gc = screen->reverseGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, gc, bg_pix);
+ XSetBackground(screen->display, gc, fg_pix);
+ }
+
+ } else {
+ if (flags & BOLD) gc = screen->normalboldGC;
+ else gc = screen->normalGC;
+
+ if (term->misc.dynamicColors) {
+ XSetForeground(screen->display, gc, fg_pix);
+ XSetBackground(screen->display, gc, bg_pix);
+ }
+ }
+
+ XDrawImageString(screen->display, TextWindow(screen), gc,
+ x, y, (char *) &chars[lastind], n = col - lastind);
+ if((flags & BOLD) && screen->enbolden)
+ XDrawString(screen->display, TextWindow(screen), gc,
+ x + 1, y, (char *) &chars[lastind], n);
+ if((flags & UNDERLINE) && screen->underline)
+ XDrawLine(screen->display, TextWindow(screen), gc,
+ x, y+1, x + n * FontWidth(screen), y+1);
+ }
+}
+
+ClearBufRows (screen, first, last)
+/*
+ Sets the rows first though last of the buffer of screen to spaces.
+ Requires first <= last; first, last are rows of screen->buf.
+ */
+register TScreen *screen;
+register int first, last;
+{
+ first *= 4;
+ last = 4 * last + 3;
+ while (first <= last)
+ bzero (screen->buf [first++], (screen->max_col + 1));
+}
+
+/*
+ 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
+ */
+ScreenResize (screen, width, height, flags)
+ register TScreen *screen;
+ int width, height;
+ unsigned *flags;
+{
+ int rows, cols;
+ int border = 2 * screen->border;
+ int move_down_by;
+#if defined(sun) && !defined(SVR4)
+#ifdef TIOCSSIZE
+ struct ttysize ts;
+#endif /* TIOCSSIZE */
+#else /* sun */
+#ifdef TIOCSWINSZ
+ struct winsize ws;
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+ Window tw = TextWindow (screen);
+
+ /* clear the right and bottom internal border because of NorthWest
+ gravity might have left junk on the right and bottom edges */
+ XClearArea (screen->display, tw,
+ width - screen->border, 0, /* right edge */
+ screen->border, height, /* from top to bottom */
+ False);
+ XClearArea (screen->display, tw,
+ 0, height - screen->border, /* bottom */
+ width, screen->border, /* all across the bottom */
+ False);
+
+ /* round so that it is unlikely the screen will change size on */
+ /* small mouse movements. */
+ rows = (height + FontHeight(screen) / 2 - border) /
+ FontHeight(screen);
+ cols = (width + FontWidth(screen) / 2 - border - screen->scrollbar) /
+ FontWidth(screen);
+ if (rows < 1) rows = 1;
+ if (cols < 1) cols = 1;
+
+ /* update buffers if the screen has changed size */
+ if (screen->max_row != rows - 1 || screen->max_col != cols - 1) {
+ register int savelines = screen->scrollWidget ?
+ screen->savelines : 0;
+ int delta_rows = rows - (screen->max_row + 1);
+
+ 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, (Char **)&screen->abuf_address,
+ rows, cols, screen->max_row + 1, screen->max_col + 1);
+ move_down_by = Reallocate(&screen->allbuf,
+ (Char **)&screen->sbuf_address,
+ rows + savelines, cols,
+ screen->max_row + 1 + savelines,
+ screen->max_col + 1);
+ screen->buf = &screen->allbuf[4 * savelines];
+
+ screen->max_row += delta_rows;
+ screen->max_col = 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;
+ screen->cur_row += move_down_by;
+ screen->cursor_row += move_down_by;
+ ScrollSelection(screen, move_down_by);
+
+ if (screen->alternate)
+ SwitchBufPtrs(screen); /* put the pointers back */
+ }
+
+ /* adjust scrolling region */
+ screen->top_marg = 0;
+ screen->bot_marg = screen->max_row;
+ *flags &= ~ORIGIN;
+
+ if (screen->cur_row > screen->max_row)
+ screen->cur_row = screen->max_row;
+ if (screen->cur_col > screen->max_col)
+ screen->cur_col = screen->max_col;
+
+ screen->fullVwin.height = height - border;
+ screen->fullVwin.width = width - border - screen->scrollbar;
+
+ } else if(FullHeight(screen) == height && FullWidth(screen) == width)
+ return(0); /* nothing has changed at all */
+
+ if (screen->scrollWidget) {
+ if (term->misc.sb_right) {
+ ResizeScrollBar(screen->scrollWidget, width -
+ screen->scrollWidget->core.width -
+ screen->scrollWidget->core.border_width, 0, height -1);
+ } else {
+ ResizeScrollBar(screen->scrollWidget, -1, -1, height);
+ }
+ }
+
+ screen->fullVwin.fullheight = height;
+ screen->fullVwin.fullwidth = width;
+ ResizeSelection (screen, rows, cols);
+#if defined(sun) && !defined(SVR4)
+#ifdef TIOCSSIZE
+ /* Set tty's idea of window size */
+ ts.ts_lines = rows;
+ ts.ts_cols = cols;
+ ioctl (screen->respond, TIOCSSIZE, &ts);
+#ifdef SIGWINCH
+ if(screen->pid > 1) {
+ int pgrp;
+
+ if (ioctl (screen->respond, TIOCGPGRP, &pgrp) != -1)
+ kill_process_group(pgrp, SIGWINCH);
+ }
+#endif /* SIGWINCH */
+#endif /* TIOCSSIZE */
+#else /* sun */
+#ifdef TIOCSWINSZ
+ /* Set tty's idea of window size */
+ ws.ws_row = rows;
+ ws.ws_col = cols;
+ ws.ws_xpixel = width;
+ ws.ws_ypixel = height;
+ ioctl (screen->respond, TIOCSWINSZ, (char *)&ws);
+#ifdef notdef /* change to SIGWINCH if this doesn't work for you */
+ if(screen->pid > 1) {
+ int pgrp;
+
+ if (ioctl (screen->respond, TIOCGPGRP, &pgrp) != -1)
+ kill_process_group(pgrp, SIGWINCH);
+ }
+#endif /* SIGWINCH */
+#endif /* TIOCSWINSZ */
+#endif /* sun */
+ return (0);
+}
+
+/*
+ * Sets the attributes from the row, col, to row, col + length according to
+ * mask and value. The bits in the attribute byte specified by the mask are
+ * set to the corresponding bits in the value byte. If length would carry us
+ * over the end of the line, it stops at the end of the line.
+ */
+void
+ScrnSetAttributes(screen, row, col, mask, value, length)
+TScreen *screen;
+int row, col;
+unsigned mask, value;
+register int length; /* length of string */
+{
+ register Char *attrs;
+ register int avail = screen->max_col - col + 1;
+
+ if (length > avail)
+ length = avail;
+ if (length <= 0)
+ return;
+ attrs = screen->buf[4 * row + 1] + col;
+ value &= mask; /* make sure we only change the bits allowed by mask*/
+ while(length-- > 0) {
+ *attrs &= ~mask; /* clear the bits */
+ *attrs |= value; /* copy in the new values */
+ attrs++;
+ }
+}
+
+/*
+ * Gets the attributes from the row, col, to row, col + length into the
+ * supplied array, which is assumed to be big enough. If length would carry us
+ * over the end of the line, it stops at the end of the line. Returns
+ * the number of bytes of attributes (<= length)
+ */
+int
+ScrnGetAttributes(screen, row, col, str, length)
+TScreen *screen;
+int row, col;
+Char *str;
+register int length; /* length of string */
+{
+ register Char *attrs;
+ register int avail = screen->max_col - col + 1;
+ int ret;
+
+ if (length > avail)
+ length = avail;
+ if (length <= 0)
+ return 0;
+ ret = length;
+ attrs = screen->buf[4 * row + 1] + col;
+ while(length-- > 0) {
+ *str++ = *attrs++;
+ }
+ return ret;
+}
+Bool
+non_blank_line(sb, row, col, len)
+ScrnBuf sb;
+register int row, col, len;
+{
+ register int i;
+ register Char *ptr = sb [4 * row];
+
+ for (i = col; i < len; i++) {
+ if (ptr[i])
+ return True;
+ }
+ return False;
+}
diff --git a/vendor/x11iraf/xgterm/scrollbar.c b/vendor/x11iraf/xgterm/scrollbar.c
new file mode 100644
index 00000000..ca077b43
--- /dev/null
+++ b/vendor/x11iraf/xgterm/scrollbar.c
@@ -0,0 +1,531 @@
+/*
+ * $XConsortium: scrollbar.c,v 1.44 94/04/02 12:42:01 gildea 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.
+ */
+
+#include "ptyx.h" /* gets Xt headers, too */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <X11/Xatom.h>
+
+#include <X11/StringDefs.h>
+#include <X11/Shell.h>
+
+#include <X11/Xaw/Scrollbar.h>
+
+#include "data.h"
+#include "error.h"
+#include "menu.h"
+
+/* Event handlers */
+
+static void ScrollTextTo();
+static void ScrollTextUpDownBy();
+
+
+/* resize the text window for a terminal screen, modifying the
+ * appropriate WM_SIZE_HINTS and taking advantage of bit gravity.
+ */
+
+static void ResizeScreen(xw, min_width, min_height )
+ register XgtermWidget xw;
+ int min_width, min_height;
+{
+ register TScreen *screen = &xw->screen;
+#ifndef nothack
+ XSizeHints sizehints;
+ long supp;
+#endif
+ XtGeometryResult geomreqresult;
+ Dimension reqWidth, reqHeight, repWidth, repHeight;
+
+ /*
+ * 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 xgterm 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 xgterm.
+ */
+
+#ifndef nothack
+ /*
+ * NOTE: If you change the way any of the hints are calculated
+ * below, make sure you change the calculation both in the
+ * sizehints assignments and in the XtVaSetValues.
+ */
+
+ if (! XGetWMNormalHints(screen->display, XtWindow(XtParent(xw)),
+ &sizehints, &supp))
+ sizehints.flags = 0;
+ sizehints.base_width = min_width;
+ sizehints.base_height = min_height;
+ 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.flags |= (PBaseSize|PMinSize|PResizeInc);
+ /* These are obsolete, but old clients may use them */
+ sizehints.width = (screen->max_col + 1) * FontWidth(screen)
+ + min_width;
+ sizehints.height = (screen->max_row + 1) * FontHeight(screen)
+ + min_height;
+#endif
+
+ /*
+ * Note: width and height are not set here because they are
+ * obsolete.
+ */
+ XtVaSetValues(XtParent(xw),
+ XtNbaseWidth, min_width,
+ XtNbaseHeight, min_height,
+ XtNwidthInc, FontWidth(screen),
+ XtNheightInc, FontHeight(screen),
+ XtNminWidth, min_width + FontWidth(screen),
+ XtNminHeight, min_height + FontHeight(screen),
+ NULL);
+
+ reqWidth = (screen->max_col + 1) * FontWidth(screen) + min_width;
+ reqHeight = FontHeight(screen) * (screen->max_row + 1) + min_height;
+ geomreqresult = XtMakeResizeRequest ((Widget)xw, reqWidth, reqHeight,
+ &repWidth, &repHeight);
+
+ if (geomreqresult == XtGeometryAlmost) {
+ geomreqresult = XtMakeResizeRequest ((Widget)xw, repWidth,
+ repHeight, NULL, NULL);
+ }
+
+#ifndef nothack
+ XSetWMNormalHints(screen->display, XtWindow(XtParent(xw)), &sizehints);
+#endif
+}
+
+void DoResizeScreen (xw)
+ register XgtermWidget xw;
+{
+ int border = 2 * xw->screen.border;
+ ResizeScreen (xw, border + xw->screen.scrollbar, border);
+}
+
+
+static Widget CreateScrollBar(xw, x, y, height)
+ XgtermWidget xw;
+ int x, y, height;
+{
+ Widget scrollWidget;
+
+ static Arg argList[] = {
+ {XtNx, (XtArgVal) 0},
+ {XtNy, (XtArgVal) 0},
+ {XtNheight, (XtArgVal) 0},
+ {XtNreverseVideo, (XtArgVal) 0},
+ {XtNorientation, (XtArgVal) XtorientVertical},
+ {XtNborderWidth, (XtArgVal) 1},
+ };
+
+ argList[0].value = (XtArgVal) x;
+ argList[1].value = (XtArgVal) y;
+ argList[2].value = (XtArgVal) height;
+ argList[3].value = (XtArgVal) xw->misc.re_verse;
+
+ scrollWidget = XtCreateWidget("scrollbar", scrollbarWidgetClass,
+ (Widget)xw, argList, XtNumber(argList));
+ XtAddCallback (scrollWidget, XtNscrollProc, ScrollTextUpDownBy, 0);
+ XtAddCallback (scrollWidget, XtNjumpProc, ScrollTextTo, 0);
+ return (scrollWidget);
+}
+
+static void RealizeScrollBar (sbw, screen)
+ Widget sbw;
+ TScreen *screen;
+{
+ XtRealizeWidget (sbw);
+}
+
+
+ScrollBarReverseVideo(scrollWidget)
+ register Widget scrollWidget;
+{
+ Arg args[4];
+ int nargs = XtNumber(args);
+ unsigned long bg, fg, bdr;
+ Pixmap bdpix;
+
+ XtSetArg(args[0], XtNbackground, &bg);
+ XtSetArg(args[1], XtNforeground, &fg);
+ XtSetArg(args[2], XtNborderColor, &bdr);
+ XtSetArg(args[3], XtNborderPixmap, &bdpix);
+ XtGetValues (scrollWidget, args, nargs);
+ args[0].value = (XtArgVal) fg;
+ args[1].value = (XtArgVal) bg;
+ nargs--; /* don't set border_pixmap */
+ if (bdpix == XtUnspecifiedPixmap) { /* if not pixmap then pixel */
+ args[2].value = args[1].value; /* set border to new fg */
+ } else { /* ignore since pixmap */
+ nargs--; /* don't set border pixel */
+ }
+ XtSetValues (scrollWidget, args, nargs);
+}
+
+
+
+ScrollBarDrawThumb(scrollWidget)
+ register Widget scrollWidget;
+{
+ register TScreen *screen = &term->screen;
+ register int thumbTop, thumbHeight, totalHeight;
+
+ thumbTop = screen->topline + screen->savedlines;
+ thumbHeight = screen->max_row + 1;
+ totalHeight = thumbHeight + screen->savedlines;
+
+ XawScrollbarSetThumb(scrollWidget,
+ ((float)thumbTop) / totalHeight,
+ ((float)thumbHeight) / totalHeight);
+
+}
+
+ResizeScrollBar(scrollWidget, x, y, height)
+ register Widget scrollWidget;
+ int x, y;
+ unsigned height;
+{
+ XtConfigureWidget(scrollWidget, x, y, scrollWidget->core.width,
+ height, scrollWidget->core.border_width);
+ if (term->misc.sb_right)
+ XtMoveWidget(scrollWidget, x,y);
+ ScrollBarDrawThumb(scrollWidget);
+}
+
+WindowScroll(screen, top)
+ register TScreen *screen;
+ int top;
+{
+ register int i, lines;
+ register int scrolltop, scrollheight, refreshtop;
+ register int x = 0;
+
+ 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 > screen->max_row + 1)
+ lines = screen->max_row + 1;
+ scrollheight = screen->max_row - lines + 1;
+ if(i > 0)
+ refreshtop = scrolltop = 0;
+ else {
+ scrolltop = lines;
+ refreshtop = scrollheight;
+ }
+ x = (term->misc.sb_right? screen->border : screen->scrollbar+screen->border);
+ scrolling_copy_area(screen, scrolltop, scrollheight, -i);
+ screen->topline = top;
+
+ ScrollSelection(screen, i);
+
+ XClearArea(
+ screen->display,
+ TextWindow(screen),
+ (int) x,
+ (int) refreshtop * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) lines * FontHeight(screen),
+ FALSE);
+ ScrnRefresh(screen, refreshtop, 0, lines, screen->max_col + 1, False);
+
+ ScrollBarDrawThumb(screen->scrollWidget);
+}
+
+
+ScrollBarOn (xw, init, doalloc)
+ XgtermWidget xw;
+ int init, doalloc;
+{
+ register TScreen *screen = &xw->screen;
+ register int border = 2 * screen->border;
+ register int i;
+
+ if(screen->scrollbar)
+ return;
+
+ if (init) { /* then create it only */
+ if (screen->scrollWidget) return;
+
+ /* make it a dummy size and resize later */
+ if ((screen->scrollWidget = CreateScrollBar (xw, -1, - 1, 5))
+ == NULL) {
+ Bell();
+ return;
+ }
+
+ return;
+
+ }
+
+ if (!screen->scrollWidget) {
+ Bell ();
+ Bell ();
+ return;
+ }
+
+ if (doalloc && screen->allbuf) {
+ if((screen->allbuf =
+ (ScrnBuf) realloc((char *) screen->buf,
+ (unsigned) 4*(screen->max_row + 2 +
+ screen->savelines) *
+ sizeof(char *)))
+ == NULL)
+ Error (ERROR_SBRALLOC);
+ screen->buf = &screen->allbuf[4 * screen->savelines];
+ memmove( (char *)screen->buf, (char *)screen->allbuf,
+ 4 * (screen->max_row + 2) * sizeof (char *));
+ for(i = 4 * screen->savelines - 1 ; i >= 0 ; i--)
+ if((screen->allbuf[i] =
+ (Char *)calloc((unsigned) screen->max_col+1, sizeof(char))) ==
+ NULL)
+ Error (ERROR_SBRALLOC2);
+ }
+
+ if (term->misc.sb_right) {
+ ResizeScrollBar (screen->scrollWidget,
+ screen->fullVwin.fullwidth -
+ screen->scrollWidget->core.width -
+ screen->scrollWidget->core.border_width,
+ 0,
+ Height (screen) + border -1);
+ } else {
+ ResizeScrollBar (screen->scrollWidget, -1, -1,
+ Height (screen) + border);
+ }
+ RealizeScrollBar (screen->scrollWidget, screen);
+ screen->scrollbar = screen->scrollWidget->core.width +
+ screen->scrollWidget->core.border_width;
+
+ ScrollBarDrawThumb(screen->scrollWidget);
+ DoResizeScreen (xw);
+ XtMapWidget(screen->scrollWidget);
+ update_scrollbar ();
+ if (screen->buf) {
+ XClearWindow (screen->display, XtWindow (term));
+ Redraw ();
+ }
+}
+
+ScrollBarOff(screen)
+ register TScreen *screen;
+{
+ if(!screen->scrollbar)
+ return;
+ XtUnmapWidget(screen->scrollWidget);
+ screen->scrollbar = 0;
+ DoResizeScreen (term);
+ update_scrollbar ();
+ if (screen->buf) {
+ XClearWindow (screen->display, XtWindow (term));
+ Redraw ();
+ }
+}
+
+/*ARGSUSED*/
+static void ScrollTextTo(scrollbarWidget, client_data, call_data)
+ Widget scrollbarWidget;
+ XtPointer client_data;
+ XtPointer call_data;
+{
+ float *topPercent = (float *) call_data;
+ register TScreen *screen = &term->screen;
+ int thumbTop; /* relative to first saved line */
+ int newTopLine;
+
+/*
+ screen->savedlines : Number of offscreen text lines,
+ screen->maxrow + 1 : Number of onscreen text lines,
+ screen->topline : -Number of lines above the last screen->max_row+1 lines
+*/
+
+ thumbTop = *topPercent * (screen->savedlines + screen->max_row+1);
+ newTopLine = thumbTop - screen->savedlines;
+ WindowScroll(screen, newTopLine);
+}
+
+/*ARGSUSED*/
+static void ScrollTextUpDownBy(scrollbarWidget, client_data, call_data)
+ Widget scrollbarWidget;
+ XtPointer client_data;
+ XtPointer call_data;
+{
+ int pixels = (int) call_data;
+
+ register TScreen *screen = &term->screen;
+ register 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 (a, b)
+ char *a, *b;
+{
+ register char ca, cb;
+
+ if (!a || !b) return 0;
+
+ while (1) {
+ ca = *a;
+ cb = *b;
+ if (isascii(ca) && isupper(ca)) { /* lowercasify */
+#ifdef _tolower
+ ca = _tolower (ca);
+#else
+ ca = tolower (ca);
+#endif
+ }
+ if (ca != cb || ca == '\0') break; /* if not eq else both nul */
+ a++, b++;
+ }
+ if (cb == '\0' && (ca == '\0' || (ca == 's' && a[1] == '\0')))
+ return 1;
+
+ return 0;
+}
+
+static int params_to_pixels (screen, params, n)
+ TScreen *screen;
+ String *params;
+ int n;
+{
+ register mult = 1;
+ register char *s;
+
+ switch (n > 2 ? 2 : n) {
+ case 2:
+ s = params[1];
+ if (specialcmplowerwiths (s, "page")) {
+ mult = (screen->max_row + 1) * FontHeight(screen);
+ } else if (specialcmplowerwiths (s, "halfpage")) {
+ mult = ((screen->max_row + 1) * FontHeight(screen)) >> 1;
+ } else if (specialcmplowerwiths (s, "pixel")) {
+ mult = 1;
+ } /* else assume that it is Line */
+ mult *= atoi (params[0]);
+ break;
+ case 1:
+ mult = atoi (params[0]) * FontHeight(screen); /* lines */
+ break;
+ default:
+ mult = screen->scrolllines * FontHeight(screen);
+ break;
+ }
+
+ return mult;
+}
+
+
+/*ARGSUSED*/
+void HandleScrollForward (gw, event, params, nparams)
+ Widget gw;
+ XEvent *event;
+ String *params;
+ Cardinal *nparams;
+{
+ XgtermWidget w = (XgtermWidget) gw;
+ register TScreen *screen = &w->screen;
+
+ ScrollTextUpDownBy (gw, (XtPointer) NULL,
+ (XtPointer)params_to_pixels (screen, params, (int) *nparams));
+ return;
+}
+
+
+/*ARGSUSED*/
+void HandleScrollBack (gw, event, params, nparams)
+ Widget gw;
+ XEvent *event;
+ String *params;
+ Cardinal *nparams;
+{
+ XgtermWidget w = (XgtermWidget) gw;
+ register TScreen *screen = &w->screen;
+
+ ScrollTextUpDownBy (gw, (XtPointer) NULL,
+ (XtPointer)-params_to_pixels (screen, params, (int) *nparams));
+ return;
+}
diff --git a/vendor/x11iraf/xgterm/tabs.c b/vendor/x11iraf/xgterm/tabs.c
new file mode 100644
index 00000000..c4152355
--- /dev/null
+++ b/vendor/x11iraf/xgterm/tabs.c
@@ -0,0 +1,106 @@
+/*
+ * $XConsortium: tabs.c,v 1.4 91/05/06 17:12:18 gildea 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.
+ */
+
+/* tabs.c */
+
+#include "ptyx.h"
+
+/*
+ * This file presumes 32bits/word. This is somewhat of a crock, and should
+ * be fixed sometime.
+ */
+
+/*
+ * places tabstops at only every 8 columns
+ */
+TabReset(tabs)
+Tabs tabs;
+{
+ register 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
+ */
+TabSet(tabs, col)
+ Tabs tabs;
+ int col;
+{
+ tabs[col >> 5] |= (1 << (col & 31));
+}
+
+/*
+ * clears a tabstop at col
+ */
+TabClear(tabs, col)
+ Tabs tabs;
+ int col;
+{
+ tabs[col >> 5] &= ~(1 << (col & 31));
+}
+
+/*
+ * returns the column of the next tabstop
+ * (or MAX_TABS - 1 if there are no more).
+ * A tabstop at col is ignored.
+ */
+TabNext (tabs, col)
+ Tabs tabs;
+ int col;
+{
+ extern XgtermWidget term;
+ register TScreen *screen = &term->screen;
+
+ if(screen->curses && screen->do_wrap && (term->flags & WRAPAROUND)) {
+ Index(screen, 1);
+ col = screen->cur_col = screen->do_wrap = 0;
+ }
+ for (++col; col<MAX_TABS; ++col)
+ if (tabs[col >> 5] & (1 << (col & 31)))
+ return (col);
+
+ return (MAX_TABS - 1);
+}
+
+/*
+ * clears all tabs
+ */
+TabZonk (tabs)
+Tabs tabs;
+{
+ register int i;
+
+ for (i=0; i<TAB_ARRAY_SIZE; ++i)
+ tabs[i] = 0;
+}
diff --git a/vendor/x11iraf/xgterm/termcap b/vendor/x11iraf/xgterm/termcap
new file mode 100644
index 00000000..f69c315e
--- /dev/null
+++ b/vendor/x11iraf/xgterm/termcap
@@ -0,0 +1,27 @@
+# $XConsortium: termcap,v 1.6 91/06/24 15:08:52 gildea Exp $
+#
+vs|xterm|vs100|xterm terminal emulator (X Window System):\
+ :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:UP=\E[%dA:\
+ :al=\E[L:am:\
+ :bs:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:co#80:\
+ :cs=\E[%i%d;%dr:ct=\E[3k:\
+ :dc=\E[P:dl=\E[M:\
+ :im=\E[4h:ei=\E[4l:mi:\
+ :ho=\E[H:\
+ :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\
+ :rs=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E<:\
+ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:kb=^H:kd=\EOB:ke=\E[?1l\E>:\
+ :kl=\EOD:km:kn#4:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:\
+ :li#65:md=\E[1m:me=\E[m:mr=\E[7m:ms:nd=\E[C:pt:\
+ :sc=\E7:rc=\E8:sf=\n:so=\E[7m:se=\E[m:sr=\EM:\
+ :te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:\
+ :up=\E[A:us=\E[4m:ue=\E[m:xn:
+v2|xterms|vs100s|xterm terminal emulator, small window (X Window System):\
+ :co#80:li#24:tc=xterm:
+vb|xterm-bold|xterm with bold instead of underline:\
+ :us=\E[1m:tc=xterm:
+#
+# vi may work better with this termcap, because vi
+# doesn't use insert mode much
+vi|xterm-ic|xterm-vi|xterm with insert character instead of insert mode:\
+ :im=:ei=:mi@:ic=\E[@:tc=xterm:
diff --git a/vendor/x11iraf/xgterm/terminfo b/vendor/x11iraf/xgterm/terminfo
new file mode 100644
index 00000000..98749285
--- /dev/null
+++ b/vendor/x11iraf/xgterm/terminfo
@@ -0,0 +1,17 @@
+xterm|vs100|xterm terminal emulator,
+ ind=^J, cols#80, lines#65,
+ clear=\E[H\E[2J, cub1=^H, am, cup=\E[%i%p1%d;%p2%dH,
+ cuf1=\E[C, cuu1=\E[A, el=\E[K, ed=\E[J,
+ cud=\E[%p1%dB, cuu=\E[%p1%dA, cub=\E[%p1%dD,
+ cuf=\E[%p1%dC, km,
+ smso=\E[7m, rmso=\E[m, smul@, rmul@,
+ bold=\E[1m, rev=\E[7m, blink=@, sgr0=\E[m,
+ rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, rs2=@
+ kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, ht=^I, ri=\EM,
+ vt@, xon@, csr=\E[%i%p1%d;%p2%dr,
+ il=\E[%p1%dL, dl=\E[%p1%dM, il1=\E[L, dl1=\E[M,
+ ich=\E[%p1%d@, dch=\E[%p1%dP, ich1=\E[@, dch1=\E[P,
+ use=vt100-am,
+xterms|vs100s|xterm terminal emulator (small screen 24x80),
+ cols#80, lines#24,
+ use=xterm,
diff --git a/vendor/x11iraf/xgterm/util.c b/vendor/x11iraf/xgterm/util.c
new file mode 100644
index 00000000..f23ce8f8
--- /dev/null
+++ b/vendor/x11iraf/xgterm/util.c
@@ -0,0 +1,1111 @@
+/*
+ * $XConsortium: util.c,v 1.31 91/06/20 18:34:47 gildea 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.
+ */
+
+/* util.c */
+
+#include "ptyx.h"
+#include "data.h"
+#include "error.h"
+#include "menu.h"
+
+#include <stdio.h>
+
+static void horizontal_copy_area();
+static void vertical_copy_area();
+
+/*
+ * These routines are used for the jump scroll feature
+ */
+FlushScroll(screen)
+register TScreen *screen;
+{
+ register int i;
+ register int shift = -screen->topline;
+ register int bot = screen->max_row - shift;
+ register int refreshtop;
+ register int refreshheight;
+ register int scrolltop;
+ register 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));
+ screen->scroll_amt = 0;
+ screen->refresh_amt = 0;
+ if(refreshheight > 0) {
+ XClearArea (
+ screen->display,
+ TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ (int) refreshtop * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) refreshheight * FontHeight(screen),
+ FALSE);
+ ScrnRefresh(screen, refreshtop, 0, refreshheight,
+ screen->max_col + 1, False);
+ }
+}
+
+AddToRefresh(screen)
+register TScreen *screen;
+{
+ register int amount = screen->refresh_amt;
+ register int row = screen->cur_row;
+
+ if(amount == 0)
+ return(0);
+ if(amount > 0) {
+ register int bottom;
+
+ if(row == (bottom = screen->bot_marg) - amount) {
+ screen->refresh_amt++;
+ return(1);
+ }
+ return(row >= bottom - amount + 1 && row <= bottom);
+ } else {
+ register int top;
+
+ amount = -amount;
+ if(row == (top = screen->top_marg) + amount) {
+ screen->refresh_amt--;
+ return(1);
+ }
+ return(row <= top + amount - 1 && row >= top);
+ }
+}
+
+/*
+ * 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
+ */
+Scroll(screen, amount)
+register TScreen *screen;
+register int amount;
+{
+ register int i = screen->bot_marg - screen->top_marg + 1;
+ register int shift;
+ register int bot;
+ register int refreshtop = 0;
+ register int refreshheight;
+ register int scrolltop;
+ register int scrollheight;
+
+ if(screen->cursor_state)
+ HideCursor();
+ if (amount > i)
+ amount = i;
+ 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));
+ if (amount == i) {
+ ClearScreen(screen);
+ 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(screen->scrollWidget && !screen->alternate
+ && screen->top_marg == 0) {
+ 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) {
+ XClearArea (
+ screen->display,
+ TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ (int) refreshtop * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) refreshheight * FontHeight(screen),
+ FALSE);
+ if(refreshheight > shift)
+ refreshheight = shift;
+ }
+ }
+ if(screen->scrollWidget && !screen->alternate && screen->top_marg == 0)
+ ScrnDeleteLine(screen->allbuf, screen->bot_marg +
+ screen->savelines, 0, amount, screen->max_col + 1);
+ else
+ ScrnDeleteLine(screen->buf, screen->bot_marg, screen->top_marg,
+ amount, screen->max_col + 1);
+ if(refreshheight > 0)
+ ScrnRefresh(screen, refreshtop, 0, refreshheight,
+ screen->max_col + 1, False);
+}
+
+
+/*
+ * 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
+ */
+RevScroll(screen, amount)
+register TScreen *screen;
+register int amount;
+{
+ register int i = screen->bot_marg - screen->top_marg + 1;
+ register int shift;
+ register int bot;
+ register int refreshtop;
+ register int refreshheight;
+ register int scrolltop;
+ register int scrollheight;
+
+ if(screen->cursor_state)
+ HideCursor();
+ if (amount > i)
+ amount = i;
+ 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)
+ XClearArea (
+ screen->display,
+ TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ (int) refreshtop * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) refreshheight * FontHeight(screen),
+ FALSE);
+ }
+ ScrnInsertLine (screen->buf, screen->bot_marg, screen->top_marg,
+ amount, screen->max_col + 1);
+}
+
+/*
+ * If cursor not in scrolling region, returns. Else,
+ * inserts n blank lines at the cursor's position. Lines above the
+ * bottom margin are lost.
+ */
+InsertLine (screen, n)
+register TScreen *screen;
+register int n;
+{
+ register int i;
+ register int shift;
+ register int bot;
+ register int refreshtop;
+ register int refreshheight;
+ register int scrolltop;
+ register int scrollheight;
+
+ if (screen->cur_row < screen->top_marg ||
+ screen->cur_row > screen->bot_marg)
+ return;
+ if(screen->cursor_state)
+ HideCursor();
+ 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 > screen->max_row + 1)
+ 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)
+ XClearArea (
+ screen->display,
+ TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ (int) refreshtop * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) refreshheight * FontHeight(screen),
+ FALSE);
+ }
+ /* adjust screen->buf */
+ ScrnInsertLine(screen->buf, screen->bot_marg, screen->cur_row, n,
+ screen->max_col + 1);
+}
+
+/*
+ * If cursor not in scrolling region, returns. Else, deletes n lines
+ * at the cursor's position, lines added at bottom margin are blank.
+ */
+DeleteLine(screen, n)
+register TScreen *screen;
+register int n;
+{
+ register int i;
+ register int shift;
+ register int bot;
+ register int refreshtop;
+ register int refreshheight;
+ register int scrolltop;
+ register int scrollheight;
+
+ if (screen->cur_row < screen->top_marg ||
+ screen->cur_row > screen->bot_marg)
+ return;
+ if(screen->cursor_state)
+ HideCursor();
+ 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 > screen->max_row + 1)
+ 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)
+ XClearArea (
+ screen->display,
+ TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ (int) refreshtop * FontHeight(screen) + screen->border,
+ (unsigned) Width(screen),
+ (unsigned) refreshheight * FontHeight(screen),
+ FALSE);
+ }
+ /* adjust screen->buf */
+ if(screen->scrollWidget && !screen->alternate && screen->cur_row == 0)
+ ScrnDeleteLine(screen->allbuf, screen->bot_marg +
+ screen->savelines, 0, n, screen->max_col + 1);
+ else
+ ScrnDeleteLine(screen->buf, screen->bot_marg, screen->cur_row,
+ n, screen->max_col + 1);
+}
+
+/*
+ * Insert n blanks at the cursor's position, no wraparound
+ */
+InsertChar (screen, n)
+ register TScreen *screen;
+ register int n;
+{
+ register int cx, cy;
+
+ if(screen->cursor_state)
+ HideCursor();
+ screen->do_wrap = 0;
+ if(screen->cur_row - screen->topline <= screen->max_row) {
+ if(!AddToRefresh(screen)) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+
+ /*
+ * prevent InsertChar from shifting the end of a line over
+ * if it is being appended to
+ */
+ if (non_blank_line (screen->buf, screen->cur_row,
+ screen->cur_col, screen->max_col + 1))
+ horizontal_copy_area(screen, screen->cur_col,
+ screen->max_col+1 - (screen->cur_col+n),
+ n);
+
+ cx = CursorX (screen, screen->cur_col);
+ cy = CursorY (screen, screen->cur_row);
+
+ XFillRectangle(
+ screen->display,
+ TextWindow(screen),
+ screen->reverseGC,
+ cx, cy,
+ (unsigned) n * FontWidth(screen), (unsigned) FontHeight(screen));
+ }
+ }
+ /* adjust screen->buf */
+ ScrnInsertChar(screen->buf, screen->cur_row, screen->cur_col, n,
+ screen->max_col + 1);
+}
+
+/*
+ * Deletes n chars at the cursor's position, no wraparound.
+ */
+DeleteChar (screen, n)
+ register TScreen *screen;
+ register int n;
+{
+ register int width;
+
+ if(screen->cursor_state)
+ HideCursor();
+ screen->do_wrap = 0;
+ if (n > (width = screen->max_col + 1 - screen->cur_col))
+ n = width;
+
+ if(screen->cur_row - screen->topline <= screen->max_row) {
+ if(!AddToRefresh(screen)) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+
+ horizontal_copy_area(screen, screen->cur_col+n,
+ screen->max_col+1 - (screen->cur_col+n),
+ -n);
+
+ XFillRectangle
+ (screen->display, TextWindow(screen),
+ screen->reverseGC,
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar)
+ + Width(screen) - n*FontWidth(screen),
+ CursorY (screen, screen->cur_row), n * FontWidth(screen),
+ FontHeight(screen));
+ }
+ }
+ /* adjust screen->buf */
+ ScrnDeleteChar (screen->buf, screen->cur_row, screen->cur_col, n,
+ screen->max_col + 1);
+
+}
+
+/*
+ * Clear from cursor position to beginning of display, inclusive.
+ */
+ClearAbove (screen)
+register TScreen *screen;
+{
+ register 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)
+ XClearArea(screen->display, TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ top * FontHeight(screen) + screen->border,
+ Width(screen), height * FontHeight(screen), FALSE);
+
+ if(screen->cur_row - screen->topline <= screen->max_row)
+ ClearLeft(screen);
+ }
+ ClearBufRows(screen, 0, screen->cur_row - 1);
+}
+
+/*
+ * Clear from cursor position to end of display, inclusive.
+ */
+ClearBelow (screen)
+register TScreen *screen;
+{
+ register top;
+
+ ClearRight(screen);
+ if((top = screen->cur_row - screen->topline) <= screen->max_row) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ if(++top <= screen->max_row)
+ XClearArea(screen->display, TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ top * FontHeight(screen) + screen->border,
+ Width(screen), (screen->max_row - top + 1) *
+ FontHeight(screen), FALSE);
+ }
+ ClearBufRows(screen, screen->cur_row + 1, screen->max_row);
+}
+
+/*
+ * Clear last part of cursor's line, inclusive.
+ */
+ClearRight (screen)
+register TScreen *screen;
+{
+ if(screen->cursor_state)
+ HideCursor();
+ screen->do_wrap = 0;
+ if(screen->cur_row - screen->topline <= screen->max_row) {
+ if(!AddToRefresh(screen)) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ XFillRectangle(screen->display, TextWindow(screen),
+ screen->reverseGC,
+ CursorX(screen, screen->cur_col),
+ CursorY(screen, screen->cur_row),
+ Width(screen) - screen->cur_col * FontWidth(screen),
+ FontHeight(screen));
+ }
+ }
+ memset(screen->buf [4 * screen->cur_row] + screen->cur_col, 0,
+ (screen->max_col - screen->cur_col + 1));
+ memset(screen->buf [4 * screen->cur_row + 1] + screen->cur_col, 0,
+ (screen->max_col - screen->cur_col + 1));
+ memset(screen->buf [4 * screen->cur_row + 2] + screen->cur_col, 0,
+ (screen->max_col - screen->cur_col + 1));
+ memset(screen->buf [4 * screen->cur_row + 3] + screen->cur_col, 0,
+ (screen->max_col - screen->cur_col + 1));
+ /* with the right part cleared, we can't be wrapping */
+ screen->buf [4 * screen->cur_row + 1] [0] &= ~LINEWRAPPED;
+}
+
+/*
+ * Clear first part of cursor's line, inclusive.
+ */
+ClearLeft (screen)
+ register TScreen *screen;
+{
+ int i;
+ Char *cp;
+
+ if(screen->cursor_state)
+ HideCursor();
+ screen->do_wrap = 0;
+ if(screen->cur_row - screen->topline <= screen->max_row) {
+ if(!AddToRefresh(screen)) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ XFillRectangle (screen->display, TextWindow(screen),
+ screen->reverseGC,
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ CursorY (screen, screen->cur_row),
+ (screen->cur_col + 1) * FontWidth(screen),
+ FontHeight(screen));
+ }
+ }
+
+ for ( i=0, cp=screen->buf[4 * screen->cur_row];
+ i < screen->cur_col + 1;
+ i++, cp++)
+ *cp = ' ';
+ for ( i=0, cp=screen->buf[4 * screen->cur_row + 1];
+ i < screen->cur_col + 1;
+ i++, cp++)
+ *cp = CHARDRAWN;
+ bzero (screen->buf [4 * screen->cur_row + 2], (screen->cur_col + 1));
+ bzero (screen->buf [4 * screen->cur_row + 3], (screen->cur_col + 1));
+}
+
+/*
+ * Erase the cursor's line.
+ */
+ClearLine(screen)
+register TScreen *screen;
+{
+ if(screen->cursor_state)
+ HideCursor();
+ screen->do_wrap = 0;
+ if(screen->cur_row - screen->topline <= screen->max_row) {
+ if(!AddToRefresh(screen)) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ XFillRectangle (screen->display, TextWindow(screen),
+ screen->reverseGC,
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ CursorY (screen, screen->cur_row),
+ Width(screen), FontHeight(screen));
+ }
+ }
+ memset(screen->buf [4 * screen->cur_row], 0, (screen->max_col + 1));
+ memset(screen->buf [4 * screen->cur_row + 1], 0, (screen->max_col + 1));
+ memset(screen->buf [4 * screen->cur_row + 2], 0, (screen->max_col + 1));
+ memset(screen->buf [4 * screen->cur_row + 3], 0, (screen->max_col + 1));
+}
+
+ClearScreen(screen)
+register TScreen *screen;
+{
+ register int top;
+
+ if(screen->cursor_state)
+ HideCursor();
+ screen->do_wrap = 0;
+ if((top = -screen->topline) <= screen->max_row) {
+ if(screen->scroll_amt)
+ FlushScroll(screen);
+ if(top == 0)
+ XClearWindow(screen->display, TextWindow(screen));
+ else
+ XClearArea(screen->display, TextWindow(screen),
+ (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar),
+ top * FontHeight(screen) + screen->border,
+ Width(screen), (screen->max_row - top + 1) *
+ FontHeight(screen), FALSE);
+ }
+ ClearBufRows (screen, 0, screen->max_row);
+}
+
+CopyWait(screen)
+register 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(screen, src_x, src_y, width, height, dest_x, dest_y)
+ TScreen *screen;
+ int src_x, src_y;
+ unsigned int width, height;
+ int dest_x, dest_y;
+{
+ /* 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,
+ TextWindow(screen), TextWindow(screen),
+ screen->normalGC,
+ 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(screen, firstchar, nchars, amount)
+ 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 = CursorX(screen, firstchar);
+ int src_y = CursorY(screen, screen->cur_row);
+
+ copy_area(screen, src_x, src_y,
+ (unsigned)nchars*FontWidth(screen), FontHeight(screen),
+ src_x + amount*FontWidth(screen), src_y);
+}
+
+/*
+ * use when inserting or deleting lines from the screen
+ */
+static void
+vertical_copy_area(screen, firstline, nlines, amount)
+ 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, src_y;
+
+ src_x = (term->misc.sb_right ?
+ (int) screen->border :
+ (int) screen->border + screen->scrollbar);
+ src_y = firstline * FontHeight(screen) + screen->border;
+
+ copy_area(screen, src_x, src_y,
+ (unsigned)Width(screen), nlines*FontHeight(screen),
+ src_x, src_y - amount*FontHeight(screen));
+ }
+}
+
+/*
+ * use when scrolling the entire screen
+ */
+scrolling_copy_area(screen, firstline, nlines, amount)
+ 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.
+ */
+HandleExposure (screen, event)
+ register TScreen *screen;
+ register XEvent *event;
+{
+ register XExposeEvent *reply = (XExposeEvent *)event;
+
+ /* 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,
+ reply->x+reply->width);
+ int both_y2 = Min(screen->copy_src_y+screen->copy_height,
+ 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.
+ */
+handle_translated_exposure (screen, rect_x, rect_y, rect_width, rect_height)
+ register TScreen *screen;
+ register int rect_x, rect_y;
+ register unsigned int rect_width, rect_height;
+{
+ register int toprow, leftcol, nrows, ncols;
+ extern Bool waiting_for_initial_map;
+
+ toprow = (rect_y - screen->border) / FontHeight(screen);
+ if(toprow < 0)
+ toprow = 0;
+ if (term->misc.sb_right)
+ leftcol = (rect_x - screen->border) /
+ FontWidth(screen);
+ else
+ leftcol = (rect_x - screen->border - screen->scrollbar) /
+ FontWidth(screen);
+
+
+ if(leftcol < 0)
+ leftcol = 0;
+ nrows = (rect_y + rect_height - 1 - screen->border) /
+ FontHeight(screen) - toprow + 1;
+ if (term->misc.sb_right)
+ ncols = (rect_x + rect_width - 1 - screen->border) /
+ FontWidth(screen) - leftcol + 1;
+ else
+ ncols = (rect_x + rect_width - 1 - screen->border -
+ screen->scrollbar) / FontWidth(screen) - leftcol + 1;
+ toprow -= screen->scrolls;
+ if (toprow < 0) {
+ nrows += toprow;
+ toprow = 0;
+ }
+ if (toprow + nrows - 1 > screen->max_row)
+ nrows = screen->max_row - toprow + 1;
+ if (leftcol + ncols - 1 > screen->max_col)
+ ncols = screen->max_col - leftcol + 1;
+
+ 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);
+}
+
+ReverseVideo (termw)
+ XgtermWidget termw;
+{
+ register TScreen *screen = &termw->screen;
+ GC tmpGC;
+ unsigned long tmp;
+
+ tmp = termw->core.background_pixel;
+ if(screen->cursorcolor == screen->foreground)
+ screen->cursorcolor = tmp;
+ termw->core.background_pixel = screen->foreground;
+ screen->foreground = tmp;
+
+ tmp = screen->mousecolorback;
+ screen->mousecolorback = screen->mousecolor;
+ screen->mousecolor = tmp;
+
+ tmpGC = screen->normalGC;
+ screen->normalGC = screen->reverseGC;
+ screen->reverseGC = tmpGC;
+
+ tmpGC = screen->normalboldGC;
+ screen->normalboldGC = screen->reverseboldGC;
+ screen->reverseboldGC = tmpGC;
+
+ recolor_cursor (screen->pointer_cursor,
+ screen->mousecolor, screen->mousecolorback);
+ recolor_cursor (screen->arrow,
+ screen->mousecolor, screen->mousecolorback);
+
+ termw->misc.re_verse = !termw->misc.re_verse;
+
+ XDefineCursor(screen->display, TextWindow(screen), screen->pointer_cursor);
+
+ if(screen->scrollWidget)
+ ScrollBarReverseVideo(screen->scrollWidget);
+
+ XSetWindowBackground(screen->display, TextWindow(screen), termw->core.background_pixel);
+ XClearWindow(screen->display, TextWindow(screen));
+ ScrnRefresh (screen, 0, 0, screen->max_row + 1,
+ screen->max_col + 1, False);
+ update_reversevideo();
+}
+
+
+recolor_cursor (cursor, fg, bg)
+ Cursor cursor; /* X cursor ID to set */
+ unsigned long fg, bg; /* pixel indexes to look up */
+{
+ register TScreen *screen = &term->screen;
+ register 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;
+}
+
+
+
+void
+GetColors(term,pColors)
+ XgtermWidget term;
+ ScrnColors *pColors;
+{
+ register TScreen *screen = &term->screen;
+ GC tmpGC;
+ unsigned long tmp;
+
+
+ pColors->which= 0;
+ SET_COLOR_VALUE(pColors,TEXT_FG, screen->foreground);
+ SET_COLOR_VALUE(pColors,TEXT_BG, term->core.background_pixel);
+ SET_COLOR_VALUE(pColors,TEXT_CURSOR, screen->cursorcolor);
+ SET_COLOR_VALUE(pColors,MOUSE_FG, screen->mousecolor);
+ SET_COLOR_VALUE(pColors,MOUSE_BG, screen->mousecolorback);
+}
+
+
+ChangeColors(term,pNew)
+ XgtermWidget term;
+ ScrnColors *pNew;
+{
+ register TScreen *screen = &term->screen;
+ GC tmpGC;
+ unsigned long tmp;
+ Bool newCursor= TRUE;
+
+
+ if (COLOR_DEFINED(pNew,TEXT_BG)) {
+ term->core.background_pixel= COLOR_VALUE(pNew,TEXT_BG);
+ }
+
+ if (COLOR_DEFINED(pNew,TEXT_CURSOR)) {
+ screen->cursorcolor= COLOR_VALUE(pNew,TEXT_CURSOR);
+ }
+ else if ((screen->cursorcolor == screen->foreground)&&
+ (COLOR_DEFINED(pNew,TEXT_FG))) {
+ screen->cursorcolor= COLOR_VALUE(pNew,TEXT_FG);
+ }
+ else newCursor= FALSE;
+
+ if (COLOR_DEFINED(pNew,TEXT_FG)) {
+ Pixel fg= COLOR_VALUE(pNew,TEXT_FG);
+ screen->foreground= fg;
+ XSetForeground(screen->display,screen->normalGC,fg);
+ XSetBackground(screen->display,screen->reverseGC,fg);
+ XSetForeground(screen->display,screen->normalboldGC,fg);
+ XSetBackground(screen->display,screen->reverseboldGC,fg);
+ }
+
+ if (COLOR_DEFINED(pNew,TEXT_BG)) {
+ Pixel bg= COLOR_VALUE(pNew,TEXT_BG);
+ term->core.background_pixel= bg;
+ XSetBackground(screen->display,screen->normalGC,bg);
+ XSetForeground(screen->display,screen->reverseGC,bg);
+ XSetBackground(screen->display,screen->normalboldGC,bg);
+ XSetForeground(screen->display,screen->reverseboldGC,bg);
+ XSetWindowBackground(screen->display, TextWindow(screen),
+ term->core.background_pixel);
+ }
+
+ if (COLOR_DEFINED(pNew,MOUSE_FG)||(COLOR_DEFINED(pNew,MOUSE_BG))) {
+ if (COLOR_DEFINED(pNew,MOUSE_FG))
+ screen->mousecolor= COLOR_VALUE(pNew,MOUSE_FG);
+ if (COLOR_DEFINED(pNew,MOUSE_BG))
+ screen->mousecolorback= COLOR_VALUE(pNew,MOUSE_BG);
+
+ recolor_cursor (screen->pointer_cursor,
+ screen->mousecolor, screen->mousecolorback);
+ recolor_cursor (screen->arrow,
+ screen->mousecolor, screen->mousecolorback);
+ XDefineCursor(screen->display, TextWindow(screen),
+ screen->pointer_cursor);
+ }
+
+ set_cursor_gcs(screen);
+ XClearWindow(screen->display, TextWindow(screen));
+ ScrnRefresh (screen, 0, 0, screen->max_row + 1,
+ screen->max_col + 1, False);
+}
+
diff --git a/vendor/x11iraf/xgterm/xgterm.man b/vendor/x11iraf/xgterm/xgterm.man
new file mode 100644
index 00000000..5ed5163d
--- /dev/null
+++ b/vendor/x11iraf/xgterm/xgterm.man
@@ -0,0 +1,981 @@
+.\" @(#)xgterm.1 1.1 16-Dec-96 MJF
+.TH XGTERM 1 "16 Dec 1996" "X11IRAF Project"
+.SH NAME
+xgterm \- terminal emulator for X with graphics and imaging capability
+.SH SYNOPSIS
+\fBxgterm\fP [\-\fItoolkitoption\fP ...] [\-\fIoption\fP ...]
+.SH DESCRIPTION
+The \fIxgterm\fP program is a terminal emulator for the X Window System
+based largely on \fIxterm\fP but with a completely new graphics and imaging
+widget. It provides DEC VT102 and Tektronix 4014 compatible terminals for
+programs that can't use the window system directly. \fIXGterm\fP also
+serves as a prototype for the \fIWidget Server\fP being developed by the
+IRAF Project at NOAO. The \fIObject Manager Library\fP it uses implements a
+window system toolkit as an interpreted window-object language, allowing
+application GUIs to be defined and executed at runtime without compiling
+any code, and with minimal dependence upon the underlying window system
+toolkit library. We will concentrate here, however, on it's use as a terminal
+emulator and a description of the new \fIGterm\fP widget.
+.PP
+The Gterm graphics window operates almost identically to the \fIxterm\fP Tek
+window, however there are extensions for implementing full-screen cursors,
+imaging, area fills, colors, graphics erasure, a "status line" and so on.
+Any graphics application capable of running under an \fIxterm\fP Tek window
+should also be able to use \fIxgterm\fP as well. Client programs wishing to
+make use of the extended features, or those wishing to implement a GUI, are
+advised to use the OBM (\fIObject Manager\fP) library supplied with the XGterm
+source as part of the X11IRAF package. This provides a much better
+programmatic interface to all of the features available; however, as of
+this writing it is not yet fully documented. Users are referred to the
+\fIXImtool\fP task as an example of a more complex application using the
+\fIOBM Library\fP and \fIGterm\fP widget, as well as demo tasks in the
+\fIguidemo\fP directory of the X11IRAF sources. Questions or comments may
+also be sent to \fIiraf@noao.edu\fP.
+.PP
+The VT102 text window is unchanged from the original \fIxterm\fR application.
+All of it's resources, command-line options and operation are identical to
+that used by \fIxterm\fP. The \fItermcap(5)\fP entry for \fIxterm\fP may
+be used for \fIxgterm\fP as well. See the \fIxterm(1)\fP man page for details.
+.SH OPTIONS
+All \fIxterm(1)\fP and X Toolkit command line options are supported, there
+are no additional options.
+.SH RESOURCES
+The program understands all of the core X Toolkit resource names and
+classes, all text window resources known to \fIxterm(1)\fP, as well as
+the \fIGterm\fP (graphics and imaging widget) resources. The proper Class
+name for all resources described here is \fIGterm\fP. A table of
+available \fIGterm\fP resources and their defaults may be found below,
+some of the more interesting resources are described here in detail:
+.TP 5
+\fIbasePixel\fP
+Base cell of the custom colormap. This essentially allows you
+to reserve \fIbasePixel\fP colors in the global colormap for other
+applications. The default is 38, if changed you'll need to also enable
+the \fIcmapInitialize\fP resource to force the Gterm widget to
+update it's global colormap resource in the X server.
+.TP 5
+\fIcmapInitialize\fP
+Initialize the ximtool colormap at startup. When resetting the \fIbasePixel\fP
+resource or colormap this is required in order to force the Gterm widget to
+update it's global colormap resource in the X server. The default is False.
+.TP 5
+\fIcmapInterpolate\fP
+Interpolate the colormap to the number of display colors. The default is
+True.
+.TP 5
+\fIcmapName\fP
+Name used for private colormap. The default for all IRAF imaging
+applications is \fIimage\fP. Gterm widget based imaging applications
+which have the same value of cmapName will share the same colormap,
+minimizing colormap flashing and allowing multiple applications to be
+run at the same time.
+.TP 5
+\fIcolor0\fP
+The widget background color. The default is black.
+.TP 5
+\fIcolor1\fP
+The widget foreground color. The default is white.
+.TP 5
+\fIcolor2\fP thru \fIcolor9\fP
+Optional drawing colors. The line color used for graphics is set using
+an escape sequence to select the current color index. See \fIGterm I/O
+Escape Sequences\fP below for more details.
+.TP 5
+\fIcrosshairCursorColor\fP
+Color of the full screen crosshair cursor.
+.TP 5
+\fIdefaultMarker\fP
+Default marker type. Options include \fItext\fP, \fIline\fP, \fIpolyline\fP,
+\fIrectangle\fP, \fIbox\fP, \fIcircle\fP, \fIellipse\fP, and \fIpolygon\fP.
+The default is \fIrectangle\fP.
+.TP 5
+\fIdeiconifyWindow\fP
+De-iconify the Gterm graphics window when activated. The default is False.
+.TP 5
+\fIdialogBgColor\fP
+Dialog box (i.e. the status line) background color. Dialog text is text which
+is drawn into the dialog area at the bottom of the gterm window, it is
+transient and is not a permanent part of the graphics being drawn. Dialog
+text is normally used to interact with the user or to display messages
+during program operation, without affecting the graphics being drawn.
+.TP 5
+\fIdialogFgColor\fP
+Dialog box (i.e. status line) foreground color.
+.TP 5
+\fIginmodeBlinkInterval\fP
+Graphics cursor blink interval, time is specified in milliseconds. The
+default is 0.
+.TP 5
+\fIginmodeCursor\fP
+Graphics mode cursor type. The default is a full screen cursor custom to
+the widget.
+.TP 5
+\fIheight\fP
+Height of the Gterm window. The default is 480.
+.TP 5
+\fIidleCursor\fP
+Cursor to use when not in graphics mode. The default is a plus sign.
+.TP 5
+\fImarkerHighlightColor\fP
+Highlight color for the active marker. When the pointer moves into a marker
+is it marked "active", the highlight color and width change to which marker
+is active. The default is green.
+.TP 5
+\fImarkerHighlightWidth\fP
+Highlight width for the active marker. The default is 2.
+.TP 5
+\fImaxColors\fP
+The maximum number of colors to use in the private global colormap, the
+default is 216. Out of this number 10 colors (the \fIcolor0\fP thru
+\fIcolor9\fP values) are reserved by the widget as static colors, the
+remainder may be allocated for images.
+.TP 5
+\fIraiseWindow\fP
+Raise the window when active. The default is False.
+.TP 5
+\fIwarpCursor\fP
+Warp the cursor to the window when active. The default is False.
+.TP 5
+\fIwidth\fP
+Width of the Gterm window. The default is 640.
+
+.SH "GTERM WIDGET RESOURCES"
+
+.SS "Class Hierarchy"
+.PP
+\fBCore -> Gterm\fP
+.SS "Resources"
+.PP
+When creating a Gterm widget instance, the following resources are retrieved
+from the arguments list or from the resource database:
+
+.TS
+center;
+lB lB lB lB
+l l l l.
+Name Class Type Default Description
+=
+alphaFont1 XFontStruct nil2 Graphics fonts
+alphaFont2 XFontStruct 5x8 "
+alphaFont3 XFontStruct 6x10 "
+alphaFont4 XFontStruct 7x13 "
+alphaFont5 XFontStruct 8x13 "
+alphaFont6 XFontStruct 9x15 "
+alphaFont7 XFontStruct 9x15 "
+alphaFont8 XFontStruct 9x15 "
+basePixel Int 38 Base of private global colormap
+busyCursor String watch Cursor to use when application is busy
+busyCursorBgColor Foreground white Busy cursor background color
+busyCursorFgColor Foreground black Busy cursor foreground color
+cacheRasters String whenNeeded Save rasters as server pixmaps for faster access
+cmapInitialize Boolean False Initialize colormap at startup
+cmapInterpolate Boolean True Interpolate colormap
+cmapName String default Custom colormap name
+cmapShadow Int 10 Colormap shadow interval
+cmapUpdate Int 60 Colormap update interval
+color0 Background black Default graphics background color
+color1 Foreground white Default graphics foreground color
+color2 Foreground red Optional drawing color
+color3 Foreground green "
+color4 Foreground blue "
+color5 Foreground cyan "
+color6 Foreground yellow "
+color7 Foreground magenta "
+color8 Foreground purple "
+color9 Foreground darkslategray "
+copyOnResize Boolean True Copy raster when resized
+crosshairCursorColor Foreground red Full-screen cursor color
+defaultMarker String rectangle Default marker type
+deiconifyWindow Boolean False Deiconify window when active
+dialogBgColor Foreground yellow Status line background color
+dialogFgColor Foreground black Status line foreground color
+dialogFont1 XFontStruct nil2 Status line fonts
+dialogFont2 XFontStruct 5x8 "
+dialogFont3 XFontStruct 6x10 "
+dialogFont4 XFontStruct 7x13 "
+dialogFont5 XFontStruct 8x13 "
+dialogFont6 XFontStruct 9x15 "
+dialogFont7 XFontStruct 9x15 "
+dialogFont8 XFontStruct 9x15 "
+ginmodeBlinkInterval Int 0 Graphics cursor blink interval
+ginmodeCursor String full_crosshair Graphics cursor type
+ginmodeCursorBgColor Foreground black Graphics cursor background color
+ginmodeCursorFgColor Foreground white Graphics cursor foreground color
+height Dimension 480 Height of graphics window
+idleCursor String Plus Idle cursor type
+idleCursorBgColor Foreground white Idle cursor background color
+idleCursorFgColor Foreground black Idle cursor foreground color
+markerBoxKnotColor Foreground blue Vertex knot color
+markerBoxKnotSize Int 0 Vertex knot size
+markerBoxLineColor Foreground green Marker border color
+markerCircleKnotColor Foreground blue Vertex knot color
+markerCircleKnotSize Int 0 Vertex knot size
+markerCircleLineColor Foreground green Marker border color
+markerCursorBgColor Foreground black Cursor background when in marker
+markerCursorFgColor Foreground yellow Cursor foreground when in marker
+markerEllipseKnotColor Foreground blue Vertex knot color
+markerEllipseKnotSize Int 0 Vertex knot size
+markerEllipseLineColor Foreground green Marker border color
+markerFill Boolean False Flood fill marker area with \fImarkerFillColor\fP
+markerFillBgColor Foreground black Fill area background color
+markerFillColor Foreground slategray Flood fill color
+markerFillStyle Int FillSolid Fill area style
+markerHighlightColor Foreground green Marker highlight color
+markerHighlightWidth Int 2 Marker highlight line width
+markerLineKnotColor Foreground blue Vertex knot color
+markerLineKnotSize Int 5 Vertex knot size
+markerLineLineColor Foreground green Line marker color
+markerLineStyle Int LineSolid Line marker line style
+markerLineWidth Int 1 Line marker width
+markerPgonKnotColor Foreground blue Vertex knot color
+markerPgonKnotSize Int 5 Vertex knot size
+markerPgonLineColor Foreground green Marker border color
+markerRectKnotColor Foreground blue Vertex knot color
+markerRectKnotSize Int 0 Vertex knot size
+markerRectLineColor Foreground green Marker border color
+markerTextBgColor Foreground slategray Text marker background color
+markerTextBorder Int 2 Text marker border width
+markerTextColor Foreground yellow Text marker text color
+markerTextFont XFontStruct 6x13 Text marker font
+markerTextLineColor Foreground green Text marker line color
+markerTextString String NULL Text string
+markerTranslations String default Marker event-to-actions translations
+maxColors Int 216 Max colors in custom colormap
+maxMappings Int 32 Max image mappings
+maxRasters Int 512 Max image rasters
+nearEdge Int 1 T{
+Distance, in pixels, between pointer and marker edge required
+for translation actions for be in effect.
+T}
+nearVertex Int 4 T{
+Distance, in pixels between pointer and marker vertex (i.e. \fIknot\fP)
+required for translation actions for be in effect.
+T}
+raiseWindow Boolean False Raise window when active
+translations String default Event-to-actions translations
+useTimers Boolean True Ok to use timers
+warpCursor Boolean False Enable warp cursor when active
+width Dimension 640 Height of graphics window
+xorFill Boolean False Fill with GXxor
+xorFillBgColor Int 255 Xor-fill background color
+xorFillColor Int 2 Xor-fill color
+.TE
+
+.SH "GTERM WIDGET TRANSLATIONS AND ACTIONS"
+
+.LP
+The default translations for a Gterm window are:
+.TS
+center;
+r l.
+<Btn1Down>: m_create()
+<Btn2Down>: crosshair(on)
+<Btn2Motion>: crosshair(on)
+<Btn2Up>: crosshair(off)
+<EnterWindow>: enter-window()
+<LeaveWindow>: leave-window()
+<KeyPress>: graphics-input()
+<Motion>: track-cursor()
+.TE
+.LP
+The available action procedures for a Gterm window are:
+.RS
+.TP 20
+\fIignore()\fP
+Ignore an event.
+.TP 20
+\fIgraphics-input()\fP
+Handle a graphics input request.
+.TP 20
+\fIcrosshair(on|off)\fP
+Display a crosshair cursor.
+.TP 20
+\fItrack-cursor()\fP
+Track crosshair cursor position.
+.TP 20
+\fIenter-window()\fP
+Handle an EnterWindow event.
+.TP 20
+\fIleave-window()\fP
+Handle an LeaveWindow event.
+.TP 20
+\fIreset()\fP
+Do a soft reset of the Gterm widget.
+.TP 20
+\fIm_create()\fP
+Create a new marker. Valid types include
+.TS
+center;
+l l l l.
+\fItext line polyline rectangle
+box circle ellipse polygon\fP
+.TE
+The default is \fIrectangle\fP, if no type is given the default type
+specified by the \fImarkerType\fP resource will be used.
+.RE
+
+.SH "GTERM MARKER TRANSLATIONS AND ACTIONS"
+
+.LP
+The default translations for a marker are:
+
+.TS
+center;
+r l.
+!Shift <Btn1Motion>: m_rotateResize()
+<Btn1Motion>: m_moveResize()
+!Shift <Btn1Down>: m_raise() m_markpos()
+<Btn1Down>: m_raise() m_markposAdd()
+<Btn1Up>: m_redraw() m_destroyNull()
+<Btn2Down>: m_lower()
+<Key>BackSpace: m_deleteDestroy()
+<Key>Delete: m_deleteDestroy()
+<KeyPress>: m_input()
+<Motion>: track-cursor()
+.TE
+
+Translations affect only the currently active marker, the cursor must be
+within \fInearEdge\fP pixels of a marker edge, or \fInearVertex\fP pixels
+of a marker vertex to take effect.
+
+The available action procedures for a marker are
+.RS
+.TP 18
+\fIm_create(type)\fP
+Create a new marker. Valid types include
+.TS
+center;
+l l l l.
+\fItext line polyline rectangle
+box circle ellipse polygon\fP
+.TE
+The default is \fIrectangle\fP, if no type is given the default type
+specified by the \fImarkerType\fP resource will be used.
+.TP 18
+\fIm_destroy()\fP
+Destroy the active marker.
+.TP 18
+\fIm_destroyNull()\fP
+Destroy the active marker if it is null sized.
+.TP 18
+\fIm_set(attribute, value, ....)\fP
+Set a marker attribute. Valid attributes include
+
+.TS
+center;
+l l l l.
+\fIactivated autoRedraw fill fillBgColor
+fillColor fillPattern fillStyle font
+height highlightColor imageText knotColor
+knotSize lineColor lineStyle lineWidth
+rotangle sensitive textBgColor textBorder
+textColor translations type visible
+width x y \fP
+.TE
+.TP 18
+\fIm_raise()\fP
+Raise the active marker to the top of the display list.
+.TP 18
+\fIm_lower()\fP
+Lower the active marker to the bottom of the display list.
+.TP 18
+\fIm_notify(event, event, ....)\fP
+Notify any clients that have registered callbacks for the specified type
+of events. Recognized events include
+.TS
+center;
+l l l.
+\fInotify \fImoveResize \fImodify
+\fIredraw \fIdestroy \fIinput
+\fIfocusIn \fIfocusOut \fIconstraint\fP
+.TE
+.TP 18
+\fIm_input()\fP
+Notify any clients that have registered a input callback that a input event
+has occurred.
+.TP 18
+\fIm_markpos()\fP
+Mark the current position of the marker, e.g., so that it can later be erased.
+.TP 18
+\fIm_markposAdd()\fP
+Execute either the markpos or add action, depending upon
+the pointer location. If the pointer is over an active marker at a
+location where the add action can be executed this is done, otherwise the
+markpos action is executed.
+.TP 18
+\fIm_redraw()\fP
+Redraw the active marker.
+.TP 18
+\fIm_addPt()\fP
+Add a point (i.e. vertex knot). \fIPolyline\fP and \fIpolygon\fP markers only.
+.TP 18
+\fIm_deletePt()\fP
+Delete a point (i.e. vertex knot).
+.TP 18
+\fIm_movePt()\fP
+Move a point (i.e. vertex knot). \fIPolyline\fP and \fIpolygon\fP markers only.
+.TP 18
+\fIm_deleteDestroy()\fP
+Delete a point or destroy a marker, depending upon the pointer position.
+.TP 18
+\fIm_move()\fP
+Move a marker.
+.TP 18
+\fIm_resize()\fP
+Resize a marker.
+.TP 18
+\fIm_moveResize()\fP
+Move a point or marker, or resize a marker, depending upon the pointer
+position.
+.TP 18
+\fIm_rotate()\fP
+Rotate a marker.
+.TP 18
+\fIm_rotateResize()\fP
+Rotate or resize a marker. A marker is rotated if near a vertex know, or
+resized if near an edge.
+.RE
+
+.SH "GTERM I/O ESCAPE SEQUENCES"
+XGterm uses escape sequences to provide graphics emulation.
+This protocol is an extension of the Tektronix 4012 graphics protocol.
+The basic extensions are patterned after the Retrographics VT640 graphics
+terminal, using GS (octal \\035, aka Ctrl-]) and CAN (octal \\030, aka
+Ctrl-x) to switch between vt100 and graphics modes.
+Additional extensions are defined to support advanced features such as
+color, area fills, graphics erasure, setting the cursor location under
+program control, interactive dialog via the "status line", and so on.
+
+While these escape sequences can be used directly, the best programmatic
+interface is to use the OBM (\fIObject Manager\fP) library supplied with
+the XGterm source as part of the X11IRAF package. Any Tektronix-compatible
+graphics library will suffice for producing vector graphics, the added
+escape sequences used by the Gterm widget are required to make use of
+imaging, area fills, the status line, etc.
+
+All escape sequences begin with an \fBESC\fP character (octal \\033), followed
+by up to three characters defining the action to be taken. All strings in
+capital letters refer to the ASCII code (e.g. \fILF\fP is the ASCII linefeed
+code), a three digit number preceeded by a '\' refers to an octal code (e.g.
+"\012" is octal 12) , all others are characters in the escape code (e.g.
+"/bc" are the three characters '/', 'b', and 'c').
+
+.SS "ESCAPE SEQUENCES"
+
+.RS
+.TP 15
+\fBUS\fP
+.sp -0.5
+.TP 15
+\fBCR\fP
+Switch to alpha mode. Characters are drawn in the graphics window at the
+"current" position (normally set beforehand with a GS/US vector move),
+using the alpha mode font. Receipt of any control code causes alpha mode to be
+exited.
+
+.TP 15
+\fBGS\fP
+Switch to vector polyline mode.
+.sp -0.5
+.TP 15
+\fBFS\fP
+Switch to vector polypoint mode.
+.sp -0.5
+.TP 15
+\fBRS\fP
+Switch to vector mode, vertices are joined as a polygon.
+
+With all three codes, vertices and points are accumulated in a buffer and
+displayed when the buffer fills or when vector mode is terminated by receipt
+of any control code. A workstation open will be done if it hasn't already
+been opened, no-op sequences GS-CAN are filtered out, since they would only
+cause a pointless switch to the graphics frame and back without drawing.
+The open workstation sequence is GS,US, or by the \fIxterm\fP graphics start
+escape sequence "[?38h".
+
+.TP 15
+\fBEM\fP
+Enter message mode. In message mode input text is accumulated in a buffer
+and eventually passed to the object manager, which delivers the message to
+the referenced object. Messages are used to download the user interface to
+be executed by the object manager. During execution, messages are used
+to set the values of user interface parameters to allow the UI to track
+the state of the client application.
+
+.TP 15
+\fBCAN\fP
+Close workstation and enter command mode.
+.TP 15
+\fBBEL\fP
+Ring the screen bell.
+
+.TP 15
+\fBENQ\fP
+Return terminal status. Returned values include the terminal mode, and alpha
+cursor x and y position.
+.TP 15
+\fBSUB\fP
+Initiate a cursor read, values are returned in window coordinates.
+.TP 15
+\fB/SUB\fP
+Return window cursor position in raster coordinates.
+.TP 15
+\fBFF\fP
+Clear the screen.
+.TP 15
+\fB/f\fP
+Set current cursor position.
+.TP 15
+\fB0\fP
+Set character size 0. (Currently ignored).
+.sp -0.5
+.TP 15
+\fB1\fP
+Set character size 1. (Currently ignored).
+.sp -0.5
+.TP 15
+\fB2\fP
+Set character size 2. (Currently ignored).
+.sp -0.5
+.TP 15
+\fB3\fP
+Set character size 3. (Currently ignored).
+.TP 15
+\fB/0d\fP
+Set color index.
+.sp -0.5
+.TP 15
+\fB/1d\fP
+Clear graphics screen.
+.sp -0.5
+.TP 15
+\fB/2d\fP
+Invert graphics screen
+.TP 15
+\fB`\fP
+Select line style 0. (Solid)
+.sp -0.5
+.TP 15
+\fBa\fP
+Select line style 1. (Dashed)
+.sp -0.5
+.TP 15
+\fBb\fP
+Select line style 2. (Dotted)
+.sp -0.5
+.TP 15
+\fBc\fP
+Select line style 3. (DashDot)
+.sp -0.5
+.TP 15
+\fBd\fP
+Select line style 4. (Dash3Dot)
+.TP 15
+\fB/0w\fP
+Select line width 0.
+.sp -0.5
+.TP 15
+\fB/1w\fP
+Select line width 1.
+.sp -0.5
+.TP 15
+\fB/2w\fP
+Select line width 2.
+.sp -0.5
+.TP 15
+\fB/nw\fP
+Select line width 3.
+.TP 15
+\fB/0c\fP
+Select line color 0.
+.sp -0.5
+.TP 15
+\fB/1c\fP
+Select line color 1.
+.sp -0.5
+.TP 15
+\fB/2c\fP
+Select line color 2.
+.sp -0.5
+.TP 15
+\fB/3c\fP
+Select line color 3.
+.sp -0.5
+.TP 15
+\fB/4c\fP
+Select line color 4.
+.sp -0.5
+.TP 15
+\fB/5c\fP
+Select line color 5.
+.sp -0.5
+.TP 15
+\fB/6c\fP
+Select line color 6.
+.sp -0.5
+.TP 15
+\fB/7c\fP
+Select line color 7.
+.sp -0.5
+.TP 15
+\fB/8c\fP
+Select line color 8.
+.sp -0.5
+.TP 15
+\fB/9c\fP
+Select line color 9.
+.RE
+
+.SS "IMAGING ESCAPE SEQUENCES"
+
+These are encoded as follows:
+
+ \fBESC\fP <code> [ \fIP ; P\fP ; ... ] <\fIdata\fP>
+
+where \fIcode\fR is a character sequence and \fIP\fP is an ASCII encoded
+parameter described below.
+.RS
+.TP 15
+\fB/nc\fP
+Select line color. Parameter is the color number in the range 0-9.
+.TP 15
+\fBsre\fP
+\fIReset\fP. Parameters are "reset-str".
+.TP 15
+\fBssz\fP
+\fIResize\fP. Parameters are "resize-str".
+.TP 15
+\fBrir\fP
+\fIInitialize raster\fP.
+.TP 15
+\fBrcr\fP
+\fICreate a raster\fP. Parameters are raster number, type, width, height, and
+depth. Type is 1 for a normal (client) raster, 2 for cached in server memory,
+or 0 if you don't care. Depth may be 1, 8, 16, or 32.
+.TP 15
+\fBrde\fP
+\fIDestroy a raster\fP. Parameter is raster number.
+.TP 15
+\fBrqr\fP
+\fIQuery a raster\fP. Parameter is raster number.
+Output parameters are status, type, width, height, and depth encoded in the
+string ""\\033[5;%d;%d;%d;%d;%d]".
+.TP 15
+\fBrsr\fP
+\fISelect a raster\fP. Parameter is raster number.
+.TP 15
+\fBrwr\fP
+\fIWrite pixels to a rectangular region of a raster\fP. Parameters are raster
+number, encoding type (not used), x1, y1, nx, ny, and depth followed by
+(nx*ny) data pixels.
+.TP 15
+\fBrrd\fP
+\fIRead from a rectangular region of a raster\fP. Parameters are raster
+number, encoding type (not used), x1, y1, nx, ny, and depth followed by (nx*ny)
+data pixels.
+.TP 15
+\fBrrp\fP
+\fIRefresh raster pixels\fP. Parameters are raster number, coordinate type (0
+for pixel, 1 for NDC), x1, y1, nx, ny.
+.TP 15
+\fBrsp\fP
+\fISet all the raster pixels in a region to a single color\fP. Parameters are
+raster number, coordinate type (0 for pixel, 1 for NDC), x1, y1, nx, ny,
+color, and raster operand. If nx=ny=0 the entire raster will be written.
+Raster operands include transient (octal 020), refresh_all (octal 040),
+or refresh_none (octal 100).
+.TP 15
+\fBrco\fP
+\fICopy a region of the source raster to a region of the
+destination raster\fP. Parameters are raster operand, source raster number,
+source type, source x coord, source y coord, source width, source height,
+destination raster number, destination type, destination x coord, destination
+y coord, destination width, destination height, If the input and output
+regions are not the same size the subimage is automatically scaled to fit
+the destination region. If the destination extent DNX or DNY is negative,
+the image is flipped in that axis. The type of spatial scaling performed is
+determined by the scale factors (zoom, dezoom, or no scaling). The rasterop
+argument is used to exercise fine control over how the mapping is performed,
+e.g. to force a refresh, implement a transient mapping, or in the case of a
+dezoom (many-to-one) mapping, select the antialiasing technique to be used.
+.TP 15
+\fBrwc\fP
+\fIWrite a colormap\fP. Parameters are colormap number, first color and the
+number of colors followed by NC colors triples in the data.
+.TP 15
+\fBrrc\fP
+\fIReturn the color assignments for a region of the named colormap\fP.
+Parameters are colormap number, first color and the number of colors followed
+by NC colors triples in the data.
+.TP 15
+\fBrlc\fP
+\fILoad a colormap into the display\fP, optionally scaling the colormap via a
+linear transformation in the process. Parameters are the colormap number, the
+offset value, and the cursor x and Y coordinates in NDC units. The colormap is
+unaffected if offset=0.5, scale=1.0. A negative scale inverts the image.
+If map=0 the linear transformation is applied directly to the display colormap.
+.TP 15
+\fBrfc\fP
+\fIFree a colormap\fP. Parameter is the colormap number.
+.TP 15
+\fBrwo\fP
+\fIWrite the IOmap\fP. Parameters are the first color and the number of colors,
+followed by NC color triples in the data. An iomap is an optional lookup
+table used to isolate the client application from the color model used within
+the Gterm widget. To simplify color allocation the Gterm widget defines a
+logical color space where color 0 is the background, 1 the foreground, 2-N are
+statically allocated standard colors, and colors N+1 and above are dynamically
+allocated by the graphics application. Less-demanding applications use
+only the statically allocated, shared colors. The widget internally maps
+these logical colors to whatever the window system requires, but providing
+a well-defined logical color space isolates the client from the details of
+color allocation in the underlying window system.
+
+An iomap can be used to define a mapping between the color model of the
+client application and the Gterm color model (when we say color model here
+we mean color allocation schemes for 8 bit pseudocolor). By default the
+iomap is one-to-one. The use of an iomap frees the client from having to
+worry about color index translations, and allows color tables to be
+combined in the widget for greater efficiency when color tables are serially
+applied. The iomap applies to all color indices or pixel values passed
+in i/o operations between the client and the Gterm widget.
+.TP 15
+\fBrro\fP
+\fIRead the IOmap\fP. Return values are the first color and the number of
+colors, followed by NC color triples in the data.
+.TP 15
+\fBrim\fP
+\fIDelete all mappings\fP and initialize the mapping subsystem.
+.TP 15
+\fBrsm\fP
+\fIDefine a new mapping function\fP, or modify an old one.
+If a new mapping is defined it is merely enabled, and no refreshing
+of the screen takes place until either some mapped data is written
+to or the mapping is explicitly refreshed. If an existing mapping is
+modified the old and new mappings are examined and only those portions
+of the destination rect for which the mapping changed are updated.
+This permits minor changes to a mapping (e.g. moving an edge) without
+having to redraw the entire region. Regions of the destination drawable
+which were previously covered by the mapping but which were exposed by
+modifying the mapping are redrawn.
+.TP 15
+\fBrgm\fP
+\fIReturn the external parameters of a mapping\fP. Parameter is the mapping
+number, values returned (in the string
+"\\033[6;%d;%d %d;%d;%d;%d;%d;%d %d;%d;%d;%d;%d;%d]") are the mapping
+number, rasterop, source mapping, type, x, y, width, height, and destination
+mapping, type, x, y, width and height.
+.TP 15
+\fBrem\fP
+\fIEnable a mapping\fP. Parameters are the mapping number and an integer
+flag indicating whether to refresh the mapping.
+.TP 15
+\fBrdm\fP
+\fIDisable a mapping\fP. Disabling a mapping does not
+affect the mapping definition, hence a disabled mapping may later be
+reenabled. Parameters are the mapping number and an integer flag indicating
+whether to erase the mapping.
+.TP 15
+\fBrrm\fP
+\fIRefresh a mapping\fP. Parameter is the mapping number.
+.TP 15
+\fBrfm\fP
+\fIFree a mapping\fP. Parameter is the mapping number.
+.RE
+
+.SH "MORE ON IMAGING"
+The imaging model of the Gterm widget defines the following key object or
+data types: \fIrasters\fP, \fImappings\fP, and \fIcolors\fP.
+.TP 10
+.B "raster"
+A raster is a MxN array of pixels. At present pixels are 8 bits deep but
+hooks are built into the widget to expand this in the future. Pixel
+values are indices into the Gterm virtual colormap, with values starting at
+zero. A raster may be any size. A raster is merely a two-dimensional array
+in the graphics server; it is not displayed unless mapped. An exception is
+raster zero, which is the graphics window. Rasters are referred to by number,
+starting with zero. Initially only raster zero exists; new rasters are created
+with the create raster escape code \fBrcr\fP. Space for rasters may be
+allocated either in the graphics server, or in the X server. This has
+implications on performance but is otherwise transparent to the client.
+By default rasters are allocated in the graphics server, i.e., in the X client.
+.TP 10
+.B "mapping"
+A mapping defines a projection of a rectangle of the source raster onto a
+rectangle of the destination raster. Mappings may be either enabled (active)
+or disabled. When a mapping is enabled, any change to a pixel in the source
+rect will cause the corresponding pixels in the destination rect to be
+updated. Mappings are referred to by number starting with one. Initially
+no mappings are defined. If the size of the input and output rect is not
+the same the input rect will be scaled by pixel replication or subsampling
+to fill the output rect. If the argument DW (destination width) or DH
+(destination height) of the destination rect is negative, the image will be
+flipped around the corresponding axis when copied to the destination; the
+region of the destination drawn into is the same in either case. Multiple
+mappings may reference the same source or destination raster. Mappings are
+refreshed in order by the mapping number. Modifying a mapping causes the
+changed regions of the destination rect to be refreshed.
+.TP 10
+.B "color"
+The \fIGterm\fP widget provides a fixed number of preassigned colors
+corresponding to pixel values 0 through 9. Zero is the background color,
+one is the foreground color, and 2-9 (8 colors) are arbitrary colors defined
+by Gterm widget resources. These static colors are normally used to draw
+the background, frame, axes, titles, etc. of a plot, or to draw color
+graphics within the drawing area. The advantage of static colors is that
+they are shared with other X clients, and the values of these colors may be
+assigned by the user to personalize the way plots look.
+
+The \fIGterm\fP widget also allows any number (up to about 200 or so) additional
+colors to be defined at runtime by the client application. These color
+values start at pixel value 10 and go up to the maximum pixel value assigned
+by the client. The client application allocates colors with the
+write colormap escape code \fBrwc\fP. Attempts to overwrite the values of
+the static colors are ignored. The values of already allocated colors may
+be changed dynamically at runtime using write colormap code to write the
+desired range of color values.
+
+Applications should not assume that there are 10 static colors and 200 or
+so allocatable colors. The IRAF graphcap entry for the logical device in use,
+and resources set for the widget,
+defines these parameters for the device. Alternatively, the read colormap
+code may be used to dynamically determine how many colors the server has
+preallocated when the application starts up.
+
+An image may use either static and dynamic pixel values or both types of
+values, but in most cases imaging applications involve smoothly shaded
+surfaces hence will require dynamically assigned private colors.
+
+If for some reason the client application cannot use the \fIGterm\fP widget
+color model, the IOMAP feature can be used to make the widget appear to have
+some externally defined (i.e., client defined) color model.
+.LP
+The maximum number of rasters and maximum number of mappings is defined by
+the Gterm widget resources \fImaxRaster\fP and \fImaxMappings\fP (or in the
+GUI file) when the graphics application starts up. The maximum values should
+be much larger than most applications require. Applications should allocate
+raster or mapping numbers sequentially starting at 1 (more or less) to avoid
+running out of raster or mapping descriptors.
+
+The {read|write}pixels escape codes operate directly on
+raster pixels. The mapping escape codes support two alternative coordinate
+systems, raster pixels and NDC (normalized device coordinates), as indicated
+by the ST or DT argument (source or destination coordinate type). Note
+that the origin of the pixel coordinate system is the upper left corner of
+the display window (consistent with most graphics systems), whereas the origin
+of the NDC coordinate system is the lower left corner (consistent with IRAF).
+
+Pixel coordinates allow precise control of imaging but require the
+application to know the window size, and may result in complications e.g. if
+the window is resized. NDC coordinates pretty much guarantee that a mapping
+will involve sampling, hence are not the most efficient, but the graphics
+will be drawn correctly no matter how the window is resized and for most
+applications the performance difference is negligible. Most applications
+should use NDC coordinates for raster 0 (the display window), and pixel
+coordinates for rasters 1-N.
+
+Although the size of rasters 1 and higher are defined by the client
+application, the size of raster zero, the actual gterm display window, is
+subject to the constraints of the window system. The client can attempt to
+reset the size of the gterm window using create raster escape with raster=0,
+however the Gterm widget, UI containing the \fIGterm\fP widget, and the window
+manager are all free to deny such a request. The query raster escape should be
+called to determine the actual size of the window one will be drawing into.
+
+.SS AN EXAMPLE IMAGING APPLICATION
+
+.LP
+An example of a simple imaging application might be one that downloads an
+image and displays it in the gterm window, filling the window. This could
+be done as follows (following a graphics open and other escape codes to
+prepare the drawing surface).
+
+.TP 15
+\fIcreate raster\fP
+Create raster 1 the size of the pixel array to be displayed. This need not
+be the same as the size of the gterm display window.
+.TP 15
+\fIset mapping\fP
+Define a mapping between raster 1 and raster 0, the display window, using
+NDC coordinates to define the region of the display window to be
+filled. The mapping number is arbitrary but mappings should normally be
+allocated starting with 1. The mapping is automatically enabled
+when first defined.
+.TP 15
+\fIwrite colormap\fP
+(Optional). Define the pixel value to RGB color assignments for the image
+pixels.
+.TP 15
+\fIwrite pixels\fP
+This escape is called one or more times to write pixels into raster 1.
+At most 32K pixels can be written in each call. As each write is
+made the affected region of the display window will be updated.
+.LP
+Alternatively, one could write the pixels and then define the mapping to
+cause the entire image to be displayed at once.
+
+Note that the imaging escape can be combined with normal graphics to draw text
+and graphics around or on top of an image region. The order in which drawing
+operations occur is important, e.g., to draw graphics or text on top of an
+image the image should be drawn first.
+
+.SH "MARKERS"
+Markers are a general feature of the \fIGterm\fP widget and are used more
+extensively in other programs (e.g. the prototype IRAF science GUI
+applications), but they have no real use in \fIxgterm\fP when used as
+simply a graphics terminal. All markers share some of the same characteristics,
+so it is worthwhile learning basic marker manipulation keystrokes (as defined
+using the default marker translations), especially how to delete an
+accidentally created marker:
+.RS
+.TP 3
+\fBo\fP
+\fIDelete\fP or \fIBackspace\fP in a marker deletes it.
+.TP 3
+\fBo\fP
+MB1 anywhere inside a marker may be used to drag the marker.
+.TP 3
+\fBo\fP
+MB1 near a marker corner or edge, depending on the type of marker,
+resizes the marker.
+.TP 3
+\fBo\fP
+Shift-MB1 on the corner of most markers will rotate the marker.
+.TP 3
+\fBo\fP
+Markers stack, if you have several markers and you put one on top of
+the other. The active marker is highlighted to tell you which of the
+stacked markers is active. If the markers overlap, this will be marker
+"on top" in the stacking order.
+.TP 3
+\fBo\fP
+MB2 in the body of a marker "lowers" the marker, i.e. moves it to the
+bottom of the stacking order.
+.RE
+
+.SH ENVIRONMENT
+.I XGterm
+sets the environment variables ``TERM'' and ``TERMCAP'' properly for the
+size window you have created.
+It also uses and sets the environment
+variable ``DISPLAY'' to specify which bit map display terminal to use.
+The environment variable ``WINDOWID'' is set to the X window id number
+of the \fIxgterm\fP window.
+
+.SH "SEE ALSO"
+xterm(1), resize(1), X(1), pty(4), tty(4)
+.br
+\fIXterm Control Sequences\fP (in the \fIxterm\fP source directory)
+
+.SH BUGS
+Many of the same bugs affecting \fIxterm\fP also apply here.
+
+\fIXgterm\fP is not normally installed with setuid permissions. On some
+Linux systems, for example, where the /dev/tty and /dev/pty devices have
+root ownership and permission 600 this can cause problems. Workarounds
+are to either install \fIXGterm\fP with setuid permissions or modify the
+/dev/tty and /dev/pty devices to have permission 666.
+
+.SH COPYRIGHT
+Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
diff --git a/vendor/x11iraf/xgterm/xgterm.ps b/vendor/x11iraf/xgterm/xgterm.ps
new file mode 100644
index 00000000..368ba9f7
--- /dev/null
+++ b/vendor/x11iraf/xgterm/xgterm.ps
@@ -0,0 +1,1298 @@
+%!PS-Adobe-3.0
+%%Creator: groff version 1.09
+%%CreationDate: Sat Apr 5 14:58:34 1997
+%%DocumentNeededResources: font Times-Roman
+%%+ font Times-Bold
+%%+ font Times-Italic
+%%DocumentSuppliedResources: procset grops 1.09 0
+%%Pages: 13
+%%PageOrder: Ascend
+%%Orientation: Portrait
+%%EndComments
+%%BeginProlog
+%%BeginResource: procset grops 1.09 0
+/setpacking where{
+pop
+currentpacking
+true setpacking
+}if
+/grops 120 dict dup begin
+/SC 32 def
+/A/show load def
+/B{0 SC 3 -1 roll widthshow}bind def
+/C{0 exch ashow}bind def
+/D{0 exch 0 SC 5 2 roll awidthshow}bind def
+/E{0 rmoveto show}bind def
+/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
+/G{0 rmoveto 0 exch ashow}bind def
+/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/I{0 exch rmoveto show}bind def
+/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
+/K{0 exch rmoveto 0 exch ashow}bind def
+/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/M{rmoveto show}bind def
+/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
+/O{rmoveto 0 exch ashow}bind def
+/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/Q{moveto show}bind def
+/R{moveto 0 SC 3 -1 roll widthshow}bind def
+/S{moveto 0 exch ashow}bind def
+/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/SF{
+findfont exch
+[exch dup 0 exch 0 exch neg 0 0]makefont
+dup setfont
+[exch/setfont cvx]cvx bind def
+}bind def
+/MF{
+findfont
+[5 2 roll
+0 3 1 roll
+neg 0 0]makefont
+dup setfont
+[exch/setfont cvx]cvx bind def
+}bind def
+/level0 0 def
+/RES 0 def
+/PL 0 def
+/LS 0 def
+/PLG{
+gsave newpath clippath pathbbox grestore
+exch pop add exch pop
+}bind def
+/BP{
+/level0 save def
+1 setlinecap
+1 setlinejoin
+72 RES div dup scale
+LS{
+90 rotate
+}{
+0 PL translate
+}ifelse
+1 -1 scale
+}bind def
+/EP{
+level0 restore
+showpage
+}bind def
+/DA{
+newpath arcn stroke
+}bind def
+/SN{
+transform
+.25 sub exch .25 sub exch
+round .25 add exch round .25 add exch
+itransform
+}bind def
+/DL{
+SN
+moveto
+SN
+lineto stroke
+}bind def
+/DC{
+newpath 0 360 arc closepath
+}bind def
+/TM matrix def
+/DE{
+TM currentmatrix pop
+translate scale newpath 0 0 .5 0 360 arc closepath
+TM setmatrix
+}bind def
+/RC/rcurveto load def
+/RL/rlineto load def
+/ST/stroke load def
+/MT/moveto load def
+/CL/closepath load def
+/FL{
+currentgray exch setgray fill setgray
+}bind def
+/BL/fill load def
+/LW/setlinewidth load def
+/RE{
+findfont
+dup maxlength 1 index/FontName known not{1 add}if dict begin
+{
+1 index/FID ne{def}{pop pop}ifelse
+}forall
+/Encoding exch def
+dup/FontName exch def
+currentdict end definefont pop
+}bind def
+/DEFS 0 def
+/EBEGIN{
+moveto
+DEFS begin
+}bind def
+/EEND/end load def
+/CNT 0 def
+/level1 0 def
+/PBEGIN{
+/level1 save def
+translate
+div 3 1 roll div exch scale
+neg exch neg exch translate
+0 setgray
+0 setlinecap
+1 setlinewidth
+0 setlinejoin
+10 setmiterlimit
+[]0 setdash
+/setstrokeadjust where{
+pop
+false setstrokeadjust
+}if
+/setoverprint where{
+pop
+false setoverprint
+}if
+newpath
+/CNT countdictstack def
+userdict begin
+/showpage{}def
+}bind def
+/PEND{
+clear
+countdictstack CNT sub{end}repeat
+level1 restore
+}bind def
+end def
+/setpacking where{
+pop
+setpacking
+}if
+%%EndResource
+%%IncludeResource: font Times-Roman
+%%IncludeResource: font Times-Bold
+%%IncludeResource: font Times-Italic
+grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
+def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
+/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
+/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
+/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
+/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
+/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
+/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
+/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
+/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
+/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
+/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
+/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
+/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
+/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
+/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
+/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
+/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
+/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
+/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
+/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
+/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
+/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
+/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
+/Times-Roman@0 ENC0/Times-Roman RE
+%%EndProlog
+%%Page: 1 1
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 9
+/Times-Bold@0 SF -.18(NA)72 84 S(ME).18 E F0(xgterm \255 terminal emula\
+tor for X with graphics and imaging capability)108 96 Q F1(SYNOPSIS)72
+112.8 Q/F2 10/Times-Bold@0 SF(xgterm)108 124.8 Q F0<5bad>2.5 E/F3 10
+/Times-Italic@0 SF(toolkitoption)A F0(...] [\255)2.5 E F3(option)A F0
+(...])2.5 E F1(DESCRIPTION)72 141.6 Q F0(The)108 153.6 Q F3(xgterm)3.475
+E F0 .975(program is a terminal emulator for the X W)3.475 F(indo)-.4 E
+3.474(wS)-.25 G .974(ystem based lar)-3.474 F .974(gely on)-.18 F F3
+(xterm)3.474 E F0 -.2(bu)3.474 G 3.474(tw).2 G .974(ith a)-3.474 F .378
+(completely ne)108 165.6 R 2.878(wg)-.25 G .378
+(raphics and imaging widget. It pro)-2.878 F .379(vides DEC VT102 and T)
+-.15 F .379(ektronix 4014 compatible ter)-.7 F(-)-.2 E .636
+(minals for programs that can')108 177.6 R 3.136(tu)-.18 G .635
+(se the windo)-3.136 F 3.135(ws)-.25 G .635(ystem directly)-3.135 F(.)
+-.65 E F3(XGterm)5.635 E F0 .635(also serv)3.135 F .635
+(es as a prototype for the)-.15 F F3 -.55(Wi)108 189.6 S(dg).55 E .237
+(et Server)-.1 F F0 .237(being de)2.737 F -.15(ve)-.25 G .237
+(loped by the IRAF Project at NO).15 F -.55(AO)-.35 G 5.238(.T).55 G(he)
+-5.238 E F3 .238(Object Mana)2.738 F -.1(ge)-.1 G 2.738(rL).1 G(ibr)
+-2.738 E(ary)-.15 E F0 .238(it uses imple-)2.738 F .379(ments a windo)
+108 201.6 R 2.879(ws)-.25 G .379(ystem toolkit as an interpreted windo)
+-2.879 F .378(w-object language, allo)-.25 F .378
+(wing application GUIs to be)-.25 F 1.984(de\214ned and e)108 213.6 R
+-.15(xe)-.15 G 1.984(cuted at runtime without compiling an).15 F 4.484
+(yc)-.15 G 1.985(ode, and with minimal dependence upon the)-4.484 F
+1.488(underlying windo)108 225.6 R 3.988(ws)-.25 G 1.488
+(ystem toolkit library)-3.988 F 6.488(.W)-.65 G 3.987(ew)-7.288 G 1.487
+(ill concentrate here, ho)-3.987 F(we)-.25 E -.15(ve)-.25 G 2.287 -.4
+(r, o).15 H 3.987(ni).4 G(t')-3.987 E 3.987(su)-.55 G 1.487
+(se as a terminal)-3.987 F(emulator and a description of the ne)108
+237.6 Q(w)-.25 E F3(Gterm)2.5 E F0(widget.)2.5 E .205
+(The Gterm graphics windo)108 254.4 R 2.705(wo)-.25 G .205
+(perates almost identically to the)-2.705 F F3(xterm)2.705 E F0 -.7(Te)
+2.705 G 2.706(kw).7 G(indo)-2.706 E 1.506 -.65(w, h)-.25 H -.25(ow).65 G
+-2.15 -.25(ev e).25 H 2.706(rt).25 G .206(here are e)-2.706 F(xten-)-.15
+E .616(sions for implementing full-screen cursors, imaging, area \214ll\
+s, colors, graphics erasure, a "status line" and)108 266.4 R .33(so on.)
+108 278.4 R(An)5.33 E 2.83(yg)-.15 G .33
+(raphics application capable of running under an)-2.83 F F3(xterm)2.831
+E F0 -.7(Te)2.831 G 2.831(kw).7 G(indo)-2.831 E 2.831(ws)-.25 G .331
+(hould also be able to use)-2.831 F F3(xgterm)108 290.4 Q F0 .528
+(as well.)3.028 F .528(Client programs wishing to mak)5.528 F 3.028(eu)
+-.1 G .528(se of the e)-3.028 F .527
+(xtended features, or those wishing to imple-)-.15 F .019
+(ment a GUI, are advised to use the OBM \()108 302.4 R F3 .019
+(Object Mana)B -.1(ge)-.1 G(r).1 E F0 2.519(\)l)C .019
+(ibrary supplied with the XGterm source as part)-2.519 F .557
+(of the X11IRAF package.)108 314.4 R .557(This pro)5.557 F .557
+(vides a much better programmatic interf)-.15 F .557
+(ace to all of the features a)-.1 F -.25(va)-.2 G(il-).25 E .198
+(able; ho)108 326.4 R(we)-.25 E -.15(ve)-.25 G .998 -.4(r, a).15 H 2.698
+(so).4 G 2.698(ft)-2.698 G .198
+(his writing it is not yet fully documented.)-2.698 F .198
+(Users are referred to the)5.198 F F3(XImtool)2.698 E F0 .198
+(task as an)2.698 F -.15(ex)108 338.4 S .093(ample of a more comple).15
+F 2.593(xa)-.15 G .093(pplication using the)-2.593 F F3 .093(OBM Libr)
+2.593 F(ary)-.15 E F0(and)2.593 E F3(Gterm)2.593 E F0 .092
+(widget, as well as demo tasks in)2.593 F(the)108 350.4 Q F3(guidemo)
+6.971 E F0 4.471(directory of the X11IRAF sources.)6.971 F 4.472
+(Questions or comments may also be sent to)9.471 F F3(ir)108 362.4 Q
+(af@noao.edu)-.15 E F0(.)A .164(The VT102 te)108 379.2 R .164(xt windo)
+-.15 F 2.664(wi)-.25 G 2.664(su)-2.664 G .164
+(nchanged from the original)-2.664 F F3(xterm)2.664 E F0 2.664
+(application. All)2.664 F .164(of it')2.664 F 2.664(sr)-.55 G .164
+(esources, command-)-2.664 F .27
+(line options and operation are identical to that used by)108 391.2 R F3
+(xterm)2.77 E F0 5.27(.T)C(he)-5.27 E F3(termcap\(5\))2.77 E F0 .27
+(entry for)2.77 F F3(xterm)2.77 E F0 .27(may be used)2.77 F(for)108
+403.2 Q F3(xgterm)2.5 E F0(as well.)2.5 E(See the)5 E F3(xterm\(1\))2.5
+E F0(man page for details.)2.5 E F1(OPTIONS)72 420 Q F0(All)108 432 Q F3
+(xterm\(1\))2.5 E F0(and X T)2.5 E(oolkit command line options are supp\
+orted, there are no additional options.)-.8 E F1(RESOURCES)72 448.8 Q F0
+.779(The program understands all of the core X T)108 460.8 R .779
+(oolkit resource names and classes, all te)-.8 F .778(xt windo)-.15 F
+3.278(wr)-.25 G(esources)-3.278 E(kno)108 472.8 Q .371(wn to)-.25 F F3
+(xterm\(1\))2.871 E F0 2.872(,a)C 2.872(sw)-2.872 G .372(ell as the)
+-2.872 F F3(Gterm)2.872 E F0 .372
+(\(graphics and imaging widget\) resources.)2.872 F .372
+(The proper Class name)5.372 F .729(for all resources described here is)
+108 484.8 R F3(Gterm)3.229 E F0 5.729(.A)C .729(table of a)-2.5 F -.25
+(va)-.2 G(ilable).25 E F3(Gterm)3.229 E F0 .729(resources and their def)
+3.229 F .728(aults may be)-.1 F(found belo)108 496.8 Q 1.3 -.65(w, s)
+-.25 H
+(ome of the more interesting resources are described here in detail:).65
+E F3(basePixel)108 513.6 Q F0 1.515(Base cell of the custom colormap.)
+133 525.6 R 1.515(This essentially allo)6.515 F 1.515(ws you to reserv)
+-.25 F(e)-.15 E F3(basePixel)4.016 E F0 1.516(colors in the)4.016 F .75
+(global colormap for other applications.)133 537.6 R .75(The def)5.75 F
+.749(ault is 38, if changed you')-.1 F .749(ll need to also enable the)
+-.1 F F3(cmapInitialize)133 549.6 Q F0 .971
+(resource to force the Gterm widget to update it')3.471 F 3.471(sg)-.55
+G .972(lobal colormap resource in the X)-3.471 F(serv)133 561.6 Q(er)
+-.15 E(.)-.55 E F3(cmapInitialize)108 578.4 Q F0 .385
+(Initialize the ximtool colormap at startup.)133 590.4 R .385
+(When resetting the)5.385 F F3(basePixel)2.885 E F0 .385
+(resource or colormap this is)2.885 F .719
+(required in order to force the Gterm widget to update it')133 602.4 R
+3.22(sg)-.55 G .72(lobal colormap resource in the X serv)-3.22 F(er)-.15
+E(.)-.55 E(The def)133 614.4 Q(ault is F)-.1 E(alse.)-.15 E F3
+(cmapInterpolate)108 631.2 Q F0
+(Interpolate the colormap to the number of display colors.)133 643.2 Q
+(The def)5 E(ault is T)-.1 E(rue.)-.35 E F3(cmapName)108 660 Q F0 1.276
+(Name used for pri)133 672 R -.25(va)-.25 G 1.276(te colormap.).25 F
+1.276(The def)6.276 F 1.276(ault for all IRAF imaging applications is)
+-.1 F F3(ima)3.775 E -.1(ge)-.1 G F0 6.275(.G).1 G(term)-6.275 E .16
+(widget based imaging applications which ha)133 684 R .46 -.15(ve t)-.2
+H .16(he same v).15 F .16(alue of cmapName will share the same col-)-.25
+F(ormap, minimizing colormap \215ashing and allo)133 696 Q
+(wing multiple applications to be run at the same time.)-.25 E
+(X11IRAF Project)72 768 Q(16 Dec 1996)137.62 E(1)203.45 E EP
+%%Page: 2 2
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 10
+/Times-Italic@0 SF(color0)108 84 Q F0(The widget background color)133 96
+Q 5(.T)-.55 G(he def)-5 E(ault is black.)-.1 E F1(color1)108 112.8 Q F0
+(The widget fore)133 124.8 Q(ground color)-.15 E 5(.T)-.55 G(he def)-5 E
+(ault is white.)-.1 E F1(color2)108 141.6 Q F0(thru)5 E F1(color9)5 E F0
+.765(Optional dra)133 153.6 R .765(wing colors.)-.15 F .764(The line co\
+lor used for graphics is set using an escape sequence to select)5.765 F
+(the current color inde)133 165.6 Q 2.5(x. See)-.15 F F1
+(Gterm I/O Escape Sequences)2.5 E F0(belo)2.5 E 2.5(wf)-.25 G
+(or more details.)-2.5 E F1(cr)108 182.4 Q(osshairCur)-.45 E(sorColor)
+-.1 E F0(Color of the full screen crosshair cursor)133 194.4 Q(.)-.55 E
+F1(defaultMark)108 211.2 Q(er)-.1 E F0(Def)133 223.2 Q .353(ault mark)
+-.1 F .353(er type.)-.1 F .353(Options include)5.353 F F1(te)2.853 E(xt)
+-.2 E F0(,)A F1(line)2.853 E F0(,)A F1(polyline)2.853 E F0(,)A F1 -.37
+(re)2.853 G(ctangle).37 E F0(,)A F1(box)2.853 E F0(,)A F1(cir)2.853 E
+(cle)-.37 E F0(,)A F1(ellipse)2.853 E F0 2.853(,a)C(nd)-2.853 E F1
+(polygon)2.854 E F0(.)A(The def)133 235.2 Q(ault is)-.1 E F1 -.37(re)2.5
+G(ctangle).37 E F0(.)A F1(deiconifyW)108 252 Q(indow)-.55 E F0
+(De-iconify the Gterm graphics windo)133 264 Q 2.5(ww)-.25 G(hen acti)
+-2.5 E -.25(va)-.25 G 2.5(ted. The).25 F(def)2.5 E(ault is F)-.1 E
+(alse.)-.15 E F1(dialo)108 280.8 Q(gBgColor)-.1 E F0 .262
+(Dialog box \(i.e. status line\) background color)133 292.8 R 5.261(.D)
+-.55 G .261(ialog te)-5.261 F .261(xt is te)-.15 F .261(xt which is dra)
+-.15 F .261(wn into the dialog area)-.15 F .769
+(at the bottom of the gterm windo)133 304.8 R 2.069 -.65(w, i)-.25 H
+3.269(ti).65 G 3.269(st)-3.269 G .769
+(ransient and is not a permanent part of the graphics being)-3.269 F
+(dra)133 316.8 Q 2.925(wn. Dialog)-.15 F(te)2.925 E .424(xt is normally\
+ used to interact with the user or to display messages during program)
+-.15 F(operation, without af)133 328.8 Q(fecting the graphics being dra)
+-.25 E(wn.)-.15 E F1(dialo)108 345.6 Q(gFgColor)-.1 E F0
+(Dialog box \(i.e. status line\) fore)133 357.6 Q(ground color)-.15 E(.)
+-.55 E F1(ginmodeBlinkInterval)108 374.4 Q F0
+(Graphics cursor blink interv)133 386.4 Q
+(al, time is speci\214ed in milliseconds.)-.25 E(The def)5 E(ault is 0.)
+-.1 E F1(ginmodeCur)108 403.2 Q(sor)-.1 E F0(Graphics mode cursor type.)
+133 415.2 Q(The def)5 E
+(ault is a full screen cursor custom to the widget.)-.1 E F1(height)108
+432 Q F0(Height of the Gterm windo)133 444 Q 3.8 -.65(w. T)-.25 H
+(he def).65 E(ault is 480.)-.1 E F1(idleCur)108 460.8 Q(sor)-.1 E F0
+(Cursor to use when not in graphics mode.)133 472.8 Q F1(mark)108 489.6
+Q(erHighlightColor)-.1 E F0 .835(Highlight color for the acti)133 501.6
+R 1.135 -.15(ve m)-.25 H(ark).15 E(er)-.1 E 5.835(.W)-.55 G .835
+(hen the pointer mo)-5.835 F -.15(ve)-.15 G 3.335(si).15 G .835
+(nto a mark)-3.335 F .835(er is it mark)-.1 F .835(ed "acti)-.1 F -.15
+(ve)-.25 G(",).15 E(the highlight color and width change to which mark)
+133 513.6 Q(er is acti)-.1 E -.15(ve)-.25 G 5(.T).15 G(he def)-5 E
+(ault is green.)-.1 E F1(mark)108 530.4 Q(erHighlightW)-.1 E(idth)-.55 E
+F0(Highlight width for the acti)133 542.4 Q .3 -.15(ve m)-.25 H(ark).15
+E(er)-.1 E 2.5(.T)-.55 G(he def)-2.5 E(ault is 2.)-.1 E F1(maxColor)108
+559.2 Q(s)-.1 E F0 .255(The maximum number of colors to use in the pri)
+133 571.2 R -.25(va)-.25 G .254(te global colormap, the def).25 F .254
+(ault is 216.)-.1 F .254(Out of this)5.254 F 1.526
+(number 10 colors \(the)133 583.2 R F1(color0)4.026 E F0(theu)4.026 E F1
+(color9)4.026 E F0 -.25(va)4.026 G 1.526(lues\) are reserv).25 F 1.527
+(ed by the widget as static colors, the)-.15 F
+(remainder may be allocated for images.)133 595.2 Q F1 -.15(ra)108 612 S
+(iseW).15 E(indow)-.55 E F0(Raise the windo)133 624 Q 2.5(ww)-.25 G
+(hen acti)-2.5 E -.15(ve)-.25 G 5(.T).15 G(he def)-5 E(ault is F)-.1 E
+(alse.)-.15 E F1(warpCur)108 640.8 Q(sor)-.1 E F0 -.8(Wa)133 652.8 S
+(rp the cursor to the windo).8 E 2.5(ww)-.25 G(hen acti)-2.5 E -.15(ve)
+-.25 G 5(.T).15 G(he def)-5 E(ault is F)-.1 E(alse.)-.15 E F1(width)108
+669.6 Q F0 -.4(Wi)133 681.6 S(dth of the Gterm windo).4 E 3.8 -.65(w. T)
+-.25 H(he def).65 E(ault is 640.)-.1 E(X11IRAF Project)72 768 Q
+(16 Dec 1996)137.62 E(2)203.45 E EP
+%%Page: 3 3
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 9
+/Times-Bold@0 SF(GTERM WIDGET RESOURCES)72 84 Q/F2 10/Times-Bold@0 SF
+(Class Hierar)87 96 Q(ch)-.18 E(y)-.15 E(Cor)108 108 Q 2.5(e-)-.18 G 2.5
+(>G)-2.5 G(term)-2.5 E(Resour)87 124.8 Q(ces)-.18 E F0 1.38
+(When crating a Gterm widget instance, the follo)108 136.8 R 1.38
+(wing resources are retrie)-.25 F -.15(ve)-.25 G 3.88(df).15 G 1.38
+(rom the ar)-3.88 F 1.38(guments list or)-.18 F
+(from the resource database:)108 148.8 Q F2 86.29(Name Class)105.715
+172.8 R -.74(Ty)2.5 G 15.59(pe Default).74 F(Description)38.33 E .4 LW
+542.285 177.3 105.715 177.3 DL 542.285 179.3 105.715 179.3 DL F0(alphaF)
+105.715 188.8 Q 66.43(ont1 XF)-.15 F 12.5(ontStruct nil2)-.15 F
+(Graphics fonts)54.43 E(alphaF)105.715 200.8 Q 66.43(ont2 XF)-.15 F 12.5
+(ontStruct 5x8)-.15 F(")69.99 E(alphaF)105.715 212.8 Q 66.43(ont3 XF)
+-.15 F 12.5(ontStruct 6x10)-.15 F(")64.99 E(alphaF)105.715 224.8 Q 66.43
+(ont4 XF)-.15 F 12.5(ontStruct 7x13)-.15 F(")64.99 E(alphaF)105.715
+236.8 Q 66.43(ont5 XF)-.15 F 12.5(ontStruct 8x13)-.15 F(")64.99 E
+(alphaF)105.715 248.8 Q 66.43(ont6 XF)-.15 F 12.5(ontStruct 9x15)-.15 F
+(")64.99 E(alphaF)105.715 260.8 Q 66.43(ont7 XF)-.15 F 12.5
+(ontStruct 9x15)-.15 F(")64.99 E(alphaF)105.715 272.8 Q 66.43(ont8 XF)
+-.15 F 12.5(ontStruct 9x15)-.15 F(")64.99 E(basePix)105.715 284.8 Q 73.1
+(el Int)-.15 F 57.49(38 Base)53.19 F(of pri)2.5 E -.25(va)-.25 G
+(te global colormap).25 E -.2(bu)105.715 296.8 S 65.37(syCursor String)
+.2 F -.1(wa)39.85 G 43.71(tch Cursor).1 F(to use when application is b)
+2.5 E(usy)-.2 E -.2(bu)105.715 308.8 S 30.92(syCursorBgColor F).2 F(ore)
+-.15 E 15.44(ground white)-.15 F(Busy cursor background color)47.77 E
+-.2(bu)105.715 320.8 S 32.03(syCursorFgColor F).2 F(ore)-.15 E 15.44
+(ground black)-.15 F(Busy cursor fore)48.33 E(ground color)-.15 E 59.08
+(cacheRasters String)105.715 332.8 R 15.29(whenNeeded Sa)39.85 F .3 -.15
+(ve r)-.2 H(asters as serv).15 E(er pixmaps for f)-.15 E(aster access)
+-.1 E 54.07(cmapInitialize Boolean)105.715 344.8 R -.15(Fa)30.97 G 46.53
+(lse Initialize).15 F(colormap at startup)2.5 E 46.3
+(cmapInterpolate Boolean)105.715 356.8 R -.35(Tr)30.97 G 48.96
+(ue Interpolate).35 F(colormap)2.5 E 65.74(cmapName String)105.715 368.8
+R(def)39.85 E 39.82(ault Custom)-.1 F(colormap name)2.5 E(cmapShado)
+105.715 380.8 Q 60.15(wI)-.25 G 50.69(nt 10)-60.15 F(Colormap shado)
+59.99 E 2.5(wi)-.25 G(nterv)-2.5 E(al)-.25 E 60.74(cmapUpdate Int)
+105.715 392.8 R 57.49(60 Colormap)53.19 F(update interv)2.5 E(al)-.25 E
+85.73(color0 Background)105.715 404.8 R 45.83(black Def)15.42 F
+(ault graphics background color)-.1 E 85.73(color1 F)105.715 416.8 R
+(ore)-.15 E 15.44(ground white)-.15 F(Def)47.77 E(ault graphics fore)-.1
+E(ground color)-.15 E 85.73(color2 F)105.715 428.8 R(ore)-.15 E 15.44
+(ground red)-.15 F(Optional dra)57.22 E(wing color)-.15 E 85.73
+(color3 F)105.715 440.8 R(ore)-.15 E 15.44(ground green)-.15 F(")62.78 E
+85.73(color4 F)105.715 452.8 R(ore)-.15 E 15.44(ground blue)-.15 F(")
+67.77 E 85.73(color5 F)105.715 464.8 R(ore)-.15 E 15.44(ground c)-.15 F
+63.76(yan ")-.15 F 85.73(color6 F)105.715 476.8 R(ore)-.15 E 15.44
+(ground yello)-.15 F 58.02(w")-.25 G 85.73(color7 F)105.715 488.8 R(ore)
+-.15 E 15.44(ground magenta)-.15 F(")51.11 E 85.73(color8 F)105.715
+500.8 R(ore)-.15 E 15.44(ground purple)-.15 F(")59.44 E 85.73(color9 F)
+105.715 512.8 R(ore)-.15 E 15.44(ground darkslate)-.15 F 28.77(gray ")
+-.15 F(cop)105.715 524.8 Q 53.06(yOnResize Boolean)-.1 F -.35(Tr)30.97 G
+48.96(ue Cop).35 F 2.5(yr)-.1 G(aster when resized)-2.5 E 25.18
+(crosshairCursorColor F)105.715 536.8 R(ore)-.15 E 15.44(ground red)-.15
+F(Full-screen cursor color)57.22 E(def)105.715 548.8 Q(aultMark)-.1 E
+54.28(er String)-.1 F 30.84(rectangle Def)39.85 F(ault mark)-.1 E
+(er type)-.1 E(deiconifyW)105.715 560.8 Q(indo)-.4 E 42.22(wB)-.25 G
+28.47(oolean F)-42.22 F 46.53(alse Deiconify)-.15 F(windo)2.5 E 2.5(ww)
+-.25 G(hen acti)-2.5 E -.15(ve)-.25 G 51.83(dialogBgColor F)105.715
+572.8 R(ore)-.15 E 15.44(ground yello)-.15 F 43.02(wS)-.25 G
+(tatus line background color)-43.02 E 52.94(dialogFgColor F)105.715
+584.8 R(ore)-.15 E 15.44(ground black)-.15 F(Status line fore)48.33 E
+(ground color)-.15 E(dialogF)105.715 596.8 Q 63.09(ont1 XF)-.15 F 12.5
+(ontStruct nil2)-.15 F(Status line fonts)54.43 E(dialogF)105.715 608.8 Q
+63.09(ont2 XF)-.15 F 12.5(ontStruct 5x8)-.15 F(")69.99 E(dialogF)105.715
+620.8 Q 63.09(ont3 XF)-.15 F 12.5(ontStruct 6x10)-.15 F(")64.99 E
+(dialogF)105.715 632.8 Q 63.09(ont4 XF)-.15 F 12.5(ontStruct 7x13)-.15 F
+(")64.99 E(dialogF)105.715 644.8 Q 63.09(ont5 XF)-.15 F 12.5
+(ontStruct 8x13)-.15 F(")64.99 E(dialogF)105.715 656.8 Q 63.09(ont6 XF)
+-.15 F 12.5(ontStruct 9x15)-.15 F(")64.99 E(dialogF)105.715 668.8 Q
+63.09(ont7 XF)-.15 F 12.5(ontStruct 9x15)-.15 F(")64.99 E(dialogF)
+105.715 680.8 Q 63.09(ont8 XF)-.15 F 12.5(ontStruct 9x15)-.15 F(")64.99
+E(ginmodeBlinkInterv)105.715 692.8 Q 23.2(al Int)-.25 F 64.99(0G)53.19 G
+(raphics cursor blink interv)-64.99 E(al)-.25 E 49.06
+(ginmodeCursor String)105.715 704.8 R 12.5(full_crosshair Graphics)39.85
+F(cursor type)2.5 E 14.61(ginmodeCursorBgColor F)105.715 716.8 R(ore)
+-.15 E 15.44(ground black)-.15 F(Graphics cursor background color)48.33
+E(X11IRAF Project)72 768 Q(16 Dec 1996)137.62 E(3)203.45 E EP
+%%Page: 4 4
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R 15.72
+(ginmodeCursorFgColor F)105.715 84 R(ore)-.15 E 15.44(ground white)-.15
+F(Graphics cursor fore)47.77 E(ground color)-.15 E 86.28
+(height Dimension)105.715 96 R 52.49(480 Height)20.41 F
+(of graphics windo)2.5 E(w)-.25 E 69.06(idleCursor String)105.715 108 R
+50.26(Plus Idle)39.85 F(cursor type)2.5 E 34.61(idleCursorBgColor F)
+105.715 120 R(ore)-.15 E 15.44(ground white)-.15 F
+(Idle cursor background color)47.77 E 35.72(idleCursorFgColor F)105.715
+132 R(ore)-.15 E 15.44(ground black)-.15 F(Idle cursor fore)48.33 E
+(ground color)-.15 E(mark)105.715 144 Q 23.61(erBoxKnotColor F)-.1 F
+(ore)-.15 E 15.44(ground blue)-.15 F -1.11(Ve)52.77 G(rte)1.11 E 2.5(xk)
+-.15 G(not color)-2.5 E(mark)105.715 156 Q 29.17(erBoxKnotSize Int)-.1 F
+64.99(0V)53.19 G(erte)-66.1 E 2.5(xk)-.15 G(not size)-2.5 E(mark)105.715
+168 Q 25.28(erBoxLineColor F)-.1 F(ore)-.15 E 15.44(ground green)-.15 F
+(Mark)47.78 E(er border color)-.1 E(mark)105.715 180 Q 15.84
+(erCircleKnotColor F)-.1 F(ore)-.15 E 15.44(ground blue)-.15 F -1.11(Ve)
+52.77 G(rte)1.11 E 2.5(xk)-.15 G(not color)-2.5 E(mark)105.715 192 Q
+21.4(erCircleKnotSize Int)-.1 F 64.99(0V)53.19 G(erte)-66.1 E 2.5(xk)
+-.15 G(not size)-2.5 E(mark)105.715 204 Q 17.51(erCircleLineColor F)-.1
+F(ore)-.15 E 15.44(ground green)-.15 F(Mark)47.78 E(er border color)-.1
+E(mark)105.715 216 Q 21.39(erCursorBgColor F)-.1 F(ore)-.15 E 15.44
+(ground black)-.15 F(Cursor background when in mark)48.33 E(er)-.1 E
+(mark)105.715 228 Q 22.5(erCursorFgColor F)-.1 F(ore)-.15 E 15.44
+(ground yello)-.15 F 43.02(wC)-.25 G(ursor fore)-43.02 E
+(ground when in mark)-.15 E(er)-.1 E(mark)105.715 240 Q 12.5
+(erEllipseKnotColor F)-.1 F(ore)-.15 E 15.44(ground blue)-.15 F -1.11
+(Ve)52.77 G(rte)1.11 E 2.5(xk)-.15 G(not color)-2.5 E(mark)105.715 252 Q
+18.06(erEllipseKnotSize Int)-.1 F 64.99(0V)53.19 G(erte)-66.1 E 2.5(xk)
+-.15 G(not size)-2.5 E(mark)105.715 264 Q 14.17(erEllipseLineColor F)-.1
+F(ore)-.15 E 15.44(ground green)-.15 F(Mark)47.78 E(er border color)-.1
+E(mark)105.715 276 Q 69.16(erFill Boolean)-.1 F -.15(Fa)30.97 G 46.53
+(lse Flood).15 F(\214ll mark)2.5 E(er area with)-.1 E/F1 10
+/Times-Italic@0 SF(mark)2.5 E(erF)-.1 E(illColor)-.45 E F0(mark)105.715
+288 Q 34.71(erFillBgColor F)-.1 F(ore)-.15 E 15.44(ground black)-.15 F
+(Fill area background color)48.33 E(mark)105.715 300 Q 46.38
+(erFillColor F)-.1 F(ore)-.15 E 15.44(ground slate)-.15 F 31.54
+(gray Flood)-.15 F(\214ll color)2.5 E(mark)105.715 312 Q 48.6
+(erFillStyle Int)-.1 F 32.47(FillSolid Fill)53.19 F(area style)2.5 E
+(mark)105.715 324 Q 21.94(erHighlightColor F)-.1 F(ore)-.15 E 15.44
+(ground green)-.15 F(Mark)47.78 E(er highlight color)-.1 E(mark)105.715
+336 Q(erHighlightW)-.1 E 20.12(idth Int)-.4 F 64.99(2M)53.19 G(ark)
+-64.99 E(er highlight line width)-.1 E(mark)105.715 348 Q 21.95
+(erLineKnotColor F)-.1 F(ore)-.15 E 15.44(ground blue)-.15 F -1.11(Ve)
+52.77 G(rte)1.11 E 2.5(xk)-.15 G(not color)-2.5 E(mark)105.715 360 Q
+27.51(erLineKnotSize Int)-.1 F 64.99(5V)53.19 G(erte)-66.1 E 2.5(xk)-.15
+G(not size)-2.5 E(mark)105.715 372 Q 23.62(erLineLineColor F)-.1 F(ore)
+-.15 E 15.44(ground green)-.15 F(Line mark)47.78 E(er color)-.1 E(mark)
+105.715 384 Q 44.17(erLineStyle Int)-.1 F 28.04(LineSolid Line)53.19 F
+(mark)2.5 E(er line style)-.1 E(mark)105.715 396 Q(erLineW)-.1 E 40.13
+(idth Int)-.4 F 64.99(1L)53.19 G(ine mark)-64.99 E(er width)-.1 E(mark)
+105.715 408 Q 19.72(erPgonKnotColor F)-.1 F(ore)-.15 E 15.44
+(ground blue)-.15 F -1.11(Ve)52.77 G(rte)1.11 E 2.5(xk)-.15 G(not color)
+-2.5 E(mark)105.715 420 Q 25.28(erPgonKnotSize Int)-.1 F 64.99(5V)53.19
+G(erte)-66.1 E 2.5(xk)-.15 G(not size)-2.5 E(mark)105.715 432 Q 21.39
+(erPgonLineColor F)-.1 F(ore)-.15 E 15.44(ground green)-.15 F(Mark)47.78
+E(er border color)-.1 E(mark)105.715 444 Q 21.95(erRectKnotColor F)-.1 F
+(ore)-.15 E 15.44(ground blue)-.15 F -1.11(Ve)52.77 G(rte)1.11 E 2.5(xk)
+-.15 G(not color)-2.5 E(mark)105.715 456 Q 27.51(erRectKnotSize Int)-.1
+F 64.99(0V)53.19 G(erte)-66.1 E 2.5(xk)-.15 G(not size)-2.5 E(mark)
+105.715 468 Q 23.62(erRectLineColor F)-.1 F(ore)-.15 E 15.44
+(ground green)-.15 F(Mark)47.78 E(er border color)-.1 E(mark)105.715 480
+Q(erT)-.1 E -.15(ex)-.7 G 31.13(tBgColor F).15 F(ore)-.15 E 15.44
+(ground slate)-.15 F 31.54(gray T)-.15 F -.15(ex)-.7 G 2.5(tm).15 G(ark)
+-2.5 E(er background color)-.1 E(mark)105.715 492 Q(erT)-.1 E -.15(ex)
+-.7 G 37.81(tBorder Int).15 F 64.99(2T)53.19 G -.15(ex)-65.69 G 2.5(tm)
+.15 G(ark)-2.5 E(er border width)-.1 E(mark)105.715 504 Q(erT)-.1 E -.15
+(ex)-.7 G 42.8(tColor F).15 F(ore)-.15 E 15.44(ground yello)-.15 F 43.02
+(wT)-.25 G -.15(ex)-43.72 G 2.5(tm).15 G(ark)-2.5 E(er te)-.1 E
+(xt color)-.15 E(mark)105.715 516 Q(erT)-.1 E -.15(ex)-.7 G(tF).15 E
+47.39(ont XF)-.15 F 12.5(ontStruct 6x13)-.15 F -1.25 -.7(Te x)49.99 H
+2.5(tm).7 G(ark)-2.5 E(er font)-.1 E(mark)105.715 528 Q(erT)-.1 E -.15
+(ex)-.7 G 24.47(tLineColor F).15 F(ore)-.15 E 15.44(ground green)-.15 F
+-1.25 -.7(Te x)47.78 H 2.5(tm).7 G(ark)-2.5 E(er line color)-.1 E(mark)
+105.715 540 Q(erT)-.1 E -.15(ex)-.7 G 41.13(tString String).15 F 40.83
+(NULL T)39.85 F -.15(ex)-.7 G 2.5(ts).15 G(tring)-2.5 E(mark)105.715 552
+Q(erT)-.1 E 33.97(ranslations String)-.35 F(def)39.85 E 39.82(ault Mark)
+-.1 F(er e)-.1 E -.15(ve)-.25 G(nt-to-actions translations).15 E 67.39
+(maxColors Int)105.715 564 R 52.49(216 Max)53.19 F
+(colors in custom colormap)2.5 E 54.06(maxMappings Int)105.715 576 R
+57.49(32 Max)53.19 F(image mappings)2.5 E 64.62(maxRasters Int)105.715
+588 R 52.49(512 Max)53.19 F(image rasters)2.5 E 73.52(nearEdge Int)
+105.715 600 R(1)53.19 E 5.68(Distance, in pix)353.785 600 R 5.68
+(els, between pointer and)-.15 F(mark)353.785 612 Q 2.674
+(er edge required for translation actions)-.1 F(for be in ef)353.785 624
+Q(fect.)-.25 E(nearV)105.715 636 Q(erte)-1.11 E 70.62(xI)-.15 G 50.69
+(nt 4)-70.62 F .03(Distance, in pix)353.785 636 R .03
+(els between pointer and mark)-.15 F(er)-.1 E -.15(ve)353.785 648 S(rte)
+.15 E 8.102(x\()-.15 G(i.e.)-8.102 E F1(knot)8.102 E F0 8.102(\)r)C
+5.602(equired for translation)-8.102 F(actions for be in ef)353.785 660
+Q(fect.)-.25 E(raiseW)105.715 672 Q(indo)-.4 E 61.11(wB)-.25 G 28.47
+(oolean F)-61.11 F 46.53(alse Raise)-.15 F(windo)2.5 E 2.5(ww)-.25 G
+(hen acti)-2.5 E -.15(ve)-.25 G 65.17(translations String)105.715 684 R
+(def)39.85 E 39.82(ault Ev)-.1 F(ent-to-actions translations)-.15 E
+(useT)105.715 696 Q 69.97(imers Boolean)-.35 F -.35(Tr)30.97 G 48.96
+(ue Ok).35 F(to use timers)2.5 E -.1(wa)105.715 708 S 64.17
+(rpCursor Boolean).1 F -.15(Fa)30.97 G 46.53(lse Enable).15 F -.1(wa)2.5
+G(rp cursor when acti).1 E -.15(ve)-.25 G(X11IRAF Project)72 768 Q
+(16 Dec 1996)137.62 E(4)203.45 E EP
+%%Page: 5 5
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R 88.5
+(width Dimension)105.715 84 R 52.49(640 Height)20.41 F
+(of graphics windo)2.5 E(w)-.25 E 84.05(xorFill Boolean)105.715 96 R
+-.15(Fa)30.97 G 46.53(lse Fill).15 F(with GXxor)2.5 E 49.6
+(xorFillBgColor Int)105.715 108 R 52.49(255 Xor)53.19 F
+(-\214ll background color)-.2 E 61.27(xorFillColor Int)105.715 120 R
+64.99(2X)53.19 G(or)-64.99 E(-\214ll color)-.2 E/F1 9/Times-Bold@0 SF
+(GTERM WIDGET TRANSLA)72 148.8 Q(TIONS AND A)-.855 E(CTIONS)-.495 E F0
+(The def)108 160.8 Q(ault translations for a Gterm windo)-.1 E 2.5(wa)
+-.25 G(re:)-2.5 E(<Btn1Do)262.55 172.8 Q 12.5(wn>: m_create\(\))-.25 F
+(<Btn2Do)262.55 184.8 Q 12.5(wn>: crosshair\(on\))-.25 F 12.5
+(<Btn2Motion>: crosshair\(on\))257.29 196.8 R 12.5
+(<Btn2Up>: crosshair\(of)274.52 208.8 R(f\))-.25 E(<EnterW)250.74 220.8
+Q(indo)-.4 E 12.5(w>: enter)-.25 F(-windo)-.2 E(w\(\))-.25 E(<Lea)248.32
+232.8 Q -.15(ve)-.2 G -.4(Wi).15 G(ndo).4 E 12.5(w>: lea)-.25 F -.15(ve)
+-.2 G(-windo).15 E(w\(\))-.25 E(<K)268.82 244.8 Q -.15(ey)-.25 G 12.5
+(Press>: graphics-input\(\)).15 F 12.5(<Motion>: track-cursor\(\))276.74
+256.8 R(The a)108 273.6 Q -.25(va)-.2 G
+(ilable action procedures for a Gterm windo).25 E 2.5(wa)-.25 G(re:)-2.5
+E/F2 10/Times-Italic@0 SF(ignor)144 290.4 Q(e\(\))-.37 E F0(Ignore an e)
+67.6 E -.15(ve)-.25 G(nt.).15 E F2(gr)144 307.2 Q(aphics-input\(\))-.15
+E F0(Handle a graphics input request.)34.6 E F2(cr)144 324 Q
+(osshair\(on|of)-.45 E(f\))-.18 E F0(Display a crosshair cursor)32.88 E
+(.)-.55 E F2(tr)144 340.8 Q(ac)-.15 E(k-cur)-.2 E(sor\(\))-.1 E F0 -.35
+(Tr)43.8 G(ack crosshair cursor position.).35 E F2(enter)144 357.6 Q
+(-window\(\))-.2 E F0(Handle an EnterW)38.54 E(indo)-.4 E 2.5(we)-.25 G
+-.15(ve)-2.75 G(nt.).15 E F2(leave-window\(\))144 374.4 Q F0
+(Handle an Lea)37.79 E -.15(ve)-.2 G -.4(Wi).15 G(ndo).4 E 2.5(we)-.25 G
+-.15(ve)-2.75 G(nt.).15 E F2 -.37(re)144 391.2 S(set\(\)).37 E F0
+(Do a soft reset of the Gterm widget.)74.27 E F2(m_cr)144 408 Q
+(eate\(\))-.37 E F0(Create a ne)56.5 E 2.5(wm)-.25 G(ark)-2.5 E(er)-.1 E
+5(.V)-.55 G(alid types include)-6.11 E F2(te)316.18 420 Q 13.26(xt line)
+-.2 F 13.06(polyline r)22.21 F(ectangle)-.37 E 13.06(box cir)316.18 432
+R 12.31(cle ellipse)-.37 F(polygon)21.67 E F0 .71(The def)244 444 R .71
+(ault is)-.1 F F2 -.37(re)3.21 G(ctangle).37 E F0 3.21(,i)C 3.21(fn)
+-3.21 G 3.21(ot)-3.21 G .71(ype is gi)-3.21 F -.15(ve)-.25 G 3.21(nt).15
+G .71(he def)-3.21 F .71(ault type speci\214ed by)-.1 F(the)244 456 Q F2
+(mark)2.5 E(erT)-.1 E(ype)-.74 E F0(resource will be used.)2.5 E F1
+(GTERM MARKER TRANSLA)72 484.8 Q(TIONS AND A)-.855 E(CTIONS)-.495 E F0
+(The def)108 496.8 Q(ault translations for a mark)-.1 E(er are:)-.1 E
+(!Shift <Btn1Motion>:)214.325 520.8 Q(m_rotateResize\(\))15 E 12.5
+(<Btn1Motion>: m_mo)239.605 532.8 R -.15(ve)-.15 G(Resize\(\)).15 E
+(!Shift <Btn1Do)219.585 544.8 Q 12.5(wn>: m_raise\(\))-.25 F
+(m_markpos\(\))5 E(<Btn1Do)244.865 556.8 Q 12.5(wn>: m_raise\(\))-.25 F
+(m_markposAdd\(\))5 E 12.5(<Btn1Up>: m_redra)256.835 568.8 R
+(w\(\) m_destro)-.15 E(yNull\(\))-.1 E(<Btn2Do)244.865 580.8 Q 12.5
+(wn>: m_lo)-.25 F(wer\(\))-.25 E(<K)227.815 592.8 Q -.15(ey)-.25 G 12.5
+(>BackSpace: m_deleteDestro).15 F(y\(\))-.1 E(<K)246.145 604.8 Q -.15
+(ey)-.25 G 12.5(>Delete: m_deleteDestro).15 F(y\(\))-.1 E(<K)251.135
+616.8 Q -.15(ey)-.25 G 12.5(Press>: m_input\(\)).15 F 12.5
+(<Motion>: track-cursor\(\))259.055 628.8 R -.35(Tr)108 652.8 S .334
+(anslations af).35 F .333(fect only the currently acti)-.25 F .633 -.15
+(ve m)-.25 H(ark).15 E(er)-.1 E 2.833(,t)-.4 G .333
+(he cursor must be within)-2.833 F F2(nearEdg)2.833 E(e)-.1 E F0(pix)
+2.833 E .333(els of a mark)-.15 F(er)-.1 E(edge, or)108 664.8 Q F2
+(nearV)2.5 E(erte)-1.11 E(x)-.2 E F0(pix)2.5 E(els of a mark)-.15 E
+(er v)-.1 E(erte)-.15 E 2.5(xt)-.15 G 2.5(ot)-2.5 G(ak)-2.5 E 2.5(ee)-.1
+G -.25(ff)-2.5 G(ect.).25 E(The a)108 688.8 Q -.25(va)-.2 G
+(ilable action procedures for a mark).25 E(er are)-.1 E F2(m_cr)144
+705.6 Q(eate\(type\))-.37 E F0(Create a ne)29.84 E 2.5(wm)-.25 G(ark)
+-2.5 E(er)-.1 E 5(.V)-.55 G(alid types include)-6.11 E F2(te)311.18
+717.6 Q 13.26(xt line)-.2 F 13.06(polyline r)22.21 F(ectangle)-.37 E F0
+(X11IRAF Project)72 768 Q(16 Dec 1996)137.62 E(5)203.45 E EP
+%%Page: 6 6
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 10
+/Times-Italic@0 SF 13.06(box cir)311.18 84 R 12.31(cle ellipse)-.37 F
+(polygon)21.67 E F0 .322(The def)234 96 R .322(ault is)-.1 F F1 -.37(re)
+2.822 G(ctangle).37 E F0 2.822(,i)C 2.822(fn)-2.822 G 2.822(ot)-2.822 G
+.322(ype is gi)-2.822 F -.15(ve)-.25 G 2.822(nt).15 G .322(he def)-2.822
+F .322(ault type speci\214ed by the)-.1 F F1(mark)234 108 Q(erT)-.1 E
+(ype)-.74 E F0(resource will be used.)2.5 E F1(m_destr)144 124.8 Q
+(oy\(\))-.45 E F0(Destro)42.13 E 2.5(yt)-.1 G(he acti)-2.5 E .3 -.15
+(ve m)-.25 H(ark).15 E(er)-.1 E(.)-.55 E F1(m_destr)144 141.6 Q
+(oyNull\(\))-.45 E F0(Destro)24.9 E 2.5(yt)-.1 G(he acti)-2.5 E .3 -.15
+(ve m)-.25 H(ark).15 E(er if it is null sized.)-.1 E F1(m_set\(attrib)
+144 158.4 Q(ute)-.2 E 2.5(,v)-.1 G(alue)-2.5 E 2.5(,.)-.1 G(...\))-2.5 E
+F0(Set a mark)234 170.4 Q(er attrib)-.1 E 2.5(ute. V)-.2 F(alid attrib)
+-1.11 E(utes include)-.2 E F1 13.47(activated autoRedr)268.8 194.4 R
+22.66(aw \214ll)-.15 F(\214llBgColor)53.74 E 16.23(\214llColor \214llP)
+268.8 206.4 R 31.64(attern \214llStyle)-.8 F(font)34.3 E 25.13
+(height highlightColor)268.8 218.4 R(ima)14.44 E -.1(ge)-.1 G -.86 -.92
+(Te x).1 H 23.96(tk).92 G(notColor)-23.96 E 16.8(knotSize lineColor)
+268.8 230.4 R 27.36(lineStyle lineW)35.56 F(idth)-.55 E -.45(ro)268.8
+242.4 S 16.69(tangle sensitive).45 F(te)39.46 E 13.11(xtBgColor te)-.2 F
+(xtBor)-.2 E(der)-.37 E(te)268.8 254.4 Q 12.55(xtColor tr)-.2 F 23.76
+(anslations type)-.15 F(visible)47.64 E 27.9(width x)268.8 266.4 R(y)
+69.46 E(m_r)144 283.2 Q(aise\(\))-.15 E F0(Raise the acti)51.27 E .3
+-.15(ve m)-.25 H(ark).15 E(er to the top of the display list.)-.1 E F1
+(m_lower\(\))144 300 Q F0(Lo)48.34 E(wer the acti)-.25 E .3 -.15(ve m)
+-.25 H(ark).15 E(er to the bottom of the display list.)-.1 E F1
+(m_notify\(e)144 316.8 Q(vent, e)-.15 E(vent, ....\))-.15 E F0 1.545
+(Notify an)234 328.8 R 4.045(yc)-.15 G 1.545(lients that ha)-4.045 F
+1.845 -.15(ve r)-.2 H -.15(eg).15 G 1.544
+(istered callbacks for the speci\214ed type of).15 F -2.15 -.25(ev e)234
+340.8 T 2.5(nts. Recognized).25 F -2.15 -.25(ev e)2.5 H(nts include).25
+E F1 19.16(notify mo)313.8 352.8 R 12.5(veResize modify)-.1 F -.37(re)
+313.8 364.8 S(dr).37 E 13.57(aw destr)-.15 F 30.06(oy input)-.45 F 12.5
+(focusIn focusOut)313.8 376.8 R(constr)25.44 E(aint)-.15 E(m_input\(\))
+144 393.6 Q F0 .097(Notify an)50.56 F 2.597(yc)-.15 G .097
+(lients that ha)-2.597 F .398 -.15(ve r)-.2 H -.15(eg).15 G .098
+(istered a input callback that a input e).15 F -.15(ve)-.25 G .098
+(nt has).15 F(occurred.)234 405.6 Q F1(m_markpos\(\))144 422.4 Q F0
+(Mark the current position of the mark)36.68 E(er)-.1 E 2.5(,e)-.4 G
+(.g., so that it can later be erased.)-2.5 E F1(m_markposAdd\(\))144
+439.2 Q F0(Ex)20.57 E .464(ecute either the markpos or add action, depe\
+nding upon the pointer loca-)-.15 F 4.141(tion. If)234 451.2 R 1.641
+(the pointer is o)4.141 F -.15(ve)-.15 G 4.141(ra).15 G 4.141(na)-4.141
+G(cti)-4.141 E 1.941 -.15(ve m)-.25 H(ark).15 E 1.642
+(er at a location where the add)-.1 F 3.254(action can be e)234 463.2 R
+-.15(xe)-.15 G 3.254
+(cuted this is done, otherwise the markpos action is).15 F -.15(exe)234
+475.2 S(cuted.).15 E F1(m_r)144 492 Q(edr)-.37 E(aw\(\))-.15 E F0(Redra)
+42.75 E 2.5(wt)-.15 G(he acti)-2.5 E .3 -.15(ve m)-.25 H(ark).15 E(er)
+-.1 E(.)-.55 E F1(m_addPt\(\))144 508.8 Q F0(Add a point \(i.e. v)47.23
+E(erte)-.15 E 2.5(xk)-.15 G(not\).)-2.5 E F1 -.8(Po)2.5 G(lyline).8 E F0
+(and)2.5 E F1(polygon)2.5 E F0(mark)2.5 E(ers only)-.1 E(.)-.65 E F1
+(m_deletePt\(\))144 525.6 Q F0(Delete a point \(i.e. v)38.35 E(erte)-.15
+E 2.5(xk)-.15 G(not\).)-2.5 E F1(m_mo)144 542.4 Q(vePt\(\))-.1 E F0(Mo)
+41.23 E .3 -.15(ve a p)-.15 H(oint \(i.e. v).15 E(erte)-.15 E 2.5(xk)
+-.15 G(not\).)-2.5 E F1 -.8(Po)2.5 G(lyline).8 E F0(and)2.5 E F1
+(polygon)2.5 E F0(mark)2.5 E(ers only)-.1 E(.)-.65 E F1(m_deleteDestr)
+144 559.2 Q(oy\(\))-.45 E F0(Delete a point or destro)16.03 E 2.5(yam)
+-.1 G(ark)-2.5 E(er)-.1 E 2.5(,d)-.4 G
+(epending upon the pointer position.)-2.5 E F1(m_mo)144 576 Q(ve\(\))-.1
+E F0(Mo)50.12 E .3 -.15(ve a m)-.15 H(ark).15 E(er)-.1 E(.)-.55 E F1
+(m_r)144 592.8 Q(esize\(\))-.37 E F0(Resize a mark)48.16 E(er)-.1 E(.)
+-.55 E F1(m_mo)144 609.6 Q(veResize\(\))-.1 E F0(Mo)24.57 E 2.025 -.15
+(ve a p)-.15 H 1.725(oint or mark).15 F(er)-.1 E 4.225(,o)-.4 G 4.225
+(rr)-4.225 G 1.725(esize a mark)-4.225 F(er)-.1 E 4.225(,d)-.4 G 1.725
+(epending upon the pointer)-4.225 F(position.)234 621.6 Q F1(m_r)144
+638.4 Q(otate\(\))-.45 E F0(Rotate a mark)47.68 E(er)-.1 E(.)-.55 E F1
+(m_r)144 655.2 Q(otateResize\(\))-.45 E F0 1.547
+(Rotate or resize a mark)22.13 F(er)-.1 E 6.547(.A)-.55 G(mark)-2.5 E
+1.546(er is rotated if near a v)-.1 F(erte)-.15 E 4.046(xk)-.15 G(no)
+-4.046 E 2.846 -.65(w, o)-.25 H(r).65 E(resized if near an edge.)234
+667.2 Q/F2 9/Times-Bold@0 SF(GTERM I/O ESCAPE SEQ)72 696 Q(UENCES)-.09 E
+F0 1.075(XGterm uses escape sequences to pro)108 708 R 1.075
+(vide graphics emulation.)-.15 F 1.075(This protocol is an e)6.075 F
+1.076(xtension of the T)-.15 F(ek-)-.7 E .536
+(tronix 4012 graphics protocol.)108 720 R .536(The basic e)5.536 F .535
+(xtensions are patterned after the Retrographics VT640 graphics)-.15 F
+(X11IRAF Project)72 768 Q(16 Dec 1996)137.62 E(6)203.45 E EP
+%%Page: 7 7
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R .742(ter\
+minal, using GS \(octal \\035, aka Ctrl-]\) and CAN \(octal \\030, aka \
+Ctrl-x\) to switch between vt100 and)108 84 R 1.079(graphics modes.)108
+96 R 1.079(Additional e)6.079 F 1.079
+(xtensions are de\214ned to support adv)-.15 F 1.078
+(anced features such as color)-.25 F 3.578(,a)-.4 G 1.078(rea \214lls,)
+-3.578 F .606(graphics erasure, setting the cursor location under progr\
+am control, interacti)108 108 R .906 -.15(ve d)-.25 H .606
+(ialog via the "status line",).15 F(and so on.)108 120 Q 1.48
+(While these escape sequences can be used directly)108 144 R 3.98(,t)
+-.65 G 1.48(he best programmatic interf)-3.98 F 1.48
+(ace is to use the OBM)-.1 F(\()108 156 Q/F1 10/Times-Italic@0 SF 1.19
+(Object Mana)B -.1(ge)-.1 G(r).1 E F0 3.69(\)l)C 1.191
+(ibrary supplied with the XGterm source as part of the X11IRAF package.)
+-3.69 F(An)6.191 E 3.691(yT)-.15 G(ek-)-4.391 E .926
+(tronix-compatible graphics library will suf)108 168 R .926
+(\214ce for producing v)-.25 F .926
+(ector graphics, the added escape sequences)-.15 F
+(used by the Gterm widget are required to mak)108 180 Q 2.5(eu)-.1 G
+(se of imaging, area \214lls, the status line, etc.)-2.5 E .243
+(All escape sequences be)108 204 R .243(gin with an)-.15 F/F2 10
+/Times-Bold@0 SF(ESC)2.743 E F0 .243(character \(octal \\033\), follo)
+2.743 F .243(wed by up to three characters de\214ning)-.25 F .636
+(the action to be tak)108 216 R 3.136(en. All)-.1 F .636
+(strings in capital letters refer to the ASCII code \(e.g.)3.136 F F1
+(LF)3.136 E F0 .636(is the ASCII linefeed)3.136 F .319(code\), a three \
+digit number preceeded by a '\264 refers to an octal code \(e.g.)108 228
+R 5("1)5.319 G .319(2" is octal 12\) , all others are)-5 F
+(characters in the escape code \(e.g.)108 240 Q
+("/bc" are the three characters '/', 'b', and 'c'\).)5 E F2(ESCAPE SEQ)
+87 268.8 Q(UENCES)-.1 E(US)144 280.8 Q(CR)144 291.6 Q F0 1.789
+(Switch to alpha mode.)60.56 F 1.788(Characters are dra)6.789 F 1.788
+(wn in the graphics windo)-.15 F 4.288(wa)-.25 G 4.288(tt)-4.288 G(he)
+-4.288 E .694
+("current" position \(normally set beforehand with a GS/US v)219 303.6 R
+.694(ector mo)-.15 F -.15(ve)-.15 G .694(\), using).15 F 2.016
+(the alpha mode font. Receipt of an)219 315.6 R 4.516(yc)-.15 G 2.016
+(ontrol code causes alpha mode to be)-4.516 F -.15(ex)219 327.6 S(ited.)
+.15 E F2(GS)144 356.4 Q F0(Switch to v)61.66 E(ector polyline mode.)-.15
+E F2(FS)144 367.2 Q F0(Switch to v)63.33 E(ector polypoint mode.)-.15 E
+F2(RS)144 378 Q F0(Switch to v)62.22 E(ector mode, v)-.15 E
+(ertices are joined as a polygon.)-.15 E -.4(Wi)219 402 S 1.185
+(th all three codes, v).4 F 1.185
+(ertices and points are accumulated in a b)-.15 F(uf)-.2 E 1.186
+(fer and dis-)-.25 F .011(played when the b)219 414 R(uf)-.2 E .011
+(fer \214lls or when v)-.25 F .01
+(ector mode is terminated by receipt of an)-.15 F(y)-.15 E .188
+(control code.)219 426 R 2.688(Aw)5.188 G .188
+(orkstation open will be done if it hasn')-2.788 F 2.689(ta)-.18 G .189
+(lready been opened,)-2.689 F .271
+(no-op sequences GS-CAN are \214ltered out, since the)219 438 R 2.771
+(yw)-.15 G .271(ould only cause a point-)-2.871 F .109
+(less switch to the graphics frame and back without dra)219 450 R 2.609
+(wing. The)-.15 F .11(open w)2.61 F(orksta-)-.1 E .034
+(tion sequence is GS,US, or by the)219 462 R F1(xterm)2.534 E F0 .034
+(graphics start escape sequence "[?38h".)2.534 F F2(EM)144 490.8 Q F0
+1.249(Enter message mode.)58.89 F 1.249(In message mode input te)6.249 F
+1.249(xt is accumulated in a b)-.15 F(uf)-.2 E(fer)-.25 E .49(and e)219
+502.8 R -.15(ve)-.25 G .489(ntually passed to the object manager).15 F
+2.989(,w)-.4 G .489(hich deli)-2.989 F -.15(ve)-.25 G .489
+(rs the message to the).15 F 2.227(referenced object.)219 514.8 R 2.227
+(Messages are used to do)7.227 F 2.227(wnload the user interf)-.25 F
+2.228(ace to be)-.1 F -.15(exe)219 526.8 S .52
+(cuted by the object manager).15 F 3.02(,a)-.4 G .52(nd during e)-3.02 F
+-.15(xe)-.15 G .52(cution messages are used to set).15 F .723(the v)219
+538.8 R .723(alues of user interf)-.25 F .723(ace parameters to allo)-.1
+F 3.223(wt)-.25 G .724(he UI to track the state of the)-3.223 F
+(client application.)219 550.8 Q F2(CAN)144 579.6 Q F0(Close w)53.34 E
+(orkstation and enter command mode.)-.1 E F2(BEL)144 596.4 Q F0
+(Ring the screen bell.)54.99 E F2(ENQ)144 625.2 Q F0 .99
+(Return terminal status.)53.33 F .99(Returned v)5.99 F .99
+(alues include the terminal mode, and alpha)-.25 F
+(cursor x and y position.)219 637.2 Q F2(SUB)144 654 Q F0
+(Initiate a cursor read, v)55.55 E(alues are returned in windo)-.25 E
+2.5(wc)-.25 G(oordinates.)-2.5 E F2(/SUB)144 670.8 Q F0(Return windo)
+52.77 E 2.5(wc)-.25 G(ursor position in raster coordinates.)-2.5 E F2
+(FF)144 687.6 Q F0(Clear the screen.)62.78 E F2(/f)144 704.4 Q F0
+(Set current cursor position.)68.89 E(X11IRAF Project)72 768 Q
+(16 Dec 1996)137.62 E(7)203.45 E EP
+%%Page: 8 8
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 10
+/Times-Bold@0 SF(0)144 84 Q F0
+(Set character size 0. \(Currently ignored\).)70 E F1(1)144 94.8 Q F0
+(Set character size 1. \(Currently ignored\).)70 E F1(2)144 105.6 Q F0
+(Set character size 2. \(Currently ignored\).)70 E F1(3)144 116.4 Q F0
+(Set character size 3. \(Currently ignored\).)70 E F1(/0d)144 133.2 Q F0
+(Set color inde)61.66 E(x.)-.15 E F1(/1d)144 144 Q F0
+(Clear graphics screen.)61.66 E F1(/2d)144 154.8 Q F0(In)61.66 E -.15
+(ve)-.4 G(rt graphics screen).15 E F1(`)144 171.6 Q F0
+(Select line style 0. \(Solid\))71.67 E F1(a)144 182.4 Q F0
+(Select line style 1. \(Dashed\))70 E F1(b)144 193.2 Q F0
+(Select line style 2. \(Dotted\))69.44 E F1(c)144 204 Q F0
+(Select line style 3. \(DashDot\))70.56 E F1(d)144 214.8 Q F0
+(Select line style 4. \(Dash3Dot\))69.44 E F1(/0w)144 231.6 Q F0
+(Select line width 0.)60 E F1(/1w)144 242.4 Q F0(Select line width 1.)60
+E F1(/2w)144 253.2 Q F0(Select line width 2.)60 E F1(/nw)144 264 Q F0
+(Select line width 3.)59.44 E F1(/0c)144 280.8 Q F0
+(Select line color 0.)62.78 E F1(/1c)144 291.6 Q F0
+(Select line color 1.)62.78 E F1(/2c)144 302.4 Q F0
+(Select line color 2.)62.78 E F1(/3c)144 313.2 Q F0
+(Select line color 3.)62.78 E F1(/4c)144 324 Q F0(Select line color 4.)
+62.78 E F1(/5c)144 334.8 Q F0(Select line color 5.)62.78 E F1(/6c)144
+345.6 Q F0(Select line color 6.)62.78 E F1(/7c)144 356.4 Q F0
+(Select line color 7.)62.78 E F1(/8c)144 367.2 Q F0
+(Select line color 8.)62.78 E F1(/9c)144 378 Q F0(Select line color 9.)
+62.78 E F1(IMA)87 406.8 Q(GING ESCAPE SEQ)-.55 E(UENCES)-.1 E F0
+(These are encoded as follo)108 418.8 Q(ws:)-.25 E F1(ESC)198.99 442.8 Q
+F0(<code> [)2.5 E/F2 10/Times-Italic@0 SF 2.5(P;P)2.5 G F0 2.5(;.)C
+(.. ] <)-2.5 E F2(data)A F0(>)A(where)108 466.8 Q F2(code)2.5 E F0
+(is a character sequence and)2.5 E F2(P)2.5 E F0
+(is an ASCII encoded parameter described belo)2.5 E -.65(w.)-.25 G F1
+(/nc)144 483.6 Q F0(Select line color)62.22 E 5(.P)-.55 G
+(arameter is the color number in the range 0-9.)-5.15 E F1(sr)144 500.4
+Q(e)-.18 E F2(Reset)62.41 E F0 5(.P)C(arameters are "reset-str".)-5.15 E
+F1(ssz)144 517.2 Q F2(Resize)62.78 E F0 2.5(.P)C
+(arameters are "resize-str".)-2.65 E F1(rir)144 534 Q F2(Initialize r)
+63.34 E(aster)-.15 E F0(.)A F1 -.18(rc)144 550.8 S(r).18 E F2(Cr)61.86 E
+.9(eate a r)-.37 F(aster)-.15 E F0 5.9(.P)C .9
+(arameters are raster number)-6.05 F 3.4(,t)-.4 G .9
+(ype, width, height, and depth.)-3.4 F -.8(Ty)219 562.8 S .198
+(pe is 1 for a normal \(client\) raster).8 F 2.698(,2f)-.4 G .198
+(or cached in serv)-2.698 F .197(er memory)-.15 F 2.697(,o)-.65 G 2.697
+(r0i)-2.697 G 2.697(fy)-2.697 G(ou)-2.697 E(don')219 574.8 Q 2.5(tc)-.18
+G 2.5(are. Depth)-2.5 F(may be 1, 8, 16, or 32.)2.5 E F1(rde)144 591.6 Q
+F2(Destr)60.56 E(oy a r)-.45 E(aster)-.15 E F0 5(.P)C
+(arameter is raster number)-5.15 E(.)-.55 E F1 -.18(rq)144 608.4 S(r).18
+E F2 .149(Query a r)60.74 F(aster)-.15 E F0 5.149(.P)C .149
+(arameter is raster number)-5.299 F 5.149(.O)-.55 G .149
+(utput parameters are status, type,)-5.149 F(width, height, and depth e\
+ncoded in the string ""\\033[5;%d;%d;%d;%d;%d]".)219 620.4 Q F1(rsr)144
+637.2 Q F2(Select a r)62.23 E(aster)-.15 E F0 5(.P)C
+(arameter is raster number)-5.15 E(.)-.55 E F1(rwr)144 654 Q F2 .635
+(Write pixels to a r)58.9 F .634(ectangular r)-.37 F -.4(eg)-.37 G .634
+(ion of a r).4 F(aster)-.15 E F0 5.634(.P)C .634
+(arameters are raster number)-5.784 F(,)-.4 E 1.155
+(encoding type \(not used\), x1, y1, nx, n)219 666 R 2.455 -.65(y, a)
+-.15 H 1.156(nd depth follo).65 F 1.156(wed by \(nx*n)-.25 F 1.156
+(y\) data)-.15 F(pix)219 678 Q(els.)-.15 E F1(rrd)144 694.8 Q F2 2.223
+(Read fr)60.56 F 2.223(om a r)-.45 F 2.223(ectangular r)-.37 F -.4(eg)
+-.37 G 2.223(ion of a r).4 F(aster)-.15 E F0 7.223(.P)C 2.222
+(arameters are raster number)-7.373 F(,)-.4 E 1.155
+(encoding type \(not used\), x1, y1, nx, n)219 706.8 R 2.455 -.65(y, a)
+-.15 H 1.156(nd depth follo).65 F 1.156(wed by \(nx*n)-.25 F 1.156
+(y\) data)-.15 F(pix)219 718.8 Q(els.)-.15 E(X11IRAF Project)72 768 Q
+(16 Dec 1996)137.62 E(8)203.45 E EP
+%%Page: 9 9
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 10
+/Times-Bold@0 SF(rr)144 84 Q(p)-.1 E/F2 10/Times-Italic@0 SF(Refr)60.66
+E 2.298(esh r)-.37 F 2.298(aster pixels)-.15 F F0 7.298(.P)C 2.298
+(arameters are raster number)-7.448 F 4.798(,c)-.4 G 2.298
+(oordinate type \(0 for)-4.798 F(pix)219 96 Q
+(el, 1 for NDC\), x1, y1, nx, n)-.15 E -.65(y.)-.15 G F1(rsp)144 112.8 Q
+F2 .048(Set all the r)61.11 F .048(aster pixels in a r)-.15 F -.4(eg)
+-.37 G .048(ion to a single color).4 F F0 5.048(.P)C .048
+(arameters are raster num-)-5.198 F(ber)219 124.8 Q 3.484(,c)-.4 G .984
+(oordinate type \(0 for pix)-3.484 F .984
+(el, 1 for NDC\), x1, y1, nx, n)-.15 F 2.284 -.65(y, c)-.15 H(olor).65 E
+3.484(,a)-.4 G .984(nd raster)-3.484 F 3.125(operand. If)219 136.8 R
+(nx=n)3.125 E .625(y=0 the entire raster will be written.)-.15 F .626
+(Raster operands include)5.626 F(transient \(octal 020\), refresh_all \
+\(octal 040\), or refresh_none \(octal 100\).)219 148.8 Q F1 -.18(rc)144
+165.6 S(o).18 E F2 .142(Copy a r)61.3 F -.4(eg)-.37 G .142
+(ion of the sour).4 F .142(ce r)-.37 F .141(aster to a r)-.15 F -.4(eg)
+-.37 G .141(ion of the destination r).4 F(aster)-.15 E F0 7.641(.P)C
+(aram-)-7.791 E 2.031(eters are raster operand, source raster number)219
+177.6 R 4.531(,s)-.4 G 2.031(ource type, source x coord,)-4.531 F .424
+(source y coord, source width, source height, destination raster number)
+219 189.6 R 2.924(,d)-.4 G(estina-)-2.924 E 1.157(tion type, destinatio\
+n x coord, destination y coord, destination width, destina-)219 201.6 R
+.079(tion height, If the input and output re)219 213.6 R .078
+(gions are not the same size the subimage is)-.15 F .247
+(automatically scaled to \214t the destination re)219 225.6 R 2.747
+(gion. If)-.15 F .248(the destination e)2.747 F .248(xtent DNX)-.15 F
+.035(or DNY is ne)219 237.6 R -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G
+2.535(,t).15 G .035(he image is \215ipped in that axis.)-2.535 F .034
+(The type of spatial scaling)5.034 F 1.47
+(performed is determined by the scale f)219 249.6 R 1.47
+(actors \(zoom, dezoom, or no scaling\).)-.1 F .481(The rasterop ar)219
+261.6 R .481(gument is used to e)-.18 F -.15(xe)-.15 G .481
+(rcise \214ne control o).15 F -.15(ve)-.15 G 2.981(rh).15 G .98 -.25
+(ow t)-2.981 H .48(he mapping is).25 F .168(performed, e.g. to force a \
+refresh, implement a transient mapping, or in the case)219 273.6 R 1.926
+(of a dezoom \(man)219 285.6 R 1.926
+(y-to-one\) mapping, select the antialiasing technique to be)-.15 F
+(used.)219 297.6 Q F1(rwc)144 314.4 Q F2 .247(Write a colormap)58.9 F F0
+5.247(.P)C .247(arameters are colormap number)-5.397 F 2.747<2c8c>-.4 G
+.248(rst color and the number)-2.747 F(of colors follo)219 326.4 Q
+(wed by NC colors triples in the data.)-.25 E F1(rr)144 343.2 Q(c)-.18 E
+F2 .708(Return the color assignments for a r)61.86 F -.4(eg)-.37 G .707
+(ion of the named colormap).4 F F0 5.707(.P)C(arameters)-5.857 E .387
+(are colormap number)219 355.2 R 2.887<2c8c>-.4 G .388
+(rst color and the number of colors follo)-2.887 F .388(wed by NC col-)
+-.25 F(ors triples in the data.)219 367.2 Q F1(rlc)144 384 Q F2 .803
+(Load a colormap into the display)63.34 F F0 3.303(,o)C .802
+(ptionally scaling the colormap via a linear)-3.303 F .826
+(transformation in the process.)219 396 R -.15(Pa)5.826 G .826
+(rameters are the colormap number).15 F 3.326(,t)-.4 G .826(he of)-3.326
+F(fset)-.25 E -.25(va)219 408 S .232
+(lue, and the cursor x and Y coordinates in NDC units.).25 F .232
+(The colormap is unaf-)5.232 F 1.211(fected if of)219 420 R 1.212
+(fset=0.5, scale=1.0.)-.25 F 3.712(An)6.212 G -2.25 -.15(eg a)-3.712 H
+(ti).15 E 1.512 -.15(ve s)-.25 H 1.212(cale in).15 F -.15(ve)-.4 G 1.212
+(rts the image.).15 F 1.212(If map=0)6.212 F
+(the linear transformation is applied directly to the display colormap.)
+219 432 Q F1(rfc)144 448.8 Q F2 -1.77 -.55(Fr e)62.79 H 2.5(eac).55 G
+(olormap)-2.5 E F0 5(.P)C(arameter is the colormap number)-5.15 E(.)-.55
+E F1(rw)144 465.6 Q(o)-.1 E F2 .927(Write the IOmap)58.44 F F0 3.427(.P)
+C .927(arameters are the \214rst color and the number of colors, fol-)
+-3.577 F(lo)219 477.6 Q 1.241(wed by NC color triples in the data.)-.25
+F 1.242(An iomap is an optional lookup table)6.241 F 2.215(used to isol\
+ate the client application from the color model used within the)219
+489.6 R .646(Gterm widget.)219 501.6 R 2.246 -.8(To s)5.646 H .646
+(implify color allocation the Gterm widget de\214nes a logical).8 F
+1.185(color space where color 0 is the background, 1 the fore)219 513.6
+R 1.184(ground, 2-N are stati-)-.15 F .218
+(cally allocated standard colors, and colors N+1 and abo)219 525.6 R
+.518 -.15(ve a)-.15 H .219(re dynamically allo-).15 F 1.567
+(cated by the graphics application.)219 537.6 R 1.566
+(Less-demanding applications use only the)6.567 F .022
+(statically allocated, shared colors.)219 549.6 R .022
+(The widget internally maps these logical col-)5.022 F .54(ors to whate)
+219 561.6 R -.15(ve)-.25 G 3.039(rt).15 G .539(he windo)-3.039 F 3.039
+(ws)-.25 G .539(ystem requires, b)-3.039 F .539(ut pro)-.2 F .539
+(viding a well-de\214ned logi-)-.15 F 1.812(cal color space isolates th\
+e client from the details of color allocation in the)219 573.6 R
+(underlying windo)219 585.6 Q 2.5(ws)-.25 G(ystem.)-2.5 E 1.702(An ioma\
+p can be used to de\214ne a mapping between the color model of the)219
+609.6 R 1.153(client application and the Gterm color model \(when we sa\
+y color model here)219 621.6 R .235
+(we mean color allocation schemes for 8 bit pseudocolor\).)219 633.6 R
+.235(By def)5.235 F .235(ault the iomap)-.1 F .375(is one-to-one.)219
+645.6 R .375(The use of an iomap frees the client from ha)5.375 F .375
+(ving to w)-.2 F .375(orry about)-.1 F .976(color inde)219 657.6 R 3.476
+(xt)-.15 G .976(ranslations, and allo)-3.476 F .976
+(ws color tables to be combined in the widget)-.25 F .412
+(for greater ef)219 669.6 R(\214cienc)-.25 E 2.912(yw)-.15 G .413
+(hen color tables are serially applied.)-2.912 F .413(The iomap applies)
+5.413 F 1.073(to all color indices or pix)219 681.6 R 1.072(el v)-.15 F
+1.072(alues passed in i/o operations between the client)-.25 F
+(and the Gterm widget.)219 693.6 Q F1(rr)144 710.4 Q(o)-.18 E F2 .034
+(Read the IOmap)61.3 F F0 5.034(.R)C .034(eturn v)-5.034 F .034
+(alues are the \214rst color and the number of colors, fol-)-.25 F(lo)
+219 722.4 Q(wed by NC color triples in the data.)-.25 E(X11IRAF Project)
+72 768 Q(16 Dec 1996)137.62 E(9)203.45 E EP
+%%Page: 10 10
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 10
+/Times-Bold@0 SF(rim)144 84 Q/F2 10/Times-Italic@0 SF
+(Delete all mappings)59.45 E F0(and initialize the mapping subsystem.)
+2.5 E F1(rsm)144 100.8 Q F2 1.472(De\214ne a ne)58.34 F 3.972(wm)-.15 G
+1.472(apping function)-3.972 F F0 3.972(,o)C 3.972(rm)-3.972 G 1.471
+(odify an old one.)-3.972 F 1.471(If a ne)6.471 F 3.971(wm)-.25 G 1.471
+(apping is)-3.971 F 1.115
+(de\214ned it is merely enabled, and no refreshing of the screen tak)219
+112.8 R 1.116(es place until)-.1 F .37
+(either some mapped data is written to or the mapping is e)219 124.8 R
+.37(xplicitly refreshed.)-.15 F(If)5.37 E 1.057(an e)219 136.8 R 1.057
+(xisting mapping is modi\214ed the old and ne)-.15 F 3.558(wm)-.25 G
+1.058(appings are e)-3.558 F 1.058(xamined and)-.15 F .921(only those p\
+ortions of the destination rect for which the mapping changed are)219
+148.8 R 2.691(updated. This)219 160.8 R .192
+(permits minor changes to a mapping \(e.g. mo)2.691 F .192
+(ving an edge\) with-)-.15 F 1.769(out ha)219 172.8 R 1.769
+(ving to redra)-.2 F 4.268(wt)-.15 G 1.768(he entire re)-4.268 F 4.268
+(gion. Re)-.15 F 1.768(gions of the destination dra)-.15 F -.1(wa)-.15 G
+(ble).1 E 1.82(which were pre)219 184.8 R 1.82(viously co)-.25 F -.15
+(ve)-.15 G 1.82(red by the mapping b).15 F 1.82(ut which were e)-.2 F
+1.82(xposed by)-.15 F(modifying the mapping are redra)219 196.8 Q(wn.)
+-.15 E F1 -.1(rg)144 213.6 S(m).1 E F2 .73(Return the e)57.33 F .729
+(xternal par)-.2 F(ameter)-.15 E 3.229(so)-.1 G 3.229(fam)-3.229 G
+(apping)-3.229 E F0 5.729(.P)C .729(arameter is the mapping num-)-5.879
+F(ber)219 225.6 Q 6.444(,v)-.4 G 3.944
+(alues returned \(in the string "\\033[6;%d;%d %d;%d;%d;%d;%d;%d)-6.694
+F 1.213(%d;%d;%d;%d;%d;%d]"\) are the mapping number)219 237.6 R 3.713
+(,r)-.4 G 1.213(asterop, source mapping,)-3.713 F(type, x, y)219 249.6 Q
+2.5(,w)-.65 G(idth, height, and destination mapping, type, x, y)-2.5 E
+2.5(,w)-.65 G(idth and height.)-2.5 E F1 -.18(re)144 266.4 S(m).18 E F2
+.043(Enable a mapping)57.97 F F0 2.543(.P)C .043
+(arameters are the mapping number and an inte)-2.693 F .044
+(ger \215ag indi-)-.15 F(cating whether to refresh the mapping.)219
+278.4 Q F1(rdm)144 295.2 Q F2 1.329(Disable a mapping)56.67 F F0 3.828
+(.D)C 1.328(isabling a mapping does not af)-3.828 F 1.328
+(fect the mapping de\214ni-)-.25 F .149
+(tion, hence a disabled mapping may later be reenabled. P)219 307.2 R
+.15(arameters are the map-)-.15 F(ping number and an inte)219 319.2 Q
+(ger \215ag indicating whether to erase the mapping.)-.15 E F1(rrm)144
+336 Q F2(Refr)57.79 E(esh a mapping)-.37 E F0 2.5(.P)C
+(arameter is the mapping number)-2.65 E(.)-.55 E F1(rfm)144 352.8 Q F2
+-1.77 -.55(Fr e)58.9 H 2.5(eam).55 G(apping)-2.5 E F0 2.5(.P)C
+(arameter is the mapping number)-2.65 E(.)-.55 E/F3 9/Times-Bold@0 SF
+(MORE ON IMA)72 381.6 Q(GING)-.495 E F0 .452
+(The imaging model of the Gterm widget de\214nes the follo)108 393.6 R
+.452(wing k)-.25 F .752 -.15(ey o)-.1 H .452(bject or data types:).15 F
+F2 -.15(ra)2.951 G(ster).15 E(s)-.1 E F0(,)A F2(mappings)2.951 E F0(,)A
+(and)108 405.6 Q F2(color)2.5 E(s)-.1 E F0(.)A F1(raster)108 422.4 Q F0
+2.749(Ar)24.46 G .249(aster is a MxN array of pix)-2.749 F 2.749
+(els. At)-.15 F .249(present pix)2.749 F .249(els are 8 bits deep b)-.15
+F .249(ut hooks are b)-.2 F .249(uilt into the)-.2 F .766(widget to e)
+158 434.4 R .766(xpand this in the future.)-.15 F(Pix)5.765 E .765(el v)
+-.15 F .765(alues are indices into the Gterm virtual colormap,)-.25 F
+.82(with v)158 446.4 R .82(alues starting at zero.)-.25 F 3.32(Ar)5.82 G
+.821(aster may be an)-3.32 F 3.321(ys)-.15 G 3.321(ize. A)-3.321 F .821
+(raster is merely a tw)3.321 F(o-dimensional)-.1 E 1.232
+(array in the graphics serv)158 458.4 R 1.232
+(er; it is not displayed unless mapped.)-.15 F 1.232(An e)6.232 F 1.232
+(xception is raster zero,)-.15 F .577(which is the graphics windo)158
+470.4 R 4.378 -.65(w. R)-.25 H .578(asters are referred to by number).65
+F 3.078(,s)-.4 G .578(tarting with zero.)-3.078 F(Initially)5.578 E .032
+(only raster zero e)158 482.4 R .032(xists; ne)-.15 F 2.532(wr)-.25 G
+.032(asters are created with the create raster escape code)-2.532 F F1
+-.18(rc)2.532 G(r).18 E F0 5.031(.S)C .031(pace for)-5.031 F .329
+(rasters may be allocated either in the graphics serv)158 494.4 R(er)
+-.15 E 2.829(,o)-.4 G 2.829(ri)-2.829 G 2.83(nt)-2.829 G .33(he X serv)
+-2.83 F(er)-.15 E 5.33(.T)-.55 G .33(his has implications)-5.33 F .03
+(on performance b)158 506.4 R .03
+(ut is otherwise transparent to the client.)-.2 F .029(By def)5.029 F
+.029(ault rasters are allocated in the)-.1 F(graphics serv)158 518.4 Q
+(er)-.15 E 2.5(,i)-.4 G(.e., in the X client.)-2.5 E F1(mapping)108
+535.2 Q F0 2.737(Am)12.21 G .238(apping de\214nes a projection of a rec\
+tangle of the source raster onto a rectangle of the desti-)-2.737 F
+2.348(nation raster)158 547.2 R 7.348(.M)-.55 G 2.348
+(appings may be either enabled \(acti)-7.348 F -.15(ve)-.25 G 4.848(\)o)
+.15 G 4.848(rd)-4.848 G 4.847(isabled. When)-4.848 F 4.847(am)4.847 G
+2.347(apping is)-4.847 F .148(enabled, an)158 559.2 R 2.648(yc)-.15 G
+.149(hange to a pix)-2.648 F .149
+(el in the source rect will cause the corresponding pix)-.15 F .149
+(els in the des-)-.15 F .267(tination rect to be updated.)158 571.2 R
+.267(Mappings are referred to by number starting with one.)5.267 F .266
+(Initially no)5.266 F .151(mappings are de\214ned.)158 583.2 R .152(If \
+the size of the input and output rect is not the same the input rect wi\
+ll)5.151 F .064(be scaled by pix)158 595.2 R .063
+(el replication or subsampling to \214ll the output rect.)-.15 F .063
+(If the ar)5.063 F .063(gument D)-.18 F 2.563(W\()-.3 G(desti-)-2.563 E
+.769(nation width\) or DH \(destination height\) of the destination rec\
+t is ne)158 607.2 R -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G 3.269(,t).15
+G .769(he image will be)-3.269 F .078(\215ipped around the correspondin\
+g axis when copied to the destination; the re)158 619.2 R .077
+(gion of the destina-)-.15 F .648(tion dra)158 631.2 R .648
+(wn into is the same in either case.)-.15 F .648
+(Multiple mappings may reference the same source)5.648 F .992
+(or destination raster)158 643.2 R 5.992(.M)-.55 G .992
+(appings are refreshed in order by the mapping number)-5.992 F 5.991(.M)
+-.55 G .991(odifying a)-5.991 F(mapping causes the changed re)158 655.2
+Q(gions of the destination rect to be refreshed.)-.15 E F1(color)108 672
+Q F0(The)28.34 E F2(Gterm)2.648 E F0 .148(widget pro)2.648 F .148
+(vides a \214x)-.15 F .149
+(ed number of preassigned colors corresponding to pix)-.15 F .149(el v)
+-.15 F(alues)-.25 E 3.202(0t)158 684 S .701
+(hrough 9. Zero is the background color)-3.202 F 3.201(,o)-.4 G .701
+(ne is the fore)-3.201 F .701(ground color)-.15 F 3.201(,a)-.4 G .701
+(nd 2-9 \(8 colors\) are)-3.201 F .907
+(arbitrary colors de\214ned by Gterm widget resources.)158 696 R .908
+(These static colors are normally used to)5.908 F(dra)158 708 Q 3.7(wt)
+-.15 G 1.2(he background, frame, ax)-3.7 F 1.199
+(es, titles, etc. of a plot, or to dra)-.15 F 3.699(wc)-.15 G 1.199
+(olor graphics within the)-3.699 F(dra)158 720 Q .772(wing area.)-.15 F
+.772(The adv)5.772 F .772(antage of static colors is that the)-.25 F
+3.273(ya)-.15 G .773(re shared with other X clients, and)-3.273 F
+(X11IRAF Project)72 768 Q(16 Dec 1996)137.62 E(10)198.45 E EP
+%%Page: 11 11
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R(the v)158
+84 Q
+(alues of these colors may be assigned by the user to personalize the w)
+-.25 E(ay plots look.)-.1 E(The)158 108 Q/F1 10/Times-Italic@0 SF(Gterm)
+4.146 E F0 1.646(widget also allo)4.146 F 1.646(ws an)-.25 F 4.146(yn)
+-.15 G 1.645(umber \(up to about 200 or so\) additional colors to be)
+-4.146 F .655(de\214ned at runtime by the client application.)158 120 R
+.655(These color v)5.655 F .655(alues start at pix)-.25 F .655(el v)-.15
+F .655(alue 10 and go)-.25 F .69(up to the maximum pix)158 132 R .69
+(el v)-.15 F .69(alue assigned by the client.)-.25 F .69
+(The client application allocates colors)5.69 F .23
+(with the write colormap escape code)158 144 R/F2 10/Times-Bold@0 SF
+(rwc)2.731 E F0 5.231(.A)C .231(ttempts to o)-5.231 F -.15(ve)-.15 G
+.231(rwrite the v).15 F .231(alues of the static colors)-.25 F 1.142
+(are ignored.)158 156 R 1.142(The v)6.142 F 1.141(alues of already allo\
+cated colors may be changed dynamically at runtime)-.25 F
+(using write colormap code to write the desired range of color v)158 168
+Q(alues.)-.25 E .322(Applications should not assume that there are 10 s\
+tatic colors and 200 or so allocatable colors.)158 192 R .169
+(The graphcap entry for the logical de)158 204 R .169
+(vice in use de\214nes these parameters for the de)-.25 F 2.668
+(vice. Alter)-.25 F(-)-.2 E(nati)158 216 Q -.15(ve)-.25 G(ly).15 E 3.167
+(,t)-.65 G .668
+(he read colormap code may be used to dynamically determine ho)-3.167 F
+3.168(wm)-.25 G(an)-3.168 E 3.168(yc)-.15 G .668(olors the)-3.168 F
+(serv)158 228 Q(er has preallocated when the application starts up.)-.15
+E .66(An image may use either static and dynamic pix)158 252 R .66(el v)
+-.15 F .66(alues or both types of v)-.25 F .66(alues, b)-.25 F .66
+(ut in most)-.2 F 1.124(cases imaging applications in)158 264 R -.2(vo)
+-.4 G(lv).2 E 3.624(es)-.15 G 1.124(moothly shaded surf)-3.624 F 1.124
+(aces hence will require dynamically)-.1 F(assigned pri)158 276 Q -.25
+(va)-.25 G(te colors.).25 E .175
+(If for some reason the client application cannot use the)158 300 R F1
+(Gterm)2.675 E F0 .174(widget color model, the IOMAP)2.674 F 1.512
+(feature can be used to mak)158 312 R 4.013(et)-.1 G 1.513
+(he widget appear to ha)-4.013 F 1.813 -.15(ve s)-.2 H 1.513(ome e).15 F
+1.513(xternally de\214ned \(i.e., client)-.15 F
+(de\214ned\) color model.)158 324 Q 1.969(The maximum number of rasters\
+ and maximum number of mappings is de\214ned by the Gterm widget)108
+340.8 R(resources)108 352.8 Q F1(maxRaster)3.398 E F0(and)3.398 E F1
+(maxMappings)3.398 E F0 .898
+(\(or in the GUI \214le\) when the graphics application starts up.)3.398
+F(The)5.898 E .213(maximum v)108 364.8 R .213(alues should be much lar)
+-.25 F .212(ger than most applications require.)-.18 F .212
+(Applications should allocate raster)5.212 F 1.369
+(or mapping numbers sequentially starting at 1 \(more or less\) to a)108
+376.8 R -.2(vo)-.2 G 1.37(id running out of raster or mapping).2 F
+(descriptors.)108 388.8 Q .81(The {read|write}pix)108 412.8 R .81
+(els escape codes operate directly on raster pix)-.15 F 3.31(els. The)
+-.15 F .81(mapping escape codes support)3.31 F(tw)108 424.8 Q 2.793(oa)
+-.1 G(lternati)-2.793 E .593 -.15(ve c)-.25 H .294
+(oordinate systems, raster pix).15 F .294(els and NDC \(normalized de)
+-.15 F .294(vice coordinates\), as indicated by)-.25 F .223
+(the ST or DT ar)108 436.8 R .223
+(gument \(source or destination coordinate type\).)-.18 F .223
+(Note that the origin of the pix)5.223 F .222(el coordinate)-.15 F .335
+(system is the upper left corner of the display windo)108 448.8 R 2.835
+(w\()-.25 G .335(consistent with most graphics systems\), whereas the)
+-2.835 F(origin of the NDC coordinate system is the lo)108 460.8 Q
+(wer left corner \(consistent with IRAF\).)-.25 E(Pix)108 484.8 Q .111
+(el coordinates allo)-.15 F 2.611(wp)-.25 G .111
+(recise control of imaging b)-2.611 F .111
+(ut require the application to kno)-.2 F 2.61(wt)-.25 G .11(he windo)
+-2.61 F 2.61(ws)-.25 G .11(ize, and)-2.61 F .804
+(may result in complications e.g. if the windo)108 496.8 R 3.304(wi)-.25
+G 3.304(sr)-3.304 G 3.304(esized. NDC)-3.304 F .805
+(coordinates pretty much guarantee that a)3.305 F .086(mapping will in)
+108 508.8 R -.2(vo)-.4 G(lv).2 E 2.586(es)-.15 G .086
+(ampling, hence are not the most ef)-2.586 F .086(\214cient, b)-.25 F
+.086(ut the graphics will be dra)-.2 F .085(wn correctly no)-.15 F .254
+(matter ho)108 520.8 R 2.754(wt)-.25 G .254(he windo)-2.754 F 2.754(wi)
+-.25 G 2.754(sr)-2.754 G .254
+(esized and for most applications the performance dif)-2.754 F .254
+(ference is ne)-.25 F 2.754(gligible. Most)-.15 F 2.022(applications sh\
+ould use NDC coordinates for raster 0 \(the display windo)108 532.8 R
+2.021(w\), and pix)-.25 F 2.021(el coordinates for)-.15 F(rasters 1-N.)
+108 544.8 Q .856(Although the size of rasters 1 and higher are de\214ne\
+d by the client application, the size of raster zero, the)108 568.8 R
+.384(actual gterm display windo)108 580.8 R 1.684 -.65(w, i)-.25 H 2.884
+(ss).65 G .384(ubject to the constraints of the windo)-2.884 F 2.883(ws)
+-.25 G 2.883(ystem. The)-2.883 F .383(client can attempt to)2.883 F .45
+(reset the size of the gterm windo)108 592.8 R 2.95(wu)-.25 G .45
+(sing create raster escape with raster=0, ho)-2.95 F(we)-.25 E -.15(ve)
+-.25 G 2.95(rt).15 G .45(he Gterm widget, UI)-2.95 F .124
+(containing the)108 604.8 R F1(Gterm)2.624 E F0 .124
+(widget, and the windo)2.624 F 2.624(wm)-.25 G .124
+(anager are all free to den)-2.624 F 2.624(ys)-.15 G .124
+(uch a request.)-2.624 F .123(The query raster)5.124 F
+(escape should be called to determine the actual size of the windo)108
+616.8 Q 2.5(wo)-.25 G(ne will be dra)-2.5 E(wing into.)-.15 E F2
+(AN EXAMPLE IMA)87 645.6 Q(GING APPLICA)-.55 E(TION)-.95 E F0 .69(An e)
+108 657.6 R .69
+(xample of a simple imaging application might be one that do)-.15 F .691
+(wnloads an image and displays it in the)-.25 F 1.296(gterm windo)108
+669.6 R 2.596 -.65(w, \214)-.25 H 1.296(lling the windo).65 F 5.096 -.65
+(w. T)-.25 H 1.296(his could be done as follo).65 F 1.295(ws \(follo)
+-.25 F 1.295(wing a graphics open and other)-.25 F
+(escape codes to prepare the dra)108 681.6 Q(wing surf)-.15 E(ace\).)-.1
+E F1(cr)108 710.4 Q(eate r)-.37 E(aster)-.15 E F0 .664
+(Create raster 1 the size of the pix)24.14 F .664
+(el array to be displayed. This need not be the same as)-.15 F
+(the size of the gterm display windo)183 722.4 Q -.65(w.)-.25 G
+(X11IRAF Project)72 768 Q(16 Dec 1996)137.62 E(11)198.45 E EP
+%%Page: 12 12
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 10
+/Times-Italic@0 SF(set mapping)108 84 Q F0 .331
+(De\214ne a mapping between raster 1 and raster 0, the display windo)
+26.39 F 1.63 -.65(w, u)-.25 H .33(sing NDC coordi-).65 F 1.143
+(nates to de\214ne the re)183 96 R 1.143(gion of the display windo)-.15
+F 3.643(wt)-.25 G 3.643(ob)-3.643 G 3.644<658c>-3.643 G 3.644(lled. The)
+-3.644 F 1.144(mapping number is)3.644 F 1.69(arbitrary b)183 108 R 1.69
+(ut mappings should normally be allocated starting with 1. The mapping \
+is)-.2 F(automatically enabled when \214rst de\214ned.)183 120 Q F1
+(write colormap)108 136.8 Q F0 2.5(\(Optional\). De\214ne)13.61 F
+(the pix)2.5 E(el v)-.15 E
+(alue to RGB color assignments for the image pix)-.25 E(els.)-.15 E F1
+(write pixels)108 153.6 Q F0 .252
+(This escape is called one or more times to write pix)28.61 F .252
+(els into raster 1.)-.15 F .252(At most 32K pix)5.252 F(els)-.15 E .098
+(can be written in each call.)183 165.6 R .098
+(As each write is made the af)5.098 F .097(fected re)-.25 F .097
+(gion of the display win-)-.15 F(do)183 177.6 Q 2.5(ww)-.25 G
+(ill be updated.)-2.5 E(Alternati)108 194.4 Q -.15(ve)-.25 G(ly).15 E
+3.313(,o)-.65 G .814(ne could write the pix)-3.313 F .814
+(els and then de\214ne the mapping to cause the entire image to be dis-)
+-.15 F(played at once.)108 206.4 Q .071(Note that the imaging escape ca\
+n be combined with normal graphics to dra)108 230.4 R 2.57(wt)-.15 G
+-.15(ex)-2.57 G 2.57(ta).15 G .07(nd graphics around or on)-2.57 F .078
+(top of an image re)108 242.4 R 2.579(gion. The)-.15 F .079
+(order in which dra)2.579 F .079
+(wing operations occur is important, e.g., to dra)-.15 F 2.579(wg)-.15 G
+.079(raphics or)-2.579 F(te)108 254.4 Q
+(xt on top of an image the image should be dra)-.15 E(wn \214rst.)-.15 E
+/F2 9/Times-Bold@0 SF(MARKERS)72 283.2 Q F0(Mark)108 295.2 Q
+(ers are a general feature of the)-.1 E F1(Gterm)2.5 E F0
+(widget and are used more e)2.5 E(xtensi)-.15 E -.15(ve)-.25 G
+(ly in other programs \(e.g. the).15 E 1.47
+(prototype IRAF science GUI applications\), b)108 307.2 R 1.47(ut the)
+-.2 F 3.97(yh)-.15 G -2.25 -.2(av e)-3.97 H 1.47(no real use in)4.17 F
+F1(xgterm)3.97 E F0 1.47(when used as simply a)3.97 F 1.134
+(graphics terminal. All mark)108 319.2 R 1.133
+(ers share some of the same characteristics, so it is w)-.1 F 1.133
+(orthwhile learning basic)-.1 F(mark)108 331.2 Q .356(er manipulation k)
+-.1 F -.15(ey)-.1 G(strok).15 E .357(es \(as de\214ned using the def)-.1
+F .357(ault mark)-.1 F .357(er translations\), especially ho)-.1 F 2.857
+(wt)-.25 G 2.857(od)-2.857 G(elete)-2.857 E
+(an accidentally created mark)108 343.2 Q(er:)-.1 E/F3 10/Times-Bold@0
+SF(o)144 360 Q F1(Delete)10 E F0(or)2.5 E F1(Bac)2.5 E(kspace)-.2 E F0
+(in a mark)2.5 E(er deletes it.)-.1 E F3(o)144 376.8 Q F0(MB1 an)10 E
+(ywhere inside a mark)-.15 E(er may be used to drag the mark)-.1 E(er)
+-.1 E(.)-.55 E F3(o)144 393.6 Q F0(MB1 near a mark)10 E
+(er corner or edge, depending on the type of mark)-.1 E(er)-.1 E 2.5(,r)
+-.4 G(esizes the mark)-2.5 E(er)-.1 E(.)-.55 E F3(o)144 410.4 Q F0
+(Shift-MB1 on the corner of most mark)10 E(ers will rotate the mark)-.1
+E(er)-.1 E(.)-.55 E F3(o)144 427.2 Q F0(Mark)10 E 1.238
+(ers stack, if you ha)-.1 F 1.538 -.15(ve s)-.2 H -2.15 -.25(ev e).15 H
+1.238(ral mark).25 F 1.238(ers and you put one on top of the other)-.1 F
+3.737(.T)-.55 G 1.237(he acti)-3.737 F -.15(ve)-.25 G(mark)159 439.2 Q
+.135(er is highlighted to tell you which of the stack)-.1 F .136
+(ed mark)-.1 F .136(ers is acti)-.1 F -.15(ve)-.25 G 2.636(.I).15 G
+2.636(ft)-2.636 G .136(he mark)-2.636 F .136(ers o)-.1 F -.15(ve)-.15 G
+(rlap,).15 E(this will be mark)159 451.2 Q
+(er "on top" in the stacking order)-.1 E(.)-.55 E F3(o)144 468 Q F0 .641
+(MB2 in the body of a mark)10 F .641(er "lo)-.1 F .641(wers" the mark)
+-.25 F(er)-.1 E 3.141(,i)-.4 G .64(.e. mo)-3.141 F -.15(ve)-.15 G 3.14
+(si).15 G 3.14(tt)-3.14 G 3.14(ot)-3.14 G .64(he bottom of the stacking)
+-3.14 F(order)159 480 Q(.)-.55 E F2(ENVIR)72 508.8 Q(ONMENT)-.27 E F1
+(XGterm)108 520.8 Q F0 .012(sets the en)2.512 F .013(vironment v)-.4 F
+.013(ariables `)-.25 F(`TERM')-.74 E 2.513('a)-.74 G .013(nd `)-2.513 F
+(`TERMCAP')-.74 E 2.513('p)-.74 G .013(roperly for the size windo)-2.513
+F 2.513(wy)-.25 G .013(ou ha)-2.513 F -.15(ve)-.2 G 3.154(created. It)
+108 532.8 R .654(also uses and sets the en)3.154 F .654(vironment v)-.4
+F .654(ariable `)-.25 F(`DISPLA)-.74 E(Y')-1.05 E 3.154('t)-.74 G 3.154
+(os)-3.154 G .653(pecify which bit map display ter)-3.154 F(-)-.2 E .789
+(minal to use.)108 544.8 R .789(The en)5.789 F .789(vironment v)-.4 F
+.789(ariable `)-.25 F(`WINDO)-.74 E(WID')-.35 E 3.289('i)-.74 G 3.289
+(ss)-3.289 G .789(et to the X windo)-3.289 F 3.29(wi)-.25 G 3.29(dn)
+-3.29 G .79(umber of the)-3.29 F F1(xgterm)3.29 E F0(windo)108 556.8 Q
+-.65(w.)-.25 G F2(SEE ALSO)72 585.6 Q F0
+(xterm\(1\), resize\(1\), X\(1\), pty\(4\), tty\(4\))108 597.6 Q F1
+(Xterm Contr)108 609.6 Q(ol Sequences)-.45 E F0(\(in the)2.5 E F1(xterm)
+2.5 E F0(source directory\))2.5 E F2 -.09(BU)72 638.4 S(GS).09 E F0(Man)
+108 650.4 Q 2.5(yo)-.15 G 2.5(ft)-2.5 G(he same b)-2.5 E(ugs af)-.2 E
+(fecting)-.25 E F1(xterm)2.5 E F0(also apply here.)2.5 E F1(Xgterm)108
+674.4 Q F0 .725(is not normally installed with setuid permissions.)3.225
+F .724(On some Linux systems where the /de)5.725 F .724(v/tty and)-.25 F
+(/de)108 686.4 Q 1.355(v/pty de)-.25 F 1.355(vices ha)-.25 F 1.655 -.15
+(ve r)-.2 H 1.355(oot o).15 F 1.355
+(wnership and permission 600 this can cause problems.)-.25 F -.8(Wo)
+6.355 G 1.355(rkarounds are to).8 F .857(either install)108 698.4 R F1
+(XGterm)3.357 E F0 .857(with setuid permissions or modify the /de)3.357
+F .857(v/tty and /de)-.25 F .856(v/pty de)-.25 F .856(vices to ha)-.25 F
+1.156 -.15(ve p)-.2 H(ermis-).15 E(sion 666.)108 710.4 Q
+(X11IRAF Project)72 768 Q(16 Dec 1996)137.62 E(12)198.45 E EP
+%%Page: 13 13
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF 357.74(XGTERM\(1\) XGTERM\(1\))72 48 R/F1 9
+/Times-Bold@0 SF(COPYRIGHT)72 84 Q F0(Cop)108 96 Q
+(yright\(c\) 1986 Association of Uni)-.1 E -.15(ve)-.25 G
+(rsities for Research in Astronomy Inc.).15 E(X11IRAF Project)72 768 Q
+(16 Dec 1996)137.62 E(13)198.45 E EP
+%%Trailer
+end
+%%EOF
diff --git a/vendor/x11iraf/xgterm/xterm.man b/vendor/x11iraf/xgterm/xterm.man
new file mode 100644
index 00000000..6717bad2
--- /dev/null
+++ b/vendor/x11iraf/xgterm/xterm.man
@@ -0,0 +1,1649 @@
+.\" $XConsortium: xterm.man,v 1.72 91/08/23 18:46:18 gildea Exp $
+.TH XTERM 1 "Release 5" "X Version 11"
+.SH NAME
+xterm \- terminal emulator for X
+.SH SYNOPSIS
+.B xterm
+[\-\fItoolkitoption\fP ...] [\-option ...]
+.SH DESCRIPTION
+The \fIxterm\fP program is a terminal emulator for the X Window System.
+It provides DEC VT102 and Tektronix 4014
+compatible terminals for programs that can't
+use the window system directly. If the underlying operating system supports
+terminal resizing capabilities (for example, the SIGWINCH signal in systems
+derived from 4.3bsd), \fIxterm\fP will use the facilities to notify programs
+running in the window whenever it is resized.
+.PP
+The VT102 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 VT102 window, and the ``Tek Options''
+menu in the 4014 window.
+.SH EMULATIONS
+The VT102 emulation is fairly complete, but does not support the blinking
+character attribute nor the double-wide and double-size character sets.
+.IR Termcap (5)
+entries that work with
+.I xterm
+include ``xterm,'' ``vt102,'' ``vt100'' and ``ansi,'' and
+.I xterm
+automatically searches the termcap file in this order for these entries and then
+sets the ``TERM'' and the ``TERMCAP'' environment variables.
+.PP
+Many of the special
+.I xterm
+features (like logging) 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.
+Four different font sizes and five different lines types are supported.
+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\fIyy\fB\-\fIMM\fB\-\fIdd\fB.\fIhh\fB:\fImm\fB:\fIss\fR'', where
+.IR yy ,
+.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 ).
+.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.
+.PP
+In either VT102 or Tektronix mode, there are escape sequences to change the
+name of the windows and to specify a new log file name.
+See \fIXterm Control Sequences\fP for details.
+Enabling the escape sequence to change the
+log file name is a compile-time option;
+by default this escape sequence is ignored for security reasons.
+.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):
+.TP 8
+.B \-help
+This causes \fIxterm\fP to print out a verbose message describing its options.
+.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
+.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. The
+default is 2.
+.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.
+.TP 8
+.B "\-cn"
+This option indicates that newlines should not be cut in line-mode
+selections.
+.TP 8
+.B \+cn
+This option indicates that newlines should be cut in line-mode selections.
+.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.
+.TP 8
+.B \-cu
+This option indicates that \fIxterm\fP should work around a bug in the
+.IR curses (3x)
+cursor motion package that causes the
+.IR more (1)
+program to display lines that are exactly the width of the window and
+are followed by a line beginning with a tab to be displayed incorrectly
+(the leading tabs are not displayed).
+.TP 8
+.B \+cu
+This option indicates that that \fIxterm\fP should not work around the
+.IR curses (3x)
+bug mentioned above.
+.TP 8
+.BI \-e " program \[arguments \.\.\.\]"
+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 \-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.
+.TP 8
+.B \-im
+Turn on the \fBuseInsertMode\fP resource.
+.TP 8
+.B +im
+Turn off the \fBuseInsertMode\fP resource.
+.TP 8
+.B \-j
+This option indicates that \fIxterm\fP should do jump scrolling. Normally,
+text is scrolled one line at a time; this option allows \fIxterm\fP to move
+multiple lines at a time so that it doesn't fall as far behind. Its use is
+strongly recommended since it make \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 \-l
+This option indicates that \fIxterm\fP should send all terminal output to
+a log file as well as to the screen. This option can be enabled or disabled
+using the ``VT Options'' menu.
+.TP 8
+.B \+l
+This option indicates that \fIxterm\fP should not do logging.
+.TP 8
+.BI \-lf " filename"
+This option specifies the name of the file to which the output log described
+above is written. If \fIfile\fP begins with a pipe symbol (|), the rest of
+the string is assumed to be a command to be used as the endpoint of a pipe.
+The ability to log to a pipe is a compile-time option which is
+disabled by default for security reasons.
+The default filename is ``\fBXtermLog.\fIXXXXX\fR'' (where \fIXXXXX\fP
+is the process id of \fIxterm\fP) and is created in the directory from which
+\fIxterm\fP was started (or the user's home directory in the case of a
+login window).
+.TP 8
+.B \-ls
+This option indicates that the shell that is started in the \fIxterm\fP window
+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).
+.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
+.B "\-mc milliseconds"
+This option specifies the maximum time between multi-click selections.
+.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.
+.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 \-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 \-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
+.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 \-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. The default is 64.
+.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.
+.TP 8
+.B \+t
+This option indicates that \fIxterm\fP should start in VT102 mode.
+.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. Allowable keywords include: intr, quit, erase, kill, eof,
+eol, swtch, start, stop, brk, susp, dsusp, rprnt, flush, weras, and lnext.
+Control characters may be specified as ^char (e.g. ^c or ^u) and ^? may be
+used to indicate delete.
+.TP 8
+.BI \-tn " name"
+This option specifies the name of the terminal type to be set in the TERM
+environment variable. This terminal type must exist in the \fItermcap(5)\fP
+database and should have \fIli#\fP and \fIco#\fP entries.
+.TP 8
+.B \-ut
+This option indicates that \fIxterm\fP shouldn't write a record into the
+the system log file \fI/etc/utmp\fP.
+.TP 8
+.B \+ut
+This option indicates that \fIxterm\fP should write a record into the system
+log file \fI/etc/utmp\fP.
+.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 \-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 show not wait before starting the
+subprocess.
+.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 specifies the last two letters of the name of a pseudoterminal
+to use in slave mode, plus the number of the inherited file descriptor.
+The option is parsed ``%c%c%d''.
+This allows \fIxterm\fP to be used as an input and
+output channel for an existing program and is sometimes used in specialized
+applications.
+.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 \-bg \fIcolor\fP
+This option specifies the color to use for the background of the window.
+The default is ``white.''
+.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 \-bw \fInumber\fP
+This option specifies the width in pixels of the border surrounding the window.
+.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 \-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 \-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 \-rv
+This option indicates that reverse video should be simulated by swapping
+the foreground and background colors.
+.TP 8
+.B \-geometry \fIgeometry\fP
+This option specifies the preferred size and position of the VT102 window;
+see \fIX(1)\fP.
+.TP 8
+.B \-display \fIdisplay\fP
+This option specifies the X server to contact; see \fIX(1)\fP.
+.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.
+.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.
+.SH RESOURCES
+The program understands all of the core X Toolkit resource names and
+classes as well as:
+.\".in +1in
+.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 "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 "ttyModes (\fPclass\fB TtyModes)"
+Specifies a string containing terminal setting keywords and the characters
+to which they may be bound. Allowable keywords include: intr, quit,
+erase, kill, eof, eol, swtch, start, stop, brk, susp, dsusp, rprnt, flush,
+weras, and lnext. Control characters may be specified as ^char (e.g. ^c or ^u)
+and ^? may be used to indicate Delete. This is very useful for overriding
+the default terminal settings without having to do an \fIstty\fP every time
+an \fIxterm\fP is started.
+.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 "utmpInhibit (\fPclass\fB UtmpInhibit)"
+Specifies whether or not \fIxterm\fP should try to record the user's terminal
+in \fI/etc/utmp\fP.
+.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.
+.\".in -1in
+.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.''
+.\".in 11in
+.sp
+.PP
+The following resources are specified as part of the \fIvt100\fP widget (class
+\fIVT100\fP):
+.\".in +1in
+.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.
+.sp
+.TP 8
+.B "alwaysHighlight (\fPclass\fB AlwaysHighlight)"
+Specifies whether or not \fIxterm\fP should always display a highlighted
+text cursor. By default, a hollow text cursor is displayed whenever the
+pointer moves out of the window or the window loses the input focus.
+.TP 8
+.B "appcursorDefault (\fPclass\fB AppcursorDefault)"
+If ``true,'' the cursor keys are initially in application 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. 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 "boldFont (\fPclass\fB BoldFont)"
+Specifies the name of the bold font to use instead of overstriking.
+.TP 8
+.B "c132 (\fPclass\fB C132)"
+Specifies whether or not the VT102 DECCOLM escape sequence should be honored.
+The default is ``false.''
+.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 "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 section on specifying character classes.
+.TP 8
+.B "curses (\fPclass\fB Curses)"
+Specifies whether or not the last column bug in
+.IR curses (3x)
+should be worked around.
+The default is ``false.''
+.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 "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 "cursorColor (\fPclass\fB Foreground)"
+Specifies the color to use for the text cursor. The default is ``black.''
+.TP 8
+.B "eightBitInput (\fPclass\fB EightBitInput\fP)"
+If true, Meta characters input from the keyboard are presented as a
+single character with the eighth bit turned on.
+If false, Meta characters are converted into a two-character
+sequence with the character itself preceded by ESC.
+The default is ``true.''
+.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.''
+.TP 8
+.B "font (\fPclass\fB Font)"
+Specifies the name of the normal font. The default is ``fixed.''
+.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 "geometry (\fPclass\fB Geometry)"
+Specifies the preferred size and position of the VT102 window.
+.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 "jumpScroll (\fPclass\fB JumpScroll)"
+Specifies whether or not jump scroll should be used. The default is ``true.''
+.TP 8
+.B "logFile (\fPclass\fB Logfile)"
+Specifies the name of the file to which a terminal session is logged. The
+default is ``\fBXtermLog.\fIXXXXX\fR'' (where \fIXXXXX\fP
+is the process id of \fIxterm\fP).
+.TP 8
+.B "logging (\fPclass\fB Logging)"
+Specifies whether or not a terminal session should be logged. The default is
+``false.''
+.TP 8
+.B "logInhibit (\fPclass\fB LogInhibit)"
+Specifies whether or not terminal session logging should be inhibited. The
+default is ``false.''
+.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 run when the user types near the
+right margin. The default is ``false.''
+.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 "pointerColor (\fPclass\fB Foreground)"
+Specifies the foreground color of the pointer. The default is
+``XtDefaultForeground.''
+.TP 8
+.B "pointerColorBackground (\fPclass\fB Background)"
+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 "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. 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 "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 "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. 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 "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.
+.TP 8
+.B "tekInhibit (\fPclass\fB TekInhibit)"
+Specifies whether or not Tektronix mode should be disallowed. 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 "titeInhibit (\fPclass\fB TiteInhibit)"
+Specifies whether or not \fIxterm\fP should remove 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.
+.TP 8
+.B "translations (\fPclass\fB Translations)"
+Specifies the key and button bindings for menus, selections, ``programmed
+strings,'' etc. See \fBACTIONS\fP below.
+.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.''
+.sp
+.PP
+The following resources are specified as part of the \fItek4014\fP widget
+(class \fITek4014\fP):
+.\".in +1in
+.TP 8
+.B "width (\fPclass\fB Width)"
+Specifies the width of the Tektronix window in pixels.
+.TP 8
+.B "height (\fPclass\fB Height)"
+Specifies the height of the Tektronix window in pixels.
+.TP 8
+.B "fontLarge (\fPclass\fB Font)"
+Specifies the large font to use in the Tektronix window.
+.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 "fontSmall (\fPclass\fB Font)"
+Specifies the small font to use in the Tektronix window.
+.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 "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.''
+.\".in -1in
+.sp
+.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.
+.PP
+The \fImainMenu\fP has the following entries:
+.\".in +1in
+.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 "logging (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-logging(toggle)\fP action.
+.TP 8
+.B "redraw (\fPclass\fB SmeBSB)"
+This entry invokes the \fBredraw()\fP action.
+.TP 8
+.B "line1 (\fPclass\fB SmeLine)"
+This is a separator.
+.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 "line2 (\fPclass\fB SmeLine)"
+This is a separator.
+.TP 8
+.B "quit (\fPclass\fB SmeBSB)"
+This entry invokes the \fBquit()\fP action.
+.\".in -1in
+.sp
+.PP
+The \fIvtMenu\fP has the following entries:
+.\".in +1in
+.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 "marginbell (\fPclass\fB SmeBSB)"
+This entry invokes the \fBset-marginbell(toggle)\fP action.
+.TP 8
+.B "altscreen (\fPclass\fB SmeBSB)"
+This entry is currently disabled.
+.TP 8
+.B "line1 (\fPclass\fB SmeLine)"
+This is a separator.
+.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 "line2 (\fPclass\fB SmeLine)"
+This is a separator.
+.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.
+.\".in -1in
+.sp
+.PP
+The \fIfontMenu\fP has the following entries:
+.\".in +1in
+.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.
+.\".in -1in
+.sp
+.PP
+The \fItekMenu\fP has the following entries:
+.\".in +1in
+.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 "line1 (\fPclass\fB SmeLine)"
+This is a separator.
+.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 "line2 (\fPclass\fB SmeLine)"
+This is a separator.
+.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.
+.\".in -1in
+.sp
+.PP
+The following resources are useful when specified for the Athena Scrollbar
+widget:
+.\".in +1in
+.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.
+.\".in -1in
+.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.
+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 the cut buffer is globally shared among different applications,
+you should regard it 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
+.PP
+Unlike the VT102 window, the Tektronix window dows 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.
+Most menus are divided into two section, separated by a horizontal line.
+The top portion contains various 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.
+The bottom portion of the menu are command entries; selecting one of these
+performs the indicated function.
+.PP
+The
+.B xterm
+menu pops up when the ``control'' key and pointer button one are
+pressed in a window.
+The \fImainMenu\fP contains items that apply to both the VT102 and Tektronix
+windows.
+The
+.B Secure Keyboard
+mode is be used when typing in passwords or other sensitive data in an
+unsecure environment;
+see \fBSECURITY\fP below.
+Notable entries in the command section of the menu are the
+.BR Continue ,
+.BR Suspend ,
+.BR Interrupt ,
+.BR Hangup ,
+.B Terminate
+and
+.B Kill
+which sends the SIGCONT, SIGTSTP, SIGINT, SIGHUP, SIGTERM and
+SIGKILL signals, respectively, to the process group of the process running
+under
+.I xterm
+(usually the shell).
+The
+.B Continue
+function is especially useful if the user has accidentally typed CTRL-Z,
+suspending the process.
+.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.
+In the command section of this menu, the soft reset entry will 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).
+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.
+.PP
+The \fIfontMenu\fP sets the font used in the VT102 window.
+In addition to the default font and a number of alternatives that are
+set with resources, the menu offers the font last specified by the Set
+Font escape sequence (see the document \fIXterm Control Sequences\fP)
+and the current selection as a font name (if the PRIMARY selection is owned).
+.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.
+The
+.B PAGE
+entry in the command section clears the Tektronix window.
+.SH SECURITY
+.PP
+X environments differ in their security consciousness. MIT 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, there is
+every possibility that someone can run an application that will use the
+basic services of the X protocol to snoop on your activities, potentially
+capturing a transcript of everything you type at the keyboard.
+This 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 that host-based control, but a simple
+mechanism exists for protecting keyboard input in \fIxterm\fP.
+.PP
+The \fBxterm\fP menu (see \fBMENUS\fP above) contains a \fBSecure Keyboard\fP
+entry which, when enabled, ensures 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. Only one X client at a time can secure 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 xterm
+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 middle 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 \fIcharClass\fP (class \fICharClass\fP) resource.
+.PP
+This resource is simply a list of \fIrange\fP:\fIvalue\fP pairs where the
+range is either a single number or \fIlow\fP-\fIhigh\fP in the range of 0
+to 127, corresponding to the ASCII 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.
+.PP
+The default table is
+.sp
+.in +8
+.ft C \" Courier
+.nf
+static int charClass[128] = {
+/* 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};
+.fi
+.ft P
+.in -8
+.sp
+For example, the string ``33:48,37:48,45-47:48,64: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 very 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 translations for the vt100 or tek4014 widgets.
+Changing the translations for events other than key and button events
+is not expected, and will cause unpredictable behavior. The following
+actions are provided for using within the \fIvt100\fP or \fItek4014\fP
+\fBtranslations\fP resources:
+.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 "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-seven-bit()"
+This action is a synonym for \fBinsert()\fP
+.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.
+The exact action depends on the value of the \fBeightBitInput\fP resource.
+.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 "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 "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 "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-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 "select-extend()"
+This action tracks the pointer and extends the selection. It
+should only be bound to Motion events.
+.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-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-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 "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: \fId\fP or \fID\fP indicate the default font (the font initially
+used when
+\fIxterm\fP was started), \fI1\fP through \fI6\fP indicate the fonts
+specified by the \fIfont1\fP through \fIfont6\fP resources, \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
+\fIs\fP or \fIS\fP indicate the font selection (as made by programs such as
+\fIxfontsel(1)\fP) indicated by the second action argument.
+.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 "scroll-back(\fIcount\fP [,\fIunits\fP])"
+This action scrolls the text window backward so that text that had previously
+scrolled off the top of the screen is now visible. 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.
+.TP 8
+.B "scroll-forw(\fIcount\fP [,\fIunits\fP])"
+This action scrolls is similar to \fBscroll-back\fP except that it scrolls
+the other direction.
+.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 "set-logging(\fIon/off/toggle\fP)"
+This action toggles the \fBlogging\fP resource and is also invoked
+by the \fBlogging\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 "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
+.I 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 "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 "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-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-reverse-video(\fIon/off/toggle\fP)"
+This action toggles the \fIreverseVideo\fP resource and is also invoked by
+the \fBreversevideo\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-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-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-appcursor(\fIon/off/toggle\fP)"
+This action toggles the handling Application Cursor Key mode
+and is also invoked by the \Bappcursor\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-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-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-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-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-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-altscreen(\fIon/off/toggle\fP)"
+This action toggles between the alternate and current screens.
+.TP 8
+.B "soft-reset()"
+This action resets the scrolling region and is also invoked from the
+\fBsoftreset\fP entry in \fIvtMenu\fP.
+.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 "clear-saved-lines()"
+This action does \fBhard-reset()\fP (see above) 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.
+.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-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-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 "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 "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 "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:
+.sp
+.in +4
+.DS
+.TA 2.5i
+.ta 2.5i
+.nf
+ Shift <KeyPress> Prior: scroll-back(1,halfpage) \\n\\
+ Shift <KeyPress> Next: scroll-forw(1,halfpage) \\n\\
+Shift <KeyPress> Select: select-cursor-start() \\
+ select-cursor-end(PRIMARY, CUT_BUFFER0) \\n\\
+Shift <KeyPress> Insert: insert-selection(PRIMARY, CUT_BUFFER0) \\n\\
+ ~Meta<KeyPress>: insert-seven-bit() \\n\\
+ Meta<KeyPress>: insert-eight-bit() \\n\\
+ !Ctrl <Btn1Down>: popup-menu(mainMenu) \\n\\
+ !Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \\n\\
+ ~Meta <Btn1Down>: select-start() \\n\\
+ ~Meta <Btn1Motion>: select-extend() \\n\\
+ !Ctrl <Btn2Down>: popup-menu(vtMenu) \\n\\
+ !Lock Ctrl <Btn2Down>: popup-menu(vtMenu) \\n\\
+ ~Ctrl ~Meta <Btn2Down>: ignore() \\n\\
+ ~Ctrl ~Meta <Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0) \\n\\
+ !Ctrl <Btn3Down>: popup-menu(fontMenu) \\n\\
+ !Lock Ctrl <Btn3Down>: popup-menu(fontMenu) \\n\\
+ ~Ctrl ~Meta <Btn3Down>: start-extend() \\n\\
+ ~Meta <Btn3Motion>: select-extend() \\n\\
+ <BtnUp>: select-end(PRIMARY, CUT_BUFFER0) \\n\\
+ <BtnDown>: bell(0)
+.fi
+.DE
+.sp
+.in -4
+.PP
+The default bindings in the Tektronix window are:
+.sp
+.in +4
+.DS
+.TA 2.5i
+.ta 2.5i
+.nf
+ ~Meta<KeyPress>: insert-seven-bit() \\n\\
+ Meta<KeyPress>: insert-eight-bit() \\n\\
+ !Ctrl <Btn1Down>: popup-menu(mainMenu) \\n\\
+!Lock Ctrl <Btn1Down>: popup-menu(mainMenu) \\n\\
+ !Ctrl <Btn2Down>: popup-menu(tekMenu) \\n\\
+!Lock Ctrl <Btn2Down>: popup-menu(tekMenu) \\n\\
+Shift ~Meta<Btn1Down>: gin-press(L) \\n\\
+ ~Meta<Btn1Down>: gin-press(l) \\n\\
+Shift ~Meta<Btn2Down>: gin-press(M) \\n\\
+ ~Meta<Btn2Down>: gin-press(m) \\n\\
+Shift ~Meta<Btn3Down>: gin-press(R) \\n\\
+ ~Meta<Btn3Down>: gin-press(r)
+.fi
+.DE
+.sp
+.in -4
+.PP
+Below is a sample how of the \fBkeymap()\fP action is used to add special
+keys for entering commonly-typed works:
+.sp
+.in +4
+.nf
+.DS
+.TA .5i 1.5i
+.ta .5i 1.5i
+.nf
+*VT100.Translations: #override <Key>F13: keymap(dbx)
+*VT100.dbxKeymap.translations: \\
+ <Key>F14: keymap(None) \\n\\
+ <Key>F17: string("next") string(0x0d) \\n\\
+ <Key>F18: string("step") string(0x0d) \\n\\
+ <Key>F19: string("continue") string(0x0d) \\n\\
+ <Key>F20: string("print ") insert-selection(PRIMARY, CUT_BUFFER0)
+.fi
+.DE
+.sp
+.in -4
+.SH ENVIRONMENT
+.I Xterm
+sets the environment variables ``TERM'' and ``TERMCAP'' properly for the
+size window you have created.
+It also uses and sets the environment
+variable ``DISPLAY'' to specify which bit map display terminal to use.
+The environment variable ``WINDOWID'' is set to the X window id number
+of the
+.I xterm
+window.
+.SH "SEE ALSO"
+resize(1), X(1), pty(4), tty(4)
+.br
+\fIXterm Control Sequences\fP (in the \fIxterm\fP source directory)
+.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
+The Tek widget does not support key/button re-binding.
+.PP
+Only fixed-width, character-cell fonts are supported.
+.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 don't 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 log file name
+and the COPY file name.
+.SH COPYRIGHT
+Copyright 1989, Massachusetts Institute of Technology.
+.br
+See \fIX(1)\fP for a full statement of rights and permissions.
+.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)
+
diff --git a/vendor/x11iraf/xgterm/z b/vendor/x11iraf/xgterm/z
new file mode 100755
index 00000000..b7239648
--- /dev/null
+++ b/vendor/x11iraf/xgterm/z
@@ -0,0 +1,5 @@
+#!/iraf/iraf/bin.macintel/ecl.e -f
+
+plot
+prow dev$pix 23
+
diff --git a/vendor/x11iraf/xgterm/zz.c b/vendor/x11iraf/xgterm/zz.c
new file mode 100644
index 00000000..9983217d
--- /dev/null
+++ b/vendor/x11iraf/xgterm/zz.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+main (int argc, char **argv)
+{
+ char s[128];
+
+ if (argc) {
+ printf ("\033[?38h\035\033\033\014"); /* XTerm OW plus GS/ESC/FF */
+
+/* printf ("\033[?38h\035^_"); /* XTerm OW plus XGterm OW */
+
+ } else
+ printf ("\035^_"); /* XGterm OW */
+}