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:
ArthurSonzogni 2019-07-01 00:43:29 +02:00
parent 16ae64dfb4
commit 65e7fae7df

View File

@ -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);