[plt-scheme] Changing the style of all snips in an editor?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Nov 2 18:16:21 EDT 2007

I think you want this:

(define (change) (send t change-style delta 0 (send t last-position) #f))

the 'start and 'end arguments refer to the position of the selection
(so it was changing just the insertion point in your tests).

Robby

On 11/2/07, Matt Jadud <jadudm at gmail.com> wrote:
> Hi all,
>
> How do I go about changing (say) the font face for all the snips in an editor?
>
> Given the code:
>
> (define f (new frame% (label "Woot") (min-width 200) (min-height 300)))
> (define t (new text%))
> (define ec (new editor-canvas% (parent f) (editor t)
>                 (style '(hide-vscroll hide-hscroll))))
> (send f show #t)
> (define delta (new style-delta%))
> (send delta set-family 'script)
> (define (change) (send t change-style delta 'start 'end #f))
>
> I can type some text into my editor, invoke "change", and then any new
> text entered is in script. However, I'm at a bit of a loss as to how I
> encourage all of the snips in the editor to update their font family
> (for example).
>
> I can ask the editor for the first snip, and iterate through all of
> them, but it isn't clear how I would update the style for each of
> those snips. Or, perhaps that isn't the approved method.
>
> I'm missing something in the documentation here, and have trolled
> around the class hierarchy to think that something obvious might be
> escaping me.
>
> Many thanks,
> Matt
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.