]> git.deb.at Git - pkg/abook.git/blobdiff - abook_rl.c
autoconf/automake update
[pkg/abook.git] / abook_rl.c
index f9ebba6529f32c7e4a3675e4aa4c75e0df1bec38..c09b4bb6dc4866e8402bfb4b1f37c0a6b58459b4 100644 (file)
@@ -32,7 +32,7 @@
 #endif
 
 #ifdef HANDLE_MULTIBYTE
-#      include <wchar.h>
+#      include <mbswidth.h>
 #endif
 
 #define RL_READLINE_NAME       "Abook"
@@ -53,27 +53,7 @@ rl_refresh()
 static int
 rline_calc_point()
 {
-       char *p;
-       int ret = 0;
-       
-       mbtowc(NULL, NULL, 0);
-       for(p = rl_line_buffer;(p - rl_line_buffer) < rl_point;) {
-               int a, l;
-               wchar_t wc;
-               
-               if((a = mbtowc(&wc, p, MB_CUR_MAX)) == 0)
-                       break;
-               else if (a == -1)
-                       return rl_point; /* fall back */
-               else
-                       p += a;
-
-               l = wcwidth(wc);
-               if(l > 0)
-                       ret += l;
-       }
-
-       return ret;
+       return (int)mbsnwidth(rl_line_buffer, rl_point, 0);
 }
 #endif
 
@@ -120,7 +100,9 @@ abook_rl_init(bool use_completion)
 {
        rl_readline_name = RL_READLINE_NAME;
        
+#if RL_VERSION_MAJOR >= 4
        rl_already_prompted = 1;
+#endif
        rl_catch_sigwinch = 0;
        
        rl_redisplay_function = rline_update;