On 1/13/2013 7:06 PM, Wolfgang Schuster wrote:
what’s your opinion to redefine the leaders command to take a optional name which loads a predefined setup?
We should avoid redefining a primitive (esp one that is used in math).
<code> % use \doifsymbolelse for the symbol key?
\unprotect
\installcorenamespace{leaders} \installcorenamespace{leadersalternative}
\installdefinehandler \??leaders {leaders} \??leaders \installparameterhandler \??leaders {leaders} \installsetuphandler \??leaders {leaders}
\def\leaders {\doifnextoptionalelse\leaders_indeed\normalleaders}
\def\leaders_indeed[#1]% {\def\currentleaders{#1}% \expandcheckedcsname\??leadersalternative{\leadersparameter\c!alternative}\s!default}
\setvalue{\??leadersalternative\s!default}% {\leadersparameter\c!left \normalleaders\hbox to \leadersparameter\c!width{\hss\leadersparameter\c!symbol\hss}\hfill \leadersparameter\c!right}
\setvalue{\??leadersalternative\s!default}% {\leadersparameter\c!left \normalleaders\hbox to \leadersparameter\c!width{\hss\leadersparameter\c!symbol\hss}\hfill \leadersparameter\c!right}
\setvalue{\??leadersalternative\v!global}% {\leadersparameter\c!left \normalgleaders\hbox to \leadersparameter\c!width{\hss\leadersparameter\c!symbol\hss}\hfill \leadersparameter\c!right}
\setupleaders [\c!width=1em, \c!symbol=., \c!alternative=\s!default]
\protect
\defineleaders[test]%[symbol=x]
\starttext
text\leaders\hbox to 1em{\hss .\hss}\hfill text
text\leaders[test]text
\stoptext </code>
This method would be cleaner for user defined list layouts where one want to change the filler between the text and the page number because a setup like this isn’t something for a normal user.
As we have a few more leader primitives, I generalized your code a bit and also made the box alignment configurable: \installcorenamespace{fillers} \installcorenamespace{fillersalternative} \installcommandhandler \??fillers {fillers} \??fillers \unexpanded\def\fillers {\dosingleempty\spac_fillers_indeed} \def\spac_fillers_indeed[#1]% {\begingroup \edef\currentleaders{#1}% \fillersparameter\c!left \expandcheckedcsname\??fillersalternative{\fillersparameter\c!alternative}\v!local \simplealignedbox {\fillersparameter\c!width}% {\fillersparameter\c!align}% {\fillersparameter\c!symbol}% \hfill \fillersparameter\c!right \endgroup} \letvalue{\??fillersalternative\s!local }\normalleaders % overflow ends up inbetween (current box) \letvalue{\??fillersalternative\v!global }\normalgleaders % overflow ends up inbetween (outermost box) \letvalue{\??fillersalternative\v!middle }\normalcleaders % overflow ends up before, after (current box) \letvalue{\??fillersalternative\v!broad }\normalxleaders % overflow ends up before, inbetween, after (current box) \setupfillers [\c!width=\emwidth, \c!symbol=., \c!align=\v!middle, \c!alternative=\s!local] \protect \definefillers[test][symbol=!] \starttext text\leaders\hbox to 1em{\hss .\hss}\hfill text text\fillers[test]text \stoptext
<code source="strc-lst.mkvi"> \definelistalternative [c] [\c!distance=5em, \c!width=0pt, \c!stretch=10em, \c!filler=\hskip.5em\gleaders\hbox to .5em{\hss.\hss}\hfill\hskip.5em\relax, \c!renderingsetup=\??listrenderings:abc] </code>
before we add this kind of code, how about a more extensive mechanism so that we can say filler=periods for this we need to generalize the above even more i.e. we could have: alternative=rule (height width depth) alternative=box (the leaders) alternative=stretch (hfill and then methods, for leaders, so now we get: \unprotect \installcorenamespace{fillers} \installcorenamespace{fillersalternative} \installcorenamespace{fillersleadermethod} \installcommandhandler \??fillers {fillers} \??fillers \unexpanded\def\fillers {\dosingleempty\spac_fillers_indeed} \def\spac_fillers_indeed[#1]% {\begingroup \edef\currentfillers{#1}% \scratchdimen\fillersparameter\c!leftmargin\relax \ifdim\scratchdimen=\zeropoint\else \hskip\scratchdimen \fi \fillersparameter\c!left\relax \getvalue{\??fillersalternative\fillersparameter\c!alternative}\relax \fillersparameter\c!right\relax \scratchdimen\fillersparameter\c!rightmargin\relax \ifdim\scratchdimen=\zeropoint\else \hskip\scratchdimen \fi \endgroup} \setvalue{\??fillersalternative\s!box}% {\expandcheckedcsname\??fillersleadermethod{\fillersparameter\c!method}\v!local \simplealignedbox {\fillersparameter\c!width}% {\fillersparameter\c!align}% {\fillersparameter\c!symbol}% \hfill} \setvalue{\??fillersalternative\c!stretch}% {\hfill} \setvalue{\??fillersalternative\c!rule}% {\expandcheckedcsname\??fillersleadermethod{\fillersparameter\c!method}\v!local \hrule \!!height\fillersparameter\c!height \!!depth \fillersparameter\c!depth \hfill} \letvalue{\??fillersleadermethod\s!local }\normalleaders % overflow ends up inbetween (current box) \letvalue{\??fillersleadermethod\v!global}\normalgleaders % overflow ends up inbetween (outermost box) \letvalue{\??fillersleadermethod\v!middle}\normalcleaders % overflow ends up before, after (current box) \letvalue{\??fillersleadermethod\v!broad }\normalxleaders % overflow ends up before, inbetween, after (current box) \setupfillers [\c!width=\emwidth, \c!symbol=., \c!align=\v!middle, \c!height=.1\exheight, \c!depth=\zeropoint, \c!leftmargin=\zeropoint, \c!rightmargin=\zeropoint, \c!alternative=\s!box, \c!method=\s!local] % maybe box -> symbol \protect \definefillers[test-a][alternative=stretch] \definefillers[test-b][alternative=box,symbol=!] \definefillers[test-c][alternative=rule,height=.1ex,leftmargin=.5em,rightmargin=.25em] \starttext text\leaders\hbox to 1em{\hss .\hss}\hfill text text\fillers[test-a]text text\fillers[test-b]text text\fillers[test-c]text \stoptext maybe box should be symbol (no \v!symbol yet) maybe some more tricks can be added Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------