From 229ddcf5ccbb325fe81ee018a2a99c53a3869cd1 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Sun, 24 Sep 2017 16:58:27 +0200 Subject: [PATCH] non-line scrolling mode in getline --- CHANGELOG.md | 3 +++ apps/cli/cli_handle.c | 3 +++ apps/cli/cli_main.c | 1 + clixon.conf.cpp.cpp | 4 ++++ example/routing.conf.local | 4 ++++ 5 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c6a78b5..3da43065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Clixon CHANGELOG +* Support for non-line scrolling in CLI, eg wrap lines. Set with: + CLICON_CLI_LINESCROLLING 0 + ## 3.3.2 Aug 27 2017 ### Known issues diff --git a/apps/cli/cli_handle.c b/apps/cli/cli_handle.c index 7d2e422e..97be41ef 100644 --- a/apps/cli/cli_handle.c +++ b/apps/cli/cli_handle.c @@ -146,6 +146,9 @@ cli_syntax_set(clicon_handle h, cli_syntax_t *stx) { struct cli_handle *cl = handle(h); + + if (cl->cl_stx) + free(cl->cl_stx); cl->cl_stx = stx; return 0; } diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index a9a17073..dc31fa71 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -392,6 +392,7 @@ main(int argc, char **argv) cli_plugin_start(h, argc+1, argv-1); *(argv-1) = tmp; + cligen_line_scrolling_set(cli_cligen(h), clicon_option_int(h,"CLICON_CLI_LINESCROLLING")); /* Launch interfactive event loop, unless -1 */ if (restarg != NULL && strlen(restarg)){ char *mode = cli_syntax_mode(h); diff --git a/clixon.conf.cpp.cpp b/clixon.conf.cpp.cpp index 11102feb..3c384ad1 100644 --- a/clixon.conf.cpp.cpp +++ b/clixon.conf.cpp.cpp @@ -119,6 +119,10 @@ CLICON_XMLDB_PLUGIN libdir/xmldb/text.so # Dont include keys in cvec in cli vars callbacks, ie a & k in 'a k ' ignored # CLICON_CLI_VARONLY 1 +# Set to 0 if you want CLI to wrap to next line. +# Set to 1 if you want CLI to scroll sideways when approaching right margin +# CLICON_CLI_LINESCROLLING 1 + # FastCGI unix socket. Should be specified in webserver # Eg in nginx: fastcgi_pass unix:/www-data/clicon_restconf.sock; CLICON_RESTCONF_PATH /www-data/fastcgi_restconf.sock diff --git a/example/routing.conf.local b/example/routing.conf.local index 4427abcf..9c4c75ad 100644 --- a/example/routing.conf.local +++ b/example/routing.conf.local @@ -32,3 +32,7 @@ CLICON_USE_STARTUP_CONFIG 0 # XMLDB datastore plugin filename (see datastore/ and clixon_xml_db.[ch]) CLICON_XMLDB_PLUGIN /usr/local/lib/xmldb/text.so #CLICON_XMLDB_PLUGIN /usr/local/lib/xmldb/keyvalue.so + +# Set to 0 if you want CLI to wrap to next line. +# Set to 1 if you want CLI to scroll sideways when approaching right margin +CLICON_CLI_LINESCROLLING 0