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