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