FTXUI
0.8.1
C++ functional terminal UI.
terminal_input_parser.hpp
Go to the documentation of this file.
1
#ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
2
#define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
3
4
#include <memory>
// for unique_ptr
5
#include <string>
// for string
6
#include <vector>
// for vector
7
8
#include "
ftxui/component/event.hpp
"
// for Event (ptr only)
9
#include "
ftxui/component/mouse.hpp
"
// for Mouse
10
#include "
ftxui/component/receiver.hpp
"
// for Sender
11
12
namespace
ftxui
{
13
struct
Event;
14
15
// Parse a sequence of |char| accross |time|. Produces |Event|.
16
class
TerminalInputParser
{
17
public
:
18
TerminalInputParser
(
Sender<Event>
out);
19
void
Timeout
(
int
time);
20
void
Add
(
char
c);
21
22
private
:
23
unsigned
char
Current();
24
bool
Eat();
25
26
enum
Type {
27
UNCOMPLETED,
28
DROP,
29
CHARACTER,
30
SPECIAL,
31
MOUSE,
32
CURSOR_REPORTING,
33
};
34
35
struct
CursorReporting {
36
int
x;
37
int
y;
38
};
39
40
struct
Output {
41
Type type;
42
union
{
43
Mouse
mouse;
44
CursorReporting cursor;
45
};
46
47
Output(Type t) : type(t) {}
48
};
49
50
void
Send(Output type);
51
Output Parse();
52
Output ParseUTF8();
53
Output ParseESC();
54
Output ParseDCS();
55
Output ParseCSI();
56
Output ParseOSC();
57
Output ParseMouse(
bool
altered,
bool
pressed, std::vector<int> arguments);
58
Output ParseCursorReporting(std::vector<int> arguments);
59
60
Sender<Event> out_;
61
int
position_ = -1;
62
int
timeout_ = 0;
63
std::string pending_;
64
};
65
66
}
// namespace ftxui
67
68
#endif
/* end of include guard: FTXUI_COMPONENT_TERMINAL_INPUT_PARSER */
69
70
// Copyright 2020 Arthur Sonzogni. All rights reserved.
71
// Use of this source code is governed by the MIT license that can be found in
72
// the LICENSE file.
ftxui
Definition:
captured_mouse.hpp:6
event.hpp
ftxui::TerminalInputParser::Timeout
void Timeout(int time)
Definition:
terminal_input_parser.cpp:15
ftxui::TerminalInputParser::TerminalInputParser
TerminalInputParser(Sender< Event > out)
Definition:
terminal_input_parser.cpp:12
receiver.hpp
ftxui::Mouse
A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift,...
Definition:
mouse.hpp:8
ftxui::TerminalInputParser::Add
void Add(char c)
Definition:
terminal_input_parser.cpp:24
ftxui::Sender
std::unique_ptr< SenderImpl< T > > Sender
Definition:
receiver.hpp:44
mouse.hpp
ftxui::TerminalInputParser
Definition:
terminal_input_parser.hpp:16