CLX keyboard input, save character code

Discussion of Common Lisp
Post Reply
E_Blackadder
Posts: 4
Joined: Thu Dec 15, 2011 11:30 pm

CLX keyboard input, save character code

Post by E_Blackadder » Thu Dec 15, 2011 11:43 pm

Hello all, my first post here,

To learn a little more of Common Lisp I have spent today trying to write a terminal emulator for Lisp using the CLX library. So far I have most of it working apart from the keyboard (somewhat important for a terminal). I have the :key-press event like:

(:key-press (key) (format t "Key: ~a~%" key))

But every time I press a button I get "Key: NIL" at the REPL, so I was wondering how I can store the character code or character-type generated from pressing a button on the keyboard?

Using SBCL 1.0.49 and FreeBSD

Any help would be greatly appreciated

E_Blackadder

Indecipherable
Posts: 47
Joined: Fri Jun 03, 2011 5:30 am
Location: Behind you.
Contact:

Re: CLX keyboard input, save character code

Post by Indecipherable » Fri Dec 16, 2011 10:47 am

Code: Select all

(char-code #\A) ==> 65
(code-char 65) ==> #\A
If that's what you meant.
Don't take the FUN out of DEFUN !

E_Blackadder
Posts: 4
Joined: Thu Dec 15, 2011 11:30 pm

Re: CLX keyboard input, save character code

Post by E_Blackadder » Fri Dec 16, 2011 2:59 pm

The (char-code) part I have working but when a button is pressed I can't get CLX to return the character code for me to use from the keyboard. Right now if I start my program and press 'a' on the keyboard the :key-event clause just returns NIL. So far the CLX tutorial and documentation hasn't help at all with this. If I can't get a answer from here I think the best place is to look through the McCLIM source code, but thats a reasonably large undertaking I believe, so any help you be great.

E_Blackadder

Post Reply