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 public bool getIndentOnTab() 240 { 241 return gtk_source_view_get_indent_on_tab(gtkSourceView) != 0; 242 } 243 244 /** 245 * Returns the number of spaces to use for each step of indent. 246 * See gtk_source_view_set_indent_width() for details. 247 * 248 * Return: indent width. 249 */ 250 public int getIndentWidth() 251 { 252 return gtk_source_view_get_indent_width(gtkSourceView); 253 } 254 255 /** 256 * Returns whether when inserting a tabulator character it should 257 * be replaced by a group of space characters. 258 * 259 * Return: %TRUE if spaces are inserted instead of tabs. 260 */ 261 public bool getInsertSpacesInsteadOfTabs() 262 { 263 return gtk_source_view_get_insert_spaces_instead_of_tabs(gtkSourceView) != 0; 264 } 265 266 /** 267 * Gets attributes and priority for the @category. 268 * 269 * Params: 270 * category = the category. 271 * priority = place where priority of the category will be stored. 272 * 273 * Return: #GtkSourceMarkAttributes for the @category. 274 * The object belongs to @view, so it must not be unreffed. 275 */ 276 public SourceMarkAttributes getMarkAttributes(string category, int* priority) 277 { 278 auto p = gtk_source_view_get_mark_attributes(gtkSourceView, Str.toStringz(category), priority); 279 280 if(p is null) 281 { 282 return null; 283 } 284 285 return ObjectG.getDObject!(SourceMarkAttributes)(cast(GtkSourceMarkAttributes*) p); 286 } 287 288 /** 289 * Gets the position of the right margin in the given @view. 290 * 291 * Return: the position of the right margin. 292 */ 293 public uint getRightMarginPosition() 294 { 295 return gtk_source_view_get_right_margin_position(gtkSourceView); 296 } 297 298 /** 299 * Returns whether line marks are displayed beside the text. 300 * 301 * Return: %TRUE if the line marks are displayed. 302 * 303 * Since: 2.2 304 */ 305 public bool getShowLineMarks() 306 { 307 return gtk_source_view_get_show_line_marks(gtkSourceView) != 0; 308 } 309 310 /** 311 * Returns whether line numbers are displayed beside the text. 312 * 313 * Return: %TRUE if the line numbers are displayed. 314 */ 315 public bool getShowLineNumbers() 316 { 317 return gtk_source_view_get_show_line_numbers(gtkSourceView) != 0; 318 } 319 320 /** 321 * Returns whether a right margin is displayed. 322 * 323 * Return: %TRUE if the right margin is shown. 324 */ 325 public bool getShowRightMargin() 326 { 327 return gtk_source_view_get_show_right_margin(gtkSourceView) != 0; 328 } 329 330 /** 331 * Returns %TRUE if pressing the Backspace key will try to delete spaces 332 * up to the previous tab stop. 333 * 334 * Return: %TRUE if smart Backspace handling is enabled. 335 * 336 * Since: 3.18 337 */ 338 public bool getSmartBackspace() 339 { 340 return gtk_source_view_get_smart_backspace(gtkSourceView) != 0; 341 } 342 343 /** 344 * Returns a #GtkSourceSmartHomeEndType end value specifying 345 * how the cursor will move when HOME and END keys are pressed. 346 * 347 * Return: a #GtkSourceSmartHomeEndType value. 348 */ 349 public GtkSourceSmartHomeEndType getSmartHomeEnd() 350 { 351 return gtk_source_view_get_smart_home_end(gtkSourceView); 352 } 353 354 /** 355 * Returns the width of tabulation in characters. 356 * 357 * Return: width of tab. 358 */ 359 public uint getTabWidth() 360 { 361 return gtk_source_view_get_tab_width(gtkSourceView); 362 } 363 364 /** 365 * Determines the visual column at @iter taking into consideration the 366 * #GtkSourceView:tab-width of @view. 367 * 368 * Params: 369 * iter = a position in @view. 370 * 371 * Return: the visual column at @iter. 372 */ 373 public uint getVisualColumn(TextIter iter) 374 { 375 return gtk_source_view_get_visual_column(gtkSourceView, (iter is null) ? null : iter.getTextIterStruct()); 376 } 377 378 /** 379 * Insert one indentation level at the beginning of the 380 * specified lines. 381 * 382 * Params: 383 * start = #GtkTextIter of the first line to indent 384 * end = #GtkTextIter of the last line to indent 385 * 386 * Since: 3.16 387 */ 388 public void indentLines(TextIter start, TextIter end) 389 { 390 gtk_source_view_indent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 391 } 392 393 /** 394 * If %TRUE auto-indentation of text is enabled. 395 * 396 * When Enter is pressed to create a new line, the auto-indentation inserts the 397 * same indentation as the previous line. This is <emphasis>not</emphasis> a 398 * "smart indentation" where an indentation level is added or removed depending 399 * on the context. 400 * 401 * Params: 402 * enable = whether to enable auto indentation. 403 */ 404 public void setAutoIndent(bool enable) 405 { 406 gtk_source_view_set_auto_indent(gtkSourceView, enable); 407 } 408 409 /** 410 * Set if and how the background pattern should be displayed. 411 * 412 * Params: 413 * backgroundPattern = the #GtkSourceBackgroundPatternType. 414 * 415 * Since: 3.16 416 */ 417 public void setBackgroundPattern(GtkSourceBackgroundPatternType backgroundPattern) 418 { 419 gtk_source_view_set_background_pattern(gtkSourceView, backgroundPattern); 420 } 421 422 /** 423 * Set if and how the spaces should be visualized. Specifying @flags as 0 will 424 * disable display of spaces. 425 * 426 * Params: 427 * flags = #GtkSourceDrawSpacesFlags specifing how white spaces should 428 * be displayed 429 */ 430 public void setDrawSpaces(GtkSourceDrawSpacesFlags flags) 431 { 432 gtk_source_view_set_draw_spaces(gtkSourceView, flags); 433 } 434 435 /** 436 * If @highlight is %TRUE the current line will be highlighted. 437 * 438 * Params: 439 * highlight = whether to highlight the current line. 440 */ 441 public void setHighlightCurrentLine(bool highlight) 442 { 443 gtk_source_view_set_highlight_current_line(gtkSourceView, highlight); 444 } 445 446 /** 447 * If %TRUE, when the tab key is pressed when several lines are selected, the 448 * selected lines are indented of one level instead of being replaced with a \t 449 * character. Shift+Tab unindents the selection. 450 * 451 * If the first or last line is not selected completely, it is also indented or 452 * unindented. 453 * 454 * When the selection doesn't span several lines, the tab key always replaces 455 * the selection with a normal \t character. 456 * 457 * Params: 458 * enable = whether to indent a block when tab is pressed. 459 */ 460 public void setIndentOnTab(bool enable) 461 { 462 gtk_source_view_set_indent_on_tab(gtkSourceView, enable); 463 } 464 465 /** 466 * Sets the number of spaces to use for each step of indent when the tab key is 467 * pressed. If @width is -1, the value of the #GtkSourceView:tab-width property 468 * will be used. 469 * 470 * The #GtkSourceView:indent-width interacts with the 471 * #GtkSourceView:insert-spaces-instead-of-tabs property and 472 * #GtkSourceView:tab-width. An example will be clearer: if the 473 * #GtkSourceView:indent-width is 4 and 474 * #GtkSourceView:tab-width is 8 and 475 * #GtkSourceView:insert-spaces-instead-of-tabs is %FALSE, then pressing the tab 476 * key at the beginning of a line will insert 4 spaces. So far so good. Pressing 477 * the tab key a second time will remove the 4 spaces and insert a \t character 478 * instead (since #GtkSourceView:tab-width is 8). On the other hand, if 479 * #GtkSourceView:insert-spaces-instead-of-tabs is %TRUE, the second tab key 480 * pressed will insert 4 more spaces for a total of 8 spaces in the 481 * #GtkTextBuffer. 482 * 483 * The test-widget program (available in the GtkSourceView repository) may be 484 * useful to better understand the indentation settings (enable the space 485 * drawing!). 486 * 487 * Params: 488 * width = indent width in characters. 489 */ 490 public void setIndentWidth(int width) 491 { 492 gtk_source_view_set_indent_width(gtkSourceView, width); 493 } 494 495 /** 496 * If %TRUE a tab key pressed is replaced by a group of space characters. Of 497 * course it is still possible to insert a real \t programmatically with the 498 * #GtkTextBuffer API. 499 * 500 * Params: 501 * enable = whether to insert spaces instead of tabs. 502 */ 503 public void setInsertSpacesInsteadOfTabs(bool enable) 504 { 505 gtk_source_view_set_insert_spaces_instead_of_tabs(gtkSourceView, enable); 506 } 507 508 /** 509 * Sets attributes and priority for the @category. 510 * 511 * Params: 512 * category = the category. 513 * attributes = mark attributes. 514 * priority = priority of the category. 515 */ 516 public void setMarkAttributes(string category, SourceMarkAttributes attributes, int priority) 517 { 518 gtk_source_view_set_mark_attributes(gtkSourceView, Str.toStringz(category), (attributes is null) ? null : attributes.getSourceMarkAttributesStruct(), priority); 519 } 520 521 /** 522 * Sets the position of the right margin in the given @view. 523 * 524 * Params: 525 * pos = the width in characters where to position the right margin. 526 */ 527 public void setRightMarginPosition(uint pos) 528 { 529 gtk_source_view_set_right_margin_position(gtkSourceView, pos); 530 } 531 532 /** 533 * If %TRUE line marks will be displayed beside the text. 534 * 535 * Params: 536 * show = whether line marks should be displayed. 537 * 538 * Since: 2.2 539 */ 540 public void setShowLineMarks(bool show) 541 { 542 gtk_source_view_set_show_line_marks(gtkSourceView, show); 543 } 544 545 /** 546 * If %TRUE line numbers will be displayed beside the text. 547 * 548 * Params: 549 * show = whether line numbers should be displayed. 550 */ 551 public void setShowLineNumbers(bool show) 552 { 553 gtk_source_view_set_show_line_numbers(gtkSourceView, show); 554 } 555 556 /** 557 * If %TRUE a right margin is displayed. 558 * 559 * Params: 560 * show = whether to show a right margin. 561 */ 562 public void setShowRightMargin(bool show) 563 { 564 gtk_source_view_set_show_right_margin(gtkSourceView, show); 565 } 566 567 /** 568 * When set to %TRUE, pressing the Backspace key will try to delete spaces 569 * up to the previous tab stop. 570 * 571 * Params: 572 * smartBackspace = whether to enable smart Backspace handling. 573 * 574 * Since: 3.18 575 */ 576 public void setSmartBackspace(bool smartBackspace) 577 { 578 gtk_source_view_set_smart_backspace(gtkSourceView, smartBackspace); 579 } 580 581 /** 582 * Set the desired movement of the cursor when HOME and END keys 583 * are pressed. 584 * 585 * Params: 586 * smartHomeEnd = the desired behavior among #GtkSourceSmartHomeEndType. 587 */ 588 public void setSmartHomeEnd(GtkSourceSmartHomeEndType smartHomeEnd) 589 { 590 gtk_source_view_set_smart_home_end(gtkSourceView, smartHomeEnd); 591 } 592 593 /** 594 * Sets the width of tabulation in characters. The #GtkTextBuffer still contains 595 * \t characters, but they can take a different visual width in a #GtkSourceView 596 * widget. 597 * 598 * Params: 599 * width = width of tab in characters. 600 */ 601 public void setTabWidth(uint width) 602 { 603 gtk_source_view_set_tab_width(gtkSourceView, width); 604 } 605 606 /** 607 * Removes one indentation level at the beginning of the 608 * specified lines. 609 * 610 * Params: 611 * start = #GtkTextIter of the first line to indent 612 * end = #GtkTextIter of the last line to indent 613 * 614 * Since: 3.16 615 */ 616 public void unindentLines(TextIter start, TextIter end) 617 { 618 gtk_source_view_unindent_lines(gtkSourceView, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 619 } 620 621 int[string] connectedSignals; 622 623 void delegate(GtkSourceChangeCaseType, SourceView)[] onChangeCaseListeners; 624 /** 625 * Keybinding signal to change case of the text at the current cursor position. 626 * 627 * Params: 628 * caseType = the case to use 629 * 630 * Since: 3.16 631 */ 632 void addOnChangeCase(void delegate(GtkSourceChangeCaseType, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 633 { 634 if ( "change-case" !in connectedSignals ) 635 { 636 Signals.connectData( 637 this, 638 "change-case", 639 cast(GCallback)&callBackChangeCase, 640 cast(void*)this, 641 null, 642 connectFlags); 643 connectedSignals["change-case"] = 1; 644 } 645 onChangeCaseListeners ~= dlg; 646 } 647 extern(C) static void callBackChangeCase(GtkSourceView* sourceviewStruct, GtkSourceChangeCaseType caseType, SourceView _sourceview) 648 { 649 foreach ( void delegate(GtkSourceChangeCaseType, SourceView) dlg; _sourceview.onChangeCaseListeners ) 650 { 651 dlg(caseType, _sourceview); 652 } 653 } 654 655 void delegate(int, SourceView)[] onChangeNumberListeners; 656 /** 657 * Keybinding signal to edit a number at the current cursor position. 658 * 659 * Params: 660 * count = the number to add to the number at the current position 661 * 662 * Since: 3.16 663 */ 664 void addOnChangeNumber(void delegate(int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 665 { 666 if ( "change-number" !in connectedSignals ) 667 { 668 Signals.connectData( 669 this, 670 "change-number", 671 cast(GCallback)&callBackChangeNumber, 672 cast(void*)this, 673 null, 674 connectFlags); 675 connectedSignals["change-number"] = 1; 676 } 677 onChangeNumberListeners ~= dlg; 678 } 679 extern(C) static void callBackChangeNumber(GtkSourceView* sourceviewStruct, int count, SourceView _sourceview) 680 { 681 foreach ( void delegate(int, SourceView) dlg; _sourceview.onChangeNumberListeners ) 682 { 683 dlg(count, _sourceview); 684 } 685 } 686 687 void delegate(SourceView)[] onJoinLinesListeners; 688 /** 689 * Keybinding signal to join the lines currently selected. 690 * 691 * Since: 3.16 692 */ 693 void addOnJoinLines(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 694 { 695 if ( "join-lines" !in connectedSignals ) 696 { 697 Signals.connectData( 698 this, 699 "join-lines", 700 cast(GCallback)&callBackJoinLines, 701 cast(void*)this, 702 null, 703 connectFlags); 704 connectedSignals["join-lines"] = 1; 705 } 706 onJoinLinesListeners ~= dlg; 707 } 708 extern(C) static void callBackJoinLines(GtkSourceView* sourceviewStruct, SourceView _sourceview) 709 { 710 foreach ( void delegate(SourceView) dlg; _sourceview.onJoinLinesListeners ) 711 { 712 dlg(_sourceview); 713 } 714 } 715 716 void delegate(TextIter, Event, SourceView)[] onLineMarkActivatedListeners; 717 /** 718 * Emitted when a line mark has been activated (for instance when there 719 * was a button press in the line marks gutter). You can use @iter to 720 * determine on which line the activation took place. 721 * 722 * Params: 723 * iter = a #GtkTextIter 724 * event = the #GdkEvent that activated the event 725 */ 726 void addOnLineMarkActivated(void delegate(TextIter, Event, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 727 { 728 if ( "line-mark-activated" !in connectedSignals ) 729 { 730 Signals.connectData( 731 this, 732 "line-mark-activated", 733 cast(GCallback)&callBackLineMarkActivated, 734 cast(void*)this, 735 null, 736 connectFlags); 737 connectedSignals["line-mark-activated"] = 1; 738 } 739 onLineMarkActivatedListeners ~= dlg; 740 } 741 extern(C) static void callBackLineMarkActivated(GtkSourceView* sourceviewStruct, GtkTextIter* iter, GdkEvent* event, SourceView _sourceview) 742 { 743 foreach ( void delegate(TextIter, Event, SourceView) dlg; _sourceview.onLineMarkActivatedListeners ) 744 { 745 dlg(ObjectG.getDObject!(TextIter)(iter), ObjectG.getDObject!(Event)(event), _sourceview); 746 } 747 } 748 749 void delegate(bool, int, SourceView)[] onMoveLinesListeners; 750 /** 751 * The ::move-lines signal is a keybinding which gets emitted 752 * when the user initiates moving a line. The default binding key 753 * is Alt+Up/Down arrow. And moves the currently selected lines, 754 * or the current line by @count. For the moment, only 755 * @count of -1 or 1 is valid. 756 * 757 * Params: 758 * copy = %TRUE if the line should be copied, 759 * %FALSE if it should be moved 760 * count = the number of lines to move over. 761 * 762 * Since: 2.10 763 */ 764 void addOnMoveLines(void delegate(bool, int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 765 { 766 if ( "move-lines" !in connectedSignals ) 767 { 768 Signals.connectData( 769 this, 770 "move-lines", 771 cast(GCallback)&callBackMoveLines, 772 cast(void*)this, 773 null, 774 connectFlags); 775 connectedSignals["move-lines"] = 1; 776 } 777 onMoveLinesListeners ~= dlg; 778 } 779 extern(C) static void callBackMoveLines(GtkSourceView* sourceviewStruct, bool copy, int count, SourceView _sourceview) 780 { 781 foreach ( void delegate(bool, int, SourceView) dlg; _sourceview.onMoveLinesListeners ) 782 { 783 dlg(copy, count, _sourceview); 784 } 785 } 786 787 void delegate(bool, SourceView)[] onMoveToMatchingBracketListeners; 788 /** 789 * Keybinding signal to move the cursor to the matching bracket. 790 * 791 * Params: 792 * extendSelection = %TRUE if the move should extend the selection 793 * 794 * Since: 3.16 795 */ 796 void addOnMoveToMatchingBracket(void delegate(bool, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 797 { 798 if ( "move-to-matching-bracket" !in connectedSignals ) 799 { 800 Signals.connectData( 801 this, 802 "move-to-matching-bracket", 803 cast(GCallback)&callBackMoveToMatchingBracket, 804 cast(void*)this, 805 null, 806 connectFlags); 807 connectedSignals["move-to-matching-bracket"] = 1; 808 } 809 onMoveToMatchingBracketListeners ~= dlg; 810 } 811 extern(C) static void callBackMoveToMatchingBracket(GtkSourceView* sourceviewStruct, bool extendSelection, SourceView _sourceview) 812 { 813 foreach ( void delegate(bool, SourceView) dlg; _sourceview.onMoveToMatchingBracketListeners ) 814 { 815 dlg(extendSelection, _sourceview); 816 } 817 } 818 819 void delegate(int, SourceView)[] onMoveWordsListeners; 820 /** 821 * The ::move-words signal is a keybinding which gets emitted 822 * when the user initiates moving a word. The default binding key 823 * is Alt+Left/Right Arrow and moves the current selection, or the current 824 * word by one word. 825 * 826 * Params: 827 * count = the number of words to move over 828 * 829 * Since: 3.0 830 */ 831 void addOnMoveWords(void delegate(int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 832 { 833 if ( "move-words" !in connectedSignals ) 834 { 835 Signals.connectData( 836 this, 837 "move-words", 838 cast(GCallback)&callBackMoveWords, 839 cast(void*)this, 840 null, 841 connectFlags); 842 connectedSignals["move-words"] = 1; 843 } 844 onMoveWordsListeners ~= dlg; 845 } 846 extern(C) static void callBackMoveWords(GtkSourceView* sourceviewStruct, int count, SourceView _sourceview) 847 { 848 foreach ( void delegate(int, SourceView) dlg; _sourceview.onMoveWordsListeners ) 849 { 850 dlg(count, _sourceview); 851 } 852 } 853 854 void delegate(SourceView)[] onRedoListeners; 855 void addOnRedo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 856 { 857 if ( "redo" !in connectedSignals ) 858 { 859 Signals.connectData( 860 this, 861 "redo", 862 cast(GCallback)&callBackRedo, 863 cast(void*)this, 864 null, 865 connectFlags); 866 connectedSignals["redo"] = 1; 867 } 868 onRedoListeners ~= dlg; 869 } 870 extern(C) static void callBackRedo(GtkSourceView* sourceviewStruct, SourceView _sourceview) 871 { 872 foreach ( void delegate(SourceView) dlg; _sourceview.onRedoListeners ) 873 { 874 dlg(_sourceview); 875 } 876 } 877 878 void delegate(SourceView)[] onShowCompletionListeners; 879 /** 880 * The ::show-completion signal is a key binding signal which gets 881 * emitted when the user requests a completion, by pressing 882 * <keycombo><keycap>Control</keycap><keycap>space</keycap></keycombo>. 883 * 884 * This will create a #GtkSourceCompletionContext with the activation 885 * type as %GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED. 886 * 887 * Applications should not connect to it, but may emit it with 888 * g_signal_emit_by_name() if they need to activate the completion by 889 * another means, for example with another key binding or a menu entry. 890 */ 891 void addOnShowCompletion(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 892 { 893 if ( "show-completion" !in connectedSignals ) 894 { 895 Signals.connectData( 896 this, 897 "show-completion", 898 cast(GCallback)&callBackShowCompletion, 899 cast(void*)this, 900 null, 901 connectFlags); 902 connectedSignals["show-completion"] = 1; 903 } 904 onShowCompletionListeners ~= dlg; 905 } 906 extern(C) static void callBackShowCompletion(GtkSourceView* sourceviewStruct, SourceView _sourceview) 907 { 908 foreach ( void delegate(SourceView) dlg; _sourceview.onShowCompletionListeners ) 909 { 910 dlg(_sourceview); 911 } 912 } 913 914 void delegate(TextIter, int, SourceView)[] onSmartHomeEndListeners; 915 /** 916 * Emitted when a the cursor was moved according to the smart home 917 * end setting. The signal is emitted after the cursor is moved, but 918 * during the GtkTextView::move-cursor action. This can be used to find 919 * out whether the cursor was moved by a normal home/end or by a smart 920 * home/end. 921 * 922 * Params: 923 * iter = a #GtkTextIter 924 * count = the count 925 * 926 * Since: 3.0 927 */ 928 void addOnSmartHomeEnd(void delegate(TextIter, int, SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 929 { 930 if ( "smart-home-end" !in connectedSignals ) 931 { 932 Signals.connectData( 933 this, 934 "smart-home-end", 935 cast(GCallback)&callBackSmartHomeEnd, 936 cast(void*)this, 937 null, 938 connectFlags); 939 connectedSignals["smart-home-end"] = 1; 940 } 941 onSmartHomeEndListeners ~= dlg; 942 } 943 extern(C) static void callBackSmartHomeEnd(GtkSourceView* sourceviewStruct, GtkTextIter* iter, int count, SourceView _sourceview) 944 { 945 foreach ( void delegate(TextIter, int, SourceView) dlg; _sourceview.onSmartHomeEndListeners ) 946 { 947 dlg(ObjectG.getDObject!(TextIter)(iter), count, _sourceview); 948 } 949 } 950 951 void delegate(SourceView)[] onUndoListeners; 952 void addOnUndo(void delegate(SourceView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 953 { 954 if ( "undo" !in connectedSignals ) 955 { 956 Signals.connectData( 957 this, 958 "undo", 959 cast(GCallback)&callBackUndo, 960 cast(void*)this, 961 null, 962 connectFlags); 963 connectedSignals["undo"] = 1; 964 } 965 onUndoListeners ~= dlg; 966 } 967 extern(C) static void callBackUndo(GtkSourceView* sourceviewStruct, SourceView _sourceview) 968 { 969 foreach ( void delegate(SourceView) dlg; _sourceview.onUndoListeners ) 970 { 971 dlg(_sourceview); 972 } 973 } 974 }