Vcpkg 包
FTXUI 在 Vcpkg 注册表 中可用。
要使用它,您可以将以下内容添加到您的 vcpkg.json
中:
{
"name": "your-project",
"version-string": "0.1.0",
"dependencies": [
{
"name": "ftxui",
"version>=": "6.1.9"
}
]
}
使用 Vcpkg 安装 FTXUI
vcpkg install --triplet x64-linux # 或 x64-windows / arm64-osx 等。
配置您的构建系统。
如果您正在使用 CMake,您可以在 CMakeLists.txt
中使用以下内容:
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(my_project)
# 确保在配置时传递 vcpkg 工具链文件
find_package(ftxui CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main
PRIVATE ftxui::screen
PRIVATE ftxui::dom
PRIVATE ftxui::component
)
main.cpp
auto screen = ScreenInteractive::TerminalOutput();
auto button = Button("Click me", [] { std::cout << "Clicked!\n"; });
screen.Loop(button);
}
The FTXUI ftxui:: namespace.
配置并构建项目
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build
./build/main