FTXUI  5.0.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
terminal_input_parser.hpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
5#define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
6
7#include <memory> // for unique_ptr
8#include <string> // for string
9#include <vector> // for vector
10
11#include "ftxui/component/event.hpp" // for Event (ptr only)
12#include "ftxui/component/mouse.hpp" // for Mouse
13#include "ftxui/component/receiver.hpp" // for Sender
14#include "ftxui/component/task.hpp" // for Task
15
16namespace ftxui {
17struct Event;
18
19// Parse a sequence of |char| accross |time|. Produces |Event|.
21 public:
23 void Timeout(int time);
24 void Add(char c);
25
26 private:
27 unsigned char Current();
28 bool Eat();
29
30 enum Type {
31 UNCOMPLETED,
32 DROP,
33 CHARACTER,
34 SPECIAL,
35 MOUSE,
36 CURSOR_REPORTING,
37 };
38
39 struct CursorReporting {
40 int x;
41 int y;
42 };
43
44 struct Output {
45 Type type;
46 union {
47 Mouse mouse;
48 CursorReporting cursor;
49 };
50
51 Output(Type t) : 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 ParseCursorReporting(std::vector<int> arguments);
63
64 Sender<Task> 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 */
std::unique_ptr< SenderImpl< T > > Sender
Definition receiver.hpp:47
Component Slider(SliderOption< T > options)
A slider in any direction.
Definition slider.cpp:339
A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift,...
Definition mouse.hpp:11