diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-11-16 20:16:53 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-11-16 20:16:53 +0100 |
commit | 744befce8596a7007e60c1f046da570fadc205bd (patch) | |
tree | 867472bb4d18e581ef80ba0dbf8bf7fd047cddd2 /tex | |
parent | a9eb7ca71c27fdd59cf99273adf74b17d72063b2 (diff) | |
download | context-744befce8596a7007e60c1f046da570fadc205bd.tar.gz |
2020-11-16 19:40:00
Diffstat (limited to 'tex')
51 files changed, 3745 insertions, 307 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index e3fbc2cc3..8e57e6627 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2020.11.15 20:40} +\newcontextversion{2020.11.16 19:37} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index 9c628dbae..d22d7b6e7 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.15 20:40} +\edef\contextversion{2020.11.16 19:37} %D For those who want to use this: diff --git a/tex/context/base/mkii/mult-cs.mkii b/tex/context/base/mkii/mult-cs.mkii index 2f38323ef..290ae510e 100644 --- a/tex/context/base/mkii/mult-cs.mkii +++ b/tex/context/base/mkii/mult-cs.mkii @@ -1368,7 +1368,6 @@ \setinterfaceelement{type}{opis} % definitions for interface commands for language cs % -\setinterfacecommand{CAPPED}{KAP} \setinterfacecommand{Character}{Znak} \setinterfacecommand{Characters}{Znaky} \setinterfacecommand{MONTH}{MESIC} diff --git a/tex/context/base/mkii/mult-fr.mkii b/tex/context/base/mkii/mult-fr.mkii index 6eed238c6..d39d3619c 100644 --- a/tex/context/base/mkii/mult-fr.mkii +++ b/tex/context/base/mkii/mult-fr.mkii @@ -1368,7 +1368,6 @@ \setinterfaceelement{type}{transcrire} % definitions for interface commands for language fr % -\setinterfacecommand{CAPPED}{CAP} \setinterfacecommand{Character}{Caractere} \setinterfacecommand{Characters}{Caracteres} \setinterfacecommand{MONTH}{MOIS} diff --git a/tex/context/base/mkii/mult-ro.mkii b/tex/context/base/mkii/mult-ro.mkii index 1c8de1c87..0663659e3 100644 --- a/tex/context/base/mkii/mult-ro.mkii +++ b/tex/context/base/mkii/mult-ro.mkii @@ -1368,7 +1368,6 @@ \setinterfaceelement{type}{type} % definitions for interface commands for language ro % -\setinterfacecommand{CAPPED}{KAP} \setinterfacecommand{Character}{Litera} \setinterfacecommand{Characters}{Litere} \setinterfacecommand{MONTH}{LUNA} diff --git a/tex/context/base/mkiv/anch-bar.mkxl b/tex/context/base/mkiv/anch-bar.mkxl new file mode 100644 index 000000000..3587eb8a0 --- /dev/null +++ b/tex/context/base/mkiv/anch-bar.mkxl @@ -0,0 +1,220 @@ +%D \module +%D [ file=anch-bar, +%D version=2003.03.16, +%D title=\CONTEXT\ Anchoring Macros, +%D subtitle=Margin Bars and alike, +%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 Anchoring Macros / Margin Bars} + +\unprotect + +%D This can be done better now ... + +%D We will implement a sidebar mechanism using the functionality from +%D \type {core-pos}. +%D +%D \starttyping +%D \definesidebar[whow][rulecolor=green,distance=0pt] +%D +%D \input tufte \par +%D \startsidebar +%D \input tufte \par +%D \input tufte \par +%D \startsidebar[whow] +%D \input tufte \par +%D \input tufte \par +%D \input tufte +%D \stopsidebar \par +%D \input tufte \par +%D \input tufte +%D \stopsidebar \par +%D \input tufte \par +%D \input tufte \par +%D \startsidebar +%D \input tufte \par +%D \input tufte \par +%D \input tufte \par +%D \input tufte \par +%D \input tufte +%D \stopsidebar \par +%D \input tufte \par +%D \input tufte \par +%D \startsidebar +%D \input tufte +%D \input tufte +%D \input tufte +%D \input tufte +%D \input tufte +%D \stopsidebar +%D \stoptyping + +\installcorenamespace{sidebar} + +\installcommandhandler \??sidebar {sidebar} \??sidebar + +\newcount\c_anch_sidebars_n +\newcount\c_anch_sidebars_current % local +\newdimen\d_anch_sidebars_distance +\newcount\c_anch_sidebars_level + +% \setupMPvariables +% [mpos:sidebar] +% [linecolor=red, +% linewidth=2pt, +% distance=5pt] + +\setupsidebar + [\c!rulethickness=\dimexpr\bodyfontsize/6\relax, % 2pt default + \c!rulecolor=\s!black, + \c!alternative=0, + \c!topoffset=\zeropoint, + \c!bottomoffset=\zeropoint, + \c!distance=.5\bodyfontsize, + \c!level=, + \c!leftmargindistance=\zeropoint] + +\aliased\let\setupsidebars\setupsidebar + +\permanent\tolerant\protected\def\startsidebar[#1]#*[#2]% + {\bgroup + \dontleavehmode + \advance\c_anch_sidebars_level\plusone + \global\advance\c_anch_sidebars_n\plusone + \c_anch_sidebars_current\c_anch_sidebars_n\relax % relax needed + \ifhastok={#1}% + \edef\currentsidebar{\the\c_anch_sidebars_level}% + \checksidebarparent + \setupcurrentsidebar[#1]% + \else + \def\currentsidebar{#1}% + \setupcurrentsidebar[#2]% + \fi + \scratchdistance\sidebarparameter\c!distance\relax + \scratchdimen\sidebarparameter\c!leftmargindistance\relax + \edef\m_level{\sidebarparameter\c!level}% + \ifempty\m_level + \ifnum\c_anch_sidebars_level=\plusone + \ifzeropt\scratchdimen + \advance\d_anch_sidebars_distance\scratchdistance\relax + \else + \d_anch_sidebars_distance\scratchdimen + \fi + \else + \advance\d_anch_sidebars_distance\scratchdistance\relax + \fi + \else + \ifnum\m_level=\plusone + \ifzeropt\scratchdimen + \advance\d_anch_sidebars_distance\scratchdistance\relax + \else + \d_anch_sidebars_distance\scratchdimen + \fi + \else + \d_anch_sidebars_distance\dimexpr\scratchdimen+\numexpr\m_level-\plusone\relax\dimexpr\scratchdistance\relax\relax + \fi + \fi + \startpositionoverlay{\v!text-1}% + \normalexpanded{\setMPpositiongraphicrange % maybe expand in definition + {b:sidebar:\the\c_anch_sidebars_n}% + {e:sidebar:\the\c_anch_sidebars_n}% + {mpos:sidebar}% + {self=sidebar:\the\c_anch_sidebars_n, + linewidth=\sidebarparameter\c!rulethickness, + linecolor=\sidebarparameter\c!rulecolor, + alternative=\sidebarparameter\c!alternative, + topoffset=\the\dimexpr\sidebarparameter\c!topoffset, + bottomoffset=\the\dimexpr\sidebarparameter\c!bottomoffset, + distance=\the\d_anch_sidebars_distance}% + }% + \stoppositionoverlay + \bpos{sidebar:\the\c_anch_sidebars_current}% + \ignorespaces} + +\permanent\protected\def\stopsidebar + {\removelastspace + \epos{sidebar:\the\c_anch_sidebars_current} + \carryoverpar\egroup} + +%D Let's keep this nice and simple (okay, we could pass the 6 variables in +%D one lua call). + +\startMPpositionmethod{mpos:sidebar} + \startMPpositiongraphic{mpos:sidebar}{linecolor,linewidth,distance,alternative}% + anch_sidebars_draw ( + \MPp\MPbself,\MPp\MPeself,\MPy\MPbself,\MPy\MPeself,\MPh\MPbself,\MPd\MPeself, + \MPx{\textanchor},\MPy{\textanchor},\MPw{\textanchor},\MPh{\textanchor}, + \MPvar{alternative},\MPvar{distance},\MPvar{linewidth},\MPvar{linecolor}, + \MPvar{topoffset}, \MPvar{bottomoffset} + ) ; + \stopMPpositiongraphic + \MPpositiongraphic{mpos:sidebar}{}% +\stopMPpositionmethod + +%D We now reimplement the \MKII\ margin rules handler in a more +%D modern way. +%D +%D \setupmarginrules +%D [rulecolor=darkred, +%D rulethickness=2pt] +%D +%D \setupmarginrules % sidebar +%D [2] +%D [rulecolor=darkblue] +%D +%D \startmarginrule[1] +%D \input ward +%D \startmarginrule[2] +%D \input ward +%D \startmarginrule[3] +%D \input ward +%D \startmarginrule[level=6,rulecolor=darkgreen] +%D \input ward +%D \stopmarginrule +%D \input ward +%D \stopmarginrule +%D \input ward +%D \stopmarginrule +%D \input ward +%D \stopmarginrule +%D +%D Compared to the old mechanism we now can pass settings too. + +\definesidebar + [\v!margin] + [\c!leftmargindistance=\dimexpr\leftmargindistance+\sidebarparameter\c!rulethickness/2\relax] + +\dorecurse{5}{\definesidebar[\v!margin:#1][\v!margin]} % let's be nice and predefine 5 levels + +\permanent\tolerant\protected\def\setupmarginrule[#1]#*[#2]% + {\ifarguments\or + \setupsidebar[\v!margin][#1]% + \or + \setupsidebar[\v!margin:#1][#2]% + \fi} + +\aliased\let\setupmarginrules\setupmarginrule + +\permanent\tolerant\protected\def\startmarginrule[#1]% pretty inefficient checking + {\edef\m_anch_marginrules_kind{#1}% + \ifempty\m_anch_marginrules_kind + \startsidebar[\v!margin][]% + \orelse\ifhastok={\m_anch_marginrules_kind}% + \startsidebar[\v!margin][#1]% + \else + \anch_marginrules_check{#1}% + \startsidebar[\v!margin:#1][\c!level=#1]% + \fi} + +\def\anch_marginrules_check#1% + {\doifnotcommandhandler\??sidebar{\v!margin:#1}{\definesidebar[\v!margin:#1][\v!margin]}} + +\aliased\let\stopmarginrule\stopsidebar + +\protect \endinput diff --git a/tex/context/base/mkiv/anch-bck.mklx b/tex/context/base/mkiv/anch-bck.mklx new file mode 100644 index 000000000..91e523d8f --- /dev/null +++ b/tex/context/base/mkiv/anch-bck.mklx @@ -0,0 +1,747 @@ +%D \module +%D [ file=anch-bck, % moved from anch-pgr (1999.08.01) +%D version=2011.12.19, +%D title=\CONTEXT\ Anchoring Macros, +%D subtitle=Backgrounds, +%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 Anchoring Macros / Backgrounds} + +%D This module is quite okay but at some point I might add methods that use +%D attributes although not too much is to be expected, apart from better anchoring. +%D In fact better anchoring can be done independent of that. + +\unprotect + +% This might be overloaded later on: + +% \defineoverlay[\v!text-2][\positionoverlay{\v!text-2}] +% \defineoverlay[\v!text-1][\positionoverlay{\v!text-1}] +% \defineoverlay[\v!text+1][\positionoverlay{\v!text+1}] +% \defineoverlay[\v!text+2][\positionoverlay{\v!text+2}] + +% Paragraph positions: + +\newcount\c_anch_backgrounds_text_n + +\def\v_anch_backgrounds_text_current {tbg:0} +\def\v_anch_backgrounds_anchor_current_b{b:\v_anch_backgrounds_text_current} +\def\v_anch_backgrounds_anchor_current_e{e:\v_anch_backgrounds_text_current} + +\def\anch_backgrounds_text_initialize_next + {\global\advance\c_anch_backgrounds_text_n\plusone + \edef\v_anch_backgrounds_text_current{tbg:\number\c_anch_backgrounds_text_n}} + +% The first position can be used in the middle of a paragraph in which case we're +% too late with initializing par positions. Therefore we check if positions are +% used at all. +% +% tricky: we need to catch newly set! otherwise an old run can have positions + +\protected\def\anch_backgrounds_text_initialize + {\doifelsepositionsused\enableparpositions\donothing + \glet\anch_backgrounds_text_initialize\relax} + +\appendtoks + \anch_backgrounds_text_initialize +\to \everystarttext + +%D Some MP + +\newcount\MPparcounter + +\permanent\def\MPself {\MPvar{self}} +\permanent\def\MPbself {b:\MPvar{self}} +\permanent\def\MPeself {e:\MPvar{self}} +\permanent\def\MPparanchor{p:\number\MPparcounter} + +% \carryoverpar is needed for left/right floats + +% \definetextbackground[more][state=start,backgroundcolor=red] % location=paragraph +% \definetextbackground[test][state=start,backgroundcolor=green] +% +% \page \placefigure[left]{}{} +% +% \starttextbackground[test] +% \readfile{ward}{}{} +% \starttextbackground[more] +% \readfile{ward}{}{} +% \stoptextbackground +% \readfile{ward}{}{} +% \stoptextbackground +% +% \page \placefigure[right]{}{} +% +% \starttextbackground[test] +% \readfile{ward}{}{} +% \starttextbackground[more] +% \readfile{ward}{}{} +% \stoptextbackground +% \readfile{ward}{}{} +% \stoptextbackground + +\newcount\c_anch_backgrounds_text_level + +\installcorenamespace{textbackground} +\installcorenamespace{textbackgroundlevel} + +\installcommandhandler \??textbackground {textbackground} \??textbackground + +\appendtoks + \frozen\instance\setuevalue{\currenttextbackground}{\groupedcommand{\starttextbackground[\currenttextbackground]}{\stoptextbackground}}% + \frozen\instance\setuevalue{\e!start\currenttextbackground}{\starttextbackground[\currenttextbackground]}% + \frozen\instance\setuevalue{\e!stop \currenttextbackground}{\stoptextbackground}% +\to \everydefinetextbackground + +\newconstant \c_anch_backgrounds_pos_state +\newconditional\c_anch_backgrounds_pos_no_shape + +\def\anch_backgrounds_bpos + {\ifconditional\c_anch_backgrounds_pos_no_shape + \bposkind\v_anch_backgrounds_text_current\plusthree + \else + \bposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state + \fi} + +\def\anch_backgrounds_epos + {\ifconditional\c_anch_backgrounds_pos_no_shape + \eposkind\v_anch_backgrounds_text_current\plusthree + \else + \eposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state + \fi} + +% \permanent\tolerant\protected\def\starttextbackground[#tag]#spacer[#settings]% +% {\begingroup +% \advance\c_anch_backgrounds_text_level\plusone +% \def\currenttextbackground{#tag}% +% \anch_backgrounds_text_initialize_next +% \ifparameter#settings\or +% \setupcurrenttextbackground[#settings]% +% \fi +% \doifelse{\textbackgroundparameter\c!state}\v!start +% \anch_backgrounds_text_preset_yes +% \anch_backgrounds_text_preset_nop +% \anch_backgrounds_text_start_indeed} + +% ugly hack to register usage + +\newcount \c_anch_backgrounds_text_count +\newcount \c_anch_backgrounds_text_check +\newconstant\c_anch_backgrounds_text_state + +\permanent\tolerant\protected\def\starttextbackground[#tag]#spacer[#settings]% + {\begingroup + \global\advance\c_anch_backgrounds_text_count\plusone + \advance\c_anch_backgrounds_text_level\plusone + \def\currenttextbackground{#tag}% + \anch_backgrounds_text_initialize_next + \ifparameter#settings\or + \setupcurrenttextbackground[#settings]% + \fi + \doifelse{\textbackgroundparameter\c!state}\v!start + \anch_backgrounds_text_preset_yes + \anch_backgrounds_text_preset_nop + \anch_backgrounds_text_start_indeed} + +\def\anch_backgrounds_text_level_start + {\c_anch_backgrounds_text_check\c_anch_backgrounds_text_count} + +\def\anch_backgrounds_text_level_stop + {\c_anch_backgrounds_text_state + \ifnum\c_anch_backgrounds_text_count>\c_anch_backgrounds_text_check + \plusone + \else + \zerocount + \fi} + +% todo \backgroundvariable\c!variant + +% criterium determines when we fall back on text +% always is always forcing paragraphs + +\let\anch_backgrounds_text_start_indeed\relax +\let\anch_backgrounds_text_stop_indeed \relax + +\setvalue{\??textbackgroundlevel\v!text}% + {\let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_txt + \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_txt} + +\setvalue{\??textbackgroundlevel\v!paragraph}% + {\ifnum\c_anch_backgrounds_text_level>\textbackgroundparameter\c!criterium\relax + \let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_txt + \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_txt + \else + \let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_par + \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_par + \fi} + +\setvalue{\??textbackgroundlevel\v!always}% + {\let\anch_backgrounds_text_start_indeed\anch_backgrounds_text_start_par + \let\anch_backgrounds_text_stop_indeed \anch_backgrounds_text_stop_par} + +\setvalue{\??textbackgroundlevel\v!none}% + {\anch_backgrounds_text_preset_nop} + +\def\anch_backgrounds_text_preset_nop + {\let\anch_backgrounds_text_start_indeed\relax + \let\anch_backgrounds_text_stop_indeed \relax} + +\def\anch_backgrounds_text_preset_yes + {\anch_backgrounds_text_preset_nop + \csname\??textbackgroundlevel\textbackgroundparameter\c!location\endcsname + \edef\p_anch_backgrounds_text_frame {\textbackgroundparameter\c!frame}% + \edef\p_anch_backgrounds_text_corner {\textbackgroundparameter\c!corner}% + \edef\p_anch_backgrounds_text_background{\textbackgroundparameter\c!background}% + \ifx\p_anch_backgrounds_text_frame\v!on + \ifx\p_anch_backgrounds_text_corner\v!round + \let\p_anch_backgrounds_text_frame\!!plustwo + \else + \let\p_anch_backgrounds_text_frame\!!plusone + \fi + \else + \let\p_anch_backgrounds_text_frame\!!zerocount + \fi + \ifx\p_anch_backgrounds_text_background\v!color + \let\p_anch_backgrounds_text_background\!!plusone + \else + \let\p_anch_backgrounds_text_background\!!zerocount + \fi + \startpositionoverlay{\textbackgroundoverlay{\textbackgroundparameter\c!level}}% + \anch_backgrounds_text_meta_graphic % gets expanded directly + \stoppositionoverlay} + +\def\anch_backgrounds_text_meta_graphic + {\normalexpanded + {\setMPpositiongraphicrange % needs to be optimized + {\v_anch_backgrounds_anchor_current_b}% + {\v_anch_backgrounds_anchor_current_e}% + {\textbackgroundparameter\c!method}% + {self=\v_anch_backgrounds_text_current, + mp=\textbackgroundparameter\c!mp, + gridtype=\textbackgroundparameter\c!alternative, + filltype=\p_anch_backgrounds_text_background, + linetype=\p_anch_backgrounds_text_frame, + dashtype=\textbackgroundparameter\c!dash, + gridcolor=\textbackgroundparameter\c!framecolor, + linecolor=\textbackgroundparameter\c!framecolor, + lineoffset=\textbackgroundparameter\c!frameoffset, + fillcolor=\textbackgroundparameter\c!backgroundcolor, + filloffset=\textbackgroundparameter\c!backgroundoffset, + gridwidth=\textbackgroundparameter\c!rulethickness, + gridshift=\textbackgroundparameter\c!voffset, + linewidth=\textbackgroundparameter\c!rulethickness, + lineradius=\textbackgroundparameter\c!radius}}} + +\permanent\protected\def\stoptextbackground + {\anch_backgrounds_text_stop_indeed + \carryoverpar\endgroup} % why doesn't this work ? + +\permanent\protected\def\starttextbackgroundmanual + {\begingroup + \c_anch_backgrounds_pos_state\plusone + \usetextbackgroundstyleandcolor\c!style\c!color + \anch_backgrounds_bpos} + +\permanent\protected\def\stoptextbackgroundmanual + {\anch_backgrounds_epos + \carryoverpar\endgroup} + +\def\anch_backgrounds_text_start_txt + {\ifvmode \dontleavehmode \fi + \begingroup + \c_anch_backgrounds_pos_state\plusone + \usetextbackgroundstyleandcolor\c!style\c!color + \anch_backgrounds_bpos} + +\def\anch_backgrounds_text_stop_txt + {\anch_backgrounds_epos + \carryoverpar\endgroup} + +\newskip\textbackgroundskip + +% maybe we should have a resetter for such compensation struts + +\def\anch_backgrounds_reset_attributes + {\scratchcounter\c_attr_snapmethod + \resetallattributes % \c_attr_linenumber\attributeunsetvalue + \c_attr_snapmethod\scratchcounter} + +\def\anch_backgrounds_text_start_par % beware .. background shapes + {\endgraf % new + \textbackgroundparameter\c!before + \begingroup + \c_anch_backgrounds_pos_state\plustwo + \begingroup + \anch_backgrounds_reset_attributes + \noindent + \ifgridsnapping + \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!topoffset}% + \ifdim\textbackgroundskip>\zeropoint + \struttedbox % not always ok (e.g. setups) + {\hpack{\raise\textbackgroundskip\hpack{\anch_backgrounds_bpos}}}% + \else + \anch_backgrounds_bpos + \fi + \else + \anch_backgrounds_bpos + \fi + \endgraf % we need a vertical nobreak - 29/06/2004 + \endgroup + \nobreak + \vskip-\lineheight + \nobreak + \ifgridsnapping \else + \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!topoffset}% + \ifdim\textbackgroundskip>\zeropoint + \kern\textbackgroundskip\nobreak + \fi + \fi + \dosetleftskipadaption{\textbackgroundparameter\c!leftoffset}% + \advance\leftskip\leftskipadaption + \dosetleftskipadaption{\textbackgroundparameter\c!rightoffset}% + \advance\rightskip\leftskipadaption + % new + \dosetraggedcommand{\textbackgroundparameter\c!align}% + \raggedcommand + % + \usetextbackgroundstyleandcolor\c!style\c!color + \nowhitespace + \seteffectivehsize + \doinhibitblank % \blank[\v!disable]% new + \par} + +\def\anch_backgrounds_text_stop_par + {\par + \removelastskip % new + \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!bottomoffset}% + \ifdim\lastskip>\zeropoint + \advance\textbackgroundskip-\lastskip + \fi + \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint + \kern\textbackgroundskip\nobreak + \fi \fi + \nobreak + \vskip-\dimexpr\lineheight+\parskip\relax % problem: we loose the hangindent + \nobreak + \endgroup + \begingroup + \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM + \anch_backgrounds_reset_attributes + \nobreak \noindent \strut \hfill \kern\zeropoint + % so far + \spac_helpers_assign_skip\textbackgroundskip{\textbackgroundparameter\c!bottomoffset}% + \ifgridsnapping % experimental, pascal (todo: topoffset in same way) + \ifdim\textbackgroundskip>\zeropoint + \struttedbox % not always ok (e.g. setups) + {\hpack{\lower\textbackgroundskip\hpack{\anch_backgrounds_epos}}}% + \else + \anch_backgrounds_epos + \fi + \else + \anch_backgrounds_epos + \fi + \endgraf + \carryoverpar\endgroup + \endgraf % new + \textbackgroundparameter\c!after} + +\permanent\protected\def\checkpositionoverlays % overloads \relax in anch-pgr + {\ifproductionrun + \enabletextarearegistration + \enablehiddenbackground + \enforced\glet\checkpositionoverlays\relax + \fi} + +% shape handling + +\definesystemattribute[textbackground][public] + +% \def\page_prepare_backgrounds#1% +% {\clf_collectbackgrounds\realpageno#1\relax} + +\def\anch_backgrounds_bpos + {\ifconditional\c_anch_backgrounds_pos_no_shape + \c_attr_textbackground\attributeunsetvalue + \bposkind\v_anch_backgrounds_text_current\plusthree + \orelse\ifnum\c_anch_backgrounds_pos_state=\plusone + \bposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state + \clf_registerbackground{\v_anch_backgrounds_text_current}% + \else + \bposkind\v_anch_backgrounds_text_current\c_anch_backgrounds_pos_state + \c_attr_textbackground\attributeunsetvalue + \fi} + +% plugs into other code + +\def\strc_floats_wrap_free_region + {\global\setbox\floatbox\hpack % we always need to wrap + {\ifconditional\c_strc_floats_trace_free + \strc_floats_show_free_region + \fi + \box\floatbox}} + +\startuseMPgraphic{floatfree} + draw_free_region( + \the\wd\floatbox, + \the\ht\floatbox, + \the\dp\floatbox, + \the\d_free_offset_left, + \the\d_free_offset_right, + \the\d_free_offset_top, + \the\d_free_offset_bottom + ) ; +\stopuseMPgraphic + +\def\strc_floats_show_free_region + {\lower\dp\floatbox\hpack to \zeropoint {\useMPgraphic{floatfree}}} + +\newconditional\c_strc_floats_mark_as_free +\newconditional\c_strc_floats_trace_free +\newconstant \c_free_offset_kind +\newdimen \d_free_offset_left +\newdimen \d_free_offset_right +\newdimen \d_free_offset_top +\newdimen \d_free_offset_bottom + +\installtextracker{floats.freeregion} + {\settrue \c_strc_floats_trace_free} + {\setfalse\c_strc_floats_trace_free} + +\def\strc_floats_mark_as_free#1#2#3#4#5% + {\c_free_offset_kind #1% + \d_free_offset_left #2% + \d_free_offset_right #3% + \d_free_offset_top #4% + \d_free_offset_bottom#5% + \strc_floats_wrap_free_region + \anch_mark_tagged_box_free + \floatbox + \c_free_offset_kind + \d_free_offset_left + \d_free_offset_right + \d_free_offset_top + \d_free_offset_bottom} + +\ifx\strc_floats_mark_pag_as_free\relax \else + \writestatus{error}{wrong place for pag_as_free}\wait +\fi + +\ifx\strc_floats_mark_par_as_free\relax \else + \writestatus{error}{wrong place for par_as_free}\wait +\fi + +\def\strc_floats_mark_pag_as_free + {\ifpositioning + \ifconditional\c_strc_floats_mark_as_free + \strc_floats_mark_as_free + \plusone + \zeropoint + \zeropoint + \d_strc_floats_top + \d_strc_floats_bottom + \fi + \fi} + +\def\strc_floats_mark_par_as_free + {\ifpositioning + \ifconditional\c_strc_floats_mark_as_free + \ifcase\c_page_sides_float_type + \or % backspace + \strc_floats_mark_as_free + \plustwo + \zeropoint + \d_page_sides_rightoffset + \d_page_sides_topskip + \d_page_sides_bottomskip + \or % leftedge + \strc_floats_mark_as_free + \plustwo + \zeropoint + \d_page_sides_rightoffset + \d_page_sides_topskip + \d_page_sides_bottomskip + \or % leftmargin + \strc_floats_mark_as_free + \plustwo + \zeropoint + \d_page_sides_rightoffset + \d_page_sides_topskip + \d_page_sides_bottomskip + \or % leftside + \strc_floats_mark_as_free + \plustwo + \d_page_sides_leftskip % maybe too + \d_page_sides_margin + \d_page_sides_topskip + \d_page_sides_bottomskip + \or % rightside + \strc_floats_mark_as_free + \plusthree + \d_page_sides_margin + \d_page_sides_rightskip % maybe too + \d_page_sides_topskip + \d_page_sides_bottomskip + \or % rightmargin + \strc_floats_mark_as_free + \plusthree + \d_page_sides_leftoffset + \zeropoint + \d_page_sides_topskip + \d_page_sides_bottomskip + \or % rightedge + \strc_floats_mark_as_free + \plusthree + \d_page_sides_leftoffset + \zeropoint + \d_page_sides_topskip + \d_page_sides_bottomskip + \or % cutspace + \strc_floats_mark_as_free + \plusthree + \d_page_sides_leftoffset + \zeropoint + \d_page_sides_topskip + \d_page_sides_bottomskip + \fi + \fi + \fi} + +% so far + +\setuptextbackground + [\c!mp=mpos:region:draw, + \c!method=mpos:region, + \c!state=\v!start, + \c!location=\v!text, + \c!leftoffset=\!!zeropoint, % 1em, + \c!rightoffset=\textbackgroundparameter\c!leftoffset, + \c!topoffset=\!!zeropoint, % \v!medium, + \c!bottomoffset=\textbackgroundparameter\c!topoffset, + \c!criterium=\plusone, + \c!level=-1, + \c!alternative=0, + \c!align=, + \c!dash=0, % to be internationalized + \c!background=\v!color, + \c!backgroundcolor=lightgray, + \c!backgroundoffset=\!!zeropoint, + \c!corner=\v!rectangular, + \c!radius=.5\bodyfontsize, + \c!voffset=\!!zeropoint, + \c!frame=\v!on, + \c!framecolor=blue, + \c!frameoffset=\!!zeropoint, + \c!rulethickness=\linewidth] + +%D The \METAPOST\ connection: + +% gridtype = 1 => baseline +% gridtype = 2 => betweenline + +\setupMPvariables + [mpos:region] + [mp=mpos:region:unset, + gridtype=0, + linetype=1, + filltype=1, + dashtype=0, % 1 = dashed, 2 = dashed with background + gridcolor=red, + linecolor=blue, + fillcolor=lightgray, + filloffset=\!!zeropoint, + linewidth=\linewidth, + gridwidth=\linewidth, + gridshift=\!!zeropoint, + lineradius=.5\bodyfontsize, + lineoffset=\!!zeropoint, + dashtype=1] + +\startuseMPgraphic{mpos:region:setup} + boxgridtype := \MPvar{gridtype} ; + boxlinetype := \MPvar{linetype} ; + boxfilltype := \MPvar{filltype} ; + boxdashtype := \MPvar{dashtype} ; + boxfilloffset := \MPvar{filloffset} ; + boxlinewidth := \MPvar{linewidth} ; + boxgridwidth := \MPvar{gridwidth} ; + boxgridshift := \MPvar{gridshift} ; + boxlineradius := \MPvar{lineradius} ; + boxlineoffset := \MPvar{lineoffset} ; + % + def boxgridcolor = \MPvar{gridcolor} enddef ; + def boxlinecolor = \MPvar{linecolor} enddef ; + def boxfillcolor = \MPvar{fillcolor} enddef ; + % + def boxgridoptions = withcolor boxgridcolor enddef ; + def boxlineoptions = withcolor boxlinecolor enddef ; + def boxfilloptions = withcolor boxfillcolor enddef ; +\stopuseMPgraphic + +\startuseMPgraphic{mpos:region:extra} + % user stuff +\stopuseMPgraphic + +\startuseMPgraphic{mpos:region:anchor} + setbounds currentpicture to multibox ; +\stopuseMPgraphic + +\startMPpositiongraphic{mpos:region}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius,lineoffset} + \includeMPgraphic{mpos:region:setup} ; + \includeMPgraphic{mpos:region:extra} ; + \MPgetmultipars{\MPvar{self}}{\MPanchorid} ; + \includeMPgraphic{\MPvar{mp}} ; + \includeMPgraphic{mpos:region:anchor} ; +\stopMPpositiongraphic + +%D For old times sake: + +\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth} + string tag; tag := "\MPvar{self}" ; + path box ; box := positionbox(tag) ; + + box := box enlarged \MPvar{filloffset} ; + fill box withcolor \MPvar{fillcolor} ; + draw box withcolor \MPvar{linecolor} withpen pencircle scaled \MPvar{linewidth} ; + + positioninregion; +\stopMPpositiongraphic + +\startMPpositionmethod{mpos:region} + \MPpositiongraphic{mpos:region}{}% +\stopMPpositionmethod + +\startuseMPgraphic{mpos:region:draw} + draw_multi_pars +\stopuseMPgraphic + +\startuseMPgraphic{mpos:region:show} + show_multi_pars +\stopuseMPgraphic + +\startuseMPgraphic{mpos:region:kind} + show_multi_kind +\stopuseMPgraphic + +\startuseMPgraphic{mpos:region:sideline} + draw_multi_side +\stopuseMPgraphic + +\startuseMPgraphic{mpos:region:sideline:dashed} + draw_multi_side_path dashed evenly ; +\stopuseMPgraphic + +%D As an example we define a grid background: + +\definetextbackground + [\v!grid] + [\c!state=\v!stop, + \c!location=\v!paragraph, + \c!frame=\v!off, + \c!framecolor=red, + \c!background=, + \c!alternative=1] + +\ifx\basegrid\undefined \else \overloaded\aliased\letcsname\v!grid\endcsname\basegrid \fi + +%D Some examples (that might become modules anch-imp-whatever): + +\setupMPvariables + [mpos:encircle] + [fillcolor=lightgray, + filloffset=\!!zeropoint, + linecolor=blue, + lineoffset=5pt, + linewidth=1pt] + +\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset} + \MPgetposboxes{\MPvar{self}}{\MPanchorid} + if nofposboxes = 1 : + posboxes[1] := posboxes[1] enlarged \MPvar{lineoffset} cornered \MPvar{lineoffset} ; + fill posboxes[1] withcolor \MPvar{fillcolor} ; + draw posboxes[1] withpen pencircle scaled \MPvar{linewidth} withcolor \MPvar{linecolor} ; + fi ; +\stopMPpositiongraphic + +\setupMPvariables + [mpos:connect] + [linecolor=red, + lineoffset=.25ex, + linewidth=1pt] + +\startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth} + boxlinewidth := \MPvar{linewidth} ; + boxlineoffset := \MPvar{lineoffset} ; + def boxlineoptions = withcolor \MPvar{linecolor} enddef ; + \MPgetposboxes{\MPvar{from},\MPvar{to}}{\MPanchorid} + connect_positions ; +\stopMPpositiongraphic + +\protect \endinput + +\definetextbackground[underline] [location=text,alternative=1,background=,frame=off] +\definetextbackground[overstrike] [location=text,alternative=2,background=,frame=off] +\definetextbackground[exlines] [location=text,alternative=3,background=,frame=off] +\definetextbackground[strikethrough][location=text,alternative=4,background=,frame=off] + +\definestartstop [underline] + [before={\starttextbackground[underline]}, + after=\stoptextbackground] + +\definestartstop + [overstrike] + [before={\starttextbackground[overstrike]}, + after=\stoptextbackground] + +\definestartstop + [exlines] + [before={\starttextbackground[exlines]}, + after=\stoptextbackground] + +\definestartstop + [strikethrough] + [before={\starttextbackground[strikethrough]}, + after=\stoptextbackground] + +\definetextbackground + [sideline] + [mp=mpos:region:sideline, + location=paragraph, + framecolor=red, + frameoffset=5mm] + +\definestartstop [sideline] + [before={\starttextbackground[sideline]}, + after=\stoptextbackground] + +\starttext + + \startunderline \input tufte \stopunderline \blank + \startoverstrike \input tufte \stopoverstrike \blank + \startexlines \input tufte \stopexlines \blank + \startstrikethrough \input tufte \stopstrikethrough \blank + \startsideline \input tufte \stopsideline \blank + + \page + + \startpositionoverlay{text-1} + \setMPpositiongraphic{connect-1-b}{mpos:connect}{from=connect-1-b,to=connect-1-e} + \setMPpositiongraphic{connect-1-e}{mpos:connect}{from=connect-1-b,to=connect-1-e} + \stoppositionoverlay + + \startpositionoverlay{text-1} + \setMPpositiongraphic{encircle-1}{mpos:encircle}{self=encircle-1} + \stoppositionoverlay + + test \hpos{connect-1-b}{START} + \dorecurse{10}{\input ward} + \hpos{encircle-1}{\strut HERE} + \dorecurse{10}{\input ward} + \hpos{connect-1-e}{STOP} test + +\stoptext diff --git a/tex/context/base/mkiv/anch-pgr.mkxl b/tex/context/base/mkiv/anch-pgr.mkxl new file mode 100644 index 000000000..3439fd5a2 --- /dev/null +++ b/tex/context/base/mkiv/anch-pgr.mkxl @@ -0,0 +1,445 @@ +%D \module +%D [ file=anch-pgr, % split off core-pos +%D version=1999.08.01, +%D title=\CONTEXT\ Anchoring Macros, +%D subtitle=Positioning Graphics, +%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 Anchoring Macros / Grapics} + +%D Before we come to graphics support, we have to make sure of the reference point +%D on the page. The next macros do so and are hooked into the page building routine. + +\registerctxluafile{anch-pgr}{} + +\unprotect + +%D A few more low level macros take care of defining and recalling actions. Actions +%D are saved globally! The lists can become quite long because there can be lots of +%D parameters passed on so we clean up the list afterwards. + +\newtoks\everypositionaction +\newtoks\everyinsertpositionaction +\newtoks\everycleanpositionaction + +\installcorenamespace{positionaction} +\installcorenamespace{positioncleanup} + +\protected\def\anch_positions_set_action#1% + {\expandafter\gdef\csname\??positionaction#1\endcsname} % nicely gobbles spaces + +\permanent\protected\def\doifpositionaction#1% + {\ifcsname\??positionaction#1\endcsname + \expandafter\firstofoneargument + \else + \expandafter\gobbleoneargument + \fi} + +\permanent\protected\def\doifelsepositionaction#1% + {\ifcsname\??positionaction#1\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\aliased\let\doifpositionactionelse\doifelsepositionaction + +\protected\def\dopositionaction#1% + {\edef\currentpositionaction{#1}% + \ifcsname\??positionaction\currentpositionaction\endcsname + \anch_positions_action_indeed + \fi} + +\def\anch_positions_action_indeed + {\doifelseposition\currentpositionaction + \anch_positions_action_indeed_yes + \anch_positions_action_indeed_nop} + +\def\anch_positions_action_indeed_nop + {\anch_positions_trace_action_nop} + +\def\anch_positions_action_indeed_yes % we need a way to figure out if we have actions + {\begingroup + \setbox\scratchbox\hbox % \hpack + {\anch_positions_trace_action_yes + \the\everyinsertpositionaction + \the\everypositionaction + \begincsname\??positionaction\currentpositionaction\endcsname + \anch_positions_cleanup_action}% + \smashedbox\scratchbox % smashing is really needed else we get problems with too big overlays + \endgroup} + +\protected\def\anch_positions_trace_action_nop_indeed + {\anch_positions_trace\clap\darkred{<\currentpositionaction>}} + +\protected\def\anch_positions_trace_action_yes_indeed + {\anch_positions_trace\clap\darkgreen{<\currentpositionaction>}} + +\let\anch_positions_trace_action_nop\relax +\let\anch_positions_trace_action_yes\relax + +\appendtoks + \let\anch_positions_trace_action_nop\anch_positions_trace_action_nop_indeed + \let\anch_positions_trace_action_yes\anch_positions_trace_action_yes_indeed +\to \t_anch_positions_tracers + +%D Here the complication has to do with collecting actions for later execution. This +%D collection is especially handy when we want to move actions to a specific layer. +%D Such series of actions are stored in a macro that is cleaned up after each +%D invocation. + +\def\anch_positions_cleanup_action % not in trialtypesetting + {\ifcsname\??positioncleanup\currentpositionaction\endcsname + \the\everycleanpositionaction + \setxvalue{\??positioncleanup\currentpositionaction}{\csname\??positioncleanup\currentpositionaction\endcsname}% + \fi} + +\permanent\protected\def\handlepositionaction#1\with#2\on#3% ugly, will change + {\begingroup + \edef\currentpositionanchor + {\ifempty\currentpositionoverlay#3\else\currentpositionoverlay::\MPanchoridentifier\fi}% + \normalexpanded{\anch_positions_set_action{\currentpositionanchor}{\noexpand\getvalue{\??positioncleanup\currentpositionanchor}}}% + \let#1\relax + \ifcsname\??positioncleanup\currentpositionanchor\endcsname + \setxvalue{\??positioncleanup\currentpositionanchor}% + {\csname\??positioncleanup\currentpositionanchor\endcsname#1#2}% + \else + \setxvalue{\??positioncleanup\currentpositionanchor}% + {#1#2}% + \fi + \endgroup} + +%D The first version of this module implemented head and tail anchors. Currently we +%D stick to just one anchor and derive the head and tail anchors from this one. We +%D set these anchors before and after each page. + +\newdimen\c_anch_page_width +\newdimen\c_anch_page_height + +\protected\def\anch_positions_register_page#1% this one is flushed first ! ... can't we avoid this one + {\ifpositioning\ifcase\realpageno\or + \ifdim\c_anch_page_height=\paperheight + \ifdim\c_anch_page_width=\paperwidth + % no change + \else + \c_anch_page_width \paperwidth + \c_anch_page_height\paperheight + \anch_make_page_box{#1}% \ifvbox#1\setbox#1\hpack{\box#1}\fi + \fi + \else + \c_anch_page_width \paperwidth + \c_anch_page_height\paperheight + \anch_make_page_box{#1}% \ifvbox#1\setbox#1\hpack{\box#1}\fi + \fi + \fi\fi} + +\protected\def\anch_positions_place_anchors + {\ifpositioning + \anch_positions_place_anchors_yes + \else + \anch_positions_place_anchors_nop + \fi} + +\def\anch_positions_place_anchors_yes % todo : depth pagebox + {\begingroup + \setbox\scratchbox\emptyhbox + \ht\scratchbox\textheight + \dp\scratchbox\zeropoint % redundant + \wd\scratchbox\makeupwidth + \anch_mark_text_box\scratchbox + \box\scratchbox + \endgroup} + +\def\anch_positions_place_anchors_nop + {\vkern\textheight} + +%D \macros +%D {positionoverlay,startpositionoverlay} +%D +%D As long as we're dealing with graphics it makes much sense to use the available +%D overlay mechanism. For this purpose, we define some dedicated overlay extensions. +%D +%D \startbuffer[sample] +%D \defineoverlay [sample] [\positionoverlay{sample}] +%D +%D \startpositionoverlay{sample} +%D \setMPpositiongraphic{A-1}{connectcenter}{from=A-1,to=A-2} +%D \stoppositionoverlay +%D \stopbuffer +%D +%D \typebuffer[sample] +%D +%D \startbuffer[graphic] +%D \startMPpositiongraphic{connectcenter} +%D path pa, pb ; pair ca, cb ; +%D initialize_box(\MPpos{\MPvar{from}}) ; pa := pxy ; ca := cxy ; +%D initialize_box(\MPpos{\MPvar{to}}) ; pb := pxy ; cb := cxy ; +%D draw pa withcolor red ; +%D draw pb withcolor red ; +%D draw ca -- cb withcolor blue ; +%D anchor_box(\MPanchor{\MPvar{from}}) ; +%D \stopMPpositiongraphic +%D \stopbuffer +%D +%D We can best demonstrate this in an example, say: +%D +%D \startbuffer[text] +%D \framed +%D [backgroundachtergrond=sample,align=middle,width=7cm] +%D {We want to connect \hpos {A-1} {this} word with its +%D grammatical cousin \hpos {A-2} {that}.} +%D \stopbuffer +%D +%D \typebuffer[text] +%D +%D \startlinecorrection +%D %\getbuffer[graphic,sample,text] +%D \stoplinecorrection +%D +%D The graphic is defined in the following way, using some macros defined in an +%D auxiliary \METAPOST\ module that is preloaded. +%D +%D \typebuffer[graphic] + +\def\MPanchoridentifier{mpa} % {mp-anchor} + +%D The rest of the definitions concerning such overlays may look complicated, + +\let\currentpositionoverlay\empty + +%D Position actions are automatically executed when a position is set. + +\def\textbackgroundoverlay#1{\v!text#1} +\def\MPanchornumber {\the\realpageno} + +\permanent\protected\def\positionoverlay % the test prevents too many redundant positions + {\ifpositioning % in (not used) text* position layers + \expandafter\anch_positions_overlay_indeed + \else % also \iftrialtypesetting test here? + \expandafter\gobbleoneargument + \fi} + +\def\anch_positions_overlay_indeed#1% + {\begingroup + \edef\currentpositionoverlay{#1}% + \ifcsname\??positionaction\currentpositionoverlay::\MPanchoridentifier\endcsname + \anch_positions_overlay_compose + \fi + \endgroup} + +\def\MPoverlayanchor#1{\MPpos\MPanchorid} + +\def\anch_positions_overlay_compose + {\vpack to \d_overlay_height + {%\writestatus{!!!}{\currentpositionoverlay/\MPanchoridentifier/\MPanchornumber}% + \edef\MPanchorid{\currentpositionoverlay::\MPanchoridentifier:\MPanchornumber}% realpageno + % \edef\MPanchor##1{\MPpos\MPanchorid}% + \let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used + \the\everyinsertpositionaction + \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid + \setbox\scratchbox\hbox to \d_overlay_width % \hpack + {\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% + \ht\scratchbox\d_overlay_height + \dp\scratchbox\zeropoint + \anch_mark_tagged_box\scratchbox\MPanchorid % needs an hbox + \box\scratchbox + \vfill}} + +\permanent\protected\def\positionregionoverlay % shares regions + {\ifpositioning + \expandafter\anch_positions_region_overlay_indeed + \else % also \iftrialtypesetting test here? + \expandafter\gobbletwoarguments + \fi} + +\let\currentpositionregion\empty + +\def\anch_positions_region_overlay_indeed#1#2% + {\begingroup + \edef\currentpositionregion {#1}% + \edef\currentpositionoverlay{#2}% + \ifcsname\??positionaction\currentpositionoverlay::\MPanchoridentifier\endcsname + \anch_positions_region_overlay_compose + \fi + \endgroup} + +\def\anch_positions_region_overlay_compose + {\vpack to \d_overlay_height + {\let\MPanchorid\currentpositionregion + \let\MPanchor\MPoverlayanchor % no need to fetch it already, seldom used + \the\everyinsertpositionaction + \copyposition{\currentpositionoverlay::\MPanchoridentifier}\MPanchorid + \setbox\scratchbox\hbox to \d_overlay_width % \hpack + {\dopositionaction{\currentpositionoverlay::\MPanchoridentifier}\hss}% + \ht\scratchbox\d_overlay_height + \dp\scratchbox\zeropoint + \box\scratchbox + \vfill}} + +% \let\anch_positions_overlay_nop\gobbleoneargument + +\permanent\protected\def\startpositionoverlay + {\iftrialtypesetting + \expandafter\anch_positions_overlay_start_nop + \else + \expandafter\anch_positions_overlay_start_yes + \fi} + +\def\anch_positions_overlay_start_nop#1\stoppositionoverlay + {} + +\ifdefined\checkpositionoverlays \else \let\checkpositionoverlays\relax \fi + +\let\currentpositionoverlay\empty + +\def\anch_positions_overlay_start_yes#1% + {\checkpositionoverlays + \edef\currentpositionoverlay{#1}} + +\permanent\protected\def\stoppositionoverlay + {\let\currentpositionoverlay\empty} + +%D A position graphic is a normal (non||reused) \METAPOST\ graphic, used +%D immediately, with zero dimensions, so that a sequence of them does not harm. + +\installcorenamespace{positiongraphic} +\installcorenamespace{positionmethod} +%installcorenamespace{graphicvariable} + +\newbox\b_anch_positions_graphic + +\permanent\tolerant\protected\def\startMPpositiongraphic#=#*#=#:#3\stopMPpositiongraphic % tag list mpcode + {\setgvalue{\??positiongraphic#1}{\anch_positions_meta_graphic_use{#1}{#2}{#3}}} + +\aliased\let\stopMPpositiongraphic\relax + +\def\anch_positions_meta_graphic_prepare + {\ifcsname\??graphicvariable\currentmpvariableclass:self\endcsname \else + \letvalue{\??graphicvariable\currentmpvariableclass:self}\currentposition + \fi + \ifcsname\??graphicvariable\currentmpvariableclass:from\endcsname \else + \letvalue{\??graphicvariable\currentmpvariableclass:from}\currentposition + \fi} + +\def\anch_positions_meta_graphic_use#1#2#3% + {\begingroup + \meta_prepare_variables{#2}% + \anch_positions_meta_graphic_prepare + \startMPcode#3\stopMPcode + \endgroup} + +\permanent\tolerant\protected\def\MPpositiongraphic#=#*#=% + {\ifcsname\??positionmethod#1\endcsname % method + \expandafter\anch_positions_meta_graphic_direct_method + \orelse\ifcsname\??positiongraphic#1\endcsname + \expandafter\anch_positions_meta_graphic_direct_normal + \else + \expandafter\gobbletwoarguments + \fi{#1}{#2}} + +\def\anch_positions_meta_graphic_direct_method{\anch_positions_meta_graphic_direct\??positionmethod } +\def\anch_positions_meta_graphic_direct_normal{\anch_positions_meta_graphic_direct\??positiongraphic} + +\def\anch_positions_meta_graphic_direct#1#2#3% what tag setups + {\begingroup + \setupMPvariables[#2][#3]% + \edef\currentmpvariableclass{#2}% + \anch_positions_meta_graphic_prepare + \obeyMPboxorigin % do we also set the size ? when needed this must be done in mp ... might change + \enforced\def\MPpositiongraphic{\anch_positions_meta_graphic_nested{#3}}% takes two extra arguments + \setbox\b_anch_positions_graphic\hbox % \hpack + {\ignorespaces\begincsname#1#2\endcsname\removelastspace}% + \smashbox\b_anch_positions_graphic + \box\b_anch_positions_graphic + \endgroup} + +\def\anch_positions_meta_graphic_nested#1#2#3% nesting used in prikkels / pascal (might go away) + {\begingroup + \setupMPvariables[#2][#1,#3]% + \edef\currentmpvariableclass{#2}% + \anch_positions_meta_graphic_prepare + \begincsname\??positiongraphic#2\endcsname + \endgroup}% + +\permanent\def\startMPpositionmethod#1#2\stopMPpositionmethod + {\setgvalue{\??positionmethod#1}{#2}} % todo: var list here + +\aliased\let\stopMPpositionmethod\relax + +%D Simple one position graphics. + +\permanent\tolerant\protected\def\setMPpositiongraphic#=#*#=#*#=% + {\ifempty\currentpositionoverlay + \anch_positions_set_action{#1}{\MPpositiongraphic{#2}{#3}}% + \else % silly can be one + \anch_positions_meta_graphic_handle{#1}{#2}{#3}% + \fi} + +\def\anch_positions_meta_graphic_handle#1#2#3% combine with boxes + {\handlepositionaction\anch_positions_meta_graphic_handle_indeed\with{#1}{#2}{#3}\on{#2}} + +\def\anch_positions_meta_graphic_insert#1#2#3% pos tag setups + {\ifnum\MPp{#1}=\realpageno\relax % extra saveguard + \def\currentposition{#1}\MPpositiongraphic{#2}{#3}% + \fi} + +\let\anch_positions_meta_graphic_handle_indeed\relax + +\appendtoks + \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_insert +\to \everyinsertpositionaction + +\def\anch_positions_meta_graphic_cleanup#1#2#3% pos tag setups + {\ifnum\MPp{#1}<\realpageno \else + \noexpand\anch_positions_meta_graphic_handle_indeed{#1}{#2}{#3}% + \fi} + +\appendtoks + \let\anch_positions_meta_graphic_handle_indeed\anch_positions_meta_graphic_cleanup +\to \everycleanpositionaction + +%D Graphics that span two positions (beware, does not cross pages). + +\permanent\tolerant\protected\def\setMPpositiongraphicrange#=#*#=#*#=#*#=% + {\ifempty\currentpositionoverlay + \anch_positions_set_action{#1}{\MPpositiongraphic{#3}{#4}}% + \else + \anch_positions_meta_graphic_handle_range{#1}{#2}{#3}{#4}% + \fi} + +\def\anch_positions_meta_graphic_handle_range#1#2#3#4% + {\handlepositionaction\anch_positions_meta_graphic_handle_range_indeed\with{#1}{#2}{#3}{#4}\on{#2}} + +\def\anch_positions_meta_graphic_insert_range#1#2#3#4% pos pos tag setups + {\clf_doifelserangeonpage{#1}{#2}\realpageno + {\def\currentposition{#1}% + \MPpositiongraphic{#3}{#4}}% + {}} + +\appendtoks + \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_insert_range +\to \everyinsertpositionaction + +\def\anch_positions_meta_graphic_cleanup_range#1#2#3#4% pos tag setups + {\ifnum\MPp{#2}<\realpageno \else + \noexpand \anch_positions_meta_graphic_handle_range_indeed{#1}{#2}{#3}{#4}% + \fi} + +\appendtoks + \let\anch_positions_meta_graphic_handle_range_indeed\anch_positions_meta_graphic_cleanup_range +\to \everycleanpositionaction + +\let\anch_positions_meta_graphic_handle_range_indeed\gobblefourarguments + +% Helpers: + +\permanent\def\MPgetposboxes #1#2{\clf_fetchposboxes{#1}{#2}\realpageno} +\permanent\def\MPgetmultipars#1#2{\clf_fetchmultipar{#1}{#2}\realpageno} + +\protect \endinput diff --git a/tex/context/base/mkiv/anch-snc.mkxl b/tex/context/base/mkiv/anch-snc.mkxl new file mode 100644 index 000000000..5f0246155 --- /dev/null +++ b/tex/context/base/mkiv/anch-snc.mkxl @@ -0,0 +1,160 @@ +%D \module +%D [ file=anch-snc, +%D version=2003.12.01, % actually 1999 so real old +%D title=\CONTEXT\ Anchoring Macros, +%D subtitle=Synchronization, +%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 The original is in the mkii file. It does more at the \TEX\ end and +%D has some more magic. If we really need that I'll add it. After all, +%D in mkiv we can do things different. + +%D TODO: bleed : + left , minus right oro check if it touches page ... autobleed + +\writestatus{loading}{ConTeXt Anchoring Macros / Synchronization} + +\registerctxluafile{anch-snc}{} + +\unprotect + +\ifx\??syncposcounter\undefined \installcorenamespace{syncposcounter} \fi +\ifx\s!syncpos \undefined \def\s!syncpos {syncpos} \fi + +\let\c_sync_n\relax + +\unexpanded\def\definesyncpositions[#1]% + {\ifcsname\??syncposcounter:#1\endcsname \else + \expandafter\newcount\csname\??syncposcounter:#1\endcsname + \fi} + +\unexpanded\def\syncposition + {\dodoubleempty\anch_sync_position} + +\def\anch_sync_position[#1][#2]% we could actually use par positions + {\dontleavehmode + \ifcsname\??syncposcounter:#1\endcsname + \let\c_sync_n\lastnamedcs + \global\advance\c_sync_n\plusone + \enabletextarearegistration + \setpositionplus{\s!syncpos:#1:\the\c_sync_n}{#2}\hpack{\strut}% + \else + \strut + \fi + \ignorespaces} + +\protect + +\continueifinputfile{anch-snc.mkiv} + +\starttext + +% \setuppapersize[A4][A3] + +\setuplayout[location=middle] + +\setupbodyfont[dejavu] + +\definesyncpositions[1] +\definesyncpositions[2] + +% \enabletrackers[metapost.lua] + +\startMPdefinitions + input "mp-asnc.mpiv" ; + + SetSyncColor(1,0,"magenta") ; + SetSyncColor(1,1,"red") ; + SetSyncColor(1,2,"green") ; + SetSyncColor(1,3,"blue") ; + SetSyncColor(1,4,"yellow") ; + + SetSyncColor(2,0,"magenta") ; + SetSyncColor(2,1,"red") ; + SetSyncColor(2,2,"green") ; + SetSyncColor(2,3,"blue") ; + SetSyncColor(2,4,"yellow") ; +\stopMPdefinitions + +\startuseMPgraphic{sync1} + StartPage ; + StartSync(1) ; + SyncHOffset := 0 ; + SyncWidth := BackSpace - LeftMarginDistance; + CollectSyncDataPage ; + % ExtendSyncPaths ; % to top of text area + PruneSyncPaths ; % clip top / bottom + CollapseSyncPaths ; + MakeSyncPaths ; + % DrawSyncPaths ; + FillSyncPaths ; + StopSync ; + clip currentpicture to Page ; + setbounds currentpicture to Page ; + StopPage ; +\stopuseMPgraphic + +\startuseMPgraphic{sync2} + StartSync(2) ; + SyncHOffset := -1cm ; + SyncWidth := 1cm ; + CollectSyncDataRegion(OverlayRegion) ; + ExtendSyncPaths ; % to top of text area + MakeSyncPaths ; + FillSyncPaths ; + StopSync ; + clip currentpicture to OverlayBox leftenlarged 1cm; + setbounds currentpicture to OverlayBox ; +\stopuseMPgraphic + +\defineoverlay[tempoverlay1][\useMPgraphic{sync1}] +\defineoverlay[tempoverlay2][\useMPgraphic{sync2}] + +\setupbackgrounds[page][background=tempoverlay1] + +\framed[region=yes,background=tempoverlay2,width=14cm,align=normal]{ + \syncposition[2][1]\samplefile{ward}\endgraf + \syncposition[2][2]\samplefile{ward}\endgraf + \syncposition[2][3]\samplefile{ward}\endgraf +} + + +\vskip1cm \hskip1cm \framed[region=yes,background=tempoverlay2,width=16cm,align=normal]{ + \syncposition[2][1]\samplefile{ward}\endgraf + \syncposition[2][2]\samplefile{ward}\endgraf + \syncposition[2][3]\samplefile{ward}\endgraf +} + +\vskip1cm \hskip1cm \framed[region=yes,background=tempoverlay2,width=10cm,align=normal]{ + \syncposition[2][1]\samplefile{ward}\endgraf + \syncposition[2][2]\samplefile{ward}\endgraf + \syncposition[2][3]\samplefile{ward}\endgraf +} + + +\dorecurse {100} { +% \dorecurse {1} { + \startchapter[title={Test #1}] + \syncposition[1][1,reset]\dorecurse{20}{\samplefile{ward}\endgraf} + \syncposition[1][2]\dorecurse {4}{\samplefile{ward}\endgraf} + \syncposition[1][3]\dorecurse {7}{\samplefile{ward}\endgraf} + \syncposition[1][4]\dorecurse {3}{\samplefile{ward}\endgraf} + \stopchapter +} + +\dorecurse {100} { +% \dorecurse {1} { + \startchapter[title={Test #1}] + \syncposition[1][1]\dorecurse{1}{\samplefile{ward}\endgraf} + \syncposition[1][2]\dorecurse{1}{\samplefile{ward}\endgraf} + \syncposition[1][3]\dorecurse{1}{\samplefile{ward}\endgraf} + \syncposition[1][4]\dorecurse{1}{\samplefile{ward}\endgraf} + \stopchapter +} + +\stoptext diff --git a/tex/context/base/mkiv/anch-tab.mkxl b/tex/context/base/mkiv/anch-tab.mkxl index 0cc0b6dc9..8f4bb0b5b 100644 --- a/tex/context/base/mkiv/anch-tab.mkxl +++ b/tex/context/base/mkiv/anch-tab.mkxl @@ -87,19 +87,26 @@ \protected\def\tablepos {\normalexpanded{\global\posXCtoks\emptytoks\the\posXCtoks}} -\permanent\tolerant\protected\def\tbXC [#1]{\anch_table_check_state\ifparameters#1\or\anch_tables_indeed_XC [#1]\else\expandafter\NC\fi} -\permanent\tolerant\protected\def\tbGSC[#1]{\anch_table_check_state\ifparameters#1\or\anch_tables_indeed_GSC[#1]\else\expandafter\NC\fi} -\permanent\tolerant\protected\def\tbGFC[#1]{\anch_table_check_state\ifparameters#1\or\anch_tables_indeed_GFC[#1]\else\expandafter\NC\fi} -\permanent\tolerant\protected\def\tbGTC[#1]{\anch_table_check_state\ifparameters#1\or\anch_tables_indeed_GTC[#1]\else\expandafter\NC\fi} +\permanent\protected\def\tbXC {\anch_table_checked\anch_tables_indeed_XC } +\permanent\protected\def\tbGSC{\anch_table_checked\anch_tables_indeed_GSC} +\permanent\protected\def\tbGFC{\anch_table_checked\anch_tables_indeed_GFC} +\permanent\protected\def\tbGTC{\anch_table_checked\anch_tables_indeed_GTC} -\def\anch_table_check_state +\tolerant\def\anch_table_checked#1[#2]% {\iftrialtypesetting \global\settrue\tablehaspositions - \firstargumentfalse - \fi} + \expandafter\anch_tables_indeed_NC + \orelse\ifparameter#2\or + \expandafter#1% + \else + \expandafter\anch_tables_indeed_NC + \fi[#2]} + +\def\anch_tables_indeed_NC[#1]% + {\NC} \def\anch_tables_indeed_XC[#1]% - {{\overloaded\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}} + {{\enforced\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}} \def\anch_tables_step_XC#1% {\anch_tables_step_indeed_XC[#1]} diff --git a/tex/context/base/mkiv/catc-act.mkxl b/tex/context/base/mkiv/catc-act.mkxl new file mode 100644 index 000000000..4ccf22a7f --- /dev/null +++ b/tex/context/base/mkiv/catc-act.mkxl @@ -0,0 +1,51 @@ +%D \module +%D [ file=catc-act, +%D version=2006.09.18, +%D title=\CONTEXT\ Catcode Macros, +%D subtitle=Default Catcode Tables, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\unprotect + +%D \macros +%D {installactivecharacter, defineactivecharacter} +%D +%D This module deals with some active character handling and I still need to +%D update it to use \typ {\letcharcode <number> = \something}. This module +%D will be simplified stepwise. Look into the \MKIV\ variant for originals. +%D +%D There was a time when we had active double quotes and such but we no longer +%D do that. In fact, only the tilde and bar can be active in \CONTEXT. +%D +%D For those who love the more obscure features of \TEX: whenever you see +%D uppercase magic with active characters, keep in mind that this is something +%D deep down in the engine: handling of that specific case. The code here is +%D not used and not really tested. + +\permanent\protected\def\installactivecharacter#1 % + {\ifchknum#1\or + \scratchcounter #1\edef\scratchmacro{\expandtoken\othercatcode\scratchcounter}% + \else + \scratchcounter`#1\let \scratchmacro #1% + \fi + \normalexpanded{\startextendcatcodetable\ctxcatcodes\catcode\the\scratchcounter\activecatcode\stopextendcatcodetable}% + \letcatcodecommand \ctxcatcodes \scratchcounter \scratchmacro + \ifnum\currentcatcodetable=\ctxcatcodes \setcatcodetable\ctxcatcodes \fi} + +\permanent\protected\def\defineactivecharacter #1 #2% + {\ifchknum#1\or\letcharcode#1=#2\relax\else\letcharcode`#1=#2\relax\fi} + +\permanent\protected\def\makecharacteractive #1 % + {\catcode`#1\activecatcode} + +\permanent\protected\def\installanddefineactivecharacter #1 #2% + {\normalexpanded{\installactivecharacter \utfchar{#1} }% + \defineactivecharacter #1 #2} + +\protect \endinput diff --git a/tex/context/base/mkiv/catc-def.mkxl b/tex/context/base/mkiv/catc-def.mkxl new file mode 100644 index 000000000..e93345e1c --- /dev/null +++ b/tex/context/base/mkiv/catc-def.mkxl @@ -0,0 +1,147 @@ +%D \module +%D [ file=catc-def, +%D version=2006.09.18, +%D title=\CONTEXT\ Catcode Macros, +%D subtitle=Default Tables, +%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 The following catcode tables are rather \CONTEXT\ independent. + +\ifdefined\nilcatcodes \else \newcatcodetable \nilcatcodes \fi +\ifdefined\texcatcodes \else \newcatcodetable \texcatcodes \fi +\ifdefined\luacatcodes \else \newcatcodetable \luacatcodes \fi +\ifdefined\notcatcodes \else \newcatcodetable \notcatcodes \fi +\ifdefined\vrbcatcodes \else \newcatcodetable \vrbcatcodes \fi +\ifdefined\prtcatcodes \else \newcatcodetable \prtcatcodes \fi + +\startcatcodetable \nilcatcodes + \catcode\tabasciicode \spacecatcode + \catcode\endoflineasciicode \endoflinecatcode + \catcode\formfeedasciicode \endoflinecatcode + \catcode\spaceasciicode \spacecatcode + \catcode\endoffileasciicode \ignorecatcode +\stopcatcodetable + +\startcatcodetable \texcatcodes + \catcode\tabasciicode \spacecatcode + \catcode\endoflineasciicode \endoflinecatcode + \catcode\formfeedasciicode \endoflinecatcode + \catcode\spaceasciicode \spacecatcode + \catcode\endoffileasciicode \ignorecatcode + \catcode\circumflexasciicode\superscriptcatcode + \catcode\underscoreasciicode\subscriptcatcode + \catcode\ampersandasciicode \alignmentcatcode + \catcode\backslashasciicode \escapecatcode + \catcode\leftbraceasciicode \begingroupcatcode + \catcode\rightbraceasciicode\endgroupcatcode + \catcode\dollarasciicode \mathshiftcatcode + \catcode\hashasciicode \parametercatcode + \catcode\commentasciicode \commentcatcode +\stopcatcodetable + +\startcatcodetable \luacatcodes + \catcode\tabasciicode \othercatcode + \catcode\endoflineasciicode \othercatcode + \catcode\formfeedasciicode \othercatcode + \catcode\spaceasciicode \othercatcode + \catcode\endoffileasciicode \ignorecatcode + \catcode\circumflexasciicode\othercatcode + \catcode\underscoreasciicode\othercatcode + \catcode\ampersandasciicode \othercatcode + \catcode\backslashasciicode \escapecatcode + \catcode\commentasciicode \othercatcode + \catcode\hashasciicode \othercatcode + \catcode\barasciicode \othercatcode + \catcode\leftbraceasciicode \othercatcode + \catcode\rightbraceasciicode\othercatcode + \catcode\tildeasciicode \othercatcode + \catcode\dollarasciicode \othercatcode +\stopcatcodetable + +\startcatcodetable \notcatcodes % probably less needed + \catcode\tabasciicode \spacecatcode + \catcode\endoflineasciicode \endoflinecatcode + \catcode\formfeedasciicode \endoflinecatcode + \catcode\spaceasciicode \spacecatcode + \catcode\endoffileasciicode \ignorecatcode + \catcode\circumflexasciicode \othercatcode + \catcode\underscoreasciicode \othercatcode + \catcode\ampersandasciicode \othercatcode + \catcode\tildeasciicode \othercatcode + \catcode\hashasciicode \othercatcode + \catcode\dollarasciicode \othercatcode + \catcode\commentasciicode \othercatcode + \catcode\lessthanasciicode \othercatcode + \catcode\morethanasciicode \othercatcode + \catcode\leftbraceasciicode \othercatcode + \catcode\rightbraceasciicode \othercatcode + \catcode\doublequoteasciicode \othercatcode + \catcode\singlequoteasciicode \othercatcode + \catcode\forwardslashasciicode\othercatcode + \catcode\backslashasciicode \othercatcode + \catcode\barasciicode \othercatcode +\stopcatcodetable + +\startcatcodetable \vrbcatcodes % probably less needed + \catcode\tabasciicode \othercatcode + \catcode\endoflineasciicode\othercatcode + \catcode\formfeedasciicode \othercatcode + \catcode\spaceasciicode \othercatcode + \catcode\endoffileasciicode\othercatcode +\stopcatcodetable + +\startcatcodetable \prtcatcodes + \catcode\tabasciicode \spacecatcode + \catcode\endoflineasciicode \endoflinecatcode + \catcode\formfeedasciicode \endoflinecatcode + \catcode\spaceasciicode \spacecatcode + \catcode\endoffileasciicode \ignorecatcode + \catcode\circumflexasciicode \superscriptcatcode + %catcode\underscoreasciicode \subscriptcatcode + \catcode\underscoreasciicode \lettercatcode + \catcode\ampersandasciicode \alignmentcatcode + \catcode\backslashasciicode \escapecatcode + \catcode\leftbraceasciicode \begingroupcatcode + \catcode\rightbraceasciicode \endgroupcatcode + \catcode\dollarasciicode \mathshiftcatcode + \catcode\hashasciicode \parametercatcode + \catcode\commentasciicode \commentcatcode + \catcode\atsignasciicode \lettercatcode + \catcode\exclamationmarkasciicode\lettercatcode + \catcode\questionmarkasciicode \lettercatcode + \catcode\tildeasciicode \activecatcode + \catcode\barasciicode \activecatcode +\stopcatcodetable + +%D Because some characters have a special meaning, we provide shortcuts to their +%D character representation. Some will be overloaded (which might change). + +\chardef \^ = \circumflexasciicode +\chardef \_ = \underscoreasciicode +\chardef \& = \ampersandasciicode +\chardef \% = \commentasciicode +\chardef \# = \hashasciicode +\chardef \$ = \dollarasciicode +\chardef \{ = \leftbraceasciicode +\chardef \} = \rightbraceasciicode +\chardef \\ = \backslashasciicode +\chardef \| = \barasciicode + +% way too wide in lm, so one can also use: +% +% \def\_{\dontleavehmode \kern.06em \vbox{\hrule width.3em}} % this will become a \chardef + +%D From now on we can use the protection mechanisms. + +\permanent\protected\def\unprotect{\pushcatcodetable\setcatcodetable\prtcatcodes} +\permanent\protected\def\protect {\popcatcodetable} + +% \prependtoks \catcodetable\ctxcatcodes \to \everyjob + +\endinput diff --git a/tex/context/base/mkiv/catc-ini.mkxl b/tex/context/base/mkiv/catc-ini.mkxl index c32ba5fc1..1dcd2107f 100644 --- a/tex/context/base/mkiv/catc-ini.mkxl +++ b/tex/context/base/mkiv/catc-ini.mkxl @@ -92,7 +92,7 @@ {\global\advance\c_syst_catcodes_n\plusone \global\defcsname\??catcodetablen\number\c_syst_catcodes_n\endcsname{\string#1}% logging %\setnewconstant#1\c_syst_catcodes_n - \overloaded\integerdef#1\c_syst_catcodes_n + \immutable\integerdef#1\c_syst_catcodes_n \ctxcommand{registercatcodetable("\expandafter\gobbleoneargument\string#1",\number#1)}} \newtoks \everysetdefaultcatcodes @@ -127,7 +127,7 @@ \permanent\protected\def\permitcircumflexescape % to be used grouped {\catcode\circumflexasciicode\superscriptcatcode} -\let\permitcaretescape\permitcircumflexescape +\aliased\let\permitcaretescape\permitcircumflexescape % == % @@ -148,9 +148,9 @@ %D Once a catcode is assigned, the next assignments will happen faster. However, %D redefinitions probably happen seldom so it's sort of overkill. -\permanent\def\letcatcodecommand{\afterassignment\syst_catcodes_let_a\c_syst_catcodes_a} -\permanent\def\defcatcodecommand{\afterassignment\syst_catcodes_def_a\c_syst_catcodes_a} -\permanent\def\uedcatcodecommand{\afterassignment\syst_catcodes_ued_a\c_syst_catcodes_a} +\permanent\protected\def\letcatcodecommand{\afterassignment\syst_catcodes_let_a\c_syst_catcodes_a} +\permanent\protected\def\defcatcodecommand{\afterassignment\syst_catcodes_def_a\c_syst_catcodes_a} +\permanent\protected\def\uedcatcodecommand{\afterassignment\syst_catcodes_ued_a\c_syst_catcodes_a} \def\syst_catcodes_let_a{\afterassignment\syst_catcodes_let_b\c_syst_catcodes_b} \def\syst_catcodes_def_a{\afterassignment\syst_catcodes_def_b\c_syst_catcodes_b} diff --git a/tex/context/base/mkiv/catc-sym.mkxl b/tex/context/base/mkiv/catc-sym.mkxl new file mode 100644 index 000000000..5334d7723 --- /dev/null +++ b/tex/context/base/mkiv/catc-sym.mkxl @@ -0,0 +1,95 @@ +%D \module +%D [ file=catc-sym, +%D version=1997.01.03, % moved code +%D title=\CONTEXT\ Catcode Macros, +%D subtitle=Some Handy Constants, +%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 The following definitions can be used for mapping special characters onto +%D letters, although we cheat a bit: they actually are of category other but +%D for users that distinction doesn't matter here. The definitions in \MKII\ +%D and \MKIV\ look more impressive but here we use a \LUAMETATEX\ feature +%D that permits a more direct definition (that also looks nice with the +%D \CONTEXT\ syntax highlighting): + +\immutable\edef\letterleftbrace {\expandtoken \othercatcode \leftbraceasciicode} +\immutable\edef\letterrightbrace {\expandtoken \othercatcode \rightbraceasciicode} +\immutable\edef\letterampersand {\expandtoken \othercatcode \ampersandasciicode} +\immutable\edef\letterless {\expandtoken \othercatcode \lessthanasciicode} +\immutable\edef\lettermore {\expandtoken \othercatcode \morethanasciicode} +\immutable\edef\letterhash {\expandtoken \othercatcode \hashasciicode} +\immutable\edef\letterdoublequote {\expandtoken \othercatcode \doublequoteasciicode} +\immutable\edef\lettersinglequote {\expandtoken \othercatcode \singlequoteasciicode} +\immutable\edef\letterdollar {\expandtoken \othercatcode \dollarasciicode} +\immutable\edef\letterpercent {\expandtoken \othercatcode \percentasciicode} +\immutable\edef\letterhat {\expandtoken \othercatcode \circumflexasciicode} +\immutable\edef\letterunderscore {\expandtoken \othercatcode \underscoreasciicode} +\immutable\edef\letterbar {\expandtoken \othercatcode \barasciicode} +\immutable\edef\lettertilde {\expandtoken \othercatcode \tildeasciicode} +\immutable\edef\letterbackslash {\expandtoken \othercatcode \backslashasciicode} +\immutable\edef\letterslash {\expandtoken \othercatcode \forwardslashasciicode} +\immutable\edef\letterquestionmark {\expandtoken \othercatcode \questionmarkasciicode} +\immutable\edef\letterexclamationmark {\expandtoken \othercatcode \exclamationmarkasciicode} +\immutable\edef\letterat {\expandtoken \othercatcode \atsignasciicode} +\immutable\edef\lettercolon {\expandtoken \othercatcode \colonasciicode} + +\immutable\edef\letterleftparenthesis {\expandtoken \othercatcode \leftparentasciicode} +\immutable\edef\letterrightparenthesis {\expandtoken \othercatcode \rightparentasciicode} +\immutable\edef\letterleftbracket {\expandtoken \othercatcode \leftbracketasciicode} +\immutable\edef\letterrightbracket {\expandtoken \othercatcode \rightbracketasciicode} + +\aliased\let\letterescape \letterbackslash +\aliased\let\letterbgroup \letterleftbrace +\aliased\let\letteregroup \letterrightbrace +\aliased\let\letteropenbrace \letterleftbrace +\aliased\let\letterclosebrace\letterrightbrace + +\unprotect + +%immutable\edef\_n_u_l_{\expandtoken \othercatcode \zerocount} % nul(l) +%immutable\edef\_s_o_h_{\expandtoken \othercatcode \plusone } % start of header ^^^^0001 +\immutable\edef\_s_t_x_{\expandtoken \othercatcode \plustwo } % start of text ^^^^0002 +\immutable\edef\_e_t_x_{\expandtoken \othercatcode \plusthree} % end of text ^^^^0003 +\immutable\edef\_e_o_t_{\expandtoken \othercatcode \plusfour } % end of transmission ^^^^0004 +%immutable\edef\_e_n_q_{\expandtoken \othercatcode \plusfive } % enquiry +%immutable\edef\_a_c_k_{\expandtoken \othercatcode \plussix } % aknowledgement + +\protect + +%D \macros +%D {uncatcodespecials,setnaturalcatcodes,setnormalcatcodes, +%D uncatcodecharacters,uncatcodeallcharacters, +%D uncatcodespacetokens} +%D +%D The following macros are more or less replaced by switching to a catcode table +%D (which we simulate in \MKII) but we keep them for convenience and compatibility. +%D Some old engine code has been removed. A few ar still used a few times so I need +%D to clean that up. + +%permanent\protected\def\uncatcodespecials {\setcatcodetable\nilcatcodes \uncatcodespacetokens} +%permanent\protected\def\setnaturalcatcodes {\setcatcodetable\nilcatcodes} +\permanent\protected\def\setnormalcatcodes {\setcatcodetable\ctxcatcodes} % maybe \texcatcodes +%permanent\protected\def\uncatcodecharacters {\setcatcodetable\nilcatcodes} % was fast version, gone now +%permanent\protected\def\uncatcodeallcharacters{\setcatcodetable\nilcatcodes} % was slow one, with restore + +\permanent\protected\def\uncatcodespacetokens + {\catcode\spaceasciicode \spacecatcode + \catcode\tabasciicode \spacecatcode + \catcode\formfeedasciicode \endoflinecatcode + \catcode\endoflineasciicode\endoflinecatcode + \catcode\delasciicode \ignorecatcode} + +%D These two are probably no longer needed, but we keep them for a while. Some more +%D explanation can be foun din the mkiv variant of this module, where we also +%D discuss side effects. It's time to move on, so these might go away some day. + +\aliased \let\rescan \scantextokens +\permanent\def\rescanwithsetup#1#2{\begingroup\directsetup{#1}\scantextokens{#2}\endgroup} + +\endinput diff --git a/tex/context/base/mkiv/char-act.mkxl b/tex/context/base/mkiv/char-act.mkxl index bdc5b0717..3fb4d2da6 100644 --- a/tex/context/base/mkiv/char-act.mkxl +++ b/tex/context/base/mkiv/char-act.mkxl @@ -79,34 +79,21 @@ % but ... as we don't want to freeze to \obeyedspace etc which can be set after % \obeyspaces, we use an idirectness -\def\_obeyed_space_{\obeyedspace} -\def\_obeyed_tab_ {\obeyedtab} -\def\_obeyed_line_ {\obeyedline} -\def\_obeyed_page_ {\obeyedpage} - -\permanent\protected\def\obeyspaces {\catcode\spaceasciicode \activecatcode\enforced\letcharcode\spaceasciicode \_obeyed_space_} -\permanent\protected\def\obeytabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \_obeyed_tab_} -\permanent\protected\def\obeylines {\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\_obeyed_line_} -\permanent\protected\def\obeypages {\catcode\formfeedasciicode \activecatcode\enforced\letcharcode\formfeedasciicode \_obeyed_page_} - -\permanent\protected\def\ignoretabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \_obeyed_space_} -\permanent\protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\_obeyed_space_} +\def\syst_obeyed_space{\obeyedspace} +\def\syst_obeyed_tab {\obeyedtab} +\def\syst_obeyed_line {\obeyedline} +\def\syst_obeyed_page {\obeyedpage} + +\permanent\protected\def\obeyspaces {\catcode\spaceasciicode \activecatcode\enforced\letcharcode\spaceasciicode \syst_obeyed_space} +\permanent\protected\def\obeytabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \syst_obeyed_tab } +\permanent\protected\def\obeylines {\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_line } +\permanent\protected\def\obeypages {\catcode\formfeedasciicode \activecatcode\enforced\letcharcode\formfeedasciicode \syst_obeyed_page } + +\permanent\protected\def\ignoretabs {\catcode\tabasciicode \activecatcode\enforced\letcharcode\tabasciicode \syst_obeyed_space} +\permanent\protected\def\ignorelines{\catcode\endoflineasciicode\activecatcode\enforced\letcharcode\endoflineasciicode\syst_obeyed_space} \permanent\protected\def\ignorepages{\catcode\formfeedasciicode \ignorecatcode} \permanent\protected\def\ignoreeofs {\catcode\endoffileasciicode\ignorecatcode} -\permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\enforced\letcharcode\spaceasciicode\_control_space_} - -%D \macros -%D {naturaltextext} -%D -%D When one uses \ETEX, switching to normal \TEX\ is possible too. We also introduce -%D a switch that can be used in the drivers and set in higher level shell macros. - -\permanent\protected\def\naturaltextext#1\relax % this command will become obsolete - {\begingroup - \def\ascii{#1}% - \setcatcodetable\ctxcatcodes - \prettynaturalfont{\scantextokens\expandafter{\ascii}\ifhmode\unskip\fi}% - \endgroup} +\permanent\protected\def\setcontrolspaces{\catcode\spaceasciicode\activecatcode\enforced\letcharcode\spaceasciicode\controlspace} \endinput \protect diff --git a/tex/context/base/mkiv/chem-ini.mkxl b/tex/context/base/mkiv/chem-ini.mkxl new file mode 100644 index 000000000..55bbbd874 --- /dev/null +++ b/tex/context/base/mkiv/chem-ini.mkxl @@ -0,0 +1,53 @@ +%D \module +%D [ file=chem-ini, +%D version=2008.03.06, +%D subtitle=Chemistry, +%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. + +% todo: \mathscriptsmode + +\writestatus{loading}{ConTeXt Chemistry Macros / Initialization} % might become Inline + +\registerctxluafile{chem-ini}{} + +\unprotect + +% todo: use \mathscriptsmode if needed + +%D \macros +%D {molecule} +%D +%D Quick and dirty: +%D +%D \starttyping +%D \unexpanded\def\molecule#1% +%D {$\enablesupersub\tf#1$} +%D \stoptyping +%D +%D Using \LUA: +%D +%D \startbuffer +%D \molecule{H_2SO_4^-2} +%D \molecule{H_2SO_4^{-2}} +%D \molecule{H_2SO_4^{-2{x}}} +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +\permanent\protected\def\molecule#1% todo: can become a public implementor + {\clf_molecule{#1}} + +%D For old times sake: + +\permanent\protected\def\chem#1#2#3% + {\dontleavehmode\begingroup#1\lohi{#2}{#3}\endgroup} + +\protect \endinput + + diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 0f6cc7c6b..1389645e0 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -13,7 +13,7 @@ % \normalend % uncomment this to get the real base runtime -\newcontextversion{2020.11.15 20:40} +\newcontextversion{2020.11.16 19:37} %D This file is loaded at runtime, thereby providing an excellent place for hacks, %D patches, extensions and new features. There can be local overloads in cont-loc diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index e0941a513..97762871c 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -45,7 +45,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.15 20:40} +\edef\contextversion{2020.11.16 19:37} %D Kind of special: diff --git a/tex/context/base/mkiv/context.mkxl b/tex/context/base/mkiv/context.mkxl index e417248eb..ea5d97d8f 100644 --- a/tex/context/base/mkiv/context.mkxl +++ b/tex/context/base/mkiv/context.mkxl @@ -29,7 +29,7 @@ %D {YYYY.MM.DD HH:MM} format. \edef\contextformat {\jobname} -\edef\contextversion{2020.11.15 20:40} +\edef\contextversion{2020.11.16 19:37} %overloadmode 1 % check frozen / warning %overloadmode 2 % check frozen / error @@ -95,10 +95,10 @@ \loadmarkfile{luat-soc} \loadmkxlfile{catc-ini} -\loadmarkfile{catc-act} -\loadmarkfile{catc-def} +\loadmkxlfile{catc-act} +\loadmkxlfile{catc-def} \loadmkxlfile{catc-ctx} -\loadmarkfile{catc-sym} +\loadmkxlfile{catc-sym} \loadmkxlfile{toks-ini} \loadmkxlfile{cldf-ini} @@ -153,7 +153,7 @@ \loadmkxlfile{attr-ini} -\loadmarkfile{core-ini} +\loadmkxlfile{core-ini} \loadmkxlfile{core-env} \loadmkxlfile{layo-ini} @@ -187,16 +187,16 @@ \loadmarkfile{supp-ran} \loadmkxlfile{supp-mat} -\loadmarkfile{core-uti} +\loadmkxlfile{core-uti} \loadmklxfile{file-job} \loadmkxlfile{anch-pos} -\loadmarkfile{typo-ini} +\loadmkxlfile{typo-ini} \loadmarkfile{typo-lin} \loadmarkfile{typo-bld} % par builders -\loadmarkfile{typo-inj} +\loadmkxlfile{typo-inj} \loadmklxfile{file-syn} \loadmklxfile{file-mod} @@ -216,9 +216,8 @@ \loadmkxlfile{unic-ini} -% \loadmarkfile{core-uti} -\loadmarkfile{core-two} -\loadmarkfile{core-dat} +\loadmkxlfile{core-two} +\loadmkxlfile{core-dat} \loadmkxlfile{colo-ini} \loadmkxlfile{colo-grp} % optional @@ -332,7 +331,7 @@ \loadmkvifile{page-lin} \loadmarkfile{page-par} \loadmarkfile{typo-pag} -\loadmarkfile{typo-mar} +\loadmkxlfile{typo-mar} \loadmarkfile{typo-itm} \loadmarkfile{buff-ini} @@ -423,8 +422,8 @@ \loadmarkfile{typo-krn} \loadmkvifile{typo-itc} \loadmkxlfile{typo-dir} -\loadmarkfile{typo-brk} -\loadmarkfile{typo-cap} +\loadmkxlfile{typo-brk} +\loadmkxlfile{typo-cap} \loadmarkfile{typo-dig} \loadmarkfile{typo-rep} \loadmkvifile{typo-txt} @@ -469,11 +468,11 @@ \loadmarkfile{page-plg} \loadmarkfile{page-str} -\loadmarkfile{anch-pgr} % can be moved up (nicer for dependencies) -\loadmkvifile{anch-bck} +\loadmkxlfile{anch-pgr} % can be moved up (nicer for dependencies) +\loadmklxfile{anch-bck} \loadmkxlfile{anch-tab} % overloads tabl-tbl -\loadmarkfile{anch-bar} -%loadmarkfile{anch-snc} % when needed this one will be redone +\loadmkxlfile{anch-bar} +%loadmkxlfile{anch-snc} % when needed this one will be redone \loadmkxlfile{math-ini} % way after font-pre ! \loadmkxlfile{math-pln} @@ -497,7 +496,7 @@ \loadmarkfile{strc-mat} -\loadmarkfile{chem-ini} +\loadmkxlfile{chem-ini} \loadmkxlfile{chem-str} \loadmkxlfile{typo-scr} @@ -555,9 +554,9 @@ \loadmkxlfile{cldf-ver} % verbatim, this can come late \loadmkxlfile{cldf-com} % commands, this can come late -\loadmarkfile{core-ctx} % this order might change but we need to check depedencies / move to another namespace +\loadmkxlfile{core-ctx} % this order might change but we need to check depedencies / move to another namespace -\loadmarkfile{core-def} +\loadmkxlfile{core-def} %usemodule[x][res-04] % xml resource libraries %usemodule[x][res-08] % rlx runtime conversion diff --git a/tex/context/base/mkiv/core-ctx.mkxl b/tex/context/base/mkiv/core-ctx.mkxl new file mode 100644 index 000000000..77fb0f139 --- /dev/null +++ b/tex/context/base/mkiv/core-ctx.mkxl @@ -0,0 +1,29 @@ +%D \module +%D [ file=core-ctx, +%D version=2006.08.16, % old stuff +%D title=\CONTEXT\ Core Macros, +%D subtitle=Job Control, +%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 / Job Control} + +\registerctxluafile{core-ctx}{} + +\unprotect + +% called directly in core-def.mkiv +% +% \unexpanded\def\job_options_get_commandline {\clf_setdocumentcommandline} +% \unexpanded\def\job_options_get_ctxfile {\clf_setdocumentctxfile} +% \unexpanded\def\job_options_set_modes {\clf_setdocumentmodes} +% \unexpanded\def\job_options_set_modules {\clf_setdocumentmodules} +% \unexpanded\def\job_options_set_environments{\clf_setdocumentenvironments} +% \unexpanded\def\job_options_set_filenames {\clf_setdocumentfilenames} + +\protect \endinput diff --git a/tex/context/base/mkiv/core-dat.mkxl b/tex/context/base/mkiv/core-dat.mkxl new file mode 100644 index 000000000..7360a4e46 --- /dev/null +++ b/tex/context/base/mkiv/core-dat.mkxl @@ -0,0 +1,110 @@ +%D \module +%D [ file=core-dat, +%D version=20122.04.17, % replaces core-two from 1997.03.31, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Multipass Datasets, +%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 / Multipass Datasets} + +%D \starttyping +%D \definedataset[test-1] +%D \definedataset[test-2][delay=yes] +%D +%D \startlines +%D set 1: \setdataset[test-1][whatever=this-or-that-1] +%D set 2: \setdataset[test-2][whatever=this-or-that-2] +%D set 3: \setdataset[test-2][whatever=this-or-that-3] +%D \stoplines +%D +%D \startlines +%D get 1: \datasetvariable{test-1}{1}{whatever} / \datasetvariable{test-1}{1}{realpage} +%D get 2: \datasetvariable{test-2}{1}{whatever} / \datasetvariable{test-2}{1}{realpage} +%D get 3: \datasetvariable{test-2}{2}{whatever} / \datasetvariable{test-2}{2}{realpage} +%D \stoplines +%D \stoptyping + +\unprotect + +\registerctxluafile{core-dat}{} + +\installcorenamespace{dataset} + +\installcommandhandler \??dataset {dataset} \??dataset + +\permanent\tolerant\protected\def\setdataset[#1]#*[#2]#*[#3]% + {\begingroup + \edef\currentdataset{#1}% + \ifparameters\or\or + \clf_setdataset + name {\currentdataset}% + delay {\datasetparameter\c!delay}% + data {#2}% + \relax + \or + \edef\currentdataset{#1}% + \clf_setdataset + name {\currentdataset}% + tag {#2}% + delay {\datasetparameter\c!delay}% + data {#3}% + \relax + \fi + \endgroup} + +\permanent\def\datasetvariable#1#2#3% + {\clf_datasetvariable{#1}{#2}{#3}} + +\installcorenamespace{pagestate} +\installcorenamespace{pagestatecounter} + +\installcommandhandler \??pagestate {pagestate} \??pagestate + +\def\syst_pagestates_allocate + {\expandafter\newcount\csname\??pagestatecounter\currentpagestate\endcsname} + +\appendtoks + \syst_pagestates_allocate +\to \everydefinepagestate + +\setuppagestate + [\c!delay=\v!yes] + +\permanent\tolerant\protected\def\setpagestate[#1]#*[#2]% + {\begingroup + \edef\currentpagestate{#1}% + \ifcsname\??pagestatecounter\currentpagestate\endcsname + \scratchcounter\lastnamedcs + \advance\scratchcounter\plusone + \else + \scratchcounter\plusone + \syst_pagestates_allocate + \fi + \global\csname\??pagestatecounter\currentpagestate\endcsname\scratchcounter + \clf_setpagestate + name {\currentpagestate}% + tag {\ifparameter#2\or#2\else\number\scratchcounter\fi}% + delay {\pagestateparameter\c!delay}% + \relax + \endgroup} + +\permanent\protected\def\autosetpagestate#1% + {\syst_pagestates_set[#1]\relax} + +\permanent\def\autopagestatenumber#1{\begincsname\??pagestatecounter#1\endcsname} + +\permanent\def\pagestaterealpage #1#2{\clf_pagestaterealpage {#1}{#2}} +\permanent\def\setpagestaterealpageno#1#2{\clf_setpagestaterealpageno{#1}{#2}} +\permanent\def\pagestaterealpageorder#1#2{\clf_pagestaterealpageorder{#1}#2\relax} + +\permanent\def\autopagestaterealpage #1{\clf_pagestaterealpage {#1}{\number\autopagestatenumber{#1}}} +\permanent\def\setautopagestaterealpageno#1{\clf_setpagestaterealpageno{#1}{\number\autopagestatenumber{#1}}} +\permanent\def\autopagestaterealpageorder#1{\clf_pagestaterealpageorder{#1}\numexpr\autopagestatenumber{#1}\relax} + +\protect diff --git a/tex/context/base/mkiv/core-def.mkiv b/tex/context/base/mkiv/core-def.mkiv index b1d984ae5..b09d5b28f 100644 --- a/tex/context/base/mkiv/core-def.mkiv +++ b/tex/context/base/mkiv/core-def.mkiv @@ -49,13 +49,6 @@ \typo_firstline_handle \to \everypar -\ifcase\contextlmtxmode \else - \appendtoks - \spac_paragraph_wrap - \spac_paragraph_freeze - \to \everypar -\fi - \appendtoks \flushnotes \to \everydisplay diff --git a/tex/context/base/mkiv/core-def.mkxl b/tex/context/base/mkiv/core-def.mkxl new file mode 100644 index 000000000..a413b8738 --- /dev/null +++ b/tex/context/base/mkiv/core-def.mkxl @@ -0,0 +1,182 @@ +%D \module +%D [ file=core-def, +%D version=2002.05.07, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Defaults, +%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 / Defaults} + +%D Here we collect settings that cannot be done earlier due to +%D depedencies. More code will moved to this module later. + +\unprotect + +\usesymbols[mis,nav] % no longer mvs preloaded + +\setupsymbolset[navigation 1] + +\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 + \typo_initial_handle + \typo_firstline_handle + % + \spac_paragraph_wrap + \spac_paragraph_freeze +\to \everypar + +\appendtoks + \flushnotes +\to \everydisplay + +% \appendtoks +% \adjustsidefloatdisplaylines +% \to \everydisplay + +% \appendtoks +% \flushpostponednodedata +% \to \neverypar + +% \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 + +% We made \loadoptionfile obsolete: we pass options via the command line to +% luatex now and handle them directly instead of via a file. This also makes +% the next obsolete: +% +% \directsetup{*runtime:options} +% \directsetup{*runtime:modules} + +\appendtoks + \showcontextbanner + \initializenewlinechar + \calculatecurrenttime + \syst_files_load + % for the moment here (before doc env) + \setupoutput[pdf]% + % + \clf_setdocumentcommandline + \clf_setdocumentctxfile + \clf_setdocumentfilenames + \font_preloads_at_every_job + \settopskip % brrr + \initializemainlanguage + \initializepagebackgrounds + \initializepagecounters + \clf_setdocumentmodes + \clf_setdocumentmodules + \clf_setdocumentenvironments +\to \everyjob + +\appendtoks + \ifarrangingpages\poparrangedpages\fi +\to \everybye + +\prependtoks + \resetallattributes +\to \everybeforeoutput + +\appendtoks + \the\everybackendshipout +\to \everyshipout + +\prependtoks + \the\everylastbackendshipout +\to \everylastshipout + +\prependtoks + \lefttoright +\to \everybeforeoutput + +% temporary here: + +\pushoverloadmode + \frozen\unexpanded\def\arg{\mathortext\normalmatharg\normaltextarg} +\popoverloadmode + +% might move to \everydump or even disappear: + +\nonknuthmode + +% brrr + +\appendtoks + \synchronizegloballinespecs + \synchronizelocallinespecs +\to \everysetupbodyfont + +\appendtoks + \synchronizelocallinespecs +\to \everyswitchtobodyfont + +% who knows + +% \appendtoks +% \resetcharacterspacing +% \to \everyhyphenatedurl + +% \setbreakpoints[compound] + +%D Till we fixed all styles: + +\enforced\let\\\crlf % frozen or permanent? + +\protect \endinput diff --git a/tex/context/base/mkiv/core-env.mkxl b/tex/context/base/mkiv/core-env.mkxl index 47f2c3c6c..e1a96b35f 100644 --- a/tex/context/base/mkiv/core-env.mkxl +++ b/tex/context/base/mkiv/core-env.mkxl @@ -304,8 +304,10 @@ \newconditional\c_syst_modes_set_done % conditionals can be pushed/popped +\installmacrostack\c_syst_modes_set_done + \permanent\protected\def\startmodeset - {\pushmacro\c_syst_modes_set_done + {\push_macro_c_syst_modes_set_done \setfalse\c_syst_modes_set_done \doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit} @@ -333,7 +335,7 @@ {\doifelsenextoptionalcs\syst_modes_set_start\syst_modes_set_quit} \def\syst_modes_set_quit#-\stopmodeset - {\popmacro\c_syst_modes_set_done} + {\pop_macro_c_syst_modes_set_done} %D Lets now set a mode: @@ -358,7 +360,7 @@ \letvalue{\??setup:\??empty}\gobbleoneargument -\def\syst_setups#1% the grid option will be extended to other main modes +\permanent\def\syst_setups#1% the grid option will be extended to other main modes {\csname\??setup \ifgridsnapping \ifcsname\??setup\v!grid:#1\endcsname\v!grid:#1\else:\ifcsname\??setup:#1\endcsname#1\else\??empty\fi\fi @@ -369,22 +371,22 @@ % no checking and we assume it being defined: -\def\fastsetup #1{\csname\??setup:#1\endcsname\empty} -\def\fastsetupwithargument #1{\csname\??setup:#1\endcsname} % swapped per 2015-08-30 -\def\fastsetupwithargumentswapped#1#2{\csname\??setup:#2\endcsname{#1}}% swapped per 2015-09-05 +\permanent\def\fastsetup #1{\csname\??setup:#1\endcsname\empty} +\permanent\def\fastsetupwithargument #1{\csname\??setup:#1\endcsname} % swapped per 2015-08-30 +\permanent\def\fastsetupwithargumentswapped#1#2{\csname\??setup:#2\endcsname{#1}}% swapped per 2015-09-05 % the next one is meant for \c!setups situations, hence the check for % a shortcut \let\m_syst_setups_asked\empty -\def\doprocesslocalsetups#1% sort of public, fast local variant +\permanent\protected\def\doprocesslocalsetups#1% sort of public, fast local variant {\edef\m_syst_setups_asked{#1}% \ifempty\m_syst_setups_asked\else \expandafter\syst_setups_process_local \fi} -\protected\def\usesetupsparameter#1% +\permanent\protected\def\usesetupsparameter#1% {\edef\m_syst_setups_asked{#1\c!setups}% \ifempty\m_syst_setups_asked\else \expandafter\syst_setups_process_local @@ -399,35 +401,34 @@ {\clf_autosetups{\m_syst_setups_asked}% \relax} % let's prevent lookahead -\def\autosetups#1% - {\clf_autosetups{#1}} +\permanent\def\autosetups#1{\clf_autosetups{#1}} % todo: public implementor -\edef\setupwithargument#1% saves a few expansions +\permanent\edef\setupwithargument#1% saves a few expansions {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#1\endcsname#1\noexpand\else\??empty\noexpand\fi\endcsname} -\edef\setupwithargumentswapped#1#2% saves a few expansions (can be \let) +\permanent\edef\setupwithargumentswapped#1#2% saves a few expansions (can be \let) {\noexpand\csname\??setup:\noexpand\ifcsname\??setup:#2\endcsname#2\noexpand\else\??empty\noexpand\fi\endcsname{#1}} -\let\directsetup\syst_setups -\let\texsetup \syst_setups % nicer than \directsetup and more en par with xmlsetup and luasetup +\aliased\let\directsetup\syst_setups +\aliased\let\texsetup \syst_setups % nicer than \directsetup and more en par with xmlsetup and luasetup -\protected\def\doifelsesetups#1% to be done: grid +\permanent\protected\def\doifelsesetups#1% to be done: grid {\ifcsname\??setup:#1\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} -\let\doifsetupselse\doifelsesetups +\aliased\let\doifsetupselse\doifelsesetups -\protected\def\doifsetups#1% to be done: grid +\permanent\protected\def\doifsetups#1% to be done: grid {\ifcsname\??setup:#1\endcsname \expandafter\firstofoneargument \else \expandafter\gobbleoneargument \fi} -\protected\def\doifnotsetups#1% to be done: grid +\permanent\protected\def\doifnotsetups#1% to be done: grid {\ifcsname\??setup:#1\endcsname \expandafter\gobbleoneargument \else @@ -571,26 +572,23 @@ %D System setups: -\let\systemsetupsprefix\wildcardsymbol +\aliased\let\systemsetupsprefix\wildcardsymbol -\def\systemsetups#1{\syst_setups{\systemsetupsprefix#1}} +\permanent\def\systemsetups#1{\syst_setups{\systemsetupsprefix#1}} -\protected\def\resetsetups[#1]% see x-fo for usage +\permanent\protected\def\resetsetups[#1]% see x-fo for usage {\ifcsname\??setup\ifgridsnapping\v!grid\fi:#1\endcsname \dodoglobal\undefinevalue{\??setup\ifgridsnapping\v!grid\fi:#1}% \else \dodoglobal\undefinevalue{\??setup:#1}% \fi} -\protected\def\copysetups - {\dodoubleargument\syst_setups_copy} - -\def\syst_setups_copy[#1][#2]% +\permanent\tolerant\protected\def\copysetups[#1]#*[#2]% {\ifcsname\??setup:#2\endcsname \letcsname\??setup:#1\expandafter\endcsname\lastnamedcs \fi} -\protected\def\showsetupsdefinition[#1]% +\permanent\protected\def\showsetupsdefinition[#1]% {\showvalue{\??setup:#1}} % temp hack for debugging %D \macros @@ -612,9 +610,6 @@ \permanent\protected\def\setgvariables{\syst_variables_set[\getrawgparameters]} \permanent\protected\def\setxvariables{\syst_variables_set[\getrawxparameters]} -% \protected\def\globalsetvariables % obsolete -% {\dotripleargument\syst_variables_set[\globalgetrawparameters]} - \tolerant\def\syst_variables_set[#1]#*[#2]#*[#3]% tricky, test on s-pre-60 {\doifelse{#2}\currentvariableclass {#1[\??variables#2:][#3]}% diff --git a/tex/context/base/mkiv/core-ini.mkiv b/tex/context/base/mkiv/core-ini.mkiv index 31ef501d9..9352c9487 100644 --- a/tex/context/base/mkiv/core-ini.mkiv +++ b/tex/context/base/mkiv/core-ini.mkiv @@ -91,7 +91,7 @@ %D Exporting: -\newtoks\everyinitializeexport +\newtoks \everyinitializeexport %D Sectioning: diff --git a/tex/context/base/mkiv/core-ini.mkxl b/tex/context/base/mkiv/core-ini.mkxl new file mode 100644 index 000000000..2e32e9bdd --- /dev/null +++ b/tex/context/base/mkiv/core-ini.mkxl @@ -0,0 +1,224 @@ +%D \module +%D [ file=core-ini, +%D version=2003.12.01, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Additional Initialization, +%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 / Additional Initialization} + +\unprotect + +%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). + +%D \macros +%D {every...} +%D +%D A few every's. + +%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 \everyendoftextbody + +\newtoks \everystarttext +\newtoks \everystoptext + +\newtoks \everystartdocument +\newtoks \everystopdocument + +%D Purity: + +\newtoks \everyforgetall +\newtoks \everycleanupfeatures +\newtoks \everysimplifycommands +\newtoks \everypreroll + +\let\simplifiedcommands\everysimplifycommands % backward compatible, will stay as it's used in styles + +\newconditional\simplifyingcommands % public + +\permanent\protected\def\forgetall {\the\everyforgetall} +\permanent\protected\def\cleanupfeatures {\the\everycleanupfeatures} +\permanent\protected\def\simplifycommands{\the\everysimplifycommands} + +\appendtoks + \settrue\simplifyingcommands +\to \everysimplifycommands + +\appendtoks + \everypar\emptytoks % pretty important +\to \everyforgetall + +%D Page building: + +\newtoks \everybeforepagebody +\newtoks \everyafterpagebody + +\aliased\let\everypagebody\everybeforepagebody % backward compatible, will become obsolete + +%D Floats: + +\newtoks \everyinsidefloat + +%D Exporting: + +\newtoks \everyinitializeexport + +%D Sectioning: + +%newtoks \everyheadstart + +%D Par building (experimental, used in xml <p> .. </p>) + +\newtoks \everybeginofpar +\newtoks \everyendofpar +%newtoks \everyparflush + +\protected\def\bpar{\the\everybeginofpar\ignorespaces} % may interfere with \everypar +\protected\def\epar{\ifhmode\removeunwantedspaces\the\everyendofpar\fi} % test prevents problems with \bpar\epar + +%D Lists: + +\newtoks \everylistentry +\newtoks \everysavesortkeys + +%D Marks: + +%newtoks \everymarking + +%D Fonts: + +\newtoks \everyfont +\newtoks \everyglobalbodyfont +\newtoks \everydefinedfont + +\newtoks \everybodyfont +\newtoks \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 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 \ifinsidemulticolumns % simple mixed-in-text columns +\newif \ifdoublesided \doublesidedfalse +\newif \ifsinglesided \singlesidedtrue +\newif \ifinsidefloat +\newif \ifdoingblocks +\newif \ifgridsnapping +\newif \ifexporting + +\newconstant\pageduplexmode % 0 single 1 double 2 mix +\newconstant\pagebodymode % 0 not 1 normal pagebody 2 spread + +\newcount\nofcolumns \nofcolumns \plusone +\newcount\nofmulticolumns \nofmulticolumns\plusone + +%D \macros +%D {ifproductionrun} +%D +%D This boolean can be used to bypass certain initializations. + +% \newif\ifproductionrun % already defined + +\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 robust test for inner +%D situations. + +\newif \ifboxedcontent +\newtoks\everyboxedcontent + +\appendtoks + \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/mkiv/core-two.mkxl b/tex/context/base/mkiv/core-two.mkxl new file mode 100644 index 000000000..0299e76f5 --- /dev/null +++ b/tex/context/base/mkiv/core-two.mkxl @@ -0,0 +1,109 @@ +%D \module +%D [ file=core-two, % moved from core-uti +%D version=1997.03.31, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Two Pass Data, +%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 / Two Pass Data} + +%D This is a rather old mechanism which has not changed much over time, apart from +%D adding a few more selectors. This code used to be part of \type {core-uti}. The +%D following examples demonstrate the interface. +%D +%D \startbuffer +%D \definetwopasslist{test-1} +%D +%D \gettwopassdatalist{test-1} [\twopassdatalist=] +%D \checktwopassdata {test-1} [\twopassdata=] +%D \checktwopassdata {test-1} [\twopassdata=] +%D \gettwopassdata {test-1} [\twopassdata=] +%D \gettwopassdata {test-1} [\twopassdata=] +%D +%D \definetwopasslist{test-2} +%D +%D \lazysavetwopassdata{test-2}{1}{x} +%D \lazysavetwopassdata{test-2}{2}{y} +%D \lazysavetwopassdata{test-2}{3}{z} +%D +%D \gettwopassdatalist{test-2} [\twopassdatalist=x,y,z] +%D \checktwopassdata {test-2} [\twopassdata=x] +%D \checktwopassdata {test-2} [\twopassdata=x] +%D \gettwopassdata {test-2} [\twopassdata=x] +%D \gettwopassdata {test-2} [\twopassdata=y] +%D \gettwopassdata {test-2} [\twopassdata=z] +%D \gettwopassdata {test-2} [\twopassdata=] +%D +%D \definetwopasslist{test-3} +%D +%D \lazysavetaggedtwopassdata{test-3}{1}{x}{a} +%D \lazysavetaggedtwopassdata{test-3}{2}{y}{b} +%D \lazysavetaggedtwopassdata{test-3}{3}{z}{c} +%D +%D \findtwopassdata{test-3}{x} [\twopassdata=a] +%D \findtwopassdata{test-3}{y} [\twopassdata=b] +%D \findtwopassdata{test-3}{z} [\twopassdata=c] +%D \findtwopassdata{test-3}{w} [\twopassdata=] +%D +%D \definetwopasslist{test-4} +%D +%D \lazysavetwopassdata{test-4}{1}{A} +%D \lazysavetwopassdata{test-4}{2}{B} +%D \lazysavetwopassdata{test-4}{3}{C} +%D +%D \getfirsttwopassdata{test-4} [\twopassdata=A] +%D \getlasttwopassdata {test-4} [\twopassdata=C] +%D \getfirsttwopassdata{test-4} [\twopassdata=A] +%D \getlasttwopassdata {test-4} [\twopassdata=C] +%D \getfromtwopassdata {test-4}{1} [\twopassdata=A] +%D \getfromtwopassdata {test-4}{3} [\twopassdata=C] +%D \getfromtwopassdata {test-4}{2} [\twopassdata=B] +%D \stopbuffer +%D +%D \getbuffer \typebuffer + +\unprotect + +\registerctxluafile{core-two}{} + +\permanent\def\immediatesavetwopassdata #1#2#3{\normalexpanded{\noexpand\clf_savetwopassdata{#1}{#3}}} +\permanent\def \lazysavetwopassdata #1#2#3{\normalexpanded{\noexpand\ctxlatecommand{savetwopassdata("#1","#3")}}} +\permanent\let \savetwopassdata \lazysavetwopassdata +\permanent\def \savetaggedtwopassdata#1#2#3#4{\normalexpanded{\noexpand\clf_savetaggedtwopassdata{#1}{#3}{#4}}} +\permanent\def\lazysavetaggedtwopassdata#1#2#3#4{\normalexpanded{\noexpand\ctxlatecommand{savetaggedtwopassdata("#1",'#3',"#4")}}} + +% temp hack: needs a proper \starteverytimeluacode + +\setfalse\twopassdatafound +\let \twopassdata \empty +\let \twopassdatalist \empty + +\def\syst_twopass_check % can be delegated to lua once obsolete is gone + {\ifx\twopassdata\empty + \setfalse\twopassdatafound + \else + \settrue\twopassdatafound + \fi} + +\permanent\protected\def\definetwopasslist #1{\clf_definetwopasslist{#1}} +\permanent\protected\def\gettwopassdata #1{\edef\twopassdata {\clf_gettwopassdata {#1}}\syst_twopass_check} +\permanent\protected\def\checktwopassdata #1{\edef\twopassdata {\clf_checktwopassdata {#1}}\syst_twopass_check} +\permanent\protected\def\findtwopassdata #1#2{\edef\twopassdata {\clf_findtwopassdata {#1}{#2}}\syst_twopass_check} +\permanent\protected\def\getfirsttwopassdata #1{\edef\twopassdata {\clf_getfirsttwopassdata {#1}}\syst_twopass_check} +\permanent\protected\def\getlasttwopassdata #1{\edef\twopassdata {\clf_getlasttwopassdata {#1}}% + \edef\noftwopassitems{\clf_counttwopassdata {#1}}\syst_twopass_check} +\permanent\protected\def\getnamedtwopassdatalist#1#2{\edef #1{\clf_gettwopassdatalist {#2}}} +\permanent\protected\def\gettwopassdatalist #1{\edef\twopassdatalist{\clf_gettwopassdatalist {#1}}} + +\permanent\protected\def\doifelseintwopassdata #1#2{\clf_doifelseintwopassdata{#1}{#2}} + +\aliased\let\doifintwopassdataelse\doifelseintwopassdata +\aliased\let\getfromtwopassdata \findtwopassdata + +\protect \endinput diff --git a/tex/context/base/mkiv/core-uti.lua b/tex/context/base/mkiv/core-uti.lua index 1debf347b..60cf3d6a9 100644 --- a/tex/context/base/mkiv/core-uti.lua +++ b/tex/context/base/mkiv/core-uti.lua @@ -392,53 +392,24 @@ statistics.register("jobdata time",function() end end) -if CONTEXTLMTXMODE > 0 then - - function statistics.callbacks() - local backend = backends.getcallbackstate() - local frontend = status.getcallbackstate() - local pages = structures.pages.nofpages or 0 - local total = frontend.count + backend.count - local average = pages > 0 and math.round(total/pages) or 0 - local result = format ( - "file: %s, saved: %s, direct: %s, function: %s, value: %s, message: %s, bytecode: %s, late %s, total: %s (%s per page)", - frontend.file, frontend.saved, frontend.direct, frontend["function"], - frontend.value, frontend.message, frontend.bytecode, backend.count, - total, average - ) - statistics.callbacks = function() - return result - end - return result - end - - statistics.register("callbacks", statistics.callbacks) - -else - - function statistics.callbacks() - local c_internal = status.callbacks or 0 - local c_file = status.indirect_callbacks or 0 - local c_direct = status.direct_callbacks or 0 - local c_late = backends.getcallbackstate().count - local c_function = status.function_callbacks or 0 - local c_total = c_internal + c_file + c_direct + c_late + c_function - local n_pages = structures.pages.nofpages or 0 - local c_average = n_pages > 0 and math.round(c_total/n_pages) or 0 - local result = format ( - "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)", - c_internal, c_file, c_direct, c_late, c_function, c_total, c_average - ) - statistics.callbacks = function() - return result - end +statistics.register("callbacks", function() + local c_internal = status.callbacks or 0 + local c_file = status.indirect_callbacks or 0 + local c_direct = status.direct_callbacks or 0 + local c_late = backends.getcallbackstate().count + local c_function = status.function_callbacks or 0 + local c_total = c_internal + c_file + c_direct + c_late + c_function + local n_pages = structures.pages.nofpages or 0 + local c_average = n_pages > 0 and math.round(c_total/n_pages) or 0 + local result = format ( + "internal: %s, file: %s, direct: %s, late: %s, function %s, total: %s (%s per page)", + c_internal, c_file, c_direct, c_late, c_function, c_total, c_average + ) + statistics.callbacks = function() return result end - - statistics.register("callbacks", statistics.callbacks) - -end - + return result +end) statistics.register("randomizer", function() if rmethod and rvalue then diff --git a/tex/context/base/mkiv/core-uti.mkxl b/tex/context/base/mkiv/core-uti.mkxl new file mode 100644 index 000000000..b8d3bf7eb --- /dev/null +++ b/tex/context/base/mkiv/core-uti.mkxl @@ -0,0 +1,35 @@ +%D \module +%D [ file=core-uti, +%D version=1997.03.31, % 2006.09.19 mkiv +%D title=\CONTEXT\ Core Macros, +%D subtitle=Utility File Handling, +%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 / Utility File Handling} + +\unprotect + +\registerctxluafile{core-uti}{} + +% savecurrentvalue#1#2% immediate, expanded, defined at lua end + +\appendtoks + \clf_setjobcomment + file {\jobname}% + format {\contextformat}% + stamp {\contextversion}% + escape {\!!bs\space...\space\!!es}% + \relax +\to \everystarttext + +\appendtoks + \clf_initializejob +\to \everyjob + +\protect \endinput diff --git a/tex/context/base/mkiv/meta-ini.mkxl b/tex/context/base/mkiv/meta-ini.mkxl index 5422f3f1c..3e1c54d53 100644 --- a/tex/context/base/mkiv/meta-ini.mkxl +++ b/tex/context/base/mkiv/meta-ini.mkxl @@ -380,12 +380,13 @@ \permanent\tolerant\def\startMPdrawing[#1]% todo: use pickup #: {\meta_start_drawing#1} -\def\meta_start_drawing#1#2\stopMPdrawing % to be redone, this ascii stuff +\def\meta_start_drawing#1#2\stopMPdrawing {\relax \bgroup \meta_enable_include - \doifelse{#1}{-}{\convertargument#2\to\asciia}{\def\asciia{#2}}% - \xdef\MPdrawingdata{\MPdrawingdata\asciia}% + \doifelse{#1}{-} + {\xdef\MPdrawingdata{\MPdrawingdata\detokenize{#2}}}% + {\xdef\MPdrawingdata{\MPdrawingdata#2}}% \egroup} \permanent\let\stopMPdrawing\relax @@ -981,13 +982,10 @@ \installcorenamespace{mptext} -\permanent\protected\def\setMPtext#1#2% todo : #1 must be made : safe - {\defconvertedargument\ascii{#2}% hm, kind of old fashioned, this - \dodoglobal\letvalue{\??mptext#1}\ascii} - -\permanent\def\MPtext #1{\begincsname\??mptext#1\endcsname\empty} -\permanent\def\MPstring#1{"\begincsname\??mptext#1\endcsname\empty"} -\permanent\def\MPbetex #1{btex \begincsname\??mptext#1\endcsname\space etex} +\permanent\protected\def\setMPtext#1#2{\dodoglobal\edefcsname\??mptext#1\endcsname{\detokenize{#2}}} +\permanent \def\MPtext #1{\begincsname\??mptext#1\endcsname\empty} +\permanent \def\MPstring #1{"\begincsname\??mptext#1\endcsname\empty"} +\permanent \def\MPbetex #1{btex \begincsname\??mptext#1\endcsname\space etex} %D In order to communicate conveniently with the \TEX\ engine, we introduce some %D typesetting variables. diff --git a/tex/context/base/mkiv/mult-def.lua b/tex/context/base/mkiv/mult-def.lua index 08baaf437..6d6813fde 100644 --- a/tex/context/base/mkiv/mult-def.lua +++ b/tex/context/base/mkiv/mult-def.lua @@ -11,16 +11,16 @@ if not modules then modules = { } end modules ['mult-def'] = { return { ["commands"]={ - ["CAPPED"]={ - ["cs"]="KAP", - ["de"]="KAP", - ["en"]="CAP", - ["fr"]="CAP", - ["it"]="CAP", - ["nl"]="KAP", - ["pe"]="CAP", - ["ro"]="KAP", - }, +--["CAPPED"]={ +-- ["cs"]="KAP", +-- ["de"]="KAP", +-- ["en"]="CAP", +-- ["fr"]="CAP", +-- ["it"]="CAP", +-- ["nl"]="KAP", +-- ["pe"]="CAP", +-- ["ro"]="KAP", +--}, ["Character"]={ ["cs"]="Znak", ["de"]="Buchstabe", diff --git a/tex/context/base/mkiv/mult-low.lua b/tex/context/base/mkiv/mult-low.lua index ab7e78e18..e72c3ab22 100644 --- a/tex/context/base/mkiv/mult-low.lua +++ b/tex/context/base/mkiv/mult-low.lua @@ -65,7 +65,7 @@ return { "lessthanasciicode", "morethanasciicode", "doublecommentsignal", "atsignasciicode", "exclamationmarkasciicode", "questionmarkasciicode", "doublequoteasciicode", "singlequoteasciicode", "forwardslashasciicode", - "primeasciicode", "hyphenasciicode", + "primeasciicode", "hyphenasciicode", "percentasciicode", "leftbracketasciicode", "rightbracketasciicode", -- "frozenhsizecode", "frozenskipcode", "frozenhangcode", "frozenindentcode", "frozenparfillcode", "frozenadjustcode", "frozenprotrudecode", "frozentolerancecode", "frozenstretchcode", @@ -255,6 +255,7 @@ return { "scratchmuskip", "globalscratchmuskip", "privatescratchmuskip", "scratchtoks", "globalscratchtoks", "privatescratchtoks", "scratchbox", "globalscratchbox", "privatescratchbox", + "scratchmacro", "scratchmacroone", "scratchmacrotwo", -- "globalscratchcounterone", "globalscratchcountertwo", "globalscratchcounterthree", -- diff --git a/tex/context/base/mkiv/node-mig.mkxl b/tex/context/base/mkiv/node-mig.mkxl index f15f87f23..420140e6f 100644 --- a/tex/context/base/mkiv/node-mig.mkxl +++ b/tex/context/base/mkiv/node-mig.mkxl @@ -38,7 +38,7 @@ \registerctxluafile{node-mig}{autosuffix} -\let\automigrateinserts\relax -\let\automigratemarks \relax +\aliased\let\automigrateinserts\donothing +\aliased\let\automigratemarks \donothing \protect diff --git a/tex/context/base/mkiv/spac-hor.mkxl b/tex/context/base/mkiv/spac-hor.mkxl index f6fb41ea8..450e4fd76 100644 --- a/tex/context/base/mkiv/spac-hor.mkxl +++ b/tex/context/base/mkiv/spac-hor.mkxl @@ -178,10 +178,9 @@ %newif\ifindentation \indentationtrue % will become a mode -\let\checkindentation\relax +\aliased\let\checkindentation\relax \installmacrostack\checkindentation -%installmacrostack\ifindentation \def\spac_indentation_remove {\ifzeropt\parindent \else @@ -194,25 +193,25 @@ {%\global\indentationfalse \spac_indentation_remove} -\def\spac_indentation_do_toggle_indeed +\permanent\protected\def\spac_indentation_do_toggle_indeed {%\global\indentationfalse - \glet\checkindentation\spac_indentation_no_toggle_indeed + \enforced\glet\checkindentation\spac_indentation_no_toggle_indeed \spac_indentation_remove} -\def\spac_indentation_no_toggle_indeed +\permanent\protected\def\spac_indentation_no_toggle_indeed {%\global\indentationtrue - \glet\checkindentation\spac_indentation_do_toggle_indeed} + \enforced\glet\checkindentation\spac_indentation_do_toggle_indeed} -\def\spac_indentation_do_indeed +\permanent\protected\def\spac_indentation_do_indeed {}%\global\indentationtrue} -\def\spac_indentation_do_toggle - {\glet\checkindentation\spac_indentation_do_toggle_indeed} +\permanent\protected\def\spac_indentation_do_toggle + {\enforced\glet\checkindentation\spac_indentation_do_toggle_indeed} -\def\spac_indentation_no_toggle - {\glet\checkindentation\spac_indentation_no_toggle_indeed} +\permanent\protected\def\spac_indentation_no_toggle + {\enforced\glet\checkindentation\spac_indentation_no_toggle_indeed} -\def\spac_indentation_check_toggle +\permanent\protected\def\spac_indentation_check_toggle {\ifcase\c_spac_indentation_toggle_state % nothing \or @@ -221,23 +220,23 @@ \spac_indentation_do_toggle \fi} -\def\spac_indentation_variant_yes - {\glet\checkindentation\spac_indentation_do_indeed} +\permanent\protected\def\spac_indentation_variant_yes + {\enforced\glet\checkindentation\spac_indentation_do_indeed} -\def\spac_indentation_no_next_check +\permanent\protected\def\spac_indentation_no_next_check {\spac_indentation_remove - \glet\checkindentation\spac_indentation_do_indeed} + \enforced\glet\checkindentation\spac_indentation_do_indeed} \permanent\protected\def\spac_indentation_variant_no % made global {\ifinpagebody \else %\global\indentationfalse - \glet\checkindentation\spac_indentation_no_next_check + \enforced\glet\checkindentation\spac_indentation_no_next_check \fi} \permanent\protected\def\nonoindentation % bv bij floats {\ifinpagebody \else %\global\indentationtrue - \glet\checkindentation\spac_indentation_do_indeed + \enforced\glet\checkindentation\spac_indentation_do_indeed \fi} \permanent\protected\def\spac_indentation_variant_force @@ -248,26 +247,16 @@ \noindent\hskip\parindent \fi \fi} -\appendtoks - \push_macro_checkindentation - \push_macro_ifindentation -\to \everypushsomestate - -\appendtoks - \pop_macro_ifindentation - \pop_macro_checkindentation -\to \everypopsomestate - % public: -\let\indentation \spac_indentation_variant_force -\let\noindentation\spac_indentation_variant_no % public -\let\doindentation\spac_indentation_variant_yes % public +\aliased\let\indentation \spac_indentation_variant_force +\aliased\let\noindentation\spac_indentation_variant_no % public +\aliased\let\doindentation\spac_indentation_variant_yes % public \permanent\protected\def\dontrechecknextindentation % public (in macros) {\global\enforced\let\dorechecknextindentation\relax} -\let\dorechecknextindentation\relax % public (in macros) +\aliased\let\dorechecknextindentation\relax % public (in macros) \permanent\protected\protected\def\spac_indentation_check_next_indentation {\global\enforced\let\dorechecknextindentation\relax diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex ab1d3a038..59506d8ca 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 21b55a433..46ad6854d 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/strc-enu.mklx b/tex/context/base/mkiv/strc-enu.mklx index 0561ad340..c593a65b0 100644 --- a/tex/context/base/mkiv/strc-enu.mklx +++ b/tex/context/base/mkiv/strc-enu.mklx @@ -244,10 +244,6 @@ \newtoks\everyenumeration -\appendtoks - \disablepseudocaps % sorry, uppercase causes troubles -\to \everyenumeration - \letcsname\??constructionmainhandler \v!enumeration\expandafter\endcsname\csname\??constructionmainhandler \v!description\endcsname \letcsname\??constructioncommandhandler\v!enumeration\expandafter\endcsname\csname\??constructioncommandhandler\v!description\endcsname \letcsname\??constructionstarthandler \v!enumeration\expandafter\endcsname\csname\??constructionstarthandler \v!description\endcsname diff --git a/tex/context/base/mkiv/syst-aux.mkxl b/tex/context/base/mkiv/syst-aux.mkxl index 0f268854b..d3e75fd07 100644 --- a/tex/context/base/mkiv/syst-aux.mkxl +++ b/tex/context/base/mkiv/syst-aux.mkxl @@ -219,7 +219,7 @@ %D is more efficient but it probably won't be noticed. It's anyway cheaper on memory %D access. We use versions that don't even store the arguments. -%def\gobbleoneargument #-{} +%permanent\def\gobbleoneargument #-{} \permanent\def\gobbletwoarguments #-#-{} \permanent\def\gobblethreearguments #-#-#-{} \permanent\def\gobblefourarguments #-#-#-#-{} @@ -259,9 +259,6 @@ % \mutable\let\nextnextnext \relax % kind of obsolete % \mutable\let\nexttoken \relax -\let\m_syst_action_yes\relax -\let\m_syst_action_nop\relax - \permanent\protected\def\doifelsenextchar#1#2#3% #1 should not be {} ! {\def\m_syst_action_yes{#2}% \def\m_syst_action_nop{#3}% @@ -3756,75 +3753,13 @@ \aliased\let\doifsamestringelse\doifelsesamestring -% BEGIN OF OBSOLETE % - -%D \macros -%D {ConvertToConstant,ConvertConstantAfter} -%D -%D When comparing arguments with a constant, we can get into trouble when this -%D argument consists of tricky expandable commands. One solution for this is -%D converting the argument to a string of unexpandable characters. To make -%D comparison possible, we have to convert the constant too. -%D -%D \starttyping -%D \ConvertToConstant\doifelse {...} {...} {then ...} {else ...} -%D \stoptyping -%D -%D This construction is only needed when the first argument can give troubles. -%D Misuse can slow down processing. -%D -%D \starttyping -%D \ConvertToConstant\doifelse{\c!alfa} {\c!alfa}{...}{...} -%D \ConvertToConstant\doifelse{alfa} {\c!alfa}{...}{...} -%D \ConvertToConstant\doifelse{alfa} {alfa} {...}{...} -%D \ConvertToConstant\doifelse{alfa \alfa test}{\c!alfa}{...}{...} -%D \stoptyping -%D -%D In examples~2 and~3 both arguments equal, in~1 and~4 they differ. - -\permanent\protected\def\ConvertToConstant#1#2#3% will go - {\edef\m_syst_string_one{\expandafter\detokenize\expandafter{#2}}% - \edef\m_syst_string_two{\expandafter\detokenize\expandafter{#3}}% - #1{\m_syst_string_one}{\m_syst_string_two}} - -%D When the argument \type{#1} consists of commands, we had better use +%D These are obsolete in MTX: %D %D \starttyping -%D \ConvertConstantAfter\processaction[#1][...] -%D \ConvertConstantAfter\doifelse{#1}{\v!something}{}{} +%D \ConvertToConstant #1#2#3 +%D \CheckConstantAfter #1#2 +%D \ConvertConstantAfter #1#2#3 %D \stoptyping -%D -%D This commands accepts things like: -%D -%D \starttyping -%D \v!constant -%D constant -%D \hbox to \hsize{\rubish} -%D \stoptyping -%D -%D As we will see in the core modules, this macro permits constructions like: -%D -%D \starttyping -%D \setupfootertexts[...][...] -%D \setupfootertexts[margin][...][...] -%D \setupfootertexts[\v!margin][...][...] -%D \stoptyping -%D -%D where \type {...} can be anything legally \TEX. - -\permanent\protected\def\CheckConstantAfter#1#2% will go - {\expandafter\convertargument\v!prefix!\to\ascii - \convertargument#1\to#2\relax - \doifelseinstring\ascii{#2} - {\expandafter\convertargument#1\to#2} - {}} - -\permanent\protected\def\ConvertConstantAfter#1#2#3% will go - {\CheckConstantAfter{#2}\asciia - \CheckConstantAfter{#3}\asciib - #1{\asciia}{\asciib}} - -% END OF OBSOLETE % %D \macros %D {assignifempty} diff --git a/tex/context/base/mkiv/syst-ini.mkxl b/tex/context/base/mkiv/syst-ini.mkxl index f04e2e2db..8cb2b8c1c 100644 --- a/tex/context/base/mkiv/syst-ini.mkxl +++ b/tex/context/base/mkiv/syst-ini.mkxl @@ -67,7 +67,9 @@ \immutable\integerdef\morethanasciicode 62 % > used as alternative verbatim } \immutable\integerdef\questionmarkasciicode 63 % ? used in namespace protection \immutable\integerdef\atsignasciicode 64 % @ used in namespace protection +\immutable\integerdef\leftbracketasciicode 91 \immutable\integerdef\backslashasciicode 92 % `\\ +\immutable\integerdef\rightbracketasciicode 93 \immutable\integerdef\circumflexasciicode 94 \immutable\integerdef\underscoreasciicode 95 \immutable\integerdef\leftbraceasciicode 123 % `\{ @@ -76,6 +78,8 @@ \immutable\integerdef\tildeasciicode 126 % `\~ \immutable\integerdef\delasciicode 127 +\aliased\let\percentasciicode\commentasciicode + %catcode\zeroasciicode \ignorecatcode % `\^^@ ascii null is ignored \catcode\tabasciicode \spacecatcode % `\^^I ascii tab is a blank space \catcode\formfeedasciicode \activecatcode % `\^^L ascii form-feed (active, set later) @@ -155,8 +159,8 @@ \permanent\def\gobbleoneargument#-{} % will be defined later on anyway -%D First we define a simplified version of the \CONTEXT\ protection mechanism. -%D Later we will implement a better variant. +%D First we define a simplified version of the \CONTEXT\ protection mechanism. Later +%D we will implement a better variant. \def\unprotect {\edef\protect @@ -388,6 +392,10 @@ \newcount\globalscratchcountertwo \newcount\globalscratchcounterthree +\mutable\let\scratchmacro \relax +\mutable\let\scratchmacroone\relax +\mutable\let\scratchmacrotwo\relax + %D \macros %D {tempstring} diff --git a/tex/context/base/mkiv/tabl-ntb.mkxl b/tex/context/base/mkiv/tabl-ntb.mkxl index 45e9236ff..f47c67802 100644 --- a/tex/context/base/mkiv/tabl-ntb.mkxl +++ b/tex/context/base/mkiv/tabl-ntb.mkxl @@ -895,10 +895,10 @@ \let\eTABLEbody\relax \let\eTABLEfoot\relax -\permanent\tolerant\protected\def\bTABLEhead[#1]#2\eTABLEhead{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_head} -\permanent\tolerant\protected\def\bTABLEnext[#1]#2\eTABLEnext{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_next} -\permanent\tolerant\protected\def\bTABLEbody[#1]#2\eTABLEbody{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_body} -\permanent\tolerant\protected\def\bTABLEfoot[#1]#2\eTABLEfoot{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_foot} +\permanent\tolerant\protected\def\bTABLEhead[#1]#:#2\eTABLEhead{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_head} +\permanent\tolerant\protected\def\bTABLEnext[#1]#:#2\eTABLEnext{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_next} +\permanent\tolerant\protected\def\bTABLEbody[#1]#:#2\eTABLEbody{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_body} +\permanent\tolerant\protected\def\bTABLEfoot[#1]#:#2\eTABLEfoot{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_foot} \def\tabl_ntb_section[#1]#2% also used in tabl-nte {\protected\def\tabl_ntb_setup_section{\setupcurrentnaturaltablelocal[#1]}% diff --git a/tex/context/base/mkiv/typo-brk.mkxl b/tex/context/base/mkiv/typo-brk.mkxl new file mode 100644 index 000000000..51abc1034 --- /dev/null +++ b/tex/context/base/mkiv/typo-brk.mkxl @@ -0,0 +1,94 @@ +%D \module +%D [ file=typo-brk, +%D version=2009.03.27, % code moved from core-spa.mkiv +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Breakpoints, +%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 Typesetting Macros / Breakpoints} + +\unprotect + +% hm, we cannot prebuild lists, font dependent +% +% -- type nleft nright language left right middle +% +% -- we might eventually stick to only method 5 + +\registerctxluafile{typo-brk}{} + +\definesystemattribute[breakpoint][public,global] + +% see below: \exhyphenchar \minusone % we use a different order than base tex, so we really need this + +\permanent\tolerant\protected\def\definebreakpoints[#1]% + {\clf_definebreakpoints{#1}} % todo: public implementor + +\permanent\tolerant\protected\def\definebreakpoint[#1]#*[#2]#*[#3]% name char settings + {\begingroup + \getdummyparameters + [\c!type=\plusone,\c!nleft=\plusthree,\c!nright=\plusthree,% + \s!language=,\c!left=,\c!right=,\c!middle=,\c!range=\v!no,% + #3]% + \clf_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}% + range {\directdummyparameter\c!range}% + }% + \relax + \endgroup} + +\permanent\protected\def\setbreakpoints[#1]% + {\exhyphenchar\minusone % we use a different order than base tex, so we really need this + \clf_setbreakpoints{#1}} + +\permanent\protected\def\resetbreakpoints + {\exhyphenchar\hyphenasciicode % 2020.03.05 + \c_attr_breakpoint\attributeunsetvalue} + +\definebreakpoints[compound] + +% 1: simple break +% 6: simple break but skip same + +\definebreakpoint [compound] [+] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= +%definebreakpoint [compound] [-] [\c!nleft=3,\c!nright=3,\c!type=1,\c!range=\v!yes] % middle=+,left=,right= +\definebreakpoint [compound] [-] [\c!nleft=3,\c!nright=3,\c!type=6,\c!range=\v!yes] % middle=+,left=,right= +\definebreakpoint [compound] [/] [\c!nleft=3,\c!nright=3,\c!type=1] % middle=+,left=,right= +\definebreakpoint [compound] [(] [\c!nleft=3,\c!nright=3,\c!type=2] % type=5,middle=(,left=(-,right= +\definebreakpoint [compound] [)] [\c!nleft=3,\c!nright=3,\c!type=3] % type=5,middle=),left=,right=-) + +\aliased\let\installbreakpoint\definebreakpoint % for a while + +% \start \hsize 1.5cm \setbreakpoints[compound] +% \definebreakpoint [compound] [-] [nleft=3,nright=3,type=5,left=,right={-},middle={-}] +% \definebreakpoint [compound] [(] [nleft=3,nright=3,type=5,left=,right={(-},middle={(}] +% \definebreakpoint [compound] [)] [nleft=3,nright=3,type=5,left={-)},right=,middle={)}] +% composed-word\par composed(word)\par +% \stop + +% \mainlanguage[czech] +% \definebreakpoint [compound] [\number`-] [language=cs,nleft=3,nright=3,type=4] +% \setbreakpoints[compound] +% \start \hsize 1mm test-test \par \stop + +%D Maybe some day default: +% +% \setbreakpoints[compound] + +\protect \endinput + diff --git a/tex/context/base/mkiv/typo-cap.mkxl b/tex/context/base/mkiv/typo-cap.mkxl new file mode 100644 index 000000000..1674f1eed --- /dev/null +++ b/tex/context/base/mkiv/typo-cap.mkxl @@ -0,0 +1,265 @@ +%D \module +%D [ file=typo-cap, +%D version=2009.03.27, % code moved from core-spa.mkiv +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Capping, +%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 Typesetting Macros / Caps} + +\unprotect + +%D Maybe we need a more clever system: either command or style mode etc. so +%D that we can avoid the grouped mess in a simple style switch. + +\registerctxluafile{typo-cap}{optimize} + +% \definesystemattribute[case][public] % already predefined + +%D \macros +%D {setupcapitals} +%D +%D By default we use pseudo small caps in titles. This can be set up with: +%D +%D \showsetup{setupcapitals} + +\installcorenamespace{capitals} + +\installcommandhandler \??capitals {capitals} \??capitals + +%D Beware, these are not really defines (yet). + +\definecapitals[\v!WORD] % all upper +\definecapitals[\v!capital] % one upper + font +\definecapitals[\v!Capital] % some upper + font +\definecapitals[\v!mixed] % UpperCase +\definecapitals[\v!Word] % one upper + font +\definecapitals[\v!Words] % some upper +\definecapitals[\v!camel] % lowers first +\definecapitals[\v!word][\c!style=] % nothing + +%D \macros +%D {Word, Words, WORD, WORDS} +%D +%D This is probably not the right place to present the next set of macros. +%D +%D \starttyping +%D \Word {far too many words} +%D \Words{far too many words} +%D \WORD {far too many words} +%D \WORDS{far too many words} +%D \stoptyping +%D +%D \typebuffer +%D +%D This calls result in: +%D +%D \startlines +%D \getbuffer +%D \stoplines +%D +%D \showsetup{Word} +%D \showsetup{Words} +%D \showsetup{WORD} +%D \showsetup{WORDS} + +% test \WORD{test TEST \TeX} test +% test \word{test TEST \TeX} test +% test \Word{test TEST \TeX} test + +\permanent\protected\def\setcharactercasing[#1]{\clf_setcharactercasing{#1}\fontid\font} % can be public implementor + +\protected\def\typo_capitale_WORD {\clf_setcharactercasing{\v!WORD }\fontid\font} +\protected\def\typo_capitale_word {\clf_setcharactercasing{\v!word }\fontid\font} +\protected\def\typo_capitale_Word {\clf_setcharactercasing{\v!Word }\fontid\font} +\protected\def\typo_capitale_Words{\clf_setcharactercasing{\v!Words}\fontid\font} +\protected\def\typo_capitale_camel{\clf_setcharactercasing{\v!camel}\fontid\font} + +\permanent\protected\def\WORD {\triggergroupedcommandcs\typo_capitale_WORD } +\permanent\protected\def\word {\triggergroupedcommandcs\typo_capitale_word } +\permanent\protected\def\Word {\triggergroupedcommandcs\typo_capitale_Word } +\permanent\protected\def\Words{\triggergroupedcommandcs\typo_capitale_Words} +\permanent\protected\def\camel{\triggergroupedcommandcs\typo_capitale_camel} + +\aliased\let\WORDS\WORD +\aliased\let\words\word + +%D \macros +%D {kap,KAP,Kap,Kaps,nokap,userealcaps,usepseudocaps} +%D +%D We already introduced \type {\cap} as way to capitalize words. This command comes +%D in several versions: +%D +%D \startbuffer +%D \cap {let's put on a \cap{cap}} +%D \cap {let's put on a \nocap{cap}} +%D \CAP {let's put on a \\{cap}} +%D \Cap {let's put on a \\{cap}} +%D \Caps{let's put on a cap} +%D \stopbuffer +%D +%D \typebuffer +%D +%D Note the use of \type {\nocap}, \type {\\} and the nested \type {\cap}. +%D +%D \startlines +%D \getbuffer +%D \stoplines +%D +%D These macros show te main reason why we introduced the smaller \type {\tx} and +%D \type {\txx}. +%D +%D \starttyping +%D \cap\romannumerals{1995} +%D \stoptyping +%D +%D This at first sight unusual capitilization is completely legal. +%D +%D \showsetup{smallcapped} +%D \showsetup{notsmallcapped} +%D \showsetup{CAPPED} +%D \showsetup{SmallCapped} +%D \showsetup{SmallCaps} +%D +%D The difference between pseudo and real caps is demonstrated below: +%D +%D \startbuffer +%D \usepseudocaps \cap{Hans Hagen} +%D \userealcaps \cap{Hans Hagen} +%D \stopbuffer +%D +%D \typebuffer +%D +%D \getbuffer +%D +%D The \type {\bgroup} trickery below is needed because of \type {\groupedcommand}. + +\newconditional\c_typo_capitals_pseudo + +\permanent\protected\def\usepseudocaps{\settrue \c_typo_capitals_pseudo} +\permanent\protected\def\userealcaps {\setfalse\c_typo_capitals_pseudo} + +\usepseudocaps + +% we use char0 as placeholder for the larger font +% +% here we keep the \groupedcommand + +\def\typo_capitals_set_fake#1% + {\edef\currentcapitals{#1}% + \clf_setcharactercasing{\currentcapitals}\fontid\font + \usecapitalsstyleparameter\c!style} + +\def\typo_capitals_set_real#1% + {\edef\currentcapitals{#1}% + \sc + \clf_setcharactercasing{\currentcapitals}\fontid\font} + +\permanent\protected\def\pseudosmallcapped{\triggergroupedcommandcs\font_style_pseudosmallcapped} +\permanent\protected\def\pseudoSmallcapped{\triggergroupedcommandcs\font_style_pseudoSmallcapped} +\permanent\protected\def\pseudoSmallCapped{\triggergroupedcommandcs\font_style_pseudoSmallCapped} +\permanent\protected\def\pseudoMixedCapped{\triggergroupedcommandcs\font_style_pseudoMixedCapped} + +\permanent\protected\def\realsmallcapped {\triggergroupedcommandcs\font_style_realsmallcapped} +\permanent\protected\def\realSmallcapped {\triggergroupedcommandcs\font_style_realSmallcapped} +\permanent\protected\def\realSmallCapped {\triggergroupedcommandcs\font_style_realSmallCapped} + +\permanent\protected\def\notsmallcapped {\triggergroupedcommandcs\font_style_notsmallcapped} + +\protected\def\font_style_pseudosmallcapped{\typo_capitals_set_fake\v!WORD } % all upper +\protected\def\font_style_pseudoSmallcapped{\typo_capitals_set_fake\v!capital} % one upper + font +\protected\def\font_style_pseudoSmallCapped{\typo_capitals_set_fake\v!Capital} % some upper + font +\protected\def\font_style_pseudoMixedCapped{\typo_capitals_set_fake\v!mixed } + +\protected\def\font_style_realsmallcapped {\typo_capitals_set_real\v!WORD } % all lower +\protected\def\font_style_realSmallcapped {\typo_capitals_set_real\v!Word } % one upper + font +\protected\def\font_style_realSmallCapped {\typo_capitals_set_real\v!Words } % some upper + +\protected\def\font_style_notsmallcapped {\typo_capitals_set_fake\v!word } + +\protected\def\typo_capitals_smallcaps + {\ifconditional\c_typo_capitals_pseudo + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\permanent\protected\def\smallcapped{\typo_capitals_smallcaps\pseudosmallcapped\realsmallcapped} +\permanent\protected\def\Smallcapped{\typo_capitals_smallcaps\pseudoSmallcapped\realSmallcapped} +\permanent\protected\def\SmallCapped{\typo_capitals_smallcaps\pseudoSmallCapped\realSmallCapped} + +\permanent\protected\def\font_style_smallcapped{\typo_capitals_smallcaps\font_style_pseudosmallcapped\font_style_realsmallcapped} +\permanent\protected\def\font_style_Smallcapped{\typo_capitals_smallcaps\font_style_pseudoSmallcapped\font_style_realSmallcapped} +\permanent\protected\def\font_style_SmallCapped{\typo_capitals_smallcaps\font_style_pseudoSmallCapped\font_style_realSmallCapped} + +\permanent\protected\def\autocap{\ifmmode\expandafter\normalcap\else\expandafter\smallcapped\fi} + +\prependtoks + \enforced\let\normalcap\cap % mathmode cap +\to \everydump + +\appendtoks + \enforced\let\cap\autocap +\to \everydump + +\aliased\let\kap\cap % for old times sake +\aliased\let\Caps\SmallCapped % for old times sake + +\aliased\let\mixedcaps\pseudoMixedCapped + +\aliased\let\normalsmallcapped\smallcapped +\aliased\let\normalWORD \WORD +\aliased\let\normalword \word + +\aliased\let\font_style_normalsmallcapped\font_style_smallcapped +\aliased\let\font_style_normalWORD \WORD +\aliased\let\font_style_normalword \word + +\appendtoks + \ifx\currentcapitals\empty + \doifelse{\directcapitalsparameter\c!title}\v!yes + {\definealternativestyle[\v!capital ][\font_style_normalsmallcapped][\font_style_normalsmallcapped]% + \definealternativestyle[\v!smallcaps][\setsmallcaps][\setsmallcaps]} + {\definealternativestyle[\v!capital ][\font_style_normalsmallcapped][\font_style_normalWORD]% + \definealternativestyle[\v!smallcaps][\setsmallcaps][\font_style_normalWORD]}% + \doifelse{\directcapitalsparameter\s!sc}\v!yes + \userealcaps + \usepseudocaps + \fi +\to \everysetupcapitals + +\aliased\let\uppercased\normalWORD +\aliased\let\lowercased\normalword + +\setupcapitals + [\c!title=\v!yes, + \c!style=\tx, + \s!sc=\v!no] % no \c!sc any longer + +\definefont + [MixedCaps] + [CurrentFont*default cp 1.2\exheight] + +\setupcapitals + [\v!mixed] + [\c!style=MixedCaps] + +% \definestartstop is not yet in available at core-spa time +% +% \startrandomized \input tufte \stoprandomized +% +% \definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=] + +% \protected\def\randomizetext{\groupedcommand{\c_attr_case\pluseight}{}} + +\permanent\protected\def\randomizetext{\triggergroupedcommand{\c_attr_case\pluseight}} + +\definestartstop[randomized][\c!before=\dosetattribute{case}{8},\c!after=] + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-ini.mkxl b/tex/context/base/mkiv/typo-ini.mkxl new file mode 100644 index 000000000..3e0790af0 --- /dev/null +++ b/tex/context/base/mkiv/typo-ini.mkxl @@ -0,0 +1,49 @@ +%D \module +%D [ file=typo-ini, +%D version=2000.16.09, +%D title=\CONTEXT\ Typographic Macros, +%D subtitle=Initialization, +%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 Since \CONTEXT\ is dealing with typographics, isn't +%D September 2000 a bit late to start writing this module? It +%D may seem so, but since more and more languages are +%D supported, we think it is time to isolate language specific +%D typographic extensions in modules. The first language that +%D demands this is Chinese, and more will follow. + +\writestatus{loading}{ConTeXt Typographic Macros / Initialization} + +\registerctxluafile{typo-ini}{} + +\unprotect + +% This will be done differently: +% +% %D \macros +% %D {ifvertical} +% %D +% %D The following switch can be used to signal macros that they +% %D should adapt their behaviour. +% +% \newif\ifvertical % maybe also ifreverse +% +% %D \macros +% %D {vhbox} +% %D +% %D A stupid but useful macro. +% +% \def\vhbox{\ifvertical\vbox\else\hbox\fi} + +%D \macros +%D {everyresettypesetting} + +\newtoks\everyresettypesetting + +\protect \endinput diff --git a/tex/context/base/mkiv/typo-inj.mkiv b/tex/context/base/mkiv/typo-inj.mkiv index 633d430e4..db5bb2d5b 100644 --- a/tex/context/base/mkiv/typo-inj.mkiv +++ b/tex/context/base/mkiv/typo-inj.mkiv @@ -44,35 +44,31 @@ %D \startsection[title=Delta] fourth \index{fourth} \stopsection %D \stoptext -\unexpanded\def\resetinjector [#1]{\clf_resetinjector{#1}} -\unexpanded\def\markinjector [#1]{\dontleavehmode\clf_markinjector{#1}} -\unexpanded\def\docheckinjector [#1][#2]{\clf_checkinjector{#1}{#2}} -\unexpanded\def\checknextinjector [#1]{\clf_checkinjector{#1}{\v!next}} -\unexpanded\def\checkpreviousinjector [#1]{\clf_checkinjector{#1}{\v!previous}} -%unexpanded\def\checknextinjector [#1]{\clf_checknextinjector{#1}} -%unexpanded\def\checkpreviousinjector [#1]{\clf_checkpreviousinjector{#1}} -\unexpanded\def\dosetinjector [#1][#2][#3]{\clf_setinjector{#1}{#2}{#3}} -\unexpanded\def\doshowinjector [#1]{\clf_showinjector{#1}} +\permanent \protected\def\resetinjector [#1]{\clf_resetinjector{#1}} +\permanent \protected\def\markinjector [#1]{\dontleavehmode\clf_markinjector{#1}} +\permanent\tolerant\protected\def\checkinjector [#1]#*[#2]{\clf_checkinjector{#1}{#2}} +\permanent \protected\def\checknextinjector [#1]{\clf_checkinjector{#1}{\v!next}} +\permanent \protected\def\checkpreviousinjector [#1]{\clf_checkinjector{#1}{\v!previous}} +%permanent \protected\def\checknextinjector [#1]{\clf_checknextinjector{#1}} +%permanent \protected\def\checkpreviousinjector [#1]{\clf_checkpreviousinjector{#1}} +\permanent\tolerant\protected\def\setinjector [#1]#*[#2]#*[#3]{\clf_setinjector{#1}{#2}{#3}} +\permanent\tolerant\protected\def\showinjector [#1]{\clf_showinjector{#1}} -\unexpanded\def\checkinjector{\dodoubleempty \docheckinjector} -\unexpanded\def\setinjector {\dotripleargument\dosetinjector} -\unexpanded\def\showinjector {\dosingleempty \doshowinjector} - -\unexpanded\def\domarkinjector#1#2% called at the lua end +\permanent\protected\def\domarkinjector#1#2% called at the lua end {\dontleavehmode\llap{\infofont\ifcase#1\else\red\fi<#2>\quad}} % low level definers .. we could have \injectors_mark and \injectors_check and then % use \v!list instead of \s!list -\unexpanded\def\doinstallinjector#1% +\permanent\protected\def\doinstallinjector#1% {\letvalue{typo_injectors_mark_#1}\donothing \letvalue{typo_injectors_check_#1}\donothing} -\unexpanded\def\doactivateinjector#1% used at lua end +\permanent\protected\def\doactivateinjector#1% used at lua end {\setuxvalue{typo_injectors_mark_#1}{\dontleavehmode\noexpand\clf_markinjector{#1}}% \setuxvalue{typo_injectors_check_#1}{\noexpand\clf_checkinjector{#1}}} -\unexpanded\def\dotestinjector#1% only for testing outside unprotect +\permanent\protected\def\dotestinjector#1% only for testing outside unprotect {\begincsname typo_injectors_check_#1\endcsname \begincsname typo_injectors_mark_#1\endcsname} diff --git a/tex/context/base/mkiv/typo-inj.mkxl b/tex/context/base/mkiv/typo-inj.mkxl new file mode 100644 index 000000000..633d430e4 --- /dev/null +++ b/tex/context/base/mkiv/typo-inj.mkxl @@ -0,0 +1,80 @@ +%D \module +%D [ file=typo-inj, +%D version=2014.10.13, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Triggering Actions, +%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 Typesetting Macros / Triggering Actions} + +%D This is a sort of escape from too automatic typesetting of lists. I have +%D been thinking fo a more generic injector for instance based on tags (as we +%D already index each element) but thi sis sort of fuzzy because the number of a +%D tag is not always incremented before we check for it. Also, registers and lists +%D are among the few candidates that cannot be controlled directly by putting +%D something in the input. So,m for the moment I stick to this mechanism but +%D future versions of \CONTEXT\ might do it differently. Compatibility is not much +%D of an issue here as this mechanism is only to be used in final production runs. + +\unprotect + +\registerctxluafile{typo-inj}{} + +% todo: no need in trialmode + +%D \showinjector +%D +%D \setinjector[register][3][\column] +%D \setinjector[list] [2][{\blank[3*big]}] +%D +%D \starttext +%D \placelist[section][criterium=text] +%D \blank[3*big] +%D \placeregister[index][criterium=text] +%D \page +%D \startsection[title=Alpha] first \index{first} \stopsection +%D \startsection[title=Beta] second \index{second} \stopsection +%D \startsection[title=Gamma] third \index{third} \stopsection +%D \startsection[title=Delta] fourth \index{fourth} \stopsection +%D \stoptext + +\unexpanded\def\resetinjector [#1]{\clf_resetinjector{#1}} +\unexpanded\def\markinjector [#1]{\dontleavehmode\clf_markinjector{#1}} +\unexpanded\def\docheckinjector [#1][#2]{\clf_checkinjector{#1}{#2}} +\unexpanded\def\checknextinjector [#1]{\clf_checkinjector{#1}{\v!next}} +\unexpanded\def\checkpreviousinjector [#1]{\clf_checkinjector{#1}{\v!previous}} +%unexpanded\def\checknextinjector [#1]{\clf_checknextinjector{#1}} +%unexpanded\def\checkpreviousinjector [#1]{\clf_checkpreviousinjector{#1}} +\unexpanded\def\dosetinjector [#1][#2][#3]{\clf_setinjector{#1}{#2}{#3}} +\unexpanded\def\doshowinjector [#1]{\clf_showinjector{#1}} + +\unexpanded\def\checkinjector{\dodoubleempty \docheckinjector} +\unexpanded\def\setinjector {\dotripleargument\dosetinjector} +\unexpanded\def\showinjector {\dosingleempty \doshowinjector} + +\unexpanded\def\domarkinjector#1#2% called at the lua end + {\dontleavehmode\llap{\infofont\ifcase#1\else\red\fi<#2>\quad}} + +% low level definers .. we could have \injectors_mark and \injectors_check and then +% use \v!list instead of \s!list + +\unexpanded\def\doinstallinjector#1% + {\letvalue{typo_injectors_mark_#1}\donothing + \letvalue{typo_injectors_check_#1}\donothing} + +\unexpanded\def\doactivateinjector#1% used at lua end + {\setuxvalue{typo_injectors_mark_#1}{\dontleavehmode\noexpand\clf_markinjector{#1}}% + \setuxvalue{typo_injectors_check_#1}{\noexpand\clf_checkinjector{#1}}} + +\unexpanded\def\dotestinjector#1% only for testing outside unprotect + {\begincsname typo_injectors_check_#1\endcsname + \begincsname typo_injectors_mark_#1\endcsname} + +\protect \endinput + diff --git a/tex/context/base/mkiv/typo-mar.mkxl b/tex/context/base/mkiv/typo-mar.mkxl new file mode 100644 index 000000000..8c8fc218e --- /dev/null +++ b/tex/context/base/mkiv/typo-mar.mkxl @@ -0,0 +1,474 @@ +% macros=mkvi + +%D \module +%D [ file=typo-mar, +%D version=2010.02.15, % was experimental code +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Margindata, +%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. + +% maybe dontleavehmode when scope is local + +% todo: tags +% todo: force inline with option (saves pos) +% todo: margintitle (also less position then) + +\writestatus{loading}{ConTeXt Typesetting Macros / Margindata} + +\unprotect + +%D This module has been on the agenda for a while. Actually, it is one of the things +%D that I really need myself, for instance when rendering rather unpredictable +%D (educational) tests encoded in XML. This module permits anchoring for instance +%D item numbers and also overload them when they have subnumbers. In the future it +%D might replace the current maginal note mechanism (that then will be just an +%D instance). +%D +%D In spite of what might be expected, the more advanced \LUA\ based variant is upto +%D twice as fast on simple entries. Also, we no longer need an extra pass to get +%D inner and outer alignments in sync with the pagebuilder. + +\registerctxluafile{typo-mar}{} + +%definesystemattribute[margindata] % only at the lua end + +%D In \MKII\ we have three categories and their historically meaning is as follows: +%D +%D marginlines: These are flushed relative to the start of a line and need to be +%D invoked there. +%D +%D marginwords: These can be issued in the text flow and will migrate sidewards; in +%D spite of the name, it can be a paragraph of text as well, but normally it's +%D words. +%D +%D margintexts: These can be set beforehand and are flushed at the next paragraph of +%D text (of header). +%D +%D In \MKIV\ we have further integrated the mechanism and we now have: +%D +%D margindata: This can be anything that needs to go into the margin. It can be +%D anchored in the text or given beforehand in which case it gets flushed at the +%D first occasion. +%D +%D margintext: This runs on top of margindata and the only difference is that it +%D uses the framed mechanism for packaging. +%D +%D Stacking is done differently as is inner and outer alignment (in most cases more +%D efficient). The functionality is mostly the same as in \MKII, but there are a few +%D additions, like names entries, where later ones overload preceding not yet +%D flushed ones. Data can get catagorized and is then treated as a group (e.g. when +%D stacking is needed). +%D +%D The amount of \TEX\ code is less than in \MKII\ because we do all trickery in at +%D the \LUA\ end. At the end of this file we define several commands, like \type +%D {\inleftmargin} and \type {\inleft}. You can configure them individually or as a +%D group. There is an inheritance model in place. +%D +%D The following notes will be stacked: +%D +%D \starttyping +%D \ininner[line=2]{IM A} +%D \ininner[stack=yes]{IM B} +%D \ininner[stack=yes]{IM C} +%D \stoptyping +%D +%D The distance between them is determined by \type {dy}: +%D +%D \starttyping +%D \ininner[stack=yes,dy=2ex][frame=on] {IM A} +%D \ininner[stack=yes,dy=2ex][frame=on] {IM B} +%D \stoptyping +%D +%D There are several methods of vertical alignment. +%D +%D \starttyping +%D \inmargin [method=first] [frame=on] {first\\second} \input ward \par +%D \inmargin [method=first] [frame=on,offset=3pt] {first\\second} \input ward \par +%D \inmargin [method=first,voffset=-3pt][frame=on,offset=3pt,rulethickness=3pt] {first\\second} \input ward \par +%D \inmargin [method=first,voffset=-6pt][frame=on,offset=3pt,rulethickness=3pt] {first\\second} \input ward \par +%D \stoptyping +%D +%D You sometimes need to combine \type {voffset} with \type {offset}. The first +%D argument concerns the data, the second the framed. Not sharing the setup is on +%D purpose: location, offset, alignment and other parameters might clash. + +\installcorenamespace{margindata} +\installcorenamespace{marginframed} + +\installcommandhandler \??margindata {margindata} \??margindata +\installframedcommandhandler \??marginframed {marginframed} \??marginframed + +\setupmargindata + [\c!location=\v!left, + % \c!align=, + % \c!method=, + \c!style=\v!bold, + \c!color=, % maybe \maintextcolor + % \c!name=, + % \c!category=, + \c!threshold=.25\exheight, + \c!margin=\v!normal, + \c!scope=\v!global, + \c!width=, + % \c!stack=, + % \c!stackname=, + % \c!option=, % \v!paragraph (follow shape) + \c!line=0, + \c!anchor=\v!text, + \c!bottomspace=\strutdepth, % slack used for keeptogether + \c!dy=\zeropoint, + \c!distance=\zeropoint, + \c!hoffset=\zeropoint, + \c!voffset=\zeropoint] + +\setupmarginframed % so, align should be set with the data command + [\c!strut=\v!yes, % so by default we scale the strut to the font ! + \c!offset=\v!overlay, + \c!fr!analyze=\v!yes, + \c!frame=\v!off, + \c!width=\margindataparameter\c!width, + \c!align=\margindataparameter\c!align] + +\appendtoks + \frozen\instance\setuevalue\currentmargindata{\margindata[\currentmargindata]}% +\to \everydefinemargindata + +\newconditional\inhibitmargindata % This one is used at the Lua end! +\newtoks \everymargindatacontent % Later on we will set this one. + +\appendtoks + \settrue\inhibitmargindata +\to \everyforgetall + +\appendtoks + \forgetall + \tf + \resetallattributes % \deactivatecolor % needed, but maybe we should switch to maintextcolor: \onlyinheritmaintextcolor + \pickupattributes +\to \everymargindatacontent + +% trialtypesetting: no need for margin stuff while trialing as +% is has no dimensions + +\newcount\nofmargintexts +\newcount\c_typo_margins_n + +\ifdefined\dotagmarginanchor \else \let\dotagmarginanchor\gobbleoneargument \fi +\ifdefined\dotagmargintext \else \let\dotagmargintext \gobbleoneargument \fi + +\definepagestate[\s!margintext] + +\protected\def\typo_margins_data_synchronize + {\doforcedtrackpagestate\s!margintext\nofmargintexts % includes increment + \docheckpagestate\s!margintext\nofmargintexts + %\doifelserightpagestate\s!margintext\nofmargintexts\relax\relax + \realpageno\realpagestateno + \swapmargins} + +\permanent\protected\def\margindata + {\iftrialtypesetting + \expandafter\typo_margins_data_nop + \else + \expandafter\typo_margins_data_yes + \fi} + +\permanent\tolerant\protected\def\typo_margins_data_nop[#name]#spacer[#dataparameters]#spacer[#textparameters]#:#content% + {} + +\permanent\tolerant\protected\def\typo_margins_data_yes[#name]#spacer[#dataparameters]#spacer[#textparameters]#:#content% + {\setfalse\inhibitmargindata % flushing afterwards + \begingroup + %\settrue\inhibitmargindata % no flushing in here + \def\currentmargindata{#name}% + \let\currentmarginframed\currentmargindata + \ifparameter#dataparameters\or + \setupcurrentmargindata[#dataparameters]% + \fi + \doifelsenothing{#content}\donefalse\donetrue + \global\advance\c_typo_margins_n\plusone + \ifdone + \edef\currentmarginreference{\margindataparameter\c!reference}% + \ifempty\currentmarginreference \else + \strc_references_set_page_only_destination_box_attribute\currentmarginreference\currentmarginreference + \fi + \edef\currentmargindatastrut{\margindataparameter\c!strut}% + \dostarttaggedchained\t!margintext\currentmargindata\??margindata + \dotagmargintext\c_typo_margins_n + \ifcsname\currentmarginframedhash\s!parent\endcsname + \setbox\nextbox\naturalhbox \currentmarginreference \bgroup + \the\everymargindatacontent + \usemargindatastyleandcolor\c!style\c!color + \setupcurrentmarginframed[\c!location=\v!normal,#textparameters]% + \typo_margins_data_synchronize + \inheritedmarginframedframed\bgroup + \ifempty\currentmargindatastrut \else + \synchronizestrut\currentmargindatastrut + \fi + \begstrut + \strc_references_flush_destination_nodes + \margindataparameter\c!command{#content}% + \endstrut + \egroup + \egroup + \edef\currentmarginfirstheight{\number\dimexpr\framedfirstheight}% + \else + \edef\currentmargindatawidth{\margindataparameter\c!width}% + \ifempty\currentmargindatawidth + \setbox\nextbox\naturalhbox \currentmarginreference \bgroup + \typo_margins_data_synchronize + \the\everymargindatacontent + \usemargindatastyleandcolor\c!style\c!color + \ifempty\currentmargindatastrut \else + \synchronizestrut\currentmargindatastrut + \fi + \begstrut + \strc_references_flush_destination_nodes + \margindataparameter\c!command{#content}% + \endstrut + \egroup + \let\currentmarginfirstheight\empty + \else + \setbox\nextbox\naturalhbox \currentmarginreference \bgroup + \typo_margins_data_synchronize + \dosetraggedcommand{\margindataparameter\c!align}% + \vtop \bgroup + \the\everymargindatacontent + \usemargindatastyleandcolor\c!style\c!color + \hsize\currentmargindatawidth + \raggedcommand + \ifempty\currentmargindatastrut \else + \synchronizestrut\currentmargindatastrut + \fi + \begstrut + \strc_references_flush_destination_nodes + \margindataparameter\c!command{#content}% + \endstrut + \egroup + \egroup + \edef\currentmarginfirstheight{true}% + \fi + \fi + \dostoptagged + \fi + \ifdone + \edef\p_anchor{\margindataparameter\c!anchor}% + \anch_positions_initialize % we use positions at the lua end + \dostarttagged\t!marginanchor\empty + \dotagmarginanchor\c_typo_margins_n + \clf_savemargindata + location {\margindataparameter\c!location}% + method {\margindataparameter\c!method}% + category {\margindataparameter\c!category}% + name {\margindataparameter\c!name}% + scope {\margindataparameter\c!scope}% + option {\margindataparameter\c!option}% + number \nextbox + margin {\margindataparameter\c!margin}% local normal margin edge + distance \dimexpr\margindataparameter\c!distance\relax + hoffset \dimexpr\margindataparameter\c!hoffset\relax + voffset \dimexpr\margindataparameter\c!voffset\relax + dy \dimexpr\margindataparameter\c!dy\relax + bottomspace \dimexpr\margindataparameter\c!bottomspace\relax + \ifempty\currentmarginfirstheight \else + baseline {\currentmarginfirstheight}% + \fi + threshold \dimexpr\margindataparameter\c!threshold\relax % overlap related, will change + \ifhmode + inline true % + \fi + anchor {\p_anchor\ifx\p_anchor\v!region:0\fi}% kind of a hack to force column anchoring (for now) + % + % we're not in forgetall + % + % \ifzeropt\leftskip \else + % leftskip \dimexpr\leftskip\relax + % \fi + % \ifzeropt\leftskip \else + % rightskip \dimexpr\rightskip\relax + % \fi + align {\margindataparameter\c!align}% + line \numexpr\margindataparameter\c!line\relax + stackname {\margindataparameter\c!stackname}% + stack {\margindataparameter\c!stack}% + index \c_typo_margins_n + \relax + \dostoptagged + \else + \clf_savemargindata + location {\margindataparameter\c!location}% + method {\margindataparameter\c!method}% + category {\margindataparameter\c!category}% + name {\margindataparameter\c!name}% + scope {\margindataparameter\c!scope}% + number \nextbox + \relax + \fi + \endgroup} + +%D Downward compatible hack: + +\permanent\protected\def\typo_margins_space_or_par + {\endgraf\ifhmode\space\fi} + +\appendtoks + \enforced\let\\\typo_margins_space_or_par +\to \everymargindatacontent + +%D Another one: + +% \installcorenamespace{oppositemargin} +% +% \letvalue{\??oppositemargin\v!left }\v!right +% \letvalue{\??oppositemargin\v!right }\v!left +% \letvalue{\??oppositemargin\v!inner }\v!outer +% \letvalue{\??oppositemargin\v!outer }\v!inner +% \letvalue{\??oppositemargin\v!normal}\v!normal +% +% \def\oppositemargin#1% +% {\csname\??oppositemargin\ifcsname\??oppositemargin#1\endcsname#1\else\v!normal\fi\endcsname} + +%D Definitions: + +% common to lines and text + +\setupmargindata [\v!left ] [\c!method=\v!first,\c!location=\v!left ,\c!margin=\v!margin,\c!align=\v!flushright,\s!parent=\??margindata] % we could autoparent when no define yet +\setupmargindata [\v!right] [\c!method=\v!first,\c!location=\v!right,\c!margin=\v!margin,\c!align=\v!flushleft, \s!parent=\??margindata] +\setupmargindata [\v!outer] [\c!method=\v!first,\c!location=\v!outer,\c!margin=\v!margin,\c!align=\v!inner, \s!parent=\??margindata] +\setupmargindata [\v!inner] [\c!method=\v!first,\c!location=\v!inner,\c!margin=\v!margin,\c!align=\v!outer, \s!parent=\??margindata] + +% lines + +\definemargindata [\v!inleftmargin] [\v!left ] [\c!margin=\v!margin,\c!width=\leftmarginwidth ,\c!style=,\c!color=] +\definemargindata [\v!inrightmargin] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!style=,\c!color=] +\definemargindata [\v!inoutermargin] [\v!outer] [\c!margin=\v!margin,\c!width=\outermarginwidth,\c!style=,\c!color=] +\definemargindata [\v!ininnermargin] [\v!inner] [\c!margin=\v!margin,\c!width=\innermarginwidth,\c!style=,\c!color=] + +\definemargindata [\v!inleftedge] [\v!left ] [\c!margin=\v!edge ,\c!width=\leftedgewidth ,\c!style=,\c!color=,\c!category=\v!edge] +\definemargindata [\v!inrightedge] [\v!right] [\c!margin=\v!edge ,\c!width=\rightedgewidth ,\c!style=,\c!color=,\c!category=\v!edge] +\definemargindata [\v!inouteredge] [\v!outer] [\c!margin=\v!edge ,\c!width=\outeredgewidth ,\c!style=,\c!color=,\c!category=\v!edge] +\definemargindata [\v!ininneredge] [\v!inner] [\c!margin=\v!edge ,\c!width=\inneredgewidth ,\c!style=,\c!color=,\c!category=\v!edge] + +\definemargindata [\v!atleftmargin] [\v!left ] [\c!margin=\v!normal,\c!width=\leftmarginwidth ,\c!style=,\c!color=] +\definemargindata [\v!atrightmargin] [\v!right] [\c!margin=\v!normal,\c!width=\rightmarginwidth,\c!style=,\c!color=] + +% text: \v!added + +\definemargindata [\v!inleft] [\v!left ] [\c!margin=\v!margin,\c!width=\leftmarginwidth ,\c!align=\v!flushright] +\definemargindata [\v!inright] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!align=\v!flushleft] +\definemargindata [\v!inouter] [\v!outer] [\c!margin=\v!margin,\c!width=\outermarginwidth,\c!align=\v!inner] +\definemargindata [\v!ininner] [\v!inner] [\c!margin=\v!margin,\c!width=\innermarginwidth,\c!align=\v!outer] + +% no longer auto auto-other + +\definemargindata [\v!inmargin] [\v!left] [\c!margin=\v!margin,\c!width=\leftmarginwidth, \c!align=\v!flushright] +\definemargindata [\v!inother] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!align=\v!flushleft] + +\definemargindata [\v!margintext] [\v!left] [\c!margin=\v!margin,\c!width=\leftmarginwidth, \c!align=\v!flushright,\c!stack=\v!yes] + +\setupmarginframed [\v!left ] [\c!method=\v!first,\c!align=\v!flushright,\s!parent=\??marginframed] % we could autoparent when no define yet +\setupmarginframed [\v!right] [\c!method=\v!first,\c!align=\v!flushleft, \s!parent=\??marginframed] +\setupmarginframed [\v!outer] [\c!method=\v!first,\c!align=\v!inner, \s!parent=\??marginframed] +\setupmarginframed [\v!inner] [\c!method=\v!first,\c!align=\v!outer, \s!parent=\??marginframed] + +\definemarginframed [\v!inleft] [\v!left ] +\definemarginframed [\v!inright] [\v!right] +\definemarginframed [\v!inouter] [\v!outer] +\definemarginframed [\v!ininner] [\v!inner] +\definemarginframed [\v!inmargin] [\v!inleft] +\definemarginframed [\v!inother] [\v!inright] + +\aliased\let\marginword \margintext +\aliased\let\margintitle \margintext +\aliased\let\inothermargin\inother % for old times sake + +%definemargindata [inouterextra] [\v!outer] [\c!margin=\v!edge,\c!location=\v!outer,\c!width=\outeredgewidth,\c!align=\v!outer,\c!category=\v!edge] +%definemargindata [ininnerextra] [\v!inner] [\c!margin=\v!edge,\c!location=\v!inner,\c!width=\inneredgewidth,\c!align=\v!inner,\c!category=\v!edge] +% +%definemarginframed [inouterextra] [\v!outer] +%definemarginframed [ininnerextra] [\v!inner] + +%D As we have more control we are not backward compatible although in +%D practice it won't hurt that much. So, from now on use: +%D +%D \starttyping +%D \definemargindata +%D \setupmargindata +%D \definemarginframed +%D \setupmarginframed +%D \stoptyping + +% The following sort of works okay but is to be avoided ... it will disappear from lmtx: + +\permanent\tolerant\protected\def\defineinmargin[#name]#spacer[#location]#spacer[#align]#spacer[#settings]% not completely compatible + {\ifarguments\else + \definemargindata[#name][\c!location=#location,\c!align=#align,#settings]% + \definemarginframed[#name][#location][\c!align=#align,#settings]% + \fi} + +\aliased\let\definemarginline\definemargindata % for old times sake +\aliased\let\setupinmargin \setupmargindata % only partial (no framed), for old times sake + +% begin of experimental code (will move) +% +% \dosetanchor{x}test \dostarthanchoring{x}\llap{crap}\dostophanchoring{x}test test test +% test \dostarthanchoring{text}\llap{crap}\dostophanchoring{text}test test test + +% \def\dosetanchor #1{\dontleavehmode\latelua{anchors.set("#1")}} +% \def\doresetanchor #1{\dontleavehmode\latelua{anchors.reset("#1")}} +% \def\doresetanchornow #1{\directlua{anchors.reset("#1")}} +% \def\dostartanchoring #1{\dontleavehmode\latelua{anchors.startmove("#1")}} +% \def\dostopanchoring #1{\dontleavehmode\latelua{anchors.stopmove("#1")}} +% \def\dostarthanchoring#1{\dontleavehmode\latelua{anchors.startmove("#1","h")}} +% \def\dostartvanchoring#1{\dontleavehmode\latelua{anchors.startmove("#1","v")}} +% \let\dostophanchoring \dostopanchoring +% \let\dostopvanchoring \dostopanchoring + +%D Here because in strc-ren we are too early: + +% % \definemargindata +% % [margintext:chapter] +% % [margintext:section] +% % +% % \defineheadalternative +% % [margintext:chapter] +% % [margintext] +% % [margintext=margintext:chapter] +% % +% % \setuphead +% % [chapter] +% % [alternative=margintext:chapter] +% +% \setuphead +% [chapter] +% [alternative=margintext] + +\definemargindata + [\v!margintext:\v!section] + [\v!left] + [\c!margin=\v!margin, + \c!width=\leftmarginwidth, + \c!align=\v!flushright] + +\defineheadalternative + [\v!margintext] + [\c!alternative=\v!somewhere, + \c!margintext=\v!margintext:\v!section, + \c!renderingsetup=\??headrenderings:\v!margintext] + +\startsetups[\??headrenderings:\v!margintext] + \executeifdefined{\headalternativeparameter\c!margintext}\margintext { + \ifconditional\headshownumber + \headnumbercontent + \hskip\headnumberdistance + \fi + \headtextcontent + } +\stopsetups + +\protect \endinput diff --git a/tex/context/interface/mkii/keys-cs.xml b/tex/context/interface/mkii/keys-cs.xml index f97364024..1a0faa2b5 100644 --- a/tex/context/interface/mkii/keys-cs.xml +++ b/tex/context/interface/mkii/keys-cs.xml @@ -1380,7 +1380,6 @@ <!-- definitions for interface commands for language cs --> <cd:commands> - <cd:command name='CAPPED' value='KAP'/> <cd:command name='Character' value='Znak'/> <cd:command name='Characters' value='Znaky'/> <cd:command name='MONTH' value='MESIC'/> diff --git a/tex/context/interface/mkii/keys-fr.xml b/tex/context/interface/mkii/keys-fr.xml index 74f8d4c99..4be991a8a 100644 --- a/tex/context/interface/mkii/keys-fr.xml +++ b/tex/context/interface/mkii/keys-fr.xml @@ -1380,7 +1380,6 @@ <!-- definitions for interface commands for language fr --> <cd:commands> - <cd:command name='CAPPED' value='CAP'/> <cd:command name='Character' value='Caractere'/> <cd:command name='Characters' value='Caracteres'/> <cd:command name='MONTH' value='MOIS'/> diff --git a/tex/context/interface/mkii/keys-ro.xml b/tex/context/interface/mkii/keys-ro.xml index 0f632ddb0..f27a02302 100644 --- a/tex/context/interface/mkii/keys-ro.xml +++ b/tex/context/interface/mkii/keys-ro.xml @@ -1380,7 +1380,6 @@ <!-- definitions for interface commands for language ro --> <cd:commands> - <cd:command name='CAPPED' value='KAP'/> <cd:command name='Character' value='Litera'/> <cd:command name='Characters' value='Litere'/> <cd:command name='MONTH' value='LUNA'/> diff --git a/tex/context/modules/mkiv/s-system-macros.mkxl b/tex/context/modules/mkiv/s-system-macros.mkxl index 58360b4bf..9ba57882d 100644 --- a/tex/context/modules/mkiv/s-system-macros.mkxl +++ b/tex/context/modules/mkiv/s-system-macros.mkxl @@ -105,7 +105,7 @@ -- local tolerant = v.tolerant and "tolerant" local noaligned = v.noaligned and "noaligned" local instance = v.instance and "instance" - local parameters = v.parameters or 0 + local parameters = v.parameters local dealtwith = mutable or immutable or frozen or permanent or primitive -- beware: we can have combinations local cscommand = gsub(v.cmdname or "","_"," ") local whatever = find(k,"^[a-z][a-z][a-z]+_") @@ -113,7 +113,7 @@ local csname = context.escape(k) ctx_NC() if dealtwith then context("+") elseif whatever then context("-") elseif instance then context("!")end ctx_NC() if primitive then ctx_bold(csname) else context(csname) end - ctx_NC() if parameters > 0 then context(parameters) end + ctx_NC() if parameters then context(parameters > 0 and parameters or "-") end ctx_NC() context(cscommand) -- ctx_NC() if tolerant then context(tolerant) end ctx_NC() if primitive then context(primitive) end diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 7548b39df..55d0f22d6 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 2020-11-15 20:40 +-- merge date : 2020-11-16 19:37 do -- begin closure to overcome local limits and interference |