From 7f2979ad229065e1e2922386ff70c00253c72fae Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Tue, 4 Feb 2020 14:03:29 -0800 Subject: [PATCH] remove `keep-all-lines` --- quad/quad/scribblings/quad.scrbl | 7 +++---- quad/quadwriter/layout.rkt | 12 ++++++------ quad/quadwriter/tags.rkt | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/quad/quad/scribblings/quad.scrbl b/quad/quad/scribblings/quad.scrbl index 6f2cb10b..65a73d9b 100644 --- a/quad/quad/scribblings/quad.scrbl +++ b/quad/quad/scribblings/quad.scrbl @@ -575,11 +575,10 @@ Vertical space added around a block. Value is a @tech{dimension string}. } @deftogether[(@defthing[#:kind "attribute" keep-first-lines symbol?] - @defthing[#:kind "attribute" keep-last-lines symbol?] - @defthing[#:kind "attribute" keep-all-lines symbol?])]{ -How many lines of the quad are kept together near a page break. @racket[keep-first-lines] sets the minimum number of lines that appear before a page break; @racket[keep-last-lines] sets the minimum number that appear after. In both cases, they take a non-negative integer string as a value. + @defthing[#:kind "attribute" keep-last-lines symbol?])]{ +How many lines of the quad are kept together near a page break. @racket[keep-first-lines] sets the minimum number of lines that appear before a page break; @racket[keep-last-lines] sets the minimum number that appear after. In both cases, they take a non-negative integer string as a value, or @racket["all"]. -@racket[keep-all-lines] keeps all the lines of a quad on the same page. Activated only when value is @racket["true"]. Be careful with this option — it's possible to make a single quad that is longer than one page, in which case @racketmodname[quadwriter] will ignore the setting to prevent an impossible situation. +If the value (of one or both attributes) is @racket["all"], then all the lines of the quad are kept the same page. Be careful with this option — it's possible to make a single quad that is longer than one page, in which case @racketmodname[quadwriter] will ignore the setting to prevent an impossible situation. } @defthing[#:kind "attribute" keep-with-next symbol?]{ diff --git a/quad/quadwriter/layout.rkt b/quad/quadwriter/layout.rkt index d97ab644..7a0520e4 100644 --- a/quad/quadwriter/layout.rkt +++ b/quad/quadwriter/layout.rkt @@ -596,16 +596,16 @@ (define idx (add1 idx0)) ;; always catch last line of block in this case ;; so later cases are guaranteed to have earlier lines. + (define keep-first (quad-ref ln :keep-first-lines)) + (define keep-last (quad-ref ln :keep-last-lines)) (unless (eq? idx group-len) (when (or - ;; if we have :keep-all we can skip :keep-first and :keep-last cases - (quad-ref ln :keep-all-lines) + ;; if we have keep all we can skip :keep-first and :keep-last cases + (or (equal? keep-first "all") (equal? keep-last "all")) ;; to keep n lines, we only paint the first n - 1 ;; (because each nobr line sticks to the next) - (let ([keep-first (quad-ref ln :keep-first-lines)]) - (and (number? keep-first) (< idx keep-first))) - (let ([keep-last (quad-ref ln :keep-last-lines)]) - (and (number? keep-last) (< (- group-len keep-last) idx)))) + (and (number? keep-first) (< idx keep-first)) + (and (number? keep-last) (< (- group-len keep-last) idx))) (make-nobreak! ln))) (cons ln reversed-lines))) diff --git a/quad/quadwriter/tags.rkt b/quad/quadwriter/tags.rkt index 471f48c2..3e2f5d6c 100644 --- a/quad/quadwriter/tags.rkt +++ b/quad/quadwriter/tags.rkt @@ -68,7 +68,7 @@ :inset-bottom "8" :inset-left "30" :inset-right "30" - :keep-all-lines "yes") + :keep-first-lines "all") attrs) exprs)) (define id (default-tag-function 'id))