1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
/* -*- C -*- */ 
require gtksourceview; 
 
class GTK2.SourceBuffer; 
inherit GTK2.TextBuffer; 
 
%{ 
#include "gtksourceview/gtksourceview.h" 
%} 
add_global { 
#include "gtksourceview/gtksourceview.h" 
}; 
 
//! Text buffer object for GTK2.SourceView 
//! <p> 
//! Properties: 
//! int check-brackets 
//! int escape-char 
//! int highlight 
//! GTK2.SourceLanguage language 
//! int max-undo-levels 
 
signal redo; 
signal undo; 
signal highlight_updated; 
signal marker_updated; 
 
not gtksourceview20; 
void create(GTK2.SourceTagTable|GTK2.SourceLanguage|void table_or_lang) 
//! Creates a new source buffer.  If table_or_lang is a GTK2.SourceLanguage, 
//! it will create a buffer using the highlighting patterns of that language. 
//! If it is a GTK2.SourceTagTable, it will use that table, otherwise it will 
//! be a new source buffer with a new tag table. 
{ 
  pgtk2_verify_not_inited(); 
  pgtk2_verify_setup(); 
  if (args) { 
    struct object *o1; 
    GtkSourceBuffer *gs; 
    get_all_args(NULL,args,"%o",&o1); 
    if (G_TYPE_FROM_INSTANCE(get_gobject(o1))==GTK_TYPE_SOURCE_TAG_TABLE) { 
      gs=gtk_source_buffer_new( 
                        GTK_SOURCE_TAG_TABLE(get_gobject(o1))); 
    } else { 
      gs=gtk_source_buffer_new_with_language( 
                        GTK_SOURCE_LANGUAGE(get_gobject(o1))); 
    } 
    THIS->obj=G_OBJECT(gs); 
  } else { 
    GtkSourceBuffer *gs; 
    gs=gtk_source_buffer_new(NULL); 
    THIS->obj=G_OBJECT(gs); 
  } 
  pgtk2_pop_n_elems(args); 
  pgtk2__init_this_object(); 
} 
endnot; 
require gtksourceview20; 
void create(GTK2.TextTagTable|GTK2.SourceLanguage|void table_or_lang) 
//! Create a new SourceBuffer. 
{ 
  pgtk2_verify_not_inited(); 
  pgtk2_verify_setup(); 
  if (args) { 
    struct object *o1; 
    GtkSourceBuffer *gs; 
    get_all_args(NULL,args,"%o",&o1); 
    if (G_TYPE_FROM_INSTANCE(get_gobject(o1))==GTK_TYPE_TEXT_TAG_TABLE) { 
      gs=gtk_source_buffer_new( 
                        GTK_TEXT_TAG_TABLE(get_gobject(o1))); 
    } else { 
      gs=gtk_source_buffer_new_with_language( 
                        GTK_SOURCE_LANGUAGE(get_gobject(o1))); 
    } 
    THIS->obj=G_OBJECT(gs); 
  } else { 
    GtkSourceBuffer *gs; 
    gs=gtk_source_buffer_new(NULL); 
    THIS->obj=G_OBJECT(gs); 
  } 
  pgtk2_pop_n_elems(args); 
  pgtk2__init_this_object(); 
} 
endrequire; 
 
not gtksourceview20; 
int get_check_brackets(); 
//! Determines whether bracket match highlighting is activated. 
 
void set_check_brackets(int setting); 
//! Controls the bracket match highlighting function in the buffer.  If 
//! activated, when you position your cursor over a bracket character (a 
//! parenthesis, a square bracket, etc.) the matching opening or closing 
//! bracket character will be highlighted.  You can specify the style with the 
//! set_bracket_match_style() function. 
 
void set_bracket_match_style(mapping(string:mixed) style) 
//! Sets the style used for highlighting matching brackets. 
//! <code> 
//! ([ "default": boolean, 
//!    "mask": int, 
//!    "foreground": GDK2.Color, 
//!    "background": GDK2.Color, 
//!    "italic": boolean, 
//!    "bold": boolean, 
//!    "underline": boolean, 
//!    "strikethrough": boolean 
//! ]); 
//! </code> 
{ 
  pgtk2_verify_inited(); 
  { 
    GtkSourceTagStyle *sts; 
    struct mapping *m; 
    struct svalue *sv; 
    get_all_args(NULL,args,"%m",&m); 
    if (m==NULL) 
      Pike_error("No mapping.\n"); 
    sts=gtk_source_tag_style_new(); 
    if (sts==NULL) 
      SIMPLE_OUT_OF_MEMORY_ERROR("set_bracket_match_style",sizeof(GtkSourceTagStyle)); 
    sv=low_mapping_string_lookup(m,_STR("default")); 
    if (sv) 
      sts->is_default=PGTK_GETINT(sv); 
    sv=low_mapping_string_lookup(m,_STR("mask")); 
    if (sv) 
      sts->mask=PGTK_GETINT(sv); 
    sv=low_mapping_string_lookup(m,_STR("foreground")); 
    if (sv) { 
      if (TYPEOF(*sv) == PIKE_T_OBJECT && get_gdkobject(sv->u.object,color)) 
        sts->foreground=*(GdkColor *)get_gdkobject(sv->u.object,color); 
    } 
    sv=low_mapping_string_lookup(m,_STR("background")); 
    if (sv) { 
      if (TYPEOF(*sv) == PIKE_T_OBJECT && get_gdkobject(sv->u.object,color)) 
        sts->background=*(GdkColor *)get_gdkobject(sv->u.object,color); 
    } 
    sv=low_mapping_string_lookup(m,_STR("italic")); 
    if (sv) 
      sts->italic=PGTK_GETINT(sv); 
    sv=low_mapping_string_lookup(m,_STR("bold")); 
    if (sv) 
      sts->bold=PGTK_GETINT(sv); 
    sv=low_mapping_string_lookup(m,_STR("underline")); 
    if (sv) 
      sts->underline=PGTK_GETINT(sv); 
    sv=low_mapping_string_lookup(m,_STR("strikethrough")); 
    if (sv) 
      sts->strikethrough=PGTK_GETINT(sv); 
    gtk_source_buffer_set_bracket_match_style(GTK_SOURCE_BUFFER(THIS->obj),sts); 
    gtk_source_tag_style_free(sts); 
  } 
  RETURN_THIS(); 
} 
 
int get_highlight(); 
//! Determines whether text highlighting is activated in the source buffer. 
 
void set_highlight(int setting); 
//! Controls whether text is highlighted in the buffer.  If setting is true, 
//! the text will be highlighted according to the patterns installed in the 
//! buffer (either set with set_language() or by adding individual 
//! GTK2.SourceTag tags to the buffer's tag table).  Otherwise, any current 
//! highlighted text will be restored to the default buffer style. 
//! <p> 
//! Tags not of GTK2.SourceTag type will not be removed by this option, and 
//! normal GTK2.TextTag priority settings apply when highlighting is enabled. 
//! <p> 
//! If not using a GTK2.SourceLanguage for setting the highlighting patterns in 
//! the buffer, it is recommended for performance reasons that you add all the 
//! GTK2.SourceTag tags with highlighting disabled and enable it when finished. 
endnot; 
 
int get_max_undo_levels(); 
//! Determines the number of undo levels the buffer will track for buffer edits. 
 
void set_max_undo_levels(int setting); 
//! Sets the number of undo levels for user actions the buffer will track.  If 
//! the number of user actions exceeds the limit set by this funcction, older 
//! actions will be discarded. 
//! <p> 
//! A new action is started whenever the function begin_user_action() is 
//! called.  In general, this happens whenever the user presses any key which 
//! modifies the buffer, but the undo manager will try to merge similar 
//! consecutive actions, such as multiple character insertions into one action. 
//! But, inserting a newline does start a new action. 
 
GTK2.SourceLanguage get_language() 
//! Determines the GTK2.SourceLanguage used by the buffer. 
{ 
  pgtk2_verify_inited(); 
  pgtk2_pop_n_elems(args); 
  { 
    GtkSourceLanguage *sl; 
    sl=gtk_source_buffer_get_language(GTK_SOURCE_BUFFER(THIS->obj)); 
    g_object_ref(sl); 
    push_gobject(sl); 
  } 
} 
 
void set_language(GTK2.SourceLanguage lang); 
//! Sets the source language the source buffer will use, adding GTK2.SourceTag 
//! tags with the language's patterns and setting the escape character with 
//! set_escape_char().  Note that this will remove any GTK2.SourceTag tags 
//! currently in the buffer's tag table. 
 
not gtksourceview20; 
int get_escape_char(); 
//! Determines the escaping character used by the source buffer highlighting 
//! engine. 
 
void set_escape_char(int escape_char); 
//! Sets the escape character to be used by the highlighting engine. 
//! <p> 
//! When performing the initial analysis, the engine will discard a matching 
//! syntax pattern if it's prefixed with an odd number of escape characters. 
//! This allows for example to correctly highlight strings with escaped quotes 
//! embedded. 
//! <p> 
//! This setting affects only syntax patterns. 
endnot; 
 
int can_undo(); 
//! Determines whether a source buffer can undo the last action. 
 
int can_redo(); 
//! Determines whether a source buffer can redo the last action. 
 
void undo(); 
//! Undoes the last user action which modified the buffer.  Use can_undo() to 
//! check whether a call to this function will have any effect. 
//! <p> 
//! Actions are defined as groups of operations between a call to 
//! GTK2.TextBuffer->begin_user_action() and GTK2.TextBuffer->end_user_action(), 
//! or sequences of similar edits (inserts or deletes) on the same line. 
 
void redo(); 
//! Redoes the last undo operation.  Use can_redo() to check whether a call to 
//! this function will have any effect. 
 
void begin_not_undoable_action(); 
//! Marks the beginning of a not undoable action on the buffer, disabling the 
//! undo manager.  Typically you would call this function before initially 
//! setting the contents of the buffer (e.g. when loading a file in a text 
//! editor). 
//! <p> 
//! You may nest begin_no_undoable_action()/end_not_undoable_action() blocks. 
 
void end_not_undoable_action(); 
//! Marks the end of a not undoable action on the buffer.  When the last not 
//! undoable block is closed through a call to this function, the list of undo 
//! actions is cleared and the undo manager is re-enabled. 
 
not gtksourceview20; 
GTK2.SourceMarker create_marker(string name, string type, GTK2.TextIter where) 
//! Creates a marker in the buffer of type type.  A marker is semantically very 
//! similar to a GTK2.TextMark, except it has a type which is used by the 
//! GTK2.SourceView displaying the buffer to show a pixmap on the left margin, 
//! at the line the marker is in.  Becuase of this, a marker is generally 
//! associated to a line and not a character position.  Markers are also 
//! accessible through a position or range in the buffer. 
//! <p> 
//! Markers are implemented using GTK2.TextMark, so all characteristics and 
//! restrictions to marks apply to markers too.  These include life cycle 
//! issues and "mark-set" and "mark-deleted" signal emissions. 
//! <p> 
//! Like a GTK2.TextMark, a GTK2.SourceMarker can be anonymous if the passed 
//! name is 0. 
//! <p> 
//! Markers always have left gravity and are moved to the beginning of the line 
//! when the users deletes the line they were in.  Also, if the user deletes a 
//! region of text which contained lines with markers, those are deleted. 
//! <p> 
//! Typical uses for a marker are bookmarks, breakpoints, current executing 
//! instruction indication in a source file, etc. 
{ 
  pgtk2_verify_inited(); 
  { 
    char *name=NULL,*type; 
    struct object *o1; 
    GtkSourceMarker *gm; 
    INT_TYPE g; 
    if (TYPEOF(Pike_sp[-args]) == PIKE_T_INT) 
      get_all_args(NULL,args,"%i%s%o",&g,&type,&o1); 
    else 
      get_all_args(NULL,args,"%s%s%o",&name,&type,&o1); 
    gm=gtk_source_buffer_create_marker(GTK_SOURCE_BUFFER(THIS->obj), 
                        name,type, 
                        (GtkTextIter *)get_pg2object(o1,pgtk2_text_iter_program)); 
    pgtk2_pop_n_elems(args); 
    push_gobjectclass(gm,pgtk2_source_marker_program); 
  } 
} 
 
void move_marker(GTK2.SourceMarker marker, GTK2.TextIter where) 
//! Moves marker to the new location. 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o1,*o2; 
    get_all_args(NULL,args,"%o%o",&o1,&o2); 
    gtk_source_buffer_move_marker(GTK_SOURCE_BUFFER(THIS->obj), 
                        (GtkSourceMarker *)get_gobject(o1), 
                        (GtkTextIter *)get_gobject(o2)); 
  } 
  RETURN_THIS(); 
} 
 
void delete_marker(GTK2.SourceMarker marker) 
//! Deletes marker from the source buffer.  The same conditions as for 
//! GTK2.TextMark apply here. 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o1; 
    get_all_args(NULL,args,"%o",&o1); 
    gtk_source_buffer_delete_marker(GTK_SOURCE_BUFFER(THIS->obj), 
                        (GtkSourceMarker *)get_gobject(o1)); 
  } 
  RETURN_THIS(); 
} 
 
GTK2.SourceMarker get_marker(string name) 
//! Looks up the GTK2.SourceMarker named name, or returns 0 if it doesn't exist. 
{ 
  pgtk2_verify_inited(); 
  { 
    char *name; 
    GtkSourceMarker *gm; 
    get_all_args(NULL,args,"%s",&name); 
    gm=gtk_source_buffer_get_marker(GTK_SOURCE_BUFFER(THIS->obj),name); 
    pgtk2_pop_n_elems(args); 
    if (gm) 
      push_gobjectclass(gm,pgtk2_source_marker_program); 
    else 
      push_int(0); 
  } 
} 
 
array(GTK2.SourceMarker) get_markers_in_region(GTK2.TextIter begin, 
                        GTK2.TextIter end) 
//! Returns an ordered (by position) list of GTK2.SourceMarker objects inside 
//! the region delimited by the GTK2.TextIters begin and end.  The iters may 
//! be in any order. 
{ 
  pgtk2_verify_inited(); 
  { 
    GSList *gsl,*gs2; 
    struct object *o1,*o2; 
    int i=0; 
    get_all_args(NULL,args,"%o%o",&o1,&o2); 
    gsl=gs2=gtk_source_buffer_get_markers_in_region(GTK_SOURCE_BUFFER(THIS->obj), 
                        (GtkTextIter *)get_gobject(o1), 
                        (GtkTextIter *)get_gobject(o2)); 
    pgtk2_pop_n_elems(args); 
    while (gs2) { 
      push_gobjectclass(gs2->data,pgtk2_source_marker_program); 
      g_object_ref(gs2->data); 
      i++; 
      gs2=g_slist_next(gs2); 
    } 
    f_aggregate(i); 
    g_slist_free(gsl); 
  } 
} 
 
GTK2.SourceMarker get_first_marker() 
//! Returns the first (nearest to the top of the buffer) marker. 
{ 
  pgtk2_verify_inited(); 
  pgtk2_pop_n_elems(args); 
  { 
    GtkSourceMarker *gm; 
    gm=gtk_source_buffer_get_first_marker(GTK_SOURCE_BUFFER(THIS->obj)); 
    if (gm) 
      push_gobjectclass(gm,pgtk2_source_marker_program); 
    else 
      push_int(0); 
  } 
} 
 
GTK2.SourceMarker get_last_marker() 
//! Returns the last (nearest to the bottom of the buffer) marker. 
{ 
  pgtk2_verify_inited(); 
  pgtk2_pop_n_elems(args); 
  { 
    GtkSourceMarker *gm; 
    gm=gtk_source_buffer_get_last_marker(GTK_SOURCE_BUFFER(THIS->obj)); 
    if (gm) 
      push_gobjectclass(gm,pgtk2_source_marker_program); 
    else 
      push_int(0); 
  } 
} 
 
GTK2.TextIter get_iter_at_marker(GTK2.SourceMarker marker) 
//! Returns a GTK2.TextIter at marker. 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o1; 
    GtkTextIter *gti; 
    get_all_args(NULL,args,"%o",&o1); 
    gti=g_malloc(sizeof(GtkTextIter)); 
    if (gti==NULL) 
      SIMPLE_OUT_OF_MEMORY_ERROR("get_iter_at_marker",sizeof(GtkTextIter)); 
    gtk_source_buffer_get_iter_at_marker(GTK_SOURCE_BUFFER(THIS->obj), 
                        gti,(GtkSourceMarker *)get_gobject(o1)); 
    pgtk2_pop_n_elems(args); 
    push_pgdk2object(gti,pgtk2_text_iter_program,1); 
  } 
} 
 
GTK2.SourceMarker get_next_marker(GTK2.TextIter iter) 
//! Returns the nearest marker to the right of iter.  If there are multiple 
//! markers at the same position, this function will always return the first 
//! one (from the internal linked list), even if starting the search exactly 
//! at its location.  You can get the others using next(). 
{ 
  pgtk2_verify_inited(); 
  { 
    GtkSourceMarker *gm; 
    struct object *o1; 
    get_all_args(NULL,args,"%o",&o1); 
    gm=gtk_source_buffer_get_next_marker(GTK_SOURCE_BUFFER(THIS->obj), 
                        (GtkTextIter *)get_gobject(o1)); 
    pgtk2_pop_n_elems(args); 
    if (gm) 
      push_gobjectclass(gm,pgtk2_source_marker_program); 
    else 
      push_int(0); 
  } 
} 
 
GTK2.SourceMarker get_prev_marker(GTK2.TextIter iter) 
//! Returns the nearest marker to the left of iter.  If there are multiple 
//! markers at the same position, this function will always return the last one 
//! (from the internal linked list), even if starting the search exactly at 
//! its location.  You can get the others using prev(). 
{ 
  pgtk2_verify_inited(); 
  { 
    GtkSourceMarker *gm; 
    struct object *o1; 
    get_all_args(NULL,args,"%o",&o1); 
    gm=gtk_source_buffer_get_prev_marker(GTK_SOURCE_BUFFER(THIS->obj), 
                        (GtkTextIter *)get_gobject(o1)); 
    pgtk2_pop_n_elems(args); 
    if (gm) 
      push_gobjectclass(gm,pgtk2_source_marker_program); 
    else 
      push_int(0); 
  } 
} 
endnot;