[PoCs] use modifier accessors

pull/2567/head
nick black 2 years ago
parent 379b02c5cf
commit b51fa64150
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -310,7 +310,7 @@ int input_demo(ncpp::NotCurses* nc) {
if(r == 0){ // interrupted by signal
continue;
}
if((r == 'D' && ncinput_ctrl_p(&ni) || r == NCKEY_EOF){
if((r == 'D' && ncinput_ctrl_p(&ni)) || r == NCKEY_EOF){
done = true;
tid.join();
ncuplot_destroy(plot);

@ -372,12 +372,12 @@ bool ncreader_offer_input(ncreader* n, const ncinput* ni){
if(ni->evtype == NCTYPE_RELEASE){
return false;
}
if(ncinput_ctrl_p(&ni) && !n->no_cmd_keys){
if(ncinput_ctrl_p(ni) && !n->no_cmd_keys){
return ncreader_ctrl_input(n, ni);
}else if(ncinput_alt_p(&ni) && !n->no_cmd_keys){
}else if(ncinput_alt_p(ni) && !n->no_cmd_keys){
return ncreader_alt_input(n, ni);
}
if(ncinput_alt_p(&ni) || ncinput_ctrl_p(&ni)){ // pass on all alts/ctrls if no_cmd_keys is set
if(ncinput_alt_p(ni) || ncinput_ctrl_p(ni)){ // pass on all alts/ctrls if no_cmd_keys is set
return false;
}
if(ni->id == NCKEY_BACKSPACE){

@ -13,9 +13,12 @@ int main(void){
while((i = ncdirect_get_blocking(n, &ni)) != (uint32_t)-1){
unsigned char utf8[5] = {0};
notcurses_ucs32_to_utf8(&i, 1, utf8, sizeof(utf8));
printf("Read input: [%c%c%c] %s\n", ni.ctrl ? 'C' : 'c',
ni.alt ? 'A' : 'a', ni.shift ? 'S' : 's', utf8);
if(ni.ctrl && i == 'D'){
printf("Read input: [%c%c%c] %s\n",
ncinput_ctrl_p(&ni) ? 'C' : 'c',
ncinput_alt_p(&ni) ? 'A' : 'a',
ncinput_shift_p(&ni) ? 'S' : 's',
utf8);
if(ncinput_ctrl_p(&ni) && i == 'D'){
break;
}
}

@ -40,7 +40,11 @@ run_selector(struct notcurses* nc, struct ncselector* ns){
}
switch(keypress){
case NCKEY_ENTER: ncselector_destroy(ns, NULL); return;
case 'M': case 'J': if(ni.ctrl){ ncselector_destroy(ns, NULL); return; }
case 'M': case 'J':
if(ncinput_ctrl_p(&ni)){
ncselector_destroy(ns, NULL);
return;
}
}
if(keypress == 'q'){
break;

Loading…
Cancel
Save