Problem
I would like to illustrate an example of using a vtcl(TCL)-based
program in an ASCII document. Is it possible to do this? Solution
A program using vtcl(TCL) can be run in curses(S) (character) mode, by unsetting the DISPLAY environment variable. To capture the screen output, use a scoterm(XC) emulator, and unset the DISPLAY environment variable, eg (in ksh(C) or sh(C)):
$ unset DISPLAYThe vtcl(TCL) program can now be run in the scoterm(XC), and
will use the curses(S) based display engine rather than the
Motif engine. Select the screen display you wish to capture
and cut-and-paste the screen to a file using the mouse.This may simply be achieved using vi(C) in another scoterm(XC). Start vi(C) and enter insert mode, for example:
$ vi /tmp/output_file
<i>After you cut-and-paste the screen shot into the file, enter <Esc> to return to command-mode in vi(C), and save the file.
The file (however created) will contain ANSI line-drawing
characters, which will not display correctly in an ASCII
document. A simple script is appended which will convert
simple ANSI line-drawing characters to pipe symbols '|',
hyphens '-' and equals symbols '='.Run the attached script on the file and redirect the output to a new file:
$ convertVtclCurses /tmp/output_file > /tmp/image.ASCIINOTE: The script, as shown, can only translate simple line-drawing
characters; no attempt is made for those which cannot be
represented using the characters noted above. This translation
is, however, effective for the majority of vtcl(TCL) screen output.The screen thus translated may be 80 characters wide. It may
be useful to trim the width of the line to 78/79 characters by
removing an extraneous character from each line.If the output from convertVtclCurses still includes ANSI line-drawing characters, the od(C) command may be used to determine the octal values of such characters, for example:
$ convertVtclCurses file.ansi | od -cAdd the octal values to the tr(C) command with an appropriate ASCII translation.
#!/bin/ksh#
# simple translation of scoterm(XC) line drawing characters to it(SSL) format
# __ __ __
# | | | - |
#
# | | ==> | |
#
# | | | - |
# -- -- --if [ $# -lt 1 ]
then
echo "convertVtclCurses file [ file file ... ] [ > output ]"
else
while [ $# -gt 0 ]
do
#
# The complete list of translated (octal) characters is:
# \332 \304 \277 \263 \300 \267 \331 \272 \324 \315 \274 \270 \273 \275
# \276 \310 \311 \323 \325 \326 \260
#
# to (ASCII) '|-|||||||=||||||||||#'
#
#
cat $1 | tr
'\332\304\277\263\300\267\331\272\324\315\274\270\273\275\276\310\311\323\325\32
6\260' '|-|||||||=||||||||||#'
shift
done
fi