From 4b459764a30ae1fb1e124b1a7a5a44ecb5a4d54b Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 5 Jan 2012 19:27:53 +0100 Subject: beta 2011.12.31 13:16 --- tex/context/base/anch-bck.mkvi | 13 +- tex/context/base/anch-pgr.mkiv | 54 +- tex/context/base/anch-pos.mkiv | 2 +- tex/context/base/anch-tab.mkiv | 4 +- tex/context/base/attr-col.lua | 2 +- tex/context/base/attr-col.mkiv | 2 +- tex/context/base/attr-lay.mkiv | 2 +- tex/context/base/back-exp.mkiv | 24 +- tex/context/base/back-ini.mkiv | 27 +- tex/context/base/back-pdf.mkiv | 94 +- tex/context/base/buff-ini.mkiv | 186 ++- tex/context/base/buff-ver.mkiv | 50 +- tex/context/base/chem-str.mkiv | 18 +- tex/context/base/colo-ext.mkiv | 84 +- tex/context/base/colo-grp.mkiv | 168 +++ tex/context/base/colo-imp-dem.mkiv | 260 ++++ tex/context/base/colo-imp-rgb.mkiv | 262 +--- tex/context/base/colo-ini.lua | 134 +- tex/context/base/colo-ini.mkiv | 979 ++++++-------- tex/context/base/colo-run.lua | 66 + tex/context/base/colo-run.mkiv | 277 ++-- tex/context/base/cont-log.mkiv | 87 +- tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 23 +- tex/context/base/context-version.pdf | Bin 4072 -> 4075 bytes tex/context/base/context-version.png | Bin 106000 -> 101989 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 11 +- tex/context/base/core-con.mkiv | 154 +-- tex/context/base/core-ctx.mkiv | 10 +- tex/context/base/core-env.mkiv | 497 ++++--- tex/context/base/core-fnt.mkiv | 40 - tex/context/base/core-gen.mkiv | 166 --- tex/context/base/core-mis.mkiv | 277 +--- tex/context/base/core-sys.mkiv | 206 +-- tex/context/base/core-two.mkiv | 48 +- tex/context/base/core-uti.lua | 2 + tex/context/base/core-uti.mkiv | 9 +- tex/context/base/core-var.mkiv | 9 +- tex/context/base/file-job.mkvi | 36 +- tex/context/base/file-syn.mkvi | 8 +- tex/context/base/font-ext.lua | 102 +- tex/context/base/font-gds.mkiv | 10 +- tex/context/base/font-ini.mkiv | 364 ++--- tex/context/base/grph-trf.mkiv | 363 ++++- tex/context/base/hand-ini.mkiv | 45 +- tex/context/base/java-ini.lua | 8 + tex/context/base/java-ini.mkiv | 27 +- tex/context/base/l-math.lua | 4 +- tex/context/base/lang-ini.mkiv | 113 +- tex/context/base/lang-lab.mkiv | 61 +- tex/context/base/lang-mis.mkiv | 242 ++-- tex/context/base/lang-url.mkiv | 53 +- tex/context/base/lang-wrd.lua | 6 + tex/context/base/lang-wrd.mkiv | 35 +- tex/context/base/lpdf-col.lua | 13 + tex/context/base/luat-mac.lua | 2 +- tex/context/base/luat-sto.lua | 6 + tex/context/base/lxml-ctx.mkiv | 3 - tex/context/base/lxml-ini.mkiv | 138 +- tex/context/base/lxml-sor.mkiv | 10 +- tex/context/base/m-chart.mkvi | 8 +- tex/context/base/m-database.mkiv | 4 +- tex/context/base/math-ali.mkiv | 53 +- tex/context/base/math-for.mkiv | 7 +- tex/context/base/meta-fig.mkiv | 2 +- tex/context/base/meta-ini.mkiv | 153 ++- tex/context/base/meta-tex.mkiv | 38 +- tex/context/base/mlib-pdf.mkiv | 18 +- tex/context/base/mlib-pps.mkiv | 19 +- tex/context/base/mult-aux.mkiv | 185 ++- tex/context/base/mult-de.mkii | 3 + tex/context/base/mult-def.lua | 13 + tex/context/base/mult-dim.mkvi | 123 ++ tex/context/base/mult-en.mkii | 3 + tex/context/base/mult-fr.mkii | 3 + tex/context/base/mult-ini.lua | 43 +- tex/context/base/mult-ini.mkiv | 24 +- tex/context/base/mult-it.mkii | 3 + tex/context/base/mult-low.lua | 8 +- tex/context/base/mult-nl.mkii | 3 + tex/context/base/mult-pe.mkii | 3 + tex/context/base/mult-ro.mkii | 3 + tex/context/base/mult-sys.mkiv | 205 +-- tex/context/base/node-bck.mkiv | 66 +- tex/context/base/node-fin.mkiv | 14 +- tex/context/base/node-ini.mkiv | 2 +- tex/context/base/node-par.mkiv | 30 +- tex/context/base/node-rul.mkiv | 233 ++-- tex/context/base/node-shp.lua | 8 + tex/context/base/pack-bck.mkvi | 7 +- tex/context/base/pack-box.mkiv | 514 ++++---- tex/context/base/pack-fen.mkiv | 16 +- tex/context/base/pack-lyr.mkiv | 733 +++++----- tex/context/base/pack-mis.mkvi | 4 +- tex/context/base/pack-pos.mkiv | 2 +- tex/context/base/pack-rul.mkiv | 150 ++- tex/context/base/page-app.mkiv | 4 +- tex/context/base/page-bck.mkiv | 4 +- tex/context/base/page-com.mkiv | 2 +- tex/context/base/page-imp.mkiv | 24 +- tex/context/base/page-inf.mkiv | 10 +- tex/context/base/page-ini.mkiv | 8 +- tex/context/base/page-lay.mkiv | 259 ++-- tex/context/base/page-mak.mkvi | 11 +- tex/context/base/page-mbk.mkvi | 37 +- tex/context/base/page-mis.mkiv | 2 +- tex/context/base/page-mrk.mkiv | 6 +- tex/context/base/page-mul.mkiv | 37 +- tex/context/base/page-one.mkiv | 13 +- tex/context/base/page-plg.mkiv | 16 +- tex/context/base/page-txt.mkvi | 169 +-- tex/context/base/phys-dim.mkiv | 18 +- tex/context/base/s-inf-01.mkvi | 2 +- tex/context/base/s-inf-03.mkiv | 13 +- tex/context/base/scrn-bar.mkvi | 5 +- tex/context/base/scrn-but.mkvi | 77 +- tex/context/base/scrn-fld.mkvi | 99 +- tex/context/base/scrn-hlp.mkvi | 6 +- tex/context/base/scrn-ini.mkvi | 4 +- tex/context/base/scrn-pag.mkvi | 6 +- tex/context/base/scrn-wid.mkvi | 52 +- tex/context/base/scrp-ini.mkiv | 4 +- tex/context/base/spac-ali.mkiv | 1172 ++++++++-------- tex/context/base/spac-def.mkiv | 2 +- tex/context/base/spac-pag.mkiv | 52 +- tex/context/base/spac-ver.mkiv | 66 +- tex/context/base/status-files.pdf | Bin 24080 -> 24490 bytes tex/context/base/status-lua.pdf | Bin 169690 -> 170135 bytes tex/context/base/status-mkiv.lua | 1394 ++++++++++++++++++++ tex/context/base/status-mkiv.tex | 83 ++ tex/context/base/strc-blk.mkiv | 4 +- tex/context/base/strc-des.mkiv | 8 +- tex/context/base/strc-flt.mkvi | 24 +- tex/context/base/strc-itm.mkvi | 191 +-- tex/context/base/strc-lst.mkiv | 77 +- tex/context/base/strc-mar.lua | 2 +- tex/context/base/strc-mar.mkiv | 65 +- tex/context/base/strc-not.mkiv | 2 +- tex/context/base/strc-pag.mkiv | 6 +- tex/context/base/strc-ref.mkvi | 4 +- tex/context/base/strc-sec.mkiv | 67 +- tex/context/base/strc-syn.mkiv | 10 +- tex/context/base/strc-tag.mkiv | 2 +- tex/context/base/supp-mat.mkiv | 30 +- tex/context/base/supp-ran.mkiv | 16 +- tex/context/base/symb-ini.mkiv | 191 +-- tex/context/base/syst-aux.mkiv | 83 +- tex/context/base/tabl-tbl.mkiv | 19 +- tex/context/base/tabl-xnt.mkvi | 2 +- tex/context/base/tabl-xtb.mkvi | 26 +- tex/context/base/trac-deb.mkiv | 28 +- tex/context/base/trac-tex.mkiv | 12 +- tex/context/base/type-ini.mkiv | 10 +- tex/context/base/type-otf.mkiv | 58 +- tex/context/base/typo-cap.mkiv | 9 + tex/context/base/typo-mar.mkiv | 37 +- tex/context/base/typo-par.mkiv | 4 +- tex/context/base/typo-prc.mkvi | 9 +- tex/context/base/unic-ini.mkiv | 14 +- tex/context/base/x-xtag.mkiv | 60 + tex/context/base/xtag-ini.mkii | 3 + tex/context/interface/keys-cs.xml | 3 + tex/context/interface/keys-de.xml | 3 + tex/context/interface/keys-en.xml | 3 + tex/context/interface/keys-fr.xml | 3 + tex/context/interface/keys-it.xml | 3 + tex/context/interface/keys-nl.xml | 3 + tex/context/interface/keys-pe.xml | 3 + tex/context/interface/keys-ro.xml | 3 + tex/generic/context/luatex/luatex-fonts-merged.lua | 6 +- 171 files changed, 7575 insertions(+), 5788 deletions(-) create mode 100644 tex/context/base/colo-grp.mkiv create mode 100644 tex/context/base/colo-imp-dem.mkiv create mode 100644 tex/context/base/colo-run.lua delete mode 100644 tex/context/base/core-gen.mkiv create mode 100644 tex/context/base/mult-dim.mkvi create mode 100644 tex/context/base/status-mkiv.lua create mode 100644 tex/context/base/status-mkiv.tex (limited to 'tex') diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi index 75a7f05a5..cf5b82967 100644 --- a/tex/context/base/anch-bck.mkvi +++ b/tex/context/base/anch-bck.mkvi @@ -112,7 +112,10 @@ \newcount\c_backgrounds_text_level -\installcommandhandler \??td {textbackground} \??td +\installcorenamespace{textbackground} +\installcorenamespace{textbackgroundlevel} + +\installcommandhandler \??textbackground {textbackground} \??textbackground \appendtoks \setuevalue{\currenttextbackground}{\groupedcommand{\starttextbackground[\currenttextbackground]}{\stoptextbackground}}% @@ -147,11 +150,11 @@ \let\backgrounds_text_start_indeed\relax \let\backgrounds_text_stop_indeed \relax -\setvalue{\??td:l:\v!text}% +\setvalue{\??textbackgroundlevel\v!text}% {\let\backgrounds_text_start_indeed\backgrounds_text_start_txt \let\backgrounds_text_stop_indeed \dostoptextbackgroundtxt} -\setvalue{\??td:l:\v!paragraph}% +\setvalue{\??textbackgroundlevel\v!paragraph}% {\ifnum\c_backgrounds_text_level>\plusone \let\backgrounds_text_start_indeed\backgrounds_text_start_txt \let\backgrounds_text_stop_indeed \dostoptextbackgroundtxt @@ -160,7 +163,7 @@ \let\backgrounds_text_stop_indeed \dostoptextbackgroundpar \fi} -\setvalue{\??td:l:\v!none}% +\setvalue{\??textbackgroundlevel\v!none}% {\backgrounds_text_preset_nop} \def\backgrounds_text_preset_nop @@ -169,7 +172,7 @@ \def\backgrounds_text_preset_yes {\backgrounds_text_preset_nop - \csname\??td:l:\textbackgroundparameter\c!location\endcsname + \csname\??textbackgroundlevel\textbackgroundparameter\c!location\endcsname \edef\m_backgrounds_text_frame {\textbackgroundparameter\c!frame}% \edef\m_backgrounds_text_corner {\textbackgroundparameter\c!corner}% \edef\m_backgrounds_text_background{\textbackgroundparameter\c!background}% diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index a30a2e3eb..c7acc0b32 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -39,27 +39,28 @@ \newtoks\everyinsertpositionaction \newtoks\everycleanpositionaction -\let\POSactionprefix\POSprefix +\installcorenamespace{positionaction} +\installcorenamespace{positioncleanup} \unexpanded\def\dosetpositionaction#1% - {\setgvalue{\POSactionprefix#1::}} + {\setgvalue{\??positionaction#1}} \def\doifpositionaction#1% - {\ifcsname\POSactionprefix#1::\endcsname + {\ifcsname\??positionaction#1\endcsname \expandafter\firstofoneargument \else \expandafter\gobbleoneargument \fi} \def\doifpositionactionelse#1% - {\ifcsname\POSactionprefix#1::\endcsname + {\ifcsname\??positionaction#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} \def\dopositionaction#1% test saves hash entry in etex - {\ifcsname\POSactionprefix#1::\endcsname + {\ifcsname\??positionaction#1\endcsname \positions_action_indeed{#1}% \fi} @@ -72,7 +73,7 @@ {\traceposstring\clap\red{<#1>}% \the\everyinsertpositionaction \the\everypositionaction - \csname\POSactionprefix#1::\endcsname + \csname\??positionaction#1\endcsname \positions_cleanup_action{#1}}% \smashedbox\scratchbox % smashing is really needed else we get problems with too big overlays \endgroup @@ -80,39 +81,38 @@ %D Here the complication has to do with collecting actions %D for later execution. This collection is especially handy -%D when we want to move actions to a specific layer. -%D Such series of actions are stored in a macro (the one -%D with the funny \type {++}) which is cleaned up after each -%D invocation. +%D when we want to move actions to a specific layer. Such +%D series of actions are stored in a macro that is cleaned up +%D after each invocation. % this can probably be done better % \def\positions_cleanup_action#1% not in trialtypesetting -% {\ifcsname\POSactionprefix#1++\endcsname +% {\ifcsname\??positioncleanup#1\endcsname % \the\everycleanpositionaction % \iflocalpositioning -% \letgvalue{\POSactionprefix#1++}\empty +% \letgvalue{\??positioncleanup#1}\empty % \else -% \setxvalue{\POSactionprefix#1++}{\getvalue{\POSactionprefix#1++}}% +% \setxvalue{\??positioncleanup#1}{\getvalue{\??positioncleanup#1}}% % \fi % \fi} \def\positions_cleanup_action#1% not in trialtypesetting - {\ifcsname\POSactionprefix#1++\endcsname + {\ifcsname\??positioncleanup#1\endcsname \the\everycleanpositionaction \iflocalpositioning % erase - \expandafter\let\csname\POSactionprefix#1++\endcsname\empty + \expandafter\let\csname\??positioncleanup#1\endcsname\empty \else % globalize - \global\expandafter\let\csname\POSactionprefix#1++\expandafter\endcsname\csname\POSactionprefix#1++\endcsname + \global\expandafter\let\csname\??positioncleanup#1\expandafter\endcsname\csname\??positioncleanup#1\endcsname \fi \fi} \def\handlepositionaction#1\with#2\on#3% ugly {\begingroup \edef\!!stringa{\ifx\currentpositionoverlay\empty#3\else\currentpositionoverlay::\MPanchoridentifier\fi}% - \edef\!!stringc{\POSactionprefix\!!stringa++}% + \edef\!!stringc{\??positioncleanup\!!stringa}% \normalexpanded{\dosetpositionaction{\!!stringa}{\noexpand\getvalue{\!!stringc}}}% \global\let#1\relax \edef\!!stringb{\ifcsname\!!stringc\endcsname\csname\!!stringc\endcsname\fi}% why ... @@ -368,13 +368,17 @@ %D graphic, used immediately, with zero dimensions, so that a %D sequence of them does not harm. +\installcorenamespace{positiongraphic} +\installcorenamespace{positionmethod} +%installcorenamespace{graphicvariable} + \newbox\positiongraphicbox \def\startMPpositiongraphic % id setups {\dodoublegroupempty\positions_mp_graphic_start} \def\positions_mp_graphic_start#1#2#3\stopMPpositiongraphic % tag list mpcode - {\setgvalue{\??gp:#1}{\positions_mp_graphic_use{#1}{#2}{#3}}} + {\setgvalue{\??positiongraphic#1}{\positions_mp_graphic_use{#1}{#2}{#3}}} \let\stopMPpositiongraphic\relax @@ -397,9 +401,9 @@ {\dodoublegroupempty\positions_mp_graphic_direct} \def\positions_mp_graphic_direct#1% tag setups - {\ifcsname\??gq:#1\endcsname % method + {\ifcsname\??positionmethod#1\endcsname % method \expandafter\positions_mp_graphic_direct_indeed_method - \else\ifcsname \??gp:#1\endcsname + \else\ifcsname\??positiongraphic#1\endcsname \doubleexpandafter\positions_mp_graphic_direct_indeed_normal \else \doubleexpandafter\positions_mp_graphic_direct_indeed_unknown @@ -408,10 +412,10 @@ \let\positions_mp_graphic_direct_indeed_unknown\gobbletwoarguments \def\positions_mp_graphic_direct_indeed_method - {\positions_mp_graphic_direct_indeed\??gq} + {\positions_mp_graphic_direct_indeed\??positionmethod} \def\positions_mp_graphic_direct_indeed_normal - {\positions_mp_graphic_direct_indeed\??gp} + {\positions_mp_graphic_direct_indeed\??positiongraphic} \def\positions_mp_graphic_direct_indeed#1#2#3% what tag setups {\begingroup @@ -421,7 +425,7 @@ \ignoreMPboxdepth \def\positions_mp_graphic_direct{\positions_mp_graphic_nested{#3}}% takes two extra arguments \setbox\positiongraphicbox\hbox - {\ignorespaces\csname#1:#2\endcsname\removelastspace}% + {\ignorespaces\csname#1#2\endcsname\removelastspace}% \smashbox\positiongraphicbox \box\positiongraphicbox \endgroup} @@ -431,11 +435,11 @@ \setupMPvariables[#2][#1,#3]% \edef\currentmpvariableclass{#2}% \positions_mp_graphic_prepare - \getvalue{\??gp:#2}% + \getvalue{\??positiongraphic#2}% \endgroup}% \def\startMPpositionmethod#1#2\stopMPpositionmethod - {\setgvalue{\??gq:#1}{#2}} % todo: var list here + {\setgvalue{\??positionmethod#1}{#2}} % todo: var list here \let\stopMPpositionmethod\relax diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index 898607cb4..01a662ae2 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -151,7 +151,7 @@ \appendtoks \localpositioningfalse -\to \everypagebody +\to \everybeforepagebody %D \macros %D {MPp, MPx, MPy, MPw, MPh, MPd, diff --git a/tex/context/base/anch-tab.mkiv b/tex/context/base/anch-tab.mkiv index 137b96889..62b46dc46 100644 --- a/tex/context/base/anch-tab.mkiv +++ b/tex/context/base/anch-tab.mkiv @@ -33,8 +33,10 @@ \def\dotablebpos{\bpos} \def\dotableepos{\epos} +\installcorenamespace{positiontables} + \def\tbPOSprefix - {tbp:\number\noftabpositions:} + {\??positiontables\number\noftabpositions:} \def\tablepos {\normalexpanded{\global\posXCtoks\emptytoks\the\posXCtoks}} diff --git a/tex/context/base/attr-col.lua b/tex/context/base/attr-col.lua index 6683e9a2d..c592d1dc1 100644 --- a/tex/context/base/attr-col.lua +++ b/tex/context/base/attr-col.lua @@ -48,7 +48,7 @@ local unsetvalue = attributes.unsetvalue -- we can also collapse the two attributes: n, n+1, n+2 and then -- at the tex end add 0, 1, 2, but this is not faster and less -- flexible (since sometimes we freeze color attribute values at --- the lua end of the game +-- the lua end of the game) -- -- we also need to store the colorvalues because we need then in mp -- diff --git a/tex/context/base/attr-col.mkiv b/tex/context/base/attr-col.mkiv index 47a26df22..6231755e9 100644 --- a/tex/context/base/attr-col.mkiv +++ b/tex/context/base/attr-col.mkiv @@ -17,6 +17,6 @@ \unprotect -% We implement this elsewhere. +% We implement this elsewhere but some coce might end up here. \protect \endinput diff --git a/tex/context/base/attr-lay.mkiv b/tex/context/base/attr-lay.mkiv index 047bbcd45..67cd204e2 100644 --- a/tex/context/base/attr-lay.mkiv +++ b/tex/context/base/attr-lay.mkiv @@ -63,7 +63,7 @@ \appendtoks \let\currentviewerlayer\empty -\to \everypagebody +\to \everybeforepagebody % layout components are implemented rather directly (speed) diff --git a/tex/context/base/back-exp.mkiv b/tex/context/base/back-exp.mkiv index 202171a91..7fcb27ff2 100644 --- a/tex/context/base/back-exp.mkiv +++ b/tex/context/base/back-exp.mkiv @@ -29,17 +29,17 @@ \definesystemattribute[taggedpar][public] \unexpanded\def\setelementexporttag - {\dotripleargument\dosetelementexporttag} + {\dotripleargument\backend_set_element_export_tag} -\def\dosetelementexporttag +\def\back_set_element_export_tag {\ifthirdargument - \expandafter\dosetelementexporttaga + \expandafter \backend_set_element_export_tag_a \else\ifsecondargument - \expandafter\expandafter\expandafter\dosetelementexporttagb + \doubleexpandafter\backend_set_element_export_tag_b \fi\fi} -\unexpanded\def\dosetelementexporttaga[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","#2","#3")}} -\unexpanded\def\dosetelementexporttagb[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","export","#2")}} +\def\backend_set_element_export_tag_a[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","#2","#3")}} +\def\backend_set_element_export_tag_a[#1][#2][#3]{\taggedctxcommand{settagproperty("#1","export","#2")}} % todo: no need for calls when trialtypesetting @@ -119,16 +119,14 @@ % The action: \setupbackend[export=yes] % or filename -% maybe we will move css to setupexport ? or just support both - -\def\c!export {export} % maybe: option={css,xhtml} -\def\c!css {css} -\def\c!xhtml {xhtml} +% maybe xhtml css settings will move to setupexport % maybe some day a definer -\installparameterhandler \??be {export} -\installsetuphandler \??be {export} +\installcorenamespace{export} + +\installparameterhandler \??export {export} +\installsetuphandler \??export {export} \setupexport [\c!align=\number\raggedstatus, diff --git a/tex/context/base/back-ini.mkiv b/tex/context/base/back-ini.mkiv index f2301b7a3..4324a9eb5 100644 --- a/tex/context/base/back-ini.mkiv +++ b/tex/context/base/back-ini.mkiv @@ -138,28 +138,19 @@ %D know what the target file will be. In other driver %D modules we wil set \type {\jobsuffix} to \type {pdf}. -\def\jobsuffix{pdf} +%D Backend configuration: -\ifdefined\resetsystemmode \else % can't happen - \let\setsystemmode \gobbleoneargument - \let\resetsystemmode\gobbleoneargument -\fi +\installcorenamespace{backend} -\def\setjobsuffix#1% - {\resetsystemmode\jobsuffix - \edef\jobsuffix{#1}% - \setsystemmode\jobsuffix} - -\unexpanded\def\setupoutput[#1]{} % will be command line switch +\installdirectcommandhandler \??backend {backend} -%D New: +\let\jobsuffix\empty -\newtoks\everysetupbackend - -\def\backendparameter#1{\csname\ifcsname\??bc#1\endcsname\??bc#1\else\s!empty\fi\endcsname} +\unexpanded\def\backend_set_job_suffix#1% % checking could happen in mode + {\ifx\jobsuffix\empty\else\resetsystemmode\jobsuffix\fi + \edef\jobsuffix{#1}% + \ifx\jobsuffix\empty\else\setsystemmode \jobsuffix\fi} -\def\setupbackend[#1]% - {\getparameters[\??bc][#1]% - \the\everysetupbackend} +\backend_set_job_suffix{pdf} % default \protect \endinput diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index bd0b12733..8d4f0d6c7 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -56,9 +56,9 @@ %D This one can be consulted by users although the suffix is also %D a system mode. -\setjobsuffix{pdf} +\backend_set_job_suffix{pdf} -%D PDF/X (matbe combine the two lua calls) +%D PDF/X (maybe combine the two lua calls) \setupbackend [xmpfile=] @@ -87,22 +87,21 @@ %D These are the only official methods to add stuff to the resources. -\def\pdfbackendsetcatalog #1#2{\ctxlua{lpdf.addtocatalog ("#1",\!!bs#2\!!es)}} -\def\pdfbackendsetinfo #1#2{\ctxlua{lpdf.addtoinfo ("#1",\!!bs#2\!!es)}} -\def\pdfbackendsetname #1#2{\ctxlua{lpdf.addtonames ("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetcatalog #1#2{\ctxlua{lpdf.addtocatalog ("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetinfo #1#2{\ctxlua{lpdf.addtoinfo ("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetname #1#2{\ctxlua{lpdf.addtonames ("#1",\!!bs#2\!!es)}} -\def\pdfbackendsetpageattribute #1#2{\ctxlua{lpdf.addtopageattributes ("#1",\!!bs#2\!!es)}} -\def\pdfbackendsetpagesattribute#1#2{\ctxlua{lpdf.addtopagesattributes("#1",\!!bs#2\!!es)}} -\def\pdfbackendsetpageresource #1#2{\ctxlua{lpdf.addtopageresources ("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetpageattribute #1#2{\ctxlua{lpdf.addtopageattributes ("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetpagesattribute#1#2{\ctxlua{lpdf.addtopagesattributes("#1",\!!bs#2\!!es)}} +\unexpanded\def\pdfbackendsetpageresource #1#2{\ctxlua{lpdf.addtopageresources ("#1",\!!bs#2\!!es)}} -\def\pdfbackendsetextgstate #1#2{\ctxlua{lpdf.adddocumentextgstate ("#1",lpdf.verbose(\!!bs#2\!!es))}} -\def\pdfbackendsetcolorspace #1#2{\ctxlua{lpdf.adddocumentcolorspace("#1",lpdf.verbose(\!!bs#2\!!es))}} -\def\pdfbackendsetpattern #1#2{\ctxlua{lpdf.adddocumentpattern ("#1",lpdf.verbose(\!!bs#2\!!es))}} -\def\pdfbackendsetshade #1#2{\ctxlua{lpdf.adddocumentshade ("#1",lpdf.verbose(\!!bs#2\!!es))}} +\unexpanded\def\pdfbackendsetextgstate #1#2{\ctxlua{lpdf.adddocumentextgstate ("#1",lpdf.verbose(\!!bs#2\!!es))}} +\unexpanded\def\pdfbackendsetcolorspace #1#2{\ctxlua{lpdf.adddocumentcolorspace("#1",lpdf.verbose(\!!bs#2\!!es))}} +\unexpanded\def\pdfbackendsetpattern #1#2{\ctxlua{lpdf.adddocumentpattern ("#1",lpdf.verbose(\!!bs#2\!!es))}} +\unexpanded\def\pdfbackendsetshade #1#2{\ctxlua{lpdf.adddocumentshade ("#1",lpdf.verbose(\!!bs#2\!!es))}} -\def\pdfbackendcurrentresources {\cldcontext{lpdf.collectedresources()}} - -\def\pdfcolor #1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}} \let\PDFcolor\pdfcolor + \def\pdfbackendcurrentresources {\cldcontext{lpdf.collectedresources()}} + \def\pdfcolor #1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}} \let\PDFcolor\pdfcolor %D Let's block these: @@ -223,13 +222,13 @@ \def\dostartobject#1#2#3#4#5% {\bgroup \setbox\objectbox\vbox\bgroup - \def\dodostopobject{\egroup\doregisterobject{#1}{#2}}} + \def\backend_stop_object{\egroup\backend_register_object{#1}{#2}}} \def\dostopobject - {\dodostopobject + {\backend_stop_object \egroup} -\def\doregisterobject#1#2% +\def\backend_register_object#1#2% {\the\pdfbackendeveryxform \finalizeobjectbox\objectbox \immediate\pdfxform resources {\pdfbackendcurrentresources}\objectbox @@ -241,7 +240,8 @@ \def\doinsertobject#1#2% {\begingroup \doifobjectreferencefoundelse{#1}{#2} - {\dogetobjectreference{#1}{#2}\PDFobjectreference\pdfrefxform\PDFobjectreference}% + {\dogetobjectreference{#1}{#2}\m_backend_object_reference + \pdfrefxform\m_backend_object_reference}% \donothing \endgroup} @@ -251,8 +251,8 @@ {\begingroup \xdef\lastpredefinedsymbol{#1}% \settightobject{SYM}{#1}\hbox{\symbol[#1]}% to be checked ... maybe only fitting - \dogetobjectreference{SYM}{#1}\lastref - \ctxlua{backends.codeinjections.registersymbol("#1",\lastref)}% + \dogetobjectreference{SYM}{#1}\m_backend_object_reference + \ctxlua{backends.codeinjections.registersymbol("#1",\m_backend_object_reference)}% \endgroup} % for the moment here @@ -268,24 +268,39 @@ %D implemented in the \POSTSCRIPT\ driver. This code is %D somewhat obsolete as we now have metapost embedded. -\def\doPDFovalcalc#1#2#3% - {\PointsToBigPoints{\dimexpr#1+#2\relax}#3} +% \def\backend_oval_calc#1#2#3% +% {\PointsToBigPoints{\dimexpr#2+#3\relax}#1} -\unexpanded\def\doovalbox#1#2#3#4#5#6#7#8% todo: \scratchdimen/\scatchbox +\unexpanded\def\doovalbox#1#2#3#4#5#6#7#8% {\forcecolorhack \bgroup - \dimen0=#4\divide\dimen0 \plustwo - \doPDFovalcalc{0pt}{+\dimen0}\xmin - \doPDFovalcalc{#1}{-\dimen0}\xmax - \doPDFovalcalc{#2}{-\dimen0}\ymax - \doPDFovalcalc{-#3}{+\dimen0}\ymin - \advance\dimen0 by #5% - \doPDFovalcalc{0pt}{+\dimen0}\xxmin - \doPDFovalcalc{#1}{-\dimen0}\xxmax - \doPDFovalcalc{#2}{-\dimen0}\yymax - \doPDFovalcalc{-#3}{+\dimen0}\yymin - \doPDFovalcalc{#4}{\zeropoint}\stroke - \doPDFovalcalc{#5}{\zeropoint}\radius +% \scratchdimen#4% +% \divide\scratchdimen\plustwo +% \backend_oval_calc\xmin \zeropoint\scratchdimen +% \backend_oval_calc\xmax {#1}{-\scratchdimen}% +% \backend_oval_calc\ymax {#2}{-\scratchdimen}% +% \backend_oval_calc\ymin {-#3}\scratchdimen +% \advance\scratchdimen by #5% +% \backend_oval_calc\xxmin \zeropoint\scratchdimen +% \backend_oval_calc\xxmax {#1}{-\scratchdimen}% +% \backend_oval_calc\yymax {#2}{-\scratchdimen}% +% \backend_oval_calc\yymin {-#3}\scratchdimen +% \backend_oval_calc\stroke{#4}\zeropoint +% \backend_oval_calc\radius{#5}\zeropoint + % + \PointsToBigPoints{#4} \stroke + \PointsToBigPoints{#5} \radius + \scratchdimen\dimexpr#4/\plustwo\relax + \PointsToBigPoints \scratchdimen \xmin + \PointsToBigPoints{\dimexpr #1-\scratchdimen}\xmax + \PointsToBigPoints{\dimexpr #2-\scratchdimen}\ymax + \PointsToBigPoints{\dimexpr-#3+\scratchdimen}\ymin + \advance\scratchdimen by #5\relax + \PointsToBigPoints \scratchdimen \xxmin + \PointsToBigPoints{\dimexpr #1-\scratchdimen}\xxmax + \PointsToBigPoints{\dimexpr #2-\scratchdimen}\yymax + \PointsToBigPoints{\dimexpr-#3+\scratchdimen}\yymin + % \edef\dostroke{#6}% \edef\dofill{#7}% \edef\mode{\number#8 \space}% @@ -483,10 +498,13 @@ \fi Q}% \fi}% - \wd\scratchbox#1\ht\scratchbox#2\dp\scratchbox#3\box\scratchbox + \wd\scratchbox#1% + \ht\scratchbox#2% + \dp\scratchbox#3% + \box\scratchbox \egroup} -\unexpanded\def\pdfactualtext#1#2% +\unexpanded\def\pdfactualtext#1#2% not interfaced {\pdfliteral direct{/Span <> BDC}% #1% \pdfliteral direct{EMC}} diff --git a/tex/context/base/buff-ini.mkiv b/tex/context/base/buff-ini.mkiv index 7fedd3b60..3fe9f18dd 100644 --- a/tex/context/base/buff-ini.mkiv +++ b/tex/context/base/buff-ini.mkiv @@ -27,150 +27,128 @@ \def\doifelsebuffer#1% {\ctxcommand{doifelsebuffer("#1")}} -\def\resetbuffer - {\dosingleempty\doresetbuffer} +\unexpanded\def\resetbuffer + {\dosingleempty\buffers_reset} -\def\doresetbuffer[#1]% +\def\buffers_reset[#1]% {\ctxcommand{erasebuffer("#1")}} -\unexpanded\def\dostartdefinedbuffer +\setuvalue{\e!start\v!buffer}% {\bgroup \obeylines - \doquadrupleempty\dodostartbuffer} + \dosingleempty\buffers_start} -\let\dostartbuffer\dostartdefinedbuffer % used in some modules +\def\buffers_start[#1]% + {\buffers_start_indeed{}{#1}{\e!start\v!buffer}{\e!stop\v!buffer}} -\def\dodostartbuffer[#1][#2][#3][#4]% [category] [name] [start] [stop] - {\iffourthargument - \def\next{\dododostartbuffer{#1}{#2}{#3}{#4}}% - \else - \def\next{\dododostartbuffer {}{#1}{#2}{#3}}% - \fi - \next} - -\def\dododostartbuffer#1#2#3#4% \donothing needed ! - {\normalexpanded{\dodowithbuffer{#2}{#3}{#4}{\donothing}{\egroup\noexpand\getvalue{#4}}}} +\def\buffers_start_indeed#1#2#3#4% \donothing needed ! + {\normalexpanded{\buffers_pickup{#2}{#3}{#4}{}{\buffers_stop{#4}}}} -\setvalue{\e!start\v!buffer}% +\unexpanded\def\grabbufferdata % was: \dostartbuffer {\bgroup \obeylines - \dosingleempty\redostartbuffer} + \doquadrupleempty\buffers_grab_direct_indeed} -\def\redostartbuffer[#1]% - {\dododostartbuffer{}{#1}{\e!start\v!buffer}{\e!stop\v!buffer}} +\unexpanded\def\grabbufferdatadirect % name start stop + {\buffers_start_indeed\empty} -\def\dowithbuffer#1#2#3% name, startsequence, stopsequence, before, after - {\normalexpanded{\dodowithbuffer{#1}{#2}{#3}}} +\def\buffers_grab_direct_indeed % [category] [name] [start] [stop] + {\iffourthargument + \expandafter\buffers_grab_direct_indeed_a + \else + \expandafter\buffers_grab_direct_indeed_b + \fi} + +\def\buffers_grab_direct_indeed_a[#1][#2][#3][#4]{\buffers_start_indeed{#1}{#2}{#3}{#4}} +\def\buffers_grab_direct_indeed_b[#1][#2][#3][#4]{\buffers_start_indeed\empty{#1}{#2}{#3}} -\unexpanded\long\def\dodowithbuffer#1#2#3#4#5% name, startsequence, stopsequence, before, after +\unexpanded\def\buffers_pickup#1#2#3#4#5% name, startsequence, stopsequence, before, after {#4% \bgroup \edef\catcodetableofbuffer{\number\catcodetable}% \ctxcommand{erasebuffer("#1")}% - \setcatcodetable \vrbcatcodes - \long\def\nododowithbuffer + \setcatcodetable\vrbcatcodes + \def\buffers_finish {\egroup #5}% - \long\def\dododowithbuffer##1#3% is detokenize needed? TEST + \def\buffers_gobble##1#3% is detokenize needed? TEST %{\ctxcommand{grabbuffer("#1","#2","#3",\!!bs\detokenize{##1}\!!es)} % space ? {\ctxcommand{grabbuffer("#1","#2","#3",\!!bs>##1\!!es,\catcodetableofbuffer)}% space ? - \dododowithbuffer - \nododowithbuffer}% - \dododowithbuffer} + \buffers_gobble + \buffers_finish}% + \buffers_gobble} -\def\setbuffer - {\dosingleempty\dosetbuffer} +\unexpanded\def\buffers_stop#1% + {\egroup + \getvalue{#1}} + +\unexpanded\def\setbuffer + {\dosingleempty\buffers_set} \let\endbuffer\relax -\long\def\dosetbuffer[#1]#2\endbuffer % seldom used so we just pass #2 +\def\buffers_set[#1]#2\endbuffer % seldom used so we just pass #2 {\ctxcommand{assignbuffer("#1",\!!bs\detokenize{#2}\!!es,\number\catcodetable)}} -\def\namedbufferparameter#1#2{\csname\??bu#1#2\endcsname} +% beware, never adapt the global buffer settings, actually we might introduce +% a broken parent chain for this purpose but on the other hand it's not that +% different from framed cum suis -\unexpanded\def\setupbuffer - {\dodoubleempty\dosetupbuffer} +\installcorenamespace{buffer} -\def\dosetupbuffer[#1][#2]% - {\ifsecondargument - \getparameters[\??bu#1][#2]% - \else - \getparameters[\??bu][#1]% - \fi} - -\newtoks\everydefinebuffer - -\unexpanded\def\definebuffer - {\dodoubleempty\dodefinebuffer} - -\def\dodefinebuffer[#1][#2]% - {\iffirstargument - \global\advance\nofdefinedbuffers\plusone - \setevalue{\??bu#1\c!number}{\number\nofdefinedbuffers}% - \def\currentbuffer{#1}% - \getparameters[\??bu#1][#2]% - \the\everydefinebuffer - \else - % fatal error - \fi} +\installcommandhandler \??buffer {buffer} \??buffer -\def\thebuffernumber #1{\csname\??bu#1\c!number\endcsname} -\def\thedefinedbuffer#1{def-\csname\??bu#1\c!number\endcsname} +\setupbuffer + [\c!before=, + \c!after=] \appendtoks - \setuevalue{\e!start\currentbuffer}% - {\noexpand\dostartdefinedbuffer - [\currentbuffer]% - [def-\number\nofdefinedbuffers]% - [\e!start\currentbuffer]% - [\e!stop\currentbuffer]}% - \setuevalue{\e!get\currentbuffer}% - {\noexpand\dogetdefinedbuffer - [\currentbuffer]% - [def-\number\nofdefinedbuffers]}% + \global\advance\nofdefinedbuffers\plusone + \setexpandedbufferparameter\c!number{\number\nofdefinedbuffers}% + \setuevalue{\e!start\currentbuffer}{\buffers_start_indeed + {\currentbuffer}{def-\number\nofdefinedbuffers}{\e!start\currentbuffer}{\e!stop\currentbuffer}}% + \setuevalue{\e!get\currentbuffer}{\buffers_get_stored + {\currentbuffer}{def-\number\nofdefinedbuffers}}% \to \everydefinebuffer -\def\doprocessbufferlist#1#2% - {\doifelsenothing{#1} - {\dododogetbuffer\empty} - {\processcommalist[#1]#2}} +\def\thebuffernumber #1{\namedbufferparameter{#1}\c!number} +\def\thedefinedbuffer#1{def-\namedbufferparameter{#1}\c!number} \unexpanded\def\getbuffer % no [settings yet] - {\dosingleempty\dogetbuffer} + {\dosingleempty\buffers_get} -\unexpanded\def\dogetbuffer[#1]% [name] +\unexpanded\def\buffers_get[#1]% [name] {\namedbufferparameter\empty\c!before - \doprocessbufferlist{#1}\dododogetbuffer + \doifelsenothing{#1} + {\buffers_get_stored_indeed\empty} + {\processcommalist[#1]\buffers_get_stored_indeed}% \namedbufferparameter\empty\c!after} -\def\dogetdefinedbuffer[#1][#2]% +\unexpanded\def\buffers_get_stored#1#2% {\namedbufferparameter{#1}\c!before - \dododogetbuffer{#2}% + \buffers_get_stored_indeed{#2}% \namedbufferparameter{#1}\c!after} -\unexpanded\def\dododogetbuffer#1% +\unexpanded\def\buffers_get_stored_indeed#1% {\ctxcommand{getbuffer("#1")}} -\definebuffer[\v!hiding] \setupbuffer[\v!hiding][\c!before=,\c!after=] +\definebuffer + [\v!hiding] + +\setupbuffer + [\v!hiding] + [\c!before=, + \c!after=] -% \let\processTEXbuffer\getbuffer % handy synonym +\unexpanded\def\processTEXbuffer + {\dosingleempty\buffers_process_tex} -\unexpanded\def\doprocesstexbuffer#1% +\def\buffers_process_tex[#1]% {\pushcatcodetable \catcodetable\ctxcatcodes % \setcatcodetable - \dododogetbuffer{#1}% + \buffers_get_stored_indeed{#1}% \popcatcodetable} -\unexpanded\def\processTEXbuffer - {\dosingleempty\doprocessTEXbuffer} - -\def\doprocessTEXbuffer[#1]% - {\doprocesstexbuffer{#1}} - -\setupbuffer - [\c!before=, - \c!after=] - % only mkiv: % % \startbuffer[x] @@ -179,9 +157,11 @@ % % \savebuffer[x][temp.log] -\unexpanded\def\savebuffer{\dodoubleempty\dosavebuffer} +\unexpanded\def\savebuffer + {\dodoubleempty\buffers_save} -\def\dosavebuffer[#1][#2]{\ctxcommand{savebuffer("#1","#2")}} +\def\buffers_save[#1][#2]% + {\ctxcommand{savebuffer("#1","#2")}} %D Experimental: no expansion of commands in buffer! @@ -194,11 +174,17 @@ % % \ctxluabuffer[what] \ctxluabuffer -\def\ctxluabuffer {\dosingleempty\doctxluabuffer} -\def\mkvibuffer {\dosingleempty\domkvibuffer} -\def\mkvibufferraw{\dosingleempty\domkvibufferraw} +\unexpanded\def\ctxluabuffer {\dosingleempty\buffers_ctxlua} +\unexpanded\def\mkvibuffer {\dosingleempty\buffers_mkvi} +% what was: \mkvibufferraw + +\def\buffers_ctxlua[#1]{\ctxcommand{getbufferctxlua("#1")}} +\def\buffers_mkvi [#1]{\ctxcommand{getbuffermkvi("#1")}} + +% used elsewhere + +\unexpanded\def\doprocesstexbuffer#1{\buffers_process_tex[#1]} % still used? -\def\doctxluabuffer [#1]{\ctxcommand{getbufferctxlua("#1")}} -\def\domkvibuffer [#1]{\ctxcommand{getbuffermkvi("#1")}} +\let\dostartbuffer\grabbufferdata % for old times sake \protect \endinput diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 36f9130ef..9f767be32 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -23,6 +23,10 @@ %D Initializations. +\installcorenamespace{typinglines} +\installcorenamespace{typingspace} +\installcorenamespace{typingblank} % needs checking ... used? + \newtoks\everyinitializeverbatim \appendtoks @@ -37,31 +41,31 @@ \unexpanded\def\specialcontrolspace{\hskip\zeropoint\fastcontrolspace\hskip\zeropoint} -\setvalue{\??tp:\c!lines:\v!yes }{\obeybreakpoints} -\setvalue{\??tp:\c!lines:\v!hyphenated}{\obeyhyphens} +\setvalue{\??typinglines\v!yes }{\obeybreakpoints} +\setvalue{\??typinglines\v!hyphenated}{\obeyhyphens} -\setvalue{\??tp:\c!space:\v!on }{\let\obeyedspace\specialcontrolspace} -\setvalue{\??tp:\c!space:\v!stretch }{\let\obeyedspace\specialstretchedspace} -\setvalue{\??tp:\c!space:\v!normal }{} -\setvalue{\??tp:\c!space:\v!fixed }{\let\obeyedspace\specialfixedspace} +\setvalue{\??typingspace\v!on }{\let\obeyedspace\specialcontrolspace} +\setvalue{\??typingspace\v!stretch }{\let\obeyedspace\specialstretchedspace} +\setvalue{\??typingspace\v!normal }{} +\setvalue{\??typingspace\v!fixed }{\let\obeyedspace\specialfixedspace} -\setvalue{\??tp:\c!blank:\v!standard }{\ctxparskip} -\setvalue{\??tp:\c!blank:\v!small }{\smallskipamount} -\setvalue{\??tp:\c!blank:\v!medium }{\medskipamount} -\setvalue{\??tp:\c!blank:\v!big }{\bigskipamount} -\setvalue{\??tp:\c!blank:\v!halfline }{.5\baselineskip} -\setvalue{\??tp:\c!blank:\v!line }{\baselineskip} -\setvalue{\??tp:\c!blank:\v!none }{\zeropoint} +\setvalue{\??typingblank\v!standard }{\ctxparskip} +\setvalue{\??typingblank\v!small }{\smallskipamount} +\setvalue{\??typingblank\v!medium }{\medskipamount} +\setvalue{\??typingblank\v!big }{\bigskipamount} +\setvalue{\??typingblank\v!halfline }{.5\baselineskip} +\setvalue{\??typingblank\v!line }{\baselineskip} +\setvalue{\??typingblank\v!none }{\zeropoint} \def\secondstageinitializetype {\let\obeyedspace\specialobeyedspace - \csname\??tp:\c!space:\typeparameter\c!space\endcsname + \csname\??typingspace\typeparameter\c!space\endcsname \relax\the\everyinitializeverbatim\relax} \def\secondstageinitializetyping {\let\obeyedspace\specialobeyedspace - \csname\??tp:\c!space:\typingparameter\c!space\endcsname - \csname\??tp:\c!lines:\typingparameter\c!lines\endcsname + \csname\??typingspace\typingparameter\c!space\endcsname + \csname\??typinglines\typingparameter\c!lines\endcsname \relax\the\everyinitializeverbatim\relax} \def\firststageinitializetype @@ -108,7 +112,9 @@ %D Specific inline verbatim commands can be defined with the %D following command. -\installcommandhandler \??ty {type} \??ty +\installcorenamespace{type} + +\installcommandhandler \??type {type} \??type \appendtoks \normalexpanded{\dodefinetype{\currenttype}}% @@ -138,7 +144,9 @@ %D %D The definitions default to the standard typing values. -\installcommandhandler \??tp {typing} \??tp +\installcorenamespace{typing} + +\installcommandhandler \??typing {typing} \??typing \appendtoks \setuevalue{\e!start\currenttyping}{\dostarttyping{\currenttyping}}% @@ -420,7 +428,7 @@ \normalexpanded{\dotypeblockverbatim{\e!start\currenttyping}{\e!stop\currenttyping}}} \unexpanded\def\dotypeblockverbatim#1#2% - {\dowithbuffer{_typing_}{#1}{#2}{}{\dodotypeblockverbatim{#1}{#2}}} + {\buffers_pickup{_typing_}{#1}{#2}{}{\dodotypeblockverbatim{#1}{#2}}} % was dowithbuffer \def\dodotypeblockverbatim#1#2% {\secondstageinitializetyping @@ -649,8 +657,8 @@ \definetyping[\v!typing] -\setuptyping[\v!file] [\s!parent=\??tp\v!typing] % we don't want \start..\stop overload -\setuptyping[\v!buffer][\s!parent=\??tp\v!file] % we don't want \start..\stop overload +\setuptyping[\v!file] [\s!parent=\??typing\v!typing] % we don't want \start..\stop overload +\setuptyping[\v!buffer][\s!parent=\??typing\v!file] % we don't want \start..\stop overload %D The setups for inline verbatim default to: diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index 998ff942a..40e631c87 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -49,6 +49,8 @@ \unprotect +\installcorenamespace{chemicalsymbol} + \unexpanded\def\setupchemical {\dosingleempty\dosetupchemical} @@ -80,16 +82,16 @@ {\dodoubleempty\dodefinechemicalsymbol} \def\dodefinechemicalsymbol[#1][#2]% - {\setvalue{\??cm::#1}{#2}} + {\setvalue{\??chemicalsymbol#1}{#2}} \unexpanded\def\chemicalsymbol[#1]% - {\getvalue{\??cm::#1}} + {\getvalue{\??chemicalsymbol#1}} % size (small medium big) \unexpanded\def\dosetchemicaltext - {\dousestyleparameter\@cmstyle - \dousecolorparameter\@cmcolor} + {\dousestyleparameter\@@cmstyle + \dousecolorparameter\@@cmcolor} \edef\chemicaltoplocation{t} \edef\chemicalbotlocation{b} @@ -505,17 +507,17 @@ % \formulachemicalmid\expandafter{\the\formulachemicalmid\dodochemicalformulamid{#1}&}} % % \def\dodochemicalformulamid#1% -% {\ifcsname\??cm::\detokenize{#1}\endcsname -% \csname\??cm::\detokenize{#1}\expandafter\endcsname{}{}% +% {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname +% \csname\??chemicalsymbol\detokenize{#1}\expandafter\endcsname{}{}% % \else % \molecule{#1}{}{}% % \fi} \def\domidformulachemical#1% - {\csname\??cm::\detokenize{#1}\endcsname} + {\csname\??chemicalsymbol\detokenize{#1}\endcsname} \def\doformulachemical#1#2#3% we could do hboxes and measure - {\ifcsname\??cm::\detokenize{#1}\endcsname + {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname \formulachemicalmid\expandafter{\the\formulachemicalmid\domidformulachemical{#1}{#2}{#3}}% \else \ifthirdargument diff --git a/tex/context/base/colo-ext.mkiv b/tex/context/base/colo-ext.mkiv index 6cb02f88b..12af6798a 100644 --- a/tex/context/base/colo-ext.mkiv +++ b/tex/context/base/colo-ext.mkiv @@ -29,10 +29,10 @@ %D %D will negate the colors in box zero. -\def\negatecolorbox#1% +\unexpanded\def\negatecolorbox#1% {\setbox#1\hbox {\startnegativeproperty % might change - \startcolor[white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor + \startcolor[\s!white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor \hskip-\wd#1% \box#1% \stopnegativeproperty}} @@ -43,89 +43,57 @@ %D We can move the stack and attribute setting to the \LUA\ end. -\def\registercolorintent#1#2% - {\setevalue{\??qi:#1}{\attribute\colorintentattribute\ctxcommand{registercolorintent('#2')} }} +\installcorenamespace{colorintent} -\def\dotriggercolorintent +\unexpanded\def\registercolorintent#1#2% + {\setevalue{\??colorintent#1}{\attribute\colorintentattribute\ctxcommand{registercolorintent('#2')} }} + +\unexpanded\def\colors_trigger_intent {\ctxcommand{enablecolorintents()}% - \gdef\dotriggercolorintent##1{\csname\??qi:##1\endcsname}% - \dotriggercolorintent} + \unexpanded\gdef\colors_trigger_intent##1{\csname\??colorintent##1\endcsname}% + \colors_trigger_intent} \registercolorintent{knockout} {knockout} \registercolorintent{overprint}{overprint} \installattributestack\colorintentattribute -\setevalue{\??qi:\v!none}{\attribute\colorintentattribute\attributeunsetvalue} % or reset? used at all? +\setevalue{\??colorintent\v!none}{\attribute\colorintentattribute\attributeunsetvalue} % or reset? used at all? \unexpanded\def\startcolorintent[#1]% {\pushattribute\colorintentattribute - \dotriggercolorintent{#1}} + \colors_trigger_intent{#1}} \unexpanded\def\stopcolorintent {\popattribute\colorintentattribute} \unexpanded\def\startoverprint{\startcolorintent[\v!overprint]} -\unexpanded\def\stopoverprint {\stopcolorintent} - \unexpanded\def\startknockout {\startcolorintent[\v!knockout ]} -\unexpanded\def\stopknockout {\stopcolorintent} + +\let\stopoverprint\stopcolorintent +\let\stopknockout \stopcolorintent \let\starttextcolorintent\relax \let\stoptextcolorintent \relax -\setupcolors - [\c!overprint=\v!no] - \appendtoks - \dosettextcolorintent + \colors_set_text_intent \to \everysetupcolors -\def\dosettextcolorintent - {\doifnot\@@clintent\v!none - {\xdef\starttextcolorintent{\noexpand\dotriggercolorintent{\@@clintent}}% - \glet\dosettextcolorintent\relax - \dotriggercolorintent\@@clintent}} +\let\p_colors_intent\empty + +\def\colors_set_text_intent + {\edef\p_colors_intent{\colorsparameter\c!intent}% + \ifx\p_colors_intent\v!none \else + \unexpanded\xdef\starttextcolorintent{\colors_trigger_intent{\p_colors_intent}}% + \glet\colors_set_text_intent\relax + \colors_trigger_intent\p_colors_intent + \fi} \appendtoks \starttextcolorintent \to \everystarttextproperties \appendtoks \stoptextcolorintent \to \everystoptextproperties -\setupcolors[\c!intent=\v!none] - -% A goodie that replaces the startMPcolor hackery - -% \definecolor[red-t] [r=1,t=0.5,a=1] -% \definecolor[green-t][g=1,t=0.5,a=1] -% -% \defineintermediatecolor[mycolora][0.5,red,green] -% \defineintermediatecolor[mycolorb][0.5,red-t,green-t] -% -% \definecolor[mycolorc][.5(blue,red)] -% \definecolor[mycolord][.5(blue)] -% -% \enabledirectives[colors.pgf] -% \definecolor[mycolorx][magenta!50!yellow] -% -% \starttext -% test {\mycolora OEPS} test -% test {\mycolorb OEPS} test -% test {\mycolorc OEPS} test -% test {\mycolord OEPS} test -% test {\mycolorx OEPS} test -% \stoptext - -\unexpanded\def\defineintermediatecolor - {\dotripleempty\dodefineintermediatecolor} - -\def\dodefineintermediatecolor[#1][#2][#3]% \dotripleempty adds {} inside [] - {\dododefineintermediatecolor[#1][#2][#3]} - -\def\dododefineintermediatecolor[#1][#2,#3,#4][#5]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{defineintermediatecolor("#1","#2", - \thecolorattribute{#3},\thecolorattribute{#4}, - \thetransparencyattribute{#3},\thetransparencyattribute{#4}, - "#5",false,\iffreezecolors true\else false\fi)}% not global - \dodefinecolorcommand\setvalue{#1}} +\setupcolors + [\c!intent=\v!none] \protect \endinput diff --git a/tex/context/base/colo-grp.mkiv b/tex/context/base/colo-grp.mkiv new file mode 100644 index 000000000..a6cf0fbf3 --- /dev/null +++ b/tex/context/base/colo-grp.mkiv @@ -0,0 +1,168 @@ +%D \module +%D [ file=colo-grp, +%D version=2011.12.27, % moved from colo-ini +%D title=\CONTEXT\ Color Macros, +%D subtitle=Groups, +%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. + +%D Regular colors and palets are used most, contrary to groups +%D which is why we define their support in a separate module. + +\writestatus{loading}{ConTeXt Color Macros / Groups} + +\unprotect + +%D \macros +%D {definecolorgroup} +%D +%D The naming of the colors in this palet suggests some +%D ordening, which in turn is suported by color grouping. +%D +%D \starttyping +%D \definecolorgroup +%D [red] +%D [1.00:0.90:0.90, +%D 1.00:0.80:0.80, +%D 1.00:0.70:0.70, +%D 1.00:0.55:0.55, +%D 1.00:0.40:0.40, +%D 1.00:0.25:0.25, +%D 1.00:0.15:0.15, +%D 0.90:0.00:0.00] +%D \stoptyping +%D +%D In such a color group colors are numbered from~$1$ to~$n$. +%D +%D \showsetup{definecolorgroup} +%D +%D This kind of specification is not only more compact than +%D defining each color separate, it also loads faster and takes +%D less bytes. + +\installcorenamespace{colorgroup} +\installcorenamespace{colorgroupsetter} + +\newcount\c_colors_group_n % scratch counter + +\unexpanded\def\definecolorgroup % sort of obsolete, just use palets directly + {\dotripleempty\colors_define_color_group} + +\def\colors_define_color_group + {\ifthirdargument + \expandafter\colors_define_color_group_normal + \else + \expandafter\colors_define_color_group_checked + \fi} + +\def\colors_define_color_group_normal[#1][#2][#3]% + {\c_colors_group_n\zerocount + \processcommalist[#3]{\colors_define_color_group_entry{#1}{#2}}} + +\def\colors_define_color_group_checked[#1][#2][#3]% + {\doifinstringelse{:}{#2} + {\colors_define_color_group_normal[#1][\v!rgb][#2]} + {\doloop % inherited + {\ifcsname\??colorgroup#2:\recurselevel\endcsname + \setevalue{\??colorgroup#1:\recurselevel}{\csname\??colorgroup#2:\recurselevel\endcsname}% + \else + \exitloop + \fi}}} + +\def\colors_define_color_group_entry#1#2#3% name mode specification + {\advance\c_colors_group_n\plusone + \csname\??colorgroupsetter\ifcsname\??colorgroupssetter#2\endcsname#2\else\s!rgb\fi\endcsname[#1:\the\c_colors_group_n][#3:0:0:0:0]} + +\setvalue{\??colorgroupsetter\s!gray}[#1][#2:#3]{\definecolor[#1][s=#2]} +\setvalue{\??colorgroupsetter\s!rgb }[#1][#2:#3:#4:#5]{\definecolor[#1][r=#2,g=#3,b=#4]} +\setvalue{\??colorgroupsetter\s!cmyk}[#1][#2:#3:#4:#5:#6]{\definecolor[#1][c=#2,m=#3=,y=#4,k=#5]} +\setvalue{\??colorgroupsetter\s!spot}[#1][#2:#3:#4]{\definespotcolor[#1][#2][p=#3]} + +%D \macros +%D {showcolorgroup} +%D +%D We can show the group by: +%D +%D \startbuffer +%D \showcolorgroup [blue] [horizontal,name,number,value] +%D \stopbuffer +%D +%D \typebuffer +%D +%D or in color: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D which uses: +%D +%D \showsetup{showcolorgroup} + +\fetchruntimecommand \showcolorgroup {\f!colorprefix\s!run} + +%D There are ten predefined color groups, like +%D \color[green]{\em groen}, \color[red]{\em rood}, +%D \color[blue]{\em blauw}, \color[cyan]{\em cyaan}, +%D \color[magenta]{\em magenta} and \color[yellow]{\em geel}. +%D +%D \startlinecorrection +%D \hbox to \hsize +%D {\hss +%D \showcolorgroup [red] [vertical,name,number]\hss +%D \showcolorgroup [green] [vertical,name]\hss +%D \showcolorgroup [blue] [vertical,name]\hss +%D \showcolorgroup [cyan] [vertical,name]\hss +%D \showcolorgroup [magenta][vertical,name]\hss +%D \showcolorgroup [yellow] [vertical,name]\hss} +%D \stoplinecorrection +%D +%D These groups are used to define palets {\em alfa} upto {\em +%D zeta}. As long as we don't use colors from the same row, we +%D get ourselves distinctive palets. By activating such a palet +%D one gains access to its members {\em top} to {\em charm} (of +%D course one should use more suitable names than these). +%D +%D \startlinecorrection +%D \hbox to \hsize +%D {\showpalet [alfa] [vertical,name,number]\hss +%D \showpalet [beta] [vertical,name]\hss +%D \showpalet [gamma] [vertical,name]\hss +%D \showpalet [delta] [vertical,name]\hss +%D \showpalet [epsilon] [vertical,name]\hss +%D \showpalet [zeta] [vertical,name]} +%D \stoplinecorrection +%D +%D By using the keyword \type {value} the individual color +%D components are shown too. When printed in color, these +%D showcases show both the colors and the gray value. + +%D \macros +%D {comparecolorgroup} +%D +%D The similar command: +%D +%D \startbuffer +%D \comparecolorgroup [blue] +%D \stopbuffer +%D +%D \typebuffer +%D +%D shows color groups: +%D +%D \startlinecorrection +%D \getbuffer +%D \stoplinecorrection +%D +%D this commands are defined as: +%D +%D \showsetup{comparecolorgroup} + +\fetchruntimecommand \comparecolorgroup {\f!colorprefix\s!run} + +\protect \endinput diff --git a/tex/context/base/colo-imp-dem.mkiv b/tex/context/base/colo-imp-dem.mkiv new file mode 100644 index 000000000..5b794c551 --- /dev/null +++ b/tex/context/base/colo-imp-dem.mkiv @@ -0,0 +1,260 @@ +%D \module +%D [ file=colo-dem, % moved from colo-rgb, +%D version=1995.01.01, +%D title=\CONTEXT\ Color Macros, +%D subtitle=Demo Palets and Groups, +%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. + +%D Like colors, we first define the english colorgroups. These +%D colorgroups are tuned for distinctive gray scale printing. + +\definecolorgroup + [gray] + [0.95:0.95:0.95, + 0.90:0.90:0.90, + 0.80:0.80:0.80, + 0.70:0.70:0.70, + 0.60:0.60:0.60, + 0.50:0.50:0.50, + 0.40:0.40:0.40, + 0.30:0.30:0.30, + 0.20:0.20:0.20, + 0.10:0.10:0.10, + 0.00:0.00:0.00] + +\definecolorgroup + [red] + [1.00:0.90:0.90, + 1.00:0.80:0.80, + 1.00:0.70:0.70, + 1.00:0.55:0.55, + 1.00:0.40:0.40, + 1.00:0.25:0.25, + 1.00:0.15:0.15, + 0.90:0.00:0.00] + +\definecolorgroup + [green] + [0.90:1.00:0.90, + 0.70:1.00:0.70, + 0.50:1.00:0.50, + 0.30:1.00:0.30, + 0.15:0.90:0.15, + 0.00:0.80:0.00, + 0.00:0.65:0.00, + 0.00:0.50:0.00] + +\definecolorgroup + [blue] + [0.90:0.95:1.00, + 0.80:0.90:1.00, + 0.55:0.85:1.00, + 0.30:0.80:1.00, + 0.15:0.75:1.00, + 0.00:0.70:1.00, + 0.00:0.55:1.00, + 0.00:0.40:1.00] + +\definecolorgroup + [cyan] + [0.80:1.00:1.00, + 0.60:1.00:1.00, + 0.30:1.00:1.00, + 0.00:0.95:0.95, + 0.00:0.85:0.85, + 0.00:0.75:0.75, + 0.00:0.60:0.60, + 0.00:0.50:0.50] + +\definecolorgroup + [magenta] + [1.00:0.90:1.00, + 1.00:0.80:1.00, + 1.00:0.65:1.00, + 1.00:0.50:1.00, + 1.00:0.35:1.00, + 1.00:0.15:1.00, + 0.90:0.05:0.90, + 0.80:0.00:0.80] + +\definecolorgroup + [yellow] + [1.00:1.00:0.70, + 1.00:1.00:0.00, + 1.00:0.85:0.05, + 1.00:0.70:0.00, + 1.00:0.55:0.00, + 0.95:0.40:0.00, + 0.80:0.30:0.00, + 0.60:0.30:0.00] + +\definecolorgroup + [red*] + [1.00:0.95:0.95, + 1.00:0.90:0.90, + 1.00:0.80:0.80, + 1.00:0.70:0.70, + 1.00:0.60:0.60, + 1.00:0.50:0.50, + 1.00:0.40:0.40, + 1.00:0.30:0.30] + +\definecolorgroup + [green*] + [0.95:1.00:0.95, + 0.90:1.00:0.90, + 0.80:1.00:0.80, + 0.70:1.00:0.70, + 0.60:1.00:0.60, + 0.50:1.00:0.50, + 0.40:1.00:0.40, + 0.30:1.00:0.30] + +\definecolorgroup + [blue*] + [0.95:0.95:1.00, + 0.90:0.90:1.00, + 0.80:0.80:1.00, + 0.70:0.70:1.00, + 0.60:0.60:1.00, + 0.50:0.50:1.00, + 0.40:0.40:1.00, + 0.30:0.30:1.00] + +\definecolorgroup + [yellow*] + [1.00:1.00:0.10, + 1.00:1.00:0.00, + 0.90:0.90:0.00, + 0.80:0.80:0.00, + 0.70:0.70:0.00, + 0.60:0.60:0.00, + 0.50:0.50:0.00, + 0.40:0.40:0.00] + +%D For the sake of implementing interface dependant color +%D groups we support colorgroup duplication. + +\startinterface dutch + \definecolorgroup [grijs] [gray] + \definecolorgroup [rood] [red] + \definecolorgroup [groen] [green] + \definecolorgroup [blauw] [blue] + \definecolorgroup [cyaan] [cyan] + \definecolorgroup [magenta] [magenta] + \definecolorgroup [geel] [yellow] + \definecolorgroup [rood*] [red*] + \definecolorgroup [groen*] [green*] + \definecolorgroup [blauw*] [blue*] + \definecolorgroup [geel*] [yellow*] +\stopinterface + +\startinterface german + \definecolorgroup [grau] [gray] + \definecolorgroup [rot] [red] + \definecolorgroup [gruen] [green] + \definecolorgroup [blau] [blue] + \definecolorgroup [cyan] [cyan] + \definecolorgroup [magenta] [magenta] + \definecolorgroup [gelb] [yellow] + \definecolorgroup [rot*] [red*] + \definecolorgroup [gruen*] [green*] + \definecolorgroup [blau*] [blue*] + \definecolorgroup [gelb*] [yellow*] +\stopinterface + +\startinterface czech + \definecolorgroup [seda] [gray] + \definecolorgroup [cervena] [red] + \definecolorgroup [zelena] [green] + \definecolorgroup [modra] [blue] + \definecolorgroup [azurova] [cyan] + \definecolorgroup [fialova] [magenta] + \definecolorgroup [zluta] [yellow] + \definecolorgroup [cervena*] [red*] + \definecolorgroup [zelena*] [green*] + \definecolorgroup [modra*] [blue*] + \definecolorgroup [zluta*] [yellow*] +\stopinterface + +\startinterface italian + \definecolorgroup [grigio] [gray] + \definecolorgroup [rosso] [red] + \definecolorgroup [verde] [green] + \definecolorgroup [blu] [blue] + \definecolorgroup [ciano] [cyan] + \definecolorgroup [azzurro] [cyan] + \definecolorgroup [turchino][cyan] + \definecolorgroup [magenta] [magenta] + \definecolorgroup [cremisi] [magenta] + \definecolorgroup [giallo] [yellow] + \definecolorgroup [rosso*] [red*] + \definecolorgroup [verde*] [green*] + \definecolorgroup [blu*] [blue*] + \definecolorgroup [giallo*] [yellow*] +\stopinterface + +%D The next set of color palets is quite language independant. +%D These palets are meant as examples. + +\definepalet + [alfa] + [ top=red:7, + bottom=green:6, + up=blue:5, + down=cyan:4, + strange=magenta:3, + charm=yellow:2] + +\definepalet + [beta] + [ top=red:7, + bottom=green:5, + up=blue:3, + down=cyan:6, + strange=magenta:2, + charm=yellow:1] + +\definepalet + [gamma] + [ top=red:2, + bottom=green:5, + up=blue:3, + down=cyan:6, + strange=magenta:7, + charm=yellow:4] + +\definepalet + [delta] + [ top=yellow*:5, + bottom=yellow*:3, + up=yellow*:2, + down=magenta:6, + strange=blue:4, + charm=blue:1] + +\definepalet + [epsilon] + [ top=cyan:7, + bottom=cyan:5, + up=blue:3, + down=yellow:6, + strange=yellow:4, + charm=yellow:2] + +\definepalet + [zeta] + [ top=red:6, + bottom=green:5, + up=blue:7, + down=cyan:4, + strange=magenta:3, + charm=yellow:2] + +\endinput diff --git a/tex/context/base/colo-imp-rgb.mkiv b/tex/context/base/colo-imp-rgb.mkiv index 68fb4e839..9bc6befba 100644 --- a/tex/context/base/colo-imp-rgb.mkiv +++ b/tex/context/base/colo-imp-rgb.mkiv @@ -18,8 +18,8 @@ %D interface dependant colors. We use the color inheritance %D mechanisms to implement the interface dependant ones. -%D First we define some simple primary \cap{RGB} and \cap{CMYK} -%D colors. All colors are defined in \cap{RGB} color space. +%D For historic reasons all colors are defined in \RGB\ color +%D space and there is no reason to change this. \definecolor [red] [r=1, g=0, b=0] \definecolor [green] [r=0, g=1, b=0] @@ -266,264 +266,8 @@ \stopinterface -%D Like colors, we first define the english colorgroups. These -%D colorgroups are tuned for distinctive gray scale printing. - -% todo : more efficient and real gray - -\definecolorgroup - [gray] - [0.95:0.95:0.95, - 0.90:0.90:0.90, - 0.80:0.80:0.80, - 0.70:0.70:0.70, - 0.60:0.60:0.60, - 0.50:0.50:0.50, - 0.40:0.40:0.40, - 0.30:0.30:0.30, - 0.20:0.20:0.20, - 0.10:0.10:0.10, - 0.00:0.00:0.00] - -\definecolorgroup - [red] - [1.00:0.90:0.90, - 1.00:0.80:0.80, - 1.00:0.70:0.70, - 1.00:0.55:0.55, - 1.00:0.40:0.40, - 1.00:0.25:0.25, - 1.00:0.15:0.15, - 0.90:0.00:0.00] - -\definecolorgroup - [green] - [0.90:1.00:0.90, - 0.70:1.00:0.70, - 0.50:1.00:0.50, - 0.30:1.00:0.30, - 0.15:0.90:0.15, - 0.00:0.80:0.00, - 0.00:0.65:0.00, - 0.00:0.50:0.00] - -\definecolorgroup - [blue] - [0.90:0.95:1.00, - 0.80:0.90:1.00, - 0.55:0.85:1.00, - 0.30:0.80:1.00, - 0.15:0.75:1.00, - 0.00:0.70:1.00, - 0.00:0.55:1.00, - 0.00:0.40:1.00] - -\definecolorgroup - [cyan] - [0.80:1.00:1.00, - 0.60:1.00:1.00, - 0.30:1.00:1.00, - 0.00:0.95:0.95, - 0.00:0.85:0.85, - 0.00:0.75:0.75, - 0.00:0.60:0.60, - 0.00:0.50:0.50] - -\definecolorgroup - [magenta] - [1.00:0.90:1.00, - 1.00:0.80:1.00, - 1.00:0.65:1.00, - 1.00:0.50:1.00, - 1.00:0.35:1.00, - 1.00:0.15:1.00, - 0.90:0.05:0.90, - 0.80:0.00:0.80] - -\definecolorgroup - [yellow] - [1.00:1.00:0.70, - 1.00:1.00:0.00, - 1.00:0.85:0.05, - 1.00:0.70:0.00, - 1.00:0.55:0.00, - 0.95:0.40:0.00, - 0.80:0.30:0.00, - 0.60:0.30:0.00] - -\definecolorgroup - [red*] - [1.00:0.95:0.95, - 1.00:0.90:0.90, - 1.00:0.80:0.80, - 1.00:0.70:0.70, - 1.00:0.60:0.60, - 1.00:0.50:0.50, - 1.00:0.40:0.40, - 1.00:0.30:0.30] - -\definecolorgroup - [green*] - [0.95:1.00:0.95, - 0.90:1.00:0.90, - 0.80:1.00:0.80, - 0.70:1.00:0.70, - 0.60:1.00:0.60, - 0.50:1.00:0.50, - 0.40:1.00:0.40, - 0.30:1.00:0.30] - -\definecolorgroup - [blue*] - [0.95:0.95:1.00, - 0.90:0.90:1.00, - 0.80:0.80:1.00, - 0.70:0.70:1.00, - 0.60:0.60:1.00, - 0.50:0.50:1.00, - 0.40:0.40:1.00, - 0.30:0.30:1.00] - -\definecolorgroup - [yellow*] - [1.00:1.00:0.10, - 1.00:1.00:0.00, - 0.90:0.90:0.00, - 0.80:0.80:0.00, - 0.70:0.70:0.00, - 0.60:0.60:0.00, - 0.50:0.50:0.00, - 0.40:0.40:0.00] - -%D For the sake of implementing interface dependant color -%D groups we support colorgroup duplication. - -\startinterface dutch - \definecolorgroup [grijs] [gray] - \definecolorgroup [rood] [red] - \definecolorgroup [groen] [green] - \definecolorgroup [blauw] [blue] - \definecolorgroup [cyaan] [cyan] - \definecolorgroup [magenta] [magenta] - \definecolorgroup [geel] [yellow] - \definecolorgroup [rood*] [red*] - \definecolorgroup [groen*] [green*] - \definecolorgroup [blauw*] [blue*] - \definecolorgroup [geel*] [yellow*] -\stopinterface - -\startinterface german - \definecolorgroup [grau] [gray] - \definecolorgroup [rot] [red] - \definecolorgroup [gruen] [green] - \definecolorgroup [blau] [blue] - \definecolorgroup [cyan] [cyan] - \definecolorgroup [magenta] [magenta] - \definecolorgroup [gelb] [yellow] - \definecolorgroup [rot*] [red*] - \definecolorgroup [gruen*] [green*] - \definecolorgroup [blau*] [blue*] - \definecolorgroup [gelb*] [yellow*] -\stopinterface - -\startinterface czech - \definecolorgroup [seda] [gray] - \definecolorgroup [cervena] [red] - \definecolorgroup [zelena] [green] - \definecolorgroup [modra] [blue] - \definecolorgroup [azurova] [cyan] - \definecolorgroup [fialova] [magenta] - \definecolorgroup [zluta] [yellow] - \definecolorgroup [cervena*] [red*] - \definecolorgroup [zelena*] [green*] - \definecolorgroup [modra*] [blue*] - \definecolorgroup [zluta*] [yellow*] -\stopinterface - -\startinterface italian - \definecolorgroup [grigio] [gray] - \definecolorgroup [rosso] [red] - \definecolorgroup [verde] [green] - \definecolorgroup [blu] [blue] - \definecolorgroup [ciano] [cyan] - \definecolorgroup [azzurro] [cyan] - \definecolorgroup [turchino][cyan] - \definecolorgroup [magenta] [magenta] - \definecolorgroup [cremisi] [magenta] - \definecolorgroup [giallo] [yellow] - \definecolorgroup [rosso*] [red*] - \definecolorgroup [verde*] [green*] - \definecolorgroup [blu*] [blue*] - \definecolorgroup [giallo*] [yellow*] -\stopinterface - -%D The next set of color palets is quite language independant. -%D These palets are meant as examples. - -\definepalet - [alfa] - [ top=red:7, - bottom=green:6, - up=blue:5, - down=cyan:4, - strange=magenta:3, - charm=yellow:2] - -\definepalet - [beta] - [ top=red:7, - bottom=green:5, - up=blue:3, - down=cyan:6, - strange=magenta:2, - charm=yellow:1] - -\definepalet - [gamma] - [ top=red:2, - bottom=green:5, - up=blue:3, - down=cyan:6, - strange=magenta:7, - charm=yellow:4] - -\definepalet - [delta] - [ top=yellow*:5, - bottom=yellow*:3, - up=yellow*:2, - down=magenta:6, - strange=blue:4, - charm=blue:1] - -\definepalet - [epsilon] - [ top=cyan:7, - bottom=cyan:5, - up=blue:3, - down=yellow:6, - strange=yellow:4, - charm=yellow:2] - -\definepalet - [zeta] - [ top=red:6, - bottom=green:5, - up=blue:7, - down=cyan:4, - strange=magenta:3, - charm=yellow:2] - -%D The next four colors are used for typesetting verbatim \TEX\ -%D in color. - -\definecolor [texcolorone] [middlered] -\definecolor [texcolortwo] [middlegreen] -\definecolor [texcolorthree] [middleblue] -\definecolor [texcolorfour] [darkyellow] - %D Bonus (needed for FO test): -\definecolor [orange] [r=1,g=.5] +\definecolor [orange] [r=1,g=.5] \endinput diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index 5e504e388..474651fea 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -7,7 +7,7 @@ if not modules then modules = { } end modules ['colo-ini'] = { } local type, tonumber = type, tonumber -local concat = table.concat +local concat, insert, remove = table.concat, table.insert, table.remove local format, gmatch, gsub, lower, match, find = string.format, string.gmatch, string.gsub, string.lower, string.match, string.find local P, R, C, Cc = lpeg.P, lpeg.R, lpeg.C, lpeg.Cc local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns @@ -20,19 +20,48 @@ local attributes, context, commands = attributes, context, commands local settings_to_hash_strict = utilities.parsers.settings_to_hash_strict -local colors = attributes.colors -local transparencies = attributes.transparencies -local colorintents = attributes.colorintents -local registrations = backends.registrations -local settexattribute = tex.setattribute -local gettexattribute = tex.getattribute +local colors = attributes.colors +local transparencies = attributes.transparencies +local colorintents = attributes.colorintents +local registrations = backends.registrations +local settexattribute = tex.setattribute +local gettexattribute = tex.getattribute -local a_color = attributes.private('color') -local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colormodel') +local a_color = attributes.private('color') +local a_transparency = attributes.private('transparency') +local a_colorspace = attributes.private('colormodel') -local register_color = colors.register -local attributes_list = attributes.list +local register_color = colors.register +local attributes_list = attributes.list + +local colorvalues = colors.values +local transparencyvalues = transparencies.values + +colors.sets = colors.sets or { } -- sets are mostly used for +local colorsets = colors.sets -- showing lists of defined +local colorset = { } -- colors +colorsets.default = colorset + +storage.register("attributes/colors/sets",colorsets,"attributes.colors.sets") + +local stack = { } + +function colors.pushset(name) + insert(stack,colorset) + colorset = colorsets[name] + if not colorset then + colorset = { } + colorsets[name] = colorset + end +end + +function colors.popset(name) + colorset = remove(stack) +end + +function colors.setlist(name) + return table.sortedkeys(name and name ~= "" and colorsets[name] or colorsets.default or {}) +end local function definecolor(name, ca, global) if ca and ca > 0 then @@ -54,6 +83,7 @@ local function definecolor(name, ca, global) context.colordefrlc(name) end end + colorset[name] = true-- maybe we can store more end local function inheritcolor(name, ca, global) @@ -76,6 +106,7 @@ local function inheritcolor(name, ca, global) context.colordefrlc(name) end end + colorset[name] = true-- maybe we can store more end local function definetransparent(name, ta, global) @@ -142,11 +173,6 @@ local transparent = { luminosity = 16, } --- backend driven limitations - -colors.supported = true -- always true -transparencies.supported = true - local gray_okay, rgb_okay, cmyk_okay, spot_okay, multichannel_okay, forced = true, true, true, true, true, false function colors.forcesupport(gray,rgb,cmyk,spot,multichannel) -- pdfx driven @@ -210,8 +236,7 @@ local registered = { } local function do_registerspotcolor(parent,name,parentnumber,e,f,d,p) if not registered[parent] then ---~ print("!!!1",parent) - local v = colors.values[parentnumber] + local v = colorvalues[parentnumber] if v then local model = colors.default -- else problems with shading etc if model == 1 then model = v[1] end @@ -232,8 +257,7 @@ end local function do_registermultitonecolor(parent,name,parentnumber,e,f,d,p) -- same as spot but different template if not registered[parent] then ---~ print("!!!2",parent) - local v = colors.values[parentnumber] + local v = colorvalues[parentnumber] if v then local model = colors.default -- else problems with shading etc if model == 1 then model = v[1] end @@ -346,10 +370,11 @@ function colors.defineprocesscolor(name,str,global,freeze) -- still inconsistent -- end end end + colorset[name] = true-- maybe we can store more end function colors.isblack(ca) -- maybe commands - local cv = ca > 0 and colors.value(ca) + local cv = ca > 0 and colorvalues[ca] return (cv and cv[2] == 0) or false end @@ -376,6 +401,7 @@ function colors.definespotcolor(name,parent,str,global) end end end + colorset[name] = true-- maybe we can store more end function colors.registerspotcolor(parent, str) @@ -430,12 +456,13 @@ function colors.definemultitonecolor(name,multispec,colorspec,selfspec) end end end + colorset[name] = true-- maybe we can store more end local function mpcolor(model,ca,ta,default) -- will move to mlib-col - local cv = colors.supported and colors.value(ca) -- faster when direct colors.values[ca] + local cv = colorvalues[ca] if cv then - local tv = transparencies.supported and transparencies.value(ta) + local tv = transparencyvalues[ta] if model == 1 then model = cv[1] end @@ -468,9 +495,9 @@ local function mpcolor(model,ca,ta,default) -- will move to mlib-col end --~ local function mpcolor(model,ca,ta,default) -- will move to mlib-col ---~ local cv = colors.supported and colors.value(ca) -- faster when direct colors.values[ca] +--~ local cv = colorvalues[ca] --~ if cv then ---~ local tv = transparencies.supported and transparencies.value(ta) +--~ local tv = transparencyvalues[ta] --~ if model == 1 then --~ model = cv[1] --~ end @@ -510,7 +537,7 @@ colors.mpcolor = mpcolor colors.mpoptions = mpoptions function colors.formatcolor(ca,separator) - local cv = colors.value(ca) + local cv = colorvalues[ca] if cv then local c, cn, f, t, model = { }, 0, 13, 13, cv[1] if model == 2 then @@ -531,12 +558,12 @@ function colors.formatcolor(ca,separator) end function colors.formatgray(ca,separator) - local cv = colors.value(ca) + local cv = colorvalues[ca] return format("%0.3f",(cv and cv[2]) or 0) end function colors.colorcomponents(ca) -- return list - local cv = colors.value(ca) + local cv = colorvalues[ca] if cv then local model = cv[1] if model == 2 then @@ -556,7 +583,7 @@ function colors.colorcomponents(ca) -- return list end function colors.transparencycomponents(ta) - local tv = transparencies.value(ta) + local tv = transparencyvalues[ta] if tv then return format("a=%1.3f t=%1.3f",tv[1],tv[2]) else @@ -565,7 +592,7 @@ function colors.transparencycomponents(ta) end function colors.spotcolorname(ca,default) - local cv, v = colors.value(ca), "unknown" + local cv, v = colorvalues[ca], "unknown" if cv and cv[1] == 5 then v = cv[10] end @@ -573,7 +600,7 @@ function colors.spotcolorname(ca,default) end function colors.spotcolorparent(ca,default) - local cv, v = colors.value(ca), "unknown" + local cv, v = colorvalues[ca], "unknown" if cv and cv[1] == 5 then v = cv[12] if v == "" then @@ -584,7 +611,7 @@ function colors.spotcolorparent(ca,default) end function colors.spotcolorvalue(ca,default) - local cv, v = colors.value(ca), 0 + local cv, v = colorvalues[ca], 0 if cv and cv[1] == 5 then v = cv[13] end @@ -608,7 +635,7 @@ end function colors.defineintermediatecolor(name,fraction,c_one,c_two,a_one,a_two,specs,global,freeze) fraction = tonumber(fraction) or 1 - local one, two = colors.value(c_one), colors.value(c_two) + local one, two = colorvalues[c_one], colorvalues[c_two] if one then if two then local csone, cstwo = one[1], two[1] @@ -652,7 +679,7 @@ function colors.defineintermediatecolor(name,fraction,c_one,c_two,a_one,a_two,sp definecolor(name,ca,global,freeze) end end - local one, two = transparencies.value(a_one), transparencies.value(a_two) + local one, two = transparencyvalues[a_one], transparencyvalues[a_two] local t = settings_to_hash_strict(specs) local ta = tonumber((t and t.a) or (one and one[1]) or (two and two[1])) local tt = tonumber((t and t.t) or (one and two and f(one,two,2,fraction))) @@ -670,7 +697,7 @@ end --~ end --~ function colors.defineduocolor(name,fraction_one,c_one,fraction_two,c_two,global,freeze) ---~ local one, two = colors.value(c_one), colors.value(c_two) +--~ local one, two = colorvalues[c_one], colorvalues[c_two] --~ if one and two then --~ fraction_one = tonumber(fraction_one) or 1 --~ fraction_two = tonumber(fraction_two) or 1 @@ -708,7 +735,7 @@ end function colors.definemixcolor(name,fractions,cs,global,freeze) local values = { } for i=1,#cs do -- do fraction in here - local v = colors.value(cs[i]) + local v = colorvalues[cs[i]] if not v then return end @@ -739,13 +766,15 @@ local patterns = { "colo-imp-%s.mkiv", "colo-imp-%s.tex", "colo-%s.mkiv", "colo- local function action(name,foundname) context.startreadingfile() + context.startcolorset { name } context.input(foundname) - context.showcolormessage("colors",4,name) + context.showmessage("colors",4,name) + context.stopcolorset() context.stopreadingfile() end local function failure(name) - context.showcolormessage("colors",5,name) + context.showmessage("colors",5,name) end function colors.usecolors(name) @@ -766,9 +795,9 @@ function commands.setcolormodel(model,weight) settexattribute(a_colorspace,setcolormodel(model,weight)) end -function commands.setrastercolor(name,s) - settexattribute(a_color,colors.definesimplegray(name,s)) -end +-- function commands.setrastercolor(name,s) +-- settexattribute(a_color,colors.definesimplegray(name,s)) +-- end function commands.registermaintextcolor(a) colors.main = a @@ -804,4 +833,25 @@ function commands.doifdrawingblackelse() commands.doifelse(colors.isblack(gettexattribute(a_color))) end +-- function commands.withcolorsinset(name,command) +-- local set +-- if name and name ~= "" then +-- set = colorsets[name] +-- else +-- set = colorsets.default +-- end +-- if set then +-- if command then +-- for name in table.sortedhash(set) do +-- context[command](name) +-- end +-- else +-- context(concat(table.sortedkeys(set),",")) +-- end +-- end +-- end + +commands.startcolorset = colors.pushset +commands.stopcolorset = colors.popset + commands.usecolors = colors.usecolors diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 6c752f3ae..1e75c29a2 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D We need to clean this up further but first we hav eto make sure that mkiv +%D We need to clean this up further but first we have to make sure that mkiv %D code works ok. \writestatus{loading}{ConTeXt Color Macros / Initialization} @@ -26,68 +26,48 @@ %D In \MKIV\ we have independent color, colorspace and transparency %D but I'm still not sure if I keep it that way as it's probably more -%D efficient to combine them (less attributes and finalizing). +%D efficient to combine them (less attributes and finalizing). If +%D it becomes a bottleneck we can set up a more complex system +%D with one shared attribute for colorspace, color and transparency. %D -%D We use a couple of local registers. That way we don't have -%D to group when converting colors. By the way, this is not -%D really faster. We can sqeeze half a second runtime for 50K -%D switches on a 1G machine, but the macros will become rather -%D ugly then. To mention one such improvement: no colon -%D after the key character (.25 sec). - -\newcount\colorcount - -%D When typesetting for paper, we prefer using the \cap{CMYK} -%D color space, but for on||screen viewing we prefer \cap{RGB} -%D (the previous implementation supported only this scheme). -%D Independant of such specifications, we support some automatic -%D conversions: +%D When typesetting for paper, we prefer using the \CMYK\ color space, +%D but for on||screen viewing we prefer \RGB\ (the previous +%D implementation supported only this scheme). Independant of such +%D specifications, we support some automatic conversions: %D %D \startitemize[packed] -%D \item convert all colors to \cap{RGB} -%D \item convert all colors to \cap{CMYK} +%D \item convert all colors to \RGB +%D \item convert all colors to \CMYK %D \item convert all colors to gray scales %D \stopitemize %D -%D We also support optimization of colors to gray scales. -%D -%D \startitemize[continue] -%D \item reduce gray colors to gray scales -%D \item reduce \cap{CMY} components to \cap{K} -%D \stopitemize -%D %D These options are communicated by means of: -\newif\ifRGBsupported -\newif\ifCMYKsupported -\newif\ifSPOTsupported -\newif\ifpreferGRAY -\newif\ifGRAYprefered -\newif\ifconvertGRAY \convertGRAYtrue -\newif\ifreduceCMYK -\newif\ifconverttoGRAY -\newif\ifweightGRAY \weightGRAYtrue - -%D The last boolean controls reduction of \cap{CMYK} to -%D \cap{CMY} colors. When set to true, the black component -%D is added to the other ones. -%D -%D Prefering gray is not the same as converting to gray. -%D Conversion treats each color components in a different way, -%D while prefering is just a reduction and thus a -%D space||saving option. - -\newif\iffreezecolors \freezecolorsfalse -\newif\ifincolor % not used outside this module - -\let\colorlist \empty -\let\currentspotcolor \empty -\let\allspotcolors \empty -\let\usedspotcolors \empty -\let\currentpalet \empty +\newconditional\c_colors_rgb_supported +\newconditional\c_colors_cmyk_supported +\newconditional\c_colors_spot_supported % backend driven +\newconditional\c_colors_weight_gray \settrue\c_colors_weight_gray +\newconditional\c_colors_convert_gray \settrue\c_colors_convert_gray +\newconditional\c_colors_enabled +\newconditional\c_colors_expanded + +\let\currentcolormodel \empty +\let\currentcolorname \empty +\let\currentcolorpalet \empty +\let\currentcolorprefix\empty % \currentcolorpalet: + +\installcorenamespace{color} +\installcorenamespace{colorattribute} +\installcorenamespace{transparencyattribute} +\installcorenamespace{colorsetter} +\installcorenamespace{transparencysetter} +\installcorenamespace{colorpaletspecification} +\installcorenamespace{colorpalet} +\installcorenamespace{colorstack} %D \macros -%D {definecolor,defineglobalcolor,definenamedcolor,definespotcolor,definemultitonecolor} +%D {definecolor,defineglobalcolor,definenamedcolor,definespotcolor,definemultitonecolor, +%D definetransparency} %D %D \startbuffer %D \definecolor [blue] [c=1,m=.38,y=0,k=.64] % pantone pms 2965 uncoated m @@ -110,80 +90,80 @@ %D %D \getbuffer \typebuffer -\unexpanded\def\definecolor {\dodoubleargument\dodefinecolor} -\unexpanded\def\defineglobalcolor {\dodoubleargument\dodefineglobalcolor} -\unexpanded\def\definenamedcolor {\dodoubleargument\dodefinenamedcolor} -\unexpanded\def\definespotcolor {\dotripleargument\dodefinespotcolor} -\unexpanded\def\definemultitonecolor{\doquadrupleempty\dodefinemultitonecolor} +\unexpanded\def\definecolor {\dodoubleargument\colors_define} +\unexpanded\def\defineglobalcolor {\dodoubleargument\colors_define_global} +\unexpanded\def\definenamedcolor {\dodoubleargument\colors_define_named} +\unexpanded\def\definespotcolor {\dotripleargument\colors_define_spot} +\unexpanded\def\definemultitonecolor{\doquadrupleempty\colors_define_multitone} +\unexpanded\def\definetransparency {\dodoubleargument\colors_define_transpancy} %D \macros -%D {startcolor,stopcolor, -%D faststartcolor,faststopcolor, -%D startraster,stopraster,raster, -%D color,graycolor} +%D {startcolor,stopcolor,color,graycolor} %D -%D The local and global and raster commands are here just -%D for compatibility with \MKII. +%D The local and global commands are here just for compatibility +%D with \MKII. %D %D \showsetup{startcolor} %D -%D \macros -%D {color,graycolor} -%D -%D This leaves the simple color command: -%D -%D \showsetup{color} -%D \showsetup{graycolor} -%D -%D This leaves the simple color command: +%D The simple color commands are: %D %D \showsetup{color} %D \showsetup{graycolor} -\unexpanded\def\switchtocolor [#1]{\csname#1\endcsname} -\unexpanded\def\color [#1]{\groupedcommand{\doactivatecolor{#1}}{}} -\unexpanded\def\startcolor [#1]{\begingroup\doactivatecolor{#1}} -\unexpanded\def\stopcolor {\endgroup} -\unexpanded\def\graycolor [#1]{\groupedcommand{\dosetcolormodel{gray}\doactivatecolor{#1}}{}} -\unexpanded\def\colored [#1]{\groupedcommand{\definecolor[@colored@][#1]\doactivatecolor{@colored@}}{}} -\unexpanded\def\fastcolored [#1]#2{\begingroup\dodefinefastcolor[@colored@][#1]\doactivatecolor{@colored@}#2\endgroup} - -% some of this will go away - -\unexpanded\def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]} -\unexpanded\def\stopcolorpage {\stopcolor} -\unexpanded\def\startraster [#1]{\dosetrastercolor{#1}} -\unexpanded\def\stopraster {} -\unexpanded\def\raster [#1]{\groupedcommand{\dosetrastercolor{#1}}{}} -\unexpanded\def\faststartcolor [#1]{\doactivatecolor{#1}} -\unexpanded\def\faststopcolor {} - -\def\getcolorattributevalue#1#2% color macro (obsolete again, we have a better method) - {\begingroup - \doactivatecolor{#1}% - \normalexpanded{\endgroup\edef\noexpand#2% - {\ifnum\attribute\colorattribute=\attributeunsetvalue\else\number\attribute\colorattribute\fi}}} +%D We expect sane behaviour in \MKIV\ so we don't used grouped command any +%D longer. -\let\grey\graycolor +% \testfeatureonce{100000}{\color[red]{}} % 1.046 => 0.541 -%D Stacking: +\def\@colored@{@colored@} -% \colormodelattribute \colorattribute \transparencyattribute +\unexpanded\def\switchtocolor[#1]{\csname#1\endcsname} -\newcount\currentcolornesting +%unexpanded\def\color [#1]{\groupedcommand{\colors_activate{#1}}{}} -\unexpanded\def\pushcolor[#1]% - {\global\advance\currentcolornesting\plusone - \expandafter\edef\csname\??cl:s:\number\currentcolornesting\endcsname - {\attribute\colormodelattribute \the\attribute\colormodelattribute - \attribute\colorattribute \the\attribute\colorattribute - \attribute\transparencyattribute\the\attribute\transparencyattribute - \space}% stack - \doactivatecolor{#1}} +\unexpanded\def\color [#1]{\bgroup + \def\g_color{\colors_activate{#1}}% + \afterassignment\g_color + \let\nexttoken} -\unexpanded\def\popcolor - {\csname\??cl:s:\number\currentcolornesting\endcsname - \global\advance\currentcolornesting\minusone} +%unexpanded\def\graycolor [#1]{\groupedcommand{\colors_set_model\s!gray\colors_activate{#1}}{}} % special, all embeded also gray + +\unexpanded\def\graycolor [#1]{\bgroup + \def\g_color{\colors_set_model\s!gray\colors_activate{#1}}% + \afterassignment\g_color + \let\nexttoken} + +\unexpanded\def\startcolor [#1]{\begingroup + \colors_activate{#1}} + +\unexpanded\def\stopcolor {\endgroup} + +%unexpanded\def\colored [#1]{\groupedcommand{\colors_define[\@colored@][#1]\colors_activate\@colored@}{}} + +\unexpanded\def\colored [#1]{\bgroup + \def\g_color{\colors_define[\@colored@][#1]\colors_activate\@colored@}% + \afterassignment\g_color + \let\nexttoken} + +\unexpanded\def\fastcolored[#1]#2{\begingroup % is this command still needed? + \dodefinefastcolor[\@colored@][#1]% + \colors_activate\@colored@ + #2% + \endgroup} + + +%D The following command is obsolete: + +\unexpanded\def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]} +\unexpanded\def\stopcolorpage {\stopcolor} + +\def\getcolorattributevalue#1#2% obsolete, use \thecolorattribute instead ... + {\begingroup + \colors_activate{#1}% + \normalexpanded{\endgroup\edef\noexpand#2% + {\ifnum\attribute\colorattribute=\attributeunsetvalue\else\number\attribute\colorattribute\fi}}} + +\let\grey\graycolor % these macros are only used in tracing %D \macros %D {startcurrentcolor,stopcurrentcolor} @@ -197,91 +177,95 @@ %D Color definitions can be grouped in files with the name: %D %D \starttyping -%D \f!colorprefix-identifier.tex +%D colo-imp-tag.tex %D \stoptyping %D -%D where \type{\f!colorprefix} is \unprotect {\tttf \f!colorprefix}. -%D Loading such a file is done by \protect +%D Loading such a file is done by: %D %D \showsetup{usecolors} %D -%D Some default colors are specified in \type{colo-rgb.tex}, -%D which is loaded into the format by: +%D Some default colors are specified in \type {colo-imp-rgb}, +%D which is loaded into the format by default. +%D +%D Some demo palets and groups are defined in \type {colo-imp-dem} +%D which can be loaded with: %D %D \starttyping -%D \usecolors[rgb] +%D \usecolors[dem] %D \stoptyping -\unexpanded\def\usecolors[#1]{\ctxcommand{usecolors(\!!bs#1\!!es)}} +\unexpanded\def\startcolorset[#1]{\ctxcommand{startcolorset("#1")}} +\unexpanded\def\stopcolorset {\ctxcommand{stopcolorset()}} +\unexpanded\def\usecolors [#1]{\ctxcommand{usecolors("#1")}} \let\setupcolor\usecolors -%D \macros -%D {definetransparency} -%D -%D This command numbers to names: - -\unexpanded\def\definetransparency - {\dodoubleargument\dodefinetransparency} +\installdirectcommandhandler \??color {colors} -\unexpanded\def\setupcolors - {\dosingleargument\dosetupcolors} +\let\colors_show_message\gobblethreearguments -\let\showcolormessage\gobblethreearguments +% \newtoks\everysetupcolors -\newtoks\everysetupcolors +\let\v_colors_freeze_state\s!false +\let\v_colors_weight_state\s!false -\let\dosetcolorvalue \setvalue -\def\colorfreezestate{false} - -\def\dosetupcolors[#1]% some no longer make sense in MkIV - {\getparameters[\??cl][#1]% - \doifelse\@@clspot\v!yes - \SPOTsupportedtrue - \SPOTsupportedfalse - \doifelse\@@clreduction\v!yes - \reduceCMYKtrue - \reduceCMYKfalse - \doifelse\@@clexpansion\v!yes - \freezecolorstrue - \freezecolorsfalse - \iffreezecolors - \let\dosetcolorvalue\setevalue - \def\colorfreezestate{true}% +\appendtoks % we could use \directcolorsparameter here + % + \doifelse{\colorsparameter\c!spot }\v!yes \settrue \setfalse\c_colors_spot_supported + \doifelse{\colorsparameter\c!expansion}\v!yes \settrue \setfalse\c_colors_expanded + \doifelse{\colorsparameter\c!factor }\v!no \setfalse\settrue \c_colors_weight_gray + \doifelse{\colorsparameter\c!rgb }\v!yes \settrue \setfalse\c_colors_rgb_supported + \doifelse{\colorsparameter\c!cmyk }\v!yes \settrue \setfalse\c_colors_cmyk_supported + \doifelse{\colorsparameter\c!state }\v!start\settrue \setfalse\c_colors_enabled + % + \ifconditional\c_colors_weight_gray + \let\v_colors_weight_state\s!true \else - \let\dosetcolorvalue\setvalue - \def\colorfreezestate{false}% + \let\v_colors_weight_state\s!false \fi - \doifelse\@@clfactor\v!no - \weightGRAYfalse - \weightGRAYtrue - \doifelse\@@clrgb\v!no - {\ifRGBsupported \showcolormessage\m!colors {9}\v!rgb \RGBsupportedfalse \fi} - {\ifRGBsupported \else\showcolormessage\m!colors{10}\v!rgb \RGBsupportedtrue \fi}% - \doifelse\@@clcmyk\v!no - {\ifCMYKsupported \showcolormessage\m!colors {9}\v!cmyk\CMYKsupportedfalse\fi} - {\ifCMYKsupported\else\showcolormessage\m!colors{10}\v!cmyk\CMYKsupportedtrue \fi}% - \preferGRAYfalse - \convertGRAYtrue - \processaction - [\@@clconversion] - [ \v!yes=>\preferGRAYtrue, - \v!no=>\convertGRAYfalse, - \v!never=>\convertGRAYfalse, - \v!always=>\preferGRAYtrue\RGBsupportedfalse\CMYKsupportedfalse]% - \ifRGBsupported - \converttoGRAYfalse - \else\ifCMYKsupported - \converttoGRAYfalse + % + \ifconditional\c_colors_expanded + \let\v_colors_freeze_state\s!true \else - \ifconverttoGRAY\else\showcolormessage\m!colors{11}\empty\fi - \converttoGRAYtrue - \fi\fi - \doifelse\@@clstate\v!stop - {\incolorfalse}% - {\incolortrue\let\@@clstate\v!start}% - \dosetupcolormodel - \the\everysetupcolors} + \let\v_colors_freeze_state\s!false + \fi + % + \setfalse\c_colors_convert_gray + \processaction + [\colorsparameter\c!conversion] % no == never (was different in mkii) + [ \v!yes=>\settrue \c_colors_convert_gray, + \v!always=>\settrue \c_colors_convert_gray + \setfalse\c_colors_rgb_supported + \setfalse\c_colors_cmyk_supported]% + \ifconditional\c_colors_rgb_supported \colors_show_message\m!colors9\v!rgb \fi + \ifconditional\c_colors_cmyk_supported\colors_show_message\m!colors9\v!cmyk\fi + \colors_setup_current_model +\to \everysetupcolors + +\appendtoks + \setupcolors[\c!state=\v!start]% + \ctxcommand{enablecolor()}% % this can as well happen when + \ctxcommand{enabletransparency()}% % the handler is defined in lua + \let\colors_show_message\showmessage +\to \everyjob + +%D We provide stacking independent of grouping. + +\newcount\c_colors_nesting + + +\unexpanded\def\pushcolor[#1]% + {\global\advance\c_colors_nesting\plusone + \expandafter\edef\csname\??colorstack\number\c_colors_nesting\endcsname + {\attribute\colormodelattribute \the\attribute\colormodelattribute + \attribute\colorattribute \the\attribute\colorattribute + \attribute\transparencyattribute\the\attribute\transparencyattribute + \relax}% stack + \colors_activate{#1}} + +\unexpanded\def\popcolor + {\csname\??colorstack\number\c_colors_nesting\endcsname + \global\advance\c_colors_nesting\minusone} %D In this documentation we will not go into too much details %D on palets. Curious users can find more information on this @@ -348,29 +332,34 @@ %D This saves us some typing in for instance the modules that %D deal with pretty verbatim typesetting. +\let\m_colors_palet_tmp\empty + \unexpanded\def\definepalet - {\dodoubleargument\dodefinepalet} + {\dodoubleargument\colors_define_palet} -\def\dodefinepalet[#1][#2]% +\unexpanded\def\colors_define_palet[#1][#2]% todo {\doifassignmentelse{#2} - {%\showcolormessage\m!colors6{#1}% - \letvalueempty{\??pa#1}% - \setevalue{\??pa\??pa#1}{#2}% - \def\dodododefinepalet[##1=##2]% - {\doifvaluesomething{\??pa#1} - {\setevalue{\??pa#1}{\csname\??pa#1\endcsname,}}% - \setevalue{\??pa#1}{\csname\??pa#1\endcsname##1}% - \dodefinepaletcolor{#1}{##1}{##2}}% - \def\dododefinepalet##1% - {\dodododefinepalet[##1]}% - \processcommalist[#2]\dododefinepalet} - {\doifdefined{\??pa#2} - {\expanded{\dodefinepalet[#1][\csname\??pa\??pa#2\endcsname]}}}} + {%\colors_show_message\m!colors6{#1}% + \let\m_colors_palet_tmp\empty + \setevalue{\??colorpaletspecification#1}{#2}% + \processcommalist[#2]{\colors_define_palet_one{#1}}% + \letvalue{\??colorpalet#1}\m_colors_palet_tmp + \let\m_colors_palet_tmp\empty} + {\ifcsname\??colorpaletspecification#2\endcsname + \normalexpanded{\colors_define_palet[#1][\csname\??colorpaletspecification#2\endcsname]}% + \fi}} + +\def\colors_define_palet_one#1#2% get rid of { } in #2 + {\colors_define_palet_two{#1}[#2]}% + +\def\colors_define_palet_two#1[#2=#3]% + {\edef\m_colors_palet_tmp{\ifx\m_colors_palet_tmp\empty\else\m_colors_palet_tmp,\fi#2}% + \colors_define_palet_set{#1}{#2}{#3}}% \let\paletsize\!!zerocount \def\getpaletsize[#1]% - {\getcommacommandsize[\csname\??pa\??pa#1\endcsname]% + {\getcommacommandsize[\csname\??colorpaletspecification#1\endcsname]% \edef\paletsize{\number\commalistsize}} %D Instead of refering to colors, one can also directly specify @@ -389,22 +378,25 @@ %D %D \showsetup{setuppalet} -\let\currentpalet\empty +\newtoks\everysetuppalet \unexpanded\def\setuppalet - {\dosingleempty\dosetuppalet} + {\dosingleempty\colors_setup_palet} -\def\dosetuppalet[#1]% - {\edef\currentpalet{#1}% - \ifx\currentpalet\empty +\def\colors_setup_palet[#1]% + {\edef\currentcolorpalet{#1}% + \ifx\currentcolorpalet\empty % seems to be a reset - \else\ifcsname\??pa\currentpalet\endcsname - \edef\currentpalet{#1:}% + \let\currentcolorprefix\empty + \else\ifcsname\??colorpalet\currentcolorpalet\endcsname + \edef\currentcolorprefix{#1:}% \else - \showcolormessage\m!colors7\currentpalet - \let\currentpalet\empty + \colors_show_message\m!colors7\currentcolorpalet + \let\currentcolorpalet\empty + \let\currentcolorprefix\empty \fi\fi - \initializemaintextcolor} + \the\everysetuppalet + \color_initialize_maintextcolor} %D \macros %D {showpalet} @@ -428,120 +420,6 @@ \fetchruntimecommand \showcolorcomponents {\f!colorprefix\s!run} -%D \macros -%D {definecolorgroup} -%D -%D The naming of the colors in this palet suggests some -%D ordening, which in turn is suported by color grouping. -%D -%D \starttyping -%D \definecolorgroup -%D [red] -%D [1.00:0.90:0.90, -%D 1.00:0.80:0.80, -%D 1.00:0.70:0.70, -%D 1.00:0.55:0.55, -%D 1.00:0.40:0.40, -%D 1.00:0.25:0.25, -%D 1.00:0.15:0.15, -%D 0.90:0.00:0.00] -%D \stoptyping -%D -%D In such a color group colors are numbered from~$1$ to~$n$. -%D -%D \showsetup{definecolorgroup} -%D -%D This kind of specification is not only more compact than -%D defining each color separate, it also loads faster and takes -%D less bytes. - -\unexpanded\def\definecolorgroup - {\dotripleempty\dodefinecolorgroup} - -\def\dododefinecolorgroupgray [#1][#2:#3]{\definecolor [#1:\the\colorcount][s=#2]} -\def\dododefinecolorgrouprgb [#1][#2:#3:#4:#5]{\definecolor [#1:\the\colorcount][r=#2,g=#3,b=#4]} -\def\dododefinecolorgroupcmyk[#1][#2:#3:#4:#5:#6]{\definecolor [#1:\the\colorcount][c=#2,m=#3=,y=#4,k=#5]} -\def\dododefinecolorgroupspot [#1][#2:#3:#4]{\definespotcolor[#1:\the\colorcount][#2][p=#3]} - -\def\dododefinecolorgroup#1#2% - {\advance\colorcount\plusone - \getvalue{dododefinecolorgroup\currentcolorspace}[#1][#2:0:0:0:0]} - -\def\dodefinecolorgroup[#1][#2][#3]% obsolete, just use palets - {\ifthirdargument - \doifelsenothing{#2}{\let\currentcolorspace\v!rgb}{\def\currentcolorspace{#2}}% - \colorcount\zerocount - \processcommalist[#3]{\dododefinecolorgroup{#1}}% - \else - \doifinstringelse{:}{#2} - {\definecolorgroup[#1][\v!rgb][#2]} - {\doloop - {\ifcsname\??cr#2:\recurselevel\endcsname - \setevalue{\??cr#1:\recurselevel}{\csname\??cr#2:\recurselevel\endcsname}% - \else - \exitloop - \fi}}% - \fi} - -%D \macros -%D {showcolorgroup} -%D -%D We can show the group by: -%D -%D \startbuffer -%D \showcolorgroup [blue] [horizontal,name,number,value] -%D \stopbuffer -%D -%D \typebuffer -%D -%D or in color: -%D -%D \startlinecorrection -%D \getbuffer -%D \stoplinecorrection -%D -%D which uses: -%D -%D \showsetup{showcolorgroup} - -\fetchruntimecommand \showcolorgroup {\f!colorprefix\s!run} - -%D There are ten predefined color groups, like -%D \color[green]{\em groen}, \color[red]{\em rood}, -%D \color[blue]{\em blauw}, \color[cyan]{\em cyaan}, -%D \color[magenta]{\em magenta} and \color[yellow]{\em geel}. -%D -%D \startlinecorrection -%D \hbox to \hsize -%D {\hss -%D \showcolorgroup [red] [vertical,name,number]\hss -%D \showcolorgroup [green] [vertical,name]\hss -%D \showcolorgroup [blue] [vertical,name]\hss -%D \showcolorgroup [cyan] [vertical,name]\hss -%D \showcolorgroup [magenta][vertical,name]\hss -%D \showcolorgroup [yellow] [vertical,name]\hss} -%D \stoplinecorrection -%D -%D These groups are used to define palets {\em alfa} upto {\em -%D zeta}. As long as we don't use colors from the same row, we -%D get ourselves distinctive palets. By activating such a palet -%D one gains access to its members {\em top} to {\em charm} (of -%D course one should use more suitable names than these). -%D -%D \startlinecorrection -%D \hbox to \hsize -%D {\showpalet [alfa] [vertical,name,number]\hss -%D \showpalet [beta] [vertical,name]\hss -%D \showpalet [gamma] [vertical,name]\hss -%D \showpalet [delta] [vertical,name]\hss -%D \showpalet [epsilon] [vertical,name]\hss -%D \showpalet [zeta] [vertical,name]} -%D \stoplinecorrection -%D -%D By using the keyword \type {value} the individual color -%D components are shown too. When printed in color, these -%D showcases show both the colors and the gray value. - %D \macros %D {comparepalet} %D @@ -565,29 +443,6 @@ \fetchruntimecommand \comparepalet {\f!colorprefix\s!run} -%D \macros -%D {comparecolorgroup} -%D -%D The similar command: -%D -%D \startbuffer -%D \comparecolorgroup [blue] -%D \stopbuffer -%D -%D \typebuffer -%D -%D shows color groups: -%D -%D \startlinecorrection -%D \getbuffer -%D \stoplinecorrection -%D -%D this commands are defined as: -%D -%D \showsetup{comparecolorgroup} - -\fetchruntimecommand \comparecolorgroup {\f!colorprefix\s!run} - %D \macros %D {showcolor} %D @@ -639,46 +494,22 @@ %D \MPcolor{my own red} %D \stoptyping %D -%D This macro returns a \METAPOST\ triplet \type{(R,G,B)}. -%D Unless \CMYK\ color support is turned on with \type -%D {MPcmyk}, only \cap{RGB} colors and gray scales are -%D supported. - +%D This macro returns \METAPOST\ code that represents the +%D color. +%D %D For the moment we keep the next downward compatibility %D switch, i.e.\ expanded colors. However, predefined colors %D and palets are no longer expanded (which is what I wanted %D in the first place). %D -%D Well, in case we want to do color separation and use CMYK -%D colors only, this is dangerous since unwanted remapping may -%D take place. Especially when we redefine already defined -%D colors in another color space (e.g. darkgreen is -%D predefined in RGB color space, so a redefinition in CMYK -%D coordinates before RGB mode is disabled, would give -%D unexpected results due to the already frozen color spec.) - -%D In \MKIV\ we don't support color separation as we might now assume -%D that printing houses have the right programs to do it themselves. -%D The \MKII\ color separator was implemented as part of a project -%D that needed. If it's ever needed in \MKIV\ i'll do it in the -%D backend. - -\let\doifseparatingcolorselse\secondoftwoarguments -\let\doifcolorchannelelse \secondofthreearguments -\let\resetcolorseparation \relax -\let\colorchannelprefix \empty -\let\colorchannelsuffix \empty - -%D We now define the low level macros: +%D In \MKIV\ we don't support color separation as we might now +%D assume that printing houses have the right programs to do +%D it themselves. If it's ever needed in \MKIV\ It is relatively +%D easy to support it in the backend code. % todo: palets in definecolor % todo: {\red xx} vs \red{xx} -% check: registerusedspotcolors -% check: \currentcolorname -% check: \outercolorname -% check: \startcolormode - % \def\mptexcolor#1{"\dogetattributeid\s!color \somecolorattribute{#1} A"} % % \startMPpage @@ -688,46 +519,42 @@ % draw btex test etex withprescript \mptexcolor{blue} ; % \stopMPpage -% \ifx\currentcolormodel\undefined \newcount\currentcolormodel \fi - -\def\currentcolormodel{\attribute\colormodelattribute} +\unexpanded\def\setcolormodel[#1]% % beware, \setupcolors will overload this, so this one is + {\colors_set_model{#1}} % only for local usage -\def\dosetcolormodel#1% no message - {\ctxcommand{setcolormodel('#1',\ifweightGRAY true\else false\fi)}} % sets attribute +\def\colors_set_model#1% direct + {\edef\currentcolormodel{#1}% + \ctxcommand{setcolormodel('\currentcolormodel',\v_colors_weight_state)}} % sets attribute at lua end -\dosetcolormodel{all} +\colors_set_model\s!all -\def\dosetupcolormodel - {\ifincolor - \ifRGBsupported - \ifCMYKsupported - \dosetcolormodel{all}% +\def\colors_setup_current_model + {\ifconditional\c_colors_enabled + \ifconditional\c_colors_rgb_supported + \ifconditional\c_colors_cmyk_supported + \colors_set_model\s!all \else - \dosetcolormodel{rgb}% + \colors_set_model\s!rgb \fi \else - \ifCMYKsupported - \dosetcolormodel{cmyk}% + \ifconditional\c_colors_cmyk_supported + \colors_set_model\s!cmyk \else - \ifconvertGRAY - \dosetcolormodel{gray}% + \ifconditional\c_colors_convert_gray + \colors_set_model\s!gray \else - \dosetcolormodel{none}% + \colors_set_model\s!none \fi \fi \fi \else - \ifconvertGRAY - \dosetcolormodel{gray}% + \ifconditional\c_colors_convert_gray + \colors_set_model\s!gray \else - \dosetcolormodel{none}% + \colors_set_model\s!none \fi \fi} -\appendtoks - \dosetupcolormodel -\to \everyjob - % Currently in mkiv transparency is implemented independent of color. This costs % a bit more processing time but gives the possibility to apply transparency % independently in the future. Is this useful? If not we may as well combine them @@ -737,49 +564,34 @@ % Since we couple definitions, we could stick to one test. Todo. Same for mpcolor. -% : in currentpalet, maybe not, ugly (some day at the lua end) - -\letvalueempty{\??qc:-} -\letvalueempty{\??qt:-} - -% \unexpanded\def\doactivatecolor#1% : in currentpalet, maybe not, ugly (some day at the lua end) -% {\edef\currentcolorname{#1}% -% \ifcsname\??qc:\currentpalet\currentcolorname\endcsname -% \csname\??qc:\currentpalet\currentcolorname\endcsname -% \csname\??qt:\currentpalet\currentcolorname\endcsname -% \else\ifcsname\??qc:\currentcolorname\endcsname -% \csname\??qc:\currentcolorname\endcsname -% \csname\??qt:\currentcolorname\endcsname -% \fi\fi} +\letvalue{\??colorsetter-}\empty % used? +\letvalue{\??transparencysetter-}\empty % used? -\unexpanded\def\doactivatecolor#1% not that much faster but less tracing - {\edef\currentcolorname{#1}% - \ifx\currentpalet\empty - \expandafter\doactivatecolor_nop +\def\colors_activate % two-step is not that much faster but less tracing + {\ifx\currentcolorprefix\empty + \expandafter\colors_activate_nop \else - \expandafter\doactivatecolor_yes + \expandafter\colors_activate_yes \fi} -\unexpanded\def\doactivatecolor_yes - {\ifcsname\??qc:\currentpalet\currentcolorname\endcsname - \csname\??qc:\currentpalet\currentcolorname\endcsname - \csname\??qt:\currentpalet\currentcolorname\endcsname - \else\ifcsname\??qc:\currentcolorname\endcsname - \csname\??qc:\currentcolorname\endcsname - \csname\??qt:\currentcolorname\endcsname +\def\colors_activate_yes#1% + {\edef\currentcolorname{#1}% + \ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname + \csname\??colorsetter\currentcolorprefix\currentcolorname\endcsname + \csname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname + \else\ifcsname\??colorsetter\currentcolorname\endcsname + \csname\??colorsetter\currentcolorname\endcsname + \csname\??transparencysetter\currentcolorname\endcsname \fi\fi} -\unexpanded\def\doactivatecolor_nop - {\ifcsname\??qc:\currentcolorname\endcsname - \csname\??qc:\currentcolorname\endcsname - \csname\??qt:\currentcolorname\endcsname +\def\colors_activate_nop#1% + {\edef\currentcolorname{#1}% + \ifcsname\??colorsetter\currentcolorname\endcsname + \csname\??colorsetter\currentcolorname\endcsname + \csname\??transparencysetter\currentcolorname\endcsname \fi} -\let\normaldoactivatecolor\doactivatecolor - -% new: - -\let\dousecolorparameter\doactivatecolor +\let\dousecolorparameter\colors_activate \unexpanded\def\dousecolorhashparameter#1#2% {\ifcsname#1#2\endcsname @@ -788,82 +600,89 @@ \unexpanded\def\dousecurrentcolorparameter {\let\currentcolorname\currentcolorparameter % maybe only when success - \ifcsname\??qc:\currentpalet\currentcolorparameter\endcsname - \csname\??qc:\currentpalet\currentcolorparameter\endcsname - \csname\??qt:\currentpalet\currentcolorparameter\endcsname - \else\ifcsname\??qc:\currentcolorparameter\endcsname - \csname\??qc:\currentcolorparameter\endcsname - \csname\??qt:\currentcolorparameter\endcsname + \ifcsname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname + \csname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname + \csname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname + \else\ifcsname\??colorsetter\currentcolorparameter\endcsname + \csname\??colorsetter\currentcolorparameter\endcsname + \csname\??transparencysetter\currentcolorparameter\endcsname \fi\fi} \let\dosetcolorattribute\dousecolorhashparameter % for a while -% if it becomes a bottleneck we can set up a more complex system with one shared -% attribute for colorspace, color and transparency -% -% maybe always on - -\def\doactivatecolor - {\ifproductionrun - \ctxcommand{enablecolor() commands.enabletransparency()}% not that efficient but at least robust - \let\doactivatecolor\normaldoactivatecolor - \expandafter\doactivatecolor - \else - \expandafter\normaldoactivatecolor - \fi} - -\def\deactivatecolor +\unexpanded\def\deactivatecolor {\let\currentcolorname\s!black \attribute\colorattribute\attributeunsetvalue \attribute\transparencyattribute\attributeunsetvalue} -\def\dodefinecolorcommand#1#2% - {\unexpanded#1{#2}{\doactivatecolor{#2}}} - -\let\colorlist\empty % not really used, only for colo-run -\setfalse\collectcolorsinlist -\def\collectcolorinlist#1{\doglobal\addtocommalist{#1}\colorlist} +\def\colors_define[#1][#2]% + {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colors_freeze_state)}% + \unexpanded\setvalue{#1}{\colors_activate{#1}}} -\def\doregistercolor#1#2% - {\ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}} +\def\colors_define_global[#1][#2]% + {\ctxcommand{defineprocesscolor("#1","#2",true,\v_colors_freeze_state)}% + \unexpanded\setgvalue{#1}{\colors_activate{#1}}} -\def\dodefinecolor[#1][#2]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}% - \dodefinecolorcommand\setvalue{#1}} +\def\colors_define_named[#1][#2]% + {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colors_freeze_state)}% + \unexpanded\setvalue{#1}{\colors_activate{#1}}} -\def\dodefineglobalcolor[#1][#2]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{defineprocesscolor("#1","#2",true,\colorfreezestate)}% - \dodefinecolorcommand\setgvalue{#1}} +\def\dodefinefastcolor[#1][#2]% still not fast but ok (might change) + {\ctxcommand{defineprocesscolor("#1","#2",false,\v_colors_freeze_state)}% + \unexpanded\setvalue{#1}{\colors_activate{#1}}} -\def\dodefinenamedcolor[#1][#2]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}% - \dodefinecolorcommand\setvalue{#1}} +% Spotcolors used setxvalue but that messes up currentcolor +% and probably no global is needed either but they are global +% at the lua end (true argument) so we keep that if only because +% spot colors often are a document wide property -\def\dodefinespotcolor[#1][#2][#3]% - {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi - \ctxcommand{definespotcolor("#1","#2","#3",true)}% - \dodefinecolorcommand\setxvalue{#1}} +\def\colors_define_spot[#1][#2][#3]% + {\ctxcommand{definespotcolor("#1","#2","#3",true)}% + \unexpanded\setgvalue{#1}{\colors_activate{#1}}} -\def\dodefinemultitonecolor[#1][#2][#3][#4]% +\def\colors_define_multitone[#1][#2][#3][#4]% {\ctxcommand{definemultitonecolor("#1","#2","#3","#4",true)}% - \dodefinecolorcommand\setxvalue{#1}} + \unexpanded\setgvalue{#1}{\colors_activate{#1}}} -\def\dodefinetransparency[#1][#2]% +%D Transparencies (only): + +\def\colors_define_transpancy[#1][#2]% {\ctxcommand{definetransparency("#1",#2)}} -\def\dosetrastercolor#1% slow, we need a fast one - {\edef\@@rastervalue{#1}% - \ifx\@@rastervalue\empty - \let\@@rastervalue\@@rsscreen - \fi - \ctxcommand{setrastercolor("_raster_",\@@rastervalue)}} % sets attribute +% A goodie that replaces the startMPcolor hackery -\def\dodefinefastcolor[#1][#2]% still not fast but ok - {\ctxcommand{defineprocesscolor("#1","#2",false,\colorfreezestate)}% - \dodefinecolorcommand\setvalue{#1}} +% \definecolor[red-t] [r=1,t=0.5,a=1] +% \definecolor[green-t][g=1,t=0.5,a=1] +% +% \defineintermediatecolor[mycolora][0.5,red,green] +% \defineintermediatecolor[mycolorb][0.5,red-t,green-t] +% +% \definecolor[mycolorc][.5(blue,red)] +% \definecolor[mycolord][.5(blue)] +% +% \enabledirectives[colors.pgf] +% \definecolor[mycolorx][magenta!50!yellow] +% +% \starttext +% test {\mycolora OEPS} test +% test {\mycolorb OEPS} test +% test {\mycolorc OEPS} test +% test {\mycolord OEPS} test +% test {\mycolorx OEPS} test +% \stoptext + +\unexpanded\def\defineintermediatecolor + {\dotripleempty\colors_define_intermediate} + +\def\colors_define_intermediate[#1][#2][#3]% \dotripleempty adds {} inside [] + {\colors_define_intermediate_indeed[#1][#2][#3]} + +\def\colors_define_intermediate_indeed[#1][#2,#3,#4][#5]% + {\ctxcommand{defineintermediatecolor("#1","#2", + \thecolorattribute{#3},\thecolorattribute{#4}, + \thetransparencyattribute{#3},\thetransparencyattribute{#4}, + "#5",false,\iffreezecolors true\else false\fi)}% not global + \unexpanded\setvalue{#1}{\colors_activate{#1}}} %D \macros %D {doifcolorelse, doifcolor} @@ -873,32 +692,23 @@ %D define ourselves a color conditional first. \def\doifcolorelse#1% - {\ifcsname\??qa:\currentpalet#1\endcsname + {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname \expandafter\firstoftwoarguments - \else\ifcsname\??qa:#1\endcsname + \else\ifcsname\??colorattribute#1\endcsname \doubleexpandafter\firstoftwoarguments \else \doubleexpandafter\secondoftwoarguments \fi\fi} \def\doifcolor#1% - {\ifcsname\??qa:\currentpalet#1\endcsname + {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname \expandafter\firstofoneargument - \else\ifcsname\??qa:#1\endcsname + \else\ifcsname\??colorattribute#1\endcsname \doubleexpandafter\firstofoneargument \else \doubleexpandafter\gobbleoneargument \fi\fi} -%D \macros -%D {colored} -%D -%D A bit like \type {\definedfont}: - -\unexpanded\def\colored[#1]% - {\ctxcommand{defineprocesscolor("@colored@","#1",false,false)}% - \groupedcommand{\doactivatecolor{@colored@}}{}} - %D \macros %D {startregistercolor,stopregistercolor,permitcolormode} %D @@ -925,94 +735,107 @@ %D \stopregistercolor %D \stoptyping -% can be cleaned up - \let\maintextcolor \empty \def\defaulttextcolor {black} -\def\@@themaintextcolor{themaintextcolor} +\def\s!themaintextcolor{themaintextcolor} \appendtoks - \deactivatecolor - \ifx\maintextcolor\empty\else\doactivatecolor\maintextcolor\fi + \deactivatecolor + \ifx\maintextcolor\empty\else\colors_activate\maintextcolor\fi \to \everybeforeoutput -\def\registermaintextcolor - {\ctxcommand{registermaintextcolor(\thecolorattribute\maintextcolor)}} +\def\colors_switch_to_maintextcolor#1% + {\let\maintextcolor\s!themaintextcolor + \definecolor[\maintextcolor][#1]% + \colors_activate\maintextcolor + \ctxcommand{registermaintextcolor(\thecolorattribute\maintextcolor)}} \unexpanded\def\starttextcolor[#1]% {\doifsomething{#1} - {\definecolor[\@@themaintextcolor][#1]% - \let\maintextcolor\@@themaintextcolor - \doactivatecolor\maintextcolor - \registermaintextcolor}} + {\colors_switch_to_maintextcolor{#1}}} \let\stoptextcolor\relax -\def\initializemaintextcolor - {\doifelsenothing\@@cltextcolor - {\definecolor[\@@themaintextcolor][\defaulttextcolor]} - {\definecolor[\@@themaintextcolor][\@@cltextcolor]}% - \let\maintextcolor\@@themaintextcolor - \doactivatecolor\maintextcolor - \registermaintextcolor} +\let\p_colors_textcolor\empty + +\def\color_initialize_maintextcolor + {\edef\p_colors_textcolor{\colorsparameter\c!textcolor}% + \ifx\p_colors_textcolor\empty + \colors_switch_to_maintextcolor\defaulttextcolor + \else + \colors_switch_to_maintextcolor\p_colors_textcolor + \fi} + +\appendtoks \color_initialize_maintextcolor \to \everyjob +\appendtoks \color_initialize_maintextcolor \to \everysetupcolors -\appendtoks \initializemaintextcolor \to \everyjob -\appendtoks \initializemaintextcolor \to \everysetupcolors +\def\colors_inherited_direct_cs#1{\csname\??colorsetter \ifcsname\??colorsetter #1\endcsname#1\fi\endcsname} +\def\colors_inherited_direct_ca#1{\csname\??colorattribute \ifcsname\??colorattribute #1\endcsname#1\fi\endcsname} +\def\colors_inherited_direct_ts#1{\csname\??transparencysetter \ifcsname\??transparencysetter #1\endcsname#1\fi\endcsname} +\def\colors_inherited_direct_ta#1{\csname\??transparencyattribute\ifcsname\??transparencyattribute#1\endcsname#1\fi\endcsname} -\def\doinheritdirectcs#1{\csname\??qc:\ifcsname\??qc:#1\endcsname#1\fi\endcsname} -\def\doinheritdirectca#1{\csname\??qa:\ifcsname\??qa:#1\endcsname#1\fi\endcsname} -\def\doinheritdirectts#1{\csname\??qt:\ifcsname\??qt:#1\endcsname#1\fi\endcsname} -\def\doinheritdirectta#1{\csname\??qs:\ifcsname\??qs:#1\endcsname#1\fi\endcsname} +\def\colors_inherited_palet_ca#1#2{\csname\??colorattribute \ifcsname\??colorattribute \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +\def\colors_inherited_palet_cs#1#2{\csname\??colorsetter \ifcsname\??colorsetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +\def\colors_inherited_palet_ta#1#2{\csname\??transparencyattribute\ifcsname\??transparencyattribute\??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} +\def\colors_inherited_palet_ts#1#2{\csname\??transparencysetter \ifcsname\??transparencysetter \??colorpalet#1:#2\endcsname\??colorpalet#1:#2\fi\endcsname} -\def\doinheritpaletca#1#2{\csname\??qa:\ifcsname\??qa:\??pa#1:#2\endcsname\??pa#1:#2\fi\endcsname} -\def\doinheritpaletcs#1#2{\csname\??qc:\ifcsname\??qc:\??pa#1:#2\endcsname\??pa#1:#2\fi\endcsname} -\def\doinheritpaletta#1#2{\csname\??qs:\ifcsname\??qs:\??pa#1:#2\endcsname\??pa#1:#2\fi\endcsname} -\def\doinheritpaletts#1#2{\csname\??qt:\ifcsname\??qt:\??pa#1:#2\endcsname\??pa#1:#2\fi\endcsname} +\let\colors_set_value\setvalue + +\appendtoks + \ifconditional\c_colors_expanded + \let\colors_set_value\setevalue + \else + \let\colors_set_value\setvalue + \fi +\to \everysetupcolors -\def\dodefinepaletcolor#1#2#3% +\def\colors_define_palet_set#1#2#3% {\doifassignmentelse{#3}% \definepalet[test][xx={y=.4}] - {\definecolor[\??pa#1:#2][#3]% - \dosetcolorvalue{\??qc:#1:#2}{\doinheritpaletca{#1}{#2}}% - \dosetcolorvalue{\??qa:#1:#2}{\doinheritpaletcs{#1}{#2}}% - \dosetcolorvalue{\??qt:#1:#2}{\doinheritpaletta{#1}{#2}}% - \dosetcolorvalue{\??qs:#1:#2}{\doinheritpaletts{#1}{#2}}} - {\ifcsname\??qc:#3\endcsname % \definepalet[test][xx=green] - \dosetcolorvalue{\??qc:#1:#2}{\doinheritdirectcs{#3}}% - \dosetcolorvalue{\??qa:#1:#2}{\doinheritdirectca{#3}}% - \dosetcolorvalue{\??qt:#1:#2}{\doinheritdirectts{#3}}% - \dosetcolorvalue{\??qs:#1:#2}{\doinheritdirectta{#3}}% + {\definecolor[\??colorpalet#1:#2][#3]% + \colors_set_value{\??colorsetter #1:#2}{\colors_inherited_palet_ca{#1}{#2}}% + \colors_set_value{\??colorattribute #1:#2}{\colors_inherited_palet_cs{#1}{#2}}% + \colors_set_value{\??transparencysetter #1:#2}{\colors_inherited_palet_ta{#1}{#2}}% + \colors_set_value{\??transparencyattribute#1:#2}{\colors_inherited_palet_ts{#1}{#2}}} + {\ifcsname\??colorsetter#3\endcsname % \definepalet[test][xx=green] + \colors_set_value{\??colorsetter #1:#2}{\colors_inherited_direct_cs{#3}}% + \colors_set_value{\??colorattribute #1:#2}{\colors_inherited_direct_ca{#3}}% + \colors_set_value{\??transparencysetter #1:#2}{\colors_inherited_direct_ts{#3}}% + \colors_set_value{\??transparencyattribute#1:#2}{\colors_inherited_direct_ta{#3}}% \else % not entered when making format - \localundefine{\??qc:#1:#2}% - \localundefine{\??qa:#1:#2}% - \localundefine{\??qt:#1:#2}% - \localundefine{\??qs:#1:#2}% + \localundefine{\??colorsetter #1:#2}% + \localundefine{\??colorattribute #1:#2}% + \localundefine{\??transparencysetter #1:#2}% + \localundefine{\??transparencyattribute#1:#2}% \fi}} -\setvalue{\??qc:}{} \setvalue{\??qa:}{0} -\setvalue{\??qt:}{} \setvalue{\??qs:}{0} +\letvalue{\??colorsetter }\empty \letvalue{\??colorattribute }\!!zerocount +\letvalue{\??transparencysetter}\empty \letvalue{\??transparencyattribute}\!!zerocount + +\setvalue{\??colorattribute currentcolor}{\the\attribute\colorattribute} % for mpcolor +\setvalue{\??transparencyattribute currentcolor}{\the\attribute\transparencyattribute} % for mpcolor -\def\doinheritca#1{\csname\??qa:\ifcsname\??qa:\currentpalet#1\endcsname\currentpalet#1\else\ifcsname\??qa:#1\endcsname#1\fi\fi\endcsname} -\def\doinheritcs#1{\csname\??qc:\ifcsname\??qc:\currentpalet#1\endcsname\currentpalet#1\else\ifcsname\??qc:#1\endcsname#1\fi\fi\endcsname} -\def\doinheritta#1{\csname\??qs:\ifcsname\??qs:\currentpalet#1\endcsname\currentpalet#1\else\ifcsname\??qs:#1\endcsname#1\fi\fi\endcsname} -\def\doinheritts#1{\csname\??qt:\ifcsname\??qt:\currentpalet#1\endcsname\currentpalet#1\else\ifcsname\??qt:#1\endcsname#1\fi\fi\endcsname} +\def\colors_inherited_ca#1{\csname\??colorattribute \ifcsname\??colorattribute \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorattribute #1\endcsname#1\fi\fi\endcsname} +\def\colors_inherited_cs#1{\csname\??colorsetter \ifcsname\??colorsetter \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorsetter #1\endcsname#1\fi\fi\endcsname} +\def\colors_inherited_ta#1{\csname\??transparencyattribute\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencyattribute#1\endcsname#1\fi\fi\endcsname} +\def\colors_inherited_ts#1{\csname\??transparencysetter \ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencysetter #1\endcsname#1\fi\fi\endcsname} %D Low level defs: -\def\colordefalc#1#2{\setevalue{\??qa:#1}{#2}\setvalue {\??qc:#1}{\attribute\colorattribute #2 }} -\def\colordefagc#1#2{\setxvalue{\??qa:#1}{#2}\setgvalue{\??qc:#1}{\attribute\colorattribute #2 }} % was not g -\def\colordefalt#1#2{\setevalue{\??qs:#1}{#2}\setvalue {\??qt:#1}{\attribute\transparencyattribute#2 }} -\def\colordefagt#1#2{\setxvalue{\??qs:#1}{#2}\setgvalue{\??qt:#1}{\attribute\transparencyattribute#2 }} +\unexpanded\def\colordefalc#1#2{\setevalue{\??colorattribute #1}{#2}\setvalue {\??colorsetter #1}{\attribute\colorattribute #2 }} +\unexpanded\def\colordefagc#1#2{\setxvalue{\??colorattribute #1}{#2}\setgvalue{\??colorsetter #1}{\attribute\colorattribute #2 }} % was not g +\unexpanded\def\colordefalt#1#2{\setevalue{\??transparencyattribute#1}{#2}\setvalue {\??transparencysetter#1}{\attribute\transparencyattribute#2 }} +\unexpanded\def\colordefagt#1#2{\setxvalue{\??transparencyattribute#1}{#2}\setgvalue{\??transparencysetter#1}{\attribute\transparencyattribute#2 }} -\def\colordefflc#1#2{\setvalue {\??qa:#1}{\doinheritca{#2}}\setvalue {\??qc:#1}{\doinheritcs{#2}}} -\def\colordeffgc#1#2{\setgvalue{\??qa:#1}{\doinheritca{#2}}\setvalue {\??qc:#1}{\doinheritcs{#2}}} -\def\colordefflt#1#2{\setvalue {\??qs:#1}{\doinheritta{#2}}\setvalue {\??qt:#1}{\doinheritts{#2}}} -\def\colordeffgt#1#2{\setgvalue{\??qs:#1}{\doinheritta{#2}}\setgvalue{\??qt:#1}{\doinheritts{#2}}} +\unexpanded\def\colordefflc#1#2{\setvalue {\??colorattribute #1}{\colors_inherited_ca{#2}}\setvalue {\??colorsetter #1}{\colors_inherited_cs{#2}}} +\unexpanded\def\colordeffgc#1#2{\setgvalue{\??colorattribute #1}{\colors_inherited_ca{#2}}\setvalue {\??colorsetter #1}{\colors_inherited_cs{#2}}} +\unexpanded\def\colordefflt#1#2{\setvalue {\??transparencyattribute#1}{\colors_inherited_ta{#2}}\setvalue {\??transparencysetter#1}{\colors_inherited_ts{#2}}} +\unexpanded\def\colordeffgt#1#2{\setgvalue{\??transparencyattribute#1}{\colors_inherited_ta{#2}}\setgvalue{\??transparencysetter#1}{\colors_inherited_ts{#2}}} -\def\colordefrlc #1{\localundefine {\??qa:#1}\localundefine {\??qc:#1}} -\def\colordefrgc #1{\globalundefine{\??qa:#1}\globalundefine{\??qc:#1}} -\def\colordefrlt #1{\localundefine {\??qs:#1}\localundefine {\??qt:#1}} -\def\colordefrgt #1{\globalundefine{\??qs:#1}\globalundefine{\??qt:#1}} +\unexpanded\def\colordefrlc #1{\localundefine {\??colorattribute #1}\localundefine {\??colorsetter #1}} +\unexpanded\def\colordefrgc #1{\globalundefine{\??colorattribute #1}\globalundefine{\??colorsetter #1}} +\unexpanded\def\colordefrlt #1{\localundefine {\??transparencyattribute#1}\localundefine {\??transparencysetter#1}} +\unexpanded\def\colordefrgt #1{\globalundefine{\??transparencyattribute#1}\globalundefine{\??transparencysetter#1}} %D \macros %D {colorvalue, grayvalue} @@ -1038,11 +861,13 @@ \let\colorformatseparator\space -\def\MPcolor #1{\ctxcommand{mpcolor(\number\currentcolormodel,\number\doinheritca{#1},\number\doinheritta{#1})}} -\def\MPoptions #1{\ctxcommand{mpoptions(\number\currentcolormodel,\number\doinheritca{#1},\number\doinheritta{#1})}} +\def\MPcolor #1{\ctxcommand{mpcolor(\number\attribute\colormodelattribute,\number\colors_inherited_ca{#1},\number\colors_inherited_ta{#1})}} +\def\MPoptions #1{\ctxcommand{mpoptions(\number\attribute\colormodelattribute,\number\colors_inherited_ca{#1},\number\colors_inherited_ta{#1})}} -\def\thecolorattribute #1{\number\csname\??qa:\ifcsname\??qa:\currentpalet#1\endcsname\currentpalet#1\else\ifcsname\??qa:#1\endcsname#1\fi\fi\endcsname} -\def\thetransparencyattribute#1{\number\csname\??qs:\ifcsname\??qs:\currentpalet#1\endcsname\currentpalet#1\else\ifcsname\??qs:#1\endcsname#1\fi\fi\endcsname} +\def\thecolorattribute #1{\number\csname\??colorattribute \ifcsname\??colorattribute \currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??colorattribute #1\endcsname#1\fi\fi\endcsname} +\def\thetransparencyattribute#1{\number\csname\??transparencyattribute\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\currentcolorprefix#1\else\ifcsname\??transparencyattribute#1\endcsname#1\fi\fi\endcsname} + +\def\thecolormodelattribute {\the\attribute\colormodelattribute} \def\internalspotcolorname #1{\ctxcommand{spotcolorname(\thecolorattribute{#1})}} \def\internalspotcolorparent #1{\ctxcommand{spotcolorparent(\thecolorattribute{#1})}} @@ -1079,10 +904,9 @@ \unexpanded\def\forcecolorhack{\leaders\hrule\normalhskip\zeropoint} -%D We default to the colors defined in \type {colo-rgb} and -%D support both \cap{RGB} and \cap{CMYK} output. As you can -%D see, color support is turned off by default. Reduction of -%D gray colors to gray scales is turned on. +%D We default to the colors defined in \type {colo-imp-rgb} and +%D support both \RGB\ and \CMYK\ output. Transparencies are defined +%D here: \definecolor[black][s=0] \definecolor[white][s=1] @@ -1106,27 +930,14 @@ \definetransparency [luminosity] [16] \setupcolors - [\c!state=\v!stop, % will be enabled later on + [\c!state=\v!stop, % color will be enabled later on \c!conversion=\v!yes, - \c!reduction=\v!no, \c!rgb=\v!yes, \c!cmyk=\v!yes, \c!spot=\v!yes, - \c!mp\c!cmyk=\@@clcmyk, - \c!mp\c!spot=\@@clspot, \c!expansion=\v!no, \c!textcolor=, - \c!split=\v!no, % obsolete - \c!factor=\v!yes, - \c!criterium=\v!all] % obsolete - -\appendtoks - \setupcolors[\c!state=\v!start]% later direct -\to \everyjob - -\appendtoks - \let\showcolormessage\showmessage -\to \everyjob + \c!factor=\v!yes] \setupcolor [\v!rgb] diff --git a/tex/context/base/colo-run.lua b/tex/context/base/colo-run.lua new file mode 100644 index 000000000..4f1916d5a --- /dev/null +++ b/tex/context/base/colo-run.lua @@ -0,0 +1,66 @@ +if not modules then modules = { } end modules ['colo-run'] = { + version = 1.000, + comment = "companion to colo-run.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- For historic reasons the core has a couple of tracing +-- features. Nowadays these would end up in modules. + +local colors= attributes.colors + +function commands.showcolorset(name) + local set = colors.setlist(name) + context.starttabulate { "|l|l|l|l|l|l|l|" } + for i=1,#set do + local s = set[i] + local r = { width = "4em", height = "max", depth = "max", color = s } + context.NC() + context.setcolormodel { "gray" } + context.blackrule(r) + context.NC() + context.blackrule(r) + context.NC() + context.grayvalue(s) + context.NC() + context.colorvalue(s) + context.NC() + context(s) + context.NC() + context.NR() + end + context.stoptabulate() +end + +function commands.showcolorcomponents(list) + local set = utilities.parsers.settings_to_array(list) + context.starttabulate { "|lT|lT|lT|lT|" } + context.NC() + context("color") + context.NC() + context("name") + context.NC() + context("transparency") + context.NC() + context("specification ") + context.NC() + context.NR() + context.TB() + for i=1,#set do + local s = set[i] + context.NC() + context.showcolorbar { s } + context.NC() + context(s) + context.NC() + context.transparencycomponents(s) + context.NC() + context.colorcomponents(s) + context.NC() + context.NR() + end + context.stoptabulate() +end + diff --git a/tex/context/base/colo-run.mkiv b/tex/context/base/colo-run.mkiv index 363b39c47..7d24b1d89 100644 --- a/tex/context/base/colo-run.mkiv +++ b/tex/context/base/colo-run.mkiv @@ -11,57 +11,70 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +\registerctxluafile{colo-run}{1.000} + \unprotect -% temp hack (not do be documented) +%D Colors + +% These are nicer in \LUA\ code than in \TEX\ code but not more +% efficient. + +\unexpanded\gdef\showcolorbar[#1]% + {\backgroundline[#1]{\strut\enspace\color[white]{white}\enspace\color[black]{black}\enspace}} -% \gdef\doformatcolorP#1:#2:#3:#4:#5:#6\od % was undefined in colo-ini -% {#1\colorformatseparator -% \dodoformatcolor{#2}\colorformatseparator -% \dodoformatcolor{#3}\colorformatseparator -% \dodoformatcolor{#4}\colorformatseparator} +\unexpanded\gdef\showcolor {\dosingleempty\colors_show} +\unexpanded\gdef\showcolorset {\dosingleempty\colors_show_set} +\unexpanded\gdef\showcolorcomponents{\dosingleempty\colors_show_components} -% \gdef\doformatgrayP#1:#2:#3:#4:#5:#6\od -% {todo} +\gdef\colors_show_set [#1]{\ctxcommand{showcolorset("#1")}} +\gdef\colors_show_components[#1]{\ctxcommand{showcolorcomponents("#1")}} -% so far +\gdef\colors_show[#1]% % we do this at the tex end as loading happens + {\usecolors [#1]% % delayed and we can only ask for the set if + \showcolorset[#1]} % loading has happened -\gdef\showpalet +% The rest might also be done in \LUA\ although there is not much +% beauty to gain here (too much typesetting specific). Also, these +% macros are pretty old and hardly used so best keep them as they +% are. + +%D Palets + +\unexpanded\gdef\showpalet {\dodoubleargument\doshowpalet} \gdef\doshowpalet[#1][#2]% - {\doifdefined{\??pa#1} - {\doifinsetelse\v!vertical{#2} - {\showverticalpalet[#1][#2]} - {\showhorizontalpalet[#1][#2]}}} + {\ifcsname\??colorpalet#1\endcsname + \doifinsetelse\v!vertical{#2} \colors_show_palet_vertical \colors_show_palet_horizontal [#1][#2]% + \fi} -\gdef\showverticalpalet[#1][#2]% +\gdef\colors_show_palet_vertical[#1][#2]% {\localvbox {\offinterlineskip \setuppalet[#1] - \def\rule - {\vrule\!!width3em\!!height\strutht\!!depth\strutdp} \tabskip\zeropoint - \def\doshowpalet##1% + \def\show_palet##1% {\doifinsetelse\v!number{#2}{##1\hskip.5em}{}& - \color[##1]{\rule}\graycolor[##1]{\rule}& + \color[##1]{\vrule\!!width3em\!!height\strutht\!!depth\strutdp}% + \graycolor[##1]{\vrule\!!width3em\!!height\strutht\!!depth\strutdp}& \doifinset\v!value{#2}{\hskip.5em\colorvalue{##1}}\crcr} \halign {\hss##&\hss##\hss&##\cr - &\doifinset{\v!name}{#2}{\strut#1}&\cr% - \processpalet[#1]\doshowpalet\crcr}}} + &\doifinset\v!name{#2}{\strut#1}&\cr% + \colors_process_palet[#1]\show_palet\crcr}}} -\gdef\showhorizontalpalet[#1][#2]% todo: bTABLE etc +\gdef\colors_show_palet_horizontal[#1][#2]% todo: bTABLE etc {\localvbox {\offinterlineskip \setuppalet[#1] \tabskip\zeropoint \!!widtha\zeropoint \doifinset\v!number{#2} - {\def\doshowpalet##1% + {\def\show_palet##1% {\setbox0\hbox{##1}% \ifdim\!!widtha<\wd0\!!widtha\wd0\fi}% - \processpalet[#1]\doshowpalet}% + \colors_process_palet[#1]\show_palet}% \advance\!!widtha 1em \ifdim\!!widtha<5em \!!widtha5em @@ -69,18 +82,18 @@ \halign {##&&\hbox to \!!widtha{\hss##\hss}\cr \doifinset\v!number{#2} - {\def\doshowpalet##1{&\strut##1}% - \processpalet[#1]\doshowpalet}\cr + {\def\show_palet##1{&\strut##1}% + \colors_process_palet[#1]\show_palet}\cr \doifinset\v!name{#2}{#1\hskip.5em}% - \def\doshowpalet##1% + \def\show_palet##1% {&\strut\color[##1]{\vrule\!!width\!!widtha\!!height\strutht\!!depth\zeropoint}}% - \processpalet[#1]\doshowpalet\crcr + \colors_process_palet[#1]\show_palet\crcr \noalign{\vskip-\strutdepth}% - \def\doshowpalet##1% + \def\show_palet##1% {&\graycolor[##1]{\vrule\!!width\!!widtha\!!height\zeropoint\!!depth\strutdp}}% - \processpalet[#1]\doshowpalet\crcr + \colors_process_palet[#1]\show_palet\crcr \doifinset\v!value{#2} - {\def\doshowpalet##1% + {\def\show_palet##1% {&\vbox {\hsize\!!widtha \vskip.25ex @@ -88,39 +101,67 @@ \veryraggedcenter \let\colorformatseparator\endgraf \colorvalue{##1}}}% - \processpalet[#1]\doshowpalet}% + \colors_process_palet[#1]\show_palet}% \crcr}}} -\gdef\processpalet[#1]% - {\expanded{\globalprocesscommalist[\getvalue{\??pa#1}]}} +\gdef\colors_process_palet[#1]% + {\expanded{\globalprocesscommalist[\getvalue{\??colorpalet#1}]}} + +\unexpanded\gdef\comparepalet + {\dosingleargument\colors_compare_palet} -\gdef\showcolorgroup - {\dodoubleargument\doshowcolorgroup} +\gdef\colors_compare_palet[#1]% + {\ifcsname\??colorpalet#1\endcsname + \hbox + {\colors_compare_palet_indeed\color[#1]% + \quad + \colors_compare_palet_indeed\graycolor[#1]}% + \fi} -\gdef\doshowcolorgroup[#1][#2]% +\gdef\colors_compare_palet_indeed#1[#2]% + {\localvbox + {\offinterlineskip + \setuppalet[#2] + \getcommacommandsize[\getvalue{\??colorpalet#2}] + \!!widtha2em\relax + \hsize\commalistsize\!!widtha + \def\compare_palet##1% + {\hbox + {\setbox0\hbox + {#1[##1]{\vrule\!!width\hsize\!!height3ex}}% + \wd0\zeropoint + \box0 + \hbox to \hsize + {\def\compare_palet####1% + {\hbox to \!!widtha + {\hss#1[####1]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}% + \processcommacommand[\getvalue{\??colorpalet#2}]\compare_palet}} + \endgraf} + \processcommacommand[\getvalue{\??colorpalet#2}]\compare_palet}} + +%D Groups + +\unexpanded\gdef\showcolorgroup + {\dodoubleargument\colors_show_group} + +\gdef\colors_show_group[#1][#2]% {\doifcolor{#1:1} - {\doifinsetelse\v!vertical{#2} - {\showverticalcolorgroup[#1][#2]} - {\showhorizontalcolorgroup[#1][#2]}}} + {\doifinsetelse\v!vertical{#2} \colors_show_group_vertical \colors_show_group_horizontal [#1][#2]}} -\gdef\showhorizontalcolorgroup[#1][#2]% +\gdef\colors_show_group_horizontal[#1][#2]% {\localvbox {\offinterlineskip \setuppalet \tabskip\zeropoint - \def\rule - {\vrule\!!width4em\!!height\strutht\!!depth\strutdp} \def\colorformatseparator{\strut\cr} - \def\dodoshowgroup##1% - {\halign - {\hss####\hss\cr - \doifinset\v!number{#2}{\strut##1}\cr - \color[#1:##1]{\vrule\!!width4em\!!height\strutht\!!depth\zeropoint}\cr - \graycolor[#1:##1]{\vrule\!!width4em\!!height\zeropoint\!!depth\strutdp}\cr - \doifinset\v!value{#2}{\colorvalue{#1:##1}\strut}\crcr}} - \def\doshowgroup##1% - {\doifcolor{#1:##1} - {\vbox{\dodoshowgroup{##1}}}}% + \def\show_group##1% + {\doifcolor{#1:##1}{\vbox + {\halign + {\hss####\hss\cr + \doifinset\v!number{#2}{\strut##1}\cr + \color[#1:##1]{\vrule\!!width4em\!!height\strutht\!!depth\zeropoint}\cr + \graycolor[#1:##1]{\vrule\!!width4em\!!height\zeropoint\!!depth\strutdp}\cr + \doifinset\v!value{#2}{\colorvalue{#1:##1}\strut}\crcr}}}}% \hbox {\doifinset\v!name{#2} {\strut @@ -128,130 +169,52 @@ {\raise3\lineheight\hbox{#1\hskip.5em}} {#1}% \hskip.5em}% - \doshowgroup1\doshowgroup2\doshowgroup3\doshowgroup4% - \doshowgroup5\doshowgroup6\doshowgroup7\doshowgroup8}}} + \show_group1\show_group2\show_group3\show_group4% + \show_group5\show_group6\show_group7\show_group8}}} -\gdef\showverticalcolorgroup[#1][#2]% +\gdef\colors_show_group_vertical[#1][#2]% {\localvbox {\offinterlineskip \setuppalet \tabskip\zeropoint - \def\rule - {\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}% - \def\doshowgroup##1% + \def\show_group##1% {\doifcolor{#1:##1} {\doifinset\v!number{#2}{##1\hskip.5em}& - \color[#1:##1]{\rule}\graycolor[#1:##1]{\rule}& + \color[#1:##1]{\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}% + \graycolor[#1:##1]{\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}& \doifinset\v!value{#2}{\hskip.5em\colorvalue{#1:##1}}\crcr}}% \halign {\hss##&\hss##\hss&##\hss\cr &\doifinset\v!name{#2}{\strut#1}&\crcr - \doshowgroup1\doshowgroup2\doshowgroup3\doshowgroup4% - \doshowgroup5\doshowgroup6\doshowgroup7\doshowgroup8}}} + \show_group1\show_group2\show_group3\show_group4% + \show_group5\show_group6\show_group7\show_group8}}} -\gdef\showcolor - {\dosingleempty\doshowcolor} +\unexpanded\gdef\comparecolorgroup + {\dosingleargument\colors_compare_group} -\gdef\doshowcolor[#1]% - {\bgroup - \iffirstargument - \let\colorlist\empty % not really used, only for colo-run - \let\colorstyle\empty - \settrue\collectcolorsinlist - \setupcolor[#1]% - \fi - \def\rule - {\vrule\!!width4em\!!height\strutht\!!depth\strutdp}% - \def\docommand##1% - {\NC\graycolor[##1]{\rule}\NC\color[##1]{\rule}\NC\grayvalue{##1}\NC\colorvalue{##1}\NC##1\NC\NR}% - \starttabulate[|l|l|l|l|l|l|l|] - \expanded{\globalprocesscommalist[\colorlist]}\docommand - \stoptabulate - \egroup} - -\gdef\comparepalet - {\dosingleargument\docomparepalet} - -\gdef\docomparepalet[#1]% - {\doifdefined{\??pa#1} - {\hbox - {\dodocomparepalet\color[#1]% - \quad - \dodocomparepalet\graycolor[#1]}}} - -\gdef\dodocomparepalet#1[#2]% - {\localvbox - {\offinterlineskip - \setuppalet[#2] - \getcommacommandsize[\getvalue{\??pa#2}] - \!!widtha2em\relax - \hsize\commalistsize\!!widtha - \def\rule% - {\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex} - \def\dododocomparepalet##1% - {\hbox - {\setbox0\hbox - {#1[##1]{\vrule\!!width\hsize\!!height3ex}}% - \wd0\zeropoint - \box0 - \hbox to \hsize - {\def\dododocomparepalet####1% - {\hbox to \!!widtha - {\hss#1[####1]{\rule}\hss}}% - \processcommacommand[\getvalue{\??pa#2}]\dododocomparepalet}} - \endgraf} - \processcommacommand[\getvalue{\??pa#2}]\dododocomparepalet}} - -\gdef\comparecolorgroup - {\dosingleargument\docomparecolorgroup} - -\gdef\docomparecolorgroup[#1]% +\gdef\colors_compare_group[#1]% {\doifcolor{#1:1} {\hbox - {\dodocomparecolorgroup\color[#1]% + {\colors_compare_group_indeed\color[#1]% \quad - \dodocomparecolorgroup\graycolor[#1]}}} + \colors_compare_group_indeed\graycolor[#1]}}} -\gdef\dodocomparecolorgroup#1[#2]% +\gdef\colors_compare_group_indeed#1[#2]% {\localvbox {\!!counta\zerocount - \dorecurse{15} - {\doifcolor{#2:\recurselevel}{\advance\!!counta\plusone}} + \dorecurse{15}{\doifcolor{#2:\recurselevel}{\advance\!!counta\plusone}} \!!widtha2em\relax \hsize\!!counta\!!widtha - \def\rule - {\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex} - \def\dododocomparecolorgroup##1% - {\hbox to \hsize - {\setbox0\hbox - {#1[#2:##1]{\vrule\!!width\hsize\!!height3ex}}% - \wd0\zeropoint - \box0 - \hbox to \hsize - {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\rule}\hss}}} - \endgraf} - \dorecurse\!!counta{\dododocomparecolorgroup\recurselevel}}} - -\gdef\dogetcolorcomponents#1% - {\doifelsenothing{#1} - {\appendtoks - \TB - \to \scratchtoks} - {\appendtoks - \NC\showcolorbar[#1]\NC#1\NC\transparencycomponents{#1}\NC\colorcomponents{#1}\NC \NR - \to \scratchtoks}} - -\gdef\showcolorbar[#1]% - {\backgroundline[#1]{\strut\enspace\color[white]{white}\enspace\color[black]{black}\enspace}} - -\gdef\showcolorcomponents[#1]% - {\begingroup - \scratchtoks{\TB}% - \processcommacommand[#1]\dogetcolorcomponents - \starttabulate[|lT|lT|lT|lT|] - \NC color \NC name \NC transparency \NC specification \NC\NR - \the\scratchtoks - \stoptabulate - \endgroup} + \dorecurse\!!counta{\colors_compare_group_step{#1}{#2}\recurselevel}}} + +\def\colors_compare_group_step#1#2#3% + {\hbox to \hsize + {\setbox0\hbox + {#1[#2:#3]{\vrule\!!width\hsize\!!height3ex}}% + \wd0\zeropoint + \box0 + \hbox to \hsize + {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}} + \endgraf} \protect \endinput diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 0e866d665..16f94a495 100644 --- a/tex/context/base/cont-log.mkiv +++ b/tex/context/base/cont-log.mkiv @@ -20,25 +20,31 @@ \unprotect -\def\Mkern#1% - {{\setbox\scratchbox\hbox{M}\kern#1\wd\scratchbox}} - \unexpanded\def\TeX - {T% - \Mkern{-.1667}\lower.5ex\hbox{E}% - \Mkern{-.125}X} + {\dontleavehmode + \begingroup + \setbox\scratchbox\hbox{M}% + T% + \kern-.1667\wd\scratchbox + \lower.5ex\hbox{E}% + \kern-.125\wd\scratchbox + X% + \endgroup} \unexpanded\def\ConTeXt{Con\TeX t} \unexpanded\def\PPCHTeX{ppch\TeX} \unexpanded\def\PRAGMA {Pragma ADE} \unexpanded\def\LaTeX % requested by erik frambach - {{\setbox\scratchbox\hbox{L}% - \scratchdimen\ht\scratchbox - \setbox\scratchbox\hbox{\txx A}% - L\kern-.55\wd\scratchbox - \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}% - \kern-.2\wd\scratchbox\TeX}} + {\dontleavehmode + \begingroup + \setbox\scratchbox\hbox{L}% + \scratchdimen\ht\scratchbox + \setbox\scratchbox\hbox{\txx A}% + L\kern-.55\wd\scratchbox + \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}% + \kern-.2\wd\scratchbox\TeX + \endgroup} \unexpanded\def\TaBlE {T% @@ -53,25 +59,27 @@ \kern-.075em C% \kern-.11em\TeX} -\def\AMSswitch#1% +\def\logo_ams_script#1% {$\cal\ifdim\bodyfontsize>1.1em\scriptstyle\fi#1$} \unexpanded\def\AmSTeX - {\AMSswitch A% - \kern-.1667em\lower.5ex\hbox{\AMSswitch M}% - \kern-.125em\AMSswitch S% + {\dontleavehmode + \logo_ams_script A% + \kern-.1667em\lower.5ex\hbox{\logo_ams_script M}% + \kern-.125em\logo_ams_script S% -\TeX} \unexpanded\def\LamSTeX {L% - \kern-.4em\raise.3ex\hbox{\AMSswitch A}% - \kern-.25em\lower.4ex\hbox{\AMSswitch M}% - \kern-.1em{\AMSswitch S}% + \kern-.4em\raise.3ex\hbox{\logo_ams_script A}% + \kern-.25em\lower.4ex\hbox{\logo_ams_script M}% + \kern-.1em{\logo_ams_script S}% -\TeX} \unexpanded\def\AmSLaTeX - {\AMSswitch A% - \kern-.1667em\lower.5ex\hbox{\AMSswitch M}% + {\dontleavehmode + \logo_ams_script A% + \kern-.1667em\lower.5ex\hbox{\logo_ams_script M}% \kern-.125em\AMSswitch S% -\LaTeX} @@ -84,16 +92,19 @@ %D I changed this into one that adapts itself: \unexpanded\def\Context - {{C\kern -.0667em\getscaledglyph{.8}\empty{O\kern -.0667emN\kern + {\dontleavehmode + \begingroup + C\kern -.0667em\getscaledglyph{.8}\empty{O\kern -.0667emN\kern -.0549emT\doifitalicelse{\kern-.1em}{\kern-.1667em}\lower.5ex\hbox - {E}\doifitalicelse\empty{\kern-.11em}X\kern-.055emT}}} + {E}\doifitalicelse\empty{\kern-.11em}X\kern-.055emT}% + \endgroup} %D The \METAFONT\ and \METAPOST\ logos adapt themselves to the %D current fontsize, an ugly but usefull hack. \let\logofont\nullfont -\loadmapfile[original-base.map] +\loadmapfile[original-base.map] % stil needed? \unexpanded\def\setMFPfont% more sensitive for low level changes {\font\logofont=logo% @@ -106,14 +117,20 @@ 10 at \currentfontscale\bodyfontsize % there is no afm in the minimals yet \logofont} -\def\MetaHyphen% there is no hyphenchar in this font +\def\logo_meta_hyphen % there is no hyphenchar in this font {\discretionary{\vrule\!!height.33em\!!depth-.27em\!!width.33em}{}{}} \unexpanded\def\MetaFont - {{\setMFPfont META\MetaHyphen FONT}} + {\dontleavehmode + \begingroup + \setMFPfont META\logo_meta_hyphen FONT% + \endgroup} \unexpanded\def\MetaPost - {{\setMFPfont META\MetaHyphen POST}} + {\dontleavehmode + \begingroup + \setMFPfont META\logo_meta_hyphen POST% + \endgroup} \unexpanded\def\MetaFun {MetaFun} @@ -158,7 +175,7 @@ % Adapted from a patch by Mojca: -\def\@XeTeX@ +\def\logo_xetex_e {\setbox\scratchbox\hbox{E}% \raise\dimexpr\ht\scratchbox+\dp\scratchbox\relax\hbox{\rotate[\c!rotation=180]{\box\scratchbox}}} @@ -169,14 +186,14 @@ \iffontchar\font"018E\relax \char"018E% \else - \ifx\fontalternative\c!bf\mirror{E}\else - \ifx\fontalternative\c!it \@XeTeX@\else - \ifx\fontalternative\c!sl \@XeTeX@\else - \ifx\fontalternative\c!bi \@XeTeX@\else - \ifx\fontalternative\c!bs \@XeTeX@\else - \mirror{E}\fi\fi\fi\fi\fi + \ifx\fontalternative\c!bf \mirror{E}\else + \ifx\fontalternative\c!it\logo_xetex_e\else + \ifx\fontalternative\c!sl\logo_xetex_e\else + \ifx\fontalternative\c!bi\logo_xetex_e\else + \ifx\fontalternative\c!bs\logo_xetex_e\else + \mirror{E}\fi\fi\fi\fi\fi \fi}% - \kern-.1667em \TeX} + \kern-.1667em\TeX} \let\ETEX \eTeX \let\PDFTEX \pdfTeX diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 9b77a93bf..62231b388 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.12.23 09:52} +\newcontextversion{2011.12.31 13:16} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index ca975ac2a..e6f938585 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2011.12.23 09:52} +\newcontextversion{2011.12.31 13:16} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new @@ -326,8 +326,6 @@ % \the\dimexpr(\dimchoice{11pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) % \the\dimexpr(\dimchoice{14pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) -\def\showsetupsdefinition[#1]{\showvalue{\??su:#1}} % temp hack for debugging - \def\tabulaterule % to be redone, not correct {\dotabulaterule {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax @@ -434,25 +432,6 @@ \setinnerparpositions % see "techniek" for application \to \everytabulate -\def\fontclassname#1#2% - {\ifcsname\??ff#1#2\endcsname - \fontclassname{#1}{\csname\??ff#1#2\endcsname}% - \else\ifcsname\??ff#2\endcsname - \fontclassname{#1}{\csname\??ff#2\endcsname}% - \else - #2% - \fi\fi} - -\def\defineclassfontsynonym - {\dotripleargument\dodefineclassfontsynonym} - -\def\dodefineclassfontsynonym[#1][#2][#3]% - {\definefontsynonym[#1][\fontclassname{#2}{#3}]} - -%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}] -% -%\defineclassfontsynonym [KopFont] [officina] [SerifBold] - \def\startcolumnmakeup % don't change {\bgroup \getrawnoflines\textheight % teksthoogte kan topskip hebben, dus raw diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index ffed26193..481fbd3e9 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index fca899a4d..cddb71cf5 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index e179ef31b..2140c36b3 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2011.12.23 09:52} +\edef\contextversion{2011.12.31 13:16} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index b68913a10..b608a1a59 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2011.12.23 09:52} +\edef\contextversion{2011.12.31 13:16} %D For those who want to use this: @@ -110,6 +110,7 @@ \loadmarkfile{mult-def} \loadmarkfile{mult-chk} \loadmarkfile{mult-aux} +\loadmkvifile{mult-dim} \loadmarkfile{cldf-int} % interface @@ -153,7 +154,7 @@ \loadmarkfile{supp-ran} \loadmarkfile{supp-mat} \loadmarkfile{supp-ali} -\loadmarkfile{supp-num} +\loadmarkfile{supp-num} % replaced \loadmarkfile{typo-ini} @@ -175,11 +176,11 @@ \loadmarkfile{unic-ini} -\loadmarkfile{core-gen} \loadmarkfile{core-uti} \loadmarkfile{core-two} \loadmarkfile{colo-ini} +\loadmarkfile{colo-grp} % optional \loadmarkfile{colo-ext} \loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented) @@ -224,9 +225,9 @@ \loadmarkfile{strc-reg} \loadmarkfile{strc-lev} % experiment +\loadmarkfile{spac-ali} \loadmarkfile{spac-hor} \loadmarkfile{spac-ver} -\loadmarkfile{spac-ali} \loadmarkfile{spac-pag} \loadmarkfile{spac-fnt} \loadmarkfile{spac-par} @@ -446,8 +447,8 @@ \loadmarkfile{back-pdf} % actually, this one should load the next three \loadmarkfile{mlib-pdf} \loadmarkfile{mlib-pps} -\loadmarkfile{grph-epd} \loadmarkfile{meta-pdf} +\loadmarkfile{grph-epd} \loadmarkfile{back-exp} diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv index 6bffc3f41..8db66a5fc 100644 --- a/tex/context/base/core-con.mkiv +++ b/tex/context/base/core-con.mkiv @@ -208,19 +208,17 @@ %D %D Anyhow, the conversion looks like: -\def\doconvertmonthlong #1{\ctxcommand{month(#1)}} -\def\doconvertmonthshort#1{\ctxcommand{monthmnem(#1)}} +\def\monthlong #1{\ctxcommand{month(#1)}} +\def\monthshort#1{\ctxcommand{monthmnem(#1)}} -\let\doconvertmonth\doconvertmonthlong +\let\convertmonth\monthlong % for old times sake %D We redefine the \TEX\ primitive \type{\month} as: %D %D \showsetup{month} %D \showsetup{MONTH} -\let\monthlong \doconvertmonthlong % was \def -\let\monthshort\doconvertmonthshort % was \def -\let\month \doconvertmonth % was \def +\let\month \monthlong \def\MONTH #1{\WORD{\month {#1}}} \def\MONTHLONG #1{\WORD{\monthlong {#1}}} @@ -237,23 +235,26 @@ %D \item exept years that can be divided by 100 %D \item unless years can be divided by 400 %D \stopitemize + +%D \macros +%D {weekday,WEEKDAY} %D -%D This makes the year 1900 into a normal year and 1996 and -%D 2000 into leap years, right? Well, converting to string -%D looks familiar: +%D The first one is sort of redundant. It takes the day +%D number argument. +%D +%D \showsetup{weekday} +%D \showsetup{WEEKDAY} -\def\doconvertday#1{\ctxcommand{day(#1)}} +\def\weekday#1{\ctxcommand{day(#1)}} +\def\WEEKDAY#1{\WORD{\weekday{#1}}} %D \macros %D {getdayoftheweek, dayoftheweek} \newcount\normalweekday -% \def\getdayoftheweek#1#2#3{\normalweekday\ctxcommand{weekday(\number#1,\number#2,\number#3)}} -% \def\dayoftheweek #1#2#3{\doconvertday{\ctxcommand{weekday(\number#1,\number#2,\number#3)}}} - -\def\getdayoftheweek#1#2#3{\normalweekday\ctxcommand{weekday(\number#1,\number#2,\number#3)}\relax} % number -\def\dayoftheweek #1#2#3{\ctxcommand{weekdayname(\number#1,\number#2,\number#3)}} % name + \def\dayoftheweek #1#2#3{\ctxcommand{weekdayname(\number#1,\number#2,\number#3)}} % name +\unexpanded\def\getdayoftheweek#1#2#3{\normalweekday\ctxcommand{weekday(\number#1,\number#2,\number#3)}\relax} % number %D Using this macro in %D @@ -279,31 +280,6 @@ %D The macro \type {\getdayoftheweek} can be used to calculate %D the number \type {\normalweekday}. -%D \macros -%D {weekday,WEEKDAY} -%D -%D The first one is sort of redundant. It takes the day -%D number argument. -%D -%D \showsetup{weekday} -%D \showsetup{WEEKDAY} - -\def\weekday - {\doconvertday} - -\def\WEEKDAY#1% - {\WORD{\doconvertday{#1}}} - -%D \macros -%D {weekoftheday} -%D -%D {\em not yet implemented:} -%D -%D \starttyping -%D \def\weekoftheday#1#2#3% -%D {} -%D \stoptyping - %D \macros %D {doifleapyearelse, %D getdayspermonth} @@ -327,7 +303,7 @@ \def\doifleapyearelse#1% {\ctxcommand{doifleapyearelse(\number#1)}} -\def\getdayspermonth#1#2% +\unexpanded\def\getdayspermonth#1#2% {\edef\numberofdays{\ctxcommand{nofdays(\number#1,\number#2)}}} \def\dayspermonth#1#2% @@ -439,9 +415,9 @@ \newtoks \everycurrentdate \unexpanded\def\currentdate - {\dosingleempty\docurrentdate} + {\dosingleempty\system_current_date} -\def\docurrentdate[#1]% +\def\system_current_date[#1]% {\begingroup \the\everycurrentdate \doifsomething{#1}{\edef\currentdatespecification{#1}}% @@ -449,9 +425,9 @@ \endgroup} \unexpanded\def\date - {\dodoubleempty\dodate} + {\dodoubleempty\system_date} -\def\dodate[#1][#2]% +\def\system_date[#1][#2]% {\begingroup \iffirstargument \getparameters[\??da][d=\normalday,m=\normalmonth,y=\normalyear,#1]% @@ -459,7 +435,7 @@ \normalmonth\@@dam\relax \normalyear \@@day\relax \fi - \docurrentdate[#2]% + \system_current_date[#2]% \endgroup} \def\rawdate[#1]% expandable and no labels @@ -479,17 +455,21 @@ \let\currenthour \!!plusone \let\currentminute\!!plusone +\let\currentsecond\!!plusone \def\currenttimespecification{h,:,m} -\def\complexcurrenttime[#1]% +\unexpanded\def\currenttime + {\doifnextoptionalelse\system_current_time_yes\system_current_time_nop} + + +\unexpanded\def\system_current_time_yes[#1]% {\calculatecurrenttime \processallactionsinset[#1][h=>\currenthour,m=>\currentminute,\s!unknown=>\commalistelement]} -\def\simplecurrenttime - {\expanded{\complexcurrenttime[\currenttimespecification]}} +\unexpanded\def\system_current_time_nop + {\normalexpanded{\system_current_time_yes[\currenttimespecification]}} -\definecomplexorsimple\currenttime %D Because we're dealing with dates, we also introduce a few %D day loops: @@ -502,10 +482,10 @@ %D The counters \type {\normalyear}, \type {\normalmonth} and %D \type{\normalday} can be used for for date manipulations. -\def\processmonth#1#2#3% year month command +\unexpanded\def\processmonth#1#2#3% year month command {\begingroup \getdayspermonth{#1}{#2}% - \dostepwiserecurse1\numberofdays1% + \dostepwiserecurse\plusone\numberofdays\plusone {\normalyear #1\relax \normalmonth#2\relax \normalday \recurselevel\relax @@ -514,7 +494,7 @@ \def\lastmonth{12} % can be set to e.g. 1 when testing -\def\processyear#1#2#3#4% year command before after +\unexpanded\def\processyear#1#2#3#4% year command before after {\begingroup \dorecurse\lastmonth {\normalyear #1\relax @@ -546,62 +526,69 @@ %D \defineconversion [en] [whatever] [\something] %D \stoptyping +\installcorenamespace {conversion} +\installcorenamespace {conversionarguments} +\installcorenamespace {conversionwords} + \unexpanded\def\defineconversion - {\dotripleempty\dodefineconversion} + {\dotripleempty\system_define_conversion} -\def\dodefineconversion[#1][#2][#3]% from now on global (maybe local again some day) +\def\system_define_conversion[#1][#2][#3]% from now on global (maybe local again some day) {\ifthirdargument - \dododefineconversion{#1#2}{#1:#2}{#3}% + \system_define_conversion_indeed{#1#2}{#1:#2}{#3}% \else - \dododefineconversion{#1}{#1}{#2}% + \system_define_conversion_indeed{#1}{#1}{#2}% \fi} -\def\dododefineconversion#1#2#3% +\def\system_define_conversion_indeed#1#2#3% {\doifinstringelse{,}{\detokenize{#3}} {\ctxcommand{defineconversion("#2",\!!bs\detokenize{#3}\!!es)}% - \setgvalue{\??cv#1}{\checkedconversion{#2}}} - {\setgvalue{\??cv#1}{#3}}} + \setgvalue{\??conversion#1}{\system_checked_conversion{#2}}} + {\setgvalue{\??conversion#1}{#3}}} -\def\checkedconversion#1#2% +\def\system_checked_conversion#1#2% {\ctxcommand{checkedconversion("#1",#2)}} %D If a conversion is just a font switch then we need to make sure %D that the number is indeed end up as number in the input, so we %D need to handle the second argument. -\def\convertnumber#1#2% - {\csname - \??cv=>% we want a fully expandable (no if interference) - \ifcsname\??cv\currentlanguage#1\endcsname1\else - \ifcsname\??cv #1\endcsname2\else - 3\fi\fi +\def\convertnumber#1#2% expandable + {\csname\??conversionarguments + \ifcsname\??conversion\currentlanguage#1\endcsname1\else + \ifcsname\??conversion #1\endcsname2\else + 3\fi\fi \endcsname{#1}{\number#2}} -\setvalue{\??cv=>1}#1{\csname\??cv\currentlanguage#1\endcsname} -\setvalue{\??cv=>2}#1{\csname\??cv #1\endcsname} -\letvalue{\??cv=>3}\checkedconversion +\setvalue{\??conversionarguments1}#1{\csname\??conversion\currentlanguage#1\endcsname} +\setvalue{\??conversionarguments2}#1{\csname\??conversion #1\endcsname} +\letvalue{\??conversionarguments3}\system_checked_conversion \def\doifconversiondefinedelse#1% - {\ifcsname\??cv\currentlanguage#1\endcsname + {\ifcsname\??conversion\currentlanguage#1\endcsname \expandafter\firstoftwoarguments - \else\ifcsname\??cv#1\endcsname + \else\ifcsname\??conversion#1\endcsname \doubleexpandafter\firstoftwoarguments \else \doubleexpandafter\secondoftwoarguments \fi\fi} -\def\doifelseconversionnumber#1#2% slow but seldom used - {\doifdefinedelse{\??cv#1#2}} +\def\doifelseconversionnumber#1#2% + {\ifcsname\??conversion#1#2\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} %D Handy. -\setvalue{\??cv:\c!n:\v!one }{1} -\setvalue{\??cv:\c!n:\v!two }{2} -\setvalue{\??cv:\c!n:\v!three}{3} -\setvalue{\??cv:\c!n:\v!four }{4} -\setvalue{\??cv:\c!n:\v!five }{5} +\setvalue{\??conversionwords\v!one }{1} +\setvalue{\??conversionwords\v!two }{2} +\setvalue{\??conversionwords\v!three}{3} +\setvalue{\??conversionwords\v!four }{4} +\setvalue{\??conversionwords\v!five }{5} -\def\wordtonumber#1#2{\ifcsname\??cv:\c!n:#1\endcsname\csname\??cv:\c!n:#1\endcsname\else#2\fi} +\def\wordtonumber#1#2{\ifcsname\??conversionwords#1\endcsname\csname\??conversionwords#1\endcsname\else#2\fi} % \defineconversion[ctx][c,o,n,t,e,x,t] % @@ -632,8 +619,8 @@ \defineconversion [\v!none] [\numbers] \defineconversion [\s!default] [\numbers] -\defineconversion [month] [\doconvertmonthlong] -\defineconversion [month:mnem] [\doconvertmonthshort] +\defineconversion [month] [\monthlong] +\defineconversion [month:mnem] [\monthshort] \defineconversion [\v!character] [\character] \defineconversion [\v!Character] [\Character] @@ -690,7 +677,6 @@ \defineconversion [persiannumerals] [\persiannumerals] \defineconversion [arabicexnumerals] [\arabicexnumerals] - \defineconversion [koreannumerals] [\koreannumerals] \defineconversion [koreanparentnumerals] [\koreanparentnumerals] \defineconversion [koreancirclenumerals] [\koreancirclenumerals] @@ -709,7 +695,7 @@ %D Symbol sets: -\ifx\symbol\undefined \def\symbol[#1]{#1} \fi % todo +\ifdefined\symbol \else \def\symbol[#1]{#1} \fi % todo \defineconversion [set 0] diff --git a/tex/context/base/core-ctx.mkiv b/tex/context/base/core-ctx.mkiv index 0595d0897..e178ee21b 100644 --- a/tex/context/base/core-ctx.mkiv +++ b/tex/context/base/core-ctx.mkiv @@ -19,10 +19,12 @@ \registerctxluafile{core-ctx}{1.000} -\def\loadctxpreplist{\ctxcommand{loadctxpreplist()}\global\let\loadctxpreplist\relax} +\def\loadctxpreplist + {\ctxcommand{loadctxpreplist()}% + \glet\loadctxpreplist\relax} -% \prependtoks\loadctxpreplist\to\everyjob - -\appendtoks\loadctxpreplist\to\everystarttext % maybe too late but don't change it now +\appendtoks + \loadctxpreplist +\to \everystarttext % maybe too late but don't change it now \protect \endinput diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv index e81f1e6b3..d2113539a 100644 --- a/tex/context/base/core-env.mkiv +++ b/tex/context/base/core-env.mkiv @@ -40,11 +40,12 @@ %D level style does not want that. Preventing can be %D considered a permanent disabling on forehand. -\def\@mode@{@md@} -\def\@mode@{mode} - \def\systemmodeprefix{*} +% we will have \installcorenamespace{mode} but need some hackery at the lua end then + +\installcorenamespace{modestack} + % todo: check prevent mode, also at the lua end \setnewconstant\disabledmode \zerocount @@ -53,42 +54,42 @@ % fast internal ones -\def\donewmode#1% - {\@EA\newcount\csname\@mode@#1\endcsname} +\def\system_modes_new#1% + {\expandafter\newcount\csname\s!mode#1\endcsname} -\def\newmode#1% - {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi} +\unexpanded\def\newmode#1% + {\ifcsname\s!mode#1\endcsname\else\system_modes_new{#1}\fi} -\def\setmode#1% - {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi - \csname\@mode@#1\endcsname\enabledmode} +\unexpanded\def\setmode#1% + {\ifcsname\s!mode#1\endcsname\else\system_modes_new{#1}\fi + \csname\s!mode#1\endcsname\enabledmode} -\def\resetmode#1% - {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi - \csname\@mode@#1\endcsname\disabledmode} +\unexpanded\def\resetmode#1% + {\ifcsname\s!mode#1\endcsname\else\system_modes_new{#1}\fi + \csname\s!mode#1\endcsname\disabledmode} -\def\newsystemmode#1% - {\ifcsname\@mode@\systemmodeprefix#1\endcsname\else\donewmode{\systemmodeprefix#1}\fi} +\unexpanded\def\newsystemmode#1% + {\ifcsname\s!mode\systemmodeprefix#1\endcsname\else\system_modes_new{\systemmodeprefix#1}\fi} -\def\setsystemmode#1% - {\ifcsname\@mode@\systemmodeprefix#1\endcsname\else\donewmode{\systemmodeprefix#1}\fi - \csname\@mode@\systemmodeprefix#1\endcsname\enabledmode} +\unexpanded\def\setsystemmode#1% + {\ifcsname\s!mode\systemmodeprefix#1\endcsname\else\system_modes_new{\systemmodeprefix#1}\fi + \csname\s!mode\systemmodeprefix#1\endcsname\enabledmode} -\def\resetsystemmode#1% - {\ifcsname\@mode@\systemmodeprefix#1\endcsname\else\donewmode{\systemmodeprefix#1}\fi - \csname\@mode@\systemmodeprefix#1\endcsname\disabledmode} +\unexpanded\def\resetsystemmode#1% + {\ifcsname\s!mode\systemmodeprefix#1\endcsname\else\system_modes_new{\systemmodeprefix#1}\fi + \csname\s!mode\systemmodeprefix#1\endcsname\disabledmode} % \def\dosetsystemmode#1% -% {\csname\@mode@\systemmodeprefix#1\endcsname\enabledmode} +% {\csname\s!mode\systemmodeprefix#1\endcsname\enabledmode} % % \def\doresetsystemmode#1% -% {\csname\@mode@\systemmodeprefix#1\endcsname\disabledmode} +% {\csname\s!mode\systemmodeprefix#1\endcsname\disabledmode} % demo: trialtypesetting is a systemmode as well as an if -\newsystemmode{trialtypesetting} +\newsystemmode{trialtypesetting} % the name of \@@trialtypesetting might change (also at the lua end) -\expandafter\let\expandafter\@@trialtypesetting\csname\@mode@\systemmodeprefix trialtypesetting\endcsname % private ! +\expandafter\let\expandafter\@@trialtypesetting\csname\s!mode\systemmodeprefix trialtypesetting\endcsname % private ! \appendtoks \@@trialtypesetting\enabledmode @@ -100,133 +101,122 @@ % user ones -\unexpanded\def\preventmode{\unprotect\dopreventmode} -\unexpanded\def\enablemode {\unprotect\doenablemode } -\unexpanded\def\disablemode{\unprotect\dodisablemode} +\unexpanded\def\preventmode{\unprotect\system_modes_prevent} +\unexpanded\def\enablemode {\unprotect\system_modes_enable } +\unexpanded\def\disablemode{\unprotect\system_modes_disable} \let\definemode\disablemode % nicer -\def\dopreventmode[#1]{\protect\rawprocesscommacommand[#1]\dodopreventmode} -\def\doenablemode [#1]{\protect\rawprocesscommacommand[#1]\dodoenablemode } -\def\dodisablemode[#1]{\protect\rawprocesscommacommand[#1]\dododisablemode} +\def\system_modes_prevent[#1]{\protect\rawprocesscommacommand[#1]\system_modes_prevent_indeed} +\def\system_modes_enable [#1]{\protect\rawprocesscommacommand[#1]\system_modes_enable_indeed } +\def\system_modes_disable[#1]{\protect\rawprocesscommacommand[#1]\system_modes_disable_indeed} -\def\dodopreventmode#1% - {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi - \csname\@mode@#1\endcsname\preventedmode} +\def\system_modes_prevent_indeed#1% + {\ifcsname\s!mode#1\endcsname\else\system_modes_new{#1}\fi + \csname\s!mode#1\endcsname\preventedmode} -\def\dodoenablemode#1% we can speed it up by moving the new outside - {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi - \ifnum\csname\@mode@#1\endcsname=\preventedmode \else - \csname\@mode@#1\endcsname\enabledmode +\def\system_modes_enable_indeed#1% we can speed it up by moving the new outside + {\ifcsname\s!mode#1\endcsname\else\system_modes_new{#1}\fi + \ifnum\csname\s!mode#1\endcsname=\preventedmode \else + \csname\s!mode#1\endcsname\enabledmode \fi} -\def\dododisablemode#1% - {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi - \ifnum\csname\@mode@#1\endcsname=\preventedmode \else - \csname\@mode@#1\endcsname\disabledmode +\def\system_modes_disable_indeed#1% + {\ifcsname\s!mode#1\endcsname\else\system_modes_new{#1}\fi + \ifnum\csname\s!mode#1\endcsname=\preventedmode \else + \csname\s!mode#1\endcsname\disabledmode \fi} % handy for mp \def\booleanmodevalue#1% - {\ifcsname\@mode@#1\endcsname\ifcase\csname\@mode@#1\endcsname fals\else tru\fi\else fals\fi e} + {\ifcsname\s!mode#1\endcsname\ifcase\csname\s!mode#1\endcsname\s!false\else\s!true\fi\else\s!false\fi} % check macros -\newif\ifcheckedmode - -\def\dodocheckformode#1% - {\ifcsname\@mode@#1\endcsname\ifcase\csname\@mode@#1\endcsname\else\checkedmodetrue\fi\fi} - -\def\docheckformode#1#2#3% will be sped up with a quit - {\protect\checkedmodefalse\rawprocesscommacommand[#3]\dodocheckformode - \ifcheckedmode\@EA#1\else\@EA#2\fi} - -\def\dodocheckforallmodes#1% - {\ifcsname\@mode@#1\endcsname\ifcase\csname\@mode@#1\endcsname\checkedmodefalse\fi\else\checkedmodefalse\fi} - -\def\docheckforallmodes#1#2#3% will be sped up with a quit - {\protect\checkedmodetrue\rawprocesscommacommand[#3]\dodocheckforallmodes - \ifcheckedmode\@EA#1\else\@EA#2\fi} - -% simple ones - -\unexpanded\def\doifmodeelse{\unprotect\dodoifmodeelse} -\unexpanded\def\doifmode {\unprotect\dodoifmode} -\unexpanded\def\doifnotmode {\unprotect\dodoifnotmode} -\unexpanded\def\startmode {\unprotect\dostartmode} -\unexpanded\def\startnotmode{\unprotect\dostartnotmode} - -\def\dodoifmodeelse - {\docheckformode\firstoftwoarguments\secondoftwoarguments} - -\def\dodoifmode - {\docheckformode\firstofoneargument\gobbleoneargument} +% For some reason the older version had an unprotect for grabbing the +% mode list (only) which does not really make sense any more so that +% has been removed. One should (un)protect at the outer level instead. -\def\dodoifnotmode - {\docheckformode\gobbleoneargument\firstofoneargument} +\newconditional\c_checked_mode -\unexpanded\def\dostartmode[#1]% - {\docheckformode\donothing\dostopmode{#1}} - -\def\dostartnotmode[#1]% - {\docheckformode\dostopnotmode\donothing{#1}} - -\unexpanded\def\stopmode {} % no relax -\unexpanded\def\stopnotmode{} % no relax - -\def\dostopmode #1\stopmode {} -\def\dostopnotmode#1\stopnotmode{} - -\unexpanded\def\doifallmodeselse{\unprotect\dodoifallmodeselse} -\unexpanded\def\doifallmodes {\unprotect\dodoifallmodes} -\unexpanded\def\doifnotallmodes {\unprotect\dodoifnotallmodes} -\unexpanded\def\startallmodes {\unprotect\dostartallmodes} -\unexpanded\def\startnotallmodes{\unprotect\dostartnotallmodes} - -\def\dodoifallmodeselse - {\docheckforallmodes\firstoftwoarguments\secondoftwoarguments} - -\def\dodoifallmodes - {\docheckforallmodes\firstofoneargument\gobbleoneargument} - -\def\dodoifnotallmodes - {\docheckforallmodes\gobbleoneargument\firstofoneargument} +\def\system_modes_check_indeed#1% + {\ifcsname\s!mode#1\endcsname + \ifcase\csname\s!mode#1\endcsname\else + \let\system_modes_check_step\gobbleoneargument + \fi + \fi} -\def\dostartallmodes[#1]% - {\docheckforallmodes\donothing\dostopallmodes{#1}} +\def\system_modes_check#1#2#3% + {\let\system_modes_check_step\system_modes_check_indeed + \rawprocesscommacommand[#3]\system_modes_check_step + \ifx\system_modes_check_step\gobbleoneargument + \expandafter#1% + \else + \expandafter#2% + \fi} -\def\dostartnotallmodes[#1]% - {\docheckforallmodes\dostopnotallmodes\donothing{#1}} +\def\system_modes_check_all_indeed#1% + {\ifcsname\s!mode#1\endcsname + \ifcase\csname\s!mode#1\endcsname + \let\system_modes_check_all_step\gobbleoneargument + \fi + \else + \let\system_modes_check_all_step\gobbleoneargument + \fi} -\unexpanded\def\stopallmodes {} % no relax -\unexpanded\def\stopnotallmodes{} % no relax +\def\system_modes_check_all#1#2#3% + {\let\system_modes_check_all_step\system_modes_check_all_indeed + \rawprocesscommacommand[#3]\system_modes_check_all_step + \ifx\system_modes_check_all_step\gobbleoneargument + \expandafter#2 + \else + \expandafter#1 + \fi} -\def\dostopallmodes #1\stopallmodes {} -\def\dostopnotallmodes#1\stopnotallmodes{} +\unexpanded\def\doifmodeelse {\system_modes_check\firstoftwoarguments\secondoftwoarguments} +\unexpanded\def\doifmode {\system_modes_check\firstofoneargument\gobbleoneargument} +\unexpanded\def\doifnotmode {\system_modes_check\gobbleoneargument\firstofoneargument} +\unexpanded\def\startmode [#1]{\system_modes_check\donothing\system_modes_stop_yes{#1}} +\unexpanded\def\startnotmode [#1]{\system_modes_check\system_modes_stop_nop\donothing{#1}} +\unexpanded\def\doifallmodeselse {\system_modes_check_all\firstoftwoarguments\secondoftwoarguments} +\unexpanded\def\doifallmodes {\system_modes_check_all\firstofoneargument\gobbleoneargument} +\unexpanded\def\doifnotallmodes {\system_modes_check_all\gobbleoneargument\firstofoneargument} +\unexpanded\def\startallmodes [#1]{\system_modes_check_all\donothing\system_modes_stop_all_yes{#1}} +\unexpanded\def\startnotallmodes[#1]{\system_modes_check_all\system_modes_stop_all_nop\donothing{#1}} + +\unexpanded\def\stopmode {} % no relax +\unexpanded\def\stopnotmode {} % no relax +\unexpanded\def\stopallmodes {} % no relax +\unexpanded\def\stopnotallmodes {} % no relax + +\def\system_modes_stop_yes #1\stopmode {} +\def\system_modes_stop_nop #1\stopnotmode {} +\def\system_modes_stop_all_yes#1\stopallmodes {} +\def\system_modes_stop_all_nop#1\stopnotallmodes{} %D Pushing/popping: \unexpanded\def\pushmode[#1]% - {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi - \expandafter\edef\csname\@mode@:#1\endcsname{\number\csname\@mode@#1\endcsname}% - \expandafter\pushmacro\csname\@mode@:#1\endcsname} + {\ifcsname\s!mode#1\endcsname\else\system_modes_new{#1}\fi + \expandafter\edef\csname\??modestack#1\endcsname{\number\csname\s!mode#1\endcsname}% + \expandafter\pushmacro\csname\??modestack#1\endcsname} \unexpanded\def\popmode[#1]% - {\ifcsname\@mode@:#1\endcsname - \expandafter\popmacro\csname\@mode@:#1\endcsname - \csname\@mode@#1\endcsname\csname\@mode@:#1\endcsname\relax + {\ifcsname\??modestack#1\endcsname + \expandafter\popmacro\csname\??modestack#1\endcsname + \csname\s!mode#1\endcsname\csname\??modestack#1\endcsname\relax \fi} \def\pushsystemmode#1% - {\ifcsname\@mode@\systemmodeprefix#1\endcsname\else\donewmode{\systemmodeprefix#1}\fi - \expandafter\edef\csname\@mode@:\systemmodeprefix#1\endcsname{\number\csname\@mode@\systemmodeprefix#1\endcsname}% - \expandafter\pushmacro\csname\@mode@:\systemmodeprefix#1\endcsname} + {\ifcsname\s!mode\systemmodeprefix#1\endcsname\else\system_modes_new{\systemmodeprefix#1}\fi + \expandafter\edef\csname\??modestack\systemmodeprefix#1\endcsname{\number\csname\s!mode\systemmodeprefix#1\endcsname}% + \expandafter\pushmacro\csname\??modestack\systemmodeprefix#1\endcsname} \def\popsystemmode#1% - {\ifcsname\@mode@:\systemmodeprefix#1\endcsname - \expandafter\popmacro\csname\@mode@:\systemmodeprefix#1\endcsname - \csname\@mode@\systemmodeprefix#1\endcsname\csname\@mode@:\systemmodeprefix#1\endcsname\relax + {\ifcsname\??modestack\systemmodeprefix#1\endcsname + \expandafter\popmacro\csname\??modestack\systemmodeprefix#1\endcsname + \csname\s!mode\systemmodeprefix#1\endcsname\csname\??modestack\systemmodeprefix#1\endcsname\relax \fi} %D Lets now set a mode: @@ -235,38 +225,40 @@ %D Setups: +\installcorenamespace{setup} % we can probably get rid of some :'s later on + \unexpanded\def\startsetups{} % to please dep checker \unexpanded\def\stopsetups {} % to please dep checker \expanded % will become obsolete - {\def\@EA\noexpand\csname\e!start\v!setups\endcsname + {\def\expandafter\noexpand\csname\e!start\v!setups\endcsname {\begingroup\noexpand\doifnextoptionalelse - {\noexpand\dostartsetupsA\@EA\noexpand\csname\e!stop\v!setups\endcsname} - {\noexpand\dostartsetupsB\@EA\noexpand\csname\e!stop\v!setups\endcsname}}} + {\noexpand\dostartsetupsA\expandafter\noexpand\csname\e!stop\v!setups\endcsname} + {\noexpand\dostartsetupsB\expandafter\noexpand\csname\e!stop\v!setups\endcsname}}} \letvalue{\e!stop\v!setups}\relax -\unexpanded\def\setups{\doifnextbgroupelse\dosetupsA\dosetupsB} % {..} or [..] -\unexpanded\def\setup {\doifnextbgroupelse\dosetups \dosetupsC} % {..} or [..] +\unexpanded\def\setups{\doifnextbgroupelse\system_setups_a\system_setups_b} % {..} or [..] +\unexpanded\def\setup {\doifnextbgroupelse\system_setups \system_setups_c} % {..} or [..] -\def\dosetupsA #1{\processcommacommand[#1]\dosetups} % {..} -\def\dosetupsB[#1]{\processcommacommand[#1]\dosetups} % [..] -\def\dosetupsC[#1]{\dosetups{#1}} % [..] +\def\system_setups_a #1{\processcommacommand[#1]\system_setups} % {..} +\def\system_setups_b[#1]{\processcommacommand[#1]\system_setups} % [..] +\def\system_setups_c[#1]{\system_setups{#1}} % [..] -\letvalue{\??su:\letterpercent}\gobbleoneargument +\letvalue{\??setup:\letterpercent}\gobbleoneargument -\def\dosetups#1% the grid option will be extended to other main modes - {\csname\??su +\def\system_setups#1% the grid option will be extended to other main modes + {\csname\??setup \ifgridsnapping - \ifcsname\??su\v!grid:#1\endcsname\v!grid:#1\else\ifcsname\??su:#1\endcsname:#1\else:\letterpercent\fi\fi + \ifcsname\??setup\v!grid:#1\endcsname\v!grid:#1\else\ifcsname\??setup:#1\endcsname:#1\else:\letterpercent\fi\fi \else - \ifcsname\??su:#1\endcsname:#1\else:\letterpercent\fi + \ifcsname\??setup:#1\endcsname:#1\else:\letterpercent\fi \fi \endcsname\empty} % takes one argument % We can consider: % -% \setvalue{\??su->\v!auto}#1{\ctxcommand{autosetup("#1")}} +% \setvalue{\??setup->\v!auto}#1{\ctxcommand{autosetup("#1")}} % % ":\letterpercent" => "->\v!auto" with "\endcsname{#1}" % @@ -283,7 +275,7 @@ \fi} % \def\dodoprocesslocalsetups -% {\@EA\processcommalist\@EA[\tobeprocessedsetups]\dosetups} +% {\expandafter\processcommalist\expandafter[\tobeprocessedsetups]\system_setups} % setups=S1 % setups=lua(S2) @@ -297,13 +289,17 @@ {\ctxcommand{autosetups("#1")}} \edef\setupwithargument#1% saves a few expansions - {\noexpand\csname\??su:\noexpand\ifcsname\??su:#1\endcsname#1\noexpand\else\letterpercent\noexpand\fi\endcsname} + {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#1\endcsname#1\noexpand\else\letterpercent\noexpand\fi\endcsname} -\let\directsetup\dosetups -\let\texsetup \dosetups % nicer than \directsetup and more en par with xmlsetup and luasetup +\let\directsetup\system_setups +\let\texsetup \system_setups % nicer than \directsetup and more en par with xmlsetup and luasetup \def\doifsetupselse#1% to be done: grid - {\doifdefinedelse{\??su:#1}} % doto: ifcsname + {\ifcsname\??setup:#1\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} % \startluasetups oeps % context("DONE") @@ -337,33 +333,35 @@ % % \ctxluabuffer -\newtoks\everydefinesetups \appendtoks +\newtoks\t_system_setups_tex \appendtoks \catcode\endoflineasciicode \ignorecatcode -\to \everydefinesetups +\to \t_system_setups_tex -\newtoks\everydefinelocalsetups \appendtoks +\newtoks\t_system_setups_loc \appendtoks \catcode\endoflineasciicode \ignorecatcode -\to \everydefinelocalsetups +\to \t_system_setups_loc -\newtoks\everydefinerawsetups \appendtoks +\newtoks\t_system_setups_raw \appendtoks % nothing -\to \everydefinerawsetups +\to \t_system_setups_raw -\newtoks\everydefinexmlsetups \appendtoks +\newtoks\t_system_setups_xml \appendtoks \catcode\endoflineasciicode\ignorecatcode \catcode\barasciicode \othercatcode -\to \everydefinexmlsetups +\to \t_system_setups_xml -\newtoks\everydefineluasetups \appendtoks +\newtoks\t_system_setups_lua \appendtoks \obeylualines \obeyluatokens -\to \everydefineluasetups +\to \t_system_setups_lua -\unexpanded\def\startluasetups {\begingroup\doifnextoptionalelse\dostartluasetupsA \dostartluasetupsB } -\unexpanded\def\startxmlsetups {\begingroup\doifnextoptionalelse\dostartxmlsetupsA \dostartxmlsetupsB } -\unexpanded\def\startrawsetups {\begingroup\doifnextoptionalelse\dostartrawsetupsA \dostartrawsetupsB } -\unexpanded\def\startlocalsetups{\begingroup\doifnextoptionalelse\dostartlocalsetupsA\dostartlocalsetupsB} -\unexpanded\def\startsetups {\begingroup\doifnextoptionalelse\dostartsetupsA \dostartsetupsB } +% Is doglobal still relevant? Maybe always global? Or never? Anyway, it will become obsolete. + +\unexpanded\def\startluasetups {\begingroup\doifnextoptionalelse\system_setups_start_lua_a\system_setups_start_lua_b} +\unexpanded\def\startxmlsetups {\begingroup\doifnextoptionalelse\system_setups_start_xml_a\system_setups_start_xml_b} +\unexpanded\def\startrawsetups {\begingroup\doifnextoptionalelse\system_setups_start_raw_a\system_setups_start_raw_b} +\unexpanded\def\startlocalsetups{\begingroup\doifnextoptionalelse\system_setups_start_loc_a\system_setups_start_loc_b} +\unexpanded\def\startsetups {\begingroup\doifnextoptionalelse\system_setups_start_tex_a\system_setups_start_tex_b} \let\stopluasetups \relax \let\stopxmlsetups \relax @@ -371,59 +369,62 @@ \let\stoplocalsetups \relax \let\stopsetups \relax -\def\dodostartluasetups #1#2#3\stopluasetups {\endgroup\dodoglobal\@EA\def\csname\??su#1:#2\@EA\endcsname\@EA##\@EA1\@EA{#3}} -\def\dodostartxmlsetups #1#2#3\stopxmlsetups {\endgroup\dodoglobal\@EA\def\csname\??su#1:#2\@EA\endcsname\@EA##\@EA1\@EA{#3}} -\def\dodostartrawsetups #1#2#3\stoprawsetups {\endgroup\dodoglobal\@EA\def\csname\??su#1:#2\@EA\endcsname\@EA##\@EA1\@EA{#3}} -\def\dodostartlocalsetups #1#2#3\stoplocalsetups{\endgroup\dodoglobal\@EA\def\csname\??su#1:#2\@EA\endcsname\@EA##\@EA1\@EA{#3}} -\def\dodostartsetups #1#2#3\stopsetups {\endgroup\dodoglobal\@EA\def\csname\??su#1:#2\@EA\endcsname\@EA##\@EA1\@EA{#3}} - -\def\dostartluasetups {\ifsecondargument\@EA\dostartluasetupsC \else\@EA\dostartluasetupsD \fi} -\def\dostartxmlsetups {\ifsecondargument\@EA\dostartxmlsetupsC \else\@EA\dostartxmlsetupsD \fi} -\def\dostartrawsetups {\ifsecondargument\@EA\dostartrawsetupsC \else\@EA\dostartrawsetupsD \fi} -\def\dostartlocalsetups {\ifsecondargument\@EA\dostartlocalsetupsC\else\@EA\dostartlocalsetupsD\fi} -\def\dostartsetups {\ifsecondargument\@EA\dostartsetupsC \else\@EA\dostartsetupsD \fi} - -\def\dostartluasetupsA {\the\everydefineluasetups \dodoubleempty\dostartluasetups} % [ ] delimited -\def\dostartxmlsetupsA {\the\everydefinexmlsetups \dodoubleempty\dostartxmlsetups} % [ ] delimited -\def\dostartrawsetupsA {\the\everydefinerawsetups \dodoubleempty\dostartrawsetups} % [ ] delimited -\def\dostartlocalsetupsA {\the\everydefinelocalsetups\dodoubleempty\dostartlocalsetups} % [ ] delimited -\def\dostartsetupsA {\the\everydefinesetups \dodoubleempty\dostartsetups} % [ ] delimited - -% empty preserves inner {} (is removed by the \@EA{#3}) - -\def\dostartluasetupsB #1 {\the\everydefineluasetups \dodostartluasetups \empty{#1}\empty} % space delimited -\def\dostartxmlsetupsB #1 {\the\everydefinexmlsetups \dodostartxmlsetups \empty{#1}\empty} % space delimited -\def\dostartrawsetupsB #1 {\the\everydefinerawsetups \dodostartrawsetups \empty{#1}\empty} % space delimited -\def\dostartlocalsetupsB #1 {\the\everydefinelocalsetups\dodostartlocalsetups\empty{#1}\empty} % space delimited -\def\dostartsetupsB #1 {\the\everydefinesetups \dodostartsetups \empty{#1}\empty} % space delimited - -\def\dostartluasetupsC [#1][#2]{\the\everydefineluasetups \dodostartluasetups {#1}{#2}\empty} % [..] [..] -\def\dostartxmlsetupsC [#1][#2]{\the\everydefinexmlsetups \dodostartxmlsetups {#1}{#2}\empty} % [..] [..] -\def\dostartrawsetupsC [#1][#2]{\the\everydefinerawsetups \dodostartrawsetups {#1}{#2}\empty} % [..] [..] -\def\dostartlocalsetupsC[#1][#2]{\the\everydefinelocalsetups\dodostartlocalsetups{#1}{#2}\empty} % [..] [..] -\def\dostartsetupsC [#1][#2]{\the\everydefinesetups \dodostartsetups {#1}{#2}\empty} % [..] [..] - -\def\dostartluasetupsD [#1][#2]{\the\everydefineluasetups \dodostartluasetups \empty{#1}\empty} % [..] -\def\dostartxmlsetupsD [#1][#2]{\the\everydefinexmlsetups \dodostartxmlsetups \empty{#1}\empty} % [..] -\def\dostartrawsetupsD [#1][#2]{\the\everydefinerawsetups \dodostartrawsetups \empty{#1}\empty} % [..] -\def\dostartlocalsetupsD[#1][#2]{\the\everydefinelocalsetups\dodostartlocalsetups\empty{#1}\empty} % [..] -\def\dostartsetupsD [#1][#2]{\the\everydefinesetups \dodostartsetups \empty{#1}\empty} % [..] - -\def\luasetup#1{\ctxlua{\dosetups{#1}}} +\def\system_setups_start_lua_indeed#1#2#3\stopluasetups {\endgroup\dodoglobal\expandafter\def\csname\??setup#1:#2\expandafter\endcsname\expandafter##\expandafter1\expandafter{#3}} +\def\system_setups_start_xml_indeed#1#2#3\stopxmlsetups {\endgroup\dodoglobal\expandafter\def\csname\??setup#1:#2\expandafter\endcsname\expandafter##\expandafter1\expandafter{#3}} +\def\system_setups_start_raw_indeed#1#2#3\stoprawsetups {\endgroup\dodoglobal\expandafter\def\csname\??setup#1:#2\expandafter\endcsname\expandafter##\expandafter1\expandafter{#3}} +\def\system_setups_start_loc_indeed#1#2#3\stoplocalsetups{\endgroup\dodoglobal\expandafter\def\csname\??setup#1:#2\expandafter\endcsname\expandafter##\expandafter1\expandafter{#3}} +\def\system_setups_start_tex_indeed#1#2#3\stopsetups {\endgroup\dodoglobal\expandafter\def\csname\??setup#1:#2\expandafter\endcsname\expandafter##\expandafter1\expandafter{#3}} + +\def\system_setups_start_lua{\ifsecondargument\expandafter\system_setups_start_lua_c\else\expandafter\system_setups_start_lua_d\fi} +\def\system_setups_start_xml{\ifsecondargument\expandafter\system_setups_start_xml_c\else\expandafter\system_setups_start_xml_d\fi} +\def\system_setups_start_raw{\ifsecondargument\expandafter\system_setups_start_raw_c\else\expandafter\system_setups_start_raw_d\fi} +\def\system_setups_start_loc{\ifsecondargument\expandafter\system_setups_start_loc_c\else\expandafter\system_setups_start_loc_d\fi} +\def\system_setups_start_tex{\ifsecondargument\expandafter\system_setups_start_tex_c\else\expandafter\system_setups_start_tex_d\fi} + +\def\system_setups_start_lua_a{\the\t_system_setups_lua\dodoubleempty\system_setups_start_lua} % [ ] delimited +\def\system_setups_start_xml_a{\the\t_system_setups_xml\dodoubleempty\system_setups_start_xml} % [ ] delimited +\def\system_setups_start_raw_a{\the\t_system_setups_raw\dodoubleempty\system_setups_start_raw} % [ ] delimited +\def\system_setups_start_loc_a{\the\t_system_setups_loc\dodoubleempty\system_setups_start_loc} % [ ] delimited +\def\system_setups_start_tex_a{\the\t_system_setups_tex\dodoubleempty\system_setups_start_tex} % [ ] delimited + +% empty preserves inner {} (is removed by the \expandafter{#3}) + +\def\system_setups_start_lua_b#1 {\the\t_system_setups_lua\system_setups_start_lua_indeed\empty{#1}\empty} % space delimited +\def\system_setups_start_xml_b#1 {\the\t_system_setups_xml\system_setups_start_xml_indeed\empty{#1}\empty} % space delimited +\def\system_setups_start_raw_b#1 {\the\t_system_setups_raw\system_setups_start_raw_indeed\empty{#1}\empty} % space delimited +\def\system_setups_start_loc_b#1 {\the\t_system_setups_loc\system_setups_start_loc_indeed\empty{#1}\empty} % space delimited +\def\system_setups_start_tex_b#1 {\the\t_system_setups_tex\system_setups_start_tex_indeed\empty{#1}\empty} % space delimited + +\def\system_setups_start_lua_c[#1][#2]{\the\t_system_setups_lua\system_setups_start_lua_indeed{#1}{#2}\empty} % [..] [..] +\def\system_setups_start_xml_c[#1][#2]{\the\t_system_setups_xml\system_setups_start_xml_indeed{#1}{#2}\empty} % [..] [..] +\def\system_setups_start_raw_c[#1][#2]{\the\t_system_setups_raw\system_setups_start_raw_indeed{#1}{#2}\empty} % [..] [..] +\def\system_setups_start_loc_c[#1][#2]{\the\t_system_setups_loc\system_setups_start_loc_indeed{#1}{#2}\empty} % [..] [..] +\def\system_setups_start_tex_c[#1][#2]{\the\t_system_setups_tex\system_setups_start_tex_indeed{#1}{#2}\empty} % [..] [..] + +\def\system_setups_start_lua_d[#1][#2]{\the\t_system_setups_lua\system_setups_start_lua_indeed\empty{#1}\empty} % [..] +\def\system_setups_start_xml_d[#1][#2]{\the\t_system_setups_xml\system_setups_start_xml_indeed\empty{#1}\empty} % [..] +\def\system_setups_start_raw_d[#1][#2]{\the\t_system_setups_raw\system_setups_start_raw_indeed\empty{#1}\empty} % [..] +\def\system_setups_start_loc_d[#1][#2]{\the\t_system_setups_loc\system_setups_start_loc_indeed\empty{#1}\empty} % [..] +\def\system_setups_start_tex_d[#1][#2]{\the\t_system_setups_tex\system_setups_start_tex_indeed\empty{#1}\empty} % [..] + +\def\luasetup#1{\ctxlua{\system_setups{#1}}} % % % % \def\systemsetupsprefix{*} -\def\systemsetups#1{\dosetups{\systemsetupsprefix#1}} +\def\systemsetups#1{\system_setups{\systemsetupsprefix#1}} \def\resetsetups[#1]% see x-fo for usage - {\ifcsname\??su\ifgridsnapping\v!grid\fi:#1\endcsname - \dodoglobal\letbeundefined{\??su\ifgridsnapping\v!grid\fi:#1}% + {\ifcsname\??setup\ifgridsnapping\v!grid\fi:#1\endcsname + \dodoglobal\letbeundefined{\??setup\ifgridsnapping\v!grid\fi:#1}% \else - \dodoglobal\letbeundefined{\??su:#1}% + \dodoglobal\letbeundefined{\??setup:#1}% \fi} - + +\def\showsetupsdefinition[#1]% + {\showvalue{\??setup:#1}} % temp hack for debugging + %D \macros %D {setvariables,getvariable,getvariabledefault} %D @@ -436,40 +437,40 @@ %D \setvariables[xx][titletitel=e] %D \stoptyping -\def\??vars{@@vars} +\installcorenamespace{variables} -\unexpanded\def\setvariables {\dotripleargument\dosetvariables[\getrawparameters ]} -\unexpanded\def\setevariables{\dotripleargument\dosetvariables[\getraweparameters]} -\unexpanded\def\setgvariables{\dotripleargument\dosetvariables[\getrawgparameters]} -\unexpanded\def\setxvariables{\dotripleargument\dosetvariables[\getrawxparameters]} +\unexpanded\def\setvariables {\dotripleargument\system_variables_set[\getrawparameters ]} +\unexpanded\def\setevariables{\dotripleargument\system_variables_set[\getraweparameters]} +\unexpanded\def\setgvariables{\dotripleargument\system_variables_set[\getrawgparameters]} +\unexpanded\def\setxvariables{\dotripleargument\system_variables_set[\getrawxparameters]} \unexpanded\def\globalsetvariables % obsolete - {\dotripleargument\dosetvariables[\globalgetrawparameters]} + {\dotripleargument\system_variables_set[\globalgetrawparameters]} -\def\dosetvariables[#1][#2][#3]% tricky, test on s-pre-60 +\def\system_variables_set[#1][#2][#3]% tricky, test on s-pre-60 {\errorisfataltrue \doifelse{#2}\currentvariableclass - {#1[\??vars:#2:][#3]}% + {#1[\??variables#2:][#3]}% {\pushmacro\currentvariableclass \def\currentvariableclass{#2}% \getvariable{#2}\s!reset - #1[\??vars:#2:][#3]% + #1[\??variables#2:][#3]% \getvariable{#2}\s!set \popmacro\currentvariableclass}% \errorisfatalfalse} -\unexpanded\def\setvariable #1#2#3{\expandafter\def \csname\??vars:#1:#2\endcsname{#3}} -\unexpanded\def\setevariable#1#2#3{\expandafter\edef\csname\??vars:#1:#2\endcsname{#3}} -\unexpanded\def\setgvariable#1#2#3{\expandafter\gdef\csname\??vars:#1:#2\endcsname{#3}} -\unexpanded\def\setxvariable#1#2#3{\expandafter\xdef\csname\??vars:#1:#2\endcsname{#3}} +\unexpanded\def\setvariable #1#2#3{\expandafter\def \csname\??variables#1:#2\endcsname{#3}} +\unexpanded\def\setevariable#1#2#3{\expandafter\edef\csname\??variables#1:#2\endcsname{#3}} +\unexpanded\def\setgvariable#1#2#3{\expandafter\gdef\csname\??variables#1:#2\endcsname{#3}} +\unexpanded\def\setxvariable#1#2#3{\expandafter\xdef\csname\??variables#1:#2\endcsname{#3}} \def\getvariable#1#2% {\csname - \ifcsname\??vars:#1:#2\endcsname\??vars:#1:#2\else\s!empty\fi + \ifcsname\??variables#1:#2\endcsname\??variables#1:#2\else\s!empty\fi \endcsname} \def\showvariable#1#2% - {\showvalue{\ifcsname\??vars:#1:#2\endcsname\??vars:#1:#2\else\s!empty\fi}} + {\showvalue{\ifcsname\??variables#1:#2\endcsname\??variables#1:#2\else\s!empty\fi}} \let\currentvariableclass\empty @@ -478,20 +479,22 @@ %D %D I'll probably forget that this on exists. +\let\m_system_variables_temp\empty + \def\checkvariables - {\dodoubleargument\docheckvariables} + {\dodoubleargument\system_variables_check} -\def\docheckvariables - {\dogetparameters\docheckrawvalue} +\def\system_variables_check + {\dogetparameters\system_variables_check_value} -\def\docheckrawvalue#1#2#3% - {\ifcsname\??vars:#1:#2\endcsname - \edef\checkedrawvalue{\csname\??vars:#1:#2\endcsname}% - \ifx\checkedrawvalue\empty - \expandafter\def\csname\??vars:#1:#2\endcsname{#3}% +\def\system_variables_check_value#1#2#3% + {\ifcsname\??variables#1:#2\endcsname + \edef\m_system_variables_temp{\csname\??variables#1:#2\endcsname}% + \ifx\m_system_variables_temp\empty + \expandafter\def\csname\??variables#1:#2\endcsname{#3}% \fi \else - \expandafter\def\csname\??vars:#1:#2\endcsname{#3}% + \expandafter\def\csname\??variables#1:#2\endcsname{#3}% \fi} %D \macros @@ -499,55 +502,37 @@ %D %D A few trivial macros: -\def\doifelsevariable#1#2% - {\ifcsname\??vars:#1:#2\endcsname +\unexpanded\def\doifelsevariable#1#2% + {\ifcsname\??variables#1:#2\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\def\doifvariable#1#2% - {\ifcsname\??vars:#1:#2\endcsname +\unexpanded\def\doifvariable#1#2% + {\ifcsname\??variables#1:#2\endcsname \expandafter\firstofoneargument \else \expandafter\gobbleoneargument \fi} -\def\doifnotvariable#1#2% - {\ifcsname\??vars:#1:#2\endcsname +\unexpanded\def\doifnotvariable#1#2% + {\ifcsname\??variables#1:#2\endcsname \expandafter\gobbleoneargument \else \expandafter\firstofoneargument \fi} \def\getvariabledefault#1#2% #3% can be command, so no ifcsname here - {\executeifdefined{\??vars:#1:#2}}% {#3} - -% \unexpanded\def\setupenv{\dodoubleargument\rawgetparameters[\??en]} -% -% \def\doifenvelse#1{\doifdefinedelse{\??en#1}} % speed up -% \def\doifenv #1{\doifdefined {\??en#1}} % speed up -% \def\doifnotenv #1{\doifundefined {\??en#1}} % speed up -% -% \def\env#1{\csname\??en#1\endcsname} -% -% \def\envvar#1#2% -% {\ifcsname\??en#1\endcsname -% \csname\??en#1\endcsname\else#2% -% \fi} -% -% low level change, now also accessible as \getvariable -% {environment}{...}; the next macros will become obsolete -% some day in favor of normal variables in the environment -% namespace - -\def\s!environment{environment} - -\unexpanded\def\setupenv {\dotripleargument\dosetvariables[\getrawparameters][\s!environment]} -\def\doifenvelse{\doifelsevariable \s!environment} -\def\doifenv {\doifvariable \s!environment} -\def\doifnotenv {\doifnotvariable \s!environment} -\def\env {\getvariable \s!environment} -\def\envvar {\getvariabledefault\s!environment} + {\executeifdefined{\??variables#1:#2}}% {#3} + +\unexpanded\def\setupenv + {\dotripleargument\system_variables_set[\getrawparameters][\s!environment]} + +\unexpanded\def\doifenvelse{\doifelsevariable \s!environment} +\unexpanded\def\doifenv {\doifvariable \s!environment} +\unexpanded\def\doifnotenv {\doifnotvariable \s!environment} +\def\env {\getvariable \s!environment} +\def\envvar {\getvariabledefault\s!environment} \protect \endinput diff --git a/tex/context/base/core-fnt.mkiv b/tex/context/base/core-fnt.mkiv index 641411f00..5f08cf75b 100644 --- a/tex/context/base/core-fnt.mkiv +++ b/tex/context/base/core-fnt.mkiv @@ -249,44 +249,4 @@ %D %D \getbuffer -% %D \macros -% %D {setupinitial,placeinitial,checkinitial} -% %D -% %D {\em To be documented.} -% %D -% %D \starttyping -% %D \setupinitial[state=start] \placeinitial \input tufte -% %D \stoptyping -% %D -% %D and -% %D -% %D \starttyping -% %D \def\bpar{\ifvmode\checkinitial\fi} -% %D \def\epar{\ifhmode\par\fi\checkinitial} -% %D \stoptyping -% -% % to do: more fine tuning -% -% \unexpanded\def\setupinitial -% {\dodoubleempty\getparameters[\??dc]} -% -% \definefontsynonym[Initial][Regular] % prefered initial identifier -% \definefontsynonym[initial][Initial] % internal but accepted too -% -% \setupinitial -% [\c!state=\v!stop, -% \c!location=\v!text, -% \c!n=3, -% \c!distance=.125em, -% \c!command=, -% \s!font=initial] -% -% \def\AutoDroppedCapsCommand{\NiceDroppedCaps\@@dccommand\@@dcfont\@@dcdistance\@@dcn}% -% -% \unexpanded\def\placeinitial -% {\doifelse\@@dclocation\v!margin{\chardef\DropMode\plusone}{\chardef\DropMode\zerocount}% -% \doif \@@dcstate\v!start{\ifcase\@@dcn\else\AutoDroppedCaps\fi}} -% -% \let\checkinitial\CheckDroppedCaps - \protect \endinput diff --git a/tex/context/base/core-gen.mkiv b/tex/context/base/core-gen.mkiv deleted file mode 100644 index 0d7fcebe0..000000000 --- a/tex/context/base/core-gen.mkiv +++ /dev/null @@ -1,166 +0,0 @@ -%D \module -%D [ file=core-gen, -%D version=1995.10.10, -%D title=\CONTEXT\ Core Macros, -%D subtitle=General, -%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 Core Macros / General} - -\unprotect - -%D \macros -%D {assigndimension,assignalfadimension} -%D -%D Hieronder worden enkele commando's gedefinieerd rond -%D toekenningen. Allereerst een commando om waarden aan -%D een \DIMENSION\ toe te kennen: -%D -%D \starttyping -%D \assigndimension -%D {|klein|middel|groot|-klein|-middel|-groot|geen} -%D {\dimension} -%D {waarde klein} -%D {waarde middel} -%D {waarde groot} -%D \stoptyping -%D -%D Hierbij krijgt de \DIMENSION\ \type{\dimension} een waarde -%D afhankelijk van het meegegeven trefwoord. -%D -%D \startnarrower -%D \startlines -%D \type{(-)klein }\qquad (--) waarde klein -%D \type{(-)middel}\qquad (--) waarde middel -%D \type{(-)groot }\qquad (--) waarde groot -%D \type{geen }\qquad 0pt -%D \type{waarde }\qquad waarde -%D \stoplines -%D \stopnarrower -%D -%D Een trefwoord mag worden voorafgegaan door een \type{-}. -%D Deze macro toont een voorbeeld van het gebruik van -%D \type{\processaction} en constanten. -%D -%D Analoog aan het bovenstaande commando kennen we een -%D commando om waarden toe te kennen aan een macro: -%D -%D \starttyping -%D \assignalfadimension -%D {|klein|middel|groot|geen} -%D {\macro} -%D {waarde klein} -%D {waarde middel} -%D {waarde groot} -%D \stoptyping - -% The third (optimized) version: - -\def\@ad@{@ad@} - -\setvalue{\@ad@ \v!none }{\zeropoint\gobblethreearguments} -\setvalue{\@ad@ \v!big }{\thirdofthreearguments} -\setvalue{\@ad@ \v!medium}{\secondofthreearguments} -\setvalue{\@ad@ \v!small }{\firstofthreearguments} -\setvalue{\@ad@-\v!big }{-\thirdofthreearguments} -\setvalue{\@ad@-\v!medium}{-\secondofthreearguments} -\setvalue{\@ad@-\v!small }{-\firstofthreearguments} - -\def\assigndimension#1#2% #3 #4 #5 - {#2=\ifcsname\@ad@#1\endcsname - \csname\@ad@#1\expandafter\endcsname - \else - #1\expandafter\gobblethreearguments - \fi} - -\def\@aa@{@aa@} - -\setvalue{\@aa@\v!none }{0\gobblethreearguments} -\setvalue{\@aa@\v!big }{\thirdofthreearguments} -\setvalue{\@aa@\v!medium}{\secondofthreearguments} -\setvalue{\@aa@\v!small }{\firstofthreearguments} - -\def\assignalfadimension#1#2#3#4#5% #3#4#5 are single digits - {\edef#2{\ifcsname\@aa@#1\endcsname - \csname\@aa@#1\expandafter\endcsname - \else - #1\expandafter\gobblethreearguments - \fi#3#4#5}} - -%D \macros -%D {assignvalue} -%D -%D Een variant hierop is het commando: -%D -%D \starttyping -%D \assignvalue -%D {|klein|middel|groot} -%D {\macro} -%D {waarde klein } -%D {waarde middel} -%D {waarde groot} -%D \stoptyping -%D -%D Hierbij krijgt \type{\macro} een waarde afhankelijk van -%D het meegegeven trefwoord: -%D -%D \startnarrower -%D \startlines -%D \type{klein }\qquad waarde klein -%D \type{middel}\qquad waarde middel -%D \type{groot }\qquad waarde groot -%D \type{waarde}\qquad waarde -%D \stoplines -%D \stopnarrower -%D -%D Hier doet \type{geen} dus niet mee. - -\def\@av@{@av@} - -\letvalue{\@av@\v!big }\thirdofthreearguments -\letvalue{\@av@\v!medium}\secondofthreearguments -\letvalue{\@av@\v!small }\firstofthreearguments - -\def\assignvalue#1#2#3#4#5% - {\edef#2{\ifcsname\@av@#1\endcsname - \csname\@av@#1\expandafter\endcsname - \else - #1\expandafter\gobblethreearguments - \fi{#3}{#4}{#5}}} - -%D \macros -%D {assignwidth} -%D -%D Een breedte van een opgegeven tekst kan worden berekend en -%D toegekend aan een \DIMENSION\ met: -%D -%D \starttyping -%D \assignwidth -%D {\dimension} -%D {|passend|ruim} -%D {tekst} -%D \stoptyping -%D -%D Dit commando sluit, evenals de bovenstaande -%D \type{\assign}||commando's, aan op de wijze waarop -%D in de andere \CONTEXT||modules toekenningen -%D plaatsvinden. Bij \type{ruim} wordt de gemeten breedte -%D met 1~em vermeerderd. - -\def\assignwidth#1#2#3#4% - {\doifelsenothing{#2} - {\setbox\scratchbox\hbox{#3}% - #1\wd\scratchbox} - {\doifinsetelse{#2}{\v!fit,\v!broad} - {\setbox\scratchbox\hbox{#3}% - #1\wd\scratchbox - \doif{#2}\v!broad{\advance#1 #4}}% - {#1=#2}}}% - -\protect \endinput diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv index e08693fca..ad74c2084 100644 --- a/tex/context/base/core-mis.mkiv +++ b/tex/context/base/core-mis.mkiv @@ -13,7 +13,7 @@ \writestatus{loading}{ConTeXt Core Macros / Misc Commands} -% todo: kleur in legenda + letter +% needs to be redone % %D You would not expect the next macro in \CONTEXT, % %D wouldn't you? It's there to warn \LATEX\ users that @@ -681,8 +681,6 @@ \unexpanded\def\startsubsentence{\beginofsubsentence \prewordbreak\beginofsubsentencespacing} \unexpanded\def\stopsubsentence {\endofsubsentencespacing\prewordbreak\endofsubsentence} \unexpanded\def\subsentence {\groupedcommand\startsubsentence\stopsubsentence} - -\enableactivediscretionaries \definehspace [quotation] [\zeropoint] \definehspace [interquotation] [.125em] @@ -1971,278 +1969,7 @@ \unexpanded\def\placeontopofeachother{\placerelativetoeachother\halign\hss} \unexpanded\def\placesidebyside {\placerelativetoeachother\valign\vss} - -%D A couple of examples, demonstrating how the depth is -%D taken care of: -%D -%D \startbuffer -%D test\rotate[frame=on, rotation=0] {gans}% -%D test\rotate[frame=on, rotation=90] {gans}% -%D test\rotate[frame=on, rotation=180]{gans}% -%D test\rotate[frame=on, rotation=270]{gans}% -%D test -%D \stopbuffer -%D -%D \typebuffer \getbuffer - -% When we rotate over arbitrary angles, we need to relocate the -% resulting box because rotation brings that box onto the negative -% axis. The calculations (mostly sin and cosine) need to be tuned for -% the way a box is packages (i.e. the refence point). A typical example -% of drawing, scribbling, and going back to the days of school math. -% -% We do a bit more calculations than needed, simply because that way -% it's easier to debug the code. - -% We can completely do this in lua .. when 'I'm bored ... - -\def\dododorotatenextbox - {\setbox\nextbox\vbox to \@@layerysiz - {\vfill - \hbox to \@@layerxsiz - {\dostartrotation\@@rorotation - \nextboxwd\zeropoint - \nextboxht\zeropoint - \flushnextbox - \dostoprotation - \hfill}% - \kern\@@layerypos}% - \setbox\nextbox\hbox - {\kern\@@layerxpos - \kern\@@layerxoff - \lower\@@layeryoff\flushnextbox}} - -\def\dodorotatenextbox#1#2% quite some trial and error -) - {\dontshowcomposition - \dontcomplain - \ifnum#2=\plusfour - % new, location=middle - \!!widthb \nextboxwd - \!!heightb\nextboxht - \!!depthb \nextboxdp - \setbox\nextbox\vbox{\vskip.5\nextboxht\hskip-.5\nextboxwd\flushnextbox}% - \smashbox\nextbox - \fi - \!!widtha \nextboxwd - \!!heighta\nextboxht - \!!deptha \nextboxdp - \!!doneafalse - \!!donebfalse - \ifcase#2\or - % 1: fit - \or - % 2: depth, not fit - \!!doneatrue - \!!donebtrue - \or - % 3: depth, fit - \!!donebtrue - \fi - \setbox\nextbox\vbox{\hbox{\raise\nextboxdp\flushnextbox}}% - \!!dimena \nextboxht - \setcalculatedcos\cos\@@rorotation - \setcalculatedsin\sin\@@rorotation - \@@layerxpos\zeropoint - \@@layerypos\zeropoint - \@@layerxoff\zeropoint - \@@layeryoff\zeropoint - \ifdim\sin\points>\zeropoint - \ifdim\cos\points>\zeropoint - \@@layerxsiz \cos\!!widtha - \@@layerysiz \sin\!!widtha - \advance\@@layerxsiz \sin\!!dimena - \advance\@@layerysiz \cos\!!dimena - \@@layerypos \cos\!!dimena - \if!!donea - \@@layerxoff \negated\sin\!!dimena - \advance\@@layerxoff \sin\!!deptha - \fi - \if!!doneb - \@@layeryoff \cos\!!deptha - \fi - \dododorotatenextbox - \else - \@@layerxsiz \negated\cos\!!widtha - \@@layerysiz \sin\!!widtha - \advance\@@layerxsiz \sin\!!dimena - \advance\@@layerysiz \negated\cos\!!dimena - \@@layerxpos \negated\cos\!!widtha - \if!!donea - \@@layerxoff -\@@layerxsiz - \advance\@@layerxoff \sin\!!deptha - \fi - \if!!doneb - \@@layeryoff \negated\cos\!!heighta - \fi - \dododorotatenextbox - \wd\nextbox\if!!donea\sin\!!deptha\else\@@layerxsiz\fi - \fi - \else - \ifdim\cos\points<\zeropoint - \@@layerxsiz \negated\cos\!!widtha - \@@layerysiz \negated\sin\!!widtha - \advance\@@layerxsiz \negated\sin\!!dimena - \advance\@@layerysiz \negated\cos\!!dimena - \@@layerxpos \@@layerxsiz - \@@layerypos \negated\sin\!!widtha - \if!!donea - \@@layerxoff -\@@layerxsiz - \advance\@@layerxoff \negated\sin\!!heighta - \fi - \if!!doneb - \@@layeryoff \@@layerysiz - \advance\@@layeryoff \cos\!!deptha - \fi - \dododorotatenextbox - \wd\nextbox\if!!donea\negated\sin\!!heighta\else\@@layerxsiz\fi - \else - \@@layerxsiz \cos\!!widtha - \@@layerysiz \negated\sin\!!widtha - \advance\@@layerxsiz \negated\sin\!!dimena - \advance\@@layerysiz \cos\!!dimena - \ifdim\sin\points=\zeropoint - \@@layerxpos \zeropoint - \@@layerxoff \zeropoint - \@@layerypos \@@layerysiz - \if!!doneb - \@@layeryoff \!!deptha - \fi - \else - \@@layerypos \@@layerysiz - \@@layerxpos \negated\sin\!!dimena - \if!!donea - \@@layerxoff -\@@layerxsiz - \advance\@@layerxoff \negated\sin\!!heighta - \fi - \if!!doneb - \@@layeryoff \negated\sin\!!deptha - \fi - \fi - \dododorotatenextbox - \ifdim\sin\points=\zeropoint - \else - \wd\nextbox\if!!donea\negated\sin\!!heighta\else\@@layerxsiz\fi - \fi - \fi - \fi - % new, location=middle - \ifnum#2=\plusfour - \setbox\nextbox\vbox{\vskip-.5\!!heightb\hskip.5\!!heightb\flushnextbox}% - \nextboxwd\!!widthb - \nextboxht\!!heightb - \nextboxdp\!!depthb - \fi} - -% \def\dorotatenextbox#1#2% -% {\doifsomething{#1} -% {\edef\@@rorotation{\realnumber{#1}}% get rid of leading zeros and spaces -% \setbox\nextbox\vbox{\flushnextbox}% not really needed -% \dodorotatenextbox\@@rorotation#2}% -% \hbox{\boxcursor\flushnextbox}} - -% \rotate[rotation=left]{\externalfigure[cow.pdf]} - -\def\dorotatenextbox#1#2% - {\hbox\bgroup - \edef\@@rorotation{#1}% - \ifx\@@rorotation\empty - \else - \ifx\@@rorotation\v!left - \doifoddpageelse{\edef\@@rorotation{90}}{\edef\@@rorotation{270}}% - \else\ifx\@@rorotation\v!right - \doifoddpageelse{\edef\@@rorotation{270}}{\edef\@@rorotation{90}}% - \else\ifx\@@rorotation\v!inner - \signalrightpage - \doifrightpageelse{\edef\@@rorotation{270}}{\edef\@@rorotation{90}}% - \else\ifx\@@rorotation\v!outer - \signalrightpage - \doifrightpageelse{\edef\@@rorotation{90}}{\edef\@@rorotation{270}}% - \else - \edef\@@rorotation{\realnumber{\@@rorotation}}% get rid of leading zeros and spaces - \fi\fi\fi\fi - \setbox\nextbox\vbox{\flushnextbox}% not really needed - \dodorotatenextbox\@@rorotation#2% - \fi - \boxcursor\flushnextbox - \egroup} - - -\def\dodorotatebox#1% {angle} \hbox/\vbox/\vtop - {\bgroup\hbox\bgroup % compatibility hack - \dowithnextbox - {\dorotatenextbox{#1}\plusone - \egroup\egroup}} -\def\dorotatebox#1% {angle} \hbox/\vbox/\vtop - {\ifcase#1\relax - \expandafter\gobbleoneargument - \else - \expandafter\dodorotatebox - \fi{#1}} - -\unexpanded\def\rotate % \bgroup: \rotate kan argument zijn - {\bgroup\complexorsimpleempty\rotate} - -% \def\complexrotate[#1]% framed met diepte ! -% {\getparameters[\??ro][#1]% -% \processaction -% [\@@rolocation] -% [ \v!depth=>\!!counta\plusthree\donefalse,% depth fit - raw box -% \v!fit=>\!!counta\plustwo \donefalse,% depth tight - raw box -% \v!broad=>\!!counta\plusone \donefalse,% nodepth fit - raw box -% \v!high=>\!!counta\plusone \donetrue ,% nodepth fit - framed -% \v!middle=>\!!counta\plusfour \donefalse,% centered, keep dimensions -% \s!default=>\!!counta\plusthree\donetrue ,% depth fit - framed -% \s!unknown=>\!!counta\plusthree\donetrue ]% depth fit - framed -% \ifdone -% \def\docommand{\localframed[\??ro][#1,\c!location=]}% -% \else -% \let\docommand\relax -% \fi -% \dowithnextbox{\dorotatenextbox\@@rorotation\!!counta\egroup}\vbox\docommand} - -\setvalue{\??ro::\c!location::\v!depth }{\!!counta\plusthree\donefalse} % depth fit - raw box -\setvalue{\??ro::\c!location::\v!fit }{\!!counta\plustwo \donefalse} % depth tight - raw box -\setvalue{\??ro::\c!location::\v!broad }{\!!counta\plusone \donefalse} % nodepth fit - raw box -\setvalue{\??ro::\c!location::\v!high }{\!!counta\plusone \donetrue } % nodepth fit - framed -\setvalue{\??ro::\c!location::\v!middle }{\!!counta\plusfour \donefalse} % centered, keep dimensions -\setvalue{\??ro::\c!location::\v!default}{\!!counta\plusthree\donetrue } % depth fit - framed - -\def\complexrotate[#1]% framed met diepte ! - {\getparameters[\??ro][#1]% - \executeifdefined{\??ro::\c!location::\@@rolocation}{\!!counta\plusthree\donetrue}% - \ifdone - \def\docommand{\localframed[\??ro][#1,\c!location=]}% - \else - \let\docommand\relax - \fi - \dowithnextbox{\dorotatenextbox\@@rorotation\!!counta\egroup}\vbox\docommand} - -\presetlocalframed[\??ro] - -\unexpanded\def\setuprotate - {\dodoubleargument\getparameters[\??ro]} - -\setuprotate - [\c!rotation=90, - \c!location=\v!normal, - \c!width=\v!fit, - \c!height=\v!fit, - \c!offset=\v!overlay, - \c!frame=\v!off] - -% \dostepwiserecurse{0}{360}{10} -% {\startlinecorrection[blank] -% \hbox -% {\expanded{\setuprotate[rotation=\recurselevel]}% -% \traceboxplacementtrue -% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=depth] {\ruledhbox{\bfb (depth)}}}}% -% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=fit] {\ruledhbox{\bfb (fit)}}}}% -% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=broad] {\ruledhbox{\bfb (broad)}}}}% -% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=normal]{\ruledhbox{\bfb (normal)}}}}% -% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=high] {\ruledhbox{\bfb (high)}}}}} -% \stoplinecorrection} - % to be used in some other places! todo! % % divides \hsize in fractions, will be made a bit more @@ -2256,8 +1983,6 @@ % % \setuphorizontaldivision[afstand=,aantal=] (passend,passend) -\def\??fr{@@fr} - \unexpanded\def\setuphorizontaldivision {\dodoubleargument\getparameters[\??fr]} diff --git a/tex/context/base/core-sys.mkiv b/tex/context/base/core-sys.mkiv index bfacd3c48..9dc03d336 100644 --- a/tex/context/base/core-sys.mkiv +++ b/tex/context/base/core-sys.mkiv @@ -21,7 +21,7 @@ %D Version checking: -\def\newcontextversion#1% +\unexpanded\def\newcontextversion#1% {\doifelse{#1}\contextversion {\let\newcontextversion\gobbleoneargument} {\writeline @@ -36,7 +36,6 @@ %D line ending. I hate this mess. \edef\operatingsystem {\cldcontext{os.platform}} - \def \jobfilename {\cldcontext{environment.jobfilename or ""}} \def \jobfilesuffix {\cldcontext{environment.jobfilesuffix or ""}} \def \inputfilebarename{\cldcontext{environment.inputfilebarename or ""}} @@ -44,21 +43,18 @@ \def \inputfilename {\cldcontext{environment.inputfilename or ""}} \def \outputfilename {\cldcontext{environment.outputfilename or ""}} -\newtoks \everysetupsystem - -\unexpanded\def\setupsystem - {\dosingleargument\dosetupsystem} +\installcorenamespace{system} -\def\dosetupsystem[#1]% - {\getparameters[\??sv][#1]% - \the\everysetupsystem} +\installdirectcommandhandler \??system {system} \appendtoks - \edef\outputresolution{\@@svresolution}% + \edef\outputresolution{\directsystemparameter\c!resolution}% + \edef\outputfilename {\directsystemparameter\c!file }% + \edef\inputfilename {\directsystemparameter\c!inputfile }% \to \everysetupsystem \appendtoks - \ifcase\@@svn + \ifcase\directsystemparameter\c!n\relax % % 0 : unknown \or \setsystemmode\v!first % 1 : first run @@ -71,17 +67,12 @@ \fi \to \everysetupsystem -\appendtoks - \edef\outputfilename{\@@svfile}% - \edef\inputfilename {\@@svinputfile}% -\to \everysetupsystem - -\let\@@jobsuffix\s!unknown +\let\m_system_job_suffix\s!unknown \appendtoks - \resetsystemmode{suffix-\@@jobsuffix}% - \edef\@@jobsuffix{\jobsuffix}% - \setsystemmode{suffix-\@@jobsuffix}% + \resetsystemmode{suffix-\m_system_job_suffix}% + \edef\m_system_job_suffix{\jobsuffix}% + \setsystemmode{suffix-\m_system_job_suffix}% \to \everysetupsystem \appendtoks @@ -95,13 +86,11 @@ \def\jobfullname{\jobfilename.\jobfilesuffix} -\def\setjobfullname#1% #1 = default if not given +\unexpanded\def\setjobfullname#1% #1 = default if not given {\doifelsenothing\jobfilename {\let\jobfullname\empty} {\doif\jobfilesuffix\c!tex{\edef\jobfullname{\jobfilename.#1}}}} -\def\systemparameter#1{\executeifdefined{\??sv#1}\empty} - %D There are a couple of system states avaiable: %D %D \starttabulate [|T|T|] @@ -130,7 +119,7 @@ \unexpanded\def\setuprandomize[#1]% {\doifsomething{#1} - {\bgroup + {\begingroup % tex's time is in minutes \scratchcounter\normaltime \processaction @@ -143,7 +132,7 @@ \s!unknown=>\scratchcounter#1]% \expanded{\setrandomseed{\the\scratchcounter}}% % \writestatus\m!system{randomseed: \the\scratchcounter}% - \egroup}} + \endgroup}} \setupsystem [\c!directory=, @@ -158,25 +147,9 @@ %D Remark: windows programs normally handle \type {cr|lf|crlf} but unix %D is more picky, so we default to the \type {cr}. I never understood why %D \type {crlf} was not used in all systems, since it makes most sense. +%D But anyway, in \MKIV\ we avoid most of the complications anyway as we +%D deal with much at the \LUA\ end. -\def\dostartglobaldefs#1#2% - {\edef\!!stringa{\the\globaldefs}% - \ifnum\globaldefs#10 - \globaldefs-\globaldefs - \fi - \advance\globaldefs #21 - \setevalue{@gd@\the\globaldefs}{\!!stringa}} - -\def\dostopglobaldefs - {\doifdefinedelse{@gd@\the\globaldefs} - {\globaldefs\getvalue{@gd@\the\globaldefs}\relax} - {\globaldefs\zerocount}} - -\unexpanded\def\startlocal {\dostartglobaldefs>-} -\unexpanded\def\stoplocal {\dostopglobaldefs} -\unexpanded\def\startglobal {\dostartglobaldefs<+} -\unexpanded\def\stopglobal {\dostopglobaldefs} - \def\complexstart[#1]{\bgroup\getvalue{\e!start#1}} \def\complexstop [#1]{\getvalue{\e!stop #1}\egroup} @@ -188,7 +161,9 @@ % \c!before \c!after \c!inbetween \c!commands \c!style \c!color -\installcommandhandler{\??be}{startstop}{\??be} +\installcorenamespace{startstop} + +\installcommandhandler \??startstop {startstop} \??startstop \appendtoks \setuevalue{\e!start\currentstartstop}{\dostartstop_start {\currentstartstop}}% @@ -219,7 +194,9 @@ \dostoptagged \startstopparameter\c!inbetween}} -\installcommandhandler{\??hl}{highlight}{\??hl} % we could do with less +\installcorenamespace{highlight} + +\installcommandhandler \??highlight {highlight} \??highlight % we could do with less \appendtoks \setuevalue\currenthighlight{\dohighlight_indeed{\currenthighlight}}% @@ -234,57 +211,26 @@ \usehighlightstyleandcolor\c!style\c!color \dotaghighlight} {\dostoptagged}} - -% \docommand kan niet worden gebruikt omdat deze macro -% soms lokaal wordt gebruikt -% te zijner tijd: -% -% \definevariable {pc} % ProtectedCommand -% -% \def\executeprotected#1% -% {\csname\??pc\string#1\endcsname} -% -% \unexpanded\def\defineprotected#1#2% -% {\expandafter\def\csname\??pc\string#2\endcsname} -% -% \unexpanded\def\defineunprotected#1% -% {\def#1} -% -% \def\doprotected% -% {\ifx\next\define -% \let\next=\defineprotected -% \else -% \let\next=\executeprotected -% \fi -% \next} -% -% \def\unexpanded% -% {\futurelet\next\doprotected} -% -% \unexpanded\define\ziezo{ziezo} -% -% \unexpanded\ziezo +\unexpanded\def\define + {\doifnextoptionalelse\system_define_yes\def} -\def\complexdefine[#1]#2#3% - {\ifx#2\undefined - \else +\unexpanded\def\system_define_yes[#1]#2#3% + {\ifdefined#2% \showmessage\m!system4{\string#2}% \fi - \ifcase0#1\def#2{#3}% - \or\def#2##1{#3}% - \or\def#2##1##2{#3}% - \or\def#2##1##2##3{#3}% - \or\def#2##1##2##3##4{#3}% - \or\def#2##1##2##3##4##5{#3}% - \or\def#2##1##2##3##4##5##6{#3}% - \or\def#2##1##2##3##4##5##6##7{#3}% - \or\def#2##1##2##3##4##5##6##7##8{#3}% - \or\def#2##1##2##3##4##5##6##7##8##9{#3}% - \else\def#2{#3}% - \fi} - -\definecomplexorsimpleempty\define + \ifcase0#1\relax + \def#2{#3}\or + \def#2##1{#3}\or + \def#2##1##2{#3}\or + \def#2##1##2##3{#3}\or + \def#2##1##2##3##4{#3}\or + \def#2##1##2##3##4##5{#3}\or + \def#2##1##2##3##4##5##6{#3}\or + \def#2##1##2##3##4##5##6##7{#3}\or + \def#2##1##2##3##4##5##6##7##8{#3}\or + \def#2##1##2##3##4##5##6##7##8##9{#3}\else + \def#2{#3}\fi} % \startluacode % local contextsprint, ctxcatcodes = context.sprint, tex.ctxcatcodes @@ -362,73 +308,19 @@ % \whateverb[A][B]{C}{D} % \stoptext +%D This is a checked variant of \type {\getvalue}. + \unexpanded\def\macroname#1% brrr - {\executeifdefined{#1}\empty} - -\def\usecommands#1% - {\bgroup - \def\docommand##1{\setbox0\hbox{\getvalue{\string##1}##1}}% - \processcommalist[#1]\docommand - \egroup} - -\newif\ifforcefileexpansion % handy for document level overload - -%D The next implementation is about 4 times as faster than a -%D processaction alternative on an string of average length. -%D Since this feature is used in XML processing, it made sense -%D to support this faster alternative. It's installable as well. -%D -%D We keep this around for \MKII\ \XML\ but it's not used in \MKIV\ -%D code as expansion is controlled in another way there. - -\def\installexpander#1#2#3% changed, no longer \convert..\to... - {\setvalue{\s!do\c!expansion#1l}{#2}% - \setvalue{\s!do\c!expansion#1g}{#3}}% - -% \convertexpanded is obsolete - -\long\def\doconvertexpanded#1#2#3% #4 % [l|g] \cs {kind} {data} - {\csname % that we assign all exp a value - \s!do\c!expansion - \ifforcefileexpansion - \v!yes - \else\ifcsname\s!do\c!expansion#3#1\endcsname - #3% - \else - \s!default - \fi\fi - #1% - \endcsname#2}% #3 - -\long\def\defconvertexpanded {\doconvertexpanded l} -\long\def\gdefconvertexpanded{\doconvertexpanded g} - -\installexpander\v!command \defconvertedcommand \gdefconvertedcommand -\installexpander\s!default \defconvertedargument \gdefconvertedargument -\installexpander\empty \defconvertedargument \gdefconvertedargument -\installexpander\v!no \defconvertedargument \gdefconvertedargument -\installexpander\v!yes \defconvertedmeaning \gdefconvertedmeaning -\installexpander\v!yes \defconvertedmeaning \gdefconvertedmeaning -\installexpander\v!strict \defreducedargument \gdefreducedargument -\installexpander {utf} \defreducedtoutf \gdefreducedtoutf - -\def\dodefconvertedmeaning#1#2#3% watch the double expansion ! - {\bgroup - \xdef\@@globalexpanded{#3}% - \xdef\@@globalexpanded{\@@globalexpanded}% - \egroup - #1#2\@@globalexpanded} + {\csname\ifcsname#1\endcsname#1\else\s!empty\fi\endcsname} -\def\defconvertedmeaning {\dodefconvertedmeaning\defconvertedcommand} -\def\gdefconvertedmeaning{\dodefconvertedmeaning\gdefconvertedcommand} +% %D A weird one that I probably needed once, so it might as well become +% %D obsolete. +% +% \unexpanded\def\usecommands#1% +% {\begingroup +% \def\docommand##1{\setbox\scratchbox\hbox{\csname\string##1\endcsname##1}}% +% \processcommalist[#1]\docommand +% \endgroup} -\def\dodefreducedargument#1#2#3% - {\begingroup - \reducetocoding[raw]% - \edef\ascii{#3}% - \expandafter\endgroup\expandafter#1\expandafter#2\expandafter{\ascii}} -\def\defreducedargument {\dodefreducedargument\edef} -\def\gdefreducedargument{\dodefreducedargument\xdef} - \protect \endinput diff --git a/tex/context/base/core-two.mkiv b/tex/context/base/core-two.mkiv index 725573899..58662d030 100644 --- a/tex/context/base/core-two.mkiv +++ b/tex/context/base/core-two.mkiv @@ -71,15 +71,8 @@ \unprotect -\let\twopassdatalist\empty - -\newif\iftwopassdatafound %% will become conditional - \registerctxluafile{core-two}{1.001} -%D I'm not that sure if this behaves exactly like mkii. This needs a cleanup. Is \type -%D {\normalexpanded} needed? - \def\immediatesavetwopassdata #1#2#3{\normalexpanded{\noexpand\ctxcommand {savetwopassdata('#1',"#3")}}} \def\savetwopassdata #1#2#3{\normalexpanded{\noexpand\ctxlatecommand{savetwopassdata('#1',"#3")}}} \def\lazysavetwopassdata #1#2#3{\normalexpanded{\noexpand\ctxlatecommand{savetwopassdata('#1',"#3")}}} @@ -88,21 +81,40 @@ % temp hack: needs a proper \starteverytimeluacode -\def\testtwopassdata{\ifx\twopassdata\empty\twopassdatafoundfalse\else\twopassdatafoundtrue\fi} +\setfalse\twopassdatafound +\let \twopassdata \empty +\let \twopassdatalist \empty + +\newif \iftwopassdatafound % obsolete, will go + +\def\system_twopass_check + {\ifx\twopassdata\empty + \twopassdatafoundfalse % obsolete + \setfalse\twopassdatafound + \else + \twopassdatafoundtrue % obsolete + \settrue\twopassdatafound + \fi} + +\def\system_twopass_set_not_found + {\twopassdatafoundfalse % obsolete + \setfalse\twopassdatafound} -% todo: move the edef to lua +\def\system_twopass_set_found + {\twopassdatafoundtrue % obsolete + \settrue\twopassdatafound} \unexpanded\def\definetwopasslist #1{\ctxcommand{definetwopasslist('#1')}} - \def\gettwopassdata #1{\edef\twopassdata {\ctxcommand{gettwopassdata ("#1")}}\testtwopassdata} - \def\checktwopassdata #1{\edef\twopassdata {\ctxcommand{checktwopassdata ("#1")}}\testtwopassdata} - \def\findtwopassdata #1#2{\edef\twopassdata {\ctxcommand{findtwopassdata("#1","#2")}}\testtwopassdata} - \def\getfirsttwopassdata #1{\edef\twopassdata {\ctxcommand{getfirsttwopassdata ("#1")}}\testtwopassdata} - \def\getlasttwopassdata #1{\edef\twopassdata {\ctxcommand{getlasttwopassdata ("#1")}}% - \edef\noftwopassitems{\ctxcommand{counttwopassdata ("#1")}}\testtwopassdata} - \def\getnamedtwopassdatalist#1#2{\edef #1{\ctxcommand{gettwopassdatalist ("#2")}}} - \def\gettwopassdatalist #1{\edef\twopassdatalist{\ctxcommand{gettwopassdatalist ("#1")}}} +\unexpanded\def\gettwopassdata #1{\edef\twopassdata {\ctxcommand{gettwopassdata ("#1")}}\system_twopass_check} +\unexpanded\def\checktwopassdata #1{\edef\twopassdata {\ctxcommand{checktwopassdata ("#1")}}\system_twopass_check} +\unexpanded\def\findtwopassdata #1#2{\edef\twopassdata {\ctxcommand{findtwopassdata("#1","#2")}}\system_twopass_check} +\unexpanded\def\getfirsttwopassdata #1{\edef\twopassdata {\ctxcommand{getfirsttwopassdata ("#1")}}\system_twopass_check} +\unexpanded\def\getlasttwopassdata #1{\edef\twopassdata {\ctxcommand{getlasttwopassdata ("#1")}}% + \edef\noftwopassitems{\ctxcommand{counttwopassdata ("#1")}}\system_twopass_check} +\unexpanded\def\getnamedtwopassdatalist#1#2{\edef #1{\ctxcommand{gettwopassdatalist ("#2")}}} +\unexpanded\def\gettwopassdatalist #1{\edef\twopassdatalist{\ctxcommand{gettwopassdatalist ("#1")}}} - \def\doifelseintwopassdata #1#2{\ctxcommand{doifelseintwopassdata("#1","#2")}} +\unexpanded\def\doifelseintwopassdata #1#2{\ctxcommand{doifelseintwopassdata("#1","#2")}} \let\getfromtwopassdata \findtwopassdata diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua index 69b8fffe1..7834be963 100644 --- a/tex/context/base/core-uti.lua +++ b/tex/context/base/core-uti.lua @@ -135,6 +135,8 @@ local jobpacker = packers.new(packlist,1.01) job.pack = true +directives.register("job.pack",function(v) pack = v end) + local _save_, _load_, _others_ = { }, { }, { } -- registers timing function job.save(filename) -- we could return a table but it can get pretty large diff --git a/tex/context/base/core-uti.mkiv b/tex/context/base/core-uti.mkiv index 6153bc847..9a783f78a 100644 --- a/tex/context/base/core-uti.mkiv +++ b/tex/context/base/core-uti.mkiv @@ -17,7 +17,7 @@ \registerctxluafile{core-uti}{1.001} -\def\savecurrentvalue#1#2% +\def\savecurrentvalue#1#2% immediate, so not \unexpanded {\ctxlua{job.variables.save("\strippedcsname#1","#2")}} \appendtoks @@ -35,11 +35,4 @@ }% \to \everyjob -\def\notuccompression{\ctxlua{job.pack=false}} - -%D Some styles might use these use these commands: - -\def\installprogram {\dosingleempty\doinstallprogram} -\def\doinstallprogram[#1]{\gobbleoneargument} - \protect \endinput diff --git a/tex/context/base/core-var.mkiv b/tex/context/base/core-var.mkiv index db056c3e7..26559f246 100644 --- a/tex/context/base/core-var.mkiv +++ b/tex/context/base/core-var.mkiv @@ -15,6 +15,8 @@ \unprotect +%D Much of this will move to *-ini files. + %D We introduce a couple of variables that are used all over %D \CONTEXT. Alternatively we could define them in each module %D but as they are part of the bigger picture we prefer to do @@ -65,12 +67,7 @@ \newtoks \everybeforepagebody \newtoks \everyafterpagebody -\let \everypagebody \everybeforepagebody % backward compatible - -%D Multipass: - -\newtoks \everybeforeutilityread -\newtoks \everyafterutilityread +\let \everypagebody \everybeforepagebody % backward compatible, will become obsolete %D Floats: diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi index 43179e156..8523be33a 100644 --- a/tex/context/base/file-job.mkvi +++ b/tex/context/base/file-job.mkvi @@ -85,12 +85,12 @@ \ifdefined\textlevel\else \newcount\textlevel \fi % might go away -\def\dostarttext +\unexpanded\def\dostarttext {\glet\dostarttext\relax \the\everystarttext \global\everystarttext\emptytoks} -\def\dostoptext +\unexpanded\def\dostoptext {\glet\dostoptext\relax \flushfinallayoutpage % optional \page % anyway @@ -166,11 +166,11 @@ \def\currentproduct {\ctxcommand{currentproduct ()}} \def\currentcomponent {\ctxcommand{currentcomponent ()}} \def\currentenvironment {\ctxcommand{currentenvironment()}} +\def\processedfile {\ctxcommand{processedfile()}} +\def\processedfiles {\ctxcommand{processedfiles()}} \unexpanded\def\dostarttextfile #name{\ctxcommand{dostarttextfile(name)}} \unexpanded\def\dostoptextfile {\ctxcommand{dostoptextfile()}} -\def\processedfile {\ctxcommand{processedfile()}} -\def\processedfiles {\ctxcommand{processedfiles()}} \unexpanded\def\loadtexfile [#name]{\ctxcommand{usetexfile("#name")}} \unexpanded\def\loadluafile [#name]{\ctxcommand{useluafile("#name")}} @@ -220,43 +220,43 @@ \newsystemmode\v!component \newsystemmode\v!environment -\def\startprojectindeed +\unexpanded\def\startprojectindeed {\starttext \pushsystemmode\v!project \setsystemmode\v!project} -\def\stopprojectindeed +\unexpanded\def\stopprojectindeed {\popsystemmode\v!project \stoptext \signalendofinput\v!project} -\def\startproductindeed +\unexpanded\def\startproductindeed {\starttext \pushsystemmode\v!product \setsystemmode\v!product} -\def\stopproductindeed +\unexpanded\def\stopproductindeed {\popsystemmode\v!product \stoptext \signalendofinput\v!product} -\def\startcomponentindeed +\unexpanded\def\startcomponentindeed {\starttext \pushreferenceprefix\currentcomponent \pushsystemmode\v!component \setsystemmode\v!component} -\def\stopcomponentindeed +\unexpanded\def\stopcomponentindeed {\popsystemmode\v!component \popreferenceprefix \stoptext \signalendofinput\v!component} -\def\startenvironmentindeed +\unexpanded\def\startenvironmentindeed {\pushsystemmode\v!environment \setsystemmode\v!environment} -\def\stopenvironmentindeed +\unexpanded\def\stopenvironmentindeed {\popsystemmode\v!environment \signalendofinput\v!environment} @@ -268,7 +268,7 @@ {\dosingleargument\start_document} \unexpanded\def\start_document[#settings]% - {\setvariables[document][#settings]% + {\setvariables[\s!document][#settings]% \the\everysetupdocument\relax \starttext \documentvariable\c!before} @@ -278,16 +278,16 @@ \stoptext} \def\documentvariable#name% - {\getvariable{document}{#name}} + {\getvariable\s!document{#name}} -\unexpanded\def\setupdocument[#1]% - {\setvariables[document][#1]% +\unexpanded\def\setupdocument[#settings]% + {\setvariables[\s!document][#settings]% \the\everysetupdocument\relax} \setvariables [document] - [\c!before=\directsetup{document:start}, - \c!after=\directsetup{document:stop}] + [\c!before=\directsetup{\s!document:start}, + \c!after=\directsetup{\s!document:stop}] %S The document: namespace will be used elsewhere too. diff --git a/tex/context/base/file-syn.mkvi b/tex/context/base/file-syn.mkvi index 573c582d7..e823a3519 100644 --- a/tex/context/base/file-syn.mkvi +++ b/tex/context/base/file-syn.mkvi @@ -43,11 +43,11 @@ %D \usemodules[pictex,chemie,unit] %D \stoptyping -\unexpanded\def\definefilesynonym {\dodoubleempty \dodefinefilesynonym} -\unexpanded\def\definefilefallback{\dodoubleargument\dodefinefilefallback} % still used? +\unexpanded\def\definefilesynonym {\dodoubleempty \system_define_file_synonym } +\unexpanded\def\definefilefallback{\dodoubleargument\system_define_file_fallback} % still used? -\def\dodefinefilesynonym [#name][#realname]{\ctxcommand{definefilesynonym ("#name","#realname")}} -\def\dodefinefilefallback[#name][#alternatives]{\ctxcommand{definefilefallback("#name","#alternatives")}} +\def\system_define_file_synonym [#name][#realname]{\ctxcommand{definefilesynonym ("#name","#realname")}} +\def\system_define_file_fallback[#name][#alternatives]{\ctxcommand{definefilefallback("#name","#alternatives")}} %D \macros %D {truefilename} diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua index bb03aee8d..fc255d395 100644 --- a/tex/context/base/font-ext.lua +++ b/tex/context/base/font-ext.lua @@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['font-ext'] = { local utf = unicode.utf8 local next, type, byte = next, type, string.byte -local gmatch, concat = string.gmatch, table.concat +local gmatch, concat, format = string.gmatch, table.concat, string.format local utfchar = utf.char local getparameters = utilities.parsers.getparameters @@ -706,6 +706,106 @@ registerotffeature { } } +-- for zhichu chen (see mailing list archive): we might add a few more variants +-- in due time +-- +-- \definefontfeature[boxed][default][boundingbox=yes] % paleblue +-- +-- maybe: +-- +-- \definecolor[DummyColor][s=.75,t=.5,a=1] {\DummyColor test} \nopdfcompression +-- +-- local gray = { "special", "pdf: /Tr1 gs .75 g" } +-- local black = { "special", "pdf: /Tr0 gs 0 g" } + +local push = { "push" } +local pop = { "pop" } +local gray = { "special", "pdf: .75 g" } +local black = { "special", "pdf: 0 g" } + +local downcache = { } -- handy for huge cjk fonts +local rulecache = { } -- handy for huge cjk fonts + +setmetatableindex(downcache,function(t,d) + local v = { "down", d } + t[d] = v + return v +end) + +setmetatableindex(rulecache,function(t,h) + local v = { } + t[h] = v + setmetatableindex(v,function(t,w) + local v = { "rule", h, w } + t[w] = v + return v + end) + return v +end) + +local function showboundingbox(tfmdata,key,value) + if value then + local vfspecials = backends.pdf.tables.vfspecials + local gray = vfspecials and (vfspecials.rulecolors[value] or vfspecials.rulecolors.palegray) or gray + local characters = tfmdata.characters + local resources = tfmdata.resources + local additions = { } + local private = resources.private + for unicode, old_c in next, characters do + private = private + 1 + local width = old_c.width or 0 + local height = old_c.height or 0 + local depth = old_c.depth or 0 + local new_c + if depth == 0 then + new_c = { + width = width, + height = height, + commands = { + push, + gray, + rulecache[height][width], + black, + pop, + { "slot", 1, private }, + } + } + else + new_c = { + width = width, + height = height, + depth = depth, + commands = { + push, + downcache[depth], + gray, + rulecache[height+depth][width], + black, + pop, + { "slot", 1, private }, + } + } + end + setmetatableindex(new_c,old_c) + characters[unicode] = new_c + additions[private] = old_c + end + for k, v in next, additions do + characters[k] = v + end + resources.private = private + end +end + +fonts.constructors.newfeatures("otf").register { + name = "boundingbox", + description = "show boundingbox", + manipulators = { + base = showboundingbox, + node = showboundingbox, + } +} + -- -- historic stuff, move from font-ota (handled differently, typo-rep) -- -- local delete_node = nodes.delete diff --git a/tex/context/base/font-gds.mkiv b/tex/context/base/font-gds.mkiv index 6e56c7f0a..d0c5be17d 100644 --- a/tex/context/base/font-gds.mkiv +++ b/tex/context/base/font-gds.mkiv @@ -17,8 +17,6 @@ \unprotect -\def\loadfontgoodies[#1]{\ctxcommand{loadfontgoodies("#1")}} - % this will become colorgroups and move to font-col or so \definecolor[colorscheme:1:1][s=.75] @@ -39,12 +37,16 @@ \definesystemattribute[colorscheme][public] -\def\setfontcolorscheme % will move to the lua end +\unexpanded\def\loadfontgoodies[#1]% + {\ctxcommand{loadfontgoodies("#1")}} + +\unexpanded\def\setfontcolorscheme % will move to the lua end {\ctxcommand{enablefontcolorschemes()}% \xdef\setfontcolorscheme[##1]{\attribute\colorschemeattribute##1\relax}% \setfontcolorscheme} -\edef\resetfontcolorscheme{\attribute\colorschemeattribute\attributeunsetvalue} +\unexpanded\def\resetfontcolorscheme + {\attribute\colorschemeattribute\attributeunsetvalue} \protect \endinput diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index 14376b733..4f0c40e7f 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -144,14 +144,14 @@ % % \dostepwiserecurse{2}{15}{1} % {{\switchtobodyfont[\recurselevel pt]\crap test}\endgraf} - + % adapted, else wrong interlinespace \unexpanded\def\setfontparameters {\synchronizefontsfalse \the\everybodyfont \synchronizefontstrue} - + % handy \newcounter\pushedfont @@ -452,19 +452,12 @@ %D We define some (very private) constants to improve speed, %D memory usage and consistency. -\def\@size@ {@f@si@} % bodyfont size prefix (12pt etc) -\def\@style@ {@f@st@} % full style prefix (roman etc) -\def\@shortstyle@ {@f@sh@} % short style prefix (rm etc) -\def\@letter@ {@f@le@} % first alternative typeface -\def\@noletter@ {@f@no@} % second alternative typeface -\def\@fontclass@ {@f@cl@} % fontclass - -% \edef\@size@ {\??fh:b:} % bodyfont size prefix (12pt etc) -% \edef\@style@ {\??fh:f:} % full style prefix (roman etc) -% \edef\@shortstyle@ {\??fh:s:} % short style prefix (rm etc) -% \edef\@letter@ {\??fh:l:} % first alternative typeface -% \edef\@noletter@ {\??fh:n:} % second alternative typeface -% \edef\@fontclass@ {\??fh:c:} % fontclass +\installcorenamespace {fontfile} % file synonyms +\installcorenamespace {fontsize} % bodyfont size prefix (12pt etc) +\installcorenamespace {fontstyle} % full style prefix (roman etc) +\installcorenamespace {fontshortstyle} % short style prefix (rm etc) +\installcorenamespace {fontclassyes} % fontclass +\installcorenamespace {fontclassnop} % nofontclass %D \macros %D {fontclass, defaultfontclass} @@ -477,6 +470,24 @@ \let\fontclass \empty \let\defaultfontclass\empty +\def\fontclassname#1#2% + {\ifcsname\??fontfile#1#2\endcsname + \fontclassname{#1}{\csname\??fontfile#1#2\endcsname}% + \else\ifcsname\??fontfile#2\endcsname + \fontclassname{#1}{\csname\??fontfile#2\endcsname}% + \else + #2% + \fi\fi} + +\def\defineclassfontsynonym + {\dotripleargument\dodefineclassfontsynonym} + +\def\dodefineclassfontsynonym[#1][#2][#3]% + {\definefontsynonym[#1][\fontclassname{#2}{#3}]} + +%\definefontsynonym [KopFont] [\fontclassname{officina}{SerifBold}] +% +%\defineclassfontsynonym [KopFont] [officina] [SerifBold] %D \macros %D {textonly} %D @@ -761,24 +772,27 @@ \ifconditional\pseudoboldmathstate\plussix\else\plusthree\fi \fi} -\letvalue{\??ff:\c!mr:\c!tf }\synchronizemathfamilymr -\letvalue{\??ff:\c!mr:\c!sl }\synchronizemathfamilymr -\letvalue{\??ff:\c!mr:\c!it }\synchronizemathfamilymr -\letvalue{\??ff:\c!mr:\c!bf }\synchronizemathfamilymb -\letvalue{\??ff:\c!mr:\c!bs }\synchronizemathfamilymb -\letvalue{\??ff:\c!mr:\c!bi }\synchronizemathfamilymb -\letvalue{\??ff:\c!mr:\empty}\synchronizemathfamilymr +\installcorenamespace{fontmathsynchronizer} +\installcorenamespace{fontmathstoredstrategy} + +\letvalue{\??fontmathsynchronizer\c!tf }\synchronizemathfamilymr +\letvalue{\??fontmathsynchronizer\c!sl }\synchronizemathfamilymr +\letvalue{\??fontmathsynchronizer\c!it }\synchronizemathfamilymr +\letvalue{\??fontmathsynchronizer\c!bf }\synchronizemathfamilymb +\letvalue{\??fontmathsynchronizer\c!bs }\synchronizemathfamilymb +\letvalue{\??fontmathsynchronizer\c!bi }\synchronizemathfamilymb +\letvalue{\??fontmathsynchronizer\empty}\synchronizemathfamilymr \def\synchronizemathfamily - {\csname\??ff:\c!mr:\ifcsname\??ff:\c!mr:\fontalternative\endcsname\fontalternative\fi\endcsname} + {\csname\??fontmathsynchronizer\ifcsname\??fontmathsynchronizer\fontalternative\endcsname\fontalternative\fi\endcsname} -\ifdefined\fontid +\ifdefined \fontid \appendtoks \ifnum\fontid\textfont\zerocount=\fontid\textfont\plusthree - \letvalue{\??ff:ms:\fontclass}\dosetmathpartialboldstrategy % enables partial bold math + \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathpartialboldstrategy % enables partial bold math \else - \letvalue{\??ff:ms:\fontclass}\dosetmathfullboldstrategy % enables full bold math + \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathfullboldstrategy % enables full bold math \fi \to \mathstrategies @@ -788,15 +802,15 @@ \edef\currentmathfontmr{\fontname\textfont\zerocount}% \edef\currentmathfontmb{\fontname\textfont\plusthree}% \ifx\currentmathfontmr\currentmathfontmb - \letvalue{\??ff:ms:\fontclass}\dosetmathpartialboldstrategy % enables partial bold math + \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathpartialboldstrategy % enables partial bold math \else - \letvalue{\??ff:ms:\fontclass}\dosetmathfullboldstrategy % enables full bold math + \letvalue{\??fontmathstoredstrategy\fontclass}\dosetmathfullboldstrategy % enables full bold math \fi \to \mathstrategies \fi -\def\synchronizemathboldstrategy {\csname\??ff:ms:\fontclass\endcsname} +\def\synchronizemathboldstrategy {\csname\??fontmathstoredstrategy\fontclass\endcsname} \newconditional\pseudoboldmathstate @@ -990,7 +1004,7 @@ % sets \scaledfontmode and \somefontname and \somefontsize \ifcase\scaledfontmode\relax % none, avoid the designsize if possible - \scaledfontsize-1000\scaledpoint + \scaledfontsize-\plusthousand\scaledpoint \or % at \scaledfontsize\somefontsize @@ -1058,40 +1072,40 @@ % resolve \def\@@thefeaturesyes#1% - {\ifcsname\??ff\fontclass#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff\fontclass#1\s!features \endcsname\else - \ifcsname\??ff #1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff #1\s!features \endcsname\else - \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thefeaturesyes \csname\??ff\fontclass #1\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thefeaturesyes \csname\??ff #1\endcsname\else - \let \@@fontfeatures \empty \fi\fi\fi\fi} + {\ifcsname\??fontfile\fontclass#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??fontfile\fontclass#1\s!features \endcsname\else + \ifcsname\??fontfile #1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??fontfile #1\s!features \endcsname\else + \ifcsname\??fontfile\fontclass #1\endcsname\@EA \@@thefeaturesyes \csname\??fontfile\fontclass #1\endcsname\else + \ifcsname\??fontfile #1\endcsname\@EA \@@thefeaturesyes \csname\??fontfile #1\endcsname\else + \let \@@fontfeatures \empty \fi\fi\fi\fi} \def\@@thefallbacksyes#1% - {\ifcsname\??ff\fontclass#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff\fontclass#1\s!fallbacks\endcsname\else - \ifcsname\??ff #1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff #1\s!fallbacks\endcsname\else - \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thefallbacksyes\csname\??ff\fontclass #1\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksyes\csname\??ff #1\endcsname\else - \let \@@fontfallbacks \empty \fi\fi\fi\fi} + {\ifcsname\??fontfile\fontclass#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??fontfile\fontclass#1\s!fallbacks\endcsname\else + \ifcsname\??fontfile #1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??fontfile #1\s!fallbacks\endcsname\else + \ifcsname\??fontfile\fontclass #1\endcsname\@EA \@@thefallbacksyes\csname\??fontfile\fontclass #1\endcsname\else + \ifcsname\??fontfile #1\endcsname\@EA \@@thefallbacksyes\csname\??fontfile #1\endcsname\else + \let \@@fontfallbacks \empty \fi\fi\fi\fi} \def\@@thegoodiesyes#1% - {\ifcsname\??ff\fontclass#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??ff\fontclass#1\s!goodies \endcsname\else - \ifcsname\??ff #1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??ff #1\s!goodies \endcsname\else - \ifcsname\??ff\fontclass #1\endcsname\@EA \@@thegoodiesyes \csname\??ff\fontclass #1\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thegoodiesyes \csname\??ff #1\endcsname\else - \let \@@fontgoodies \empty \fi\fi\fi\fi} + {\ifcsname\??fontfile\fontclass#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??fontfile\fontclass#1\s!goodies \endcsname\else + \ifcsname\??fontfile #1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??fontfile #1\s!goodies \endcsname\else + \ifcsname\??fontfile\fontclass #1\endcsname\@EA \@@thegoodiesyes \csname\??fontfile\fontclass #1\endcsname\else + \ifcsname\??fontfile #1\endcsname\@EA \@@thegoodiesyes \csname\??fontfile #1\endcsname\else + \let \@@fontgoodies \empty \fi\fi\fi\fi} \def\@@thefeaturesnop#1% - {\ifcsname\??ff#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??ff#1\s!features \endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thefeaturesnop \csname\??ff #1\endcsname\else - \let \@@fontfeatures \empty \fi\fi} + {\ifcsname\??fontfile#1\s!features \endcsname\@EA\let\@EA\@@fontfeatures \csname\??fontfile#1\s!features \endcsname\else + \ifcsname\??fontfile #1\endcsname\@EA \@@thefeaturesnop \csname\??fontfile #1\endcsname\else + \let \@@fontfeatures \empty \fi\fi} \def\@@thefallbacksnop#1% - {\ifcsname\??ff#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??ff#1\s!fallbacks\endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thefallbacksnop\csname\??ff #1\endcsname\else - \let \@@fontfallbacks \empty \fi\fi} + {\ifcsname\??fontfile#1\s!fallbacks\endcsname\@EA\let\@EA\@@fontfallbacks \csname\??fontfile#1\s!fallbacks\endcsname\else + \ifcsname\??fontfile #1\endcsname\@EA \@@thefallbacksnop\csname\??fontfile #1\endcsname\else + \let \@@fontfallbacks \empty \fi\fi} \def\@@thegoodiesnop#1% - {\ifcsname\??ff#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??ff#1\s!goodies \endcsname\else - \ifcsname\??ff #1\endcsname\@EA \@@thegoodiesnop \csname\??ff #1\endcsname\else - \let \@@fontgoodies \empty \fi\fi} + {\ifcsname\??fontfile#1\s!goodies \endcsname\@EA\let\@EA\@@fontgoodies \csname\??fontfile#1\s!goodies \endcsname\else + \ifcsname\??fontfile #1\endcsname\@EA \@@thegoodiesnop \csname\??fontfile #1\endcsname\else + \let \@@fontgoodies \empty \fi\fi} \def\updatefontparametersyes {\@@thefeaturesyes \somefontname @@ -1260,11 +1274,11 @@ \fi} \def\dodefinefontsynonymnop - {\@EA\let\csname\??ff\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion + {\@EA\let\csname\??fontfile\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion \doifnextoptionalelse\dododefinefontsynonymnop\nonodefinefontsynonymnop} \def\dodefinefontsynonymyes - {\@EA\let\csname\??ff\fontclass\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion + {\@EA\let\csname\??fontfile\fontclass\@@fontname\endcsname\@@fontfile % maybe just #1 #3, saves expansion \doifnextoptionalelse\dododefinefontsynonymyes\nonodefinefontsynonymyes} \def\dododefinefontsynonymnop[#1]% @@ -1305,24 +1319,24 @@ % end of helpers \def\nonodefinefontsynonymnop - {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\undefined - \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\undefined - \@EA\let\csname\??ff\@@fontname\s!goodies \endcsname\undefined} + {\@EA\let\csname\??fontfile\@@fontname\s!features \endcsname\undefined + \@EA\let\csname\??fontfile\@@fontname\s!fallbacks\endcsname\undefined + \@EA\let\csname\??fontfile\@@fontname\s!goodies \endcsname\undefined} \def\nonodefinefontsynonymyes - {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined - \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined - \global\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\undefined} + {\global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!features \endcsname\undefined + \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!fallbacks\endcsname\undefined + \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!goodies \endcsname\undefined} \def\dodododefinefontsynonymnop - {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\@@ff@@features - \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks - \@EA\let\csname\??ff\@@fontname\s!goodies \endcsname\@@ff@@goodies} + {\@EA\let\csname\??fontfile\@@fontname\s!features \endcsname\@@ff@@features + \@EA\let\csname\??fontfile\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks + \@EA\let\csname\??fontfile\@@fontname\s!goodies \endcsname\@@ff@@goodies} \def\dodododefinefontsynonymyes - {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features - \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks - \global\@EA\let\csname\??ff\fontclass\@@fontname\s!goodies \endcsname\@@ff@@goodies} + {\global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!features \endcsname\@@ff@@features + \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks + \global\@EA\let\csname\??fontfile\fontclass\@@fontname\s!goodies \endcsname\@@ff@@goodies} \let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater @@ -1336,23 +1350,23 @@ {\@EA\dotruefontname#1*\empty*\relax} \def\dotruefontname#1*#2#3*#4\relax - {\ifcsname\??ff\fontclass#1\endcsname + {\ifcsname\??fontfile\fontclass#1\endcsname \ifx#2\empty - \@EA\truefontname\csname\??ff\fontclass#1\endcsname + \@EA\truefontname\csname\??fontfile\fontclass#1\endcsname \else - \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname*#2#3% + \@EA\redotruefontname\csname\??fontfile\fontclass#1\endcsname*#2#3% \fi - \else\ifcsname\??ff\defaultfontclass#1\endcsname + \else\ifcsname\??fontfile\defaultfontclass#1\endcsname \ifx#2\empty - \@EA\truefontname\csname\??ff\defaultfontclass#1\endcsname + \@EA\truefontname\csname\??fontfile\defaultfontclass#1\endcsname \else - \@EA\redotruefontname\csname\??ff\defaultfontclass#1\endcsname*#2#3% + \@EA\redotruefontname\csname\??fontfile\defaultfontclass#1\endcsname*#2#3% \fi - \else\ifcsname\??ff#1\endcsname + \else\ifcsname\??fontfile#1\endcsname \ifx#2\empty - \@EA\truefontname\csname\??ff#1\endcsname + \@EA\truefontname\csname\??fontfile#1\endcsname \else - \@EA\redotruefontname\csname\??ff#1\endcsname*#2#3% + \@EA\redotruefontname\csname\??fontfile#1\endcsname*#2#3% \fi \else #1\ifx#2\empty\else*#2#3\fi @@ -1362,27 +1376,27 @@ {\@EA\dodotruefontname#1*\relax} \def\dodotruefontname#1*#2\relax - {\ifcsname\??ff\fontclass#1\endcsname - \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname - \else\ifcsname\??ff\defaultfontclass#1\endcsname - \@EA\redotruefontname\csname\??ff\defaultfontclass#1\endcsname - \else\ifcsname\??ff#1\endcsname - \@EA\redotruefontname\csname\??ff#1\endcsname + {\ifcsname\??fontfile\fontclass#1\endcsname + \@EA\redotruefontname\csname\??fontfile\fontclass#1\endcsname + \else\ifcsname\??fontfile\defaultfontclass#1\endcsname + \@EA\redotruefontname\csname\??fontfile\defaultfontclass#1\endcsname + \else\ifcsname\??fontfile#1\endcsname + \@EA\redotruefontname\csname\??fontfile#1\endcsname \else #1% \fi\fi\fi} \def\expandfontsynonym#1#2% #2 := onelevelexpansion(#1) - {\ifcsname\??ff\fontclass#2\endcsname - \expandafter\def\expandafter#1\expandafter{\csname\??ff\fontclass#2\endcsname}% - \else\ifcsname\??ff\defaultfontclass#2\endcsname - \expandafter\def\expandafter#1\expandafter{\csname\??ff\defaultfontclass#2\endcsname}% + {\ifcsname\??fontfile\fontclass#2\endcsname + \expandafter\def\expandafter#1\expandafter{\csname\??fontfile\fontclass#2\endcsname}% + \else\ifcsname\??fontfile\defaultfontclass#2\endcsname + \expandafter\def\expandafter#1\expandafter{\csname\??fontfile\defaultfontclass#2\endcsname}% \fi\fi} \def\doifelsefontsynonym#1% - {\ifcsname\??ff\fontclass#1\endcsname + {\ifcsname\??fontfile\fontclass#1\endcsname \expandafter\firstoftwoarguments - \else\ifcsname\??ff\defaultfontclass#1\endcsname + \else\ifcsname\??fontfile\defaultfontclass#1\endcsname \doubleexpandafter\firstoftwoarguments \else \doubleexpandafter\secondoftwoarguments @@ -1417,10 +1431,10 @@ %D A goody: \def\tracedfontname#1% - {#1\ifcsname\??ff\fontclass#1\endcsname - \@EA\tracedfontname\csname\??ff\fontclass#1\endcsname - \else\ifcsname\??ff#1\endcsname - \@EA\tracedfontname\csname\??ff#1\endcsname + {#1\ifcsname\??fontfile\fontclass#1\endcsname + \@EA\tracedfontname\csname\??fontfile\fontclass#1\endcsname + \else\ifcsname\??fontfile#1\endcsname + \@EA\tracedfontname\csname\??fontfile#1\endcsname \fi\fi} %D \macros @@ -1817,11 +1831,11 @@ %\@@endfontdef % new code, see remark \ifproductionrun - \ifcsname\@size@#1\endcsname + \ifcsname\??fontsize#1\endcsname % only once \else % prevent loop (hence \empty) - \letvalueempty{\@size@#1}% + \letvalueempty{\??fontsize#1}% \pushmacro\fontclass % new per 26102009 \edef\fontclass{#2}% % new per 26102009 \defineunknownfont{#1}% @@ -1829,7 +1843,7 @@ \fi \fi % so far - \setvalue{\@size@#1}{\docompletefontswitch[#1]}} + \setvalue{\??fontsize#1}{\docompletefontswitch[#1]}} %D {\bf Remark:} We need to cover the following cases, %D otherwise users can get confused: @@ -1880,15 +1894,15 @@ [\??ft#1\tempbodyfontsize][\??ft\s!default] [\c!interlinespace,\c!em]% %\ifproductionrun - \ifcsname\@size@\tempbodyfontsize\endcsname \else - \letvalueempty{\@size@\tempbodyfontsize}% prevent loop + \ifcsname\??fontsize\tempbodyfontsize\endcsname \else + \letvalueempty{\??fontsize\tempbodyfontsize}% prevent loop \pushmacro\fontclass \edef\fontclass{#1}% \normalexpanded{\defineunknownfont{\tempbodyfontsize}}% we can also inherit here \popmacro\fontclass \fi %\fi - \setevalue{\@size@#1}{\noexpand\docompletefontswitch[#1]}% + \setevalue{\??fontsize#1}{\noexpand\docompletefontswitch[#1]}% \@@endfontdef} % this one already catches both define/setup @@ -2035,10 +2049,10 @@ \else % Maybe there are default dependencies defined which we can use ([unknown]) and % if not, then we have at least to make sure some basics are set up. - \ifcsname\@size@#1\endcsname \else + \ifcsname\??fontsize#1\endcsname \else \defineunknownfont{#1}% \fi - \ifcsname\@size@#1\endcsname \else + \ifcsname\??fontsize#1\endcsname \else \definebodyfont[#1][\c!rm][]% \fi \fi\fi} @@ -2174,7 +2188,7 @@ \fi} \def\dodefineunknownsubfont#1#2% - {\ifcsname\@size@\csname\??ft#1#2\endcsname\endcsname + {\ifcsname\??fontsize\csname\??ft#1#2\endcsname\endcsname \else \donetrue \defineunknownfont{\csname\??ft#1#2\endcsname}% @@ -2194,7 +2208,7 @@ {\dodefineunknownbodyfont{#1}}% \ifdone \donefalse - \setvalue{\@size@#1}{\docompletefontswitch[#1]}% + \setvalue{\??fontsize#1}{\docompletefontswitch[#1]}% \ifdefiningunknownfont \else \definingunknownfonttrue \processcommacommand[\fontrelativesizelist]{\dodefineunknownsubfont{#1}}% @@ -2314,12 +2328,12 @@ {\normalexpanded{\dodoswitchpoints{#1}}} \unexpanded\def\dodoswitchpoints#1% - {\ifcsname\@size@#1\endcsname \else + {\ifcsname\??fontsize#1\endcsname \else \defineunknownfont{#1}% \fi% %\defineunknownfontstyles{#1}% - \ifcsname\@size@#1\endcsname - \csname\@size@#1\endcsname + \ifcsname\??fontsize#1\endcsname + \csname\??fontsize#1\endcsname \localbodyfontsize#1\relax % \edef\fontbody{\fontbody}% to be tested but we can clean up mkiv further \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\localbodyfontsize}% @@ -2329,8 +2343,8 @@ \fi} \unexpanded\def\doswitchstyle[#1]% - {\ifcsname\@style@#1\endcsname - \csname\@style@#1\endcsname + {\ifcsname\??fontstyle#1\endcsname + \csname\??fontstyle#1\endcsname \edef\fontstyle{#1}% \ifmmode\mr\fi % in order to be compatible with \rm in math mode % \the\everybodyfont % cleaner, in setting size as well as style @@ -2526,7 +2540,7 @@ \let\fontstyle\empty % new 31/7/2006 \let\fontsize \empty \else - \ifcsname\@style@\expandedfontthing\endcsname + \ifcsname\??fontstyle\expandedfontthing\endcsname \let\fontstyle\expandedfontthing \else \setcurrentfontclass\expandedfontthing @@ -2547,10 +2561,10 @@ \def\dodododosetfont#1#2#3% #1 = set/switch state {\edef\normalizedsetfont{\thenormalizedbodyfontsize{#2}}% - \ifcsname\@size@\normalizedsetfont\endcsname \else + \ifcsname\??fontsize\normalizedsetfont\endcsname \else \defineunknownfont{#2}% \fi - \ifcsname\@size@\normalizedsetfont\endcsname + \ifcsname\??fontsize\normalizedsetfont\endcsname \localbodyfontsize\normalizedsetfont \let\normalizedbodyfontsize\normalizedsetfont \else @@ -2592,14 +2606,12 @@ % we need to check the fontclass \def\registerfontclass#1% - {\letgvalue{\@fontclass@#1}\v!yes} % global ? - -\edef\@no@fontclass@{\@fontclass@:?:} + {\letgvalue{\??fontclassyes#1}\v!yes} % global ? \def\setcurrentfontclass#1% - {\ifcsname\@fontclass@#1\endcsname + {\ifcsname\??fontclassyes#1\endcsname \edef\fontclass{#1}% - \else\ifcsname\@no@fontclass@#1\endcsname + \else\ifcsname\??fontclassnop#1\endcsname % already tried \else % too messy: \ifcase\currentgrouplevel % (unpredictable) \trycurrentfontclass{#1}% @@ -2618,23 +2630,23 @@ {\ifconditional\autotypescripts % try to load typescript #1 \usetypescript[#1]% - \ifcsname\@fontclass@#1\endcsname + \ifcsname\??fontclassyes#1\endcsname \edef\fontclass{#1}% \else % try to load type-#1.mkiv \usetypescriptfile[\f!typeprefix#1]% % try to load typescript #1 \usetypescript[#1]% - \ifcsname\@fontclass@#1\endcsname + \ifcsname\??fontclassyes#1\endcsname \edef\fontclass{#1}% \else % todo: message - \letvalueempty{\@no@fontclass@#1}% + \letvalueempty{\??fontclassnop#1}% \fi \fi \else % todo: message - \letvalueempty{\@no@fontclass@#1}% + \letvalueempty{\??fontclassnop#1}% \fi} \let\defaultfontstyle \c!rm @@ -2987,8 +2999,8 @@ %D \stoptyping \def\dododefinefontstyle#1#2% - {\setvalue{\@shortstyle@#2}{#1}% - \setvalue{\@style@#2}{\csname#1\endcsname}} + {\setvalue{\??fontshortstyle#2}{#1}% + \setvalue{\??fontstyle #2}{\csname#1\endcsname}} \def\dodefinefontstyle[#1][#2]% {\rawdoifinsetelse{#2}{\fontstylelist}{}{\addtocommalist{#2}\fontstylelist}% @@ -3091,12 +3103,12 @@ \def\fastswitchtobodyfont#1% {\ifcsname\??ft\normalizedbodyfontsize#1\endcsname \edef\futurebodyfontsize{\csname\??ft\normalizedbodyfontsize#1\endcsname}% - \ifcsname\@size@\futurebodyfontsize\endcsname - \csname\@size@\futurebodyfontsize\endcsname + \ifcsname\??fontsize\futurebodyfontsize\endcsname + \csname\??fontsize\futurebodyfontsize\endcsname \localbodyfontsize\futurebodyfontsize\relax \fi \fi - \csname\@style@\fontstyle\endcsname + \csname\??fontstyle\fontstyle\endcsname \the\everybodyfont} %D \starttyping @@ -3345,7 +3357,7 @@ {\complexswitchstyleonly[\checkedstrippedcsname#1]} \def\complexswitchstyleonly[#1]% todo : check - {\setcurrentfontstyle{\csname\@shortstyle@#1\endcsname}% + {\setcurrentfontstyle{\csname\??fontshortstyle#1\endcsname}% \the\everybodyfont} % needed ? %D \macros @@ -4019,37 +4031,37 @@ \s!Serif \fi\fi\fi} % potential generalization: - -% \letvalue{\??ff:t:\c!rm}\s!Serif -% \letvalue{\??ff:t:\c!ss}\s!Sans -% \letvalue{\??ff:t:\c!tt}\s!Mono % -% \letvalue{\??ff:s:\c!bf}\s!Bold -% \letvalue{\??ff:s:\c!sl}\s!Slanted -% \letvalue{\??ff:s:\c!it}\s!Italic -% \letvalue{\??ff:s:\c!bs}\s!BoldSlanted -% \letvalue{\??ff:s:\c!bi}\s!BoldItalic +% \letvalue{\??fontfile:t:\c!rm}\s!Serif +% \letvalue{\??fontfile:t:\c!ss}\s!Sans +% \letvalue{\??fontfile:t:\c!tt}\s!Mono % -% \letvalue{\??ff:a:\c!rm}\s!Regular -% \letvalue{\??ff:a:\c!ss}\s!Support -% \letvalue{\??ff:a:\c!tt}\s!Type +% \letvalue{\??fontfile:s:\c!bf}\s!Bold +% \letvalue{\??fontfile:s:\c!sl}\s!Slanted +% \letvalue{\??fontfile:s:\c!it}\s!Italic +% \letvalue{\??fontfile:s:\c!bs}\s!BoldSlanted +% \letvalue{\??fontfile:s:\c!bi}\s!BoldItalic % -% \def\fontstringA{\executeifdefined{\??ff:t:\fontstyle}\s!Serif} -% \def\fontstringB{\executeifdefined{\??ff:a:\fontstyle}\s!Serif} -% \def\fontstringC{\executeifdefined{\??ff:s:\fontstyle}\empty} -% \def\fontstringD{\executeifdefined{\??ff:t:\csname\??tf\fontclass\s!default\endcsname}\s!Serif} +% \letvalue{\??fontfile:a:\c!rm}\s!Regular +% \letvalue{\??fontfile:a:\c!ss}\s!Support +% \letvalue{\??fontfile:a:\c!tt}\s!Type +% +% \def\fontstringA{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif} +% \def\fontstringB{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif} +% \def\fontstringC{\executeifdefined{\??fontfile:s:\fontstyle}\empty} +% \def\fontstringD{\executeifdefined{\??fontfile:t:\csname\??tf\fontclass\s!default\endcsname}\s!Serif} \def\glyphfontfile#1% {#1% - \ifcsname\??ff#1\fontstringA\fontstringC\endcsname + \ifcsname\??fontfile#1\fontstringA\fontstringC\endcsname \fontstringA\fontstringC - \else\ifcsname\??ff#1\fontstringB\fontstringC\endcsname + \else\ifcsname\??fontfile#1\fontstringB\fontstringC\endcsname \fontstringB\fontstringC - \else\ifcsname\??ff#1\fontstringA\endcsname + \else\ifcsname\??fontfile#1\fontstringA\endcsname \fontstringA - \else\ifcsname\??ff#1\fontstringB\endcsname + \else\ifcsname\??fontfile#1\fontstringB\endcsname \fontstringB - \else\ifcsname\??ff#1\fontstringC\endcsname + \else\ifcsname\??fontfile#1\fontstringC\endcsname \fontstringC \fi\fi\fi\fi\fi} @@ -4071,36 +4083,38 @@ %D Since we know what scaling it to be applied, we can %D implement a much faster alternative: +\installcorenamespace {symbolfont} + \let\thedefinedfont\relax \def\setscaledstyledsymbolicfont#1#2#3% quite a slowdown, glyphfontfile {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#3}} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% - \ifcsname\??ss->\askedsymbolfont\endcsname - \csname\??ss->\askedsymbolfont\endcsname + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname \else \dodefinesymbolicfont \fi} \def\setscaleddirectsymbolicfont#1#2#3% quite a slowdown, glyphfontfile {\edef\askedsymbolfont{\truefontname{#3} at \the\dimexpr#2\dimexpr\currentfontbodyscale\dimexpr#1}% - \ifcsname\??ss->\askedsymbolfont\endcsname - \csname\??ss->\askedsymbolfont\endcsname + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname \else \dodefinesymbolicfont \fi} \def\setstyledsymbolicfont#1% quite a slowdown, glyphfontfile {\edef\askedsymbolfont{\truefontname{\glyphfontfile{#1}} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% - \ifcsname\??ss->\askedsymbolfont\endcsname - \csname\??ss->\askedsymbolfont\endcsname + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname \else \dodefinesymbolicfont \fi} \def\setdirectsymbolicfont#1% {\edef\askedsymbolfont{\truefontname{#1} at \the\dimexpr\currentfontbodyscale\dimexpr\fontbody}% - \ifcsname\??ss->\askedsymbolfont\endcsname - \csname\??ss->\askedsymbolfont\endcsname + \ifcsname\??symbolfont\askedsymbolfont\endcsname + \csname\??symbolfont\askedsymbolfont\endcsname \else \dodefinesymbolicfont \fi} @@ -4108,7 +4122,7 @@ \def\dodefinesymbolicfont {\definefont[currentsymbolfont][\askedsymbolfont]% \currentsymbolfont - \global\expandafter\let\csname\??ss->\askedsymbolfont\endcsname\lastrawfontcall} + \global\expandafter\let\csname\??symbolfont\askedsymbolfont\endcsname\lastrawfontcall} \unexpanded\def\getnamedglyphstyled#1#2{{\setstyledsymbolicfont{#1}\ctxcommand{fontchar("#2")}}} \unexpanded\def\getnamedglyphdirect#1#2{{\setdirectsymbolicfont{#1}\ctxcommand{fontchar("#2")}}} @@ -4490,31 +4504,47 @@ % definitions .. no tagging here -\installcommandhandler \??cf {style} \??cf +\installcorenamespace{style} +\installcorenamespace{stylecheck} + +\installcommandhandler \??style {style} \??style \appendtoks - \letvalue{\??cf\currentstyle\s!check}\relax - \setuevalue{\e!start\currentstyle}{\begingroup\use_defined_style{\currentstyle}}% - \setuevalue{\e!stop \currentstyle}{\endgroup}% - \setuevalue {\currentstyle}{\groupedcommand{\use_defined_style{\currentstyle}}{}}% + \letvalue{\??stylecheck\currentstyle}\relax + \setuevalue{\e!start\currentstyle}{\apply_style_start{\currentstyle}}% + \setuevalue{\e!stop \currentstyle}{\apply_style_stop}% + \setuevalue {\currentstyle}{\apply_style_grouped{\currentstyle}}% no longer groupedcommand here \to \everydefinestyle +\unexpanded\def\apply_style_start#1% + {\begingroup + \use_defined_style{#1}} + +\unexpanded\def\apply_style_stop + {\endgroup} + +\unexpanded\def\apply_style_grouped#1% assumes that the next is { or \bgroup + {\bgroup + \def\g_style{\use_defined_style{#1}}% + \afterassignment\g_style + \let\nexttoken} + \unexpanded\def\use_defined_style#1% {\edef\currentstyle{#1}% \usestylestyleandcolor\c!style\c!color} \unexpanded\def\use_generic_style#1% - {\getparameters[\??cf][\c!style=,\c!color=,#1]% - \dousestyleparameter\@@cfstyle - \dousecolorparameter\@@cfcolor} + {\let\currentstyle\s!unknown % reasonable generic tag + \setupcurrentstyle[\c!style=,\c!color=,#1]% + \usestylestyleandcolor\c!style\c!color} % commands -\unexpanded\def\style[#1]% +\unexpanded\def\style[#1]% as this is can be a switch we use groupedcommand {\csname style_% \ifcsname#1\endcsname nop% - \else\ifcsname\??cf#1\s!check\endcsname + \else\ifcsname\??stylecheck#1\endcsname use% \else yes% @@ -4534,7 +4564,7 @@ \csname start_style_% \ifcsname#1\endcsname nop% - \else\ifcsname\??cf#1\s!check\endcsname + \else\ifcsname\??stylecheck#1\endcsname use% \else yes% diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv index 2e7e497e2..754ea70d8 100644 --- a/tex/context/base/grph-trf.mkiv +++ b/tex/context/base/grph-trf.mkiv @@ -70,7 +70,11 @@ % we can let sx/sy win (first check) -\installcommandhandler \??xy {scale} \??xy % we can have instances +\installcorenamespace{scale} +\installcorenamespace{scalegrid} +\installcorenamespace{scalenorm} + +\installcommandhandler \??scale {scale} \??scale % we can have instances \setupscale [\c!sx=1, @@ -112,7 +116,7 @@ \dowithnextboxcs\transforms_scale_finish\hbox} \def\transforms_scale_finish - {% + {% todo: p_scale_ \edef\p_scale {\scaleparameter\c!scale }% \edef\p_xscale {\scaleparameter\c!xscale }% \edef\p_yscale {\scaleparameter\c!yscale }% @@ -251,18 +255,18 @@ \xdef\finalscaleboxxscale {\withoutpt\the\dimexpr\m_transforms_scale_temp_x\points/\plushundred\relax}% \xdef\finalscaleboxyscale {\withoutpt\the\dimexpr\m_transforms_scale_temp_y\points/\plushundred\relax}} -\setvalue{\??xy:\c!grid:\v!yes }{\getnoflines \d_transforms_scale_used_y_size\edef\p_height{\the\noflines\lineheight}} -\setvalue{\??xy:\c!grid:\v!height }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+\strutdepth}} -\setvalue{\??xy:\c!grid:\v!depth }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight-\strutdepth}} -\setvalue{\??xy:\c!grid:\v!halfline}{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+.5\lineheight}} -\setvalue{\??xy:\c!grid:\v!fit }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\noflines\lineheight}} -\letvalue{\??xy:\c!grid:\empty }\donothing +\setvalue{\??scalegrid\v!yes }{\getnoflines \d_transforms_scale_used_y_size\edef\p_height{\the\noflines\lineheight}} +\setvalue{\??scalegrid\v!height }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+\strutdepth}} +\setvalue{\??scalegrid\v!depth }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight-\strutdepth}} +\setvalue{\??scalegrid\v!halfline}{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\dimexpr\noflines\lineheight+.5\lineheight}} +\setvalue{\??scalegrid\v!fit }{\getrawnoflines\d_transforms_scale_used_y_size\edef\p_height{\the\noflines\lineheight}} +\letvalue{\??scalegrid\empty }\donothing \def\transforms_scale_check_parameters % resolve self referencing loops {\ifx\p_maxwidth \empty\else \edef\p_maxwidth {\the\dimexpr\p_maxwidth }\fi \ifx\p_maxheight\empty\else \edef\p_maxheight{\the\dimexpr\p_maxheight }\fi \ifx\p_lines \empty\else \edef\p_height {\the\dimexpr\p_lines\lineheight}\fi - \getvalue{\??xy:\c!grid:\scaleparameter\c!grid}} + \getvalue{\??scalegrid\scaleparameter\c!grid}} \def\transforms_scale_by_nature % where ! ! ! ! ! {\ifx\p_width \empty\else \global\d_transforms_scale_used_x_size\p_width \fi @@ -407,15 +411,15 @@ \fi} \def\transforms_scale_calculate_norm#1#2% todo: swap 1 and 2 and pass one less - {\csname\??ef:n:\ifcsname\??ef:n:#2\endcsname#2\else\s!unknown\fi\endcsname#1#2} + {\csname\??scalenorm\ifcsname\??scalenorm#2\endcsname#2\else\s!unknown\fi\endcsname#1#2} -\setvalue{\??ef:n:\v!max }#1#2#3#4#5{\global#1#4} -\setvalue{\??ef:n:\v!fit }#1#2#3#4#5{\global#1#5} -\setvalue{\??ef:n:\v!broad }#1#2#3#4#5{\global#1\dimexpr#5-4\@@exbodyfont\relax} -\setvalue{\??ef:n:\s!unknown}#1#2#3#4#5{\global#1\dimexpr#2\dimexpr\@@exbodyfont/10\relax\relax} % brr ex -\setvalue{\??ef:n:\v!auto }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} -\setvalue{\??ef:n:\empty }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} -\setvalue{\??ef:n:\s!default}#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} +\setvalue{\??scalenorm\v!max }#1#2#3#4#5{\global#1#4} +\setvalue{\??scalenorm\v!fit }#1#2#3#4#5{\global#1#5} +\setvalue{\??scalenorm\v!broad }#1#2#3#4#5{\global#1\dimexpr#5-4\@@exbodyfont\relax} +\setvalue{\??scalenorm\s!unknown}#1#2#3#4#5{\global#1\dimexpr#2\dimexpr\@@exbodyfont/10\relax\relax} % brr ex +\setvalue{\??scalenorm\v!auto }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} +\setvalue{\??scalenorm\empty }#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} +\setvalue{\??scalenorm\s!default}#1#2#3#4#5{\ifx#3\empty\else\global#1#3\fi} \def\transforms_scale_calculate_scales#1#2#3#4% {\scratchdimen\dimexpr#1/\dimexpr#2/\plusthousand\relax\relax @@ -616,7 +620,7 @@ \setbox\nextbox\hbox % old {\advance\!!dimenc -\@@cpleftoffset % new ! \advance\!!dimend -\@@cpbottomoffset % new ! % - added - \hskip-\!!dimenc\lower\!!dimend\flushnextbox}% old + \hskip-\!!dimenc\lower\!!dimend\box\nextbox}% old \wd\nextbox\zeropoint \ht\nextbox\zeropoint \dp\nextbox\zeropoint @@ -631,7 +635,7 @@ \setbox\nextbox\hbox % new ! {\!!dimena-\@@cpleftoffset % new ! \!!dimenb \@@cpbottomoffset % new ! % - removed - \hskip\!!dimena\lower\!!dimenb\flushnextbox}% new ! + \hskip\!!dimena\lower\!!dimenb\box\nextbox}% new ! \wd\nextbox\!!dimena \ht\nextbox\!!dimenb \dp\nextbox\zeropoint @@ -686,10 +690,327 @@ {\dontshowcomposition \scratchdimen\wd\nextbox % better use an hbox (if no \forgetall, leftskip etc may creep in) - %\setbox\nextbox\vbox{\forgetall\dostartmirroring\hskip-\wd\nextbox\flushnextbox\dostopmirroring}% - \setbox\nextbox\hbox{\dostartmirroring\hskip-\wd\nextbox\flushnextbox\dostopmirroring}% + %\setbox\nextbox\vbox{\forgetall\dostartmirroring\hskip-\wd\nextbox\box\nextbox\dostopmirroring}% + \setbox\nextbox\hbox{\dostartmirroring\hskip-\wd\nextbox\box\nextbox\dostopmirroring}% \wd\nextbox\scratchdimen \box\nextbox \egroup} +%D A couple of examples, demonstrating how the depth is +%D taken care of: +%D +%D \startbuffer +%D test\rotate[frame=on, rotation=0] {gans}% +%D test\rotate[frame=on, rotation=90] {gans}% +%D test\rotate[frame=on, rotation=180]{gans}% +%D test\rotate[frame=on, rotation=270]{gans}% +%D test +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +% When we rotate over arbitrary angles, we need to relocate the +% resulting box because rotation brings that box onto the negative +% axis. The calculations (mostly sin and cosine) need to be tuned for +% the way a box is packages (i.e. the refence point). A typical example +% of drawing, scribbling, and going back to the days of school math. +% +% We do a bit more calculations than needed, simply because that way +% it's easier to debug the code. + +% Cleanup in progress ... todo: less boxing + +\installcorenamespace {rotate} +\installcorenamespace {rotatelocation} +\installcorenamespace {rotatepreset} + +% we can alias these to \d_layers-* to save some dimens or maybe have a generic +% set of scratch variables + +% maybe just \rotation_... + +\newdimen\d_transforms_rotation_x_size +\newdimen\d_transforms_rotation_y_size +\newdimen\d_transforms_rotation_x_offset +\newdimen\d_transforms_rotation_y_offset +\newdimen\d_transforms_rotation_x_position +\newdimen\d_transforms_rotation_y_position + +\newdimen\d_transforms_rotation_used_height + +\let\d_transforms_rotation_width \!!widtha +\let\d_transforms_rotation_height\!!heighta +\let\d_transforms_rotation_depth \!!deptha + +\let\d_transforms_rotation_saved_width \!!widthb +\let\d_transforms_rotation_saved_height\!!heightb +\let\d_transforms_rotation_saved_depth \!!depthb + +\newconditional\c_transforms_rotation_obey_depth +\newconditional\c_transforms_rotation_not_fit +\newconditional\c_transforms_rotation_center + +\installframedcommandhandler \??rotate {rotate} \??rotate + +\setuprotate + [\c!rotation=90, + \c!location=\v!normal, + \c!width=\v!fit, + \c!height=\v!fit, + \c!offset=\v!overlay, + \c!frame=\v!off] + +\let\p_rotation_location\empty +\let\p_rotation_rotation\empty + +\unexpanded\def\rotate % \bgroup: \rotate kan argument zijn + {\bgroup + \dosingleempty\transforms_rotate} + +\def\transforms_rotate[#1]% + {\iffirstargument + \setupcurrentrotate[#1]% + \fi + \edef\p_rotation_location{\rotateparameter\c!location}% + \edef\p_rotation_rotation{\rotateparameter\c!rotation}% + \csname\??rotatelocation + \ifcsname\??rotatelocation\p_rotation_location\endcsname\p_rotation_location\else\v!default\fi + \endcsname} + +\def\transforms_rotate_framed + {\resetrotateparameter\c!location + \dowithnextboxcs\transforms_rotate_finish\vbox + \inheritedrotateframed} + +\def\transforms_rotate_normal + {\dowithnextboxcs\transforms_rotate_finish\vbox} + +\def\transforms_rotate_finish + {\transforms_rotation_finish_indeed + \egroup} + +\setvalue{\??rotatelocation\v!depth}% + {\setfalse\c_transforms_rotation_not_fit + \setfalse\c_transforms_rotation_center + \settrue \c_transforms_rotation_obey_depth + \transforms_rotate_normal} + +\setvalue{\??rotatelocation\v!fit}% + {\settrue \c_transforms_rotation_not_fit + \setfalse\c_transforms_rotation_center + \settrue \c_transforms_rotation_obey_depth + \transforms_rotate_normal} + +\setvalue{\??rotatelocation\v!broad}% + {\setfalse\c_transforms_rotation_not_fit + \setfalse\c_transforms_rotation_center + \setfalse\c_transforms_rotation_obey_depth + \transforms_rotate_normal} + +\setvalue{\??rotatelocation\v!high}% + {\setfalse\c_transforms_rotation_not_fit + \setfalse\c_transforms_rotation_center + \setfalse\c_transforms_rotation_obey_depth + \transforms_rotate_framed} + +\setvalue{\??rotatelocation\v!middle}% + {\setfalse\c_transforms_rotation_not_fit + \settrue \c_transforms_rotation_center + \setfalse\c_transforms_rotation_obey_depth % hm, depth ? + \transforms_rotate_normal} + +\setvalue{\??rotatelocation\v!default}% + {\setfalse\c_transforms_rotation_not_fit + \setfalse\c_transforms_rotation_center + \settrue \c_transforms_rotation_obey_depth + \transforms_rotate_framed} + +\def\dorotatebox#1% {angle} \hbox/\vbox/\vtop % a fast low level one + {\ifcase#1\relax + \expandafter\gobbleoneargument + \else + \expandafter\transforms_rotation_box + \fi{#1}} + +\def\transforms_rotation_box#1% {angle} \hbox/\vbox/\vtop + {\bgroup + \hbox\bgroup % compatibility hack + \edef\p_rotation_rotation{#1}% + \dowithnextboxcs\transforms_rotation_finish} + +\def\transforms_rotation_finish + {\getvalue{\??rotatelocation\v!broad}% + \transforms_rotation_finish_indeed + \egroup + \egroup} + +\def\transforms_rotation_finish_indeed + {\hbox\bgroup + \ifx\p_rotation_rotation\empty + \transforms_rotation_finish_nop + \else + \transforms_rotation_finish_yes + \fi + \egroup} + +\def\transforms_rotation_finish_nop + {\boxcursor\box\nextbox} + +\setvalue{\??rotatepreset\v!left}% + {\edef\p_rotation_rotation{\doifoddpageelse{90}{270}}} + +\setvalue{\??rotatepreset\v!right}% + {\edef\p_rotation_rotation{\doifoddpageelse{270}{90}}} + +\setvalue{\??rotatepreset\v!inner}% + {\signalrightpage + \doifrightpageelse{\def\p_rotation_rotation{270}}{\def\p_rotation_rotation{90}}} + +\setvalue{\??rotatepreset\v!outer}% + {\signalrightpage + \doifrightpageelse{\def\p_rotation_rotation{90}}{\def\p_rotation_rotation{270}}} + +\setvalue{\??rotatepreset\v!default}% + {\edef\p_rotation_rotation{\realnumber{\p_rotation_rotation}}}% get rid of leading zeros and spaces + +\def\transforms_rotation_finish_yes + {\csname\??rotatepreset + \ifcsname\??rotatepreset\p_rotation_rotation\endcsname\p_rotation_rotation\else\v!default\fi + \endcsname + \setbox\nextbox\vbox{\box\nextbox}% not really needed + \dontshowcomposition + \dontcomplain + \ifconditional\c_transforms_rotation_center + \d_transforms_rotation_saved_width \wd\nextbox + \d_transforms_rotation_saved_height\ht\nextbox + \d_transforms_rotation_saved_depth \dp\nextbox + \setbox\nextbox\vbox{\vskip.5\ht\nextbox\hskip-.5\wd\nextbox\box\nextbox}% + \smashbox\nextbox + \fi + \d_transforms_rotation_width \wd\nextbox + \d_transforms_rotation_height\ht\nextbox + \d_transforms_rotation_depth \dp\nextbox + \setbox\nextbox\vbox{\hbox{\raise\dp\nextbox\box\nextbox}}% + \d_transforms_rotation_used_height \ht\nextbox + % much of the next happens in lua (all the sin and cos) so we can do that in + % one go if needed + \setcalculatedcos\cos\p_rotation_rotation + \setcalculatedsin\sin\p_rotation_rotation + \ifdim\sin\points>\zeropoint + \ifdim\cos\points>\zeropoint + \transforms_rotation_calculate_a + \transforms_rotation_apply + \else + \transforms_rotation_calculate_b + \transforms_rotation_apply + \wd\nextbox\ifconditional\c_transforms_rotation_not_fit\sin\d_transforms_rotation_depth\else\d_transforms_rotation_x_size\fi + \fi + \else + \ifdim\cos\points<\zeropoint + \transforms_rotation_calculate_c + \transforms_rotation_apply + \wd\nextbox\ifconditional\c_transforms_rotation_not_fit\negated\sin\d_transforms_rotation_height\else\d_transforms_rotation_x_size\fi + \else\ifdim\sin\points=\zeropoint + \transforms_rotation_calculate_d + \transforms_rotation_apply + % no wd ? + \else + \transforms_rotation_calculate_e + \transforms_rotation_apply + \wd\nextbox\ifconditional\c_transforms_rotation_not_fit\negated\sin\d_transforms_rotation_height\else\d_transforms_rotation_x_size\fi + \fi\fi + \fi + \ifconditional\c_transforms_rotation_center + \setbox\nextbox\vbox{\vskip-.5\d_transforms_rotation_saved_height\hskip.5\d_transforms_rotation_saved_height\box\nextbox}% + \wd\nextbox\d_transforms_rotation_saved_width + \ht\nextbox\d_transforms_rotation_saved_height + \dp\nextbox\d_transforms_rotation_saved_depth + \fi + \boxcursor\box\nextbox} + +\def\transforms_rotation_calculate_a + {\d_transforms_rotation_x_size\dimexpr\cos\d_transforms_rotation_width+\sin\d_transforms_rotation_used_height\relax + \d_transforms_rotation_y_size\dimexpr\sin\d_transforms_rotation_width+\cos\d_transforms_rotation_used_height\relax + \d_transforms_rotation_x_position\zeropoint + \d_transforms_rotation_y_position\cos\d_transforms_rotation_used_height + \ifconditional\c_transforms_rotation_not_fit + \d_transforms_rotation_x_offset\dimexpr\negated\sin\d_transforms_rotation_used_height+\sin\d_transforms_rotation_depth\relax + \fi + \ifconditional\c_transforms_rotation_obey_depth + \d_transforms_rotation_y_offset\cos\d_transforms_rotation_depth + \fi} + +\def\transforms_rotation_calculate_b + {\d_transforms_rotation_x_size\dimexpr\negated\cos\d_transforms_rotation_width+\sin\d_transforms_rotation_used_height\relax + \d_transforms_rotation_y_size\dimexpr\sin\d_transforms_rotation_width+\negated\cos\d_transforms_rotation_used_height\relax + \d_transforms_rotation_x_position\negated\cos\d_transforms_rotation_width + \d_transforms_rotation_y_position\zeropoint + \ifconditional\c_transforms_rotation_not_fit + \d_transforms_rotation_x_offset\dimexpr-\d_transforms_rotation_x_size+\sin\d_transforms_rotation_depth\relax + \fi + \ifconditional\c_transforms_rotation_obey_depth + \d_transforms_rotation_y_offset\negated\cos\d_transforms_rotation_height + \fi} + +\def\transforms_rotation_calculate_c + {\d_transforms_rotation_x_size\dimexpr\negated\cos\d_transforms_rotation_width+\negated\sin\d_transforms_rotation_used_height\relax + \d_transforms_rotation_y_size\dimexpr\negated\sin\d_transforms_rotation_width+\negated\cos\d_transforms_rotation_used_height\relax + \d_transforms_rotation_x_position\d_transforms_rotation_x_size + \d_transforms_rotation_y_position\negated\sin\d_transforms_rotation_width + \ifconditional\c_transforms_rotation_not_fit + \d_transforms_rotation_x_offset\dimexpr-\d_transforms_rotation_x_size+\negated\sin\d_transforms_rotation_height\relax + \fi + \ifconditional\c_transforms_rotation_obey_depth + \d_transforms_rotation_y_offset\dimexpr\d_transforms_rotation_y_size+\cos\d_transforms_rotation_depth\relax + \fi} + +\def\transforms_rotation_calculate_d + {\d_transforms_rotation_x_size\dimexpr\cos\d_transforms_rotation_width+\negated\sin\d_transforms_rotation_used_height\relax + \d_transforms_rotation_y_size\dimexpr\negated\sin\d_transforms_rotation_width+\cos\d_transforms_rotation_used_height\relax + \d_transforms_rotation_x_position\zeropoint + \d_transforms_rotation_y_position\d_transforms_rotation_y_size + \d_transforms_rotation_x_offset\zeropoint + \ifconditional\c_transforms_rotation_obey_depth + \d_transforms_rotation_y_offset\d_transforms_rotation_depth + \fi} + +\def\transforms_rotation_calculate_e + {\d_transforms_rotation_x_size\dimexpr\cos\d_transforms_rotation_width+\negated\sin\d_transforms_rotation_used_height\relax + \d_transforms_rotation_y_size\dimexpr\negated\sin\d_transforms_rotation_width+\cos\d_transforms_rotation_used_height\relax + \d_transforms_rotation_x_position\negated\sin\d_transforms_rotation_used_height + \d_transforms_rotation_y_position\d_transforms_rotation_y_size + \ifconditional\c_transforms_rotation_not_fit + \d_transforms_rotation_x_offset\dimexpr-\d_transforms_rotation_x_size+\negated\sin\d_transforms_rotation_height\relax + \fi + \ifconditional\c_transforms_rotation_obey_depth + \d_transforms_rotation_y_offset\negated\sin\d_transforms_rotation_depth + \fi} + +\def\transforms_rotation_apply + {\setbox\nextbox\vbox to \d_transforms_rotation_y_size + {\vfill + \hbox to \d_transforms_rotation_x_size + {\dostartrotation\p_rotation_rotation + \wd\nextbox\zeropoint + \ht\nextbox\zeropoint + \box\nextbox + \dostoprotation + \hfill}% + \kern\d_transforms_rotation_y_position}% + \setbox\nextbox\hbox + {\kern\dimexpr\d_transforms_rotation_x_position+\d_transforms_rotation_x_offset\relax + \lower\d_transforms_rotation_y_offset\box\nextbox}} + +% \dostepwiserecurse{0}{360}{10} +% {\startlinecorrection[blank] +% \hbox +% {\expanded{\setuprotate[rotation=\recurselevel]}% +% \traceboxplacementtrue +% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=depth] {\ruledhbox{\bfb (depth)}}}}% +% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=fit] {\ruledhbox{\bfb (fit)}}}}% +% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=broad] {\ruledhbox{\bfb (broad)}}}}% +% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=normal]{\ruledhbox{\bfb (normal)}}}}% +% \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=high] {\ruledhbox{\bfb (high)}}}}} +% \stoplinecorrection} + \protect \endinput diff --git a/tex/context/base/hand-ini.mkiv b/tex/context/base/hand-ini.mkiv index cf659389b..e9a6e087c 100644 --- a/tex/context/base/hand-ini.mkiv +++ b/tex/context/base/hand-ini.mkiv @@ -39,36 +39,35 @@ %D New stuff. -\unexpanded\def\setupfontexpansion {\dodoubleargument\dosetupfontexpansion } -\unexpanded\def\setupfontprotrusion{\dodoubleargument\dosetupfontprotrusion} +\unexpanded\def\setupfontexpansion {\dodoubleargument\fonts_expansion_setup } +\unexpanded\def\setupfontprotrusion{\dodoubleargument\fonts_protrusion_setup} -\def\dosetupfontexpansion [#1][#2]{\ctxcommand{setupfontexpansion ("#1","#2")}} -\def\dosetupfontprotrusion[#1][#2]{\ctxcommand{setupfontprotrusion("#1","#2")}} +\def\fonts_expansion_setup [#1][#2]{\ctxcommand{setupfontexpansion ("#1","#2")}} +\def\fonts_protrusion_setup[#1][#2]{\ctxcommand{setupfontprotrusion("#1","#2")}} % \setupfontprotrusion[quality-upright][vector=quality] % \setupfontprotrusion[quality-slanted][vector=quality,right=1.5] -%D Old stuff. +\let\pdfadjustspacing\relax \newcount\pdfadjustspacing % a little bit protection +\let\pdfprotrudechars\relax \newcount\pdfprotrudechars % a little bit protection -\def\fonthandlingerror{\writestatus\m!fonts{font handling is replaced by features in mkiv}} +\def\fonts_expansion_enable {\normalpdfadjustspacing\plustwo } +\def\fonts_expansion_disable {\normalpdfadjustspacing\zerocount} +\def\fonts_protruding_enable {\normalpdfprotrudechars\plustwo } +\def\fonts_protruding_disable{\normalpdfprotrudechars\zerocount} -\def\enableadjusting {\pdfadjustspacing\plustwo } \let\enableexpansion \enableadjusting -\def\disableadjusting {\pdfadjustspacing\zerocount} \let\disableexpansion\disableadjusting -\def\enableprotruding {\pdfprotrudechars\plustwo } -\def\disableprotruding{\pdfprotrudechars\zerocount} +\appendtoks \fonts_expansion_disable \to \everyforgetall % Here or not here? +\appendtoks \fonts_protruding_disable \to \everyforgetall % Here or not here? -\appendtoks \disableadjusting \to \everyforgetall % Here or not here? -\appendtoks \disableprotruding \to \everyforgetall % Here or not here? - -\unexpanded\def\startfonthandling #1{\fonthandlingerror\fonthandlingerror\gobbleuntil\stopfonthandling} % can't happen -\unexpanded\def\definefonthandling {\dotripleempty\dodefinefonthandling} -\unexpanded\def\setupfonthandling {\dodoubleempty\dosetupfonthandling } -\def\dodefinefonthandling[#1][#2][#3]{\fonthandlingerror} -\def\dosetupfonthandling [#1][#2]{\fonthandlingerror} -\def\usehandling [#1]{\fonthandlingerror} - -%D Just to be sure, maybe users use it: - -\let\fonthandling\empty +% \def\fonthandlingerror{\writestatus\m!fonts{font handling is replaced by features in mkiv}} +% +% \let\fonthandling\empty +% +% \unexpanded\def\startfonthandling #1{\fonthandlingerror\fonthandlingerror\gobbleuntil\stopfonthandling} % can't happen +% \unexpanded\def\definefonthandling {\dotripleempty\dodefinefonthandling} +% \unexpanded\def\setupfonthandling {\dodoubleempty\dosetupfonthandling } +% \def\dodefinefonthandling[#1][#2][#3]{\fonthandlingerror} +% \def\dosetupfonthandling [#1][#2]{\fonthandlingerror} +% \def\usehandling [#1]{\fonthandlingerror} \protect \endinput diff --git a/tex/context/base/java-ini.lua b/tex/context/base/java-ini.lua index 8ffabab05..ff9afe239 100644 --- a/tex/context/base/java-ini.lua +++ b/tex/context/base/java-ini.lua @@ -214,3 +214,11 @@ function javascripts.usescripts(name) } end end + +-- interface + +commands.storejavascriptcode = interactions.javascripts.storecode +commands.storejavascriptpreamble = interactions.javascripts.storepreamble +commands.addtojavascriptpreamble = interactions.javascripts.addtopreamble +commands.usejavascriptpreamble = interactions.javascripts.usepreamblenow +commands.usejavascriptscripts = interactions.javascripts.usescripts diff --git a/tex/context/base/java-ini.mkiv b/tex/context/base/java-ini.mkiv index 16d145ba0..76df468e7 100644 --- a/tex/context/base/java-ini.mkiv +++ b/tex/context/base/java-ini.mkiv @@ -110,10 +110,10 @@ \obeylualines \obeyluatokens \def\u{\letterbackslash u}% - \dostartJScode} + \javascripts_start_code} -\long\def\dostartJScode#1\stopJScode - {\normalexpanded{\endgroup\ctxlua{interactions.javascripts.storecode(\!!bs#1\!!es)}}} +\def\javascripts_start_code#1\stopJScode + {\normalexpanded{\endgroup\ctxcommand{storejavascriptcode(\!!bs#1\!!es)}}} \let\stopJScode\relax @@ -122,16 +122,15 @@ \obeylualines \obeyluatokens \def\u{\letterbackslash u}% - \dostartJSpreamble} + \javascripts_start_preamble} -\long\def\dostartJSpreamble#1\stopJSpreamble - {\normalexpanded{\endgroup\ctxlua{interactions.javascripts.storepreamble(\!!bs#1\!!es)}}} +\def\javascripts_start_preamble#1\stopJSpreamble + {\normalexpanded{\endgroup\ctxcommand{storejavascriptpreamble(\!!bs#1\!!es)}}} \let\stopJSpreamble\relax -\def\setJSpreamble #1#2{\ctxlua{interactions.javascripts.storepreamble ("#1",\!!bs#2\!!es)}} -\def\addtoJSpreamble #1#2{\ctxlua{interactions.javascripts.addtopreamble ("#1",\!!bs#2\!!es)}} -\def\douseJSpreamblenow#1{\ctxlua{interactions.javascripts.usepreamblenow("#1")}} +\unexpanded\def\setJSpreamble #1#2{\ctxcommand{storejavascriptpreamble("#1",\!!bs#2\!!es)}} +\unexpanded\def\addtoJSpreamble#1#2{\ctxcommand{addtojavascriptpreamble("#1",\!!bs#2\!!es)}} %D \macros %D {useJSscripts} @@ -148,11 +147,11 @@ %D %D The not so complicated implementation of this macro is: -\def\douseJSscripts[#1][#2]% - {\ctxlua{interactions.javascripts.usescripts(\!!bs#1\!!es)}% - \douseJSpreamblenow{#2}} - \def\useJSscripts - {\dodoubleempty\douseJSscripts} + {\dodoubleempty\javascripts_use_scripts} + +\def\javascripts_use_scripts[#1][#2]% + {\ctxcommand{usejavascriptscripts(\!!bs#1\!!es)}% two steps as this one calls tex code + \ctxcommand{usejavascriptpreamble("#2")}} % so this one comes later \protect \endinput diff --git a/tex/context/base/l-math.lua b/tex/context/base/l-math.lua index 48089957f..43f60b56b 100644 --- a/tex/context/base/l-math.lua +++ b/tex/context/base/l-math.lua @@ -29,6 +29,6 @@ if not math.sind then end if not math.odd then - function math.odd (n) return n % 2 == 0 end - function math.even(n) return n % 2 ~= 0 end + function math.odd (n) return n % 2 ~= 0 end + function math.even(n) return n % 2 == 0 end end diff --git a/tex/context/base/lang-ini.mkiv b/tex/context/base/lang-ini.mkiv index 6f77eee8d..f010b3c20 100644 --- a/tex/context/base/lang-ini.mkiv +++ b/tex/context/base/lang-ini.mkiv @@ -39,8 +39,8 @@ % \testlanguage[de] \testlanguage[de-de] \testlanguage[de-at] \testlanguage[de-ch] \page % \testlanguage[en] \testlanguage[us] \testlanguage[en-us] \testlanguage[uk] \testlanguage[en-gb] \page -\ifx\nonfrenchspacing\undefined \let\nonfrenchspacing\relax \fi -\ifx\frenchspacing \undefined \let\frenchspacing \relax \fi +\ifdefined\nonfrenchspacing\else \let\nonfrenchspacing\relax \fi +\ifdefined\frenchspacing \else \let\frenchspacing \relax \fi %D When loading hyphenation patterns, \TEX\ assign a number to %D each loaded table, starting with~0. Switching to a specific @@ -79,6 +79,13 @@ %D \macros %D {defaultlanguage,languageparameter,specificlanguageparameter} +%D We don't use the commandhandler here (yet) because we have +%D a rather special fallback mechanism so quite some compatibility +%D testing is needed. + +\installcorenamespace{language} +\installcorenamespace{languagelinked} + \def\defaultlanguage#1% {\ifcsname\??la#1\s!default\endcsname \expandafter\defaultlanguage\csname\??la#1\s!default\endcsname @@ -155,10 +162,6 @@ %D implementations support run time addition of patterns to a %D preloaded format). -% move to lua end - -\def\dodoinstalllanguage#1#2% - {\ifcsname#1\endcsname\else\setuvalue{#1}{\complexlanguage[#2]}\fi} %D \macros %D {preloadlanguages} @@ -173,48 +176,50 @@ \def\installedlanguages{\ctxlua{languages.installed()}} -\def\doiflanguageelse#1% +\unexpanded\def\doiflanguageelse#1% {\ifcsname\??la#1\c!state\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\def\doinstalllanguage[#1][#2]% +\def\reallanguagetag#1% + {\ifcsname\??languagelinked#1\endcsname\csname\??languagelinked#1\endcsname\else#1\fi} + +% \language[#1] gave unwanted side effect of loading language specifics + +\unexpanded\def\installlanguage + {\dodoubleargument\languages_install} + +\def\languages_install[#1][#2]% {\doifassignmentelse{#2} {\doiflanguageelse{#1} {\getparameters[\??la#1][#2]} - {\setvalue{\l!prefix!#1}{#1}% - \dodoinstalllanguage{#1}{#1}% + {\setvalue{\??languagelinked#1}{#1}% + \languages_install_indeed{#1}{#1}% \getparameters[\??la#1][\c!state=\v!start,#2]}% \edef\currentsetuplanguage{#1}% \ctxlua{languages.define("#1","\specificlanguageparameter{#1}\s!default")}% \the\everysetuplanguage} - {\setvalue{\l!prefix!#1}{#2}% + {\setvalue{\??languagelinked#1}{#2}% \ctxlua{languages.synonym("#1","#2")}% - %\getparameters[\??la#1][\s!default=#2]% - \dodoinstalllanguage{#1}{#2}}} - -\def\reallanguagetag#1% - {\ifcsname\l!prefix!#1\endcsname\csname\l!prefix!#1\endcsname\else#1\fi} - -% \language[#1] gave unwanted side effect of loading language specifics + \languages_install_indeed{#1}{#2}}} -\def\installlanguage - {\dodoubleargument\doinstalllanguage} +\def\languages_install_indeed#1#2% + {\ifcsname#1\endcsname\else\setuvalue{#1}{\complexlanguage[#2]}\fi} %D When the second argument is a language identifier, a %D synonym is created. This feature is present because we %D used dutch mnemonics in the dutch version, but nowadays %D conform a standard. -\def\doifpatternselse#1% - {\bgroup % will change +\unexpanded\def\doifpatternselse#1% + {\begingroup % will change \language[#1]% \ifnum\normallanguage>\zerocount - \bgroup\expandafter\firstoftwoarguments + \endgroup\expandafter\firstoftwoarguments \else - \bgroup\expandafter\secondoftwoarguments + \endgroup\expandafter\secondoftwoarguments \fi} %D \macros @@ -227,11 +232,13 @@ %D Beware, this command can only be used when a language is installed. \unexpanded\def\setuplanguage - {\dodoubleempty\dosetuplanguage} + {\dodoubleempty\languages_setup} -\ifdefined\docomplexlanguage \else \let\docomplexlanguage\relax \fi +\ifdefined\languages_synchronize \else + \let\languages_synchronize\relax % be nice for setups till we have one +\fi -\def\dosetuplanguage[#1][#2]% +\def\languages_setup[#1][#2]% {\ifsecondargument \pushmacro\currentlanguage % can be default \edef\currentsetuplanguage{\reallanguagetag{#1}}% @@ -239,13 +246,12 @@ \the\everysetuplanguage \popmacro\currentlanguage %\doif\currentsetuplanguage\currentlanguage we can have influenced inheritance (default) - \docomplexlanguage \else \let\currentsetuplanguage\currentlanguage \getparameters[\??la\currentsetuplanguage][#1]% \the\everysetuplanguage - \docomplexlanguage - \fi} + \fi + \languages_synchronize} \appendtoks \ctxlua{languages.setdirty("\currentsetuplanguage")}% @@ -263,6 +269,9 @@ \c!righthyphen=-, \c!hyphen=-, \c!spacing=\v!packed, + \c!compoundhyphen=\compoundhyphen, + \c!rightcompoundhyphen=\compoundhyphen, + \c!leftcompoundhyphen=, \c!midsentence=---, \c!leftsentence=---, \c!rightsentence=---, @@ -279,14 +288,6 @@ \c!date={\v!year,\ ,\v!month,\ ,\v!day}, \c!text=Ag] -% rather new, split and per language - -\setuplanguage - [\s!default] - [\c!compoundhyphen=\compoundhyphen, - \c!rightcompoundhyphen=\compoundhyphen, - \c!leftcompoundhyphen=] - % to be tested: % % \setuplanguage @@ -352,7 +353,7 @@ \newtoks \everylanguage -\def\docomplexlanguage% assumes that \currentlanguage is set % % % use different name as complex +\def\languages_synchronize% assumes that \currentlanguage is set % % % use different name as complex {\normallanguage\ctxcommand{languagenumber(% "\currentlanguage",% "\defaultlanguage\currentlanguage",% @@ -398,40 +399,38 @@ % we will also permit access by the other names -\def\complexlanguage[#1]% +\unexpanded\def\languages_set_specified[#1]% {\edef\askedlanguage{#1}% \ifx\askedlanguage\empty \else - \ifcsname\l!prefix!\askedlanguage\endcsname - \edef\askedlanguage{\csname\l!prefix!\askedlanguage\endcsname}% + \ifcsname\??languagelinked\askedlanguage\endcsname + \edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}% \ifx\currentlanguage\askedlanguage \else \setcurrentlanguage\currentmainlanguage\askedlanguage - \docomplexlanguage + \languages_synchronize \fi \else \showmessage\m!languages6{#1}% \fi \fi} -\let\simplelanguage\normallanguage - -\definecomplexorsimple\language +\unexpanded\def\language + {\doifnextoptionalelse\languages_set_specified\normallanguage} \newcount\mainlanguagenumber -\def\mainlanguage[#1]% +\unexpanded\def\mainlanguage[#1]% {\edef\askedlanguage{#1}% \ifx\askedlanguage\empty \else - \ifcsname\l!prefix!\askedlanguage\endcsname - \edef\askedlanguage{\csname\l!prefix!\askedlanguage\endcsname}% + \ifcsname\??languagelinked\askedlanguage\endcsname + \edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}% \ifx\currentlanguage\askedlanguage - \ifx\currentmainlanguage\askedlanguage - \else + \ifx\currentmainlanguage\askedlanguage \else \setcurrentlanguage\askedlanguage\askedlanguage - \docomplexlanguage + \languages_synchronize \fi \else \setcurrentlanguage\askedlanguage\askedlanguage - \docomplexlanguage + \languages_synchronize \fi \fi \fi @@ -560,11 +559,9 @@ %D is one of the few places outside the interface modules where %D \type{\startinterface} is used. -%D We default to english: - \setupcurrentlanguage[\s!en] -\def\initializemainlanguage +\unexpanded\def\initializemainlanguage {\mainlanguage[\currentlanguage]% \showmessage\m!languages9\currentlanguage} @@ -586,7 +583,7 @@ %D For the moment here: -\uchyph = 1 % also treat uppercase -\exhyphenchar=45 % to permit breaking at explicit hyphens +\uchyph 1 % also treat uppercase +\exhyphenchar 45 % to permit breaking at explicit hyphens \protect \endinput diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index 870ecd4f9..fcd25e9c8 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -65,6 +65,8 @@ %D %D The last two cases concern the current language. +\installcorenamespace{label} + \let\currentlabelcategory\empty \def\definelabelclass @@ -92,20 +94,20 @@ \ifnum#2=\plustwo \def#3{#5#4}% \def#5##1##2% ##1=language - {\ifcsname\??ml:\currentlabelcategory#1:##1:##2\endcsname - \csname\??ml:\currentlabelcategory#1:##1:##2\endcsname - \else\ifcsname\??ml:#1:##1:##2\endcsname - \csname\??ml:#1:##1:##2\endcsname + {\ifcsname\??label\currentlabelcategory#1:##1:##2\endcsname + \csname\??label\currentlabelcategory#1:##1:##2\endcsname + \else\ifcsname\??label#1:##1:##2\endcsname + \csname\??label#1:##1:##2\endcsname \else\ifcsname\??la#4\s!default\endcsname \expandafter#5\csname\??la#4\s!default\endcsname{##2}% - \else\ifcsname\??ml:\currentlabelcategory#1:##2\endcsname - \csname\??ml:\currentlabelcategory#1:##2\endcsname - \else\ifcsname\??ml:#1:##2\endcsname - \csname\??ml:#1:##2\endcsname - \else\ifcsname\??ml:\currentlabelcategory#1:\s!en:##2\endcsname - \csname\??ml:\currentlabelcategory#1:\s!en:##2\endcsname - \else\ifcsname\??ml:#1:\s!en:##2\endcsname - \csname\??ml:#1:\s!en:##2\endcsname + \else\ifcsname\??label\currentlabelcategory#1:##2\endcsname + \csname\??label\currentlabelcategory#1:##2\endcsname + \else\ifcsname\??label#1:##2\endcsname + \csname\??label#1:##2\endcsname + \else\ifcsname\??label\currentlabelcategory#1:\s!en:##2\endcsname + \csname\??label\currentlabelcategory#1:\s!en:##2\endcsname + \else\ifcsname\??label#1:\s!en:##2\endcsname + \csname\??label#1:\s!en:##2\endcsname \else ##2% \fi\fi\fi\fi\fi\fi\fi}% @@ -116,14 +118,14 @@ \else \unexpanded\def#3{#5#4}% \unexpanded\def#5##1##2% - {\ifcsname\??ml:#1:##1:##2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:##1:##2\endcsname + {\ifcsname\??label#1:##1:##2\endcsname + \expandafter\let\expandafter\thetextprefix\csname\??label#1:##1:##2\endcsname \else\ifcsname\??la#4\s!default\endcsname \expandafter#5\csname\??la#4\s!default\endcsname{##2}% - \else\ifcsname\??ml:#1:##2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:##2\endcsname - \else\ifcsname\??ml:#1:\s!en:##2\endcsname - \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:\s!en:##2\endcsname + \else\ifcsname\??label#1:##2\endcsname + \expandafter\let\expandafter\thetextprefix\csname\??label#1:##2\endcsname + \else\ifcsname\??label#1:\s!en:##2\endcsname + \expandafter\let\expandafter\thetextprefix\csname\??label#1:\s!en:##2\endcsname \else \let\thetextprefix\dummytextprefix \fi\fi\fi\fi}% @@ -181,7 +183,7 @@ \grabuntil{stop#1text}\start_some_text_prefix_indeed} \def\start_some_text_prefix_indeed#1% text (not special checking done here yet, only for long texts anyway) - {\expandafter\edef\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname{{\ctxlua{context(string.strip(\!!bs#1\!!es))}}\empty}} + {\expandafter\edef\csname\??label\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname{{\ctxlua{context(string.strip(\!!bs#1\!!es))}}\empty}} \def\setup_some_text_prefix[#1][#2]% {\ifsecondargument @@ -204,7 +206,7 @@ \expandafter\assign_some_text_prefix_yes \or % checking - \ifcsname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname + \ifcsname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname \expandafter\expandafter\expandafter\assign_some_text_prefix_nop \else \expandafter\expandafter\expandafter\assign_some_text_prefix_yes @@ -214,24 +216,27 @@ \expandafter\assign_some_text_prefix_dumb \fi{#1}} +\let\m_languages_label_left \empty +\let\m_languages_label_right\empty + \def\assign_some_text_prefix_yes#1[#2,#3,#4]% - {\edef\!!stringa{#2}% - \edef\!!stringb{#3}% - \ifx\!!stringb\empty - \ifx\!!stringa\empty - \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{\empty\empty}% + {\edef\m_languages_label_left {#2}% + \edef\m_languages_label_right{#3}% + \ifx\m_languages_label_right\empty + \ifx\m_languages_label_left\empty + \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{\empty\empty}% \else - \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}\empty}% + \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}\empty}% \fi \else - \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}{#3}}% + \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}{#3}}% \fi} \def\assign_some_text_prefix_nop#1[#2]% {} \def\assign_some_text_prefix_dumb#1[#2,#3]% - {\expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}} + {\expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}} \definelabelclass [head] [0] % titles \definelabelclass [label] [0] % texts diff --git a/tex/context/base/lang-mis.mkiv b/tex/context/base/lang-mis.mkiv index 71b23e580..094e9f971 100644 --- a/tex/context/base/lang-mis.mkiv +++ b/tex/context/base/lang-mis.mkiv @@ -13,6 +13,8 @@ \writestatus{loading}{ConTeXt Language Macros / Compounds} +%D More or less replaced. + %D \gdef\starttest#1\stoptest{\starttabulate[|l|l|p|]#1\stoptabulate} %D \gdef\test #1{\NC\detokenize{#1}\NC\hyphenatedword{#1}\NC#1\NC\NR} @@ -155,10 +157,9 @@ %D In the main \CONTEXT\ modules these can be tuned by a setup %D command. Watch the (maybe) better looking compound hyphen. -\ifx\compoundhyphen \undefined \def\compoundhyphen{\hbox{-\kern-.25ex-}} \fi - -\ifx\beginofsubsentence \undefined \def\beginofsubsentence{\hbox{---}} \fi -\ifx\endofsubsentence \undefined \def\endofsubsentence {\hbox{---}} \fi +\ifx\compoundhyphen \undefined \def\compoundhyphen {\hbox{-\kern-.25ex-}} \fi +\ifx\beginofsubsentence\undefined \def\beginofsubsentence{\hbox{---}} \fi +\ifx\endofsubsentence \undefined \def\endofsubsentence {\hbox{---}} \fi %D The last two variables are needed for subsentences %D |<|like this one|>| which we did not yet mention. @@ -167,11 +168,10 @@ %D compound characters like |-| or || to be separated from the %D words. \TEX\ hackers will recognise the next two macro's: -\ifx\prewordbreak \undefined \def\prewordbreak {\penalty\plustenthousand\hskip\zeropoint\relax} \fi -%ifx\postwordbreak \undefined \def\postwordbreak{\penalty\zerocount \prewordbreak } \fi -\ifx\postwordbreak \undefined \def\postwordbreak{\penalty\zerocount \hskip\zeropoint\relax} \fi - -\ifx\hspaceamount \undefined \def\hspaceamount#1#2{.16667em} \fi % language specific +\ifx\prewordbreak \undefined \def\prewordbreak {\penalty\plustenthousand\hskip\zeropoint\relax} \fi +%ifx\postwordbreak\undefined \def\postwordbreak {\penalty\zerocount \prewordbreak } \fi +\ifx\postwordbreak\undefined \def\postwordbreak {\penalty\zerocount \hskip\zeropoint\relax} \fi +\ifx\hspaceamount \undefined \def\hspaceamount#1#2{.16667em} \fi % language specific %D \macros %D {beginofsubsentencespacing,endofsubsentencespacing} @@ -196,20 +196,20 @@ %D |x_n-{1\over2}| &for ${1\over2}2xxx -\def\hyphenliketextmodediscretionary#1#2% +\def\languages_discretionary_hyphen_like#1#2% {\ifconditional\spaceafterdiscretionary \prewordbreak\hbox{#1}\relax \else\ifconditional\punctafterdiscretionary @@ -383,16 +385,16 @@ \fi\fi} \definetextmodediscretionary {} - {\hyphenliketextmodediscretionary\textmodehyphen\textmodehyphendiscretionary} + {\languages_discretionary_hyphen_like\textmodehyphen\textmodehyphendiscretionary} \definetextmodediscretionary - - {\hyphenliketextmodediscretionary\normalhyphen\normalhyphendiscretionary} + {\languages_discretionary_hyphen_like\normalhyphen\normalhyphendiscretionary} \definetextmodediscretionary _ - {\hyphenliketextmodediscretionary\composedhyphen\composedhyphendiscretionary} + {\languages_discretionary_hyphen_like\composedhyphen\composedhyphendiscretionary} \definetextmodediscretionary ) - {\hyphenliketextmodediscretionary{)}{\discretionary{-)}{}{)}}} + {\languages_discretionary_hyphen_like{)}{\discretionary{-)}{}{)}}} \definetextmodediscretionary ( {\ifdim\lastskip>\zeropoint @@ -456,10 +458,10 @@ %D \goto{Some||Long||Word} %D \stoptyping -\def\fakecompoundhyphen - {\def\|{\mathortext\vert\dofakecompoundhyphen}} +\unexpanded\def\fakecompoundhyphen + {\def\|{\mathortext\vert\languages_fake_compound_hyphen}} -\def\dofakecompoundhyphen +\def\languages_fake_compound_hyphen {\def##1|% {\doifelsenothing{##1}\compoundhyphen{##1}% \kern\compoundbreakpoint\allowbreak}} @@ -473,10 +475,10 @@ %D earlier, this one also looks ahead for spaces and grouping %D tokens. -\def\midworddiscretionary - {\futurelet\next\domidworddiscretionary} +\unexpanded\def\midworddiscretionary + {\futurelet\next\languages_mid_word_discretionary} -\def\domidworddiscretionary +\def\languages_mid_word_discretionary {\ifx\next\blankspace\else \ifx\next\bgroup \else \ifx\next\egroup \else @@ -523,10 +525,10 @@ %D mentioned earlier in this module. We take care of two %D arguments, which complicates things a bit. -\def\@nc@{@nc@} % normal character -\def\@cc@{@cc@} % compound character -\def\@cs@{@cs@} % compound characters -\def\@cx@{@cx@} % compound definition +\installcorenamespace{compoundnormal} +\installcorenamespace{compoundsingle} +\installcorenamespace{compoundmultiple} +\installcorenamespace{compounddefinition} %D When we started working on MK IV code, we needed a different %D approach for defining the active character itself. In MK II as @@ -534,39 +536,26 @@ \setnewconstant\compoundcharactermode\plusone +\newcount\c_languages_compound_character + \def\installcompoundcharacter #1#2#3 #4% {#4} no grouping {\ifcase\compoundcharactermode % ignore mode \else - \chardef\thecompoundcharacter`#1% - \expandafter\chardef\csname\@nc@\string#1\endcsname\thecompoundcharacter + \chardef\c_languages_compound_character`#1% + \expandafter\chardef\csname\??compoundnormal\string#1\endcsname\c_languages_compound_character \def\!!stringa{#3}% - \expandafter\def\csname\ifx\!!stringa\empty\@cc@\else\@cs@\fi\detokenize{#1#2#3}\endcsname{#4}% - \setevalue{\@cx@\detokenize{#1}}{\noexpand\handlecompoundcharacter{\detokenize{#1}}}% beter nr's - \expandafter\letcatcodecommand\expandafter\ctxcatcodes\expandafter\thecompoundcharacter\csname\@cx@\detokenize{#1}\endcsname + \expandafter\def\csname\ifx\!!stringa\empty\??compoundsingle\else\??compoundmultiple\fi\detokenize{#1#2#3}\endcsname{#4}% + \setevalue{\??compounddefinition\detokenize{#1}}{\noexpand\languages_handle_compound_character{\detokenize{#1}}}% beter nr's + \expandafter\letcatcodecommand\expandafter\ctxcatcodes\expandafter\c_languages_compound_character\csname\??compounddefinition\detokenize{#1}\endcsname \fi} -%D In order to serve the language specific well, we will introduce -%D a namespace: - -% \ifx\currentlanguage\undefined - \let\compoundcharacterclass\empty -% \else -% \def\compoundcharacterclass{\currentlanguage} -% \fi - -\def\@cc@{@cc@\compoundcharacterclass} % compound character -\def\@cs@{@cs@\compoundcharacterclass} % compound characters - %D We can also ignore definitions (needed in for instance \XML). Beware, %D this macro is supposed to be used grouped! \def\ignorecompoundcharacter {\compoundcharactermode\zerocount} -\let\restorecompoundcharacter \gobbleoneargument % obsolete -\let\enableactivediscretionaries\relax % obsolete - %D In handling the compound characters we have to take care of %D \type{\bgroup} and \type{\egroup} tokens, so we end up with %D a multi||step interpretation macro. We look ahead for a @@ -579,40 +568,41 @@ %D with \type{\futurelet} to prevent spaces from %D disappearing. -\def\handlecompoundcharacter#1% - {\def\xhandlecompoundcharacter{\dohandlecompoundcharacter{#1}}% - \futurelet\next\xhandlecompoundcharacter} - -\def\dohandlecompoundcharacter - {\ifx\next\bgroup - %\expandafter\dodohandlecompoundcharacter % handle "{ee} -> \"ee - %\expandafter\gobbleoneargument % forget "{ee} -> ee - \expandafter\handlecompoundcharacterone % ignore "{ee} -> "ee - \else\ifx\next\egroup - \doubleexpandafter\donohandlecompoundcharacter - \else\ifx\next\blankspace - \tripleexpandafter\donohandlecompoundcharacter +\def\languages_handle_compound_character#1% + {\def\languages_handle_compound_character_finish{\languages_handle_compound_character_finish_indeed{#1}}% + \futurelet\nexttoken\xhandlecompoundcharacter} + +\def\languages_handle_compound_character_finish_indeed + {\ifx\nexttoken\bgroup + %\expandafter\languages_handle_compound_character_pickup % handle "{ee} -> \"ee + %\expandafter\gobbleoneargument % forget "{ee} -> ee + \expandafter\languages_handle_compound_character_one % ignore "{ee} -> "ee + \else\ifx\nexttoken\egroup + \doubleexpandafter\languages_handle_compound_character_normal + \else\ifx\nexttoken\blankspace + \tripleexpandafter\languages_handle_compound_character_normal \else - \tripleexpandafter\dodohandlecompoundcharacter + \tripleexpandafter\languages_handle_compound_character_pickup \fi\fi\fi} -\def\donohandlecompoundcharacter#1{\csname\@nc@\string#1\endcsname} +\def\languages_handle_compound_character_normal#1% + {\csname\??compoundnormal\string#1\endcsname} -\def\dododohandlecompoundcharacter - {\ifx\next\bgroup - \expandafter\handlecompoundcharacterone - \else\ifx\next\egroup - \doubleexpandafter\handlecompoundcharacterone - \else\ifx\next\blankspace - \tripleexpandafter\handlecompoundcharacterone +\def\languages_handle_compound_character_pickup#1#2% preserve space + {\def\languages_handle_compound_character_finish{\languages_handle_compound_character_finish_indeed#1#2}% + \futurelet\nexttoken\languages_handle_compound_character_finish} + +\def\languages_handle_compound_character_finish_indeed + {\ifx\nexttoken\bgroup + \expandafter\languages_handle_compound_character_one + \else\ifx\nexttoken\egroup + \doubleexpandafter\languages_handle_compound_character_one + \else\ifx\nexttoken\blankspace + \tripleexpandafter\languages_handle_compound_character_one \else - \tripleexpandafter\handlecompoundcharactertwo + \tripleexpandafter\languages_handle_compound_character_two \fi\fi\fi} -\def\dodohandlecompoundcharacter#1#2% preserve space - {\def\xdodohandlecompoundcharacter{\dododohandlecompoundcharacter#1#2}% - \futurelet\next\xdodohandlecompoundcharacter} - %D Besides taken care of the grouping and space tokens, we have %D to deal with three situations. First we look if the next %D character equals the first one, if so, then we just insert @@ -626,25 +616,25 @@ %D %D In later modules we will see how these commands are used. -\long\def\handlecompoundcharacterone#1#2% +\def\languages_handle_compound_character_one#1#2% {\if\string#1\string#2% was: \ifx#1#2% - \def\next{\csname\@nc@\string#1\endcsname}% - \else\ifcsname\@cc@\string#1\string#2\endcsname - \def\next{\csname\@cc@\string#1\string#2\endcsname}% + \def\next{\csname\??compoundnormal\string#1\endcsname}% + \else\ifcsname\??compoundsingle\string#1\string#2\endcsname + \def\next{\csname\??compoundsingle\string#1\string#2\endcsname}% \else - \def\next{\csname\@nc@\string#1\endcsname#2}% + \def\next{\csname\??compoundnormal\string#1\endcsname#2}% \fi\fi \next} -\long\def\handlecompoundcharactertwo#1#2#3% +\def\languages_handle_compound_character_two#1#2#3% {\if\string#1\string#2% - \def\next{\csname\@nc@\string#1\endcsname#3}% - \else\ifcsname\@cs@\string#1\string#2\string#3\endcsname - \def\next{\csname\@cs@\string#1\string#2\string#3\endcsname}% - \else\ifcsname\@cc@\string#1\string#2\endcsname - \def\next{\csname\@cc@\string#1\string#2\endcsname#3}% + \def\next{\csname\??compoundnormal\string#1\endcsname#3}% + \else\ifcsname\??compoundmultiple\string#1\string#2\string#3\endcsname + \def\next{\csname\??compoundmultiple\string#1\string#2\string#3\endcsname}% + \else\ifcsname\??compoundsingle\string#1\string#2\endcsname + \def\next{\csname\??compoundsingle\string#1\string#2\endcsname#3}% \else - \def\next{\csname\@nc@\string#1\endcsname#2#3}% + \def\next{\csname\??compoundnormal\string#1\endcsname#2#3}% \fi\fi\fi \next} @@ -652,8 +642,8 @@ %D {lang-sla.tex}) we provide: \def\simplifiedcompoundcharacter#1#2% - {\ifcsname\@cc@\string#1\string#2\endcsname - \doubleexpandafter\firstofoneargument\csname\@cc@\string#1\string#2\endcsname + {\ifcsname\??compoundsingle\string#1\string#2\endcsname + \doubleexpandafter\firstofoneargument\csname\??compoundsingle\string#1\string#2\endcsname \else #2% \fi} @@ -672,6 +662,6 @@ %D %D Handy in for instance XML. (Kind of obsolete) -\ifx\normalcompound\undefined \let\normalcompound=| \fi +\ifdefined\normalcompound \else \let\normalcompound=| \fi \protect \endinput diff --git a/tex/context/base/lang-url.mkiv b/tex/context/base/lang-url.mkiv index 23178a2a2..134b899da 100644 --- a/tex/context/base/lang-url.mkiv +++ b/tex/context/base/lang-url.mkiv @@ -55,48 +55,47 @@ \let|=\letterbar \to \everyhyphenatedurl -\def\hyphenatedurlseparator{} % \periodcentered +\let\hyphenatedurlseparator \empty % \periodcentered +\let\hyphenatedurldiscretionary\empty -\def\dohyphenatedurlspace {\nobreak\hskip\zeropoint plus\onepoint\nobreak} -\def\dohyphenatedurlafter #1{\char#1\discretionary{}{\hyphenatedurlseparator}{}} -\def\dohyphenatedurlbefore #1{\discretionary{\hyphenatedurlseparator}{}{}\char#1\relax} -\def\dohyphenatedurlnormal #1{\char#1\relax} -\def\dohyphenatedurldisc #1{\discretionary{}{}{}} +\setnewconstant\hyphenatedurllefthyphenmin \plusthree +\setnewconstant\hyphenatedurlrighthyphenmin\plusthree -\def\dohyphenatedurlspace_trace {\nobreak\begingroup\darkyellow\ruledhskip\zeropoint plus\onepoint\endgroup\nobreak} -\def\dohyphenatedurlafter_trace #1{\char#1\hsmash{\darkblue\vl}\discretionary{}{\hyphenatedurlseparator}{}} -\def\dohyphenatedurlbefore_trace#1{\discretionary{\hyphenatedurlseparator}{}{}\hsmash{\darkred\vl}\char#1\relax} -\def\dohyphenatedurlnormal_trace#1{\char#1\relax} -\def\dohyphenatedurldisc_trace #1{\discretionary{\hsmash{\darkgreen\vl}}{\hsmash{\darkgreen\vl}}{\hsmash{\darkgreen\vl}}} +\def\languages_hyphenated_url_space {\nobreak\hskip\zeropoint plus\onepoint\nobreak} +\def\languages_hyphenated_url_after #1{\char#1\discretionary{}{\hyphenatedurlseparator}{}} +\def\languages_hyphenated_url_before #1{\discretionary{\hyphenatedurlseparator}{}{}\char#1\relax} +\def\languages_hyphenated_url_normal #1{\char#1\relax} +\def\languages_hyphenated_url_disc #1{\discretionary{}{}{}} + +\def\languages_hyphenated_url_space_trace {\nobreak\begingroup\darkyellow\ruledhskip\zeropoint plus\onepoint\endgroup\nobreak} +\def\languages_hyphenated_url_after_trace #1{\char#1\hsmash{\darkblue\vl}\discretionary{}{\hyphenatedurlseparator}{}} +\def\languages_hyphenated_url_before_trace#1{\discretionary{\hyphenatedurlseparator}{}{}\hsmash{\darkred\vl}\char#1\relax} +\def\languages_hyphenated_url_normal_trace#1{\char#1\relax} +\def\languages_hyphenated_url_disc_trace #1{\discretionary{\hsmash{\darkgreen\vl}}{\hsmash{\darkgreen\vl}}{\hsmash{\darkgreen\vl}}} \def\showhyphenatedurlbreaks - {\let\dohyphenatedurlspace \dohyphenatedurlspace_trace - \let\dohyphenatedurlafter \dohyphenatedurlafter_trace - \let\dohyphenatedurlbefore\dohyphenatedurlbefore_trace - \let\dohyphenatedurlnormal\dohyphenatedurlnormal_trace - \let\dohyphenatedurldisc \dohyphenatedurldisc_trace} + {\let\languages_hyphenated_url_space \languages_hyphenated_url_space_trace + \let\languages_hyphenated_url_after \languages_hyphenated_url_after_trace + \let\languages_hyphenated_url_before\languages_hyphenated_url_before_trace + \let\languages_hyphenated_url_normal\languages_hyphenated_url_normal_trace + \let\languages_hyphenated_url_disc \languages_hyphenated_url_disc_trace} \def\sethyphenatedurlnormal#1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,0)}} \def\sethyphenatedurlbefore#1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,1)}} \def\sethyphenatedurlafter #1{\ctxcommand{hyphenatedurl.setcharacters(\!!bs#1\!!es,2)}} -\def\hyphenatedurldiscretionary{} - % \sethyphenatedurlafter{ABCDEF} -\setnewconstant\hyphenatedurllefthyphenmin \plusthree -\setnewconstant\hyphenatedurlrighthyphenmin\plusthree - \unexpanded \def\hyphenatedurl#1% {\dontleavehmode \begingroup \the\everyhyphenatedurl - \language\zerocount - \let\s\dohyphenatedurlspace - \let\n\dohyphenatedurlnormal - \let\b\dohyphenatedurlbefore - \let\a\dohyphenatedurlafter - \let\d\dohyphenatedurldisc + \normallanguage\zerocount + \let\s\languages_hyphenated_url_space + \let\a\languages_hyphenated_url_after + \let\b\languages_hyphenated_url_before + \let\n\languages_hyphenated_url_normal + \let\d\languages_hyphenated_url_disc \normalexpanded{\noexpand\ctxcommand{hyphenatedurl( \!!bs\noexpand\detokenize{#1}\!!es, \number\hyphenatedurllefthyphenmin, diff --git a/tex/context/base/lang-wrd.lua b/tex/context/base/lang-wrd.lua index 558d5744f..3d3cb6aec 100644 --- a/tex/context/base/lang-wrd.lua +++ b/tex/context/base/lang-wrd.lua @@ -412,3 +412,9 @@ end --~ namespace = languagehacks, --~ processor = languagehacks.process --~ } + +-- interface + +commands.enablespellchecking = words.enable +commands.disablespellchecking = words.disable +commands.loadspellchecklist = words.load diff --git a/tex/context/base/lang-wrd.mkiv b/tex/context/base/lang-wrd.mkiv index 6d8e28cd5..1408b7372 100644 --- a/tex/context/base/lang-wrd.mkiv +++ b/tex/context/base/lang-wrd.mkiv @@ -27,33 +27,28 @@ % \setupspellchecking[state=start,method=2] % ... % \typefile{\jobname.words} +% +% beware, maybe some day we will honour grouping +% +% 1: spell checking +% 2: word counting +% 3: language coloring -\def\loadspellchecklist - {\dodoubleempty\doloadspellchecklist} - -\def\doloadspellchecklist[#1][#2]% - {\ctxlua{languages.words.load("#1","#2")}} - -\unexpanded\def\setupspellchecking - {\dosingleargument\dosetupspellchecking} - -\newtoks\everysetupspellchecking +\installcorenamespace{spell} -\unexpanded\def\setupspellchecking[#1]% todo colors - {\getparameters[\??lw][#1]% - \the\everysetupspellchecking} +\installdirectcommandhandler \??spell {spellchecking} \appendtoks - \doifelse\@@lwstate\v!start - {\ctxlua{languages.words.enable { method = "\@@lwmethod", list = "\@@lwlist" }}} - {\ctxlua{languages.words.disable()}}% + \doifelse{\directspellcheckingparameter\c!state}\v!start + {\ctxcommand{enablespellchecking { method = "\directspellcheckingparameter\c!method", list = "\directspellcheckingparameter\c!list" }}} + {\ctxcommand{disablespellchecking()}}% \to \everysetupspellchecking -% beware, maybe some day we will honour grouping +\unexpanded\def\loadspellchecklist + {\dodoubleempty\languages_load_spell_check_list} -% 1: spell checking -% 2: word counting -% 3: language coloring +\def\languages_load_spell_check_list[#1][#2]% + {\ctxcommand{loadspellchecklist("#1","#2")}} \setupspellchecking [\c!state=\v!stop, diff --git a/tex/context/base/lpdf-col.lua b/tex/context/base/lpdf-col.lua index 555c0290f..85f719c40 100644 --- a/tex/context/base/lpdf-col.lua +++ b/tex/context/base/lpdf-col.lua @@ -632,8 +632,21 @@ backends.pdf.tables.vfspecials = { -- todo: distinguish between glyph and rule c red = { "special", 'pdf: 1 0 0 rg 1 0 0 RG' }, green = { "special", 'pdf: 0 1 0 rg 0 1 0 RG' }, blue = { "special", 'pdf: 0 0 1 rg 0 0 1 RG' }, + gray = { "special", 'pdf: .75 g .75 G' }, black = { "special", 'pdf: 0 g 0 G' }, + rulecolors = { + red = { "special", 'pdf: 1 0 0 rg' }, + green = { "special", 'pdf: 0 1 0 rg' }, + blue = { "special", 'pdf: 0 0 1 rg' }, + gray = { "special", 'pdf: .5 g' }, + black = { "special", 'pdf: 0 g' }, + palered = { "special", 'pdf: 1 .75 .75 rg' }, + palegreen = { "special", 'pdf: .75 1 .75 rg' }, + paleblue = { "special", 'pdf: .75 .75 1 rg' }, + palegray = { "special", 'pdf: .75 g' }, + }, + startslant = function(a) return { "special", format("pdf: q 1 0 %s 1 0 0 cm",a) } end, stopslant = { "special", "pdf: Q" }, diff --git a/tex/context/base/luat-mac.lua b/tex/context/base/luat-mac.lua index 7287692fc..d0543250c 100644 --- a/tex/context/base/luat-mac.lua +++ b/tex/context/base/luat-mac.lua @@ -122,7 +122,7 @@ local grammar = { "converter", texcode = pushlocal * startcode * spaces - * (name * spaces)^1 -- new: multiple + * (csname * spaces)^1 -- new: multiple, new:csname instead of name -- * (declaration + furthercomment + (1 - newline - space))^0 * ((declaration * (space^0/""))^1 + furthercomment + (1 - newline - space))^0 -- accepts #a #b #c * V("texbody") diff --git a/tex/context/base/luat-sto.lua b/tex/context/base/luat-sto.lua index 2c7a25aaa..30bb7d5bb 100644 --- a/tex/context/base/luat-sto.lua +++ b/tex/context/base/luat-sto.lua @@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['luat-sto'] = { license = "see context related readme files" } +-- we could nil some function in the productionrun + local type, next, setmetatable, getmetatable, collectgarbage = type, next, setmetatable, getmetatable, collectgarbage local gmatch, format, write_nl = string.gmatch, string.format, texio.write_nl local serialize, concat, sortedhash = table.serialize, table.concat, table.sortedhash @@ -128,6 +130,10 @@ function statistics.reportstorage(whereto) for k,v in sortedhash(catcodes.names) do write_nl(whereto,format("%03i %s",k,concat(v," "))) end + write_nl(whereto," ","used corenamespaces:"," ") + for k,v in sortedhash(interfaces.corenamespaces) do + write_nl(whereto,format("%03i %s",k,v)) + end write_nl(whereto," ") end diff --git a/tex/context/base/lxml-ctx.mkiv b/tex/context/base/lxml-ctx.mkiv index 9a5428a7b..530c29aa7 100644 --- a/tex/context/base/lxml-ctx.mkiv +++ b/tex/context/base/lxml-ctx.mkiv @@ -35,9 +35,6 @@ [lshowtitle] [\c!style=\tta] -% \unexpanded\def\setuplxmlshow[#1]% -% {\dodoubleargument\getparameters[\??xl]} - \unexpanded\def\xmllshow#1% {\ctxlua{xml.ctx.tshow { pattern = \!!bs\detokenize{#1}\!!es, diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv index 77a57ac03..2ba1619e4 100644 --- a/tex/context/base/lxml-ini.mkiv +++ b/tex/context/base/lxml-ini.mkiv @@ -25,10 +25,7 @@ \registerctxluafile{lxml-tex}{1.001} % tex finalizers \registerctxluafile{lxml-dir}{1.001} % ctx hacks - -\unprotect % todo \!!bs \!!es - -\def\c!entities{entities} % to be internationalized +\unprotect % todo \!!bs \!!es where handy (slower) \def\ctxlxml #1{\directlua\zerocount{lxml.#1}} @@ -90,10 +87,10 @@ \def\xmldisplayverbatim #1{\ctxlxml{displayverbatim("#1")}} \def\xmlinlineverbatim #1{\ctxlxml{inlineverbatim("#1")}} -\def\xmlload #1#2{\ctxlxml{load("#1","#2","\@@xmentities","\@@xmcompress")}} -\def\xmlloadbuffer #1#2{\ctxlxml{loadbuffer("#1","#2","\@@xmentities","\@@xmcompress")}} -\def\xmlloaddata #1#2{\ctxlxml{loaddata("#1",\!!bs#2\!!es,"\@@xmentities","\@@xmcompress")}} -\def\xmlloadregistered #1#2{\ctxlxml{loadregistered("#1","\@@xmentities","\@@xmcompress")}} +\def\xmlload #1#2{\ctxlxml{load("#1","#2","\p_xml_entities","\p_xml_compress")}} +\def\xmlloadbuffer #1#2{\ctxlxml{loadbuffer("#1","#2","\p_xml_entities","\p_xml_compress")}} +\def\xmlloaddata #1#2{\ctxlxml{loaddata("#1",\!!bs#2\!!es,"\p_xml_entities","\p_xml_compress")}} +\def\xmlloadregistered #1#2{\ctxlxml{loadregistered("#1","\p_xml_entities","\p_xml_compress")}} \def\xmlloaddirectives #1{\ctxlxml{directives.load("any:///#1")}} \def\xmlpos #1{\ctxlxml{pos("#1")}} @@ -108,12 +105,12 @@ % todo: \xmldoifelseattribute -\def\xmldoif #1#2{\ctxlxml{doif (\!!bs#1\!!es,\!!bs#2\!!es)}} -\def\xmldoifnot #1#2{\ctxlxml{doifnot (\!!bs#1\!!es,\!!bs#2\!!es)}} -\def\xmldoifelse #1#2{\ctxlxml{doifelse (\!!bs#1\!!es,\!!bs#2\!!es)}} -\def\xmldoiftext #1#2{\ctxlxml{doiftext (\!!bs#1\!!es,\!!bs#2\!!es)}} -\def\xmldoifnottext #1#2{\ctxlxml{doifnottext (\!!bs#1\!!es,\!!bs#2\!!es)}} -\def\xmldoifelsetext #1#2{\ctxlxml{doifelsetext(\!!bs#1\!!es,\!!bs#2\!!es)}} +\def\xmldoif #1#2{\ctxlxml{doif (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable +\def\xmldoifnot #1#2{\ctxlxml{doifnot (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable +\def\xmldoifelse #1#2{\ctxlxml{doifelse (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable +\def\xmldoiftext #1#2{\ctxlxml{doiftext (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable +\def\xmldoifnottext #1#2{\ctxlxml{doifnottext (\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable +\def\xmldoifelsetext #1#2{\ctxlxml{doifelsetext(\!!bs#1\!!es,\!!bs#2\!!es)}} % expandable %def\xmldoifelseempty #1#2{\ctxlxml{doifelseempty("#1","#2")}} % #2, "*" or "" == self not yet implemented %def\xmldoifelseselfempty #1{\ctxlxml{doifelseempty("#1")}} @@ -136,44 +133,44 @@ % todo: 1:xml:whatever always before 3:xml:something -\def\xmlprependsetup #1{\ctxlxml{installsetup(1,"*","#1")}} -\def\xmlappendsetup #1{\ctxlxml{installsetup(2,"*","#1")}} -\def\xmlbeforesetup #1#2{\ctxlxml{installsetup(3,"*","#1","#2"))}} -\def\xmlaftersetup #1#2{\ctxlxml{installsetup(4,"*","#1","#2"))}} +\unexpanded\def\xmlprependsetup #1{\ctxlxml{installsetup(1,"*","#1")}} +\unexpanded\def\xmlappendsetup #1{\ctxlxml{installsetup(2,"*","#1")}} +\unexpanded\def\xmlbeforesetup #1#2{\ctxlxml{installsetup(3,"*","#1","#2")}} +\unexpanded\def\xmlaftersetup #1#2{\ctxlxml{installsetup(4,"*","#1","#2")}} -\def\xmlprependdocumentsetup #1#2{\ctxlxml{installsetup(1,"#1","#2")}} -\def\xmlappenddocumentsetup #1#2{\ctxlxml{installsetup(2,"#1","#2")}} -\def\xmlbeforedocumentsetup#1#2#3{\ctxlxml{installsetup(3,"#1","#2","#3"))}} -\def\xmlafterdocumentsetup #1#2#3{\ctxlxml{installsetup(4,"#1","#2","#3"))}} +\unexpanded\def\xmlprependdocumentsetup #1#2{\ctxlxml{installsetup(1,"#1","#2")}} +\unexpanded\def\xmlappenddocumentsetup #1#2{\ctxlxml{installsetup(2,"#1","#2")}} +\unexpanded\def\xmlbeforedocumentsetup#1#2#3{\ctxlxml{installsetup(3,"#1","#2","#3")}} +\unexpanded\def\xmlafterdocumentsetup #1#2#3{\ctxlxml{installsetup(4,"#1","#2","#3")}} -\def\xmlremovesetup #1{\ctxlxml{removesetup("*","#1")}} -\def\xmlremovedocumentsetup #1#2{\ctxlxml{removesetup("#1","#2")}} +\unexpanded\def\xmlremovesetup #1{\ctxlxml{removesetup("*","#1")}} +\unexpanded\def\xmlremovedocumentsetup #1#2{\ctxlxml{removesetup("#1","#2")}} -\def\xmlflushdocumentsetups #1#2{\ctxlxml{flushsetups("#1","*","#2")}} % #1 == id where to apply * and #2 -\def\xmlresetdocumentsetups #1{\ctxlxml{resetsetups("#1")}} +\unexpanded\def\xmlflushdocumentsetups #1#2{\ctxlxml{flushsetups("#1","*","#2")}} % #1 == id where to apply * and #2 +\unexpanded\def\xmlresetdocumentsetups #1{\ctxlxml{resetsetups("#1")}} \let\xmlregistersetup \xmlappendsetup \let\xmlregisterdocumentsetup\xmlappenddocumentsetup \def\xmldocument{main} -\def\xmlregisteredsetups +\unexpanded\def\xmlregisteredsetups {\xmlstarttiming \xmlflushsetups \xmldefaulttotext\xmldocument % after include \xmlstoptiming} -\def\xmlregistereddocumentsetups#1#2% id setups +\unexpanded\def\xmlregistereddocumentsetups#1#2% id setups {\xmlstarttiming % todo: test for duplicates ! \xmlflushdocumentsetups{#1}{#2}% \xmldefaulttotext{#1}% after include \xmlstoptiming} -\def\xmlstarttiming{\ctxlua{statistics.starttiming(lxml)}} -\def\xmlstoptiming {\ctxlua{statistics.stoptiming (lxml)}} +\unexpanded\def\xmlstarttiming{\ctxlua{statistics.starttiming(lxml)}} +\unexpanded\def\xmlstoptiming {\ctxlua{statistics.stoptiming (lxml)}} -\def\doxmlprocess#1#2#3#4#5% flag \loader id name what initializersetup +\def\lxml_process#1#2#3#4#5% flag \loader id name what initializersetup {\begingroup \edef\xmldocument{#3}% #2 can be \xmldocument and set as such %xmlpushdocument{#3}% @@ -185,10 +182,10 @@ %xmlpopdocument \endgroup} -\def\xmlprocessfile {\doxmlprocess\plusone \xmlload} -\def\xmlprocessdata {\doxmlprocess\zerocount\xmlloaddata} -\def\xmlprocessbuffer {\doxmlprocess\zerocount\xmlloadbuffer} -\def\xmlprocessregistered{\doxmlprocess\zerocount\xmlloadregistered} +\unexpanded\def\xmlprocessfile {\lxml_process\plusone \xmlload} +\unexpanded\def\xmlprocessdata {\lxml_process\zerocount\xmlloaddata} +\unexpanded\def\xmlprocessbuffer {\lxml_process\zerocount\xmlloadbuffer} +\unexpanded\def\xmlprocessregistered{\lxml_process\zerocount\xmlloadregistered} \let\xmlprocess \xmlprocessfile \startxmlsetups xml:flush @@ -200,7 +197,7 @@ \xmlmain{#1} \stopxmlsetups -\def\xmlloadonly#1#2#3% +\unexpanded\def\xmlloadonly#1#2#3% {\xmlload{#1}{#2}% \xmlregistereddocumentsetups{#1}{#3}} @@ -208,7 +205,7 @@ % instructions preceding the root element; well, in some % sense that is the root -\long\def\xmlconnect#1#2#3% inefficient +\unexpanded\def\xmlconnect#1#2#3% inefficient {\scratchcounter\xmlcount{#1}{#2}\relax \ifcase\scratchcounter \or \xmlall{#1}{#2}% @@ -218,10 +215,10 @@ \xmlidx{#1}{#2}\recurselevel}% \fi} -\def\xmlcdataobeyedline {\obeyedline} -\def\xmlcdataobeyedspace{\strut\obeyedspace} -\def\xmlcdatabefore {\bgroup\tt} -\def\xmlcdataafter {\egroup} +\unexpanded\def\xmlcdataobeyedline {\obeyedline} +\unexpanded\def\xmlcdataobeyedspace{\strut\obeyedspace} +\unexpanded\def\xmlcdatabefore {\bgroup\tt} +\unexpanded\def\xmlcdataafter {\egroup} % verbatim (dodo:pre/post whitespace, maybe splot verbatim and % cdata commands), experimental: @@ -242,7 +239,6 @@ \unexpanded\def\startxmldisplayverbatim[#1]% {\startpacked % \begingroup - \let\currenttypingclass\??tp \edef\currenttyping{xml:#1}% \unexpanded\def\stopxmldisplayverbatim {\endofverbatimlines @@ -252,8 +248,7 @@ \unexpanded\def\startxmlinlineverbatim[#1]% {\begingroup - \let\currenttypingclass\??ty - \edef\currenttyping{xml:#1}% + \edef\currenttype{xml:#1}% \let\stopxmldisplayverbatim\endgroup \doinitializeverbatim} @@ -292,16 +287,18 @@ \newconstant\xmlprocessingmode % 0=unset, 1=text, 2=hidden -\newtoks\everysetupxml +\installcorenamespace{xml} +\installcorenamespace{xmldefaults} +\installcorenamespace{xmlmapvalue} -\unexpanded\def\setupxml[#1]{\getparameters[\??xm][#1]\the\everysetupxml} +\installdirectcommandhandler \??xml {xml} -\letvalue{\??xm:\s!default:\v!normal}\zerocount -\letvalue{\??xm:\s!default:\v!none }\zerocount -\letvalue{\??xm:\s!default:\v!text }\plusone -\letvalue{\??xm:\s!default:\v!hidden}\plustwo +\letvalue{\??xmldefaults\v!normal}\zerocount +\letvalue{\??xmldefaults\v!none }\zerocount +\letvalue{\??xmldefaults\v!text }\plusone +\letvalue{\??xmldefaults\v!hidden}\plustwo -\def\xmldefaulttotext#1% +\unexpanded\def\xmldefaulttotext#1% {\ifcase\xmlprocessingmode % unset \or @@ -313,20 +310,29 @@ \fi} \appendtoks - \xmlprocessingmode\executeifdefined{\??xm:\s!default:\@@xmdefault}\plusone + \xmlprocessingmode\executeifdefined{\??xmldefaults\directxmlparameter\c!default}\plusone \to \everysetupxml -\def\xmlinitialize{\the\everysetupxml} +\unexpanded\def\xmlinitialize + {\the\everysetupxml} + +\let\p_xml_entities\empty +\let\p_xml_compress\empty + +\appendtoks + \edef\p_xml_entities{\directxmlparameter\c!entities}% + \edef\p_xml_compress{\directxmlparameter\c!compress}% +\to \everysetupxml \setupxml [\c!default=, % flush all \c!compress=\v!no, % strip comment \c!entities=\v!yes] % replace entities -\def\xmlmapvalue #1#2#3{\setvalue{\??xm:v:#1:#2}{#3}} % keep #3 to grab spaces -\def\xmlvalue #1#2#3{\executeifdefined{\??xm:v:#1:#2}{#3}} -%def\xmlvalue #1#2{\ifcsname\??xm:v:#1:#2\endcsname\csname\??xm:v:#1:#2\expandafter\expandafter\gobbleoneargument\expandafter\endcsname\else\expandafter\firstofoneargument\fi} -\def\xmldoifelsevalue #1#2{\ifcsname\??xm:v:#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\def\xmlmapvalue #1#2#3{\setvalue{\??xmlmapvalue#1:#2}{#3}} % keep #3 to grab spaces +\def\xmlvalue #1#2#3{\executeifdefined{\??xmlmapvalue#1:#2}{#3}} +%def\xmlvalue #1#2{\ifcsname\??xmlmapvalue#1:#2\endcsname\csname\??xmlmapvalue#1:#2\expandafter\expandafter\gobbleoneargument\expandafter\endcsname\else\expandafter\firstofoneargument\fi} +\def\xmldoifelsevalue #1#2{\ifcsname\??xmlmapvalue#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} \let\xmlmapval\xmlmapvalue \let\xmlval \xmlvalue @@ -349,26 +355,26 @@ \unexpanded\def\xmle {\ifcase\xmlautoentities - \expandafter\xmle@none + \expandafter\xml_e_none \or - \expandafter\xmle@upper + \expandafter\xml_e_upper \or - \expandafter\xmle@upperlower + \expandafter\xml_e_upperlower \else - \expandafter\xmle@none + \expandafter\xml_e_none \fi} -\def\xmle@none#1#2% safe +\def\xml_e_none#1#2% safe {#1} -\def\xmle@upper#1#2% can be abbreviation +\def\xml_e_upper#1#2% can be abbreviation {\ifcsname#2\endcsname \csname#2\expandafter\endcsname \else #1% \fi} -\def\xmle@upperlower#1#2% can be anything, so unsafe +\def\xml_e_upperlower#1#2% can be anything, so unsafe {\ifcsname#2\endcsname \csname#2\expandafter\endcsname \else\ifcsname#1\endcsname @@ -380,9 +386,9 @@ % handy helpers (analogue to MP and LUA and TEX and also MkII) \unexpanded\def\processXMLbuffer - {\dosingleempty\doprocessXMLbuffer} + {\dosingleempty\xml_process_buffer} -\def\doprocessXMLbuffer[#1]% +\def\xml_process_buffer[#1]% {\xmlprocessbuffer{temp}{#1}{}} \unexpanded\def\processXMLfile#1% diff --git a/tex/context/base/lxml-sor.mkiv b/tex/context/base/lxml-sor.mkiv index 88952d661..0ee1f16f3 100644 --- a/tex/context/base/lxml-sor.mkiv +++ b/tex/context/base/lxml-sor.mkiv @@ -19,11 +19,11 @@ \unprotect -\def\xmlresetsorter #1{\ctxlxml{sorters.reset("#1")}} -\def\xmladdsortentry#1#2#3{\ctxlxml{sorters.add("#1","#2",\!!bs#3\!!es)}} -\def\xmlshowsorter #1{\ctxlxml{sorters.show("#1")}} -\def\xmlflushsorter #1#2{\ctxlxml{sorters.flush("#1","#2")}} -\def\xmlsortentries #1{\ctxlxml{sorters.sort("#1")}} +\unexpanded\def\xmlresetsorter #1{\ctxlxml{sorters.reset("#1")}} +\unexpanded\def\xmladdsortentry#1#2#3{\ctxlxml{sorters.add("#1","#2",\!!bs#3\!!es)}} +\unexpanded\def\xmlshowsorter #1{\ctxlxml{sorters.show("#1")}} +\unexpanded\def\xmlflushsorter #1#2{\ctxlxml{sorters.flush("#1","#2")}} +\unexpanded\def\xmlsortentries #1{\ctxlxml{sorters.sort("#1")}} \protect \endinput diff --git a/tex/context/base/m-chart.mkvi b/tex/context/base/m-chart.mkvi index 866d3c45b..a9de44859 100644 --- a/tex/context/base/m-chart.mkvi +++ b/tex/context/base/m-chart.mkvi @@ -339,13 +339,11 @@ \begingroup \directsetup{flowcell:text:user} \doifelsenothing {\getvariable{flowcell:text}{figure}} { - \doframed - [flowcell:\getvariable{flowcell:text}{align}] + \expandcheckedcsname{flowcell:}{\getvariable{flowcell:text}{align}}\empty {\getvariable{flowcell:text}{text}} } { - \doframed - [flowcell:\getvariable{flowcell:text}{align}] - [background=flowcell:figure] + \expandcheckedcsname{flowcell:}{\getvariable{flowcell:text}{align}}\empty + [\c!background=flowcell:figure] {\getvariable{flowcell:text}{text}} } \endgroup diff --git a/tex/context/base/m-database.mkiv b/tex/context/base/m-database.mkiv index 370045d4b..cef0aa815 100644 --- a/tex/context/base/m-database.mkiv +++ b/tex/context/base/m-database.mkiv @@ -86,7 +86,7 @@ \def\dodefineseparatedlist[#1][#2]% {\definedatabase[#1][#2]% - \setuvalue{\e!start#1}{\dostartbuffer[#1][\e!start#1][\e!stop#1]}% + \setuvalue{\e!start#1}{\grabbufferdatadirect{#1}{\e!start#1}{\e!stop#1}}% \setuvalue{\e!stop#1}{\processdatabasebuffer[#1][#1]}} \def\processseparatedfile[#1][#2]% @@ -94,7 +94,7 @@ \def\startseparatedlist[#1]% to be interfaced {\def\stopseparatedlist{\processdatabasebuffer[#1][#1]}% - \dostartbuffer[#1][startseparatedlist][stopseparatedlist]} + \grabbufferdatadirect{#1}{startseparatedlist}{stopseparatedlist}} \protect diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv index 9e2837cc2..0738666f0 100644 --- a/tex/context/base/math-ali.mkiv +++ b/tex/context/base/math-ali.mkiv @@ -204,7 +204,10 @@ \dostoptagged \dostoptagged} -\installcommandhandler \??eq {mathalignment} \??eq +\installcorenamespace{mathalignment} +\installcorenamespace{mathalignmentvariant} + +\installcommandhandler \??mathalignment {mathalignment} \??mathalignment \appendtoks \setuevalue{\e!start\currentmathalignment}{\math_alignment_start{\currentmathalignment}}% @@ -235,27 +238,27 @@ \dostarttagged\t!mathtablecell\empty} \def\math_left_of_equalign - {\ifcsname\??eq::a::\number\c_math_eqalign_column\endcsname - \ifcase\csname\??eq::a::\number\c_math_eqalign_column\endcsname\or + {\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname + \ifcase\csname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname\or \relax \or \hfill \or \hfill \fi \fi} \def\math_right_of_eqalign - {\ifcsname\??eq::a::\number\c_math_eqalign_column\endcsname - \ifcase\csname\??eq::a::\number\c_math_eqalign_column\endcsname\or + {\ifcsname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname + \ifcase\csname\??mathalignmentvariant\number\c_math_eqalign_column\endcsname\or \hfill \or \relax \or \hfill \fi \fi} \def\doseteqaligncolumn#1% we could just add to the preamble (as with other alignments) - {\expandafter\let\csname\??eq::a::\number\c_math_eqalign_column\expandafter\endcsname - \csname\??eq::a::\ifcsname\??eq::a::#1\endcsname#1\else\v!normal\fi\endcsname} + {\expandafter\let\csname\??mathalignmentvariant\number\c_math_eqalign_column\expandafter\endcsname + \csname\??mathalignmentvariant\ifcsname\??mathalignmentvariant#1\endcsname#1\else\v!normal\fi\endcsname} -\letvalue{\??eq::a::\v!normal}\zerocount -\letvalue{\??eq::a::\v!left }\plusone -\letvalue{\??eq::a::\v!right }\plustwo -\letvalue{\??eq::a::\v!middle}\plusthree +\letvalue{\??mathalignmentvariant\v!normal}\zerocount +\letvalue{\??mathalignmentvariant\v!left }\plusone +\letvalue{\??mathalignmentvariant\v!right }\plustwo +\letvalue{\??mathalignmentvariant\v!middle}\plusthree \def\math_align_NR_generic[#1][#2]% {\donestedformulanumber{#1}{#2}\crcr} @@ -396,7 +399,9 @@ %D %D Another wish \unknown -\installcommandhandler \??ce {mathcases} \??ce +\installcorenamespace{mathcases} + +\installcommandhandler \??mathcases {mathcases} \??mathcases \setupmathcases [\c!distance=1em, @@ -501,7 +506,9 @@ %D %D Yet another one \unknown -\installcommandhandler \??mk {mathmatrix} \??mk +\installcorenamespace{mathmatrix} + +\installcommandhandler \??mathmatrix {mathmatrix} \??mathmatrix \setupmathmatrix [\c!distance=1em, @@ -577,8 +584,10 @@ \unexpanded\def\dodomatrixNC {\gdef\domatrixNC{\endmath&}} +\installcorenamespace{mathmatrixhandler} + \def\installmathmatrixhandler#1#2% - {\setvalue{\??mx:h:#1}{#2}} + {\setvalue{\??mathmatrixhandler#1}{#2}} \let\mathmatrixleft \empty % experimental hook \let\mathmatrixright\empty % experimental hook @@ -600,7 +609,7 @@ \installmathmatrixhandler\v!normal{\def\mathmatrixbox{\math_matrix_process\plustwo \zerocount}} % lohi \def\math_matrix_handler_apply - {\csname\??mx:h:\ifcsname\??mx:h:\mathmatrixparameter\c!location\endcsname + {\csname\??mathmatrixhandler\ifcsname\??mathmatrixhandler\mathmatrixparameter\c!location\endcsname \mathmatrixparameter\c!location \else \v!normal @@ -893,18 +902,18 @@ %D \type {\stopinnermath} can be overloaded in specialized %D modules. -\unexpanded\def\startinnermath - {\csname\??fm:\e!start:\formulaparameter\c!align\endcsname} +\installcorenamespace{mathinnerstart} +\installcorenamespace{mathinnerstop} -\unexpanded\def\stopinnermath - {\csname\??fm:\e!stop :\formulaparameter\c!align\endcsname} +\unexpanded\def\startinnermath{\csname\??mathinnerstart\formulaparameter\c!align\endcsname} +\unexpanded\def\stopinnermath {\csname\??mathinnerstop \formulaparameter\c!align\endcsname} -\def\mathinnerstrut +\unexpanded\def\mathinnerstrut {\doif{\formulaparameter\c!strut}\v!yes\strut} \unexpanded\def\defineinnermathhandler#1#2#3% - {\setvalue{\??fm:\e!start:#1}{#2}% - \setvalue{\??fm:\e!stop :#1}{#3}} + {\setvalue{\??mathinnerstart#1}{#2}% + \setvalue{\??mathinnerstop #1}{#3}} \newif\iftracemath diff --git a/tex/context/base/math-for.mkiv b/tex/context/base/math-for.mkiv index ebb5ec534..aee640572 100644 --- a/tex/context/base/math-for.mkiv +++ b/tex/context/base/math-for.mkiv @@ -21,8 +21,11 @@ %D \macros %D {setupformulas,setupsubformulas} -\installcommandhandler \??fm {formula} \??fm -\installcommandhandler \??fn {subformula} \??fn % maybe just setuphandler (no childs used yet) +\installcorenamespace{formula} +\installcorenamespace{subformula} + +\installcommandhandler \??formula {formula} \??formula +\installcommandhandler \??subformula {subformula} \??subformula % maybe just setuphandler (no childs used yet) \let\setupformulas \setupformula \let\setupsubformulas\setupsubformula diff --git a/tex/context/base/meta-fig.mkiv b/tex/context/base/meta-fig.mkiv index 644501260..7d268b77d 100644 --- a/tex/context/base/meta-fig.mkiv +++ b/tex/context/base/meta-fig.mkiv @@ -51,7 +51,7 @@ %D %D A bit out of place, here but nevertheless: -\def\MPfigure#1#2% test for dup figure, can be replaced by a textext +\unexpanded\def\MPfigure#1#2% test for dup figure, can be replaced by a textext {\bgroup \getfiguredimensionsonly[#1]% [\c!object=\v!no] already set \startMPcode diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index 2732341d5..09e26edf1 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -27,6 +27,12 @@ \def\currentMPformat {metafun} \def\defaultMPgraphicinstance{metafun} +%installcorenamespace{graphicvariable} % todo +\installcorenamespace{mpinstancetokens} +\installcorenamespace{mpgraphic} +\installcorenamespace{mpstaticgraphic} +\installcorenamespace{mpclip} + % The next command is, of course, dedicated to Mojca, who % needs it for gnuplot. Anyway, the whole multiple engine % mechanism is to keep her gnuplot from interfering. @@ -82,13 +88,13 @@ \edef\currentwidth {\the\hsize \space}% \edef\currentheight {\the\vsize \space}} -\def\t_mp_instance{\csname\??gi:t:\currentMPgraphicinstance\endcsname} % token register +\def\t_mp_instance{\csname\??mpinstancetokens\currentMPgraphicinstance\endcsname} % token register \unexpanded\def\defineMPinstance {\dodoubleargument\mp_define_instance} \def\mp_define_instance[#1][#2]% - {\ifcsname\??gi:t:#1\endcsname\else\expandafter\newtoks\csname\??gi:t:#1\endcsname\fi + {\ifcsname\??mpinstancetokens#1\endcsname\else\expandafter\newtoks\csname\??mpinstancetokens#1\endcsname\fi \t_mp_instance\emptytoks % in case we redefine \getparameters[\??gi#1][\s!format=mpost,\s!extensions=\v!no,\s!initializations=\v!no,#2]} @@ -122,22 +128,25 @@ \defineMPinstance[metapost][\s!format=mpost] \defineMPinstance[nofun] [\s!format=mpost] -\def\beginMPgraphicgroup#1% +\newconditional\mp_include_extensions +\newconditional\mp_include_initializations + +\def\mp_begin_graphic_group#1% {\begingroup \mp_analyze_graphicname[#1]} -\def\endMPgraphicgroup +\def\mp_end_graphic_group {\endgroup} \def\MPaskedfigure{false} -\def\currentMPinitializations - {\ifconditional\includeMPinitializations\the\t_mp_initializations;\fi\theMPrandomseed;} +\def\mp_flush_current_initializations + {\ifconditional\mp_include_initializations\the\t_mp_initializations;\fi\theMPrandomseed;} -\def\currentMPpreamble - {\ifconditional\includeMPextensions\the\t_mp_extensions;\the\t_mp_userinclusions;\fi\the\t_mp_instance;} +\def\mp_flush_current_preamble + {\ifconditional\mp_include_extensions\the\t_mp_extensions;\the\t_mp_userinclusions;\fi\the\t_mp_instance;} -\def\dostartcurrentMPgraphic +\def\mp_start_current_graphic {\begingroup \mp_enable_include \the\everyMPgraphic @@ -145,32 +154,32 @@ \setMPrandomseed % this has to change % we need to preexpand the token lists \doifelsevalue{\??gi\currentMPgraphicinstance\s!extensions}\v!yes - {\settrue \includeMPextensions + {\settrue \mp_include_extensions \letgvalue{\??gi\currentMPgraphicinstance\s!extensions}\v!no} - {\setfalse\includeMPextensions}% + {\setfalse\mp_include_extensions}% \doifelsevalue{\??gi\currentMPgraphicinstance\s!initializations}\v!yes - {\settrue \includeMPinitializations}% - {\setfalse\includeMPinitializations}} + {\settrue \mp_include_initializations}% + {\setfalse\mp_include_initializations}} -\def\dostopcurrentMPgraphic +\def\mp_stop_current_graphic {\global\t_mp_instance\emptytoks \endgroup} \unexpanded\def\mp_process_graphic#1% todo: extensions and inclusions outside beginfig - {\dostartcurrentMPgraphic + {\mp_start_current_graphic \forgetall \setbox\b_mp_graphic\hbox\bgroup % ; added 20100901 (as in mkii) \normalexpanded{\noexpand\ctxlua{metapost.graphic( "\currentMPgraphicinstance", "\currentMPgraphicformat", \!!bs#1;\!!es, - \!!bs\currentMPinitializations;\!!es, - \!!bs\currentMPpreamble;\!!es, + \!!bs\mp_flush_current_initializations;\!!es, + \!!bs\mp_flush_current_preamble;\!!es, \MPaskedfigure )}}% \egroup \placeMPgraphic - \dostopcurrentMPgraphic} + \mp_stop_current_graphic} \newif\ifsetMPrandomseed \setMPrandomseedtrue % false by default @@ -184,8 +193,8 @@ %D Calling up previously defined graphics. \def\includeMPgraphic#1% gets expanded ! - {\ifcsname\??gm:#1\endcsname - \csname\??gm:#1\endcsname ; % ; is safeguard + {\ifcsname\??mpgraphic#1\endcsname + \csname\??mpgraphic#1\endcsname ; % ; is safeguard \fi} \unexpanded\def\mp_enable_include % public @@ -240,7 +249,7 @@ \egroup} \unexpanded\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less - {\setgvalue{\??gm:c:#1}{#2}} + {\setgvalue{\??mpclip#1}{#2}} \let\stopMPclip\relax @@ -248,16 +257,16 @@ {\begingroup \edef\width {#2\space}\let\overlaywidth \width \edef\height{#3\space}\let\overlayheight\height - \ifcsname\??gm:c:#1\endcsname - \dostartcurrentMPgraphic + \ifcsname\??mpmpclip#1\endcsname + \mp_start_current_graphic \xdef\MPclippath{\normalexpanded{\noexpand\ctxlua{metapost.theclippath( "\currentMPgraphicinstance", "\currentMPgraphicformat", - \!!bs\getvalue{\??gm:c:#1}\!!es, - \!!bs\currentMPinitializations\!!es, - \!!bs\currentMPpreamble\!!es + \!!bs\getvalue{\??mpclip#1}\!!es, + \!!bs\mp_flush_current_initializations\!!es, + \!!bs\mp_flush_current_preamble\!!es )}}}% - \dostopcurrentMPgraphic + \mp_stop_current_graphic \ifx\MPclippath\empty \xdef\MPclippath{#4}% \fi @@ -482,20 +491,20 @@ {\begingroup % when there are that many they're probably not that unique anyway \edef\currentmpvariableclass{#1}% \extendMPoverlaystamp{#2}% incl prepare - \ifcsname\??gm:\overlaystamp:#1\endcsname\else + \ifcsname\??mpgraphic\overlaystamp:#1\endcsname\else \mp_enable_include % redundant \global\advance\c_mp_object_counter\plusone \setobject{MP}{\number\c_mp_object_counter}\hbox{\mp_process_graphic{#3}}% was vbox, graphic must end up as hbox - \setxvalue{\??gm:\overlaystamp:#1}{\mp_reuse_box{\number\c_mp_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% + \setxvalue{\??mpgraphic\overlaystamp:#1}{\mp_reuse_box{\number\c_mp_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% \fi - \getvalue{\??gm:\overlaystamp:#1}% + \getvalue{\??mpgraphic\overlaystamp:#1}% \endgroup} \unexpanded\def\startuniqueMPgraphic {\dodoublegroupempty\mp_start_unique_graphic} \def\mp_start_unique_graphic#1#2#3\stopuniqueMPgraphic - {\setgvalue{\??gm:#1}{\mp_handle_unique_graphic{#1}{#2}{#3}}} + {\setgvalue{\??mpgraphic#1}{\mp_handle_unique_graphic{#1}{#2}{#3}}} \let\stopuniqueMPgraphic\relax @@ -503,10 +512,10 @@ {\dodoublegroupempty\mp_unique_graphic} \def\mp_unique_graphic#1#2% - {\beginMPgraphicgroup{#1}% + {\mp_begin_graphic_group{#1}% \setupMPvariables[\currentMPgraphicname][#2]% - \getvalue{\??gm:\currentMPgraphicname}\empty - \endMPgraphicgroup} + \getvalue{\??mpgraphic\currentMPgraphicname}\empty + \mp_end_graphic_group} \def\mp_handle_use_graphic#1#2#3% {\begingroup @@ -520,7 +529,7 @@ {\dodoublegroupempty\mp_start_use_graphic} \def\mp_start_use_graphic#1#2#3\stopuseMPgraphic - {\setgvalue{\??gm:#1}{\mp_handle_use_graphic{#1}{#2}{#3}}} + {\setgvalue{\??mpgraphic#1}{\mp_handle_use_graphic{#1}{#2}{#3}}} \let\stopuseMPgraphic\relax @@ -528,7 +537,7 @@ {\dodoublegroupempty\mp_start_usable_graphic} \def\mp_start_usable_graphic#1#2#3\stopusableMPgraphic - {\setgvalue{\??gm:#1}{\mp_handle_use_graphic{#1}{#2}{#3}}} + {\setgvalue{\??mpgraphic#1}{\mp_handle_use_graphic{#1}{#2}{#3}}} \let\stopusableMPgraphic\relax @@ -539,15 +548,15 @@ \mp_enable_include % redundant \global\advance\c_mp_object_counter\plusone \setobject{MP}{\number\c_mp_object_counter}\hbox{\mp_process_graphic{#3}}% was vbox, graphic must end up as hbox - \setxvalue{\??gm:#1}{\mp_reuse_box{\number\c_mp_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% - \getvalue{\??gm:#1}% + \setxvalue{\??mpgraphic#1}{\mp_reuse_box{\number\c_mp_object_counter}{\the\MPllx}{\the\MPlly}{\the\MPurx}{\the\MPury}}% + \getvalue{\??mpgraphic#1}% \endgroup} \unexpanded\def\startreusableMPgraphic {\dodoublegroupempty\mp_start_reusable_graphic} \def\mp_start_reusable_graphic#1#2#3\stopreusableMPgraphic - {\setgvalue{\??gm:#1}{\mp_handle_reusable_graphic{#1}{#2}{#3}}} + {\setgvalue{\??mpgraphic#1}{\mp_handle_reusable_graphic{#1}{#2}{#3}}} \let\stopreusableMPgraphic\relax @@ -555,10 +564,10 @@ {\dodoublegroupempty\mp_use_graphic} \def\mp_use_graphic#1#2% - {\beginMPgraphicgroup{#1}% + {\mp_begin_graphic_group{#1}% \doifsomething{#2}{\setupMPvariables[\currentMPgraphicname][#2]}% - \getvalue{\??gm:\currentMPgraphicname}\empty - \endMPgraphicgroup} + \getvalue{\??mpgraphic\currentMPgraphicname}\empty + \mp_end_graphic_group} \let\reuseMPgraphic \useMPgraphic % we can save a setup here if needed \let\reusableMPgraphic\reuseMPgraphic % we can save a setup here if needed @@ -580,9 +589,9 @@ \unexpanded\def\startuniqueMPpagegraphic {\dodoublegroupempty\mp_start_unique_page_graphic} -\def\mp_start_unique_page_graphic#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage - {\setgvalue{\??gm:o:#1}{\mp_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state - \setgvalue{\??gm:e:#1}{\mp_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined +\def\mp_start_unique_page_graphic#1#2#3\stopuniqueMPpagegraphic % inefficient, double storage + {\setgvalue{\??mpgraphic o:#1}{\mp_handle_unique_graphic{o:#1}{#2}{#3}}% % but these also keep the state + \setgvalue{\??mpgraphic e:#1}{\mp_handle_unique_graphic{e:#1}{#2}{#3}}} % and meaning will be redefined \let\stopuniqueMPpagegraphic\relax @@ -590,11 +599,11 @@ {\dodoublegroupempty\mp_unique_page_graphic} \def\mp_unique_page_graphic#1#2% - {\beginMPgraphicgroup{#1}% + {\mp_begin_graphic_group{#1}% \let\overlaystamp\overlaypagestamp \setupMPvariables[\m_mp_page_prefix:\currentMPgraphicname][#2]% prefix is new here - \getvalue{\??gm:\m_mp_page_prefix:\currentMPgraphicname}{}% - \endMPgraphicgroup} + \getvalue{\??mpgraphic\m_mp_page_prefix:\currentMPgraphicname}{}% + \mp_end_graphic_group} %D One way of defining a stamp is: %D @@ -653,9 +662,9 @@ {\dosingleempty\mp_process_buffer} \def\mp_process_buffer[#1]% - {\beginMPgraphicgroup{#1}% + {\mp_begin_graphic_group{#1}% \mp_process_graphic{\ctxcommand{feedback("\currentMPgraphicname")}}% - \endMPgraphicgroup} + \mp_end_graphic_group} \unexpanded\def\runMPbuffer {\dosingleempty\mp_run_buffer} @@ -717,10 +726,10 @@ \fi} \def\mp_start_code_instance#1#2\stopMPcode - {\beginMPgraphicgroup{#1::\s!dummy}% name does not matter + {\mp_begin_graphic_group{#1::\s!dummy}% name does not matter \mp_enable_include \mp_process_graphic{#2}% - \endMPgraphicgroup} + \mp_end_graphic_group} \def\mp_start_code_standard#1#2\stopMPcode {\mp_process_graphic{#2}} @@ -738,9 +747,9 @@ \fi} \def\mp_code_instance#1#2% - {\beginMPgraphicgroup{#1::\s!dummy}% name does not matter + {\mp_begin_graphic_group{#1::\s!dummy}% name does not matter \mp_process_graphic{#2}% - \endMPgraphicgroup} + \mp_end_graphic_group} \def\mp_code_standard#1% #2 {\mp_process_graphic} @@ -815,13 +824,15 @@ %D \MPbetex {identifier} %D \stoptyping +\installcorenamespace{mptext} + \unexpanded\def\setMPtext#1#2% todo : #1 must be made : safe {\defconvertedargument\ascii{#2}% - \dodoglobal\letvalue{\??gt:#1}\ascii} + \dodoglobal\letvalue{\??mptext#1}\ascii} -\def\MPtext #1{\executeifdefined{\??gt:#1}\empty} -\def\MPstring#1{"\executeifdefined{\??gt:#1}\empty"} -\def\MPbetex #1{btex \executeifdefined{\??gt:#1}\empty\space etex} +\def\MPtext #1{\executeifdefined{\??mptext#1}\empty} +\def\MPstring#1{"\executeifdefined{\??mptext#1}\empty"} +\def\MPbetex #1{btex \executeifdefined{\??mptext#1}\empty\space etex} %D In order to communicate conveniently with the \TEX\ %D engine, we introduce some typesetting variables. @@ -863,9 +874,9 @@ \disablecompoundcharacters \to \everyMPgraphic -\appendtoks % before color - \doregistercolor{currentcolor}\currentcolorname -\to \everyMPgraphic +% \appendtoks % before color, inefficient, replace by low level copy +% \doregistercolor{currentcolor}\currentcolorname +% \to \everyMPgraphic % \color[green]{abc \startMPcode % fill fullcircle scaled 3cm withoutcolor; @@ -947,10 +958,10 @@ %D processing the screen version of the \METAFUN\ manual. \def\doifelseMPgraphic#1% - {\ifcsname\??gm :#1\endcsname \expandafter \firstoftwoarguments \else - \ifcsname\??gm:o:#1\endcsname \doubleexpandafter\firstoftwoarguments \else - \ifcsname\??gm:e:#1\endcsname \tripleexpandafter\firstoftwoarguments \else - \tripleexpandafter\secondoftwoarguments \fi\fi\fi} + {\ifcsname\??mpgraphic #1\endcsname \expandafter \firstoftwoarguments \else + \ifcsname\??mpgraphic o:#1\endcsname \doubleexpandafter\firstoftwoarguments \else + \ifcsname\??mpgraphic e:#1\endcsname \tripleexpandafter\firstoftwoarguments \else + \tripleexpandafter\secondoftwoarguments \fi\fi\fi} \let\doifMPgraphicelse\doifelseMPgraphic @@ -1027,13 +1038,13 @@ %D \typebuffer \getbuffer \unexpanded\def\startstaticMPfigure#1#2\stopstaticMPfigure - {\startreusableMPgraphic{\??gm:s:#1}#2\stopreusableMPgraphic} + {\startreusableMPgraphic{\??mpstaticgraphic#1}#2\stopreusableMPgraphic} \unexpanded\def\startstaticMPgraphic {\dodoublegroupempty\mp_start_static_graphic} \def\mp_start_static_graphic#1#2#3\stopstaticMPgraphic - {\startreusableMPgraphic{\??gm:s:#1}{#2}#3\stopreusableMPgraphic} + {\startreusableMPgraphic{\??mpstaticgraphic#1}{#2}#3\stopreusableMPgraphic} \let\stopstaticMPfigure \relax \let\stopstaticMPgraphic\relax @@ -1043,9 +1054,9 @@ \def\mp_use_static_figure[#1][#2]% {\ifsecondargument - \scale[#2]{\reuseMPgraphic{\??gm:s:#1}}% + \scale[#2]{\reuseMPgraphic{\??mpstaticgraphic#1}}% \else - \reuseMPgraphic{\??gm:s:#1}% + \reuseMPgraphic{\??mpstaticgraphic#1}% \fi} %D Goody for preventing overflows: @@ -1090,10 +1101,8 @@ \newconstant\MPcolormethod -% can be faster, just - \appendtoks - \ctxlua{metapost.setoutercolor(\number\MPcolormethod,\number\currentcolormodel,\number\dogetattribute{color},\number\dogetattribute{transparency})}% + \ctxlua{metapost.setoutercolor(\number\MPcolormethod,\number\attribute\colormodelattribute,\number\attribute\colorattribute,\number\dogetattribute{transparency})}% \to \everyMPgraphic \startMPinitializations diff --git a/tex/context/base/meta-tex.mkiv b/tex/context/base/meta-tex.mkiv index 644db27d9..f31910460 100644 --- a/tex/context/base/meta-tex.mkiv +++ b/tex/context/base/meta-tex.mkiv @@ -19,6 +19,10 @@ % looks a bit like a hack. But in fact this method is obsolete and % eventually might go away. +\installcorenamespace{graphictextext} +\installcorenamespace{graphictexdepth} +\installcorenamespace{graphictexarguments} + \unexpanded\def\startTeXtexts#1\stopTeXtexts {#1} @@ -28,23 +32,23 @@ {\dosingleempty\mp_textext} \def\mp_textext[#1]#2#3% contrary to mkii we don't process yet but we do expand - {\setxvalue{\??gx:#2}{\mp_textext_indeed{#1}{#3}}} + {\setxvalue{\??graphictextext#2}{\mp_textext_indeed{#1}{#3}}} \unexpanded\def\mp_textext_indeed#1#2% {\begingroup \setbox\nextbox\hbox{#2}% - \executeifdefined{\??gx:m:#1}{\getvalue{\??gx:m:depth}}% + \executeifdefined{\??graphictexdepth#1}{\getvalue{\??graphictexdepth\s!depth}}% \box\nextbox \endgroup} \def\getTeXtext#1% - {\getvalue{\??gx:#1}} + {\getvalue{\??graphictextext#1}} -\setvalue{\??gx:m:d}{\setbox\nextbox\hbox{\lower\dp\nextbox\box\nextbox}} % unchecked -\setvalue{\??gx:m:n}{} % unchecked +\setvalue{\??graphictexdepth d}{\setbox\nextbox\hbox{\lower\dp\nextbox\box\nextbox}} % unchecked +\letvalue{\??graphictexdepth n}\donothing % unchecked -\setvalue {\??gx:m:depth}{\getvalue{\??gx:m:d}} -\setvalue{\??gx:m:nodepth}{\getvalue{\??gx:m:n}} +\setvalue{\??graphictexdepth\s!depth }{\getvalue{\??graphictexdepth d}} +\letvalue{\??graphictexdepth\s!nodepth}\donothing % \definetextext[framed]{\framed} % @@ -66,8 +70,8 @@ {\def\currenttextext{#1}% \doifnextoptionalelse\mp_define_textext_one\mp_define_textext_zero} -\def\mp_define_textext_one {\setvalue{\??gx:1:\currenttextext}} -\def\mp_define_textext_zero{\setvalue{\??gx:0:\currenttextext}} +\def\mp_define_textext_one {\setvalue{\??graphictexarguments1:\currenttextext}} +\def\mp_define_textext_zero{\setvalue{\??graphictexarguments0:\currenttextext}} \def\sometxt#1#{\mp_some_txt{#1}} @@ -80,20 +84,20 @@ \def\mp_some_txt_indeed_yes[#1]% {\def\currenttextext{#1}% - \csname\??gx:% - \ifcsname\??gx:0:#1\endcsname0\else - \ifcsname\??gx:1:#1\endcsname1\else - ?\fi\fi + \csname\??graphictexarguments + \ifcsname\??graphictexarguments0:#1\endcsname0\else + \ifcsname\??graphictexarguments1:#1\endcsname1\else + ?\fi\fi \endcsname} \def\mp_some_txt_indeed_nop {} -\setvalue{\??gx:?}{} -\setvalue{\??gx:0}{\csname\??gx:0:\currenttextext\endcsname} -\setvalue{\??gx:1}{\dosingleempty\mp_gx_one} +\setvalue{\??graphictexarguments ?}{} +\setvalue{\??graphictexarguments 0}{\csname\??graphictexarguments\currenttextext\endcsname} +\setvalue{\??graphictexarguments 1}{\dosingleempty\mp_gx_one} -\def\mp_gx_one{\csname\??gx:1:\currenttextext\endcsname} +\def\mp_gx_one{\csname\??graphictexarguments1:\currenttextext\endcsname} % \definetextext[framed][#1]#2{\framed[width=4cm]{\switchtobodyfont[#1]#2}} % \definetextext[simple]{\framed[width=8cm]} diff --git a/tex/context/base/mlib-pdf.mkiv b/tex/context/base/mlib-pdf.mkiv index 05c772720..407ecb534 100644 --- a/tex/context/base/mlib-pdf.mkiv +++ b/tex/context/base/mlib-pdf.mkiv @@ -93,7 +93,7 @@ \def\startMPLIBtoPDF#1#2#3#4% {\dostarttagged\t!mpgraphic\empty \naturalhbox attr \imageattribute 1 \bgroup - \doactivatecolor\s!black\forcecolorhack + \dousecolorparameter\s!black\forcecolorhack \setMPboundingbox{#1}{#2}{#3}{#4}% \setbox\MPbox\vbox\bgroup % \forgetall % already done elsewhere @@ -130,23 +130,23 @@ \def\directstopMPLIBtoPDF {\normalstopMPLIBtoPDF\stopTEXpage} \unexpanded\def\directMPgraphic - {\dodoublegroupempty\dodirectMPgraphic} + {\dodoublegroupempty\mlib_direct_graphic} -\unexpanded\long\def\directMPgraphic#1#2% makes pages (todo: make boxes) - {\beginMPgraphicgroup{#1}% +\def\mlib_direct_graphic#1#2% makes pages (todo: make boxes) + {\mp_begin_graphic_group{#1}% \let\startMPLIBtoPDF\directstartMPLIBtoPDF \let\stopMPLIBtoPDF \directstopMPLIBtoPDF - \dostartcurrentMPgraphic + \mp_start_current_graphic \forgetall \normalexpanded{\noexpand\ctxlua{metapost.graphic( "\currentMPgraphicinstance", "\currentMPgraphicformat", \!!bs#2;\!!es, - \!!bs\currentMPinitializations;\!!es, - \!!bs\currentMPpreamble;\!!es, + \!!bs\mp_flush_current_initializations;\!!es, + \!!bs\mp_flush_current_preamble;\!!es, "all" )}}% - \dostopcurrentMPgraphic - \endMPgraphicgroup} + \mp_stop_current_graphic + \mp_end_graphic_group} \protect \endinput diff --git a/tex/context/base/mlib-pps.mkiv b/tex/context/base/mlib-pps.mkiv index cebaddb0c..a9b2e6e70 100644 --- a/tex/context/base/mlib-pps.mkiv +++ b/tex/context/base/mlib-pps.mkiv @@ -17,20 +17,7 @@ %D Todo: catch nested graphics like external figures with dummies. -% \newtoks\everyMPLIBtext % not yet used - -% \appendtoks -% \let\handleuseMPgraphic \thirdofthreearguments -% \let\handlereusableMPgraphic\thirdofthreearguments -% \to \everyMPLIBtext - -% this will move ! - -% Instead of preallocated boxes we now use a table of lists so that we -% have no limitation. Typically an example of a next version solution -% due to \LUATEX\ evolving. - -% TODO: foigure out why this is shifted +% todo: figure out why this is shifted % % \setupbodyfont[palatino] % @@ -40,8 +27,8 @@ % \stopMPpage % \stoptext % -% A slightly larger picturew works ok. Some kind of interference -% with the OTR. +% A slightly larger picture works ok so maybe there is some kind +% of interference with the page builder. \newbox \MPtextbox \newtoks\everyMPLIBsettext diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index 902f88f45..444418a90 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -122,7 +122,7 @@ % End of experimental code. \unexpanded\def\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 + {\ifx#2\relax\let#2\empty\fi % it is hardly faster but produces less expansion tracing %\def#3##1{\csname#4{#1#2}{##1}\endcsname}% \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}% @@ -159,16 +159,17 @@ \unexpanded\def\interfaces_install_parameter_hash_handler#1#2#3#4#5#6#7#8#9% {\ifx#2\relax\let#2\empty\fi - \def#3##1{#4{#1#2}{##1}:}% + \def#3##1{#1#4{#1#2}{##1}:}% leading #1 was missing .. is this one used? \def#4##1##2{\ifcsname##1:##2\endcsname##1\else\expandafter#5\csname##1:\s!parent\endcsname{##2}\fi}% - \def#5##1##2{\ifx##1\relax\else#4{##1}{##2}\fi}% is {} needed around ##1 ? + \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}% \unexpanded\def#9##1{\expandafter\edef\csname#1##1:\s!parent\endcsname{#1#2}}} \unexpanded\def\installparameterhashhandler#1#2% - {\normalexpanded + {\expandafter\let\csname#2namespace\endcsname#1% + \normalexpanded {\interfaces_install_parameter_hash_handler {\noexpand#1}% \??aa \expandafter\noexpand\csname current#2\endcsname @@ -183,19 +184,21 @@ % In \MKIV\ we can probably use the english variant for all other % languages too. -\unexpanded\def\interfaces_install_parameter_set_handler#1#2#3#4#5% we can speed this up for english +\unexpanded\def\interfaces_install_parameter_set_handler#1#2#3#4#5#6% we can speed this up for english {\ifx#2\relax\let#2\empty\fi - \unexpanded\def#3{\dosetvalue{#1#2:}}% ##1 {##2} (braces are mandate) - \unexpanded\def#4{\doletvalue{#1#2:}}% ##1 ##2 - \unexpanded\def#5{\doletvalue{#1#2:}\empty}}% ##1 + \unexpanded\def#3{\dosetvalue {#1#2:}}% ##1 {##2} (braces are mandate) + \unexpanded\def#4{\dosetevalue{#1#2:}}% ##1 {##2} (braces are mandate) + \unexpanded\def#5{\doletvalue {#1#2:}}% ##1 ##2 + \unexpanded\def#6{\doletvalue {#1#2:}\empty}}% ##1 \startinterface english - \unexpanded\def\interfaces_install_parameter_set_handler#1#2#3#4#5% + \unexpanded\def\interfaces_install_parameter_set_handler#1#2#3#4#5#6% {\ifx#2\relax\let#2\empty\fi - \unexpanded\def#3##1{\expandafter\def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) - \unexpanded\def#4##1{\expandafter\let\csname#1#2:##1\endcsname}% ##1 ##2 - \unexpanded\def#5##1{\expandafter\let\csname#1#2:##1\endcsname\empty}}% ##1 + \unexpanded\def#3##1{\expandafter \def\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) + \unexpanded\def#4##1{\expandafter\edef\csname#1#2:##1\endcsname}% ##1 {##2} (braces are mandate) + \unexpanded\def#5##1{\expandafter \let\csname#1#2:##1\endcsname}% ##1 ##2 + \unexpanded\def#6##1{\expandafter \let\csname#1#2:##1\endcsname\empty}}% ##1 \stopinterface @@ -205,6 +208,7 @@ {\noexpand#1}% \??aa \expandafter\noexpand\csname current#2\endcsname \expandafter\noexpand\csname set#2parameter\endcsname + \expandafter\noexpand\csname setexpanded#2parameter\endcsname \expandafter\noexpand\csname let#2parameter\endcsname \expandafter\noexpand\csname reset#2parameter\endcsname}} @@ -425,8 +429,157 @@ \installsetuphandler {#1}{#2}% \installstyleandcolorhandler {#1}{#2}} -\unexpanded\def\installnamespace#1% - {\setvalue{????#1}{@@@@#1}} +%D Many mechanisms have some kind of inheritance in place, and these are +%D the speed||critical ones. Therefore there is no reason to stick to +%D \type {\@@xxkey} for the sake of performance. For this reason we also +%D provide a direct variant. This permits a more consistent treatment of +%D namespaces. A \type {\whateverparameter} call is three times slower +%D and a \type {\directwhateverparameter} call two times but for some +%D 100K expansions we only loose some .1 second which is neglectable +%D given the small amount of expansions in real runs. + +%D We don't need colons for such simple cases. + +\unexpanded\def\interfaces_install_direct_parameter_handler#1#2#3#4% + {\def#2##1{\csname\ifcsname#1##1\endcsname#1##1\else\s!empty\fi\endcsname}% + \def#3##1{\detokenize\expandafter\expandafter\expandafter{\csname#1##1\endcsname}}% + \def#4##1{\csname#1##1\endcsname}} + +\unexpanded\def\installdirectparameterhandler#1#2% + {\normalexpanded + {\interfaces_install_direct_parameter_handler + {\noexpand#1}% + \expandafter\noexpand\csname #2parameter\endcsname + \expandafter\noexpand\csname detokenized#2parameter\endcsname + \expandafter\noexpand\csname direct#2parameter\endcsname}} + +\unexpanded\def\interfaces_install_direct_setup_handler#1#2#3#4% + {\unexpanded\def#2{\dosingleempty#3}% + \newtoks#4% + \def#3[##1]% + {\interfaces_get_parameters#1[##1]% + \the#4}} + +\unexpanded\def\installdirectsetuphandler#1#2% + {\normalexpanded + {\interfaces_install_direct_setup_handler + {\noexpand#1}% \??aa + \expandafter\noexpand\csname setup#2\endcsname + \expandafter\noexpand\csname d@setup#2\endcsname + \expandafter\noexpand\csname everysetup#2\endcsname}} + +\unexpanded\def\interfaces_install_direct_parameter_set_handler#1#2#3#4#5% + {\unexpanded\def#2{\dosetvalue #1}% + \unexpanded\def#3{\dosetevalue#1}% + \unexpanded\def#4{\doletvalue #1}% + \unexpanded\def#5{\doletvalue #1\empty}}% + +\startinterface english + + \unexpanded\def\interfaces_install_direct_parameter_set_handler#1#2#3#4#5% + {\unexpanded\def#2##1{\expandafter \def\csname#1##1\endcsname}% + \unexpanded\def#3##1{\expandafter\edef\csname#1##1\endcsname}% + \unexpanded\def#4##1{\expandafter \let\csname#1##1\endcsname}% + \unexpanded\def#5##1{\expandafter \let\csname#1##1\endcsname\empty}}% + +\stopinterface + +\unexpanded\def\installdirectparametersethandler#1#2% + {\normalexpanded + {\interfaces_install_direct_parameter_set_handler + {\noexpand#1}% \??aa + \expandafter\noexpand\csname set#2parameter\endcsname + \expandafter\noexpand\csname setexpanded#2parameter\endcsname + \expandafter\noexpand\csname let#2parameter\endcsname + \expandafter\noexpand\csname reset#2parameter\endcsname}} + +\let\installdirectstyleandcolorhandler\installstyleandcolorhandler + +\unexpanded\def\installdirectcommandhandler#1#2% + {\installdirectparameterhandler {#1}{#2}% + \installdirectsetuphandler {#1}{#2}% + \installdirectparametersethandler {#1}{#2}% + \installdirectstyleandcolorhandler{#1}{#2}} + +% Experiment: + +% \installcorenamespace {one} +% \installcorenamespace {two} +% +% \installcommandhandler \??one {one} \??one +% \installcommandhandler \??two {two} \??two +% +% \defineone[test] \setupone[test][alpha=first] +% \definetwo[test] \setuptwo[test][beta=second] +% +% \protect +% +% \def\currentone{test} +% \def\currenttwo{test} +% +% \relateparameterhandlers {two} {test} {one} {test} +% +% yes:\oneparameter{alpha}\par +% nop:\oneparameter{beta}\par +% yes:\twoparameter{alpha}\par +% yes:\twoparameter{beta}\par + +\unexpanded\def\relateparameterhandlers#1#2#3#4% {from} {instance} {to} {instance} + {\expandafter\edef\csname\csname#1namespace\endcsname#2:\s!parent\endcsname{\csname#3namespace\endcsname#4}} + +% First we had, in tune with the regular system variables: +% +% \starttyping +% \unexpanded\def\installnamespace#1{\setvalue{????#1}{@@@@#1}} +% \stoptyping +% +% The following variant is nicer and in principle faster but that gets +% unnoticed unless lots of expansion happens. Also, we can use long tags +% but the internal expansion will be relatively small (and unlikely more +% than 4 characters). For instance, \??xx used to expand to @@xx but now +% becomes for instance 123::. This is one character more but in quite some +% cases we had : after such a tag in the old situation. In the new situation +% we create more namespaces and don't need that : any more, so we end up +% with on the average the same amount of tokens and definitely less when +% we consider cases like \??xx:\c!align: which now is just \??somealign and +% therefore has length 5 now (instead of 4+1+5+1=10). +% +% Eventualy we will have a verbose \blablanamespace and the difference between +% core and regular can go ... after all, \xxxparameter can already clash between +% the two prefix groups .. if users use this mechanism a lot they should use +% verbose names anyway (the old two character names were mostly an optimization +% as they also expanded to these characters). + +% todo: register namespaces at lua end for logging and reverse resolve +% todo: move this to syst-ini so that we can use it real early + +\newcount\interfaces_n_of_namespaces + +\def\v_interfaces_prefix_template{\number \interfaces_n_of_namespaces::} +\def\v_interfaces_prefix_template{\characters\interfaces_n_of_namespaces::} +\def\v_interfaces_prefix_template{\number \interfaces_n_of_namespaces>} +\def\v_interfaces_prefix_template{\characters\interfaces_n_of_namespaces>} + +\def\v_interfaces_prefix_template % consistently %03i> + {\ifnum\interfaces_n_of_namespaces<\plusten00\else\ifnum\interfaces_n_of_namespaces<\plushundred0\fi\fi + \number\interfaces_n_of_namespaces>} + +\unexpanded\def\installnamespace#1% for modules and users + {\ifcsname ????#1\endcsname + \writestatus\m!system{duplicate user namespace '#1'}\wait + \else + \global\advance\interfaces_n_of_namespaces\plusone + \expandafter\edef\csname ????#1\endcsname{\v_interfaces_prefix_template}% + \fi} + +\unexpanded\def\installcorenamespace#1% + {\ifcsname ??#1\endcsname + \writestatus\m!system{duplicate core namespace '#1'}\wait + \else + \global\advance\interfaces_n_of_namespaces\plusone + \expandafter\edef\csname ??#1\endcsname{\v_interfaces_prefix_template}% + \ctxcommand{registernamespace(\number\interfaces_n_of_namespaces,"#1")}% + \fi} % \enabletrackers[interfaces.namespaces,context.flush] % @@ -463,6 +616,8 @@ % “\testparameter{text}” % % \stoptext +% +% This is a user (module) command: \unexpanded\def\definenamespace {\dodoubleargument\interfaces_define_name_space} @@ -479,7 +634,7 @@ %D \showparentchain{@@am}{left} %D \stoptyping -\def\showparentchain#1#2% +\unexpanded\def\showparentchain#1#2% {\writestatus\m!system{chain: [ \interfaces_show_parent_chain{#1#2}]}} \def\interfaces_show_parent_chain#1% diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii index e6aab7ad5..14631c9c7 100644 --- a/tex/context/base/mult-de.mkii +++ b/tex/context/base/mult-de.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{coupling}{verknuepfung} \setinterfaceconstant{couplingway}{verkopplungsart} \setinterfaceconstant{criterium}{kriterium} +\setinterfaceconstant{css}{css} \setinterfaceconstant{current}{aktuell} \setinterfaceconstant{cutspace}{cutspace} \setinterfaceconstant{dash}{strich} @@ -650,6 +651,7 @@ \setinterfaceconstant{editoretallimit}{editoretallimit} \setinterfaceconstant{editoretaltext}{editoretaltext} \setinterfaceconstant{empty}{leer} +\setinterfaceconstant{entities}{entities} \setinterfaceconstant{entries}{entries} \setinterfaceconstant{equalheight}{equalheight} \setinterfaceconstant{equalwidth}{equalwidth} @@ -1042,6 +1044,7 @@ \setinterfaceconstant{white}{weiss} \setinterfaceconstant{width}{breite} \setinterfaceconstant{xfactor}{xfaktor} +\setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} \setinterfaceconstant{xoffset}{xoffset} \setinterfaceconstant{xscale}{xformat} diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index 8430154ed..2ed8fe3f3 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -6456,6 +6456,19 @@ return { ["en"]="dash", ["nl"]="streep", }, + ["export"] = { + ["en"]="export", + }, + ["css"] = { + ["en"]="css", + }, + ["xhtml"] = { + ["en"]="xhtml", + }, + ["entities"]={ + ["en"]="entities", + ["nl"]="entities", + }, ["labeloffset"]={ ["en"]="labeloffset", }, diff --git a/tex/context/base/mult-dim.mkvi b/tex/context/base/mult-dim.mkvi new file mode 100644 index 000000000..1b49017f4 --- /dev/null +++ b/tex/context/base/mult-dim.mkvi @@ -0,0 +1,123 @@ +%D \module +%D [ file=core-gen, +%D version=1995.10.10, +%D title=\CONTEXT\ Core Macros, +%D subtitle=General, +%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 Core Macros / General} + +\unprotect + +%D \macros +%D {assigndimension,assignalfadimension} +%D +%D The following commands are used to process keyword based +%D dimension setters. +%D +%D \starttyping +%D \assigndimension +%D {|small|medium|big|-small|-medium|-big|none} +%D {\dimension} +%D {value small} +%D {value medium} +%D {value big} +%D \stoptyping +%D +%D The given keyword determines the result. + +\installcorenamespace{dimensionnormal} + +\setvalue{\??dimensionnormal \v!none }#value#dimension#small#medium#big{#dimension\zeropoint} +\setvalue{\??dimensionnormal \v!small }#value#dimension#small#medium#big{#dimension=#small\relax} +\setvalue{\??dimensionnormal \v!medium}#value#dimension#small#medium#big{#dimension=#medium\relax} +\setvalue{\??dimensionnormal \v!big }#value#dimension#small#medium#big{#dimension=#big\relax} +\setvalue{\??dimensionnormal-\v!small }#value#dimension#small#medium#big{#dimension=-#small\relax} +\setvalue{\??dimensionnormal-\v!medium}#value#dimension#small#medium#big{#dimension=-#medium\relax} +\setvalue{\??dimensionnormal-\v!big }#value#dimension#small#medium#big{#dimension=-#big\relax} +\setvalue{\??dimensionnormal\s!unknown}#value#dimension#small#medium#big{#dimension=-#value\relax} + +\unexpanded\def\assigndimension#value% + {\csname\??dimensionnormal\ifcsname\??dimensionnormal#value\endcsname#value\else\s!unknown\fi\endcsname{#value}} + +%D The next variant assigns to a macro instead of a dimension. +%D +%D \starttyping +%D \assignalfadimension +%D {|small|medium|big|none} +%D {\macro} +%D {value small} +%D {value medium} +%D {value big} +%D \stoptyping +%D +%D This one is used for factors. + +\installcorenamespace{dimensionalfa} + +\setvalue{\??dimensionalfa\v!none }#value#macro#small#medium#big{\let #macro\!!zerocount} +\setvalue{\??dimensionalfa\v!small }#value#macro#small#medium#big{\edef#macro{#small}} +\setvalue{\??dimensionalfa\v!medium }#value#macro#small#medium#big{\edef#macro{#medium}} +\setvalue{\??dimensionalfa\v!big }#value#macro#small#medium#big{\edef#macro{#big}} +\setvalue{\??dimensionalfa\s!unknown}#value#macro#small#medium#big{\edef#macro{#value}} + +\unexpanded\def\assignalfadimension#value% + {\csname\??dimensionalfa\ifcsname\??dimensionalfa#value\endcsname#value\else\s!unknown\fi\endcsname{#value}} + +%D \macros +%D {assignvalue} +%D +%D A variant that does not assume dimenions ios the following: +%D +%D \starttyping +%D \assignvalue +%D {|small|medium|big} +%D {\macro} +%D {value small} +%D {value medium} +%D {value big} +%D \stoptyping + +\installcorenamespace{dimensionvalue} + +\setvalue{\??dimensionvalue\v!small }#macro#small#medium#big{\edef#macro{#small}} +\setvalue{\??dimensionvalue\v!medium }#macro#small#medium#big{\edef#macro{#medium}} +\setvalue{\??dimensionvalue\v!big }#macro#small#medium#big{\edef#macro{#big}} +\setvalue{\??dimensionvalue\s!unknown}#macro#small#medium#big{\let #macro\empty} + +\unexpanded\def\assignvalue#value% + {\csname\??dimensionvalue\ifcsname\??dimensionvalue#value\endcsname#value\else\s!unknown\fi\endcsname} + +%D \macros +%D {assignwidth} +%D +%D Een breedte van een opgegeven tekst kan worden berekend en +%D toegekend aan een \DIMENSION\ met: +%D +%D \starttyping +%D \assignwidth +%D {|fit|broad} +%D {\dimension} +%D {text} +%D {extra} +%D \stoptyping + +\installcorenamespace{dimensionwidth} + +\newbox\b_assign_width + +\setvalue{\??dimensionwidth }#value#dimension#content#extra{\setbox\b_assign_width\hbox{#content}#dimension\wd\b_assign_width\b_assign_width\emptybox} +\setvalue{\??dimensionwidth\v!fit }#value#dimension#content#extra{\setbox\b_assign_width\hbox{#content}#dimension\wd\b_assign_width\b_assign_width\emptybox} +\setvalue{\??dimensionwidth\v!broad }#value#dimension#content#extra{\setbox\b_assign_width\hbox{#content}#dimension\dimexpr\wd\b_assign_width+#extra\relax\b_assign_width\emptybox} +\setvalue{\??dimensionwidth\v!unknown}#value#dimension#content#extra{#dimension=#value\relax} + +\unexpanded\def\assignwidth#value% + {\csname\??dimensionwidth\ifcsname\??dimensionwidth#value\endcsname#value\else\s!unknown\fi\endcsname{#value}} + +\protect \endinput diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii index a646a51c6..57f627906 100644 --- a/tex/context/base/mult-en.mkii +++ b/tex/context/base/mult-en.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{coupling}{coupling} \setinterfaceconstant{couplingway}{couplingway} \setinterfaceconstant{criterium}{criterium} +\setinterfaceconstant{css}{css} \setinterfaceconstant{current}{current} \setinterfaceconstant{cutspace}{cutspace} \setinterfaceconstant{dash}{dash} @@ -650,6 +651,7 @@ \setinterfaceconstant{editoretallimit}{editoretallimit} \setinterfaceconstant{editoretaltext}{editoretaltext} \setinterfaceconstant{empty}{empty} +\setinterfaceconstant{entities}{entities} \setinterfaceconstant{entries}{entries} \setinterfaceconstant{equalheight}{equalheight} \setinterfaceconstant{equalwidth}{equalwidth} @@ -1042,6 +1044,7 @@ \setinterfaceconstant{white}{white} \setinterfaceconstant{width}{width} \setinterfaceconstant{xfactor}{xfactor} +\setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} \setinterfaceconstant{xoffset}{xoffset} \setinterfaceconstant{xscale}{xscale} diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii index dd8e69434..f2a5599d7 100644 --- a/tex/context/base/mult-fr.mkii +++ b/tex/context/base/mult-fr.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{coupling}{couplage} \setinterfaceconstant{couplingway}{modecouplage} \setinterfaceconstant{criterium}{critere} +\setinterfaceconstant{css}{css} \setinterfaceconstant{current}{courant} \setinterfaceconstant{cutspace}{cutspace} \setinterfaceconstant{dash}{pointille} @@ -650,6 +651,7 @@ \setinterfaceconstant{editoretallimit}{editoretallimit} \setinterfaceconstant{editoretaltext}{editoretaltext} \setinterfaceconstant{empty}{vide} +\setinterfaceconstant{entities}{entities} \setinterfaceconstant{entries}{entries} \setinterfaceconstant{equalheight}{equalheight} \setinterfaceconstant{equalwidth}{equalwidth} @@ -1042,6 +1044,7 @@ \setinterfaceconstant{white}{blanc} \setinterfaceconstant{width}{largeur} \setinterfaceconstant{xfactor}{xfactor} +\setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} \setinterfaceconstant{xoffset}{xoffset} \setinterfaceconstant{xscale}{xscale} diff --git a/tex/context/base/mult-ini.lua b/tex/context/base/mult-ini.lua index e073130db..4ec50d350 100644 --- a/tex/context/base/mult-ini.lua +++ b/tex/context/base/mult-ini.lua @@ -17,18 +17,20 @@ local setmetatableindex = table.setmetatableindex local report_interface = logs.reporter("interface","initialization") -interfaces = interfaces or { } -interfaces.constants = mark(interfaces.constants or { }) -interfaces.variables = mark(interfaces.variables or { }) -interfaces.elements = mark(interfaces.elements or { }) -interfaces.formats = mark(interfaces.formats or { }) -interfaces.translations = mark(interfaces.translations or { }) - -storage.register("interfaces/constants", interfaces.constants, "interfaces.constants") -storage.register("interfaces/variables", interfaces.variables, "interfaces.variables") -storage.register("interfaces/elements", interfaces.elements, "interfaces.elements") -storage.register("interfaces/formats", interfaces.formats, "interfaces.formats") -storage.register("interfaces/translations", interfaces.translations, "interfaces.translations") +interfaces = interfaces or { } +interfaces.constants = mark(interfaces.constants or { }) +interfaces.variables = mark(interfaces.variables or { }) +interfaces.elements = mark(interfaces.elements or { }) +interfaces.formats = mark(interfaces.formats or { }) +interfaces.translations = mark(interfaces.translations or { }) +interfaces.corenamespaces = mark(interfaces.corenamespaces or { }) + +storage.register("interfaces/constants", interfaces.constants, "interfaces.constants") +storage.register("interfaces/variables", interfaces.variables, "interfaces.variables") +storage.register("interfaces/elements", interfaces.elements, "interfaces.elements") +storage.register("interfaces/formats", interfaces.formats, "interfaces.formats") +storage.register("interfaces/translations", interfaces.translations, "interfaces.translations") +storage.register("interfaces/corenamespaces", interfaces.corenamespaces, "interfaces.corenamespaces") interfaces.interfaces = { "cs", "de", "en", "fr", "it", "nl", "ro", "pe", @@ -54,12 +56,13 @@ end setmetatableindex(complete, resolve) -local constants = interfaces.constants -local variables = interfaces.variables -local elements = interfaces.elements -local formats = interfaces.formats -local translations = interfaces.translations -local reporters = { } -- just an optimization +local constants = interfaces.constants +local variables = interfaces.variables +local elements = interfaces.elements +local formats = interfaces.formats +local translations = interfaces.translations +local corenamespaces = interfaces.corenamespaces +local reporters = { } -- just an optimization local function valueiskey(t,k) -- will be helper t[k] = k @@ -72,6 +75,10 @@ setmetatableindex(elements, valueiskey) setmetatableindex(formats, valueiskey) setmetatableindex(translations, valueiskey) +function commands.registernamespace(n,namespace) + corenamespaces[n] = namespace +end + local function resolve(t,k) local v = logs.reporter(k) t[k] = v diff --git a/tex/context/base/mult-ini.mkiv b/tex/context/base/mult-ini.mkiv index 5f20bec15..0ec6e4239 100644 --- a/tex/context/base/mult-ini.mkiv +++ b/tex/context/base/mult-ini.mkiv @@ -43,10 +43,7 @@ %D \NC \type{\e!prefix!} \NC e! \NC element \NC\MR %D \NC \type{\f!prefix!} \NC f! \NC file \NC\MR %D \NC \type{\k!prefix!} \NC k! \NC constant (indirect) \NC\MR -%D \NC \type{\l!prefix!} \NC l! \NC language \NC\MR %D \NC \type{\m!prefix!} \NC m! \NC age \NC\MR -%D \NC \type{\p!prefix!} \NC p! \NC procedure \NC\MR -%D \NC \type{\r!prefix!} \NC r! \NC reference \NC\MR %D \NC \type{\s!prefix!} \NC s! \NC system \NC\MR %D \NC \type{\v!prefix!} \NC v! \NC variable \NC\MR %D \HL @@ -54,12 +51,16 @@ %D \stoplinecorrection %D %D In the single||lingual version we used \type{!}, \type{!!}, -%D \type{!!!} and \type{!!!!}. +%D \type{!!!} and \type{!!!!}. In the meantime some of these +%D are obsolete (we had some 12 originally). -\def\c!prefix!{c!} \def\e!prefix!{e!} \def\f!prefix!{f!} -\def\k!prefix!{k!} \def\l!prefix!{l!} \def\m!prefix!{m!} -\def\p!prefix!{p!} \def\r!prefix!{r!} \def\s!prefix!{s!} -\def\v!prefix!{v!} \def\t!prefix!{t!} +\def\c!prefix!{c!} +\def\e!prefix!{e!} +\def\f!prefix!{f!} % for the moment we keep this one +\def\k!prefix!{k!} +\def\m!prefix!{m!} +\def\s!prefix!{s!} +\def\v!prefix!{v!} %D \macros %D [constants,variables,commands] @@ -131,7 +132,6 @@ %D definesystemvariable, %D definesystemconstant, %D definemessageconstant, -%D definereferenceconstant, %D definefileconstant} %D %D The first part of this module is dedicated to dealing with @@ -169,17 +169,11 @@ %D Next come some interface independant constants: %D %D \starttyping -%D \definereferenceconstant {name} {meaning} %D \definefileconstant {name} {meaning} %D \stoptyping -\unexpanded\def\definereferenceconstant #1#2{\expandafter\def\csname\r!prefix!#1\endcsname{#2}} % obsolete \unexpanded\def\definefileconstant #1#2{\expandafter\def\csname\f!prefix!#1\endcsname{#2}} -%D A new one: - -\unexpanded\def\definetypescriptconstant#1#2{\expandafter\def\csname\t!prefix!#1\endcsname{#2}} - %D And finaly we have the one argument, space saving constants %D %D \starttyping diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii index f562b3e21..c1bb74fd6 100644 --- a/tex/context/base/mult-it.mkii +++ b/tex/context/base/mult-it.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{coupling}{accoppiamento} \setinterfaceconstant{couplingway}{modoaccoppiamento} \setinterfaceconstant{criterium}{criterio} +\setinterfaceconstant{css}{css} \setinterfaceconstant{current}{corrente} \setinterfaceconstant{cutspace}{cutspace} \setinterfaceconstant{dash}{dash} @@ -650,6 +651,7 @@ \setinterfaceconstant{editoretallimit}{editoretallimit} \setinterfaceconstant{editoretaltext}{editoretaltext} \setinterfaceconstant{empty}{vuoto} +\setinterfaceconstant{entities}{entities} \setinterfaceconstant{entries}{entries} \setinterfaceconstant{equalheight}{equalheight} \setinterfaceconstant{equalwidth}{equalwidth} @@ -1042,6 +1044,7 @@ \setinterfaceconstant{white}{bianco} \setinterfaceconstant{width}{ampiezza} \setinterfaceconstant{xfactor}{xfactor} +\setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} \setinterfaceconstant{xoffset}{xoffset} \setinterfaceconstant{xscale}{xscale} diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index d2bd4f116..51d0da537 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['mult-low'] = { +ctxlatecommandif not modules then modules = { } end modules ['mult-low'] = { version = 1.001, comment = "companion to mult-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -63,6 +63,7 @@ return { -- maybe a different class -- "startmode", "stopmode", "startnotmode", "stopnotmode", "doifmode", "doifmodeelse", "doifnotmode", + "startallmodes", "stopallmodes", "startnotallmodes", "stopnotallmodes", "doifallmodes", "doifallmodeselse", "doifnotallmodes", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", @@ -74,6 +75,10 @@ return { -- "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", + "startluasetups", "stopluasetups", + "starttexsetups", "stoptexsetups", + "startrawsetups", "stoprawsetups", + "startlocalsetups", "stoplocalsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", -- @@ -170,6 +175,7 @@ return { "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "setconstant", -- "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", + "dosingleargument", "dodoubleargument", "dotripleargument", "doquadrupleargument", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", -- "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii index 965a92aae..8d6f46ed3 100644 --- a/tex/context/base/mult-nl.mkii +++ b/tex/context/base/mult-nl.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{coupling}{koppeling} \setinterfaceconstant{couplingway}{koppelwijze} \setinterfaceconstant{criterium}{criterium} +\setinterfaceconstant{css}{css} \setinterfaceconstant{current}{huidige} \setinterfaceconstant{cutspace}{snijwit} \setinterfaceconstant{dash}{streep} @@ -650,6 +651,7 @@ \setinterfaceconstant{editoretallimit}{editoretallimit} \setinterfaceconstant{editoretaltext}{editoretaltext} \setinterfaceconstant{empty}{leeg} +\setinterfaceconstant{entities}{entities} \setinterfaceconstant{entries}{ingangen} \setinterfaceconstant{equalheight}{equalheight} \setinterfaceconstant{equalwidth}{equalwidth} @@ -1042,6 +1044,7 @@ \setinterfaceconstant{white}{wit} \setinterfaceconstant{width}{breedte} \setinterfaceconstant{xfactor}{xfactor} +\setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} \setinterfaceconstant{xoffset}{xoffset} \setinterfaceconstant{xscale}{xschaal} diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii index 08b4f1533..074869620 100644 --- a/tex/context/base/mult-pe.mkii +++ b/tex/context/base/mult-pe.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{coupling}{تزویج} \setinterfaceconstant{couplingway}{روش‌تزویج} \setinterfaceconstant{criterium}{criterium} +\setinterfaceconstant{css}{css} \setinterfaceconstant{current}{جاری} \setinterfaceconstant{cutspace}{فضای‌برش} \setinterfaceconstant{dash}{دش} @@ -650,6 +651,7 @@ \setinterfaceconstant{editoretallimit}{editoretallimit} \setinterfaceconstant{editoretaltext}{editoretaltext} \setinterfaceconstant{empty}{تهی} +\setinterfaceconstant{entities}{entities} \setinterfaceconstant{entries}{entries} \setinterfaceconstant{equalheight}{ارتفاع‌یکسان} \setinterfaceconstant{equalwidth}{عرض‌یکسان} @@ -1042,6 +1044,7 @@ \setinterfaceconstant{white}{سفید} \setinterfaceconstant{width}{عرض} \setinterfaceconstant{xfactor}{فاکتورایکس} +\setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} \setinterfaceconstant{xoffset}{آفست‌ایکس} \setinterfaceconstant{xscale}{مقیاس‌ایکس} diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii index 8fafc2ca3..e5b2c2dd8 100644 --- a/tex/context/base/mult-ro.mkii +++ b/tex/context/base/mult-ro.mkii @@ -622,6 +622,7 @@ \setinterfaceconstant{coupling}{cuplare} \setinterfaceconstant{couplingway}{modcuplare} \setinterfaceconstant{criterium}{criteriu} +\setinterfaceconstant{css}{css} \setinterfaceconstant{current}{curent} \setinterfaceconstant{cutspace}{cutspace} \setinterfaceconstant{dash}{dash} @@ -650,6 +651,7 @@ \setinterfaceconstant{editoretallimit}{editoretallimit} \setinterfaceconstant{editoretaltext}{editoretaltext} \setinterfaceconstant{empty}{gol} +\setinterfaceconstant{entities}{entities} \setinterfaceconstant{entries}{entries} \setinterfaceconstant{equalheight}{equalheight} \setinterfaceconstant{equalwidth}{equalwidth} @@ -1042,6 +1044,7 @@ \setinterfaceconstant{white}{alb} \setinterfaceconstant{width}{latime} \setinterfaceconstant{xfactor}{xfactor} +\setinterfaceconstant{xhtml}{xhtml} \setinterfaceconstant{xmax}{xmax} \setinterfaceconstant{xoffset}{xoffset} \setinterfaceconstant{xscale}{xscala} diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index 5467eb32f..44f4dc8c3 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -198,6 +198,7 @@ \definesystemconstant {font} \definesystemconstant {link} \definesystemconstant {parent} +\definesystemconstant {child} \definesystemconstant {clone} \definesystemconstant {section} \definesystemconstant {handler} @@ -223,6 +224,11 @@ \definesystemconstant {run} +\definesystemconstant {mode} +\definesystemconstant {setup} +\definesystemconstant {environment} +\definesystemconstant {document} + %definesystemconstant {fam} \definesystemconstant {text} \definesystemconstant {script} @@ -293,6 +299,20 @@ \definesystemconstant {extensions} \definesystemconstant {initializations} +\definesystemconstant {rgb} +\definesystemconstant {cmyk} +\definesystemconstant {gray} +\definesystemconstant {spot} +\definesystemconstant {all} +\definesystemconstant {none} + +\definesystemconstant {map} +\definesystemconstant {special} +\definesystemconstant {size} + +\definesystemconstant {depth} +\definesystemconstant {nodepth} + %D Just to be complete we define the standard \TEX\ units. \definesystemconstant {cm} @@ -310,41 +330,6 @@ \definesystemconstant {nd} \definesystemconstant {nc} -%definesystemconstant {entrya} -%definesystemconstant {entryb} -%definesystemconstant {entryc} -%definesystemconstant {entryd} -%definesystemconstant {entry} -%definesystemconstant {see} -%definesystemconstant {from} -%definesystemconstant {to} -%definesystemconstant {synonym} -%definesystemconstant {reference} -%definesystemconstant {main} -%definesystemconstant {list} -%definesystemconstant {item} -%definesystemconstant {itemcount} -%definesystemconstant {references} -%definesystemconstant {between} -%definesystemconstant {old} -%definesystemconstant {thisisblock} -%definesystemconstant {thiswasblock} -%definesystemconstant {figurepreset} -%definesystemconstant {pass} -%definesystemconstant {list} -%definesystemconstant {margin} -%definesystemconstant {profile} -%definesystemconstant {versionbegin} -%definesystemconstant {versionend} -%definesystemconstant {cross} - -%D Reference constants are no longer used in \MKIV\ but for the -%D moment we keep this mechanism available. -%D -%D \starttyping -%D \definereferenceconstant {whatever} -%D \stoptyping - %D As the name of their define command states, the next set of %D constants is used in the message macro's. @@ -412,285 +397,148 @@ \definesystemvariable {ab} % AlignedBoxes \definesystemvariable {ac} % ACcent \definesystemvariable {ae} % AttributEs -\definesystemvariable {ag} % AchterGrond \definesystemvariable {al} % ALinea's -\definesystemvariable {am} % interActieMenu \definesystemvariable {an} % ANchor \definesystemvariable {as} % AlignmentSwitch -\definesystemvariable {at} % ATtachments -%definesystemvariable {ba} % synchronisatieBAlk -\definesystemvariable {bc} % BaCkend -\definesystemvariable {be} % startstop (BeginEnd) \definesystemvariable {bj} % BlokJe -%definesystemvariable {bk} % Blokken (floats) -%definesystemvariable {bl} % BLanko \definesystemvariable {bg} % BleedinG \definesystemvariable {bm} % BookMark -%definesystemvariable {bo} % BlankO (definitions) \definesystemvariable {bp} % BreakPoint \definesystemvariable {br} % sideBaR -%definesystemvariable {bs} % SelecteerBlokken -\definesystemvariable {bt} % BuTton -\definesystemvariable {bu} % BUffer -%definesystemvariable {bv} % Brieven \definesystemvariable {bx} % BackendExport -%definesystemvariable {by} % Per \definesystemvariable {cb} % CollectBox -\definesystemvariable {cc} % Comment -\definesystemvariable {ce} % CasEs -\definesystemvariable {cf} % Style (ColorFont) \definesystemvariable {ch} % CHaracterspacing \definesystemvariable {ci} % CItaat \definesystemvariable {ck} % Character Kerning -\definesystemvariable {cl} % kleur (CoLor setup) \definesystemvariable {cn} % CollumN \definesystemvariable {cm} % CheMical \definesystemvariable {co} % COmbinaties \definesystemvariable {cp} % CliP -\definesystemvariable {cr} % kleur (ColoR) -%definesystemvariable {cs} % kleur (ColorSeparation -\definesystemvariable {cv} % ConVersie -%definesystemvariable {cy} % CrYteria \definesystemvariable {da} % DAte \definesystemvariable {db} % Labels -\definesystemvariable {dc} % DroppedCaps \definesystemvariable {dd} % DoorDefinieren \definesystemvariable {de} % DEel \definesystemvariable {di} % DIrections \definesystemvariable {dl} % DunneLijnen \definesystemvariable {dn} % DoorNummeren \definesystemvariable {dm} % DefineMeasure -\definesystemvariable {do} % DefinieerOpmaak \definesystemvariable {du} % DUmmy -\definesystemvariable {ds} % DoorSpringen \definesystemvariable {ef} % ExternFiguur -%definesystemvariable {ec} % EnCoding \definesystemvariable {el} % Elements \definesystemvariable {en} % ENvironments -%definesystemvariable {ep} % ExternfiguurPreset -\definesystemvariable {eq} % EQalign \definesystemvariable {er} % external resources \definesystemvariable {et} % EffecT \definesystemvariable {ex} % ExterneFiguren -%definesystemvariable {fa} % font feature -\definesystemvariable {fb} % FieldBody \definesystemvariable {fc} % FramedContent -\definesystemvariable {fd} % FielDgroup -%definesystemvariable {fe} % FoxetExtensions -\definesystemvariable {ff} % FontFile -%definesystemvariable {fg} % FiGuurmaten -\definesystemvariable {fh} % FontHash \definesystemvariable {fi} % FIle Once -\definesystemvariable {fl} % Floats -\definesystemvariable {fm} % ForMules -\definesystemvariable {fn} % subformulas \definesystemvariable {fo} % xml FO (xtag) -\definesystemvariable {fp} % FilegroeP \definesystemvariable {fq} % Features -\definesystemvariable {fr} % ForM -%definesystemvariable {fs} % FileSynonym +\definesystemvariable {fr} % Division \definesystemvariable {ft} % FonTs \definesystemvariable {fu} % FontSolution -%definesystemvariable {fv} % FontVariant \definesystemvariable {fw} % simpleFonts by Wolfgang \definesystemvariable {fx} % FoXet \definesystemvariable {gr} % GRid -\definesystemvariable {gm} % Graphic Metapost \definesystemvariable {gb} % Graphic Bitmaps \definesystemvariable {gi} % Graphic Instance -\definesystemvariable {gt} % Graphic Text \definesystemvariable {gv} % Graphic Variable -\definesystemvariable {gp} % Graphic Position -\definesystemvariable {gq} % Graphic Position Method -\definesystemvariable {gx} % Graphic TeX Text \definesystemvariable {ha} % HAng \definesystemvariable {hf} % Helpers Framed -\definesystemvariable {hl} % HighLight \definesystemvariable {hs} % HSpace -%definesystemvariable {ht} % HiddenText -\definesystemvariable {ia} % Interactie -\definesystemvariable {ib} % InteractieBalk -%definesystemvariable {ic} % ICc profiles \definesystemvariable {id} % Index -%definesystemvariable {ig} % ItemGroup \definesystemvariable {ih} % InHoudsopgave -%definesystemvariable {ii} % stelIndexIn \definesystemvariable {il} % stelInvulRegelsin -%definesystemvariable {im} % InMarge \definesystemvariable {in} % INspringen \definesystemvariable {ip} % InsertPages \definesystemvariable {is} % Items \definesystemvariable {it} % stelInTerliniein \definesystemvariable {iv} % stelInvulLijnenin \definesystemvariable {ka} % KAntlijn -\definesystemvariable {kd} % KaDerteksten -\definesystemvariable {kj} % KopJes (floats) \definesystemvariable {kk} % Kapitalen \definesystemvariable {kl} % KoLommen \definesystemvariable {km} % KenMerk -%definesystemvariable {ko} % KOp(pen) \definesystemvariable {kp} % KopPelteken -%definesystemvariable {kr} % KoRps \definesystemvariable {ks} % KolomSpan \definesystemvariable {kt} % KonTakten \definesystemvariable {kw} % KontaktWaarde \definesystemvariable {la} % LAnguage -%definesystemvariable {lb} % LaBels \definesystemvariable {ld} % LegenDa \definesystemvariable {le} % LinetablE \definesystemvariable {lf} % LocalFigures \definesystemvariable {lg} % taal (LanGuage) -\definesystemvariable {li} % LIjst \definesystemvariable {lk} % LinK \definesystemvariable {ll} % Layers -%definesystemvariable {ln} % LijNen -%definesystemvariable {lo} % LOgos -\definesystemvariable {lt} % LiTeratuur \definesystemvariable {lr} % LayeR -\definesystemvariable {ls} % languageScript -\definesystemvariable {lt} % LuaTables \definesystemvariable {lu} % LUacode -\definesystemvariable {lw} % WordList \definesystemvariable {lx} % LayerteXt -\definesystemvariable {ly} % LaYout \definesystemvariable {ma} % MargeAchtergrond -\definesystemvariable {mb} % MargeBlokken -\definesystemvariable {mc} % MarginCategory +\definesystemvariable {mc} % MultiColumn \definesystemvariable {md} % MoDule -%definesystemvariable {me} % MultilingualElement (tags) -\definesystemvariable {mf} % MarginFramed -%definesystemvariable {mg} % Metapost paGe -%definesystemvariable {mh} % MultilingualHead \definesystemvariable {mi} % MultilingualInterface -\definesystemvariable {mk} % MarKering \definesystemvariable {ml} % MultilingualLabel \definesystemvariable {mm} % MultilingualMath \definesystemvariable {mt} % inline MaTh \definesystemvariable {mo} % Math Options \definesystemvariable {mp} % MetaPost -\definesystemvariable {mx} % MatriX -\definesystemvariable {ng} % parbuilders -\definesystemvariable {nh} % new heads (structure) \definesystemvariable {nn} % structurenumbering \definesystemvariable {nm} % Nummering \definesystemvariable {np} % NaastPlaatsen \definesystemvariable {nr} % Nummeren \definesystemvariable {ob} % OBjects -%definesystemvariable {of} % OFfset \definesystemvariable {oi} % OmlijndInstellingen \definesystemvariable {ol} % OmLijnd \definesystemvariable {od} % Omlijnd Defaults (simple) -\definesystemvariable {on} % ONderstreep -%definesystemvariable {oo} % OpsOmmingen -\definesystemvariable {op} % OPsomming -%definesystemvariable {or} % OtpfilteR -%definesystemvariable {os} % OffSet -%definesystemvariable {ot} % OTpsequence -\definesystemvariable {ov} % OVerlay \definesystemvariable {ox} % OffsetBox -\definesystemvariable {pa} % PAlet \definesystemvariable {pb} % PuBlication \definesystemvariable {pc} % PageComment \definesystemvariable {pe} % PagEhandler -%definesystemvariable {pf} % ProFiel -%definesystemvariable {pg} % \definesystemvariable {ph} % ParagrapH -\definesystemvariable {pl} % PLaats \definesystemvariable {pn} % PaginaNummer -\definesystemvariable {po} % PrOcessor -\definesystemvariable {pp} % PaPier \definesystemvariable {pr} % PRogrammas \definesystemvariable {ps} % PoSitioneren \definesystemvariable {pt} % PageshifT \definesystemvariable {px} % Parallel \definesystemvariable {py} % PropertYs \definesystemvariable {pv} % PublicationVariable -\definesystemvariable {qi} % colorIntentattribute -\definesystemvariable {qc} % Colorattribute (cs) -\definesystemvariable {qt} % Transparencyattribute (ts) -\definesystemvariable {qa} % Colorattribute (ca) -\definesystemvariable {qs} % Transparencyattribute (ta) \definesystemvariable {ql} % catcode table let % already defined \definesystemvariable {qd} % catcode table def % already defined \definesystemvariable {qu} % catcode table ued % already defined \definesystemvariable {qm} % catcode table meaning % already defined -\definesystemvariable {ra} % RAise -%definesystemvariable {rd} % RenDering -\definesystemvariable {re} % REferenceformat \definesystemvariable {rf} % ReFerencing -\definesystemvariable {rg} % ReGel -%definesystemvariable {rl} % ReferentieLijst \definesystemvariable {rn} % RegelNummer -\definesystemvariable {ro} % ROteren -%definesystemvariable {rr} % linenotes \definesystemvariable {rs} % RaSters \definesystemvariable {rt} % RoosTers -%definesystemvariable {rv} % ReserVeerfiguur \definesystemvariable {rw} % RenderingWindow -\definesystemvariable {sa} % ScAle \definesystemvariable {sb} % SectieBlok -\definesystemvariable {sc} % SCherm \definesystemvariable {sd} % SounD \definesystemvariable {se} % SEctie -%definesystemvariable {sf} % SpeciFics \definesystemvariable {sg} % SpacinG \definesystemvariable {sh} % ShapeText \definesystemvariable {si} % SplIt -%definesystemvariable {sk} % SectieKop \definesystemvariable {sl} % SmalLer -\definesystemvariable {sm} % SynonieMen -%definesystemvariable {sn} % SubNummer -\definesystemvariable {so} % SOrteren \definesystemvariable {sp} % SelecteerPapier \definesystemvariable {sr} % SpacehandleR -\definesystemvariable {ss} % Symbool \definesystemvariable {st} % STickers -\definesystemvariable {su} % SetUp -\definesystemvariable {sv} % SysteemVariabelen -%definesystemvariable {sw} % SectionWorld \definesystemvariable {sx} % Selector -%definesystemvariable {sy} % SYnchronisatie \definesystemvariable {ta} % TAb \definesystemvariable {tb} % TekstBlokken -\definesystemvariable {td} % TextbackgrounDs \definesystemvariable {te} % TEmplate \definesystemvariable {tf} % TypeFace -%definesystemvariable {tg} % Tex paGe \definesystemvariable {ti} % TabelInstellingen -\definesystemvariable {tk} % Teksten \definesystemvariable {tl} % TekstLijnen \definesystemvariable {tm} % TypesynonyM \definesystemvariable {to} % TOlerance -\definesystemvariable {tp} % TyPen -%definesystemvariable {tr} % TRacer \definesystemvariable {ts} % TypeScript \definesystemvariable {tt} % TabulaTe \definesystemvariable {tx} % TeXtflow -\definesystemvariable {ty} % TYpe -%definesystemvariable {uc} % Unicode -%definesystemvariable {ui} % UItvoer -\definesystemvariable {un} % UNits \definesystemvariable {ur} % URl \definesystemvariable {ut} % strUT -%definesystemvariable {up} % Utility Program \definesystemvariable {va} % VspAce -%definesystemvariable {ve} % VErsie \definesystemvariable {vn} % VoetNoten \definesystemvariable {vs} % VSpacing -%definesystemvariable {vt} % VerTical -\definesystemvariable {wc} % WidgetContent -\definesystemvariable {wh} % WidgetHelp -\definesystemvariable {wl} % WidgetLabel -\definesystemvariable {wp} % WidgetPopuphelp -%definesystemvariable {wr} % WitRuimte -%definesystemvariable {ws} % WidgetStack (not used) -\definesystemvariable {wt} % WidgetTotal \definesystemvariable {wz} % whitespace \definesystemvariable {xf} % XML File (xtag) -\definesystemvariable {xl} % lxml (mkiv) -\definesystemvariable {xm} % xml (mkiv) \definesystemvariable {xp} % XML Processing (xtag, so still needed) -\definesystemvariable {xy} % schaal \definesystemvariable {za} % layout adapt % ZetspiegelAanpassing \definesystemvariable {zc} % columns \definesystemvariable {zo} % otr @@ -775,15 +623,6 @@ \definefileconstant {locfilename} {cont-loc} \definefileconstant {expfilename} {cont-exp} -%D Handy for typescripts (we could use s! instead) but these -%D might go: - -\definetypescriptconstant {name} {name} -\definetypescriptconstant {default} {default} -\definetypescriptconstant {map} {map} -\definetypescriptconstant {special} {special} -\definetypescriptconstant {size} {size} - %D The setup files for the language, font, color and special %D subsystems have a common prefix. This means that we have at %D most three characters for unique filenames. diff --git a/tex/context/base/node-bck.mkiv b/tex/context/base/node-bck.mkiv index 844ffa377..d0860dcdc 100644 --- a/tex/context/base/node-bck.mkiv +++ b/tex/context/base/node-bck.mkiv @@ -20,53 +20,69 @@ \registerctxluafile{node-bck}{1.001} -\def\doinitializeboxbackgrounds % will move to lua +\def\backgrounds_boxes_initialize % will move to lua {\ctxlua{nodes.tasks.enableaction("shipouts","nodes.handlers.backgrounds")}% \glet\doinitializeboxbackgrounds\donothing} -%D Box helpers: - % \backgroundvbox[green] {\input tufte } \par % \backgroundvbox[blue] {\input ward } \par % \backgroundvbox[red] {\input knuth } \par % \backgroundhbox[yellow]{\rotate[rotation=45]{hello world}} \par -\def\doaddbackgroundtobox#1[#2]% - {\begingroup\doinitializeboxbackgrounds\faststartcolor[#2]% - \normalexpanded{\noexpand\faststopcolor\endgroup#1 - attr \backgroundattribute \plusone - attr \colormodelattribute \the\attribute\colormodelattribute - attr \colorattribute \the\attribute\colorattribute - attr \transparencyattribute \the\attribute\transparencyattribute}} - -\def\backgroundvbox{\doaddbackgroundtobox\vbox} -\def\backgroundvtop{\doaddbackgroundtobox\vtop} -\def\backgroundhbox{\doaddbackgroundtobox\hbox} - \def\colorattr#1% - {\ifcsname\??qc:\currentpalet#1\endcsname - \thecolorattr{\currentpalet#1}% - \else\ifcsname\??qc:#1\endcsname + {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname + \thecolorattr{\currentcolorprefix#1}% + \else\ifcsname\??colorattribute#1\endcsname \thecolorattr{#1}% \fi\fi} \def\thecolorattr#1% {attr \colormodelattribute \attribute\colormodelattribute - attr \colorattribute \csname\??qc:#1\endcsname - attr \transparencyattribute \csname\??qt:#1\endcsname} + attr \colorattribute \csname\??colorattribute #1\endcsname + attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized \def\backgroundcolorattr#1% - {\ifcsname\??qc:\currentpalet#1\endcsname - \thebackgroundcolorattr{\currentpalet#1}% - \else\ifcsname\??qc:#1\endcsname + {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname + \thebackgroundcolorattr{\currentcolorprefix#1}% + \else\ifcsname\??colorattribute#1\endcsname \thebackgroundcolorattr{#1}% \fi\fi} \def\thebackgroundcolorattr#1% {attr \backgroundattribute \plusone attr \colormodelattribute \attribute\colormodelattribute - attr \colorattribute \csname\??qc:#1\endcsname - attr \transparencyattribute \csname\??qt:#1\endcsname} + attr \colorattribute \csname\??colorattribute#1\endcsname + attr \transparencyattribute \thetransparencyattribute{#1} } % can be optimized + +\unexpanded\def\backgroundhbox{\backgrounds_boxes_add\hbox} +\unexpanded\def\backgroundvbox{\backgrounds_boxes_add\vbox} +\unexpanded\def\backgroundvtop{\backgrounds_boxes_add\vtop} + +% \def\backgrounds_boxes_add#1[#2]% +% {\begingroup +% \backgrounds_boxes_initialize +% \dousecolorparameter{#2}% +% \normalexpanded{\endgroup#1 +% attr \backgroundattribute \plusone +% attr \colormodelattribute \the\attribute\colormodelattribute +% attr \colorattribute \the\attribute\colorattribute +% attr \transparencyattribute \the\attribute\transparencyattribute}} +% +% more efficient: + +\def\backgrounds_boxes_add#1[#2]% + {\backgrounds_boxes_initialize#1\backgroundcolorattr{#2}} + +% less argument carry over: +% +% \def\backgrounds_boxes_add#1[#2]% +% {\backgrounds_boxes_initialize#1% +% \ifcsname\??colorattribute\currentcolorprefix#2\endcsname +% \thebackgroundcolorattr{\currentcolorprefix#2}% +% \else\ifcsname\??colorattribute#2\endcsname +% \thebackgroundcolorattr{#2}% +% \fi\fi} + % \def\backgroundvbox[#1]{\vbox \backgroundcolorattr{#1}} % \def\backgroundvtop[#1]{\vtop \backgroundcolorattr{#1}} diff --git a/tex/context/base/node-fin.mkiv b/tex/context/base/node-fin.mkiv index 2f90e699b..09bac6c08 100644 --- a/tex/context/base/node-fin.mkiv +++ b/tex/context/base/node-fin.mkiv @@ -18,19 +18,17 @@ \unprotect +\registerctxluafile{node-shp}{1.001} \registerctxluafile{node-fin}{1.001} % we might generalize this one -\definesystemattribute[trigger][public] - -% There will be two: (1) page i.e. before shipout cq. impose cache -% (2) at shipout +% we might have two variants at some point (efficiency) -\def\finalizeobjectbox #1{\ctxlua{nodes.handlers.finalize(tex.box[\number#1])}} -\def\finalizeshipoutbox#1{\ctxlua{nodes.handlers.finalize(tex.box[\number#1])}} +\def\finalizeobjectbox #1{\ctxcommand{finalizebox(\number#1)}} +\def\finalizeshipoutbox#1{\ctxcommand{finalizebox(\number#1)}} -% tricky stuff: +% Tricky stuff: this might become obsolete. -% THIS MIGHT BECOME OBSOLETE. +\definesystemattribute[trigger][public] \newcount\attributeboxcount diff --git a/tex/context/base/node-ini.mkiv b/tex/context/base/node-ini.mkiv index e071506a2..afc362de9 100644 --- a/tex/context/base/node-ini.mkiv +++ b/tex/context/base/node-ini.mkiv @@ -26,7 +26,7 @@ \registerctxluafile{node-tsk}{1.001} \registerctxluafile{node-tex}{1.001} \registerctxluafile{node-pro}{1.001} -\registerctxluafile{node-shp}{1.001} +%registerctxluafile{node-shp}{1.001} % moved to node-fin.mkiv \registerctxluafile{node-ser}{1.001} \registerctxluafile{node-ext}{1.001} %registerctxluafile{node-inj}{1.001} % we might split it off diff --git a/tex/context/base/node-par.mkiv b/tex/context/base/node-par.mkiv index e6a322637..17eefe39b 100644 --- a/tex/context/base/node-par.mkiv +++ b/tex/context/base/node-par.mkiv @@ -36,26 +36,30 @@ % management (enable/disable) is global and will move to lua -\newcount\nofparbuilders +\installcorenamespace {parbuilder} + +\newcount\c_par_n_of_builders + +\let\m_par_current_builder\empty \unexpanded\def\defineparbuilder[#1]% - {\global\advance\nofparbuilders\plusone - \ctxlua{builders.paragraphs.constructors.register("#1",\number\nofparbuilders)}% - \setxvalue{\??ng:#1}{\attribute\parbuilderattribute\nofparbuilders}} + {\global\advance\c_par_n_of_builders\plusone + \ctxlua{builders.paragraphs.constructors.register("#1",\number\c_par_n_of_builders)}% + \setxvalue{\??parbuilder#1}{\attribute\parbuilderattribute\number\c_par_n_of_builders}} \unexpanded\def\startparbuilder[#1]% - {\edef\@@currentparbuilder{\number\attribute\parbuilderattribute}% - \globalpushmacro\@@currentparbuilder - \getvalue{\??ng:#1}% - \checkparbuilders} + {\edef\m_par_current_builder{\number\attribute\parbuilderattribute}% + \globalpushmacro\m_par_current_builder + \getvalue{\??parbuilder#1}\relax + \par_builders_check} \unexpanded\def\stopparbuilder {\ifhmode\par\fi - \globalpopmacro\@@currentparbuilder - \attribute\parbuilderattribute\@@currentparbuilder\relax - \checkparbuilders} + \globalpopmacro\m_par_current_builder + \attribute\parbuilderattribute\m_par_current_builder\relax + \par_builders_check} -\def\setmainparbuilder[#1]% +\unexpanded\def\setmainparbuilder[#1]% {\ctxlua{builders.paragraphs.constructors.set("#1")}} % no high level interface, after all implementing a linebreaker is not something that @@ -68,7 +72,7 @@ \def\enableparbuilders {\ctxlua{builders.paragraphs.constructors.enable ()}} \def\disableparbuilders{\ctxlua{builders.paragraphs.constructors.disable()}} -\def\checkparbuilders % can be more efficient as we don't want to do this to often +\def\par_builders_check % can be made more efficient as we don't want to do this too often {\ifcase\attribute\parbuilderattribute \disableparbuilders \else diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv index b093521f9..58e51b1b8 100644 --- a/tex/context/base/node-rul.mkiv +++ b/tex/context/base/node-rul.mkiv @@ -15,7 +15,8 @@ \writestatus{loading}{ConTeXt Core Macros / Bars} -%D The name of this file might change. +%D The name of this file might change (and then the prefix will +%D become \xxxx_bar etc). %D \macros %D {underbar,underbars, @@ -52,9 +53,15 @@ %D \showsetup{overstrikes} %D %D \showsetup{setupunderbar} +%D +%D Nested bars can be configured by appending \type {:} to the +%D category. -%D todo: mkvi this file ... no redefine, just pass all parameters, too messy now -%D (due to grouping) so better hash settings at the lua end +%D As with many early usage of \LUA\ in \MKIV\ this mechanism explores a way +%D to deal with local settings at the \TEX\ end and remembering parameters +%D at the \LUA\ end. We might do things differently now, but as settings normally +%D don't change that often, we're not in a hurry to do that now. The problem at +%D the \LUA\ end is that we don't know when to clean up. \unprotect @@ -63,40 +70,42 @@ \registerctxluafile{node-rul}{1.001} -\installcommandhandler \??on {bar} \??on +\installcorenamespace{bar} +\installcorenamespace{barindex} +\installcorenamespace{barattribute} +\installcorenamespace{barstack} + +\installcommandhandler \??bar {bar} \??bar -\newtoks\checkalldefinedbars +\newtoks\t_bar_checklist + +\let\c_bar_index\relax % temporary synonym +\let\p_bar_color\empty \let\setupbars\setupbar \appendtoks - \ifsecondargument - \dodefinebarindeed\currentbar - \else - \the\checkalldefinedbars - \fi + \ifsecondargument + \bar_define + \else + \the\t_bar_checklist + \fi \to \everysetupbar \appendtoks - \ifcsname\??on:\currentbar:c\endcsname - \csname\??on:\currentbar:c\endcsname\zerocount - \else - \expandafter\newcount\csname\??on:\currentbar:c\endcsname - \fi - \normalexpanded{\checkalldefinedbars{\doredefinebar{\currentbar}\the\checkalldefinedbars}}% - \dodefinebarindeed\currentbar - \setuevalue\currentbar{\doruled{\currentbar}}% + \ifcsname\??barindex\currentbar\endcsname + \csname\??barindex\currentbar\endcsname\zerocount + \else + \expandafter\newcount\csname\??barindex\currentbar\endcsname + \fi + \normalexpanded{\t_bar_checklist{\bar_redefine{\currentbar}\the\t_bar_checklist}}% + \bar_define + \setuevalue\currentbar{\bar_direct{\currentbar}}% \to \everydefinebar -\unexpanded\def\dodefinebarindeed#1% - {\begingroup - \edef\currentbar{#1}% - \doifsomethingelse{\barparameter\c!color} - {\donetrue\colored[\barparameter\c!color]} - {\donefalse}% - \normalexpanded - {\endgroup - \scratchcounter\ctxlua{nodes.rules.define { +\unexpanded\def\bar_define + {\edef\p_bar_color{\barparameter\c!color}% + \setevalue{\??barattribute\currentbar}{\number\ctxlua{nodes.rules.define { method = \barparameter\c!method, offset = \barparameter\c!offset, continue = "\barparameter\c!continue", @@ -105,52 +114,51 @@ unit = "\barparameter\c!unit", order = "\barparameter\c!order", max = \barparameter\c!max, - ma = \ifdone\the\attribute\colormodelattribute \else0\fi, - ca = \ifdone\the\attribute\colorattribute \else0\fi, - ta = \ifdone\the\attribute\transparencyattribute\else0\fi - }}}% - \setevalue{\??on#1:a}{\the\scratchcounter}} + ma = \thecolormodelattribute, + ca = \thecolorattribute\p_bar_color, + ta = \thetransparencyattribute\p_bar_color + }}}} -\let\doredefinebar\dodefinebarindeed +\unexpanded\def\bar_redefine#1% + {\def\currentbar{#1}\bar_define} -\unexpanded\def\doruled#1% - {\groupedcommand{\dodoruled{#1}}\relax} +\unexpanded\def\bar_direct#1% + {\groupedcommand{\bar_set{#1}}\relax} -\def\dodoruled +\def\bar_set {\ctxlua{nodes.rules.enable()}% will be moved to lua - \glet\dodoruled\dodoruledindeed - \dodoruled} + \glet\bar_set\bar_set_indeed + \bar_set} -\def\dodoruledindeed#1% maybe reverse the 1000 (also maybe use more attributes instead of settings) +\def\bar_set_indeed#1% maybe reverse the 1000 (also maybe use more attributes instead of settings) {\edef\currentbar{#1}% - \advance\csname\??on:#1:c\endcsname\plusone % local ? - \scratchcounter\csname\??on:#1:c\endcsname + \expandafter\let\expandafter\c_bar_index\csname\??barindex#1\endcsname + \advance\c_bar_index\plusone \usebarstyleandcolor\c!foregroundstyle\c!foregroundcolor \attribute\ruledattribute\numexpr - 1000*\scratchcounter - +\csname\??on#1\ifcsname\??on#1:\number\scratchcounter\s!parent\endcsname:\number\scratchcounter\fi:a\endcsname + \plusthousand*\c_bar_index + +\csname\??barattribute#1\ifcsname\??bar#1:\number\c_bar_index\s!parent\endcsname:\number\c_bar_index\fi\endcsname \relax} -% ungrouped - \unexpanded\def\startbar[#1]% {\begingroup - \dodoruled{#1}} + \bar_set{#1}} \unexpanded\def\stopbar {\endgroup} -\newcount\currentbarnesting % todo: same as colors +% ungrouped + +\newcount\c_bar_nesting % todo: same as colors \unexpanded\def\pushbar[#1]% - {\global\advance\currentbarnesting\plusone - \expandafter\edef\csname\??on:s:\number\currentbarnesting\endcsname - {\attribute\ruledattribute\the\attribute\ruledattribute}% stack - \dodoruled{#1}} + {\global\advance\c_bar_nesting\plusone + \expandafter\edef\csname\??barstack\number\c_bar_nesting\endcsname{\attribute\ruledattribute\the\attribute\ruledattribute}% + \bar_set{#1}} \unexpanded\def\popbar - {\csname\??on:s:\number\currentbarnesting\endcsname - \global\advance\currentbarnesting\minusone} + {\csname\??barstack\number\c_bar_nesting\endcsname + \global\advance\c_bar_nesting\minusone} \setupbars [\c!method=0, % new: 0=center nested, 1=stack nested @@ -167,9 +175,9 @@ % \definebar[touchbar] [\c!method=0,\c!dy=-0.4,\c!offset=-0.0] % \definebar[touchbars] [touchbar] [\c!continue=\v!yes] -\definebar[\v!overstrike] [\c!method=0,\c!dy=0.4,\c!offset=0.5,\c!continue=\v!yes] -\definebar[\v!underbar] [\c!method=1,\c!dy=-0.4,\c!offset=-0.3,\c!continue=\v!yes] -\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes] +\definebar[\v!overstrike][\c!method=0,\c!dy=0.4,\c!offset=0.5,\c!continue=\v!yes] +\definebar[\v!underbar] [\c!method=1,\c!dy=-0.4,\c!offset=-0.3,\c!continue=\v!yes] +\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes] \definebar [\v!understrike] @@ -199,82 +207,75 @@ %D This will move: (a bit duplicated) -\installcommandhandler \??ra {shift} \??ra +\installcorenamespace{shift} +\installcorenamespace{shiftindex} +\installcorenamespace{shiftattribute} + +\installcommandhandler \??shift {shift} \??shift -\newtoks\checkalldefinedshifts +\newtoks\t_shift_checklist + +\let\c_shift_index\relax % temporary synonym \let\setupshifts\setupshift \appendtoks - \ifsecondargument - \dodefineshiftindeed\currentshift - \else - \the\checkalldefinedshifts - \fi + \ifsecondargument + \shift_define + \else + \the\t_shift_checklist + \fi \to \everysetupshift \appendtoks - \ifcsname\??ra:\currentshift:c\endcsname - \csname\??ra:\currentshift:c\endcsname\zerocount - \else - \expandafter\newcount\csname\??ra:\currentshift:c\endcsname - \fi - \normalexpanded{\checkalldefinedshifts{\doredefineshift{\currentshift}\the\checkalldefinedshifts}}% - \dodefineshiftindeed{\currentshift}% - \setuevalue\currentshift{\doshifted{\currentshift}}% + \ifcsname\??shiftindex\currentshift\endcsname + \csname\??shiftindex\currentshift\endcsname\zerocount + \else + \expandafter\newcount\csname\??shiftindex\currentshift\endcsname + \fi + \normalexpanded{\t_shift_checklist{\shift_redefine{\currentshift}\the\t_shift_checklist}}% + \shift_define + \setuevalue\currentshift{\shift_direct{\currentshift}}% \to \everydefineshift -\unexpanded\def\dodefineshiftindeed#1% - {\begingroup - \edef\currentshift{#1}% - \normalexpanded - {\endgroup - \scratchcounter\ctxlua{nodes.shifts.define { +\unexpanded\def\shift_define + {\setevalue{\??shiftattribute\currentshift}{\number\ctxlua{nodes.shifts.define { method = \shiftparameter\c!method, continue = "\shiftparameter\c!continue", dy = \shiftparameter\c!dy, unit = "\shiftparameter\c!unit", - }}}% - \setevalue{\??ra#1:a}{\the\scratchcounter}} + }}}} -\let\doredefineshift\dodefineshiftindeed +\unexpanded\def\shift_redefine#1% + {\def\currentshift{#1}\shift_define} -% \unexpanded\def\doshifted#1% -% {\groupedcommand{\dodoshifted{#1}}\relax} - -\def\dodoshifted +\unexpanded\def\shift_set {\ctxlua{nodes.shifts.enable()}% - \glet\dodoshifted\dodoshiftedindeed - \dodoshifted} + \glet\shift_set\shift_set_indeed + \shift_set} -\def\dostartisolation{\signalcharacter} -\def\dostopisolation {\signalcharacter} -\def\doisolator {\signalcharacter} +% \unexpanded\def\shift_direct#1% +% {\doisolatedgroupedalign{\shift_set{#1}}\donothing} -\def\doisolatedgroupedalign#1#2% +\unexpanded\def\shift_direct#1% {\groupedcommand - {\begingroup\dostartisolation\begingroup#1} - {#2\endgroup\dostopisolation\endgroup}} + {\begingroup\dostartisolation\begingroup\shift_set{#1}} + {\endgroup\dostopisolation\endgroup}} -\def\dosetupisolatedalign#1% - {\doisolator - \setupalign[#1]\relax} - -\def\dodoshiftedindeed#1% +\def\shift_set_indeed#1% todo: check parent ! {\def\currentshift{#1}% - \advance\csname\??ra:#1:c\endcsname\plusone - \scratchcounter\csname\??ra:#1:c\endcsname - \attribute\shiftedattribute\numexpr1000*\scratchcounter - +\csname\??ra#1\ifcsname\??ra#1:\number\scratchcounter\s!parent\endcsname:\number\scratchcounter\fi:a\endcsname + \expandafter\let\expandafter\c_shift_index\csname\??shiftindex#1\endcsname + \advance\c_shift_index\plusone + \attribute\shiftedattribute\numexpr + \plusthousand*\c_shift_index + +\csname\??shiftattribute#1\ifcsname\??shift#1:\number\c_shift_index\s!parent\endcsname:\number\c_shift_index\fi\endcsname + \relax \useshiftstyleandcolor\c!style\c!color \dosetupisolatedalign{\shiftparameter\c!align}} -\unexpanded\def\doshifted#1% - {\doisolatedgroupedalign{\dodoshifted{#1}}{}} - \unexpanded\def\startshift[#1]% {\begingroup - \dodoshifted{#1}} + \shift_set{#1}} \unexpanded\def\stopshift {\endgroup} @@ -299,13 +300,19 @@ \expandafter\let\expandafter\shiftup \csname\v!shiftup \endcsname \expandafter\let\expandafter\shiftdown \csname\v!shiftdown \endcsname -\protect \endinput +% This is a weird helper: -% obsolete: +\unexpanded\def\dostartisolation{\signalcharacter} +\unexpanded\def\dostopisolation {\signalcharacter} +\unexpanded\def\doisolator {\signalcharacter} -\setupunderbar - [\c!alternative=a, - \c!rulethickness=\linewidth, - \c!bottomoffset=1.5pt, - \c!topoffset=2.5pt, - \c!rulecolor=] +\unexpanded\def\dosetupisolatedalign#1% + {\doisolator + \setupalign[#1]\relax} + +\unexpanded\def\doisolatedgroupedalign#1#2% + {\groupedcommand + {\begingroup\dostartisolation\begingroup#1} + {#2\endgroup\dostopisolation\endgroup}} + +\protect \endinput diff --git a/tex/context/base/node-shp.lua b/tex/context/base/node-shp.lua index 75177a4ed..6fad0f495 100644 --- a/tex/context/base/node-shp.lua +++ b/tex/context/base/node-shp.lua @@ -18,6 +18,8 @@ local mark_code = nodecodes.mark local kern_code = nodecodes.kern local glue_code = nodecodes.glue +local texbox = tex.box + local free_node = node.free local remove_node = node.remove @@ -60,3 +62,9 @@ function nodes.handlers.finalize(head) -- problem, attr loaded before node, todo end --~ nodes.handlers.finalize = actions + +-- interface + +function commands.finalizebox(n) + actions(texbox[n]) +end diff --git a/tex/context/base/pack-bck.mkvi b/tex/context/base/pack-bck.mkvi index ed742421a..a105150b6 100644 --- a/tex/context/base/pack-bck.mkvi +++ b/tex/context/base/pack-bck.mkvi @@ -52,7 +52,9 @@ \unprotect -\installframedcommandhandler \??ag {background} \??ag +\installcorenamespace {background} + +\installframedcommandhandler \??background {background} \??background % The mode is not that public an dmostlu an initial mode: % @@ -243,12 +245,11 @@ \unexpanded\def\background_add_to_nextbox#color% handy helper {\hbox - {\faststartcolor[#color]% + {\dousecolorparameter{#color}% \vrule \!!width \nextboxwd \!!height\nextboxht \!!depth \nextboxdp - \faststopcolor \hskip-\nextboxwd \flushnextbox}} diff --git a/tex/context/base/pack-box.mkiv b/tex/context/base/pack-box.mkiv index 90abcf497..843f3fcd8 100644 --- a/tex/context/base/pack-box.mkiv +++ b/tex/context/base/pack-box.mkiv @@ -13,6 +13,8 @@ \writestatus{loading}{ConTeXt Packaging Macros / Boxes} +% to be cleaned up + %D This module contains all kind of macros for moving content %D around. Many macros here come from other modules, but %D depencies made it more clear to isolate them. @@ -164,62 +166,62 @@ {\def\currentcollector{#1}% \chardef\collectorbox\csname\@@collectorbox#1\endcsname \getparameters[\??cb#1][#2]% - \@@layerxsiz\wd\collectorbox - \@@layerysiz\ht\collectorbox + \d_layers_x_size\wd\collectorbox + \d_layers_y_size\ht\collectorbox \doifvaluesomething{\??cb#1\c!rotation} {\setbox\nextbox\hbox {\rotate [\c!location=\v!high, \c!rotation=\collectorparameter\c!rotation] {\flushnextbox}}}% - \advance\@@layerysiz\dp\collectorbox - \@@layerxpos\collectorparameter\c!x - \advance\@@layerxpos\collectorparameter\c!hoffset - \@@layerypos\collectorparameter\c!y - \advance\@@layerypos\collectorparameter\c!voffset + \advance\d_layers_y_size\dp\collectorbox + \d_layers_x_position\collectorparameter\c!x + \advance\d_layers_x_position\collectorparameter\c!hoffset + \d_layers_y_position\collectorparameter\c!y + \advance\d_layers_y_position\collectorparameter\c!voffset \doifelse\v!middle{\collectorparameter\c!corner} - {\ifdim\@@layerxsiz>\zeropoint - \advance\@@layerxpos.5\@@layerxsiz + {\ifdim\d_layers_x_size>\zeropoint + \advance\d_layers_x_position.5\d_layers_x_size \fi - \ifdim\@@layerysiz>\zeropoint - \advance\@@layerypos.5\@@layerysiz + \ifdim\d_layers_y_size>\zeropoint + \advance\d_layers_y_position.5\d_layers_y_size \fi}% {\normalexpanded{\noexpand\doifinset{\v!bottom}{\collectorparameter\c!corner}} - {\ifdim\@@layerysiz>\zeropoint - \advance\@@layerypos-\@@layerysiz - \@@layerypos-\@@layerypos + {\ifdim\d_layers_y_size>\zeropoint + \advance\d_layers_y_position-\d_layers_y_size + \d_layers_y_position-\d_layers_y_position \fi}% \normalexpanded{\noexpand\doifinset{\v!right}{\collectorparameter\c!corner}} - {\ifdim\@@layerxsiz>\zeropoint - \advance\@@layerxpos-\@@layerxsiz - \@@layerxpos-\@@layerxpos + {\ifdim\d_layers_x_size>\zeropoint + \advance\d_layers_x_position-\d_layers_x_size + \d_layers_x_position-\d_layers_x_position \fi}}% \setbox\nextbox\hbox {\alignedbox[\collectorparameter\c!location]\vbox{\flushnextbox}}% \boxmaxdepth\zeropoint % really needed, nice example - \global\advance\boxhdisplacement\@@layerxpos + \global\advance\boxhdisplacement\d_layers_x_position \ifdim\boxhdisplacement<\zeropoint \global\setbox\collectorbox\hbox {\hskip-\boxhdisplacement \box\collectorbox}% \fi - \global\advance\boxvdisplacement\@@layerypos + \global\advance\boxvdisplacement\d_layers_y_position \ifdim\boxvdisplacement<\zeropoint \global\setbox\collectorbox\hbox {\lower-\boxvdisplacement \box\collectorbox}% \fi - \@@layerxsiz\wd\collectorbox - \@@layerysiz\ht\collectorbox - \advance\@@layerysiz\dp\collectorbox + \d_layers_x_size\wd\collectorbox + \d_layers_y_size\ht\collectorbox + \advance\d_layers_y_size\dp\collectorbox \global\setbox\collectorbox\hbox {\box\collectorbox - \hskip-\@@layerxsiz - \hskip\@@layerxpos\relax + \hskip-\d_layers_x_size + \hskip\d_layers_x_position\relax \ifdim\boxhdisplacement<\zeropoint \hskip-\boxhdisplacement \fi - \lower\@@layerypos\hbox + \lower\d_layers_y_position\hbox {\ifdim\boxvdisplacement<\zeropoint \lower-\boxvdisplacement\flushnextbox \else @@ -229,8 +231,8 @@ \global\setbox\collectorbox\hbox {\lower\ht\collectorbox\box\collectorbox}% % just to be sure - \ifdim\wd\collectorbox<\@@layerxsiz - \wd\collectorbox\@@layerxsiz + \ifdim\wd\collectorbox<\d_layers_x_size + \wd\collectorbox\d_layers_x_size \fi} \def\flushcollector[#1]% @@ -442,12 +444,12 @@ \c!hoffset=\@@bgoffset] \unexpanded\def\bleed - {\dosingleempty\dobleed} + {\dosingleempty\boxes_bleed} \def\bleedwidth {\the\hsize}% \def\bleedheight{\the\vsize}% -\def\dobleed[#1]#2% +\def\boxes_bleed[#1]#2% {\hbox\bgroup \xdef\bleedwidth {\the\hsize}% \xdef\bleedheight{\the\vsize}% @@ -559,49 +561,33 @@ % only apply the offset to ... \def\setlayerframed - {\dotripleempty\dosetlayerframed} - -% \def\dosetlayerframed -% {\ifthirdargument -% \expandafter\dosetlayerframedT -% \else -% \expandafter\dosetlayerframedS -% \fi} -% -% \def\dosetlayerframedT[#1][#2][#3]% -% {\dowithnextbox{\setlayer[#1][#2]{\flushnextbox}}% -% \hbox\framed[#3]} -% -% \def\dosetlayerframedS[#1][#2][#3]% -% {\dowithnextbox % we could use a local setlayer command (no doif..empty) which also saves a nextbox -% {\setlayer[#1][\c!width=\nextboxwd,\c!height=\nextboxht,#2,\c!offset=\!!zeropoint]{\flushnextbox}}% -% \hbox\normalframedwithsettings[\c!location=\v!normal,#2]}% fast call (no arg check) + {\dotripleempty\layers_set_framed} -\def\dosetlayerframed +\def\layers_set_framed {\ifthirdargument - \expandafter\dosetlayerframedT + \expandafter \layers_set_framed_t \else\ifsecondargument - \doubleexpandafter\dosetlayerframedD + \doubleexpandafter\layers_set_framed_d \else - \doubleexpandafter\dosetlayerframedS + \doubleexpandafter\layers_set_framed_s \fi\fi} -\def\dosetlayerframedS[#1][#2][#3]% +\def\layers_set_framed_s[#1][#2][#3]% {\setlayer[#1][\c!width=\wd\nextbox,\c!height=\ht\nextbox,\c!offset=\zeropoint]% \normalframedwithsettings[\c!location=\v!normal]} % diffrent kind of location -\def\dosetlayerframedD[#1][#2][#3]% +\def\layers_set_framed_d[#1][#2][#3]% {\setlayer[#1][\c!width=\wd\nextbox,\c!height=\ht\nextbox,#2,\c!offset=\zeropoint]% \normalframedwithsettings[\c!location=\v!normal,#2]} % diffrent kind of location -\def\dosetlayerframedT[#1][#2][#3]% +\def\layers_set_framed_t[#1][#2][#3]% {\setlayer[#1][#2]% \normalframedwithsettings[#3]} - + \def\setlayertext - {\dotripleempty\dosetlayertext} + {\dotripleempty\layers_set_text} -\def\dosetlayertext[#1][#2][#3]% +\def\layers_set_text[#1][#2][#3]% {\bgroup \getparameters [\??lx] @@ -618,7 +604,7 @@ {\setlayer[#1][#2]{\strut\dousecolorparameter\@@lxcolor\flushnextbox}% \egroup}% \vtop} - + % \setupbackgrounds % [page] % [background=pagefigures] @@ -692,159 +678,135 @@ \definelayerpreset [\v!middle\v!right] [\c!location=\v!left,\c!corner=\v!right,\c!dy=.5\layerheight] - -\def\alignedbox - {\dodoubleempty\doalignedbox[]} - -% \def\doalignedbox[#1][#2]% -% {\bgroup -% %\let\iftraceboxplacement\iftracelayers % ugly -% \dowithnextbox -% {\let\next\middlebox -% \processaction -% [#2] -% [ t=>\let\next\topbox , b=>\let\next\bottombox , -% l=>\let\next\leftbox , r=>\let\next\rightbox , -% bl=>\let\next\bottomleftbox,br=>\let\next\bottomrightbox, -% tl=>\let\next\topleftbox ,tr=>\let\next\toprightbox , -% lt=>\let\next\lefttopbox ,lb=>\let\next\leftbottombox , -% rt=>\let\next\righttopbox ,rb=>\let\next\rightbottombox]% -% \next{\flushnextbox}% -% \egroup}#1} - -\def\doalignedbox[#1][#2]% - {\bgroup - %\let\iftraceboxplacement\iftracelayers % ugly - \dowithnextbox - {\serializecommalist[#2]% - \executeifdefined{\??ab\??ab\serializedcommalist}\middlebox{\flushnextbox}% - \egroup}#1} - -\setvalue{\??ab\??ab }{\middlebox} -\setvalue{\??ab\??ab\v!middle }{\middlebox} -\setvalue{\??ab\??ab\v!left }{\leftbox } -\setvalue{\??ab\??ab\v!right }{\rightbox } -\setvalue{\??ab\??ab\v!bottom }{\bottombox} -\setvalue{\??ab\??ab\v!top }{\topbox } - -\setvalue{\??ab\??ab\v!middle\v!middle}{\middlebox} -\setvalue{\??ab\??ab\v!left \v!top }{\lefttopbox} -\setvalue{\??ab\??ab\v!left \v!bottom}{\leftbottombox} -\setvalue{\??ab\??ab\v!right \v!top }{\righttopbox} -\setvalue{\??ab\??ab\v!right \v!bottom}{\rightbottombox} -\setvalue{\??ab\??ab\v!top \v!left }{\topleftbox} -\setvalue{\??ab\??ab\v!bottom\v!left }{\bottomleftbox} -\setvalue{\??ab\??ab\v!top \v!right }{\toprightbox} -\setvalue{\??ab\??ab\v!bottom\v!right }{\bottomrightbox} - -\setvalue{\??ab\??ab c}{\middlebox} -\setvalue{\??ab\??ab l}{\leftbox} -\setvalue{\??ab\??ab r}{\rightbox} -\setvalue{\??ab\??ab b}{\bottombox} -\setvalue{\??ab\??ab t}{\topbox} - -\setvalue{\??ab\??ab lt}{\lefttopbox} -\setvalue{\??ab\??ab lb}{\leftbottombox} -\setvalue{\??ab\??ab rt}{\righttopbox} -\setvalue{\??ab\??ab rb}{\rightbottombox} -\setvalue{\??ab\??ab tl}{\topleftbox} -\setvalue{\??ab\??ab bl}{\bottomleftbox} -\setvalue{\??ab\??ab tr}{\toprightbox} -\setvalue{\??ab\??ab br}{\bottomrightbox} - -\setvalue{\??ab\??ab m}{\middlebox} - -% The next ones were desparately needed by Vit Zyka (see -% \type {supp-box} for definitions). - -\setvalue{\??ab\??ab g}{\baselinemiddlebox} -\setvalue{\??ab\??ab gl}{\baselineleftbox} -\setvalue{\??ab\??ab gc}{\baselinemiddlebox} -\setvalue{\??ab\??ab gr}{\baselinerightbox} - -\setvalue{\??ab\??ab \v!line }{\baselinemiddlebox} % \v!grid is taken -\setvalue{\??ab\??ab \v!line\v!left }{\baselineleftbox} -\setvalue{\??ab\??ab \v!line\v!middle}{\baselinemiddlebox} -\setvalue{\??ab\??ab \v!line\v!right }{\baselinerightbox} - -\unexpanded\def\offsetbox - {\dodoubleempty\dooffsetbox[]} + +\installcorenamespace{alignedboxes} + +\unexpanded\def\alignedbox{\dosingleempty\boxes_aligned_box} +\unexpanded\def\aligned {\dosingleempty\boxes_aligned} + +\def\boxes_aligned_box[#1]{\bgroup\serializecommalist[#1]\dowithnextboxcs\boxes_aligned_finish} +\def\boxes_aligned [#1]{\bgroup\serializecommalist[#1]\dowithnextboxcs\boxes_aligned_finish\hbox} + +\def\boxes_aligned_finish + {\csname\??alignedboxes + \ifcsname\??alignedboxes\serializedcommalist\endcsname\serializedcommalist\else\v!middle\fi + \endcsname{\flushnextbox}% + \egroup} + +\letvalue{\??alignedboxes }\middlebox +\letvalue{\??alignedboxes\v!middle }\middlebox +\letvalue{\??alignedboxes\v!middle\v!middle}\middlebox +\letvalue{\??alignedboxes\v!left }\leftbox +\letvalue{\??alignedboxes\v!left \v!top }\lefttopbox +\letvalue{\??alignedboxes\v!left \v!bottom}\leftbottombox +\letvalue{\??alignedboxes\v!right }\rightbox +\letvalue{\??alignedboxes\v!right \v!top }\righttopbox +\letvalue{\??alignedboxes\v!right \v!bottom}\rightbottombox +\letvalue{\??alignedboxes\v!bottom }\bottombox +\letvalue{\??alignedboxes\v!bottom\v!left }\bottomleftbox +\letvalue{\??alignedboxes\v!bottom\v!right }\bottomrightbox +\letvalue{\??alignedboxes\v!top }\topbox +\letvalue{\??alignedboxes\v!top \v!left }\topleftbox +\letvalue{\??alignedboxes\v!top \v!right }\toprightbox +\letvalue{\??alignedboxes\v!line }\baselinemiddlebox % \v!grid is taken +\letvalue{\??alignedboxes\v!line \v!left }\baselineleftbox +\letvalue{\??alignedboxes\v!line \v!middle}\baselinemiddlebox +\letvalue{\??alignedboxes\v!line \v!right }\baselinerightbox +\letvalue{\??alignedboxes c}\middlebox +\letvalue{\??alignedboxes l}\leftbox +\letvalue{\??alignedboxes r}\rightbox +\letvalue{\??alignedboxes b}\bottombox +\letvalue{\??alignedboxes t}\topbox +\letvalue{\??alignedboxes lt}\lefttopbox +\letvalue{\??alignedboxes lb}\leftbottombox +\letvalue{\??alignedboxes rt}\righttopbox +\letvalue{\??alignedboxes rb}\rightbottombox +\letvalue{\??alignedboxes tl}\topleftbox +\letvalue{\??alignedboxes bl}\bottomleftbox +\letvalue{\??alignedboxes tr}\toprightbox +\letvalue{\??alignedboxes br}\bottomrightbox +\letvalue{\??alignedboxes m}\middlebox +\letvalue{\??alignedboxes g}\baselinemiddlebox +\letvalue{\??alignedboxes gl}\baselineleftbox +\letvalue{\??alignedboxes gc}\baselinemiddlebox +\letvalue{\??alignedboxes gr}\baselinerightbox % left/right/top/bottomoffset -> dimensions change % x/y | method=fixed -> dimensions don't change -\def\dooffsetbox[#1][#2]% - {\bgroup - \dowithnextbox - {\getparameters[\??ox] - [\c!x=\zeropoint, - \c!y=\zeropoint, - \c!width=\nextboxwd, - \c!height=\nextboxht, - \c!depth=\nextboxdp, - \c!location=, - \c!leftoffset=\zeropoint, - \c!rightoffset=\zeropoint, - \c!topoffset=\zeropoint, - \c!bottomoffset=\zeropoint, - \c!method=, - #2]% - \donefalse - \ifdim\@@oxleftoffset =\zeropoint\else\donetrue\fi - \ifdim\@@oxrightoffset=\zeropoint\else\donetrue\fi - \ifdim\@@oxtopoffset =\zeropoint\else\donetrue\fi - \ifdim\@@oxbottomoffset =\zeropoint\else\donetrue\fi - \ifdone - \doif\@@oxmethod\v!fixed % new - {\ifdim\@@oxleftoffset=\zeropoint - \ifdim\@@oxrightoffset=\zeropoint \else - \scratchdimen-\@@oxrightoffset - \edef\@@oxx{\the\scratchdimen}% - \let\@@oxrightoffset\zeropoint - \fi - \else - \let\@@oxx\@@oxleftoffset - \let\@@oxleftoffset\zeropoint - \fi - \ifdim\@@oxtopoffset=\zeropoint - \ifdim\@@oxbottomoffset=\zeropoint \else - \scratchdimen-\@@oxbottomoffset - \edef\@@oxy{\the\scratchdimen}% - \let\@@oxbottomoffset\zeropoint - \fi - \else - \let\@@oxy\@@oxtopoffset - \let\@@oxtopoffset\zeropoint - \fi - \donefalse}% - \fi - \ifdone - \setbox\nextbox\vbox - {\forgetall\offinterlineskip - \vskip\@@oxtopoffset - \hbox - {\hskip\@@oxleftoffset - \flushnextbox - \hskip\@@oxrightoffset}% - \vskip\@@oxbottomoffset}% - \scratchdimen\nextboxht - \advance\scratchdimen\nextboxdp - \nextboxht\scratchdimen - \nextboxdp\zeropoint - \fi - \freezedimenmacro\@@oxwidth - \freezedimenmacro\@@oxheight - \freezedimenmacro\@@oxdepth - \setbox\nextbox\hbox - {\hskip\@@oxx\lower\@@oxy\hbox - {\doifelsenothing\@@oxlocation - {\flushnextbox} - {\alignedbox[\@@oxlocation]\hbox{\flushnextbox}}}}% - \nextboxwd\@@oxwidth - \nextboxht\@@oxheight - \nextboxdp\@@oxdepth - \flushnextbox - \egroup}#1} +\unexpanded\def\offsetbox{\dosingleempty\boxes_offset_box} +\unexpanded\def\offset {\dosingleempty\boxes_offset} + +\def\boxes_offset_box[#1]{\bgroup\dowithnextbox{\boxes_offsetfinish{#1}}} +\def\boxes_offset [#1]{\bgroup\dowithnextbox{\boxes_offsetfinish{#1}}\hbox} + +\def\boxes_offsetfinish#1% + {\getparameters[\??ox] + [\c!x=\zeropoint, + \c!y=\zeropoint, + \c!width=\nextboxwd, + \c!height=\nextboxht, + \c!depth=\nextboxdp, + \c!location=, + \c!leftoffset=\zeropoint, + \c!rightoffset=\zeropoint, + \c!topoffset=\zeropoint, + \c!bottomoffset=\zeropoint, + \c!method=, + #1]% + \donefalse + \ifdim\@@oxleftoffset =\zeropoint\else\donetrue\fi + \ifdim\@@oxrightoffset =\zeropoint\else\donetrue\fi + \ifdim\@@oxtopoffset =\zeropoint\else\donetrue\fi + \ifdim\@@oxbottomoffset=\zeropoint\else\donetrue\fi + \ifdone + \doif\@@oxmethod\v!fixed % new + {\ifdim\@@oxleftoffset=\zeropoint + \ifdim\@@oxrightoffset=\zeropoint \else + \edef\@@oxx{\the\dimexpr-\@@oxrightoffset}% + \let\@@oxrightoffset\zeropoint + \fi + \else + \let\@@oxx\@@oxleftoffset + \let\@@oxleftoffset\zeropoint + \fi + \ifdim\@@oxtopoffset=\zeropoint + \ifdim\@@oxbottomoffset=\zeropoint \else + \edef\@@oxy{\the\dimexpr-\@@oxbottomoffset}% + \let\@@oxbottomoffset\zeropoint + \fi + \else + \let\@@oxy\@@oxtopoffset + \let\@@oxtopoffset\zeropoint + \fi + \donefalse}% + \fi + \ifdone + \setbox\nextbox\vbox + {\forgetall % already done + \offinterlineskip + \vskip\@@oxtopoffset + \hbox + {\hskip\@@oxleftoffset + \box\nextbox + \hskip\@@oxrightoffset}% + \vskip\@@oxbottomoffset}% + \ht\nextbox\htdp\nextbox + \dp\nextbox\zeropoint + \fi + \freezedimenmacro\@@oxwidth + \freezedimenmacro\@@oxheight + \freezedimenmacro\@@oxdepth + \setbox\nextbox\hbox + {\hskip\@@oxx\lower\@@oxy\hbox + {\doifelsenothing\@@oxlocation + {\box\nextbox} + {\alignedbox[\@@oxlocation]\hbox{\box\nextbox}}}}% + \wd\nextbox\@@oxwidth + \ht\nextbox\@@oxheight + \dp\nextbox\@@oxdepth + \box\nextbox + \egroup} % \useMPlibrary[pre] \setupbackgrounds[page][background=pagegrid] % @@ -856,73 +818,43 @@ % \input tufte % \placefigure[left,none]{}{\offset[bottomoffset=1cm]{\externalfigure[koe][breedte=3cm]}} % \input tufte - -\unexpanded\def\offset {\dodoubleempty\dooffsetbox [\hbox]} % yes or no -\unexpanded\def\aligned{\dosingleempty\doalignedbox[\hbox]} % yes or no %\ruledhbox{\offsetbox[x=-1cm,y=-1cm,location=c] % {\framed[width=4cm,height=4cm]{x}}} - -\def\dotabbed#1#2#3#4% + +% Some old code: +% +% \ltabbed{\romannumerals{3}}{\romannumerals{1}} test \endgraf +% \ltabbed{\romannumerals{3}}{\romannumerals{2}} test \endgraf +% \ltabbed{\romannumerals{3}}{\romannumerals{3}} test \endgraf +% +% \rtabbed{\romannumerals{3}}{\romannumerals{1}} test \endgraf +% \rtabbed{\romannumerals{3}}{\romannumerals{2}} test \endgraf +% \rtabbed{\romannumerals{3}}{\romannumerals{3}} test \endgraf +% +% \ctabbed{\romannumerals{3}}{\romannumerals{1}} test \endgraf +% \ctabbed{\romannumerals{3}}{\romannumerals{2}} test \endgraf +% \ctabbed{\romannumerals{3}}{\romannumerals{3}} test \endgraf + +\def\boxes_tabbed#1#2#3#4% {\dontleavehmode - \bgroup + \begingroup \setbox\scratchbox\hbox{#3}% \hbox to \wd\scratchbox{#1#4#2}% - \egroup} + \endgroup} -\unexpanded\def\ltabbed{\dotabbed\relax\hss} -\unexpanded\def\rtabbed{\dotabbed\hss \relax} -\unexpanded\def\ctabbed{\dotabbed\hss \hss} \let\mtabbed\ctabbed +\unexpanded\def\ltabbed{\boxes_tabbed\relax\hss} +\unexpanded\def\rtabbed{\boxes_tabbed\hss \relax} +\unexpanded\def\ctabbed{\boxes_tabbed\hss \hss} -% \ltabbed{\romeins{3}}{\romeins{1}} test \endgraf -% \ltabbed{\romeins{3}}{\romeins{2}} test \endgraf -% \ltabbed{\romeins{3}}{\romeins{3}} test \endgraf -% -% \rtabbed{\romeins{3}}{\romeins{1}} test \endgraf -% \rtabbed{\romeins{3}}{\romeins{2}} test \endgraf -% \rtabbed{\romeins{3}}{\romeins{3}} test \endgraf -% -% \ctabbed{\romeins{3}}{\romeins{1}} test \endgraf -% \ctabbed{\romeins{3}}{\romeins{2}} test \endgraf -% \ctabbed{\romeins{3}}{\romeins{3}} test \endgraf +\let\mtabbed\ctabbed -% alternative, if done, then other name -% -% \def\dotabbed#1#2#3#4% -% {\dontleavehmode -% \bgroup -% \scratchdimen\zeropoint -% \def\docommand##1% -% {\setbox\scratchbox\hbox{##1}% -% \ifdim\wd\scratchbox>\scratchdimen -% \scratchdimen\wd\scratchbox -% \fi}% -% \processcommalist[#3]\docommand -% \hbox to \scratchdimen{#1#4#2}% -% \egroup} -% -% \def\ltabbed{\dotabbed\relax\hss} -% \def\rtabbed{\dotabbed\hss \relax} -% \def\ctabbed{\dotabbed\hss \hss} \let\mtabbed\ctabbed -% -% \ltabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{10}} test \endgraf -% \ltabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{15}} test \endgraf -% \ltabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{2000}} test \endgraf -% -% \rtabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{10}} test \endgraf -% \rtabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{15}} test \endgraf -% \rtabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{2000}} test \endgraf -% -% \ctabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{10}} test \endgraf -% \ctabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{15}} test \endgraf -% \ctabbed{\romeins{10},\romeins{2000},\romeins{15}}{\romeins{2000}} test \endgraf - % to be documented -\unexpanded\def\phantombox[#1]% +\unexpanded\def\phantombox[#1]% == \framed[\c!empty=\v!yes,\c!offset=\v!overlay,#1]{} {\hbox\bgroup \getparameters - [\??ol] + [\??ol] % brrr [\c!width=\zeropoint,% \c!height=\zeropoint,% \c!depth=\zeropoint,#1]% @@ -932,39 +864,41 @@ \dp\scratchbox\@@oldepth \box\scratchbox \egroup} - + % \backgroundimage{1}{\hsize}{\vsize}{\externalfigure[cow][\c!width=3cm]} \unexpanded\def\backgroundimage#1#2#3% repeat hsize vsize {\bgroup \forgetall - \dowithnextbox - {\offinterlineskip - \ifcase#1\relax - % just one - \else - \scratchdimen#2\divide\scratchdimen\nextboxwd\count0\scratchdimen\advance\count0\plusone - \scratchdimen#3\divide\scratchdimen\nextboxht\count2\scratchdimen\advance\count2\plusone - % to be considered, probably methods - \ifcase#1\or % x and y - \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}% - \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}% - \or % x - \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}% - \or % y - \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}% - \fi - \fi - \ifdim\nextboxwd>#2\relax - \setbox\nextbox\hbox to #2{\hss\flushnextbox\hss}% - \setbox\nextbox\hbox{\expanded{\clip[\c!width=#2,\c!height=\the\nextboxht]{\flushnextbox}}}% - \fi - \ifdim\nextboxht>#3\relax - \setbox\nextbox\vbox to #3{\vss\flushnextbox\vss}% - \setbox\nextbox\hbox{\expanded{\clip[\c!width=\the\nextboxwd,\c!height=#3]{\flushnextbox}}}% - \fi - \flushnextbox - \egroup}% - \hbox} - + \dowithnextbox{\boxes_background_image{#1}{#2}{#3}}\hbox} + +\def\boxes_background_image#1#2#3% + {\offinterlineskip + \ifcase#1\relax + % just one + \else + \scratchdimen#2\divide\scratchdimen\wd\nextbox\count0\scratchdimen\advance\count0\plusone + \scratchdimen#3\divide\scratchdimen\ht\nextbox\count2\scratchdimen\advance\count2\plusone + % to be considered: methods + \ifcase#1% + \or % x and y + \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}% + \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}% + \or % x + \setbox\nextbox\hbox{\dorecurse{\count0}{\copy\nextbox}}% + \or % y + \setbox\nextbox\vbox{\dorecurse{\count2}{\copy\nextbox\endgraf}}% + \fi + \fi + \ifdim\wd\nextbox>#2\relax + \setbox\nextbox\hbox to #2{\hss\box\nextbox\hss}% + \setbox\nextbox\hbox{\normalexpanded{\clip[\c!width=#2,\c!height=\the\ht\nextbox]{\box\nextbox}}}% + \fi + \ifdim\ht\nextbox>#3\relax + \setbox\nextbox\vbox to #3{\vss\box\nextbox\vss}% + \setbox\nextbox\hbox{\normalexpanded{\clip[\c!width=\the\wd\nextbox,\c!height=#3]{\box\nextbox}}}% + \fi + \box\nextbox + \egroup} + \protect \endinput diff --git a/tex/context/base/pack-fen.mkiv b/tex/context/base/pack-fen.mkiv index 722d8fed7..a5e692b68 100644 --- a/tex/context/base/pack-fen.mkiv +++ b/tex/context/base/pack-fen.mkiv @@ -28,20 +28,20 @@ \unprotect \def\installleftframerenderer#1#2% - {\setvalue{\??hf l\v!on#1}{\whateverleftframe{#2}}% - \expandafter\let\csname\??hf l\v!off#1\expandafter\endcsname\csname\??hf l\v!on#1\endcsname} + {\setvalue{\??framedleft\v!on#1}{\whateverleftframe{#2}}% + \expandafter\let\csname\??framedleft\v!off#1\expandafter\endcsname\csname\??framedleft\v!on#1\endcsname} \def\installrightframerenderer#1#2% - {\setvalue{\??hf r\v!on#1}{\whateverrightframe{#2}}% - \expandafter\let\csname\??hf r\v!off#1\expandafter\endcsname\csname\??hf r\v!on#1\endcsname} + {\setvalue{\??framedright\v!on#1}{\whateverrightframe{#2}}% + \expandafter\let\csname\??framedright\v!off#1\expandafter\endcsname\csname\??framedright\v!on#1\endcsname} \def\installtopframerenderer#1#2% - {\setvalue{\??hf t\v!on#1}{\whatevertopframe{#2}}% - \expandafter\let\csname\??hf t\v!off#1\expandafter\endcsname\csname\??hf t\v!on#1\endcsname} + {\setvalue{\??framedtop\v!on#1}{\whatevertopframe{#2}}% + \expandafter\let\csname\??framedtop\v!off#1\expandafter\endcsname\csname\??framedtop\v!on#1\endcsname} \def\installbottomframerenderer#1#2% - {\setvalue{\??hf b\v!on#1}{\whateverbottomframe{#2}}% - \expandafter\let\csname\??hf b\v!off#1\expandafter\endcsname\csname\??hf b\v!on#1\endcsname} + {\setvalue{\??framedbottom\v!on#1}{\whateverbottomframe{#2}}% + \expandafter\let\csname\??framedbottom\v!off#1\expandafter\endcsname\csname\??framedbottom\v!on#1\endcsname} \ifdefined \framed_overlay_initialize_indeed diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv index 2bba60df7..461edaefe 100644 --- a/tex/context/base/pack-lyr.mkiv +++ b/tex/context/base/pack-lyr.mkiv @@ -23,92 +23,165 @@ % displacement. Should be an option, on by default % (compatibility). -% positie=forceer == ja maar dan ook in status=herhaal - %D The layering mechanism implemented here is independent of %D the output routine, but future extensions may depend on a %D more close cooperation. -%D First we overload a macro from \type {core-rul}. From now on +%D First we overload a macro from \type {pack-rul}. From now on %D we accept a (optional) argument: the specific layer it %D will go in. This means that we can move an overlay from one %D background to the other using the dimensions of the parent. -\ifx\undefined\defineoverlay \message{loaded to early} \wait \fi +\ifdefined\defineoverlay \else \message{loaded to early} \wait \fi \unexpanded\def\defineoverlay - {\dotripleempty\dodefineoverlay} + {\dotripleempty\framed_define_overlay} -\def\dodefineoverlay[#1][#2][#3]% overlay [layer] content +\def\framed_define_overlay[#1][#2][#3]% overlay [layer] content {\ifthirdargument %\writestatus{BEWARE}{This (overlay definition) has changed!}% temp - \def\docommand##1{\setvalue{\??ov##1}{\setlayer[#2]{\executedefinedoverlay{##1}{#3}}}} + \def\framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\setlayer[#2]{\executedefinedoverlay{##1}{#3}}}} \else - \def\docommand##1{\setvalue{\??ov##1}{\executedefinedoverlay{##1}{#2}}}% + \def\framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\executedefinedoverlay{##1}{#2}}}% \fi - \processcommalist[#1]\docommand} - -%D When tracing is turned on, a couple of boxes will -%D show up as well as the reference point. - -\newif\iftracelayers % \tracelayerstrue + \processcommalist[#1]\framed_define_overlay_indeed} -%D This handy constant saved some string memory. +%D We use the command handler code. The previous, more direct parameter +%D handling was 25\% faster when no parameters were passed when adding +%D content to a layer. However, when we pass for instance a preset, the +%D new methos is some 10\% faster and it happens that in most cases we +%D do pass some parameters. It would be interesting to see if we can push +%D the preset in between the regular chain but it could also lead to +%D unwanted side effects when nesting layer placement. -\def\@@layerbox{@@layerbox} +\installcorenamespace{layer} +\installcorenamespace{layerbox} +\installcorenamespace{layerpreset} +\installcorenamespace{layerposition} %D \macros -%D {definelayer} +%D {definelayer,setuplayer} %D %D Each layer gets its own (global) box. This also means that %D the data that goes into a layer, is typeset immediately. %D Each layer automatically gets an associated overlay, %D which can be used in any background assignment. +%D +%D After a layer is defined, you can change its +%D characteristics. + +\installcommandhandler \??layer {layer} \??layer -% todo : links/rechts - -\unexpanded\def\definelayer - {\dodoubleargument\dodefinelayer} - -\def\dodefinelayer[#1][#2]% \zeropoint ipv \!!zeropoint - {\setuplayer - [#1] - [\c!doublesided=,\c!preset=, - \c!state=\v!start,\c!direction=\v!normal,\c!option=, - \c!x=\zeropoint,\c!y=\zeropoint,\c!position=\v!no, - \c!line=0,\c!column=0, - \c!width=\nextboxwd,\c!height=\nextboxht, - \c!offset=\zeropoint,\c!rotation=, % geen 0 ! - \c!hoffset=\zeropoint,\c!voffset=\zeropoint, - \c!dx=\zeropoint,\c!dy=\zeropoint, - \c!location=rb,\c!position=\v!no,\c!page=, - \c!method=\v!overlay, - \c!sx=1,\c!sy=1,\c!corner=,#2]% - \doifvalue{\??ll#1\c!doublesided}\v!yes - {\dopresetlayerbox{\v!left #1}% - \dopresetlayerbox{\v!right#1}}% - \dopresetlayerbox{#1}% - \defineoverlay[#1][\composedlayer{#1}]} - -\def\dopresetlayerbox#1% - {\ifcsname\@@layerbox#1\endcsname +\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] + +\let\p_layers_doublesided\empty +\let\p_layers_state \empty +\let\p_layers_option \empty +\let\p_layers_method \empty +\let\p_layers_preset \empty +\let\p_layers_rotation \empty +\let\p_layers_position \empty +\let\p_layers_hoffset \empty +\let\p_layers_voffset \empty +\let\p_layers_offset \empty +\let\p_layers_dx \empty +\let\p_layers_dy \empty +\let\p_layers_sx \empty +\let\p_layers_sy \empty +\let\p_layers_x \empty +\let\p_layers_y \empty +\let\p_layers_corner \empty +\let\p_layers_location \empty +\let\p_layers_line \empty +\let\p_layers_column \empty +\let\p_layers_width \empty +\let\p_layers_height \empty +\let\p_layers_direction \empty + +\let\m_layers_page \empty +\let\m_layers_target \empty + +\newconditional\c_layers_repeated +\newconditional\c_layers_trace +\newcount \c_layers_current_data + +\newbox\b_layers + +\newdimen\d_layers_x_size +\newdimen\d_layers_y_size +\newdimen\d_layers_x_offset +\newdimen\d_layers_y_offset +\newdimen\d_layers_x_position +\newdimen\d_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_layers_doublesided{\layerparameter\c!doublesided}% + \ifx\p_layers_doublesided\v!yes + \relateparameterhandlers{layer}{\v!left \currentlayer}{layer}\currentlayer % permits left* + \relateparameterhandlers{layer}{\v!right\currentlayer}{layer}\currentlayer % permits right* + \layers_preset_box{\v!left \currentlayer}% + \layers_preset_box{\v!right\currentlayer}% + \fi + \layers_preset_box\currentlayer + \normalexpanded{\defineoverlay[\currentlayer][\noexpand\composedlayer{\currentlayer}]}% +\to \everydefinelayer + +\def\layers_preset_box#1% + {\ifcsname\??layerbox#1\endcsname \resetlayer[#1]% \else - \expandafter\newbox\csname\@@layerbox#1\endcsname + \expandafter\newbox\csname\??layerbox#1\endcsname \fi} %D \macros -%D {setuplayer} +%D {resetlayer} %D -%D After a layer is defined, you can change its -%D characteristics. +%D This macro hardly needs an explanation (but is seldom +%D needed anyway). -\unexpanded\def\setuplayer - {\dodoubleargument\dosetuplayer} +\def\layers_reset_box#1% + {\ifcsname\??layerbox#1\endcsname + \global\setbox\csname\??layerbox#1\endcsname\emptybox + \fi} -\def\dosetuplayer[#1][#2]% - {\def\docommand##1{\getparameters[\??ll##1][#2]}% - \processcommalist[#1]\docommand} +\def\resetlayer[#1]% + {\layers_reset_box{#1}% + \layers_reset_box{\v!left #1}% + \layers_reset_box{\v!right#1}% + \layers_reset_box{#1:\realfolio}} %D \macros %D {setlayer} @@ -122,178 +195,174 @@ %D \setlayer [identifier] [optional parameters] {data} %D \stoptyping -\newcount\currentlayerdata - -\let\currentlayerwidth \!!zeropoint -\let\currentlayerheight\!!zeropoint - \def\setcurrentlayerdimensions - {\dodoubleempty\dosetcurrentlayerdimensions} + {\dodoubleempty\layers_set_current_dimensions} -\def\dosetcurrentlayerdimensions[#1][#2]% name left|right +\def\layers_set_current_dimensions[#1][#2]% name left|right {\edef\currentlayerwidth {\thelayerwidth {#2#1}}% \edef\currentlayerheight{\thelayerheight{#2#1}}} -\def\thelayerwidth #1{\the\wd\executeifdefined{\@@layerbox#1}\emptybox} -\def\thelayerheight#1{\the\ht\executeifdefined{\@@layerbox#1}\emptybox} +% \def\thelayerwidth #1{\the\wd\executeifdefined{\??layerbox#1}\emptybox} +% \def\thelayerheight#1{\the\ht\executeifdefined{\??layerbox#1}\emptybox} -\def\setlayer - {\dotripleempty\dosetlayer} +\def\thelayerwidth #1{\the\ifcsname\??layerbox#1\endcsname\wd\csname\??layerbox#1\endcsname\else\zeropoint\fi} +\def\thelayerheight#1{\the\ifcsname\??layerbox#1\endcsname\ht\csname\??layerbox#1\endcsname\else\zeropoint\fi} -\def\dosetlayer[#1][#2][#3]% #4 == box do \fi is ok - {\doifelsevalue{\??ll#1\c!state}\v!stop - {\dowithnextboxcs\donothing\hbox} - {\ifthirdargument - \dodosetlayer[#1][#2][#3]% - \else - \doifassignmentelse{#2} - {\dodosetlayer[#1][][#2]}% - {\dodosetlayer[#1][#2][]}% - \fi}} +\unexpanded\def\setlayer + {\dotripleempty\layers_set} -\def\dodosetlayer[#1][#2][#3]% #2 = links/rechts +\def\layers_set[#1][#2][#3]% #4 == box do \fi is ok {\bgroup - \recalculatebackgrounds % brrr - \global\advance\currentlayerdata\plusone + \edef\currentlayer{#1}% + \edef\p_layers_state{\layerparameter{#1}\c!state} + \ifx\p_layers_state\v!stop + \dowithnextboxcs\egroup\hbox + \else\ifthirdargument + \layers_set_indeed[#1][#2][#3]% + \else + \doifassignmentelse{#2} + {\layers_set_indeed[#1][][#2]}% + {\layers_set_indeed[#1][#2][]}% + \fi\fi} + +\def\layers_set_indeed[#1][#2][#3]% #2 = links/rechts + {\page_backgrounds_recalculate % brrr + \global\advance\c_layers_current_data\plusone \forgetall \dontcomplain - \doifvalue{\??ll#1\c!option}\v!test\tracelayerstrue - \iftracelayers\traceboxplacementtrue\fi - \dowithnextbox{\dodosetlayerindeed{#1}{#2}{#3}\egroup}\hbox} - -\def\dodosetlayerindeed#1#2#3% #2 = links/rechts - {\ifcsname\@@layerbox#1\endcsname % nb: odd/even discard, left/right not - \edef\@@layerloc{#2}% - \ifx\@@layerloc\v!even + \edef\p_layers_option{\layerparameter\c!option}% + \ifx\p_layers_option\v!test + \traceboxplacementtrue + \fi + \edef\m_layers_target{#2}% + \dowithnextbox{\layers_set_finish{#3}}\hbox} + +\def\layers_set_finish#1% + {\ifcsname\??layerbox\currentlayer\endcsname % can move up + \ifx\m_layers_target\v!even \ifodd\realpageno - % discard nextbox + % discard nextbox \else - \dododosetlayer[#1][\v!left][#3]% + \let\m_layers_target\v!left + \layers_set_content{#1}% \fi - \else\ifx\@@layerloc\v!odd + \else\ifx\m_layers_target\v!odd \ifodd\realpageno - \dododosetlayer[#1][\v!right][#3]% - %\else - % discard nextbox + \let\m_layers_target\v!right + \layers_set_content{#1}% + \else + % discard nextbox \fi \else - \dododosetlayer[#1][#2][#3]% + \layers_set_content{#1}% \fi\fi \else - \writestatus{layer}{unknown layer #1}% - \fi} - -\newbox\layerbox - -\newdimen\@@layerxsiz -\newdimen\@@layerysiz -\newdimen\@@layerxoff -\newdimen\@@layeryoff -\newdimen\@@layerxpos -\newdimen\@@layerypos - -\let\lastlayerxpos\!!zeropoint -\let\lastlayerypos\!!zeropoint -\let\lastlayerwd \!!zeropoint -\let\lastlayerht \!!zeropoint -\let\lastlayerdp \!!zeropoint + \writestatus{layer}{unknown layer \currentlayer}% + \fi + \egroup} % todo left/right -\def\setlastlayerpos#1% - {\edef\layerpage{\MPp{lyr:\the\currentlayerdata}}% - \xdef\lastlayerxpos{\the\dimexpr-\MPx{lyr:#1:\layerpage}+\MPx{lyr:\the\currentlayerdata}\relax}% - \xdef\lastlayerypos{\the\dimexpr \MPy{lyr:#1:\layerpage}-\MPy{lyr:\the\currentlayerdata}\relax}} +\def\layers_set_last_position_yes + {\edef\m_layers_page{\MPp{\??layerposition\the\c_layers_current_data}}% + \xdef\lastlayerxpos{\the\dimexpr-\MPx{\??layerposition\m_layers_target\currentlayer:\m_layers_page}+\MPx{\??layerposition\the\c_layers_current_data}\relax}% + \xdef\lastlayerypos{\the\dimexpr \MPy{\??layerposition\m_layers_target\currentlayer:\m_layers_page}-\MPy{\??layerposition\the\c_layers_current_data}\relax}%} + \d_layers_x_position\lastlayerxpos + \d_layers_y_position\lastlayerypos + \begingroup + \edef\currentlayer{\currentlayer\m_layers_page}% + \global\letlayerparameter\c!position\v!yes + \endgroup + \global\letlayerparameter\c!state\v!start % needed ? + \setbox\b_layers\vbox to \d_layers_y_size{\hbox to \d_layers_x_size{\xypos{\??layerposition\the\c_layers_current_data}\hss}\vss}} + +\def\layers_set_last_position_nop + {\setbox\b_layers\emptybox + \globallet\lastlayerxpos\!!zeropoint + \globallet\lastlayerypos\!!zeropoint + \doifinset\v!bottom\p_layers_corner\layers_set_bottom_positions + \doifinset\v!right \p_layers_corner\layers_set_right_positions + \doifinset\v!middle\p_layers_corner\layers_set_middle_positions + \edef\m_layers_page{\layerparameter\c!page}} \unexpanded\def\definelayerpreset - {\dodoubleargument\dodefinelayerpreset} - -% \def\dodefinelayerpreset[#1][#2]% -% {\setvalue{\??ll\??ll#1}{\dopresetlayer{#2}}} -% -% more fun: \definelayerpreset[whatever][lefttop] + {\dodoubleargument\layers_define_preset} -\def\dodefinelayerpreset[#1][#2]% +\def\layers_define_preset[#1][#2]% {\doifassignmentelse{#2} - {\setvalue{\??ll\??ll#1}{\dopresetlayer{#2}}} - {\setvalue{\??ll\??ll#1}{\csname\??ll\??ll#2\endcsname}}} - -\def\dopresetlayer#1#2#3% #1=list #2=tag #3=list - {\getparameters[\??ll#2][#1,#3]} - -\letempty\currentlayer - -\def\layerparameter#1{\csname\??ll\currentlayer#1\endcsname} - -\newdimen\layerwidth -\newdimen\layerheight - -\def\dododosetlayer[#1][#2][#3]% will be sped up - {% we use the global width, never change this - \def\currentlayer{#1}% - \@@layerxsiz\layerparameter\c!width - \@@layerysiz\layerparameter\c!height - \layerwidth \@@layerxsiz - \layerheight\@@layerysiz - % preroll - \getparameters[\??ll\currentlayer][#3]% + {\setvalue{\??layerpreset#1}{\setupcurrentlayer[#2]}} + {\setvalue{\??layerpreset#1}{\csname\??layerpreset#2\endcsname}}} + +\def\layers_set_content#1% + {\layerwidth \layerparameter\c!width % global (local later) + \layerheight\layerparameter\c!height % global (local later) + \d_layers_x_size\layerwidth + \d_layers_y_size\layerheight % - % \executeifdefined{\??ll\??ll\layerparameter\c!preset}\gobbletwoarguments\currentlayer{#3}% + \setupcurrentlayer[#1]% preroll % - \edef\@@currentlayerpreset{\layerparameter\c!preset}% - \ifcsname\??ll\??ll\@@currentlayerpreset\endcsname\csname\??ll\??ll\@@currentlayerpreset\endcsname\currentlayer{#3}\fi + \edef\p_layers_preset {\layerparameter\c!preset }% + % + \ifcsname\??layerpreset\p_layers_preset\endcsname + \csname\??layerpreset\p_layers_preset\endcsname + \setupcurrentlayer[#1]% postroll + \fi % - \doif{\layerparameter\c!position}\v!overlay % slow, use \dosetvalue instead - {\getparameters[\??ll\currentlayer][\c!width=\zeropoint,\c!height=\zeropoint,\c!position=\v!yes]}% - \doifsomething{\layerparameter\c!rotation}% todo: use direct lowlevel call - {\setbox\nextbox\hbox{\rotate[\c!location=\v!high,\c!rotation=\layerparameter\c!rotation]{\flushnextbox}}}% - % no, not local - % \@@layerxsiz\layerparameter\c!width - % \@@layerysiz\layerparameter\c!height - % never change that - \@@layerxpos\layerparameter\c!x - \@@layerypos\layerparameter\c!y - \doifelse{\layerparameter\c!hoffset}\v!max{\@@layerxoff\@@layerxsiz}{\@@layerxoff\layerparameter\c!hoffset}% - \doifelse{\layerparameter\c!voffset}\v!max{\@@layeryoff\@@layerysiz}{\@@layeryoff\layerparameter\c!voffset}% - % dx/dy are internal context ones and can be used in preset - \advance\@@layerxoff\dimexpr\layerparameter\c!offset+\layerparameter\c!dx\relax - \advance\@@layeryoff\dimexpr\layerparameter\c!offset+\layerparameter\c!dy\relax - \@@layerxpos\layerparameter\c!sx\@@layerxpos - \@@layerypos\layerparameter\c!sy\@@layerypos - \@@layerxoff\layerparameter\c!sx\@@layerxoff - \@@layeryoff\layerparameter\c!sy\@@layeryoff - \edef\@@currentlayerposition{\layerparameter\c!position}% - \ifx\@@currentlayerposition\v!yes % combine ^ - \setlastlayerpos{#2\currentlayer}% sets \layerpage; todo l/r %%%%%%%%%%%% - \@@layerxpos\lastlayerxpos - \@@layerypos\lastlayerypos - \letgvalue{\??ll\currentlayer\layerpage\c!position}\v!yes - \letgvalue{\??ll\currentlayer\c!state}\v!start % needed ? - \setbox\layerbox\vbox to \@@layerysiz{\hbox to \@@layerxsiz{\xypos{lyr:\the\currentlayerdata}\hss}\vss}% + \edef\p_layers_rotation {\layerparameter\c!rotation }% + \edef\p_layers_position {\layerparameter\c!position }% + \edef\p_layers_hoffset {\layerparameter\c!hoffset }% + \edef\p_layers_voffset {\layerparameter\c!voffset }% + \edef\p_layers_offset {\layerparameter\c!offset }% + \edef\p_layers_dx {\layerparameter\c!dx }% + \edef\p_layers_dy {\layerparameter\c!dy }% + \edef\p_layers_sx {\layerparameter\c!sx }% + \edef\p_layers_sy {\layerparameter\c!sy }% + \edef\p_layers_x {\layerparameter\c!x }% + \edef\p_layers_y {\layerparameter\c!y }% + \edef\p_layers_corner {\layerparameter\c!corner }% + \edef\p_layers_location {\layerparameter\c!location }% + \edef\p_layers_line {\layerparameter\c!line }% + \edef\p_layers_column {\layerparameter\c!column }% + \edef\p_layers_width {\layerparameter\c!width }% local ones + \edef\p_layers_height {\layerparameter\c!height }% local ones + \edef\p_layers_direction{\layerparameter\c!direction}% + % + \ifx\p_layers_position\v!overlay + \let\p_layers_width \zeropoint + \let\p_layers_height \zeropoint + \let\p_layers_position\v!yes + \fi + \ifx\p_layers_rotation\empty \else + % use direct call + \setbox\nextbox\hbox{\rotate[\c!location=\v!high,\c!rotation=\layerparameter\c!rotation]{\box\nextbox}}% + \fi + \d_layers_x_offset\p_layers_sx\dimexpr + \ifx\p_layers_hoffset\v!max\d_layers_x_size\else\p_layers_hoffset\fi+\p_layers_offset+\p_layers_dx + \relax + \d_layers_y_offset\p_layers_sy\dimexpr + \ifx\p_layers_voffset\v!max\d_layers_y_size\else\p_layers_voffset\fi+\p_layers_offset+\p_layers_dy + \relax + \d_layers_x_position\p_layers_sx\dimexpr\p_layers_x\relax + \d_layers_y_position\p_layers_sy\dimexpr\p_layers_y\relax + \ifx\p_layers_position\v!yes + \layers_set_last_position_yes \else - \setbox\layerbox\emptybox - \globallet\lastlayerxpos\!!zeropoint - \globallet\lastlayerypos\!!zeropoint - \normalexpanded{\doifinset{\v!bottom}{\layerparameter\c!corner}}\dosetlayerbottompositions - \normalexpanded{\doifinset{\v!right }{\layerparameter\c!corner}}\dosetlayerrightpositions - \normalexpanded{\doifinset{\v!middle}{\layerparameter\c!corner}}\dosetlayermiddlepositions - \edef\layerpage{\layerparameter\c!page}% + \layers_set_last_position_nop \fi - \ifx\layerpage\empty \else % is expanded - \edef\layerpage{:\layerpage}% - \ifcsname\@@layerbox#2\currentlayer\layerpage\endcsname \else - \expandafter\newbox\csname\@@layerbox#2\currentlayer\layerpage\endcsname + % + \ifx\m_layers_page\empty \else % is expanded + \edef\m_layers_page{:\m_layers_page}% + \ifcsname\??layerbox\m_layers_target\currentlayer\m_layers_page\endcsname \else + \expandafter\newbox\csname\??layerbox\m_layers_target\currentlayer\m_layers_page\endcsname \fi \fi - \chardef\layerpagebox\csname\@@layerbox#2\currentlayer\layerpage\endcsname + \chardef\layerpagebox\csname\??layerbox\m_layers_target\currentlayer\m_layers_page\endcsname \ifvoid\layerpagebox \gsetboxllx\layerpagebox\zeropoint \gsetboxlly\layerpagebox\zeropoint \fi \global\setbox\layerpagebox\vbox %to \layerparameter\c!height % new, otherwise no negative y possible {\offinterlineskip - %postpone, to after nextboxwd correction % \hsize\layerparameter\c!width % new, keep box small - %\ifvoid\csname\@@layerbox\currentlayer\layerpage\endcsname\else % why not #2#1 \ifvoid\layerpagebox \let\lastlayerwidth \zeropoint \let\lastlayerheight\zeropoint @@ -303,87 +372,89 @@ \ht\layerpagebox\zeropoint \dp\layerpagebox\zeropoint \wd\layerpagebox\zeropoint - \doifnot{\layerparameter\c!direction}\v!reverse{\box\layerpagebox}% + \ifx\p_layers_direction\v!reverse\else + \box\layerpagebox + \fi \fi % don't move - \xdef\lastlayerwd{\the\nextboxwd}% - \xdef\lastlayerht{\the\nextboxht}% % not entirely ok when grid ! - \xdef\lastlayerdp{\the\nextboxdp}% % not entirely ok when grid ! + \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 - \doifelse{\layerparameter\c!location}\v!grid\donetrue\donefalse - \ifdone - \nextboxht\strutheight - \nextboxdp\strutdepth + \ifx\p_layers_location\v!grid + \ht\nextbox\strutheight + \dp\nextbox\strutdepth \else - \setbox\nextbox\hbox{\alignedbox[\layerparameter\c!location]\vbox{\flushnextbox}}% + \setbox\nextbox\hbox{\alignedbox[\p_layers_location]\vbox{\box\nextbox}}% \fi - \ifnum\layerparameter\c!line=\zerocount\else % no \ifcase, can be negative - \advance\@@layerypos\dimexpr\layerparameter\c!line\lineheight+\topskip-\lineheight-\nextboxht\relax + \ifnum\p_layers_line=\zerocount\else % no \ifcase, can be negative + \advance\d_layers_y_position\dimexpr\p_layers_line\lineheight+\topskip-\lineheight-\ht\nextbox\relax \fi - \ifnum\layerparameter\c!column=\zerocount\else % no \ifcase, can be negative - \advance\@@layerxpos\layoutcolumnoffset{\layerparameter\c!column}% + \ifnum\p_layers_column=\zerocount\else % no \ifcase, can be negative + \advance\d_layers_x_position\layoutcolumnoffset\p_layers_column\relax \fi - \ifdone - \setbox\nextbox\hbox{\alignedbox[rb]\vbox{\flushnextbox}}% + \ifx\p_layers_location\v!grid + \setbox\nextbox\hbox{\alignedbox[rb]\vbox{\box\nextbox}}% \fi % ll registration - \scratchdimen\@@layerxpos - \advance\scratchdimen\@@layerxoff + \scratchdimen\dimexpr\d_layers_x_position+\d_layers_x_offset\relax \ifdim\scratchdimen<\getboxllx\layerpagebox \gsetboxllx\layerpagebox\scratchdimen \fi - \advance\scratchdimen\nextboxwd - \nextboxwd\ifdim\scratchdimen>\lastlayerwidth \scratchdimen \else \lastlayerwidth \fi - \scratchdimen\dimexpr\@@layerypos+\@@layeryoff\relax + \advance\scratchdimen\wd\nextbox + \wd\nextbox\ifdim\scratchdimen>\lastlayerwidth \scratchdimen \else \lastlayerwidth \fi + \scratchdimen\dimexpr\d_layers_y_position+\d_layers_y_offset\relax \ifdim\scratchdimen<\getboxlly\layerpagebox \gsetboxlly\layerpagebox\scratchdimen \fi % ll compensation - \advance\scratchdimen\dimexpr\nextboxht+\nextboxdp\relax - \nextboxht\ifdim\scratchdimen>\lastlayerheight \scratchdimen \else \lastlayerheight \fi - \nextboxdp\zeropoint + \advance\scratchdimen\dimexpr\ht\nextbox+\dp\nextbox\relax + \ht\nextbox\ifdim\scratchdimen>\lastlayerheight \scratchdimen \else \lastlayerheight \fi + \dp\nextbox\zeropoint % placement - \hsize\layerparameter\c!width % new, keep box small - \vbox to \layerparameter\c!height \bgroup + \hsize\p_layers_width + \vbox to \p_layers_height \bgroup \smashbox\nextbox - \vskip\dimexpr\@@layerypos+\@@layeryoff\relax - \hskip\dimexpr\@@layerxpos+\@@layerxoff\relax - \flushnextbox + \vskip\dimexpr\d_layers_y_position+\d_layers_y_offset\relax + \hskip\dimexpr\d_layers_x_position+\d_layers_x_offset\relax + \box\nextbox \ifvoid\layerpagebox % already flushed \else % the reverse case % check ! - \vskip-\dimexpr\@@layerypos+\@@layeryoff\relax + \vskip-\dimexpr\d_layers_y_position+\d_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\layerbox\else\box\layerbox\fi} + \ifvoid\b_layers \else + \box\b_layers + \fi} -\def\dosetlayerbottompositions - {\ifnum\layerparameter\c!line=\zerocount\else % can be < 0 - \setevalue{\??ll\currentlayer\c!line}{\the\numexpr-\layerparameter\c!line+\layoutlines+\plusone\relax}% +\def\layers_set_bottom_positions + {\ifnum\p_layers_line=\zerocount\else % can be < 0 + \edef\p_layers_line{\the\numexpr-\p_layers_line+\layoutlines+\plusone\relax}% use counter instead ? \fi - \ifdim\@@layerysiz>\zeropoint - \advance\@@layerypos-\@@layerysiz - \@@layerypos-\@@layerypos - \@@layeryoff-\@@layeryoff + \ifdim\d_layers_y_size>\zeropoint + \advance\d_layers_y_position-\d_layers_y_size + \d_layers_y_position-\d_layers_y_position + \d_layers_y_offset-\d_layers_y_offset \fi} -\def\dosetlayerrightpositions - {\ifnum\layerparameter\c!column=\zerocount\else % can be < 0 - \setevalue{\??ll\currentlayer\c!column}{\the\numexpr-\layerparameter\c!column+\layoutcolumns+\plusone\relax}% +\def\layers_set_right_positions + {\ifnum\p_layers_column=\zerocount\else % can be < 0 + \edef\p_layers_column{\the\numexpr-\layerparameter\c!column+\layoutcolumns+\plusone\relax}% use counter instead ? \fi - \ifdim\@@layerxsiz>\zeropoint - \advance\@@layerxpos-\@@layerxsiz - \@@layerxpos-\@@layerxpos - \@@layerxoff-\@@layerxoff + \ifdim\d_layers_x_size>\zeropoint + \advance\d_layers_x_position-\d_layers_x_size + \d_layers_x_position-\d_layers_x_position + \d_layers_x_offset-\d_layers_x_offset \fi} -\def\dosetlayermiddlepositions - {\ifdim\@@layerxsiz>\zeropoint \advance\@@layerxpos.5\@@layerxsiz \fi - \ifdim\@@layerysiz>\zeropoint \advance\@@layerypos.5\@@layerysiz \fi} +\def\layers_set_middle_positions + {\ifdim\d_layers_x_size>\zeropoint \advance\d_layers_x_position.5\d_layers_x_size \fi + \ifdim\d_layers_y_size>\zeropoint \advance\d_layers_y_position.5\d_layers_y_size \fi} %D Given the task to be accomplished, the previous macro is %D not even that complicated. It mainly comes down to skipping @@ -395,14 +466,14 @@ %D {doifelselayerdata} \def\doifelselayerdata#1% - {\ifcsname\@@layerbox#1\endcsname - \ifvoid\csname\@@layerbox#1\endcsname - \@EAEAEA\secondoftwoarguments + {\ifcsname\??layerbox#1\endcsname + \ifvoid\csname\??layerbox#1\endcsname + \doubleexpandafter\secondoftwoarguments \else - \@EAEAEA\firstoftwoarguments + \doubleexpandafter\firstoftwoarguments \fi \else - \@EA\secondoftwoarguments + \expandafter\secondoftwoarguments \fi} %D \macros @@ -415,114 +486,121 @@ % todo: setups before flush, handy hook -\unexpanded\def\flushlayer[#1]% quite core, so optimized +\unexpanded\def\flushlayer[#1]% quite core, so optimized (todo: check for void) {\begingroup \forgetall \edef\currentlayer{#1}% - \edef\@@currentlayerstate{\csname\??ll\currentlayer\c!state\endcsname}% - \ifx\@@currentlayerstate\v!stop + \edef\p_layers_state{\layerparameter\c!state}% + \ifx\p_layers_state\v!stop % nothing - \else\ifx\@@currentlayerstate\v!next - \global\expandafter\let\csname\??ll\currentlayer\c!state\endcsname\v!start % dangerous, stack-built-up - \else\ifx\@@currentlayerstate\v!continue - \global\expandafter\let\csname\??ll\currentlayer\c!state\endcsname\v!repeat % dangerous, stack-built-up + \else\ifx\p_layers_state\v!next + \global\letlayerparameter\c!state\v!start % dangerous, stack-built-up + \else\ifx\p_layers_state\v!continue + \global\letlayerparameter\c!state\v!repeat % dangerous, stack-built-up \else - \edef\@@currentlayerdoublesided{\csname\??ll\currentlayer\c!doublesided\endcsname}% - \ifx\@@currentlayerdoublesided\v!yes - \ifcsname\@@layerbox#1\endcsname + \edef\p_layers_doublesided{\layerparameter\c!doublesided}% + \ifx\p_layers_doublesided\v!yes + \ifcsname\??layerbox#1\endcsname % we can make a dedicated one for this - \doifbothsidesoverruled{\dodoflushlayerB\v!left}{\dodoflushlayerB\v!right}{\dodoflushlayerB\v!left}% + \doifbothsidesoverruled + {\layers_flush_double\v!left }% + {\layers_flush_double\v!right}% + {\layers_flush_double\v!left }% \else - \dodoflushlayerA + \layers_flush_single \fi \else - \dodoflushlayerA + \layers_flush_single \fi \fi\fi\fi \endgroup} % \ifcase#1\else\writestatus{layer}{unknown layer #3}\fi -\def\dodoflushlayerA +\def\layers_flush_single {\startoverlay - {\ifcsname\@@layerbox\currentlayer \endcsname\dodoflushlayer\plusone \currentlayer \fi}% - {\ifcsname\@@layerbox\currentlayer:\realfolio\endcsname\dodoflushlayer\zerocount{\currentlayer:\realfolio}\fi}% + {\ifcsname\??layerbox \currentlayer \endcsname\layers_flush_indeed\plusone \currentlayer \fi}% + {\ifcsname\??layerbox \currentlayer:\realfolio\endcsname\layers_flush_indeed\zerocount{\currentlayer:\realfolio}\fi}% \stopoverlay} -\def\dodoflushlayerB#1% +\def\layers_flush_double#1% {\startoverlay - {\ifcsname\@@layerbox \currentlayer \endcsname\dodoflushlayer\plusone \currentlayer \fi}% - {\ifcsname\@@layerbox \currentlayer:\realfolio\endcsname\dodoflushlayer\zerocount {\currentlayer:\realfolio}\fi}% - {\ifcsname\@@layerbox#1\currentlayer \endcsname\dodoflushlayer\plusone {#1\currentlayer }\fi}% - {\ifcsname\@@layerbox#1\currentlayer:\realfolio\endcsname\dodoflushlayer\zerocount{#1\currentlayer:\realfolio}\fi}% + {\ifcsname\??layerbox \currentlayer \endcsname\layers_flush_indeed\plusone \currentlayer \fi}% + {\ifcsname\??layerbox \currentlayer:\realfolio\endcsname\layers_flush_indeed\zerocount {\currentlayer:\realfolio}\fi}% + {\ifcsname\??layerbox#1\currentlayer \endcsname\layers_flush_indeed\plusone {#1\currentlayer }\fi}% + {\ifcsname\??layerbox#1\currentlayer:\realfolio\endcsname\layers_flush_indeed\zerocount{#1\currentlayer:\realfolio}\fi}% \stopoverlay} -\def\dodoflushlayer#1#2% quite core, so optimized +\def\layers_flush_indeed#1#2% quite core, so optimized {\begingroup % already grouped \offinterlineskip - \edef\@@currentlayermethod{\csname\??ll\currentlayer\c!method\endcsname}% - \edef\@@currentlayeroption{\csname\??ll\currentlayer\c!option\endcsname}% - % needed because we need to handle method but we should find a way to - % speed this up - \edef\@@currentlayerpreset{\csname\??ll\currentlayer\c!preset\endcsname}% - \ifcsname\??ll\??ll\@@currentlayerpreset\endcsname\csname\??ll\??ll\@@currentlayerpreset\endcsname\currentlayer{}\fi - % - \ifx\@@currentlayeroption\v!test - \tracelayerstrue + \edef\p_layers_preset{\layerparameter\c!preset}% + \ifcsname\??layerpreset\p_layers_preset\endcsname + \csname\??layerpreset\p_layers_preset\endcsname \fi - \iftracelayers + \edef\p_layers_method{\layerparameter\c!method}% + \edef\p_layers_option{\layerparameter\c!option}% + \ifx\p_layers_option\v!test \traceboxplacementtrue \fi - \!!doneafalse - \!!donebfalse - \ifx\@@currentlayermethod\v!overlay\!!doneatrue\fi - \ifx\@@currentlayermethod\v!fit \!!donebtrue\fi - \!!donectrue - \ifcase#1\else - \edef\@@currentlayerposition{\csname\??ll\currentlayer\c!position\endcsname}% - \ifx\@@currentlayerposition\v!yes \else - \edef\@@currentlayerrepeat{\csname\??ll\currentlayer\c!repeat\endcsname}% - % \edef\@@currentlayerstate {\csname\??ll\currentlayer\c!state\endcsname}% actually this is already set - \ifx\@@currentlayerrepeat\v!yes - \!!donecfalse - \else\ifx\@@currentlayerstate\v!repeat - \!!donecfalse + \ifcase#1\relax + \setfalse\c_layers_repeated + \else + \edef\p_layers_position{\layerparameter\c!position}% + \ifx\p_layers_position\v!yes + \setfalse\c_layers_repeated + \else + \edef\p_layers_repeat{\layerparameter\c!repeat}% + \ifx\p_layers_repeat\v!yes + \settrue\c_layers_repeated + \else\ifx\p_layers_state\v!repeat + \settrue\c_layers_repeated + \else + \setfalse\c_layers_repeated \fi\fi \fi \fi - \chardef\layerbox\csname\@@layerbox#2\endcsname % \@@layerbox\currentlayer + \chardef\b_layers\csname\??layerbox#2\endcsname % trick % 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 - \if!!doneb - \therepositionededlayerbox + \ifx\p_layers_method\v!fit + \layers_positioned_box_yes \else - \if!!donec\box\else\copy\fi\layerbox % sorry for the delay due to copying + \layers_positioned_box_nop \fi % todo: method=offset => overlayoffset right/down (handy for backgrounds with offset) - \doifoverlayelse{#2}{\setlayoutcomponentattribute{\v!layer:#2}}\resetlayoutcomponentattribute - \iftracelayers \ruledvbox \else \vbox \fi \if!!donea to \overlayheight \fi \layoutcomponentboxattribute - {\hbox \if!!donea to \overlaywidth \fi - {\edef\@@currentlayerpageposition{\csname\??ll#2\realfolio\c!position\endcsname}% - \ifx\@@currentlayerpageposition\v!yes\xypos{lyr:#2:\realfolio}\fi + \doifoverlayelse{#2}% + {\setlayoutcomponentattribute{\v!layer:#2}}% + \resetlayoutcomponentattribute + \ifx\p_layers_option\v!test \ruledvbox \else \vbox \fi \ifx\p_layers_method\v!overlay to \overlayheight \fi \layoutcomponentboxattribute + {\hbox \ifx\p_layers_method\v!overlay to \overlaywidth \fi + {\edef\currentlayer{#2\realfolio}% local + \edef\p_layers_position{\layerparameter\c!position}% local + \ifx\p_layers_position\v!yes + \xypos{\??layerposition#2:\realfolio}% + \fi \box\nextbox \hss}% \vss}% - \if!!donec - \gsetboxllx\layerbox\zeropoint - \gsetboxlly\layerbox\zeropoint + \ifconditional\c_layers_repeated\else + \gsetboxllx\b_layers\zeropoint + \gsetboxlly\b_layers\zeropoint \fi \endgroup} -\def\therepositionededlayerbox % assumes that \if!!donec is set (todo: use dedicated flags) +\def\layers_positioned_box_yes {\vbox - {\vskip-\getboxlly\layerbox - \hskip-\getboxllx\layerbox - \hsize-\dimexpr\getboxllx\layerbox-\wd\layerbox\relax - \if!!donec\box\else\copy\fi\layerbox}} + {\vskip-\getboxlly\b_layers + \hskip-\getboxllx\b_layers + \hsize-\dimexpr\getboxllx\b_layers-\wd\b_layers\relax + \ifconditional\c_layers_repeated\copy\else\box\fi\b_layers}} + +\def\layers_positioned_box_nop + {\ifconditional\c_layers_repeated\copy\else\box\fi\b_layers} -% \definelayer[test][method=fit] \setupcolors[state=start] \tracelayerstrue +% \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]} @@ -536,11 +614,9 @@ %D when we use it as parameter. This name also suits better %D to other layering commands. -\def\composedlayer#1{\flushlayer[#1]} - -\let\placelayer\flushlayer +\unexpanded\def\composedlayer#1{\flushlayer[#1]} -\def\tightlayer[#1]% +\unexpanded\def\tightlayer[#1]% {\hbox {\def\currentlayer{#1}% todo: left/right \setbox\nextbox\emptybox % hoogte/breedte are \wd\nextbox/\ht\nextbox @@ -548,23 +624,7 @@ \vsize\layerparameter\c!height % \overlaywheight = \vsize \composedlayer{#1}}} -%D \macros -%D {resetlayer} -%D -%D This macro hardly needs an explanation (and is seldom -%D needed as well). - -\def\doresetlayer#1% - {\ifcsname\@@layerbox#1\endcsname - \global\setbox\csname\@@layerbox#1\endcsname\emptybox - \fi} - -\def\resetlayer[#1]% - {\doresetlayer{#1}% - \doifvalue{\??ll#1\c!doublesided}\v!yes % kind of redundant test - {\doresetlayer{\v!left #1}% - \doresetlayer{\v!right#1}}% - \doresetlayer{#1:\realfolio}} +\let\placelayer\flushlayer %D \macros %D {setMPlayer} @@ -597,31 +657,28 @@ %D {\useMPgraphic{oeps}} %D \stoptyping -\def\setMPlayer - {\dotripleempty\dosetMPlayer} +\unexpanded\def\setMPlayer + {\dotripleempty\layers_set_MP} \def\MPlayerwidth {\hsize} \def\MPlayerheight{\vsize} -\def\dosetMPlayer[#1][#2][#3]% +\def\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]} -\def\getMPlayer - {\dodoubleempty\dogetMPlayer} +\unexpanded\def\getMPlayer + {\dodoubleempty\layers_get_MP} -\def\dogetMPlayer[#1][#2]% - {\framed - [\c!background={\v!foreground,#1}, - \c!frame=\v!off, - \c!offset=\v!overlay,#2]} +\def\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: -\ifx\settextpagecontent\undefined \writestatus\m!system{error in page-lyr.tex} \wait \fi - -\let\normalsettextpagecontent\settextpagecontent +\ifdefined\settextpagecontent \else + \writestatus\m!system{error in page-lyr.tex} \wait +\fi \definelayer [OTRTEXT] @@ -631,9 +688,9 @@ [\c!width=\innermakeupwidth, \c!height=\textheight] -% will be overloaded in page-spr +\let\normalsettextpagecontent\settextpagecontent % will be overloaded in page-spr -\def\settextpagecontent#1#2#3% #2 and #3 will disappear +\unexpanded\def\settextpagecontent#1#2#3% #2 and #3 will disappear {\doifelselayerdata{OTRTEXT} {\setbox#1\hbox to \makeupwidth {\startoverlay diff --git a/tex/context/base/pack-mis.mkvi b/tex/context/base/pack-mis.mkvi index c24c13808..af6a32070 100644 --- a/tex/context/base/pack-mis.mkvi +++ b/tex/context/base/pack-mis.mkvi @@ -22,7 +22,9 @@ % \placement [name][settings] % \place [settings] -\installcommandhandler \??pl {placement} \??pl +\installcorenamespace{placement} + +\installcommandhandler \??placement {placement} \??placement \appendtoks \setuevalue{\e!place\currentplacement}{\pack_placement{\currentplacement}}% diff --git a/tex/context/base/pack-pos.mkiv b/tex/context/base/pack-pos.mkiv index 3f71dfa8d..e0dc5508c 100644 --- a/tex/context/base/pack-pos.mkiv +++ b/tex/context/base/pack-pos.mkiv @@ -15,7 +15,7 @@ \unprotect -% An old but still usefull mechanism (updated in mkiv): +% An old but still usefull mechanism: % % \ruledvbox{\startpositioning % \position(1,1){test} diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv index e7620b43e..68dd4b28f 100644 --- a/tex/context/base/pack-rul.mkiv +++ b/tex/context/base/pack-rul.mkiv @@ -59,6 +59,12 @@ %D The parameter handler: +\installcorenamespace{framed} +\installcorenamespace{framedtop} +\installcorenamespace{framedbottom} +\installcorenamespace{framedleft} +\installcorenamespace{framedright} + \let\currentframed\s!unknown % brrr must have a value % \def\framedparameter #1{\csname\doframedparameter\currentframed{#1}\endcsname} @@ -172,7 +178,10 @@ %\c!orientation=, \c!autowidth=\v!yes, %\c!setups= -] + \c!loffset=\zeropoint, + \c!roffset=\zeropoint, + \c!toffset=\zeropoint, + \c!boffset=\zeropoint] % for backgrounds @@ -193,7 +202,11 @@ \c!framecorner=\framedparameter\c!corner, \c!frameradius=\framedparameter\c!radius, \c!framedepth=\framedparameter\c!depth, - \c!location=\v!normal] + \c!location=\v!normal, + \c!loffset=\zeropoint, + \c!roffset=\zeropoint, + \c!toffset=\zeropoint, + \c!boffset=\zeropoint] %D We will communicate through module specific variables, current %D framed parameters and some reserved dimension registers. @@ -357,14 +370,14 @@ %D It won't be a surprise that we not only provide gray boxes, %D but also colored ones. Here it is: -\def\framed_background_box_color % can be more of \color[] -> \faststartcolor in mkiv +\def\framed_background_box_color {\edef\p_framed_backgroundcolor{\framedparameter\c!backgroundcolor}% \ifx\p_framed_backgroundcolor\empty \else \doifcolor\p_framed_backgroundcolor\framed_background_box_color_indeed \fi} \def\framed_background_box_color_indeed - {\hbox{\doactivatecolor\p_framed_backgroundcolor\framed_filled_box}} + {\hbox{\dousecolorparameter\p_framed_backgroundcolor\framed_filled_box}} %D \macros %D {defineoverlay, doifoverlayelse, overlayoffset, @@ -440,6 +453,9 @@ %D can contain text and be executed under an regime where %D interlineskip is off). +\installcorenamespace{overlay} +\installcorenamespace{overlaybuiltin} + \appendtoks \oninterlineskip \to \everyoverlay @@ -453,7 +469,7 @@ {\dodoubleargument\framed_define_overlay} \def\framed_define_overlay[#1][#2]% - {\def\framed_define_overlay_indeed##1{\setvalue{\??ov##1}{\executedefinedoverlay{##1}{#2}}}% + {\def\framed_define_overlay_indeed##1{\setvalue{\??overlay##1}{\executedefinedoverlay{##1}{#2}}}% \processcommalist[#1]\framed_define_overlay_indeed} \unexpanded\def\executedefinedoverlay#1#2% we can share the definitions @@ -490,7 +506,7 @@ %D For testing we provide: \def\doifoverlayelse#1% only tests external overlays - {\ifcsname\??ov#1\endcsname + {\ifcsname\??overlay#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments @@ -507,9 +523,9 @@ \let\currentbackground\empty \def\framed_process_background - {\ifcsname\??ov:\currentbackground\endcsname + {\ifcsname\??overlaybuiltin\currentbackground\endcsname \framed_process_background_indeed_internal - \else\ifcsname\??ov\currentbackground\endcsname + \else\ifcsname\??overlay\currentbackground\endcsname \framed_process_background_indeed_external \fi\fi} @@ -517,10 +533,10 @@ {\bgroup \setbox\b_framed_extra\hbox{%\bgroup \ifzeropt\framedbackgroundoffset - \csname\??ov:\currentbackground\endcsname + \csname\??overlaybuiltin\currentbackground\endcsname \else \kern-\framedbackgroundoffset - \hbox{\csname\??ov:\currentbackground\endcsname}% + \hbox{\csname\??overlaybuiltin\currentbackground\endcsname}% \fi }%\egroup \wd\b_framed_extra\zeropoint @@ -534,10 +550,10 @@ \bgroup \setbox\b_framed_extra\hbox{%\bgroup \ifzeropt\framedbackgroundoffset - \csname\??ov\currentbackground\endcsname + \csname\??overlay\currentbackground\endcsname \else \kern-\framedbackgroundoffset - \hbox{\csname\??ov\currentbackground\endcsname}% + \hbox{\csname\??overlay\currentbackground\endcsname}% \fi }%\egroup \wd\b_framed_extra\zeropoint @@ -607,9 +623,9 @@ %D %D We predefine two already familiar backgrounds: -\letvalue{\??ov:\v!screen }\framed_background_box_gray -\letvalue{\??ov:\v!color }\framed_background_box_color -\letvalue{\??ov:\v!foreground}\framed_background_box_content % replaces: \defineoverlay[\v!foreground][\foregroundbox] +\letvalue{\??overlaybuiltin\v!screen }\framed_background_box_gray +\letvalue{\??overlaybuiltin\v!color }\framed_background_box_color +\letvalue{\??overlaybuiltin\v!foreground}\framed_background_box_content % replaces: \defineoverlay[\v!foreground][\foregroundbox] %D We can specify overlays as a comma separated list of %D overlays, a sometimes handy feature. @@ -636,7 +652,7 @@ \setbox\b_framed_extra\hbox {\kern-\d_framed_frameoffset \raise\scratchdimen - \hbox{\ifx\overlaylinecolor\empty\else\doactivatecolor\overlaylinecolor\fi\framed_stroked_box}}% + \hbox{\ifx\overlaylinecolor\empty\else\dousecolorparameter\overlaylinecolor\fi\framed_stroked_box}}% \wd\b_framed_extra\wd\b_framed_normal \ht\b_framed_extra\ht\b_framed_normal \dp\b_framed_extra\dp\b_framed_normal @@ -650,15 +666,15 @@ \ht\scratchbox\d_framed_target_ht \dp\scratchbox\d_framed_target_dp \setbox\scratchbox\vbox \bgroup - \csname \??hf t\p_framed_frame\framedparameter\c!topframe \endcsname + \csname \??framedtop\p_framed_frame\framedparameter\c!topframe \endcsname \nointerlineskip % new (needed for fences) \hbox \bgroup - \csname \??hf l\p_framed_frame\framedparameter\c!leftframe \endcsname + \csname \??framedleft\p_framed_frame\framedparameter\c!leftframe \endcsname \box\scratchbox - \csname \??hf r\p_framed_frame\framedparameter\c!rightframe \endcsname + \csname \??framedright\p_framed_frame\framedparameter\c!rightframe \endcsname \egroup \nointerlineskip % new (needed for fences) - \csname \??hf b\p_framed_frame\framedparameter\c!bottomframe\endcsname + \csname \??framedbottom\p_framed_frame\framedparameter\c!bottomframe\endcsname \egroup \wd\scratchbox\d_framed_target_wd \ht\scratchbox\d_framed_target_ht @@ -670,21 +686,21 @@ \def\framed_r_rule{\kern-\d_framed_linewidth\vrule\!!width\d_framed_linewidth} \def\framed_l_rule{\vrule\!!width\d_framed_linewidth\kern-\d_framed_linewidth} -\letvalue{\??hf t\v!on \v!on}\framed_t_rule -\letvalue{\??hf t\v!off\v!on}\framed_t_rule -\letvalue{\??hf t\v!on }\framed_t_rule +\letvalue{\??framedtop \v!on \v!on}\framed_t_rule +\letvalue{\??framedtop \v!off\v!on}\framed_t_rule +\letvalue{\??framedtop \v!on }\framed_t_rule -\letvalue{\??hf b\v!on \v!on}\framed_b_rule -\letvalue{\??hf b\v!off\v!on}\framed_b_rule -\letvalue{\??hf b\v!on }\framed_b_rule +\letvalue{\??framedbottom\v!on \v!on}\framed_b_rule +\letvalue{\??framedbottom\v!off\v!on}\framed_b_rule +\letvalue{\??framedbottom\v!on }\framed_b_rule -\letvalue{\??hf l\v!on \v!on}\framed_l_rule -\letvalue{\??hf l\v!off\v!on}\framed_l_rule -\letvalue{\??hf l\v!on }\framed_l_rule +\letvalue{\??framedleft \v!on \v!on}\framed_l_rule +\letvalue{\??framedleft \v!off\v!on}\framed_l_rule +\letvalue{\??framedleft \v!on }\framed_l_rule -\letvalue{\??hf r\v!on \v!on}\framed_r_rule -\letvalue{\??hf r\v!off\v!on}\framed_r_rule -\letvalue{\??hf r\v!on }\framed_r_rule +\letvalue{\??framedright \v!on \v!on}\framed_r_rule +\letvalue{\??framedright \v!off\v!on}\framed_r_rule +\letvalue{\??framedright \v!on }\framed_r_rule % no overlapping rules @@ -693,21 +709,21 @@ \def\framed_r_rules{\kern-\d_framed_linewidth\vrule\!!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\!!depth-\d_framed_linewidth\!!width\d_framed_linewidth} \def\framed_l_rules{\vrule\!!height\dimexpr\d_framed_target_ht-\d_framed_linewidth\relax\!!depth-\d_framed_linewidth\!!width\d_framed_linewidth\kern-\d_framed_linewidth} -\letvalue{\??hf t\v!small\v!small}\frame_t_rules -\letvalue{\??hf t\v!off \v!small}\frame_t_rules -\letvalue{\??hf t\v!small }\frame_t_rules +\letvalue{\??framedtop \v!small\v!small}\frame_t_rules +\letvalue{\??framedtop \v!off \v!small}\frame_t_rules +\letvalue{\??framedtop \v!small }\frame_t_rules -\letvalue{\??hf b\v!small\v!small}\frame_b_rules -\letvalue{\??hf b\v!off \v!small}\frame_b_rules -\letvalue{\??hf b\v!small }\frame_b_rules +\letvalue{\??framedbottom\v!small\v!small}\frame_b_rules +\letvalue{\??framedbottom\v!off \v!small}\frame_b_rules +\letvalue{\??framedbottom\v!small }\frame_b_rules -\letvalue{\??hf l\v!small\v!small}\frame_l_rules -\letvalue{\??hf l\v!off \v!small}\frame_l_rules -\letvalue{\??hf l\v!small }\frame_l_rules +\letvalue{\??framedleft \v!small\v!small}\frame_l_rules +\letvalue{\??framedleft \v!off \v!small}\frame_l_rules +\letvalue{\??framedleft \v!small }\frame_l_rules -\letvalue{\??hf r\v!small\v!small}\frame_r_rules -\letvalue{\??hf r\v!off \v!small}\frame_r_rules -\letvalue{\??hf r\v!small }\frame_r_rules +\letvalue{\??framedright \v!small\v!small}\frame_r_rules +\letvalue{\??framedright \v!off \v!small}\frame_r_rules +\letvalue{\??framedright \v!small }\frame_r_rules % \framed % [width=4cm,height=3cm,rulethickness=3mm, @@ -1669,11 +1685,10 @@ \def\framed_check_extra_offsets {\setfalse\c_framed_has_extra_offset - \d_framed_loffset\framedparameter\c!loffset - \d_framed_roffset\framedparameter\c!roffset - \d_framed_toffset\framedparameter\c!toffset - \d_framed_boffset\framedparameter\c!boffset - \relax + \d_framed_loffset\framedparameter\c!loffset\relax + \d_framed_roffset\framedparameter\c!roffset\relax + \d_framed_toffset\framedparameter\c!toffset\relax + \d_framed_boffset\framedparameter\c!boffset\relax \ifzeropt\d_framed_loffset\else \advance\d_framed_width -\d_framed_loffset \settrue\c_framed_has_extra_offset \fi \ifzeropt\d_framed_roffset\else \advance\d_framed_width -\d_framed_roffset \settrue\c_framed_has_extra_offset \fi \ifzeropt\d_framed_toffset\else \advance\d_framed_height-\d_framed_toffset \settrue\c_framed_has_extra_offset \fi @@ -2294,7 +2309,10 @@ %D %D The next definition shows the defaults. -\installframedcommandhandler \??kd {framedtext} \??kd +\installcorenamespace{framedtext} +\installcorenamespace{framedtextlocation} + +\installframedcommandhandler \??framedtext {framedtext} \??framedtext \let\setupframedtexts\setupframedtext @@ -2337,18 +2355,18 @@ \setuevalue {\currentframedtext}{\framed_text_direct{\currentframedtext}}% \to \everydefineframedtext -\setvalue{\??kd:l:\v!left }{\letframedtextparameter\c!left \relax - \letframedtextparameter\c!right\hfill} +\setvalue{\??framedtextlocation\v!left }{\letframedtextparameter\c!left \relax + \letframedtextparameter\c!right\hfill} -\setvalue{\??kd:l:\v!right }{\letframedtextparameter\c!left \hfill - \letframedtextparameter\c!right\relax} +\setvalue{\??framedtextlocation\v!right }{\letframedtextparameter\c!left \hfill + \letframedtextparameter\c!right\relax} -\setvalue{\??kd:l:\v!middle}{\letframedtextparameter\c!left \hfill - \letframedtextparameter\c!right\hfill} +\setvalue{\??framedtextlocation\v!middle}{\letframedtextparameter\c!left \hfill + \letframedtextparameter\c!right\hfill} -\setvalue{\??kd:l:\v!none }{\letframedtextparameter\c!left \relax - \letframedtextparameter\c!right\relax - \settrue\c_framed_text_location_none} +\setvalue{\??framedtextlocation\v!none }{\letframedtextparameter\c!left \relax + \letframedtextparameter\c!right\relax + \settrue\c_framed_text_location_none} \unexpanded\def\framed_text_start#1% {\bgroup @@ -2364,7 +2382,7 @@ {\setupframedtexts[\currentframedtext][#2]% \doifsomething{#1}{\setframedtextparameter\c!location{#1}}% does not listen to #3 \setfalse\c_framed_text_location_none - \csname\??kd:l:\framedtextparameter\c!location\endcsname + \csname\??framedtextlocation\framedtextparameter\c!location\endcsname \resetframedtextparameter\c!location % removed 06/2001 % \forgetparindent @@ -2390,7 +2408,7 @@ %D in the presentation styles, where we don't want %D interference. -\defineplacement[\??kd][\s!parent=\??kd\currentframedtext] +\defineplacement[\??framedtext][\s!parent=\??framedtext\currentframedtext] \unexpanded\def\framed_text_stop % no \baselinecorrection, see faq docs {\endgraf @@ -2406,7 +2424,7 @@ \box\b_framed_normal \else \egroup - \placement[\??kd][\c!depthcorrection=\v!off]{\box\b_framed_normal}% + \placement[\??framedtext][\c!depthcorrection=\v!off]{\box\b_framed_normal}% \fi\fi \egroup} @@ -2723,10 +2741,10 @@ \c!autowidth=\v!yes, %\c!setups=, \c!strut=\v!yes, - \c!loffset=\zeropoint, - \c!roffset=\zeropoint, - \c!toffset=\zeropoint, - \c!boffset=\zeropoint] + %\c!loffset=\zeropoint, + %\c!roffset=\zeropoint, + %\c!toffset=\zeropoint, + ]%\c!boffset=\zeropoint] \setupscreens [\c!screen=0.95] diff --git a/tex/context/base/page-app.mkiv b/tex/context/base/page-app.mkiv index c1f3859e1..07195996f 100644 --- a/tex/context/base/page-app.mkiv +++ b/tex/context/base/page-app.mkiv @@ -17,7 +17,9 @@ \unprotect -\installframedcommandhandler \??fp {fittingpage} \??fp +\installcorenamespace{fittingpage} + +\installframedcommandhandler \??fittingpage {fittingpage} \??fittingpage \newdimen\fitting_page_width \newdimen\fitting_page_height diff --git a/tex/context/base/page-bck.mkiv b/tex/context/base/page-bck.mkiv index 08bf8958b..42891e76e 100644 --- a/tex/context/base/page-bck.mkiv +++ b/tex/context/base/page-bck.mkiv @@ -219,7 +219,7 @@ %D regression. Calculation is delayed till the page anyway so the %D state is known. -\def\recalculatebackgrounds % will be renamed +\def\page_backgrounds_recalculate {\global\settrue\c_page_backgrounds_new} \def\page_backgrounds_set_boxes @@ -661,7 +661,7 @@ \def\enablehiddenbackground {\global\settrue\c_page_backgrounds_hidden_enabled \global\settrue\c_page_backgrounds_some - \recalculatebackgrounds} + \page_backgrounds_recalculate} \def\disablehiddenbackground {\global\setfalse\c_page_backgrounds_hidden_enabled} diff --git a/tex/context/base/page-com.mkiv b/tex/context/base/page-com.mkiv index fb7f34a4b..80012dd14 100644 --- a/tex/context/base/page-com.mkiv +++ b/tex/context/base/page-com.mkiv @@ -103,7 +103,7 @@ \setvalue{\e!start\v!pagecomment}% {\global\pagecommenttrue - \dostartbuffer[\v!pagecomment][\e!start\v!pagecomment][\e!stop\v!pagecomment]} + \grabbufferdatadirect\v!pagecomment{\e!start\v!pagecomment}{\e!stop\v!pagecomment}} \setuppagecomment [\c!state=, % \v!stop would invoke background calculation diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv index d18f78140..1804f9f95 100644 --- a/tex/context/base/page-imp.mkiv +++ b/tex/context/base/page-imp.mkiv @@ -51,6 +51,10 @@ % \def\pagestoshipout{1,3,5} % \stoptypen +\installcorenamespace{layouthandler} +\installcorenamespace{layoutarranger} +\installcorenamespace{layoutarrangeoption} + \newcount \shippedoutpages \newcount \combinedpagescounter @@ -61,14 +65,14 @@ \setnewconstant\shipoutfinalizemethod\plusone % this will be default (we will have two finalizers) -\def\installpagehandler#1#2% % a handler takes one argument: something to be boxed - {\setgvalue{\??pp:h:#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package) +\def\installpagehandler#1#2% % a handler takes one argument: something to be boxed + {\setgvalue{\??layouthandler#1}##1{#2{##1}}} % and shipped out (don't depend on the exact package) \unexpanded\def\invokepagehandler#1% - {\expandcheckedcsname{\??pp:h:}{#1}\v!normal} + {\expandcheckedcsname{\??layouthandler}{#1}\v!normal} \def\page_shipouts_handle - {\csname\??pp:h:\ifcsname\??pp:h:\v_page_target_method\endcsname + {\csname\??layouthandler\ifcsname\??layouthandler\v_page_target_method\endcsname \v_page_target_method \else \v!none @@ -198,17 +202,17 @@ \newcount\arrangedpageX \arrangedpageX\plusone \newcount\arrangedpageY \arrangedpageY\plusone -\def\pages_paper_set_offsets +\def\page_paper_set_offsets {\global\paperoffset\v_page_target_offset \global\advance\paperwidth -2\dimexpr\paperoffset/\arrangedpageX\relax \global\advance\paperheight-2\dimexpr\paperoffset/\arrangedpageY\relax} \def\doinstallarrangedoption#1#2% - {\setvalue{\??pp:o:#1}{#2}} + {\setvalue{\??layoutarrangeoption#1}{#2}} \def\doinstalledarrangedoption#1% - {\ifcsname\??pp:o:#1\endcsname - \csname\??pp:o:#1\endcsname + {\ifcsname\??layoutarrangeoption#1\endcsname + \csname\??layoutarrangeoption#1\endcsname \else \checkinstalledpagearrangement{#1}% this installs the arranger \fi} @@ -275,10 +279,10 @@ \fi} \def\installpagearrangement #1 % will lchange, no space - {\setgvalue{\??pp:a:#1}} + {\setgvalue{\??layoutarranger#1}} \def\checkinstalledpagearrangement#1% can be empty: aaa,,bbb - {\executeifdefined{\??pp:a:#1}\donothing} + {\executeifdefined{\??layoutarranger#1}\donothing} \let\poparrangedpages\relax \let\pusharrangedpage\relax diff --git a/tex/context/base/page-inf.mkiv b/tex/context/base/page-inf.mkiv index 41e3520c8..4c01e3076 100644 --- a/tex/context/base/page-inf.mkiv +++ b/tex/context/base/page-inf.mkiv @@ -17,6 +17,8 @@ \unprotect +\installcorenamespace{layoutinfo} + \newtoks\everyresetversion \newtoks\everysetupversion @@ -31,7 +33,7 @@ \def\page_info_setup[#1]% {\the\everyresetversion - \ifcsname\??ly:v:#1\endcsname + \ifcsname\??layoutinfo#1\endcsname \edef\currentversioninfo{#1}% \let\page_info_add_to_box\page_info_add_to_box_indeed \else @@ -41,13 +43,13 @@ \the\everysetupversion} \unexpanded\def\place_info_place_info % at the bottom of the page - {\csname\??ly:v:\currentversioninfo\endcsname} + {\csname\??layoutinfo\currentversioninfo\endcsname} \unexpanded\def\installversioninfo#1#2% - {\setvalue{\??ly:v:#1}{#2}} + {\setvalue{\??layoutinfo#1}{#2}} \unexpanded\def\includeversioninfo#1% - {\csname\??ly:v:#1\endcsname} + {\csname\??layoutinfo#1\endcsname} \installversioninfo\v!concept {\vskip\!!sixpoint diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index 253c8419b..623ee908e 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -374,15 +374,15 @@ \newconditional\page_marks_building_successive_pages \settrue\page_marks_building_successive_pages \def\page_marks_synchronize_page#1% box - {\dosynchronizemarking[\v!page][#1][\ifconditional\page_marks_building_successive_pages\v!keep\fi]} + {\marking_synchronize[\v!page][#1][\ifconditional\page_marks_building_successive_pages\v!keep\fi]} \def\page_marks_synchronize_column#1#2#3#4% first last column box {\ifnum#3=#1\relax - \dosynchronizemarking[\number#3,\v!column:\number#3,\v!first,\v!column:\v!first][#4][]% + \marking_synchronize[\number#3,\v!column:\number#3,\v!first,\v!column:\v!first][#4][]% \else\ifnum#3=#2\relax - \dosynchronizemarking[\number#3,\v!column:\number#3,\v!last, \v!column:\v!last ][#4][]% + \marking_synchronize[\number#3,\v!column:\number#3,\v!last, \v!column:\v!last ][#4][]% \else - \dosynchronizemarking[\number#3,\v!column:\number#3 ][#4][]% + \marking_synchronize[\number#3,\v!column:\number#3 ][#4][]% \fi\fi} % Page body building diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index c6ff5bc66..a6126b660 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -65,6 +65,8 @@ \newdimen\layoutcolumndistance \layoutcolumndistance = \zeropoint \newdimen\layoutcolumnwidth \layoutcolumnwidth = \zeropoint +\newdimen\totaltextwidth + %D The next series of dimensions are complemented by left %D and rights ones. @@ -108,7 +110,13 @@ %D Now we've come to the setup and definition commands. -\installswitchcommandhandler \??ly {layout} \??ly +\installcorenamespace{layout} +\installcorenamespace{layoutlocation} +\installcorenamespace{layoutalternative} +\installcorenamespace{layoutcolumn} +\installcorenamespace{layoutmethod} + +\installswitchcommandhandler \??layout {layout} \??layout \appendtoks \letlayoutparameter\c!state\v!start @@ -123,7 +131,7 @@ \to \everysetuplayout \appendtoks - \pages_layouts_synchronize + \page_layouts_synchronize \page_layouts_check_next \to \everysetuplayout @@ -163,7 +171,7 @@ \global\headerdistance \layoutdistance\headerheight \naturalheaderdistance \global\footerdistance \layoutdistance\footerheight \naturalfooterdistance \global\bottomdistance \layoutdistance\bottomheight \naturalbottomdistance - } + } \def\page_layouts_set_distances % local in \setreducedvsize {\headerdistance\layoutdistance\headerheight\naturalheaderdistance @@ -252,7 +260,12 @@ %D We keep track of these features with the following %D variables. -\installcommandhandler \??pp {layouttarget} \??pp % so this is a sort of mix, not really a user command / maybe switch handler +\installcorenamespace{layouttarget} +\installcorenamespace{layoutpaper} +\installcorenamespace{layoutprint} +\installcorenamespace{layoutcurrent} + +\installcommandhandler \??layouttarget {layouttarget} \??layouttarget % so this is a sort of mix, not really a user command / maybe switch handler \newconditional\c_page_target_paper_mirror \newconstant \c_page_target_paper_orientation @@ -294,7 +307,7 @@ \def\v_page_target_xy {\numexpr\v_page_target_nx*\v_page_target_ny\relax} % Normally we will not use this command directly but for now it -% works out okay. In th efuture we might use more of the related +% works out okay. In the future we might use more of the related % commands. \setuplayouttarget @@ -335,16 +348,16 @@ \else \doifassignmentelse{#2} {\definelayouttarget[#1][#2]} - {\setevalue{\??pp:1:#1}{#2}% - \setevalue{\??pp:2:#1}{#3}}% + {\setevalue{\??layoutpaper#1}{#2}% + \setevalue{\??layoutprint#1}{#3}}% \fi} \appendtoks - \letvalue{\??pp:c:\currentlayouttarget}\relax + \letvalue{\??layoutcurrent\currentlayouttarget}\relax \to \everydefinelayouttarget -\def\page_paper_the_paper_size#1{\ifcsname\??pp:1:#1\endcsname\csname\??pp:1:#1\endcsname\else#1\fi} -\def\page_paper_the_print_size#1{\ifcsname\??pp:2:#1\endcsname\csname\??pp:2:#1\endcsname\else#1\fi} +\def\page_paper_the_paper_size#1{\ifcsname\??layoutpaper#1\endcsname\csname\??layoutpaper#1\endcsname\else#1\fi} +\def\page_paper_the_print_size#1{\ifcsname\??layoutprint#1\endcsname\csname\??layoutprint#1\endcsname\else#1\fi} % \setuppaper [page=A4,paper=A3] % the k/v variant, changes the current page mapping % \setuppapersize[A4][a=b,c=d] % the k/v variant, changes nothing, just settings @@ -369,13 +382,13 @@ \unexpanded\def\setup_paper_size_settings[#1]% sometimes used to set paper/print size {\let\currentlayouttarget\empty - \edef\tmp_layouttarget_paper_saved{\page_paper_the_paper_size{\layouttargetparameter\c!page }}% - \edef\tmp_layouttarget_print_saved{\page_paper_the_print_size{\layouttargetparameter\c!paper}}% + \edef\m_layouttarget_paper_saved{\page_paper_the_paper_size{\layouttargetparameter\c!page }}% + \edef\m_layouttarget_print_saved{\page_paper_the_print_size{\layouttargetparameter\c!paper}}% \setupcurrentlayouttarget[#1]% - \edef\tmp_layouttarget_paper{\page_paper_the_paper_size{\layouttargetparameter\c!page }}% - \edef\tmp_layouttarget_print{\page_paper_the_print_size{\layouttargetparameter\c!paper}}% - \ifx\tmp_layouttarget_paper_saved\tmp_layouttarget_paper - \ifx\tmp_layouttarget_print_saved\tmp_layouttarget_print + \edef\m_layouttarget_paper{\page_paper_the_paper_size{\layouttargetparameter\c!page }}% + \edef\m_layouttarget_print{\page_paper_the_print_size{\layouttargetparameter\c!paper}}% + \ifx\m_layouttarget_paper_saved\m_layouttarget_paper + \ifx\m_layouttarget_print_saved\m_layouttarget_print % we didn't change the size, maybe only sx or sy or so \else \setup_paper_size_settings_recalibrate @@ -385,13 +398,13 @@ \fi} \def\setup_paper_size_settings_recalibrate - {\ifx\tmp_layouttarget_paper\empty + {\ifx\m_layouttarget_paper\empty % forget about it \else - \ifx\tmp_layouttarget_print\empty - \let\tmp_layouttarget_print\tmp_layouttarget_paper + \ifx\m_layouttarget_print\empty + \let\m_layouttarget_print\m_layouttarget_paper \fi - \pages_paper_set_current[\tmp_layouttarget_paper][\tmp_layouttarget_print]% + \page_paper_set_current[\m_layouttarget_paper][\m_layouttarget_print]% \fi \letlayouttargetparameter\c!page \papersize \letlayouttargetparameter\c!paper\printpapersize} @@ -402,8 +415,8 @@ \unexpanded\def\setup_paper_size_change_size[#1][#2]% {\doifelsenothing{#2} - {\pages_paper_set_current[#1][#1]} - {\pages_paper_set_current[#1][#2]}} + {\page_paper_set_current[#1][#1]} + {\page_paper_set_current[#1][#2]}} \let\setuppaper\setup_paper_size_settings @@ -420,69 +433,69 @@ \to \everyaftershipout \unexpanded\def\page_paper_set_restore#1#2% - {\xdef\page_paper_restore{\pages_paper_set_current_indeed[#1][#2]}} + {\xdef\page_paper_restore{\page_paper_set_current_indeed[#1][#2]}} -\unexpanded\def\pages_paper_set_current[#1][#2]% - {\normalexpanded{\pages_paper_set_current_indeed +\unexpanded\def\page_paper_set_current[#1][#2]% + {\normalexpanded{\page_paper_set_current_indeed [\page_paper_the_paper_size{#1}]% [\page_paper_the_print_size{#2}]}} -\setvalue{\??pp:1:\v!reset }{\global\setfalse\c_page_target_paper_landscape - \global\setfalse\c_page_target_paper_mirror - \global\setfalse\c_page_target_paper_negate - \global\c_page_target_paper_orientation\uprotationangle - \global\c_page_target_paper_reverse \uprotationangle} -\setvalue{\??pp:1:\v!landscape }{\global\settrue\c_page_target_paper_landscape} -\setvalue{\??pp:1:\v!mirrored }{\global\settrue\c_page_target_paper_mirror} -\setvalue{\??pp:1:\v!negative }{\global\settrue\c_page_target_paper_negate} -\setvalue{\??pp:1:\v!rotated }{\global\c_page_target_paper_orientation\rightrotationangle - \global\c_page_target_paper_reverse \leftrotationangle} -\setvalue{\??pp:1:\number\rightrotationangle}{\global\c_page_target_paper_orientation\rightrotationangle - \global\c_page_target_paper_reverse \leftrotationangle} -\setvalue{\??pp:1:\number\downrotationangle }{\global\c_page_target_paper_orientation\downrotationangle - \global\c_page_target_paper_reverse \zerocount} -\setvalue{\??pp:1:\number\leftrotationangle }{\global\c_page_target_paper_orientation\leftrotationangle - \global\c_page_target_paper_reverse \rightrotationangle} - -\setvalue{\??pp:1:\v!reset }{\global\setfalse\c_page_target_print_landscape - \global\setfalse\c_page_target_print_mirror - \global\setfalse\c_page_target_print_negate - \global\c_page_target_print_orientation\uprotationangle - \global\c_page_target_print_reverse \uprotationangle} -\setvalue{\??pp:2:\v!landscape }{\global\settrue\c_page_target_print_landscape} -\setvalue{\??pp:2:\v!mirrored }{\global\settrue\c_page_target_print_mirror} -\setvalue{\??pp:2:\v!negative }{\global\settrue\c_page_target_print_negate} -\setvalue{\??pp:2:\v!rotated }{\global\c_page_target_print_orientation\rightrotationangle - \global\c_page_target_print_reverse \leftrotationangle} -\setvalue{\??pp:2:\number\rightrotationangle}{\global\c_page_target_print_orientation\rightrotationangle - \global\c_page_target_print_reverse \leftrotationangle} -\setvalue{\??pp:2:\number\downrotationangle }{\global\c_page_target_print_orientation\downrotationangle - \global\c_page_target_print_reverse \zerocount} -\setvalue{\??pp:2:\number\leftrotationangle }{\global\c_page_target_print_orientation\leftrotationangle - \global\c_page_target_print_reverse \rightrotationangle} - -\def\pages_paper_handle_page_option #1{\ifcsname\??pp:1:#1\endcsname\csname\??pp:1:#1\endcsname\fi} -\def\pages_paper_handle_print_option#1{\ifcsname\??pp:2:#1\endcsname\csname\??pp:2:#1\endcsname\fi} - -\unexpanded\def\pages_paper_identify_target#1% - {\ifcsname\??pp:c:#1\endcsname +\setvalue{\??layoutpaper\v!reset }{\global\setfalse\c_page_target_paper_landscape + \global\setfalse\c_page_target_paper_mirror + \global\setfalse\c_page_target_paper_negate + \global\c_page_target_paper_orientation\uprotationangle + \global\c_page_target_paper_reverse \uprotationangle} +\setvalue{\??layoutpaper\v!landscape }{\global\settrue\c_page_target_paper_landscape} +\setvalue{\??layoutpaper\v!mirrored }{\global\settrue\c_page_target_paper_mirror} +\setvalue{\??layoutpaper\v!negative }{\global\settrue\c_page_target_paper_negate} +\setvalue{\??layoutpaper\v!rotated }{\global\c_page_target_paper_orientation\rightrotationangle + \global\c_page_target_paper_reverse \leftrotationangle} +\setvalue{\??layoutpaper\number\rightrotationangle}{\global\c_page_target_paper_orientation\rightrotationangle + \global\c_page_target_paper_reverse \leftrotationangle} +\setvalue{\??layoutpaper\number\downrotationangle }{\global\c_page_target_paper_orientation\downrotationangle + \global\c_page_target_paper_reverse \zerocount} +\setvalue{\??layoutpaper\number\leftrotationangle }{\global\c_page_target_paper_orientation\leftrotationangle + \global\c_page_target_paper_reverse \rightrotationangle} +\setvalue{\??layoutpaper\v!reset }{\global\setfalse\c_page_target_print_landscape + \global\setfalse\c_page_target_print_mirror + \global\setfalse\c_page_target_print_negate + \global\c_page_target_print_orientation\uprotationangle + \global\c_page_target_print_reverse \uprotationangle} + +\setvalue{\??layoutprint\v!landscape }{\global\settrue\c_page_target_print_landscape} +\setvalue{\??layoutprint\v!mirrored }{\global\settrue\c_page_target_print_mirror} +\setvalue{\??layoutprint\v!negative }{\global\settrue\c_page_target_print_negate} +\setvalue{\??layoutprint\v!rotated }{\global\c_page_target_print_orientation\rightrotationangle + \global\c_page_target_print_reverse \leftrotationangle} +\setvalue{\??layoutprint\number\rightrotationangle}{\global\c_page_target_print_orientation\rightrotationangle + \global\c_page_target_print_reverse \leftrotationangle} +\setvalue{\??layoutprint\number\downrotationangle }{\global\c_page_target_print_orientation\downrotationangle + \global\c_page_target_print_reverse \zerocount} +\setvalue{\??layoutprint\number\leftrotationangle }{\global\c_page_target_print_orientation\leftrotationangle + \global\c_page_target_print_reverse \rightrotationangle} + +\def\page_paper_handle_page_option #1{\ifcsname\??layoutpaper#1\endcsname\csname\??layoutpaper#1\endcsname\fi} +\def\page_paper_handle_print_option#1{\ifcsname\??layoutprint#1\endcsname\csname\??layoutprint#1\endcsname\fi} + +\unexpanded\def\page_paper_identify_target#1% + {\ifcsname\??layoutcurrent#1\endcsname \edef\currentlayouttarget{#1}% \fi} -\unexpanded\def\pages_paper_set_current_indeed[#1][#2]% - {\edef\tmp_pages_asked_paper{\v!reset,#1}% can be the restores - \edef\tmp_pages_asked_print{\v!reset,#2}% +\unexpanded\def\page_paper_set_current_indeed[#1][#2]% + {\edef\m_page_asked_paper{\v!reset,#1}% can be the restores + \edef\m_page_asked_print{\v!reset,#2}% % - \page_paper_set_restore\tmp_pages_asked_paper\tmp_pages_asked_print + \page_paper_set_restore\m_page_asked_paper\m_page_asked_print % % locate page target \let\currentlayouttarget\empty - \processcommacommand[\tmp_pages_asked_paper]\pages_paper_identify_target + \processcommacommand[\m_page_asked_paper]\page_paper_identify_target \ifx\currentlayouttarget\empty \let\currentlayouttarget\currentpage \fi \global\let\papersize\currentlayouttarget - \processcommacommand[\tmp_pages_asked_paper]\pages_paper_handle_page_option + \processcommacommand[\m_page_asked_paper]\page_paper_handle_page_option \global\paperwidth \layouttargetparameter\c!width \relax \global\paperheight\layouttargetparameter\c!height\relax \ifdim\paperwidth<\onepoint @@ -499,11 +512,11 @@ \normalexpanded{\setlayouttargetparemeter\c!width {\the\paperwidth }}% \fi % - \pages_paper_set_offsets + \page_paper_set_offsets % locate paper target - \processcommacommand[\tmp_pages_asked_print]\pages_paper_identify_target + \processcommacommand[\m_page_asked_print]\page_paper_identify_target \global\let\printpapersize\currentlayouttarget - \processcommacommand[\tmp_pages_asked_print]\pages_paper_handle_print_option + \processcommacommand[\m_page_asked_print]\page_paper_handle_print_option \global\printpaperwidth \layouttargetparameter\c!width \relax \global\printpaperheight\layouttargetparameter\c!height\relax \ifdim\printpaperwidth<\onepoint @@ -517,8 +530,8 @@ \fi % this check can be confusing, so we've added the possibility % to bypass this test: \setuppapersize[option=fit] - \edef\tmp_pages_asked_option{\rootlayouttargetparameter\c!option}% - \ifx\tmp_pages_asked_option\v!max % \v!fit is + \edef\m_page_asked_option{\rootlayouttargetparameter\c!option}% + \ifx\m_page_asked_option\v!max % \v!fit is \begingroup % we need to pre-swap else we get the wrong paper size \ifnum\c_page_target_paper_orientation=\rightrotationangle @@ -542,11 +555,11 @@ \endgroup \fi %\writestatus{layout target}{(\the\paperwidth,\the\paperheight) -> (\the\printpaperwidth,\the\printpaperheight)}% - \pages_layouts_synchronize} + \page_layouts_synchronize} -\ifx\pages_paper_set_offsets\undefined +\ifx\page_paper_set_offsets\undefined - \def\pages_paper_set_offsets % will move + \def\page_paper_set_offsets % will move {\global\paperoffset\v_page_target_offset \global\advance\paperwidth -2\paperoffset \global\advance\paperheight-2\paperoffset} @@ -556,7 +569,7 @@ \ifdefined\setups \else \unexpanded\def\setups[#1]{\setdefaultpenalties} \fi % still needed? \ifdefined\docheckgridsnapping \else \let\docheckgridsnapping\relax \fi -\def\pages_layouts_synchronize +\def\page_layouts_synchronize {\setups[\layoutparameter\c!preset]% \global\leftmarginwidth \layoutparameter\c!leftmargin \global\rightmarginwidth\layoutparameter\c!rightmargin @@ -655,13 +668,21 @@ \ifdim\makeupheight<\onepoint \global\makeupheight\onepoint \fi + % handy in page builder + \global\totaltextwidth\dimexpr + \leftedgetotal + +\leftmargintotal + +\makeupwidth + +\rightmargintotal + +\rightedgetotal + \relax % \page_layouts_check_next % here ? \page_layouts_calculate_extras \page_target_check_centering \calculatehsizes \calculatevsizes \page_layouts_check_pseudo_columns - \recalculatebackgrounds} + \page_backgrounds_recalculate} \def\page_layouts_check_pseudo_columns {\global\layoutcolumns\layoutparameter\c!columns @@ -673,21 +694,21 @@ \fi} \def\page_layouts_check_pseudo_column - {\setxvalue{\??ly:c:\recurselevel}% + {\setxvalue{\??layoutcolumn\recurselevel}% {\the\numexpr\recurselevel-\plusone\relax\dimexpr\layoutcolumnwidth+\layoutcolumndistance\relax}} -\letvalue{\??ly:c:0}\zeropoint +\letvalue{\??layoutcolumn0}\zeropoint \def\layoutcolumnoffset#1% - {\csname\??ly:c:\ifcsname\??ly:c:#1\endcsname#1\else0\fi\endcsname} + {\csname\??layoutcolumn\ifcsname\??layoutcolumn#1\endcsname#1\else0\fi\endcsname} -\def\pages_layouts_synchronize_at_start +\def\page_layouts_synchronize_at_start {\ifdim\makeupheight=\layoutlines\lineheight \else % weird check - \pages_layouts_synchronize + \page_layouts_synchronize \fi} \appendtoks - \pages_layouts_synchronize_at_start % still needed? + \page_layouts_synchronize_at_start % still needed? \to \everystarttext % document: @@ -701,7 +722,7 @@ \def\page_layouts_change#1% {%\writestatus\m!layouts{changing to layout #1}% \xdef\currentlayout{#1}% - \pages_layouts_synchronize} + \page_layouts_synchronize} \let\changetolayout\page_layouts_change % also public @@ -737,13 +758,13 @@ \ifcsname\namedlayouthash\v_real_page_odd_or_even\c!state\endcsname \page_layouts_check_default_indeed\v_real_page_odd_or_even\fi\fi\fi\fi\fi} \def\installlayoutmethod#1#2% - {\setgvalue{\??ly:m:#1}{#2}} + {\setgvalue{\??layoutmethod#1}{#2}} \installlayoutmethod\v!default{\page_layouts_check_default} \installlayoutmethod\v!normal {\page_layouts_check_default} \def\page_layouts_check_next - {\csname\??ly:m:\ifcsname\??ly:m:\layoutparameter\c!method\endcsname + {\csname\??layoutmethod\ifcsname\??layoutmethod\layoutparameter\c!method\endcsname \layoutparameter\c!method \else \v!normal @@ -797,27 +818,27 @@ \let\v_page_target_top_fill \relax \let\v_page_target_bottom_fill\relax} -\setvalue{\??ly:\c!location:\v!right }{\settrue\c_page_layouts_location_is_set - \let\v_page_target_left_fill \hss} -\setvalue{\??ly:\c!location:\v!left }{\settrue\c_page_layouts_location_is_set - \let\v_page_target_right_fill \hss} -\setvalue{\??ly:\c!location:\v!bottom }{\settrue\c_page_layouts_location_is_set - \let\v_page_target_top_fill \vss} -\setvalue{\??ly:\c!location:\v!top }{\settrue\c_page_layouts_location_is_set - \let\v_page_target_bottom_fill\vss} -\setvalue{\??ly:\c!location:\v!middle }{\settrue\c_page_layouts_location_is_set - \let\v_page_target_left_fill \hss - \let\v_page_target_right_fill \hss - \let\v_page_target_top_fill \vss - \let\v_page_target_bottom_fill\vss} -\setvalue{\??ly:\c!location:\empty }{\setfalse\c_page_layouts_location_is_set % default also signal to scrn_ - \let\v_page_target_right_fill \hss - \let\v_page_target_bottom_fill\hss} -\setvalue{\??ly:\c!location:\v!doublesided}{\settrue \c_page_target_print_doublesided} -\setvalue{\??ly:\c!location:\v!singlesided}{\setfalse\c_page_target_print_doublesided} +\setvalue{\??layoutlocation\v!right }{\settrue\c_page_layouts_location_is_set + \let\v_page_target_left_fill \hss} +\setvalue{\??layoutlocation\v!left }{\settrue\c_page_layouts_location_is_set + \let\v_page_target_right_fill \hss} +\setvalue{\??layoutlocation\v!bottom }{\settrue\c_page_layouts_location_is_set + \let\v_page_target_top_fill \vss} +\setvalue{\??layoutlocation\v!top }{\settrue\c_page_layouts_location_is_set + \let\v_page_target_bottom_fill\vss} +\setvalue{\??layoutlocation\v!middle }{\settrue\c_page_layouts_location_is_set + \let\v_page_target_left_fill \hss + \let\v_page_target_right_fill \hss + \let\v_page_target_top_fill \vss + \let\v_page_target_bottom_fill\vss} +\setvalue{\??layoutlocation\empty }{\setfalse\c_page_layouts_location_is_set % default also signal to scrn_ + \let\v_page_target_right_fill \hss + \let\v_page_target_bottom_fill\hss} +\setvalue{\??layoutlocation\v!doublesided}{\settrue \c_page_target_print_doublesided} +\setvalue{\??layoutlocation\v!singlesided}{\setfalse\c_page_target_print_doublesided} \def\page_target_check_centering_indeed#1% - {\ifcsname\??ly:\c!location:#1\endcsname\csname\??ly:\c!location:#1\endcsname\fi} + {\ifcsname\??layoutlocation#1\endcsname\csname\??layoutlocation#1\endcsname\fi} \unexpanded\def\page_target_check_centering {\setfalse\c_page_target_print_doublesided @@ -827,7 +848,7 @@ % installers \def\installlayoutalternative#1#2% - {\setgvalue{\??ly:a:#1}{#2}} + {\setgvalue{\??layoutalternative#1}{#2}} \def\page_boxes_construct_content_default#1#2% #1 and #2 will become variables {\setbox\pagebox\vbox @@ -843,7 +864,7 @@ \installlayoutalternative\v!normal {\page_boxes_construct_content_default} \def\page_boxes_construct_content - {\csname\??ly:a:\ifcsname\??ly:a:\layoutparameter\c!alternative\endcsname + {\csname\??layoutalternative\ifcsname\??layoutalternative\layoutparameter\c!alternative\endcsname \layoutparameter\c!alternative \else \v!normal @@ -892,7 +913,7 @@ \setvsize \global\pagegoal\vsize % - \recalculatebackgrounds + \page_backgrounds_recalculate \global\let\page_adepts_push\relax \global\let\page_adepts_pop\page_adepts_pop_indeed} @@ -912,7 +933,7 @@ \def\page_adepts_pop_indeed {\global\textheight \page_adepts_pushed_text_height \global\footerheight\page_adepts_pushed_footer_height - \pages_layouts_synchronize + \page_layouts_synchronize \global\let\page_adepts_push\page_adepts_push_indeed \global\let\page_adepts_pop\relax} @@ -998,16 +1019,16 @@ \def\freezetextwidth % name will change % \makeupwidth may be set to \textwidth {\textwidth\makeupwidth % which is a tricky but valid value - \edef\tmp_currentlayout_text_width {\layoutparameter\c!textwidth }% - \edef\tmp_currentlayout_text_margin{\layoutparameter\c!textmargin}% - \ifx\tmp_currentlayout_text_width\empty \else - \textwidth\tmp_currentlayout_text_width % local + \edef\m_currentlayout_text_width {\layoutparameter\c!textwidth }% + \edef\m_currentlayout_text_margin{\layoutparameter\c!textmargin}% + \ifx\m_currentlayout_text_width\empty \else + \textwidth\m_currentlayout_text_width % local \fi \global\innermakeupwidth\textwidth - \ifx\tmp_currentlayout_text_margin\empty + \ifx\m_currentlayout_text_margin\empty \global\innermakeupmargin\zeropoint \else - \global\innermakeupmargin\tmp_currentlayout_text_margin\relax + \global\innermakeupmargin\m_currentlayout_text_margin\relax \fi \scratchdimen\dimexpr\innermakeupmargin+\innermakeupmargin\relax \global\advance\innermakeupwidth-\scratchdimen @@ -1087,7 +1108,7 @@ % \freezepagestatechecks % \to \everybeforeshipout -\def\goleftonpage % name will change +\def\goleftonpage % name will change (we could cache) {\hskip-\dimexpr\leftmargindistance+\leftmarginwidth+\leftedgedistance+\leftedgewidth\relax} \def\doifmarginswapelse#1#2% diff --git a/tex/context/base/page-mak.mkvi b/tex/context/base/page-mak.mkvi index e4899f948..5cd9aa51b 100644 --- a/tex/context/base/page-mak.mkvi +++ b/tex/context/base/page-mak.mkvi @@ -37,7 +37,10 @@ %D New is that we have a layout with the same name so one can set %D up a special layout tthat then gets used. -\installcommandhandler \??do {makeup} \??do +\installcorenamespace{makeup} +\installcorenamespace{makeupdoublesided} + +\installcommandhandler \??makeup {makeup} \??makeup \appendtoks \setuevalue{\e!start\currentmakeup\e!makeup}{\startmakeup[\currentmakeup]}% @@ -123,17 +126,17 @@ \makeupparameter\c!after \relax % to be sure we don't enter the \if \ifdoublesided \ifodd\realpageno \else - \getvalue{\??do::\c!doublesided::\makeupparameter\c!doublesided}% + \getvalue{\??makeupdoublesided\makeupparameter\c!doublesided}% \fi \fi \poppagestate % new \egroup \stoplayout} % includes \page -\setvalue{\??do::\c!doublesided::\v!yes}% +\setvalue{\??makeupdoublesided\v!yes}% {\emptyhbox \page} -\setvalue{\??do::\c!doublesided::\v!empty}% +\setvalue{\??makeupdoublesided\v!empty}% {\the\page_makeup_every_setup % == \page[\v!dummy] \page[\v!blank]% diff --git a/tex/context/base/page-mbk.mkvi b/tex/context/base/page-mbk.mkvi index 7e13bb1b1..05e3cb104 100644 --- a/tex/context/base/page-mbk.mkvi +++ b/tex/context/base/page-mbk.mkvi @@ -36,15 +36,18 @@ % % todo: flush margin floats at end of text -\installcommandhandler \??mb {marginblock} \??mb +\installcorenamespace{marginblock} +\installcorenamespace{marginblocklocation} + +\installcommandhandler \??marginblock {marginblock} \??marginblock \let\setupmarginblocks\setupmarginblock -\newconditional\page_margin_blocks_c % not really needed as we can check each time +\newconditional\c_page_margin_blocks % not really needed as we can check each time \appendtoks \doifelse{\rootmarginblockparameter\c!state}\v!start - \settrue\setfalse\page_margin_blocks_c + \settrue\setfalse\c_page_margin_blocks \to \everysetupmarginblock \setupmarginblocks @@ -132,9 +135,9 @@ \fi} \def\page_margin_check_indeed - {\ifcsname\??mb::\c!location::\marginblockparameter\c!location\endcsname + {\ifcsname\??marginblocklocation\marginblockparameter\c!location\endcsname \page_margin_prepare_box - \csname\??mb::\c!location::\marginblockparameter\c!location\endcsname + \csname\??marginblocklocation\marginblockparameter\c!location\endcsname \else \global\page_margin_box\emptybox \fi} @@ -156,16 +159,16 @@ \box\page_margin_prepared_box \marginblockparameter\c!after}} -\setvalue{\??mb::\c!location::\v!left }{\page_margin_set_l_box} -\setvalue{\??mb::\c!location::\v!right }{\page_margin_set_r_box} -\setvalue{\??mb::\c!location::\v!inmargin}{\doifbothsidesoverruled - \page_margin_set_r_box - \page_margin_set_r_box - \page_margin_set_l_box} -\setvalue{\??mb::\c!location::\v!middle }{\doifbothsidesoverruled - \page_margin_set_r_box - \page_margin_set_l_box - \page_margin_set_r_box} +\setvalue{\??marginblocklocation\v!left }{\page_margin_set_l_box} +\setvalue{\??marginblocklocation\v!right }{\page_margin_set_r_box} +\setvalue{\??marginblocklocation\v!inmargin}{\doifbothsidesoverruled + \page_margin_set_r_box + \page_margin_set_r_box + \page_margin_set_l_box} +\setvalue{\??marginblocklocation\v!middle }{\doifbothsidesoverruled + \page_margin_set_r_box + \page_margin_set_l_box + \page_margin_set_r_box} \unexpanded\def\place_r_margin_block_yes {\setbox\page_margin_prepared_box\hbox to \rightmarginwidth @@ -218,12 +221,12 @@ {\someelsefloat[#options,\v!here]} % still an old name \def\page_margin_float_before - {\ifconditional\page_margin_blocks_c + {\ifconditional\c_page_margin_blocks \doifinset\v!margin\floatlocation\endgraf \fi} \def\page_margin_float_set_hsize - {\ifconditional\page_margin_blocks_c + {\ifconditional\c_page_margin_blocks \doifinset\v!margin\floatlocation{\hsize\rootmarginblockparameter\c!width}% \fi} diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-mis.mkiv index 507ab9a2b..d38068931 100644 --- a/tex/context/base/page-mis.mkiv +++ b/tex/context/base/page-mis.mkiv @@ -57,7 +57,7 @@ \def\page_postponed_blocks_start[#1]% {\edef\currentpostponedpage{#1}% - \dostartbuffer[postponedblock][\e!start\v!postponing][\e!stop\v!postponing]} + \grabbufferdatadirect{postponedblock}{\e!start\v!postponing}{\e!stop\v!postponing}} % officially we should flush again after a flush as there can be new future pages % but that will be looked into when we run into it diff --git a/tex/context/base/page-mrk.mkiv b/tex/context/base/page-mrk.mkiv index d1552dcfd..aabef6154 100644 --- a/tex/context/base/page-mrk.mkiv +++ b/tex/context/base/page-mrk.mkiv @@ -134,8 +134,10 @@ \let\page_marks_add_page\gobbleoneargument \let\page_marks_add_more\gobbleoneargument +\installcorenamespace{layoutmarking} + \def\installpagecutmark#1#2% - {\setvalue{\??ly:n:\c!marking:#1}{#2}} + {\setvalue{\??layoutmarking#1}{#2}} % \installpagecutmark\v!off % {} @@ -171,7 +173,7 @@ \setfalse\c_page_marks_add_more_marking \setfalse\c_page_marks_add_more_lines \setfalse\c_page_marks_add_more_number - \csname\??ly:n:\c!marking:\layoutparameter\c!marking\endcsname + \csname\??layoutmarking\layoutparameter\c!marking\endcsname \ifconditional\c_page_marks_add_page_lines \let\page_marks_add_page\page_marks_add_page_indeed \else diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv index 4fcb72719..b9e8daf7c 100644 --- a/tex/context/base/page-mul.mkiv +++ b/tex/context/base/page-mul.mkiv @@ -115,12 +115,6 @@ %D %D \interface \type{\ifinheritcolumns} \\ %D handle ragging or not \\ -%D \interface \type{\ifr@ggedbottom} \\ -%D use ragged bottoms \\ -%D \interface \type{\ifb@selinebottom} \\ -%D put the bottom line on the baseline \\ -%D \interface \type{\ifnormalbottom} \\ -%D put the bottom line at the baseline \\ %D %D \interface \type{\ifreversecolumns} \\ %D reverse the order in wich columns are flushed \\ @@ -541,7 +535,7 @@ %D One of the complications of flushing out the boxes is that %D \type{\precolumnbox} needs to be \type{\unvbox}'ed, otherwise %D there is too less flexibility in the page when using -%D \type{\r@ggedbottom}. It took a lot of time before these +%D \type{\raggedbottom}. It took a lot of time before these %D kind of problems were overcome. Using \type{\unvbox} at the %D wrong moment can generate \type{\balancingerror}'s. %D @@ -965,7 +959,8 @@ {\splitcurrentcolumn from \box\normalpagebox to \dimen0}% \setbox\restofpage\vbox{\unvbox\normalpagebox}% \ifinheritcolumns - \ifr@ggedbottom % vreemd + \ifcase\bottomraggednessmode + % 0 = ragged \dohandleallcolumns {\global\setbox\currentcolumnbox\vbox to \ht\firstcolumnbox {\dimen0\dp\currentcolumnbox @@ -977,14 +972,14 @@ \ifbottomnotes \else \dimen0\ht\firstcolumnbox \fi - \fi - \ifn@rmalbottom + \or + % 1 = normal \advance\dimen0 \maxdepth \dohandleallcolumns {\global\setbox\currentcolumnbox\vbox to \dimen0 {\unvbox\currentcolumnbox}}% - \fi - \ifb@selinebottom + \or + % 2 = baseline % the columns are on top of the baseline \fi \else @@ -1161,7 +1156,7 @@ \fi %\global\output{\balancingerror}% \page_otf_set_engine_output_routine{\balancingerror}% - \b@selinebottomtrue % forces depth in separation rule + \baselinebottom % forces depth in separation rule \flushcolumnedpage\plusone \multicolumnseject \egroup} @@ -1562,7 +1557,9 @@ \hskip.5\dimen0 \vrule \!!width\linewidth - \ifb@selinebottom\!!depth\strutdepth\fi + \ifnum\bottomraggednessmode=\plustwo % baselinebottom + \!!depth\strutdepth + \fi \hskip.5\dimen0\relax \stoptextproperties \egroup} @@ -1587,6 +1584,12 @@ \definecomplexorsimpleempty\startcolumns +% to be reconsidered ... (in any case they need to be unexpandable sinze 2011.12.30) + +\unexpanded\def\columns_align_option_yes {\stretchcolumnstrue \inheritcolumnsfalse}% todo: new key +\unexpanded\def\columns_align_option_no {\stretchcolumnsfalse\inheritcolumnsfalse}% todo: new key +\unexpanded\def\columns_align_option_text{\stretchcolumnsfalse\inheritcolumnstrue }% + \def\complexstartcolumns[#1]% %% \startcolumns {\bgroup \let\stopcolumns\egroup @@ -1611,9 +1614,9 @@ \doifelse\@@klbalance\v!yes \balancecolumnstrue \balancecolumnsfalse - \installalign\v!yes {\stretchcolumnstrue \inheritcolumnsfalse}% todo: new key - \installalign\v!no {\stretchcolumnsfalse\inheritcolumnsfalse}% todo: new key - \installalign\v!text{\stretchcolumnsfalse\inheritcolumnstrue }% + \installalign\v!yes {\columns_align_option_yes }% + \installalign\v!no {\columns_align_option_no }% + \installalign\v!text{\columns_align_option_text}% \stretchcolumnsfalse \inheritcolumnstrue \doifsomething\@@klalign{\expanded{\setupalign[\@@klalign]}}% diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv index c44ff830b..d958fc240 100644 --- a/tex/context/base/page-one.mkiv +++ b/tex/context/base/page-one.mkiv @@ -126,17 +126,20 @@ \prevdepth\openstrutdepth \dobotinsertions \vfil - \else\ifr@ggedbottom + \else\ifcase\bottomraggednessmode + % ragged \vskip\dimexpr\openstrutdepth-\d_page_one_natural_depth\relax \prevdepth\openstrutdepth \dobotinsertions \vfil - \else\ifb@selinebottom - \kern\dimexpr\maxdepth-\d_page_one_natural_depth\relax + \or + % align (normal) \dobotinsertions - \else + \or + % baseline + \kern\dimexpr\maxdepth-\d_page_one_natural_depth\relax \dobotinsertions - \fi\fi\fi + \fi\fi \fakepagenotes}% \ifconditional\c_notes_bottom_present \ifgridsnapping diff --git a/tex/context/base/page-plg.mkiv b/tex/context/base/page-plg.mkiv index 0921682c4..01f8f42c2 100644 --- a/tex/context/base/page-plg.mkiv +++ b/tex/context/base/page-plg.mkiv @@ -128,11 +128,11 @@ \hsize\paperwidth \vsize\paperheight \setbox\pagebox\vbox - {\doifbothsidesoverruled - {\let\!!stringa\v!page} - {\let\!!stringa\v!rightpage} - {\let\!!stringa\v!leftpage}% - \getvalue{\??ly\c!method:\!!stringa}}% +% {\doifbothsidesoverruled +% {\csname\??layoutmethod\v!page\endcsname} +% {\csname\??layoutmethod\v!rightpage\endcsname} +% {\csname\??layoutmethod\v!leftpage\endcsname}}% + {\csname\??layoutmethod\doifbothsidesoverruled\v!page\v!rightpage\v!leftpage\endcsname}% \wd\pagebox\paperwidth \ht\pagebox\paperheight \dp\pagebox\zeropoint} @@ -187,8 +187,8 @@ % to be done nicely (proper namespacing) -\setvalue{\??ly:m:\v!leftpage }{\csname\??ly:m:\v!page\endcsname} -\setvalue{\??ly:m:\v!rightpage}{\csname\??ly:m:\v!page\endcsname} +\setvalue{\??layoutmethod\v!leftpage }{\csname\??layoutmethod\v!page\endcsname} +\setvalue{\??layoutmethod\v!rightpage}{\csname\??layoutmethod\v!page\endcsname} \unexpanded\def\startpagelayout {\bgroup @@ -199,6 +199,6 @@ \def\start_page_layout[#1]#2\stoppagelayout {\egroup - \setvalue{\??ly:m:#1}{#2}} + \setvalue{\??layoutmethod#1}{#2}} \protect \endinput diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi index ff78ff89d..4d33e6c20 100644 --- a/tex/context/base/page-txt.mkvi +++ b/tex/context/base/page-txt.mkvi @@ -38,7 +38,15 @@ %D \showsetup{setupfooter} %D \showsetup{setupbottom} -\installcommandhandler \??tk {layoutelement} \??tk +\installcorenamespace{layouttexts} +\installcorenamespace{layouttextsline} +\installcorenamespace{layouttextsreset} +\installcorenamespace{layouttextssynchronize} +\installcorenamespace{layouttextstrut} +\installcorenamespace{layouttextspecial} +\installcorenamespace{layouttextcontent} + +\installcommandhandler \??layouttexts {layoutelement} \??layouttexts % \appendtoks % \resetlayoutelementparameter\c!lefttext % resolves better @@ -87,15 +95,15 @@ \to \everysetuplayoutelement \def\reset_layout_element_status#vertical% - {\expandafter\gdef\csname\??tk:r:#vertical\endcsname{\set_layout_element_status_normal#vertical}} + {\expandafter\gdef\csname\??layouttextsreset#vertical\endcsname{\set_layout_element_status_normal#vertical}} \def\set_layout_element_status_normal#vertical% {\global\expandafter\let\csname\namedlayoutelementhash#vertical\c!state\endcsname\v!normal - \global\expandafter\let\csname\??tk:r:#vertical\endcsname\relax + \global\expandafter\let\csname\??layouttextsreset#vertical\endcsname\relax \synchronize_current_layout_element{#vertical}} \def\synchronize_current_layout_element#vertical% - {\xdef\previoustextstate{\getvalue{\??tk:x:#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 @@ -107,7 +115,7 @@ \ifx\previoustextstate\v!high \calculatevsizes\recalculatebackgrounds \else \ifx\currenttextstate \v!none \calculatevsizes\recalculatebackgrounds \else \ifx\previoustextstate\v!none \calculatevsizes\recalculatebackgrounds \fi\fi\fi\fi - \letgvalue{\??tk:x:#vertical}\currenttextstate} + \letgvalue{\??layouttextssynchronize#vertical}\currenttextstate} \unexpanded\def\setuptop {\dotripleempty\setup_layout_text[\v!top ]} \unexpanded\def\setupheader{\dotripleempty\setup_layout_text[\v!header]} @@ -241,60 +249,6 @@ \resetlayoutelementparameter\c!middletext \fi\fi\fi\fi\fi} -% \def\setup_texts[#vertical][#horizontal][#a][#b][#c][#d]% -% {\ifsixthargument -% \edef\currentlayoutelement{#vertical:#horizontal}% -% \setlayoutelementparameter\c!lefttext -% {\process_layout_element_double -% \c!leftstyle \c!leftcolor \c!leftwidth {#a}% -% \c!rightstyle\c!rightcolor\c!rightwidth{#d}}% -% \setlayoutelementparameter\c!righttext -% {\process_layout_element_double -% \c!rightstyle\c!rightcolor\c!rightwidth{#b}% -% \c!leftstyle \c!leftcolor \c!leftwidth {#c}}% -% \else\iffifthargument -% \sixthargumenttrue -% \setup_texts[#vertical][\v!text][#horizontal][#a][#b][#c]% -% \else\iffourthargument -% \edef\currentlayoutelement{#vertical:#horizontal}% -% \doifelsenothing{\detokenize{#a}} -% {\resetlayoutelementparameter\c!lefttext} -% {\setlayoutelementparameter\c!lefttext -% {\process_layout_element_double -% \c!leftstyle\c!leftcolor\c!leftwidth{#a}% -% \c!leftstyle\c!leftcolor\c!leftwidth{#a}}}% -% \doifelsenothing{\detokenize{#b}} -% {\resetlayoutelementparameter\c!righttext} -% {\setlayoutelementparameter\c!righttext -% {\process_layout_element_double -% \c!rightstyle\c!rightcolor\c!rightwidth{#b}% -% \c!rightstyle\c!rightcolor\c!rightwidth{#b}}}% -% \else\ifthirdargument -% \fourthargumenttrue -% \setup_texts[#vertical][\v!text][#horizontal][#horizontal][][]% -% \else\ifsecondargument -% \edef\currentlayoutelement{#vertical:\v!text}% -% \resetlayoutelementparameter\c!lefttext -% \resetlayoutelementparameter\c!righttext -% \doifelsenothing{\detokenize{#horizontal}} -% {\resetlayoutelementparameter\c!middletext} -% {\setlayoutelementparameter\c!middletext -% {\process_layout_element_single\c!style\c!color\c!width{#horizontal}}}% -% \else -% \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 -% \fi\fi\fi\fi\fi} - %D Left and right texts are swapped on odd and even pages, but %D only when double sided typesetting is enabled. @@ -303,10 +257,10 @@ \process_layout_element_double_odd \process_layout_element_double_even} -\def\process_layout_element_double_odd #lstyle#lstyle#lwidth#lcontent#rstyle#rcolor#rwidth#rcontent% - {\process_layout_element_single#lstyle#lstyle#lwidth{#lcontent}} +\def\process_layout_element_double_odd #lstyle#lcolor#lwidth#lcontent#rstyle#rcolor#rwidth#rcontent% + {\process_layout_element_single#lstyle#lcolor#lwidth{#lcontent}} -\def\process_layout_element_double_even#lstyle#lstyle#lwidth#lcontent#rstyle#rcolor#rwidth#rcontent% +\def\process_layout_element_double_even#lstyle#color#lwidth#lcontent#rstyle#rcolor#rwidth#rcontent% {\process_layout_element_single#rstyle#rcolor#rwidth{#rcontent}} %D The next macro will be cleaned up and made less messy and @@ -320,14 +274,14 @@ \process_layout_element_single_indeed#style#color#width{#content}% \fi} -\setvalue{\??tk:s:\v!yes}{\setstrut\strut} % maybe more variants +\setvalue{\??layouttextstrut\v!yes}{\setstrut\strut} % maybe more variants \def\process_layout_element_single_indeed#style#color#width#content% {\begingroup \uselayoutelementstyleandcolor#style#color% - \csname\??tk:s:\layoutelementparameter\c!strut\endcsname - \ifcsname\??tk:p:\layout_element_content\endcsname - \csname\??tk:p:\layout_element_content\endcsname + \csname\??layouttextstrut\layoutelementparameter\c!strut\endcsname + \ifcsname\??layouttextspecial\layout_element_content\endcsname + \csname\??layouttextspecial\layout_element_content\endcsname \else \edef\currentlayoutelementwidth{\layoutelementparameter#width}% \ifx\currentlayoutelementwidth\empty @@ -350,8 +304,8 @@ {\limitatetext{\getmarking[\layout_element_content][\v!first]}\currentlayoutelementwidth\unknown} {\ignorecrlf\limitatetext{#content{}{}{}}\currentlayoutelementwidth\unknown}} -\setvalue{\??tk:p:\v!pagenumber}{\place_layout_page_number} -\setvalue{\??tk:p:\v!date }{\currentdate} +\setvalue{\??layouttextspecial\v!pagenumber}{\place_layout_page_number} +\setvalue{\??layouttextspecial\v!date }{\currentdate} %D When specified, the texts are automatically limited in %D length. @@ -398,7 +352,7 @@ \unexpanded\def\place_layout_text_line#vertical% {\set_layout_element_status#vertical% - \csname\??tk:l:\ifcsname\??tk:l:\textlinestatus\endcsname\textlinestatus\else\s!unknown\fi\endcsname#vertical} + \csname\??layouttextsline\ifcsname\??layouttextsline\textlinestatus\endcsname\textlinestatus\else\s!unknown\fi\endcsname#vertical} \unexpanded\def\doifelselayouttextline#vertical% shown or not {\edef\currentlayoutelementstate{\namedlayoutelementparameter{#vertical}\c!state}% @@ -422,32 +376,31 @@ \newconditional\resyncaftertextline -\setvalue{\??tk:l:\v!normal}{\place_layout_text_line_indeed} -\setvalue{\??tk:l:\empty }{\place_layout_text_line_indeed} +\setvalue{\??layouttextsline\v!normal}{\place_layout_text_line_indeed} +\setvalue{\??layouttextsline\empty }{\place_layout_text_line_indeed} -\letvalue{\??tk:l:\v!none}\gobbletwoarguments -\letvalue{\??tk:l:\v!stop}\gobbletwoarguments +\letvalue{\??layouttextsline\v!none}\gobbletwoarguments +\letvalue{\??layouttextsline\v!stop}\gobbletwoarguments -\setvalue{\??tk:l:\v!high}#vertical#height% +\setvalue{\??layouttextsline\v!high}#vertical#height% {\global\settrue\resyncaftertextline \reset_layout_element_status#vertical} -\setvalue{\??tk:l:\v!empty}#vertical#height% +\setvalue{\??layouttextsline\v!empty}#vertical#height% {\reset_layout_element_status#vertical} -\setvalue{\??tk:l:\v!start}#vertical#height% +\setvalue{\??layouttextsline\v!start}#vertical#height% {\reset_layout_element_status#vertical% \place_layout_text_line_indeed#vertical#height} -\setvalue{\??tk:l:\v!nomarking}#vertical#height% +\setvalue{\??layouttextsline\v!nomarking}#vertical#height% {\bgroup \reset_layout_element_status#vertical% \settrue\inhibitgetmarking - \let\dogetmarking\nogetmarking % obsolete in new marking mechanism \place_layout_text_line_indeed#vertical#height% \egroup} -\setvalue{\??tk:l:\s!unknown}#vertical#height% +\setvalue{\??layouttextsline\s!unknown}#vertical#height% {\global\settrue\resyncaftertextline \begingroup % new \reset_layout_element_status#vertical% @@ -462,11 +415,11 @@ %D is flushed. \def\resetlayouttextlines % public - {\csname\??tk:r:\v!top \endcsname - \csname\??tk:r:\v!header\endcsname - \csname\??tk:r:\v!text \endcsname - \csname\??tk:r:\v!footer\endcsname - \csname\??tk:r:\v!bottom\endcsname + {\csname\??layouttextsreset\v!top \endcsname + \csname\??layouttextsreset\v!header\endcsname + \csname\??layouttextsreset\v!text \endcsname + \csname\??layouttextsreset\v!footer\endcsname + \csname\??layouttextsreset\v!bottom\endcsname \ifconditional\resyncaftertextline \calculateglobalvsizes \recalculatebackgrounds @@ -480,12 +433,12 @@ \def\set_text_content[#vertical][#horizontal][#one][#two][#three]% header text middle text/text {\iffifthargument - \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\executeifdefined{\??tk:c:\c!text:#one}\c!middletext}% + \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\executeifdefined{\??layouttextcontent\c!text:#one}\c!middletext}% {\process_layout_element_double \c!leftstyle \c!leftcolor \c!leftwidth {#two}% \c!rightstyle\c!rightcolor\c!rightwidth{#three}}% \else\iffourthargument - \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\executeifdefined{\??tk:c:\c!text:#one}\c!middletext}% + \setvalue{\namedlayoutelementhash{#vertical:#horizontal}\executeifdefined{\??layouttextcontent\c!text:#one}\c!middletext}% {\process_layout_element_double \c!leftstyle \c!leftcolor \c!leftwidth {#two}% \c!rightstyle\c!rightcolor\c!rightwidth{#two}}% @@ -502,16 +455,16 @@ \def\reset_text_content[#vertical][#horizontal][#tag]% header text middle {\edef\currentlayoutelement{#vertical:#horizontal}% \ifthirdargument - \letvalueempty{\layoutelementhash\executeifdefined{\??tk:c:\c!text:#tag}\c!middletext}% + \letvalueempty{\layoutelementhash\executeifdefined{\??layouttextcontent\c!text:#tag}\c!middletext}% \else\ifsecondargument \resetlayoutelementparameter\c!lefttext \resetlayoutelementparameter\c!middletext \resetlayoutelementparameter\c!righttext \fi\fi} -\letvalue{\??tk:c:\c!middle:\c!text}\c!middletext -\letvalue{\??tk:c:\c!left :\c!text}\c!lefttext -\letvalue{\??tk:c:\c!right :\c!text}\c!righttext +\letvalue{\??layouttextcontent\c!middle:\c!text}\c!middletext +\letvalue{\??layouttextcontent\c!left :\c!text}\c!lefttext +\letvalue{\??layouttextcontent\c!right :\c!text}\c!righttext %D The placement of a whole line is handled by the next two %D macros. These are hooked into the general purpose token @@ -527,22 +480,22 @@ \def\place_layout_text_line_left_or_right#height% {\goleftonpage -% \hbox{% - \setbox\layout_element_box\vbox to #height - {\vsize#height\relax - \normalbaselines - \let\\\ignoredlinebreak - \let\crlf\ignoredlinebreak - \namedlayoutelementparameter\currentlayouttextline\c!before - \doifbothsidesoverruled - \place_layout_text_line_right - \place_layout_text_line_right - \place_layout_text_line_left - \namedlayoutelementparameter\currentlayouttextline\c!after - \kern\zeropoint}% keep the \dp, beware of \vtops, never change this! - \dp\layout_element_box\zeropoint - \box\layout_element_box -% }% + \setbox\layout_element_box\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 + \place_layout_text_line_right + \place_layout_text_line_right + \place_layout_text_line_left + \namedlayoutelementparameter\currentlayouttextline\c!after + \kern\zeropoint}% keep the \dp, beware of \vtops, never change this! + \dp\layout_element_box\zeropoint + \box\layout_element_box \vskip-#height\relax} \let\extra_at_margin_left \plusone @@ -630,7 +583,7 @@ \def\place_layout_element_indeed#width#content% {\vbox % to \vsize - {\hsize#1\relax + {\hsize#width\relax \layoutelementparameter\c!before \setlayoutcomponentattribute\currentlayoutelement \hbox \layoutcomponentboxattribute to #width{#content}% @@ -911,7 +864,7 @@ \vbox \layoutcomponentboxattribute to \textheight {\offinterlineskip \freezetextwidth - \hsize\textwidth % local variant of \sethsize + \hsize\textwidth % local variant of \sethsize <<< in columns? \boxmaxdepth\maxdepth \noindent % content can be < \hsize \dopagecontents#2#3}% diff --git a/tex/context/base/phys-dim.mkiv b/tex/context/base/phys-dim.mkiv index a82badb91..3a153281d 100644 --- a/tex/context/base/phys-dim.mkiv +++ b/tex/context/base/phys-dim.mkiv @@ -328,7 +328,11 @@ % only a space when a number is part of the unit -\installcommandhandler \??un {unit} \??un +\installcorenamespace {unit} +\installcorenamespace {unitseparator} +\installcorenamespace {unitspace} + +\installcommandhandler \??unit {unit} \??unit \setupunit [\c!alternative=, % done: text @@ -362,12 +366,12 @@ \unexpanded\def\unitsbackspace {\negthinspace} \unexpanded\def\installunitsseparator#1#2% - {\setvalue{\??un:1:#1}{#2}} + {\setvalue{\??unitseparator#1}{#2}} \unexpanded\def\dounitsseparator {\edef\currentunitsseparator{\unitparameter\c!separator}% - \csname\??un:1:% - \ifcsname\??un:1:\currentunitsseparator\endcsname\currentunitsseparator\else\v!normal\fi + \csname\??unitseparator + \ifcsname\??unitseparator\currentunitsseparator\endcsname\currentunitsseparator\else\v!normal\fi \endcsname} \installunitsseparator\v!normal {\cdot} @@ -377,13 +381,13 @@ \installunitsseparator\v!none {} \unexpanded\def\installunitsspace#1#2% - {\setvalue{\??un:2:#1}{#2}} + {\setvalue{\??unitspace#1}{#2}} \unexpanded\def\dounitsspace {\unskip % weird, why is unskip needed \edef\currentunitsspace{\unitparameter\c!space}% - \csname\??un:2:% - \ifcsname\??un:2:\currentunitsspace\endcsname\currentunitsspace\else\v!normal\fi + \csname\??unitspace + \ifcsname\??unitspace\currentunitsspace\endcsname\currentunitsspace\else\v!normal\fi \endcsname} \installunitsspace\v!normal {\unitsmediumspace} diff --git a/tex/context/base/s-inf-01.mkvi b/tex/context/base/s-inf-01.mkvi index 40aea4eb7..51d3cbac8 100644 --- a/tex/context/base/s-inf-01.mkvi +++ b/tex/context/base/s-inf-01.mkvi @@ -46,7 +46,7 @@ local function collect(list,suffix,n) local path = document.arguments.basepath or file.dirname(resolvers.find_file("context.mkiv"),".") - local pattern = path .. "/*." .. suffix + local pattern = path .. "/*." .. suffix .. "$" -- avoid bla.tex~ local texfiles = dir.glob(pattern) for _, name in ipairs(texfiles) do local base = file.basename(name) diff --git a/tex/context/base/s-inf-03.mkiv b/tex/context/base/s-inf-03.mkiv index 85440f0db..c9cfd54a1 100644 --- a/tex/context/base/s-inf-03.mkiv +++ b/tex/context/base/s-inf-03.mkiv @@ -108,14 +108,11 @@ end backgroundcolor=darkgray, backgroundoffset=2mm] -\setuplayout - [page] - -\startstandardmakeup +\startpagemakeup \vfill \pagereference[global] - \startnarrower[5mm] - \raggedcenter + \startnarrower[10mm] + \setupalign[nothyhenated,middle,broad] \TitlePageFont \setupinterlinespace \getbuffer % luabuffer \par @@ -126,9 +123,7 @@ end \par % \hskip10mm\scale[width=\dimexpr\paperwidth-20mm\relax]{\white \strut Lua infrastructure \emdash\ \currentdate} \vfill -\stopstandardmakeup - -\setuplayout +\stoppagemakeup \setupbackgrounds [page] diff --git a/tex/context/base/scrn-bar.mkvi b/tex/context/base/scrn-bar.mkvi index de67a6ee5..3be46d915 100644 --- a/tex/context/base/scrn-bar.mkvi +++ b/tex/context/base/scrn-bar.mkvi @@ -57,7 +57,9 @@ %D \stoptext %D \stoptyping -\installframedcommandhandler \??ib {interactionbar} \??ib +\installcorenamespace{interactionbar} + +\installframedcommandhandler \??interactionbar {interactionbar} \??interactionbar \unexpanded\def\interactionbar {\dodoubleempty\scrn_bar_direct} @@ -76,7 +78,6 @@ \endgroup \fi} - \newdimen\scrn_bar_width \newdimen\scrn_bar_height \newdimen\scrn_bar_depth diff --git a/tex/context/base/scrn-but.mkvi b/tex/context/base/scrn-but.mkvi index 1a5d0f0f6..dbb66e32e 100644 --- a/tex/context/base/scrn-but.mkvi +++ b/tex/context/base/scrn-but.mkvi @@ -44,13 +44,15 @@ %D %D \showsetup{setupbuttons} -\installframedcommandhandler \??bt {button} \??bt +\installcorenamespace{button} +\installcorenamespace{buttonlocation} + +\installframedcommandhandler \??button {button} \??button \let\setupbuttons\setupbutton \appendtoks \setuevalue\currentbutton{\scrn_button_direct{\currentbutton}}% -% \setevalue{\??bt:\currentbutton\s!parent}{\currentbuttonhash}% framed \to \everydefinebutton \unexpanded\def\scrn_button_direct#tag% @@ -142,13 +144,13 @@ %D The renderers: -\expandafter\let\csname\??bt:\c!location:\v!yes \endcsname\zerocount -\expandafter\let\csname\??bt:\c!location:\v!empty \endcsname\plusone -\expandafter\let\csname\??bt:\c!location:\v!no \endcsname\plustwo -\expandafter\let\csname\??bt:\c!location:\v!none \endcsname\plusthree -\expandafter\let\csname\??bt:\c!location:\v!normal \endcsname\plusone % default -\expandafter\let\csname\??bt:\c!location:\s!default\endcsname\plusone % default -\expandafter\let\csname\??bt:\c!location:\s!empty \endcsname\plusone % default +\expandafter\let\csname\??buttonlocation\v!yes \endcsname\zerocount +\expandafter\let\csname\??buttonlocation\v!empty \endcsname\plusone +\expandafter\let\csname\??buttonlocation\v!no \endcsname\plustwo +\expandafter\let\csname\??buttonlocation\v!none \endcsname\plusthree +\expandafter\let\csname\??buttonlocation\v!normal \endcsname\plusone % default +\expandafter\let\csname\??buttonlocation\s!default\endcsname\plusone % default +\expandafter\let\csname\??buttonlocation\s!empty \endcsname\plusone % default \newconditional\scrn_button_skipped @@ -156,7 +158,7 @@ {\begingroup \attribute\referenceattribute\attributeunsetvalue \global\setfalse\scrn_button_skipped - \chardef\locationboxpagestate\csname\??bt:\c!location:#currentparameter\c!samepage\endcsname % ?? bt: todo + \chardef\locationboxpagestate\csname\??buttonlocation#currentparameter\c!samepage\endcsname % ?? bt: todo \doifreferencefoundelse{#action}\scrn_button_make_yes\scrn_button_make_nop #currentparameter% #inheritedframed% @@ -322,7 +324,13 @@ %D \setupinteractionmenu[right][samepage=none, unknownreference=none] %D \stoptyping -\installframedcommandhandler \??am {interactionmenu} \??am +\installcorenamespace{menu} +\installcorenamespace{menutoks} +\installcorenamespace{menustate} +\installcorenamespace{menupacker} +\installcorenamespace{menualign} + +\installframedcommandhandler \??menu {interactionmenu} \??menu \let\setupinteractionmenus\setupinteractionmenu @@ -349,20 +357,20 @@ \fi\fi} \def\scrn_menu_register#tag#category% - {\ifcsname\??am:t:#category\endcsname \else - \expandafter\newtoks \csname\??am:t:#category\endcsname - \expandafter\setfalse\csname\??am:c:#category\endcsname + {\ifcsname\??menutoks#category\endcsname \else + \expandafter\newtoks \csname\??menutoks#category\endcsname + \expandafter\setfalse\csname\??menustate#category\endcsname \fi - \normalexpanded{\csname\??am:t:#category\endcsname{\the\csname\??am:t:#category\endcsname\scrn_menu_action{#tag}}}} + \normalexpanded{\csname\??menutoks#category\endcsname{\the\csname\??menutoks#category\endcsname\scrn_menu_action{#tag}}}} \def\scrn_menu_actions#category% - {\the\csname\??am:t:#category\endcsname} + {\the\csname\??menutoks#category\endcsname} %D Fill menus: \normalexpanded{\long\def\expandafter\noexpand\csname\e!start\v!interactionmenu\endcsname[#tag]#content\expandafter\noexpand\csname\e!stop\v!interactionmenu\endcsname}% {\def\currentinteractionmenu{#tag}% - \expandafter\settrue\csname\??am:c:\interactionmenuparameter\c!category\endcsname + \expandafter\settrue\csname\??menustate\interactionmenuparameter\c!category\endcsname \setinteractionmenuparameter\c!menu{#content}} \def\resetinteractionmenu[#tag]% @@ -457,14 +465,14 @@ \ht\scrn_menu_box\scrn_menu_asked_height \dp\scrn_menu_box\zeropoint} -\setvalue{scrn_menu_align_\v!right }{\let\scrn_menu_left_align\raggedright} -\setvalue{scrn_menu_align_\v!left }{\let\scrn_menu_left_align\raggedleft} -\setvalue{scrn_menu_align_\v!flushright}{\let\scrn_menu_left_align\raggedleft} -\setvalue{scrn_menu_align_\v!flushleft }{\let\scrn_menu_left_align\raggedright} -\setvalue{scrn_menu_align_\v!middle }{\let\scrn_menu_left_align\raggedcenter} -\setvalue{scrn_menu_align_\v!low }{\let\scrn_menu_top_align\vss\let\scrn_menu_bottom_align\relax} -\setvalue{scrn_menu_align_\v!high }{\let\scrn_menu_top_align\relax\let\scrn_menu_bottom_align\vss} -\setvalue{scrn_menu_align_\v!lohi }{\let\scrn_menu_top_align\vss\let\scrn_menu_bottom_align\vss} +\setvalue{\??menualign\v!right }{\let\scrn_menu_left_align\raggedright} +\setvalue{\??menualign\v!left }{\let\scrn_menu_left_align\raggedleft} +\setvalue{\??menualign\v!flushright}{\let\scrn_menu_left_align\raggedleft} +\setvalue{\??menualign\v!flushleft }{\let\scrn_menu_left_align\raggedright} +\setvalue{\??menualign\v!middle }{\let\scrn_menu_left_align\raggedcenter} +\setvalue{\??menualign\v!low }{\let\scrn_menu_top_align\vss\let\scrn_menu_bottom_align\relax} +\setvalue{\??menualign\v!high }{\let\scrn_menu_top_align\relax\let\scrn_menu_bottom_align\vss} +\setvalue{\??menualign\v!lohi }{\let\scrn_menu_top_align\vss\let\scrn_menu_bottom_align\vss} \let\scrn_menu_left_align \relax \let\scrn_menu_right_align \relax @@ -472,7 +480,7 @@ \let\scrn_menu_bottom_align\relax \def\scrn_menu_set_align - {\csname scrn_menu_align_\interactionmenuparameter\c!itemalign\endcsname} + {\csname\??menualign\interactionmenuparameter\c!itemalign\endcsname} %D Hook into the pagebuilder (as less testing as possible): @@ -484,7 +492,7 @@ \fi} \def\scrn_menu_insert_checked#location% - {\ifconditional\csname\??am:c:#location\endcsname + {\ifconditional\csname\??menustate#location\endcsname \scrn_menu_insert_indeed{#location}% \fi} @@ -497,19 +505,19 @@ \global\scrn_menu_next_distance\zeropoint \let\scrn_menu_action\scrn_menu_package_indeed \the\everysetmenucommands - \csname\??am:\c!menu:\namedinteractionmenuparameter\askedinteractionmenulocation\c!alternative\endcsname + \csname\??menupacker\namedinteractionmenuparameter\askedinteractionmenulocation\c!alternative\endcsname \fi \fi \endgroup} %D This calls: % can be \c!command for vertical/horizontal -\setvalue{\??am:\c!menu:\v!vertical}% all menus +\setvalue{\??menupacker\v!vertical}% all menus {\let\scrn_menu_packager\scrn_menu_packager_vertical \setbox\scrn_menu_box\hbox{\scrn_menu_actions\askedinteractionmenulocation}% \scrn_menu_apply_final \box\scrn_menu_box} -\setvalue{\??am:\c!menu:\v!horizontal}% all menus +\setvalue{\??menupacker\v!horizontal}% all menus {\let\scrn_menu_packager\scrn_menu_packager_horizontal \setbox\scrn_menu_box\vbox{\scrn_menu_actions\askedinteractionmenulocation}% \scrn_menu_apply_final @@ -774,7 +782,6 @@ \edef\currentinteractionmenu{#tag}% \doif{\interactionmenuparameter\c!state}\v!local {\letinteractionmenuparameter\c!state\v!start - % \setinteractionmenuparameter\s!parent{\??am\askedinteractionmenulocation}% nice hack \strictinteractionmenuparameter\c!menu}% \endgroup} @@ -927,10 +934,10 @@ %D Lists: -\setvalue{\@@dodolistelement\v!left }{\def\dosomelistelement{\scrn_menu_list_element\v!left }} -\setvalue{\@@dodolistelement\v!right }{\def\dosomelistelement{\scrn_menu_list_element\v!right }} -\setvalue{\@@dodolistelement\v!top }{\def\dosomelistelement{\scrn_menu_list_element\v!top }} -\setvalue{\@@dodolistelement\v!bottom}{\def\dosomelistelement{\scrn_menu_list_element\v!bottom}} +\setvalue{\??listelement\v!left }{\def\dosomelistelement{\scrn_menu_list_element\v!left }} +\setvalue{\??listelement\v!right }{\def\dosomelistelement{\scrn_menu_list_element\v!right }} +\setvalue{\??listelement\v!top }{\def\dosomelistelement{\scrn_menu_list_element\v!top }} +\setvalue{\??listelement\v!bottom}{\def\dosomelistelement{\scrn_menu_list_element\v!bottom}} \def\scrn_menu_list_element#1#2#3#4#5#6#7% {\startbut[internal(#3)] diff --git a/tex/context/base/scrn-fld.mkvi b/tex/context/base/scrn-fld.mkvi index 00c5ff36e..e5564a70c 100644 --- a/tex/context/base/scrn-fld.mkvi +++ b/tex/context/base/scrn-fld.mkvi @@ -100,17 +100,12 @@ %D When submitting a form, we need to tell the driver module %D that we want \FDF\ or \HTML. -\newtoks\everysetupforms +\installcorenamespace {forms} -\unexpanded\def\setupforms - {\dosingleempty\scrn_forms_setup} - -\def\scrn_forms_setup[#settings] - {\getparameters[\??fr][#settings]% - \the\everysetupforms} +\installdirectcommandhandler \??forms {forms} \appendtoks - \ctxcommand{setformsmethod("\@@frmethod")}% + \ctxcommand{setformsmethod("\formsparameter\c!method")}% \to \everysetupforms \setupforms @@ -145,8 +140,11 @@ %D Now comes the real code: -\installcommandhandler \??fd {fieldcategory} \??fd -\installcommandhandler \??fb {fieldbody} \??fb +\installcorenamespace{fieldcategory} +\installcorenamespace{fieldbody} + +\installcommandhandler \??fieldcategory {fieldcategory} \??fieldcategory +\installcommandhandler \??fieldbody {fieldbody} \??fieldbody \newbox\scrn_field_box_body @@ -163,10 +161,10 @@ \def\scrn_field_check_category {\edef\currentfieldbodycategory{\fieldbodyparameter\c!category}% \ifx\currentfieldbodycategory\empty - \letfieldbodyparameter\s!parent\??fd + \letfieldbodyparameter\s!parent\??fieldcategory %\setevalue{\currentfieldbodyhash\s!parent}{\namedfieldcategoryhash\empty}% to WS: not hash ! \else - \normalexpanded{\setfieldbodyparameter{\s!parent}{\??fd\currentfieldbodycategory}}% + \normalexpanded{\setfieldbodyparameter{\s!parent}{\??fieldcategory\currentfieldbodycategory}}% %\setevalue{\currentfieldbodyhash\s!parent}{\namedfieldcategoryhash\currentfieldbodycategory}% to WS: not hash ! \fi} @@ -212,10 +210,12 @@ {\edef\currentfieldframecolor{\fieldbodyparameter\c!fieldframecolor}% \ifx\currentfieldframecolor\empty\else \getcolorattributevalue\currentfieldframecolor\currentfieldframecolorvalue + % == \edef\currentfieldframecolorvalue{\thecolorattribute\currentfieldframecolor}% \fi \edef\currentfieldbackgroundcolor{\fieldbodyparameter\c!fieldbackgroundcolor}% \ifx\currentfieldbackgroundcolor\empty\else \getcolorattributevalue\currentfieldbackgroundcolor\currentfieldbackgroundcolorvalue + % == \edef\currentfieldbackgroundcolorvalue{\thecolorattribute\currentfieldbackgroundcolor}% \fi \usefieldbodystyleandcolor\c!style\c!color \ctxcommand{insertfield("\currentfieldbody", { @@ -235,6 +235,7 @@ \ifx\currentfieldbackgroundcolor\empty \else backgroundcolor = "\currentfieldbackgroundcolor", backgroundcolorvalue = "\currentfieldbackgroundcolorvalue", + \fi \ifx\currentfieldframecolor\empty \else framecolor = "\currentfieldframecolor", @@ -374,17 +375,21 @@ %D The traditional field command does some labeling and %D boxing: -\installparameterhandler \??wl {fieldlabelframed} -\installparameterhandler \??wc {fieldcontentframed} -\installparameterhandler \??wt {fieldtotalframed} +\installcorenamespace{fieldlabel} +\installcorenamespace{fieldcontent} +\installcorenamespace{fieldtotal} -\installsetuphandler \??wl {fieldlabelframed} -\installsetuphandler \??wc {fieldcontentframed} -\installsetuphandler \??wt {fieldtotalframed} +\installparameterhandler \??fieldlabel {fieldlabelframed} +\installparameterhandler \??fieldcontent {fieldcontentframed} +\installparameterhandler \??fieldtotal {fieldtotalframed} -\installinheritedframed {fieldlabelframed} -\installinheritedframed {fieldcontentframed} -\installinheritedframed {fieldtotalframed} +\installsetuphandler \??fieldlabel {fieldlabelframed} +\installsetuphandler \??fieldcontent {fieldcontentframed} +\installsetuphandler \??fieldtotal {fieldtotalframed} + +\installinheritedframed {fieldlabelframed} +\installinheritedframed {fieldcontentframed} +\installinheritedframed {fieldtotalframed} \unexpanded\def\setupfield {\doquintupleempty\scrn_field_setup_field} \unexpanded\def\setupfields{\doquadrupleempty\scrn_field_setup_fields} @@ -420,25 +425,25 @@ \def\scrn_field_setup_field[#tag][#variant][#totalsettings][#labelsettings][#fieldsettings]% {\iffifthargument - \definefieldcategory[#tag][\s!parent=\??wc#tag,#fieldsettings] - \setupfieldtotalframed [#tag][\s!parent=\??wt,\c!alternative={#variant},#totalsettings]% - \setupfieldlabelframed [#tag][\s!parent=\??wl,#labelsettings]% - \setupfieldcontentframed[#tag][\s!parent=\??wc,#fieldsettings]% + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#fieldsettings] + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant},#totalsettings]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel,#labelsettings]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#fieldsettings]% \else\iffourthargument - \definefieldcategory[#tag][\s!parent=\??wc#tag,#labelsettings] - \setupfieldtotalframed [#tag][\s!parent=\??wt,\c!alternative={#variant},#totalsettings]% - \setupfieldlabelframed [#tag][\s!parent=\??wl]% - \setupfieldcontentframed[#tag][\s!parent=\??wc,#labelsettings]% + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#labelsettings] + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant},#totalsettings]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#labelsettings]% \else\ifthirdargument - \definefieldcategory[#tag][\s!parent=\??wc#tag,#totalsettings] - \setupfieldtotalframed [#tag][\s!parent=\??wt,\c!alternative={#variant}]% - \setupfieldlabelframed [#tag][\s!parent=\??wl]% - \setupfieldcontentframed[#tag][\s!parent=\??wc,#totalsettings]% + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#totalsettings] + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal,\c!alternative={#variant}]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#totalsettings]% \else\ifsecondargument - \definefieldcategory[#tag][\s!parent=\??wc#tag,#variant] - \setupfieldtotalframed [#tag][\s!parent=\??wt]% - \setupfieldlabelframed [#tag][\s!parent=\??wl]% - \setupfieldcontentframed[#tag][\s!parent=\??wc,#variant]% + \definefieldcategory[#tag][\s!parent=\??fieldcontent#tag,#variant] + \setupfieldtotalframed [#tag][\s!parent=\??fieldtotal]% + \setupfieldlabelframed [#tag][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[#tag][\s!parent=\??fieldcontent,#variant]% \fi\fi\fi\fi} \def\scrn_field_setup_fields[#variant][#totalsettings][#labelsettings][#fieldsettings]% @@ -459,10 +464,10 @@ % just to get the chain right for no category: -\definefieldcategory [][\s!parent=\??wc] -% \setupfieldtotalframed [][\s!parent=\??wt] -% \setupfieldlabelframed [][\s!parent=\??wl] -% \setupfieldcontentframed[][\s!parent=\??wc] +\definefieldcategory [][\s!parent=\??fieldcontent] +%setupfieldtotalframed [][\s!parent=\??fieldtotal] +%setupfieldlabelframed [][\s!parent=\??fieldlabel] +%setupfieldcontentframed[][\s!parent=\??fieldcontent] % no longer supported: @@ -490,9 +495,9 @@ \let\currentfieldlabel\currentfieldbody \fi \ifx\currentfieldcategory\empty - \setupfieldtotalframed [\currentfieldbody][\s!parent=\??wt]% - \setupfieldlabelframed [\currentfieldbody][\s!parent=\??wl]% - \setupfieldcontentframed[\currentfieldbody][\s!parent=\??wc]% + \setupfieldtotalframed [\currentfieldbody][\s!parent=\??fieldtotal]% + \setupfieldlabelframed [\currentfieldbody][\s!parent=\??fieldlabel]% + \setupfieldcontentframed[\currentfieldbody][\s!parent=\??fieldcontent]% \definefieldcategory [\currentfieldbody]% \setupfieldbody [\currentfieldbody][\c!category=\currentfieldbody]% \let\currentfieldcategory\currentfieldbody @@ -637,7 +642,9 @@ \newbox \scrn_tooltip_box_text \newcount\scrn_tooltip_n -\installframedcommandhandler \??wh {tooltip} \??wh +\installcorenamespace{tooltip} + +\installframedcommandhandler \??tooltip {tooltip} \??tooltip \setuptooltip [\c!location=\v!right, @@ -769,7 +776,7 @@ {\iflocation \dontleavehmode \begingroup - \setupfieldcategory[\c!start=1,#settings]% was just \??fd + \setupfieldcategory[\c!start=1,#settings]% was just \??fieldcategory \scrn_field_load_scripts \definecollector [fieldstack]% diff --git a/tex/context/base/scrn-hlp.mkvi b/tex/context/base/scrn-hlp.mkvi index b1a8a10d4..a6aa5b9f1 100644 --- a/tex/context/base/scrn-hlp.mkvi +++ b/tex/context/base/scrn-hlp.mkvi @@ -60,7 +60,9 @@ \definesystemattribute[help][public] -\installframedcommandhandler \??wp {help} \??wp +\installcorenamespace{popuphelp} + +\installframedcommandhandler \??popuphelp {help} \??popuphelp \setuphelp [\c!frame=\v!off, @@ -104,7 +106,7 @@ \def\scrn_help_start_indeed[#reference]% {\edef\currenthelpreference{#reference}% - \dostartbuffer[\currenthelp][\e!start\currenthelp][\e!stop\currenthelp]} + \grabbufferdatadirect\currenthelp{\e!start\currenthelp}{\e!stop\currenthelp}} \unexpanded\def\scrn_help_stop {\iflocation diff --git a/tex/context/base/scrn-ini.mkvi b/tex/context/base/scrn-ini.mkvi index a5a50cddd..561f2e572 100644 --- a/tex/context/base/scrn-ini.mkvi +++ b/tex/context/base/scrn-ini.mkvi @@ -27,7 +27,9 @@ %D %D \showsetup{setupinteraction} -\installswitchcommandhandler \??ia {interaction} \??ia +\installcorenamespace{interaction} + +\installswitchcommandhandler \??interaction {interaction} \??interaction \let\currentinteraction\empty diff --git a/tex/context/base/scrn-pag.mkvi b/tex/context/base/scrn-pag.mkvi index ca5305304..fc6215def 100644 --- a/tex/context/base/scrn-pag.mkvi +++ b/tex/context/base/scrn-pag.mkvi @@ -19,8 +19,10 @@ \unprotect -\installparameterhandler \??sc {interactionscreen} -\installsetuphandler \??sc {interactionscreen} +\installcorenamespace{interactionscreen} + +\installparameterhandler \??interactionscreen {interactionscreen} +\installsetuphandler \??interactionscreen {interactionscreen} \newdimen\canvaswidth \newdimen\canvasheight diff --git a/tex/context/base/scrn-wid.mkvi b/tex/context/base/scrn-wid.mkvi index 09d42673b..26b06f759 100644 --- a/tex/context/base/scrn-wid.mkvi +++ b/tex/context/base/scrn-wid.mkvi @@ -64,7 +64,10 @@ \newbox\scrn_attachment_box_link \newbox\scrn_attachment_box_symbol -\installcommandhandler\??at{attachment}\??at +\installcorenamespace{attachment} +\installcorenamespace{attachmentlocation} + +\installcommandhandler \??attachment {attachment} \??attachment \let\setupattachments\setupattachment % convenience and compatibility @@ -94,7 +97,7 @@ {\ifsecondargument \begingroup \def\currentattachment{_}% - \setupcurrentattachment[#settings,\s!parent=\??at]% + \setupcurrentattachment[#settings,\s!parent=\??attachment]% \ctxcommand{registerattachment{ tag = "#tag", registered = "#tag", @@ -160,7 +163,7 @@ {\doifassignmentelse{#registered} {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment,#registered]\egroup}}% {\def\scrn_attachment_stop{\scrn_attachment_inject[#registered][\c!buffer=\v!attachment,#settings]\egroup}}}% - \dostartbuffer[\v!attachment][\e!start\currentattachment][\e!stop\currentattachment]} + \grabbufferdatadirect\v!attachment{\e!start\currentattachment}{\e!stop\currentattachment}} \def\scrn_attachment_start_ignore {\expandafter\gobbleuntil\csname\e!stop\currentattachment\endcsname} @@ -194,7 +197,7 @@ height = \number\dimexpr\currentattachmentheight\relax, depth = \number\dimexpr\currentattachmentdepth \relax, color = "\attachmentparameter\c!color", - colormodel = \number\currentcolormodel, + colormodel = \number\attribute\colormodelattribute, colorvalue = \thecolorattribute{\attachmentparameter\c!color}, transparencyvalue = \thetransparencyattribute{\attachmentparameter\c!color}, symbol = "\currentattachmentsymbol", @@ -222,16 +225,16 @@ \def\scrn_attachment_place {\executeifdefined - {\??at:\c!location:\attachmentparameter\c!location}\hbox + {\??attachmentlocation\attachmentparameter\c!location}\hbox {\box\scrn_attachment_box_link}} -\setvalue{\??at:\c!location:\v!inmargin }{\inmargin } -\setvalue{\??at:\c!location:\v!leftedge }{\inleftedge } -\setvalue{\??at:\c!location:\v!rightedge }{\inrightedge } -\setvalue{\??at:\c!location:\v!leftmargin }{\inleftmargin } -\setvalue{\??at:\c!location:\v!rightmargin}{\inrightmargin} -\setvalue{\??at:\c!location:\v!high }{\high} -\setvalue{\??at:\c!location:\v!none }{\scrn_attachment_collect} +\setvalue{\??attachmentlocation\v!inmargin }{\inmargin } +\setvalue{\??attachmentlocation\v!leftedge }{\inleftedge } +\setvalue{\??attachmentlocation\v!rightedge }{\inrightedge } +\setvalue{\??attachmentlocation\v!leftmargin }{\inleftmargin } +\setvalue{\??attachmentlocation\v!rightmargin}{\inrightmargin} +\setvalue{\??attachmentlocation\v!high }{\high} +\setvalue{\??attachmentlocation\v!none }{\scrn_attachment_collect} \def\scrn_attachment_collect#content% {\global\setbox\scrn_attachment_box_collect\hbox\bgroup @@ -348,7 +351,10 @@ % % test -\installcommandhandler \??cc {comment} \??cc +\installcorenamespace{comment} +\installcorenamespace{commentlocation} + +\installcommandhandler \??comment {comment} \??comment \newbox\scrn_comment_box_collect \newbox\scrn_comment_box_rendering @@ -416,7 +422,7 @@ {\setupcurrentcomment[\currentcomment][#title]} {\setupcurrentcomment[\currentcomment][\c!title=#title,#settings]}% \def\scrn_comment_stop{\scrn_comment_inject\egroup}% - \dostartbuffer[\v!comment][\e!start\currentcomment][\e!stop\currentcomment]} + \grabbufferdatadirect\v!comment{\e!start\currentcomment}{\e!stop\currentcomment}} \def\scrn_comment_start_ignore {\expandafter\gobbleuntil\csname\e!stop\currentcomment\endcsname} @@ -457,7 +463,7 @@ depth = \number\dimexpr\currentcommentdepth, nx = \commentparameter\c!nx, ny = \commentparameter\c!ny, - colormodel = \number\currentcolormodel, + colormodel = \number\attribute\colormodelattribute, colorvalue = \thecolorattribute{\commentparameter\c!color}, transparencyvalue = \thetransparencyattribute{\commentparameter\c!color}, option = "\commentparameter\c!option", % todo @@ -477,16 +483,16 @@ \def\scrn_comment_place {\executeifdefined - {\??cc:\c!location:\commentparameter\c!location}\hbox + {\??commentlocation\commentparameter\c!location}\hbox {\hbox{\box\scrn_comment_box_link}}} -\setvalue{\??cc:\c!location:\v!inmargin }{\inmargin } -\setvalue{\??cc:\c!location:\v!leftedge }{\inleftedge } -\setvalue{\??cc:\c!location:\v!rightedge }{\inrightedge } -\setvalue{\??cc:\c!location:\v!leftmargin }{\inleftmargin } -\setvalue{\??cc:\c!location:\v!rightmargin}{\inrightmargin} -\setvalue{\??cc:\c!location:\v!high }{\high} -\setvalue{\??cc:\c!location:\v!none }{\scrn_comment_collect} +\setvalue{\??commentlocation\v!inmargin }{\inmargin } +\setvalue{\??commentlocation\v!leftedge }{\inleftedge } +\setvalue{\??commentlocation\v!rightedge }{\inrightedge } +\setvalue{\??commentlocation\v!leftmargin }{\inleftmargin } +\setvalue{\??commentlocation\v!rightmargin}{\inrightmargin} +\setvalue{\??commentlocation\v!high }{\high} +\setvalue{\??commentlocation\v!none }{\scrn_comment_collect} \def\scrn_comment_collect#content% {\global\setbox\scrn_comment_box_collect\hbox\bgroup diff --git a/tex/context/base/scrp-ini.mkiv b/tex/context/base/scrp-ini.mkiv index d0ee8770d..1c2b1dbaf 100644 --- a/tex/context/base/scrp-ini.mkiv +++ b/tex/context/base/scrp-ini.mkiv @@ -26,7 +26,9 @@ \unprotect -\installcommandhandler\??ls{script}\??ls +\installcorenamespace{script} + +\installcommandhandler \??script {script} \??script % presets are global and are currently defined in lua diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 371701a01..16fdddea6 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -15,18 +15,31 @@ \unprotect +%D The \type {new} and \type {old} methods are gone as we now have \type +%D {flush*} variants. Starting at the last day of 2011 both methods are +%D merged into one and caching has been added, which makes switching +%D twice as fast. + \registerctxluafile{spac-ali}{1.001} \definesystemattribute[realign] [public] % might be combined with the next one \definesystemattribute[alignstate][public] % will make a single attributes for several states +\appendtoks + \attribute\realignattribute \attributeunsetvalue + \attribute\alignstateattribute\attributeunsetvalue +\to \everyforgetall + \unexpanded\def\resetrealignsignal{\attribute\realignattribute\attributeunsetvalue} \unexpanded\def\signalinnerrealign{\ctxcommand{setrealign(2)}} \unexpanded\def\signalouterrealign{\ctxcommand{setrealign(1)}} -\appendtoks - \resetrealignsignal -\to \everyforgetall +\installcorenamespace{aligncommand} +\installcorenamespace{alignhorizontal} +\installcorenamespace{alignvertical} +\installcorenamespace{alignmentcache} + +\newtoks\everyresetalign % todo % We will not use bodydir and pagedir so we disable them. That way we get % normal hyperlink support. @@ -122,344 +135,609 @@ display:\ifconditional\displaylefttoright l2r\else r2l\fi\space inline:\ifconditional \inlinelefttoright l2r\else r2l\fi\space ]\endgroup} - -\def\dodefinehbox[#1][#2]% - {\setvalue{hbox#1}##1{\hbox to #2{\begstrut##1\endstrut\hss}}} -\unexpanded\def\definehbox - {\dodoubleargument\dodefinehbox} +% Tolerance and hyphenation -% To be redone: +\newcount\hyphenminoffset -\unexpanded\def\ibox#1#2#3% - {\vbox\bgroup - \forgetall - \let\\=\endgraf - \ifdoublesided\signalinnerrealign\fi - \doifrightpageelse\raggedright\raggedleft - \let\next} +\ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi -\unexpanded\def\obox#1#2#3% - {\vbox\bgroup - \forgetall - \let\\=\endgraf - \ifdoublesided\signalouterrealign\fi - \doifrightpageelse\raggedleft\raggedright - \let\next} +\unexpanded\def\lesshyphens + {\advance\hyphenminoffset\plusone + \sethyphenationvariables} -\def\@@ragged@@command{@@ragged@@c} -\def\@@ragged@@hbox {@@ragged@@h} -\def\@@ragged@@vbox {@@ragged@@v} +\unexpanded\def\morehyphens + {\ifcase\hyphenminoffset \else + \advance\hyphenminoffset\minusone + \fi + \sethyphenationvariables} -\def\dosetraggedvbox#1% can be more keys - {\let\raggedbox\vbox - \processcommacommand[#1]\dodosetraggedvbox} -\def\dosetraggedhbox#1% can be more keys - {\let\raggedbox\hbox - \processcommacommand[#1]\dodosetraggedhbox} +\unexpanded\def\nohyphens % % % % % not clever, we still hyphenate but supress application + {\ifx\dohyphens\relax + \edef\dohyphens + {\hyphenpenalty \the\hyphenpenalty + \exhyphenpenalty\the\exhyphenpenalty + \relax}% + \fi + \hyphenpenalty\plustenthousand + \exhyphenpenalty\plustenthousand} -\def\dodosetraggedvbox#1% - {\ifcsname\@@ragged@@vbox#1\endcsname - \csname\@@ragged@@vbox#1\endcsname - \quitcommalist - \fi} +\let\dohyphens\relax -\def\dodosetraggedhbox#1% - {\ifcsname\@@ragged@@hbox#1\endcsname - \csname\@@ragged@@hbox#1\endcsname - \quitcommalist - \fi} +\newcount\c_spacing_minimum_tolerance \c_spacing_minimum_tolerance = 1500 +\newcount\c_spacing_normal_tolerance \c_spacing_normal_tolerance = 3000 +\newcount\c_spacing_extreme_tolerance \c_spacing_extreme_tolerance = 4500 -\setvalue{\@@ragged@@vbox\v!left }{\let\raggedbox\lbox} -\setvalue{\@@ragged@@vbox\v!right }{\let\raggedbox\rbox} -\setvalue{\@@ragged@@vbox\v!middle }{\let\raggedbox\cbox} -\setvalue{\@@ragged@@vbox\v!inner }{\let\raggedbox\ibox} -\setvalue{\@@ragged@@vbox\v!outer }{\let\raggedbox\obox} -\setvalue{\@@ragged@@vbox\v!flushleft }{\let\raggedbox\rbox} -\setvalue{\@@ragged@@vbox\v!flushright}{\let\raggedbox\lbox} -\setvalue{\@@ragged@@vbox\v!center }{\let\raggedbox\cbox} -\setvalue{\@@ragged@@vbox\v!no }{\def\raggedbox{\vbox\bgroup\raggedright\let\next=}]} +\def\spacing_raggedness_left {\plustwo\bodyfontsize} +\def\spacing_raggedness_right {\plustwo\bodyfontsize} +\def\spacing_raggedness_middle{\plussix\bodyfontsize} % overloaded below -\setvalue{\@@ragged@@hbox\v!left }{\def\raggedbox{\doalignedline\v!left }} -\setvalue{\@@ragged@@hbox\v!right }{\def\raggedbox{\doalignedline\v!right }} -\setvalue{\@@ragged@@hbox\v!middle }{\def\raggedbox{\doalignedline\v!middle}} -\setvalue{\@@ragged@@hbox\v!inner }{\def\raggedbox{\doalignedline\v!inner }} -\setvalue{\@@ragged@@hbox\v!outer }{\def\raggedbox{\doalignedline\v!outer }} -\setvalue{\@@ragged@@hbox\v!flushleft }{\def\raggedbox{\doalignedline\v!right }} -\setvalue{\@@ragged@@hbox\v!flushright}{\def\raggedbox{\doalignedline\v!left }} -\setvalue{\@@ragged@@hbox\v!center }{\def\raggedbox{\doalignedline\v!middle}} +% oeps, hsize can be 0pt in which case we get a strange division +% was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} -\newtoks\everyraggedcommand +\def\spacing_raggedness_middle{\ifdim\hsize=\zeropoint\plussix\bodyfontsize\else.5\hsize\fi} -\def\raggedcommand{\the\everyraggedcommand} +\unexpanded\def\setraggedness#1% tricky .. we keep the global tolerance otherwise ... to be reconsidered + {\ifnum\tolerance<\c_spacing_minimum_tolerance + \tolerance\c_spacing_minimum_tolerance % small values have unwanted side effects + \else + % todo: take set value or none .. better done elsewhere (200 is normal) + \fi + \ifx\dohyphens\relax % was 2.5 in old implementation using scratch registers + \hyphenpenalty\dimexpr2.8\hsize/\dimexpr#1\relax\relax % 50 in raggedright/raggedleft + \fi} -% slow, we can do this in lua ... some day +\unexpanded\def\ragged_command_tolerant + {\tolerance\c_spacing_normal_tolerance} -\let\raggedbox\relax +\unexpanded\def\ragged_command_very_tolerant + {\tolerance\c_spacing_extreme_tolerance} -% pretty slow (will be sped up) +\unexpanded\def\ragged_command_stretch + {\emergencystretch\bodyfontsize} -\newconstant\ragged_command_h_align_state -\newconstant\ragged_command_v_align_state -\newconstant\ragged_command_broad_state +% Vertical -\ifdefined\raggedonelinerstate \else \newconditional\raggedonelinerstate \fi % public +\newconstant\c_spacing_state_vertical -% \unexpanded\def\dosetraggedcommand#1% beware: #1=empty is ignored, keep that! assumes \forgetall -% {\edef\askedraggedalign{#1}% -% \ifx\askedraggedalign\empty -% \nonosetraggedcommand -% \else -% \dodosetraggedcommand -% \fi} -% -% \def\nonosetraggedcommand -% {\everyraggedcommand{\resetrealignsignal}% \emptytoks maybe only when #1 <> empty -% \let\raggedtopcommand\empty -% \let\raggedbottomcommand\empty -% \let\raggedbox\relax -% \setfalse\raggedonelinerstate} -% -% \def\dodosetraggedcommand % beware: #1=empty is ignored, keep that! -% {\everyraggedcommand{\resetrealignsignal}% \emptytoks maybe only when #1 <> empty -% \let\raggedtopcommand\empty -% \let\raggedbottomcommand\empty -% \let\raggedbox\relax -% \setfalse\raggedonelinerstate -% \ifcsname\@@ragged@@command\askedraggedalign\endcsname % fast for one keyword and special table case -% \!!doneafalse -% \!!donebfalse -% \!!donectrue -% \csname\@@ragged@@command\askedraggedalign\endcsname -% \else -% \doifinsetelse\v!broad\askedraggedalign\!!doneatrue\!!doneafalse -% \doifinsetelse\v!wide \askedraggedalign\!!donebtrue\!!donebfalse -% \!!donectrue -% \rawprocesscommacommand[\askedraggedalign]\dododosetraggedcommand -% \fi} +\unexpanded\def\spacing_vertical_none + {\let\raggedtopcommand \relax + \let\raggedbottomcommand\relax} -% happens a lot: {\flushleft,broad,high} \veryraggedright\let\raggedbottomcommand\vfilll +\unexpanded\def\spacing_vertical_lohi + {\let\raggedtopcommand \vfilll + \let\raggedbottomcommand\vfilll} -\unexpanded\def\dosetraggedcommand#1% beware: #1=empty is ignored, keep that! assumes \forgetall - {\edef\askedraggedalign{#1}% - \ifx\askedraggedalign\empty - \nonosetraggedcommand - \else - \dodosetraggedcommand +\unexpanded\def\spacing_vertical_low + {\let\raggedtopcommand \vfilll + \let\raggedbottomcommand\relax} + +\unexpanded\def\spacing_vertical_high + {\let\raggedtopcommand \relax + \let\raggedbottomcommand\vfilll} + +\def\spacing_flush_vertical + {\ifcase\c_spacing_state_vertical + \spacing_vertical_none + \or + \spacing_vertical_lohi + \or + \spacing_vertical_low + \or + \spacing_vertical_high \fi} -\def\dodosetraggedcommand - {\let\raggedtopcommand\empty - \let\raggedbottomcommand\empty - \let\raggedbox\relax - \setfalse\raggedonelinerstate - \everyraggedcommand\emptytoks - \ragged_command_broad_state \zerocount - \ragged_command_h_align_state\zerocount - \ragged_command_v_align_state\zerocount - \ifcsname\@@ragged@@command\askedraggedalign\endcsname - \csname\@@ragged@@command\askedraggedalign\endcsname - \else - \rawprocesscommacommand[\askedraggedalign]\dododosetraggedcommand - \fi - % probably also ok: \normalexpanded{\everyraggedcommand{\resetrealignsignal\the\everyraggedcommand\ragged_command_flush_align}}} - \normalexpanded{\everyraggedcommand\expandafter{\expandafter\resetrealignsignal\the\everyraggedcommand\ragged_command_flush_align}}} +% Horizontal + +\ifdefined\raggedonelinerstate \else + \newconditional\raggedonelinerstate % public +\fi -\def\nonosetraggedcommand - {\let\raggedtopcommand\empty - \let\raggedbottomcommand\empty - \let\raggedbox\relax - \setfalse\raggedonelinerstate - \everyraggedcommand{\resetrealignsignal}} +\newconstant\raggedstatus % public -\def\dododosetraggedcommand#1% - {\csname\@@ragged@@command#1\endcsname} +\newconstant\c_spacing_state_horizontal +\newconstant\c_spacing_state_broad -\unexpanded\def\ragged_command_tolerant {\tolerance3000\relax} -\unexpanded\def\ragged_command_very_tolerant{\tolerance4500\relax} -\unexpanded\def\ragged_command_stretch {\emergencystretch\bodyfontsize} +\def\spacing_ragged_fill_amount {\plusone fil} +\def\spacing_ragged_fill_amount_negative {\minusone fil} +\def\spacing_ragged_fill_amount_double {\plustwo fil} +\def\spacing_ragged_fill_amount_space {\plustwo fil} % can be added to xspace if we have a key +\def\spacing_ragged_fill_amount_half {.5fil} +\let\spacing_ragged_space_amount \interwordspace +\def\spacing_ragged_space_amount_x {.5\emwidth} -\def\ragged_command_flush_align - {\ifcase\ragged_command_h_align_state +\newskip\s_zero_plus_one_fil \s_zero_plus_one_fil = 0pt plus 1fil +\newskip\s_zero_plus_zero \s_zero_plus_zero = 0pt plus 0pt + +% \!!plus ... slower than inline + +\unexpanded\def\spacing_horizontal_none + {\raggedstatus\zerocount + \attribute\alignstateattribute\attributeunsetvalue + \leftskip \plusone\leftskip + \rightskip \plusone\rightskip + \spaceskip \zeropoint + \xspaceskip \zeropoint + \parfillskip\s_zero_plus_one_fil} % new + +\unexpanded\def\spacing_horizontal_left + {\setraggedness\spacing_raggedness_left + \raggedstatus\plusone + \attribute\alignstateattribute\plusone + \leftskip \plusone\leftskip \!!plus\spacing_raggedness_left + \rightskip \plusone\rightskip\!!plus\zeropoint + \spaceskip \spacing_ragged_space_amount + \xspaceskip \spacing_ragged_space_amount_x + \parfillskip\s_zero_plus_zero + \parindent \zeropoint + \relax} + +\unexpanded\def\spacing_horizontal_center + {\setraggedness\spacing_raggedness_middle + \raggedstatus\plustwo + \attribute\alignstateattribute\plustwo + \leftskip \plusone\leftskip \!!plus\spacing_raggedness_middle + \rightskip \plusone\rightskip\!!plus\spacing_raggedness_middle + \spaceskip \spacing_ragged_space_amount + \xspaceskip \spacing_ragged_space_amount_x + \parfillskip\s_zero_plus_zero + \parindent \zeropoint + \relax} + +\unexpanded\def\spacing_horizontal_right + {\setraggedness\spacing_raggedness_right + \raggedstatus\plusthree + \attribute\alignstateattribute\plusthree + \leftskip \plusone\leftskip \!!plus\zeropoint + \rightskip \plusone\rightskip\!!plus\spacing_raggedness_right + \spaceskip \spacing_ragged_space_amount + \xspaceskip \spacing_ragged_space_amount_x + \parfillskip\s_zero_plus_one_fil + %\parindent \parindent + \relax} + +\unexpanded\def\spacing_horizontal_very_left + {\raggedstatus\plusone + \attribute\alignstateattribute\plusone + \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount + \rightskip \plusone\rightskip\!!plus\zeropoint + \spaceskip \spacing_ragged_space_amount + \xspaceskip \spacing_ragged_space_amount_x + \parfillskip\s_zero_plus_zero + \parindent \zeropoint + \relax} + +\unexpanded\def\spacing_horizontal_very_center + {\raggedstatus\plustwo + \attribute\alignstateattribute\plustwo + \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount + \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount + \spaceskip \spacing_ragged_space_amount + \xspaceskip \spacing_ragged_space_amount_x + \parfillskip\s_zero_plus_zero + \parindent \zeropoint + \relax} + +\unexpanded\def\spacing_horizontal_very_right + {\raggedstatus\plusthree + \attribute\alignstateattribute\plusthree + \leftskip \plusone\leftskip \!!plus\zeropoint + \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount + \spaceskip \spacing_ragged_space_amount + \xspaceskip \spacing_ragged_space_amount_x + \parfillskip\s_zero_plus_zero + %\parindent \parindent + \relax} + +\unexpanded\def\spacing_horizontal_wide_center + {\setraggedness\spacing_raggedness_middle + \raggedstatus\plustwo + \attribute\alignstateattribute\plustwo + \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount_half + \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount_half + \spaceskip \spacing_ragged_space_amount + \xspaceskip \spacing_ragged_space_amount_x + \parfillskip\s_zero_plus_zero + \parindent \zeropoint + \relax} + +\unexpanded\def\spacing_horizontal_centered_last_line + {\raggedstatus\zerocount + \attribute\alignstateattribute\attributeunsetvalue + \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount\relax + \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount_negative\relax + \spaceskip \zeropoint\relax + \xspaceskip \zeropoint\relax + \parfillskip\zeropoint\!!plus\spacing_ragged_fill_amount_double\relax + \parindent \zeropoint + \relax} + +\unexpanded\def\spacing_horizontal_right_tt % a plain command + {\tttf % brrr + \raggedstatus\plusthree + \attribute\alignstateattribute\plusthree + \leftskip \plusone\leftskip \!!plus\zeropoint\relax + \rightskip \plusone\rightskip\!!plus\spacing_raggedness_right\relax + \spaceskip \zeropoint\relax + \xspaceskip \zeropoint\relax + \parfillskip\s_zero_plus_zero + %\parindent \parindent + \relax} + +\unexpanded\def\spacing_horizontal_extra + {\xspaceskip\zeropoint\!!plus\spacing_ragged_fill_amount_space\relax} + +\def\spacing_flush_horizontal + {\ifcase\c_spacing_state_horizontal % 0 - \notragged + \spacing_horizontal_none \or % 1 center - \ifcase\ragged_command_broad_state - \raggedcenter + \ifcase\c_spacing_state_broad + \spacing_horizontal_center \or - \veryraggedcenter + \spacing_horizontal_very_center \or - \raggedwidecenter + \spacing_horizontal_wide_center \fi \or % 2 flush left - \ifcase\ragged_command_broad_state - \raggedright + \ifcase\c_spacing_state_broad + \spacing_horizontal_right \else - \veryraggedright + \spacing_horizontal_very_right \fi \or % 3 flush right - \ifcase\ragged_command_broad_state - \raggedleft + \ifcase\c_spacing_state_broad + \spacing_horizontal_left \else - \veryraggedleft + \spacing_horizontal_very_left \fi \or % 4 inner \ifdoublesided \signalinnerrealign \fi - \rightorleftpageaction\raggedright\raggedleft + \rightorleftpageaction\spacing_horizontal_right\spacing_horizontal_left \or % 5 outer \ifdoublesided \signalouterrealign \fi - \rightorleftpageaction\raggedleft\raggedright + \rightorleftpageaction\c_spacing_state_horizontal_left\spacing_horizontal_right \or % 6 oneliner - \ifcase\ragged_command_broad_state - \raggedright + \ifcase\c_spacing_state_broad + \spacing_horizontal_right \else - \veryraggedright + \spacing_horizontal_very_right \fi \parfillskip\zeropoint \or % 7 centered last line - \centeredlastline + \spacing_horizontal_centered_last_line \fi} -\setvalue{\@@ragged@@command\v!broad }{\ragged_command_broad_state\plusone} % was donea -\setvalue{\@@ragged@@command\v!wide }{\ragged_command_broad_state\plustwo} % was doneb - -\setvalue{\@@ragged@@command\v!hanging }{\everyraggedcommand\expandafter{\the\everyraggedcommand\enableprotruding}} -\setvalue{\@@ragged@@command\v!nothanging }{\everyraggedcommand\expandafter{\the\everyraggedcommand\disableprotruding}} -\setvalue{\@@ragged@@command\v!hz }{\everyraggedcommand\expandafter{\the\everyraggedcommand\enableadjusting}} -\setvalue{\@@ragged@@command\v!nohz }{\everyraggedcommand\expandafter{\the\everyraggedcommand\disableadjusting}} -%setvalue{\@@ragged@@command\v!spacing }{\everyraggedcommand\expandafter{\the\everyraggedcommand\enablespacehandling\enablekernhandling}} -%setvalue{\@@ragged@@command\v!nospacing }{\everyraggedcommand\expandafter{\the\everyraggedcommand\disablespacehandling\disablekernhandling}} -\setvalue{\@@ragged@@command\v!hyphenated }{\everyraggedcommand\expandafter{\the\everyraggedcommand\dohyphens}} -\setvalue{\@@ragged@@command\v!nothyphenated }{\everyraggedcommand\expandafter{\the\everyraggedcommand\nohyphens}} - -\setvalue{\@@ragged@@command\v!tolerant }{\everyraggedcommand\expandafter{\the\everyraggedcommand\ragged_command_tolerant}} -\setvalue{\@@ragged@@command\v!verytolerant }{\everyraggedcommand\expandafter{\the\everyraggedcommand\ragged_command_very_tolerant}} -\setvalue{\@@ragged@@command\v!stretch }{\everyraggedcommand\expandafter{\the\everyraggedcommand\ragged_command_stretch}} - -\setvalue{\@@ragged@@command\v!flushright }{\ragged_command_h_align_state\plusthree} -\setvalue{\@@ragged@@command\v!flushleft }{\ragged_command_h_align_state\plustwo} -\setvalue{\@@ragged@@command\v!middle }{\ragged_command_h_align_state\plusone} -\setvalue{\@@ragged@@command\v!no }{\ragged_command_h_align_state\plustwo} -\setvalue{\@@ragged@@command\v!yes }{\ragged_command_h_align_state\zerocount} -\setvalue{\@@ragged@@command\v!normal }{\ragged_command_h_align_state\zerocount} -\setvalue{\@@ragged@@command\v!inner }{\ragged_command_h_align_state\plusfour} -\setvalue{\@@ragged@@command\v!outer }{\ragged_command_h_align_state\plusfive} -\setvalue{\@@ragged@@command\v!right }{\ragged_command_h_align_state\plustwo} -\setvalue{\@@ragged@@command\v!left }{\ragged_command_h_align_state\plusthree} -\setvalue{\@@ragged@@command\v!center }{\ragged_command_h_align_state\plusone} -\setvalue{\@@ragged@@command\v!disable }{\ragged_command_h_align_state\plussix} -\setvalue{\@@ragged@@command\v!last }{\ragged_command_h_align_state\plusseven} - -\setvalue{\@@ragged@@command\v!line }{\settrue\raggedonelinerstate} - -\setvalue{\@@ragged@@command\v!high }{\let\raggedbottomcommand\vfilll} % and since we lack a -\setvalue{\@@ragged@@command\v!low }{\let\raggedtopcommand \vfilll} % proper keyword, but -\setvalue{\@@ragged@@command\v!lohi }{\let\raggedbottomcommand\vfilll\let\raggedtopcommand\vfilll} % we do support the ugly laho (lohi) - -\setvalue{\@@ragged@@command\v!lesshyphenation}{\everyraggedcommand\expandafter{\the\everyraggedcommand\lesshyphens}} -\setvalue{\@@ragged@@command\v!morehyphenation}{\everyraggedcommand\expandafter{\the\everyraggedcommand\morehyphens}} - -\setvalue{\@@ragged@@command\v!lefttoright }{\everyraggedcommand\expandafter{\the\everyraggedcommand\lefttoright}} -\setvalue{\@@ragged@@command\v!righttoleft }{\everyraggedcommand\expandafter{\the\everyraggedcommand\righttoleft}} -\setvalue{\@@ragged@@command l2r}{\everyraggedcommand\expandafter{\the\everyraggedcommand\lefttoright}} -\setvalue{\@@ragged@@command r2l}{\everyraggedcommand\expandafter{\the\everyraggedcommand\righttoleft}} - -\setvalue{\@@ragged@@command\v!table }{\let\raggedbottomcommand\vfilll - \ragged_command_broad_state\plusone - \ragged_command_h_align_state\plustwo} - -% compare: -% -% \framed[width=4cm,align=no] {\hfil xxx} -% \framed[width=4cm,align=disable]{\hfil xxx} +% Page spacing: -% More alignments: +\newconstant\c_spacing_state_page -% \hyphenpenalty = ( 2.5 * \hsize ) / \raggedness -% \tolerance >= 1500 % was 200 -% \raggedness = 2 .. 6\bodyfontsize +\def\bottomalignlimit{\plusthree\lineheight} -\newconstant\raggedstatus % normal left center right +\newconstant\bottomraggednessmode % 0=ragged 1=normal/align 2=baseline -% \unexpanded\def\setalignstateattribute % unexpanded ! -% {\attribute\alignstateattribute\ifcase\raggedstatus\attributeunsetvalue\else\raggedstatus\fi} +\unexpanded\def\raggedbottom + {\bottomraggednessmode\zerocount + \settopskip} -\def\leftraggedness {2\bodyfontsize} -\def\rightraggedness {2\bodyfontsize} -\def\middleraggedness {6\bodyfontsize} +\unexpanded\def\alignbottom + {\bottomraggednessmode\plusone + \settopskip} -\def\middleraggedness {.5\hsize} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} +\unexpanded\def\baselinebottom + {\bottomraggednessmode\plustwo + \settopskip} -% oeps, hsize can be 0pt in which case we get a strange division +\let\normalbottom\alignbottom % downward compatible -\def\middleraggedness {\ifdim\hsize=\zeropoint6\bodyfontsize\else.5\hsize\fi} % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} +\unexpanded\def\setbottomalignmode#1% + {\bottomraggednessmode#1% + \settopskip} -%D More hyphenation control, will be combined with align -%D setup. +\def\spacing_flush_page + {\ifcase\c_spacing_state_page + % keep state + \or + \raggedbottom + \or + \alignbottom + \or + \baselinebottom + \fi} -\unexpanded\def\nohyphens % % % % % not clever, we still hyphenate but supress application - {\ifx\dohyphens\relax - \edef\dohyphens - {\hyphenpenalty\the\hyphenpenalty - \exhyphenpenalty\the\exhyphenpenalty\relax}% +% Directions + +\newconstant\c_spacing_state_direction + +\def\spacing_flush_direction + {\ifcase\c_spacing_state_direction + % keep state + \or + \lefttoright + \or + \righttoleft + \fi} + +% Interesting is that the non cached version is also pretty efficient +% and as we cache we seldom call that one now so one can debate the +% speedup. + +\newtoks\t_spacing_set_alignment + +\let\raggedcommand \relax +\let\updateraggedskips\relax + +% \unexpanded\def\spacing_set_text_align#1% beware: #1=empty is ignored, keep that! assumes \forgetall ... needs checking +% {\edef\askedraggedalign{#1}% +% \ifx\askedraggedalign\empty +% \spacing_set_text_align_nop +% \else +% \spacing_set_text_align_yes +% \fi} + +% \def\spacing_set_text_align_nop % as we cache (empty) anyway, this one can go +% {%\let\raggedtopcommand \relax +% %\let\raggedbottomcommand\relax +% \let\raggedbox \relax % why +% \t_spacing_set_alignment +% {\resetrealignsignal +% \setfalse\raggedonelinerstate +% \let\raggedtopcommand \relax +% \let\raggedbottomcommand\relax}} + +% \def\spacing_set_text_align_yes % hm, we could hash settings ! nice experiment +% {%\let\raggedtopcommand\empty +% %\let\raggedbottomcommand\empty +% \let\raggedbox\relax % why +% % we inherit hyphenation and tolerance +% \t_spacing_set_alignment \emptytoks +% \c_spacing_state_broad \zerocount +% \c_spacing_state_horizontal\zerocount +% \c_spacing_state_vertical \zerocount +% \c_spacing_state_direction \zerocount % what is default ? +% \c_spacing_state_page \zerocount +% \ifcsname\??aligncommand\askedraggedalign\endcsname +% \csname\??aligncommand\askedraggedalign\endcsname +% \else +% \rawprocesscommacommand[\askedraggedalign]\spacing_set_text_align_collect +% \fi +% \normalexpanded{\t_spacing_set_alignment +% {\resetrealignsignal % can go as it is alway set +% \setfalse\raggedonelinerstate % bad +% \the\t_spacing_set_alignment +% \spacing_flush_horizontal +% \spacing_flush_vertical +% \spacing_flush_direction +% \spacing_flush_page +% }}} % kept + +\unexpanded\def\spacing_set_text_align#1% what to do with empty (and forgetall) + {\edef\askedraggedalign{#1}% + \let\raggedbox\relax % why + % we inherit hyphenation and tolerance + \t_spacing_set_alignment \emptytoks + \c_spacing_state_broad \zerocount + \c_spacing_state_horizontal\zerocount + \c_spacing_state_vertical \zerocount + \c_spacing_state_direction \zerocount % what is default ? + \c_spacing_state_page \zerocount + \ifcsname\??aligncommand\askedraggedalign\endcsname + \csname\??aligncommand\askedraggedalign\endcsname + \else + \rawprocesscommacommand[\askedraggedalign]\spacing_set_text_align_collect \fi - \hyphenpenalty\plustenthousand - \exhyphenpenalty\plustenthousand} + \normalexpanded{\t_spacing_set_alignment + {\resetrealignsignal % can go as it is alway set + \setfalse\raggedonelinerstate % bad + \the\t_spacing_set_alignment + \spacing_flush_horizontal + \spacing_flush_vertical + \spacing_flush_direction + \spacing_flush_page + }}} % kept + +\def\spacing_set_text_align_collect#1% + {\csname\??aligncommand#1\endcsname} + +\def\spacing_alignment_add_to_cache#1% + {\spacing_set_text_align{#1} + \edef\raggedcommand{\the\t_spacing_set_alignment}% + \global\expandafter\let\csname\??alignmentcache#1\endcsname\raggedcommand} + +% The regular align setter: -\let\dohyphens\relax +\unexpanded\def\setupalign + {\dosingleempty\spacing_setup_align} -%D To prevent unwanted side effects, we also have to check -%D for hyphens here: +\def\spacing_setup_align[#1]% immediate + {\expandafter\let\expandafter\raggedcommand\csname\??alignmentcache#1\endcsname + \ifx\raggedcommand\relax + \spacing_alignment_add_to_cache{#1}% + \fi + \let\updateraggedskips\raggedcommand + \raggedcommand} -\newskip\@@raggedskipa -\newskip\@@raggedskipb +% the local (key driven) setter: -\unexpanded\def\setraggedness#1% - {\ifnum\tolerance<1500\relax % small values have - \tolerance1500\relax % unwanted side effects +\unexpanded\def\spacing_setup_aligned#1% deferred + {\expandafter\let\expandafter\raggedcommand\csname\??alignmentcache#1\endcsname + \ifx\raggedcommand\relax + \spacing_alignment_add_to_cache{#1}% \fi - \ifx\dohyphens\relax - % this code will be reconsidered / kind of fuzzy (and old) - \@@raggedskipa 2.5\hsize - \@@raggedskipb #1\relax - \divide\@@raggedskipa \@@raggedskipb - \hyphenpenalty\@@raggedskipa + \let\updateraggedskips\raggedcommand} + +\let\dosetraggedcommand\spacing_setup_aligned % sort of public + +% The keywords: + +\unexpanded\def\installalign#1#2% beware: commands must be unexpandable! + {\ifcsname\??aligncommand#1\endcsname \else + \setvalue{\??aligncommand#1}{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment#2}}% \fi} -\let\updateraggedskips\relax +\letvalue{\??aligncommand\empty }\empty +\setvalue{\??aligncommand\v!broad }{\c_spacing_state_broad \plusone } +\setvalue{\??aligncommand\v!wide }{\c_spacing_state_broad \plustwo } + +\setvalue{\??aligncommand\v!bottom }{\c_spacing_state_page \plusone } +\setvalue{\??aligncommand\v!height }{\c_spacing_state_page \plustwo } +\setvalue{\??aligncommand\v!line }{\c_spacing_state_page \plusthree + % this will become another keyword (undocumented anyway) + \t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\settrue\raggedonelinerstate}} + +\setvalue{\??aligncommand\v!high }{\c_spacing_state_vertical \plusthree} +\setvalue{\??aligncommand\v!low }{\c_spacing_state_vertical \plustwo } +\setvalue{\??aligncommand\v!lohi }{\c_spacing_state_vertical \plusone } + +\setvalue{\??aligncommand\v!flushright }{\c_spacing_state_horizontal\plusthree} +\setvalue{\??aligncommand\v!flushleft }{\c_spacing_state_horizontal\plustwo } +\setvalue{\??aligncommand\v!middle }{\c_spacing_state_horizontal\plusone } +\setvalue{\??aligncommand\v!no }{\c_spacing_state_horizontal\plustwo } +\setvalue{\??aligncommand\v!yes }{\c_spacing_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!width }{\c_spacing_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!normal }{\c_spacing_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!reset }{\c_spacing_state_page \zerocount + \c_spacing_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!inner }{\c_spacing_state_horizontal\plusfour } +\setvalue{\??aligncommand\v!outer }{\c_spacing_state_horizontal\plusfive } +\setvalue{\??aligncommand\v!flushinner }{\c_spacing_state_horizontal\plusfive } +\setvalue{\??aligncommand\v!flushouter }{\c_spacing_state_horizontal\plusfour } +\setvalue{\??aligncommand\v!right }{\c_spacing_state_horizontal\plustwo } +\setvalue{\??aligncommand\v!left }{\c_spacing_state_horizontal\plusthree} +\setvalue{\??aligncommand\v!center }{\c_spacing_state_horizontal\plusone + \c_spacing_state_broad \plustwo } +\setvalue{\??aligncommand\v!disable }{\c_spacing_state_horizontal\plussix } +\setvalue{\??aligncommand\v!last }{\c_spacing_state_horizontal\plusseven} + + +\setvalue{\??aligncommand\v!lefttoright }{\c_spacing_state_direction \plusone } +\setvalue{\??aligncommand\v!righttoleft }{\c_spacing_state_direction \plustwo } +\setvalue{\??aligncommand l2r}{\c_spacing_state_direction \plusone } +\setvalue{\??aligncommand r2l}{\c_spacing_state_direction \plustwo } + +\setvalue{\??aligncommand\v!table }{\c_spacing_state_vertical \plusthree + \c_spacing_state_broad \plusone + \c_spacing_state_horizontal\plustwo } + +\setvalue{\??aligncommand\v!lesshyphenation}{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\lesshyphens}} +\setvalue{\??aligncommand\v!morehyphenation}{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\morehyphens}} + +\setvalue{\??aligncommand\v!hanging }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_protruding_enable }} +\setvalue{\??aligncommand\v!nothanging }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_protruding_disable}} +\setvalue{\??aligncommand\v!hz }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_expansion_enable }} +\setvalue{\??aligncommand\v!nohz }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_expansion_disable }} +\setvalue{\??aligncommand\v!spacing }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\enablespacehandling \enablekernhandling }} +\setvalue{\??aligncommand\v!nospacing }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\disablespacehandling\disablekernhandling}} +\setvalue{\??aligncommand\v!hyphenated }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\dohyphens}} +\setvalue{\??aligncommand\v!nothyphenated }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\nohyphens}} + +\setvalue{\??aligncommand\v!tolerant }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\ragged_command_tolerant}} +\setvalue{\??aligncommand\v!verytolerant }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\ragged_command_very_tolerant}} +\setvalue{\??aligncommand\v!stretch }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\ragged_command_stretch}} + +% Visible commands: + +\let\notragged \spacing_horizontal_none +\let\forgetragged \spacing_horizontal_none +\let\raggedleft \spacing_horizontal_left +\let\raggedcenter \spacing_horizontal_center +\let\raggedright \spacing_horizontal_right +\let\veryraggedleft \spacing_horizontal_very_left +\let\veryraggedcenter\spacing_horizontal_very_center +\let\veryraggedright \spacing_horizontal_very_right +\let\raggedwidecenter\spacing_horizontal_wide_center +\let\centeredlastline\spacing_horizontal_centered_last_line +\let\ttraggedright \spacing_horizontal_right_tt % a plain command + +% Box commands. + +\unexpanded\def\ibox#1#2#3% + {\vbox\bgroup + \forgetall + \let\\=\endgraf + \ifdoublesided\signalinnerrealign\fi + \doifrightpageelse\spacing_horizontal_right\spacing_horizontal_left + \let\next} + +\unexpanded\def\obox#1#2#3% + {\vbox\bgroup + \forgetall + \let\\=\endgraf + \ifdoublesided\signalouterrealign\fi + \doifrightpageelse\c_spacing_state_horizontal_left\spacing_horizontal_right + \let\next} + +\let\raggedbox\relax + +\def\dosetraggedvbox#1% can be more keys + {\let\raggedbox\vbox + \processcommacommand[#1]\dodosetraggedvbox} + +\def\dosetraggedhbox#1% can be more keys + {\let\raggedbox\hbox + \processcommacommand[#1]\dodosetraggedhbox} + +\def\dodosetraggedvbox#1% + {\ifcsname\??alignvertical#1\endcsname + \csname\??alignvertical#1\endcsname + \quitcommalist + \fi} + +\def\dodosetraggedhbox#1% + {\ifcsname\??alignhorizontal#1\endcsname + \csname\??alignhorizontal#1\endcsname + \quitcommalist + \fi} + +\setvalue{\??alignvertical \v!left }{\let\raggedbox\lbox} +\setvalue{\??alignvertical \v!right }{\let\raggedbox\rbox} +\setvalue{\??alignvertical \v!middle }{\let\raggedbox\cbox} +\setvalue{\??alignvertical \v!inner }{\let\raggedbox\ibox} +\setvalue{\??alignvertical \v!outer }{\let\raggedbox\obox} +\setvalue{\??alignvertical \v!flushleft }{\let\raggedbox\rbox} +\setvalue{\??alignvertical \v!flushright}{\let\raggedbox\lbox} +\setvalue{\??alignvertical \v!center }{\let\raggedbox\cbox} +\setvalue{\??alignvertical \v!no }{\def\raggedbox{\vbox\bgroup\spacing_horizontal_right\let\next=}]} + +% maybe \let's + +\setvalue{\??alignhorizontal\v!left }{\def\raggedbox{\doalignedline\v!left }} +\setvalue{\??alignhorizontal\v!right }{\def\raggedbox{\doalignedline\v!right }} +\setvalue{\??alignhorizontal\v!middle }{\def\raggedbox{\doalignedline\v!middle}} +\setvalue{\??alignhorizontal\v!inner }{\def\raggedbox{\doalignedline\v!inner }} +\setvalue{\??alignhorizontal\v!outer }{\def\raggedbox{\doalignedline\v!outer }} +\setvalue{\??alignhorizontal\v!flushleft }{\def\raggedbox{\doalignedline\v!right }} +\setvalue{\??alignhorizontal\v!flushright}{\def\raggedbox{\doalignedline\v!left }} +\setvalue{\??alignhorizontal\v!center }{\def\raggedbox{\doalignedline\v!middle}} + +% The next one can be in use so we keep it around but oen should +% be aware of possible interference. \unexpanded\def\setraggedskips#1#2#3#4#5#6#7% never change this name (todo: inline this one .. less tracingall) {\unexpanded\def\updateraggedskips{\dosetraggedskips{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% \updateraggedskips} \def\dosetraggedskips#1#2#3#4#5#6#7% - {\raggedstatus#1\relax - \attribute\alignstateattribute\ifcase\raggedstatus\attributeunsetvalue\else\raggedstatus\fi - \leftskip 1\leftskip \!!plus#2\relax % zie: Tex By Topic 8.1.3 - \rightskip 1\rightskip\!!plus#3\relax % zie: Tex By Topic 8.1.3 - \spaceskip #4\relax - \xspaceskip #5\relax - \parfillskip\zeropoint\!!plus#6\relax - \parindent #7\relax} - -\appendtoks - \attribute\alignstateattribute\attributeunsetvalue -\to \everyforgetall - -% \def\notragged% -% {\setraggedskips{0}{0em}{0em}{0em}{0em}{1fil}{\parindent}} + {\raggedstatus #1\relax + \leftskip 1\leftskip \!!plus#2\relax + \rightskip 1\rightskip\!!plus#3\relax + \spaceskip #4\relax + \xspaceskip #5\relax + \parfillskip \zeropoint\!!plus#6\relax + \parindent #7\relax + \attribute\alignstateattribute\ifcase\raggedstatus\attributeunsetvalue\else\raggedstatus\fi} % older (context) names: @@ -468,16 +746,16 @@ % tracing: -\def\doshowpardata#1% +\def\spacing_show_par_data#1% {\ifx#1\relax\else \hbox{\string#1: \the#1}\endgraf - \expandafter\doshowpardata + \expandafter\spacing_show_par_data \fi} \unexpanded\def\showpardata {\edef\thepardata {\hbox{font: \fontname\font}\endgraf - \doshowpardata + \spacing_show_par_data \interwordspace \interwordstretch \interwordshrink \emwidth \exheight \extraspace \hsize \vsize \leftskip \rightskip @@ -487,16 +765,15 @@ \displaywidowpenalty \widowpenalty \clubpenalty \brokenpenalty \doublehyphendemerits \finalhyphendemerits \adjdemerits \relax}% + \dontleavehmode \begingroup \dontshowcomposition - \inleftmargin{\vsmash - {\infofont - \framed[\c!align=\v!right]{\thepardata}}}% + \inleftmargin{\vsmash{\infofont\framed[\c!align=\v!right]{\thepardata}}}% \endgroup} \unexpanded\def\startshowpardata {\begingroup - \showcomposition + \showcomposition % all this tracing can go ... if we want it back it will be done in lua \showstruts\tracepositionstrue \tracingparagraphs\maxdimen \appendtoksonce\showpardata\let\showpardata\relax\to\everypar} @@ -504,211 +781,15 @@ {\endgraf \endgroup} -% defaults - -\def\raggedfillamount {1fil} -\def\raggednegativefillamount{-1fil} -\def\raggeddoublefillamount {2fil} -\def\raggedhalffillamount {.5fil} -\def\raggedspaceamount {\interwordspace} % {.3333em} -\def\raggedxspaceamount {.5em} - -\unexpanded\def\notragged - {\raggedstatus\zerocount - \leftskip 1\leftskip - \rightskip 1\rightskip - \spaceskip \zeropoint - \xspaceskip \zeropoint - \parfillskip\zeropoint\!!plus\raggedfillamount\relax - \let\updateraggedskips\relax} % new - -\let\forgetragged\notragged - -\unexpanded\def\raggedleft - {\setraggedness\leftraggedness - \setraggedskips1\leftraggedness\zeropoint\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -\unexpanded\def\raggedcenter - {\setraggedness\middleraggedness - \setraggedskips2\middleraggedness\middleraggedness\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -\unexpanded\def\centeredlastline - {\setraggedskips - \zerocount - \raggedfillamount - \raggednegativefillamount - \zeropoint - \zeropoint - \raggeddoublefillamount - \zeropoint} - -%D We used to have: -%D -%D \starttyping -%D \def\raggedright -%D {\setraggedness\rightraggedness -%D \setraggedskips{3}{0em}{\rightraggedness}{.3333em}{.5em}{0em}{\parindent}} -%D \stoptyping -%D -%D However, the next alternative, suggested by Taco, is better. - -\unexpanded\def\raggedright - {\setraggedness\rightraggedness - \setraggedskips3\zeropoint\rightraggedness\raggedspaceamount - \raggedxspaceamount\raggedfillamount\parindent} - -\unexpanded\def\veryraggedleft - {\setraggedskips1\raggedfillamount\zeropoint\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -%D When we want the last line to have a natural width: -%D -%D \starttyping -%D \def\veryraggedleft% -%D {\setraggedskips{1}{1fil}{0em}{.3333em}{.5em}{0em}{-1fil}} -%D \stoptyping -%D -%D but this one is not accepted by the macros. - -\unexpanded\def\veryraggedcenter - {\setraggedskips2\raggedfillamount\raggedfillamount\raggedspaceamount - \raggedxspaceamount\zeropoint\zeropoint} - -\unexpanded\def\veryraggedright - {\setraggedskips3\zeropoint\raggedfillamount\raggedspaceamount - \raggedxspaceamount\zeropoint\parindent} - -\unexpanded\def\ttraggedright - {\tttf - \setraggedskips3\zeropoint\rightraggedness - \zeropoint\zeropoint\zeropoint\parindent} % \ctxparindent - -%D A bonus one: - -\unexpanded\def\raggedwidecenter - {\setraggedness\middleraggedness - \setraggedskips2\raggedhalffillamount\raggedhalffillamount - \raggedspaceamount\raggedxspaceamount\zeropoint\zeropoint} - -\newif\if@@asragged \@@asraggedtrue % old method - -% todo -% -% \setuplayout[grid=yes,lines=44] \showgrid -% \starttext -% test \vfill test \endgraf \strut \endgraf \vskip-\lineheight \removedepth \pagina test -% \stoptext - -% \setupalign[reset,new,right,old] - -\def\@@align@@rl{\if!!donea\veryraggedleft \else\raggedleft \fi} -\def\@@align@@rr{\if!!donea\veryraggedright \else\raggedright \fi} -\def\@@align@@rc{\if!!donea\veryraggedcenter\else\raggedcenter\fi} - -\setvalue{@@ngila@@\v!broad }{\!!doneatrue} -\setvalue{@@ngila@@\v!wide }{\!!donebtrue} - -\unexpanded\def\setraggedparagraphmode - {\doifrightpageelse - {\ifdoublesided\signalinnerrealign\expandafter\firstoftwoarguments \fi} - {\ifdoublesided\signalouterrealign\expandafter\secondoftwoarguments\fi}} - -\unexpanded\def\installalign#1#2{\setvalue{@@align@@#1}{#2}} % can be used for overloads - -\installalign \v!new {\@@asraggedfalse} -\installalign \v!old {\@@asraggedtrue} -\installalign \empty {} - -\installalign \v!line {\baselinebottom} -\installalign \v!bottom {\raggedbottom} -\installalign \v!height {\normalbottom} -\installalign \v!width {\notragged} -\installalign \v!normal {\notragged} -\installalign \v!yes {\notragged} -\installalign \v!no {\raggedright} -\installalign \v!inner {\if@@asragged \setraggedparagraphmode\@@align@@rl\@@align@@rr \else - \setraggedparagraphmode\@@align@@rr\@@align@@rl \fi} -\installalign \v!outer {\if@@asragged \setraggedparagraphmode\@@align@@rr\@@align@@rl \else - \setraggedparagraphmode\@@align@@rl\@@align@@rr \fi} -\installalign \v!left {\if@@asragged\@@align@@rl\else\@@align@@rr\fi} -\installalign \v!right {\if@@asragged\@@align@@rr\else\@@align@@rl\fi} -\installalign \v!middle {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} -\installalign \v!flushleft {\if!!donea\veryraggedright \else\raggedright\fi} -\installalign \v!flushright {\if!!donea\veryraggedleft \else\raggedleft \fi} -\installalign \v!flushouter {\setraggedparagraphmode\raggedleft\raggedright} -\installalign \v!flushinner {\setraggedparagraphmode\raggedright\raggedleft} -\installalign \v!center {\if!!doneb\raggedwidecenter\else\@@align@@rc\fi} -\installalign \v!hanging {\enableprotruding} -\installalign \v!nothanging {\disableprotruding} -\installalign \v!hz {\enableadjusting} -\installalign \v!nohz {\disableadjusting} -\installalign \v!spacing {\enablespacehandling \enablekernhandling} -\installalign \v!nospacing {\disablespacehandling\disablekernhandling} -\installalign \v!hyphenated {\dohyphens} -\installalign \v!nothyphenated {\nohyphens} -\installalign \v!new {\@@asraggedfalse} % so new will give you consistency -\installalign \v!reset {\notragged\normalbottom} - -\installalign \v!tolerant {\tolerance3000\relax} -\installalign \v!verytolerant {\tolerance4500\relax} -\installalign \v!stretch {\emergencystretch\bodyfontsize} - -\installalign \v!righttoleft {\lefttoright} -\installalign \v!lefttoright {\righttoleft} -\installalign {l2r} {\lefttoright} -\installalign {r2l} {\righttoleft} - -\installalign \v!last {\centeredlastline} - -\newcount\hyphenminoffset - -\ifx\sethyphenationvariables\undefined \let\sethyphenationvariables\relax \fi - -\unexpanded\def\lesshyphens - {\advance\hyphenminoffset\plusone - \sethyphenationvariables} - -\unexpanded\def\morehyphens - {\ifcase\hyphenminoffset \else - \advance\hyphenminoffset\minusone - \fi - \sethyphenationvariables} - -\installalign \v!lesshyphenation {\lesshyphens} -\installalign \v!morehyphenation {\morehyphens} - -\def\dodosetupalign#1{\csname @@align@@#1\endcsname} -\def\dodosetupngila#1{\csname @@ngila@@#1\endcsname} - -\unexpanded\def\setupalign - {\dosingleargument\dosetupalign} - -\def\dosetupalign[#1]% can be made faster by checking for defined #1 - {\!!doneafalse - \!!donebfalse - \raggedstatus\zerocount - \resetrealignsignal - \processcommacommand[#1]\dodosetupngila - \processcommacommand[#1]\dodosetupalign} - -% \setupalign[flushleft] \input ward \par % lijnlinks -% \setupalign[right] \input ward \par - -% \setupalign[flushright] \input ward \par % lijnrechts -% \setupalign[left] \input ward \par - -% \setupalign[middle] \input ward \par % centreer -% \setupalign[center] \input ward \par +% Structure: \unexpanded\def\startalignment - {\bgroup + {\begingroup \setupalign} \unexpanded\def\stopalignment {\par - \egroup} + \endgroup} \setnewconstant\alignstrutmode\plusone @@ -746,26 +827,28 @@ \ifdefined\rightline \else \def\rightline #1{\line{\hss#1}} \fi \ifdefined\centerline \else \def\centerline#1{\line{\hss#1\hss}} \fi -% directe commando's +% direct commands -\unexpanded\def\leftaligned {\doalignline \relax \hss } -\unexpanded\def\midaligned {\doalignline \hss \hss } -\unexpanded\def\rightaligned{\doalignline \hss \relax} -\unexpanded\def\maxaligned {\doalignline \relax \relax} +\unexpanded\def\leftaligned {\doalignline\relax \hss } +\unexpanded\def\midaligned {\doalignline\hss \hss } +\unexpanded\def\rightaligned{\doalignline\hss \relax} +\unexpanded\def\maxaligned {\doalignline\relax \relax} \let\centeraligned\midaligned -% indirecte commando's +% indirect commands + +\installcorenamespace{alignline} -\letvalue{\s!do\v!line\v!left }\leftaligned -\letvalue{\s!do\v!line\v!right }\rightaligned -\letvalue{\s!do\v!line\v!middle }\midaligned -\letvalue{\s!do\v!line\v!flushleft }\rightaligned -\letvalue{\s!do\v!line\v!flushright}\leftaligned -\letvalue{\s!do\v!line\v!center }\midaligned -\letvalue{\s!do\v!line\v!max }\maxaligned +\letvalue{\??alignline\v!left }\leftaligned +\letvalue{\??alignline\v!right }\rightaligned +\letvalue{\??alignline\v!middle }\midaligned +\letvalue{\??alignline\v!flushleft }\rightaligned +\letvalue{\??alignline\v!flushright}\leftaligned +\letvalue{\??alignline\v!center }\midaligned +\letvalue{\??alignline\v!max }\maxaligned -\def\doalignedline#1{\resetrealignsignal\csname\s!do\v!line#1\endcsname} +\def\doalignedline#1{\resetrealignsignal\csname\??alignline#1\endcsname} %D Experimental (will be redone when floats are redone as it's real messy %D now). It can also be made faster (if needed). @@ -777,8 +860,7 @@ \setlocalhsize \def\\{\endgroup\par\doxalignline#1#2#3#4#5#6\begingroup}% inefficient \dowithnextbox - {%\noindent moved up - \hbox to \localhsize + {\hbox to \localhsize {#1\hskip\ifdone#2\else#3\fi#4% \hbox to \localhsize {\the\everyleftofalignedline @@ -792,35 +874,33 @@ \def\doxcheckline % used for floats so multipass anyway {\signalrightpage\doifrightpageelse\donetrue\donefalse} -\setvalue{\s!do\v!line\v!inner }{\doxalignline\doxcheckline++\zeropoint \relax\hss } -\setvalue{\s!do\v!line\v!outer }{\doxalignline\doxcheckline++\zeropoint \hss \relax} -\setvalue{\s!do\v!line\v!innermargin}{\doxalignline\doxcheckline-+\innermargintotal\relax\hss } -\setvalue{\s!do\v!line\v!outermargin}{\doxalignline\doxcheckline+-\outermargintotal\hss \relax} -\setvalue{\s!do\v!line\v!inneredge }{\doxalignline\doxcheckline-+\inneredgetotal \relax\hss } -\setvalue{\s!do\v!line\v!outeredge }{\doxalignline\doxcheckline+-\outeredgetotal \hss \relax} -\setvalue{\s!do\v!line\v!backspace }{\doxalignline\doxcheckline-+\backspace \relax\hss } -\setvalue{\s!do\v!line\v!cutspace }{\doxalignline\doxcheckline+-\cutspace \hss \relax} - -\setvalue{\s!do\v!line\v!leftmargin }{\doxalignline\donefalse --\leftmargintotal \hss \relax} -\setvalue{\s!do\v!line\v!rightmargin}{\doxalignline\donefalse ++\rightmargintotal\relax\hss } -\setvalue{\s!do\v!line\v!leftedge }{\doxalignline\donefalse --\leftedgetotal \hss \relax} -\setvalue{\s!do\v!line\v!rightedge }{\doxalignline\donefalse ++\rightedgetotal \relax\hss } - -% ! ! ! beware, redefining \doalignline gives the wrong results ! ! ! -% -% \def\doalignline{\doxalignline\donefalse++\zeropoint} +\setvalue{\??alignline\v!inner }{\doxalignline\doxcheckline++\zeropoint \relax\hss } +\setvalue{\??alignline\v!outer }{\doxalignline\doxcheckline++\zeropoint \hss \relax} +\setvalue{\??alignline\v!innermargin}{\doxalignline\doxcheckline-+\innermargintotal\relax\hss } +\setvalue{\??alignline\v!outermargin}{\doxalignline\doxcheckline+-\outermargintotal\hss \relax} +\setvalue{\??alignline\v!inneredge }{\doxalignline\doxcheckline-+\inneredgetotal \relax\hss } +\setvalue{\??alignline\v!outeredge }{\doxalignline\doxcheckline+-\outeredgetotal \hss \relax} +\setvalue{\??alignline\v!backspace }{\doxalignline\doxcheckline-+\backspace \relax\hss } +\setvalue{\??alignline\v!cutspace }{\doxalignline\doxcheckline+-\cutspace \hss \relax} -%D Better: +\setvalue{\??alignline\v!leftmargin }{\doxalignline\donefalse --\leftmargintotal \hss \relax} +\setvalue{\??alignline\v!rightmargin}{\doxalignline\donefalse ++\rightmargintotal\relax\hss } +\setvalue{\??alignline\v!leftedge }{\doxalignline\donefalse --\leftedgetotal \hss \relax} +\setvalue{\??alignline\v!rightedge }{\doxalignline\donefalse ++\rightedgetotal \relax\hss } -\def\doalignedline#1{\csname\s!do\v!line#1\endcsname} +\def\doalignedline#1% unchecked + {\csname\??alignline#1\endcsname} \def\alignedline#1#2% setting default - {\csname\s!do\v!line\ifcsname\s!do\v!line#1\endcsname#1\else#2\fi\endcsname} + {\csname\??alignline\ifcsname\??alignline#1\endcsname#1\else#2\fi\endcsname} % beware: \wordright{whatever\kern-\rightskip} should work! % so, no funny boxing here -\def\dowordright[#1]% +\unexpanded\def\wordright + {\dosingleempty\spacing_word_right} + +\def\spacing_word_right[#1]% {% don't change \groupedcommand {\removeunwantedspaces @@ -835,50 +915,72 @@ \finalhyphendemerits\zerocount % yes or no (see hyhenation/specialcases-001.tex) \par}} -\unexpanded\def\wordright - {\dosingleempty\dowordright} - -% \dorecurse{5}{something } \wordright{--someone} \endgraf -% \dorecurse{6}{something } \wordright{--someone} \endgraf -% \dorecurse{7}{something } \wordright{--someone} \endgraf +% \dorecurse{5}{something} \wordright{--someone} \endgraf +% \dorecurse{6}{something} \wordright{--someone} \endgraf +% \dorecurse{7}{something} \wordright{--someone} \endgraf % -% \dorecurse{5}{something } \wordright{--someone else entirely} \endgraf -% \dorecurse{6}{something } \wordright{--someone else entirely} \endgraf -% \dorecurse{7}{something } \wordright{--someone else entirely} \endgraf +% \dorecurse{5}{something} \wordright{--someone else entirely} \endgraf +% \dorecurse{6}{something} \wordright{--someone else entirely} \endgraf +% \dorecurse{7}{something} \wordright{--someone else entirely} \endgraf % % \wordright[\rightskip]{whatever} - -% \simplealignedbox{2cm}{right}{x} -% \setvalue{\s!simple\c!align\v!right }#1#2{\hbox to #1{#2\hss}} -% \setvalue{\s!simple\c!align\v!left }#1#2{\hbox to #1{\hss#2}} -% \setvalue{\s!simple\c!align\v!flushright }#1#2{\hbox to #1{\hss#2}} -% \setvalue{\s!simple\c!align\v!flushleft }#1#2{\hbox to #1{#2\hss}} -% \setvalue{\s!simple\c!align\v!middle }#1#2{\hbox to #1{\hss#2\hss}} +% \simplealignedbox{2cm}{right}{x} -% \unexpanded\def\simplealignedbox#1% -% {\csname\s!simple\c!align\ifcsname\s!simple\c!align#1\endcsname#1\else\v!right\fi\endcsname} +\installcorenamespace{alignsimple} -\setvalue{\s!simple:\c!align:\v!right }#1{{#1\hss}} -\setvalue{\s!simple:\c!align:\v!left }#1{{\hss#1}} -\setvalue{\s!simple:\c!align:\v!flushright }#1{{\hss#1}} -\setvalue{\s!simple:\c!align:\v!flushleft }#1{{#1\hss}} -\setvalue{\s!simple:\c!align:\v!middle }#1{{\hss#1\hss}} +\setvalue{\??alignsimple\v!right }#1{{#1\hss}} +\setvalue{\??alignsimple\v!left }#1{{\hss#1}} +\setvalue{\??alignsimple\v!flushright}#1{{\hss#1}} +\setvalue{\??alignsimple\v!flushleft }#1{{#1\hss}} +\setvalue{\??alignsimple\v!middle }#1{{\hss#1\hss}} \unexpanded\def\simplealignedbox#1#2% - {\hbox to #1\csname\s!simple:\c!align:\ifcsname\s!simple:\c!align:#2\endcsname#2\else\v!right\fi\endcsname} - -% \setvalue{spac_align_set_ss_\v!right }#1#2{\let#1\relax\let#2\hss } -% \setvalue{spac_align_set_ss_\v!left }#1#2{\let#1\hss \let#2\relax} -% \setvalue{spac_align_set_ss_\v!flushright}#1#2{\let#1\hss \let#2\relax} -% \setvalue{spac_align_set_ss_\v!flushleft }#1#2{\let#1\relax\let#2\hss } -% \setvalue{spac_align_set_ss_\v!middle }#1#2{\let#1\hss \let#2\hss } -% \setvalue{spac_align_set_ss_\v!low }#1#2{\let#1\vss \let#2\relax} -% \setvalue{spac_align_set_ss_\v!high }#1#2{\let#1\relax\let#2\vss } -% \setvalue{spac_align_set_ss_\v!lohi }#1#2{\let#1\vss \let#2\vss } -% \setvalue{spac_align_set_ss_\s!unknown }#1#2{\let#1\relax\let#2\relax} + {\hbox to #1\csname\??alignsimple\ifcsname\??alignsimple#2\endcsname#2\else\v!right\fi\endcsname} +% \installnamespace{alignsets} +% +% \setvalue{\??alignsets\v!right }#1#2{\let#1\relax\let#2\hss } +% \setvalue{\??alignsets\v!left }#1#2{\let#1\hss \let#2\relax} +% \setvalue{\??alignsets\v!flushright}#1#2{\let#1\hss \let#2\relax} +% \setvalue{\??alignsets\v!flushleft }#1#2{\let#1\relax\let#2\hss } +% \setvalue{\??alignsets\v!middle }#1#2{\let#1\hss \let#2\hss } +% \setvalue{\??alignsets\v!low }#1#2{\let#1\vss \let#2\relax} +% \setvalue{\??alignsets\v!high }#1#2{\let#1\relax\let#2\vss } +% \setvalue{\??alignsets\v!lohi }#1#2{\let#1\vss \let#2\vss } +% \setvalue{\??alignsets\s!unknown }#1#2{\let#1\relax\let#2\relax} +% % \unexpanded\def\spac_align_set_ss#1% -% {\csname spac_align_set_ss_\ifcsname spac_align_set_ss_#1\endcsname#1\else\s!unknown\fi\endcsname} +% {\csname\??alignsetss\ifcsname\??alignsetss#1\endcsname#1\else\s!unknown\fi\endcsname} + +% Some obsolete (old) helpers: + +\def\dodefinehbox[#1][#2]% + {\setvalue{hbox#1}##1{\hbox to #2{\begstrut##1\endstrut\hss}}} + +\unexpanded\def\definehbox + {\dodoubleargument\dodefinehbox} \protect \endinput + +% \newskip\@@raggedskipa +% \newskip\@@raggedskipb +% +% \newcount\c_spacing_minimum_tolerance \c_spacing_minimum_tolerance = 1500 +% +% \unexpanded\def\setraggedness#1% +% {\ifnum\tolerance<\c_spacing_minimum_tolerance % small values have +% \tolerance\c_spacing_minimum_tolerance % unwanted side effects +% \fi +% \ifx\dohyphens\relax +% % this code will be reconsidered / kind of fuzzy (and old) +% \@@raggedskipa 2.5\hsize +% \@@raggedskipb #1\relax +% \divide\@@raggedskipa \@@raggedskipb +% \hyphenpenalty\@@raggedskipa +% \fi} + +% \installalign \v!inner {\setraggedparagraphmode\spacing_align_rl\spacing_align_rr} +% \installalign \v!outer {\setraggedparagraphmode\spacing_align_rr\spacing_align_rl} +% \installalign \v!flushouter {\setraggedparagraphmode\spacing_horizontal_left \spacing_horizontal_right} +% \installalign \v!flushinner {\setraggedparagraphmode\spacing_horizontal_right\spacing_horizontal_left } diff --git a/tex/context/base/spac-def.mkiv b/tex/context/base/spac-def.mkiv index c1703fadb..333335630 100644 --- a/tex/context/base/spac-def.mkiv +++ b/tex/context/base/spac-def.mkiv @@ -71,7 +71,7 @@ \appendtoks \setrelativeinterlinespace \to \everybodyfont \appendtoks \updateraggedskips \to \everyfontswitch % under test -\prependtoks \let\par\endgraf \to \everypagebody % see \fillinline +\prependtoks \let\par\endgraf \to \everybeforepagebody % see \fillinline \appendtoks \simplesetupspacing \to \everydefinedfont \setupwhitespace diff --git a/tex/context/base/spac-pag.mkiv b/tex/context/base/spac-pag.mkiv index c3ed49fe8..264fbd108 100644 --- a/tex/context/base/spac-pag.mkiv +++ b/tex/context/base/spac-pag.mkiv @@ -43,45 +43,53 @@ %\llap{\infofont\number\noftrackedpagestates/\number#2}% tracing \fi} -\def\doifrightpagestateelse#1#2% +\def\doifrightpagestateelse#1#2% not expandable ! {\ifcase\frozenpagestate \pagestatemismatchfalse \realpagestateno\realfolio \ifinpagebody \ifdoublesided \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse + \system_twopass_set_found + \else + \system_twopass_set_not_found \fi \else - \twopassdatafoundtrue + \system_twopass_set_found \fi \else\ifdoublesided \findtwopassdata{#1}{\number#2}% - \iftwopassdatafound + \ifconditional\twopassdatafound \realpagestateno\twopassdata\relax \ifnum\twopassdata=\realpageno \else \pagestatemismatchtrue \fi \ifodd\twopassdata\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse + \system_twopass_set_found + \else + \system_twopass_set_not_found \fi \else \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse + \system_twopass_set_found + \else + \system_twopass_set_not_found \fi \fi \else - \twopassdatafoundtrue + \system_twopass_set_found \fi\fi \else \ifodd\realpagestateno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse + \system_twopass_set_found + \else + \system_twopass_set_not_found \fi \fi - \iftwopassdatafound - \@EA\firstoftwoarguments + \ifconditional\twopassdatafound + \expandafter\firstoftwoarguments \else - \@EA\secondoftwoarguments + \expandafter\secondoftwoarguments \fi} \def\doifforcedrightpagestateelse#1#2% @@ -89,28 +97,34 @@ \pagestatemismatchfalse \realpagestateno\realfolio \findtwopassdata{#1}{\number#2}% - \iftwopassdatafound + \ifconditional\twopassdatafound \realpagestateno\twopassdata\relax \ifnum\twopassdata=\realpageno \else \pagestatemismatchtrue \fi \ifodd\twopassdata\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse + \system_twopass_set_found + \else + \system_twopass_set_not_found \fi \else \ifodd\realpageno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse + \system_twopass_set_found + \else + \system_twopass_set_not_found \fi \fi \else \ifodd\realpagestateno\relax - \twopassdatafoundtrue \else \twopassdatafoundfalse + \system_twopass_set_found + \else + \system_twopass_set_not_found \fi \fi - \iftwopassdatafound - \@EA\firstoftwoarguments + \ifconditional\twopassdatafound + \expandafter\firstoftwoarguments \else - \@EA\secondoftwoarguments + \expandafter\secondoftwoarguments \fi} \def\freezepagestate {\frozenpagestate\plusone } @@ -178,7 +192,7 @@ {\pagechangedfalse \doforcedtrackpagestate{#2}{#3}% \findtwopassdata{#2}{\number#3}% - \iftwopassdatafound + \ifconditional\twopassdatafound \ifnum\twopassdata>0\getvalue{#2:p:#1}\relax \pagechangedtrue \fi diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index 35095085f..7fb66a0ab 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -606,11 +606,16 @@ \fi} \unexpanded\def\settopskip % the extra test is needed for the lbr family - {\ifgridsnapping - \topskip\zeropoint - \else - \topskip\systemtopskipfactor\globalbodyfontsize\ifr@ggedbottom\!!plus5\globalbodyfontsize\fi\relax + {\topskip + \ifgridsnapping + \zeropoint + \else + \systemtopskipfactor\globalbodyfontsize + \ifcase\bottomraggednessmode % ragged bottom + \!!plus5\globalbodyfontsize + \fi \fi + %\relax \topskipgap\topskip \advance\topskipgap -\openstrutheight\relax \ifdim\minimumstrutheight>\zeropoint @@ -1175,55 +1180,6 @@ \def\savestrut {\setbox\savedstrutbox\copy\strutbox} \def\savedstrut{\copy \savedstrutbox} -%D Page spacing - -\newconstant\bottomraggednessmode % 0=ragged 1=normal/align 2=baseline - -\def\bottomalignlimit{3\lineheight} - -\newif\ifn@rmalbottom % this will be a proper constant -\newif\ifr@ggedbottom % this will be a proper constant -\newif\ifb@selinebottom % this will be a proper constant - -\unexpanded\def\normalbottom - {% \topskip 10pt - \r@ggedbottomfalse} - -\unexpanded\def\raggedbottom - {\bottomraggednessmode\zerocount - \n@rmalbottomfalse - \r@ggedbottomtrue - \b@selinebottomfalse - \settopskip} - -\unexpanded\def\alignbottom - {\bottomraggednessmode\plusone - \n@rmalbottomtrue - \r@ggedbottomfalse - \b@selinebottomfalse - \settopskip} - -\unexpanded\def\baselinebottom - {\bottomraggednessmode\plustwo - \n@rmalbottomfalse - \r@ggedbottomfalse - \b@selinebottomtrue - \settopskip} - -\let\normalbottom\alignbottom % downward compatible - -% so, the new one will be -% -% \bottomraggednessmode=0 % 0=ragged 1=normal/align 2=baseline -% -% \def\bottomalignlimit{3\lineheight} % will be settable -% -% \def\raggedbottom {\bottomraggednessmode\zerocount\settopskip} -% \def\alignbottom {\bottomraggednessmode\plusone \settopskip} -% \def\baselinebottom{\bottomraggednessmode\plustwo \settopskip} -% -% \let\normalbottom =\alignbottom - %D Good old blank redone: %definesystemattribute[kernchars] [public] @@ -1839,7 +1795,9 @@ %D Contrary to \MKII\ we can now define classes of lines (generalized by %D Wolfgang). I will probably rewrite bits in \LUA. -\installcommandhandler \??rg {lines} \??rg +\installcorenamespace{lines} + +\installcommandhandler \??lines {lines} \??lines \setuplines [\c!option=, diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index f6656b7ad..b3dea543c 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 17abf7776..97eb83beb 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua new file mode 100644 index 000000000..049512fdd --- /dev/null +++ b/tex/context/base/status-mkiv.lua @@ -0,0 +1,1394 @@ +-- colo-run.mkiv colo-imp-*.mkiv ... + +return { + preloaded = { + { + filename = "syst-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "norm-ctx", + marktype = "mkiv", + status = "okay", + }, + { + filename = "syst-pln", + marktype = "mkiv", + status = "okay", + }, + { + filename = "syst-mes", + marktype = "mkiv", + status = "okay", + }, + { + filename = "luat-cod", + marktype = "mkiv", + status = "okay", + }, + { + filename = "luat-bas", + marktype = "mkiv", + status = "okay", + comment = "maybe combine (3)", + }, + { + filename = "luat-lib", + marktype = "mkiv", + status = "okay", + comment = "maybe combine (3)", + }, + { + filename = "catc-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "catc-act", + marktype = "mkiv", + status = "okay", + comment = "forward dependency", + }, + { + filename = "catc-def", + marktype = "mkiv", + status = "okay", + }, + { + filename = "catc-ctx", + marktype = "mkiv", + status = "okay", + }, + { + filename = "catc-sym", + marktype = "mkiv", + status = "okay", + }, + { + filename = "cldf-ini", + marktype = "mkiv", + status = "okay", + comment = "maybe combine (1)", + }, + { + filename = "syst-aux", + marktype = "mkiv", + status = "okay", + comment = "will be better protected" + }, + { + filename = "syst-lua", + marktype = "mkiv", + status = "okay", + comment = "maybe combine (1)", + }, + { + filename = "syst-con", + marktype = "mkiv", + status = "okay", + comment = "maybe combine (1)", + }, + { + filename = "syst-fnt", + marktype = "mkiv", + status = "okay", + comment = "maybe combine (1)", + }, + { + filename = "syst-rtp", + marktype = "mkiv", + status = "okay", + comment = "maybe combine (1)", + }, + { + filename = "file-ini", + marktype = "mkvi", + status = "okay", + comment = "maybe combine (2)", + }, + { + filename = "file-res", + marktype = "mkvi", + status = "okay", + comment = "maybe combine (2)", + }, + { + filename = "file-lib", + marktype = "mkvi", + status = "okay", + }, + { + filename = "supp-dir", + marktype = "mkiv", + status = "okay", + }, + { + filename = "char-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "char-utf", + marktype = "mkiv", + status = "okay", + }, + { + filename = "char-act", + marktype = "mkiv", + status = "okay", + comment = "forward dependency", + }, + { + filename = "mult-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "mult-sys", + marktype = "mkiv", + status = "okay", + }, + { + filename = "mult-def", + marktype = "mkiv", + status = "okay", + }, + { + filename = "mult-chk", + marktype = "mkiv", + status = "okay", + }, + { + filename = "mult-aux", + marktype = "mkiv", + status = "okay", + }, + { + filename = "mult-dim", + marktype = "mkvi", + status = "okay", + }, + { + filename = "cldf-int", + marktype = "mkiv", + status = "okay", + }, + { + filename = "luat-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "toks-ini", + marktype = "mkiv", + status = "okay", + comment = "maybe this becomes a runtime module", + }, + { + filename = "attr-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "core-var", + marktype = "mkiv", + status = "unknown", + comment = "code might move from here", + }, + { + filename = "core-env", + marktype = "mkiv", + status = "okay", + comment = "might need more redoing", + }, + { + filename = "layo-ini", + marktype = "mkiv", + status = "todo", + comment = "more might move to here", + }, + { + filename = "node-ini", + marktype = "mkiv", + status = "okay", + comment = "maybe this becomes a runtime module", + }, + { + filename = "cldf-bas", + marktype = "mkiv", + status = "okay", + }, + { + filename = "node-fin", + marktype = "mkiv", + status = "okay", + comment = "might need more redoing", + }, + { + filename = "node-mig", + marktype = "mkiv", + status = "okay", + comment = "needs integration and configuration", + }, + { + filename = "node-par", + marktype = "mkiv", + status = "experimental", + }, + { + filename = "back-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "attr-col", + marktype = "mkiv", + status = "okay", + }, + { + filename = "attr-lay", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "attr-neg", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "attr-eff", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "trac-tex", + marktype = "mkiv", + status = "okay", + comment = "needs more usage", + }, + { + filename = "trac-deb", + marktype = "mkiv", + status = "okay", + }, + { + filename = "supp-box", + marktype = "mkiv", + status = "okay", + }, + { + filename = "supp-vis", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "supp-fun", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "supp-ran", + marktype = "mkiv", + status = "okay", + }, + { + filename = "supp-mat", + marktype = "mkiv", + status = "okay", + comment = "will be moved to the math-* modules", + }, + { + filename = "supp-ali", + marktype = "mkiv", + status = "unknown", + comment = "will be reimplemented", + }, + { + filename = "supp-num", + marktype = "mkiv", + status = "obsolete", + comment = "replaced by units", + }, + { + filename = "typo-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-ins", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "file-syn", + marktype = "mkvi", + status = "okay", + }, + { + filename = "file-mod", + marktype = "mkvi", + status = "unknown", + }, + { + filename = "core-con", + marktype = "mkiv", + status = "okay", + }, + { + filename = "cont-fil", + marktype = "mkiv", + status = "okay", + }, + { + filename = "regi-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "enco-ini", + marktype = "mkiv", + status = "messy", + }, + { + filename = "hand-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lang-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lang-lab", + marktype = "mkiv", + status = "okay", + comment = "namespace should be languages", + }, + { + filename = "unic-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "core-uti", + marktype = "mkiv", + status = "okay", + }, + { + filename = "core-two", + marktype = "mkiv", + status = "okay", + }, + { + filename = "colo-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "colo-ext", + marktype = "mkiv", + status = "okay", + }, + { + filename = "colo-grp", + marktype = "mkiv", + status = "okay", + }, + { + filename = "node-bck", + marktype = "mkiv", + status = "okay", + }, + { + filename = "trac-vis", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "lang-mis", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lang-url", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lang-def", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lang-wrd", + marktype = "mkiv", + status = "okay", + }, + { + filename = "file-job", + marktype = "mkvi", + status = "okay", + comment = "might need more redoing", + }, + { + filename = "symb-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "sort-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "pack-mis", + marktype = "mkvi", + status = "okay", + }, + { + filename = "pack-rul", + marktype = "mkiv", + status = "okay", + comment = "namespace to be done", + }, + { + filename = "pack-mrl", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "pack-bck", + marktype = "mkvi", + status = "okay", + }, + { + filename = "pack-fen", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lxml-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lxml-sor", + marktype = "mkiv", + status = "okay", + }, + { + filename = "typo-prc", + marktype = "mkvi", + status = "okay", + }, + { + filename = "strc-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-tag", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-doc", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-num", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-mar", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-sbe", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-lst", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-sec", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-pag", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-ren", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-xml", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-def", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-ref", + marktype = "mkvi", + status = "unknown", + }, + { + filename = "strc-reg", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-lev", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "spac-hor", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "spac-ver", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "spac-ali", + marktype = "mkiv", + status = "unknown", + comment = "will be rewritten", + }, + { + filename = "spac-pag", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "spac-fnt", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "spac-par", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "spac-def", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "spac-grd", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "anch-pos", + marktype = "mkiv", + status = "okay", + }, + { + filename = "scrn-ini", + marktype = "mkvi", + status = "okay", + comment = "maybe change locationattribute names" + }, + { + filename = "scrn-ref", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "pack-obj", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-itm", + marktype = "mkvi", + status = "okay", + }, + { + filename = "strc-des", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-syn", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "core-sys", + marktype = "mkiv", + status = "okay", + comment = "a funny mix", + }, + { + filename = "page-var", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-fac", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-brk", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-col", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-inf", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-grd", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-flt", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-bck", + marktype = "mkiv", + status = "okay", + }, + { + filename = "page-not", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-one", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-lay", + marktype = "mkiv", + status = "okay", + }, + { + filename = "page-box", + marktype = "mkvi", + status = "okay", + }, + { + filename = "page-txt", + marktype = "mkvi", + status = "okay", + }, + { + filename = "page-sid", + marktype = "mkiv", + status = "okay", + }, + { + filename = "strc-flt", + marktype = "mkvi", + status = "unknown", + }, + { + filename = "page-mis", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-mbk", + marktype = "mkvi", + status = "unknown", + }, + { + filename = "page-mul", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-set", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "pack-lyr", + marktype = "mkiv", + status = "okay", + }, + { + filename = "pack-pos", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-mak", + marktype = "mkvi", + status = "unknown", + }, + { + filename = "page-lin", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-par", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-pag", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-mar", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "file-job", + marktype = "mkvi", + status = "unknown", + }, + { + filename = "buff-ini", + marktype = "mkiv", + status = "okay", + comment = "check other modules for buffer usage", + }, + { + filename = "buff-ver", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "buff-par", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "buff-imp-tex", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "buff-imp-mp", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "buff-imp-lua", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "buff-imp-xml", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "buff-imp-parsed-xml", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-blk", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-imp", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-sel", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-com", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "scrn-pag", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "scrn-wid", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "scrn-but", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "scrn-bar", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "strc-bkm", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-com", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-pln", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-tab", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-tbl", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-ntb", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-nte", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-ltb", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-tsp", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "tabl-xtb", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "java-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "scrn-fld", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "scrn-hlp", + marktype = "mkvi", + status = "okay", + comment = "namespace needs checking" + }, + { + filename = "char-enc", + marktype = "mkiv", + status = "okay", + }, + { + filename = "font-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "font-unk", + marktype = "mkiv", + status = "okay", + }, + { + filename = "font-tra", + marktype = "mkiv", + status = "okay", + comment = "likely this will become a module", + }, + { + filename = "font-uni", + marktype = "mkiv", + status = "okay", + comment = "this one might be merged", + }, + { + filename = "font-col", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "font-gds", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lxml-css", + marktype = "mkiv", + status = "okay", + comment = "this is work in progress", + }, + { + filename = "spac-chr", + marktype = "mkiv", + status = "okay", + }, + { + filename = "blob-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-cln", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-spa", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-krn", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-itc", + marktype = "mkvi", + status = "okay", + }, + { + filename = "typo-dir", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-brk", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-cap", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-dig", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-rep", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "typo-txt", + marktype = "mkvi", + status = "okay", + comment = "maybe there will be a nicer interface", + }, + { + filename = "typo-par", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "type-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "type-set", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "type-def", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "type-lua", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "scrp-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "prop-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "mlib-ctx", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "meta-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "meta-tex", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "meta-fun", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "meta-pag", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-mrk", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-flw", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-spr", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-plg", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-str", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "anch-pgr", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "anch-bck", + marktype = "mkvi", + status = "unknown", + }, + { + filename = "anch-tab", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "anch-bar", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "anch-snc", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-pln", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-for", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-def", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-ali", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-arr", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-frc", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-scr", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-int", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-del", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-inl", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "math-dis", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "phys-dim", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-mat", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "chem-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "chem-str", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "core-fnt", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "node-rul", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "node-spl", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-not", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "strc-lnt", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "core-mis", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "grph-trf", + marktype = "mkiv", + status = "okay", + comment = "namespace has to be made consistent" + }, + { + filename = "grph-inc", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "grph-fig", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "grph-raw", + marktype = "mkiv", + status = "okay", + }, + { + filename = "pack-box", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "pack-bar", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "page-app", + marktype = "mkiv", + status = "okay", + }, + { + filename = "meta-fig", + marktype = "mkiv", + status = "okay", + }, + { + filename = "lang-spa", + marktype = "mkiv", + status = "okay", + comment = "more or less obsolete" + }, + { + filename = "bibl-bib", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "bibl-tra", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "meta-xml", + marktype = "mkiv", + status = "okay", + comment = "not needed" + }, + { + filename = "cont-log", + marktype = "mkiv", + status = "okay", + }, + { + filename = "task-ini", + marktype = "mkiv", + status = "okay", + }, + { + filename = "cldf-ver", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "cldf-com", + marktype = "mkiv", + status = "okay", + }, + { + filename = "core-ctx", + marktype = "mkiv", + status = "okay", + }, + { + filename = "core-ini", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "core-def", + marktype = "mkiv", + status = "unknown", + }, + { + filename = "back-pdf", + marktype = "mkiv", + status = "okay", + comment = "object related code might move or change", + }, + { + filename = "mlib-pdf", + marktype = "mkiv", + status = "okay", + }, + { + filename = "mlib-pps", + marktype = "mkiv", + status = "okay", + }, + { + filename = "meta-pdf", + marktype = "mkiv", + status = "okay", + }, + { + filename = "grph-epd", + marktype = "mkiv", + status = "okay", + comment = "might need more work", + }, + { + filename = "back-exp", + marktype = "mkiv", + status = "okay", + comment = "some parameters might move from export to backend" + }, + } +} diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex new file mode 100644 index 000000000..922df9ec1 --- /dev/null +++ b/tex/context/base/status-mkiv.tex @@ -0,0 +1,83 @@ +\setupbodyfont[dejavu,10pt] + +\setuplayout + [width=middle, + height=middle, + backspace=1cm, + topspace=1cm, + footer=0pt, + header=1.25cm] + +\setuphead + [subject] + [style=\bfa] + +\setuppagenumbering + [location=] + +\setupheadertexts + [\currentdate][MkIV cleanup Status / Page \pagenumber] + +\starttext + +\startsubject[title=Todo] + +\startitemize[packed] + \startitem currently the new namespace prefixes are not consistent but this + will be done when we're satisfied with one scheme \stopitem + \startitem there will be additional columns in the table, like for namespace + so we need another round of checking then \stopitem + \startitem the imp modules are not in the list and needs checking too \stopitem + \startitem the s, x, m modules will be checked, redone and reorganized \stopitem + \startitem the lua code will be cleaned up upgraded as some is quite old + and experimental \stopitem + \startitem we need a proper dependency tree and better defined loading order \stopitem + \startitem all dotag.. will be moved to the tags_.. namespace \stopitem + \startitem we need to check what messages are gone (i.e.\ clean up mult-mes) \stopitem + \startitem some commands can go from mult-def (and the xml file) \stopitem + \startitem check for setuphandler vs simplesetuphandler \stopitem + \startitem all showcomposition etc can go (we can redo that in lua if needed) \stopitem +\stopitemize + +\stopsubject + +\startsubject[title=Status] + +\startluacode + + local coremodules = dofile("status-mkiv.lua") + + if coremodules then + + local preloaded = coremodules.preloaded + + if preloaded then + + context.starttabulate { "|Tr|Tl|Tl|l|p|" } + context.NC() -- context.bold("order") + context.NC() context.bold("file") + context.NC() context.bold("mark") + context.NC() context.bold("status") + context.NC() context.bold("comment") + context.NC() context.NR() + for i=1,#preloaded do + local module = preloaded[i] + local status = module.status + context.NC() context(i) + context.NC() context(module.filename) + context.NC() context(module.marktype) + context.NC() if status == "unknown" then context.italic(status) else context(status) end + context.NC() context(module.comment) + context.NC() context.NR() + end + context.stoptabulate() + + end + + end + +\stopluacode + +\stopsubject + +\stoptext diff --git a/tex/context/base/strc-blk.mkiv b/tex/context/base/strc-blk.mkiv index bb9e7563e..a632b38fb 100644 --- a/tex/context/base/strc-blk.mkiv +++ b/tex/context/base/strc-blk.mkiv @@ -45,8 +45,8 @@ \setuvalue{\e!begin#1}{\dodoubleempty\dobeginofblock[#1]}% \letvalue{\e!end#1}\relax} -\long\def\dobeginofblock[#1][#2]% - {\normalexpanded{\noexpand\dodowithbuffer{@block@}{\e!begin#1}{\e!end#1}} +\def\dobeginofblock[#1][#2]% + {\normalexpanded{\buffers_pickup{@block@}{\e!begin#1}{\e!end#1}} {}% before {\ctxcommand{savestructureblock("#1","#2","@block@")}}}% after diff --git a/tex/context/base/strc-des.mkiv b/tex/context/base/strc-des.mkiv index cd2cbc12f..a386b16cb 100644 --- a/tex/context/base/strc-des.mkiv +++ b/tex/context/base/strc-des.mkiv @@ -350,8 +350,8 @@ {\dodescriptionhandler\currentdescriptiontext}% {\dodescriptionhandler\currentdescriptionsample}}% \assignwidth - \descriptionsheadwidth {\descriptionlocationparameter\c!width} + \descriptionsheadwidth {\unhcopy\descriptionheadbox} \descriptionsheaddistance \setbox\descriptionheadbox\hbox @@ -1079,7 +1079,9 @@ %D much like indentation and indenting. We also assume start/stop %D usage or some explicit par. -\installcommandhandler \??ds {indentedtext} \??ds +\installcorenamespace{indentedtext} + +\installcommandhandler \??indentedtext {indentedtext} \??indentedtext %D \startbuffer %D \defineindentedtext[one][text=one] @@ -1130,8 +1132,8 @@ \doifnothing{\indentedtextparameter\c!sample} {\setindentedtextparameter\c!sample{\indentedtextparameter\c!text}}% \assignwidth - {\indented_text_width} {\indentedtextparameter\c!width} + {\indented_text_width} {\useindentedtextstyleandcolor\c!headstyle\c!headcolor \indentedtextparameter\c!sample \spr{\indentedtextparameter\c!separator}} diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi index 579890985..0a0b6badd 100644 --- a/tex/context/base/strc-flt.mkvi +++ b/tex/context/base/strc-flt.mkvi @@ -26,8 +26,12 @@ %D - less gobal mess %D - more mkiv-ish -\installframedcommandhandler \??fl {float} \??fl -\installframedcommandhandler \??kj {floatcaption} \??kj +\installcorenamespace{float} +\installcorenamespace{floatbuilder} +\installcorenamespace{floatcaption} + +\installframedcommandhandler \??float {float} \??float +\installframedcommandhandler \??floatcaption {floatcaption} \??floatcaption \let\setupfloats \setupfloat \let\setupcaption \setupfloatcaption @@ -361,7 +365,7 @@ \def\dogetfloatdata % precedes save ! {\doglobal\increment\noffloatpages \findtwopassdata{\s!float\s!data}{\noffloatpages}% - \iftwopassdatafound + \ifconditional\twopassdatafound \globallet\twopassfloatdata\twopassdata \else \globallet\twopassfloatdata\realpageno % \realfolio @@ -812,14 +816,14 @@ \global\sidefloatextrashift\zeropoint \doifassignmentelse{#settings}% {\begingroup - \getparameters[\??fl\??fl][\c!x=\zeropoint,\c!y=\zeropoint,#settings]% + \setupcurrentfloat[\c!x=\zeropoint,\c!y=\zeropoint,#settings]% \ifgridsnapping - \getnoflines\@@fly + \getnoflines{\floatparameter\c!y}% \global\sidefloatdownshift\noflines\lineheight \else - \global\sidefloatdownshift\@@fl@@fly + \global\sidefloatdownshift\floatparameter\c!y \fi - \global\sidefloatextrashift\@@fl@@flx + \global\sidefloatextrashift\floatparameter\c!x \endgroup} {\movedownsidefloat[#settings]}} @@ -1624,7 +1628,7 @@ \def\relocatecaptionright#1{\float_align_caption{\hbox to \tempfloatwidth{\hss#1}}} \def\relocatecaptionleft #1{\float_align_caption{\hbox to \tempfloatwidth{#1\hss}}} -\long\def\installfloatboxbuilder#1#2{\setvalue{\??kj:#1}{#2}} +\long\def\installfloatboxbuilder#1#2{\setvalue{\??floatbuilder#1}{#2}} \def\build_float_box {\global\setbox\floatbox\vbox @@ -1632,9 +1636,9 @@ \forgetall \let\floatcaptionarrangement\s!default \def\docommand##1% - {\doifdefined{\??kj:##1}{\def\floatcaptionarrangement{##1}\quitcommalist}}% + {\doifdefined{\??floatbuilder##1}{\def\floatcaptionarrangement{##1}\quitcommalist}}% \processcommacommand[\floatcaptionparameter\c!location]\docommand - \executeifdefined{\??kj:\floatcaptionarrangement}{\getvalue{\??kj:\s!default}}}} + \executeifdefined{\??floatbuilder\floatcaptionarrangement}{\getvalue{\??floatbuilder\s!default}}}} \def\locate_text_float {\let\next\float_align_caption diff --git a/tex/context/base/strc-itm.mkvi b/tex/context/base/strc-itm.mkvi index 0dc06b105..f4fb779fd 100644 --- a/tex/context/base/strc-itm.mkvi +++ b/tex/context/base/strc-itm.mkvi @@ -15,6 +15,11 @@ \registerctxluafile{strc-itm}{1.001} +%D Cleaning up this module happened around the time when Kate Bush came up +%D with the nicest numbered list of words: 50 Words For Snow. It's therefore +%D no surprise that I had that cd running several times when updating this +%D code. One of the highlights of 2011. + % todo: check breaks % todo: check grouping @@ -277,7 +282,19 @@ %D Defining and setup: -\installcommandhandler \??op {itemgroup} \??op +\installcorenamespace{itemgroup} +\installcorenamespace{itemgroupoption} +\installcorenamespace{itemgroupsetting} +\installcorenamespace{itemgroupkeyword} +\installcorenamespace{itemgroupalign} +\installcorenamespace{itemgrouplocal} +\installcorenamespace{itemgroupglobal} +\installcorenamespace{itemgroupdistance} +\installcorenamespace{itemgroupstack} +\installcorenamespace{itemgroupfirst} +\installcorenamespace{itemgroupstart} + +\installcommandhandler \??itemgroup {itemgroup} \??itemgroup \let\setupitemgroups\setupitemgroup @@ -294,16 +311,16 @@ %D Global states \def\itemgroups_store_continue_state#options#settings% - {\setxvalue{\??op:o:\currentitemgroup}{\itemgroups_process_options{#options}}% - \setgvalue{\??op:s:\currentitemgroup}{\setupcurrentitemgroup [#settings]}} + {\setxvalue{\??itemgroupoption \currentitemgroup}{\itemgroups_process_options{#options}}% + \setgvalue{\??itemgroupsetting\currentitemgroup}{\setupcurrentitemgroup [#settings]}} \def\itemgroups_fetch_continue_state - {\getvalue{\??op:o:\currentitemgroup}% - \getvalue{\??op:s:\currentitemgroup}} + {\getvalue{\??itemgroupoption \currentitemgroup}% + \getvalue{\??itemgroupsetting\currentitemgroup}} \def\itemgroups_reset_continue_state - {\letgvalue{\??op:o:\currentitemgroup}\relax - \letgvalue{\??op:s:\currentitemgroup}\relax} + {\letgvalue{\??itemgroupoption \currentitemgroup}\relax + \letgvalue{\??itemgroupsetting\currentitemgroup}\relax} \definevspacing[\v!item @0] [penalty:0] % allow \definevspacing[\v!item @10000] [penalty:10000] % no @@ -345,8 +362,8 @@ \let\itemgroupsecond\itemgroupfirst \let\itemgroupfirst\!!plusone \fi - \ifcsname\??op:k:\itemgroupsecond\endcsname - \csname\??op:k:\itemgroupsecond\endcsname + \ifcsname\??itemgroupkeyword\itemgroupsecond\endcsname + \csname\??itemgroupkeyword\itemgroupsecond\endcsname \else \itemgroups_set_symbol\itemgroupconstantvalue \fi @@ -357,51 +374,51 @@ \settrue\c_itemgroups_pack \fi} -\setvalue{\??op:k:\!!zerocount}{} % ignore 0 -\setvalue{\??op:k:\v!packed }{\itemgroups_process_set_option_pack} -\setvalue{\??op:k:\v!intro }{\settrue\c_itemgroups_intro} % here? not set to false -\setvalue{\??op:k:\v!autointro}{\settrue\c_itemgroups_auto_intro} -\setvalue{\??op:k:\v!broad }{\ifx\itemgroupfirst\empty - \let\itemgroupfirst\!!plusone - \fi - \letitemgroupparameter\c!factor\itemgroupfirst} -\setvalue{\??op:k:\v!text }{\settrue\c_itemgroups_text - \settrue\c_itemgroups_inline - \settrue\c_itemgroups_joined - \itemgroups_process_set_option_pack} -\setvalue{\??op:k:\v!columns }{\itemgroups_process_set_option_pack} -\setvalue{\??op:k:\v!before }{\settrue\c_itemgroups_before} -\setvalue{\??op:k:\v!after }{\settrue\c_itemgroups_after} -\setvalue{\??op:k:\v!nowhite }{\settrue\c_itemgroups_nowhite} -\setvalue{\??op:k:\v!margin }{\setitemgroupparameter\c!width{-2em}} % signal -\setvalue{\??op:k:\v!inmargin }{\setitemgroupparameter\c!width{-2em}} % signal -\setvalue{\??op:k:\v!atmargin }{\ifnum\c_itemgroups_nesting>\plusone - \setitemgroupparameter\c!width{0em}% - \fi} % signal -\setvalue{\??op:k:\v!intext }{\settrue\c_itemgroups_inline} -\setvalue{\??op:k:\v!loose }{\setfalse\c_itemgroups_optimize} -\setvalue{\??op:k:\v!fit }{\settrue\c_itemgroups_fitting} -\setvalue{\??op:k:\v!nofit }{\setfalse\c_itemgroups_fitting} -\setvalue{\??op:k:\v!paragraph}{\settrue\c_itemgroups_paragraph - \itemgroups_process_set_option_pack} -\setvalue{\??op:k:\v!joinedup }{\settrue\c_itemgroups_joined - \itemgroups_process_set_option_pack} -\setvalue{\??op:k:\v!serried }{\edef\itemgroupfirst{-\ifx\itemgroupfirst\empty1\else\itemgroupfirst\fi}% - \letitemgroupparameter\c!factor\itemgroupfirst} -\setvalue{\??op:k:\v!stopper }{\letitemgroupparameter\c!placestopper\v!yes} % keep {} -\setvalue{\??op:k:\v!unpacked }{\setfalse\c_itemgroups_pack} -\setvalue{\??op:k:\v!repeat }{\settrue\c_itemgroups_repeat} -\setvalue{\??op:k:\v!reverse }{\settrue\c_itemgroups_reverse} -\setvalue{\??op:k:\v!columns }{\settrue\c_itemgroups_columns} -\setvalue{\??op:k:\v!one }{\letitemgroupparameter\c!n\plusone} -\setvalue{\??op:k:\v!two }{\letitemgroupparameter\c!n\plustwo} -\setvalue{\??op:k:\v!three }{\letitemgroupparameter\c!n\plusthree} -\setvalue{\??op:k:\v!four }{\letitemgroupparameter\c!n\plusfour} -\setvalue{\??op:k:\v!five }{\letitemgroupparameter\c!n\plusfive} -\setvalue{\??op:k:\v!standard }{\setupcurrentitemgroup - [\c!width=1.5em,\c!factor=0,\c!distance=.5em,\c!inner=,\c!factor=0,% - \c!beforehead=,\c!afterhead=\blank,% - \c!before=\blank,\c!inbetween=\blank,\c!after=\blank]} +\setvalue{\??itemgroupkeyword\!!zerocount}{} % ignore 0 +\setvalue{\??itemgroupkeyword\v!packed }{\itemgroups_process_set_option_pack} +\setvalue{\??itemgroupkeyword\v!intro }{\settrue\c_itemgroups_intro} % here? not set to false +\setvalue{\??itemgroupkeyword\v!autointro}{\settrue\c_itemgroups_auto_intro} +\setvalue{\??itemgroupkeyword\v!broad }{\ifx\itemgroupfirst\empty + \let\itemgroupfirst\!!plusone + \fi + \letitemgroupparameter\c!factor\itemgroupfirst} +\setvalue{\??itemgroupkeyword\v!text }{\settrue\c_itemgroups_text + \settrue\c_itemgroups_inline + \settrue\c_itemgroups_joined + \itemgroups_process_set_option_pack} +\setvalue{\??itemgroupkeyword\v!columns }{\itemgroups_process_set_option_pack} +\setvalue{\??itemgroupkeyword\v!before }{\settrue\c_itemgroups_before} +\setvalue{\??itemgroupkeyword\v!after }{\settrue\c_itemgroups_after} +\setvalue{\??itemgroupkeyword\v!nowhite }{\settrue\c_itemgroups_nowhite} +\setvalue{\??itemgroupkeyword\v!margin }{\setitemgroupparameter\c!width{-2em}} % signal +\setvalue{\??itemgroupkeyword\v!inmargin }{\setitemgroupparameter\c!width{-2em}} % signal +\setvalue{\??itemgroupkeyword\v!atmargin }{\ifnum\c_itemgroups_nesting>\plusone + \setitemgroupparameter\c!width{0em}% + \fi} % signal +\setvalue{\??itemgroupkeyword\v!intext }{\settrue\c_itemgroups_inline} +\setvalue{\??itemgroupkeyword\v!loose }{\setfalse\c_itemgroups_optimize} +\setvalue{\??itemgroupkeyword\v!fit }{\settrue\c_itemgroups_fitting} +\setvalue{\??itemgroupkeyword\v!nofit }{\setfalse\c_itemgroups_fitting} +\setvalue{\??itemgroupkeyword\v!paragraph}{\settrue\c_itemgroups_paragraph + \itemgroups_process_set_option_pack} +\setvalue{\??itemgroupkeyword\v!joinedup }{\settrue\c_itemgroups_joined + \itemgroups_process_set_option_pack} +\setvalue{\??itemgroupkeyword\v!serried }{\edef\itemgroupfirst{-\ifx\itemgroupfirst\empty1\else\itemgroupfirst\fi}% + \letitemgroupparameter\c!factor\itemgroupfirst} +\setvalue{\??itemgroupkeyword\v!stopper }{\letitemgroupparameter\c!placestopper\v!yes} % keep {} +\setvalue{\??itemgroupkeyword\v!unpacked }{\setfalse\c_itemgroups_pack} +\setvalue{\??itemgroupkeyword\v!repeat }{\settrue\c_itemgroups_repeat} +\setvalue{\??itemgroupkeyword\v!reverse }{\settrue\c_itemgroups_reverse} +\setvalue{\??itemgroupkeyword\v!columns }{\settrue\c_itemgroups_columns} +\setvalue{\??itemgroupkeyword\v!one }{\letitemgroupparameter\c!n\plusone} +\setvalue{\??itemgroupkeyword\v!two }{\letitemgroupparameter\c!n\plustwo} +\setvalue{\??itemgroupkeyword\v!three }{\letitemgroupparameter\c!n\plusthree} +\setvalue{\??itemgroupkeyword\v!four }{\letitemgroupparameter\c!n\plusfour} +\setvalue{\??itemgroupkeyword\v!five }{\letitemgroupparameter\c!n\plusfive} +\setvalue{\??itemgroupkeyword\v!standard }{\setupcurrentitemgroup + [\c!width=1.5em,\c!factor=0,\c!distance=.5em,\c!inner=,\c!factor=0,% + \c!beforehead=,\c!afterhead=\blank,% + \c!before=\blank,\c!inbetween=\blank,\c!after=\blank]} \def\itemgroups_initialize_local {\setfalse\c_itemgroups_inline @@ -430,16 +447,16 @@ \global\letitemgroupparameter\c!maxwidth\!!zerocount } -\setvalue{\??op:1:\v!intro }{\settrue\c_itemgroups_intro } -\setvalue{\??op:1:\v!random }{\settrue\c_itemgroups_randomize} -\setvalue{\??op:1:\v!continue}{\settrue\c_itemgroups_continue } +\setvalue{\??itemgroupfirst\v!intro }{\settrue\c_itemgroups_intro } +\setvalue{\??itemgroupfirst\v!random }{\settrue\c_itemgroups_randomize} +\setvalue{\??itemgroupfirst\v!continue}{\settrue\c_itemgroups_continue } \def\itemgroups_preset_stage_one#options% {\processcommacommand[#options]\itemgroups_preset_stage_one_indeed} \def\itemgroups_preset_stage_one_indeed#option% - {\ifcsname\??op:1:#option\endcsname - \csname\??op:1:#option\endcsname + {\ifcsname\??itemgroupfirst#option\endcsname + \csname\??itemgroupfirst#option\endcsname \fi} \ifdefined\dotagsetitemgroup \else \let\dotagsetitemgroup\relax \fi @@ -688,36 +705,36 @@ \ifdefined\startcolumns \else \unexpanded\def\startcolumns[#settings]{} \fi \ifdefined\stopcolumns \else \unexpanded\def\stopcolumns {} \fi -\letvalue{\??op:a:\v!flushleft }\relax -\letvalue{\??op:a:\v!right }\relax -\letvalue{\??op:a:\v!flushright}\hfill -\letvalue{\??op:a:\v!left }\hfill -\letvalue{\??op:a:\v!middle }\hfil -\letvalue{\??op:a:\v!center }\hfil +\letvalue{\??itemgroupalign\v!flushleft }\relax +\letvalue{\??itemgroupalign\v!right }\relax +\letvalue{\??itemgroupalign\v!flushright}\hfill +\letvalue{\??itemgroupalign\v!left }\hfill +\letvalue{\??itemgroupalign\v!middle }\hfil +\letvalue{\??itemgroupalign\v!center }\hfil \def\itemgroups_left_sym_filler - {\csname\??op:a:\itemgroupparameter\c!symalign\endcsname} + {\csname\??itemgroupalign\itemgroupparameter\c!symalign\endcsname} % symbols + states \def\itemgroups_store_global_symbol#symbol% - {\letgvalue{\??op:g:\currentitemlevel}#symbol} + {\letgvalue{\??itemgroupglobal\currentitemlevel}#symbol} \def\itemgroups_store_local_symbol#symbol% - {\letgvalue{\??op:l:\currentitemlevel}#symbol} + {\letgvalue{\??itemgrouplocal\currentitemlevel}#symbol} \def\itemgroups_fetch_global_symbol - {\getvalue{\??op:g:\currentitemlevel}} + {\getvalue{\??itemgroupglobal\currentitemlevel}} \def\itemgroups_fetch_local_symbol - {\getvalue{\??op:l:\currentitemlevel}} + {\getvalue{\??itemgrouplocal\currentitemlevel}} \def\itemgroups_setup_symbol_default {\edef\itemgroups_asked_symbol{\itemgroupparameter\c!symbol}% \itemgroups_store_global_symbol\empty} \def\itemgroups_setup_symbol_continue - {\ifcsname\??op:g:\currentitemlevel\endcsname + {\ifcsname\??itemgroupglobal\currentitemlevel\endcsname \let\itemgroups_asked_symbol\itemgroups_fetch_global_symbol \else \let\itemgroups_asked_symbol\currentitemlevel @@ -1071,25 +1088,25 @@ \startitemgrouphead} \unexpanded\def\itemgroups_start_items - {\dosingleempty\itemgroups_start_items} + {\dosingleempty\itemgroups_start_items_indeed} -\unexpanded\def\itemgroups_start_items[#whatever]% something got lost +\unexpanded\def\itemgroups_start_items_indeed[#whatever]% something got lost {\itemgroups_start_edge {\dorecurse{0\itemgroupparameter\c!items}{\itemgroups_used_symbol\hss}% \unskip}} \unexpanded\def\startspecialitemgroupitem[#name]% - {\csname\??op:\e!start:\ifcsname#name\endcsname#name\else\v!item\fi\endcsname} + {\csname\??itemgroupstart\ifcsname\??itemgroupstart#name\endcsname#name\else\v!item\fi\endcsname} \unexpanded\def\stopspecialitemgroupitem {\stopitemgroupitem} -\letvalue{\??op:\e!start:\v!item}\itemgroups_start_do_item -\letvalue{\??op:\e!start:\v!sub }\itemgroups_start_subitem -\letvalue{\??op:\e!start:\v!sym }\itemgroups_start_symbol -\letvalue{\??op:\e!start:\v!ran }\itemgroups_start_edge -\letvalue{\??op:\e!start:\v!its }\itemgroups_start_items -\letvalue{\??op:\e!start:\v!mar }\itemgroups_start_margin +\letvalue{\??itemgroupstart\v!item}\itemgroups_start_do_item +\letvalue{\??itemgroupstart\v!sub }\itemgroups_start_subitem +\letvalue{\??itemgroupstart\v!sym }\itemgroups_start_symbol +\letvalue{\??itemgroupstart\v!ran }\itemgroups_start_edge +\letvalue{\??itemgroupstart\v!its }\itemgroups_start_items +\letvalue{\??itemgroupstart\v!mar }\itemgroups_start_margin \def\optimizelistitemsbreak {\ifcase\c_itemgroups_column_depth \ifconditional\c_itemgroups_optimize @@ -1292,15 +1309,15 @@ \itemgroups_check_for_repeated \ignorespaces} -\setvalue{\??op:d:\c!textdistance:\v!none}% +\setvalue{\??itemgroupdistance\c!textdistance:\v!none}% {\let\m_itemgroups_text_distance\zeropoint} \unexpanded\def\itemgroups_set_text_item_distance {\edef\m_itemgroups_text_distance{\itemgroupparameter\c!textdistance}% \ifx\m_itemgroups_text_distance\empty % - \else\ifcsname\??op:d:\c!textdistance:\m_itemgroups_text_distance\endcsname - \csname\??op:d:\c!textdistance:\m_itemgroups_text_distance\endcsname + \else\ifcsname\??itemgroupdistance\c!textdistance:\m_itemgroups_text_distance\endcsname + \csname\??itemgroupdistance\c!textdistance:\m_itemgroups_text_distance\endcsname \else \itemgroups_set_text_item_distance_indeed \fi\fi} @@ -1390,7 +1407,7 @@ \@EA\def\@EA\itemgroups_collected_store\@EA#\@EA1\csname\e!stop\v!item\endcsname % use grabuntil {\advance\c_itemgroups_collected_stored\plusone - \setvalue{\??op:x:\number\c_itemgroups_collected_stored}{\startitemgroupitem#1\stopitemgroupitem}} + \setvalue{\??itemgroupstack\number\c_itemgroups_collected_stored}{\startitemgroupitem#1\stopitemgroupitem}} \def\itemgroups_collected_flush {\ifconditional\c_itemgroups_randomize @@ -1398,9 +1415,9 @@ \else \advance\c_itemgroups_collected_current\plusone \fi - \doifdefined{\??op:x:\number\c_itemgroups_collected_current} - {\getvalue{\??op:x:\number\c_itemgroups_collected_current}% - \letbeundefined{\??op:x:\number\c_itemgroups_collected_current}% + \doifdefined{\??itemgroupstack\number\c_itemgroups_collected_current} + {\getvalue{\??itemgroupstack\number\c_itemgroups_collected_current}% + \letbeundefined{\??itemgroupstack\number\c_itemgroups_collected_current}% \advance\c_itemgroups_collected_done\plusone}% \ifnum\c_itemgroups_collected_done<\c_itemgroups_collected_stored \expandafter\itemgroups_collected_flush diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv index 6d7622a6a..043d23bb5 100644 --- a/tex/context/base/strc-lst.mkiv +++ b/tex/context/base/strc-lst.mkiv @@ -15,6 +15,8 @@ \registerctxluafile{strc-lst}{1.001} +% needs clean up + % nmstate -> no pagenumber if not start % autocrossdocument -> todo % expansion -> todo @@ -23,7 +25,13 @@ \unprotect -\installframedcommandhandler \??li {list} \??li +\installcorenamespace{list} +\installcorenamespace{listextras} +\installcorenamespace{listalternatives} +\installcorenamespace{listelement} +\installcorenamespace{listelementcommand} + +\installframedcommandhandler \??list {list} \??list \def\usenestedliststyleandcolor#1#2% will change {\useliststyleandcolor#1#2% @@ -124,9 +132,12 @@ {\endgroup} \def\dodostructurelistinject[#1][#2]% - {\getparameters[\??li\??li][\c!type=userdata,\c!location=\v!none,#1]% - \edef\currentlisttype {\@@li@@litype}% - \edef\currentlistlocation{\@@li@@lilocation}% +% {\getparameters[\??li\??li][\c!type=userdata,\c!location=\v!none,#1]% +% \edef\currentlisttype {\@@li@@litype}% +% \edef\currentlistlocation{\@@li@@lilocation}% + {\setupcurrentlist[\c!type=userdata,\c!location=\v!none,#1]% grouped + \edef\currentlisttype {\listparameter\c!type}% + \edef\currentlistlocation{\listparameter\c!location}% \setnextinternalreference \edef\currentlistnumber{\ctxlua{structures.lists.push{ references = { @@ -252,7 +263,7 @@ {\dodoubleargument\dodefinelistextra} \def\dodefinelistextra[#1][#2]% - {\getparameters[\??li:\c!extras:#1:][#2]} + {\getparameters[\??listextras#1:][#2]} % todo: more generic tracing @@ -260,8 +271,8 @@ [\v!page] [\c!before={\showmessage\m!system{14}{\currentlist/\currentlistindex}\page}] -\def\processlistextrabefore{\executeifdefined{\??li:\c!extras:\currentlistextra:\c!before}\relax} -\def\processlistextraafter {\executeifdefined{\??li:\c!extras:\currentlistextra:\c!after }\relax} +\def\processlistextrabefore{\executeifdefined{\??listextras\currentlistextra:\c!before}\relax} +\def\processlistextraafter {\executeifdefined{\??listextras\currentlistextra:\c!after }\relax} \unexpanded\def\processlistofstructure#1#2#3#4% name, method, n, extra {\ctxlua{structures.lists.pushnesting(#3)}% @@ -301,14 +312,14 @@ % TODO: also make this a commandhandler \def\listalternativeparameter#1% - {\ifcsname\??li\??li\listparameter\c!alternative#1\endcsname - \csname\??li\??li\listparameter\c!alternative#1\endcsname + {\ifcsname\??listalternatives\listparameter\c!alternative#1\endcsname + \csname\??listalternatives\listparameter\c!alternative#1\endcsname \else \listparameter{#1}% \fi} \unexpanded\def\setuplistalternative[#1]% - {\dodoubleargument\getparameters[\??li\??li#1]} + {\dodoubleargument\getparameters[\??listalternatives#1]} \def\listfill {\listalternativeparameter\c!command } \def\listskip {\listalternativeparameter\c!distance} @@ -544,22 +555,20 @@ % so far for list symbols -\def\@@dodolistelement{dodolistelement} - \def\dosomelistelement#1#2#3{#1 #2 #3} -\setvalue{\@@dodolistelement a}{\let\dosomelistelement\dodofixdlistelementABC} -\setvalue{\@@dodolistelement b}{\let\dosomelistelement\dodofixdlistelementABC} -\setvalue{\@@dodolistelement c}{\let\dosomelistelement\dodofixdlistelementABC} -\setvalue{\@@dodolistelement d}{\let\dosomelistelement\dodofixdlistelementD} -\setvalue{\@@dodolistelement e}{\let\dosomelistelement\dodofixdlistelementE} -\setvalue{\@@dodolistelement f}{\let\dosomelistelement\dodofixdlistelementF} -\setvalue{\@@dodolistelement g}{\let\dosomelistelement\dodofixdlistelementG} +\setvalue{\??listelement a}{\let\dosomelistelement\dodofixdlistelementABC} +\setvalue{\??listelement b}{\let\dosomelistelement\dodofixdlistelementABC} +\setvalue{\??listelement c}{\let\dosomelistelement\dodofixdlistelementABC} +\setvalue{\??listelement d}{\let\dosomelistelement\dodofixdlistelementD} +\setvalue{\??listelement e}{\let\dosomelistelement\dodofixdlistelementE} +\setvalue{\??listelement f}{\let\dosomelistelement\dodofixdlistelementF} +\setvalue{\??listelement g}{\let\dosomelistelement\dodofixdlistelementG} -\setvalue{\@@dodolistelement\v!none }{\def\dosomelistelement{\dodofreevlistelement}} -\setvalue{\@@dodolistelement\v!vertical }{\def\dosomelistelement{\dodofreevlistelement}} -\setvalue{\@@dodolistelement\v!horizontal}{\def\dosomelistelement{\dodofreehlistelement}} -\setvalue{\@@dodolistelement\v!command }{\let\dosomelistelement\dodocommandlistelement} +\setvalue{\??listelement\v!none }{\def\dosomelistelement{\dodofreevlistelement}} +\setvalue{\??listelement\v!vertical }{\def\dosomelistelement{\dodofreevlistelement}} +\setvalue{\??listelement\v!horizontal}{\def\dosomelistelement{\dodofreehlistelement}} +\setvalue{\??listelement\v!command }{\let\dosomelistelement\dodocommandlistelement} % \setuplist % [section] @@ -573,13 +582,13 @@ \unexpanded\def\definelistplacement {\dodoubleempty\dodefinelistplacement} -\def\dodefinelistplacement[#1][#2]% - {\setvalue{\@@dodolistelement#1}% +\def\dodefinelistplacement[#1][#2]% looks messy + {\setvalue{\??listelement#1}% {\doifelsenothing{#2} - {\getvalue{\@@dodolistelement\v!command}}% - {\executeifdefined{\@@dodolistelement#2}{\getvalue{\@@dodolistelement\v!command}}}% - \setlistparameter\c!command{\getvalue{\@@dodolistelement::#1}}}% - \setvalue{\@@dodolistelement::#1}} + {\getvalue{\??listelement\v!command}}% + {\executeifdefined{\??listelement#2}{\getvalue{\??listelement\v!command}}}% + \setlistparameter\c!command{\getvalue{\??listelementcommand#1}}}% + \setvalue{\??listelementcommand#1}} % don't mess arround with endgraf/grouping else we loose leftskip @@ -592,7 +601,7 @@ \ifx\currentlistalternative\empty [unknown list alternative]% \else - \executeifdefined{\@@dodolistelement\currentlistalternative}{[unknown list alternative: \currentlistalternative]}% + \executeifdefined{\??listelement\currentlistalternative}{[unknown list alternative: \currentlistalternative]}% \fi} \def\dodolistelement#1#2#3#4#5#6% @@ -907,8 +916,8 @@ % todo: make simple parameter handler -\def\combinedlistparameter#1{\csname\??ih\currentcombinedlist#1\endcsname} -\def\combinedlisttoks {\csname\??ih::\currentcombinedlist\endcsname} +\def\combinedlistparameter#1{\csname\??ih\currentcombinedlist#1\endcsname} % to be redone! +\def\combinedlisttoks {\csname\??ih::\currentcombinedlist\endcsname} % to be redone! \unexpanded\def\definecombinedlist {\dotripleempty\dodefinecombinedlist} @@ -918,8 +927,8 @@ \getparameters [\??ih#1] [\c!criterium=\v!local,\c!number=0,\c!list={#2},#3]% -\expandafter\newtoks\csname\??ih::\currentcombinedlist\endcsname -\combinedlisttoks{#3}% + \expandafter\newtoks\csname\??ih::\currentcombinedlist\endcsname + \combinedlisttoks{#3}% \setvalue{\e!setup#1\e!endsetup}{\dodoubleempty\dosetupcombinedlist[#1]}% \setvalue{\e!place#1}{\dodoubleempty\doplacecombinedlist[#1]}% \setvalue{\e!complete#1}{\dodoubleempty\docompletecombinedlist[#1]}} diff --git a/tex/context/base/strc-mar.lua b/tex/context/base/strc-mar.lua index 45a6be4e7..65d806a64 100644 --- a/tex/context/base/strc-mar.lua +++ b/tex/context/base/strc-mar.lua @@ -195,7 +195,7 @@ function marks.define(name,settings) settings = settings or { } data[name] = settings local parent = settings.parent - if parent == nil or parent == "" then + if parent == nil or parent == "" or parent == name then settings.parent = false else local dp = data[parent] diff --git a/tex/context/base/strc-mar.mkiv b/tex/context/base/strc-mar.mkiv index 5ae23ac75..dd18421f7 100644 --- a/tex/context/base/strc-mar.mkiv +++ b/tex/context/base/strc-mar.mkiv @@ -41,47 +41,28 @@ \definesystemattribute [marks] [global] -\let\currentmarking\empty +\installcorenamespace{marking} -\def\markingparameter #1{\csname\domarkingparameter{\??mk\currentmarking}#1\endcsname} -\def\namedmarkingparameter #1#2{\csname\domarkingparameter{\??mk#1}#2\endcsname} -\def\domarkingparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\domarkingparentparameter\csname#1\s!parent\endcsname#2\fi} -\def\domarkingparentparameter#1#2{\ifx#1\relax\s!empty\else\domarkingparameter#1#2\fi} +\installcommandhandler \??marking {marking} \??marking -\newconditional\inhibitgetmarking -\newconditional\inhibitsetmarking -\newtoks \everymarking - -\unexpanded\def\setupmarking - {\dodoubleargument\dosetupmarking} - -\def\dosetupmarking[#1][#2]% - {\ifsecondargument - \def\docommand##1{\getparameters[\??mk##1][#2]}% - \processcommalist[#1]\docommand - \else - \getparameters[\??mk][#1]% - \fi} +\newconditional\inhibitgetmarking % will become private +\newconditional\inhibitsetmarking % will become private -% management +\newtoks \everymarking -\unexpanded\def\definemarking {\dodoubleempty \dodefinemarking} -\unexpanded\def\relatemarking {\dodoubleempty \dorelatemarking} -\unexpanded\def\setmarking {\dosingleargument\dosetmarking } \let\marking\setmarking -\unexpanded\def\resetmarking {\dosingleargument\doresetmarking } -\unexpanded\def\synchronizemarking{\dotripleargument\dosynchronizemarking } +\unexpanded\def\relatemarking {\dodoubleempty \marking_relate } +\unexpanded\def\setmarking {\dosingleargument\marking_set } \let\marking\setmarking +\unexpanded\def\resetmarking {\dosingleargument\marking_reset } +\unexpanded\def\synchronizemarking{\dotripleargument\marking_synchronize} -\def\dodefinemarking[#1][#2]% marking parent - {\doifelsenothing{#2} - {\ctxcommand{definemarking("#1")}% - \getparameters[\??mk#1][\s!parent=\??mk]} - {\ctxcommand{definemarking("#1",{ parent = "#2" })}% - \getparameters[\??mk#1][\s!parent=\??mk#2]}} +\appendtoks + \ctxcommand{definemarking("\currentmarking",{ parent = "\currentmarkingparent" })}% +\to \everydefinemarking -\def\dorelatemarking[#1][#2]% +\def\marking_relate[#1][#2]% {\ctxcommand{relatemarking("#1","#2")}} -\def\dosetmarking[#1]#2% +\def\marking_set[#1]#2% {\ifconditional\inhibitsetmarking % nothing \else @@ -90,17 +71,17 @@ {\ctxcommand{setmarking("#1",\!!bs\detokenize{#2}\!!es)}}% \fi} -\def\doresetmarking[#1]% +\def\marking_reset[#1]% {\ctxcommand{resetmarking("#1")}} +\def\marking_synchronize[#1][#2][#3]% #1=class #2=boxnumber (some day also name) #3=options, maybe second argument table + {\ifvoid#2\else\ctxcommand{synchronizemarking("#1",\number#2,"#3")}\fi} + \def\doifelsemarking#1% {\ctxcommand{doifelsemarking("#1")}} -\def\dosynchronizemarking[#1][#2][#3]% #1=class #2=boxnumber (some day also name) #3=options, maybe second argument table - {\ifvoid#2\else\ctxcommand{synchronizemarking("#1",\number#2,"#3")}\fi} - % \appendtoks -% \dosynchronizemarking[\v!page][\normalpagebox][\v!keep]% keep if no marks +% \marking_synchronize[\v!page][\normalpagebox][\v!keep]% keep if no marks % \to \everybeforepagebody % defaults @@ -115,15 +96,15 @@ \unexpanded\def\getmarking {\ifconditional\inhibitgetmarking - \expandafter\dotripleargument\expandafter\nogetmarking + \expandafter\dotripleargument\expandafter\marking_get_nop \else - \expandafter\dotripleargument\expandafter\dogetmarking + \expandafter\dotripleargument\expandafter\marking_get_yes \fi} -\def\nogetmarking[#1][#2][#3]% +\def\marking_get_nop[#1][#2][#3]% {} -\def\dogetmarking[#1][#2][#3]% +\def\marking_get_yes[#1][#2][#3]% {\doif{\namedmarkingparameter{#1}\c!state}\v!start {\begingroup \setsystemmode\v!marking diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index e026a5986..6e5e0ad96 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -86,7 +86,7 @@ % better mark a note .. once flushed no more flushing %appendtoks \notesenabledfalse \to \everymarking -\appendtoks \notesenabledfalse \to \everypagebody +\appendtoks \notesenabledfalse \to \everybeforepagebody \appendtoks \notesenabledfalse \to \everystructurelist % quick hack %D Often we need to process the whole set of notes and to make that diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv index 8a6f463e4..3075b18be 100644 --- a/tex/context/base/strc-pag.mkiv +++ b/tex/context/base/strc-pag.mkiv @@ -316,12 +316,12 @@ \trackingmarginnotesfalse \fi \fi - \recalculatebackgrounds + \page_backgrounds_recalculate \dosetpagenumberlocation \to \everysetuppagenumbering -\ifdefined \recalculatebackgrounds \else - \let\recalculatebackgrounds\relax +\ifdefined \page_backgrounds_recalculate \else + \let\page_backgrounds_recalculate\relax \fi \ifdefined \dosetpagenumberlocation \else diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi index b6a644619..98cb7e46c 100644 --- a/tex/context/base/strc-ref.mkvi +++ b/tex/context/base/strc-ref.mkvi @@ -964,7 +964,9 @@ % to be done: interfaced -\installcommandhandler \??re {referenceformat} \??re +\installcorenamespace{referenceformat} + +\installcommandhandler \??referenceformat {referenceformat} \??referenceformat \appendtoks \setuevalue\currentreferenceformat{\execute_reference_format{\currentreferenceformat}}% diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index d18a729e6..cac338af6 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -61,7 +61,14 @@ % \c!file \c!grid \c!margintext % \c!expansion \c!xmlsetup \s!catcode -\installcommandhandler \??nh {head} \??nh +\installcorenamespace{head} +\installcorenamespace{headlevel} +\installcorenamespace{headincrement} +\installcorenamespace{headplace} +\installcorenamespace{headmarkyes} +\installcorenamespace{headmarknop} + +\installcommandhandler \??head {head} \??head \let\setupheads\setuphead % will go @@ -79,7 +86,7 @@ \normalexpanded {% \setheadparameter{\c!label}{\currenthead}% \setheadparameter{\c!coupling}{\currenthead}% - \setheadparameter{\s!parent}{\??nh\currentheadparent}% + \setheadparameter{\s!parent}{\??head\currentheadparent}% \definemarking[\currenthead] [\currentheadsection]% \definemarking[\currenthead\v!number][\currentheadsection]% \setupmarking [\currenthead] [\c!filtercommand=\noexpand\sectionheadmarkingtitle {\currenthead}]% @@ -164,24 +171,24 @@ \def\setnextsectionlevel#1% {\global\advance\maxstructuredepth\plusone - \setevalue{\??nh:\c!level:#1}{\the\maxstructuredepth}} + \setevalue{\??headlevel#1}{\the\maxstructuredepth}} \def\sectionlevel#1% - {\csname\??nh:\c!level:\ifcsname\??nh:\c!level:#1\endcsname#1\else\v!none\fi\endcsname} + {\csname\??headlevel\ifcsname\??headlevel#1\endcsname#1\else\v!none\fi\endcsname} -\setvalue{\??nh:\c!level:\v!block}{0} -\setvalue{\??nh:\c!level:\v!none }{-1} -\setvalue{\??nh:\c!level:\v!text }{-2} +\setvalue{\??headlevel\v!block}{0} +\setvalue{\??headlevel\v!none }{-1} +\setvalue{\??headlevel\v!text }{-2} \newtoks\everydefinesection \unexpanded\def\definesection[#1]% - {\ifcsname\??nh:\c!level:#1\endcsname \else + {\ifcsname\??headlevel#1\endcsname \else \edef\currentsection{#1}% not used, will go \edef\currenthead{#1}% \setnextsectionlevel{#1}% \setstructurelevel{#1}{\sectionlevel{#1}}% - \normalexpanded{\setheadparameter{\s!parent}{\??nh\lastsectionname}}% TO BE CHECKED + \normalexpanded{\setheadparameter{\s!parent}{\??head\lastsectionname}}% TO BE CHECKED, WE HAVE A HELPER \the\everydefinesection % so far for these default inheritances \definemarking[#1]% @@ -198,7 +205,7 @@ {\dotripleempty\dosetupsection} \def\dosetupsection[#1][#2][#3]% - {\ifcsname\??nh:\c!level:#1\endcsname + {\ifcsname\??headlevel#1\endcsname \dodosetupsection[#1][#2][#3]% \else \dodosetupsection[\sectionheadsection{#1}][#2][#3]% @@ -207,11 +214,9 @@ \def\dodosetupsection[#1][#2][#3]% {\pushmacro\currenthead \ifthirdargument - % \getparameters[\??nh#1#2][#3]% ? probably sectionblock \edef\currenthead{#1#2}% % not used at any more in mkiv (sets now) \setupcurrenthead[#3]% \else - % \getparameters[\??nh#1][#2]% \edef\currenthead{#1}% \setupcurrenthead[#2]% \fi @@ -298,15 +303,15 @@ \newconditional\headshownumber \newconditional\headisdisplay -\setvalue{\??nh:\c!incrementnumber:\v!yes }{\settrue \headdoincrement\settrue \headtolist} -\setvalue{\??nh:\c!incrementnumber:\v!no }{\setfalse\headdoincrement\setfalse\headtolist} -\setvalue{\??nh:\c!incrementnumber:\v!list }{\setfalse\headdoincrement\settrue \headtolist} -\setvalue{\??nh:\c!incrementnumber:\s!empty}{\settrue \headdoincrement\settrue \headtolist} +\setvalue{\??headincrement\v!yes }{\settrue \headdoincrement\settrue \headtolist} +\setvalue{\??headincrement\v!no }{\setfalse\headdoincrement\setfalse\headtolist} +\setvalue{\??headincrement\v!list }{\setfalse\headdoincrement\settrue \headtolist} +\setvalue{\??headincrement\s!empty}{\settrue \headdoincrement\settrue \headtolist} \def\setheadincrement {\edef\currentheadincrement{\headparameter\c!incrementnumber}% - \ifcsname\??nh:\c!incrementnumber:\currentheadincrement\endcsname - \csname\??nh:\c!incrementnumber:\currentheadincrement\endcsname + \ifcsname\??headincrement\currentheadincrement\endcsname + \csname\??headincrement\currentheadincrement\endcsname \else \settrue \headdoincrement\settrue \headtolist % \filterheadnumber @@ -320,30 +325,30 @@ % use : \currentheadincrement as spec \fi} -\setvalue{\??nh:\c!placehead:\v!yes}% +\setvalue{\??headplace\v!yes}% {\setfalse\headleaveempty \settrue \headdoplace \setfalse\headhidden} -\setvalue{\??nh:\c!placehead:\v!empty}% +\setvalue{\??headplace\v!empty}% {\settrue \headleaveempty \settrue \headdoplace \setfalse\headhidden} -\setvalue{\??nh:\c!placehead:\v!no}% +\setvalue{\??headplace\v!no}% {\settrue \headleaveempty \setfalse\headdoplace \setfalse\headhidden} -\setvalue{\??nh:\c!placehead:\v!hidden}% +\setvalue{\??headplace\v!hidden}% {\settrue \headleaveempty \setfalse\headdoplace \settrue \headhidden} \def\setheadplacement {\executeifdefined - {\??nh:\c!placehead:\headparameter\c!placehead} - {\getvalue{\??nh:\c!placehead:\v!yes}}} + {\??headplace\headparameter\c!placehead} + {\getvalue{\??headplace\v!yes}}} \def\setheaddisplay {\doifelsevalue{\??ns:\headparameter\c!alternative}\v!horizontal @@ -353,7 +358,7 @@ \newmode\v!sectionnumber \def\dosettructureheadnumbercontent - {\setsystemmode \v!sectionnumber + {\setsystemmode\v!sectionnumber \settrue\headshownumber} % why ? \def\doresettructureheadnumbercontent @@ -674,16 +679,16 @@ {\doifsomething{\headparameter#2}{\expanded{\setuplayouttext[#1][\c!state=\headparameter#2]}}} \donothing} -\setvalue{\??nh:\??mk:n:\v!page }{} -\setvalue{\??nh:\??mk:n:\v!reset}{\resetcurrentstructuremarks} -\setvalue{\??nh:\??mk:y:\v!page }{} % to be checked: {\resetcurrentstructuremarks} -\setvalue{\??nh:\??mk:y:\v!reset}{\resetcurrentstructuremarks} +\setvalue{\??headmarknop\v!page }{} +\setvalue{\??headmarknop\v!reset}{\resetcurrentstructuremarks} +\setvalue{\??headmarkyes\v!page }{} % to be checked: {\resetcurrentstructuremarks} +\setvalue{\??headmarkyes\v!reset}{\resetcurrentstructuremarks} \def\docheckheadlayout {\doifelsenothing{\headparameter\c!page} - {\getvalue{\??nh:\??mk:n:\headparameter\c!marking}} + {\getvalue{\??headmarknop\headparameter\c!marking}} {\page[\headparameter\c!page]% - \getvalue{\??nh:\??mk:y:\headparameter\c!marking}% + \getvalue{\??headmarkyes\headparameter\c!marking}% \dodocheckheadlayout\v!header\c!header \dodocheckheadlayout\v!text \c!text \dodocheckheadlayout\v!footer\c!footer}} diff --git a/tex/context/base/strc-syn.mkiv b/tex/context/base/strc-syn.mkiv index 7a9d5d3dd..535eab04b 100644 --- a/tex/context/base/strc-syn.mkiv +++ b/tex/context/base/strc-syn.mkiv @@ -51,7 +51,9 @@ \globallet#3\s!tex \fi} -\installsimplecommandhandler \??sm {synonym} \??sm +\installcorenamespace{synonym} + +\installsimplecommandhandler \??synonym {synonym} \??synonym \let\setupsynonyms\setupsynonym @@ -209,7 +211,9 @@ %D Sorting (a simplified version of synonym). -\installsimplecommandhandler \??so {sorting} \??so +\installcorenamespace{sorting} + +\installsimplecommandhandler \??sorting {sorting} \??sorting \setupsorting [\c!state=\v!start, @@ -304,7 +308,7 @@ \def\doplacelistofsorts[#1][#2]% NOG EEN RUWE VERSIE MAKEN ZONDER WITRUIMTE ETC ETC {\begingroup \def\currentsorting{#1}% - \getparameters[\??so#1][#2]% + \setupcurrentsorting[#2]% \startpacked \ctxlua{structures.synonyms.process('#1',{ criterium = "\sortingparameter\c!criterium", diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv index 7c4042348..c6dd93657 100644 --- a/tex/context/base/strc-tag.mkiv +++ b/tex/context/base/strc-tag.mkiv @@ -253,7 +253,7 @@ \appendtoks \dodisableelements \dodisabletagged -\to \everypagebody +\to \everybeforepagebody % \doifinelementelse{structure:section} {yes} {no} % \doifinelementelse{structure:chapter} {yes} {no} diff --git a/tex/context/base/supp-mat.mkiv b/tex/context/base/supp-mat.mkiv index e4cfd13e5..bc26611ae 100644 --- a/tex/context/base/supp-mat.mkiv +++ b/tex/context/base/supp-mat.mkiv @@ -96,20 +96,20 @@ %D %D An example of usage of the following can be found in the MathML module: -\long\def\displaymathematics#1{\relax\ifmmode#1\else\dostartformula{}#1\dostopformula\fi} - \def\inlinemathematics {\dontleavehmode\mathematics} - \def\automathematics {\relax\ifhmode\@EA\inlinemathematics\else\@EA\displaymathematics\fi} +\unexpanded\def\displaymathematics#1{\relax\ifmmode#1\else\dostartformula{}#1\dostopformula\fi} +\unexpanded\def\inlinemathematics {\dontleavehmode\mathematics} +\unexpanded\def\automathematics {\relax\ifhmode\expandafter\inlinemathematics\else\expandafter\displaymathematics\fi} % better, esp when used in bTABLE ... eTABLE -\def\automathematics +\unexpanded\def\automathematics {\relax \ifhmode \expandafter\inlinemathematics \else\ifintable - \expandafter\expandafter\expandafter\inlinemathematics + \doubleexpandafter\inlinemathematics \else - \expandafter\expandafter\expandafter\displaymathematics + \doubleexpandafter\displaymathematics \fi\fi} %D \macros @@ -216,8 +216,8 @@ %D %D \typebuffer \getbuffer -\def\cramped - {\mathpalette\docramped} +\unexpanded\def\cramped + {\mathpalette\math_cramped} %D We force a cramped style by issuing a non||existing radical (box). %D After that we make sure the height is correct. (Comment taken from @@ -245,7 +245,7 @@ % \ht\scratchbox-\scratchdimen % \box\scratchbox} -\def\docramped#1#2% +\def\math_cramped#1#2% {\begingroup % added HH, made even more cramped \setbox\scratchbox\hbox {\nulldelimiterspace\zeropoint @@ -295,13 +295,13 @@ %D Notice that \type {\clap{\cramped ... }} would also work, %D but it requires \TEX\ to typeset it arguments 16 times. -\def\docrampedllap#1#2{{}\dollap{\docramped #1{#2}}} -\def\docrampedrlap#1#2{{}\dorlap{\docramped #1{#2}}} -\def\docrampedclap#1#2{{}\doclap{\docramped #1{#2}}} +\unexpanded\def\crampedllap{\mathpalette\math_cramped_llap} +\unexpanded\def\crampedrlap{\mathpalette\math_cramped_rlap} +\unexpanded\def\crampedclap{\mathpalette\math_cramped_clap} -\def\crampedllap{\mathpalette\docrampedllap} -\def\crampedrlap{\mathpalette\docrampedrlap} -\def\crampedclap{\mathpalette\docrampedclap} +\def\math_cramped_llap#1#2{{}\dollap{\math_cramped #1{#2}}} +\def\math_cramped_rlap#1#2{{}\dorlap{\math_cramped #1{#2}}} +\def\math_cramped_clap#1#2{{}\doclap{\math_cramped #1{#2}}} % experiment, not yet to be used diff --git a/tex/context/base/supp-ran.mkiv b/tex/context/base/supp-ran.mkiv index a04d28247..356ed580f 100644 --- a/tex/context/base/supp-ran.mkiv +++ b/tex/context/base/supp-ran.mkiv @@ -18,13 +18,13 @@ \registerctxluafile{supp-ran}{1.001} -\def\getrandomcount #1#2#3{#1=\ctxcommand{getrandomcounta(\number#2,\number#3)}} -\def\getrandomdimen #1#2#3{#1=\ctxcommand{getrandomcounta(\number\dimexpr#2,\number\dimexpr#3)}\scaledpoint} -\def\getrandomnumber#1#2#3{\edef#1{\ctxcommand{getrandomcounta(\number#2,\number#3)}}} -\def\getrandomfloat #1#2#3{\edef#1{\ctxcommand{getrandomcountb(\number\dimexpr#2\points,\number\dimexpr#3\points)}}} -\def\setrandomseed #1{\ctxcommand{setrandomseed(\number#1)}} -\def\getrandomseed #1{\edef#1{\ctxcommand{getrandomseed()}}} -\def\freezerandomseed {\ctxcommand{freezerandomseed()}} -\def\defrostrandomseed {\ctxcommand{defrostrandomseed()}} +\unexpanded\def\getrandomcount #1#2#3{#1=\ctxcommand{getrandomcounta(\number#2,\number#3)}} +\unexpanded\def\getrandomdimen #1#2#3{#1=\ctxcommand{getrandomcounta(\number\dimexpr#2,\number\dimexpr#3)}\scaledpoint} +\unexpanded\def\getrandomnumber#1#2#3{\edef#1{\ctxcommand{getrandomcounta(\number#2,\number#3)}}} +\unexpanded\def\getrandomfloat #1#2#3{\edef#1{\ctxcommand{getrandomcountb(\number\dimexpr#2\points,\number\dimexpr#3\points)}}} +\unexpanded\def\setrandomseed #1{\ctxcommand{setrandomseed(\number#1)}} +\unexpanded\def\getrandomseed #1{\edef#1{\ctxcommand{getrandomseed()}}} +\unexpanded\def\freezerandomseed {\ctxcommand{freezerandomseed()}} +\unexpanded\def\defrostrandomseed {\ctxcommand{defrostrandomseed()}} \endinput diff --git a/tex/context/base/symb-ini.mkiv b/tex/context/base/symb-ini.mkiv index 8ccd8552f..0285a5641 100644 --- a/tex/context/base/symb-ini.mkiv +++ b/tex/context/base/symb-ini.mkiv @@ -43,96 +43,109 @@ %D \definesymbol [level 5] [$\star$] %D \stoptyping -% ss:tag -> symbol -% ss:set:tag -> symbol out of set -% ss*tag -> list of symbols in set +\installcorenamespace{symbol} +\installcorenamespace{symbolset} + +\newtoks\t_symbols_setups + +\let\m_symbols_current_set\empty + +\newconditional\c_symbols_found + +\newtoks\everysymbol + +%D We don't use the commandhandler as symbols have their own +%D subsystem for resolving values. \unexpanded\def\definesymbol - {\dotripleempty\dodefinesymbol} + {\dotripleempty\symbols_define} -\def\dodefinesymbol[#1][#2][#3]% class name meaning +\def\symbols_define[#1][#2][#3]% class name meaning {\ifthirdargument - \setvalue{\??ss:#1:#2}{#3}% - \doifsomething{#1}{\addvalue{\??ss*#1}{#2}}% + \setvalue{\??symbol#1:#2}{#3}% + \doifsomething{#1}{\addvalue{\??symbolset#1}{#2}}% \else - \setvalue{\??ss:\currentsymboldef:#1}{#2}% - \addvalue{\??ss*\currentsymboldef}{#1}% + \setvalue{\??symbol\m_symbols_current_set:#1}{#2}% + \addvalue{\??symbolset\m_symbols_current_set}{#1}% \fi} -\def\doifinsymbolsetelse#1#2{\ifcsname\??ss:#1:#2\endcsname\@EA\firstoftwoarguments\else\@EA\secondoftwoarguments\fi} -\def\doifinsymbolset #1#2{\ifcsname\??ss:#1:#2\endcsname\@EA\firstofoneargument \else\@EA\gobbleoneargument \fi} -\def\doifsymbolsetelse #1{\ifcsname\??ss*#1\endcsname \@EA\firstoftwoarguments\else\@EA\secondoftwoarguments\fi} +\letvalue{\??symbolset}\empty -\letvalue{\??ss*}\empty +\def\doifinsymbolsetelse#1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} +\def\doifinsymbolset #1#2{\ifcsname\??symbol#1:#2\endcsname\expandafter\firstofoneargument \else\expandafter\gobbleoneargument \fi} +\def\doifsymbolsetelse #1{\ifcsname\??symbolset#1\endcsname\expandafter\firstoftwoarguments\else\expandafter\secondoftwoarguments\fi} -\def\symbolset#1{\csname\??ss*\ifcsname\??ss*#1\endcsname#1\fi\endcsname} % no [#1], to be used in commalists etc +\def\symbolset#1{\csname\??symbolset\ifcsname\??symbolset#1\endcsname#1\fi\endcsname} % no [#1], to be used in commalists etc %D Since symbols are used frequently in interactive %D documents, we speed up this one. Well, that was history, %D since now we simplified things a bit, because the low %D level macros have been sped up every now and then. -\unexpanded\def\symbol % This one always gobbles spaces, - {\dodoubleempty\dosymbol} % so never change it again! - -\newif\ifnosymbol \newtoks\everysymbol - -\def\dodosymbol#1#2% \relax's prevent lookahead problems - {\nosymbolfalse - \begingroup - \the\everysymbol - \csname\??ss:#1:#2\endcsname\relax - \endgroup} - -\letvalue{\??ss:}\firstofoneargument - -\def\directsymbol#1#2% no \relax, there can be an argument, see lists - {\csname\??ss:\ifcsname\??ss:#1:#2\endcsname#1:#2\fi\endcsname} - % We support both: % % Test test \symbol[whatever]\ test \symbol[whatever]. % Test test \symbol{whatever} test \symbol{whatever}. -\def\dosymbol % so we also handle \symbol{name} +\unexpanded\def\symbol % This one always gobbles spaces, + {\dodoubleempty\symbols_place} % so never change it again! + +\def\symbols_place % so we also handle \symbol{name} {\iffirstargument % which is nicer with following spaces - \expandafter\donormalsymbol + \expandafter\symbols_place_normal \else - \expandafter\dospecialsymbol + \expandafter\symbols_place_special \fi} -\def\dospecialsymbol[#1][#2]#3% - {\firstargumenttrue - \secondargumentfalse - \donormalsymbol[#3][]} - -\def\donormalsymbol[#1][#2]% - {\nosymboltrue +\def\symbols_place_normal[#1][#2]% + {\setfalse\c_symbols_found \ifsecondargument \edef\currentsymbol{#2}% - \ifcsname\??ss:#1:#2\endcsname - \dodosymbol{#1}{#2}% + \ifcsname\??symbol#1:#2\endcsname + \symbols_place_indeed{#1:#2}% \fi \else \edef\currentsymbol{#1}% \fi - \ifnosymbol - \the\symbolsetups - \ifnosymbol - \redosymbol\currentsymbol + \ifconditional\c_symbols_found \else + \the\t_symbols_setups + \ifconditional\c_symbols_found \else + \symbols_place_retry\currentsymbol \fi \fi} -\def\fetchsymbol#1% - {\ifnosymbol - \ifcsname\??ss:#1:\currentsymbol\endcsname - \dodosymbol{#1}\currentsymbol - \fi +\def\symbols_place_special[#1][#2]#3% + {\firstargumenttrue + \secondargumentfalse + \symbols_place_normal[#3][]} + +\def\symbols_place_indeed#1% \relax's prevent lookahead problems + {\settrue\c_symbols_found + \begingroup + \the\everysymbol + \csname\??symbol#1\endcsname\relax + \endgroup} + +\letvalue{\??symbol}\firstofoneargument + +\def\directsymbol#1#2% no \relax, there can be an argument, see lists + {\csname\??symbol\ifcsname\??symbol#1:#2\endcsname#1:#2\fi\endcsname} + +\def\symbols_fetch + {\ifconditional\c_symbols_found + \expandafter\gobbleoneargument + \else + \expandafter\symbols_fetch_indeed \fi} -\def\redosymbol#1% - {\ifcsname\??ss::#1\endcsname - \dodosymbol\empty{#1}% +\def\symbols_fetch_indeed#1% + {\ifcsname\??symbol#1:\currentsymbol\endcsname + \symbols_place_indeed{#1:\currentsymbol}% + \fi} + +\def\symbols_place_retry#1% + {\ifcsname\??symbol:#1\endcsname + \symbols_place_indeed{:#1}% \else #1% \fi} @@ -150,23 +163,23 @@ \def\defaultsymbolfactor{10} \def\defaultsymbolheight{1.25ex} -\def\figuresymbol - {\dodoubleempty\dofiguresymbol} +\unexpanded\def\figuresymbol + {\dodoubleempty\symbols_figure} \ifdefined\externalfigure \else \def\externalfigure[#1][#2]{#1} \fi \ifdefined\resetexternalfigures \else \let\resetexternalfigures\relax \fi -\def\dofiguresymbol[#1][% #2]% +\def\symbols_figure[#1][% #2]% {\externalfigure[#1][\c!reset=\v!yes,\c!symbol=\v!yes,\c!height=\defaultsymbolheight,}% #2]} \appendtoks \resetexternalfigures \to \everysymbol \unexpanded\def\definefiguresymbol - {\dotripleempty\dodefinefiguresymbol} + {\dotripleempty\symbols_figure_define} -\def\dodefinefiguresymbol[#1][#2][#3]% +\def\symbols_figure_define[#1][#2][#3]% {\ifsecondargument - \definesymbol[#1][{\dofiguresymbol[#2][#3]}]% + \definesymbol[#1][{\symbols_figure[#2][#3]}]% \fi} %D \macros @@ -174,31 +187,34 @@ %D %D A handy private one: -% a bit messy - -\def\xfetchsymbol#1% - {\ifnosymbol - \doifinsymbolset{#1}\currentsymbol\nosymbolfalse +\def\symbols_fetch_first + {\ifconditional\c_symbols_found + \expandafter\gobbleoneargument + \else + \expandafter\symbols_fetch_first_indeed \fi} -\def\xredosymbol#1% - {\doifinsymbolset\empty\currentsymbol\nosymbolfalse} +\def\symbols_fetch_first_indeed#1% + {\doifinsymbolset{#1}\currentsymbol{\settrue\c_symbols_found}} + +\def\symbols_fetch_second#1% + {\doifinsymbolset\empty\currentsymbol{\settrue\c_symbols_found}} \def\doifsymboldefinedelse#1% {\begingroup \edef\currentsymbol{#1}% - \let\fetchsymbol\xfetchsymbol - \nosymboltrue - \the\symbolsetups - \ifnosymbol - \xredosymbol\currentsymbol - \ifnosymbol - \endgroup\@EAEAEA\secondoftwoarguments + \let\symbols_fetch\symbols_fetch_first + \setfalse\c_symbols_found + \the\t_symbols_setups + \ifconditional\c_symbols_found + \endgroup\expandafter\firstoftwoarguments + \else + \symbols_fetch_second\currentsymbol + \ifconditional\c_symbols_found + \endgroup\doubleexpandafter\firstoftwoarguments \else - \endgroup\@EAEAEA\firstoftwoarguments + \endgroup\doubleexpandafter\secondoftwoarguments \fi - \else - \endgroup\@EA\firstoftwoarguments \fi} %D \macros @@ -231,24 +247,21 @@ %D \showsetup{setupsymbolset} %D \showsetup{startsymbolset} -\let\currentsymboldef\empty - \unexpanded\def\startsymbolset[#1]% - {\def\currentsymboldef{#1}} + {\pushmacro\m_symbols_current_set + \def\m_symbols_current_set{#1}} \unexpanded\def\stopsymbolset - {\let\currentsymboldef\empty} - -\newtoks\symbolsetups + {\popmacro\m_symbols_current_set} \unexpanded\def\setupsymbolset[#1]% - {\prependtoksonce\fetchsymbol{#1}\to\symbolsetups} + {\prependtoksonce\symbols_fetch{#1}\to\t_symbols_setups} -\def\resetsymbolset - {\symbolsetups\emptytoks} +\unexpanded\def\resetsymbolset + {\t_symbols_setups\emptytoks} -\def\forcesymbolset[#1]% - {\symbolsetups{\fetchsymbol{#1}}} +\unexpanded\def\forcesymbolset[#1]% + {\t_symbols_setups{\symbols_fetch{#1}}} %D \macros %D {showsymbolset} diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 8b8c272a3..bb2423e5d 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -121,16 +121,22 @@ %D variables). Redefining these constants can have disastrous %D results. -\def\v!prefix! {v!} \def\c!prefix! {c!} -\def\s!prefix! {s!} \def\p!prefix! {p!} +\def\v!prefix! {v!} +\def\c!prefix! {c!} +\def\s!prefix! {s!} -\def\s!next {next} \def\s!default {default} -\def\s!dummy {dummy} \def\s!unknown {unknown} +\def\s!next {next} +\def\s!default {default} +\def\s!dummy {dummy} +\def\s!unknown {unknown} -\def\s!do {do} \def\s!dodo {dodo} +\def\s!do {do} +\def\s!dodo {dodo} -\def\s!complex {complex} \def\s!start {start} -\def\s!simple {simple} \def\s!stop {stop} +\def\s!complex {complex} +\def\s!start {start} +\def\s!simple {simple} +\def\s!stop {stop} \def\s!empty {empty} @@ -540,7 +546,7 @@ \unexpanded\def\doifalldefinedelse#1% {\begingroup - \donetrue + \donetrue % we could use a reserved one and avoid the group \processcommalist[#1]\do_if_all_defined_else \ifdone \endgroup\expandafter\firstoftwoarguments @@ -573,7 +579,7 @@ %D \doifelse {string1} {string2} {then ...}{else ...} %D \stoptyping -\def\doif#1#2% +\unexpanded\def\doif#1#2% {\edef\!!stringa{#1}% \edef\!!stringb{#2}% \ifx\!!stringa\!!stringb @@ -582,7 +588,7 @@ \expandafter\gobbleoneargument \fi} -\def\doifnot#1#2% +\unexpanded\def\doifnot#1#2% {\edef\!!stringa{#1}% \edef\!!stringb{#2}% \ifx\!!stringa\!!stringb @@ -591,7 +597,7 @@ \expandafter\firstofoneargument \fi} -\def\doifelse#1#2% +\unexpanded\def\doifelse#1#2% {\edef\!!stringa{#1}% \edef\!!stringb{#2}% \ifx\!!stringa\!!stringb @@ -613,7 +619,7 @@ %D %D This time, the string is not expanded. -\def\doifemptyelse#1% +\unexpanded\def\doifemptyelse#1% {\def\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\firstoftwoarguments @@ -621,7 +627,7 @@ \expandafter\secondoftwoarguments \fi} -\def\doifempty#1% +\unexpanded\def\doifempty#1% {\def\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\firstofoneargument @@ -629,7 +635,7 @@ \expandafter\gobbleoneargument \fi} -\def\doifnotempty#1% +\unexpanded\def\doifnotempty#1% {\def\!!stringa{#1}% \ifx\!!stringa\empty \expandafter\gobbleoneargument @@ -875,9 +881,11 @@ \fi\fi #1#2} +\def\do_common_check + {\expandafter\do_check_if_common_else_two\!!stringb,],\relax}% + \def\do_do_do_if_common_else - {\def\do_common_check{\expandafter\do_check_if_common_else_two\!!stringb,],\relax}% - \expandafter\do_check_if_common_else_one\!!stringa,],\relax} + {\expandafter\do_check_if_common_else_one\!!stringa,],\relax} \unexpanded\def\doifcommonelse{\do_do_if_common_else\firstoftwoarguments\secondoftwoarguments} \unexpanded\def\doifcommon {\do_do_if_common_else\firstofoneargument \gobbleoneargument } @@ -4269,8 +4277,8 @@ \def\HandleGroup#1#2% {\bgroup - \def\BeforeGroup{\bgroup#1\bgroup\aftergroup\AfterGroup}% - \def\AfterGroup {#2\egroup\egroup}% + \def\BeforeGroup{\bgroup#1\bgroup\aftergroup\AfterGroup}% can't we remove the second \bgroup + \def\AfterGroup {#2\egroup\egroup}% % and one \egroup here? \afterassignment\BeforeGroup \let\next=} @@ -5330,11 +5338,11 @@ %D arguments are sets. \def\do_if_all_common_else#1#2#3#4% slow - {\def\do_common_check##1% + {\def\do_common_check_all##1% {\doifnotinset{##1}{#4}\donefalse \ifdone\else\expandafter\quitcommalist\fi}% \donetrue - \processcommalist[#3]\do_common_check + \processcommalist[#3]\do_common_check_all \ifdone\expandafter#1\else\expandafter#2\fi} \def\doifallcommonelse{\do_if_all_common_else\firstoftwoarguments\secondoftwoarguments} @@ -6008,41 +6016,6 @@ \appendtoks \let\iftrialtypesetting\iftrue \to \everysettrialtypesetting \appendtoks \let\iftrialtypesetting\iffalse \to \everyresettrialtypesetting -%D \macros -%D {startlocal, startglobal} -%D -%D The next four macros are rather self explaining: -%D -%D \starttyping -%D \startlocal -%D whatever assignments -%D \stoplocal -%D -%D \startglobal -%D whatever assignments -%D \stopglobal -%D \stoptyping -%D -%D These macros are meant for those who know the difference -%D between local and global assignments and are aware of the -%D possible unwanted side effect - -\def\dostartglobaldefs#1#2% - {\scratchcounter\globaldefs - \ifnum\globaldefs#1\zerocount - \globaldefs-\globaldefs - \fi - \advance\globaldefs#2\plusone - \expandafter\chardef\csname@gd@\the\globaldefs\endcsname\scratchcounter} - -\def\dostopglobaldefs - {\globaldefs\ifcsname @gd@\the\globaldefs\endcsname\zerocount} - -\unexpanded\def\startlocal {\dostartglobaldefs>-} -\unexpanded\def\stoplocal {\dostopglobaldefs} -\unexpanded\def\startglobal {\dostartglobaldefs<+} -\unexpanded\def\stopglobal {\dostopglobaldefs} - %D \macros %D {twodigitrounding} %D diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index f79dfbf69..05dfc4412 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -1081,9 +1081,8 @@ {\vrule\!!width\tabulatevrulethickness\relax} \def\docoloredtabulatevrule - {\faststartcolor[\currenttabulatevrulecolor]% - \vrule\!!width\tabulatevrulethickness\relax - \faststopcolor} + {\dousecolorparameter\currenttabulatevrulecolor + \vrule\!!width\tabulatevrulethickness\relax} \unexpanded\def\dotabulatevrule {\ifcase\tabulatevrulethickness\else @@ -1164,9 +1163,8 @@ \relax} \def\docoloredtabulatehrule - {\faststartcolor[\currenttabulatelocalhrulecolor]% - \donormaltabulatehrule - \faststopcolor} + {\dousecolorparameter\currenttabulatelocalhrulecolor + \donormaltabulatehrule} \unexpanded\def\dotabulatehrule {\ifcase\tabulatelocalhrulethickness\else @@ -1186,9 +1184,8 @@ \hfill} \def\docoloredtabulatehlinerule - {\faststartcolor[\currenttabulatelocalhrulecolor]% - \donormaltabulatehlinerule - \faststopcolor} + {\dousecolorparameter\currenttabulatelocalhrulecolor + \donormaltabulatehlinerule} \def\dotabulatelinerule {\multispan\totaltabulatecolumns % \multispan is a plain macro @@ -1241,14 +1238,14 @@ \fi \setxvalue{\??tt:c:\the\tabulatecolumn}{#1}% \attribute\backgroundattribute\plusone - \faststartcolor[#1]\strut\char0\faststopcolor + \dousecolorparameter{#1}\strut\char\zerocount % hack \endgroup} \def\repeatsettabulatecolor {\begingroup \ifcsname\??tt:c:\the\tabulatecolumn\endcsname \attribute\backgroundattribute\plusone - \faststartcolor[\csname\??tt:c:\the\tabulatecolumn\endcsname]\strut\char0\faststopcolor + \expandafter\dousecolorparameter\csname\??tt:c:\the\tabulatecolumn\endcsname\strut\char\zerocount % hack \fi \endgroup} diff --git a/tex/context/base/tabl-xnt.mkvi b/tex/context/base/tabl-xnt.mkvi index 1794100af..1e7fefe2c 100644 --- a/tex/context/base/tabl-xnt.mkvi +++ b/tex/context/base/tabl-xnt.mkvi @@ -130,6 +130,6 @@ {\bgroup \x_table_prepare{#settings}% \edef\x_table_current_buffer{\x_table_default_buffer}% - \dodowithbuffer\x_table_current_buffer{bTABLE}{eTABLE}\relax\x_table_process} + \buffers_pickup\x_table_current_buffer{bTABLE}{eTABLE}\relax\x_table_process} \protect \endinput diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi index 58f980844..20036a869 100644 --- a/tex/context/base/tabl-xtb.mkvi +++ b/tex/context/base/tabl-xtb.mkvi @@ -74,8 +74,8 @@ % \let\tsplitafter \donothing % \let\postprocesstsplit \donothing -\let\dotagxtablecell \relax -\let\dotagxtablesignal\relax +\let\dotagxtablecell \relax % names will change +\let\dotagxtablesignal\relax % names will change \appendtoks \def\dotagxtablecell {\taggedctxcommand{settagtablecell(\number\tablecellrows,\number\tablecellcolumns,\number\raggedstatus)}}% @@ -99,7 +99,10 @@ % \setupxtable[one] [a=b,c=d] % \setupxtable [a=b,c=d] -\installframedautocommandhandler \??lt {xtable} \??lt +\installcorenamespace{xtable} +\installcorenamespace{xtablecheck} + +\installframedautocommandhandler \??xtable {xtable} \??xtable \appendtoks \checkxtableparent % so we can deal with undefined settings, not that it's efficient @@ -150,7 +153,7 @@ {\bgroup \x_table_prepare{#settings}% \edef\x_table_current_buffer{\x_table_default_buffer}% - \dodowithbuffer{\x_table_current_buffer}{startxtable}{stopxtable}\relax\x_table_process} + \buffers_pickup{\x_table_current_buffer}{startxtable}{stopxtable}\relax\x_table_process} \unexpanded\def\processxtablebuffer {\dosingleempty\process_x_table_buffer} @@ -212,7 +215,7 @@ \setupcurrentxtable[#settings]% \fi \edef\x_table_current_buffer{\x_table_default_buffer}% - \normalexpanded{\dodowithbuffer{\x_table_current_buffer}{\e!start\currentxtable}{\e!stop\currentxtable}\relax\x_table_process}} + \normalexpanded{\buffers_pickup{\x_table_current_buffer}{\e!start\currentxtable}{\e!stop\currentxtable}\relax\x_table_process}} \unexpanded\def\stop_named_x_table {} @@ -596,7 +599,7 @@ %D \typebuffer \placetable{}{\getbuffer} \appendtoks - \letvalue{\??lt\currentxtable\s!check}\relax % faster than checking parent + \letvalue{\??xtablecheck\currentxtable}\relax % faster than checking parent \to \everysetupxtable % groups @@ -610,7 +613,7 @@ \def\start_x_group_delayed_one[#tag]% % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname - {\ifcsname\??lt#tag\s!check\endcsname + {\ifcsname\??xtablecheck#tag\endcsname \expandafter\start_x_group_delayed_two \else \expandafter\setupcurrentxtable @@ -636,7 +639,7 @@ \def\start_x_cell_delayed_one[#tag]% % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname - {\ifcsname\??lt#tag\s!check\endcsname + {\ifcsname\??xtablecheck#tag\endcsname \expandafter\start_x_cell_delayed_two \else \expandafter\start_x_cell_yes @@ -661,7 +664,7 @@ \def\start_x_row_delayed_one[#tag]% % {\ifcsname\namedxtablehash{#tag}\s!parent\endcsname - {\ifcsname\??lt#tag\s!check\endcsname + {\ifcsname\??xtablecheck#tag\endcsname \expandafter\start_x_row_delayed_two \else \expandafter\start_x_row_yes @@ -678,7 +681,4 @@ {\stop_x_row \endgroup} -\protect - -% \continueifinputfile{tabl-xtb.mkvi} - +\protect \endinput diff --git a/tex/context/base/trac-deb.mkiv b/tex/context/base/trac-deb.mkiv index 89ec43694..4f5f0e931 100644 --- a/tex/context/base/trac-deb.mkiv +++ b/tex/context/base/trac-deb.mkiv @@ -16,22 +16,22 @@ \registerctxluafile{trac-lmx}{1.001} \registerctxluafile{trac-deb}{1.001} -\def\breakpoint{\showdebuginfo\wait} +\unexpanded\def\breakpoint{\showdebuginfo\wait} -\def\showtrackers {\ctxlua{trackers.show()}} -\def\enabletrackers [#1]{\ctxlua{trackers.enable("#1")}} -\def\disabletrackers [#1]{\ctxlua{trackers.disable("#1")}} -\def\resettrackers {\ctxlua{trackers.reset()}} +\unexpanded\def\showtrackers {\ctxlua{trackers.show()}} +\unexpanded\def\enabletrackers [#1]{\ctxlua{trackers.enable("#1")}} +\unexpanded\def\disabletrackers [#1]{\ctxlua{trackers.disable("#1")}} +\unexpanded\def\resettrackers {\ctxlua{trackers.reset()}} -\def\showdirectives {\ctxlua{directives.show()}} -\def\enabledirectives [#1]{\ctxlua{directives.enable("#1")}} -\def\disabledirectives [#1]{\ctxlua{directives.disable("#1")}} +\unexpanded\def\showdirectives {\ctxlua{directives.show()}} +\unexpanded\def\enabledirectives [#1]{\ctxlua{directives.enable("#1")}} +\unexpanded\def\disabledirectives [#1]{\ctxlua{directives.disable("#1")}} -\def\showexperiments {\ctxlua{experiments.show()}} -\def\enableexperiments [#1]{\ctxlua{experiments.enable("#1")}} -\def\disableexperiments[#1]{\ctxlua{experiments.disable("#1")}} +\unexpanded\def\showexperiments {\ctxlua{experiments.show()}} +\unexpanded\def\enableexperiments [#1]{\ctxlua{experiments.enable("#1")}} +\unexpanded\def\disableexperiments[#1]{\ctxlua{experiments.disable("#1")}} -\def\showdebuginfo{\ctxlua{lmx.showdebuginfo()}} -\def\overloaderror{\ctxlua{lmx.overloaderror()}} % \enabledirectives[system.showerror] +\unexpanded\def\showdebuginfo{\ctxlua{lmx.showdebuginfo()}} +\unexpanded\def\overloaderror{\ctxlua{lmx.overloaderror()}} % \enabledirectives[system.showerror] -\def\showlogcategories {\ctxlua{logs.show()}} +\unexpanded\def\showlogcategories {\ctxlua{logs.show()}} diff --git a/tex/context/base/trac-tex.mkiv b/tex/context/base/trac-tex.mkiv index 585419701..47ef92e54 100644 --- a/tex/context/base/trac-tex.mkiv +++ b/tex/context/base/trac-tex.mkiv @@ -26,17 +26,17 @@ \let\alltextracers\empty % so that we can report available tracers -\def\installtextracer#1% +\unexpanded\def\installtextracer#1% {\addtocommalist{#1}\alltextracers} -\def\enabletextracers [#1]{\processcommalist[#1]\doenabletextracer} -\def\disabletextracers[#1]{\processcommalist[#1]\dodisabletextracer} +\unexpanded\def\enabletextracers [#1]{\processcommalist[#1]\system_textracer_enable } +\unexpanded\def\disabletextracers[#1]{\processcommalist[#1]\system_textracer_disable} -\def\doenabletextracer #1{\csname enabletracer#1\endcsname} -\def\dodisabletextracer#1{\csname disabletracer#1\endcsname} +\def\system_textracer_enable #1{\csname enabletracer#1\endcsname} +\def\system_textracer_disable#1{\csname disabletracer#1\endcsname} % The next one is for Taco, although we can use directives as well: -\def\nomkivstatistics{\enabledirectives[system.nostatistics]} +\unexpanded\def\nomkivstatistics{\enabledirectives[system.nostatistics]} \protect \endinput diff --git a/tex/context/base/type-ini.mkiv b/tex/context/base/type-ini.mkiv index cb8bc5a50..f0b20cbed 100644 --- a/tex/context/base/type-ini.mkiv +++ b/tex/context/base/type-ini.mkiv @@ -400,7 +400,7 @@ \def\dofastdefinetypeface#1#2#3#4#5% {\dododefinetypeface[#1][#2]% \dostarttypefacedefining{#1}{#2}{#5}% - \usetypescript[#3][#4][\t!size]% + \usetypescript[#3][#4][\s!size]% \dostoptypefacedefining} \def\dodefinetypeface[#1][#2][#3][#4][#5][#6]% @@ -408,15 +408,15 @@ \iftracetypescripts\writestatus\m!fonts{define: [#1] [#2] [#3] [#4]}\fi \dododefinetypeface[#1][#2]% \dostarttypefacedefining{#1}{#2}{#6}% - \usetypescript[#3][#4][\t!name,\t!default]% - \usetypescript[#3][#5][\t!size]% + \usetypescript[#3][#4][\s!name,\s!default]% + \usetypescript[#3][#5][\s!size]% \dostoptypefacedefining \else\iffourthargument \iftracetypescripts\writestatus\m!fonts{define: [#1] [#2] [#3] [#4]}\fi \dododefinetypeface[#1][#2]% \dostarttypefacedefining{#1}{#2}{}% - \usetypescript[#3][#4][\t!name,\t!default]% - \usetypescript[#3][\s!default][\t!size]% + \usetypescript[#3][#4][\s!name,\s!default]% + \usetypescript[#3][\s!default][\s!size]% \dostoptypefacedefining \else\ifthirdargument \dododefinetypeface[#1][#2]% diff --git a/tex/context/base/type-otf.mkiv b/tex/context/base/type-otf.mkiv index 9c18f0546..7c915e77c 100644 --- a/tex/context/base/type-otf.mkiv +++ b/tex/context/base/type-otf.mkiv @@ -1742,55 +1742,45 @@ \stoptypescriptcollection -%D For some reason the libertine collection has not retained its -%D original names. We force the \OPENTYPE\ variant. Once these fonts -%D are stable we might switch to the by then hopefully cleaner internal -%D names. - \starttypescriptcollection[libertine] -% \starttypescript [serif] [libertine] [name] -% \setups[\s!font:\s!fallback:\s!serif] -% \definefontsynonym [\s!Serif] [\s!file:fxlr.otf] [\s!features=\s!default] -% \definefontsynonym [\s!SerifBold] [\s!file:fxlb.otf] [\s!features=\s!default] -% \definefontsynonym [\s!SerifItalic] [\s!file:fxlri.otf] [\s!features=\s!default] -% \definefontsynonym [\s!SerifBoldItalic] [\s!file:fxlbi.otf] [\s!features=\s!default] -% \stoptypescript - \starttypescript [serif] [libertine] - \definefontsynonym [Libertine-Regular] [\s!file:fxlr] - \definefontsynonym [Libertine-Italic] [\s!file:fxlri] - \definefontsynonym [Libertine-Bold] [\s!file:fxlb] - \definefontsynonym [Libertine-BoldItalic] [\s!file:fxlbi] - \definefontsynonym [Libertine-SmallCaps] [\s!file:fxlr] [\s!features=\s!smallcaps] + \definefontsynonym [Libertine-Regular] [\s!file:linlibertiner] + \definefontsynonym [Libertine-Italic] [\s!file:linlibertineri] + \definefontsynonym [Libertine-Slanted] [\s!file:linlibertinearl] + \definefontsynonym [Libertine-Bold] [\s!file:linlibertinerb] + \definefontsynonym [Libertine-BoldItalic] [\s!file:linlibertinerbi] + \definefontsynonym [Libertine-BoldSlanted] [\s!file:linlibertineabl] \stoptypescript \starttypescript [serif] [libertine] [name] \setups[\s!font:\s!fallback:\s!serif] - \definefontsynonym [\s!Serif] [Libertine-Regular] [\s!features=\s!default] - \definefontsynonym [\s!SerifItalic] [Libertine-Italic] [\s!features=\s!default] - \definefontsynonym [\s!SerifBold] [Libertine-Bold] [\s!features=\s!default] - \definefontsynonym [\s!SerifBoldItalic] [Libertine-BoldItalic] [\s!features=\s!default] - \definefontsynonym [\s!SerifCaps] [Libertine-Regular] [\s!features=\s!smallcaps] + \definefontsynonym [\s!Serif] [Libertine-Regular] [\s!features=\s!default] + \definefontsynonym [\s!SerifItalic] [Libertine-Italic] [\s!features=\s!default] + \definefontsynonym [\s!SerifSlanted] [Libertine-Slanted] [\s!features=\s!default] + \definefontsynonym [\s!SerifBold] [Libertine-Bold] [\s!features=\s!default] + \definefontsynonym [\s!SerifBoldItalic] [Libertine-BoldItalic] [\s!features=\s!default] + \definefontsynonym [\s!SerifBoldSlanted] [Libertine-BoldSlanted] [\s!features=\s!default] + \definefontsynonym [\s!SerifCaps] [Libertine-Regular] [\s!features=\s!smallcaps] \stoptypescript \starttypescript [sans] [biolinum] \setups[\s!font:\s!fallback:\s!sans] - \definefontsynonym [Biolinum-Regular] [\s!file:fxbr.otf] - \definefontsynonym [Biolinum-Bold] [\s!file:fxbb.otf] - \definefontsynonym [Biolinum-Italic] [\s!file:fxbri.otf] - \definefontsynonym [Biolinum-Slanted] [\s!file:fxbro.otf] - \definefontsynonym [Biolinum-BoldItalic] [\s!file:fxbbo.otf] + \definefontsynonym [Biolinum-Regular] [\s!file:linbiolinumr] + \definefontsynonym [Biolinum-Bold] [\s!file:linbiolinumrb] + \definefontsynonym [Biolinum-Italic] [\s!file:linbiolinumri] + \definefontsynonym [Biolinum-Slanted] [\s!file:linbiolinumarl] + \definefontsynonym [Biolinum-BoldSlanted] [\s!file:linbiolinumabl] \stoptypescript \starttypescript [sans] [biolinum] [name] \setups[\s!font:\s!fallback:\s!sans] - \definefontsynonym [\s!Sans] [Biolinum-Regular] [\s!features=\s!default] - \definefontsynonym [\s!SansBold] [Biolinum-Bold] [\s!features=\s!default] - \definefontsynonym [\s!SansItalic] [Biolinum-Italic] [\s!features=\s!default] - \definefontsynonym [\s!SansSlanted] [Biolinum-Slanted] [\s!features=\s!default] - \definefontsynonym [\s!SansBoldItalic] [Biolinum-BoldItalic] [\s!features=\s!default] - \definefontsynonym [\s!SansCaps] [Biolinum-Regular] [\s!features=\s!smallcaps] + \definefontsynonym [\s!Sans] [Biolinum-Regular] [\s!features=\s!default] + \definefontsynonym [\s!SansBold] [Biolinum-Bold] [\s!features=\s!default] + \definefontsynonym [\s!SansItalic] [Biolinum-Italic] [\s!features=\s!default] + \definefontsynonym [\s!SansSlanted] [Biolinum-Slanted] [\s!features=\s!default] + \definefontsynonym [\s!SansBoldItalic] [Biolinum-BoldSlanted] [\s!features=\s!default] + \definefontsynonym [\s!SansCaps] [Biolinum-Regular] [\s!features=\s!smallcaps] \stoptypescript \starttypescript [libertine] diff --git a/tex/context/base/typo-cap.mkiv b/tex/context/base/typo-cap.mkiv index fd520da59..80b5270d2 100644 --- a/tex/context/base/typo-cap.mkiv +++ b/tex/context/base/typo-cap.mkiv @@ -59,6 +59,15 @@ \unexpanded\def\Word {\groupedcommand{\setcharactercasing[\plusthree]}{}} \unexpanded\def\Words{\groupedcommand{\setcharactercasing[\plusfour ]}{}} +% this will become: +% +% \unexpanded\def\WORD {\bgroup\def\g_word{\setcharactercasing[\plusone ]}\afterassignment\g_word\let\nexttoken} +% \unexpanded\def\word {\bgroup\def\g_word{\setcharactercasing[\plustwo ]}\afterassignment\g_word\let\nexttoken} +% \unexpanded\def\Word {\bgroup\def\g_word{\setcharactercasing[\plusthree]}\afterassignment\g_word\let\nexttoken} +% \unexpanded\def\Words{\bgroup\def\g_word{\setcharactercasing[\plusfour ]}\afterassignment\g_word\let\nexttoken} +% +% so no longer {\Word test} and { } mandate (also later \groupedcommands will go) + \let\WORDS\WORD \let\words\word diff --git a/tex/context/base/typo-mar.mkiv b/tex/context/base/typo-mar.mkiv index 7702a9eaf..7ee182c39 100644 --- a/tex/context/base/typo-mar.mkiv +++ b/tex/context/base/typo-mar.mkiv @@ -99,8 +99,11 @@ %D argument concerns the data, the second the framed. Not sharing the setup is %D on purpose: location, offset, alignment and other parameters might clash. -\installcommandhandler \??mc {margindata} \??mc -\installframedcommandhandler \??mf {marginframed} \??mf +\installcorenamespace{margindata} +\installcorenamespace{marginframed} + +\installcommandhandler \??margindata {margindata} \??margindata +\installframedcommandhandler \??marginframed {marginframed} \??marginframed \setupmargindata [\c!location=\v!left, @@ -276,23 +279,25 @@ %D Another one: -% \letvalue{\??mc->\v!left }\v!right -% \letvalue{\??mc->\v!right }\v!left -% \letvalue{\??mc->\v!inner }\v!outer -% \letvalue{\??mc->\v!outer }\v!inner -% \letvalue{\??mc->\v!normal}\v!normal +% \installcorenamespace{oppositemargin} +% +% \letvalue{\??oppositemargin\v!left }\v!right +% \letvalue{\??oppositemargin\v!right }\v!left +% \letvalue{\??oppositemargin\v!inner }\v!outer +% \letvalue{\??oppositemargin\v!outer }\v!inner +% \letvalue{\??oppositemargin\v!normal}\v!normal % % \def\oppositemargin#1% -% {\csname\??mc->\ifcsname\??mc->#1\endcsname#1\else\v!normal\fi\endcsname} +% {\csname\??oppositemargin\ifcsname\??oppositemargin#1\endcsname#1\else\v!normal\fi\endcsname} %D Definitions: % common to lines and text -\setupmargindata [\v!left ] [\c!method=\v!first,\c!location=\v!left ,\c!margin=\v!margin,\c!align=\v!flushright,\s!parent=\??mc] % we could autoparent when no define yet -\setupmargindata [\v!right] [\c!method=\v!first,\c!location=\v!right,\c!margin=\v!margin,\c!align=\v!flushleft, \s!parent=\??mc] -\setupmargindata [\v!outer] [\c!method=\v!first,\c!location=\v!outer,\c!margin=\v!margin,\c!align=\v!inner, \s!parent=\??mc] -\setupmargindata [\v!inner] [\c!method=\v!first,\c!location=\v!inner,\c!margin=\v!margin,\c!align=\v!outer, \s!parent=\??mc] +\setupmargindata [\v!left ] [\c!method=\v!first,\c!location=\v!left ,\c!margin=\v!margin,\c!align=\v!flushright,\s!parent=\??margindata] % we could autoparent when no define yet +\setupmargindata [\v!right] [\c!method=\v!first,\c!location=\v!right,\c!margin=\v!margin,\c!align=\v!flushleft, \s!parent=\??margindata] +\setupmargindata [\v!outer] [\c!method=\v!first,\c!location=\v!outer,\c!margin=\v!margin,\c!align=\v!inner, \s!parent=\??margindata] +\setupmargindata [\v!inner] [\c!method=\v!first,\c!location=\v!inner,\c!margin=\v!margin,\c!align=\v!outer, \s!parent=\??margindata] % lines @@ -323,10 +328,10 @@ \definemargindata [margintext] [\v!left] [\c!margin=\v!margin,\c!width=\leftmarginwidth, \c!align=\v!flushright,\c!stack=\v!yes] -\setupmarginframed [\v!left ] [\c!method=\v!first,\c!align=\v!flushright,\s!parent=\??mf] % we could autoparent when no define yet -\setupmarginframed [\v!right] [\c!method=\v!first,\c!align=\v!flushleft, \s!parent=\??mf] -\setupmarginframed [\v!outer] [\c!method=\v!first,\c!align=\v!inner, \s!parent=\??mf] -\setupmarginframed [\v!inner] [\c!method=\v!first,\c!align=\v!outer, \s!parent=\??mf] +\setupmarginframed [\v!left ] [\c!method=\v!first,\c!align=\v!flushright,\s!parent=\??marginframed] % we could autoparent when no define yet +\setupmarginframed [\v!right] [\c!method=\v!first,\c!align=\v!flushleft, \s!parent=\??marginframed] +\setupmarginframed [\v!outer] [\c!method=\v!first,\c!align=\v!inner, \s!parent=\??marginframed] +\setupmarginframed [\v!inner] [\c!method=\v!first,\c!align=\v!outer, \s!parent=\??marginframed] \definemarginframed [inleft] [\v!left ] \definemarginframed [inright] [\v!right] diff --git a/tex/context/base/typo-par.mkiv b/tex/context/base/typo-par.mkiv index fa0f71117..358c31878 100644 --- a/tex/context/base/typo-par.mkiv +++ b/tex/context/base/typo-par.mkiv @@ -49,7 +49,9 @@ %D \placeinitial \input ward \par \input ward \placeinitial \input tufte %D \stoptyping -\installsimplecommandhandler \??dc {initial} \??dc +\installcorenamespace{initial} + +\installsimplecommandhandler \??initial {initial} \??initial \appendtoks \checkinitialparent % this might become automatic diff --git a/tex/context/base/typo-prc.mkvi b/tex/context/base/typo-prc.mkvi index 3bb743b8b..3c0fcc93e 100644 --- a/tex/context/base/typo-prc.mkvi +++ b/tex/context/base/typo-prc.mkvi @@ -44,10 +44,13 @@ %D Valid keys for defining a processor are \type {style}, \type {color}, \type {left}, %D \type {right}, and \type {command} (the given command takes one argument). -\installcommandhandler \??po {processor} \??po +\installcorenamespace{processor} +\installcorenamespace{processorcheck} + +\installcommandhandler \??processor {processor} \??processor \appendtoks - \letvalue{\??po\currentprocessor\s!check}\relax + \letvalue{\??processorcheck\currentprocessor}\relax \ctxcommand{registerstructureprocessor("\currentprocessor")}% global, but it permits using processor that are yet undefined \to \everydefineprocessor @@ -58,7 +61,7 @@ \unexpanded\def\applyprocessor#tag% {\def\currentprocessor{#tag}% - \ifcsname\??po\currentprocessor\s!check\endcsname + \ifcsname\??processorcheck\currentprocessor\endcsname \expandafter\apply_processor \else \expandafter\firstofoneargument diff --git a/tex/context/base/unic-ini.mkiv b/tex/context/base/unic-ini.mkiv index a46d264ae..55764dbdc 100644 --- a/tex/context/base/unic-ini.mkiv +++ b/tex/context/base/unic-ini.mkiv @@ -17,25 +17,21 @@ \unprotect -\let\keeputfcharacters\relax % used in xtag -\newconstant\utfunicodetracer % used in xtag - -%def\unicodechar #1{\char\numexpr#1\relax} % no lookahead \def\unicodenumber #1{\the \numexpr#1\relax} % no lookahead \def\unicodehexnumber#1{\cldcontext{number.toevenhex(\number#1))}} -%D Better is: -%D %D \startbuffer %D \unicodechar{left square bracket}okay\unicodechar{right square bracket} %D \stopbuffer %D %D \typebuffer \getbuffer -\def\unicodechar #1{\ctxcommand{unicodechar("#1")}} +%def\unicodechar#1{\char\numexpr#1\relax} % no lookahead +\def\unicodechar#1{\ctxcommand{unicodechar("#1")}} -\unexpanded\def\unknownchar{{\hbox{\vrule\!!width.5em\!!height1ex\!!depth\zeropoint}}} +\unexpanded\def\unknownchar + {\dontleavehmode\hbox{\vrule\!!width.5em\!!height1ex\!!depth\zeropoint}} -\ifx\zwnbsp\undefined \let\zwnbsp\relax \fi % zerowidthnonbreakablespace +\ifdefined\zwnbsp\else \let\zwnbsp\relax \fi % zerowidthnonbreakablespace \protect \endinput diff --git a/tex/context/base/x-xtag.mkiv b/tex/context/base/x-xtag.mkiv index c26b352b0..09490cc8f 100644 --- a/tex/context/base/x-xtag.mkiv +++ b/tex/context/base/x-xtag.mkiv @@ -18,6 +18,66 @@ \writestatus{xtag}{this module is obsolete, use the mkiv-xml features or use mkii instead} +%D Well, at this time (2011.12.28) I'm not sure if this code still works in +%D \MKIV. But in any case we move snippets here that are only needed for old +%D \MKII\ code. + +\unprotect + +\newif\ifforcefileexpansion % handy for document level overload + +\def\installexpander#1#2#3% changed, no longer \convert..\to... + {\setvalue{\s!do\c!expansion#1l}{#2}% + \setvalue{\s!do\c!expansion#1g}{#3}}% + +\def\doconvertexpanded#1#2#3% #4 % [l|g] \cs {kind} {data} + {\csname % that we assign all exp a value + \s!do\c!expansion + \ifforcefileexpansion + \v!yes + \else\ifcsname\s!do\c!expansion#3#1\endcsname + #3% + \else + \s!default + \fi\fi + #1% + \endcsname#2}% #3 + +\def\defconvertexpanded {\doconvertexpanded l} +\def\gdefconvertexpanded{\doconvertexpanded g} + +\installexpander\v!command \defconvertedcommand \gdefconvertedcommand +\installexpander\s!default \defconvertedargument \gdefconvertedargument +\installexpander\empty \defconvertedargument \gdefconvertedargument +\installexpander\v!no \defconvertedargument \gdefconvertedargument +\installexpander\v!yes \defconvertedmeaning \gdefconvertedmeaning +\installexpander\v!yes \defconvertedmeaning \gdefconvertedmeaning +\installexpander\v!strict \defreducedargument \gdefreducedargument +\installexpander {utf} \defreducedtoutf \gdefreducedtoutf + +\def\dodefconvertedmeaning#1#2#3% watch the double expansion ! + {\bgroup + \xdef\@@globalexpanded{#3}% + \xdef\@@globalexpanded{\@@globalexpanded}% + \egroup + #1#2\@@globalexpanded} + +\def\defconvertedmeaning {\dodefconvertedmeaning\defconvertedcommand} +\def\gdefconvertedmeaning{\dodefconvertedmeaning\gdefconvertedcommand} + +\def\dodefreducedargument#1#2#3% + {\begingroup + \reducetocoding[raw]% + \edef\ascii{#3}% + \expandafter\endgroup\expandafter#1\expandafter#2\expandafter{\ascii}} + +\def\defreducedargument {\dodefreducedargument\edef} +\def\gdefreducedargument{\dodefreducedargument\xdef} + +\protect + +%D The \XML\ modules. + \loadmarkfile{catc-xml} \loadcorefile{xtag-ini.mkii} diff --git a/tex/context/base/xtag-ini.mkii b/tex/context/base/xtag-ini.mkii index a1d5d7be5..79fb2f24d 100644 --- a/tex/context/base/xtag-ini.mkii +++ b/tex/context/base/xtag-ini.mkii @@ -16,6 +16,9 @@ %D Beware: don't rely on \longempty things, since this may %D change! +\ifdefined\keeputfcharacters \else \let\keeputfcharacters\relax \fi % for mkiv +\ifdefined\utfunicodetracer \else \newconstant\utfunicodetracer \fi % for mkiv + %D \macros %D {defineinputmode,setinputmode} %D diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml index fe13663f2..17c1ee535 100644 --- a/tex/context/interface/keys-cs.xml +++ b/tex/context/interface/keys-cs.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml index b7e891e58..457dfd73e 100644 --- a/tex/context/interface/keys-de.xml +++ b/tex/context/interface/keys-de.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml index d351f511b..24ae37452 100644 --- a/tex/context/interface/keys-en.xml +++ b/tex/context/interface/keys-en.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml index 0facadd4b..356b83747 100644 --- a/tex/context/interface/keys-fr.xml +++ b/tex/context/interface/keys-fr.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml index d28cacba1..b7bcdfeed 100644 --- a/tex/context/interface/keys-it.xml +++ b/tex/context/interface/keys-it.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml index 2d742834d..5c0a70d60 100644 --- a/tex/context/interface/keys-nl.xml +++ b/tex/context/interface/keys-nl.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml index de6f6aa6b..3d9e0b2a2 100644 --- a/tex/context/interface/keys-pe.xml +++ b/tex/context/interface/keys-pe.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml index d0d647620..8d4be42b6 100644 --- a/tex/context/interface/keys-ro.xml +++ b/tex/context/interface/keys-ro.xml @@ -628,6 +628,7 @@ + @@ -656,6 +657,7 @@ + @@ -1048,6 +1050,7 @@ + diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index afaef1878..9763c8c59 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 : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 12/23/11 09:52:45 +-- merge date : 12/31/11 13:16:01 do -- begin closure to overcome local limits and interference @@ -1942,8 +1942,8 @@ if not math.sind then end if not math.odd then - function math.odd (n) return n % 2 == 0 end - function math.even(n) return n % 2 ~= 0 end + function math.odd (n) return n % 2 ~= 0 end + function math.even(n) return n % 2 == 0 end end end -- closure -- cgit v1.2.3