4#ifndef FTXUI_COMPONENT_APP_HPP
5#define FTXUI_COMPONENT_APP_HPP
104 friend class ThrottledRequest;
105 void RunOnce(
const Component& component);
106 void RunOnceBlocking(
Component component);
109 bool HandleSelection(
bool handled,
Event event);
110 void RefreshSelection();
112 std::string ResetCursorPosition();
114 void RequestCursorPosition(
bool force =
false);
116 void TerminalSend(std::string_view);
117 void TerminalFlush();
119 void InstallPipedInputHandling();
120 void InstallTerminalInfo();
122 void Signal(
int signal);
124 size_t FetchTerminalEvents();
126 void PostAnimationTask();
128 App* suspended_screen_ =
nullptr;
138 const bool use_alternative_screen_;
140 bool track_mouse_ =
true;
142 std::string set_cursor_position_;
143 std::string reset_cursor_position_;
145 std::atomic<bool> quit_{
false};
146 bool installed_ =
false;
147 bool animation_requested_ =
false;
153 std::uint64_t frame_count_ = 0;
154 bool mouse_captured =
false;
155 bool previous_frame_resized_ =
false;
157 bool frame_valid_ =
false;
159 bool force_handle_ctrl_c_ =
true;
160 bool force_handle_ctrl_z_ =
true;
163 bool handle_piped_input_ =
true;
164 bool is_stdin_a_tty_ =
false;
165 bool is_stdout_a_tty_ =
false;
169 std::string terminal_name_ =
"unknown";
170 int terminal_version_ = 0;
172 std::string terminal_emulator_name_ =
"unknown";
173 std::string terminal_emulator_version_ =
"unknown";
175 std::vector<int> terminal_capabilities_;
179 struct SelectionData {
185 bool operator==(
const SelectionData& other)
const;
186 bool operator!=(
const SelectionData& other)
const;
188 SelectionData selection_data_;
189 SelectionData selection_data_previous_;
190 std::unique_ptr<Selection> selection_;
191 std::function<void()> selection_on_change_;
195 std::unique_ptr<Internal> internal_;
204 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.
int TerminalVersion() const
Return the terminal version.
std::vector< std::string > TerminalCapabilityNames() const
Return the names of the terminal capabilities.
static App FullscreenPrimaryScreen()
const std::string & TerminalName() const
Return the terminal name.
static App TerminalOutput()
static App FullscreenAlternateScreen()
CapturedMouse CaptureMouse()
Try to get the unique lock about being able to capture the mouse.
const std::string & TerminalEmulatorVersion() const
Return the terminal emulator version.
static App FixedSize(int dimx, int dimy)
std::string GetSelection()
Returns the content of the current selection.
const std::vector< int > & TerminalCapabilities() const
Return the terminal capabilities.
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)
const std::string & TerminalEmulatorName() const
Return the terminal emulator name.
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