diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-brk.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/page-brk.mkiv | 267 |
1 files changed, 193 insertions, 74 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-brk.mkiv b/Master/texmf-dist/tex/context/base/page-brk.mkiv index ac1fffd6b1c..11dc04bfda5 100644 --- a/Master/texmf-dist/tex/context/base/page-brk.mkiv +++ b/Master/texmf-dist/tex/context/base/page-brk.mkiv @@ -228,7 +228,7 @@ \installpagebreakmethod \v!quadruple % not yet ok inside columnsets {\ifdoublesided - \ifnum\numexpr\realpageno/4\relax=\numexpr\realpageno/2\relax\else + \ifnum\numexpr\realpageno/\plusfour\relax=\numexpr\realpageno/\plustwo\relax\else \page_breaks_handle_direct\v!yes \page_breaks_handle_direct\v!empty \page_breaks_handle_direct\v!empty @@ -316,96 +316,215 @@ %D Test page breaks. -\newdimen \d_page_tests_test -\newconstant\c_page_tests_mode +% \newdimen \d_page_tests_test +% \newconstant\c_page_tests_mode -\newconstant\testpagemethod % todo: \testnewpage[method=,lines=,voffset=] -\newconstant\testpagetrigger +\newconstant\testpagemethod % old +\newconstant\testpagetrigger % old -\unexpanded\def\testpage {\c_page_tests_mode\plusone \dodoubleempty\page_tests_test} % -\unexpanded\def\testpageonly{\c_page_tests_mode\plustwo \dodoubleempty\page_tests_test} % no penalties added to the mvl -\unexpanded\def\testpagesync{\c_page_tests_mode\plusthree\dodoubleempty\page_tests_test} % force sync - -\def\page_tests_test[#1][#2]% don't change, only add more methods +% \unexpanded\def\testpage {\c_page_tests_mode\plusone \dodoubleempty\page_tests_test} % +% \unexpanded\def\testpageonly{\c_page_tests_mode\plustwo \dodoubleempty\page_tests_test} % no penalties added to the mvl +% \unexpanded\def\testpagesync{\c_page_tests_mode\plusthree\dodoubleempty\page_tests_test} % force sync +% +% \def\page_tests_test[#1][#2]% don't change, only add more methods +% {\relax % needed before \if +% \ifconditional\c_page_breaks_enabled +% % new from here +% \ifcase\testpagetrigger +% \endgraf +% \or\ifvmode +% \dosomebreak\allowbreak +% \else % indeed? +% \vadjust{\allowbreak}% +% \endgraf +% \fi\fi +% % till here +% \ifdim\pagegoal<\maxdimen \relax +% \ifdim\pagetotal<\pagegoal \relax +% \d_page_tests_test\dimexpr +% #1\lineheight +% +\pagetotal +% \ifdim\lastskip<\parskip+\parskip\fi +% \ifsecondargument+#2\fi +% \relax +% \ifcase\testpagemethod +% \ifdim\d_page_tests_test>.99\pagegoal +% \penalty-\plustenthousand +% \fi +% \or +% \ifdim\dimexpr\d_page_tests_test-\pagegoal\relax>-\lineheight +% \penalty-\plustenthousand +% \fi +% \or +% \getnoflines\pagegoal +% \ifdim\dimexpr\d_page_tests_test-\noflines\lineheight\relax>-\lineheight +% \penalty-\plustenthousand +% \fi +% \or % same as 0 but more accurate +% \ifdim\dimexpr\d_page_tests_test-10\scaledpoint\relax>\pagegoal +% \penalty-\plustenthousand +% \fi +% \fi +% \else\ifnum\c_page_tests_mode=\plusthree +% \page_tests_flush_so_far +% \fi\fi +% \else\ifnum\c_page_tests_mode=\plusone +% \goodbreak +% \fi\fi +% \else +% \endgraf +% \fi} +% +% \def\page_tests_flush_so_far +% {\endgraf +% \ifdim\pagetotal>\pagegoal +% \ifdim\dimexpr\pagetotal-\pageshrink\relax>\pagegoal +% \goodbreak +% \else +% \page +% \fi +% \fi} + +\installcorenamespace {pagechecker} +\installcorenamespace {pagecheckermethod} + +\installcommandhandler \??pagechecker {pagechecker} \??pagechecker + +\setuppagechecker + [\c!method=1, + \c!before=, + \c!after=, + \c!inbetween=, + \c!lines=\plusthree, + \c!offset=\zeropoint] + +\def\page_check_amount + {\dimexpr + \pagecheckerparameter\c!lines\lineheight + +\pagetotal + \ifdim\lastskip<\parskip+\parskip\fi + +\pagecheckerparameter\c!offset + \relax} + +\unexpanded\def\checkpage + {\dodoubleempty\page_check} + +\def\page_check[#1][#2]% {\relax % needed before \if + \endgraf \ifconditional\c_page_breaks_enabled - % new from here - \ifcase\testpagetrigger - \endgraf - \or\ifvmode - \dosomebreak\allowbreak - \else % indeed? - \vadjust{\allowbreak}% - \endgraf - \fi\fi - % till here - \ifdim\pagegoal<\maxdimen \relax - \ifdim\pagetotal<\pagegoal \relax - \d_page_tests_test\dimexpr - #1\lineheight - +\pagetotal - \ifdim\lastskip<\parskip+\parskip\fi - \ifsecondargument+#2\fi - \relax - \ifcase\testpagemethod - \ifdim\d_page_tests_test>.99\pagegoal - \penalty-\plustenthousand - \fi - \or - \ifdim\dimexpr\d_page_tests_test-\pagegoal\relax>-\lineheight - \penalty-\plustenthousand - \fi - \or - \getnoflines\pagegoal - \ifdim\dimexpr\d_page_tests_test-\noflines\lineheight\relax>-\lineheight - \penalty-\plustenthousand - \fi - \or % same as 0 but more accurate - \ifdim\dimexpr\d_page_tests_test-10\scaledpoint\relax>\pagegoal - \penalty-\plustenthousand - \fi - \fi - \else\ifnum\c_page_tests_mode=\plusthree - \page_tests_flush_so_far - \fi\fi - \else\ifnum\c_page_tests_mode=\plusone - \goodbreak - \fi\fi + \begingroup + \edef\currentpagechecker{#1}% + \ifsecondargument\setupcurrentpagechecker[#2]\fi + \csname\??pagecheckermethod\pagecheckerparameter\c!method\endcsname + \endgroup + \fi} + +\setvalue{\??pagecheckermethod 0}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \ifdim\page_check_amount>.99\pagegoal + \pagecheckerparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi \else - \endgraf + \pagecheckerparameter\c!inbetween \fi} -\def\page_tests_flush_so_far - {\endgraf - \ifdim\pagetotal>\pagegoal - \ifdim\dimexpr\pagetotal-\pageshrink\relax>\pagegoal - \goodbreak +\setvalue{\??pagecheckermethod 1}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \ifdim\dimexpr\page_check_amount-\pagegoal\relax>-\lineheight + \pagecheckerparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi \else - \page + \pagecheckerparameter\c!inbetween \fi + \else + \goodbreak + \pagecheckerparameter\c!inbetween \fi} +\setvalue{\??pagecheckermethod 2}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \getnoflines\pagegoal + \ifdim\dimexpr\page_check_amount-\noflines\lineheight\relax>-\lineheight + \pagecheckparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \pagecheckerparameter\c!inbetween + \fi} + +\setvalue{\??pagecheckermethod 3}% + {\ifdim\pagegoal<\maxdimen \relax + \ifdim\pagetotal<\pagegoal \relax + \ifdim\dimexpr\page_check_amount-10\scaledpoint\relax>\pagegoal + \pagecheckerparameter\c!before + \penalty-\plustenthousand + \pagecheckerparameter\c!after + \else + \pagecheckerparameter\c!inbetween + \fi + \else + \ifdim\pagetotal>\pagegoal + \ifdim\dimexpr\pagetotal-\pageshrink\relax>\pagegoal + \goodbreak + \pagecheckerparameter\c!inbetween + \else + \pagecheckerparameter\c!before + \page + \pagecheckerparameter\c!after + \fi + \else + \pagecheckerparameter\c!inbetween + \fi + \fi + \else + \pagecheckerparameter\c!inbetween + \fi} + +\definepagechecker[\s!unknown:0] [\c!method=0,\c!before=,\c!after=,\c!inbetween=] +\definepagechecker[\s!unknown:1][\s!unknown:0][\c!method=1] +\definepagechecker[\s!unknown:2][\s!unknown:0][\c!method=2] +\definepagechecker[\s!unknown:3][\s!unknown:0][\c!method=3] + +\def\page_tests_test_a[#1][#2]{\normalexpanded{\checkpage[\s!unknown:1][\c!lines=#1,\c!offset=\ifsecondargument#2\else\zeropoint\fi]}} +\def\page_tests_test_b[#1][#2]{\normalexpanded{\checkpage[\s!unknown:2][\c!lines=#1,\c!offset=\ifsecondargument#2\else\zeropoint\fi]}} +\def\page_tests_test_c[#1][#2]{\normalexpanded{\checkpage[\s!unknown:3][\c!lines=#1,\c!offset=\ifsecondargument#2\else\zeropoint\fi]}} + +\unexpanded\def\testpage {\dodoubleempty\page_tests_test_a} % +\unexpanded\def\testpageonly{\dodoubleempty\page_tests_test_b} % no penalties added to the mvl +\unexpanded\def\testpagesync{\dodoubleempty\page_tests_test_c} % force sync + %D Test column breaks. -\def\testcolumn +\unexpanded\def\testcolumn {\dodoubleempty\page_tests_columns_test} \def\page_tests_columns_test[#1][#2]% - {\endgraf - \ifdim\pagegoal<\maxdimen - \ifdim\pagetotal<\pagegoal - \d_page_tests_test\dimexpr - \pagegoal - -\pagetotal - \ifdim\lastskip<\parskip+\parskip\fi - \ifsecondargument+#2\fi - \relax - \getrawnoflines\d_page_tests_test % (raw) - \ifnum#1>\noflines - \column - \fi + {\ifdefined\page_otr_command_test_column + \ifsecondargument + \page_otr_command_test_column[#1][#2]% \else - \penalty-\plustenthousand % (untested) + \page_otr_command_test_column[#1][\zeropoint]% \fi \fi} |