#pragma once #include #include #include #include #include namespace ui { // Escape (ESC) and Control (CSI) commands. enum commands { // Specific to this codebase INCOMPLETE, // We are in the middle of parsing a not-yet-completed command NOTCOMMAND, // We are not currently parsing a command; the character is placed in callback args INVALID, // Command was fully parsed but was invalid // Control characters BEL, BS, HT, LF, VT, FF, CR, SO, SI, DEL, // ESC commands DECALN, DECPAM, DECPNM, DECRC, DECSC, HTS, IND, NEL, RI, RIS, SCSG0_OFF, SCSG0_ON, SCSG1_OFF, SCSG1_ON, ST, // CSI commands CBT, CNL, CPL, CUB, CUD, CUF, CHA, CUP, CUU, DA, DCH, DECSTBM, DL, DSR, ECH, ED, EL, HPA, HPR, HVP, ICH, IL, RCP, REP, RM, RM_PRIVATE, SCP, SD, SGR, SM, SM_PRIVATE, SM_GRAPHICS, SU, TBC, VPA, VPR, WINOPS }; struct commandParserImpl; class CommandParser { public: // Construct a parser which does not automatically execute commands CommandParser(); // Construct a parser that calls a function when a command is parsed CommandParser(std::map)>>); ~CommandParser() {} // Parse the next character in the stream. This is stateful. std::tuple> parse(int); private: std::shared_ptr data; }; }