From 3ddbb3c2ec5de4be71861ac286036d7479fcff34 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 27 Sep 2021 22:32:10 -0400 Subject: [PATCH] readline PoC --- src/lib/direct.c | 1 + src/poc/readline.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/poc/readline.c diff --git a/src/lib/direct.c b/src/lib/direct.c index c1c7939f5..ad7619204 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -955,6 +955,7 @@ char* ncdirect_readline(ncdirect* n, const char* prompt){ } return readline(prompt); #else + logerror("notcurses was built without readline support\n"); (void)n; (void)prompt; return NULL; diff --git a/src/poc/readline.c b/src/poc/readline.c new file mode 100644 index 000000000..6e5c60e25 --- /dev/null +++ b/src/poc/readline.c @@ -0,0 +1,26 @@ +#include + +// play with libreadline as wrapped by notcurses-direct + +static int +rl(struct ncdirect* n){ + char* l; + while( (l = ncdirect_readline(n, "ncdirect")) ){ + fprintf(stderr, "input: [%s]\n", l); + free(l); + } + return 0; +} + +int main(void){ + uint64_t flags = NCDIRECT_OPTION_INHIBIT_CBREAK; + struct ncdirect* n = ncdirect_core_init(NULL, NULL, flags); + if(n == NULL){ + return EXIT_FAILURE; + } + rl(n); + if(ncdirect_stop(n)){ + return EXIT_FAILURE; + } + return EXIT_SUCCESS; +}