libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
inputparser.h
Go to the documentation of this file.
1
8#pragma once
9
11#include <promeki/core/list.h>
14
16
25 public:
27 struct ParsedEvent {
28 enum Type { None, Key, Mouse };
29 Type type = None;
30 KeyEvent::Key key = KeyEvent::Key_Unknown;
31 uint8_t modifiers = 0;
32 String text;
33 // Mouse fields
34 Point2Di32 mousePos;
35 MouseEvent::Button mouseButton = MouseEvent::NoButton;
36 MouseEvent::Action mouseAction = MouseEvent::Press;
38 };
39
41
48 List<ParsedEvent> feed(const char *data, int len);
49
50 private:
51 enum State {
52 Normal,
53 EscapeStart,
54 CSI,
55 SS3,
56 CSIParam,
57 MouseSGR
58 };
59
60 State _state = Normal;
61 String _buf;
62 uint8_t _buttonState = 0;
63
64 void parseCSI(const String &seq, List<ParsedEvent> &events);
65 void parseSS3(char ch, List<ParsedEvent> &events);
66 void parseMouseSGR(const String &seq, List<ParsedEvent> &events);
67 static KeyEvent::Key csiToKey(int code, int modifier);
68};
69
Key
Key code enumeration.
Definition keyevent.h:30
Dynamic array container wrapping std::vector.
Definition list.h:40
Button
Mouse button flags (bit values for combining).
Definition mouseevent.h:29
Action
Mouse action enumeration.
Definition mouseevent.h:37
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
State machine for parsing terminal escape sequences into events.
Definition inputparser.h:24
List< ParsedEvent > feed(const char *data, int len)
Feeds raw input bytes into the parser.
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
Parsed event variant.
Definition inputparser.h:27
uint8_t mouseButtons
Bitmask of all held buttons.
Definition inputparser.h:37