1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Structure Macros Indented Text}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26\installcorenamespace{indentedtext}
27
28\installcommandhandler \??indentedtext {indentedtext} \??indentedtext
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\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
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
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
116 {\strc_indentedtexts_start{#1}{#2}#3\strc_indentedtexts_stop}
117
118\setupindentedtext
119 [\c!style=\v!normal,
120 \c!headstyle=\v!normal,
121
122
123 \c!width=\v!fit,
124 \c!text=\unknown,
125
126 \c!before=\blank,
127 \c!after=\blank,
128 \c!distance=1em,
129 \c!separator={ :}]
130
131\protect \endinput
132 |