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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
%D \module
%D [ file=strc-ind, % was part of strc-des,
%D version=2008.10.20,
%D title=\CONTEXT\ Structure Macros,
%D subtitle=Indented Text,
%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 Structure Macros / Indented Text}
\unprotect
%D \macros
%D {defineindentedtext,
%D setupindentedtext}
%D
%D Ok, we keep it but with a different command as it all looks too
%D much like indentation and indenting. We also assume start/stop
%D usage or some explicit par.
\installcorenamespace{indentedtext}
\installcommandhandler \??indentedtext {indentedtext} \??indentedtext
%D \startbuffer
%D \defineindentedtext[one][text=one]
%D \defineindentedtext[two][text=two]
%D
%D \one test test \par
%D \subone test test \par
%D \subtwo test test \par
%D \subsubone test test \par
%D
%D \startone
%D test test
%D \startone
%D test test
%D \startone
%D test test
%D \stopone
%D \starttwo
%D test test
%D \startone
%D test test
%D \stopone
%D \stoptwo
%D \stopone
%D \stopone
%D \stopbuffer
%D
%D \typebuffer \getbuffer
\newcount\c_strc_indentedtexts_nesting
\newdimen\d_strc_indentedtexts_width
\newdimen\d_strc_indentedtexts_distance
\appendtoks
\frozen\instance\setuevalue {\e!start\currentindentedtext}{\strc_indentedtexts_start{\currentindentedtext}\c_strc_indentedtexts_nesting}%
\frozen\instance\setuevalue {\e!stop \currentindentedtext}{\strc_indentedtexts_stop}%
% to be avoided ... might go away
\frozen\instance\setuevalue {\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{0}}%
\frozen\instance\setuevalue {\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{1}}%
\frozen\instance\setuevalue{\v!sub\v!sub\currentindentedtext}{\strc_indentedtexts_direct{\currentindentedtext}{2}}%
\to \everydefineindentedtext
\protected\def\strc_indentedtexts_start#1#2% we need to get rid of \spr
{\par
\begingroup
\edef\currentindentedtext{#1}%
\c_strc_indentedtexts_nesting#2\relax
\indentedtextparameter\c!before
\d_strc_indentedtexts_distance\indentedtextparameter\c!distance\relax
\doifnothing{\indentedtextparameter\c!sample}
{\setindentedtextparameter\c!sample{\indentedtextparameter\c!text}}%
\assignwidth
{\indentedtextparameter\c!width}
{\d_strc_indentedtexts_width}
{\useindentedtextstyleandcolor\c!headstyle\c!headcolor
\indentedtextparameter\c!sample
\spr{\indentedtextparameter\c!separator}}
{\d_strc_indentedtexts_distance}%
\advance\d_strc_indentedtexts_width \d_strc_indentedtexts_distance
\setbox\scratchbox\hbox to \d_strc_indentedtexts_width
{\useindentedtextstyleandcolor\c!headstyle\c!headcolor
\strut
\indentedtextparameter\c!text
\hss
\spr{\indentedtextparameter\c!separator}%
\hskip\d_strc_indentedtexts_distance}%
\parindent\zeropoint
\hskip\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
\advance\c_strc_indentedtexts_nesting\plusone
\dontleavehmode\box\scratchbox
\hangindent\c_strc_indentedtexts_nesting\d_strc_indentedtexts_width
\useindentedtextstyleandcolor\c!style\c!color}
\protected\def\strc_indentedtexts_stop
{\indentedtextparameter\c!after
\par
\endgroup}
\permanent\tolerant\protected\def\startindentedtext[#1]%
{\strc_indentedtexts_start{#1}\c_strc_indentedtexts_nesting}
\permanent\let\stopindentedtext\strc_indentedtexts_stop
\protected\def\strc_indentedtexts_direct#1#2#3\par % no longer clever grabpar trickery
{\strc_indentedtexts_start{#1}{#2}#3\strc_indentedtexts_stop}
\setupindentedtext
[\c!style=\v!normal,
\c!headstyle=\v!normal,
%\c!color=,
%\c!headcolor=,
\c!width=\v!fit,
\c!text=\unknown,
%\c!sample=,
\c!before=\blank,
\c!after=\blank,
\c!distance=1em,
\c!separator={ :}]
\protect \endinput
|