Stop using Sender/Receiver in TerminalInputParser. (#1073)

Stop using Sender/Receiver in TerminalInputParser.

This will help removing usage of thread.

At some point, my goal is to have an initialization step when installing
the ScreenInteractive so that we can provide the terminal ID
synchronously without losing some events. This will help with:
https://github.com/ArthurSonzogni/FTXUI/pull/1069
This commit is contained in:
Arthur Sonzogni
2025-07-02 15:23:01 +02:00
committed by GitHub
parent 68fc9b1212
commit b78b97056b
11 changed files with 311 additions and 303 deletions

View File

@@ -4,12 +4,11 @@
#ifndef FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
#define FTXUI_COMPONENT_TERMINAL_INPUT_PARSER
#include <functional>
#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
#include "ftxui/component/mouse.hpp" // for Mouse
namespace ftxui {
struct Event;
@@ -17,7 +16,7 @@ struct Event;
// Parse a sequence of |char| accross |time|. Produces |Event|.
class TerminalInputParser {
public:
explicit TerminalInputParser(Sender<Task> out);
explicit TerminalInputParser(std::function<void(Event)> out);
void Timeout(int time);
void Add(char c);
@@ -62,7 +61,7 @@ class TerminalInputParser {
Output ParseMouse(bool altered, bool pressed, std::vector<int> arguments);
Output ParseCursorPosition(std::vector<int> arguments);
Sender<Task> out_;
std::function<void(Event)> out_;
int position_ = -1;
int timeout_ = 0;
std::string pending_;