%NAME: Bruce M. Corwin
%COMP: Bruce M. Corwin
%PROG: vtwidget
%CODE: Vt.c screen.c screen.h Vt.h VtP.h low_level.h translations.h attributes.h attributes.c load_menu.c
%FUNC: XmVtDialogCancelCB
This routine is used to respond to a Cancel button being pressed on a child
dialog.  It sends 'CANCEL' to the standard input of the tty process.
%FUNC: s_modify
This routine is used to set the S_MOD flag on an entire line of the Vt screen.
This allows faster updates to this flag when large sections of the screen
need to be repainted.
%FUNC: XmVtDialogHelpCB
This routine is used to respond to a Help button being pressed on a child
dialog.  It sends 'HELP' to the standard input of the tty process.
%FUNC: XmVtDialogOkCB
This routine is used to respond to an OK button being pressed on a child
dialog.  It sends 'OK' to the standard input of the tty process.
%FUNC: XmVtFileSelectionDialogOkCB
This routine is used to respond to a selected file OK from a child file dialog.
It sends an 'FILEOK:filepath' type message back to the standard input of the tty
process where filepath is the fully qualified path the the selected file.
%FUNC: ArmHyper
This function is used to change the appearance of a
hyperlink section of the screen.  This section is
any section that has the same attributes as the
HyperAttributes resource.  This change in appearance
is meant to represent that at the lifting of the
left mouse button the hyperlink will execute.
%FUNC: BeginFunction
This action begins either a selection or a hyperlink
transaction.  This depends on what events follow.
%FUNC: ChangeGCColors
This function is called whenever a change is made to
one of several colors defined in resources.  Several
of the Graphics Contexts have related colors.  For
instance, the inverse_GC has the background pixel
color set to the same value as the normal_GC has
for its foreground pixel color.
%FUNC: ChangeGCFont
This function is called when a change to the VT font
has been made.  This requires that all Graphics
Contexts that use the font are changed accordingly.
%FUNC: ChangeGCSpecialColor
This function is specificaly used to change the
colors of the special font.
%FUNC: ChangeGCSpecialFont
This function is called when a change to the special VT font
has been made.  This requires that the special Graphics
Context that uses the font is changed accordingly.
%FUNC: ChangeManaged
This is a normal Method called when a child of the Vt Widget changes whether it
is managed or not.  With the Vt widget this does not mean very much.  The size
of the main widget does not depend on its children.  So if a widget pops in and
out of managment it simply appears and disappears from the Vt widget.  Basicaly
this routine is a stub in place of XmDrawingArea behavior which tries to change
the size of this widget when all of the children are unmanaged.
%FUNC: ClearDeadSpace
This routine is used to clean up a section of the screen that is blank
area but that might get clutterd with extrainious graphics.  This is caused
by a couple of situations.  First, graphics output can overwrite the edge of the
windows clear space.  This space is the border between text and the shadow.
Sometimes the wide and double height fonts cause the same problem.
%FUNC: CopyClipboard
This routine is called as an action to Copy to the X11 clipboard.
%FUNC: CreateOneCascade
This function is used to create a cascade button on a popup menu.
%FUNC: CreateOneOption
This function is used to create a basic button option on a popup menu.
%FUNC: CreateOneSep
This function is used to create a separator on a popup menu.
%FUNC: DeleteChild
This is a standard method that is called when a widget is deleted from the
Vt widget.  It is needed to properly size the window when the scrollbar
disappears.
%FUNC: Destroy
Destroy is used to free up the screen data and
also perform any other clean up activity.
%FUNC: Down
Down is an action routine that is triggered by the Down Key being pressed.
%FUNC: DrawHighlight
DrawHighlight draws the highlight for the current
XmVtWidget.
%FUNC: DrawShadow
DrawShadow redraws the shadow for the current
XmVtWidget.
%FUNC: EndFunction
This routine performs several functions.  It is used
to end a Hyperlink type transaction, and it also is
used to finalize a selection.  A selection can be one
of two types: a select on an area or a select on a
word.  The hyperlink transaction is executed by the
ExecHyper function.
%FUNC: ExecHyper
This function is used to change the appearance of a
hyperlink section of the screen as well as execute
the link.  This section is any section that has the
same attributes as the HyperAttributes resource. 
%FUNC: FocusInProc
This is an action routine used to check whether the widget should be
highlighted or not.  It looks for a normal focus in event to trigger the
highlighting process.
%FUNC: FocusOutProc
This is an action routine used to check whether the widget should be
unhighlighted or not.  It looks for a normal focus out event to trigger the
unhighlighting process.
%FUNC: FontListToFirstFontStruct
This routine obtains the first font structure from the provided XmFontList
data.  It does not provide any other font data besides the first font
structure.
%FUNC: GeometryManager
This is a normal Method that is called when children have requested position or
size changes be performed on them.
%FUNC: GetColumnFromX
This routine does the proper calculations to
convert an X coordinate pixel to a character
screen column value.
%FUNC: GetColumnsFromWidth
GetColumnsFromWidth is used to obtain the number of
appropriate columns for the widget derived from the
pixel width.
%FUNC: GetHeightFromRows
GetHeightFromRows is used to obtain an equivilent
pixel height of the widget from the number of rows.
This is usualy used to try to reset this height.
%FUNC: GetRowFromY
This routine does the proper calculations to
convert a Y coordinate pixel to a character
screen row value.
%FUNC: GetRowsFromHeight
GetRowsFromHeight is used to obtain the number of
appropriate rows for the widget derived from the
pixel height.
%FUNC: GetWidthFromColumns
GetWidthFromColumns is used to obtain an equivilent
pixel width of the widget from the number of columns.
This is usualy used to try to reset this width.
%FUNC: GetXFromColumn
This routine does the proper calculations to
convert a column value to an X pixel coordinate.
%FUNC: GetYFromRow
This routine does the proper calculations to
convert a row value to an Y pixel coordinate.
%FUNC: Initialize
Initialize is used to intialize the screen
data structures and other XmVtWidget data
structures.
%FUNC: InsertChild
This is a standard method that is called when a new widget is inserted into the
Vt Widget.
%FUNC: Layout
This routine is used under several circumstances to update the layout of
children of the Vt widget.  This is mostly used to update the scrollbar on
the right hand side of the Vt widget.  These circumstances might include a
change in background color or a change in the number of rows.
%FUNC: Motion
This routine is called as the mouse moves over the
Vt widget.  It is used to change the cursor if the
cursor is over a hyper-link attribute character
area.
%FUNC: ObtainGraphicsContexts
This function is used to find all the needed Graphics
Contexts for the widget.
%FUNC: OneGC
This routine creates one GC for future use.  This is called for each GC used
in the widget.
%FUNC: PageDown
PageDown is an action routine that is triggered by the PageDown Key being
pressed.
%FUNC: PageUp
PageUp is an action routine that is triggered by the PageUp Key being
pressed.
%FUNC: Paste
This routine is used to perform a paste operation
for the X window system.
%FUNC: PasteClipboard
This routine is called as an action to Paste from the X11 clipboard.
%FUNC: PopupCallback
This function is the callback for all of the basic and cascading menu buttons
for a popup menu in the Vt widget.
%FUNC: PopupMenuPost
This function displays a dynamic menu.
%FUNC: Redisplay
Redisplay is used to redisplay the XmVtWidget after
being covered.
%FUNC: Resize
Resize is used to reallocate the screen geometry to
the new arrangement.  It will clear any new area and
retain old area.
%FUNC: SelectArea
This routine performs an Atomic selection on an area
that is a rectangle formed by dragging the first
mouse button.
%FUNC: SelectWord
This routine performs an Atomic selection on one word
on the screen.  This word is identified by having
separating spaces around it.
%FUNC: SendMouse
This routine is called when a send mouse event is requested.  It sends the
mouse cursor information to the character based application (such as elvis).
%FUNC: SetUpPopupMenu
This routine is used to set up the initial menu 'stub'.  It prepares the base
menu shells and menu widgets and performs various initialization tasks.
%FUNC: SetValues
SevValues is called whenever the user application
needs to change any resources.
%FUNC: StartTimers
This function is used to start two of the three Xt Timer functions that service
the Vt widget.
%FUNC: StopTimers
This function is used to stop two of the three Xt Timer functions that service
the Vt widget.
%FUNC: StoreMenuShell
This routine is used to store the main menu shells for a complete heirarchial
menu structure.  These menu shells are then used to destroy the completed menu
when the XmVtUnloadPopup function is called.
%FUNC: StoreOption
This routine is used to add an option onto the current menu.  It can add a
regular option, a separator or a cascading button.  This can be done for either
a popup or a pulldown menu.
%FUNC: StringInput
StringInput is used as two action routines called string and self-insert.
As self-insert it inserts the pressed key into the keyboard buffer.  As
string it is used to insert a specified ascii value into the buffer.
%FUNC: UnDrawHighlight
UnDrawHighlight removes the highlight for the current XmVtWidget.
%FUNC: UnDrawShadow
UnDrawShadow removes the shadow for the current XmVtWidget.  This is useful
for prototyping gui user interfaces using the escape sequences.  It removes
a distracting border if one is not desired.
%FUNC: Up
Up is an action routine that is triggered by the Up Key being pressed.
%FUNC: XDrawEdge
This routine looks alot like the XDrawRectangle basic XLib function except that
it uses an upper left and a lower right GC to create a shadow effect on the
area bounded.
%FUNC: XmVtAppendListChild
This function appends a line of text to a child list widget of the Vt widget.
This line of text is appended to the bottom of the data.
%FUNC: XmVtAppendTextChild
This function appends a line of text to a child text widget of the Vt widget.
This line of text is appended to the bottom of the data.
%FUNC: XmVtBlankWidgets
This routine unmanages all Vt child widgets.  This is similar to a clear screen
except it is for the special case of widgets.
%FUNC: XmVtChildResize
This routine is used to resize a child widget using the normal rows and columns
type values of the screen coordinates.
%FUNC: XmVtChildSetValues
This routine receives the vtwidget name, a child identity character, a
resource and a value for the resource that will be set.  With this information
it properly sets the given resource for the child widget.
%FUNC: XmVtCopy
This routine copies selected data to the Clipboard from the Vt Widget.
%FUNC: XmVtDropSiteCB
This callback is called whenever a drag/drop operation deposits data on the Vt widget.
%FUNC: XmVtDumpTextChild
This routine sends all the data from a text widget to the keyboard input queue
of the parent Vt widget.  The child text widget is identified by the character
identity code provided as argument 2.
%FUNC: XmVtFlush
XmVtFlush is an externaly callable routine that
is used to clear the keyboard buffer of all
characters.  This can be used if a user would
like to utilize the data in an Activate
callback structure instead of using XmVtRead.
%FUNC: XmVtLoadButtonData
This routine is the normal method for programers to load a section of text to
be fed back to the keyboard at the activation of a PushButton.
%FUNC: XmVtLoadHyperData
This routine is the normal method for programers to load a section of text to
be fed back to the keyboard at the activation of a hyper text link.
%FUNC: XmVtLoadIcon
This routine is the normal method for programers to load an icon file into a Pixmap.  The identity
is a single character that when printed with an attribute of graphics will output an entire
icon image.  An icon can be either a XBM file or XPM (On Motif 2.0 or greater).
%FUNC: XmVtLoadPopup
This routine will create all of the menus provided in the referenced menu
file and will make the referenced root menu the base popup menu.
%FUNC: XmVtLoadWidget
This routine is used to prepare a particular widget for plotting on the
screen.  It does not begin managing the widget however.  That is done when
it is actualy plotted.
%FUNC: XmVtMonitor
XmVtMonitor is an externaly callable routine that
is used to monitor a file descriptor that is
connected to an open pseudo terminal, socket or
even a serial line device.
It properly sets up the periodic checks on the file
descriptor and sets up a handler for the death of
children.  A pid of XmCR_VT_NOPID can be sent in
to the input pid and this will prevent any signal
handling.
%FUNC: XmVtPBActivate
This routine is called from all Pushbutton widgets when they are pressed.  It
is a callback routine.
%FUNC: XmVtPaste
This routine pastes data from the Clipboard into the Vt Widget.
%FUNC: XmVtRead
XmVtRead is an externaly callable routine that
is used like the read system call except it
accesses a XmVtWidget instead of a file
descriptor.
%FUNC: XmVtSBDecCB
This function is used as the Decrement callback to the internal scrollbar.
%FUNC: XmVtSBDragCB
This function is used as the Drag callback to the internal scrollbar.
%FUNC: XmVtSBIncCB
This function is used as the Increment callback to the internal scrollbar.
%FUNC: XmVtSBPageDecCB
This function is used as the Page Decrement callback to the internal scrollbar.
%FUNC: XmVtSBPageIncCB
This function is used as the Page Increment callback to the internal scrollbar.
%FUNC: XmVtScrollBarSetValue
This function is used to set the scroll value of the VT
widget.
%FUNC: XmVtSend
XmVtSend is an externaly callable routine that
is used to send characters to the keyboard
buffer manually.  When this is done the Activate
callback is called.
%FUNC: XmVtSyncSize
This function is used before the main application is
realized to coordinate its width and height with the
VT widgets columns and rows.  This is very useful in
cases where the VT widget is the main widget in the
application and should have a specified number of
columns and rows for any given font.
%FUNC: XmVtTBActivate
This routine is called from all Togglebutton widgets when they are pressed.  It
is a callback routine related to any change in value for a toggle button.
%FUNC: XmVtTFActivate
This routine is called from all TextField widgets when they are pressed.  It
is a callback routine.
%FUNC: XmVtTransferProcCB
This routine performs the actual transfer of data from the drop to the keyboard
input.
%FUNC: XmVtUnloadPopup
This routine will remove a previously created Vt Popup menu created with the
XmVtLoadPopup routine.  It frees memory and destroys menu widgets.  This routine
is used when either of the resources RootMenu or MenuFile are changed.  This
should be called before a new XmVtLoadPopup is called.
%FUNC: XmVtUnmonitor
XmVtUnmonitor is an externaly callable routine that is used to end a monitoring
activity on a Vt widget.  If a process is presently being monitored that
process is first sent a SIGTERM signal as a friendly request for ending.
If the process is still present (as in the case of a shell like /bin/ksh) a
SIGKILL is then sent.  Next the descriptor that is being monitored is closed and
set to the value of 0.  Also the monitoring flag is set to False and the pid
internal resource is set to XmCR_VT_NOPID.  At that point the monitor callback
list is called for any other clean up the application might wish to perform.
%FUNC: XmVtWrite
XmVtWrite is an externaly callable routine that
is used like the write system call except it
accesses a XmVtWidget instead of a file
descriptor.
%FUNC: add_scrollbar
This function is called when the SetValues or Initialize find that the scrolled
flag is set to true.  It creates a scroll bar on the right side of the Vt
widget.  It also sets up all of the internal callbacks.
%FUNC: alc_vtscreen
This routine is used to allocate the memory used for the VTLINE array used
to store the screen information.
%FUNC: answer
This function sends the answerback message to the input keyboard queue.  This
routine is called when a character 5 (answer back) is interpreted.
%FUNC: beep
Produce an audible tone. This is a routine called by
the screen system, and is located in the graphics
subsystem.
%FUNC: bottom_edge
Check to see if the cursor is at the bottom edge if
true scroll up one line.
%FUNC: calc_ix
This routine calculates the main internal translation
weighting facter for determining RGB values.
%FUNC: cancel_eol
This function is called right before a control sequence that will change the
cursor position.  It cancels a preparation for autowrap that might be in
progress.
%FUNC: change_colors
This routine is one of several routines called by
the screen subsystem.  It is used to change the
colors of the VT terminal.  It changes the
appropriate resources to emulate the changes a
VT240 might make.
%FUNC: change_width
This function is used to resize the screen from escape sequences.  This is
used by standard ANSI escape sequences.
%FUNC: checkfd
This function is called whenever a free chunk of
processing time is available from the Xt event
processing subsystem and when a file descipter is
being monitored as a call to XmVtMonitor.  It
checks the file descriptor to see if output needs
to be printed on the VT widget.
%FUNC: chop
This function is used to chop an input buffer up into as large of blocks as
possible that can be digested for output into the widget screen data.  The
bigger the chunks the better the performance because these routines are called
often because of the fact that this is the main data stream.
%FUNC: clear_all
Clear all the screen.
%FUNC: clear_aol
Clear all of line.
%FUNC: clear_bol
Clear from begining of line to the cursor.
%FUNC: clear_down
Clear downward from cursor.
%FUNC: clear_eol
Clear to end of line.
%FUNC: clear_up
This routine clears the screen up from the cursor
position to the first character position of the
screen.
%FUNC: clr
This function clears the appropriate bit in an attribute.
%FUNC: collect
This routine is used to collect preprocessed lines that have already had
comments and blank lines removed.
%FUNC: convert_esc
This routine is used to convert strings that have internal escaped characters.
These include the escape, return and null characters.
%FUNC: convert_proc
This routine is used to respond to queries about what
kind of data does the widget support for selection 
conversions.  It also actual sends data to other X
clients that have requested a converted section
of selection.  TARGETS is the atom that is used to
respond to queries about what kind of target this
widget can convert to.
%FUNC: cub_move
This function moves the cursor backwards.
%FUNC: cud_move
This function moves the cursor down.
%FUNC: cuf_move
This function moves the cursor forward.
%FUNC: cup_move
This function moves the cursor to a specified location.
%FUNC: cuu_move
This function moves the cursor up.
%FUNC: delete_char
Delete any number of characters from the cursor forward.
%FUNC: delete_lines
Delete any number of blank lines starting at the current
cursor.
%FUNC: doblink
This function is called every 400 milliseconds or so (as long as there is some
processing time available) to toggle the blink on blink type attribute
characters  on the screen.  It toggles the switch and then sets the modified
switch on all such characters on the screen.  The routine plot will see these
characters the next screen update and toggle their images.
%FUNC: dputs
Debug puts.
%FUNC: dynamic_tmpnam
This function works similar to tmpnam (on which it relies) except for two
differences.  First, it does not take any parameters like tmpnam.  It returns
the value directly.  Secondly, it returns a dynamic value that must be freed
after use.  This allows saving the value for future use such as deleting the
file.
%FUNC: eight_bit
This routine is used to intiate eight bit emulation.
Normaly this includes at least a load of the default
color maps.  Since this 'terminal' ceases to exist at
the end of its usage there is no default set of
colors.  Therefore at this time this routine does
nothing.
%FUNC: equalize
This routine is used to equalize rgb values that are
out of range.  This occurs when large values of
luminance are specified.  The color is basicaly made
more white by spreading this extra intensity to the
other normal ranged colors.
%FUNC: execute_esc
Execute the commands associated with an escape sequence.
%FUNC: find_command
This routine determines what token should represent the current command.  It
returns a -1 if the command is not a supported command.  It returns the index
number for a supported command.
%FUNC: fixrems
This routine is used to fix up an escape sequence that
has a 'alternative' format for the numeric parameters.
Anyway, this alternative format involves no values in
the area where you would expect them such as:
ESC[;7H which means go to column 7 in the first row.
%FUNC: free_data
free_data frees all allocated dynamic memory associated
with the screen.  It also frees other dynamic allocations as well as closes
some files that may be open.
%FUNC: free_menu
This routine is used to clean up all dynamic memory used by a menu type
structure.
%FUNC: free_vtscreen
This routine is used to free all of the allocated memory in a VTLINE array.
A VTLINE array is the memory structure used to store all of the screen
information.
%FUNC: g_attr
This function gets the attribute section of the screen
buffer.
%FUNC: g_cset
This function gets the character set section of the screen
buffer.
%FUNC: g_data
This function gets the data section of the screen buffer.
%FUNC: g_flag
This function gets the modify flag section of the screen
buffer.
%FUNC: g_line_attr
This function gets the line attributes for a line of the screen.
%FUNC: get_blue
Obtain a Blue rgb value from hue, luminance and
saturation.
%FUNC: get_green
Obtain a Green rgb value from hue, luminance and
saturation.
%FUNC: get_red
Obtain a Red rgb value from hue, luminance and
saturation.
%FUNC: gethostaddr
This function is used to find the host address of the current node.
%FUNC: graphics_plot
This routine is used to plot high resolution graphics at a specified
location.  These graphics are in Xpm format.  Please notice that this
routine protects sections of the screen from further plots.  This may
block out some text if graphics is located at the same text coordinates.
%FUNC: half_scroll_up
Scroll up lower part of the screen up to the cursor.
%FUNC: hasmatching
This function compares two attribute variables to determine if they have any
matching set attributes.
%FUNC: init_data
init_data initializes all the internal data structures
for the screen.  It allocates space sets the cursor in
places and clears the screen.
%FUNC: insert_blanks
Insert any number of spaces at the current cursor.
%FUNC: insert_char
insert_char inserts one character at the current position.
It will move characters out of the way to make room for
the character to be printed.
%FUNC: insert_lines
Insert any number of blank lines at the current cursor.
%FUNC: isany
This function is true if any attributes are set in an attribute variable.
%FUNC: isequal
This function is true if the two provided attribute variables have the same
attributes set.
%FUNC: isforcing
This boolean check determines whether a character is
one of those which forces a set RGB value to be loaded
into a terminal colormap.
%FUNC: isnone
This function is true only if there are no attributes set in an attribute
variable.
%FUNC: isnonview
This routine finds those characters that are non viewable for the Vt widget.
it returns True if the passed character is not viewable.  The general rules
for the vtwidget is to not print any characters less that character 28 except
for character 22.  The reason for this set up is to allow the printing of
DOS ANSI graphics characters (something rxvt and color_xterm do not do).
There still may be some DOS ANSI graphics characters not printed, I have no
references here.  I just test with a nice ANSI artwork file I found.
%FUNC: isset
This function is a boolean function that determines if a particular bit is
set in an attribute.
%FUNC: load_menu
This routine is used to load a given menu file to derive a dynamic popup
menu for the Vt widget right hand mouse press action.
%FUNC: lose_ownership_proc
This routine is called when the Primary selection is
lost on the X server.  This means that the VT widget
must clean up the highlighting representing the
selected data because it no longer is truly selected.
%FUNC: make_lines
make_lines takes a string of characters and converts
them to the proper line drawing characters.
%FUNC: make_ukascii
This routine takes a string of characters and searches for any # symbols and
substitutes the correct font character ID in the screen.
%FUNC: message
message parses an escape sequence that is sent to provide
a message to the terminal.  This message is stored in the
vt structure.
%FUNC: message_do
This function calls the special callback for the message escape sequence.
When a message is sent to the Vt Widget this routine is called and then
the callback message_callback is executed.
%FUNC: multi_attr
This function handles those cases of setting more than
one character attribute at one time with the attribute
sequence.  Unfortunatly this routine is short because
it is recursive it calls execute_esc to set the
proper attributes.  This can be changed if this is
not proper.  I do not mind recursive code if its easy
to read.  However it can be hard to read if it is
complicated.  This is not.
%FUNC: newline
This function begins a new line.  It does not need to check any modes unline
the normal carriage return.  It is basicly a carriage return/ line feed.
%FUNC: non_print
Execute the non printable character actions like
Carage return, line feed and escape.
%FUNC: ok_revive
This routine is called to OK a total revival of all characters on the displayed
screen.  This is used when a scroll has taken place.  This causes the
update_image routine to call revive_all.  This is an API call that is used by
screen.c.
%FUNC: ok_update
This function is called to authorize an update to the screen whenever the
X system finds some extra time or imediately if smooth_mode is TRUE.
If smooth_mode is FALSE, this does not actualy perform the update 
to the screen, it just sets the wheels in motion by setting the appropriate
flag in the widget.  This is an API call for screen.c to use.
%FUNC: p_cb
This routine is the callback for the Paste routine.
It is called when the X Server is ready for the
actual data transfer.  It performs the actual paste
of data.  In this case it simple sends the data to
the keyboard queue.
%FUNC: paint_data
This routine paints the current data to the output device.  It accesses the
memory structures of vt.vtscreen directly so if any changes are made to
these structures coorisponding changes need to be made here.
This routine is rather
hard to understand, especialy if you do not understand how Vt.c is processing
information it receives from screen.c.  It has been optimized to accelerate the
painting of data on the Vt widget window.  This is my only excuse for such
hard to read code.  I basicaly loop through the data line by line column by
column looking for modified data (S_MOD).  I then try to find similar chunks
of screen info (same attributes and cset) and plot them with the plot routine.
At some point another optimization will be to simply plot the data directly
from the vt.vtscreen area instead of memcpy-ing it to a pldata area.  This
memcpy takes a little time when you are looping it so much.  This routine
was originaly in Vt.c but was moved to this module when it was rewritten to
access screen data structures directly.  It is now a low level routine even
though it calls the plot routine in Vt.c.
%FUNC: parse_color
This routine properly decodes complete DEC color
sequences for setting terminal color maps.  These color
maps are a different type than the X color maps. They
are related specificaly for DEC VT240 type color usage.
%FUNC: parse_esc
parse_esc isolates an escape sequence to be later
executed by execute_esc.
%FUNC: parse_hls
This routine properly decodes just the Hue, Luminiance
and Saturation part of a DEC color sequence.  It returns
the X RGB color value that is appropriate.  It also
finds which terminal color map to load with the new
color.
%FUNC: parse_line
Find all the commands and parameters on a line and place
these into string arrays for future parsing.
%FUNC: place_cursor
Place the cursor in a specific location. 
This is a routine called by the screen system,
and is located in the graphics subsystem.
%FUNC: plot
Plot a string in a specific location. This is
a routine called by the screen system, and is
located in the graphics subsystem.
%FUNC: process_line
This routine is used to process each line of the vtrc file individualy.  It
scans each line for various pieces of information such as menu name, command
to execute on that menu item, data to operate upon and a description for
the menu item.
%FUNC: program
This system is a new widget called Vt it emulates a VTXXX
DEC style terminal plus many other special GUI type
functions that can make a text based application look like
a full fledged Motif application.
%FUNC: protect
This function will protect an area of the screen from having text data
written to it.  This is used to protect graphics areas.  If this was not
done text would overwrite the graphics.
%FUNC: qtrim
This routine is used to trim white space characters from the end of
a string.
%FUNC: qtrim2
This routine is used to trim only the space character from the end of
a string.
%FUNC: readready
This function checks a file descriptor to find if
it is ready to be read from.  This is used as a
non-blocking mode check on a file descriptor.
%FUNC: remove_cursor
Remove the cursor from a specific location.
This is a routine called by the screen system,
and is located in the graphics subsystem.
%FUNC: remove_scrollbar
This function destroys the scrollbar widget when SetValues finds that the
scrolled flag has been set to false.
%FUNC: reserve
This routine reserves a range of lines on the screen
for scrolling.  This permits localized scrolling of
part of the screen. This is commonly used in editors.
%FUNC: reset
Reset initializes all of the soft parameters for the
screen.  This includes where the cursor is and clearing
the screen as well as setting insert and attributes.
%FUNC: reset_attr
This function clears an attribute variable.
%FUNC: resize_data
resize data changes the values of the rows and columns
of the screen.  It does some dynamic memory changes
and ensures all memory is accounted for.
%FUNC: reverse_index
Insert one line at the cursor.
%FUNC: revive
This function revives any character on the screen that
is visible.  This is done for a redisplay.
%FUNC: revive_all
This function is used when there has been a scroll or
several scrolls that have taken place during a write.
To make the widget use its time best it will only
mark all screen bytes as modified only if a scroll has
occured and it will only do this at the end of the
write.  To demonstrate, consider a buffer full of
line feeds. If the widget looped the entire screen for
each line feed there would be millions of iterations
of the marking loop while, by using revive_all, there
is only a single marking of the entire screen.
%FUNC: right_edge
Check to see if the cursor is at the right edge, if
true move to next line.
%FUNC: s_attr
This function sets the attribute section of the screen
%FUNC: s_common
This function sets many characteristics across a defined section of a line.
It will set the data, attributes, and character set information for a whole
line if necesary.  This function is built to provide optimization for
the many calls made to clear lines or set lines to a particular value.
%FUNC: s_swap
This function is used to swap one line and another line by reassigning pointers.
This function is used for optimization of reverse index and
scrolling type functions.  It sets the source line to modified (The source
becomes the destination then during the swap.)  The destination line is
considered unimportant and so it is never identified as modified.  I found this
to be faster than a s_copy function that used memcpy to actualy move data.  Now
I just reassign pointers by swaping VTLINE structures.
%FUNC: s_cset
This function sets the character set section of the screen
buffer.
%FUNC: s_data
This function sets the data section of the screen buffer.
%FUNC: s_flag
This function sets the modify flag section of the screen
buffer.
%FUNC: s_line_attr
This function sets the line attribute for a line of the screen.
buffer.
%FUNC: s_multi
This routine works a little like a combination of s_data, s_attr, s_flag and
s_cset.  It also works with a complete string.  It adds multiple components
to the vtscreen element of the Vt widget.  This routine could probably also
be named add_string because it works alot like insert_char except it adds the
data instead of inserting it and it adds a full string of characters.
This routine can only enough characters to fill a line.  If more characters
are sent to it than what it needs to fill a line it will ignore them.  It does
however return the number of characters it actualy outputs.
%FUNC: scroll_up
Scroll the screen up.
%FUNC: self_test
This function fills the screen with 'E's.  This is used as a self test for
most DEC terminals.
%FUNC: send_keys
Send_keys is used to send data to the input buffer
of the widget from a non-keyboard input method.
%FUNC: set
This function sets the appropriate bit in an attribute.
%FUNC: showgraphic
This routine is called from the screen command interpreter to cause the Vt
widget to output a graphics image to the screen.  The vt.graphics_name element
of the widget has the filename of the graphics image.
%FUNC: singlespcQ
This function removes all extranious spaces or tabs and
replaces them with a single space or tab. EXCEPT within a
double quotes delimited string. This is how this function
differs from the regular singlespc function. It also adds a
simple mask to be used by other functions that will be a
string of Xs where a string resides in the original input
string.
%FUNC: speccmp
This routine is a Special string compare that works
alot like strncmp except that ; characters are removed
from the first string before the comparison is made.
This basicaly means that the ; character is ignored.
%FUNC: special_message
This routine parses an escape sequence that is sent to provide
a special_message to the VT widget.  This message is a command sequence
that is used to access special features such as GIF picture loading.
%FUNC: special_msg_do
This function is used to service a special message.  These special messages.
can have a variety of commands directed towards the widget.
%FUNC: strcatch
Concatenate a character to a string.
%FUNC: strcicmp
This routine works exactly like strcmp except that the comparison is case
insensitive.  (Notice the 'ci' in the name.)
%FUNC: strcincmp
This routine works exactly like strncmp except that the comparison is case
insensitive.  (Notice the 'ci' in the name.)
%FUNC: string_set_attr
This function translates a string of attributes into a value to bitwise OR
into an attribute varable.  This is used for instance to set the Hyperattribute
resource from string values.
%FUNC: sub_proc_one
Sub process an 'escape[?ParmsCode'  seqence for parameters.
Most of these will be hard coded in the execute_esc 
function.  Only those that are not being processed will
end up here.
%FUNC: sub_proc_three
This routine is used to sub process an 'escape[Pal' type escape sequence.
This type sequence is used to behavior mode type flags in the emulation
typicaly.  A subcode of l means to reset the flag.  A subcode of h
means to set the flag and a subcode of $p means to report the flags
state back to the host.
%FUNC: sub_proc_two
Sub process an 'escape[ParmsCode'  seqence for parameters.
Some of these will be hard coded in the execute_esc
function. Several heavily used functions like relocating
the cursor are located here.
%FUNC: sync_cursor
Make sure that the screen cursor is not outside the bounds
of the screen.
%FUNC: tab_clear
This function clears a tab at the current cursor location.
%FUNC: tab_clear_all
This function clears all tabs.
%FUNC: tab_over
Tab over to the next screen defined tab.
%FUNC: tab_set
This function sets a tab at the current cursor location.
%FUNC: transfer_done_proc
This function is called when a client is done
transfering a selection into its application.  The
routine is not used in this widget.
%FUNC: unmanage_unpainted_widgets
As its name implies this routine searches the child widget list to find all
those widgets that have not been plotted on the current Vt widget.  When
it finds one it unmanages the widget.
%FUNC: update_image
This routine is called repeatedly whenever possible every TOUT # of 
milliseconds.  It repaints the screen to the current state and places the
cursor in the appropriate coordinates.  It then reschedules itself in another
TOUT # of milliseconds.
%FUNC: widget_child_dead
This routine is called by the signal handler for
SIGCLD.  It sorts out which child to which widget
has just died.  It then sets the appropriate flag
in the proper widget.
%FUNC: widget_plot
This routine is used to place widgets at a specified
location.  These widgets are standard Motif widgets.  Please notice that this
routine can only place one widget of a given identity a very odd effect can
occur if a particular widget is plotted twice on the same screen.
%FUNC: write_s
write_s works just like write except no file descriptor
is passed because write_s only writes to the screen.
%FUNC: writeready
This function checks a file descriptor to find if
it is ready to be written to.  This is used as a
non-blocking mode check on a file descriptor.
%PARM: line_pos Input
This is the line position to set to S_MOD.
%PARM: addon Input
String to substitute if s directive is found.
%PARM: address Output
Address of current node.
%PARM: alen Input
Actual length of match
%PARM: app Input
This is the application name to obtain the popup menu for.
%PARM: args Input
Set of X arguments
%PARM: attr Input
Type of characters
%PARM: attr1 Input
Attribute number 1 for compare.
%PARM: attr2 Input
Attribute number 2 for compare.
%PARM: attr_data Input
Attribute data in string format.
%PARM: background Input
This is the background Pixel for the new GC.
%PARM: base Input
Base angle for hue
%PARM: bintense Input
Intensity flag
%PARM: blue Input
Blue value 0 - 255
%PARM: bot Input
Bottom offset
%PARM: bot_right Input
Bottom right GC
%PARM: buffer Input
Buffer of output data
%PARM: call_back Input
This variable defines callback reasons.
%PARM: callback Input
Callback data
%PARM: callback_data Input
This is data to be sent if the button is activated.
%PARM: cb Input
Callback data.
%PARM: cd Input
Client data.
%PARM: ch Input
This is a single character.
%PARM: client_dat Input
Client data passed to callback
%PARM: client_data Input
Data for callback
%PARM: closure Input
Input data from the drop. In this case the parent vt widget.
%PARM: command_str Input
This is the command string to evaluate.
%PARM: count Input
Count of characters to write
%PARM: cset Input
Character set
%PARM: ctd Input
This is a boolean value sent to the dynamic instantiation routine.
%PARM: ctw Input
Current widget
%PARM: current
Current Widget
%PARM: cw Input
Current Widget
%PARM: data Input
Data to append
%PARM: depth Input
Thickness of the edge or shadow to draw.
%PARM: destination Input
This is the destination line to copy to.
%PARM: display Input
Display for rectangle.
%PARM: elements Output
Elements parsed from line.
%PARM: event Input
X event for situation
%PARM: extend Input
String data to extend the value of the text widget.
%PARM: fd Input
Input file descriptor
%PARM: first Input
Default first parm
%PARM: firststr Input
First string to compare
%PARM: flag Input
Modified flag
%PARM: font_list Input
This is the font list to examine.
%PARM: foreground Input
This is the foreground Pixel for the new GC.
%PARM: format Input
Format of data (8bits)
%PARM: format_return Input
Format of data returned
%PARM: green Input
Green value 0 - 255
%PARM: height Input
Height of rectangle
%PARM: hue Input
Hue angle of color
%PARM: hyper_data Input
This is data to be sent if the hyper link is activated.
%PARM: id Input
Identity of interval
%PARM: identity Input
Identity of the element.  This is a single character that will identify the
element on the screen.
%PARM: in_column Input
Column to convert to a pixel X coordinate
%PARM: in_row Input
Row to convert to a pixel Y coordinate
%PARM: iname Input
The name of the icon to load.
%PARM: inhue Input
Hue value to check
%PARM: input Input
Color sequence to parse
%PARM: input_pid Input
Pid to monitor
%PARM: inputdata Input
This is the special message command and data.
%PARM: label Input
Label for a button on the menu.
%PARM: last Input
Default last parm
%PARM: ldata Input
Line attribute information.
%PARM: len Input
Length of string
%PARM: length Input
Length of value data
%PARM: length_return Input
Length of data returned
%PARM: lf Input
Left offset
%PARM: line Input
Line of input to parse.
%PARM: location Input
This is the location of the menu file.
%PARM: lum Input
Luminance of color
%PARM: map Input
Color map ID to load
%PARM: mapping Input
Mapping flag
%PARM: mask Output
Mask showing a string.
%PARM: mattr Input
Multiple attributes
%PARM: maxx_value Input
Maximum X coord Value
%PARM: maxy_value Input
Maximum Y coord Value
%PARM: menu_array Input
This is the main menu array to create sub menus with.
%PARM: menupath Input
This is the full path to a menu file to load.
%PARM: minx_value Input
Minimum X coord Value
%PARM: miny_value Input
Minimum Y coord Value
%PARM: name Input
The name of the widget.
%PARM: new Input
New Widget
%PARM: new_menu Input
This is the new menu information structure.
%PARM: new_popup Input
The new popup menu stub to add options to.
%PARM: new_w Input
New Widget to Eval
%PARM: newfont Input
This is the new font for the new GC.
%PARM: notify_parent Input
This Boolean value is used to determine if the parent widget should be notified
of a request for new size.  This is not needed for instance when the shell
parent has been resized by the window manager.
%PARM: num_args Input
Number of X arguments
%PARM: number Input
Number of actions to take
%PARM: numparams Input
Number of parameters
%PARM: p_attr Input
Plotting attribute value.
%PARM: params Input
Parameters to Action
%PARM: parent Input
Parent widget for new menu.
%PARM: pldata Input
Plot data
%PARM: post Input
Post-printed tag data from a text widget.
%PARM: pre Input
Pre-printed tag data from a text widget.
%PARM: quotechr Input
Defined quote character.
%PARM: receiver Input
Receiving Widget
%PARM: red Input
Red value 0 - 255
%PARM: region Input
This is the region that has been exposed.
%PARM: reply_ge Input
This is the response to a GeometryManager request.
%PARM: request
Requested Widget
%PARM: request_ge Input
This is the geometry request to the GeometryManager routine.
%PARM: res Input
Resource name.
%PARM: retval Output
This is an output value.
%PARM: rgb Output
X rgb color string
%PARM: root Input
This is the menu that should be the root menu.
%PARM: row Input
Count of rows in 2D array
%PARM: rt Input
Right offset
%PARM: sat Input
Saturation of color
%PARM: scr_width Input
New width of screen.
%PARM: screen_flag Input
Modify screen flag
%PARM: scroll_value
Value to scroll
%PARM: secondstr Input
Second string to compare.
%PARM: selection Input
Current selection struct
%PARM: seltype Input
Selection type of transfer.
%PARM: sent_widget Input
This is the widget that is sending the callback.
%PARM: shell Input
Menu shell widget to store away in the Vt widget.
%PARM: signum Input
Signal number provided to the signal handler by UNIX.
%PARM: single Input
Single chr to print
%PARM: source Input
This is the source line to copy from.
%PARM: string Input
This is the input string to single space.
%PARM: strwidth Input
Actual string width of strings
%PARM: target Input
Target type of conversion
%PARM: time Input
Time of event.
%PARM: title Input
Title for new menu.
%PARM: tnew Input
New Widget
%PARM: top Input
Top offset
%PARM: top_left Input
Top Left GC
%PARM: treq Input
Requested Widget
%PARM: tw Input
VT Widget data
%PARM: type Input
Input type of data.
%PARM: type_return Input
Type of selection returned
%PARM: type_s Input
Type of selection
%PARM: val Input
Value to set resource to.
%PARM: value Input
Value to paste
%PARM: value_return Input
Data returned
%PARM: vtmenu Input
This is a menu structure to free.
%PARM: vtscreen_name Input
This is the current vtscreen to manipulate.
%PARM: vtw Input
Current VT widget
%PARM: w Input
Passed Widget
%PARM: wcol Input
Character width of widget to realize.
%PARM: wgt Input
Input widget to callback.
%PARM: wid Input
Widget to be used for processing.
%PARM: width Input
Width of rectangle
%PARM: win Input
Window for rectangle
%PARM: writing_flag Input
Modify writing flag
%PARM: wrow Input
Character height of widget to realize.
%PARM: wtype Input
The type of widget to realize.
%PARM: xc Input
X coordinate
%PARM: xc1 Input
X coordinate one is the left X coordinate of a protected box
%PARM: xc2 Input
X coordinate two is the right X coordinate of a protected box
%PARM: xcoord Input
X coordinate
%PARM: yc Input
Y coordinate
%PARM: yc1 Input
Y coordinate one is the top Y coordinate of a protected box
%PARM: yc2 Input
Y coordinate two is the bottom Y coordinate of a protected box
%PARM: ycoord Input
Y coordinate
%HIST: parse_line
11/07/95    Bruce M. Corwin   Initial Release
%HIST: program
02/15/96    Bruce M. Corwin   Initial Release
%HIST: singlespcQ
11/07/95    Bruce M. Corwin   Initial Release
%LOGC: widget_plot
The scrolled text and scrolled list need special treatment (as denoted by the
special boolean).  This is apparently because to be properly sized or moved
they need to be accessed throught the SetValues method instead of XtMoveWidget.
This seems to be a result of having the XmScrolledWindow and child Widget so
tightly integrated together.  If this method is not used the XtMoveWidget ends
up moving the child inside of the ScrolledWindow (or more likely its the
clipping window) which distorts the appearance of the widget.
%HIST: paint_data
02/15/96    Bruce M. Corwin   Initial Release
02/04/97    Bruce M. Corwin   Changed the value of S_MOD to 1
                              instead of -1 for signed problems.
%HIST: reset
11/07/95    Bruce M. Corwin   Initial Release
04/22/97    Bruce M. Corwin   Made sure to initialize more variables.
%HIST: alc_vtscreen
11/07/95    Bruce M. Corwin   Initial Release
04/22/97    Bruce M. Corwin   Made sure to initialize line_attribute
