Re: Fwd: trapping key in case statement

2017-01-12 Thread dean
Hi Alex
Thank you very much for the explanation.
Best Regards
Dean

On 12 January 2017 at 15:58, Alexander Burger  wrote:

> Hi Dean,
>
> > I can match the (key) value of backspace to BS using 'if' but am not sure
> > how to using 'case'
> >
> > (setq BS "^?")
>
> Note that "^?" is DEL (ASCII 127), mapped to by some keyboard drivers when
> the
> backspace key is pressed.
>
> Backspace (ASCII 8) is "^H".
>
>
> > (setq Key (key))
> > (if (= Key BS) (prinl "yes BS")) #works fine when backspace is pressed
> > (case Key ("a" (prinl "a pressed"))) #works fine when "a" is pressed
> > (case Key (BS (prinl "BS pressed"))) #???
>
> 'case' does not evaluate the clauses. But as the value of BS is constant,
> you
> can use a read macro
>
>(case Key (`BS (prinl "BS pressed")))
>
>
> But better catch both values:
>
>(prinl
>   (case (key)
>  (("^H" "^?") "BS pressed")
>  (T "Other key pressed") ) )
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Fwd: trapping key in case statement

2017-01-12 Thread Alexander Burger
Hi Dean,

> I can match the (key) value of backspace to BS using 'if' but am not sure
> how to using 'case'
> 
> (setq BS "^?")

Note that "^?" is DEL (ASCII 127), mapped to by some keyboard drivers when the
backspace key is pressed.

Backspace (ASCII 8) is "^H".


> (setq Key (key))
> (if (= Key BS) (prinl "yes BS")) #works fine when backspace is pressed
> (case Key ("a" (prinl "a pressed"))) #works fine when "a" is pressed
> (case Key (BS (prinl "BS pressed"))) #???

'case' does not evaluate the clauses. But as the value of BS is constant, you
can use a read macro

   (case Key (`BS (prinl "BS pressed")))


But better catch both values:

   (prinl
  (case (key)
 (("^H" "^?") "BS pressed")
 (T "Other key pressed") ) )

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe