added current-pretty-printer

This commit is contained in:
Robby Findler 2010-09-16 13:08:21 -05:00
parent e0bda30738
commit 28a253b206
5 changed files with 31 additions and 12 deletions

View File

@ -98,5 +98,12 @@
[initial-font-size (parameter/c number?)] [initial-font-size (parameter/c number?)]
[initial-char-width (parameter/c (or/c number? (-> any/c number?)))]) [initial-char-width (parameter/c (or/c number? (-> any/c number?)))])
(provide reduction-steps-cutoff (provide/contract
default-pretty-printer) [reduction-steps-cutoff (parameter/c exact-nonnegative-integer?)]
[default-pretty-printer
(-> any/c output-port? exact-nonnegative-integer? (is-a?/c text%)
void?)]
[current-pretty-printer
(parameter/c
(-> any/c output-port? exact-nonnegative-integer? (is-a?/c text%)
void?))])

View File

@ -9,6 +9,7 @@
size-editor-snip% size-editor-snip%
size-text% size-text%
default-pretty-printer default-pretty-printer
current-pretty-printer
initial-char-width initial-char-width
resizing-pasteboard-mixin resizing-pasteboard-mixin
get-user-char-width) get-user-char-width)
@ -38,6 +39,8 @@
(display ",'hole" op)]))]) (display ",'hole" op)]))])
(pretty-print v port))) (pretty-print v port)))
(define current-pretty-printer (make-parameter default-pretty-printer))
(define reflowing-snip<%> (define reflowing-snip<%>
(interface () (interface ()
reflow-program)) reflow-program))

View File

@ -50,10 +50,10 @@ todo:
(define updown-label (pick-label "" "^")) (define updown-label (pick-label "" "^"))
(define back-label (pick-label "" "<-")) (define back-label (pick-label "" "<-"))
(define (stepper red term [pp default-pretty-printer]) (define (stepper red term [pp (current-pretty-printer)])
(stepper/seed red (list term) pp)) (stepper/seed red (list term) pp))
(define (stepper/seed red seed [pp default-pretty-printer]) (define (stepper/seed red seed [pp (current-pretty-printer)])
(define term (car seed)) (define term (car seed))
;; all-nodes-ht : hash[sexp -o> (is-a/c node%)] ;; all-nodes-ht : hash[sexp -o> (is-a/c node%)]
(define all-nodes-ht (make-hash)) (define all-nodes-ht (make-hash))

View File

@ -130,7 +130,7 @@
(define (traces/ps reductions pre-exprs filename (define (traces/ps reductions pre-exprs filename
#:multiple? [multiple? #f] #:multiple? [multiple? #f]
#:pred [pred (λ (x) #t)] #:pred [pred (λ (x) #t)]
#:pp [pp default-pretty-printer] #:pp [pp (current-pretty-printer)]
#:racket-colors? [racket-colors? #t] #:racket-colors? [racket-colors? #t]
#:scheme-colors? [scheme-colors? racket-colors?] #:scheme-colors? [scheme-colors? racket-colors?]
#:colors [colors '()] #:colors [colors '()]
@ -241,7 +241,7 @@
(define (traces reductions pre-exprs (define (traces reductions pre-exprs
#:multiple? [multiple? #f] #:multiple? [multiple? #f]
#:pred [pred (λ (x) #t)] #:pred [pred (λ (x) #t)]
#:pp [pp default-pretty-printer] #:pp [pp (current-pretty-printer)]
#:colors [colors '()] #:colors [colors '()]
#:racket-colors? [racket-colors? #t] #:racket-colors? [racket-colors? #t]
#:scheme-colors? [scheme-colors? racket-colors?] #:scheme-colors? [scheme-colors? racket-colors?]

View File

@ -1458,7 +1458,7 @@ exploring reduction sequences.
[#:pp pp [#:pp pp
(or/c (any -> string) (or/c (any -> string)
(any output-port number (is-a?/c text%) -> void)) (any output-port number (is-a?/c text%) -> void))
default-pretty-printer] (current-pretty-printer)]
[#:colors colors [#:colors colors
(listof (listof
(cons/c string? (cons/c string?
@ -1577,7 +1577,7 @@ inserted into the editor by this library have a
[#:pp pp [#:pp pp
(or/c (any -> string) (or/c (any -> string)
(any output-port number (is-a?/c text%) -> void)) (any output-port number (is-a?/c text%) -> void))
default-pretty-printer] (current-pretty-printer)]
[#:colors colors [#:colors colors
(listof (listof
(cons/c string? (cons/c string?
@ -1607,7 +1607,7 @@ just before the PostScript is created with the graph pasteboard.
[t any/c] [t any/c]
[pp (or/c (any -> string) [pp (or/c (any -> string)
(any output-port number (is-a?/c text%) -> void)) (any output-port number (is-a?/c text%) -> void))
default-pretty-printer]) (current-pretty-printer)])
void?]{ void?]{
This function opens a stepper window for exploring the This function opens a stepper window for exploring the
@ -1622,7 +1622,7 @@ The @racket[pp] argument is the same as to the
[seed (cons/c any/c (listof any/c))] [seed (cons/c any/c (listof any/c))]
[pp (or/c (any -> string) [pp (or/c (any -> string)
(any output-port number (is-a?/c text%) -> void)) (any output-port number (is-a?/c text%) -> void))
default-pretty-printer]) (current-pretty-printer)])
void?]{ void?]{
Like @racket[stepper], this function opens a stepper window, but it Like @racket[stepper], this function opens a stepper window, but it
@ -1748,7 +1748,16 @@ the color used to fill the arrowhead and the text colors control the
color used to draw the label on the edge. color used to draw the label on the edge.
} }
@defproc[(default-pretty-printer [v any] [port output-port] [width number] [text (is-a?/c text%)]) void?]{ @defparam[current-pretty-printer pp (-> any/c
output-port?
exact-nonnegative-integer?
(is-a?/c text%)
void?)]{
A parameter that is used by the graphics tools to render
expressions. Defaults to @racket[default-pretty-printer].
}
@defproc[(default-pretty-printer [v any/c] [port output-port?] [width exact-nonnegative-integer?] [text (is-a?/c text%)]) void?]{
This is the default value of @racket[pp] used by @racket[traces] and This is the default value of @racket[pp] used by @racket[traces] and
@racket[stepper] and it uses @racket[stepper] and it uses