mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-11-15 11:38:56 +08:00
Compare commits
3 Commits
main
...
HarryPehko
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dad2eaaa28 | ||
|
|
5c3e3151a5 | ||
|
|
143b24c6a5 |
212
.github/copilot-instructions.md
vendored
212
.github/copilot-instructions.md
vendored
@@ -1,212 +0,0 @@
|
|||||||
# FTXUI - Functional Terminal (X) User Interface
|
|
||||||
|
|
||||||
FTXUI is a cross-platform C++ library for terminal-based user interfaces with a functional programming approach, inspired by React.
|
|
||||||
|
|
||||||
**ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the information here.**
|
|
||||||
|
|
||||||
## Working Effectively
|
|
||||||
|
|
||||||
### Build System Setup and Commands
|
|
||||||
- Bootstrap and build the repository:
|
|
||||||
```bash
|
|
||||||
# Basic build (library only) - fast
|
|
||||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
|
||||||
cmake --build build --parallel $(nproc)
|
|
||||||
# Build time: ~30 seconds. NEVER CANCEL. Set timeout to 120+ seconds.
|
|
||||||
|
|
||||||
# Build with examples
|
|
||||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DFTXUI_BUILD_EXAMPLES=ON
|
|
||||||
cmake --build build --parallel $(nproc)
|
|
||||||
# Build time: ~70 seconds. NEVER CANCEL. Set timeout to 180+ seconds.
|
|
||||||
|
|
||||||
# Build with examples and tests
|
|
||||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DFTXUI_BUILD_EXAMPLES=ON -DFTXUI_BUILD_TESTS=ON
|
|
||||||
cmake --build build --parallel $(nproc)
|
|
||||||
# Build time: ~113 seconds (includes GoogleTest download). NEVER CANCEL. Set timeout to 300+ seconds.
|
|
||||||
```
|
|
||||||
|
|
||||||
- Alternative build with Ninja (faster):
|
|
||||||
```bash
|
|
||||||
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DFTXUI_BUILD_EXAMPLES=ON
|
|
||||||
ninja -C build
|
|
||||||
# Build time: ~62 seconds. NEVER CANCEL. Set timeout to 180+ seconds.
|
|
||||||
```
|
|
||||||
|
|
||||||
- Run unit tests:
|
|
||||||
```bash
|
|
||||||
# Configure with tests enabled first, then:
|
|
||||||
cd build && ctest --output-on-failure
|
|
||||||
# Test time: ~4 seconds (302 tests). NEVER CANCEL. Set timeout to 60+ seconds.
|
|
||||||
```
|
|
||||||
|
|
||||||
### Bazel Support
|
|
||||||
- FTXUI also supports Bazel build system
|
|
||||||
- **WARNING**: Bazel may fail due to network connectivity issues in sandboxed environments
|
|
||||||
- If Bazel is available:
|
|
||||||
```bash
|
|
||||||
bazel build //... # Build everything
|
|
||||||
bazel test //... # Run tests
|
|
||||||
```
|
|
||||||
|
|
||||||
## Validation
|
|
||||||
|
|
||||||
### Manual Testing After Changes
|
|
||||||
- **ALWAYS manually validate changes by building and running examples after making code modifications**
|
|
||||||
- Run example applications to verify functionality:
|
|
||||||
```bash
|
|
||||||
# Build an example first
|
|
||||||
cmake --build build --target ftxui_example_border
|
|
||||||
|
|
||||||
# Run examples (they are interactive, use timeout to terminate)
|
|
||||||
timeout 2s build/examples/dom/ftxui_example_border
|
|
||||||
timeout 2s build/examples/dom/ftxui_example_color_gallery
|
|
||||||
timeout 2s build/examples/component/ftxui_example_button
|
|
||||||
```
|
|
||||||
- Examples should produce visual terminal output with borders, colors, and UI components
|
|
||||||
- **CRITICAL**: Always run at least one DOM example and one Component example to verify both modules work
|
|
||||||
|
|
||||||
### Code Quality and Formatting
|
|
||||||
- Always run formatting before committing:
|
|
||||||
```bash
|
|
||||||
./tools/format.sh
|
|
||||||
# Format time: ~7 seconds. NEVER CANCEL. Set timeout to 60+ seconds.
|
|
||||||
```
|
|
||||||
- The format script adds license headers and runs clang-format on all source files
|
|
||||||
- **Required**: Run formatting or the CI (.github/workflows/build.yaml) will fail
|
|
||||||
|
|
||||||
### Build Validation Requirements
|
|
||||||
- ALWAYS build with both `-DFTXUI_BUILD_EXAMPLES=ON` and `-DFTXUI_BUILD_TESTS=ON` when making changes
|
|
||||||
- Run the complete test suite with `ctest --output-on-failure`
|
|
||||||
- All 302 tests must pass
|
|
||||||
- **Scenario Testing**: Run at least these validation scenarios:
|
|
||||||
1. Build library only (basic validation)
|
|
||||||
2. Build with examples and run 2-3 different examples
|
|
||||||
3. Build with tests and run complete test suite
|
|
||||||
4. Run formatting tool to ensure code style compliance
|
|
||||||
|
|
||||||
## Project Structure
|
|
||||||
|
|
||||||
### Key Directories
|
|
||||||
```
|
|
||||||
/home/runner/work/FTXUI/FTXUI/
|
|
||||||
├── include/ftxui/ # Public header files
|
|
||||||
│ ├── component/ # Interactive component headers
|
|
||||||
│ ├── dom/ # DOM element headers
|
|
||||||
│ ├── screen/ # Screen and rendering headers
|
|
||||||
│ └── util/ # Utility headers
|
|
||||||
├── src/ftxui/ # Implementation files
|
|
||||||
│ ├── component/ # Interactive components (buttons, menus, etc.)
|
|
||||||
│ ├── dom/ # DOM elements (layout, styling, text)
|
|
||||||
│ ├── screen/ # Screen rendering and terminal handling
|
|
||||||
│ └── util/ # Utilities
|
|
||||||
├── examples/ # Example applications
|
|
||||||
│ ├── component/ # Interactive component examples
|
|
||||||
│ └── dom/ # DOM element examples
|
|
||||||
├── cmake/ # CMake configuration files
|
|
||||||
├── tools/ # Development tools (formatting, etc.)
|
|
||||||
└── .github/workflows/ # CI/CD configuration
|
|
||||||
```
|
|
||||||
|
|
||||||
### Core Library Modules
|
|
||||||
FTXUI is organized into three main modules that depend on each other:
|
|
||||||
```
|
|
||||||
┌component──┐ (Interactive UI components)
|
|
||||||
│┌dom──────┐│ (Layout and styling elements)
|
|
||||||
││┌screen─┐││ (Terminal rendering and input)
|
|
||||||
└┴┴───────┴┴┘
|
|
||||||
```
|
|
||||||
|
|
||||||
1. **screen**: Low-level terminal handling, colors, pixels, input
|
|
||||||
2. **dom**: Layout elements (hbox, vbox, text, borders, etc.)
|
|
||||||
3. **component**: Interactive components (buttons, menus, input fields)
|
|
||||||
|
|
||||||
### CMake Build Options
|
|
||||||
| Option | Description | Default |
|
|
||||||
|-----------------------------------|----------------------------------|---------|
|
|
||||||
| FTXUI_BUILD_EXAMPLES | Build example applications | OFF |
|
|
||||||
| FTXUI_BUILD_DOCS | Build documentation | OFF |
|
|
||||||
| FTXUI_BUILD_TESTS | Build and enable tests | OFF |
|
|
||||||
| FTXUI_BUILD_MODULES | Build C++20 modules | OFF |
|
|
||||||
| FTXUI_ENABLE_INSTALL | Generate install targets | ON |
|
|
||||||
| FTXUI_MICROSOFT_TERMINAL_FALLBACK | Windows terminal compatibility | ON/OFF |
|
|
||||||
|
|
||||||
## Common Tasks
|
|
||||||
|
|
||||||
### Building Examples
|
|
||||||
```bash
|
|
||||||
# Build specific examples
|
|
||||||
cmake --build build --target ftxui_example_border
|
|
||||||
cmake --build build --target ftxui_example_button
|
|
||||||
cmake --build build --target ftxui_example_menu
|
|
||||||
|
|
||||||
# List all available examples
|
|
||||||
find build -name "ftxui_example_*" -type f
|
|
||||||
```
|
|
||||||
|
|
||||||
### Running Tests
|
|
||||||
```bash
|
|
||||||
# Run all tests
|
|
||||||
cd build && ctest
|
|
||||||
|
|
||||||
# Run tests with verbose output
|
|
||||||
cd build && ctest --verbose
|
|
||||||
|
|
||||||
# Run specific test pattern
|
|
||||||
cd build && ctest -R "Button" --verbose
|
|
||||||
```
|
|
||||||
|
|
||||||
### Working with Source Code
|
|
||||||
- **Component Development**: Modify files in `src/ftxui/component/` for interactive elements
|
|
||||||
- **DOM Development**: Modify files in `src/ftxui/dom/` for layout and styling
|
|
||||||
- **Screen Development**: Modify files in `src/ftxui/screen/` for terminal rendering
|
|
||||||
- **Adding Examples**: Add new `.cpp` files in `examples/component/` or `examples/dom/`
|
|
||||||
- **Header Files**: Public APIs are in `include/ftxui/[module]/`
|
|
||||||
|
|
||||||
### Integration Patterns
|
|
||||||
When adding FTXUI to a project, use CMake FetchContent (recommended):
|
|
||||||
```cmake
|
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(ftxui
|
|
||||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
|
||||||
GIT_TAG v6.1.9
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(ftxui)
|
|
||||||
|
|
||||||
target_link_libraries(your_target PRIVATE
|
|
||||||
ftxui::component # For interactive components
|
|
||||||
ftxui::dom # For layout elements
|
|
||||||
ftxui::screen # For basic rendering
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Build Issues
|
|
||||||
- If CMake configuration fails, ensure C++20 support: `cmake --version` (need 3.12+)
|
|
||||||
- If Ninja build fails, fall back to Make: `cmake -S . -B build` (without `-G Ninja`)
|
|
||||||
- If tests fail to build, GoogleTest download might have failed - check network connectivity
|
|
||||||
- Build artifacts are in `build/` directory - delete with `rm -rf build` to clean
|
|
||||||
|
|
||||||
### Example Issues
|
|
||||||
- Examples are interactive terminal applications - use `timeout` to terminate them
|
|
||||||
- If examples don't display correctly, terminal might not support colors/Unicode
|
|
||||||
- Examples require terminal size of at least 80x24 for proper display
|
|
||||||
|
|
||||||
### Formatting Issues
|
|
||||||
- Format script requires clang-format to be installed
|
|
||||||
- If format script fails, check that source files are not read-only
|
|
||||||
- Format script modifies files in-place - commit changes afterwards
|
|
||||||
|
|
||||||
## Critical Reminders
|
|
||||||
|
|
||||||
- **NEVER CANCEL long-running builds** - they may take 2-3 minutes
|
|
||||||
- **ALWAYS run the formatting tool** before committing changes
|
|
||||||
- **ALWAYS build and test examples** when making component/dom changes
|
|
||||||
- **SET APPROPRIATE TIMEOUTS**: 300+ seconds for builds, 60+ seconds for tests
|
|
||||||
- **BUILD TIMING EXPECTATIONS**:
|
|
||||||
- Basic library: ~30 seconds
|
|
||||||
- With examples: ~70 seconds
|
|
||||||
- With examples + tests: ~113 seconds (first time, includes GoogleTest download)
|
|
||||||
- Subsequent builds: ~60-70 seconds
|
|
||||||
- Tests execution: ~4 seconds
|
|
||||||
- Formatting: ~7 seconds
|
|
||||||
16
.github/workflows/documentation.yaml
vendored
16
.github/workflows/documentation.yaml
vendored
@@ -12,10 +12,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: "Checkout repository"
|
- name: "Checkout repository"
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
|
||||||
fetch-depth: 0 # Need full history.
|
|
||||||
fetch-tags: true # Need tags.
|
|
||||||
|
|
||||||
|
|
||||||
- name: "Install cmake"
|
- name: "Install cmake"
|
||||||
uses: lukka/get-cmake@latest
|
uses: lukka/get-cmake@latest
|
||||||
@@ -34,12 +30,7 @@ jobs:
|
|||||||
sudo apt-get install graphviz;
|
sudo apt-get install graphviz;
|
||||||
|
|
||||||
- name: "Build documentation"
|
- name: "Build documentation"
|
||||||
run: |
|
|
||||||
python3 ./tools/build_multiversion_doc.py
|
|
||||||
|
|
||||||
- name: "Build examples"
|
|
||||||
run: >
|
run: >
|
||||||
mkdir -p multiversion_docs/main/examples;
|
|
||||||
mkdir build;
|
mkdir build;
|
||||||
cd build;
|
cd build;
|
||||||
emcmake cmake ..
|
emcmake cmake ..
|
||||||
@@ -50,7 +41,8 @@ jobs:
|
|||||||
-DFTXUI_BUILD_TESTS_FUZZER=OFF
|
-DFTXUI_BUILD_TESTS_FUZZER=OFF
|
||||||
-DFTXUI_ENABLE_INSTALL=OFF
|
-DFTXUI_ENABLE_INSTALL=OFF
|
||||||
-DFTXUI_DEV_WARNINGS=OFF;
|
-DFTXUI_DEV_WARNINGS=OFF;
|
||||||
cmake --build .;
|
cmake --build . --target doc;
|
||||||
|
cmake --build . ;
|
||||||
rsync -amv
|
rsync -amv
|
||||||
--include='*/'
|
--include='*/'
|
||||||
--include='*.html'
|
--include='*.html'
|
||||||
@@ -60,13 +52,13 @@ jobs:
|
|||||||
--include='*.wasm'
|
--include='*.wasm'
|
||||||
--exclude='*'
|
--exclude='*'
|
||||||
examples
|
examples
|
||||||
../multiversion_docs/
|
doc/doxygen/html;
|
||||||
|
|
||||||
- name: "Deploy"
|
- name: "Deploy"
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: multiversion_docs
|
publish_dir: build/doc/doxygen/html/
|
||||||
enable_jekyll: false
|
enable_jekyll: false
|
||||||
allow_empty_commit: false
|
allow_empty_commit: false
|
||||||
force_orphan: true
|
force_orphan: true
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -28,7 +28,6 @@ out/
|
|||||||
# .github directory:
|
# .github directory:
|
||||||
!.github/**/*.yaml
|
!.github/**/*.yaml
|
||||||
!.github/**/*.yml
|
!.github/**/*.yml
|
||||||
!.github/**/*.md
|
|
||||||
|
|
||||||
# cmake directory:
|
# cmake directory:
|
||||||
!cmake/**/*.in
|
!cmake/**/*.in
|
||||||
@@ -71,6 +70,4 @@ out/
|
|||||||
|
|
||||||
# tools directory:
|
# tools directory:
|
||||||
!tools/**/*.sh
|
!tools/**/*.sh
|
||||||
!tools/**/*.py
|
|
||||||
!tools/**/*.cpp
|
!tools/**/*.cpp
|
||||||
build/
|
|
||||||
|
|||||||
@@ -169,15 +169,13 @@ ftxui_cc_library(
|
|||||||
"src/ftxui/component/util.cpp",
|
"src/ftxui/component/util.cpp",
|
||||||
"src/ftxui/component/window.cpp",
|
"src/ftxui/component/window.cpp",
|
||||||
|
|
||||||
|
|
||||||
# Private header from ftxui:dom.
|
# Private header from ftxui:dom.
|
||||||
"src/ftxui/dom/node_decorator.hpp",
|
"src/ftxui/dom/node_decorator.hpp",
|
||||||
|
|
||||||
# Private header from ftxui:screen.
|
# Private header from ftxui:screen.
|
||||||
"src/ftxui/screen/string_internal.hpp",
|
"src/ftxui/screen/string_internal.hpp",
|
||||||
"src/ftxui/screen/util.hpp",
|
"src/ftxui/screen/util.hpp",
|
||||||
|
|
||||||
# Private header.
|
|
||||||
"include/ftxui/util/warn_windows_macro.hpp",
|
|
||||||
],
|
],
|
||||||
hdrs = [
|
hdrs = [
|
||||||
"include/ftxui/component/animation.hpp",
|
"include/ftxui/component/animation.hpp",
|
||||||
|
|||||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -27,22 +27,9 @@ Next
|
|||||||
- Remove dependency on 'pthread'.
|
- Remove dependency on 'pthread'.
|
||||||
|
|
||||||
### Component
|
### Component
|
||||||
- Feature: POSIX Piped Input Handling.
|
|
||||||
- Allows FTXUI applications to read data from stdin (when piped) while still receiving keyboard input from the terminal.
|
|
||||||
- Enabled by default.
|
|
||||||
- Can be disabled using `ScreenInteractive::HandlePipedInput(false)`.
|
|
||||||
- Only available on Linux and macOS.
|
|
||||||
Thanks @HarryPehkonen for PR #1094.
|
|
||||||
- Fix ScreenInteractive::FixedSize screen stomps on the preceding terminal
|
- Fix ScreenInteractive::FixedSize screen stomps on the preceding terminal
|
||||||
output. Thanks @zozowell in #1064.
|
output. Thanks @zozowell in #1064.
|
||||||
- Fix vertical `ftxui::Slider`. The "up" key was previously decreasing the
|
|
||||||
value. Thanks @its-pablo in #1093 for reporting the issue.
|
|
||||||
|
|
||||||
### Dom
|
|
||||||
- Fix integer overflow in `ComputeShrinkHard`. Thanks @its-pablo in #1137 for
|
|
||||||
reporting and fixing the issue.
|
|
||||||
- Add specialization for `vbox/hbox/dbox` to allow a container of Element as
|
|
||||||
as input. Thanks @nbusser in #1117.
|
|
||||||
|
|
||||||
6.1.9 (2025-05-07)
|
6.1.9 (2025-05-07)
|
||||||
------------
|
------------
|
||||||
|
|||||||
@@ -178,8 +178,8 @@ include(cmake/ftxui_install.cmake)
|
|||||||
include(cmake/ftxui_package.cmake)
|
include(cmake/ftxui_package.cmake)
|
||||||
include(cmake/ftxui_modules.cmake)
|
include(cmake/ftxui_modules.cmake)
|
||||||
|
|
||||||
add_subdirectory(examples)
|
|
||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
|
add_subdirectory(examples)
|
||||||
|
|
||||||
# You can generate ./examples_modules/ by running
|
# You can generate ./examples_modules/ by running
|
||||||
# ./tools/generate_examples_modules.sh
|
# ./tools/generate_examples_modules.sh
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://github.com/ArthurSonzogni/FTXUI/assets/4759106/6925b6da-0a7e-49d9-883c-c890e1f36007" alt="Demo image"></img>
|
<img src="https://github.com/ArthurSonzogni/FTXUI/assets/4759106/6925b6da-0a7e-49d9-883c-c890e1f36007" alt="Demo image"></img>
|
||||||
<br/>
|
<br/>
|
||||||
@@ -363,9 +362,6 @@ Feel free to add your projects here:
|
|||||||
- [FTB - tertminal file browser](https://github.com/Cyxuan0311/FTB)
|
- [FTB - tertminal file browser](https://github.com/Cyxuan0311/FTB)
|
||||||
- [openJuice](https://github.com/mikomikotaishi/openJuice)
|
- [openJuice](https://github.com/mikomikotaishi/openJuice)
|
||||||
- [SHOOT!](https://github.com/ShingZhanho/ENGG1340-Project-25Spring)
|
- [SHOOT!](https://github.com/ShingZhanho/ENGG1340-Project-25Spring)
|
||||||
- [VerifySN (Fast Hash Tool)](https://github.com/d06i/verifySN)
|
|
||||||
- [tic-tac-toe](https://github.com/birland/tic-tac-toe)
|
|
||||||
- [typing-speed-test](https://github.com/ymcx/typing-speed-test)
|
|
||||||
|
|
||||||
### [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam)
|
### [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam)
|
||||||
|
|
||||||
@@ -419,9 +415,9 @@ cc_binary(
|
|||||||
name = "your_target",
|
name = "your_target",
|
||||||
srcs = ["your_source.cc"],
|
srcs = ["your_source.cc"],
|
||||||
deps = [
|
deps = [
|
||||||
"@ftxui//:component",
|
"@ftxui//:ftxui_component",
|
||||||
"@ftxui//:dom",
|
"@ftxui//:ftxui_dom",
|
||||||
"@ftxui//:screen",
|
"@ftxui//:ftxui_screen",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ include(FetchContent)
|
|||||||
|
|
||||||
FetchContent_Declare(googletest
|
FetchContent_Declare(googletest
|
||||||
GIT_REPOSITORY "https://github.com/google/googletest"
|
GIT_REPOSITORY "https://github.com/google/googletest"
|
||||||
GIT_TAG 52eb8108c5bdec04579160ae17225d66034bd723 # v1.17.0
|
GIT_TAG 23ef29555ef4789f555f1ba8c51b4c52975f0907
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ include(CMakePackageConfigHelpers)
|
|||||||
install(
|
install(
|
||||||
TARGETS screen dom component
|
TARGETS screen dom component
|
||||||
EXPORT ftxui-targets
|
EXPORT ftxui-targets
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
> This feature is still in development, and the API may change in future releases.
|
> This feature is still in development, and the API may change in future releases.
|
||||||
> Your contribution is needed to help us improve the compatibility and usability
|
> Your contribution is needed to help us improve the compatibility and usability
|
||||||
> of C++ modules in FTXUI. If you encounter any issues or have suggestions,
|
> of C++20 modules in FTXUI. If you encounter any issues or have suggestions,
|
||||||
> please open an issue.
|
> please open an issue.
|
||||||
|
|
||||||
FTXUI experimentally supports
|
FTXUI experimentally supports
|
||||||
[C++20 modules](https://en.cppreference.com/w/cpp/language/modules) to reduce
|
[C++20 modules](https://en.cppreference.com/w/cpp/language/modules) to reduce
|
||||||
compilation times and improve code organization. Each part of the library has a
|
compilation times and improve code organization. Each header has a
|
||||||
corresponding module, split into partitions per each header.
|
corresponding module.
|
||||||
|
|
||||||
Use the FTXUI_BUILD_MODULES option to build the FTXUI project itself to provide C++20 modules,
|
Use the FTXUI_BUILD_MODULES option to build the FTXUI project itself to provide C++ 20 modules,
|
||||||
for example with CMake and Ninja:
|
for example with CMake and Ninja:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -25,7 +25,7 @@ ninja
|
|||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> To use modules, you need a C++≥20 compatible compiler, CMake version 3.20 or
|
> To use modules, you need a C++20 compatible compiler, CMake version 3.20 or
|
||||||
> higher, and use a compatible generator like Ninja. Note that Makefile
|
> higher, and use a compatible generator like Ninja. Note that Makefile
|
||||||
> generators **do not support modules**.
|
> generators **do not support modules**.
|
||||||
|
|
||||||
@@ -34,12 +34,9 @@ Then, in your own code you can consume the modules and code as normal:
|
|||||||
```cpp
|
```cpp
|
||||||
import ftxui;
|
import ftxui;
|
||||||
|
|
||||||
using ftxui::Button;
|
|
||||||
using ftxui::ScreenInteractive;
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ftxui::ScreenInteractive::TerminalOutput();
|
||||||
auto button = Button("Click me", screen.QuitClosure());
|
auto button = ftxui::Button("Click me", screen.QuitClosure());
|
||||||
screen.Loop(button);
|
screen.Loop(button);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -73,6 +70,38 @@ are available:
|
|||||||
|
|
||||||
- `ftxui`
|
- `ftxui`
|
||||||
- `ftxui.component`
|
- `ftxui.component`
|
||||||
- `ftxui.dom`
|
- `ftxui.component.Animation`
|
||||||
- `ftxui.screen`
|
- `ftxui.component.CapturedMouse`
|
||||||
- `ftxui.util`
|
- `ftxui.component.Component`
|
||||||
|
- `ftxui.component.ComponentBase`
|
||||||
|
- `ftxui.component.ComponentOptions`
|
||||||
|
- `ftxui.component.Event`
|
||||||
|
- `ftxui.component.Loop`
|
||||||
|
- `ftxui.component.Mouse`
|
||||||
|
- `ftxui.component.Receiver`
|
||||||
|
- `ftxui.component.ScreenInteractive`
|
||||||
|
- `ftxui.component.Task`
|
||||||
|
- `ftxui.dom`
|
||||||
|
- `ftxui.dom.Canvas`
|
||||||
|
- `ftxui.dom.Deprecated`
|
||||||
|
- `ftxui.dom.Direction`
|
||||||
|
- `ftxui.dom.Elements`
|
||||||
|
- `ftxui.dom.FlexboxConfig`
|
||||||
|
- `ftxui.dom.LinearGradient`
|
||||||
|
- `ftxui.dom.Node`
|
||||||
|
- `ftxui.dom.Requirement`
|
||||||
|
- `ftxui.dom.Selection`
|
||||||
|
- `ftxui.dom.Table`
|
||||||
|
- `ftxui.screen`
|
||||||
|
- `ftxui.screen.Box`
|
||||||
|
- `ftxui.screen.Color`
|
||||||
|
- `ftxui.screen.ColorInfo`
|
||||||
|
- `ftxui.screen.Deprecated`
|
||||||
|
- `ftxui.screen.Image`
|
||||||
|
- `ftxui.screen.Pixel`
|
||||||
|
- `ftxui.screen.Screen`
|
||||||
|
- `ftxui.screen.String`
|
||||||
|
- `ftxui.screen.Terminal`
|
||||||
|
- `ftxui.util`
|
||||||
|
- `ftxui.util.AutoReset`
|
||||||
|
- `ftxui.util.Ref`
|
||||||
|
|||||||
@@ -2,9 +2,16 @@
|
|||||||
<!-- start footer part -->
|
<!-- start footer part -->
|
||||||
<!--BEGIN GENERATE_TREEVIEW-->
|
<!--BEGIN GENERATE_TREEVIEW-->
|
||||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||||
|
<ul>
|
||||||
|
$navpath
|
||||||
|
<li class="footer">$generatedby <a href="https://www.doxygen.org/index.html"><img class="footer" src="$relpath^doxygen.svg" width="104" height="31" alt="doxygen"/></a> $doxygenversion </li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!--END GENERATE_TREEVIEW-->
|
<!--END GENERATE_TREEVIEW-->
|
||||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||||
|
<hr class="footer"/><address class="footer"><small>
|
||||||
|
$generatedby <a href="https://www.doxygen.org/index.html"><img class="footer" src="$relpath^doxygen.svg" width="104" height="31" alt="doxygen"/></a> $doxygenversion
|
||||||
|
</small></address>
|
||||||
<!--END !GENERATE_TREEVIEW-->
|
<!--END !GENERATE_TREEVIEW-->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,99 +1,19 @@
|
|||||||
@page installation_conan Conan
|
@page installation_conan Conan
|
||||||
@tableofcontents
|
|
||||||
|
|
||||||
FTXUI can be easily obtained and integrated into your project using the Conan package manager.
|
Unofficial recipe for FTXUI exists on Conan Center:
|
||||||
|
<https://conan.io/center/recipes/ftxui>
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
First, ensure that Conan is installed on your system. If not, you can install it via pip:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
pip install conan
|
|
||||||
```
|
|
||||||
Conan often works in tandem with CMake, so you will need to have CMake installed as well. Once you have confirmed both Conan and CMake are installed, create a project directory, for example, `ftxui-demo`:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
mkdir C:\ftxui-demo
|
|
||||||
cd C:\ftxui-demo
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
After ensuring your environment is set up correctly, create a Conan configuration file `conanfile.txt`. This file is used to declare your project's dependencies. The community-maintained package for FTXUI can be found on [Conan Center](https://conan.io/center/recipes/ftxui).
|
|
||||||
|
|
||||||
> [!note]
|
> [!note]
|
||||||
> This is an unofficial build script. This means it is not maintained by the FTXUI
|
> This is an unofficial recipe. That means it is not maintained by the FTXUI
|
||||||
> team but by the community. The package maintainer appears to actively update it
|
> team, but by the community. The package maintainers seems to actively update
|
||||||
> to the latest releases. Many thanks to the maintainer for their work!
|
> the package to the latest version. Thanks to the maintainers for their work!
|
||||||
|
|
||||||
@todo If you are familiar with the process, please consider adding an "official" build script to Conan Center.
|
|
||||||
This could be a GitHub Action that automatically updates Conan Center upon new releases.
|
|
||||||
|
|
||||||
```ini
|
@todo Add instructions on how to use the conan recipe.
|
||||||
[requires]
|
|
||||||
ftxui/6.0.2
|
|
||||||
|
|
||||||
[generators]
|
@todo Please consider adding an "official" recipe to Conan Center if know how.
|
||||||
CMakeDeps
|
It could be a github action that will automatically update the conan center
|
||||||
CMakeToolchain
|
when a new release is made.
|
||||||
|
|
||||||
[layout]
|
|
||||||
cmake_layout
|
|
||||||
```
|
|
||||||
|
|
||||||
## Install Dependencies and Build
|
|
||||||
|
|
||||||
Once configured, run the following command to install FTXUI and its dependencies:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
conan install . --output-folder=build --build=missing
|
|
||||||
```
|
|
||||||
|
|
||||||
This will download and install `ftxui/6.0.2` along with all its dependencies from Conan's remote repositories.
|
|
||||||
|
|
||||||
After the installation completes, you can test it by creating a `demo.cpp` file in your project directory:
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
#include <ftxui/screen/screen.hpp>
|
|
||||||
#include <ftxui/dom/elements.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
using namespace ftxui;
|
|
||||||
auto document = hbox({
|
|
||||||
text(" Hello "),
|
|
||||||
text("FTXUI ") | bold | color(Color::Red),
|
|
||||||
text(" world! ")
|
|
||||||
});
|
|
||||||
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
|
|
||||||
Render(screen, document);
|
|
||||||
std::cout << screen.ToString() << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
If the test is successful, you can then create a `CMakeLists.txt` file in the project directory:
|
|
||||||
|
|
||||||
```cmake
|
|
||||||
cmake_minimum_required(VERSION 3.20)
|
|
||||||
project(ftxui-demo)
|
|
||||||
|
|
||||||
# Set the C++ standard
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
|
||||||
|
|
||||||
# Find the FTXUI package installed via Conan
|
|
||||||
find_package(ftxui CONFIG REQUIRED)
|
|
||||||
|
|
||||||
# Create the executable
|
|
||||||
add_executable(demo demo.cpp)
|
|
||||||
|
|
||||||
# Link the executable to the FTXUI library
|
|
||||||
target_link_libraries(demo PRIVATE ftxui::component)
|
|
||||||
```
|
|
||||||
|
|
||||||
@todo 考虑到中国多数地区使用Conan很有可能遇到各种网络问题,我想做一个定制的版本说明,但是我对conan的了解有限再加上没有找到合适的资料,因此这个计划短暂的被搁置了,如果您知道方法,欢迎在[中文版本](xiaoditx.girhub.io/public/docs/ftxui%E4%B8%AD%E6%96%87%E7%BF%BB%E8%AF%91/installation/conan/)的下方留下评论以提醒我
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<div class="section_buttons">
|
<div class="section_buttons">
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,10 @@ add_subdirectory(dom)
|
|||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
|
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
|
||||||
foreach(file
|
foreach(file
|
||||||
"index.css"
|
|
||||||
"index.html"
|
"index.html"
|
||||||
"index.mjs"
|
"index.mjs"
|
||||||
"run_webassembly.py"
|
"index.css"
|
||||||
"sw.js"
|
"run_webassembly.py")
|
||||||
)
|
|
||||||
configure_file(${file} ${file})
|
configure_file(${file} ${file})
|
||||||
endforeach(file)
|
endforeach(file)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ example(radiobox)
|
|||||||
example(radiobox_in_frame)
|
example(radiobox_in_frame)
|
||||||
example(renderer)
|
example(renderer)
|
||||||
example(resizable_split)
|
example(resizable_split)
|
||||||
example(resizable_split_clamp)
|
|
||||||
example(scrollbar)
|
example(scrollbar)
|
||||||
example(selection)
|
example(selection)
|
||||||
example(slider)
|
example(slider)
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ int main() {
|
|||||||
int value = 50;
|
int value = 50;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto btn_dec_01 = Button("-1", [&] { value -= 1; }, Style());
|
auto btn_dec_01 = Button("-1", [&] { value += 1; }, Style());
|
||||||
auto btn_inc_01 = Button("+1", [&] { value += 1; }, Style());
|
auto btn_inc_01 = Button("+1", [&] { value -= 1; }, Style());
|
||||||
auto btn_dec_10 = Button("-10", [&] { value -= 10; }, Style());
|
auto btn_dec_10 = Button("-10", [&] { value -= 10; }, Style());
|
||||||
auto btn_inc_10 = Button("+10", [&] { value += 10; }, Style());
|
auto btn_inc_10 = Button("+10", [&] { value += 10; }, Style());
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
||||||
|
|
||||||
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
|
#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
@@ -13,24 +14,17 @@ using namespace ftxui;
|
|||||||
int main() {
|
int main() {
|
||||||
auto screen = ScreenInteractive::Fullscreen();
|
auto screen = ScreenInteractive::Fullscreen();
|
||||||
|
|
||||||
// State:
|
auto middle = Renderer([] { return text("middle") | center; });
|
||||||
|
auto left = Renderer([] { return text("Left") | center; });
|
||||||
|
auto right = Renderer([] { return text("right") | center; });
|
||||||
|
auto top = Renderer([] { return text("top") | center; });
|
||||||
|
auto bottom = Renderer([] { return text("bottom") | center; });
|
||||||
|
|
||||||
int left_size = 20;
|
int left_size = 20;
|
||||||
int right_size = 20;
|
int right_size = 20;
|
||||||
int top_size = 10;
|
int top_size = 10;
|
||||||
int bottom_size = 10;
|
int bottom_size = 10;
|
||||||
|
|
||||||
// Renderers:
|
|
||||||
auto RendererInfo = [](const std::string& name, int* size) {
|
|
||||||
return Renderer([name, size] {
|
|
||||||
return text(name + ": " + std::to_string(*size)) | center;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
auto middle = Renderer([] { return text("Middle") | center; });
|
|
||||||
auto left = RendererInfo("Left", &left_size);
|
|
||||||
auto right = RendererInfo("Right", &right_size);
|
|
||||||
auto top = RendererInfo("Top", &top_size);
|
|
||||||
auto bottom = RendererInfo("Bottom", &bottom_size);
|
|
||||||
|
|
||||||
auto container = middle;
|
auto container = middle;
|
||||||
container = ResizableSplitLeft(left, container, &left_size);
|
container = ResizableSplitLeft(left, container, &left_size);
|
||||||
container = ResizableSplitRight(right, container, &right_size);
|
container = ResizableSplitRight(right, container, &right_size);
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
// Copyright 2025 Arthur Sonzogni. All rights reserved.
|
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
|
||||||
// the LICENSE file.
|
|
||||||
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
|
||||||
|
|
||||||
#include "ftxui/component/component.hpp" // for Renderer, ResizableSplitBottom, ResizableSplitLeft, ResizableSplitRight, ResizableSplitTop
|
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
|
||||||
#include "ftxui/dom/elements.hpp" // for Element, operator|, text, center, border
|
|
||||||
|
|
||||||
using namespace ftxui;
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
auto screen = ScreenInteractive::Fullscreen();
|
|
||||||
|
|
||||||
// State:
|
|
||||||
int size = 40;
|
|
||||||
int size_min = 10;
|
|
||||||
int size_max = 80;
|
|
||||||
|
|
||||||
// Renderers:
|
|
||||||
auto split = ResizableSplit({
|
|
||||||
.main = Renderer([] { return text("Left") | center; }),
|
|
||||||
.back = Renderer([] { return text("Right") | center; }),
|
|
||||||
.direction = Direction::Left,
|
|
||||||
.main_size = &size,
|
|
||||||
.min = &size_min,
|
|
||||||
.max = &size_max,
|
|
||||||
});
|
|
||||||
|
|
||||||
auto renderer = Renderer(split, [&] {
|
|
||||||
return window(text("Drag the separator with the mouse"),
|
|
||||||
vbox({
|
|
||||||
text("Min: " + std::to_string(size_min)),
|
|
||||||
text("Max: " + std::to_string(size_max)),
|
|
||||||
text("Size: " + std::to_string(size)),
|
|
||||||
separator(),
|
|
||||||
split->Render() | flex,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
screen.Loop(renderer);
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,15 @@
|
|||||||
@import url(https://fonts.googleapis.com/css?family=Khula:700);
|
@import url(https://fonts.googleapis.com/css?family=Khula:700);
|
||||||
|
|
||||||
html {
|
|
||||||
--toc-width: 250px;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: #EEE;
|
background-color:#EEE;
|
||||||
padding: 0px;
|
padding:0px;
|
||||||
margin: 0px;
|
margin:0px;
|
||||||
font-family: Khula, Helvetica, sans-serif;
|
font-family: Khula, Helvetica, sans-serif;
|
||||||
font-size: 130%;
|
font-size: 130%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
max-width: 1300px;
|
max-width:1300px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
@@ -24,7 +20,7 @@ a {
|
|||||||
margin: 0 -.25rem;
|
margin: 0 -.25rem;
|
||||||
padding: 0 .25rem;
|
padding: 0 .25rem;
|
||||||
transition: color .3s ease-in-out,
|
transition: color .3s ease-in-out,
|
||||||
box-shadow .3s ease-in-out;
|
box-shadow .3s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
@@ -34,48 +30,45 @@ a:hover {
|
|||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
width: 100%;
|
width:100%;
|
||||||
background-color: rgba(100, 100, 255, 0.5);
|
background-color: rgba(100,100,255,0.5);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#selectExample {
|
#selectExample {
|
||||||
flex: 1;
|
flex:1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#selectExample,
|
#selectExample, #selectExample option {
|
||||||
#selectExample option {
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
border: 0px;
|
border:0px;
|
||||||
background-color: #bbb;
|
background-color: #bbb;
|
||||||
color: black;
|
color:black;
|
||||||
}
|
}
|
||||||
|
|
||||||
#selectExample:focus {
|
#selectExample:focus {
|
||||||
outline: none;
|
outline:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#terminal {
|
#terminal {
|
||||||
width: 100%;
|
width:100%;
|
||||||
height 500px;
|
height 500px;
|
||||||
height: calc(clamp(200px, 100vh - 300px, 900px));
|
height: calc(clamp(200px, 100vh - 300px, 900px));
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: none;
|
border:none;
|
||||||
padding: 10px;
|
background-color:black;
|
||||||
margin: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#terminalContainer {
|
#terminalContainer {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.75),
|
box-shadow: 0px 2px 10px 0px rgba(0,0,0,0.75),
|
||||||
0px 2px 80px 0px rgba(0, 0, 0, 0.50);
|
0px 2px 80px 0px rgba(0,0,0,0.50);
|
||||||
background-color: black;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fakeButtons {
|
.fakeButtons {
|
||||||
@@ -83,7 +76,7 @@ h1 {
|
|||||||
width: 10px;
|
width: 10px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
||||||
margin: 6px;
|
margin:6px;
|
||||||
background-color: #ff3b47;
|
background-color: #ff3b47;
|
||||||
border-color: #9d252b;
|
border-color: #9d252b;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@@ -102,79 +95,13 @@ h1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.fakeMenu {
|
.fakeMenu {
|
||||||
display: flex;
|
display:flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
width: 100%;
|
width:100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
background-color: #bbb;
|
background-color: #bbb;
|
||||||
color: black;
|
color:black;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toc-container {
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
width: var(--toc-width);
|
|
||||||
background: white;
|
|
||||||
padding: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
scrollbar-width: thin;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toc-title {
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
font-size: 0.9em;
|
|
||||||
color: #555;
|
|
||||||
|
|
||||||
position: sticky;
|
|
||||||
transition: position 1.0s ease-in-out;
|
|
||||||
top: 0;
|
|
||||||
z-index: 1;
|
|
||||||
padding: 20px;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
border-bottom: 1px solid #ddd;
|
|
||||||
|
|
||||||
/* Gradient background for the title */
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toc-item {
|
|
||||||
padding: 3px 8px;
|
|
||||||
margin: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.85em;
|
|
||||||
border-radius: 3px;
|
|
||||||
transition: background 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toc-item:hover {
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toc-item.selected {
|
|
||||||
background: #e0e0e0;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
.toc-container {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1025px) {
|
|
||||||
.page {
|
|
||||||
margin-left: calc(var(--toc-width) + 20px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,18 +9,13 @@
|
|||||||
<script type="module" src="index.mjs"></script>
|
<script type="module" src="index.mjs"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="toc-container">
|
|
||||||
<div class="toc-list"></div>
|
|
||||||
</div>
|
|
||||||
<script id="example_script"></script>
|
<script id="example_script"></script>
|
||||||
|
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<p>
|
<p>
|
||||||
<a href="https://github.com/ArthurSonzogni/FTXUI">FTXUI</a> is a simple
|
<a href="https://github.com/ArthurSonzogni/FTXUI">FTXUI</a> is a simple
|
||||||
functional C++ library for terminal user interface. <br/>
|
functional C++ library for terminal user interface. <br/>
|
||||||
This showcases the: <a
|
This showcases the: <a href="https://github.com/ArthurSonzogni/FTXUI/tree/master/examples">./example/</a> folder. <br/>
|
||||||
href="https://github.com/ArthurSonzogni/FTXUI/tree/master/examples">./example/</a>
|
|
||||||
folder. See <a id="source">source</a>.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="terminalContainer">
|
<div id="terminalContainer">
|
||||||
|
|||||||
@@ -92,69 +92,6 @@ window.Module = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const source = document.querySelector("#source");
|
|
||||||
source.href = "https://github.com/ArthurSonzogni/FTXUI/blob/main/examples/" + example + ".cpp";
|
|
||||||
|
|
||||||
const words = example.split('/')
|
const words = example.split('/')
|
||||||
words[1] = "ftxui_example_" + words[1] + ".js"
|
words[1] = "ftxui_example_" + words[1] + ".js"
|
||||||
document.querySelector("#example_script").src = words.join('/');
|
document.querySelector("#example_script").src = words.join('/');
|
||||||
|
|
||||||
|
|
||||||
// Table of Contents (TOC) for quick navigation.
|
|
||||||
|
|
||||||
// Get select element
|
|
||||||
const selectEl = document.querySelector('select#selectExample');
|
|
||||||
if (!selectEl) {
|
|
||||||
console.error('select#selectExample not found');
|
|
||||||
} else {
|
|
||||||
// Get TOC container
|
|
||||||
const tocContainer = document.querySelector('.toc-container');
|
|
||||||
const tocList = tocContainer.querySelector('.toc-list');
|
|
||||||
|
|
||||||
// Group options by directory
|
|
||||||
const groupedOptions = Array.from(selectEl.options).reduce((acc, option) => {
|
|
||||||
const [dir, file] = option.text.split('/');
|
|
||||||
if (!acc[dir]) {
|
|
||||||
acc[dir] = [];
|
|
||||||
}
|
|
||||||
acc[dir].push({ option, file });
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
// Generate TOC items
|
|
||||||
for (const dir in groupedOptions) {
|
|
||||||
const dirContainer = document.createElement('div');
|
|
||||||
|
|
||||||
const dirHeader = document.createElement('div');
|
|
||||||
dirHeader.textContent = dir;
|
|
||||||
dirHeader.className = 'toc-title';
|
|
||||||
dirContainer.appendChild(dirHeader);
|
|
||||||
|
|
||||||
groupedOptions[dir].forEach(({ option, file }) => {
|
|
||||||
const tocItem = document.createElement('div');
|
|
||||||
tocItem.textContent = file;
|
|
||||||
tocItem.className = 'toc-item';
|
|
||||||
|
|
||||||
if (selectEl.options[selectEl.selectedIndex].value === option.value) {
|
|
||||||
tocItem.classList.add('selected');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Click handler
|
|
||||||
tocItem.addEventListener('click', () => {
|
|
||||||
for(let i=0; i<selectEl.options.length; ++i) {
|
|
||||||
if (selectEl.options[i].value == option.value) {
|
|
||||||
selectEl.selectedIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
history.pushState({}, "", "?file=" + option.value);
|
|
||||||
location.reload();
|
|
||||||
});
|
|
||||||
|
|
||||||
dirContainer.appendChild(tocItem);
|
|
||||||
});
|
|
||||||
|
|
||||||
tocList.appendChild(dirContainer);
|
|
||||||
}
|
|
||||||
}''
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include <ftxui/util/ref.hpp> // for Ref, ConstRef, StringRef
|
#include <ftxui/util/ref.hpp> // for Ref, ConstRef, StringRef
|
||||||
#include <ftxui/util/warn_windows_macro.hpp>
|
#include <ftxui/util/warn_windows_macro.hpp>
|
||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
#include <limits> // for numeric_limits
|
|
||||||
#include <string> // for string
|
#include <string> // for string
|
||||||
|
|
||||||
#include "ftxui/component/component_base.hpp" // for Component
|
#include "ftxui/component/component_base.hpp" // for Component
|
||||||
@@ -218,10 +217,6 @@ struct ResizableSplitOption {
|
|||||||
(direction() == Direction::Left || direction() == Direction::Right) ? 20
|
(direction() == Direction::Left || direction() == Direction::Right) ? 20
|
||||||
: 10;
|
: 10;
|
||||||
std::function<Element()> separator_func = [] { return ::ftxui::separator(); };
|
std::function<Element()> separator_func = [] { return ::ftxui::separator(); };
|
||||||
|
|
||||||
// Constraints on main_size:
|
|
||||||
Ref<int> min = 0;
|
|
||||||
Ref<int> max = std::numeric_limits<int>::max();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// @brief Option for the `Slider` component.
|
// @brief Option for the `Slider` component.
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
#ifndef FTXUI_COMPONENT_RECEIVER_HPP_
|
#ifndef FTXUI_COMPONENT_RECEIVER_HPP_
|
||||||
#define FTXUI_COMPONENT_RECEIVER_HPP_
|
#define FTXUI_COMPONENT_RECEIVER_HPP_
|
||||||
|
|
||||||
|
#include <ftxui/util/warn_windows_macro.h>
|
||||||
#include <algorithm> // for copy, max
|
#include <algorithm> // for copy, max
|
||||||
#include <atomic> // for atomic, __atomic_base
|
#include <atomic> // for atomic, __atomic_base
|
||||||
#include <condition_variable> // for condition_variable
|
#include <condition_variable> // for condition_variable
|
||||||
#include <ftxui/util/warn_windows_macro.hpp>
|
#include <memory> // for unique_ptr, make_unique
|
||||||
#include <memory> // for unique_ptr, make_unique
|
#include <mutex> // for mutex, unique_lock
|
||||||
#include <mutex> // for mutex, unique_lock
|
#include <queue> // for queue
|
||||||
#include <queue> // for queue
|
#include <utility> // for move
|
||||||
#include <utility> // for move
|
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
|
|||||||
@@ -147,8 +147,6 @@ class ScreenInteractive : public Screen {
|
|||||||
|
|
||||||
// Piped input handling state (POSIX only)
|
// Piped input handling state (POSIX only)
|
||||||
bool handle_piped_input_ = true;
|
bool handle_piped_input_ = true;
|
||||||
// File descriptor for /dev/tty, used for piped input handling.
|
|
||||||
int tty_fd_ = -1;
|
|
||||||
|
|
||||||
// The style of the cursor to restore on exit.
|
// The style of the cursor to restore on exit.
|
||||||
int cursor_reset_shape_ = 1;
|
int cursor_reset_shape_ = 1;
|
||||||
|
|||||||
@@ -5,18 +5,25 @@
|
|||||||
#define FTXUI_DOM_TAKE_ANY_ARGS_HPP
|
#define FTXUI_DOM_TAKE_ANY_ARGS_HPP
|
||||||
|
|
||||||
// IWYU pragma: private, include "ftxui/dom/elements.hpp"
|
// IWYU pragma: private, include "ftxui/dom/elements.hpp"
|
||||||
#include <deque>
|
|
||||||
#include <ftxui/dom/node.hpp>
|
#include <ftxui/dom/node.hpp>
|
||||||
#include <queue>
|
|
||||||
#include <stack>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void Merge(Elements& /*container*/, T /*element*/) {}
|
||||||
|
|
||||||
|
template <>
|
||||||
inline void Merge(Elements& container, Element element) {
|
inline void Merge(Elements& container, Element element) {
|
||||||
container.push_back(std::move(element));
|
container.push_back(std::move(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline void Merge(Elements& container, Elements elements) {
|
||||||
|
for (auto& element : elements) {
|
||||||
|
container.push_back(std::move(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Turn a set of arguments into a vector.
|
// Turn a set of arguments into a vector.
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
Elements unpack(Args... args) {
|
Elements unpack(Args... args) {
|
||||||
@@ -25,50 +32,11 @@ Elements unpack(Args... args) {
|
|||||||
return vec;
|
return vec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make |container| able to take any number of arguments.
|
// Make |container| able to take any number of argments.
|
||||||
#define TAKE_ANY_ARGS(container) \
|
#define TAKE_ANY_ARGS(container) \
|
||||||
inline Element container(Element child) { \
|
|
||||||
return container(unpack(std::move(child))); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
template <class... Args> \
|
template <class... Args> \
|
||||||
inline Element container(Args... children) { \
|
Element container(Args... children) { \
|
||||||
return container(unpack(std::forward<Args>(children)...)); \
|
return container(unpack(std::forward<Args>(children)...)); \
|
||||||
} \
|
|
||||||
\
|
|
||||||
template <class Container> \
|
|
||||||
inline Element container(Container&& children) { \
|
|
||||||
Elements elements; \
|
|
||||||
for (auto& child : children) { \
|
|
||||||
elements.push_back(std::move(child)); \
|
|
||||||
} \
|
|
||||||
return container(std::move(elements)); \
|
|
||||||
} \
|
|
||||||
template <> \
|
|
||||||
inline Element container(std::stack<Element>&& children) { \
|
|
||||||
Elements elements; \
|
|
||||||
while (!children.empty()) { \
|
|
||||||
elements.push_back(std::move(children.top())); \
|
|
||||||
children.pop(); \
|
|
||||||
} \
|
|
||||||
return container(std::move(elements)); \
|
|
||||||
} \
|
|
||||||
template <> \
|
|
||||||
inline Element container(std::queue<Element>&& children) { \
|
|
||||||
Elements elements; \
|
|
||||||
while (!children.empty()) { \
|
|
||||||
elements.push_back(std::move(children.front())); \
|
|
||||||
children.pop(); \
|
|
||||||
} \
|
|
||||||
return container(std::move(elements)); \
|
|
||||||
} \
|
|
||||||
template <> \
|
|
||||||
inline Element container(std::deque<Element>&& children) { \
|
|
||||||
Elements elements; \
|
|
||||||
for (auto& child : children) { \
|
|
||||||
elements.push_back(std::move(child)); \
|
|
||||||
} \
|
|
||||||
return container(std::move(elements)); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TAKE_ANY_ARGS(vbox)
|
TAKE_ANY_ARGS(vbox)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class Screen : public Image {
|
|||||||
BarBlinking = 5,
|
BarBlinking = 5,
|
||||||
Bar = 6,
|
Bar = 6,
|
||||||
};
|
};
|
||||||
Shape shape = Hidden;
|
Shape shape;
|
||||||
};
|
};
|
||||||
|
|
||||||
Cursor cursor() const { return cursor_; }
|
Cursor cursor() const { return cursor_; }
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
export module ftxui.component;
|
export module ftxui.component;
|
||||||
|
|
||||||
export import :Animation;
|
export import ftxui.component.animation;
|
||||||
export import :CapturedMouse;
|
export import ftxui.component.captured_mouse;
|
||||||
export import :Component;
|
export import ftxui.component.component;
|
||||||
export import :ComponentBase;
|
export import ftxui.component.component_base;
|
||||||
export import :ComponentOptions;
|
export import ftxui.component.component_options;
|
||||||
export import :Event;
|
export import ftxui.component.event;
|
||||||
export import :Loop;
|
export import ftxui.component.loop;
|
||||||
export import :Mouse;
|
export import ftxui.component.mouse;
|
||||||
export import :Receiver;
|
export import ftxui.component.receiver;
|
||||||
export import :ScreenInteractive;
|
export import ftxui.component.screen_interactive;
|
||||||
export import :Task;
|
export import ftxui.component.task;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/// @module ftxui.component:Animation
|
/// @module ftxui.component.animation
|
||||||
/// @brief C++20 module interface for the Animation namespace of the Component module.
|
/// @brief C++20 module interface for the Animation namespace of the Component module.
|
||||||
///
|
///
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ module;
|
|||||||
|
|
||||||
#include <ftxui/component/animation.hpp>
|
#include <ftxui/component/animation.hpp>
|
||||||
|
|
||||||
export module ftxui.component:Animation;
|
export module ftxui.component.animation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui::animation
|
* @namespace ftxui::animation
|
||||||
@@ -23,7 +23,7 @@ export namespace ftxui::animation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace easing
|
* @namespace easing
|
||||||
* @brief The FTXUI ftxui::animation::easing:: namespace
|
* @brief The FTXUI sf::animation::easing:: namespace
|
||||||
*/
|
*/
|
||||||
namespace easing {
|
namespace easing {
|
||||||
using ftxui::animation::easing::Function;
|
using ftxui::animation::easing::Function;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component.CapturedMouse
|
/// @module ftxui.component.captured_mouse
|
||||||
/// @brief Module file for the CapturedMouseInterface class of the Component module
|
/// @brief Module file for the CapturedMouseInterface class of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/captured_mouse.hpp>
|
#include <ftxui/component/captured_mouse.hpp>
|
||||||
|
|
||||||
export module ftxui.component:CapturedMouse;
|
export module ftxui.component.captured_mouse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:Component
|
/// @module ftxui.component.component
|
||||||
/// @brief Module file for the Component classes of the Component module
|
/// @brief Module file for the Component classes of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/component.hpp>
|
#include <ftxui/component/component.hpp>
|
||||||
|
|
||||||
export module ftxui.component:Component;
|
export module ftxui.component.component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
@@ -28,10 +28,6 @@ export namespace ftxui {
|
|||||||
using ftxui::operator|;
|
using ftxui::operator|;
|
||||||
using ftxui::operator|=;
|
using ftxui::operator|=;
|
||||||
|
|
||||||
/**
|
|
||||||
* @namespace Container
|
|
||||||
* @brief The FTXUI ftxui::Container:: namespace
|
|
||||||
*/
|
|
||||||
namespace Container {
|
namespace Container {
|
||||||
using ftxui::Container::Vertical;
|
using ftxui::Container::Vertical;
|
||||||
using ftxui::Container::Horizontal;
|
using ftxui::Container::Horizontal;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:ComponentBase
|
/// @module ftxui.component.component_base
|
||||||
/// @brief Module file for the ComponentBase class of the Component module
|
/// @brief Module file for the ComponentBase class of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/component_base.hpp>
|
#include <ftxui/component/component_base.hpp>
|
||||||
|
|
||||||
export module ftxui.component:ComponentBase;
|
export module ftxui.component.component_base;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
@@ -16,10 +16,6 @@ export namespace ftxui {
|
|||||||
using ftxui::Focus;
|
using ftxui::Focus;
|
||||||
using ftxui::Event;
|
using ftxui::Event;
|
||||||
|
|
||||||
/**
|
|
||||||
* @namespace animation
|
|
||||||
* @brief The FTXUI ftxui::animation:: namespace
|
|
||||||
*/
|
|
||||||
namespace animation {
|
namespace animation {
|
||||||
using ftxui::animation::Params;
|
using ftxui::animation::Params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:ComponentOptions
|
/// @module ftxui.component.component_options
|
||||||
/// @brief Module file for options for the Component class of the Component module
|
/// @brief Module file for options for the Component class of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/component_options.hpp>
|
#include <ftxui/component/component_options.hpp>
|
||||||
|
|
||||||
export module ftxui.component:ComponentOptions;
|
export module ftxui.component.component_options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:Event
|
/// @module ftxui.component.event
|
||||||
/// @brief Module file for the Event struct of the Component module
|
/// @brief Module file for the Event struct of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/event.hpp>
|
#include <ftxui/component/event.hpp>
|
||||||
|
|
||||||
export module ftxui.component:Event;
|
export module ftxui.component.event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ class InputBase : public ComponentBase, public InputOption {
|
|||||||
elements.push_back(element);
|
elements.push_back(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto element = vbox(std::move(elements)) | frame;
|
auto element = vbox(std::move(elements), cursor_line) | frame;
|
||||||
return transform_func({
|
return transform_func({
|
||||||
std::move(element), hovered_, is_focused,
|
std::move(element), hovered_, is_focused,
|
||||||
false // placeholder
|
false // placeholder
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:Loop
|
/// @module ftxui.component.loop
|
||||||
/// @brief Module file for the Loop class of the Component module
|
/// @brief Module file for the Loop class of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/loop.hpp>
|
#include <ftxui/component/loop.hpp>
|
||||||
|
|
||||||
export module ftxui.component:Loop;
|
export module ftxui.component.loop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ class MenuBase : public ComponentBase, public MenuOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Element bar = IsHorizontal()
|
const Element bar = IsHorizontal()
|
||||||
? hbox(std::move(elements))
|
? hbox(std::move(elements), selected_focus_)
|
||||||
: vbox(std::move(elements));
|
: vbox(std::move(elements), selected_focus_);
|
||||||
|
|
||||||
if (!underline.enabled) {
|
if (!underline.enabled) {
|
||||||
return bar | reflect(box_);
|
return bar | reflect(box_);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:Mouse
|
/// @module ftxui.component.mouse
|
||||||
/// @brief Module file for the Mouse struct of the Component module
|
/// @brief Module file for the Mouse struct of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/mouse.hpp>
|
#include <ftxui/component/mouse.hpp>
|
||||||
|
|
||||||
export module ftxui.component:Mouse;
|
export module ftxui.component.mouse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class RadioboxBase : public ComponentBase, public RadioboxOption {
|
|||||||
}
|
}
|
||||||
elements.push_back(element | reflect(boxes_[i]));
|
elements.push_back(element | reflect(boxes_[i]));
|
||||||
}
|
}
|
||||||
return vbox(std::move(elements)) | reflect(box_);
|
return vbox(std::move(elements), hovered_) | reflect(box_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:Receiver
|
/// @module ftxui.component.receiver
|
||||||
/// @brief Module file for the Receiver class of the Component module
|
/// @brief Module file for the Receiver class of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/receiver.hpp>
|
#include <ftxui/component/receiver.hpp>
|
||||||
|
|
||||||
export module ftxui.component:Receiver;
|
export module ftxui.component.receiver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include <algorithm> // for max
|
|
||||||
#include <ftxui/component/component_options.hpp> // for ResizableSplitOption
|
#include <ftxui/component/component_options.hpp> // for ResizableSplitOption
|
||||||
#include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up
|
#include <ftxui/dom/direction.hpp> // for Direction, Direction::Down, Direction::Left, Direction::Right, Direction::Up
|
||||||
#include <ftxui/util/ref.hpp> // for Ref
|
#include <ftxui/util/ref.hpp> // for Ref
|
||||||
@@ -19,22 +18,34 @@
|
|||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class ResizableSplitBase : public ComponentBase, public ResizableSplitOption {
|
class ResizableSplitBase : public ComponentBase {
|
||||||
public:
|
public:
|
||||||
explicit ResizableSplitBase(ResizableSplitOption options)
|
explicit ResizableSplitBase(ResizableSplitOption options)
|
||||||
: ResizableSplitOption(std::move(options)) {
|
: options_(std::move(options)) {
|
||||||
switch (direction()) {
|
switch (options_->direction()) {
|
||||||
case Direction::Left:
|
case Direction::Left:
|
||||||
Add(Container::Horizontal({main, back}));
|
Add(Container::Horizontal({
|
||||||
|
options_->main,
|
||||||
|
options_->back,
|
||||||
|
}));
|
||||||
break;
|
break;
|
||||||
case Direction::Right:
|
case Direction::Right:
|
||||||
Add(Container::Horizontal({back, main}));
|
Add(Container::Horizontal({
|
||||||
|
options_->back,
|
||||||
|
options_->main,
|
||||||
|
}));
|
||||||
break;
|
break;
|
||||||
case Direction::Up:
|
case Direction::Up:
|
||||||
Add(Container::Vertical({main, back}));
|
Add(Container::Vertical({
|
||||||
|
options_->main,
|
||||||
|
options_->back,
|
||||||
|
}));
|
||||||
break;
|
break;
|
||||||
case Direction::Down:
|
case Direction::Down:
|
||||||
Add(Container::Vertical({back, main}));
|
Add(Container::Vertical({
|
||||||
|
options_->back,
|
||||||
|
options_->main,
|
||||||
|
}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,27 +75,27 @@ class ResizableSplitBase : public ComponentBase, public ResizableSplitOption {
|
|||||||
return ComponentBase::OnEvent(event);
|
return ComponentBase::OnEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (direction()) {
|
switch (options_->direction()) {
|
||||||
case Direction::Left:
|
case Direction::Left:
|
||||||
main_size() = std::max(0, event.mouse().x - box_.x_min);
|
options_->main_size() = std::max(0, event.mouse().x - box_.x_min);
|
||||||
break;
|
return true;
|
||||||
case Direction::Right:
|
case Direction::Right:
|
||||||
main_size() = std::max(0, box_.x_max - event.mouse().x);
|
options_->main_size() = std::max(0, box_.x_max - event.mouse().x);
|
||||||
break;
|
return true;
|
||||||
case Direction::Up:
|
case Direction::Up:
|
||||||
main_size() = std::max(0, event.mouse().y - box_.y_min);
|
options_->main_size() = std::max(0, event.mouse().y - box_.y_min);
|
||||||
break;
|
return true;
|
||||||
case Direction::Down:
|
case Direction::Down:
|
||||||
main_size() = std::max(0, box_.y_max - event.mouse().y);
|
options_->main_size() = std::max(0, box_.y_max - event.mouse().y);
|
||||||
break;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
main_size() = std::clamp(main_size(), min(), max());
|
// NOTREACHED()
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element OnRender() final {
|
Element OnRender() final {
|
||||||
switch (direction()) {
|
switch (options_->direction()) {
|
||||||
case Direction::Left:
|
case Direction::Left:
|
||||||
return RenderLeft();
|
return RenderLeft();
|
||||||
case Direction::Right:
|
case Direction::Right:
|
||||||
@@ -100,41 +111,46 @@ class ResizableSplitBase : public ComponentBase, public ResizableSplitOption {
|
|||||||
|
|
||||||
Element RenderLeft() {
|
Element RenderLeft() {
|
||||||
return hbox({
|
return hbox({
|
||||||
main->Render() | size(WIDTH, EQUAL, main_size()),
|
options_->main->Render() |
|
||||||
separator_func() | reflect(separator_box_),
|
size(WIDTH, EQUAL, options_->main_size()),
|
||||||
back->Render() | xflex,
|
options_->separator_func() | reflect(separator_box_),
|
||||||
|
options_->back->Render() | xflex,
|
||||||
}) |
|
}) |
|
||||||
reflect(box_);
|
reflect(box_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element RenderRight() {
|
Element RenderRight() {
|
||||||
return hbox({
|
return hbox({
|
||||||
back->Render() | xflex,
|
options_->back->Render() | xflex,
|
||||||
separator_func() | reflect(separator_box_),
|
options_->separator_func() | reflect(separator_box_),
|
||||||
main->Render() | size(WIDTH, EQUAL, main_size()),
|
options_->main->Render() |
|
||||||
|
size(WIDTH, EQUAL, options_->main_size()),
|
||||||
}) |
|
}) |
|
||||||
reflect(box_);
|
reflect(box_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element RenderTop() {
|
Element RenderTop() {
|
||||||
return vbox({
|
return vbox({
|
||||||
main->Render() | size(HEIGHT, EQUAL, main_size()),
|
options_->main->Render() |
|
||||||
separator_func() | reflect(separator_box_),
|
size(HEIGHT, EQUAL, options_->main_size()),
|
||||||
back->Render() | yflex,
|
options_->separator_func() | reflect(separator_box_),
|
||||||
|
options_->back->Render() | yflex,
|
||||||
}) |
|
}) |
|
||||||
reflect(box_);
|
reflect(box_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element RenderBottom() {
|
Element RenderBottom() {
|
||||||
return vbox({
|
return vbox({
|
||||||
back->Render() | yflex,
|
options_->back->Render() | yflex,
|
||||||
separator_func() | reflect(separator_box_),
|
options_->separator_func() | reflect(separator_box_),
|
||||||
main->Render() | size(HEIGHT, EQUAL, main_size()),
|
options_->main->Render() |
|
||||||
|
size(HEIGHT, EQUAL, options_->main_size()),
|
||||||
}) |
|
}) |
|
||||||
reflect(box_);
|
reflect(box_);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Ref<ResizableSplitOption> options_;
|
||||||
CapturedMouse captured_mouse_;
|
CapturedMouse captured_mouse_;
|
||||||
Box separator_box_;
|
Box separator_box_;
|
||||||
Box box_;
|
Box box_;
|
||||||
|
|||||||
@@ -233,105 +233,5 @@ TEST(ResizableSplit, NavigationVertical) {
|
|||||||
EXPECT_FALSE(component_bottom->Active());
|
EXPECT_FALSE(component_bottom->Active());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ResizableSplit, MinMaxSizeLeft) {
|
|
||||||
int position = 5;
|
|
||||||
auto component = ResizableSplit({
|
|
||||||
.main = BasicComponent(),
|
|
||||||
.back = BasicComponent(),
|
|
||||||
.direction = Direction::Left,
|
|
||||||
.main_size = &position,
|
|
||||||
.separator_func = [] { return separatorDouble(); },
|
|
||||||
.min = 3,
|
|
||||||
.max = 8,
|
|
||||||
});
|
|
||||||
auto screen = Screen(20, 20);
|
|
||||||
Render(screen, component->Render());
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(5, 1)));
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
// Try to resize below min
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(2, 1)));
|
|
||||||
EXPECT_EQ(position, 3); // Clamped to min
|
|
||||||
// Try to resize above max
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(10, 1)));
|
|
||||||
EXPECT_EQ(position, 8); // Clamped to max
|
|
||||||
EXPECT_TRUE(component->OnEvent(MouseReleased(10, 1)));
|
|
||||||
EXPECT_EQ(position, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(ResizableSplit, MinMaxSizeRight) {
|
|
||||||
int position = 5;
|
|
||||||
auto component = ResizableSplit({
|
|
||||||
.main = BasicComponent(),
|
|
||||||
.back = BasicComponent(),
|
|
||||||
.direction = Direction::Right,
|
|
||||||
.main_size = &position,
|
|
||||||
.separator_func = [] { return separatorDouble(); },
|
|
||||||
.min = 3,
|
|
||||||
.max = 8,
|
|
||||||
});
|
|
||||||
auto screen = Screen(20, 20);
|
|
||||||
Render(screen, component->Render());
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(14, 1)));
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
// Try to resize below min
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(18, 1)));
|
|
||||||
EXPECT_EQ(position, 3); // Clamped to min
|
|
||||||
// Try to resize above max
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(10, 1)));
|
|
||||||
EXPECT_EQ(position, 8); // Clamped to max
|
|
||||||
EXPECT_TRUE(component->OnEvent(MouseReleased(10, 1)));
|
|
||||||
EXPECT_EQ(position, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(ResizableSplit, MinMaxSizeTop) {
|
|
||||||
int position = 5;
|
|
||||||
auto component = ResizableSplit({
|
|
||||||
.main = BasicComponent(),
|
|
||||||
.back = BasicComponent(),
|
|
||||||
.direction = Direction::Up,
|
|
||||||
.main_size = &position,
|
|
||||||
.separator_func = [] { return separatorDouble(); },
|
|
||||||
.min = 2,
|
|
||||||
.max = 10,
|
|
||||||
});
|
|
||||||
auto screen = Screen(20, 20);
|
|
||||||
Render(screen, component->Render());
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(1, 5)));
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
// Try to resize below min
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(1, 1)));
|
|
||||||
EXPECT_EQ(position, 2); // Clamped to min
|
|
||||||
// Try to resize above max
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(1, 15)));
|
|
||||||
EXPECT_EQ(position, 10); // Clamped to max
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(ResizableSplit, MinMaxSizeBottom) {
|
|
||||||
int position = 5;
|
|
||||||
auto component = ResizableSplit({
|
|
||||||
.main = BasicComponent(),
|
|
||||||
.back = BasicComponent(),
|
|
||||||
.direction = Direction::Down,
|
|
||||||
.main_size = &position,
|
|
||||||
.separator_func = [] { return separatorDouble(); },
|
|
||||||
.min = 3,
|
|
||||||
.max = 12,
|
|
||||||
});
|
|
||||||
auto screen = Screen(20, 20);
|
|
||||||
Render(screen, component->Render());
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(1, 14)));
|
|
||||||
EXPECT_EQ(position, 5);
|
|
||||||
// Try to resize below min
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(1, 18)));
|
|
||||||
EXPECT_EQ(position, 3); // Clamped to min
|
|
||||||
// Try to resize above max
|
|
||||||
EXPECT_TRUE(component->OnEvent(MousePressed(1, 5)));
|
|
||||||
EXPECT_EQ(position, 12); // Clamped to max
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
// NOLINTEND
|
// NOLINTEND
|
||||||
|
|||||||
@@ -112,13 +112,13 @@ void ftxui_on_resize(int columns, int rows) {
|
|||||||
|
|
||||||
#else // POSIX (Linux & Mac)
|
#else // POSIX (Linux & Mac)
|
||||||
|
|
||||||
int CheckStdinReady(int fd) {
|
int CheckStdinReady() {
|
||||||
timeval tv = {0, 0}; // NOLINT
|
timeval tv = {0, 0}; // NOLINT
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
FD_ZERO(&fds); // NOLINT
|
FD_ZERO(&fds); // NOLINT
|
||||||
FD_SET(fd, &fds); // NOLINT
|
FD_SET(STDIN_FILENO, &fds); // NOLINT
|
||||||
select(fd + 1, &fds, nullptr, nullptr, &tv); // NOLINT
|
select(STDIN_FILENO + 1, &fds, nullptr, nullptr, &tv); // NOLINT
|
||||||
return FD_ISSET(fd, &fds); // NOLINT
|
return FD_ISSET(STDIN_FILENO, &fds); // NOLINT
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -539,8 +539,6 @@ void ScreenInteractive::Install() {
|
|||||||
// https://github.com/ArthurSonzogni/FTXUI/issues/846
|
// https://github.com/ArthurSonzogni/FTXUI/issues/846
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
InstallPipedInputHandling();
|
|
||||||
|
|
||||||
// After uninstalling the new configuration, flush it to the terminal to
|
// After uninstalling the new configuration, flush it to the terminal to
|
||||||
// ensure it is fully applied:
|
// ensure it is fully applied:
|
||||||
on_exit_functions.emplace([] { Flush(); });
|
on_exit_functions.emplace([] { Flush(); });
|
||||||
@@ -606,10 +604,9 @@ void ScreenInteractive::Install() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct termios terminal; // NOLINT
|
struct termios terminal; // NOLINT
|
||||||
tcgetattr(tty_fd_, &terminal);
|
tcgetattr(STDIN_FILENO, &terminal);
|
||||||
on_exit_functions.emplace([terminal = terminal, tty_fd_ = tty_fd_] {
|
on_exit_functions.emplace(
|
||||||
tcsetattr(tty_fd_, TCSANOW, &terminal);
|
[=] { tcsetattr(STDIN_FILENO, TCSANOW, &terminal); });
|
||||||
});
|
|
||||||
|
|
||||||
// Enabling raw terminal input mode
|
// Enabling raw terminal input mode
|
||||||
terminal.c_iflag &= ~IGNBRK; // Disable ignoring break condition
|
terminal.c_iflag &= ~IGNBRK; // Disable ignoring break condition
|
||||||
@@ -637,7 +634,7 @@ void ScreenInteractive::Install() {
|
|||||||
// read.
|
// read.
|
||||||
terminal.c_cc[VTIME] = 0; // Timeout in deciseconds for non-canonical read.
|
terminal.c_cc[VTIME] = 0; // Timeout in deciseconds for non-canonical read.
|
||||||
|
|
||||||
tcsetattr(tty_fd_, TCSANOW, &terminal);
|
tcsetattr(STDIN_FILENO, TCSANOW, &terminal);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -673,6 +670,14 @@ void ScreenInteractive::Install() {
|
|||||||
// ensure it is fully applied:
|
// ensure it is fully applied:
|
||||||
Flush();
|
Flush();
|
||||||
|
|
||||||
|
// Redirect the true terminal to stdin, so that we can read keyboard input
|
||||||
|
// directly from stdin, even if the input is piped from a file or another
|
||||||
|
// process.
|
||||||
|
//
|
||||||
|
// TODO: Instead of redirecting stdin, we could define the file descriptor to
|
||||||
|
// read from, and use it in the TerminalInputParser.
|
||||||
|
InstallPipedInputHandling();
|
||||||
|
|
||||||
quit_ = false;
|
quit_ = false;
|
||||||
|
|
||||||
PostAnimationTask();
|
PostAnimationTask();
|
||||||
@@ -680,7 +685,6 @@ void ScreenInteractive::Install() {
|
|||||||
|
|
||||||
void ScreenInteractive::InstallPipedInputHandling() {
|
void ScreenInteractive::InstallPipedInputHandling() {
|
||||||
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
|
||||||
tty_fd_ = STDIN_FILENO;
|
|
||||||
// Handle piped input redirection if explicitly enabled by the application.
|
// Handle piped input redirection if explicitly enabled by the application.
|
||||||
// This allows applications to read data from stdin while still receiving
|
// This allows applications to read data from stdin while still receiving
|
||||||
// keyboard input from the terminal for interactive use.
|
// keyboard input from the terminal for interactive use.
|
||||||
@@ -688,23 +692,29 @@ void ScreenInteractive::InstallPipedInputHandling() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If stdin is a terminal, we don't need to open /dev/tty.
|
// If stdin is a terminal, we don't need to redirect it.
|
||||||
if (isatty(STDIN_FILENO)) {
|
if (isatty(STDIN_FILENO)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open /dev/tty for keyboard input.
|
// Save the current stdin so we can restore it later.
|
||||||
tty_fd_ = open("/dev/tty", O_RDONLY);
|
int original_fd = dup(STDIN_FILENO);
|
||||||
if (tty_fd_ < 0) {
|
if (original_fd < 0) {
|
||||||
// Failed to open /dev/tty (containers, headless systems, etc.)
|
|
||||||
tty_fd_ = STDIN_FILENO; // Fallback to stdin.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the /dev/tty file descriptor on exit.
|
// Redirect stdin to the controlling terminal for keyboard input.
|
||||||
on_exit_functions.emplace([this] {
|
if (std::freopen("/dev/tty", "r", stdin) == nullptr) {
|
||||||
close(tty_fd_);
|
// Failed to open /dev/tty (containers, headless systems, etc.)
|
||||||
tty_fd_ = -1;
|
// Clean up and continue without redirection
|
||||||
|
close(original_fd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore the original stdin file descriptor on exit.
|
||||||
|
on_exit_functions.emplace([=] {
|
||||||
|
dup2(original_fd, STDIN_FILENO);
|
||||||
|
close(original_fd);
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1142,7 +1152,7 @@ void ScreenInteractive::FetchTerminalEvents() {
|
|||||||
internal_->terminal_input_parser.Add(out[i]);
|
internal_->terminal_input_parser.Add(out[i]);
|
||||||
}
|
}
|
||||||
#else // POSIX (Linux & Mac)
|
#else // POSIX (Linux & Mac)
|
||||||
if (!CheckStdinReady(tty_fd_)) {
|
if (!CheckStdinReady()) {
|
||||||
const auto timeout =
|
const auto timeout =
|
||||||
std::chrono::steady_clock::now() - internal_->last_char_time;
|
std::chrono::steady_clock::now() - internal_->last_char_time;
|
||||||
const size_t timeout_ms =
|
const size_t timeout_ms =
|
||||||
@@ -1154,7 +1164,7 @@ void ScreenInteractive::FetchTerminalEvents() {
|
|||||||
|
|
||||||
// Read chars from the terminal.
|
// Read chars from the terminal.
|
||||||
std::array<char, 128> out{};
|
std::array<char, 128> out{};
|
||||||
size_t l = read(tty_fd_, out.data(), out.size());
|
size_t l = read(fileno(stdin), out.data(), out.size());
|
||||||
|
|
||||||
// Convert the chars to events.
|
// Convert the chars to events.
|
||||||
for (size_t i = 0; i < l; ++i) {
|
for (size_t i = 0; i < l; ++i) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:ScreenInteractive
|
/// @module ftxui.component.screen_interactive
|
||||||
/// @brief Module file for the ScreenInteractive class of the Component module
|
/// @brief Module file for the ScreenInteractive class of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/screen_interactive.hpp>
|
#include <ftxui/component/screen_interactive.hpp>
|
||||||
|
|
||||||
export module ftxui.component:ScreenInteractive;
|
export module ftxui.component.screen_interactive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// Copyright 2025 Arthur Sonzogni. All rights reserved.
|
// Copyright 2025 Arthur Sonzogni. All rights reserved.
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include <fcntl.h>
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "ftxui/component/component.hpp"
|
#include "ftxui/component/component.hpp"
|
||||||
#include "ftxui/component/screen_interactive.hpp"
|
#include "ftxui/component/screen_interactive.hpp"
|
||||||
@@ -47,7 +47,7 @@ class PipedInputTest : public ::testing::Test {
|
|||||||
void WriteToPipedStdin(const std::string& data) {
|
void WriteToPipedStdin(const std::string& data) {
|
||||||
if (piped_stdin_setup_) {
|
if (piped_stdin_setup_) {
|
||||||
write(pipe_fds_[1], data.c_str(), data.length());
|
write(pipe_fds_[1], data.c_str(), data.length());
|
||||||
close(pipe_fds_[1]); // Close write end to signal EOF
|
close(pipe_fds_[1]); // Close write end to signal EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ TEST_F(PipedInputTest, ExplicitlyEnabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.HandlePipedInput(true); // Explicitly enable
|
screen.HandlePipedInput(true); // Explicitly enable
|
||||||
auto component = Renderer([] { return text("test"); });
|
auto component = Renderer([] { return text("test"); });
|
||||||
|
|
||||||
SetupPipedStdin();
|
SetupPipedStdin();
|
||||||
@@ -191,8 +191,7 @@ TEST_F(PipedInputTest, HandlePipedInputMethodBehavior) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Test the graceful fallback when /dev/tty is not available
|
// Test the graceful fallback when /dev/tty is not available
|
||||||
// This test simulates environments like containers where /dev/tty might not
|
// This test simulates environments like containers where /dev/tty might not exist
|
||||||
// exist
|
|
||||||
TEST_F(PipedInputTest, GracefulFallbackWhenTtyUnavailable) {
|
TEST_F(PipedInputTest, GracefulFallbackWhenTtyUnavailable) {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
auto component = Renderer([] { return text("test"); });
|
auto component = Renderer([] { return text("test"); });
|
||||||
@@ -200,9 +199,8 @@ TEST_F(PipedInputTest, GracefulFallbackWhenTtyUnavailable) {
|
|||||||
SetupPipedStdin();
|
SetupPipedStdin();
|
||||||
WriteToPipedStdin("test data\n");
|
WriteToPipedStdin("test data\n");
|
||||||
|
|
||||||
// This test doesn't directly mock /dev/tty unavailability since that's hard
|
// This test doesn't directly mock /dev/tty unavailability since that's hard to do
|
||||||
// to do in a unit test environment, but the code path handles freopen()
|
// in a unit test environment, but the code path handles freopen() failure gracefully
|
||||||
// failure gracefully
|
|
||||||
screen.Install();
|
screen.Install();
|
||||||
|
|
||||||
// The behavior depends on whether /dev/tty is available
|
// The behavior depends on whether /dev/tty is available
|
||||||
@@ -212,7 +210,7 @@ TEST_F(PipedInputTest, GracefulFallbackWhenTtyUnavailable) {
|
|||||||
screen.Uninstall();
|
screen.Uninstall();
|
||||||
|
|
||||||
// After uninstall, stdin should be restored
|
// After uninstall, stdin should be restored
|
||||||
EXPECT_FALSE(isatty(STDIN_FILENO)); // Should still be our test pipe
|
EXPECT_FALSE(isatty(STDIN_FILENO)); // Should still be our test pipe
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -33,20 +33,6 @@ Decorator flexDirection(Direction direction) {
|
|||||||
return xflex; // NOT_REACHED()
|
return xflex; // NOT_REACHED()
|
||||||
}
|
}
|
||||||
|
|
||||||
Direction Opposite(Direction d) {
|
|
||||||
switch (d) {
|
|
||||||
case Direction::Up:
|
|
||||||
return Direction::Down;
|
|
||||||
case Direction::Down:
|
|
||||||
return Direction::Up;
|
|
||||||
case Direction::Left:
|
|
||||||
return Direction::Right;
|
|
||||||
case Direction::Right:
|
|
||||||
return Direction::Left;
|
|
||||||
}
|
|
||||||
return d; // NOT_REACHED()
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class SliderBase : public SliderOption<T>, public ComponentBase {
|
class SliderBase : public SliderOption<T>, public ComponentBase {
|
||||||
public:
|
public:
|
||||||
@@ -61,15 +47,59 @@ class SliderBase : public SliderOption<T>, public ComponentBase {
|
|||||||
flexDirection(this->direction) | reflect(gauge_box_) | gauge_color;
|
flexDirection(this->direction) | reflect(gauge_box_) | gauge_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDirection(Direction pressed) {
|
void OnLeft() {
|
||||||
if (pressed == this->direction) {
|
switch (this->direction) {
|
||||||
this->value() += this->increment();
|
case Direction::Right:
|
||||||
return;
|
this->value() -= this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Left:
|
||||||
|
this->value() += this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Up:
|
||||||
|
case Direction::Down:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pressed == Opposite(this->direction)) {
|
void OnRight() {
|
||||||
this->value() -= this->increment();
|
switch (this->direction) {
|
||||||
return;
|
case Direction::Right:
|
||||||
|
this->value() += this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Left:
|
||||||
|
this->value() -= this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Up:
|
||||||
|
case Direction::Down:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnUp() {
|
||||||
|
switch (this->direction) {
|
||||||
|
case Direction::Up:
|
||||||
|
this->value() -= this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Down:
|
||||||
|
this->value() += this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Left:
|
||||||
|
case Direction::Right:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDown() {
|
||||||
|
switch (this->direction) {
|
||||||
|
case Direction::Down:
|
||||||
|
this->value() += this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Up:
|
||||||
|
this->value() -= this->increment();
|
||||||
|
break;
|
||||||
|
case Direction::Left:
|
||||||
|
case Direction::Right:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,16 +110,16 @@ class SliderBase : public SliderOption<T>, public ComponentBase {
|
|||||||
|
|
||||||
T old_value = this->value();
|
T old_value = this->value();
|
||||||
if (event == Event::ArrowLeft || event == Event::Character('h')) {
|
if (event == Event::ArrowLeft || event == Event::Character('h')) {
|
||||||
OnDirection(Direction::Left);
|
OnLeft();
|
||||||
}
|
}
|
||||||
if (event == Event::ArrowRight || event == Event::Character('l')) {
|
if (event == Event::ArrowRight || event == Event::Character('l')) {
|
||||||
OnDirection(Direction::Right);
|
OnRight();
|
||||||
}
|
}
|
||||||
if (event == Event::ArrowUp || event == Event::Character('k')) {
|
if (event == Event::ArrowUp || event == Event::Character('k')) {
|
||||||
OnDirection(Direction::Up);
|
OnDown();
|
||||||
}
|
}
|
||||||
if (event == Event::ArrowDown || event == Event::Character('j')) {
|
if (event == Event::ArrowDown || event == Event::Character('j')) {
|
||||||
OnDirection(Direction::Down);
|
OnUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->value() = std::max(this->min(), std::min(this->max(), this->value()));
|
this->value() = std::max(this->min(), std::min(this->max(), this->value()));
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.component:Task
|
/// @module ftxui.component.task
|
||||||
/// @brief Module file for the Task class of the Component module
|
/// @brief Module file for the Task class of the Component module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/component/task.hpp>
|
#include <ftxui/component/task.hpp>
|
||||||
|
|
||||||
export module ftxui.component:Task;
|
export module ftxui.component.task;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class TaskRunner {
|
|||||||
auto PostTask(Task task) -> void;
|
auto PostTask(Task task) -> void;
|
||||||
|
|
||||||
/// Schedules a task to be executed after a certain duration.
|
/// Schedules a task to be executed after a certain duration.
|
||||||
auto PostDelayedTask(Task task,
|
auto PostDelayedTask(Task task, std::chrono::steady_clock::duration duration)
|
||||||
std::chrono::steady_clock::duration duration) -> void;
|
-> void;
|
||||||
|
|
||||||
/// Runs the tasks in the queue, return the delay until the next delayed task
|
/// Runs the tasks in the queue, return the delay until the next delayed task
|
||||||
/// can be executed.
|
/// can be executed.
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
/// @module ftxui.dom
|
/// @module ftxui.dom
|
||||||
/// @brief Module file for FTXUI DOM operations.
|
/// @brief Module file for FTXUI main operations.
|
||||||
|
|
||||||
export module ftxui.dom;
|
export module ftxui.dom;
|
||||||
|
|
||||||
export import :Canvas;
|
export import ftxui.dom.canvas;
|
||||||
export import :Deprecated;
|
export import ftxui.dom.deprecated;
|
||||||
export import :Direction;
|
export import ftxui.dom.direction;
|
||||||
export import :Elements;
|
export import ftxui.dom.elements;
|
||||||
export import :FlexboxConfig;
|
export import ftxui.dom.flexbox_config;
|
||||||
export import :LinearGradient;
|
export import ftxui.dom.linear_gradient;
|
||||||
export import :Node;
|
export import ftxui.dom.node;
|
||||||
export import :Requirement;
|
export import ftxui.dom.requirement;
|
||||||
export import :Selection;
|
export import ftxui.dom.selection;
|
||||||
export import :Table;
|
export import ftxui.dom.table;
|
||||||
|
|||||||
@@ -4,18 +4,11 @@
|
|||||||
#include "ftxui/dom/box_helper.hpp"
|
#include "ftxui/dom/box_helper.hpp"
|
||||||
|
|
||||||
#include <algorithm> // for max
|
#include <algorithm> // for max
|
||||||
#include <cstdint>
|
#include <vector> // for vector
|
||||||
#include <vector> // for vector
|
|
||||||
|
|
||||||
namespace ftxui::box_helper {
|
namespace ftxui::box_helper {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int SafeRatio(int value, int numerator, int denominator) {
|
|
||||||
return static_cast<int64_t>(value) * static_cast<int64_t>(numerator) /
|
|
||||||
std::max(static_cast<int64_t>(denominator), static_cast<int64_t>(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when the size allowed is greater than the requested size. This
|
// Called when the size allowed is greater than the requested size. This
|
||||||
// distributes the extra spaces toward the flexible elements, in relative
|
// distributes the extra spaces toward the flexible elements, in relative
|
||||||
// proportions.
|
// proportions.
|
||||||
@@ -24,7 +17,7 @@ void ComputeGrow(std::vector<Element>* elements,
|
|||||||
int flex_grow_sum) {
|
int flex_grow_sum) {
|
||||||
for (Element& element : *elements) {
|
for (Element& element : *elements) {
|
||||||
const int added_space =
|
const int added_space =
|
||||||
SafeRatio(extra_space, element.flex_grow, flex_grow_sum);
|
extra_space * element.flex_grow / std::max(flex_grow_sum, 1);
|
||||||
extra_space -= added_space;
|
extra_space -= added_space;
|
||||||
flex_grow_sum -= element.flex_grow;
|
flex_grow_sum -= element.flex_grow;
|
||||||
element.size = element.min_size + added_space;
|
element.size = element.min_size + added_space;
|
||||||
@@ -38,8 +31,8 @@ void ComputeShrinkEasy(std::vector<Element>* elements,
|
|||||||
int extra_space,
|
int extra_space,
|
||||||
int flex_shrink_sum) {
|
int flex_shrink_sum) {
|
||||||
for (Element& element : *elements) {
|
for (Element& element : *elements) {
|
||||||
const int added_space = SafeRatio(
|
const int added_space = extra_space * element.min_size *
|
||||||
extra_space, element.min_size * element.flex_shrink, flex_shrink_sum);
|
element.flex_shrink / std::max(flex_shrink_sum, 1);
|
||||||
extra_space -= added_space;
|
extra_space -= added_space;
|
||||||
flex_shrink_sum -= element.flex_shrink * element.min_size;
|
flex_shrink_sum -= element.flex_shrink * element.min_size;
|
||||||
element.size = element.min_size + added_space;
|
element.size = element.min_size + added_space;
|
||||||
@@ -47,7 +40,7 @@ void ComputeShrinkEasy(std::vector<Element>* elements,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called when the size allowed is lower than the requested size, and the
|
// Called when the size allowed is lower than the requested size, and the
|
||||||
// shrinkable element can not absorb the (negative) extra_space. This assigns
|
// shrinkable element can not absorbe the (negative) extra_space. This assign
|
||||||
// zero to shrinkable elements and distribute the remaining (negative)
|
// zero to shrinkable elements and distribute the remaining (negative)
|
||||||
// extra_space toward the other non shrinkable elements.
|
// extra_space toward the other non shrinkable elements.
|
||||||
void ComputeShrinkHard(std::vector<Element>* elements,
|
void ComputeShrinkHard(std::vector<Element>* elements,
|
||||||
@@ -59,8 +52,7 @@ void ComputeShrinkHard(std::vector<Element>* elements,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int added_space = SafeRatio(extra_space, element.min_size, size);
|
const int added_space = extra_space * element.min_size / std::max(1, size);
|
||||||
|
|
||||||
extra_space -= added_space;
|
extra_space -= added_space;
|
||||||
size -= element.min_size;
|
size -= element.min_size;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Canvas
|
/// @module ftxui.dom.canvas
|
||||||
/// @brief Module file for the Canvas struct of the DOM module
|
/// @brief Module file for the Canvas struct of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/canvas.hpp>
|
#include <ftxui/dom/canvas.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Canvas;
|
export module ftxui.dom.canvas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Deprecated
|
/// @module ftxui.dom.deprecated
|
||||||
/// @brief Module file for deprecated parts of the DOM module
|
/// @brief Module file for deprecated parts of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/deprecated.hpp>
|
#include <ftxui/dom/deprecated.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Deprecated;
|
export module ftxui.dom.deprecated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Direction
|
/// @module ftxui.dom.direction
|
||||||
/// @brief Module file for the Direction enum of the Dom module
|
/// @brief Module file for the Direction enum of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/direction.hpp>
|
#include <ftxui/dom/direction.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Direction;
|
export module ftxui.dom.direction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Elements
|
/// @module ftxui.dom.elements
|
||||||
/// @brief Module file for the Element classes and functions of the DOM module
|
/// @brief Module file for the Element classes and functions of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/elements.hpp>
|
#include <ftxui/dom/elements.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Elements;
|
export module ftxui.dom.elements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:FlexboxConfig
|
/// @module ftxui.dom.flexbox_config
|
||||||
/// @brief Module file for the FlexboxConfig struct of the DOM module
|
/// @brief Module file for the FlexboxConfig struct of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/flexbox_config.hpp>
|
#include <ftxui/dom/flexbox_config.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:FlexboxConfig;
|
export module ftxui.dom.flexbox_config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -2,13 +2,9 @@
|
|||||||
// Use of this source code is governed by the MIT license that can be found in
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
// the LICENSE file.
|
// the LICENSE file.
|
||||||
#include <gtest/gtest.h> // for Test, TestInfo (ptr only), EXPECT_EQ, Message, TEST, TestPartResult
|
#include <gtest/gtest.h> // for Test, TestInfo (ptr only), EXPECT_EQ, Message, TEST, TestPartResult
|
||||||
#include <array> // for array
|
#include <cstddef> // for size_t
|
||||||
#include <cstddef> // for size_t
|
#include <string> // for allocator, basic_string, string
|
||||||
#include <queue>
|
#include <vector> // for vector
|
||||||
#include <stack> // for stack
|
|
||||||
#include <string> // for allocator, basic_string, string
|
|
||||||
#include <unordered_set> // for unordered_set
|
|
||||||
#include <vector> // for vector
|
|
||||||
|
|
||||||
#include "ftxui/dom/elements.hpp" // for text, operator|, Element, flex_grow, flex_shrink, hbox
|
#include "ftxui/dom/elements.hpp" // for text, operator|, Element, flex_grow, flex_shrink, hbox
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
@@ -362,39 +358,5 @@ TEST(HBoxTest, FlexGrow_NoFlex_FlewShrink) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, FromElementsContainer) {
|
|
||||||
Elements elements_vector{text("0"), text("1")};
|
|
||||||
|
|
||||||
std::array<Element, 2> elements_array{text("0"), text("1")};
|
|
||||||
|
|
||||||
std::deque<Element> elements_deque{text("0"), text("1")};
|
|
||||||
|
|
||||||
std::stack<Element> elements_stack;
|
|
||||||
elements_stack.push(text("1"));
|
|
||||||
elements_stack.push(text("0"));
|
|
||||||
|
|
||||||
std::queue<Element> elements_queue;
|
|
||||||
elements_queue.emplace(text("0"));
|
|
||||||
elements_queue.emplace(text("1"));
|
|
||||||
|
|
||||||
const std::vector<Element> collection_hboxes{
|
|
||||||
hbox(std::move(elements_vector)), hbox(std::move(elements_array)),
|
|
||||||
hbox(std::move(elements_stack)), hbox(std::move(elements_deque)),
|
|
||||||
hbox(std::move(elements_queue)),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const Element& collection_hbox : collection_hboxes) {
|
|
||||||
Screen screen(2, 1);
|
|
||||||
Render(screen, collection_hbox);
|
|
||||||
EXPECT_EQ("01", screen.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exception: unordered set, which has no guaranteed order.
|
|
||||||
std::unordered_set<Element> elements_set{text("0"), text("0")};
|
|
||||||
Screen screen(2, 1);
|
|
||||||
Render(screen, hbox(elements_set));
|
|
||||||
EXPECT_EQ("00", screen.ToString());
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
// NOLINTEND
|
// NOLINTEND
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:LinearGradient
|
/// @module ftxui.dom.linear_gradient
|
||||||
/// @brief Module file for the LinearGradient struct of the DOM module
|
/// @brief Module file for the LinearGradient struct of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/linear_gradient.hpp>
|
#include <ftxui/dom/linear_gradient.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:LinearGradient;
|
export module ftxui.dom.linear_gradient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Node
|
/// @module ftxui.dom.node
|
||||||
/// @brief Module file for the Node class of the DOM module
|
/// @brief Module file for the Node class of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/node.hpp>
|
#include <ftxui/dom/node.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Node;
|
export module ftxui.dom.node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Requirement
|
/// @module ftxui.dom.requirement
|
||||||
/// @brief Module file for the Requirement struct of the DOM module
|
/// @brief Module file for the Requirement struct of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/requirement.hpp>
|
#include <ftxui/dom/requirement.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Requirement;
|
export module ftxui.dom.requirement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Selection
|
/// @module ftxui.dom.selection
|
||||||
/// @brief Module file for the Selection class of the DOM module
|
/// @brief Module file for the Selection class of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/selection.hpp>
|
#include <ftxui/dom/selection.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Selection;
|
export module ftxui.dom.selection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class Size : public Node {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
/// @brief Apply a constraint on the size of an element.
|
/// @brief Apply a constraint on the size of an element.
|
||||||
/// @param direction Whether the WIDTH or the HEIGHT of the element must be
|
/// @param direction Whether the WIDTH of the HEIGHT of the element must be
|
||||||
/// constrained.
|
/// constrained.
|
||||||
/// @param constraint The type of constaint.
|
/// @param constraint The type of constaint.
|
||||||
/// @param value The value.
|
/// @param value The value.
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.dom:Table
|
/// @module ftxui.dom.table
|
||||||
/// @brief Module file for the Table class of the DOM module
|
/// @brief Module file for the Table class of the Dom module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/dom/table.hpp>
|
#include <ftxui/dom/table.hpp>
|
||||||
|
|
||||||
export module ftxui.dom:Table;
|
export module ftxui.dom.table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
export module ftxui.screen;
|
export module ftxui.screen;
|
||||||
|
|
||||||
export import :Box;
|
export import ftxui.screen.box;
|
||||||
export import :Color;
|
export import ftxui.screen.color;
|
||||||
export import :ColorInfo;
|
export import ftxui.screen.color_info;
|
||||||
export import :Deprecated;
|
export import ftxui.screen.deprecated;
|
||||||
export import :Image;
|
export import ftxui.screen.image;
|
||||||
export import :Pixel;
|
export import ftxui.screen.pixel;
|
||||||
export import :Screen;
|
export import ftxui.screen.screen;
|
||||||
export import :String;
|
export import ftxui.screen.string;
|
||||||
export import :Terminal;
|
export import ftxui.screen.terminal;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:Box
|
/// @module ftxui.screen.box
|
||||||
/// @brief Module file for the Box struct of the Screen module
|
/// @brief Module file for the Box struct of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/box.hpp>
|
#include <ftxui/screen/box.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:Box;
|
export module ftxui.screen.box;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:Color
|
/// @module ftxui.screen.color
|
||||||
/// @brief Module file for the Color class of the Screen module
|
/// @brief Module file for the Color class of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/color.hpp>
|
#include <ftxui/screen/color.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:Color;
|
export module ftxui.screen.color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
@@ -14,10 +14,6 @@ export module ftxui.screen:Color;
|
|||||||
export namespace ftxui {
|
export namespace ftxui {
|
||||||
using ftxui::Color;
|
using ftxui::Color;
|
||||||
|
|
||||||
/**
|
|
||||||
* @namespace literals
|
|
||||||
* @brief The FTXUI ftxui::literals:: namespace
|
|
||||||
*/
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
using ftxui::literals::operator""_rgb;
|
using ftxui::literals::operator""_rgb;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:ColorInfo
|
/// @module ftxui.screen.color_info
|
||||||
/// @brief Module file for the ColorInfo struct of the Screen module
|
/// @brief Module file for the ColorInfo struct of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/color_info.hpp>
|
#include <ftxui/screen/color_info.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:ColorInfo;
|
export module ftxui.screen.color_info;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:Deprecated
|
/// @module ftxui.screen.deprecated
|
||||||
/// @brief Module file for the deprecated parts of the Screen module
|
/// @brief Module file for the deprecated parts of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/deprecated.hpp>
|
#include <ftxui/screen/deprecated.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:Deprecated;
|
export module ftxui.screen.deprecated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:Image
|
/// @module ftxui.screen.image
|
||||||
/// @brief Module file for the Image class of the Screen module
|
/// @brief Module file for the Image class of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/image.hpp>
|
#include <ftxui/screen/image.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:Image;
|
export module ftxui.screen.image;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:Pixel
|
/// @module ftxui.screen.pixel
|
||||||
/// @brief Module file for the Pixel struct of the Screen module
|
/// @brief Module file for the Pixel struct of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/pixel.hpp>
|
#include <ftxui/screen/pixel.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:Pixel;
|
export module ftxui.screen.pixel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
/// @module ftxui.screen:Screen
|
/// @module ftxui.screen.screen
|
||||||
/// @brief Module file for the Screen class of the Screen module
|
/// @brief Module file for the Screen class of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/screen.hpp>
|
#include <ftxui/screen/screen.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:Screen;
|
export module ftxui.screen.screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
* @brief The FTXUI ftxui:: namespace
|
* @brief The FTXUI ftxui:: namespace
|
||||||
*/
|
*/
|
||||||
export namespace ftxui {
|
export namespace ftxui {
|
||||||
/**
|
|
||||||
* @namespace Dimension
|
|
||||||
* @brief The FTXUI ftxui::Dimension:: namespace
|
|
||||||
*/
|
|
||||||
namespace Dimension {
|
namespace Dimension {
|
||||||
using ftxui::Dimension::Fixed;
|
using ftxui::Dimension::Fixed;
|
||||||
using ftxui::Dimension::Full;
|
using ftxui::Dimension::Full;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:String
|
/// @module ftxui.screen.string
|
||||||
/// @brief Module file for string functions of the Screen module
|
/// @brief Module file for string functions of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/string.hpp>
|
#include <ftxui/screen/string.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:String;
|
export module ftxui.screen.string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.screen:Terminal
|
/// @module ftxui.screen.terminal
|
||||||
/// @brief Module file for the Terminal namespace of the Screen module
|
/// @brief Module file for the Terminal namespace of the Screen module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/screen/terminal.hpp>
|
#include <ftxui/screen/terminal.hpp>
|
||||||
|
|
||||||
export module ftxui.screen:Terminal;
|
export module ftxui.screen.terminal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
@@ -14,10 +14,6 @@ export module ftxui.screen:Terminal;
|
|||||||
export namespace ftxui {
|
export namespace ftxui {
|
||||||
using ftxui::Dimensions;
|
using ftxui::Dimensions;
|
||||||
|
|
||||||
/**
|
|
||||||
* @namespace Terminal
|
|
||||||
* @brief The FTXUI ftxui::Terminal:: namespace
|
|
||||||
*/
|
|
||||||
namespace Terminal {
|
namespace Terminal {
|
||||||
using ftxui::Terminal::Size;
|
using ftxui::Terminal::Size;
|
||||||
using ftxui::Terminal::SetFallbackSize;
|
using ftxui::Terminal::SetFallbackSize;
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
|
|
||||||
export module ftxui.util;
|
export module ftxui.util;
|
||||||
|
|
||||||
export import :AutoReset;
|
export import ftxui.util.autoreset;
|
||||||
export import :Ref;
|
export import ftxui.util.ref;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.util:AutoReset
|
/// @module ftxui.util.autoreset
|
||||||
/// @brief Module file for the AutoReset class of the Util module
|
/// @brief Module file for the AutoReset class of the Util module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/util/autoreset.hpp>
|
#include <ftxui/util/autoreset.hpp>
|
||||||
|
|
||||||
export module ftxui.util:AutoReset;
|
export module ftxui.util.autoreset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/// @module ftxui.util:Ref
|
/// @module ftxui.util.ref
|
||||||
/// @brief Module file for the Ref classes of the Util module
|
/// @brief Module file for the Ref classes of the Util module
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <ftxui/util/ref.hpp>
|
#include <ftxui/util/ref.hpp>
|
||||||
|
|
||||||
export module ftxui.util:Ref;
|
export module ftxui.util.ref;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace ftxui
|
* @namespace ftxui
|
||||||
|
|||||||
@@ -1,230 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import shutil
|
|
||||||
import tempfile
|
|
||||||
import json
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import List, Dict
|
|
||||||
|
|
||||||
class VersionInfo:
|
|
||||||
"""A structure to hold all information about a single documentation version."""
|
|
||||||
def __init__(self, name: str, is_main: bool, output_root: Path):
|
|
||||||
self.name = name
|
|
||||||
self.is_main = is_main
|
|
||||||
# Destination directory for the built docs, relative to the output root.
|
|
||||||
self.dest_dir = output_root if is_main else output_root / "en" / name
|
|
||||||
# The path to this version's index.html, relative to the output root.
|
|
||||||
self.index_path_from_root = self.dest_dir / "index.html"
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
return f"VersionInfo(name='{self.name}', dest_dir='{self.dest_dir}')"
|
|
||||||
|
|
||||||
def run_command(command: List[str], check: bool = True, cwd: Path = None):
|
|
||||||
"""
|
|
||||||
Runs a command, prints its output, and handles errors.
|
|
||||||
"""
|
|
||||||
command_str = ' '.join(command)
|
|
||||||
print(f"Executing: {command_str} in {cwd or Path.cwd()}")
|
|
||||||
try:
|
|
||||||
# Using capture_output=True to get stdout/stderr
|
|
||||||
result = subprocess.run(
|
|
||||||
command,
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
check=check,
|
|
||||||
cwd=cwd
|
|
||||||
)
|
|
||||||
if result.stdout:
|
|
||||||
print(result.stdout)
|
|
||||||
if result.stderr:
|
|
||||||
print(result.stderr)
|
|
||||||
return result
|
|
||||||
except subprocess.CalledProcessError as e:
|
|
||||||
print(f"ERROR: Command failed with exit code {e.returncode}")
|
|
||||||
print(f"Command: {command_str}")
|
|
||||||
if e.stdout:
|
|
||||||
print("--- STDOUT ---")
|
|
||||||
print(e.stdout)
|
|
||||||
if e.stderr:
|
|
||||||
print("--- STDERR ---")
|
|
||||||
print(e.stderr)
|
|
||||||
raise # Re-raise the exception to halt the script
|
|
||||||
|
|
||||||
def get_version_switcher_js(
|
|
||||||
current_version: VersionInfo,
|
|
||||||
all_versions: List[VersionInfo],
|
|
||||||
current_html_file: Path
|
|
||||||
) -> str:
|
|
||||||
"""
|
|
||||||
Generates the JavaScript for the version switcher dropdown.
|
|
||||||
|
|
||||||
This version pre-calculates the relative path from the current HTML file
|
|
||||||
to the index.html of every other version, simplifying the JS logic.
|
|
||||||
"""
|
|
||||||
version_names = [v.name for v in all_versions]
|
|
||||||
|
|
||||||
# Create a dictionary mapping version names to their relative URLs.
|
|
||||||
relative_paths: Dict[str, str] = {}
|
|
||||||
for version in all_versions:
|
|
||||||
# Calculate the relative path from the *parent directory* of the current HTML file
|
|
||||||
# to the target version's index.html.
|
|
||||||
path = os.path.relpath(version.index_path_from_root, current_html_file.parent)
|
|
||||||
relative_paths[version.name] = path
|
|
||||||
|
|
||||||
# Use json.dumps for safe serialization of data into JavaScript.
|
|
||||||
versions_json = json.dumps(version_names)
|
|
||||||
paths_json = json.dumps(relative_paths)
|
|
||||||
current_version_json = json.dumps(current_version.name)
|
|
||||||
|
|
||||||
return f"""
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {{
|
|
||||||
const projectNumber = document.getElementById('projectnumber');
|
|
||||||
if (!projectNumber) {{
|
|
||||||
console.warn('Doxygen element with ID "projectnumber" not found. Cannot add version switcher.');
|
|
||||||
return;
|
|
||||||
}}
|
|
||||||
|
|
||||||
const versions = {versions_json};
|
|
||||||
const version_paths = {paths_json};
|
|
||||||
const currentVersion = {current_version_json};
|
|
||||||
|
|
||||||
// Sort versions: 'main' first, then others numerically descending.
|
|
||||||
versions.sort((a, b) => {{
|
|
||||||
if (a === 'main') return -1;
|
|
||||||
if (b === 'main') return 1;
|
|
||||||
return b.localeCompare(a, undefined, {{ numeric: true, sensitivity: 'base' }});
|
|
||||||
}});
|
|
||||||
|
|
||||||
const select = document.createElement('select');
|
|
||||||
select.onchange = function() {{
|
|
||||||
const selectedVersion = this.value;
|
|
||||||
// Navigate directly to the pre-calculated relative path.
|
|
||||||
if (selectedVersion !== currentVersion) {{
|
|
||||||
window.location.href = version_paths[selectedVersion];
|
|
||||||
}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
versions.forEach(v => {{
|
|
||||||
const option = document.createElement('option');
|
|
||||||
option.value = v;
|
|
||||||
option.textContent = v;
|
|
||||||
if (v === currentVersion) {{
|
|
||||||
option.selected = true;
|
|
||||||
}}
|
|
||||||
select.appendChild(option);
|
|
||||||
}});
|
|
||||||
|
|
||||||
// Replace the Doxygen project number element with our dropdown.
|
|
||||||
projectNumber.replaceWith(select);
|
|
||||||
|
|
||||||
// Apply some styling to make it look good.
|
|
||||||
Object.assign(select.style, {{
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
||||||
color: 'white',
|
|
||||||
border: '1px solid rgba(255, 255, 255, 0.2)',
|
|
||||||
padding: '5px',
|
|
||||||
borderRadius: '5px',
|
|
||||||
fontSize: '14px',
|
|
||||||
fontFamily: 'inherit',
|
|
||||||
marginLeft: '10px',
|
|
||||||
cursor: 'pointer'
|
|
||||||
}});
|
|
||||||
}});
|
|
||||||
"""
|
|
||||||
|
|
||||||
def main():
|
|
||||||
"""Main function to build multi-version documentation."""
|
|
||||||
root_dir = Path.cwd()
|
|
||||||
output_dir = root_dir / "multiversion_docs"
|
|
||||||
|
|
||||||
print("--- 1. Cleaning up old documentation ---")
|
|
||||||
if output_dir.exists():
|
|
||||||
shutil.rmtree(output_dir)
|
|
||||||
output_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
print("--- 2. Getting versions from git ---")
|
|
||||||
git_tags_result = run_command(["git", "tag", "--list", "v*"])
|
|
||||||
# Create a list of version names, starting with 'main'.
|
|
||||||
version_names = ["main"] + sorted(
|
|
||||||
git_tags_result.stdout.splitlines(),
|
|
||||||
reverse=True
|
|
||||||
)
|
|
||||||
print(f"Versions to build: {', '.join(version_names)}")
|
|
||||||
|
|
||||||
# Pre-compute all version information and paths.
|
|
||||||
versions = [
|
|
||||||
VersionInfo(name, name == "main", output_dir)
|
|
||||||
for name in version_names
|
|
||||||
]
|
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as build_dir_str:
|
|
||||||
build_dir = Path(build_dir_str)
|
|
||||||
# --- 3. Build documentation for each version ---
|
|
||||||
for version in versions:
|
|
||||||
print(f"\n--- Building docs for version: {version.name} ---")
|
|
||||||
|
|
||||||
# Create a temporary directory for this version's source code.
|
|
||||||
version_src_dir = build_dir / f"src_{version.name}"
|
|
||||||
version_src_dir.mkdir()
|
|
||||||
|
|
||||||
# Check out the version's source code from git.
|
|
||||||
archive_path = version_src_dir / "source.tar"
|
|
||||||
run_command([
|
|
||||||
"git", "archive", version.name,
|
|
||||||
"--format=tar", f"--output={archive_path}"
|
|
||||||
])
|
|
||||||
run_command(["tar", "-xf", str(archive_path)], cwd=version_src_dir)
|
|
||||||
archive_path.unlink()
|
|
||||||
|
|
||||||
# Configure and build the docs using CMake.
|
|
||||||
version_build_dir = build_dir / f"build_{version.name}"
|
|
||||||
version_build_dir.mkdir()
|
|
||||||
run_command([ "cmake", str(version_src_dir), "-DFTXUI_BUILD_DOCS=ON", '-DFTXUI_BUILD_EXAMPLES=ON'], cwd=version_build_dir)
|
|
||||||
run_command(["make", "doc"], cwd=version_build_dir)
|
|
||||||
|
|
||||||
# Copy the generated HTML files to the final destination.
|
|
||||||
doxygen_html_dir = version_build_dir / "doc" / "doxygen" / "html"
|
|
||||||
if not doxygen_html_dir.is_dir():
|
|
||||||
print(f"FATAL: Doxygen HTML output not found for version {version.name}")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
print(f"Copying files to: {version.dest_dir}")
|
|
||||||
shutil.copytree(doxygen_html_dir, version.dest_dir, dirs_exist_ok=True)
|
|
||||||
|
|
||||||
# --- 4. Inject version switcher into all HTML files ---
|
|
||||||
print("\n--- Injecting version switcher JavaScript ---")
|
|
||||||
for version in versions:
|
|
||||||
if not version.dest_dir.exists():
|
|
||||||
print(f"Warning: Destination directory for {version.name} does not exist. Skipping JS injection.")
|
|
||||||
continue
|
|
||||||
|
|
||||||
print(f"Processing HTML files in: {version.dest_dir}")
|
|
||||||
|
|
||||||
html_files = []
|
|
||||||
if version.is_main:
|
|
||||||
# For the main version, find all HTML files, but explicitly exclude the 'en' directory.
|
|
||||||
html_files.extend(version.dest_dir.glob("*.html"))
|
|
||||||
for subdir in version.dest_dir.iterdir():
|
|
||||||
if subdir.is_dir() and subdir.name != 'en':
|
|
||||||
html_files.extend(subdir.rglob("*.html"))
|
|
||||||
else:
|
|
||||||
# For other versions, their directory is self-contained.
|
|
||||||
html_files = list(version.dest_dir.rglob("*.html"))
|
|
||||||
|
|
||||||
for html_file in html_files:
|
|
||||||
js_script = get_version_switcher_js(version, versions, html_file)
|
|
||||||
script_tag = f'<script>{js_script}</script>'
|
|
||||||
|
|
||||||
content = html_file.read_text(encoding='utf-8')
|
|
||||||
# Inject the script right before the closing body tag.
|
|
||||||
new_content = content.replace("</body>", f"{script_tag}\n</body>")
|
|
||||||
html_file.write_text(new_content, encoding='utf-8')
|
|
||||||
|
|
||||||
print("\n--- 5. Finalizing ---")
|
|
||||||
print("Multi-version documentation generated successfully!")
|
|
||||||
print(f"Output located in: {output_dir.resolve()}")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
Reference in New Issue
Block a user