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 gtk.TextView; 26 27 private import gdk.Window; 28 private import glib.ConstructionException; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gobject.Signals; 32 private import gtk.Container; 33 private import gtk.ScrollableIF; 34 private import gtk.ScrollableT; 35 private import gtk.TextAttributes; 36 private import gtk.TextBuffer; 37 private import gtk.TextChildAnchor; 38 private import gtk.TextIter; 39 private import gtk.TextMark; 40 private import gtk.Widget; 41 private import gtk.c.functions; 42 public import gtk.c.types; 43 public import gtkc.gtktypes; 44 private import pango.PgTabArray; 45 private import std.algorithm; 46 47 48 /** 49 * You may wish to begin by reading the 50 * [text widget conceptual overview][TextWidget] 51 * which gives an overview of all the objects and data 52 * types related to the text widget and how they work together. 53 * 54 * # CSS nodes 55 * 56 * |[<!-- language="plain" --> 57 * textview.view 58 * ├── border.top 59 * ├── border.left 60 * ├── text 61 * │ ╰── [selection] 62 * ├── border.right 63 * ├── border.bottom 64 * ╰── [window.popup] 65 * ]| 66 * 67 * GtkTextView has a main css node with name textview and style class .view, 68 * and subnodes for each of the border windows, and the main text area, 69 * with names border and text, respectively. The border nodes each get 70 * one of the style classes .left, .right, .top or .bottom. 71 * 72 * A node representing the selection will appear below the text node. 73 * 74 * If a context menu is opened, the window node will appear as a subnode 75 * of the main node. 76 */ 77 public class TextView : Container, ScrollableIF 78 { 79 /** the main Gtk struct */ 80 protected GtkTextView* gtkTextView; 81 82 /** Get the main Gtk struct */ 83 public GtkTextView* getTextViewStruct(bool transferOwnership = false) 84 { 85 if (transferOwnership) 86 ownedRef = false; 87 return gtkTextView; 88 } 89 90 /** the main Gtk struct as a void* */ 91 protected override void* getStruct() 92 { 93 return cast(void*)gtkTextView; 94 } 95 96 /** 97 * Sets our main struct and passes it to the parent class. 98 */ 99 public this (GtkTextView* gtkTextView, bool ownedRef = false) 100 { 101 this.gtkTextView = gtkTextView; 102 super(cast(GtkContainer*)gtkTextView, ownedRef); 103 } 104 105 // add the Scrollable capabilities 106 mixin ScrollableT!(GtkTextView); 107 108 /** 109 * Get the text line at the pixel y 110 */ 111 string getLineTextAt(int y) 112 { 113 114 TextIter iter = new TextIter(); 115 int windowX; 116 int windowY; 117 bufferToWindowCoords(TextWindowType.TEXT, 0, y, windowX, windowY); 118 119 gtk_text_view_get_line_at_y(gtkTextView, iter.getTextIterStruct(), y+y-windowY, null); 120 121 TextIter iterEnd = new TextIter(); 122 TextBuffer buffer = getBuffer(); 123 buffer.getIterAtOffset(iterEnd, iter.getOffset()+iter.getCharsInLine()); 124 return buffer.getText(iter, iterEnd, false); 125 } 126 127 /** 128 * Simply appends some on the cursor position 129 * Params: 130 * text = the text to append 131 */ 132 void insertText(string text) 133 { 134 TextBuffer buf = getBuffer(); 135 buf.insertAtCursor(text); 136 } 137 138 /** 139 * Simply appends some text to this view 140 * Params: 141 * text = the text to append 142 */ 143 void appendText(string text, bool ensureVisible=true) 144 { 145 TextBuffer buf = getBuffer(); 146 TextIter iter = new TextIter(); 147 buf.getEndIter(iter); 148 buf.insert(iter, text); 149 if ( ensureVisible ) 150 { 151 double within_margin = 0.0; 152 bool use_align = false; 153 double xalign = 0.0; 154 double yalign = 0.0; 155 scrollToMark(buf.createMark("",iter,true), within_margin, use_align, xalign, yalign); 156 } 157 } 158 159 /** 160 */ 161 162 /** */ 163 public static GType getType() 164 { 165 return gtk_text_view_get_type(); 166 } 167 168 /** 169 * Creates a new #GtkTextView. If you don’t call gtk_text_view_set_buffer() 170 * before using the text view, an empty default buffer will be created 171 * for you. Get the buffer with gtk_text_view_get_buffer(). If you want 172 * to specify your own buffer, consider gtk_text_view_new_with_buffer(). 173 * 174 * Returns: a new #GtkTextView 175 * 176 * Throws: ConstructionException GTK+ fails to create the object. 177 */ 178 public this() 179 { 180 auto p = gtk_text_view_new(); 181 182 if(p is null) 183 { 184 throw new ConstructionException("null returned by new"); 185 } 186 187 this(cast(GtkTextView*) p); 188 } 189 190 /** 191 * Creates a new #GtkTextView widget displaying the buffer 192 * @buffer. One buffer can be shared among many widgets. 193 * @buffer may be %NULL to create a default buffer, in which case 194 * this function is equivalent to gtk_text_view_new(). The 195 * text view adds its own reference count to the buffer; it does not 196 * take over an existing reference. 197 * 198 * Params: 199 * buffer = a #GtkTextBuffer 200 * 201 * Returns: a new #GtkTextView. 202 * 203 * Throws: ConstructionException GTK+ fails to create the object. 204 */ 205 public this(TextBuffer buffer) 206 { 207 auto p = gtk_text_view_new_with_buffer((buffer is null) ? null : buffer.getTextBufferStruct()); 208 209 if(p is null) 210 { 211 throw new ConstructionException("null returned by new_with_buffer"); 212 } 213 214 this(cast(GtkTextView*) p); 215 } 216 217 /** 218 * Adds a child widget in the text buffer, at the given @anchor. 219 * 220 * Params: 221 * child = a #GtkWidget 222 * anchor = a #GtkTextChildAnchor in the #GtkTextBuffer for @text_view 223 */ 224 public void addChildAtAnchor(Widget child, TextChildAnchor anchor) 225 { 226 gtk_text_view_add_child_at_anchor(gtkTextView, (child is null) ? null : child.getWidgetStruct(), (anchor is null) ? null : anchor.getTextChildAnchorStruct()); 227 } 228 229 /** 230 * Adds a child at fixed coordinates in one of the text widget's 231 * windows. 232 * 233 * The window must have nonzero size (see 234 * gtk_text_view_set_border_window_size()). Note that the child 235 * coordinates are given relative to scrolling. When 236 * placing a child in #GTK_TEXT_WINDOW_WIDGET, scrolling is 237 * irrelevant, the child floats above all scrollable areas. But when 238 * placing a child in one of the scrollable windows (border windows or 239 * text window) it will move with the scrolling as needed. 240 * 241 * Params: 242 * child = a #GtkWidget 243 * whichWindow = which window the child should appear in 244 * xpos = X position of child in window coordinates 245 * ypos = Y position of child in window coordinates 246 */ 247 public void addChildInWindow(Widget child, GtkTextWindowType whichWindow, int xpos, int ypos) 248 { 249 gtk_text_view_add_child_in_window(gtkTextView, (child is null) ? null : child.getWidgetStruct(), whichWindow, xpos, ypos); 250 } 251 252 /** 253 * Moves the given @iter backward by one display (wrapped) line. 254 * A display line is different from a paragraph. Paragraphs are 255 * separated by newlines or other paragraph separator characters. 256 * Display lines are created by line-wrapping a paragraph. If 257 * wrapping is turned off, display lines and paragraphs will be the 258 * same. Display lines are divided differently for each view, since 259 * they depend on the view’s width; paragraphs are the same in all 260 * views, since they depend on the contents of the #GtkTextBuffer. 261 * 262 * Params: 263 * iter = a #GtkTextIter 264 * 265 * Returns: %TRUE if @iter was moved and is not on the end iterator 266 */ 267 public bool backwardDisplayLine(TextIter iter) 268 { 269 return gtk_text_view_backward_display_line(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 270 } 271 272 /** 273 * Moves the given @iter backward to the next display line start. 274 * A display line is different from a paragraph. Paragraphs are 275 * separated by newlines or other paragraph separator characters. 276 * Display lines are created by line-wrapping a paragraph. If 277 * wrapping is turned off, display lines and paragraphs will be the 278 * same. Display lines are divided differently for each view, since 279 * they depend on the view’s width; paragraphs are the same in all 280 * views, since they depend on the contents of the #GtkTextBuffer. 281 * 282 * Params: 283 * iter = a #GtkTextIter 284 * 285 * Returns: %TRUE if @iter was moved and is not on the end iterator 286 */ 287 public bool backwardDisplayLineStart(TextIter iter) 288 { 289 return gtk_text_view_backward_display_line_start(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 290 } 291 292 /** 293 * Converts coordinate (@buffer_x, @buffer_y) to coordinates for the window 294 * @win, and stores the result in (@window_x, @window_y). 295 * 296 * Note that you can’t convert coordinates for a nonexisting window (see 297 * gtk_text_view_set_border_window_size()). 298 * 299 * Params: 300 * win = a #GtkTextWindowType, except %GTK_TEXT_WINDOW_PRIVATE 301 * bufferX = buffer x coordinate 302 * bufferY = buffer y coordinate 303 * windowX = window x coordinate return location or %NULL 304 * windowY = window y coordinate return location or %NULL 305 */ 306 public void bufferToWindowCoords(GtkTextWindowType win, int bufferX, int bufferY, out int windowX, out int windowY) 307 { 308 gtk_text_view_buffer_to_window_coords(gtkTextView, win, bufferX, bufferY, &windowX, &windowY); 309 } 310 311 /** 312 * Moves the given @iter forward by one display (wrapped) line. 313 * A display line is different from a paragraph. Paragraphs are 314 * separated by newlines or other paragraph separator characters. 315 * Display lines are created by line-wrapping a paragraph. If 316 * wrapping is turned off, display lines and paragraphs will be the 317 * same. Display lines are divided differently for each view, since 318 * they depend on the view’s width; paragraphs are the same in all 319 * views, since they depend on the contents of the #GtkTextBuffer. 320 * 321 * Params: 322 * iter = a #GtkTextIter 323 * 324 * Returns: %TRUE if @iter was moved and is not on the end iterator 325 */ 326 public bool forwardDisplayLine(TextIter iter) 327 { 328 return gtk_text_view_forward_display_line(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 329 } 330 331 /** 332 * Moves the given @iter forward to the next display line end. 333 * A display line is different from a paragraph. Paragraphs are 334 * separated by newlines or other paragraph separator characters. 335 * Display lines are created by line-wrapping a paragraph. If 336 * wrapping is turned off, display lines and paragraphs will be the 337 * same. Display lines are divided differently for each view, since 338 * they depend on the view’s width; paragraphs are the same in all 339 * views, since they depend on the contents of the #GtkTextBuffer. 340 * 341 * Params: 342 * iter = a #GtkTextIter 343 * 344 * Returns: %TRUE if @iter was moved and is not on the end iterator 345 */ 346 public bool forwardDisplayLineEnd(TextIter iter) 347 { 348 return gtk_text_view_forward_display_line_end(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 349 } 350 351 /** 352 * Returns whether pressing the Tab key inserts a tab characters. 353 * gtk_text_view_set_accepts_tab(). 354 * 355 * Returns: %TRUE if pressing the Tab key inserts a tab character, 356 * %FALSE if pressing the Tab key moves the keyboard focus. 357 * 358 * Since: 2.4 359 */ 360 public bool getAcceptsTab() 361 { 362 return gtk_text_view_get_accepts_tab(gtkTextView) != 0; 363 } 364 365 /** 366 * Gets the width of the specified border window. See 367 * gtk_text_view_set_border_window_size(). 368 * 369 * Params: 370 * type = window to return size from 371 * 372 * Returns: width of window 373 */ 374 public int getBorderWindowSize(GtkTextWindowType type) 375 { 376 return gtk_text_view_get_border_window_size(gtkTextView, type); 377 } 378 379 /** 380 * Gets the bottom margin for text in the @text_view. 381 * 382 * Returns: bottom margin in pixels 383 * 384 * Since: 3.18 385 */ 386 public int getBottomMargin() 387 { 388 return gtk_text_view_get_bottom_margin(gtkTextView); 389 } 390 391 /** 392 * Returns the #GtkTextBuffer being displayed by this text view. 393 * The reference count on the buffer is not incremented; the caller 394 * of this function won’t own a new reference. 395 * 396 * Returns: a #GtkTextBuffer 397 */ 398 public TextBuffer getBuffer() 399 { 400 auto p = gtk_text_view_get_buffer(gtkTextView); 401 402 if(p is null) 403 { 404 return null; 405 } 406 407 return ObjectG.getDObject!(TextBuffer)(cast(GtkTextBuffer*) p); 408 } 409 410 /** 411 * Given an @iter within a text layout, determine the positions of the 412 * strong and weak cursors if the insertion point is at that 413 * iterator. The position of each cursor is stored as a zero-width 414 * rectangle. The strong cursor location is the location where 415 * characters of the directionality equal to the base direction of the 416 * paragraph are inserted. The weak cursor location is the location 417 * where characters of the directionality opposite to the base 418 * direction of the paragraph are inserted. 419 * 420 * If @iter is %NULL, the actual cursor position is used. 421 * 422 * Note that if @iter happens to be the actual cursor position, and 423 * there is currently an IM preedit sequence being entered, the 424 * returned locations will be adjusted to account for the preedit 425 * cursor’s offset within the preedit sequence. 426 * 427 * The rectangle position is in buffer coordinates; use 428 * gtk_text_view_buffer_to_window_coords() to convert these 429 * coordinates to coordinates for one of the windows in the text view. 430 * 431 * Params: 432 * iter = a #GtkTextIter 433 * strong = location to store the strong 434 * cursor position (may be %NULL) 435 * weak = location to store the weak 436 * cursor position (may be %NULL) 437 * 438 * Since: 3.0 439 */ 440 public void getCursorLocations(TextIter iter, out GdkRectangle strong, out GdkRectangle weak) 441 { 442 gtk_text_view_get_cursor_locations(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), &strong, &weak); 443 } 444 445 /** 446 * Find out whether the cursor should be displayed. 447 * 448 * Returns: whether the insertion mark is visible 449 */ 450 public bool getCursorVisible() 451 { 452 return gtk_text_view_get_cursor_visible(gtkTextView) != 0; 453 } 454 455 /** 456 * Obtains a copy of the default text attributes. These are the 457 * attributes used for text unless a tag overrides them. 458 * You’d typically pass the default attributes in to 459 * gtk_text_iter_get_attributes() in order to get the 460 * attributes in effect at a given text position. 461 * 462 * The return value is a copy owned by the caller of this function, 463 * and should be freed with gtk_text_attributes_unref(). 464 * 465 * Returns: a new #GtkTextAttributes 466 */ 467 public TextAttributes getDefaultAttributes() 468 { 469 auto p = gtk_text_view_get_default_attributes(gtkTextView); 470 471 if(p is null) 472 { 473 return null; 474 } 475 476 return ObjectG.getDObject!(TextAttributes)(cast(GtkTextAttributes*) p, true); 477 } 478 479 /** 480 * Returns the default editability of the #GtkTextView. Tags in the 481 * buffer may override this setting for some ranges of text. 482 * 483 * Returns: whether text is editable by default 484 */ 485 public bool getEditable() 486 { 487 return gtk_text_view_get_editable(gtkTextView) != 0; 488 } 489 490 /** 491 * Gets the default indentation of paragraphs in @text_view. 492 * Tags in the view’s buffer may override the default. 493 * The indentation may be negative. 494 * 495 * Returns: number of pixels of indentation 496 */ 497 public int getIndent() 498 { 499 return gtk_text_view_get_indent(gtkTextView); 500 } 501 502 /** 503 * Gets the value of the #GtkTextView:input-hints property. 504 * 505 * Since: 3.6 506 */ 507 public GtkInputHints getInputHints() 508 { 509 return gtk_text_view_get_input_hints(gtkTextView); 510 } 511 512 /** 513 * Gets the value of the #GtkTextView:input-purpose property. 514 * 515 * Since: 3.6 516 */ 517 public GtkInputPurpose getInputPurpose() 518 { 519 return gtk_text_view_get_input_purpose(gtkTextView); 520 } 521 522 /** 523 * Retrieves the iterator at buffer coordinates @x and @y. Buffer 524 * coordinates are coordinates for the entire buffer, not just the 525 * currently-displayed portion. If you have coordinates from an 526 * event, you have to convert those to buffer coordinates with 527 * gtk_text_view_window_to_buffer_coords(). 528 * 529 * Params: 530 * iter = a #GtkTextIter 531 * x = x position, in buffer coordinates 532 * y = y position, in buffer coordinates 533 * 534 * Returns: %TRUE if the position is over text 535 */ 536 public bool getIterAtLocation(out TextIter iter, int x, int y) 537 { 538 GtkTextIter* outiter = gMalloc!GtkTextIter(); 539 540 auto p = gtk_text_view_get_iter_at_location(gtkTextView, outiter, x, y) != 0; 541 542 iter = ObjectG.getDObject!(TextIter)(outiter, true); 543 544 return p; 545 } 546 547 /** 548 * Retrieves the iterator pointing to the character at buffer 549 * coordinates @x and @y. Buffer coordinates are coordinates for 550 * the entire buffer, not just the currently-displayed portion. 551 * If you have coordinates from an event, you have to convert 552 * those to buffer coordinates with 553 * gtk_text_view_window_to_buffer_coords(). 554 * 555 * Note that this is different from gtk_text_view_get_iter_at_location(), 556 * which returns cursor locations, i.e. positions between 557 * characters. 558 * 559 * Params: 560 * iter = a #GtkTextIter 561 * trailing = if non-%NULL, location to store an integer indicating where 562 * in the grapheme the user clicked. It will either be 563 * zero, or the number of characters in the grapheme. 564 * 0 represents the trailing edge of the grapheme. 565 * x = x position, in buffer coordinates 566 * y = y position, in buffer coordinates 567 * 568 * Returns: %TRUE if the position is over text 569 * 570 * Since: 2.6 571 */ 572 public bool getIterAtPosition(out TextIter iter, out int trailing, int x, int y) 573 { 574 GtkTextIter* outiter = gMalloc!GtkTextIter(); 575 576 auto p = gtk_text_view_get_iter_at_position(gtkTextView, outiter, &trailing, x, y) != 0; 577 578 iter = ObjectG.getDObject!(TextIter)(outiter, true); 579 580 return p; 581 } 582 583 /** 584 * Gets a rectangle which roughly contains the character at @iter. 585 * The rectangle position is in buffer coordinates; use 586 * gtk_text_view_buffer_to_window_coords() to convert these 587 * coordinates to coordinates for one of the windows in the text view. 588 * 589 * Params: 590 * iter = a #GtkTextIter 591 * location = bounds of the character at @iter 592 */ 593 public void getIterLocation(TextIter iter, out GdkRectangle location) 594 { 595 gtk_text_view_get_iter_location(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), &location); 596 } 597 598 /** 599 * Gets the default justification of paragraphs in @text_view. 600 * Tags in the buffer may override the default. 601 * 602 * Returns: default justification 603 */ 604 public GtkJustification getJustification() 605 { 606 return gtk_text_view_get_justification(gtkTextView); 607 } 608 609 /** 610 * Gets the default left margin size of paragraphs in the @text_view. 611 * Tags in the buffer may override the default. 612 * 613 * Returns: left margin in pixels 614 */ 615 public int getLeftMargin() 616 { 617 return gtk_text_view_get_left_margin(gtkTextView); 618 } 619 620 /** 621 * Gets the #GtkTextIter at the start of the line containing 622 * the coordinate @y. @y is in buffer coordinates, convert from 623 * window coordinates with gtk_text_view_window_to_buffer_coords(). 624 * If non-%NULL, @line_top will be filled with the coordinate of the top 625 * edge of the line. 626 * 627 * Params: 628 * targetIter = a #GtkTextIter 629 * y = a y coordinate 630 * lineTop = return location for top coordinate of the line 631 */ 632 public void getLineAtY(out TextIter targetIter, int y, out int lineTop) 633 { 634 GtkTextIter* outtargetIter = gMalloc!GtkTextIter(); 635 636 gtk_text_view_get_line_at_y(gtkTextView, outtargetIter, y, &lineTop); 637 638 targetIter = ObjectG.getDObject!(TextIter)(outtargetIter, true); 639 } 640 641 /** 642 * Gets the y coordinate of the top of the line containing @iter, 643 * and the height of the line. The coordinate is a buffer coordinate; 644 * convert to window coordinates with gtk_text_view_buffer_to_window_coords(). 645 * 646 * Params: 647 * iter = a #GtkTextIter 648 * y = return location for a y coordinate 649 * height = return location for a height 650 */ 651 public void getLineYrange(TextIter iter, out int y, out int height) 652 { 653 gtk_text_view_get_line_yrange(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), &y, &height); 654 } 655 656 /** 657 * Gets the value of the #GtkTextView:monospace property. 658 * 659 * Returns: %TRUE if monospace fonts are desired 660 * 661 * Since: 3.16 662 */ 663 public bool getMonospace() 664 { 665 return gtk_text_view_get_monospace(gtkTextView) != 0; 666 } 667 668 /** 669 * Returns whether the #GtkTextView is in overwrite mode or not. 670 * 671 * Returns: whether @text_view is in overwrite mode or not. 672 * 673 * Since: 2.4 674 */ 675 public bool getOverwrite() 676 { 677 return gtk_text_view_get_overwrite(gtkTextView) != 0; 678 } 679 680 /** 681 * Gets the default number of pixels to put above paragraphs. 682 * Adding this function with gtk_text_view_get_pixels_below_lines() 683 * is equal to the line space between each paragraph. 684 * 685 * Returns: default number of pixels above paragraphs 686 */ 687 public int getPixelsAboveLines() 688 { 689 return gtk_text_view_get_pixels_above_lines(gtkTextView); 690 } 691 692 /** 693 * Gets the value set by gtk_text_view_set_pixels_below_lines(). 694 * 695 * The line space is the sum of the value returned by this function and the 696 * value returned by gtk_text_view_get_pixels_above_lines(). 697 * 698 * Returns: default number of blank pixels below paragraphs 699 */ 700 public int getPixelsBelowLines() 701 { 702 return gtk_text_view_get_pixels_below_lines(gtkTextView); 703 } 704 705 /** 706 * Gets the value set by gtk_text_view_set_pixels_inside_wrap(). 707 * 708 * Returns: default number of pixels of blank space between wrapped lines 709 */ 710 public int getPixelsInsideWrap() 711 { 712 return gtk_text_view_get_pixels_inside_wrap(gtkTextView); 713 } 714 715 /** 716 * Gets the default right margin for text in @text_view. Tags 717 * in the buffer may override the default. 718 * 719 * Returns: right margin in pixels 720 */ 721 public int getRightMargin() 722 { 723 return gtk_text_view_get_right_margin(gtkTextView); 724 } 725 726 /** 727 * Gets the default tabs for @text_view. Tags in the buffer may 728 * override the defaults. The returned array will be %NULL if 729 * “standard” (8-space) tabs are used. Free the return value 730 * with pango_tab_array_free(). 731 * 732 * Returns: copy of default tab array, or %NULL if 733 * “standard" tabs are used; must be freed with pango_tab_array_free(). 734 */ 735 public PgTabArray getTabs() 736 { 737 auto p = gtk_text_view_get_tabs(gtkTextView); 738 739 if(p is null) 740 { 741 return null; 742 } 743 744 return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) p, true); 745 } 746 747 /** 748 * Gets the top margin for text in the @text_view. 749 * 750 * Returns: top margin in pixels 751 * 752 * Since: 3.18 753 */ 754 public int getTopMargin() 755 { 756 return gtk_text_view_get_top_margin(gtkTextView); 757 } 758 759 /** 760 * Fills @visible_rect with the currently-visible 761 * region of the buffer, in buffer coordinates. Convert to window coordinates 762 * with gtk_text_view_buffer_to_window_coords(). 763 * 764 * Params: 765 * visibleRect = rectangle to fill 766 */ 767 public void getVisibleRect(out GdkRectangle visibleRect) 768 { 769 gtk_text_view_get_visible_rect(gtkTextView, &visibleRect); 770 } 771 772 /** 773 * Retrieves the #GdkWindow corresponding to an area of the text view; 774 * possible windows include the overall widget window, child windows 775 * on the left, right, top, bottom, and the window that displays the 776 * text buffer. Windows are %NULL and nonexistent if their width or 777 * height is 0, and are nonexistent before the widget has been 778 * realized. 779 * 780 * Params: 781 * win = window to get 782 * 783 * Returns: a #GdkWindow, or %NULL 784 */ 785 public Window getWindow(GtkTextWindowType win) 786 { 787 auto p = gtk_text_view_get_window(gtkTextView, win); 788 789 if(p is null) 790 { 791 return null; 792 } 793 794 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 795 } 796 797 /** 798 * Usually used to find out which window an event corresponds to. 799 * 800 * If you connect to an event signal on @text_view, this function 801 * should be called on `event->window` to see which window it was. 802 * 803 * Params: 804 * window = a window type 805 * 806 * Returns: the window type. 807 */ 808 public GtkTextWindowType getWindowType(Window window) 809 { 810 return gtk_text_view_get_window_type(gtkTextView, (window is null) ? null : window.getWindowStruct()); 811 } 812 813 /** 814 * Gets the line wrapping for the view. 815 * 816 * Returns: the line wrap setting 817 */ 818 public GtkWrapMode getWrapMode() 819 { 820 return gtk_text_view_get_wrap_mode(gtkTextView); 821 } 822 823 /** 824 * Allow the #GtkTextView input method to internally handle key press 825 * and release events. If this function returns %TRUE, then no further 826 * processing should be done for this key event. See 827 * gtk_im_context_filter_keypress(). 828 * 829 * Note that you are expected to call this function from your handler 830 * when overriding key event handling. This is needed in the case when 831 * you need to insert your own key handling between the input method 832 * and the default key event handling of the #GtkTextView. 833 * 834 * |[<!-- language="C" --> 835 * static gboolean 836 * gtk_foo_bar_key_press_event (GtkWidget *widget, 837 * GdkEventKey *event) 838 * { 839 * if ((key->keyval == GDK_KEY_Return || key->keyval == GDK_KEY_KP_Enter)) 840 * { 841 * if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (view), event)) 842 * return TRUE; 843 * } 844 * 845 * // Do some stuff 846 * 847 * return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event); 848 * } 849 * ]| 850 * 851 * Params: 852 * event = the key event 853 * 854 * Returns: %TRUE if the input method handled the key event. 855 * 856 * Since: 2.22 857 */ 858 public bool imContextFilterKeypress(GdkEventKey* event) 859 { 860 return gtk_text_view_im_context_filter_keypress(gtkTextView, event) != 0; 861 } 862 863 /** 864 * Updates the position of a child, as for gtk_text_view_add_child_in_window(). 865 * 866 * Params: 867 * child = child widget already added to the text view 868 * xpos = new X position in window coordinates 869 * ypos = new Y position in window coordinates 870 */ 871 public void moveChild(Widget child, int xpos, int ypos) 872 { 873 gtk_text_view_move_child(gtkTextView, (child is null) ? null : child.getWidgetStruct(), xpos, ypos); 874 } 875 876 /** 877 * Moves a mark within the buffer so that it's 878 * located within the currently-visible text area. 879 * 880 * Params: 881 * mark = a #GtkTextMark 882 * 883 * Returns: %TRUE if the mark moved (wasn’t already onscreen) 884 */ 885 public bool moveMarkOnscreen(TextMark mark) 886 { 887 return gtk_text_view_move_mark_onscreen(gtkTextView, (mark is null) ? null : mark.getTextMarkStruct()) != 0; 888 } 889 890 /** 891 * Move the iterator a given number of characters visually, treating 892 * it as the strong cursor position. If @count is positive, then the 893 * new strong cursor position will be @count positions to the right of 894 * the old cursor position. If @count is negative then the new strong 895 * cursor position will be @count positions to the left of the old 896 * cursor position. 897 * 898 * In the presence of bi-directional text, the correspondence 899 * between logical and visual order will depend on the direction 900 * of the current run, and there may be jumps when the cursor 901 * is moved off of the end of a run. 902 * 903 * Params: 904 * iter = a #GtkTextIter 905 * count = number of characters to move (negative moves left, 906 * positive moves right) 907 * 908 * Returns: %TRUE if @iter moved and is not on the end iterator 909 */ 910 public bool moveVisually(TextIter iter, int count) 911 { 912 return gtk_text_view_move_visually(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), count) != 0; 913 } 914 915 /** 916 * Moves the cursor to the currently visible region of the 917 * buffer, it it isn’t there already. 918 * 919 * Returns: %TRUE if the cursor had to be moved. 920 */ 921 public bool placeCursorOnscreen() 922 { 923 return gtk_text_view_place_cursor_onscreen(gtkTextView) != 0; 924 } 925 926 /** 927 * Ensures that the cursor is shown (i.e. not in an 'off' blink 928 * interval) and resets the time that it will stay blinking (or 929 * visible, in case blinking is disabled). 930 * 931 * This function should be called in response to user input 932 * (e.g. from derived classes that override the textview's 933 * #GtkWidget::key-press-event handler). 934 * 935 * Since: 3.20 936 */ 937 public void resetCursorBlink() 938 { 939 gtk_text_view_reset_cursor_blink(gtkTextView); 940 } 941 942 /** 943 * Reset the input method context of the text view if needed. 944 * 945 * This can be necessary in the case where modifying the buffer 946 * would confuse on-going input method behavior. 947 * 948 * Since: 2.22 949 */ 950 public void resetImContext() 951 { 952 gtk_text_view_reset_im_context(gtkTextView); 953 } 954 955 /** 956 * Scrolls @text_view the minimum distance such that @mark is contained 957 * within the visible area of the widget. 958 * 959 * Params: 960 * mark = a mark in the buffer for @text_view 961 */ 962 public void scrollMarkOnscreen(TextMark mark) 963 { 964 gtk_text_view_scroll_mark_onscreen(gtkTextView, (mark is null) ? null : mark.getTextMarkStruct()); 965 } 966 967 /** 968 * Scrolls @text_view so that @iter is on the screen in the position 969 * indicated by @xalign and @yalign. An alignment of 0.0 indicates 970 * left or top, 1.0 indicates right or bottom, 0.5 means center. 971 * If @use_align is %FALSE, the text scrolls the minimal distance to 972 * get the mark onscreen, possibly not scrolling at all. The effective 973 * screen for purposes of this function is reduced by a margin of size 974 * @within_margin. 975 * 976 * Note that this function uses the currently-computed height of the 977 * lines in the text buffer. Line heights are computed in an idle 978 * handler; so this function may not have the desired effect if it’s 979 * called before the height computations. To avoid oddness, consider 980 * using gtk_text_view_scroll_to_mark() which saves a point to be 981 * scrolled to after line validation. 982 * 983 * Params: 984 * iter = a #GtkTextIter 985 * withinMargin = margin as a [0.0,0.5) fraction of screen size 986 * useAlign = whether to use alignment arguments (if %FALSE, 987 * just get the mark onscreen) 988 * xalign = horizontal alignment of mark within visible area 989 * yalign = vertical alignment of mark within visible area 990 * 991 * Returns: %TRUE if scrolling occurred 992 */ 993 public bool scrollToIter(TextIter iter, double withinMargin, bool useAlign, double xalign, double yalign) 994 { 995 return gtk_text_view_scroll_to_iter(gtkTextView, (iter is null) ? null : iter.getTextIterStruct(), withinMargin, useAlign, xalign, yalign) != 0; 996 } 997 998 /** 999 * Scrolls @text_view so that @mark is on the screen in the position 1000 * indicated by @xalign and @yalign. An alignment of 0.0 indicates 1001 * left or top, 1.0 indicates right or bottom, 0.5 means center. 1002 * If @use_align is %FALSE, the text scrolls the minimal distance to 1003 * get the mark onscreen, possibly not scrolling at all. The effective 1004 * screen for purposes of this function is reduced by a margin of size 1005 * @within_margin. 1006 * 1007 * Params: 1008 * mark = a #GtkTextMark 1009 * withinMargin = margin as a [0.0,0.5) fraction of screen size 1010 * useAlign = whether to use alignment arguments (if %FALSE, just 1011 * get the mark onscreen) 1012 * xalign = horizontal alignment of mark within visible area 1013 * yalign = vertical alignment of mark within visible area 1014 */ 1015 public void scrollToMark(TextMark mark, double withinMargin, bool useAlign, double xalign, double yalign) 1016 { 1017 gtk_text_view_scroll_to_mark(gtkTextView, (mark is null) ? null : mark.getTextMarkStruct(), withinMargin, useAlign, xalign, yalign); 1018 } 1019 1020 /** 1021 * Sets the behavior of the text widget when the Tab key is pressed. 1022 * If @accepts_tab is %TRUE, a tab character is inserted. If @accepts_tab 1023 * is %FALSE the keyboard focus is moved to the next widget in the focus 1024 * chain. 1025 * 1026 * Params: 1027 * acceptsTab = %TRUE if pressing the Tab key should insert a tab 1028 * character, %FALSE, if pressing the Tab key should move the 1029 * keyboard focus. 1030 * 1031 * Since: 2.4 1032 */ 1033 public void setAcceptsTab(bool acceptsTab) 1034 { 1035 gtk_text_view_set_accepts_tab(gtkTextView, acceptsTab); 1036 } 1037 1038 /** 1039 * Sets the width of %GTK_TEXT_WINDOW_LEFT or %GTK_TEXT_WINDOW_RIGHT, 1040 * or the height of %GTK_TEXT_WINDOW_TOP or %GTK_TEXT_WINDOW_BOTTOM. 1041 * Automatically destroys the corresponding window if the size is set 1042 * to 0, and creates the window if the size is set to non-zero. This 1043 * function can only be used for the “border windows”, and it won’t 1044 * work with %GTK_TEXT_WINDOW_WIDGET, %GTK_TEXT_WINDOW_TEXT, or 1045 * %GTK_TEXT_WINDOW_PRIVATE. 1046 * 1047 * Params: 1048 * type = window to affect 1049 * size = width or height of the window 1050 */ 1051 public void setBorderWindowSize(GtkTextWindowType type, int size) 1052 { 1053 gtk_text_view_set_border_window_size(gtkTextView, type, size); 1054 } 1055 1056 /** 1057 * Sets the bottom margin for text in @text_view. 1058 * 1059 * Note that this function is confusingly named. 1060 * In CSS terms, the value set here is padding. 1061 * 1062 * Params: 1063 * bottomMargin = bottom margin in pixels 1064 * 1065 * Since: 3.18 1066 */ 1067 public void setBottomMargin(int bottomMargin) 1068 { 1069 gtk_text_view_set_bottom_margin(gtkTextView, bottomMargin); 1070 } 1071 1072 /** 1073 * Sets @buffer as the buffer being displayed by @text_view. The previous 1074 * buffer displayed by the text view is unreferenced, and a reference is 1075 * added to @buffer. If you owned a reference to @buffer before passing it 1076 * to this function, you must remove that reference yourself; #GtkTextView 1077 * will not “adopt” it. 1078 * 1079 * Params: 1080 * buffer = a #GtkTextBuffer 1081 */ 1082 public void setBuffer(TextBuffer buffer) 1083 { 1084 gtk_text_view_set_buffer(gtkTextView, (buffer is null) ? null : buffer.getTextBufferStruct()); 1085 } 1086 1087 /** 1088 * Toggles whether the insertion point should be displayed. A buffer with 1089 * no editable text probably shouldn’t have a visible cursor, so you may 1090 * want to turn the cursor off. 1091 * 1092 * Note that this property may be overridden by the 1093 * #GtkSettings:gtk-keynave-use-caret settings. 1094 * 1095 * Params: 1096 * setting = whether to show the insertion cursor 1097 */ 1098 public void setCursorVisible(bool setting) 1099 { 1100 gtk_text_view_set_cursor_visible(gtkTextView, setting); 1101 } 1102 1103 /** 1104 * Sets the default editability of the #GtkTextView. You can override 1105 * this default setting with tags in the buffer, using the “editable” 1106 * attribute of tags. 1107 * 1108 * Params: 1109 * setting = whether it’s editable 1110 */ 1111 public void setEditable(bool setting) 1112 { 1113 gtk_text_view_set_editable(gtkTextView, setting); 1114 } 1115 1116 /** 1117 * Sets the default indentation for paragraphs in @text_view. 1118 * Tags in the buffer may override the default. 1119 * 1120 * Params: 1121 * indent = indentation in pixels 1122 */ 1123 public void setIndent(int indent) 1124 { 1125 gtk_text_view_set_indent(gtkTextView, indent); 1126 } 1127 1128 /** 1129 * Sets the #GtkTextView:input-hints property, which 1130 * allows input methods to fine-tune their behaviour. 1131 * 1132 * Params: 1133 * hints = the hints 1134 * 1135 * Since: 3.6 1136 */ 1137 public void setInputHints(GtkInputHints hints) 1138 { 1139 gtk_text_view_set_input_hints(gtkTextView, hints); 1140 } 1141 1142 /** 1143 * Sets the #GtkTextView:input-purpose property which 1144 * can be used by on-screen keyboards and other input 1145 * methods to adjust their behaviour. 1146 * 1147 * Params: 1148 * purpose = the purpose 1149 * 1150 * Since: 3.6 1151 */ 1152 public void setInputPurpose(GtkInputPurpose purpose) 1153 { 1154 gtk_text_view_set_input_purpose(gtkTextView, purpose); 1155 } 1156 1157 /** 1158 * Sets the default justification of text in @text_view. 1159 * Tags in the view’s buffer may override the default. 1160 * 1161 * Params: 1162 * justification = justification 1163 */ 1164 public void setJustification(GtkJustification justification) 1165 { 1166 gtk_text_view_set_justification(gtkTextView, justification); 1167 } 1168 1169 /** 1170 * Sets the default left margin for text in @text_view. 1171 * Tags in the buffer may override the default. 1172 * 1173 * Note that this function is confusingly named. 1174 * In CSS terms, the value set here is padding. 1175 * 1176 * Params: 1177 * leftMargin = left margin in pixels 1178 */ 1179 public void setLeftMargin(int leftMargin) 1180 { 1181 gtk_text_view_set_left_margin(gtkTextView, leftMargin); 1182 } 1183 1184 /** 1185 * Sets the #GtkTextView:monospace property, which 1186 * indicates that the text view should use monospace 1187 * fonts. 1188 * 1189 * Params: 1190 * monospace = %TRUE to request monospace styling 1191 * 1192 * Since: 3.16 1193 */ 1194 public void setMonospace(bool monospace) 1195 { 1196 gtk_text_view_set_monospace(gtkTextView, monospace); 1197 } 1198 1199 /** 1200 * Changes the #GtkTextView overwrite mode. 1201 * 1202 * Params: 1203 * overwrite = %TRUE to turn on overwrite mode, %FALSE to turn it off 1204 * 1205 * Since: 2.4 1206 */ 1207 public void setOverwrite(bool overwrite) 1208 { 1209 gtk_text_view_set_overwrite(gtkTextView, overwrite); 1210 } 1211 1212 /** 1213 * Sets the default number of blank pixels above paragraphs in @text_view. 1214 * Tags in the buffer for @text_view may override the defaults. 1215 * 1216 * Params: 1217 * pixelsAboveLines = pixels above paragraphs 1218 */ 1219 public void setPixelsAboveLines(int pixelsAboveLines) 1220 { 1221 gtk_text_view_set_pixels_above_lines(gtkTextView, pixelsAboveLines); 1222 } 1223 1224 /** 1225 * Sets the default number of pixels of blank space 1226 * to put below paragraphs in @text_view. May be overridden 1227 * by tags applied to @text_view’s buffer. 1228 * 1229 * Params: 1230 * pixelsBelowLines = pixels below paragraphs 1231 */ 1232 public void setPixelsBelowLines(int pixelsBelowLines) 1233 { 1234 gtk_text_view_set_pixels_below_lines(gtkTextView, pixelsBelowLines); 1235 } 1236 1237 /** 1238 * Sets the default number of pixels of blank space to leave between 1239 * display/wrapped lines within a paragraph. May be overridden by 1240 * tags in @text_view’s buffer. 1241 * 1242 * Params: 1243 * pixelsInsideWrap = default number of pixels between wrapped lines 1244 */ 1245 public void setPixelsInsideWrap(int pixelsInsideWrap) 1246 { 1247 gtk_text_view_set_pixels_inside_wrap(gtkTextView, pixelsInsideWrap); 1248 } 1249 1250 /** 1251 * Sets the default right margin for text in the text view. 1252 * Tags in the buffer may override the default. 1253 * 1254 * Note that this function is confusingly named. 1255 * In CSS terms, the value set here is padding. 1256 * 1257 * Params: 1258 * rightMargin = right margin in pixels 1259 */ 1260 public void setRightMargin(int rightMargin) 1261 { 1262 gtk_text_view_set_right_margin(gtkTextView, rightMargin); 1263 } 1264 1265 /** 1266 * Sets the default tab stops for paragraphs in @text_view. 1267 * Tags in the buffer may override the default. 1268 * 1269 * Params: 1270 * tabs = tabs as a #PangoTabArray 1271 */ 1272 public void setTabs(PgTabArray tabs) 1273 { 1274 gtk_text_view_set_tabs(gtkTextView, (tabs is null) ? null : tabs.getPgTabArrayStruct()); 1275 } 1276 1277 /** 1278 * Sets the top margin for text in @text_view. 1279 * 1280 * Note that this function is confusingly named. 1281 * In CSS terms, the value set here is padding. 1282 * 1283 * Params: 1284 * topMargin = top margin in pixels 1285 * 1286 * Since: 3.18 1287 */ 1288 public void setTopMargin(int topMargin) 1289 { 1290 gtk_text_view_set_top_margin(gtkTextView, topMargin); 1291 } 1292 1293 /** 1294 * Sets the line wrapping for the view. 1295 * 1296 * Params: 1297 * wrapMode = a #GtkWrapMode 1298 */ 1299 public void setWrapMode(GtkWrapMode wrapMode) 1300 { 1301 gtk_text_view_set_wrap_mode(gtkTextView, wrapMode); 1302 } 1303 1304 /** 1305 * Determines whether @iter is at the start of a display line. 1306 * See gtk_text_view_forward_display_line() for an explanation of 1307 * display lines vs. paragraphs. 1308 * 1309 * Params: 1310 * iter = a #GtkTextIter 1311 * 1312 * Returns: %TRUE if @iter begins a wrapped line 1313 */ 1314 public bool startsDisplayLine(TextIter iter) 1315 { 1316 return gtk_text_view_starts_display_line(gtkTextView, (iter is null) ? null : iter.getTextIterStruct()) != 0; 1317 } 1318 1319 /** 1320 * Converts coordinates on the window identified by @win to buffer 1321 * coordinates, storing the result in (@buffer_x,@buffer_y). 1322 * 1323 * Note that you can’t convert coordinates for a nonexisting window (see 1324 * gtk_text_view_set_border_window_size()). 1325 * 1326 * Params: 1327 * win = a #GtkTextWindowType except %GTK_TEXT_WINDOW_PRIVATE 1328 * windowX = window x coordinate 1329 * windowY = window y coordinate 1330 * bufferX = buffer x coordinate return location or %NULL 1331 * bufferY = buffer y coordinate return location or %NULL 1332 */ 1333 public void windowToBufferCoords(GtkTextWindowType win, int windowX, int windowY, out int bufferX, out int bufferY) 1334 { 1335 gtk_text_view_window_to_buffer_coords(gtkTextView, win, windowX, windowY, &bufferX, &bufferY); 1336 } 1337 1338 protected class OnBackspaceDelegateWrapper 1339 { 1340 void delegate(TextView) dlg; 1341 gulong handlerId; 1342 1343 this(void delegate(TextView) dlg) 1344 { 1345 this.dlg = dlg; 1346 onBackspaceListeners ~= this; 1347 } 1348 1349 void remove(OnBackspaceDelegateWrapper source) 1350 { 1351 foreach(index, wrapper; onBackspaceListeners) 1352 { 1353 if (wrapper.handlerId == source.handlerId) 1354 { 1355 onBackspaceListeners[index] = null; 1356 onBackspaceListeners = std.algorithm.remove(onBackspaceListeners, index); 1357 break; 1358 } 1359 } 1360 } 1361 } 1362 OnBackspaceDelegateWrapper[] onBackspaceListeners; 1363 1364 /** 1365 * The ::backspace signal is a 1366 * [keybinding signal][GtkBindingSignal] 1367 * which gets emitted when the user asks for it. 1368 * 1369 * The default bindings for this signal are 1370 * Backspace and Shift-Backspace. 1371 */ 1372 gulong addOnBackspace(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1373 { 1374 auto wrapper = new OnBackspaceDelegateWrapper(dlg); 1375 wrapper.handlerId = Signals.connectData( 1376 this, 1377 "backspace", 1378 cast(GCallback)&callBackBackspace, 1379 cast(void*)wrapper, 1380 cast(GClosureNotify)&callBackBackspaceDestroy, 1381 connectFlags); 1382 return wrapper.handlerId; 1383 } 1384 1385 extern(C) static void callBackBackspace(GtkTextView* textviewStruct, OnBackspaceDelegateWrapper wrapper) 1386 { 1387 wrapper.dlg(wrapper.outer); 1388 } 1389 1390 extern(C) static void callBackBackspaceDestroy(OnBackspaceDelegateWrapper wrapper, GClosure* closure) 1391 { 1392 wrapper.remove(wrapper); 1393 } 1394 1395 protected class OnCopyClipboardDelegateWrapper 1396 { 1397 void delegate(TextView) dlg; 1398 gulong handlerId; 1399 1400 this(void delegate(TextView) dlg) 1401 { 1402 this.dlg = dlg; 1403 onCopyClipboardListeners ~= this; 1404 } 1405 1406 void remove(OnCopyClipboardDelegateWrapper source) 1407 { 1408 foreach(index, wrapper; onCopyClipboardListeners) 1409 { 1410 if (wrapper.handlerId == source.handlerId) 1411 { 1412 onCopyClipboardListeners[index] = null; 1413 onCopyClipboardListeners = std.algorithm.remove(onCopyClipboardListeners, index); 1414 break; 1415 } 1416 } 1417 } 1418 } 1419 OnCopyClipboardDelegateWrapper[] onCopyClipboardListeners; 1420 1421 /** 1422 * The ::copy-clipboard signal is a 1423 * [keybinding signal][GtkBindingSignal] 1424 * which gets emitted to copy the selection to the clipboard. 1425 * 1426 * The default bindings for this signal are 1427 * Ctrl-c and Ctrl-Insert. 1428 */ 1429 gulong addOnCopyClipboard(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1430 { 1431 auto wrapper = new OnCopyClipboardDelegateWrapper(dlg); 1432 wrapper.handlerId = Signals.connectData( 1433 this, 1434 "copy-clipboard", 1435 cast(GCallback)&callBackCopyClipboard, 1436 cast(void*)wrapper, 1437 cast(GClosureNotify)&callBackCopyClipboardDestroy, 1438 connectFlags); 1439 return wrapper.handlerId; 1440 } 1441 1442 extern(C) static void callBackCopyClipboard(GtkTextView* textviewStruct, OnCopyClipboardDelegateWrapper wrapper) 1443 { 1444 wrapper.dlg(wrapper.outer); 1445 } 1446 1447 extern(C) static void callBackCopyClipboardDestroy(OnCopyClipboardDelegateWrapper wrapper, GClosure* closure) 1448 { 1449 wrapper.remove(wrapper); 1450 } 1451 1452 protected class OnCutClipboardDelegateWrapper 1453 { 1454 void delegate(TextView) dlg; 1455 gulong handlerId; 1456 1457 this(void delegate(TextView) dlg) 1458 { 1459 this.dlg = dlg; 1460 onCutClipboardListeners ~= this; 1461 } 1462 1463 void remove(OnCutClipboardDelegateWrapper source) 1464 { 1465 foreach(index, wrapper; onCutClipboardListeners) 1466 { 1467 if (wrapper.handlerId == source.handlerId) 1468 { 1469 onCutClipboardListeners[index] = null; 1470 onCutClipboardListeners = std.algorithm.remove(onCutClipboardListeners, index); 1471 break; 1472 } 1473 } 1474 } 1475 } 1476 OnCutClipboardDelegateWrapper[] onCutClipboardListeners; 1477 1478 /** 1479 * The ::cut-clipboard signal is a 1480 * [keybinding signal][GtkBindingSignal] 1481 * which gets emitted to cut the selection to the clipboard. 1482 * 1483 * The default bindings for this signal are 1484 * Ctrl-x and Shift-Delete. 1485 */ 1486 gulong addOnCutClipboard(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1487 { 1488 auto wrapper = new OnCutClipboardDelegateWrapper(dlg); 1489 wrapper.handlerId = Signals.connectData( 1490 this, 1491 "cut-clipboard", 1492 cast(GCallback)&callBackCutClipboard, 1493 cast(void*)wrapper, 1494 cast(GClosureNotify)&callBackCutClipboardDestroy, 1495 connectFlags); 1496 return wrapper.handlerId; 1497 } 1498 1499 extern(C) static void callBackCutClipboard(GtkTextView* textviewStruct, OnCutClipboardDelegateWrapper wrapper) 1500 { 1501 wrapper.dlg(wrapper.outer); 1502 } 1503 1504 extern(C) static void callBackCutClipboardDestroy(OnCutClipboardDelegateWrapper wrapper, GClosure* closure) 1505 { 1506 wrapper.remove(wrapper); 1507 } 1508 1509 protected class OnDeleteFromCursorDelegateWrapper 1510 { 1511 void delegate(GtkDeleteType, int, TextView) dlg; 1512 gulong handlerId; 1513 1514 this(void delegate(GtkDeleteType, int, TextView) dlg) 1515 { 1516 this.dlg = dlg; 1517 onDeleteFromCursorListeners ~= this; 1518 } 1519 1520 void remove(OnDeleteFromCursorDelegateWrapper source) 1521 { 1522 foreach(index, wrapper; onDeleteFromCursorListeners) 1523 { 1524 if (wrapper.handlerId == source.handlerId) 1525 { 1526 onDeleteFromCursorListeners[index] = null; 1527 onDeleteFromCursorListeners = std.algorithm.remove(onDeleteFromCursorListeners, index); 1528 break; 1529 } 1530 } 1531 } 1532 } 1533 OnDeleteFromCursorDelegateWrapper[] onDeleteFromCursorListeners; 1534 1535 /** 1536 * The ::delete-from-cursor signal is a 1537 * [keybinding signal][GtkBindingSignal] 1538 * which gets emitted when the user initiates a text deletion. 1539 * 1540 * If the @type is %GTK_DELETE_CHARS, GTK+ deletes the selection 1541 * if there is one, otherwise it deletes the requested number 1542 * of characters. 1543 * 1544 * The default bindings for this signal are 1545 * Delete for deleting a character, Ctrl-Delete for 1546 * deleting a word and Ctrl-Backspace for deleting a word 1547 * backwords. 1548 * 1549 * Params: 1550 * type = the granularity of the deletion, as a #GtkDeleteType 1551 * count = the number of @type units to delete 1552 */ 1553 gulong addOnDeleteFromCursor(void delegate(GtkDeleteType, int, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1554 { 1555 auto wrapper = new OnDeleteFromCursorDelegateWrapper(dlg); 1556 wrapper.handlerId = Signals.connectData( 1557 this, 1558 "delete-from-cursor", 1559 cast(GCallback)&callBackDeleteFromCursor, 1560 cast(void*)wrapper, 1561 cast(GClosureNotify)&callBackDeleteFromCursorDestroy, 1562 connectFlags); 1563 return wrapper.handlerId; 1564 } 1565 1566 extern(C) static void callBackDeleteFromCursor(GtkTextView* textviewStruct, GtkDeleteType type, int count, OnDeleteFromCursorDelegateWrapper wrapper) 1567 { 1568 wrapper.dlg(type, count, wrapper.outer); 1569 } 1570 1571 extern(C) static void callBackDeleteFromCursorDestroy(OnDeleteFromCursorDelegateWrapper wrapper, GClosure* closure) 1572 { 1573 wrapper.remove(wrapper); 1574 } 1575 1576 protected class OnExtendSelectionDelegateWrapper 1577 { 1578 bool delegate(GtkTextExtendSelection, TextIter, TextIter, TextIter, TextView) dlg; 1579 gulong handlerId; 1580 1581 this(bool delegate(GtkTextExtendSelection, TextIter, TextIter, TextIter, TextView) dlg) 1582 { 1583 this.dlg = dlg; 1584 onExtendSelectionListeners ~= this; 1585 } 1586 1587 void remove(OnExtendSelectionDelegateWrapper source) 1588 { 1589 foreach(index, wrapper; onExtendSelectionListeners) 1590 { 1591 if (wrapper.handlerId == source.handlerId) 1592 { 1593 onExtendSelectionListeners[index] = null; 1594 onExtendSelectionListeners = std.algorithm.remove(onExtendSelectionListeners, index); 1595 break; 1596 } 1597 } 1598 } 1599 } 1600 OnExtendSelectionDelegateWrapper[] onExtendSelectionListeners; 1601 1602 /** 1603 * The ::extend-selection signal is emitted when the selection needs to be 1604 * extended at @location. 1605 * 1606 * Params: 1607 * granularity = the granularity type 1608 * location = the location where to extend the selection 1609 * start = where the selection should start 1610 * end = where the selection should end 1611 * 1612 * Returns: %GDK_EVENT_STOP to stop other handlers from being invoked for the 1613 * event. %GDK_EVENT_PROPAGATE to propagate the event further. 1614 * 1615 * Since: 3.16 1616 */ 1617 gulong addOnExtendSelection(bool delegate(GtkTextExtendSelection, TextIter, TextIter, TextIter, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1618 { 1619 auto wrapper = new OnExtendSelectionDelegateWrapper(dlg); 1620 wrapper.handlerId = Signals.connectData( 1621 this, 1622 "extend-selection", 1623 cast(GCallback)&callBackExtendSelection, 1624 cast(void*)wrapper, 1625 cast(GClosureNotify)&callBackExtendSelectionDestroy, 1626 connectFlags); 1627 return wrapper.handlerId; 1628 } 1629 1630 extern(C) static int callBackExtendSelection(GtkTextView* textviewStruct, GtkTextExtendSelection granularity, GtkTextIter* location, GtkTextIter* start, GtkTextIter* end, OnExtendSelectionDelegateWrapper wrapper) 1631 { 1632 return wrapper.dlg(granularity, ObjectG.getDObject!(TextIter)(location), ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), wrapper.outer); 1633 } 1634 1635 extern(C) static void callBackExtendSelectionDestroy(OnExtendSelectionDelegateWrapper wrapper, GClosure* closure) 1636 { 1637 wrapper.remove(wrapper); 1638 } 1639 1640 protected class OnInsertAtCursorDelegateWrapper 1641 { 1642 void delegate(string, TextView) dlg; 1643 gulong handlerId; 1644 1645 this(void delegate(string, TextView) dlg) 1646 { 1647 this.dlg = dlg; 1648 onInsertAtCursorListeners ~= this; 1649 } 1650 1651 void remove(OnInsertAtCursorDelegateWrapper source) 1652 { 1653 foreach(index, wrapper; onInsertAtCursorListeners) 1654 { 1655 if (wrapper.handlerId == source.handlerId) 1656 { 1657 onInsertAtCursorListeners[index] = null; 1658 onInsertAtCursorListeners = std.algorithm.remove(onInsertAtCursorListeners, index); 1659 break; 1660 } 1661 } 1662 } 1663 } 1664 OnInsertAtCursorDelegateWrapper[] onInsertAtCursorListeners; 1665 1666 /** 1667 * The ::insert-at-cursor signal is a 1668 * [keybinding signal][GtkBindingSignal] 1669 * which gets emitted when the user initiates the insertion of a 1670 * fixed string at the cursor. 1671 * 1672 * This signal has no default bindings. 1673 * 1674 * Params: 1675 * str = the string to insert 1676 */ 1677 gulong addOnInsertAtCursor(void delegate(string, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1678 { 1679 auto wrapper = new OnInsertAtCursorDelegateWrapper(dlg); 1680 wrapper.handlerId = Signals.connectData( 1681 this, 1682 "insert-at-cursor", 1683 cast(GCallback)&callBackInsertAtCursor, 1684 cast(void*)wrapper, 1685 cast(GClosureNotify)&callBackInsertAtCursorDestroy, 1686 connectFlags); 1687 return wrapper.handlerId; 1688 } 1689 1690 extern(C) static void callBackInsertAtCursor(GtkTextView* textviewStruct, char* str, OnInsertAtCursorDelegateWrapper wrapper) 1691 { 1692 wrapper.dlg(Str.toString(str), wrapper.outer); 1693 } 1694 1695 extern(C) static void callBackInsertAtCursorDestroy(OnInsertAtCursorDelegateWrapper wrapper, GClosure* closure) 1696 { 1697 wrapper.remove(wrapper); 1698 } 1699 1700 protected class OnMoveCursorDelegateWrapper 1701 { 1702 void delegate(GtkMovementStep, int, bool, TextView) dlg; 1703 gulong handlerId; 1704 1705 this(void delegate(GtkMovementStep, int, bool, TextView) dlg) 1706 { 1707 this.dlg = dlg; 1708 onMoveCursorListeners ~= this; 1709 } 1710 1711 void remove(OnMoveCursorDelegateWrapper source) 1712 { 1713 foreach(index, wrapper; onMoveCursorListeners) 1714 { 1715 if (wrapper.handlerId == source.handlerId) 1716 { 1717 onMoveCursorListeners[index] = null; 1718 onMoveCursorListeners = std.algorithm.remove(onMoveCursorListeners, index); 1719 break; 1720 } 1721 } 1722 } 1723 } 1724 OnMoveCursorDelegateWrapper[] onMoveCursorListeners; 1725 1726 /** 1727 * The ::move-cursor signal is a 1728 * [keybinding signal][GtkBindingSignal] 1729 * which gets emitted when the user initiates a cursor movement. 1730 * If the cursor is not visible in @text_view, this signal causes 1731 * the viewport to be moved instead. 1732 * 1733 * Applications should not connect to it, but may emit it with 1734 * g_signal_emit_by_name() if they need to control the cursor 1735 * programmatically. 1736 * 1737 * The default bindings for this signal come in two variants, 1738 * the variant with the Shift modifier extends the selection, 1739 * the variant without the Shift modifer does not. 1740 * There are too many key combinations to list them all here. 1741 * - Arrow keys move by individual characters/lines 1742 * - Ctrl-arrow key combinations move by words/paragraphs 1743 * - Home/End keys move to the ends of the buffer 1744 * - PageUp/PageDown keys move vertically by pages 1745 * - Ctrl-PageUp/PageDown keys move horizontally by pages 1746 * 1747 * Params: 1748 * step = the granularity of the move, as a #GtkMovementStep 1749 * count = the number of @step units to move 1750 * extendSelection = %TRUE if the move should extend the selection 1751 */ 1752 gulong addOnMoveCursor(void delegate(GtkMovementStep, int, bool, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1753 { 1754 auto wrapper = new OnMoveCursorDelegateWrapper(dlg); 1755 wrapper.handlerId = Signals.connectData( 1756 this, 1757 "move-cursor", 1758 cast(GCallback)&callBackMoveCursor, 1759 cast(void*)wrapper, 1760 cast(GClosureNotify)&callBackMoveCursorDestroy, 1761 connectFlags); 1762 return wrapper.handlerId; 1763 } 1764 1765 extern(C) static void callBackMoveCursor(GtkTextView* textviewStruct, GtkMovementStep step, int count, bool extendSelection, OnMoveCursorDelegateWrapper wrapper) 1766 { 1767 wrapper.dlg(step, count, extendSelection, wrapper.outer); 1768 } 1769 1770 extern(C) static void callBackMoveCursorDestroy(OnMoveCursorDelegateWrapper wrapper, GClosure* closure) 1771 { 1772 wrapper.remove(wrapper); 1773 } 1774 1775 protected class OnMoveViewportDelegateWrapper 1776 { 1777 void delegate(GtkScrollStep, int, TextView) dlg; 1778 gulong handlerId; 1779 1780 this(void delegate(GtkScrollStep, int, TextView) dlg) 1781 { 1782 this.dlg = dlg; 1783 onMoveViewportListeners ~= this; 1784 } 1785 1786 void remove(OnMoveViewportDelegateWrapper source) 1787 { 1788 foreach(index, wrapper; onMoveViewportListeners) 1789 { 1790 if (wrapper.handlerId == source.handlerId) 1791 { 1792 onMoveViewportListeners[index] = null; 1793 onMoveViewportListeners = std.algorithm.remove(onMoveViewportListeners, index); 1794 break; 1795 } 1796 } 1797 } 1798 } 1799 OnMoveViewportDelegateWrapper[] onMoveViewportListeners; 1800 1801 /** 1802 * The ::move-viewport signal is a 1803 * [keybinding signal][GtkBindingSignal] 1804 * which can be bound to key combinations to allow the user 1805 * to move the viewport, i.e. change what part of the text view 1806 * is visible in a containing scrolled window. 1807 * 1808 * There are no default bindings for this signal. 1809 * 1810 * Params: 1811 * step = the granularity of the movement, as a #GtkScrollStep 1812 * count = the number of @step units to move 1813 */ 1814 gulong addOnMoveViewport(void delegate(GtkScrollStep, int, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1815 { 1816 auto wrapper = new OnMoveViewportDelegateWrapper(dlg); 1817 wrapper.handlerId = Signals.connectData( 1818 this, 1819 "move-viewport", 1820 cast(GCallback)&callBackMoveViewport, 1821 cast(void*)wrapper, 1822 cast(GClosureNotify)&callBackMoveViewportDestroy, 1823 connectFlags); 1824 return wrapper.handlerId; 1825 } 1826 1827 extern(C) static void callBackMoveViewport(GtkTextView* textviewStruct, GtkScrollStep step, int count, OnMoveViewportDelegateWrapper wrapper) 1828 { 1829 wrapper.dlg(step, count, wrapper.outer); 1830 } 1831 1832 extern(C) static void callBackMoveViewportDestroy(OnMoveViewportDelegateWrapper wrapper, GClosure* closure) 1833 { 1834 wrapper.remove(wrapper); 1835 } 1836 1837 protected class OnPasteClipboardDelegateWrapper 1838 { 1839 void delegate(TextView) dlg; 1840 gulong handlerId; 1841 1842 this(void delegate(TextView) dlg) 1843 { 1844 this.dlg = dlg; 1845 onPasteClipboardListeners ~= this; 1846 } 1847 1848 void remove(OnPasteClipboardDelegateWrapper source) 1849 { 1850 foreach(index, wrapper; onPasteClipboardListeners) 1851 { 1852 if (wrapper.handlerId == source.handlerId) 1853 { 1854 onPasteClipboardListeners[index] = null; 1855 onPasteClipboardListeners = std.algorithm.remove(onPasteClipboardListeners, index); 1856 break; 1857 } 1858 } 1859 } 1860 } 1861 OnPasteClipboardDelegateWrapper[] onPasteClipboardListeners; 1862 1863 /** 1864 * The ::paste-clipboard signal is a 1865 * [keybinding signal][GtkBindingSignal] 1866 * which gets emitted to paste the contents of the clipboard 1867 * into the text view. 1868 * 1869 * The default bindings for this signal are 1870 * Ctrl-v and Shift-Insert. 1871 */ 1872 gulong addOnPasteClipboard(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1873 { 1874 auto wrapper = new OnPasteClipboardDelegateWrapper(dlg); 1875 wrapper.handlerId = Signals.connectData( 1876 this, 1877 "paste-clipboard", 1878 cast(GCallback)&callBackPasteClipboard, 1879 cast(void*)wrapper, 1880 cast(GClosureNotify)&callBackPasteClipboardDestroy, 1881 connectFlags); 1882 return wrapper.handlerId; 1883 } 1884 1885 extern(C) static void callBackPasteClipboard(GtkTextView* textviewStruct, OnPasteClipboardDelegateWrapper wrapper) 1886 { 1887 wrapper.dlg(wrapper.outer); 1888 } 1889 1890 extern(C) static void callBackPasteClipboardDestroy(OnPasteClipboardDelegateWrapper wrapper, GClosure* closure) 1891 { 1892 wrapper.remove(wrapper); 1893 } 1894 1895 protected class OnPopulatePopupDelegateWrapper 1896 { 1897 void delegate(Widget, TextView) dlg; 1898 gulong handlerId; 1899 1900 this(void delegate(Widget, TextView) dlg) 1901 { 1902 this.dlg = dlg; 1903 onPopulatePopupListeners ~= this; 1904 } 1905 1906 void remove(OnPopulatePopupDelegateWrapper source) 1907 { 1908 foreach(index, wrapper; onPopulatePopupListeners) 1909 { 1910 if (wrapper.handlerId == source.handlerId) 1911 { 1912 onPopulatePopupListeners[index] = null; 1913 onPopulatePopupListeners = std.algorithm.remove(onPopulatePopupListeners, index); 1914 break; 1915 } 1916 } 1917 } 1918 } 1919 OnPopulatePopupDelegateWrapper[] onPopulatePopupListeners; 1920 1921 /** 1922 * The ::populate-popup signal gets emitted before showing the 1923 * context menu of the text view. 1924 * 1925 * If you need to add items to the context menu, connect 1926 * to this signal and append your items to the @popup, which 1927 * will be a #GtkMenu in this case. 1928 * 1929 * If #GtkTextView:populate-all is %TRUE, this signal will 1930 * also be emitted to populate touch popups. In this case, 1931 * @popup will be a different container, e.g. a #GtkToolbar. 1932 * 1933 * The signal handler should not make assumptions about the 1934 * type of @widget, but check whether @popup is a #GtkMenu 1935 * or #GtkToolbar or another kind of container. 1936 * 1937 * Params: 1938 * popup = the container that is being populated 1939 */ 1940 gulong addOnPopulatePopup(void delegate(Widget, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1941 { 1942 auto wrapper = new OnPopulatePopupDelegateWrapper(dlg); 1943 wrapper.handlerId = Signals.connectData( 1944 this, 1945 "populate-popup", 1946 cast(GCallback)&callBackPopulatePopup, 1947 cast(void*)wrapper, 1948 cast(GClosureNotify)&callBackPopulatePopupDestroy, 1949 connectFlags); 1950 return wrapper.handlerId; 1951 } 1952 1953 extern(C) static void callBackPopulatePopup(GtkTextView* textviewStruct, GtkWidget* popup, OnPopulatePopupDelegateWrapper wrapper) 1954 { 1955 wrapper.dlg(ObjectG.getDObject!(Widget)(popup), wrapper.outer); 1956 } 1957 1958 extern(C) static void callBackPopulatePopupDestroy(OnPopulatePopupDelegateWrapper wrapper, GClosure* closure) 1959 { 1960 wrapper.remove(wrapper); 1961 } 1962 1963 protected class OnPreeditChangedDelegateWrapper 1964 { 1965 void delegate(string, TextView) dlg; 1966 gulong handlerId; 1967 1968 this(void delegate(string, TextView) dlg) 1969 { 1970 this.dlg = dlg; 1971 onPreeditChangedListeners ~= this; 1972 } 1973 1974 void remove(OnPreeditChangedDelegateWrapper source) 1975 { 1976 foreach(index, wrapper; onPreeditChangedListeners) 1977 { 1978 if (wrapper.handlerId == source.handlerId) 1979 { 1980 onPreeditChangedListeners[index] = null; 1981 onPreeditChangedListeners = std.algorithm.remove(onPreeditChangedListeners, index); 1982 break; 1983 } 1984 } 1985 } 1986 } 1987 OnPreeditChangedDelegateWrapper[] onPreeditChangedListeners; 1988 1989 /** 1990 * If an input method is used, the typed text will not immediately 1991 * be committed to the buffer. So if you are interested in the text, 1992 * connect to this signal. 1993 * 1994 * This signal is only emitted if the text at the given position 1995 * is actually editable. 1996 * 1997 * Params: 1998 * preedit = the current preedit string 1999 * 2000 * Since: 2.20 2001 */ 2002 gulong addOnPreeditChanged(void delegate(string, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2003 { 2004 auto wrapper = new OnPreeditChangedDelegateWrapper(dlg); 2005 wrapper.handlerId = Signals.connectData( 2006 this, 2007 "preedit-changed", 2008 cast(GCallback)&callBackPreeditChanged, 2009 cast(void*)wrapper, 2010 cast(GClosureNotify)&callBackPreeditChangedDestroy, 2011 connectFlags); 2012 return wrapper.handlerId; 2013 } 2014 2015 extern(C) static void callBackPreeditChanged(GtkTextView* textviewStruct, char* preedit, OnPreeditChangedDelegateWrapper wrapper) 2016 { 2017 wrapper.dlg(Str.toString(preedit), wrapper.outer); 2018 } 2019 2020 extern(C) static void callBackPreeditChangedDestroy(OnPreeditChangedDelegateWrapper wrapper, GClosure* closure) 2021 { 2022 wrapper.remove(wrapper); 2023 } 2024 2025 protected class OnSelectAllDelegateWrapper 2026 { 2027 void delegate(bool, TextView) dlg; 2028 gulong handlerId; 2029 2030 this(void delegate(bool, TextView) dlg) 2031 { 2032 this.dlg = dlg; 2033 onSelectAllListeners ~= this; 2034 } 2035 2036 void remove(OnSelectAllDelegateWrapper source) 2037 { 2038 foreach(index, wrapper; onSelectAllListeners) 2039 { 2040 if (wrapper.handlerId == source.handlerId) 2041 { 2042 onSelectAllListeners[index] = null; 2043 onSelectAllListeners = std.algorithm.remove(onSelectAllListeners, index); 2044 break; 2045 } 2046 } 2047 } 2048 } 2049 OnSelectAllDelegateWrapper[] onSelectAllListeners; 2050 2051 /** 2052 * The ::select-all signal is a 2053 * [keybinding signal][GtkBindingSignal] 2054 * which gets emitted to select or unselect the complete 2055 * contents of the text view. 2056 * 2057 * The default bindings for this signal are Ctrl-a and Ctrl-/ 2058 * for selecting and Shift-Ctrl-a and Ctrl-\ for unselecting. 2059 * 2060 * Params: 2061 * select = %TRUE to select, %FALSE to unselect 2062 */ 2063 gulong addOnSelectAll(void delegate(bool, TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2064 { 2065 auto wrapper = new OnSelectAllDelegateWrapper(dlg); 2066 wrapper.handlerId = Signals.connectData( 2067 this, 2068 "select-all", 2069 cast(GCallback)&callBackSelectAll, 2070 cast(void*)wrapper, 2071 cast(GClosureNotify)&callBackSelectAllDestroy, 2072 connectFlags); 2073 return wrapper.handlerId; 2074 } 2075 2076 extern(C) static void callBackSelectAll(GtkTextView* textviewStruct, bool select, OnSelectAllDelegateWrapper wrapper) 2077 { 2078 wrapper.dlg(select, wrapper.outer); 2079 } 2080 2081 extern(C) static void callBackSelectAllDestroy(OnSelectAllDelegateWrapper wrapper, GClosure* closure) 2082 { 2083 wrapper.remove(wrapper); 2084 } 2085 2086 protected class OnSetAnchorDelegateWrapper 2087 { 2088 void delegate(TextView) dlg; 2089 gulong handlerId; 2090 2091 this(void delegate(TextView) dlg) 2092 { 2093 this.dlg = dlg; 2094 onSetAnchorListeners ~= this; 2095 } 2096 2097 void remove(OnSetAnchorDelegateWrapper source) 2098 { 2099 foreach(index, wrapper; onSetAnchorListeners) 2100 { 2101 if (wrapper.handlerId == source.handlerId) 2102 { 2103 onSetAnchorListeners[index] = null; 2104 onSetAnchorListeners = std.algorithm.remove(onSetAnchorListeners, index); 2105 break; 2106 } 2107 } 2108 } 2109 } 2110 OnSetAnchorDelegateWrapper[] onSetAnchorListeners; 2111 2112 /** 2113 * The ::set-anchor signal is a 2114 * [keybinding signal][GtkBindingSignal] 2115 * which gets emitted when the user initiates setting the "anchor" 2116 * mark. The "anchor" mark gets placed at the same position as the 2117 * "insert" mark. 2118 * 2119 * This signal has no default bindings. 2120 */ 2121 gulong addOnSetAnchor(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2122 { 2123 auto wrapper = new OnSetAnchorDelegateWrapper(dlg); 2124 wrapper.handlerId = Signals.connectData( 2125 this, 2126 "set-anchor", 2127 cast(GCallback)&callBackSetAnchor, 2128 cast(void*)wrapper, 2129 cast(GClosureNotify)&callBackSetAnchorDestroy, 2130 connectFlags); 2131 return wrapper.handlerId; 2132 } 2133 2134 extern(C) static void callBackSetAnchor(GtkTextView* textviewStruct, OnSetAnchorDelegateWrapper wrapper) 2135 { 2136 wrapper.dlg(wrapper.outer); 2137 } 2138 2139 extern(C) static void callBackSetAnchorDestroy(OnSetAnchorDelegateWrapper wrapper, GClosure* closure) 2140 { 2141 wrapper.remove(wrapper); 2142 } 2143 2144 protected class OnToggleCursorVisibleDelegateWrapper 2145 { 2146 void delegate(TextView) dlg; 2147 gulong handlerId; 2148 2149 this(void delegate(TextView) dlg) 2150 { 2151 this.dlg = dlg; 2152 onToggleCursorVisibleListeners ~= this; 2153 } 2154 2155 void remove(OnToggleCursorVisibleDelegateWrapper source) 2156 { 2157 foreach(index, wrapper; onToggleCursorVisibleListeners) 2158 { 2159 if (wrapper.handlerId == source.handlerId) 2160 { 2161 onToggleCursorVisibleListeners[index] = null; 2162 onToggleCursorVisibleListeners = std.algorithm.remove(onToggleCursorVisibleListeners, index); 2163 break; 2164 } 2165 } 2166 } 2167 } 2168 OnToggleCursorVisibleDelegateWrapper[] onToggleCursorVisibleListeners; 2169 2170 /** 2171 * The ::toggle-cursor-visible signal is a 2172 * [keybinding signal][GtkBindingSignal] 2173 * which gets emitted to toggle the #GtkTextView:cursor-visible 2174 * property. 2175 * 2176 * The default binding for this signal is F7. 2177 */ 2178 gulong addOnToggleCursorVisible(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2179 { 2180 auto wrapper = new OnToggleCursorVisibleDelegateWrapper(dlg); 2181 wrapper.handlerId = Signals.connectData( 2182 this, 2183 "toggle-cursor-visible", 2184 cast(GCallback)&callBackToggleCursorVisible, 2185 cast(void*)wrapper, 2186 cast(GClosureNotify)&callBackToggleCursorVisibleDestroy, 2187 connectFlags); 2188 return wrapper.handlerId; 2189 } 2190 2191 extern(C) static void callBackToggleCursorVisible(GtkTextView* textviewStruct, OnToggleCursorVisibleDelegateWrapper wrapper) 2192 { 2193 wrapper.dlg(wrapper.outer); 2194 } 2195 2196 extern(C) static void callBackToggleCursorVisibleDestroy(OnToggleCursorVisibleDelegateWrapper wrapper, GClosure* closure) 2197 { 2198 wrapper.remove(wrapper); 2199 } 2200 2201 protected class OnToggleOverwriteDelegateWrapper 2202 { 2203 void delegate(TextView) dlg; 2204 gulong handlerId; 2205 2206 this(void delegate(TextView) dlg) 2207 { 2208 this.dlg = dlg; 2209 onToggleOverwriteListeners ~= this; 2210 } 2211 2212 void remove(OnToggleOverwriteDelegateWrapper source) 2213 { 2214 foreach(index, wrapper; onToggleOverwriteListeners) 2215 { 2216 if (wrapper.handlerId == source.handlerId) 2217 { 2218 onToggleOverwriteListeners[index] = null; 2219 onToggleOverwriteListeners = std.algorithm.remove(onToggleOverwriteListeners, index); 2220 break; 2221 } 2222 } 2223 } 2224 } 2225 OnToggleOverwriteDelegateWrapper[] onToggleOverwriteListeners; 2226 2227 /** 2228 * The ::toggle-overwrite signal is a 2229 * [keybinding signal][GtkBindingSignal] 2230 * which gets emitted to toggle the overwrite mode of the text view. 2231 * 2232 * The default bindings for this signal is Insert. 2233 */ 2234 gulong addOnToggleOverwrite(void delegate(TextView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2235 { 2236 auto wrapper = new OnToggleOverwriteDelegateWrapper(dlg); 2237 wrapper.handlerId = Signals.connectData( 2238 this, 2239 "toggle-overwrite", 2240 cast(GCallback)&callBackToggleOverwrite, 2241 cast(void*)wrapper, 2242 cast(GClosureNotify)&callBackToggleOverwriteDestroy, 2243 connectFlags); 2244 return wrapper.handlerId; 2245 } 2246 2247 extern(C) static void callBackToggleOverwrite(GtkTextView* textviewStruct, OnToggleOverwriteDelegateWrapper wrapper) 2248 { 2249 wrapper.dlg(wrapper.outer); 2250 } 2251 2252 extern(C) static void callBackToggleOverwriteDestroy(OnToggleOverwriteDelegateWrapper wrapper, GClosure* closure) 2253 { 2254 wrapper.remove(wrapper); 2255 } 2256 }