[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A couple of I/O questions
- To: clisp-list, haible@ma2s2.mathematik.uni-karlsruhe.de
- Subject: A couple of I/O questions
- From: haible (Bruno Haible)
- Date: Fri, 30 Apr 93 11:10:44 +0200
Peter Dudey asks:
> How do I turn the string "13" into the fixnum 13?
Use READ-FROM-STRING or PARSE-INTEGER.
> Is there any way to move the cursor around the screen ... ?
CLISP contains a fairly portable mini-curses like screen access package.
Here is a documentation of it. (It mentions windows, but only one window
is possible now: the full (virtual) screen.)
99.2. Random Screen Access
--------------------------
(SYSTEM::MAKE-WINDOW)
returns a "window stream". As long as this stream is open, the terminal
is in cbreak/noecho mode. *TERMINAL-IO* shouldn't be used for input or
output during this time. (Use WITH-KEYBOARD and *KEYBOARD-INPUT* instead.)
(SYSTEM::WINDOW-SIZE window-stream)
returns the window's size, as two values:
height (= Ymax+1) and width (= Xmax+1).
(SYSTEM::WINDOW-CURSOR-POSITION window-stream)
returns the position of the cursor in the window, as two values:
line (>=0, <=Ymax, 0 means top), column (>=0, <=Xmax, 0 means left margin).
(SYSTEM::SET-WINDOW-CURSOR-POSITION window-stream line column)
sets the position of the cursor in the window.
(SYSTEM::CLEAR-WINDOW window-stream)
clears the window's contents and puts the cursor in the upper left corner.
(SYSTEM::CLEAR-WINDOW-TO-EOT window-stream)
clears the window's contents from the cursor position to the end of window.
(SYSTEM::CLEAR-WINDOW-TO-EOL window-stream)
clears the window's contents from the cursor position to the end of line.
(SYSTEM::DELETE-WINDOW-LINE window-stream)
removes the cursor's line, moves the lines below it up by one line and
clears the window's last line.
(SYSTEM::INSERT-WINDOW-LINE window-stream)
inserts a line at the cursor's line, moving the lines below it down by
one line.
(SYSTEM::HIGHLIGHT-ON window-stream)
switches highlighted output on.
(SYSTEM::HIGHLIGHT-OFF window-stream)
switches highlighted output off.
(SYSTEM::WINDOW-CURSOR-ON window-stream)
makes the cursor visible, a cursor block in most implementations.
(SYSTEM::WINDOW-CURSOR-OFF window-stream)
makes the cursor invisible, in implementations where this is possible.
I suggest a macro like
(defmacro with-window (&body body)
`(LET ((*WINDOW* (SYS::MAKE-WINDOW)))
(UNWIND-PROTECT (PROGN ,@body) (CLOSE *WINDOW*))
)
)
to ensure that the window stream is closed in all cases.
Bruno Haible
haible@ma2s2.mathematik.uni-karlsruhe.de