BUG FIX (was: RE: [gtk-list] RE: 0.99.7 Entry (editable?) bug)




It seems the complicated backward character calculations were to
accommodate the possibility of the entry text having characters of
different widths.

I can't see how this can happen, however, so I've put together a
patch assusing that all the characters in the text entry are the
same width, and this fixes the problem I reported.

I'm not saying that this is 100% correct, but I'd like to hear why it
isn't. I have only changed the gtk_move_backward_character function
as an example, but the other functions that use
move_backward_character will also probably need some work (e.g.
gtk_move_backward_word)

Opinions?

--
E-Mail: Tony Gale <gale@daedalus.dera.gov.uk>
"This isn't brain surgery; it's just television."
- David Letterman

The views expressed above are entirely those of the writer
and do not represent the views, policy or understanding of
any other person or official body.
Index: gtkentry.c
===================================================================
RCS file: /debian/home/gnomecvs/gtk+/gtk/gtkentry.c,v
retrieving revision 1.31
diff -u -r1.31 gtkentry.c
--- gtkentry.c	1998/03/14 18:33:39	1.31
+++ gtkentry.c	1998/03/16 14:09:30
@@ -1580,14 +1580,18 @@
 static void
 gtk_move_backward_character (GtkEntry *entry)
 {
+  gint len;
   GtkEditable *editable;
   editable = GTK_EDITABLE (entry);
 
   /* this routine is correct only if string is state-independent-encoded */
 
-  if (0 < editable->current_pos)
-    editable->current_pos = move_backward_character (entry->text,
-						     editable->current_pos);
+  if (0 < editable->current_pos) {
+    len = mblen (entry->text+editable->current_pos, MB_CUR_MAX);
+    editable->current_pos -= (len>0)? len:1;
+  }
+  if (editable->current_pos < 0)
+    editable->current_pos = 0;
 }
 
 static void


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