4#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
5#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
27using Component = std::shared_ptr<ComponentBase>;
28class ScreenInteractivePrivate;
91 void RunOnceBlocking(
Component component);
94 bool HandleSelection(
bool handled,
Event event);
95 void RefreshSelection();
97 void ResetCursorPosition();
99 void Signal(
int signal);
102 enum class Dimension {
108 Dimension dimension_ = Dimension::Fixed;
109 bool use_alternative_screen_ =
false;
113 bool use_alternative_screen);
115 bool track_mouse_ =
true;
120 std::string set_cursor_position;
121 std::string reset_cursor_position;
123 std::atomic<bool> quit_{
false};
124 std::thread event_listener_;
125 std::thread animation_listener_;
126 bool animation_requested_ =
false;
132 bool mouse_captured =
false;
133 bool previous_frame_resized_ =
false;
135 bool frame_valid_ =
false;
137 bool force_handle_ctrl_c_ =
true;
138 bool force_handle_ctrl_z_ =
true;
141 int cursor_reset_shape_ = 1;
145 struct SelectionData {
151 bool operator==(
const SelectionData& other)
const;
152 bool operator!=(
const SelectionData& other)
const;
154 SelectionData selection_data_;
155 SelectionData selection_data_previous_;
156 std::unique_ptr<Selection> selection_;
157 std::function<void()> selection_on_change_;
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::unique_ptr< ReceiverImpl< T > > Receiver
std::unique_ptr< SenderImpl< T > > Sender
std::variant< Event, Closure, AnimationTask > Task
std::function< void()> Closure
std::shared_ptr< ComponentBase > Component