[gtkmm] TextBuffer: Wrap gtk_text_buffer_insert_markup()



commit 2f8679e4595db119855a98f464e05f374c0142fe
Author: Juan R. GarcĂ­a Blanco <juanrgar gmail com>
Date:   Tue Dec 16 23:09:19 2014 +0100

    TextBuffer: Wrap gtk_text_buffer_insert_markup()

 gtk/src/textbuffer.ccg |   24 ++++++++++++++++++++++++
 gtk/src/textbuffer.hg  |   24 +++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/gtk/src/textbuffer.ccg b/gtk/src/textbuffer.ccg
index d6827e5..01999a4 100644
--- a/gtk/src/textbuffer.ccg
+++ b/gtk/src/textbuffer.ccg
@@ -403,6 +403,30 @@ TextBuffer::iterator TextBuffer::insert_with_tags_by_name(const iterator& pos,
   return range_end;
 }
 
+TextBuffer::iterator TextBuffer::insert_markup(const iterator& pos, const Glib::ustring& markup)
+{
+  // gtk_text_buffer_insert_markup() modifies the iterator, but that's not the
+  // STL way so we give it something that we don't mind it modifying.
+  iterator iterCopy (pos);
+  gtk_text_buffer_insert_markup(gobj(), iterCopy.gobj(), markup.data(), markup.bytes());
+
+  // According to the gtk_text_buffer_insert_markup() docs, the "default signal handler
+  // revalidates it to point to the end of the inserted text".
+  return iterCopy;
+}
+
+TextBuffer::iterator TextBuffer::insert_markup(const iterator& pos, const char* markup_begin, const char* 
markup_end)
+{
+  // gtk_text_buffer_insert_markup() modifies the iterator, but that's not the
+  // STL way so we give it something that we don't mind it modifying.
+  iterator iterCopy (pos);
+  gtk_text_buffer_insert_markup(gobj(), iterCopy.gobj(), markup_begin, markup_end - markup_begin);
+
+  // According to the gtk_text_buffer_insert_markup() docs, the "default signal handler
+  // revalidates it to point to the end of the inserted text".
+  return iterCopy;
+}
+
 TextBuffer::iterator TextBuffer::insert(const iterator& pos,
                                         const iterator& range_begin, const iterator& range_end)
 {
diff --git a/gtk/src/textbuffer.hg b/gtk/src/textbuffer.hg
index 95cc236..e67ed71 100644
--- a/gtk/src/textbuffer.hg
+++ b/gtk/src/textbuffer.hg
@@ -77,7 +77,7 @@ class TextBuffer : public Glib::Object
            gtk_text_buffer_get_selection_bounds, gtk_text_buffer_insert_interactive,
            gtk_text_buffer_insert, gtk_text_buffer_insert_at_cursor, 
gtk_text_buffer_insert_interactive_at_cursor,
            gtk_text_buffer_insert_with_tags, gtk_text_buffer_insert_with_tags_by_name,
-           gtk_text_buffer_get_iter_at_child_anchor)
+           gtk_text_buffer_get_iter_at_child_anchor, gtk_text_buffer_insert_markup)
 public:
   typedef TextIter iterator;
   typedef TextTag Tag;
@@ -287,6 +287,28 @@ public:
   iterator insert_with_tags_by_name(const iterator& pos, const char* text_begin, const char* text_end,
                                     const std::vector<Glib::ustring>& tag_names);
 
+  /** Inserts text in @a markup at position @a pos.
+   * Emits the "insert_text" signal, possibly multiple times; insertion actually occurs in the
+   * default handler for the signal. The @a pos iterator will point to the end of the
+   * inserted text on return.
+   *
+   * @param pos Location to insert the markup.
+   * @param markup The text containing pango markup to be inserted in the buffer.
+   * @result An iterator that points to the end of the inserted markup text.
+   */
+  iterator insert_markup(const iterator& pos, const Glib::ustring& markup);
+
+  /** Inserts markup text at position @a pos.
+   * Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal.
+   * The @a pos iterator will point to the end of the inserted text on return.
+   *
+   * @param pos Location to insert the markup.
+   * @param markup_begin The start of a UTF8 character array containing pango markup.
+   * @param markup_end The end of the UTF8 character array containing pango markup.
+   * @result An iterator that points to the end of the inserted markup text.
+   */
+  iterator insert_markup(const iterator& pos, const char* markup_begin, const char* markup_end);
+
   /* Deletes all text between @a range_begin and @a range_end. The order of range_begin and range_end is not 
actually relevant.
    * This function actually emits the "delete_range" signal, and the default handler of that signal deletes 
the text.
    * Because the buffer is modified, all outstanding iterators become invalid after calling this function.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]