4#ifndef FTXUI_COMPONENT_APP_HPP
5#define FTXUI_COMPONENT_APP_HPP
96 friend class ThrottledRequest;
98 void RunOnceBlocking(
Component component);
101 bool HandleSelection(
bool handled,
Event event);
102 void RefreshSelection();
104 std::string ResetCursorPosition();
106 void RequestCursorPosition(
bool force =
false);
107 void RequestCursorShape();
109 void TerminalSend(std::string_view);
110 void TerminalFlush();
112 void InstallPipedInputHandling();
114 void Signal(
int signal);
116 size_t FetchTerminalEvents();
118 void PostAnimationTask();
120 App* suspended_screen_ =
nullptr;
130 const bool use_alternative_screen_;
132 bool track_mouse_ =
true;
134 std::string set_cursor_position_;
135 std::string reset_cursor_position_;
137 std::atomic<bool> quit_{
false};
138 bool installed_ =
false;
139 bool animation_requested_ =
false;
145 std::uint64_t frame_count_ = 0;
146 bool mouse_captured =
false;
147 bool previous_frame_resized_ =
false;
149 bool frame_valid_ =
false;
151 bool force_handle_ctrl_c_ =
true;
152 bool force_handle_ctrl_z_ =
true;
155 bool handle_piped_input_ =
true;
156 bool is_a_tty_ =
false;
161 int cursor_reset_shape_ = 1;
165 struct SelectionData {
171 bool operator==(
const SelectionData& other)
const;
172 bool operator!=(
const SelectionData& other)
const;
174 SelectionData selection_data_;
175 SelectionData selection_data_previous_;
176 std::unique_ptr<Selection> selection_;
177 std::function<void()> selection_on_change_;
181 std::unique_ptr<Internal> internal_;
190 static void Signal(
App& s,
int signal) { s.Signal(signal); }
static void Signal(App &s, int signal)
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.
void PostEvent(Event event)
Add an event to the main loop. It will be executed later, after every other scheduled events.
static App FitComponent()
static App * Active()
Return the currently active screen, or null if none.
void Post(Task task)
Add a task to the main loop. It will be executed later, after every other scheduled tasks.
static App FullscreenPrimaryScreen()
static App TerminalOutput()
static App FullscreenAlternateScreen()
CapturedMouse CaptureMouse()
Try to get the unique lock about behing able to capture the mouse.
static App FixedSize(int dimx, int dimy)
std::string GetSelection()
Returns the content of the current selection.
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...
App is a Screen that can handle events, run a main loop, and manage components.
Loop is a class that manages the event loop for a component.
Represent an event. It can be key press event, a terminal resize, or more ...
A rectangular grid of Cell.
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