~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to src/sciwrappers.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-08-07 03:23:12 UTC
  • mfrom: (1.4.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20100807032312-ot70ac9d50cn79we
Tags: upstream-0.19
ImportĀ upstreamĀ versionĀ 0.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *      along with this program; if not, write to the Free Software
19
19
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $Id: sciwrappers.c 4630 2010-01-31 21:54:47Z eht16 $
 
21
 * $Id: sciwrappers.c 4869 2010-05-03 14:46:32Z ntrel $
22
22
 */
23
23
 
24
24
/** @file sciwrappers.h
25
25
 * Wrapper functions for the Scintilla editor widget @c SCI_* messages.
26
26
 * You should also check the http://scintilla.org documentation, as it is more detailed.
 
27
 *
 
28
 * To get Scintilla notifications, use the @c editor-notify @link signals Geany Signal @endlink.
 
29
 *
27
30
 * @note These functions were originally from the cssed project
28
31
 * (http://cssed.sf.net, thanks).
29
 
 * @see ScintillaFuncs::send_message().
 
32
 * @see scintilla_send_message().
30
33
 */
31
34
 
32
35
#include <string.h>
40
43
 
41
44
 
42
45
/* line numbers visibility */
43
 
void sci_set_line_numbers(ScintillaObject * sci, gboolean set, gint extra_width)
 
46
void sci_set_line_numbers(ScintillaObject *sci, gboolean set, gint extra_width)
44
47
{
45
48
        if (set)
46
49
        {
48
51
                gint len = SSM(sci, SCI_GETLINECOUNT, 0, 0);
49
52
                gint width;
50
53
 
51
 
                g_snprintf(tmp_str, 15, "_%d%d", len, extra_width);
 
54
                g_snprintf(tmp_str, 15, "_%d", len);
52
55
                width = sci_text_width(sci, STYLE_LINENUMBER, tmp_str);
53
 
                SSM (sci, SCI_SETMARGINWIDTHN, 0, width);
54
 
                SSM (sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */
 
56
                if (extra_width)
 
57
                {
 
58
                        g_snprintf(tmp_str, 15, "%d", extra_width);
 
59
                        width += sci_text_width(sci, STYLE_LINENUMBER, tmp_str);
 
60
                }
 
61
                SSM(sci, SCI_SETMARGINWIDTHN, 0, width);
 
62
                SSM(sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */
55
63
        }
56
64
        else
57
65
        {
58
 
                SSM (sci, SCI_SETMARGINWIDTHN, 0, 0 );
 
66
                SSM(sci, SCI_SETMARGINWIDTHN, 0, 0);
59
67
        }
60
68
}
61
69
 
62
 
void sci_set_mark_long_lines(ScintillaObject * sci, gint type, gint column, const gchar *colour)
 
70
 
 
71
void sci_set_mark_long_lines(ScintillaObject *sci, gint type, gint column, const gchar *colour)
63
72
{
64
73
        if (column == 0)
65
74
                type = 2;
87
96
 
88
97
 
89
98
/* symbol margin visibility */
90
 
void sci_set_symbol_margin(ScintillaObject * sci, gboolean set )
 
99
void sci_set_symbol_margin(ScintillaObject *sci, gboolean set)
91
100
{
92
101
        if (set)
93
102
        {
96
105
        }
97
106
        else
98
107
        {
99
 
                SSM (sci, SCI_SETMARGINWIDTHN, 1, 0);
 
108
                SSM(sci, SCI_SETMARGINWIDTHN, 1, 0);
100
109
                SSM(sci, SCI_SETMARGINSENSITIVEN, 1, FALSE);
101
110
        }
102
111
}
103
112
 
 
113
 
104
114
/* folding margin visibility */
105
115
void sci_set_folding_margin_visible(ScintillaObject *sci, gboolean set)
106
116
{
116
126
        }
117
127
}
118
128
 
 
129
 
119
130
/* end of lines */
120
 
void sci_set_visible_eols(ScintillaObject* sci, gboolean set )
121
 
{
122
 
        SSM(sci,SCI_SETVIEWEOL,set,0);
123
 
}
124
 
 
125
 
void sci_set_visible_white_spaces(ScintillaObject* sci, gboolean set )
126
 
{
127
 
        if (set)
128
 
                SSM(sci,SCI_SETVIEWWS,SCWS_VISIBLEALWAYS,0);
129
 
        else
130
 
                SSM(sci,SCI_SETVIEWWS,SCWS_INVISIBLE,0);
131
 
}
132
 
 
133
 
void sci_set_lines_wrapped(ScintillaObject* sci, gboolean set )
134
 
{
135
 
        if (set)
136
 
                SSM(sci,SCI_SETWRAPMODE,SC_WRAP_WORD,0);
137
 
        else
138
 
                SSM(sci,SCI_SETWRAPMODE,SC_WRAP_NONE,0);
139
 
}
140
 
 
141
 
gint sci_get_eol_mode( ScintillaObject* sci)
142
 
{
143
 
        return SSM( sci, SCI_GETEOLMODE, 0, 0);
144
 
}
145
 
 
146
 
void sci_set_eol_mode( ScintillaObject* sci, gint eolmode)
147
 
{
148
 
        SSM( sci, SCI_SETEOLMODE, eolmode, 0);
149
 
}
150
 
 
151
 
void sci_convert_eols( ScintillaObject* sci, gint eolmode)
152
 
{
153
 
        SSM( sci, SCI_CONVERTEOLS, eolmode,0);
154
 
}
155
 
 
156
 
void sci_add_text(ScintillaObject* sci, const gchar* text)
 
131
void sci_set_visible_eols(ScintillaObject *sci, gboolean set)
 
132
{
 
133
        SSM(sci, SCI_SETVIEWEOL, set, 0);
 
134
}
 
135
 
 
136
 
 
137
void sci_set_visible_white_spaces(ScintillaObject *sci, gboolean set)
 
138
{
 
139
        if (set)
 
140
                SSM(sci, SCI_SETVIEWWS, SCWS_VISIBLEALWAYS, 0);
 
141
        else
 
142
                SSM(sci, SCI_SETVIEWWS, SCWS_INVISIBLE, 0);
 
143
}
 
144
 
 
145
 
 
146
void sci_set_lines_wrapped(ScintillaObject *sci, gboolean set)
 
147
{
 
148
        if (set)
 
149
                SSM(sci, SCI_SETWRAPMODE, SC_WRAP_WORD, 0);
 
150
        else
 
151
                SSM(sci, SCI_SETWRAPMODE, SC_WRAP_NONE, 0);
 
152
}
 
153
 
 
154
 
 
155
gint sci_get_eol_mode(ScintillaObject *sci)
 
156
{
 
157
        return SSM(sci, SCI_GETEOLMODE, 0, 0);
 
158
}
 
159
 
 
160
 
 
161
void sci_set_eol_mode(ScintillaObject *sci, gint eolmode)
 
162
{
 
163
        SSM(sci, SCI_SETEOLMODE, eolmode, 0);
 
164
}
 
165
 
 
166
 
 
167
void sci_convert_eols(ScintillaObject *sci, gint eolmode)
 
168
{
 
169
        SSM(sci, SCI_CONVERTEOLS, eolmode, 0);
 
170
}
 
171
 
 
172
 
 
173
void sci_add_text(ScintillaObject *sci, const gchar *text)
157
174
{
158
175
        if (text != NULL)
159
 
        { /* if null text is passed to scintilla will segfault */
160
 
                SSM( sci, SCI_ADDTEXT, strlen(text), (sptr_t) text);
 
176
        { /* if null text is passed scintilla will segfault */
 
177
                SSM(sci, SCI_ADDTEXT, strlen(text), (sptr_t) text);
161
178
        }
162
179
}
163
180
 
164
 
/** Set all text.
 
181
 
 
182
/** Sets all text.
165
183
 * @param sci Scintilla widget.
166
184
 * @param text Text. */
167
 
void sci_set_text(ScintillaObject* sci, const gchar* text)
 
185
void sci_set_text(ScintillaObject *sci, const gchar *text)
168
186
{
169
187
        if( text != NULL ){ /* if null text is passed to scintilla will segfault */
170
 
                SSM( sci, SCI_SETTEXT, 0, (sptr_t) text);
 
188
                SSM(sci, SCI_SETTEXT, 0, (sptr_t) text);
171
189
        }
172
190
}
173
191
 
174
192
 
175
 
gboolean sci_can_undo( ScintillaObject* sci )
176
 
{
177
 
        return SSM( sci, SCI_CANUNDO, 0, 0);
178
 
}
179
 
 
180
 
 
181
 
gboolean sci_can_redo( ScintillaObject* sci )
182
 
{
183
 
        return SSM( sci, SCI_CANREDO, 0, 0);
184
 
}
185
 
 
186
 
 
187
 
void sci_undo( ScintillaObject* sci )
188
 
{
189
 
        if( sci_can_undo(sci) )
190
 
                SSM( sci, SCI_UNDO, 0, 0);
191
 
}
192
 
 
193
 
 
194
 
void sci_redo( ScintillaObject* sci )
195
 
{
196
 
        if( sci_can_redo( sci ) )
197
 
                SSM( sci, SCI_REDO,0,0);
198
 
}
199
 
 
200
 
 
201
 
/** Begin grouping a set of edits together as one Undo action.
 
193
gboolean sci_can_undo(ScintillaObject *sci)
 
194
{
 
195
        return SSM(sci, SCI_CANUNDO, 0, 0);
 
196
}
 
197
 
 
198
 
 
199
gboolean sci_can_redo(ScintillaObject *sci)
 
200
{
 
201
        return SSM(sci, SCI_CANREDO, 0, 0);
 
202
}
 
203
 
 
204
 
 
205
void sci_undo(ScintillaObject *sci)
 
206
{
 
207
        if (sci_can_undo(sci))
 
208
                SSM(sci, SCI_UNDO, 0, 0);
 
209
}
 
210
 
 
211
 
 
212
void sci_redo(ScintillaObject *sci)
 
213
{
 
214
        if (sci_can_redo(sci))
 
215
                SSM(sci, SCI_REDO, 0, 0);
 
216
}
 
217
 
 
218
 
 
219
/** Begins grouping a set of edits together as one Undo action.
202
220
 * You must call sci_end_undo_action() after making your edits.
203
221
 * @param sci Scintilla @c GtkWidget. */
204
 
void sci_start_undo_action( ScintillaObject* sci )
 
222
void sci_start_undo_action(ScintillaObject *sci)
205
223
{
206
 
        SSM( sci,SCI_BEGINUNDOACTION,0,0 );
 
224
        SSM(sci, SCI_BEGINUNDOACTION, 0, 0);
207
225
}
208
226
 
209
227
 
210
 
/** End grouping a set of edits together as one Undo action.
 
228
/** Ends grouping a set of edits together as one Undo action.
211
229
 * @param sci Scintilla @c GtkWidget.
212
230
 * @see sci_start_undo_action(). */
213
 
void sci_end_undo_action( ScintillaObject* sci )
214
 
{
215
 
        SSM( sci, SCI_ENDUNDOACTION,0,0);
216
 
}
217
 
 
218
 
 
219
 
void sci_set_undo_collection( ScintillaObject* sci, gboolean set )
220
 
{
221
 
        SSM( sci, SCI_SETUNDOCOLLECTION,set,0);
222
 
}
223
 
 
224
 
 
225
 
void sci_empty_undo_buffer( ScintillaObject* sci )
226
 
{
227
 
        SSM( sci, SCI_EMPTYUNDOBUFFER,0,0);
 
231
void sci_end_undo_action(ScintillaObject *sci)
 
232
{
 
233
        SSM(sci, SCI_ENDUNDOACTION, 0, 0);
 
234
}
 
235
 
 
236
 
 
237
void sci_set_undo_collection(ScintillaObject *sci, gboolean set)
 
238
{
 
239
        SSM(sci, SCI_SETUNDOCOLLECTION, set, 0);
 
240
}
 
241
 
 
242
 
 
243
void sci_empty_undo_buffer(ScintillaObject *sci)
 
244
{
 
245
        SSM(sci, SCI_EMPTYUNDOBUFFER, 0, 0);
228
246
}
229
247
 
230
248
 
234
252
}
235
253
 
236
254
 
237
 
void sci_zoom_in( ScintillaObject* sci )
238
 
{
239
 
        SSM( sci, SCI_ZOOMIN,0,0);
240
 
}
241
 
 
242
 
 
243
 
void sci_zoom_out( ScintillaObject* sci )
244
 
{
245
 
        SSM( sci, SCI_ZOOMOUT,0,0);
246
 
}
247
 
 
248
 
 
249
 
void sci_zoom_off( ScintillaObject* sci )
250
 
{
251
 
        SSM( sci, SCI_SETZOOM,0,0);
252
 
}
253
 
 
254
 
 
255
 
gint sci_get_zoom( ScintillaObject* sci )
256
 
{
257
 
        return SSM( sci, SCI_GETZOOM,0,0);
258
 
}
259
 
 
260
 
 
261
 
void sci_set_marker_at_line( ScintillaObject* sci, gint line_number, gboolean set, gint marker )
262
 
{
263
 
        if ( set )
264
 
        {
265
 
                SSM( sci, SCI_MARKERADD, line_number, marker);
266
 
        }
267
 
        else
268
 
        {
269
 
                SSM( sci, SCI_MARKERDELETE, line_number, marker);
270
 
        }
271
 
}
272
 
 
273
 
 
274
 
gboolean sci_is_marker_set_at_line(ScintillaObject* sci, gint line, gint marker)
 
255
void sci_zoom_in(ScintillaObject *sci)
 
256
{
 
257
        SSM(sci, SCI_ZOOMIN, 0, 0);
 
258
}
 
259
 
 
260
 
 
261
void sci_zoom_out(ScintillaObject *sci)
 
262
{
 
263
        SSM(sci, SCI_ZOOMOUT, 0, 0);
 
264
}
 
265
 
 
266
 
 
267
void sci_zoom_off(ScintillaObject *sci)
 
268
{
 
269
        SSM(sci, SCI_SETZOOM, 0, 0);
 
270
}
 
271
 
 
272
 
 
273
gint sci_get_zoom(ScintillaObject *sci)
 
274
{
 
275
        return SSM(sci, SCI_GETZOOM, 0, 0);
 
276
}
 
277
 
 
278
 
 
279
/** Sets a line marker.
 
280
 * @param sci Scintilla widget.
 
281
 * @param line_number Line number.
 
282
 * @param marker Marker number. */
 
283
void sci_set_marker_at_line(ScintillaObject *sci, gint line_number, gint marker)
 
284
{
 
285
        SSM(sci, SCI_MARKERADD, line_number, marker);
 
286
}
 
287
 
 
288
 
 
289
/** Deletes a line marker.
 
290
 * @param sci Scintilla widget.
 
291
 * @param line_number Line number.
 
292
 * @param marker Marker number. */
 
293
void sci_delete_marker_at_line(ScintillaObject *sci, gint line_number, gint marker)
 
294
{
 
295
        SSM(sci, SCI_MARKERDELETE, line_number, marker);
 
296
}
 
297
 
 
298
 
 
299
/** Checks if a line has a marker set.
 
300
 * @param sci Scintilla widget.
 
301
 * @param line Line number.
 
302
 * @param marker Marker number.
 
303
 * @return Whether it's set. */
 
304
gboolean sci_is_marker_set_at_line(ScintillaObject *sci, gint line, gint marker)
275
305
{
276
306
        gint state;
277
307
 
278
 
        state = SSM( sci, SCI_MARKERGET, line, 0 );
 
308
        state = SSM(sci, SCI_MARKERGET, line, 0);
279
309
        return (state & (1 << marker));
280
310
}
281
311
 
282
312
 
283
 
void sci_toggle_marker_at_line(ScintillaObject* sci, gint line, gint marker)
 
313
void sci_toggle_marker_at_line(ScintillaObject *sci, gint line, gint marker)
284
314
{
285
315
        gboolean set = sci_is_marker_set_at_line(sci, line, marker);
286
316
 
287
 
        sci_set_marker_at_line(sci, line, set, marker);
 
317
        if (!set)
 
318
                sci_set_marker_at_line(sci, line, marker);
 
319
        else
 
320
                sci_delete_marker_at_line(sci, line, marker);
288
321
}
289
322
 
290
323
 
291
324
/* Returns the line number of the next marker that matches marker_mask, or -1.
292
325
 * marker_mask is a bitor of 1 << marker_index. (See MarkerHandleSet::MarkValue()).
293
326
 * Note: If there is a marker on the line, it returns the same line. */
294
 
gint sci_marker_next(ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap)
 
327
gint sci_marker_next(ScintillaObject *sci, gint line, gint marker_mask, gboolean wrap)
295
328
{
296
329
        gint marker_line;
297
330
 
305
338
/* Returns the line number of the previous marker that matches marker_mask, or -1.
306
339
 * marker_mask is a bitor of 1 << marker_index. (See MarkerHandleSet::MarkValue()).
307
340
 * Note: If there is a marker on the line, it returns the same line. */
308
 
gint sci_marker_previous(ScintillaObject* sci, gint line, gint marker_mask, gboolean wrap)
 
341
gint sci_marker_previous(ScintillaObject *sci, gint line, gint marker_mask, gboolean wrap)
309
342
{
310
343
        gint marker_line;
311
344
 
321
354
}
322
355
 
323
356
 
324
 
/** Get line number from position.
 
357
/** Gets the line number from @a position.
325
358
 * @param sci Scintilla widget.
326
359
 * @param position Position. */
327
 
gint sci_get_line_from_position(ScintillaObject* sci, gint position )
 
360
gint sci_get_line_from_position(ScintillaObject *sci, gint position)
328
361
{
329
362
        return SSM(sci, SCI_LINEFROMPOSITION, position, 0);
330
363
}
331
364
 
332
365
 
333
 
/** Get column number relative to the start of the line that @a position is on.
 
366
/** Gets the column number relative to the start of the line that @a position is on.
334
367
 * @param sci Scintilla widget.
335
368
 * @param position Position. */
336
 
gint sci_get_col_from_position(ScintillaObject* sci, gint position )
 
369
gint sci_get_col_from_position(ScintillaObject *sci, gint position)
337
370
{
338
371
        return SSM(sci, SCI_GETCOLUMN, position, 0);
339
372
}
340
373
 
341
374
 
342
 
/** Get position for the start of @a line.
 
375
/** Gets the position for the start of @a line.
343
376
 * @param sci Scintilla widget.
344
377
 * @param line Line.
345
378
 * @return Position. */
346
 
gint sci_get_position_from_line(ScintillaObject* sci, gint line )
 
379
gint sci_get_position_from_line(ScintillaObject *sci, gint line)
347
380
{
348
381
        return SSM(sci, SCI_POSITIONFROMLINE, line, 0);
349
382
}
350
383
 
351
384
 
352
 
/** Get cursor position.
 
385
/** Gets the cursor position.
353
386
 * @param sci Scintilla widget.
354
387
 * @return Position. */
355
 
gint sci_get_current_position(ScintillaObject* sci )
 
388
gint sci_get_current_position(ScintillaObject *sci)
356
389
{
357
390
        return SSM(sci, SCI_GETCURRENTPOS, 0, 0);
358
391
}
359
392
 
360
393
 
361
 
/** Set the cursor position.
 
394
/** Sets the cursor position.
362
395
 * @param sci Scintilla widget.
363
396
 * @param position Position.
364
397
 * @param scroll_to_caret Whether to scroll the cursor in view. */
365
 
void sci_set_current_position(ScintillaObject* sci, gint position, gboolean scroll_to_caret)
 
398
void sci_set_current_position(ScintillaObject *sci, gint position, gboolean scroll_to_caret)
366
399
{
367
400
        if (scroll_to_caret)
368
401
                SSM(sci, SCI_GOTOPOS, position, 0);
377
410
 
378
411
/* Set the cursor line without scrolling the view.
379
412
 * Use sci_goto_line() to also scroll. */
380
 
void sci_set_current_line(ScintillaObject* sci, gint line)
 
413
void sci_set_current_line(ScintillaObject *sci, gint line)
381
414
{
382
415
        gint pos = sci_get_position_from_line(sci, line);
383
416
        sci_set_current_position(sci, pos, FALSE);
384
417
}
385
418
 
386
419
 
387
 
/** Get total number of lines.
 
420
/** Gets the total number of lines.
388
421
 * @param sci Scintilla widget. */
389
 
gint sci_get_line_count( ScintillaObject* sci )
 
422
gint sci_get_line_count(ScintillaObject *sci)
390
423
{
391
424
        return SSM(sci, SCI_GETLINECOUNT, 0, 0);
392
425
}
393
426
 
394
427
 
395
 
/** Set selection start position.
 
428
/** Sets the selection start position.
396
429
 * @param sci Scintilla widget.
397
430
 * @param position Position. */
398
 
void sci_set_selection_start(ScintillaObject* sci, gint position)
 
431
void sci_set_selection_start(ScintillaObject *sci, gint position)
399
432
{
400
433
        SSM(sci, SCI_SETSELECTIONSTART, position, 0);
401
434
}
402
435
 
403
436
 
404
 
/** Set selection end position.
 
437
/** Sets the selection end position.
405
438
 * @param sci Scintilla widget.
406
439
 * @param position Position. */
407
 
void sci_set_selection_end(ScintillaObject* sci, gint position)
 
440
void sci_set_selection_end(ScintillaObject *sci, gint position)
408
441
{
409
442
        SSM(sci, SCI_SETSELECTIONEND, position, 0);
410
443
}
416
449
}
417
450
 
418
451
 
419
 
gint sci_get_line_end_position(ScintillaObject* sci, gint line)
 
452
gint sci_get_line_end_position(ScintillaObject *sci, gint line)
420
453
{
421
454
        return SSM(sci, SCI_GETLINEENDPOSITION, line, 0);
422
455
}
423
456
 
424
457
 
425
 
void sci_cut(ScintillaObject* sci)
 
458
void sci_cut(ScintillaObject *sci)
426
459
{
427
460
        SSM(sci, SCI_CUT, 0, 0);
428
461
}
429
462
 
430
463
 
431
 
void sci_copy(ScintillaObject* sci)
 
464
void sci_copy(ScintillaObject *sci)
432
465
{
433
466
        SSM(sci, SCI_COPY, 0, 0);
434
467
}
435
468
 
436
469
 
437
 
void sci_paste(ScintillaObject* sci)
 
470
void sci_paste(ScintillaObject *sci)
438
471
{
439
472
        SSM(sci, SCI_PASTE, 0, 0);
440
473
}
441
474
 
442
475
 
443
 
void sci_clear(ScintillaObject* sci)
 
476
void sci_clear(ScintillaObject *sci)
444
477
{
445
478
        SSM(sci, SCI_CLEAR, 0, 0);
446
479
}
447
480
 
448
481
 
449
 
/** Get position of selection start.
450
 
 * @param sci Scintilla widget.
451
 
 * @return Position. */
452
 
gint sci_get_selection_start(ScintillaObject* sci)
453
 
{
454
 
        return SSM(sci, SCI_GETSELECTIONSTART,0,0);
455
 
}
456
 
 
457
 
 
458
 
/** Get position of selection end.
459
 
 * @param sci Scintilla widget.
460
 
 * @return Position. */
461
 
gint sci_get_selection_end(ScintillaObject* sci)
462
 
{
463
 
        return SSM(sci, SCI_GETSELECTIONEND,0,0);
464
 
}
465
 
 
466
 
 
467
 
/** Replace selection.
 
482
/** Gets the selection start position.
 
483
 * @param sci Scintilla widget.
 
484
 * @return Position. */
 
485
gint sci_get_selection_start(ScintillaObject *sci)
 
486
{
 
487
        return SSM(sci, SCI_GETSELECTIONSTART, 0, 0);
 
488
}
 
489
 
 
490
 
 
491
/** Gets the selection end position.
 
492
 * @param sci Scintilla widget.
 
493
 * @return Position. */
 
494
gint sci_get_selection_end(ScintillaObject *sci)
 
495
{
 
496
        return SSM(sci, SCI_GETSELECTIONEND, 0, 0);
 
497
}
 
498
 
 
499
 
 
500
/** Replaces selection.
468
501
 * @param sci Scintilla widget.
469
502
 * @param text Text. */
470
 
void sci_replace_sel(ScintillaObject* sci, const gchar* text)
 
503
void sci_replace_sel(ScintillaObject *sci, const gchar *text)
471
504
{
472
 
        SSM(sci, SCI_REPLACESEL,0, (sptr_t) text);
 
505
        SSM(sci, SCI_REPLACESEL, 0, (sptr_t) text);
473
506
}
474
507
 
475
508
 
476
 
/** Get length of all text.
 
509
/** Gets the length of all text.
477
510
 * @param sci Scintilla widget.
478
511
 * @return Length. */
479
 
gint sci_get_length(ScintillaObject* sci)
480
 
{
481
 
        return SSM(sci,SCI_GETLENGTH,0,0);
482
 
}
483
 
 
484
 
 
485
 
gint sci_get_lexer(ScintillaObject* sci)
486
 
{
487
 
        return SSM(sci,SCI_GETLEXER,0,0);
488
 
}
489
 
 
490
 
 
491
 
/** Get line length.
 
512
gint sci_get_length(ScintillaObject *sci)
 
513
{
 
514
        return SSM(sci, SCI_GETLENGTH, 0, 0);
 
515
}
 
516
 
 
517
 
 
518
gint sci_get_lexer(ScintillaObject *sci)
 
519
{
 
520
        return SSM(sci, SCI_GETLEXER, 0, 0);
 
521
}
 
522
 
 
523
 
 
524
/** Gets line length.
492
525
 * @param sci Scintilla widget.
493
526
 * @param line Line number.
494
527
 * @return Length. */
495
 
gint sci_get_line_length(ScintillaObject* sci,gint line)
496
 
{
497
 
        return SSM(sci,SCI_LINELENGTH, line,0);
498
 
}
499
 
 
500
 
 
501
 
/** Get line contents.
 
528
gint sci_get_line_length(ScintillaObject *sci, gint line)
 
529
{
 
530
        return SSM(sci, SCI_LINELENGTH, line, 0);
 
531
}
 
532
 
 
533
 
 
534
/* safe way to read Scintilla string into new memory.
 
535
 * works with any string buffer messages that follow the Windows message convention. */
 
536
gchar *sci_get_string(ScintillaObject *sci, gint msg, gulong wParam)
 
537
{
 
538
        gint size = SSM(sci, msg, wParam, 0) + 1;
 
539
        gchar *str = g_malloc(size);
 
540
 
 
541
        SSM(sci, msg, wParam, (sptr_t)str);
 
542
        str[size - 1] = '\0';   /* ensure termination, needed for SCI_GETLINE */
 
543
        return str;
 
544
}
 
545
 
 
546
 
 
547
/** Gets line contents.
502
548
 * @param sci Scintilla widget.
503
549
 * @param line_num Line number.
504
550
 * @return A @c NULL-terminated copy of the line text. */
505
 
gchar *sci_get_line(ScintillaObject* sci, gint line_num)
 
551
gchar *sci_get_line(ScintillaObject *sci, gint line_num)
506
552
{
507
 
        gint len = sci_get_line_length(sci, line_num);
508
 
        gchar *linebuf = g_malloc(len + 1);
509
 
 
510
 
        SSM(sci, SCI_GETLINE, line_num, (sptr_t) linebuf);
511
 
        linebuf[len] = '\0';
512
 
        return linebuf;
 
553
        return sci_get_string(sci, SCI_GETLINE, line_num);
513
554
}
514
555
 
515
556
 
516
 
/** Get all text.
 
557
/** Gets all text.
517
558
 * @deprecated sci_get_text is deprecated and should not be used in newly-written code.
518
559
 * Use sci_get_contents() instead.
519
560
 *
520
561
 * @param sci Scintilla widget.
521
562
 * @param len Length of @a text buffer, usually sci_get_length() + 1.
522
563
 * @param text Text buffer; must be allocated @a len + 1 bytes for null-termination. */
523
 
void sci_get_text(ScintillaObject* sci, gint len, gchar* text)
 
564
void sci_get_text(ScintillaObject *sci, gint len, gchar *text)
524
565
{
525
 
        SSM( sci, SCI_GETTEXT, len, (sptr_t) text );
 
566
        SSM(sci, SCI_GETTEXT, len, (sptr_t) text);
526
567
}
527
568
 
528
 
/** Get all text inside a given text length.
 
569
 
 
570
/** Gets all text inside a given text length.
529
571
 * @param sci Scintilla widget.
530
572
 * @param len Length of the text to retrieve from the start of the document,
531
573
 *            usually sci_get_length() + 1.
540
582
        return text;
541
583
}
542
584
 
543
 
/** Get selected text.
 
585
 
 
586
/** Gets selected text.
544
587
 * @deprecated sci_get_selected_text is deprecated and should not be used in newly-written code.
545
588
 * Use sci_get_selection_contents() instead.
546
589
 *
547
590
 * @param sci Scintilla widget.
548
591
 * @param text Text buffer; must be allocated sci_get_selected_text_length() + 1 bytes
549
592
 * for null-termination. */
550
 
void sci_get_selected_text(ScintillaObject* sci, gchar* text)
 
593
void sci_get_selected_text(ScintillaObject *sci, gchar *text)
551
594
{
552
 
        SSM( sci, SCI_GETSELTEXT, 0, (sptr_t) text);
 
595
        SSM(sci, SCI_GETSELTEXT, 0, (sptr_t) text);
553
596
}
554
597
 
555
 
/** Get selected text.
 
598
 
 
599
/** Gets selected text.
556
600
 * @param sci Scintilla widget.
557
601
 *
558
602
 * @return The selected text. Should be freed when no longer needed.
561
605
 */
562
606
gchar *sci_get_selection_contents(ScintillaObject *sci)
563
607
{
564
 
        gint len = sci_get_selected_text_length(sci);
565
 
        gchar *selection = g_malloc(len + 1);
566
 
 
567
 
        SSM(sci, SCI_GETSELTEXT, 0, (sptr_t) selection);
568
 
 
569
 
        return selection;
 
608
        return sci_get_string(sci, SCI_GETSELTEXT, 0);
570
609
}
571
610
 
572
 
/** Get selected text length.
 
611
 
 
612
/** Gets selected text length.
573
613
 * @param sci Scintilla widget.
574
614
 * @return Length. */
575
 
gint sci_get_selected_text_length(ScintillaObject* sci)
 
615
gint sci_get_selected_text_length(ScintillaObject *sci)
576
616
{
577
 
        return SSM( sci, SCI_GETSELTEXT, 0, 0);
 
617
        return SSM(sci, SCI_GETSELTEXT, 0, 0);
578
618
}
579
619
 
580
 
gint sci_get_position_from_xy(ScintillaObject* sci, gint x, gint y, gboolean nearby)
 
620
 
 
621
gint sci_get_position_from_xy(ScintillaObject *sci, gint x, gint y, gboolean nearby)
581
622
{
582
623
        /* for nearby return -1 if there is no character near to the x,y point. */
583
624
        return SSM(sci, (nearby) ? SCI_POSITIONFROMPOINTCLOSE : SCI_POSITIONFROMPOINT, x, y);
584
625
}
585
626
 
586
627
 
587
 
/** Check if a line is visible (folding may have hidden it).
 
628
/** Checks if a line is visible (folding may have hidden it).
588
629
 * @param sci Scintilla widget.
589
630
 * @param line Line number.
590
631
 * @return Whether @a line will be drawn on the screen. */
591
 
gboolean sci_get_line_is_visible(ScintillaObject* sci, gint line)
 
632
gboolean sci_get_line_is_visible(ScintillaObject *sci, gint line)
592
633
{
593
 
        return SSM(sci,SCI_GETLINEVISIBLE, line,0);
 
634
        return SSM(sci, SCI_GETLINEVISIBLE, line, 0);
594
635
}
595
636
 
596
637
 
597
 
/** Make the @a line visible (folding may have hidden it).
 
638
/** Makes @a line visible (folding may have hidden it).
598
639
 * @param sci Scintilla widget.
599
640
 * @param line Line number. */
600
 
void sci_ensure_line_is_visible(ScintillaObject* sci, gint line)
 
641
void sci_ensure_line_is_visible(ScintillaObject *sci, gint line)
601
642
{
602
 
        SSM(sci,SCI_ENSUREVISIBLE,line,0);
 
643
        SSM(sci, SCI_ENSUREVISIBLE, line, 0);
603
644
}
604
645
 
605
646
 
606
 
gint sci_get_fold_level(ScintillaObject* sci, gint line)
 
647
gint sci_get_fold_level(ScintillaObject *sci, gint line)
607
648
{
608
 
        return SSM(sci,SCI_GETFOLDLEVEL, line,0);
 
649
        return SSM(sci, SCI_GETFOLDLEVEL, line, 0);
609
650
}
610
651
 
611
652
 
612
653
/* Get the line number of the fold point before start_line, or -1 if there isn't one */
613
 
gint sci_get_fold_parent(ScintillaObject* sci, gint start_line)
614
 
{
615
 
        return SSM( sci, SCI_GETFOLDPARENT, start_line, 0);
616
 
}
617
 
 
618
 
 
619
 
void sci_toggle_fold(ScintillaObject* sci, gint line)
620
 
{
621
 
        SSM( sci, SCI_TOGGLEFOLD, line, 1);
622
 
}
623
 
 
624
 
 
625
 
gboolean sci_get_fold_expanded(ScintillaObject* sci, gint line)
626
 
{
627
 
        return SSM( sci, SCI_GETFOLDEXPANDED, line, 0);
628
 
}
629
 
 
630
 
 
631
 
void sci_colourise( ScintillaObject* sci, gint start, gint end)
632
 
{
633
 
        SSM( sci, SCI_COLOURISE, start, end);
634
 
}
635
 
 
636
 
 
637
 
void sci_clear_all(ScintillaObject * sci)
638
 
{
639
 
        SSM( sci, SCI_CLEARALL, 0, 0);
640
 
}
641
 
 
642
 
 
643
 
gint sci_get_end_styled(ScintillaObject * sci)
644
 
{
645
 
        return SSM(sci,SCI_GETENDSTYLED, 0,0);
646
 
}
647
 
 
648
 
 
649
 
void sci_set_tab_width(ScintillaObject * sci, gint width)
 
654
gint sci_get_fold_parent(ScintillaObject *sci, gint start_line)
 
655
{
 
656
        return SSM(sci, SCI_GETFOLDPARENT, start_line, 0);
 
657
}
 
658
 
 
659
 
 
660
void sci_toggle_fold(ScintillaObject *sci, gint line)
 
661
{
 
662
        SSM(sci, SCI_TOGGLEFOLD, line, 1);
 
663
}
 
664
 
 
665
 
 
666
gboolean sci_get_fold_expanded(ScintillaObject *sci, gint line)
 
667
{
 
668
        return SSM(sci, SCI_GETFOLDEXPANDED, line, 0);
 
669
}
 
670
 
 
671
 
 
672
void sci_colourise(ScintillaObject *sci, gint start, gint end)
 
673
{
 
674
        SSM(sci, SCI_COLOURISE, start, end);
 
675
}
 
676
 
 
677
 
 
678
void sci_clear_all(ScintillaObject *sci)
 
679
{
 
680
        SSM(sci, SCI_CLEARALL, 0, 0);
 
681
}
 
682
 
 
683
 
 
684
gint sci_get_end_styled(ScintillaObject *sci)
 
685
{
 
686
        return SSM(sci, SCI_GETENDSTYLED, 0, 0);
 
687
}
 
688
 
 
689
 
 
690
void sci_set_tab_width(ScintillaObject *sci, gint width)
650
691
{
651
692
        SSM(sci, SCI_SETTABWIDTH, width, 0);
652
693
}
653
694
 
654
695
 
655
 
/** Get display tab width (this is not indent width, see GeanyIndentPrefs).
 
696
/** Gets display tab width (this is not indent width, see GeanyIndentPrefs).
656
697
 * @param sci Scintilla widget.
657
698
 * @return Width.
658
699
 *
659
700
 * @since 0.15
660
701
 **/
661
 
gint sci_get_tab_width(ScintillaObject * sci)
 
702
gint sci_get_tab_width(ScintillaObject *sci)
662
703
{
663
704
        return SSM(sci, SCI_GETTABWIDTH, 0, 0);
664
705
}
665
706
 
666
707
 
667
 
/** Get character.
 
708
/** Gets a character.
668
709
 * @param sci Scintilla widget.
669
710
 * @param pos Position.
670
711
 * @return Char. */
679
720
        SSM(sci, SCI_SETSAVEPOINT, 0, 0);
680
721
}
681
722
 
 
723
 
682
724
void sci_set_indentation_guides(ScintillaObject *sci, gint mode)
683
725
{
684
726
        SSM(sci, SCI_SETINDENTATIONGUIDES, mode, 0);
691
733
}
692
734
 
693
735
 
694
 
/** Check if there's a selection.
 
736
/** Checks if there's a selection.
695
737
 * @param sci Scintilla widget.
696
738
 * @return Whether a selection is present.
697
739
 *
699
741
 **/
700
742
gboolean sci_has_selection(ScintillaObject *sci)
701
743
{
702
 
        if (SSM(sci, SCI_GETSELECTIONEND,0,0) - SSM(sci, SCI_GETSELECTIONSTART,0,0))
 
744
        if (SSM(sci, SCI_GETSELECTIONEND, 0, 0) - SSM(sci, SCI_GETSELECTIONSTART, 0, 0))
703
745
                return TRUE;
704
746
        else
705
747
                return FALSE;
708
750
 
709
751
void sci_goto_pos(ScintillaObject *sci, gint pos, gboolean unfold)
710
752
{
711
 
        if (unfold) SSM(sci,SCI_ENSUREVISIBLE,SSM(sci, SCI_LINEFROMPOSITION, pos, 0),0);
 
753
        if (unfold) SSM(sci, SCI_ENSUREVISIBLE, SSM(sci, SCI_LINEFROMPOSITION, pos, 0), 0);
712
754
        SSM(sci, SCI_GOTOPOS, pos, 0);
713
755
}
714
756
 
729
771
}
730
772
 
731
773
 
732
 
/** Scroll the cursor in view.
 
774
/** Scrolls the cursor in view.
733
775
 * @param sci Scintilla widget. */
734
776
void sci_scroll_caret(ScintillaObject *sci)
735
777
{
751
793
 
752
794
gint sci_search_next(ScintillaObject *sci, gint flags, const gchar *text)
753
795
{
754
 
        return SSM(sci, SCI_SEARCHNEXT, flags, (sptr_t) text );
 
796
        return SSM(sci, SCI_SEARCHNEXT, flags, (sptr_t) text);
755
797
}
756
798
 
757
799
 
758
800
gint sci_search_prev(ScintillaObject *sci, gint flags, const gchar *text)
759
801
{
760
 
        return SSM(sci, SCI_SEARCHPREV, flags, (sptr_t) text );
 
802
        return SSM(sci, SCI_SEARCHPREV, flags, (sptr_t) text);
761
803
}
762
804
 
763
805
 
 
806
/** Finds text in the document.
 
807
 * The @a ttf argument should be a pointer to a Sci_TextToFind structure which contains
 
808
 * the text to find and the range in which the text should be searched.
 
809
 *
 
810
 * Please refer to the Scintilla documentation for a more detailed description.
 
811
 *
 
812
 * @param sci Scintilla widget.
 
813
 * @param flags Bitmask of Scintilla search flags (@c SCFIND_*, see Scintilla documentation).
 
814
 * @param ttf Pointer to a TextToFind structure which contains the text to find and the range.
 
815
 * @return The position of the start of the found text if it succeeds, otherwise @c -1.
 
816
 *         The @c chrgText.cpMin and @c chrgText.cpMax members of @c TextToFind are filled in
 
817
 *         with the start and end positions of the found text.
 
818
 */
764
819
gint sci_find_text(ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf)
765
820
{
766
 
        return SSM(sci, SCI_FINDTEXT, flags, (long) ttf );
 
821
        return SSM(sci, SCI_FINDTEXT, flags, (long) ttf);
767
822
}
768
823
 
769
824
 
770
 
void sci_set_font(ScintillaObject *sci, gint style, const gchar* font, gint size)
 
825
void sci_set_font(ScintillaObject *sci, gint style, const gchar *font, gint size)
771
826
{
772
827
        SSM(sci, SCI_STYLESETFONT, style, (sptr_t) font);
773
828
        SSM(sci, SCI_STYLESETSIZE, style, size);
774
829
}
775
830
 
776
831
 
 
832
/** Jumps to the specified line in the document.
 
833
 * If @a unfold is set and @a line is hidden by a fold, it is unfolded
 
834
 * first to ensure it is visible.
 
835
 * @param sci Scintilla widget.
 
836
 * @param line Line.
 
837
 * @param unfold Whether to unfold first.
 
838
 */
777
839
void sci_goto_line(ScintillaObject *sci, gint line, gboolean unfold)
778
840
{
779
841
        if (unfold) SSM(sci, SCI_ENSUREVISIBLE, line, 0);
787
849
}
788
850
 
789
851
 
790
 
/** Get style ID for @a position.
 
852
/** Gets style ID at @a position.
791
853
 * @param sci Scintilla widget.
792
854
 * @param position Position.
793
855
 * @return Style ID. */
796
858
        return SSM(sci, SCI_GETSTYLEAT, position, 0);
797
859
}
798
860
 
 
861
 
799
862
void sci_set_codepage(ScintillaObject *sci, gint cp)
800
863
{
801
864
        g_return_if_fail(cp == 0 || cp == SC_CP_UTF8);
811
874
 
812
875
void sci_clear_cmdkey(ScintillaObject *sci, gint key)
813
876
{
814
 
        SSM (sci, SCI_CLEARCMDKEY, key, 0);
 
877
        SSM(sci, SCI_CLEARCMDKEY, key, 0);
815
878
}
816
879
 
817
880
 
818
 
/** Get text between @a start and @a end.
 
881
/** Gets text between @a start and @a end.
819
882
 * @deprecated sci_get_text_range is deprecated and should not be used in newly-written code.
820
883
 * Use sci_get_contents_range() instead.
821
884
 *
832
895
        SSM(sci, SCI_GETTEXTRANGE, 0, (long) &tr);
833
896
}
834
897
 
835
 
/** Get text between @a start and @a end.
 
898
 
 
899
/** Gets text between @a start and @a end.
836
900
 *
837
901
 * @param sci Scintilla widget.
838
902
 * @param start Start.
861
925
}
862
926
 
863
927
 
864
 
/** Insert text.
 
928
/** Inserts text.
865
929
 * @param sci Scintilla widget.
866
 
 * @param pos Position.
 
930
 * @param pos Position, or -1 for current.
867
931
 * @param text Text. */
868
932
void sci_insert_text(ScintillaObject *sci, gint pos, const gchar *text)
869
933
{
895
959
}
896
960
 
897
961
 
898
 
void sci_set_keywords(ScintillaObject *sci, gint k, gchar *text)
 
962
void sci_set_keywords(ScintillaObject *sci, gint k, const gchar *text)
899
963
{
900
964
        SSM(sci, SCI_SETKEYWORDS, k, (sptr_t) text);
901
965
}
902
966
 
 
967
 
903
968
void sci_set_readonly(ScintillaObject *sci, gboolean readonly)
904
969
{
905
970
        SSM(sci, SCI_SETREADONLY, readonly, 0);
906
971
}
907
972
 
908
 
/** A simple convenience function for sending Scintilla commands without any parameters.
 
973
 
 
974
/** Sends Scintilla commands without any parameters.
909
975
 * @param sci The Scintilla @c GtkWidget.
910
976
 * @param cmd @c SCI_COMMAND.
911
977
 * @see http://scintilla.org for the documentation.
912
978
 *
913
979
 *  @since 0.16
914
980
 */
915
 
void sci_send_command(ScintillaObject * sci, gint cmd)
 
981
void sci_send_command(ScintillaObject *sci, gint cmd)
916
982
{
917
983
        SSM(sci, cmd, 0, 0);
918
984
}
919
985
 
920
986
 
921
 
/** Get current line number.
 
987
/** Gets current line number.
922
988
 * @param sci Scintilla widget.
923
989
 * @return Line number. */
924
990
gint sci_get_current_line(ScintillaObject *sci)
926
992
        return SSM(sci, SCI_LINEFROMPOSITION, SSM(sci, SCI_GETCURRENTPOS, 0, 0), 0);
927
993
}
928
994
 
 
995
 
929
996
/* Get number of lines partially or fully selected.
930
997
 * Returns 1 if there is a partial selection on the same line.
931
998
 * Returns 2 if a whole line is selected including the line break char(s). */
940
1007
        return SSM(sci, SCI_LINEFROMPOSITION, end, 0) - SSM(sci, SCI_LINEFROMPOSITION, start, 0) + 1;
941
1008
}
942
1009
 
 
1010
 
943
1011
gint sci_get_first_visible_line(ScintillaObject *sci)
944
1012
{
945
1013
        return SSM(sci, SCI_GETFIRSTVISIBLELINE, 0, 0);
947
1015
 
948
1016
 
949
1017
/**
950
 
 *  Set the current indicator. This is necessary to define an indicator for a range of text or
 
1018
 *  Sets the current indicator. This is necessary to define an indicator for a range of text or
951
1019
 *  clearing indicators for a range of text.
952
1020
 *
953
1021
 *  @param sci Scintilla widget.
962
1030
        SSM(sci, SCI_SETINDICATORCURRENT, indic, 0);
963
1031
}
964
1032
 
 
1033
 
965
1034
void sci_indicator_fill(ScintillaObject *sci, gint pos, gint len)
966
1035
{
967
1036
        SSM(sci, SCI_INDICATORFILLRANGE, pos, len);
968
1037
}
969
1038
 
 
1039
 
970
1040
/**
971
 
 *  Clear a range of text from the currently set indicator.
 
1041
 *  Clears the currently set indicator from a range of text.
972
1042
 *  Starting at @a pos, @a len characters long.
973
1043
 *  In order to make this function properly, you need to set the current indicator before with
974
1044
 *  @ref sci_indicator_set().
984
1054
        SSM(sci, SCI_INDICATORCLEARRANGE, pos, len);
985
1055
}
986
1056
 
 
1057
 
987
1058
void sci_select_all(ScintillaObject *sci)
988
1059
{
989
1060
        SSM(sci, SCI_SELECTALL, 0, 0);
990
1061
}
991
1062
 
 
1063
 
992
1064
gint sci_get_line_indent_position(ScintillaObject *sci, gint line)
993
1065
{
994
1066
        return SSM(sci, SCI_GETLINEINDENTPOSITION, line, 0);
995
1067
}
996
1068
 
 
1069
 
997
1070
void sci_set_autoc_max_height(ScintillaObject *sci, gint val)
998
1071
{
999
1072
        SSM(sci, SCI_AUTOCSETMAXHEIGHT, val, 0);
1000
1073
}
1001
1074
 
1002
 
/** Find a matching brace at @a pos.
 
1075
 
 
1076
/** Finds a matching brace at @a pos.
1003
1077
 * @param sci Scintilla widget.
1004
1078
 * @param pos Position.
1005
1079
 * @return Matching brace position.
1011
1085
        return SSM(sci, SCI_BRACEMATCH, pos, 0);
1012
1086
}
1013
1087
 
 
1088
 
1014
1089
gint sci_get_overtype(ScintillaObject *sci)
1015
1090
{
1016
1091
        return SSM(sci, SCI_GETOVERTYPE, 0, 0);
1017
1092
}
1018
1093
 
 
1094
 
1019
1095
void sci_set_tab_indents(ScintillaObject *sci, gboolean set)
1020
1096
{
1021
1097
        SSM(sci, SCI_SETTABINDENTS, set, 0);
1022
1098
}
1023
1099
 
 
1100
 
1024
1101
void sci_set_use_tabs(ScintillaObject *sci, gboolean set)
1025
1102
{
1026
1103
        SSM(sci, SCI_SETUSETABS, set, 0);
1027
1104
}
1028
1105
 
 
1106
 
1029
1107
gint sci_get_pos_at_line_sel_start(ScintillaObject *sci, gint line)
1030
1108
{
1031
1109
        return SSM(sci, SCI_GETLINESELSTARTPOSITION, line, 0);
1032
1110
}
1033
1111
 
 
1112
 
1034
1113
gint sci_get_pos_at_line_sel_end(ScintillaObject *sci, gint line)
1035
1114
{
1036
1115
        return SSM(sci, SCI_GETLINESELENDPOSITION, line, 0);
1037
1116
}
1038
1117
 
1039
 
/** Get selection mode.
 
1118
 
 
1119
/** Gets selection mode.
1040
1120
 * @param sci Scintilla widget.
1041
1121
 * @return Selection mode. */
1042
1122
gint sci_get_selection_mode(ScintillaObject *sci)
1044
1124
        return SSM(sci, SCI_GETSELECTIONMODE, 0, 0);
1045
1125
}
1046
1126
 
1047
 
/** Set selection mode.
 
1127
 
 
1128
/** Sets selection mode.
1048
1129
 * @param sci Scintilla widget.
1049
1130
 * @param mode Mode. */
1050
1131
void sci_set_selection_mode(ScintillaObject *sci, gint mode)
1052
1133
        SSM(sci, SCI_SETSELECTIONMODE, mode, 0);
1053
1134
}
1054
1135
 
 
1136
 
1055
1137
void sci_set_scrollbar_mode(ScintillaObject *sci, gboolean visible)
1056
1138
{
1057
1139
        SSM(sci, SCI_SETHSCROLLBAR, visible, 0);
1058
1140
        SSM(sci, SCI_SETVSCROLLBAR, visible, 0);
1059
1141
}
1060
1142
 
 
1143
 
 
1144
/** Sets the indentation of a line.
 
1145
 * @param sci Scintilla widget.
 
1146
 * @param line Line to indent.
 
1147
 * @param indent Indentation width.
 
1148
 *
 
1149
 * @since 0.19
 
1150
 */
1061
1151
void sci_set_line_indentation(ScintillaObject *sci, gint line, gint indent)
1062
1152
{
1063
1153
        SSM(sci, SCI_SETLINEINDENTATION, line, indent);
1064
1154
}
1065
1155
 
1066
 
int sci_get_line_indentation(ScintillaObject *sci, gint line)
 
1156
 
 
1157
/** Gets the indentation width of a line.
 
1158
 * @param sci Scintilla widget.
 
1159
 * @param line Line to get the indentation from.
 
1160
 * @return Indentation width.
 
1161
 *
 
1162
 * @since 0.19
 
1163
 */
 
1164
gint sci_get_line_indentation(ScintillaObject *sci, gint line)
1067
1165
{
1068
1166
        return SSM(sci, SCI_GETLINEINDENTATION, line, 0);
1069
1167
}
1070
1168
 
 
1169
 
1071
1170
void sci_set_caret_policy_x(ScintillaObject *sci, gint policy, gint slop)
1072
1171
{
1073
1172
        SSM(sci, SCI_SETXCARETPOLICY, policy, slop);
1074
1173
}
1075
1174
 
 
1175
 
1076
1176
void sci_set_caret_policy_y(ScintillaObject *sci, gint policy, gint slop)
1077
1177
{
1078
1178
        SSM(sci, SCI_SETYCARETPOLICY, policy, slop);
1079
1179
}
1080
1180
 
1081
 
void sci_set_scroll_stop_at_last_line(ScintillaObject* sci, gboolean set)
 
1181
 
 
1182
void sci_set_scroll_stop_at_last_line(ScintillaObject *sci, gboolean set)
1082
1183
{
1083
1184
        SSM(sci, SCI_SETENDATLASTLINE, set, 0);
1084
1185
}
1085
1186
 
 
1187
 
1086
1188
void sci_cancel(ScintillaObject *sci)
1087
1189
{
1088
 
        SSM( sci, SCI_CANCEL, 0, 0);
 
1190
        SSM(sci, SCI_CANCEL, 0, 0);
1089
1191
}
1090
1192
 
 
1193
 
1091
1194
gint sci_get_target_end(ScintillaObject *sci)
1092
1195
{
1093
 
        return SSM( sci, SCI_GETTARGETEND, 0, 0);
 
1196
        return SSM(sci, SCI_GETTARGETEND, 0, 0);
1094
1197
}
1095
1198
 
 
1199
 
1096
1200
gint sci_get_position_after(ScintillaObject *sci, gint start)
1097
1201
{
1098
1202
        return SSM(sci, SCI_POSITIONAFTER, start, 0);
1099
1203
}
1100
1204
 
 
1205
 
1101
1206
void sci_lines_split(ScintillaObject *sci, gint pixelWidth)
1102
1207
{
1103
1208
        SSM(sci, SCI_LINESSPLIT, pixelWidth, 0);
1104
1209
}
1105
1210
 
 
1211
 
1106
1212
void sci_lines_join(ScintillaObject *sci)
1107
1213
{
1108
1214
        SSM(sci, SCI_LINESJOIN, 0, 0);
1109
1215
}
1110
1216
 
 
1217
 
1111
1218
gint sci_text_width(ScintillaObject *sci, gint styleNumber, const gchar *text)
1112
1219
{
1113
1220
        return SSM(sci, SCI_TEXTWIDTH, styleNumber, (sptr_t) text);