[plt-scheme] Snips and styles in text%

From: Saint Katsmall T. Wise, Esquire (kela_bit at netvision.net.il)
Date: Thu Jun 26 21:43:56 EDT 2003

This is a part of a class I have.

(define text-input-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)))

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



Posted on the users mailing list.