~ubuntu-branches/debian/squeeze/geany-plugins/squeeze

« back to all changes in this revision

Viewing changes to geanylua/docs/geanylua-ref.html

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-07-10 22:56:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090710225641-xc1126t7pq0jmpos
Tags: upstream-0.17.1
ImportĀ upstreamĀ versionĀ 0.17.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
 
2
<html>
 
3
<head>
 
4
<title>Lua plugin for Geany - Reference</title>
 
5
<style type="text/css">
 
6
<!--
 
7
UL,PRE,P{
 
8
  margin:  12px 25% 12px 5%
 
9
}
 
10
.odd {
 
11
  background-color:#f4f4fc
 
12
}
 
13
.even {
 
14
  background-color:#ffffff
 
15
}
 
16
.desc {
 
17
  font-family:sans-serif
 
18
}
 
19
-->
 
20
</style>
 
21
</head>
 
22
<body >
 
23
<hr><h2>Lua scripting plugin for the Geany IDE</h2><hr><br>
 
24
The Geany module provides these functions and variables...<br><br><br>
 
25
<div style="background-color:#fcf4f4; margin-left:12px; margin-right:12px">
 
26
<hr>
 
27
<table summary="quick links" width="90%" align="center" >
 
28
<tr align="center" >
 
29
<td><a href="#Editor_functions">Editor functions</a></td>
 
30
<td><a href="#System_functions">System functions</a></td>
 
31
<td><a href="#Dialog_functions">Dialog functions</a></td>
 
32
</tr></table>
 
33
<hr>
 
34
</div>
 
35
<br><br>
 
36
 
 
37
<b><a name="Editor_functions"></a>Editor functions:</b>
 
38
 
 
39
<table style="font-family:monospace" summary="function index" width="90%">
 
40
<tr class="odd">
 
41
  <td>&nbsp; function <a href="#activate"><b>activate</b></a> ( tab_id )<br></td>
 
42
  <td class="desc">-- Focus the specified editor tab.</td>
 
43
</tr>
 
44
<tr class="even">
 
45
  <td>&nbsp; function <a href="#appinfo"><b>appinfo</b></a> ()<br></td>
 
46
  <td class="desc">-- Return information about the current Geany instance.</td>
 
47
</tr>
 
48
<tr class="odd">
 
49
  <td>&nbsp; function <a href="#batch"><b>batch</b></a> ( start )<br></td>
 
50
  <td class="desc">-- Set a marker for a reversible group of operations.</td>
 
51
</tr>
 
52
 
 
53
<tr class="even">
 
54
  <td>&nbsp; function <a href="#byte"><b>byte</b></a> ( [position] )<br></td>
 
55
  <td class="desc">-- Get the numeric value of the character at position.</td>
 
56
</tr>
 
57
<tr class="odd">
 
58
  <td>&nbsp; function <a href="#caret"><b>caret</b></a> ( [position] )<br></td>
 
59
  <td class="desc">-- Get or set the caret position.</td>
 
60
</tr>
 
61
 
 
62
<tr class="even">
 
63
  <td>&nbsp; function <a href="#close"><b>close</b></a> ( [filename]|[index] )<br></td>
 
64
  <td class="desc">-- Close a document.</td>
 
65
</tr>
 
66
 
 
67
<tr class="odd">
 
68
  <td>&nbsp; function <a href="#copy"><b>copy</b></a> ( [content]|[start,stop] )<br></td>
 
69
  <td class="desc">-- Copy text to the clipboard.</td>
 
70
</tr>
 
71
 
 
72
<tr class="even">
 
73
  <td>&nbsp; function <a href="#count"><b>count</b></a> ()<br></td>
 
74
  <td class="desc">-- Get the number of open tabs.</td>
 
75
</tr>
 
76
 
 
77
<tr class="odd">
 
78
  <td>&nbsp; function <a href="#cut"><b>cut</b></a> ()<br></td>
 
79
  <td class="desc">-- Cut selection to the clipboard.</td>
 
80
</tr>
 
81
 
 
82
<tr class="even">
 
83
  <td>&nbsp; function <a href="#documents"><b>documents</b></a> ( [doc_id] )<br></td>
 
84
  <td class="desc">-- Access the list of all open documents.</td>
 
85
</tr>
 
86
 
 
87
<tr class="odd">
 
88
  <td>&nbsp; function <a href="#filename"><b>filename</b></a> ()<br></td>
 
89
  <td class="desc">-- Get the name of the current document.</td>
 
90
</tr>
 
91
 
 
92
<tr class="even">
 
93
  <td>&nbsp; function <a href="#fileinfo"><b>fileinfo</b></a> ()<br></td>
 
94
  <td class="desc">-- Return some information about the current document.</td>
 
95
</tr>
 
96
 
 
97
<tr class="odd">
 
98
  <td>&nbsp; function <a href="#find"><b>find</b></a> ( phrase, start, stop, options )<br></td>
 
99
  <td class="desc">-- Search for text within the document.</td>
 
100
</tr>
 
101
 
 
102
<tr class="even">
 
103
  <td>&nbsp; function <a href="#height"><b>height</b></a> ()<br></td>
 
104
  <td class="desc">-- Get the number of lines in the current document</td>
 
105
</tr>
 
106
 
 
107
<tr class="odd">
 
108
  <td>&nbsp; function <a href="#keycmd"><b>keycmd</b></a> ( command )<br></td>
 
109
  <td class="desc">-- Activate a built-in Geany menu command.</td>
 
110
</tr>
 
111
 
 
112
<tr class="even">
 
113
  <td>&nbsp; function <a href="#keygrab"><b>keygrab</b></a> ( [prompt] )<br></td>
 
114
  <td class="desc">-- Intercept a keystroke from Geany.</td>
 
115
</tr>
 
116
 
 
117
 
 
118
<tr class="odd">
 
119
  <td>&nbsp; function <a href="#length"><b>length</b></a> ()<br></td>
 
120
  <td class="desc">-- Get number of characters in the current document.</td>
 
121
</tr>
 
122
 
 
123
<tr class="even">
 
124
  <td>&nbsp; function <a href="#lines"><b>lines</b></a> ( [index] )<br></td>
 
125
  <td class="desc">-- Get the text on one specific line, or all of them.</td>
 
126
</tr>
 
127
 
 
128
<tr class="odd">
 
129
  <td>&nbsp; function <a href="#match"><b>match</b></a> ( [position] )<br></td>
 
130
  <td class="desc">-- Find a matching bracket, parenthesis, etc.</td>
 
131
</tr>
 
132
 
 
133
<tr class="even">
 
134
  <td>&nbsp; function <a href="#navigate"><b>navigate</b></a> ( mode,count [,extend [,rect]])<br></td>
 
135
  <td class="desc">-- Move the caret incrementally.</td>
 
136
</tr>
 
137
 
 
138
<tr class="odd">
 
139
  <td>&nbsp; function <a href="#newfile"><b>newfile</b></a> ( [filename] )<br></td>
 
140
  <td class="desc">-- Create a new document.</td>
 
141
</tr>
 
142
 
 
143
<tr class="even">
 
144
  <td>&nbsp; function <a href="#open"><b>open</b></a> ( [filename]|[index] )<br></td>
 
145
  <td class="desc">-- Open or reload a file from disk.</td>
 
146
</tr>
 
147
 
 
148
<tr class="odd">
 
149
  <td>&nbsp; function <a href="#paste"><b>paste</b></a> ()<br></td>
 
150
  <td class="desc">-- Paste text from the clipboard.</td>
 
151
</tr>
 
152
 
 
153
 
 
154
<tr class="even">
 
155
  <td>&nbsp; function <a href="#rowcol"><b>rowcol</b></a> ( [pos]|[row,col] )<br></td>
 
156
  <td class="desc">-- Translate between linear and rectangular locations.</td>
 
157
</tr>
 
158
 
 
159
<tr class="odd">
 
160
  <td>&nbsp; function <a href="#save"><b>save</b></a> ( [filename]|[index] )<br></td>
 
161
  <td class="desc">-- Save an open document to a disk file.</td>
 
162
</tr>
 
163
 
 
164
<tr class="even">
 
165
  <td>&nbsp; function <a href="#scintilla"><b>scintilla</b></a> ( msg_id, wparam, lparam )<br></td>
 
166
  <td class="desc">-- Send a message directly to the Scintilla widget.</td>
 
167
</tr>
 
168
 
 
169
<tr class="odd">
 
170
  <td>&nbsp; function <a href="#select"><b>select</b></a> ( [[start,] stop] )<br></td>
 
171
  <td class="desc">-- Get or set the selection endpoints and caret.</td>
 
172
</tr>
 
173
 
 
174
<tr class="even">
 
175
  <td>&nbsp; function <a href="#selection"><b>selection</b></a> ( [content] )<br></td>
 
176
  <td class="desc">-- Get or set the contents of the document's selection.</td>
 
177
</tr>
 
178
 
 
179
<tr class="odd">
 
180
  <td>&nbsp; function <a href="#signal"><b>signal</b></a> ( widget, signal )<br></td>
 
181
  <td class="desc">-- Send a GTK signal to a Geany interface widget.</td>
 
182
</tr>
 
183
 
 
184
<tr class="even">
 
185
  <td>&nbsp; function <a href="#text"><b>text</b></a> ( [content] )<br></td>
 
186
  <td class="desc">-- Get or set the contents of the entire document.</td>
 
187
</tr>
 
188
 
 
189
<tr class="odd">
 
190
  <td>&nbsp; function <a href="#word"><b>word</b></a> ( [position] )<br></td>
 
191
  <td class="desc">-- Get the word at the specified location.</td>
 
192
</tr>
 
193
 
 
194
<tr class="even">
 
195
  <td>&nbsp; function <a href="#xsel"><b>xsel</b></a> ( [text] )<br></td>
 
196
  <td class="desc">-- Get or set the contents of the primary X selection.</td>
 
197
</tr>
 
198
 
 
199
<tr class="odd">
 
200
  <td>&nbsp; function <a href="#yield"><b>yield</b></a> ()<br></td>
 
201
  <td class="desc">-- Refreshes the user interface.</td>
 
202
</tr>
 
203
 
 
204
 
 
205
<tr class="even">
 
206
 <td>&nbsp;</td>
 
207
 <td></td>
 
208
</tr>
 
209
 
 
210
<tr class="odd">
 
211
<td>&nbsp; var <a href="#caller"><b>caller</b></a> : <i>number</i><br>
 
212
</td><td class="desc">-- The index of the document that triggered an event.</td>
 
213
</tr>
 
214
 
 
215
<tr class="even">
 
216
<td>&nbsp; var <a href="#rectsel"><b>rectsel</b></a> : <i>boolean</i><br>
 
217
</td><td class="desc">-- Whether or not the selection is in rectangular mode.</td>
 
218
</tr>
 
219
<tr class="odd">
 
220
<td>&nbsp; var <a href="#project"><b>project</b></a> : <i>keyfile</i><br>
 
221
</td><td class="desc">-- An object representing a project configuration event.</td>
 
222
</tr>
 
223
<tr class="even">
 
224
<td>&nbsp; var <a href="#script"><b>script</b></a> : <i>string</i><br>
 
225
</td><td class="desc">-- The filename of the currently executing Lua script.</td>
 
226
</tr>
 
227
<tr class="odd">
 
228
<td>&nbsp; var <a href="#wordchars"><b>wordchars</b></a> : <i>string</i><br></td>
 
229
<td class="desc">-- The characters that are considered part of a word.</td>
 
230
</tr>
 
231
 
 
232
</table>
 
233
 
 
234
 
 
235
<br>
 
236
<br><br>
 
237
 
 
238
<b><a name="System_functions"></a>System functions:</b>
 
239
<table style="font-family:monospace" summary="function index" width="90%">
 
240
<tr class="odd">
 
241
<td>&nbsp; function <a href="#basename"><b>basename</b></a>( pathstr )<br></td>
 
242
<td class="desc">-- Extract the filename portion of a path string.</td>
 
243
</tr>
 
244
<tr class="even">
 
245
<td>&nbsp; function <a href="#dirlist"><b>dirlist</b></a>( path )<br></td>
 
246
<td class="desc">-- List the contents of a folder.</td>
 
247
</tr>
 
248
<tr class="odd">
 
249
<td>&nbsp; function <a href="#dirname"><b>dirname</b></a>( pathstr )<br></td>
 
250
<td class="desc">-- Get the directory portion of a file's path.</td>
 
251
</tr>
 
252
<tr class="even">
 
253
<td>&nbsp; function <a href="#fullpath"><b>fullpath</b></a>( filename )<br></td>
 
254
<td class="desc">-- Get the full path to a file.</td>
 
255
</tr>
 
256
<tr class="odd">
 
257
  <td>&nbsp; function <a href="#launch"><b>launch</b></a> ( program [, arg1 [, arg2, ...]] )<br></td>
 
258
  <td class="desc">-- Execute an external application.</td>
 
259
</tr>
 
260
<tr class="even">
 
261
  <td>&nbsp; function <a href="#optimize"><b>optimize</b></a> ()<br></td>
 
262
  <td class="desc">-- Run a script without the debug hook.</td>
 
263
</tr>
 
264
<tr class="odd">
 
265
  <td>&nbsp; function <a href="#rescan"><b>rescan</b></a> ()<br></td>
 
266
  <td class="desc">-- Regenerate the scripts menu.</td>
 
267
</tr>
 
268
<tr class="even">
 
269
  <td>&nbsp; function <a href="#stat"><b>stat</b></a> ( filename [, lstat] )<br></td>
 
270
  <td class="desc">-- Retrieve some information about a disk file.</td>
 
271
</tr>
 
272
<tr class="odd">
 
273
  <td>&nbsp; function <a href="#timeout"><b>timeout</b></a> ( seconds )<br></td>
 
274
  <td class="desc">-- Control maximum time allowed for script execution.</td>
 
275
</tr>
 
276
<tr class="even">
 
277
  <td>&nbsp; function <a href="#wkdir"><b>wkdir</b></a> ( [folder] )<br></td>
 
278
  <td class="desc">-- Get or set the current working directory.</td>
 
279
</tr>
 
280
<tr class="even">
 
281
 <td>&nbsp;</td>
 
282
 <td></td>
 
283
</tr>
 
284
<tr class="odd">
 
285
<td>&nbsp; var <a href="#dirsep"><b>dirsep</b></a> : <i>string</i><br>
 
286
</td><td class="desc">-- The default filesystem path separator, "<tt>/</tt>" or "<tt>\</tt>".</td>
 
287
</tr>
 
288
</table>
 
289
 
 
290
<br>
 
291
<br><br>
 
292
 
 
293
<b><a name="Dialog_functions"></a>Dialog functions:</b>
 
294
<table style="font-family:monospace" summary="function index" width="90%">
 
295
<tr class="odd">
 
296
<td>&nbsp; function <a href="#choose"><b>choose</b></a> ( prompt, items )</td>
 
297
<td class="desc" width="33%">-- Select an item from the list.</td>
 
298
</tr>
 
299
<tr class="even">
 
300
<td>&nbsp; function <a href="#confirm"><b>confirm</b></a> ( title, question, default )</td>
 
301
<td class="desc">-- Ask a yes-or-no question.</td>
 
302
</tr>
 
303
<tr class="odd">
 
304
<td>&nbsp; function <a href="#input"><b>input</b></a> ( [prompt] [,default] )</td>
 
305
<td class="desc">-- Prompt to enter some text.</td>
 
306
</tr>
 
307
<tr class="even">
 
308
<td>&nbsp; function <a href="#message"><b>message</b></a> ( [title,] message )</td>
 
309
<td class="desc">-- Display some information.</td>
 
310
</tr>
 
311
<tr class="odd">
 
312
<td>&nbsp; function <a href="#pickfile"><b>pickfile</b></a> ( [mode [,path [,filter]]] )</td>
 
313
<td class="desc">-- Select a file from disk.</td>
 
314
</tr>
 
315
<tr class="even">
 
316
 <td>&nbsp;</td>
 
317
 <td></td>
 
318
</tr>
 
319
<tr class="odd">
 
320
<td>&nbsp; var <a href="#banner"><b>banner</b></a> : <i>string</i><br></td>
 
321
<td class="desc">-- The window title for all dialogs.</td>
 
322
</tr>
 
323
</table><br>
 
324
If you need a more advanced dialog creation API, check out the 
 
325
<tt><big><a href="geanylua-input.html">dialog</a></big></tt> module.
 
326
<br><br><br>
 
327
<hr>
 
328
 
 
329
 
 
330
<hr><a name="activate"></a><h3><tt>geany.activate ( tab_id )</tt></h3><p>
 
331
Activates the document specified by <tt><b>tab_id</b></tt>.
 
332
</p>
 
333
<p>
 
334
If <tt><b>tab_id</b></tt> is a number, it activates the document at that index.
 
335
 &nbsp; A <i>positive</i> number refers to the internal document array, and a <i>negative</i>
 
336
number refers to the (absolute) GtkNotebook index.<br>
 
337
Note that the indices begin at <tt>(1)</tt> and <tt>(-1)</tt> respectively.
 
338
</p>
 
339
<p>
 
340
If <tt><b>tab_id</b></tt> is a string, the function will try to activate the
 
341
notebook tab whose filename matches that string.<br>
 
342
( The full pathname is required! )
 
343
</p><p>
 
344
Returns <tt><b>true</b></tt> on success, or <tt><b>false</b></tt> if the tab could not be found.
 
345
</p><br><br>
 
346
 
 
347
<a name="appinfo"></a><hr><h3><tt>geany.appinfo ()</tt></h3><p>
 
348
Returns a Lua table containing information about the currently running Geany instance.<br><br>
 
349
The <tt>appinfo</tt> table contains the following fields:
 
350
<br>&nbsp;
 
351
<table border="0" summary="appinfo table fields">
 
352
<tr><td width="5%"></td><td><tt>debug</tt></td><td> -- <tt>true</tt> if Geany is running in debug mode.</td></tr>
 
353
<tr><td width="5%"></td><td><tt>configdir &nbsp; </tt></td><td> -- User's local configuration folder.</td></tr>
 
354
<tr><td width="5%"></td><td><tt>datadir</tt></td><td> -- System-wide configuration folder.</td></tr>
 
355
<tr><td width="5%"></td><td><tt>docdir</tt></td><td> -- Location of the Geany help files.</td></tr>
 
356
<tr><td width="5%"></td><td><tt>scriptdir</tt></td><td> -- Top level folder for GeanyLua scripts.</td></tr>
 
357
<tr><td width="5%"></td><td><tt>tools</tt></td><td> -- Table of user-configured tools. (see below)</td></tr>
 
358
<tr><td width="5%"></td><td><tt>template</tt></td><td> -- Table of user's template information. (see below)</td></tr>
 
359
<tr><td width="5%"></td><td><tt>project</tt></td><td> -- Table of current project information. (see below)</td></tr>
 
360
</table>
 
361
<p>
 
362
&mdash;&mdash;&mdash;&mdash;</p><p>
 
363
The <tt>tools</tt> sub-table contains the following fields:
 
364
<br>&nbsp;
 
365
<table border="0" summary="tools table fields">
 
366
<tr><td width="15%"></td><td><tt>browser</tt> </td></tr>
 
367
<tr><td width="15%"></td><td><tt>make</tt> </td></tr>
 
368
<tr><td width="15%"></td><td><tt>term</tt> </td><td></tr>
 
369
<tr><td width="15%"></td><td><tt>print</tt> </td></tr>
 
370
<tr><td width="15%"></td><td><tt>grep</tt> </td></tr>
 
371
<tr><td width="15%"></td><td><tt>action</tt> </td></tr>
 
372
</table>
 
373
<p>
 
374
&mdash;&mdash;&mdash;&mdash;</p><p>
 
375
The <tt>template</tt> sub-table contains the following fields:
 
376
<br>&nbsp;
 
377
<table border="0" summary="template fields">
 
378
<tr><td width="15%"></td><td><tt>developer</tt> </td></tr>
 
379
<tr><td width="15%"></td><td><tt>company</tt> </td></tr>
 
380
<tr><td width="15%"></td><td><tt>mail</tt> </td><td></tr>
 
381
<tr><td width="15%"></td><td><tt>initial</tt> </td></tr>
 
382
<tr><td width="15%"></td><td><tt>version</tt> </td></tr>
 
383
</table>
 
384
<p>
 
385
&mdash;&mdash;&mdash;&mdash;</p><p>
 
386
The <tt>project</tt> sub-table *might* contain the following fields:
 
387
<br>&nbsp;
 
388
<table border="0" summary="template fields">
 
389
<tr><td width="15%"></td><td><tt>name</tt> </td><td> -- Name of project.</td></tr>
 
390
<tr><td width="15%"></td><td><tt>desc</tt> </td><td> -- Project description.</td></tr>
 
391
<tr><td width="15%"></td><td><tt>file</tt> </td><td> -- Project filename.</td></tr>
 
392
<tr><td width="15%"></td><td><tt>base</tt> </td><td> -- Base path of project files.</td></tr>
 
393
<tr><td width="15%"></td><td><tt>exec</tt> </td><td> -- Default "run" command.</td></tr>
 
394
<tr><td width="15%"></td><td><tt>mask</tt> </td><td> -- Semicolon-delimited list of filetypes.</td></tr>
 
395
</table>
 
396
<p>
 
397
<b>* Important:</b> The entire <tt>project</tt> sub-table will be <tt>nil</tt> if there is no open project!<br>
 
398
<br><br>
 
399
 
 
400
<a name="basename"></a><hr><h3><tt>geany.basename ( pathstr )</tt></h3><p>
 
401
Returns the rightmost filename portion of <tt>pathstr</tt>, with the directory portion removed.
 
402
</p><br><br>
 
403
 
 
404
<hr><a name="batch"></a><h3><tt>geany.batch ( start )</tt></h3><p>
 
405
This function marks the beginning or ending of a group of operations<br>
 
406
that you want the user to be able to undo in a single step.</p>
 
407
<p>
 
408
If the <tt><b>start</b></tt> argument is <tt><b>true</b></tt>,
 
409
it marks the <i>beginning</i> of a group of operations.</p>
 
410
<p>
 
411
If the <tt><b>start</b></tt> argument is <tt><b>false</b></tt>,
 
412
it marks the <i>ending</i> of a group of operations.
 
413
</p><br><br>
 
414
 
 
415
<hr><a name="byte"></a><h3><tt>geany.byte ( [position] )</tt></h3><p>
 
416
When called with no arguments, returns the numeric value of the character at
 
417
the current caret position.</p><p>
 
418
When called with a numeric <tt><b>position</b></tt> argument, returns the
 
419
value of the character at that position.
 
420
</p><br><br>
 
421
 
 
422
 
 
423
<hr><a name="caret"></a><h3><tt>geany.caret ( [position] )</tt></h3><p>
 
424
When called with no arguments, returns the current caret position.</p>
 
425
<p>
 
426
When called with a single numeric argument, moves the caret to that position.<br>
 
427
Out-of-range values are adjusted to the nearest possible position (i.e. the start or end of the document.)
 
428
</p><br><br>
 
429
 
 
430
<a name="close"></a><hr><h3><tt>geany.close ( [filename]|[index] )</tt></h3>
 
431
<p>
 
432
When called with no arguments, closes the currently active document.
 
433
</p>
 
434
<p>
 
435
When called with a numeric argument, closes the file of that document index.
 
436
</p>
 
437
<p>
 
438
When called with a string argument, it will close that named document.
 
439
</p>
 
440
<p>
 
441
If the document has unsaved changes, the user will be prompted to save before closing,<br>
 
442
and will also be given the option to cancel the operation. &nbsp; To avoid this, you might <br>
 
443
want to consider using the <tt>geany.save()</tt> function beforehand.
 
444
</p>
 
445
<p>
 
446
Returns <tt><b>true</b></tt> if the document was successfully closed, or <tt><b>false</b></tt> otherwise.</p>
 
447
<br><br>
 
448
 
 
449
<hr><a name="copy"></a><h3><tt>geany.copy ( [content]|[start,stop] )</tt></h3><p>
 
450
When called with no arguments, copies the current selection to the clipboard.
 
451
</p><p>
 
452
When called with a single string argument, copies the contents of that string to the clipboard.
 
453
</p>
 
454
<p>
 
455
When called with two arguments, copies the portion of the current document's text
 
456
that lies between the <tt><b>start</b></tt> and <tt><b>stop</b></tt> positions.
 
457
(Both positions must be positive numbers.)
 
458
</p>
 
459
<p>
 
460
Returns the number of characters copied, or <tt><b>nil</b></tt> if there is no open document.
 
461
</p>
 
462
<br><br>
 
463
 
 
464
<hr><a name="count"></a><h3><tt>geany.count ()</tt></h3><p>
 
465
Returns the number of open documents.
 
466
</p><br><br>
 
467
 
 
468
 
 
469
<hr><a name="cut"></a><h3><tt>geany.cut ()</tt></h3><p>
 
470
Cuts the current selection to the clipboard.
 
471
</p>
 
472
<p>
 
473
Returns the number of characters cut, or <tt><b>nil</b></tt> if there is no open document.
 
474
</p><br><br>
 
475
 
 
476
 
 
477
<a name="dirlist"></a><hr><h3><tt>geany.dirlist ( path )</tt></h3><p>
 
478
Returns an iterator function that will be called once for each entry (file or subdirectory) in the specified folder.
 
479
The iterator produces only the name of each entry, and in no particular order.</p><p>
 
480
This function will generate an error dialog if the specified folder does not exist or cannot be accessed.
 
481
</p><br><br>
 
482
 
 
483
<a name="dirname"></a><hr><h3><tt>geany.dirname ( pathstr )</tt></h3><p>
 
484
Returns the directory portion of <tt>pathstr</tt>, with the rightmost filename portion removed.
 
485
</p><br><br>
 
486
 
 
487
<hr><a name="documents"></a><h3><tt>geany.documents ( [doc_id] )</tt></h3><p>
 
488
When called with a numeric argument, returns the full path and filename of <br>
 
489
the document at the index specified by <tt><b>doc_id</b></tt>.
 
490
</p>
 
491
<p>
 
492
When called with a string argument, returns the numeric index of the document with the<br>
 
493
path/filename that matches the <tt><b>doc_id</b></tt> string.<br>
 
494
</p>
 
495
<p>
 
496
Either of the two forms above may also return <tt><b>nil</b></tt> if the argument cannot be matched.</p>
 
497
<p>
 
498
Note: The <i>index</i> here refers to the editor's internal document array,
 
499
and might not be <br>
 
500
the same as the notebook tab index, since the tabs can be re-ordered by the user.
 
501
</p>
 
502
<p>
 
503
<br><br>
 
504
When called with no arguments, the function returns an iterator to list the full path and filename
 
505
of each document currently open in the editor.</p><p>
 
506
For example:</p>
 
507
<pre>
 
508
 
 
509
for filename in geany.documents()
 
510
do
 
511
  print(filename)
 
512
end
 
513
</pre>
 
514
 
 
515
<br><br>
 
516
 
 
517
 
 
518
<a name="filename"></a><hr><h3><tt>geany.filename ()</tt></h3><p>
 
519
Returns the full path and filename of the current Geany document.</p><p>
 
520
If there is no open document, or if the current document is untitled, returns <tt><b>nil</b></tt>.
 
521
</p><br><br>
 
522
 
 
523
 
 
524
<a name="fileinfo"></a><hr><h3><tt>geany.fileinfo ()</tt></h3><p>
 
525
Returns a Lua table containing various information about the current document.<br>
 
526
If there is no open document, returns <tt><b>nil</b></tt>.
 
527
</p><p>
 
528
The returned table contains the following fields:
 
529
<table border="0" summary="fileinfo fields">
 
530
<tr><td width="5%"></td><td><tt>name</tt> </td><td> -- The filename, without the path.</td></tr>
 
531
<tr><td width="5%"></td><td><tt>path</tt> </td><td> -- The full path of the file's directory, including the trailing slash.</td></tr>
 
532
<tr><td width="5%"></td><td><tt>ext</tt> </td><td> -- The file extension, including the dot, e.g. "<b>.DLL</b>" or "<b>.txt</b>"</td></tr>
 
533
<tr><td width="5%"></td><td><tt>type</tt> </td><td> -- A one-word description of the filetype, e.g. "<b>C</b>" or "<b>Python</b>".</td></tr>
 
534
<tr><td width="5%"></td><td><tt>desc</tt> </td><td> -- A longer description of the filetype, e.g. "<b>Lua source file</b>" or "<b>Cascading StyleSheet</b>".</td></tr>
 
535
<tr><td width="5%"></td><td><tt>opener</tt> </td><td> -- The string used to begin a comment, e.g. "<b class="desc">&lt;!--</b>".</td></tr>
 
536
<tr><td width="5%"></td><td><tt>closer</tt> </td><td> -- The string used to end a comment, e.g. "<b class="desc">--&gt;</b>".</td></tr>
 
537
<tr><td width="5%"></td><td><tt>action</tt> </td><td> -- The action command as executed by the context menu</td></tr>
 
538
<tr><td width="5%"></td><td><tt>compiler</tt> </td><td> -- The command used to compile this type of file.</td></tr>
 
539
<tr><td width="5%"></td><td><tt>linker</tt> </td><td> -- The command used to link this type of file.</td></tr>
 
540
<tr><td width="5%"></td><td><tt>exec</tt> </td><td> -- The primary command used to execute this type of file.</td></tr>
 
541
<tr><td width="5%"></td><td><tt>exec2</tt> </td><td> -- An alternative command used to execute this type of file.</td></tr>
 
542
<tr><td width="5%"></td><td><tt>ftid</tt> </td><td> -- The unique numeric filetype identifier, as used by Geany.</td></tr>
 
543
<tr><td width="5%"></td><td><tt>encoding</tt> </td><td> -- The file's in-memory encoding. (may differ from the on-disk encoding.)</td></tr>
 
544
<tr><td width="5%"></td><td><tt>bom</tt> </td><td> -- <tt><b>true</b></tt> if the file contains a <b>B</b>yte-<b>O</b>rder <b>M</b>arker.</td></tr>
 
545
<tr><td width="5%"></td><td><tt>changed</tt> </td><td> -- <tt><b>true</b></tt> if the file has unsaved changes.</td></tr>
 
546
<tr><td width="5%"></td><td><tt>readonly</tt> </td><td> -- <tt><b>true</b></tt> if the in-memory document is tagged as read-only.</td></tr>
 
547
</table>
 
548
<br><br>
 
549
 
 
550
 
 
551
 
 
552
<a name="find"></a><hr><h3><tt>geany.find ( phrase, start, stop, options )</tt></h3><p>
 
553
Searches within the current document for the string <tt>phrase</tt>, beginning at <br>
 
554
the numeric <tt>start</tt> position and ending at the <tt>stop</tt> position.<br>
 
555
( To search backwards, specify a <tt>start</tt> value greater than <tt>stop</tt> . )<br><br>
 
556
</p><p>
 
557
 
 
558
 
 
559
The <tt>options</tt> argument is a table, each element may be one of the following strings:<br>
 
560
 
 
561
<table border="0" summary="search options">
 
562
<tr><td width="3%">&nbsp;</td><td width="20%"><tt>
 
563
"matchcase"</tt></td><td> -- A match only occurs with text that matches the case of the search string.
 
564
</td></tr>
 
565
<tr><td>&nbsp;</td><td><tt>
 
566
"wholeword" </tt> </td><td> -- A match only occurs if the characters before and after are not word characters.
 
567
</td></tr>
 
568
<tr><td>&nbsp;</td><td><tt>
 
569
"wordstart" </tt> </td><td> -- A match only occurs if the character before is not a word character.
 
570
</td></tr>
 
571
<tr><td>&nbsp;</td><td><tt>
 
572
"regexp" </tt> </td><td> -- The search string should be interpreted as a regular expression.
 
573
</td></tr>
 
574
<tr><td>&nbsp;</td><td><tt>
 
575
"posix" </tt> </td><td> -- Use bare parentheses
 
576
<tt><b>(</b></tt> 
 
577
<tt><b>)</b></tt> 
 
578
for tagged sections rather than the escaped <tt><b>\(</b></tt> and <tt><b>\)</b></tt>.
 
579
</td></tr>
 
580
<tr><td colspan="3">
 
581
( The empty set <tt><b>{}</b></tt> may also be specified, to search using the default options. )
 
582
</td></tr>
 
583
</table>
 
584
<p>
 
585
If a match is found, the function returns the starting and ending positions of the match,<br>
 
586
otherwise it returns <tt><b>nil</b>.</tt>
 
587
</p><p>
 
588
For example, to select the first case-sensitive whole-word match of the string
 
589
 &nbsp;'<b>foobar</b>'&nbsp; you could use something like this:</p>
 
590
<pre>
 
591
 a,b = geany.find( "foobar", 0, geany.length(), {"wholeword","matchcase"} )
 
592
 if (a) then
 
593
   geany.select(a,b)
 
594
 else
 
595
   geany.message("Search phrase not found.")
 
596
 end
 
597
</pre><br><br>
 
598
 
 
599
 
 
600
 
 
601
<a name="fullpath"></a><hr><h3><tt>geany.fullpath ( filename )</tt></h3><p>
 
602
Returns the fully canonicalized form of the path to an <i>existing</i> named file, or <tt>nil</tt> if the path could not be found.
 
603
</p><br><br>
 
604
 
 
605
 
 
606
 
 
607
 
 
608
<a name="height"></a><hr><h3><tt>geany.height ()</tt></h3><p>
 
609
Returns the total number of  lines in the current document.
 
610
</p><br><br>
 
611
 
 
612
<a name="keycmd"></a><hr><h3><tt>geany.keycmd ( command )</tt></h3><p>
 
613
Activates (runs) one of Geany's built-in menu commands.</p><p>
 
614
The <tt>command</tt> argument should be one the string constants defined in the
 
615
"<tt>glspi_keycmd.h</tt>" header from the plugin sources. &nbsp;
 
616
For example, to display Geany's preferences dialog, you could use:</p><p>
 
617
<tt> &nbsp; geany.keycmd("MENU_PREFERENCES")</tt>
 
618
</p>
 
619
<p>
 
620
This function raises an error if the command argument is invalid.
 
621
</p><br><br>
 
622
 
 
623
 
 
624
 
 
625
 
 
626
 
 
627
<a name="keygrab"></a><hr><h3><tt>geany.keygrab ( [prompt] )</tt></h3><p>
 
628
 
 
629
Intercepts the next keyboard key pressed, preventing the editor from receiving
 
630
that keyboard event.</p>
 
631
<p>
 
632
The function returns the value of the pressed key as a string,
 
633
alphanumeric keys will return their keyboard value, such as
 
634
&nbsp;<tt>"a"</tt>&nbsp; or &nbsp;<tt>"1"</tt>&nbsp; while other keys may
 
635
return a string describing the key, such
 
636
as <tt>"Return"</tt> or <tt>"Escape"</tt>. &nbsp;
 
637
( Consult the file &nbsp;<tt>gdk/gdkkeysyms.h</tt>&nbsp; in the GTK sources for some idea of the key names. )
 
638
</p><p>
 
639
It should be possible to use this function on keyboards other than US,
 
640
although this hasn't been tested, and scripts written for one keyboard
 
641
might not be portable to another system. </p>
 
642
<p>Key combinations with the modifier keys &nbsp;<b>[Ctrl]</b> &nbsp;or&nbsp; <b>[Alt]</b>&nbsp;
 
643
are not supported. &nbsp; Detection of the &nbsp;<b>[Shift]</b>&nbsp; key state is somewhat supported,
 
644
although currently it may not be completely reliable.
 
645
&nbsp; Repeatedly calling this function in rapid succession (as in a loop) may also result in some "dropped" keys,
 
646
so for best results its use should be confined to detecting a single "lowercase" key press.</p><p>
 
647
 
 
648
If the optional <tt>prompt</tt> string argument is present, its text will be shown
 
649
as a "calltip" near the upper left-hand area of the current document.
 
650
(but only if there is a document open.)</p>
 
651
<p>
 
652
This function was primarily intended for assigning "chained" sets of hot key
 
653
options, in conjunction with user-defined <a href="geanylua-keys.html">keybindings</a>.
 
654
 
 
655
 
 
656
</p>
 
657
<p>
 
658
 
 
659
</p><br><br>
 
660
 
 
661
 
 
662
 
 
663
 
 
664
 
 
665
<a name="launch"></a><hr><h3><tt>geany.launch ( program [, arg1 [, arg2, ...]] )</tt></h3><p>
 
666
Executes the external application specified by &nbsp;<tt>program</tt>,&nbsp;
 
667
passing any additional arguments to its command line.
 
668
</p>
 
669
<p>
 
670
Returns <tt>true</tt> if the process was succesfully created, else it returns <tt>false</tt> plus an error message.</p>
 
671
<p>
 
672
For example:<br><tt>
 
673
&nbsp; local ok,msg = geany.launch("firefox", "http://www.yahoo.com/")<br>
 
674
&nbsp; if not ok then geany.message(msg) end</tt>
 
675
</p>
 
676
<p>
 
677
This function returns immediately, regardless of the status of the newly-created process.
 
678
If you need to wait for a process to complete before returning,
 
679
use Lua's built-in &nbsp;<tt>os.execute()</tt>&nbsp; function instead.
 
680
</p>
 
681
<p>Note that using this function on MS-Windows might require installing the
 
682
"<b><tt>gspawn-win32-helper.exe</tt></b>" program somewhere in your <tt>PATH</tt>. &nbsp;
 
683
( It is included in the GTK/GLib package. )</p>
 
684
<br><br>
 
685
 
 
686
 
 
687
<a name="length"></a><hr><h3><tt>geany.length ()</tt></h3><p>
 
688
Returns the text length of the current document.
 
689
</p><br><br>
 
690
 
 
691
 
 
692
<a name="lines"></a><hr><h3><tt>geany.lines ( [index] )</tt></h3><p>
 
693
When called with one argument, returns a string containing the text at
 
694
the specified line number of the current document.<br>
 
695
It may also return <tt><b>nil</b></tt> if there is no open document,
 
696
or if the specified <tt><b>index</b></tt> is outside the range of lines.
 
697
</p><p>
 
698
When called without any arguments, it returns an iterator that steps
 
699
through each line of the current document. <br>
 
700
So you can use it like this:<pre>
 
701
for line in geany.lines()
 
702
do
 
703
  print(line)
 
704
end
 
705
</pre>
 
706
<br><br>
 
707
 
 
708
 
 
709
<a name="match"></a><hr><h3><tt>geany.match ( [position] )</tt></h3><p>
 
710
Attempts to find a corresponding matching brace from the given <tt><b>position</b></tt> of one brace.<br>
 
711
( If the <tt><b>position</b></tt> argument is omitted, the current caret position is assumed. )
 
712
</p>
 
713
<p>The brace characters handled are: <tt><b>&nbsp; () [] {} &lt;&gt;</b></tt></p>
 
714
<p> The search is forwards from an opening brace and backwards from a closing brace.<br>
 
715
If the character at <tt><b>position</b></tt> is not a brace character, or a matching brace cannot be found,<br>
 
716
the return value is -1. Otherwise, the return value is the position of the matching brace.
 
717
</p><br><br>
 
718
 
 
719
 
 
720
 
 
721
<a name="navigate"></a><hr><h3><tt>geany.navigate ( mode, count [,extend [,rect]] )</tt></h3><p>
 
722
Moves the caret incrementally.</p>
 
723
<p>
 
724
The &nbsp;<tt><b>mode</b></tt> &nbsp;argument must be one of the following strings:
 
725
<ul>
 
726
<li><tt>"char"</tt> &nbsp; -- Move by characters.</li>
 
727
<li><tt>"part"</tt> &nbsp; -- Move by segments in <big>MixedCase</big> or <big>under_score</big> style identifiers.</li>
 
728
<li><tt>"word"</tt> &nbsp; -- Move by words.</li>
 
729
<li><tt>"edge"</tt> &nbsp; -- Move to beginning or end of current line.</li>
 
730
<li><tt>"line"</tt> &nbsp; -- Move up or down by lines.</li>
 
731
<li><tt>"para"</tt> &nbsp; -- Move up or down by paragraphs.</li>
 
732
<li><tt>"page"</tt> &nbsp; -- Move up or down by pages.</li>
 
733
<li><tt>"body"</tt> &nbsp; -- Move to the beginning or end of the entire document.</li>
 
734
</ul>
 
735
<p>
 
736
If the numeric <tt><b>count</b></tt> argument is <i>positive</i>, the caret is moved <i>forward</i> or <i>down</i> by that many steps.<br>
 
737
If it is <i>negative</i>, the caret is moved <i>backward</i> or <i>up</i> by that many steps.<br>
 
738
( If it is <i>zero</i> there is not much point in using this function. )<br>
 
739
There is also no point in using a magnitude greater than <i>one</i> for the <tt>"edge"</tt> or <tt>"body"</tt> modes.
 
740
</p>
 
741
<p>
 
742
If the optional boolean <tt><b>extend</b></tt> argument is <tt><b>true</b></tt>,
 
743
the selection is expanded or contracted to the new caret position,
 
744
similar to holding down the&nbsp; <big>[Shift]</big> &nbsp;key when navigating with the keyboard.
 
745
</p><p>
 
746
If the optional boolean <tt><b>rect</b></tt> argument is also <tt><b>true</b></tt>,
 
747
the selection is treated as <i>rectangular</i> rather than <i>linear</i>.<br>
 
748
( Rectangular selection is only supported for <tt>char</tt>, <tt>edge</tt>,
 
749
<tt>line</tt>, or <tt>page</tt> modes. )
 
750
</p>
 
751
<br><br>
 
752
 
 
753
 
 
754
<a name="newfile"></a><hr><h3><tt>geany.newfile ( [filename] )</tt></h3><p>
 
755
When called with one argument, creates a new document with the specified
 
756
<tt>filename</tt>. </p><p>When called with no arguments, creates a new, untitled document.
 
757
</p><br><br>
 
758
 
 
759
 
 
760
 
 
761
<a name="open"></a><hr><h3><tt>geany.open ( [filename]|[index] )</tt></h3><p>
 
762
When called with no arguments, reloads the currently active document from disk.
 
763
</p><p>
 
764
When called with a numeric argument, reloads the file of that document index.
 
765
</p><p>
 
766
When called with a string argument, it will reload that filename if it is already open,
 
767
or otherwise it will open it in a new tab. <br>
 
768
It will not create a non-existent file, for that you need to use <tt>geany.newfile()</tt>
 
769
</p>
 
770
<p>
 
771
Returns the <i>one-based</i> document index on success,
 
772
or <i>zero</i> if the document could not be opened or reloaded.</p>
 
773
<br><br>
 
774
 
 
775
<a name="optimize"></a><hr><h3><tt>geany.optimize ()</tt></h3><p>
 
776
Disables the Lua interpreter's "debug hook", the thing that
 
777
allows the plugin to track line number information and elapsed time.</p><p>
 
778
The advantage of calling <tt>optimize()</tt> is that a lengthy, CPU-intensive
 
779
script can sometimes run much faster.
 
780
</p><p>
 
781
The disadvantage is that you lose the line number information that helps in
 
782
debugging your script, and the built-in protection against things like endless loops.
 
783
For this reason you should only use this function if you really need it, and
 
784
only when you are reasonably sure that your script doesn't contain any errors.
 
785
</p><p>For best results this function should be called at the very
 
786
beginning of the script.
 
787
 
 
788
</p>
 
789
<br><br>
 
790
 
 
791
<a name="paste"></a><hr><h3><tt>geany.paste ()</tt></h3><p>
 
792
Pastes the text from the clipboard into the active document at the current caret position,<br>
 
793
replacing any current selection.
 
794
</p><p>
 
795
Returns <tt><b>nil</b></tt> if there is no open document,
 
796
or if the document is marked read-only.</p><p>
 
797
Otherwise it returns the effective change in the document's size. <br>
 
798
( Which may actually be negative, if the clipboard content size is less than the prior selection. )
 
799
</p>
 
800
<br><br>
 
801
 
 
802
 
 
803
<a name="rescan"></a><hr><h3><tt>geany.rescan ()</tt></h3><p>
 
804
Scans the scripts folder, rebuilds the <b><i>Tools-><u>L</u>ua Scripts</i></b> menu,
 
805
and re-initializes the GTK accelerator group (keybindings) associated with the plugin.
 
806
</p><br><br>
 
807
 
 
808
 
 
809
<a name="rowcol"></a><hr><h3><tt>geany.rowcol ( [position]|[line,column] )</tt></h3><p>
 
810
This function translates between line/column coordinates and linear position (offset from beginning of document).<br>
 
811
</p>
 
812
<p>The syntax takes three forms:</p>
 
813
<ul>
 
814
<li>
 
815
With <i>no</i> arguments, it returns the rectangular coordinates of the current caret position:<br>
 
816
<tt>&nbsp; line, column = geany.rowcol()</tt><br>
 
817
( Note that in Lua a single function call like the one above returns both values! )<br><br>
 
818
</li>
 
819
<li>
 
820
With <i>one</i> argument, it it returns the rectangular coordinates of the specified <tt><b>position</b></tt>
 
821
argument:<br>
 
822
<tt>&nbsp; line, column = geany.rowcol(position)</tt><br><br>
 
823
</li>
 
824
 
 
825
<li>
 
826
With <i>two</i> arguments, it translates from the given <tt><b>line</b></tt> and <tt><b>column</b></tt>
 
827
to the linear position:<br>
 
828
<tt>&nbsp; position = geany.rowcol(line,column)</tt>
 
829
</li>
 
830
</ul>
 
831
<p>
 
832
Out-of-range arguments are adjusted to the nearest valid possibility.
 
833
</p><br><br>
 
834
 
 
835
<a name="save"></a><hr><h3><tt>geany.save ( [filename]|[index] )</tt></h3><p>
 
836
When called with no arguments, saves the currently active document to disk.
 
837
</p><p>
 
838
When called with a numeric argument, saves the file of that document index.
 
839
</p><p>
 
840
When called with a string argument, it will save that named document ( That is, of course, if it is open. )
 
841
</p>
 
842
<p>
 
843
Returns <tt><b>true</b></tt> on success, or <tt><b>false</b></tt> if the document could not be saved.</p>
 
844
<br><br>
 
845
 
 
846
 
 
847
<a name="scintilla"></a><hr><h3><tt>geany.scintilla ( msg_id [, wparam [, lparam]] )</tt></h3><p>
 
848
<i>Power users only!</i>
 
849
</p>
 
850
<p>
 
851
Sends a <tt><b>SCI_*</b></tt> message directly to the Scintilla widget of the active document.</p>
 
852
<p>
 
853
The <tt><b>msg_id</b></tt> can be a numeric value, or a case-insensitive string with or
 
854
without the <tt>"SCI_"</tt> prefix, 
 
855
such as <tt>"SCI_POSITIONFROMPOINT"</tt>, <tt>"POSITIONFROMPOINT"</tt>, or <tt>"PositionFromPoint"</tt>.
 
856
</p><p>
 
857
The wparam, lparam, and return types depend on the particular message, based on the
 
858
interface described in the &nbsp;"<tt><small>Scintilla.iface</small></tt>"&nbsp; file from the Scintilla sources.
 
859
</p><p>
 
860
For API calls which expect a pre-allocated char buffer as the lparam, the allocation is 
 
861
automatically managed 
 
862
by the GeanyLua module, your lparam is ignored, and the return value is a Lua string.&nbsp; 
 
863
In cases where the length is specified 
 
864
in the wparam, the null terminator is not counted - if you ask for 3 chars, you get 3 chars.
 
865
</p><p>
 
866
Currently only string, numeric, and boolean types are supported, any API call that
 
867
expects or returns complex types will result in an error. &nbsp;This function tries hard to 
 
868
protect from garbage being passed to
 
869
Scintilla, but ultimately <i>you</i> are expected to know what you're doing!
 
870
</p><br><br>
 
871
 
 
872
<a name="select"></a><hr><h3><tt>geany.select ( [[start,] stop]] )</tt></h3><p>
 
873
When called with no arguments, returns the beginning <b><i>and</i></b> ending points of
 
874
the current selection, in the form:<br>
 
875
<tt>
 
876
&nbsp; start, stop = geany.select()
 
877
</tt><br>
 
878
( Note that in Lua a single function call like the one above returns both values! )</p>
 
879
<p>
 
880
To find out if the selection is rectangular, test the
 
881
boolean variable <tt><b>geany.rectsel</b></tt> immediately after this call.
 
882
</p>
 
883
<p><br>
 
884
If this function is called with two arguments, it creates a new selection in
 
885
the current document.
 
886
<br> The selection is <i>anchored</i> at the <tt><b>start</b></tt>
 
887
position, and <i>extended</i> to the <tt><b>stop</b></tt> position.</p><p>
 
888
The boolean variable <tt><b>geany.rectsel</b></tt> can be set prior to this
 
889
call to control 
 
890
whether this selection is created in normal or rectangular mode.
 
891
</p>
 
892
<p><br>
 
893
If called with one argument, the caret is moved to that position, but no selection is created,<br>
 
894
and any existing selection is lost.
 
895
</p>
 
896
<p>
 
897
<br>
 
898
Note that in all cases, the value of <tt><b>stop</b></tt> is considered to be
 
899
the end of the selection where the caret is located.</p><p>
 
900
So, if <tt><b>stop</b></tt> is less than <tt><b>start</b></tt>, the caret is postioned
 
901
at the <i>beginning</i> of the selection, <br>similar to a selection created by
 
902
dragging the mouse <i>backwards</i> in the document.</p>
 
903
<p>
 
904
<b>Hint:</b> To select the entire document, you can use: &nbsp;
 
905
<tt>geany.select( 0, geany.length() )</tt>
 
906
</p><br><br>
 
907
 
 
908
 
 
909
<a name="selection"></a><hr><h3><tt>geany.selection ( [content] )</tt></h3><p>
 
910
When called with no arguments, returns the selected text in the current Geany
 
911
document as a string. <br>
 
912
Returns the empty string if no text is selected, or <tt><b>nil</b></tt>
 
913
if there is no open document.
 
914
</p><p>When called with one argument, the selected text of the current document
 
915
will be replaced with the specified <tt>content</tt>
 
916
string.<br>
 
917
If no text is currently selected, the text will be inserted at the current
 
918
(caret) position.
 
919
</p><br><br>
 
920
 
 
921
<a name="signal"></a><hr><h3><tt>geany.signal ( widget, signal )</tt></h3><p>
 
922
Emits a GTK signal to a given widget in the Geany user interface.</p><p>
 
923
The <tt>widget</tt> argument is a string identifying the widget by its Glade &nbsp;<tt><b>"id"</b></tt>&nbsp; attribute.<br>
 
924
The <tt>signal</tt> argument is a string identifying the signal to be emitted.
 
925
</p><p>
 
926
This function was primarily intended for activating Geany's builtin menu commands.<br>
 
927
For instance, to display the file open dialog you could do:<br> 
 
928
<tt> &nbsp; geany.signal("menu_open1", "activate")</tt>
 
929
</p><p>
 
930
The function does not return a value, but may trigger an error message if the
 
931
widget name is not found or the signal name is not valid for the specified widget.
 
932
 &nbsp; 
 
933
Note that it is generally easier and more reliable to use the <tt>keycmd()</tt> function whenever possible.
 
934
</p><br><br>
 
935
 
 
936
<a name="stat"></a><hr><h3><tt>geany.stat( filename [, lstat] )</tt></h3><p>
 
937
Returns a table providing some (limited) information about the specified file.<br>
 
938
If the information could not be obtained, the function returns <tt>nil</tt> plus an string describing the reason for failure.
 
939
</p>
 
940
<p>
 
941
If the file is a symbolic link, and  the optional &nbsp;<tt>lstat</tt>&nbsp; argument is <tt>true</tt>, the
 
942
information is returned about the link itself, otherwise the table provides
 
943
information about the file that the link points to.
 
944
</p><p>
 
945
The returned table contains the following fields:
 
946
<table border="0" summary="stat table fields">
 
947
<tr><td width="5%"></td><td><tt>size </tt></td><td> -- The size of the file, in bytes.</td></tr>
 
948
<tr><td width="5%"></td><td><tt>time </tt></td><td> -- Modification time, in seconds from the epoch.</td></tr>
 
949
<tr><td width="5%"></td><td><tt>type </tt></td><td> -- A single-character string that denotes the type of file (see below)</td></tr>
 
950
<tr><td width="5%"></td><td><tt>read </tt></td><td> -- <tt>true</tt> if the effective user can read from the file.</td></tr>
 
951
<tr><td width="5%"></td><td><tt>write</tt></td><td> -- <tt>true</tt> if the effective user can modify the file.</td></tr>
 
952
<tr><td width="5%"></td><td><tt>exec </tt></td><td> -- <tt>true</tt> if the effective user can execute the file.</td></tr>
 
953
</table>
 
954
<p><br>
 
955
The <tt>type</tt> field contains one of the following values:
 
956
<table border="0" summary="stat table type field values">
 
957
<tr><td width="5%"></td><td><tt>"b" </tt></td><td> -- a block-oriented device.</td></tr>
 
958
<tr><td width="5%"></td><td><tt>"c" </tt></td><td> -- a character-special device.</td></tr>
 
959
<tr><td width="5%"></td><td><tt>"d" </tt></td><td> -- a directory.</td></tr>
 
960
<tr><td width="5%"></td><td><tt>"f" </tt></td><td> -- a FIFO or named pipe.</td></tr>
 
961
<tr><td width="5%"></td><td><tt>"l" </tt></td><td> -- a symbolic link.</td></tr>
 
962
<tr><td width="5%"></td><td><tt>"r" </tt></td><td> -- a regular file.</td></tr>
 
963
<tr><td width="5%"></td><td><tt>"s" </tt></td><td> -- a socket.</td></tr>
 
964
</table>
 
965
<p>
 
966
Note that this function does not support symbolic links or ACL permissions on MS-Windows.
 
967
</p><br><br>
 
968
 
 
969
 
 
970
 
 
971
<a name="text"></a><hr><h3><tt>geany.text ( [content] )</tt></h3><p>
 
972
When called with no arguments, returns the entire text of the currently
 
973
active Geany document as a string.<br>( Returns <tt><b>nil</b></tt>
 
974
if there is no open document.)
 
975
</p><p>
 
976
When called with one argument, the entire text of the current
 
977
document is replaced with the specified <tt>content</tt> string.
 
978
</p><br><br>
 
979
 
 
980
 
 
981
<a name="timeout"></a><hr><h3><tt>geany.timeout ( seconds )</tt></h3><p>
 
982
 
 
983
Attempts to control the maximum time allowed, in whole seconds, for the current script to
 
984
finish execution.</p><p>
 
985
By default, scripts are allowed 15 seconds to complete, but if your script needs
 
986
more time, you can increase it here. 
 
987
</p><p>
 
988
Note that the interpreter is only able to trigger this "timeout exceeded" error when it is actually processing instructions.
 
989
This provides protection against things like accidentally creating an endless loop,
 
990
but it might still be possible to create a script that hangs indefinitely. ( For instance if
 
991
you call <tt>io.read()</tt> without access to a terminal. )</p><p>
 
992
The internal timer is paused whenever one of the dialog box functions is called,
 
993
to allow the user time to respond.
 
994
</p><p>
 
995
Setting the timeout to zero will disable it completely, that is, the script will never time out.
 
996
</p><p><br><br>
 
997
 
 
998
<a name="wkdir"></a><hr><h3><tt>geany.wkdir ( [folder] )</tt></h3><p>
 
999
When called with no arguments, returns the current working directory.</p>
 
1000
<p>
 
1001
When called with one argument, tries to change into that <tt>folder</tt>,
 
1002
and returns <tt>true</tt> on sucess, or <tt>false</tt> plus an error message
 
1003
on failure.
 
1004
</p><br><br>
 
1005
 
 
1006
<a name="word"></a><hr><h3><tt>geany.word ( [position] )</tt></h3><p>
 
1007
When called with no arguments, returns the word at the current caret position.
 
1008
</p><p>
 
1009
When called with one argument, returns the word at the specified
 
1010
<tt><b>position</b></tt>.
 
1011
</p><p>
 
1012
This function can return an empty string if the position is not touching
 
1013
a character that is considered to be part of a word. You can modify this
 
1014
set of characters in the <tt><b>geany.wordchars</b></tt> variable.
 
1015
</p><br><br>
 
1016
 
 
1017
 
 
1018
<a name="xsel"></a><hr><h3><tt>geany.xsel ( [text] )</tt></h3><p>
 
1019
When called with no arguments, returns the text-based contents of the primary X selection.
 
1020
</p><p>
 
1021
When called with one argument, assigns that <tt>text</tt> as the contents of the primary X selection.
 
1022
 
 
1023
</p><p>
 
1024
This function is only valid for X-Window environments, on MS-Windows, it does nothing.
 
1025
</p><br><br>
 
1026
 
 
1027
<a name="yield"></a><hr><h3><tt>geany.yield ()</tt></h3><p>
 
1028
Temporarily returns control to the IDE, to allow user interface elements to
 
1029
be refreshed/repainted during lengthy script operations.
 
1030
</p><p>Since most scripts will probably have a run time of less than a couple of seconds,
 
1031
you will likely never need this function. But if you do, it should be used with caution,
 
1032
since it allows Geany's state to be changed during script execution. This could have
 
1033
unpleasant consequences, for instance if the user closes a document that the script is referencing.
 
1034
</p>
 
1035
<br><br>
 
1036
<br><br>
 
1037
<hr><hr>
 
1038
 
 
1039
<!-- Dialog functions -->
 
1040
<h3>&nbsp; &nbsp; &nbsp; Dialog functions</h3>
 
1041
<hr>
 
1042
 
 
1043
<a name="choose"></a><hr><h3><tt>geany.choose ( prompt, items )</tt></h3><p>
 
1044
Displays a dialog box to allow the user to choose from a list of items. </p><p>
 
1045
The <tt>prompt</tt> argument string will display a message above the list box
 
1046
to explain the request.</p><p>
 
1047
The <tt>items</tt> argument is a Lua table, each element of the table must be
 
1048
a string.
 
1049
</p><p>
 
1050
The function returns the selected item as a string:</p>
 
1051
<ul>
 
1052
<li>If the <b>OK</b> button is clicked,
 
1053
<li>If the [Return] key is pressed while the item list is active.
 
1054
<li>If the user double-clicks an item in the list.
 
1055
</ul>
 
1056
<p>
 
1057
If the <b>Cancel</b> button is clicked, or if the dialog is is dismissed by
 
1058
some other means, e.g. by pressing the  [Escape] key, the function returns
 
1059
<tt><b>nil</b></tt>.
 
1060
</p><br><br>
 
1061
 
 
1062
 
 
1063
<a name="confirm"></a><hr><h3><tt>geany.confirm ( title, question, default )</tt></h3><p>
 
1064
  Displays a simple yes-or-no style dialog box to ask the specified
 
1065
  <tt>question</tt>.<br>
 
1066
  The <tt>title</tt> argument is displayed as a bold-faced title for the dialog.
 
1067
  </p><p>
 
1068
  Returns <tt><b>true</b></tt> if the 'Yes' button is clicked,
 
1069
  or <tt><b>false</b></tt>  if the 'No' button is
 
1070
  clicked.</p><p>
 
1071
  If the dialog is dismissed by some other means, e.g. by pressing the
 
1072
  [Escape] key, <br>the function will return the boolean value specified by the
 
1073
   <tt>default</tt> argument. </p>
 
1074
  <p>All three arguments are required, but you can pass <tt><b>nil</b></tt>
 
1075
  as the first argument to suppress the title.
 
1076
</p><br><br>
 
1077
 
 
1078
 
 
1079
<a name="input"></a><hr><h3><tt>geany.input ( [prompt] [,default] )</tt></h3><p>
 
1080
Displays an input dialog to prompt the user for some text. </p><p>
 
1081
The <tt>prompt</tt> argument string will display a message above the entry box
 
1082
to explain what input is requested.</p><p>
 
1083
The <tt>default</tt> argument string, if present, will add some pre-selected
 
1084
text into the entry area.</p><p>
 
1085
If the <b>OK</b> button is clicked, or if the [Return] key is pressed while the
 
1086
entry field is active, the function will return the contents of the entry field
 
1087
 as a string.</p><p>
 
1088
If the <b>Cancel</b> button is clicked, or if the dialog is is dismissed by
 
1089
some other means, e.g. by pressing the
 
1090
  [Escape] key, the function returns <tt><b>nil</b></tt>.
 
1091
</p><br><br>
 
1092
 
 
1093
 
 
1094
<a name="message"></a><hr><h3><tt>geany.message ( [title,] message )</tt></h3><p>
 
1095
When called with one argument, displays a simple dialog box containing
 
1096
the specified <tt>message</tt> string. </p>
 
1097
<p>When called with two arguments, the <tt>title</tt> argument is displayed as
 
1098
a bold-faced title,
 
1099
and the <tt>message</tt> argument will be the message text.
 
1100
</p><br><br>
 
1101
<hr>
 
1102
 
 
1103
<a name="pickfile"></a><hr><h3><tt>geany.pickfile ( [mode [,path [,filter]]] )</tt></h3>
 
1104
<p>
 
1105
Displays a dialog that allows the user to select a filename.</p><p>
 
1106
All three arguments are optional, but you can pass <tt>nil</tt> as a placeholder to
 
1107
use the default value for any of the arguments.</p><p>
 
1108
The <tt>mode</tt> argument specifies the type of dialog, and must be one
 
1109
of two strings, either <tt>"open"</tt> or <tt>"save"</tt>.<br>
 
1110
( passing <tt>nil</tt> is the same as <tt>"open"</tt> )<br>
 
1111
In <tt>"save"</tt> mode the function will issue an overwrite confirmation prompt if the targeted file already exists.
 
1112
</p><p>
 
1113
The <tt>path</tt> string argument sets the initial directory for the dialog, or <tt>nil</tt>
 
1114
to use the current directory.<br>
 
1115
If the last (rightmost) element of the path is an existing directory, the path will be used as-is,
 
1116
otherwise the last element is assumed to be a filename (whether it actually exists on disk or not)
 
1117
and will be parsed off and used as the suggested filename for the dialog.
 
1118
</p><p>
 
1119
The <tt>filter</tt> argument controls which files are displayed,
 
1120
or it can be <tt>nil</tt> to display all files.<br>
 
1121
It is a string consisting of pairs of substrings, where each substring
 
1122
is separated by the pipe "<tt>|</tt>" symbol.<br>
 
1123
The first element in each pair of substrings is the human-readable description of the filetype,<br> 
 
1124
and the second element of the 
 
1125
pair is a set of semicolon-delimited shell wildcards to filter on.<br>
 
1126
For instance, a filter for web files might look like:<br>
 
1127
<tt><b> &nbsp; "HTML files|*.html;*.htm|PHP files|*.php;*.php4|Style sheets|*.css"</b></tt>
 
1128
<br>
 
1129
( Those familiar with 
 
1130
<a href="http://en.wikipedia.org/wiki/Borland_Delphi">Borland Delphi</a>
 
1131
 might recognize this syntax from the
 
1132
 <a href="http://www.delphibasics.co.uk/RTL.asp?Name=TOpenDialog">TOpenDialog.Filter</a> property. )
 
1133
</p>
 
1134
<p><br>
 
1135
Note that this function does not actually open or save anything, it merely returns the
 
1136
full path and filename of the selected file, or <tt>nil</tt> if the user cancels the dialog.</p>
 
1137
<br><br>
 
1138
<hr>
 
1139
<hr>
 
1140
<h3>Module level variables</h3>
 
1141
<hr>
 
1142
<a name="wordchars"></a><hr><h3><tt>geany.wordchars</tt></h3><p>
 
1143
This variable determines which characters are considered to be part of a word.
 
1144
</p><p>
 
1145
It is used by the <tt><b>geany.word()</b></tt> function and may also be reset by that
 
1146
function if its current value cannot be interpreted as a string.</p><p>
 
1147
The default value is:<br><tt>
 
1148
&nbsp; &nbsp; <big> <big>
 
1149
"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"</big> </big></tt>
 
1150
<p>
 
1151
If you need to modify this string, you may want to save a copy of the original
 
1152
so you can restore it later.
 
1153
</p><br><br>
 
1154
 
 
1155
<a name="rectsel"></a><hr><h3><tt>geany.rectsel</tt></h3><p>
 
1156
This variable controls and/or returns the "selection mode" of the current document.
 
1157
</p><p>
 
1158
It is used by the <tt><b>geany.select()</b></tt> function and is adjusted
 
1159
when the selection is queried, and examined when the selection is set. <br>
 
1160
It may also be reset if its current value cannot be interpreted as a boolean.</p>
 
1161
<p>
 
1162
A value of <tt><b>true</b></tt> represents a rectangular selection
 
1163
and <tt><b>false</b></tt> represents the normal linear selection mode.
 
1164
</p><br><br>
 
1165
 
 
1166
<a name="banner"></a><hr><h3><tt>geany.banner</tt></h3><p>
 
1167
This variable controls the window title for dialogs displayed by the current script.
 
1168
</p><p>
 
1169
It may be reset by the dialog functions if its value cannot be interpreted as a string.
 
1170
</p><br><br>
 
1171
 
 
1172
 
 
1173
<a name="caller"></a><hr><h3><tt>geany.caller</tt></h3><p>
 
1174
This variable stores the internal index of the document that triggered one of the <a href="./geanylua-intro.html#events">event scripts</a>.</p>
 
1175
<p>
 
1176
For example, to print the filename of a file that has just been saved, you could put<br>
 
1177
this line in your <b>~/.geany/plugins/lua/events/saved.lua</b> script file:</p><p>
 
1178
<tt>&nbsp; print(geany.documents(geany.caller))</tt>
 
1179
</p><p>
 
1180
 
 
1181
 
 
1182
 
 
1183
 
 
1184
This variable is only relevant for the opened, created, activated, and saved event scripts,
 
1185
for all other scripts it is set to zero.<br>
 
1186
 
 
1187
</p><br><br>
 
1188
 
 
1189
<a name="dirsep"></a><hr><h3><tt>geany.dirsep</tt></h3><p>
 
1190
This variable returns the default filesystem path separator.<br>
 
1191
( A forward slash <tt><b>/</b></tt> for Unix or
 
1192
  a backslash <tt><b>\</b></tt> for MS-Windows. )
 
1193
</p><br><br>
 
1194
 
 
1195
 
 
1196
<a name="project"></a><hr><h3><tt>geany.project</tt></h3><p>
 
1197
This variable provides a reference to the <a href="geanylua-keyfile.html">GKeyFile</a> object
 
1198
for the project that triggered a
 
1199
&nbsp;proj-*&nbsp; <a href="./geanylua-intro.html#events">event script</a>.</p>
 
1200
<p>
 
1201
The information stored in the object can be manipulated using the <tt>keyfile</tt> module.<br>
 
1202
For example, to print the description of the project that has just been opened, you could put<br>
 
1203
this line in your <b>~/.geany/plugins/lua/events/proj-opened.lua</b> script file:</p><p>
 
1204
<tt>&nbsp; print(keyfile.value(geany.project, "project", "description"))</tt>
 
1205
</p><p>
 
1206
This variable is only relevant for the project-based event scripts, for all other scripts it is set to <tt>nil</tt>.<br>
 
1207
 
 
1208
</p><br><br>
 
1209
 
 
1210
 
 
1211
<a name="script"></a><hr><h3><tt>geany.script</tt></h3><p>
 
1212
This variable stores the full path and filename of the active script.</p>
 
1213
<br><br>
 
1214
<hr>
 
1215
<br><br>
 
1216
<div align="right"><small>&copy; 2007-2008 <i>Jeff Pohlmeyer </i> &nbsp; </small></div>
 
1217
<br><br>
 
1218
<br><br><br><br>
 
1219
<br><br><br><br>
 
1220
<br><br><br><br>
 
1221
<br><br><br><br>
 
1222
 
 
1223
</body>
 
1224
</html>