the following I wrote in an e-mail discussion. It might be of general interest:
On Sun, Oct 26, 2014 at 09:07:05PM +0200, Mike Pechkin wrote:
> ... how to read arrow keys ?
Unfortunately this depends on the terminal. If you have an xterm (I
think most terminals on Linux are compatible), you could use
1. You can do it yourself. Read the (key) values like this:
(pack (make (link (key)) (while (key 100) (link @))))
As a result, you can try e.g. (pressing the up-arrow):
: (= *XtUp (pack (make (link (key)) (while (key 100) (link @)))))
2. Start PicoLisp in debug mode (with '+'). Then you have a function
'fkey' defined in "@lib/led.l". You can use it to define keyboard
: (fkey *XtUp (prinl 'UP))
: (fkey *XtDown (prinl 'DOWN))
Now you can use up- and down-arrow in the REPL to have 'prg' bodies
like (prinl 'UP) executed.
Another alternative is not to use arrow keys (or just additionally) and
also allow the "standard" Unix keys 'h', 'j', 'k' and 'l'. I did that
for example in "games/mine.l".
Yes another alternative is not to use keys at all, and allow board
coordinate input like in Chess and Tic-Tac-Toe in "games/".