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