summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/interaction/interaction-comments.tex
blob: b19894d577d91e9a2493f691dbe1ee6f233fa0df (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
\environment interaction-style

\enabletrackers[comments.anchors]

\startcomponent interaction-comments

\setupcomment
  [location=inmargin]

\startchapter[title={Comments}]

Many \PDF\ viewers support text annotations. These are small notes that can be
popped up. In \CONTEXT\ we call them comments, because often that's what they are
used for. Comments evolved from simple ones using a limited encoding into more
advanced ones with representations. A comment looks like:

\startbuffer
\startcomment
  Hello beautiful world!
\stopcomment
\stopbuffer

\typebuffer

\getbuffer

When you open a document with comment you will likely see some symbol depicting
it. But, it's one of those features that is viewer dependent so when it looks odd
or unexpected, check in \ACROBAT\ first. The position and size can differ per
viewer and when you zoom in the size can either stay the same or scale. The
viewer can show the pop up text at the same location or someplace else. Although
in principle there is control over this, my experience is that viewers (also
Acrobat) keep changing this (not always for the best). Just assume the worst: it
will never look good and although for a while we kept up with viewers, the
inconsistency (and accumulated waste of time) led us to the current minimalistic
approach.

By default, in \CONTEXT\ comments are placed at the spot a bit raised. In this
document we put them in the margin, by saying:

\starttyping
\setupcomment
  [location=inmargin]
\stoptyping

Comments can have titles and properties but not all viewers support properties.
Contrary to other environments, the first argument is not a category but a title.
This because we are compatible with \MKII.

\startbuffer
\startcomment[french]
  In France they use «angle bracket glyphs» in subsentences.
\stopcomment

\startcomment[accents][color=darkgreen]
  You can used an àçéñţêð character too.
\stopcomment
\stopbuffer

\typebuffer \getbuffer

And normally empty lines are also supported (again this can differ per viewer):

\startbuffer
\startcomment[lines][color=darkblue]
  How about an

  empty line?
\stopcomment
\stopbuffer

\typebuffer \getbuffer

As we can see here, comments are sort of stacked. These examples also show that
we can pass an optional title and set up some characteristics. An inline comment
is defined with \type {\comment}:

\startbuffer
\comment {How I hate those notes spoiling the layout.} Maybe some day
I can convince myself to add some features \comment {Think of comment classes
that can be turned on and off and get their own colors.} related to version
control.
\stopbuffer

\typebuffer

\inlinebuffer\ Comments hide part of the text and thereby are to be used with
care. Until now I never used them. Anyhow, from now on, one can happily use:

You can use other symbols than the default, and a couple are predefined in
the standard: {\tt \cldcontext {table.concat (lpdf.commentsymbols(), ", ")}}.

\startbuffer
\startcomment[symbol=Help]
  Do we want this kind of rubish?
\stopcomment
\stopbuffer

You can also use your own symbols:

% \definesymbol [comment-normal][{\externalfigure[cow.pdf]}]
% \definesymbol [comment-down]  [{\externalfigure[cow.pdf]}]
%
% \unexpanded\def\CowSymbol#1#2%
%   {\scale
%     [height=#1]
%     {\startMPcode
%        loadfigure "cow.mp" number 1 ;
%        refill currentpicture withcolor #2 ;
%      \stopMPcode}}
%
% \definesymbol [comment-normal] [\CowSymbol{4ex}{darkred}]
% \definesymbol [comment-down]   [\CowSymbol{4ex}{darkgreen}]

\startbuffer
\startuniqueMPgraphic{cow}{height,s:color}
    loadfigure "cow.mp" number 1 ;
    refill currentpicture withcolor "\MPvar{color}"    ;
    currentpicture := currentpicture ysized \MPvar{height} ;
\stopuniqueMPgraphic

\definesymbol
  [comment-normal]
  [\uniqueMPgraphic{cow}{height=4ex,color=darkred}]
\definesymbol
  [comment-down]
  [\uniqueMPgraphic{cow}{height=4ex,color=darkgreen}]

\stopbuffer

\typebuffer \getbuffer

\startbuffer
\startcomment[hello][symbol={comment-normal,comment-down}]
    oeps
\stopcomment
\stopbuffer

\typebuffer \getbuffer

Again the way this shows up depends on the viewer capabilities so there might be
a fallback on the normal comment symbol. You can influence the size of the image
(icon):

\startbuffer
\startcomment[hello]
    [symbol={comment-normal,comment-down},width=\marginwidth]
    oeps
\stopcomment
\stopbuffer

\typebuffer \getbuffer

There are some options that you can use for finetuning the comments.

\showsetup{setupcomment}

A new instance is defined with:

\showsetup{definecomment}

The default instance is predefined by

\starttyping
\definecomment[comment]
\stoptyping

You can define your own instances:

\starttyping
\definecomment[mycomment]
\stoptyping

The generated commands have a syntax like:

\showsetup{startcomment:instance}

and:

\showsetup{comment:instance}

Most fields explain themselves. With \type {state} you can disable this feature.
Comments can be hidden in which there is no icon shown. The \type {nx} and \type
{ny} fields determine the size of the popup.

In case you wonder where the yellow backgrounds come from, here is the trick:

\starttyping
\enabletrackers[comments.anchors]
\stoptyping

\stopchapter

\stopcomponent