1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#pragma once
/// @file
#include <functional>
namespace nix {
/** DFA that eats terminal escapes
*
* See: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
*/
class TerminalCodeEater
{
public:
void feed(char c, std::function<void(char)> on_char);
private:
enum class State {
ExpectESC,
ExpectESCSeq,
InCSIParams,
InCSIIntermediates,
InOSCParams,
InOSCST,
};
State state = State::ExpectESC;
void transition(State new_state);
};
};
|