1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GtkSourceBuffer.html 27 * outPack = gsv 28 * outFile = SourceBuffer 29 * strct = GtkSourceBuffer 30 * realStrct= 31 * ctorStrct= 32 * clss = SourceBuffer 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_source_buffer_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ListSG 48 * - gsv.SourceLanguage 49 * - gsv.SourceMark 50 * - gsv.SourceStyleScheme 51 * - gsv.SourceUndoManager 52 * - gsv.SourceUndoManagerIF 53 * - gtk.TextIter 54 * - gtk.TextTagTable 55 * structWrap: 56 * - GSList* -> ListSG 57 * - GtkSourceLanguage* -> SourceLanguage 58 * - GtkSourceMark* -> SourceMark 59 * - GtkSourceStyleScheme* -> SourceStyleScheme 60 * - GtkSourceUndoManager* -> SourceUndoManagerIF 61 * - GtkTextIter* -> TextIter 62 * - GtkTextTagTable* -> TextTagTable 63 * module aliases: 64 * local aliases: 65 * overrides: 66 */ 67 68 module gsv.SourceBuffer; 69 70 public import gsvc.gsvtypes; 71 72 private import gsvc.gsv; 73 private import glib.ConstructionException; 74 private import gobject.ObjectG; 75 76 private import gobject.Signals; 77 public import gtkc.gdktypes; 78 private import glib.Str; 79 private import glib.ListSG; 80 private import gsv.SourceLanguage; 81 private import gsv.SourceMark; 82 private import gsv.SourceStyleScheme; 83 private import gsv.SourceUndoManager; 84 private import gsv.SourceUndoManagerIF; 85 private import gtk.TextIter; 86 private import gtk.TextTagTable; 87 88 89 private import gtk.TextBuffer; 90 91 /** 92 * The GtkSourceBuffer object is the model for GtkSourceView widgets. 93 * It extends the GtkTextBuffer object by adding features useful to display 94 * and edit source code such as syntax highlighting and bracket matching. It 95 * also implements support for undo/redo operations, and for the search and 96 * replace. 97 * 98 * To create a GtkSourceBuffer use gtk_source_buffer_new() or 99 * gtk_source_buffer_new_with_language(). The second form is just a convenience 100 * function which allows you to initially set a GtkSourceLanguage. 101 * 102 * By default highlighting is enabled, but you can disable it with 103 * gtk_source_buffer_set_highlight_syntax(). 104 * 105 * Undo and Redo 106 * 107 * A custom GtkSourceUndoManager can be implemented and set with 108 * gtk_source_buffer_set_undo_manager(). However the default implementation 109 * should be suitable for most uses. By default, actions that can be undone or 110 * redone are defined as groups of operations between a call to 111 * gtk_text_buffer_begin_user_action() and gtk_text_buffer_end_user_action(). In 112 * general, this happens whenever the user presses any key which modifies the 113 * buffer. But the default undo manager will try to merge similar consecutive 114 * actions, such as multiple character insertions on the same line, into one 115 * action. But, inserting a newline starts a new action. 116 * 117 * The default undo manager remembers the "modified" state of the buffer, and 118 * restore it when an action is undone or redone. It can be useful in a text 119 * editor to know whether the file is saved. See gtk_text_buffer_get_modified() 120 * and gtk_text_buffer_set_modified(). 121 * 122 * <hr> 123 * 124 * Context Classes 125 * 126 * It is possible to retrieve some information from the syntax highlighting 127 * engine. There are currently three context classes, that are applied to 128 * regions of a GtkSourceBuffer: 129 * 130 * comment: the region delimits a comment; 131 * 132 * string: the region delimits a string; 133 * 134 * no-spell-check: the region should not be spell 135 * checked. 136 */ 137 public class SourceBuffer : TextBuffer 138 { 139 140 /** the main Gtk struct */ 141 protected GtkSourceBuffer* gtkSourceBuffer; 142 143 144 /** Get the main Gtk struct */ 145 public GtkSourceBuffer* getSourceBufferStruct() 146 { 147 return gtkSourceBuffer; 148 } 149 150 151 /** the main Gtk struct as a void* */ 152 protected override void* getStruct() 153 { 154 return cast(void*)gtkSourceBuffer; 155 } 156 157 /** 158 * Sets our main struct and passes it to the parent class 159 */ 160 public this (GtkSourceBuffer* gtkSourceBuffer) 161 { 162 super(cast(GtkTextBuffer*)gtkSourceBuffer); 163 this.gtkSourceBuffer = gtkSourceBuffer; 164 } 165 166 protected override void setStruct(GObject* obj) 167 { 168 super.setStruct(obj); 169 gtkSourceBuffer = cast(GtkSourceBuffer*)obj; 170 } 171 172 /** 173 */ 174 int[string] connectedSignals; 175 176 void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer)[] onBracketMatchedListeners; 177 /** 178 * Sets iter to a valid iterator pointing to the matching bracket 179 * if state is GTK_SOURCE_BRACKET_MATCH_FOUND. Otherwise iter is 180 * meaningless. 181 * Since 2.12 182 */ 183 void addOnBracketMatched(void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 184 { 185 if ( !("bracket-matched" in connectedSignals) ) 186 { 187 Signals.connectData( 188 getStruct(), 189 "bracket-matched", 190 cast(GCallback)&callBackBracketMatched, 191 cast(void*)this, 192 null, 193 connectFlags); 194 connectedSignals["bracket-matched"] = 1; 195 } 196 onBracketMatchedListeners ~= dlg; 197 } 198 extern(C) static void callBackBracketMatched(GtkSourceBuffer* bufferStruct, GtkTextIter* iter, GtkSourceBracketMatchType state, SourceBuffer _sourceBuffer) 199 { 200 foreach ( void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg ; _sourceBuffer.onBracketMatchedListeners ) 201 { 202 dlg(ObjectG.getDObject!(TextIter)(iter), state, _sourceBuffer); 203 } 204 } 205 206 void delegate(TextIter, TextIter, SourceBuffer)[] onHighlightUpdatedListeners; 207 /** 208 */ 209 void addOnHighlightUpdated(void delegate(TextIter, TextIter, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 210 { 211 if ( !("highlight-updated" in connectedSignals) ) 212 { 213 Signals.connectData( 214 getStruct(), 215 "highlight-updated", 216 cast(GCallback)&callBackHighlightUpdated, 217 cast(void*)this, 218 null, 219 connectFlags); 220 connectedSignals["highlight-updated"] = 1; 221 } 222 onHighlightUpdatedListeners ~= dlg; 223 } 224 extern(C) static void callBackHighlightUpdated(GtkSourceBuffer* sourcebufferStruct, GtkTextIter* arg1, GtkTextIter* arg2, SourceBuffer _sourceBuffer) 225 { 226 foreach ( void delegate(TextIter, TextIter, SourceBuffer) dlg ; _sourceBuffer.onHighlightUpdatedListeners ) 227 { 228 dlg(ObjectG.getDObject!(TextIter)(arg1), ObjectG.getDObject!(TextIter)(arg2), _sourceBuffer); 229 } 230 } 231 232 void delegate(SourceBuffer)[] onRedoListeners; 233 /** 234 */ 235 void addOnRedo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 236 { 237 if ( !("redo" in connectedSignals) ) 238 { 239 Signals.connectData( 240 getStruct(), 241 "redo", 242 cast(GCallback)&callBackRedo, 243 cast(void*)this, 244 null, 245 connectFlags); 246 connectedSignals["redo"] = 1; 247 } 248 onRedoListeners ~= dlg; 249 } 250 extern(C) static void callBackRedo(GtkSourceBuffer* sourcebufferStruct, SourceBuffer _sourceBuffer) 251 { 252 foreach ( void delegate(SourceBuffer) dlg ; _sourceBuffer.onRedoListeners ) 253 { 254 dlg(_sourceBuffer); 255 } 256 } 257 258 void delegate(GtkTextMark*, SourceBuffer)[] onSourceMarkUpdatedListeners; 259 /** 260 * The ::source_mark_updated signal is emitted each time 261 * a mark is added to, moved or removed from the buffer. 262 */ 263 void addOnSourceMarkUpdated(void delegate(GtkTextMark*, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 264 { 265 if ( !("source-mark-updated" in connectedSignals) ) 266 { 267 Signals.connectData( 268 getStruct(), 269 "source-mark-updated", 270 cast(GCallback)&callBackSourceMarkUpdated, 271 cast(void*)this, 272 null, 273 connectFlags); 274 connectedSignals["source-mark-updated"] = 1; 275 } 276 onSourceMarkUpdatedListeners ~= dlg; 277 } 278 extern(C) static void callBackSourceMarkUpdated(GtkSourceBuffer* bufferStruct, GtkTextMark* mark, SourceBuffer _sourceBuffer) 279 { 280 foreach ( void delegate(GtkTextMark*, SourceBuffer) dlg ; _sourceBuffer.onSourceMarkUpdatedListeners ) 281 { 282 dlg(mark, _sourceBuffer); 283 } 284 } 285 286 void delegate(SourceBuffer)[] onUndoListeners; 287 /** 288 * See Also 289 * GtkTextBuffer, GtkSourceView 290 */ 291 void addOnUndo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 292 { 293 if ( !("undo" in connectedSignals) ) 294 { 295 Signals.connectData( 296 getStruct(), 297 "undo", 298 cast(GCallback)&callBackUndo, 299 cast(void*)this, 300 null, 301 connectFlags); 302 connectedSignals["undo"] = 1; 303 } 304 onUndoListeners ~= dlg; 305 } 306 extern(C) static void callBackUndo(GtkSourceBuffer* sourcebufferStruct, SourceBuffer _sourceBuffer) 307 { 308 foreach ( void delegate(SourceBuffer) dlg ; _sourceBuffer.onUndoListeners ) 309 { 310 dlg(_sourceBuffer); 311 } 312 } 313 314 315 /** 316 * Creates a new source buffer. 317 * Params: 318 * table = a GtkTextTagTable, or NULL to create a new one. [allow-none] 319 * Throws: ConstructionException GTK+ fails to create the object. 320 */ 321 public this (TextTagTable table) 322 { 323 // GtkSourceBuffer * gtk_source_buffer_new (GtkTextTagTable *table); 324 auto p = gtk_source_buffer_new((table is null) ? null : table.getTextTagTableStruct()); 325 if(p is null) 326 { 327 throw new ConstructionException("null returned by gtk_source_buffer_new((table is null) ? null : table.getTextTagTableStruct())"); 328 } 329 this(cast(GtkSourceBuffer*) p); 330 } 331 332 /** 333 * Creates a new source buffer using the highlighting patterns in 334 * language. This is equivalent to creating a new source buffer with 335 * a new tag table and then calling gtk_source_buffer_set_language(). 336 * Params: 337 * language = a GtkSourceLanguage. 338 * Throws: ConstructionException GTK+ fails to create the object. 339 */ 340 public this (SourceLanguage language) 341 { 342 // GtkSourceBuffer * gtk_source_buffer_new_with_language (GtkSourceLanguage *language); 343 auto p = gtk_source_buffer_new_with_language((language is null) ? null : language.getSourceLanguageStruct()); 344 if(p is null) 345 { 346 throw new ConstructionException("null returned by gtk_source_buffer_new_with_language((language is null) ? null : language.getSourceLanguageStruct())"); 347 } 348 this(cast(GtkSourceBuffer*) p); 349 } 350 351 /** 352 * Controls whether syntax is highlighted in the buffer. If highlight 353 * is TRUE, the text will be highlighted according to the syntax 354 * patterns specified in the language set with 355 * gtk_source_buffer_set_language(). If highlight is FALSE, syntax highlighting 356 * is disabled and all the GtkTextTag objects that have been added by the 357 * syntax highlighting engine are removed from the buffer. 358 * Params: 359 * highlight = TRUE to enable syntax highlighting, FALSE to disable it. 360 */ 361 public void setHighlightSyntax(int highlight) 362 { 363 // void gtk_source_buffer_set_highlight_syntax (GtkSourceBuffer *buffer, gboolean highlight); 364 gtk_source_buffer_set_highlight_syntax(gtkSourceBuffer, highlight); 365 } 366 367 /** 368 * Determines whether syntax highlighting is activated in the source 369 * buffer. 370 * Returns: TRUE if syntax highlighting is enabled, FALSE otherwise. 371 */ 372 public int getHighlightSyntax() 373 { 374 // gboolean gtk_source_buffer_get_highlight_syntax (GtkSourceBuffer *buffer); 375 return gtk_source_buffer_get_highlight_syntax(gtkSourceBuffer); 376 } 377 378 /** 379 * Associate a GtkSourceLanguage with the buffer. If language is 380 * not-NULL and syntax highlighting is enabled (see gtk_source_buffer_set_highlight_syntax()), 381 * the syntax patterns defined in language will be used to highlight the text 382 * contained in the buffer. If language is NULL, the text contained in the 383 * buffer is not highlighted. 384 * The buffer holds a reference to language. 385 * Params: 386 * language = a GtkSourceLanguage to set, or NULL. [allow-none] 387 */ 388 public void setLanguage(SourceLanguage language) 389 { 390 // void gtk_source_buffer_set_language (GtkSourceBuffer *buffer, GtkSourceLanguage *language); 391 gtk_source_buffer_set_language(gtkSourceBuffer, (language is null) ? null : language.getSourceLanguageStruct()); 392 } 393 394 /** 395 * Returns the GtkSourceLanguage associated with the buffer, 396 * see gtk_source_buffer_set_language(). The returned object should not be 397 * unreferenced by the user. 398 * Returns: the GtkSourceLanguage associated with the buffer, or NULL. [transfer none] 399 */ 400 public SourceLanguage getLanguage() 401 { 402 // GtkSourceLanguage * gtk_source_buffer_get_language (GtkSourceBuffer *buffer); 403 auto p = gtk_source_buffer_get_language(gtkSourceBuffer); 404 405 if(p is null) 406 { 407 return null; 408 } 409 410 return ObjectG.getDObject!(SourceLanguage)(cast(GtkSourceLanguage*) p); 411 } 412 413 /** 414 * Controls the bracket match highlighting function in the buffer. If 415 * activated, when you position your cursor over a bracket character 416 * (a parenthesis, a square bracket, etc.) the matching opening or 417 * closing bracket character will be highlighted. 418 * Params: 419 * highlight = TRUE if you want matching brackets highlighted. 420 */ 421 public void setHighlightMatchingBrackets(int highlight) 422 { 423 // void gtk_source_buffer_set_highlight_matching_brackets (GtkSourceBuffer *buffer, gboolean highlight); 424 gtk_source_buffer_set_highlight_matching_brackets(gtkSourceBuffer, highlight); 425 } 426 427 /** 428 * Determines whether bracket match highlighting is activated for the 429 * source buffer. 430 * Returns: TRUE if the source buffer will highlight matching brackets. 431 */ 432 public int getHighlightMatchingBrackets() 433 { 434 // gboolean gtk_source_buffer_get_highlight_matching_brackets (GtkSourceBuffer *buffer); 435 return gtk_source_buffer_get_highlight_matching_brackets(gtkSourceBuffer); 436 } 437 438 /** 439 * Sets style scheme used by the buffer. If scheme is NULL no 440 * style scheme is used. 441 * Params: 442 * scheme = a GtkSourceStyleScheme or NULL. [allow-none] 443 */ 444 public void setStyleScheme(SourceStyleScheme scheme) 445 { 446 // void gtk_source_buffer_set_style_scheme (GtkSourceBuffer *buffer, GtkSourceStyleScheme *scheme); 447 gtk_source_buffer_set_style_scheme(gtkSourceBuffer, (scheme is null) ? null : scheme.getSourceStyleSchemeStruct()); 448 } 449 450 /** 451 * Returns the GtkSourceStyleScheme associated with the buffer, 452 * see gtk_source_buffer_set_style_scheme(). 453 * The returned object should not be unreferenced by the user. 454 * Returns: the GtkSourceStyleScheme associated with the buffer, or NULL. [transfer none] 455 */ 456 public SourceStyleScheme getStyleScheme() 457 { 458 // GtkSourceStyleScheme * gtk_source_buffer_get_style_scheme (GtkSourceBuffer *buffer); 459 auto p = gtk_source_buffer_get_style_scheme(gtkSourceBuffer); 460 461 if(p is null) 462 { 463 return null; 464 } 465 466 return ObjectG.getDObject!(SourceStyleScheme)(cast(GtkSourceStyleScheme*) p); 467 } 468 469 /** 470 * Forces buffer to analyze and highlight the given area synchronously. 471 * Note 472 * This is a potentially slow operation and should be used only 473 * when you need to make sure that some text not currently 474 * visible is highlighted, for instance before printing. 475 * Params: 476 * start = start of the area to highlight. 477 * end = end of the area to highlight. 478 */ 479 public void ensureHighlight(TextIter start, TextIter end) 480 { 481 // void gtk_source_buffer_ensure_highlight (GtkSourceBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end); 482 gtk_source_buffer_ensure_highlight(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 483 } 484 485 /** 486 * Creates a source mark in the buffer of category category. A source mark is 487 * a GtkTextMark but organised into categories. Depending on the category 488 * a pixbuf can be specified that will be displayed along the line of the mark. 489 * Like a GtkTextMark, a GtkSourceMark can be anonymous if the 490 * passed name is NULL. Also, the buffer owns the marks so you 491 * shouldn't unreference it. 492 * Marks always have left gravity and are moved to the beginning of 493 * the line when the user deletes the line they were in. 494 * Typical uses for a source mark are bookmarks, breakpoints, current 495 * executing instruction indication in a source file, etc.. 496 * Since 2.2 497 * Params: 498 * name = the name of the mark, or NULL. [allow-none] 499 * category = a string defining the mark category. 500 * where = location to place the mark. 501 * Returns: a new GtkSourceMark, owned by the buffer. [transfer none] 502 */ 503 public SourceMark createSourceMark(string name, string category, TextIter where) 504 { 505 // GtkSourceMark * gtk_source_buffer_create_source_mark (GtkSourceBuffer *buffer, const gchar *name, const gchar *category, const GtkTextIter *where); 506 auto p = gtk_source_buffer_create_source_mark(gtkSourceBuffer, Str.toStringz(name), Str.toStringz(category), (where is null) ? null : where.getTextIterStruct()); 507 508 if(p is null) 509 { 510 return null; 511 } 512 513 return ObjectG.getDObject!(SourceMark)(cast(GtkSourceMark*) p); 514 } 515 516 /** 517 * Moves iter to the position of the next GtkSourceMark of the given 518 * category. Returns TRUE if iter was moved. If category is NULL, the 519 * next source mark can be of any category. 520 * Since 2.2 521 * Params: 522 * iter = an iterator. 523 * category = category to search for, or NULL. [allow-none] 524 * Returns: whether iter was moved. 525 */ 526 public int forwardIterToSourceMark(TextIter iter, string category) 527 { 528 // gboolean gtk_source_buffer_forward_iter_to_source_mark (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar *category); 529 return gtk_source_buffer_forward_iter_to_source_mark(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)); 530 } 531 532 /** 533 * Moves iter to the position of the previous GtkSourceMark of the given 534 * category. Returns TRUE if iter was moved. If category is NULL, the 535 * previous source mark can be of any category. 536 * Since 2.2 537 * Params: 538 * iter = an iterator. 539 * category = category to search for, or NULL. [allow-none] 540 * Returns: whether iter was moved. 541 */ 542 public int backwardIterToSourceMark(TextIter iter, string category) 543 { 544 // gboolean gtk_source_buffer_backward_iter_to_source_mark (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar *category); 545 return gtk_source_buffer_backward_iter_to_source_mark(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)); 546 } 547 548 /** 549 * Returns the list of marks of the given category at line. 550 * If category is NULL, all marks at line are returned. 551 * Since 2.2 552 * Params: 553 * line = a line number. 554 * category = category to search for, or NULL. [allow-none] 555 * Returns: a newly allocated GSList. [element-type GtkSource.Mark][transfer container] 556 */ 557 public ListSG getSourceMarksAtLine(int line, string category) 558 { 559 // GSList * gtk_source_buffer_get_source_marks_at_line (GtkSourceBuffer *buffer, gint line, const gchar *category); 560 auto p = gtk_source_buffer_get_source_marks_at_line(gtkSourceBuffer, line, Str.toStringz(category)); 561 562 if(p is null) 563 { 564 return null; 565 } 566 567 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 568 } 569 570 /** 571 * Returns the list of marks of the given category at iter. If category 572 * is NULL it returns all marks at iter. 573 * Since 2.2 574 * Params: 575 * iter = an iterator. 576 * category = category to search for, or NULL. [allow-none] 577 * Returns: a newly allocated GSList. [element-type GtkSource.Mark][transfer container] 578 */ 579 public ListSG getSourceMarksAtIter(TextIter iter, string category) 580 { 581 // GSList * gtk_source_buffer_get_source_marks_at_iter (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar *category); 582 auto p = gtk_source_buffer_get_source_marks_at_iter(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)); 583 584 if(p is null) 585 { 586 return null; 587 } 588 589 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 590 } 591 592 /** 593 * Remove all marks of category between start and end from the buffer. 594 * If category is NULL, all marks in the range will be removed. 595 * Since 2.2 596 * Params: 597 * start = a GtkTextIter. 598 * end = a GtkTextIter. 599 * category = category to search for, or NULL. [allow-none] 600 */ 601 public void removeSourceMarks(TextIter start, TextIter end, string category) 602 { 603 // void gtk_source_buffer_remove_source_marks (GtkSourceBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end, const gchar *category); 604 gtk_source_buffer_remove_source_marks(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), Str.toStringz(category)); 605 } 606 607 /** 608 * Check if the class context_class is set on iter. 609 * See the GtkSourceBuffer description for the list of context classes. 610 * Since 2.10 611 * Params: 612 * iter = a GtkTextIter. 613 * contextClass = class to search for. 614 * Returns: whether iter has the context class. 615 */ 616 public int iterHasContextClass(TextIter iter, string contextClass) 617 { 618 // gboolean gtk_source_buffer_iter_has_context_class (GtkSourceBuffer *buffer, const GtkTextIter *iter, const gchar *context_class); 619 return gtk_source_buffer_iter_has_context_class(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)); 620 } 621 622 /** 623 * Get all defined context classes at iter. 624 * See the GtkSourceBuffer description for the list of context classes. 625 * Since 2.10 626 * Params: 627 * iter = a GtkTextIter. 628 * Returns: a new NULL terminated array of context class names. Use g_strfreev() to free the array if it is no longer needed. [array zero-terminated=1][transfer full] 629 */ 630 public string[] getContextClassesAtIter(TextIter iter) 631 { 632 // gchar ** gtk_source_buffer_get_context_classes_at_iter (GtkSourceBuffer *buffer, const GtkTextIter *iter); 633 return Str.toStringArray(gtk_source_buffer_get_context_classes_at_iter(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct())); 634 } 635 636 /** 637 * Moves forward to the next toggle (on or off) of the context class. If no 638 * matching context class toggles are found, returns FALSE, otherwise TRUE. 639 * Does not return toggles located at iter, only toggles after iter. Sets 640 * iter to the location of the toggle, or to the end of the buffer if no 641 * toggle is found. 642 * See the GtkSourceBuffer description for the list of context classes. 643 * Since 2.10 644 * Params: 645 * iter = a GtkTextIter. 646 * contextClass = the context class. 647 * Returns: whether we found a context class toggle after iter 648 */ 649 public int iterForwardToContextClassToggle(TextIter iter, string contextClass) 650 { 651 // gboolean gtk_source_buffer_iter_forward_to_context_class_toggle (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar *context_class); 652 return gtk_source_buffer_iter_forward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)); 653 } 654 655 /** 656 * Moves backward to the next toggle (on or off) of the context class. If no 657 * matching context class toggles are found, returns FALSE, otherwise TRUE. 658 * Does not return toggles located at iter, only toggles after iter. Sets 659 * iter to the location of the toggle, or to the end of the buffer if no 660 * toggle is found. 661 * See the GtkSourceBuffer description for the list of context classes. 662 * Since 2.10 663 * Params: 664 * iter = a GtkTextIter. 665 * contextClass = the context class. 666 * Returns: whether we found a context class toggle before iter 667 */ 668 public int iterBackwardToContextClassToggle(TextIter iter, string contextClass) 669 { 670 // gboolean gtk_source_buffer_iter_backward_to_context_class_toggle (GtkSourceBuffer *buffer, GtkTextIter *iter, const gchar *context_class); 671 return gtk_source_buffer_iter_backward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)); 672 } 673 674 /** 675 * Determines the number of undo levels the buffer will track for 676 * buffer edits. 677 * Returns: the maximum number of possible undo levels or -1 if no limit is set. 678 */ 679 public int getMaxUndoLevels() 680 { 681 // gint gtk_source_buffer_get_max_undo_levels (GtkSourceBuffer *buffer); 682 return gtk_source_buffer_get_max_undo_levels(gtkSourceBuffer); 683 } 684 685 /** 686 * Sets the number of undo levels for user actions the buffer will 687 * track. If the number of user actions exceeds the limit set by this 688 * function, older actions will be discarded. 689 * If max_undo_levels is -1, no limit is set. 690 * Params: 691 * maxUndoLevels = the desired maximum number of undo levels. 692 */ 693 public void setMaxUndoLevels(int maxUndoLevels) 694 { 695 // void gtk_source_buffer_set_max_undo_levels (GtkSourceBuffer *buffer, gint max_undo_levels); 696 gtk_source_buffer_set_max_undo_levels(gtkSourceBuffer, maxUndoLevels); 697 } 698 699 /** 700 * Redoes the last undo operation. Use gtk_source_buffer_can_redo() 701 * to check whether a call to this function will have any effect. 702 */ 703 public void redo() 704 { 705 // void gtk_source_buffer_redo (GtkSourceBuffer *buffer); 706 gtk_source_buffer_redo(gtkSourceBuffer); 707 } 708 709 /** 710 * Undoes the last user action which modified the buffer. Use 711 * gtk_source_buffer_can_undo() to check whether a call to this 712 * function will have any effect. 713 */ 714 public void undo() 715 { 716 // void gtk_source_buffer_undo (GtkSourceBuffer *buffer); 717 gtk_source_buffer_undo(gtkSourceBuffer); 718 } 719 720 /** 721 * Determines whether a source buffer can redo the last action 722 * (i.e. if the last operation was an undo). 723 * Returns: TRUE if a redo is possible. 724 */ 725 public int canRedo() 726 { 727 // gboolean gtk_source_buffer_can_redo (GtkSourceBuffer *buffer); 728 return gtk_source_buffer_can_redo(gtkSourceBuffer); 729 } 730 731 /** 732 * Determines whether a source buffer can undo the last action. 733 * Returns: TRUE if it's possible to undo the last action. 734 */ 735 public int canUndo() 736 { 737 // gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer); 738 return gtk_source_buffer_can_undo(gtkSourceBuffer); 739 } 740 741 /** 742 * Marks the beginning of a not undoable action on the buffer, 743 * disabling the undo manager. Typically you would call this function 744 * before initially setting the contents of the buffer (e.g. when 745 * loading a file in a text editor). 746 * You may nest gtk_source_buffer_begin_not_undoable_action() / 747 * gtk_source_buffer_end_not_undoable_action() blocks. 748 */ 749 public void beginNotUndoableAction() 750 { 751 // void gtk_source_buffer_begin_not_undoable_action (GtkSourceBuffer *buffer); 752 gtk_source_buffer_begin_not_undoable_action(gtkSourceBuffer); 753 } 754 755 /** 756 * Marks the end of a not undoable action on the buffer. When the 757 * last not undoable block is closed through the call to this 758 * function, the list of undo actions is cleared and the undo manager 759 * is re-enabled. 760 */ 761 public void endNotUndoableAction() 762 { 763 // void gtk_source_buffer_end_not_undoable_action (GtkSourceBuffer *buffer); 764 gtk_source_buffer_end_not_undoable_action(gtkSourceBuffer); 765 } 766 767 /** 768 * Returns the GtkSourceUndoManager associated with the buffer, 769 * see gtk_source_buffer_set_undo_manager(). The returned object should not be 770 * unreferenced by the user. 771 * Returns: the GtkSourceUndoManager associated with the buffer, or NULL. [transfer none] 772 */ 773 public SourceUndoManagerIF getUndoManager() 774 { 775 // GtkSourceUndoManager * gtk_source_buffer_get_undo_manager (GtkSourceBuffer *buffer); 776 auto p = gtk_source_buffer_get_undo_manager(gtkSourceBuffer); 777 778 if(p is null) 779 { 780 return null; 781 } 782 783 return ObjectG.getDObject!(SourceUndoManager, SourceUndoManagerIF)(cast(GtkSourceUndoManager*) p); 784 } 785 786 /** 787 * Set the buffer undo manager. If manager is NULL the default undo manager 788 * will be set. 789 * Params: 790 * manager = A GtkSourceUndoManager or NULL. [allow-none] 791 */ 792 public void setUndoManager(SourceUndoManagerIF manager) 793 { 794 // void gtk_source_buffer_set_undo_manager (GtkSourceBuffer *buffer, GtkSourceUndoManager *manager); 795 gtk_source_buffer_set_undo_manager(gtkSourceBuffer, (manager is null) ? null : manager.getSourceUndoManagerTStruct()); 796 } 797 }