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