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