1 // Generated by gmmproc 2.60.0 -- DO NOT MODIFY! 2 #ifndef _GTKMM_TEXTBUFFER_H 3 #define _GTKMM_TEXTBUFFER_H 4 5 #include <gtkmmconfig.h> 6 7 8 #include <glibmm/ustring.h> 9 #include <sigc++/sigc++.h> 10 11 /* Copyright(C) 1998-2002 The gtkmm Development Team 12 * 13 * This library is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU Lesser General Public 15 * License as published by the Free Software Foundation; either 16 * version 2.1 of the License, or(at your option) any later version. 17 * 18 * This library is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * Lesser General Public License for more details. 22 * 23 * You should have received a copy of the GNU Lesser General Public 24 * License along with this library; if not, write to the Free Software 25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 26 */ 27 28 // This is for including the config header before any code (such as 29 // the #ifndef GTKMM_DISABLE_DEPRECATED in deprecated classes) is generated: 30 31 32 #include <vector> 33 34 #include <gtkmm/texttagtable.h> 35 #include <gtkmm/textchildanchor.h> 36 #include <gtkmm/textmark.h> 37 #include <gtkmm/textiter.h> 38 #include <gtkmm/clipboard.h> 39 #include <gdkmm/pixbuf.h> 40 #include <gtkmmconfig.h> 41 #include <utility> 42 43 44 #ifndef DOXYGEN_SHOULD_SKIP_THIS 45 using GtkTextBuffer = struct _GtkTextBuffer; 46 using GtkTextBufferClass = struct _GtkTextBufferClass; 47 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 48 49 50 #ifndef DOXYGEN_SHOULD_SKIP_THIS 51 namespace Gtk 52 { class TextBuffer_Class; } // namespace Gtk 53 #endif //DOXYGEN_SHOULD_SKIP_THIS 54 55 namespace Gtk 56 { 57 58 class TextMark; 59 class TextIter; 60 61 /** Multi-line attributed text that can be displayed by one or more Gtk::TextView widgets. 62 * 63 * Text in a buffer can be marked with tags. A @link Gtk::TextTag Gtk::TextBuffer::Tag@endlink is an attribute that can be applied to some range of text. For example, a tag 64 * might be called "bold" and make the text inside the tag bold. However, the tag concept is more general than that; tags don't 65 * have to affect appearance. They can instead affect the behavior of mouse and key presses, "lock" a range of text so the user 66 * can't edit it, or countless other things. A tag is represented by a @link Gtk::TextTag Gtk::TextBuffer::Tag@endlink object. 67 * One @link Gtk::TextTag Gtk::TextBuffer::Tag@endlink can be applied to any number of text ranges in any number of @link Gtk::TextBuffer Gtk::TextBuffers@endlink. 68 * 69 * Each tag is stored in a @link Gtk::TextTagTable Gtk::TextBuffer::TagTable@endlink. A tag table defines a set of tags that can be used together. Each buffer has one tag 70 * table associated with it; only tags from that tag table can be used with the buffer. A single tag table can be shared between 71 * multiple buffers, however. 72 * 73 * Most text manipulation is accomplished with iterators, represented by an @link Gtk::TextIter iterator@endlink. The iterator can 74 * be used to navigate over characters, words, lines, and sentences. 75 * 76 * But iterators can't be used to preserve positions across buffer modifications. To preserve a position, the 77 * @link Gtk::TextMark Gtk::TextBuffer::Mark@endlink object is ideal. There are two marks built-in to GtkTextBuffer; these are 78 * named "insert" and "selection_bound" and refer to the insertion point and the boundary of the selection which is not the 79 * insertion point. If no text is selected, these two marks will be in the same position. You can manipulate what is selected and 80 * where the cursor appears by moving these marks around. 81 * 82 * Text buffers always contain at least one line, but may be empty (that is, buffers can contain zero characters). The last line 83 * in the text buffer never ends in a line separator (such as newline); the other lines in the buffer always end in a line 84 * separator. Line separators count as characters when computing character counts and character offsets. Note that some Unicode 85 * line separators are represented with multiple bytes in UTF-8, and the two-character sequence "\r\n" is also considered a line 86 * separator. 87 * 88 * @ingroup TextView 89 */ 90 91 class TextBuffer : public Glib::Object 92 { 93 94 #ifndef DOXYGEN_SHOULD_SKIP_THIS 95 96 public: 97 using CppObjectType = TextBuffer; 98 using CppClassType = TextBuffer_Class; 99 using BaseObjectType = GtkTextBuffer; 100 using BaseClassType = GtkTextBufferClass; 101 102 // noncopyable 103 TextBuffer(const TextBuffer&) = delete; 104 TextBuffer& operator=(const TextBuffer&) = delete; 105 106 private: friend class TextBuffer_Class; 107 static CppClassType textbuffer_class_; 108 109 protected: 110 explicit TextBuffer(const Glib::ConstructParams& construct_params); 111 explicit TextBuffer(GtkTextBuffer* castitem); 112 113 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 114 115 public: 116 117 TextBuffer(TextBuffer&& src) noexcept; 118 TextBuffer& operator=(TextBuffer&& src) noexcept; 119 120 ~TextBuffer() noexcept override; 121 122 /** Get the GType for this class, for use with the underlying GObject type system. 123 */ 124 static GType get_type() G_GNUC_CONST; 125 126 #ifndef DOXYGEN_SHOULD_SKIP_THIS 127 128 129 static GType get_base_type() G_GNUC_CONST; 130 #endif 131 132 ///Provides access to the underlying C GObject. gobj()133 GtkTextBuffer* gobj() { return reinterpret_cast<GtkTextBuffer*>(gobject_); } 134 135 ///Provides access to the underlying C GObject. gobj()136 const GtkTextBuffer* gobj() const { return reinterpret_cast<GtkTextBuffer*>(gobject_); } 137 138 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. 139 GtkTextBuffer* gobj_copy(); 140 141 private: 142 143 144 public: 145 typedef TextIter iterator; 146 typedef TextTag Tag; 147 typedef TextTagTable TagTable; 148 typedef TextMark Mark; 149 typedef TextChildAnchor ChildAnchor; 150 151 protected: 152 TextBuffer(); 153 explicit TextBuffer(const Glib::RefPtr<TagTable>& tag_table); 154 155 public: 156 157 static Glib::RefPtr<TextBuffer> create(); 158 159 160 static Glib::RefPtr<TextBuffer> create(const Glib::RefPtr<TagTable>& tag_table); 161 162 163 /** Obtains the number of lines in the buffer. This value is cached, so 164 * the function is very fast. 165 * 166 * @return Number of lines in the buffer. 167 */ 168 int get_line_count() const; 169 170 /** Gets the number of characters in the buffer; note that characters 171 * and bytes are not the same, you can’t e.g.\ expect the contents of 172 * the buffer in string form to be this many bytes long. The character 173 * count is cached, so this function is very fast. 174 * 175 * @return Number of characters in the buffer. 176 */ 177 int get_char_count() const; 178 179 /// See get_char_count(). 180 int size() const; 181 182 183 /** Get the Gtk::TextTagTable associated with this buffer. 184 * 185 * @return The buffer’s tag table. 186 */ 187 Glib::RefPtr<TextBuffer::TagTable> get_tag_table(); 188 189 /** Get the Gtk::TextTagTable associated with this buffer. 190 * 191 * @return The buffer’s tag table. 192 */ 193 Glib::RefPtr<const TextBuffer::TagTable> get_tag_table() const; 194 195 /** Removes the current contents of the buffer, and inserts @a text instead. 196 * @param text The text to put in the buffer. 197 */ 198 void set_text(const Glib::ustring& text); 199 200 /** Removes the current contents of the buffer, and inserts @a text instead. 201 * @param text_begin The start of a UTF8 character array. 202 * @param text_end The end of the UTF8 character array. 203 */ 204 void set_text(const char* text_begin, const char* text_end); 205 206 207 //TODO: Make all insert() methods have the same return type: 208 209 /** Inserts @a text at position @a pos. 210 * Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. 211 * The @a pos iterator is invalidated when insertion occurs (because the buffer contents change). 212 * 213 * @param pos An iterator pointing to the position at which the text should be inserted. 214 * @param text The text to be inserted in the buffer. 215 * @result An iterator that points to the end of the inserted text. 216 */ 217 iterator insert(const iterator& pos, const Glib::ustring& text); 218 219 /** Inserts text at position @a pos. 220 * Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. 221 * The @a pos iterator is invalidated when insertion occurs (because the buffer contents change). 222 * 223 * @param pos An iterator pointing to the position at which the text should be inserted. 224 * @param text_begin The start of a UTF8 character array. 225 * @param text_end The end of the UTF8 character array. 226 * @result An iterator that points to the end of the inserted text. 227 */ 228 iterator insert(const iterator& pos, const char* text_begin, const char* text_end); 229 230 /** Inserts @a text, using the current cursor position as the insertion point. 231 * Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. 232 * 233 * @param text The text to be inserted in the buffer. 234 * @result An iterator that points to the end of the inserted text. 235 */ 236 void insert_at_cursor(const Glib::ustring& text); 237 238 /** Inserts text, using the current cursor position as the insertion point. 239 * Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. 240 * 241 * @param text_begin The start of a UTF8 character array. 242 * @param text_end The end of the UTF8 character array. 243 * @result An iterator that points to the end of the inserted text. 244 */ 245 void insert_at_cursor(const char* text_begin, const char* text_end); 246 247 /** Like insert(), but the insertion will not occur if @a iter is at a non-editable location in the buffer. 248 * Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive). 249 * 250 * @a default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. 251 * Typically the result of Gtk::TextView::get_editable() is appropriate here. 252 * 253 * @param pos An iterator pointing to the position at which the text should be inserted. 254 * @param text The text to be inserted in the buffer. 255 * @param default_editable Default editability of buffer 256 * @result Whether text was actually inserted 257 */ 258 std::pair<iterator,bool> insert_interactive( 259 const iterator& pos, const Glib::ustring& text, bool default_editable = true); 260 261 /** Like insert(), but the insertion will not occur if @a pos is at a non-editable location in the buffer. 262 * Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive). 263 * 264 * @a default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. 265 * Typically the result of Gtk::TextView::get_editable() is appropriate here. 266 * 267 * @param pos An iterator pointing to the position at which the text should be inserted. 268 * @param text_begin The start of a UTF8 character array. 269 * @param text_end The end of the UTF8 character array. 270 * @param default_editable Default editability of buffer. 271 * @result Whether text was actually inserted 272 */ 273 std::pair<iterator,bool> insert_interactive( 274 const iterator& pos, const char* text_begin, const char* text_end, bool default_editable = true); 275 276 /** Calls insert_interactive() at the cursor position. 277 * 278 * @a default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. 279 * Typically the result of Gtk::TextView::get_editable() is appropriate here. 280 * 281 * @param text The text to be inserted in the buffer. 282 * @param default_editable Default editability of buffer 283 * @result Whether text was actually inserted 284 */ 285 bool insert_interactive_at_cursor(const Glib::ustring& text, bool default_editable = true); 286 287 /** Calls insert_interactive() at the cursor position. 288 * 289 * @a default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. 290 * Typically the result of Gtk::TextView::get_editable() is appropriate here. 291 * 292 * @param text_begin The start of a UTF8 character array. 293 * @param text_end The end of the UTF8 character array. 294 * @param default_editable Default editability of buffer 295 * @result Whether text was actually inserted 296 */ 297 bool insert_interactive_at_cursor(const char* text_begin, const char* text_end, 298 bool default_editable = true); 299 300 /** Copies text, tags, and pixbufs between @a range_begin and @a range_end (the order of range_begin and range_begin doesn't 301 * matter) and inserts the copy at @a pos. Used instead of simply getting/inserting text because it preserves images and tags. 302 * If range_begin and range_end are in a different buffer, the two buffers must share the same tag table. 303 * 304 * Implemented via emissions of the insert_text and apply_tag signals, so expect those. 305 * 306 * @param pos An iterator pointing to the position at which the text should be inserted. 307 * @param range_begin A position in a buffer. 308 * @param range_end Another position in the same buffer as @a range_begin. 309 * @result Whether text was actually inserted 310 */ 311 iterator insert(const iterator& pos, const iterator& range_begin, const iterator& range_end); 312 313 314 /** Same as insert_range(), but does nothing if the insertion point isn't editable. 315 * 316 * The @a default_editable parameter indicates whether the text is editable at @a pos if no tags enclosing @a pos affect editability. 317 * Typically the result of Gtk::TextView::get_editable() is appropriate here. 318 * 319 * @param pos An iterator pointing to the position at which the text should be inserted. 320 * @param range_begin A position in a buffer. 321 * @param range_end Another position in the same buffer as @a range_begin. 322 * @param default_editable Default editability of buffer. 323 * @result Whether text was actually inserted 324 */ 325 std::pair<iterator,bool> insert_interactive(const iterator& pos, const iterator& range_begin, const iterator& range_end, bool default_editable = true); 326 327 328 iterator insert_with_tag(const iterator& pos, const Glib::ustring& text, const Glib::RefPtr<Tag>& tag); 329 iterator insert_with_tag(const iterator& pos, const char* text_begin, const char* text_end, const Glib::RefPtr<Tag>& tag); 330 331 iterator insert_with_tag(const iterator& pos, const Glib::ustring& text, const Glib::ustring& tag_name); 332 iterator insert_with_tag(const iterator& pos, const char* text_begin, const char* text_end, const Glib::ustring& tag_name); 333 334 /** Inserts text into buffer at @a pos, applying the list of tags to the newly-inserted text. 335 * Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function. 336 * 337 * @param pos An iterator pointing to the position at which the text should be inserted. 338 * @param text The text to be inserted in the buffer. 339 * @param tags A standard C++ container of @link Gtk::TextTag Gtk::TextBuffer::Tags@endlink. 340 * @result Whether text was actually inserted 341 */ 342 iterator insert_with_tags(const iterator& pos, const Glib::ustring& text, 343 const std::vector< Glib::RefPtr<Tag> >& tags); 344 345 /** Inserts text into buffer at @a pos, applying the list of tags to the newly-inserted text. 346 * Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function. 347 * 348 * @param pos An iterator pointing to the position at which the text should be inserted. 349 * @param text_begin The start of a UTF8 character array. 350 * @param text_end The end of the UTF8 character array. 351 * @param tags A standard C++ container of @link Gtk::TextTag Gtk::TextBuffer::Tags@endlink. 352 * @result Whether text was actually inserted 353 */ 354 iterator insert_with_tags(const iterator& pos, const char* text_begin, const char* text_end, 355 const std::vector< Glib::RefPtr<Tag> >& tags); 356 357 /** Inserts text into buffer at @a pos, applying the list of tags to the newly-inserted text. 358 * Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function. 359 * 360 * @param pos An iterator pointing to the position at which the text should be inserted. 361 * @param text The text to be inserted in the buffer. 362 * @param tag_names A standard C++ container of tag names. 363 * @result Whether text was actually inserted 364 */ 365 iterator insert_with_tags_by_name(const iterator& pos, const Glib::ustring& text, 366 const std::vector<Glib::ustring>& tag_names); 367 368 369 /** Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function. 370 * 371 * @param pos An iterator pointing to the position at which the text should be inserted. 372 * @param text_begin The start of a UTF8 character array. 373 * @param text_end The end of the UTF8 character array. 374 * @param tag_names A standard C++ container of tag names. 375 * @result Whether text was actually inserted 376 */ 377 iterator insert_with_tags_by_name(const iterator& pos, const char* text_begin, const char* text_end, 378 const std::vector<Glib::ustring>& tag_names); 379 380 /** Inserts text in @a markup at position @a pos. 381 * Emits the "insert_text" signal, possibly multiple times; insertion actually occurs in the 382 * default handler for the signal. The @a pos iterator will point to the end of the 383 * inserted text on return. 384 * 385 * @param pos Location to insert the markup. 386 * @param markup The text containing pango markup to be inserted in the buffer. 387 * @result An iterator that points to the end of the inserted markup text. 388 */ 389 iterator insert_markup(const iterator& pos, const Glib::ustring& markup); 390 391 /** Inserts markup text at position @a pos. 392 * Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. 393 * The @a pos iterator will point to the end of the inserted text on return. 394 * 395 * @param pos Location to insert the markup. 396 * @param markup_begin The start of a UTF8 character array containing pango markup. 397 * @param markup_end The end of the UTF8 character array containing pango markup. 398 * @result An iterator that points to the end of the inserted markup text. 399 */ 400 iterator insert_markup(const iterator& pos, const char* markup_begin, const char* markup_end); 401 402 /* Deletes all text between @a range_begin and @a range_end. The order of range_begin and range_end is not actually relevant. 403 * This function actually emits the "delete_range" signal, and the default handler of that signal deletes the text. 404 * Because the buffer is modified, all outstanding iterators become invalid after calling this function. 405 * @param range_begin 406 * @param range_end 407 * @result An iterator that points to the location where text was deleted. 408 */ 409 iterator erase(const iterator& range_begin, const iterator& range_end); 410 411 412 /* Deletes all editable text between @a range_begin and @a range_end. The order of range_begin and range_end is not actually relevant. 413 * This function actually emits the "delete_range" signal, and the default handler of that signal deletes the text. 414 * Because the buffer is modified, all outstanding iterators become invalid after calling this function. 415 * 416 * @a default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. 417 * Typically the result of Gtk::TextView::get_editable() is appropriate here. 418 * 419 * @param range_begin 420 * @param range_end 421 * @param default_editable Default editability of buffer 422 * @result An iterator that points to the location where text was deleted, or end() is no text was deleted. 423 */ 424 std::pair<iterator,bool> erase_interactive(const iterator& range_begin, const iterator& range_end, bool default_editable = true); 425 426 427 /** Performs the appropriate action as if the user hit the delete 428 * key with the cursor at the position specified by @a iter. In the 429 * normal case a single character will be deleted, but when 430 * combining accents are involved, more than one character can 431 * be deleted, and when precomposed character and accent combinations 432 * are involved, less than one character will be deleted. 433 * 434 * Because the buffer is modified, all outstanding iterators become 435 * invalid after calling this method; however, this method returns 436 * a valid iterator that points to the location where text was deleted. 437 * 438 * @param iter A position in the buffer. 439 * @param interactive Whether the deletion is caused by user interaction. 440 * @param default_editable Whether the buffer is editable by default. 441 * @result An iterator to the location where text was deleted, if the buffer was modified. 442 * 443 * @newin{2,6} 444 */ 445 iterator backspace(const iterator& iter, bool interactive = true, bool default_editable = true); 446 447 448 /** Returns the text in the range [ @a range_start, @a range_end). Excludes undisplayed 449 * text (text marked with tags that set the invisibility attribute) if 450 * @a include_hidden_chars is <tt>false</tt>. Does not include characters 451 * representing embedded images, so byte and character indexes into 452 * the returned string do not correspond to byte 453 * and character indexes into the buffer. Contrast with 454 * get_slice(). 455 * 456 * @param range_start Start of a range. 457 * @param range_end End of a range. 458 * @param include_hidden_chars Whether to include invisible text. 459 * @return An allocated UTF-8 string. 460 */ 461 Glib::ustring get_text(const iterator& range_start, const iterator& range_end, bool include_hidden_chars = true) const; 462 463 /** Returns all the text in the buffer. Excludes undisplayed 464 * text (text marked with tags that set the invisibility attribute) if 465 * @a include_hidden_chars is <tt>false</tt>. Does not include characters 466 * representing embedded images, so byte and character indexes into 467 * the returned string do <em>not</em> correspond to byte 468 * and character indexes into the buffer. Contrast with 469 * get_slice(). 470 * 471 * @param include_hidden_chars Whether to include invisible text. 472 * @return An allocated UTF-8 string. 473 */ 474 Glib::ustring get_text(bool include_hidden_chars = true) const; 475 476 477 /** Returns the text in the range [ @a range_start, @a range_end). Excludes undisplayed 478 * text (text marked with tags that set the invisibility attribute) if 479 * @a include_hidden_chars is <tt>false</tt>. The returned string includes a 480 * 0xFFFC character whenever the buffer contains 481 * embedded images, so byte and character indexes into 482 * the returned string do correspond to byte 483 * and character indexes into the buffer. Contrast with 484 * get_text(). Note that 0xFFFC can occur in normal 485 * text as well, so it is not a reliable indicator that a pixbuf or 486 * widget is in the buffer. 487 * 488 * @param range_start Start of a range. 489 * @param range_end End of a range. 490 * @param include_hidden_chars Whether to include invisible text. 491 * @return An allocated UTF-8 string. 492 */ 493 Glib::ustring get_slice(const iterator& range_start, const iterator& range_end, bool include_hidden_chars = true) const; 494 495 iterator insert_pixbuf(const iterator& pos, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf); 496 497 498 iterator insert_child_anchor(const iterator& pos, const Glib::RefPtr<ChildAnchor>& anchor); 499 500 501 Glib::RefPtr<ChildAnchor> create_child_anchor(const iterator& pos); 502 503 504 /** Adds the mark at position @a where. The mark must not be added to 505 * another buffer, and if its name is not <tt>nullptr</tt> then there must not 506 * be another mark in the buffer with the same name. 507 * 508 * Emits the Gtk::TextBuffer::signal_mark_set() signal as notification of the mark's 509 * initial placement. 510 * 511 * @newin{2,12} 512 * 513 * @param mark The mark to add. 514 * @param where Location to place mark. 515 */ 516 void add_mark(const Glib::RefPtr<TextBuffer::Mark>& mark, const iterator& where); 517 518 519 /** Creates a mark at position @a where. The mark can be retrieved by name using 520 * get_mark(). If a mark has left gravity, and text is 521 * inserted at the mark's current location, the mark will be moved to 522 * the left of the newly-inserted text. If the mark has right gravity 523 * ( @a left_gravity = <tt>false</tt>), the mark will end up on the right of 524 * newly-inserted text. The standard left-to-right cursor is a mark 525 * with right gravity (when you type, the cursor stays on the right 526 * side of the text you're typing). 527 * 528 * Emits the "mark_set" signal as notification of the mark's initial 529 * placement. 530 * 531 * @param mark_name Name for mark, or <tt>nullptr</tt>. 532 * @param where Location to place mark. 533 * @param left_gravity Whether the mark has left gravity. 534 * @return The new Gtk::TextMark object. 535 */ 536 Glib::RefPtr<TextBuffer::Mark> create_mark(const Glib::ustring& mark_name, const iterator& where, bool left_gravity = true); 537 538 /** Create an anonymous mark. */ 539 /** Creates an anonymous mark at position @a where. 540 * 541 * If a mark has left gravity, and text is 542 * inserted at the mark's current location, the mark will be moved to 543 * the left of the newly-inserted text. If the mark has right gravity 544 * ( @a left_gravity = <tt>false</tt>), the mark will end up on the right of 545 * newly-inserted text. The standard left-to-right cursor is a mark 546 * with right gravity (when you type, the cursor stays on the right 547 * side of the text you're typing). 548 * 549 * Emits the "mark_set" signal as notification of the mark's initial 550 * placement. 551 * @param where Location to place mark. 552 * @param left_gravity Whether the mark has left gravity. 553 * @return The new Gtk::TextMark object. 554 */ 555 Glib::RefPtr<Mark> create_mark(const iterator& where, bool left_gravity = true); 556 557 558 /** Moves @a mark to the new location @a where. Emits the Gtk::TextBuffer::signal_mark_set() 559 * signal as notification of the move. 560 * 561 * @param mark A Gtk::TextMark. 562 * @param where New location for @a mark in @a buffer. 563 */ 564 void move_mark(const Glib::RefPtr<Mark>& mark, const iterator& where); 565 566 /** Deletes @a mark, so that it's no longer located anywhere in the 567 * buffer. Removes the reference the buffer holds to the mark, so if 568 * you don't keep a Glib::RefPtr to the mark, it will be freed. Even 569 * if the mark isn't freed, most operations on @a mark become 570 * invalid. There is no way to undelete a 571 * mark. Gtk::TextMark::get_deleted() will return <tt>true</tt> after this 572 * function has been called on a mark; Gtk::TextMark::get_deleted() 573 * indicates that a mark no longer belongs to a buffer. The "mark_deleted" 574 * signal will be emitted as notification after the mark is deleted. 575 * 576 * @param mark A Gtk::TextMark in @a buffer. 577 */ 578 void delete_mark(const Glib::RefPtr<Mark>& mark); 579 580 581 /** Returns the mark named @a name in buffer @a buffer, or <tt>nullptr</tt> if no such 582 * mark exists in the buffer. 583 * 584 * @param name A mark name. 585 * @return A Gtk::TextMark, or <tt>nullptr</tt>. 586 */ 587 Glib::RefPtr<TextBuffer::Mark> get_mark(const Glib::ustring& name); 588 589 /** Returns the mark named @a name in buffer @a buffer, or <tt>nullptr</tt> if no such 590 * mark exists in the buffer. 591 * 592 * @param name A mark name. 593 * @return A Gtk::TextMark, or <tt>nullptr</tt>. 594 */ 595 Glib::RefPtr<const TextBuffer::Mark> get_mark(const Glib::ustring& name) const; 596 597 598 /** Moves the mark named @a name (which must exist) to location @a where. 599 * See move_mark() for details. 600 * 601 * @param name Name of a mark. 602 * @param where New location for mark. 603 */ 604 void move_mark_by_name(const Glib::ustring& name, const iterator& where); 605 606 /** Deletes the mark named @a name; the mark must exist. See 607 * delete_mark() for details. 608 * 609 * @param name Name of a mark in @a buffer. 610 */ 611 void delete_mark_by_name(const Glib::ustring& name); 612 613 614 /** Returns the mark that represents the cursor (insertion point). 615 * Equivalent to calling get_mark() to get the mark 616 * named “insert”, but very slightly more efficient, and involves less 617 * typing. 618 * 619 * @return Insertion point mark. 620 */ 621 Glib::RefPtr<TextBuffer::Mark> get_insert(); 622 623 /** Returns the mark that represents the selection bound. Equivalent 624 * to calling get_mark() to get the mark named 625 * “selection_bound”, but very slightly more efficient, and involves 626 * less typing. 627 * 628 * The currently-selected text in @a buffer is the region between the 629 * “selection_bound” and “insert” marks. If “selection_bound” and 630 * “insert” are in the same place, then there is no current selection. 631 * get_selection_bounds() is another convenient function 632 * for handling the selection, if you just want to know whether there’s a 633 * selection and what its bounds are. 634 * 635 * @return Selection bound mark. 636 */ 637 Glib::RefPtr<TextBuffer::Mark> get_selection_bound(); 638 639 640 /** This function moves the “insert” and “selection_bound” marks 641 * simultaneously. If you move them to the same place in two steps 642 * with move_mark(), you will temporarily select a 643 * region in between their old and new locations, which can be pretty 644 * inefficient since the temporarily-selected region will force stuff 645 * to be recalculated. This function moves them as a unit, which can 646 * be optimized. 647 * 648 * @param where Where to put the cursor. 649 */ 650 void place_cursor(const iterator& where); 651 652 /** Emits the “apply-tag” signal on @a buffer. The default 653 * handler for the signal applies @a tag to the given range. 654 * @a range_start and @a range_end do not have to be in order. 655 * 656 * @param tag A Gtk::TextTag. 657 * @param range_start One bound of range to be tagged. 658 * @param range_end Other bound of range to be tagged. 659 */ 660 void apply_tag(const Glib::RefPtr<Tag>& tag, const iterator& range_start, const iterator& range_end); 661 662 /** Emits the “remove-tag” signal. The default handler for the signal 663 * removes all occurrences of @a tag from the given range. @a range_start and 664 * @a range_end don’t have to be in order. 665 * 666 * @param tag A Gtk::TextTag. 667 * @param range_start One bound of range to be untagged. 668 * @param range_end Other bound of range to be untagged. 669 */ 670 void remove_tag(const Glib::RefPtr<Tag>& tag, const iterator& range_start, const iterator& range_end); 671 672 /** Calls Gtk::TextTagTable::lookup() on the buffer’s tag table to 673 * get a Gtk::TextTag, then calls apply_tag(). 674 * 675 * @param name Name of a named Gtk::TextTag. 676 * @param range_start One bound of range to be tagged. 677 * @param range_end Other bound of range to be tagged. 678 */ 679 void apply_tag_by_name(const Glib::ustring& name, const iterator& range_start, const iterator& range_end); 680 681 /** Calls Gtk::TextTagTable::lookup() on the buffer’s tag table to 682 * get a Gtk::TextTag, then calls remove_tag(). 683 * 684 * @param name Name of a Gtk::TextTag. 685 * @param range_start One bound of range to be untagged. 686 * @param range_end Other bound of range to be untagged. 687 */ 688 void remove_tag_by_name(const Glib::ustring& name, const iterator& range_start, const iterator& range_end); 689 690 /** Removes all tags in the range between @a range_start and @a range_end. Be careful 691 * with this function; it could remove tags added in code unrelated to 692 * the code you’re currently writing. That is, using this function is 693 * probably a bad idea if you have two or more unrelated code sections 694 * that add tags. 695 * 696 * @param range_start One bound of range to be untagged. 697 * @param range_end Other bound of range to be untagged. 698 */ 699 void remove_all_tags(const iterator& range_start, const iterator& range_end); 700 701 /** Creates a tag and adds it to the tag table for buffer. Equivalent to calling Gtk::TextBuffer::Tag::create() and then adding 702 * the tag to the buffer's tag table. 703 * A tag called @a tag_name must not already exist in the tag table for this buffer. 704 * 705 * @param tag_name The name for the new tag. 706 * @result The new tag. 707 */ 708 Glib::RefPtr<Tag> create_tag(const Glib::ustring& tag_name); 709 710 711 /** Creates an anoymous tag and adds it to the tag table for buffer. Equivalent to calling Gtk::TextBuffer::Tag::create() and then adding 712 * the tag to the buffer's tag table. 713 * 714 * @result The new tag. 715 */ 716 Glib::RefPtr<Tag> create_tag(); 717 718 iterator get_iter_at_line_offset(int line_number, int char_offset); 719 iterator get_iter_at_line_index(int line_number, int byte_index); 720 iterator get_iter_at_offset(int char_offset); 721 iterator get_iter_at_line(int line_number); 722 iterator begin(); 723 iterator end(); 724 void get_bounds(iterator& range_begin, iterator& range_end); 725 726 /** Get the current position of a mark. 727 * @param mark The @link Gtk::TextMark Gtk::TextBuffer::Mark@endlink 728 * @result An iterator that points to the position of the @a mark. 729 */ 730 iterator get_iter_at_mark(const Glib::RefPtr<Mark>& mark); 731 732 /** Get the current position of an anchor. 733 * @param anchor A @link Gtk::TextChildAnchor Gtk::TextBuffer::Anchor@endlink that appears in the buffer. 734 * @result An iterator that points to the position of the @a anchor. 735 */ 736 iterator get_iter_at_child_anchor(const Glib::RefPtr<ChildAnchor>& anchor); 737 738 739 /** Indicates whether the buffer has been modified since the last call 740 * to set_modified() set the modification flag to 741 * <tt>false</tt>. Used for example to enable a “save” function in a text 742 * editor. 743 * 744 * @return <tt>true</tt> if the buffer has been modified. 745 */ 746 bool get_modified() const; 747 748 /** Used to keep track of whether the buffer has been modified since the 749 * last time it was saved. Whenever the buffer is saved to disk, call 750 * gtk_text_buffer_set_modified ( @a buffer, <tt>false</tt>). When the buffer is modified, 751 * it will automatically toggled on the modified bit again. When the modified 752 * bit flips, the buffer emits the Gtk::TextBuffer::signal_modified_changed() signal. 753 * 754 * @param setting Modification flag setting. 755 */ 756 void set_modified(bool setting = true); 757 758 759 /** Indicates whether the buffer has some text currently selected. 760 * 761 * @newin{2,10} 762 * 763 * @return <tt>true</tt> if the there is text selected. 764 */ 765 bool get_has_selection() const; 766 767 768 /** Adds @a clipboard to the list of clipboards in which the selection 769 * contents of @a buffer are available. In most cases, @a clipboard will be 770 * the Gtk::Clipboard of type GDK_SELECTION_PRIMARY for a view of @a buffer. 771 * 772 * @param clipboard A Gtk::Clipboard. 773 */ 774 void add_selection_clipboard(const Glib::RefPtr<Clipboard>& clipboard); 775 776 /** Removes a Gtk::Clipboard added with 777 * add_selection_clipboard(). 778 * 779 * @param clipboard A Gtk::Clipboard added to @a buffer by 780 * add_selection_clipboard(). 781 */ 782 void remove_selection_clipboard(const Glib::RefPtr<Clipboard>& clipboard); 783 784 /** Copies the currently-selected text to a clipboard, then deletes 785 * said text if it’s editable. 786 * 787 * @param clipboard The Gtk::Clipboard object to cut to. 788 * @param default_editable Default editability of the buffer. 789 */ 790 void cut_clipboard(const Glib::RefPtr<Clipboard>& clipboard, bool default_editable = true); 791 792 /** Copies the currently-selected text to a clipboard. 793 * 794 * @param clipboard The Gtk::Clipboard object to copy to. 795 */ 796 void copy_clipboard(const Glib::RefPtr<Clipboard>& clipboard); 797 void paste_clipboard(const Glib::RefPtr<Clipboard>& clipboard, const iterator& override_location, bool default_editable = true); 798 void paste_clipboard(const Glib::RefPtr<Clipboard>& clipboard, bool default_editable = true); 799 800 801 /** Returns <tt>true</tt> if some text is selected; places the bounds 802 * of the selection in @a range_start and @a range_end (if the selection has length 0, 803 * then @a range_start and @a range_end are filled in with the same value). 804 * @a range_start and @a range_end will be in ascending order. If @a range_start and @a range_end are 805 * <tt>nullptr</tt>, then they are not filled in, but the return value still indicates 806 * whether text is selected. 807 * 808 * @param range_start Iterator to initialize with selection start. 809 * @param range_end Iterator to initialize with selection end. 810 * @return Whether the selection has nonzero length. 811 */ 812 bool get_selection_bounds(iterator& range_start, iterator& range_end) const; 813 814 /** Deletes the range between the “insert” and “selection_bound” marks, 815 * that is, the currently-selected text. If @a interactive is <tt>true</tt>, 816 * the editability of the selection will be considered (users can’t delete 817 * uneditable text). 818 * 819 * @param interactive Whether the deletion is caused by user interaction. 820 * @param default_editable Whether the buffer is editable by default. 821 * @return Whether there was a non-empty selection to delete. 822 */ 823 bool erase_selection(bool interactive = true, bool default_editable = true); 824 825 826 /** This function moves the “insert” and “selection_bound” marks 827 * simultaneously. If you move them in two steps 828 * with move_mark(), you will temporarily select a 829 * region in between their old and new locations, which can be pretty 830 * inefficient since the temporarily-selected region will force stuff 831 * to be recalculated. This function moves them as a unit, which can 832 * be optimized. 833 * 834 * @newin{2,4} 835 * 836 * @param ins Where to put the “insert” mark. 837 * @param bound Where to put the “selection_bound” mark. 838 */ 839 void select_range(const iterator& ins, const iterator& bound); 840 841 /* Called to specify atomic user actions, used to implement undo */ 842 843 /** Called to indicate that the buffer operations between here and a 844 * call to end_user_action() are part of a single 845 * user-visible operation. The operations between 846 * begin_user_action() and 847 * end_user_action() can then be grouped when creating 848 * an undo stack. Gtk::TextBuffer maintains a count of calls to 849 * begin_user_action() that have not been closed with 850 * a call to end_user_action(), and emits the 851 * “begin-user-action” and “end-user-action” signals only for the 852 * outermost pair of calls. This allows you to build user actions 853 * from other user actions. 854 * 855 * The “interactive” buffer mutation functions, such as 856 * insert_interactive(), automatically call begin/end 857 * user action around the buffer operations they perform, so there's 858 * no need to add extra calls if you user action consists solely of a 859 * single call to one of those functions. 860 */ 861 void begin_user_action(); 862 863 /** Should be paired with a call to begin_user_action(). 864 * See that function for a full explanation. 865 */ 866 void end_user_action(); 867 868 869 /** This function returns the list of targets this text buffer can 870 * provide for copying and as DND source. The targets in the list are 871 * added with @a info values from the Gtk::TextBufferTargetInfo enum, 872 * using Gtk::TargetList::add_rich_text_targets() and 873 * Gtk::TargetList::add_text_targets(). 874 * 875 * @newin{2,10} 876 * 877 * @return The Gtk::TargetList. 878 */ 879 Glib::RefPtr<TargetList> get_copy_target_list() const; 880 881 /** This function returns the list of targets this text buffer supports 882 * for pasting and as DND destination. The targets in the list are 883 * added with @a info values from the Gtk::TextBufferTargetInfo enum, 884 * using Gtk::TargetList::add_rich_text_targets() and 885 * Gtk::TargetList::add_text_targets(). 886 * 887 * @newin{2,10} 888 * 889 * @return The Gtk::TargetList. 890 */ 891 Glib::RefPtr<TargetList> get_paste_target_list() const; 892 893 /** For instance,<br> 894 * guint8* on_serialize(const Glib::RefPtr<TextBuffer>& content_buffer, const iterator& start, const iterator& end, gsize& length); 895 * 896 * @param content_buffer The TextBuffer to serialize. It may be different from 897 * the TextBuffer where the serialize format is registered. 898 * @param start Start of the block of text to serialize. 899 * @param end End of the block of text to serialize. 900 * @param[out] length The length of the serialized data. 901 * @return A newly-allocated array of guint8 which contains the serialized data, or <tt>0</tt> if an error occurred. 902 */ 903 typedef sigc::slot<guint8*, const Glib::RefPtr<TextBuffer>&, const iterator&, const iterator&, gsize&> SlotSerialize; 904 905 /** For instance,<br> 906 * bool on_deserialize(const Glib::RefPtr<TextBuffer>& content_buffer, iterator& iter, const guint8* data, gsize length, bool create_tags); 907 * 908 * @param content_buffer The TextBuffer to deserialize into. It may be different 909 * from the TextBuffer where the deserialize format is registered. 910 * @param iter Insertion point for the deserialized text. 911 * @param data Data to deserialize. 912 * @param length Length of data. 913 * @param create_tags <tt>true</tt> if deserializing may create tags. 914 * @return <tt>true</tt> on success, <tt>false</tt> otherwise. 915 * @throw Glib::Error If the deserialize slot throws a Glib::Error or an object 916 * derived from Glib::Error, the exception will be propagated out from 917 * the calling deserialize() method. 918 */ 919 typedef sigc::slot<bool, const Glib::RefPtr<TextBuffer>&, iterator&, const guint8*, gsize, bool> SlotDeserialize; 920 921 /** This function registers a rich text serialization @a slot along with 922 * its @a mime_type with this TextBuffer. 923 * 924 * @newin{3,16} 925 * 926 * @param mime_type The format’s mime-type. 927 * @param slot The serialize slot to register. 928 * @return The newly registered format’s mime-type. 929 */ 930 Glib::ustring register_serialize_format(const Glib::ustring& mime_type, const SlotSerialize& slot); 931 932 933 /** This function registers GTK+’s internal rich text serialization 934 * format with the passed @a buffer. The internal format does not comply 935 * to any standard rich text format and only works between Gtk::TextBuffer 936 * instances. It is capable of serializing all of a text buffer’s tags 937 * and embedded pixbufs. 938 * 939 * This function is just a wrapper around 940 * register_serialize_format(). The mime type used 941 * for registering is “application/x-gtk-text-buffer-rich-text”, or 942 * “application/x-gtk-text-buffer-rich-text;format= @a tagset_name” if a 943 * @a tagset_name was passed. 944 * 945 * The @a tagset_name can be used to restrict the transfer of rich text 946 * to buffers with compatible sets of tags, in order to avoid unknown 947 * tags from being pasted. It is probably the common case to pass an 948 * identifier != <tt>nullptr</tt> here, since the <tt>nullptr</tt> tagset requires the 949 * receiving buffer to deal with with pasting of arbitrary tags. 950 * 951 * @newin{2,10} 952 * 953 * @param tagset_name An optional tagset name, on <tt>nullptr</tt>. 954 * @return The Gdk::Atom that corresponds to the 955 * newly registered format’s mime-type. 956 */ 957 Glib::ustring register_serialize_tagset(const Glib::ustring& tagset_name); 958 959 /** This function registers a rich text deserialization @a slot along with 960 * its @a mime_type with this TextBuffer. 961 * 962 * @newin{3,16} 963 * 964 * @param mime_type The format’s mime-type. 965 * @param slot The deserialize slot to register. 966 * @return The newly registered format’s mime-type. 967 */ 968 Glib::ustring register_deserialize_format(const Glib::ustring& mime_type, const SlotDeserialize& slot); 969 970 971 /** This function registers GTK+’s internal rich text serialization 972 * format with the passed @a buffer. See 973 * register_serialize_tagset() for details. 974 * 975 * @newin{2,10} 976 * 977 * @param tagset_name An optional tagset name, on <tt>nullptr</tt>. 978 * @return The Gdk::Atom that corresponds to the 979 * newly registered format’s mime-type. 980 */ 981 Glib::ustring register_deserialize_tagset(const Glib::ustring& tagset_name); 982 983 984 /** This function unregisters a rich text format that was previously 985 * registered using register_serialize_format() or 986 * register_serialize_tagset() 987 * 988 * @newin{2,10} 989 * 990 * @param format A Gdk::Atom representing a registered rich text format. 991 */ 992 void unregister_serialize_format(const Glib::ustring& format); 993 994 /** This function unregisters a rich text format that was previously 995 * registered using register_deserialize_format() or 996 * register_deserialize_tagset(). 997 * 998 * @newin{2,10} 999 * 1000 * @param format A Gdk::Atom representing a registered rich text format. 1001 */ 1002 void unregister_deserialize_format(const Glib::ustring& format); 1003 1004 1005 /** Use this function to allow a rich text deserialization function to 1006 * create new tags in the receiving buffer. Note that using this 1007 * function is almost always a bad idea, because the rich text 1008 * functions you register should know how to map the rich text format 1009 * they handler to your text buffers set of tags. 1010 * 1011 * The ability of creating new (arbitrary!) tags in the receiving buffer 1012 * is meant for special rich text formats like the internal one that 1013 * is registered using register_deserialize_tagset(), 1014 * because that format is essentially a dump of the internal structure 1015 * of the source buffer, including its tag names. 1016 * 1017 * You should allow creation of tags only if you know what you are 1018 * doing, e.g. if you defined a tagset name for your application 1019 * suite’s text buffers and you know that it’s fine to receive new 1020 * tags from these buffers, because you know that your application can 1021 * handle the newly created tags. 1022 * 1023 * @newin{2,10} 1024 * 1025 * @param format A Gdk::Atom representing a registered rich text format. 1026 * @param can_create_tags Whether deserializing this format may create tags. 1027 */ 1028 void set_can_create_tags(const Glib::ustring& format, bool can_create_tags = true); 1029 1030 /** This functions returns the value set with 1031 * deserialize_set_can_create_tags() 1032 * 1033 * @newin{2,10} 1034 * 1035 * @param format A Gdk::Atom representing a registered rich text format. 1036 * @return Whether deserializing this format may create tags. 1037 */ 1038 bool get_can_create_tags(const Glib::ustring& format) const; 1039 1040 1041 std::vector<Glib::ustring> get_serialize_formats() const; 1042 1043 std::vector<Glib::ustring> get_deserialize_formats() const; 1044 1045 1046 /** This function serializes the portion of text between @a range_start 1047 * and @a range_end in the rich text format represented by @a format. 1048 * 1049 * @a formats to be used must be registered using 1050 * register_serialize_format() or 1051 * register_serialize_tagset() beforehand. 1052 * 1053 * @newin{2,10} 1054 * 1055 * @param content_buffer The Gtk::TextBuffer to serialize. 1056 * @param format The rich text format to use for serializing. 1057 * @param range_start Start of block of text to serialize. 1058 * @param range_end End of block of test to serialize. 1059 * @param length Return location for the length of the serialized data. 1060 * @return The serialized 1061 * data, encoded as @a format. 1062 */ 1063 guint8* serialize(const Glib::RefPtr<TextBuffer>& content_buffer, const Glib::ustring& format, const iterator& range_start, const iterator& range_end, gsize& length); 1064 1065 1066 /** This function deserializes rich text in format @a format and inserts 1067 * it at @a iter. 1068 * 1069 * @a formats to be used must be registered using 1070 * register_deserialize_format() or 1071 * register_deserialize_tagset() beforehand. 1072 * 1073 * @newin{2,10} 1074 * 1075 * @param content_buffer The Gtk::TextBuffer to deserialize into. 1076 * @param format The rich text format to use for deserializing. 1077 * @param iter Insertion point for the deserialized text. 1078 * @param data Data to deserialize. 1079 * @param length Length of @a data. 1080 * @return <tt>true</tt> on success, <tt>false</tt> otherwise. 1081 * 1082 * @throws Glib::Error 1083 */ 1084 bool deserialize(const Glib::RefPtr<TextBuffer>& content_buffer, const Glib::ustring& format, iterator& iter, const guint8* data, gsize length); 1085 1086 1087 /** 1088 * @par Slot Prototype: 1089 * <tt>void on_my_%insert(const TextBuffer::iterator& pos, const Glib::ustring& text, int bytes)</tt> 1090 * 1091 * Flags: Run Last 1092 * 1093 * The signal_insert_text() signal is emitted to insert text in a Gtk::TextBuffer. 1094 * Insertion actually occurs in the default handler. 1095 * 1096 * Note that if your handler runs before the default handler it must not 1097 * invalidate the @a pos iter (or has to revalidate it). 1098 * The default signal handler revalidates it to point to the end of the 1099 * inserted text. 1100 * 1101 * See also: 1102 * Gtk::TextBuffer::insert(), 1103 * Gtk::TextBuffer::insert_range(). 1104 * 1105 * @param pos Position to insert @a text in @a textbuffer. 1106 * @param text The UTF-8 text to be inserted. 1107 * @param bytes Length of the inserted text in bytes. 1108 */ 1109 1110 Glib::SignalProxy< void,const TextBuffer::iterator&,const Glib::ustring&,int > signal_insert(); 1111 1112 1113 /** 1114 * @par Slot Prototype: 1115 * <tt>void on_my_%insert_pixbuf(const TextBuffer::iterator& pos, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)</tt> 1116 * 1117 * Flags: Run Last 1118 * 1119 * The signal_insert_pixbuf() signal is emitted to insert a Gdk::Pixbuf 1120 * in a Gtk::TextBuffer. Insertion actually occurs in the default handler. 1121 * 1122 * Note that if your handler runs before the default handler it must not 1123 * invalidate the @a pos iter (or has to revalidate it). 1124 * The default signal handler revalidates it to be placed after the 1125 * inserted @a pixbuf. 1126 * 1127 * See also: Gtk::TextBuffer::insert_pixbuf(). 1128 * 1129 * @param pos Position to insert @a pixbuf in @a textbuffer. 1130 * @param pixbuf The Gdk::Pixbuf to be inserted. 1131 */ 1132 1133 Glib::SignalProxy< void,const TextBuffer::iterator&,const Glib::RefPtr<Gdk::Pixbuf>& > signal_insert_pixbuf(); 1134 1135 1136 /** 1137 * @par Slot Prototype: 1138 * <tt>void on_my_%insert_child_anchor(const TextBuffer::iterator& pos, const Glib::RefPtr<ChildAnchor>& anchor)</tt> 1139 * 1140 * Flags: Run Last 1141 * 1142 * The signal_insert_child_anchor() signal is emitted to insert a 1143 * Gtk::TextChildAnchor in a Gtk::TextBuffer. 1144 * Insertion actually occurs in the default handler. 1145 * 1146 * Note that if your handler runs before the default handler it must 1147 * not invalidate the @a pos iter (or has to revalidate it). 1148 * The default signal handler revalidates it to be placed after the 1149 * inserted @a anchor. 1150 * 1151 * See also: Gtk::TextBuffer::insert_child_anchor(). 1152 * 1153 * @param pos Position to insert @a anchor in @a textbuffer. 1154 * @param anchor The Gtk::TextChildAnchor to be inserted. 1155 */ 1156 1157 Glib::SignalProxy< void,const TextBuffer::iterator&,const Glib::RefPtr<ChildAnchor>& > signal_insert_child_anchor(); 1158 1159 1160 /** 1161 * @par Slot Prototype: 1162 * <tt>void on_my_%erase(const TextBuffer::iterator& range_start, const TextBuffer::iterator& range_end)</tt> 1163 * 1164 * Flags: Run Last 1165 * 1166 * The signal_delete_range() signal is emitted to delete a range 1167 * from a Gtk::TextBuffer. 1168 * 1169 * Note that if your handler runs before the default handler it must not 1170 * invalidate the @a range_start and @a range_end iters (or has to revalidate them). 1171 * The default signal handler revalidates the @a range_start and @a range_end iters to 1172 * both point to the location where text was deleted. Handlers 1173 * which run after the default handler (see Glib::signal_connect_after()) 1174 * do not have access to the deleted text. 1175 * 1176 * See also: Gtk::TextBuffer::delete(). 1177 * 1178 * @param range_start The start of the range to be deleted. 1179 * @param range_end The end of the range to be deleted. 1180 */ 1181 1182 Glib::SignalProxy< void,const TextBuffer::iterator&,const TextBuffer::iterator& > signal_erase(); 1183 1184 1185 /** 1186 * @par Slot Prototype: 1187 * <tt>void on_my_%changed()</tt> 1188 * 1189 * Flags: Run Last 1190 * 1191 * The signal_changed() signal is emitted when the content of a Gtk::TextBuffer 1192 * has changed. 1193 */ 1194 1195 Glib::SignalProxy< void > signal_changed(); 1196 1197 1198 /** 1199 * @par Slot Prototype: 1200 * <tt>void on_my_%modified_changed()</tt> 1201 * 1202 * Flags: Run Last 1203 * 1204 * The signal_modified_changed() signal is emitted when the modified bit of a 1205 * Gtk::TextBuffer flips. 1206 * 1207 * See also: 1208 * Gtk::TextBuffer::set_modified(). 1209 */ 1210 1211 Glib::SignalProxy< void > signal_modified_changed(); 1212 1213 1214 /** 1215 * @par Slot Prototype: 1216 * <tt>void on_my_%mark_set(const TextBuffer::iterator& location, const Glib::RefPtr<TextBuffer::Mark>& mark)</tt> 1217 * 1218 * Flags: Run Last 1219 * 1220 * The signal_mark_set() signal is emitted as notification 1221 * after a Gtk::TextMark is set. 1222 * 1223 * See also: 1224 * Gtk::TextBuffer::create_mark(), 1225 * Gtk::TextBuffer::move_mark(). 1226 * 1227 * @param location The location of @a mark in @a textbuffer. 1228 * @param mark The mark that is set. 1229 */ 1230 1231 Glib::SignalProxy< void,const TextBuffer::iterator&,const Glib::RefPtr<TextBuffer::Mark>& > signal_mark_set(); 1232 1233 1234 /** 1235 * @par Slot Prototype: 1236 * <tt>void on_my_%mark_deleted(const Glib::RefPtr<TextBuffer::Mark>& mark)</tt> 1237 * 1238 * Flags: Run Last 1239 * 1240 * The signal_mark_deleted() signal is emitted as notification 1241 * after a Gtk::TextMark is deleted. 1242 * 1243 * See also: 1244 * Gtk::TextBuffer::delete_mark(). 1245 * 1246 * @param mark The mark that was deleted. 1247 */ 1248 1249 Glib::SignalProxy< void,const Glib::RefPtr<TextBuffer::Mark>& > signal_mark_deleted(); 1250 1251 1252 /** 1253 * @par Slot Prototype: 1254 * <tt>void on_my_%apply_tag(const Glib::RefPtr<TextBuffer::Tag>& tag, const TextBuffer::iterator& range_begin, const TextBuffer::iterator& range_end)</tt> 1255 * 1256 * Flags: Run Last 1257 * 1258 * The signal_apply_tag() signal is emitted to apply a tag to a 1259 * range of text in a Gtk::TextBuffer. 1260 * Applying actually occurs in the default handler. 1261 * 1262 * Note that if your handler runs before the default handler it must not 1263 * invalidate the @a range_begin and @a range_end iters (or has to revalidate them). 1264 * 1265 * See also: 1266 * Gtk::TextBuffer::apply_tag(), 1267 * Gtk::TextBuffer::insert_with_tags(), 1268 * Gtk::TextBuffer::insert_range(). 1269 * 1270 * @param tag The applied tag. 1271 * @param range_begin The start of the range the tag is applied to. 1272 * @param range_end The end of the range the tag is applied to. 1273 */ 1274 1275 Glib::SignalProxy< void,const Glib::RefPtr<TextBuffer::Tag>&,const TextBuffer::iterator&,const TextBuffer::iterator& > signal_apply_tag(); 1276 1277 1278 /** 1279 * @par Slot Prototype: 1280 * <tt>void on_my_%remove_tag(const Glib::RefPtr<TextBuffer::Tag>& tag, const TextBuffer::iterator& range_begin, const TextBuffer::iterator& range_end)</tt> 1281 * 1282 * Flags: Run Last 1283 * 1284 * The signal_remove_tag() signal is emitted to remove all occurrences of @a tag from 1285 * a range of text in a Gtk::TextBuffer. 1286 * Removal actually occurs in the default handler. 1287 * 1288 * Note that if your handler runs before the default handler it must not 1289 * invalidate the @a range_begin and @a range_end iters (or has to revalidate them). 1290 * 1291 * See also: 1292 * Gtk::TextBuffer::remove_tag(). 1293 * 1294 * @param tag The tag to be removed. 1295 * @param range_begin The start of the range the tag is removed from. 1296 * @param range_end The end of the range the tag is removed from. 1297 */ 1298 1299 Glib::SignalProxy< void,const Glib::RefPtr<TextBuffer::Tag>&,const TextBuffer::iterator&,const TextBuffer::iterator& > signal_remove_tag(); 1300 1301 1302 /** 1303 * @par Slot Prototype: 1304 * <tt>void on_my_%begin_user_action()</tt> 1305 * 1306 * Flags: Run Last 1307 * 1308 * The signal_begin_user_action() signal is emitted at the beginning of a single 1309 * user-visible operation on a Gtk::TextBuffer. 1310 * 1311 * See also: 1312 * Gtk::TextBuffer::begin_user_action(), 1313 * Gtk::TextBuffer::insert_interactive(), 1314 * Gtk::TextBuffer::insert_range_interactive(), 1315 * Gtk::TextBuffer::delete_interactive(), 1316 * Gtk::TextBuffer::backspace(), 1317 * Gtk::TextBuffer::delete_selection(). 1318 */ 1319 1320 Glib::SignalProxy< void > signal_begin_user_action(); 1321 1322 1323 /** 1324 * @par Slot Prototype: 1325 * <tt>void on_my_%end_user_action()</tt> 1326 * 1327 * Flags: Run Last 1328 * 1329 * The signal_end_user_action() signal is emitted at the end of a single 1330 * user-visible operation on the Gtk::TextBuffer. 1331 * 1332 * See also: 1333 * Gtk::TextBuffer::end_user_action(), 1334 * Gtk::TextBuffer::insert_interactive(), 1335 * Gtk::TextBuffer::insert_range_interactive(), 1336 * Gtk::TextBuffer::delete_interactive(), 1337 * Gtk::TextBuffer::backspace(), 1338 * Gtk::TextBuffer::delete_selection(), 1339 * Gtk::TextBuffer::backspace(). 1340 */ 1341 1342 Glib::SignalProxy< void > signal_end_user_action(); 1343 1344 1345 /** 1346 * @par Slot Prototype: 1347 * <tt>void on_my_%paste_done(const Glib::RefPtr<Gtk::Clipboard>& clipboard)</tt> 1348 * 1349 * Flags: Run Last 1350 * 1351 * The paste-done signal is emitted after paste operation has been completed. 1352 * This is useful to properly scroll the view to the end of the pasted text. 1353 * See Gtk::TextBuffer::paste_clipboard() for more details. 1354 * 1355 * @newin{2,16} 1356 * 1357 * @param clipboard The Gtk::Clipboard pasted from. 1358 */ 1359 1360 Glib::SignalProxy< void,const Glib::RefPtr<Gtk::Clipboard>& > signal_paste_done(); 1361 1362 1363 /** Text Tag Table. 1364 * 1365 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 1366 * or receive notification when the value of the property changes. 1367 */ 1368 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TextBuffer::TagTable> > property_tag_table() const; 1369 1370 1371 /** The text content of the buffer. Without child widgets and images, 1372 * see Gtk::TextBuffer::get_text() for more information. 1373 * 1374 * @newin{2,8} 1375 * 1376 * Default value: "" 1377 * 1378 * @return A PropertyProxy that allows you to get or set the value of the property, 1379 * or receive notification when the value of the property changes. 1380 */ 1381 Glib::PropertyProxy< Glib::ustring > property_text() ; 1382 1383 /** The text content of the buffer. Without child widgets and images, 1384 * see Gtk::TextBuffer::get_text() for more information. 1385 * 1386 * @newin{2,8} 1387 * 1388 * Default value: "" 1389 * 1390 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 1391 * or receive notification when the value of the property changes. 1392 */ 1393 Glib::PropertyProxy_ReadOnly< Glib::ustring > property_text() const; 1394 1395 /** Whether the buffer has some text currently selected. 1396 * 1397 * @newin{2,10} 1398 * 1399 * Default value: <tt>false</tt> 1400 * 1401 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 1402 * or receive notification when the value of the property changes. 1403 */ 1404 Glib::PropertyProxy_ReadOnly< bool > property_has_selection() const; 1405 1406 1407 /** The position of the insert mark (as offset from the beginning 1408 * of the buffer). It is useful for getting notified when the 1409 * cursor moves. 1410 * 1411 * @newin{2,10} 1412 * 1413 * Default value: 0 1414 * 1415 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 1416 * or receive notification when the value of the property changes. 1417 */ 1418 Glib::PropertyProxy_ReadOnly< int > property_cursor_position() const; 1419 1420 1421 /** The list of targets this buffer supports for clipboard copying 1422 * and as DND source. 1423 * 1424 * @newin{2,10} 1425 * 1426 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 1427 * or receive notification when the value of the property changes. 1428 */ 1429 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TargetList> > property_copy_target_list() const; 1430 1431 1432 /** The list of targets this buffer supports for clipboard pasting 1433 * and as DND destination. 1434 * 1435 * @newin{2,10} 1436 * 1437 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 1438 * or receive notification when the value of the property changes. 1439 */ 1440 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TargetList> > property_paste_target_list() const; 1441 1442 1443 public: 1444 1445 public: 1446 //C++ methods used to invoke GTK+ virtual functions: 1447 1448 protected: 1449 //GTK+ Virtual Functions (override these to change behaviour): 1450 1451 //Default Signal Handlers:: 1452 /// This is a default handler for the signal signal_insert(). 1453 virtual void on_insert(const TextBuffer::iterator& pos, const Glib::ustring& text, int bytes); 1454 /// This is a default handler for the signal signal_insert_pixbuf(). 1455 virtual void on_insert_pixbuf(const TextBuffer::iterator& pos, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf); 1456 /// This is a default handler for the signal signal_insert_child_anchor(). 1457 virtual void on_insert_child_anchor(const TextBuffer::iterator& pos, const Glib::RefPtr<ChildAnchor>& anchor); 1458 /// This is a default handler for the signal signal_erase(). 1459 virtual void on_erase(const TextBuffer::iterator& range_start, const TextBuffer::iterator& range_end); 1460 /// This is a default handler for the signal signal_changed(). 1461 virtual void on_changed(); 1462 /// This is a default handler for the signal signal_modified_changed(). 1463 virtual void on_modified_changed(); 1464 /// This is a default handler for the signal signal_mark_set(). 1465 virtual void on_mark_set(const TextBuffer::iterator& location, const Glib::RefPtr<TextBuffer::Mark>& mark); 1466 /// This is a default handler for the signal signal_mark_deleted(). 1467 virtual void on_mark_deleted(const Glib::RefPtr<TextBuffer::Mark>& mark); 1468 /// This is a default handler for the signal signal_apply_tag(). 1469 virtual void on_apply_tag(const Glib::RefPtr<TextBuffer::Tag>& tag, const TextBuffer::iterator& range_begin, const TextBuffer::iterator& range_end); 1470 /// This is a default handler for the signal signal_remove_tag(). 1471 virtual void on_remove_tag(const Glib::RefPtr<TextBuffer::Tag>& tag, const TextBuffer::iterator& range_begin, const TextBuffer::iterator& range_end); 1472 /// This is a default handler for the signal signal_begin_user_action(). 1473 virtual void on_begin_user_action(); 1474 /// This is a default handler for the signal signal_end_user_action(). 1475 virtual void on_end_user_action(); 1476 /// This is a default handler for the signal signal_paste_done(). 1477 virtual void on_paste_done(const Glib::RefPtr<Gtk::Clipboard>& clipboard); 1478 1479 1480 }; 1481 1482 } // namespace Gtk 1483 1484 1485 namespace Glib 1486 { 1487 /** A Glib::wrap() method for this object. 1488 * 1489 * @param object The C instance. 1490 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. 1491 * @result A C++ instance that wraps this C instance. 1492 * 1493 * @relates Gtk::TextBuffer 1494 */ 1495 Glib::RefPtr<Gtk::TextBuffer> wrap(GtkTextBuffer* object, bool take_copy = false); 1496 } 1497 1498 1499 #endif /* _GTKMM_TEXTBUFFER_H */ 1500 1501