kopia lustrzana https://github.com/espressif/esp-idf
fix(linenoise): Skip 0x00 to 0x1F character in dump mode
Skipping through the non printable character assures that in dumb mode, any special keys will not lead to the cursor movement.pull/13557/merge
rodzic
aa61062584
commit
ada38e8d5e
|
@ -178,6 +178,7 @@ enum KEY_ACTION{
|
|||
CTRL_U = 21, /* Ctrl+u */
|
||||
CTRL_W = 23, /* Ctrl+w */
|
||||
ESC = 27, /* Escape */
|
||||
UNIT_SEP = 31, /* ctrl-_ */
|
||||
BACKSPACE = 127 /* Backspace */
|
||||
};
|
||||
|
||||
|
@ -1131,9 +1132,7 @@ static int linenoiseDumb(char* buf, size_t buflen, const char* prompt) {
|
|||
int c = fgetc(stdin);
|
||||
if (c == '\n') {
|
||||
break;
|
||||
} else if (c >= 0x1c && c <= 0x1f){
|
||||
continue; /* consume arrow keys */
|
||||
} else if (c == BACKSPACE || c == 0x8) {
|
||||
} else if (c == BACKSPACE || c == CTRL_H) {
|
||||
if (count > 0) {
|
||||
buf[count - 1] = 0;
|
||||
count--;
|
||||
|
@ -1146,6 +1145,10 @@ static int linenoiseDumb(char* buf, size_t buflen, const char* prompt) {
|
|||
continue;
|
||||
}
|
||||
|
||||
} else if (c <= UNIT_SEP) {
|
||||
/* Consume all character that are non printable (the backspace
|
||||
* case is handled above) */
|
||||
continue;
|
||||
} else {
|
||||
buf[count] = c;
|
||||
++count;
|
||||
|
|
Ładowanie…
Reference in New Issue