text% printer recognizes a line containing only a form-feed character and uses it as a page break; a form-feed character displays as ^L

original commit: 92a410687731200c8167b29bdcefb7f86c2ead3f
This commit is contained in:
Matthew Flatt 2010-05-11 09:37:08 -06:00
commit b95d39c847

View File

@ -5430,6 +5430,14 @@
(set! write-locked? wl?)
(set! flow-locked? fl?))))
(define/private (new-page-line? line)
(let ([len (mline-len line)])
(and (<= 1 len 2)
(let* ([pos (mline-get-position line)]
[s (get-text pos (+ pos len))])
(or (equal? s "\f")
(equal? s "\f\n"))))))
(define/private (has/print-page dc page print?)
(if flow-locked?
#f
@ -5463,15 +5471,25 @@
[next-h 0.0])
(let loop ([h h]
[i i]
[line line])
(if (or (zero? h)
[line line]
[can-continue? #t]
[unline 0.0])
(cond
[(or (zero? h)
(and (i . < . num-valid-lines)
((mline-h line) . < . (- H h))))
(loop (+ h (mline-h line))
((mline-h line) . < . (- H h))
can-continue?))
(let ([lh (mline-h line)]
[new-page? (new-page-line? line)])
(loop (+ h lh)
(add1 i)
(mline-next line))
(mline-next line)
(not new-page?)
(if new-page? lh unline)))]
[else
(let-values ([(h i line)
(if (and (h . < . H)
(cond
[(and (h . < . H)
(i . < . num-valid-lines)
((mline-h line) . > . H))
;; we'll have to break it up anyway; start now?
@ -5482,8 +5500,9 @@
(values (+ h (mline-h line))
(add1 i)
(mline-next line))
(values h i line)))
(values h i line))])
(values h i line)))]
[else
(values h i line)])])
(let-values ([(next-h h)
(if (h . > . H)
;; only happens if we have something that's too big to fit on a page;
@ -5504,7 +5523,7 @@
(send dc start-page))
(do-redraw dc
(+ y (if (zero? i) 0 1))
(+ y (- h 1))
(+ y (- h 1 unline))
0 W (+ (- y) vm) hm
'no-caret #f #f)
(when (negative? page)
@ -5515,7 +5534,7 @@
line
(+ y h)
next-h
i)))))))))))))))
i))))])))))))))))
(define/override (do-has-print-page? dc page)
(has/print-page dc page #f))