[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FORMAT Features

I have been anoyed that Common Lisp has no screen manipulation primitives.
Clearly it would be nice to have a general set of Window functions, but
it would also be extremely difficult to do right.  I think that
something like the following new FORMAT features would prove to be
useful.  Basically I am proposing to put some of the features of Maclisp's
CURSORPOS function into FORMAT.
(1) Clear-Screen.  The ~| directive used to clear the screen (window)
on some CL implementations, but last time I tried it I got PAGE
in a lozenge instead.  While this behavior is useful for viewing
files it is not always desirable.  If it is undesirable to
change the behavior of ~| (again) then the ~:| directive could
be used instead.  If the output stream is a terminal or window
then this directive clears it.  Otherwise it "outputs a page separator

The following directives signal an error if the output stream cannot
support the operation.

(2) Cursor positioning.  The POINT on the screen can be set with
the directive "~n,m."  (That is the "period" directive.)  For
example (format t "~0,0.") puts the cursor in the home position.
(format t "~V,V." x y) puts the cursor at position X, Y.  One problem
with this is that the period character is hard to read on some terminals
and listings.

If period is too hard to read the directive "~:%" might be used instead.
This makes sense because the ~% directive moves the cursor to the next
line.  ~n,m:% moves the cursor to anyplace on the screen.
(3) Clear-Rest-Of-Line.  The directive ~J clears all characters to the
end of the line.  With a precomma argument is clears that many
characters, starting at the cursor.

Alternatively this function could be assigned to "~:&".
This makes sense if one thinks of the fresh-line operation
as being primarilly to put the cursor before a blank line.  The
colon can be treated as suppressing the possible preceeding carrige return.
In my experience these three functions can handle 95% of the screen
manipulations that are needed.  I would also eliminate most of the
waffling in the description of the ~T tabulation directive.  
Implementations should just be required to keep track of where
the cursor is.  For files the implementation should keep track
of how many characters have been output since the last newline.
I can't believe its really that hard.  The directive doesn't
really serve any useful purpose if people can't figure out
what it is going to do.
Each implementation still needs its own way of determining what
type of terminal is being used.

Chris Eliot