input: allow duplications of escapes #199

pull/204/head
nick black 5 years ago
parent 2aeb303e94
commit 2a256192ad
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -92,11 +92,13 @@ notcurses_add_input_escape(notcurses* nc, const char* esc, char32_t special){
cur = &(*cur)->trie[validate];
}
}while(*esc);
// it appears that multiple keys can be mapped to the same escape string. as
// an example, see "kend" and "kc1" in st ("simple term" from suckless) :/.
if((*cur)->special != NCKEY_INVALID){ // already had one here!
fprintf(stderr, "Already added escape (got 0x%x, wanted 0x%x)\n", (*cur)->special, special);
return -1;
fprintf(stderr, "Warning: already added escape (got 0x%x, wanted 0x%x)\n", (*cur)->special, special);
}else{
(*cur)->special = special;
}
(*cur)->special = special;
return 0;
}
@ -296,6 +298,7 @@ int prep_special_keys(notcurses* nc){
}
//fprintf(stderr, "support for terminfo's %s: %s\n", k->tinfo, seq);
if(notcurses_add_input_escape(nc, seq, k->key)){
fprintf(stderr, "Couldn't add support for %s\n", k->tinfo);
return -1;
}
}

@ -557,6 +557,13 @@ interrogate_terminfo(notcurses* nc, const notcurses_options* opts){
term_verify_seq(&nc->clearbol, "el1");
term_verify_seq(&nc->cuf, "cuf"); // n non-destructive spaces
term_verify_seq(&nc->cuf1, "cuf1"); // non-destructive space
term_verify_seq(&nc->smkx, "smkx"); // set application mode
if(nc->smkx){
if(putp(tiparm(nc->smkx)) != OK){
fprintf(stderr, "Error entering application mode\n");
return -1;
}
}
if(prep_special_keys(nc)){
return -1;
}

Loading…
Cancel
Save