Loading...
Searching...
No Matches
terminal_input_parser.hpp
Go to the documentation of this file.
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
#define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
#include <string> // for string
#include <vector> // for vector
#include "ftxui/component/mouse.hpp" // for Mouse
#include "ftxui/component/receiver.hpp" // for Sender
#include "ftxui/component/task.hpp" // for Task
namespace ftxui {
struct Event;
// Parse a sequence of |char| accross |time|. Produces |Event|.
class TerminalInputParser {
public:
explicit TerminalInputParser(Sender<Task> out);
void Timeout(int time);
void Add(char c);
private:
unsigned char Current();
bool Eat();
enum Type {
UNCOMPLETED,
DROP,
CHARACTER,
MOUSE,
CURSOR_POSITION,
CURSOR_SHAPE,
SPECIAL,
};
struct CursorPosition {
int x;
int y;
};
struct Output {
Type type;
union {
Mouse mouse;
CursorPosition cursor{};
int cursor_shape;
};
Output(Type t) // NOLINT
: type(t) {}
};
void Send(Output output);
Output Parse();
Output ParseUTF8();
Output ParseESC();
Output ParseDCS();
Output ParseCSI();
Output ParseOSC();
Output ParseMouse(bool altered, bool pressed, std::vector<int> arguments);
Output ParseCursorPosition(std::vector<int> arguments);
Sender<Task> out_;
int position_ = -1;
int timeout_ = 0;
std::string pending_;
};
} // namespace ftxui
#endif /* end of include guard: FTXUI_COMPONENT_TERMINAL_INPUT_PARSER */
ftxui::TerminalInputParser::Output.__unnamed0__::cursor
CursorPosition cursor
ftxui::TerminalInputParser::Output.__unnamed0__::cursor_shape
int cursor_shape
ftxui::TerminalInputParser::Output.__unnamed0__::mouse
Mouse mouse
ftxui::TerminalInputParser::Add
void Add(char c)
Definition terminal_input_parser.cpp:108
ftxui::TerminalInputParser::TerminalInputParser
TerminalInputParser(Sender< Task > out)
Definition terminal_input_parser.cpp:93
ftxui::TerminalInputParser::Timeout
void Timeout(int time)
Definition terminal_input_parser.cpp:96
mouse.hpp
ftxui
Definition animation.hpp:10
ftxui::Sender
std::unique_ptr< SenderImpl< T > > Sender
Definition receiver.hpp:45
receiver.hpp
ftxui::Event
Represent an event. It can be key press event, a terminal resize, or more ...
Definition event.hpp:27
ftxui::Mouse
A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift,...
Definition mouse.hpp:11
task.hpp