2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkSourceBuffer.html
27 * outFile = SourceBuffer
28 * strct = GtkSourceBuffer
39 * - gtk_source_buffer_
44 * - gsv.SourceTagTable
45 * - gsv.SourceLanguage
46 * - gsv.SourceTagStyle
53 * - GtkSourceLanguage* -> SourceLanguage
54 * - GtkSourceMarker* -> SourceMarker
55 * - GtkSourceTagStyle* -> SourceTagStyle
56 * - GtkSourceTagTable* -> SourceTagTable
57 * - GtkTextIter* -> TextIter
62 module gsv
.SourceBuffer
;
68 import tango
.io
.Stdout
; // use the tango loging?
72 private import gsvc
.gsvtypes
;
74 private import gsvc
.gsv
;
77 private import gsv
.SourceTagTable
;
78 private import gsv
.SourceLanguage
;
79 private import gsv
.SourceTagStyle
;
80 private import gsv
.SourceMarker
;
81 private import gtk
.TextIter
;
82 private import glib
.Str
;
83 private import glib
.ListSG
;
90 * The GtkSourceBuffer object is the model for GtkSourceView widgets.
91 * It extends the GtkTextBuffer object by adding features necessary to
92 * display and edit source code: syntax highlighting, bracket matching
93 * and markers. It also implements support for undo/redo operations.
94 * To create a GtkSourceBuffer use gtk_source_buffer_new() or
95 * gtk_source_buffer_new_with_language(). The second form is just a
96 * convenience function which allows you to initially set a
98 * By default highlighting is enabled, but you can disable it with
99 * gtk_source_buffer_set_highlight(). This can be useful if you're not
100 * using GtkSourceLanguage objects to set the highlighting patterns, and
101 * instead you're manually adding GtkSourceTag objects to the buffer's
104 private import gtk
.TextBuffer
;
105 public class SourceBuffer
: TextBuffer
108 /** the main Gtk struct */
109 protected GtkSourceBuffer
* gtkSourceBuffer
;
112 public GtkSourceBuffer
* getSourceBufferStruct()
114 return gtkSourceBuffer
;
118 /** the main Gtk struct as a void* */
119 protected void* getStruct()
121 return cast(void*)gtkSourceBuffer
;
125 * Sets our main struct and passes it to the parent class
127 public this (GtkSourceBuffer
* gtkSourceBuffer
)
131 if ( gtkSourceBuffer
is null )
136 Stdout("struct gtkSourceBuffer is null on constructor").newline
;
140 printf("struct gtkSourceBuffer is null on constructor");
147 assert(gtkSourceBuffer
!is null, "struct gtkSourceBuffer is null on constructor");
149 super(cast(GtkTextBuffer
*)gtkSourceBuffer
);
150 this.gtkSourceBuffer
= gtkSourceBuffer
;
156 // imports for the signal processing
157 private import gobject
.Signals
;
158 private import gtkc
.gdktypes
;
159 int[char[]] connectedSignals
;
161 void delegate(gboolean
, SourceBuffer
)[] onCanRedoListeners
;
162 void addOnCanRedo(void delegate(gboolean
, SourceBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
164 if ( !("can-redo" in connectedSignals
) )
169 cast(GCallback
)&callBackCanRedo
,
173 connectedSignals
["can-redo"] = 1;
175 onCanRedoListeners
~= dlg
;
177 extern(C
) static void callBackCanRedo(GtkSourceBuffer
* sourcebufferStruct
, gboolean arg1
, SourceBuffer sourceBuffer
)
179 bool consumed
= false;
181 foreach ( void delegate(gboolean
, SourceBuffer
) dlg
; sourceBuffer
.onCanRedoListeners
)
183 dlg(arg1
, sourceBuffer
);
189 void delegate(gboolean
, SourceBuffer
)[] onCanUndoListeners
;
190 void addOnCanUndo(void delegate(gboolean
, SourceBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
192 if ( !("can-undo" in connectedSignals
) )
197 cast(GCallback
)&callBackCanUndo
,
201 connectedSignals
["can-undo"] = 1;
203 onCanUndoListeners
~= dlg
;
205 extern(C
) static void callBackCanUndo(GtkSourceBuffer
* sourcebufferStruct
, gboolean arg1
, SourceBuffer sourceBuffer
)
207 bool consumed
= false;
209 foreach ( void delegate(gboolean
, SourceBuffer
) dlg
; sourceBuffer
.onCanUndoListeners
)
211 dlg(arg1
, sourceBuffer
);
217 void delegate(TextIter
, TextIter
, SourceBuffer
)[] onHighlightUpdatedListeners
;
218 void addOnHighlightUpdated(void delegate(TextIter
, TextIter
, SourceBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
220 if ( !("highlight-updated" in connectedSignals
) )
225 cast(GCallback
)&callBackHighlightUpdated
,
229 connectedSignals
["highlight-updated"] = 1;
231 onHighlightUpdatedListeners
~= dlg
;
233 extern(C
) static void callBackHighlightUpdated(GtkSourceBuffer
* sourcebufferStruct
, GtkTextIter
* arg1
, GtkTextIter
* arg2
, SourceBuffer sourceBuffer
)
235 bool consumed
= false;
237 foreach ( void delegate(TextIter
, TextIter
, SourceBuffer
) dlg
; sourceBuffer
.onHighlightUpdatedListeners
)
239 dlg(new TextIter(arg1
), new TextIter(arg2
), sourceBuffer
);
245 void delegate(TextIter
, SourceBuffer
)[] onMarkerUpdatedListeners
;
246 void addOnMarkerUpdated(void delegate(TextIter
, SourceBuffer
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
248 if ( !("marker-updated" in connectedSignals
) )
253 cast(GCallback
)&callBackMarkerUpdated
,
257 connectedSignals
["marker-updated"] = 1;
259 onMarkerUpdatedListeners
~= dlg
;
261 extern(C
) static void callBackMarkerUpdated(GtkSourceBuffer
* sourcebufferStruct
, GtkTextIter
* arg1
, SourceBuffer sourceBuffer
)
263 bool consumed
= false;
265 foreach ( void delegate(TextIter
, SourceBuffer
) dlg
; sourceBuffer
.onMarkerUpdatedListeners
)
267 dlg(new TextIter(arg1
), sourceBuffer
);
276 * Creates a new source buffer.
278 * a GtkSourceTagTable, or NULL to create a new one.
280 * a new source buffer.
282 public this (SourceTagTable table
)
284 // GtkSourceBuffer* gtk_source_buffer_new (GtkSourceTagTable *table);
285 this(cast(GtkSourceBuffer
*)gtk_source_buffer_new((table
is null) ?
null : table
.getSourceTagTableStruct()) );
289 * Creates a new source buffer using the highlighting patterns in
290 * language. This is equivalent to creating a new source buffer with
291 * the default tag table and then calling
292 * gtk_source_buffer_set_language().
294 * a GtkSourceLanguage.
296 * a new source buffer which will highlight text
297 * according to language.
299 public this (SourceLanguage language
)
301 // GtkSourceBuffer* gtk_source_buffer_new_with_language (GtkSourceLanguage *language);
302 this(cast(GtkSourceBuffer
*)gtk_source_buffer_new_with_language((language
is null) ?
null : language
.getSourceLanguageStruct()) );
306 * Determines whether bracket match highlighting is activated for the
311 * TRUE if the source buffer will highlight matching
314 public int getCheckBrackets()
316 // gboolean gtk_source_buffer_get_check_brackets (GtkSourceBuffer *buffer);
317 return gtk_source_buffer_get_check_brackets(gtkSourceBuffer
);
321 * Controls the bracket match highlighting function in the buffer. If
322 * activated, when you position your cursor over a bracket character
323 * (a parenthesis, a square bracket, etc.) the matching opening or
324 * closing bracket character will be highlighted. You can specify the
325 * style with the gtk_source_buffer_set_bracket_match_style()
330 * TRUE if you want matching brackets highlighted.
332 public void setCheckBrackets(int checkBrackets
)
334 // void gtk_source_buffer_set_check_brackets (GtkSourceBuffer *buffer, gboolean check_brackets);
335 gtk_source_buffer_set_check_brackets(gtkSourceBuffer
, checkBrackets
);
339 * Sets the style used for highlighting matching brackets.
343 * the GtkSourceTagStyle specifying colors and text
346 public void setBracketMatchStyle(SourceTagStyle style
)
348 // void gtk_source_buffer_set_bracket_match_style (GtkSourceBuffer *source_buffer, const GtkSourceTagStyle *style);
349 gtk_source_buffer_set_bracket_match_style(gtkSourceBuffer
, (style
is null) ?
null : style
.getSourceTagStyleStruct());
353 * Determines whether text highlighting is activated in the source
358 * TRUE if highlighting is enabled.
360 public int getHighlight()
362 // gboolean gtk_source_buffer_get_highlight (GtkSourceBuffer *buffer);
363 return gtk_source_buffer_get_highlight(gtkSourceBuffer
);
367 * Controls whether text is highlighted in the buffer. If highlight
368 * is TRUE, the text will be highlighted according to the patterns
369 * installed in the buffer (either set with
370 * gtk_source_buffer_set_language() or by adding individual
371 * GtkSourceTag tags to the buffer's tag table). Otherwise, any
372 * current highlighted text will be restored to the default buffer
374 * Tags not of GtkSourceTag type will not be removed by this option,
375 * and normal GtkTextTag priority settings apply when highlighting is
377 * If not using a GtkSourceLanguage for setting the highlighting
378 * patterns in the buffer, it is recommended for performance reasons
379 * that you add all the GtkSourceTag tags with highlighting disabled
380 * and enable it when finished.
384 * TRUE if you want to activate highlighting.
386 public void setHighlight(int highlight
)
388 // void gtk_source_buffer_set_highlight (GtkSourceBuffer *buffer, gboolean highlight);
389 gtk_source_buffer_set_highlight(gtkSourceBuffer
, highlight
);
393 * Determines the number of undo levels the buffer will track for
398 * the maximum number of possible undo levels.
400 public int getMaxUndoLevels()
402 // gint gtk_source_buffer_get_max_undo_levels (GtkSourceBuffer *buffer);
403 return gtk_source_buffer_get_max_undo_levels(gtkSourceBuffer
);
407 * Sets the number of undo levels for user actions the buffer will
408 * track. If the number of user actions exceeds the limit set by this
409 * function, older actions will be discarded.
410 * A new action is started whenever the function
411 * gtk_text_buffer_begin_user_action() is called. In general, this
412 * happens whenever the user presses any key which modifies the
413 * buffer, but the undo manager will try to merge similar consecutive
414 * actions, such as multiple character insertions into one action.
415 * But, inserting a newline does start a new action.
419 * the desired maximum number of undo levels.
421 public void setMaxUndoLevels(int maxUndoLevels
)
423 // void gtk_source_buffer_set_max_undo_levels (GtkSourceBuffer *buffer, gint max_undo_levels);
424 gtk_source_buffer_set_max_undo_levels(gtkSourceBuffer
, maxUndoLevels
);
428 * Determines the GtkSourceLanguage used by the buffer. The returned
429 * object should not be unreferenced by the user.
433 * the GtkSourceLanguage set by
434 * gtk_source_buffer_set_language(), or NULL.
436 public SourceLanguage
getLanguage()
438 // GtkSourceLanguage* gtk_source_buffer_get_language (GtkSourceBuffer *buffer);
439 return new SourceLanguage( gtk_source_buffer_get_language(gtkSourceBuffer
) );
443 * Sets the GtkSourceLanguage the source buffer will use, adding
444 * GtkSourceTag tags with the language's patterns and setting the
445 * escape character with gtk_source_buffer_set_escape_char(). Note
446 * that this will remove any GtkSourceTag tags currently in the
447 * buffer's tag table. The buffer holds a reference to the language
452 * a GtkSourceLanguage to set, or NULL.
454 public void setLanguage(SourceLanguage language
)
456 // void gtk_source_buffer_set_language (GtkSourceBuffer *buffer, GtkSourceLanguage *language);
457 gtk_source_buffer_set_language(gtkSourceBuffer
, (language
is null) ?
null : language
.getSourceLanguageStruct());
461 * Determines the escaping character used by the source buffer
462 * highlighting engine.
466 * the UTF-8 character for the escape character the
469 public gunichar
getEscapeChar()
471 // gunichar gtk_source_buffer_get_escape_char (GtkSourceBuffer *buffer);
472 return gtk_source_buffer_get_escape_char(gtkSourceBuffer
);
476 * Sets the escape character to be used by the highlighting engine.
477 * When performing the initial analysis, the engine will discard a
478 * matching syntax pattern if it's prefixed with an odd number of
479 * escape characters. This allows for example to correctly highlight
480 * strings with escaped quotes embedded.
481 * This setting affects only syntax patterns (i.e. those defined in
482 * GtkSyntaxTag tags).
486 * the escape character the buffer should use.
488 public void setEscapeChar(gunichar escapeChar
)
490 // void gtk_source_buffer_set_escape_char (GtkSourceBuffer *buffer, gunichar escape_char);
491 gtk_source_buffer_set_escape_char(gtkSourceBuffer
, escapeChar
);
495 * Determines whether a source buffer can undo the last action.
499 * TRUE if it's possible to undo the last action.
503 // gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer);
504 return gtk_source_buffer_can_undo(gtkSourceBuffer
);
508 * Determines whether a source buffer can redo the last action
509 * (i.e. if the last operation was an undo).
513 * TRUE if a redo is possible.
517 // gboolean gtk_source_buffer_can_redo (GtkSourceBuffer *buffer);
518 return gtk_source_buffer_can_redo(gtkSourceBuffer
);
522 * Undoes the last user action which modified the buffer. Use
523 * gtk_source_buffer_can_undo() to check whether a call to this
524 * function will have any effect.
525 * Actions are defined as groups of operations between a call to
526 * gtk_text_buffer_begin_user_action() and
527 * gtk_text_buffer_end_user_action(), or sequences of similar edits
528 * (inserts or deletes) on the same line.
534 // void gtk_source_buffer_undo (GtkSourceBuffer *buffer);
535 gtk_source_buffer_undo(gtkSourceBuffer
);
539 * Redoes the last undo operation. Use gtk_source_buffer_can_redo()
540 * to check whether a call to this function will have any effect.
546 // void gtk_source_buffer_redo (GtkSourceBuffer *buffer);
547 gtk_source_buffer_redo(gtkSourceBuffer
);
551 * Marks the beginning of a not undoable action on the buffer,
552 * disabling the undo manager. Typically you would call this function
553 * before initially setting the contents of the buffer (e.g. when
554 * loading a file in a text editor).
555 * You may nest gtk_source_buffer_begin_not_undoable_action() /
556 * gtk_source_buffer_end_not_undoable_action() blocks.
560 public void beginNotUndoableAction()
562 // void gtk_source_buffer_begin_not_undoable_action (GtkSourceBuffer *buffer);
563 gtk_source_buffer_begin_not_undoable_action(gtkSourceBuffer
);
567 * Marks the end of a not undoable action on the buffer. When the
568 * last not undoable block is closed through the call to this
569 * function, the list of undo actions is cleared and the undo manager
574 public void endNotUndoableAction()
576 // void gtk_source_buffer_end_not_undoable_action (GtkSourceBuffer *buffer);
577 gtk_source_buffer_end_not_undoable_action(gtkSourceBuffer
);
581 * Creates a marker in the buffer of type type. A marker is
582 * semantically very similar to a GtkTextMark, except it has a type
583 * which is used by the GtkSourceView displaying the buffer to show a
584 * pixmap on the left margin, at the line the marker is in. Because
585 * of this, a marker is generally associated to a line and not a
586 * character position. Markers are also accessible through a position
587 * or range in the buffer.
588 * Markers are implemented using GtkTextMark, so all characteristics
589 * and restrictions to marks apply to markers too. These includes
590 * life cycle issues and "mark-set" and "mark-deleted" signal
592 * Like a GtkTextMark, a GtkSourceMarker can be anonymous if the
593 * passed name is NULL. Also, the buffer owns the markers so you
594 * shouldn't unreference it.
595 * Markers always have left gravity and are moved to the beginning of
596 * the line when the user deletes the line they were in. Also, if the
597 * user deletes a region of text which contained lines with markers,
599 * Typical uses for a marker are bookmarks, breakpoints, current
600 * executing instruction indication in a source file, etc..
604 * the name of the marker, or NULL.
606 * a string defining the marker type, or NULL.
608 * location to place the marker.
610 * a new GtkSourceMarker, owned by the buffer.
612 public SourceMarker
createMarker(char[] name
, char[] type
, TextIter where
)
614 // GtkSourceMarker* gtk_source_buffer_create_marker (GtkSourceBuffer *buffer, const gchar *name, const gchar *type, const GtkTextIter *where);
615 return new SourceMarker( gtk_source_buffer_create_marker(gtkSourceBuffer
, Str
.toStringz(name
), Str
.toStringz(type
), (where
is null) ?
null : where
.getTextIterStruct()) );
619 * Moves marker to the new location where.
623 * a GtkSourceMarker in buffer.
625 * the new location for the marker.
627 public void moveMarker(SourceMarker marker
, TextIter where
)
629 // void gtk_source_buffer_move_marker (GtkSourceBuffer *buffer, GtkSourceMarker *marker, const GtkTextIter *where);
630 gtk_source_buffer_move_marker(gtkSourceBuffer
, (marker
is null) ?
null : marker
.getSourceMarkerStruct(), (where
is null) ?
null : where
.getTextIterStruct());
634 * Deletes marker from the source buffer. The same conditions as for
635 * GtkTextMark apply here. The marker is no longer accessible from
636 * the buffer, but if you held a reference to it, it will not be
641 * a GtkSourceMarker in the buffer.
643 public void deleteMarker(SourceMarker marker
)
645 // void gtk_source_buffer_delete_marker (GtkSourceBuffer *buffer, GtkSourceMarker *marker);
646 gtk_source_buffer_delete_marker(gtkSourceBuffer
, (marker
is null) ?
null : marker
.getSourceMarkerStruct());
650 * Looks up the GtkSourceMarker named name in buffer, returning
651 * NULL if it doesn't exists.
655 * name of the marker to retrieve.
657 * the GtkSourceMarker whose name is name, or NULL.
659 public SourceMarker
getMarker(char[] name
)
661 // GtkSourceMarker* gtk_source_buffer_get_marker (GtkSourceBuffer *buffer, const gchar *name);
662 return new SourceMarker( gtk_source_buffer_get_marker(gtkSourceBuffer
, Str
.toStringz(name
)) );
666 * Returns an ordered (by position) GSList of
667 * GtkSourceMarker objects inside the region delimited by the
668 * GtkTextIter begin and end. The iters may be in any order.
672 * beginning of the range.
676 * a GSList of the GtkSourceMarker inside the range.
678 public ListSG
getMarkersInRegion(TextIter begin
, TextIter end
)
680 // GSList* gtk_source_buffer_get_markers_in_region (GtkSourceBuffer *buffer, const GtkTextIter *begin, const GtkTextIter *end);
681 return new ListSG( gtk_source_buffer_get_markers_in_region(gtkSourceBuffer
, (begin
is null) ?
null : begin
.getTextIterStruct(), (end
is null) ?
null : end
.getTextIterStruct()) );
685 * Returns the first (nearest to the top of the buffer) marker in
690 * a reference to the first GtkSourceMarker, or NULL if
691 * there are no markers in the buffer.
693 public SourceMarker
getFirstMarker()
695 // GtkSourceMarker* gtk_source_buffer_get_first_marker (GtkSourceBuffer *buffer);
696 return new SourceMarker( gtk_source_buffer_get_first_marker(gtkSourceBuffer
) );
700 * Returns the last (nearest to the bottom of the buffer) marker in
705 * a reference to the last GtkSourceMarker, or NULL if
706 * there are no markers in the buffer.
708 public SourceMarker
getLastMarker()
710 // GtkSourceMarker* gtk_source_buffer_get_last_marker (GtkSourceBuffer *buffer);
711 return new SourceMarker( gtk_source_buffer_get_last_marker(gtkSourceBuffer
) );
715 * Initializes iter at the location of marker.
719 * a GtkTextIter to initialize.
721 * a GtkSourceMarker of buffer.
723 public void getIterAtMarker(TextIter iter
, SourceMarker marker
)
725 // void gtk_source_buffer_get_iter_at_marker (GtkSourceBuffer *buffer, GtkTextIter *iter, GtkSourceMarker *marker);
726 gtk_source_buffer_get_iter_at_marker(gtkSourceBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct(), (marker
is null) ?
null : marker
.getSourceMarkerStruct());
730 * Returns the nearest marker to the right of iter. If there are
731 * multiple markers at the same position, this function will always
732 * return the first one (from the internal linked list), even if
733 * starting the search exactly at its location. You can get the
734 * others using gtk_source_marker_next().
738 * the location to start searching from.
740 * the GtkSourceMarker nearest to the right of iter,
741 * or NULL if there are no more markers after iter.
743 public SourceMarker
getNextMarker(TextIter iter
)
745 // GtkSourceMarker* gtk_source_buffer_get_next_marker (GtkSourceBuffer *buffer, GtkTextIter *iter);
746 return new SourceMarker( gtk_source_buffer_get_next_marker(gtkSourceBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct()) );
750 * Returns the nearest marker to the left of iter. If there are
751 * multiple markers at the same position, this function will always
752 * return the last one (from the internal linked list), even if
753 * starting the search exactly at its location. You can get the
754 * others using gtk_source_marker_prev().
758 * the location to start searching from.
760 * the GtkSourceMarker nearest to the left of iter,
761 * or NULL if there are no more markers before iter.
763 * The "check-brackets" property
764 * "check-brackets" gboolean : Read / Write
765 * Whether to check and highlight matching brackets.
766 * Default value: TRUE
768 public SourceMarker
getPrevMarker(TextIter iter
)
770 // GtkSourceMarker* gtk_source_buffer_get_prev_marker (GtkSourceBuffer *buffer, GtkTextIter *iter);
771 return new SourceMarker( gtk_source_buffer_get_prev_marker(gtkSourceBuffer
, (iter
is null) ?
null : iter
.getTextIterStruct()) );