Adding window clearing and message printing to DandeGUI
I continued working on DandeGUI, a GUI library for Medley Interlisp I'm writing in Common Lisp. I added two new short public functions, GUI:CLEAR-WINDOW
and GUI:PRINT-MESSAGE
, and fixed a bug in some internal code.
GUI:CLEAR-WINDOW
deletes the text of the window associated with the Interlisp TEXTSTREAM
passed as the argument:
(DEFUN CLEAR-WINDOW (STREAM)
"Delete all the text of the window associated with STREAM. Returns STREAM"
(WITH-WRITE-ENABLED (STR STREAM)
(IL:TEDIT.DELETE STR 1 (IL:TEDIT.NCHARS STR)))
STREAM)
It's little more than a call to the TEdit API function IL:TEDIT.DELETE
for deleting text in the editor buffer, wrapped in the internal macro GUI::WITH-WRITE-ENABLED
that establishes a context for write access to a window.
I also wrote GUI:PRINT-MESSAGE
. This function prints a message to the prompt area of the window associated with the TEXTSTREAM
passed as an argument, optionally clearing the area prior to printing. The prompt area is a one-line Interlisp prompt window attached above the title bar of the TEdit window where the editor displays errors and status messages.
(DEFUN PRINT-MESSAGE (STREAM MESSAGE &OPTIONAL DONT-CLEAR-P)
"Print MESSAGE to the prompt area of the window associated with STREAM. If DONT-CLEAR-P is non NIL the area will be cleared first. Returns STREAM."
(IL:TEDIT.PROMPTPRINT STREAM MESSAGE (NOT DONT-CLEAR-P))
STREAM)
GUI:PRINT-MESSAGE
just passes the appropriate arguments to the TEdit API function IL:TEDIT.PROMPTPRINT
which does the actual printing.
The documentation of both functions is in the API reference on the project repo.
Testing DandeGUI revealed that sometimes text wasn't appended to the end but inserted at the beginning of windows. To address the issue I changed GUI::WITH-WRITE-ENABLED
to ensure the file pointer of the stream is set to the end of the file (i.e -1
) prior to passing control to output functions. The fix was to add a call to the Interlisp function IL:SETFILEPTR
:
(IL:SETFILEPTR ,STREAM -1)
#DandeGUI #CommonLisp #Interlisp #Lisp
Discuss... Email | Reply @amoroso@oldbytes.space