Subject: [clisp-list] ext:with-keyboard question

From: [email-masked]
Date: Mon Jul 12 14:41:00 2004

I thought to try to make a screen using the screen package. The 
documentation says to use ext:with-keyboard for input. I'm trying to write a 
simple menu system with the following code: 

(setf *main-win* (screen:make-window))
(setf *cust-name* "CST")
(setf menu-x 20)
(screen:clear-window *main-win*)
(screen:set-window-cursor-position *main-win* 0 31)
(format *main-win* "M A I N   M E N U")
(screen:set-window-cursor-position *main-win* 1 38)
(format *main-win* "~a" *cust-name*)
(screen:set-window-cursor-position *main-win* 3 menu-x)
(format *main-win* "1. Add traffic source")
(screen:set-window-cursor-position *main-win* 4 menu-x)
(format *main-win* "2. Remove traffic source")
(screen:set-window-cursor-position *main-win* 5 menu-x)
(format *main-win* "3. Toggle bill cycle process flag")
(screen:set-window-cursor-position *main-win* 6 menu-x)
(format *main-win* "4. Toggle customer has traffic flag [~a]" "true") 

(do () (nil)
 (ext:with-keyboard .
   (cond ((string= "q" (read ext:*keyboard-input*))
	   (return))
	  ((string= "Q" (read ext:*keyboard-input*))
	   (return))))) 

however, I'm getting the error:
*** - SYSTEM::%EXPAND-FORM: (STRING= "q" (READ *KEYBOARD-INPUT*)) should be 
a lambda expression 

Can someone help me out with how this should be coded or maybe some 
documentation to read?  (I've been using 
http://clisp.cons.org/impnotes/terminal.html and 
http://clisp.cons.org/impnotes/screen.html for reference) 

Thanks,
 -- Jeff

---

From: Sam Steingold <[email-masked]>
Date: Mon Jul 12 15:09:17 2004

> *  <[email-masked]> [2004-07-12 16:32:31 -0500]:
>
>  (ext:with-keyboard .

try

  (ext:with-keyboard
 	   (return))))

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Profanity is the one language all programmers know best.

---

From: [email-masked]
Date: Tue Jul 13 14:23:02 2004

>  	  ((string= "Q" (read ext:*keyboard-input*))

I have changed the code to this: 

(ext:with-keyboard
   (cond ((char= #\q (read-char ext:*keyboard-input*))
	   (return))
	  ((char= #\Q (read-char ext:*keyboard-input*))
	   (return)))) 

Which doesn't really work either since (read-char ext:*keyboard-input*) 
returns this: 

#S(SYSTEM::INPUT-CHARACTER :CHAR #\q :BITS 0 :FONT 0 :KEY NIL) 

which I don't know how to parse correctly. It looks like I should be able to 
query the response to get the :CHAR out, but I can't find anything in the 
documentation that tells me how to do that. There are methods to get the 
bits and the font, but not the char or the key as far as I can tell. Perhaps 
I'm not reading the part of the documentation? 

Can anyone direct me/teach me the right right thing to do here? 

Thanks for all the help! It is much appreciated. :) 

Jeff

---

From: Sam Steingold <[email-masked]>
Date: Tue Jul 13 15:50:02 2004

> *  <[email-masked]> [2004-07-13 16:14:25 -0500]:
>
> (ext:with-keyboard
> which I don't know how to parse correctly. It looks like I should be
> able to query the response to get the :CHAR out, but I can't find
> anything in the documentation that tells me how to do that. There are
> methods to get the bits and the font, but not the char or the key as
> far as I can tell. Perhaps I'm not reading the part of the
> documentation?

SYS::INPUT-CHARACTER-CHAR will definitely get you #\q out of the
SYSTEM::INPUT-CHARACTER struct.

I am not sure why it (or something similat) is not exported.
(I would think that #'CHARACTER would coerce a SYSTEM::INPUT-CHARACTER
to a CHARACTER by taking the :CHAR slot).

Same for the :KEY.

Bruno?

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Only the mediocre are always at their best.