XGTERM(1) | General Commands Manual | XGTERM(1) |
xgterm - terminal emulator for X with graphics and imaging capability
xgterm [-toolkitoption ...] [-option ...]
The xgterm program is a terminal emulator for the X Window System based largely on xterm 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. XGterm also serves as a prototype for the Widget Server being developed by the IRAF Project at NOAO. The Object Manager Library 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 Gterm widget.
The Gterm graphics window operates almost identically to the xterm 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 xterm Tek window should also be able to use xgterm 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 (Object Manager) 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 XImtool task as an example of a more complex application using the OBM Library and Gterm widget, as well as demo tasks in the guidemo directory of the X11IRAF sources.
The VT102 text window is unchanged from the original xterm application. All of it's resources, command-line options and operation are identical to that used by xterm. The termcap(5) entry for xterm may be used for xgterm as well. See the xterm(1) man page for details.
All xterm(1) and X Toolkit command line options are supported, there are no additional options.
The program understands all of the core X Toolkit resource names and classes, all text window resources known to xterm(1), as well as the Gterm (graphics and imaging widget) resources. The proper Class name for all resources described here is Gterm. A table of available Gterm resources and their defaults may be found below, some of the more interesting resources are described here in detail:
Core -> Gterm
When creating a Gterm widget instance, the following resources are retrieved from the arguments list or from the resource database:
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 markerFillColor |
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 | Distance, in pixels, between pointer and marker edge required for translation actions for be in effect. |
nearVertex | Int | 4 | Distance, in pixels between pointer and marker vertex (i.e. knot) required for translation actions for be in effect. |
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 |
The default translations for a Gterm window are:
<Btn1Down>: | m_create() |
<Btn2Down>: | crosshair(on) |
<Btn2Motion>: | crosshair(on) |
<Btn2Up>: | crosshair(off) |
<EnterWindow>: | enter-window() |
<LeaveWindow>: | leave-window() |
<KeyPress>: | graphics-input() |
<Motion>: | track-cursor() |
The available action procedures for a Gterm window are:
text | line | polyline | rectangle |
box | circle | ellipse | polygon |
The default translations for a marker are:
!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() |
Translations affect only the currently active marker, the cursor must be within nearEdge pixels of a marker edge, or nearVertex pixels of a marker vertex to take effect.
The available action procedures for a marker are
text | line | polyline | rectangle |
box | circle | ellipse | polygon |
activated | 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 |
notify | moveResize | modify |
redraw | destroy | input |
focusIn | focusOut | constraint |
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 (Object Manager) 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 ESC 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. LF is the ASCII linefeed code), a three digit number preceded by a '´ refers to an octal code (e.g. " 12" is octal 12) , all others are characters in the escape code (e.g. "/bc" are the three characters '/', 'b', and 'c').
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 xterm graphics start escape sequence "[?38h".
These are encoded as follows:
ESC <code> [ P ; P ; ... ] <data>
where code is a character sequence and P is an ASCII encoded parameter described below.
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.
The imaging model of the Gterm widget defines the following key object or data types: rasters, mappings, and colors.
The Gterm 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 rwc. 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 Gterm 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.
The maximum number of rasters and maximum number of mappings is defined by the Gterm widget resources maxRaster and maxMappings (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 Gterm 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.
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).
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.
Markers are a general feature of the Gterm widget and are used more extensively in other programs (e.g. the prototype IRAF science GUI applications), but they have no real use in xgterm 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:
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 xgterm window.
xterm(1), resize(1), X(1), pty(4), tty(4)
Xterm Control Sequences (in the xterm source directory)
Many of the same bugs affecting xterm also apply here.
Xgterm 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 XGterm with setuid permissions or modify the /dev/tty and /dev/pty devices to have permission 666.
Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
16 Dec 1996 | X11IRAF Project |