[plt-scheme] Re: Snips and styles in text%
Oops. I mixed input and output. (because of a similar input text-field%
class)
Saint Katsmall T. Wise, Esquire wrote:
> This is a part of a class I have.
>
> (define text-input-port%
(define text-output-port%
>
> (class object%
> (init-field parent)
> (define editor (instantiate text% ()))
> (define editor-canvas
> (instantiate editor-canvas% ()
> [parent parent]
> [editor editor]))
> (define-pipe (input output))
>
> (define current-style (send the-style-list basic-style))
>
> '...
>
> (define (flush-output)
> (define snip (make-object string-snip% output-buffer))
> (set! output-buffer "")
> (send snip set-style current-style)
> (send editor insert snip)
> (send editor insert "\n"))
>
> '...
>
> (define/public (get-input-port) input)))
(define/public (get-output-port) output)))
>
>
> Now.
> Using style-delta%s it alters current-style according to escape
> characters (found in input).
> Before every change to current-style though, and whenever a newline
> occurs, it calls flush-output which makes a string-snip% object that
> contains all the text that has been stored in cache (all the text
> since last newline or style change), sets snip's style to
> current-style and inserts snip and a newline.
> However, for some reason all the text is the same normal style with no
> change whatsoever.
>
> What could be wrong?
>
> Thanks,
> Katsmall T. Wise, Esquire.
This is just meant to create an output port that links to a text% and
has styles.
Note that it uses a different thread to read from input and put it in
cache (or change the style if it's an escape character or flush if it's
a newline).
Hope it is clearer now,
Katsmall T. Wise, Esquire.