clip code and blockquote boxes (sort of fixes #13)

main
Matthew Butterick 6 years ago
parent 1753100d98
commit e6b0efc103

@ -61,6 +61,7 @@ Naming guidelines
border-color-bottom
background-color
clip ; whether box boundary clips its contents
keep-first-lines
keep-last-lines

@ -477,7 +477,18 @@
(box-side (+ right (half bw-right)) bottom (- left (half bw-left)) bottom
(quad-ref first-line 'border-color-bottom) bw-bottom)
(box-side left (+ bottom (half bw-bottom)) left (- top (half bw-top))
(quad-ref first-line 'border-color-left) bw-left))
(quad-ref first-line 'border-color-left) bw-left)
(case (quad-ref first-line 'clip #false)
[(#true "true")
(save doc)
(rect doc left top width height)
(clip doc)]))
(define ((block-draw-end first-line) q doc)
(case (quad-ref first-line 'clip #false)
[(#true "true") (restore doc)])
(when (draw-debug-block?)
(draw-debug q doc "#6c6" "#9c9")))
(define (block-wrap lines)
(define first-line (car lines))
@ -485,6 +496,7 @@
#:to 'nw
#:elems (from-parent lines 'nw)
#:id 'block
#:attrs (quad-attrs first-line)
#:size (delay (pt (pt-x (size first-line)) ;
(+ (for/sum ([line (in-list lines)])
(pt-y (size line)))
@ -492,9 +504,7 @@
(quad-ref first-line 'inset-bottom 0))))
#:shift-elems (pt 0 (+ (quad-ref first-line 'inset-top 0)))
#:draw-start (block-draw-start first-line)
#:draw-end (if (draw-debug-block?)
(λ (q doc) (draw-debug q doc "#6c6" "#9c9"))
void)))
#:draw-end (block-draw-end first-line)))
(define/match (from-parent qs [where #f])
;; doesn't change any positioning. doesn't depend on state. can happen anytime.

@ -32,7 +32,8 @@
(define-tag-function (blockquote attrs exprs)
(qexpr (append '((display "block")
(first-line-indent "0")
(background-color "#eee")
(background-color "#eee")
(clip "true")
(font-family "default-sans") (font-size "10") (line-height "14")
(border-width-top "0.5") (border-color-top "gray") (border-inset-top "8")
(border-width-left "3") (border-color-left "gray") (border-inset-left "20")
@ -83,6 +84,7 @@
line-break))
(qexpr (list* '(display "block") '(background-color "aliceblue")
'(first-line-indent "0")
'(clip "true")
'(font-family "default-mono") '(font-size "11") '(line-height "14")
'(border-inset-top "10")
'(border-width-left "2") '(border-color-left "#669") '(border-inset-left "0")

Loading…
Cancel
Save