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