[plt-scheme] [Mred] - syntax coloring in editor canvas

From: jack jack (jack4746 at hotmail.com)
Date: Thu Dec 7 15:05:28 EST 2006

Here is what i got before viewing Framework GUI manual.
For the moment i used a button, but like you said, i could make the same 
using after-insert.

;; changes style of the given word
(define (button_fonc x y)
  (let* ((txt (send Canvas1 get-editor))
         (mot (get-text-from-user "Color Test" "whichword"))
         (start (send txt find-string mot 'forward 0 'eof #t #f))
         (end (send txt find-string mot 'forward 0 'eof #f #f))
         ;(start (send txt get-start-position))
         ;(end (send txt get-end-position))
         (delta (make-object style-delta% )))
    (send delta set-weight-on 'bold)
    (send delta set-delta-foreground (make-object color% 255 0 0) )
    (send txt change-style  delta start end)))


Ok, I said i read the framework GUI (especially the color:text%), but i 
didn't get the main idea of it (i'll retry tomorrow ;)).

What would it bring me more than this code?

Plus, text:color% seems to work with multiple lexeme values on a lexeme 
whereas in the precedent source, i can make it without changing the 
lexer/parser part of my code.

As i said, i might have missed something with text:color% ;)


One more question, let such a definition be:

(define if
   ....)

in my case, define AND if would be colored, whereas only define should be...

Could text:color% do the right job for me? :D

_________________________________________________________________
Les révélations de la starac 6 commentées par Jérémy! 
http://starac2006.spaces.live.com/



Posted on the users mailing list.