forked from lix-project/lix
jade
18ed6c3bdf
This allows for automating using the repl without needing a PTY, with
very easy to write test files.
Change-Id: Ia8d7854edd91f93477638942cb6fc261354e6035
30 lines
474 B
C++
30 lines
474 B
C++
#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,
|
|
};
|
|
|
|
State state = State::ExpectESC;
|
|
|
|
void transition(State new_state);
|
|
};
|
|
};
|