FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
terminal_input_parser.hpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. 保留所有權利。
2// 本原始碼的使用受 MIT 授權條款約束,詳情請參閱
3// LICENSE 檔案。
4#ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
5#define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
6
7#include <functional>
8#include <string> // for string
9#include <vector> // for vector
10
11#include "ftxui/component/mouse.hpp" // for Mouse
12
13namespace ftxui {
14struct Event;
15
16// 解析一段時間內的 |char| 序列。產生 |Event|。
18 public:
19 explicit TerminalInputParser(std::function<void(Event)> out);
20 void Timeout(int time);
21 void Add(char c);
22
23 private:
24 unsigned char Current();
25 bool Eat();
26
27 enum Type {
28 UNCOMPLETED,
29 DROP,
30 CHARACTER,
31 MOUSE,
32 CURSOR_POSITION,
33 CURSOR_SHAPE,
34 SPECIAL,
35 };
36
37 struct CursorPosition {
38 int x;
39 int y;
40 };
41
42 struct Output {
43 Type type;
44 union {
45 Mouse mouse;
46 CursorPosition cursor{};
47 int cursor_shape;
48 };
49
50 Output(Type t) // NOLINT
51 : type(t) {}
52 };
53
54 void Send(Output output);
55 Output Parse();
56 Output ParseUTF8();
57 Output ParseESC();
58 Output ParseDCS();
59 Output ParseCSI();
60 Output ParseOSC();
61 Output ParseMouse(bool altered, bool pressed, std::vector<int> arguments);
62 Output ParseCursorPosition(std::vector<int> arguments);
63
64 std::function<void(Event)> out_;
65 int position_ = -1;
66 int timeout_ = 0;
67 std::string pending_;
68};
69
70} // namespace ftxui
71
72#endif /* end of include guard: FTXUI_COMPONENT_TERMINAL_INPUT_PARSER */
TerminalInputParser(std::function< void(Event)> out)
代表一個事件。它可以是按鍵事件、終端機大小調整,或更多...
Definition event.hpp:27
滑鼠事件。它包含滑鼠的座標、按下的按鈕 以及修飾鍵(shift、ctrl、meta)。
Definition mouse.hpp:11
FTXUI 的 ftxui:: 命名空間
Definition animation.hpp:10