original commit: 2972e6749d68cae6816ee284f7452c6b7bf31e1c
This commit is contained in:
Robby Findler 2004-10-24 13:49:26 +00:00
parent 8be44c13fb
commit a060e05a8d
2 changed files with 17 additions and 16 deletions

View File

@ -34,19 +34,18 @@
(define -snip-class% (define -snip-class%
(class snip-class% (class snip-class%
(define/override (read f) (define/override (read f)
(let* ([number (string->number (send f get-string))] (let* ([number (string->number (bytes->string/utf-8 (send f get-bytes)))]
[decimal-prefix (send f get-string)] [decimal-prefix (bytes->string/utf-8 (send f get-bytes))]
[fraction-str (send f get-string)] [fraction-bytes (send f get-bytes)]
[expansions-str (send f get-string)] [expansions (string->number (bytes->string/utf-8 (send f get-bytes)))]
[fraction-view [fraction-view
(cond (cond
[(string=? "#t" fraction-str) 'decimal] [(equal? #"#t" fraction-bytes) 'decimal]
[(string=? "#f" fraction-str) [(equal? #"#f" fraction-bytes)
(preferences:get 'framework:fraction-snip-style)] (preferences:get 'framework:fraction-snip-style)]
[(string=? "mixed" fraction-str) 'mixed] [(equal? #"mixed" fraction-bytes) 'mixed]
[(string=? "decimal" fraction-str) 'decimal] [(equal? #"decimal" fraction-bytes) 'decimal]
[(string=? "improper" fraction-str) 'improper])] [(equal? #"improper" fraction-bytes) 'improper])]
[expansions (string->number expansions-str)]
[snip [snip
(instantiate number-snip% () (instantiate number-snip% ()
[number number] [number number]
@ -54,7 +53,7 @@
(send snip iterate (max 0 (- expansions 1))) ;; one iteration is automatic (send snip iterate (max 0 (- expansions 1))) ;; one iteration is automatic
(send snip set-fraction-view fraction-view) (send snip set-fraction-view fraction-view)
snip)) snip))
(super-instantiate ()))) (super-new)))
(define number-snipclass (new -snip-class%)) (define number-snipclass (new -snip-class%))
(send number-snipclass set-version 3) (send number-snipclass set-version 3)
@ -319,10 +318,10 @@
dens)])])) dens)])]))
(define/override (write f) (define/override (write f)
(send f put (number->string number)) (send f put (string->bytes/utf-8 (number->string number)))
(send f put decimal-prefix) (send f put (string->bytes/utf-8 decimal-prefix))
(send f put (format "~a" fraction-view)) (send f put (string->bytes/utf-8 (format "~a" fraction-view)))
(send f put (number->string expansions))) (send f put (string->bytes/utf-8 (number->string expansions))))
(define/override (copy) (define/override (copy)
(let ([snip (instantiate number-snip% () (let ([snip (instantiate number-snip% ()

View File

@ -1468,7 +1468,9 @@ WARNING: printf is rebound in the body of the unit to always
(channel-put-evt (channel-put-evt
resp-chan resp-chan
(lambda (src line col pos) (lambda (src line col pos)
nth))])))] (if (is-a? nth readable-snip<%>)
(send nth read-special src line col pos)
nth)))])))]
[else [else
#f])])) #f])]))