3#ifndef FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
4#define FTXUI_COMPONENT_SCREEN_INTERACTIVE_HPP
23using Component = std::shared_ptr<ComponentBase>;
24class ScreenInteractivePrivate;
87 void RunOnceBlocking(
Component component);
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)
启用或禁用自动管道输入处理。 启用后,FTXUI 将检测管道输入并将 stdin 从 /dev/tty 重定向 以进行键盘输入,从而允许应用程序读取管道数据,同时仍 接收交互式键盘事件。
static ScreenInteractive FixedSize(int dimx, int dimy)
void PostEvent(Event event)
向主循环添加一个事件。 它将在所有其他计划事件之后执行。
void Post(Task task)
向主循环添加一个任务。 它将在所有其他计划任务之后执行。
static ScreenInteractive FitComponent()
创建一个 ScreenInteractive,其宽度和高度与正在绘制的组件匹配。
static ScreenInteractive Fullscreen()
static ScreenInteractive FullscreenPrimaryScreen()
static ScreenInteractive * Active()
返回当前活动屏幕,如果没有则返回空。
CapturedMouse CaptureMouse()
尝试获取能够捕获鼠标的唯一锁。
std::string GetSelection()
返回当前选择的内容
static ScreenInteractive FullscreenAlternateScreen()
void TrackMouse(bool enable=true)
设置是否跟踪鼠标并报告事件。 在主循环之外调用。例如 ScreenInteractive::Loop(...)。
void SelectionChange(std::function< void()> callback)
void RequestAnimationFrame()
添加一个任务以再次绘制屏幕,直到所有动画完成。
Closure ExitLoopClosure()
返回一个退出主循环的函数。
void ForceHandleCtrlC(bool force)
强制 FTXUI 处理或不处理 Ctrl-C,即使组件 捕获了 Event::CtrlC。
~ScreenInteractive() override
void ForceHandleCtrlZ(bool force)
强制 FTXUI 处理或不处理 Ctrl-Z,即使组件 捕获了 Event::CtrlZ。
Closure WithRestoredIO(Closure)
装饰一个函数。它以相同的方式执行,但在执行期间, 当前活动屏幕终端的钩子会被暂时卸载。
ScreenInteractive 是一个可以处理事件、运行主循环和管理组件的 Screen。
代表一个事件。它可以是按键事件、终端大小调整等等...
FTXUI ftxui::Dimension:: 命名空间
std::chrono::time_point< Clock > TimePoint
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase
std::unique_ptr< CapturedMouseInterface > CapturedMouse
std::variant< Event, Closure, AnimationTask > Task
std::function< void()> Closure
std::shared_ptr< ComponentBase > Component