From eb98ab58cb48980779525bcbe25a3f0a04c77266 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 22 Jun 2013 00:45:18 -0500 Subject: [PATCH] add 'horizontal-side-conditions-same-line style to rule-pict-style --- pkgs/redex/pict.rkt | 11 ++++++----- pkgs/redex/private/pict.rkt | 24 ++++++++++++++++-------- pkgs/redex/scribblings/ref.scrbl | 15 +++++++++------ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/pkgs/redex/pict.rkt b/pkgs/redex/pict.rkt index 367227779b..64931ce3de 100644 --- a/pkgs/redex/pict.rkt +++ b/pkgs/redex/pict.rkt @@ -8,11 +8,12 @@ texpict/mrpict) (define reduction-rule-style/c - (symbols 'compact-vertical - 'vertical - 'vertical-overlapping-side-conditions - 'horizontal-left-align - 'horizontal)) + (or/c 'vertical + 'compact-vertical + 'vertical-overlapping-side-conditions + 'horizontal + 'horizontal-left-align + 'horizontal-side-conditions-same-line)) (provide reduction-rule-style/c render-term term->pict term->pict/pretty-write diff --git a/pkgs/redex/private/pict.rkt b/pkgs/redex/private/pict.rkt index ac9fdfad77..1068abff32 100644 --- a/pkgs/redex/private/pict.rkt +++ b/pkgs/redex/private/pict.rkt @@ -179,7 +179,7 @@ (define current-label-extra-space (make-parameter 0)) (define reduction-relation-rule-separation (make-parameter 4)) -(define ((rule-picts->pict/horizontal left-column-align) rps) +(define ((rule-picts->pict/horizontal left-column-align side-conditions-same-line?) rps) (let* ([sep 2] [max-rhs (apply max 0 @@ -208,11 +208,17 @@ [label (hbl-append (blank (label-space) 0) (rp->pict-label rp))] [sep (blank 4)]) (append - (list lhs arrow rhs label - (blank) (blank) - (let ([sc (rp->side-condition-pict rp max-w)]) - (inset sc (min 0 (- max-rhs (pict-width sc))) 0 0 0)) - (blank)) + (if side-conditions-same-line? + (list lhs arrow + (hbl-append rhs + (let ([sc (rp->side-condition-pict rp max-w)]) + (inset sc (min 0 (- max-rhs (pict-width sc))) 0 0 0))) + label) + (list lhs arrow rhs label + (blank) (blank) + (let ([sc (rp->side-condition-pict rp max-w)]) + (inset sc (min 0 (- max-rhs (pict-width sc))) 0 0 0)) + (blank))) (if (= len i) '() (list sep (blank) (blank) (blank)))))))) @@ -425,9 +431,11 @@ [(vertical-overlapping-side-conditions) rule-picts->pict/vertical-overlapping-side-conditions] [(horizontal-left-align) - (rule-picts->pict/horizontal ltl-superimpose)] + (rule-picts->pict/horizontal ltl-superimpose #f)] + [(horizontal-side-conditions-same-line) + (rule-picts->pict/horizontal rtl-superimpose #t)] [else ;; horizontal - (rule-picts->pict/horizontal rtl-superimpose)])) + (rule-picts->pict/horizontal rtl-superimpose #f)])) (define (mk-arrow-pict sz style) (let ([cache (make-hash)]) diff --git a/pkgs/redex/scribblings/ref.scrbl b/pkgs/redex/scribblings/ref.scrbl index 6585b8861e..d35959436f 100644 --- a/pkgs/redex/scribblings/ref.scrbl +++ b/pkgs/redex/scribblings/ref.scrbl @@ -2803,7 +2803,9 @@ variant, the side-conditions don't contribute to the width of the pict, but are just overlaid on the second line of each rule. The @racket['horizontal-left-align] style is like the @racket['horizontal] style, but the left-hand sides of the rules are aligned on the left, -instead of on the right. +instead of on the right. The @racket[''horizontal-side-conditions-same-line] +is like @racket['horizontal], except that side-conditions +are on the same lines as the rule, instead of on their own line below. } @@ -2811,11 +2813,12 @@ instead of on the right. A contract equivalent to -@racketblock[ -(symbols 'vertical - 'compact-vertical - 'vertical-overlapping-side-conditions - 'horizontal) +@racketblock[(or/c 'vertical + 'compact-vertical + 'vertical-overlapping-side-conditions + 'horizontal + 'horizontal-left-align + 'horizontal-side-conditions-same-line) ]} @defparam[arrow-space space natural-number/c]{