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); 651 end = ObjectG.getDObject!(TextIter)(outend); 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); 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); 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); 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, and must not be 797 * beyond the end of the line. Note bytes, not 798 * characters; UTF-8 may encode one character as multiple bytes. 799 * 800 * Params: 801 * iter = iterator to initialize 802 * lineNumber = line number counting from 0 803 * byteIndex = byte index from start of line 804 */ 805 public void getIterAtLineIndex(out TextIter iter, int lineNumber, int byteIndex) 806 { 807 GtkTextIter* outiter = gMalloc!GtkTextIter(); 808 809 gtk_text_buffer_get_iter_at_line_index(gtkTextBuffer, outiter, lineNumber, byteIndex); 810 811 iter = ObjectG.getDObject!(TextIter)(outiter); 812 } 813 814 /** 815 * Obtains an iterator pointing to @char_offset within the given 816 * line. The @char_offset must exist, offsets off the end of the line 817 * are not allowed. Note characters, not bytes; 818 * UTF-8 may encode one character as multiple bytes. 819 * 820 * Params: 821 * iter = iterator to initialize 822 * lineNumber = line number counting from 0 823 * charOffset = char offset from start of line 824 */ 825 public void getIterAtLineOffset(out TextIter iter, int lineNumber, int charOffset) 826 { 827 GtkTextIter* outiter = gMalloc!GtkTextIter(); 828 829 gtk_text_buffer_get_iter_at_line_offset(gtkTextBuffer, outiter, lineNumber, charOffset); 830 831 iter = ObjectG.getDObject!(TextIter)(outiter); 832 } 833 834 /** 835 * Initializes @iter with the current position of @mark. 836 * 837 * Params: 838 * iter = iterator to initialize 839 * mark = a #GtkTextMark in @buffer 840 */ 841 public void getIterAtMark(out TextIter iter, TextMark mark) 842 { 843 GtkTextIter* outiter = gMalloc!GtkTextIter(); 844 845 gtk_text_buffer_get_iter_at_mark(gtkTextBuffer, outiter, (mark is null) ? null : mark.getTextMarkStruct()); 846 847 iter = ObjectG.getDObject!(TextIter)(outiter); 848 } 849 850 /** 851 * Initializes @iter to a position @char_offset chars from the start 852 * of the entire buffer. If @char_offset is -1 or greater than the number 853 * of characters in the buffer, @iter is initialized to the end iterator, 854 * the iterator one past the last valid character in the buffer. 855 * 856 * Params: 857 * iter = iterator to initialize 858 * charOffset = char offset from start of buffer, counting from 0, or -1 859 */ 860 public void getIterAtOffset(out TextIter iter, int charOffset) 861 { 862 GtkTextIter* outiter = gMalloc!GtkTextIter(); 863 864 gtk_text_buffer_get_iter_at_offset(gtkTextBuffer, outiter, charOffset); 865 866 iter = ObjectG.getDObject!(TextIter)(outiter); 867 } 868 869 /** 870 * Obtains the number of lines in the buffer. This value is cached, so 871 * the function is very fast. 872 * 873 * Return: number of lines in the buffer 874 */ 875 public int getLineCount() 876 { 877 return gtk_text_buffer_get_line_count(gtkTextBuffer); 878 } 879 880 /** 881 * Returns the mark named @name in buffer @buffer, or %NULL if no such 882 * mark exists in the buffer. 883 * 884 * Params: 885 * name = a mark name 886 * 887 * Return: a #GtkTextMark, or %NULL 888 */ 889 public TextMark getMark(string name) 890 { 891 auto p = gtk_text_buffer_get_mark(gtkTextBuffer, Str.toStringz(name)); 892 893 if(p is null) 894 { 895 return null; 896 } 897 898 return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) p); 899 } 900 901 /** 902 * Indicates whether the buffer has been modified since the last call 903 * to gtk_text_buffer_set_modified() set the modification flag to 904 * %FALSE. Used for example to enable a “save” function in a text 905 * editor. 906 * 907 * Return: %TRUE if the buffer has been modified 908 */ 909 public bool getModified() 910 { 911 return gtk_text_buffer_get_modified(gtkTextBuffer) != 0; 912 } 913 914 /** 915 * This function returns the list of targets this text buffer supports 916 * for pasting and as DND destination. The targets in the list are 917 * added with @info values from the #GtkTextBufferTargetInfo enum, 918 * using gtk_target_list_add_rich_text_targets() and 919 * gtk_target_list_add_text_targets(). 920 * 921 * Return: the #GtkTargetList 922 * 923 * Since: 2.10 924 */ 925 public TargetList getPasteTargetList() 926 { 927 auto p = gtk_text_buffer_get_paste_target_list(gtkTextBuffer); 928 929 if(p is null) 930 { 931 return null; 932 } 933 934 return ObjectG.getDObject!(TargetList)(cast(GtkTargetList*) p); 935 } 936 937 /** 938 * Returns the mark that represents the selection bound. Equivalent 939 * to calling gtk_text_buffer_get_mark() to get the mark named 940 * “selection_bound”, but very slightly more efficient, and involves 941 * less typing. 942 * 943 * The currently-selected text in @buffer is the region between the 944 * “selection_bound” and “insert” marks. If “selection_bound” and 945 * “insert” are in the same place, then there is no current selection. 946 * gtk_text_buffer_get_selection_bounds() is another convenient function 947 * for handling the selection, if you just want to know whether there’s a 948 * selection and what its bounds are. 949 * 950 * Return: selection bound mark 951 */ 952 public TextMark getSelectionBound() 953 { 954 auto p = gtk_text_buffer_get_selection_bound(gtkTextBuffer); 955 956 if(p is null) 957 { 958 return null; 959 } 960 961 return ObjectG.getDObject!(TextMark)(cast(GtkTextMark*) p); 962 } 963 964 /** 965 * Returns %TRUE if some text is selected; places the bounds 966 * of the selection in @start and @end (if the selection has length 0, 967 * then @start and @end are filled in with the same value). 968 * @start and @end will be in ascending order. If @start and @end are 969 * NULL, then they are not filled in, but the return value still indicates 970 * whether text is selected. 971 * 972 * Params: 973 * start = iterator to initialize with selection start 974 * end = iterator to initialize with selection end 975 * 976 * Return: whether the selection has nonzero length 977 */ 978 public bool getSelectionBounds(out TextIter start, out TextIter end) 979 { 980 GtkTextIter* outstart = gMalloc!GtkTextIter(); 981 GtkTextIter* outend = gMalloc!GtkTextIter(); 982 983 auto p = gtk_text_buffer_get_selection_bounds(gtkTextBuffer, outstart, outend) != 0; 984 985 start = ObjectG.getDObject!(TextIter)(outstart); 986 end = ObjectG.getDObject!(TextIter)(outend); 987 988 return p; 989 } 990 991 /** 992 * This function returns the rich text serialize formats registered 993 * with @buffer using gtk_text_buffer_register_serialize_format() or 994 * gtk_text_buffer_register_serialize_tagset() 995 * 996 * Return: an array of 997 * #GdkAtoms representing the registered formats. 998 * 999 * Since: 2.10 1000 */ 1001 public GdkAtom[] getSerializeFormats() 1002 { 1003 int nFormats; 1004 1005 auto p = gtk_text_buffer_get_serialize_formats(gtkTextBuffer, &nFormats); 1006 1007 return p[0 .. nFormats]; 1008 } 1009 1010 /** 1011 * Returns the text in the range [@start,@end). Excludes undisplayed 1012 * text (text marked with tags that set the invisibility attribute) if 1013 * @include_hidden_chars is %FALSE. The returned string includes a 1014 * 0xFFFC character whenever the buffer contains 1015 * embedded images, so byte and character indexes into 1016 * the returned string do correspond to byte 1017 * and character indexes into the buffer. Contrast with 1018 * gtk_text_buffer_get_text(). Note that 0xFFFC can occur in normal 1019 * text as well, so it is not a reliable indicator that a pixbuf or 1020 * widget is in the buffer. 1021 * 1022 * Params: 1023 * start = start of a range 1024 * end = end of a range 1025 * includeHiddenChars = whether to include invisible text 1026 * 1027 * Return: an allocated UTF-8 string 1028 */ 1029 public string getSlice(TextIter start, TextIter end, bool includeHiddenChars) 1030 { 1031 return Str.toString(gtk_text_buffer_get_slice(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), includeHiddenChars)); 1032 } 1033 1034 /** 1035 * Initialized @iter with the first position in the text buffer. This 1036 * is the same as using gtk_text_buffer_get_iter_at_offset() to get 1037 * the iter at character offset 0. 1038 * 1039 * Params: 1040 * iter = iterator to initialize 1041 */ 1042 public void getStartIter(out TextIter iter) 1043 { 1044 GtkTextIter* outiter = gMalloc!GtkTextIter(); 1045 1046 gtk_text_buffer_get_start_iter(gtkTextBuffer, outiter); 1047 1048 iter = ObjectG.getDObject!(TextIter)(outiter); 1049 } 1050 1051 /** 1052 * Get the #GtkTextTagTable associated with this buffer. 1053 * 1054 * Return: the buffer’s tag table 1055 */ 1056 public TextTagTable getTagTable() 1057 { 1058 auto p = gtk_text_buffer_get_tag_table(gtkTextBuffer); 1059 1060 if(p is null) 1061 { 1062 return null; 1063 } 1064 1065 return ObjectG.getDObject!(TextTagTable)(cast(GtkTextTagTable*) p); 1066 } 1067 1068 /** 1069 * Returns the text in the range [@start,@end). Excludes undisplayed 1070 * text (text marked with tags that set the invisibility attribute) if 1071 * @include_hidden_chars is %FALSE. Does not include characters 1072 * representing embedded images, so byte and character indexes into 1073 * the returned string do not correspond to byte 1074 * and character indexes into the buffer. Contrast with 1075 * gtk_text_buffer_get_slice(). 1076 * 1077 * Params: 1078 * start = start of a range 1079 * end = end of a range 1080 * includeHiddenChars = whether to include invisible text 1081 * 1082 * Return: an allocated UTF-8 string 1083 */ 1084 public string getText(TextIter start, TextIter end, bool includeHiddenChars) 1085 { 1086 return Str.toString(gtk_text_buffer_get_text(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), includeHiddenChars)); 1087 } 1088 1089 /** 1090 * Inserts @len bytes of @text at position @iter. If @len is -1, 1091 * @text must be nul-terminated and will be inserted in its 1092 * entirety. Emits the “insert-text” signal; insertion actually occurs 1093 * in the default handler for the signal. @iter is invalidated when 1094 * insertion occurs (because the buffer contents change), but the 1095 * default signal handler revalidates it to point to the end of the 1096 * inserted text. 1097 * 1098 * Params: 1099 * iter = a position in the buffer 1100 * text = text in UTF-8 format 1101 * len = length of text in bytes, or -1 1102 */ 1103 public void insert(TextIter iter, string text) 1104 { 1105 gtk_text_buffer_insert(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int)text.length); 1106 } 1107 1108 /** 1109 * Simply calls gtk_text_buffer_insert(), using the current 1110 * cursor position as the insertion point. 1111 * 1112 * Params: 1113 * text = text in UTF-8 format 1114 * len = length of text, in bytes 1115 */ 1116 public void insertAtCursor(string text) 1117 { 1118 gtk_text_buffer_insert_at_cursor(gtkTextBuffer, Str.toStringz(text), cast(int)text.length); 1119 } 1120 1121 /** 1122 * Inserts a child widget anchor into the text buffer at @iter. The 1123 * anchor will be counted as one character in character counts, and 1124 * when obtaining the buffer contents as a string, will be represented 1125 * by the Unicode “object replacement character” 0xFFFC. Note that the 1126 * “slice” variants for obtaining portions of the buffer as a string 1127 * include this character for child anchors, but the “text” variants do 1128 * not. E.g. see gtk_text_buffer_get_slice() and 1129 * gtk_text_buffer_get_text(). Consider 1130 * gtk_text_buffer_create_child_anchor() as a more convenient 1131 * alternative to this function. The buffer will add a reference to 1132 * the anchor, so you can unref it after insertion. 1133 * 1134 * Params: 1135 * iter = location to insert the anchor 1136 * anchor = a #GtkTextChildAnchor 1137 */ 1138 public void insertChildAnchor(TextIter iter, TextChildAnchor anchor) 1139 { 1140 gtk_text_buffer_insert_child_anchor(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (anchor is null) ? null : anchor.getTextChildAnchorStruct()); 1141 } 1142 1143 /** 1144 * Like gtk_text_buffer_insert(), but the insertion will not occur if 1145 * @iter is at a non-editable location in the buffer. Usually you 1146 * want to prevent insertions at ineditable locations if the insertion 1147 * results from a user action (is interactive). 1148 * 1149 * @default_editable indicates the editability of text that doesn't 1150 * have a tag affecting editability applied to it. Typically the 1151 * result of gtk_text_view_get_editable() is appropriate here. 1152 * 1153 * Params: 1154 * iter = a position in @buffer 1155 * text = some UTF-8 text 1156 * len = length of text in bytes, or -1 1157 * defaultEditable = default editability of buffer 1158 * 1159 * Return: whether text was actually inserted 1160 */ 1161 public bool insertInteractive(TextIter iter, string text, bool defaultEditable) 1162 { 1163 return gtk_text_buffer_insert_interactive(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(text), cast(int)text.length, defaultEditable) != 0; 1164 } 1165 1166 /** 1167 * Calls gtk_text_buffer_insert_interactive() at the cursor 1168 * position. 1169 * 1170 * @default_editable indicates the editability of text that doesn't 1171 * have a tag affecting editability applied to it. Typically the 1172 * result of gtk_text_view_get_editable() is appropriate here. 1173 * 1174 * Params: 1175 * text = text in UTF-8 format 1176 * len = length of text in bytes, or -1 1177 * defaultEditable = default editability of buffer 1178 * 1179 * Return: whether text was actually inserted 1180 */ 1181 public bool insertInteractiveAtCursor(string text, bool defaultEditable) 1182 { 1183 return gtk_text_buffer_insert_interactive_at_cursor(gtkTextBuffer, Str.toStringz(text), cast(int)text.length, defaultEditable) != 0; 1184 } 1185 1186 /** 1187 * Inserts the text in @markup at position @iter. @markup will be inserted 1188 * in its entirety and must be nul-terminated and valid UTF-8. Emits the 1189 * #GtkTextBuffer::insert-text signal, possibly multiple times; insertion 1190 * actually occurs in the default handler for the signal. @iter will point 1191 * to the end of the inserted text on return. 1192 * 1193 * Params: 1194 * iter = location to insert the markup 1195 * markup = a nul-terminated UTF-8 string containing [Pango markup][PangoMarkupFormat] 1196 * len = length of @markup in bytes, or -1 1197 * 1198 * Since: 3.16 1199 */ 1200 public void insertMarkup(TextIter iter, string markup, int len) 1201 { 1202 gtk_text_buffer_insert_markup(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), Str.toStringz(markup), len); 1203 } 1204 1205 /** 1206 * Inserts an image into the text buffer at @iter. The image will be 1207 * counted as one character in character counts, and when obtaining 1208 * the buffer contents as a string, will be represented by the Unicode 1209 * “object replacement character” 0xFFFC. Note that the “slice” 1210 * variants for obtaining portions of the buffer as a string include 1211 * this character for pixbufs, but the “text” variants do 1212 * not. e.g. see gtk_text_buffer_get_slice() and 1213 * gtk_text_buffer_get_text(). 1214 * 1215 * Params: 1216 * iter = location to insert the pixbuf 1217 * pixbuf = a #GdkPixbuf 1218 */ 1219 public void insertPixbuf(TextIter iter, Pixbuf pixbuf) 1220 { 1221 gtk_text_buffer_insert_pixbuf(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 1222 } 1223 1224 /** 1225 * Copies text, tags, and pixbufs between @start and @end (the order 1226 * of @start and @end doesn’t matter) and inserts the copy at @iter. 1227 * Used instead of simply getting/inserting text because it preserves 1228 * images and tags. If @start and @end are in a different buffer from 1229 * @buffer, the two buffers must share the same tag table. 1230 * 1231 * Implemented via emissions of the insert_text and apply_tag signals, 1232 * so expect those. 1233 * 1234 * Params: 1235 * iter = a position in @buffer 1236 * start = a position in a #GtkTextBuffer 1237 * end = another position in the same buffer as @start 1238 */ 1239 public void insertRange(TextIter iter, TextIter start, TextIter end) 1240 { 1241 gtk_text_buffer_insert_range(gtkTextBuffer, (iter is null) ? null : iter.getTextIterStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1242 } 1243 1244 /** 1245 * Same as gtk_text_buffer_insert_range(), but does nothing if the 1246 * insertion point isn’t editable. The @default_editable parameter 1247 * indicates whether the text is editable at @iter if no tags 1248 * enclosing @iter affect editability. Typically the result of 1249 * gtk_text_view_get_editable() is appropriate here. 1250 * 1251 * Params: 1252 * iter = a position in @buffer 1253 * start = a position in a #GtkTextBuffer 1254 * end = another position in the same buffer as @start 1255 * defaultEditable = default editability of the buffer 1256 * 1257 * Return: whether an insertion was possible at @iter 1258 */ 1259 public bool insertRangeInteractive(TextIter iter, TextIter start, TextIter end, bool defaultEditable) 1260 { 1261 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; 1262 } 1263 1264 /** 1265 * Moves @mark to the new location @where. Emits the #GtkTextBuffer::mark-set 1266 * signal as notification of the move. 1267 * 1268 * Params: 1269 * mark = a #GtkTextMark 1270 * where = new location for @mark in @buffer 1271 */ 1272 public void moveMark(TextMark mark, TextIter where) 1273 { 1274 gtk_text_buffer_move_mark(gtkTextBuffer, (mark is null) ? null : mark.getTextMarkStruct(), (where is null) ? null : where.getTextIterStruct()); 1275 } 1276 1277 /** 1278 * Moves the mark named @name (which must exist) to location @where. 1279 * See gtk_text_buffer_move_mark() for details. 1280 * 1281 * Params: 1282 * name = name of a mark 1283 * where = new location for mark 1284 */ 1285 public void moveMarkByName(string name, TextIter where) 1286 { 1287 gtk_text_buffer_move_mark_by_name(gtkTextBuffer, Str.toStringz(name), (where is null) ? null : where.getTextIterStruct()); 1288 } 1289 1290 /** 1291 * Pastes the contents of a clipboard. If @override_location is %NULL, the 1292 * pasted text will be inserted at the cursor position, or the buffer selection 1293 * will be replaced if the selection is non-empty. 1294 * 1295 * Note: pasting is asynchronous, that is, we’ll ask for the paste data and 1296 * return, and at some point later after the main loop runs, the paste data will 1297 * be inserted. 1298 * 1299 * Params: 1300 * clipboard = the #GtkClipboard to paste from 1301 * overrideLocation = location to insert pasted text, or %NULL 1302 * defaultEditable = whether the buffer is editable by default 1303 */ 1304 public void pasteClipboard(Clipboard clipboard, TextIter overrideLocation, bool defaultEditable) 1305 { 1306 gtk_text_buffer_paste_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct(), (overrideLocation is null) ? null : overrideLocation.getTextIterStruct(), defaultEditable); 1307 } 1308 1309 /** 1310 * This function moves the “insert” and “selection_bound” marks 1311 * simultaneously. If you move them to the same place in two steps 1312 * with gtk_text_buffer_move_mark(), you will temporarily select a 1313 * region in between their old and new locations, which can be pretty 1314 * inefficient since the temporarily-selected region will force stuff 1315 * to be recalculated. This function moves them as a unit, which can 1316 * be optimized. 1317 * 1318 * Params: 1319 * where = where to put the cursor 1320 */ 1321 public void placeCursor(TextIter where) 1322 { 1323 gtk_text_buffer_place_cursor(gtkTextBuffer, (where is null) ? null : where.getTextIterStruct()); 1324 } 1325 1326 /** 1327 * This function registers a rich text deserialization @function along with 1328 * its @mime_type with the passed @buffer. 1329 * 1330 * Params: 1331 * mimeType = the format’s mime-type 1332 * funct = the deserialize function to register 1333 * userData = @function’s user_data 1334 * userDataDestroy = a function to call when @user_data is no longer needed 1335 * 1336 * Return: the #GdkAtom that corresponds to the 1337 * newly registered format’s mime-type. 1338 * 1339 * Since: 2.10 1340 */ 1341 public GdkAtom registerDeserializeFormat(string mimeType, GtkTextBufferDeserializeFunc funct, void* userData, GDestroyNotify userDataDestroy) 1342 { 1343 return gtk_text_buffer_register_deserialize_format(gtkTextBuffer, Str.toStringz(mimeType), funct, userData, userDataDestroy); 1344 } 1345 1346 /** 1347 * This function registers GTK+’s internal rich text serialization 1348 * format with the passed @buffer. See 1349 * gtk_text_buffer_register_serialize_tagset() for details. 1350 * 1351 * Params: 1352 * tagsetName = an optional tagset name, on %NULL 1353 * 1354 * Return: the #GdkAtom that corresponds to the 1355 * newly registered format’s mime-type. 1356 * 1357 * Since: 2.10 1358 */ 1359 public GdkAtom registerDeserializeTagset(string tagsetName) 1360 { 1361 return gtk_text_buffer_register_deserialize_tagset(gtkTextBuffer, Str.toStringz(tagsetName)); 1362 } 1363 1364 /** 1365 * This function registers a rich text serialization @function along with 1366 * its @mime_type with the passed @buffer. 1367 * 1368 * Params: 1369 * mimeType = the format’s mime-type 1370 * funct = the serialize function to register 1371 * userData = @function’s user_data 1372 * userDataDestroy = a function to call when @user_data is no longer needed 1373 * 1374 * Return: the #GdkAtom that corresponds to the 1375 * newly registered format’s mime-type. 1376 * 1377 * Since: 2.10 1378 */ 1379 public GdkAtom registerSerializeFormat(string mimeType, GtkTextBufferSerializeFunc funct, void* userData, GDestroyNotify userDataDestroy) 1380 { 1381 return gtk_text_buffer_register_serialize_format(gtkTextBuffer, Str.toStringz(mimeType), funct, userData, userDataDestroy); 1382 } 1383 1384 /** 1385 * This function registers GTK+’s internal rich text serialization 1386 * format with the passed @buffer. The internal format does not comply 1387 * to any standard rich text format and only works between #GtkTextBuffer 1388 * instances. It is capable of serializing all of a text buffer’s tags 1389 * and embedded pixbufs. 1390 * 1391 * This function is just a wrapper around 1392 * gtk_text_buffer_register_serialize_format(). The mime type used 1393 * for registering is “application/x-gtk-text-buffer-rich-text”, or 1394 * “application/x-gtk-text-buffer-rich-text;format=@tagset_name” if a 1395 * @tagset_name was passed. 1396 * 1397 * The @tagset_name can be used to restrict the transfer of rich text 1398 * to buffers with compatible sets of tags, in order to avoid unknown 1399 * tags from being pasted. It is probably the common case to pass an 1400 * identifier != %NULL here, since the %NULL tagset requires the 1401 * receiving buffer to deal with with pasting of arbitrary tags. 1402 * 1403 * Params: 1404 * tagsetName = an optional tagset name, on %NULL 1405 * 1406 * Return: the #GdkAtom that corresponds to the 1407 * newly registered format’s mime-type. 1408 * 1409 * Since: 2.10 1410 */ 1411 public GdkAtom registerSerializeTagset(string tagsetName) 1412 { 1413 return gtk_text_buffer_register_serialize_tagset(gtkTextBuffer, Str.toStringz(tagsetName)); 1414 } 1415 1416 /** 1417 * Removes all tags in the range between @start and @end. Be careful 1418 * with this function; it could remove tags added in code unrelated to 1419 * the code you’re currently writing. That is, using this function is 1420 * probably a bad idea if you have two or more unrelated code sections 1421 * that add tags. 1422 * 1423 * Params: 1424 * start = one bound of range to be untagged 1425 * end = other bound of range to be untagged 1426 */ 1427 public void removeAllTags(TextIter start, TextIter end) 1428 { 1429 gtk_text_buffer_remove_all_tags(gtkTextBuffer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1430 } 1431 1432 /** 1433 * Removes a #GtkClipboard added with 1434 * gtk_text_buffer_add_selection_clipboard(). 1435 * 1436 * Params: 1437 * clipboard = a #GtkClipboard added to @buffer by 1438 * gtk_text_buffer_add_selection_clipboard() 1439 */ 1440 public void removeSelectionClipboard(Clipboard clipboard) 1441 { 1442 gtk_text_buffer_remove_selection_clipboard(gtkTextBuffer, (clipboard is null) ? null : clipboard.getClipboardStruct()); 1443 } 1444 1445 /** 1446 * Emits the “remove-tag” signal. The default handler for the signal 1447 * removes all occurrences of @tag from the given range. @start and 1448 * @end don’t have to be in order. 1449 * 1450 * Params: 1451 * tag = a #GtkTextTag 1452 * start = one bound of range to be untagged 1453 * end = other bound of range to be untagged 1454 */ 1455 public void removeTag(TextTag tag, TextIter start, TextIter end) 1456 { 1457 gtk_text_buffer_remove_tag(gtkTextBuffer, (tag is null) ? null : tag.getTextTagStruct(), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1458 } 1459 1460 /** 1461 * Calls gtk_text_tag_table_lookup() on the buffer’s tag table to 1462 * get a #GtkTextTag, then calls gtk_text_buffer_remove_tag(). 1463 * 1464 * Params: 1465 * name = name of a #GtkTextTag 1466 * start = one bound of range to be untagged 1467 * end = other bound of range to be untagged 1468 */ 1469 public void removeTagByName(string name, TextIter start, TextIter end) 1470 { 1471 gtk_text_buffer_remove_tag_by_name(gtkTextBuffer, Str.toStringz(name), (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 1472 } 1473 1474 /** 1475 * This function moves the “insert” and “selection_bound” marks 1476 * simultaneously. If you move them in two steps 1477 * with gtk_text_buffer_move_mark(), you will temporarily select a 1478 * region in between their old and new locations, which can be pretty 1479 * inefficient since the temporarily-selected region will force stuff 1480 * to be recalculated. This function moves them as a unit, which can 1481 * be optimized. 1482 * 1483 * Params: 1484 * ins = where to put the “insert” mark 1485 * bound = where to put the “selection_bound” mark 1486 * 1487 * Since: 2.4 1488 */ 1489 public void selectRange(TextIter ins, TextIter bound) 1490 { 1491 gtk_text_buffer_select_range(gtkTextBuffer, (ins is null) ? null : ins.getTextIterStruct(), (bound is null) ? null : bound.getTextIterStruct()); 1492 } 1493 1494 /** 1495 * This function serializes the portion of text between @start 1496 * and @end in the rich text format represented by @format. 1497 * 1498 * @formats to be used must be registered using 1499 * gtk_text_buffer_register_serialize_format() or 1500 * gtk_text_buffer_register_serialize_tagset() beforehand. 1501 * 1502 * Params: 1503 * contentBuffer = the #GtkTextBuffer to serialize 1504 * format = the rich text format to use for serializing 1505 * start = start of block of text to serialize 1506 * end = end of block of test to serialize 1507 * 1508 * Return: the serialized 1509 * data, encoded as @format 1510 * 1511 * Since: 2.10 1512 */ 1513 public ubyte[] serialize(TextBuffer contentBuffer, GdkAtom format, TextIter start, TextIter end) 1514 { 1515 size_t length; 1516 1517 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); 1518 1519 return p[0 .. length]; 1520 } 1521 1522 /** 1523 * Used to keep track of whether the buffer has been modified since the 1524 * last time it was saved. Whenever the buffer is saved to disk, call 1525 * gtk_text_buffer_set_modified (@buffer, FALSE). When the buffer is modified, 1526 * it will automatically toggled on the modified bit again. When the modified 1527 * bit flips, the buffer emits the #GtkTextBuffer::modified-changed signal. 1528 * 1529 * Params: 1530 * setting = modification flag setting 1531 */ 1532 public void setModified(bool setting) 1533 { 1534 gtk_text_buffer_set_modified(gtkTextBuffer, setting); 1535 } 1536 1537 /** 1538 * Deletes current contents of @buffer, and inserts @text instead. If 1539 * @len is -1, @text must be nul-terminated. @text must be valid UTF-8. 1540 * 1541 * Params: 1542 * text = UTF-8 text to insert 1543 * len = length of @text in bytes 1544 */ 1545 public void setText(string text) 1546 { 1547 gtk_text_buffer_set_text(gtkTextBuffer, Str.toStringz(text), cast(int)text.length); 1548 } 1549 1550 /** 1551 * This function unregisters a rich text format that was previously 1552 * registered using gtk_text_buffer_register_deserialize_format() or 1553 * gtk_text_buffer_register_deserialize_tagset(). 1554 * 1555 * Params: 1556 * format = a #GdkAtom representing a registered rich text format. 1557 * 1558 * Since: 2.10 1559 */ 1560 public void unregisterDeserializeFormat(GdkAtom format) 1561 { 1562 gtk_text_buffer_unregister_deserialize_format(gtkTextBuffer, format); 1563 } 1564 1565 /** 1566 * This function unregisters a rich text format that was previously 1567 * registered using gtk_text_buffer_register_serialize_format() or 1568 * gtk_text_buffer_register_serialize_tagset() 1569 * 1570 * Params: 1571 * format = a #GdkAtom representing a registered rich text format. 1572 * 1573 * Since: 2.10 1574 */ 1575 public void unregisterSerializeFormat(GdkAtom format) 1576 { 1577 gtk_text_buffer_unregister_serialize_format(gtkTextBuffer, format); 1578 } 1579 1580 int[string] connectedSignals; 1581 1582 void delegate(TextTag, TextIter, TextIter, TextBuffer)[] onApplyTagListeners; 1583 /** 1584 * The ::apply-tag signal is emitted to apply a tag to a 1585 * range of text in a #GtkTextBuffer. 1586 * Applying actually occurs in the default handler. 1587 * 1588 * Note that if your handler runs before the default handler it must not 1589 * invalidate the @start and @end iters (or has to revalidate them). 1590 * 1591 * See also: 1592 * gtk_text_buffer_apply_tag(), 1593 * gtk_text_buffer_insert_with_tags(), 1594 * gtk_text_buffer_insert_range(). 1595 * 1596 * Params: 1597 * tag = the applied tag 1598 * start = the start of the range the tag is applied to 1599 * end = the end of the range the tag is applied to 1600 */ 1601 void addOnApplyTag(void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1602 { 1603 if ( "apply-tag" !in connectedSignals ) 1604 { 1605 Signals.connectData( 1606 this, 1607 "apply-tag", 1608 cast(GCallback)&callBackApplyTag, 1609 cast(void*)this, 1610 null, 1611 connectFlags); 1612 connectedSignals["apply-tag"] = 1; 1613 } 1614 onApplyTagListeners ~= dlg; 1615 } 1616 extern(C) static void callBackApplyTag(GtkTextBuffer* textbufferStruct, GtkTextTag* tag, GtkTextIter* start, GtkTextIter* end, TextBuffer _textbuffer) 1617 { 1618 foreach ( void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg; _textbuffer.onApplyTagListeners ) 1619 { 1620 dlg(ObjectG.getDObject!(TextTag)(tag), ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _textbuffer); 1621 } 1622 } 1623 1624 void delegate(TextBuffer)[] onBeginUserActionListeners; 1625 /** 1626 * The ::begin-user-action signal is emitted at the beginning of a single 1627 * user-visible operation on a #GtkTextBuffer. 1628 * 1629 * See also: 1630 * gtk_text_buffer_begin_user_action(), 1631 * gtk_text_buffer_insert_interactive(), 1632 * gtk_text_buffer_insert_range_interactive(), 1633 * gtk_text_buffer_delete_interactive(), 1634 * gtk_text_buffer_backspace(), 1635 * gtk_text_buffer_delete_selection(). 1636 */ 1637 void addOnBeginUserAction(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1638 { 1639 if ( "begin-user-action" !in connectedSignals ) 1640 { 1641 Signals.connectData( 1642 this, 1643 "begin-user-action", 1644 cast(GCallback)&callBackBeginUserAction, 1645 cast(void*)this, 1646 null, 1647 connectFlags); 1648 connectedSignals["begin-user-action"] = 1; 1649 } 1650 onBeginUserActionListeners ~= dlg; 1651 } 1652 extern(C) static void callBackBeginUserAction(GtkTextBuffer* textbufferStruct, TextBuffer _textbuffer) 1653 { 1654 foreach ( void delegate(TextBuffer) dlg; _textbuffer.onBeginUserActionListeners ) 1655 { 1656 dlg(_textbuffer); 1657 } 1658 } 1659 1660 void delegate(TextBuffer)[] onChangedListeners; 1661 /** 1662 * The ::changed signal is emitted when the content of a #GtkTextBuffer 1663 * has changed. 1664 */ 1665 void addOnChanged(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1666 { 1667 if ( "changed" !in connectedSignals ) 1668 { 1669 Signals.connectData( 1670 this, 1671 "changed", 1672 cast(GCallback)&callBackChanged, 1673 cast(void*)this, 1674 null, 1675 connectFlags); 1676 connectedSignals["changed"] = 1; 1677 } 1678 onChangedListeners ~= dlg; 1679 } 1680 extern(C) static void callBackChanged(GtkTextBuffer* textbufferStruct, TextBuffer _textbuffer) 1681 { 1682 foreach ( void delegate(TextBuffer) dlg; _textbuffer.onChangedListeners ) 1683 { 1684 dlg(_textbuffer); 1685 } 1686 } 1687 1688 void delegate(TextIter, TextIter, TextBuffer)[] onDeleteRangeListeners; 1689 /** 1690 * The ::delete-range signal is emitted to delete a range 1691 * from a #GtkTextBuffer. 1692 * 1693 * Note that if your handler runs before the default handler it must not 1694 * invalidate the @start and @end iters (or has to revalidate them). 1695 * The default signal handler revalidates the @start and @end iters to 1696 * both point to the location where text was deleted. Handlers 1697 * which run after the default handler (see g_signal_connect_after()) 1698 * do not have access to the deleted text. 1699 * 1700 * See also: gtk_text_buffer_delete(). 1701 * 1702 * Params: 1703 * start = the start of the range to be deleted 1704 * end = the end of the range to be deleted 1705 */ 1706 void addOnDeleteRange(void delegate(TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1707 { 1708 if ( "delete-range" !in connectedSignals ) 1709 { 1710 Signals.connectData( 1711 this, 1712 "delete-range", 1713 cast(GCallback)&callBackDeleteRange, 1714 cast(void*)this, 1715 null, 1716 connectFlags); 1717 connectedSignals["delete-range"] = 1; 1718 } 1719 onDeleteRangeListeners ~= dlg; 1720 } 1721 extern(C) static void callBackDeleteRange(GtkTextBuffer* textbufferStruct, GtkTextIter* start, GtkTextIter* end, TextBuffer _textbuffer) 1722 { 1723 foreach ( void delegate(TextIter, TextIter, TextBuffer) dlg; _textbuffer.onDeleteRangeListeners ) 1724 { 1725 dlg(ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _textbuffer); 1726 } 1727 } 1728 1729 void delegate(TextBuffer)[] onEndUserActionListeners; 1730 /** 1731 * The ::end-user-action signal is emitted at the end of a single 1732 * user-visible operation on the #GtkTextBuffer. 1733 * 1734 * See also: 1735 * gtk_text_buffer_end_user_action(), 1736 * gtk_text_buffer_insert_interactive(), 1737 * gtk_text_buffer_insert_range_interactive(), 1738 * gtk_text_buffer_delete_interactive(), 1739 * gtk_text_buffer_backspace(), 1740 * gtk_text_buffer_delete_selection(), 1741 * gtk_text_buffer_backspace(). 1742 */ 1743 void addOnEndUserAction(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1744 { 1745 if ( "end-user-action" !in connectedSignals ) 1746 { 1747 Signals.connectData( 1748 this, 1749 "end-user-action", 1750 cast(GCallback)&callBackEndUserAction, 1751 cast(void*)this, 1752 null, 1753 connectFlags); 1754 connectedSignals["end-user-action"] = 1; 1755 } 1756 onEndUserActionListeners ~= dlg; 1757 } 1758 extern(C) static void callBackEndUserAction(GtkTextBuffer* textbufferStruct, TextBuffer _textbuffer) 1759 { 1760 foreach ( void delegate(TextBuffer) dlg; _textbuffer.onEndUserActionListeners ) 1761 { 1762 dlg(_textbuffer); 1763 } 1764 } 1765 1766 void delegate(TextIter, TextChildAnchor, TextBuffer)[] onInsertChildAnchorListeners; 1767 /** 1768 * The ::insert-child-anchor signal is emitted to insert a 1769 * #GtkTextChildAnchor in a #GtkTextBuffer. 1770 * Insertion actually occurs in the default handler. 1771 * 1772 * Note that if your handler runs before the default handler it must 1773 * not invalidate the @location iter (or has to revalidate it). 1774 * The default signal handler revalidates it to be placed after the 1775 * inserted @anchor. 1776 * 1777 * See also: gtk_text_buffer_insert_child_anchor(). 1778 * 1779 * Params: 1780 * location = position to insert @anchor in @textbuffer 1781 * anchor = the #GtkTextChildAnchor to be inserted 1782 */ 1783 void addOnInsertChildAnchor(void delegate(TextIter, TextChildAnchor, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1784 { 1785 if ( "insert-child-anchor" !in connectedSignals ) 1786 { 1787 Signals.connectData( 1788 this, 1789 "insert-child-anchor", 1790 cast(GCallback)&callBackInsertChildAnchor, 1791 cast(void*)this, 1792 null, 1793 connectFlags); 1794 connectedSignals["insert-child-anchor"] = 1; 1795 } 1796 onInsertChildAnchorListeners ~= dlg; 1797 } 1798 extern(C) static void callBackInsertChildAnchor(GtkTextBuffer* textbufferStruct, GtkTextIter* location, GtkTextChildAnchor* anchor, TextBuffer _textbuffer) 1799 { 1800 foreach ( void delegate(TextIter, TextChildAnchor, TextBuffer) dlg; _textbuffer.onInsertChildAnchorListeners ) 1801 { 1802 dlg(ObjectG.getDObject!(TextIter)(location), ObjectG.getDObject!(TextChildAnchor)(anchor), _textbuffer); 1803 } 1804 } 1805 1806 void delegate(TextIter, Pixbuf, TextBuffer)[] onInsertPixbufListeners; 1807 /** 1808 * The ::insert-pixbuf signal is emitted to insert a #GdkPixbuf 1809 * in a #GtkTextBuffer. Insertion actually occurs in the default handler. 1810 * 1811 * Note that if your handler runs before the default handler it must not 1812 * invalidate the @location iter (or has to revalidate it). 1813 * The default signal handler revalidates it to be placed after the 1814 * inserted @pixbuf. 1815 * 1816 * See also: gtk_text_buffer_insert_pixbuf(). 1817 * 1818 * Params: 1819 * location = position to insert @pixbuf in @textbuffer 1820 * pixbuf = the #GdkPixbuf to be inserted 1821 */ 1822 void addOnInsertPixbuf(void delegate(TextIter, Pixbuf, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1823 { 1824 if ( "insert-pixbuf" !in connectedSignals ) 1825 { 1826 Signals.connectData( 1827 this, 1828 "insert-pixbuf", 1829 cast(GCallback)&callBackInsertPixbuf, 1830 cast(void*)this, 1831 null, 1832 connectFlags); 1833 connectedSignals["insert-pixbuf"] = 1; 1834 } 1835 onInsertPixbufListeners ~= dlg; 1836 } 1837 extern(C) static void callBackInsertPixbuf(GtkTextBuffer* textbufferStruct, GtkTextIter* location, GdkPixbuf* pixbuf, TextBuffer _textbuffer) 1838 { 1839 foreach ( void delegate(TextIter, Pixbuf, TextBuffer) dlg; _textbuffer.onInsertPixbufListeners ) 1840 { 1841 dlg(ObjectG.getDObject!(TextIter)(location), ObjectG.getDObject!(Pixbuf)(pixbuf), _textbuffer); 1842 } 1843 } 1844 1845 void delegate(TextIter, string, int, TextBuffer)[] onInsertTextListeners; 1846 /** 1847 * The ::insert-text signal is emitted to insert text in a #GtkTextBuffer. 1848 * Insertion actually occurs in the default handler. 1849 * 1850 * Note that if your handler runs before the default handler it must not 1851 * invalidate the @location iter (or has to revalidate it). 1852 * The default signal handler revalidates it to point to the end of the 1853 * inserted text. 1854 * 1855 * See also: 1856 * gtk_text_buffer_insert(), 1857 * gtk_text_buffer_insert_range(). 1858 * 1859 * Params: 1860 * location = position to insert @text in @textbuffer 1861 * text = the UTF-8 text to be inserted 1862 * len = length of the inserted text in bytes 1863 */ 1864 void addOnInsertText(void delegate(TextIter, string, int, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1865 { 1866 if ( "insert-text" !in connectedSignals ) 1867 { 1868 Signals.connectData( 1869 this, 1870 "insert-text", 1871 cast(GCallback)&callBackInsertText, 1872 cast(void*)this, 1873 null, 1874 connectFlags); 1875 connectedSignals["insert-text"] = 1; 1876 } 1877 onInsertTextListeners ~= dlg; 1878 } 1879 extern(C) static void callBackInsertText(GtkTextBuffer* textbufferStruct, GtkTextIter* location, char* text, int len, TextBuffer _textbuffer) 1880 { 1881 foreach ( void delegate(TextIter, string, int, TextBuffer) dlg; _textbuffer.onInsertTextListeners ) 1882 { 1883 dlg(ObjectG.getDObject!(TextIter)(location), Str.toString(text), len, _textbuffer); 1884 } 1885 } 1886 1887 void delegate(TextMark, TextBuffer)[] onMarkDeletedListeners; 1888 /** 1889 * The ::mark-deleted signal is emitted as notification 1890 * after a #GtkTextMark is deleted. 1891 * 1892 * See also: 1893 * gtk_text_buffer_delete_mark(). 1894 * 1895 * Params: 1896 * mark = The mark that was deleted 1897 */ 1898 void addOnMarkDeleted(void delegate(TextMark, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1899 { 1900 if ( "mark-deleted" !in connectedSignals ) 1901 { 1902 Signals.connectData( 1903 this, 1904 "mark-deleted", 1905 cast(GCallback)&callBackMarkDeleted, 1906 cast(void*)this, 1907 null, 1908 connectFlags); 1909 connectedSignals["mark-deleted"] = 1; 1910 } 1911 onMarkDeletedListeners ~= dlg; 1912 } 1913 extern(C) static void callBackMarkDeleted(GtkTextBuffer* textbufferStruct, GtkTextMark* mark, TextBuffer _textbuffer) 1914 { 1915 foreach ( void delegate(TextMark, TextBuffer) dlg; _textbuffer.onMarkDeletedListeners ) 1916 { 1917 dlg(ObjectG.getDObject!(TextMark)(mark), _textbuffer); 1918 } 1919 } 1920 1921 void delegate(TextIter, TextMark, TextBuffer)[] onMarkSetListeners; 1922 /** 1923 * The ::mark-set signal is emitted as notification 1924 * after a #GtkTextMark is set. 1925 * 1926 * See also: 1927 * gtk_text_buffer_create_mark(), 1928 * gtk_text_buffer_move_mark(). 1929 * 1930 * Params: 1931 * location = The location of @mark in @textbuffer 1932 * mark = The mark that is set 1933 */ 1934 void addOnMarkSet(void delegate(TextIter, TextMark, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1935 { 1936 if ( "mark-set" !in connectedSignals ) 1937 { 1938 Signals.connectData( 1939 this, 1940 "mark-set", 1941 cast(GCallback)&callBackMarkSet, 1942 cast(void*)this, 1943 null, 1944 connectFlags); 1945 connectedSignals["mark-set"] = 1; 1946 } 1947 onMarkSetListeners ~= dlg; 1948 } 1949 extern(C) static void callBackMarkSet(GtkTextBuffer* textbufferStruct, GtkTextIter* location, GtkTextMark* mark, TextBuffer _textbuffer) 1950 { 1951 foreach ( void delegate(TextIter, TextMark, TextBuffer) dlg; _textbuffer.onMarkSetListeners ) 1952 { 1953 dlg(ObjectG.getDObject!(TextIter)(location), ObjectG.getDObject!(TextMark)(mark), _textbuffer); 1954 } 1955 } 1956 1957 void delegate(TextBuffer)[] onModifiedChangedListeners; 1958 /** 1959 * The ::modified-changed signal is emitted when the modified bit of a 1960 * #GtkTextBuffer flips. 1961 * 1962 * See also: 1963 * gtk_text_buffer_set_modified(). 1964 */ 1965 void addOnModifiedChanged(void delegate(TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1966 { 1967 if ( "modified-changed" !in connectedSignals ) 1968 { 1969 Signals.connectData( 1970 this, 1971 "modified-changed", 1972 cast(GCallback)&callBackModifiedChanged, 1973 cast(void*)this, 1974 null, 1975 connectFlags); 1976 connectedSignals["modified-changed"] = 1; 1977 } 1978 onModifiedChangedListeners ~= dlg; 1979 } 1980 extern(C) static void callBackModifiedChanged(GtkTextBuffer* textbufferStruct, TextBuffer _textbuffer) 1981 { 1982 foreach ( void delegate(TextBuffer) dlg; _textbuffer.onModifiedChangedListeners ) 1983 { 1984 dlg(_textbuffer); 1985 } 1986 } 1987 1988 void delegate(Clipboard, TextBuffer)[] onPasteDoneListeners; 1989 /** 1990 * The paste-done signal is emitted after paste operation has been completed. 1991 * This is useful to properly scroll the view to the end of the pasted text. 1992 * See gtk_text_buffer_paste_clipboard() for more details. 1993 * 1994 * Params: 1995 * clipboard = the #GtkClipboard pasted from 1996 * 1997 * Since: 2.16 1998 */ 1999 void addOnPasteDone(void delegate(Clipboard, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2000 { 2001 if ( "paste-done" !in connectedSignals ) 2002 { 2003 Signals.connectData( 2004 this, 2005 "paste-done", 2006 cast(GCallback)&callBackPasteDone, 2007 cast(void*)this, 2008 null, 2009 connectFlags); 2010 connectedSignals["paste-done"] = 1; 2011 } 2012 onPasteDoneListeners ~= dlg; 2013 } 2014 extern(C) static void callBackPasteDone(GtkTextBuffer* textbufferStruct, GtkClipboard* clipboard, TextBuffer _textbuffer) 2015 { 2016 foreach ( void delegate(Clipboard, TextBuffer) dlg; _textbuffer.onPasteDoneListeners ) 2017 { 2018 dlg(ObjectG.getDObject!(Clipboard)(clipboard), _textbuffer); 2019 } 2020 } 2021 2022 void delegate(TextTag, TextIter, TextIter, TextBuffer)[] onRemoveTagListeners; 2023 /** 2024 * The ::remove-tag signal is emitted to remove all occurrences of @tag from 2025 * a range of text in a #GtkTextBuffer. 2026 * Removal actually occurs in the default handler. 2027 * 2028 * Note that if your handler runs before the default handler it must not 2029 * invalidate the @start and @end iters (or has to revalidate them). 2030 * 2031 * See also: 2032 * gtk_text_buffer_remove_tag(). 2033 * 2034 * Params: 2035 * tag = the tag to be removed 2036 * start = the start of the range the tag is removed from 2037 * end = the end of the range the tag is removed from 2038 */ 2039 void addOnRemoveTag(void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2040 { 2041 if ( "remove-tag" !in connectedSignals ) 2042 { 2043 Signals.connectData( 2044 this, 2045 "remove-tag", 2046 cast(GCallback)&callBackRemoveTag, 2047 cast(void*)this, 2048 null, 2049 connectFlags); 2050 connectedSignals["remove-tag"] = 1; 2051 } 2052 onRemoveTagListeners ~= dlg; 2053 } 2054 extern(C) static void callBackRemoveTag(GtkTextBuffer* textbufferStruct, GtkTextTag* tag, GtkTextIter* start, GtkTextIter* end, TextBuffer _textbuffer) 2055 { 2056 foreach ( void delegate(TextTag, TextIter, TextIter, TextBuffer) dlg; _textbuffer.onRemoveTagListeners ) 2057 { 2058 dlg(ObjectG.getDObject!(TextTag)(tag), ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), _textbuffer); 2059 } 2060 } 2061 }