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 module gsv.SourceBuffer; 26 27 private import glib.ConstructionException; 28 private import glib.ListSG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.Signals; 32 private import gsv.SourceLanguage; 33 private import gsv.SourceMark; 34 private import gsv.SourceStyleScheme; 35 private import gsv.SourceUndoManager; 36 private import gsv.SourceUndoManagerIF; 37 private import gsvc.gsv; 38 public import gsvc.gsvtypes; 39 private import gtk.TextBuffer; 40 private import gtk.TextIter; 41 private import gtk.TextMark; 42 private import gtk.TextTag; 43 private import gtk.TextTagTable; 44 public import gtkc.gdktypes; 45 private import std.algorithm; 46 47 48 /** */ 49 public class SourceBuffer : TextBuffer 50 { 51 /** the main Gtk struct */ 52 protected GtkSourceBuffer* gtkSourceBuffer; 53 54 /** Get the main Gtk struct */ 55 public GtkSourceBuffer* getSourceBufferStruct() 56 { 57 return gtkSourceBuffer; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected override void* getStruct() 62 { 63 return cast(void*)gtkSourceBuffer; 64 } 65 66 protected override void setStruct(GObject* obj) 67 { 68 gtkSourceBuffer = cast(GtkSourceBuffer*)obj; 69 super.setStruct(obj); 70 } 71 72 /** 73 * Sets our main struct and passes it to the parent class. 74 */ 75 public this (GtkSourceBuffer* gtkSourceBuffer, bool ownedRef = false) 76 { 77 this.gtkSourceBuffer = gtkSourceBuffer; 78 super(cast(GtkTextBuffer*)gtkSourceBuffer, ownedRef); 79 } 80 81 82 /** */ 83 public static GType getType() 84 { 85 return gtk_source_buffer_get_type(); 86 } 87 88 /** 89 * Creates a new source buffer. 90 * 91 * Params: 92 * table = a #GtkTextTagTable, or %NULL to create a new one. 93 * 94 * Return: a new source buffer. 95 * 96 * Throws: ConstructionException GTK+ fails to create the object. 97 */ 98 public this(TextTagTable table) 99 { 100 auto p = gtk_source_buffer_new((table is null) ? null : table.getTextTagTableStruct()); 101 102 if(p is null) 103 { 104 throw new ConstructionException("null returned by new"); 105 } 106 107 this(cast(GtkSourceBuffer*) p, true); 108 } 109 110 /** 111 * Creates a new source buffer using the highlighting patterns in 112 * @language. This is equivalent to creating a new source buffer with 113 * a new tag table and then calling gtk_source_buffer_set_language(). 114 * 115 * Params: 116 * language = a #GtkSourceLanguage. 117 * 118 * Return: a new source buffer which will highlight text 119 * according to the highlighting patterns in @language. 120 * 121 * Throws: ConstructionException GTK+ fails to create the object. 122 */ 123 public this(SourceLanguage language) 124 { 125 auto p = gtk_source_buffer_new_with_language((language is null) ? null : language.getSourceLanguageStruct()); 126 127 if(p is null) 128 { 129 throw new ConstructionException("null returned by new_with_language"); 130 } 131 132 this(cast(GtkSourceBuffer*) p, true); 133 } 134 135 /** 136 * Moves @iter to the position of the previous #GtkSourceMark of the given 137 * category. Returns %TRUE if @iter was moved. If @category is NULL, the 138 * previous source mark can be of any category. 139 * 140 * Params: 141 * iter = an iterator. 142 * category = category to search for, or %NULL 143 * 144 * Return: whether @iter was moved. 145 * 146 * Since: 2.2 147 */ 148 public bool backwardIterToSourceMark(TextIter iter, string category) 149 { 150 return gtk_source_buffer_backward_iter_to_source_mark(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)) != 0; 151 } 152 153 /** 154 * Marks the beginning of a not undoable action on the buffer, 155 * disabling the undo manager. Typically you would call this function 156 * before initially setting the contents of the buffer (e.g. when 157 * loading a file in a text editor). 158 * 159 * You may nest gtk_source_buffer_begin_not_undoable_action() / 160 * gtk_source_buffer_end_not_undoable_action() blocks. 161 */ 162 public void beginNotUndoableAction() 163 { 164 gtk_source_buffer_begin_not_undoable_action(gtkSourceBuffer); 165 } 166 167 /** 168 * Determines whether a source buffer can redo the last action 169 * (i.e. if the last operation was an undo). 170 * 171 * Return: %TRUE if a redo is possible. 172 */ 173 public bool canRedo() 174 { 175 return gtk_source_buffer_can_redo(gtkSourceBuffer) != 0; 176 } 177 178 /** 179 * Determines whether a source buffer can undo the last action. 180 * 181 * Return: %TRUE if it's possible to undo the last action. 182 */ 183 public bool canUndo() 184 { 185 return gtk_source_buffer_can_undo(gtkSourceBuffer) != 0; 186 } 187 188 /** 189 * Changes the case of the text between the specified iterators. 190 * 191 * Params: 192 * caseType = how to change the case. 193 * start = a #GtkTextIter. 194 * end = a #GtkTextIter. 195 * 196 * Since: 3.12 197 */ 198 public void changeCase(GtkSourceChangeCaseType caseType, TextIter start, TextIter end) 199 { 200 gtk_source_buffer_change_case(gtkSourceBuffer, caseType, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 201 } 202 203 /** 204 * Creates a source mark in the @buffer of category @category. A source mark is 205 * a #GtkTextMark but organised into categories. Depending on the category 206 * a pixbuf can be specified that will be displayed along the line of the mark. 207 * 208 * Like a #GtkTextMark, a #GtkSourceMark can be anonymous if the 209 * passed @name is %NULL. Also, the buffer owns the marks so you 210 * shouldn't unreference it. 211 * 212 * Marks always have left gravity and are moved to the beginning of 213 * the line when the user deletes the line they were in. 214 * 215 * Typical uses for a source mark are bookmarks, breakpoints, current 216 * executing instruction indication in a source file, etc.. 217 * 218 * Params: 219 * name = the name of the mark, or %NULL. 220 * category = a string defining the mark category. 221 * where = location to place the mark. 222 * 223 * Return: a new #GtkSourceMark, owned by the buffer. 224 * 225 * Since: 2.2 226 */ 227 public SourceMark createSourceMark(string name, string category, TextIter where) 228 { 229 auto p = gtk_source_buffer_create_source_mark(gtkSourceBuffer, Str.toStringz(name), Str.toStringz(category), (where is null) ? null : where.getTextIterStruct()); 230 231 if(p is null) 232 { 233 return null; 234 } 235 236 return ObjectG.getDObject!(SourceMark)(cast(GtkSourceMark*) p); 237 } 238 239 /** 240 * Marks the end of a not undoable action on the buffer. When the 241 * last not undoable block is closed through the call to this 242 * function, the list of undo actions is cleared and the undo manager 243 * is re-enabled. 244 */ 245 public void endNotUndoableAction() 246 { 247 gtk_source_buffer_end_not_undoable_action(gtkSourceBuffer); 248 } 249 250 /** 251 * Forces buffer to analyze and highlight the given area synchronously. 252 * 253 * <note> 254 * <para> 255 * This is a potentially slow operation and should be used only 256 * when you need to make sure that some text not currently 257 * visible is highlighted, for instance before printing. 258 * </para> 259 * </note> 260 * 261 * Params: 262 * start = start of the area to highlight. 263 * end = end of the area to highlight. 264 */ 265 public void ensureHighlight(TextIter start, TextIter end) 266 { 267 gtk_source_buffer_ensure_highlight(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 268 } 269 270 /** 271 * Moves @iter to the position of the next #GtkSourceMark of the given 272 * @category. Returns %TRUE if @iter was moved. If @category is NULL, the 273 * next source mark can be of any category. 274 * 275 * Params: 276 * iter = an iterator. 277 * category = category to search for, or %NULL 278 * 279 * Return: whether @iter was moved. 280 * 281 * Since: 2.2 282 */ 283 public bool forwardIterToSourceMark(TextIter iter, string category) 284 { 285 return gtk_source_buffer_forward_iter_to_source_mark(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)) != 0; 286 } 287 288 /** 289 * Get all defined context classes at @iter. 290 * 291 * See the #GtkSourceBuffer description for the list of default context classes. 292 * 293 * Params: 294 * iter = a #GtkTextIter. 295 * 296 * Return: a new %NULL 297 * terminated array of context class names. 298 * Use g_strfreev() to free the array if it is no longer needed. 299 * 300 * Since: 2.10 301 */ 302 public string[] getContextClassesAtIter(TextIter iter) 303 { 304 auto retStr = gtk_source_buffer_get_context_classes_at_iter(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct()); 305 306 scope(exit) Str.freeStringArray(retStr); 307 return Str.toStringArray(retStr); 308 } 309 310 /** 311 * Determines whether bracket match highlighting is activated for the 312 * source buffer. 313 * 314 * Return: %TRUE if the source buffer will highlight matching 315 * brackets. 316 */ 317 public bool getHighlightMatchingBrackets() 318 { 319 return gtk_source_buffer_get_highlight_matching_brackets(gtkSourceBuffer) != 0; 320 } 321 322 /** 323 * Determines whether syntax highlighting is activated in the source 324 * buffer. 325 * 326 * Return: %TRUE if syntax highlighting is enabled, %FALSE otherwise. 327 */ 328 public bool getHighlightSyntax() 329 { 330 return gtk_source_buffer_get_highlight_syntax(gtkSourceBuffer) != 0; 331 } 332 333 /** 334 * Return: whether the @buffer has an implicit trailing newline. 335 * 336 * Since: 3.14 337 */ 338 public bool getImplicitTrailingNewline() 339 { 340 return gtk_source_buffer_get_implicit_trailing_newline(gtkSourceBuffer) != 0; 341 } 342 343 /** 344 * Returns the #GtkSourceLanguage associated with the buffer, 345 * see gtk_source_buffer_set_language(). The returned object should not be 346 * unreferenced by the user. 347 * 348 * Return: the #GtkSourceLanguage associated 349 * with the buffer, or %NULL. 350 */ 351 public SourceLanguage getLanguage() 352 { 353 auto p = gtk_source_buffer_get_language(gtkSourceBuffer); 354 355 if(p is null) 356 { 357 return null; 358 } 359 360 return ObjectG.getDObject!(SourceLanguage)(cast(GtkSourceLanguage*) p); 361 } 362 363 /** 364 * Determines the number of undo levels the buffer will track for buffer edits. 365 * 366 * Return: the maximum number of possible undo levels or -1 if no limit is set. 367 */ 368 public int getMaxUndoLevels() 369 { 370 return gtk_source_buffer_get_max_undo_levels(gtkSourceBuffer); 371 } 372 373 /** 374 * Returns the list of marks of the given category at @iter. If @category 375 * is %NULL it returns all marks at @iter. 376 * 377 * Params: 378 * iter = an iterator. 379 * category = category to search for, or %NULL 380 * 381 * Return: a newly allocated #GSList. 382 * 383 * Since: 2.2 384 */ 385 public ListSG getSourceMarksAtIter(TextIter iter, string category) 386 { 387 auto p = gtk_source_buffer_get_source_marks_at_iter(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(category)); 388 389 if(p is null) 390 { 391 return null; 392 } 393 394 return new ListSG(cast(GSList*) p); 395 } 396 397 /** 398 * Returns the list of marks of the given category at @line. 399 * If @category is %NULL, all marks at @line are returned. 400 * 401 * Params: 402 * line = a line number. 403 * category = category to search for, or %NULL 404 * 405 * Return: a newly allocated #GSList. 406 * 407 * Since: 2.2 408 */ 409 public ListSG getSourceMarksAtLine(int line, string category) 410 { 411 auto p = gtk_source_buffer_get_source_marks_at_line(gtkSourceBuffer, line, Str.toStringz(category)); 412 413 if(p is null) 414 { 415 return null; 416 } 417 418 return new ListSG(cast(GSList*) p); 419 } 420 421 /** 422 * Returns the #GtkSourceStyleScheme associated with the buffer, 423 * see gtk_source_buffer_set_style_scheme(). 424 * The returned object should not be unreferenced by the user. 425 * 426 * Return: the #GtkSourceStyleScheme 427 * associated with the buffer, or %NULL. 428 */ 429 public SourceStyleScheme getStyleScheme() 430 { 431 auto p = gtk_source_buffer_get_style_scheme(gtkSourceBuffer); 432 433 if(p is null) 434 { 435 return null; 436 } 437 438 return ObjectG.getDObject!(SourceStyleScheme)(cast(GtkSourceStyleScheme*) p); 439 } 440 441 /** 442 * Returns the #GtkSourceUndoManager associated with the buffer, 443 * see gtk_source_buffer_set_undo_manager(). The returned object should not be 444 * unreferenced by the user. 445 * 446 * Return: the #GtkSourceUndoManager associated 447 * with the buffer, or %NULL. 448 */ 449 public SourceUndoManagerIF getUndoManager() 450 { 451 auto p = gtk_source_buffer_get_undo_manager(gtkSourceBuffer); 452 453 if(p is null) 454 { 455 return null; 456 } 457 458 return ObjectG.getDObject!(SourceUndoManager, SourceUndoManagerIF)(cast(GtkSourceUndoManager*) p); 459 } 460 461 /** 462 * Moves backward to the next toggle (on or off) of the context class. If no 463 * matching context class toggles are found, returns %FALSE, otherwise %TRUE. 464 * Does not return toggles located at @iter, only toggles after @iter. Sets 465 * @iter to the location of the toggle, or to the end of the buffer if no 466 * toggle is found. 467 * 468 * See the #GtkSourceBuffer description for the list of default context classes. 469 * 470 * Params: 471 * iter = a #GtkTextIter. 472 * contextClass = the context class. 473 * 474 * Return: whether we found a context class toggle before @iter 475 * 476 * Since: 2.10 477 */ 478 public bool iterBackwardToContextClassToggle(TextIter iter, string contextClass) 479 { 480 return gtk_source_buffer_iter_backward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0; 481 } 482 483 /** 484 * Moves forward to the next toggle (on or off) of the context class. If no 485 * matching context class toggles are found, returns %FALSE, otherwise %TRUE. 486 * Does not return toggles located at @iter, only toggles after @iter. Sets 487 * @iter to the location of the toggle, or to the end of the buffer if no 488 * toggle is found. 489 * 490 * See the #GtkSourceBuffer description for the list of default context classes. 491 * 492 * Params: 493 * iter = a #GtkTextIter. 494 * contextClass = the context class. 495 * 496 * Return: whether we found a context class toggle after @iter 497 * 498 * Since: 2.10 499 */ 500 public bool iterForwardToContextClassToggle(TextIter iter, string contextClass) 501 { 502 return gtk_source_buffer_iter_forward_to_context_class_toggle(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0; 503 } 504 505 /** 506 * Check if the class @context_class is set on @iter. 507 * 508 * See the #GtkSourceBuffer description for the list of default context classes. 509 * 510 * Params: 511 * iter = a #GtkTextIter. 512 * contextClass = class to search for. 513 * 514 * Return: whether @iter has the context class. 515 * 516 * Since: 2.10 517 */ 518 public bool iterHasContextClass(TextIter iter, string contextClass) 519 { 520 return gtk_source_buffer_iter_has_context_class(gtkSourceBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(contextClass)) != 0; 521 } 522 523 /** 524 * Joins the lines of text between the specified iterators. 525 * 526 * Params: 527 * start = a #GtkTextIter. 528 * end = a #GtkTextIter. 529 * 530 * Since: 3.16 531 */ 532 public void joinLines(TextIter start, TextIter end) 533 { 534 gtk_source_buffer_join_lines(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 535 } 536 537 /** 538 * Redoes the last undo operation. Use gtk_source_buffer_can_redo() 539 * to check whether a call to this function will have any effect. 540 * 541 * This function emits the #GtkSourceBuffer::redo signal. 542 */ 543 public void redo() 544 { 545 gtk_source_buffer_redo(gtkSourceBuffer); 546 } 547 548 /** 549 * Remove all marks of @category between @start and @end from the buffer. 550 * If @category is NULL, all marks in the range will be removed. 551 * 552 * Params: 553 * start = a #GtkTextIter. 554 * end = a #GtkTextIter. 555 * category = category to search for, or %NULL. 556 * 557 * Since: 2.2 558 */ 559 public void removeSourceMarks(TextIter start, TextIter end, string category) 560 { 561 gtk_source_buffer_remove_source_marks(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), Str.toStringz(category)); 562 } 563 564 /** 565 * Controls the bracket match highlighting function in the buffer. If 566 * activated, when you position your cursor over a bracket character 567 * (a parenthesis, a square bracket, etc.) the matching opening or 568 * closing bracket character will be highlighted. 569 * 570 * Params: 571 * highlight = %TRUE if you want matching brackets highlighted. 572 */ 573 public void setHighlightMatchingBrackets(bool highlight) 574 { 575 gtk_source_buffer_set_highlight_matching_brackets(gtkSourceBuffer, highlight); 576 } 577 578 /** 579 * Controls whether syntax is highlighted in the buffer. 580 * 581 * If @highlight is %TRUE, the text will be highlighted according to the syntax 582 * patterns specified in the #GtkSourceLanguage set with 583 * gtk_source_buffer_set_language(). 584 * 585 * If @highlight is %FALSE, syntax highlighting is disabled and all the 586 * #GtkTextTag objects that have been added by the syntax highlighting engine 587 * are removed from the buffer. 588 * 589 * Params: 590 * highlight = %TRUE to enable syntax highlighting, %FALSE to disable it. 591 */ 592 public void setHighlightSyntax(bool highlight) 593 { 594 gtk_source_buffer_set_highlight_syntax(gtkSourceBuffer, highlight); 595 } 596 597 /** 598 * Sets whether the @buffer has an implicit trailing newline. 599 * 600 * If an explicit trailing newline is present in a #GtkTextBuffer, #GtkTextView 601 * shows it as an empty line. This is generally not what the user expects. 602 * 603 * If @implicit_trailing_newline is %TRUE (the default value): 604 * - when a #GtkSourceFileLoader loads the content of a file into the @buffer, 605 * the trailing newline (if present in the file) is not inserted into the 606 * @buffer. 607 * - when a #GtkSourceFileSaver saves the content of the @buffer into a file, a 608 * trailing newline is added to the file. 609 * 610 * On the other hand, if @implicit_trailing_newline is %FALSE, the file's 611 * content is not modified when loaded into the @buffer, and the @buffer's 612 * content is not modified when saved into a file. 613 * 614 * Params: 615 * implicitTrailingNewline = the new value. 616 * 617 * Since: 3.14 618 */ 619 public void setImplicitTrailingNewline(bool implicitTrailingNewline) 620 { 621 gtk_source_buffer_set_implicit_trailing_newline(gtkSourceBuffer, implicitTrailingNewline); 622 } 623 624 /** 625 * Associates a #GtkSourceLanguage with the buffer. 626 * 627 * Note that a #GtkSourceLanguage affects not only the syntax highlighting, but 628 * also the [context classes][context-classes]. If you want to disable just the 629 * syntax highlighting, see gtk_source_buffer_set_highlight_syntax(). 630 * 631 * The buffer holds a reference to @language. 632 * 633 * Params: 634 * language = a #GtkSourceLanguage to set, or %NULL. 635 */ 636 public void setLanguage(SourceLanguage language) 637 { 638 gtk_source_buffer_set_language(gtkSourceBuffer, (language is null) ? null : language.getSourceLanguageStruct()); 639 } 640 641 /** 642 * Sets the number of undo levels for user actions the buffer will 643 * track. If the number of user actions exceeds the limit set by this 644 * function, older actions will be discarded. 645 * 646 * If @max_undo_levels is -1, the undo/redo is unlimited. 647 * 648 * If @max_undo_levels is 0, the undo/redo is disabled. 649 * 650 * Params: 651 * maxUndoLevels = the desired maximum number of undo levels. 652 */ 653 public void setMaxUndoLevels(int maxUndoLevels) 654 { 655 gtk_source_buffer_set_max_undo_levels(gtkSourceBuffer, maxUndoLevels); 656 } 657 658 /** 659 * Sets a #GtkSourceStyleScheme to be used by the buffer and the view. 660 * 661 * Note that a #GtkSourceStyleScheme affects not only the syntax highlighting, 662 * but also other #GtkSourceView features such as highlighting the current line, 663 * matching brackets, the line numbers, etc. 664 * 665 * Instead of setting a %NULL @scheme, it is better to disable syntax 666 * highlighting with gtk_source_buffer_set_highlight_syntax(), and setting the 667 * #GtkSourceStyleScheme with the "classic" or "tango" ID, because those two 668 * style schemes follow more closely the GTK+ theme (for example for the 669 * background color). 670 * 671 * The buffer holds a reference to @scheme. 672 * 673 * Params: 674 * scheme = a #GtkSourceStyleScheme or %NULL. 675 */ 676 public void setStyleScheme(SourceStyleScheme scheme) 677 { 678 gtk_source_buffer_set_style_scheme(gtkSourceBuffer, (scheme is null) ? null : scheme.getSourceStyleSchemeStruct()); 679 } 680 681 /** 682 * Set the buffer undo manager. If @manager is %NULL the default undo manager 683 * will be set. 684 * 685 * Params: 686 * manager = A #GtkSourceUndoManager or %NULL. 687 */ 688 public void setUndoManager(SourceUndoManagerIF manager) 689 { 690 gtk_source_buffer_set_undo_manager(gtkSourceBuffer, (manager is null) ? null : manager.getSourceUndoManagerStruct()); 691 } 692 693 /** 694 * Sort the lines of text between the specified iterators. 695 * 696 * Params: 697 * start = a #GtkTextIter. 698 * end = a #GtkTextIter. 699 * flags = #GtkSourceSortFlags specifying how the sort should behave 700 * column = sort considering the text starting at the given column 701 * 702 * Since: 3.18 703 */ 704 public void sortLines(TextIter start, TextIter end, GtkSourceSortFlags flags, int column) 705 { 706 gtk_source_buffer_sort_lines(gtkSourceBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), flags, column); 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 * This function emits the #GtkSourceBuffer::undo signal. 715 */ 716 public void undo() 717 { 718 gtk_source_buffer_undo(gtkSourceBuffer); 719 } 720 721 protected class OnBracketMatchedDelegateWrapper 722 { 723 void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg; 724 gulong handlerId; 725 ConnectFlags flags; 726 this(void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg, gulong handlerId, ConnectFlags flags) 727 { 728 this.dlg = dlg; 729 this.handlerId = handlerId; 730 this.flags = flags; 731 } 732 } 733 protected OnBracketMatchedDelegateWrapper[] onBracketMatchedListeners; 734 735 /** 736 * @iter is set to a valid iterator pointing to the matching bracket 737 * if @state is %GTK_SOURCE_BRACKET_MATCH_FOUND. Otherwise @iter is 738 * meaningless. 739 * 740 * The signal is emitted only when the @state changes, typically when 741 * the cursor moves. 742 * 743 * A use-case for this signal is to show messages in a #GtkStatusbar. 744 * 745 * Params: 746 * iter = if found, the location of the matching bracket. 747 * state = state of bracket matching. 748 * 749 * Since: 2.12 750 */ 751 gulong addOnBracketMatched(void delegate(TextIter, GtkSourceBracketMatchType, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 752 { 753 onBracketMatchedListeners ~= new OnBracketMatchedDelegateWrapper(dlg, 0, connectFlags); 754 onBracketMatchedListeners[onBracketMatchedListeners.length - 1].handlerId = Signals.connectData( 755 this, 756 "bracket-matched", 757 cast(GCallback)&callBackBracketMatched, 758 cast(void*)onBracketMatchedListeners[onBracketMatchedListeners.length - 1], 759 cast(GClosureNotify)&callBackBracketMatchedDestroy, 760 connectFlags); 761 return onBracketMatchedListeners[onBracketMatchedListeners.length - 1].handlerId; 762 } 763 764 extern(C) static void callBackBracketMatched(GtkSourceBuffer* sourcebufferStruct, GtkTextIter* iter, GtkSourceBracketMatchType state,OnBracketMatchedDelegateWrapper wrapper) 765 { 766 wrapper.dlg(ObjectG.getDObject!(TextIter)(iter), state, wrapper.outer); 767 } 768 769 extern(C) static void callBackBracketMatchedDestroy(OnBracketMatchedDelegateWrapper wrapper, GClosure* closure) 770 { 771 wrapper.outer.internalRemoveOnBracketMatched(wrapper); 772 } 773 774 protected void internalRemoveOnBracketMatched(OnBracketMatchedDelegateWrapper source) 775 { 776 foreach(index, wrapper; onBracketMatchedListeners) 777 { 778 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 779 { 780 onBracketMatchedListeners[index] = null; 781 onBracketMatchedListeners = std.algorithm.remove(onBracketMatchedListeners, index); 782 break; 783 } 784 } 785 } 786 787 788 protected class OnHighlightUpdatedDelegateWrapper 789 { 790 void delegate(TextIter, TextIter, SourceBuffer) dlg; 791 gulong handlerId; 792 ConnectFlags flags; 793 this(void delegate(TextIter, TextIter, SourceBuffer) dlg, gulong handlerId, ConnectFlags flags) 794 { 795 this.dlg = dlg; 796 this.handlerId = handlerId; 797 this.flags = flags; 798 } 799 } 800 protected OnHighlightUpdatedDelegateWrapper[] onHighlightUpdatedListeners; 801 802 /** 803 * The ::highlight-updated signal is emitted when the syntax 804 * highlighting is updated in a certain region of the @buffer. This 805 * signal is useful to be notified when a context class region is 806 * updated (e.g. the no-spell-check context class). 807 * 808 * Params: 809 * start = the start of the updated region 810 * end = the end of the updated region 811 */ 812 gulong addOnHighlightUpdated(void delegate(TextIter, TextIter, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 813 { 814 onHighlightUpdatedListeners ~= new OnHighlightUpdatedDelegateWrapper(dlg, 0, connectFlags); 815 onHighlightUpdatedListeners[onHighlightUpdatedListeners.length - 1].handlerId = Signals.connectData( 816 this, 817 "highlight-updated", 818 cast(GCallback)&callBackHighlightUpdated, 819 cast(void*)onHighlightUpdatedListeners[onHighlightUpdatedListeners.length - 1], 820 cast(GClosureNotify)&callBackHighlightUpdatedDestroy, 821 connectFlags); 822 return onHighlightUpdatedListeners[onHighlightUpdatedListeners.length - 1].handlerId; 823 } 824 825 extern(C) static void callBackHighlightUpdated(GtkSourceBuffer* sourcebufferStruct, GtkTextIter* start, GtkTextIter* end,OnHighlightUpdatedDelegateWrapper wrapper) 826 { 827 wrapper.dlg(ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), wrapper.outer); 828 } 829 830 extern(C) static void callBackHighlightUpdatedDestroy(OnHighlightUpdatedDelegateWrapper wrapper, GClosure* closure) 831 { 832 wrapper.outer.internalRemoveOnHighlightUpdated(wrapper); 833 } 834 835 protected void internalRemoveOnHighlightUpdated(OnHighlightUpdatedDelegateWrapper source) 836 { 837 foreach(index, wrapper; onHighlightUpdatedListeners) 838 { 839 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 840 { 841 onHighlightUpdatedListeners[index] = null; 842 onHighlightUpdatedListeners = std.algorithm.remove(onHighlightUpdatedListeners, index); 843 break; 844 } 845 } 846 } 847 848 849 protected class OnRedoDelegateWrapper 850 { 851 void delegate(SourceBuffer) dlg; 852 gulong handlerId; 853 ConnectFlags flags; 854 this(void delegate(SourceBuffer) dlg, gulong handlerId, ConnectFlags flags) 855 { 856 this.dlg = dlg; 857 this.handlerId = handlerId; 858 this.flags = flags; 859 } 860 } 861 protected OnRedoDelegateWrapper[] onRedoListeners; 862 863 /** 864 * The ::redo signal is emitted to redo the last undo operation. 865 */ 866 gulong addOnRedo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 867 { 868 onRedoListeners ~= new OnRedoDelegateWrapper(dlg, 0, connectFlags); 869 onRedoListeners[onRedoListeners.length - 1].handlerId = Signals.connectData( 870 this, 871 "redo", 872 cast(GCallback)&callBackRedo, 873 cast(void*)onRedoListeners[onRedoListeners.length - 1], 874 cast(GClosureNotify)&callBackRedoDestroy, 875 connectFlags); 876 return onRedoListeners[onRedoListeners.length - 1].handlerId; 877 } 878 879 extern(C) static void callBackRedo(GtkSourceBuffer* sourcebufferStruct,OnRedoDelegateWrapper wrapper) 880 { 881 wrapper.dlg(wrapper.outer); 882 } 883 884 extern(C) static void callBackRedoDestroy(OnRedoDelegateWrapper wrapper, GClosure* closure) 885 { 886 wrapper.outer.internalRemoveOnRedo(wrapper); 887 } 888 889 protected void internalRemoveOnRedo(OnRedoDelegateWrapper source) 890 { 891 foreach(index, wrapper; onRedoListeners) 892 { 893 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 894 { 895 onRedoListeners[index] = null; 896 onRedoListeners = std.algorithm.remove(onRedoListeners, index); 897 break; 898 } 899 } 900 } 901 902 903 protected class OnSourceMarkUpdatedDelegateWrapper 904 { 905 void delegate(TextMark, SourceBuffer) dlg; 906 gulong handlerId; 907 ConnectFlags flags; 908 this(void delegate(TextMark, SourceBuffer) dlg, gulong handlerId, ConnectFlags flags) 909 { 910 this.dlg = dlg; 911 this.handlerId = handlerId; 912 this.flags = flags; 913 } 914 } 915 protected OnSourceMarkUpdatedDelegateWrapper[] onSourceMarkUpdatedListeners; 916 917 /** 918 * The ::source-mark-updated signal is emitted each time 919 * a mark is added to, moved or removed from the @buffer. 920 * 921 * Params: 922 * mark = the #GtkSourceMark 923 */ 924 gulong addOnSourceMarkUpdated(void delegate(TextMark, SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 925 { 926 onSourceMarkUpdatedListeners ~= new OnSourceMarkUpdatedDelegateWrapper(dlg, 0, connectFlags); 927 onSourceMarkUpdatedListeners[onSourceMarkUpdatedListeners.length - 1].handlerId = Signals.connectData( 928 this, 929 "source-mark-updated", 930 cast(GCallback)&callBackSourceMarkUpdated, 931 cast(void*)onSourceMarkUpdatedListeners[onSourceMarkUpdatedListeners.length - 1], 932 cast(GClosureNotify)&callBackSourceMarkUpdatedDestroy, 933 connectFlags); 934 return onSourceMarkUpdatedListeners[onSourceMarkUpdatedListeners.length - 1].handlerId; 935 } 936 937 extern(C) static void callBackSourceMarkUpdated(GtkSourceBuffer* sourcebufferStruct, GtkTextMark* mark,OnSourceMarkUpdatedDelegateWrapper wrapper) 938 { 939 wrapper.dlg(ObjectG.getDObject!(TextMark)(mark), wrapper.outer); 940 } 941 942 extern(C) static void callBackSourceMarkUpdatedDestroy(OnSourceMarkUpdatedDelegateWrapper wrapper, GClosure* closure) 943 { 944 wrapper.outer.internalRemoveOnSourceMarkUpdated(wrapper); 945 } 946 947 protected void internalRemoveOnSourceMarkUpdated(OnSourceMarkUpdatedDelegateWrapper source) 948 { 949 foreach(index, wrapper; onSourceMarkUpdatedListeners) 950 { 951 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 952 { 953 onSourceMarkUpdatedListeners[index] = null; 954 onSourceMarkUpdatedListeners = std.algorithm.remove(onSourceMarkUpdatedListeners, index); 955 break; 956 } 957 } 958 } 959 960 961 protected class OnUndoDelegateWrapper 962 { 963 void delegate(SourceBuffer) dlg; 964 gulong handlerId; 965 ConnectFlags flags; 966 this(void delegate(SourceBuffer) dlg, gulong handlerId, ConnectFlags flags) 967 { 968 this.dlg = dlg; 969 this.handlerId = handlerId; 970 this.flags = flags; 971 } 972 } 973 protected OnUndoDelegateWrapper[] onUndoListeners; 974 975 /** 976 * The ::undo signal is emitted to undo the last user action which 977 * modified the buffer. 978 */ 979 gulong addOnUndo(void delegate(SourceBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 980 { 981 onUndoListeners ~= new OnUndoDelegateWrapper(dlg, 0, connectFlags); 982 onUndoListeners[onUndoListeners.length - 1].handlerId = Signals.connectData( 983 this, 984 "undo", 985 cast(GCallback)&callBackUndo, 986 cast(void*)onUndoListeners[onUndoListeners.length - 1], 987 cast(GClosureNotify)&callBackUndoDestroy, 988 connectFlags); 989 return onUndoListeners[onUndoListeners.length - 1].handlerId; 990 } 991 992 extern(C) static void callBackUndo(GtkSourceBuffer* sourcebufferStruct,OnUndoDelegateWrapper wrapper) 993 { 994 wrapper.dlg(wrapper.outer); 995 } 996 997 extern(C) static void callBackUndoDestroy(OnUndoDelegateWrapper wrapper, GClosure* closure) 998 { 999 wrapper.outer.internalRemoveOnUndo(wrapper); 1000 } 1001 1002 protected void internalRemoveOnUndo(OnUndoDelegateWrapper source) 1003 { 1004 foreach(index, wrapper; onUndoListeners) 1005 { 1006 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1007 { 1008 onUndoListeners[index] = null; 1009 onUndoListeners = std.algorithm.remove(onUndoListeners, index); 1010 break; 1011 } 1012 } 1013 } 1014 1015 }