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

streams to common lisp windows.

Well, I HAVE succeeded in implementing a function that will return
the READ of a window. It is truly ugly but it works. The essential
steps are:
catch :exit
event-case to capture keycodes (NOT ascii)
 when :key-press
  convert key to ascii
  when key is of type character
   concat to buffer
   if key is a constituent char
    then exit event-case
    else continue event-case
event-case to throw away the key event (discard-p t)
condition-case (with-input-from-string (s buffer) (setq result (read s)))
 on simple-condition-error (setq result :fail)
unless (eq result :fail) (throw :exit result)

 essentially, i capture each key-press event, convert it to ascii,
and if it is an ascii character I add it to the buffer. The constituent
character check is there to wait until there is some terminating input
character before calling READ (else 376 is returned as 3 (read succeeds
 next, i have to throw away the key-press event from the event queue
since it was requeued by exiting the first event-case
 then, i use the condition system to keep READ safe from errors and
attempt a READ on the buffer. If READ succeeds (it might be reading
a partial list and fail) then I return the result, else I continue.

 I understand that this is incredibly clanky but X-Windows wants me
to write my program as an EVENT-CASE structure and other window
systems will allow READs to windows. My code is designed to port
to other window systems.

One (flame-like) comment: X-Windows is designed as a policy-free
window system but it strongly constrains the designs of programs
that use it. Methinks this might need discussion.


IBM T.J.Watson Research Center
Yorktown Heights, N.Y. 10598