FTXUI
4.1.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
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
#include "
ftxui/component/task.hpp
"
// for Task
12
13
namespace
ftxui
{
14
struct
Event;
15
16
// Parse a sequence of |char| accross |time|. Produces |Event|.
17
class
TerminalInputParser
{
18
public
:
19
TerminalInputParser
(
Sender<Task>
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
SPECIAL,
32
MOUSE,
33
CURSOR_REPORTING,
34
};
35
36
struct
CursorReporting {
37
int
x;
38
int
y;
39
};
40
41
struct
Output {
42
Type type;
43
union
{
44
Mouse
mouse;
45
CursorReporting cursor;
46
};
47
48
Output(Type t) : type(t) {}
49
};
50
51
void
Send(Output output);
52
Output Parse();
53
Output ParseUTF8();
54
Output ParseESC();
55
Output ParseDCS();
56
Output ParseCSI();
57
Output ParseOSC();
58
Output ParseMouse(
bool
altered,
bool
pressed, std::vector<int> arguments);
59
Output ParseCursorReporting(std::vector<int> arguments);
60
61
Sender<Task>
out_;
62
int
position_ = -1;
63
int
timeout_ = 0;
64
std::string pending_;
65
};
66
67
}
// namespace ftxui
68
69
#endif
/* end of include guard: FTXUI_COMPONENT_TERMINAL_INPUT_PARSER */
70
71
// Copyright 2020 Arthur Sonzogni. All rights reserved.
72
// Use of this source code is governed by the MIT license that can be found in
73
// the LICENSE file.
ftxui::TerminalInputParser
Definition
terminal_input_parser.hpp:17
ftxui::TerminalInputParser::Add
void Add(char c)
Definition
terminal_input_parser.cpp:64
ftxui::TerminalInputParser::TerminalInputParser
TerminalInputParser(Sender< Task > out)
Definition
terminal_input_parser.cpp:49
ftxui::TerminalInputParser::Timeout
void Timeout(int time)
Definition
terminal_input_parser.cpp:52
event.hpp
mouse.hpp
ftxui
Definition
animation.hpp:9
ftxui::Sender
std::unique_ptr< SenderImpl< T > > Sender
Definition
receiver.hpp:44
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
task.hpp