]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fs_cli: clear the CLI before inserting function key commands
authorTravis Cross <tc@traviscross.com>
Thu, 22 Sep 2011 21:07:54 +0000 (21:07 +0000)
committerTravis Cross <tc@traviscross.com>
Fri, 23 Sep 2011 01:25:43 +0000 (01:25 +0000)
libs/esl/fs_cli.c

index 3085a44ea5ad124d97ff4194699a905746de37b9..3873f455f112192ae7c002ee1832395074d77c68 100644 (file)
@@ -102,6 +102,13 @@ static void sleep_s(int secs) { _sleep_ns(secs, 0); }
 
 static int process_command(esl_handle_t *handle, const char *cmd);
 
+static void clear_cli(void) {
+       const LineInfo *lf = el_line(el);
+       int len=(lf->lastchar - lf->buffer);
+       for (; len>0; len--)
+               write(STDOUT_FILENO, "\b", 1);
+}
+
 /* If a fnkey is configured then process the command */
 static unsigned char console_fnkey_pressed(int i)
 {
@@ -112,6 +119,7 @@ static unsigned char console_fnkey_pressed(int i)
                esl_log(ESL_LOG_ERROR, "FUNCTION KEY F%d IS NOT BOUND, please edit your config.\n", i);
                return CC_REDISPLAY;
        }
+       clear_cli();
        printf("%s\n", c);
        if (process_command(global_handle, c)) {
                running = thread_running = 0;