mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
Merge branch 'fix/linenoise-arrow-usage' into 'master'
fix(linenoise): Read escape sequences one character at a time Closes IDFGH-15849 See merge request espressif/esp-idf!40601
This commit is contained in:
@@ -1022,11 +1022,15 @@ static int linenoiseEdit(char *buf, size_t buflen, const char *prompt)
|
|||||||
case ESC: { /* escape sequence */
|
case ESC: { /* escape sequence */
|
||||||
/* ESC [ sequences. */
|
/* ESC [ sequences. */
|
||||||
char seq[3];
|
char seq[3];
|
||||||
int r = read_func(in_fd, seq, 2);
|
int r = read_func(in_fd, seq, 1);
|
||||||
if (r != 2) {
|
if (r != 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (seq[0] == '[') {
|
if (seq[0] == '[') {
|
||||||
|
int r = read_func(in_fd, seq + 1, 1);
|
||||||
|
if (r != 1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (seq[1] >= '0' && seq[1] <= '9') {
|
if (seq[1] >= '0' && seq[1] <= '9') {
|
||||||
/* Extended escape, read additional byte. */
|
/* Extended escape, read additional byte. */
|
||||||
r = read_func(in_fd, seq + 2, 1);
|
r = read_func(in_fd, seq + 2, 1);
|
||||||
@@ -1065,6 +1069,10 @@ static int linenoiseEdit(char *buf, size_t buflen, const char *prompt)
|
|||||||
}
|
}
|
||||||
/* ESC O sequences. */
|
/* ESC O sequences. */
|
||||||
else if (seq[0] == 'O') {
|
else if (seq[0] == 'O') {
|
||||||
|
int r = read_func(in_fd, seq + 1, 1);
|
||||||
|
if (r != 1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
switch(seq[1]) {
|
switch(seq[1]) {
|
||||||
case 'H': /* Home */
|
case 'H': /* Home */
|
||||||
linenoiseEditMoveHome(&l);
|
linenoiseEditMoveHome(&l);
|
||||||
|
Reference in New Issue
Block a user