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 = GtkTextBuffer.html 27 * outPack = gtk 28 * outFile = TextBuffer 29 * strct = GtkTextBuffer 30 * realStrct= 31 * ctorStrct= 32 * clss = TextBuffer 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_text_buffer_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - gtk_text_buffer_set_text 46 * - gtk_text_buffer_insert_with_tags 47 * - gtk_text_buffer_insert_with_tags_by_name 48 * - gtk_text_buffer_create_tag 49 * omit signals: 50 * imports: 51 * - glib.Str 52 * - glib.ErrorG 53 * - glib.GException 54 * - gtk.TextMark 55 * - gtk.TextIter 56 * - gdk.Rectangle 57 * - gtk.Widget 58 * - pango.PgTabArray 59 * - gtk.TextAttributes 60 * - gtk.TextTagTable 61 * - gtk.TextIter 62 * - gtk.TextTag 63 * - gdk.Pixbuf 64 * - gtk.TextChildAnchor 65 * - gtk.TextMark 66 * - gtk.Clipboard 67 * - gdk.Bitmap 68 * - gtk.TargetList 69 * - std.stdarg 70 * structWrap: 71 * - GdkBitmap* -> Bitmap 72 * - GdkPixbuf* -> Pixbuf 73 * - GdkRectangle* -> Rectangle 74 * - GtkClipboard* -> Clipboard 75 * - GtkTargetList* -> TargetList 76 * - GtkTextAttributes* -> TextAttributes 77 * - GtkTextBuffer* -> TextBuffer 78 * - GtkTextChildAnchor* -> TextChildAnchor 79 * - GtkTextIter* -> TextIter 80 * - GtkTextMark* -> TextMark 81 * - GtkTextTag* -> TextTag 82 * - GtkTextTagTable* -> TextTagTable 83 * - GtkWidget* -> Widget 84 * - PangoTabArray* -> PgTabArray 85 * module aliases: 86 * local aliases: 87 * overrides: 88 */ 89 90 module gtk.TextBuffer; 91 92 public import gtkc.gtktypes; 93 94 private import gtkc.gtk; 95 private import glib.ConstructionException; 96 private import gobject.ObjectG; 97 98 private import gobject.Signals; 99 public import gtkc.gdktypes; 100 101 private import glib.Str; 102 private import glib.ErrorG; 103 private import glib.GException; 104 private import gtk.TextMark; 105 private import gtk.TextIter; 106 private import gdk.Rectangle; 107 private import gtk.Widget; 108 private import pango.PgTabArray; 109 private import gtk.TextAttributes; 110 private import gtk.TextTagTable; 111 private import gtk.TextIter; 112 private import gtk.TextTag; 113 private import gdk.Pixbuf; 114 private import gtk.TextChildAnchor; 115 private import gtk.TextMark; 116 private import gtk.Clipboard; 117 private import gdk.Bitmap; 118 private import gtk.TargetList; 119 120 121 version(Tango) { 122 private import tango.core.Vararg; 123 124 version = druntime; 125 } else version(D_Version2) { 126 private import core.vararg; 127 128 version = druntime; 129 } else { 130 private import std.stdarg; 131 } 132 133 134 private import gobject.ObjectG; 135 136 /** 137 * Description 138 * You may wish to begin by reading the text widget 139 * conceptual overview which gives an overview of all the objects and data 140 * types related to the text widget and how they work together. 141 */ 142 public class TextBuffer : ObjectG 143 { 144 145 /** the main Gtk struct */ 146 protected GtkTextBuffer* gtkTextBuffer; 147 148 149 public GtkTextBuffer* getTextBufferStruct() 150 { 151 return gtkTextBuffer; 152 } 153 154 155 /** the main Gtk struct as a void* */ 156 protected override void* getStruct() 157 { 158 return cast(void*)gtkTextBuffer; 159 } 160 161 /** 162 * Sets our main struct and passes it to the parent class 163 */ 164 public this (GtkTextBuffer* gtkTextBuffer) 165 { 166 super(cast(GObject*)gtkTextBuffer); 167 this.gtkTextBuffer = gtkTextBuffer; 168 } 169 170 protected override void setStruct(GObject* obj) 171 { 172 super.setStruct(obj); 173 gtkTextBuffer = cast(GtkTextBuffer*)obj; 174 } 175 176 /** 177 * Deletes current contents of buffer, and inserts text instead. If 178 * len is -1, text must be nul-terminated. text must be valid UTF-8. 179 * Params: 180 * text = UTF-8 text to insert 181 */ 182 public void setText(string text) 183 { 184 // void gtk_text_buffer_set_text (GtkTextBuffer *buffer, const gchar *text, gint len); 185 gtk_text_buffer_set_text(gtkTextBuffer, Str.toStringz(text), cast(int) text.length); 186 } 187 188 /** 189 * Inserts len bytes of text at position iter. If len is -1, 190 * text must be nul-terminated and will be inserted in its 191 * entirety. Emits the "insert_text" signal; insertion actually occurs 192 * in the default handler for the signal. iter is invalidated when 193 * insertion occurs (because the buffer contents change), but the 194 * default signal handler revalidates it to point to the end of the 195 * inserted text. 196 * Params: 197 * iter = a position in the buffer 198 * text = UTF-8 format text to insert 199 */ 200 public void insert(TextIter iter, string text) 201 { 202 // void gtk_text_buffer_insert (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len); 203 gtk_text_buffer_insert(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int) text.length); 204 } 205 206 /** 207 * Simply calls gtk_text_buffer_insert(), using the current 208 * cursor position as the insertion point. 209 * Params: 210 * text = some text in UTF-8 format 211 */ 212 public void insertAtCursor(string text) 213 { 214 // void gtk_text_buffer_insert_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len); 215 gtk_text_buffer_insert_at_cursor(gtkTextBuffer, Str.toStringz(text), cast(int) text.length); 216 } 217 218 /** 219 * Like gtk_text_buffer_insert(), but the insertion will not occur if 220 * iter is at a non-editable location in the buffer. Usually you 221 * want to prevent insertions at ineditable locations if the insertion 222 * results from a user action (is interactive). 223 * default_editable indicates the editability of text that doesn't 224 * have a tag affecting editability applied to it. Typically the 225 * result of gtk_text_view_get_editable() is appropriate here. 226 * Params: 227 * iter = a position in buffer 228 * text = some UTF-8 text 229 * defaultEditable = default editability of buffer 230 * Returns: 231 * whether text was actually inserted 232 */ 233 public int insertInteractive(TextIter iter, string text, int defaultEditable) 234 { 235 // gboolean gtk_text_buffer_insert_interactive (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, gboolean default_editable); 236 return gtk_text_buffer_insert_interactive(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int) text.length, defaultEditable); 237 } 238 239 /** 240 * Calls gtk_text_buffer_insert_interactive() at the cursor 241 * position. 242 * default_editable indicates the editability of text that doesn't 243 * have a tag affecting editability applied to it. Typically the 244 * result of gtk_text_view_get_editable() is appropriate here. 245 * Params: 246 * text = text in UTF-8 format 247 * defaultEditable = default editability of buffer 248 * Returns: 249 * whether text was actually inserted 250 */ 251 public int insertInteractiveAtCursor(string text, int defaultEditable) 252 { 253 // gboolean gtk_text_buffer_insert_interactive_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len, gboolean default_editable); 254 return gtk_text_buffer_insert_interactive_at_cursor(gtkTextBuffer, Str.toStringz(text), cast(int) text.length, defaultEditable); 255 } 256 257 /** 258 * Inserts text into buffer at iter, applying the list of tags to 259 * the newly-inserted text. The last tag specified must be NULL to 260 * terminate the list. Equivalent to calling gtk_text_buffer_insert(), 261 * then gtk_text_buffer_apply_tag() on the inserted text; 262 * gtk_text_buffer_insert_with_tags() is just a convenience function. 263 * Params: 264 * iter = an iterator in buffer 265 * text = UTF-8 text 266 * ... = NULL-terminated list of tags to apply 267 */ 268 //version(Tango){} else -- still doesn't work on tango, but it compiles now 269 public void insertWithTags(TextIter iter, string text, ... ) 270 { 271 for (int i = 0; (i<_arguments.length) && (_arguments[i] == typeid(TextTag)); i++) 272 { 273 TextTag tag = va_arg!(TextTag)(_argptr); 274 // void gtk_text_buffer_insert_with_tags (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, GtkTextTag *first_tag, ...); 275 gtk_text_buffer_insert_with_tags(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int) text.length, (tag is null) ? null : tag.getTextTagStruct(), null); 276 } 277 } 278 279 /** 280 * Same as gtk_text_buffer_insert_with_tags(), but allows you 281 * to pass in tag names instead of tag objects. 282 * Params: 283 * iter = position in buffer 284 * text = UTF-8 text 285 * ... = more tag names 286 */ 287 // version(Tango){} else -- still doesn't work on tango, but it compiles now 288 public void insertWithTagsByName(TextIter iter, string text, ... ) 289 { 290 for (int i = 0; (i<_arguments.length) && (_arguments[i] == typeid(string)); i++) 291 { 292 string tagName = va_arg!(string)(_argptr); 293 // void gtk_text_buffer_insert_with_tags_by_name (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, const gchar *first_tag_name, ...); 294 gtk_text_buffer_insert_with_tags_by_name(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int) text.length, Str.toStringz(tagName), null); 295 } 296 } 297 298 /** 299 * Create a new tag for this buffer 300 * Params: 301 * tagName= can be null for no name 302 * propertyName= 303 * propertyValue= 304 */ 305 TextTag createTag(string tagName, string propertyName, int propertyValue, 306 string propertyName1, string propertyValue1) 307 { 308 return new TextTag( 309 gtk_text_buffer_create_tag(gtkTextBuffer, 310 Str.toStringz(tagName), 311 Str.toStringz(propertyName),propertyValue, 312 Str.toStringz(propertyName1), 313 Str.toStringz(propertyValue1), 314 null) 315 ); 316 317 } 318 /** 319 * Create a new tag for this buffer 320 * Params: 321 * tagName= can be null for no name 322 * propertyName= 323 * propertyValue= 324 */ 325 TextTag createTag(string tagName, string propertyName, int propertyValue) 326 { 327 return new TextTag( 328 gtk_text_buffer_create_tag(gtkTextBuffer, 329 Str.toStringz(tagName), 330 Str.toStringz(propertyName),propertyValue,null) 331 ); 332 333 } 334 335 /** 336 * Create a new tag for this buffer 337 * Params: 338 * tagName= can be null for no name 339 * propertyName= 340 * propertyValue= 341 */ 342 TextTag createTag(string tagName, string propertyName, double propertyValue) 343 { 344 return new TextTag( 345 gtk_text_buffer_create_tag(gtkTextBuffer, Str.toStringz(tagName), Str.toStringz(propertyName),propertyValue,null) 346 ); 347 348 } 349 350 /** 351 * Create a new tag for this buffer 352 * Params: 353 * tagName= can be null for no name 354 * propertyName= 355 * propertyValue= 356 * propertyName2= 357 * propertyValue2= 358 */ 359 TextTag createTag(string tagName, string propertyName, int propertyValue, string propertyName2, int propertyValue2) 360 { 361 return new TextTag( 362 gtk_text_buffer_create_tag(gtkTextBuffer, Str.toStringz(tagName), Str.toStringz(propertyName), propertyValue, Str.toStringz(propertyName2), propertyValue2, null) 363 ); 364 } 365 366 /** Create a new tag for this buffer */ 367 TextTag createTag(string tagName, string propertyName, int propertyValue, string propertyName2, int propertyValue2, string propertyName3, int propertyValue3, string propertyName4, int propertyValue4, string propertyName5, int propertyValue5) 368 { 369 return new TextTag( 370 gtk_text_buffer_create_tag(gtkTextBuffer, Str.toStringz(tagName), Str.toStringz(propertyName), propertyValue, Str.toStringz(propertyName2), propertyValue2, Str.toStringz(propertyName3), propertyValue3, Str.toStringz(propertyName4), propertyValue4, Str.toStringz(propertyName5), propertyValue5, null) 371 ); 372 } 373 374 /** 375 * Create a new tag for this buffer 376 * Params: 377 * tagName= can be null for no name 378 * propertyName= 379 * propertyValue= 380 */ 381 TextTag createTag(string tagName, string propertyName, string propertyValue) 382 { 383 return new TextTag( 384 gtk_text_buffer_create_tag(gtkTextBuffer, Str.toStringz(tagName), Str.toStringz(propertyName),Str.toStringz(propertyValue),null) 385 ); 386 387 } 388 389 /** 390 * Create a new tag for this buffer 391 * Params: 392 * tagName = can be null for no name 393 * propertyName= 394 * propertyValue= 395 */ 396 TextTag createTag(string tagName, string propertyName, Bitmap propertyValue) 397 { 398 return new TextTag( 399 gtk_text_buffer_create_tag(gtkTextBuffer, Str.toStringz(tagName), Str.toStringz(propertyName),propertyValue.getBitmapStruct(),null) 400 ); 401 402 } 403 404 /** 405 * Obtain the entire text 406 * Returns: The text string 407 */ 408 string getText() 409 { 410 TextIter start = new TextIter(); 411 TextIter end = new TextIter(); 412 getBounds(start,end); 413 return Str.toString(gtk_text_buffer_get_slice(gtkTextBuffer, start.getTextIterStruct(), end.getTextIterStruct(), true)); 414 } 415 416 /** 417 * Create a new tag for this buffer 418 * Params: 419 * tagName= can be null for no name 420 * propertyName= 421 * propertyValue= 422 * propertyName2= 423 * propertyValue2= 424 */ 425 TextTag createTag(string tagName, 426 string propertyName, string propertyValue, 427 string propertyName2, int propertyValue2) 428 { 429 return new TextTag( 430 gtk_text_buffer_create_tag(gtkTextBuffer, Str.toStringz(tagName), 431 Str.toStringz(propertyName), Str.toStringz(propertyValue), 432 Str.toStringz(propertyName2), propertyValue2, null) 433 ); 434 } 435 436 /** 437 */ 438 int[string] connectedSignals; 439 440 void delegate(TextTag, TextIter, TextIter, TextBuffer)[] onApplyTagListeners; 441 /** 442 * The ::apply-tag signal is emitted to apply a tag to a 443 * range of text in a GtkTextBuffer. 444 * Applying actually occurs in the default handler. 445 * Note that if your handler runs before the default handler it must not 446 * invalidate the start and end iters (or has to revalidate them). 447 * See also: 448 * gtk_text_buffer_apply_tag(), 449 * gtk_text_buffer_insert_with_tags(), 450 * gtk_text_buffer_insert_range(). 451 */ 452 void addOnApplyTag(void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 453 { 454 if ( !("apply-tag" in connectedSignals) ) 455 { 456 Signals.connectData( 457 getStruct(), 458 "apply-tag", 459 cast(GCallback)&callBackApplyTag, 460 cast(void*)this, 461 null, 462 connectFlags); 463 connectedSignals["apply-tag"] = 1; 464 } 465 onApplyTagListeners ~= dlg; 466 } 467 extern(C) static void callBackApplyTag(GtkTextBuffer* textbufferStruct, GtkTextTag* tag, GtkTextIter* start, GtkTextIter* end, TextBuffer _textBuffer) 468 { 469 foreach ( void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg ; _textBuffer.onApplyTagListeners ) 470 { 471 dlg(ObjectG.getDObject!(TextTag)(tag), ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _textBuffer); 472 } 473 } 474 475 void delegate(TextBuffer)[] onBeginUserActionListeners; 476 /** 477 * The ::begin-user-action signal is emitted at the beginning of a single 478 * user-visible operation on a GtkTextBuffer. 479 * See also: 480 * gtk_text_buffer_begin_user_action(), 481 * gtk_text_buffer_insert_interactive(), 482 * gtk_text_buffer_insert_range_interactive(), 483 * gtk_text_buffer_delete_interactive(), 484 * gtk_text_buffer_backspace(), 485 * gtk_text_buffer_delete_selection(). 486 */ 487 void addOnBeginUserAction(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 488 { 489 if ( !("begin-user-action" in connectedSignals) ) 490 { 491 Signals.connectData( 492 getStruct(), 493 "begin-user-action", 494 cast(GCallback)&callBackBeginUserAction, 495 cast(void*)this, 496 null, 497 connectFlags); 498 connectedSignals["begin-user-action"] = 1; 499 } 500 onBeginUserActionListeners ~= dlg; 501 } 502 extern(C) static void callBackBeginUserAction(GtkTextBuffer* textbufferStruct, TextBuffer _textBuffer) 503 { 504 foreach ( void delegate(TextBuffer) dlg ; _textBuffer.onBeginUserActionListeners ) 505 { 506 dlg(_textBuffer); 507 } 508 } 509 510 void delegate(TextBuffer)[] onChangedListeners; 511 /** 512 * The ::changed signal is emitted when the content of a GtkTextBuffer 513 * has changed. 514 */ 515 void addOnChanged(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 516 { 517 if ( !("changed" in connectedSignals) ) 518 { 519 Signals.connectData( 520 getStruct(), 521 "changed", 522 cast(GCallback)&callBackChanged, 523 cast(void*)this, 524 null, 525 connectFlags); 526 connectedSignals["changed"] = 1; 527 } 528 onChangedListeners ~= dlg; 529 } 530 extern(C) static void callBackChanged(GtkTextBuffer* textbufferStruct, TextBuffer _textBuffer) 531 { 532 foreach ( void delegate(TextBuffer) dlg ; _textBuffer.onChangedListeners ) 533 { 534 dlg(_textBuffer); 535 } 536 } 537 538 void delegate(TextIter, TextIter, TextBuffer)[] onDeleteRangeListeners; 539 /** 540 * The ::delete-range signal is emitted to delete a range 541 * from a GtkTextBuffer. 542 * Note that if your handler runs before the default handler it must not 543 * invalidate the start and end iters (or has to revalidate them). 544 * The default signal handler revalidates the start and end iters to 545 * both point point to the location where text was deleted. Handlers 546 * which run after the default handler (see g_signal_connect_after()) 547 * do not have access to the deleted text. 548 * See also: gtk_text_buffer_delete(). 549 */ 550 void addOnDeleteRange(void delegate(TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 551 { 552 if ( !("delete-range" in connectedSignals) ) 553 { 554 Signals.connectData( 555 getStruct(), 556 "delete-range", 557 cast(GCallback)&callBackDeleteRange, 558 cast(void*)this, 559 null, 560 connectFlags); 561 connectedSignals["delete-range"] = 1; 562 } 563 onDeleteRangeListeners ~= dlg; 564 } 565 extern(C) static void callBackDeleteRange(GtkTextBuffer* textbufferStruct, GtkTextIter* start, GtkTextIter* end, TextBuffer _textBuffer) 566 { 567 foreach ( void delegate(TextIter, TextIter, TextBuffer) dlg ; _textBuffer.onDeleteRangeListeners ) 568 { 569 dlg(ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _textBuffer); 570 } 571 } 572 573 void delegate(TextBuffer)[] onEndUserActionListeners; 574 /** 575 * The ::end-user-action signal is emitted at the end of a single 576 * user-visible operation on the GtkTextBuffer. 577 * See also: 578 * gtk_text_buffer_end_user_action(), 579 * gtk_text_buffer_insert_interactive(), 580 * gtk_text_buffer_insert_range_interactive(), 581 * gtk_text_buffer_delete_interactive(), 582 * gtk_text_buffer_backspace(), 583 * gtk_text_buffer_delete_selection(), 584 * gtk_text_buffer_backspace(). 585 */ 586 void addOnEndUserAction(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 587 { 588 if ( !("end-user-action" in connectedSignals) ) 589 { 590 Signals.connectData( 591 getStruct(), 592 "end-user-action", 593 cast(GCallback)&callBackEndUserAction, 594 cast(void*)this, 595 null, 596 connectFlags); 597 connectedSignals["end-user-action"] = 1; 598 } 599 onEndUserActionListeners ~= dlg; 600 } 601 extern(C) static void callBackEndUserAction(GtkTextBuffer* textbufferStruct, TextBuffer _textBuffer) 602 { 603 foreach ( void delegate(TextBuffer) dlg ; _textBuffer.onEndUserActionListeners ) 604 { 605 dlg(_textBuffer); 606 } 607 } 608 609 void delegate(TextIter, TextChildAnchor, TextBuffer)[] onInsertChildAnchorListeners; 610 /** 611 * The ::insert-child-anchor signal is emitted to insert a 612 * GtkTextChildAnchor in a GtkTextBuffer. 613 * Insertion actually occurs in the default handler. 614 * Note that if your handler runs before the default handler it must 615 * not invalidate the location iter (or has to revalidate it). 616 * The default signal handler revalidates it to be placed after the 617 * inserted anchor. 618 * See also: gtk_text_buffer_insert_child_anchor(). 619 */ 620 void addOnInsertChildAnchor(void delegate(TextIter, TextChildAnchor, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 621 { 622 if ( !("insert-child-anchor" in connectedSignals) ) 623 { 624 Signals.connectData( 625 getStruct(), 626 "insert-child-anchor", 627 cast(GCallback)&callBackInsertChildAnchor, 628 cast(void*)this, 629 null, 630 connectFlags); 631 connectedSignals["insert-child-anchor"] = 1; 632 } 633 onInsertChildAnchorListeners ~= dlg; 634 } 635 extern(C) static void callBackInsertChildAnchor(GtkTextBuffer* textbufferStruct, GtkTextIter* location, GtkTextChildAnchor* anchor, TextBuffer _textBuffer) 636 { 637 foreach ( void delegate(TextIter, TextChildAnchor, TextBuffer) dlg ; _textBuffer.onInsertChildAnchorListeners ) 638 { 639 dlg(ObjectG.getDObject!(TextIter)(location), ObjectG.getDObject!(TextChildAnchor)(anchor), _textBuffer); 640 } 641 } 642 643 void delegate(TextIter, Pixbuf, TextBuffer)[] onInsertPixbufListeners; 644 /** 645 * The ::insert-pixbuf signal is emitted to insert a GdkPixbuf 646 * in a GtkTextBuffer. Insertion actually occurs in the default handler. 647 * Note that if your handler runs before the default handler it must not 648 * invalidate the location iter (or has to revalidate it). 649 * The default signal handler revalidates it to be placed after the 650 * inserted pixbuf. 651 * See also: gtk_text_buffer_insert_pixbuf(). 652 */ 653 void addOnInsertPixbuf(void delegate(TextIter, Pixbuf, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 654 { 655 if ( !("insert-pixbuf" in connectedSignals) ) 656 { 657 Signals.connectData( 658 getStruct(), 659 "insert-pixbuf", 660 cast(GCallback)&callBackInsertPixbuf, 661 cast(void*)this, 662 null, 663 connectFlags); 664 connectedSignals["insert-pixbuf"] = 1; 665 } 666 onInsertPixbufListeners ~= dlg; 667 } 668 extern(C) static void callBackInsertPixbuf(GtkTextBuffer* textbufferStruct, GtkTextIter* location, GdkPixbuf* pixbuf, TextBuffer _textBuffer) 669 { 670 foreach ( void delegate(TextIter, Pixbuf, TextBuffer) dlg ; _textBuffer.onInsertPixbufListeners ) 671 { 672 dlg(ObjectG.getDObject!(TextIter)(location), ObjectG.getDObject!(Pixbuf)(pixbuf), _textBuffer); 673 } 674 } 675 676 void delegate(TextIter, string, gint, TextBuffer)[] onInsertTextListeners; 677 /** 678 * The ::insert-text signal is emitted to insert text in a GtkTextBuffer. 679 * Insertion actually occurs in the default handler. 680 * Note that if your handler runs before the default handler it must not 681 * invalidate the location iter (or has to revalidate it). 682 * The default signal handler revalidates it to point to the end of the 683 * inserted text. 684 * See also: 685 * gtk_text_buffer_insert(), 686 * gtk_text_buffer_insert_range(). 687 */ 688 void addOnInsertText(void delegate(TextIter, string, gint, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 689 { 690 if ( !("insert-text" in connectedSignals) ) 691 { 692 Signals.connectData( 693 getStruct(), 694 "insert-text", 695 cast(GCallback)&callBackInsertText, 696 cast(void*)this, 697 null, 698 connectFlags); 699 connectedSignals["insert-text"] = 1; 700 } 701 onInsertTextListeners ~= dlg; 702 } 703 extern(C) static void callBackInsertText(GtkTextBuffer* textbufferStruct, GtkTextIter* location, gchar* text, gint len, TextBuffer _textBuffer) 704 { 705 foreach ( void delegate(TextIter, string, gint, TextBuffer) dlg ; _textBuffer.onInsertTextListeners ) 706 { 707 dlg(ObjectG.getDObject!(TextIter)(location), Str.toString(text), len, _textBuffer); 708 } 709 } 710 711 void delegate(TextMark, TextBuffer)[] onMarkDeletedListeners; 712 /** 713 * The ::mark-deleted signal is emitted as notification 714 * after a GtkTextMark is deleted. 715 */ 716 void addOnMarkDeleted(void delegate(TextMark, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 717 { 718 if ( !("mark-deleted" in connectedSignals) ) 719 { 720 Signals.connectData( 721 getStruct(), 722 "mark-deleted", 723 cast(GCallback)&callBackMarkDeleted, 724 cast(void*)this, 725 null, 726 connectFlags); 727 connectedSignals["mark-deleted"] = 1; 728 } 729 onMarkDeletedListeners ~= dlg; 730 } 731 extern(C) static void callBackMarkDeleted(GtkTextBuffer* textbufferStruct, GtkTextMark* mark, TextBuffer _textBuffer) 732 { 733 foreach ( void delegate(TextMark, TextBuffer) dlg ; _textBuffer.onMarkDeletedListeners ) 734 { 735 dlg(ObjectG.getDObject!(TextMark)(mark), _textBuffer); 736 } 737 } 738 739 void delegate(TextIter, TextMark, TextBuffer)[] onMarkSetListeners; 740 /** 741 * The ::mark-set signal is emitted as notification 742 * after a GtkTextMark is set. 743 * See also: 744 * gtk_text_buffer_create_mark(), 745 * gtk_text_buffer_move_mark(). 746 */ 747 void addOnMarkSet(void delegate(TextIter, TextMark, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 748 { 749 if ( !("mark-set" in connectedSignals) ) 750 { 751 Signals.connectData( 752 getStruct(), 753 "mark-set", 754 cast(GCallback)&callBackMarkSet, 755 cast(void*)this, 756 null, 757 connectFlags); 758 connectedSignals["mark-set"] = 1; 759 } 760 onMarkSetListeners ~= dlg; 761 } 762 extern(C) static void callBackMarkSet(GtkTextBuffer* textbufferStruct, GtkTextIter* location, GtkTextMark* mark, TextBuffer _textBuffer) 763 { 764 foreach ( void delegate(TextIter, TextMark, TextBuffer) dlg ; _textBuffer.onMarkSetListeners ) 765 { 766 dlg(ObjectG.getDObject!(TextIter)(location), ObjectG.getDObject!(TextMark)(mark), _textBuffer); 767 } 768 } 769 770 void delegate(TextBuffer)[] onModifiedChangedListeners; 771 /** 772 * The ::modified-changed signal is emitted when the modified bit of a 773 * GtkTextBuffer flips. 774 */ 775 void addOnModifiedChanged(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 776 { 777 if ( !("modified-changed" in connectedSignals) ) 778 { 779 Signals.connectData( 780 getStruct(), 781 "modified-changed", 782 cast(GCallback)&callBackModifiedChanged, 783 cast(void*)this, 784 null, 785 connectFlags); 786 connectedSignals["modified-changed"] = 1; 787 } 788 onModifiedChangedListeners ~= dlg; 789 } 790 extern(C) static void callBackModifiedChanged(GtkTextBuffer* textbufferStruct, TextBuffer _textBuffer) 791 { 792 foreach ( void delegate(TextBuffer) dlg ; _textBuffer.onModifiedChangedListeners ) 793 { 794 dlg(_textBuffer); 795 } 796 } 797 798 void delegate(Clipboard, TextBuffer)[] onPasteDoneListeners; 799 /** 800 * The paste-done signal is emitted after paste operation has been completed. 801 * This is useful to properly scroll the view to the end of the pasted text. 802 * See gtk_text_buffer_paste_clipboard() for more details. 803 * Since 2.16 804 */ 805 void addOnPasteDone(void delegate(Clipboard, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 806 { 807 if ( !("paste-done" in connectedSignals) ) 808 { 809 Signals.connectData( 810 getStruct(), 811 "paste-done", 812 cast(GCallback)&callBackPasteDone, 813 cast(void*)this, 814 null, 815 connectFlags); 816 connectedSignals["paste-done"] = 1; 817 } 818 onPasteDoneListeners ~= dlg; 819 } 820 extern(C) static void callBackPasteDone(GtkTextBuffer* textbufferStruct, GtkClipboard* arg1, TextBuffer _textBuffer) 821 { 822 foreach ( void delegate(Clipboard, TextBuffer) dlg ; _textBuffer.onPasteDoneListeners ) 823 { 824 dlg(ObjectG.getDObject!(Clipboard)(arg1), _textBuffer); 825 } 826 } 827 828 void delegate(TextTag, TextIter, TextIter, TextBuffer)[] onRemoveTagListeners; 829 /** 830 * The ::remove-tag signal is emitted to remove all occurrences of tag from 831 * a range of text in a GtkTextBuffer. 832 * Removal actually occurs in the default handler. 833 * Note that if your handler runs before the default handler it must not 834 * invalidate the start and end iters (or has to revalidate them). 835 * See also: 836 * gtk_text_buffer_remove_tag(). 837 * See Also 838 * GtkTextView, GtkTextIter, GtkTextMark 839 */ 840 void addOnRemoveTag(void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 841 { 842 if ( !("remove-tag" in connectedSignals) ) 843 { 844 Signals.connectData( 845 getStruct(), 846 "remove-tag", 847 cast(GCallback)&callBackRemoveTag, 848 cast(void*)this, 849 null, 850 connectFlags); 851 connectedSignals["remove-tag"] = 1; 852 } 853 onRemoveTagListeners ~= dlg; 854 } 855 extern(C) static void callBackRemoveTag(GtkTextBuffer* textbufferStruct, GtkTextTag* tag, GtkTextIter* start, GtkTextIter* end, TextBuffer _textBuffer) 856 { 857 foreach ( void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg ; _textBuffer.onRemoveTagListeners ) 858 { 859 dlg(ObjectG.getDObject!(TextTag)(tag), ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _textBuffer); 860 } 861 } 862 863 864 /** 865 * Creates a new text buffer. 866 * Params: 867 * table = a tag table, or NULL to create a new one. [allow-none] 868 * Throws: ConstructionException GTK+ fails to create the object. 869 */ 870 public this (TextTagTable table) 871 { 872 // GtkTextBuffer * gtk_text_buffer_new (GtkTextTagTable *table); 873 auto p = gtk_text_buffer_new((table is null) ? null : table.getTextTagTableStruct()); 874 if(p is null) 875 { 876 throw new ConstructionException("null returned by gtk_text_buffer_new((table is null) ? null : table.getTextTagTableStruct())"); 877 } 878 this(cast(GtkTextBuffer*) p); 879 } 880 881 /** 882 * Obtains the number of lines in the buffer. This value is cached, so 883 * the function is very fast. 884 * Returns: number of lines in the buffer 885 */ 886 public int getLineCount() 887 { 888 // gint gtk_text_buffer_get_line_count (GtkTextBuffer *buffer); 889 return gtk_text_buffer_get_line_count(gtkTextBuffer); 890 } 891 892 /** 893 * Gets the number of characters in the buffer; note that characters 894 * and bytes are not the same, you can't e.g. expect the contents of 895 * the buffer in string form to be this many bytes long. The character 896 * count is cached, so this function is very fast. 897 * Returns: number of characters in the buffer 898 */ 899 public int getCharCount() 900 { 901 // gint gtk_text_buffer_get_char_count (GtkTextBuffer *buffer); 902 return gtk_text_buffer_get_char_count(gtkTextBuffer); 903 } 904 905 /** 906 * Get the GtkTextTagTable associated with this buffer. 907 * Returns: the buffer's tag table. [transfer none] 908 */ 909 public TextTagTable getTagTable() 910 { 911 // GtkTextTagTable * gtk_text_buffer_get_tag_table (GtkTextBuffer *buffer); 912 auto p = gtk_text_buffer_get_tag_table(gtkTextBuffer); 913 914 if(p is null) 915 { 916 return null; 917 } 918 919 return ObjectG.getDObject!(TextTagTable)(cast(GtkTextTagTable*) p); 920 } 921 922 /** 923 * Inserts len bytes of text at position iter. If len is -1, 924 * text must be nul-terminated and will be inserted in its 925 * entirety. Emits the "insert-text" signal; insertion actually occurs 926 * in the default handler for the signal. iter is invalidated when 927 * insertion occurs (because the buffer contents change), but the 928 * default signal handler revalidates it to point to the end of the 929 * inserted text. 930 * Params: 931 * iter = a position in the buffer 932 * text = text in UTF-8 format 933 * len = length of text in bytes, or -1 934 */ 935 public void insert(TextIter iter, string text, int len) 936 { 937 // void gtk_text_buffer_insert (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len); 938 gtk_text_buffer_insert(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), len); 939 } 940 941 /** 942 * Simply calls gtk_text_buffer_insert(), using the current 943 * cursor position as the insertion point. 944 * Params: 945 * text = text in UTF-8 format 946 * len = length of text, in bytes 947 */ 948 public void insertAtCursor(string text, int len) 949 { 950 // void gtk_text_buffer_insert_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len); 951 gtk_text_buffer_insert_at_cursor(gtkTextBuffer, Str.toStringz(text), len); 952 } 953 954 /** 955 * Like gtk_text_buffer_insert(), but the insertion will not occur if 956 * iter is at a non-editable location in the buffer. Usually you 957 * want to prevent insertions at ineditable locations if the insertion 958 * results from a user action (is interactive). 959 * default_editable indicates the editability of text that doesn't 960 * have a tag affecting editability applied to it. Typically the 961 * result of gtk_text_view_get_editable() is appropriate here. 962 * Params: 963 * iter = a position in buffer 964 * text = some UTF-8 text 965 * len = length of text in bytes, or -1 966 * defaultEditable = default editability of buffer 967 * Returns: whether text was actually inserted 968 */ 969 public int insertInteractive(TextIter iter, string text, int len, int defaultEditable) 970 { 971 // gboolean gtk_text_buffer_insert_interactive (GtkTextBuffer *buffer, GtkTextIter *iter, const gchar *text, gint len, gboolean default_editable); 972 return gtk_text_buffer_insert_interactive(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), len, defaultEditable); 973 } 974 975 /** 976 * Calls gtk_text_buffer_insert_interactive() at the cursor 977 * position. 978 * default_editable indicates the editability of text that doesn't 979 * have a tag affecting editability applied to it. Typically the 980 * result of gtk_text_view_get_editable() is appropriate here. 981 * Params: 982 * text = text in UTF-8 format 983 * len = length of text in bytes, or -1 984 * defaultEditable = default editability of buffer 985 * Returns: whether text was actually inserted 986 */ 987 public int insertInteractiveAtCursor(string text, int len, int defaultEditable) 988 { 989 // gboolean gtk_text_buffer_insert_interactive_at_cursor (GtkTextBuffer *buffer, const gchar *text, gint len, gboolean default_editable); 990 return gtk_text_buffer_insert_interactive_at_cursor(gtkTextBuffer, Str.toStringz(text), len, defaultEditable); 991 } 992 993 /** 994 * Copies text, tags, and pixbufs between start and end (the order 995 * of start and end doesn't matter) and inserts the copy at iter. 996 * Used instead of simply getting/inserting text because it preserves 997 * images and tags. If start and end are in a different buffer from 998 * buffer, the two buffers must share the same tag table. 999 * Implemented via emissions of the insert_text and apply_tag signals, 1000 * so expect those. 1001 * Params: 1002 * iter = a position in buffer 1003 * start = a position in a GtkTextBuffer 1004 * end = another position in the same buffer as start 1005 */ 1006 public void insertRange(TextIter iter, TextIter start, TextIter end) 1007 { 1008 // void gtk_text_buffer_insert_range (GtkTextBuffer *buffer, GtkTextIter *iter, const GtkTextIter *start, const GtkTextIter *end); 1009 gtk_text_buffer_insert_range(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1010 } 1011 1012 /** 1013 * Same as gtk_text_buffer_insert_range(), but does nothing if the 1014 * insertion point isn't editable. The default_editable parameter 1015 * indicates whether the text is editable at iter if no tags 1016 * enclosing iter affect editability. Typically the result of 1017 * gtk_text_view_get_editable() is appropriate here. 1018 * Params: 1019 * iter = a position in buffer 1020 * start = a position in a GtkTextBuffer 1021 * end = another position in the same buffer as start 1022 * defaultEditable = default editability of the buffer 1023 * Returns: whether an insertion was possible at iter 1024 */ 1025 public int insertRangeInteractive(TextIter iter, TextIter start, TextIter end, int defaultEditable) 1026 { 1027 // gboolean gtk_text_buffer_insert_range_interactive (GtkTextBuffer *buffer, GtkTextIter *iter, const GtkTextIter *start, const GtkTextIter *end, gboolean default_editable); 1028 return gtk_text_buffer_insert_range_interactive(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), defaultEditable); 1029 } 1030 1031 /** 1032 * Deletes text between start and end. The order of start and end 1033 * is not actually relevant; gtk_text_buffer_delete() will reorder 1034 * them. This function actually emits the "delete-range" signal, and 1035 * the default handler of that signal deletes the text. Because the 1036 * buffer is modified, all outstanding iterators become invalid after 1037 * calling this function; however, the start and end will be 1038 * re-initialized to point to the location where text was deleted. 1039 * Params: 1040 * start = a position in buffer 1041 * end = another position in buffer 1042 */ 1043 public void delet(TextIter start, TextIter end) 1044 { 1045 // void gtk_text_buffer_delete (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end); 1046 gtk_text_buffer_delete(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1047 } 1048 1049 /** 1050 * Deletes all editable text in the given range. 1051 * Calls gtk_text_buffer_delete() for each editable sub-range of 1052 * [start,end). start and end are revalidated to point to 1053 * the location of the last deleted range, or left untouched if 1054 * no text was deleted. 1055 * Params: 1056 * startIter = start of range to delete 1057 * endIter = end of range 1058 * defaultEditable = whether the buffer is editable by default 1059 * Returns: whether some text was actually deleted 1060 */ 1061 public int deleteInteractive(TextIter startIter, TextIter endIter, int defaultEditable) 1062 { 1063 // gboolean gtk_text_buffer_delete_interactive (GtkTextBuffer *buffer, GtkTextIter *start_iter, GtkTextIter *end_iter, gboolean default_editable); 1064 return gtk_text_buffer_delete_interactive(gtkTextBuffer, (startIter is null) ? null : startIter.getTextIterStruct(), (endIter is null) ? null : endIter.getTextIterStruct(), defaultEditable); 1065 } 1066 1067 /** 1068 * Performs the appropriate action as if the user hit the delete 1069 * key with the cursor at the position specified by iter. In the 1070 * normal case a single character will be deleted, but when 1071 * combining accents are involved, more than one character can 1072 * be deleted, and when precomposed character and accent combinations 1073 * are involved, less than one character will be deleted. 1074 * Because the buffer is modified, all outstanding iterators become 1075 * invalid after calling this function; however, the iter will be 1076 * re-initialized to point to the location where text was deleted. 1077 * Since 2.6 1078 * Params: 1079 * iter = a position in buffer 1080 * interactive = whether the deletion is caused by user interaction 1081 * defaultEditable = whether the buffer is editable by default 1082 * Returns: TRUE if the buffer was modified 1083 */ 1084 public int backspace(TextIter iter, int interactive, int defaultEditable) 1085 { 1086 // gboolean gtk_text_buffer_backspace (GtkTextBuffer *buffer, GtkTextIter *iter, gboolean interactive, gboolean default_editable); 1087 return gtk_text_buffer_backspace(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), interactive, defaultEditable); 1088 } 1089 1090 /** 1091 * Returns the text in the range [start,end). Excludes undisplayed 1092 * text (text marked with tags that set the invisibility attribute) if 1093 * include_hidden_chars is FALSE. Does not include characters 1094 * representing embedded images, so byte and character indexes into 1095 * the returned string do not correspond to byte 1096 * and character indexes into the buffer. Contrast with 1097 * gtk_text_buffer_get_slice(). 1098 * Params: 1099 * start = start of a range 1100 * end = end of a range 1101 * includeHiddenChars = whether to include invisible text 1102 * Returns: an allocated UTF-8 string 1103 */ 1104 public string getText(TextIter start, TextIter end, int includeHiddenChars) 1105 { 1106 // gchar * gtk_text_buffer_get_text (GtkTextBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end, gboolean include_hidden_chars); 1107 return Str.toString(gtk_text_buffer_get_text(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), includeHiddenChars)); 1108 } 1109 1110 /** 1111 * Returns the text in the range [start,end). Excludes undisplayed 1112 * text (text marked with tags that set the invisibility attribute) if 1113 * include_hidden_chars is FALSE. The returned string includes a 1114 * 0xFFFC character whenever the buffer contains 1115 * embedded images, so byte and character indexes into 1116 * the returned string do correspond to byte 1117 * and character indexes into the buffer. Contrast with 1118 * gtk_text_buffer_get_text(). Note that 0xFFFC can occur in normal 1119 * text as well, so it is not a reliable indicator that a pixbuf or 1120 * widget is in the buffer. 1121 * Params: 1122 * start = start of a range 1123 * end = end of a range 1124 * includeHiddenChars = whether to include invisible text 1125 * Returns: an allocated UTF-8 string 1126 */ 1127 public string getSlice(TextIter start, TextIter end, int includeHiddenChars) 1128 { 1129 // gchar * gtk_text_buffer_get_slice (GtkTextBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end, gboolean include_hidden_chars); 1130 return Str.toString(gtk_text_buffer_get_slice(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), includeHiddenChars)); 1131 } 1132 1133 /** 1134 * Inserts an image into the text buffer at iter. The image will be 1135 * counted as one character in character counts, and when obtaining 1136 * the buffer contents as a string, will be represented by the Unicode 1137 * "object replacement character" 0xFFFC. Note that the "slice" 1138 * variants for obtaining portions of the buffer as a string include 1139 * this character for pixbufs, but the "text" variants do 1140 * not. e.g. see gtk_text_buffer_get_slice() and 1141 * gtk_text_buffer_get_text(). 1142 * Params: 1143 * iter = location to insert the pixbuf 1144 * pixbuf = a GdkPixbuf 1145 */ 1146 public void insertPixbuf(TextIter iter, Pixbuf pixbuf) 1147 { 1148 // void gtk_text_buffer_insert_pixbuf (GtkTextBuffer *buffer, GtkTextIter *iter, GdkPixbuf *pixbuf); 1149 gtk_text_buffer_insert_pixbuf(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 1150 } 1151 1152 /** 1153 * Inserts a child widget anchor into the text buffer at iter. The 1154 * anchor will be counted as one character in character counts, and 1155 * when obtaining the buffer contents as a string, will be represented 1156 * by the Unicode "object replacement character" 0xFFFC. Note that the 1157 * "slice" variants for obtaining portions of the buffer as a string 1158 * include this character for child anchors, but the "text" variants do 1159 * not. E.g. see gtk_text_buffer_get_slice() and 1160 * gtk_text_buffer_get_text(). Consider 1161 * gtk_text_buffer_create_child_anchor() as a more convenient 1162 * alternative to this function. The buffer will add a reference to 1163 * the anchor, so you can unref it after insertion. 1164 * Params: 1165 * iter = location to insert the anchor 1166 * anchor = a GtkTextChildAnchor 1167 */ 1168 public void insertChildAnchor(TextIter iter, TextChildAnchor anchor) 1169 { 1170 // void gtk_text_buffer_insert_child_anchor (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextChildAnchor *anchor); 1171 gtk_text_buffer_insert_child_anchor(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (anchor is null) ? null : anchor.getTextChildAnchorStruct()); 1172 } 1173 1174 /** 1175 * This is a convenience function which simply creates a child anchor 1176 * with gtk_text_child_anchor_new() and inserts it into the buffer 1177 * with gtk_text_buffer_insert_child_anchor(). The new anchor is 1178 * owned by the buffer; no reference count is returned to 1179 * the caller of gtk_text_buffer_create_child_anchor(). 1180 * Params: 1181 * iter = location in the buffer 1182 * Returns: the created child anchor. [transfer none] 1183 */ 1184 public TextChildAnchor createChildAnchor(TextIter iter) 1185 { 1186 // GtkTextChildAnchor * gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer, GtkTextIter *iter); 1187 auto p = gtk_text_buffer_create_child_anchor(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct()); 1188 1189 if(p is null) 1190 { 1191 return null; 1192 } 1193 1194 return ObjectG.getDObject!(TextChildAnchor)(cast(GtkTextChildAnchor*) p); 1195 } 1196 1197 /** 1198 * Creates a mark at position where. If mark_name is NULL, the mark 1199 * is anonymous; otherwise, the mark can be retrieved by name using 1200 * gtk_text_buffer_get_mark(). If a mark has left gravity, and text is 1201 * inserted at the mark's current location, the mark will be moved to 1202 * the left of the newly-inserted text. If the mark has right gravity 1203 * (left_gravity = FALSE), the mark will end up on the right of 1204 * newly-inserted text. The standard left-to-right cursor is a mark 1205 * with right gravity (when you type, the cursor stays on the right 1206 * side of the text you're typing). 1207 * The caller of this function does not own a 1208 * reference to the returned GtkTextMark, so you can ignore the 1209 * return value if you like. Marks are owned by the buffer and go 1210 * away when the buffer does. 1211 * Emits the "mark-set" signal as notification of the mark's initial 1212 * placement. 1213 * Params: 1214 * markName = name for mark, or NULL. [allow-none] 1215 * where = location to place mark 1216 * leftGravity = whether the mark has left gravity 1217 * Returns: the new GtkTextMark object. [transfer none] 1218 */ 1219 public TextMark createMark(string markName, TextIter where, int leftGravity) 1220 { 1221 // GtkTextMark * gtk_text_buffer_create_mark (GtkTextBuffer *buffer, const gchar *mark_name, const GtkTextIter *where, gboolean left_gravity); 1222 auto p = gtk_text_buffer_create_mark(gtkTextBuffer, Str.toStringz(markName), (where is null) ? null : where.getTextIterStruct(), leftGravity); 1223 1224 if(p is null) 1225 { 1226 return null; 1227 } 1228 1229 return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) p); 1230 } 1231 1232 /** 1233 * Moves mark to the new location where. Emits the "mark-set" signal 1234 * as notification of the move. 1235 * Params: 1236 * mark = a GtkTextMark 1237 * where = new location for mark in buffer 1238 */ 1239 public void moveMark(TextMark mark, TextIter where) 1240 { 1241 // void gtk_text_buffer_move_mark (GtkTextBuffer *buffer, GtkTextMark *mark, const GtkTextIter *where); 1242 gtk_text_buffer_move_mark(gtkTextBuffer, (mark is null) ? null : mark.getTextMarkStruct(), (where is null) ? null : where.getTextIterStruct()); 1243 } 1244 1245 /** 1246 * Moves the mark named name (which must exist) to location where. 1247 * See gtk_text_buffer_move_mark() for details. 1248 * Params: 1249 * name = name of a mark 1250 * where = new location for mark 1251 */ 1252 public void moveMarkByName(string name, TextIter where) 1253 { 1254 // void gtk_text_buffer_move_mark_by_name (GtkTextBuffer *buffer, const gchar *name, const GtkTextIter *where); 1255 gtk_text_buffer_move_mark_by_name(gtkTextBuffer, Str.toStringz(name), (where is null) ? null : where.getTextIterStruct()); 1256 } 1257 1258 /** 1259 * Adds the mark at position where. The mark must not be added to 1260 * another buffer, and if its name is not NULL then there must not 1261 * be another mark in the buffer with the same name. 1262 * Emits the "mark-set" signal as notification of the mark's initial 1263 * placement. 1264 * Since 2.12 1265 * Params: 1266 * mark = the mark to add 1267 * where = location to place mark 1268 */ 1269 public void addMark(TextMark mark, TextIter where) 1270 { 1271 // void gtk_text_buffer_add_mark (GtkTextBuffer *buffer, GtkTextMark *mark, const GtkTextIter *where); 1272 gtk_text_buffer_add_mark(gtkTextBuffer, (mark is null) ? null : mark.getTextMarkStruct(), (where is null) ? null : where.getTextIterStruct()); 1273 } 1274 1275 /** 1276 * Deletes mark, so that it's no longer located anywhere in the 1277 * buffer. Removes the reference the buffer holds to the mark, so if 1278 * you haven't called g_object_ref() on the mark, it will be freed. Even 1279 * if the mark isn't freed, most operations on mark become 1280 * invalid, until it gets added to a buffer again with 1281 * gtk_text_buffer_add_mark(). Use gtk_text_mark_get_deleted() to 1282 * find out if a mark has been removed from its buffer. 1283 * The "mark-deleted" signal will be emitted as notification after 1284 * the mark is deleted. 1285 * Params: 1286 * mark = a GtkTextMark in buffer 1287 */ 1288 public void deleteMark(TextMark mark) 1289 { 1290 // void gtk_text_buffer_delete_mark (GtkTextBuffer *buffer, GtkTextMark *mark); 1291 gtk_text_buffer_delete_mark(gtkTextBuffer, (mark is null) ? null : mark.getTextMarkStruct()); 1292 } 1293 1294 /** 1295 * Deletes the mark named name; the mark must exist. See 1296 * gtk_text_buffer_delete_mark() for details. 1297 * Params: 1298 * name = name of a mark in buffer 1299 */ 1300 public void deleteMarkByName(string name) 1301 { 1302 // void gtk_text_buffer_delete_mark_by_name (GtkTextBuffer *buffer, const gchar *name); 1303 gtk_text_buffer_delete_mark_by_name(gtkTextBuffer, Str.toStringz(name)); 1304 } 1305 1306 /** 1307 * Returns the mark named name in buffer buffer, or NULL if no such 1308 * mark exists in the buffer. 1309 * Params: 1310 * name = a mark name 1311 * Returns: a GtkTextMark, or NULL. [transfer none] 1312 */ 1313 public TextMark getMark(string name) 1314 { 1315 // GtkTextMark * gtk_text_buffer_get_mark (GtkTextBuffer *buffer, const gchar *name); 1316 auto p = gtk_text_buffer_get_mark(gtkTextBuffer, Str.toStringz(name)); 1317 1318 if(p is null) 1319 { 1320 return null; 1321 } 1322 1323 return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) p); 1324 } 1325 1326 /** 1327 * Returns the mark that represents the cursor (insertion point). 1328 * Equivalent to calling gtk_text_buffer_get_mark() to get the mark 1329 * named "insert", but very slightly more efficient, and involves less 1330 * typing. 1331 * Returns: insertion point mark. [transfer none] 1332 */ 1333 public TextMark getInsert() 1334 { 1335 // GtkTextMark * gtk_text_buffer_get_insert (GtkTextBuffer *buffer); 1336 auto p = gtk_text_buffer_get_insert(gtkTextBuffer); 1337 1338 if(p is null) 1339 { 1340 return null; 1341 } 1342 1343 return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) p); 1344 } 1345 1346 /** 1347 * Returns the mark that represents the selection bound. Equivalent 1348 * to calling gtk_text_buffer_get_mark() to get the mark named 1349 * "selection_bound", but very slightly more efficient, and involves 1350 * less typing. 1351 * The currently-selected text in buffer is the region between the 1352 * "selection_bound" and "insert" marks. If "selection_bound" and 1353 * "insert" are in the same place, then there is no current selection. 1354 * gtk_text_buffer_get_selection_bounds() is another convenient function 1355 * for handling the selection, if you just want to know whether there's a 1356 * selection and what its bounds are. 1357 * Returns: selection bound mark. [transfer none] 1358 */ 1359 public TextMark getSelectionBound() 1360 { 1361 // GtkTextMark * gtk_text_buffer_get_selection_bound (GtkTextBuffer *buffer); 1362 auto p = gtk_text_buffer_get_selection_bound(gtkTextBuffer); 1363 1364 if(p is null) 1365 { 1366 return null; 1367 } 1368 1369 return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) p); 1370 } 1371 1372 /** 1373 * Indicates whether the buffer has some text currently selected. 1374 * Since 2.10 1375 * Returns: TRUE if the there is text selected 1376 */ 1377 public int getHasSelection() 1378 { 1379 // gboolean gtk_text_buffer_get_has_selection (GtkTextBuffer *buffer); 1380 return gtk_text_buffer_get_has_selection(gtkTextBuffer); 1381 } 1382 1383 /** 1384 * This function moves the "insert" and "selection_bound" marks 1385 * simultaneously. If you move them to the same place in two steps 1386 * with gtk_text_buffer_move_mark(), you will temporarily select a 1387 * region in between their old and new locations, which can be pretty 1388 * inefficient since the temporarily-selected region will force stuff 1389 * to be recalculated. This function moves them as a unit, which can 1390 * be optimized. 1391 * Params: 1392 * where = where to put the cursor 1393 */ 1394 public void placeCursor(TextIter where) 1395 { 1396 // void gtk_text_buffer_place_cursor (GtkTextBuffer *buffer, const GtkTextIter *where); 1397 gtk_text_buffer_place_cursor(gtkTextBuffer, (where is null) ? null : where.getTextIterStruct()); 1398 } 1399 1400 /** 1401 * This function moves the "insert" and "selection_bound" marks 1402 * simultaneously. If you move them in two steps 1403 * with gtk_text_buffer_move_mark(), you will temporarily select a 1404 * region in between their old and new locations, which can be pretty 1405 * inefficient since the temporarily-selected region will force stuff 1406 * to be recalculated. This function moves them as a unit, which can 1407 * be optimized. 1408 * Since 2.4 1409 * Params: 1410 * ins = where to put the "insert" mark 1411 * bound = where to put the "selection_bound" mark 1412 */ 1413 public void selectRange(TextIter ins, TextIter bound) 1414 { 1415 // void gtk_text_buffer_select_range (GtkTextBuffer *buffer, const GtkTextIter *ins, const GtkTextIter *bound); 1416 gtk_text_buffer_select_range(gtkTextBuffer, (ins is null) ? null : ins.getTextIterStruct(), (bound is null) ? null : bound.getTextIterStruct()); 1417 } 1418 1419 /** 1420 * Emits the "apply-tag" signal on buffer. The default 1421 * handler for the signal applies tag to the given range. 1422 * start and end do not have to be in order. 1423 * Params: 1424 * tag = a GtkTextTag 1425 * start = one bound of range to be tagged 1426 * end = other bound of range to be tagged 1427 */ 1428 public void applyTag(TextTag tag, TextIter start, TextIter end) 1429 { 1430 // void gtk_text_buffer_apply_tag (GtkTextBuffer *buffer, GtkTextTag *tag, const GtkTextIter *start, const GtkTextIter *end); 1431 gtk_text_buffer_apply_tag(gtkTextBuffer, (tag is null) ? null : tag.getTextTagStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1432 } 1433 1434 /** 1435 * Emits the "remove-tag" signal. The default handler for the signal 1436 * removes all occurrences of tag from the given range. start and 1437 * end don't have to be in order. 1438 * Params: 1439 * tag = a GtkTextTag 1440 * start = one bound of range to be untagged 1441 * end = other bound of range to be untagged 1442 */ 1443 public void removeTag(TextTag tag, TextIter start, TextIter end) 1444 { 1445 // void gtk_text_buffer_remove_tag (GtkTextBuffer *buffer, GtkTextTag *tag, const GtkTextIter *start, const GtkTextIter *end); 1446 gtk_text_buffer_remove_tag(gtkTextBuffer, (tag is null) ? null : tag.getTextTagStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1447 } 1448 1449 /** 1450 * Calls gtk_text_tag_table_lookup() on the buffer's tag table to 1451 * get a GtkTextTag, then calls gtk_text_buffer_apply_tag(). 1452 * Params: 1453 * name = name of a named GtkTextTag 1454 * start = one bound of range to be tagged 1455 * end = other bound of range to be tagged 1456 */ 1457 public void applyTagByName(string name, TextIter start, TextIter end) 1458 { 1459 // void gtk_text_buffer_apply_tag_by_name (GtkTextBuffer *buffer, const gchar *name, const GtkTextIter *start, const GtkTextIter *end); 1460 gtk_text_buffer_apply_tag_by_name(gtkTextBuffer, Str.toStringz(name), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1461 } 1462 1463 /** 1464 * Calls gtk_text_tag_table_lookup() on the buffer's tag table to 1465 * get a GtkTextTag, then calls gtk_text_buffer_remove_tag(). 1466 * Params: 1467 * name = name of a GtkTextTag 1468 * start = one bound of range to be untagged 1469 * end = other bound of range to be untagged 1470 */ 1471 public void removeTagByName(string name, TextIter start, TextIter end) 1472 { 1473 // void gtk_text_buffer_remove_tag_by_name (GtkTextBuffer *buffer, const gchar *name, const GtkTextIter *start, const GtkTextIter *end); 1474 gtk_text_buffer_remove_tag_by_name(gtkTextBuffer, Str.toStringz(name), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1475 } 1476 1477 /** 1478 * Removes all tags in the range between start and end. Be careful 1479 * with this function; it could remove tags added in code unrelated to 1480 * the code you're currently writing. That is, using this function is 1481 * probably a bad idea if you have two or more unrelated code sections 1482 * that add tags. 1483 * Params: 1484 * start = one bound of range to be untagged 1485 * end = other bound of range to be untagged 1486 */ 1487 public void removeAllTags(TextIter start, TextIter end) 1488 { 1489 // void gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer, const GtkTextIter *start, const GtkTextIter *end); 1490 gtk_text_buffer_remove_all_tags(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1491 } 1492 1493 /** 1494 * Obtains an iterator pointing to char_offset within the given 1495 * line. The char_offset must exist, offsets off the end of the line 1496 * are not allowed. Note characters, not bytes; 1497 * UTF-8 may encode one character as multiple bytes. 1498 * Params: 1499 * iter = iterator to initialize. [out] 1500 * lineNumber = line number counting from 0 1501 * charOffset = char offset from start of line 1502 */ 1503 public void getIterAtLineOffset(TextIter iter, int lineNumber, int charOffset) 1504 { 1505 // void gtk_text_buffer_get_iter_at_line_offset (GtkTextBuffer *buffer, GtkTextIter *iter, gint line_number, gint char_offset); 1506 gtk_text_buffer_get_iter_at_line_offset(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), lineNumber, charOffset); 1507 } 1508 1509 /** 1510 * Initializes iter to a position char_offset chars from the start 1511 * of the entire buffer. If char_offset is -1 or greater than the number 1512 * of characters in the buffer, iter is initialized to the end iterator, 1513 * the iterator one past the last valid character in the buffer. 1514 * Params: 1515 * iter = iterator to initialize. [out] 1516 * charOffset = char offset from start of buffer, counting from 0, or -1 1517 */ 1518 public void getIterAtOffset(TextIter iter, int charOffset) 1519 { 1520 // void gtk_text_buffer_get_iter_at_offset (GtkTextBuffer *buffer, GtkTextIter *iter, gint char_offset); 1521 gtk_text_buffer_get_iter_at_offset(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), charOffset); 1522 } 1523 1524 /** 1525 * Initializes iter to the start of the given line. 1526 * Params: 1527 * iter = iterator to initialize. [out] 1528 * lineNumber = line number counting from 0 1529 */ 1530 public void getIterAtLine(TextIter iter, int lineNumber) 1531 { 1532 // void gtk_text_buffer_get_iter_at_line (GtkTextBuffer *buffer, GtkTextIter *iter, gint line_number); 1533 gtk_text_buffer_get_iter_at_line(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), lineNumber); 1534 } 1535 1536 /** 1537 * Obtains an iterator pointing to byte_index within the given line. 1538 * byte_index must be the start of a UTF-8 character, and must not be 1539 * beyond the end of the line. Note bytes, not 1540 * characters; UTF-8 may encode one character as multiple bytes. 1541 * Params: 1542 * iter = iterator to initialize. [out] 1543 * lineNumber = line number counting from 0 1544 * byteIndex = byte index from start of line 1545 */ 1546 public void getIterAtLineIndex(TextIter iter, int lineNumber, int byteIndex) 1547 { 1548 // void gtk_text_buffer_get_iter_at_line_index (GtkTextBuffer *buffer, GtkTextIter *iter, gint line_number, gint byte_index); 1549 gtk_text_buffer_get_iter_at_line_index(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), lineNumber, byteIndex); 1550 } 1551 1552 /** 1553 * Initializes iter with the current position of mark. 1554 * Params: 1555 * iter = iterator to initialize. [out] 1556 * mark = a GtkTextMark in buffer 1557 */ 1558 public void getIterAtMark(TextIter iter, TextMark mark) 1559 { 1560 // void gtk_text_buffer_get_iter_at_mark (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextMark *mark); 1561 gtk_text_buffer_get_iter_at_mark(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (mark is null) ? null : mark.getTextMarkStruct()); 1562 } 1563 1564 /** 1565 * Obtains the location of anchor within buffer. 1566 * Params: 1567 * iter = an iterator to be initialized. [out] 1568 * anchor = a child anchor that appears in buffer 1569 */ 1570 public void getIterAtChildAnchor(TextIter iter, TextChildAnchor anchor) 1571 { 1572 // void gtk_text_buffer_get_iter_at_child_anchor (GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextChildAnchor *anchor); 1573 gtk_text_buffer_get_iter_at_child_anchor(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (anchor is null) ? null : anchor.getTextChildAnchorStruct()); 1574 } 1575 1576 /** 1577 * Initialized iter with the first position in the text buffer. This 1578 * is the same as using gtk_text_buffer_get_iter_at_offset() to get 1579 * the iter at character offset 0. 1580 * Params: 1581 * iter = iterator to initialize. [out] 1582 */ 1583 public void getStartIter(TextIter iter) 1584 { 1585 // void gtk_text_buffer_get_start_iter (GtkTextBuffer *buffer, GtkTextIter *iter); 1586 gtk_text_buffer_get_start_iter(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct()); 1587 } 1588 1589 /** 1590 * Initializes iter with the "end iterator," one past the last valid 1591 * character in the text buffer. If dereferenced with 1592 * gtk_text_iter_get_char(), the end iterator has a character value of 1593 * 0. The entire buffer lies in the range from the first position in 1594 * the buffer (call gtk_text_buffer_get_start_iter() to get 1595 * character position 0) to the end iterator. 1596 * Params: 1597 * iter = iterator to initialize. [out] 1598 */ 1599 public void getEndIter(TextIter iter) 1600 { 1601 // void gtk_text_buffer_get_end_iter (GtkTextBuffer *buffer, GtkTextIter *iter); 1602 gtk_text_buffer_get_end_iter(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct()); 1603 } 1604 1605 /** 1606 * Retrieves the first and last iterators in the buffer, i.e. the 1607 * entire buffer lies within the range [start,end). 1608 * Params: 1609 * start = iterator to initialize with first position in the buffer. [out] 1610 * end = iterator to initialize with the end iterator. [out] 1611 */ 1612 public void getBounds(TextIter start, TextIter end) 1613 { 1614 // void gtk_text_buffer_get_bounds (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end); 1615 gtk_text_buffer_get_bounds(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1616 } 1617 1618 /** 1619 * Indicates whether the buffer has been modified since the last call 1620 * to gtk_text_buffer_set_modified() set the modification flag to 1621 * FALSE. Used for example to enable a "save" function in a text 1622 * editor. 1623 * Returns: TRUE if the buffer has been modified 1624 */ 1625 public int getModified() 1626 { 1627 // gboolean gtk_text_buffer_get_modified (GtkTextBuffer *buffer); 1628 return gtk_text_buffer_get_modified(gtkTextBuffer); 1629 } 1630 1631 /** 1632 * Used to keep track of whether the buffer has been modified since the 1633 * last time it was saved. Whenever the buffer is saved to disk, call 1634 * gtk_text_buffer_set_modified (buffer, FALSE). When the buffer is modified, 1635 * it will automatically toggled on the modified bit again. When the modified 1636 * bit flips, the buffer emits a "modified-changed" signal. 1637 * Params: 1638 * setting = modification flag setting 1639 */ 1640 public void setModified(int setting) 1641 { 1642 // void gtk_text_buffer_set_modified (GtkTextBuffer *buffer, gboolean setting); 1643 gtk_text_buffer_set_modified(gtkTextBuffer, setting); 1644 } 1645 1646 /** 1647 * Deletes the range between the "insert" and "selection_bound" marks, 1648 * that is, the currently-selected text. If interactive is TRUE, 1649 * the editability of the selection will be considered (users can't delete 1650 * uneditable text). 1651 * Params: 1652 * interactive = whether the deletion is caused by user interaction 1653 * defaultEditable = whether the buffer is editable by default 1654 * Returns: whether there was a non-empty selection to delete 1655 */ 1656 public int deleteSelection(int interactive, int defaultEditable) 1657 { 1658 // gboolean gtk_text_buffer_delete_selection (GtkTextBuffer *buffer, gboolean interactive, gboolean default_editable); 1659 return gtk_text_buffer_delete_selection(gtkTextBuffer, interactive, defaultEditable); 1660 } 1661 1662 /** 1663 * Pastes the contents of a clipboard at the insertion point, or 1664 * at override_location. (Note: pasting is asynchronous, that is, 1665 * we'll ask for the paste data and return, and at some point later 1666 * after the main loop runs, the paste data will be inserted.) 1667 * Params: 1668 * clipboard = the GtkClipboard to paste from 1669 * overrideLocation = location to insert pasted text, or NULL for 1670 * at the cursor. [allow-none] 1671 * defaultEditable = whether the buffer is editable by default 1672 */ 1673 public void pasteClipboard(Clipboard clipboard, TextIter overrideLocation, int defaultEditable) 1674 { 1675 // void gtk_text_buffer_paste_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard, GtkTextIter *override_location, gboolean default_editable); 1676 gtk_text_buffer_paste_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct(), (overrideLocation is null) ? null : overrideLocation.getTextIterStruct(), defaultEditable); 1677 } 1678 1679 /** 1680 * Copies the currently-selected text to a clipboard. 1681 * Params: 1682 * clipboard = the GtkClipboard object to copy to 1683 */ 1684 public void copyClipboard(Clipboard clipboard) 1685 { 1686 // void gtk_text_buffer_copy_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard); 1687 gtk_text_buffer_copy_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct()); 1688 } 1689 1690 /** 1691 * Copies the currently-selected text to a clipboard, then deletes 1692 * said text if it's editable. 1693 * Params: 1694 * clipboard = the GtkClipboard object to cut to 1695 * defaultEditable = default editability of the buffer 1696 */ 1697 public void cutClipboard(Clipboard clipboard, int defaultEditable) 1698 { 1699 // void gtk_text_buffer_cut_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard, gboolean default_editable); 1700 gtk_text_buffer_cut_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct(), defaultEditable); 1701 } 1702 1703 /** 1704 * Returns TRUE if some text is selected; places the bounds 1705 * of the selection in start and end (if the selection has length 0, 1706 * then start and end are filled in with the same value). 1707 * start and end will be in ascending order. If start and end are 1708 * NULL, then they are not filled in, but the return value still indicates 1709 * whether text is selected. 1710 * Params: 1711 * start = iterator to initialize with selection start. [out] 1712 * end = iterator to initialize with selection end. [out] 1713 * Returns: whether the selection has nonzero length 1714 */ 1715 public int getSelectionBounds(TextIter start, TextIter end) 1716 { 1717 // gboolean gtk_text_buffer_get_selection_bounds (GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end); 1718 return gtk_text_buffer_get_selection_bounds(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1719 } 1720 1721 /** 1722 * Called to indicate that the buffer operations between here and a 1723 * call to gtk_text_buffer_end_user_action() are part of a single 1724 * user-visible operation. The operations between 1725 * gtk_text_buffer_begin_user_action() and 1726 * gtk_text_buffer_end_user_action() can then be grouped when creating 1727 * an undo stack. GtkTextBuffer maintains a count of calls to 1728 * gtk_text_buffer_begin_user_action() that have not been closed with 1729 * a call to gtk_text_buffer_end_user_action(), and emits the 1730 * "begin-user-action" and "end-user-action" signals only for the 1731 * outermost pair of calls. This allows you to build user actions 1732 * from other user actions. 1733 * The "interactive" buffer mutation functions, such as 1734 * gtk_text_buffer_insert_interactive(), automatically call begin/end 1735 * user action around the buffer operations they perform, so there's 1736 * no need to add extra calls if you user action consists solely of a 1737 * single call to one of those functions. 1738 */ 1739 public void beginUserAction() 1740 { 1741 // void gtk_text_buffer_begin_user_action (GtkTextBuffer *buffer); 1742 gtk_text_buffer_begin_user_action(gtkTextBuffer); 1743 } 1744 1745 /** 1746 * Should be paired with a call to gtk_text_buffer_begin_user_action(). 1747 * See that function for a full explanation. 1748 */ 1749 public void endUserAction() 1750 { 1751 // void gtk_text_buffer_end_user_action (GtkTextBuffer *buffer); 1752 gtk_text_buffer_end_user_action(gtkTextBuffer); 1753 } 1754 1755 /** 1756 * Adds clipboard to the list of clipboards in which the selection 1757 * contents of buffer are available. In most cases, clipboard will be 1758 * the GtkClipboard of type GDK_SELECTION_PRIMARY for a view of buffer. 1759 * Params: 1760 * clipboard = a GtkClipboard 1761 */ 1762 public void addSelectionClipboard(Clipboard clipboard) 1763 { 1764 // void gtk_text_buffer_add_selection_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard); 1765 gtk_text_buffer_add_selection_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct()); 1766 } 1767 1768 /** 1769 * Removes a GtkClipboard added with 1770 * gtk_text_buffer_add_selection_clipboard(). 1771 * Params: 1772 * clipboard = a GtkClipboard added to buffer by 1773 * gtk_text_buffer_add_selection_clipboard() 1774 */ 1775 public void removeSelectionClipboard(Clipboard clipboard) 1776 { 1777 // void gtk_text_buffer_remove_selection_clipboard (GtkTextBuffer *buffer, GtkClipboard *clipboard); 1778 gtk_text_buffer_remove_selection_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct()); 1779 } 1780 1781 /** 1782 * This function deserializes rich text in format format and inserts 1783 * it at iter. 1784 * formats to be used must be registered using 1785 * gtk_text_buffer_register_deserialize_format() or 1786 * gtk_text_buffer_register_deserialize_tagset() beforehand. 1787 * Since 2.10 1788 * Params: 1789 * contentBuffer = the GtkTextBuffer to deserialize into 1790 * format = the rich text format to use for deserializing 1791 * iter = insertion point for the deserialized text 1792 * data = data to deserialize. [array length=length] 1793 * Returns: TRUE on success, FALSE otherwise. 1794 * Throws: GException on failure. 1795 */ 1796 public int deserialize(TextBuffer contentBuffer, GdkAtom format, TextIter iter, ubyte[] data) 1797 { 1798 // gboolean gtk_text_buffer_deserialize (GtkTextBuffer *register_buffer, GtkTextBuffer *content_buffer, GdkAtom format, GtkTextIter *iter, const guint8 *data, gsize length, GError **error); 1799 GError* err = null; 1800 1801 auto p = gtk_text_buffer_deserialize(gtkTextBuffer, (contentBuffer is null) ? null : contentBuffer.getTextBufferStruct(), format, (iter is null) ? null : iter.getTextIterStruct(), data.ptr, cast(int) data.length, &err); 1802 1803 if (err !is null) 1804 { 1805 throw new GException( new ErrorG(err) ); 1806 } 1807 1808 return p; 1809 } 1810 1811 /** 1812 * This functions returns the value set with 1813 * gtk_text_buffer_deserialize_set_can_create_tags() 1814 * Since 2.10 1815 * Params: 1816 * format = a GdkAtom representing a registered rich text format 1817 * Returns: whether deserializing this format may create tags 1818 */ 1819 public int deserializeGetCanCreateTags(GdkAtom format) 1820 { 1821 // gboolean gtk_text_buffer_deserialize_get_can_create_tags (GtkTextBuffer *buffer, GdkAtom format); 1822 return gtk_text_buffer_deserialize_get_can_create_tags(gtkTextBuffer, format); 1823 } 1824 1825 /** 1826 * Use this function to allow a rich text deserialization function to 1827 * create new tags in the receiving buffer. Note that using this 1828 * function is almost always a bad idea, because the rich text 1829 * functions you register should know how to map the rich text format 1830 * they handler to your text buffers set of tags. 1831 * The ability of creating new (arbitrary!) tags in the receiving buffer 1832 * is meant for special rich text formats like the internal one that 1833 * is registered using gtk_text_buffer_register_deserialize_tagset(), 1834 * because that format is essentially a dump of the internal structure 1835 * of the source buffer, including its tag names. 1836 * You should allow creation of tags only if you know what you are 1837 * doing, e.g. if you defined a tagset name for your application 1838 * suite's text buffers and you know that it's fine to receive new 1839 * tags from these buffers, because you know that your application can 1840 * handle the newly created tags. 1841 * Since 2.10 1842 * Params: 1843 * format = a GdkAtom representing a registered rich text format 1844 * canCreateTags = whether deserializing this format may create tags 1845 */ 1846 public void deserializeSetCanCreateTags(GdkAtom format, int canCreateTags) 1847 { 1848 // void gtk_text_buffer_deserialize_set_can_create_tags (GtkTextBuffer *buffer, GdkAtom format, gboolean can_create_tags); 1849 gtk_text_buffer_deserialize_set_can_create_tags(gtkTextBuffer, format, canCreateTags); 1850 } 1851 1852 /** 1853 * This function returns the list of targets this text buffer can 1854 * provide for copying and as DND source. The targets in the list are 1855 * added with info values from the GtkTextBufferTargetInfo enum, 1856 * using gtk_target_list_add_rich_text_targets() and 1857 * gtk_target_list_add_text_targets(). 1858 * Since 2.10 1859 * Returns: the GtkTargetList. [transfer none] 1860 */ 1861 public TargetList getCopyTargetList() 1862 { 1863 // GtkTargetList * gtk_text_buffer_get_copy_target_list (GtkTextBuffer *buffer); 1864 auto p = gtk_text_buffer_get_copy_target_list(gtkTextBuffer); 1865 1866 if(p is null) 1867 { 1868 return null; 1869 } 1870 1871 return ObjectG.getDObject!(TargetList)(cast(GtkTargetList*) p); 1872 } 1873 1874 /** 1875 * This function returns the rich text deserialize formats registered 1876 * with buffer using gtk_text_buffer_register_deserialize_format() or 1877 * gtk_text_buffer_register_deserialize_tagset() 1878 * Since 2.10 1879 * Returns: an array of GdkAtoms representing the registered formats. [array length=n_formats][transfer container] 1880 */ 1881 public GdkAtom[] getDeserializeFormats() 1882 { 1883 // GdkAtom * gtk_text_buffer_get_deserialize_formats (GtkTextBuffer *buffer, gint *n_formats); 1884 int nFormats; 1885 auto p = gtk_text_buffer_get_deserialize_formats(gtkTextBuffer, &nFormats); 1886 1887 if(p is null) 1888 { 1889 return null; 1890 } 1891 1892 return p[0 .. nFormats]; 1893 } 1894 1895 /** 1896 * This function returns the list of targets this text buffer supports 1897 * for pasting and as DND destination. The targets in the list are 1898 * added with info values from the GtkTextBufferTargetInfo enum, 1899 * using gtk_target_list_add_rich_text_targets() and 1900 * gtk_target_list_add_text_targets(). 1901 * Since 2.10 1902 * Returns: the GtkTargetList. [transfer none] 1903 */ 1904 public TargetList getPasteTargetList() 1905 { 1906 // GtkTargetList * gtk_text_buffer_get_paste_target_list (GtkTextBuffer *buffer); 1907 auto p = gtk_text_buffer_get_paste_target_list(gtkTextBuffer); 1908 1909 if(p is null) 1910 { 1911 return null; 1912 } 1913 1914 return ObjectG.getDObject!(TargetList)(cast(GtkTargetList*) p); 1915 } 1916 1917 /** 1918 * This function returns the rich text serialize formats registered 1919 * with buffer using gtk_text_buffer_register_serialize_format() or 1920 * gtk_text_buffer_register_serialize_tagset() 1921 * Since 2.10 1922 * Returns: an array of GdkAtoms representing the registered formats. [array length=n_formats][transfer container] 1923 */ 1924 public GdkAtom[] getSerializeFormats() 1925 { 1926 // GdkAtom * gtk_text_buffer_get_serialize_formats (GtkTextBuffer *buffer, gint *n_formats); 1927 int nFormats; 1928 auto p = gtk_text_buffer_get_serialize_formats(gtkTextBuffer, &nFormats); 1929 1930 if(p is null) 1931 { 1932 return null; 1933 } 1934 1935 return p[0 .. nFormats]; 1936 } 1937 1938 /** 1939 * This function registers a rich text deserialization function along with 1940 * its mime_type with the passed buffer. 1941 * Since 2.10 1942 * Params: 1943 * mimeType = the format's mime-type 1944 * userData = function's user_data 1945 * userDataDestroy = a function to call when user_data is no longer needed 1946 * Returns: the GdkAtom that corresponds to the newly registered format's mime-type. [transfer none] 1947 */ 1948 public GdkAtom registerDeserializeFormat(string mimeType, GtkTextBufferDeserializeFunc funct, void* userData, GDestroyNotify userDataDestroy) 1949 { 1950 // GdkAtom gtk_text_buffer_register_deserialize_format (GtkTextBuffer *buffer, const gchar *mime_type, GtkTextBufferDeserializeFunc function, gpointer user_data, GDestroyNotify user_data_destroy); 1951 return gtk_text_buffer_register_deserialize_format(gtkTextBuffer, Str.toStringz(mimeType), funct, userData, userDataDestroy); 1952 } 1953 1954 /** 1955 * This function registers GTK+'s internal rich text serialization 1956 * format with the passed buffer. See 1957 * gtk_text_buffer_register_serialize_tagset() for details. 1958 * Since 2.10 1959 * Params: 1960 * tagsetName = an optional tagset name, on NULL. [allow-none] 1961 * Returns: the GdkAtom that corresponds to the newly registered format's mime-type. [transfer none] 1962 */ 1963 public GdkAtom registerDeserializeTagset(string tagsetName) 1964 { 1965 // GdkAtom gtk_text_buffer_register_deserialize_tagset (GtkTextBuffer *buffer, const gchar *tagset_name); 1966 return gtk_text_buffer_register_deserialize_tagset(gtkTextBuffer, Str.toStringz(tagsetName)); 1967 } 1968 1969 /** 1970 * This function registers a rich text serialization function along with 1971 * its mime_type with the passed buffer. 1972 * Since 2.10 1973 * Params: 1974 * mimeType = the format's mime-type 1975 * userData = function's user_data 1976 * userDataDestroy = a function to call when user_data is no longer needed 1977 * Returns: the GdkAtom that corresponds to the newly registered format's mime-type. [transfer none] 1978 */ 1979 public GdkAtom registerSerializeFormat(string mimeType, GtkTextBufferSerializeFunc funct, void* userData, GDestroyNotify userDataDestroy) 1980 { 1981 // GdkAtom gtk_text_buffer_register_serialize_format (GtkTextBuffer *buffer, const gchar *mime_type, GtkTextBufferSerializeFunc function, gpointer user_data, GDestroyNotify user_data_destroy); 1982 return gtk_text_buffer_register_serialize_format(gtkTextBuffer, Str.toStringz(mimeType), funct, userData, userDataDestroy); 1983 } 1984 1985 /** 1986 * This function registers GTK+'s internal rich text serialization 1987 * format with the passed buffer. The internal format does not comply 1988 * to any standard rich text format and only works between GtkTextBuffer 1989 * instances. It is capable of serializing all of a text buffer's tags 1990 * and embedded pixbufs. 1991 * This function is just a wrapper around 1992 * gtk_text_buffer_register_serialize_format(). The mime type used 1993 * for registering is "application/x-gtk-text-buffer-rich-text", or 1994 * "application/x-gtk-text-buffer-rich-text;format=tagset_name" if a 1995 * tagset_name was passed. 1996 * The tagset_name can be used to restrict the transfer of rich text 1997 * to buffers with compatible sets of tags, in order to avoid unknown 1998 * tags from being pasted. It is probably the common case to pass an 1999 * identifier != NULL here, since the NULL tagset requires the 2000 * receiving buffer to deal with with pasting of arbitrary tags. 2001 * Since 2.10 2002 * Params: 2003 * tagsetName = an optional tagset name, on NULL. [allow-none] 2004 * Returns: the GdkAtom that corresponds to the newly registered format's mime-type. [transfer none] 2005 */ 2006 public GdkAtom registerSerializeTagset(string tagsetName) 2007 { 2008 // GdkAtom gtk_text_buffer_register_serialize_tagset (GtkTextBuffer *buffer, const gchar *tagset_name); 2009 return gtk_text_buffer_register_serialize_tagset(gtkTextBuffer, Str.toStringz(tagsetName)); 2010 } 2011 2012 /** 2013 * This function serializes the portion of text between start 2014 * and end in the rich text format represented by format. 2015 * formats to be used must be registered using 2016 * gtk_text_buffer_register_serialize_format() or 2017 * gtk_text_buffer_register_serialize_tagset() beforehand. 2018 * Since 2.10 2019 * Params: 2020 * contentBuffer = the GtkTextBuffer to serialize 2021 * format = the rich text format to use for serializing 2022 * start = start of block of text to serialize 2023 * end = end of block of test to serialize 2024 * Returns: the serialized data, encoded as format. [array length=length][transfer full] 2025 */ 2026 public ubyte[] serialize(TextBuffer contentBuffer, GdkAtom format, TextIter start, TextIter end) 2027 { 2028 // guint8 * gtk_text_buffer_serialize (GtkTextBuffer *register_buffer, GtkTextBuffer *content_buffer, GdkAtom format, const GtkTextIter *start, const GtkTextIter *end, gsize *length); 2029 gsize length; 2030 auto p = gtk_text_buffer_serialize(gtkTextBuffer, (contentBuffer is null) ? null : contentBuffer.getTextBufferStruct(), format, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), &length); 2031 2032 if(p is null) 2033 { 2034 return null; 2035 } 2036 2037 return p[0 .. length]; 2038 } 2039 2040 /** 2041 * This function unregisters a rich text format that was previously 2042 * registered using gtk_text_buffer_register_deserialize_format() or 2043 * gtk_text_buffer_register_deserialize_tagset(). 2044 * Since 2.10 2045 * Params: 2046 * format = a GdkAtom representing a registered rich text format. 2047 */ 2048 public void unregisterDeserializeFormat(GdkAtom format) 2049 { 2050 // void gtk_text_buffer_unregister_deserialize_format (GtkTextBuffer *buffer, GdkAtom format); 2051 gtk_text_buffer_unregister_deserialize_format(gtkTextBuffer, format); 2052 } 2053 2054 /** 2055 * This function unregisters a rich text format that was previously 2056 * registered using gtk_text_buffer_register_serialize_format() or 2057 * gtk_text_buffer_register_serialize_tagset() 2058 * Since 2.10 2059 * Params: 2060 * format = a GdkAtom representing a registered rich text format. 2061 */ 2062 public void unregisterSerializeFormat(GdkAtom format) 2063 { 2064 // void gtk_text_buffer_unregister_serialize_format (GtkTextBuffer *buffer, GdkAtom format); 2065 gtk_text_buffer_unregister_serialize_format(gtkTextBuffer, format); 2066 } 2067 }