mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-07-14 23:21:12 +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/screen/string.hpp"
|
||||
|
||||
@ -48,15 +49,18 @@ Event ParseCSI(std::function<char()> getchar, std::string& input) {
|
||||
char c = getchar();
|
||||
input += c;
|
||||
|
||||
if (c >= ' ' && c <= '/')
|
||||
if (c >= '0' && c<= '9')
|
||||
continue;
|
||||
|
||||
if (c == ';')
|
||||
continue;
|
||||
|
||||
if (c >= ' ' && c <= '~')
|
||||
return Event::Special(input);
|
||||
|
||||
// Invalid ESC in CSI.
|
||||
if (c == '\e')
|
||||
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) {
|
||||
input += getchar();
|
||||
switch (input.back()) {
|
||||
case 'P':
|
||||
return ParseDCS(getchar, input);
|
||||
case '[':
|
||||
return ParseCSI(getchar, input);
|
||||
case ']':
|
||||
return ParseOSC(getchar, input);
|
||||
case 'P': return ParseDCS(getchar, input);
|
||||
case '[': return ParseCSI(getchar, input);
|
||||
case ']': return ParseOSC(getchar, input);
|
||||
default:
|
||||
input += getchar();
|
||||
return Event::Special(input);
|
||||
|
Loading…
Reference in New Issue
Block a user