summaryrefslogtreecommitdiff
path: root/gtk/gtktextbuffer.c
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2003-01-06 22:34:23 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2003-01-06 22:34:23 +0000
commitbc70dc94bf6392a7503ebd81092494631a272c44 (patch)
treeb6d9d87acf4be094a3a9401f86fa54a929b1a6f8 /gtk/gtktextbuffer.c
parent41f2f7974e8d5ccd52543d82b92e1ff2c7ce3c2d (diff)
downloadgtk+-bc70dc94bf6392a7503ebd81092494631a272c44.tar.gz
Implement a utility function proposed in #102534:
2003-01-06 Matthias Clasen <maclas@gmx.de> Implement a utility function proposed in #102534: * gtk/gtktextbtree.h: * gtk/gtktextbtree.c (_gtk_text_btree_select_range): New function. (_gtk_text_btree_place_cursor): Now a simple wrapper around _gtk_text_btree_select_range(). * gtk/gtktextbuffer.h: * gtk/gtktextbuffer.c (gtk_text_buffer_select_range): New function. (gtk_text_buffer_place_cursor): Now a simple wrapper around gtk_text_buffer_select_range().
Diffstat (limited to 'gtk/gtktextbuffer.c')
-rw-r--r--gtk/gtktextbuffer.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c
index d5327d0aae..1f49807f75 100644
--- a/gtk/gtktextbuffer.c
+++ b/gtk/gtktextbuffer.c
@@ -2009,17 +2009,42 @@ void
gtk_text_buffer_place_cursor (GtkTextBuffer *buffer,
const GtkTextIter *where)
{
- GtkTextIter real;
+ gtk_text_buffer_select_range (buffer, where, where);
+}
+
+
+/**
+ * gtk_text_buffer_select_range:
+ * @buffer: a #GtkTextBuffer
+ * @ins: where to put the "insert" mark
+ * @bound: where to put the "selection_bound" mark
+ *
+ * This function moves the "insert" and "selection_bound" marks
+ * simultaneously. If you move them in two steps
+ * with gtk_text_buffer_move_mark(), you will temporarily select a
+ * region in between their old and new locations, which can be pretty
+ * inefficient since the temporarily-selected region will force stuff
+ * to be recalculated. This function moves them as a unit, which can
+ * be optimized.
+ **/
+void
+gtk_text_buffer_select_range (GtkTextBuffer *buffer,
+ const GtkTextIter *ins,
+ const GtkTextIter *bound)
+{
+ GtkTextIter real_ins;
+ GtkTextIter real_bound;
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
- real = *where;
+ real_ins = *ins;
+ real_bound = *bound;
- _gtk_text_btree_place_cursor (get_btree (buffer), &real);
- gtk_text_buffer_mark_set (buffer, &real,
+ _gtk_text_btree_select_range (get_btree (buffer), &real_ins, &real_bound);
+ gtk_text_buffer_mark_set (buffer, &real_ins,
gtk_text_buffer_get_mark (buffer,
"insert"));
- gtk_text_buffer_mark_set (buffer, &real,
+ gtk_text_buffer_mark_set (buffer, &real_bound,
gtk_text_buffer_get_mark (buffer,
"selection_bound"));
}