mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-04 06:00:30 +00:00
introduce NCKEY_ESC, use it everywhere
This commit is contained in:
parent
db0dc15088
commit
e885d87d1a
@ -119,6 +119,9 @@ extern "C" {
|
||||
#define NCKEY_SCROLL_DOWN NCKEY_BUTTON5
|
||||
#define NCKEY_RETURN NCKEY_ENTER
|
||||
|
||||
// Just aliases, ma'am, from the 128 characters common to ASCII+UTF8
|
||||
#define NCKEY_ESC 0x1b
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
@ -142,7 +142,7 @@ const char* nckeystr(char32_t spkey){
|
||||
|
||||
// Print the utf8 Control Pictures for otherwise unprintable ASCII
|
||||
char32_t printutf8(char32_t kp){
|
||||
if(kp <= 27){
|
||||
if(kp <= NCKEY_ESC){
|
||||
return 0x2400 + kp;
|
||||
}
|
||||
return kp;
|
||||
|
@ -153,7 +153,7 @@ cursor_yx_get(int ttyfd, int* y, int* x){
|
||||
while(read(ttyfd, &in, 1) == 1){
|
||||
bool valid = false;
|
||||
switch(state){
|
||||
case CURSOR_ESC: valid = (in == '\x1b'); state = CURSOR_LSQUARE; break;
|
||||
case CURSOR_ESC: valid = (in == NCKEY_ESC); state = CURSOR_LSQUARE; break;
|
||||
case CURSOR_LSQUARE: valid = (in == '['); state = CURSOR_ROW; break;
|
||||
case CURSOR_ROW:
|
||||
if(isdigit(in)){
|
||||
|
@ -12,8 +12,6 @@
|
||||
#define CSIPREFIX "\x1b[<"
|
||||
static const char32_t NCKEY_CSI = 1;
|
||||
|
||||
static const unsigned char ESC = 0x1b; // 27
|
||||
|
||||
static sig_atomic_t resize_seen;
|
||||
|
||||
void sigwinch_handler(int signo){
|
||||
@ -75,7 +73,7 @@ void input_free_esctrie(esctrie** eptr){
|
||||
|
||||
static int
|
||||
ncinputlayer_add_input_escape(ncinputlayer* nc, const char* esc, char32_t special){
|
||||
if(esc[0] != ESC || strlen(esc) < 2){ // assume ESC prefix + content
|
||||
if(esc[0] != NCKEY_ESC || strlen(esc) < 2){ // assume ESC prefix + content
|
||||
fprintf(stderr, "Not an escape: %s (0x%x)\n", esc, special);
|
||||
return -1;
|
||||
}
|
||||
@ -205,7 +203,7 @@ handle_getc(ncinputlayer* nc, int kpress, ncinput* ni, int leftmargin, int topma
|
||||
if(kpress < 0){
|
||||
return -1;
|
||||
}
|
||||
if(kpress == ESC){
|
||||
if(kpress == NCKEY_ESC){
|
||||
const esctrie* esc = nc->inputescapes;
|
||||
int candidate = 0;
|
||||
while(esc && esc->special == NCKEY_INVALID && nc->inputbuf_occupied){
|
||||
@ -524,7 +522,7 @@ int prep_special_keys(ncinputlayer* nc){
|
||||
//fprintf(stderr, "no support for terminfo's %s\n", k->tinfo);
|
||||
continue;
|
||||
}
|
||||
if(seq[0] != ESC){
|
||||
if(seq[0] != NCKEY_ESC){
|
||||
//fprintf(stderr, "Terminfo's %s is not an escape sequence (%zub)\n", k->tinfo, strlen(seq));
|
||||
continue;
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ bool ncmenu_offer_input(ncmenu* n, const ncinput* nc){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}else if(nc->id == 0x1b){
|
||||
}else if(nc->id == NCKEY_ESC){
|
||||
ncmenu_rollup(n);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user