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