|
15 | 15 | repl-output-run |
16 | 16 | repl-output-prompt |
17 | 17 | repl-output-exit |
18 | | - repl-output-value |
19 | | - repl-output-value-special |
20 | 18 | make-repl-output-manager |
21 | 19 | make-repl-output-port |
22 | 20 | make-repl-error-port |
23 | 21 | repl-error-port? |
24 | | - repl-output-print-value?) |
| 22 | + print-images-as-specials?) |
25 | 23 |
|
26 | 24 | ;;; REPL output |
27 | 25 |
|
|
188 | 186 | (port-print-handler out (make-value-pipe-handler)) |
189 | 187 | out) |
190 | 188 |
|
191 | | -;; A flag for our global-port-print-handler (see print.rkt) that it's |
192 | | -;; being used for a REPL output port and that it should convert |
193 | | -;; images (which isn't appropriate to do for ports generally). |
194 | | -(define repl-output-print-value? (make-parameter #f)) |
| 189 | +;; A flag set by the port-print-handler for our repl-output-port. |
| 190 | +;; Intended for use by our global-port-print-handler (see print.rkt). |
| 191 | +;; When true, use racket/convert to write-special image values as |
| 192 | +;; (cons 'image image-file-path-name) -- which obviously isn't |
| 193 | +;; appropriate to do for ports generally. |
| 194 | +(define print-images-as-specials? (make-parameter #f)) |
195 | 195 |
|
196 | 196 | ;; We want to avoid many calls to repl-output-value with short |
197 | 197 | ;; strings. This can happen for example with pretty-print, which does |
|
213 | 213 | ;; print handler does pretty printing. |
214 | 214 | (define outermost? (make-parameter #t)) |
215 | 215 | (define-values (pin pout) (make-value-pipe)) |
216 | | - (define (handler v _out [depth 0]) |
| 216 | + (define (racket-repl-output-port-handler v _out [depth 0]) |
217 | 217 | (parameterize ([outermost? #f] |
218 | | - [repl-output-print-value? #t]) |
| 218 | + [print-images-as-specials? #t]) |
219 | 219 | (match (convert-image v #:remove-from-cache? #t) |
220 | 220 | [(cons path-name _pixel-width) |
221 | 221 | (write-special (cons 'image path-name) pout)] |
|
224 | 224 | (when (outermost?) |
225 | 225 | (drain-value-pipe pin pout) |
226 | 226 | (set!-values (pin pout) (make-value-pipe)))) |
227 | | - handler) |
| 227 | + racket-repl-output-port-handler) |
228 | 228 |
|
229 | 229 | (define (make-value-pipe) |
230 | 230 | (make-pipe-with-specials)) |
|
0 commit comments