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

@@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <cassert>
#include <ftxui/component/event.hpp>
#include <vector>
#include "ftxui/component/component.hpp"
#include "ftxui/component/terminal_input_parser.hpp"
@@ -212,16 +213,17 @@ extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) {
auto screen =
Screen::Create(Dimension::Fixed(width), Dimension::Fixed(height));
auto event_receiver = MakeReceiver<Task>();
{
auto parser = TerminalInputParser(event_receiver->MakeSender());
for (size_t i = 0; i < size; ++i)
parser.Add(data[i]);
// Generate some events.
std::vector<Event> events;
auto parser =
TerminalInputParser([&](const Event& event) { events.push_back(event); });
for (size_t i = 0; i < size; ++i) {
parser.Add(data[i]);
}
Task event;
while (event_receiver->Receive(&event)) {
component->OnEvent(std::get<Event>(event));
for (const auto& event : events) {
component->OnEvent(event);
auto document = component->Render();
Render(screen, document);
}