Terminal++ 3.1.0.4
A C++ library for interacting with ANSI terminal windows
Loading...
Searching...
No Matches
parser.hpp
1#pragma once
2
3#include "terminalpp/core.hpp"
4#include "terminalpp/token.hpp"
5
6#include <optional>
7#include <vector>
8
9namespace terminalpp::detail {
10
11class TERMINALPP_EXPORT parser
12{
13public:
14 parser();
15
16 std::optional<terminalpp::token> operator()(byte input);
17
18private:
19 enum class state
20 {
21 idle,
22 cr,
23 lf,
24 escape,
25 arguments,
26 mouse0,
27 mouse1,
28 mouse2,
29 };
30
31 std::optional<terminalpp::token> parse_idle(byte input);
32 std::optional<terminalpp::token> parse_cr(byte input);
33 std::optional<terminalpp::token> parse_lf(byte input);
34 std::optional<terminalpp::token> parse_escape(byte input);
35 std::optional<terminalpp::token> parse_arguments(byte input);
36 std::optional<terminalpp::token> parse_mouse0(byte input);
37 std::optional<terminalpp::token> parse_mouse1(byte input);
38 std::optional<terminalpp::token> parse_mouse2(byte input);
39
40 state state_;
41 byte initializer_;
42 byte extender_;
43 bool meta_;
44 mouse::event_type mouse_event_type_;
45 point mouse_coordinate_;
46 byte_storage argument_;
47 std::vector<byte_storage> arguments_;
48};
49
50} // namespace terminalpp::detail