Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkmm-root/base/ChangeLog,v
retrieving revision 1.437
diff -u -3 -r1.437 ChangeLog
--- ChangeLog	8 Aug 2002 19:59:14 -0000	1.437
+++ ChangeLog	9 Aug 2002 10:59:59 -0000
@@ -1,3 +1,19 @@
+2002-08-09  Martin Schulze  <MHL.Schulze@t-online.de>
+
+	* gtk/src/textiter.{ccg,hg}, gtk/src/textmark.{ccg,hg}:
+	Avoid unnecessary includes. Add TextMark::get_iter() which
+	works equivalent to mymark->get_buffer()->get_iter_at_mark(mymark).
+	* gtk/src/textbuffer.{ccg,hg}:
+	- Make TextBuffer::insert_(interactive_)at_cursor() return
+	the iterator of the cursor position using get_insert()->get_iter()
+	or end() if the insertion failed.
+	- Make TextBuffer::delete_(interactive_)text() return the iterator
+	of the position where the deletion occured or end() if no deletion
+	occured. Make the iterators in the parameter list const.
+	- Make the iterators in the parameter lists of
+	TextBuffer::paste_clipboard(), TextBuffer::insert_child_anchor()
+	and TextBuffer::create_child_anchor() const.
+
 2002-08-08  Murray Cumming  <murrayc@usa.net>
 
 	* Removed examples/combo and examples/menu. They are replaced by
Index: gtk/src/textbuffer.ccg
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-src/textbuffer.ccg,v
retrieving revision 1.24
diff -u -3 -r1.24 textbuffer.ccg
--- gtk/src/textbuffer.ccg	6 Aug 2002 10:05:39 -0000	1.24
+++ gtk/src/textbuffer.ccg	9 Aug 2002 11:02:12 -0000
@@ -161,14 +161,31 @@
   return iterCopy;
 }
 
-void TextBuffer::insert_at_cursor(const Glib::ustring& text)
+void TextBuffer::insert_child_anchor(const iterator& iter, const Glib::RefPtr<TextChildAnchor>& anchor)
+{
+  iterator iterCopy(iter); //Copy the iterator. It might be changed because it is used as a signal parameter internally.
+  gtk_text_buffer_insert_child_anchor(gobj(), iterCopy.gobj(), Glib::unwrap(anchor));
+}
+
+Glib::RefPtr<TextChildAnchor> TextBuffer::create_child_anchor(const iterator& iter)
+{
+  iterator iterCopy(iter); //Copy the iterator. It might be changed because it is used as a signal parameter internally.
+  Glib::RefPtr<TextChildAnchor> retvalue = Glib::wrap(gtk_text_buffer_create_child_anchor(gobj(), iterCopy.gobj()));
+  if(!(retvalue.is_null()))
+    retvalue->reference(); //The function does not do a ref for us.
+  return retvalue;
+}
+
+TextBuffer::iterator TextBuffer::insert_at_cursor(const Glib::ustring& text)
 {
   gtk_text_buffer_insert_at_cursor(gobj(), text.data(), text.bytes());
+  return get_insert()->get_iter();
 }
 
-void TextBuffer::insert_at_cursor(const char* text_begin, const char* text_end)
+TextBuffer::iterator TextBuffer::insert_at_cursor(const char* text_begin, const char* text_end)
 {
   gtk_text_buffer_insert_at_cursor(gobj(), text_begin, text_end - text_begin);
+  return get_insert()->get_iter();
 }
 
 TextBuffer::iterator TextBuffer::insert_interactive(const iterator& iter, const Glib::ustring& text, bool default_editable)
@@ -185,14 +202,20 @@
   return ( bSuccess ? iterCopy :  end());
 }
 
-bool TextBuffer::insert_interactive_at_cursor(const Glib::ustring& text, bool default_editable)
+TextBuffer::iterator TextBuffer::insert_interactive_at_cursor(const Glib::ustring& text, bool default_editable)
 {
-  return gtk_text_buffer_insert_interactive_at_cursor(gobj(), text.data(), text.bytes(), default_editable);
+  if(gtk_text_buffer_insert_interactive_at_cursor(gobj(), text.data(), text.bytes(), default_editable))
+    return get_insert()->get_iter(); //Return insertion point iterator (=cursor)
+  else
+    return end();
 }
 
-bool TextBuffer::insert_interactive_at_cursor(const char* text_begin, const char* text_end, bool default_editable)
+TextBuffer::iterator TextBuffer::insert_interactive_at_cursor(const char* text_begin, const char* text_end, bool default_editable)
 {
-  return gtk_text_buffer_insert_interactive_at_cursor(gobj(), text_begin, text_end - text_begin, default_editable);
+  if(gtk_text_buffer_insert_interactive_at_cursor(gobj(), text_begin, text_end - text_begin, default_editable))
+    return get_insert()->get_iter(); //Return insertion point interator (=cursor)
+  else
+    return end();
 }
 
 TextBuffer::iterator TextBuffer::insert_with_tag(const iterator& iter, const Glib::ustring& text, const Glib::RefPtr<Tag>& tag)
@@ -317,6 +340,26 @@
   return ( bSuccess ? iterCopy :  TextBuffer::end() ); //Use "TextBuffer::" to avoid compiler confusion with the "end" input parameter.
 }
 
+TextBuffer::iterator TextBuffer::delete_text(const iterator& start, const iterator& end)
+{
+  iterator startCopy(start), endCopy(end); //gtk+ sets the iterators to where the deletion occured. We do it the STL way and therefore need copies.
+  gtk_text_buffer_delete(gobj(), startCopy.gobj(), endCopy.gobj());
+  return startCopy;
+}
+
+TextBuffer::iterator TextBuffer::delete_interactive_text(const iterator& start_iter, const iterator& end_iter, bool default_editable)
+{
+  iterator startCopy(start_iter), endCopy(end_iter); //gtk+ sets the iterators to where the deletion occured. We do it the STL way and therefore need copies.
+  if(gtk_text_buffer_delete_interactive(gobj(), startCopy.gobj(), endCopy.gobj(), static_cast<int>(default_editable)))
+    return startCopy;
+  else
+    return end();
+}
+
+void TextBuffer::paste_clipboard(Clipboard& clipboard, const iterator& override_location, bool default_editable)
+{
+  gtk_text_buffer_paste_clipboard(gobj(), clipboard.gobj(), (const_cast<iterator&>(override_location)).gobj(), static_cast<int>(default_editable));
+}
 
 
 TextBuffer::iterator TextBuffer::get_iter_at_child_anchor(const Glib::RefPtr<TextChildAnchor>& anchor)
Index: gtk/src/textbuffer.hg
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-src/textbuffer.hg,v
retrieving revision 1.29
diff -u -3 -r1.29 textbuffer.hg
--- gtk/src/textbuffer.hg	19 Jul 2002 19:39:52 -0000	1.29
+++ gtk/src/textbuffer.hg	9 Aug 2002 11:02:12 -0000
@@ -77,20 +77,20 @@
   iterator insert(const iterator& iter, const Glib::ustring& text);
   iterator insert(const iterator& iter, const char* text_begin, const char* text_end);
 
-  void insert_at_cursor(const Glib::ustring& text);
-  void insert_at_cursor(const char* text_begin, const char* text_end);
+  iterator insert_at_cursor(const Glib::ustring& text);
+  iterator insert_at_cursor(const char* text_begin, const char* text_end);
 
   iterator insert(const iterator& iter);
 
   ///Returns end() if the insertion was not successful.
   iterator insert_interactive(const iterator& iter, const Glib::ustring& text, bool default_editable = true);
 
-   ///Returns end() if the insertion was not successful.
+  ///Returns end() if the insertion was not successful.
   iterator insert_interactive(const iterator& iter, const char* text_begin, const char* text_end, bool default_editable = true);
 
-  //TODO: Return an iterator? How do we get an iterator to the cursor position? murrayc.
-  bool insert_interactive_at_cursor(const Glib::ustring& text, bool default_editable = true);
-  bool insert_interactive_at_cursor(const char* text_begin, const char* text_end, bool default_editable = true);
+  ///Returns the cursor position or end() if the insertion was not successful.
+  iterator insert_interactive_at_cursor(const Glib::ustring& text, bool default_editable = true);
+  iterator insert_interactive_at_cursor(const char* text_begin, const char* text_end, bool default_editable = true);
 
   iterator insert_range(const iterator& iter, const iterator& start, const iterator& end);
   _IGNORE(gtk_text_buffer_insert_range)
@@ -115,8 +115,12 @@
   iterator insert_with_tags_by_name(const iterator& iter, const char* text_begin, const char* text_end,
                                 const Glib::StringArrayHandle& tag_names);
 
-  _WRAP_METHOD(void delete_text(iterator& start, iterator& end), gtk_text_buffer_delete)
-  _WRAP_METHOD(bool delete_interactive_text(iterator& start_iter, iterator& end_iter, bool default_editable = true), gtk_text_buffer_delete_interactive)
+  ///Returns the iterator where the deletion occured.
+  iterator delete_text(const iterator& start, const iterator& end);
+  _IGNORE(gtk_text_buffer_delete)
+  ///Returns the iterator where the deletion occured or end() if no text was deleted.
+  iterator delete_interactive_text(const iterator& start, const iterator& end, bool default_editable = true);
+  _IGNORE(gtk_text_buffer_delete_interactive)
 
 
   _WRAP_METHOD(Glib::ustring get_text(const iterator& start, const iterator& end, bool include_hidden_chars = true), gtk_text_buffer_get_text)
@@ -126,8 +130,10 @@
   iterator insert_pixbuf(const iterator& iter, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
   _IGNORE(gtk_text_buffer_insert_pixbuf)
 
-  _WRAP_METHOD(void insert_child_anchor(iterator& iter, const Glib::RefPtr<TextChildAnchor>& anchor), gtk_text_buffer_insert_child_anchor)
-  _WRAP_METHOD(Glib::RefPtr<TextChildAnchor> create_child_anchor(iterator& iter), gtk_text_buffer_create_child_anchor, refreturn)
+  void insert_child_anchor(const iterator& iter, const Glib::RefPtr<TextChildAnchor>& anchor);
+  _IGNORE(gtk_text_buffer_insert_child_anchor)
+  Glib::RefPtr<TextChildAnchor> create_child_anchor(const iterator& iter);
+  _IGNORE(gtk_text_buffer_create_child_anchor)
 
   _WRAP_METHOD(Glib::RefPtr<TextBuffer::Mark> create_mark(const Glib::ustring& mark_name, const iterator& where, bool left_gravity = true), gtk_text_buffer_create_mark, refreturn)
   _WRAP_METHOD(void move_mark(const Glib::RefPtr<Mark>& mark, const iterator& where), gtk_text_buffer_move_mark)
@@ -168,7 +174,8 @@
   _WRAP_METHOD(void remove_selection_clipboard(Clipboard& clipboard), gtk_text_buffer_remove_selection_clipboard)
   _WRAP_METHOD(void cut_clipboard(Clipboard& clipboard, bool default_editable = true), gtk_text_buffer_cut_clipboard)
   _WRAP_METHOD(void copy_clipboard(Clipboard& clipboard), gtk_text_buffer_copy_clipboard)
-  _WRAP_METHOD(void paste_clipboard(Clipboard& clipboard, iterator& override_location, bool default_editable = true), gtk_text_buffer_paste_clipboard)
+  void paste_clipboard(Clipboard& clipboard, const iterator& override_location, bool default_editable = true);
+  _IGNORE(gtk_text_buffer_paste_clipboard)
 
   void get_selection_bounds(iterator& start, iterator& end);
   _IGNORE(gtk_text_buffer_get_selection_bounds)
Index: gtk/src/textiter.ccg
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-src/textiter.ccg,v
retrieving revision 1.7
diff -u -3 -r1.7 textiter.ccg
--- gtk/src/textiter.ccg	7 Jul 2002 12:18:52 -0000	1.7
+++ gtk/src/textiter.ccg	9 Aug 2002 11:02:13 -0000
@@ -23,7 +23,6 @@
 
 #include <gtkmm/texttag.h>
 #include <gtkmm/textbuffer.h>
-#include <gtk/gtktextiter.h>
 
 namespace Gtk
 {
Index: gtk/src/textiter.hg
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-src/textiter.hg,v
retrieving revision 1.27
diff -u -3 -r1.27 textiter.hg
--- gtk/src/textiter.hg	7 Jul 2002 12:18:52 -0000	1.27
+++ gtk/src/textiter.hg	9 Aug 2002 11:02:13 -0000
@@ -23,9 +23,9 @@
 #include <glibmm/slisthandle.h>
 #include <gdkmm/pixbuf.h>
 #include <gtkmm/texttag.h>
-#include <gtkmm/textmark.h>
 #include <gtkmm/textchildanchor.h>
 #include <gtkmm/textattributes.h>
+#include <gtk/gtktextiter.h> //We need the definition of GtkTextIter.
 
 
 _DEFS(gtkmm,gtk)
@@ -37,6 +37,7 @@
 _WRAP_ENUM(TextSearchFlags, GtkTextSearchFlags)
 
 class TextBuffer;
+class TextMark;
 
 /** You can iterate over characters, words, lines, and sentences, but operator* and operator++ deal in characters.
  * TODO: Maybe we should have separate iterators for words, lines, and sentences.
Index: gtk/src/textmark.ccg
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-src/textmark.ccg,v
retrieving revision 1.2
diff -u -3 -r1.2 textmark.ccg
--- gtk/src/textmark.ccg	16 Apr 2002 13:01:53 -0000	1.2
+++ gtk/src/textmark.ccg	9 Aug 2002 11:02:13 -0000
@@ -22,5 +22,17 @@
  */
 
 
+#include <gtkmm/textmark.h>
 #include <gtkmm/textbuffer.h>
-#include <gtk/gtktextmark.h>
\ No newline at end of file
+#include <gtk/gtktextmark.h>
+
+
+namespace Gtk {
+
+TextIter TextMark::get_iter()
+{
+  return get_buffer()->get_iter_at_mark(Glib::RefPtr<TextMark>(this));
+}
+
+}
+
Index: gtk/src/textmark.hg
===================================================================
RCS file: /cvs/gnome/gtkmm-root/gtk-src/textmark.hg,v
retrieving revision 1.10
diff -u -3 -r1.10 textmark.hg
--- gtk/src/textmark.hg	19 Jul 2002 19:39:52 -0000	1.10
+++ gtk/src/textmark.hg	9 Aug 2002 11:02:13 -0000
@@ -21,7 +21,6 @@
 
 
 #include <gtkmm/object.h>
-#include <gtk/gtktextbuffer.h> //Needed by gtktextmark.h
 
 _DEFS(gtkmm,gtk)
 _PINCLUDE(glibmm/private/object_p.h)
@@ -30,6 +29,7 @@
 {
 
 class TextBuffer;
+class TextIter;
 
 /**
  * @ingroup TextView
@@ -47,6 +47,7 @@
   _WRAP_METHOD(Glib::RefPtr<TextBuffer> get_buffer(), gtk_text_mark_get_buffer, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const TextBuffer> get_buffer() const, gtk_text_mark_get_buffer, refreturn)
   _WRAP_METHOD(bool get_left_gravity() const, gtk_text_mark_get_left_gravity)
+  TextIter get_iter();
 };
 
 } /* namespace Gtk */
