diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/spac-ver.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/spac-ver.mkiv | 135 |
1 files changed, 109 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/context/base/spac-ver.mkiv b/Master/texmf-dist/tex/context/base/spac-ver.mkiv index 0c84958beb0..e44056954ad 100644 --- a/Master/texmf-dist/tex/context/base/spac-ver.mkiv +++ b/Master/texmf-dist/tex/context/base/spac-ver.mkiv @@ -17,6 +17,8 @@ \registerctxluafile{spac-ver}{1.001} +% todo: use usernodes ? + % todo: itemize : intro ... only when there is one or two lines preceding and then % keep these together i.e. \blank[intro] @@ -120,7 +122,7 @@ \setvalue{\??interlinespacerelative\v!auto }{\let\setrelativeinterlinespace\spac_linespacing_set_relative_interlinespace} \def\spac_linespacing_set_specified_relative_interlinespace#1% fragile? - {\doifdimenstringelse{#1} + {\doifelsedimenstring{#1} {\setupspecifiedinterlinespace[\c!line=#1]} {\assignvalue{#1}\currentrelativeinterlinespace{1.00}{1.25}{1.50}% \spacing\currentrelativeinterlinespace}} @@ -140,6 +142,20 @@ \spacing\currentrelativeinterlinespace \fi} +\unexpanded\def\spac_linespacing_setup_use + {\ifcsname\namedinterlinespacehash\m_spac_interlinespace\s!parent\endcsname + \let\currentinterlinespace\m_spac_interlinespace + \spac_linespacing_setup_specified_interline_space + % \else + % we only support named interlinespaces + \fi} + +\unexpanded\def\useinterlinespaceparameter#1% see footnotes + {\edef\m_spac_interlinespace{#1\c!interlinespace}% + \ifx\m_spac_interlinespace\empty \else + \spac_linespacing_setup_use + \fi} + \newtoks\everysetupglobalinterlinespace \newtoks\everysetuplocalinterlinespace @@ -174,7 +190,7 @@ \fi\fi} \def\spac_linespacing_setup_specified_or_relative[#1]% - {\doifassignmentelse{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]% + {\doifelseassignment{#1}\setupspecifiedinterlinespace\setuprelativeinterlinespace[#1]% \the\iflocalinterlinespace\everysetuplocalinterlinespace\else\everysetupglobalinterlinespace\fi} \def\spac_linespacing_synchronize_local % adapts to the font @@ -201,7 +217,7 @@ \fi \popmacro\currentinterlinespace \else - \normalexpanded{\noexpand\doifassignmentelse{\p_spac_checked_interlinespace}% + \normalexpanded{\noexpand\doifelseassignment{\p_spac_checked_interlinespace}% \setupspecifiedinterlinespace\setuprelativeinterlinespace[\p_spac_checked_interlinespace]}% \iflocalinterlinespace \the\everysetuplocalinterlinespace @@ -334,7 +350,7 @@ \let\v_spac_whitespace_current\v!none \unexpanded\def\setupwhitespace - {\doifnextoptionalcselse\spac_whitespace_setup_yes\spac_whitespace_setup_nop} + {\doifelsenextoptionalcs\spac_whitespace_setup_yes\spac_whitespace_setup_nop} \def\spac_whitespace_setup_nop {\ifx\v_spac_whitespace_current\v!none\else @@ -960,6 +976,35 @@ \let\normalstrut\strut +\unexpanded\def\halfstrut + {\relax + \dontleavehmode + \begingroup + \setbox\scratchbox\copy\strutbox + \ht\scratchbox\dimexpr\strutht/\plustwo\relax + \dp\scratchbox\dimexpr\strutdp/\plustwo\relax + \box\scratchbox + \endgroup} + +\unexpanded\def\quarterstrut + {\relax + \dontleavehmode + \begingroup + \setbox\scratchbox\copy\strutbox + \ht\scratchbox\dimexpr\strutht/\plusfour\relax + \dp\scratchbox\dimexpr\strutdp/\plusfour\relax + \box\scratchbox + \endgroup} + +\unexpanded\def\depthstrut + {\relax + \dontleavehmode + \begingroup + \setbox\scratchbox\copy\strutbox + \ht\scratchbox\dimexpr\strutht-\struthtdp/\plustwo\relax % assumes that ht > lineheight/2 + \box\scratchbox + \endgroup} + %D Sometimes a capstrut comes in handy %D %D \starttabulate[|Tl|l|l|] @@ -1032,12 +1077,17 @@ \newbox\nostrutbox \setbox\nostrutbox\emptyhbox +\newtoks\everysetnostrut + \unexpanded\def\setnostrut - {\setbox\strutbox\copy\nostrutbox - \let\strut\empty - \let\endstrut\empty - \let\begstrut\empty - \let\crlfplaceholder\empty} + {\the\everysetnostrut} + +\appendtoks + \setbox\strutbox\copy\nostrutbox + \let\strut\empty + \let\endstrut\empty + \let\begstrut\empty +\to \everysetnostrut % when enabled, sigstruts will remove themselves if nothing % goes inbetween @@ -1167,7 +1217,7 @@ \let\normaloffinterlineskip\offinterlineskip % knuth's original \appendtoks - \ifvmode\ctxcommand{resetprevdepth()}\fi % a nasty hack (tested for a while now) + \ifvmode\clf_resetprevdepth\fi % a nasty hack (tested for a while now) \to \everyafteroutput %D My own one: @@ -1341,7 +1391,7 @@ \unexpanded\def\installsnapvalues#1#2% todo: a proper define {\edef\currentsnapper{#1:#2}% \ifcsname\??gridsnapperattributes\currentsnapper\endcsname \else - \setevalue{\??gridsnapperattributes\currentsnapper}{\ctxcommand{definesnapmethod("#1","#2")}}% + \setevalue{\??gridsnapperattributes\currentsnapper}{\clf_definesnapmethod{#1}{#2}}% \fi \setevalue{\??gridsnappers#1}{\attribute\snapmethodattribute\csname\??gridsnapperattributes\currentsnapper\endcsname\space}} @@ -1410,6 +1460,9 @@ \definegridsnapping[\v!none] [\v!none] \definegridsnapping[\v!line] [\v!line] \definegridsnapping[\v!strut] [\v!strut] +\definegridsnapping[\v!box] [\v!box] % centers a box rounded upwards (box:.5 -> tolerance) +\definegridsnapping[\v!min] [\v!min] % centers a box rounded downwards +\definegridsnapping[\v!max] [\v!max] % centers a box rounded upwards \definegridsnapping[\v!max] [\v!maxdepth,\v!maxheight,\v!strut] \definegridsnapping[\v!min] [\v!mindepth,\v!minheight,\v!strut] @@ -1495,10 +1548,10 @@ \def\spac_grids_snap_to_finish#1% {\ifvbox\nextbox % this will go away - \ctxcommand{vspacingcollapse(\number\nextbox)}% isn't that already done? + \clf_vspacingcollapse\nextbox\relax % isn't that already done? \fi \doifelsenothing{#1}{\spac_grids_snap_value_set\v!normal}{\spac_grids_snap_value_set{#1}}% - \ctxcommand{vspacingsnap(\number\nextbox,\number\attribute\snapmethodattribute)}% + \clf_vspacingsnap\nextbox\attribute\snapmethodattribute\relax \ifvbox\nextbox\vbox\else\hbox\fi attr \snapmethodattribute \zerocount {\box\nextbox}% \egroup} @@ -1648,7 +1701,7 @@ \def\spac_vspacing_define_amount[#1][#2][#3]% can be combined {\setvalue{\??vspacingamount#1}{\ifgridsnapping#3\else#2\fi}% - \ctxcommand{vspacingsetamount("#1")}} + \clf_vspacingsetamount{#1}} % \installcorenamespace{vspacingamountnormal} % \installcorenamespace{vspacingamountgrid} @@ -1660,13 +1713,13 @@ % \fi % \csname n>#1\endcsname{#2}% % \csname g>#1\endcsname{#3}% -% \ctxcommand{vspacingsetamount("#1")}} +% \clf_vspacingsetamount{#1}} \unexpanded\def\definevspacing {\dodoubleempty\spac_vspacing_define} \def\spac_vspacing_define[#1][#2]% - {\ctxcommand{vspacingdefine("#1","#2")}} + {\clf_vspacingdefine{#1}{#2}} %D The injector code (generated at the \LUA\ end): @@ -1767,7 +1820,7 @@ % The main spacer: \unexpanded\def\vspacing - {\doifnextoptionalcselse\spac_vspacing_yes\spac_vspacing_nop} + {\doifelsenextoptionalcs\spac_vspacing_yes\spac_vspacing_nop} \def\spac_vspacing_yes {\ifinpagebody % somewhat weird @@ -1788,21 +1841,21 @@ \fi\fi} \def\spac_vspacing_yes_indeed[#1]% - {\ifmmode\else\par\ctxcommand{vspacing("#1")}\fi} + {\ifmmode\else\par\clf_vspacing{#1}\fi} \def\spac_vspacing_yes_ignore[#1]% {\ifmmode\else\par\fi} \def\spac_vspacing_nop_indeed - {\ifmmode\else\par\ctxcommand{vspacing("\currentvspacing")}\fi} + {\ifmmode\else\par\clf_vspacing{\currentvspacing}\fi} \def\spac_vspacing_nop_ignore {\ifmmode\else\par\fi} \def\directvspacing#1% - {\par\ctxcommand{vspacing("#1")}} + {\par\clf_vspacing{#1}} -% handy (and faste): +% handy (and faster): \unexpanded\def\directvpenalty#1% {\begingroup @@ -1823,7 +1876,7 @@ % these depend on bigskipamount cum suis so we'd better sync them \unexpanded\def\setupvspacing - {\doifnextoptionalcselse\setupvspacing_yes\setupvspacing_nop} + {\doifelsenextoptionalcs\setupvspacing_yes\setupvspacing_nop} \let\currentvspacing\s!default % hm, default, standard ... @@ -1876,6 +1929,21 @@ \fi\fi \relax} +% used in itemize ... always test this + +\newdimen\d_spac_overlay + +\def\spac_overlay_lines + {\blank[\v!back,\v!overlay]% + \nointerlineskip} + +% \startitemize[n] +% \item \input zapf +% \item \startitemize[a] +% \item \input knuth +% \stopitemize +% \stopitemize +% % \strut \hfill first line \blank[overlay] second line \hfill \strut % % \ruledvbox { @@ -1883,6 +1951,9 @@ % line 2 \hfill \strut \blank[overlay] % \strut \hfill line 3 \hfill \strut % } +% +% \dorecurse{50} +% {\startitemize[n] \startitem \startitemize[a] \item #1 \stopitemize \stopitem \stopitemize} \definevspacing[\v!preference][penalty:-500] % goodbreak \definevspacing[\v!samepage] [penalty:10000] % nobreak @@ -1893,7 +1964,7 @@ \definevspacing[\v!back] [category:7] % together [category:8] \definevspacing[\v!overlay] [category:9] -\definevspacing[\v!always] [category:0] +\definevspacing[\v!always] [category:0] % hm, internally it's discard \definevspacing[\v!weak] [order:0] \definevspacing[\v!strong] [order:100] @@ -1920,8 +1991,20 @@ %D \type {\blank} (we needed the first one while playing with the %D new code). +% We keep this one as reference +% +% \unexpanded\def\inhibitblank +% {\vspacing[\v!disable]} +% +% but use the following more efficient variant instead: + \unexpanded\def\inhibitblank - {\vspacing[\v!disable]} % can be made faster + {\ifvmode + \begingroup + \attribute\skipcategoryattribute\plusfive + \vskip\zeropoint + \endgroup + \fi} \let\doinhibitblank\inhibitblank % keep this command, used in styles @@ -2006,7 +2089,7 @@ \let\m_spac_hanging_location\empty \def\spac_hanging_start[#1]% - {\doifassignmentelse{#1} + {\doifelseassignment{#1} {\let\m_spac_hanging_location\empty \setupcurrenthanging[#1]}% {\edef\m_spac_hanging_location{#1}}% @@ -2135,7 +2218,7 @@ % as encountered in forced blank skips (see lua code) % % \appendtoks -% \ifvmode\ctxcommand{resetprevdepth()}\fi +% \ifvmode\clf_resetprevdepth\fi % \to \everyafteroutput % % this should only happen when there is nothing left over (how to detemine that) .. testcase: |