4#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
5#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
24using Component = std::shared_ptr<ComponentBase>;
25class ScreenInteractivePrivate;
95 void RunOnceBlocking(
Component component);
98 bool HandleSelection(
bool handled,
Event event);
99 void RefreshSelection();
101 void ResetCursorPosition();
103 void Signal(
int signal);
105 void FetchTerminalEvents();
107 void PostAnimationTask();
110 enum class Dimension {
119 bool use_alternative_screen);
120 const Dimension dimension_;
121 const bool use_alternative_screen_;
123 bool track_mouse_ =
true;
125 std::string set_cursor_position;
126 std::string reset_cursor_position;
128 std::atomic<bool> quit_{
false};
129 bool animation_requested_ =
false;
135 std::uint64_t frame_count_ = 0;
136 bool mouse_captured =
false;
137 bool previous_frame_resized_ =
false;
139 bool frame_valid_ =
false;
141 bool force_handle_ctrl_c_ =
true;
142 bool force_handle_ctrl_z_ =
true;
145 int cursor_reset_shape_ = 1;
149 struct SelectionData {
155 bool operator==(
const SelectionData& other)
const;
156 bool operator!=(
const SelectionData& other)
const;
158 SelectionData selection_data_;
159 SelectionData selection_data_previous_;
160 std::unique_ptr<Selection> selection_;
161 std::function<void()> selection_on_change_;
165 std::unique_ptr<Internal> internal_;
static void Signal(ScreenInteractive &s, int signal)
static ScreenInteractive TerminalOutput()
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.
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.
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