]> git.deb.at Git - pkg/abook.git/blobdiff - abook_rl.c
autoconf/automake update
[pkg/abook.git] / abook_rl.c
index 22c66ce497527d764776ddee531ec95444722776..c09b4bb6dc4866e8402bfb4b1f37c0a6b58459b4 100644 (file)
 #       include <history.h>
 #endif
 
+#ifdef HANDLE_MULTIBYTE
+#      include <mbswidth.h>
+#endif
+
 #define RL_READLINE_NAME       "Abook"
 
 static int rl_x, rl_y;
@@ -45,10 +49,22 @@ rl_refresh()
        wrefresh(rl_win);
 }
 
+#ifdef HANDLE_MULTIBYTE
+static int
+rline_calc_point()
+{
+       return (int)mbsnwidth(rl_line_buffer, rl_point, 0);
+}
+#endif
+
 static void
 rline_update()
 {      
+#ifdef HANDLE_MULTIBYTE
+       int real_point = rline_calc_point() + rl_x;
+#else
        int real_point = rl_point + rl_x;
+#endif
        
        if(real_point > (COLS - 1))
                mvwaddnstr(rl_win, rl_y, rl_x,
@@ -84,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;