[plt-scheme] vi mode and editor questions

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Sat Nov 22 20:04:23 EST 2008

Robby Findler wrote:
> On Sat, Nov 22, 2008 at 4:32 PM, Jon Rafkind <workmin at ccs.neu.edu> wrote:
>> Oh yea, sorry. So when I press control I get an event that has the key code
>> as 'control'. But shouldn't the get-control-down be #t in this case? What I
>> want is to be able to press ctrl-d and have (get-control-down) be #t and
>> (get-key-code) be #\d.
> When I do the experiment myself (code below) I get what you seem to
> want. I'm on a mac tho, and I don't have a linux machine handy to
> test. So, I'm not sure what the right answer is. Matthew would
> probably know better, but maybe a first step is for you to try the
> below.
> Robby
> #lang scheme/gui
> (define t%
>   (class text%
>     (define/override (on-char evt)
>       (printf "key-code ~s control ~s\n"
>               (send evt get-key-code)
>               (send evt get-control-down))
>       (super on-char evt))
>     (super-new)))
> (define f (new frame% [label ""] [width 200] [height 200]))
> (define t (new t%))
> (define ec (new editor-canvas% [parent f] [editor t]))
> (send ec focus)
> (send f show #t)
That seems to work. When I press ctrl-b I get

key-code control control #f
key-code #\b control #t
key-code release control #t

I don't see the difference between my code and yours except that I'm 
using whatever editor the definitions window uses. Does it handle key 
codes specially? If I hold down 'b' I see my code print 'key code #\b 
control #f' and then if I press control while still holding b, the b 
repeat stops and it says 'key code control control #f'.

Posted on the users mailing list.