From 0223d4fff11badc03470b4320fa9dfe28afd1bed Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 17 Feb 2000 22:00:13 +0000 Subject: Client: Online help works (Cisco style: just press `?' at the end of a line). --- client/client.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'client/client.c') diff --git a/client/client.c b/client/client.c index 50335e4..b9e3ab8 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); -- cgit v1.2.3