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