diff options
author | Martin Mares <mj@ucw.cz> | 2000-02-17 22:00:13 +0000 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2000-02-17 22:00:13 +0000 |
commit | 0223d4fff11badc03470b4320fa9dfe28afd1bed (patch) | |
tree | b4281ed75395e0f219c3dc7fb2cc97f6282769db /client/client.c | |
parent | c51f132d582632037b4ef064fbd32d785af245fc (diff) |
Client: Online help works (Cisco style: just press `?' at the end of a line).
Diffstat (limited to 'client/client.c')
-rw-r--r-- | client/client.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/client/client.c b/client/client.c index 50335e4f..b9e3ab81 100644 --- a/client/client.c +++ b/client/client.c @@ -91,10 +91,43 @@ got_line(char *cmd_buffer) free(cmd_buffer); } +static int +input_complete(int arg, int key) +{ + ding(); + return 0; +} + +static int +input_help(int arg, int key) +{ + int i = 0; + + if (rl_point != rl_end || arg != 1) + return rl_insert(arg, '?'); + while (i < rl_end) + { + if (rl_line_buffer[i++] == '"') + do + { + if (i >= rl_end) /* `?' inside quoted string -> insert */ + return rl_insert(1, '?'); + } + while (rl_line_buffer[i++] != '"'); + } + puts("?"); + cmd_help(rl_line_buffer, rl_end); + rl_on_new_line(); + rl_redisplay(); + return 0; +} + static void input_init(void) { rl_readline_name = "birdc"; + rl_add_defun("bird-complete", input_complete, '\t'); + rl_add_defun("bird-help", input_help, '?'); rl_callback_handler_install("bird> ", got_line); input_initialized = 1; if (fcntl(0, F_SETFL, O_NONBLOCK) < 0) @@ -282,6 +315,7 @@ main(int argc, char **argv) #endif parse_args(argc, argv); + cmd_build_tree(); server_connect(); io_loop(0); |