diff --git a/src/wreadln.c b/src/wreadln.c
index dc1dfe86708f629d8eeb80bff240e03df6c20b86..bf31d1db349edbaadb6114f7400b8d8c1c7e2b87 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
-/*
- * $Id$
- *
+/*
* (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* This program is free software; you can redistribute it and/or modify
*
*/
-#include "config.h"
-
#include "wreadln.h"
+#include "charset.h"
+#include "config.h"
#include <stdlib.h>
#include <string.h>
extern void sigstop(void);
extern void screen_bell(void);
-extern size_t my_strlen(char *str);
#ifndef USE_NCURSESW
/* move the cursor one step to the right */
/* clear input area */
whline(w, ' ', width);
/* print visible part of the line buffer */
- if(masked == TRUE) whline(w, '*', my_strlen(line)-start);
+ if(masked == TRUE) whline(w, '*', utf8_width(line) - start);
else waddnstr(w, line+start, width);
/* move the cursor to the correct position */
wmove(w, y, x0 + cursor-start);
case ERR: /* ingnore errors */
break;
- case KEY_RESIZE:
- /* a resize event */
- if( x1>COLS ) {
- x1=COLS;
- width = x1-x0;
- cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
- }
- /* make shure the cursor is visible */
- curs_set(1);
- break;
-
case TAB:
if( gcmp ) {
char *prefix = NULL;
line[cursor] = 0;
break;
case KEY_CTRL_U:
- cursor = my_strlen(line);
+ cursor = utf8_width(line);
for (i = 0;i < cursor; i++)
line[i] = '\0';
cursor = 0;
break;
case KEY_DC: /* handle delete key. As above */
case KEY_CTRL_D:
- if (cursor <= (gint)my_strlen(line) - 1) {
+ if (cursor <= (gint)utf8_width(line) - 1) {
for (i = cursor; line[i] != 0; i++)
line[i] = line[i + 1];
}
if (key >= 32) {
if (strlen (line + cursor)) { /* if the cursor is */
/* not at the last pos */
- gchar *tmp = 0;
+ gchar *tmp = NULL;
gsize size = strlen(line + cursor) + 1;
tmp = g_malloc0(size);
}
cursor_move_to_eol(&cursor, &start, width, x0, x1, wline);
break;
- case KEY_RESIZE:
- /* resize event */
- if( x1>COLS )
- {
- x1=COLS;
- width = x1-x0;
- cursor_move_to_eol(&cursor, &start, width, x0, x1, wline);
- }
- /* make shure the cursor is visible */
- curs_set(1);
- break;
}
}