strc-ind.mkiv /size: 4169 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=strc-ind, % was part of strc-des,
3%D        version=2008.10.20,
4%D          title=\CONTEXT\ Structure Macros,
5%D       subtitle=Indented Text,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{ConTeXt Structure Macros / Indented Text}
15
16\unprotect
17
18%D \macros
19%D   {defineindentedtext,
20%D    setupindentedtext}
21%D
22%D Ok, we keep it but with a different command as it all looks too
23%D much like indentation and indenting. We also assume start/stop
24%D usage or some explicit par.
25
26\installcorenamespace{indentedtext}
27
28\installcommandhandler \??indentedtext {indentedtext} \??indentedtext
29
30%D \startbuffer
31%D \defineindentedtext[one][text=one]
32%D \defineindentedtext[two][text=two]
33%D
34%D \one test test \par
35%D \subone test test \par
36%D \subtwo test test \par
37%D \subsubone test test \par
38%D
39%D \startone
40%D     test test
41%D     \startone
42%D         test test
43%D         \startone
44%D             test test
45%D         \stopone
46%D         \starttwo
47%D             test test
48%D             \startone
49%D                 test test
50%D             \stopone
51%D         \stoptwo
52%D     \stopone
53%D \stopone
54%D \stopbuffer
55%D
56%D \typebuffer \getbuffer
57
58\newcount\c_strc_indentedtexts_nesting
59\newdimen\d_strc_indentedtexts_width
60\newdimen\d_strc_indentedtexts_distance
61
62\appendtoks
63   \setuevalue    {\e!start\currentindentedtext}{\strc_indentedtexts_start{\currentindentedtext}\c_strc_indentedtexts_nesting}%
64   \setuevalue    {\e!stop \currentindentedtext}{\strc_indentedtexts_stop}%
65   % to be avoided ... might go away
66   \setuevalue            {\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{0}}%
67   \setuevalue      {\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{1}}%
68   \setuevalue{\v!sub\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{2}}%
69\to \everydefineindentedtext
70
71\unexpanded\def\strc_indentedtexts_start#1#2% we need to get rid of \spr
72  {\par
73   \begingroup
74   \edef\currentindentedtext{#1}%
75   \c_strc_indentedtexts_nesting#2\relax
76   \indentedtextparameter\c!before
77   \d_strc_indentedtexts_distance\indentedtextparameter\c!distance\relax
78   \doifnothing{\indentedtextparameter\c!sample}
79     {\setindentedtextparameter\c!sample{\indentedtextparameter\c!text}}%
80   \assignwidth
81     {\indentedtextparameter\c!width}
82     {\d_strc_indentedtexts_width}
83     {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
84      \indentedtextparameter\c!sample
85      \spr{\indentedtextparameter\c!separator}}
86     {\d_strc_indentedtexts_distance}%
87   \advance\d_strc_indentedtexts_width \d_strc_indentedtexts_distance
88   \setbox\scratchbox\hbox to \d_strc_indentedtexts_width
89     {\useindentedtextstyleandcolor\c!headstyle\c!headcolor
90      \strut
91      \indentedtextparameter\c!text
92      \hss
93      \spr{\indentedtextparameter\c!separator}%
94      \hskip\d_strc_indentedtexts_distance}%
95   \parindent\zeropoint
96   \hskip\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
97   \advance\c_strc_indentedtexts_nesting\plusone
98   \dontleavehmode\box\scratchbox
99   \hangindent\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
100   \useindentedtextstyleandcolor\c!style\c!color}
101
102\unexpanded\def\strc_indentedtexts_stop
103  {\indentedtextparameter\c!after
104   \par
105   \endgroup}
106
107\unexpanded\def\startindentedtext
108  {\dosingleempty\strc_indentedtexts_start_direct}
109
110\def\strc_indentedtexts_start_direct[#1]%
111  {\strc_indentedtexts_start{#1}\c_strc_indentedtexts_nesting}
112
113\let\stopindentedtext\strc_indentedtexts_stop
114
115\unexpanded\def\strc_indentedtexts_direct#1#2#3\par % no longer clever grabpar trickery
116  {\strc_indentedtexts_start{#1}{#2}#3\strc_indentedtexts_stop}
117
118\setupindentedtext
119  [\c!style=\v!normal,
120   \c!headstyle=\v!normal,
121  %\c!color=,
122  %\c!headcolor=,
123   \c!width=\v!fit,
124   \c!text=\unknown,
125  %\c!sample=,
126   \c!before=\blank,
127   \c!after=\blank,
128   \c!distance=1em,
129   \c!separator={ :}]
130
131\protect \endinput
132