Typesetting now recognizes carets (^) in the underscore component of a
non-terminal reference, applying the non-terminal-superscript-style to the text following the caret. svn: r17801
This commit is contained in:
parent
f71ff300b2
commit
bbc654c69e
|
@ -59,6 +59,7 @@
|
||||||
[default-style (parameter/c text-style/c)]
|
[default-style (parameter/c text-style/c)]
|
||||||
[non-terminal-style (parameter/c text-style/c)]
|
[non-terminal-style (parameter/c text-style/c)]
|
||||||
[non-terminal-subscript-style (parameter/c text-style/c)]
|
[non-terminal-subscript-style (parameter/c text-style/c)]
|
||||||
|
[non-terminal-superscript-style (parameter/c text-style/c)]
|
||||||
[linebreaks (parameter/c (or/c false/c (listof boolean?)))]
|
[linebreaks (parameter/c (or/c false/c (listof boolean?)))]
|
||||||
[curly-quotes-for-strings (parameter/c boolean?)]
|
[curly-quotes-for-strings (parameter/c boolean?)]
|
||||||
[white-bracket-sizing (parameter/c
|
[white-bracket-sizing (parameter/c
|
||||||
|
|
|
@ -159,5 +159,9 @@
|
||||||
;; make sure two metafunctions simultaneously rewritten line up properly
|
;; make sure two metafunctions simultaneously rewritten line up properly
|
||||||
(test (render-metafunctions S T TL) "metafunctions-multiple.png")
|
(test (render-metafunctions S T TL) "metafunctions-multiple.png")
|
||||||
|
|
||||||
|
;; Non-terminal superscripts
|
||||||
|
(test (render-lw lang (to-lw (x_^abcdef x_q^abcdef)))
|
||||||
|
"superscripts.png")
|
||||||
|
|
||||||
(printf "bitmap-test.ss: ")
|
(printf "bitmap-test.ss: ")
|
||||||
(done)
|
(done)
|
||||||
|
|
BIN
collects/redex/private/bmps-macosx/superscripts.png
Normal file
BIN
collects/redex/private/bmps-macosx/superscripts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 944 B |
|
@ -7,6 +7,7 @@
|
||||||
texpict/utils
|
texpict/utils
|
||||||
texpict/mrpict
|
texpict/mrpict
|
||||||
|
|
||||||
|
scheme/match
|
||||||
scheme/gui/base
|
scheme/gui/base
|
||||||
scheme/class)
|
scheme/class)
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
label-style
|
label-style
|
||||||
non-terminal-style
|
non-terminal-style
|
||||||
non-terminal-subscript-style
|
non-terminal-subscript-style
|
||||||
|
non-terminal-superscript-style
|
||||||
label-font-size
|
label-font-size
|
||||||
default-font-size
|
default-font-size
|
||||||
metafunction-font-size
|
metafunction-font-size
|
||||||
|
@ -688,18 +690,15 @@
|
||||||
'modern
|
'modern
|
||||||
(default-font-size)))))]
|
(default-font-size)))))]
|
||||||
[(and (symbol? atom)
|
[(and (symbol? atom)
|
||||||
(regexp-match #rx"^([^_]*)_(.*)$" (symbol->string atom)))
|
(regexp-match #rx"^([^_^]*)_([^^]*)\\^?(.*)$" (symbol->string atom)))
|
||||||
=>
|
=>
|
||||||
(λ (m)
|
(match-lambda
|
||||||
(let* ([first-part (cadr m)]
|
[(list _ nt sub sup)
|
||||||
[second-part (caddr m)]
|
(let* ([sub-pict (basic-text sub (non-terminal-subscript-style))]
|
||||||
[first-span (- span (string-length first-part))])
|
[sup-pict (basic-text sup (non-terminal-superscript-style))]
|
||||||
(list
|
[sub+sup (lbl-superimpose sub-pict sup-pict)])
|
||||||
(non-terminal->token col first-span first-part)
|
(list (non-terminal->token col span nt)
|
||||||
(make-string-token (+ col first-span)
|
(make-pict-token (+ col span) 0 sub+sup)))])]
|
||||||
(- span first-span)
|
|
||||||
second-part
|
|
||||||
(non-terminal-subscript-style)))))]
|
|
||||||
[(or (memq atom all-nts)
|
[(or (memq atom all-nts)
|
||||||
(memq atom '(number variable variable-except variable-not-otherwise-mentioned)))
|
(memq atom '(number variable variable-except variable-not-otherwise-mentioned)))
|
||||||
(list (non-terminal->token col span (format "~s" atom)))]
|
(list (non-terminal->token col span (format "~s" atom)))]
|
||||||
|
@ -747,6 +746,7 @@
|
||||||
(define (unksc str) (pink-background ((current-text) str 'modern (default-font-size))))
|
(define (unksc str) (pink-background ((current-text) str 'modern (default-font-size))))
|
||||||
(define non-terminal-style (make-parameter '(italic . roman)))
|
(define non-terminal-style (make-parameter '(italic . roman)))
|
||||||
(define non-terminal-subscript-style (make-parameter `(subscript . ,(non-terminal-style))))
|
(define non-terminal-subscript-style (make-parameter `(subscript . ,(non-terminal-style))))
|
||||||
|
(define non-terminal-superscript-style (make-parameter `(superscript . ,(non-terminal-style))))
|
||||||
(define default-style (make-parameter 'roman))
|
(define default-style (make-parameter 'roman))
|
||||||
(define metafunction-style (make-parameter 'swiss))
|
(define metafunction-style (make-parameter 'swiss))
|
||||||
(define (metafunction-text str) ((current-text) str (metafunction-style) (metafunction-font-size)))
|
(define (metafunction-text str) ((current-text) str (metafunction-style) (metafunction-font-size)))
|
||||||
|
|
|
@ -1865,6 +1865,7 @@ cases appear. If it is a list of numbers, then only the selected cases appear (c
|
||||||
@defparam[metafunction-style style text-style/c]{}
|
@defparam[metafunction-style style text-style/c]{}
|
||||||
@defparam[non-terminal-style style text-style/c]{}
|
@defparam[non-terminal-style style text-style/c]{}
|
||||||
@defparam[non-terminal-subscript-style style text-style/c]{}
|
@defparam[non-terminal-subscript-style style text-style/c]{}
|
||||||
|
@defparam[non-terminal-superscript-style style text-style/c]{}
|
||||||
@defparam[default-style style text-style/c]{}]]{
|
@defparam[default-style style text-style/c]{}]]{
|
||||||
|
|
||||||
These parameters determine the font used for various text in
|
These parameters determine the font used for various text in
|
||||||
|
@ -1875,15 +1876,27 @@ useful things it can be is one of the symbols @scheme['roman],
|
||||||
monospaced font, respectively. (It can also encode style
|
monospaced font, respectively. (It can also encode style
|
||||||
information, too.)
|
information, too.)
|
||||||
|
|
||||||
The label-style is used for the reduction rule label
|
The @scheme[label-style] is used for the reduction rule label
|
||||||
names. The literal-style is used for names that aren't
|
names. The @scheme[literal-style] is used for names that aren't
|
||||||
non-terminals that appear in patterns. The
|
non-terminals that appear in patterns. The
|
||||||
metafunction-style is used for the names of
|
@scheme[metafunction-style] is used for the names of
|
||||||
metafunctions. The non-terminal-style is for non-terminals
|
metafunctions.
|
||||||
and non-terminal-subscript-style is used for the portion
|
|
||||||
|
The @scheme[non-terminal-style] is used for the names of non-terminals.
|
||||||
|
Two parameters style the text in the (optional) "underscore" component
|
||||||
|
of a non-terminal reference. The first, @scheme[non-terminal-subscript-style],
|
||||||
|
applies to the segment between the underscore and the first caret (@scheme[^])
|
||||||
|
to follow it; the second, @scheme[non-terminal-superscript-style], applies
|
||||||
|
to the segment following that caret. For example, in the non-terminal
|
||||||
|
reference @scheme[x_y_z], @scheme[x] has style @scheme[non-terminal-style],
|
||||||
|
@scheme[y] has style @scheme[non-terminal-subscript-style], and @scheme[z]
|
||||||
|
has style @scheme[non-terminal-superscript-style].
|
||||||
|
|
||||||
|
The
|
||||||
|
@scheme[non-terminal-subscript-style] is used for the portion
|
||||||
after the underscore in non-terminal references.
|
after the underscore in non-terminal references.
|
||||||
|
|
||||||
The default-style is used for parenthesis, the dot in dotted
|
The @scheme[default-style] is used for parenthesis, the dot in dotted
|
||||||
lists, spaces, the separator words in the grammar, the
|
lists, spaces, the separator words in the grammar, the
|
||||||
"where" and "fresh" in side-conditions, and other places
|
"where" and "fresh" in side-conditions, and other places
|
||||||
where the other parameters aren't used.
|
where the other parameters aren't used.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user