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// このソースコードは、LICENSEファイルにあるMITライセンスに従って使用されます。
3// LICENSEファイルを参照してください。
4#ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
5#define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
6
7#include <functional>
8#include <string> // 文字列用
9#include <vector> // ベクター用
10
11#include "ftxui/component/mouse.hpp" // マウス用
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 /* インクルードガードの終わり: FTXUI_COMPONENT_TERMINAL_INPUT_PARSER */
TerminalInputParser(std::function< void(Event)> out)
イベントを表します。キープレスイベント、ターミナルのリサイズなど、さまざまなイベントがあります。
Definition event.hpp:28
マウスイベント。マウスの座標、押されたボタン、 および修飾子(shift, ctrl, meta)が含まれます。
Definition mouse.hpp:11
FTXUI ftxui:: 名前空間
Definition animation.hpp:9