diff options
author | Hans Hagen <pragma@wxs.nl> | 2019-08-05 11:51:52 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2019-08-05 11:51:52 +0200 |
commit | e92fac1b64f7969cadd8ae60f336c43624250d42 (patch) | |
tree | f44286816267846b1af5f7f8847bcdcd8cbe7991 /tex | |
parent | 3668eb2ecc0f7dcc6c44fd1e971cbe37fa010fd6 (diff) | |
download | context-e92fac1b64f7969cadd8ae60f336c43624250d42.tar.gz |
2019-08-05 10:42:00
Diffstat (limited to 'tex')
32 files changed, 2402 insertions, 472 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 9af34509b..d9c9ca7c4 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2019.08.02 19:40} +\newcontextversion{2019.08.05 10:34} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 83494251a..9e1710245 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.02 19:40} +\edef\contextversion{2019.08.05 10:34} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index da1370aaf..248cf8b18 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -968,9 +968,12 @@ \setinterfaceconstant{menu}{meniu} \setinterfaceconstant{method}{metoda} \setinterfaceconstant{middle}{mijloc} +\setinterfaceconstant{middlecolor}{middlecolor} \setinterfaceconstant{middlecommand}{middlecommand} \setinterfaceconstant{middlespeech}{middlespeech} +\setinterfaceconstant{middlestyle}{middlestyle} \setinterfaceconstant{middletext}{textmijloc} +\setinterfaceconstant{middlewidth}{middlewidth} \setinterfaceconstant{midsentence}{midsentence} \setinterfaceconstant{min}{min} \setinterfaceconstant{mindepth}{mindepth} diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 0665e7235..f35151c93 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2019.08.02 19:40} +\newcontextversion{2019.08.05 10:34} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 79f24bda9..a6d3c7f7b 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.02 19:40} +\edef\contextversion{2019.08.05 10:34} \edef\contextkind {beta} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index 128eddc68..07a53fc2c 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2019.08.02 19:40} +\edef\contextversion{2019.08.05 10:34} \edef\contextkind {beta} %D Kind of special: @@ -60,7 +60,7 @@ %D First we load the system modules. These implement a lot of manipulation macros. %D We start with setting up some basic \TEX\ machinery. -\loadmkxlfile{syst-ini} +\loadmkxlfile{syst-ini} % LMTX %D We just quit if new functionality is expected. @@ -172,10 +172,10 @@ \loadmkxlfile{driv-ini} % LMTX -\loadmkxlfile{back-ini} +\loadmkxlfile{back-ini} % LMTX \loadmarkfile{back-res} \loadmarkfile{back-trf} -\loadmkxlfile{back-out} +\loadmkxlfile{back-out} % LMTX \loadmarkfile{attr-col} \loadmarkfile{attr-lay} @@ -318,7 +318,7 @@ \loadmarkfile{page-one} \loadmarkfile{page-lay} \loadmkvifile{page-box} -\loadmkvifile{page-txt} +\loadmklxfile{page-txt} % LMTX \loadmarkfile{page-sid} % when \loadmkvifile{strc-flt} @@ -331,13 +331,7 @@ %loadmarkfile{page-set} % \usecolumns[old-columnsets] \loadmarkfile{page-cst} \loadmarkfile{page-pcl} % new - -\doifelsefileexists {pack-lyr.mkxl} { - \loadmkxlfile{pack-lyr} % LMTX -} { - \loadmkivfile{pack-lyr} -} - +\loadmkxlfile{pack-lyr} % LMTX \loadmarkfile{pack-pos} \loadmkvifile{page-mak} @@ -463,9 +457,9 @@ \loadmarkfile{prop-ini} % only for downward compatibility -\loadmkxlfile{mlib-ctx} % messy order +\loadmkxlfile{mlib-ctx} % LMTX % messy order -\loadmkxlfile{meta-ini} +\loadmkxlfile{meta-ini} % LMTX \loadmarkfile{meta-tex} \loadmarkfile{meta-fun} \loadmarkfile{meta-pag} @@ -473,7 +467,7 @@ \loadmarkfile{meta-fnt} \loadmarkfile{meta-nod} \loadmarkfile{meta-lua} -\loadmkxlfile{meta-mac} +\loadmkxlfile{meta-mac} % LMTX \loadmarkfile{page-mrk} % depends on mp @@ -579,14 +573,14 @@ % now we hook in backend code (needs checking) -\loadmkxlfile{driv-shp} +\loadmkxlfile{driv-shp} % LMTX \loadmarkfile{back-exp} -\loadmkxlfile{back-pdf} -\loadmkxlfile{back-mps} -\loadmkxlfile{back-lua} +\loadmkxlfile{back-pdf} % LMTX +\loadmkxlfile{back-mps} % LMTX +\loadmkxlfile{back-lua} % LMTX -\loadmarkfile{mlib-pdf} +\loadmkxlfile{mlib-pdf} % LMTX \loadmarkfile{mlib-pps} \loadmarkfile{meta-pdf} \loadmarkfile{meta-blb} @@ -601,8 +595,6 @@ \loadmarkfile{cont-run} % the main runner (used in cont-yes.mkiv) -% \loadmkxlfile{driv-shp} - \appendtoks \setupoutput[pdf] \to \everyjob diff --git a/tex/context/base/mkiv/grph-inc.mkiv b/tex/context/base/mkiv/grph-inc.mkiv index 83681580e..3564347f3 100644 --- a/tex/context/base/mkiv/grph-inc.mkiv +++ b/tex/context/base/mkiv/grph-inc.mkiv @@ -506,29 +506,6 @@ \c!height =\externalfigureparameter\c!height, \c!lines =\externalfigureparameter\c!lines] -% % this will become: -% -% \unexpanded\def\doscalefigure % used at lua end -% {\global\setbox\foundexternalfigure\vbox\bgroup -% \bgroup -% \let\currentscale\currentexternalfigure -% \let\scaleparameter\externalfigureparameter -% \dowithnextboxcs\grph_scale_finish\hbox{\dowithfigure{\box\foundexternalfigure}}% -% \egroup} -% -% % or even better: -% -% \def\grph_scale_inherited#1% -% {\bgroup -% \expandafter\let\expandafter\currentscale \csname current#1\endcsname -% \expandafter\let\expandafter\scaleparameter\csname #1parameter\endcsname -% \dowithnextboxcs\grph_scale_finish\hbox} -% -% \unexpanded\def\doscalefigure % used at lua end -% {\global\setbox\foundexternalfigure\vbox\bgroup -% \grph_scale_inherited{externalfigure}{\dowithfigure{\box\foundexternalfigure}}% -% \egroup} - %D You can register additional suffixes with the following command: %D %D \starttyping diff --git a/tex/context/base/mkiv/meta-imp-dum.mkiv b/tex/context/base/mkiv/meta-imp-dum.mkiv index 457de4b35..74a2de875 100644 --- a/tex/context/base/mkiv/meta-imp-dum.mkiv +++ b/tex/context/base/mkiv/meta-imp-dum.mkiv @@ -13,8 +13,7 @@ \unprotect -%D This library overloads the normal external figure -%D placeholder by a nicer one. +%D This library overloads the normal external figure placeholder by a nicer one. %D %D \startbuffer %D \useMPlibrary[dum] diff --git a/tex/context/base/mkiv/mlib-pdf.mkiv b/tex/context/base/mkiv/mlib-pdf.mkiv index e47df4a99..d251a5145 100644 --- a/tex/context/base/mkiv/mlib-pdf.mkiv +++ b/tex/context/base/mkiv/mlib-pdf.mkiv @@ -13,13 +13,12 @@ \unprotect -% We use bit more code that needed because we want to limit the -% amount of boxing. +%D We use bit more code that needed because we want to limit the amount of boxing. \registerctxluafile{mlib-pdf}{} -%D Some code is shared between MPLIB and MPS. The following variables -%D are also available for introspection and other purposes. +%D Some code is shared between MPLIB and MPS. The following variables are also +%D available for introspection and other purposes. \ifdefined\MPwidth \else \newdimen\MPwidth \fi \ifdefined\MPheight \else \newdimen\MPheight \fi diff --git a/tex/context/base/mkiv/mlib-pdf.mkxl b/tex/context/base/mkiv/mlib-pdf.mkxl new file mode 100644 index 000000000..113dfe129 --- /dev/null +++ b/tex/context/base/mkiv/mlib-pdf.mkxl @@ -0,0 +1,171 @@ +%D \module +%D [ file=mlib-pdf, +%D version=2008.03.25, +%D title=\METAPOST\ Integrated Graphics, +%D subtitle=Conversion to PDF, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +%D We use bit more code that needed because we want to limit the amount of boxing. + +\registerctxluafile{mlib-pdf}{} + +%D Some code is shared between MPLIB and MPS. The following variables are also +%D available for introspection and other purposes. + +\ifdefined\MPwidth \else \newdimen\MPwidth \fi +\ifdefined\MPheight \else \newdimen\MPheight \fi + +\ifdefined\MPllx \else \newdimen\MPllx \fi +\ifdefined\MPlly \else \newdimen\MPlly \fi +\ifdefined\MPurx \else \newdimen\MPurx \fi +\ifdefined\MPury \else \newdimen\MPury \fi + +\ifdefined\MPbox \else \newbox \MPbox \fi + +\unexpanded\def\setMPboundingbox#1#2#3#4% at some point we might pass them as base or scaled points + {\global\MPllx #1\onebasepoint + \global\MPlly #2\onebasepoint + \global\MPurx #3\onebasepoint + \global\MPury #4\onebasepoint + \global\MPwidth \dimexpr\MPurx-\MPllx\relax + \global\MPheight\dimexpr\MPury-\MPlly\relax} + +\unexpanded\def\resetMPboundingbox + {\global\MPwidth \zeropoint + \global\MPheight\zeropoint + \global\MPllx \zeropoint + \global\MPlly \zeropoint + \global\MPurx \zeropoint + \global\MPury \zeropoint} + +\let\popMPboundingbox\relax + +\unexpanded\def\pushMPboundingbox + {\edef\popMPboundingbox + {\global\MPwidth \the\MPwidth + \global\MPheight\the\MPheight + \global\MPllx \the\MPllx + \global\MPlly \the\MPlly + \global\MPurx \the\MPurx + \global\MPury \the\MPury + \relax}} + +% \unexpanded\def\repositionMPboxindeed +% {\setbox\MPbox\hpack\bgroup +% \kern-\MPllx +% \raise-\MPlly +% \box\MPbox +% \egroup} + +\unexpanded\def\repositionMPboxindeed + {\boxxmove\MPbox-\MPllx + \boxymove\MPbox-\MPlly} + +\unexpanded\def\repositionMPbox + {\ifzeropt\MPllx + \ifzeropt\MPlly + % okay + \else + \repositionMPboxindeed + \fi + \else + \repositionMPboxindeed + \fi} + +% \unexpanded\def\finalizeMPbox +% {\repositionMPbox +% \setbox\MPbox\vpack to \MPheight\bgroup +% \vfill +% \hsize\MPwidth +% \smashbox\MPbox +% \box\MPbox +% \egroup +% \wd\MPbox\MPwidth +% \ht\MPbox\MPheight} + +\unexpanded\def\finalizeMPbox + {\repositionMPbox + \boxyoffset\MPbox\dimexpr\boxyoffset\MPbox-\MPheight\relax + \wd\MPbox\MPwidth + \ht\MPbox\MPheight} + +% MPLIB specific: + +\def\MPLIBtoPDF{\clf_mpflushliteral} % expanded + +\unexpanded\def\startMPLIBtoPDF#1#2#3#4% + {\meta_process_graphic_figure_start + \dostarttagged\t!mpgraphic\empty + \naturalhpack attr \imageattribute \plusone \bgroup + \dousecolorparameter\s!black\forcecolorhack + \setMPboundingbox{#1}{#2}{#3}{#4}% + \setbox\MPbox\vpack\bgroup + % \forgetall % already done elsewhere + \noindent} % forces the proper cm in the backend + +\unexpanded\def\stopMPLIBtoPDF + {\egroup + \finalizeMPbox + \box\MPbox + \egroup + \dostoptagged + \meta_process_graphic_figure_stop} + +\def\MPLIBflushreset % This can (will) move to the Lua end. + {\clf_mpflushreset} + +%D Kind of special: +% +% test.mp: +% +% beginfig(1) fill fullcircle scaled 10cm withcolor red ; endfig ; +% beginfig(2) draw fullcircle scaled 5cm withcolor blue ; endfig ; +% beginfig(3) draw textext("just some text") ; endfig ; +% +% standalone pages: +% +% \starttext +% \directMPgraphic{input "test.mp" ;} +% \stoptext + +\let\normalstartMPLIBtoPDF\startMPLIBtoPDF +\let\normalstopMPLIBtoPDF \stopMPLIBtoPDF + +\unexpanded\def\directstartMPLIBtoPDF{\startTEXpage\normalstartMPLIBtoPDF} +\unexpanded\def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage} + +\unexpanded\def\directMPgraphic + {\dodoublegroupempty\mlib_direct_graphic} + +\def\mlib_direct_graphic#1#2% makes pages (todo: make boxes) + {\meta_begin_graphic_group{#1}% + \let\startMPLIBtoPDF\directstartMPLIBtoPDF + \let\stopMPLIBtoPDF \directstopMPLIBtoPDF + \meta_start_current_graphic + \forgetall + \edef\p_extensions{\MPinstanceparameter\s!extensions}% + \normalexpanded{\noexpand\clf_mpgraphic + instance {\currentMPinstance}% + format {\currentMPformat}% + data {#2;}% + initializations {\meta_flush_current_initializations}% + \ifx\p_extensions\v!yes + extensions {\clf_getmpextensions{\currentMPinstance}}% + \fi + inclusions {\meta_flush_current_inclusions}% + definitions {\meta_flush_current_definitions}% + figure {all}% + method {\MPinstanceparameter\c!method}% + \relax}% + \meta_stop_current_graphic + \meta_end_graphic_group} + +\protect \endinput diff --git a/tex/context/base/mkiv/mlib-scn.lua b/tex/context/base/mkiv/mlib-scn.lua index d73e210c3..97768f7a7 100644 --- a/tex/context/base/mkiv/mlib-scn.lua +++ b/tex/context/base/mkiv/mlib-scn.lua @@ -30,6 +30,9 @@ local type, next = type, next local byte = string.byte local insert, remove = table.insert, table.remove +local mplib = mplib +local metapost = metapost + local codes = mplib.codes() local types = mplib.types() diff --git a/tex/context/base/mkiv/mult-aux.mkiv b/tex/context/base/mkiv/mult-aux.mkiv index b29478a56..f72e87608 100644 --- a/tex/context/base/mkiv/mult-aux.mkiv +++ b/tex/context/base/mkiv/mult-aux.mkiv @@ -214,8 +214,8 @@ \def\mult_interfaces_detokenize{\expandafter\expandafter\expandafter\detokenize\expandafter\expandafter\expandafter} -\unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8% inlining \csname*\endcsname is more efficient (#3 and #6 only) - {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing +\unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only) + {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing \def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}% \def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}% %\def#5##1##2{\ifx##1\relax\??empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ? @@ -223,7 +223,8 @@ \def#5##1##2{\ifx##1\relax^^^^0019\else#4##1{##2}\fi}% is {} needed around ##1 ? \def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}% \def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack - \def#8##1{\begincsname#1#2:##1\endcsname}} + \def#8##1{\begincsname#1#2:##1\endcsname} + \def#9##1##2{\expandafter\let\expandafter##1\csname\ifcsname#1#2:##2\endcsname#1#2:##2\else\expandafter#5\csname#1#2:\s!parent\endcsname{##2}\fi\endcsname}} \unexpanded\def\installparameterhandler#1#2% {\normalexpanded @@ -235,7 +236,8 @@ \expandafter\noexpand\csname do#2parentparameter\endcsname % or : #2_parent_parameter \expandafter\noexpand\csname named#2parameter\endcsname \expandafter\noexpand\csname detokenized#2parameter\endcsname - \expandafter\noexpand\csname direct#2parameter\endcsname}} % strict#2parameter is gone + \expandafter\noexpand\csname direct#2parameter\endcsname + \expandafter\noexpand\csname letfrom#2parameter\endcsname}} % strict#2parameter is gone \unexpanded\def\mult_interfaces_install_root_parameter_handler#1#2#3% {\def#2##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root diff --git a/tex/context/base/mkiv/mult-aux.mkxl b/tex/context/base/mkiv/mult-aux.mkxl index 8343fb8dd..ebe3d0f2a 100644 --- a/tex/context/base/mkiv/mult-aux.mkxl +++ b/tex/context/base/mkiv/mult-aux.mkxl @@ -194,8 +194,8 @@ \def\mult_interfaces_detokenize{\expandafter\expandafter\expandafter\detokenize\expandafter\expandafter\expandafter} -\unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8% inlining \csname*\endcsname is more efficient (#3 and #6 only) - {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing +\unexpanded\def\mult_interfaces_install_parameter_handler#1#2#3#4#5#6#7#8#9% inlining \csname*\endcsname is more efficient (#3 and #6 only) + {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing \def#3##1{\csname\ifcsname#1#2:##1\endcsname#1#2:##1\else\expandafter#5\csname#1#2:\s!parent\endcsname{##1}\fi\endcsname}% \def#4##1##2{\ifcsname##1:##2\endcsname##1:##2\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}% %\def#5##1##2{\ifx##1\relax\??empty\else#4{##1}{##2}\fi}% is {} needed around ##1 ? @@ -203,7 +203,8 @@ \def#5##1##2{\ifx##1\relax^^^^0019\else#4##1{##2}\fi}% is {} needed around ##1 ? \def#6##1##2{\csname\ifcsname#1##1:##2\endcsname#1##1:##2\else\expandafter#5\csname#1##1:\s!parent\endcsname{##2}\fi\endcsname}% \def#7##1{\detokenize\expandafter\expandafter\expandafter{\csname#1#2:##1\endcsname}}% always root, no backtrack - \def#8##1{\begincsname#1#2:##1\endcsname}} + \def#8##1{\begincsname#1#2:##1\endcsname} + \def#9##1##2{\expandafter\let\expandafter##1\csname\ifcsname#1#2:##2\endcsname#1#2:##2\else\expandafter#5\csname#1#2:\s!parent\endcsname{##2}\fi\endcsname}} \unexpanded\def\installparameterhandler#1#2% {\normalexpanded @@ -215,7 +216,8 @@ \expandafter\noexpand\csname do#2parentparameter\endcsname % or : #2_parent_parameter \expandafter\noexpand\csname named#2parameter\endcsname \expandafter\noexpand\csname detokenized#2parameter\endcsname - \expandafter\noexpand\csname direct#2parameter\endcsname}} % strict#2parameter is gone + \expandafter\noexpand\csname direct#2parameter\endcsname + \expandafter\noexpand\csname letfrom#2parameter\endcsname}} % strict#2parameter is gone \unexpanded\def\mult_interfaces_install_root_parameter_handler#1#2#3% {\def#2##1{\detokenize\expandafter\expandafter\expandafter{\csname#1:##1\endcsname}}% always root @@ -236,7 +238,8 @@ \def#5##1##2{\ifx##1\relax\else#4##1{##2}\fi}% \def#6{#1#2:}% \def#7##1{#1##1:}% - \def#8{\ifx#2\empty\else\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi\fi}% +% \def#8{\ifx#2\empty\else\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi\fi}% + \def#8{\ifx#2\empty\orelse\ifcsname#1#2:\s!parent\endcsname\else\expandafter\let\csname#1#2:\s!parent\endcsname#1\fi}% \unexpanded\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}} \unexpanded\def\installparameterhashhandler#1#2% @@ -314,11 +317,17 @@ \let\definehandlerparent\empty +% \def\mult_check_for_parent#1#2#3#4% +% {\ifcsname#1#4:\s!parent\endcsname \else \ifx#4\empty \else +% \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}% +% \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}% +% \fi \fi} + \def\mult_check_for_parent#1#2#3#4% - {\ifcsname#1#4:\s!parent\endcsname \else \ifx#4\empty \else + {\ifcsname#1#4:\s!parent\endcsname\orelse\ifx#4\empty\else \writestatus\m!system{error: invalid parent #4 for #3, #4 defined too (best check it)}% \expandafter\edef\csname#1#4:\s!parent\endcsname{#2}% - \fi \fi} + \fi} %def\mult_interfaces_chain#1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\space\fi} %def\getparentchain #1#2{\ifcsname#1#2:\s!chain\endcsname\csname#1#2:\s!chain\endcsname\fi} diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index b6fdb7021..cb3b4f4e5 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -9108,6 +9108,18 @@ return { ["en"]="middlecommand", ["nl"]="middencommando", }, + ["middlecolor"]={ + ["en"]="middlecolor", + ["nl"]="middenkleur", + }, + ["middlestyle"]={ + ["en"]="middlestyle", + ["nl"]="middenletter", + }, + ["middlewidth"]={ + ["en"]="middlewidth", + ["nl"]="middenbreedte", + }, ["middlespeech"]={ ["cs"]="middlespeech", ["de"]="middlespeech", diff --git a/tex/context/base/mkiv/pack-lyr.mkxl b/tex/context/base/mkiv/pack-lyr.mkxl new file mode 100644 index 000000000..838e2fe19 --- /dev/null +++ b/tex/context/base/mkiv/pack-lyr.mkxl @@ -0,0 +1,794 @@ +%D \module +%D [ file=pack-lyr, +%D version=2000.10.20, +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Layers, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Layers} + +% todo : first / last / next / +... => page key +% test on left/right box when no doublesided option given +% use \ifcsname instead of doifvalue + +\unprotect + +% When being backgrounds layers get the background offset displacement. Should be +% an option, on by default (compatibility). + +%D The layering mechanism implemented here is independent of the output routine, but +%D future extensions may depend on a more close cooperation. +%D +%D First we overload a macro from \type {pack-rul}. From now on we accept a +%D (optional) argument: the specific layer it will go in. This means that we can +%D move an overlay from one background to the other using the dimensions of the +%D parent. + +\ifdefined\defineoverlay \else \message{loaded to early} \wait \fi + +\unexpanded\def\defineoverlay + {\dotripleempty\pack_framed_define_overlay} + +\def\pack_framed_define_overlay[#1][#2][#3]% overlay [layer] content + {\ifthirdargument + %\writestatus{BEWARE}{This (overlay definition) has changed!}% temp + \def\pack_framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\setlayer[#2]{\executedefinedoverlay{##1}{#3}}}}% + \else + \def\pack_framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\executedefinedoverlay{##1}{#2}}}% + \fi + \processcommalist[#1]\pack_framed_define_overlay_indeed} + +%D We use the command handler code. The previous, more direct parameter handling was +%D 25\% faster when no parameters were passed when adding content to a layer. +%D However, when we pass for instance a preset, the new methos is some 10\% faster +%D and it happens that in most cases we do pass some parameters. It would be +%D interesting to see if we can push the preset in between the regular chain but it +%D could also lead to unwanted side effects when nesting layer placement. + +\installcorenamespace{layer} +\installcorenamespace{layerbox} +\installcorenamespace{layerpreset} +\installcorenamespace{layerposition} % brr, unreadable + +%D \macros +%D {definelayer,setuplayer} +%D +%D Each layer gets its own (global) box. This also means that the data that goes +%D into a layer, is typeset immediately. Each layer automatically gets an associated +%D overlay, which can be used in any background assignment. +%D +%D After a layer is defined, you can change its characteristics. + +\installcommandhandler \??layer {layer} \??layer + +\setuplayer + [\c!state=\v!start, + %\c!doublesided=, + %\c!preset=, + %\c!option=, + %\c!corner=, + %\c!page=, + %\c!rotation=, % geen 0 ! + \c!direction=\v!normal, + \c!position=\v!no, + \c!method=\v!overlay, + \c!x=\zeropoint, + \c!y=\zeropoint, + \c!line=0, + \c!column=0, + \c!width=\wd\nextbox, % don't change this globally + \c!height=\ht\nextbox, % don't change this globally + \c!offset=\zeropoint, + \c!hoffset=\zeropoint, + \c!voffset=\zeropoint, + \c!dx=\zeropoint, + \c!dy=\zeropoint, + \c!location=rb, + \c!sx=1, + \c!sy=1, + \c!region=\layeranchor] + +\def\layeranchor{\currentlayer:\the\realpageno} + +\let\p_pack_layers_doublesided\empty +\let\p_pack_layers_state \empty +\let\p_pack_layers_option \empty +\let\p_pack_layers_method \empty +\let\p_pack_layers_preset \empty +\let\p_pack_layers_rotation \empty +\let\p_pack_layers_position \empty +\let\p_pack_layers_hoffset \empty +\let\p_pack_layers_voffset \empty +\let\p_pack_layers_offset \empty +\let\p_pack_layers_dx \empty +\let\p_pack_layers_dy \empty +\let\p_pack_layers_sx \empty +\let\p_pack_layers_sy \empty +\let\p_pack_layers_x \empty +\let\p_pack_layers_y \empty +\let\p_pack_layers_corner \empty +\let\p_pack_layers_location \empty +\let\p_pack_layers_line \empty +\let\p_pack_layers_column \empty +\let\p_pack_layers_width \empty +\let\p_pack_layers_height \empty +\let\p_pack_layers_direction \empty +\let\p_pack_layers_region \empty + +\let\m_pack_layers_page \empty +\let\m_pack_layers_target \empty +\let\m_pack_layers_region \empty +\let\m_pack_layers_anchor \empty + +\newconditional\c_pack_layers_repeated +\newconditional\c_pack_layers_trace +\newcount \c_pack_layers_current_data + +\newbox\b_layers + +\newdimen\d_pack_layers_x_size +\newdimen\d_pack_layers_y_size +\newdimen\d_pack_layers_x_offset +\newdimen\d_pack_layers_y_offset +\newdimen\d_pack_layers_x_position +\newdimen\d_pack_layers_y_position + +\newdimen\layerwidth +\newdimen\layerheight + +\let\lastlayerxpos\!!zeropoint +\let\lastlayerypos\!!zeropoint +\let\lastlayerwd \!!zeropoint +\let\lastlayerht \!!zeropoint +\let\lastlayerdp \!!zeropoint + +\appendtoks + \edef\p_pack_layers_doublesided{\layerparameter\c!doublesided}% + \ifx\p_pack_layers_doublesided\v!yes + \relateparameterhandlers{layer}{\v!left \currentlayer}{layer}\currentlayer % permits left* + \relateparameterhandlers{layer}{\v!right\currentlayer}{layer}\currentlayer % permits right* + \pack_layers_preset_box{\v!left \currentlayer}% + \pack_layers_preset_box{\v!right\currentlayer}% + \fi + \pack_layers_preset_box\currentlayer + \normalexpanded{\defineoverlay[\currentlayer][\noexpand\composedlayer{\currentlayer}]}% +\to \everydefinelayer + +\def\pack_layers_preset_box#1% + {\ifcsname\??layerbox#1\endcsname + \resetlayer[#1]% + \else + \expandafter\newbox\csname\??layerbox#1\endcsname + \fi} + +%D \macros +%D {resetlayer} +%D +%D This macro hardly needs an explanation (but is seldom needed anyway). + +\def\pack_layers_reset_box#1% + {\ifcsname\??layerbox#1\endcsname + %\global\setbox\csname\??layerbox#1\endcsname\emptybox + \global\setbox\lastnamedcs\emptybox + \fi} + +\def\resetlayer[#1]% + {\pack_layers_reset_box{#1}% + \pack_layers_reset_box{\v!left #1}% + \pack_layers_reset_box{\v!right#1}% + \pack_layers_reset_box{#1:\the\realpageno}} + +%D \macros +%D {setlayer} +%D +%D Data is moved into a layer with the following macro. When \type {position} is +%D set, relative positioning is used, with the current point as reference point. +%D Otherwise the topleft corner is used as reference point. +%D +%D \starttyping +%D \setlayer [identifier] [optional parameters] {data} +%D \stoptyping + +\def\setcurrentlayerdimensions + {\dodoubleempty\pack_layers_set_current_dimensions} + +\def\pack_layers_set_current_dimensions[#1][#2]% name left|right + {\edef\currentlayerwidth {\thelayerwidth {#2#1}}% + \edef\currentlayerheight{\thelayerheight{#2#1}}} + +\def\thelayerwidth #1{\the\ifcsname\??layerbox#1\endcsname\wd\lastnamedcs\else\zeropoint\fi} +\def\thelayerheight#1{\the\ifcsname\??layerbox#1\endcsname\ht\lastnamedcs\else\zeropoint\fi} + +\unexpanded\def\setlayer + {\dotripleempty\pack_layers_set} + +\def\pack_layers_set[#1][#2][#3]% #4 == box do \fi is ok + {\bgroup + \checkpositionoverlays % otherwise funny regions + \edef\currentlayer{#1}% + \edef\p_pack_layers_state{\layerparameter\c!state}% + \ifx\p_pack_layers_state\v!stop + \dowithnextboxcs\egroup\hbox % no pack ? + \orelse\ifthirdargument + \pack_layers_set_indeed[#1][#2][#3]% + \else + \ifcondition\validassignment{#2}% + \pack_layers_set_indeed[#1][][#2]% + \else + \pack_layers_set_indeed[#1][#2][]% + \fi + \fi} + +\def\pack_layers_set_indeed[#1][#2][#3]% #2 = links/rechts + {\page_backgrounds_recalculate % brrr + \global\advance\c_pack_layers_current_data\plusone + \forgetall + \dontcomplain + \edef\p_pack_layers_option{\layerparameter\c!option}% + \ifx\p_pack_layers_option\v!test + \settrue\c_pack_layers_trace + \traceboxplacementtrue + \fi + \edef\m_pack_layers_target{#2}% + \dowithnextbox{\pack_layers_set_finish{#3}}\hbox} + +\def\pack_layers_set_finish#1% + {\ifcsname\??layerbox\currentlayer\endcsname % can move up + \ifx\m_pack_layers_target\v!even + \ifodd\realpageno + % discard nextbox + \else + \let\m_pack_layers_target\v!left + \pack_layers_set_content{#1}% + \fi + \orelse\ifx\m_pack_layers_target\v!odd + \ifodd\realpageno + \let\m_pack_layers_target\v!right + \pack_layers_set_content{#1}% + \else + % discard nextbox + \fi + \else + \pack_layers_set_content{#1}% + \fi + \else + \writestatus{layer}{unknown layer \currentlayer}% + \fi + \egroup} + +% todo: left/right +% todo: get position data in one go + +\def\pack_layers_set_last_position_yes % target: left|right + {% this will become one call + \edef\m_pack_layers_anchor{\??layerposition\the\c_pack_layers_current_data}% + \edef\m_pack_layers_page {\MPp\m_pack_layers_anchor}% + %edef\m_pack_layers_region{\MPr\m_pack_layers_anchor}% wrong one + \edef\m_pack_layers_region{\layerparameter\c!region}% + \d_pack_layers_x_position \dimexpr-\MPx\m_pack_layers_region+\MPx\m_pack_layers_anchor\relax + \d_pack_layers_y_position \dimexpr \MPy\m_pack_layers_region-\MPy\m_pack_layers_anchor+\MPh\m_pack_layers_region\relax + \xdef\lastlayerxpos{\the\d_pack_layers_x_position}% + \xdef\lastlayerypos{\the\d_pack_layers_y_position}% + % \writestatus{layering}{region: \m_pack_layers_region=>\MPxywhd\m_pack_layers_region}% + % \writestatus {}{anchor: \m_pack_layers_anchor=>\MPxywhd\m_pack_layers_anchor}% + % \writestatus {}{offset: \c!dx,\c!dy =>\lastlayerxpos,\lastlayerypos}% + \global\letlayerparameter\c!state\v!start % needed ? + \setbox\b_layers\vpack to \d_pack_layers_y_size + {\hpack to \d_pack_layers_x_size + {\xypos\m_pack_layers_anchor\hss}% + \vss}} + +\def\pack_layers_set_last_position_nop + {\setbox\b_layers\emptybox + \d_pack_layers_x_position\p_pack_layers_sx\dimexpr\p_pack_layers_x\relax + \d_pack_layers_y_position\p_pack_layers_sy\dimexpr\p_pack_layers_y\relax + \glet\lastlayerxpos\!!zeropoint + \glet\lastlayerypos\!!zeropoint + \doifinset\v!bottom\p_pack_layers_corner\pack_layers_set_bottom_positions + \doifinset\v!right \p_pack_layers_corner\pack_layers_set_right_positions + \doifinset\v!middle\p_pack_layers_corner\pack_layers_set_middle_positions + \edef\m_pack_layers_page{\layerparameter\c!page}} + +\unexpanded\def\definelayerpreset + {\dodoubleargument\pack_layers_define_preset} + +\def\pack_layers_define_preset[#1][#2]% + {\doifelseassignment{#2} + {\setvalue{\??layerpreset#1}{\setupcurrentlayer[#2]}} + {\setvalue{\??layerpreset#1}{\csname\??layerpreset#2\endcsname}}} + +\def\pack_layers_set_content#1% + {\layerwidth \layerparameter\c!width % global (local later) + \layerheight\layerparameter\c!height % global (local later) + \d_pack_layers_x_size\layerwidth + \d_pack_layers_y_size\layerheight + % + \setupcurrentlayer[#1]% preroll + % + \edef\p_pack_layers_preset {\layerparameter\c!preset }% + % + \ifcsname\??layerpreset\p_pack_layers_preset\endcsname + \lastnamedcs + \setupcurrentlayer[#1]% postroll + \fi + % + \edef\p_pack_layers_rotation {\layerparameter\c!rotation }% + \edef\p_pack_layers_position {\layerparameter\c!position }% + \edef\p_pack_layers_hoffset {\layerparameter\c!hoffset }% + \edef\p_pack_layers_voffset {\layerparameter\c!voffset }% + \edef\p_pack_layers_offset {\layerparameter\c!offset }% + \edef\p_pack_layers_dx {\layerparameter\c!dx }% + \edef\p_pack_layers_dy {\layerparameter\c!dy }% + \edef\p_pack_layers_sx {\layerparameter\c!sx }% + \edef\p_pack_layers_sy {\layerparameter\c!sy }% + \edef\p_pack_layers_x {\layerparameter\c!x }% + \edef\p_pack_layers_y {\layerparameter\c!y }% + \edef\p_pack_layers_corner {\layerparameter\c!corner }% + \edef\p_pack_layers_location {\layerparameter\c!location }% + \edef\p_pack_layers_line {\layerparameter\c!line }% + \edef\p_pack_layers_column {\layerparameter\c!column }% + \edef\p_pack_layers_width {\layerparameter\c!width }% local ones + \edef\p_pack_layers_height {\layerparameter\c!height }% local ones + \edef\p_pack_layers_direction{\layerparameter\c!direction}% + % + \ifx\p_pack_layers_position\v!overlay + \let\p_pack_layers_width \zeropoint + \let\p_pack_layers_height \zeropoint + \let\p_pack_layers_position\v!yes + \fi + \ifx\p_pack_layers_rotation\empty \else + % use direct call + \setbox\nextbox\hpack + {\rotate[\c!location=\v!high,\c!rotation=\layerparameter\c!rotation]{\box\nextbox}}% + \fi + \d_pack_layers_x_offset\p_pack_layers_sx\dimexpr + \ifx\p_pack_layers_hoffset\v!max\d_pack_layers_x_size\else\p_pack_layers_hoffset\fi+\p_pack_layers_offset+\p_pack_layers_dx + \relax + \d_pack_layers_y_offset\p_pack_layers_sy\dimexpr + \ifx\p_pack_layers_voffset\v!max\d_pack_layers_y_size\else\p_pack_layers_voffset\fi+\p_pack_layers_offset+\p_pack_layers_dy + \relax + \ifx\p_pack_layers_position\v!yes + \pack_layers_set_last_position_yes + \else + \pack_layers_set_last_position_nop + \fi + % + \ifx\m_pack_layers_page\empty \else % is expanded + \edef\m_pack_layers_page{:\m_pack_layers_page}% + \ifcsname\??layerbox\m_pack_layers_target\currentlayer\m_pack_layers_page\endcsname \else + \expandafter\newbox\csname\??layerbox\m_pack_layers_target\currentlayer\m_pack_layers_page\endcsname + \fi + \fi + \chardef\layerpagebox\csname\??layerbox\m_pack_layers_target\currentlayer\m_pack_layers_page\endcsname + \ifvoid\layerpagebox + \gsetboxllx\layerpagebox\zeropoint + \gsetboxlly\layerpagebox\zeropoint + \fi + \global\setbox\layerpagebox\vpack %to \layerparameter\c!height % new, otherwise no negative y possible + {\offinterlineskip + \ifvoid\layerpagebox + \let\lastlayerwidth \zeropoint + \let\lastlayerheight\zeropoint + \else + \edef\lastlayerwidth {\the\wd\layerpagebox}% + \edef\lastlayerheight{\the\ht\layerpagebox}% + \ht\layerpagebox\zeropoint + \dp\layerpagebox\zeropoint + \wd\layerpagebox\zeropoint + \ifx\p_pack_layers_direction\v!reverse\else + \box\layerpagebox + \fi + \fi + % don't move + \xdef\lastlayerwd{\the\wd\nextbox}% + \xdef\lastlayerht{\the\ht\nextbox}% % not entirely ok when grid ! + \xdef\lastlayerdp{\the\dp\nextbox}% % not entirely ok when grid ! + % this code + \ifx\p_pack_layers_location\v!grid + \ht\nextbox\strutheight + \dp\nextbox\strutdepth + \else + \setbox\nextbox\hpack + {\alignedbox[\p_pack_layers_location]\vpack{\box\nextbox}}% + \fi + \ifnum\p_pack_layers_line=\zerocount\else % no \ifcase, can be negative + \advance\d_pack_layers_y_position\dimexpr\p_pack_layers_line\lineheight+\topskip-\lineheight-\ht\nextbox\relax + \fi + \ifnum\p_pack_layers_column=\zerocount\else % no \ifcase, can be negative + \advance\d_pack_layers_x_position\layoutcolumnoffset\p_pack_layers_column\relax + \fi + \ifx\p_pack_layers_location\v!grid + \setbox\nextbox\hpack + {\alignedbox[rb]\vpack{\box\nextbox}}% + \fi + % ll registration + \scratchdimen\dimexpr\d_pack_layers_x_position+\d_pack_layers_x_offset\relax + \ifdim\scratchdimen<\getboxllx\layerpagebox + \gsetboxllx\layerpagebox\scratchdimen + \fi + \advance\scratchdimen\wd\nextbox + \wd\nextbox\ifdim\scratchdimen>\lastlayerwidth \scratchdimen \else \lastlayerwidth \fi + \scratchdimen\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax + \ifdim\scratchdimen<\getboxlly\layerpagebox + \gsetboxlly\layerpagebox\scratchdimen + \fi + % ll compensation + \advance\scratchdimen\dimexpr\ht\nextbox+\dp\nextbox\relax + \ht\nextbox\ifdim\scratchdimen>\lastlayerheight \scratchdimen \else \lastlayerheight \fi + \dp\nextbox\zeropoint + % placement + \hsize\p_pack_layers_width + \vpack to \p_pack_layers_height \bgroup + \smashbox\nextbox + \vskip\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax + \hskip\dimexpr\d_pack_layers_x_position+\d_pack_layers_x_offset\relax + % or maybe instead of the \vskip + % \raise-\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax + \box\nextbox + \ifvoid\layerpagebox + % already flushed + \else + % the reverse case % check ! + \vskip-\dimexpr\d_pack_layers_y_position+\d_pack_layers_y_offset\relax + \box\layerpagebox + \fi + \egroup}% + % when position is true, the layerbox holds the compensation and needs + % to be placed; never change this ! + \ifvoid\b_layers \else + \box\b_layers + \fi} + +\def\pack_layers_set_bottom_positions + {\ifnum\p_pack_layers_line=\zerocount\else % can be < 0 + \edef\p_pack_layers_line{\the\numexpr-\p_pack_layers_line+\layoutlines+\plusone\relax}% use counter instead ? + \fi + \ifdim\d_pack_layers_y_size>\zeropoint + \advance\d_pack_layers_y_position-\d_pack_layers_y_size + \d_pack_layers_y_position-\d_pack_layers_y_position + \d_pack_layers_y_offset-\d_pack_layers_y_offset + \fi} + +\def\pack_layers_set_right_positions + {\ifnum\p_pack_layers_column=\zerocount\else % can be < 0 + \edef\p_pack_layers_column{\the\numexpr-\layerparameter\c!column+\layoutcolumns+\plusone\relax}% use counter instead ? + \fi + \ifdim\d_pack_layers_x_size>\zeropoint + \advance\d_pack_layers_x_position-\d_pack_layers_x_size + \d_pack_layers_x_position-\d_pack_layers_x_position + \d_pack_layers_x_offset-\d_pack_layers_x_offset + \fi} + +\def\pack_layers_set_middle_positions + {\ifdim\d_pack_layers_x_size>\zeropoint \advance\d_pack_layers_x_position.5\d_pack_layers_x_size \fi + \ifdim\d_pack_layers_y_size>\zeropoint \advance\d_pack_layers_y_position.5\d_pack_layers_y_size \fi} + +%D Given the task to be accomplished, the previous macro is not even that +%D complicated. It mainly comes down to skipping to the right place and placing a +%D box on top of or below the existing content. In the case of position tracking, +%D another reference point is chosen. + +%D \macros +%D {doifelselayerdata} + +\def\doifelselayerdata#1% + {\ifcsname\??layerbox#1\endcsname + %\ifvoid\csname\??layerbox#1\endcsname + \ifvoid\lastnamedcs + \doubleexpandafter\secondoftwoarguments + \else + \doubleexpandafter\firstoftwoarguments + \fi + \else + \expandafter\secondoftwoarguments + \fi} + +\let\doiflayerdataelse\doifelselayerdata + +%D \macros +%D {flushlayer} +%D +%D When we flush a layer, we flush both the main one and the page dependent one +%D (when defined). This feature is more efficient in \ETEX\ since there testing for +%D an undefined macro does not takes hash space. + +% todo: setups before flush, handy hook + +\unexpanded\def\flushlayer[#1]% quite core, so optimized (todo: check for void) + {\begingroup + \forgetall + \edef\currentlayer{#1}% + \edef\p_pack_layers_state{\layerparameter\c!state}% + \ifx\p_pack_layers_state\v!stop + % nothing + \orelse\ifx\p_pack_layers_state\v!next + \global\letlayerparameter\c!state\v!start % dangerous, stack-built-up + \orelse\ifx\p_pack_layers_state\v!continue + \global\letlayerparameter\c!state\v!repeat % dangerous, stack-built-up + \else + \edef\p_pack_layers_doublesided{\layerparameter\c!doublesided}% + \ifx\p_pack_layers_doublesided\v!yes + \ifcsname\??layerbox#1\endcsname + % we can make a dedicated one for this + \doifbothsidesoverruled + {\pack_layers_flush_double\v!left }% + {\pack_layers_flush_double\v!right}% + {\pack_layers_flush_double\v!left }% + \else + \pack_layers_flush_single + \fi + \else + \pack_layers_flush_single + \fi + \fi + \endgroup} + +% \def\pack_layers_flush_single +% {\startoverlay +% {\ifcsname\??layerbox \currentlayer \endcsname\pack_layers_flush_indeed\plusone \currentlayer \fi}% +% {\ifcsname\??layerbox \currentlayer:\the\realpageno\endcsname\pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\fi}% +% \stopoverlay} +% +% \def\pack_layers_flush_double#1% +% {\startoverlay +% {\ifcsname\??layerbox \currentlayer \endcsname\pack_layers_flush_indeed\plusone \currentlayer \fi}% +% {\ifcsname\??layerbox \currentlayer:\the\realpageno\endcsname\pack_layers_flush_indeed\zerocount {\currentlayer:\the\realpageno}\fi}% +% {\ifcsname\??layerbox#1\currentlayer \endcsname\pack_layers_flush_indeed\plusone {#1\currentlayer }\fi}% +% {\ifcsname\??layerbox#1\currentlayer:\the\realpageno\endcsname\pack_layers_flush_indeed\zerocount{#1\currentlayer:\the\realpageno}\fi}% +% \stopoverlay} + +% optimized: + +\def\pack_layers_flush_single + {\ifcsname\??layerbox\currentlayer\endcsname + \ifvoid\lastnamedcs + \ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname + \ifvoid\lastnamedcs\else + \chardef\b_layer_two\lastnamedcs + \pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two + \fi + \fi + \else + \chardef\b_layer_one\lastnamedcs + \ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname + \ifvoid\lastnamedcs\else + \chardef\b_layer_two\lastnamedcs + \startoverlay + {\pack_layers_flush_indeed\plusone \currentlayer \b_layer_one}% + {\pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two}% + \stopoverlay + \fi + \else + \pack_layers_flush_indeed\plusone\currentlayer\b_layer_one + \fi + \fi + \orelse\ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname + \ifvoid\lastnamedcs + % nothing + \else + \chardef\b_layer_two\lastnamedcs + \pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two + \fi + \fi} + +% less optimized: + +\def\pack_layers_flush_double#1% + {\startoverlay + {\ifcsname\??layerbox\currentlayer\endcsname + \ifvoid\lastnamedcss\else \chardef\b_layer_two\lastnamedcs + \pack_layers_flush_indeed\plusone\currentlayer\b_layer_two + \fi + \fi}% + {\ifcsname\??layerbox\currentlayer:\the\realpageno\endcsname + \ifvoid\lastnamedcss\else \chardef\b_layer_two\lastnamedcs + \pack_layers_flush_indeed\zerocount{\currentlayer:\the\realpageno}\b_layer_two + \fi + \fi}% + {\ifcsname\??layerbox#1\currentlayer\endcsname + \ifvoid\lastnamedcss\else \chardef\b_layer_two\lastnamedcs + \pack_layers_flush_indeed\plusone{#1\currentlayer}\b_layer_two + \fi + \fi}% + {\ifcsname\??layerbox#1\currentlayer:\the\realpageno\endcsname + \ifvoid\lastnamedcss\else \chardef\b_layer_two\lastnamedcs + \pack_layers_flush_indeed\zerocount{#1\currentlayer:\the\realpageno}\b_layer_two + \fi + \fi}% + \stopoverlay} + +\let\pack_layers_top_fill \relax +\let\pack_layers_bottom_fill\vss + +%def\pack_layers_flush_indeed#1#2% +\def\pack_layers_flush_indeed#1#2#3% + {\begingroup % already grouped + \offinterlineskip + \edef\p_pack_layers_preset{\layerparameter\c!preset}% + \ifcsname\??layerpreset\p_pack_layers_preset\endcsname + \lastnamedcs + \fi + \edef\p_pack_layers_method{\layerparameter\c!method}% + \edef\p_pack_layers_option{\layerparameter\c!option}% + \ifx\p_pack_layers_option\v!test + \settrue\c_pack_layers_trace + \traceboxplacementtrue + \fi + \ifcase#1\relax + \setfalse\c_pack_layers_repeated + \else + \edef\p_pack_layers_position{\layerparameter\c!position}% + \ifx\p_pack_layers_position\v!yes + \setfalse\c_pack_layers_repeated + \else + \edef\p_pack_layers_repeat{\layerparameter\c!repeat}% + \ifx\p_pack_layers_repeat\v!yes + \settrue\c_pack_layers_repeated + \orelse\ifx\p_pack_layers_state\v!repeat + \settrue\c_pack_layers_repeated + \else + \setfalse\c_pack_layers_repeated + \fi + \fi + \fi + %chardef\b_layers\csname\??layerbox#2\endcsname % trick + \let\b_layers#3% + % we need to copy in order to retain the negative offsets for a next + % stage of additions, i.e. llx/lly accumulate in repeat mode and the + % compensation may differ each flush depending on added content + \setbox\nextbox + \ifx\p_pack_layers_method\v!fit + \pack_layers_positioned_box_yes + \else + \pack_layers_positioned_box_nop + \fi + % todo: method=offset => overlayoffset right/down (handy for backgrounds with offset) + \doifelseoverlay{#2}% + {\setlayoutcomponentattribute{\v!layer:#2}}% + \resetlayoutcomponentattribute + % we have conflicting demands: some mechanisms want ll anchoring .. I need to figure this out + % and maybe we will have 'origin=bottom' or so + \setbox\nextbox + \ifx\p_pack_layers_option\v!test \ruledvbox \else \vpack \fi \ifx\p_pack_layers_method\v!overlay to \d_overlay_height \fi \layoutcomponentboxattribute + {\pack_layers_top_fill +% +% \hpack \ifx\p_pack_layers_method\v!overlay to \d_overlay_width \fi +% {\box\nextbox +% \hss}% +% + \ifx\p_pack_layers_method\v!overlay \wd\nextbox\d_overlay_width\fi + \box\nextbox +% + \pack_layers_bottom_fill}% + % \edef\currentlayer{#2}% :\the\realpageno}% local .. check \anchor + % \edef\p_pack_layers_position{\layerparameter\c!position}% local + \ifx\p_pack_layers_position\v!yes + \edef\p_pack_layers_region{\layerparameter\c!region}% + \ifx\p_pack_layers_region\empty + \else + \anch_mark_tagged_box\nextbox\p_pack_layers_region % was \layeranchor + \fi + \fi + \box\nextbox + % + \ifconditional\c_pack_layers_repeated\else + \gsetboxllx\b_layers\zeropoint + \gsetboxlly\b_layers\zeropoint + \fi + \endgroup} + +\def\pack_layers_positioned_box_yes + {\vpack + {\vskip-\getboxlly\b_layers + \hskip-\getboxllx\b_layers + \hsize-\dimexpr\getboxllx\b_layers-\wd\b_layers\relax + \ifconditional\c_pack_layers_repeated\copy\else\box\fi\b_layers}} + +\def\pack_layers_positioned_box_nop + {\ifconditional\c_pack_layers_repeated\copy\else\box\fi\b_layers} + +% \definelayer[test][method=fit] \setupcolors[state=start,option=test] +% +% \framed[framecolor=red,offset=overlay]{\setlayer[test]{aa}\setlayer[test][x=10pt]{g}\flushlayer[test]} +% \framed[framecolor=red,offset=overlay]{\setlayer[test]{aa}\setlayer[test][x=-10pt]{bb}\flushlayer[test]} +% \framed[framecolor=red,offset=overlay]{\setlayer[test][x=-20pt]{cccccc}\flushlayer[test]} +% \framed[framecolor=red,offset=overlay]{\setlayer[test]{dd}\setlayer[test][x=-20pt,y=-3pt]{eeeeee}\flushlayer[test]} + +%D \macros +%D {composedlayer,placelayer,tightlayer} +%D +%D This is a handy shortcut, which saves a couple of braces when we use it as +%D parameter. This name also suits better to other layering commands. + +\unexpanded\def\composedlayer#1{\flushlayer[#1]} + +\unexpanded\def\tightlayer[#1]% + {\hpack + {\def\currentlayer{#1}% todo: left/right + \setbox\nextbox\emptybox + \d_overlay_width \layerparameter\c!width + \d_overlay_height\layerparameter\c!height + \composedlayer{#1}}} + +\let\placelayer\flushlayer + +%D \macros +%D {setMPlayer} +%D +%D The following layer macro uses the positions that are registered by \METAPOST. +%D +%D \starttyping +%D \definelayer[test] +%D +%D \setMPlayer [test] [somepos-1] {Whatever we want here!} +%D \setMPlayer [test] [somepos-2] {Whatever we need there!} +%D \setMPlayer [test] [somepos-3] {\externalfigure[cow.mps][width=2cm]} +%D +%D \startuseMPgraphic{oeps} +%D draw fullcircle scaled 10cm withcolor red ; +%D register ("somepos-1",2cm,3cm,center currentpicture) ; +%D register ("somepos-2",8cm,5cm,(-1cm,-2cm)) ; +%D register ("somepos-3",0cm,0cm,(-2cm,2cm)) ; +%D \stopuseMPgraphic +%D +%D \getMPlayer[test]{\useMPgraphic{oeps}} +%D \stoptyping +%D +%D The last line is equivalent to +%D +%D \starttyping +%D \framed +%D [background={foreground,test},offset=overlay] +%D {\useMPgraphic{oeps}} +%D \stoptyping + +\unexpanded\def\setMPlayer + {\dotripleempty\pack_layers_set_MP} + +\def\MPlayerwidth {\hsize} +\def\MPlayerheight{\vsize} + +\def\pack_layers_set_MP[#1][#2][#3]% + {\edef\MPlayerwidth {\MPw{#2}}% + \edef\MPlayerheight{\MPh{#2}}% + \setlayer[#1][\c!x=\MPx{#2},\c!y=\MPy{#2},\c!position=\v!no,#3]} + +\unexpanded\def\getMPlayer + {\dodoubleempty\pack_layers_get_MP} + +\def\pack_layers_get_MP[#1][#2]% + {\framed[\c!background={\v!foreground,#1},\c!frame=\v!off,\c!offset=\v!overlay,#2]} % takes argument + +%D Watch out, a redefinition: + +\ifdefined\settextpagecontent \else + \writestatus\m!system{error in page-lyr.tex} \wait +\fi + +\definelayer + [OTRTEXT] + +\setuplayer + [OTRTEXT] + [\c!width=\innermakeupwidth, + \c!height=\textheight] + +\let\normalsettextpagecontent\settextpagecontent % will be overloaded in page-spr + +\unexpanded\def\settextpagecontent#1#2#3% #2 and #3 will disappear + {\doifelselayerdata{OTRTEXT} + {\setbox#1\hpack to \makeupwidth + {\startoverlay + {\tightlayer[OTRTEXT]} % first, otherwise problems with toc + {\normalsettextpagecontent{#1}{#2}{#3}\box#1} + \stopoverlay}% + \dp#1\zeropoint}% + {\normalsettextpagecontent{#1}{#2}{#3}}} + +\protect \endinput diff --git a/tex/context/base/mkiv/pack-rul.mkxl b/tex/context/base/mkiv/pack-rul.mkxl index 0da5bff61..c913977c7 100644 --- a/tex/context/base/mkiv/pack-rul.mkxl +++ b/tex/context/base/mkiv/pack-rul.mkxl @@ -917,12 +917,12 @@ \edef\p_framed_background{\framedparameter\c!background}% % not here, in calling macro: setups \pack_framed_remove_depth - \ifx\p_framed_frame\v!overlay \else \ifx\p_framed_frame\v!none \else + \ifx\p_framed_frame\v!overlay \orelse \ifx\p_framed_frame\v!none \else \ifx\p_framed_rulethickness\empty\else \d_framed_linewidth\p_framed_rulethickness\relax \fi \pack_framed_add_outline % real or invisible frame - \fi\fi + \fi \ifx\p_framed_background\empty \else \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}% \d_framed_backgroundoffset @@ -935,10 +935,8 @@ \pack_framed_add_background \fi \pack_framed_restore_depth - \iftrialtypesetting \else - \ifx\m_overlay_region\empty\else - \pack_framed_add_region - \fi + \iftrialtypesetting\orelse\ifx\m_overlay_region\empty\else + \pack_framed_add_region \fi \box\b_framed_normal \egroup} @@ -956,12 +954,12 @@ \d_framed_frameoffset\framedparameter\c!frameoffset\relax % also used in backgrounds \edef\p_framed_frame{\framedparameter\c!frame}% \edef\p_framed_background{\framedparameter\c!background}% - \ifx\p_framed_frame\v!overlay \else \ifx\p_framed_frame\v!none \else + \ifx\p_framed_frame\v!overlay \orelse \ifx\p_framed_frame\v!none \else \ifx\p_framed_rulethickness\empty \else \d_framed_linewidth\p_framed_rulethickness\relax \fi \pack_framed_add_outline % real or invisible frame - \fi\fi + \fi \ifx\p_framed_background\empty \else \edef\p_framed_backgroundoffset{\framedparameter\c!backgroundoffset}% \d_framed_backgroundoffset @@ -1131,12 +1129,12 @@ % obey user set height, also downward compatible \else \edef\p_framed_lines{\framedparameter\c!lines}% - \ifx\p_framed_lines\empty\else - \ifcase\p_framed_lines\else - \d_framed_height\p_framed_lines\lineheight - \edef\localheight{\the\d_framed_height}% - \settrue\c_framed_has_height - \fi + \ifx\p_framed_lines\empty + \orelse\ifcase\p_framed_lines + \else + \d_framed_height\p_framed_lines\lineheight + \edef\localheight{\the\d_framed_height}% + \settrue\c_framed_has_height \fi \fi % this is now an option: width=local diff --git a/tex/context/base/mkiv/page-txt.mklx b/tex/context/base/mkiv/page-txt.mklx new file mode 100644 index 000000000..6029034e5 --- /dev/null +++ b/tex/context/base/mkiv/page-txt.mklx @@ -0,0 +1,969 @@ +% macros=mkvi + +%D \module +%D [ file=page-txt, % copied from main-001, +%D version=1997.03.31, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Texts, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Page Macros / Texts} + +\unprotect + +\newtoks\toptextcontent \newtoks\leftedgetextcontent +\newtoks\headertextcontent \newtoks\leftmargintextcontent +\newtoks\footertextcontent \newtoks\rightmargintextcontent +\newtoks\bottomtextcontent \newtoks\rightedgetextcontent + +\newtoks\texttextcontent + +%D \macros +%D {setuptop, setupheader, setuptext,setupfooter, setupbottom} +%D +%D The macros in this module sometimes look a bit more complicated than needed, +%D which is a direct result of the fact that their ancestors are quite old and +%D upward compatibility is a must. +%D +%D \showsetup{setuptop} +%D \showsetup{setupheader} +%D \showsetup{setuptext} +%D \showsetup{setupfooter} +%D \showsetup{setupbottom} + +\installcorenamespace{layouttexts} +\installcorenamespace{layouttextsline} +\installcorenamespace{layouttextsreset} +\installcorenamespace{layouttextssynchronize} +\installcorenamespace{layouttextstrut} +\installcorenamespace{layouttextspecial} +\installcorenamespace{layouttextcontent} + +\installcommandhandler \??layouttexts {layoutelement} \??layouttexts + +% \appendtoks +% \resetlayoutelementparameter\c!lefttext % resolves better +% \resetlayoutelementparameter\c!middletext +% \resetlayoutelementparameter\c!righttext +% \to \everydefinelayoutelement + +\definelayoutelement[\v!top ] +\definelayoutelement[\v!header] +\definelayoutelement[\v!text ] +\definelayoutelement[\v!footer] +\definelayoutelement[\v!bottom] + +\definelayoutelement[\v!top :\v!text] [\v!top ][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!header:\v!text] [\v!header][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!text :\v!text] [\v!text ][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!footer:\v!text] [\v!footer][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!bottom:\v!text] [\v!bottom][\c!lefttext=,\c!middletext=,\c!righttext=] + +\definelayoutelement[\v!top :\v!margin][\v!top ][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!header:\v!margin][\v!header][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!text :\v!margin][\v!text ][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!footer:\v!margin][\v!footer][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!bottom:\v!margin][\v!bottom][\c!lefttext=,\c!middletext=,\c!righttext=] + +\definelayoutelement[\v!top :\v!edge] [\v!top ][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!header:\v!edge] [\v!header][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!text :\v!edge] [\v!text ][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!footer:\v!edge] [\v!footer][\c!lefttext=,\c!middletext=,\c!righttext=] +\definelayoutelement[\v!bottom:\v!edge] [\v!bottom][\c!lefttext=,\c!middletext=,\c!righttext=] + +\unexpanded\def\setuplayouttext + {\dotripleempty\page_layouts_setup_text} + +\def\page_layouts_setup_text[#vertical][#horizontal][#settings]% + {\ifthirdargument + \setuplayoutelement[#vertical:#horizontal][#settings]% + \else + \setuplayoutelement[#vertical][#horizontal]% + \fi} + +\appendtoks + \ifx\currentlayoutelement\empty\else + \page_layouts_synchronize_element\currentlayoutelement % brr, can be vertical:horizontal + \fi +\to \everysetuplayoutelement + +\def\page_layouts_reset_element_status#vertical% + {\expandafter\normalgdef\csname\??layouttextsreset#vertical\endcsname{\page_layouts_set_element_status_normal#vertical}} + +\def\page_layouts_set_element_status_normal#vertical% + {\expandafter\glet\csname\namedlayoutelementhash#vertical\c!state\endcsname\v!normal + \expandafter\glet\csname\??layouttextsreset#vertical\endcsname\relax + \page_layouts_synchronize_element{#vertical}} + +\def\page_layouts_synchronize_element#vertical% + {\xdef\previoustextstate{\csname\??layouttextssynchronize#vertical\endcsname}% can be a let + \edef\currenttextstate {\namedlayoutelementparameter{#vertical}\c!state}% + %\writestatus{>>}{[#vertical:\currenttextstate/\previoustextstate]}% + \ifx\currenttextstate\previoustextstate \else + \page_layouts_synchronize_element_indeed{#vertical}% + \fi} + +\def\page_layouts_synchronize_element_indeed#vertical% + {\ifx\currenttextstate \v!high \calculatevsizes\page_backgrounds_recalculate \orelse + \ifx\previoustextstate\v!high \calculatevsizes\page_backgrounds_recalculate \orelse + \ifx\currenttextstate \v!none \calculatevsizes\page_backgrounds_recalculate \orelse + \ifx\previoustextstate\v!none \calculatevsizes\page_backgrounds_recalculate \fi + \letgvalue{\??layouttextssynchronize#vertical}\currenttextstate} + +\unexpanded\def\setuptop {\dotripleempty\page_layouts_setup_text[\v!top ]} +\unexpanded\def\setupheader{\dotripleempty\page_layouts_setup_text[\v!header]} +\unexpanded\def\setuptext {\dotripleempty\page_layouts_setup_text[\v!text ]} +\unexpanded\def\setupfooter{\dotripleempty\page_layouts_setup_text[\v!footer]} +\unexpanded\def\setupbottom{\dotripleempty\page_layouts_setup_text[\v!bottom]} + +%D We inherit some settings: + +\setuplayoutelement + [ \c!leftstyle=\layoutelementparameter\c!style, + \c!middlestyle=\layoutelementparameter\c!style, + \c!rightstyle=\layoutelementparameter\c!style, + \c!leftcolor=\layoutelementparameter\c!color, + \c!middlecolor=\layoutelementparameter\c!color, + \c!rightcolor=\layoutelementparameter\c!color, + \c!leftwidth=\layoutelementparameter\c!width, + \c!middlewidth=\layoutelementparameter\c!width, + \c!rightwidth=\layoutelementparameter\c!width] + +%D \macros +%D {noheaderandfooterlines,notopandbottomlines} +%D +%D Although not really needed, the following shortcuts sometimes come in handy. +%D +%D \showsetup{noheaderandfooterlines} +%D \showsetup{notopandbottomlines} + +\unexpanded\def\noheaderandfooterlines + {\setuplayoutelement[\v!header][\c!state=\v!empty]% + \setuplayoutelement[\v!footer][\c!state=\v!empty]} + +\unexpanded\def\notopandbottomlines + {\setuplayoutelement[\v!top ][\c!state=\v!empty]% + \setuplayoutelement[\v!bottom][\c!state=\v!empty]} + +%D \macros +%D {setuptoptexts,setupheadertexts,setuptexttexts,setupfootertexts,setupbottomtexts} +%D +%D The next macros take one or more arguments. The exact setup depends on the number +%D of arguments. Although not that intuitive, the current scheme evolved out of the +%D original. When margin and edge texts as well as middle texts showed up, the +%D current odd|/|even scheme surfaced. +%D +%D \showsetup{setuptoptexts} +%D \showsetup{setupheadertexts} +%D \showsetup{setuptexttexts} +%D \showsetup{setupfootertexts} +%D \showsetup{setupbottomtexts} +%D +%D Only the following have checking for pagenumber, date and mark built in, so when +%D someone uses the key|/|value interface these things have to be set explicitly as +%D part of the text. + +\unexpanded\def\setuptoptexts {\dosixtupleempty\page_layouts_setup_texts[\v!top ]} +\unexpanded\def\setupheadertexts{\dosixtupleempty\page_layouts_setup_texts[\v!header]} +\unexpanded\def\setuptexttexts {\dosixtupleempty\page_layouts_setup_texts[\v!text ]} +\unexpanded\def\setupfootertexts{\dosixtupleempty\page_layouts_setup_texts[\v!footer]} +\unexpanded\def\setupbottomtexts{\dosixtupleempty\page_layouts_setup_texts[\v!bottom]} + +\unexpanded\def\page_layouts_setup_text_six[#vertical][#horizontal][#a][#b][#c][#d]% + {\edef\currentlayoutelement{#vertical:#horizontal}% + \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_double{#a}{#d}}% + \setlayoutelementparameter\c!righttext{\page_layouts_process_element_double{#b}{#c}}} + +\unexpanded\def\page_layouts_setup_text_five[#vertical][#horizontal][#a][#b][#c][#d]% + {\edef\currentlayoutelement{#vertical:\v!text}% + \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_double{#horizontal}{#c}}% + \setlayoutelementparameter\c!righttext{\page_layouts_process_element_double{#a}{#b}}} + +\unexpanded\def\page_layouts_setup_text_four[#vertical][#horizontal][#a][#b][#c][#d]% + {\edef\currentlayoutelement{#vertical:#horizontal}% + \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_single{#a}}% + \setlayoutelementparameter\c!righttext{\page_layouts_process_element_single{#b}}} + +\unexpanded\def\page_layouts_setup_text_three[#vertical][#horizontal][#a][#b][#c][#d]% + {\edef\currentlayoutelement{#vertical:\v!text}% + \setlayoutelementparameter\c!lefttext {\page_layouts_process_element_single{#horizontal}}% + \setlayoutelementparameter\c!righttext{\page_layouts_process_element_single{#a}}} + +\unexpanded\def\page_layouts_setup_text_two[#vertical][#horizontal][#a][#b][#c][#d]% + {\edef\currentlayoutelement{#vertical:\v!text}% + \resetlayoutelementparameter\c!lefttext + \resetlayoutelementparameter\c!righttext + \setlayoutelementparameter \c!middletext{\page_layouts_process_element_single{#horizontal}}} + +\unexpanded\def\page_layouts_setup_text_one[#vertical][#horizontal][#a][#b][#c][#d]% + {\edef\currentlayoutelement{#vertical:\v!text}% + \resetlayoutelementparameter\c!lefttext + \resetlayoutelementparameter\c!righttext + \resetlayoutelementparameter\c!middletext + \edef\currentlayoutelement{#vertical:\v!margin}% + \resetlayoutelementparameter\c!lefttext + \resetlayoutelementparameter\c!righttext + \resetlayoutelementparameter\c!middletext + \edef\currentlayoutelement{#vertical:\v!edge}% + \resetlayoutelementparameter\c!lefttext + \resetlayoutelementparameter\c!righttext + \resetlayoutelementparameter\c!middletext} + +\unexpanded\def\page_layouts_setup_texts + {\ifsixthargument \expandafter\page_layouts_setup_text_six \orelse + \iffifthargument \expandafter\page_layouts_setup_text_five \orelse + \iffourthargument\expandafter\page_layouts_setup_text_four \orelse + \ifthirdargument \expandafter\page_layouts_setup_text_three\orelse + \ifsecondargument\expandafter\page_layouts_setup_text_two \else + \expandafter\page_layouts_setup_text_one \fi} + +%D Left and right texts are swapped on odd and even pages, but only when double +%D sided typesetting is enabled. + +\setvalue{\??layouttextstrut\v!yes}{\setstrut\strut} % maybe more variants + +\let\m_page_layouts_element_content\empty + +\unexpanded\def\page_layouts_process_element_single#content% + {\edef\m_page_layouts_element_content{\detokenize{#content}}% so no \v!xxx + \ifcsname\??layouttextspecial\m_page_layouts_element_content\endcsname + \lastnamedcs + \else + \doifelsemarking\m_page_layouts_element_content + {\getmarking[\m_page_layouts_element_content][\v!first]}% + {#content}% + \fi} + +\unexpanded\def\page_layouts_process_element_double#first#second% + {\doifelseoddpage + {\page_layouts_process_element_single{#first}} + {\page_layouts_process_element_single{#second}}} + +\unexpanded\def\page_layouts_process_element_indeed#style#color#width% + {\begingroup + \uselayoutelementstyleandcolor#style#color% + \begincsname\??layouttextstrut\layoutelementparameter\c!strut\endcsname + \ignorecrlf + \edef\currentlayoutelementwidth{\layoutelementparameter#width}% + \ifx\currentlayoutelementwidth\empty\else + \expandafter\page_layouts_process_element_limited + \fi\p_text + \endgroup} + +\def\page_layouts_process_element_limited#content% are the {}{}{} still needed? +% {\limitatetext{#content{}{}{}}\currentlayoutelementwidth\unknown} + {\limitated + left \currentlayoutelementwidth + text {#content} + sentinel {\unknown} + \relax} + +\setvalue{\??layouttextspecial\v!pagenumber}{\page_layouts_place_page_number} +\setvalue{\??layouttextspecial\v!date }{\currentdate} + +%D When specified, the texts are automatically limited in length. + +\appendtoks \page_layouts_place_text_line\v!top \topheight \to \toptextcontent +\appendtoks \page_layouts_place_text_line\v!header\headerheight \to \headertextcontent +\appendtoks \page_layouts_place_text_line\v!text \textheight \to \texttextcontent +\appendtoks \page_layouts_place_text_line\v!footer\footerheight \to \footertextcontent +\appendtoks \page_layouts_place_text_line\v!bottom\bottomheight \to \bottomtextcontent + +%D Texts can be disabled, moved up and ignored, depending in the \type {status} +%D variable. This is handled by the next couple of macros. + +\newcount\c_page_layouts_element_state_n + +\def\page_layouts_set_element_status#vertical% + {\c_page_layouts_element_state_n=0\namedlayoutelementparameter#vertical\c!n\relax + \ifcase\c_page_layouts_element_state_n + \edef\textlinestatus{\namedlayoutelementparameter#vertical\c!state}% + \else + \setxvalue{\namedlayoutelementhash#vertical\c!n}{\the\numexpr\c_page_layouts_element_state_n+\minusone}% + \let\textlinestatus\v!stop + \fi} + +\appendtoks + \doifinset\v!header\floatspecification{\setxvalue{\namedlayoutelementhash\v!header\c!n}{1}}% + \doifinset\v!footer\floatspecification{\setxvalue{\namedlayoutelementhash\v!footer\c!n}{1}}% +\to \everybeforeflushedpagefloat + +\unexpanded\def\page_layouts_place_text_line#vertical% + {\page_layouts_set_element_status#vertical\relax + \ifcsname\??layouttextsline\textlinestatus\endcsname + \expandafter\lastnamedcs + \else + \expandafter\page_layouts_place_text_line_unknown + \fi#vertical} + +\unexpanded\def\doifelselayouttextline#vertical% shown or not + {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}% + \ifx\currentlayoutelementstate\v!normal + \expandafter\firstoftwoarguments + \orelse\ifx\currentlayoutelementstate\v!start + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\unexpanded\def\doifelselayoutsomeline#vertical% present or not + {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}% + \ifx\currentlayoutelementstate\v!none + \expandafter\secondoftwoarguments + \orelse\ifx\currentlayoutelementstate\v!high + \expandafter\secondoftwoarguments + \else + \expandafter\firstoftwoarguments + \fi} + +\let\doiflayouttextlineelse\doifelselayouttextline +\let\doiflayoutsomelineelse\doifelselayoutsomeline + +\newconditional\resyncaftertextline + +\setvalue{\??layouttextsline\v!normal}{\page_layouts_place_text_line_indeed} +\setvalue{\??layouttextsline\empty }{\page_layouts_place_text_line_indeed} + +\letvalue{\??layouttextsline\v!none}\gobbletwoarguments +\letvalue{\??layouttextsline\v!stop}\gobbletwoarguments + +\setvalue{\??layouttextsline\v!high}#vertical#height% + {\global\settrue\resyncaftertextline + \page_layouts_reset_element_status#vertical} + +\setvalue{\??layouttextsline\v!empty}#vertical#height% + {\page_layouts_reset_element_status#vertical} + +\setvalue{\??layouttextsline\v!start}#vertical#height% + {\page_layouts_reset_element_status#vertical% + \page_layouts_place_text_line_indeed#vertical#height} + +\setvalue{\??layouttextsline\v!nomarking}#vertical#height% + {\bgroup + \page_layouts_reset_element_status#vertical% + \settrue\inhibitgetmarking + \page_layouts_place_text_line_indeed#vertical#height% + \egroup} + +% \setupheadertexts [11] +% \definetext [title] [header] [aa] +% \setupheadertexts [11] [22] +% \definetext [title] [header] [aa] [bb] +% \setupheadertexts [text] [11] [22] +% \definetext [title] [header] [text] [aa] [bb] +% \setupheadertexts [11] [22] [33] [44] +% \definetext [title] [header] [aa] [bb] [cc] [dd] +% \setupheadertexts [text] [11] [22] [33] [44] +% \definetext [title] [header] [text] [aa] [bb] [cc] [dd] + +\def\page_layouts_place_text_line_unknown#vertical#height% + {\global\settrue\resyncaftertextline + \begingroup % new + \page_layouts_reset_element_status#vertical% + \begincsname\namedlayoutelementhash{#vertical}\textlinestatus\endcsname + \begincsname\namedlayoutelementhash{#vertical:\v!text}\textlinestatus\endcsname + \begincsname\namedlayoutelementhash{#vertical:\v!margin}\textlinestatus\endcsname + \begincsname\namedlayoutelementhash{#vertical:\v!edge}\textlinestatus\endcsname + \page_layouts_place_text_line_indeed#vertical#height% + \endgroup} + +\letvalue{\??layouttextsline\s!unknown}\page_layouts_place_text_line_unknown + +%D The following macro has to be called after a page is flushed. + +\unexpanded\def\resetlayouttextlines % public + {\begincsname\??layouttextsreset\v!top \endcsname + \begincsname\??layouttextsreset\v!header\endcsname + \begincsname\??layouttextsreset\v!text \endcsname + \begincsname\??layouttextsreset\v!footer\endcsname + \begincsname\??layouttextsreset\v!bottom\endcsname + \ifconditional\resyncaftertextline + \calculateglobalvsizes + \page_backgrounds_recalculate + \global\setfalse\resyncaftertextline + \fi} + +\def\getspecificlayouttext#vertical#horizontal#what% + {\begincsname\namedlayoutelementhash{#vertical:#horizontal}#what\endcsname} + +% \settext[header][text][middle][xxx][yyy] + +\unexpanded\def\settextcontent + {\doquintupleempty\page_layouts_set_text_content} + +\def\page_layouts_set_text_content[#vertical][#horizontal][#one][#two][#three]% header text middle text/text + {\iffifthargument + \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext}% + {\page_layouts_process_element_double{#two}{#three}}% + \orelse\iffourthargument + \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\begincsname\??layouttextcontent\v!text:#one\endcsname\c!middletext}% + {\page_layouts_process_element_double{#two}{#two}}% + \orelse\ifthirdargument + \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\c!middletext}% + {\page_layouts_process_element_double{#one}{#one}}% + \fi} + +\let\currentlayoutelement\relax + +\unexpanded\def\resettextcontent + {\dotripleempty\page_layouts_reset_text_content} + +\def\page_layouts_reset_text_content[#vertical][#horizontal][#tag]% header text middle + {\edef\currentlayoutelement{#vertical:#horizontal}% + \ifthirdargument + \letvalueempty{\layoutelementhash\begincsname\??layouttextcontent\v!text:#tag\endcsname\c!middletext}% + \orelse\ifsecondargument + \resetlayoutelementparameter\c!lefttext + \resetlayoutelementparameter\c!middletext + \resetlayoutelementparameter\c!righttext + \fi} + +\letvalue{\??layouttextcontent\v!text:\c!middle}\c!middletext +\letvalue{\??layouttextcontent\v!text:\c!left }\c!lefttext +\letvalue{\??layouttextcontent\v!text:\c!right }\c!righttext + +%D The placement of a whole line is handled by the next two macros. These are hooked +%D into the general purpose token list registers mentioned before. + +\let\currentlayouttextline\relax + +\def\page_layouts_place_text_line_indeed#vertical#height% + {\let\currentlayouttextline#vertical% + \ifdim#height>\zeropoint\relax % prevents pagenumbers when zero height + \page_layouts_place_text_line_left_or_right{#height}% + \fi} + +\def\page_layouts_place_text_line_left_or_right#height% + {\goleftonpage + \setbox\b_page_layouts_element\vbox to #height + {\vsize#height\relax + %\hsize\zeropoint % hack so that e.g. after=\hairline gives predictable results + \hsize\totaltextwidth + \normalbaselines + \let\\\ignoredlinebreak + \let\crlf\ignoredlinebreak + \namedlayoutelementparameter\currentlayouttextline\c!before + \doifbothsidesoverruled + \page_layouts_place_text_line_right + \page_layouts_place_text_line_right + \page_layouts_place_text_line_left + \namedlayoutelementparameter\currentlayouttextline\c!after + \vkern\zeropoint}% keep the \dp, beware of \vtops, never change this! + \dp\b_page_layouts_element\zeropoint + \box\b_page_layouts_element + \vkern-#height\relax} + +\let\page_layouts_place_extra_text_left \empty % historic +\let\page_layouts_place_extra_text_right\empty % historic + +\def\page_layouts_place_text_line_right + {\hpack + {\ifdim\leftedgewidth>\zeropoint + \page_layouts_left_edge_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth + \fi + \ifdim\leftmarginwidth>\zeropoint + \page_layouts_left_margin_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth\zerocount + \fi + \ifdim\makeupwidth>\zeropoint + \page_layouts_text_body_element_l_m_r_e + \fi + \ifdim\rightmarginwidth>\zeropoint + \page_layouts_right_margin_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth\plusone + \fi + \ifdim\rightedgewidth>\zeropoint + \page_layouts_right_edge_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth + \fi}} + +\def\page_layouts_place_text_line_left + {\hpack + {\ifdim\leftedgewidth>\zeropoint + \page_layouts_left_edge_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth + \fi + \ifdim\leftmarginwidth>\zeropoint + \page_layouts_left_margin_element\c!righttext\c!rightstyle\c!rightcolor\c!rightwidth\zerocount + \fi + \ifdim\makeupwidth>\zeropoint + \page_layouts_text_body_element_e_r_m_l + \fi + \ifdim\rightmarginwidth>\zeropoint + \page_layouts_right_margin_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth\plusone + \fi + \ifdim\rightedgewidth>\zeropoint + \page_layouts_right_edge_element\c!lefttext\c!leftstyle\c!leftcolor\c!leftwidth + \fi}} + +\def\page_layouts_left_edge_element_indeed#text#style#color#width% + {\letfromlayoutelementparameter\p_text#text% + \ifx\p_text\empty\else + \hbox to \leftedgewidth\bgroup + \hss + \page_layouts_process_element_indeed#style#color#width% + \egroup + \else + \kern\leftedgewidth + \fi} + +\def\page_layouts_left_edge_element#text#style#color#width% + {\edef\currentlayoutelement{\currentlayouttextline:\v!edge}% + \page_layouts_place_element_indeed\leftedgewidth + {\page_layouts_left_edge_element_indeed#text#style#color#width}% + \kern\leftedgedistance} + +\def\page_layouts_right_edge_element_indeed#text#style#color#width% + {\letfromlayoutelementparameter\p_text#text% + \ifx\p_text\empty\else + \hbox to \rightedgewidth\bgroup + \page_layouts_process_element_indeed#style#color#width% + \hss + \egroup + \else + \kern\rightedgewidth + \fi} + +\def\page_layouts_right_edge_element#text#style#color#width% + {\edef\currentlayoutelement{\currentlayouttextline:\v!edge}% + \kern\rightedgedistance + \page_layouts_place_element_indeed\rightedgewidth + {\page_layouts_right_edge_element_indeed#text#style#color#width}} + +% margin needs checking! + +\def\page_layouts_left_margin_element_indeed#text#style#color#width#margintoo% + {\letfromlayoutelementparameter\p_text#text% + \ifx\p_text\empty + \kern\leftmarginwidth + \else + \hbox to \leftmarginwidth\bgroup + \hss + \page_layouts_process_element_indeed#style#color#width% + \egroup + \fi + \ifcase#margintoo\or + \letfromlayoutelementparameter\p_text\c!margintext + \ifx\p_text\empty\else + \kern-\leftmarginwidth + \hbox to \leftmarginwidth\bgroup + \hss + \p_text % styling ? + \egroup + \fi + \fi} + +\def\page_layouts_left_margin_element#text#style#color#width#margintoo% + {\edef\currentlayoutelement{\currentlayouttextline:\v!margin}% + \page_layouts_place_element_indeed\leftmarginwidth + {\page_layouts_left_margin_element_indeed#text#style#color#width#margintoo}% + \kern\leftmargindistance} + +\def\page_layouts_right_margin_element_indeed#text#style#color#width#margintoo% + {\letfromlayoutelementparameter\p_text#text% + \ifx\p_text\empty + \kern\rightmarginwidth + \else + \hbox to \rightmarginwidth\bgroup + \page_layouts_process_element_indeed#style#color#width% + \hss + \egroup + \fi + \ifcase#margintoo\or + \letfromlayoutelementparameter\p_text\c!margintext + \ifx\p_text\empty\else + \kern-\rightmarginwidth + \hbox to \rightmarginwidth\bgroup + \p_text % ? styling + \hss + \egroup + \fi + \fi} + +\def\page_layouts_right_margin_element#text#style#color#width#margintoo% + {\edef\currentlayoutelement{\currentlayouttextline:\v!margin}% + \kern\rightmargindistance + \page_layouts_place_element_indeed\rightmarginwidth + {\page_layouts_right_margin_element_indeed#text#style#color#width#margintoo}} + +\def\page_layouts_text_body_element_indeed_l_m_r_e + {\letfromlayoutelementparameter\p_text\c!lefttext + \ifx\p_text\empty + \ifx\page_layouts_place_extra_text_left\empty\else + \hbox to \makeupwidth\bgroup + \page_layouts_place_extra_text_left + \hss + \egroup + \kern-\makeupwidth + \fi + \else + \hbox to \makeupwidth\bgroup + \page_layouts_place_extra_text_left + \page_layouts_process_element_indeed\c!leftstyle\c!leftcolor\c!leftwidth% + \hss + \egroup + \kern-\makeupwidth + \fi + \letfromlayoutelementparameter\p_text\c!middletext + \ifx\p_text\empty\else + \hbox to \makeupwidth\bgroup + \hss + \page_layouts_process_element_indeed\c!middlestyle\c!middlecolor\c!middlewidth% + \hss + \egroup + \kern-\makeupwidth + \fi + \letfromlayoutelementparameter\p_text\c!righttext + \ifx\p_text\empty + \kern\makeupwidth + \else + \hbox to \makeupwidth\bgroup + \hss + \page_layouts_process_element_indeed\c!rightstyle\c!rightcolor\c!rightwidth% + \egroup + \fi} + +\def\page_layouts_text_body_element_indeed_e_r_m_l + {\letfromlayoutelementparameter\p_text\c!righttext + \ifx\p_text\empty\else + \hbox to \makeupwidth\bgroup + \page_layouts_process_element_indeed\c!rightstyle\c!rightcolor\c!rightwidth% + \hss + \egroup + \kern-\makeupwidth + \fi + \letfromlayoutelementparameter\p_text\c!middletext + \ifx\p_text\empty\else + \hbox to \makeupwidth\bgroup + \hss + \page_layouts_process_element_indeed\c!middlestyle\c!middlecolor\c!middlewidth% + \hss + \egroup + \kern-\makeupwidth + \fi + \letfromlayoutelementparameter\p_text\c!lefttext + \ifx\p_text\empty + \ifx\page_layouts_place_extra_text_right\empty + \kern\makeupwidth + \else + \hbox to \makeupwidth\bgroup + \hss + \page_layouts_place_extra_text_right + \egroup + \fi + \else + \hbox to \makeupwidth\bgroup + \hss + \page_layouts_process_element_indeed\c!leftstyle\c!leftcolor\c!leftwidth% + \page_layouts_place_extra_text_right + \egroup + \fi} + +\def\page_layouts_text_body_element_l_m_r_e + {\edef\currentlayoutelement{\currentlayouttextline:\v!text}% + \page_layouts_place_element_indeed\makeupwidth\page_layouts_text_body_element_indeed_l_m_r_e} + +\def\page_layouts_text_body_element_e_r_m_l + {\edef\currentlayoutelement{\currentlayouttextline:\v!text}% + \page_layouts_place_element_indeed\makeupwidth\page_layouts_text_body_element_indeed_e_r_m_l} + +\def\page_layouts_place_element_indeed#width#content% + {\vbox % to \vsize + {\hsize#width\relax + \layoutelementparameter\c!before + \setlayoutcomponentattribute\currentlayoutelement + \hbox \layoutcomponentboxattribute to #width{#content}% + \layoutelementparameter\c!after}} + +%D Although it is far better to use backgrounds for this purpose, one can add a rule +%D in the following way. This method makes the rules disappear in case of an empty +%D text line. Consider this a feature. +%D +%D \starttyping +%D \setupheadertexts[left][right] +%D +%D \setupheader[text][after=\hrule,style=bold] +%D +%D \starttext +%D \input tufte \page +%D \setupheader[state=empty] +%D \input tufte \page +%D \stoptext +%D \stoptyping + +%D This code will move to \type {page-flt.tex}. + +\appendtoks \placerightmarginblock \kern-\rightmarginwidth \to \rightmargintextcontent +\appendtoks \placeleftmarginblock \kern-\leftmarginwidth \to \leftmargintextcontent + +%D \macros +%D {definetext} +%D +%D Some macros ago, we implemented the \type {status} option \type {unknown}. This +%D one is used to take care of symbolic texts handlers. +%D +%D \showsetup{definetext} +%D +%D The next example demonstrates how we can use this mechanism to provide page +%D (event) dependent text lines. +%D +%D \starttyping +%D \definetext[chapter][footer][pagenumber] +%D \setuphead[chapter][header=high,footer=chapter] +%D \setupheadertexts[pagenumber] +%D \setupfootertexts[left][right] +%D \chapter{eerste} \dorecurse{20}{\input tufte \relax} +%D \chapter{tweede} \dorecurse{20}{\input tufte \relax} +%D \stoptyping + +\unexpanded\def\definetext + {\doseventupleempty\page_layouts_define_text} + +\def\page_layouts_define_text[#tag][#vertical][#horizontal][#a][#b][#c][#d]% + {\ifseventhargument + \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}{\page_layouts_setup_text_six {#vertical}{#horizontal}{#a}{#b}{#c}{#d}}% + \orelse\ifsixthargument + \setvalue{\namedlayoutelementhash {#vertical}#tag}{\page_layouts_setup_text_five {#vertical}{#horizontal}{#a}{#b}{#c}}% + \orelse\iffifthargument + \setvalue{\namedlayoutelementhash{#vertical:#horizontal}#tag}{\page_layouts_setup_text_four {#vertical}{#horizontal}{#a}{#b}}% + \orelse\iffourthargument + \setvalue{\namedlayoutelementhash {#vertical}#tag}{\page_layouts_setup_text_three{#vertical}{#horizontal}{#a}}% + \else + \setvalue{\namedlayoutelementhash {#vertical}#tag}{\page_layouts_setup_text_two {#vertical}{#horizontal}}% + \fi} + +%D A few more page breakers: + +\installpagebreakmethod \v!empty + {\page_otr_flush_all_floats + \page_otr_command_next_page + \doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!empty]}% + \doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}% + \page_otr_insert_dummy_page} + +\installpagebreakmethod \v!header + {\doifnot{\namedlayoutelementparameter\v!header\c!state}\v!stop{\setuplayoutelement[\v!header][\c!state=\v!empty]}} + +\installpagebreakmethod \v!footer + {\doifnot{\namedlayoutelementparameter\v!footer\c!state}\v!stop{\setuplayoutelement[\v!footer][\c!state=\v!empty]}} + +%D While the header and footer lines are moved away from the main text, the top and +%D bottom lines are centered. + +\setuplayoutelement[\v!top ][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=] +\setuplayoutelement[\v!header][\c!state=\v!normal,\c!n=0,\c!before=, \c!after=\vss,\c!strut=\v!yes] +\setuplayoutelement[\v!text ][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=] +\setuplayoutelement[\v!footer][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=, \c!strut=\v!yes] +\setuplayoutelement[\v!bottom][\c!state=\v!normal,\c!n=0,\c!before=\vss,\c!after=\vss,\c!strut=] + +%D Moved here from strc-pag: +%D +%D We reset a previous location but only when it has a pagenumber associated. This +%D is a rather messy test but better than the MkII way where we use states and keep +%D settings. + +\let\m_page_layouts_page_number_location \relax +\let\m_page_layouts_page_number_location_v\relax +\let\m_page_layouts_page_number_location_h\relax +\let\m_page_layouts_page_number_location_x\relax + +\def\page_layouts_place_page_number % also elsewhere .. beware, not \unexpanded else + {\strc_pagenumbers_place_location} % test below fails + +\def\page_layouts_reset_page_number_location + {\ifx\m_page_layouts_page_number_location_v\relax\else + \edef\currentlayoutelement{\m_page_layouts_page_number_location_v:\m_page_layouts_page_number_location_h}% + \edef\page_layouts_previous_page_number_locator{\detokenizedlayoutelementparameter\m_page_layouts_page_number_location_x}% + \doif{\meaning\page_layouts_previous_page_number_locator}{\meaning\page_layouts_place_page_number} + {\resetlayoutelementparameter\m_page_layouts_page_number_location_x}% + \fi} + +\def\page_layouts_set_page_number_location + {\edef\currentlayoutelement{\m_page_layouts_page_number_location_v:\m_page_layouts_page_number_location_h}% + \letlayoutelementparameter\m_page_layouts_page_number_location_x\page_layouts_place_page_number + \ifx\m_page_layouts_page_number_location_x\c!marginedgetext + \let\page_layouts_place_extra_text_left \page_layouts_place_page_number_left + \let\page_layouts_place_extra_text_right\page_layouts_place_page_number_right + \else + \let\page_layouts_place_extra_text_left \empty + \let\page_layouts_place_extra_text_right\empty + \fi} + +\def\page_layouts_identify_page_number_location + {\let\m_page_layouts_page_number_location_v\v!footer + \let\m_page_layouts_page_number_location_h\v!text + \let\m_page_layouts_page_number_location_x\c!middletext + \processallactionsinset[\directpagenumberingparameter\c!location] + [ \v!header=>\let\m_page_layouts_page_number_location_v\v!header, + \v!footer=>\let\m_page_layouts_page_number_location_v\v!footer, + \v!middle=>\let\m_page_layouts_page_number_location_h\v!text + \let\m_page_layouts_page_number_location_x\c!middletext, + \v!left=>\let\m_page_layouts_page_number_location_h\v!text + \let\m_page_layouts_page_number_location_x\c!lefttext, + \v!right=>\let\m_page_layouts_page_number_location_h\v!text + \let\m_page_layouts_page_number_location_x\c!righttext, + \v!inleft=>\let\m_page_layouts_page_number_location_h\v!margin + \let\m_page_layouts_page_number_location_x\c!lefttext, + \v!inright=>\let\m_page_layouts_page_number_location_h\v!margin + \let\m_page_layouts_page_number_location_x\c!righttext, + \v!inmargin=>\let\m_page_layouts_page_number_location_h\v!margin + \def\m_page_layouts_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi}, + \v!margin=>\let\m_page_layouts_page_number_location_h\v!margin + \def\m_page_layouts_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi}, + \v!atmargin=>\let\m_page_layouts_page_number_location_h\v!text + \let\m_page_layouts_page_number_location_x\c!marginedgetext, + \v!marginedge=>\let\m_page_layouts_page_number_location_h\v!text + \let\m_page_layouts_page_number_location_x\c!marginedgetext]} + +\unexpanded\def\strc_pagenumbers_set_location + {\edef\p_strc_pagenumbers_location{\directpagenumberingparameter\c!location}% + \ifx\p_strc_pagenumbers_location\m_page_layouts_page_number_location + % unchanged + \else + \let\m_page_layouts_page_number_location\p_strc_pagenumbers_location + \page_layouts_reset_page_number_location + \ifx\p_strc_pagenumbers_location\empty + % set otherwise + \orelse\ifx\p_strc_pagenumbers_location\v!none + % set otherwise + \else + \page_layouts_identify_page_number_location + \page_layouts_set_page_number_location + \fi + \fi} + +\def\page_layouts_place_page_number_left % historic + {\begingroup + \setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}% + \ifzeropt\wd\scratchbox\else + \edef\p_strc_pagenumbers_width{\directpagenumberingparameter\c!width}% + \ifx\p_strc_pagenumbers_width\empty + \box\scratchbox\tfskip + \else + \hpack to \p_strc_pagenumbers_width{\box\scratchbox\hss}% + \fi + \fi + \endgroup} + +\def\page_layouts_place_page_number_right % historic + {\begingroup + \setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}% + \ifzeropt\wd\scratchbox\else + \edef\p_strc_pagenumbers_width{\directpagenumberingparameter\c!width}% + \ifx\p_strc_pagenumbers_width\empty + \tfskip\box\scratchbox + \else + \hpack to \p_strc_pagenumbers_width{\hss\box\scratchbox}% + \fi + \fi + \endgroup} + +\strc_pagenumbers_set_location % initializes + +\newbox\b_page_layouts_element + +\def\page_layouts_insert_elements + {\ifcase\pageornamentstate + \page_layouts_place_elements_indeed % we could have a special flag for always ignored + \fi} + +\def\page_layouts_place_elements_indeed + {\setbox\b_page_layouts_element\vpack + {\dontcomplain + \calculatereducedvsizes + \swapmargins + \offinterlineskip + \vkern\dimexpr-\topheight-\topdistance\relax + \the\toptextcontent + \vkern\dimexpr\topheight+\topdistance\relax + \the\headertextcontent + \vkern\dimexpr\headerheight+\headerdistance+\textdistance\relax + \anch_positions_place_anchors + \vkern\dimexpr-\textdistance-\textheight\relax + \the\texttextcontent + \vkern\textheight + \the\everyendoftextbody + \vkern\footerdistance + \the\footertextcontent + \vkern\dimexpr\footerheight+\bottomdistance\relax + \the\bottomtextcontent + \vkern\bottomheight + \vfilll}% + \smashbox\b_page_layouts_element + \box\b_page_layouts_element} + +% \ifdefined\page_prepare_backgrounds\else +% \let\page_prepare_backgrounds\gobbleoneargument +% \fi + +% only for very special controlled cases or experiments: + +\let\page_scale_text_box\gobbleoneargument + +\def\page_insert_body#1#2% + {\setbox\b_page_layouts_element\vpack + {\offinterlineskip + \calculatereducedvsizes + \calculatehsizes + \swapmargins + \vkern\dimexpr\headerheight+\headerdistance+\textdistance\relax + \dontleavehmode + %\page_prepare_backgrounds{#2}% + \hpack to \makeupwidth + {\begingroup + \swapmargins + \goleftonpage + \ifdim\leftedgewidth>\zeropoint + \the\leftedgetextcontent + \kern\dimexpr\leftedgewidth+\leftedgedistance\relax + \fi + \ifdim\leftmarginwidth>\zeropoint + \the\leftmargintextcontent + \kern\dimexpr\leftmarginwidth+\leftmargindistance\relax + \fi + \endgroup + \page_postprocessors_page{#2}% + \settextpagecontent\b_page_layouts_element{#1}{#2}% + \page_backgrounds_add_to_text\b_page_layouts_element + \page_grids_add_to_box\b_page_layouts_element + \page_scale_text_box\b_page_layouts_element + \box\b_page_layouts_element + \begingroup + \ifdim\rightmarginwidth>\zeropoint + \kern\rightmargindistance + \the\rightmargintextcontent + \kern\rightmarginwidth + \fi + \ifdim\rightedgewidth>\zeropoint + \kern\rightedgedistance + \the\rightedgetextcontent + \kern\rightedgewidth + \fi + \endgroup + \hss}}% + \smashbox\b_page_layouts_element + \box\b_page_layouts_element} + +%D The main text area has to be combined with some additional (tracing) information. +%D +%D This will be stored as normal and overloaded in page-lyr and later in page-spr we +%D overload the the stored version .. evenatually i will clear up the experimental +%D mess. + +\def\settextpagecontent#1#2#3% #2 and #3 will disappear / is overloaded + {\setbox#1\hpack to \makeupwidth + {\hss % so don't change this + \setlayoutcomponentattribute{\v!page:\v!text}% + \vpack \layoutcomponentboxattribute to \textheight + {\offinterlineskip + \freezetextwidth + \hsize\textwidth % local variant of \sethsize <<< in columns? + \boxmaxdepth\maxdepth + \noindent % content can be < \hsize + \page_otr_command_package_contents#2#3}% this will vbox + \hss}% + \dp#1\zeropoint} + +\protect \endinput diff --git a/tex/context/base/mkiv/page-txt.mkvi b/tex/context/base/mkiv/page-txt.mkvi index 2f0ac72de..4b3702ad7 100644 --- a/tex/context/base/mkiv/page-txt.mkvi +++ b/tex/context/base/mkiv/page-txt.mkvi @@ -25,12 +25,11 @@ \newtoks\texttextcontent %D \macros -%D {setuptop, setupheader, setuptext, -%D setupfooter, setupbottom} +%D {setuptop, setupheader, setuptext,setupfooter, setupbottom} %D -%D The macros in this module sometimes look a bit more complicated than -%D needed, which is a direct result of the fact that their ancestors are -%D quite old and upward compatibility is a must. +%D The macros in this module sometimes look a bit more complicated than needed, +%D which is a direct result of the fact that their ancestors are quite old and +%D upward compatibility is a must. %D %D \showsetup{setuptop} %D \showsetup{setupheader} @@ -136,8 +135,7 @@ %D \macros %D {noheaderandfooterlines,notopandbottomlines} %D -%D Although not really needed, the following shortcuts -%D sometimes come in handy. +%D Although not really needed, the following shortcuts sometimes come in handy. %D %D \showsetup{noheaderandfooterlines} %D \showsetup{notopandbottomlines} @@ -151,8 +149,7 @@ \setuplayoutelement[\v!bottom][\c!state=\v!empty]} %D \macros -%D {setuptoptexts, setupheadertexts, setuptexttexts, -%D setupfootertexts, setupbottomtexts} +%D {setuptoptexts,setupheadertexts,setuptexttexts,setupfootertexts,setupbottomtexts} %D %D The next macros take one or more arguments. The exact setup depends on the number %D of arguments. Although not that intuitive, the current scheme evolved out of the @@ -171,11 +168,6 @@ \unexpanded\def\setupfootertexts{\dosixtupleempty\page_layouts_setup_texts[\v!footer ]} \unexpanded\def\setupbottomtexts{\dosixtupleempty\page_layouts_setup_texts[\v!bottom ]} -% todo: \setuplayoutelementtext - -%D An alternative approach is to have more variables but that does not make the code -%D less complex (probably more). - \unexpanded\def\page_layouts_setup_text_six#vertical#horizontal#a#b#c#d% {\edef\currentlayoutelement{#vertical:#horizontal}% \setlayoutelementparameter\c!lefttext @@ -320,22 +312,6 @@ %D When specified, the texts are automatically limited in length. -% % where used ? -% -% \def\page_layouts_limitate_element_text#width% -% {\edef\currentlayoutelementwidth{\layoutelementparameter#width}% -% \ifx\currentlayoutelementwidth\empty -% \expandafter\firstofoneargument -% \else -% \expandafter\page_layouts_limitate_element_text_indeed -% \fi} -% -% \def\page_layouts_limitate_element_text_indeed#content% -% {\limitatetext{#content}\currentlayoutelementwidth\unknown} - -%D The placement of text is hooked into the token lists -%D associated to the area at hand. - \appendtoks \page_layouts_place_text_line\v!top \topheight \to \toptextcontent \appendtoks \page_layouts_place_text_line\v!header\headerheight \to \headertextcontent \appendtoks \page_layouts_place_text_line\v!text \textheight \to \texttextcontent @@ -814,10 +790,6 @@ \strc_pagenumbers_set_location % initializes -% will go to page-box.mkiv - -% the next macros will be redone (less boxing) - \newbox\b_page_layouts_element \def\page_layouts_insert_elements diff --git a/tex/context/base/mkiv/spac-ver.mkxl b/tex/context/base/mkiv/spac-ver.mkxl index d15105e80..e939242cb 100644 --- a/tex/context/base/mkiv/spac-ver.mkxl +++ b/tex/context/base/mkiv/spac-ver.mkxl @@ -64,12 +64,20 @@ \def\skipfactor {.75} \def\skipgluefactor{.25} +% \def\normalskipamount +% {\openlineheight +% \ifgridsnapping \else \ifblankflexible +% \s!plus \skipgluefactor\openlineheight +% \s!minus\skipgluefactor\openlineheight +% \fi \fi +% \relax} + \def\normalskipamount {\openlineheight - \ifgridsnapping \else \ifblankflexible + \ifgridsnapping \orelse \ifblankflexible \s!plus \skipgluefactor\openlineheight \s!minus\skipgluefactor\openlineheight - \fi \fi + \fi \relax} \ifdefined\bodyfontinterlinespace \else diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 096af2970..b8ef17696 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 05edff1b1..59583eef9 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-itm.mklx b/tex/context/base/mkiv/strc-itm.mklx index 959801c8b..fcf67c7f5 100644 --- a/tex/context/base/mkiv/strc-itm.mklx +++ b/tex/context/base/mkiv/strc-itm.mklx @@ -1448,9 +1448,9 @@ {\box\b_strc_itemgroups\hskip\itemgroupparameter\c!distance}}} \def\strc_itemgroups_make_destination_box - {\iftrialtypesetting \else \ifx\m_strc_itemgroups_destination\empty \else + {\iftrialtypesetting \orelse \ifx\m_strc_itemgroups_destination\empty \else \setbox\b_strc_itemgroups\hbox{\directgotobox{\box\b_strc_itemgroups}[\m_strc_itemgroups_destination]}% - \fi\fi} + \fi} \def\strc_itemgroups_check_indenting {\setfalse\c_strc_itemgroups_indented_first diff --git a/tex/context/base/mkiv/supp-box.lua b/tex/context/base/mkiv/supp-box.lua index f2da9155b..323274bea 100644 --- a/tex/context/base/mkiv/supp-box.lua +++ b/tex/context/base/mkiv/supp-box.lua @@ -26,6 +26,7 @@ local disc_code = nodecodes.disc local hlist_code = nodecodes.hlist local vlist_code = nodecodes.vlist local glue_code = nodecodes.glue +local penalty_code = nodecodes.penalty local glyph_code = nodecodes.glyph local nuts = nodes.nuts @@ -49,6 +50,7 @@ local takebox = nuts.takebox local setlink = nuts.setlink local setboth = nuts.setboth local setnext = nuts.setnext +local setprev = nuts.setprev local setbox = nuts.setbox local setlist = nuts.setlist local setdisc = nuts.setdisc @@ -56,6 +58,8 @@ local setwidth = nuts.setwidth local setheight = nuts.setheight local setdepth = nuts.setdepth local setshift = nuts.setshift +local setsplit = nuts.setsplit +local setattrlist = nuts.setattrlist local flush_node = nuts.flush_node local flush_list = nuts.flush_list @@ -64,6 +68,9 @@ local copy_list = nuts.copy_list local find_tail = nuts.tail local getdimensions = nuts.dimensions local hpack = nuts.hpack +local traverse_id = nuts.traverse_id +local free = nuts.free +local findtail = nuts.tail local nextdisc = nuts.traversers.disc local nextdir = nuts.traversers.dir @@ -648,3 +655,162 @@ implement { texsetdimen("givendepth", t.depth or 0) end, } + +local function stripglue(list) + local done = false + local first = list + while first do + local id = getid(first) + if id == glue_code or id == penalty_code then + first = getnext(first) + else + break + end + end + if first and first ~= list then + -- we have discardables + setsplit(getprev(first),first) + flush_list(list) + list = first + done = true + end + if list then + local tail = findtail(list) + local last = tail + while last do + local id = getid(last) + if id == glue_code or id == penalty_code then + last = getprev(last) + else + break + end + end + if last ~= tail then + -- we have discardables + flush_list(getnext(last)) + setnext(last) + done = true + end + end + return list, done +end + +local function limitate(t) + local text = t.text + if text then + text = tonut(text) + else + return + end + local sentinel = t.sentinel + if sentinel then + sentinel = tonut(sentinel) + local s = getlist(sentinel) + setlist(sentinel) + free(sentinel) + sentinel = s + else + return tonode(text) + end + local list = getlist(text) + local width = getwidth(text) + local done = false + if t.strip then + list, done = stripglue(list) + if not list then + setlist(text) + setwidth(text,0) + return text + elseif done then + width = getdimensions(list) + setlist(text,list) + end + end + local left = t.left or 0 + local right = t.right or 0 + if left + right >= width then + if done then + setwidth(text,width) + end + return tonode(text) + end + local last = nil + local first = nil + local maxleft = left + local maxright = right + local swidth = getwidth(sentinel) + if maxright > 0 then + maxleft = maxleft - swidth/2 + maxright = maxright - swidth/2 + else + maxleft = maxleft - swidth + end + for n in traverse_id(glue_code,list) do + local width = getdimensions(list,n) + if width > maxleft then + if not last then + last = n + end + break + else + last = n + end + end + if last and maxright > 0 then + for n in traverse_id(glue_code,last) do + local width = getdimensions(n) + if width < maxright then + first = n + break + else + first = n + end + end + end + if last then + local rest = getnext(last) + if rest then + local tail = findtail(sentinel) + if first and getid(first) == glue_code and getid(tail) == glue_code then + setwidth(first,0) + end + if last and getid(last) == glue_code and getid(sentinel) == glue_code then + setwidth(last,0) + end + if first and first ~= last then + local prev = getprev(first) + if prev then + setnext(prev) + end + setlink(tail,first) + end + setlink(last,sentinel) + setprev(rest) + flush_list(rest) + end + end + local result = hpack(list) + setattrlist(result,text) + setlist(text) + free(text) + return tonode(result) +end + +interfaces.implement { + name = "limitated", + public = true, + protected = true, + arguments = { + { + { "left", "dimension" }, + { "right", "dimension" }, + { "text", "hbox" }, + { "sentinel", "hbox" }, + { "strip", "boolean" }, + } + }, + actions = function(t) + context.dontleavehmode() + context(limitate(t)) + end, +} diff --git a/tex/context/base/mkiv/supp-box.mkiv b/tex/context/base/mkiv/supp-box.mkiv index 4a8ff33f8..bdd20b497 100644 --- a/tex/context/base/mkiv/supp-box.mkiv +++ b/tex/context/base/mkiv/supp-box.mkiv @@ -541,7 +541,7 @@ %D \determinenoflines{\definedfont[Sans at 40pt]test\\test} %D \stoptyping -\def\dodeterminenoflines % can be mkiv'd +\def\syst_boxes_determine_noflines % can be mkiv'd {\beginofshapebox \unvbox\nextbox \endofshapebox @@ -554,7 +554,7 @@ \forgetall \let\crlf\endgraf \let\\\endgraf - \dowithnextboxcs\dodeterminenoflines\vbox} + \dowithnextboxcs\syst_boxes_determine_noflines\vbox} %D \macros %D {doiftextelse, doiftext} @@ -677,10 +677,10 @@ %D The next couple of shortcuts saves us memory as well as \type {{}}'s in passing %D parameters. -\def\nextboxht {\ht\nextbox} -\def\nextboxwd {\wd\nextbox} -\def\nextboxdp {\dp\nextbox} -\def\nextboxhtdp {\dimexpr\ht\nextbox+\dp\nextbox\relax} +\def\nextboxht {\ht\nextbox} +\def\nextboxwd {\wd\nextbox} +\def\nextboxdp {\dp\nextbox} +\def\nextboxhtdp{\dimexpr\ht\nextbox+\dp\nextbox\relax} \unexpanded\def\flushnextbox{\box\nextbox} @@ -1277,6 +1277,7 @@ \let\speciallimitatetext\firstoffourarguments \setbox\scratchboxone\hbox {\nohyphens + \dontcomplain \normallimitatetext{#1}{+#2}{}#4% \normallimitatetext{#1}{-#3}{}}% \setbox\scratchboxtwo\hbox @@ -1467,7 +1468,7 @@ %D complicated menus, headers and footers and|/|or margin material. \unexpanded\def\sbox - {\vbox\bgroup + {\vpack\bgroup \dowithnextboxcs\syst_boxes_sbox_finish\vbox} \unexpanded\def\syst_boxes_sbox_finish @@ -1481,6 +1482,10 @@ \egroup} %D A variant on this: +%D +%D \starttyping +%D xx \ruledhbox{\inlinedbox{\tfd test}} xx +%D \stoptyping \unexpanded\def\inlinedbox {\bgroup @@ -2273,11 +2278,11 @@ \unexpanded\def\limitatelines#1#2% size sentinel {\dowithnextbox - {\dimen0=#1\hsize - \ifdim\wd\nextbox>\dimen0 + {\scratchdimen#1\hsize + \ifdim\wd\nextbox>\scratchdimen \setbox\nextbox\hbox - {\advance\dimen0 -.1\hsize - \limitatetext{\unhbox\nextbox}{\dimen0}{\nobreak#2}}% + {\advance\scratchdimen -.1\hsize + \limitatetext{\unhbox\nextbox}{\scratchdimen}{\nobreak#2}}% \fi \unhbox\nextbox} \hbox} @@ -2286,14 +2291,14 @@ {\dowithnextbox {\bgroup \par - \dimen0\ht\nextbox + \scratchdimen\ht\nextbox \ht\nextbox\strutht \dp\nextbox\strutdp \hpack{\box\nextbox} \prevdepth\strutdp \doloop - {\advance\dimen0 -\lineheight - \ifdim\dimen0<\zeropoint + {\advance\scratchdimen -\lineheight + \ifdim\scratchdimen<\zeropoint \exitloop \else \nobreak @@ -2841,12 +2846,6 @@ %D A bit dirty: -% \unexpanded\def\nodestostring#1% \cs {content} -% {\dowithnextbox{\edef#1{\syst_boxes_nodestostring}}\hbox} -% -% \def\syst_boxes_nodestostring -% {\clf_boxtostring\nextbox} - \unexpanded\def\nodestostring#1#2% more tolerant for #2=\cs {\begingroup \setbox\nextbox\hbox{#2}% diff --git a/tex/context/base/mkiv/supp-box.mkxl b/tex/context/base/mkiv/supp-box.mkxl index a77327b3e..42f17f03d 100644 --- a/tex/context/base/mkiv/supp-box.mkxl +++ b/tex/context/base/mkiv/supp-box.mkxl @@ -29,37 +29,6 @@ \newdimen\givenheight \newdimen\givendepth -% handy to have -% -% \hbox to \hsize -% {\en -% \switchnaarkorps[5pt]% -% \emergencystretch2em -% \dimen0=\baselineskip -% \baselineskip=\dimen0 plus 1pt -% \hsize=.2\hsize -% \vsize=2\hsize -% \ruledvbox to \vsize{\input tufte \par}\hss -% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth}\hss -% \ruledvbox to \vsize{\input tufte \par\kern0pt}\hss -% \ruledvbox to \vsize{\input tufte \par\vfill}\hss -% \ruledvbox to \vsize{\input tufte \par\kern-\prevdepth\vfill}} -% -% \hbox to \hsize -% {\en -% \switchnaarkorps[5pt]% -% \emergencystretch2em -% \dimen0=\baselineskip -% \baselineskip=\dimen0 plus 1pt -% \hsize=.18\hsize -% \vsize=2.5\hsize -% \setbox0=\vbox{\input tufte\relax}% -% \ruledvbox to \vsize{\unvcopy0}\hss -% \ruledvbox to \vsize{\unvcopy0\kern-\dp0}\hss -% \ruledvbox to \vsize{\unvcopy0\kern0pt}\hss -% \ruledvbox to \vsize{\unvcopy0\vfill}\hss -% \ruledvbox to \vsize{\unvcopy0\kern-\dp0\vfill}} - %D \macros %D {dontcomplain} %D @@ -230,17 +199,6 @@ %D catcode safer. It is needed by the math module (although the \type {\leavevmode} %D is not added here). -% \unexpanded\def\smash -% {\begingroup -% \futurelet\nexttoken\syst_boxes_smash} -% -% \def\syst_boxes_smash -% {\ifx\nexttoken[% -% \expandafter\syst_boxes_smash_yes -% \else -% \expandafter\syst_boxes_smash_nop -% \fi} - \unexpanded\def\smash {\begingroup \futureexpandis[\syst_boxes_smash_yes\syst_boxes_smash_nop} @@ -295,9 +253,6 @@ \def\syst_boxes_lower_nextbox_dp {\setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}} -% \def\syst_boxes_lower_nextbox_dp -% {\boxymove\nextbox-\dp\nextbox} - %D \starttabulate[|l|l|] %D \NC w \NC \ruledhbox{\smash [w]{This is some great smashing, isn't it?}} \NC \NR %D \NC h \NC \ruledhbox{\smash [h]{This is some great smashing, isn't it?}} \NC \NR @@ -416,10 +371,6 @@ %D The next alternative is slightly more clever, since it accepts \type {{12}} as %D well as \type {12} as box number. -% \unexpanded\def\getboxheight#1\of#2\box#3% -% {\def\next{#1\dimexpr\ht\c_boxes_register+\dp\c_boxes_register\relax}% -% \afterassignment\next\c_boxes_register=#3} - \unexpanded\def\getboxheight#1\of#2\box#3% {\def\next{#1\htdp\c_boxes_register}% \afterassignment\next\c_boxes_register=#3} @@ -552,7 +503,7 @@ %D \determinenoflines{\definedfont[Sans at 40pt]test\\test} %D \stoptyping -\def\dodeterminenoflines % can be mkiv'd +\def\syst_boxes_determine_noflines % can be mkiv'd {\beginofshapebox \unvbox\nextbox \endofshapebox @@ -565,7 +516,7 @@ \forgetall \let\crlf\endgraf \let\\\endgraf - \dowithnextboxcs\dodeterminenoflines\vbox} + \dowithnextboxcs\syst_boxes_determine_noflines\vbox} %D \macros %D {doiftextelse, doiftext} @@ -692,10 +643,10 @@ %D The next couple of shortcuts saves us memory as well as \type {{}}'s in passing %D parameters. -\def\nextboxht {\ht\nextbox} -\def\nextboxwd {\wd\nextbox} -\def\nextboxdp {\dp\nextbox} -\def\nextboxhtdp {\htdp\nextbox} +\def\nextboxht {\ht\nextbox} +\def\nextboxwd {\wd\nextbox} +\def\nextboxdp {\dp\nextbox} +\def\nextboxhtdp{\htdp\nextbox} \unexpanded\def\flushnextbox{\box\nextbox} @@ -1172,7 +1123,7 @@ \def\dodoboundtext#1% {\setbox\scratchboxone\hbox{#1}% \advance\scratchdimen -\wd\scratchboxone - \ifdim\scratchdimen>\zeropoint\relax#1\fi}% + \ifdim\scratchdimen>\zeropoint\relax#1\fi} \def\doboundtext#1#2#3% still used? {\hbox @@ -1203,109 +1154,121 @@ \ifdefined\fakecompoundhyphen\else \let\fakecompoundhyphen\relax \fi \ifdefined\veryraggedright \else \def\veryraggedright{\raggedright} \fi -\unexpanded\def\limitatetext - {\bgroup % evt \setstrut - \forgetall % otherwise indentation and so - \let\limitatetext\firstofthreearguments - \fakecompoundhyphen % dangerous ! ! ! ! ! ! ! ! ! - \dowithnextboxcs\syst_boxes_limitate_text\hbox} - -\def\syst_boxes_limitate_text#1% #2 - {\doifelsenothing{#1}\syst_boxes_limitate_text_nop\syst_boxes_limitate_text_yes{#1}} % {#2} - -\def\syst_boxes_limitate_text_nop#1#2% - {\unhbox\nextbox - \egroup} - -\def\syst_boxes_limitate_text_yes#1#2% - {\nopenalties - \scratchdimen#1\relax - \ifdim\scratchdimen<\zeropoint\relax % we'll take the last line - \donefalse - \scratchdimen-\scratchdimen - \else - \donetrue - \fi - \ifdim\wd\nextbox>\scratchdimen - \setbox\scratchbox\hbox{\ifdone\space#2\else#2\space\fi}% - \advance\scratchdimen -\wd\scratchbox - \setbox\scratchboxone\box\nextbox - \setbox\nextbox\vbox - {\hsize\scratchdimen - \hfuzz\maxdimen - \veryraggedright - \strut - \ifdone \else - \parfillskip\zeropoint - \rightskip\zeropoint - \hskip\zeropoint \s!plus 1\s!fill % \hsize - \fi - \unhcopy\scratchboxone}% - \ifdim\ht\nextbox>\strutht - \setbox\nextbox\vbox % if omitted: missing brace reported - {\splittopskip\openstrutheight - \ifdone - \setbox\nextbox\vsplit\nextbox to \strutht - \else - \doloop - {\setbox\scratchboxone\vsplit\nextbox to \strutht - \ifdim\ht\nextbox>\strutht \else \exitloop \fi}% - \fi - \unvbox\nextbox - \setbox\nextbox\lastbox - \global\setbox1\hpack - {\ifdone - \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox - \else - \box\scratchbox\unhbox\nextbox - \fi - \unskip}}% - \unhbox1 - \else - \unhbox0% - \fi - \else - \unhbox\nextbox - \fi - \egroup} - -%D We can also limit a text with more control: -%D -%D \startbuffer -%D \limitatetext {\input tufte } {2cm,5mm} {\unknown} -%D \limitatetext {ton en hans} {2cm,5mm} {\unknown} -%D \limitatetext {ton en hans zijn eikels} {2cm,5mm} {\unknown} -%D \limitatetext {ton} {2cm,5mm} {\unknown} -%D \stopbuffer -%D -%D \typebuffer \getbuffer -%D -%D We build this feature on top of the previous macro. - -% we could move the text argument to the end - -\let\normallimitatetext\limitatetext - -\def\speciallimitatetext#1#2#3#4% text left right placeholder - {%\dontleavehmode - \bgroup - \let\speciallimitatetext\firstoffourarguments - \setbox\scratchboxone\hbox - {\nohyphens - \normallimitatetext{#1}{+#2}{}#4% - \normallimitatetext{#1}{-#3}{}}% - \setbox\scratchboxtwo\hbox - {#1}% - \ifdim\wd\scratchboxtwo<\wd\scratchboxone #1\else\unhbox\scratchboxone\fi - \egroup} +% \unexpanded\def\limitatetext +% {\bgroup % evt \setstrut +% \forgetall % otherwise indentation and so +% \let\limitatetext\firstofthreearguments +% \fakecompoundhyphen % dangerous ! ! ! ! ! ! ! ! ! +% \dowithnextboxcs\syst_boxes_limitate_text\hbox} +% +% \def\syst_boxes_limitate_text#1% #2 +% {\doifelsenothing{#1}\syst_boxes_limitate_text_nop\syst_boxes_limitate_text_yes{#1}} % {#2} +% +% \def\syst_boxes_limitate_text_nop#1#2% +% {\unhbox\nextbox +% \egroup} +% +% \def\syst_boxes_limitate_text_yes#1#2% +% {\nopenalties +% \scratchdimen#1\relax +% \ifdim\scratchdimen<\zeropoint\relax % we'll take the last line +% \donefalse +% \scratchdimen-\scratchdimen +% \else +% \donetrue +% \fi +% \ifdim\wd\nextbox>\scratchdimen +% \setbox\scratchbox\hbox{\ifdone\space#2\else#2\space\fi}% +% \advance\scratchdimen -\wd\scratchbox +% \setbox\scratchboxone\box\nextbox +% \setbox\nextbox\vbox +% {\hsize\scratchdimen +% \hfuzz\maxdimen +% \veryraggedright +% \strut +% \ifdone \else +% \parfillskip\zeropoint +% \rightskip\zeropoint +% \hskip\zeropoint \s!plus 1\s!fill % \hsize +% \fi +% \unhcopy\scratchboxone}% +% \ifdim\ht\nextbox>\strutht +% \setbox\nextbox\vbox % if omitted: missing brace reported +% {\splittopskip\openstrutheight +% \ifdone +% \setbox\nextbox\vsplit\nextbox to \strutht +% \else +% \doloop +% {\setbox\scratchboxone\vsplit\nextbox to \strutht +% \ifdim\ht\nextbox>\strutht \else \exitloop \fi}% +% \fi +% \unvbox\nextbox +% \setbox\nextbox\lastbox +% \global\setbox1\hpack +% {\ifdone +% \unhbox\nextbox\unskip\kern\zeropoint\box\scratchbox +% \else +% \box\scratchbox\unhbox\nextbox +% \fi +% \unskip}}% +% \unhbox1 +% \else +% \unhbox0% +% \fi +% \else +% \unhbox\nextbox +% \fi +% \egroup} +% +% %D We can also limit a text with more control: +% %D +% %D \startbuffer +% %D \limitatetext {\input tufte } {2cm,5mm} {\unknown} +% %D \limitatetext {ton en hans} {2cm,5mm} {\unknown} +% %D \limitatetext {ton en hans zijn eikels} {2cm,5mm} {\unknown} +% %D \limitatetext {ton} {2cm,5mm} {\unknown} +% %D \stopbuffer +% %D +% %D \typebuffer \getbuffer +% %D +% %D We build this feature on top of the previous macro. +% +% % we could move the text argument to the end +% +% \let\normallimitatetext\limitatetext +% +% \def\speciallimitatetext#1#2#3#4% text left right placeholder +% {%\dontleavehmode +% \bgroup +% \let\speciallimitatetext\firstoffourarguments +% \setbox\scratchboxone\hbox +% {\nohyphens +% \normallimitatetext{#1}{+#2}{}#4% +% \normallimitatetext{#1}{-#3}{}}% +% \setbox\scratchboxtwo\hbox +% {#1}% +% \ifdim\wd\scratchboxtwo<\wd\scratchboxone #1\else\unhbox\scratchboxone\fi +% \egroup} +% +% \unexpanded\def\limitatetext#1#2#3% \expanded added 2003/01/16 +% {\splitatcomma{#2}\leftlimit\rightlimit +% \ifx\rightlimit\empty +% \normallimitatetext {#1}\leftlimit {#3}% +% \else +% \speciallimitatetext{#1}\leftlimit\rightlimit{#3}% +% \fi} \unexpanded\def\limitatetext#1#2#3% \expanded added 2003/01/16 {\splitatcomma{#2}\leftlimit\rightlimit - \ifx\rightlimit\empty - \normallimitatetext {#1}\leftlimit {#3}% - \else - \speciallimitatetext{#1}\leftlimit\rightlimit{#3}% - \fi} + \limitated + left \leftlimit + \ifx\rightlimit\empty\else + right \rightlimit + \fi + strip true + sentinel {#3} + text {#1} + \relax} %D Undocumented bonus (see wiki): %D @@ -1485,16 +1448,6 @@ {\vpack\bgroup \dowithnextboxcs\syst_boxes_sbox_finish\vbox} -% \unexpanded\def\syst_boxes_sbox_finish -% {\setbox\nextbox\hpack -% {\strut -% \dp\nextbox\zeropoint -% \lower\strutdp\box\nextbox}% -% \dp\nextbox\strutdp -% \ht\nextbox\strutht -% \box\nextbox -% \egroup} - \unexpanded\def\syst_boxes_sbox_finish {\boxyoffset\nextbox-\strutdp \dp\nextbox\strutdp @@ -1503,19 +1456,10 @@ \egroup} %D A variant on this: - -% \unexpanded\def\inlinedbox -% {\bgroup -% \dowithnextbox -% {\setbox\nextbox\hpack -% {\lower -% \dimexpr(\htdp\nextbox-\lineheight)/\plustwo+\strutdp\relax -% \box\nextbox}% -% \ht\nextbox\strutht -% \dp\nextbox\strutdp -% \box\nextbox -% \egroup}% -% \hbox} +%D +%D \starttyping +%D xx \ruledhbox{\inlinedbox{\tfd test}} xx +%D \stoptyping \unexpanded\def\inlinedbox {\bgroup @@ -1601,37 +1545,6 @@ %D The dimensions of the surrounding box are kept intact. This commands handles %D positive and negative dimensions (which is why we need two boxes with rules). -% \unexpanded\def\centeredbox#1#% height +/-dimen width +/-dimen -% {\bgroup -% \setbox\scratchboxone\vpack to \vsize -% \bgroup -% \dontcomplain -% \forgetall -% \setbox\scratchboxone\hpack{\vrule\s!width \zeropoint#1}% -% \setbox\scratchboxtwo\vpack{\hrule\s!height\zeropoint#1}% -% \advance\vsize \ht\scratchboxtwo -% \advance\hsize \wd\scratchboxone -% \vpack to \vsize -% \bgroup -% \vskip-\ht\scratchboxtwo -% \vss -% \hpack to \hsize -% \bgroup -% \dowithnextbox -% {\hskip-\wd\scratchboxone -% \hss -% \box\nextbox -% \hss -% \egroup -% \vss -% \egroup -% \egroup -% \wd\scratchboxone\hsize -% \ht\scratchboxone\vsize -% \box\scratchboxone -% \egroup} -% \hbox} - \unexpanded\def\centeredbox#1#% height +/-dimen width +/-dimen {\bgroup \dontcomplain @@ -1830,7 +1743,36 @@ \newdimen\hboxestohboxslack %D Create line and fake height of paragraph by messign with heights: a nice hack by -%D DEK himself. See older files for that code. +%D DEK himself. + +%\unexpanded\def\setvboxtohbox +% {\bgroup +% \ifdim\baselineskip<16pt \relax +% \scratchdimen\baselineskip +% \multiply\scratchdimen 1024 +% \else +% \message{cropping \baselineskip to 16pt}% +% \scratchdimen\maxdimen +% \fi +% \divide\scratchdimen \hsize +% \multiply\scratchdimen 64 +% \xdef\vboxtohboxfactor{\withoutpt\the\scratchdimen}% +% \egroup} +% +% \unexpanded\def\startvboxtohbox +% {\bgroup +% \setvboxtohbox +% \setbox\scratchbox\hbox\bgroup} +% +% \unexpanded\def\stopvboxtohbox +% {\ifcase\vboxtohboxslack\else\hskip\zeropoint\!!minus\vboxtohboxslack\fi +% \egroup +% \dp\scratchbox\zeropoint +% \ht\scratchbox\vboxtohboxfactor\wd\scratchbox +% \box\scratchbox +% \egroup} + +% More modern: % \definesystemattribute[vboxtohboxseparator][public] @@ -2174,26 +2116,6 @@ \unexpanded\def\tbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_tbox_finish\hbox} \unexpanded\def\bbox{\hpack\bgroup\dowithnextboxcs\syst_boxes_bbox_finish\hbox} -% \def\syst_boxes_tbox_finish -% {\scratchdepth\dimexpr\ht\nextbox+\dp\nextbox-\ht\strutbox\relax -% \ht\nextbox\ht\strutbox -% \dp\nextbox\scratchdepth -% \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}% -% \ht\nextbox\ht\strutbox -% \dp\nextbox\scratchdepth -% \box\nextbox -% \egroup} - -% \def\syst_boxes_bbox_finish -% {\scratchheight\dimexpr\ht\nextbox+\dp\nextbox-\dp\strutbox\relax -% \dp\nextbox\dp\strutbox -% \ht\nextbox\scratchheight -% \setbox\nextbox\hpack{\lower\dp\nextbox\box\nextbox}% -% \dp\nextbox\dp\strutbox -% \ht\nextbox\scratchheight -% \box\nextbox -% \egroup} - \def\syst_boxes_tbox_finish {\scratchheight\ht\strutbox \scratchdepth\dimexpr\htdp\nextbox-\scratchheight\relax @@ -2268,11 +2190,11 @@ \unexpanded\def\limitatelines#1#2% size sentinel {\dowithnextbox - {\dimen0=#1\hsize - \ifdim\wd\nextbox>\dimen0 + {\scratchdimen#1\hsize + \ifdim\wd\nextbox>\scratchdimen \setbox\nextbox\hbox - {\advance\dimen0 -.1\hsize - \limitatetext{\unhbox\nextbox}{\dimen0}{\nobreak#2}}% + {\advance\scratchdimen -.1\hsize + \limitatetext{\unhbox\nextbox}{\scratchdimen}{\nobreak#2}}% \fi \unhbox\nextbox} \hbox} @@ -2281,14 +2203,14 @@ {\dowithnextbox {\bgroup \par - \dimen0\ht\nextbox + \scratchdimen\ht\nextbox \ht\nextbox\strutht \dp\nextbox\strutdp \hpack{\box\nextbox} \prevdepth\strutdp \doloop - {\advance\dimen0 -\lineheight - \ifdim\dimen0<\zeropoint + {\advance\scratchdimen -\lineheight + \ifdim\scratchdimen<\zeropoint \exitloop \else \nobreak @@ -2344,13 +2266,6 @@ \let\bottomleftbox \leftbottombox \let\bottomrightbox\rightbottombox -% \def\syst_boxes_rightbox_finish -% {\global\boxhdisplacement\boxoffset -% \global\boxvdisplacement.5\ht\nextbox -% \global\advance\boxvdisplacement-.5\dp\nextbox -% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_rightbox_finish {\global\boxhdisplacement\boxoffset \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax @@ -2360,14 +2275,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_leftbox_finish -% {\global\boxhdisplacement-\wd\nextbox -% \global\advance\boxhdisplacement-\boxoffset -% \global\boxvdisplacement.5\ht\nextbox -% \global\advance\boxvdisplacement-.5\dp\nextbox -% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_leftbox_finish {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax @@ -2377,13 +2284,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_topbox_finish -% {\global\boxhdisplacement-.5\wd\nextbox -% \global\boxvdisplacement-\dp\nextbox -% \global\advance\boxvdisplacement-\boxoffset -% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_topbox_finish {\global\boxhdisplacement-.5\wd\nextbox \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax @@ -2393,13 +2293,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_bottombox_finish -% {\global\boxhdisplacement-.5\wd\nextbox -% \global\boxvdisplacement\ht\nextbox -% \global\advance\boxvdisplacement\boxoffset -% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_bottombox_finish {\global\boxhdisplacement-.5\wd\nextbox \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax @@ -2409,14 +2302,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_lefttopbox_finish -% {\global\boxhdisplacement-\wd\nextbox -% \global\advance\boxhdisplacement-\boxoffset -% \global\boxvdisplacement-\dp\nextbox -% \global\advance\boxvdisplacement-\boxoffset -% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_lefttopbox_finish {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax @@ -2426,13 +2311,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_righttopbox_finish -% {\global\boxhdisplacement\boxoffset -% \global\boxvdisplacement-\dp\nextbox -% \global\advance\boxvdisplacement-\boxoffset -% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_righttopbox_finish {\global\boxhdisplacement\boxoffset \global\boxvdisplacement\dimexpr-\dp\nextbox-\boxoffset\relax @@ -2442,14 +2320,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_leftbottombox_finish -% {\global\boxhdisplacement-\wd\nextbox -% \global\advance\boxhdisplacement-\boxoffset -% \global\boxvdisplacement\ht\nextbox -% \global\advance\boxvdisplacement\boxoffset -% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_leftbottombox_finish {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax @@ -2459,13 +2329,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_rightbottombox_finish -% {\global\boxhdisplacement\boxoffset -% \global\boxvdisplacement\ht\nextbox -% \global\advance\boxvdisplacement\boxoffset -% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_rightbottombox_finish {\global\boxhdisplacement\boxoffset \global\boxvdisplacement\dimexpr\ht\nextbox+\boxoffset\relax @@ -2480,13 +2343,6 @@ \unexpanded\def\baselineleftbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselineleftbox_finish \placedbox} \unexpanded\def\baselinerightbox {\hpack\bgroup\dowithnextboxcs\syst_boxes_baselinerightbox_finish \placedbox} -% \def\syst_boxes_middlebox_finish -% {\global\boxhdisplacement-.5\wd\nextbox -% \global\boxvdisplacement.5\ht\nextbox -% \global\advance\boxvdisplacement-.5\dp\nextbox -% \boxcursor\kern\boxhdisplacement\lower\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_middlebox_finish {\global\boxhdisplacement-.5\wd\nextbox \global\boxvdisplacement.5\dimexpr\ht\nextbox-\dp\nextbox\relax @@ -2496,13 +2352,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_baselinemiddlebox_finish -% {\global\boxhdisplacement-.5\wd\nextbox -% \global\advance\boxhdisplacement-\boxoffset -% \global\boxvdisplacement-\boxoffset -% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_baselinemiddlebox_finish {\global\boxhdisplacement\dimexpr-.5\wd\nextbox-\boxoffset\relax \global\boxvdisplacement-\boxoffset @@ -2512,13 +2361,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_baselineleftbox_finish -% {\global\boxhdisplacement-\wd\nextbox -% \global\advance\boxhdisplacement-\boxoffset -% \global\boxvdisplacement-\boxoffset -% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_baselineleftbox_finish {\global\boxhdisplacement\dimexpr-\wd\nextbox-\boxoffset\relax \global\boxvdisplacement-\boxoffset @@ -2528,12 +2370,6 @@ \box\nextbox \egroup} -% \def\syst_boxes_baselinerightbox_finish -% {\global\boxhdisplacement\boxoffset -% \global\boxvdisplacement-\boxoffset -% \boxcursor\kern\boxhdisplacement\raise-\boxvdisplacement\box\nextbox -% \egroup} - \def\syst_boxes_baselinerightbox_finish {\global\boxhdisplacement\boxoffset \global\boxvdisplacement-\boxoffset @@ -2944,12 +2780,6 @@ %D A bit dirty: -% \unexpanded\def\nodestostring#1% \cs {content} -% {\dowithnextbox{\edef#1{\syst_boxes_nodestostring}}\hbox} -% -% \def\syst_boxes_nodestostring -% {\clf_boxtostring\nextbox} - \unexpanded\def\nodestostring#1#2% more tolerant for #2=\cs {\begingroup \setbox\nextbox\hbox{#2}% diff --git a/tex/context/base/mkiv/tabl-tsp.mkiv b/tex/context/base/mkiv/tabl-tsp.mkiv index 9e30975cd..c5858fec1 100644 --- a/tex/context/base/mkiv/tabl-tsp.mkiv +++ b/tex/context/base/mkiv/tabl-tsp.mkiv @@ -187,7 +187,9 @@ \bgroup \forcelocalfloats \setuplocalfloats[\c!before=,\c!after=,\c!inbetween=]% -% \settrialtypesetting % this controls samepage resetting too but it also messes up the numbering + % This controls samepage resetting too but it also messes up the numbering + % so I need another fix. +% \settrialtypesetting \splitfloatcommand{\hbox to #1{\strut}}% dummy line % \resettrialtypesetting \setbox\scratchbox\vbox{\flushlocalfloats}% \vpack ? diff --git a/tex/context/base/mkiv/toks-ini.lua b/tex/context/base/mkiv/toks-ini.lua index af93d3bc1..eef26574e 100644 --- a/tex/context/base/mkiv/toks-ini.lua +++ b/tex/context/base/mkiv/toks-ini.lua @@ -42,7 +42,7 @@ local scan_glue = token.scan_glue local scan_keyword = token.scan_keyword local scan_keyword_cs = token.scan_keyword_cs or scan_keyword local scan_token = token.scan_token -local scan_list = token.scan_list +local scan_box = token.scan_box local scan_word = token.scan_word local scan_key = token.scan_key local scan_value = token.scan_value @@ -138,11 +138,29 @@ local function scan_verbatim() return scan_argument(false) end +if not scan_box then + + local scan_list = token.scan_list + local put_next = token.put_next + + scan_box = function(s) + if s == "hbox" or s == "vbox" or s == "vtop" then + put_next(create_token(s)) + end + end + + token.scan_box = scan_box + +end + tokens.scanners = { -- these expand token = scan_token, toks = scan_toks, tokens = scan_toks, - list = scan_list, + box = scan_box, + hbox = function() return scan_box("hbox") end, + vbox = function() return scan_box("vbox") end, + vtop = function() return scan_box("vtop") end, dimen = scan_dimen, dimension = scan_dimen, glue = scan_glue, diff --git a/tex/context/base/mkiv/toks-scn.lua b/tex/context/base/mkiv/toks-scn.lua index b707500e7..2d20d5a8b 100644 --- a/tex/context/base/mkiv/toks-scn.lua +++ b/tex/context/base/mkiv/toks-scn.lua @@ -186,6 +186,10 @@ local shortcuts = { scanboolean = scanboolean, scandimen = scandimen, scandimension = scandimen, + scanbox = scanners.box, + scanhbox = scanners.hbox, + scanvbox = scanners.vbox, + scanvtop = scanners.vtop, scanconditional = scanconditional, scanopen = scanopen, scanclose = scanclose, diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 77404fcff..12c7a8606 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -974,9 +974,12 @@ <cd:constant name='menu' value='meniu'/> <cd:constant name='method' value='metoda'/> <cd:constant name='middle' value='mijloc'/> + <cd:constant name='middlecolor' value='middlecolor'/> <cd:constant name='middlecommand' value='middlecommand'/> <cd:constant name='middlespeech' value='middlespeech'/> + <cd:constant name='middlestyle' value='middlestyle'/> <cd:constant name='middletext' value='textmijloc'/> + <cd:constant name='middlewidth' value='middlewidth'/> <cd:constant name='midsentence' value='midsentence'/> <cd:constant name='min' value='min'/> <cd:constant name='mindepth' value='mindepth'/> diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex 20ca3b4a7..9e16246d2 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 41bca13ac..1f38209d2 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 7b3dbccbd..ce333b321 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 08/02/19 19:40:08 +-- merge date : 08/05/19 10:34:41 do -- begin closure to overcome local limits and interference |