notcurses-input: use getopt, no mice with -m #2579

pull/2580/head
nick black 2 years ago
parent 47c42cf172
commit 46fd9317e5
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -7,6 +7,7 @@
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <clocale> #include <clocale>
#include <getopt.h>
#include <iostream> #include <iostream>
#include <ncpp/Plane.hh> #include <ncpp/Plane.hh>
#include <ncpp/NotCurses.hh> #include <ncpp/NotCurses.hh>
@ -417,19 +418,29 @@ int main(int argc, char** argv){
nopts.margin_r = 2; nopts.margin_r = 2;
nopts.margin_b = 2; nopts.margin_b = 2;
nopts.loglevel = NCLOGLEVEL_ERROR; nopts.loglevel = NCLOGLEVEL_ERROR;
// FIXME handle -m to inhibit mice events bool nomice = false;
if(argc > 2){ int opt;
usage(argv[0], stderr); while((opt = getopt(argc, argv, "vm")) != -1){
}else if(argc == 2){ switch(opt){
if(strcmp(argv[1], "-v") == 0){ case 'm':
nopts.loglevel = NCLOGLEVEL_TRACE; nomice = true;
}else{ break;
usage(argv[0], stderr); case 'v':
nopts.loglevel = NCLOGLEVEL_TRACE;
break;
default:
usage(argv[0], stderr);
break;
} }
} }
if(argv[optind]){ // non-option argument was provided
usage(argv[0], stderr);
}
nopts.flags = NCOPTION_INHIBIT_SETLOCALE; nopts.flags = NCOPTION_INHIBIT_SETLOCALE;
NotCurses nc(nopts); NotCurses nc(nopts);
nc.mouse_enable(NCMICE_ALL_EVENTS); if(!nomice){
nc.mouse_enable(NCMICE_ALL_EVENTS);
}
int ret = input_demo(&nc); int ret = input_demo(&nc);
if(!nc.stop() || ret){ if(!nc.stop() || ret){
return EXIT_FAILURE; return EXIT_FAILURE;

Loading…
Cancel
Save