drop crashrpt
[TortoiseGit.git] / ext / scintilla / doc / ScintillaUsage.html
blobc19cbc556f56c0d3843d5e24f9f9390be4cf864d
1 <?xml version="1.0"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head>
6 <meta name="generator" content="HTML Tidy, see www.w3.org" />
7 <meta name="generator" content="SciTE" />
8 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9 <title>
10 Scintilla Usage Notes
11 </title>
12 <style type="text/css">
13 SPAN {
14 font-family: Verdana, Arial, Helvetica;
15 font-size: 9pt;
17 .S0 {
18 color: #808080;
19 font-family: Verdana, Arial, Helvetica;
21 .S1 {
22 font-family: Comic Sans MS, Times New Roman, Times;
23 color: #007F00;
24 font-size: 8pt;
26 .S2 {
27 font-family: Comic Sans MS, Times New Roman, Times;
28 color: #007F00;
29 font-size: 8pt;
31 .S3 {
32 font-family: Verdana, Arial, Helvetica;
33 color: #7F7F7F;
35 .S4 {
36 font-family: Verdana, Arial, Helvetica;
37 color: #007F7F;
39 .S5 {
40 color: #00007F;
41 font-weight: bold;
42 font-family: Verdana, Arial, Helvetica;
44 .S6 {
45 color: #7F007F;
46 font-family: Courier New, Courier;
48 .S7 {
49 color: #7F007F;
50 font-family: Courier New, Courier;
52 .S8 {
53 color: #007F7F;
55 .S9 {
56 color: #7F7F00;
58 .S10 {
59 font-weight: bold;
61 </style>
62 </head>
63 <body bgcolor="#FFFFFF" text="#000000">
64 <table bgcolor="#000000" width="100%" cellspacing="0" cellpadding="0" border="0">
65 <tr>
66 <td>
67 <img src="SciTEIco.png" border="3" height="64" width="64" alt="Scintilla icon" />
68 </td>
69 <td>
70 <a href="index.html" style="color:white;text-decoration:none"><font size="5">Scintilla
71 Usage Notes</font></a>
72 </td>
73 </tr>
74 </table>
75 <h2>
76 Implementing Auto-Indent
77 </h2>
78 <p>
79 The key idea is to use the SCN_CHARADDED notification to add indentation after a newline.
80 </p>
81 <p>
82 The lParam on the notification is a pointer to a SCNotification structure whose ch member
83 specifies the character added. If a newline was added, the previous line can be retrieved and
84 the same indentation can be added to the new line.
85 </p>
86 <p>
87 Here is the relevant portion of code from SciTE: (SciTE.cxx SciTEWindow::CharAdded)
88 </p>
89 <span class='S5'>if</span><span class='S0'>&nbsp;</span> <span class='S10'>(</span><span
90 class='S11'>ch</span><span class='S0'>&nbsp;</span> <span class='S10'>==</span><span
91 class='S0'>&nbsp;</span> <span class='S7'>'\r'</span><span class='S0'>&nbsp;</span> <span
92 class='S10'>||</span><span class='S0'>&nbsp;</span> <span class='S11'>ch</span><span
93 class='S0'>&nbsp;</span> <span class='S10'>==</span><span class='S0'>&nbsp;</span> <span
94 class='S7'>'\n'</span><span class='S10'>)</span><span class='S0'>&nbsp;</span> <span
95 class='S10'>{</span><span class='S0'><br />
96 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>char</span><span class='S0'>&nbsp;</span>
97 <span class='S11'>linebuf</span><span class='S10'>[</span><span class='S4'>1000</span><span
98 class='S10'>];</span><span class='S0'><br />
99 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>int</span><span class='S0'>&nbsp;</span>
100 <span class='S11'>curLine</span><span class='S0'>&nbsp;</span> <span class='S10'>=</span><span
101 class='S0'>&nbsp;</span> <span class='S11'>GetCurrentLineNumber</span><span
102 class='S10'>();</span><span class='S0'><br />
103 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>int</span><span class='S0'>&nbsp;</span>
104 <span class='S11'>lineLength</span><span class='S0'>&nbsp;</span> <span class='S10'>
105 =</span><span class='S0'>&nbsp;</span> <span class='S11'>SendEditor</span><span
106 class='S10'>(</span><span class='S11'>SCI_LINELENGTH</span><span class='S10'>,</span><span
107 class='S0'>&nbsp;</span> <span class='S11'>curLine</span><span class='S10'>);</span><span
108 class='S0'><br />
109 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S2'>
110 //Platform::DebugPrintf("[CR]&nbsp;%d&nbsp;len&nbsp;=&nbsp;%d\n",&nbsp;curLine,&nbsp;lineLength);</span><span
111 class='S0'><br />
112 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>if</span><span class='S0'>&nbsp;</span> <span
113 class='S10'>(</span><span class='S11'>curLine</span><span class='S0'>&nbsp;</span> <span
114 class='S10'>&gt;</span><span class='S0'>&nbsp;</span> <span class='S4'>0</span><span
115 class='S0'>&nbsp;</span> <span class='S10'>&amp;&amp;</span><span class='S0'>&nbsp;</span>
116 <span class='S11'>lineLength</span><span class='S0'>&nbsp;</span> <span class='S10'>
117 &lt;=</span><span class='S0'>&nbsp;</span> <span class='S4'>2</span><span
118 class='S10'>)</span><span class='S0'>&nbsp;</span> <span class='S10'>{</span><span
119 class='S0'><br />
120 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>int</span><span class='S0'>&nbsp;</span>
121 <span class='S11'>prevLineLength</span><span class='S0'>&nbsp;</span> <span class='S10'>
122 =</span><span class='S0'>&nbsp;</span> <span class='S11'>SendEditor</span><span
123 class='S10'>(</span><span class='S11'>SCI_LINELENGTH</span><span class='S10'>,</span><span
124 class='S0'>&nbsp;</span> <span class='S11'>curLine</span><span class='S0'>&nbsp;</span> <span
125 class='S10'>-</span><span class='S0'>&nbsp;</span> <span class='S4'>1</span><span
126 class='S10'>);</span><span class='S0'><br />
127 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>if</span><span class='S0'>&nbsp;</span> <span
128 class='S10'>(</span><span class='S11'>prevLineLength</span><span class='S0'>&nbsp;</span> <span
129 class='S10'>&lt;</span><span class='S0'>&nbsp;</span> <span class='S5'>sizeof</span><span
130 class='S10'>(</span><span class='S11'>linebuf</span><span class='S10'>))</span><span
131 class='S0'>&nbsp;</span> <span class='S10'>{</span><span class='S0'><br />
132 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S11'>WORD</span><span
133 class='S0'>&nbsp;</span> <span class='S11'>buflen</span><span class='S0'>&nbsp;</span> <span
134 class='S10'>=</span><span class='S0'>&nbsp;</span> <span class='S5'>sizeof</span><span
135 class='S10'>(</span><span class='S11'>linebuf</span><span class='S10'>);</span><span
136 class='S0'><br />
137 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S11'>memcpy</span><span
138 class='S10'>(</span><span class='S11'>linebuf</span><span class='S10'>,</span><span
139 class='S0'>&nbsp;</span> <span class='S10'>&amp;</span><span class='S11'>buflen</span><span
140 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S5'>sizeof</span><span
141 class='S10'>(</span><span class='S11'>buflen</span><span class='S10'>));</span><span
142 class='S0'><br />
143 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S11'>
144 SendEditor</span><span class='S10'>(</span><span class='S11'>EM_GETLINE</span><span
145 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S11'>curLine</span><span
146 class='S0'>&nbsp;</span> <span class='S10'>-</span><span class='S0'>&nbsp;</span> <span
147 class='S4'>1</span><span class='S10'>,</span><span class='S0'><br />
148 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
149 <span class='S5'>reinterpret_cast</span><span class='S10'>&lt;</span><span
150 class='S11'>LPARAM</span><span class='S10'>&gt;(</span><span class='S5'>static_cast</span><span
151 class='S10'>&lt;</span><span class='S5'>char</span><span class='S0'>&nbsp;</span> <span
152 class='S10'>*&gt;(</span><span class='S11'>linebuf</span><span class='S10'>)));</span><span
153 class='S0'><br />
154 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S11'>linebuf</span><span
155 class='S10'>[</span><span class='S11'>prevLineLength</span><span class='S10'>]</span><span
156 class='S0'>&nbsp;</span> <span class='S10'>=</span><span class='S0'>&nbsp;</span> <span
157 class='S7'>'\0'</span><span class='S10'>;</span><span class='S0'><br />
158 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>for</span><span
159 class='S0'>&nbsp;</span> <span class='S10'>(</span><span class='S5'>int</span><span
160 class='S0'>&nbsp;</span> <span class='S11'>pos</span><span class='S0'>&nbsp;</span> <span
161 class='S10'>=</span><span class='S0'>&nbsp;</span> <span class='S4'>0</span><span
162 class='S10'>;</span><span class='S0'>&nbsp;</span> <span class='S11'>linebuf</span><span
163 class='S10'>[</span><span class='S11'>pos</span><span class='S10'>];</span><span
164 class='S0'>&nbsp;</span> <span class='S11'>pos</span><span class='S10'>++)</span><span
165 class='S0'>&nbsp;</span> <span class='S10'>{</span><span class='S0'><br />
166 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span
167 class='S5'>if</span><span class='S0'>&nbsp;</span> <span class='S10'>(</span><span
168 class='S11'>linebuf</span><span class='S10'>[</span><span class='S11'>pos</span><span
169 class='S10'>]</span><span class='S0'>&nbsp;</span> <span class='S10'>!=</span><span
170 class='S0'>&nbsp;</span> <span class='S7'>'&nbsp;'</span><span class='S0'>&nbsp;</span> <span
171 class='S10'>&amp;&amp;</span><span class='S0'>&nbsp;</span> <span class='S11'>
172 linebuf</span><span class='S10'>[</span><span class='S11'>pos</span><span
173 class='S10'>]</span><span class='S0'>&nbsp;</span> <span class='S10'>!=</span><span
174 class='S0'>&nbsp;</span> <span class='S7'>'\t'</span><span class='S10'>)</span><span
175 class='S0'><br />
176 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
177 <span class='S11'>linebuf</span><span class='S10'>[</span><span class='S11'>pos</span><span
178 class='S10'>]</span><span class='S0'>&nbsp;</span> <span class='S10'>=</span><span
179 class='S0'>&nbsp;</span> <span class='S7'>'\0'</span><span class='S10'>;</span><span
180 class='S0'><br />
181 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S10'>}</span><span
182 class='S0'><br />
183 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S11'>
184 SendEditor</span><span class='S10'>(</span><span class='S11'>EM_REPLACESEL</span><span
185 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S4'>0</span><span
186 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S5'>
187 reinterpret_cast</span><span class='S10'>&lt;</span><span class='S11'>LPARAM</span><span
188 class='S10'>&gt;(</span><span class='S5'>static_cast</span><span class='S10'>&lt;</span><span
189 class='S5'>char</span><span class='S0'>&nbsp;</span> <span class='S10'>*&gt;(</span><span
190 class='S11'>linebuf</span><span class='S10'>)));</span><span class='S0'><br />
191 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S10'>}</span><span class='S0'><br />
192 </span> <span class='S10'>}</span><br />
194 <p style="margin-bottom: 0in">
195 Of course, fancier handling could be implemented. For example, if the previous line was the
196 start of a control construct, the next line could be automatically indented one tab further.
197 (Assuming that is your indenting style.)
198 </p>
199 <h2>
200 Implementing Syntax Styling
201 </h2>
203 Syntax styling is handled by the SCN_STYLENEEDED notification. Scintilla keeps track of the
204 end of the styled text - this is retrieved with SCI_GETENDSTYLED. In response to the
205 SCN_STYLENEEDED notification, you should apply styles to the text from ENDSTYLED to the
206 position specified by the notification.
207 </p>
209 Here is the relevant portion of code from SciTE: (SciTE.cxx)
210 </p>
211 <span class='S5'>void</span><span class='S0'>&nbsp;</span> <span class='S11'>
212 SciTEWindow</span><span class='S10'>::</span><span class='S11'>Notify</span><span
213 class='S10'>(</span><span class='S11'>SCNotification</span><span class='S0'>&nbsp;</span> <span
214 class='S10'>*</span><span class='S11'>notification</span><span class='S10'>)</span><span
215 class='S0'>&nbsp;</span> <span class='S10'>{</span><span class='S0'><br />
216 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>switch</span><span class='S0'>&nbsp;</span>
217 <span class='S10'>(</span><span class='S11'>notification</span><span
218 class='S10'>-&gt;</span><span class='S11'>nmhdr.code</span><span class='S10'>)</span><span
219 class='S0'>&nbsp;</span> <span class='S10'>{</span><span class='S0'><br />
220 &nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>case</span><span class='S0'>&nbsp;</span>
221 <span class='S11'>SCN_STYLENEEDED</span><span class='S10'>:</span><span
222 class='S0'>&nbsp;</span> <span class='S10'>{</span><span class='S0'><br />
223 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span
224 class='S5'>if</span><span class='S0'>&nbsp;</span> <span class='S10'>(</span><span
225 class='S11'>notification</span><span class='S10'>-&gt;</span><span
226 class='S11'>nmhdr.idFrom</span><span class='S0'>&nbsp;</span> <span class='S10'>==</span><span
227 class='S0'>&nbsp;</span> <span class='S11'>IDM_SRCWIN</span><span class='S10'>)</span><span
228 class='S0'>&nbsp;</span> <span class='S10'>{</span><span class='S0'><br />
229 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
230 <span class='S5'>int</span><span class='S0'>&nbsp;</span> <span class='S11'>
231 endStyled</span><span class='S0'>&nbsp;</span> <span class='S10'>=</span><span
232 class='S0'>&nbsp;</span> <span class='S11'>SendEditor</span><span class='S10'>(</span><span
233 class='S11'>SCI_GETENDSTYLED</span><span class='S10'>);</span><span class='S0'><br />
234 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
235 <span class='S5'>int</span><span class='S0'>&nbsp;</span> <span class='S11'>
236 lineEndStyled</span><span class='S0'>&nbsp;</span> <span class='S10'>=</span><span
237 class='S0'>&nbsp;</span> <span class='S11'>SendEditor</span><span class='S10'>(</span><span
238 class='S11'>EM_LINEFROMCHAR</span><span class='S10'>,</span><span class='S0'>&nbsp;</span>
239 <span class='S11'>endStyled</span><span class='S10'>);</span><span class='S0'><br />
240 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
241 <span class='S11'>endStyled</span><span class='S0'>&nbsp;</span> <span class='S10'>
242 =</span><span class='S0'>&nbsp;</span> <span class='S11'>SendEditor</span><span
243 class='S10'>(</span><span class='S11'>EM_LINEINDEX</span><span class='S10'>,</span><span
244 class='S0'>&nbsp;</span> <span class='S11'>lineEndStyled</span><span class='S10'>);</span><span
245 class='S0'><br />
246 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
247 <span class='S11'>Colourise</span><span class='S10'>(</span><span
248 class='S11'>endStyled</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
249 class='S11'>notification</span><span class='S10'>-&gt;</span><span
250 class='S11'>position</span><span class='S10'>);</span><br />
253 Colourize(start, end) retrieves the specified range of text and then calls ColourizeDoc in
254 keywords.cxx. It starts the process by calling:
255 </p>
256 &nbsp;&nbsp;&nbsp;&nbsp;<span class='S11'>SendMessage</span><span class='S10'>(</span><span
257 class='S11'>hwnd</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
258 class='S11'>SCI_STARTSTYLING</span><span class='S10'>,</span><span class='S0'>&nbsp;</span>
259 <span class='S11'>startPos</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
260 class='S4'>31</span><span class='S10'>);</span><br />
263 and then for each token of the text, calling:
264 </p>
265 &nbsp;&nbsp;&nbsp;&nbsp;<span class='S11'>SendMessage</span><span class='S10'>(</span><span
266 class='S11'>hwnd</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
267 class='S11'>SCI_SETSTYLING</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
268 class='S11'>length</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
269 class='S11'>style</span><span class='S10'>);</span><br />
272 where style is a number from 0 to 31 whose appearance has been defined using the
273 SCI_STYLESET... messages.
274 </p>
275 <h2>
276 Implementing Calltips
277 </h2>
279 Again, the SCN_CHARADDED notification is used to catch when an opening parenthesis is added.
280 The preceding word can then be retrieved from the current line:
281 </p>
282 &nbsp;&nbsp;&nbsp;&nbsp;<span class='S5'>char</span><span class='S0'>&nbsp;</span> <span
283 class='S11'>linebuf</span><span class='S10'>[</span><span class='S4'>1000</span><span
284 class='S10'>];</span><span class='S0'><br />
285 </span> &nbsp;&nbsp;&nbsp;&nbsp;<span class='S5'>int</span><span class='S0'>&nbsp;</span> <span
286 class='S11'>current</span><span class='S0'>&nbsp;</span> <span class='S10'>=</span><span
287 class='S0'>&nbsp;</span> <span class='S11'>SendEditor</span><span class='S10'>(</span><span
288 class='S11'>SCI_GETCURLINE</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
289 class='S5'>sizeof</span><span class='S10'>(</span><span class='S11'>linebuf</span><span
290 class='S10'>),</span><span class='S0'><br />
291 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S5'>
292 reinterpret_cast</span><span class='S10'>&lt;</span><span class='S11'>LPARAM</span><span
293 class='S10'>&gt;(</span><span class='S5'>static_cast</span><span class='S10'>&lt;</span><span
294 class='S5'>char</span><span class='S0'>&nbsp;</span> <span class='S10'>*&gt;(</span><span
295 class='S11'>linebuf</span><span class='S10'>)));</span><span class='S0'><br />
296 </span> &nbsp;&nbsp;&nbsp;&nbsp;<span class='S5'>int</span><span class='S0'>&nbsp;</span> <span
297 class='S11'>pos</span><span class='S0'>&nbsp;</span> <span class='S10'>=</span><span
298 class='S0'>&nbsp;</span> <span class='S11'>SendEditor</span><span class='S10'>(</span><span
299 class='S11'>SCI_GETCURRENTPOS</span><span class='S10'>);</span><span class='S0'><br />
300 <br />
301 </span> &nbsp;&nbsp;&nbsp;&nbsp;<span class='S5'>int</span><span class='S0'>&nbsp;</span> <span
302 class='S11'>startword</span><span class='S0'>&nbsp;</span> <span class='S10'>=</span><span
303 class='S0'>&nbsp;</span> <span class='S11'>current</span><span class='S0'>&nbsp;</span> <span
304 class='S10'>-</span><span class='S0'>&nbsp;</span> <span class='S4'>1</span><span
305 class='S10'>;</span><span class='S0'><br />
306 </span> &nbsp;&nbsp;&nbsp;&nbsp;<span class='S5'>while</span><span class='S0'>&nbsp;</span>
307 <span class='S10'>(</span><span class='S11'>startword</span><span class='S0'>&nbsp;</span>
308 <span class='S10'>&gt;</span><span class='S0'>&nbsp;</span> <span class='S4'>0</span><span
309 class='S0'>&nbsp;</span> <span class='S10'>&amp;&amp;</span><span class='S0'>&nbsp;</span>
310 <span class='S11'>isalpha</span><span class='S10'>(</span><span class='S11'>linebuf</span><span
311 class='S10'>[</span><span class='S11'>startword</span><span class='S0'>&nbsp;</span> <span
312 class='S10'>-</span><span class='S0'>&nbsp;</span> <span class='S4'>1</span><span
313 class='S10'>]))</span><span class='S0'><br />
314 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S11'>
315 startword</span><span class='S10'>--;</span><span class='S0'><br />
316 </span> &nbsp;&nbsp;&nbsp;&nbsp;<span class='S11'>linebuf</span><span class='S10'>[</span><span
317 class='S11'>current</span><span class='S0'>&nbsp;</span> <span class='S10'>-</span><span
318 class='S0'>&nbsp;</span> <span class='S4'>1</span><span class='S10'>]</span><span
319 class='S0'>&nbsp;</span> <span class='S10'>=</span><span class='S0'>&nbsp;</span> <span
320 class='S7'>'\0'</span><span class='S10'>;</span><span class='S0'><br />
321 </span> &nbsp;&nbsp;&nbsp;&nbsp;<span class='S5'>char</span><span class='S10'>*</span><span
322 class='S0'>&nbsp;</span> <span class='S11'>word</span><span class='S0'>&nbsp;</span> <span
323 class='S10'>=</span><span class='S0'>&nbsp;</span> <span class='S11'>linebuf</span><span
324 class='S0'>&nbsp;</span> <span class='S10'>+</span><span class='S0'>&nbsp;</span> <span
325 class='S11'>startword</span><span class='S10'>;</span><br />
328 Then if a calltip is available it can be displayed. The calltip appears immediately below
329 the position specified. The calltip can be multiple lines separated by newlines (\n).
330 </p>
331 &nbsp;&nbsp;&nbsp;&nbsp;<span class='S11'>pos</span><span class='S0'>&nbsp;</span> <span
332 class='S10'>=</span><span class='S0'>&nbsp;</span> <span class='S11'>SendMessage</span><span
333 class='S10'>(</span><span class='S11'>hwnd</span><span class='S10'>,</span><span
334 class='S0'>&nbsp;</span> <span class='S11'>SCI_GETCURRENTPOS</span><span
335 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S4'>0</span><span
336 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S4'>0</span><span
337 class='S10'>);</span><span class='S0'><br />
338 </span> &nbsp;&nbsp;&nbsp;&nbsp;<span class='S11'>SendMessageText</span><span
339 class='S10'>(</span><span class='S11'>hwnd</span><span class='S10'>,</span><span
340 class='S0'>&nbsp;</span> <span class='S11'>SCI_CALLTIPSHOW</span><span
341 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S11'>pos</span><span
342 class='S0'>&nbsp;</span> <span class='S10'>-</span><span class='S0'>&nbsp;</span> <span
343 class='S11'>wordLen</span><span class='S0'>&nbsp;</span> <span class='S10'>-</span><span
344 class='S0'>&nbsp;</span> <span class='S4'>1</span><span class='S10'>,</span><span
345 class='S0'>&nbsp;</span> <span class='S11'>calltip</span><span class='S10'>);</span><br />
348 The calltip can be removed when a closing parenthesis is entered:
349 </p>
350 &nbsp;&nbsp;&nbsp;&nbsp;<span class='S5'>if</span><span class='S0'>&nbsp;</span> <span
351 class='S10'>(</span><span class='S11'>SendMessage</span><span class='S10'>(</span><span
352 class='S11'>hwnd</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
353 class='S11'>SCI_CALLTIPACTIVE</span><span class='S10'>,</span><span class='S0'>&nbsp;</span>
354 <span class='S4'>0</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
355 class='S4'>0</span><span class='S10'>))</span><span class='S0'><br />
356 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class='S11'>
357 SendMessage</span><span class='S10'>(</span><span class='S11'>hwnd</span><span
358 class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S11'>
359 SCI_CALLTIPCANCEL</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span
360 class='S4'>0</span><span class='S10'>,</span><span class='S0'>&nbsp;</span> <span class='S4'>
361 0</span><span class='S10'>);</span><br />
364 Obviously, it is up the application to look after supplying the appropriate calltip text.
365 </p>
367 SciTE goes one step further, counting the commas between arguments and highlighting the
368 corresponding part of the calltip. This code is in ContinueCallTip.
369 </p>
371 <i>Page contributed by Andrew McKinlay.</i>
372 </p>
373 </body>
374 </html>