[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[giFTcurs-commits] giFTcurs/src ui.c
From: |
Göran Weinholt |
Subject: |
[giFTcurs-commits] giFTcurs/src ui.c |
Date: |
Tue, 04 Nov 2003 18:25:32 -0500 |
CVSROOT: /cvsroot/giftcurs
Module name: giFTcurs
Branch:
Changes by: Göran Weinholt <address@hidden> 03/11/04 18:25:31
Modified files:
src : ui.c
Log message:
Only treat the query field as utf8 if it validates as such.
Patches:
Index: giFTcurs/src/ui.c
diff -u giFTcurs/src/ui.c:1.114 giFTcurs/src/ui.c:1.115
--- giFTcurs/src/ui.c:1.114 Mon Oct 13 17:42:37 2003
+++ giFTcurs/src/ui.c Tue Nov 4 18:25:31 2003
@@ -18,7 +18,7 @@
* along with giFTcurs; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * $Id: ui.c,v 1.114 2003/10/13 21:42:37 weinholt Exp $
+ * $Id: ui.c,v 1.115 2003/11/04 23:25:31 weinholt Exp $
*/
#include "giftcurs.h"
@@ -347,10 +347,12 @@
}
/* This handles keys written into a inputbox. */
-/* FIXME: posp should take wide chars into account */
int ui_input_handler(GString *foo, int *posp, int *vposp, int key)
{
int ret = 1, pos = *posp;
+ int use_utf8;
+
+ use_utf8 = utf8 && g_utf8_validate(foo->str, foo->len, NULL);
switch (key) {
case 0:
@@ -375,18 +377,18 @@
remove_word(foo, &pos);
break;
case KEY_LEFT:
- if (utf8) {
+ if (use_utf8) {
char *prevc = g_utf8_find_prev_char(foo->str, foo->str
+ pos);
-
+
pos = prevc - foo->str;
} else {
pos--;
}
break;
case KEY_RIGHT:
- if (utf8) {
+ if (use_utf8) {
char *nextc = g_utf8_find_next_char(foo->str + pos,
NULL);
-
+
pos = nextc - foo->str;
} else {
pos++;
@@ -398,7 +400,7 @@
case KEY_DC: /* delete char */
if ((pos == 0 && key != KEY_DC) || (pos == foo->len && key ==
KEY_DC))
break;
- if (utf8) {
+ if (use_utf8) {
if (key == KEY_DC) {
char *nextc = g_utf8_find_next_char(foo->str +
pos, NULL);
int npos = nextc - foo->str;
@@ -432,7 +434,7 @@
pos = foo->len;
*posp = pos;
- if (utf8) {
+ if (use_utf8) {
char *p;
for (p = foo->str, *vposp = 0; *p && p < foo->str + pos; p =
g_utf8_next_char(p))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [giFTcurs-commits] giFTcurs/src ui.c,
Göran Weinholt <=