summaryrefslogtreecommitdiff
path: root/tex/context/base/spac-flr.mkiv
blob: d09a9cf79f35b966e70aa1af1a7620926450e9d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
%D \module
%D   [       file=spac-fil,
%D        version=2013.01.13,
%D          title=\CONTEXT\ Spacing Macros,
%D       subtitle=Fillers,
%D         author={Hans Hagen and Wolfgang Schuster},
%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 Spacing Macros / Fillers}

\unprotect

%D A bit more extensive variant of a prototype posted by Wolfgang to the
%D development list. Instead of dealing with a few leader types it makes
%D sense to support them all as well as simple rule fillers. Eventually we
%D can also use in for the mathfillers. We distinguish between alternatives
%D and with them methods, and a checker is provided for use in applying
%D e.g.\ fillers in lists.

\installcorenamespace{filler}
\installcorenamespace{filleralternative}
\installcorenamespace{fillerleadermethod}

\installcommandhandler \??filler {filler} \??filler

\let\setupfillers\setupfiller

\unexpanded\def\filler
  {\dosingleempty\spac_fillers_indeed}

\unexpanded\def\checkedfiller#1%
  {\ifcsname\namedfillerhash{#1}\s!parent\endcsname
     \spac_fillers_indeed[#1]%
     \expandafter\gobbleoneargument
   \else
     \expandafter\firstofoneargument
   \fi{#1}}

\def\spac_fillers_indeed[#1]%
  {\removeunwantedspaces
   \begingroup
   \edef\currentfiller{#1}%
   \scratchdimen\fillerparameter\c!leftmargin\relax
   \ifdim\scratchdimen=\zeropoint\else
     \hskip\scratchdimen
   \fi
   \fillerparameter\c!left\relax
   \expandnamespaceparameter\??filleralternative\fillerparameter\c!alternative\s!unknown\relax
   \fillerparameter\c!right\relax
   \scratchdimen\fillerparameter\c!rightmargin\relax
   \ifdim\scratchdimen=\zeropoint\else
     \hskip\scratchdimen
   \fi
   \endgroup
   \ignorespaces}

\setvalue{\??filleralternative\s!unknown}%
  {}

\setvalue{\??filleralternative\v!symbol}%
  {\expandnamespaceparameter\??fillerleadermethod\fillerparameter\c!method\v!local
      \simplealignedbox
        {\fillerparameter\c!width}%
        {\fillerparameter\c!align}%
        {\fillerparameter\c!symbol}%
   \hfill}

\setvalue{\??filleralternative\c!stretch}%
  {\hfill}

\setvalue{\??filleralternative\c!rule}%
  {\expandnamespaceparameter\??fillerleadermethod\fillerparameter\c!method\v!local
     \hrule
       \!!height\fillerparameter\c!height
       \!!depth \fillerparameter\c!depth
   \hfill}

\letvalue{\??fillerleadermethod\s!local }\normalleaders  % overflow ends up inbetween (current box)
\letvalue{\??fillerleadermethod\v!global}\normalgleaders % overflow ends up inbetween (outermost box)
\letvalue{\??fillerleadermethod\v!middle}\normalcleaders % overflow ends up before, after (current box)
\letvalue{\??fillerleadermethod\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=\v!symbol,
   \c!method=\s!local]

% maybe box -> symbol

\protect \endinput

% \definefiller[test-a][alternative=stretch]
% \definefiller[test-b][alternative=symbol,symbol=!]
% \definefiller[test-c][alternative=rule,height=.1ex,leftmargin=.5em,rightmargin=.25em]

% \starttext
%     text\filler[test-a]text \par
%     text\filler[test-b]text \par
%     text\filler[test-c]text \par
%     text\checkedfiller{<nothing>}text \par
% \stoptext