summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>1998-11-16 23:18:06 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-11-16 23:18:06 +0000
commit7e44eced8c7c01f60a1135f7de6bd2215d5a3967 (patch)
treeda3d855166a91366d39300791ade23b5b765b9e7
parentd8ab8e0e7d400f8ab41709191e25e42196983861 (diff)
downloadgdk-pixbuf-7e44eced8c7c01f60a1135f7de6bd2215d5a3967.tar.gz
Optimizations for moving point n places. (gtk-mailund-980718-0, Thomas
Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com> * gtk/gtktext.c: Optimizations for moving point n places. (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>) * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was broken. (GtkWidget's default unmap handler should work fine). Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
-rw-r--r--ChangeLog10
-rw-r--r--ChangeLog.pre-2-010
-rw-r--r--ChangeLog.pre-2-1010
-rw-r--r--ChangeLog.pre-2-210
-rw-r--r--ChangeLog.pre-2-410
-rw-r--r--ChangeLog.pre-2-610
-rw-r--r--ChangeLog.pre-2-810
-rw-r--r--gtk/gtkfixed.c11
-rw-r--r--gtk/gtktext.c82
9 files changed, 118 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index 326bcbb2e..9ff3fd933 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.c: Optimizations for moving point n
+ places.
+ (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>)
+
+ * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was
+ broken. (GtkWidget's default unmap handler should work fine).
+ Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
+
Mon Nov 16 00:59:26 PST 1998 Manish Singh <yosh@gimp.org>
* gtk/gtkmenubar.[ch]: added shadow_type setting and
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 326bcbb2e..9ff3fd933 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,13 @@
+Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.c: Optimizations for moving point n
+ places.
+ (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>)
+
+ * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was
+ broken. (GtkWidget's default unmap handler should work fine).
+ Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
+
Mon Nov 16 00:59:26 PST 1998 Manish Singh <yosh@gimp.org>
* gtk/gtkmenubar.[ch]: added shadow_type setting and
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 326bcbb2e..9ff3fd933 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,13 @@
+Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.c: Optimizations for moving point n
+ places.
+ (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>)
+
+ * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was
+ broken. (GtkWidget's default unmap handler should work fine).
+ Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
+
Mon Nov 16 00:59:26 PST 1998 Manish Singh <yosh@gimp.org>
* gtk/gtkmenubar.[ch]: added shadow_type setting and
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 326bcbb2e..9ff3fd933 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,13 @@
+Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.c: Optimizations for moving point n
+ places.
+ (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>)
+
+ * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was
+ broken. (GtkWidget's default unmap handler should work fine).
+ Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
+
Mon Nov 16 00:59:26 PST 1998 Manish Singh <yosh@gimp.org>
* gtk/gtkmenubar.[ch]: added shadow_type setting and
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 326bcbb2e..9ff3fd933 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,13 @@
+Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.c: Optimizations for moving point n
+ places.
+ (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>)
+
+ * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was
+ broken. (GtkWidget's default unmap handler should work fine).
+ Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
+
Mon Nov 16 00:59:26 PST 1998 Manish Singh <yosh@gimp.org>
* gtk/gtkmenubar.[ch]: added shadow_type setting and
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 326bcbb2e..9ff3fd933 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,13 @@
+Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.c: Optimizations for moving point n
+ places.
+ (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>)
+
+ * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was
+ broken. (GtkWidget's default unmap handler should work fine).
+ Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
+
Mon Nov 16 00:59:26 PST 1998 Manish Singh <yosh@gimp.org>
* gtk/gtkmenubar.[ch]: added shadow_type setting and
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 326bcbb2e..9ff3fd933 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,13 @@
+Mon Nov 16 15:10:33 1998 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtktext.c: Optimizations for moving point n
+ places.
+ (gtk-mailund-980718-0, Thomas Mailund Jensen <mailund@daimi.aau.dk>)
+
+ * gtk/gtkfixed.c: Removed gtk_fixed_umap, which was
+ broken. (GtkWidget's default unmap handler should work fine).
+ Pointed out by Patrice Fortier <Patrice.Fortier@aquarel.fr>
+
Mon Nov 16 00:59:26 PST 1998 Manish Singh <yosh@gimp.org>
* gtk/gtkmenubar.[ch]: added shadow_type setting and
diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c
index 47c9d01de..799d9159d 100644
--- a/gtk/gtkfixed.c
+++ b/gtk/gtkfixed.c
@@ -22,7 +22,6 @@
static void gtk_fixed_class_init (GtkFixedClass *klass);
static void gtk_fixed_init (GtkFixed *fixed);
static void gtk_fixed_map (GtkWidget *widget);
-static void gtk_fixed_unmap (GtkWidget *widget);
static void gtk_fixed_realize (GtkWidget *widget);
static void gtk_fixed_size_request (GtkWidget *widget,
GtkRequisition *requisition);
@@ -87,7 +86,6 @@ gtk_fixed_class_init (GtkFixedClass *class)
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
widget_class->map = gtk_fixed_map;
- widget_class->unmap = gtk_fixed_unmap;
widget_class->realize = gtk_fixed_realize;
widget_class->size_request = gtk_fixed_size_request;
widget_class->size_allocate = gtk_fixed_size_allocate;
@@ -215,15 +213,6 @@ gtk_fixed_map (GtkWidget *widget)
}
static void
-gtk_fixed_unmap (GtkWidget *widget)
-{
- g_return_if_fail (widget != NULL);
- g_return_if_fail (GTK_IS_FIXED (widget));
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-}
-
-static void
gtk_fixed_realize (GtkWidget *widget)
{
GdkWindowAttr attributes;
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 4ab73c7b9..b30ea25a9 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -3232,17 +3232,6 @@ move_mark_n (GtkPropertyMark* mark, gint n)
}
static void
-advance_mark_n (GtkPropertyMark* mark, gint n)
-{
- gint i;
-
- g_assert (n > 0);
-
- for (i = 0; i < n; i += 1)
- advance_mark (mark);
-}
-
-static void
advance_mark (GtkPropertyMark* mark)
{
TextProperty* prop = MARK_CURRENT_PROPERTY (mark);
@@ -3259,6 +3248,37 @@ advance_mark (GtkPropertyMark* mark)
}
static void
+advance_mark_n (GtkPropertyMark* mark, gint n)
+{
+ gint i;
+ TextProperty* prop;
+
+ g_assert (n > 0);
+
+ i = 0; /* otherwise it migth not be init. */
+ prop = MARK_CURRENT_PROPERTY(mark);
+
+ if ((prop->length - mark->offset - 1) < n) { /* if we need to change prop. */
+ /* to make it easier */
+ n += (mark->offset);
+ mark->index -= mark->offset;
+ mark->offset = 0;
+ /* first we take seven-mile-leaps to get to the right text
+ * property. */
+ while ((n-i) > prop->length - 1) {
+ i += prop->length;
+ mark->index += prop->length;
+ mark->property = MARK_NEXT_LIST_PTR (mark);
+ prop = MARK_CURRENT_PROPERTY (mark);
+ }
+ }
+
+ /* and then the rest */
+ mark->index += n - i;
+ mark->offset += n - i;
+}
+
+static void
decrement_mark (GtkPropertyMark* mark)
{
mark->index -= 1;
@@ -3275,25 +3295,28 @@ decrement_mark (GtkPropertyMark* mark)
static void
decrement_mark_n (GtkPropertyMark* mark, gint n)
{
- gint i;
-
g_assert (n > 0);
-
- for (i = 0; i < n; i += 1)
- decrement_mark (mark);
-}
+ while (mark->offset < n) {
+ /* jump to end of prev */
+ n -= mark->offset + 1;
+ mark->index -= mark->offset + 1;
+ mark->property = MARK_PREV_LIST_PTR (mark);
+ mark->offset = MARK_CURRENT_PROPERTY (mark)->length - 1;
+ }
+
+ /* and the rest */
+ mark->index -= n;
+ mark->offset -= n;
+}
+
static GtkPropertyMark
find_mark (GtkText* text, guint mark_position)
{
return find_mark_near (text, mark_position, &text->point);
}
-/* This can be optimized in two ways.
- * First, advances can be made in units of the current TextProperty
- * length, when possible. This will reduce computation and function
- * call overhead.
- *
+/*
* You can also start from the end, what a drag.
*/
static GtkPropertyMark
@@ -3324,18 +3347,9 @@ find_mark_near (GtkText* text, guint mark_position, const GtkPropertyMark* near)
mark.property = text->text_properties;
mark.offset = 0;
}
-
- if (mark.index > mark_position)
- {
- while (mark.index > mark_position)
- decrement_mark (&mark);
- }
- else
- {
- while (mark_position > mark.index)
- advance_mark (&mark);
- }
-
+
+ move_mark_n (&mark, mark_position - mark.index);
+
return mark;
}