~neon/pykde4/master

« back to all changes in this revision

Viewing changes to docs/html/ktexteditor/KTextEditor.TemplateInterface.html

  • Committer: Simon Edwards
  • Date: 2013-05-17 19:15:12 UTC
  • Revision ID: git-v1:a46160bff9c0346159e2d50fd33680a25403b964
Updated the ktexteditor bindings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 
4
 
 
5
<head>
 
6
  <title>KTextEditor.TemplateInterface</title>
 
7
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
  <meta http-equiv="Content-Style-Type" content="text/css" />
 
9
  <link rel="stylesheet" type="text/css" href="../common/doxygen.css" />
 
10
  <link rel="stylesheet" media="screen" type="text/css" title="KDE Colors" href="../common/kde.css" />
 
11
</head>
 
12
<body>
 
13
<div id="container">
 
14
<div id="header">
 
15
  <div id="header_top">
 
16
    <div>
 
17
      <div>
 
18
        <img alt ="" src="../common/top-kde.jpg"/>
 
19
        KDE 4.9 PyKDE API Reference
 
20
      </div>
 
21
    </div>
 
22
  </div>
 
23
  <div id="header_bottom">
 
24
    <div id="location">
 
25
      <ul>
 
26
        <li>KDE's Python API</li>
 
27
      </ul>
 
28
    </div>
 
29
 
 
30
    <div id="menu">
 
31
      <ul>
 
32
        <li><a href="../modules.html">Overview</a></li>
 
33
<li><a href="http://techbase.kde.org/Development/Languages/Python">PyKDE Home</a></li>
 
34
<li><a href="http://kde.org/family/">Sitemap</a></li>
 
35
<li><a href="http://kde.org/contact/">Contact Us</a></li>
 
36
</ul>
 
37
    </div>
 
38
  </div>
 
39
</div>
 
40
 
 
41
<div id="body_wrapper">
 
42
<div id="body">
 
43
<div id="right">
 
44
<div class="content">
 
45
<div id="main">
 
46
<div class="clearer">&nbsp;</div>
 
47
 
 
48
<h1>TemplateInterface Class Reference</h1>
 
49
<code>from PyKDE4.ktexteditor import *</code>
 
50
<p>
 
51
 
 
52
 
 
53
Namespace: <a href="../ktexteditor/KTextEditor.html">KTextEditor</a><br />
 
54
<h2>Detailed Description</h2>
 
55
 
 
56
<p>This is an interface for inserting template strings with user editable
 
57
fields into a document.
 
58
</p>
 
59
<table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><br><h2>Methods</h2></td></tr>
 
60
<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#TemplateInterface">__init__</a> (self)</td></tr>
 
61
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#KTE_INTERNAL_setupIntialValues">KTE_INTERNAL_setupIntialValues</a> (self, QString templateString, {QString:QString} initialValues)</td></tr>
 
62
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#insertTemplateText">insertTemplateText</a> (self, <a href="../ktexteditor/KTextEditor.Cursor.html">KTextEditor.Cursor</a> insertPosition, QString templateString, {QString:QString} initialValues)</td></tr>
 
63
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#insertTemplateTextImplementation">insertTemplateTextImplementation</a> (self, <a href="../ktexteditor/KTextEditor.Cursor.html">KTextEditor.Cursor</a> insertPosition, QString templateString, {QString:QString} initialValues)</td></tr>
 
64
<tr><td colspan="2"><br><h2>Static Methods</h2></td></tr>
 
65
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="#expandMacros">expandMacros</a> ({QString:QString} initialValues, QWidget parentWindow)</td></tr>
 
66
</table>
 
67
<hr><h2>Method Documentation</h2><a class="anchor" name="TemplateInterface"></a>
 
68
<div class="memitem">
 
69
<div class="memproto">
 
70
<table class="memname"><tr>
 
71
<td class="memname">__init__</td>
 
72
<td>(</td>
 
73
<td class="paramtype">&nbsp;</td>
 
74
<td class="paramname"><em>self</em>&nbsp;)</td>
 
75
<td width="100%"> </td>
 
76
</tr>
 
77
</table>
 
78
</div>
 
79
<div class="memdoc"></div></div><a class="anchor" name="KTE_INTERNAL_setupIntialValues"></a>
 
80
<div class="memitem">
 
81
<div class="memproto">
 
82
<table class="memname"><tr>
 
83
<td class="memname">bool KTE_INTERNAL_setupIntialValues</td>
 
84
<td>(</td>
 
85
<td class="paramtype">&nbsp;<em>self</em>, </td>
 
86
<td class="paramname"></td>
 
87
</tr><tr>
 
88
<td class="memname"></td>
 
89
<td></td>
 
90
<td class="paramtype">QString&nbsp;</td>
 
91
<td class="paramname"><em>templateString</em>, </td>
 
92
</tr>
 
93
<tr>
 
94
<td class="memname"></td>
 
95
<td></td>
 
96
<td class="paramtype">{QString:QString}&nbsp;</td>
 
97
<td class="paramname"><em>initialValues</em></td>
 
98
</tr>
 
99
<tr>
 
100
<td></td>
 
101
<td>)</td>
 
102
<td></td>
 
103
<td></td>
 
104
<td width="100%"> </td>
 
105
</tr></table>
 
106
</div>
 
107
<div class="memdoc"><p>DO NOT USE !!!! THIS IS USED INTERNALLY by the interface only !!!!!!
 
108
Behaviour might change !!!!!!!
 
109
</p></div></div><a class="anchor" name="insertTemplateText"></a>
 
110
<div class="memitem">
 
111
<div class="memproto">
 
112
<table class="memname"><tr>
 
113
<td class="memname">bool insertTemplateText</td>
 
114
<td>(</td>
 
115
<td class="paramtype">&nbsp;<em>self</em>, </td>
 
116
<td class="paramname"></td>
 
117
</tr><tr>
 
118
<td class="memname"></td>
 
119
<td></td>
 
120
<td class="paramtype"><a href="../ktexteditor/KTextEditor.Cursor.html">KTextEditor.Cursor</a>&nbsp;</td>
 
121
<td class="paramname"><em>insertPosition</em>, </td>
 
122
</tr>
 
123
<tr>
 
124
<td class="memname"></td>
 
125
<td></td>
 
126
<td class="paramtype">QString&nbsp;</td>
 
127
<td class="paramname"><em>templateString</em>, </td>
 
128
</tr>
 
129
<tr>
 
130
<td class="memname"></td>
 
131
<td></td>
 
132
<td class="paramtype">{QString:QString}&nbsp;</td>
 
133
<td class="paramname"><em>initialValues</em></td>
 
134
</tr>
 
135
<tr>
 
136
<td></td>
 
137
<td>)</td>
 
138
<td></td>
 
139
<td></td>
 
140
<td width="100%"> </td>
 
141
</tr></table>
 
142
</div>
 
143
<div class="memdoc"><p>Inserts an interactive ediable template text at line "line", column "col".
 
144
<dl class="return" compact><dt><b>Returns:</b></dt><dd> true if inserting the string succeeded
 
145
</dd></dl> </p>
 
146
<p>
 
147
Use insertTemplateText(lines(), ...) to append text at end of document
 
148
Template strings look like
 
149
"for( int ${index}=0;${index}&lt;10;${index}++) { ${cursor} };"
 
150
or "%{date}"
 
151
</p>
 
152
<p>
 
153
This syntax is somewhat similar to the one found in the Eclipse editor or textmate.
 
154
</p>
 
155
<p>
 
156
There are certain common placeholders (macros), which get assigned a
 
157
default initialValue, If the second parameter does not a given value.
 
158
For all others the initial value is the name of the placeholder.
 
159
</p>
 
160
<p>
 
161
Placeholder names may only consist of a-zA-Z0-9_
 
162
</p>
 
163
<p>
 
164
<dl class="since" compact><dt><b>Since:</b></dt><dd> 4.5
 
165
if a placeholder is a mirror, the place holder name may contain additional information
 
166
${something/regexp/replacement/} takes the value of the placeholder something and replaces the match with the replacement before inserting the mirrored value
 
167
${something/regexp/replacement/g} like above, but for all occurences
 
168
The syntax of the regexp and the replacement are the ones from kateparts regexp search/replace
 
169
${something/regexp/replacement/i} like above, but case insensitive
 
170
The syntax of the regexp and the replacement are the ones from kateparts regexp search/replace
 
171
Possible flags: g and i. Those flags can be combined too
 
172
If a literal / should appear in the regexp, it has to be escaped \/,
 
173
literal \ has to be escaped too
 
174
</dd></dl> </p>
 
175
<p>
 
176
If you have mirrored ranges and want another occurence than the first one as the master
 
177
you can add @directly after the placeholder name.
 
178
</p>
 
179
<p>
 
180
The interface2 version invokes the function specified by functionName within the script specified
 
181
by the scriptToken, if a placeholder is specified with backticks like
 
182
${placeholder`functionName`}
 
183
The function has a global environment containing "view", "document" and "debug", at
 
184
least in the katepart implementation. The function invokation is not allowed to be mixed with other replacements
 
185
</p>
 
186
<p>
 
187
If a / or ` replacement is done on a master the initial value is modified and therefor
 
188
also all mirrored placeholders are affected too, later on the replacement is not done anymore on master ranges
 
189
</p>
 
190
<p>
 
191
The parameters for invoked javascript functions will be the following:
 
192
value of the master (or initial value), //to be done: placeholder name, small wrapper around the template handler (to do more sophisticated things, like adding additional placehlder points, aattaching custom properties for state keeping, ....) you tell
 
193
</p>
 
194
<p>
 
195
Specification of initial values
 
196
You can specify initial values which are different from the placeholder name
 
197
this is done via, this makes only sense for $ placeholders, not for %
 
198
${placeholder:some value} or ${placeholder@:some value}
 
199
It is not allowed to mix : and /
 
200
after the first colon, everything is interpreted as default value, } in
 
201
the default value have to be escaped (backslashes before } have to be escaped themselves) and regexp searches are ignored. The : has to be
 
202
directly after the placeholder name or after an optional @symbol.
 
203
</p>
 
204
<p>
 
205
Common placeholders and values are
 
206
</p>
 
207
<p>
 
208
- index: "i"
 
209
- loginname: The current users's loginname
 
210
- firstname: The current user's first name retrieved from kabc
 
211
- lastname: The current user's last name retrieved from kabc
 
212
- fullname: The current user's first and last name retrieved from kabc
 
213
- email: The current user's primary email address retrieved from kabc
 
214
- date: current date
 
215
- time: current time
 
216
- year: current year
 
217
- month: current month
 
218
- day: current day
 
219
- hostname: hostname of the computer
 
220
- selection: The implementation should set this to the selected text, if any
 
221
- cursor: at this position the cursor will be after editing of the
 
222
template has finished, this has to be taken care of by the actual
 
223
implementation. The placeholder gets a value of "|" assigned.
 
224
</p>
 
225
<p>
 
226
If a macro is started with a % (persent sign) like "%{date}" it isn't added
 
227
to the list editable strings ( for example TAB key navigation) if a value
 
228
differing from the macro name is found.
 
229
</p>
 
230
<p>
 
231
If the editor supports some kind of smart indentation, the inserted code
 
232
should be layouted by the indenter.
 
233
<dl class="deprecated" compact><dt><b>Deprecated:</b></dt><dd>
 
234
</dd></dl>
 
235
</p></div></div><a class="anchor" name="insertTemplateTextImplementation"></a>
 
236
<div class="memitem">
 
237
<div class="memproto">
 
238
<table class="memname"><tr>
 
239
<td class="memname">bool insertTemplateTextImplementation</td>
 
240
<td>(</td>
 
241
<td class="paramtype">&nbsp;<em>self</em>, </td>
 
242
<td class="paramname"></td>
 
243
</tr><tr>
 
244
<td class="memname"></td>
 
245
<td></td>
 
246
<td class="paramtype"><a href="../ktexteditor/KTextEditor.Cursor.html">KTextEditor.Cursor</a>&nbsp;</td>
 
247
<td class="paramname"><em>insertPosition</em>, </td>
 
248
</tr>
 
249
<tr>
 
250
<td class="memname"></td>
 
251
<td></td>
 
252
<td class="paramtype">QString&nbsp;</td>
 
253
<td class="paramname"><em>templateString</em>, </td>
 
254
</tr>
 
255
<tr>
 
256
<td class="memname"></td>
 
257
<td></td>
 
258
<td class="paramtype">{QString:QString}&nbsp;</td>
 
259
<td class="paramname"><em>initialValues</em></td>
 
260
</tr>
 
261
<tr>
 
262
<td></td>
 
263
<td>)</td>
 
264
<td></td>
 
265
<td></td>
 
266
<td width="100%"> </td>
 
267
</tr></table>
 
268
</div>
 
269
<div class="memdoc"><dl compact><dt><b>Abstract method:</b></dt><dd>This method is abstract and can be overridden but not called directly.</dd></dl><p>You must implement this, it is called by insertTemplateText, after all
 
270
default values are inserted. If you are implementing this interface,
 
271
this method should work as described in the documentation for
 
272
insertTemplateText above.
 
273
<dl class="return" compact><dt><b>Returns:</b></dt><dd> true if any text was inserted.
 
274
</dd></dl> <dl class="deprecated" compact><dt><b>Deprecated:</b></dt><dd>
 
275
</dd></dl>
 
276
</p></div></div><hr><h2>Static Method Documentation</h2><a class="anchor" name="expandMacros"></a>
 
277
<div class="memitem">
 
278
<div class="memproto">
 
279
<table class="memname"><tr>
 
280
<td class="memname">bool expandMacros</td>
 
281
<td>(</td>
 
282
<td class="paramtype">{QString:QString}&nbsp;</td>
 
283
<td class="paramname"><em>initialValues</em>, </td>
 
284
</tr>
 
285
<tr>
 
286
<td class="memname"></td>
 
287
<td></td>
 
288
<td class="paramtype">QWidget&nbsp;</td>
 
289
<td class="paramname"><em>parentWindow</em></td>
 
290
</tr>
 
291
<tr>
 
292
<td></td>
 
293
<td>)</td>
 
294
<td></td>
 
295
<td></td>
 
296
<td width="100%"> </td>
 
297
</tr></table>
 
298
</div>
 
299
<div class="memdoc"><p>Parses <b>templateString</b> for macros in the form [$%]{NAME} and finds
 
300
the value corresponding to NAME if any. The NAME string may contain
 
301
any non-whitespace character execpt '}'
 
302
</p><dl compact><dt><b>Parameters:</b></dt><dd>
 
303
<table border="0" cellspacing="2" cellpadding="0">
 
304
<tr><td></td><td valign="top"><em>initialValues</em>&nbsp;</td><td> a map with the keys for the macros to expand.
 
305
keys with a value are ignored.
 
306
</td></tr> </table></dl>
 
307
<p> </p><dl compact><dt><b>Parameters:</b></dt><dd>
 
308
<table border="0" cellspacing="2" cellpadding="0">
 
309
<tr><td></td><td valign="top"><em>parentWindow</em>&nbsp;</td><td> is used if dialogs have to be shown
 
310
</td></tr> </table></dl>
 
311
<p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> true if all macros was successfully expanded
 
312
</dd></dl> <dl class="see" compact><dt><b>See also:</b></dt><dd> insertTemplateText for a list of supported macros
 
313
</dd></dl>
 
314
</p></div></div>
 
315
</div>
 
316
</div>
 
317
</div>
 
318
 
 
319
<div id="left">
 
320
 
 
321
<div class="menu_box">
 
322
<div class="nav_list">
 
323
<ul>
 
324
<li><a href="../allclasses.html">Full Index</a></li>
 
325
</ul>
 
326
</div>
 
327
 
 
328
<a name="cp-menu" /><div class="menutitle"><div>
 
329
  <h2 id="cp-menu-project">Modules</h2>
 
330
</div></div>
 
331
<div class="nav_list">
 
332
<ul><li><a href="../akonadi/index.html">akonadi</a></li>
 
333
<li><a href="../dnssd/index.html">dnssd</a></li>
 
334
<li><a href="../kdecore/index.html">kdecore</a></li>
 
335
<li><a href="../kdeui/index.html">kdeui</a></li>
 
336
<li><a href="../khtml/index.html">khtml</a></li>
 
337
<li><a href="../kio/index.html">kio</a></li>
 
338
<li><a href="../knewstuff/index.html">knewstuff</a></li>
 
339
<li><a href="../kparts/index.html">kparts</a></li>
 
340
<li><a href="../kutils/index.html">kutils</a></li>
 
341
<li><a href="../nepomuk/index.html">nepomuk</a></li>
 
342
<li><a href="../phonon/index.html">phonon</a></li>
 
343
<li><a href="../plasma/index.html">plasma</a></li>
 
344
<li><a href="../polkitqt/index.html">polkitqt</a></li>
 
345
<li><a href="../solid/index.html">solid</a></li>
 
346
<li><a href="../soprano/index.html">soprano</a></li>
 
347
</ul></div></div>
 
348
 
 
349
</div>
 
350
 
 
351
</div>
 
352
  <div class="clearer"/>
 
353
</div>
 
354
 
 
355
<div id="end_body"></div>
 
356
</div>
 
357
<div id="footer"><div id="footer_text">
 
358
This documentation is maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;simon&#64;simonzone&#46;com">Simon Edwards</a>.<br />
 
359
        KDE<sup>&#174;</sup> and <a href="../images/kde_gear_black.png">the K Desktop Environment<sup>&#174;</sup> logo</a> are registered trademarks of <a href="http://ev.kde.org/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
 
360
        <a href="http://www.kde.org/contact/impressum.php">Legal</a>
 
361
    </div></div>
 
362
</body>
 
363
</html>