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.SourceView; 26 27 private import gdk.Event; 28 private import glib.ConstructionException; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.Signals; 32 private import gsv.SourceBuffer; 33 private import gsv.SourceCompletion; 34 private import gsv.SourceGutter; 35 private import gsv.SourceMarkAttributes; 36 private import gsvc.gsv; 37 public import gsvc.gsvtypes; 38 private import gtk.BuildableIF; 39 private import gtk.BuildableT; 40 private import gtk.ScrollableIF; 41 private import gtk.ScrollableT; 42 private import gtk.TextIter; 43 private import gtk.TextView; 44 private import gtk.Widget; 45 public import gtkc.gdktypes; 46 47 48 public class SourceView : TextView 49 { 50 /** the main Gtk struct */ 51 protected GtkSourceView* gtkSourceView; 52 53 /** Get the main Gtk struct */ 54 public GtkSourceView* getSourceViewStruct() 55 { 56 return gtkSourceView; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)gtkSourceView; 63 } 64 65 protected override void setStruct(GObject* obj) 66 { 67 gtkSourceView = cast(GtkSourceView*)obj; 68 super.setStruct(obj); 69 } 70 71 /** 72 * Sets our main struct and passes it to the parent class. 73 */ 74 public this (GtkSourceView* gtkSourceView, bool ownedRef = false) 75 { 76 this.gtkSourceView = gtkSourceView; 77 super(cast(GtkTextView*)gtkSourceView, ownedRef); 78 } 79 80 /** 81 * Returns the GtkSourceBuffer being displayed by this source view. 82 * The reference count on the buffer is not incremented; the caller 83 * of this function won't own a new reference. 84 * 85 * Returns: 86 * a GtkSourceBuffer 87 */ 88 public override SourceBuffer getBuffer() 89 { 90 auto p = gtk_text_view_get_buffer(cast(GtkTextView*)gtkSourceView); 91 92 return ObjectG.getDObject!(SourceBuffer)(cast(GtkSourceBuffer*) p); 93 } 94 95 /** 96 */ 97 98 public static GType getType() 99 { 100 return gtk_source_view_get_type(); 101 } 102 103 /** 104 * Creates a new #GtkSourceView. An empty default #GtkSourceBuffer will be 105 * created for you and can be retrieved with gtk_text_view_get_buffer(). If you 106 * want to specify your own buffer, consider gtk_source_view_new_with_buffer(). 107 * 108 * Return: a new #GtkSourceView. 109 * 110 * Throws: ConstructionException GTK+ fails to create the object. 111 */ 112 public this() 113 { 114 auto p = gtk_source_view_new(); 115 116 if(p is null) 117 { 118 throw new ConstructionException("null returned by new"); 119 } 120 121 this(cast(GtkSourceView*) p); 122 } 123 124 /** 125 * Creates a new #GtkSourceView widget displaying the buffer 126 * @buffer. One buffer can be shared among many widgets. 127 * 128 * Params: 129 * buffer = a #GtkSourceBuffer. 130 * 131 * Return: a new #GtkSourceView. 132 * 133 * Throws: ConstructionException GTK+ fails to create the object. 134 */ 135 public this(SourceBuffer buffer) 136 { 137 auto p = gtk_source_view_new_with_buffer((buffer is null) ? null : buffer.getSourceBufferStruct()); 138 139 if(p is null) 140 { 141 throw new ConstructionException("null returned by new_with_buffer"); 142 } 143 144 this(cast(GtkSourceView*) p); 145 } 146 147 /** 148 * Returns whether auto-indentation of text is enabled. 149 * 150 * Return: %TRUE if auto indentation is enabled. 151 */ 152 public bool getAutoIndent() 153 { 154 return gtk_source_view_get_auto_indent(gtkSourceView) != 0; 155 } 156 157 /** 158 * Returns the #GtkSourceBackgroundPatternType specifying if and how 159 * the background pattern should be displayed for this @view. 160 * 161 * Return: the #GtkSourceBackgroundPatternType. 162 * 163 * Since: 3.16 164 */ 165 public GtkSourceBackgroundPatternType getBackgroundPattern() 166 { 167 return gtk_source_view_get_background_pattern(gtkSourceView); 168 } 169 170 /** 171 * Gets the #GtkSourceCompletion associated with @view. 172 * 173 * Return: the #GtkSourceCompletion associated with @view. 174 */ 175 public SourceCompletion getCompletion() 176 { 177 auto p = gtk_source_view_get_completion(gtkSourceView); 178 179 if(p is null) 180 { 181 return null; 182 } 183 184 return ObjectG.getDObject!(SourceCompletion)(cast(GtkSourceCompletion*) p); 185 } 186 187 /** 188 * Returns the #GtkSourceDrawSpacesFlags specifying if and how spaces 189 * should be displayed for this @view. 190 * 191 * Return: the #GtkSourceDrawSpacesFlags, 0 if no spaces should be drawn. 192 */ 193 public GtkSourceDrawSpacesFlags getDrawSpaces() 194 { 195 return gtk_source_view_get_draw_spaces(gtkSourceView); 196 } 197 198 /** 199 * Returns the #GtkSourceGutter object associated with @window_type for @view. 200 * Only GTK_TEXT_WINDOW_LEFT and GTK_TEXT_WINDOW_RIGHT are supported, 201 * respectively corresponding to the left and right gutter. The line numbers 202 * and mark category icons are rendered in the left gutter. 203 * 204 * Params: 205 * windowType = the gutter window type. 206 * 207 * Return: the #GtkSourceGutter. 208 * 209 * Since: 2.8 210 */ 211 public SourceGutter getGutter(GtkTextWindowType windowType) 212 { 213 auto p = gtk_source_view_get_gutter(gtkSourceView, windowType); 214 215 if(p is null) 216 { 217 return null; 218 } 219 220 return ObjectG.getDObject!(SourceGutter)(cast(GtkSourceGutter*) p); 221 } 222 223 /** 224 * Returns whether the current line is highlighted. 225 * 226 * Return: %TRUE if the current line is highlighted. 227 */ 228 public bool getHighlightCurrentLine() 229 { 230 return gtk_source_view_get_highlight_current_line(gtkSourceView) != 0; 231 } 232 233 /** 234 * Returns whether when the tab key is pressed the current selection 235 * should get indented instead of replaced with the \t character. 236 * 237 * Return: %TRUE if the selection is indented when tab is pressed. 238 * 239 * Since: 1.8 240 */ 241 public bool getIndentOnTab() 242 { 243 return gtk_source_view_get_indent_on_tab(gtkSourceView) != 0; 244 } 245 246 /** 247 * Returns the number of spaces to use for each step of indent. 248 * See gtk_source_view_set_indent_width() for details. 249 * 250 * Return: indent width. 251 */ 252 public int getIndentWidth() 253 { 254 return gtk_source_view_get_indent_width(gtkSourceView); 255 } 256 257 /** 258 * Returns whether when inserting a tabulator character it should 259 * be replaced by a group of space characters. 260 * 261 * Return: %TRUE if spaces are inserted instead of tabs. 262 */ 263 public bool getInsertSpacesInsteadOfTabs() 264 { 265 return gtk_source_view_get_insert_spaces_instead_of_tabs(gtkSourceView) != 0; 266 } 267 268 /** 269 * Gets attributes and priority for the @category. 270 * 271 * Params: 272 * category = the category. 273 * priority = place where priority of the category will be stored. 274 * 275 * Return: #GtkSourceMarkAttributes for the @category. 276 * The object belongs to @view, so it must not be unreffed. 277 */ 278 public SourceMarkAttributes getMarkAttributes(string category, int* priority) 279 { 280 auto p = gtk_source_view_get_mark_attributes(gtkSourceView, Str.toStringz(category), priority); 281 282 if(p is null) 283 { 284 return null; 285 } 286 287 return ObjectG.getDObject!(SourceMarkAttributes)(cast(GtkSourceMarkAttributes*) p); 288 } 289 290 /** 291 * Gets the position of the right margin in the given @view. 292 * 293 * Return: the position of the right margin. 294 */ 295 public uint getRightMarginPosition() 296 { 297 return gtk_source_view_get_right_margin_position(gtkSourceView); 298 } 299 300 /** 301 * Returns whether line marks are displayed beside the text. 302 * 303 * Return: %TRUE if the line marks are displayed. 304 * 305 * Since: 2.2 306 */ 307 public bool getShowLineMarks() 308 { 309 return gtk_source_view_get_show_line_marks(gtkSourceView) != 0; 310 } 311 312 /** 313 * Returns whether line numbers are displayed beside the text. 314 * 315 * Return: %TRUE if the line numbers are displayed. 316 */ 317 public bool getShowLineNumbers() 318 { 319 return gtk_source_view_get_show_line_numbers(gtkSourceView) != 0; 320 } 321 322 /** 323 * Returns whether a right margin is displayed. 324 * 325 * Return: %TRUE if the right margin is shown. 326 */ 327 public bool getShowRightMargin() 328 { 329 return gtk_source_view_get_show_right_margin(gtkSourceView) != 0; 330 } 331 332 /** 333 * Returns a #GtkSourceSmartHomeEndType end value specifying 334 * how the cursor will move when HOME and END keys are pressed. 335 * 336 * Return: a #GtkSourceSmartHomeEndType value. 337 */ 338 public GtkSourceSmartHomeEndType getSmartHomeEnd() 339 { 340 return gtk_source_view_get_smart_home_end(gtkSourceView); 341 } 342 343 /** 344 * Returns the width of tabulation in characters. 345 * 346 * Return: width of tab. 347 */ 348 public uint getTabWidth() 349 { 350 return gtk_source_view_get_tab_width(gtkSourceView); 351 } 352 353 /** 354 * Determines the visual column at @iter taking into consideration the 355 * #GtkSourceView:tab-width of @view. 356 * 357 * Params: 358 * iter = a position in @view. 359 * 360 * Return: the visual column at @iter. 361 */ 362 public uint getVisualColumn(TextIter iter) 363 { 364 return gtk_source_view_get_visual_column(gtkSourceView, (iter is null) ? null : iter.getTextIterStruct()); 365 } 366 367 /** 368 * Insert one indentation level at the beginning of the 369 * specified lines. 370 * 371 * Params: 372 * start = #GtkTextIter of the first line to indent 373 * end = #GtkTextIter of the last line to indent 374 * 375 * Since: 3.16 376 */ 377 public void indentLines(TextIter start, TextIter end) 378 { 379 gtk_source_view_indent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 380 } 381 382 /** 383 * If %TRUE auto-indentation of text is enabled. 384 * 385 * When Enter is pressed to create a new line, the auto-indentation inserts the 386 * same indentation as the previous line. This is <emphasis>not</emphasis> a 387 * "smart indentation" where an indentation level is added or removed depending 388 * on the context. 389 * 390 * Params: 391 * enable = whether to enable auto indentation. 392 */ 393 public void setAutoIndent(bool enable) 394 { 395 gtk_source_view_set_auto_indent(gtkSourceView, enable); 396 } 397 398 /** 399 * Set if and how the background pattern should be displayed. 400 * 401 * Params: 402 * backgroundPattern = the #GtkSourceBackgroundPatternType. 403 * 404 * Since: 3.16 405 */ 406 public void setBackgroundPattern(GtkSourceBackgroundPatternType backgroundPattern) 407 { 408 gtk_source_view_set_background_pattern(gtkSourceView, backgroundPattern); 409 } 410 411 /** 412 * Set if and how the spaces should be visualized. Specifying @flags as 0 will 413 * disable display of spaces. 414 * 415 * Params: 416 * flags = #GtkSourceDrawSpacesFlags specifing how white spaces should 417 * be displayed 418 */ 419 public void setDrawSpaces(GtkSourceDrawSpacesFlags flags) 420 { 421 gtk_source_view_set_draw_spaces(gtkSourceView, flags); 422 } 423 424 /** 425 * If @highlight is %TRUE the current line will be highlighted. 426 * 427 * Params: 428 * highlight = whether to highlight the current line. 429 */ 430 public void setHighlightCurrentLine(bool highlight) 431 { 432 gtk_source_view_set_highlight_current_line(gtkSourceView, highlight); 433 } 434 435 /** 436 * If %TRUE, when the tab key is pressed when several lines are selected, the 437 * selected lines are indented of one level instead of being replaced with a \t 438 * character. Shift+Tab unindents the selection. 439 * 440 * If the first or last line is not selected completely, it is also indented or 441 * unindented. 442 * 443 * When the selection doesn't span several lines, the tab key always replaces 444 * the selection with a normal \t character. 445 * 446 * Params: 447 * enable = whether to indent a block when tab is pressed. 448 * 449 * Since: 1.8 450 */ 451 public void setIndentOnTab(bool enable) 452 { 453 gtk_source_view_set_indent_on_tab(gtkSourceView, enable); 454 } 455 456 /** 457 * Sets the number of spaces to use for each step of indent when the tab key is 458 * pressed. If @width is -1, the value of the #GtkSourceView:tab-width property 459 * will be used. 460 * 461 * The #GtkSourceView:indent-width interacts with the 462 * #GtkSourceView:insert-spaces-instead-of-tabs property and 463 * #GtkSourceView:tab-width. An example will be clearer: if the 464 * #GtkSourceView:indent-width is 4 and 465 * #GtkSourceView:tab-width is 8 and 466 * #GtkSourceView:insert-spaces-instead-of-tabs is %FALSE, then pressing the tab 467 * key at the beginning of a line will insert 4 spaces. So far so good. Pressing 468 * the tab key a second time will remove the 4 spaces and insert a \t character 469 * instead (since #GtkSourceView:tab-width is 8). On the other hand, if 470 * #GtkSourceView:insert-spaces-instead-of-tabs is %TRUE, the second tab key 471 * pressed will insert 4 more spaces for a total of 8 spaces in the 472 * #GtkTextBuffer. 473 * 474 * The test-widget program (available in the GtkSourceView repository) may be 475 * useful to better understand the indentation settings (enable the space 476 * drawing!). 477 * 478 * Params: 479 * width = indent width in characters. 480 */ 481 public void setIndentWidth(int width) 482 { 483 gtk_source_view_set_indent_width(gtkSourceView, width); 484 } 485 486 /** 487 * If %TRUE a tab key pressed is replaced by a group of space characters. Of 488 * course it is still possible to insert a real \t programmatically with the 489 * #GtkTextBuffer API. 490 * 491 * Params: 492 * enable = whether to insert spaces instead of tabs. 493 */ 494 public void setInsertSpacesInsteadOfTabs(bool enable) 495 { 496 gtk_source_view_set_insert_spaces_instead_of_tabs(gtkSourceView, enable); 497 } 498 499 /** 500 * Sets attributes and priority for the @category. 501 * 502 * Params: 503 * category = the category. 504 * attributes = mark attributes. 505 * priority = priority of the category. 506 */ 507 public void setMarkAttributes(string category, SourceMarkAttributes attributes, int priority) 508 { 509 gtk_source_view_set_mark_attributes(gtkSourceView, Str.toStringz(category), (attributes is null) ? null : attributes.getSourceMarkAttributesStruct(), priority); 510 } 511 512 /** 513 * Sets the position of the right margin in the given @view. 514 * 515 * Params: 516 * pos = the width in characters where to position the right margin. 517 */ 518 public void setRightMarginPosition(uint pos) 519 { 520 gtk_source_view_set_right_margin_position(gtkSourceView, pos); 521 } 522 523 /** 524 * If %TRUE line marks will be displayed beside the text. 525 * 526 * Params: 527 * show = whether line marks should be displayed. 528 * 529 * Since: 2.2 530 */ 531 public void setShowLineMarks(bool show) 532 { 533 gtk_source_view_set_show_line_marks(gtkSourceView, show); 534 } 535 536 /** 537 * If %TRUE line numbers will be displayed beside the text. 538 * 539 * Params: 540 * show = whether line numbers should be displayed. 541 */ 542 public void setShowLineNumbers(bool show) 543 { 544 gtk_source_view_set_show_line_numbers(gtkSourceView, show); 545 } 546 547 /** 548 * If %TRUE a right margin is displayed. 549 * 550 * Params: 551 * show = whether to show a right margin. 552 */ 553 public void setShowRightMargin(bool show) 554 { 555 gtk_source_view_set_show_right_margin(gtkSourceView, show); 556 } 557 558 /** 559 * Set the desired movement of the cursor when HOME and END keys 560 * are pressed. 561 * 562 * Params: 563 * smartHomeEnd = the desired behavior among #GtkSourceSmartHomeEndType. 564 */ 565 public void setSmartHomeEnd(GtkSourceSmartHomeEndType smartHomeEnd) 566 { 567 gtk_source_view_set_smart_home_end(gtkSourceView, smartHomeEnd); 568 } 569 570 /** 571 * Sets the width of tabulation in characters. The #GtkTextBuffer still contains 572 * \t characters, but they can take a different visual width in a #GtkSourceView 573 * widget. 574 * 575 * Params: 576 * width = width of tab in characters. 577 */ 578 public void setTabWidth(uint width) 579 { 580 gtk_source_view_set_tab_width(gtkSourceView, width); 581 } 582 583 /** 584 * Removes one indentation level at the beginning of the 585 * specified lines. 586 * 587 * Params: 588 * start = #GtkTextIter of the first line to indent 589 * end = #GtkTextIter of the last line to indent 590 * 591 * Since: 3.16 592 */ 593 public void unindentLines(TextIter start, TextIter end) 594 { 595 gtk_source_view_unindent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 596 } 597 598 int[string] connectedSignals; 599 600 void delegate(GtkSourceChangeCaseType, SourceView)[] onChangeCaseListeners; 601 /** 602 * Keybinding signal to change case of the text at the current cursor position. 603 * 604 * Params: 605 * caseType = the case to use 606 * 607 * Since: 3.16 608 */ 609 void addOnChangeCase(void delegate(GtkSourceChangeCaseType, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 610 { 611 if ( "change-case" !in connectedSignals ) 612 { 613 Signals.connectData( 614 this, 615 "change-case", 616 cast(GCallback)&callBackChangeCase, 617 cast(void*)this, 618 null, 619 connectFlags); 620 connectedSignals["change-case"] = 1; 621 } 622 onChangeCaseListeners ~= dlg; 623 } 624 extern(C) static void callBackChangeCase(GtkSourceView* sourceviewStruct, GtkSourceChangeCaseType caseType, SourceView _sourceview) 625 { 626 foreach ( void delegate(GtkSourceChangeCaseType, SourceView) dlg; _sourceview.onChangeCaseListeners ) 627 { 628 dlg(caseType, _sourceview); 629 } 630 } 631 632 void delegate(int, SourceView)[] onChangeNumberListeners; 633 /** 634 * Keybinding signal to edit a number at the current cursor position. 635 * 636 * Params: 637 * count = the number to add to the number at the current position 638 * 639 * Since: 3.16 640 */ 641 void addOnChangeNumber(void delegate(int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 642 { 643 if ( "change-number" !in connectedSignals ) 644 { 645 Signals.connectData( 646 this, 647 "change-number", 648 cast(GCallback)&callBackChangeNumber, 649 cast(void*)this, 650 null, 651 connectFlags); 652 connectedSignals["change-number"] = 1; 653 } 654 onChangeNumberListeners ~= dlg; 655 } 656 extern(C) static void callBackChangeNumber(GtkSourceView* sourceviewStruct, int count, SourceView _sourceview) 657 { 658 foreach ( void delegate(int, SourceView) dlg; _sourceview.onChangeNumberListeners ) 659 { 660 dlg(count, _sourceview); 661 } 662 } 663 664 void delegate(SourceView)[] onJoinLinesListeners; 665 /** 666 * Keybinding signal to join the lines currently selected. 667 * 668 * Since: 3.16 669 */ 670 void addOnJoinLines(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 671 { 672 if ( "join-lines" !in connectedSignals ) 673 { 674 Signals.connectData( 675 this, 676 "join-lines", 677 cast(GCallback)&callBackJoinLines, 678 cast(void*)this, 679 null, 680 connectFlags); 681 connectedSignals["join-lines"] = 1; 682 } 683 onJoinLinesListeners ~= dlg; 684 } 685 extern(C) static void callBackJoinLines(GtkSourceView* sourceviewStruct, SourceView _sourceview) 686 { 687 foreach ( void delegate(SourceView) dlg; _sourceview.onJoinLinesListeners ) 688 { 689 dlg(_sourceview); 690 } 691 } 692 693 void delegate(TextIter, Event, SourceView)[] onLineMarkActivatedListeners; 694 /** 695 * Emitted when a line mark has been activated (for instance when there 696 * was a button press in the line marks gutter). You can use @iter to 697 * determine on which line the activation took place. 698 * 699 * Params: 700 * iter = a #GtkTextIter 701 * event = the #GdkEvent that activated the event 702 */ 703 void addOnLineMarkActivated(void delegate(TextIter, Event, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 704 { 705 if ( "line-mark-activated" !in connectedSignals ) 706 { 707 Signals.connectData( 708 this, 709 "line-mark-activated", 710 cast(GCallback)&callBackLineMarkActivated, 711 cast(void*)this, 712 null, 713 connectFlags); 714 connectedSignals["line-mark-activated"] = 1; 715 } 716 onLineMarkActivatedListeners ~= dlg; 717 } 718 extern(C) static void callBackLineMarkActivated(GtkSourceView* sourceviewStruct, GtkTextIter* iter, GdkEvent* event, SourceView _sourceview) 719 { 720 foreach ( void delegate(TextIter, Event, SourceView) dlg; _sourceview.onLineMarkActivatedListeners ) 721 { 722 dlg(ObjectG.getDObject!(TextIter)(iter), ObjectG.getDObject!(Event)(event), _sourceview); 723 } 724 } 725 726 void delegate(bool, int, SourceView)[] onMoveLinesListeners; 727 /** 728 * The ::move-lines signal is a keybinding which gets emitted 729 * when the user initiates moving a line. The default binding key 730 * is Alt+Up/Down arrow. And moves the currently selected lines, 731 * or the current line by @count. For the moment, only 732 * @count of -1 or 1 is valid. 733 * 734 * Params: 735 * copy = %TRUE if the line should be copied, 736 * %FALSE if it should be moved 737 * count = the number of lines to move over. 738 * 739 * Since: 2.10 740 */ 741 void addOnMoveLines(void delegate(bool, int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 742 { 743 if ( "move-lines" !in connectedSignals ) 744 { 745 Signals.connectData( 746 this, 747 "move-lines", 748 cast(GCallback)&callBackMoveLines, 749 cast(void*)this, 750 null, 751 connectFlags); 752 connectedSignals["move-lines"] = 1; 753 } 754 onMoveLinesListeners ~= dlg; 755 } 756 extern(C) static void callBackMoveLines(GtkSourceView* sourceviewStruct, bool copy, int count, SourceView _sourceview) 757 { 758 foreach ( void delegate(bool, int, SourceView) dlg; _sourceview.onMoveLinesListeners ) 759 { 760 dlg(copy, count, _sourceview); 761 } 762 } 763 764 void delegate(bool, SourceView)[] onMoveToMatchingBracketListeners; 765 /** 766 * Keybinding signal to move the cursor to the matching bracket. 767 * 768 * Params: 769 * extendSelection = %TRUE if the move should extend the selection 770 * 771 * Since: 3.16 772 */ 773 void addOnMoveToMatchingBracket(void delegate(bool, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 774 { 775 if ( "move-to-matching-bracket" !in connectedSignals ) 776 { 777 Signals.connectData( 778 this, 779 "move-to-matching-bracket", 780 cast(GCallback)&callBackMoveToMatchingBracket, 781 cast(void*)this, 782 null, 783 connectFlags); 784 connectedSignals["move-to-matching-bracket"] = 1; 785 } 786 onMoveToMatchingBracketListeners ~= dlg; 787 } 788 extern(C) static void callBackMoveToMatchingBracket(GtkSourceView* sourceviewStruct, bool extendSelection, SourceView _sourceview) 789 { 790 foreach ( void delegate(bool, SourceView) dlg; _sourceview.onMoveToMatchingBracketListeners ) 791 { 792 dlg(extendSelection, _sourceview); 793 } 794 } 795 796 void delegate(int, SourceView)[] onMoveWordsListeners; 797 /** 798 * The ::move-words signal is a keybinding which gets emitted 799 * when the user initiates moving a word. The default binding key 800 * is Alt+Left/Right Arrow and moves the current selection, or the current 801 * word by one word. 802 * 803 * Params: 804 * count = the number of words to move over 805 * 806 * Since: 3.0 807 */ 808 void addOnMoveWords(void delegate(int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 809 { 810 if ( "move-words" !in connectedSignals ) 811 { 812 Signals.connectData( 813 this, 814 "move-words", 815 cast(GCallback)&callBackMoveWords, 816 cast(void*)this, 817 null, 818 connectFlags); 819 connectedSignals["move-words"] = 1; 820 } 821 onMoveWordsListeners ~= dlg; 822 } 823 extern(C) static void callBackMoveWords(GtkSourceView* sourceviewStruct, int count, SourceView _sourceview) 824 { 825 foreach ( void delegate(int, SourceView) dlg; _sourceview.onMoveWordsListeners ) 826 { 827 dlg(count, _sourceview); 828 } 829 } 830 831 void delegate(SourceView)[] onRedoListeners; 832 void addOnRedo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 833 { 834 if ( "redo" !in connectedSignals ) 835 { 836 Signals.connectData( 837 this, 838 "redo", 839 cast(GCallback)&callBackRedo, 840 cast(void*)this, 841 null, 842 connectFlags); 843 connectedSignals["redo"] = 1; 844 } 845 onRedoListeners ~= dlg; 846 } 847 extern(C) static void callBackRedo(GtkSourceView* sourceviewStruct, SourceView _sourceview) 848 { 849 foreach ( void delegate(SourceView) dlg; _sourceview.onRedoListeners ) 850 { 851 dlg(_sourceview); 852 } 853 } 854 855 void delegate(SourceView)[] onShowCompletionListeners; 856 /** 857 * The ::show-completion signal is a key binding signal which gets 858 * emitted when the user requests a completion, by pressing 859 * <keycombo><keycap>Control</keycap><keycap>space</keycap></keycombo>. 860 * 861 * This will create a #GtkSourceCompletionContext with the activation 862 * type as %GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED. 863 * 864 * Applications should not connect to it, but may emit it with 865 * g_signal_emit_by_name() if they need to activate the completion by 866 * another means, for example with another key binding or a menu entry. 867 */ 868 void addOnShowCompletion(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 869 { 870 if ( "show-completion" !in connectedSignals ) 871 { 872 Signals.connectData( 873 this, 874 "show-completion", 875 cast(GCallback)&callBackShowCompletion, 876 cast(void*)this, 877 null, 878 connectFlags); 879 connectedSignals["show-completion"] = 1; 880 } 881 onShowCompletionListeners ~= dlg; 882 } 883 extern(C) static void callBackShowCompletion(GtkSourceView* sourceviewStruct, SourceView _sourceview) 884 { 885 foreach ( void delegate(SourceView) dlg; _sourceview.onShowCompletionListeners ) 886 { 887 dlg(_sourceview); 888 } 889 } 890 891 void delegate(TextIter, int, SourceView)[] onSmartHomeEndListeners; 892 /** 893 * Emitted when a the cursor was moved according to the smart home 894 * end setting. The signal is emitted after the cursor is moved, but 895 * during the GtkTextView::move-cursor action. This can be used to find 896 * out whether the cursor was moved by a normal home/end or by a smart 897 * home/end. 898 * 899 * Params: 900 * iter = a #GtkTextIter 901 * count = the count 902 * 903 * Since: 3.0 904 */ 905 void addOnSmartHomeEnd(void delegate(TextIter, int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 906 { 907 if ( "smart-home-end" !in connectedSignals ) 908 { 909 Signals.connectData( 910 this, 911 "smart-home-end", 912 cast(GCallback)&callBackSmartHomeEnd, 913 cast(void*)this, 914 null, 915 connectFlags); 916 connectedSignals["smart-home-end"] = 1; 917 } 918 onSmartHomeEndListeners ~= dlg; 919 } 920 extern(C) static void callBackSmartHomeEnd(GtkSourceView* sourceviewStruct, GtkTextIter* iter, int count, SourceView _sourceview) 921 { 922 foreach ( void delegate(TextIter, int, SourceView) dlg; _sourceview.onSmartHomeEndListeners ) 923 { 924 dlg(ObjectG.getDObject!(TextIter)(iter), count, _sourceview); 925 } 926 } 927 928 void delegate(SourceView)[] onUndoListeners; 929 void addOnUndo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 930 { 931 if ( "undo" !in connectedSignals ) 932 { 933 Signals.connectData( 934 this, 935 "undo", 936 cast(GCallback)&callBackUndo, 937 cast(void*)this, 938 null, 939 connectFlags); 940 connectedSignals["undo"] = 1; 941 } 942 onUndoListeners ~= dlg; 943 } 944 extern(C) static void callBackUndo(GtkSourceView* sourceviewStruct, SourceView _sourceview) 945 { 946 foreach ( void delegate(SourceView) dlg; _sourceview.onUndoListeners ) 947 { 948 dlg(_sourceview); 949 } 950 } 951 }