readline PoC

This commit is contained in:
nick black 2021-09-27 22:32:10 -04:00
parent 671656ea80
commit 3ddbb3c2ec
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 27 additions and 0 deletions

View File

@ -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;

26
src/poc/readline.c Normal file
View File

@ -0,0 +1,26 @@
#include <notcurses/direct.h>
// 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;
}