diff --git a/src/wreadln.c b/src/wreadln.c
index f6b848cdd86788df9ade64319e474e8c8f052fad..d01cfcb87c8517544c930cc5a86b9b8ba1440af2 100644 (file)
--- a/src/wreadln.c
+++ b/src/wreadln.c
*
*/
+#include "wreadln.h"
+#include "charset.h"
#include "config.h"
#include <stdlib.h>
#include <ncurses.h>
#endif
-#include "wreadln.h"
-
#define KEY_CTRL_A 1
+#define KEY_CTRL_B 2
#define KEY_CTRL_C 3
-#define KEY_CTRL_D 4
+#define KEY_CTRL_D 4
#define KEY_CTRL_E 5
+#define KEY_CTRL_F 6
#define KEY_CTRL_G 7
#define KEY_CTRL_K 11
+#define KEY_CTRL_N 14
+#define KEY_CTRL_P 16
#define KEY_CTRL_U 21
#define KEY_CTRL_Z 26
#define KEY_BCKSPC 8
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 */
gint x1,
gchar *line)
{
- if (*cursor < strlen(line) && *cursor < wrln_max_line_size - 1) {
+ if (*cursor < (int)strlen(line) &&
+ *cursor < (int)wrln_max_line_size - 1) {
(*cursor)++;
if (*cursor + x0 >= x1 && *start < *cursor - width + 1)
(*start)++;
/* 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);
return NULL;
case KEY_LEFT:
+ case KEY_CTRL_B:
cursor_move_left(&cursor, &start);
break;
case KEY_RIGHT:
+ case KEY_CTRL_F:
cursor_move_right(&cursor, &start, width, x0, x1, line);
break;
case KEY_HOME:
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 <= my_strlen(line) - 1) {
+ if (cursor <= (gint)utf8_width(line) - 1) {
for (i = cursor; line[i] != 0; i++)
line[i] = line[i + 1];
}
break;
case KEY_UP:
+ case KEY_CTRL_P:
/* get previous history entry */
if( history && hlist->prev ) {
if( hlist==hcurrent )
cursor_move_to_eol(&cursor, &start, width, x0, x1, line);
break;
case KEY_DOWN:
+ case KEY_CTRL_N:
/* get next history entry */
if( history && hlist->next ) {
/* get next line */
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);