[plt-scheme] Snips and styles in text%

From: Robby Findler (robby at cs.uchicago.edu)
Date: Thu Jun 26 20:56:08 EDT 2003

You can do this:

  (define p ... some number ...)
  (define style-delta (make-object style-delta% 'change-weight 'bold))
  (send editor insert snip p p)
  (send editor change-style style-delta)

and the editor's change-style method will create the actual style, as
needed, or you can get the style list and "manually" create the style.
Probably just using change style is easier, however.

Robby

At Fri, 27 Jun 2003 03:51:03 +0000, "Saint Katsmall T. Wise, Esquire" wrote:
> ------------------------------------------------------------------------------
> Matthew Flatt wrote:
> 
> >At Fri, 27 Jun 2003 01:43:56 +0000, "Saint Katsmall T. Wise, Esquire" wrote:
> >  
> >
> >>    (define current-style (send the-style-list basic-style))
> >>[...]
> >>      (send snip set-style current-style)
> >>      (send editor insert snip)
> >>    
> >>
> >
> >The `insert' method converts the snip's style to a style in the
> >editor's style list. (This was not properly documented until recently.)
> >
> >See the `convert' method of style-list<%> for details, but each style
> >list's basic style has the name "basic", and conversion maps a named
> >style to a same-named style. So the snip is getting the "Basic" style
> >of the style list in `editor', which is probably plain.
> >
> >If I'm on track, then you can avoid the problem by creating a nameless
> >style for `current-style'. Then it will get converted the way you
> >expect.
> >
> >Matthew
> >  
> >
> How do you create a nameless style?
> Would you (make-object style%) or something like that?
> 
> Katsmall
> 
> ------------------------------------------------------------------------------
> Matthew Flatt wrote:
> 
> At Fri, 27 Jun 2003 01:43:56 +0000, "Saint Katsmall T. Wise, Esquire" wrote:
> 
>   
> 
>     (define current-style (send the-style-list basic-style))
> 
> [...]
> 
>       (send snip set-style current-style)
> 
>       (send editor insert snip)
> 
>     
> 
> 
> The `insert' method converts the snip's style to a style in the
> 
> editor's style list. (This was not properly documented until recently.)
> 
> 
> 
> See the `convert' method of style-list<%> for details, but each style
> 
> list's basic style has the name "basic", and conversion maps a named
> 
> style to a same-named style. So the snip is getting the "Basic" style
> 
> of the style list in `editor', which is probably plain.
> 
> 
> 
> If I'm on track, then you can avoid the problem by creating a nameless
> 
> style for `current-style'. Then it will get converted the way you
> 
> expect.
> 
> 
> 
> Matthew
> 
>   
> 
> How do you create a nameless style?
> Would you (make-object style%) or something like that?
> Katsmall
> ------------------------------------------------------------------------------



Posted on the users mailing list.