Code

screen: don't pass mpdclient pointer to method paint()
[ncmpc.git] / src / wreadln.c
index dc1dfe86708f629d8eeb80bff240e03df6c20b86..bf31d1db349edbaadb6114f7400b8d8c1c7e2b87 100644 (file)
@@ -1,6 +1,4 @@
-/* 
- * $Id$
- *
+/*
  * (c) 2004 by Kalle Wallin <kaw@linux.se>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -18,9 +16,9 @@
  *
  */
 
-#include "config.h"
-
 #include "wreadln.h"
+#include "charset.h"
+#include "config.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -59,7 +57,6 @@ wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL;
 
 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 */
@@ -117,7 +114,7 @@ static inline void drawline(gint cursor,
   /* 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);
@@ -211,17 +208,6 @@ _wreadln(WINDOW *w,
                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;
@@ -275,7 +261,7 @@ _wreadln(WINDOW *w,
                        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;
@@ -291,7 +277,7 @@ _wreadln(WINDOW *w,
                        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];
                        }
@@ -334,7 +320,7 @@ _wreadln(WINDOW *w,
                        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);
@@ -617,17 +603,6 @@ _wreadln(WINDOW *w,
                }
              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;
            }
 
        }