[plt-scheme] Re: What to augment, how to highlight ?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Thu Nov 22 19:04:05 EST 2007

The style list setup is imperative in a kind of non-obvious way.
Here's the code that you want, I think.

Robby

(require (lib "framework.ss" "framework"))

(define t (new text:standard-style-list%))

(let* ((sl (send t get-style-list))
       (std (send (send t get-style-list) find-named-style "Standard"))
       (delta (make-object style-delta%)))
  (send delta set-delta-foreground (make-object color% "red"))
  (send delta get-underlined-on)
  (let ([style (send sl new-named-style "keyword" std)])
    (send style set-delta delta)))

(send t insert "(abc def)")

(send t change-style
      (send (send t get-style-list) find-named-style "keyword")
      0 4)

(define f (new frame% [label ""] [width 400] [height 400]))
(define ec (new editor-canvas% [parent f] [editor t]))
(send f show #t)


On Nov 22, 2007 5:07 PM, Laurent <Ouaibou at gmail.com> wrote:
> I have finally used the color:text% width the start-colorer method.
>
> The start-colorer method needs 3 params. I can use how that :
>
> (send this start-colorer (lambda (s) (format "framework:syntax-
> color:scheme:~a" style)) get-word `()))
>
> Where style is as defined scheme code style like 'keyword,
> constant, ...'.
> However, if i want to use my own style, i must to add style in the
> current text% which inherits from color:text%, like this :
>
> ...
> (let* ((sl (send this get-style-list))
>        (bs (send sl basic-style))
>        (delta (make-object style-delta%)))
>   (send delta set-delta-foreground (make-object color% "red"))
>   (send delta get-underlined-on)
>   (send sl new-named-style "keyword" bs)
>   (send sl find-or-create-style (send sl find-named-style "keyword")
> delta)
>   (send this set-style-list sl))
> ...
>
> (send this start-colorer (lambda (s) "keyword") get-word `()))
>
> My problem is the lambda return value. If i use "keyword" i have no
> error but my text is not colored with the new style.
> Which is the string i must to return in the lambda ?
>
> Thanks,
>
> Kind Regards,
>
> Laurent
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.