summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-05-17 21:13:12 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-05-17 21:13:12 +0000
commit69ef3403896b39555061897e10f57b047ded9d2b (patch)
tree355126ec42ac088f1a3eb9aa10b14cdec48fb48b
parent6b2fe1a343141a53b9785d4efbb8598bc32556b5 (diff)
downloadgtk+-69ef3403896b39555061897e10f57b047ded9d2b.tar.gz
Make logical motion and deletion by graphemes, not by characters.
Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkentry.c: Make logical motion and deletion by graphemes, not by characters. * gtk/gtkentry.c: Handle "trailing" returns from Pango when they are not zero or one; that is, when graphemes of multiple characters are involved. * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary FIXME.
-rw-r--r--ChangeLog13
-rw-r--r--ChangeLog.pre-2-013
-rw-r--r--ChangeLog.pre-2-1013
-rw-r--r--ChangeLog.pre-2-213
-rw-r--r--ChangeLog.pre-2-413
-rw-r--r--ChangeLog.pre-2-613
-rw-r--r--ChangeLog.pre-2-813
-rw-r--r--gtk/gtkentry.c65
-rw-r--r--gtk/gtktextlayout.c1
9 files changed, 139 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 57c50d0d21..119501f6c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkentry.c: Make logical motion and deletion by graphemes,
+ not by characters.
+
+ * gtk/gtkentry.c: Handle "trailing" returns from Pango when they
+ are not zero or one; that is, when graphemes of multiple characters
+ are involved.
+
+ * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary
+ FIXME.
+
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
@@ -168,7 +180,6 @@ Fri May 11 01:05:00 2001 Tim Janik <timj@gtk.org>
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_clear_area):
Handle background pixmaps.
->>>>>>> 1.1955
Wed May 9 15:27:22 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_column_drag_function): New
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 57c50d0d21..119501f6c5 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,15 @@
+Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkentry.c: Make logical motion and deletion by graphemes,
+ not by characters.
+
+ * gtk/gtkentry.c: Handle "trailing" returns from Pango when they
+ are not zero or one; that is, when graphemes of multiple characters
+ are involved.
+
+ * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary
+ FIXME.
+
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
@@ -168,7 +180,6 @@ Fri May 11 01:05:00 2001 Tim Janik <timj@gtk.org>
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_clear_area):
Handle background pixmaps.
->>>>>>> 1.1955
Wed May 9 15:27:22 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_column_drag_function): New
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 57c50d0d21..119501f6c5 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,15 @@
+Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkentry.c: Make logical motion and deletion by graphemes,
+ not by characters.
+
+ * gtk/gtkentry.c: Handle "trailing" returns from Pango when they
+ are not zero or one; that is, when graphemes of multiple characters
+ are involved.
+
+ * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary
+ FIXME.
+
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
@@ -168,7 +180,6 @@ Fri May 11 01:05:00 2001 Tim Janik <timj@gtk.org>
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_clear_area):
Handle background pixmaps.
->>>>>>> 1.1955
Wed May 9 15:27:22 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_column_drag_function): New
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 57c50d0d21..119501f6c5 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,15 @@
+Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkentry.c: Make logical motion and deletion by graphemes,
+ not by characters.
+
+ * gtk/gtkentry.c: Handle "trailing" returns from Pango when they
+ are not zero or one; that is, when graphemes of multiple characters
+ are involved.
+
+ * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary
+ FIXME.
+
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
@@ -168,7 +180,6 @@ Fri May 11 01:05:00 2001 Tim Janik <timj@gtk.org>
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_clear_area):
Handle background pixmaps.
->>>>>>> 1.1955
Wed May 9 15:27:22 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_column_drag_function): New
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 57c50d0d21..119501f6c5 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,15 @@
+Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkentry.c: Make logical motion and deletion by graphemes,
+ not by characters.
+
+ * gtk/gtkentry.c: Handle "trailing" returns from Pango when they
+ are not zero or one; that is, when graphemes of multiple characters
+ are involved.
+
+ * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary
+ FIXME.
+
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
@@ -168,7 +180,6 @@ Fri May 11 01:05:00 2001 Tim Janik <timj@gtk.org>
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_clear_area):
Handle background pixmaps.
->>>>>>> 1.1955
Wed May 9 15:27:22 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_column_drag_function): New
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 57c50d0d21..119501f6c5 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,15 @@
+Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkentry.c: Make logical motion and deletion by graphemes,
+ not by characters.
+
+ * gtk/gtkentry.c: Handle "trailing" returns from Pango when they
+ are not zero or one; that is, when graphemes of multiple characters
+ are involved.
+
+ * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary
+ FIXME.
+
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
@@ -168,7 +180,6 @@ Fri May 11 01:05:00 2001 Tim Janik <timj@gtk.org>
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_clear_area):
Handle background pixmaps.
->>>>>>> 1.1955
Wed May 9 15:27:22 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_column_drag_function): New
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 57c50d0d21..119501f6c5 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,15 @@
+Thu May 17 17:10:13 2001 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkentry.c: Make logical motion and deletion by graphemes,
+ not by characters.
+
+ * gtk/gtkentry.c: Handle "trailing" returns from Pango when they
+ are not zero or one; that is, when graphemes of multiple characters
+ are involved.
+
+ * gtk/gtktextlayout.c (line_display_index_to_iter): Remove unnecessary
+ FIXME.
+
2001-05-17 Alexander Larsson <alla@lysator.liu.se>
* gtk/gtkbbox.c:
@@ -168,7 +180,6 @@ Fri May 11 01:05:00 2001 Tim Janik <timj@gtk.org>
* gdk/linux-fb/gdkwindow-fb.c (_gdk_windowing_window_clear_area):
Handle background pixmaps.
->>>>>>> 1.1955
Wed May 9 15:27:22 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_column_drag_function): New
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 9591896f36..ccb21525b4 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -237,6 +237,9 @@ static void gtk_entry_adjust_scroll (GtkEntry *entry);
static gint gtk_entry_move_visually (GtkEntry *editable,
gint start,
gint count);
+static gint gtk_entry_move_logically (GtkEntry *entry,
+ gint start,
+ gint count);
static gint gtk_entry_move_forward_word (GtkEntry *entry,
gint start);
static gint gtk_entry_move_backward_word (GtkEntry *entry,
@@ -252,8 +255,8 @@ static void gtk_entry_paste (GtkEntry *entry,
static void gtk_entry_update_primary_selection (GtkEntry *entry);
static void gtk_entry_do_popup (GtkEntry *entry,
GdkEventButton *event);
-static gboolean gtk_entry_mnemonic_activate (GtkWidget *widget,
- gboolean group_cycling);
+static gboolean gtk_entry_mnemonic_activate (GtkWidget *widget,
+ gboolean group_cycling);
static GtkWidgetClass *parent_class = NULL;
@@ -1847,7 +1850,7 @@ gtk_entry_move_cursor (GtkEntry *entry,
switch (step)
{
case GTK_MOVEMENT_LOGICAL_POSITIONS:
- new_pos = CLAMP (new_pos + count, 0, entry->text_length);
+ new_pos = gtk_entry_move_logically (entry, new_pos, count);
break;
case GTK_MOVEMENT_VISUAL_POSITIONS:
new_pos = gtk_entry_move_visually (entry, new_pos, count);
@@ -1917,7 +1920,7 @@ gtk_entry_delete_from_cursor (GtkEntry *entry,
switch (type)
{
case GTK_DELETE_CHARS:
- end_pos = entry->current_pos + count;
+ end_pos = gtk_entry_move_logically (entry, entry->current_pos, count);
gtk_editable_delete_text (editable, MIN (start_pos, end_pos), MAX (start_pos, end_pos));
break;
case GTK_DELETE_WORDS:
@@ -2466,9 +2469,7 @@ gtk_entry_find_position (GtkEntry *entry,
}
pos = g_utf8_pointer_to_offset (entry->text, entry->text + index);
-
- if (trailing)
- pos += 1;
+ pos += trailing;
return pos;
}
@@ -2622,11 +2623,11 @@ gtk_entry_move_visually (GtkEntry *entry,
if (new_index < 0 || new_index == G_MAXINT)
break;
+
+ index = new_index;
- if (new_trailing)
+ while (new_trailing--)
index = g_utf8_next_char (entry->text + new_index) - entry->text;
- else
- index = new_index;
}
g_object_unref (G_OBJECT (layout));
@@ -2635,6 +2636,50 @@ gtk_entry_move_visually (GtkEntry *entry,
}
static gint
+gtk_entry_move_logically (GtkEntry *entry,
+ gint start,
+ gint count)
+{
+ gint new_pos = start;
+
+ /* Prevent any leak of information */
+ if (!entry->visible)
+ {
+ new_pos = CLAMP (start + count, 0, entry->text_length);
+ }
+ else if (entry->text)
+ {
+ PangoLayout *layout = gtk_entry_get_layout (entry, FALSE);
+ PangoLogAttr *log_attrs;
+ gint n_attrs;
+
+ pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
+
+ while (count > 0 && new_pos < entry->text_length)
+ {
+ do
+ new_pos++;
+ while (new_pos < entry->text_length && !log_attrs[new_pos].is_cursor_position);
+
+ count--;
+ }
+ while (count < 0 && new_pos > 0)
+ {
+ do
+ new_pos--;
+ while (new_pos > 0 && !log_attrs[new_pos].is_cursor_position);
+
+ count++;
+ }
+
+ g_free (log_attrs);
+ g_object_unref (G_OBJECT (layout));
+ }
+
+ return new_pos;
+}
+
+static gint
gtk_entry_move_forward_word (GtkEntry *entry,
gint start)
{
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 208fa8c0ea..de68df6d8b 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -1982,7 +1982,6 @@ line_display_index_to_iter (GtkTextLayout *layout,
gtk_text_iter_forward_to_line_end (iter);
}
- /* FIXME should this be cursor positions? */
gtk_text_iter_forward_chars (iter, trailing);
}