summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/anch-pgr.mkiv8
-rw-r--r--tex/context/base/anch-tab.mkiv184
-rw-r--r--tex/context/base/buff-ver.mkiv2
-rw-r--r--tex/context/base/catc-ini.mkiv64
-rw-r--r--tex/context/base/cont-log.mkiv2
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv57
-rw-r--r--tex/context/base/context-version.pdfbin4146 -> 4141 bytes
-rw-r--r--tex/context/base/context-version.pngbin106156 -> 105732 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv14
-rw-r--r--tex/context/base/core-con.mkiv159
-rw-r--r--tex/context/base/core-def.mkiv114
-rw-r--r--tex/context/base/core-env.mkiv47
-rw-r--r--tex/context/base/core-ini.mkiv223
-rw-r--r--tex/context/base/core-var.mkiv254
-rw-r--r--tex/context/base/enco-ini.mkiv2
-rw-r--r--tex/context/base/file-ini.mkvi20
-rw-r--r--tex/context/base/file-job.mkvi7
-rw-r--r--tex/context/base/font-sty.mkvi2
-rw-r--r--tex/context/base/grph-raw.mkiv14
-rw-r--r--tex/context/base/grph-trf.mkiv137
-rw-r--r--tex/context/base/lang-lab.mkiv19
-rw-r--r--tex/context/base/lang-mis.mkiv2
-rw-r--r--tex/context/base/luat-ini.mkiv8
-rw-r--r--tex/context/base/lxml-ini.mkiv2
-rw-r--r--tex/context/base/math-ali.mkiv87
-rw-r--r--tex/context/base/math-arr.mkiv379
-rw-r--r--tex/context/base/math-for.mkiv15
-rw-r--r--tex/context/base/math-ini.mkiv18
-rw-r--r--tex/context/base/meta-ini.mkiv36
-rw-r--r--tex/context/base/mult-def.mkiv4
-rw-r--r--tex/context/base/mult-low.lua3
-rw-r--r--tex/context/base/mult-sys.mkiv120
-rw-r--r--tex/context/base/pack-bck.mkvi2
-rw-r--r--tex/context/base/pack-mrl.mkiv859
-rw-r--r--tex/context/base/pack-rul.mkiv19
-rw-r--r--tex/context/base/page-bck.mkiv132
-rw-r--r--tex/context/base/page-col.mkiv75
-rw-r--r--tex/context/base/page-com.mkiv176
-rw-r--r--tex/context/base/page-fac.mkiv48
-rw-r--r--tex/context/base/page-flt.mkiv175
-rw-r--r--tex/context/base/page-flw.mkiv186
-rw-r--r--tex/context/base/page-imp.mkiv3
-rw-r--r--tex/context/base/page-ini.mkiv4
-rw-r--r--tex/context/base/page-ins.mkiv90
-rw-r--r--tex/context/base/page-lay.mkiv76
-rw-r--r--tex/context/base/page-lin.lua9
-rw-r--r--tex/context/base/page-lin.mkiv523
-rw-r--r--tex/context/base/page-mbk.mkvi4
-rw-r--r--tex/context/base/page-mul.mkiv76
-rw-r--r--tex/context/base/page-not.mkiv10
-rw-r--r--tex/context/base/page-one.mkiv105
-rw-r--r--tex/context/base/page-plg.mkiv101
-rw-r--r--tex/context/base/page-pst.lua (renamed from tex/context/base/page-mis.lua)4
-rw-r--r--tex/context/base/page-pst.mkiv (renamed from tex/context/base/page-mis.mkiv)29
-rw-r--r--tex/context/base/page-sel.mkiv347
-rw-r--r--tex/context/base/page-sel.mkvi368
-rw-r--r--tex/context/base/page-set.mkiv42
-rw-r--r--tex/context/base/page-sid.mkiv9
-rw-r--r--tex/context/base/page-spr.mkiv90
-rw-r--r--tex/context/base/page-str.mkiv10
-rw-r--r--tex/context/base/page-txt.mkvi100
-rw-r--r--tex/context/base/regi-ini.lua3
-rw-r--r--tex/context/base/scrn-pag.mkvi6
-rw-r--r--tex/context/base/scrn-wid.lua12
-rw-r--r--tex/context/base/scrn-wid.mkvi107
-rw-r--r--tex/context/base/spac-def.mkiv36
-rw-r--r--tex/context/base/spac-grd.mkiv6
-rw-r--r--tex/context/base/spac-hor.mkiv6
-rw-r--r--tex/context/base/spac-ver.mkiv53
-rw-r--r--tex/context/base/status-files.pdfbin24466 -> 24505 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin182510 -> 182713 bytes
-rw-r--r--tex/context/base/status-mkiv.lua138
-rw-r--r--tex/context/base/status-mkiv.tex35
-rw-r--r--tex/context/base/strc-flt.mkvi74
-rw-r--r--tex/context/base/strc-ind.mkiv12
-rw-r--r--tex/context/base/strc-mat.mkiv450
-rw-r--r--tex/context/base/strc-num.mkiv26
-rw-r--r--tex/context/base/strc-pag.mkiv64
-rw-r--r--tex/context/base/strc-ref.lua1
-rw-r--r--tex/context/base/strc-ref.mkvi36
-rw-r--r--tex/context/base/strc-reg.mkiv2
-rw-r--r--tex/context/base/strc-tag.mkiv8
-rw-r--r--tex/context/base/supp-mat.mkiv7
-rw-r--r--tex/context/base/syst-aux.mkiv73
-rw-r--r--tex/context/base/syst-ini.mkiv26
-rw-r--r--tex/context/base/tabl-ntb.mkiv8
-rw-r--r--tex/context/base/tabl-tab.mkiv154
-rw-r--r--tex/context/base/tabl-tsp.mkiv6
-rw-r--r--tex/context/base/typo-brk.mkiv16
-rw-r--r--tex/context/base/typo-cap.mkiv25
-rw-r--r--tex/context/base/typo-del.mkiv31
-rw-r--r--tex/context/base/typo-spa.mkiv17
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
95 files changed, 3682 insertions, 3437 deletions
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv
index 130116bc7..01ef25dc4 100644
--- a/tex/context/base/anch-pgr.mkiv
+++ b/tex/context/base/anch-pgr.mkiv
@@ -365,11 +365,11 @@
\let\stopMPpositiongraphic\relax
\def\anch_positions_meta_graphic_prepare
- {\ifcsname\??gv\currentmpvariableclass:self\endcsname \else
- \letvalue{\??gv\currentmpvariableclass:self}\currentposition
+ {\ifcsname\??graphicvariable\currentmpvariableclass:self\endcsname \else
+ \letvalue{\??graphicvariable\currentmpvariableclass:self}\currentposition
\fi
- \ifcsname\??gv\currentmpvariableclass:from\endcsname \else
- \letvalue{\??gv\currentmpvariableclass:from}\currentposition
+ \ifcsname\??graphicvariable\currentmpvariableclass:from\endcsname \else
+ \letvalue{\??graphicvariable\currentmpvariableclass:from}\currentposition
\fi}
\def\anch_positions_meta_graphic_use#1#2#3%
diff --git a/tex/context/base/anch-tab.mkiv b/tex/context/base/anch-tab.mkiv
index 1b90d2476..2fb6938a2 100644
--- a/tex/context/base/anch-tab.mkiv
+++ b/tex/context/base/anch-tab.mkiv
@@ -13,6 +13,9 @@
\writestatus{loading}{ConTeXt Anchoring Macros / Table Extensions}
+%D This is just a playground and functionality might change or even
+%D dissappear in favour of better solutions.
+
\unprotect
\newcount\c_anch_tabs
@@ -57,23 +60,22 @@
\global\advance\c_anch_tabs\plusone
\to \everytabulate
-%D Beware, the following code is somewhat weird and experimental
-%D and might be dropped or become a loadable module.
+%D Beware, the following code is somewhat weird and experimental and might be
+%D dropped or become a loadable module.
%D \macros
%D {GFC, GTC, GSC}
%D
-%D The next macros extend tables and tabulation with
-%D backgrounds and position related features. Areas are
-%D specified with symbolic names, and symbolic references to
-%D the graphics involved. Each table has its own namespace.
+%D The next macros extend tables and tabulation with backgrounds and position
+%D related features. Areas are specified with symbolic names, and symbolic
+%D references to the graphics involved. Each table has its own namespace.
\newconditional\tablehaspositions
-\newcount\noftabpositions
-\newtoks \posXCtoks
+\newcount \noftabpositions
+\newtoks \posXCtoks
-\def\dotablebpos{\bpos}
-\def\dotableepos{\epos}
+\def\anch_tabulate_bpos{\bpos}
+\def\anch_tabulate_epos{\epos}
\installcorenamespace{positiontables}
@@ -85,74 +87,80 @@
\let\tabulatepos\tablepos
-\def\dodododoGSC[#1:#2]%
- {\remappositionframed{#2}{\tbPOSprefix#1}%
- \dotablebpos{\tbPOSprefix#1}%
- \doglobal\appendtoks\@EA\dotableepos\@EA{\tbPOSprefix#1}\to\posXCtoks}
+\unexpanded\def\tbXC {\dosingleempty\anch_tables_XC }
+\unexpanded\def\tbGSC{\dosingleempty\anch_tables_GSC}
+\unexpanded\def\tbGFC{\dosingleempty\anch_tables_GFC}
+\unexpanded\def\tbGTC{\dosingleempty\anch_tables_GTC}
-\def\dododoGSC[#1:#2:#3]%
- {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC}
+\def\anch_table_check_state
+ {\iftrialtypesetting
+ \global\settrue\tablehaspositions
+ \firstargumentfalse
+ \fi}
-\def\dodoGSC[#1]%
- {\def\docommand##1{\dododoGSC[##1:##1]}%
- \processcommalist[#1]\docommand}
+\def\anch_tables_XC [#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_XC [#1]\else\expandafter\fi\NC}
+\def\anch_tables_GSC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GSC[#1]\else\expandafter\NC\fi}
+\def\anch_tables_GFC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GFC[#1]\else\expandafter\NC\fi}
+\def\anch_tables_GTC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GTC[#1]\else\expandafter\NC\fi}
-\def\dodododoGFC[#1:#2:#3]%
- {\remappositionframed{#2}{\tbPOSprefix#1}%
- \dotablebpos{\tbPOSprefix#1}}
+\def\anch_tables_indeed_XC[#1]%
+ {{\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}}
-\def\dododoGFC[#1]%
- {\def\docommand##1{\dodododoGFC[##1:##1]}%
- \processcommalist[#1]\docommand}
+\def\anch_tables_step_XC#1%
+ {\anch_tables_step_indeed_XC[#1]}
-\def\dodoGFC[#1]%
- {\doglobal\appendtoks\dododoGFC[#1]\to\posXCtoks\NC}
+\def\anch_tables_step_indeed_XC[#1#2]%
+ {\if#1>\anch_tables_indeed_GFC [#2:#2]\else
+ \if#1+\anch_tables_indeed_GFC [#2:#2]\else
+ \if#1<\anch_tables_indeed_GTC [#2:#2]\else
+ \if#1-\anch_tables_indeed_GTC [#2:#2]\else
+ \if#1=\anch_tables_indeed_GSC [#2:#2]\else
+ \anch_tables_indeed_GSC[#1#2:#1#2]\fi\fi\fi\fi\fi}
-\def\dododododoGTC[#1:#2]%
- {\dotableepos{\tbPOSprefix#1}}
+\def\anch_tables_indeed_GSC[#1]%
+ {\processcommalist[#1]\anch_tables_step_GSC}
-\def\dodododoGTC[#1]%
- {\def\docommand##1{\dododododoGTC[##1:##1]}%
- \processcommalist[#1]\docommand}
+\def\anch_tables_step_GSC#1%
+ {\anch_tables_append_GSC[#1:#1]}
-\def\dododoGTC[#1]%
- {\doglobal\appendtoks\dodododoGTC[#1]\to\posXCtoks}
+\def\anch_tables_append_GSC[#1:#2:#3]%
+ {\doglobal\appendtoks\anch_tables_process_GSC[#1:#2]\to\posXCtoks\NC}
-\def\dodoGTC[#1]%
- {\doglobal\appendtoks\dododoGTC[#1]\to\posXCtoks\NC}
+\def\anch_tables_process_GSC[#1:#2]%
+ {\remappositionframed{#2}{\tbPOSprefix#1}%
+ \anch_tabulate_bpos{\tbPOSprefix#1}%
+ \doglobal\appendtoks\@EA\anch_tabulate_epos\@EA{\tbPOSprefix#1}\to\posXCtoks}
-\def\dodododoXC[#1#2]%
- {\if#1>\dodoGFC [#2:#2]\else
- \if#1+\dodoGFC [#2:#2]\else
- \if#1<\dodoGTC [#2:#2]\else
- \if#1-\dodoGTC [#2:#2]\else
- \if#1=\dodoGSC [#2:#2]\else
- \dodoGSC[#1#2:#1#2]\fi\fi\fi\fi\fi}
+\def\anch_tables_indeed_GFC[#1]%
+ {\doglobal\appendtoks\anch_tables_delayed_GFC[#1]\to\posXCtoks\NC}
-\def\dododoXC#1%
- {\dodododoXC[#1]}
+\def\anch_tables_delayed_GFC[#1]%
+ {\processcommalist[#1]\anch_tables_step_GFC}
-\def\dodoXC[#1]%
- {{\let\NC\relax\processcommalist[#1]\dododoXC}}
+\def\anch_tables_step_GFC#1%
+ {\anch_tables_process_GFC[#1:#1]}
-\def\@@checktablepositionstate
- {\iftrialtypesetting
- \global\settrue\tablehaspositions
- \firstargumentfalse
- \fi}
+\def\anch_tables_process_GFC[#1:#2:#3]%
+ {\remappositionframed{#2}{\tbPOSprefix#1}%
+ \anch_tabulate_bpos{\tbPOSprefix#1}}
+
+\def\anch_tables_indeed_GTC[#1]%
+ {\doglobal\appendtoks\anch_tables_delayed_GTC[#1]\to\posXCtoks\NC}
-\def\doGSC[#1]{\@@checktablepositionstate\iffirstargument\dodoGSC[#1]\else\expandafter\NC\fi}
-\def\doGFC[#1]{\@@checktablepositionstate\iffirstargument\dodoGFC[#1]\else\expandafter\NC\fi}
-\def\doGTC[#1]{\@@checktablepositionstate\iffirstargument\dodoGTC[#1]\else\expandafter\NC\fi}
-\def\doXC [#1]{\@@checktablepositionstate\iffirstargument\dodoXC [#1]\else\expandafter\fi\NC}
+\def\anch_tables_delayed_GTC[#1]%
+ {\doglobal\appendtoks\anch_tables_process_GTC[#1]\to\posXCtoks}
-\def\tbGSC{\dosingleempty\doGSC}
-\def\tbGFC{\dosingleempty\doGFC}
-\def\tbGTC{\dosingleempty\doGTC}
-\def\tbXC {\dosingleempty\doXC }
+\def\anch_tables_process_GTC[#1]%
+ {\processcommalist[#1]\anch_tables_step_GTC}
-%D The amount of code to support tables and tabulation is
-%D rather minimalistic.
+\def\anch_tables_step_GTC#1%
+ {\anch_tables_step_indeed_GTC[#1:#1]}
+
+\def\anch_tables_step_indeed_GTC[#1:#2]%
+ {\anch_tabulate_epos{\tbPOSprefix#1}}
+
+%D The amount of code to support tables and tabulation is rather
+%D minimalistic.
\let\tabulatepos\tablepos
@@ -187,31 +195,30 @@
% We need to handle paragraphs as well.
-\let\doflushtabulateepos\relax
+\let\anch_tabulate_flush_epos\relax
-\def\dotabulatebpos
+\def\anch_tabulate_bpos_indeed
{\bpos}
-\def\dotabulateepos#1%
+\def\anch_tabulate_epos_indeed#1%
{\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
\epos{#1}%
- \glet\doflushtabulateepos\relax
+ \glet\anch_tabulate_flush_epos\relax
\else
- \gdef\doflushtabulateepos{\epos{#1}}%
+ \gdef\anch_tabulate_flush_epos{\epos{#1}}%
\fi}
\def\flushtabulatesplitbox
{\box\b_tabl_tabulate
- \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi}
+ \iftrialtypesetting\else\ifconditional\tablehaspositions\anch_tabulate_flush_epos\fi\fi}
\appendtoks
- \let\dotablebpos\dotabulatebpos % ?
- \let\dotableepos\dotabulateepos % ?
- \glet\doflushtabulateepos\relax
+ \let\anch_tabulate_bpos\anch_tabulate_bpos_indeed % ?
+ \let\anch_tabulate_epos\anch_tabulate_epos_indeed % ?
+ \glet\anch_tabulate_flush_epos\relax
\to \everytabulate
-%D In order to prevent potential clashes with abbreviations,
-%D postpone the mapping.
+%D In order to prevent potential clashes with abbreviations, postpone the mapping.
\appendtoks
\let\GSC\tbGSC
@@ -223,8 +230,8 @@
%D \macros
%D {definepositionframed}
%D
-%D The next example show how to provide backgrounds to table
-%D cells. First we define some framed backgrounds.
+%D The next example show how to provide backgrounds to table cells. First we define
+%D some framed backgrounds.
%D
%D \startbuffer
%D \definepositionframed[x][background=color,backgroundcolor=red]
@@ -244,8 +251,7 @@
%D \stoptabulate
%D \stopbuffer
%D
-%D The table itself defines three areas (a, b and~c) using
-%D these frames.
+%D The table itself defines three areas (a, b and~c) using these frames.
%D
%D \typebuffer
%D % \getbuffer
@@ -270,9 +276,8 @@
\let\XC \tbXC
\to \everytable
-%D In the previous example, we could have provided an overlay to
-%D the framed definition. A more direct approach is demonstrated
-%D below:
+%D In the previous example, we could have provided an overlay to the framed definition.
+%D A more direct approach is demonstrated below:
%D
%D \startbuffer
%D \def\cw#1{\color[white]{#1}}
@@ -291,8 +296,7 @@
%D
%D \typebuffer \getbuffer
%D
-%D The definition of the table looks about the same as the
-%D previous one:
+%D The definition of the table looks about the same as the previous one:
%D
%D \startbuffer
%D \starttable[|c|c|c|]
@@ -347,22 +351,26 @@
% \definepositionframed[y][background=color,fillcolor=green]
% \definepositionframed[z][background=color,fillcolor=blue]
-\def\remappositionframed#1#2% from to
+\unexpanded\def\remappositionframed#1#2% from to
{\copyposition{b:#1}{b:#2}%
\copyposition{e:#1}{e:#2}%
\anch_positions_set_action{b:#2}{\dopositionaction{b:#1}}}
\unexpanded\def\definepositionframed
- {\dodoubleargument\dodefinepositionframed}
+ {\dodoubleargument\anch_framed_define}
-\def\dodefinepositionframed[#1][#2]%
- {\anch_positions_set_action{b:#1}{\dopositionframed[#1][#2]}}
+\def\anch_framed_define[#1][#2]%
+ {\anch_positions_set_action{b:#1}{\anch_framed_handle[#1][#2]}}
+
+\unexpanded\def\anch_framed_handle
+ {\bgroup
+ \anch_framed_indeed}
\unexpanded\def\positionframed
{\bgroup
- \dodoubleempty\dopositionframed}
+ \dodoubleempty\anch_framed_indeed}
-\def\dopositionframed[#1][#2]%
+\def\anch_framed_indeed[#1][#2]%
{\setbox\scratchbox\hbox
{\scratchwidth \dimexpr\MPx{e:#1}-\MPx{b:#1}\relax
\scratchdepth \dimexpr\MPy{b:#1}-\MPy{e:#1}+\MPd{e:#1}\relax
diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv
index d8fbe31b4..36de37669 100644
--- a/tex/context/base/buff-ver.mkiv
+++ b/tex/context/base/buff-ver.mkiv
@@ -839,6 +839,6 @@
\appendtoks
\def\type#1{\letterbackslash\checkedstrippedcsname#1}% or maybe detokenize
\def\tex #1{\letterbackslash#1}%
-\to \simplifiedcommands
+\to \everysimplifycommands
\protect \endinput
diff --git a/tex/context/base/catc-ini.mkiv b/tex/context/base/catc-ini.mkiv
index 26c3ceee9..791ce31c4 100644
--- a/tex/context/base/catc-ini.mkiv
+++ b/tex/context/base/catc-ini.mkiv
@@ -87,6 +87,17 @@
\xdef\outputnewlinechar{^^J}%
\endgroup}
+%D We predefine some prefixes ahead of syst-aux and mult-sys. We reserve 8 slots
+%D for catcodes.
+
+\def\??catcodelet {1>>} % let : \let
+\def\??catcodedef {2>>} % def : \def
+\def\??catcodeued {3>>} % ued : \unexpanded\def
+\def\??catcodeget {4>>} % \meaning
+
+\def\??catcodetablet{5>>}
+\def\??catcodetablen{6>>}
+
\newcount\c_syst_catcodes_n \c_syst_catcodes_n\zerocount % 0 = signal, so advance before allocate
\newcount\c_syst_catcodes_a
\newcount\c_syst_catcodes_b
@@ -94,7 +105,7 @@
\normalprotected\def\newcatcodetable#1% we could move the cctdefcounter to lua
{\global\advance\c_syst_catcodes_n\plusone
- \expandafter\xdef\csname\??qm:n:\number\c_syst_catcodes_n\endcsname{\string#1}% logging
+ \expandafter\xdef\csname\??catcodetablen\number\c_syst_catcodes_n\endcsname{\string#1}% logging
\newconstant#1%
#1\c_syst_catcodes_n
\ctxlua{catcodes.register("\expandafter\gobbleoneargument\string#1",\number#1)}}
@@ -151,12 +162,7 @@
\setnewconstant\c_syst_catcodes_hack\tildeasciicode
%D Once a catcode is assigned, the next assignments will happen
-%D faster. We predefine some prefixes ahead of mult-sys.
-
-\def\??ql{@@ql} % let : \let
-\def\??qd{@@qd} % def : \def
-\def\??qu{@@qu} % ued : \unexpanded\def
-\def\??qm{@@qm} % \meaning
+%D faster.
\def\letcatcodecommand{\afterassignment\syst_catcodes_let_a\c_syst_catcodes_a}
\def\defcatcodecommand{\afterassignment\syst_catcodes_def_a\c_syst_catcodes_a}
@@ -167,46 +173,46 @@
\def\syst_catcodes_ued_a{\afterassignment\syst_catcodes_ued_b\c_syst_catcodes_b}
\def\syst_catcodes_let_b % each time
- {\ifcsname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
- \csname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
+ {\ifcsname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
+ \csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
\else
\expandafter\syst_catcodes_let_c
\fi}
\def\syst_catcodes_def_b % each time
- {\ifcsname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
- \csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
+ {\ifcsname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
+ \csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
\else
\expandafter\syst_catcodes_def_c
\fi}
\def\syst_catcodes_ued_b % each time
- {\ifcsname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
- \csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
+ {\ifcsname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname
+ \csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
\else
\expandafter\syst_catcodes_ued_c
\fi}
\def\syst_catcodes_let_c % only first time
- {\expandafter\gdef\csname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname\expandafter
- {\expandafter\let\csname\??qm:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}%
+ {\expandafter\gdef\csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname\expandafter
+ {\expandafter\let\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}%
\syst_catcodes_reinstate_unexpanded
- \csname\??ql:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
+ \csname\??catcodelet\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
\def\syst_catcodes_def_c % only first time (we could use \normalexpanded here)
- {\expandafter\gdef\csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
+ {\expandafter\gdef\csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
\expandafter##\expandafter1\expandafter
- {\expandafter\def\csname\??qm:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}%
+ {\expandafter\def\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}%
\syst_catcodes_reinstate_normal
- \csname\??qd:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
+ \csname\??catcodedef\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
\def\syst_catcodes_ued_c % only first time
- {\expandafter\gdef\csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
+ {\expandafter\gdef\csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\expandafter\endcsname
\expandafter##\expandafter1\expandafter
- {\expandafter\normalprotected\expandafter\def\csname\??qm:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}%
+ {\expandafter\normalprotected\expandafter\def\csname\??catcodeget\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname{##1}}%
\syst_catcodes_reinstate_unexpanded
- \csname\??qu:\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
+ \csname\??catcodeued\number\c_syst_catcodes_a:\number\c_syst_catcodes_b\endcsname}
\def\reinstatecatcodecommand{\afterassignment\syst_catcodes_reinstate_normal\c_syst_catcodes_b}
@@ -227,8 +233,8 @@
\newconstant\defaultcatcodetable
\def\catcodecommand#1%
- {\csname\??qm:\number
- \ifcsname\??qm:\number\currentcatcodetable:\number#1\endcsname
+ {\csname\??catcodeget\number
+ \ifcsname\??catcodeget\number\currentcatcodetable:\number#1\endcsname
\currentcatcodetable \else \defaultcatcodetable
\fi
:\number#1\endcsname}
@@ -251,13 +257,13 @@
\normalprotected\def\pushcatcodetable
{\advance\c_syst_catcodes_level\plusone
\syst_catcodes_trace_push
- \expandafter\chardef\csname\??qm:t:\number\c_syst_catcodes_level\endcsname\currentcatcodetable}
+ \expandafter\chardef\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname\currentcatcodetable}
\normalprotected\def\popcatcodetable
{\ifcase\c_syst_catcodes_level
\syst_catcodes_trace_nesting_error
\else
- \expandafter\catcodetable\csname\??qm:t:\number\c_syst_catcodes_level\endcsname
+ \expandafter\catcodetable\csname\??catcodetablet\number\c_syst_catcodes_level\endcsname
\syst_catcodes_trace_pop
\advance\c_syst_catcodes_level\minusone
\fi}
@@ -269,7 +275,7 @@
\normalprotected\def\restorecatcodes % takes previous level
{\ifnum\c_syst_catcodes_level>\plusone
- \expandafter\catcodetable\csname\??qm:t:\number\numexpr\c_syst_catcodes_level-1\relax\endcsname
+ \expandafter\catcodetable\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname
\fi}
% \newtoks\everycatcodetable
@@ -294,14 +300,14 @@
\def\syst_catcodes_prev
{\ifnum\numexpr\c_syst_catcodes_level-1\relax>\zerocount
- \csname\??qm:n:\number\csname\??qm:t:\number\numexpr\c_syst_catcodes_level-1\relax\endcsname\endcsname
+ \csname\??catcodetablen\number\csname\??catcodetablet\number\numexpr\c_syst_catcodes_level-1\relax\endcsname\endcsname
\else
-%
\fi}
\def\catcodetablename
{\ifnum\currentcatcodetable>\zerocount
- \csname\??qm:n:\number\currentcatcodetable\endcsname
+ \csname\??catcodetablen\number\currentcatcodetable\endcsname
\else
-%
\fi}
diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv
index 5baa05bee..a83417ffd 100644
--- a/tex/context/base/cont-log.mkiv
+++ b/tex/context/base/cont-log.mkiv
@@ -276,6 +276,6 @@
\def\MetaFont{MetaFont}%
\def\MetaFun {MetaFun}%
\def\TeX {TeX}%
-\to \simplifiedcommands
+\to \everysimplifycommands
\protect \endinput
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 6cb0f0bdc..eea9250ad 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{2012.06.30 12:32}
+\newcontextversion{2012.07.04 10:42}
%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 442b42222..794733f23 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{2012.06.30 12:32}
+\newcontextversion{2012.07.04 10:42}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
@@ -124,47 +124,6 @@
% \markpage[nobackgrounds]
% \doifmarkedpageelse{nobackgrounds}
-% Just a simple and fast hanger, for usage in macros.
-
-\def\setuphanging
- {\dodoubleempty\getparameters[\??ha]}
-
-\setuphanging
- [\c!distance=.5em]
-
-\def\starthanging
- {\noindent\bgroup
- \dowithnextbox
- {\setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}%
- \hangindent\nextboxwd
- \hangafter\plusone
- \flushnextbox\ignorespaces}
- \hbox}
-
-\def\stophanging
- {\endgraf
- \egroup}
-
-% experimental
-
-\def\stophangaround
- {\endgraf
- \egroup}
-
-\def\starthangaround
- {\noindent\bgroup
- \dowithnextbox
- {\ifdim\nextboxht>\strutht\setbox\nextbox\tbox{\flushnextbox}\fi
- \setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}%
- \getboxheight\scratchdimen\of\box\nextbox
- \getnoflines\scratchdimen
- \nextboxht\strutht
- \nextboxdp\strutdp
- \hangindent\nextboxwd
- \hangafter-\noflines
- \llap{\flushnextbox}\ignorespaces}
- \hbox}
-
\def\modevalue#1#2#3%
{\@EA\ifx\csname\@mode@\systemmodeprefix#1\endcsname\endcsname\enabledmode#2\else#2\fi}
@@ -179,7 +138,7 @@
% \placefloatplaceholder}
\def\placefloatplaceholder
- {\ifroomforfloat \else
+ {\ifconditional\c_page_floats_room \else
\scratchdimen\pagegoal
\advance\scratchdimen-\pagetotal
\advance\scratchdimen-3\lineheight
@@ -328,12 +287,12 @@
% \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\tabulaterule % to be redone, not correct
- {\dotabulaterule
- {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax
- \doifvalue{\??tt\currenttabulate\c!distance}\v!grid
- {\kern-\scratchdimen}}} % experimental tm-prikkels
-% so far
+%\def\tabulaterule % to be redone, not correct
+% {\dotabulaterule
+% {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax
+% \doif{\tabulateparameter\c!distance}\v!grid
+% {\kern-\scratchdimen}}} % experimental tm-prikkels
+%
% between alignment lines certain rules apply, and even a
% simple test can mess up a table, which is why we have a
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index b0e91f6fa..f95cc016a 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 2a2f8a374..70c4214dc 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index c547b109d..232902240 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{2012.06.30 12:32}
+\edef\contextversion{2012.07.04 10:42}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index bcaa34449..9f6d4e3c3 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -19,11 +19,13 @@
%D 2004.8.30 the low level interface is english. Watch out and adapt
%D your styles an modules.
+% \everypar{\writestatus{!!!!}{some spurious input in line \the\inputlineno}\wait}
+
%D The order of loading will change when all modules have been cleaned
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.06.30 12:32}
+\edef\contextversion{2012.07.04 10:42}
%D For those who want to use this:
@@ -121,7 +123,7 @@
\loadmarkfile{attr-ini}
-\loadmarkfile{core-var}
+\loadmarkfile{core-ini}
\loadmarkfile{core-env}
\loadmarkfile{layo-ini}
@@ -275,7 +277,7 @@
\loadmkvifile{strc-flt}
-\loadmarkfile{page-mis}
+\loadmarkfile{page-pst}
\loadmkvifile{page-mbk}
\loadmarkfile{page-mul}
\loadmarkfile{page-set}
@@ -304,14 +306,15 @@
\loadmarkfile{strc-blk}
\loadmarkfile{page-imp}
-\loadmarkfile{page-sel} % optional
-\loadmarkfile{page-com} % optional
+\loadmkvifile{page-sel} % optional
\loadmkvifile{scrn-pag}
\loadmkvifile{scrn-wid}
\loadmkvifile{scrn-but}
\loadmkvifile{scrn-bar}
+\loadmarkfile{page-com} % optional (after scrn-pag)
+
\loadmarkfile{strc-bkm} % bookmarks
\loadmarkfile{tabl-com}
@@ -461,7 +464,6 @@
\loadmarkfile{core-ctx} % this order might change but we need to check depedencies / move to another namespace
-\loadmarkfile{core-ini}
\loadmarkfile{core-def}
%usemodule[x][res-04] % xml resource libraries
diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv
index 241d43165..5979bfe37 100644
--- a/tex/context/base/core-con.mkiv
+++ b/tex/context/base/core-con.mkiv
@@ -20,35 +20,27 @@
\ifdefined\currentlanguage \else \let\currentlanguage\empty \fi
\ifdefined\labeltext \else \let\labeltext \firstofoneargument \fi
-%D This module deals with all kind of conversions from numbers
-%D and dates. I considered splitting this module in a support
-%D one and a core one, but to keep things simple as well as
-%D preserve the overview, I decided against splitting.
+%D This module deals with all kind of conversions from numbers and dates. I
+%D considered splitting this module in a support one and a core one, but to keep
+%D things simple as well as preserve the overview, I decided against splitting.
\let\spr\firstofoneargument % separator
\let\stp\firstofoneargument % stopper
-% cleaner, some day:
-%
-% \def\isolateseparators % etex only, even works with list separator overloading
-% {\unexpanded\def\spr##1{{##1}}%
-% \unexpanded\def\stp##1{{##1}}}
-
-% needed for arab :
+% needed for arab:
\unexpanded\def\isolateseparators % even works with list separator overloading
- {\def\spr##1{{##1}}%
- \def\stp##1{{##1}}}
+ {\def\spr##1{{##1}}% % we can probably best mess around with zwj
+ \def\stp##1{{##1}}} % and friends
%D \macros
%D {numbers}
%D
-%D First we deal with the dummy conversion of numbers using the
-%D \TEX\ primitive \type{\number}. The uppercase alternative is
-%D only there for compatibility with the other conversion
-%D macros. We could do without \type{#1} but this way we get
-%D rid of unwanted braces. For the savety we also define a
-%D non||sence uppercase alternative.
+%D First we deal with the dummy conversion of numbers using the \TEX\ primitive
+%D \type{\number}. The uppercase alternative is only there for compatibility with
+%D the other conversion macros. We could do without \type{#1} but this way we get
+%D rid of unwanted braces. For the savety we also define a non||sence uppercase
+%D alternative.
%D
%D \showsetup{numbers}
%D
@@ -57,8 +49,8 @@
%D \def\Numbers#1{\number#1}
%D \stoptyping
%D
-%D Due to read ahead, as in \type{[\pagenumber\space]} the space will
-%D disappear, unless we use:
+%D Due to read ahead, as in \type{[\pagenumber\space]} the space will disappear,
+%D unless we use:
\def\numbers#1{\purenumber{#1}}
\def\Numbers#1{\purenumber{#1}}
@@ -66,10 +58,9 @@
%D \macros
%D {romannumerals,Romannumerals}
%D
-%D \TEX\ the program uses a rather tricky conversion from
-%D numbers to their roman counterparts. This conversion could
-%D of course be programmed in \TEX\ itself, but I guess Knuth
-%D found the programming trick worth presenting.
+%D \TEX\ the program uses a rather tricky conversion from numbers to their roman
+%D counterparts. This conversion could of course be programmed in \TEX\ itself, but
+%D I guess Knuth found the programming trick worth presenting.
%D
%D \showsetup{romannumerals}
%D \showsetup{Romannumerals}
@@ -113,9 +104,9 @@
%D \macros
%D {character,Character}
%D
-%D Converting a number into a character can of course only
-%D be done with numbers less or equal to~26. At the cost of
-%D much more macros a faster conversion is possible, using:
+%D Converting a number into a character can of course only be done with numbers
+%D less or equal to~26. At the cost of much more macros a faster conversion is
+%D possible, using:
%D
%D \starttyping
%D \setvalue{char1}{a} \def\character#1{\getvalue{char#1}}
@@ -134,9 +125,8 @@
%D \macros
%D {characters,Characters}
%D
-%D Converting large numbers is supported by the next two
-%D macros. This time we just count on: $\cdots$~x, y, z, aa,
-%D ab, ac~$\cdots$.
+%D Converting large numbers is supported by the next two macros. This time we
+%D just count on: $\cdots$~x, y, z, aa, ab, ac~$\cdots$.
%D
%D \showsetup{characters}
%D \showsetup{Characters}
@@ -174,9 +164,8 @@
%D \macros
%D {protectconversion}
%D
-%D The previous two commands are not robust enough to be
-%D passed to \type{\write} en \type{\message}. That's why we
-%D introduce:
+%D The previous two commands are not robust enough to be passed to \type
+%D {\write} en \type{\message}. That's why we introduce:
\unexpanded\def\protectconversion
{\let\doconvertcharacters\firstofoneargument}
@@ -184,10 +173,9 @@
%D \macros
%D {normaltime,normalyear,normalmonth,normalday}
%D
-%D The last part of this module is dedicated to converting
-%D dates. Because we want to use as meaningful commands as
-%D possible, and because \TEX\ already uses up some of those,
-%D we save the original meanings.
+%D The last part of this module is dedicated to converting dates. Because we
+%D want to use as meaningful commands as possible, and because \TEX\ already
+%D uses up some of those, we save the original meanings.
\savenormalmeaning\time
\savenormalmeaning\year
@@ -197,10 +185,9 @@
%D \macros
%D {month,MONTH}
%D
-%D Converting the month number into a month name is done
-%D using a case statement, abstact values and the label
-%D mechanism. This way users can easily redefine a label from
-%D for instance german into austrian.
+%D Converting the month number into a month name is done using a case statement,
+%D abstact values and the label mechanism. This way users can easily redefine a
+%D label from for instance german into austrian.
%D
%D \starttyping
%D \setuplabeltext [de] [january=J\"anner]
@@ -224,11 +211,9 @@
\def\MONTHLONG #1{\WORD{\monthlong {#1}}}
\def\MONTHSHORT#1{\WORD{\monthshort{#1}}}
-%D We never explicitly needed this, but Tobias Burnus pointed
-%D out that it would be handy to convert to the day of the
-%D week. In doing so, we have to calculate the total number of
-%D days, taking leapyears into account. For those who are
-%D curious:
+%D We never explicitly needed this, but Tobias Burnus pointed out that it would be
+%D handy to convert to the day of the week. In doing so, we have to calculate the
+%D total number of days, taking leapyears into account. For those who are curious:
%D
%D \startitemize[packed]
%D \item years that can be divided by 4 are leapyears
@@ -239,8 +224,7 @@
%D \macros
%D {weekday,WEEKDAY}
%D
-%D The first one is sort of redundant. It takes the day
-%D number argument.
+%D The first one is sort of redundant. It takes the day number argument.
%D
%D \showsetup{weekday}
%D \showsetup{WEEKDAY}
@@ -277,15 +261,15 @@
%D \getbuffer
%D \stoplines
%D
-%D The macro \type {\getdayoftheweek} can be used to calculate
-%D the number \type {\normalweekday}.
+%D The macro \type {\getdayoftheweek} can be used to calculate the number
+%D \type {\normalweekday}.
%D \macros
%D {doifleapyearelse,
%D getdayspermonth}
%D
-%D Sometimes we need to know if we're dealing with a
-%D leapyear, so here is a testmacro:
+%D Sometimes we need to know if we're dealing with a leapyear, so here is a
+%D testmacro:
%D
%D \starttyping
%D \doifleapyearelse{year}{yes}{no}
@@ -297,8 +281,7 @@
%D \getdayspermonth{year}{month}
%D \stoptyping
%D
-%D The number of days is available in the macro \type
-%D {\numberofdays}.
+%D The number of days is available in the macro \type {\numberofdays}.
\def\doifleapyearelse#1%
{\ctxcommand{doifleapyearelse(\number#1)}}
@@ -320,13 +303,11 @@
%D \macros
%D {currentdate, rawdate, date}
%D
-%D We use these conversion macros in the date formatting
-%D macro:
+%D We use these conversion macros in the date formatting macro:
%D
%D \showsetup{currentdate}
%D
-%D This macro takes care of proper spacing and delivers for
-%D instance:
+%D This macro takes care of proper spacing and delivers for instance:
%D
%D \startbuffer
%D \currentdate[weekday,day,month,year] % still dutch example
@@ -351,8 +332,8 @@
%D
%D or typeset: \getbuffer.
%D
-%D When no argument is passed, the current date is given as
-%D specified per language (using \type{\installlanguage}).
+%D When no argument is passed, the current date is given as specified per
+%D language (using \type{\installlanguage}).
%D
%D \showsetup{currentdate}
%D
@@ -367,8 +348,8 @@
%D
%D \typebuffer
%D
-%D The date is specified by one character keys. When no date
-%D is given, we get the current date.
+%D The date is specified by one character keys. When no date is given, we
+%D get the current date.
%D
%D \startlines
%D \getbuffer
@@ -430,10 +411,13 @@
\def\syst_converters_date[#1][#2]%
{\begingroup
\iffirstargument
- \getparameters[\??da][d=\normalday,m=\normalmonth,y=\normalyear,#1]%
- \normalday \@@dad\relax
- \normalmonth\@@dam\relax
- \normalyear \@@day\relax
+ \letdummyparameter\c!d\normalday
+ \letdummyparameter\c!m\normalmonth
+ \letdummyparameter\c!y\normalyear
+ \getdummyparameters[#1]%
+ \normalday \directdummyparameter\c!d\relax
+ \normalmonth\directdummyparameter\c!m\relax
+ \normalyear \directdummyparameter\c!y\relax
\fi
\syst_converters_current_date[#2]%
\endgroup}
@@ -444,9 +428,8 @@
%D \macros
%D {currenttime}
%D
-%D The currenttime is actually the jobtime. You can specify
-%D a pattern similar to the previous date macro using the
-%D keys \type {h}, \type {m} and a separator.
+%D The currenttime is actually the jobtime. You can specify a pattern similar
+%D to the previous date macro using the keys \type {h}, \type {m} and a separator.
\unexpanded\def\calculatecurrenttime
{\edef\currenthour {\ctxcommand{hour ()}}%
@@ -462,7 +445,6 @@
\unexpanded\def\currenttime
{\doifnextoptionalelse\syst_converters_current_time_yes\syst_converters_current_time_nop}
-
\unexpanded\def\syst_converters_current_time_yes[#1]%
{\calculatecurrenttime
\processallactionsinset[#1][h=>\currenthour,m=>\currentminute,\s!unknown=>\commalistelement]}
@@ -471,16 +453,15 @@
{\normalexpanded{\syst_converters_current_time_yes[\currenttimespecification]}}
-%D Because we're dealing with dates, we also introduce a few
-%D day loops:
+%D Because we're dealing with dates, we also introduce a few day loops:
%D
%D \starttyping
%D \processmonth{year}{month}{command}
%D \processyear{year}{command}{before}{after}
%D \stoptyping
%D
-%D The counters \type {\normalyear}, \type {\normalmonth} and
-%D \type{\normalday} can be used for for date manipulations.
+%D The counters \type {\normalyear}, \type {\normalmonth} and \type {\normalday}
+%D can be used for for date manipulations.
\unexpanded\def\processmonth#1#2#3% year month command
{\begingroup
@@ -505,15 +486,13 @@
%D \macros
%D {defineconversion, convertnumber}
%D
-%D Conversion involves the macros that we implemented earlier
-%D in this module.
+%D Conversion involves the macros that we implemented earlier in this module.
%D
%D \showsetup{defineconversion}
%D \showsetup{convertnumber}
%D
-%D We can feed this command with conversion macros as well as
-%D a set of conversion symbols. Both need a bit different
-%D treatment.
+%D We can feed this command with conversion macros as well as a set of conversion
+%D symbols. Both need a bit different treatment.
%D
%D \starttyping
%D \defineconversion [roman] [\romannumerals]
@@ -549,9 +528,9 @@
\def\syst_converters_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.
+%D If a conversion is just a font switch then we need to make sure that the
+%D number is indeed end up as number in the input, so we need to handle the
+%D second argument.
\def\convertnumber#1#2% expandable
{\csname\??conversionarguments
@@ -600,19 +579,17 @@
%D \macros
%D {ordinaldaynumber, highordinalstr, ordinalstr}
%D
-%D Efficient general ordinal number converters are sometimes
-%D difficult to implement. Fortunately dates never exceed the
-%D number~31.
+%D Efficient general ordinal number converters are sometimes difficult to
+%D implement. Fortunately dates never exceed the number~31.
\def\highordinalstr #1{\high{\notsmallcapped{#1}}}
\def\ordinalstr #1{\notsmallcapped{#1}}
\def\ordinaldaynumber #1{\ctxcommand{ordinal(#1,"\currentlanguage")}}
-%D As longs as symbols are linked to levels or numbers, we can
-%D also use the conversion mechanism, but in for instance the
-%D itemization macros, we prefer symbols because they can more
-%D easier be (partially) redefined. Symbols are implemented
-%D in another module.
+%D As longs as symbols are linked to levels or numbers, we can also use the
+%D conversion mechanism, but in for instance the itemization macros, we prefer
+%D symbols because they can more easier be (partially) redefined. Symbols are
+%D implemented in another module.
\def\smallcappedromannumerals#1{\smallcapped{\romannumerals{#1}}}
\def\smallcappedcharacters #1{\smallcapped{\characters {#1}}}
diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv
index 5423b97aa..d418689ef 100644
--- a/tex/context/base/core-def.mkiv
+++ b/tex/context/base/core-def.mkiv
@@ -24,38 +24,87 @@
\setupinteraction[\c!symbolset=navigation 1]
+% what a mess
+
+\everypar \emptytoks
+\neverypar \emptytoks
+
+\appendtoks
+ % \flushnotes
+ \page_otr_command_synchronize_side_floats % an otr specific command
+ \checkindentation
+ \showparagraphnumber
+ \restoreinterlinepenalty
+ % \flushmargincontents
+ % \flushcommentanchors
+ \flushnotes
+ \synchronizenotes
+ \OTRSETshowstatus
+ \registerparoptions
+ % \flushsyncpositions
+ \flushpostponednodedata
+ \typo_delimited_repeat
+ \insertparagraphintro
+\to \everypar
+
+\appendtoks
+ \flushnotes
+\to \everydisplay
+
+\appendtoks
+ \adjustsidefloatdisplaylines
+\to \everydisplay
+
+% \appendtoks
+% \flushsyncpositions
+% \to \everyheadstart
+
+% \appendtoks
+% \flushsyncresets
+% \to \everyendoftextbody
+
+\appendtoks
+ \ignorespaces
+\to \everybeginofpar
+
+\appendtoks
+ \removeunwantedspaces
+ % \strut % option ?
+ % \flushsyncresets
+ % \setlastlinewidth % gone, will be done in lua
+ \endgraf
+\to \everyendofpar
+
% initialization order:
\ifdefined\font_preloads_at_every_job \else \let\font_preloads_at_every_job \relax \fi
\ifdefined\font_preloads_at_start_text \else \let\font_preloads_at_start_text\relax \fi
\ifdefined\font_preloads_at_stop_text \else \let\font_preloads_at_stop_text \relax \fi
-\appendtoks \font_preloads_at_start_text \to \everystarttext
-\appendtoks \font_preloads_at_stop_text \to \everystoptext
-
-\appendtoks \showcontextbanner \to \everyjob
-\appendtoks \initializenewlinechar \to \everyjob
-\appendtoks \calculatecurrenttime \to \everyjob
-\appendtoks \loadsystemfiles \to \everyjob
-
-\appendtoks \loadoptionfile \to \everyjob % obsolete
\appendtoks
- \job_options_get_commandline % expands some commands
- \job_options_get_ctxfile % might expand some commands
-\to \everyjob % ok here?
-
-\appendtoks \font_preloads_at_every_job \to \everyjob
-\appendtoks \settopskip \to \everyjob
-\appendtoks \initializemainlanguage \to \everyjob
-\appendtoks \xmlinitialize \to \everyjob % is this still needed?
-\appendtoks \setfalse\c_page_backgrounds_new \to \everyjob
-\appendtoks \setfalse\c_page_backgrounds_some \to \everyjob
-\appendtoks \initializepagecounters \to \everyjob
+ \font_preloads_at_start_text
+\to \everystarttext
-\appendtoks \directsetup{*runtime:options} \to \everyjob % obsolete
-\appendtoks \directsetup{*runtime:modules} \to \everyjob % obsolete
+\appendtoks
+ \font_preloads_at_stop_text
+\to \everystoptext
\appendtoks
+ \showcontextbanner
+ \initializenewlinechar
+ \calculatecurrenttime
+ \loadsystemfiles
+ % \loadoptionfile % obsolete, but nice to keep as reference of when/how
+ \job_options_get_commandline % expands some commands
+ \job_options_get_ctxfile % might expand some commands
+ \font_preloads_at_every_job
+ \settopskip % brrr
+ \initializemainlanguage
+ \initializexmlprocessing % is this still needed?
+ \initializepagebackgrounds
+ \initializepagecounters
+ % \directsetup{*runtime:options}% % obsolete as the option file is replaced by a more direct mechanism
+ % \directsetup{*runtime:modules}% % obsolete as the option file is replaced by a more direct mechanism
\job_options_set_modes
\job_options_set_modules
\job_options_set_environments
@@ -65,14 +114,25 @@
\job_options_log
\to \everystarttext
-\appendtoks \ifarrangingpages\poparrangedpages\fi \to \everybye
+\appendtoks
+ \ifarrangingpages\poparrangedpages\fi
+\to \everybye
+
+\prependtoks
+ \resetallattributes
+\to \everybeforeoutput
-\prependtoks \resetallattributes \to \everybeforeoutput
+\appendtoks
+ \the\everybackendshipout
+\to \everyshipout
-\appendtoks \the\everybackendshipout \to \everyshipout
-\prependtoks \the\everylastbackendshipout \to \everylastshipout
+\prependtoks
+ \the\everylastbackendshipout
+\to \everylastshipout
-\prependtoks \lefttoright \to \everybeforeoutput
+\prependtoks
+ \lefttoright
+\to \everybeforeoutput
% temporary here:
diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv
index 1819d084d..6b369b29a 100644
--- a/tex/context/base/core-env.mkiv
+++ b/tex/context/base/core-env.mkiv
@@ -625,4 +625,51 @@
\def\env {\getvariable \s!environment}
\def\envvar {\getvariabledefault\s!environment}
+%D \macros
+%D {defineselector,setupselector,select,directselect}
+%D
+%D \starttyping
+%D \defineselector[caption][max=2,n=2]
+%D
+%D \start
+%D \setupselector[caption][n=1]
+%D \placelist[figure][criterium=all]
+%D \stop
+%D
+%D \starttext
+%D \placefigure
+%D {\select{caption}{zapf}{\input zapf \relax}}
+%D {}
+%D \stoptext
+%D \stoptyping
+
+\installcorenamespace{selector}
+
+\unexpanded\def\defineselector{\dodoubleargument\syst_selectors_define}
+\unexpanded\def\setupselector {\dodoubleargument\syst_selectors_setup}
+
+% \def\syst_selectors_define[#1][#2]{\getparameters[\??selector#1][\c!max=\plusone,\c!n=\plusone,#2]}
+% \def\syst_selectors_setup [#1][#2]{\getparameters[\??selector#1][#2]}
+
+\def\syst_selectors_define[#1][{\getparameters[\??selector#1][\c!max=\plustwo,\c!n=\plusone,}
+\def\syst_selectors_setup [#1][{\getparameters[\??selector#1][}
+
+\unexpanded\def\select % unexpandable
+ {\directselect}
+
+% \def\directselect#1% expandable
+% {\filterfromnext % maybe add an \expanded
+% {\csname\??selector\ifcsname\??selector#1\c!max\endcsname#1\fi\c!max\endcsname}%
+% {\csname\??selector\ifcsname\??selector#1\c!n \endcsname#1\fi\c!n \endcsname}}
+%
+% this is more efficient when the arguments are used a few times (or passed along):
+
+\def\directselect#1% expandable
+ {\expandafter\filterfromnext
+ \csname\??selector\ifcsname\??selector#1\c!max\endcsname#1\fi\c!max\expandafter\endcsname
+ \csname\??selector\ifcsname\??selector#1\c!n \endcsname#1\fi\c!n \endcsname}
+
+\letvalue{\??selector\c!max}\plusone
+\letvalue{\??selector\c!n }\plusone
+
\protect \endinput
diff --git a/tex/context/base/core-ini.mkiv b/tex/context/base/core-ini.mkiv
index 6235d5bde..7b32cb3a2 100644
--- a/tex/context/base/core-ini.mkiv
+++ b/tex/context/base/core-ini.mkiv
@@ -13,58 +13,199 @@
\writestatus{loading}{ConTeXt Core Macros / Additional Initialization}
-%D We will move more code to here, so that we become less dependent of the
-%D orde in which modules are loaded.
-
\unprotect
-\everypar \emptytoks
-\neverypar \emptytoks
+%D We introduce a couple of variables that are used all over \CONTEXT. Alternatively
+%D we could define them in each module but as they are part of the bigger picture we
+%D prefer to do it here. Ideally we should hav ea proper dependency tree but it might
+%D be that we want to make versions with a smaller footprints in which case one would
+%D still need to define the token list registers (unless we could do that runtime).
-\appendtoks
- %flushnotes
- \page_otr_command_synchronize_side_floats % an otr specific command
- \checkindentation
- \showparagraphnumber
- \restoreinterlinepenalty
- %flushmargincontents
- %flushcommentanchors
- \flushnotes
- \synchronizenotes
- \OTRSETshowstatus
- \registerparoptions
- %\flushsyncpositions
- \flushpostponednodedata
- \typo_delimited_repeat
- \insertparagraphintro
-\to \everypar
+%D \macros
+%D {every...}
+%D
+%D A few every's.
-\appendtoks
- \flushnotes
-\to \everydisplay
+%D Output routine:
+
+\newtoks \everybeforeoutput
+\newtoks \everyafteroutput
+
+%D Shipout:
+
+\newtoks \everyshipout
+\newtoks \everybeforeshipout
+\newtoks \everyaftershipout
+\newtoks \everyfirstshipout
+\newtoks \everylastshipout
+
+%D End of run:
+
+\newtoks \everybye
+\newtoks \everygoodbye
+\newtoks \everynotabene
+
+%D Document:
+
+\newtoks \everysetupdocument
+\newtoks \everyendoftextbody
+
+\newtoks \everystarttext
+\newtoks \everystoptext
+
+%D Purity:
+
+\newtoks \everyforgetall
+\newtoks \everycleanupfeatures
+\newtoks \everysimplifycommands
+
+\let\simplifiedcommands\everysimplifycommands % backward compatible, will stay as it's used in styles
+
+\unexpanded\def\forgetall {\the\everyforgetall}
+\unexpanded\def\cleanupfeatures {\the\everycleanupfeatures}
+\unexpanded\def\simplifycommands{\the\everysimplifycommands}
\appendtoks
- \adjustsidefloatdisplaylines
-\to \everydisplay
+ \everypar\emptytoks % pretty important
+\to \everyforgetall
+
+%D Page building:
+
+\newtoks \everybeforepagebody
+\newtoks \everyafterpagebody
+
+\let\everypagebody\everybeforepagebody % backward compatible, will become obsolete
+
+%D Floats:
+
+\newtoks \everyinsidefloat
+
+%D Sectioning:
+
+\newtoks \everyheadstart
+
+%D Par building (experimental, used in xml <p> .. </p>)
+
+\newtoks \everybeginofpar
+\newtoks \everyendofpar
+%newtoks \everyparflush
+
+\unexpanded\def\bpar{\the\everybeginofpar\ignorespaces} % may interfere with \everypar
+\unexpanded\def\epar{\ifhmode\removeunwantedspaces\the\everyendofpar\fi} % test prevents problems with \bpar\epar
+
+%D Lists:
+
+\newtoks \everylistentry
+\newtoks \everysavesortkeys
+
+%D Marks:
-% \appendtoks
-% \flushsyncpositions
-% \to \everyheadstart
+\newtoks \everymarking
-% \appendtoks
-% \flushsyncresets
-% \to \everyendoftextbody
+%D Fonts:
+
+\newtoks \everyfont
+\newtoks \everyglobalbodyfont
+\newtoks \everydefinedfont
+
+\newevery \everybodyfont \EveryBodyFont
+\newevery \everyfontswitch \EveryFontSwitch
+
+\newtoks \everysetupbodyfont
+\newtoks \everyswitchtobodyfont
+
+%D Math:
+
+\newtoks \everybeforedisplayformula
+\newtoks \everymathematics
+
+\prependtoks \the\everymathematics \to \everymath
+\prependtoks \the\everymathematics \to \everydisplay
+
+%D Tables:
+
+\newtoks \everytable % we need to disstinguish kinds
+
+%D State mess:
+
+\newtoks \everypushsomestate
+\newtoks \everypopsomestate
+
+\unexpanded\def\pushsomestates{\the\everypushsomestate}
+\unexpanded\def\popsomestates {\the\everypopsomestate }
+
+%D More generic (used to be pushcolor etc)
+
+\newtoks\everystarttextproperties
+\newtoks\everystoptextproperties
+
+\unexpanded\def\starttextproperties{\the\everystarttextproperties}
+\unexpanded\def\stoptextproperties {\the\everystoptextproperties}
+
+%D \macros
+%D {trialtypesetting}
+%D
+%D We disable trial typesetting in the output routine,
+%D just to be sure.
+
+\prependtoks
+ \resettrialtypesetting
+\to \everybeforepagebody
+
+%D \macros
+%D {ifinpagebody,ifinsidecolumns,ifdoublesided,ifsinglesided}
+%D
+%D These will become system modes and conditionals
+
+\newif \ifinpagebody
+\newif \ifinsidecolumns
+\newif \ifdoublesided \doublesidedfalse
+\newif \ifsinglesided \singlesidedtrue
+\newif \ifinsidefloat
+\newif \ifdoingblocks
+\newif \ifgridsnapping
+
+%D \macros
+%D {ifproductionrun}
+%D
+%D This boolean can be used to bypass certain initializations.
+
+\newif\ifproductionrun
\appendtoks
- \ignorespaces
-\to \everybeginofpar
+ \productionruntrue
+\to \everydump
+
+%D \macros
+%D {everyboxedcontent, ifboxedcontent,
+%D startboxedcontent, stopboxedcontent}
+%D
+%D This one is relatively new and will be used as a more robust test for inner
+%D situations.
+
+\newif \ifboxedcontent
+\newtoks\everyboxedcontent
\appendtoks
- \removeunwantedspaces
- %strut % option ?
- % \flushsyncresets
- %setlastlinewidth % gone, will be done in lua
- \endgraf
-\to \everyendofpar
+ \boxedcontenttrue
+\to \everyboxedcontent
+
+\unexpanded\def\startboxedcontent{\bgroup\the\everyboxedcontent}
+
+\let\stopboxedcontent\egroup
+
+%D We store some original meanings, maybe in \type {math-ini}.
+
+\let\normalat \at
+\let\normalin \in
+\let\normalfrom \from
+%let\normalover \over
+\let\normalabout\about
+
+%D This will be implemented way later:
+
+\let\setlayoutcomponentattribute \gobbleoneargument
+\let\resetlayoutcomponentattribute\relax
+\let\layoutcomponentboxattribute \empty
\protect \endinput
diff --git a/tex/context/base/core-var.mkiv b/tex/context/base/core-var.mkiv
deleted file mode 100644
index f9baa8995..000000000
--- a/tex/context/base/core-var.mkiv
+++ /dev/null
@@ -1,254 +0,0 @@
-%D \module
-%D [ file=core-var,
-%D version=1998.02.21,
-%D title=\CONTEXT\ Core Macros,
-%D subtitle=Variables,
-%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 / Variables}
-
-\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
-%D it here.
-
-%D \macros
-%D {every...}
-%D
-%D A few every's. Some are only used in \MKII\ or \MKIV.
-
-%D Output routine:
-
-\newtoks \everybeforeoutput
-\newtoks \everyafteroutput
-
-%D Shipout:
-
-\newtoks \everyshipout
-\newtoks \everybeforeshipout
-\newtoks \everyaftershipout
-\newtoks \everyfirstshipout
-\newtoks \everylastshipout
-
-%D End of run:
-
-\newtoks \everybye
-\newtoks \everygoodbye
-\newtoks \everynotabene
-
-%D Document
-
-\newtoks \everysetupdocument
-\newtoks \everyendoftextbody
-
-\newtoks \everystarttext
-\newtoks \everystoptext
-
-%D Purity:
-
-\newtoks \everyforgetall
-\newtoks \everycleanupfeatures
-
-\unexpanded\def\cleanupfeatures{\the\everycleanupfeatures}
-\unexpanded\def\forgetall {\the\everyforgetall}
-
-\appendtoks
- \everypar\emptytoks % pretty important
-\to \everyforgetall
-
-%D Page building:
-
-\newtoks \everybeforepagebody
-\newtoks \everyafterpagebody
-
-\let \everypagebody \everybeforepagebody % backward compatible, will become obsolete
-
-%D Floats:
-
-\newtoks \everyinsidefloat
-
-%D Sectioning:
-
-\newtoks \everyheadstart
-
-%D Par building (experimental, used in xml <p> .. </p>)
-
-\newtoks \everybeginofpar
-\newtoks \everyendofpar
-%newtoks \everyparflush
-
-\unexpanded\def\bpar{\dostarttagged\t!paragraph\empty\the\everybeginofpar\ignorespaces} % may interfere with \everypar
-\unexpanded\def\epar{\ifhmode\removeunwantedspaces\the\everyendofpar\fi\dostoptagged } % test prevents problems with \bpar\epar
-
-%D Lists:
-
-\newtoks \everylistentry
-\newtoks \everysavesortkeys
-
-%D Marks:
-
-\newtoks \everymarking
-
-%D Fonts:
-
-\newtoks \everyfont
-\newtoks \everyglobalbodyfont
-\newtoks \everydefinedfont
-
-\newevery \everybodyfont \EveryBodyFont
-\newevery \everyfontswitch \EveryFontSwitch
-
-\newtoks \everysetupbodyfont
-\newtoks \everyswitchtobodyfont
-
-%D Math:
-
-\newtoks \everybeforedisplayformula
-\newtoks \everymathematics
-
-\prependtoks \the\everymathematics \to \everymath
-\prependtoks \the\everymathematics \to \everydisplay
-
-%D Tables
-
-\newtoks \everytable
-
-%D Simplification:
-
-\newtoks \simplifiedcommands
-
-\unexpanded\def\simplifycommands
- {\the\simplifiedcommands}
-
-\appendtoks
- \let\ =\space
-\to \simplifiedcommands
-
-%D State mess:
-
-\newtoks \everypushsomestate
-\newtoks \everypopsomestate
-
-\def\pushsomestates{\the\everypushsomestate}
-\def\popsomestates {\the\everypopsomestate }
-
-%D More generic (used to be pushcolor etc)
-
-\newtoks\everystarttextproperties
-\newtoks\everystoptextproperties
-
-\unexpanded\def\starttextproperties{\the\everystarttextproperties}
-\unexpanded\def\stoptextproperties {\the\everystoptextproperties}
-
-%D \macros
-%D {trialtypesetting}
-%D
-%D We disable trial typesetting in the output routine,
-%D just to be sure.
-
-\prependtoks \resettrialtypesetting \to \everybeforepagebody
-
-%D \macros
-%D {ifinpagebody,ifinsidecolumns,ifdoublesided,ifsinglesided}
-
-\newif \ifinpagebody
-\newif \ifinsidecolumns
-\newif \ifdoublesided \doublesidedfalse
-\newif \ifsinglesided \singlesidedtrue
-\newif \ifinsidefloat
-\newif \ifdoingblocks
-\newif \ifgridsnapping
-
-%D \macros
-%D {ifprocessingXML}
-%D
-%D We need this one even if no \XML\ is supported.
-
-% \newif\ifprocessingXML % old way
-
-%D \macros
-%D {ifproductionrun}
-%D
-%D This boolean can be used to bypass certain
-%D initializations.
-
-\newif\ifproductionrun \appendtoks \productionruntrue \to \everydump
-
-%D \macros
-%D {everyboxedcontent, ifboxedcontent,
-%D startboxedcontent, stopboxedcontent}
-%D
-%D This one is relatively new and will be used as a more
-%D robust test for inner situations.
-
-\newif \ifboxedcontent
-\newtoks\everyboxedcontent
-
-\appendtoks \boxedcontenttrue \to \everyboxedcontent
-
-\unexpanded\def\startboxedcontent{\bgroup\the\everyboxedcontent}
-\let\stopboxedcontent \egroup
-
-%D \macros
-%D {fastmode,silentmode}
-%D
-%D These commands are obsolete.
-
-\let\fastmode \relax
-\let\silentmode\relax
-
-%D \macros
-%D {defineselector,setupselector}
-%D
-%D \starttyping
-%D \defineselector[caption][max=2,n=2]
-%D
-%D \start
-%D \setupselector[caption][n=1]
-%D \placelist[figure][criterium=all]
-%D \stop
-%D
-%D \starttext
-%D \placefigure
-%D {\select{caption}{zapf}{\input zapf \relax}}
-%D {}
-%D \stoptext
-%D \stoptyping
-
-\unexpanded\def\defineselector{\dodoubleargument\dodefineselector}
-\unexpanded\def\setupselector {\dodoubleargument\dosetupselector}
-
-\def\dodefineselector[#1][#2]{\getparameters[\??sx#1][\c!max=2,\c!n=1,#2]}
-\def\dosetupselector [#1][#2]{\getparameters[\??sx#1][#2]}
-
-\unexpanded\def\select#1%
- {\filterfromnext
- {\executeifdefined{\??sx#1\c!max}1}
- {\executeifdefined{\??sx#1\c!n }1}}
-
-%D We store some original meanings, maybe in \type
-%D {math-ini}.
-
-\let\normalat \at
-\let\normalin \in
-\let\normalfrom \from
-%let\normalover \over
-\let\normalabout\about
-
-%D Add-ons:
-
-\let\setlayoutcomponentattribute \gobbleoneargument
-\let\resetlayoutcomponentattribute\relax
-\let\layoutcomponentboxattribute \empty
-
-\protect \endinput
diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv
index 816e59d9d..aca70f0c0 100644
--- a/tex/context/base/enco-ini.mkiv
+++ b/tex/context/base/enco-ini.mkiv
@@ -385,6 +385,6 @@
\appendtoks
\let\buildtextaccent\secondoftwoarguments
-\to \simplifiedcommands
+\to \everysimplifycommands
\protect \endinput
diff --git a/tex/context/base/file-ini.mkvi b/tex/context/base/file-ini.mkvi
index b0f6244aa..989241dd1 100644
--- a/tex/context/base/file-ini.mkvi
+++ b/tex/context/base/file-ini.mkvi
@@ -73,15 +73,17 @@
%D \popendofline
%D \stoptyping
+\installsystemnamespace{eolstack}
+
\newcount\c_system_files_eol_level
\unexpanded\def\pushendofline
{\advance\c_system_files_eol_level\plusone
- \expandafter\chardef\csname\??fi:eol:\number\c_system_files_eol_level\endcsname\catcode\endoflineasciicode
+ \expandafter\chardef\csname\??eolstack\number\c_system_files_eol_level\endcsname\catcode\endoflineasciicode
\catcode\endoflineasciicode\commentcatcode}
\unexpanded\def\popendofline
- {\catcode\endoflineasciicode\csname\??fi:eol:\number\c_system_files_eol_level\endcsname
+ {\catcode\endoflineasciicode\csname\??eolstack\number\c_system_files_eol_level\endcsname
\advance\c_system_files_eol_level\minusone}
\unexpanded\def\restoreendofline
@@ -101,11 +103,11 @@
\the\everystartreadingfile
\pushcatcodetable % saveguard
\setcatcodetable\ctxcatcodes
- \ctxlua{regimes.push()}}% temporarily this way
+ \ctxcommand{pushregime()}}% temporarily this way
\unexpanded\def\stopreadingfile
{\popcatcodetable % saveguard
- \ctxlua{regimes.pop()}% temporarily this way
+ \ctxcommand{popregime()}% temporarily this way
\the\everystopreadingfile
\global\advance\readingfilelevel\minusone}
@@ -203,11 +205,13 @@
%D This command obeys the standard method for locating files. We could
%D move this function to the \LUA\ end.
+\installsystemnamespace {fileonce}
+
\unexpanded\def\doonlyonce#whatever%
- {\ifcsname\??fi:#whatever\endcsname
+ {\ifcsname\??fileonce#whatever\endcsname
\expandafter\gobbleoneargument
\else
- \letgvalue{\??fi:#whatever}\relax
+ \letgvalue{\??fileonce#whatever}\relax
\expandafter\firstofoneargument
\fi}
@@ -215,11 +219,11 @@
{\doonlyonce{#name}{\doiffileelse{#name}{\inputgivenfile{#name}}\donothing}}
\unexpanded\def\doendinputonce#name%
- {\ifcsname\??fi:#name\endcsname
+ {\ifcsname\??fileonce#name\endcsname
\expandafter\endinput
\fi}
\unexpanded\def\forgetdoingonce#whatever%
- {\global\letbeundefined{\??fi:#whatever}}
+ {\global\letbeundefined{\??fileonce#whatever}}
\protect \endinput
diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi
index 4a54c6b2f..3bde3f268 100644
--- a/tex/context/base/file-job.mkvi
+++ b/tex/context/base/file-job.mkvi
@@ -75,17 +75,14 @@
\def\syst_files_load#name% only mkiv files
{\readsysfile{#name.\mksuffix}{\showmessage\m!system2{#name.\mksuffix}}\donothing}
+% obsolete, but we keep it as reference of what happened
+%
% \unexpanded\def\loadoptionfile
% {\readjobfile{\jobname.\f!optionextension}
% {\writestatus\m!system{\jobname.\f!optionextension\space loaded}%
% \ctxcommand{copyfiletolog("\jobname.\f!optionextension")}}%
% {\writestatus\m!system{no \jobname.\f!optionextension}}}
-\unexpanded\def\loadoptionfile % this one is soon obsolete
- {\readjobfile{\jobname.\f!optionextension}
- {\ctxcommand{copyfiletolog("\jobname.\f!optionextension")}}%
- {}}
-
% document structure
\ifdefined\textlevel\else \newcount\textlevel \fi % might go away
diff --git a/tex/context/base/font-sty.mkvi b/tex/context/base/font-sty.mkvi
index d8f01afa7..3e1bb96da 100644
--- a/tex/context/base/font-sty.mkvi
+++ b/tex/context/base/font-sty.mkvi
@@ -84,7 +84,7 @@
% \appendtoks
% \let\groupedcommand\thirdofthreearguments
-% \to \simplifiedcommands
+% \to \everysimplifycommands
%D This command also defines the keyword as command. This means
%D that the example definition of \type{bold} we gave before,
diff --git a/tex/context/base/grph-raw.mkiv b/tex/context/base/grph-raw.mkiv
index 5b488cf58..a40b78455 100644
--- a/tex/context/base/grph-raw.mkiv
+++ b/tex/context/base/grph-raw.mkiv
@@ -45,14 +45,14 @@
\unexpanded\def\bitmapimage[#1]#2%
{\hbox\bgroup
- \getparameters[\??gb][\c!color=rgb,\c!width=,\c!height=,\c!x=,\c!y=,#1]%
- \ctxlua{figures.bitmapimage {
+ \getdummyparameters[\c!color=rgb,\c!width=,\c!height=,\c!x=,\c!y=,#1]%
+ \ctxlua{figures.bitmapimage { % we could pass #1 directly ... todo
data = \!!bs#2\!!es,
- xresolution = "\@@gbx",
- yresolution = "\@@gby",
- colorspace = "\@@gbcolor",
- width = "\@@gbwidth",
- height = "\@@gbheight"
+ colorspace = "\directdummyparameter\c!color",
+ width = "\directdummyparameter\c!width",
+ height = "\directdummyparameter\c!height"
+ xresolution = "\directdummyparameter\c!x",
+ yresolution = "\directdummyparameter\c!y",
}}%
\egroup}
diff --git a/tex/context/base/grph-trf.mkiv b/tex/context/base/grph-trf.mkiv
index 4474eb8f1..87193ae4d 100644
--- a/tex/context/base/grph-trf.mkiv
+++ b/tex/context/base/grph-trf.mkiv
@@ -575,8 +575,9 @@
%D
%D \showsetup{setupclipping}
-\unexpanded\def\setupclipping
- {\dodoubleargument\getparameters[\??cp]}
+\installcorenamespace{clipping}
+
+\installdirectcommandhandler \??clipping {clipping}
\unexpanded\def\clip
{\dosingleempty\grph_clip}
@@ -584,62 +585,106 @@
\def\grph_clip[#1]% nb top->bottom left->right
{\bgroup
\iffirstargument
- \getparameters[\??cp][#1]%
+ \setupcurrentclipping[#1]%
\fi
\dowithnextboxcs\grph_clip_finish\hbox}
\def\grph_clip_finish
- {\doifelse\@@cpstate\v!start
+ {\doifelse{\clippingparameter\c!state}\v!start
\grph_clip_yes_finish
\grph_clip_nop_finish}
+% \def\grph_clip_yes_finish
+% {\ifdim\@@cpwidth>\zeropoint
+% \!!dimena\@@cpwidth
+% \!!dimenc\@@cphoffset
+% \else
+% \!!dimena\wd\nextbox
+% \divide\!!dimena \@@cpnx
+% \!!dimenc\@@cpx\!!dimena
+% \advance\!!dimenc -\!!dimena
+% \!!dimena\@@cpsx\!!dimena
+% \fi
+% \relax % sure
+% \ifdim\@@cpheight>\zeropoint
+% \!!dimenb\@@cpheight
+% \!!dimend\ht\nextbox
+% \advance\!!dimend -\@@cpvoffset
+% \advance\!!dimend -\!!dimenb
+% \else
+% \!!dimenb\ht\nextbox
+% \divide\!!dimenb \@@cpny
+% \!!dimend-\@@cpy\!!dimenb
+% \advance\!!dimend -\@@cpsy\!!dimenb
+% \advance\!!dimend \!!dimenb
+% \!!dimenb\@@cpsy\!!dimenb
+% \advance\!!dimend \ht\nextbox % dimend !
+% \fi
+% \setbox\nextbox\hbox % old
+% {\advance\!!dimenc -\@@cpleftoffset % new !
+% \advance\!!dimend -\@@cpbottomoffset % new ! % - added
+% \hskip-\!!dimenc\lower\!!dimend\box\nextbox}% old
+% \wd\nextbox\zeropoint
+% \ht\nextbox\zeropoint
+% \dp\nextbox\zeropoint
+% \setbox\nextbox\hbox
+% {\advance\!!dimena \@@cpleftoffset % new !
+% \advance\!!dimena \@@cprightoffset % new !
+% \advance\!!dimenb \@@cpbottomoffset % new !
+% \advance\!!dimenb \@@cptopoffset % new !
+% \dostartclipping\@@cpmp\!!dimena\!!dimenb % old
+% \box\nextbox
+% \dostopclipping}%
+% \setbox\nextbox\hbox % new !
+% {\!!dimena-\@@cpleftoffset % new !
+% \!!dimenb \@@cpbottomoffset % new ! % - removed
+% \hskip\!!dimena\lower\!!dimenb\box\nextbox}% new !
+% \wd\nextbox\!!dimena
+% \ht\nextbox\!!dimenb
+% \dp\nextbox\zeropoint
+% \box\nextbox
+% \egroup}
+
\def\grph_clip_yes_finish
- {\ifdim\@@cpwidth>\zeropoint
- \!!dimena\@@cpwidth
- \!!dimenc\@@cphoffset
+ {\ifdim\clippingparameter\c!width>\zeropoint
+ \scratchwidth \clippingparameter\c!width
+ \scratchxoffset\clippingparameter\c!hoffset
\else
- \!!dimena\wd\nextbox
- \divide\!!dimena \@@cpnx
- \!!dimenc\@@cpx\!!dimena
- \advance\!!dimenc -\!!dimena
- \!!dimena\@@cpsx\!!dimena
+ \scratchwidth\dimexpr\wd\nextbox/\clippingparameter\c!nx\relax
+ \scratchxoffset\dimexpr\clippingparameter\c!x\scratchwidth-\scratchwidth\relax
+ \scratchwidth\clippingparameter\c!sx\scratchwidth
\fi
\relax % sure
- \ifdim\@@cpheight>\zeropoint
- \!!dimenb\@@cpheight
- \!!dimend\ht\nextbox
- \advance\!!dimend -\@@cpvoffset
- \advance\!!dimend -\!!dimenb
+ \ifdim\clippingparameter\c!height>\zeropoint
+ \scratchheight\clippingparameter\c!height
+ \scratchyoffset\dimexpr\ht\nextbox-\clippingparameter\c!voffset-\scratchheight\relax
\else
- \!!dimenb\ht\nextbox
- \divide\!!dimenb \@@cpny
- \!!dimend-\@@cpy\!!dimenb
- \advance\!!dimend -\@@cpsy\!!dimenb
- \advance\!!dimend \!!dimenb
- \!!dimenb\@@cpsy\!!dimenb
- \advance\!!dimend \ht\nextbox % dimend !
+ \scratchheight\dimexpr\ht\nextbox/\clippingparameter\c!ny\relax
+ \scratchyoffset\dimexpr-\clippingparameter\c!y\scratchheight-\clippingparameter\c!sy\scratchheight+\scratchheight\relax
+ \scratchheight\clippingparameter\c!sy\scratchheight
+ \advance\scratchyoffset \ht\nextbox
\fi
- \setbox\nextbox\hbox % old
- {\advance\!!dimenc -\@@cpleftoffset % new !
- \advance\!!dimend -\@@cpbottomoffset % new ! % - added
- \hskip-\!!dimenc\lower\!!dimend\box\nextbox}% old
+ \setbox\nextbox\hbox
+ {\advance\scratchxoffset -\clippingparameter\c!leftoffset \relax
+ \advance\scratchyoffset -\clippingparameter\c!bottomoffset\relax
+ \hskip-\scratchxoffset
+ \lower\scratchyoffset
+ \box\nextbox}%
\wd\nextbox\zeropoint
\ht\nextbox\zeropoint
\dp\nextbox\zeropoint
\setbox\nextbox\hbox
- {\advance\!!dimena \@@cpleftoffset % new !
- \advance\!!dimena \@@cprightoffset % new !
- \advance\!!dimenb \@@cpbottomoffset % new !
- \advance\!!dimenb \@@cptopoffset % new !
- \dostartclipping\@@cpmp\!!dimena\!!dimenb % old
+ {\advance\scratchwidth \dimexpr\clippingparameter\c!leftoffset +\clippingparameter\c!rightoffset\relax
+ \advance\scratchheight\dimexpr\clippingparameter\c!bottomoffset+\clippingparameter\c!topoffset \relax
+ \dostartclipping{\clippingparameter\c!mp}\scratchwidth\scratchheight
\box\nextbox
\dostopclipping}%
- \setbox\nextbox\hbox % new !
- {\!!dimena-\@@cpleftoffset % new !
- \!!dimenb \@@cpbottomoffset % new ! % - removed
- \hskip\!!dimena\lower\!!dimenb\box\nextbox}% new !
- \wd\nextbox\!!dimena
- \ht\nextbox\!!dimenb
+ \setbox\nextbox\hbox
+ {\hskip-\clippingparameter\c!leftoffset
+ \lower \clippingparameter\c!bottomoffset
+ \box\nextbox}%
+ \wd\nextbox\scratchwidth
+ \ht\nextbox\scratchheight
\dp\nextbox\zeropoint
\box\nextbox
\egroup}
@@ -650,18 +695,18 @@
\setupclipping
[\c!state=\v!start,
- \c!n=1, % was 2
- \c!nx=\@@cpn,\c!x=1,\c!sx=1,
- \c!ny=\@@cpn,\c!y=1,\c!sy=1,
+ \c!n=\plusone, % was \plustwo
+ \c!nx=\clippingparameter\c!n,\c!x=\plusone,\c!sx=\plusone,
+ \c!ny=\clippingparameter\c!n,\c!y=\plusone,\c!sy=\plusone,
\c!width=\zeropoint,
\c!height=\zeropoint,
\c!hoffset=\zeropoint,
\c!voffset=\zeropoint,
\c!offset=\zeropoint,
- \c!leftoffset=\@@cpoffset, % \zeropoint,
- \c!rightoffset=\@@cpoffset, % \zeropoint,
- \c!topoffset=\@@cpoffset, % \zeropoint,
- \c!bottomoffset=\@@cpoffset,% \zeropoint,
+ \c!leftoffset=\clippingparameter\c!offset,
+ \c!rightoffset=\clippingparameter\c!offset,
+ \c!topoffset=\clippingparameter\c!offset,
+ \c!bottomoffset=\clippingparameter\c!offset,
\c!mp=]
%D \startbuffer
diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv
index 0e0c4b31c..68458e069 100644
--- a/tex/context/base/lang-lab.mkiv
+++ b/tex/context/base/lang-lab.mkiv
@@ -133,8 +133,7 @@
\let#7\firstofoneargument % to be checked
\let#8\firstofoneargument % to be checked
\let#9\firstofoneargument % to be checked
- \to \simplifiedcommands
- }
+ \to \everysimplifycommands}
\let\flushleftlabelclass \firstoftwoarguments
\let\flushrightlabelclass\secondoftwoarguments
@@ -262,15 +261,17 @@
%D which expands to {\em something} or {\em iets}, depending on
%D de current language.
+\installcorenamespace{translation}
+
\unexpanded\def\translate
{\dosingleempty\lang_translate}
\def\lang_translate[#1]%
- {\getparameters[\??lg][#1]%
- \ifcsname\??lg\currentlanguage\endcsname
- \csname\??lg\currentlanguage\endcsname
- \else\ifcsname\??lg\s!en\endcsname
- \csname\??lg\s!en\endcsname
+ {\getparameters[\??translation][#1]%
+ \ifcsname\??translation\currentlanguage\endcsname
+ \csname\??translation\currentlanguage\endcsname
+ \else\ifcsname\??translation\s!en\endcsname
+ \csname\??translation\s!en\endcsname
\else
[translation #1]%
\fi\fi}
@@ -293,8 +294,8 @@
%D \stoptyping
\def\assigntranslation[#1]\to#2%
- {\getparameters[\??lg][#1]%
- \edef#2{\csname\??lg\currentlanguage\endcsname}}
+ {\getparameters[\??translation][#1]%
+ \edef#2{\csname\??translation\currentlanguage\endcsname}}
%D \macros
%D {commalistsentence}
diff --git a/tex/context/base/lang-mis.mkiv b/tex/context/base/lang-mis.mkiv
index a537a2936..4d8b8e08a 100644
--- a/tex/context/base/lang-mis.mkiv
+++ b/tex/context/base/lang-mis.mkiv
@@ -683,7 +683,7 @@
\doglobal \appendtoks
\def|#1|{\ifx#1\empty\empty-\else#1\fi}%
- \to \simplifiedcommands
+ \to \everysimplifycommands
\egroup
diff --git a/tex/context/base/luat-ini.mkiv b/tex/context/base/luat-ini.mkiv
index 46b2d1f7f..094c4ee53 100644
--- a/tex/context/base/luat-ini.mkiv
+++ b/tex/context/base/luat-ini.mkiv
@@ -108,16 +108,18 @@
%D Beware: because \type {\expanded} is een convert command, the error
%D message will show \type{<inserted text>} as part of the message.
+\installcorenamespace{luacode}
+
\def\luat_start_named_lua_code#1%
{\begingroup
\obeylualines
\obeyluatokens
- \csname\??lu:c:#1\endcsname}
+ \csname\??luacode#1\endcsname}
\unexpanded\def\definenamedlua[#1]#2[#3]% no optional arg handling here yet
- {\ifcsname\??lu:c:#1\endcsname \else
+ {\ifcsname\??luacode#1\endcsname \else
\scratchcounter\ctxlua{lua.registername("#1","#3")}%
- \normalexpanded{\edef\csname\??lu:c:#1\endcsname##1\csname\e!stop#1\v!code\endcsname}%
+ \normalexpanded{\edef\csname\??luacode#1\endcsname##1\csname\e!stop#1\v!code\endcsname}%
{\endgroup\noexpand\directlua\the\scratchcounter{protect("#1\s!data")##1}}%
\expandafter\def \csname\e!start#1\v!code\endcsname {\luat_start_named_lua_code{#1}}%
\expandafter\edef\csname #1\v!code\endcsname##1{\noexpand\directlua\the\scratchcounter{protect("#1\s!data")##1}}%
diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv
index 83e0a6f71..73cd4be7e 100644
--- a/tex/context/base/lxml-ini.mkiv
+++ b/tex/context/base/lxml-ini.mkiv
@@ -313,7 +313,7 @@
\xmlprocessingmode\executeifdefined{\??xmldefaults\directxmlparameter\c!default}\plusone
\to \everysetupxml
-\unexpanded\def\xmlinitialize % is this still needed?
+\unexpanded\def\initializexmlprocessing % is this still needed?
{\the\everysetupxml}
\let\p_lxml_entities\empty
diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv
index 94800b3ba..57727b03a 100644
--- a/tex/context/base/math-ali.mkiv
+++ b/tex/context/base/math-ali.mkiv
@@ -15,17 +15,6 @@
\unprotect
-% helpers .. will move
-
-\def\doxxdoubleempty#1#2%
- {\ifx#2[\expandafter\dodoxxdoubleempty\else\expandafter\noxxdoubleempty\fi#1#2}
-
-\def\dodoxxdoubleempty#1[#2]#3%
- {\ifx#3[\else\expandafter\nonoxxdoubleempty\fi#1[#2]#3}
-
-\def\noxxdoubleempty #1{#1[][]}
-\def\nonoxxdoubleempty#1[#2]{#1[#2][]}
-
%D The code here has been moved from other files. Beware: the \MKII\ and
%D \MKIV\ code is not gathered in files with the same name. In the
%D meantime this code has been adapted to \MKIV\ but mnore is possible.
@@ -38,19 +27,25 @@
% n>1 #### needed, strange # interaction in recurse
+\newtoks\c_math_align_a
+\newtoks\c_math_align_b
+\newtoks\c_math_align_c
+
\def\math_build_eqalign
{\scratchtoks\emptytoks
- \dorecurse{\mathalignmentparameter\c!m}
- {\ifnum\recurselevel>\plusone
- %\appendtoks
- % \tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint
- %\to\scratchtoks
- \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint}%
- \fi
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
- \dorecurse{\numexpr\mathalignmentparameter\c!n-\plusone\relax}
- {\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}}%
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}}
+ \dorecurse{\mathalignmentparameter\c!m}\def\math_build_eqalign
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_c}}}
+
+\def\math_build_eqalign_step
+ {\ifnum\recurselevel>\plusone
+ %\appendtoks
+ % \tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint
+ %\to\scratchtoks
+ \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint}%
+ \fi
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_a}}%
+ \dorecurse{\numexpr\mathalignmentparameter\c!n-\plusone\relax}
+ {\normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_b}}}}
\def\math_math_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks\displaystyle{{}#1{}}$}
\def\math_text_in_eqalign#1{$\tabskip\zeropoint\everycr\emptytoks#1$}
@@ -73,14 +68,14 @@
% use zeroskipplusfill
\def\math_prepare_r_eqalign_no
- {\!!toksa{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
- \!!toksb{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \c_math_align_b{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
\ifnum\mathraggedstatus=\plusone
- \!!toksc{\hfil&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else\ifnum\mathraggedstatus=\plusthree
- \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else
- \!!toksc{\hfil\tabskip\centering&\llap{\span\math_text_in_eqalign{##}}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil\tabskip\centering&\llap{\span\math_text_in_eqalign{##}}\tabskip\zeropoint}%
\fi\fi
\global\mathnumberstatus\zerocount
\math_build_eqalign
@@ -88,15 +83,15 @@
\tabskip\centering}
\def\math_prepare_l_eqalign_no
- {\!!toksa{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
- \!!toksb{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \c_math_align_b{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
% problem: number is handled after rest and so ends up in the margin
\ifnum\mathraggedstatus=\plusone
- \!!toksc{\hfil&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else\ifnum\mathraggedstatus=\plusthree
- \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\kern-\displaywidth\span\math_rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\kern-\displaywidth\span\math_rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else
- \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\fi\fi
\global\mathnumberstatus\zerocount
\math_build_eqalign
@@ -112,7 +107,7 @@
\let\math_finish_eqalign_no\relax
\fi
#1%
- \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#2\crcr}%
+ \halign \ifcase\eqalignmode \or to \displaywidth \fi \expandafter {\the\scratchtoks\crcr#2\crcr}%
\math_finish_eqalign_no}
\def\math_both_eqalign_no_aligned#1%
@@ -128,7 +123,7 @@
\fi
\fi
#1%
- \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}
+ \halign \ifcase\eqalignmode \or to \displaywidth \fi \expandafter \bgroup\the\scratchtoks\crcr}
\def\math_rlap#1%
{\setbox\scratchbox\hbox{#1}%
@@ -221,7 +216,7 @@
\setupmathalignment
[\c!n=2,
\c!m=1,
- \c!distance=1em]
+ \c!distance=\emwidth]
\definemathalignment[align] % default case (this is what amstex users expect)
\definemathalignment[\v!mathalignment] % prefered case (this is cleaner, less clashing)
@@ -408,8 +403,8 @@
\installcommandhandler \??mathcases {mathcases} \??mathcases
\setupmathcases
- [\c!distance=1em,
- \c!numberdistance=2.5em,
+ [\c!distance=\emwidth,
+ \c!numberdistance=2.5\emwidth,
\c!left={\left\{\mskip\thinmuskip},
\c!right={\right.}]
@@ -434,7 +429,7 @@
\def\NC{\math_cases_NC}%
\def\MC{\math_cases_NC\ifmmode\else$\def\endmath{$}\fi}%
\global\let\math_cases_NC\math_cases_NC_indeed
- \def\NR{\unskip\endmath&\global\let\math_cases_NC\math_cases_NC_indeed\doxxdoubleempty\math_cases_NR}%
+ \def\NR{\unskip\endmath&\global\let\math_cases_NC\math_cases_NC_indeed\dodirectdoubleempty\math_cases_NR}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
@@ -515,7 +510,7 @@
\installcommandhandler \??mathmatrix {mathmatrix} \??mathmatrix
\setupmathmatrix
- [\c!distance=1em,
+ [\c!distance=\emwidth,
\c!left=,
\c!right=,
\c!align=\v!middle]
@@ -570,20 +565,20 @@
\definemathmatrix[\v!mathmatrix]
\def\math_matrix_prepare
- {\!!toksa{\strut\math_first_in_eqalign\math_left_of_equalign\span
+ {\c_math_align_a{\strut\math_first_in_eqalign\math_left_of_equalign\span
\math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
- \!!toksb{&\hskip\mathmatrixparameter\c!distance
+ \c_math_align_b{&\hskip\mathmatrixparameter\c!distance
\math_next_in_eqalign\math_left_of_equalign\span
\math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
- \!!toksc{&&\hskip\mathmatrixparameter\c!distance
+ \c_math_align_c{&&\hskip\mathmatrixparameter\c!distance
\math_left_of_equalign\span
\math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
\scratchtoks\emptytoks
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksa}}%
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_a}}%
\dorecurse{\numexpr\scratchcounter-\plusone\relax}
- {\normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksb}}}%
- \normalexpanded{\scratchtoks{\the\scratchtoks\the\!!toksc}}%
- \halign \@EA \bgroup\the\scratchtoks \crcr}
+ {\normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_b}}}%
+ \normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_c}}%
+ \halign \expandafter \bgroup\the\scratchtoks \crcr}
\unexpanded\def\dodomatrixNC
{\gdef\domatrixNC{\endmath&}}
diff --git a/tex/context/base/math-arr.mkiv b/tex/context/base/math-arr.mkiv
index f18d6be2b..91bb7889b 100644
--- a/tex/context/base/math-arr.mkiv
+++ b/tex/context/base/math-arr.mkiv
@@ -40,146 +40,102 @@
% \smash-$
% $}
-\def\exmthfont#1{\mr} % \symbolicsizedfont#1\plusone{MathExtension}}
-
-\def\domthfrac#1#2#3#4#5#6#7%
+\def\math_stylebuilders_fract#1#2#3#4#5#6#7%
{\begingroup
\mathsurround\zeropoint
\setbox0\hbox{$#1 #6$}%
\setbox2\hbox{$#1 #7$}%
- \dimen0\wd0
- \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
+ \dimen0\wd\ifdim\wd2>\wd0 2\else 0\fi
\setbox4\hbox to \dimen0{\leaders\hbox{#4}\hss#5}%
\mathord{\vcenter{{\offinterlineskip
\hbox to \dimen0{\hss\box0\hss}%
- \kern \ht4%
+ \kern\ht4%
\hbox to \dimen0{\hss\copy4\hss}%
- \kern \ht4%
+ \kern\ht4%
\hbox to \dimen0{\hss\box2\hss}}}}%
\endgroup}
-\def\domthsqrt#1#2#3#4#5%
+\def\math_stylebuilders_sqrt#1#2#3#4#5%
{\begingroup
\mathsurround\zeropoint
\setbox0\hbox{$#1 #5$}%
- \dimen0=1.05\ht0 \advance\dimen0 1pt \ht0 \dimen0
- \dimen0=1.05\dp0 \advance\dimen0 1pt \dp0 \dimen0
- \dimen0\wd0
- \setbox4\hbox to \dimen0{\exmthfont#2\leaders\hbox{#3}\hfill#4}%
- \delimitershortfall=0pt
- \nulldelimiterspace=0pt
- \setbox2\hbox{$\left\delimiter"0270370 \vrule height\ht0 depth \dp0 width0pt
- \right.$}%
- \mathord{\vcenter{\hbox{\copy2
- \rlap{\raise\dimexpr\ht2-\ht4\relax\copy4}\copy0}}}%
+ \ht0\dimexpr1.05\ht0+\onepoint\relax
+ \dp0\dimexpr1.05\dp0+\onepoint\relax
+ \setbox4\hbox to \wd0{\mr#2\leaders\hbox{#3}\hfill#4}%
+ \delimitershortfall\zeropoint
+ \nulldelimiterspace\zeropoint
+ \setbox2\hbox{$\left\delimiter"0270370 \vrule \!!height\ht0 \!!depth \dp0 \!!width\zeropoint\right.$}% is this the right code point?
+ \mathord{\vcenter{\hbox{\copy2\rlap{\raise\dimexpr\ht2-\ht4\relax\copy4}\copy0}}}%
\endgroup}
\def\mthfrac#1#2#3#4#5{\mathchoice
- {\domthfrac\displaystyle \textface {#1}{#2}{#3}{#4}{#5}}%
- {\domthfrac\textstyle \textface {#1}{#2}{#3}{#4}{#5}}%
- {\domthfrac\scriptstyle \scriptface {#1}{#2}{#3}{#4}{#5}}%
- {\domthfrac\scriptscriptstyle\scriptscriptface{#1}{#2}{#3}{#4}{#5}}}
+ {\math_stylebuilders_frac\displaystyle \textface {#1}{#2}{#3}{#4}{#5}}%
+ {\math_stylebuilders_frac\textstyle \textface {#1}{#2}{#3}{#4}{#5}}%
+ {\math_stylebuilders_frac\scriptstyle \scriptface {#1}{#2}{#3}{#4}{#5}}%
+ {\math_stylebuilders_frac\scriptscriptstyle\scriptscriptface{#1}{#2}{#3}{#4}{#5}}}
\def\mthsqrt#1#2#3{\mathchoice
- {\domthsqrt\displaystyle \textface {#1}{#2}{#3}}%
- {\domthsqrt\textstyle \textface {#1}{#2}{#3}}%
- {\domthsqrt\scriptstyle \textface {#1}{#2}{#3}}%
- {\domthsqrt\scriptscriptstyle\textface {#1}{#2}{#3}}}
-
-% temp here
-
-%D We next define extensible arrows. Extensible arrows are arrows that
-%D change their length according to the width of the text to be placed
-%D above and below the arrow. Since we need to define a lot of arrows,
-%D we first define some helper macros. The basic idea is to measure
-%D the width of the box to be placed above and below the arrow, and
-%D make the \quotation{body} of the arrow as long as the bigger of the
-%D two widths.
-
-\def\mtharrfactor{1}
-\def\mtharrextra {0}
-
-% \def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
-% {\begingroup
-% \def\mtharrfactor{1}%
-% \def\mtharrextra {0}%
-% \processaction[#1] % will be sped up
-% [ \v!none=>\def\mtharrfactor{0},
-% \v!small=>\def\mtharrextra{10},
-% \v!medium=>\def\mtharrextra{15},
-% \v!big=>\def\mtharrextra{20},
-% \v!normal=>,
-% \v!default=>,
-% \v!unknown=>\doifnumberelse{#1}{\def\mtharrextra{#1}}\donothing]%
-% \mathsurround\zeropoint
-% \muskip0=\thirdoffourarguments #2mu
-% \muskip2=\fourthoffourarguments #2mu
-% \muskip4=\firstoffourarguments #2mu
-% \muskip6=\secondoffourarguments #2mu
-% \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
-% \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
-% \setbox0\hbox{$\scriptstyle
-% \mkern\muskip4\relax
-% \mkern\muskip0\relax
-% #5\relax
-% \mkern\muskip2\relax
-% \mkern\muskip6\relax
-% $}%
-% \setbox4\hbox{#3\displaystyle}%
-% \dimen0\wd0
-% \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
-% \setbox2\hbox{$\scriptstyle
-% \mkern\muskip4\relax
-% \mkern\muskip0\relax
-% #4\relax
-% \mkern\muskip2\relax
-% \mkern\muskip6\relax
-% $}%
-% \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
-% \setbox4\hbox to \dimen0{#3\displaystyle}%
-% \mathrel{\mathop{\hbox to \dimen0{\hss\copy4\hss}}\limits\normalsuperscript{\box0}\normalsubscript{\box2}}%
-% \endgroup}
-
-\def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
+ {\math_stylebuilders_sqrt\displaystyle \textface{#1}{#2}{#3}}%
+ {\math_stylebuilders_sqrt\textstyle \textface{#1}{#2}{#3}}%
+ {\math_stylebuilders_sqrt\scriptstyle \textface{#1}{#2}{#3}}%
+ {\math_stylebuilders_sqrt\scriptscriptstyle\textface{#1}{#2}{#3}}}
+
+%D We next define extensible arrows. Extensible arrows are arrows that change their
+%D length according to the width of the text to be placed above and below the arrow.
+%D Since we need to define a lot of arrows, we first define some helper macros. The
+%D basic idea is to measure the width of the box to be placed above and below the
+%D arrow, and make the \quote {body} of the arrow as long as the bigger of the two
+%D widths.
+
+\installcorenamespace{matharrowsettings}
+
+\def\m_math_arrows_factor{1}
+\def\m_math_arrows_extra {0}
+
+\setvalue{\??matharrowsettings\v!none }{\def\m_math_arrows_factor{0}}
+\setvalue{\??matharrowsettings\v!small }{\def\m_math_arrows_extra{10}}
+\setvalue{\??matharrowsettings\v!medium }{\def\m_math_arrows_extra{15}}
+\setvalue{\??matharrowsettings\v!big }{\def\m_math_arrows_extra{20}}
+\setvalue{\??matharrowsettings\v!normal }{}
+\setvalue{\??matharrowsettings }{}
+\setvalue{\??matharrowsettings\s!unknown}{\doifnumberelse\p_mathspacing{\let\m_math_arrows_extra\p_mathspacing}\donothing}
+
+\def\math_arrows_construct#1#2#3#4#5% hm, looks like we do a double mathrel (a bit cleaned up .. needs checking)
{\begingroup
- \def\mtharrfactor{1}%
- \def\mtharrextra {0}%
- \processaction[#1] % will be sped up
- [ \v!none=>\def\mtharrfactor{0},
- \v!small=>\def\mtharrextra{10},
- \v!medium=>\def\mtharrextra{15},
- \v!big=>\def\mtharrextra{20},
- \v!normal=>,
- \v!default=>,
- \v!unknown=>\doifnumberelse{#1}{\def\mtharrextra{#1}}\donothing]%
+ \def\m_math_arrows_factor{1}%
+ \def\m_math_arrows_extra {0}%
+ \edef\p_math_spacing{#1}%
+ \csname\??matharrowsettings
+ \ifcsname\??matharrowsettings\p_mathspacing\endcsname\p_mathspacing\else\s!unknown\fi
+ \endcsname
\mathsurround\zeropoint
- \muskip0=\thirdoffourarguments #2mu
- \muskip2=\fourthoffourarguments #2mu
- \muskip0=\mtharrfactor\muskip0
- \muskip2=\mtharrfactor\muskip2
- \advance\muskip0 \mtharrextra mu
- \advance\muskip2 \mtharrextra mu
- \advance\muskip0 \firstoffourarguments #2mu
- \advance\muskip2 \secondoffourarguments #2mu
+ \muskip0=\muexpr\m_math_arrows_factor\muexpr\thirdoffourarguments #2\onemuskip\relax+\m_math_arrows_extra\onemuskip+\firstoffourarguments #2\onemuskip\relax
+ \muskip2=\muexpr\m_math_arrows_factor\muexpr\fourthoffourarguments#2\onemuskip\relax+\m_math_arrows_extra\onemuskip+\secondoffourarguments#2\onemuskip\relax
\setbox0\hbox{$\scriptstyle
\mkern\muskip0\relax
#5\relax
\mkern\muskip2\relax
$}%
- \setbox4\hbox{#3\displaystyle}%
- \dimen0\wd0
- \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
\setbox2\hbox{$\scriptstyle
\mkern\muskip0\relax
#4\relax
\mkern\muskip2\relax
$}%
- \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
- \setbox4\hbox to \dimen0{#3\displaystyle}%
+ \setbox4\hbox{#3\displaystyle}%
+ \dimen0\wd0\relax
+ \ifdim\wd2>\dimen0
+ \dimen0\wd2\relax
+ \fi
+ \ifdim\wd4>\dimen0
+ \dimen0\wd4\relax
+ \fi
+ \ifdim\wd4=\dimen0\else
+ \setbox4\hbox to \dimen0{#3\displaystyle}%
+ \fi
\mathrel{\mathop{\hbox to \dimen0{\hss\copy4\hss}}\limits\normalsuperscript{\box0}\normalsubscript{\box2}}%
\endgroup}
-\let\domthxarrsingle\domthxarr
+\let\math_arrows_construct_single\math_arrows_construct
%D There are some arrows which are created by stacking two arrows. The next
%D macro helps in defining such \quotation{double arrows}.
@@ -194,29 +150,27 @@
% \chemical{SO_2}
% \stopchemicalformula
-\def\domthxarrdouble#1#2#3#4#5#6#7% opt l r sp rs top bot
+\def\math_arrows_construct_double#1#2#3#4#5#6#7% opt l r sp rs top bot
{\mathrel
- {\scratchdimen.32ex\relax % was .22, todo: make configurable
- \setbox0\hbox{$\domthxarr{#1}{#2}{#4}{\phantom{#6}}{#7}$}%
- \setbox2\hbox{$\domthxarr{#1}{#3}{#5}{#6}{\phantom{#7}}$}%
+ {\scratchdimen.32\exheight\relax % was .22, todo: make configurable
+ \setbox0\hbox{$\math_arrows_construct{#1}{#2}{#4}{\phantom{#6}}{#7}$}%
+ \setbox2\hbox{$\math_arrows_construct{#1}{#3}{#5}{#6}{\phantom{#7}}$}%
\raise\scratchdimen\box0
\kern-\wd2
\lower\scratchdimen\box2}}
%D \macros{definematharrow}
%D
-%D Macro for defining new arrows. We can define two types of
-%D arrows|<|single arrows and double arrows. Single arrows are defined
-%D as
+%D Macro for defining new arrows. We can define two types of arrows|<|single arrows
+%D and double arrows. Single arrows are defined as
%D
%D \starttyping
%D \definematharrow [xrightarrow] [0359] [\rightarrowfill]
%D \stoptyping
%D
-%D The first argument is the name of the arrow (\tex{xrightarrow} in
-%D this case.) The second argument consists of a set of 4 numbers and
-%D specify the spacing correction in math units~\type{mu}. These
-%D numbers define:
+%D The first argument is the name of the arrow (\tex {xrightarrow} in this case.) The
+%D second argument consists of a set of 4 numbers and specify the spacing correction
+%D in math units~\type {mu}. These numbers define:
%D
%D \startlines
%D 1st number: arrow||tip correction
@@ -225,9 +179,9 @@
%D 4th number: space (multiplied by \tex{matharrfactor} and advanced by \tex{matharrextra})
%D \stoplines
%D
-%D The third argument is the name of the extensible fill. The third
-%D argument is optional when the arrow is redefined later (this is
-%D useful for font specific tweaking of the skips.) For example,
+%D The third argument is the name of the extensible fill. The third argument is optional
+%D when the arrow is redefined later (this is useful for font specific tweaking of the
+%D skips.) For example,
%D
%D \startbuffer
%D \math{\xrightarrow{above}}
@@ -245,78 +199,80 @@
%D [\rightharpoonupfill,\leftharpoondownfill]
%D \stoptyping
%D
-%D The second and the third set of arguments consist of comma
-%D separated values. The first element of the second argument
-%D (\type{3095}) corresponds to the spacing correction of top arrow
-%D fill (\tex{rightarrowupfill}). Similarly, \type{0359} corresponds
-%D to bottom arrow fill \tex{leftharpoondownfill}). Stacking them on
-%D top of each other we get $\xrightleftharpoons[big]{above}{below}$.
-%D The following math arrows are defined
+%D The second and the third set of arguments consist of comma separated values. The
+%D first element of the second argument (\type {3095}) corresponds to the spacing
+%D correction of top arrow fill (\tex{rightarrowupfill}). Similarly, \type {0359}
+%D corresponds to bottom arrow fill \tex {leftharpoondownfill}). Stacking them on
+%D top of each other we get $\xrightleftharpoons [big] {above} {below}$. The
+%D following math arrows are defined
%D
%D \placetable[none]{}{\starttable[|l|m|]
-%D \NC \tex{xrightarrow } \NC \xrightarrow [big] \NC \NR
-%D \NC \tex{xleftarrow } \NC \xleftarrow [big] \NC \NR
-%D \NC \tex{xequal } \NC \xequal [big] \NC \NR
-%D \NC \tex{xRightarrow } \NC \xRightarrow [big] \NC \NR
-%D \NC \tex{xLeftarrow } \NC \xLeftarrow [big] \NC \NR
-%D \NC \tex{xLeftrightarrow } \NC \xLeftrightarrow [big] \NC \NR
-%D \NC \tex{xleftrightarrow } \NC \xleftrightarrow [big] \NC \NR
-%D \NC \tex{xmapsto } \NC \xmapsto [big] \NC \NR
-%D \NC \tex{xtwoheadrightarrow } \NC \xtwoheadrightarrow [big] \NC \NR
-%D \NC \tex{xtwoheadleftarrow } \NC \xtwoheadleftarrow [big] \NC \NR
-%D \NC \tex{xrightharpoondown } \NC \xrightharpoondown [big] \NC \NR
-%D \NC \tex{xrightharpoonup } \NC \xrightharpoonup [big] \NC \NR
-%D \NC \tex{xleftharpoondown } \NC \xleftharpoondown [big] \NC \NR
-%D \NC \tex{xleftharpoonup } \NC \xleftharpoonup [big] \NC \NR
-%D \NC \tex{xhookleftarrow } \NC \xhookleftarrow [big] \NC \NR
-%D \NC \tex{xhookrightarrow } \NC \xhookrightarrow [big] \NC \NR
-%D \NC \tex{xleftrightharpoons } \NC \xleftrightharpoons [big] \NC \NR
-%D \NC \tex{xrightleftharpoons } \NC \xrightleftharpoons [big] \NC \NR
+%D \NC \tex{xrightarrow} \NC \xrightarrow [big] \NC \NR
+%D \NC \tex{xleftarrow} \NC \xleftarrow [big] \NC \NR
+%D \NC \tex{xequal} \NC \xequal [big] \NC \NR
+%D \NC \tex{xRightarrow} \NC \xRightarrow [big] \NC \NR
+%D \NC \tex{xLeftarrow} \NC \xLeftarrow [big] \NC \NR
+%D \NC \tex{xLeftrightarrow} \NC \xLeftrightarrow [big] \NC \NR
+%D \NC \tex{xleftrightarrow} \NC \xleftrightarrow [big] \NC \NR
+%D \NC \tex{xmapsto} \NC \xmapsto [big] \NC \NR
+%D \NC \tex{xtwoheadrightarrow} \NC \xtwoheadrightarrow [big] \NC \NR
+%D \NC \tex{xtwoheadleftarrow} \NC \xtwoheadleftarrow [big] \NC \NR
+%D \NC \tex{xrightharpoondown} \NC \xrightharpoondown [big] \NC \NR
+%D \NC \tex{xrightharpoonup} \NC \xrightharpoonup [big] \NC \NR
+%D \NC \tex{xleftharpoondown} \NC \xleftharpoondown [big] \NC \NR
+%D \NC \tex{xleftharpoonup} \NC \xleftharpoonup [big] \NC \NR
+%D \NC \tex{xhookleftarrow} \NC \xhookleftarrow [big] \NC \NR
+%D \NC \tex{xhookrightarrow} \NC \xhookrightarrow [big] \NC \NR
+%D \NC \tex{xleftrightharpoons} \NC \xleftrightharpoons [big] \NC \NR
+%D \NC \tex{xrightleftharpoons} \NC \xrightleftharpoons [big] \NC \NR
%D \stoptable}
+%D If needed this can be optimized (i.e. we can preexpand using \type
+%D {\docheckedpair}).
+
\unexpanded\def\definematharrow
- {\doquadrupleargument\dodefinematharrow}
+ {\doquadrupleargument\math_arrows_define}
-\def\dodefinematharrow[#1][#2][#3][#4]% name type[none|both] template command
+\def\math_arrows_define[#1][#2][#3][#4]% name type[none|both] template command
{\iffourthargument
- \executeifdefined{dodefine#2arrow}\gobblethreearguments{#1}{#3}{#4}%
+ \executeifdefined{math_arrows_define_#2}\gobblethreearguments{#1}{#3}{#4}%
\else\ifthirdargument
- \dodefinebotharrow{#1}{#2}{#3}%
+ \math_arrows_define_both{#1}{#2}{#3}%
\else\ifsecondargument
- \redefinebotharrow{#1}{#2}{#3}%
+ \math_arrows_define_both_again{#1}{#2}{#3}%
\fi\fi\fi}
-\def\redefinebotharrow#1#2#3% real dirty, this overload!
- {\doifdefined{#1}
- {\pushmacro\dohandlemtharrow
- \def\dohandlemtharrow[##1][##2]{\setuvalue{#1}{\dohandlemtharrow[#2][##2]}}%
- % == \def\dohandlemtharrow[##1][##2]{\dodefinebotharrow{#1}{#2}{##2}}%
- \getvalue{#1}%
- \popmacro\dohandlemtharrow}}
+\def\math_arrows_define_both_again#1#2#3% real dirty, this overload!
+ {\ifcsname#1\endcsname
+ \pushmacro\math_arrows_do
+ \def\math_arrows_do[##1][##2]{\setuvalue{#1}{\math_arrows_do[#2][##2]}}%
+ \getvalue{#1}%
+ \popmacro\math_arrows_do
+ \fi}
-\def\dodefinebotharrow#1#2#3%
- {\setuvalue{#1}{\dohandlemtharrow[#2][#3]}}
+\def\math_arrows_define_both#1#2#3%
+ {\setuvalue{#1}{\math_arrows_do[#2][#3]}}
-\def\dohandlemtharrow
- {\dotripleempty\doxmtharrow}
+\unexpanded\def\math_arrows_do
+ {\dotripleempty\math_arrows_handle}
-\def\doxmtharrow[#1][#2][#3]% #3 == optional arg
- {\def\dodoxmtharrow{\dododoxmtharrow[#1,\empty,\empty][#2,\empty,\empty][#3]}% {##1}{##2}
- \dodoublegroupempty\dodoxmtharrow}
+\def\math_arrows_handle[#1][#2][#3]% #3 == optional arg .. \empty can be just 'empty'
+ {\def\math_arrows_handle_indeed{\math_arrows_handle_finalize[#1,\empty,\empty][#2,\empty,\empty][#3]}% {##1}{##2}
+ \dodoublegroupempty\math_arrows_handle_indeed}
-\def\dododoxmtharrow[#1,#2,#3][#4,#5,#6][#7]#8#9% [3] is the optional arg
+\def\math_arrows_handle_finalize[#1,#2,#3][#4,#5,#6][#7]#8#9% [3] is the optional arg
{\edef\!!stringa{#2}%
\ifx\!!stringa\empty
\ifsecondargument
- \mathrel{\domthxarrsingle{#7}{#1}{#4}{#8}{#9}}%
+ \mathrel{\math_arrows_construct_single{#7}{#1}{#4}{#8}{#9}}%
\else
- \mathrel{\domthxarrsingle{#7}{#1}{#4}{}{#8}}%
+ \mathrel{\math_arrows_construct_single{#7}{#1}{#4}{}{#8}}%
\fi
\else
\ifsecondargument
- \mathrel{\domthxarrdouble{#7}{#1}{#2}{#4}{#5}{#8}{#9}}%
+ \mathrel{\math_arrows_construct_double{#7}{#1}{#2}{#4}{#5}{#8}{#9}}%
\else
- \mathrel{\domthxarrdouble{#7}{#1}{#2}{#4}{#5}{}{#8}}%
+ \mathrel{\math_arrows_construct_double{#7}{#1}{#2}{#4}{#5}{}{#8}}%
\fi
\fi}
@@ -324,34 +280,32 @@
%D \macros{mtharrowfill,defaultmtharrowfill}
%D
-%D To extend the arrows we need to define a \quotation{math arrow
-%D fill}. This command takes 8 arguments: the first four correspond
-%D the second argument of \tex{definematharrow} explained above. The
-%D other three specify the tail, body and head of the arrow. The last
-%D argument specifies the math-mode in which the arrow is drawn.
-%D \tex{defaultmtharrowfill} has values tweaked to match Latin Modern
-%D fonts. For fonts that are significantly different (e.g. cows) a
+%D To extend the arrows we need to define a \quotation {math arrow fill}. This
+%D command takes 8 arguments: the first four correspond the second argument of
+%D \tex {definematharrow} explained above. The other three specify the tail,
+%D body and head of the arrow. The last argument specifies the math-mode in which
+%D the arrow is drawn. \tex {defaultmtharrowfill} has values tweaked to match
+%D Latin Modern fonts. For fonts that are significantly different (e.g. cows) a
%D different set of values need to be determined.
\def\mtharrowfill#1#2#3#4#5#6#7#8%
- {$\mathsurround 0pt
- \thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
+ {$\mathsurround\zeropoint
+ \thickmuskip\zeromuskip\medmuskip\thickmuskip\thinmuskip\thickmuskip
\relax#8#5%
- \mkern-#1mu
- \cleaders\hbox{$#8\mkern -#2mu#6\mkern -#3mu$}\hfill
- \mkern-#4mu#7$}
+ \mkern-#1\onemuskip
+ \cleaders\hbox{$#8\mkern-#2\onemuskip#6\mkern-#3\onemuskip$}\hfill
+ \mkern-#4\onemuskip#7$}
\def\defaultmtharrowfill{\mtharrowfill 7227}
-%D We now define some arrow fills that will be used for defining the
-%D arrows. Plain \TEX\ already defines \tex{leftarrowfill} and
-%D \tex{rightarrowfill}. The \tex{defaultmtharrowfill} command defines an
-%D arrowfill that takes an argument (so that it can also be used
-%D with over and under arrows). However the Plain \TEX\ definitions of
-%D \tex{leftarrowfill} and \tex{rightarrowfill} do not take this extra
-%D argument. To be backward compatible with Plain \TEX, we define two
-%D arrowfills: \tex{specrightarrowfill} which takes an extra argument, and
-%D \tex{rightarrowfill} which does not.
+%D We now define some arrow fills that will be used for defining the arrows. Plain
+%D \TEX\ already defines \tex {leftarrowfill} and \tex {rightarrowfill}. The \tex
+%D {defaultmtharrowfill} command defines an arrowfill that takes an argument (so
+%D that it can also be used with over and under arrows). However the Plain \TEX\
+%D definitions of \tex {leftarrowfill} and \tex {rightarrowfill} do not take this
+%D extra argument. To be backward compatible with Plain \TEX, we define two
+%D arrowfills: \tex {specrightarrowfill} which takes an extra argument, and \tex
+%D {rightarrowfill} which does not.
\unexpanded\def\specrightarrowfill {\defaultmtharrowfill \relbar \relbar \rightarrow}
\unexpanded\def\specleftarrowfill {\defaultmtharrowfill \leftarrow \relbar \relbar}
@@ -382,10 +336,9 @@
\unexpanded\def\doublebond{{\xequal}}
\unexpanded\def\triplebond{{\xtriplerel}}
-%D Now we define most commonly used arrows. These include arrows
-%D defined in \filename{amsmath.sty}, \filename{extarrows.sty},
-%D \filename{extpfel.sty} and \filename{mathtools.sty} packages for
-%D \LATEX\ (plus a few more).
+%D Now we define most commonly used arrows. These include arrows defined in \filename
+%D {amsmath.sty}, \filename {extarrows.sty}, \filename {extpfel.sty} and \filename
+%D {mathtools.sty} packages for \LATEX\ (plus a few more).
\definematharrow [xrightarrow] [0359] [\specrightarrowfill]
\definematharrow [xleftarrow] [3095] [\specleftarrowfill]
@@ -427,27 +380,27 @@
%D \macros{definemathoverarrow,defineunderarrow}
%D
-%D These macros for define math-overarrows are adapted from
-%D \filename{amsmath.sty}
+%D These macros for define math-overarrows are adapted from \filename
+%D {amsmath.sty}
\unexpanded\def\definemathoverarrow
- {\dotripleargument\dodefinemathoverarrow}
+ {\dotripleargument\math_arrows_define_over}
-\def\dodefinemathoverarrow[#1][#2][#3]%
+\def\math_arrows_define_over[#1][#2][#3]%
{\ifthirdargument
- \setuvalue{#1}{\dohandlemathoverarrow[#2][#3]}%
+ \setuvalue{#1}{\math_arrows_over_handle[#2][#3]}%
\else
- \setuvalue{#1}{\dohandlemathoverarrow[\zeropoint][#2]}%
+ \setuvalue{#1}{\math_arrows_over_handle[\zeropoint][#2]}%
\fi}
-\def\dohandlemathoverarrow[#1][#2]%
- {\mathpalette{\dodohandlemathoverarrow{#1}{#2}}}
+\def\math_arrows_over_handle[#1][#2]%
+ {\mathpalette{\math_arrows_over_handle_indeed{#1}{#2}}}
-%D Note: \filename{math-pln.tex} has \type{\kern-\onepoint} and
-%D \filename{amsmath.sty} does not. We keep the kern amount
-%D configurable. This is useful for harpoons.
+%D Note: \filename {math-pln.tex} has \type {\kern-\onepoint} and \filename
+%D {amsmath.sty} does not. We keep the kern amount configurable. This is useful
+%D for harpoons.
-\def\dodohandlemathoverarrow#1#2#3#4%
+\def\math_arrows_over_handle_indeed#1#2#3#4%
{\vbox{\ialign{##\crcr
#2#3\crcr
\noalign{\kern#1\nointerlineskip}%
@@ -456,21 +409,21 @@
%D Now the under arrows
\unexpanded\def\definemathunderarrow
- {\dotripleargument\dodefinemathunderarrow}
+ {\dotripleargument\math_arrows_define_over}
%D For underarrows the default kern is 0.3ex
-\def\dodefinemathunderarrow[#1][#2][#3]%
+\def\math_arrows_define_over[#1][#2][#3]%
{\ifthirdargument
- \setuvalue{#1}{\dohandlemathunderarrow[#2][#3]}%
+ \setuvalue{#1}{\math_arrows_under_handle[#2][#3]}%
\else
- \setuvalue{#1}{\dohandlemathunderarrow[0.3ex][#2]}%
+ \setuvalue{#1}{\math_arrows_under_handle[0.3ex][#2]}%
\fi}
-\def\dohandlemathunderarrow[#1][#2]%
- {\mathpalette{\dodohandlemathunderarrow{#1}{#2}}}
+\def\math_arrows_under_handle[#1][#2]%
+ {\mathpalette{\math_arrows_under_handle_indeed{#1}{#2}}}
-\def\dodohandlemathunderarrow#1#2#3#4%
+\def\math_arrows_under_handle_indeed#1#2#3#4%
{\vtop{\ialign{##\crcr
$\mathsurround\zeropoint\hfil#3#4\hfil$\crcr
\noalign{\nointerlineskip\kern#1}%
diff --git a/tex/context/base/math-for.mkiv b/tex/context/base/math-for.mkiv
index aee640572..0c8bd05ae 100644
--- a/tex/context/base/math-for.mkiv
+++ b/tex/context/base/math-for.mkiv
@@ -30,19 +30,4 @@
\let\setupformulas \setupformula
\let\setupsubformulas\setupsubformula
-% D \macros
-% D {setuptextformulas}
-% D
-% D This command sets up in||line math. Most features deals
-% D with grid snapping and are experimental.
-
-% \newtoks \everysetuptextformulas
-%
-% \unexpanded\def\setuptextformulas
-% {\dosingleempty\dosetuptextformulas}
-%
-% \def\dosetuptextformulas[#1]%
-% {\getparameters[\??mt][#1]%
-% \the\everysetuptextformulas}
-
\protect \endinput
diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv
index 9a8dbef25..e6a3ae6f3 100644
--- a/tex/context/base/math-ini.mkiv
+++ b/tex/context/base/math-ini.mkiv
@@ -53,6 +53,8 @@
\definesystemattribute[mathmode] [public]
\definesystemattribute[mathitalics] [public]
+\definesystemattribute[displaymath] [public]
+
\appendtoks
\attribute\mathmodeattribute\plusone
\to \everydisplay
@@ -61,6 +63,10 @@
\attribute\mathmodeattribute\plusone
\to \everybeforedisplayformula
+\appendtoksonce
+ \attribute\displaymathattribute\plusone
+\to \everybeforedisplayformula
+
\setnewconstant\defaultmathfamily \zerocount % 255
%D Some measures (maybe spac-mth):
@@ -75,18 +81,6 @@
%D Configuration for integrals. (If needed we can speed this up and make it
%D installable; no processaction is needed then).
-% \newtoks\everysetupmathematics
-%
-% \unexpanded\def\setupmathematics
-% {\dosingleargument\dosetupmathematics}
-%
-% \def\dosetupmathematics[#1]%
-% {\getparameters[\??mo][#1]%
-% \the\everysetupmathematics}
-%
-% \def\mathematicsparameter#1%
-% {\ifcsname\??mo#1\endcsname\csname\??mo#1\endcsname\fi}
-
\installcorenamespace{mathematics}
\installswitchcommandhandler \??mathematics {mathematics} \??mathematics
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index a62b81ccf..b1b8998a5 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -104,14 +104,6 @@
\c!textstyle=,
\c!textcolor=]
-% \unexpanded\def\defineMPinstance
-% {\dodoubleargument\meta_define_instance}
-
-% \def\meta_define_instance[#1][#2]%
-% {\ifcsname\??mpinstancetokens#1\endcsname\else\expandafter\newtoks\csname\??mpinstancetokens#1\endcsname\fi
-% \t_meta_instance\emptytoks % in case we redefine
-% \getparameters[\??mpinstance#1][\s!format=mpost,\s!extensions=\v!no,\s!initializations=\v!no,#2]}
-
\appendtoks
\ifcsname\??mpinstancetokens\currentMPinstance\endcsname \else
\expandafter\newtoks\csname\??mpinstancetokens\currentMPinstance\endcsname
@@ -362,34 +354,36 @@
\let \m_meta_current_variable \empty
\let \m_meta_current_variable_template\empty
+\installcorenamespace{graphicvariable}
+
\def \meta_prepare_variable_default {\MPcolor{black}} % just to be sure we use a color but ...
-\edef\meta_unknown_variable_template {\??gv:\s!unknown}
+\edef\meta_unknown_variable_template {\??graphicvariable:\s!unknown}
-\letvalue{\??gv:\s!unknown}\empty
+\letvalue{\??graphicvariable:\s!unknown}\empty
\unexpanded\def\setupMPvariables
{\dodoubleempty\meta_setup_variables}
\def\meta_setup_variables[#1][#2]%
{\ifsecondargument
- \getrawparameters[\??gv#1:][#2]%
+ \getrawparameters[\??graphicvariable#1:][#2]%
\else
- \getrawparameters[\??gv:][#1]%
+ \getrawparameters[\??graphicvariable:][#1]%
\fi}
\unexpanded\def\presetMPvariable
{\dodoubleargument\meta_preset_variable}
\def\meta_preset_variable[#1][#2=#3]%
- {\ifcsname\??gv#1:#2\endcsname \else
- \setvalue{\??gv#1:#2}{#3}%
+ {\ifcsname\??graphicvariable#1:#2\endcsname \else
+ \setvalue{\??graphicvariable#1:#2}{#3}%
\fi}
\def\MPrawvar#1#2% no checking
- {\csname\??gv#1:#2\endcsname}
+ {\csname\??graphicvariable#1:#2\endcsname}
\def\MPvariable#1% todo: could be a framed chain
- {\csname\??gv\currentmpvariableclass:#1\endcsname}
+ {\csname\??graphicvariable\currentmpvariableclass:#1\endcsname}
\unexpanded\def\useMPvariables
{\dodoubleargument\meta_use_variables}
@@ -403,7 +397,7 @@
\unexpanded\def\meta_prepare_variable#1%
{\edef\m_meta_current_variable_template
- {\??gv\currentmpvariableclass:#1}%
+ {\??graphicvariable\currentmpvariableclass:#1}%
\edef\m_meta_current_variable
{\csname\ifcsname\m_meta_current_variable_template\endcsname
\m_meta_current_variable_template\else\meta_unknown_variable_template
@@ -1172,11 +1166,9 @@
%D
%D Here is a generic setup command:
-\newtoks\everysetupMPgraphics
+\installcorenamespace{MPgraphics}
-\unexpanded\def\setupMPgraphics[#1]%
- {\getparameters[\??mp][#1]%
- \the\everysetupMPgraphics}
+\installsetuponlycommandhandler \??MPgraphics {MPgraphics}
%D Here we hook in the outer color. When \type {color} is set to \type
%D {global} we get the outer color automatically. If you change this
@@ -1184,7 +1176,7 @@
%D behave in unexpected ways.
\appendtoks
- \doifelse\@@mpcolor\v!global{\MPcolormethod\plusone}{\MPcolormethod\zerocount}%
+ \doifelse{\directMPgraphicsparameter\c!color}\v!global{\MPcolormethod\plusone}{\MPcolormethod\zerocount}%
\to \everysetupMPgraphics
\setupMPgraphics
diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv
index a2673f9d2..c7c3402a6 100644
--- a/tex/context/base/mult-def.mkiv
+++ b/tex/context/base/mult-def.mkiv
@@ -63,6 +63,10 @@
\def\s!italics {italics}
\def\s!integral {integral}
+\def\c!HL {HL}
+\def\c!VL {VL}
+\def\c!NL {NL}
+
\ifdefined\v!kerncharacters\else \def\v!kerncharacters{kerncharacters} \fi % no time now for translations should be a e! actually
\ifdefined\v!stretched \else \def\v!stretched {stretched} \fi
\ifdefined\v!vulgarfraction\else \def\v!vulgarfraction{vulgarfraction} \fi
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index fb4e05d49..fbd5d585d 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -17,6 +17,7 @@ return {
"zeropoint", "onepoint", "halfapoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint",
"points", "halfpoint",
"zeroskip",
+ "zeromuskip", "onemuskip",
"pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi",
"normalpagebox",
-- --
@@ -203,7 +204,7 @@ return {
--
"removetoks", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to",
--
- "endgraf", "empty", "null", "space", "quad", "enspace", "obeyspaces", "obeylines", "normalspace",
+ "endgraf", "endpar", "everyendpar", "empty", "null", "space", "quad", "enspace", "obeyspaces", "obeylines", "normalspace",
--
"executeifdefined",
--
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index f76840971..46d321632 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -452,108 +452,52 @@
%D for instance is available as \type{\??ag} and expands to
%D \type{@@ag} in composed variables.
-\definesystemvariable {ab} % AlignedBoxes
-\definesystemvariable {ae} % AttributEs
-\definesystemvariable {an} % ANchor
-\definesystemvariable {as} % AlignmentSwitch
-\definesystemvariable {bp} % BreakPoint
-\definesystemvariable {bx} % BackendExport
-\definesystemvariable {cb} % CollectBox
-\definesystemvariable {cp} % CliP
-\definesystemvariable {da} % DAte
+\definesystemvariable {du} % dummy, will stay
+
+% these will be replaced by namespaces / commandhandlers
+
\definesystemvariable {db} % Labels
\definesystemvariable {dd} % DoorDefinieren
-\definesystemvariable {de} % DEel
-\definesystemvariable {dl} % DunneLijnen
-\definesystemvariable {dn} % DoorNummeren
-\definesystemvariable {dm} % DefineMeasure
-\definesystemvariable {du} % DUmmy
-\definesystemvariable {ef} % ExternFiguur
-\definesystemvariable {en} % ENvironments
-\definesystemvariable {ex} % ExterneFiguren
-\definesystemvariable {fc} % FramedContent
-\definesystemvariable {fi} % FIle Once
-\definesystemvariable {fo} % xml FO (xtag)
-\definesystemvariable {fu} % FontSolution
-\definesystemvariable {fw} % simpleFonts by Wolfgang
-\definesystemvariable {fx} % FoXet
-\definesystemvariable {gb} % Graphic Bitmaps
-\definesystemvariable {gv} % Graphic Variable
-\definesystemvariable {ha} % HAng
\definesystemvariable {id} % Index
-\definesystemvariable {ih} % InHoudsopgave
-\definesystemvariable {il} % stelInvulRegelsin
-\definesystemvariable {ip} % InsertPages
-\definesystemvariable {it} % stelInTerliniein
-\definesystemvariable {iv} % stelInvulLijnenin
-\definesystemvariable {ka} % KAntlijn
+
\definesystemvariable {kl} % KoLommen
-\definesystemvariable {km} % KenMerk
-\definesystemvariable {kp} % KopPelteken
\definesystemvariable {ks} % KolomSpan
-\definesystemvariable {kt} % KonTakten
-\definesystemvariable {kw} % KontaktWaarde
-\definesystemvariable {le} % LinetablE
-\definesystemvariable {lf} % LocalFigures
-\definesystemvariable {lg} % taal (LanGuage)
-\definesystemvariable {lk} % LinK
-\definesystemvariable {ll} % Layers
-\definesystemvariable {lr} % LayeR
-\definesystemvariable {lu} % LUacode
-\definesystemvariable {ma} % MargeAchtergrond
\definesystemvariable {mc} % MultiColumn
-\definesystemvariable {mt} % inline MaTh
-\definesystemvariable {mt} % multi column (!!! double usage)
-\definesystemvariable {mo} % Math Options
-\definesystemvariable {mp} % MetaPost
-\definesystemvariable {nn} % structurenumbering
-\definesystemvariable {nm} % Nummering
-\definesystemvariable {np} % NaastPlaatsen
-\definesystemvariable {nr} % Nummeren
+\definesystemvariable {mt} % MulTicolumn
+
+\definesystemvariable {fc} % FramedContent
+\definesystemvariable {od} % Omlijnd Defaults (simple)
\definesystemvariable {oi} % OmlijndInstellingen
\definesystemvariable {ol} % OmLijnd
-\definesystemvariable {od} % Omlijnd Defaults (simple)
-\definesystemvariable {pb} % PuBlication
-\definesystemvariable {pc} % PageComment
-\definesystemvariable {ph} % ParagrapH
-\definesystemvariable {pn} % PaginaNummer
-\definesystemvariable {pr} % PRogrammas
-\definesystemvariable {py} % PropertYs
+
+\definesystemvariable {le} % LinetablE
+
+% bibl:
+
\definesystemvariable {pv} % PublicationVariable
-\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 {rn} % RegelNummer
-\definesystemvariable {rs} % RaSters
-\definesystemvariable {rt} % RoosTers
-\definesystemvariable {rw} % RenderingWindow
-\definesystemvariable {sb} % SectieBlok
-\definesystemvariable {sd} % SounD
-\definesystemvariable {se} % SEctie
-\definesystemvariable {sh} % ShapeText
-\definesystemvariable {sp} % SelecteerPapier
+\definesystemvariable {pb} % PuBlication
+
+% needs checking (namespaces now)
+
+\definesystemvariable {fw} % simpleFonts by Wolfgang
+
+% old pragma
+
+\definesystemvariable {kt} % KonTakten
+\definesystemvariable {kw} % KontaktWaarde
\definesystemvariable {st} % STickers
-\definesystemvariable {sx} % Selector
-\definesystemvariable {ta} % TAb
-\definesystemvariable {tb} % TekstBlokken
-\definesystemvariable {te} % TEmplate
-\definesystemvariable {ti} % TabelInstellingen
-\definesystemvariable {tl} % TekstLijnen
-\definesystemvariable {tt} % TabulaTe
-\definesystemvariable {tx} % TeXtflow
-\definesystemvariable {ur} % URl
-\definesystemvariable {vn} % VoetNoten
+\definesystemvariable {km} % KenMerk
+
+% mkii
+
\definesystemvariable {xf} % XML File (xtag)
\definesystemvariable {xp} % XML Processing (xtag, so still needed)
-\definesystemvariable {za} % layout adapt % ZetspiegelAanpassing
-\definesystemvariable {zc} % columns
+\definesystemvariable {fo} % xml FO (xtag)
+\definesystemvariable {fx} % FoXet
% still used but defined locally
-\definesystemvariable {cs} % CharacterSpacing
\definesystemvariable {ts} % TypeScript
-\definesystemvariable {kk} % Kapitalen
% obsolete but kept for a while (core-obs)
@@ -621,8 +565,8 @@
%definefileconstant {figureextension} {tuf}
%definefileconstant {inputextension} {tui}
%definefileconstant {outputextension} {tuo} % tup for previous run
-\definefileconstant {optionextension} {top}
-\definefileconstant {temporaryextension} {tmp}
+%definefileconstant {optionextension} {top}
+%definefileconstant {temporaryextension} {tmp}
%definefileconstant {patternsextension} {pat}
%definefileconstant {hyphensextension} {hyp}
%definefileconstant {fontmapextension} {map}
diff --git a/tex/context/base/pack-bck.mkvi b/tex/context/base/pack-bck.mkvi
index fbe704fab..57d0ee456 100644
--- a/tex/context/base/pack-bck.mkvi
+++ b/tex/context/base/pack-bck.mkvi
@@ -209,7 +209,7 @@
% \c!color=,
% \c!background=\v!screen,
% \c!backgroundcolor=\backgroundparameter\c!color,
-% \c!screen=\@@rsscreen,
+% \c!screen=\defaultbackgroundscreen,
%
\c!background=\v!color,
\c!backgroundcolor=lightgray,
diff --git a/tex/context/base/pack-mrl.mkiv b/tex/context/base/pack-mrl.mkiv
index dae6acf47..72b12d639 100644
--- a/tex/context/base/pack-mrl.mkiv
+++ b/tex/context/base/pack-mrl.mkiv
@@ -13,26 +13,24 @@
\writestatus{loading}{ConTeXt Packaging Macros / More Rules}
-%D This module needs an overhaul.
+%D The (re)implementation of margin rules has been moved elsewhere.
\unprotect
%D \macros
%D {setupblackrules,blackrule}
%D
-%D The graphic capabilities of \TEX\ do not go beyond simple
-%D filled rules, except of course when using specials. Let's
-%D start with a warning: using this commands is far more slower
-%D than using the \TEX\ primitives \type{\hrule} and
-%D \type{\vrule}, but they save us some tokens. The
+%D The graphic capabilities of \TEX\ do not go beyond simple filled rules, except of
+%D course when using specials or, in \MKIV, manipulate node lists. Let's start with
+%D a warning: using this commands is far more slower than using the \TEX\ primitives
+%D \type {\hrule} and \type {\vrule}, but they save us some tokens. The
%D characteristics of these rule drawing command can be set by:
%D
%D \showsetup{setupblackrules}
%D
-%D The simple command draws only one rule. Its optional
-%D argument can be used to specify the dimensions. By setting
-%D the width, height or depth to \type {max}, one gets the
-%D natural dimensions.
+%D The simple command draws only one rule. Its optional argument can be used to
+%D specify the dimensions. By setting the width, height or depth to \type {max}, one
+%D gets the natural dimensions.
%D
%D \showsetup{blackrule}
@@ -73,8 +71,8 @@
%D \macros
%D {blackrules}
%D
-%D One can call for a sequence of black rules, if needed
-%D equally spaced over the given width.
+%D One can call for a sequence of black rules, if needed equally spaced over the
+%D given width.
%D
%D \showsetup{blackrules}
%D
@@ -93,9 +91,8 @@
%D \getbuffer
%D \stoplines
%D
-%D We could of course have implemented this macro using
-%D \type{\leaders}, but this would probably have taken more
-%D tokens.
+%D We could of course have implemented this macro using \type {\leaders}, but this
+%D would probably have taken more tokens.
\unexpanded\def\blackrules % probably never used
{\hbox\bgroup
@@ -135,139 +132,19 @@
\c!distance=.25\emwidth,
\c!color=]
-%D Marginrules will either become obsolete or be redone.
-
-%D The next commands can be used to draw margin rules. We
-%D support two methods: \marginrule{one for in||line use} and
-%D one that acts on a paragraph. Drawing a margin rule is
-%D rather straightforward because we can use the commands that
-%D put text in the margin.
-
-\def\dodrawmarginrule
- {\setbox\scratchbox\hbox
- {\vrule\!!depth\strutdepth\!!height\strutheight\!!width\@@karulethickness}%
- \smashbox\scratchbox % no \vsmash !!!
- \box\scratchbox}
-
-\def\drawmarginrule
- {\strut\inleft{\dodrawmarginrule}}
-
-%D \macros
-%D {marginrule}
-%D
-%D The first method gobbles words and simply puts a bar in the
-%D margin. This method is not entirely robust.
-%D
-%D \showsetup{marginrule}
-
-\definecomplexorsimple\marginrule
-
-\def\simplemarginrule
- {\let\processword\drawmarginrule
- \processwords}
-
-\def\complexmarginrule[#1]%
- {\ifnum#1<\@@kalevel\relax \else
- \def\@@kadefaultwidth{#1}%
- \expandafter\simplemarginrule
- \fi}
-
-%D We need an auxiliary variable
-
-\def\@@kadefaultwidth{1}
-
-%D \macros
-%D {setupmarginrules}
-%D
-%D This macro definitions show us that we can pass an optional
-%D level, which is matched against the previous set one. The
-%D level can be set up with
-%D
-%D \showsetup{setupmarginrules}
-
-% \unexpanded\def\setupmarginrules
-% {\dodoubleargument\getparameters[\??ka]}
-%
-% %D \macros
-% %D {startmarginrule}
-% %D
-% %D The second method collects text and reformats it afterwards,
-% %D using the shapebox macros. We prevent local margin rules.
-% %D
-% %D \showsetup{startmarginrule}
-%
-% \definecomplexorsimple\startmarginrule
-%
-% \def\simplestartmarginrule
-% {\bgroup
-% \let\drawmarginrule\relax
-% \let\stopmarginrule\dostopmarginrule
-% \beginofshapebox}
-%
-% \def\complexstartmarginrule[#1]%
-% {\bgroup
-% \let\drawmarginrule\relax
-% \ifnum#1<\@@kalevel\relax
-% \let\stopmarginrule\egroup
-% \else
-% \def\@@kadefaultwidth{#1}%
-% \let\stopmarginrule\dostopmarginrule
-% \expandafter\beginofshapebox
-% \fi}
-%
-% \def\dostopmarginrule
-% {\endofshapebox
-% \reshapebox
-% {\hbox{\inleftmargin{\dodrawmarginrule}\box\shapebox}}%
-% \flushshapebox
-% \egroup}
-
-%D \startbuffer
-%D \setupmarginrules[level=5]
-%D
-%D \startmarginrule[1]
-%D First we set the level at~5. Next we typeset this first
-%D paragraph as a level~1 one. As expected no rule show up.
-%D \stopmarginrule
-%D
-%D \startmarginrule[5]
-%D The second paragraph is a level~5 one. As we can see here,
-%D the marginal rule gets a width according to its level.
-%D \stopmarginrule
-%D
-%D \startmarginrule[8]
-%D It will of course be no surprise that this third paragraph
-%D has a even thicker margin rule. This behavior can be
-%D overruled by specifying the width explictly.
-%D \stopmarginrule
-%D \stopbuffer
-%D
-%D In next example we show most features. Watch the rule
-%D thickness adapting itself to the level.
-%D
-%D \startexample
-%D \getbuffer
-%D \stopexample
-%D
-%D We just said:
-%D
-%D \typebuffer
-
%D \macros
%D {vl, hl}
%D
-%D The command \type{\vl} draws a vertical rule \vl\ with strut
-%D dimensions, multiplied with the factor specified in the
-%D optional argument. The height and depth are clipped \vl[3]
-%D to the baselinedistance. Its horizontal counterpart
-%D \type{\hl} draws a horizontal rule \hl\ with a width of 1em,
-%D multiplied with the optional factor. The horizontal rule is
-%D drawn on top of the baseline.
+%D The command \type {\vl} draws a vertical rule \vl\ with strut dimensions,
+%D multiplied with the factor specified in the optional argument. The height and
+%D depth are clipped \vl [3] to the baselinedistance. Its horizontal counterpart
+%D \type {\hl} draws a horizontal rule \hl\ with a width of 1em, multiplied with the
+%D optional factor. The horizontal rule is drawn on top of the baseline.
%D
%D \showsetup{vl}
%D \showsetup{hl}
-\unexpanded\def\dovlwdhtdp#1#2#3% used elsewhere
+\unexpanded\def\pack_rule_vl_indeed#1#2#3%
{\bgroup
\setbox\scratchbox\hbox
{\vrule
@@ -279,25 +156,27 @@
\box\scratchbox
\egroup}
-\def\complexvl[#1]%
- {\dovlwdhtdp\plusone{#1}{#1}}
+\def\pack_rule_vl[#1]%
+ {\pack_rule_vl_indeed{#1}{#1}{#1}}
-\def\complexhl[#1]%
+\def\pack_rule_hl[#1]%
{\hbox
{\vrule
\!!width #1\emwidth
\!!height\linewidth
\!!depth \zeropoint}}
-\definecomplexorsimple\vl \def\simplevl{\complexvl[\plusone]}
-\definecomplexorsimple\hl \def\simplehl{\complexhl[\plusone]}
+\unexpanded\def\vl{\dosingleempty\pack_rule_vl}
+\unexpanded\def\hl{\dosingleempty\pack_rule_hl}
+
+\let\dovlwdhtdp\pack_rule_vl_indeed % used elsewhere
%D \macros
%D {hairline, thinrule, thinrules, setupthinrules}
%D
-%D Drawing thin lines can of course easily be accomplished by
-%D the \TEX\ primitives \type{\hrule} and \type{\vrule}. The
-%D next few macros however free us from some specifications.
+%D Drawing thin lines can of course easily be accomplished by the \TEX\
+%D primitives \type{\hrule} and \type{\vrule}. The next few macros however
+%D free us from some specifications.
%D
%D \startbuffer
%D some text
@@ -338,112 +217,158 @@
%D
%D which looks like: \thinrules[n=2]
-\newconstant\ruletype
+\installcorenamespace{thinrules}
+\installcorenamespace{thinrulealternatives}
+
+\installdirectcommandhandler \??thinrules {thinrules}
+
+\setupthinrules
+ [\c!interlinespace=\v!small,
+ \c!n=3,
+ \c!before=,
+ \c!inbetween={\blank[\v!white]},
+ \c!after=,
+ \c!color=,
+ \c!height=.5\linewidth,
+ \c!depth=.5\linewidth,
+ \c!frame=\v!on, % compatible with textbackgrounds
+ \c!alternative=\v!b,
+ \c!backgroundcolor=,
+ \c!background=,
+ \c!rulethickness=\linewidth]
+
+\letvalue{\??thinrulealternatives\v!a }\zerocount
+\letvalue{\??thinrulealternatives\v!b }\plusone
+\letvalue{\??thinrulealternatives\v!c }\plustwo
+\letvalue{\??thinrulealternatives\v!none}\zerocount
+
+\newconstant\c_pack_thinrules_type
\def\thinrule
{\strut
\bgroup
- \ruletype\plusone
- \processaction
- [\@@dlalternative]
- [ \v!a=>\ruletype\zerocount,% no line
- %\v!b=>\ruletype\plusone ,% height/depth
- \v!c=>\ruletype\plustwo ,% topheight/botdepth
- % 11=>\ruletype\plusone ,% fallback for backgrounds
- 0=>\ruletype\zerocount,% compatible with backgrounds
- % 1=>\ruletype\plusone ,% compatible with backgrounds
- 2=>\ruletype\plustwo ]% compatible with backgrounds
- \doifsomething\@@dlrulethickness
- {\linewidth\@@dlrulethickness}%
+ \edef\p_height {\directthinrulesparameter\c!height}%
+ \edef\p_depth {\directthinrulesparameter\c!depth}%
+ \edef\p_background{\directthinrulesparameter\c!background}%
+ \edef\p_frame {\directthinrulesparameter\c!frame}%
+ \linewidth\dimexpr\directthinrulesparameter\c!rulethickness/\plustwo\relax
\ifdim\linewidth=\zeropoint
- \ruletype\zerocount
+ \c_pack_thinrules_type\zerocount
+ \else\ifx\p_frame\v!on
+ \c_pack_thinrules_type\expandcheckedcsname\??thinrulealternatives{\directthinrulesparameter\c!alternative}\v!b\relax
+ \else
+ \c_pack_thinrules_type\zerocount
+ \fi\fi
+ \ifnum\c_pack_thinrules_type=\plusone
+ \ifx\p_height\v!max
+ \scratchheight\strutht
+ \else
+ \setdimensionwithunit\scratchheight\p_height\strutht
+ \fi
+ \ifx\p_depth\v!max
+ \scratchdepth\strutdp
+ \else
+ \setdimensionwithunit\scratchdepth\p_depth\strutdp
+ \fi
\else
- \doifnot\@@dlframe\v!on{\ruletype\zerocount}%
+ \scratchheight\strutht
+ \scratchdepth \strutdp
\fi
- \ifnum\ruletype=\plusone
- \doif\@@dlheight\v!max{\let\@@dlheight\!!plusone}%
- \doif\@@dldepth \v!max{\let\@@dldepth \!!plusone}%
+ \ifx\p_background\v!color
+ \startcolor[\directthinrulesparameter\c!backgroundcolor]%
+ \ifnum\c_pack_thinrules_type=\plustwo % prevent overshoot due to rounding
+ \leaders
+ \hrule
+ \!!height\dimexpr\scratchheight-\linewidth\relax
+ \!!depth \dimexpr\scratchdepth -\linewidth\relax
+ \hfill
+ \else
+ \leaders
+ \hrule
+ \!!height\scratchheight
+ \!!depth \scratchdepth
+ \hfill
+ \fi
+ \stopcolor
+ \ifcase\c_pack_thinrules_type
+ % no rule
+ \or
+ \startcolor[\directthinrulesparameter\c!color]%
+ \hfillneg
+ \leaders
+ \hrule
+ \!!height\linewidth
+ \!!depth \linewidth
+ \hfill
+ \stopcolor
+ \or
+ \startcolor[\directthinrulesparameter\c!color]%
+ \hfillneg
+ \leaders
+ \hrule
+ \!!height\dimexpr-\scratchdepth+\linewidth\relax
+ \!!depth \scratchdepth
+ \hfill
+ \hfillneg
+ \leaders
+ \hrule
+ \!!height\scratchheight
+ \!!depth \dimexpr-\scratchheight+\linewidth\relax
+ \hfill
+ \stopcolor
+ \fi
\else
- \let\@@dlheight\!!plusone
- \let\@@dldepth\!!plusone
+ \ifcase\c_pack_thinrules_type
+ % no rule
+ \else
+ \startcolor[\directthinrulesparameter\c!color]%
+ \leaders
+ \hrule
+ \!!height\scratchheight
+ \!!depth \scratchdepth
+ \hfill
+ \stopcolor
+ \fi
\fi
- \freezedimensionwithunit\@@dlheight\strutht
- \freezedimensionwithunit\@@dldepth\strutdp
- \divide\linewidth \plustwo
- \doifelse\@@dlbackground\v!color
- {\startcolor[\@@dlbackgroundcolor]%
- \ifnum\ruletype=\plustwo % prevent overshoot due to rounding
- \leaders
- \hrule
- \!!height\dimexpr\@@dlheight-.5\linewidth\relax
- \!!depth \dimexpr\@@dldepth -.5\linewidth\relax
- \hfill
- \else
- \leaders
- \hrule
- \!!height\@@dlheight
- \!!depth \@@dldepth
- \hfill
- \fi
- \stopcolor
- \ifcase\ruletype
- % no rule
- \or
- \startcolor[\@@dlcolor]%
- \hfillneg
- \leaders\hrule\!!height\linewidth\!!depth\linewidth\hfill
- \stopcolor
- \or
- \startcolor[\@@dlcolor]%
- \hfillneg\leaders\hrule\!!height\dimexpr-\@@dldepth+\linewidth\relax\!!depth\@@dldepth\hfill
- \hfillneg\leaders\hrule\!!height\@@dlheight\!!depth\dimexpr-\@@dlheight+\linewidth\relax\hfill
- \stopcolor
- \fi}
- {\ifcase\ruletype \else
- \startcolor[\@@dlcolor]%
- \leaders\hrule\!!height\@@dlheight\!!depth\@@dldepth\hfill
- \stopcolor
- \fi}%
\strut
\carryoverpar\egroup}
-\def\hairline
+\unexpanded\def\hairline
{\endgraf
\thinrule
\endgraf}
-\def\dosetupthinrules[#1]%
- {\getparameters[\??dl][#1]}
+\unexpanded\def\thinrules
+ {\dosingleempty\pack_thinrules}
-\unexpanded\def\setupthinrules
- {\dosingleargument\dosetupthinrules}
-
-\def\dothinrules[#1]%
+\def\pack_thinrules[#1]%
{\bgroup
- \dosetupthinrules[#1]%
- \@@dlbefore
- \assignvalue\@@dlinterlinespace\@@dlinterlinespace{1.0}{1.5}{2.0}%
- \spacing\@@dlinterlinespace
- \dorecurse\@@dln
- {\ifnum\recurselevel=\@@dln \dothinrulesnobreak \else
- \ifnum\recurselevel=2 \dothinrulesnobreak \fi\fi
- \thinrule
- \ifnum\recurselevel<\@@dln\relax
+ \setupcurrentthinrules[#1]%
+ \assignvalue{\directthinrulesparameter\c!interlinespace}\m_pack_thinrules_interlinespace{1.0}{1.5}{2.0}%
+ \spacing\m_pack_thinrules_interlinespace
+ \edef\p_after {\directthinrulesparameter\c!after}%
+ \edef\p_inbetween{\directthinrulesparameter\c!inbetween}%
+ \directthinrulesparameter\c!before
+ \scratchcounter\directthinrulesparameter\c!n\relax
+ \dorecurse\scratchcounter
+ {\ifnum\recurselevel=\scratchcounter \penalty500 \else
+ \ifnum\recurselevel=\plustwo \penalty500 \fi\fi
+ \thinrule
+ \ifnum\recurselevel<\scratchcounter\relax
% test needed, else messed up whitespace
- \ifx\@@dlinbetween\empty
- \softbreak
+ \ifx\p_inbetween\empty
+ \softbreak % \ifhmode \hskip \parfillskip \break \fi
\else
\endgraf
\nowhitespace
- \@@dlinbetween
+ \p_inbetween
\fi
\fi}%
- \doifelsenothing\@@dlafter
- {\carryoverpar\egroup}
- {\@@dlafter\egroup}}
-
-\def\thinrules
- {\dosingleempty\dothinrules}
+ \ifx\p_after\empty
+ \carryoverpar\egroup
+ \else
+ \p_after\egroup
+ \fi{}}
%D A couple of examples are given below.
%D
@@ -464,11 +389,10 @@
%D
%D \typebuffer {\getbuffer}
%D
-%D There are a couple of alternative ways to visualize rules
-%D using backgrounds. At first sight these may look strange,
-%D but they make sense in educational settings. The
-%D alternatives are more or less compatible with the more
-%D advanced \METAPOST\ based implementation.
+%D There are a couple of alternative ways to visualize rules using backgrounds. At
+%D first sight these may look strange, but they make sense in educational settings.
+%D The alternatives are more or less compatible with the more advanced \METAPOST\
+%D based implementation.
%D
%D \startbuffer[a]
%D \setupthinrules
@@ -507,22 +431,10 @@
%D \typebuffer[b] \getbuffer[a,b]
%D \macros
-%D {optimizethinrules}
-%D
-%D By saying \type {\thinrulestrue} or \type {-false}, we
-%D can influence the way dangling lines are handled.
-
-\newif\ifoptimizethinrules \optimizethinrulestrue
-
-\def\dothinrulesnobreak
- {\ifoptimizethinrules\penalty500\fi}
-
-%D \macros
%D {textrule, starttextrule, setuptextrules}
%D
-%D Putting rules before and after a paragraph is very space
-%D sensitive, but the next command handles that quite well. It
-%D comes in two disguises:
+%D Putting rules before and after a paragraph is very space sensitive, but the
+%D next command handles that quite well. It comes in two disguises:
%D
%D \startbuffer
%D \textrule[top]{fragments}
@@ -562,132 +474,143 @@
%D \showsetup{starttextrule}
%D \showsetup{setuptextrules}
%D
-%D The implementation looks a bit complicated due to the
-%D optional arguments.
+%D The implementation looks a bit complicated due to the optional arguments.
+
+\installcorenamespace{textrules}
+\installcorenamespace{textrulealternatives}
+
+\installdirectcommandhandler \??textrules {textrules}
+
+\setuptextrules
+ [\c!location=\v!left,
+ \c!before=\blank,
+ \c!after=\blank,
+ \c!inbetween=,
+ \c!width=2\emwidth,
+ \c!style=\v!bold,
+ \c!color=,
+ \c!rulecolor=,
+ \c!bodyfont=,
+ \c!rulethickness=\linewidth,
+ \c!distance=.5\emwidth]
+
+\unexpanded\def\textrule
+ {\dosingleempty\pack_textrule}
+
+\def\pack_textrule
+ {\iffirstargument
+ \expandafter\pack_textrule_yes
+ \else
+ \expandafter\pack_textrule_nop
+ \fi}
+
+\def\pack_textrule_yes[#1]%
+ {\expandcheckedcsname\??textrulealternatives{#1}\v!bottom}
+
+\def\pack_textrule_nop[#1]%
+ {\dosinglegroupempty\pack_textrule_nop_indeed}
+
+\def\pack_textrule_nop_indeed
+ {\iffirstargument
+ \expandafter\pack_textrule_nop_indeed_yes
+ \else
+ \expandafter\pack_textrule_nop_indeed_nop
+ \fi}
+
+\def\pack_textrule_nop_indeed_yes
+ {\csname\??textrulealternatives\v!top\endcsname}
-\unexpanded\def\setuptextrules
- {\dodoubleargument\getparameters[\??tl]}
+\def\pack_textrule_nop_indeed_nop
+ {\csname\??textrulealternatives\v!bottom\endcsname\empty}
-\def\complextextrule[#1]% if needed we can make it installable
- {\let\next\dobottomtextrule
- \processaction
- [#1]
- [ \v!top=>\let\next\dotoptextrule,
- \v!middle=>\let\next\domiddletextrule,
- \v!bottom=>\let\next\dobottomtextrule]%
- \dosinglegroupempty\next}
+\setvalue{\??textrulealternatives\v!top}#1%
+ {\page[\v!preference] % interferes
+ \directtextrulesparameter\c!before\relax
+ \pack_textrule_with_text{#1}%
+ \nowhitespace
+ \directtextrulesparameter\c!inbetween\relax
+ \endgraf}
-\definecomplexorsimple\textrule
+\setvalue{\??textrulealternatives\v!bottom}#1%
+ {\pack_textrule_following{#1}%
+ \directtextrulesparameter\c!after\relax
+ \page[\v!preference]}
-\def\simpletextrule
- {\dosinglegroupempty\dounknowntextrule}
+\setvalue{\??textrulealternatives\v!middle}#1%
+ {\pack_textrule_following{#1}%
+ \directtextrulesparameter\c!inbetween\relax
+ \page[\v!preference]}
-\def\docomplextextrule#1%
+\def\pack_textrule_with_text#1%
{\bgroup
- \advance\hsize\dimexpr-\rightskip-\leftskip\relax
- \setbox\scratchbox\hbox to \hsize
- {\dimen4\dimexpr .5ex+.5\linewidth\relax
- \dimen6\dimexpr-.5ex+.5\linewidth\relax
+ \setbox\scratchbox\hbox to \availablehsize
+ {\scratchwidth \directtextrulesparameter\c!rulethickness\relax
+ \scratchheight\dimexpr .5\exheight+.5\scratchwidth\relax
+ \scratchdepth \dimexpr-.5\exheight+.5\scratchwidth\relax
\doifsomething{#1}
- {\doifelse\@@tllocation\v!inmargin
+ {\doifelse{\directtextrulesparameter\c!location}\v!inmargin
{\llap
- {\dousestyleparameter\@@tlstyle
- \dousecolorparameter\@@tlcolor
+ {\usetextrulesstyleandcolor\c!style\c!color
#1%
\hskip\leftmargindistance}}
- {\color[\@@tlrulecolor]
- {\vrule\!!height\dimen4\!!depth\dimen6\!!width\@@tlwidth}%
- \hbox spread 2\dimexpr\@@tldistance\relax
+ {\color[\directtextrulesparameter\c!rulecolor]
+ {\vrule\!!height\scratchheight\!!depth\scratchdepth\!!width\directtextrulesparameter\c!width}%
+ \hbox spread 2\dimexpr\directtextrulesparameter\c!distance\relax
{\hss
- \dousestyleparameter\@@tlstyle
- \dousecolorparameter\@@tlcolor
+ \usetextrulesstyleandcolor\c!style\c!color
\strut#1%
\hss}}}%
- \color[\@@tlrulecolor]
- {\leaders\hrule\!!height\dimen4\!!depth\dimen6\hfill}}%
+ \color[\directtextrulesparameter\c!rulecolor]
+ {\leaders\hrule\!!height\scratchheight\!!depth\scratchdepth\hfill}}%
\ht\scratchbox\strutht
\dp\scratchbox\strutdp
\noindent\box\scratchbox
-%\nobreak\verticalstrut\kern-\struttotal
-% evt \witruimte
\egroup}
-\def\dotoptextrule#1%
- {\page[\v!preference] % interferes
- %\whitespace % no
- \@@tlbefore
- \docomplextextrule{#1}%
-% todo, option: \doifnothing{#1}{\ruledvskip-.5ex}
- \nowhitespace
- \@@tlinbetween
- \endgraf}
-
-\def\dodobottomtextrule#1#2%
+\def\pack_textrule_following#1%
{\ifhmode
\endgraf
\fi
- \dimen0\strutdp
- \ifdim\prevdepth>\strutdp\else % was <\strutdp
- \ifdim\prevdepth>\zeropoint
- \advance\dimen0 -\prevdepth
+ \vskip\dimexpr \strutdp +.5\exheight
+ \ifdim\prevdepth>\strutdp\else % was <\strutdp
+ \ifdim\prevdepth>\zeropoint
+ -\prevdepth
+ \fi
\fi
- \fi
- \advance\dimen0 .5ex
- \vskip\dimen0
-% ==
-% \vskip\dimexpr \strutdp + .5ex
-% \ifdim\prevdepth>\strutdp\else\ifdim\prevdepth>\zeropoint-\prevdepth\fi\fi\relax
-%
- \@@tlinbetween
- \doifelsenothing{#2}
- {\bgroup
- \advance\hsize\dimexpr-\rightskip-\leftskip\relax
- \nointerlineskip
- \moveleft-\leftskip\vbox
- {\color[\@@tlrulecolor]
- {\hrule\!!depth\linewidth\!!height\zeropoint\!!width\hsize}}%
- \egroup}
- {\docomplextextrule{#2}}%
- \ifvmode\prevdepth\zeropoint\fi
- #1%
- \page[\v!preference]}
-
-\def\dobottomtextrule
- {\dodobottomtextrule\@@tlafter}
-
-\def\domiddletextrule
- {\dodobottomtextrule\@@tlinbetween}
-
-\def\dounknowntextrule
- {\iffirstargument
- \@EA\dotoptextrule
- \else
- \@EA\dobottomtextrule\@EA\empty
+ \relax
+ \directtextrulesparameter\c!inbetween\relax
+ \doifelsenothing{#1}
+ {\nointerlineskip
+ \dontleavehmode\vbox
+ {\color[\directtextrulesparameter\c!rulecolor]
+ {\hrule\!!depth\directtextrulesparameter\c!rulethickness\!!height\zeropoint\!!width\availablehsize}}}
+ {\pack_textrule_with_text{#1}}%
+ \ifvmode
+ \prevdepth\zeropoint
\fi}
%D The grouped commands also supports bodyfont switching:
\unexpanded\def\starttextrule#1%
{\bgroup
- \def\dounknowntextrule{\domiddletextrule}
- \dotoptextrule{#1}
+ \def\pack_textrule_nop_indeed{\csname\??textrulealternatives\v!middle\endcsname}%
+ \csname\??textrulealternatives\v!top\endcsname{#1}%
\bgroup
- \doifsomething\@@tlbodyfont{\switchtobodyfont[\@@tlbodyfont]}}
+ \doifsomething{\directtextrulesparameter\c!bodyfont}{\switchtobodyfont[\directtextrulesparameter\c!bodyfont]}}
\unexpanded\def\stoptextrule
{\par
\egroup
- \dobottomtextrule\empty
+ \csname\??textrulealternatives\v!bottom\endcsname\empty
\egroup}
%D \macros
%D {fillinrules, setupfillinrules}
%D
-%D The next few commands do not really deserve a place in a
-%D core module, because they deal with specific typography.
-%D Nevertheless I decided to make them part of the core,
-%D because they permit us to make questionaires. Let's start
-%D with some examples.
+%D The next few commands do not really deserve a place in a core module, because
+%D they deal with specific typography. Nevertheless I decided to make them part of
+%D the core, because they permit us to make questionaires. Let's start with some
+%D examples.
%D
%D \fillinrules[n=2,width=fit]{first}
%D \fillinrules[n=2,width=broad]{first}
@@ -696,85 +619,112 @@
%D \fillinrules[n=2]{first}{last}
%D \fillintext{first}{last} \input reich \par
%D
-%D The main command is \type{\fillinrules}. This command takes
-%D one and an optional second argument and sets a paragraph with
-%D empty visualized lines.
+%D The main command is \type{\fillinrules}. This command takes one and an optional
+%D second argument and sets a paragraph with empty visualized lines.
%D
%D \showsetup{fillinrules}
%D \showsetup{setupfillinrules}
-\unexpanded\def\setupfillinrules
- {\dodoubleargument\getparameters[\??il]}
-\definecomplexorsimpleempty\fillinrules
+\installcorenamespace{fillinrules}
+
+\installdirectcommandhandler \??fillinrules {fillinrules}
+
+\setupfillinrules
+ [\c!width=\v!broad,
+ \c!distance=\emwidth,
+ \c!before=\blank,
+ \c!after=\blank,
+ \c!n=\plusone,
+ \c!interlinespace=\v!small,
+ \c!separator=,
+ \c!style=,
+ \c!color=]
-\def\complexfillinrules[#1]%
- {\def\docomplexfillinrules##1##2%
- {\dodocomplexfillinrules[#1]{##1}{##2}{\thinrules
- [\c!n=\@@iln,\c!interlinespace=\@@ilinterlinespace,\c!before=,\c!after=]}}%
- \dodoublegroupempty\docomplexfillinrules}
+\unexpanded\def\fillinrules
+ {\dosingleempty\pack_fillinrules}
-\def\dodocomplexfillinrules[#1]#2#3#4%
+\def\pack_fillinrules[#1]%
{\endgraf
- \@@ilbefore
\begingroup
- \setupfillinrules[#1]%
+ \setupcurrentfillinrules[#1]%
+ \let\pack_fillinrules_rule\thinrules
+ \dodoublegroupempty\pack_fillinrules_indeed}
+
+\def\pack_fillinrules_indeed#1#2%
+ {\directfillinrulesparameter\c!before
+ \setupcurrentthinrules
+ [\c!n=\directfillinrulesparameter\c!n,
+ \c!interlinespace=\directfillinrulesparameter\c!interlinespace,
+ \c!before=,
+ \c!after=]%
+ \scratchdistance\directfillinrulesparameter\c!distance\relax
+ \edef\m_fillinrules_one{#1}%
+ \edef\m_fillinrules_two{#2}%
\noindent
- \doifsomething{#2}
- {\doifelse\@@ilwidth\v!fit
- {\let\@@ildistance\!!zeropoint
- \hbox}
- {\doifelse\@@ilwidth\v!broad
- {\hbox}
- {\hbox to \@@ilwidth}}%
- \bgroup
- \dousestyleparameter\@@ilstyle
- \dousecolorparameter\@@ilcolor
- \strut#2\hfill\@@ilseparator\hskip\@@ildistance
- \egroup}%
- %\hangindent=\wd0\relax % tzt hang=yes,n
- %\parindent=\hangindent
- %\box0\relax
+ \ifx\m_fillinrules_one\empty \else
+ \edef\p_width{\directfillinrulesparameter\c!width}%
+ \ifx\p_width\v!fit
+ \scratchdistance\zeropoint
+ \hbox
+ \else\ifx\p_width\v!broad
+ \hbox
+ \else
+ \hbox to \directfillinrulesparameter\c!width
+ \fi\fi
+ \bgroup
+ \usefillinrulesstyleandcolor\c!style\c!color
+ \strut
+ \m_fillinrules_one
+ \hfill\directfillinrulesparameter\c!separator
+ \hskip\scratchdistance
+ \egroup
+ \fi
\setupwhitespace[\v!big]%
\ignorespaces
- #4%
- \doifsomething{#3}
- {\kern\@@ildistance
- \dousestyleparameter\@@ilstyle
- \dousecolorparameter\@@ilcolor
- #3\strut}%
- \endgroup
+ \pack_fillinrules_rule
+ \ifx\m_fillinrules_two\empty \else
+ \kern\scratchdistance
+ \usefillinrulesstyleandcolor\c!style\c!color
+ \m_fillinrules_two
+ \strut
+ \fi
\endgraf
- \@@ilafter}
+ \directfillinrulesparameter\c!after
+ \endgroup}
%D \macros
%D {fillintext}
%D
-%D To provide compatible layouts when texts and lines are
-%D mixed, one can typeset a paragraph by using the command
-%D \type{\fillintext}.
+%D To provide compatible layouts when texts and lines are mixed, one can typeset
+%D a paragraph by using the command \type {\fillintext}.
%D
%D \showsetup{fillintext}
-\definecomplexorsimpleempty\fillintext
+\unexpanded\def\fillintext
+ {\dosingleempty\pack_fillintext}
+
+\def\pack_fillintext[#1]% ugly
+ {\endgraf
+ \begingroup
+ \setupcurrentfillinrules[#1]%
+ \dodoublegroupempty\pack_fillintext_indeed}
-\def\complexfillintext[#1]% rather rough, using an \unhbox is suboptimal
- {\def\docomplexfillintext##1##2%
- {\dowithnextbox
- {\dodocomplexfillinrules[#1]{##1}{\hfill##2}{\unhbox\nextbox\unskip}}%
- \hbox\bgroup\let\par\egroup\ignorespaces}%
- \dodoublegroupempty\docomplexfillintext}
+\def\pack_fillintext_indeed#1#2%
+ {\def\pack_fillinrules_rule{\unhbox\nextbox\unskip}%
+ \dowithnextbox{\pack_fillinrules_indeed{#1}{\hfill#2}}%
+ \hbox\bgroup\let\par\egroup\ignorespaces}
%D \macros
%D {fillinline, setupfillinlines}
%D
-%D Another member of the family takes care of putting a (often
-%D small) rule after a piece of text, like
+%D Another member of the family takes care of putting a (often small) rule after
+%D a piece of text, like
%D
%D \startbuffer
-%D \fillinline \input reich \par
+%D
+%D \stopbuffer\fillinline \input reich \par
%D \fillinline[margin=0cm] \input reich \par
-%D \stopbuffer
%D
%D \startexample
%D \getbuffer
@@ -789,82 +739,71 @@
%D \showsetup{fillinline}
%D \showsetup{setupfillinlines}
-\unexpanded\def\setupfillinlines
- {\dodoubleargument\getparameters[\??iv]}
+\installcorenamespace{fillinlines}
-\definecomplexorsimpleempty\fillinline
+\installdirectcommandhandler \??fillinlines {fillinlines}
-\def\complexfillinline[#1]%
- {%\endgraf % interferes with \definedescription cum suis
- \@@ivbefore
- \begingroup
- \setupfillinlines[#1]%
- \advance\rightskip \@@ivmargin
- \parfillskip\zeropoint
- \def\par % very dangerous
- {\let\par\endgraf % -)
- \ifhmode\unskip\hfill\fi
- \scratchdimen\dimexpr\@@ivwidth-\@@ivdistance\relax
- \ifdim\scratchdimen>\@@ivmargin\else\expandafter\rlap\fi
- {\kern\@@ivdistance
- \vrule
- \!!width \scratchdimen
- \!!height.5\linewidth
- \!!depth .5\linewidth}%
- \endgraf % !
- \endgroup
- \endgraf % !
- \@@ilafter}}
-
-%D Will move up:
-
-% \setupmarginrules
-% [\c!level=0,
-% \c!rulethickness=\@@kadefaultwidth\linewidth]
-
-\setupthinrules
- [\c!interlinespace=\v!small,
- \c!n=3,
- \c!before=,
- \c!inbetween={\blank[\v!white]},
- \c!after=,
+\setupfillinlines
+ [\c!width=8\emwidth, % was 3cm
+ \c!margin=\directfillinlinesparameter\c!width,
+ \c!rulethickness=\linewidth,
\c!color=,
- \c!height=.5\linewidth,
- \c!depth=.5\linewidth,
- \c!frame=\v!on, % compatible with textbackgrounds
- \c!alternative=\v!b,
- \c!backgroundcolor=,
- \c!background=,
- \c!rulethickness=]
-
-\setuptextrules
- [\c!location=\v!left,
+ \c!distance=\emwidth,
\c!before=\blank,
- \c!after=\blank,
- \c!inbetween=,
- \c!width=2em,
- \c!style=\v!bold,
- \c!color=,
- \c!rulecolor=,
- \c!bodyfont=,
- \c!distance=.5em]
+ \c!after=\blank]
-\setupfillinrules
- [\c!width=\v!broad,
- \c!distance=1em,
- \c!before=\blank,
- \c!after=\blank,
- \c!n=1,
- \c!interlinespace=\v!small,
- \c!separator=,
- \c!style=\v!normal,
- \c!color=]
+\unexpanded\def\fillinline
+ {\dosingleempty\pack_fillinline}
+
+\ifdefined\endpar % experiment with \endpar
+
+ \def\pack_fillinline[#1]%
+ {% \endpar % no, as it interferes with \definedescription cum suis
+ \begingroup
+ \setupcurrentfillinlines[#1]%
+ \directfillinlinesparameter\c!before
+ \begingroup
+ \advance\rightskip \directfillinlinesparameter\c!margin\relax
+ \parfillskip\zeropoint
+ \pushmacro\endpar
+ \def\endpar
+ {\popmacro\endpar
+ \ifhmode\unskip\hfill\fi
+ \scratchwidth\dimexpr\directfillinlinesparameter\c!width-\directfillinlinesparameter\c!distance\relax
+ \ifdim\scratchwidth>\directfillinlinesparameter\c!margin\else\expandafter\rlap\fi
+ {\kern\directfillinlinesparameter\c!distance
+ \scratchheight\dimexpr\directfillinlinesparameter\c!rulethickness/\plustwo\relax
+ \color[\directfillinlinesparameter\c!color]{\vrule\!!width\scratchwidth\!!height\scratchheight\!!depth\scratchheight}}%
+ \endpar
+ \endgroup
+ \endpar
+ \directfillinlinesparameter\c!after
+ \endgroup}} % carryover ?
+
+\else
+
+ \def\pack_fillinline[#1]%
+ {%\endgraf % no, as it interferes with \definedescription cum suis
+ \begingroup
+ \setupcurrentfillinlines[#1]%
+ \directfillinlinesparameter\c!before
+ \begingroup
+ \advance\rightskip \directfillinlinesparameter\c!margin\relax
+ \parfillskip\zeropoint
+ \def\par
+ {\let\par\endgraf
+ \ifhmode\unskip\hfill\fi
+ \scratchwidth\dimexpr\directfillinlinesparameter\c!width-\directfillinlinesparameter\c!distance\relax
+ \ifdim\scratchwidth>\directfillinlinesparameter\c!margin\else\expandafter\rlap\fi
+ {\kern\directfillinlinesparameter\c!distance
+ \scratchheight\dimexpr\directfillinlinesparameter\c!rulethickness/\plustwo\relax
+ \color[\directfillinlinesparameter\c!color]{\vrule\!!width\scratchwidth\!!height\scratchheight\!!depth\scratchheight}}%
+ \endgraf
+ \endgroup
+ \endgraf
+ \directfillinlinesparameter\c!after
+ \endgroup}} % carryover ?
-\setupfillinlines
- [\c!width=3cm,
- \c!margin=\@@ivwidth,
- \c!distance=1em,
- \c!before=\blank,
- \c!after=\blank]
+\fi
\protect \endinput
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index 16b4460e9..e0be2db13 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -54,8 +54,16 @@
%D
%D \showsetup{setupscreens}
-\unexpanded\def\setupscreens
- {\dodoubleargument\getparameters[\??rs]}
+\installcorenamespace{screens}
+
+\installsetuponlycommandhandler \??screens {screens}
+
+\appendtoks
+ \edef\defaultbackgroundscreen{\directscreensparameter\c!screen}
+\to \everysetupscreens
+
+\setupscreens
+ [\c!screen=0.90] % was 0.95 but that's hardly visible
%D The parameter handler:
@@ -2492,7 +2500,7 @@
%\c!foregroundstyle=,
%\c!background=,
%\c!backgroundcolor=,
- \c!backgroundscreen=\@@rsscreen,
+ \c!backgroundscreen=\defaultbackgroundscreen,
\c!linecorrection=\v!on,
\c!depthcorrection=\v!on,
\c!margin=\v!standard]
@@ -2861,7 +2869,7 @@
%\c!foregroundcolor=,
%\c!foregroundstyle=,
%\c!background=,
- \c!backgroundscreen=\@@rsscreen,
+ \c!backgroundscreen=\defaultbackgroundscreen,
%\c!backgroundcolor=,
\c!backgroundoffset=\zeropoint,
%\c!framecolor=,
@@ -2890,7 +2898,4 @@
%\c!toffset=\zeropoint,
]%\c!boffset=\zeropoint]
-\setupscreens
- [\c!screen=0.95]
-
\protect \endinput
diff --git a/tex/context/base/page-bck.mkiv b/tex/context/base/page-bck.mkiv
index 100c186dd..4fbbba9f4 100644
--- a/tex/context/base/page-bck.mkiv
+++ b/tex/context/base/page-bck.mkiv
@@ -42,6 +42,12 @@
\fi
\to \everybeforepagebody
+\unexpanded\def\initializepagebackgrounds
+ {\setfalse\c_page_backgrounds_new
+ \setfalse\c_page_backgrounds_new_right
+ \setfalse\c_page_backgrounds_new_left
+ \setfalse\c_page_backgrounds_some}
+
%D We keep calculations and checks to a minimum and also
%D try to minimize the amount of tracing due to expansion.
@@ -122,22 +128,27 @@
\page_backgrounds_set_nop
\fi}
-\def\page_backgrounds_check#1%
- {\edef\currentotrbackground{\??ma#1}%
+%D We don't use the commandhandler code as we want these multitude of backgrounds to be
+%D as fast as possible.
+
+\installcorenamespace{layoutbackgrounds}
+
+\unexpanded\def\page_backgrounds_check#1%
+ {\edef\currentotrbackground{\??layoutbackgrounds#1}%
\page_backgrounds_check_background}
\def\ifsomebackgroundfound#1%
- {\ifcsname\??ma#1\endcsname}
+ {\ifcsname\??layoutbackgrounds#1\endcsname}
\def\doifsomebackgroundelse#1%
- {\ifcsname\??ma#1\endcsname
+ {\ifcsname\??layoutbackgrounds#1\endcsname
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
\def\doifsomebackground#1%
- {\ifcsname\??ma#1\endcsname
+ {\ifcsname\??layoutbackgrounds#1\endcsname
\expandafter\firstofoneargument
\else
\expandafter\gobbleoneargument
@@ -148,7 +159,7 @@
%D features can be used.
\def\page_backgrounds_add_to_box#1% area
- {\ifcsname\??ma#1\endcsname
+ {\ifcsname\??layoutbackgrounds#1\endcsname
\expandafter\page_backgrounds_add_to_box_indeed
\else
\expandafter\gobblefourarguments
@@ -158,11 +169,11 @@
% need a real framed or can we use a fake (i.e. no foreground, only for hidden)
\def\page_backgrounds_add_to_box_indeed#1#2#3#4% area box width height / always non zero
- {\ifcsname\??ma#1\c!setups\endcsname % to be done
- \doprocesslocalsetups{\csname\??ma#1\c!setups\endcsname}% should not produce funny spaces !
+ {\ifcsname\??layoutbackgrounds#1\c!setups\endcsname % to be done
+ \doprocesslocalsetups{\csname\??layoutbackgrounds#1\c!setups\endcsname}% should not produce funny spaces !
\fi
% #2 has the right dimensions already
- \setbox#2\hbox{\localbackgroundframed{\??ma#1}#1#2}}% a real framed (including foreground)
+ \setbox#2\hbox{\localbackgroundframed{\??layoutbackgrounds#1}#1#2}}% a real framed (including foreground)
%D There are quite some backgrounds. At the bottom layer,
%D there is the {\em paper} background. This one is only
@@ -230,7 +241,7 @@
\page_backgrounds_set_boxes_a
\page_backgrounds_set_boxes_b
\page_backgrounds_set_boxes_c
- \ifx\@@mastate\v!repeat\else
+ \ifx\p_page_backgrounds_state\v!repeat\else
\global\setfalse\c_page_backgrounds_new
\fi}
@@ -284,9 +295,9 @@
\fi \fi}
\def\page_backgrounds_set_offsets_indeed
- {\ifcsname\??ma\v!text\v!text\endcsname
+ {\ifcsname\??layoutbackgrounds\v!text\v!text\endcsname
\page_backgrounds_set_offsets_yes
- \else\ifcsname\??ma\v!text\endcsname
+ \else\ifcsname\??layoutbackgrounds\v!text\endcsname
\page_backgrounds_set_offsets_yes
\else
\page_backgrounds_set_offsets_nop
@@ -299,26 +310,26 @@
\global\pagebackgroundcompensation\zeropoint}
\def\page_backgrounds_set_offsets_yes
- {\global\pagebackgroundcompensation\csname\??ma\v!page\c!offset\endcsname\relax
+ {\global\pagebackgroundcompensation\csname\??layoutbackgrounds\v!page\c!offset\endcsname\relax
\ifzeropt\pagebackgroundcompensation
\page_backgrounds_set_offsets_nop
\else
- \ifcsname\??ma\v!top\v!text\endcsname
+ \ifcsname\??layoutbackgrounds\v!top\v!text\endcsname
\global\pagebackgroundhoffset\zeropoint
- \else\ifcsname\??ma\v!bottom\v!text\endcsname
+ \else\ifcsname\??layoutbackgrounds\v!bottom\v!text\endcsname
\global\pagebackgroundhoffset\zeropoint
\else
\global\pagebackgroundhoffset\pagebackgroundcompensation
\fi\fi
- \ifcsname\??ma\v!text\v!rightedge\endcsname
+ \ifcsname\??layoutbackgrounds\v!text\v!rightedge\endcsname
\global\pagebackgroundvoffset\zeropoint
\global\pagebackgrounddepth \zeropoint
- \else\ifcsname\??ma\v!text\v!leftedge\endcsname
+ \else\ifcsname\??layoutbackgrounds\v!text\v!leftedge\endcsname
\global\pagebackgroundvoffset\zeropoint
\global\pagebackgrounddepth \zeropoint
\else
\global\pagebackgroundvoffset\pagebackgroundcompensation
- \global\pagebackgrounddepth \csname\??ma\v!page\c!depth\endcsname\relax
+ \global\pagebackgrounddepth \csname\??layoutbackgrounds\v!page\c!depth\endcsname\relax
\fi\fi
\fi}
@@ -370,7 +381,7 @@
\bgroup\hbox\bgroup
\goleftonpage
\ifdim\leftedgewidth>\zeropoint
- \ifcsname\??ma#1\v!leftedge\endcsname
+ \ifcsname\??layoutbackgrounds#1\v!leftedge\endcsname
\page_backgrounds_set_box_cell#1\v!leftedge\leftedgewidth#2%
\else
\kern\leftedgewidth
@@ -378,21 +389,21 @@
\kern\leftedgedistance
\fi
\ifdim\leftmarginwidth>\zeropoint
- \ifcsname\??ma#1\v!leftmargin\endcsname
+ \ifcsname\??layoutbackgrounds#1\v!leftmargin\endcsname
\page_backgrounds_set_box_cell#1\v!leftmargin\leftmarginwidth#2%
\else
\kern\leftmarginwidth
\fi
\kern\leftmargindistance
\fi
- \ifcsname\??ma#1\v!text\endcsname
+ \ifcsname\??layoutbackgrounds#1\v!text\endcsname
\page_backgrounds_set_box_cell#1\v!text\makeupwidth#2%
\else
\kern\makeupwidth
\fi
\ifdim\rightmarginwidth>\zeropoint
\kern\rightmargindistance
- \ifcsname\??ma#1\v!rightmargin\endcsname
+ \ifcsname\??layoutbackgrounds#1\v!rightmargin\endcsname
\page_backgrounds_set_box_cell#1\v!rightmargin\rightmarginwidth#2%
\else
\kern\rightmarginwidth
@@ -400,7 +411,7 @@
\fi
\ifdim\rightedgewidth>\zeropoint
\kern\rightedgedistance
- \ifcsname\??ma#1\v!rightedge\endcsname
+ \ifcsname\??layoutbackgrounds#1\v!rightedge\endcsname
\page_backgrounds_set_box_cell#1\v!rightedge\rightedgewidth#2%
\else
\kern\rightedgewidth
@@ -415,15 +426,15 @@
\def\page_backgrounds_set_box_cell#1#2#3#4% pos pos width height
{\begingroup
- \ifcsname\??ma#1#2\c!setups\endcsname
- \doprocesslocalsetups{\csname\??ma#1#2\c!setups\endcsname}% should not produce funny spaces !
+ \ifcsname\??layoutbackgrounds#1#2\c!setups\endcsname
+ \expandafter\doprocesslocalsetups\csname\??layoutbackgrounds#1#2\c!setups\endcsname % should not produce funny spaces !
\fi
- \ifcsname\??ma#1#2\c!command\endcsname
+ \ifcsname\??layoutbackgrounds#1#2\c!command\endcsname
\expandafter\page_backgrounds_set_box_cell_nop
\else
\expandafter\page_backgrounds_set_box_cell_yes
\fi#1#2#3#4%
- \localbackgroundframed{\??ma#1#2}{#1:#2}\scratchbox
+ \localbackgroundframed{\??layoutbackgrounds#1#2}{#1:#2}\scratchbox
\endgroup}
\def\page_backgrounds_set_box_cell_nop#1#2#3#4%
@@ -432,7 +443,7 @@
\ht\scratchbox#4}
\def\page_backgrounds_set_box_cell_yes#1#2#3#4%
- {\setbox\scratchbox\vbox to #4{\vss\hbox to#3{\hss\csname\??ma#1#2\c!command\endcsname\hss}\vss}%
+ {\setbox\scratchbox\vbox to #4{\vss\hbox to#3{\hss\csname\??layoutbackgrounds#1#2\c!command\endcsname\hss}\vss}%
\dp\scratchbox\zeropoint}
%D The background mechanism is quite demanding in terms or
@@ -456,53 +467,58 @@
\unexpanded\def\setupbackgrounds
{\dotripleempty\page_backgrounds_setup}
-\def\page_backgrounds_setup[#1][#2][#3]%
+\def\page_backgrounds_setup
{\ifthirdargument
- \page_backgrounds_setup_double{#1}{#2}{#3}%
+ \expandafter\page_backgrounds_setup_double
\else\ifsecondargument
- \page_backgrounds_setup_single{#1}{#2}%
+ \doubleexpandafter\page_backgrounds_setup_single
\else\iffirstargument
- \page_backgrounds_setup_basics{#1}%
- \fi\fi\fi
- \the\everybackgroundssetup}
+ \tripleexpandafter\page_backgrounds_setup_basics
+ \fi\fi\fi}
\appendtoks
- \doifelsevalue{\??ma\v!page\c!offset}\v!overlay
+ \doifelsevalue{\??layoutbackgrounds\v!page\c!offset}\v!overlay
{\global\pageoffset\zeropoint}
- {\global\pageoffset\csname\??ma\v!page\c!offset\endcsname}%
- \global\pagedepth\csname\??ma\v!page\c!depth\endcsname
+ {\global\pageoffset\csname\??layoutbackgrounds\v!page\c!offset\endcsname}%
+ \global\pagedepth\csname\??layoutbackgrounds\v!page\c!depth\endcsname
\global\pagebackgroundoffset\pageoffset
\global\pagebackgrounddepth\pagedepth
- \doifelse\@@mastate\v!stop
- {\global\setfalse\c_page_backgrounds_new}
- {\global\settrue \c_page_backgrounds_new}%
+ \edef\p_page_backgrounds_state{\csname\??layoutbackgrounds\c!state\endcsname}%
+ \ifx\p_page_backgrounds_state\v!stop
+ \global\setfalse\c_page_backgrounds_new
+ \else
+ \global\settrue \c_page_backgrounds_new
+ \fi
\to \everybackgroundssetup
\def\v_page_backgrounds_double_set{\v!paper,\v!page,\v!leftpage,\v!rightpage}
\def\v_page_backgrounds_single_set{\v!text,\v!hidden,\v!paper,\v!page,\v!leftpage,\v!rightpage}
\def\v_page_backgrounds_common_set{\v!leftedge,\v!leftmargin,\v!text,\v!rightmargin,\v!rightedge}
-\def\page_backgrounds_setup_double#1#2#3%
+\def\page_backgrounds_setup_double[#1][#2][#3]% if needed we can speed this up
{\global\settrue\c_page_backgrounds_some
- \def\docommand##1%
+ \def\page_backgrounds_setup_step##1%
{\doifinsetelse{##1}\v_page_backgrounds_double_set
{\page_backgrounds_setup_and_check{##1}{#3}}
- {\def\dodocommand####1{\page_backgrounds_setup_and_check{##1####1}{#3}}%
- \processcommalist[#2]\dodocommand}}%
- \processcommalist[#1]\docommand}
+ {\def\page_backgrounds_setup_step_nested####1{\page_backgrounds_setup_and_check{##1####1}{#3}}%
+ \processcommalist[#2]\page_backgrounds_setup_step_nested}}%
+ \processcommalist[#1]\page_backgrounds_setup_step
+ \the\everybackgroundssetup}
-\def\page_backgrounds_setup_single#1#2%
+\def\page_backgrounds_setup_single[#1][#2][#3]%
{\global\settrue\c_page_backgrounds_some
\doifcommonelse{#1}\v_page_backgrounds_single_set
- {\def\docommand##1{\page_backgrounds_setup_and_check{##1}{#2}}%
- \processcommalist[#1]\docommand}%
- {\page_backgrounds_setup_double{#1}\v_page_backgrounds_common_set{#2}}}
+ {\def\page_backgrounds_setup_step##1{\page_backgrounds_setup_and_check{##1}{#2}}%
+ \processcommalist[#1]\page_backgrounds_setup_step
+ \the\everybackgroundssetup}%
+ {\page_backgrounds_setup_double[#1][\v_page_backgrounds_common_set][#2]}}
-\def\page_backgrounds_setup_basics#1%
- {\getparameters[\??ma][#1]}
+\def\page_backgrounds_setup_basics[#1][#2][#3]%
+ {\getparameters[\??layoutbackgrounds][#1]%
+ \the\everybackgroundssetup}
\def\page_backgrounds_setup_and_check#1#2% tag settings
- {\edef\currentotrbackground{\??ma#1}%
+ {\edef\currentotrbackground{\??layoutbackgrounds#1}%
\getparameters[\currentotrbackground][#2]%
\page_backgrounds_check_background}
@@ -511,7 +527,7 @@
% hm, we can delay them
-\unexpanded\def\installsomebackground#1#2{\inheritlocalframed[\??ma#1#2][\??od]}
+\unexpanded\def\installsomebackground#1#2{\inheritlocalframed[\??layoutbackgrounds#1#2][\??od]}
\installsomebackground \v!paper \empty
\installsomebackground \v!page \empty
@@ -551,7 +567,7 @@
\installsomebackground \v!rightpage \empty
\getparameters
- [\??ma\v!page]
+ [\??layoutbackgrounds\v!page]
[\c!offset=\zeropoint, % hm, so we need to force overlay elsewhere
\c!depth=\zeropoint]
@@ -567,12 +583,12 @@
% todo page-2 .. page+2 achter pagina -> bleed
% spread-2 .. spread+2 achter spread -> spread (repeat 2 times)
-\def\enablehiddenbackground
+\unexpanded\def\enablehiddenbackground
{\global\settrue\c_page_backgrounds_hidden_enabled
\global\settrue\c_page_backgrounds_some
\page_backgrounds_recalculate}
-\def\disablehiddenbackground
+\unexpanded\def\disablehiddenbackground
{\global\setfalse\c_page_backgrounds_hidden_enabled}
\def\hiddenbackgroundlist
@@ -598,7 +614,7 @@
% \installsomebackground \v!local \empty % not really a background, invisible for users
%
% \getparameters
-% [\??ma\v!local]
+% [\??layoutbackgrounds\v!local]
% [\c!component=local,
% \c!background=\localbackgroundlist]
%
@@ -618,7 +634,7 @@
% \fi}
%
% \def\page_backgrounds_add_local_to_box_indeed#1%
-% {\setbox#1\hbox{\localbackgroundframed{\??ma\v!local}\v!local#1}%
+% {\setbox#1\hbox{\localbackgroundframed{\??layoutbackgrounds\v!local}\v!local#1}%
% \global\advance\localpositionnumber\plusone} % afterwards !
%
% \let\page_backgrounds_add_local_to_box\gobbleoneargument
diff --git a/tex/context/base/page-col.mkiv b/tex/context/base/page-col.mkiv
index 87591e336..3143cadd2 100644
--- a/tex/context/base/page-col.mkiv
+++ b/tex/context/base/page-col.mkiv
@@ -13,22 +13,23 @@
\writestatus{loading}{ConTeXt Page Macros / Column Helpers}
-%D Here we implement a couple of helpers for dealing with
-%D columns. For the moment we keep the names.
+%D Here we implement a couple of helpers for dealing with columns. For
+%D the moment we keep the names. When the mul and set modules are redone
+%D these can be adapted or disappear.
\unprotect
-%D The next two registers can be used to store pre column
-%D material as well as footnotes or so.
+%D The next two registers can be used to store pre column material as well
+%D as footnotes or so.
\newbox\precolumnbox \newdimen\precolumnboxheight
\newbox\postcolumnbox \newdimen\postcolumnboxheight
-%D We reserve a counter for the number of columns as well as
-%D the current column. Both are not to be changed by users!
+%D We reserve a counter for the number of columns as well as the current
+%D column. Both are not to be changed by users!
-\newcount\nofcolumns \nofcolumns = 1
-\newcount\mofcolumns \mofcolumns = 1
+\newcount\nofcolumns \nofcolumns\plusone
+\newcount\mofcolumns \mofcolumns\plusone
\setnewconstant\maxnofcolumns 50
\setnewconstant\allocatednofcolumns 0
@@ -38,14 +39,13 @@
\newdimen\finalcolumnheights
\newcount\finalcolumnlines
-%D This register can be used as a temporary storage for page
-%D content.
+%D This register can be used as a temporary storage for page content.
\newbox\restofpage
%D A few more (some might go away):
-\newif\ifintermediatefootnotes
+\newif\ifintermediatefootnotes % seems to be obsolete
\newif\ifcarryoverfootnotes %\carryoverfootnotestrue
\newif\iflastcolumnfootnotes %\lastcolumnfootnotestrue
\newif\ifbalancecolumns %\balancecolumnstrue
@@ -70,7 +70,6 @@
\newif\ifrecentercolumnbox \recentercolumnboxtrue
\newif\ifrerecentercolumnbox \rerecentercolumnboxtrue
-\newif\ifpackcolumnfloats \packcolumnfloatstrue
%D During initialization the temporary boxes are allocated.
%D This enables us to use as much columns as we want, without
@@ -80,7 +79,12 @@
%D Two sets of boxes are declared, the txtboxes are used for
%D the text, the topboxes are for moved column floats.
-\def\initializecolumns#1%
+\installcorenamespace{columntext}
+\installcorenamespace{columnfooter}
+\installcorenamespace{columntop}
+\installcorenamespace{columnbottom}
+
+\unexpanded\def\initializecolumns#1%
{\ifnum#1>\maxnofcolumns
\showmessage\m!columns1\maxnofcolumns
\nofcolumns\maxnofcolumns
@@ -90,11 +94,10 @@
\ifnum\nofcolumns>\allocatednofcolumns
\dorecurse\nofcolumns
{\ifnum\recurselevel>\allocatednofcolumns\relax
- % \newbox\next \letgvalue{\??zc-\recurselevel-t}=\next
- \expandafter\newbox\csname\??zc-\recurselevel-t\endcsname % text
- \expandafter\newbox\csname\??zc-\recurselevel-f\endcsname % foot
- \expandafter\newbox\csname\??zc-\recurselevel-h\endcsname % top insert
- \expandafter\newbox\csname\??zc-\recurselevel-l\endcsname % top insert
+ \expandafter\newbox\csname\??columntext \recurselevel\endcsname % text
+ \expandafter\newbox\csname\??columnfooter\recurselevel\endcsname % footer
+ \expandafter\newbox\csname\??columntop \recurselevel\endcsname % top insert
+ \expandafter\newbox\csname\??columnbottom\recurselevel\endcsname % bottom insert
\fi}%
\global\allocatednofcolumns\nofcolumns
\fi}
@@ -107,10 +110,10 @@
\def\currenttopcolumnbox {\columntopbox \mofcolumns}
\def\lasttopcolumnbox {\columntopbox \nofcolumns}
-\def\columntextbox #1{\csname\??zc-\number#1-t\endcsname}
-\def\columnfootbox #1{\csname\??zc-\number#1-f\endcsname}
-\def\columntopbox #1{\csname\??zc-\number#1-h\endcsname}
-\def\columnbotbox #1{\csname\??zc-\number#1-l\endcsname}
+\def\columntextbox #1{\csname\??columntext \number#1\endcsname}
+\def\columnfootbox #1{\csname\??columnfooter\number#1\endcsname}
+\def\columntopbox #1{\csname\??columntop \number#1\endcsname}
+\def\columnbotbox #1{\csname\??columnbottom\number#1\endcsname}
\def\columnsettextbox {\global\setbox\columntextbox}
\def\columnsetfootbox {\global\setbox\columnfootbox}
@@ -122,30 +125,30 @@
\def\columngettopbox {\copy\columntopbox}
\def\columngetbotbox {\copy\columnbotbox}
-\def\columnerasetextboxes{\dorecurse\allocatednofcolumns{\columnsettextbox\recurselevel\emptybox}}
-\def\columnerasefootboxes{\dorecurse\allocatednofcolumns{\columnsetfootbox\recurselevel\emptybox}}
-\def\columnerasetopboxes {\dorecurse\allocatednofcolumns{\columnsettopbox \recurselevel\emptybox}}
-\def\columnerasebotboxes {\dorecurse\allocatednofcolumns{\columnsetbotbox \recurselevel\emptybox}}
+\unexpanded\def\columnerasetextboxes{\dorecurse\allocatednofcolumns{\columnsettextbox\recurselevel\emptybox}}
+\unexpanded\def\columnerasefootboxes{\dorecurse\allocatednofcolumns{\columnsetfootbox\recurselevel\emptybox}}
+\unexpanded\def\columnerasetopboxes {\dorecurse\allocatednofcolumns{\columnsettopbox \recurselevel\emptybox}}
+\unexpanded\def\columnerasebotboxes {\dorecurse\allocatednofcolumns{\columnsetbotbox \recurselevel\emptybox}}
+
+%D Without going in details we present two macro's which handle the columns. The
+%D action which is transfered by the the first and only parameter can do something
+%D with \type {\currentcolumnbox}. In case of the mid columns, \type
+%D {\firstcolumnbox} and \type {\lastcolumnbox} are handled outside these macro's.
-%D Without going in details we present two macro's which handle
-%D the columns. The action which is transfered by the the first
-%D and only parameter can do something with \type
-%D {\currentcolumnbox}. In case of the mid columns, \type
-%D {\firstcolumnbox} and \type {\lastcolumnbox} are handled
-%D outside these macro's.
+%D If needed these can be sped up by using a dedicated loop macro.
-\def\dohandlecolumn#1%
+\unexpanded\def\dohandlecolumn#1%
{\mofcolumns\recurselevel
\let\currentcolumn\recurselevel
#1\relax}
-\def\dohandleallcolumns#1%
+\unexpanded\def\dohandleallcolumns#1%
{\dorecurse\nofcolumns{\dohandlecolumn{#1}}}
-\def\dohandlerevcolumns#1%
+\unexpanded\def\dohandlerevcolumns#1%
{\dostepwiserecurse\nofcolumns\plusone\minusone{\dohandlecolumn{#1}}}
-\def\dohandlemidcolumns#1%
+\unexpanded\def\dohandlemidcolumns#1%
{\dohandleallcolumns
{\ifnum\recurselevel>\plusone
\ifnum\recurselevel<\nofcolumns
diff --git a/tex/context/base/page-com.mkiv b/tex/context/base/page-com.mkiv
index 80012dd14..61cb49e89 100644
--- a/tex/context/base/page-com.mkiv
+++ b/tex/context/base/page-com.mkiv
@@ -30,79 +30,141 @@
%D \stoppagecomment
%D \stoptyping
-\unexpanded\def\setuppagecomment
- {\dosingleempty\dosetuppagecomment}
-
-\def\dosetuppagecomment[#1]%
- {\getparameters[\??pc][#1]%
- \doifelse\@@pcstate\v!start
- {\doifinsetelse\@@pclocation{\v!bottom,\v!top}
- {\setuppapersize[\c!left=\hskip\@@pcoffset]%
- \edef\@@pcpaperheight{\the\dimexpr\paperheight+\@@pcoffset+\@@pcoffset+\@@pcdistance+\@@pcheight}%
- \edef\@@pcpaperwidth {\the\dimexpr\paperwidth +\@@pcoffset+\@@pcoffset}%
- \defineoverlay[\v!pagecomment][\placepagecommentTB]}
- {\setuppapersize[\c!top=\vskip\@@pcoffset]%
- \edef\@@pcpaperheight{\the\dimexpr\paperheight+\@@pcoffset+\@@pcoffset}%
- \edef\@@pcpaperwidth {\the\dimexpr\paperwidth +\@@pcoffset+\@@pcoffset+\@@pcdistance+\@@pcwidth}%
- \defineoverlay[\v!pagecomment][\placepagecommentLR]}%
- \processaction
- [\@@pclocation]
- [ \v!bottom=>{\setuplayout[\c!location=]\setuppapersize[\c!bottom=\vss,\c!top =\vskip\@@pcoffset]},
- \v!top=>{\setuplayout[\c!location=]\setuppapersize[\c!top =\vss,\c!bottom=\vskip\@@pcoffset]},
- \v!left=>{\setuplayout[\c!location=]\setuppapersize[\c!left =\hss,\c!right =\hskip\@@pcoffset]},
- \v!right=>{\setuplayout[\c!location=]\setuppapersize[\c!right =\hss,\c!left =\hskip\@@pcoffset]}]%
- \definepapersize
- [\v!pagecomment]
- [\c!height=\@@pcpaperheight,
- \c!width=\@@pcpaperwidth]%
- \let\@@pcprintpapersize\printpapersize
- \setuppapersize[\papersize][\v!pagecomment]%
- \setupbackgrounds[\v!paper][\c!background=\v!pagecomment]}% todo append if already set
- {\doif\@@pcstate\v!stop % else initialization invokes backgrounds
- {% this should be tested first
- % \normalexpanded{\noexpand\setuppapersize[\papersize][\@@pcprintpapersize]}%
- \setupbackgrounds[\v!paper][\c!background=]}}}
-
-\def\@@pcprintpapersize{\printpapersize}
-
-\unexpanded\def\placepagecommentTB
+\installcorenamespace{pagecomment}
+\installcorenamespace{pagecommentlocations}
+\installcorenamespace{pagecommentstates}
+
+\newdimen\d_page_comments_offset
+\newdimen\d_page_comments_page_width
+\newdimen\d_page_comments_page_height
+\newdimen\d_page_comments_width
+\newdimen\d_page_comments_height
+\newdimen\d_page_comments_distance
+
+\newconditional\c_page_comment_enabled
+
+\let\p_page_commands_location\v!none
+\let\p_page_commands_state \v!stop
+
+\installsetuponlycommandhandler \??pagecomment {pagecomment}
+
+\appendtoks
+ \edef\p_page_commands_location{\directpagecommentparameter\c!location}%
+ \edef\p_page_commands_state {\directpagecommentparameter\c!state}%
+ \expandcheckedcsname\??pagecommentstates\p_page_commands_state\v!none
+\to \everysetuppagecomment
+
+\ifdefined\scrn_canvas_synchronize_simple
+
+ \appendtoks
+ \ifx\p_page_commands_state\v!start
+ \scrn_canvas_synchronize_simple
+ \else
+ \scrn_canvas_synchronize_complex
+ \fi
+ \to \everyshipout
+
+\fi
+
+\setvalue{\??pagecommentstates\v!start}%
+ {\d_page_comments_offset \directpagecommentparameter\c!offset \relax
+ \d_page_comments_distance\directpagecommentparameter\c!distance\relax
+ \d_page_comments_width \directpagecommentparameter\c!width \relax
+ \d_page_comments_height \directpagecommentparameter\c!height \relax
+ \expandcheckedcsname\??pagecommentlocations\p_page_commands_location\v!none
+ \definepapersize[\v!pagecomment][\c!height=\d_page_comments_page_height,\c!width=\d_page_comments_page_width]%
+ \setuppapersize[\papersize][\v!pagecomment]%
+ \setupbackgrounds[\v!paper][\c!background=\v!pagecomment]} % maybe append if already set
+
+\setvalue{\??pagecommentstates\v!stop}%
+ {\setupbackgrounds[\v!paper][\c!background=]}
+
+\setvalue{\??pagecommentstates\v!none}%
+ {}
+
+\setvalue{\??pagecommentlocations\v!bottom}%
+ {\setuplayout[\c!location=]%
+ \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=\vss,\c!left=\hskip\d_page_comments_offset,\c!right=]%
+ \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_height\relax
+ \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset\relax
+ \defineoverlay[\v!pagecomment][\page_comments_top_bottom]}
+
+\setvalue{\??pagecommentlocations\v!top}%
+ {\setuplayout[\c!location=]%
+ \setuppapersize[\c!top=\vss,\c!bottom=\vskip\d_page_comments_offset,\c!left=\hskip\d_page_comments_offset,\c!right=]%
+ \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_height\relax
+ \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset\relax
+ \defineoverlay[\v!pagecomment][\page_comments_top_bottom]}
+
+\setvalue{\??pagecommentlocations\v!left}%
+ {\setuplayout[\c!location=]%
+ \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=,\c!left=\hss,\c!right=\hskip\d_page_comments_offset]%
+ \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset\relax
+ \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_width\relax
+ \defineoverlay[\v!pagecomment][\page_comments_left_right]}
+
+\setvalue{\??pagecommentlocations\v!right}%
+ {\setuplayout[\c!location=]%
+ \setuppapersize[\c!top=\vskip\d_page_comments_offset,\c!bottom=,\c!left=\hskip\d_page_comments_offset,\c!right =\hss]%
+ \d_page_comments_page_height\dimexpr\paperheight+2\d_page_comments_offset\relax
+ \d_page_comments_page_width \dimexpr\paperwidth +2\d_page_comments_offset+\d_page_comments_distance+\d_page_comments_width\relax
+ \defineoverlay[\v!pagecomment][\page_comments_left_right]}
+
+\setvalue{\??pagecommentlocations\v!none}%
+ {}% \setuppapersize[\c!bottom=,\c!top=,\c!left=,\c!right=]}
+
+\unexpanded\def\page_comments_top_bottom
{\vbox to \printpaperheight
{%\forgetall
- \hsize\printpaperwidth
- \vskip\@@pcoffset
- \doifelse\@@pclocation\v!bottom{\vskip\dimexpr\paperheight+\@@pcdistance\relax}\vss
- \hskip\@@pcoffset
- \vbox to \@@pcheight
+ \hsize\printpaperwidth\relax
+ \ifx\p_page_commands_location\v!bottom
+ \vskip\dimexpr\paperheight+\d_page_comments_distance+\d_page_comments_offset\relax
+ \else
+ \vskip\d_page_comments_offset
+ \vss
+ \fi
+ \hskip\d_page_comments_offset
+ \vbox to \d_page_comments_height
{%\forgetall
\hsize\paperwidth
- \ifpagecomment
+ \ifconditional\c_page_comment_enabled
\getbuffer[\v!pagecomment]%
- \global\pagecommentfalse
+ \global\setfalse\c_page_comment_enabled
\fi}%
\hfill
- \doifelse\@@pclocation\v!bottom\vss{\vskip\dimexpr\paperheight+\@@pcdistance\relax}%
- \vskip\@@pcoffset}}
+ \ifx\p_page_commands_location\v!bottom
+ \vss
+ \vskip\d_page_comments_offset
+ \else
+ \vskip\dimexpr\paperheight+\d_page_comments_distance+\d_page_comments_offset\relax
+ \fi}}
-\unexpanded\def\placepagecommentLR
+\unexpanded\def\page_comments_left_right
{\hbox to \printpaperwidth
- {\hskip\@@pcoffset
- \doifelse\@@pclocation\v!right{\hskip\paperwidth\hskip\@@pcdistance}\hss
+ {\ifx\p_page_commands_location\v!right
+ \hskip\dimexpr\paperwidth+\d_page_comments_distance+\d_page_comments_offset\relax
+ \else
+ \hskip\d_page_comments_offset
+ \hss
+ \fi
\vbox to \printpaperheight
{%\forgetall
- \vskip\@@pcoffset
- \hsize\@@pcwidth
- \ifpagecomment
+ \vskip\d_page_comments_offset
+ \hsize\d_page_comments_width
+ \ifconditional\c_page_comment_enabled
\getbuffer[\v!pagecomment]%
- \global\pagecommentfalse
+ \global\setfalse\c_page_comment_enabled
\fi
\vss}%
- \doifelse\@@pclocation\v!right\hss{\hskip\paperwidth\hskip\@@pcdistance}%
- \hskip\@@pcoffset}}
-
-\newif\ifpagecomment
+ \ifx\p_page_commands_location\v!right
+ \hss
+ \hskip\d_page_comments_offset
+ \else
+ \hskip\dimexpr\paperwidth+\d_page_comments_distance+\d_page_comments_offset\relax
+ \fi}}
\setvalue{\e!start\v!pagecomment}%
- {\global\pagecommenttrue
+ {\global\settrue\c_page_comment_enabled
\grabbufferdatadirect\v!pagecomment{\e!start\v!pagecomment}{\e!stop\v!pagecomment}}
\setuppagecomment
diff --git a/tex/context/base/page-fac.mkiv b/tex/context/base/page-fac.mkiv
index fef1cd5ac..88789abe9 100644
--- a/tex/context/base/page-fac.mkiv
+++ b/tex/context/base/page-fac.mkiv
@@ -25,19 +25,21 @@
%D \stoptext
%D \stoptyping
-\newbox\b_page_facings_content
+\newbox \b_page_facings_content
+\newconditional\c_page_facings_busy
-\unexpanded\def\setupoppositeplacing
- {\dodoubleargument\getparameters[\??np]}
+\installcorenamespace{oppositeplacing}
+
+\installsetuponlycommandhandler \??oppositeplacing {oppositeplacing}
\unexpanded\def\startopposite
{\dowithnextboxcontent
{\hsize\makeupwidth}%
{\global\setbox\b_page_facings_content\vbox
{\ifvoid\b_page_facings_content
- \@@npbefore
+ \directoppositeplacingparameter\c!before
\else
- \@@npinbetween
+ \directoppositeplacingparameter\c!inbetween
\unvbox\b_page_facings_content
\fi
\box\nextbox}}%
@@ -47,26 +49,34 @@
{\egroup}
\def\page_facings_finish
- {\ifvoid\b_page_facings_content\else
+ {\ifvoid\b_page_facings_content \else
\global\setbox\b_page_facings_content\vbox to \makeupheight
{\unvbox\b_page_facings_content
- \@@npafter
+ \directoppositeplacingparameter\c!after
\vss}%
\fi}
\def\page_facings_flush
- {\doif\@@npstate\v!start
- {\ifvoid\b_page_facings_content\else
- \ifnum\realpageno>\plusone
- \begingroup
- \pageornamentstate\plusone % tricky
- \page_facings_finish
- \page_boxes_shipout{\page_boxes_constructed_page\box\b_page_facings_content}%
- \endgroup
- \else
- \global\setbox\b_page_facings_content\emptybox
- \fi
- \fi}}
+ {\ifconditional\c_page_facings_busy
+ \ifvoid\b_page_facings_content \else
+ \page_facings_flush_indeed
+ \fi
+ \fi}
+
+\def\page_facings_flush_indeed
+ {\ifnum\realpageno>\plusone
+ \begingroup
+ \pageornamentstate\plusone % tricky
+ \page_facings_finish
+ \page_boxes_shipout{\page_boxes_constructed_page\box\b_page_facings_content}%
+ \endgroup
+ \else
+ \global\setbox\b_page_facings_content\emptybox
+ \fi}
+
+\appendtoks
+ \doifelse{\directoppositeplacingparameter\c!state}\v!start\settrue\setfalse\c_page_facings_busy
+\to \everysetupoppositeplacing
\setupoppositeplacing
[\c!state=\v!start,
diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv
index 18c0ad263..4655d92af 100644
--- a/tex/context/base/page-flt.mkiv
+++ b/tex/context/base/page-flt.mkiv
@@ -20,31 +20,28 @@
\unprotect
-%D To be checked and removed
-
-%def\dosavefloatinfo {\showmessage\m!floatblocks2{\the\totalnoffloats}}
-\def\doinsertfloatinfo {\showmessage\m!floatblocks4{\the\totalnoffloats}}
-\def\dofloatflushedinfo{\showmessage\m!floatblocks3{\the\numexpr\totalnoffloats-\savednoffloats\relax}}
+%def\page_floats_report_saved {\showmessage\m!floatblocks2{\the\totalnoffloats}}
+\def\page_floats_report_total {\showmessage\m!floatblocks4{\the\totalnoffloats}}
+\def\page_floats_report_flushed{\showmessage\m!floatblocks3{\the\numexpr\totalnoffloats-\savednoffloats\relax}}
%D Extra float registers.
-\newif\ifsomefloatwaiting \somefloatwaitingfalse
-\newif\ifroomforfloat \roomforfloattrue
-\newif\ifnofloatpermitted \nofloatpermittedfalse
-\newif\ifcenterfloatbox \centerfloatboxtrue
-\newif\iflocalcenterfloatbox \localcenterfloatboxfalse
-\newif\ifglobalcenterfloatbox \globalcenterfloatboxfalse
-\newif\ifflushingfloats \flushingfloatsfalse
-\newif\ifpackflushedfloats \packflushedfloatstrue % for the moment
-\newif\ifpackcolumnfloats \packcolumnfloatstrue
-
-\newcount\totalnoffloats
-\newcount\savednoffloats
-\newcount\noffloatinserts
+\newconditional\c_page_floats_room
+\newconditional\c_page_floats_some_waiting
+\newconditional\c_page_floats_not_permitted
+\newconditional\c_page_floats_flushing
+\newconditional\c_page_floats_center_box \settrue\c_page_floats_center_box
+\newconditional\c_page_floats_center_box_local
+\newconditional\c_page_floats_center_box_global
+\newconditional\c_page_floats_pack_flushed \settrue\c_page_floats_pack_flushed
+
+%D For the moment we keep this but they will become private too.
+
+\newcount\totalnoffloats % these will be redone ... handled at the lua end anyway
+\newcount\savednoffloats % these will be redone ... handled at the lua end anyway
+\newcount\noffloatinserts % these will be redone ... handled at the lua end anyway
\newcount\nofcollectedfloats % communication channel
-\newbox \floatlist
-\newbox \savedfloatlist
\newbox \floattext
\newdimen\floatwidth
@@ -65,55 +62,55 @@
\appendtoks
\ifcase\savednoffloats
- \global\somefloatwaitingfalse
+ \global\setfalse\c_page_floats_some_waiting
\else
- \global\somefloatwaitingtrue
+ \global\settrue\c_page_floats_some_waiting
\fi
\to \everyfloatscheck
-\def\dofloatsflush#1#2%
+\unexpanded\def\page_floats_flush#1#2%
{\ctxcommand{flushfloat("#1",\number#2)}%
\the\everyfloatscheck}
-\def\dofloatsflushbylabel#1#2%
+\unexpanded\def\page_floats_flush_by_label#1#2%
{\ctxcommand{flushfloat("#1","#2",true)}%
\the\everyfloatscheck}
-\def\dofloatssave#1%
+\unexpanded\def\page_floats_save#1%
{\ctxcommand{savefloat("#1")}%
\the\everyfloatscheck}
-\def\dofloatsresave#1%
+\unexpanded\def\page_floats_resave#1%
{\ctxcommand{resavefloat("#1")}%
\the\everyfloatscheck}
-\def\dopushsavedfloats
+\unexpanded\def\page_floats_push_saved
{\ctxcommand{pushfloat()}%
\the\everyfloatscheck}
-\def\dopopsavedfloats
+\unexpanded\def\page_floats_pop_saved
{\ctxcommand{popfloat()}%
\the\everyfloatscheck}
-\def\dofloatsgetinfo#1%
+\unexpanded\def\page_floats_get_info#1%
{\ctxcommand{consultfloat("#1")}}
-\def\doifelsesavedfloat#1%
+\unexpanded\def\page_floats_if_else#1%
{\ctxcommand{doifelsesavedfloat("#1")}}
-\def\dofloatscollect#1#2#3%
+\unexpanded\def\page_floats_collect#1#2#3%
{\ctxcommand{collectfloat("#1",\number\dimexpr#2,\number\dimexpr#3)}}
-\def\nofstackedfloatincategory#1%
+\unexpanded\def\nofstackedfloatincategory#1%
{\ctxcommand{nofstackedfloats("#1")}}
-\let\dopushcolumnfloats\dopushsavedfloats
-\let\dopopcolumnfloats \dopopsavedfloats
+\let\page_floats_column_push_saved\page_floats_push_saved % overloaded in page-mul
+\let\page_floats_column_pop_saved \page_floats_pop_saved % overloaded in page-mul
-\def\dofloatssavepagefloat#1#2%
+\unexpanded\def\page_floats_save_page_float#1#2%
{\ctxcommand{savefloat("#1", { specification = "#2" })}}
-\def\dofloatssavesomewherefloat#1#2% #1=method
+\unexpanded\def\page_floats_save_somewhere_float#1#2% #1=method
{\ctxcommand{savefloat("#1", { specification = "#2", label = "\floatlabel" })}}
%D This is an experimental new feature (for Alan Braslau), a prelude to more:
@@ -133,12 +130,12 @@
%D \placenamedfloat[figure][beta]
%D \stoptyping
-\def\placenamedfloat
- {\dodoubleargument\doplacenamedfloat}
+\unexpanded\def\placenamedfloat
+ {\dodoubleargument\page_floats_place_named}
-\def\doplacenamedfloat[#1][#2]%
+\def\page_floats_place_named[#1][#2]%
{\doloop
- {\dofloatsflushbylabel\s!somewhere{#2}%
+ {\page_floats_flush_by_label\s!somewhere{#2}%
\ifvoid\floatbox
\exitloop
\else
@@ -162,10 +159,10 @@
%
% \placefloatwithsetups[somefigure]{}{\externalfigure[dummy][width=5cm,height=2cm]}
-\def\placefloatwithsetups
- {\dotripleempty\doplacefloatwithsetups}
+\unexpanded\def\placefloatwithsetups
+ {\dotripleempty\page_floats_place_with_setups}
-\long\def\doplacefloatwithsetups[#1][#2][#3]#4%
+\def\page_floats_place_with_setups[#1][#2][#3]#4%
{\def\floatsetupcaption {#4}%
\def\floatsetupcontent {\copy\nextbox}%
\def\floatsetupwidth {\wd\nextbox}%
@@ -178,10 +175,10 @@
%D
%D First we reimplement some helpers.
-\def\dogetfloat
- {\ifsomefloatwaiting
- \dofloatsflush\s!text{1}%
- \ifcenterfloatbox
+\unexpanded\def\page_floats_get
+ {\ifconditional\c_page_floats_some_waiting
+ \page_floats_flush\s!text\plusone
+ \ifconditional\c_page_floats_center_box
\ifdim\wd\globalscratchbox<\hsize
\global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
\else
@@ -198,40 +195,30 @@
\global\setbox\floatbox\emptybox
\fi}
-\def\dosavefloat
- {\dofloatssave\s!text
- \nonoindentation} % brrr nonoindentation here
-
-\def\doresavefloat
- {\dofloatsresave\s!text}
-
-\def\doreversesavefloat
- {\dofloatsresave\s!text}
-
-\def\doflushsavedfloats
+\unexpanded\def\page_floats_flush_saved
{\doloop
- {\ifsomefloatwaiting
+ {\ifconditional\c_page_floats_some_waiting
\page_otr_command_check_if_float_fits
- \ifroomforfloat
- \dogetfloat
+ \ifconditional\c_page_floats_room
+ \page_floats_get
\doplacefloatbox
\else
\exitloop
\fi
\else
-% \ifconditional\c_page_margin_blocks_present % not here, here just as many floats as fit
-% \page_otr_command_flush_margin_blocks
-% \else
+ % \ifconditional\c_page_margin_blocks_present % not here, here just as many floats as fit
+ % \page_otr_command_flush_margin_blocks
+ % \else
\exitloop
-% \fi
+ % \fi
\fi}}
%D Page floats use different stacks.
-\newtoks \everybeforeflushedpagefloat
+\newtoks\everybeforeflushedpagefloat
-\def\doflushsomepagefloat#1% future releases can do more clever things
- {\dofloatsflush{#1}{1}%
+\def\page_floats_flush_page_floats_indeed#1% future releases can do more clever things
+ {\page_floats_flush{#1}\plusone
\edef\floatspecification{\ctxcommand{getfloatvariable("specification")}}% Is this okay?
\the\everybeforeflushedpagefloat
\vbox to \textheight
@@ -240,38 +227,15 @@
\doifnotinset\v!low\floatspecification\vfill}%
\page_otr_fill_and_eject_page}
-\def\doflushpagefloats
+\unexpanded\def\page_floats_flush_page_floats % used in postpone
{\edef\m_page_otf_checked_page_float{\ctxcommand{checkedpagefloat()}}% (true) for packed
\ifx\m_page_otf_checked_page_float\empty
% nothing
\else\ifx\m_page_otf_checked_page_float\v!empty
\emptyhbox \page_otr_fill_and_eject_page % why not dummy_page
\else
- \doflushsomepagefloat\m_page_otf_checked_page_float
+ \page_floats_flush_page_floats_indeed\m_page_otf_checked_page_float
\fi\fi}
-
-\def\uncenteredfloatbox % hm, where is this one used (was in save/restore, see old implementation)
- {\ifcenterfloatbox
- \ifhbox\floatbox\relax % remove centering
- \ifdim\wd\floatbox=\hsize
- \ifhbox\floatbox
- \setbox\scratchbox\hbox
- {\unhbox\floatbox
- \unskip\unskip
- \global\setbox\globalscratchbox\lastbox}%
- \box\globalscratchbox
- \else
- \box\floatbox
- \fi
- \else
- \box\floatbox
- \fi
- \else
- \box\floatbox
- \fi
- \else
- \box\floatbox
- \fi}
% temp hack, needed to prevent floatbox being forgotten during
% output, this will change to using another box for flushing
@@ -291,3 +255,28 @@
\to \everyafteroutput
\protect \endinput
+
+% hm, where is this one used (was in save/restore, see old implementation)
+%
+% \unexpanded\def\uncenteredfloatbox
+% {\ifconditional\c_page_floats_center_box
+% \ifhbox\floatbox\relax % remove centering
+% \ifdim\wd\floatbox=\hsize
+% \ifhbox\floatbox
+% \setbox\scratchbox\hbox
+% {\unhbox\floatbox
+% \unskip\unskip
+% \global\setbox\globalscratchbox\lastbox}%
+% \box\globalscratchbox
+% \else
+% \box\floatbox
+% \fi
+% \else
+% \box\floatbox
+% \fi
+% \else
+% \box\floatbox
+% \fi
+% \else
+% \box\floatbox
+% \fi}
diff --git a/tex/context/base/page-flw.mkiv b/tex/context/base/page-flw.mkiv
index 9afacf584..ec1fa636d 100644
--- a/tex/context/base/page-flw.mkiv
+++ b/tex/context/base/page-flw.mkiv
@@ -14,93 +14,127 @@
\writestatus{loading}{ConTeXt Page Macros / Text Flows}
%D This is high experimental and especially flushing may change (proper
-%D spacing is the driving force here).
+%D spacing is the driving force here). It's an old mechanism used for
+%D playing with stepping through document threads. As it's a simple and
+%D effective mechanism we keep it around. It's not to be confused with
+%D upcoming stream support.
+%D
+%D \starttyping
+%D \setuppapersize [S6]
+%D \setuptolerance [verytolerant,stretch]
+%D \setupfooter [strut=no]
+%D \setupwhitespace[big]
+%D
+%D \setuplayout
+%D [rightedge=5cm,width=fit,margin=0pt,edgedistance=1cm,
+%D footer=4cm,footerdistance=1cm,header=0cm]
+%D
+%D \setuptexttexts [edge][][\vbox{\flushtextflow{alpha}}]
+%D \setupfootertexts[edge][][\vbox{\flushtextflow{beta}}]
+%D \setupfootertexts [\vbox{\flushtextflow{gamma}}][]
+%D
+%D \definetextflow [alfa] [width=\rightedgewidth]
+%D \definetextflow [beta] [width=\rightedgewidth]
+%D \definetextflow [gamma] [width=\footerheight]
+%D
+%D \starttext
+%D
+%D \dorecurse{50}
+%D {\getrandomnumber{\funny}{0}{8}
+%D \ifcase\funny \starttextflow[alfa] \input tufte.tex \stoptextflow
+%D \or \starttextflow[beta] \input knuth.tex \stoptextflow
+%D \or \starttextflow[gamma] \input materie.tex \stoptextflow
+%D \or {\bf TUFTE}\quad \input tufte \par
+%D \or {\bf TUFTE}\quad \input tufte \par
+%D \or {\bf KNUTH}\quad \input knuth \par
+%D \or {\bf KNUTH}\quad \input knuth \par
+%D \or {\bf MATERIE}\quad \input materie \par
+%D \else {\bf MATERIE}\quad \input materie \par
+%D \fi}
+%D
+%D \stoptext
+%D \stoptyping
\unprotect
-\unexpanded\def\definetextflow
- {\dodoubleempty\dodefinetextflow}
+\installcorenamespace{textflow}
+\installcorenamespace{textflowbox}
-\def\dodefinetextflow[#1][#2]% flow settings
- {\iffirstargument
- \doiftextflowcollectorelse{#1}
- {\setbox\textflowcollector{#1}\emptybox}
- {\@EA\newbox\csname\??tx:c:#1\endcsname}%
- \getparameters[\??tx:p:#1]
- [\c!width=\hsize,\c!style=,#2]%
- \fi}
+\installcommandhandler \??textflow {textflow} \??textflow
-\def\textflowparameter#1#2{\csname\??tx:p:#1#2\endcsname}
-\def\textflowcollector #1{\csname\??tx:c:#1\endcsname}
+\setuptextflow
+ [%c!style=,
+ %c!color=,
+ \c!width=\availablehsize]
-\def\doiftextflowcollectorelse#1{\doifdefinedelse{\??tx:c:#1}}
+\appendtoks
+ \ifcsname\??textflowbox\currenttextflow\endcsname
+ \setbox\csname\??textflowbox\currenttextflow\endcsname\emptybox
+ \else
+ \expandafter\newbox\csname\??textflowbox\currenttextflow\endcsname
+ \fi
+\to \everydefinetextflow
-\def\doiftextflowelse#1%
- {\doiftextflowcollectorelse{#1}
- {\ifvoid\textflowcollector{#1}%
- \expandafter\secondoftwoarguments
- \else
- \expandafter\firstoftwoarguments
- \fi}
- {\secondoftwoarguments}}
+\let\b_page_textflow_box\zerocount
-\def\doiftextflow#1%
- {\doiftextflowelse{#1}\firstofoneargument\gobbleoneargument}
+\def\textflowcollector#1%
+ {\csname\??textflowbox#1\endcsname}
+
+\unexpanded\def\doiftextflowcollectorelse#1%
+ {\ifcsname\??textflowbox#1\endcsname
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\unexpanded\def\doiftextflowelse#1%
+ {\ifcsname\??textflowbox#1\endcsname
+ \ifvoid\csname\??textflowbox#1\endcsname
+ \doubleexpandafter\secondoftwoarguments
+ \else
+ \doubleexpandafter\firstoftwoarguments
+ \fi
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+% \unexpanded\def\doiftextflow#1%
+% {\doiftextflowelse{#1}\firstofoneargument\gobbleoneargument}
\unexpanded\def\starttextflow[#1]%
- {\doiftextflowcollectorelse{#1}
- {\global\setbox\textflowcollector{#1}\vbox
- \bgroup
- \unvbox\textflowcollector{#1}%
- \hsize\textflowparameter{#1}\c!width
- \dousestyleparameter{\textflowparameter{#1}\c!style}%
- \unexpanded\def\stoptextflow{\endgraf\egroup}}
- {\let\stoptextflow\relax}}
+ {\begingroup
+ \edef\currenttextflow{#1}%
+ \ifcsname\??textflowbox\currenttextflow\endcsname
+ \b_page_textflow_box\csname\??textflowbox\currenttextflow\endcsname
+ \global\setbox\b_page_textflow_box\vbox
+ \bgroup
+ \dontcomplain
+ \ifvoid\b_page_textflow_box\else
+ \unvbox\b_page_textflow_box
+ \fi
+ \hsize\textflowparameter\c!width\relax
+ \usetextflowstyleandcolor\c!style\c!color
+ \unexpanded\def\stoptextflow{\endgraf\egroup\endgroup}%
+ \else
+ \let\stoptextflow\endgroup
+ \fi}
-\def\flushtextflow#1%
- {\doiftextflow{#1}
- {\ifdim\ht\textflowcollector{#1}>\vsize
- \setbox\scratchbox\vsplit\textflowcollector{#1} to \vsize
- \unvbox\scratchbox
+\unexpanded\def\flushtextflow#1%
+ {\begingroup
+ \edef\currenttextflow{#1}%
+ \ifcsname\??textflowbox\currenttextflow\endcsname
+ \b_page_textflow_box\csname\??textflowbox\currenttextflow\endcsname
+ \ifvoid\b_page_textflow_box
+ % sorry
+ \else\ifdim\ht\b_page_textflow_box>\vsize
+ \setbox\scratchbox\vsplit\b_page_textflow_box to \vsize
+ \ifvoid\scratchbox\else
+ \unvbox\scratchbox
+ \fi
\else
- \unvbox\textflowcollector{#1}%
- \fi}}
+ \unvbox\b_page_textflow_box
+ \fi\fi
+ \fi
+ \endgroup}
\protect \endinput
-
-% Example (dutch)
-%
-% \stelpapierformaatin [S6]
-% \steltolerantiein [soepel,rek]
-% \stelkleurenin [status=start]
-% \stelvoetin [strut=nee]
-% \stelwitruimtein [groot]
-%
-% \stellayoutin
-% [rechterrand=5cm,breedte=passend,marge=0pt,randafstand=1cm,
-% voet=4cm,voetafstand=1cm,hoofd=0cm]
-%
-% \stelteksttekstenin[rand][][\vbox{\flushtextflow{alpha}}]
-% \stelvoettekstenin [rand][][\vbox{\flushtextflow{beta}}]
-% \stelvoettekstenin [\vbox{\flushtextflow{gamma}}][]
-%
-% \definetextflow [alfa] [breedte=\rechterrandbreedte]
-% \definetextflow [beta] [breedte=\rechterrandbreedte]
-% \definetextflow [gamma] [breedte=\voethoogte]
-%
-% \starttekst
-%
-% \dorecurse{50}
-% {\getrandomnumber{\funny}{0}{8}
-% \ifcase\funny \starttextflow[alfa] \input tufte.tex \stoptextflow
-% \or \starttextflow[beta] \input knuth.tex \stoptextflow
-% \or \starttextflow[gamma] \input materie.tex \stoptextflow
-% \or {\bf TUFTE}\quad \input tufte \par
-% \or {\bf TUFTE}\quad \input tufte \par
-% \or {\bf KNUTH}\quad \input knuth \par
-% \or {\bf KNUTH}\quad \input knuth \par
-% \or {\bf MATERIE}\quad \input materie \par
-% \else {\bf MATERIE}\quad \input materie \par
-% \fi}
-%
-% \stoptekst
diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv
index 9d0f722fe..5eb587b7b 100644
--- a/tex/context/base/page-imp.mkiv
+++ b/tex/context/base/page-imp.mkiv
@@ -148,8 +148,7 @@
\donetrue
\fi
\else % testen, aangepast / expanded nodig ?
- \normalexpanded{\doifinsetelse{\the\shippedoutpages}{\pagestoshipout}}%
- \donetrue\donefalse
+ \normalexpanded{\doifinsetelse{\the\shippedoutpages}{\pagestoshipout}}\donetrue\donefalse
\fi
\ifdone
\setbox\shipoutscratchbox\hbox{#1}%
diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv
index 78d7f892e..59fcb38b6 100644
--- a/tex/context/base/page-ini.mkiv
+++ b/tex/context/base/page-ini.mkiv
@@ -64,7 +64,7 @@
\def\page_otr_flush_all_floats
{%\flushnotes already done
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\begingroup
\noftopfloats\plusthousand
\nofbotfloats\zerocount
@@ -107,7 +107,7 @@
\doincrementpageboundcounters % should hook into an every
\page_adapts_synchronize
\page_otr_check_for_pending_inserts
- \doflushspread
+ \page_spread_flush % defined later
\page_postponed_blocks_flush}
% Can't we get rid of this hackery? It's used in some widgets
diff --git a/tex/context/base/page-ins.mkiv b/tex/context/base/page-ins.mkiv
index 793e28d4c..33c50451b 100644
--- a/tex/context/base/page-ins.mkiv
+++ b/tex/context/base/page-ins.mkiv
@@ -13,20 +13,17 @@
\writestatus{loading}{ConTeXt Core Macros / Insertions}
-%D Insertions are special data collections that are associated
-%D to \TEX's internal page builder. When multiple footnote
-%D classes were introduced, I decided to isolate some of the
-%D functionality in a module.
+%D Insertions are special data collections that are associated to \TEX's internal
+%D page builder. When multiple footnote classes were introduced, I decided to
+%D isolate some of the functionality in a module.
\unprotect
-\newtoks\@@insertionlist
-
-\def\processinsertions{\the\@@insertionlist}
+\newtoks\t_page_inserts_list
\let\doprocessinsert\gobbleoneargument
-\def\installinsertion#1%
+\unexpanded\def\installinsertion#1%
{\ifdefined#1\else
\let#1\relax
\fi
@@ -35,56 +32,61 @@
\count#1\plusthousand
\skip #1\zeropoint
\dimen#1\maxdimen
- \appendtoks\doprocessinsert#1\to\@@insertionlist
+ \appendtoks\doprocessinsert#1\to\t_page_inserts_list
\fi}
-\def\synchronizeinsertions
- {\def\doprocessinsert##1{\ifvoid##1\else\insert##1{\unvbox##1}\fi}%
+\unexpanded\def\processinsertions
+ {\the\t_page_inserts_list}
+
+\unexpanded\def\synchronizeinsertions
+ {\let\doprocessinsert\page_inserts_synchronize
\processinsertions}
-%D For instance, when we postpone footnotes, we need to save
-%D some data related to the inserts. The next methods are
-%D far from ideal, but better than nothing. We save and
-%D restore box content and associated data independently.
-%D The box content is only restores when non||void.
-
-\def\backupinsertion#1%
- {\csname\string#1\endcsname}
-
-\def\installbackupinsertion#1%
- {\expandafter\newinsert\csname\string#1\endcsname
- \count\backupinsertion#1\zerocount
- \skip \backupinsertion#1\zeropoint
- \dimen\backupinsertion#1\maxdimen}
-
-\def\saveinsertionbox#1%
- {\ifdim\ht#1>\zeropoint % hm, actually unknown
- \global\setbox\backupinsertion#1\box#1%
- \else
- \global\setbox\backupinsertion#1\emptybox
+\def\page_inserts_synchronize#1%
+ {\ifvoid#1\else
+ \insert#1{\unvbox#1}%
+ \fi}
+
+%D For instance, when we postpone footnotes, we need to save some data related to
+%D the inserts. The next methods are far from ideal, but better than nothing. We
+%D save and restore box content and associated data independently. The box content
+%D is only restores when non||void.
+
+\installcorenamespace{insertionbackup}
+
+\unexpanded\def\installbackupinsertion#1%
+ {\ifcsname\??insertionbackup\string#1\endcsname \else
+ \expandafter\newinsert\csname\??insertionbackup\string#1\endcsname
+ \count\csname\??insertionbackup\string#1\endcsname\zerocount
+ \skip \csname\??insertionbackup\string#1\endcsname\zeropoint
+ \dimen\csname\??insertionbackup\string#1\endcsname\maxdimen
\fi}
-\def\restoreinsertionbox#1%
+\unexpanded\def\saveinsertionbox#1% hm, actually unknown
+ {\global\setbox\csname\??insertionbackup\string#1\endcsname
+ \ifdim\ht#1>\zeropoint\box#1\else\emptybox\fi}
+
+\unexpanded\def\restoreinsertionbox#1%
{\ifvoid\backupinsertion#1\else % if void, we keep the content
- \global\setbox#1\box\backupinsertion#1%
+ \global\setbox#1\box\csname\??insertionbackup\string#1\endcsname
\fi}
-\def\eraseinsertionbackup#1%
- {\global\setbox\backupinsertion#1\emptybox}
+\unexpanded\def\eraseinsertionbackup#1%
+ {\global\setbox\csname\??insertionbackup\string#1\endcsname\emptybox}
-\def\saveinsertiondata#1%
- {\global\skip \backupinsertion#1\skip #1%
- \global\count\backupinsertion#1\count#1%
- \global\dimen\backupinsertion#1\dimen#1}
+\unexpanded\def\saveinsertiondata#1%
+ {\global\skip \csname\??insertionbackup\string#1\endcsname\skip #1%
+ \global\count\csname\??insertionbackup\string#1\endcsname\count#1%
+ \global\dimen\csname\??insertionbackup\string#1\endcsname\dimen#1}
-\def\restoreinsertiondata#1%
- {\global\skip #1\skip \backupinsertion#1%
- \global\count#1\count\backupinsertion#1%
- \global\dimen#1\dimen\backupinsertion#1}
+\unexpanded\def\restoreinsertiondata#1%
+ {\global\skip #1\skip \csname\??insertionbackup\string#1\endcsname
+ \global\count#1\count\csname\??insertionbackup\string#1\endcsname
+ \global\dimen#1\dimen\csname\??insertionbackup\string#1\endcsname}
%D Auxiliary macros:
-\def\addinsertionheight#1\to#2%
+\unexpanded\def\addinsertionheight#1\to#2%
{\ifvoid#1\else
\advance#2 1\skip#1\relax
\advance#2 \ht #1\relax
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 78839ea70..504478e5e 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -576,7 +576,7 @@
%\writestatus{layout target}{(\the\paperwidth,\the\paperheight) -> (\the\printpaperwidth,\the\printpaperheight)}%
\page_layouts_synchronize}
-\ifx\page_paper_set_offsets\undefined
+\ifdefined\page_paper_set_offsets \else
\def\page_paper_set_offsets % will move
{\global\paperoffset\v_page_target_offset
@@ -585,8 +585,13 @@
\fi
-\ifdefined\setups \else \unexpanded\def\setups[#1]{\setdefaultpenalties} \fi % still needed?
-\ifdefined\synchronizegridsnapping \else \let\synchronizegridsnapping\relax \fi
+\ifdefined\setups \else
+ \unexpanded\def\setups[#1]{\setdefaultpenalties} % still needed?
+\fi
+
+\ifdefined\synchronizegridsnapping \else
+ \let\synchronizegridsnapping\relax
+\fi
\let\p_page_layouts_width \empty
\let\p_page_layouts_height\empty
@@ -806,7 +811,7 @@
\page_layouts_check_revert
\fi\fi\fi\fi\fi\fi}
-\def\installlayoutmethod#1#2%
+\unexpanded\def\installlayoutmethod#1#2%
{\setgvalue{\??layoutmethod#1}{#2}}
\installlayoutmethod\v!default{\page_layouts_check_default}
@@ -926,8 +931,11 @@
%D \macros
%D {adaptlayout}
+\installcorenamespace{adaptlayout}
\installcorenamespace{pageadaptations}
+\installsetuponlycommandhandler \??adaptlayout {adaptlayout}
+
\newdimen\d_page_adepts_pushed_text_height
\newdimen\d_page_adepts_pushed_footer_height
\newdimen\d_page_adepts_height
@@ -946,21 +954,28 @@
\def\page_adapts_layout_register#1#2%
{\setgvalue{\??pageadaptations#2}{\page_adapts_layout_indeed{#1}}}
+\let\p_adapts_height\zeropoint
+\let\p_adapts_lines \zerocount
+
\def\page_adapts_layout_indeed#1%
- {\getparameters[\??za][\c!height=\zeropoint,\c!lines=0,#1]%
+ {\setupcurrentadaptlayout[\c!height=\zeropoint,\c!lines=\zerocount,#1]%
\page_adepts_push
- \doifelse\@@zaheight\v!max
- {\global\d_page_adepts_height\footerheight}
- {\global\d_page_adepts_height\dimexpr
- \ifnum\@@zalines=\zerocount
- \@@zaheight
+ \edef\p_adapts_height{\adaptlayoutparameter\c!height}%
+ \edef\p_adapts_lines {\adaptlayoutparameter\c!lines}%
+ \ifx\p_adapts_height\v!max
+ \global\d_page_adepts_height\footerheight
+ \else
+ \global\d_page_adepts_height\dimexpr
+ \ifnum\p_adapts_lines=\zerocount
+ \p_adapts_height
\else
- \@@zalines\openlineheight
+ \p_adapts_lines\openlineheight
\fi
\relax
\ifdim\d_page_adepts_height>\footerheight
\global\d_page_adepts_height\footerheight
- \fi}
+ \fi
+ \fi
\global\advance\textheight \d_page_adepts_height
\global\advance\footerheight-\d_page_adepts_height
\showmessage\m!layouts1{\the\d_page_adepts_height,\the\realpageno}%
@@ -1105,33 +1120,50 @@
% #single #left #right
-\def\doifoddpageelse {\ifodd\pagenoshift\expandafter\doifoddpageelseyes \else\expandafter\doifoddpageelsenop \fi}
-\def\doifoddpageelseyes{\ifodd\realpageno \expandafter\secondoftwoarguments\else\expandafter\firstoftwoarguments \fi}
-\def\doifoddpageelsenop{\ifodd\realpageno \expandafter\firstoftwoarguments \else\expandafter\secondoftwoarguments\fi}
+\def\doifoddpageelse
+ {\ifodd\pagenoshift
+ \expandafter\page_layouts_if_odd_else_yes
+ \else
+ \expandafter\page_layouts_if_odd_else_nop
+ \fi}
+
+\def\page_layouts_if_odd_else_yes
+ {\ifodd\realpageno
+ \expandafter\secondoftwoarguments
+ \else
+ \expandafter\firstoftwoarguments
+ \fi}
+
+\def\page_layouts_if_odd_else_nop
+ {\ifodd\realpageno
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
\let\doifonevenpaginaelse\doifoddpageelse
-\def\redoifoddpageelse#1{\doifoddpageelse}
+\def\page_layouts_if_odd_else_again#1{\doifoddpageelse}
\def\doifbothsidesoverruled
{\ifdoublesided
- \expandafter\redoifoddpageelse
+ \expandafter\page_layouts_if_odd_else_again
\else
\expandafter\firstofthreearguments
\fi}
\def\doifbothsides% #1 #2 #3
{\ifdoublesided
- \expandafter\doifbothsidesindeed
+ \expandafter\page_layouts_if_both_sides
\else
\expandafter\firstofthreearguments
\fi}
-\def\doifbothsidesindeed
+\def\page_layouts_if_both_sides
{\ifsinglesided
\expandafter\firstofthreearguments
\else
- \expandafter\redoifoddpageelse
+ \expandafter\page_layouts_if_odd_else_again
\fi}
\newdimen\texthoffset
@@ -1179,12 +1211,12 @@
\def\rightorleftpageaction
{\ifdoublesided
- \expandafter\rightorleftpageactionindeed
+ \expandafter\page_layouts_right_or_left_page_action
\else
\expandafter\firstoftwoarguments
\fi}
-\def\rightorleftpageactionindeed
+\def\page_layouts_right_or_left_page_action
{\ifsinglesided
\expandafter\firstoftwoarguments
\else
diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua
index b830dbbb9..4dec0deec 100644
--- a/tex/context/base/page-lin.lua
+++ b/tex/context/base/page-lin.lua
@@ -134,6 +134,10 @@ function boxed.register(configuration)
return last
end
+function commands.registerlinenumbering(configuration)
+ context(boxed.register(configuration))
+end
+
function boxed.setup(n,configuration)
local d = data[n]
if d then
@@ -152,6 +156,8 @@ function boxed.setup(n,configuration)
return n
end
+commands.setuplinenumbering = boxed.setup
+
local function check_number(n,a,skip,sameline)
local d = data[a]
if d then
@@ -280,3 +286,6 @@ function boxed.stage_two(n,m)
end
end
end
+
+commands.linenumbersstageone = boxed.stage_one
+commands.linenumbersstagetwo = boxed.stage_two
diff --git a/tex/context/base/page-lin.mkiv b/tex/context/base/page-lin.mkiv
index 671d4c712..a26fc2c74 100644
--- a/tex/context/base/page-lin.mkiv
+++ b/tex/context/base/page-lin.mkiv
@@ -26,20 +26,6 @@
%
% we should use normal counters but then we need to sync settings
-% not yet ok, we need to give the top line a proper height
-%
-% \newbox\locallinenumberbox
-%
-% \unexpanded\def\startlocallinenumbering
-% {\setbox\locallinenumberbox\vbox\bgroup
-% \startlinenumbering}
-%
-% \unexpanded\def\stoplocallinenumbering
-% {\stoplinenumbering
-% \egroup
-% \mkdoprocessdeepboxcontents\locallinenumberbox
-% \unvbox\locallinenumberbox}
-
% some line
%
% \startlocallinenumbering
@@ -55,137 +41,96 @@
\definesystemattribute[linenumber] [public]
\definesystemattribute[linereference][public]
-\appendtoksonce \attribute\linenumberattribute \attributeunsetvalue \to \everyforgetall
-\appendtoksonce \attribute\displaymathattribute\plusone \to \everybeforedisplayformula
+\appendtoksonce
+ \attribute\linenumberattribute\attributeunsetvalue
+\to \everyforgetall
\newcount \linenumber % not used
-\newbox \linenumberscratchbox
-\newcount \linenumberchunk
-\newcount \linerefcounter
-\newconstant\linenumbernesting
+\newbox \b_page_lines_scratch
+\newcount \c_page_lines_reference
+\newconstant\c_page_lines_nesting
\newconditional\tracelinenumbering
-\def\mkprocesstextlinenumbers#1#2%
- {\setbox\linenumberscratchbox\vbox
- {\forgetall
- \offinterlineskip
- \ctxlua{nodes.lines.boxed.stage_one(\number#1,\ifcase\linenumbernesting false\else true\fi)}}% #2
- \ctxlua{nodes.lines.boxed.stage_two(\number#1,\number\linenumberscratchbox)}}% can move to lua code
-
% id nr shift width leftskip dir
-\let\makelinenumber\gobblesevenarguments
+\installcorenamespace{linenumberinginstance}
+
+\let\makelinenumber\gobblesevenarguments % used at lua end
\newconditional\boxcontentneedsprocessing
-\def\mkdoprocesspagecontents #1{\mkaddtextlinenumbers{#1}\plusone \plusone \zerocount}
-\def\mkdoprocessboxcontents #1{\mkaddtextlinenumbers{#1}\plusone \plusone \zerocount}
-\def\mkdoprocessdeepboxcontents#1{\mkaddtextlinenumbers{#1}\plusone \plusone \plusone }
-\def\mkdoprocesscolumncontents #1{\mkaddtextlinenumbers{#1}\currentcolumn\nofcolumns\zerocount}
+\def\mkdoprocesspagecontents #1{\page_lines_add_numbers_to_box{#1}\plusone \plusone \zerocount}
+\def\mkdoprocessboxcontents #1{\page_lines_add_numbers_to_box{#1}\plusone \plusone \zerocount}
+\def\mkdoprocessdeepboxcontents#1{\page_lines_add_numbers_to_box{#1}\plusone \plusone \plusone }
+\def\mkdoprocesscolumncontents #1{\page_lines_add_numbers_to_box{#1}\currentcolumn\nofcolumns\zerocount}
-\def\mklinenumberparameters
- {continue = "\linenumberparameter\c!continue",
- start = \linenumberparameter\c!start,
- step = \linenumberparameter\c!step,
- method = "\linenumberparameter\c!method",
+\def\page_lines_parameters_regular
+ {continue = "\linenumberingparameter\c!continue",
+ start = \number\linenumberingparameter\c!start,
+ step = \number\linenumberingparameter\c!step,
+ method = "\linenumberingparameter\c!method",
tag = "\currentlinenumbering"}
-\def\mklinenumberupdateparameters
- {continue = "\linenumberparameter\c!continue"}
-
-\def\mkdefinetextlinenumbering
- {\setxvalue{ln:c:\currentlinenumbering}{\number\cldcontext{nodes.lines.boxed.register({\mklinenumberparameters})}}}
+\def\page_lines_parameters_update
+ {continue = "\linenumberingparameter\c!continue"}
-\def\mkupdatetextlinenumbering
- {\ctxlua{nodes.lines.boxed.setup(\getvalue{ln:c:\currentlinenumbering},{\mklinenumberupdateparameters})}}
+\def\page_lines_start_define
+ {\setxvalue{\??linenumberinginstance\currentlinenumbering}{\ctxcommand{registerlinenumbering({\page_lines_parameters_regular})}}}
-\def\mkstarttextlinenumbering#1#2% always when assignment
- {\globallet\mkprocesspagecontents \mkdoprocesspagecontents
- \globallet\mkprocesscolumncontents\mkdoprocesscolumncontents
- \global\settrue\boxcontentneedsprocessing % see core-rul.mkiv
- \edef\currentlinenumbering{#1}%
- \ifcase#2\relax
- \mkupdatetextlinenumbering % continue
- \or
- \mkdefinetextlinenumbering % only when assignment
- \fi
- \attribute\linenumberattribute\getvalue{ln:c:\currentlinenumbering}\relax}
+\def\page_lines_start_update
+ {\ctxcommand{setuplinenumbering(\csname\??linenumberinginstance\currentlinenumbering\endcsname,{\page_lines_parameters_update})}}
-\def\mksetuptextlinenumbering
- {\ifcsname ln:c:\currentlinenumbering\endcsname
- \ctxlua{nodes.lines.boxed.setup(\getvalue{ln:c:\currentlinenumbering},{\mklinenumberparameters})}%
+\def\page_lines_setup
+ {\ifcsname \??linenumberinginstance\currentlinenumbering\endcsname
+ \ctxcommand{setuplinenumbering(\csname\??linenumberinginstance\currentlinenumbering\endcsname,{\page_lines_parameters_regular})}%
\fi}
-\def\mkstoptextlinenumbering
- {\attribute\linenumberattribute\attributeunsetvalue}
-
% we could make this a bit more efficient by putting the end reference
% in the same table as the start one but why make things complex ...
-\let\dofinishlinereference\dofinishfullreference
+\let\dofinishlinereference\dofinishfullreference % at lua end
-\def\mksomelinereference#1#2#3%
+\unexpanded\def\page_lines_some_reference#1#2#3%
{\dontleavehmode\begingroup
- \global\advance\linerefcounter\plusone
- \attribute\linereferenceattribute\linerefcounter
+ \global\advance\c_page_lines_reference\plusone
+ \attribute\linereferenceattribute\c_page_lines_reference
#3%
% for the moment we use a simple system i.e. no prefixes etc .. todo: store as number
- \expanded{\strc_references_set_named_reference{line}{#2}{conversion=\linenumberparameter\c!conversion}{\the\linerefcounter}}% kind labels userdata text
+ \normalexpanded{\strc_references_set_named_reference{line}{#2}{conversion=\linenumberingparameter\c!conversion}{\the\c_page_lines_reference}}% kind labels userdata text
\endgroup}
-\def\mkstartlinereference#1{\mksomelinereference{#1}{lr:b:#1}{}\ignorespaces}
-\def\mkstoplinereference #1{\removeunwantedspaces\mksomelinereference{#1}{lr:e:#1}{}}
+\def\page_lines_reference_start#1{\page_lines_some_reference{#1}{lr:b:#1}{}\ignorespaces}
+\def\page_lines_reference_stop #1{\removeunwantedspaces\page_lines_some_reference{#1}{lr:e:#1}{}}
+
+% \def\mklinestartreference#1[#2]{\in{#1}[lr:b:#2]} % not interfaced/ not used
+% \def\mklinestopreference #1[#2]{\in{#1}[lr:e:#2]} % not interfaced/ not used
-\def\mklinestartreference#1[#2]{\in{#1}[lr:b:#2]} % not interfaced
-\def\mklinestopreference #1[#2]{\in{#1}[lr:e:#2]} % not interfaced
+\newif\ifnumberinglines % will change
+\newif\iftypesettinglines % will change
-% high level interface
+\installcorenamespace{linenumbering}
-\newif\ifnumberinglines
-\newif\iftypesettinglines
+\installcommandhandler \??linenumbering {linenumbering} \??linenumbering
-\let\currentlinenumbering\empty
+\setnewconstant\c_page_lines_mode \plusone % 0=continue, 1=restart
+\setnewconstant\c_page_lines_location \plusone % 0=middle, 1=left, 2=right, 3=inner, 4=outer, 5=text, 6=begin, 7=end
+\setnewconstant\c_page_lines_alignment\plusfive % 0=middle, 1=left, 2=right, 5=auto
-\setnewconstant\linenumbermode \plusone % 0=continue, 1=restart
-\setnewconstant\linenumberlocation \plusone % 0=middle, 1=left, 2=right, 3=inner, 4=outer, 5=text, 6=begin, 7=end
-\setnewconstant\linenumberalignment\plusfive % 0=middle, 1=left, 2=right, 5=auto
+\newdimen\d_page_lines_width
+\newdimen\d_page_lines_distance
\newevery \beforeeverylinenumbering \relax
\newevery \aftereverylinenumbering \relax
\newevery \everylinenumber \relax
-\newdimen\linenumberwidth
-\newdimen\linenumberdistance
-
-\unexpanded\def\definelinenumbering
- {\dosingleempty\dodefinelinenumbering}
-
-\def\dodefinelinenumbering[#1]%
- {\edef\currentlinenumbering{#1}%
- \mkdefinetextlinenumbering}
-
-\unexpanded\def\setuplinenumbering
- {\dodoubleempty\dosetuplinenumbering}
-
-\def\dosetuplinenumbering[#1][#2]%
- {\ifsecondargument
- \def\currentlinenumbering{#1}%
- \getparameters[\??rn#1][#2]%
- \else
- \let\currentlinenumbering\empty
- \getparameters[\??rn][#1]%
- \fi
- \mksetuptextlinenumbering}
-
-% some day commandhandler
-
-\def\linenumberparameter#1%
- {\csname\??rn\ifcsname\??rn\currentlinenumbering#1\endcsname\currentlinenumbering\fi#1\endcsname}
+\appendtoks
+ \page_lines_setup
+\to \everysetuplinenumbering
-\unexpanded\def\dolinenumberattributes#1#2%
- {\dousestyleparameter{\linenumberparameter#1}%
- \dousecolorparameter{\linenumberparameter#2}}
+\appendtoks
+ \page_lines_start_define
+\to \everydefinelinenumbering
\setuplinenumbering
[\c!conversion=\v!numbers,
@@ -204,253 +149,270 @@
\c!align=\v!auto]
\definelinenumbering
-
-\unexpanded\def\startlinenumbering
- {\dodoubleempty\dostartlinenumbering}
+ []
% no intermediate changes in values, define a class, otherwise each range
% would need a number
% todo: text
-\expandafter\let\csname\??rn:l:\v!middle \endcsname \zerocount
-\expandafter\let\csname\??rn:l:\v!left \endcsname \plusone
-\expandafter\let\csname\??rn:l:\v!margin \endcsname \plusone
-\expandafter\let\csname\??rn:l:\v!inmargin \endcsname \plusone
-\expandafter\let\csname\??rn:l:\v!inleft \endcsname \plusone
-\expandafter\let\csname\??rn:l:\v!right \endcsname \plustwo
-\expandafter\let\csname\??rn:l:\v!inright \endcsname \plustwo
-\expandafter\let\csname\??rn:l:\v!inner \endcsname \plusthree
-\expandafter\let\csname\??rn:l:\v!outer \endcsname \plusfour
-\expandafter\let\csname\??rn:l:\v!text \endcsname \plusfive
-\expandafter\let\csname\??rn:l:\v!begin \endcsname \plussix
-\expandafter\let\csname\??rn:l:\v!end \endcsname \plusseven
-
-\expandafter\let\csname\??rn:a:\v!middle \endcsname \zerocount
-\expandafter\let\csname\??rn:a:\v!right \endcsname \plusone
-\expandafter\let\csname\??rn:a:\v!flushleft \endcsname \plusone
-\expandafter\let\csname\??rn:a:\v!left \endcsname \plustwo
-\expandafter\let\csname\??rn:a:\v!flushright\endcsname \plustwo
-\expandafter\let\csname\??rn:a:\v!auto \endcsname \plusfive
-
-\def\dostartlinenumbering[#1][#2]% todo: c!continue
+\installcorenamespace{linennumberinglocation}
+\installcorenamespace{linennumberingalternative}
+
+\expandafter\let\csname\??linennumberinglocation\v!middle \endcsname \zerocount
+\expandafter\let\csname\??linennumberinglocation\v!left \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!margin \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!inmargin \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!inleft \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!right \endcsname \plustwo
+\expandafter\let\csname\??linennumberinglocation\v!inright \endcsname \plustwo
+\expandafter\let\csname\??linennumberinglocation\v!inner \endcsname \plusthree
+\expandafter\let\csname\??linennumberinglocation\v!outer \endcsname \plusfour
+\expandafter\let\csname\??linennumberinglocation\v!text \endcsname \plusfive
+\expandafter\let\csname\??linennumberinglocation\v!begin \endcsname \plussix
+\expandafter\let\csname\??linennumberinglocation\v!end \endcsname \plusseven
+
+\expandafter\let\csname\??linennumberingalternative\v!middle \endcsname \zerocount
+\expandafter\let\csname\??linennumberingalternative\v!right \endcsname \plusone
+\expandafter\let\csname\??linennumberingalternative\v!flushleft \endcsname \plusone
+\expandafter\let\csname\??linennumberingalternative\v!left \endcsname \plustwo
+\expandafter\let\csname\??linennumberingalternative\v!flushright\endcsname \plustwo
+\expandafter\let\csname\??linennumberingalternative\v!auto \endcsname \plusfive
+
+\unexpanded\def\startlinenumbering
+ {\dodoubleempty\page_lines_start}
+
+\def\page_lines_start[#1][#2]% todo: c!continue
{\begingroup
- \linenumbermode\plusone
+ \c_page_lines_mode\plusone
\ifsecondargument
- \def\currentlinenumbering{#1}%
+ \edef\currentlinenumbering{#1}%
\doifassignmentelse{#2}
- {\getparameters[\??rn\currentlinenumbering][#2]}
+ {\setupcurrentlinenumbering[#2]}
{\doifnumberelse{#2}% downward compatible
- {\setvalue{\??rn#1\c!start}{#2}}%
+ {\setcurrentlinenumberingparameter\c!start{#2}}%
{\doif{#2}\v!continue
- {\getparameters[\??rn\currentlinenumbering][\c!continue=\v!yes]%
- \linenumbermode\zerocount}}}%
+ {\letcurrentlinenumberingparameter\c!continue\v!yes
+ \c_page_lines_mode\zerocount}}}%
\else\iffirstargument
\doifnumberelse{#1}% downward compatible
{\let\currentlinenumbering\empty
- \setvalue{\??rn\c!start}{#1}}%
+ \setcurrentlinenumberingparameter\c!start{#1}}%
{\doifelse{#1}\v!continue
{\let\currentlinenumbering\empty
- \getparameters[\??rn\currentlinenumbering][\c!continue=\v!yes]%
- \linenumbermode\zerocount}
- {\def\currentlinenumbering{#1}}}%
+ \letcurrentlinenumberingparameter\c!continue\v!yes
+ \c_page_lines_mode\zerocount}
+ {\edef\currentlinenumbering{#1}}}%
\fi\fi
- \doif{\linenumberparameter\c!continue}\v!yes
- {\linenumbermode\zerocount}%
+ \doif{\linenumberingparameter\c!continue}\v!yes
+ {\c_page_lines_mode\zerocount}%
\numberinglinestrue
\the\beforeeverylinenumbering
- \mkstarttextlinenumbering\currentlinenumbering\linenumbermode}
+ \globallet\mkprocesspagecontents \mkdoprocesspagecontents
+ \globallet\mkprocesscolumncontents\mkdoprocesscolumncontents
+ \global\settrue\boxcontentneedsprocessing % see core-rul.mkiv
+ \ifcase\c_page_lines_mode\relax
+ \page_lines_start_update % continue
+ \or
+ \page_lines_start_define % only when assignment
+ \fi
+ \attribute\linenumberattribute\getvalue{\??linenumberinginstance\currentlinenumbering}\relax}
\unexpanded\def\stoplinenumbering
- {\mkstoptextlinenumbering
+ {\attribute\linenumberattribute\attributeunsetvalue
\the\aftereverylinenumbering
\endgroup}
% number placement .. will change into (the new) margin code
-\def\mkdoinnerlinenumber{\doifoddpageelse\mkdoleftlinenumber\mkdorightlinenumber}
-\def\mkdoouterlinenumber{\doifoddpageelse\mkdorightlinenumber\mkdoleftlinenumber}
+\def\page_lines_number_inner_indeed{\doifoddpageelse\page_lines_number_left_indeed\page_lines_number_right_indeed}
+\def\page_lines_number_outer_indeed{\doifoddpageelse\page_lines_number_right_indeed\page_lines_number_left_indeed}
-\def\mkleftlinenumber
- {\ifcase\linenumberlocation
- \expandafter\mkdoleftlinenumber
+\def\page_lines_number_left
+ {\ifcase\c_page_lines_location
+ \expandafter\page_lines_number_left_indeed
\or
- \expandafter\mkdoleftlinenumber
+ \expandafter\page_lines_number_left_indeed
\or
- \expandafter\mkdoleftlinenumber
+ \expandafter\page_lines_number_left_indeed
\or
- \expandafter\mkdoinnerlinenumber
+ \expandafter\page_lines_number_inner_indeed
\or
- \expandafter\mkdoouterlinenumber
+ \expandafter\page_lines_number_outer_indeed
\or
- \expandafter\mkdotextlinenumber
+ \expandafter\page_lines_number_text_indeed
\or
- \expandafter\mkdobeginlinenumber
+ \expandafter\page_lines_number_begin_indeed
\or
- \expandafter\mkdoendlinenumber
+ \expandafter\page_lines_number_end_indeed
\fi}
-\def\mkrightlinenumber
- {\ifcase\linenumberlocation
- \expandafter\mkdorightlinenumber
+\def\page_lines_number_right
+ {\ifcase\c_page_lines_location
+ \expandafter\page_lines_number_right_indeed
\or
- \expandafter\mkdorightlinenumber
+ \expandafter\page_lines_number_right_indeed
\or
- \expandafter\mkdorightlinenumber
+ \expandafter\page_lines_number_right_indeed
\or
- \expandafter\mkdoouterlinenumber
+ \expandafter\page_lines_number_outer_indeed
\or
- \expandafter\mkdoinnerlinenumber
+ \expandafter\page_lines_number_inner_indeed
\or
- \expandafter\mkdotextlinenumber
+ \expandafter\page_lines_number_text_indeed
\or
- \expandafter\mkdoendlinenumber
+ \expandafter\page_lines_number_end_indeed
\or
- \expandafter\mkdobeginlinenumber
+ \expandafter\page_lines_number_begin_indeed
\fi}
-\newconditional\faketextlinenumber
-\newconstant \linenumberbox
-\newconstant \linenumbercolumn
-\newconstant \linenumberlastcolumn
+\newconditional\c_page_lines_fake_number
+\newconstant \b_page_lines_number
+\newconstant \c_page_lines_column
+\newconstant \c_page_lines_last_column
-\def\mkaddtextlinenumbers#1#2#3#4% box col max nesting
+\def\page_lines_add_numbers_to_box#1#2#3#4% box col max nesting
{\bgroup
- \linenumberbox #1\relax
- \linenumbercolumn #2\relax
- \linenumberlastcolumn#3\relax
- \linenumbernesting #4\relax
+ \b_page_lines_number #1\relax
+ \c_page_lines_column #2\relax
+ \c_page_lines_last_column#3\relax
+ \c_page_lines_nesting #4\relax
\fullrestoreglobalbodyfont
- \let\makelinenumber\maketextlinenumber
- \mkprocesstextlinenumbers\linenumberbox\linenumbernesting
+ \let\makelinenumber\page_lines_make_number % used at lua end
+ \setbox\b_page_lines_scratch\vbox
+ {\forgetall
+ \offinterlineskip
+ \ctxcommand{linenumbersstageone(\number\b_page_lines_number,\ifcase\c_page_lines_nesting false\else true\fi)}}%
+ \ctxcommand{linenumbersstagetwo(\number\b_page_lines_number,\number\b_page_lines_scratch)}% can move to lua code
\egroup}
-\def\maketextlinenumber#1#2%
+\let\page_lines_make_number_indeed\relax
+
+\def\page_lines_make_number#1#2%
{\edef\currentlinenumbering{#1}%
\ifcase#2\relax
- \settrue \faketextlinenumber
+ \settrue \c_page_lines_fake_number
\else
- \setfalse\faketextlinenumber
+ \setfalse\c_page_lines_fake_number
\fi
- \linenumberlocation \executeifdefined{\??rn:l:\linenumberparameter\c!location}\plusone % left
- \linenumberalignment\executeifdefined{\??rn:a:\linenumberparameter\c!align }\plusfive % auto
- \ifcase\linenumberlastcolumn\relax
- \settrue \faketextlinenumber
+ \c_page_lines_location \executeifdefined{\??linennumberinglocation \linenumberingparameter\c!location}\plusone \relax % left
+ \c_page_lines_alignment\executeifdefined{\??linennumberingalternative\linenumberingparameter\c!align }\plusfive\relax % auto
+ \ifcase\c_page_lines_last_column\relax
+ \settrue \c_page_lines_fake_number
\or
% one column
- \ifcase\linenumberlocation
- \settrue \faketextlinenumber
- % hm
+ \ifcase\c_page_lines_location
+ \settrue \c_page_lines_fake_number
+ \let\page_lines_make_number_indeed\page_lines_number_fake_indeed
\or
- \let\domakelinenumber\mkleftlinenumber
+ \let\page_lines_make_number_indeed\page_lines_number_left
\or
- \let\domakelinenumber\mkrightlinenumber
+ \let\page_lines_make_number_indeed\page_lines_number_right
\or % inner
- \let\domakelinenumber\mkdoinnerlinenumber
+ \let\page_lines_make_number_indeed\page_lines_number_inner_indeed
\or % outer
- \let\domakelinenumber\mkdoouterlinenumber
+ \let\page_lines_make_number_indeed\page_lines_number_outer_indeed
\or % text
- \let\domakelinenumber\mkdotextlinenumber
+ \let\page_lines_make_number_indeed\page_lines_number_text_indeed
\or
- \let\domakelinenumber\mkdobeginlinenumber
+ \let\page_lines_make_number_indeed\page_lines_number_begin_indeed
\or
- \let\domakelinenumber\mkdoendlinenumber
+ \let\page_lines_make_number_indeed\page_lines_number_end_indeed
\fi
- \else\ifcase\linenumbercolumn\relax
- \settrue \faketextlinenumber
+ \else\ifcase\c_page_lines_column\relax
+ \settrue \c_page_lines_fake_number
\or
- \let\domakelinenumber\mkleftlinenumber
- \ifcase\linenumberlocation\or
- \linenumberlocation\plusone
+ \let\page_lines_make_number_indeed\page_lines_number_left
+ \ifcase\c_page_lines_location\or
+ \c_page_lines_location\plusone
\or
- \linenumberlocation\plustwo
+ \c_page_lines_location\plustwo
\else
- \linenumberlocation\plusone
+ \c_page_lines_location\plusone
\or
- \linenumberlocation\plusone
+ \c_page_lines_location\plusone
\or
- \linenumberlocation\plusone
+ \c_page_lines_location\plusone
\or
- \linenumberlocation\plusone % todo
+ \c_page_lines_location\plusone % todo
\or
- \linenumberlocation\plusone % todo
+ \c_page_lines_location\plusone % todo
\fi
\else
- \let\domakelinenumber\mkrightlinenumber
- \ifcase\linenumberlocation\or
- \linenumberlocation\plustwo
+ \let\page_lines_make_number_indeed\page_lines_number_right
+ \ifcase\c_page_lines_location\or
+ \c_page_lines_location\plustwo
\or
- \linenumberlocation\plusone
+ \c_page_lines_location\plusone
\or
- \linenumberlocation\plustwo
+ \c_page_lines_location\plustwo
\or
- \linenumberlocation\plustwo
+ \c_page_lines_location\plustwo
\or
- \linenumberlocation\plustwo % todo
+ \c_page_lines_location\plustwo % todo
\or
- \linenumberlocation\plustwo % todo
+ \c_page_lines_location\plustwo % todo
\fi
\fi\fi
- \domakelinenumber{#1}}
+ \page_lines_make_number_indeed{#1}}
-\def\mkdotextlinenumber #1#2#3#4#5#6% beware, one needs so compensate for this in the width !
- {\hbox{\dosomelinenumber{#1}{2}{#2}{#5}\hskip#3\scaledpoint}}
+\let\page_lines_number_fake_indeed\gobblesixarguments % needs checking
-\def\mkdotextlinenumber #1#2#3#4#5#6% beware, one needs so compensate for this in the width !
- {\hbox{\dosomelinenumber{#1}{2}{#2}{#5}\hskip#3\scaledpoint}}
+\def\page_lines_number_text_indeed#1#2#3#4#5#6% beware, one needs so compensate for this in the \hsize
+ {\hbox{\page_lines_number_construct{#1}{2}{#2}{#5}\hskip#3\scaledpoint}}
-\def\mkdoleftlinenumber #1#2#3#4#5#6%
+\def\page_lines_number_left_indeed#1#2#3#4#5#6%
{\naturalhbox to \zeropoint
{\ifcase\istltdir#6\else \hskip-#4\scaledpoint \fi
- \llap{\dosomelinenumber{#1}{2}{#2}{#5}\kern#3\scaledpoint}}}
+ \llap{\page_lines_number_construct{#1}{2}{#2}{#5}\kern#3\scaledpoint}}}
-\def\mkdorightlinenumber#1#2#3#4#5#6%
+\def\page_lines_number_right_indeed#1#2#3#4#5#6%
{\naturalhbox to \zeropoint
{\ifcase\istltdir#6\else \hskip-#4\scaledpoint \fi
- \rlap{\hskip#4\scaledpoint\hskip#3\scaledpoint\dosomelinenumber{#1}{1}{#2}{#5}}}}
+ \rlap{\hskip\dimexpr#4\scaledpoint+#3\scaledpoint\relax\page_lines_number_construct{#1}{1}{#2}{#5}}}}
-\def\mkdobeginlinenumber #1#2#3#4#5#6%
+\def\page_lines_number_begin_indeed#1#2#3#4#5#6%
{\ifcase\istltdir#6\relax
- \linenumberlocation\plusone
- \expandafter\mkdoleftlinenumber
+ \c_page_lines_location\plusone
+ \expandafter\page_lines_number_left_indeed
\else
- \linenumberlocation\plustwo
- \expandafter\mkdorightlinenumber
+ \c_page_lines_location\plustwo
+ \expandafter\page_lines_number_left_indeed
\fi{#1}{#2}{#3}{#4}{#5}{#6}}
-\def\mkdoendlinenumber#1#2#3#4#5#6%
+\def\page_lines_number_end_indeed#1#2#3#4#5#6%
{\ifcase\istltdir#6\relax
- \linenumberlocation\plustwo
- \expandafter\mkdorightlinenumber
+ \c_page_lines_location\plustwo
+ \expandafter\page_lines_number_left_indeed
\else
- \linenumberlocation\plusone
- \expandafter\mkdoleftlinenumber
+ \c_page_lines_location\plusone
+ \expandafter\page_lines_number_left_indeed
\fi{#1}{#2}{#3}{#4}{#5}{#6}}
-\def\dosomelinenumber#1#2#3#4% tag 1=left|2=right linenumber leftskip
+\def\page_lines_number_construct#1#2#3#4% tag 1=left|2=right linenumber leftskip
{\begingroup
\def\currentlinenumbering{#1}%
\def\linenumber{#3}% unsafe
- \doifelse{\linenumberparameter\c!width}\v!margin
- {\linenumberwidth\leftmarginwidth}
- {\linenumberwidth\linenumberparameter\c!width}%
- \linenumberdistance\linenumberparameter\c!distance\relax
- \ifcase#2\relax\or\hskip\linenumberdistance\fi\relax
- \ifnum\linenumberlocation=\plusfive
- \scratchdimen\dimexpr#4\scaledpoint-\linenumberdistance\relax
- \linenumberlocation\plusone
+ \doifelse{\linenumberingparameter\c!width}\v!margin
+ {\d_page_lines_width\leftmarginwidth}
+ {\d_page_lines_width\linenumberingparameter\c!width}%
+ \d_page_lines_distance\linenumberingparameter\c!distance\relax
+ \ifcase#2\relax\or\hskip\d_page_lines_distance\fi\relax
+ \ifnum\c_page_lines_location=\plusfive
+ \scratchdimen\dimexpr#4\scaledpoint-\d_page_lines_distance\relax
+ \c_page_lines_location\plusone
\else
\scratchdimen\zeropoint
\fi
- \ifcase\linenumberalignment
- \linenumberlocation\zerocount % middle
+ \ifcase\c_page_lines_alignment
+ \c_page_lines_location\zerocount % middle
\or
- \linenumberlocation\plusone % left
+ \c_page_lines_location\plusone % left
\or
- \linenumberlocation\plustwo % right
+ \c_page_lines_location\plustwo % right
\fi
- \ifconditional\tracelinenumbering\ruledhbox\else\hbox\fi to \linenumberwidth
- {\ifcase\linenumberlocation
+ \ifconditional\tracelinenumbering\ruledhbox\else\hbox\fi to \d_page_lines_width
+ {\ifcase\c_page_lines_location
\hss % middle
\or
% left
@@ -461,16 +423,16 @@
\or
\doifoddpageelse\hss\relax % outer
\fi
- \ifconditional\faketextlinenumber
+ \ifconditional\c_page_lines_fake_number
% we need to reserve space
\else
- \dolinenumberattributes\c!style\c!color
- \linenumberparameter\c!command
- {\linenumberparameter\c!left
- \convertnumber{\linenumberparameter\c!conversion}{#3}%
- \linenumberparameter\c!right}%
+ \uselinenumberingstyleandcolor\c!style\c!color
+ \linenumberingparameter\c!command
+ {\linenumberingparameter\c!left
+ \convertnumber{\linenumberingparameter\c!conversion}{#3}%
+ \linenumberingparameter\c!right}%
\fi
- \ifcase\linenumberlocation
+ \ifcase\c_page_lines_location
\hss % middle
\or
\hss % left
@@ -481,53 +443,60 @@
\or
\doifoddpageelse\relax\hss % outer
\fi}%
- \ifcase#2\relax\or\or\hskip\linenumberdistance\fi\relax
- \hskip-\scratchdimen
+ \ifcase#2\relax
+ \hskip-\scratchdimen
+ \or
+ \hskip-\scratchdimen
+ \or
+ \hskip\dimexpr\d_page_lines_distance-\scratchdimen\relax
+ \fi
+ \relax
\the\everylinenumber
\endgroup}
-% left right inner outer
-
-% align: \alignedline\@@rnalign\v!right{\box0\hskip\@@rndistance}
-
% referencing
-\unexpanded\def\someline [#1]{\mkstartlinereference{#1}\mkstoplinereference{#1}} % was just a def
-\unexpanded\def\startline[#1]{\mkstartlinereference{#1}}
-\unexpanded\def\stopline [#1]{\mkstoplinereference {#1}}
+\unexpanded\def\someline [#1]{\page_lines_reference_start{#1}\page_lines_reference_stop{#1}} % was just a def
+\unexpanded\def\startline[#1]{\page_lines_reference_start{#1}}
+\unexpanded\def\stopline [#1]{\page_lines_reference_stop {#1}}
-\def\mkshowstartlinereference#1%
+\def\page_lines_reference_show_start#1%
{\ifconditional\tracelinenumbering
\setbox\scratchbox\hbox{\llap
{\vrule\!!width\onepoint\!!depth\strutdp\!!height.8\strutht\raise.85\strutht\hbox{\llap{\tt\txx#1}}}}%
- \smashbox\scratchbox\box\scratchbox
+ \smashbox\scratchbox
+ \box\scratchbox
\fi}
-\def\mkshowstoplinereference#1%
+\def\page_lines_reference_show_stop#1%
{\ifconditional\tracelinenumbering
\setbox\scratchbox\hbox{\rlap
{\raise.85\strutht\hbox{\rlap{\tt\txx#1}}\vrule\!!width\onepoint\!!depth\strutdp\!!height.8\strutht}}%
- \smashbox\scratchbox\box\scratchbox
+ \smashbox\scratchbox
+ \box\scratchbox
\fi}
-\def\mkstartlinereference#1{\mksomelinereference{#1}{lr:b:#1}{\mkshowstartlinereference{#1}}\ignorespaces}
-\def\mkstoplinereference #1{\removeunwantedspaces\mksomelinereference{#1}{lr:e:#1}{\mkshowstoplinereference{#1}}}
+\def\page_lines_reference_start#1{\page_lines_some_reference{#1}{lr:b:#1}{\page_lines_reference_show_start{#1}}\ignorespaces}
+\def\page_lines_reference_stop #1{\removeunwantedspaces\page_lines_some_reference{#1}{lr:e:#1}{\page_lines_reference_show_stop{#1}}}
% eventually we will do this in lua
\def\currentreferencelinenumber{\ctxcommand{filterreference("linenumber")}}
-\def\doifelsesamelinereference#1#2#3%
+\let\m_page_lines_from\empty
+\let\m_page_lines_to \empty
+
+\unexpanded\def\doifelsesamelinereference#1#2#3%
{\doifreferencefoundelse{lr:b:#1}
- {\edef\fline{\currentreferencelinenumber}%
+ {\edef\m_page_lines_from{\currentreferencelinenumber}%
\doifreferencefoundelse{lr:e:#1}
- {\edef\tline{\currentreferencelinenumber}%
- %[\fline,\tline]
- \ifx\fline\tline#2\else#3\fi}
+ {\edef\m_page_lines_to{\currentreferencelinenumber}%
+ %[\m_page_lines_from,\m_page_lines_to]
+ \ifx\m_page_lines_from\m_page_lines_to#2\else#3\fi}
{#2}}
{#2}}
-\def\inline#1[#2]%
+\unexpanded\def\inline#1[#2]%
{\doifelsenothing{#1}
{\doifelsesamelinereference{#2}
{\in{\leftlabeltext\v!line}{\rightlabeltext\v!line}[lr:b:#2]}
@@ -536,7 +505,7 @@
{\in{#1}[lr:b:#2]}
{\in{#1}[lr:b:#2]--\in[lr:e:#2]}}}
-\def\inlinerange[#1]%
+\unexpanded\def\inlinerange[#1]%
{\doifelsesamelinereference{#1}
{\in[lr:b:#1]}
{\in[lr:b:#1]--\in[lr:e:#1]}}
diff --git a/tex/context/base/page-mbk.mkvi b/tex/context/base/page-mbk.mkvi
index eb8061bf3..9e3e57193 100644
--- a/tex/context/base/page-mbk.mkvi
+++ b/tex/context/base/page-mbk.mkvi
@@ -220,9 +220,9 @@
\box\floatbox
\filbreak}%
\ifdim\ht\b_page_margin_blocks>\textheight
- % \dosavefloatinfo % no saving done anyway
+ % page_floats_report_saved % no saving done anyway
\else
- \doinsertfloatinfo
+ \page_floats_report_total
\fi}
\def\page_margin_blocks_process_float_nop
diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv
index 3792f06ee..e22ecd0a3 100644
--- a/tex/context/base/page-mul.mkiv
+++ b/tex/context/base/page-mul.mkiv
@@ -11,9 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% SEE PAGE-MUL-NEW.MKIV
-
-% BEWARE: TEMPORARY ISSUES WITH VSIZE AND HSIZE BUT WILL BE REDONE
+% !!! there are some issues with hsize an vsize as well as flushing
+% !!! floats but this module will be redone anyway
\writestatus{loading}{ConTeXt Page Macros / Simple Multi Column}
@@ -304,7 +303,7 @@
%\setcolumntextheight\relax
\widowpenalty\zerocount % is gewoon beter
\clubpenalty \zerocount % zeker bij grids
- \dopushcolumnfloats
+ \page_floats_column_push_saved
\dimen0\dimexpr\pagetotal+\parskip+\openlineheight\relax
\ifdim\dimen0<\pagegoal
\allowbreak
@@ -389,7 +388,7 @@
\synchronizeoutput % new may 2004 / we need to: \pagegoal\vsize
\checkendcolumnfootnotes
\dosomebreak\allowbreak
- \dopopcolumnfloats}
+ \page_floats_column_pop_saved}
%D Because some initializations happen three times, we defined a macro for
%D them. Erasing \type{\everypar} is needed because we don't want anything
@@ -1084,21 +1083,24 @@
%D
%D When all those floats are flushed, we switch to the local flushing routine.
-\def\dopushcolumnfloats
- {\ifsomefloatwaiting
- \showmessage\m!columns6{\the\savednoffloats}%
- \global\setbox\savedfloatlist\box\floatlist
- \xdef\dopopcolumnfloats
- {\global\savednoffloats\the\savednoffloats
- \global\setbox\floatlist\box\savedfloatlist
- \global\noexpand\somefloatwaitingtrue}%
- \global\savednoffloats\zerocount
- \global\somefloatwaitingfalse
- \else
- \global\let\dopopcolumnfloats\relax
- \fi}
-
-\let\dopopcolumnfloats\relax
+% \newbox \floatlist
+% \newbox \savedfloatlist
+%
+% \def\page_floats_column_push_saved
+% {\ifconditional\c_page_floats_some_waiting
+% \showmessage\m!columns6{\the\savednoffloats}%
+% \global\setbox\savedfloatlist\box\floatlist
+% \xdef\page_floats_column_pop_saved
+% {\global\savednoffloats\the\savednoffloats
+% \global\setbox\floatlist\box\savedfloatlist
+% \global\noexpand\settrue\c_page_floats_some_waiting}%
+% \global\savednoffloats\zerocount
+% \global\setfalse\c_page_floats_some_waiting
+% \else
+% \global\let\page_floats_column_pop_saved\relax
+% \fi}
+%
+% \let\page_floats_column_pop_saved\relax
% \def\setcolumnfloats % messy as it adapts everypar
% {\xdef\globalsavednoffloats{\the\savednoffloats}%
@@ -1212,25 +1214,25 @@
\def\docolumnroomfloat
{\ifpostponecolumnfloats
- \global\roomforfloatfalse
- \else\ifnofloatpermitted
- \global\roomforfloatfalse
+ \global\setfalse\c_page_floats_room
+ \else\ifconditional\c_page_floats_not_permitted
+ \global\setfalse\c_page_floats_room
\else
\bgroup
\getcolumnstatus\column\count255\total\dimen0\goal\dimen2\\%
- \dofloatsgetinfo\s!text
+ \page_floats_get_info\s!text
\setbox\scratchbox\vbox % tricky met objecten ?
{\blank[\rootfloatparameter\c!spacebefore]
\snaptogrid\vbox{\vskip\floatheight}}% copy?
\advance\dimen0\dimexpr\ht\scratchbox+2\openlineheight+.5\lineheight\relax\relax % needed because goal a bit higher
\ifdim\dimen0>\dimen2
- \global\roomforfloatfalse
+ \global\setfalse\c_page_floats_room
\else
- \global\roomforfloattrue
+ \global\settrue\c_page_floats_room
\fi
\ifdim\floatwidth>\hsize
\showmessage\m!columns{11}\empty
- \global\roomforfloatfalse
+ \global\setfalse\c_page_floats_room
\fi
\egroup
\fi\fi}
@@ -1241,7 +1243,7 @@
\newif\ifflushingcolumnfloats \flushingcolumnfloatstrue
\def\doflushcolumnfloat
- {\ifpostponecolumnfloats\else\ifflushingcolumnfloats\ifsomefloatwaiting
+ {\ifpostponecolumnfloats\else\ifflushingcolumnfloats\ifconditional\c_page_floats_some_waiting
\doflushcolumnfloatindeed
\fi\fi\fi}
@@ -1251,7 +1253,7 @@
\let\doflushcolumnfloat\relax
\getcolumnstatus\column\mofcolumns\total\dimen0\goal\dimen2\\%
\ifdim\dimen0>\zeropoint
- \dofloatsgetinfo\s!text
+ \page_floats_get_info\s!text
\ifdim\floatwidth>\hsize
% dropped ?
\else
@@ -1263,7 +1265,7 @@
\ifnum\mofcolumns<\nofcolumns
\advance\mofcolumns \plusone
\ifdim\ht\currenttopcolumnbox=\zeropoint
- \dofloatsflush\s!text{1}%
+ \page_floats_flush\s!text\plusone
\global\setbox\currenttopcolumnbox\vbox
{\snaptogrid\vbox{\box\floatbox}
\whitespace % nodig ?
@@ -1287,7 +1289,7 @@
\blank[\rootfloatparameter\c!spacebefore]
\nobreak
\fi
- \dofloatsflush\s!text{1}%
+ \page_floats_flush\s!text\plusone
\page_otr_command_flush_float_box
\blank[\rootfloatparameter\c!spaceafter]
\fi
@@ -1312,7 +1314,7 @@
{\ifpostponecolumnfloats\else
\bgroup
\forgetall
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\dimen8\zeropoint
\dimen4\zeropoint
\count0\zerocount % count0 can be used local
@@ -1326,7 +1328,7 @@
\whitespace % nodig ?
\blank[\rootfloatparameter\c!spaceafter]}%
\else
- \dofloatsgetinfo\s!text
+ \page_floats_get_info\s!text
\ifdim\floatwidth>\hsize
\dimen0\dimexpr\floatwidth+\intercolumnwidth+.5pt\relax
\dimen2\dimexpr\hsize +\intercolumnwidth+.5pt\relax
@@ -1337,7 +1339,7 @@
\count0\zerocount
\else
\dimen0\dimexpr\count0\hsize+\count0\intercolumnwidth-\intercolumnwidth\relax
- \dofloatsflush\s!text{1}%
+ \page_floats_flush\s!text\plusone
\ifdim\floatwidth>\finalcolumntextwidth % better somewhere else too
\global\setbox\floatbox\hbox to \finalcolumntextwidth{\hss\box\floatbox\hss}%
\fi % otherwise the graphic may disappear
@@ -1350,7 +1352,7 @@
\fi
\showmessage\m!columns{13}\empty
\else
- \dofloatsflush\s!text{1}%
+ \page_floats_flush\s!text\plusone
\ifdim\floatwidth>\finalcolumntextwidth % better somewhere else too
\global\setbox\floatbox\hbox to \finalcolumntextwidth{\hss\box\floatbox\hss}%
\fi % otherwise the graphic may disappear
@@ -1386,11 +1388,11 @@
\def\insertcolumnfloats
{\doloop
- {\ifsomefloatwaiting
+ {\ifconditional\c_page_floats_some_waiting
\bgroup
\forgetall
% no check for width
- \dogetfloat
+ \page_floats_get
\blank[\rootfloatparameter\c!spacebefore]
\snaptogrid\vbox{\copy\floatbox}
\blank[\rootfloatparameter\c!spaceafter]
diff --git a/tex/context/base/page-not.mkiv b/tex/context/base/page-not.mkiv
index 06e2f3875..ddc9b1522 100644
--- a/tex/context/base/page-not.mkiv
+++ b/tex/context/base/page-not.mkiv
@@ -13,12 +13,12 @@
\writestatus{loading}{ConTeXt Page Macros / Footnotes}
-%D Terrible hacks: we need to share save/restore
+%D This is an old mechanism that will be replaced as soon as the multicolumn
+%D code is redone.
-%D We've moved some footnote handling to a separate page
-%D module. The macros below are used in the single and multi
-%D column page handlers and permit mixed usage of column and
-%D page notes.
+%D We've moved some footnote handling to a separate page module. The macros below
+%D are used in the single and multi column page handlers and permit mixed usage of
+%D column and page notes.
\unprotect
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index 89fd7d4a8..025a9aa1a 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -210,7 +210,7 @@
\unexpanded\def\page_one_command_set_top_insertions
{\bgroup
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\noffloatinserts\zerocount
\let\totaltopinserted\!!zeropoint
\page_one_command_set_top_insertions_indeed
@@ -229,23 +229,23 @@
\def\page_one_command_set_top_insertions_indeed
{\ifnum\noffloatinserts<\noftopfloats
- \dogetfloat
+ \page_floats_get
\page_one_prepare_top_float
\ifdim\topinserted<\textheight\relax
\xdef\totaltopinserted{\the\topinserted}%
\page_one_insert_top_float
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\advance\noffloatinserts \plusone
\else
\noffloatinserts\noftopfloats\relax
\fi
- \dofloatflushedinfo
+ \page_floats_report_flushed
\else
- \doresavefloat
+ \page_floats_resave\s!text
\noffloatinserts\noftopfloats\relax
\fi
\else
- \ifsomefloatwaiting
+ \ifcoditional\c_page_floats_some_waiting
\showmessage\m!floatblocks6{\the\noftopfloats}%
\fi
\let\page_one_command_set_top_insertions_indeed\relax
@@ -254,7 +254,7 @@
\unexpanded\def\page_one_command_set_bottom_insertions
{\bgroup
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\noffloatinserts\zerocount
\page_one_command_set_bottom_insertions_indeed
\fi
@@ -262,7 +262,7 @@
\def\page_one_command_set_bottom_insertions_indeed
{\ifnum\noffloatinserts<\nofbotfloats\relax
- \dogetfloat
+ \page_floats_get
\global\advance\botinserted \ht\floatbox\relax
\global\advance\botinserted \dp\floatbox\relax
\global\advance\botinserted \floattopskip\relax
@@ -271,19 +271,19 @@
{\forgetall
\blank[\rootfloatparameter\c!spacebefore]%
\page_otr_command_flush_float_box}%
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\advance\noffloatinserts \plusone
\else
\noffloatinserts\nofbotfloats
\fi
- \dofloatflushedinfo
+ \page_floats_report_flushed
\else
- \doresavefloat
+ \page_floats_resave\s!text
\noffloatinserts\nofbotfloats\relax
\fi
- \global\nofloatpermittedtrue % vgl topfloats s!
+ \global\settrue\c_page_floats_not_permitted % vgl topfloats s!
\else
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\showmessage\m!floatblocks7{\the\nofbotfloats}%
\fi
\let\page_one_command_set_bottom_insertions_indeed\relax
@@ -324,31 +324,31 @@
\fi
\fi
\global\botinserted\zeropoint
- \global\nofloatpermittedfalse}
+ \global\setfalse\c_page_floats_not_permitted}
\unexpanded\def\page_one_command_flush_floats
- {\global\flushingfloatstrue
- \ifsomefloatwaiting
+ {\global\settrue\c_page_floats_flushing
+ \ifconditional\c_page_floats_some_waiting
\par
% if kept, then option and definitely off in gridmode ! ! ! !
% \ifvmode \prevdepth\maxdimen \fi % prevents whitespace; problematic in icare tests
\page_one_command_flush_floats_indeed
\fi
\global\savednoffloats\zerocount
- \global\somefloatwaitingfalse
- \global\flushingfloatsfalse}
+ \global\setfalse\c_page_floats_some_waiting
+ \global\setfalse\c_page_floats_flushing}
\unexpanded\def\page_one_command_flush_float_box
- {\ifcenterfloatbox \ifdim\wd\floatbox<\hsize
+ {\ifconditional\c_page_floats_center_box \ifdim\wd\floatbox<\hsize
\global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
\fi \fi
\snaptogrid\hbox{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}} % was copy
\def\page_one_command_flush_floats_indeed % much in common with OTRSET
- {\ifsomefloatwaiting
- \ifpackflushedfloats
- \centerfloatboxfalse % not needed as we do call directly
- \dofloatscollect\s!text{\hsize}{1em}%
+ {\ifconditional\c_page_floats_some_waiting
+ \ifconditional\c_page_floats_pack_flushed
+ \setfalse\c_page_floats_center_box % not needed as we do call directly
+ \page_floats_collect\s!text\hsize\emwidth
%% no longer (interferes with footnotes):
%%
%% \page_one_command_set_vsize % test 2011.06.24.001
@@ -357,9 +357,9 @@
{\hfil
\dorecurse\nofcollectedfloats
{\ifcase\columndirection % nog document wide
- \dofloatsflush\s!text{1}%
+ \page_floats_flush\s!text\plusone
\else
- \dofloatsflush\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}%
+ \page_floats_flush\s!text{\the\numexpr\nofcollectedfloats-\recurselevel+1\relax}%
\fi
\ifdim\wd\floatbox>\makeupwidth % \hsize
\hbox to \makeupwidth{\hss\box\floatbox\hss}%
@@ -371,7 +371,7 @@
\fi}%
\hfil}%
\else
- \dogetfloat
+ \page_floats_get
\fi
% there is a chance that due to rounding errors, the float
% fits on a page where it was first rejected, in which case
@@ -394,8 +394,8 @@
\fi}
\unexpanded\def\page_one_command_check_if_float_fits
- {\ifnofloatpermitted
- \global\roomforfloatfalse
+ {\ifconditional\c_page_floats_not_permitted
+ \global\setfalse\c_page_floats_room
\else
% new per 31/5/2004, should be an option, only one column mode
\begingroup
@@ -419,19 +419,19 @@
\fi
\relax % really needed ! ! ! !
\ifdim\dimen0>\dimen2
- \global\roomforfloatfalse
+ \global\setfalse\c_page_floats_room
\else
- \global\roomforfloattrue
+ \global\settrue\c_page_floats_room
\fi
\fi}
\unexpanded\def\page_one_command_flush_saved_floats
{\global\topinserted\zeropoint
\global\botinserted\zeropoint
- \ifflushingfloats \else
+ \ifconditional\c_page_floats_flushing \else
\page_one_command_set_top_insertions
\page_one_command_set_bottom_insertions
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\doif{\rootfloatparameter\c!cache}\v!no\page_one_command_flush_floats % could be _otr_
\else\ifconditional\c_page_margin_blocks_present
\page_one_command_flush_floats
@@ -443,7 +443,7 @@
\baselinecorrection
%\fi
\doplacefloatbox
- \doinsertfloatinfo
+ \page_floats_report_total
\dohandlenextfloatindent}
\def\page_one_place_float_force
@@ -469,10 +469,10 @@
%def\page_one_place_float_margin {\page_one_place_float_side_indeed\page_sides_process_float_margin\nonoindentation} % wil be overloaded
\def\page_one_place_float_margin {\page_margin_blocks_process_float}
-\def\page_one_place_float_page {\dofloatssavepagefloat \s!page \floatlocationmethod}
-\def\page_one_place_float_leftpage {\dofloatssavepagefloat \s!leftpage \floatlocationmethod}
-\def\page_one_place_float_rightpage {\dofloatssavepagefloat \s!rightpage\floatlocationmethod}
-\def\page_one_place_float_somewhere {\dofloatssavesomewherefloat\s!somewhere\floatlocationmethod}
+\def\page_one_place_float_page {\page_floats_save_page_float \s!page \floatlocationmethod}
+\def\page_one_place_float_leftpage {\page_floats_save_page_float \s!leftpage \floatlocationmethod}
+\def\page_one_place_float_rightpage {\page_floats_save_page_float \s!rightpage\floatlocationmethod}
+\def\page_one_place_float_somewhere {\page_floats_save_somewhere_float\s!somewhere\floatlocationmethod}
\def\page_one_place_float_here {\page_one_place_float_otherwise_here}
\def\page_one_place_float_auto {\page_one_place_float_otherwise}
@@ -488,38 +488,41 @@
{\doifinsetelse\v!always\floatlocationmethod
{\page[\v!preference]%
\page_otr_command_check_if_float_fits
- \ifroomforfloat
+ \ifconditional\c_page_floats_room
\page_one_place_float_here_indeed
\else
\showmessage\m!floatblocks9\empty
- \doreversesavefloat
+ \page_floats_resave\s!text
\fi}
- {\ifsomefloatwaiting
- \dosavefloat
+ {\ifconditional\c_page_floats_some_waiting
+ \page_floats_save\s!text
+ \nonoindentation
\else
\page[\v!preference]%
\page_otr_command_check_if_float_fits
- \ifroomforfloat
+ \ifconditional\c_page_floats_room
\page_one_place_float_here_indeed
\else
- \dosavefloat
+ \page_floats_save\s!text
+ \nonoindentation
\fi
\fi}}
\def\page_one_place_float_otherwise_else
{\doifinsetelse\v!always\floatlocationmethod
{\page_otr_command_check_if_float_fits
- \ifroomforfloat
+ \ifconditional\c_page_floats_room
\page_one_place_float_auto_top_bottom
\else
\showmessage\m!floatblocks9\empty
- \doreversesavefloat
+ \page_floats_resave\s!text
\fi}
{\page_otr_command_check_if_float_fits
- \ifroomforfloat
+ \ifconditional\c_page_floats_room
\page_one_place_float_auto_top_bottom
\else
- \dosavefloat
+ \page_floats_save\s!text
+ \nonoindentation
\fi}}
\def\floatautofactor{.5}
@@ -544,7 +547,7 @@
\def\page_one_place_float_top_indeed % maybe remember last beforeskip
{\page_one_prepare_top_float
\page_one_insert_top_float
- \doinsertfloatinfo}
+ \page_floats_report_total}
\def\page_one_place_float_bottom_indeed
{\global\advance\botinserted\dimexpr\ht\floatbox+\dp\floatbox+\floattopskip\relax
@@ -552,15 +555,15 @@
{\forgetall
\blank[\rootfloatparameter\c!spacebefore]%
\page_otr_command_flush_float_box}%
- %\global\nofloatpermittedtrue
- \doinsertfloatinfo}
+ %\global\settrue\c_page_floats_not_permitted
+ \page_floats_report_total}
\def\page_one_place_float_face % links, rechts, midden, hoog, midden, laag
{%\checkwaitingfloats{#1}%
\startopposite
\page_otr_command_flush_float_box
\stopopposite
- }%\doinsertfloatinfo}
+ }%\page_floats_report_total}
\unexpanded\def\page_one_command_flush_side_floats
{\page_sides_flush_floats}
diff --git a/tex/context/base/page-plg.mkiv b/tex/context/base/page-plg.mkiv
index 004b9204d..ec61da1d2 100644
--- a/tex/context/base/page-plg.mkiv
+++ b/tex/context/base/page-plg.mkiv
@@ -11,10 +11,11 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% \ifx\pageareabox\undefined \else \endinput \fi
-
\writestatus{loading}{ConTeXt Page Macros / Extra Page Building}
+%D This still needs some work, especially the dimensions need to be
+%D checked cq.\ optimized. Beware: method has become alternative!
+
%D This feature has been present for a while but has never been
%D exploited: pluggable pagebuilders. The next example code
%D demonstrates the application of one such a plug-in. This variant
@@ -31,6 +32,8 @@
%D \startpagelayout[leftpage]
%D \setupTABLE[offset=overlay]
%D \setupTABLE[c][1][width=\leftmarginwidth]
+%D \setupTABLE[c][2][width=\textwidth]
+%D \setupTABLE[c][3][width=\rightmarginwidth]
%D \bTABLE
%D \bTR
%D \bTD[nx=3,background=color,backgroundcolor=green]
@@ -43,7 +46,7 @@
%D \eTR
%D \bTR
%D \bTD[nx=3,offset=overlay]
-%D {\bTABLE[width=.5\hsize]
+%D {\bTABLE
%D \bTR
%D \bTD \pagearea[footer][text][left] \eTD
%D \bTD \pagearea[bottom][text][left] \eTD
@@ -56,7 +59,9 @@
%D
%D \startpagelayout[rightpage]
%D \setupTABLE[offset=overlay]
-%D \setupTABLE[c][1][width=\rightmarginwidth]
+%D \setupTABLE[c][1][width=\leftmarginwidth]
+%D \setupTABLE[c][2][width=\textwidth]
+%D \setupTABLE[c][3][width=\rightmarginwidth]
%D \bTABLE
%D \bTR
%D \bTD[nx=3] \pagearea[header][text][middle] \eTD
@@ -67,7 +72,7 @@
%D \eTR
%D \bTR
%D \bTD[nx=3,offset=overlay]
-%D {\bTABLE[width=.5\hsize]
+%D {\bTABLE
%D \bTR
%D \bTD \pagearea[bottom][text][right] \eTD
%D \bTD \pagearea[footer][text][right] \eTD
@@ -80,12 +85,9 @@
%D
%D \setupcolors[state=start]
%D
-%D \setupbackgrounds[text][background=color,backgroundcolor=blue]
-%D \setupbackgrounds[header][text][background=color,backgroundcolor=red]
-%D
%D \setuppagenumbering[alternative=doublesided,location=]
%D
-%D \setuplayout[method=makeup]
+%D \setuplayout[alternative=makeup]
%D
%D \definetextbackground
%D [test]
@@ -110,6 +112,8 @@
\unprotect
+\installcorenamespace{layoutmakeupalternative}
+
\def\page_boxes_construct_content_makeup#1#2#3% targetbox flusher box
{\setbox#1\hbox
{\vbox to \textheight
@@ -125,65 +129,76 @@
\dp#1\zeropoint
\hsize\paperwidth
\vsize\paperheight
- \setbox#1\vbox{\csname\??layoutmethod\doifbothsidesoverruled\v!page\v!rightpage\v!leftpage\endcsname}%
+ \setbox#1\vbox{\csname\??layoutmakeupalternative\doifbothsidesoverruled\v!page\v!rightpage\v!leftpage\endcsname}%
\wd#1\paperwidth
\ht#1\paperheight
\dp#1\zeropoint}
\installlayoutalternative\v!makeup{\page_boxes_construct_content_makeup}
-\newbox\pageareabox
+\newbox\b_page_area
\unexpanded\def\pagearea
{\dotripleempty\page_area}
-\def\page_area[#1][#2][#3]%
+\def\page_area
{\ifthirdargument
- \doifelse{#3}\v!left
- {\page_area_indeed{#1}{#2}\c!lefttext}
- {\doifelse{#3}\v!right
- {\page_area_indeed{#1}{#2}\c!righttext}
- {\page_area_indeed{#1}{#2}\c!middletext}}%
+ \expandafter\page_area_three
\else\ifsecondargument
- \doifbothsidesoverruled
- {\page_area_indeed{#1}{#2}\c!righttext}
- {\page_area_indeed{#1}{#2}\c!righttext}
- {\page_area_indeed{#1}{#2}\c!lefttext }%
+ \doubleexpandafter\page_area_two
\else
- \doif{#1}\v!text % copy due to trial runs in TABLE
- {\iftrialtypesetting
-% \copy\pagebox
- \fakebox\pagebox
- \else
-% \localpositioningfalse
- \page_backgrounds_add_to_text\pagebox
- \page_grids_add_to_box\pagebox
- \box\pagebox
- \fi}%
+ \doubleexpandafter\page_area_one
\fi\fi}
+\def\page_area_three[#1][#2][#3]%
+ {\edef\m_page_area_three{#3}%
+ \ifx\m_page_area_three\v!left
+ \let\m_page_area_three\c!lefttext
+ \else\ifx\m_page_area_three\v!right
+ \let\m_page_area_three\c!righttext
+ \else
+ \let\m_page_area_three\c!middletext
+ \fi\fi
+ \page_area_indeed{#1}{#2}\m_page_area_three}
+
+\def\page_area_two[#1][#2][#3]%
+ {\edef\m_page_area_three{\doifbothsidesoverruled\c!righttext\c!righttext\c!lefttext}%
+ \page_area_indeed{#1}{#2}\m_page_area_three}
+
+\def\page_area_one[#1][#2][#3]%
+ {\edef\m_page_area_one{#1}
+ \ifx\m_page_area_one\v!text % copy due to trial runs in TABLE
+ \iftrialtypesetting
+ \fakebox\pagebox
+ \else
+ \page_backgrounds_add_to_text\pagebox
+ \page_grids_add_to_box\pagebox
+ \box\pagebox
+ \fi
+ \fi}
+
\def\page_area_indeed#1#2#3%
- {\setbox\pageareabox\vbox{\getspecificlayouttext{#1}{#2}{#3}}%
+ {\setbox\b_page_area\vbox{\getspecificlayouttext{#1}{#2}{#3}}%
\ifsomebackgroundfound{#1#2}%
\iftrialtypesetting
-% \box\pageareabox
- \fakebox\pageareabox
+ \fakebox\b_page_area
\else
- \localframed
- [\??ma#1#2]
- [\c!width=\wd\pageareabox,
- \c!height=\ht\pageareabox,
+ % todo: \localbackgroundframed{\??layoutbackgrounds#1#2}{#1:#2}
+ \localframed % todo:
+ [\??layoutbackgrounds#1#2]
+ [\c!width=\wd\b_page_area,
+ \c!height=\ht\b_page_area,
\c!offset=\v!overlay]
- {\box\pageareabox}%
+ {\box\b_page_area}%
\fi
\else
- \box\pageareabox
+ \box\b_page_area
\fi}
% to be done nicely (proper namespacing)
-\setvalue{\??layoutmethod\v!leftpage }{\csname\??layoutmethod\v!page\endcsname}
-\setvalue{\??layoutmethod\v!rightpage}{\csname\??layoutmethod\v!page\endcsname}
+\setvalue{\??layoutmakeupalternative\v!leftpage }{\csname\??layoutmakeupalternative\v!page\endcsname}
+\setvalue{\??layoutmakeupalternative\v!rightpage}{\csname\??layoutmakeupalternative\v!page\endcsname}
\unexpanded\def\startpagelayout
{\bgroup
@@ -194,6 +209,6 @@
\def\page_layouts_start_layout[#1]#2\stoppagelayout
{\egroup
- \setvalue{\??layoutmethod#1}{#2}}
+ \setvalue{\??layoutmakeupalternative#1}{#2}}
\protect \endinput
diff --git a/tex/context/base/page-mis.lua b/tex/context/base/page-pst.lua
index 20ed23b50..8586830cf 100644
--- a/tex/context/base/page-mis.lua
+++ b/tex/context/base/page-pst.lua
@@ -1,6 +1,6 @@
-if not modules then modules = { } end modules ['page-mis'] = {
+if not modules then modules = { } end modules ['page-pst'] = {
version = 1.001,
- comment = "companion to page-mis.mkiv",
+ comment = "companion to page-pst.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
diff --git a/tex/context/base/page-mis.mkiv b/tex/context/base/page-pst.mkiv
index 6137bb462..1078dda03 100644
--- a/tex/context/base/page-mis.mkiv
+++ b/tex/context/base/page-pst.mkiv
@@ -2,7 +2,7 @@
%D [ file=page-mis,
%D version=2008.11.17, % was part of page-flt.tex / 2000.10.20
%D title=\CONTEXT\ Page Macros,
-%D subtitle=Misc Float Things,
+%D subtitle=Postponing,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\writestatus{loading}{ConTeXt Page Macros / Misc Float Things}
+\writestatus{loading}{ConTeXt Page Macros / Postponing}
-\registerctxluafile{page-mis}{1.001}
+\registerctxluafile{page-pst}{1.001}
\unprotect
@@ -21,8 +21,13 @@
\newevery\everytopofpage\relax
-\appendtoks \the\everytopofpage \to\everystarttext
-\appendtoks\global\everytopofpage\emptytoks\to\everystoptext
+\appendtoks
+ \the\everytopofpage
+\to \everystarttext
+
+\appendtoks
+ \global\everytopofpage\emptytoks
+\to \everystoptext
% \startpostponing [pagenumber] [+pageoffset]
%
@@ -44,8 +49,10 @@
%D is somewhat easier and we also can erase buffers easier when
%D we keep a local cache, especially as we can flush per page.
-\newif \ifinpostponing % prevents nesting
-\newcount\c_page_postponed_blocks_next_page % set at the lua end
+%newif \ifinpostponing % prevents nesting
+
+\newcount \c_page_postponed_blocks_next_page % set at the lua end
+\newconstant\c_page_postponed_busy
\unexpanded\setvalue{\e!start\v!postponing}%
{\bgroup
@@ -65,11 +72,11 @@
\unexpanded\def\page_postponed_blocks_flush_indeed
{\begingroup
\setsystemmode\v!postponing
- \inpostponingtrue % for old times sake
+ \settrue\c_page_postponed_busy
\global\pagetotal\zeropoint % here? still needed? (was after flush pagefloats)
\the\everytopofpage\relax
%\flushrestfloats
- \doflushpagefloats
+ \page_floats_flush_page_floats
\setnormalcatcodes % postponing in verbatim
\restoreglobalbodyfont % otherwise problems inside split verbatim
\ctxcommand{flushpostponedblocks()}%
@@ -77,8 +84,8 @@
\page_otr_command_flush_floats % new but potential dangerous, maybe we need a classification
\endgroup} % of blocks: with and without flush
-\def\page_postponed_blocks_flush
- {\ifinpostponing
+\unexpanded\def\page_postponed_blocks_flush
+ {\ifconditional\c_page_postponed_busy
% probably a nested flush
\else\ifnum\c_page_postponed_blocks_next_page=\zerocount
% nothing in cache
diff --git a/tex/context/base/page-sel.mkiv b/tex/context/base/page-sel.mkiv
deleted file mode 100644
index 27f094118..000000000
--- a/tex/context/base/page-sel.mkiv
+++ /dev/null
@@ -1,347 +0,0 @@
-%D \module
-%D [ file=page-sel, % moved from page-imp
-%D version=1998.01.15,
-%D title=\CONTEXT\ Page Macros,
-%D subtitle=Page Selection,
-%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 This will become runtime loaded code.
-
-\writestatus{loading}{ConTeXt Page Macros / Page Selection}
-
-\unprotect
-
-%D One can (mis)use this mechanism, in close cooperation
-%D with \PDFTEX\ to arrange pages of already produced files.
-%D
-%D \starttyping
-%D \insertpages[file.pdf][1,3][n=30,width=18cm]
-%D \stoptyping
-%D
-%D The pages are inserted in the text area, and even pages
-%D are repositioned according to the width. In this example
-%D empty pages are added after page 1 and 3.
-%D
-%D Selecting pages can be accomplished by:
-%D
-%D \starttyping
-%D \filterpages[file.pdf][1,3,5][n=30,width=18cm]
-%D \stoptyping
-%D
-%D One may pass \type {odd} or \type {even} instead of a
-%D comma separated list. A third alternative is:
-%D
-%D \starttyping
-%D \copypages[file.pdf][n=30,scale=950]
-%D \stoptyping
-%D
-%D This macros inserts the page, according to the settings
-%D provided.
-
-\def\insertpages
- {\dotripleempty\doinsertpages}
-
-\def\doinsertpages[#1][#2][#3]%
- {\doifassignmentelse{#2}
- {\dodoinsertpages[#1][][#2]}
- {\dodoinsertpages[#1][#2][#3]}}
-
-\def\dodoinsertpages[#1][#2][#3]%
- {\bgroup
- \dontcomplain
- \getfiguredimensions[#1]%
- \getparameters[\??ip][\c!n=\noffigurepages,\c!width=\zeropoint,#3]%
- \doifinset0{#2}{\emptyhbox\page}%
- \dorecurse\@@ipn
- {\dofilterpage{#1}\recurselevel
- \doifinset\recurselevel{#2}{\emptyhbox\page}}%
- \egroup}
-
-\def\filterpages
- {\dotripleempty\dofilterpages}
-
-\def\dofilterpages[#1][#2][#3]% % \noffigurepages not yet supported
- {\bgroup
- \dontcomplain
- \getfiguredimensions[#1]%
- \getparameters[\??ip][\c!n=\noffigurepages,\c!width=\zeropoint,#3]%
- \doifelse{#2}\v!even
- {\dorecurse\@@ipn
- {\ifodd\recurselevel\relax\else\dofilterpage{#1}\recurselevel\fi}}
- {\doifelse{#2}\v!odd
- {\dorecurse\@@ipn
- {\ifodd\recurselevel\relax\dofilterpage{#1}\recurselevel\fi}}
- {\def\dodocommand##1{\ifnum##1>\@@ipn\else\dofilterpage{#1}{##1}\fi}%
- \def\docommand ##1{\dowithrange{##1}\dodocommand}%
- \processcommalist[#2]\docommand}}%
- \egroup}
-
-\def\dofilterpage#1#2%
- {\hbox to \textwidth
- {\ifdoublesided\ifdim\@@ipwidth>\zeropoint\relax\ifodd\realpageno\else
- \hfill
- \def\dowithfigure{\hskip-\@@ipwidth}%
- \fi\fi\fi
- \setbox0\hbox
- {\externalfigure[#1][\c!page=#2,\c!height=\textheight]}%
- \wd0\zeropoint
- \box0}
- \page}
-
-\def\copypages
- {\dodoubleempty\docopypages}
-
-\def\docopypages[#1][#2]%
- {\bgroup
- \getfiguredimensions[#1]%
- \getparameters[\??ip]
- [\c!n=\noffigurepages,
- \c!marking=\v!off,
- \c!scale=\!!thousand,
- \c!offset=\zeropoint,
- #2]%
- \dorecurse\@@ipn
- {\vbox to \textheight
- {\hsize\textwidth
- \scratchdimen\@@ipoffset
- \centeredbox
- {\doifelse\@@ipmarking\v!on\cuthbox\hbox % only place where cuthbox is used
- {\ifdim\scratchdimen>\zeropoint\relax
- \advance\vsize -2\scratchdimen
- \advance\hsize -2\scratchdimen
- \externalfigure[#1][\c!page=\recurselevel,#2,\c!scale=,\c!factor=\v!max,\c!offset=\v!overlay]%
- \else
- \externalfigure[#1][\c!page=\recurselevel,#2,\c!offset=\v!overlay]%
- \fi}}}
- \page}
- \egroup}
-
-%D \macros
-%D {combinepages}
-%D
-%D Yet another way of postprocessing is handles by \type
-%D {\combinepages}. This macro builds a matrix of pages from a
-%D file, for example:
-%D
-%D \starttyping
-%D \setuppapersize
-%D [A4][A4] % or [A4,landscape][A4,landscape]
-%D
-%D \setuplayout
-%D [header=0pt,footer=1cm,
-%D backspace=1cm,topspace=1cm,
-%D width=middle,height=middle]
-%D
-%D \setupfootertexts
-%D [presentation---\currentdate\space---\space\pagenumber]
-%D
-%D \starttext
-%D \combinepages[slides][nx=2,ny=3,frame=on]
-%D \stoptext
-%D \stoptyping
-%D
-%D One can influence the way the pages are combined. (This
-%D will be explained some time.)
-
-\def\combinepages
- {\dodoubleempty\docombinepages}
-
-\def\docombinepages[#1][#2]% a=perpag b=free
- {\bgroup
- \dontcomplain
- \getfiguredimensions[#1]%
- \getparameters
- [\??ip]
- [\c!alternative=\v!a,
- \c!n=\noffigurepages,\c!nx=2,\c!ny=2,\c!start=1,\c!stop=\!!maxcard,
- \c!distance=\bodyfontsize,
- \c!bottom=\vfill,\c!top=\vss,
- \c!left=\hss,\c!right=\hss,
- \c!before=\page,\c!after=\page,\c!inbetween=\blank,
- \c!frame=,\c!background=,\c!backgroundcolor=,
- #2]%
- \def\@@ipname{#1}%
- \@@ipbefore
- \expandcheckedcsname{\??ip::\c!alternative:}\@@ipalternative\v!b
- \@@ipafter
- \egroup}
-
-\setvalue{\??ip::\c!alternative:\v!a}%
- {\global\combinedpagescounter\@@ipstart
- \doloop
- {\vbox to \textheight
- {\hsize\textwidth % ? ?
- \scratchdimen\@@ipdistance
- \!!widtha \dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
- \!!heighta\dimexpr(\vsize-\@@ipny\scratchdimen+\scratchdimen)/\@@ipny\relax
- \dorecurse\@@ipny
- {\hbox to \hsize
- {\dorecurse\@@ipnx
- {\vbox to \!!heighta
- {\hsize\!!widtha
- \vsize\!!heighta
- \@@iptop
- \hbox to \hsize
- {\@@ipleft
- \ifnum\combinedpagescounter>\@@ipstop\relax
- \globallet\@@ipn\!!zerocount
- \else\ifnum\combinedpagescounter>\@@ipn \else
- \externalfigure[\@@ipname]
- [\c!object=\v!no,
- \c!page=\number\combinedpagescounter,
- \c!factor=\v!max,
- \c!background=\@@ipbackground,
- \c!backgroundcolor=\@@ipbackgroundcolor,
- \c!frame=\@@ipframe]%
- \fi\fi
- \@@ipright}
- \@@ipbottom}%
- \global\advance\combinedpagescounter\plusone
- \hfil}%
- \hfilneg}
- \vfil}%
- \vfilneg}%
- \page
- \ifnum\combinedpagescounter>\@@ipn \exitloop\fi}}
-
-\setvalue{\??ip::\c!alternative:\v!c}%
- {\global\combinedpagescounter\@@ipstart
- \doloop
- {\vbox to \textheight
- {\hsize\textwidth % ? ?
- \scratchdimen\@@ipdistance
- \!!widtha \dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
- \!!heighta\dimexpr(\vsize-\@@ipny\scratchdimen+\scratchdimen)/\@@ipny\relax
- \hbox to \hsize
- {\dorecurse\@@ipnx
- {\@@ipleft
- \vbox to \textheight
- {\hsize\!!widtha
- {\dorecurse\@@ipny
- {\@@iptop
- \hbox to \hsize
- {\vbox to \!!heighta
- {\hsize\!!widtha
- \vsize\!!heighta
- \ifnum\combinedpagescounter>\@@ipstop\relax
- \globallet\@@ipn\!!zerocount
- \else\ifnum\combinedpagescounter>\@@ipn \else
- \externalfigure[\@@ipname]
- [\c!object=\v!no,
- \c!page=\number\combinedpagescounter,
- \c!factor=\v!max,
- \c!background=\@@ipbackground,
- \c!backgroundcolor=\@@ipbackgroundcolor,
- \c!frame=\@@ipframe]%
- \fi\fi}}
- \global\advance\combinedpagescounter\plusone
- \@@ipbottom}%
- \vfil}%
- \vfilneg}
- \hfil}%
- \hfilneg}}
- \page
- \ifnum\combinedpagescounter>\@@ipn \exitloop\fi}}
-
-\setvalue{\??ip::\c!alternative:\v!horizontal}{\getvalue{\??ip::\c!alternative:\v!a}}
-\setvalue{\??ip::\c!alternative:\v!vertical }{\getvalue{\??ip::\c!alternative:\v!c}}
-
-\setvalue{\??ip::\c!alternative:\v!b}%
- {\global\combinedpagescounter\@@ipstart
- \doloop
- {\startbaselinecorrection
- \scratchdimen\@@ipdistance
- \!!widtha\dimexpr(\hsize-\@@ipnx\scratchdimen+\scratchdimen)/\@@ipnx\relax
- \hbox to \hsize
- {\dorecurse\@@ipnx
- {\global\advance\combinedpagescounter\plusone
- \ifnum\combinedpagescounter>\@@ipn \else
- \normalexpanded{\noexpand\externalfigure[\@@ipname]
- [\c!page=\number\combinedpagescounter,
- \c!width=\the\!!widtha,% todo \freezedimenmacro
- \c!background=\@@ipbackground,
- \c!backgroundcolor=\@@ipbackgroundcolor,
- \c!frame=\@@ipframe]}%
- \hfill
- \fi}\hfillneg}%
- \stopbaselinecorrection
- \ifnum\combinedpagescounter<\@@ipn\relax
- \@@ipinbetween
- \else
- \exitloop
- \fi}}
-
-% This macro cuts a page into n parts that can be pasted
-% together.
-
-\def\slicepages
- {\dotripleempty\doslicepages}
-
-\def\doslicepages[#1][#2][#3]%
- {\ifthirdargument
- \dodoslicepages[#1][#2][#3]%
- \else
- \dodoslicepages[#1][#2][#2]%
- \fi}
-
-\newcounter\slicedpagenumber
-
-\def\dodoslicepages[#1][#2][#3]%
- {\bgroup
- \dontcomplain
- \globallet\slicedpagenumber\!!zerocount
- \getfiguredimensions[#1]
- \getparameters
- [\??ip]
- [\c!n=1,
- \c!offset=\zeropoint,
- \c!hoffset=\zeropoint,\c!voffset=\zeropoint,
- \c!width=\figurewidth,\c!height=\figureheight,#2]
- \ifnum\@@ipn>\zerocount
- \definepapersize
- [\s!dummy][\c!height=\@@ipheight,\c!width=\@@ipwidth]
- \setuppapersize
- [\s!dummy][\s!dummy]
- \setuplayout
- [\c!backspace=\zeropoint,\c!topspace=\zeropoint,
- \c!height=\v!middle,\c!width=\v!middle,
- \c!textdistance=\zeropoint,
- \c!header=\zeropoint,\c!footer=\zeropoint]
- \fi
- \dorecurse\noffigurepages
- {\global\let\slicedpagenumber\recurselevel
- \ifnum\@@ipn>\plusone
- \dorecurse\@@ipn
- {\let\xslice\recurselevel
- \dorecurse\@@ipn
- {\let\yslice\recurselevel
- \clip
- [\c!nx=\@@ipn,\c!ny=\@@ipn,\c!x=\xslice,\c!y=\yslice]
- {\scale
- [\c!scale=\@@ipn000]
- {\externalfigure[#1][\c!page=\slicedpagenumber]}}
- \page}}
- \else
- \ifodd\slicedpagenumber\relax
- \getparameters[\??ip][#2]
- \else
- \getparameters[\??ip][#3]
- \fi
- \hskip\@@ipoffset
- \clip
- [\c!hoffset=\@@iphoffset,\c!voffset=\@@ipvoffset,
- \c!height=\@@ipheight,\c!width=\@@ipwidth]
- {\externalfigure[#1][\c!page=\slicedpagenumber]}
- \page
- \fi}
- \egroup}
-
-% \starttext \slicepages[slice1.pdf][n=3] \stoptext
-
-\protect \endinput
diff --git a/tex/context/base/page-sel.mkvi b/tex/context/base/page-sel.mkvi
new file mode 100644
index 000000000..3d0771b48
--- /dev/null
+++ b/tex/context/base/page-sel.mkvi
@@ -0,0 +1,368 @@
+%D \module
+%D [ file=page-sel, % moved from page-imp
+%D version=1998.01.15,
+%D title=\CONTEXT\ Page Macros,
+%D subtitle=Page Selection,
+%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 This code relates to old texexec features and one can wonder if it needs
+%D to be in the core. So, this could become runtime loaded code. Some of
+%D the alternatives need checking.
+
+\writestatus{loading}{ConTeXt Page Macros / Page Selection}
+
+\unprotect
+
+%D One can (mis)use this mechanism to (re)arrange pages of already produced
+%D files.
+%D
+%D \starttyping
+%D \insertpages[file.pdf][1,3][n=30,width=18cm]
+%D \stoptyping
+%D
+%D The pages are inserted in the text area, and even pages are repositioned
+%D according to the width. In this example empty pages are added after page
+%D 1 and 3.
+%D
+%D Selecting pages can be accomplished by:
+%D
+%D \starttyping
+%D \filterpages[file.pdf][1,3,5][n=30,width=18cm]
+%D \stoptyping
+%D
+%D One may pass \type {odd} or \type {even} instead of a comma separated list. A
+%D third alternative is:
+%D
+%D \starttyping
+%D \copypages[file.pdf][n=30,scale=950]
+%D \stoptyping
+%D
+%D This macros inserts the page, according to the settings provided.
+
+\installcorenamespace{withpages}
+
+\installsetuponlycommandhandler \??withpages {withpages}
+% \installdirectcommandhandler \??withpages {withpages}
+
+\newcount\c_page_selectors_n
+
+\unexpanded\def\insertpages
+ {\dotripleempty\page_selectors_insert}
+
+\def\page_selectors_insert[#filename][#emptylist][#settings]%
+ {\doifassignmentelse{#emptylist}
+ {\page_selectors_insert_indeed[#filename][][#emptylist]}
+ {\page_selectors_insert_indeed[#filename][#emptylist][#settings]}}
+
+\def\page_selectors_insert_indeed[#filename][#emptylist][#settings]%
+ {\bgroup
+ \dontcomplain
+ \getfiguredimensions[#filename]%
+ \global\c_page_selectors_n\noffigurepages\relax
+ \setupcurrentwithpages[\c!width=\zeropoint,#settings]%
+ \scratchwidth\directwithpagesparameter\c!width\relax
+ \doifinset0{#emptylist}
+ {\emptyhbox\page}%
+ \dorecurse\c_page_selectors_n
+ {\page_selectors_filter_a_page{#filename}\recurselevel
+ \doifinset\recurselevel{#emptylist}
+ {\emptyhbox\page}}%
+ \egroup}
+
+\unexpanded\def\filterpages
+ {\dotripleempty\page_selectors_filter}
+
+\def\page_selectors_filter[#filename][#selection][#settings]% % \noffigurepages not yet supported
+ {\bgroup
+ \dontcomplain
+ \getfiguredimensions[#filename]%
+ \global\c_page_selectors_n\noffigurepages\relax
+ \setupcurrentwithpages[\c!width=\zeropoint,#settings]%
+ \scratchwidth\directwithpagesparameter\c!width\relax
+ \edef\p_selection{#selection}%
+ \ifx\p_selection\v!even
+ \dorecurse\c_page_selectors_n
+ {\ifodd\recurselevel\else
+ \page_selectors_filter_a_page{#filename}\recurselevel
+ \fi}%
+ \else\ifx\p_selection\v!odd
+ \dorecurse\c_page_selectors_n
+ {\ifodd\recurselevel\relax
+ \page_selectors_filter_a_page{#filename}\recurselevel
+ \fi}%
+ \else
+ \def\page_selectors_filter_step_indeed#page%
+ {\ifnum#page>\c_page_selectors_n\else
+ \page_selectors_filter_a_page{#filename}{#page}%
+ \fi}%
+ \def\page_selectors_filter_step#step%
+ {\dowithrange{#step}\page_selectors_filter_step_indeed}%
+ \processcommacommand[\p_selection]\page_selectors_filter_step
+ \fi
+ \egroup}
+
+\def\page_selectors_filter_a_page#filename#page%
+ {\hbox to \textwidth
+ {\ifdim\scratchwidth>\zeropoint
+ \rightorleftpageaction{\scratchwidth\zeropoint}{\hfill}%
+ \fi
+ \setbox\scratchbox\hbox
+ {\hskip-\scratchwidth
+ \externalfigure[#filename][\c!page=#page,\c!height=\textheight]\hss}%
+ \wd\scratchbox\zeropoint
+ \box\scratchbox}
+ \page}
+
+\unexpanded\def\copypages
+ {\dotripleempty\page_selectors_copy}
+
+\def\page_selectors_copy[#filename][#settings][#figuresettings]%
+ {\bgroup
+ \getfiguredimensions[#filename]%
+ \global\c_page_selectors_n\noffigurepages\relax
+ \setupcurrentwithpages[\c!marking=\v!off,\c!offset=\zeropoint,#settings]%
+ \scratchoffset\directwithpagesparameter\c!offset\relax
+ \dorecurse\c_page_selectors_n
+ {\vbox to \textheight
+ {\hsize\textwidth
+ \centeredbox
+ {\doifelse{\directwithpagesparameter\c!marking}\v!on\cuthbox\hbox % only place where cuthbox is used
+ {\ifdim\scratchoffset>\zeropoint\relax
+ \advance\vsize -2\scratchoffset
+ \advance\hsize -2\scratchoffset
+ \externalfigure[#filename][\c!page=\recurselevel,#figuresettings,\c!scale=,\c!factor=\v!max,\c!offset=\v!overlay]%
+ \else
+ \externalfigurefilename][\c!page=\recurselevel,#figuresettings,\c!offset=\v!overlay]%
+ \fi}}}
+ \page}
+ \egroup}
+
+%D \macros
+%D {combinepages}
+%D
+%D Yet another way of postprocessing is handles by \type {\combinepages}. This macro
+%D builds a matrix of pages from a file, for example:
+%D
+%D \starttyping
+%D \setuppapersize
+%D [A4][A4] % or [A4,landscape][A4,landscape]
+%D
+%D \setuplayout
+%D [header=0pt,footer=1cm,
+%D backspace=1cm,topspace=1cm,
+%D width=middle,height=middle]
+%D
+%D \setupfootertexts
+%D [presentation---\currentdate\space---\space\pagenumber]
+%D
+%D \starttext
+%D \combinepages[slides][nx=2,ny=3,frame=on]
+%D \stoptext
+%D \stoptyping
+%D
+%D One can influence the way the pages are combined. (This will be explained some
+%D time.)
+
+\installcorenamespace{combinepagesalternative}
+
+\unexpanded\def\combinepages
+ {\dodoubleempty\page_selectors_combine}
+
+\def\page_selectors_combine[#filename][#settings]% a=perpag b=free
+ {\bgroup
+ \dontcomplain
+ \getfiguredimensions[#filename]%
+ \global\c_page_selectors_n\noffigurepages\relax
+ \setupcurrentwithpages
+ [\c!alternative=\v!a,
+ \c!nx=\plustwo,\c!ny=\plustwo,\c!start=\plusone,\c!stop=\maxcard,
+ \c!distance=\bodyfontsize,
+ \c!bottom=\vfill,\c!top=\vss,\c!left=\hss,\c!right=\hss,
+ \c!before=\page,\c!after=\page,\c!inbetween=\blank,
+ \c!frame=,\c!background=,\c!backgroundcolor=,
+ \c!name={#filename},
+ #settings]%
+ \directwithpagesparameter\c!before
+ \scratchnx\directwithpagesparameter\c!nx
+ \scratchny\directwithpagesparameter\c!ny
+ \scratchdistance\directwithpagesparameter\c!distance\relax
+ \scratchwidth\dimexpr(\textwidth-\scratchnx\scratchdistance+\scratchdistance)/\scratchnx\relax
+ \scratchheight\dimexpr(\textheight-\scratchny\scratchdistance+\scratchdistance)/\scratchny\relax
+ \expandcheckedcsname{\??combinepagesalternative}{\directwithpagesparameter\c!alternative}\v!b
+ \directwithpagesparameter\c!after
+ \egroup}
+
+\setvalue{\??combinepagesalternative\v!a}%
+ {\global\combinedpagescounter\directwithpagesparameter\c!start\relax
+ \doloop
+ {\vbox to \textheight
+ {\dorecurse\scratchny
+ {\hbox to \textwidth
+ {\dorecurse\scratchnx
+ {\vbox to \scratchheight
+ {\hsize\scratchwidth
+ \vsize\scratchheight
+ \directwithpagesparameter\c!top
+ \hbox to \hsize
+ {\directwithpagesparameter\c!left
+ \ifnum\combinedpagescounter>\directwithpagesparameter\c!stop\relax
+ \global\c_page_selectors_n\zerocount
+ \else\ifnum\combinedpagescounter>\c_page_selectors_n \else
+ \externalfigure
+ [\directwithpagesparameter\c!name]
+ [\c!object=\v!no,
+ \c!page=\number\combinedpagescounter,
+ \c!factor=\v!max,
+ \c!background=\directwithpagesparameter\c!background,
+ \c!backgroundcolor=\directwithpagesparameter\c!backgroundcolor,
+ \c!frame=\directwithpagesparameter\c!frame]%
+ \fi\fi
+ \directwithpagesparameter\c!right}
+ \directwithpagesparameter\c!bottom}%
+ \global\advance\combinedpagescounter\plusone
+ \hfil}%
+ \hfilneg}
+ \vfil}%
+ \vfilneg}%
+ \page
+ \ifnum\combinedpagescounter>\c_page_selectors_n
+ \exitloop
+ \fi}}
+
+\setvalue{\??combinepagesalternative\v!c}%
+ {\global\combinedpagescounter\directwithpagesparameter\c!start\relax
+ \doloop
+ {\vbox to \textheight
+ {\hbox to \textwidth
+ {\dorecurse\scratchnx
+ {\directwithpagesparameter\c!left
+ \vbox to \textheight
+ {\hsize\scratchwidth
+ \dorecurse\scratchny
+ {\directwithpagesparameter\c!top
+ \hbox to \hsize
+ {\vbox to \scratchheight
+ {\hsize\scratchwidth
+ \vsize\scratchheight
+ \ifnum\combinedpagescounter>\directwithpagesparameter\c!stop\relax
+ \global\c_page_selectors_n\zerocount
+ \else\ifnum\combinedpagescounter>\c_page_selectors_n \else
+ \externalfigure
+ [\directwithpagesparameter\c!name]
+ [\c!object=\v!no,
+ \c!page=\number\combinedpagescounter,
+ \c!factor=\v!max,
+ \c!background=\directwithpagesparameter\c!background,
+ \c!backgroundcolor=\directwithpagesparameter\c!backgroundcolor,
+ \c!frame=\directwithpagesparameter\c!frame]%
+ \fi\fi}}
+ \global\advance\combinedpagescounter\plusone
+ \directwithpagesparameter\c!bottom}}%
+ \hfil}%
+ \hfilneg}}%
+ \page
+ \ifnum\combinedpagescounter>\c_page_selectors_n
+ \exitloop
+ \fi}}
+
+\setvalue{\??combinepagesalternative\v!horizontal}{\getvalue{\??combinepagesalternative\v!a}}
+\setvalue{\??combinepagesalternative\v!vertical }{\getvalue{\??combinepagesalternative\v!c}}
+
+\setvalue{\??combinepagesalternative\v!b}%
+ {\global\combinedpagescounter\directwithpagesparameter\c!start\relax
+ \doloop
+ {\startbaselinecorrection
+ \hbox to \textwidth
+ {\dorecurse\scratchnx
+ {\global\advance\combinedpagescounter\plusone
+ \ifnum\combinedpagescounter>\c_page_selectors_n \else
+ \normalexpanded{\externalfigure
+ [\directwithpagesparameter\c!name]
+ [\c!page=\number\combinedpagescounter,
+ \c!width=\the\scratchwidth,
+ \c!background=\directwithpagesparameter\c!background,
+ \c!backgroundcolor=\directwithpagesparameter\c!backgroundcolor,
+ \c!frame=\directwithpagesparameter\c!frame]}%
+ \hfill
+ \fi}%
+ \hfillneg}%
+ \stopbaselinecorrection
+ \ifnum\combinedpagescounter<\c_page_selectors_n\relax
+ \directwithpagesparameter\c!inbetween
+ \else
+ \exitloop
+ \fi}}
+
+% This macro cuts a page into n parts that can be pasted together.
+
+\unexpanded\def\slicepages
+ {\dotripleempty\page_selectors_slice}
+
+\def\page_selectors_slice[#filename][#oddsettings][#evensettings]%
+ {\ifthirdargument
+ \page_selectors_slice_indeed[#filename][#oddsettings][#evensettings]%
+ \else
+ \page_selectors_slice_indeed[#filename][#oddsettings][#oddsettings]%
+ \fi}
+
+\let\slicedpagenumber\!!zerocount
+\let\slicedpagestepx \!!zerocount
+\let\slicedpagestepy \!!zerocount
+
+\def\page_selectors_slice_indeed[#filename][#oddsettings][#evensettings]%
+ {\bgroup
+ \dontcomplain
+ \global\let\slicedpagenumber\!!zerocount
+ \getfiguredimensions[#filename]%
+ \global\c_page_selectors_n\noffigurepages\relax
+ \setupcurrentwithpages
+ [\c!offset=\zeropoint,\c!hoffset=\zeropoint,\c!voffset=\zeropoint,
+ \c!width=\figurewidth,\c!height=\figureheight,#oddsettings]%
+ \ifnum\c_page_selectors_n>\zerocount
+ \definepapersize
+ [\s!dummy][\c!height=\directwithpagesparameter\c!height,\c!width=\directwithpagesparameter\c!width]%
+ \setuppapersize
+ [\s!dummy][\s!dummy]%
+ \setuplayout
+ [\c!backspace=\zeropoint,\c!topspace=\zeropoint,
+ \c!height=\v!middle,\c!width=\v!middle,
+ \c!textdistance=\zeropoint,
+ \c!header=\zeropoint,\c!footer=\zeropoint]%
+ \fi
+ \dorecurse\noffigurepages
+ {\global\let\slicedpagenumber\recurselevel
+ \ifnum\c_page_selectors_n>\plusone
+ \dorecurse\c_page_selectors_n
+ {\let\slicedpagestepx\recurselevel
+ \dorecurse\c_page_selectors_n
+ {\let\slicedpagestepy\recurselevel
+ \clip
+ [\c!nx=\c_page_selectors_n,\c!ny=\c_page_selectors_n,\c!x=\slicedpagestepx,\c!y=\slicedpagestepy]
+ {\scale
+ [\c!scale=\number\c_page_selectors_n000]
+ {\externalfigure[#filename][\c!page=\slicedpagenumber]}}%
+ \page}}%
+ \else
+ \ifodd\slicedpagenumber\relax
+ \setupcurrentwithpages[#oddsettings]%
+ \else
+ \setupcurrentwithpages[#evensettings]%
+ \fi
+ \hskip\directwithpagesparameter\c!offset\relax
+ \clip
+ [\c!hoffset=\directwithpagesparameter\c!hoffset,\c!voffset=\directwithpagesparameter\c!voffset,
+ \c!height=\directwithpagesparameter\c!height,\c!width=\directwithpagesparameter\c!width]
+ {\externalfigure[#filename][\c!page=\slicedpagenumber]}%
+ \page
+ \fi}
+ \egroup}
+
+% \starttext \slicepages[slice1.pdf][n=3] \stoptext
+
+\protect \endinput
diff --git a/tex/context/base/page-set.mkiv b/tex/context/base/page-set.mkiv
index 99570004c..88382282f 100644
--- a/tex/context/base/page-set.mkiv
+++ b/tex/context/base/page-set.mkiv
@@ -1264,7 +1264,7 @@
\fi}
\unexpanded\def\page_set_command_check_if_float_fits
- {\global\ifnofloatpermitted\roomforfloatfalse\else\roomforfloattrue\fi}
+ {\global\ifconditional\c_page_floats_not_permitted\setfalse\c_page_floats_room\else\settrue\c_page_floats_room\fi}
\def\OTRSETunpreparebox#1%
{\ifhbox#1% spans and so
@@ -1279,11 +1279,11 @@
\def\OTRSETsavebox#1% clean up the skips
{\OTRSETunpreparebox{#1}%
- \dofloatssave\s!text}
+ \page_floats_save\s!text}
\def\OTRSETresavebox#1% clean up the skips
{\OTRSETunpreparebox{#1}%
- \dofloatsresave\s!text}
+ \page_floats_resave\s!text}
\unexpanded\def\page_set_command_flush_float_box
{\iftestfloatbox\ruledhbox\fi{\box\floatbox}}
@@ -1292,12 +1292,12 @@
{\bgroup
\def\OTRSETsavebox##1{\!!doneafalse}%
\doloop
- {\ifsomefloatwaiting
+ {\ifconditional\c_page_floats_some_waiting
\OTRSETskipstart
- \dofloatsgetinfo\s!text
+ \page_floats_get_info\s!text
\ifdim\floatwidth>\zeropoint
\!!doneatrue
- \dofloatsflush\s!text{1}%
+ \page_floats_flush\s!text\plusone
\dp\floatbox\zeropoint
\OTRSETstoreincolumnslot{TBLR}\floatbox
\if!!donea
@@ -1643,7 +1643,7 @@
\fi
\fi
\global\setfalse\OTRSETfinish
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\page_otr_command_set_vsize
\pagebreak
\page_otr_command_set_vsize
@@ -1991,7 +1991,7 @@
\dp\floatbox\strutdp
\@EA\uppercasestring\floatmethod\to\floatmethod
\OTRSETstoreincolumnslot\floatmethod\floatbox
- \doinsertfloatinfo}
+ \page_floats_report_total}
% kind of new, looks much like OTRONE, but not entirely
@@ -1999,7 +1999,7 @@
\unexpanded\def\page_set_command_set_top_insertions
{\bgroup
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\noffloatinserts\zerocount
\let\totaltopinserted\!!zeropoint
\OTRSETdodosettopinserts
@@ -2021,7 +2021,7 @@
\def\OTRSETdodosettopinserts
{\ifnum\noffloatinserts<\noftopfloats
- \dogetfloat
+ \page_floats_get
\ifdim\topinserted=\zeropoint\relax
\settrue\c_page_set_top_of_insert
\else
@@ -2047,15 +2047,15 @@
\else
\xdef\totaltopinserted{\the\topinserted}%
\insert\topins{\forgetall\box\scratchbox}% interlineskip ?
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\advance\noffloatinserts \plusone
\else
\noffloatinserts\noftopfloats\relax
\fi
- \dofloatflushedinfo
+ \page_floats_report_flushed
\fi
\else
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\showmessage\m!floatblocks6{\the\noftopfloats}%
\fi
\let\OTRSETdodosettopinserts\relax
@@ -2064,7 +2064,7 @@
\unexpanded\def\page_set_command_set_bottom_insertions
{\bgroup
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\noffloatinserts\zerocount
\OTRSETdodosetbotinserts
\fi
@@ -2072,7 +2072,7 @@
\def\OTRSETdodosetbotinserts
{\ifnum\noffloatinserts<\nofbotfloats\relax
- \dogetfloat
+ \page_floats_get
\global\advance\botinserted \ht\floatbox\relax
\global\advance\botinserted \dp\floatbox\relax
\global\advance\botinserted \floattopskip\relax
@@ -2081,19 +2081,19 @@
{\forgetall
\blank[\rootfloatparameter\c!spacebefore]%
\page_otr_command_flush_float_box}%
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\advance\noffloatinserts \plusone
\else
\noffloatinserts\nofbotfloats
\fi
- \dofloatflushedinfo
+ \page_floats_report_flushed
\else
\OTRSETresavebox\floatbox
\noffloatinserts\nofbotfloats\relax
\fi
- \global\nofloatpermittedtrue % vgl topfloats s!
+ \global\settrue\c_page_floats_not_permitted % vgl topfloats s!
\else
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\showmessage\m!floatblocks7{\the\nofbotfloats}%
\fi
\let\OTRSETdodosetbotinserts\relax
@@ -2540,10 +2540,10 @@
\unexpanded\def\page_set_command_flush_saved_floats % rather similar to _one_ ut this might change
{\global\topinserted\zeropoint
\global\botinserted\zeropoint
- \ifflushingfloats \else
+ \ifconditional\c_page_floats_flushing \else
\page_set_command_set_top_insertions
\page_set_command_set_bottom_insertions
- \ifsomefloatwaiting
+ \ifconditional\c_page_floats_some_waiting
\doif{\rootfloatparameter\c!cache}\v!no\page_set_command_flush_floats % could be _otr_
\fi
\fi}
diff --git a/tex/context/base/page-sid.mkiv b/tex/context/base/page-sid.mkiv
index f4d42a41c..f3b54e430 100644
--- a/tex/context/base/page-sid.mkiv
+++ b/tex/context/base/page-sid.mkiv
@@ -104,13 +104,12 @@
\let\logsidefloat \relax
-\newif\ifroomforfloat % shared (will change)
\newif\iftracesidefloats % public (might change)
% end of public variables
\def\page_sides_insert_info
- {\doinsertfloatinfo}
+ {\page_floats_report_total}
\def\page_sides_apply_horizontal_shift
{\ifdim\d_page_sides_maximum>\zeropoint
@@ -601,7 +600,7 @@
\fi
\relax % really needed ! ! ! !
\ifdim\dimen0>\dimen2
- \global\roomforfloatfalse
+ \global\setfalse\c_page_floats_room
\else
\ifdim\dimexpr\pagegoal-\d_page_sides_vsize\relax<\d_page_sides_bottomskip
\global\advance\d_page_sides_vsize \dimen0
@@ -612,7 +611,7 @@
\global\advance\d_page_sides_vsize \d_page_sides_bottomskip
\global\setfalse\c_page_sides_short
\fi
- \global\roomforfloattrue
+ \global\settrue\c_page_floats_room
\fi}
\def\page_sides_prepare_space
@@ -633,7 +632,7 @@
\page_sides_relocate_float{#1}%
\page_sides_apply_vertical_shift
\page_sides_analyse_space
- \ifroomforfloat \else
+ \ifconditional\c_page_floats_room \else
\page_otr_fill_and_eject_page
\page_sides_analyse_space
\page_sides_inject_dummy_lines
diff --git a/tex/context/base/page-spr.mkiv b/tex/context/base/page-spr.mkiv
index f4768d4e9..dc1e013d5 100644
--- a/tex/context/base/page-spr.mkiv
+++ b/tex/context/base/page-spr.mkiv
@@ -17,10 +17,9 @@
\unprotect
-\newbox\spreadbox
-\newif \ifinspread
-
-\setnewconstant\showspreadmode\plusone
+\newbox \b_page_spread_content
+\newconditional\c_page_spread_busy
+\newconditional\c_page_spread_once % when true only one flush (writes etc)
% beware, ugly overload, to be redone
@@ -35,52 +34,81 @@
\noindent % content can be < \hsize
\page_otr_command_package_contents#2#3}}%
\dp#1\zeropoint
- \setbox#1\hbox to \makeupwidth
- {\ifinspread
- \ifvoid\spreadbox
- \global\setbox\spreadbox\box#1%
- \copy\spreadbox\hss % left page
+ \ifconditional\c_page_spread_busy
+ \normalsettextpagecontent_spread{#1}%
+ \else
+ \normalsettextpagecontent_normal{#1}%
+ \fi}
+
+\def\normalsettextpagecontent_normal#1%
+ {\setbox#1\hbox to \makeupwidth
+ {\hss\box#1\hss}} % never change the \hss's
+
+\def\normalsettextpagecontent_spread#1%
+ {\setbox#1\hbox to \makeupwidth
+ {\ifvoid\b_page_spread_content
+ \ifconditional\c_page_spread_once
+ \box#1%
\else
- % prevent duplicate writes in normal run
- \ifarrangingpages \else \ifcase\showspreadmode
- \global\setbox\spreadbox\emptyhbox
- \wd\spreadbox\makeupwidth
- \ht\spreadbox\textheight
- \fi \fi
- \hss\box\spreadbox % right page
+ \global\setbox\b_page_spread_content\box#1%
+ \copy\b_page_spread_content
\fi
+ \hss % left page
\else
- \hss\box#1\hss % never change the \hss's
+ \hss % right page
+ \ifarrangingpages
+ % writes don't matter anyway
+ \else\ifconditional\c_page_spread_once
+ \global\setbox\b_page_spread_content\emptyhbox
+ \wd\b_page_spread_content\makeupwidth
+ \ht\b_page_spread_content\textheight
+ \else
+ % writes can interfere (todo: write stripper, but how about hyperlinks)
+ \fi \fi
+ \box\b_page_spread_content
\fi}}
-\def\doflushspread
- {\ifinspread \ifvoid\spreadbox\else
+\unexpanded\def\page_spread_flush
+ {\ifconditional\c_page_spread_busy \ifvoid\b_page_spread_content\else
% this page will be discarded later
\emptyhbox \page
\fi \fi }
\unexpanded\def\startspread
- {\bgroup
- \ifdoublesided
- \page[\v!left]%
- %\setsystemmode{spread}%
- \inspreadtrue
- \expanded{\setuplayout[\c!textwidth=\the\dimexpr2\textwidth+2\backspace\relax]}%
- \unexpanded\def\startspread{\bgroup\let\stopspread\egroup}%
- \let\stopspread\dostopspread
+ {\ifdoublesided
+ \ifconditional\c_page_spread_busy
+ \doubleexpandafter\page_spread_start_nop
+ \else
+ \doubleexpandafter\page_spread_start_yes
+ \fi
\else
- \let\stopspread\egroup
+ \expandafter\page_spread_start_nop
\fi}
\let\stopspread\relax
-\def\dostopspread
- {\kern\zeropoint\page
- \inspreadfalse
+\unexpanded\def\page_spread_start_yes
+ {\bgroup
+ \page[\v!left]%
+ %\setsystemmode{spread}%
+ \settrue\c_page_spread_busy
+ \expanded{\setuplayout[\c!textwidth=\the\dimexpr2\textwidth+2\backspace\relax]}%
+ \let\stopspread\page_spread_stop_yes}
+
+\unexpanded\def\page_spread_stop_yes
+ {\kern\zeropoint
+ \page
\setuplayout[\c!textwidth=\textwidth]
\page[\v!left]
\egroup}
+\unexpanded\def\page_spread_start_nop
+ {\bgroup
+ \let\stopspread\page_spread_stop_nop}
+
+\unexpanded\def\page_spread_stop_nop
+ {\egroup}
+
\protect \endinput
% texexec --arr --pdf test
diff --git a/tex/context/base/page-str.mkiv b/tex/context/base/page-str.mkiv
index 47eb5e3bf..200a71377 100644
--- a/tex/context/base/page-str.mkiv
+++ b/tex/context/base/page-str.mkiv
@@ -36,7 +36,7 @@
\unprotect
\let \currentoutputstream \empty
-\newif \ifinoutputstream
+\newif \ifinoutputstream % will becoem a conditional or mode
\newtoks \everyenableoutputstream
\appendtoks
@@ -71,15 +71,13 @@
{\ctxlua{streams.stop()}%
\endgroup}
-\let\currentoutputsubstream\empty
-
\unexpanded\def\startoutputsubstream[#1]% just push/pop instead
- {\glet\savedcurrentoutputstream\currentoutputstream
+ {\globalpushmacro\currentoutputstream
\enableoutputstream[#1]}
\unexpanded\def\stopoutputsubstream
- {\glet\currentoutputstream\savedcurrentoutputstream
- \enableoutputstream[\savedcurrentoutputstream]}
+ {\globalpopmacro\currentoutputstream
+ \enableoutputstream[\currentoutputstream]}
\def\flushoutputstream [#1]{\ctxlua{streams.flush("#1")}}
\def\outputstreamcopy [#1]{\vbox{\ctxlua{streams.flush("#1",true)}}}
diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi
index c86597338..241461ec0 100644
--- a/tex/context/base/page-txt.mkvi
+++ b/tex/context/base/page-txt.mkvi
@@ -430,6 +430,9 @@
\global\setfalse\resyncaftertextline
\fi}
+\def\getspecificlayouttext#vertical#horizontal#what%
+ {\csname\namedlayoutelementhash{#vertical:#horizontal}#what\endcsname}
+
% \settext[header][text][middle][xxx][yyy]
\def\settextcontent
@@ -474,8 +477,6 @@
%D macros. These are hooked into the general purpose token
%D list registers mentioned before.
-\def\ignoredlinebreak{\unskip\space\ignorespaces}
-
\def\page_layouts_place_text_line_indeed#vertical#height%
{\let\currentlayouttextline#vertical%
\ifdim#height>\zeropoint\relax % prevents pagenumbers when zero height
@@ -693,26 +694,26 @@
% associated. This is a rather messy test but better than the MkII
% way where we use states and keep settings.
-\let\m_page_layouts_page_number_location_ \relax
-\let\m_page_layouts_page_number_location__v\relax
-\let\m_page_layouts_page_number_location__h\relax
-\let\m_page_layouts_page_number_location__x\relax
+\let\m_page_layouts_page_number_location \relax
+\let\m_page_layouts_page_number_location_v\relax
+\let\m_page_layouts_page_number_location_h\relax
+\let\m_page_layouts_page_number_location_x\relax
\def\page_layouts_place_page_number % also elsewhere .. beware, not \unexpanded else
{\placelocationpagenumber} % test below fails
\def\page_layouts_reset_page_number_location
- {\ifx\m_page_layouts_page_number_location__v\relax\else
- \edef\currentlayoutelement{\m_page_layouts_page_number_location__v:\m_page_layouts_page_number_location__h}%
- \edef\page_layouts_previous_page_number_locator{\detokenizedlayoutelementparameter\m_page_layouts_page_number_location__x}%
+ {\ifx\m_page_layouts_page_number_location_v\relax\else
+ \edef\currentlayoutelement{\m_page_layouts_page_number_location_v:\m_page_layouts_page_number_location_h}%
+ \edef\page_layouts_previous_page_number_locator{\detokenizedlayoutelementparameter\m_page_layouts_page_number_location_x}%
\doif{\meaning\page_layouts_previous_page_number_locator}{\meaning\page_layouts_place_page_number}
- {\resetlayoutelementparameter\m_page_layouts_page_number_location__x}%
+ {\resetlayoutelementparameter\m_page_layouts_page_number_location_x}%
\fi}
\def\page_layouts_set_page_number_location
- {\edef\currentlayoutelement{\m_page_layouts_page_number_location__v:\m_page_layouts_page_number_location__h}%
- \letlayoutelementparameter\m_page_layouts_page_number_location__x\page_layouts_place_page_number
- \ifx\m_page_layouts_page_number_location__x\c!marginedgetext
+ {\edef\currentlayoutelement{\m_page_layouts_page_number_location_v:\m_page_layouts_page_number_location_h}%
+ \letlayoutelementparameter\m_page_layouts_page_number_location_x\page_layouts_place_page_number
+ \ifx\m_page_layouts_page_number_location_x\c!marginedgetext
\let\page_layouts_place_extra_text_left \page_layouts_place_page_number_left
\let\page_layouts_place_extra_text_right\page_layouts_place_page_number_right
\else
@@ -721,38 +722,39 @@
\fi}
\def\page_layouts_identify_page_number_location
- {\let\m_page_layouts_page_number_location__v\v!footer
- \let\m_page_layouts_page_number_location__h\v!text
- \let\m_page_layouts_page_number_location__x\c!middletext
- \processallactionsinset[\@@nmlocation]
- [ \v!header=>\let\m_page_layouts_page_number_location__v\v!header,
- \v!footer=>\let\m_page_layouts_page_number_location__v\v!footer,
- \v!middle=>\let\m_page_layouts_page_number_location__h\v!text
- \let\m_page_layouts_page_number_location__x\c!middletext,
- \v!left=>\let\m_page_layouts_page_number_location__h\v!text
- \let\m_page_layouts_page_number_location__x\c!lefttext,
- \v!right=>\let\m_page_layouts_page_number_location__h\v!text
- \let\m_page_layouts_page_number_location__x\c!righttext,
- \v!inleft=>\let\m_page_layouts_page_number_location__h\v!margin
- \let\m_page_layouts_page_number_location__x\c!lefttext,
- \v!inright=>\let\m_page_layouts_page_number_location__h\v!margin
- \let\m_page_layouts_page_number_location__x\c!righttext,
- \v!inmargin=>\let\m_page_layouts_page_number_location__h\v!margin
- \def\m_page_layouts_page_number_location__x{\ifdoublesided\c!margintext\else\c!righttext\fi},
- \v!margin=>\let\m_page_layouts_page_number_location__h\v!margin
- \def\m_page_layouts_page_number_location__x{\ifdoublesided\c!margintext\else\c!righttext\fi},
- \v!atmargin=>\let\m_page_layouts_page_number_location__h\v!text
- \let\m_page_layouts_page_number_location__x\c!marginedgetext,
- \v!marginedge=>\let\m_page_layouts_page_number_location__h\v!text
- \let\m_page_layouts_page_number_location__x\c!marginedgetext]}
+ {\let\m_page_layouts_page_number_location_v\v!footer
+ \let\m_page_layouts_page_number_location_h\v!text
+ \let\m_page_layouts_page_number_location_x\c!middletext
+ \processallactionsinset[\directpagenumberingparameter\c!location]
+ [ \v!header=>\let\m_page_layouts_page_number_location_v\v!header,
+ \v!footer=>\let\m_page_layouts_page_number_location_v\v!footer,
+ \v!middle=>\let\m_page_layouts_page_number_location_h\v!text
+ \let\m_page_layouts_page_number_location_x\c!middletext,
+ \v!left=>\let\m_page_layouts_page_number_location_h\v!text
+ \let\m_page_layouts_page_number_location_x\c!lefttext,
+ \v!right=>\let\m_page_layouts_page_number_location_h\v!text
+ \let\m_page_layouts_page_number_location_x\c!righttext,
+ \v!inleft=>\let\m_page_layouts_page_number_location_h\v!margin
+ \let\m_page_layouts_page_number_location_x\c!lefttext,
+ \v!inright=>\let\m_page_layouts_page_number_location_h\v!margin
+ \let\m_page_layouts_page_number_location_x\c!righttext,
+ \v!inmargin=>\let\m_page_layouts_page_number_location_h\v!margin
+ \def\m_page_layouts_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi},
+ \v!margin=>\let\m_page_layouts_page_number_location_h\v!margin
+ \def\m_page_layouts_page_number_location_x{\ifdoublesided\c!margintext\else\c!righttext\fi},
+ \v!atmargin=>\let\m_page_layouts_page_number_location_h\v!text
+ \let\m_page_layouts_page_number_location_x\c!marginedgetext,
+ \v!marginedge=>\let\m_page_layouts_page_number_location_h\v!text
+ \let\m_page_layouts_page_number_location_x\c!marginedgetext]}
\unexpanded\def\dosetpagenumberlocation
- {\ifx\@@nmlocation\m_page_layouts_page_number_location_
+ {\edef\p_page_numbering_location{\directpagenumberingparameter\c!location}%
+ \ifx\p_page_numbering_location\m_page_layouts_page_number_location
% unchanged
\else
- \let\m_page_layouts_page_number_location_\@@nmlocation
+ \let\m_page_layouts_page_number_location\p_page_numbering_location
\page_layouts_reset_page_number_location
- \ifx\@@nmlocation\empty
+ \ifx\p_page_numbering_location\empty
% set otherwise
\else
\page_layouts_identify_page_number_location
@@ -764,9 +766,12 @@
{\begingroup
\setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}%
\ifzeropt\wd\scratchbox\else
- \doifelsenothing\@@nmwidth
- {\box\scratchbox\tfskip}
- {\hbox to \@@nmwidth{\box\scratchbox\hss}}%
+ \edef\p_page_numbering_width{\directpagenumberingparameter\c!width}%
+ \ifx\p_page_numbering_width\empty
+ \box\scratchbox\tfskip
+ \else
+ \hbox to \p_page_numbering_width{\box\scratchbox\hss}%
+ \fi
\fi
\endgroup}
@@ -774,9 +779,12 @@
{\begingroup
\setbox\scratchbox\hbox{\ignorespaces\layoutelementparameter\c!marginedgetext\removeunwantedspaces}%
\ifzeropt\wd\scratchbox\else
- \doifelsenothing\@@nmwidth
- {\tfskip\box\scratchbox}
- {\hbox to \@@nmwidth{\hss\box\scratchbox}}%
+ \edef\p_page_numbering_width{\directpagenumberingparameter\c!width}%
+ \ifx\p_page_numbering_width\empty
+ \tfskip\box\scratchbox
+ \else
+ \hbox to \p_page_numbering_width{\hss\box\scratchbox}%
+ \fi
\fi
\endgroup}
diff --git a/tex/context/base/regi-ini.lua b/tex/context/base/regi-ini.lua
index ec6f812cc..3440dd52d 100644
--- a/tex/context/base/regi-ini.lua
+++ b/tex/context/base/regi-ini.lua
@@ -234,6 +234,9 @@ function commands.stopregime()
end
end
+commands.pushregime = regimes.push
+commands.popregime = regimes.pop
+
-- obsolete:
--
-- function regimes.setsynonym(synonym,target)
diff --git a/tex/context/base/scrn-pag.mkvi b/tex/context/base/scrn-pag.mkvi
index 66f197ffd..5bbdadda8 100644
--- a/tex/context/base/scrn-pag.mkvi
+++ b/tex/context/base/scrn-pag.mkvi
@@ -150,12 +150,6 @@
{\global\setfalse\c_scrn_canvas_tight_page}%
\to \everysetupinteractionscreen
-\appendtoks
- \doifelse\@@pcstate\v!start
- \scrn_canvas_synchronize_simple
- \scrn_canvas_synchronize_complex
-\to \everyshipout
-
\setupinteractionscreen
[\c!width=\printpaperwidth,
\c!height=\printpaperheight,
diff --git a/tex/context/base/scrn-wid.lua b/tex/context/base/scrn-wid.lua
index 6fdc4fca0..14d58a29a 100644
--- a/tex/context/base/scrn-wid.lua
+++ b/tex/context/base/scrn-wid.lua
@@ -167,11 +167,19 @@ function renderings.rendering(label)
end
end
-function renderings.var(label,key)
+local function var(label,key)
local rn = renderings[label]
- context(rn and rn[key] or "")
+ return rn and rn[key] or ""
end
+renderings.var = var
+
+function commands.renderingvar(label,key)
+ context(var(label,key))
+end
+
+commands.registerrendering = renderings.register
+
-- Rendering:
function commands.insertrenderingwindow(specification)
diff --git a/tex/context/base/scrn-wid.mkvi b/tex/context/base/scrn-wid.mkvi
index 2b75f83cd..610f1e7b9 100644
--- a/tex/context/base/scrn-wid.mkvi
+++ b/tex/context/base/scrn-wid.mkvi
@@ -483,10 +483,8 @@
% todo: dedicated margin classes
-\def\scrn_comment_place
- {\executeifdefined
- {\??commentlocation\commentparameter\c!location}\hbox
- {\hbox{\box\b_scrn_comment_link}}}
+\unexpanded\def\scrn_comment_place
+ {\hbox{\expandcheckedcsname\??commentlocation{\commentparameter\c!location}\s!unknown}}
\setvalue{\??commentlocation\v!inmargin }{\inmargin }
\setvalue{\??commentlocation\v!leftedge }{\inleftedge }
@@ -495,6 +493,12 @@
\setvalue{\??commentlocation\v!rightmargin}{\inrightmargin}
\setvalue{\??commentlocation\v!high }{\high}
\setvalue{\??commentlocation\v!none }{\scrn_comment_collect}
+\setvalue{\??commentlocation\s!unknown }{\scrn_comment_flush_collect}
+
+\unexpanded\def\scrn_comment_flush_collect
+ {\ifvoid\b_scrn_comment_collect\else
+ \box\b_scrn_comment_collect
+ \fi}
\def\scrn_comment_collect#content%
{\global\setbox\b_scrn_comment_collect\hbox\bgroup
@@ -505,10 +509,7 @@
#content%
\egroup}
-\unexpanded\def\placecomments
- {\ifvoid\b_scrn_comment_collect\else
- \box\b_scrn_comment_collect
- \fi}
+\let\placecomments\scrn_comment_flush_collect
\definecomment[comment]
@@ -529,6 +530,13 @@
%D Todo: like external figures, also search on path,
%D although, they need to be present ar viewing time, so ...
+\installcorenamespace{externalsoundtracks}
+
+\installsetuponlycommandhandler \??externalsoundtracks {externalsoundtracks}
+
+\setupexternalsoundtracks
+ [\c!option=]
+
\unexpanded\def\useexternalsoundtrack
{\dodoubleargument\scrn_soundtrack_indeed}
@@ -541,17 +549,11 @@
\def\checksoundtrack#tag% yet untested in mkiv (also move management to lua)
{\iflocation
\ctxcommand{insertsoundclip{
- tag = "#tag",
- repeat = "\@@sdoption", % not entirely ok but works
+ tag = "#tag",
+ ["repeat"] = "\directexternalsoundtrackparameter\c!option", % todo: pass option as-is
}}%
\fi}
-\unexpanded\def\setupexternalsoundtracks
- {\dodoubleargument\getparameters[\??sd]}
-
-\setupexternalsoundtracks
- [\c!option=]
-
%D Renderings (not yet tested in mkvi):
% Todo: multiple instances and inheritance .. will be done when
@@ -568,7 +570,7 @@
\def\setinternalrendering{\dodoubleempty \scrn_rendering_set}
\def\scrn_rendering_use[#tag][#mime][#file][#option]%
- {\ctxlua{interactions.renderings.register {
+ {\ctxcommand{registerrendering{
type = "external",
label = "#tag",
mime = "#mime",
@@ -579,7 +581,7 @@
\def\scrn_rendering_set[#tag][#option]% {content}
{\bgroup
\dowithnextbox
- {\ctxlua{interactions.renderings.register {
+ {\ctxcommand{registerrendering{
type = "internal",
label = "#tag",
mime = "IRO", % brrr
@@ -591,28 +593,24 @@
\egroup}%
\hbox}
-\def\renderingtype #tag{\ctxlua{interactions.renderings.var("#tag","type")}}
-\def\renderingoption#tag{\ctxlua{interactions.renderings.var("#tag","option")}}
+\def\renderingtype #tag{\ctxcommand{renderingvar("#tag","type")}}
+\def\renderingoption#tag{\ctxcommand{renderingvar("#tag","option")}}
-\def\renderingwidth {8cm} % will become private
-\def\renderingheight{6cm} % will become private
+\newdimen\d_scrn_rendering_width \d_scrn_rendering_width 8cm
+\newdimen\d_scrn_rendering_height \d_scrn_rendering_height 6cm
-\unexpanded\def\definerenderingwindow
- {\dodoubleempty\scrn_rendering_define_window}
+\let\m_scrn_rendering_page\!!zerocount
-\def\scrn_rendering_define_window[#tag][#settings]%
- {\presetlocalframed[\??rw#tag]%
- \getparameters
- [\??rw#tag]%
- [\c!openpageaction=,\c!closepageaction=,%
- \c!width=\renderingwidth,\c!height=\renderingheight,%
- #settings]}
+\installcorenamespace{renderingwindow}
-\unexpanded\def\setuprenderingwindow
- {\dodoubleargument\scrn_rendering_setup_window}
+\installframedcommandhandler \??renderingwindow {renderingwindow} \??renderingwindow
-\def\scrn_rendering_setup_window[#tag]%
- {\getparameters[\??rw#tag]}
+\appendtoks
+ \letrenderingwindowparameter\c!openpageaction \empty
+ \letrenderingwindowparameter\c!closepageaction\empty
+ \setrenderingwindowparameter\c!width {\d_scrn_rendering_width }%
+ \setrenderingwindowparameter\c!height {\d_scrn_rendering_height}%
+\to \everypresetrenderingwindow
\unexpanded\def\placerenderingwindow
{\dodoubleempty\scrn_rendering_place_window}
@@ -622,31 +620,32 @@
\edef\currentrendering{\ifsecondargument#rendering\else#window\fi}%
\doifelse{\renderingtype\currentrendering}{internal} % an object
{\getobjectdimensions{IRO}\currentrendering
- \edef\renderingheight{\the\dimexpr\objectheight+\objectdepth\relax}%
- \edef\renderingwidth{\objectwidth}%
- \dogetobjectreferencepage{IRO}\currentrendering\renderingpage}%
- {\def\renderingheight{\vsize}%
- \def\renderingwidth{\hsize}%
- \def\renderingpage{\realpageno}}%
+ \d_scrn_rendering_height\dimexpr\objectheight+\objectdepth\relax
+ \d_scrn_rendering_width\objectwidth\relax
+ \dogetobjectreferencepage{IRO}\currentrendering\m_scrn_rendering_page}%
+ {\d_scrn_rendering_height\vsize
+ \d_scrn_rendering_width\hsize
+ \let\m_scrn_rendering_page\realpageno}%
% create fall back if needed
- \ifcsname\??rw#window\c!width\endcsname
- \def\currentrenderingwindow{#window}%
- \else
+ \edef\currentrenderingwindow{\namedrenderingwindowparameter{#window}\c!width}% stupid test, we need a proper one here
+ \ifx\currentrenderingwindow\empty
\let\currentrenderingwindow\s!default
- \definerenderingwindow[\currentrenderingwindow]%
+ \definerenderingwindow[\currentrenderingwindow]% why not global
+ \else
+ \edef\currentrenderingwindow{#window}%
\fi
-% todo
-% \handlereferenceactions{\getvalue{\??rw\currentrenderingwindow\c!openpageaction }}\dosetuprenderingopenpageaction
-% \handlereferenceactions{\getvalue{\??rw\currentrenderingwindow\c!closepageaction}}\dosetuprenderingclosepageaction
- \localframed
- [\??rw\currentrenderingwindow][\c!offset=\v!overlay]%
+ % todo:
+ % \handlereferenceactions{\renderingwindowparameter\c!openpageaction }\dosetuprenderingopenpageaction
+ % \handlereferenceactions{\renderingwindowparameter\c!closepageaction}\dosetuprenderingclosepageaction
+ \letrenderingwindowparameter\c!offset\v!overlay
+ \inheritedrenderingwindowframed
{\vfill
\ctxcommand{insertrenderingwindow {
label = "\currentrendering",
- width = \number\dimexpr\renderingwidth\relax,
- height = \number\dimexpr\renderingheight\relax,
+ width = \number\d_scrn_rendering_width,
+ height = \number\d_scrn_rendering_height,
option = "\renderingoption\currentrendering",
- page = \number\renderingpage,
+ page = \number\m_scrn_rendering_page,
}}\hfill}%
\egroup}
@@ -662,6 +661,8 @@
% %D \dorecurse{10}{\linkedlistelement[demo]{link \recurselevel} \page}
% %D \stoptyping
%
+% \definesystemvariable {lk} % LinK
+%
% \installcommandhandler\??lk{linkedlist}\??lk
%
% \let\setupbutton\setuplinkedlists\setuplinkedlist
diff --git a/tex/context/base/spac-def.mkiv b/tex/context/base/spac-def.mkiv
index ea537aea7..0e2333045 100644
--- a/tex/context/base/spac-def.mkiv
+++ b/tex/context/base/spac-def.mkiv
@@ -21,29 +21,37 @@
% maybe \everysynchronizeglobalspacing
% maybe \everysynchronizelocalspacing
-\appendtoks \forgetverticalstretch \to \everybodyfont
-\appendtoks \presetnormallineheight \to \everybodyfont
-\appendtoks \setnormalbaselines \to \everybodyfont % check if redundant (\forgetverticalstretch does it too)
-\appendtoks \setstrut \to \everybodyfont % check if redundant (\forgetverticalstretch does it too)
-\appendtoks \settopskip \to \everybodyfont % factors set in \forgetverticalstretch
-\appendtoks \setmaxdepth \to \everybodyfont % factors set in \forgetverticalstretch
-\appendtoks \synchronizeindenting \to \everybodyfont
-\appendtoks \synchronizeblank \to \everybodyfont
-\appendtoks \synchronizewhitespace \to \everybodyfont
-\appendtoks \synchronizespacecodes \to \everybodyfont % not needed, frozen factors
-\appendtoks \setrelativeinterlinespace \to \everybodyfont
+\appendtoks
+ \forgetverticalstretch
+ \presetnormallineheight
+ \setnormalbaselines % check if redundant (\forgetverticalstretch does it too)
+ \setstrut % check if redundant (\forgetverticalstretch does it too)
+ \settopskip % factors set in \forgetverticalstretch
+ \setmaxdepth % factors set in \forgetverticalstretch
+ \synchronizeindenting
+ \synchronizeblank
+ \synchronizewhitespace
+ \synchronizespacecodes % not needed, frozen factors
+ \setrelativeinterlinespace
+\to \everybodyfont
% why exception
-\appendtoks \updateraggedskips \to \everyfontswitch % under test
+\appendtoks
+ \updateraggedskips % under test
+\to \everyfontswitch
% maybe more
-\prependtoks \let\par\normalpar \to \everybeforepagebody % see \fillinline (was endgraf)
+\prependtoks
+ \let\par\normalpar
+\to \everybeforepagebody % see \fillinline (was endgraf)
% needs checking:
-\appendtoks \synchronizespacecodes \to \everydefinedfont % not needed, frozen factors
+\appendtoks
+ \synchronizespacecodes
+\to \everydefinedfont % not needed, frozen factors
\setupinterlinespace
[\c!minheight=\zeropoint, % only special purpose
diff --git a/tex/context/base/spac-grd.mkiv b/tex/context/base/spac-grd.mkiv
index cf350fdb6..369c147e3 100644
--- a/tex/context/base/spac-grd.mkiv
+++ b/tex/context/base/spac-grd.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D This module will be merged intio spac-ver.mkiv.
+%D This module will be merged into spac-ver.mkiv.
\writestatus{loading}{ConTeXt Spacing Macros / Grid Snapping}
@@ -142,7 +142,9 @@
\def\showbaselinecorrection
{\def\dobaselinecorrection % visualization is not watertight!
{\bgroup
-\ifdim\prevdepth>\zeropoint\kern-\prevdepth\fi
+ \ifdim\prevdepth>\zeropoint
+ \kern-\prevdepth
+ \fi
\setbox\scratchbox\emptyhbox
\wd\scratchbox\hsize
\dp\scratchbox\strutdp
diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv
index 49187a6ad..18460b1c6 100644
--- a/tex/context/base/spac-hor.mkiv
+++ b/tex/context/base/spac-hor.mkiv
@@ -417,7 +417,7 @@
\appendtoks
\let~\space
\let\ \space
-\to \simplifiedcommands
+\to \everysimplifycommands
\unexpanded\def\removeunwantedspaces
{\ifhmode
@@ -987,4 +987,8 @@
\unexpanded\def\medglue {\spac_glues_text_or_math\medmuskip \v!medium}
\unexpanded\def\thickglue{\spac_glues_text_or_math\thickmuskip\v!big}
+%D For the moment here (used in page-txt):
+
+\unexpanded\def\ignoredlinebreak{\unskip\space\ignorespaces}
+
\protect \endinput
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index e404dc9ef..f3dd5eafe 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -1259,7 +1259,6 @@
\definesystemattribute[skipcategory] [public]
\definesystemattribute[skippenalty] [public]
\definesystemattribute[skiporder] [public]
-\definesystemattribute[displaymath] [public]
\definesystemattribute[snapmethod] [public]
\definesystemattribute[snapvbox] [public]
%definesystemattribute[snapcategory] [public]
@@ -1868,4 +1867,56 @@
\relax
\fi}
+%D Some preliminary code: a simple and fast hanger, for usage in
+%D macros (moved from cont-new).
+
+\installcorenamespace {hanging}
+
+\installdirectcommandhandler \??hanging {hanging}
+
+\setuphanging
+ [\c!distance=.5em]
+
+\unexpanded\def\starthanging
+ {\noindent\bgroup
+ \dowithnextboxcs\spac_hanging_finish\hbox}
+
+\def\spac_hanging_finish
+ {\setbox\nextbox\hbox
+ {\box\nextbox
+ \hskip\directhangingparameter\c!distance}%
+ \hangindent\wd\nextbox
+ \hangafter\plusone
+ \box\nextbox
+ \ignorespaces}
+
+\unexpanded\def\stophanging
+ {\endgraf
+ \egroup}
+
+\unexpanded\def\starthangaround
+ {\noindent\bgroup
+ \dowithnextboxcs\spac_hanging_around_finish\hbox}
+
+\def\spac_hanging_around_finish
+ {\ifdim\nextboxht>\strutht
+ \setbox\nextbox\tbox
+ {\box\nextbox}%
+ \fi
+ \setbox\nextbox\hbox
+ {\box\nextbox
+ \hskip\directhangingparameter\c!distance}%
+ \getboxheight\scratchdimen\of\box\nextbox
+ \getnoflines\scratchdimen
+ \ht\nextbox\strutht
+ \dp\nextbox\strutdp
+ \hangindent\wd\nextbox
+ \hangafter-\noflines
+ \llap{\box\nextbox}%
+ \ignorespaces}
+
+\unexpanded\def\stophangaround
+ {\endgraf
+ \egroup}
+
\protect \endinput
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 5c835ba6f..2a6807dc6 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 9a2a5fefd..273b84d23 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index 3da404199..094859290 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -190,9 +190,9 @@ return {
status = "okay",
},
{
- filename = "core-var",
+ filename = "core-ini",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
comment = "code might move from here",
},
{
@@ -279,13 +279,13 @@ return {
-- {
-- filename = "supp-vis",
-- marktype = "mkiv",
- -- status = "unknown",
+ -- status = "todo",
-- comment = "will become a module (and part will stay in the core)",
-- },
-- {
-- filename = "supp-fun",
-- marktype = "mkiv",
- -- status = "unknown",
+ -- status = "todo",
-- comment = "will be integrated elsewhere",
-- },
{
@@ -314,7 +314,8 @@ return {
{
filename = "page-ins",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "dealing with insertions might change",
},
{
filename = "file-syn",
@@ -468,8 +469,8 @@ return {
{
filename = "pack-mrl",
marktype = "mkiv",
- status = "todo",
- comment = "this is something to be done on a rainy day"
+ status = "okay",
+ comment = "endpar experimental code"
},
{
filename = "pack-bck",
@@ -509,17 +510,18 @@ return {
{
filename = "strc-doc",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-num",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "still some rough edges",
},
{
filename = "strc-mar",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "strc-sbe",
@@ -534,17 +536,17 @@ return {
{
filename = "strc-sec",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-pag",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-ren",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-xml",
@@ -555,7 +557,7 @@ return {
{
filename = "strc-def",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-ref",
@@ -566,7 +568,7 @@ return {
{
filename = "strc-reg",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-lev",
@@ -611,12 +613,12 @@ return {
{
filename = "spac-def",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "spac-grd",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
comment = "needs thinking and redoing",
},
{
@@ -651,27 +653,27 @@ return {
{
filename = "strc-con",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-des",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-enu",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-ind",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "strc-lab",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "core-sys",
@@ -682,7 +684,7 @@ return {
{
filename = "page-var",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "page-otr",
@@ -698,7 +700,7 @@ return {
{
filename = "page-fac",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "page-brk",
@@ -709,7 +711,8 @@ return {
{
filename = "page-col",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "helpers for columns",
},
{
filename = "page-inf",
@@ -720,12 +723,13 @@ return {
{
filename = "page-grd",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "page-flt",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "will be extended when columns are redone",
},
{
filename = "page-bck",
@@ -735,7 +739,7 @@ return {
{
filename = "page-not",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "page-one",
@@ -757,6 +761,7 @@ return {
filename = "page-txt",
marktype = "mkvi",
status = "okay",
+ comment = "a few things left",
},
{
filename = "page-sid",
@@ -766,12 +771,12 @@ return {
{
filename = "strc-flt",
marktype = "mkvi",
- status = "unknown",
+ status = "todo",
},
{
- filename = "page-mis",
+ filename = "page-pst",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "page-mbk",
@@ -782,12 +787,14 @@ return {
{
filename = "page-mul",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
+ comment = "will be reimplemented",
},
{
filename = "page-set",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
+ comment = "will be reimplemented",
},
{
filename = "pack-lyr",
@@ -807,7 +814,8 @@ return {
{
filename = "page-lin",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "will probably be overhauled some day"
},
{
filename = "page-par",
@@ -881,17 +889,18 @@ return {
{
filename = "page-imp",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "page-sel",
- marktype = "mkiv",
- status = "unknown",
+ marktype = "mkvi",
+ status = "okay",
+ comment = "maybe some extensions and maybe delayed loading, needs checking",
},
{
filename = "page-com",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "scrn-pag",
@@ -903,7 +912,7 @@ return {
filename = "scrn-wid",
marktype = "mkvi",
status = "okay",
- comment = "namespace needs checking"
+ comment = "functionality needs checking"
},
{
filename = "scrn-but",
@@ -937,7 +946,7 @@ return {
{
filename = "tabl-tab",
marktype = "mkiv",
- status = "unknown",
+ status = "delayed",
},
{
filename = "tabl-tbl",
@@ -964,7 +973,7 @@ return {
{
filename = "tabl-ltb",
marktype = "mkiv",
- status = "unknown",
+ status = "delayed",
comment = "will be redone when needed",
},
{
@@ -1237,22 +1246,24 @@ return {
{
filename = "page-flw",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "page-spr",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "page-plg",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "will be made better",
},
{
filename = "page-str",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "needs more work (and thinking)",
},
{
filename = "anch-pgr",
@@ -1269,7 +1280,8 @@ return {
{
filename = "anch-tab",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "will stay experimental for a while",
},
{
filename = "anch-bar",
@@ -1279,7 +1291,7 @@ return {
{
filename = "anch-snc",
marktype = "mkiv",
- status = "unknown",
+ status = "delayed",
comment = "interesting old mechanism to keep around (module?)",
},
{
@@ -1296,7 +1308,7 @@ return {
{
filename = "math-for",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
},
{
filename = "math-def",
@@ -1307,12 +1319,14 @@ return {
{
filename = "math-ali",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ commend = "will be checked and improved",
},
{
filename = "math-arr",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "needs testing",
},
{
filename = "math-frc",
@@ -1356,7 +1370,8 @@ return {
{
filename = "strc-mat",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "some more functionality will end up here",
},
{
filename = "chem-ini",
@@ -1376,7 +1391,7 @@ return {
-- {
-- filename = "core-fnt",
-- marktype = "mkiv",
- -- status = "unknown",
+ -- status = "todo",
-- },
{
filename = "node-rul",
@@ -1393,17 +1408,17 @@ return {
{
filename = "strc-not",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
{
filename = "strc-lnt",
marktype = "mkiv",
- status = "unknown",
+ status = "todo",
},
-- {
-- filename = "core-mis",
-- marktype = "mkiv",
- -- status = "unknown",
+ -- status = "todo",
-- },
{
filename = "pack-com",
@@ -1419,7 +1434,6 @@ return {
filename = "grph-trf",
marktype = "mkiv",
status = "okay",
- comment = "namespace has to be made consistent"
},
{
filename = "grph-inc",
@@ -1465,12 +1479,12 @@ return {
{
filename = "bibl-bib",
marktype = "mkiv",
- status = "unknown",
+ status = "delayed",
},
{
filename = "bibl-tra",
marktype = "mkiv",
- status = "unknown",
+ status = "delayed",
},
{
filename = "meta-xml",
@@ -1504,14 +1518,10 @@ return {
status = "okay",
},
{
- filename = "core-ini",
- marktype = "mkiv",
- status = "unknown",
- },
- {
filename = "core-def",
marktype = "mkiv",
- status = "unknown",
+ status = "okay",
+ comment = "will always be messy",
},
{
filename = "back-pdf",
diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex
index 99c281c00..b01ba8c86 100644
--- a/tex/context/base/status-mkiv.tex
+++ b/tex/context/base/status-mkiv.tex
@@ -24,7 +24,7 @@
[\currentdate][MkIV Status / Page \pagenumber]
% \showmakeup
-\showallmakeup
+% \showallmakeup
\starttext
@@ -51,13 +51,14 @@
name \stopitem
\startitem the message system will be unified \stopitem
\startitem maybe rename dowhatevertexcommand to fromluawhatevertexcommand \stopitem
-
+ \startitem consider moving setups directly to lua end (e.g. in characterspacing, breakpoint, bitmaps etc.) \stopitem
\stopitemize
\stoptitle
-\definehighlight[notabene][color=darkred, style=bold]
-\definehighlight[notamark][color=darkblue,style=bold]
+\definehighlight[notabenered] [color=darkred, style=bold]
+\definehighlight[notabeneblue] [color=darkblue, style=bold]
+\definehighlight[notabeneyellow][color=darkyellow,style=bold]
\startluacode
@@ -78,7 +79,8 @@
if loaded then
- local nofunknown = 0
+ local noftodo = 0
+ local nofdelayed = 0
local nofloaded = #loaded
local categories = { }
@@ -90,7 +92,6 @@
local l = loaded[i]
l.order = i
local category = string.match(l.filename,"([^%-]+)%-") or "module"
- -- print("unknown category",category)
local c = categories[category]
c[#c+1] = l
end
@@ -124,14 +125,17 @@
context.NC() context(module.filename)
context.NC()
if marktype == "mkvi" then
- context.notamark(marktype)
+ context.notabeneblue(marktype)
else
context(marktype)
end
context.NC()
- if status == "unknown" then
- context.notabene(status)
- nofunknown = nofunknown + 1
+ if status == "todo" then
+ context.notabenered(status)
+ noftodo = noftodo + 1
+ elseif status == "delayed" then
+ context.notabeneyellow(status)
+ nofdelayed = nofdelayed + 1
else
context(status)
end
@@ -151,9 +155,16 @@
context.starttitle { title = string.format("summary of %s modules",what) }
- context.starttabulate { "|B|l|" }
+ local nofdone = nofloaded - noftodo - nofdelayed
+
+ context.starttabulate { "|B|r|" }
+ context.HL()
+ context.NC() context("done") context.NC() context(nofdone) context.NC() context.NR()
+ context.NC() context("todo") context.NC() context(noftodo) context.NC() context.NR()
+ context.NC() context("delayed") context.NC() context(nofdelayed) context.NC() context.NR()
+ context.HL()
context.NC() context("loaded") context.NC() context(nofloaded) context.NC() context.NR()
- context.NC() context("unknown") context.NC() context(nofunknown) context.NC() context.NR()
+ context.HL()
context.stoptabulate()
context.stoptitle()
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index 000b74831..06fd02bdc 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -595,7 +595,7 @@
\splitfloat{\strc_floats_place_next_box_normal}}
\unexpanded\def\strc_floats_place_next_box_normal
- {\ifsomefloatwaiting
+ {\ifconditional\c_page_floats_some_waiting
% this was \checkwaitingfloats spread all over
\doifinsetelse\v!always\floatlocation
{\showmessage\m!floatblocks5\empty}
@@ -703,19 +703,15 @@
% documenteren in details
\def\strc_floats_analyze_variables_one
- {\doifelse{\floatparameter\c!local}\v!yes % fout keyword
- \globalcenterfloatboxtrue
- \globalcenterfloatboxfalse
- \ifglobalcenterfloatbox
- \localcenterfloatboxtrue
+ {\doifelse{\floatparameter\c!local}\v!yes\settrue\setfalse\c_page_floats_center_box_global % fout keyword
+ \ifconditional\c_page_floats_center_box_global
+ \settrue\c_page_floats_center_box_local
\else
- \doifinsetelse\v!local\floatlocation
- \localcenterfloatboxtrue
- \localcenterfloatboxfalse
+ \doifinsetelse\v!local\floatlocation\settrue\setfalse\c_page_floats_center_box_local
\fi
\doifnotcommon{\v!always,\v!here,\v!force}\floatlocation % ! ! ! ! ! !
- {\globalcenterfloatboxfalse
- \localcenterfloatboxfalse}}
+ {\setfalse\c_page_floats_center_box_global
+ \setfalse\c_page_floats_center_box_local}}
\let\naturalfloatheight\!!zeropoint
\let\naturalfloatwidth \!!zeropoint
@@ -817,7 +813,7 @@
\global\insidefloatfalse}
% \def\strc_floats_set_local_hsize
-% {\iflocalcenterfloatbox
+% {\ifconditional\c_page_floats_center_box_local
% \seteffectivehsize
% \hsize\localhsize
% \else
@@ -830,7 +826,7 @@
\newdimen\availablefloatheight
\def\strc_floats_set_local_hsize
- {\iflocalcenterfloatbox
+ {\ifconditional\c_page_floats_center_box_local
% also available check here?
\seteffectivehsize
\hsize\localhsize
@@ -1171,7 +1167,7 @@
\dostoptagged
\blank[\rootfloatparameter\c!spaceafter]%
\strc_floats_end_text_group
- \doinsertfloatinfo}
+ \page_floats_report_total}
\def\borderedfloatbox
{\begingroup
@@ -1756,6 +1752,8 @@
% test \placefigure{\input zapf\relax}{\externalfigure[cow.pdf][frame=on,grid=depth]} test \page
% \stoptext
+% This might move to page-flt:
+
\newif\ifpostponecolumnfloats \postponecolumnfloatsfalse % don't change
\setnewconstant\postcenterfloatmethod\plusone
@@ -1774,9 +1772,9 @@
\global\setbox\floatbox\hbox to \scratchdimen
% {\hfill\box\floatbox\hfill}} % geen \hss, gaat mis in kolommen !
% {\hss \box\floatbox\hss }} % wel \hss, anders mis in colset
- {\ifglobalcenterfloatbox
+ {\ifconditional\c_page_floats_center_box_global
\donetrue
- \else\iflocalcenterfloatbox
+ \else\ifconditional\c_page_floats_center_box_local
\donetrue
\else
\donefalse
@@ -1909,7 +1907,7 @@
{\ctxcommand{analysefloatmethod("#1")}}
\def\somesomewherefloat[#1]%
- {\dofloatssavesomewherefloat\s!somewhere{#1}}
+ {\page_floats_save_somewhere_float\s!somewhere{#1}}
\def\strc_floats_get_box
{\ifvisible
@@ -2072,45 +2070,49 @@
%D Local floats:
-\def\setuplocalfloats
- {\getparameters[\??lf]}
+\installcorenamespace{localfloats}
+\installcorenamespace{localfloatstack}
+
+\installsetuponlycommandhandler \??localfloats {localfloats}
\setuplocalfloats
[%\c!before=\blank,
%\c!after=\blank,
\c!inbetween=\blank]
-\initializeboxstack{localfloats}
+\initializeboxstack\??localfloatstack
-\newcounter\noflocalfloats
+\newcounter\c_strc_localfloats_n
-\def\resetlocalfloats
- {\doglobal\newcounter\noflocalfloats
- \initializeboxstack{localfloats}}
+\unexpanded\def\resetlocalfloats
+ {\global\c_strc_localfloats_n\zerocount
+ \initializeboxstack\??localfloatstack}
-\def\somelocalfloat
- {\doglobal\increment\noflocalfloats
- \savebox{localfloats}{\noflocalfloats}{\box\floatbox}}
+\unexpanded\def\somelocalfloat
+ {\global\advance\c_strc_localfloats_n\plusone
+ \savebox\??localfloatstack{\number\c_strc_localfloats_n}{\box\floatbox}}
-\def\getlocalfloats
- {\dorecurse\noflocalfloats
+\unexpanded\def\getlocalfloats
+ {\dorecurse\c_strc_localfloats_n
{\ifnum\recurselevel=\plusone % 1\relax
- \getvalue{\??lf\c!before}%
+ \directlocalfloatsparameter\c!before
\else
- \getvalue{\??lf\c!inbetween}%
+ \directlocalfloatsparameter\c!inbetween
\fi
- \dontleavehmode\hbox{\foundbox{localfloats}\recurselevel}%
- \ifnum\recurselevel=\noflocalfloats\relax
- \getvalue{\??lf\c!after}%
+ \dontleavehmode\hbox{\foundbox\??localfloatstack\recurselevel}%
+ \ifnum\recurselevel=\c_strc_localfloats_n\relax
+ \directlocalfloatsparameter\c!after
\fi}}
\def\flushlocalfloats
{\getlocalfloats
\resetlocalfloats}
-\unexpanded\def\getlocalfloat#1{\expanded{\foundbox{localfloats}{\number#1}}}
+\unexpanded\def\getlocalfloat#1%
+ {\normalexpanded{\foundbox{\??localfloatstack}{\number#1}}}
-\def\forcelocalfloats{\let\forcedfloatmethod\v!local}
+\unexpanded\def\forcelocalfloats
+ {\let\forcedfloatmethod\v!local}
\installfloatmethod \s!singlecolumn \v!local \somelocalfloat
\installfloatmethod \s!multicolumn \v!local \somelocalfloat
diff --git a/tex/context/base/strc-ind.mkiv b/tex/context/base/strc-ind.mkiv
index 4b65c7407..0098bff7d 100644
--- a/tex/context/base/strc-ind.mkiv
+++ b/tex/context/base/strc-ind.mkiv
@@ -57,6 +57,7 @@
\newcount\c_strc_indentedtexts_nesting
\newdimen\d_strc_indentedtexts_width
+\newdimen\d_strc_indentedtexts_distance
\appendtoks
\setuevalue {\e!start\currentindentedtext}{\strc_indentedtexts_start{\currentindentedtext}\c_strc_indentedtexts_nesting}%
@@ -67,12 +68,13 @@
\setuevalue{\v!sub\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{2}}%
\to \everydefineindentedtext
-\unexpanded\def\strc_indentedtexts_start#1#2%
+\unexpanded\def\strc_indentedtexts_start#1#2% we need to get rid of \spr
{\par
\begingroup
- \c_strc_indentedtexts_nesting#2\relax
\edef\currentindentedtext{#1}%
+ \c_strc_indentedtexts_nesting#2\relax
\indentedtextparameter\c!before
+ \d_strc_indentedtexts_distance\indentedtextparameter\c!distance\relax
\doifnothing{\indentedtextparameter\c!sample}
{\setindentedtextparameter\c!sample{\indentedtextparameter\c!text}}%
\assignwidth
@@ -81,15 +83,15 @@
{\useindentedtextstyleandcolor\c!headstyle\c!headcolor
\indentedtextparameter\c!sample
\spr{\indentedtextparameter\c!separator}}
- {\indentedtextparameter\c!distance}%
- \advance\d_strc_indentedtexts_width \indentedtextparameter\c!distance
+ {\d_strc_indentedtexts_distance}%
+ \advance\d_strc_indentedtexts_width \d_strc_indentedtexts_distance
\setbox\scratchbox\hbox to \d_strc_indentedtexts_width
{\useindentedtextstyleandcolor\c!headstyle\c!headcolor
\strut
\indentedtextparameter\c!text
\hss
\spr{\indentedtextparameter\c!separator}%
- \hskip\indentedtextparameter\c!distance}%
+ \hskip\d_strc_indentedtexts_distance}%
\parindent\zeropoint
\hskip\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
\advance\c_strc_indentedtexts_nesting\plusone
diff --git a/tex/context/base/strc-mat.mkiv b/tex/context/base/strc-mat.mkiv
index a6763e27e..7cdc68a73 100644
--- a/tex/context/base/strc-mat.mkiv
+++ b/tex/context/base/strc-mat.mkiv
@@ -54,7 +54,7 @@
\defineconversionset
[\v!formula]
- [numbers,characters]
+ [numbers,characters] % no \v! ?
\strc_counter_preset_using_parameter\setupformulas\sharedcounterparameter
@@ -68,22 +68,22 @@
\appendtoks
\normalexpanded{\definelist[\currentformula]}% is expansion needed?
- \setuevalue{\e!start\currentformula\v!formula}{\dostartformula{\currentformula}}%
- \setuevalue{\e!stop \currentformula\v!formula}{\dostopformula}%
+ \setuevalue{\e!start\currentformula\v!formula}{\strc_formulas_start_formula{\currentformula}}%
+ \setuevalue{\e!stop \currentformula\v!formula}{\strc_formulas_stop_formula}%
\to \everydefineformula
\definelist[\v!formula]
-\setuvalue{\e!start\v!formula}{\dostartformula{}}
-\setuvalue{\e!stop \v!formula}{\dostopformula}
+\setuvalue{\e!start\v!formula}{\strc_formulas_start_formula{}}
+\setuvalue{\e!stop \v!formula}{\strc_formulas_stop_formula}
-\let\dostartformula\relax % defined later
-\let\dostopformula \relax % defined later
+\let\strc_formulas_start_formula\relax % defined later
+\let\strc_formulas_stop_formula \relax % defined later
-\unexpanded\def\defineformulaalternative % this might change ... start and stop can become keys
- {\dotripleargument\dodefineformulaalternative} % to the general define .. s!startcommand
+\unexpanded\def\defineformulaalternative % this might change ... start and stop can become keys
+ {\dotripleargument\strc_formulas_define_alternative} % to the general define .. s!startcommand
-\def\dodefineformulaalternative[#1][#2][#3]%
+\def\strc_formulas_define_alternative[#1][#2][#3]%
{\setvalue{\e!start#1\v!formula}{#2}%
\setvalue{\e!stop #1\v!formula}{#3}}
@@ -126,8 +126,8 @@
% implementation
-\def\storecurrentformulanumber#1#2#3#4#5% ref, todo:str, \sync % todo: title etc (like float)
- {\settrue\handleformulanumber
+\unexpanded\def\strc_formulas_store_number#1#2#3#4#5% ref, todo:str, \sync % todo: title etc (like float)
+ {\settrue\c_strc_formulas_handle_number
\strc_counters_register_component
{formula}%
\setupcurrentformula \formulaparameter \detokenizedformulaparameter
@@ -143,68 +143,66 @@
% modes: 0=unset, 1=forced, 2=none, 3=reference
-\newconstant\placeformulanumbermode
-\newconstant\formulasnumbermode
-\newconstant\subformulasnumbermode
-\newconstant\nestedformulanumbermode
+\newconstant\c_strc_formulas_place_number_mode
+\newconstant\c_strc_formulas_number_mode
+\newconstant\c_strc_formulas_sub_number_mode
+\newconstant\c_strc_formulas_nested_number_mode
\appendtoks
- \placeformulanumbermode \zerocount
- \formulasnumbermode \zerocount
- \subformulasnumbermode \zerocount
- \nestedformulanumbermode\zerocount
+ \c_strc_formulas_place_number_mode \zerocount
+ \c_strc_formulas_number_mode \zerocount
+ \c_strc_formulas_sub_number_mode \zerocount
+ \c_strc_formulas_nested_number_mode\zerocount
\to \everyresetformulas
-\newconditional\handleformulanumber
-\newconditional\incrementformulanumber
-
-\newconditional\insideplaceformula
-\newconditional\insideplacesubformula
-\newconditional\insideformulas
-\newconditional\insidesubformulas
+\newconditional\c_strc_formulas_handle_number
+\newconditional\c_strc_formulas_increment
+\newconditional\c_strc_formulas_inside_place
+\newconditional\c_strc_formulas_inside_place_sub
+\newconditional\c_strc_formulas_inside_formulas
+\newconditional\c_strc_formulas_inside_formulas_sub
\appendtoks
- \global\setfalse\insideplaceformula
- \global\setfalse\insideplacesubformula
+ \global\setfalse\c_strc_formulas_inside_place
+ \global\setfalse\c_strc_formulas_inside_place_sub
\to \everyresetformulas
-\def\handleplaceformulanumbering % place formula
- {\settrue\handleformulanumber
- \docheckformulareference\placeformulanumbermode\currentplaceformulareference
- \glet\doplaceformulanumber \doplaceformulanumberindeed
- \glet\donestedformulanumber\donestedformulanumberindeed}
+\def\strc_formulas_place_numbering % place formula
+ {\settrue\c_strc_formulas_handle_number
+ \strc_formulas_check_reference\c_strc_formulas_place_number_mode\currentplaceformulareference
+ \glet\strc_formulas_place_number\strc_formulas_place_number_indeed
+ \glet\strc_formulas_place_number_nested\strc_formulas_place_number_nested_indeed}
-\def\handleformulasnumbering % formulas
- {\docheckformulareference\formulasnumbermode\currentformulareference}
+\def\strc_formulas_handle_number % formulas
+ {\strc_formulas_check_reference\c_strc_formulas_number_mode\currentformulareference}
-\def\handlesubformulasnumbering % sub formulas
- {\docheckformulareference\subformulasnumbermode\currentsubformulasreference
+\def\strc_formulas_handle_sub_number % sub formulas
+ {\strc_formulas_check_reference\c_strc_formulas_sub_number_mode\currentsubformulasreference
\strc_counters_increment\v!formula
- \storecurrentformulanumber
+ \strc_formulas_store_number
\currentsubformulasreference
\empty
\currentsubformulasnumber
\currentsubformulassynchronize
- \currentsubformulasattribute
- }
+ \currentsubformulasattribute}
-\let\dotraceformulareferencestate\relax
-\let\doshowformulareferencestate \relax
+\let\strc_formulas_reference_trace\relax
+\let\strc_formulas_reference_show \relax
-% \def\dotraceformulareferencestate
+% \def\strc_formulas_reference_trace
% {\rlap{\hbox{\quad\tt\txx[%
-% \number\placeformulanumbermode,%
-% \number\formulasnumbermode,%
-% \number\subformulasnumbermode,%
-% \number\nestedformulanumbermode
+% \number\c_strc_formulas_place_number_mode,%
+% \number\c_strc_formulas_number_mode,%
+% \number\c_strc_formulas_sub_number_mode,%
+% \number\c_strc_formulas_nested_number_mode
% ]}}}
-% \def\doshowformulareferencestate
+% \def\strc_formulas_reference_show
% {\writestatus{\v!formula}%
-% {place: \number\placeformulanumbermode,\space
-% formula: \number\formulasnumbermode,\space
-% subformula: \number\subformulasnumbermode,\space
-% nested: \number\nestedformulanumbermode]}}
+% {place: \number\c_strc_formulas_place_number_mode,\space
+% formula: \number\c_strc_formulas_number_mode,\space
+% subformula: \number\c_strc_formulas_sub_number_mode,\space
+% nested: \number\c_strc_formulas_nested_number_mode]}}
\unexpanded\def\placecurrentformulanumber
{\rm % nodig ?
@@ -216,12 +214,12 @@
\namedtaggedlabeltexts
\t!formulalabel \v!formula
\t!formulanumber\v!formula
- {\ignorespaces\doplacecurrentformulanumber\removeunwantedspaces}%
+ {\ignorespaces\strc_formulas_place_current_number\removeunwantedspaces}%
\formulaparameter\c!right}%
\doif{\formulaparameter\c!location}\v!left{\hskip\formulaparameter\c!distance}}
-\def\doplacecurrentformulanumber
- {\dohandlecurrentformulareferences
+\unexpanded\def\strc_formulas_place_current_number
+ {\strc_formulas_handle_current_references
\labeltexts\currentformula{\convertedcounter[\v!formula][]}}
% \def\theboxdestinationattribute#1{\iflocation\ifx#1\relax\else\ifx#1\empty\else attr \destinationattribute#1\fi\fi\fi}
@@ -281,10 +279,10 @@
% currently we do the number, some day we will do the (sub) formula
-\def\dohandlecurrentformulareferences
- {\doshowformulareferencestate
- \ifnum\placeformulanumbermode=\plusthree
- \storecurrentformulanumber
+\def\strc_formulas_handle_current_references
+ {\strc_formulas_reference_show
+ \ifnum\c_strc_formulas_place_number_mode=\plusthree
+ \strc_formulas_store_number
\currentplaceformulareference
\empty
\currentplaceformulanumber
@@ -294,8 +292,8 @@
\glet\currentplaceformulasynchronize\relax
\theformuladestinationattribute\currentplaceformulaattribute
\fi
- \ifnum\formulasnumbermode=\plusthree
- \storecurrentformulanumber
+ \ifnum\c_strc_formulas_number_mode=\plusthree
+ \strc_formulas_store_number
\currentformulasreference
\empty
\currentformulasnumber
@@ -305,12 +303,12 @@
\glet\currentformulassynchronize\relax
\theformuladestinationattribute\currentformulasattribute
\fi
- \ifnum\subformulasnumbermode=\plusthree
+ \ifnum\c_strc_formulas_sub_number_mode=\plusthree
\currentsubformulassynchronize
\glet\currentsubformulassynchronize\relax
\fi
- \ifnum\nestedformulanumbermode=\plusthree
- \storecurrentformulanumber
+ \ifnum\c_strc_formulas_nested_number_mode=\plusthree
+ \strc_formulas_store_number
\currentnestedformulareference
\empty
\currentnestedformulanumber
@@ -323,55 +321,55 @@
% needs checking ... too many:
-\def\dohandleformulanumbering
+\def\strc_formulas_handle_numbering
{\strc_counters_increment\v!formula
\doiftext\currentplaceformulasuffix{\strc_counters_setown_sub\v!formula\plustwo\currentplaceformulasuffix}%
\placecurrentformulanumber}
-\def\dohandlesubformulanumbering
+\def\strc_formulas_handle_sub_numbering
{\doiftextelse\currentsubformulasuffix
{\strc_counters_setown_sub\v!formula\plustwo\currentsubformulasuffix}
{\strc_counters_increment_sub\v!formula\plustwo}%
- \placecurrentformulanumber}
+ \placecurrentformulanumber}
-\def\dododoformulanumber
- {\ifconditional\handleformulanumber
+\def\strc_formulas_number_indeed
+ {\ifconditional\c_strc_formulas_handle_number
\hbox\bgroup
% main counter
- \ifconditional\insidesubformulas
+ \ifconditional\c_strc_formulas_inside_formulas_sub
% nothing
\else
- \ifcase\formulasnumbermode
- \ifcase\placeformulanumbermode
- \dohandleformulanumbering
+ \ifcase\c_strc_formulas_number_mode
+ \ifcase\c_strc_formulas_place_number_mode
+ \strc_formulas_handle_numbering
\or
- \dohandleformulanumbering
+ \strc_formulas_handle_numbering
\or
% nothing
\or
- \dohandleformulanumbering
+ \strc_formulas_handle_numbering
\fi
\or
- \dohandleformulanumbering
+ \strc_formulas_handle_numbering
\or
% nothing
\or
- \dohandleformulanumbering
+ \strc_formulas_handle_numbering
\fi
\fi
% subcounter
- \ifconditional\insidesubformulas
- \ifcase\subformulasnumbermode
+ \ifconditional\c_strc_formulas_inside_formulas_sub
+ \ifcase\c_strc_formulas_sub_number_mode
% nothing
\or
- \dohandlesubformulanumbering
+ \strc_formulas_handle_sub_numbering
\or
% nothing
\or
- \dohandlesubformulanumbering
+ \strc_formulas_handle_sub_numbering
\fi
\fi
- \dotraceformulareferencestate
+ \strc_formulas_reference_trace
\egroup
\fi}
@@ -393,10 +391,10 @@
%D
%D Otherwise we get a missing \type {$$} error reported.
-\def\resetdisplaymatheq
+\unexpanded\def\resetdisplaymatheq % when used?
{\let\normalleqno\gobbleoneargument \let\leqno\gobbleoneargument
\let\normalreqno\gobbleoneargument \let\eqno \gobbleoneargument
- \let\doplaceformulanumber\empty}
+ \let\strc_formulas_place_number\relax}
%D \macros
%D {startsubformulas}
@@ -431,28 +429,36 @@
% we don't use the skip's
-\def\forgetdisplayskips % to do
+\unexpanded\def\strc_formulas_forget_display_skips
{\abovedisplayskip \zeropoint
\belowdisplayskip \zeropoint
\abovedisplayshortskip\zeropoint
\belowdisplayshortskip\zeropoint}
-\def\predisplaysizethreshhold{2em} % was 3em
+% \def\predisplaysizethreshhold{2\emwidth} % was 3\emwidth
-\def\leftdisplayskip {\leftskip}
-\def\rightdisplayskip {\rightskip}
-\def\leftdisplaymargin {\formulaparameter\c!leftmargin}
-\def\rightdisplaymargin {\formulaparameter\c!rightmargin}
+\newdimen\d_strc_formulas_display_skip_left
+\newdimen\d_strc_formulas_display_skip_right
+\newdimen\d_strc_formulas_display_margin_left
+\newdimen\d_strc_formulas_display_margin_right
+\newdimen\d_strc_formulas_display_pre_threshold
+\newskip \d_strc_formulas_display_skip_par
-\def\beforedisplayspace
- {\doifnot{\formulaparameter\c!spacebefore}\v!none{\blank[\formulaparameter\c!spacebefore]}}
+\unexpanded\def\beforedisplayspace
+ {\edef\p_spacebefore{\formulaparameter\c!spacebefore}%
+ \ifx\p_spacebefore\v!none \else
+ \blank[\p_spacebefore]%
+ \fi}
-\def\afterdisplayspace
- {\doifnot{\formulaparameter\c!spaceafter }\v!none{\blank[\formulaparameter\c!spaceafter ]}}
+\unexpanded\def\afterdisplayspace
+ {\edef\p_spacebefore{\formulaparameter\c!spaceafter}%
+ \ifx\p_spaceaftere\v!none \else
+ \blank[\p_spaceafter]%
+ \fi}
-\def\setdisplaydimensions
- {\displayindent\leftdisplayskip
- \advance\displayindent\leftdisplaymargin
+\unexpanded\def\setdisplaydimensions
+ {\displayindent\d_strc_formulas_display_skip_left
+ \advance\displayindent\d_strc_formulas_display_margin_left
\displaywidth\hsize
%\setlocalhsize
%\displaywidth\localhsize
@@ -461,15 +467,14 @@
\else
\advance\displaywidth\hangindent
\fi
- \advance\displaywidth\dimexpr-\displayindent-\rightdisplayskip-\rightdisplaymargin\relax
+ \advance\displaywidth\dimexpr-\displayindent-\d_strc_formulas_display_skip_right-\d_strc_formulas_display_margin_right\relax
\hsize\displaywidth} % new, else overfull in itemize
-\unexpanded\def\dostartformula#1%
- {\dodoubleempty\dodostartformula[#1]}
+\unexpanded\def\strc_formulas_start_formula#1%
+ {\dodoubleempty\strc_formulas_start_formula_indeed[#1]}
-\newskip\formulaparskip
-\newskip\formulastrutht
-\newskip\formulastrutdp
+% \newskip\formulastrutht
+% \newskip\formulastrutdp
%D \startbuffer
%D \startformula[9pt] x = 1 \stopformula
@@ -478,38 +483,56 @@
%D
%D \typebuffer \getbuffer
-\def\dodostartformula[#1][#2]% setting leftskip adaption is slow !
+\unexpanded\def\strc_formulas_start_formula_indeed[#1][#2]% setting leftskip adaption is slow !
{\bgroup % HERE
\def\currentformula{#1}%
\dostarttagged\t!formula\currentformula
\the\everybeforedisplayformula
- \formulaparskip\parskip
- \formulastrutdp\strutdepth
- \formulastrutht\strutheight
- \doifsomething{#2}{\switchtoformulabodyfont[#2]}%
- \parskip\formulaparskip
- % may look better in itemizations
- \doif{\formulaparameter\c!option}\v!middle
- {\def\leftdisplayskip{\zeropoint}%
- \def\rightdisplayskip{\zeropoint}}%
- % this was an experiment
- \doifsomething{\formulaparameter\c!margin}% so we test first
- {\dosetleftskipadaption{\formulaparameter\c!margin}%
- \edef\leftdisplaymargin{\the\leftskipadaption}}% overloaded
- \long\def\dostartformula##1{\bgroup\dostarttagged\t!subformula\def\dostopformula{\dostoptagged\egroup}}%
- \freezedimenmacro\leftdisplayskip
- \freezedimenmacro\rightdisplayskip
- \freezedimenmacro\leftdisplaymargin
- \freezedimenmacro\rightdisplaymargin
- \freezedimenmacro\predisplaysizethreshhold
- \forgetdisplayskips
+ \d_strc_formulas_display_skip_par\parskip\relax
+ %\formulastrutdp\strutdepth
+ %\formulastrutht\strutheight
+ \edef\p_option {\formulaparameter\c!option}%
+ \edef\p_margin {\formulaparameter\c!margin}%
+ \edef\p_bodyfont{#2}%
+ %\ifx\p_bodyfont\empty
+ % \edef\p_bodyfont{\formulaparameter\c!bodyfont}%
+ %\fi
+ \ifx\p_bodyfont\empty \else
+ \switchtoformulabodyfont[#2]%
+ \fi
+ \parskip\d_strc_formulas_display_skip_par\relax
+ \ifx\p_option\v!middle
+ \d_strc_formulas_display_skip_left \zeropoint
+ \d_strc_formulas_display_skip_right\zeropoint
+ \else
+ \d_strc_formulas_display_skip_left \leftskip
+ \d_strc_formulas_display_skip_right\rightskip
+ \fi
+ \d_strc_formulas_display_margin_left \formulaparameter\c!leftmargin \relax
+ \d_strc_formulas_display_margin_right\formulaparameter\c!rightmargin\relax
+ \ifx\p_margin\empty \else
+ \dosetleftskipadaption\p_margin
+ \d_strc_formulas_display_margin_left\leftskipadaption
+ \fi
+ \let\strc_formulas_start_formula\strc_formulas_start_formula_nested
+ %\freezedimenmacro\predisplaysizethreshhold
+ \strc_formulas_forget_display_skips
\getvalue{\e!start\formulaparameter\c!alternative\v!formula}}
+\unexpanded\def\strc_formulas_start_formula_nested#1%
+ {\bgroup
+ \let\strc_formulas_stop_formula\strc_formulas_stop_formula_nested
+ \dostarttagged\t!subformula}
+
+\unexpanded\def\strc_formulas_stop_formula_nested
+ {\dostoptagged
+ \egroup}
+
% tagging of formulanumbers is not ok (we get two display maths blobs)
-\unexpanded\def\dostopformula
+\unexpanded\def\strc_formulas_stop_formula
{\dostarttagged\t!formulacaption\empty
- \doplaceformulanumber
+ \strc_formulas_place_number
\dostoptagged
\dostarttagged\t!formulacontent\empty
\getvalue{\e!stop\formulaparameter\c!alternative\v!formula}%
@@ -520,27 +543,31 @@
\egroup
\hangafter\minusone % added for side floats
\hangindent\zeropoint % added for side floats
- \setfalse\handleformulanumber
+ \setfalse\c_strc_formulas_handle_number
\the\everyresetformulas
\dorechecknextindentation} % here ?
% experiment:
\appendtoks
- \edef\currentformulagrid{\formulaparameter\c!grid}%
- \ifx\currentformulagrid\empty \else
- \spac_grids_snap_value_auto\currentformulagrid
+ \edef\p_grid{\formulaparameter\c!grid}%
+ \ifx\p_grid\empty \else
+ \spac_grids_snap_value_auto\p_grid
\fi
\to \everybeforedisplayformula
-\def\switchtoformulabodyfont{\switchtobodyfont}
+\unexpanded\def\switchtoformulabodyfont
+ {\switchtobodyfont}
-\setuvalue{\v!formula}{\dosingleempty\doformula}
+\setuvalue{\v!formula}{\dosingleempty\strc_formulas_formula}
-\def\doformula[#1]#2% todo: tagged
+\def\strc_formulas_formula[#1]#2% todo: tagged
{\begingroup
- \doifsomething{#1}{\switchtoformulabodyfont[#1]}%
- % not : \def\doformula[##1]##2{\mathematics{##2}}%
+ \edef\p_bodyfont{#1}%
+ \ifx\p_bodyfont\empty \else
+ \switchtoformulabodyfont[\p_bodyfont]%
+ \fi
+ % not : \def\strc_formulas_formula[##1]##2{\mathematics{##2}}%
\mathematics{#2}%
\endgroup}
@@ -558,7 +585,7 @@
\beforedisplayspace
\par
\ifvmode
- \prevdepth-\maxdimen % texbook pagina 79-80
+ \prevdepth-\maxdimen % texbook pagina 79-80
\fi
\noindent % else funny hlist with funny baselineskip
$$% \Ustartdisplaymath
@@ -601,26 +628,26 @@
% \fakewords{20}{40}
\unexpanded\def\startsubformulas
- {\dosingleempty\dostartsubformulas}
+ {\dosingleempty\strc_formulas_start_sub_formulas}
-\def\dostartsubformulas[#1]%
+\def\strc_formulas_start_sub_formulas[#1]%
{\edef\currentsubformulasreference{#1}%
- \global\settrue\insidesubformulas
- \handlesubformulasnumbering}
+ \global\settrue\c_strc_formulas_inside_formulas_sub
+ \strc_formulas_handle_sub_number}
\unexpanded\def\stopsubformulas
{\nonoindentation
\useindentnextparameter\subformulaparameter
\the\everyresetformulas % to be checked
- \global\setfalse\insidesubformulas
+ \global\setfalse\c_strc_formulas_inside_formulas_sub
\dorechecknextindentation} % here ?
%D Named subformulas (to be redone)
\unexpanded\def\startnamedsubformulas
- {\dosingleempty\dostartnamedsubformulas}
+ {\dosingleempty\strc_formulas_start_named_sub_formulas}
-\def\dostartnamedsubformulas[#1]#2%
+\def\strc_formulas_start_named_sub_formulas[#1]#2%
{\setformulalistentry{#2}%
\startsubformulas[#1]}
@@ -639,19 +666,19 @@
%D \typebuffer \getbuffer
\unexpanded\def\startformulas
- {\dosingleempty\dostartformulas}
+ {\dosingleempty\strc_formulas_start_formulas}
-\def\dostartformulas[#1]#2\stopformulas % new / to be internationalized
+\def\strc_formulas_start_formulas[#1]#2\stopformulas % new / to be internationalized
{\bgroup
\dostarttagged\t!formulaset\empty
- \global\settrue\insideformulas
+ \global\settrue\c_strc_formulas_inside_formulas
\edef\currentformulasreference{#1}%
- \handleformulasnumbering
+ \strc_formulas_handle_number
\let\currentformula\empty
- \forgetdisplayskips
+ \strc_formulas_forget_display_skips
\startdisplaymath
\setlocalhsize
- \long\unexpanded\def\startformula##1\stopformula
+ \unexpanded\def\startformula##1\stopformula
{\advance\scratchcounter\plusone}%
\scratchcounter\zerocount
#2% preroll
@@ -660,122 +687,135 @@
\fi
\hbox to \localhsize \bgroup
\hss
- \def\normalstartformula{\vskip-\strutdepth\Ustartdisplaymath}% i hate this
- \def\normalstopformula {\Ustopdisplaymath}%
- \unexpanded\def\startformula {\Ustartmath\vcenter\bgroup\normalstartformula}%
- \unexpanded\def\stopformula {\normalstopformula\egroup\Ustopmath\hss}%
+ \let\startformula\strc_formulas_nested_formula_start
+ \let\stopformula \strc_formulas_nested_formula_stop
#2%
\egroup
\stopdisplaymath
- \global\setfalse\insideformulas
+ \global\setfalse\c_strc_formulas_inside_formulas
\dostoptagged
\egroup
\the\everyresetformulas
\hangafter\minusone % added for side floats
\hangindent\zeropoint} % added for side floats
+\unexpanded\def\strc_formulas_nested_formula_start
+ {\Ustartmath
+ \vcenter\bgroup
+ \vskip-\strutdepth
+ \Ustartdisplaymath}
+
+\unexpanded\def\strc_formulas_nested_formula_stop
+ {\Ustopdisplaymath
+ \egroup
+ \Ustopmath
+ \hss}
+
% place
-\def\inhibitformulanumberflag{-}
-\def\forceformulanumberflag {+}
+\def\m_strc_formulas_flag_inhibit{-}
+\def\m_strc_formulas_flag_force {+}
-\def\docheckformulareference#1#2%
+\def\strc_formulas_check_reference#1#2%
{#1\unless\ifx\namedformulaentry\empty % \relax % new 29/8/2010
\plusthree
\else\ifx#2\empty
\zerocount
- \else\ifx#2\forceformulanumberflag
+ \else\ifx#2\m_strc_formulas_flag_force
\plusone
- \else\ifx#2\inhibitformulanumberflag
+ \else\ifx#2\m_strc_formulas_flag_inhibit
\plustwo
\else
\plusthree
\fi\fi\fi\fi}
-\unexpanded\def\formulanumber{\doformulanumber} % for the moment
+\unexpanded\def\formulanumber
+ {\strc_formulas_number} % for the moment
-\def\doformulanumber
- {\dosingleempty\dodoformulanumber}
+\def\strc_formulas_number
+ {\dosingleempty\strc_formulas_number_again}
-\def\dodoformulanumber[#1]%
+\def\strc_formulas_number_again[#1]%
{\def\currentformulareference{#1}%
- \dosinglegroupempty\dododoformulanumber}
-
-\def\redoformulanumber#1%
- {\def\currentformulasuffix{#1}%
- \dododoformulanumber}
+ \dosinglegroupempty\strc_formulas_number_indeed}
\unexpanded\def\placeformula
- {\global\settrue\insideplaceformula
- \settrue\incrementformulanumber
- \dosingleempty\doplaceformula}
+ {\global\settrue\c_strc_formulas_inside_place
+ \settrue\c_strc_formulas_increment
+ \dosingleempty\strc_formulas_place}
\unexpanded\def\placesubformula
- {\global\settrue\insideplacesubformula
- \setfalse\incrementformulanumber
- \dosingleempty\doplaceformula}
+ {\global\settrue\c_strc_formulas_inside_place_sub
+ \setfalse\c_strc_formulas_increment
+ \dosingleempty\strc_formulas_place}
-\def\doplaceformula[#1]%
+\def\strc_formulas_place[#1]%
{\def\currentplaceformulareference{#1}%
\let\currentplaceformulasuffix\empty
- \doifnextbgroupelse\moreplaceformula\redoplaceformula} % [ref]{}
+ \doifnextbgroupelse\strc_formulas_place_yes\strc_formulas_place_nop\strc_formulas_place_nop} % [ref]{}
-\def\moreplaceformula#1%
+\def\strc_formulas_place_yes#1%
{\def\currentplaceformulasuffix{#1}%
- \redoplaceformula}
+ \strc_formulas_place_nop}
-\def\redoplaceformula
- {\doifnextcharelse$\dispplaceformula\dodoplaceformula} % [ref]$$ [ref]\start
+\def\strc_formulas_place_nop
+ {\doifnextcharelse$\strc_formulas_place_pickup\strc_formulas_place_indeed} % [ref]$$ [ref]\start
-\def\dodoplaceformula
- {\handleplaceformulanumbering}
+\def\strc_formulas_place_indeed
+ {\strc_formulas_place_numbering}
-\def\dispplaceformula$$#1$$%
- {\handleplaceformulanumbering
- \dostartformula{}#1\dostopformula}
+\def\strc_formulas_place_pickup$$#1$$%
+ {\strc_formulas_place_numbering
+ \strc_formulas_start_formula{}#1\strc_formulas_stop_formula}
\let\startplaceformula\placeformula
\let\stopplaceformula \relax
% to be checked
-\let\doplaceformulanumber \relax
-\let\donestedformulanumber\gobbletwoarguments
+\let\strc_formulas_place_number \relax
+\let\strc_formulas_place_number_nested\gobbletwoarguments
-\def\donestedformulanumberindeed#1#2%
+\def\strc_formulas_place_number_nested_indeed#1#2%
{\def\currentnestedformulareference{#1}%
\def\currentnestedformulasuffix{#2}%
- \glet\doplaceformulanumber\relax
- \docheckformulareference\nestedformulanumbermode\currentnestedformulareference
- \ifcase\nestedformulanumbermode
+ \glet\strc_formulas_place_number\relax
+ \strc_formulas_check_reference\c_strc_formulas_nested_number_mode\currentnestedformulareference
+ \ifcase\c_strc_formulas_nested_number_mode
% nothing
\or
- \doformulanumber
+ \strc_formulas_number % hm, looks ahead for []
\or
% nothing
\or
- \doformulanumber
+ \strc_formulas_number % hm, looks ahead for []
\fi}
-\def\doplaceformulanumberindeed
- {\glet\doplaceformulanumber\relax
+\def\strc_formulas_place_number_indeed
+ {\glet\strc_formulas_place_number\relax
\doifelse{\formulaparameter\c!location}\v!left
- {\normalleqno{\dododoformulanumber}}
- {\normalreqno{\dododoformulanumber}}}
+ {\normalleqno{\strc_formulas_number_indeed}}
+ {\normalreqno{\strc_formulas_number_indeed}}}
% todo
\unexpanded\def\placenamedformula
- {\dosingleempty\doplacenamedformula}
+ {\dosingleempty\strc_formulase_place_named}
-\def\doplacenamedformula[#1]#2%
+\def\strc_formulase_place_named[#1]#2%
{\iffirstargument
- \def\next{\placeformula[#1]}%
+ \expandafter\strc_formulase_place_named_yes
\else
- \let\next\placeformula
- \fi
- \setformulalistentry{#2}%
- \next}
+ \expandafter\strc_formulase_place_named_nop
+ \fi}
+
+\def\strc_formulase_place_named_yes[#1]#2%
+ {\setformulalistentry{#2}%
+ \placeformula[#1]}
+
+\def\strc_formulase_place_named_nop[#1]#2%
+ {\setformulalistentry{#2}%
+ \placeformula}
\let\namedformulaentry\empty % \relax % this will become a key/value so that we can do bookmarks
diff --git a/tex/context/base/strc-num.mkiv b/tex/context/base/strc-num.mkiv
index 9c08693be..52e4960fa 100644
--- a/tex/context/base/strc-num.mkiv
+++ b/tex/context/base/strc-num.mkiv
@@ -507,22 +507,18 @@
% \m_strc_counters_last_registered_attribute
% \m_strc_counters_last_registered_synchronize
-\newconditional\hascountercaption
-\newconditional\hascountertitle
-\newconditional\hascounternumber
-
\unexpanded\def\strc_counters_register_component#1#2#3#4#5#6#7[#8][#9]% maybe also nolist
{\begingroup
%
#2[\s!haslevel=1,#8]%
- \edef\hascounterlevel {#3\s!haslevel}%
- \edef\hascountercaption{#3\s!hascaption}%
- \edef\hascountertitle {#3\s!hastitle}%
- \edef\hascounternumber {#3\s!hasnumber}%
+ \edef\p_haslevel {#3\s!haslevel}%
+ \edef\p_hascaption{#3\s!hascaption}%
+ \edef\p_hastitle {#3\s!hastitle}%
+ \edef\p_hasnumber {#3\s!hasnumber}%
%
- \edef\askedprefixsegments{#3\c!prefixsegments}%
- \ifx\askedprefixsegments\v!auto
- \edef\askedprefixsegments{\autostructureprefixsegments#3}%
+ \edef\p_prefixsegments{#3\c!prefixsegments}%
+ \ifx\p_prefixsegments\v!auto
+ \edef\p_prefixsegments{\autostructureprefixsegments#3}%
\fi
%
\edef\currentname{#3\c!name}%
@@ -534,7 +530,7 @@
\let\currentcounter\currentname
\fi
%
- \ifx\hascountercaption\v!yes
+ \ifx\p_hascaption\v!yes
\xdef\currentstructurecomponentname {#3\c!name}%
\xdef\currentstructurecomponentlevel {#3\c!level}%
\edef\currentstructurecomponentexpansion {#3\c!expansion}%
@@ -613,7 +609,7 @@
list = \!!bs\detokenize\expandafter{\currentstructurecomponentlist}\!!es,
\fi
},
- \ifx\hascounternumber\v!yes
+ \ifx\p_hasnumber\v!yes
prefixdata = {
prefix = "#3\c!prefix",
separatorset = "#3\c!prefixseparatorset",
@@ -621,7 +617,7 @@
conversionset = "#3\c!prefixconversionset",
set = "#3\c!prefixset",
% segments = "#3\c!prefixsegments",
- segments = "\askedprefixsegments",
+ segments = "\p_prefixsegments",
connector = \!!bs#3\c!prefixconnector\!!es,
},
numberdata = {
@@ -637,7 +633,7 @@
userdata = \!!bs\detokenize{#9}\!!es % will be converted to table at the lua end
}
}}%
- \xdef\m_strc_counters_last_registered_attribute {\ctxlua {tex.write(structures.references.setinternalreference(nil,nil,\nextinternalreference))}}%
+ \xdef\m_strc_counters_last_registered_attribute {\ctxcommand {setinternalreference(nil,nil,\nextinternalreference)}}%
\xdef\m_strc_counters_last_registered_synchronize{\ctxlatecommand{enhancelist(\m_strc_counters_last_registered_index)}}%
\else
\glet\m_strc_counters_last_registered_index \relax
diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv
index e3828464c..cb7cd8b23 100644
--- a/tex/context/base/strc-pag.mkiv
+++ b/tex/context/base/strc-pag.mkiv
@@ -123,8 +123,10 @@
\savecurrentpagestate
\to \everyshipout
-\def\pushpagestate{\setxvalue{\??nm:\s!userpage:\c!state}{\counterparameter\s!userpage\c!state}}
-\def\poppagestate {\normalexpanded{\setuppagenumber[\c!state=\getvalue{\??nm:\s!userpage:\c!state}]}}
+\installcorenamespace{pagestatestack} % no level yet
+
+\unexpanded\def\pushpagestate{\setxvalue{\??pagestatestack\c!state}{\counterparameter\s!userpage\c!state}}
+\unexpanded\def\poppagestate {\normalexpanded{\setuppagenumber[\c!state=\getvalue{\??pagestatestack\c!state}]}}
\setuppagenumber
[\c!way=\v!by\v!text,
@@ -249,25 +251,28 @@
% Page numbers: (can move to lua) ... inconsistent names
+\installcorenamespace{pagenumberinc}
+\installcorenamespace{pagenumberdec}
+
\def\dodecrementpagenumber {\global\userpageno\strc_counters_decremented\s!userpage\relax}
\def\doincrementpagenumber {\global\userpageno\strc_counters_incremented\s!userpage\relax}
\def\decrementsubpagenumber{\global\subpageno \strc_counters_decremented\s!subpage \relax}
\def\incrementsubpagenumber{\global\subpageno \strc_counters_incremented\s!subpage \relax}
-\def\dosynchronizepagenumber{\global\let\@@pnstate\v!start}
+\def\dosynchronizepagenumber{\global\userpagenumberstate\plustwo} % start and visible
-\def\decrementpagenumber{\csname\??pn-\counterparameter\s!userpage\c!state\endcsname}
-\def\incrementpagenumber{\csname\??pn+\counterparameter\s!userpage\c!state\endcsname}
+\def\decrementpagenumber{\csname\??pagenumberdec\counterparameter\s!userpage\c!state\endcsname}
+\def\incrementpagenumber{\csname\??pagenumberinc\counterparameter\s!userpage\c!state\endcsname}
-\letvalue{\??pn-\v!start}\dodecrementpagenumber
-\letvalue{\??pn-\v!none }\dodecrementpagenumber
-\letvalue{\??pn-\v!empty}\dodecrementpagenumber
+\letvalue{\??pagenumberdec\v!start}\dodecrementpagenumber
+\letvalue{\??pagenumberdec\v!none }\dodecrementpagenumber
+\letvalue{\??pagenumberdec\v!empty}\dodecrementpagenumber
-\letvalue{\??pn+\v!start}\doincrementpagenumber
-\letvalue{\??pn+\v!none }\doincrementpagenumber
-\setvalue{\??pn+\v!empty}{\doincrementpagenumber\dosynchronizepagenumber}
-\letvalue{\??pn+\v!keep }\dosynchronizepagenumber
+\letvalue{\??pagenumberinc\v!start}\doincrementpagenumber
+\letvalue{\??pagenumberinc\v!none }\doincrementpagenumber
+\setvalue{\??pagenumberinc\v!empty}{\doincrementpagenumber\dosynchronizepagenumber}
+\letvalue{\??pagenumberinc\v!keep }\dosynchronizepagenumber
% Control:
@@ -281,18 +286,14 @@
% Setup general page numbering
-\newtoks\everysetuppagenumbering
-
-\unexpanded\def\setuppagenumbering
- {\dosingleempty\dosetuppagenumbering}
+\installcorenamespace{pagenumbering}
-\def\dosetuppagenumbering[#1]%
- {\getparameters[\??nm][#1]\the\everysetuppagenumbering}
+\installdirectcommandhandler \??pagenumbering {pagenumbering}
\appendtoks
\singlesidedfalse \setfalse\layoutisdoublesided
\doublesidedfalse \setfalse\layoutissinglesided
- \normalexpanded{\noexpand\processallactionsinset[\@@nmalternative]}
+ \normalexpanded{\processallactionsinset[\directpagenumberingparameter\c!alternative]}
[ \v!singlesided=>\singlesidedtrue\settrue\layoutissinglesided,
\v!doublesided=>\doublesidedtrue\settrue\layoutisdoublesided]%
\ifdefined\trackingmarginnotestrue
@@ -314,8 +315,13 @@
\let\dosetpagenumberlocation\relax
\fi
-\def\flushfinallayoutpage
- {\doifsomething\@@nmpage{\doifnot\@@nmpage\v!no{\page[\@@nmpage]}}}
+\unexpanded\def\flushfinallayoutpage
+ {\edef\p_page_numbering_page{\directpagenumberingparameter\c!page}%
+ \ifx\p_page_numbering_page\empty \else
+ \ifx\p_page_numbering_page\v!no \else
+ \page[\p_page_numbering_page]
+ \fi
+ \fi}
% The numbered location handler is there because we need to be downward
% compatible. So, in fact there can be multiple handlers active at the
@@ -326,11 +332,13 @@
\unexpanded\def\placelocationpagenumber
{\ifnum\userpagenumberstate=\plustwo
\ifnum\overallpagenumberstate=\plusone
- \doif\@@nmstrut\v!yes\strut
+ \doif{\directpagenumberingparameter\c!strut}\v!yes\strut
\begingroup
- \dousestyleparameter\@@nmstyle
- \dousecolorparameter\@@nmcolor
- \@@nmcommand{\@@nmleft\labeltexts\v!pagenumber{\prefixedpagenumber}\@@nmright}%
+ \usepagenumberingstyleandcolor\c!style\c!color
+ \directpagenumberingparameter\c!command
+ {\directpagenumberingparameter\c!left
+ \labeltexts\v!pagenumber\prefixedpagenumber
+ \directpagenumberingparameter\c!right}%
\endgroup
\fi
\fi}
@@ -338,7 +346,9 @@
\unexpanded\def\completepagenumber
{\ifnum\userpagenumberstate=\plustwo
\ifnum\overallpagenumberstate=\plusone
- \@@nmleft\labeltexts\v!pagenumber\prefixedpagenumber\@@nmright
+ \directpagenumberingparameter\c!left
+ \labeltexts\v!pagenumber\prefixedpagenumber
+ \directpagenumberingparameter\c!right
\fi
\fi}
@@ -382,7 +392,7 @@
\to \everysetupsubpagenumber
\appendtoks % todo: set state: none, start, stop, reset
- \doifelse\@@nmstate\v!start
+ \doifelse{\directpagenumberingparameter\c!state}\v!start
{\overallpagenumberstate\plusone }%
{\overallpagenumberstate\zerocount}%
\to \everysetuppagenumbering
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 2d6e0a1fe..16cb91373 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -1670,7 +1670,6 @@ function references.setandgetattribute(kind,prefix,tag,data,view) -- maybe do in
return attr
end
-commands.setinternalreference = references.setinternalreference
commands.setreferenceattribute = references.setandgetattribute
function references.getinternalreference(n) -- n points into list (todo: registers)
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index 760a6babb..c11b49bd3 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -118,10 +118,10 @@
%D These are implemented in a low level form as:
-\def\strc_references_text_reference [#labels]{\strc_references_set_named_reference\s!text{#labels}{}}
-\def\strc_references_page_reference [#labels]{\strc_references_set_named_reference\s!page{#labels}{}{}}
-\def\strc_references_full_reference [#labels]{\strc_references_set_named_reference\s!full{#labels}{}}
-\def\strc_references_set_reference[#labels][#settings]{\strc_references_set_named_reference\s!user{#labels}{#settings}{}}
+\unexpanded\def\strc_references_text_reference [#labels]{\strc_references_set_named_reference\s!text{#labels}{}}
+\unexpanded\def\strc_references_page_reference [#labels]{\strc_references_set_named_reference\s!page{#labels}{}{}}
+\unexpanded\def\strc_references_full_reference [#labels]{\strc_references_set_named_reference\s!full{#labels}{}}
+\unexpanded\def\strc_references_set_reference[#labels][#settings]{\strc_references_set_named_reference\s!user{#labels}{#settings}{}}
%D Actually there is not much difference between a text and a
%D full reference, but it's the concept that counts. The low
@@ -138,7 +138,7 @@
\def\dofinishsomereference#kind{\executeifdefined{dofinish#{kind}reference}\gobbletwoarguments}
-\def\strc_references_set_named_reference
+\unexpanded\def\strc_references_set_named_reference
{\ifreferencing
\expandafter\strc_references_set_named_reference_indeed
\else
@@ -1449,14 +1449,18 @@
%D
%D \showsetup{setupurl}
-\unexpanded\def\setupurl
- {\dodoubleargument\getparameters[\??ur]}
+\installcorenamespace{url}
+
+\installdirectcommandhandler \??url {url}
+
+\setupurl
+ [\c!style=\v!type,
+ \c!color=]
\unexpanded\def\url[#label]% move \hyphenatedurl to lua end (is already lua)
{\dontleavehmode
\begingroup
- \dousestyleparameter\@@urstyle
- \dousecolorparameter\@@urcolor
+ \useurlstyleandcolor\c!style\c!color
\hyphenatedurl{\ctxcommand{geturl("#label")}}%
\endgroup}
@@ -1526,8 +1530,9 @@
% also lua, like urls and files
-\unexpanded\def\setupprograms
- {\dodoubleargument\getparameters[\??pr]}
+\installcorenamespace{programs}
+
+\installdirectcommandhandler \??programs {programs}
\unexpanded\def\defineprogram
{\dotripleargument\strc_references_define_program}
@@ -1538,9 +1543,8 @@
\def\program[#name]% incompatible, more consistent, hardy used anyway
{\dontleavehmode
\begingroup
- \dousestyleparameter\@@prstyle
- \dousecolorparameter\@@prcolor
- \ctxcommand{getprogram("#name","\@@pralternative","\@@prspace")}%
+ \useprogramsstyleandcolor\c!style\c!color
+ \ctxcommand{getprogram("#name","\directprogramsparameter\c!alternative","\directprogramsparameter\c!space")}%
\endgroup}
%D As we can see, we directly use the special reference
@@ -1665,10 +1669,6 @@
\c!separator=\nonbreakablespace,
\c!export=\v!no]
-\setupurl
- [\c!style=\v!type,
- \c!color=]
-
\setupprograms
[\c!directory=,
\c!style=\v!type,
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index e36556949..7ac21761d 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -47,7 +47,7 @@
% \index[pageclass::key]{textclass::entry}
%D Parameters ... we set up levels so we need a slightly different command handler here .. okay, we
-%D can use the childs for that ... but then we need to tweak the name in order to distinguis:
+%D can use the childs for that ... but then we need to tweak the name in order to distinguish:
%D register -> register:1 (i.e. prefix)
\let\currentregister\empty
diff --git a/tex/context/base/strc-tag.mkiv b/tex/context/base/strc-tag.mkiv
index 84d6fb2d3..b84efc92c 100644
--- a/tex/context/base/strc-tag.mkiv
+++ b/tex/context/base/strc-tag.mkiv
@@ -332,4 +332,12 @@
\unexpanded\def\settaggedmetadata[#1]%
{\ctxlua{structures.tags.registermetadata(\!!bs#1\!!es)}}
+%D An overload:
+
+\let\strc_tagged_saved_bpar\bpar
+\let\strc_tagged_saved_epar\epar
+
+\unexpanded\def\bpar{\dostarttagged\t!paragraph\empty\strc_tagged_saved_bpar}
+\unexpanded\def\epar{\strc_tagged_saved_epar\dostoptagged}
+
\protect
diff --git a/tex/context/base/supp-mat.mkiv b/tex/context/base/supp-mat.mkiv
index 21871e80d..0c2402671 100644
--- a/tex/context/base/supp-mat.mkiv
+++ b/tex/context/base/supp-mat.mkiv
@@ -91,7 +91,12 @@
%D
%D An example of usage of the following can be found in the MathML module:
-\unexpanded\def\displaymathematics#1{\relax\ifmmode#1\else\dostartformula{}#1\dostopformula\fi}
+\ifdefined\strc_formulas_start_formula \else
+ \def\strc_formulas_start_formula{\normalstartdmath}
+ \def\strc_formulas_stop_formula {\normalstopdmath }
+\fi
+
+\unexpanded\def\displaymathematics#1{\relax\ifmmode#1\else\strc_formulas_start_formula{}#1\strc_formulas_stop_formula\fi}
\unexpanded\def\inlinemathematics {\dontleavehmode\mathematics}
\unexpanded\def\automathematics {\relax\ifhmode\expandafter\inlinemathematics\else\expandafter\displaymathematics\fi}
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index 092b5b227..0de742bd3 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -60,12 +60,12 @@
%D As we don't have namespace definers yet, we use a special one:
-\newcount\c_syst_helpers_n_of_namespaces
+\newcount\c_syst_helpers_n_of_namespaces \c_syst_helpers_n_of_namespaces\pluseight % 1-8 reserved for catcodes
\def\v_interfaces_prefix_template_system{\number \c_syst_helpers_n_of_namespaces>>}
%def\v_interfaces_prefix_template_system{\characters\c_syst_helpers_n_of_namespaces>>} % no \characters yet
-\unexpanded\def\installsystemnamespace#1%
+\unexpanded\def\installsystemnamespace#1% maybe move this to syst-ini
{\ifcsname ??#1\endcsname
\writestatus\m!system{duplicate system namespace '#1'}\wait
\else
@@ -2428,37 +2428,37 @@
{\syst_helpers_seventuple_empty_one_yes#1}%
{\syst_helpers_seventuple_empty_one_nop#1}}
-\def\syst_helpers_seventuple_empty_one#1[#2]%
+\def\syst_helpers_seventuple_empty_one_yes#1[#2]%
{\firstargumenttrue
\doifnextoptionalelse
{\syst_helpers_seventuple_empty_two_yes#1{#2}}%
{\syst_helpers_seventuple_empty_two_nop#1{#2}}}
-\def\syst_helpers_seventuple_empty_two#1#2[#3]%
+\def\syst_helpers_seventuple_empty_two_yes#1#2[#3]%
{\secondargumenttrue
\doifnextoptionalelse
{\syst_helpers_seventuple_empty_three_yes#1{#2}{#3}}%
{\syst_helpers_seventuple_empty_three_nop#1{#2}{#3}}}
-\def\syst_helpers_seventuple_empty_three#1#2#3[#4]%
+\def\syst_helpers_seventuple_empty_three_yes#1#2#3[#4]%
{\thirdargumenttrue
\doifnextoptionalelse
{\syst_helpers_seventuple_empty_four_yes#1{#2}{#3}{#4}}%
{\syst_helpers_seventuple_empty_four_nop#1{#2}{#3}{#4}}}
-\def\syst_helpers_seventupleempty_four#1#2#3#4[#5]%
+\def\syst_helpers_seventupleempty_four_yes#1#2#3#4[#5]%
{\fourthargumenttrue
\doifnextoptionalelse
{\syst_helpers_seventuple_empty_five_yes#1{#2}{#3}{#4}{#5}}%
{\syst_helpers_seventuple_empty_five_nop#1{#2}{#3}{#4}{#5}}}
-\def\syst_helpers_seventuple_empty_five#1#2#3#4#5[#6]%
+\def\syst_helpers_seventuple_empty_five_yes#1#2#3#4#5[#6]%
{\fifthargumenttrue
\doifnextoptionalelse
{\syst_helpers_seventuple_empty_six_yes#1{#2}{#3}{#4}{#5}{#6}}%
{\syst_helpers_seventuple_empty_six_nop#1{#2}{#3}{#4}{#5}{#6}}}
-\def\syst_helpers_seventuple_empty_six#1#2#3#4#5#6[#7]%
+\def\syst_helpers_seventuple_empty_six_yes#1#2#3#4#5#6[#7]%
{\sixthargumenttrue
\doifnextoptionalelse
{\seventhargumenttrue#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}]}%
@@ -2537,18 +2537,18 @@
\expandafter\syst_helpers_seventuple_empty_seven_normal
\fi}
-\def\syst_helpers_seventuple_empty_spaced_two #1#2{#1[{#2}][][][][][][] }
-\def\syst_helpers_seventuple_empty_normal_two #1#2{#1[{#2}][][][][][][]}
-\def\syst_helpers_seventuple_empty_spaced_three #1#2#3{#1[{#2}][{#3}][][][][][] }
-\def\syst_helpers_seventuple_empty_normal_three #1#2#3{#1[{#2}][{#3}][][][][][]}
-\def\syst_helpers_seventuple_empty_spaced_four #1#2#3#4{#1[{#2}][{#3}][{#4}][][][][] }
-\def\syst_helpers_seventuple_empty_normal_four #1#2#3#4{#1[{#2}][{#3}][{#4}][][][][]}
-\def\syst_helpers_seventuple_empty_spaced_five #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][][] }
-\def\syst_helpers_seventuple_empty_normal_five #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][][]}
-\def\syst_helpers_seventuple_empty_spaced_six #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][][] }
-\def\syst_helpers_seventuple_empty_normal_six #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][][]}
-\def\syst_helpers_seventuple_empty_spaced_seven#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][] }
-\def\syst_helpers_seventuple_empty_normal_seven#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][]}
+\def\syst_helpers_seventuple_empty_two_spaced #1#2{#1[{#2}][][][][][][] }
+\def\syst_helpers_seventuple_empty_two_normal #1#2{#1[{#2}][][][][][][]}
+\def\syst_helpers_seventuple_empty_three_spaced #1#2#3{#1[{#2}][{#3}][][][][][] }
+\def\syst_helpers_seventuple_empty_three_normal #1#2#3{#1[{#2}][{#3}][][][][][]}
+\def\syst_helpers_seventuple_empty_four_spaced #1#2#3#4{#1[{#2}][{#3}][{#4}][][][][] }
+\def\syst_helpers_seventuple_empty_four_normal #1#2#3#4{#1[{#2}][{#3}][{#4}][][][][]}
+\def\syst_helpers_seventuple_empty_five_spaced #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][][] }
+\def\syst_helpers_seventuple_empty_five_normal #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][][]}
+\def\syst_helpers_seventuple_empty_six_spaced #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][][] }
+\def\syst_helpers_seventuple_empty_six_normal #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][][]}
+\def\syst_helpers_seventuple_empty_seven_spaced#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][] }
+\def\syst_helpers_seventuple_empty_seven_normal#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][]}
%D \macros
%D {strippedcsname}
@@ -6592,6 +6592,39 @@
\unexpanded\def\signalcharacter{\char\zerocount} % \zwj
+%D A few secial variants of commands defined here. Some more will be moved here (e.g.
+%D from table modules.
+
+\def\dodirectdoubleempty#1#2% used in math (lookahead issues)
+ {\ifx#2[%
+ \expandafter\syst_helpers_direct_double_empty_one_yes
+ \else
+ \expandafter\syst_helpers_direct_double_empty_one_nop
+ \fi#1#2}
+
+\def\syst_helpers_direct_double_empty_one_yes#1[#2]#3%
+ {\ifx#3[\else\expandafter\syst_helpers_direct_double_empty_two_nop\fi#1[#2]#3}
+
+\def\syst_helpers_direct_double_empty_one_nop#1{#1[][]}
+\def\syst_helpers_direct_double_empty_two_nop#1[#2]{#1[#2][]}
+
+%D Used in math definitions (in an type {\edef}):
+
+%D \startbuffer
+%D [\docheckedpair{}]
+%D [\docheckedpair{a}]
+%D [\docheckedpair{a,b}]
+%D [\docheckedpair{a,b,c}]
+%D \stopbuffer
+%D
+%D \typebuffer \startlines \getbuffer \stoplines
+
+\def\docheckedpair#1%
+ {\syst_helpers_checked_pair#1,,\_o_e_p_}
+
+\def\syst_helpers_checked_pair#1,#2,#3\_o_e_p_
+ {#1,#2}
+
%D Here are some nasty helpers. They can be used to fill often expanded token
%D lists efficiently (see tabulate for an example).
diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv
index b459ffffd..4dcc134ea 100644
--- a/tex/context/base/syst-ini.mkiv
+++ b/tex/context/base/syst-ini.mkiv
@@ -376,14 +376,16 @@
%D More allocations:
-\newskip \zeroskip \zeroskip = 0pt plus 0pt minus 0pt
-\newdimen\zeropoint \zeropoint = 0pt
-\newdimen\onepoint \onepoint = 1pt
-\newdimen\halfapoint \halfapoint = 0.5pt
-\newdimen\maxdimen \maxdimen = 16383.99999pt
-\newdimen\onebasepoint \onebasepoint = 1bp
-\newdimen\scaledpoint \scaledpoint = 1sp
-\newdimen\thousandpoint \thousandpoint = 1000pt
+\newskip \zeroskip \zeroskip = 0pt plus 0pt minus 0pt
+\newdimen \zeropoint \zeropoint = 0pt
+\newdimen \onepoint \onepoint = 1pt
+\newdimen \halfapoint \halfapoint = 0.5pt
+\newdimen \maxdimen \maxdimen = 16383.99999pt
+\newdimen \onebasepoint \onebasepoint = 1bp
+\newdimen \scaledpoint \scaledpoint = 1sp
+\newdimen \thousandpoint \thousandpoint = 1000pt
+\newmuskip\zeromuskip \zeromuskip = 0mu
+\newmuskip\onemuskip \onemuskip = 1mu
\let\points \onepoint
\let\halfpoint\halfapoint
@@ -822,7 +824,13 @@
\def\begcsname#1\endcsname{\ifcsname#1\endcsname\csname#1\endcsname\fi}
-%D Now come a few macros that might be needed in successive loading:
+%D Now come a few macros that might be needed in successive loading. We redefine the
+%D \type {\par} primitive pretty soon so that we get the equivalents right.
+
+\newtoks\everyendpar
+
+\normalprotected\def\endpar{\the\everyendpar\normalpar}
+\normalprotected\def\par {\endpar}
\let\endgraf\par
\let\endline\cr
diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv
index 4d2f8cc15..fca724b71 100644
--- a/tex/context/base/tabl-ntb.mkiv
+++ b/tex/context/base/tabl-ntb.mkiv
@@ -157,7 +157,7 @@
\newcount\c_tabl_level
-\def\tabl_ntb_table_push
+\unexpanded\def\tabl_ntb_table_push
{\ifnum\m_tabl_tbl_level>\plusone
\tabl_ntb_parameters_reset
% we need a proper count push/pop
@@ -167,7 +167,7 @@
\global\intabletrue
\fi}
-\def\tabl_ntb_table_pop
+\unexpanded\def\tabl_ntb_table_pop
{\ifnum\m_tabl_tbl_level>\plusone
\globalpopmacro\m_tabl_ntb_saved_row\global\c_tabl_ntb_row\m_tabl_ntb_saved_row
\globalpopmacro\m_tabl_ntb_saved_col\global\c_tabl_ntb_col\m_tabl_ntb_saved_col
@@ -175,11 +175,11 @@
\global\intablefalse
\fi}
-\def\tabl_tnb_next_level
+\unexpanded\def\tabl_tnb_next_level
{\advance\c_tabl_level\plusone
\edef\m_tabl_tbl_level{\the\c_tabl_level}}
-\def\tabl_tnb_prev_level
+\unexpanded\def\tabl_tnb_prev_level
{\advance\c_tabl_level\minusone
\edef\m_tabl_tbl_level{\the\c_tabl_level}}
diff --git a/tex/context/base/tabl-tab.mkiv b/tex/context/base/tabl-tab.mkiv
index b50be8531..20ea1d766 100644
--- a/tex/context/base/tabl-tab.mkiv
+++ b/tex/context/base/tabl-tab.mkiv
@@ -854,11 +854,8 @@
\lineskiplimit\zeropoint
\lineskip \zeropoint
\tabskip \zeropoint
- \doifelsenothing\@@titextwidth
- {\halign}
- {\doifelse\@@titextwidth\v!max
- {\halign to \hsize}
- {\halign to \@@titextwidth}}%
+ \edef\p_tabl_table_textwidth{\directtablesparameter\c!textwidth}%
+ \halign \ifx\p_tabl_table_textwidth\empty \else to \ifx\p_tabl_table_textwidth\v!max \hsize \else \p_tabl_table_textwidth \fi\fi
% \the\!taTableSpread
\bgroup
\span
@@ -1330,26 +1327,38 @@
\newconditional\tablerepeathead
\newconditional\tablerepeattail
-
\unexpanded\def\starttable
{\bgroup
\dodoubleempty\dostarttable}
\unexpanded\def\dostarttable[#1][#2]% preamble optional-settings
{\ifsecondargument
- \getparameters[\??ti][#2]%
+ \setupcurrenttables[#2]%
\fi
\let\stoptable\dostoptable
- \doif\@@tisplit\v!auto
- {\ifinsidesplitfloat\let\@@tisplit\v!yes\fi}%
- \doifinsetelse\@@tisplit{\v!yes,\v!repeat}
- {\unexpanded\def\stoptable{\stoptables\egroup}%
- \starttables}
- {\doifelsenothing\@@tiframe
- {\ifinsidefloat\else\startbaselinecorrection\fi}
- {\startframedcontent[\@@tiframe]}%
- \postponenotes
- \firststagestarttable}%
+ \edef\p_tabl_table_split{\directtablesparameter\c!split}%
+ \edef\p_tabl_table_frame{\directtablesparameter\c!frame}%
+ \ifx\p_tabl_table_split\v!auto
+ \ifinsidesplitfloat
+ \let\p_tabl_table_split\v!yes
+ \lettablesparameter\c!split\v!yes % might be used later, best make a proper mode
+ \fi
+ \fi
+ \ifx\p_tabl_table_split\v!yes
+ \unexpanded\def\stoptable{\stoptables\egroup}%
+ \starttables
+ \else\ifx\p_tabl_table_split\v!repeat
+ \unexpanded\def\stoptable{\stoptables\egroup}%
+ \starttables
+ \else
+ \ifx\p_tabl_table_frame\empty
+ \ifinsidefloat\else\startbaselinecorrection\fi
+ \else
+ \startframedcontent[\p_tabl_table_frame]%
+ \fi
+ \postponenotes
+ \firststagestarttable
+ \fi\fi
[#1]}
% We cannot define \unexpanded\def\dostoptable a ssomehow lookahead
@@ -1365,12 +1374,14 @@
\globalletempty\dotabletail
\stoptablenoalign
\dofinishtable
- \doifelsenothing\@@tiframe
- {\ifinsidefloat\else
+ \ifx\p_tabl_table_frame\empty
+ \ifinsidefloat\else
\stopbaselinecorrection
\goodbreak % compensates all the nobreaks
- \fi}
+ \fi
+ \else
\stopframedcontent
+ \fi
\egroup}
%D Before we can grab the argument, we have to make sure that
@@ -1465,7 +1476,7 @@
% \def\doverysimpletableHL % todo
% {\starttablenoalign
-% \expandafter\donormaltablefullrule\@@tiHLheight
+% \normalexpanded{\noexpand\donormaltablefullrule\m_tabl_table_HLheight}%
% \stoptablenoalign}
\def\dorestarttable#1%
@@ -1565,9 +1576,14 @@
{\bgroup
\let\stoptables\dostoptables
\splittablestrue
- \doifelse\@@tisplit\v!repeat
- {\settrue \tablerepeathead\settrue \tablerepeattail}
- {\setfalse\tablerepeathead\setfalse\tablerepeattail}%
+ \edef\p_tabl_table_split{\directtablesparameter\c!split}%
+ \ifx\p_tabl_table_split\v!repeat
+ \settrue\tablerepeathead
+ \settrue\tablerepeattail
+ \else
+ \setfalse\tablerepeathead
+ \setfalse\tablerepeattail
+ \fi
\flushnotes
\setbox\tablecontentbox\vbox\bgroup
\forgetall
@@ -1899,7 +1915,7 @@
\def\dotablevrulecommand#1% global assignments
{\doifnumberelse{#1}
{\global\tablevrulethicknessfactor#1\relax
- \global\multiply\tablevrulethicknessfactor\@@tiVLwidth\relax}
+ \global\multiply\tablevrulethicknessfactor\m_tabl_table_VLwidth\relax}
{\xdef\tablecurrentvrulecolor{#1}}}
\unexpanded\def\dotableVL
@@ -1909,7 +1925,7 @@
\def\dodotableVL[#1]%
{\global\let\tablecurrentvrulecolor\empty
- \global\tablevrulethicknessfactor\@@tiVLwidth\relax
+ \global\tablevrulethicknessfactor\m_tabl_table_VLwidth\relax
\iffirstargument
\rawprocesscommalist[#1]\dotablevrulecommand
\fi
@@ -1933,7 +1949,7 @@
\def\dotablehrulecommand#1% global assignments
{\doifnumberelse{#1}
{\global\tablehrulethicknessfactor#1\relax
- \global\multiply\tablehrulethicknessfactor\@@tiHLheight\relax}
+ \global\multiply\tablehrulethicknessfactor\m_tabl_table_HLheight\relax}
{\xdef\tablecurrenthrulecolor{#1}}}
\unexpanded\def\dotableHL
@@ -1953,7 +1969,7 @@
\writestatus\m!TABLE{change \string\MR\space into \string\SR}%
\fi\fi
\bgroup
- \global\tablehrulethicknessfactor\@@tiHLheight\relax
+ \global\tablehrulethicknessfactor\m_tabl_table_HLheight\relax
\iffirstargument
\global\let\tablecurrenthrulecolor\empty
\rawprocesscommalist[#1]\dotablehrulecommand
@@ -2007,7 +2023,7 @@
\dosingleempty\dotableTB}
\def\dotableTB[#1]%
- {\blank[\iffirstargument#1\else\@@tiNL\fi]%
+ {\blank[\iffirstargument#1\else\directtablesparameter\c!NL\fi]%
\nobreak
\stoptablenoalign}
@@ -2056,7 +2072,7 @@
\global\tabledrulespan#1\relax
\else
\global\tablehrulethicknessfactor#1\relax
- \global\multiply\tablehrulethicknessfactor\@@tiVLwidth\relax
+ \global\multiply\tablehrulethicknessfactor\m_tabl_table_VLwidth\relax
\fi}
{\xdef\tablecurrenthrulecolor{#1}}}
@@ -2074,7 +2090,7 @@
\writestatus\m!TABLE{change \string\MR\space into \string\SR}%
\fi\fi
\dosettableaction\tableunknownstate
- \global\tablehrulethicknessfactor\@@tiHLheight\relax
+ \global\tablehrulethicknessfactor\m_tabl_table_HLheight\relax
\global\tabledrulespan\zerocount
\iffirstargument
\global\let\tablecurrenthrulecolor\empty
@@ -2136,17 +2152,28 @@
\let\REF \dotablereformat
\to \localtabledefinitions
-\setvalue{\??ti:\c!distance:\v!none }{\dotableOpenUp00\def\LOW{\Lower6 }}
-\setvalue{\??ti:\c!distance:\v!small }{\dotableOpenUp00\def\LOW{\Lower6 }} % == baseline
-\setvalue{\??ti:\c!distance:\v!medium}{\dotableOpenUp11\def\LOW{\Lower7 }}
-\setvalue{\??ti:\c!distance:\v!big }{\dotableOpenUp22\def\LOW{\Lower8 }}
+\installcorenamespace{tables}
+\installcorenamespace{tabledistance}
+\installcorenamespace{tablealign}
+
+\installsetuponlycommandhandler \??tables {tables} % some day we can have named tables
+
+\setvalue{\??tabledistance\v!none }{\dotableOpenUp00\def\LOW{\Lower6 }}
+\setvalue{\??tabledistance\v!small }{\dotableOpenUp00\def\LOW{\Lower6 }} % == baseline
+\setvalue{\??tabledistance\v!medium}{\dotableOpenUp11\def\LOW{\Lower7 }}
+\setvalue{\??tabledistance\v!big }{\dotableOpenUp22\def\LOW{\Lower8 }}
\appendtoks
- \getvalue{\??ti:\c!distance:\@@tidistance}%
+ \expandcheckedcsname\??tabledistance{\directtablesparameter\c!distance}\v!medium
\to \localtabledefinitions
+\setvalue{\??tablealign\v!right }{\def\dotableparalignment{\raggedright}}
+\setvalue{\??tablealign\v!left }{\def\dotableparalignment{\raggedleft}}
+\setvalue{\??tablealign\v!middle }{\def\dotableparalignment{\raggedcenter}}
+\setvalue{\??tablealign\s!unknown}{\def\dotableparalignment{\notragged}}
+
\appendtoks
- \doifelse\@@tidistance\v!none
+ \doifelse{\directtablesparameter\c!distance}\v!none
{\tablerowfactor\zerocount}
{\tablerowfactor\plustwo }%
\to \localtabledefinitions
@@ -2160,31 +2187,28 @@
\@EAEAEA\dotextmodebar
\fi\fi}
-\unexpanded\def\setuptables
- {\dosingleargument\dosetuptables}
-
-\def\dosetuptables[#1]%
- {\getparameters[\??ti][#1]%
- \processaction % we have a command for this
- [\@@tialign]
- [ \v!right=>\def\dotableparalignment{\raggedright},
- \v!left=>\def\dotableparalignment{\raggedleft},
- \v!middle=>\def\dotableparalignment{\raggedcenter},
- \s!default=>\def\dotableparalignment{\notragged},
- \s!unknown=>\def\dotableparalignment{\notragged}]%
- \assignalfadimension\@@tiVL\@@tiVLwidth 246%
- \assignalfadimension\@@tiHL\@@tiHLheight246}
+\appendtoks
+ \expandcheckedcsname\??tablealign{\directtablesparameter\c!align}\s!unknown
+ \assignalfadimension{\directtablesparameter\c!VL}\m_tabl_table_VLwidth 246%
+ \assignalfadimension{\directtablesparameter\c!HL}\m_tabl_table_HLheight246%
+\to \everysetuptables
\def\dolocaltablesetup
- {\@@ticommands\relax
- \doifsomething\@@tibodyfont{\switchtobodyfont[\@@tibodyfont]}%
- \tablelinethicknessunit\dimexpr\@@tirulethickness/\tablelinethicknessfactor\relax
- \doifelse\@@tiheight\v!strut
- {\let\tablestrutheightfactor\tablestrutheightfactor}
- {\let\tablestrutheightfactor\@@tiheight}%
- \doifelse\@@tidepth\v!strut
- {\let\tablestrutdepthfactor\tablestrutdepthfactor}
- {\let\tablestrutdepthfactor\@@tidepth}%
+ {\directtablesparameter\c!commands\relax
+ \doifsomething{\directtablesparameter\c!bodyfont}{\switchtobodyfont[\directtablesparameter\c!bodyfont]}%
+ \tablelinethicknessunit\dimexpr\directtablesparameter\c!rulethickness/\tablelinethicknessfactor\relax
+ \edef\p_tabl_table_height{\directtablesparameter\c!height}%
+ \edef\p_tabl_table_depth{\directtablesparameter\c!depth}%
+ \ifx\p_tabl_table_height\v!strut
+ \let\tablestrutheightfactor\tablestrutheightfactor
+ \else
+ \let\tablestrutheightfactor\p_tabl_table_height
+ \fi
+ \ifx\p_tabl_table_depth\v!strut
+ \let\tablestrutdepthfactor\tablestrutdepthfactor
+ \else
+ \let\tablestrutdepthfactor\p_tabl_table_depth
+ \fi
\edef\tablestrutheightfactor{\withoutpt\the\dimexpr10\dimexpr\tablestrutheightfactor\points}%
\edef\tablestrutdepthfactor {\withoutpt\the\dimexpr10\dimexpr\tablestrutdepthfactor \points}%
\tablestrutunit\dimexpr\normalbaselineskip/12\relax % 12 is default bodyfont
@@ -2243,9 +2267,9 @@
%D \stopcombination
\setuptables
- [HL=\v!medium,
- VL=\v!medium,
- NL=\v!small,
+ [\c!HL=\v!medium,
+ \c!VL=\v!medium,
+ \c!NL=\v!small,
\c!frame=,
\c!align=\v!right,
\c!depth=.40, % \v!strut
@@ -2256,8 +2280,8 @@
\c!distance=\v!medium,
\c!bodyfont=,
\c!commands=,
- \c!background=\v!screen,
- \c!backgroundscreen=\@@rsscreen,
+ \c!background=\v!screen, % huh?
+ \c!backgroundscreen=\defaultbackgroundscreen,
\c!backgroundcolor=,
\c!split=\v!auto]
diff --git a/tex/context/base/tabl-tsp.mkiv b/tex/context/base/tabl-tsp.mkiv
index 34d3df780..5777059a5 100644
--- a/tex/context/base/tabl-tsp.mkiv
+++ b/tex/context/base/tabl-tsp.mkiv
@@ -98,7 +98,7 @@
\def\splitfloatcommand{#2}%
\global\settrue \onlyonesplitofffloat
\global\setfalse\somenextsplitofffloat
- \dopushsavedfloats
+ \page_floats_push_saved
\floatsplittingparameter\c!before
\let\next} % \bgroup
@@ -156,8 +156,8 @@
\fi
\else
\floatsplittingparameter\c!after
- \dopopsavedfloats
- \doflushsavedfloats
+ \page_floats_pop_saved
+ \page_floats_flush_saved
\fi
\global\settrue\splitfloatfirstdone}
diff --git a/tex/context/base/typo-brk.mkiv b/tex/context/base/typo-brk.mkiv
index 029f4402f..62fd72fce 100644
--- a/tex/context/base/typo-brk.mkiv
+++ b/tex/context/base/typo-brk.mkiv
@@ -38,14 +38,14 @@
\def\typo_breakpoints_define_character[#1][#2][#3]% name char settings
{\begingroup
- \getparameters[\??bp][\c!type=1,\c!nleft=3,\c!nright=3,\s!language=,\c!left=,\c!right=,\c!middle=,#3]%
- \ctxcommand{definebreakpoint("#1", "#2", "\reallanguagetag\@@bplanguage", {
- type = \@@bptype,
- nleft = "\@@bpnleft",
- nright = "\@@bpnright",
- right = "\@@bpright",
- left = "\@@bpleft",
- middle = "\@@bpmiddle"
+ \getdummyparameters[\c!type=1,\c!nleft=3,\c!nright=3,\s!language=,\c!left=,\c!right=,\c!middle=,#3]%
+ \ctxcommand{definebreakpoint("#1", "#2", "\reallanguagetag{\directdummyparameter\s!language}", { % maybe deal with #3 at the lua end
+ type = \directdummyparameter\c!type,
+ nleft = "\directdummyparameter\c!nleft",
+ nright = "\directdummyparameter\c!nright",
+ right = "\directdummyparameter\c!right",
+ left = "\directdummyparameter\c!left",
+ middle = "\directdummyparameter\c!middle"
} )}%
\endgroup}
diff --git a/tex/context/base/typo-cap.mkiv b/tex/context/base/typo-cap.mkiv
index 28ced7c42..feab6b35d 100644
--- a/tex/context/base/typo-cap.mkiv
+++ b/tex/context/base/typo-cap.mkiv
@@ -183,21 +183,22 @@
%D
%D \showsetup{setupcapitals}
-\let\normalsmallcapped\smallcapped
+\installcorenamespace{capitals}
-\definesystemvariable{kk}
+\installsetuponlycommandhandler \??capitals {capitals}
-\unexpanded\def\setupcapitals
- {\dosingleempty\typo_capitals_setup}
+\let\normalsmallcapped\smallcapped
-\def\typo_capitals_setup[#1]% todo: don't use grouping just a switch
- {\getparameters[\??kk][#1]%
- \doifelse\@@kktitle\v!yes
- {\definealternativestyle[\v!capital ][\normalsmallcapped][\normalsmallcapped]%
- \definealternativestyle[\v!smallcaps][\sc ][\sc ]}
- {\definealternativestyle[\v!capital ][\normalsmallcapped][\normalWORD ]%
- \definealternativestyle[\v!smallcaps][\sc ][\normalWORD ]}%
- \doifelse\@@kksc\v!yes\userealcaps\usepseudocaps}
+\appendtoks
+ \doifelse{\directcapitalsparameter\c!title}\v!yes
+ {\definealternativestyle[\v!capital ][\normalsmallcapped][\normalsmallcapped]%
+ \definealternativestyle[\v!smallcaps][\sc ][\sc ]}
+ {\definealternativestyle[\v!capital ][\normalsmallcapped][\normalWORD ]%
+ \definealternativestyle[\v!smallcaps][\sc ][\normalWORD ]}%
+ \doifelse{\directcapitalsparameter\s!sc}\v!yes
+ \userealcaps
+ \usepseudocaps
+\to \everysetupcapitals
\let\uppercased\normalWORD
\let\lowercased\normalword
diff --git a/tex/context/base/typo-del.mkiv b/tex/context/base/typo-del.mkiv
index b2213db65..7c36ef3c8 100644
--- a/tex/context/base/typo-del.mkiv
+++ b/tex/context/base/typo-del.mkiv
@@ -17,14 +17,19 @@
% THIS IS OBSOLETE:
-\unexpanded\def\setuphyphenmark
- {\dodoubleargument\getparameters[\??kp]}
+\installcorenamespace{hyphenmarksign} % let's not waste a setuphandler (yet)
\unexpanded\def\setuphyphenmark[#1]% sign=normal|wide
- {\dodoubleargument\getparameters[\??kp][#1]%
- \doifelse\@@kpsign {\v!normal}% was inset?
- {\let\textmodehyphen\normalhyphen \let\textmodehyphendiscretionary\normalhyphendiscretionary}
- {\let\textmodehyphen\composedhyphen\let\textmodehyphendiscretionary\composedhyphendiscretionary}}
+ {\getdummyparameters[#1]%
+ \expandcheckedcsname\??hyphenmarksign{\dummyparameter\c!sign}\v!normal}
+
+\setvalue{\??hyphenmarksign\v!normal}%
+ {\let\textmodehyphen\normalhyphen
+ \let\textmodehyphendiscretionary\normalhyphendiscretionary}
+
+\setvalue{\??hyphenmarksign\v!wide}%
+ {\let\textmodehyphen\composedhyphen
+ \let\textmodehyphendiscretionary\composedhyphendiscretionary}
\setuphyphenmark[\c!sign=\v!wide]
@@ -32,19 +37,19 @@
\definesymbol[\c!righthyphen] [\languageparameter\c!righthyphen]
\definesymbol[\c!hyphen] [\languageparameter\c!hyphen]
-\def\normalhyphen
+\unexpanded\def\normalhyphen
{\hbox{\directsymbol\empty\c!hyphen}}
-\def\composedhyphen
+\unexpanded\def\composedhyphen
{\hbox{\directsymbol\empty\c!compoundhyphen}}
-\def\normalhyphendiscretionary
+\unexpanded\def\normalhyphendiscretionary
{\discretionary
{\hbox{\directsymbol\empty\c!righthyphen}}
{\hbox{\directsymbol\empty\c!lefthyphen}}
{\hbox{\directsymbol\empty\c!hyphen}}}
-\def\composedhyphendiscretionary
+\unexpanded\def\composedhyphendiscretionary
{\discretionary
{\hbox{\directsymbol\empty\c!rightcompoundhyphen}}
{\hbox{\directsymbol\empty\c!leftcompoundhyphen}}
@@ -219,8 +224,10 @@
[\c!middlespeech]
[\leftboundarycharacter\c!middlespeech{speech}]
-\appendtoks\def\quotation#1{"#1"}\to\simplifiedcommands
-\appendtoks\def\quote #1{'#1'}\to\simplifiedcommands
+\appendtoks
+ \def\quotation#1{"#1"}%
+ \def\quote #1{'#1'}%
+\to \everysimplifycommands
%D The next features was so desperately needed by Giuseppe
%D Bilotta that he made a module for it. Since this is a
diff --git a/tex/context/base/typo-spa.mkiv b/tex/context/base/typo-spa.mkiv
index 0cfe44610..df2dab47c 100644
--- a/tex/context/base/typo-spa.mkiv
+++ b/tex/context/base/typo-spa.mkiv
@@ -25,7 +25,12 @@
\installcorenamespace{characterspacing}
-\definesystemvariable{cs} % maybe a dummy namespace
+\installsetuponlycommandhandler \??characterspacing {_p_characterspacing} % private
+
+\setup_p_characterspacing
+ [\c!left=0,
+ \c!right=0,
+ \c!alternative=0]
\unexpanded\def\definecharacterspacing[#1]%
{\ctxcommand{definecharacterspacing("#1")}}
@@ -35,11 +40,11 @@
\def\typo_characterspacing_setup[#1][#2][#3]% todo: #2 list
{\begingroup
- \getparameters[\??cs][\c!left=0,\c!right=0,\c!alternative=0,#3]%
- \ctxcommand{setupcharacterspacing("#1",\number#2, {
- left = \@@csleft,
- right = \@@csright,
- alternative = \@@csalternative
+ \setupcurrent_p_characterspacing[#3]%
+ \ctxcommand{setupcharacterspacing("#1",\number#2, { % todo: just pass #3 to the lua end
+ left = \direct_p_characterspacingparameter\c!left,
+ right = \direct_p_characterspacingparameter\c!right,
+ alternative = \direct_p_characterspacingparameter\c!alternative
})}%
\endgroup}
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 609b93658..5d05b55fe 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 : 06/30/12 12:32:51
+-- merge date : 07/04/12 10:42:10
do -- begin closure to overcome local limits and interference