adjust drracket's repl so that it renders convertible things by turning them into .png's.
This commit is contained in:
parent
39629e8e99
commit
2e54a89773
|
@ -25,6 +25,7 @@
|
||||||
mrlib/syntax-browser
|
mrlib/syntax-browser
|
||||||
compiler/distribute
|
compiler/distribute
|
||||||
compiler/bundle-dist
|
compiler/bundle-dist
|
||||||
|
file/convertible
|
||||||
"rep.rkt")
|
"rep.rkt")
|
||||||
|
|
||||||
(import [prefix drracket:debug: drracket:debug^]
|
(import [prefix drracket:debug: drracket:debug^]
|
||||||
|
@ -368,14 +369,7 @@
|
||||||
(exact? x)
|
(exact? x)
|
||||||
(real? x)
|
(real? x)
|
||||||
(not (integer? x))))])
|
(not (integer? x))))])
|
||||||
(parameterize (
|
(parameterize ([pretty-print-pre-print-hook (λ (val port) (void))]
|
||||||
;; these three handlers aren't used, but are set to override the user's settings
|
|
||||||
[pretty-print-print-line (λ (line-number op old-line dest-columns)
|
|
||||||
(when (and (not (equal? line-number 0))
|
|
||||||
(not (equal? dest-columns 'infinity)))
|
|
||||||
(newline op))
|
|
||||||
0)]
|
|
||||||
[pretty-print-pre-print-hook (λ (val port) (void))]
|
|
||||||
[pretty-print-post-print-hook (λ (val port) (void))]
|
[pretty-print-post-print-hook (λ (val port) (void))]
|
||||||
[pretty-print-exact-as-decimal #f]
|
[pretty-print-exact-as-decimal #f]
|
||||||
[pretty-print-depth #f]
|
[pretty-print-depth #f]
|
||||||
|
@ -390,7 +384,7 @@
|
||||||
(not (eq? 0 line)))
|
(not (eq? 0 line)))
|
||||||
(newline port))
|
(newline port))
|
||||||
0)]
|
0)]
|
||||||
|
|
||||||
[pretty-print-columns width]
|
[pretty-print-columns width]
|
||||||
[pretty-print-size-hook
|
[pretty-print-size-hook
|
||||||
(let ([oh (pretty-print-size-hook)])
|
(let ([oh (pretty-print-size-hook)])
|
||||||
|
@ -401,6 +395,7 @@
|
||||||
[(use-number-snip? value) 1]
|
[(use-number-snip? value) 1]
|
||||||
[(syntax? value) 1]
|
[(syntax? value) 1]
|
||||||
[(to-snip-value? value) 1]
|
[(to-snip-value? value) 1]
|
||||||
|
[(convertible? value) 1]
|
||||||
[else (oh value display? port)])))]
|
[else (oh value display? port)])))]
|
||||||
[pretty-print-print-hook
|
[pretty-print-print-hook
|
||||||
(let ([oh (pretty-print-print-hook)])
|
(let ([oh (pretty-print-print-hook)])
|
||||||
|
@ -436,6 +431,15 @@
|
||||||
(write-special (render-syntax/snip value) port)]
|
(write-special (render-syntax/snip value) port)]
|
||||||
[(to-snip-value? value)
|
[(to-snip-value? value)
|
||||||
(write-special (value->snip value) port)]
|
(write-special (value->snip value) port)]
|
||||||
|
[(convertible? value)
|
||||||
|
(define bytes (convert value 'png-bytes #f))
|
||||||
|
(if bytes
|
||||||
|
(write-special
|
||||||
|
(make-object image-snip%
|
||||||
|
(read-bitmap (open-input-bytes bytes)))
|
||||||
|
port)
|
||||||
|
(display (format (if display? "~a" "~s") value)
|
||||||
|
port))]
|
||||||
[else (oh value display? port)])))]
|
[else (oh value display? port)])))]
|
||||||
[print-graph
|
[print-graph
|
||||||
;; only turn on print-graph when using `write' or `print' printing
|
;; only turn on print-graph when using `write' or `print' printing
|
||||||
|
|
|
@ -74,8 +74,6 @@ Icon sizes are given as heights to make it easier to append them horizontally.
|
||||||
In the following example, applying @racket[load-icon] is equivalent to @racket[(plt-logo 100 'diffuse)]:
|
In the following example, applying @racket[load-icon] is equivalent to @racket[(plt-logo 100 'diffuse)]:
|
||||||
@interaction[#:eval icon-eval (load-icon "logo" "plt-logo-diffuse" 100)]
|
@interaction[#:eval icon-eval (load-icon "logo" "plt-logo-diffuse" 100)]
|
||||||
|
|
||||||
(In the interactions window, you would have to send the result of applying @racket[load-icon] to @racket[bitmap] to see it.)
|
|
||||||
|
|
||||||
@doc-apply[icon-categories]{
|
@doc-apply[icon-categories]{
|
||||||
Returns a list of all the icon categories.
|
Returns a list of all the icon categories.
|
||||||
|
|
||||||
|
|
|
@ -920,12 +920,12 @@ This produces an ACK message
|
||||||
(namespace-set-variable-value! 'd (disk 3)))
|
(namespace-set-variable-value! 'd (disk 3)))
|
||||||
'd)
|
'd)
|
||||||
|
|
||||||
("#<pict>"
|
("{image}"
|
||||||
"#<pict>"
|
"{image}"
|
||||||
"#<pict>"
|
"{image}"
|
||||||
"#<pict>"
|
"{image}"
|
||||||
"#<pict>"
|
"{image}"
|
||||||
"#<pict>")
|
"{image}")
|
||||||
'interactions
|
'interactions
|
||||||
#f
|
#f
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user