3#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
4#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
23using Component = std::shared_ptr<ComponentBase>;
24class ScreenInteractivePrivate;
90 bool HandleSelection(
bool handled,
Event event);
91 void RefreshSelection();
93 void ResetCursorPosition();
95 void InstallPipedInputHandling();
97 void Signal(
int signal);
99 void FetchTerminalEvents();
101 void PostAnimationTask();
113 bool use_alternative_screen);
116 const bool use_alternative_screen_;
118 bool track_mouse_ =
true;
120 std::string set_cursor_position;
121 std::string reset_cursor_position;
123 std::atomic<bool> quit_{
false};
124 bool animation_requested_ =
false;
130 std::uint64_t frame_count_ = 0;
131 bool mouse_captured =
false;
132 bool previous_frame_resized_ =
false;
134 bool frame_valid_ =
false;
136 bool force_handle_ctrl_c_ =
true;
137 bool force_handle_ctrl_z_ =
true;
140 bool handle_piped_input_ =
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 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.
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.
~ScreenInteractive() override
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...
ScreenInteractive 是一個可以處理事件、執行主迴圈並管理組件的 Screen。
代表一個事件。它可以是按鍵事件、終端機大小調整,或更多...
FTXUI 的 ftxui::Dimension:: 命名空間
std::chrono::time_point< Clock > TimePoint
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::variant< Event, Closure, AnimationTask > Task
std::function< void()> Closure
std::shared_ptr< ComponentBase > Component