mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-07-15 07:31:13 +08:00
Fix parsing of CSI escape sequence.
There was a bug, preventing the user from typing the DEL key. This is related to bug: https://github.com/ArthurSonzogni/FTXUI/issues/4
This commit is contained in:
parent
16ae64dfb4
commit
65e7fae7df
@ -1,3 +1,4 @@
|
|||||||
|
#include <iostream>
|
||||||
#include "ftxui/component/event.hpp"
|
#include "ftxui/component/event.hpp"
|
||||||
#include "ftxui/screen/string.hpp"
|
#include "ftxui/screen/string.hpp"
|
||||||
|
|
||||||
@ -48,15 +49,18 @@ Event ParseCSI(std::function<char()> getchar, std::string& input) {
|
|||||||
char c = getchar();
|
char c = getchar();
|
||||||
input += c;
|
input += c;
|
||||||
|
|
||||||
if (c >= ' ' && c <= '/')
|
if (c >= '0' && c<= '9')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (c == ';')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (c >= ' ' && c <= '~')
|
||||||
return Event::Special(input);
|
return Event::Special(input);
|
||||||
|
|
||||||
// Invalid ESC in CSI.
|
// Invalid ESC in CSI.
|
||||||
if (c == '\e')
|
if (c == '\e')
|
||||||
return Event::Special(input);
|
return Event::Special(input);
|
||||||
|
|
||||||
if (c >= '@' && c <= 'v')
|
|
||||||
return Event::Special(input);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,12 +93,9 @@ Event ParseOSC(std::function<char()> getchar, std::string& input) {
|
|||||||
Event ParseESC(std::function<char()> getchar, std::string& input) {
|
Event ParseESC(std::function<char()> getchar, std::string& input) {
|
||||||
input += getchar();
|
input += getchar();
|
||||||
switch (input.back()) {
|
switch (input.back()) {
|
||||||
case 'P':
|
case 'P': return ParseDCS(getchar, input);
|
||||||
return ParseDCS(getchar, input);
|
case '[': return ParseCSI(getchar, input);
|
||||||
case '[':
|
case ']': return ParseOSC(getchar, input);
|
||||||
return ParseCSI(getchar, input);
|
|
||||||
case ']':
|
|
||||||
return ParseOSC(getchar, input);
|
|
||||||
default:
|
default:
|
||||||
input += getchar();
|
input += getchar();
|
||||||
return Event::Special(input);
|
return Event::Special(input);
|
||||||
|
Loading…
Reference in New Issue
Block a user