diff options
| author | Marius <mariausol@gmail.com> | 2011-12-20 00:20:15 +0200 | 
|---|---|---|
| committer | Marius <mariausol@gmail.com> | 2011-12-20 00:20:15 +0200 | 
| commit | e2625b97c862af5ac816883310fdf8c775a3e8f9 (patch) | |
| tree | 56f72011935861b5a074175aa2e60e8c61072662 | |
| parent | 5eff1ba98979f1bdb6558c6f9a32acc4d55a3112 (diff) | |
| download | context-e2625b97c862af5ac816883310fdf8c775a3e8f9.tar.gz | |
beta 2011.12.19 22:53
23 files changed, 1640 insertions, 1412 deletions
| diff --git a/tex/context/base/anch-bck.mkvi b/tex/context/base/anch-bck.mkvi new file mode 100644 index 000000000..75a7f05a5 --- /dev/null +++ b/tex/context/base/anch-bck.mkvi @@ -0,0 +1,684 @@ +%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 +%D that use attributes although not too much is to be expected, +%D apart from better anchoring. In fact better anchoring can be +%D 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\backgrounds_text_n + +\def\v_backgrounds_text_current    {pbg:0} +\def\v_backgrounds_text_next       {pbg:1} + +\def\v_backgrounds_anchor_current_b{b:\v_backgrounds_text_current} +\def\v_backgrounds_anchor_current_e{e:\v_backgrounds_text_current} + +\def\v_backgrounds_anchor_next_b   {b:\v_backgrounds_text_next} +\def\v_backgrounds_anchor_next_e   {e:\v_backgrounds_text_next} + +\def\backgrounds_text_initialize_next +  {\global\advance\backgrounds_text_n\plusone +   \edef\v_backgrounds_text_current{pbg:\number\backgrounds_text_n}% +   \xdef\v_backgrounds_text_next   {pbg:\number\numexpr\backgrounds_text_n+\plusone\relax}} % x ? + +% todo : \synchonizepositionpage{b:\v_backgrounds_text_current}{s:\v_backgrounds_text_current}% + +\ifdefined\totalnoftextbackgrounds +    % set in tuc +\else +    \newcounter\totalnoftextbackgrounds +\fi + +\appendtoks +    \savecurrentvalue\totalnoftextbackgrounds{\number\backgrounds_text_n}% +\to \everybye + +% actually we can just ask lua to give us the nofpositions (or a least n<>0) + +\def\backgrounds_text_initialize +  {\ifcase\totalnoftextbackgrounds\else +     \enableparpositions +   \fi} + +\appendtoks +    % a position can be mid paragraph in which case we're behind +    % this will change when we move positions to lua +    \backgrounds_text_initialize +\to \everystarttext + +%D Some MP + +\newcount\localpositionnumber % incremented elsewhere + +\newcount\MPparcounter + +\def\MPself        {\MPvar{self}} +\def\MPbself       {b:\MPvar{self}} +\def\MPeself       {e:\MPvar{self}} +\def\MPwself       {w:\MPvar{self}} +\def\MPparanchor   {p:\number\MPparcounter} +\def\MPl       #tag{\MPplus{#tag}20} % slot 2 default 0 +\def\MPr       #tag{\MPplus{#tag}30} % slot 3 default 0 + +\def\textbackgroundoverlay#tag{\iflocalpositioning\v!local\else\v!text\fi#tag} +\def\MPanchornumber           {\iflocalpositioning\the\localpositionnumber\else\the\realpageno\fi} + +% \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_backgrounds_text_level + +\installcommandhandler \??td {textbackground} \??td + +\appendtoks +    \setuevalue{\currenttextbackground}{\groupedcommand{\starttextbackground[\currenttextbackground]}{\stoptextbackground}}% +    \setuevalue{\e!start\currenttextbackground}{\starttextbackground[\currenttextbackground]}% +    \setuevalue{\e!stop \currenttextbackground}{\stoptextbackground}% +    \doif{\textbackgroundparameter\c!state}\v!start\checktextbackgrounds +\to \everydefinetextbackground + +\appendtoks +    \doif{\textbackgroundparameter\c!state}\v!start\checktextbackgrounds +\to \everysetuptextbackground + +\unexpanded\def\starttextbackground +  {\begingroup +   \advance\c_backgrounds_text_level\plusone +   \dodoubleempty\backgrounds_text_start} + +\def\backgrounds_text_start[#tag][#settings]% +  {\checktextbackgrounds +   \def\currenttextbackground{#tag}% +   \backgrounds_text_initialize_next +   \ifsecondargument +     \setupcurrenttextbackground[#settings]% +   \fi +   \doifelse{\textbackgroundparameter\c!state}\v!start +     \backgrounds_text_preset_yes +     \backgrounds_text_preset_nop +   \backgrounds_text_start_indeed} + +% todo \backgroundvariable\c!variant + +\let\backgrounds_text_start_indeed\relax +\let\backgrounds_text_stop_indeed \relax + +\setvalue{\??td:l:\v!text}% +  {\let\backgrounds_text_start_indeed\backgrounds_text_start_txt +   \let\backgrounds_text_stop_indeed \dostoptextbackgroundtxt} + +\setvalue{\??td:l:\v!paragraph}% +  {\ifnum\c_backgrounds_text_level>\plusone +     \let\backgrounds_text_start_indeed\backgrounds_text_start_txt +     \let\backgrounds_text_stop_indeed \dostoptextbackgroundtxt +   \else +     \let\backgrounds_text_start_indeed\backgrounds_text_start_par +     \let\backgrounds_text_stop_indeed \dostoptextbackgroundpar +   \fi} + +\setvalue{\??td:l:\v!none}% +  {\backgrounds_text_preset_nop} + +\def\backgrounds_text_preset_nop +  {\let\backgrounds_text_start_indeed\relax +   \let\backgrounds_text_stop_indeed \relax} + +\def\backgrounds_text_preset_yes +  {\backgrounds_text_preset_nop +   \csname\??td:l:\textbackgroundparameter\c!location\endcsname +   \edef\m_backgrounds_text_frame     {\textbackgroundparameter\c!frame}% +   \edef\m_backgrounds_text_corner    {\textbackgroundparameter\c!corner}% +   \edef\m_backgrounds_text_background{\textbackgroundparameter\c!background}% +   \ifx\m_backgrounds_text_frame\v!on +     \ifx\m_backgrounds_text_corner\v!round +       \let\m_backgrounds_text_frame\!!plustwo +     \else +       \let\m_backgrounds_text_frame\!!plusone +     \fi +   \else +     \let\m_backgrounds_text_frame\!!zerocount +   \fi +   \ifx\m_backgrounds_text_background\v!color +     \let\m_backgrounds_text_background\!!plusone +   \else +     \let\m_backgrounds_text_background\!!zerocount +   \fi +   \startpositionoverlay{\textbackgroundoverlay{\textbackgroundparameter\c!level}}% +     \backgrounds_text_mp_graphic % gets expanded directly +   \stoppositionoverlay} + +\def\backgrounds_text_mp_graphic +  {\normalexpanded +     {\setMPpositiongraphicrange % needs to be optimized +        {\v_backgrounds_anchor_current_b}% +        {\v_backgrounds_anchor_current_e}% +        {\textbackgroundparameter\c!method}% +        {self=\v_backgrounds_text_current, +         mp=\textbackgroundparameter\c!mp, +         gridtype=\textbackgroundparameter\c!alternative, +         filltype=\m_backgrounds_text_background, +         linetype=\m_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}}} + +\unexpanded\def\stoptextbackground +  {\backgrounds_text_stop_indeed +   \carryoverpar\endgroup} + +\unexpanded\def\starttextbackgroundmanual +  {\begingroup +   \usetextbackgroundstyleandcolor\c!style\c!color +   \fpos\v_backgrounds_text_current\ignorespaces} + +\unexpanded\def\stoptextbackgroundmanual +  {\tpos\v_backgrounds_text_current +   \endgroup} + +\def\backgrounds_text_start_txt +  {\ifvmode \dontleavehmode \fi +   \begingroup +   \usetextbackgroundstyleandcolor\c!style\c!color +   \fpos\v_backgrounds_text_current\ignorespaces} + +\def\dostoptextbackgroundtxt +  {\tpos\v_backgrounds_text_current +   \endgroup} + +\newskip\textbackgroundskip + +\def\backgrounds_text_start_par +  {\endgraf % new +   \textbackgroundparameter\c!before +   \begingroup +   \begingroup +   \resetallattributes % \attribute\linenumberattribute \attributeunsetvalue +   \noindent +   \ifgridsnapping +     \doassignsomeskip\textbackgroundparameter\c!topoffset\to\textbackgroundskip +     \ifdim\textbackgroundskip>\zeropoint +       \struttedbox{\hbox{\raise\textbackgroundskip\hbox{\fpos\v_backgrounds_text_current}}}% +     \else +      \fpos\v_backgrounds_text_current +     \fi +   \else +     \fpos\v_backgrounds_text_current +   \fi +   \endgraf % we need a vertical nobreak - 29/06/2004 +   \endgroup +   \nobreak +   \vskip-\lineheight +   \nobreak +   \ifgridsnapping \else +     \doassignsomeskip\textbackgroundparameter\c!topoffset\to\textbackgroundskip +     \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 +   \nobreak % new per 23/04/2006 (else potential break when whitespace) +   \seteffectivehsize +   \doinhibitblank %   \blank[\v!disable]% new +   \par} + +\def\dostoptextbackgroundpar +  {\par +   \removelastskip % new +   \doassignsomeskip\textbackgroundparameter\c!bottomoffset\to\textbackgroundskip +   \ifdim\lastskip>\zeropoint +     \advance\textbackgroundskip-\lastskip +   \fi +   \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint +     \kern\textbackgroundskip\nobreak +   \fi \fi +   \nobreak +   \vskip-\dimexpr\lineheight+\parskip\relax +   \nobreak +   \endgroup +   \begingroup +   \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM +   \resetallattributes % \attribute\linenumberattribute \attributeunsetvalue +   \nobreak \noindent \strut \hfill \kern\zeropoint +   \doassignsomeskip\textbackgroundparameter\c!bottomoffset\to\textbackgroundskip +   \ifgridsnapping % experimental, pascal (todo: topoffset in same way) +     \ifdim\textbackgroundskip>\zeropoint +       \struttedbox\plusone{\hbox{\lower\textbackgroundskip\hbox{\tpos\v_backgrounds_text_current}}}% +     \else +       \tpos\v_backgrounds_text_current +     \fi +   \else +     \tpos\v_backgrounds_text_current +   \fi +   \endgraf +   \endgroup +   \endgraf % new +   \textbackgroundparameter\c!after} + +\newcount\backgrounds_text_par_pages +\newdimen\backgrounds_text_par_height +\newdimen\backgrounds_text_par_width + +\def\calculatetextpardimensions +  {\docalculatetextpardimensions\v_backgrounds_anchor_current_b\v_backgrounds_anchor_current_e\MPparanchor} + +\def\calculatenexttextpardimensions +  {\docalculatetextpardimensions\v_backgrounds_anchor_next_b\v_backgrounds_anchor_next_e\relax} + +\def\docalculatetextpardimensions#begin#end#par% +  {\backgrounds_text_par_pages\numexpr +      \MPp#end-\MPp#begin% +   \relax +   \backgrounds_text_par_height\dimexpr +     \ifcase\backgrounds_text_par_pages +       % one page +       \MPy#begin-\MPy#end% +     \else +       % two or more pages +       \ifnum\backgrounds_text_par_pages>\plustwo +         \ifnum\backgrounds_text_par_pages<\plusfive +           % more pages +           \textheight*\numexpr\backgrounds_text_par_pages+\minusone +         \else +           % keep'm small +           \plusfive\textheight % weird value +         \fi +       \else +         \MPy#begin-\MPy#end-\MPy\textanchor+\MPy\textanchor+\MPh\textanchor +       \fi +     \fi +   \relax +   \backgrounds_text_par_width\dimexpr +     \ifcase\backgrounds_text_par_pages +       % one page +       \MPx#end-\MPx#begin% +     \else +       % two or more pages / maybe also hang +       \ifx#par\relax +         \makeupwidth % \textwidth +       \else +         \MPw\MPparanchor-\MPl\MPparanchor-\MPr\MPparanchor +       \fi +     \fi +   \relax} + +\def\mintextparheight{4\lineheight} + +\def\dontsplitnexttextbackground % dangerous but useful +  {\ifdim\pagetotal>\textheight \else +     \ifdim\pagegoal=\maxdimen \else +      \calculatenexttextpardimensions +      % too tricky +      % \scratchdimen=\backgrounds_text_par_height +      % \advance\scratchdimen\pagetotal\relax +      % \ifdim\scratchdimen>\pagegoal +      % \page +      % \fi +      \ifdim\backgrounds_text_par_height>\zeropoint +        \ifdim\backgrounds_text_par_height>\mintextparheight\else +          \page % option +        \fi +      \fi +    \fi +   \fi} + +\def\checktextbackgrounds +  {\ifproductionrun +     \enabletextarearegistration +     \enablehiddenbackground +   \fi} + +\setuptextbackground +  [\c!mp=mpos:par:columnset,      % buggy: mpos:par:shape +   \c!method=mpos:par:columnset, % +   \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!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!rulethickness=\linewidth] + +%D The \METAPOST\ connection: + +%D Some of these macros are pretty clever but too complicated +%D to be nice. When things are kind of stable I'll clean up +%D this mess. + +\setupMPvariables +  [mpos:box] +  [linecolor=blue, +   linewidth=\linewidth, +   fillcolor=lightgray, +   filloffset=\!!zeropoint] + +\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth} +    initialize_box(\MPpos{\MPvar{self}}) ; +    def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; +    def boxlineoptions = withcolor \MPvar{linecolor} enddef ; +    boxlinewidth  := \MPvar{linewidth} ; +    boxfilloffset := \MPvar{filloffset} ; +    draw_box ; +    anchor_box(\MPanchor{\MPvar{self}}) ; +\stopMPpositiongraphic + +\setupMPvariables +  [mpos:area] +  [linecolor=blue, +   linewidth=\linewidth, +   fillcolor=lightgray, +   filloffset=\!!zeropoint] + +\startMPpositiongraphic{mpos:area}{fillcolor,linecolor,linewidth} +    initialize_area(\MPpos{b:\MPvar{self}},\MPpos{e:\MPvar{self}}) ; +    def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; +    def boxlineoptions = withcolor \MPvar{linecolor} enddef ; +    boxlinewidth  := \MPvar{linewidth} ; +    boxfilloffset := \MPvar{filloffset} ; +    draw_area ; +    anchor_area(\MPanchor{b:\MPvar{self}}) ; +\stopMPpositiongraphic + +% gridtype = 1 => baseline +% gridtype = 2 => betweenline + +\setupMPvariables +  [mpos:par] +  [mp=mpos:par:shape, +   gridtype=0, +   linetype=1, +   filltype=1, +   dashtype=0, % 1 = dashed, 2 = dashed with background +  %snaptops=true, % not that nice: true/false +   gridcolor=red, +   linecolor=blue, +   fillcolor=lightgray, +   filloffset=\!!zeropoint, +   linewidth=\linewidth, +   gridwidth=\linewidth, +   gridshift=\!!zeropoint, +   lineradius=.5\bodyfontsize, +   dashtype=1] + +\startuseMPgraphic{mpos:par:shape} +    \iftracepositions show_par \else draw_par \fi ; +\stopuseMPgraphic + +\startuseMPgraphic{mpos:par:setup} +    boxgridtype   := \MPvar{gridtype} ; +    boxlinetype   := \MPvar{linetype} ; +    boxfilltype   := \MPvar{filltype} ; +    boxdashtype   := \MPvar{dashtype} ; +    def boxgridoptions = withcolor \MPvar{gridcolor} enddef ; +    def boxlineoptions = withcolor \MPvar{linecolor} enddef ; +    def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; +    boxfilloffset := \MPvar{filloffset} ; +    boxlinewidth  := \MPvar{linewidth} ; +    boxgridwidth  := \MPvar{gridwidth} ; +    boxgridshift  := \MPvar{gridshift} ; +    boxlineradius := \MPvar{lineradius} ; +    %snap_multi_par_tops := \MPvar{snaptops} ; +\stopuseMPgraphic + +\startuseMPgraphic{mpos:par:extra} +    % user stuff, like: +    % snap_multi_par_tops := false ; +\stopuseMPgraphic + +\startMPpositionmethod{mpos:par} %%%%%%%%%%% will become obsolete +    \MPparcounter\MPv\MPbself{1}\zerocount\relax +    \directsetup{mpos:par:variant:\doifpositionelse\MPwself{w}{b}} +    \MPpositiongraphic{mpos:par}{}% +\stopMPpositionmethod + +\startsetups mpos:par:variant:w +    \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} +        initialize_area_par(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself) ; +        \includeMPgraphic{mpos:par:setup} ; +        \includeMPgraphic{mpos:par:extra} ; +        \includeMPgraphic{\MPvar{mp}} ; +        anchor_par(\MPanchor\MPbself) ; +    \stopMPpositiongraphic +\stopsetups + +\startsetups mpos:par:variant:b +    \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} +        initialize_par(\MPpos\MPbself,\MPpos\MPeself,\MPpos\textanchor,\MPpos\MPparanchor,\MPvv\MPparanchor{0pt,0pt,0pt,0pt,0,0pt}) ; +        \includeMPgraphic{mpos:par:setup} ; +        \includeMPgraphic{mpos:par:extra} ; +        \includeMPgraphic{\MPvar{mp}} ; +        anchor_par(\MPanchor\MPbself) ; +    \stopMPpositiongraphic +\stopsetups + +%D The next alternative works in columnsets : + +\startuseMPgraphic{mpos:par:columnset} +    \iftracepositions show_multi_pars \else draw_multi_pars \fi ; +\stopuseMPgraphic + +\startuseMPgraphic{mpos:par:sideline}{linecolor,lineoffset,linewidth} +    begingroup ; save p ; picture p ; +    for i=1 upto nofmultipars : +        p := image ( fill leftboundary multipars[i] +            shifted (-\MPvar{lineoffset},0) +            rightenlarged \MPvar{linewidth} withcolor \MPvar{linecolor} ; +        ) ; +        setbounds p to multipars[i] ; +        draw p ; +    endfor ; +    endgroup ; +\stopuseMPgraphic + +\startMPpositionmethod{mpos:par:columnset} +    \MPparcounter\MPv\MPbself{1}\zerocount\relax +    \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} +        \includeMPgraphic{mpos:par:setup} ; +        \includeMPgraphic{mpos:par:extra} ; +        prepare_multi_pars(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself,\MPpos\MPparanchor,\MPvv\MPparanchor{0pt,0pt,0pt,0pt,0,0pt}) ; +        relocate_multipars(-\MPxy\MPanchorid) ; % inside layerpos +        \includeMPgraphic{\MPvar{mp}} ; +    \stopMPpositiongraphic +    \MPpositiongraphic{mpos:par}{}% +\stopMPpositionmethod + +%D \starttyping +%D \setupbackground +%D   [test] +%D   [mp=mpos:par:columnset, +%D    method=mpos:par:columnset] +%D \stoptyping + +%D We need to treat floats in a special way. + +\startMPinitializations +    local_multi_par_area:=\iflocalpositioning true\else false\fi; +\stopMPinitializations + +%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 \letvalue\v!grid=\basegrid \fi + +%D Whatever + +\setupMPvariables +  [mpos:connect] +  [linecolor=red, +   linewidth=1pt] + +\setupMPvariables +  [mpos:encircle] +  [fillcolor=lightgray, +   filloffset=\!!zeropoint, +   linecolor=blue, +   linewidth=1pt] + +% these might become macros in mp-page + +\startuseMPgraphic{mpos:common:ec} +    path pa ; pair ca ; numeric lw ; +    lw := \MPvar{linewidth} ; +    initialize_box(\MPpos{\MPvar{self}}) ; +    pa := pxy ; ca := cxy ; pa := boundingbox pa enlarged 2lw ; +    pa := llcorner pa ... lrcorner pa ... urcorner pa ... ulcorner pa ... cycle ; +    drawoptions (withpen pencircle scaled lw withcolor \MPvar{linecolor}) ; +\stopuseMPgraphic + +\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth} +    \includeMPgraphic{mpos:common:ec} +    fill pa withcolor \MPvar{fillcolor} ; draw pa ; +    anchor_box(\MPanchor{\MPvar{self}}) ; +\stopMPpositiongraphic + +\startMPpositiongraphic{mpos:connect}{linecolor,linewidth} +    path pb, pc ; pair cb, cc ; +    \includeMPgraphic{mpos:common:ec} +    initialize_box(\MPpos{\MPvar{to}}) ; +    pb := pxy ; cb := cxy ; pb := boundingbox pb enlarged 2lw ; +    pb := llcorner pb...lrcorner pb...urcorner pb...ulcorner pb...cycle ; +    pc := ca {up} .. {down} cb ; +    cc := (pc intersection_point pa) ; +    if intersection_found : +        pc := pc cutbefore cc ; +        cc := (pc intersection_point pb) ; +        if intersection_found : +            pc := pc cutafter cc ; +            drawarrow pc ; drawarrow reverse pc ; +        fi ; +    fi ; +    anchor_box(\MPanchor{\MPvar{self}}) ; +\stopMPpositiongraphic + +\protect \endinput + +% todo 1: shift down option + +% \startuseMPgraphic{mpos:par:columnset} +%   \iftracepositions show_multi_pars \else draw_multi_pars \fi ; +%   path p ; p := boundingbox currentpicture ; +%   currentpicture := currentpicture shifted (0,-StrutDepth/2) ; +%   setbounds currentpicture to p ; +% \stopuseMPgraphic + +\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:par: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 +\stoptext diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index 4a9bf6ee3..8d5b87893 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -13,96 +13,198 @@  \writestatus{loading}{ConTeXt Anchoring Macros / Grapics} -%D We can use the commandhandler here. -  %D Before we come to graphics support, we have to make sure of -%D the reference point on the page. The next macro does so and -%D is hooked into the page building routine. +%D the reference point on the page. The next macros do so and +%D are hooked into the page building routine. -%D I will speed up this module when I have a proper torture -%D test file. +\unprotect -%D This module will be adapted to \MKIV\ and we will have a -%D more direct processing in a pre-shipout phase. +%D Here we implement position actions (was a dummy). -\unprotect +\unexpanded\def\showanchor#1% +  {\normalexpanded{\writestatus{#1} +     {\MPp{#1}\string|\MPx{#1}\string|\MPy{#1}\string|\MPw{#1}\string|\MPh{#1}\string|\MPd{#1}}}} -% in the future, the depth of tail will reflect page depth +%D A few more low level macros take care of defining and +%D recalling actions. We could save this information in the +%D position containers themselves, this would save hash +%D entries, but at the cost of much more time consuming +%D expansion. Actions are saved globally! +%D +%D The lists can become quite long (also because there can +%D be lots of parameters passed on) so we provide a hook +%D to clean up the list afterwards. -\ifx\textheight\undefined \def\textheight{\vsize} \fi +\newtoks\everypositionaction +\newtoks\everyinsertpositionaction +\newtoks\everycleanpositionaction -%D The next macros so some housekeeping. +\let\POSactionprefix\POSprefix -\def\pageanchor{page:0} % for the moment only one pagesize -\def\textanchor{text:\the\realpageno} -\def\headanchor{head:\the\realpageno} % virtual position -\def\tailanchor{tail:\the\realpageno} % virtual position +\unexpanded\def\dosetpositionaction#1% +  {\setgvalue{\POSactionprefix#1::}} + +\def\doifpositionaction#1% +  {\ifcsname\POSactionprefix#1::\endcsname +     \expandafter\firstofoneargument +   \else +     \expandafter\gobbleoneargument +   \fi} + +\def\doifpositionactionelse#1% +  {\ifcsname\POSactionprefix#1::\endcsname +     \expandafter\firstoftwoarguments +   \else +     \expandafter\secondoftwoarguments +   \fi} + +\def\dopositionaction#1% test saves hash entry in etex +  {\ifcsname\POSactionprefix#1::\endcsname +     \positions_action_indeed{#1}% +   \fi} + +\def\positions_action_indeed#1% +  {\ifcase\MPp{#1}\relax +     \traceposstring\clap\cyan{<#1>}% shouldn't happen too often +   \else +     \begingroup +     \setbox\scratchbox\hbox +       {\traceposstring\clap\red{<#1>}% +        \the\everyinsertpositionaction +        \the\everypositionaction +        \csname\POSactionprefix#1::\endcsname +        \positions_cleanup_action{#1}}% +     \smashedbox\scratchbox % smashing is really needed else we get problems with too big overlays +     \endgroup +   \fi} + +%D Here the complication has to do with collecting actions +%D for later execution. This collection is especially handy +%D when we want to move actions to a specific layer. +%D Such series of actions are stored in a macro (the one +%D with the funny \type {++}) which is cleaned up after each +%D invocation. + +% this can probably be done better -%D Anchors: +% \def\positions_cleanup_action#1% not in trialtypesetting +%   {\ifcsname\POSactionprefix#1++\endcsname +%      \the\everycleanpositionaction +%      \iflocalpositioning +%        \letgvalue{\POSactionprefix#1++}\empty +%      \else +%        \setxvalue{\POSactionprefix#1++}{\getvalue{\POSactionprefix#1++}}% +%      \fi +%    \fi} + +\def\positions_cleanup_action#1% not in trialtypesetting +  {\ifcsname\POSactionprefix#1++\endcsname +     \the\everycleanpositionaction +     \iflocalpositioning +       % erase +       \expandafter\let\csname\POSactionprefix#1++\endcsname\empty +     \else +       % globalize +       \global\expandafter\let\csname\POSactionprefix#1++\expandafter\endcsname\csname\POSactionprefix#1++\endcsname +     \fi +   \fi} -\def\dopresetpositionanchors % also mkii +\def\handlepositionaction#1\with#2\on#3% ugly    {\begingroup -   \!!dimena\ifdim\topskip>\strutht\topskip\else\strutht\fi -   \!!dimenb\dimexpr\MPy\textanchor+\MPh\textanchor-\!!dimena\relax -   \!!dimenc\dimexpr\MPy\textanchor+\strutdp\relax -   \!!dimend\MPx\textanchor -   \!!dimene\MPw\textanchor -   \replacepospxywhd\headanchor\realfolio\!!dimend\!!dimenb\!!dimene\!!dimena\strutdp -   \replacepospxywhd\tailanchor\realfolio\!!dimend\!!dimenc\!!dimene\strutht \strutdp +   \edef\!!stringa{\ifx\currentpositionoverlay\empty#3\else\currentpositionoverlay::\MPanchoridentifier\fi}% +   \edef\!!stringc{\POSactionprefix\!!stringa++}% +   \normalexpanded{\dosetpositionaction{\!!stringa}{\noexpand\getvalue{\!!stringc}}}% +   \global\let#1\relax +   \edef\!!stringb{\ifcsname\!!stringc\endcsname\csname\!!stringc\endcsname\fi}% why ... +   \setxvalue\!!stringc{\!!stringb#1#2}%     \endgroup} -\def\presetpositionanchors% compatibility hack (still needed?) -  {\ifpositioning -     \dopresetpositionanchors -   \fi} +%D The next macros do some housekeeping. + +\def\pageanchor{page:0} % for the moment only one pagesize +\def\textanchor{text:\the\realpageno}  %D The first version of this module implemented head and tail  %D anchors. Currently we stick to just one anchor and derive -%D the head and tail anchors from this one. - -\def\showanchor#1% -  {\expanded{\writestatus{#1} -     {\MPp{#1}\string|\MPx{#1}\string|\MPy{#1}\string|% -      \MPw{#1}\string|\MPh{#1}\string|\MPd{#1}}}} +%D the head and tail anchors from this one. We set these +%D anchors before and after each page. -%D We set these anchors before and after each page. - -\appendtoks \presetpositionanchors \to \beforeeverypage -\appendtoks \presetpositionanchors \to \aftereverypage +% FOR THE MOMENT DISABLED (was downward compatibity issue) +% +% \def\headanchor{head:\the\realpageno} % virtual position +% \def\tailanchor{tail:\the\realpageno} % virtual position +% +% \def\presetpositionanchors % is this still needed? +%   {\ifpositioning +%      \positions_preset_anchors +%    \fi} +% +% \def\positions_preset_anchors +%   {\begingroup +%    \!!dimena\ifdim\topskip>\strutht\topskip\else\strutht\fi +%    \!!dimenb\dimexpr\MPy\textanchor+\MPh\textanchor-\!!dimena\relax +%    \!!dimenc\dimexpr\MPy\textanchor+\strutdp\relax +%    \!!dimend\MPx\textanchor +%    \!!dimene\MPw\textanchor +%    \replacepospxywhd\headanchor\realfolio\!!dimend\!!dimenb\!!dimene\!!dimena\strutdp +%    \replacepospxywhd\tailanchor\realfolio\!!dimend\!!dimenc\!!dimene\strutht \strutdp +%    \endgroup} +% +% \appendtoks \presetpositionanchors \to \beforeeverypage +% \appendtoks \presetpositionanchors \to \aftereverypage  % todo: change with each page size change .. can be made more efficient  % as some values are the same .. this one can (at some point) be used  % to provide correction for imposition -\def\doregisterpageposition#1% -  {\setbox#1\hbox{\hpos\pageanchor{\box#1}}} - -\def\registerpageposition#1% this one is flushed first ! ... can't we avoid this one +\unexpanded\def\positions_register_page#1% this one is flushed first ! ... can't we avoid this one    {\ifpositioning\ifcase\realpageno\or       \ifdim\printpaperheight=\paperheight         \ifdim\printpaperwidth=\paperwidth           % not needed,         \else -         \doregisterpageposition{#1}% +         \positions_register_page_indeed{#1}%         \fi       \else -       \doregisterpageposition{#1}% +       \positions_register_page_indeed{#1}%       \fi     \fi\fi} -\unexpanded\def\placepositionanchors % todo : depth pagebox +\def\positions_register_page_indeed#1% +  {\setbox#1\hbox{\hpos\pageanchor{\box#1}}} + +\unexpanded\def\positions_place_anchors    {\ifpositioning -     \setbox\scratchbox\vbox to \textheight -       {\simpletopskipcorrection -        \hbox{\strut\dopositionaction\headanchor}% -        \vfill -        \hbox{\strut\dopositionaction\tailanchor}}% -     \dp\scratchbox\zeropoint -     \wd\scratchbox\makeupwidth % not \zeropoint, else wrong text backgrounds -     \hpos\textanchor{\box\scratchbox}% +     \positions_place_anchors_yes     \else -     \vskip\textheight +     \positions_place_anchors_nop     \fi} + +% FOR THE MOMENT DISABLED +% +% \def\positions_place_anchors_yes % todo : depth pagebox +%   {\begingroup +%    \setbox\scratchbox\vbox to \textheight +%      {\simpletopskipcorrection +%       \hbox{\strut\dopositionaction\headanchor}%  ! actions on a virtual position +%       \vfill +%       \hbox{\strut\dopositionaction\tailanchor}}% ! actions on a virtual position +%    \dp\scratchbox\zeropoint +%    \wd\scratchbox\makeupwidth % not \zeropoint, else wrong text backgrounds +%    \hpos\textanchor{\box\scratchbox}% +%    \endgroup} + +\def\positions_place_anchors_yes % todo : depth pagebox +  {\begingroup +   \setbox\scratchbox\emptyvbox +   \ht\scratchbox\textheight +   \dp\scratchbox\zeropoint +   \wd\scratchbox\makeupwidth +   \hpos\textanchor{\box\scratchbox}% +   \endgroup} + +\def\positions_place_anchors_nop +  {\vskip\textheight}  %D \macros  %D   {positionoverlay,startpositionoverlay} @@ -169,81 +271,78 @@  \def\positionoverlay  % the test prevents too many redundant positions    {\ifpositioning     % in (not used) text* position layers -     \expandafter\positionoverlayindeed +     \expandafter\positions_overlay_indeed     \else % also \iftrialtypesetting test here?       \expandafter\gobbleoneargument     \fi} -\def\positionoverlayindeed#1% the test prevents too many redundant positions +% keep this for a while +% +% \def\positions_overlay_indeed#1% the test prevents too many redundant positions +%   {\vbox to \overlayheight +%      {\doifpositionactionelse{#1::\MPanchoridentifier}% +%         {\edef\MPanchorid{#1::\MPanchoridentifier:\MPanchornumber}% +%          \edef\MPanchor##1{\MPpos{\MPanchorid}}% +%          \the\everyinsertpositionaction +%          \copyposition{#1::\MPanchoridentifier}{#1::\MPanchoridentifier:\MPanchornumber}% +%          \hpos +%            {#1::\MPanchoridentifier:\MPanchornumber}% +%           % this is ok +%           %{\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}}% +%           % but this one prevents cyclic runs due to +%           % rounding errors +%            {\setbox\scratchbox\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}% +%             \ht\scratchbox\overlayheight +%             \dp\scratchbox\zeropoint +%             \box\scratchbox}}% +%         {\hbox to \overlaywidth{\hss}}% +%       \vfill}} + +\def\positions_overlay_indeed#1% +  {\doifpositionactionelse{#1::\MPanchoridentifier}% +     \positions_overlay_yes\positions_overlay_nop{#1}} + +\def\positions_overlay_yes#1%    {\vbox to \overlayheight -     {\doifpositionactionelse{#1::\MPanchoridentifier}% -        {\edef\MPanchorid{#1::\MPanchoridentifier:\MPanchornumber}% -         \edef\MPanchor##1{\MPpos{\MPanchorid}}% -         \the\everyinsertpositionaction -         \copyposition{#1::\MPanchoridentifier}{#1::\MPanchoridentifier:\MPanchornumber}% -         \hpos -           {#1::\MPanchoridentifier:\MPanchornumber}% -          % this is ok -          %{\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}}% -          % but this one prevents cyclic runs due to -          % rounding errors -           {\setbox\scratchbox\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}% -            \ht\scratchbox\overlayheight -            \dp\scratchbox\zeropoint -            \box\scratchbox}}% -        {\hbox to \overlaywidth{\hss}}% +     {\edef\MPanchorid{#1::\MPanchoridentifier:\MPanchornumber}% +      \edef\MPanchor##1{\MPpos\MPanchorid}% +      \the\everyinsertpositionaction +      \copyposition{#1::\MPanchoridentifier}\MPanchorid +      \hpos \MPanchorid +       %{\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}}% oscillation due to rounding issues +        {\setbox\scratchbox\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}% +         \ht\scratchbox\overlayheight +         \dp\scratchbox\zeropoint +         \box\scratchbox}%        \vfill}} -\unexpanded\def\startpositionoverlay#1% -  {\iftrialtypesetting % we don't want redundant entries in the list -     \@EA\gobbleuntil\@EA\stoppositionoverlay +% \def\\positions_overlay_nop#1% +%   {\setbox\scratchbox\emptyvbox +%    \ht\scratchbox\overlayheight +%    \wd\scratchbox\overlaywidth +%    \box\scratchbox} + +\let\positions_overlay_nop\gobbleoneargument + +\unexpanded\def\startpositionoverlay +  {\iftrialtypesetting +     \expandafter\positions_overlay_start_nop     \else -     \def\currentpositionoverlay{#1}% +     \expandafter\positions_overlay_start_yes     \fi} +\def\positions_overlay_start_nop#1\stoppositionoverlay +  {} + +\def\positions_overlay_start_yes#1% +  {\def\currentpositionoverlay{#1}} +  \unexpanded\def\stoppositionoverlay    {\let\currentpositionoverlay\empty}  \def\resetpositionoverlay#1%    {\dosetpositionaction{#1::\MPanchoridentifier::}{}} -%D Here the complication has to do with collecting actions -%D for later execution. This collection is especially handy -%D when we want to move actions to a specific layer. -%D Such series of actions are stored in a macro (the one -%D with the funny \type {++}) which is cleaned up after each -%D invocation. - -\newtoks\everycleanpositionaction -\newtoks\everyinsertpositionaction - -\def\cleanuppositionaction#1% not in trialtypesetting -  {\ifcsname\POSactionprefix#1++\endcsname -     \the\everycleanpositionaction -     \iflocalpositioning -       \letgvalue{\POSactionprefix#1++}\empty -     \else -       \setxvalue{\POSactionprefix#1++}{\getvalue{\POSactionprefix#1++}}% -     \fi -   \fi} - -\def\handlepositionaction#1\with#2\on#3% -  {\bgroup -   \ifx\currentpositionoverlay\empty -     \edef\!!stringa{#3}% no layer, just pos itself as anchor -   \else -     \edef\!!stringa{\currentpositionoverlay::\MPanchoridentifier}% -   \fi -   \edef\!!stringc{\POSactionprefix\!!stringa++}% -   \expanded{\dosetpositionaction{\!!stringa}{\noexpand\getvalue{\!!stringc}}}% -   \global\let#1\relax -   \edef\!!stringb{\executeifdefined\!!stringc\empty}% -   \setxvalue\!!stringc{\!!stringb#1#2}% -   \egroup} - -%D The indirectness enables us redefine macros for special -%D purposes, like a cleanup. -  \def\handlepositionboxes#1#2#3%    {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}} @@ -272,74 +371,81 @@  \newbox\positiongraphicbox  \def\startMPpositiongraphic % id setups -  {\dodoublegroupempty\dostartMPpositiongraphic} +  {\dodoublegroupempty\positions_mp_graphic_start} -\long\def\dostartMPpositiongraphic#1#2#3\stopMPpositiongraphic -  {\long\setgvalue{MPG:#1}% tag list mpcode -     {\useMPpositiongraphic{#1}{#2}{#3}}} +\def\positions_mp_graphic_start#1#2#3\stopMPpositiongraphic % tag list mpcode +  {\setgvalue{MPG:#1}{\positions_mp_graphic_use{#1}{#2}{#3}}}  \let\stopMPpositiongraphic\relax -\def\prepareMPpositionvariables -  {\ifcsname\@@meta self\endcsname\else\setvalue{\@@meta self}{\currentposition}\fi -   \ifcsname\@@meta from\endcsname\else\setvalue{\@@meta from}{\currentposition}\fi} +\def\positions_mp_graphic_prepare +  {\ifcsname\@@meta self\endcsname\else\letvalue{\@@meta self}\currentposition\fi +   \ifcsname\@@meta from\endcsname\else\letvalue{\@@meta from}\currentposition\fi} -\long\def\useMPpositiongraphic#1#2#3% -  {\bgroup +\def\positions_mp_graphic_use#1#2#3% +  {\begingroup     \prepareMPvariables{#2}% -   \prepareMPpositionvariables +   \positions_mp_graphic_prepare     \enableincludeMPgraphics     \startMPcode#3\stopMPcode -   \egroup} +   \endgroup} -% Now we need a adapted action handler: +\def\MPpositiongraphic +  {\dodoublegroupempty\positions_mp_graphic_direct} + +% \def\positions_mp_graphic_direct#1#2% tag setups +%   {\begingroup +%    \def\@@meta{#1:}% +%    \setupMPvariables[#2]% +%    \positions_mp_graphic_prepare +%    \MPshiftdrawingtrue +%    \def\positions_mp_graphic_direct{\positions_mp_graphic_nested{#2}}% takes two extra arguments +%    \setbox\positiongraphicbox\hbox +%      {\ignorespaces +%       \ifcsname MPM:#1\endcsname \csname MPM:#1\endcsname \else +%       \ifcsname MPG:#1\endcsname \csname MPG:#1\endcsname \fi\fi +%       \removelastspace}% +%    \smashbox\positiongraphicbox +%    \box\positiongraphicbox +%    \endgroup} + +\def\positions_mp_graphic_direct#1% tag setups +  {\ifcsname MPM:#1\endcsname +     \expandafter\positions_mp_graphic_direct_indeed_mpm +   \else\ifcsname MPG:#1\endcsname +     \doubleexpandafter\positions_mp_graphic_direct_indeed_mpg +   \else +     \doubleexpandafter\positions_mp_graphic_direct_indeed_nop +   \fi\fi{#1}} -\def\dopositionaction#1% test saves hash entry in etex -  {\ifcsname\POSactionprefix#1::\endcsname -     \dodopositionaction{#1}% -   \fi} +\let\positions_mp_graphic_direct_indeed_nop\gobbletwoarguments -\def\dodopositionaction#1% -  {\ifnum\MPp{#1}>\zerocount % new -     \bgroup -     \setbox\scratchbox\hbox -     \bgroup -     \traceposstring\clap\red{<#1>}% -     \the\everyinsertpositionaction -     \the\everypositionaction -     \csname\POSactionprefix#1::\endcsname -     \cleanuppositionaction{#1}% -     \egroup                % smashed is really needed else -     \smashedbox\scratchbox % we get problems with too big -     \egroup                % overlays (s-pre-0x.tex) -   \else -     % shouldn't happen too often -     \traceposstring\clap\cyan{<#1>}% -   \fi} +\def\positions_mp_graphic_direct_indeed_mpm +  {\positions_mp_graphic_direct_indeed{MPM}} -\def\MPpositiongraphic -  {\dodoublegroupempty\doMPpositiongraphic} +\def\positions_mp_graphic_direct_indeed_mpg +  {\positions_mp_graphic_direct_indeed{MPG}} -\def\doMPpositiongraphic#1#2% tag setups -  {\bgroup -   \def\@@meta{#1:}% -   \setupMPvariables[#2]% -   \prepareMPpositionvariables +\def\positions_mp_graphic_direct_indeed#1#2#3% what tag setups +  {\begingroup +   \def\@@meta{#2:}% will become a commandhandler +   \setupMPvariables[#3]% +   \positions_mp_graphic_prepare     \MPshiftdrawingtrue -   \def\doMPpositiongraphic##1##2% -     {{% new, see (techniek) -       \def\@@meta{##1:}% -       \setupMPvariables[#2,##2]% -       \prepareMPpositionvariables -       % and needed -       \getvalue{MPG:##1}}}% temp hack +   \def\positions_mp_graphic_direct{\positions_mp_graphic_nested{#3}}% takes two extra arguments     \setbox\positiongraphicbox\hbox -     {\ignorespaces -      \executeifdefined{MPM:#1}{\executeifdefined{MPG:#1}\donothing}% -      \removelastspace}% +     {\ignorespaces\csname#1:#2\endcsname\removelastspace}%     \smashbox\positiongraphicbox     \box\positiongraphicbox -   \egroup} +   \endgroup} + +\def\positions_mp_graphic_nested#1#2#3% nesting used in prikkels / pascal +  {\begingroup +   \def\@@meta{#2:}% +   \setupMPvariables[#1,#3]% +   \positions_mp_graphic_prepare +   \getvalue{MPG:#2}% +   \endgroup}%  \long\def\startMPpositionmethod#1#2\stopMPpositionmethod    {\long\setgvalue{MPM:#1}{#2}} % todo: var list here @@ -372,7 +478,7 @@  \def\docleanMPpositiongraphic#1#2#3% pos tag setups    {\ifnum\MPp{#1}<\realpageno \else -     \noexpand \dohandleMPpositiongraphic{#1}{#2}{#3}% +     \noexpand\dohandleMPpositiongraphic{#1}{#2}{#3}%     \fi}  \appendtoks @@ -381,7 +487,7 @@  %D Graphics that span two positions (beware, does not cross pages). -\def\setMPpositiongraphicrange +\unexpanded\def\setMPpositiongraphicrange    {\doquadruplegroupempty\dosetMPpositiongraphicrange}  \def\dosetMPpositiongraphicrange#1#2#3#4% bpos epos tag vars @@ -425,622 +531,6 @@  \appendtoks      \let\dohandleMPpositiongraphicrange\docleanMPpositiongraphicrange  \to \everycleanpositionaction - -% will be overloaded, and/or code below moved to core-box - -\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}] - -%D Some of these macros are pretty clever but too complicated -%D to be nice. When things are kind of stable I'll clean up -%D this mess. - -%D THIS NEEDS A CLEANUP - -\setupMPvariables -  [mpos:box] -  [linecolor=blue, -   linewidth=\linewidth, -   fillcolor=lightgray, -   filloffset=\!!zeropoint] - -\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth} -  initialize_box(\MPpos{\MPvar{self}}) ; -  def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; -  def boxlineoptions = withcolor \MPvar{linecolor} enddef ; -  boxlinewidth  := \MPvar{linewidth} ; -  boxfilloffset := \MPvar{filloffset} ; -  draw_box ; -  anchor_box(\MPanchor{\MPvar{self}}) ; -\stopMPpositiongraphic - -\setupMPvariables -  [mpos:area] -  [linecolor=blue, -   linewidth=\linewidth, -   fillcolor=lightgray, -   filloffset=\!!zeropoint] - -\startMPpositiongraphic{mpos:area}{fillcolor,linecolor,linewidth} -  initialize_area(\MPpos{b:\MPvar{self}},\MPpos{e:\MPvar{self}}) ; -  def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; -  def boxlineoptions = withcolor \MPvar{linecolor} enddef ; -  boxlinewidth  := \MPvar{linewidth} ; -  boxfilloffset := \MPvar{filloffset} ; -  draw_area ; -  anchor_area(\MPanchor{b:\MPvar{self}}) ; -\stopMPpositiongraphic - -%D This is already cleaned up. - -% gridtype = 1 => baseline -% gridtype = 2 => betweenline - -\setupMPvariables -  [mpos:par] -  [mp=mpos:par:shape, -   gridtype=0, -   linetype=1, -   filltype=1, -   dashtype=0, % 1 = dashed, 2 = dashed with background -  %snaptops=true, % not that nice: true/false -   gridcolor=red, -   linecolor=blue, -   fillcolor=lightgray, -   filloffset=\!!zeropoint, -   linewidth=\linewidth, -   gridwidth=\linewidth, -   gridshift=\!!zeropoint, -   lineradius=.5\bodyfontsize, -   dashtype=1] - -\startuseMPgraphic{mpos:par:shape} -  \iftracepositions show_par \else draw_par \fi ; -\stopuseMPgraphic - -\startuseMPgraphic{mpos:par:setup} -   boxgridtype   := \MPvar{gridtype} ; -   boxlinetype   := \MPvar{linetype} ; -   boxfilltype   := \MPvar{filltype} ; -   boxdashtype   := \MPvar{dashtype} ; -   def boxgridoptions = withcolor \MPvar{gridcolor} enddef ; -   def boxlineoptions = withcolor \MPvar{linecolor} enddef ; -   def boxfilloptions = withcolor \MPvar{fillcolor} enddef ; -   boxfilloffset := \MPvar{filloffset} ; -   boxlinewidth  := \MPvar{linewidth} ; -   boxgridwidth  := \MPvar{gridwidth} ; -   boxgridshift  := \MPvar{gridshift} ; -   boxlineradius := \MPvar{lineradius} ; -  %snap_multi_par_tops := \MPvar{snaptops} ; -\stopuseMPgraphic - -\startuseMPgraphic{mpos:par:extra} -  % user stuff, like: -  % snap_multi_par_tops := false ; -\stopuseMPgraphic - -\ifx\MPparcounter\undefined \newcounter\MPparcounter \fi - -\def\MPself     {\MPvar{self}} -\def\MPbself    {b:\MPself} -\def\MPeself    {e:\MPself} -\def\MPwself    {w:\MPself} -\def\MPparanchor{p:\MPparcounter} - -\def\MPl#1{\MPplus{#1}20} -\def\MPr#1{\MPplus{#1}30} - -\startMPpositionmethod{mpos:par} %%%%%%%%%%% will become obsolete -  \edef\MPparcounter{\MPv\MPbself{1}{0}}% -  \doifpositionelse\MPwself -    {\startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} -       initialize_area_par(\MPpos\MPbself, -                           \MPpos\MPeself, -                           \MPpos\MPwself) ; -       \includeMPgraphic{mpos:par:setup} ; -       \includeMPgraphic{mpos:par:extra} ; -       \includeMPgraphic{\MPvar{mp}} ; -       anchor_par(\MPanchor\MPbself) ; -     \stopMPpositiongraphic} -    {\startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} -       initialize_par(\MPpos\MPbself, -                      \MPpos\MPeself, -                      \MPpos\textanchor, -                      \MPpos\MPparanchor, -                      \MPvv \MPparanchor{0pt,0pt,0pt,0pt,0,0pt}) ; -       \includeMPgraphic{mpos:par:setup} ; -       \includeMPgraphic{mpos:par:extra} ; -       \includeMPgraphic{\MPvar{mp}} ; -       anchor_par(\MPanchor\MPbself) ; -     \stopMPpositiongraphic}% -  \MPpositiongraphic{mpos:par}{}% -\stopMPpositionmethod - -%D The next alternative works in columnsets : - -%  \iftracepositions show\else draw\fi_multi_pars ; - -\startuseMPgraphic{mpos:par:columnset} -  \iftracepositions show_multi_pars \else draw_multi_pars \fi ; -\stopuseMPgraphic - -\startuseMPgraphic{mpos:par:sideline}{linecolor,lineoffset,linewidth} -    begingroup ; save p ; picture p ; -    for i=1 upto nofmultipars : -        p := image ( fill leftboundary multipars[i] -            shifted (-\MPvar{lineoffset},0) -            rightenlarged \MPvar{linewidth} withcolor \MPvar{linecolor} ; -        ) ; -        setbounds p to multipars[i] ; -        draw p ; -    endfor ; -    endgroup ; -\stopuseMPgraphic - -\startMPpositionmethod{mpos:par:columnset} -  \edef\MPparcounter{\MPv\MPbself{1}{0}}% -  \startMPpositiongraphic{mpos:par}{fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,gridshift,lineradius} -    \includeMPgraphic{mpos:par:setup} ; -    \includeMPgraphic{mpos:par:extra} ; -    prepare_multi_pars(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself, -      \MPpos\MPparanchor,\MPvv\MPparanchor{0pt,0pt,0pt,0pt,0,0pt}) ; -    relocate_multipars(-\MPxy\MPanchorid) ; % inside layerpos -    \includeMPgraphic{\MPvar{mp}} ; -  \stopMPpositiongraphic -  \MPpositiongraphic{mpos:par}{}% -\stopMPpositionmethod - -%D \starttyping -%D \setupbackground -%D   [test] -%D   [mp=mpos:par:columnset, -%D    method=mpos:par:columnset] -%D \stoptyping - -%D We need to treat floats in a special way. - -\startMPinitializations -  local_multi_par_area:=\iflocalpositioning true\else false\fi; -\stopMPinitializations - -\def\textbackgroundoverlay#1% -  {\iflocalpositioning\v!local\else\v!text\fi#1} - -\newcount\localpositionnumber - -\def\MPanchornumber -  {\iflocalpositioning\the\localpositionnumber\else\the\realpageno\fi} - -%D So far for the trickery. - -\newcount\textbackgrounddepth - -\ifdefined\nofparbackgrounds\else \newcount\nofparbackgrounds \fi - -\ifx\totalnofparbackgrounds\undefined \newcounter\totalnofparbackgrounds \fi - -\appendtoks -    \expanded{\savecurrentvalue\noexpand\totalnofparbackgrounds{\number\nofparbackgrounds}}% -\to \everybye - -% actually we can just ask lua to give us the nofpositions (or a least n<>0) - -\appendtoks -    % a position can be mid paragraph in which case we're behind -    % this will change when we move positions to lua -    \initializeparbackgrounds -\to \everystarttext - -\def\initializeparbackgrounds -  {\ifcase\totalnofparbackgrounds\else -     \enableparpositions -   \fi} - -\unexpanded\def\starttextbackground -  {\bgroup -   \advance\textbackgrounddepth\plusone -   \dodoubleempty\dostarttextbackground} - -\let\dodostarttextbackground\relax -\let\dodostoptextbackground \relax - -\def\currentparbackground{pbg:0} -\def\nextparbackground   {pbg:1} - -\def\btbanchor{b:\currentparbackground} -\def\etbanchor{e:\currentparbackground} - -\def\nextbtbanchor{b:\nextparbackground} -\def\nextetbanchor{e:\nextparbackground} - -\def\textbackgroundparameter#1% -  {\csname\??td\currenttextbackground#1\endcsname} - -\let\backgroundvariable\textbackgroundparameter % will become obsolete - -% \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 - -\def\dostarttextbackground[#1][#2]% -  {\checktextbackgrounds -   \def\currenttextbackground{#1}% -   \global\advance\nofparbackgrounds\plusone -   \edef\currentparbackground{pbg:\number\nofparbackgrounds}% -   \xdef\nextparbackground{pbg:\number\numexpr\nofparbackgrounds+\plusone\relax}% still xdef ? -   % todo : \synchonizepositionpage{b:\currentparbackground}{s:\currentparbackground}% -   \setuptextbackground[#1][#2]% -   \let\dodostarttextbackground\relax -   \let\dodostoptextbackground \relax -   \doif{\textbackgroundparameter\c!state}\v!start{\dopresettextbackground{#1}}% -   \dodostarttextbackground} - -% todo \backgroundvariable\c!variant - -\def\dopresettextbackground#1% todo: \backgroundparameter -  {\normalexpanded{\noexpand\processaction[\textbackgroundparameter\c!location]} -     [   \v!text=>\let\dodostarttextbackground\dostarttextbackgroundtxt -                  \let\dodostoptextbackground \dostoptextbackgroundtxt, -    \v!paragraph=>\let\dodostarttextbackground\dostarttextbackgroundpar -                  \let\dodostoptextbackground \dostoptextbackgroundpar, -         \v!none=>\let\dodostarttextbackground\relax -                  \let\dodostoptextbackground \relax]% -   \ifx\dodostarttextbackground\dostarttextbackgroundpar % untested -     \ifnum\textbackgrounddepth>\plusone % new -       \let\dodostarttextbackground\dostarttextbackgroundtxt -       \let\dodostoptextbackground \dostoptextbackgroundtxt -     \fi -   \fi -   \doifelse{\textbackgroundparameter\c!frame}\v!on -     {\doifelse{\textbackgroundparameter\c!corner}\v!round -        {\setvalue{\??td#1\c!frame}{2}} -        {\setvalue{\??td#1\c!frame}{1}}} -     {\setvalue{\??td#1\c!frame}{0}}% -   \doifelse{\textbackgroundparameter\c!background}\v!color -     {\setvalue{\??td#1\c!background}{1}} -     {\setvalue{\??td#1\c!background}{0}}% -  %\startpositionoverlay{\v!text\getvalue{\??td#1\c!level}}% -   \startpositionoverlay{\textbackgroundoverlay{\textbackgroundparameter\c!level}}% -     \expanded -       {\setMPpositiongraphicrange % moet veel efficienter -          {\btbanchor}% {b:\currentparbackground}% -          {\etbanchor}% {e:\currentparbackground}% -          {\textbackgroundparameter\c!method}% -          {self=\currentparbackground, -           mp=\textbackgroundparameter\c!mp, -           gridtype=\textbackgroundparameter\c!alternative, -           filltype=\textbackgroundparameter\c!background, -           linetype=\textbackgroundparameter\c!frame, -           dashtype=\textbackgroundparameter{dash}, %  to be internationalized -           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}}% -   \stoppositionoverlay} - -\unexpanded\def\stoptextbackground -  {\dodostoptextbackground -   \carryoverpar\egroup} - -\unexpanded\def\starttextbackgroundmanual -  {\begingroup -   \dousestylehashparameter{\??td\currenttextbackground}\c!style -   \dousecolorhashparameter{\??td\currenttextbackground}\c!color -   \fpos\currentparbackground\ignorespaces} - -\unexpanded\def\stoptextbackgroundmanual -  {\tpos\currentparbackground -   \endgroup} - -\def\dostarttextbackgroundtxt -  {\ifvmode \dontleavehmode \fi -   \begingroup -   \dousestylehashparameter{\??td\currenttextbackground}\c!style -   \dousecolorhashparameter{\??td\currenttextbackground}\c!color -   \fpos\currentparbackground\ignorespaces} - -\def\dostoptextbackgroundtxt -  {\tpos\currentparbackground -   \endgroup} - -\newskip\textbackgroundskip - -\def\dostarttextbackgroundpar -  {\endgraf % new -   \textbackgroundparameter\c!before -   \bgroup -\begingroup -\resetallattributes % \attribute\linenumberattribute \attributeunsetvalue -   \noindent -   \ifgridsnapping -     \doassignsomeskip\textbackgroundparameter\c!topoffset\to\textbackgroundskip -     \ifdim\textbackgroundskip>\zeropoint -       \struttedbox{\hbox{\raise\textbackgroundskip\hbox{\fpos\currentparbackground}}}% -     \else -      \fpos\currentparbackground -     \fi -   \else -     \fpos\currentparbackground -   \fi -   \endgraf % we need a vertical nobreak - 29/06/2004 -\endgroup -   \nobreak \vskip-\lineheight \nobreak -   \ifgridsnapping \else -     \doassignsomeskip\textbackgroundparameter\c!topoffset\to\textbackgroundskip -     \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 -   % -  %\begingroup -   \dousestylehashparameter{\??td\currenttextbackground}\c!style -   \dousecolorhashparameter{\??td\currenttextbackground}\c!color -   \nowhitespace -   \nobreak % new per 23/04/2006 (else potential break when whitespace) -   \seteffectivehsize -   \doinhibitblank %   \blank[\v!disable]% new -   \par} - -\def\dostoptextbackgroundpar -  {\par -   \removelastskip % new -  %\endgroup -   \doassignsomeskip\textbackgroundparameter\c!bottomoffset\to\textbackgroundskip -   \ifdim\lastskip>\zeropoint -     \advance\textbackgroundskip-\lastskip -   \fi -   \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint -     \kern\textbackgroundskip\nobreak -   \fi \fi -   \nobreak \vskip-\dimexpr\lineheight+\parskip\relax \nobreak -%    \nobreak \vskip-\lineheight \nobreak \nowhitespace % does not work -   \egroup -   \bgroup \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM -\resetallattributes % \attribute\linenumberattribute \attributeunsetvalue -   \nobreak \noindent \strut \hfill \kern\zeropoint -   \doassignsomeskip\textbackgroundparameter\c!bottomoffset\to\textbackgroundskip -   \ifgridsnapping % experimental, pascal (todo: topoffset in same way) -     \ifdim\textbackgroundskip>\zeropoint -       \struttedbox\plusone{\hbox{\lower\textbackgroundskip\hbox{\tpos\currentparbackground}}}% -     \else -       \tpos\currentparbackground -     \fi -   \else -     \tpos\currentparbackground -   \fi -\endgraf -   \egroup -   \endgraf % new -   \textbackgroundparameter\c!after} - -\let\textparpages \!!zeropoint -\let\textparheight\!!zeropoint -\let\textparwidth \!!zeropoint - -\def\calculatetextpardimensions -  {\docalculatetextpardimensions\btbanchor\etbanchor\MPparanchor} - -\def\calculatenexttextpardimensions -  {\docalculatetextpardimensions\nextbtbanchor\nextetbanchor\relax} - -\def\docalculatetextpardimensions#1#2#3% #1=\btbanchor #2=\etbanchor (adapted 8/6/2009) -  {\scratchcounter\numexpr\MPp#2-\MPp#1\relax -   \edef\textparpages -     {\the\scratchcounter}% -   \edef\textparheight -     {\the\dimexpr -        \ifcase\scratchcounter -          % one page -          \MPy#1-\MPy#2% -        \else -          % two or more pages -          \ifnum\scratchcounter>2 -            \ifnum\scratchcounter<5 -              % more pages -              \textheight*\numexpr\scratchcounter+\minusone -            \else -              % keep'm small -              5\textheight -            \fi -          \else -            \MPy#1-\MPy#2-\MPy\textanchor+\MPy\textanchor+\MPh\textanchor -          \fi -        \fi -      \relax}% -   \edef\textparwidth -     {\the\dimexpr -        \ifcase\scratchcounter -          % one page -          \MPx#2-\MPx#1% -        \else -          % two or more pages / maybe also hang -          \ifx#3\relax -            \makeupwidth % \textwidth -          \else -            \MPw\MPparanchor-\MPl\MPparanchor-\MPr\MPparanchor -          \fi -        \fi -      \relax}} - -\def\mintextparheight{4\lineheight} - -\def\dontsplitnexttextbackground % dangerous but useful -  {\ifdim\pagetotal>\textheight \else -     \ifdim\pagegoal=\maxdimen \else -      \calculatenexttextpardimensions -      % too tricky -      % \scratchdimen=\textparheight -      % \advance\scratchdimen\pagetotal\relax -      % \ifdim\scratchdimen>\pagegoal -      % \page -      % \fi -      \ifdim\textparheight>\zeropoint -        \ifdim\textparheight>\mintextparheight\else -          \page % option -        \fi -      \fi -    \fi -   \fi} - -\unexpanded\def\definetextbackground -  {\dodoubleempty\dodefinetextbackground} - -\def\dodefinetextbackground[#1][#2]% parent and ..parameter -  {\ifsecondargument % why ? -     \copyparameters[\??td#1][\??td] -       [\c!state,\c!location,\c!alternative,\c!mp,\c!method, -        \c!background,\c!backgroundcolor,\c!corner,\c!level, -        \c!backgroundoffset,\c!before,\c!after,\c!align,dash, % dash not yet internationalized -        \c!radius,\c!frame,\c!framecolor,\c!rulethickness,\c!voffset,\c!frameoffset, -        \c!leftoffset,\c!rightoffset,\c!topoffset,\c!bottomoffset]% -     \getparameters[\??td#1][#2]% -     \doifvalue{\??td#1\c!state}\v!start\checktextbackgrounds -     \setuvalue{#1}{\groupedcommand{\starttextbackground[#1]}{\stoptextbackground}}% -     \setuvalue{\e!start#1}{\starttextbackground[#1]}% -     \setuvalue{\e!stop #1}{\stoptextbackground}% -   \fi} - -\unexpanded\def\setuptextbackground -  {\dodoubleargument\dosetuptextbackground} - -\def\dosetuptextbackground[#1][#2]% -  {\ifsecondargument -     \doifelsenothing{#1} -       {\dodosetuptextbackground{#2}\empty} -       {\processcommalist[#1]{\dodosetuptextbackground{#2}}}% -   \else -     \dodosetuptextbackground{#1}\empty -   \fi} - -\def\dodosetuptextbackground#1#2% -  {\getparameters[\??td#2][#1]% -   \def\currenttextbackground{#2}% -   \doifvalue{\??td#2\c!state}\v!start\checktextbackgrounds} - -\let\currenttextbackground\empty - -\def\checktextbackgrounds -  {\ifproductionrun -     \enabletextarearegistration -     \enablehiddenbackground -   \fi} - -\setuptextbackground -  [\c!mp=mpos:par:columnset,      % buggy: mpos:par:shape -   \c!method=mpos:par:columnset, % -   \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!level=-1, -   \c!alternative=0, -   \c!align=, -   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!rulethickness=\linewidth] - -%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 \letvalue\v!grid=\basegrid \fi - -\setupMPvariables -  [mpos:connect] -  [linecolor=red, -   linewidth=1pt] - -\setupMPvariables -  [mpos:encircle] -  [fillcolor=lightgray, -   filloffset=\!!zeropoint, -   linecolor=blue, -   linewidth=1pt] - -% these might become macros in mp-page - -\startuseMPgraphic{mpos:common:ec} -  path pa ; pair ca ; numeric lw ; -  lw := \MPvar{linewidth} ; -  initialize_box(\MPpos{\MPvar{self}}) ; -  pa := pxy ; ca := cxy ; pa := boundingbox pa enlarged 2lw ; -  pa := llcorner pa ... lrcorner pa ... urcorner pa ... ulcorner pa ... cycle ; -  drawoptions (withpen pencircle scaled lw withcolor \MPvar{linecolor}) ; -\stopuseMPgraphic - -\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth} -  \includeMPgraphic{mpos:common:ec} -  fill pa withcolor \MPvar{fillcolor} ; draw pa ; -  anchor_box(\MPanchor{\MPvar{self}}) ; -\stopMPpositiongraphic - -\startMPpositiongraphic{mpos:connect}{linecolor,linewidth} -  path pb, pc ; pair cb, cc ; -  \includeMPgraphic{mpos:common:ec} -  initialize_box(\MPpos{\MPvar{to}}) ; -  pb := pxy ; cb := cxy ; pb := boundingbox pb enlarged 2lw ; -  pb := llcorner pb...lrcorner pb...urcorner pb...ulcorner pb...cycle ; -  pc := ca {up} .. {down} cb ; -  cc := (pc intersection_point pa) ; -  if intersection_found : -    pc := pc cutbefore cc ; -    cc := (pc intersection_point pb) ; -    if intersection_found : -      pc := pc cutafter cc ; -      drawarrow pc ; drawarrow reverse pc ; -    fi ; -  fi ; -  anchor_box(\MPanchor{\MPvar{self}}) ; -\stopMPpositiongraphic  %D \macros  %D   {stackposdown, stackposup, stackposleft,stackposright} @@ -1072,382 +562,4 @@  \unexpanded\def\stackposleft {\dostackposbox{\copy\nextbox\hskip\nextboxwd\hskip\stackposdistance}}  \unexpanded\def\stackposright{\dostackposbox{\hskip\stackposdistance\hskip\nextboxwd\flushnextbox}} -%D \macros -%D   {GFC, GTC, GSC} -%D -%D The next macros extend tables and tabulation with -%D backgrounds and position related features. Areas are -%D specified with symbolic names, and symbolic references to -%D the graphics involved. Each table has its own namespace. - -\newconditional\tablehaspositions -\newcount\noftabpositions -\newtoks \posXCtoks - -\def\dotablebpos{\bpos} -\def\dotableepos{\epos} - -\def\tbPOSprefix -  {tbp:\number\noftabpositions:} - -\def\tablepos -  {\normalexpanded{\global\posXCtoks\emptytoks\the\posXCtoks}} - -\let\tabulatepos\tablepos - -\def\dodododoGSC[#1:#2]% -  {\remappositionframed{#2}{\tbPOSprefix#1}% -   \dotablebpos{\tbPOSprefix#1}% -   \doglobal\appendtoks\@EA\dotableepos\@EA{\tbPOSprefix#1}\to\posXCtoks} - -\def\dododoGSC[#1:#2:#3]% -  {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC} - -\def\dodoGSC[#1]% -  {\def\docommand##1{\dododoGSC[##1:##1]}% -   \processcommalist[#1]\docommand} - -\def\dodododoGFC[#1:#2:#3]% -  {\remappositionframed{#2}{\tbPOSprefix#1}% -   \dotablebpos{\tbPOSprefix#1}} - -\def\dododoGFC[#1]% -  {\def\docommand##1{\dodododoGFC[##1:##1]}% -   \processcommalist[#1]\docommand} - -\def\dodoGFC[#1]% -  {\doglobal\appendtoks\dododoGFC[#1]\to\posXCtoks\NC} - -\def\dododododoGTC[#1:#2]% -  {\dotableepos{\tbPOSprefix#1}} - -\def\dodododoGTC[#1]% -  {\def\docommand##1{\dododododoGTC[##1:##1]}% -   \processcommalist[#1]\docommand} - -\def\dododoGTC[#1]% -  {\doglobal\appendtoks\dodododoGTC[#1]\to\posXCtoks} - -\def\dodoGTC[#1]% -  {\doglobal\appendtoks\dododoGTC[#1]\to\posXCtoks\NC} - -\def\dodododoXC[#1#2]% -  {\if#1>\dodoGFC  [#2:#2]\else -   \if#1+\dodoGFC  [#2:#2]\else -   \if#1<\dodoGTC  [#2:#2]\else -   \if#1-\dodoGTC  [#2:#2]\else -   \if#1=\dodoGSC  [#2:#2]\else -         \dodoGSC[#1#2:#1#2]\fi\fi\fi\fi\fi} - -\def\dododoXC#1% -  {\dodododoXC[#1]} - -\def\dodoXC[#1]% -  {{\let\NC\relax\processcommalist[#1]\dododoXC}} - -\def\@@checktablepositionstate -  {\iftrialtypesetting -     \global\settrue\tablehaspositions -     \firstargumentfalse -   \fi} - -\def\doGSC[#1]{\@@checktablepositionstate\iffirstargument\dodoGSC[#1]\else\expandafter\NC\fi} -\def\doGFC[#1]{\@@checktablepositionstate\iffirstargument\dodoGFC[#1]\else\expandafter\NC\fi} -\def\doGTC[#1]{\@@checktablepositionstate\iffirstargument\dodoGTC[#1]\else\expandafter\NC\fi} -\def\doXC [#1]{\@@checktablepositionstate\iffirstargument\dodoXC [#1]\else\expandafter\fi\NC} - -\def\tbGSC{\dosingleempty\doGSC} -\def\tbGFC{\dosingleempty\doGFC} -\def\tbGTC{\dosingleempty\doGTC} -\def\tbXC {\dosingleempty\doXC } - -%D The amount of code to support tables and tabulation is -%D rather minimalistic. - -\let\tabulatepos\tablepos - -\def\tabulatenormalpos -  {\iftrialtypesetting -     % nothing -   \else\ifconditional\tablehaspositions -     \hss\tabulatepos\hss -   \else -     % nothing -   \fi\fi} - -\def\tabulateequalpos -  {\iftrialtypesetting -     \tabulateEQ -   \else\ifconditional\tablehaspositions -     \tabulateEQpos -   \else -     \tabulateEQ -   \fi\fi} - -\def\tabulateEQpos -  {\setbox\scratchbox\hbox{\tabulateEQ}% -   \hbox to \wd\scratchbox{\hss\kern\zeropoint\tabulatepos\hss}% -   \hskip-\wd\scratchbox -   \box\scratchbox} - -\appendtoks -    \global\advance\noftabpositions\plusone -    \global\setfalse\tablehaspositions -\to \everytabulate - -% We need to handle paragraphs as well. - -\let\doflushtabulateepos\relax - -\def\dotabulatebpos -  {\bpos} - -\def\dotabulateepos#1% -  {\ifvoid\tablebox\tabulatecolumn -     \epos{#1}% -     \glet\doflushtabulateepos\relax -   \else -     \gdef\doflushtabulateepos{\epos{#1}}% -   \fi} - -\def\flushtabulatesplitbox -  {\box\tabulatebox -   \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi} - -\appendtoks -    \let\dotablebpos\dotabulatebpos -    \let\dotableepos\dotabulateepos -    \glet\doflushtabulateepos\relax -\to \everytabulate - -%D In order to prevent potential clashes with abbreviations, -%D postpone the mapping. - -\appendtoks -    \let\GSC\tbGSC -    \let\GFC\tbGFC -    \let\GTC\tbGTC -    \let\XC \tbXC -\to \everytabulate - -%D \macros -%D   {definepositionframed} -%D -%D The next example show how to provide backgrounds to table -%D cells. First we define some framed backgrounds. -%D -%D \startbuffer -%D \definepositionframed[x][background=color,backgroundcolor=red] -%D \definepositionframed[y][background=color,backgroundcolor=green] -%D \definepositionframed[z][background=color,backgroundcolor=blue] -%D \stopbuffer -%D -%D \typebuffer -%D -%D % \getbuffer -%D -%D \startbuffer -%D \starttabulate[|c|c|c|] -%D \GFC[f:x] this is a small  \NC       table            \NC     in which we \NC \FR -%D \NC       will demonstrate \GFC[g:z] that this        \GTC[g] positioning \NC \MR -%D \GSC[e:y] mechanism also   \GTC[f]   works quite well \NC     in tables   \NC \LR -%D \stoptabulate -%D \stopbuffer -%D -%D The table itself defines three areas (a, b and~c) using -%D these frames. -%D -%D \typebuffer -%D % \getbuffer -%D -%D Tables (based on \TABLE) are supported by: - -\def\normalTABLEsimplebar {\unskip\!ttRightGlue&\tablepos&}                       % | -\def\normalTABLEcomplexbar{\unskip\!ttRightGlue&\omit\tablepos\!ttAlternateVrule} % \| -\def\normalTABLEquote     {\unskip\!ttRightGlue&\omit\tablepos&}                  % " - -\appendtoks -    \global\advance\noftabpositions\plusone -    \global\setfalse\tablehaspositions -\to \everytable - -%D Since we don't want nameclashes: - -\appendtoks -    \let\GSC\tbGSC -    \let\GFC\tbGFC -    \let\GTC\tbGTC -    \let\XC \tbXC -\to \everytable - -%D In the previous example, we could have provided an overlay to -%D the framed definition. A more direct approach is demonstrated -%D below: -%D -%D \startbuffer -%D \def\cw#1{\color[white]{#1}} -%D -%D \startMPpositiongraphic{tableshade} -%D   initialize_area(\MPpos{\MPvar{from}},\MPpos{\MPvar{to}}) ; -%D   color c ; c := \MPvar{color} ; -%D   linear_shade(pxy,0,.4c,.9c) ; -%D   anchor_area(\MPanchor{\MPvar{from}}) ; -%D \stopMPpositiongraphic -%D -%D \setMPpositiongraphic{b:x}{tableshade}{from=b:x,to=e:x,color=red} -%D \setMPpositiongraphic{b:y}{tableshade}{from=b:y,to=e:y,color=green} -%D \setMPpositiongraphic{b:z}{tableshade}{from=b:z,to=e:z,color=blue} -%D \stopbuffer -%D -%D \typebuffer \getbuffer -%D -%D The definition of the table looks about the same as the -%D previous one: -%D -%D \startbuffer -%D \starttable[|c|c|c|] -%D \GFC[b:z] \cw{this is a small}  \NC       \cw{table}            \NC     in which we      \NC \FR -%D \NC       \cw{will demonstrate} \GFC[c:y] \cw{that this}        \GTC[c] \cw{positioning} \NC \MR -%D \GSC[a:x] \cw{mechanism also}   \GTC[b]   \cw{works quite well} \NC     in tables        \NC \LR -%D \stoptable -%D \stopbuffer -%D -%D \typebuffer -%D -%D \getbuffer - -% \definepositionframed[w][background=color,backgroundcolor=yellow] -% \definepositionframed[x][background=color,backgroundcolor=red] -% \definepositionframed[y][background=color,backgroundcolor=green] -% \definepositionframed[z][background=color,backgroundcolor=blue] -% -% \starttabulate[|c|c|c|] -% \NC this is a small  \NC table            \NC in which we \NC \FR -% \NC will demonstrate \NC that this        \NC positioning \NC \MR -% \NC mechanism also   \NC works quite well \NC in tables   \NC \LR -% \stoptabulate -% -% \starttabulate[|c|c|c|] -% \GFC[f:x] this is a small      \GTC      table            \NC     in which we \NC \FR -% \NC       will demonstrate     \GFC[g:z] that this        \GTC[g] positioning \NC \MR -% \GSC[e:y] mechanism also       \GTC[f]   works quite well \NC     in tables   \NC \LR -% \stoptabulate -% -% \starttabulate[|c|c|c|] -% \GFC[f:x,d:w] this is a small  \GTC[d]   table            \NC     in which we \NC \FR -% \NC           will demonstrate \GFC[g:z] that this        \GTC[g] positioning \NC \MR -% \GSC[e:y]     mechanism also   \GTC[f]   works quite well \NC     in tables   \NC \LR -% \stoptabulate -% -% \starttabulate[|c|c|c|] -% \XC[+f:x] this is a small  \XC      table            \NC     in which we \NC \FR -% \NC      will demonstrate  \XC[+g:z] that this       \XC[-g] positioning \NC \MR -% \XC[=e:y] mechanism also   \XC[-f]  works quite well \NC     in tables   \NC \LR -% \stoptabulate -% -% \starttabulate[|c|c|c|] -% \XC[+f:x,+d:w] this is a small  \XC[-d]   table            \NC     in which we \NC \FR -% \NC            will demonstrate \XC[+g:z] that this        \XC[-g] positioning \NC \MR -% \XC[=e:y]       mechanism also  \XC[-f]   works quite well \NC     in tables   \NC \LR -% \stoptabulate - -% evt                  [b:x] -% -% \definepositionframed[x][background=color,fillcolor=red] -% \definepositionframed[y][background=color,fillcolor=green] -% \definepositionframed[z][background=color,fillcolor=blue] - -\def\remappositionframed#1#2% from to -  {\copyposition{b:#1}{b:#2}% -   \copyposition{e:#1}{e:#2}% -   \dosetpositionaction{b:#2}{\dopositionaction{b:#1}}} - -\unexpanded\def\definepositionframed -  {\dodoubleargument\dodefinepositionframed} - -\def\dodefinepositionframed[#1][#2]% -  {\dosetpositionaction{b:#1}{\dopositionframed[#1][#2]}} - -\def\positionframed -  {\dodoubleempty\dopositionframed} - -\def\dopositionframed[#1][#2]% -  {\bgroup -   \setbox\scratchbox\hbox -     {\dimen0=\MPx{e:#1}% -      \advance\dimen0 -\MPx{b:#1}% -      \dimen2=\MPy{b:#1}% -      \advance\dimen2 -\MPy{e:#1}% -      \advance\dimen2 \MPd{e:#1}% -      \lower\dimen2\hbox -        {\advance\dimen2 \MPh{b:#1}% -         \framed -           [\c!width=\dimen0,\c!height=\dimen2, -            \c!offset=\v!overlay,#2]{}}}% -   \smashedbox\scratchbox -   \egroup} - -% \def\sethdistances#1% -%   {\hbox{\lpos{ml:#1}\hpos{mh:#1}{\strut}\rpos{mr:#1}}} -% -% \def\gethdistances#1% -%   {\scratchdimen\MPx{mh:#1}% -%    \advance\scratchdimen -\MPx{ml#1}% -%    \edef\lefthdistance{\the\scratchdimen}% -%    \scratchdimen\MPx{mr:#1}% -%    \advance\scratchdimen -\MPx{mh:#1}% -%    \edef\righthdistance{\the\scratchdimen}} -  \protect \endinput - -% todo 1: shift down option - -% \startuseMPgraphic{mpos:par:columnset} -%   \iftracepositions show_multi_pars \else draw_multi_pars \fi ; -%   path p ; p := boundingbox currentpicture ; -%   currentpicture := currentpicture shifted (0,-StrutDepth/2) ; -%   setbounds currentpicture to p ; -% \stopuseMPgraphic - -\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:par: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 -\stoptext diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv index da6e25f87..cd664ed40 100644 --- a/tex/context/base/anch-pos.mkiv +++ b/tex/context/base/anch-pos.mkiv @@ -208,6 +208,8 @@  %D position as well as execute an action associated with that  %D position. +\let\dopositionaction\gobbleoneargument +  \def\initializenextposition    {\ifpositioning \else       \global\positioningtrue @@ -322,46 +324,13 @@  \let\currentposition\s!unknown -%D A few more low level macros take care of defining and -%D recalling actions. We could save this information in the -%D position containers themselves, this would save hash -%D entries, but at the cost of much more time consuming -%D expansion. Actions are saved globally! - -\newtoks\everypositionaction - -\let\POSactionprefix\POSprefix - -\unexpanded\def\dosetpositionaction#1% -  {\setgvalue{\POSactionprefix#1::}} - -%D The lists can become quite long (also because there can -%D be lots of parameters passed on) so we provide a hook -%D to clean up the list afterwards. - -\let\cleanuppositionaction\gobbleoneargument - -\def\doifpositionaction#1% -  {\ifcsname\POSactionprefix#1::\endcsname -     \expandafter\firstofoneargument -   \else -     \expandafter\gobbleoneargument -   \fi} - -\def\doifpositionactionelse#1% -  {\ifcsname\POSactionprefix#1::\endcsname -     \expandafter\firstoftwoarguments -   \else -     \expandafter\secondoftwoarguments -   \fi} -  %D We can copy a position with:  %D  %D \starttyping  %D \copyposition {to} {from}  %D \stoptyping  %D -%D Again, this is a global action. +%D Again, this is a global operation.  \def\copyposition#1#2{\ctxcommand{copyposition('#1','#2')}} diff --git a/tex/context/base/anch-snc.mkiv b/tex/context/base/anch-snc.mkiv index 4940ff274..32222bb50 100644 --- a/tex/context/base/anch-snc.mkiv +++ b/tex/context/base/anch-snc.mkiv @@ -24,6 +24,8 @@  \unexpanded\def\definesyncpositions[#1]%    {\global\let\flushsyncpositions\doflushsyncpositions % only when used +   \global\let\flushsyncresets   \doflushsyncresets +   \global\let\flushsyncpresets  \doflushsyncpresets     \setcounter{\s!num:\s!syncpos:#1}{0}%     \doglobal\appendtoksonce\csname\s!reset :\s!syncpos:#1\endcsname\to\resetsyncpositions     \doglobal\appendtoksonce\csname\s!preset:\s!syncpos:#1\endcsname\to\presetsyncpositions @@ -130,15 +132,21 @@     \endgroup}  \def\flushsyncxxsets#1% -  {\setbox\scratchbox\hbox{\the#1}% +  {\begingroup +   \setbox\scratchbox\hbox{\the#1}%     \ifvoid\scratchbox\else -     \prewordbreak \let\prewordbreak\relax % only once +     \prewordbreak +    %\let\prewordbreak\relax % only once       \smashbox\scratchbox       \box\scratchbox -   \fi} +   \fi +   \endgroup} + +\let\flushsyncresets \relax +\let\flushsyncpresets\relax -\def\flushsyncresets {\flushsyncxxsets\resetsyncpositions } -\def\flushsyncpresets{\flushsyncxxsets\presetsyncpositions} +\def\doflushsyncresets {\flushsyncxxsets\resetsyncpositions } +\def\doflushsyncpresets{\flushsyncxxsets\presetsyncpositions}  % \appendtoks \flushsyncpositions \to \everypar  % \appendtoks \flushsyncpositions \to \everyheadstart diff --git a/tex/context/base/anch-tab.mkiv b/tex/context/base/anch-tab.mkiv new file mode 100644 index 000000000..137b96889 --- /dev/null +++ b/tex/context/base/anch-tab.mkiv @@ -0,0 +1,347 @@ +%D \module +%D   [       file=anch-pgr, % moved from anch-pgr (1999.08.01) +%D        version=2011.12.19, % 1999.08.01, +%D          title=\CONTEXT\ Anchoring Macros, +%D       subtitle=Table Extensions, +%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 / Table Extensions} + +%D Beware, the code in this module is somewhat weird and experimental +%D and might be dropped or become a loadable module. + +\unprotect + +%D \macros +%D   {GFC, GTC, GSC} +%D +%D The next macros extend tables and tabulation with +%D backgrounds and position related features. Areas are +%D specified with symbolic names, and symbolic references to +%D the graphics involved. Each table has its own namespace. + +\newconditional\tablehaspositions +\newcount\noftabpositions +\newtoks \posXCtoks + +\def\dotablebpos{\bpos} +\def\dotableepos{\epos} + +\def\tbPOSprefix +  {tbp:\number\noftabpositions:} + +\def\tablepos +  {\normalexpanded{\global\posXCtoks\emptytoks\the\posXCtoks}} + +\let\tabulatepos\tablepos + +\def\dodododoGSC[#1:#2]% +  {\remappositionframed{#2}{\tbPOSprefix#1}% +   \dotablebpos{\tbPOSprefix#1}% +   \doglobal\appendtoks\@EA\dotableepos\@EA{\tbPOSprefix#1}\to\posXCtoks} + +\def\dododoGSC[#1:#2:#3]% +  {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC} + +\def\dodoGSC[#1]% +  {\def\docommand##1{\dododoGSC[##1:##1]}% +   \processcommalist[#1]\docommand} + +\def\dodododoGFC[#1:#2:#3]% +  {\remappositionframed{#2}{\tbPOSprefix#1}% +   \dotablebpos{\tbPOSprefix#1}} + +\def\dododoGFC[#1]% +  {\def\docommand##1{\dodododoGFC[##1:##1]}% +   \processcommalist[#1]\docommand} + +\def\dodoGFC[#1]% +  {\doglobal\appendtoks\dododoGFC[#1]\to\posXCtoks\NC} + +\def\dododododoGTC[#1:#2]% +  {\dotableepos{\tbPOSprefix#1}} + +\def\dodododoGTC[#1]% +  {\def\docommand##1{\dododododoGTC[##1:##1]}% +   \processcommalist[#1]\docommand} + +\def\dododoGTC[#1]% +  {\doglobal\appendtoks\dodododoGTC[#1]\to\posXCtoks} + +\def\dodoGTC[#1]% +  {\doglobal\appendtoks\dododoGTC[#1]\to\posXCtoks\NC} + +\def\dodododoXC[#1#2]% +  {\if#1>\dodoGFC  [#2:#2]\else +   \if#1+\dodoGFC  [#2:#2]\else +   \if#1<\dodoGTC  [#2:#2]\else +   \if#1-\dodoGTC  [#2:#2]\else +   \if#1=\dodoGSC  [#2:#2]\else +         \dodoGSC[#1#2:#1#2]\fi\fi\fi\fi\fi} + +\def\dododoXC#1% +  {\dodododoXC[#1]} + +\def\dodoXC[#1]% +  {{\let\NC\relax\processcommalist[#1]\dododoXC}} + +\def\@@checktablepositionstate +  {\iftrialtypesetting +     \global\settrue\tablehaspositions +     \firstargumentfalse +   \fi} + +\def\doGSC[#1]{\@@checktablepositionstate\iffirstargument\dodoGSC[#1]\else\expandafter\NC\fi} +\def\doGFC[#1]{\@@checktablepositionstate\iffirstargument\dodoGFC[#1]\else\expandafter\NC\fi} +\def\doGTC[#1]{\@@checktablepositionstate\iffirstargument\dodoGTC[#1]\else\expandafter\NC\fi} +\def\doXC [#1]{\@@checktablepositionstate\iffirstargument\dodoXC [#1]\else\expandafter\fi\NC} + +\def\tbGSC{\dosingleempty\doGSC} +\def\tbGFC{\dosingleempty\doGFC} +\def\tbGTC{\dosingleempty\doGTC} +\def\tbXC {\dosingleempty\doXC } + +%D The amount of code to support tables and tabulation is +%D rather minimalistic. + +\let\tabulatepos\tablepos + +\def\tabulatenormalpos +  {\iftrialtypesetting +     % nothing +   \else\ifconditional\tablehaspositions +     \hss\tabulatepos\hss +   \else +     % nothing +   \fi\fi} + +\def\tabulateequalpos +  {\iftrialtypesetting +     \tabulateEQ +   \else\ifconditional\tablehaspositions +     \tabulateEQpos +   \else +     \tabulateEQ +   \fi\fi} + +\def\tabulateEQpos +  {\setbox\scratchbox\hbox{\tabulateEQ}% +   \hbox to \wd\scratchbox{\hss\kern\zeropoint\tabulatepos\hss}% +   \hskip-\wd\scratchbox +   \box\scratchbox} + +\appendtoks +    \global\advance\noftabpositions\plusone +    \global\setfalse\tablehaspositions +\to \everytabulate + +% We need to handle paragraphs as well. + +\let\doflushtabulateepos\relax + +\def\dotabulatebpos +  {\bpos} + +\def\dotabulateepos#1% +  {\ifvoid\tablebox\tabulatecolumn +     \epos{#1}% +     \glet\doflushtabulateepos\relax +   \else +     \gdef\doflushtabulateepos{\epos{#1}}% +   \fi} + +\def\flushtabulatesplitbox +  {\box\tabulatebox +   \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi} + +\appendtoks +    \let\dotablebpos\dotabulatebpos +    \let\dotableepos\dotabulateepos +    \glet\doflushtabulateepos\relax +\to \everytabulate + +%D In order to prevent potential clashes with abbreviations, +%D postpone the mapping. + +\appendtoks +    \let\GSC\tbGSC +    \let\GFC\tbGFC +    \let\GTC\tbGTC +    \let\XC \tbXC +\to \everytabulate + +%D \macros +%D   {definepositionframed} +%D +%D The next example show how to provide backgrounds to table +%D cells. First we define some framed backgrounds. +%D +%D \startbuffer +%D \definepositionframed[x][background=color,backgroundcolor=red] +%D \definepositionframed[y][background=color,backgroundcolor=green] +%D \definepositionframed[z][background=color,backgroundcolor=blue] +%D \stopbuffer +%D +%D \typebuffer +%D +%D % \getbuffer +%D +%D \startbuffer +%D \starttabulate[|c|c|c|] +%D \GFC[f:x] this is a small  \NC       table            \NC     in which we \NC \FR +%D \NC       will demonstrate \GFC[g:z] that this        \GTC[g] positioning \NC \MR +%D \GSC[e:y] mechanism also   \GTC[f]   works quite well \NC     in tables   \NC \LR +%D \stoptabulate +%D \stopbuffer +%D +%D The table itself defines three areas (a, b and~c) using +%D these frames. +%D +%D \typebuffer +%D % \getbuffer +%D +%D Tables (based on \TABLE) are supported by: + +\def\normalTABLEsimplebar {\unskip\!ttRightGlue&\tablepos&}                       % | +\def\normalTABLEcomplexbar{\unskip\!ttRightGlue&\omit\tablepos\!ttAlternateVrule} % \| +\def\normalTABLEquote     {\unskip\!ttRightGlue&\omit\tablepos&}                  % " + +\appendtoks +    \global\advance\noftabpositions\plusone +    \global\setfalse\tablehaspositions +\to \everytable + +%D Since we don't want nameclashes: + +\appendtoks +    \let\GSC\tbGSC +    \let\GFC\tbGFC +    \let\GTC\tbGTC +    \let\XC \tbXC +\to \everytable + +%D In the previous example, we could have provided an overlay to +%D the framed definition. A more direct approach is demonstrated +%D below: +%D +%D \startbuffer +%D \def\cw#1{\color[white]{#1}} +%D +%D \startMPpositiongraphic{tableshade} +%D   initialize_area(\MPpos{\MPvar{from}},\MPpos{\MPvar{to}}) ; +%D   color c ; c := \MPvar{color} ; +%D   linear_shade(pxy,0,.4c,.9c) ; +%D   anchor_area(\MPanchor{\MPvar{from}}) ; +%D \stopMPpositiongraphic +%D +%D \setMPpositiongraphic{b:x}{tableshade}{from=b:x,to=e:x,color=red} +%D \setMPpositiongraphic{b:y}{tableshade}{from=b:y,to=e:y,color=green} +%D \setMPpositiongraphic{b:z}{tableshade}{from=b:z,to=e:z,color=blue} +%D \stopbuffer +%D +%D \typebuffer \getbuffer +%D +%D The definition of the table looks about the same as the +%D previous one: +%D +%D \startbuffer +%D \starttable[|c|c|c|] +%D \GFC[b:z] \cw{this is a small}  \NC       \cw{table}            \NC     in which we      \NC \FR +%D \NC       \cw{will demonstrate} \GFC[c:y] \cw{that this}        \GTC[c] \cw{positioning} \NC \MR +%D \GSC[a:x] \cw{mechanism also}   \GTC[b]   \cw{works quite well} \NC     in tables        \NC \LR +%D \stoptable +%D \stopbuffer +%D +%D \typebuffer +%D +%D \getbuffer + +% \definepositionframed[w][background=color,backgroundcolor=yellow] +% \definepositionframed[x][background=color,backgroundcolor=red] +% \definepositionframed[y][background=color,backgroundcolor=green] +% \definepositionframed[z][background=color,backgroundcolor=blue] +% +% \starttabulate[|c|c|c|] +% \NC this is a small  \NC table            \NC in which we \NC \FR +% \NC will demonstrate \NC that this        \NC positioning \NC \MR +% \NC mechanism also   \NC works quite well \NC in tables   \NC \LR +% \stoptabulate +% +% \starttabulate[|c|c|c|] +% \GFC[f:x] this is a small      \GTC      table            \NC     in which we \NC \FR +% \NC       will demonstrate     \GFC[g:z] that this        \GTC[g] positioning \NC \MR +% \GSC[e:y] mechanism also       \GTC[f]   works quite well \NC     in tables   \NC \LR +% \stoptabulate +% +% \starttabulate[|c|c|c|] +% \GFC[f:x,d:w] this is a small  \GTC[d]   table            \NC     in which we \NC \FR +% \NC           will demonstrate \GFC[g:z] that this        \GTC[g] positioning \NC \MR +% \GSC[e:y]     mechanism also   \GTC[f]   works quite well \NC     in tables   \NC \LR +% \stoptabulate +% +% \starttabulate[|c|c|c|] +% \XC[+f:x] this is a small  \XC      table            \NC     in which we \NC \FR +% \NC      will demonstrate  \XC[+g:z] that this       \XC[-g] positioning \NC \MR +% \XC[=e:y] mechanism also   \XC[-f]  works quite well \NC     in tables   \NC \LR +% \stoptabulate +% +% \starttabulate[|c|c|c|] +% \XC[+f:x,+d:w] this is a small  \XC[-d]   table            \NC     in which we \NC \FR +% \NC            will demonstrate \XC[+g:z] that this        \XC[-g] positioning \NC \MR +% \XC[=e:y]       mechanism also  \XC[-f]   works quite well \NC     in tables   \NC \LR +% \stoptabulate + +% evt                  [b:x] +% +% \definepositionframed[x][background=color,fillcolor=red] +% \definepositionframed[y][background=color,fillcolor=green] +% \definepositionframed[z][background=color,fillcolor=blue] + +\def\remappositionframed#1#2% from to +  {\copyposition{b:#1}{b:#2}% +   \copyposition{e:#1}{e:#2}% +   \dosetpositionaction{b:#2}{\dopositionaction{b:#1}}} + +\unexpanded\def\definepositionframed +  {\dodoubleargument\dodefinepositionframed} + +\def\dodefinepositionframed[#1][#2]% +  {\dosetpositionaction{b:#1}{\dopositionframed[#1][#2]}} + +\def\positionframed +  {\dodoubleempty\dopositionframed} + +\def\dopositionframed[#1][#2]% +  {\bgroup +   \setbox\scratchbox\hbox +     {\dimen0=\MPx{e:#1}% +      \advance\dimen0 -\MPx{b:#1}% +      \dimen2=\MPy{b:#1}% +      \advance\dimen2 -\MPy{e:#1}% +      \advance\dimen2 \MPd{e:#1}% +      \lower\dimen2\hbox +        {\advance\dimen2 \MPh{b:#1}% +         \framed +           [\c!width=\dimen0,\c!height=\dimen2, +            \c!offset=\v!overlay,#2]{}}}% +   \smashedbox\scratchbox +   \egroup} + +% \def\sethdistances#1% +%   {\hbox{\lpos{ml:#1}\hpos{mh:#1}{\strut}\rpos{mr:#1}}} +% +% \def\gethdistances#1% +%   {\scratchdimen\MPx{mh:#1}% +%    \advance\scratchdimen -\MPx{ml#1}% +%    \edef\lefthdistance{\the\scratchdimen}% +%    \scratchdimen\MPx{mr:#1}% +%    \advance\scratchdimen -\MPx{mh:#1}% +%    \edef\righthdistance{\the\scratchdimen}} + +\protect \endinput diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 3a2639c96..f7de3a22c 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@  %C therefore copyrighted by \PRAGMA. See mreadme.pdf for  %C details. -\newcontextversion{2011.12.19 13:06} +\newcontextversion{2011.12.19 22:53}  %D This file is loaded at runtime, thereby providing an  %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 5ec1e118c..bc4d6bb5e 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@  %C therefore copyrighted by \PRAGMA. See mreadme.pdf for  %C details. -\newcontextversion{2011.12.19 13:06} +\newcontextversion{2011.12.19 22:53}  %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/context-version.pdf b/tex/context/base/context-version.pdfBinary files differ index f98f74e94..3442aa045 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.pngBinary files differ index b2123c564..250cdb7be 100644 --- a/tex/context/base/context-version.png +++ b/tex/context/base/context-version.png diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 53c21864e..6fa735c88 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@  %D your styles an modules.  \edef\contextformat {\jobname} -\edef\contextversion{2011.12.19 13:06} +\edef\contextversion{2011.12.19 22:53}  %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index ee8df8080..082abf664 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -20,7 +20,7 @@  %D your styles an modules.  \edef\contextformat {\jobname} -\edef\contextversion{2011.12.19 13:06} +\edef\contextversion{2011.12.19 22:53}  %D For those who want to use this: @@ -368,7 +368,9 @@  \loadmarkfile{page-plg}  \loadmarkfile{page-str} -\loadmarkfile{anch-pgr} % overloads tabl-tbl +\loadmarkfile{anch-pgr} % can be moved up (nicer for dependencies) +\loadmkvifile{anch-bck} +\loadmarkfile{anch-tab} % overloads tabl-tbl  \loadmarkfile{anch-bar}  \loadmarkfile{anch-snc} diff --git a/tex/context/base/m-educat.tex b/tex/context/base/m-educat.tex index f5d55fa84..93b1a6c5d 100644 --- a/tex/context/base/m-educat.tex +++ b/tex/context/base/m-educat.tex @@ -8,15 +8,15 @@  %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.  +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details.  %D This module will collect a few macros cq.\ definitions  %D meant for educational use. Most of the code has been laying  %D around for some time and has been (or is still) used in -%D \PRAGMA\ projects.  +%D \PRAGMA\ projects. -\unprotect  +\unprotect  \definesystemvariable{iv} @@ -28,10 +28,10 @@    [\c!location=\v!text,     \c!n=0,     \c!frame=\v!off, -   \c!framecolor=answerlinecolor,        +   \c!framecolor=answerlinecolor,     \c!rulethickness=2pt,     \c!background=\v!color, -   \c!backgroundcolor=answerareacolor,  +   \c!backgroundcolor=answerareacolor,     \c!alternative=2] % betweenline  % n=gedwongen @@ -48,23 +48,23 @@     \dontcomplain     \setupanswerarea       [\c!n=0,\c!m=,#1,\c!location=\v!text]% -   \doifelsenothing{\backgroundvariable\c!m} +   \doifelsenothing{\textbackgroundparameter\c!m}       {\expandafter\donoanswerspace}       {\expandafter\dodoanswerspace}%     [#1]}  \def\donoanswerspace[#1]#2%    {\setupthinrules -     [\c!alternative=\backgroundvariable\c!alternative, -      \c!color=\backgroundvariable\c!framecolor, -      \c!background=\backgroundvariable\c!background, -      \c!backgroundcolor=\backgroundvariable\c!backgroundcolor, -      \c!rulethickness=\backgroundvariable\c!rulethickness]% -   \doifelse{\backgroundvariable\c!n}{*} +     [\c!alternative=\textbackgroundparameter\c!alternative, +      \c!color=\textbackgroundparameter\c!framecolor, +      \c!background=\textbackgroundparameter\c!background, +      \c!backgroundcolor=\textbackgroundparameter\c!backgroundcolor, +      \c!rulethickness=\textbackgroundparameter\c!rulethickness]% +   \doifelse{\textbackgroundparameter\c!n}{*}       {\thinrule        \par} -     {\scratchcounter0\backgroundvariable\c!n\relax -      % tricky, guess   +     {\scratchcounter0\textbackgroundparameter\c!n\relax +      % tricky, guess        \def\processisolatedword##1%          {\setbox\scratchbox=\hbox{##1}%           \vbox{\hsize\wd\scratchbox\thinrule @@ -74,7 +74,7 @@             \vbox{\hsize\wd\scratchbox\thinrule}%           \fi}}%        \processisolatedwords{#2}\processisolatedword -      % so far  +      % so far        \ifcase\scratchcounter \else \ifnum\scratchcounter<3          \nobreak \vbox{\hsize\scratchcounter em\thinrule}%        \else % more @@ -87,11 +87,11 @@  \def\dodoanswerspace[#1]#2% m case    {\getvalue{\e!start\v!answerarea}%     #2% -   \doifelse{\backgroundvariable\c!m}{*} +   \doifelse{\textbackgroundparameter\c!m}{*}       {\hfill\strut        \getvalue{\e!stop\v!answerarea}%        \par} -     {\scratchcounter0\backgroundvariable\c!m\relax +     {\scratchcounter0\textbackgroundparameter\c!m\relax        \ifcase\scratchcounter \else \ifnum\scratchcounter<3          \nobreak \hbox to \scratchcounter em{\strut\hss}%        \else % more @@ -110,43 +110,43 @@     \dontcomplain     \setupanswerarea       [\c!n=0,\c!m=,#1,\c!location=\v!text]% -   \doifnot{\backgroundvariable\c!option}\v!joinedup\softbreak -   \doifelsenothing{\backgroundvariable\c!m} +   \doifnot{\textbackgroundparameter\c!option}\v!joinedup\softbreak +   \doifelsenothing{\textbackgroundparameter\c!m}       {\expandafter\donostartanswerlines}       {\expandafter\dodostartanswerlines}%     [#1]}  \def\donostartanswerlines[#1]%    {\setupthinrules -     [\c!alternative=\backgroundvariable\c!alternative, -      \c!color=\backgroundvariable\c!framecolor, -      \c!background=\backgroundvariable\c!background, -      \c!backgroundcolor=\backgroundvariable\c!backgroundcolor, -      \c!rulethickness=\backgroundvariable\c!rulethickness]% -   \thinrules[\c!n=\backgroundvariable\c!n]\par +     [\c!alternative=\textbackgroundparameter\c!alternative, +      \c!color=\textbackgroundparameter\c!framecolor, +      \c!background=\textbackgroundparameter\c!background, +      \c!backgroundcolor=\textbackgroundparameter\c!backgroundcolor, +      \c!rulethickness=\textbackgroundparameter\c!rulethickness]% +   \thinrules[\c!n=\textbackgroundparameter\c!n]\par     \endgroup     \grabuntil{\e!stop\e!answerlines}}  \def\dodostartanswerlines[#1]% -  {\begingroup     +  {\begingroup     \getvalue{\e!start\v!answerarea}%     \ignorespaces} -\setvalue{\e!stop\e!answerlines}%  -  {\scratchcounter0\backgroundvariable\c!m\relax -   % a \softbreak is more efficient in pos dan \par  +\setvalue{\e!stop\e!answerlines}% +  {\scratchcounter0\textbackgroundparameter\c!m\relax +   % a \softbreak is more efficient in pos dan \par     \ifcase\scratchcounter       % nothing     \or -     \softbreak  +     \softbreak     \else -     \softbreak  +     \softbreak       \advance \scratchcounter \minusone       \dorecurse\scratchcounter{\strut\hfill\strut\softbreak}%     \fi     \strut\hfill\strut     \getvalue{\e!stop\v!answerarea}% -   \par\endgroup\endgroup}  +   \par\endgroup\endgroup}  \setvalue\e!answerlines    {\dosingleempty\doanswerlines} @@ -174,19 +174,19 @@ test test test \answerspace [n=10] {Whow}. test test test  test tets test test \answerspace [n=10] {Whow}. test test  test test tets test test \answerspace [n=10] {Whow}. test  test test test tets test test \answerspace [n=10] {Whow}. -test test test test test test \answerspace [n=*] {Whow.}  +test test test test test test \answerspace [n=*] {Whow.}  test test test test test test test \startanswerlines -[n=3] What A Junk Answer \stopanswerlines  +[n=3] What A Junk Answer \stopanswerlines  test test test test test test test \startanswerlines -[n=3,alternative=0] What A Junk Answer \stopanswerlines  +[n=3,alternative=0] What A Junk Answer \stopanswerlines  test test test test test test test \startanswerlines -[n=3,alternative=1] What A Junk Answer \stopanswerlines  +[n=3,alternative=1] What A Junk Answer \stopanswerlines  test test test test test test test \startanswerlines -[n=3,alternative=2] What A Junk Answer \stopanswerlines  +[n=3,alternative=2] What A Junk Answer \stopanswerlines  \startitemize[paragraph]  \item \startanswerlines [option=seried,n=2] xxx \stopanswerlines @@ -196,20 +196,20 @@ test test test \answerspace [m=10] {Whow}. test test test  test tets test test \answerspace [m=10] {Whow}. test test  test test tets test test \answerspace [m=10] {Whow}. test  test test test tets test test \answerspace [m=10] {Whow}. -test test test test test test \answerspace [m=*] {Whow.}  +test test test test test test \answerspace [m=*] {Whow.}  test test test test test test test \startanswerlines -[m=2] What A Junk Answer \stopanswerlines  +[m=2] What A Junk Answer \stopanswerlines  test test test test test test test \startanswerlines -[m=2,alternative=0] What A Junk Answer \stopanswerlines  -  +[m=2,alternative=0] What A Junk Answer \stopanswerlines +  test test test test test test test \startanswerlines -[m=2,alternative=1] What A Junk Answer \stopanswerlines  +[m=2,alternative=1] What A Junk Answer \stopanswerlines  test test test test test test test \startanswerlines -[m=2,alternative=2] What A Junk Answer \stopanswerlines  -  +[m=2,alternative=2] What A Junk Answer \stopanswerlines +  \startitemize[paragraph]  \item \startanswerlines [option=seried,m=2] xxx \stopanswerlines  \stopitemize diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv index 19051e872..2b72ab3d7 100644 --- a/tex/context/base/meta-pag.mkiv +++ b/tex/context/base/meta-pag.mkiv @@ -23,64 +23,64 @@  %D pagebody looks.  \startMPextensions -  boolean PageStateAvailable,OnRightPage,InPageBody; -  PageStateAvailable:=true; +    boolean PageStateAvailable,OnRightPage,InPageBody; +    PageStateAvailable:=true;  \stopMPextensions  \startMPinitializations -  OnRightPage:=true; -  InPageBody:=\ifinpagebody true \else false \fi; +    OnRightPage:=true; +    InPageBody:=\ifinpagebody true \else false \fi;  \stopMPinitializations  \startMPinitializations -  def LoadPageState = -    OnRightPage:=\MPonrightpage; -    OnOddPage:=\MPonoddpage; -    RealPageNumber:=\the\realpageno; -    PageNumber:=\the\pageno; -    NOfPages:=\lastpage; -    PaperHeight:=\the\paperheight; -    PaperWidth:=\the\paperwidth; -    PrintPaperHeight:=\the\printpaperheight; -    PrintPaperWidth:=\the\printpaperwidth; -    TopSpace:=\the\topspace; -    BottomSpace:=\the\bottomspace; -    BackSpace:=\the\backspace; -    CutSpace:=\the\cutspace; -    MakeupHeight:=\the\makeupheight; -    MakeupWidth:=\the\makeupwidth; -    TopHeight:=\the\topheight; -    TopDistance:=\the\topdistance; -    HeaderHeight:=\the\headerheight; -    HeaderDistance:=\the\headerdistance; -    TextHeight:=\the\textheight; -    FooterDistance:=\the\footerdistance; -    FooterHeight:=\the\footerheight; -    BottomDistance:=\the\bottomdistance; -    BottomHeight:=\the\bottomheight; -    LeftEdgeWidth:=\the\leftedgewidth; -    LeftEdgeDistance:=\the\leftedgedistance; -    LeftMarginWidth:=\the\leftmarginwidth; -    LeftMarginDistance:=\the\leftmargindistance; -    TextWidth:=\the\textwidth ; -    RightMarginDistance:=\the\rightmargindistance; -    RightMarginWidth:=\the\rightmarginwidth; -    RightEdgeDistance:=\the\rightedgedistance; -    RightEdgeWidth:=\the\rightedgewidth; -    InnerMarginDistance:=\the\innermargindistance; -    InnerMarginWidth:=\the\innermarginwidth; -    OuterMarginDistance:=\the\outermargindistance; -    OuterMarginWidth:=\the\outermarginwidth; -    InnerEdgeDistance:=\the\inneredgedistance; -    InnerEdgeWidth:=\the\inneredgewidth; -    OuterEdgeDistance:=\the\outeredgedistance; -    OuterEdgeWidth:=\the\outeredgewidth; -    PageOffset:=\the\pageoffset; -    PageDepth:=\the\pagedepth; -    LayoutColumns:=\the\layoutcolumns; -    LayoutColumnDistance:=\the\layoutcolumndistance; -    LayoutColumnWidth:=\the\layoutcolumnwidth; -  enddef; +    def LoadPageState = +        OnRightPage:=\MPonrightpage; +        OnOddPage:=\MPonoddpage; +        RealPageNumber:=\the\realpageno; +        PageNumber:=\the\pageno; +        NOfPages:=\lastpage; +        PaperHeight:=\the\paperheight; +        PaperWidth:=\the\paperwidth; +        PrintPaperHeight:=\the\printpaperheight; +        PrintPaperWidth:=\the\printpaperwidth; +        TopSpace:=\the\topspace; +        BottomSpace:=\the\bottomspace; +        BackSpace:=\the\backspace; +        CutSpace:=\the\cutspace; +        MakeupHeight:=\the\makeupheight; +        MakeupWidth:=\the\makeupwidth; +        TopHeight:=\the\topheight; +        TopDistance:=\the\topdistance; +        HeaderHeight:=\the\headerheight; +        HeaderDistance:=\the\headerdistance; +        TextHeight:=\the\textheight; +        FooterDistance:=\the\footerdistance; +        FooterHeight:=\the\footerheight; +        BottomDistance:=\the\bottomdistance; +        BottomHeight:=\the\bottomheight; +        LeftEdgeWidth:=\the\leftedgewidth; +        LeftEdgeDistance:=\the\leftedgedistance; +        LeftMarginWidth:=\the\leftmarginwidth; +        LeftMarginDistance:=\the\leftmargindistance; +        TextWidth:=\the\textwidth ; +        RightMarginDistance:=\the\rightmargindistance; +        RightMarginWidth:=\the\rightmarginwidth; +        RightEdgeDistance:=\the\rightedgedistance; +        RightEdgeWidth:=\the\rightedgewidth; +        InnerMarginDistance:=\the\innermargindistance; +        InnerMarginWidth:=\the\innermarginwidth; +        OuterMarginDistance:=\the\outermargindistance; +        OuterMarginWidth:=\the\outermarginwidth; +        InnerEdgeDistance:=\the\inneredgedistance; +        InnerEdgeWidth:=\the\inneredgewidth; +        OuterEdgeDistance:=\the\outeredgedistance; +        OuterEdgeWidth:=\the\outeredgewidth; +        PageOffset:=\the\pageoffset; +        PageDepth:=\the\pagedepth; +        LayoutColumns:=\the\layoutcolumns; +        LayoutColumnDistance:=\the\layoutcolumndistance; +        LayoutColumnWidth:=\the\layoutcolumnwidth; +    enddef;  \stopMPinitializations  \def\MPonrightpage{true} @@ -139,83 +139,94 @@  \newif\iftracetextareas -\def\registerMPtextarea#1% -  {\ifpositioning -     \bgroup -     \global\advance\currentMPtextareadata\plusone -    %\hpos{gbd:\the\currentMPtextareadata}{#1}% -     \hpos{gbd:\the\currentMPtextareadata}% -       {\iftracetextareas\boxrulewidth1.5pt\ruledhbox\fi{#1}}% -     \edef\!!stringa{gbd:\the\currentMPtextareadata}% -     \edef\!!stringa{RegisterTextArea(% -       \MPx\!!stringa,\MPy\!!stringa,% -       \MPw\!!stringa,\MPh\!!stringa,\MPd\!!stringa);}% -     \@EA \doglobal \@EA \appendtoks \!!stringa \to \MPtextareadata -     \egroup -   \else -     \hbox{#1}% -   \fi} - -\def\registerMPlocaltextarea#1% -  {\ifpositioning -     \bgroup -     \global\advance\currentMPtextareadata\plusone -    %\hpos{gbd:\the\currentMPtextareadata}{#1}% -     \hpos{gbd:\the\currentMPtextareadata}% -       {\iftracetextareas\boxrulewidth3pt\ruledhbox\fi{#1}}% -     \edef\!!stringa{gbd:\the\currentMPtextareadata}% -     \edef\!!stringa{RegisterLocalTextArea(% -       \MPx\!!stringa,\MPy\!!stringa,% -       \MPw\!!stringa,\MPh\!!stringa,\MPd\!!stringa);}% -     \global\MPlocaltextareadata\@EA{\!!stringa}% -     \egroup -   \else -     \hbox{#1}% -   \fi} +% \def\registerMPtextarea#1% +%   {\ifpositioning +%      \bgroup +%      \global\advance\currentMPtextareadata\plusone +%     %\hpos{gbd:\the\currentMPtextareadata}{#1}% +%      \hpos{gbd:\the\currentMPtextareadata}% +%        {\iftracetextareas\boxrulewidth1.5pt\ruledhbox\fi{#1}}% +%      \edef\!!stringa{gbd:\the\currentMPtextareadata}% +%      \edef\!!stringa{RegisterTextArea(% +%        \MPx\!!stringa,\MPy\!!stringa,% +%        \MPw\!!stringa,\MPh\!!stringa,\MPd\!!stringa);}% +%      \@EA \doglobal \@EA \appendtoks \!!stringa \to \MPtextareadata +%      \egroup +%    \else +%      \hbox{#1}% +%    \fi} -% better, so that we can force a key and share with e.g. renumbering -% -% \let\namedtextarea\empty -%  % \def\registerMPlocaltextarea#1%  %   {\ifpositioning  %      \bgroup -%      \ifx\namedtextarea\empty -%        \global\advance\currentMPtextareadata\plusone -%        \edef\namedtextarea{gbd:\the\currentMPtextareadata}% -%      \fi -%      \hpos\namedtextarea{\iftracetextareas\boxrulewidth3pt\ruledhbox\fi{#1}}% -%      \edef\ascii{RegisterLocalTextArea(% -%        \MPx\namedtextarea,\MPy\namedtextarea,% -%        \MPw\namedtextarea,\MPh\namedtextarea,\MPd\namedtextarea);}% -%      \global\MPlocaltextareadata\@EA{\ascii}% +%      \global\advance\currentMPtextareadata\plusone +%     %\hpos{gbd:\the\currentMPtextareadata}{#1}% +%      \hpos{gbd:\the\currentMPtextareadata}% +%        {\iftracetextareas\boxrulewidth3pt\ruledhbox\fi{#1}}% +%      \edef\!!stringa{gbd:\the\currentMPtextareadata}% +%      \edef\!!stringa{RegisterLocalTextArea(% +%        \MPx\!!stringa,\MPy\!!stringa,% +%        \MPw\!!stringa,\MPh\!!stringa,\MPd\!!stringa);}% +%      \global\MPlocaltextareadata\@EA{\!!stringa}%  %      \egroup  %    \else  %      \hbox{#1}%  %    \fi} +\def\globalregisterMPtextarea{\normalexpanded{\global\MPtextareadata{\the\MPtextareadata +  RegisterTextArea(% +   \MPx\currentMPtextarea,% +   \MPy\currentMPtextarea,% +   \MPw\currentMPtextarea,% +   \MPh\currentMPtextarea,% +   \MPd\currentMPtextarea% +  );}}} + +\def\localregisterMPtextarea{\normalexpanded{\global\MPlocaltextareadata{% +  RegisterLocalTextArea(% +   \MPx\currentMPtextarea,% +   \MPy\currentMPtextarea,% +   \MPw\currentMPtextarea,% +   \MPh\currentMPtextarea,% +   \MPd\currentMPtextarea% +  );}}} + +\def\registerMPtextareaindeed#1#2% +  {\ifpositioning +     \begingroup +     \global\advance\currentMPtextareadata\plusone +     \edef\currentMPtextarea{gbd:\the\currentMPtextareadata}% +     \hpos\currentMPtextarea{\iftracetextareas\boxrulewidth1.5pt\ruledhbox\fi{#2}}% +     #1% +     \endgroup +   \else +     \hbox{#2}% +   \fi} + +\def\registerMPtextarea     {\registerMPtextareaindeed\globalregisterMPtextarea} +\def\registerMPlocaltextarea{\registerMPtextareaindeed\localregisterMPtextarea }  \def\resetMPlocaltextarea    {\global\MPlocaltextareadata\emptytoks}  \startMPextensions -   path PlainTextArea; +    path PlainTextArea;  \stopMPextensions  \startMPinitializations -  ResetTextAreas; -  \the\MPsavedtextareadata; -  SaveTextAreas; -  ResetTextAreas; -  \the\MPtextareadata; -  \the\MPlocaltextareadata; -  PlainTextArea:=boundingbox(\MPxy{text:\realfolio}--\MPxy{text:\realfolio} -    shifted (\MPw{text:\realfolio},\MPh{text:\realfolio})); +    ResetTextAreas; +    \the\MPsavedtextareadata; +    SaveTextAreas; +    ResetTextAreas; +    \the\MPtextareadata; +    \the\MPlocaltextareadata; +    PlainTextArea:=boundingbox(\MPxy{text:\realfolio}--\MPxy{text:\realfolio} +        shifted (\MPw{text:\realfolio},\MPh{text:\realfolio}));  \stopMPinitializations  \appendtoks -  \global\MPsavedtextareadata\MPtextareadata -  \global\MPtextareadata     \emptytoks -  \global\MPlocaltextareadata\emptytoks +    \global\MPsavedtextareadata\MPtextareadata +    \global\MPtextareadata     \emptytoks +    \global\MPlocaltextareadata\emptytoks  \to \everyshipout  \protect \endinput diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua index 40339c442..23a4a08b5 100644 --- a/tex/context/base/mult-def.lua +++ b/tex/context/base/mult-def.lua @@ -6452,6 +6452,10 @@ return {    ["buffer"]={     ["en"]="buffer",    }, +  ["dash"]={ +    ["en"]="dash", +    ["nl"]="streep", +  },    ["labeloffset"]={     ["en"]="labeloffset",    }, diff --git a/tex/context/base/page-bck.mkiv b/tex/context/base/page-bck.mkiv index 31d440771..08bf8958b 100644 --- a/tex/context/base/page-bck.mkiv +++ b/tex/context/base/page-bck.mkiv @@ -177,8 +177,8 @@  \def\page_backgrounds_add_to_paper#1%    {\doifbothsidesoverruled -     {\page_backgrounds_add_to_box\v!rightpage#1\paperwidth\paperheight} -     {\page_backgrounds_add_to_box\v!rightpage#1\paperwidth\paperheight} +     {\page_backgrounds_add_to_box\v!rightpage#1\paperwidth\paperheight}% +     {\page_backgrounds_add_to_box\v!rightpage#1\paperwidth\paperheight}%       {\page_backgrounds_add_to_box\v!leftpage #1\paperwidth\paperheight}%     \page_backgrounds_add_to_box\v!page#1\paperwidth\paperheight} @@ -188,8 +188,8 @@  %D only recalculated when they change or when the \type  %D {status} is set to \type {repeat}. -\newbox\leftbackground -\newbox\rightbackground +\newbox\leftbackground  % todo: rename +\newbox\rightbackground % todo: rename  %D Finaly there is an aditional {\em text} background, again  %D useful for special purposes only. This one is calculated @@ -328,6 +328,88 @@  \newconditional\swapbackgroundmargins \settrue\swapbackgroundmargins +% \def\page_backgrounds_set_box#1% #2% +%   {\global\setbox#1\vbox +%      {\dontcomplain +%       \swapmargins +%       \ifconditional\swapbackgroundmargins +%         \doifmarginswapelse \donothing +%           {\swapmacros\v!rightmargin\v!leftmargin +%            \swapmacros\v!rightedge  \v!leftedge}% +%       \fi +%       \calculatereducedvsizes +%       \offinterlineskip +%     % \ifconditional#2\relax +%     %   \doswapmargins % hm, this one gets nilled in \swapmargins anyway +%     % \fi +%       \vskip\dimexpr-\topheight-\topdistance\relax +%       \ifdim\topheight>\zeropoint +%         \page_backgrounds_set_box_row\v!top\topheight +%       \fi +%       \vskip\topdistance +%       \ifdim\headerheight>\zeropoint +%         \page_backgrounds_set_box_row\v!header\headerheight +%       \fi +%       \vskip\headerdistance +%       \ifdim\textheight>\zeropoint +%         \page_backgrounds_set_box_row\v!text\textheight +%       \fi +%       \vskip\footerdistance +%       \ifdim\footerheight>\zeropoint +%         \page_backgrounds_set_box_row\v!footer\footerheight +%       \fi +%       \vskip\bottomdistance +%       \ifdim\bottomheight>\zeropoint +%         \page_backgrounds_set_box_row\v!bottom\bottomheight +%       \fi +%       \vfilll}% +%   \smashbox#1} + +% \def\page_backgrounds_set_box_row#1#2% maybe helper +%   {\setbox\scratchbox\vbox to #2 +%      \bgroup\hbox\bgroup +%        \goleftonpage +%        \ifdim\leftedgewidth>\zeropoint +%          \ifcsname\??ma#1\v!leftedge\endcsname +%            \page_backgrounds_set_box_cell#1\v!leftedge\leftedgewidth#2% +%          \else +%            \hskip\leftedgewidth +%          \fi +%        \fi +%        \hskip\leftedgedistance +%        \ifdim\leftmarginwidth>\zeropoint +%          \ifcsname\??ma#1\v!leftmargin\endcsname +%            \page_backgrounds_set_box_cell#1\v!leftmargin\leftmarginwidth#2% +%          \else +%            \hskip\leftmarginwidth +%          \fi +%        \fi +%        \hskip\leftmargindistance +%        \ifcsname\??ma#1\v!text\endcsname +%          \page_backgrounds_set_box_cell#1\v!text\makeupwidth#2% +%        \else +%          \hskip\makeupwidth +%        \fi +%        \hskip\rightmargindistance +%        \ifdim\rightmarginwidth>\zeropoint +%          \ifcsname\??ma#1\v!rightmargin\endcsname +%            \page_backgrounds_set_box_cell#1\v!rightmargin\rightmarginwidth#2% +%          \else +%            \hskip\rightmarginwidth +%          \fi +%        \fi +%        \hskip\rightedgedistance +%        \ifdim\rightedgewidth>\zeropoint +%          \ifcsname\??ma#1\v!rightedge\endcsname +%            \page_backgrounds_set_box_cell#1\v!rightedge\rightedgewidth#2% +%          \else +%            \hskip\rightedgewidth +%          \fi +%        \fi +%      \egroup\egroup +%    \wd\scratchbox\zeropoint +%    \box\scratchbox\relax} +  \def\page_backgrounds_set_box#1% #2%    {\global\setbox#1\vbox       {\dontcomplain @@ -342,28 +424,28 @@      % \ifconditional#2\relax      %   \doswapmargins % hm, this one gets nilled in \swapmargins anyway      % \fi -      \vskip\dimexpr-\topheight-\topdistance\relax        \ifdim\topheight>\zeropoint +        \kern\dimexpr-\topheight-\topdistance\relax          \page_backgrounds_set_box_row\v!top\topheight +        \kern\topdistance        \fi -      \vskip\topdistance        \ifdim\headerheight>\zeropoint          \page_backgrounds_set_box_row\v!header\headerheight +        \kern\headerdistance        \fi -      \vskip\headerdistance        \ifdim\textheight>\zeropoint          \page_backgrounds_set_box_row\v!text\textheight        \fi -      \vskip\footerdistance        \ifdim\footerheight>\zeropoint +        \kern\footerdistance          \page_backgrounds_set_box_row\v!footer\footerheight        \fi -      \vskip\bottomdistance        \ifdim\bottomheight>\zeropoint +        \kern\bottomdistance          \page_backgrounds_set_box_row\v!bottom\bottomheight        \fi        \vfilll}% -  \smashbox#1} +   \smashbox#1}  \def\page_backgrounds_set_box_row#1#2% maybe helper    {\setbox\scratchbox\vbox to #2 @@ -373,37 +455,37 @@           \ifcsname\??ma#1\v!leftedge\endcsname             \page_backgrounds_set_box_cell#1\v!leftedge\leftedgewidth#2%           \else -           \hskip\leftedgewidth +           \kern\leftedgewidth           \fi +         \kern\leftedgedistance         \fi -       \hskip\leftedgedistance         \ifdim\leftmarginwidth>\zeropoint           \ifcsname\??ma#1\v!leftmargin\endcsname             \page_backgrounds_set_box_cell#1\v!leftmargin\leftmarginwidth#2%           \else -           \hskip\leftmarginwidth +           \kern\leftmarginwidth           \fi +         \kern\leftmargindistance         \fi -       \hskip\leftmargindistance         \ifcsname\??ma#1\v!text\endcsname           \page_backgrounds_set_box_cell#1\v!text\makeupwidth#2%         \else -         \hskip\makeupwidth +         \kern\makeupwidth         \fi -       \hskip\rightmargindistance         \ifdim\rightmarginwidth>\zeropoint +         \kern\rightmargindistance           \ifcsname\??ma#1\v!rightmargin\endcsname             \page_backgrounds_set_box_cell#1\v!rightmargin\rightmarginwidth#2%           \else -           \hskip\rightmarginwidth +           \kern\rightmarginwidth           \fi         \fi -       \hskip\rightedgedistance         \ifdim\rightedgewidth>\zeropoint +         \kern\rightedgedistance           \ifcsname\??ma#1\v!rightedge\endcsname             \page_backgrounds_set_box_cell#1\v!rightedge\rightedgewidth#2%           \else -           \hskip\rightedgewidth +           \kern\rightedgewidth           \fi         \fi       \egroup\egroup diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv index edf82834d..6497ba657 100644 --- a/tex/context/base/page-imp.mkiv +++ b/tex/context/base/page-imp.mkiv @@ -105,7 +105,7 @@     \deadcycles\zerocount     \endgroup} -\def\page_otr_flush_every_stuff % this will become obsolete ... was backend related +\def\page_otr_flush_every_stuff    {\begingroup     \setbox\scratchbox\hbox       {% before the main one ! @@ -161,9 +161,15 @@     \fi}  \def\page_shipouts_arrange#1% -  {\setbox\scratchbox\hbox{#1}% +  {% \global\advance\shippedoutpages\plusone +   \begingroup +   \setbox\scratchbox\hbox +     {\page_otr_flush_every_stuff +      \page_otr_flush_special_content +      \box\shipoutscratchbox}%     \pusharrangedpage\scratchbox -   \deadcycles\zerocount} +   \deadcycles\zerocount +   \endgroup}  %D We need a couple of boxes for duplex printing \unknown diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index b8e419a79..253c8419b 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -402,7 +402,7 @@        \ifcase\pageornamentstate          \page_backgrounds_add_to_paper    \pagebox        \fi -      \registerpageposition               \pagebox +      \positions_register_page            \pagebox        \ifarrangingpages          \page_boxes_apply_shift_paper     \pagebox % \v!paper        \else diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv index e30d76245..e397e2c78 100644 --- a/tex/context/base/page-lay.mkiv +++ b/tex/context/base/page-lay.mkiv @@ -367,12 +367,25 @@       \page_paper_restore     \fi} -\unexpanded\def\setup_paper_size_settings[#1]% +\unexpanded\def\setup_paper_size_settings[#1]% sometimes used to set paper/print size    {\let\currentlayouttarget\empty +   \edef\tmp_layouttarget_paper_saved{\page_paper_the_paper_size{\layouttargetparameter\c!page }}% +   \edef\tmp_layouttarget_print_saved{\page_paper_the_print_size{\layouttargetparameter\c!paper}}%     \setupcurrentlayouttarget[#1]%     \edef\tmp_layouttarget_paper{\page_paper_the_paper_size{\layouttargetparameter\c!page }}%     \edef\tmp_layouttarget_print{\page_paper_the_print_size{\layouttargetparameter\c!paper}}% -   \ifx\tmp_layouttarget_paper\empty +   \ifx\tmp_layouttarget_paper_saved\tmp_layouttarget_paper +     \ifx\tmp_layouttarget_print_saved\tmp_layouttarget_print +       % we didn't change the size, maybe only sx or sy or so +     \else +       \setup_paper_size_settings_recalibrate +     \fi +   \else +     \setup_paper_size_settings_recalibrate +   \fi} + +\def\setup_paper_size_settings_recalibrate +  {\ifx\tmp_layouttarget_paper\empty       % forget about it     \else       \ifx\tmp_layouttarget_print\empty @@ -822,9 +835,9 @@        \begingroup % needed ?        \uselayoutstyleandcolor\c!style\c!color        \offinterlineskip -      \gettextboxes +      \page_insert_elements % zero size        \endgroup -      \getmainbox#1#2}}% including footnotes +      \page_insert_body#1#2}}% including footnotes  \installlayoutalternative\v!default{\page_boxes_construct_content_default}  \installlayoutalternative\v!normal {\page_boxes_construct_content_default} diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi index 86415c6ed..bf4c3c40b 100644 --- a/tex/context/base/page-txt.mkvi +++ b/tex/context/base/page-txt.mkvi @@ -648,14 +648,6 @@  \appendtoks \placerightmarginblock \hskip-\rightmarginwidth \to \rightmargintextcontent  \appendtoks \placeleftmarginblock  \hskip-\leftmarginwidth  \to \leftmargintextcontent -%D The next hook will later be used for keeping track of -%D positions, i.e.\ it will provide a proper (page -%D dependent) reference point. - -\ifx\undefined\placepositionanchors -  \unexpanded\def\placepositionanchors{\vskip\textheight} -\fi -  %D \macros  %D   {definetext}  %D @@ -823,7 +815,7 @@  \newbox\layout_element_box -\def\gettextboxes % will become \place_layout_elements +\def\page_insert_elements    {\ifcase\pageornamentstate       \place_layout_elements_indeed     \fi} @@ -839,7 +831,7 @@        \vskip\dimexpr\topheight+\topdistance\relax        \the\headertextcontent        \vskip\dimexpr\headerheight+\headerdistance\relax -      \placepositionanchors +      \positions_place_anchors        \vskip-\textheight        \the\texttextcontent        \vskip\textheight @@ -853,7 +845,7 @@    \smashbox\layout_element_box    \box\layout_element_box} -\def\getmainbox#1#2% +\def\page_insert_body#1#2%    {\setbox\layout_element_box\vbox       {\offinterlineskip        \calculatereducedvsizes @@ -862,37 +854,35 @@        \vskip\dimexpr\headerheight+\headerdistance+\layoutparameter\c!textdistance\relax        \dontleavehmode        \hbox to \makeupwidth -        {\bgroup +        {\begingroup             \swapmargins             \goleftonpage             \ifdim\leftedgewidth>\zeropoint               \the\leftedgetextcontent -             \hskip\leftedgewidth +             \kern\dimexpr\leftedgewidth+\leftedgedistance\relax             \fi -           \hskip\leftedgedistance             \ifdim\leftmarginwidth>\zeropoint               \the\leftmargintextcontent -             \hskip\leftmarginwidth +             \kern\dimexpr\leftmarginwidth+\leftmargindistance\relax             \fi -           \hskip\leftmargindistance -         \egroup +         \endgroup           \mkprocesspagecontents{#2}%           \settextpagecontent\layout_element_box{#1}{#2}%           \page_backgrounds_add_to_text\layout_element_box           \page_grids_add_to_box\layout_element_box           \box\layout_element_box -         \bgroup -           \hskip\rightmargindistance +         \begingroup             \ifdim\rightmarginwidth>\zeropoint +             \kern\rightmargindistance               \the\rightmargintextcontent -             \hskip\rightmarginwidth +             \kern\rightmarginwidth             \fi -           \hskip\rightedgedistance             \ifdim\rightedgewidth>\zeropoint +             \kern\rightedgedistance               \the\rightedgetextcontent -             \hskip\rightedgewidth +             \kern\rightedgewidth             \fi -         \egroup +         \endgroup           \hss}}%     \smashbox\layout_element_box     \box\layout_element_box} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdfBinary files differ index ea308c0b2..a8c4bbdea 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdfBinary files differ index 0ce87fb5b..69c47e279 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index cf6c04991..a9d47903a 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -449,7 +449,7 @@          \dotabulatepostskip{\the\tabulateposskip}%          \alignmark\alignmark     }}% -   \tabulatedummy{\the\tabulatedummy\NC}% +   \tabulatedummy\expandafter{\the\tabulatedummy\NC}%     \tabulatepreskip.5\tabulateunit\relax     \ifnum\tabulatecolumns<\numexpr\noftabulatecolumns-\plusone\relax       \tabulateposskip\tabulatepreskip diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 748d476de..bc4c88c4b 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@  -- merged file : luatex-fonts-merged.lua  -- parent file : luatex-fonts.lua --- merge date  : 12/19/11 13:06:43 +-- merge date  : 12/19/11 22:53:48  do -- begin closure to overcome local limits and interference | 
