[plt-scheme] [Mred] - syntax coloring in editor canvas
color:text does significantly more than what you write below. It takes
a higher-level spec (namely a lexer spec), and it does the coloring
online in an efficient manner.
FWIW, that's the colorer that drscheme uses for its own code.
Robby
At Thu, 07 Dec 2006 21:05:28 +0100, "jack jack" wrote:
> 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/