3#include "di/container/string/string.h"
4#include "di/container/string/string_view.h"
5#include "di/function/container/function.h"
6#include "di/reflect/prelude.h"
7#include "di/vocab/variant/prelude.h"
16 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<PrintableCharacter>) {
28 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<DCS>) {
40 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<OSC>) {
50 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<APC>) {
51 return di::make_fields<
"APC">(di::field<
"data", &
APC::data>);
62 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<CSI>) {
74 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<Escape>) {
86 constexpr friend auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<ControlCharacter>) {
92using ParserResult = di::Variant<PrintableCharacter, DCS, OSC, APC, CSI, Escape, ControlCharacter>;
110#define __ENUMERATE_STATES(M) \
113 M(EscapeIntermediate, escape_intermediate) \
114 M(CsiEntry, csi_entry) \
115 M(CsiParam, csi_param) \
116 M(CsiIntermediate, csi_intermediate) \
117 M(CsiIgnore, csi_ignore) \
118 M(DcsEntry, dcs_entry) \
119 M(DcsParam, dcs_param) \
120 M(DcsIntermediate, dcs_intermediate) \
121 M(DcsPassthrough, dcs_passthrough) \
122 M(DcsIgnore, dcs_ignore) \
123 M(OscString, osc_string) \
124 M(ApcString, apc_string) \
125 M(SosPmString, sos_pm_string) \
129#define __ENUMERATE_STATE(N, n) N,
131#undef __ENUMERATE_STATE
134#define __ENUMERATE_STATE(N, n) void n##_state(c32 code_point);
136#undef __ENUMERATE_STATE
138 void ignore(c32 code_point);
139 void print(c32 code_point);
140 void execute(c32 code_point);
142 void collect(c32 code_point);
143 void param(c32 code_point);
144 void esc_dispatch(c32 code_point);
145 void csi_dispatch(c32 code_point);
147 void put(c32 code_point);
150 void osc_put(c32 code_point);
153 void apc_put(c32 code_point);
155 void output_ss3(c32 code_point);
157 void transition(State state);
159 void on_input(c32 code_point);
161 void add_param(di::Optional<u32> param);
163 State m_last_state { State::Ground };
164 State m_next_state { State::Ground };
165 di::Function<void()> m_on_state_exit;
167 di::String m_intermediate;
168 di::String m_current_param;
171 bool m_last_separator_was_colon {
false };
172 bool m_saw_legacy_string_terminator {
false };
174 di::Vector<ParserResult> m_result;
Definition escape_sequence_parser.h:94
auto parse_input_escape_sequences(di::StringView data, bool flush=true) -> di::Vector< ParserResult >
Definition escape_sequence_parser.cpp:659
auto parse_application_escape_sequences(di::StringView data) -> di::Vector< ParserResult >
Definition escape_sequence_parser.cpp:650
Mode
Definition escape_sequence_parser.h:96
@ Input
Definition escape_sequence_parser.h:98
@ Application
Definition escape_sequence_parser.h:97
#define __ENUMERATE_STATES(M)
Definition escape_sequence_parser.h:110
#define __ENUMERATE_STATE(N, n)
Definition escape_sequence_parser.h:129
Definition test_params.cpp:4
Definition cursor_style.h:5
di::Variant< PrintableCharacter, DCS, OSC, APC, CSI, Escape, ControlCharacter > ParserResult
Definition escape_sequence_parser.h:92
Definition escape_sequence_parser.h:45
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< APC >)
Definition escape_sequence_parser.h:50
auto operator==(APC const &) const -> bool=default
di::String data
Definition escape_sequence_parser.h:46
Definition escape_sequence_parser.h:55
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< CSI >)
Definition escape_sequence_parser.h:62
auto operator==(CSI const &) const -> bool=default
c32 terminator
Definition escape_sequence_parser.h:58
di::String intermediate
Definition escape_sequence_parser.h:56
Params params
Definition escape_sequence_parser.h:57
Definition escape_sequence_parser.h:80
bool was_in_escape
Definition escape_sequence_parser.h:82
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< ControlCharacter >)
Definition escape_sequence_parser.h:86
auto operator==(ControlCharacter const &) const -> bool=default
u32 code_point
Definition escape_sequence_parser.h:81
Definition escape_sequence_parser.h:21
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< DCS >)
Definition escape_sequence_parser.h:28
di::String intermediate
Definition escape_sequence_parser.h:22
auto operator==(DCS const &) const -> bool=default
Params params
Definition escape_sequence_parser.h:23
di::String data
Definition escape_sequence_parser.h:24
Definition escape_sequence_parser.h:68
c32 terminator
Definition escape_sequence_parser.h:70
auto operator==(Escape const &) const -> bool=default
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< Escape >)
Definition escape_sequence_parser.h:74
di::String intermediate
Definition escape_sequence_parser.h:69
Definition escape_sequence_parser.h:34
auto operator==(OSC const &) const -> bool=default
di::StringView terminator
Definition escape_sequence_parser.h:36
di::String data
Definition escape_sequence_parser.h:35
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< OSC >)
Definition escape_sequence_parser.h:40
Definition escape_sequence_parser.h:11
constexpr friend auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< PrintableCharacter >)
Definition escape_sequence_parser.h:16
c32 code_point
Definition escape_sequence_parser.h:12
auto operator==(PrintableCharacter const &) const -> bool=default