home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
316.lha
/
EtaleFileReader
/
efr.doc
< prev
next >
Wrap
Text File
|
1989-11-30
|
12KB
|
249 lines
The
Etale
File Reader
by William F. Hammond
Copyright 1989
[This program is freely distributable. It may not be included in a
product that is sold, other than in a collection of freely distrib-
utable software for which a modest charge for material and handling is
imposed, without the permission of the author (address at the end of
this file).]
REVISIONS: This version contains minor revisions and corrections.
Information on the revisions may be found at the end of this file
along with a newly suggested use for "program" mode.
The
Etale
File Reader is a "more"-like program designed for use
with the mathematically oriented character set that comprises the
Etale
font. The
Etale
font is an Amiga screen font that is identical
to the ordinary "topaz 8" screen font on standard ASCII characters but
has mathematical symbols, including a complete Greek alphabet,
installed in the "high-ASCII" range.
The
Etale
font contains four non-printing characters (with hex
codes 87, 86, 88, 8A) for "start superscript", "end superscript",
"start subscript", and "end subscript" that correspond to the
<Ctrl>-<Alt> versions of the keys labeled "g", "f", "h", and "j" in
the "math" keymap that accompanies the
Etale
font. My chief reason
for writing the
Etale
File Reader has been to make it possible to see
superscripts and subscripts on the Amiga screen without having the
machine taken over by a large technically-oriented word processor.
Note that this file reader reads ALL "printing" codes in whatever
font it finds installed when it is called. Support for super- and
subscripts is, moreover, available when reading ANY file in ANY font
provided that the super- and subscripts are turned on and off in the
file by means of the non-printing codes described above.
It had been possible with the version of the
Etale
font distributed
in February 1989 to achieve on a suitable printer that which can now
be seen on the screen. The reason that superscripts and subscripts
cannot be seen on the screen without a special program is that the
Amiga's "console device" does not support them. Nor does it support
"merged" symbols. For example, if a file contains a "/" character,
followed by a "<backspace>" and then a "\", on many printers, and now
in this reader, the result will be something like an uppercase "x".
The
Etale
File reader weighs in at 14,708 bytes. It is perhaps, even
then, slightly obese since it is written in "C".
There are several other ways in which this reader differs from the
standard Commodore-supplied "more" program. First, for better or for
worse, it does NOT run from WorkBench. This is because it opens a
screen-size borderless and gadgetless window on the active screen.
(This makes the viewing area as large as possible consistent with the
size of the screen and the size of the user's font. Be warned that a
LINE TOO LONG WILL NOT WRAP, but will be CLIPPED. And yes, "hard"
linefeeds are required.) Most users will want to have the means to
get behind this window, and it cannot be assumed that the average
WorkBench user is so equipped.
Care has been taken to make sure that this reader is fully compat-
ible with the concurrent piping available through the PIP: device that
is part of W. Hawes' "ConMan" console handler. Also, rather than
build a "find" facility into it, I decided to design this program so
that it could be easily inter-faced at the "shell" level with the
"search" command. For example, with PIP: in the ARP shell:
alias efrf search file [] \| efr g file
efrf scruff
will put you in the file "file" on the line containing the first
occurence of the pattern "scruff". To proceed to the next occurence,
enter "n" in the reader window. To change to regular file reading
mode enter "c" for "continue" in the reader window.
The various internal file reader commands are listed on the "help
card" in this package that has the file name "efr.help". They are
mostly self-explanatory.
For a quick demonstration of what mathematical text can look like
in the
Etale
File Reader, install the
Etale
font using "FastFonts"
from WorkBench 1.3 with the command
ff etale.font
after first copying the file "etale.font" to your "fonts:" directory,
creating a subdirectory named "etale" in your "fonts:" directory, and
copying the file "etale_8" to the filename "fonts:etale/8"; and then
enter the command
efr efrdm
in your shell (or CLI) window to view the "demo" file.
To scroll through a file in the
Etale
File Reader without pausing
(except at the end of the file) enter the command
efr t file
or the command
efr <file t
in your shell window. Or, simply at any time while reading in a file,
enter "t" at the prompt to scroll toward the end. While scrolling,
hit any "regular" key to pause and again hit any "regular" key other
than "x" to continue the scroll. At any time while paused in a scroll
enter "x" to bring up the normal file reader prompt line.
The only command line options are "t", as just explained, or "g",
which invokes "program mode". To use "program" mode you need a
"program" which is simply an ASCII file in which each line begins with
a number (ignoring leading whitespace characters -- the whitespace
characters are "<space>", "<tab>", "/", "*", "'", and ";"). A line
in a program file that, ignoring whitespace characters, does not begin
with a number will be ignored. If there are lines beginning with the
numbers 5, 61, 47, and 83, then the command
efr <program g file
will open the reader at line 5 in "file". From that point normal
reader commands can be given. Then when ready, entering "n" will move
the reader to line 61. Subsequent invocations of "n" will move the
reader to the lines 47 and 83.
The "efrf" alias described above is not very practical since it is
useful only for searching through one file with the name "file". The
simplest practical way of interfacing the file reader with the search
command is to use the following shell script with script name "rdf":
.key file/A,pat/A
.bra {
.ket }
echo "Searching {file} for the pattern {pat}"
search "{file}" "{pat}" | efr g "{file}"
(Note that since this script takes arguments, it should NOT be used
with the first version of ARP 1.3 "execute", released in April, 1989,
although it works perfectly well with the corrected version of ARP 1.3
"execute" as well as with the WorkBench 1.3 "execute".) Then the
command
rdf haystack needle
will bring up successively the occurences of the pattern "needle" in
the file "haystack" assuming that the script bit has been set on the
file "rdf".
In addition to the special non-printing ASCII codes reserved for
super- and subscripting there is support for the following escape
sequences for
monochromatic
text styling:
<Esc>[0m Clear all style
<Esc>[1m Boldface
<Esc>[3m Italics
<Esc>[4m Underline
<Esc>[7m Inverse video
Other special characters are <backspace> (hex 08) and <tab> (hex 09).
Upon finding a <backspace> the output cursor is moved backward the
width of one character without overwriting. A printing character that
follows will be merged with the character preceding the backspace.
Upon finding a <tab> the output cursor will be moved forward the width
of three characters without overwriting. There are no "tab stops" in
the file reader window. A "null" code (hex 00) in the file being read
will be ignored.
The program does not buffer the file being read. Thus, it is
possible under backward movements and under forward movements of more
than one screen page for the reading program to be oblivious of
control codes in the file that were "skipped over". Although there is
no limit on the level of subscripting, there will be glitches when a
line with three or more levels of subscripting appears as the last
line on the screen with its subscripting overwritten by the prompt
line. This may be cleared by a backward half screen page motion ("u")
followed by a forward screen page motion ("<space>").
Please note that the use of hex code 9B as a substitute for
"<Esc>[" in the world of the console device is not supported in this
file reader. Any character found in a file that is not a special
character or part of an escape sequence, as described above, will be
sent to the file reader window.
Output to the file reader window is by means of the Move() and
Text() routines found in the ROM-based graphics library. The file
being read is processed a line at a time. Before a line is sent to
the reader window it is divided into parts each of which consists of
a sequence of control characters (except for the first part of a line
that does not begin with a control character) followed by a sequence
of regular characters (except for the last part of a line that ends
with a control character). There is one call to Text() for each
part of a line that has regular characters. There is no buffering.
Thus, the program does not know the number of lines in the file that
it is reading until the first time that it reaches the end, and any
backward move in the file requires a rewind (which cannot be done if
the file is presented to the program as "standard input"). The user's
response at a prompt is picked up through the reader window's
"Intuition Direct Communication Message Port".
Please report any problems or bugs to:
William F. Hammond telephone: 518-442-4625
Department of Mathematics and Statistics
SUNYA email:
Albany, NY 12222 (USA) wfh58@leah.albany.edu
REVISIONS
This first comment is not a revision, but the answer YES to the
question "Is programming mode good for anything other than the inter-
face with the "search" command?". If you have an editor with a good
ARexx (a product of William S. Hawes, Maynard, Mass., USA) interface,
you can open the Etale File Reader from the editor on the page that
you are looking at in the editor. This certainly works with TxEd Plus
(a product of Microsmiths, Inc., Cambridge, Mass., USA). I have not
implemented such a macro with any other editor. It is just a question
of having the editor (a) write the file being edited, (b) report its
location and the name of the file being edited to ARexx, (c) saving
that location, (d) moving to the top of the screen, (e) writing that
line number in a small temporary file, (f) opening the file reader in
program mode with that small temporary file as the "program", and (g)
returning the editor's cursor back to where it was. In TxEd Plus all
of this can be wired to a single touch of the "0" key on the numeric
keypad.
The welcome banner flashes only subliminally if the program is
called by its native name "efr" (all lower case) on the command line.
The call may be through any alias so long as the alias string
definition uses the native name. (It does not matter if the file name
itself is lower case.) This speeds up loading significantly. On the
other hand, if the program is not called by its native name, the
welcome banner flashes, as in the earlier versions, for one-half
second.
The message that is sent to the console by the program when (and
if) it discovers the number of lines in the file is now sent to
"standard output" rather than unconditionally to the console.
Therefore, this message may now be diverted.
If the last character in the file being read is not a linefeed, the
program may or may not, depending on how it reaches the last line,
decide to count the last line in the line count that is reported when
it first reaches the end of the file and subsequently in the "Go To
Line" prompt. It would make the program two or three hundred bytes
larger to eliminate this, and I am not currently inclined to do so.
(After all, EMACS on the local mainframe will yell at a user trying to
write a file that does not end with a linefeed.)