[plt-scheme] vi mode and editor questions

From: Veer (diggerrrrr at gmail.com)
Date: Sun Nov 23 02:44:25 EST 2008

Hello,

 Correct me if i am wrong , but this is my understanding :

 If you override default on-char in editor-canvas% and not pass the
event to text% then it
 will not receive the event. In any case text% is derived from object%
and any key
 event has to be passed to it explicitly to it, which is what is done
by default on-char
 method of editor-canvas%.

Key handling Code:

(define (do-char who event)
  (printf
   "~s : Control? ~a  key? ~a\n"
   who (send event get-control-down)
   (send event get-key-code)))

(define frame
  (new frame%
       [label "Key Processing"]
       [width 300] [height 300]))

(define ed%
  (class editor-canvas%
    (super-new)

    (define/override (on-char event)
      (do-char "ed%:on-char :" event)
      (send (send this get-editor) on-char event))

    (define/override (on-subwindow-char receiver event)
      (do-char "ed%:on-subwindow-char :" event)
      #f)))

(define my-text%
  (class text%
    (super-new)
    (define/override (on-default-char event)
      (do-char "my-text%" event))))

(define text-object (new my-text%))
(define my-ed (new ed% [parent frame] [editor text-object]))
(send frame show #t)




On Sun, Nov 23, 2008 at 8:38 AM, Jon Rafkind <workmin at ccs.neu.edu> wrote:
> Robby Findler wrote:
>>
>> On Sat, Nov 22, 2008 at 7:04 PM, Jon Rafkind <workmin at ccs.neu.edu> wrote:
>>
>>>
>>> I don't see the difference between my code and yours except that I'm
>>> using
>>> whatever editor the definitions window uses.
>>>
>>
>> I made a little tool (code below; I added a planet link and an info.ss
>> file so drscheme would find the tool), and I still see the same (ie,
>> good) behavior.
>>
>> Robby
>>
>> #lang scheme/gui
>> (require drscheme/tool)
>>
>> (provide tool@)
>> (define tool@
>>  (unit
>>    (import drscheme:tool^)
>>    (export drscheme:tool-exports^)
>>
>>    (define phase1 void)
>>    (define phase2 void)
>>
>>    (drscheme:get/extend:extend-definitions-text
>>     (λ (t%)
>>       (class t%
>>         (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))))))
>>
>
> I just did an svn update to 4.1.3.1 (before I was using 4.1.2.2) and I have
> nothing in planet except for a link to the code above. I see the behavior
> from before where ctrl-b does not register.
>
> I tried this on my other desktop machine which also runs linux+x11 and
> drscheme 4.1.3.1 with the same behavior.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>

Posted on the users mailing list.