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