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