4#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
5#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
24using Component = std::shared_ptr<ComponentBase>;
25class ScreenInteractivePrivate;
96 void RunOnceBlocking(
Component component);
99 bool HandleSelection(
bool handled,
Event event);
100 void RefreshSelection();
102 void ResetCursorPosition();
104 void InstallPipedInputHandling();
106 void Signal(
int signal);
108 void FetchTerminalEvents();
110 void PostAnimationTask();
122 bool use_alternative_screen);
125 const bool use_alternative_screen_;
127 bool track_mouse_ =
true;
129 std::string set_cursor_position;
130 std::string reset_cursor_position;
132 std::atomic<bool> quit_{
false};
133 bool animation_requested_ =
false;
139 std::uint64_t frame_count_ = 0;
140 bool mouse_captured =
false;
141 bool previous_frame_resized_ =
false;
143 bool frame_valid_ =
false;
145 bool force_handle_ctrl_c_ =
true;
146 bool force_handle_ctrl_z_ =
true;
149 bool handle_piped_input_ =
true;
154 int cursor_reset_shape_ = 1;
158 struct SelectionData {
164 bool operator==(
const SelectionData& other)
const;
165 bool operator!=(
const SelectionData& other)
const;
167 SelectionData selection_data_;
168 SelectionData selection_data_previous_;
169 std::unique_ptr<Selection> selection_;
170 std::function<void()> selection_on_change_;
174 std::unique_ptr<Internal> internal_;
static void Signal(ScreenInteractive &s, int signal)
static ScreenInteractive TerminalOutput()
void HandlePipedInput(bool enable=true)
Enable or disable automatic piped input handling. When enabled, FTXUI will detect piped input and red...
void Exit()
Exit the main loop.
static ScreenInteractive FixedSize(int dimx, int dimy)
void PostEvent(Event event)
Add an event to the main loop. It will be executed later, after every other scheduled events.
void Post(Task task)
Add a task to the main loop. It will be executed later, after every other scheduled tasks.
static ScreenInteractive FitComponent()
static ScreenInteractive Fullscreen()
static ScreenInteractive FullscreenPrimaryScreen()
static ScreenInteractive * Active()
Return the currently active screen, or null if none.
CapturedMouse CaptureMouse()
Try to get the unique lock about behing able to capture the mouse.
std::string GetSelection()
Returns the content of the current selection.
static ScreenInteractive FullscreenAlternateScreen()
void TrackMouse(bool enable=true)
Set whether mouse is tracked and events reported. called outside of the main loop....
void SelectionChange(std::function< void()> callback)
void RequestAnimationFrame()
Add a task to draw the screen one more time, until all the animations are done.
Closure ExitLoopClosure()
Return a function to exit the main loop.
void ForceHandleCtrlC(bool force)
Force FTXUI to handle or not handle Ctrl-C, even if the component catches the Event::CtrlC.
~ScreenInteractive() override
void ForceHandleCtrlZ(bool force)
Force FTXUI to handle or not handle Ctrl-Z, even if the component catches the Event::CtrlZ.
Closure WithRestoredIO(Closure)
Decorate a function. It executes the same way, but with the currently active screen terminal hooks te...
Loop is a class that manages the event loop for a component.
ScreenInteractive is a Screen that can handle events, run a main loop, and manage components.
Represent an event. It can be key press event, a terminal resize, or more ...
A rectangular grid of Pixel.
The FTXUI ftxui::Dimension:: namespace.
std::chrono::time_point< Clock > TimePoint
The FTXUI ftxui:: namespace.
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::variant< Event, Closure, AnimationTask > Task
std::function< void()> Closure
std::shared_ptr< ComponentBase > Component