From 167fe4bcd50eca77b4715241c52abdf5505bdf5e Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 23 Jun 2016 08:23:32 -0700 Subject: [PATCH] combine break tests --- quad/quad/typeset.rkt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/quad/quad/typeset.rkt b/quad/quad/typeset.rkt index 17ab3ce4..c197d40d 100644 --- a/quad/quad/typeset.rkt +++ b/quad/quad/typeset.rkt @@ -45,14 +45,15 @@ ;; test for overset (before a new bp-k gets set). ;; send break type back through continuation - ;; test tp-horiz with > because no characters exist in the line at the start - [(> (posn-line current-posn) line-width) (last-breakpoint-k 'line-break)] - - ;; test tp-vert with >= because one column impliedly exists at the start - [(>= (posn-col current-posn) col-height) (last-breakpoint-k 'column-break)] - - ;; test page-horiz with >= because one column impliedly exists at the start - [(>= (posn-page current-posn) page-width) (last-breakpoint-k 'page-break)] + ;; we do a combined test to find out the "biggest" break that is needed + ;; order connotes precedence + [(or + ;; test page-horiz with >= because one column impliedly exists at the start + (and (>= (posn-page current-posn) page-width) 'page-break) + ;; test tp-vert with >= because one column impliedly exists at the start + (and (>= (posn-col current-posn) col-height) 'column-break) + ;; test tp-horiz with > because no characters exist in the line at the start + (and (> (posn-line current-posn) line-width) 'line-break)) => last-breakpoint-k] ;; set a new bp-k, or resume after invoking a bp-k ;; bp-k has to be in conditional so it triggers side effect but also forces next branch