4 * by JH <jheinonen@users.sourceforge.net>
6 * Copyright (C) Jaakko Heinonen
11 #include <sys/types.h>
19 #if defined(HAVE_READLINE_READLINE_H)
20 # include <readline/readline.h>
21 #elif defined(HAVE_READLINE_H)
22 # include <readline.h>
25 #if defined(HAVE_READLINE_HISTORY_H)
26 # include <readline/history.h>
27 #elif defined(HAVE_HISTORY_H)
31 #define RL_READLINE_NAME "Abook"
33 static int rl_x, rl_y;
34 static WINDOW *rl_win;
46 int real_point = rl_point + rl_x;
48 if(real_point > (COLS - 1))
49 mvwaddnstr(rl_win, rl_y, rl_x,
50 rl_line_buffer + (1 + real_point - COLS),
53 mvwaddnstr(rl_win, rl_y, rl_x, rl_line_buffer, rl_end);
56 wmove(rl_win, rl_y, min(real_point, COLS - 1));
62 rline_compdisp(char **matches, int n, int max_len)
70 abook_rl_init(int use_completion)
72 rl_readline_name = RL_READLINE_NAME;
74 rl_already_prompted = 1;
76 rl_redisplay_function = rline_update;
77 rl_completion_display_matches_hook = rline_compdisp;
79 rl_unbind_function_in_map(rl_clear_screen, rl_get_keymap());
82 rl_bind_key('\t', rl_menu_complete);
84 rl_unbind_function_in_map(rl_complete, rl_get_keymap());
85 rl_unbind_function_in_map(rl_menu_complete, rl_get_keymap());
92 abook_readline(WINDOW *w, int y, int x, char *s, int limit, int use_completion)
97 abook_rl_init(use_completion);
99 wmove(rl_win, rl_y = y, rl_x = x);
105 ret = readline(NULL);