notcurses_getc(): read from stdin
parent
a037cdfe5a
commit
c76735cb2a
@ -1,16 +1,29 @@
|
|||||||
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <clocale>
|
||||||
|
#include <iostream>
|
||||||
#include <notcurses.h>
|
#include <notcurses.h>
|
||||||
|
|
||||||
int main(void){
|
int main(void){
|
||||||
|
if(setlocale(LC_ALL, "") == nullptr){
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
notcurses_options opts{};
|
notcurses_options opts{};
|
||||||
opts.outfp = stdout;
|
opts.outfp = stdout;
|
||||||
struct notcurses* nc = notcurses_init(&opts);
|
struct notcurses* nc = notcurses_init(&opts);
|
||||||
if(nc == NULL){
|
if(nc == nullptr){
|
||||||
return EXIT_FAILURE;;
|
return EXIT_FAILURE;;
|
||||||
}
|
}
|
||||||
// FIXME read input
|
int r;
|
||||||
if(notcurses_stop(nc)){
|
cell c = CELL_TRIVIAL_INITIALIZER;
|
||||||
return EXIT_FAILURE;;
|
while((r = notcurses_getc_blocking(nc, &c)) >= 0){
|
||||||
|
if(r == 0){ // interrupted by signal
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
int e = errno;
|
||||||
|
notcurses_stop(nc);
|
||||||
|
std::cerr << "Error reading from terminal (" << strerror(e) << "?)\n";
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue