4#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
5#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
27using Component = std::shared_ptr<ComponentBase>;
91 void RefreshSelection();
93 void ResetCursorPosition();
98 enum class Dimension {
104 Dimension dimension_ = Dimension::Fixed;
105 bool use_alternative_screen_ =
false;
111 bool track_mouse_ =
true;
116 std::string set_cursor_position;
117 std::string reset_cursor_position;
119 std::atomic<bool> quit_{
false};
120 std::thread event_listener_;
121 std::thread animation_listener_;
122 bool animation_requested_ =
false;
128 bool mouse_captured =
false;
129 bool previous_frame_resized_ =
false;
131 bool frame_valid_ =
false;
133 bool force_handle_ctrl_c_ =
true;
134 bool force_handle_ctrl_z_ =
true;
137 int cursor_reset_shape_ = 1;
141 struct SelectionData {
147 bool operator==(
const SelectionData&
other)
const;
148 bool operator!=(
const SelectionData&
other)
const;
150 SelectionData selection_data_;
151 SelectionData selection_data_previous_;
152 std::unique_ptr<Selection> selection_;
153 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...
A rectangular grid of Pixel.
std::chrono::time_point< Clock > TimePoint
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::shared_ptr< T > Make(Args &&... args)
std::shared_ptr< ComponentBase > Component
std::unique_ptr< ReceiverImpl< T > > Receiver
std::unique_ptr< SenderImpl< T > > Sender
std::variant< Event, Closure, AnimationTask > Task
std::function< void()> Closure
Represent an event. It can be key press event, a terminal resize, or more ...