4 * by JH <jheinonen@users.sourceforge.net>
6 * Copyright (C) Jaakko Heinonen
12 #include <sys/types.h>
20 #if defined(HAVE_READLINE_READLINE_H)
21 # include <readline/readline.h>
22 #elif defined(HAVE_READLINE_H)
23 # include <readline.h>
26 #if defined(HAVE_READLINE_HISTORY_H)
27 # include <readline/history.h>
28 #elif defined(HAVE_HISTORY_H)
32 #define RL_READLINE_NAME "Abook"
34 static int rl_x, rl_y;
35 static WINDOW *rl_win;
47 int real_point = rl_point + rl_x;
49 if(real_point > (COLS - 1))
50 mvwaddnstr(rl_win, rl_y, rl_x,
51 rl_line_buffer + (1 + real_point - COLS),
54 mvwaddnstr(rl_win, rl_y, rl_x, rl_line_buffer, rl_end);
57 wmove(rl_win, rl_y, min(real_point, COLS - 1));
63 rline_compdisp(char **matches, int n, int max_len)
71 abook_rl_init(int use_completion)
73 rl_readline_name = RL_READLINE_NAME;
75 rl_already_prompted = 1;
77 rl_redisplay_function = rline_update;
78 rl_completion_display_matches_hook = rline_compdisp;
80 rl_unbind_function_in_map(rl_clear_screen, rl_get_keymap());
83 rl_bind_key('\t', rl_menu_complete);
85 rl_unbind_function_in_map(rl_complete, rl_get_keymap());
91 abook_readline(WINDOW *w, int y, int x, char *s, int limit, int use_completion)
96 abook_rl_init(use_completion);
98 wmove(rl_win, rl_y = y, rl_x = x);
104 ret = readline(NULL);